Skip to content

Commit

Permalink
fix(core): make window.__TAURI__.invoke context free, fixes #1547 (#1565
Browse files Browse the repository at this point in the history
)
  • Loading branch information
lucasfernog committed Apr 21, 2021
1 parent c2e43ac commit be65f04
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changes/invoke-context.md
@@ -0,0 +1,5 @@
---
"tauri": patch
---

Allow `window.__TAURI__.invoke` to be moved to another variable.
2 changes: 1 addition & 1 deletion .github/workflows/test-core.yml
Expand Up @@ -10,7 +10,7 @@ on:
- '.github/workflows/test-core.yml'
- 'core/**'
- 'examples/**'
- 'cli/**'
- 'tooling/**'

env:
RUST_BACKTRACE: 1
Expand Down
6 changes: 2 additions & 4 deletions core/tauri/scripts/core.js
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion tooling/cli.js/jest.config.js
Expand Up @@ -42,5 +42,6 @@ module.exports = {
transform: {
'\\.toml$': 'jest-transform-toml',
'\\.(js|ts)$': 'babel-jest'
}
},
transformIgnorePatterns: ['node_modules/(?!(is-png|imagemin|p-pipe)/)']
}

0 comments on commit be65f04

Please sign in to comment.