From 4bb51b3cc87b250ed0e5c5c69ce5f5cc99e07f71 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 18 Apr 2025 09:04:15 -0300 Subject: [PATCH 1/5] publish new versions (#2603) Co-authored-by: lucasfernog <20051258+lucasfernog@users.noreply.github.com> --- .changes/emit-traces.md | 5 ---- .changes/export-log-level.md | 6 ----- .changes/fern-dispatch-log-target.md | 6 ----- .changes/fix-ios-biometry-fallback-auth.md | 6 ----- .changes/fix-ios-log-simulator.md | 6 ----- .changes/updater-override-header.md | 6 ----- Cargo.lock | 8 +++---- examples/api/CHANGELOG.md | 8 +++++++ examples/api/package.json | 6 ++--- examples/api/src-tauri/CHANGELOG.md | 8 +++++++ examples/api/src-tauri/Cargo.toml | 8 +++---- plugins/biometric/CHANGELOG.md | 6 +++++ plugins/biometric/Cargo.toml | 2 +- plugins/biometric/package.json | 2 +- plugins/log/CHANGELOG.md | 10 ++++++++ plugins/log/Cargo.toml | 2 +- plugins/log/package.json | 2 +- plugins/updater/CHANGELOG.md | 4 ++++ plugins/updater/Cargo.toml | 2 +- plugins/updater/package.json | 2 +- pnpm-lock.yaml | 28 ++++++++++++---------- 21 files changed, 68 insertions(+), 65 deletions(-) delete mode 100644 .changes/emit-traces.md delete mode 100644 .changes/export-log-level.md delete mode 100644 .changes/fern-dispatch-log-target.md delete mode 100644 .changes/fix-ios-biometry-fallback-auth.md delete mode 100644 .changes/fix-ios-log-simulator.md delete mode 100644 .changes/updater-override-header.md diff --git a/.changes/emit-traces.md b/.changes/emit-traces.md deleted file mode 100644 index 569d2504..00000000 --- a/.changes/emit-traces.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'log': 'minor:feat' -'log-js': 'minor:feat' ---- -Add a `tracing` feature to the `log` plugin that emits log messages to the `tracing` system. diff --git a/.changes/export-log-level.md b/.changes/export-log-level.md deleted file mode 100644 index 11e0d93f..00000000 --- a/.changes/export-log-level.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"log": patch -"log-js": patch ---- - -Export the `LogLevel` type. diff --git a/.changes/fern-dispatch-log-target.md b/.changes/fern-dispatch-log-target.md deleted file mode 100644 index e21efc18..00000000 --- a/.changes/fern-dispatch-log-target.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -log: minor -log-js: minor ---- - -Adds a new varient `TargetKind::Dispatch` that allows you to construct arbitrary log targets diff --git a/.changes/fix-ios-biometry-fallback-auth.md b/.changes/fix-ios-biometry-fallback-auth.md deleted file mode 100644 index c01159f0..00000000 --- a/.changes/fix-ios-biometry-fallback-auth.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"biometric": patch:bug -"biometric-js": patch:bug ---- - -Fix biometric plugin ignoring fallback logic when biometry status is unavailable or not enrolled on iOS. diff --git a/.changes/fix-ios-log-simulator.md b/.changes/fix-ios-log-simulator.md deleted file mode 100644 index 1eda1d4c..00000000 --- a/.changes/fix-ios-log-simulator.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"log": patch -"log-js": patch ---- - -Fix iOS app stuck when using the iOS Simulator and the log plugin due to a deadlock when calling os_log too early. diff --git a/.changes/updater-override-header.md b/.changes/updater-override-header.md deleted file mode 100644 index 7da472b0..00000000 --- a/.changes/updater-override-header.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -updater: patch -updater-js: patch ---- - -Fix `check` and `download` overrides the `accept` header diff --git a/Cargo.lock b/Cargo.lock index e3a240a1..9956c98e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -207,7 +207,7 @@ checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" [[package]] name = "api" -version = "2.0.24" +version = "2.0.25" dependencies = [ "log", "serde", @@ -6508,7 +6508,7 @@ dependencies = [ [[package]] name = "tauri-plugin-biometric" -version = "2.2.0" +version = "2.2.1" dependencies = [ "log", "serde", @@ -6679,7 +6679,7 @@ dependencies = [ [[package]] name = "tauri-plugin-log" -version = "2.3.1" +version = "2.4.0" dependencies = [ "android_logger", "byte-unit", @@ -6892,7 +6892,7 @@ dependencies = [ [[package]] name = "tauri-plugin-updater" -version = "2.7.0" +version = "2.7.1" dependencies = [ "base64 0.22.1", "dirs 6.0.0", diff --git a/examples/api/CHANGELOG.md b/examples/api/CHANGELOG.md index 3da6506a..6ed56a11 100644 --- a/examples/api/CHANGELOG.md +++ b/examples/api/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## \[2.0.21] + +### Dependencies + +- Upgraded to `log-js@2.4.0` +- Upgraded to `biometric-js@2.2.1` +- Upgraded to `updater-js@2.7.1` + ## \[2.0.20] ### Dependencies diff --git a/examples/api/package.json b/examples/api/package.json index c9e30cf9..c367cb0b 100644 --- a/examples/api/package.json +++ b/examples/api/package.json @@ -1,7 +1,7 @@ { "name": "api", "private": true, - "version": "2.0.20", + "version": "2.0.21", "type": "module", "scripts": { "dev": "vite --clearScreen false", @@ -12,7 +12,7 @@ "dependencies": { "@tauri-apps/api": "2.5.0", "@tauri-apps/plugin-barcode-scanner": "^2.2.0", - "@tauri-apps/plugin-biometric": "^2.2.0", + "@tauri-apps/plugin-biometric": "^2.2.1", "@tauri-apps/plugin-cli": "^2.2.0", "@tauri-apps/plugin-clipboard-manager": "^2.2.2", "@tauri-apps/plugin-dialog": "^2.2.1", @@ -28,7 +28,7 @@ "@tauri-apps/plugin-process": "^2.2.1", "@tauri-apps/plugin-shell": "^2.2.1", "@tauri-apps/plugin-store": "^2.2.0", - "@tauri-apps/plugin-updater": "^2.7.0", + "@tauri-apps/plugin-updater": "^2.7.1", "@zerodevx/svelte-json-view": "1.0.11" }, "devDependencies": { diff --git a/examples/api/src-tauri/CHANGELOG.md b/examples/api/src-tauri/CHANGELOG.md index 2de4211f..dd85eb10 100644 --- a/examples/api/src-tauri/CHANGELOG.md +++ b/examples/api/src-tauri/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## \[2.0.25] + +### Dependencies + +- Upgraded to `log@2.4.0` +- Upgraded to `biometric@2.2.1` +- Upgraded to `updater@2.7.1` + ## \[2.0.24] ### Dependencies diff --git a/examples/api/src-tauri/Cargo.toml b/examples/api/src-tauri/Cargo.toml index cbc84c85..2faf175f 100644 --- a/examples/api/src-tauri/Cargo.toml +++ b/examples/api/src-tauri/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "api" publish = false -version = "2.0.24" +version = "2.0.25" description = "An example Tauri Application showcasing the api" edition = "2021" rust-version = { workspace = true } @@ -20,7 +20,7 @@ serde = { workspace = true } tiny_http = "0.12" time = "0.3" log = { workspace = true } -tauri-plugin-log = { path = "../../../plugins/log", version = "2.3.1" } +tauri-plugin-log = { path = "../../../plugins/log", version = "2.4.0" } tauri-plugin-fs = { path = "../../../plugins/fs", version = "2.2.1", features = [ "watch", ] } @@ -55,13 +55,13 @@ features = [ [target."cfg(any(target_os = \"macos\", windows, target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies] tauri-plugin-cli = { path = "../../../plugins/cli", version = "2.2.0" } tauri-plugin-global-shortcut = { path = "../../../plugins/global-shortcut", version = "2.2.0" } -tauri-plugin-updater = { path = "../../../plugins/updater", version = "2.7.0" } +tauri-plugin-updater = { path = "../../../plugins/updater", version = "2.7.1" } tauri-plugin-window-state = { path = "../../../plugins/window-state", version = "2.2.0" } [target."cfg(any(target_os = \"android\", target_os = \"ios\"))".dependencies] tauri-plugin-barcode-scanner = { path = "../../../plugins/barcode-scanner/", version = "2.2.0" } tauri-plugin-nfc = { path = "../../../plugins/nfc", version = "2.2.0" } -tauri-plugin-biometric = { path = "../../../plugins/biometric/", version = "2.2.0" } +tauri-plugin-biometric = { path = "../../../plugins/biometric/", version = "2.2.1" } tauri-plugin-geolocation = { path = "../../../plugins/geolocation/", version = "2.2.4" } tauri-plugin-haptics = { path = "../../../plugins/haptics/", version = "2.2.4" } diff --git a/plugins/biometric/CHANGELOG.md b/plugins/biometric/CHANGELOG.md index 4cd2731d..5ebbe50f 100644 --- a/plugins/biometric/CHANGELOG.md +++ b/plugins/biometric/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## \[2.2.1] + +### bug + +- [`10f9e66e`](https://github.com/tauri-apps/plugins-workspace/commit/10f9e66e32141dd35f4bf884fbf9102691187e92) ([#2633](https://github.com/tauri-apps/plugins-workspace/pull/2633) by [@pjf-dev](https://github.com/tauri-apps/plugins-workspace/../../pjf-dev)) Fix biometric plugin ignoring fallback logic when biometry status is unavailable or not enrolled on iOS. + ## \[2.2.0] - [`3a79266b`](https://github.com/tauri-apps/plugins-workspace/commit/3a79266b8cf96a55b1ae6339d725567d45a44b1d) ([#2173](https://github.com/tauri-apps/plugins-workspace/pull/2173) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Bumped all plugins to `v2.2.0`. From now, the versions for the Rust and JavaScript packages of each plugin will be in sync with each other. diff --git a/plugins/biometric/Cargo.toml b/plugins/biometric/Cargo.toml index b96f55b3..2b76fea4 100644 --- a/plugins/biometric/Cargo.toml +++ b/plugins/biometric/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tauri-plugin-biometric" -version = "2.2.0" +version = "2.2.1" description = "Prompt the user for biometric authentication on Android and iOS." edition = { workspace = true } authors = { workspace = true } diff --git a/plugins/biometric/package.json b/plugins/biometric/package.json index fe689d45..2307d67b 100644 --- a/plugins/biometric/package.json +++ b/plugins/biometric/package.json @@ -1,6 +1,6 @@ { "name": "@tauri-apps/plugin-biometric", - "version": "2.2.0", + "version": "2.2.1", "license": "MIT OR Apache-2.0", "authors": [ "Tauri Programme within The Commons Conservancy" diff --git a/plugins/log/CHANGELOG.md b/plugins/log/CHANGELOG.md index 98869ea1..210df69b 100644 --- a/plugins/log/CHANGELOG.md +++ b/plugins/log/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## \[2.4.0] + +- [`c9b21f6f`](https://github.com/tauri-apps/plugins-workspace/commit/c9b21f6f4345806eff5f495885f20dea0082b7d7) ([#2625](https://github.com/tauri-apps/plugins-workspace/pull/2625) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Export the `LogLevel` type. +- [`9629c2f4`](https://github.com/tauri-apps/plugins-workspace/commit/9629c2f4f90a56b5c2d265d1d13d3af40fc0c525) ([#2600](https://github.com/tauri-apps/plugins-workspace/pull/2600) by [@exoego](https://github.com/tauri-apps/plugins-workspace/../../exoego)) Adds a new varient `TargetKind::Dispatch` that allows you to construct arbitrary log targets +- [`686a839c`](https://github.com/tauri-apps/plugins-workspace/commit/686a839c96fae1b0334f2df9dc76ca5cdbe00dbe) ([#2626](https://github.com/tauri-apps/plugins-workspace/pull/2626) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Fix iOS app stuck when using the iOS Simulator and the log plugin due to a deadlock when calling os_log too early. + +### feat + +- [`60fc35d3`](https://github.com/tauri-apps/plugins-workspace/commit/60fc35d35cccaf1654eceb4446ecf0f89dc15502) ([#2576](https://github.com/tauri-apps/plugins-workspace/pull/2576) by [@3lpsy](https://github.com/tauri-apps/plugins-workspace/../../3lpsy)) Add a `tracing` feature to the `log` plugin that emits log messages to the `tracing` system. + ## \[2.3.1] - [`1bb1ced5`](https://github.com/tauri-apps/plugins-workspace/commit/1bb1ced53820127204aa7adf57510c1cbce55e12) ([#2524](https://github.com/tauri-apps/plugins-workspace/pull/2524) by [@elwerene](https://github.com/tauri-apps/plugins-workspace/../../elwerene)) enable TargetKind::LogDir on mobile diff --git a/plugins/log/Cargo.toml b/plugins/log/Cargo.toml index c88d40bb..660cae32 100644 --- a/plugins/log/Cargo.toml +++ b/plugins/log/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tauri-plugin-log" -version = "2.3.1" +version = "2.4.0" description = "Configurable logging for your Tauri app." authors = { workspace = true } license = { workspace = true } diff --git a/plugins/log/package.json b/plugins/log/package.json index 290ab097..9130ca88 100644 --- a/plugins/log/package.json +++ b/plugins/log/package.json @@ -1,6 +1,6 @@ { "name": "@tauri-apps/plugin-log", - "version": "2.3.1", + "version": "2.4.0", "description": "Configurable logging for your Tauri app.", "license": "MIT OR Apache-2.0", "authors": [ diff --git a/plugins/updater/CHANGELOG.md b/plugins/updater/CHANGELOG.md index 0c10166b..ccf98564 100644 --- a/plugins/updater/CHANGELOG.md +++ b/plugins/updater/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## \[2.7.1] + +- [`c5b0f51c`](https://github.com/tauri-apps/plugins-workspace/commit/c5b0f51cfd911cca9317b59efc718b570980129b) ([#2621](https://github.com/tauri-apps/plugins-workspace/pull/2621) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Fix `check` and `download` overrides the `accept` header + ## \[2.7.0] ### bug diff --git a/plugins/updater/Cargo.toml b/plugins/updater/Cargo.toml index 768dcfea..a87dd149 100644 --- a/plugins/updater/Cargo.toml +++ b/plugins/updater/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tauri-plugin-updater" -version = "2.7.0" +version = "2.7.1" description = "In-app updates for Tauri applications." edition = { workspace = true } authors = { workspace = true } diff --git a/plugins/updater/package.json b/plugins/updater/package.json index a466ac53..08a9a5dd 100644 --- a/plugins/updater/package.json +++ b/plugins/updater/package.json @@ -1,6 +1,6 @@ { "name": "@tauri-apps/plugin-updater", - "version": "2.7.0", + "version": "2.7.1", "license": "MIT OR Apache-2.0", "authors": [ "Tauri Programme within The Commons Conservancy" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 106e69bf..0de123c0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -60,7 +60,7 @@ importers: specifier: ^2.2.0 version: link:../../plugins/barcode-scanner '@tauri-apps/plugin-biometric': - specifier: ^2.2.0 + specifier: ^2.2.1 version: link:../../plugins/biometric '@tauri-apps/plugin-cli': specifier: ^2.2.0 @@ -108,7 +108,7 @@ importers: specifier: ^2.2.0 version: link:../../plugins/store '@tauri-apps/plugin-updater': - specifier: ^2.7.0 + specifier: ^2.7.1 version: link:../../plugins/updater '@zerodevx/svelte-json-view': specifier: 1.0.11 @@ -2298,9 +2298,9 @@ snapshots: - encoding - mocha - '@covector/assemble@0.12.0': + '@covector/assemble@0.12.0(mocha@10.8.2)': dependencies: - '@covector/command': 0.8.0 + '@covector/command': 0.8.0(mocha@10.8.2) '@covector/files': 0.8.0 effection: 2.0.8(mocha@10.8.2) js-yaml: 4.1.0 @@ -2311,9 +2311,10 @@ snapshots: unified: 9.2.2 transitivePeerDependencies: - encoding + - mocha - supports-color - '@covector/changelog@0.12.0': + '@covector/changelog@0.12.0(mocha@10.8.2)': dependencies: '@covector/files': 0.8.0 effection: 2.0.8(mocha@10.8.2) @@ -2323,14 +2324,16 @@ snapshots: unified: 9.2.2 transitivePeerDependencies: - encoding + - mocha - supports-color - '@covector/command@0.8.0': + '@covector/command@0.8.0(mocha@10.8.2)': dependencies: - '@effection/process': 2.1.4 + '@effection/process': 2.1.4(mocha@10.8.2) effection: 2.0.8(mocha@10.8.2) transitivePeerDependencies: - encoding + - mocha '@covector/files@0.8.0': dependencies: @@ -2377,10 +2380,8 @@ snapshots: dependencies: effection: 2.0.8(mocha@10.8.2) mocha: 10.8.2 - transitivePeerDependencies: - - encoding - '@effection/process@2.1.4': + '@effection/process@2.1.4(mocha@10.8.2)': dependencies: cross-spawn: 7.0.6 ctrlc-windows: 2.2.0 @@ -2388,6 +2389,7 @@ snapshots: shellwords: 0.1.1 transitivePeerDependencies: - encoding + - mocha '@effection/stream@2.0.6': dependencies: @@ -3186,9 +3188,9 @@ snapshots: dependencies: '@clack/prompts': 0.7.0 '@covector/apply': 0.10.0(mocha@10.8.2) - '@covector/assemble': 0.12.0 - '@covector/changelog': 0.12.0 - '@covector/command': 0.8.0 + '@covector/assemble': 0.12.0(mocha@10.8.2) + '@covector/changelog': 0.12.0(mocha@10.8.2) + '@covector/command': 0.8.0(mocha@10.8.2) '@covector/files': 0.8.0 effection: 2.0.8(mocha@10.8.2) globby: 11.1.0 From ff384cbabe82ae715798a4ee49fd07ffcfbcdb5d Mon Sep 17 00:00:00 2001 From: asomethings <16171942+asomethings@users.noreply.github.com> Date: Fri, 18 Apr 2025 21:53:25 +0900 Subject: [PATCH 2/5] fix(http): handle status code 204 to use js null fix #2580 (#2636) * fix(http): handle status code 204 to use javascript null * add change file --------- Co-authored-by: Lucas Nogueira --- .changes/http-fix-204.md | 6 ++++++ plugins/http/api-iife.js | 2 +- plugins/http/guest-js/index.ts | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changes/http-fix-204.md diff --git a/.changes/http-fix-204.md b/.changes/http-fix-204.md new file mode 100644 index 00000000..d98241cb --- /dev/null +++ b/.changes/http-fix-204.md @@ -0,0 +1,6 @@ +--- +"http": patch +"http-js": patch +--- + +Properly handle responses with status code 204. diff --git a/plugins/http/api-iife.js b/plugins/http/api-iife.js index 8858222c..d0bb98b4 100644 --- a/plugins/http/api-iife.js +++ b/plugins/http/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_PLUGIN_HTTP__=function(e){"use strict";function t(e,t,r,n){if("function"==typeof t||!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}function r(e,t,r,n,s){if("function"==typeof t||!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,r),r}var n,s,i,a;"function"==typeof SuppressedError&&SuppressedError;const o="__TAURI_TO_IPC_KEY__";class c{constructor(e){n.set(this,void 0),s.set(this,0),i.set(this,[]),a.set(this,void 0),r(this,n,e||(()=>{})),this.id=function(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}((e=>{const o=e.index;if("end"in e)return void(o==t(this,s,"f")?this.cleanupCallback():r(this,a,o));const c=e.message;if(o==t(this,s,"f")){for(t(this,n,"f").call(this,c),r(this,s,t(this,s,"f")+1);t(this,s,"f")in t(this,i,"f");){const e=t(this,i,"f")[t(this,s,"f")];t(this,n,"f").call(this,e),delete t(this,i,"f")[t(this,s,"f")],r(this,s,t(this,s,"f")+1)}t(this,s,"f")===t(this,a,"f")&&this.cleanupCallback()}else t(this,i,"f")[o]=c}))}cleanupCallback(){Reflect.deleteProperty(window,`_${this.id}`)}set onmessage(e){r(this,n,e)}get onmessage(){return t(this,n,"f")}[(n=new WeakMap,s=new WeakMap,i=new WeakMap,a=new WeakMap,o)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[o]()}}async function d(e,t={},r){return window.__TAURI_INTERNALS__.invoke(e,t,r)}const h="Request cancelled";return e.fetch=async function(e,t){const r=t?.signal;if(r?.aborted)throw new Error(h);const n=t?.maxRedirections,s=t?.connectTimeout,i=t?.proxy,a=t?.danger;t&&(delete t.maxRedirections,delete t.connectTimeout,delete t.proxy,delete t.danger);const o=t?.headers?t.headers instanceof Headers?t.headers:new Headers(t.headers):new Headers,f=new Request(e,t),l=await f.arrayBuffer(),u=0!==l.byteLength?Array.from(new Uint8Array(l)):null;for(const[e,t]of f.headers)o.get(e)||o.set(e,t);const _=(o instanceof Headers?Array.from(o.entries()):Array.isArray(o)?o:Object.entries(o)).map((([e,t])=>[e,"string"==typeof t?t:t.toString()]));if(r?.aborted)throw new Error(h);const w=await d("plugin:http|fetch",{clientConfig:{method:f.method,url:f.url,headers:_,data:u,maxRedirections:n,connectTimeout:s,proxy:i,danger:a}}),p=()=>d("plugin:http|fetch_cancel",{rid:w});if(r?.aborted)throw p(),new Error(h);r?.addEventListener("abort",(()=>{p()}));const{status:y,statusText:m,url:b,headers:g,rid:T}=await d("plugin:http|fetch_send",{rid:w}),R=new ReadableStream({start:e=>{const t=new c;t.onmessage=t=>{if(r?.aborted)return void e.error(h);const n=new Uint8Array(t),s=n[n.byteLength-1],i=n.slice(0,n.byteLength-1);1!=s?e.enqueue(i):e.close()},d("plugin:http|fetch_read_body",{rid:T,streamChannel:t}).catch((t=>{e.error(t)}))}}),A=new Response(R,{status:y,statusText:m});return Object.defineProperty(A,"url",{value:b}),Object.defineProperty(A,"headers",{value:new Headers(g)}),A},e}({});Object.defineProperty(window.__TAURI__,"http",{value:__TAURI_PLUGIN_HTTP__})} +if("__TAURI__"in window){var __TAURI_PLUGIN_HTTP__=function(e){"use strict";function t(e,t,r,n){if("function"==typeof t||!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}function r(e,t,r,n,s){if("function"==typeof t||!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,r),r}var n,s,i,a;"function"==typeof SuppressedError&&SuppressedError;const o="__TAURI_TO_IPC_KEY__";class c{constructor(e){n.set(this,void 0),s.set(this,0),i.set(this,[]),a.set(this,void 0),r(this,n,e||(()=>{})),this.id=function(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}((e=>{const o=e.index;if("end"in e)return void(o==t(this,s,"f")?this.cleanupCallback():r(this,a,o));const c=e.message;if(o==t(this,s,"f")){for(t(this,n,"f").call(this,c),r(this,s,t(this,s,"f")+1);t(this,s,"f")in t(this,i,"f");){const e=t(this,i,"f")[t(this,s,"f")];t(this,n,"f").call(this,e),delete t(this,i,"f")[t(this,s,"f")],r(this,s,t(this,s,"f")+1)}t(this,s,"f")===t(this,a,"f")&&this.cleanupCallback()}else t(this,i,"f")[o]=c}))}cleanupCallback(){Reflect.deleteProperty(window,`_${this.id}`)}set onmessage(e){r(this,n,e)}get onmessage(){return t(this,n,"f")}[(n=new WeakMap,s=new WeakMap,i=new WeakMap,a=new WeakMap,o)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[o]()}}async function d(e,t={},r){return window.__TAURI_INTERNALS__.invoke(e,t,r)}const h="Request cancelled";return e.fetch=async function(e,t){const r=t?.signal;if(r?.aborted)throw new Error(h);const n=t?.maxRedirections,s=t?.connectTimeout,i=t?.proxy,a=t?.danger;t&&(delete t.maxRedirections,delete t.connectTimeout,delete t.proxy,delete t.danger);const o=t?.headers?t.headers instanceof Headers?t.headers:new Headers(t.headers):new Headers,f=new Request(e,t),l=await f.arrayBuffer(),u=0!==l.byteLength?Array.from(new Uint8Array(l)):null;for(const[e,t]of f.headers)o.get(e)||o.set(e,t);const _=(o instanceof Headers?Array.from(o.entries()):Array.isArray(o)?o:Object.entries(o)).map((([e,t])=>[e,"string"==typeof t?t:t.toString()]));if(r?.aborted)throw new Error(h);const w=await d("plugin:http|fetch",{clientConfig:{method:f.method,url:f.url,headers:_,data:u,maxRedirections:n,connectTimeout:s,proxy:i,danger:a}}),p=()=>d("plugin:http|fetch_cancel",{rid:w});if(r?.aborted)throw p(),new Error(h);r?.addEventListener("abort",(()=>{p()}));const{status:y,statusText:m,url:b,headers:g,rid:T}=await d("plugin:http|fetch_send",{rid:w}),R=new ReadableStream({start:e=>{const t=new c;t.onmessage=t=>{if(r?.aborted)return void e.error(h);const n=new Uint8Array(t),s=n[n.byteLength-1],i=n.slice(0,n.byteLength-1);1!=s?e.enqueue(i):e.close()},d("plugin:http|fetch_read_body",{rid:T,streamChannel:t}).catch((t=>{e.error(t)}))}}),A=new Response(204!==y?R:null,{status:y,statusText:m});return Object.defineProperty(A,"url",{value:b}),Object.defineProperty(A,"headers",{value:new Headers(g)}),A},e}({});Object.defineProperty(window.__TAURI__,"http",{value:__TAURI_PLUGIN_HTTP__})} diff --git a/plugins/http/guest-js/index.ts b/plugins/http/guest-js/index.ts index 62f4916c..4b8da525 100644 --- a/plugins/http/guest-js/index.ts +++ b/plugins/http/guest-js/index.ts @@ -262,7 +262,7 @@ export async function fetch( } }) - const res = new Response(readableStreamBody, { + const res = new Response(status !== 204 ? readableStreamBody : null, { status, statusText }) From dc84f8d8bbaa70de3bb3185fbacb472993b996ef Mon Sep 17 00:00:00 2001 From: Simon Laux Date: Fri, 18 Apr 2025 13:14:52 +0000 Subject: [PATCH 3/5] single-instance: fix `cwd` in single instance on macOS (#2609) * single-instance: fix `cwd` in single instance on macOS which was the `cwd` of the first instance, instead of the second how it should be and is on windows and linux. also add rustfmt.toml to enforce the correct formatting (4 spaces for indent) * use split_once * remove rustfmt * fix indentation --------- Co-authored-by: Lucas Nogueira --- .changes/fix-macos-cwd-single-instance.md | 5 +++++ plugins/deep-link/src/lib.rs | 10 +++++----- .../single-instance/src/platform_impl/macos.rs | 18 ++++++++++-------- 3 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 .changes/fix-macos-cwd-single-instance.md diff --git a/.changes/fix-macos-cwd-single-instance.md b/.changes/fix-macos-cwd-single-instance.md new file mode 100644 index 00000000..2d528d1f --- /dev/null +++ b/.changes/fix-macos-cwd-single-instance.md @@ -0,0 +1,5 @@ +--- +single-instance: patch +--- + +fix `cwd` in single instance on macOS, which was the cwd of the first instance, instead of the second (like it is on windows and linux) diff --git a/plugins/deep-link/src/lib.rs b/plugins/deep-link/src/lib.rs index 30584df5..d74864db 100644 --- a/plugins/deep-link/src/lib.rs +++ b/plugins/deep-link/src/lib.rs @@ -114,8 +114,8 @@ mod imp { /// ## Platform-specific: /// /// - **Windows / Linux**: This function reads the command line arguments and checks if there's only one value, which must be an URL with scheme matching one of the configured values. - /// Note that you must manually check the arguments when registering deep link schemes dynamically with [`Self::register`]. - /// Additionally, the deep link might have been provided as a CLI argument so you should check if its format matches what you expect. + /// Note that you must manually check the arguments when registering deep link schemes dynamically with [`Self::register`]. + /// Additionally, the deep link might have been provided as a CLI argument so you should check if its format matches what you expect. pub fn get_current(&self) -> crate::Result>> { self.plugin_handle .run_mobile_plugin::("getCurrent", ()) @@ -226,8 +226,8 @@ mod imp { /// ## Platform-specific: /// /// - **Windows / Linux**: This function reads the command line arguments and checks if there's only one value, which must be an URL with scheme matching one of the configured values. - /// Note that you must manually check the arguments when registering deep link schemes dynamically with [`Self::register`]. - /// Additionally, the deep link might have been provided as a CLI argument so you should check if its format matches what you expect. + /// Note that you must manually check the arguments when registering deep link schemes dynamically with [`Self::register`]. + /// Additionally, the deep link might have been provided as a CLI argument so you should check if its format matches what you expect. pub fn get_current(&self) -> crate::Result>> { return Ok(self.current.lock().unwrap().clone()); } @@ -350,7 +350,7 @@ mod imp { /// ## Platform-specific: /// /// - **Windows**: Requires admin rights if the protocol is registered on local machine - /// (this can happen when registered from the NSIS installer when the install mode is set to both or per machine) + /// (this can happen when registered from the NSIS installer when the install mode is set to both or per machine) /// - **Linux**: Can only unregister the scheme if it was initially registered with [`register`](`Self::register`). May not work on older distros. /// - **macOS / Android / iOS**: Unsupported, will return [`Error::UnsupportedPlatform`](`crate::Error::UnsupportedPlatform`). pub fn unregister>(&self, _protocol: S) -> crate::Result<()> { diff --git a/plugins/single-instance/src/platform_impl/macos.rs b/plugins/single-instance/src/platform_impl/macos.rs index 70284eae..63991513 100644 --- a/plugins/single-instance/src/platform_impl/macos.rs +++ b/plugins/single-instance/src/platform_impl/macos.rs @@ -77,6 +77,13 @@ fn socket_cleanup(socket: &PathBuf) { fn notify_singleton(socket: &PathBuf) -> Result<(), Error> { let stream = UnixStream::connect(socket)?; let mut bf = BufWriter::new(&stream); + let cwd = std::env::current_dir() + .unwrap_or_default() + .to_str() + .unwrap_or_default() + .to_string(); + bf.write_all(cwd.as_bytes())?; + bf.write_all(b"\0\0")?; let args_joined = std::env::args().collect::>().join("\0"); bf.write_all(args_joined.as_bytes())?; bf.flush()?; @@ -91,12 +98,6 @@ fn listen_for_other_instances( ) { match UnixListener::bind(socket) { Ok(listener) => { - let cwd = std::env::current_dir() - .unwrap_or_default() - .to_str() - .unwrap_or_default() - .to_string(); - tauri::async_runtime::spawn(async move { for stream in listener.incoming() { match stream { @@ -104,9 +105,10 @@ fn listen_for_other_instances( let mut s = String::new(); match stream.read_to_string(&mut s) { Ok(_) => { + let (cwd, args) = s.split_once("\0\0").unwrap_or_default(); let args: Vec = - s.split('\0').map(String::from).collect(); - cb(app.app_handle(), args, cwd.clone()); + args.split('\0').map(String::from).collect(); + cb(app.app_handle(), args, cwd.to_string()); } Err(e) => { tracing::debug!("single_instance failed to be notified: {e}") From 4089002880e8fcf1f94b27d2595dedaf03cb9cb4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 19 Apr 2025 07:18:58 +0800 Subject: [PATCH 4/5] chore(deps): update eslint monorepo to v9.25.0 (#2644) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 4 +- pnpm-lock.yaml | 122 ++++++++++++++++++++++++------------------------- 2 files changed, 62 insertions(+), 64 deletions(-) diff --git a/package.json b/package.json index 3da1fdff..68c769ee 100644 --- a/package.json +++ b/package.json @@ -11,12 +11,12 @@ "example:api:dev": "pnpm run --filter \"api\" tauri dev" }, "devDependencies": { - "@eslint/js": "9.24.0", + "@eslint/js": "9.25.0", "@rollup/plugin-node-resolve": "16.0.1", "@rollup/plugin-terser": "0.4.4", "@rollup/plugin-typescript": "12.1.2", "covector": "^0.12.4", - "eslint": "9.24.0", + "eslint": "9.25.0", "eslint-config-prettier": "10.1.2", "eslint-plugin-security": "3.0.1", "prettier": "3.5.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0de123c0..1a547c97 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,8 +12,8 @@ importers: .: devDependencies: '@eslint/js': - specifier: 9.24.0 - version: 9.24.0 + specifier: 9.25.0 + version: 9.25.0 '@rollup/plugin-node-resolve': specifier: 16.0.1 version: 16.0.1(rollup@4.40.0) @@ -27,11 +27,11 @@ importers: specifier: ^0.12.4 version: 0.12.4(mocha@10.8.2) eslint: - specifier: 9.24.0 - version: 9.24.0(jiti@2.4.2) + specifier: 9.25.0 + version: 9.25.0(jiti@2.4.2) eslint-config-prettier: specifier: 10.1.2 - version: 10.1.2(eslint@9.24.0(jiti@2.4.2)) + version: 10.1.2(eslint@9.25.0(jiti@2.4.2)) eslint-plugin-security: specifier: 3.0.1 version: 3.0.1 @@ -49,7 +49,7 @@ importers: version: 5.8.3 typescript-eslint: specifier: 8.30.1 - version: 8.30.1(eslint@9.24.0(jiti@2.4.2))(typescript@5.8.3) + version: 8.30.1(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3) examples/api: dependencies: @@ -607,28 +607,28 @@ packages: resolution: {integrity: sha512-fxlS1kkIjx8+vy2SjuCB94q3htSNrufYTXubwiBFeaQHbH6Ipi43gFJq2zCMt6PHhImH3Xmr0NksKDvchWlpQQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@eslint/config-helpers@0.2.0': - resolution: {integrity: sha512-yJLLmLexii32mGrhW29qvU3QBVTu0GUmEf/J4XsBtVhp4JkIUFN/BjWqTF63yRvGApIDpZm5fa97LtYtINmfeQ==} + '@eslint/config-helpers@0.2.1': + resolution: {integrity: sha512-RI17tsD2frtDu/3dmI7QRrD4bedNKPM08ziRYaC5AhkGrzIAJelm9kJU1TznK+apx6V+cqRz8tfpEeG3oIyjxw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@eslint/core@0.12.0': - resolution: {integrity: sha512-cmrR6pytBuSMTaBweKoGMwu3EiHiEC+DoyupPmlZ0HxBJBtIxwe+j/E4XPIKNx+Q74c8lXKPwYawBf5glsTkHg==} + '@eslint/core@0.13.0': + resolution: {integrity: sha512-yfkgDw1KR66rkT5A8ci4irzDysN7FRpq3ttJolR88OqQikAWqwA8j5VZyas+vjyBNFIJ7MfybJ9plMILI2UrCw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} '@eslint/eslintrc@3.3.1': resolution: {integrity: sha512-gtF186CXhIl1p4pJNGZw8Yc6RlshoePRvE0X91oPGb3vZ8pM3qOS9W9NGPat9LziaBV7XrJWGylNQXkGcnM3IQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@eslint/js@9.24.0': - resolution: {integrity: sha512-uIY/y3z0uvOGX8cp1C2fiC4+ZmBhp6yZWkojtHL1YEMnRt1Y63HB9TM17proGEmeG7HeUY+UP36F0aknKYTpYA==} + '@eslint/js@9.25.0': + resolution: {integrity: sha512-iWhsUS8Wgxz9AXNfvfOPFSW4VfMXdVhp1hjkZVhXCrpgh/aLcc45rX6MPu+tIVUWDw0HfNwth7O28M1xDxNf9w==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} '@eslint/object-schema@2.1.6': resolution: {integrity: sha512-RBMg5FRL0I0gs51M/guSAj5/e14VQ4tpZnQNWwuDT66P14I43ItmPfIZRhO9fUVIPOAQXU47atlywZ/czoqFPA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@eslint/plugin-kit@0.2.7': - resolution: {integrity: sha512-JubJ5B2pJ4k4yGxaNLdbjrnk9d/iDz6/q8wOilpIowd6PJPgaxCuHBnBszq7Ce2TyMrywm5r4PnKm6V3iiZF+g==} + '@eslint/plugin-kit@0.2.8': + resolution: {integrity: sha512-ZAoA40rNMPwSm+AeHpCq8STiNAwzWLJuP8Xv4CHIc9wv/PSuExjMrmjfYNj682vW0OOiZ1HKxzvjQr9XZIisQA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} '@humanfs/core@0.19.1': @@ -1366,8 +1366,8 @@ packages: resolution: {integrity: sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - eslint@9.24.0: - resolution: {integrity: sha512-eh/jxIEJyZrvbWRe4XuVclLPDYSYYYgLy5zXGGxD6j8zjSAxFEzI2fL/8xNq6O2yKqVt+eF2YhV+hxjV6UKXwQ==} + eslint@9.25.0: + resolution: {integrity: sha512-MsBdObhM4cEwkzCiraDv7A6txFXEqtNXOb877TsSp2FCkBNl8JfVQrmiuDqC1IkejT6JLPzYBXx/xAiYhyzgGA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} hasBin: true peerDependencies: @@ -2298,9 +2298,9 @@ snapshots: - encoding - mocha - '@covector/assemble@0.12.0(mocha@10.8.2)': + '@covector/assemble@0.12.0': dependencies: - '@covector/command': 0.8.0(mocha@10.8.2) + '@covector/command': 0.8.0 '@covector/files': 0.8.0 effection: 2.0.8(mocha@10.8.2) js-yaml: 4.1.0 @@ -2311,10 +2311,9 @@ snapshots: unified: 9.2.2 transitivePeerDependencies: - encoding - - mocha - supports-color - '@covector/changelog@0.12.0(mocha@10.8.2)': + '@covector/changelog@0.12.0': dependencies: '@covector/files': 0.8.0 effection: 2.0.8(mocha@10.8.2) @@ -2324,16 +2323,14 @@ snapshots: unified: 9.2.2 transitivePeerDependencies: - encoding - - mocha - supports-color - '@covector/command@0.8.0(mocha@10.8.2)': + '@covector/command@0.8.0': dependencies: - '@effection/process': 2.1.4(mocha@10.8.2) + '@effection/process': 2.1.4 effection: 2.0.8(mocha@10.8.2) transitivePeerDependencies: - encoding - - mocha '@covector/files@0.8.0': dependencies: @@ -2380,8 +2377,10 @@ snapshots: dependencies: effection: 2.0.8(mocha@10.8.2) mocha: 10.8.2 + transitivePeerDependencies: + - encoding - '@effection/process@2.1.4(mocha@10.8.2)': + '@effection/process@2.1.4': dependencies: cross-spawn: 7.0.6 ctrlc-windows: 2.2.0 @@ -2389,7 +2388,6 @@ snapshots: shellwords: 0.1.1 transitivePeerDependencies: - encoding - - mocha '@effection/stream@2.0.6': dependencies: @@ -2475,9 +2473,9 @@ snapshots: '@esbuild/win32-x64@0.25.2': optional: true - '@eslint-community/eslint-utils@4.4.1(eslint@9.24.0(jiti@2.4.2))': + '@eslint-community/eslint-utils@4.4.1(eslint@9.25.0(jiti@2.4.2))': dependencies: - eslint: 9.24.0(jiti@2.4.2) + eslint: 9.25.0(jiti@2.4.2) eslint-visitor-keys: 3.4.3 '@eslint-community/regexpp@4.12.1': {} @@ -2490,9 +2488,9 @@ snapshots: transitivePeerDependencies: - supports-color - '@eslint/config-helpers@0.2.0': {} + '@eslint/config-helpers@0.2.1': {} - '@eslint/core@0.12.0': + '@eslint/core@0.13.0': dependencies: '@types/json-schema': 7.0.15 @@ -2510,13 +2508,13 @@ snapshots: transitivePeerDependencies: - supports-color - '@eslint/js@9.24.0': {} + '@eslint/js@9.25.0': {} '@eslint/object-schema@2.1.6': {} - '@eslint/plugin-kit@0.2.7': + '@eslint/plugin-kit@0.2.8': dependencies: - '@eslint/core': 0.12.0 + '@eslint/core': 0.13.0 levn: 0.4.1 '@humanfs/core@0.19.1': {} @@ -2769,15 +2767,15 @@ snapshots: '@types/unist@2.0.11': {} - '@typescript-eslint/eslint-plugin@8.30.1(@typescript-eslint/parser@8.30.1(eslint@9.24.0(jiti@2.4.2))(typescript@5.8.3))(eslint@9.24.0(jiti@2.4.2))(typescript@5.8.3)': + '@typescript-eslint/eslint-plugin@8.30.1(@typescript-eslint/parser@8.30.1(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3))(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3)': dependencies: '@eslint-community/regexpp': 4.12.1 - '@typescript-eslint/parser': 8.30.1(eslint@9.24.0(jiti@2.4.2))(typescript@5.8.3) + '@typescript-eslint/parser': 8.30.1(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3) '@typescript-eslint/scope-manager': 8.30.1 - '@typescript-eslint/type-utils': 8.30.1(eslint@9.24.0(jiti@2.4.2))(typescript@5.8.3) - '@typescript-eslint/utils': 8.30.1(eslint@9.24.0(jiti@2.4.2))(typescript@5.8.3) + '@typescript-eslint/type-utils': 8.30.1(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3) + '@typescript-eslint/utils': 8.30.1(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3) '@typescript-eslint/visitor-keys': 8.30.1 - eslint: 9.24.0(jiti@2.4.2) + eslint: 9.25.0(jiti@2.4.2) graphemer: 1.4.0 ignore: 5.3.2 natural-compare: 1.4.0 @@ -2786,14 +2784,14 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/parser@8.30.1(eslint@9.24.0(jiti@2.4.2))(typescript@5.8.3)': + '@typescript-eslint/parser@8.30.1(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3)': dependencies: '@typescript-eslint/scope-manager': 8.30.1 '@typescript-eslint/types': 8.30.1 '@typescript-eslint/typescript-estree': 8.30.1(typescript@5.8.3) '@typescript-eslint/visitor-keys': 8.30.1 debug: 4.4.0(supports-color@8.1.1) - eslint: 9.24.0(jiti@2.4.2) + eslint: 9.25.0(jiti@2.4.2) typescript: 5.8.3 transitivePeerDependencies: - supports-color @@ -2803,12 +2801,12 @@ snapshots: '@typescript-eslint/types': 8.30.1 '@typescript-eslint/visitor-keys': 8.30.1 - '@typescript-eslint/type-utils@8.30.1(eslint@9.24.0(jiti@2.4.2))(typescript@5.8.3)': + '@typescript-eslint/type-utils@8.30.1(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3)': dependencies: '@typescript-eslint/typescript-estree': 8.30.1(typescript@5.8.3) - '@typescript-eslint/utils': 8.30.1(eslint@9.24.0(jiti@2.4.2))(typescript@5.8.3) + '@typescript-eslint/utils': 8.30.1(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3) debug: 4.4.0(supports-color@8.1.1) - eslint: 9.24.0(jiti@2.4.2) + eslint: 9.25.0(jiti@2.4.2) ts-api-utils: 2.0.1(typescript@5.8.3) typescript: 5.8.3 transitivePeerDependencies: @@ -2830,13 +2828,13 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@8.30.1(eslint@9.24.0(jiti@2.4.2))(typescript@5.8.3)': + '@typescript-eslint/utils@8.30.1(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3)': dependencies: - '@eslint-community/eslint-utils': 4.4.1(eslint@9.24.0(jiti@2.4.2)) + '@eslint-community/eslint-utils': 4.4.1(eslint@9.25.0(jiti@2.4.2)) '@typescript-eslint/scope-manager': 8.30.1 '@typescript-eslint/types': 8.30.1 '@typescript-eslint/typescript-estree': 8.30.1(typescript@5.8.3) - eslint: 9.24.0(jiti@2.4.2) + eslint: 9.25.0(jiti@2.4.2) typescript: 5.8.3 transitivePeerDependencies: - supports-color @@ -3188,9 +3186,9 @@ snapshots: dependencies: '@clack/prompts': 0.7.0 '@covector/apply': 0.10.0(mocha@10.8.2) - '@covector/assemble': 0.12.0(mocha@10.8.2) - '@covector/changelog': 0.12.0(mocha@10.8.2) - '@covector/command': 0.8.0(mocha@10.8.2) + '@covector/assemble': 0.12.0 + '@covector/changelog': 0.12.0 + '@covector/command': 0.8.0 '@covector/files': 0.8.0 effection: 2.0.8(mocha@10.8.2) globby: 11.1.0 @@ -3299,9 +3297,9 @@ snapshots: escape-string-regexp@4.0.0: {} - eslint-config-prettier@10.1.2(eslint@9.24.0(jiti@2.4.2)): + eslint-config-prettier@10.1.2(eslint@9.25.0(jiti@2.4.2)): dependencies: - eslint: 9.24.0(jiti@2.4.2) + eslint: 9.25.0(jiti@2.4.2) eslint-plugin-security@3.0.1: dependencies: @@ -3316,16 +3314,16 @@ snapshots: eslint-visitor-keys@4.2.0: {} - eslint@9.24.0(jiti@2.4.2): + eslint@9.25.0(jiti@2.4.2): dependencies: - '@eslint-community/eslint-utils': 4.4.1(eslint@9.24.0(jiti@2.4.2)) + '@eslint-community/eslint-utils': 4.4.1(eslint@9.25.0(jiti@2.4.2)) '@eslint-community/regexpp': 4.12.1 '@eslint/config-array': 0.20.0 - '@eslint/config-helpers': 0.2.0 - '@eslint/core': 0.12.0 + '@eslint/config-helpers': 0.2.1 + '@eslint/core': 0.13.0 '@eslint/eslintrc': 3.3.1 - '@eslint/js': 9.24.0 - '@eslint/plugin-kit': 0.2.7 + '@eslint/js': 9.25.0 + '@eslint/plugin-kit': 0.2.8 '@humanfs/node': 0.16.6 '@humanwhocodes/module-importer': 1.0.1 '@humanwhocodes/retry': 0.4.2 @@ -4053,12 +4051,12 @@ snapshots: type-fest@0.7.1: {} - typescript-eslint@8.30.1(eslint@9.24.0(jiti@2.4.2))(typescript@5.8.3): + typescript-eslint@8.30.1(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3): dependencies: - '@typescript-eslint/eslint-plugin': 8.30.1(@typescript-eslint/parser@8.30.1(eslint@9.24.0(jiti@2.4.2))(typescript@5.8.3))(eslint@9.24.0(jiti@2.4.2))(typescript@5.8.3) - '@typescript-eslint/parser': 8.30.1(eslint@9.24.0(jiti@2.4.2))(typescript@5.8.3) - '@typescript-eslint/utils': 8.30.1(eslint@9.24.0(jiti@2.4.2))(typescript@5.8.3) - eslint: 9.24.0(jiti@2.4.2) + '@typescript-eslint/eslint-plugin': 8.30.1(@typescript-eslint/parser@8.30.1(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3))(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3) + '@typescript-eslint/parser': 8.30.1(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3) + '@typescript-eslint/utils': 8.30.1(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3) + eslint: 9.25.0(jiti@2.4.2) typescript: 5.8.3 transitivePeerDependencies: - supports-color From 5e78988f727a6d73cedc328ad7efb8ed18b116d2 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Sat, 19 Apr 2025 12:45:41 +0200 Subject: [PATCH 5/5] feat(http): handle 205, 304 null body (#2647) followup to #2636 ref: https://github.com/tauri-apps/plugins-workspace/pull/2636#issuecomment-2815593359 --- plugins/http/api-iife.js | 2 +- plugins/http/guest-js/index.ts | 60 ++++++++++++++++++---------------- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/plugins/http/api-iife.js b/plugins/http/api-iife.js index d0bb98b4..d962f4fc 100644 --- a/plugins/http/api-iife.js +++ b/plugins/http/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_PLUGIN_HTTP__=function(e){"use strict";function t(e,t,r,n){if("function"==typeof t||!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}function r(e,t,r,n,s){if("function"==typeof t||!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,r),r}var n,s,i,a;"function"==typeof SuppressedError&&SuppressedError;const o="__TAURI_TO_IPC_KEY__";class c{constructor(e){n.set(this,void 0),s.set(this,0),i.set(this,[]),a.set(this,void 0),r(this,n,e||(()=>{})),this.id=function(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}((e=>{const o=e.index;if("end"in e)return void(o==t(this,s,"f")?this.cleanupCallback():r(this,a,o));const c=e.message;if(o==t(this,s,"f")){for(t(this,n,"f").call(this,c),r(this,s,t(this,s,"f")+1);t(this,s,"f")in t(this,i,"f");){const e=t(this,i,"f")[t(this,s,"f")];t(this,n,"f").call(this,e),delete t(this,i,"f")[t(this,s,"f")],r(this,s,t(this,s,"f")+1)}t(this,s,"f")===t(this,a,"f")&&this.cleanupCallback()}else t(this,i,"f")[o]=c}))}cleanupCallback(){Reflect.deleteProperty(window,`_${this.id}`)}set onmessage(e){r(this,n,e)}get onmessage(){return t(this,n,"f")}[(n=new WeakMap,s=new WeakMap,i=new WeakMap,a=new WeakMap,o)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[o]()}}async function d(e,t={},r){return window.__TAURI_INTERNALS__.invoke(e,t,r)}const h="Request cancelled";return e.fetch=async function(e,t){const r=t?.signal;if(r?.aborted)throw new Error(h);const n=t?.maxRedirections,s=t?.connectTimeout,i=t?.proxy,a=t?.danger;t&&(delete t.maxRedirections,delete t.connectTimeout,delete t.proxy,delete t.danger);const o=t?.headers?t.headers instanceof Headers?t.headers:new Headers(t.headers):new Headers,f=new Request(e,t),l=await f.arrayBuffer(),u=0!==l.byteLength?Array.from(new Uint8Array(l)):null;for(const[e,t]of f.headers)o.get(e)||o.set(e,t);const _=(o instanceof Headers?Array.from(o.entries()):Array.isArray(o)?o:Object.entries(o)).map((([e,t])=>[e,"string"==typeof t?t:t.toString()]));if(r?.aborted)throw new Error(h);const w=await d("plugin:http|fetch",{clientConfig:{method:f.method,url:f.url,headers:_,data:u,maxRedirections:n,connectTimeout:s,proxy:i,danger:a}}),p=()=>d("plugin:http|fetch_cancel",{rid:w});if(r?.aborted)throw p(),new Error(h);r?.addEventListener("abort",(()=>{p()}));const{status:y,statusText:m,url:b,headers:g,rid:T}=await d("plugin:http|fetch_send",{rid:w}),R=new ReadableStream({start:e=>{const t=new c;t.onmessage=t=>{if(r?.aborted)return void e.error(h);const n=new Uint8Array(t),s=n[n.byteLength-1],i=n.slice(0,n.byteLength-1);1!=s?e.enqueue(i):e.close()},d("plugin:http|fetch_read_body",{rid:T,streamChannel:t}).catch((t=>{e.error(t)}))}}),A=new Response(204!==y?R:null,{status:y,statusText:m});return Object.defineProperty(A,"url",{value:b}),Object.defineProperty(A,"headers",{value:new Headers(g)}),A},e}({});Object.defineProperty(window.__TAURI__,"http",{value:__TAURI_PLUGIN_HTTP__})} +if("__TAURI__"in window){var __TAURI_PLUGIN_HTTP__=function(e){"use strict";function t(e,t,r,n){if("function"==typeof t||!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}function r(e,t,r,n,s){if("function"==typeof t||!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,r),r}var n,s,i,a;"function"==typeof SuppressedError&&SuppressedError;const o="__TAURI_TO_IPC_KEY__";class c{constructor(e){n.set(this,void 0),s.set(this,0),i.set(this,[]),a.set(this,void 0),r(this,n,e||(()=>{})),this.id=function(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}((e=>{const o=e.index;if("end"in e)return void(o==t(this,s,"f")?this.cleanupCallback():r(this,a,o));const c=e.message;if(o==t(this,s,"f")){for(t(this,n,"f").call(this,c),r(this,s,t(this,s,"f")+1);t(this,s,"f")in t(this,i,"f");){const e=t(this,i,"f")[t(this,s,"f")];t(this,n,"f").call(this,e),delete t(this,i,"f")[t(this,s,"f")],r(this,s,t(this,s,"f")+1)}t(this,s,"f")===t(this,a,"f")&&this.cleanupCallback()}else t(this,i,"f")[o]=c}))}cleanupCallback(){Reflect.deleteProperty(window,`_${this.id}`)}set onmessage(e){r(this,n,e)}get onmessage(){return t(this,n,"f")}[(n=new WeakMap,s=new WeakMap,i=new WeakMap,a=new WeakMap,o)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[o]()}}async function d(e,t={},r){return window.__TAURI_INTERNALS__.invoke(e,t,r)}const h="Request cancelled";return e.fetch=async function(e,t){const r=t?.signal;if(r?.aborted)throw new Error(h);const n=t?.maxRedirections,s=t?.connectTimeout,i=t?.proxy,a=t?.danger;t&&(delete t.maxRedirections,delete t.connectTimeout,delete t.proxy,delete t.danger);const o=t?.headers?t.headers instanceof Headers?t.headers:new Headers(t.headers):new Headers,f=new Request(e,t),l=await f.arrayBuffer(),u=0!==l.byteLength?Array.from(new Uint8Array(l)):null;for(const[e,t]of f.headers)o.get(e)||o.set(e,t);const _=(o instanceof Headers?Array.from(o.entries()):Array.isArray(o)?o:Object.entries(o)).map((([e,t])=>[e,"string"==typeof t?t:t.toString()]));if(r?.aborted)throw new Error(h);const w=await d("plugin:http|fetch",{clientConfig:{method:f.method,url:f.url,headers:_,data:u,maxRedirections:n,connectTimeout:s,proxy:i,danger:a}}),p=()=>d("plugin:http|fetch_cancel",{rid:w});if(r?.aborted)throw p(),new Error(h);r?.addEventListener("abort",(()=>{p()}));const{status:y,statusText:m,url:b,headers:g,rid:T}=await d("plugin:http|fetch_send",{rid:w}),R=[204,205,304].includes(y)?null:new ReadableStream({start:e=>{const t=new c;t.onmessage=t=>{if(r?.aborted)return void e.error(h);const n=new Uint8Array(t),s=n[n.byteLength-1],i=n.slice(0,n.byteLength-1);1!=s?e.enqueue(i):e.close()},d("plugin:http|fetch_read_body",{rid:T,streamChannel:t}).catch((t=>{e.error(t)}))}}),A=new Response(R,{status:y,statusText:m});return Object.defineProperty(A,"url",{value:b}),Object.defineProperty(A,"headers",{value:new Headers(g)}),A},e}({});Object.defineProperty(window.__TAURI__,"http",{value:__TAURI_PLUGIN_HTTP__})} diff --git a/plugins/http/guest-js/index.ts b/plugins/http/guest-js/index.ts index 4b8da525..712bbd39 100644 --- a/plugins/http/guest-js/index.ts +++ b/plugins/http/guest-js/index.ts @@ -229,40 +229,44 @@ export async function fetch( rid }) - const readableStreamBody = new ReadableStream({ - start: (controller) => { - const streamChannel = new Channel() - streamChannel.onmessage = (res: ArrayBuffer | number[]) => { - // close early if aborted - if (signal?.aborted) { - controller.error(ERROR_REQUEST_CANCELLED) - return - } + // no body for 204, 205 and 304 + // see https://searchfox.org/mozilla-central/source/dom/fetch/Response.cpp#258 + const body = [204, 205, 304].includes(status) + ? null + : new ReadableStream({ + start: (controller) => { + const streamChannel = new Channel() + streamChannel.onmessage = (res: ArrayBuffer | number[]) => { + // close early if aborted + if (signal?.aborted) { + controller.error(ERROR_REQUEST_CANCELLED) + return + } - const resUint8 = new Uint8Array(res) - const lastByte = resUint8[resUint8.byteLength - 1] - const actualRes = resUint8.slice(0, resUint8.byteLength - 1) + const resUint8 = new Uint8Array(res) + const lastByte = resUint8[resUint8.byteLength - 1] + const actualRes = resUint8.slice(0, resUint8.byteLength - 1) - // close when the signal to close (last byte is 1) is sent from the IPC. - if (lastByte == 1) { - controller.close() - return - } + // close when the signal to close (last byte is 1) is sent from the IPC. + if (lastByte == 1) { + controller.close() + return + } - controller.enqueue(actualRes) - } + controller.enqueue(actualRes) + } - // run a non-blocking body stream fetch - invoke('plugin:http|fetch_read_body', { - rid: responseRid, - streamChannel - }).catch((e) => { - controller.error(e) + // run a non-blocking body stream fetch + invoke('plugin:http|fetch_read_body', { + rid: responseRid, + streamChannel + }).catch((e) => { + controller.error(e) + }) + } }) - } - }) - const res = new Response(status !== 204 ? readableStreamBody : null, { + const res = new Response(body, { status, statusText })