From be65f04db7d2fce23477156ebba368a897ceee3c Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Wed, 21 Apr 2021 15:42:52 -0300 Subject: [PATCH] fix(core): make window.__TAURI__.invoke context free, fixes #1547 (#1565) --- .changes/invoke-context.md | 5 +++++ .github/workflows/test-core.yml | 2 +- core/tauri/scripts/core.js | 6 ++---- tooling/cli.js/jest.config.js | 3 ++- 4 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 .changes/invoke-context.md diff --git a/.changes/invoke-context.md b/.changes/invoke-context.md new file mode 100644 index 000000000..0c02aa4d2 --- /dev/null +++ b/.changes/invoke-context.md @@ -0,0 +1,5 @@ +--- +"tauri": patch +--- + +Allow `window.__TAURI__.invoke` to be moved to another variable. diff --git a/.github/workflows/test-core.yml b/.github/workflows/test-core.yml index 91de5c684..7aefb0060 100644 --- a/.github/workflows/test-core.yml +++ b/.github/workflows/test-core.yml @@ -10,7 +10,7 @@ on: - '.github/workflows/test-core.yml' - 'core/**' - 'examples/**' - - 'cli/**' + - 'tooling/**' env: RUST_BACKTRACE: 1 diff --git a/core/tauri/scripts/core.js b/core/tauri/scripts/core.js index ad16cd915..c8e5fdf41 100644 --- a/core/tauri/scripts/core.js +++ b/core/tauri/scripts/core.js @@ -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); diff --git a/tooling/cli.js/jest.config.js b/tooling/cli.js/jest.config.js index c9c77966a..2ff89abd6 100644 --- a/tooling/cli.js/jest.config.js +++ b/tooling/cli.js/jest.config.js @@ -42,5 +42,6 @@ module.exports = { transform: { '\\.toml$': 'jest-transform-toml', '\\.(js|ts)$': 'babel-jest' - } + }, + transformIgnorePatterns: ['node_modules/(?!(is-png|imagemin|p-pipe)/)'] }