fix(core): make window.__TAURI__.invoke context free, fixes #1547 (#1565)

This commit is contained in:
Lucas Fernandes Nogueira 2021-04-21 15:42:52 -03:00 committed by GitHub
parent c2e43ac66a
commit be65f04db7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 6 deletions

View File

@ -0,0 +1,5 @@
---
"tauri": patch
---
Allow `window.__TAURI__.invoke` to be moved to another variable.

View File

@ -10,7 +10,7 @@ on:
- '.github/workflows/test-core.yml'
- 'core/**'
- 'examples/**'
- 'cli/**'
- 'tooling/**'
env:
RUST_BACKTRACE: 1

View File

@ -93,14 +93,12 @@ if (!String.prototype.startsWith) {
};
window.__TAURI__.invoke = function invoke(cmd, args = {}) {
var _this = this;
return new Promise(function (resolve, reject) {
var callback = _this.transformCallback(function (r) {
var callback = window.__TAURI__.transformCallback(function (r) {
resolve(r);
delete window[error];
}, true);
var error = _this.transformCallback(function (e) {
var error = window.__TAURI__.transformCallback(function (e) {
reject(e);
delete window[callback];
}, true);

View File

@ -42,5 +42,6 @@ module.exports = {
transform: {
'\\.toml$': 'jest-transform-toml',
'\\.(js|ts)$': 'babel-jest'
}
},
transformIgnorePatterns: ['node_modules/(?!(is-png|imagemin|p-pipe)/)']
}