From 558e14bb4c35d7d15a75bc30e7cd8add930ac809 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 16 Oct 2024 09:52:18 +0800 Subject: [PATCH 01/13] chore(deps): update dependency typescript-eslint to v8.9.0 (#1937) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- pnpm-lock.yaml | 102 ++++++++++++++++++++++++------------------------- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/package.json b/package.json index bd9039ab..1d1897fb 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "rollup": "4.22.4", "tslib": "2.7.0", "typescript": "5.6.3", - "typescript-eslint": "8.8.1" + "typescript-eslint": "8.9.0" }, "resolutions": { "semver": ">=7.5.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9005b2d2..a975f431 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -52,8 +52,8 @@ importers: specifier: 5.6.3 version: 5.6.3 typescript-eslint: - specifier: 8.8.1 - version: 8.8.1(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) + specifier: 8.9.0 + version: 8.9.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) examples/api: dependencies: @@ -1028,8 +1028,8 @@ packages: '@types/unist@2.0.11': resolution: {integrity: sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA==} - '@typescript-eslint/eslint-plugin@8.8.1': - resolution: {integrity: sha512-xfvdgA8AP/vxHgtgU310+WBnLB4uJQ9XdyP17RebG26rLtDrQJV3ZYrcopX91GrHmMoH8bdSwMRh2a//TiJ1jQ==} + '@typescript-eslint/eslint-plugin@8.9.0': + resolution: {integrity: sha512-Y1n621OCy4m7/vTXNlCbMVp87zSd7NH0L9cXD8aIpOaNlzeWxIK4+Q19A68gSmTNRZn92UjocVUWDthGxtqHFg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: '@typescript-eslint/parser': ^8.0.0 || ^8.0.0-alpha.0 @@ -1039,8 +1039,8 @@ packages: typescript: optional: true - '@typescript-eslint/parser@8.8.1': - resolution: {integrity: sha512-hQUVn2Lij2NAxVFEdvIGxT9gP1tq2yM83m+by3whWFsWC+1y8pxxxHUFE1UqDu2VsGi2i6RLcv4QvouM84U+ow==} + '@typescript-eslint/parser@8.9.0': + resolution: {integrity: sha512-U+BLn2rqTTHnc4FL3FJjxaXptTxmf9sNftJK62XLz4+GxG3hLHm/SUNaaXP5Y4uTiuYoL5YLy4JBCJe3+t8awQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 @@ -1049,12 +1049,12 @@ packages: typescript: optional: true - '@typescript-eslint/scope-manager@8.8.1': - resolution: {integrity: sha512-X4JdU+66Mazev/J0gfXlcC/dV6JI37h+93W9BRYXrSn0hrE64IoWgVkO9MSJgEzoWkxONgaQpICWg8vAN74wlA==} + '@typescript-eslint/scope-manager@8.9.0': + resolution: {integrity: sha512-bZu9bUud9ym1cabmOYH9S6TnbWRzpklVmwqICeOulTCZ9ue2/pczWzQvt/cGj2r2o1RdKoZbuEMalJJSYw3pHQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typescript-eslint/type-utils@8.8.1': - resolution: {integrity: sha512-qSVnpcbLP8CALORf0za+vjLYj1Wp8HSoiI8zYU5tHxRVj30702Z1Yw4cLwfNKhTPWp5+P+k1pjmD5Zd1nhxiZA==} + '@typescript-eslint/type-utils@8.9.0': + resolution: {integrity: sha512-JD+/pCqlKqAk5961vxCluK+clkppHY07IbV3vett97KOV+8C6l+CPEPwpUuiMwgbOz/qrN3Ke4zzjqbT+ls+1Q==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: typescript: '*' @@ -1062,12 +1062,12 @@ packages: typescript: optional: true - '@typescript-eslint/types@8.8.1': - resolution: {integrity: sha512-WCcTP4SDXzMd23N27u66zTKMuEevH4uzU8C9jf0RO4E04yVHgQgW+r+TeVTNnO1KIfrL8ebgVVYYMMO3+jC55Q==} + '@typescript-eslint/types@8.9.0': + resolution: {integrity: sha512-SjgkvdYyt1FAPhU9c6FiYCXrldwYYlIQLkuc+LfAhCna6ggp96ACncdtlbn8FmnG72tUkXclrDExOpEYf1nfJQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typescript-eslint/typescript-estree@8.8.1': - resolution: {integrity: sha512-A5d1R9p+X+1js4JogdNilDuuq+EHZdsH9MjTVxXOdVFfTJXunKJR/v+fNNyO4TnoOn5HqobzfRlc70NC6HTcdg==} + '@typescript-eslint/typescript-estree@8.9.0': + resolution: {integrity: sha512-9iJYTgKLDG6+iqegehc5+EqE6sqaee7kb8vWpmHZ86EqwDjmlqNNHeqDVqb9duh+BY6WCNHfIGvuVU3Tf9Db0g==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: typescript: '*' @@ -1075,14 +1075,14 @@ packages: typescript: optional: true - '@typescript-eslint/utils@8.8.1': - resolution: {integrity: sha512-/QkNJDbV0bdL7H7d0/y0qBbV2HTtf0TIyjSDTvvmQEzeVx8jEImEbLuOA4EsvE8gIgqMitns0ifb5uQhMj8d9w==} + '@typescript-eslint/utils@8.9.0': + resolution: {integrity: sha512-PKgMmaSo/Yg/F7kIZvrgrWa1+Vwn036CdNUvYFEkYbPwOH4i8xvkaRlu148W3vtheWK9ckKRIz7PBP5oUlkrvQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 - '@typescript-eslint/visitor-keys@8.8.1': - resolution: {integrity: sha512-0/TdC3aeRAsW7MDvYRwEc1Uwm0TIBfzjPFgg60UU2Haj5qsCs9cc3zNgY71edqE3LbWfF/WoZQd3lJoDXFQpag==} + '@typescript-eslint/visitor-keys@8.9.0': + resolution: {integrity: sha512-Ht4y38ubk4L5/U8xKUBfKNYGmvKvA1CANoxiTRMM+tOLk3lbF3DvzZCxJCRSE+2GdCMSh6zq9VZJc3asc1XuAA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} '@unocss/astro@0.63.1': @@ -2145,8 +2145,8 @@ packages: resolution: {integrity: sha512-Ne2YiiGN8bmrmJJEuTWTLJR32nh/JdL1+PSicowtNb0WFpn59GK8/lfD61bVtzguz7b3PBt74nxpv/Pw5po5Rg==} engines: {node: '>=8'} - typescript-eslint@8.8.1: - resolution: {integrity: sha512-R0dsXFt6t4SAFjUSKFjMh4pXDtq04SsFKCVGDP3ZOzNP7itF0jBcZYU4fMsZr4y7O7V7Nc751dDeESbe4PbQMQ==} + typescript-eslint@8.9.0: + resolution: {integrity: sha512-AuD/FXGYRQyqyOBCpNLldMlsCGvmDNxptQ3Dp58/NXeB+FqyvTfXmMyba3PYa0Vi9ybnj7G8S/yd/4Cw8y47eA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: typescript: '*' @@ -2857,14 +2857,14 @@ snapshots: '@types/unist@2.0.11': {} - '@typescript-eslint/eslint-plugin@8.8.1(@typescript-eslint/parser@8.8.1(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3))(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3)': + '@typescript-eslint/eslint-plugin@8.9.0(@typescript-eslint/parser@8.9.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3))(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3)': dependencies: '@eslint-community/regexpp': 4.11.1 - '@typescript-eslint/parser': 8.8.1(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) - '@typescript-eslint/scope-manager': 8.8.1 - '@typescript-eslint/type-utils': 8.8.1(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) - '@typescript-eslint/utils': 8.8.1(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) - '@typescript-eslint/visitor-keys': 8.8.1 + '@typescript-eslint/parser': 8.9.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) + '@typescript-eslint/scope-manager': 8.9.0 + '@typescript-eslint/type-utils': 8.9.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) + '@typescript-eslint/utils': 8.9.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) + '@typescript-eslint/visitor-keys': 8.9.0 eslint: 9.12.0(jiti@2.0.0) graphemer: 1.4.0 ignore: 5.3.2 @@ -2875,12 +2875,12 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/parser@8.8.1(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3)': + '@typescript-eslint/parser@8.9.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3)': dependencies: - '@typescript-eslint/scope-manager': 8.8.1 - '@typescript-eslint/types': 8.8.1 - '@typescript-eslint/typescript-estree': 8.8.1(typescript@5.6.3) - '@typescript-eslint/visitor-keys': 8.8.1 + '@typescript-eslint/scope-manager': 8.9.0 + '@typescript-eslint/types': 8.9.0 + '@typescript-eslint/typescript-estree': 8.9.0(typescript@5.6.3) + '@typescript-eslint/visitor-keys': 8.9.0 debug: 4.3.7(supports-color@8.1.1) eslint: 9.12.0(jiti@2.0.0) optionalDependencies: @@ -2888,15 +2888,15 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/scope-manager@8.8.1': + '@typescript-eslint/scope-manager@8.9.0': dependencies: - '@typescript-eslint/types': 8.8.1 - '@typescript-eslint/visitor-keys': 8.8.1 + '@typescript-eslint/types': 8.9.0 + '@typescript-eslint/visitor-keys': 8.9.0 - '@typescript-eslint/type-utils@8.8.1(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3)': + '@typescript-eslint/type-utils@8.9.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3)': dependencies: - '@typescript-eslint/typescript-estree': 8.8.1(typescript@5.6.3) - '@typescript-eslint/utils': 8.8.1(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) + '@typescript-eslint/typescript-estree': 8.9.0(typescript@5.6.3) + '@typescript-eslint/utils': 8.9.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) debug: 4.3.7(supports-color@8.1.1) ts-api-utils: 1.3.0(typescript@5.6.3) optionalDependencies: @@ -2905,12 +2905,12 @@ snapshots: - eslint - supports-color - '@typescript-eslint/types@8.8.1': {} + '@typescript-eslint/types@8.9.0': {} - '@typescript-eslint/typescript-estree@8.8.1(typescript@5.6.3)': + '@typescript-eslint/typescript-estree@8.9.0(typescript@5.6.3)': dependencies: - '@typescript-eslint/types': 8.8.1 - '@typescript-eslint/visitor-keys': 8.8.1 + '@typescript-eslint/types': 8.9.0 + '@typescript-eslint/visitor-keys': 8.9.0 debug: 4.3.7(supports-color@8.1.1) fast-glob: 3.3.2 is-glob: 4.0.3 @@ -2922,20 +2922,20 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@8.8.1(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3)': + '@typescript-eslint/utils@8.9.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3)': dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@9.12.0(jiti@2.0.0)) - '@typescript-eslint/scope-manager': 8.8.1 - '@typescript-eslint/types': 8.8.1 - '@typescript-eslint/typescript-estree': 8.8.1(typescript@5.6.3) + '@typescript-eslint/scope-manager': 8.9.0 + '@typescript-eslint/types': 8.9.0 + '@typescript-eslint/typescript-estree': 8.9.0(typescript@5.6.3) eslint: 9.12.0(jiti@2.0.0) transitivePeerDependencies: - supports-color - typescript - '@typescript-eslint/visitor-keys@8.8.1': + '@typescript-eslint/visitor-keys@8.9.0': dependencies: - '@typescript-eslint/types': 8.8.1 + '@typescript-eslint/types': 8.9.0 eslint-visitor-keys: 3.4.3 '@unocss/astro@0.63.1(rollup@4.22.4)(vite@5.4.8(terser@5.34.1))': @@ -4137,11 +4137,11 @@ snapshots: type-fest@0.7.1: {} - typescript-eslint@8.8.1(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3): + typescript-eslint@8.9.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3): dependencies: - '@typescript-eslint/eslint-plugin': 8.8.1(@typescript-eslint/parser@8.8.1(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3))(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) - '@typescript-eslint/parser': 8.8.1(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) - '@typescript-eslint/utils': 8.8.1(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) + '@typescript-eslint/eslint-plugin': 8.9.0(@typescript-eslint/parser@8.9.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3))(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) + '@typescript-eslint/parser': 8.9.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) + '@typescript-eslint/utils': 8.9.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) optionalDependencies: typescript: 5.6.3 transitivePeerDependencies: From cfd48b3b2ec0fccfc162197518694ed59ceda22c Mon Sep 17 00:00:00 2001 From: Niko Korvenlaita Date: Wed, 16 Oct 2024 15:56:36 +0300 Subject: [PATCH 02/13] feat: allow http calls without origin header (#1941) --- .changes/http-allow-skip-origin.md | 6 ++++++ plugins/http/src/commands.rs | 8 ++++++++ 2 files changed, 14 insertions(+) create mode 100644 .changes/http-allow-skip-origin.md diff --git a/.changes/http-allow-skip-origin.md b/.changes/http-allow-skip-origin.md new file mode 100644 index 00000000..99062245 --- /dev/null +++ b/.changes/http-allow-skip-origin.md @@ -0,0 +1,6 @@ +--- +"http": "patch" +"http-js": "patch" +--- + +Allow skipping sending `Origin` header in HTTP requests by setting `Origin` header to an empty string when calling `fetch`. diff --git a/plugins/http/src/commands.rs b/plugins/http/src/commands.rs index cda21bd5..39a68973 100644 --- a/plugins/http/src/commands.rs +++ b/plugins/http/src/commands.rs @@ -264,6 +264,14 @@ pub async fn fetch( } } + // In case empty origin is passed, remove it. Some services do not like Origin header + // so this way we can remove it in explicit way. The default behaviour is still to set it + if cfg!(feature = "unsafe-headers") + && headers.get(header::ORIGIN) == Some(&HeaderValue::from_static("")) + { + headers.remove(header::ORIGIN); + }; + if let Some(data) = data { request = request.body(data); } From 8c67d44aef60b1427019538d8420787ef35bd3d5 Mon Sep 17 00:00:00 2001 From: Tony <68118705+Legend-Master@users.noreply.github.com> Date: Thu, 17 Oct 2024 19:14:41 +0800 Subject: [PATCH 03/13] refactor(store)!: more reworks (#1860) * refactor(store): more reworks * Enable auto save by default * Store to resource table by default * Remove share store * Clean up * Add close store * Add store function * Add lazy store * Add init to lazy store * refresh cache in example * Add get-or-create-store * Revert "Add get-or-create-store" This reverts commit 7ffd769240b1973613259bd7b2e5d999db1ce329. * try get first * Docs * Use absolute path for store * more docs * Allow js to use pre-stored (de)serialize functions * Fix js get and close store * Show case how to use pretty json * Update readme * Use store instead of `store_builder` in example * Build * Fix example * More docs for StoreBuilder::build * Add default (de)serialize fn * Use pretty json by default * Use `undefined` for empty value in get * Change files * Differentiate json null from no value for events * Add create or existing * Build * Rename inner store's inset method to set * Update readme * Apply suggestions from code review * Use close instead * Update breaking changes * Return result in resolve_store_path * Change to close_resource and take &self * Clean up * Apply suggestions from code review Co-authored-by: Amr Bashir * Remove unused pub(crate) * Update change file * Expose resolve_store_path * Remove with_store * Remove StoreInner from pub and expose is_empty * Fix wrong jsdoc param * Update readme * rename createOrExistingStore to createOrLoad * make api consistent with the JS implementation, add examples * fmt * reintroduce "get existing store" behavior for create_or_load * rename createOrLoad to newOrExisting * keep store lock throughout whole new_or_existing_inner * Remove load * Missed if load * Don't make StoreState public * Remove R: Runtime from Builder * rename newOrExisting to load, load to reload * update docs * rename missing reload fn * rename builder fn to build() * fix default permission * Fix description and create_new logic * Clippy * Update docs * Update docs * remove create_store command * remove close_store command since we extend from Resource * Revert "remove close_store command since we extend from Resource" This reverts commit 4a29fc8990fed7caec9896b0390a30130ed1813c. * Reapply "remove close_store command since we extend from Resource" This reverts commit 70a1830e7d0f60e9f9b45e91b30ef5eb278e4f7d. --------- Co-authored-by: Amr Bashir Co-authored-by: Lucas Nogueira --- .changes/store-plugin-rework-js-feat.md | 7 + .changes/store-plugin-rework.md | 23 + examples/api/src-tauri/capabilities/base.json | 6 +- examples/api/src-tauri/src/lib.rs | 3 +- examples/api/src/views/Store.svelte | 78 ++- plugins/store/README.md | 59 +-- plugins/store/api-iife.js | 2 +- plugins/store/build.rs | 7 +- .../AppSettingsManager/src-tauri/src/main.rs | 17 +- .../src-tauri/tauri.conf.json | 1 + plugins/store/guest-js/index.ts | 401 ++++++++++++---- .../autogenerated/commands/create_store.toml | 13 - .../autogenerated/commands/get_store.toml | 13 + .../autogenerated/commands/reload.toml | 13 + .../permissions/autogenerated/reference.md | 75 ++- plugins/store/permissions/default.toml | 17 +- plugins/store/permissions/schemas/schema.json | 30 +- plugins/store/src/error.rs | 13 +- plugins/store/src/lib.rs | 447 ++++++++++++------ plugins/store/src/store.rs | 340 ++++++++----- 20 files changed, 1058 insertions(+), 507 deletions(-) create mode 100644 .changes/store-plugin-rework-js-feat.md create mode 100644 .changes/store-plugin-rework.md delete mode 100644 plugins/store/permissions/autogenerated/commands/create_store.toml create mode 100644 plugins/store/permissions/autogenerated/commands/get_store.toml create mode 100644 plugins/store/permissions/autogenerated/commands/reload.toml diff --git a/.changes/store-plugin-rework-js-feat.md b/.changes/store-plugin-rework-js-feat.md new file mode 100644 index 00000000..3306af24 --- /dev/null +++ b/.changes/store-plugin-rework-js-feat.md @@ -0,0 +1,7 @@ +--- +"store-js": minor:feat +--- + +- Add `getStore` +- Add an option to use pre-stored (de)serialize functions (registered on rust) +- Add `LazyStore` diff --git a/.changes/store-plugin-rework.md b/.changes/store-plugin-rework.md new file mode 100644 index 00000000..0d9584af --- /dev/null +++ b/.changes/store-plugin-rework.md @@ -0,0 +1,23 @@ +--- +"store": minor:breaking +--- + +### Breaking changes: + +- Renamed `StoreCollection` to `StoreState` +- `StoreBuilder::build` now returns a `Result` +- `StoreExt::store` now returns `Result>` + +### Enhancements: + +- Save and cancel pending auto save on drop +- Use absolute path as store's key, fix #984 +- Share store to resource table by default +- Enable auto save with 100ms debounce time by default +- Use pretty json by default, close #1690 + +### New features: + +- Add `get_store` to get shared stores across js and rust side +- Add default (de)serialize functions settings `default_serialize_fn` and `default_deserialize_fn` +- Allow js to use pre-stored (de)serialize functions registered by `register_serialize_fn` and `register_deserialize_fn` diff --git a/examples/api/src-tauri/capabilities/base.json b/examples/api/src-tauri/capabilities/base.json index b76e898c..607828e9 100644 --- a/examples/api/src-tauri/capabilities/base.json +++ b/examples/api/src-tauri/capabilities/base.json @@ -79,10 +79,6 @@ ], "deny": ["$APPDATA/db/*.stronghold"] }, - "store:allow-entries", - "store:allow-get", - "store:allow-set", - "store:allow-save", - "store:allow-load" + "store:default" ] } diff --git a/examples/api/src-tauri/src/lib.rs b/examples/api/src-tauri/src/lib.rs index f3cacc43..701f6731 100644 --- a/examples/api/src-tauri/src/lib.rs +++ b/examples/api/src-tauri/src/lib.rs @@ -67,7 +67,8 @@ pub fn run() { .user_agent(&format!("Tauri API - {}", std::env::consts::OS)) .title("Tauri API Validation") .inner_size(1000., 800.) - .min_inner_size(600., 400.); + .min_inner_size(600., 400.) + .visible(false); } #[cfg(target_os = "windows")] diff --git a/examples/api/src/views/Store.svelte b/examples/api/src/views/Store.svelte index d8e6653b..6248b009 100644 --- a/examples/api/src/views/Store.svelte +++ b/examples/api/src/views/Store.svelte @@ -1,5 +1,5 @@ @@ -44,7 +81,12 @@ - +
+ + + + +
diff --git a/plugins/store/README.md b/plugins/store/README.md index 391d7a0c..7ab63fd4 100644 --- a/plugins/store/README.md +++ b/plugins/store/README.md @@ -70,7 +70,7 @@ Afterwards all the plugin's APIs are available through the JavaScript guest bind ```typescript import { Store } from '@tauri-apps/plugin-store' -const store = new Store('.settings.dat') +const store = await Store.load('settings.json') await store.set('some-key', { value: 5 }) @@ -81,14 +81,11 @@ if (val) { } else { console.log('val is null') } - -// This manually saves the store. -await store.save() ``` ### Persisting Values -As seen above, values added to the store are not persisted between application loads unless the application is closed gracefully. +Modifications made to the store are automatically saved by default You can manually save a store with: @@ -103,65 +100,43 @@ However, you can also load them manually later like so: await store.load() ``` +### LazyStore + +There's also a high level API `LazyStore` which only loads the store on first access, note that the options will be ignored if a `Store` with that path has already been created + +```typescript +import { LazyStore } from '@tauri-apps/plugin-store' + +const store = new LazyStore('settings.json') +``` + ## Usage from Rust You can also create `Store` instances directly in Rust: ```rust -use tauri_plugin_store::StoreBuilder; +use tauri_plugin_store::StoreExt; use serde_json::json; fn main() { tauri::Builder::default() .plugin(tauri_plugin_store::Builder::default().build()) .setup(|app| { - let mut store = StoreBuilder::new("app_data.bin").build(app.handle().clone()); - - // Attempt to load the store, if it's saved already. - store.load().expect("Failed to load store from disk"); + // This loads the store from disk + let store = app.store("app_data.json")?; // Note that values must be serde_json::Value instances, // otherwise, they will not be compatible with the JavaScript bindings. - store.insert("a".to_string(), json!("b")); - - // You can manually save the store after making changes. - // Otherwise, it will save upon graceful exit as described above. - store.save() + store.set("a".to_string(), json!("b")); }) .run(tauri::generate_context!()) .expect("error while running tauri application"); } ``` -### Loading Gracefully - -If you call `load` on a `Store` that hasn't yet been written to the disk, it will return an error. You must handle this error if you want to gracefully continue and use the default store until you save it to the disk. The example above shows how to do this. - -For example, this would cause a panic if the store has not yet been created: - -```rust -store.load().unwrap(); -``` - -Rather than silently continuing like you may expect. - -You should always handle the error appropriately rather than unwrapping, or you may experience unexpected app crashes: - -```rust -store.load().expect("Failed to load store from disk"); -``` - ### Frontend Interoperability -As you may have noticed, the `Store` crated above isn't accessible to the frontend. To interoperate with stores created by JavaScript use the exported `with_store` method: - -```rust -use tauri::Wry; -use tauri_plugin_store::StoreExt; - -let store = app.store_builder("app_data.bin").build(); -store.insert("key", "value"); -``` +The store created from both Rust side and JavaScript side are stored in the app's resource table and can be accessed by both sides, you can access it by using the same path, with `getStore` and `LazyStore` in the JavaScript side and `get_store` and `store` in the Rust side ## Contributing diff --git a/plugins/store/api-iife.js b/plugins/store/api-iife.js index 77295d7f..fc04ff00 100644 --- a/plugins/store/api-iife.js +++ b/plugins/store/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_PLUGIN_STORE__=function(e){"use strict";var t,r;function a(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}async function i(e,t={},r){return window.__TAURI_INTERNALS__.invoke(e,t,r)}"function"==typeof SuppressedError&&SuppressedError;class n{get rid(){return function(e,t,r,a){if("a"===r&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?a:"a"===r?a.call(e):a?a.value:t.get(e)}(this,t,"f")}constructor(e){t.set(this,void 0),function(e,t,r,a,i){if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");t.set(e,r)}(this,t,e)}async close(){return i("plugin:resources|close",{rid:this.rid})}}async function s(e,t,r){const n={kind:"Any"};return i("plugin:event|listen",{event:e,target:n,handler:a(t)}).then((t=>async()=>async function(e,t){await i("plugin:event|unlisten",{event:e,eventId:t})}(e,t)))}t=new WeakMap,function(e){e.WINDOW_RESIZED="tauri://resize",e.WINDOW_MOVED="tauri://move",e.WINDOW_CLOSE_REQUESTED="tauri://close-requested",e.WINDOW_DESTROYED="tauri://destroyed",e.WINDOW_FOCUS="tauri://focus",e.WINDOW_BLUR="tauri://blur",e.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",e.WINDOW_THEME_CHANGED="tauri://theme-changed",e.WINDOW_CREATED="tauri://window-created",e.WEBVIEW_CREATED="tauri://webview-created",e.DRAG_ENTER="tauri://drag-enter",e.DRAG_OVER="tauri://drag-over",e.DRAG_DROP="tauri://drag-drop",e.DRAG_LEAVE="tauri://drag-leave"}(r||(r={}));class o extends n{constructor(e,t){super(e),this.path=t}async set(e,t){await i("plugin:store|set",{rid:this.rid,key:e,value:t})}async get(e){return await i("plugin:store|get",{rid:this.rid,key:e})}async has(e){return await i("plugin:store|has",{rid:this.rid,key:e})}async delete(e){return await i("plugin:store|delete",{rid:this.rid,key:e})}async clear(){await i("plugin:store|clear",{rid:this.rid})}async reset(){await i("plugin:store|reset",{rid:this.rid})}async keys(){return await i("plugin:store|keys",{rid:this.rid})}async values(){return await i("plugin:store|values",{rid:this.rid})}async entries(){return await i("plugin:store|entries",{rid:this.rid})}async length(){return await i("plugin:store|length",{rid:this.rid})}async load(){await i("plugin:store|load",{rid:this.rid})}async save(){await i("plugin:store|save",{rid:this.rid})}async onKeyChange(e,t){return await s("store://change",(r=>{r.payload.path===this.path&&r.payload.key===e&&t(r.payload.value)}))}async onChange(e){return await s("store://change",(t=>{t.payload.path===this.path&&e(t.payload.key,t.payload.value)}))}}return e.Store=o,e.createStore=async function(e,t){const r=await i("plugin:store|create_store",{path:e,...t});return new o(r,e)},e}({});Object.defineProperty(window.__TAURI__,"store",{value:__TAURI_PLUGIN_STORE__})} +if("__TAURI__"in window){var __TAURI_PLUGIN_STORE__=function(t){"use strict";var e,a;function r(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}async function s(t,e={},a){return window.__TAURI_INTERNALS__.invoke(t,e,a)}"function"==typeof SuppressedError&&SuppressedError;class i{get rid(){return function(t,e,a,r){if("a"===a&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?r:"a"===a?r.call(t):r?r.value:e.get(t)}(this,e,"f")}constructor(t){e.set(this,void 0),function(t,e,a,r,s){if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");e.set(t,a)}(this,e,t)}async close(){return s("plugin:resources|close",{rid:this.rid})}}async function n(t,e,a){const i={kind:"Any"};return s("plugin:event|listen",{event:t,target:i,handler:r(e)}).then((e=>async()=>async function(t,e){await s("plugin:event|unlisten",{event:t,eventId:e})}(t,e)))}async function o(t,e){return await u.load(t,e)}e=new WeakMap,function(t){t.WINDOW_RESIZED="tauri://resize",t.WINDOW_MOVED="tauri://move",t.WINDOW_CLOSE_REQUESTED="tauri://close-requested",t.WINDOW_DESTROYED="tauri://destroyed",t.WINDOW_FOCUS="tauri://focus",t.WINDOW_BLUR="tauri://blur",t.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",t.WINDOW_THEME_CHANGED="tauri://theme-changed",t.WINDOW_CREATED="tauri://window-created",t.WEBVIEW_CREATED="tauri://webview-created",t.DRAG_ENTER="tauri://drag-enter",t.DRAG_OVER="tauri://drag-over",t.DRAG_DROP="tauri://drag-drop",t.DRAG_LEAVE="tauri://drag-leave"}(a||(a={}));class u extends i{constructor(t){super(t)}static async load(t,e){const a=await s("plugin:store|load",{path:t,...e});return new u(a)}static async get(t){return await s("plugin:store|get_store",{path:t}).then((t=>t?new u(t):null))}async set(t,e){await s("plugin:store|set",{rid:this.rid,key:t,value:e})}async get(t){const[e,a]=await s("plugin:store|get",{rid:this.rid,key:t});return a?e:void 0}async has(t){return await s("plugin:store|has",{rid:this.rid,key:t})}async delete(t){return await s("plugin:store|delete",{rid:this.rid,key:t})}async clear(){await s("plugin:store|clear",{rid:this.rid})}async reset(){await s("plugin:store|reset",{rid:this.rid})}async keys(){return await s("plugin:store|keys",{rid:this.rid})}async values(){return await s("plugin:store|values",{rid:this.rid})}async entries(){return await s("plugin:store|entries",{rid:this.rid})}async length(){return await s("plugin:store|length",{rid:this.rid})}async reload(){await s("plugin:store|reload",{rid:this.rid})}async save(){await s("plugin:store|save",{rid:this.rid})}async onKeyChange(t,e){return await n("store://change",(a=>{a.payload.resourceId===this.rid&&a.payload.key===t&&e(a.payload.exists?a.payload.value:void 0)}))}async onChange(t){return await n("store://change",(e=>{e.payload.resourceId===this.rid&&t(e.payload.key,e.payload.exists?e.payload.value:void 0)}))}}return t.LazyStore=class{get store(){return this._store||(this._store=o(this.path,this.options)),this._store}constructor(t,e){this.path=t,this.options=e}async init(){await this.store}async set(t,e){return(await this.store).set(t,e)}async get(t){return(await this.store).get(t)}async has(t){return(await this.store).has(t)}async delete(t){return(await this.store).delete(t)}async clear(){await(await this.store).clear()}async reset(){await(await this.store).reset()}async keys(){return(await this.store).keys()}async values(){return(await this.store).values()}async entries(){return(await this.store).entries()}async length(){return(await this.store).length()}async reload(){await(await this.store).reload()}async save(){await(await this.store).save()}async onKeyChange(t,e){return(await this.store).onKeyChange(t,e)}async onChange(t){return(await this.store).onChange(t)}async close(){this._store&&await(await this._store).close()}},t.Store=u,t.getStore=async function(t){return await u.get(t)},t.load=o,t}({});Object.defineProperty(window.__TAURI__,"store",{value:__TAURI_PLUGIN_STORE__})} diff --git a/plugins/store/build.rs b/plugins/store/build.rs index 3c9fee01..2e88d59a 100644 --- a/plugins/store/build.rs +++ b/plugins/store/build.rs @@ -3,7 +3,8 @@ // SPDX-License-Identifier: MIT const COMMANDS: &[&str] = &[ - "create_store", + "load", + "get_store", "set", "get", "has", @@ -12,9 +13,9 @@ const COMMANDS: &[&str] = &[ "reset", "keys", "values", - "length", "entries", - "load", + "length", + "reload", "save", ]; diff --git a/plugins/store/examples/AppSettingsManager/src-tauri/src/main.rs b/plugins/store/examples/AppSettingsManager/src-tauri/src/main.rs index 0dd4e0bc..f20db4fc 100644 --- a/plugins/store/examples/AppSettingsManager/src-tauri/src/main.rs +++ b/plugins/store/examples/AppSettingsManager/src-tauri/src/main.rs @@ -5,9 +5,8 @@ // Prevents additional console window on Windows in release, DO NOT REMOVE!! #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] -use std::time::Duration; - use serde_json::json; +use tauri::Listener; use tauri_plugin_store::StoreExt; mod app; @@ -18,17 +17,11 @@ fn main() { .plugin(tauri_plugin_store::Builder::new().build()) .setup(|app| { // Init store and load it from disk - let store = app - .handle() - .store_builder("settings.json") - .auto_save(Duration::from_millis(100)) - .build(); - - // If there are no saved settings yet, this will return an error so we ignore the return value. - let _ = store.load(); - + let store = app.store("settings.json")?; + app.listen("store://change", |event| { + dbg!(event); + }); let app_settings = AppSettings::load_from_store(&store); - match app_settings { Ok(app_settings) => { let theme = app_settings.theme; diff --git a/plugins/store/examples/AppSettingsManager/src-tauri/tauri.conf.json b/plugins/store/examples/AppSettingsManager/src-tauri/tauri.conf.json index 5a67883d..d3f60daa 100644 --- a/plugins/store/examples/AppSettingsManager/src-tauri/tauri.conf.json +++ b/plugins/store/examples/AppSettingsManager/src-tauri/tauri.conf.json @@ -3,6 +3,7 @@ "version": "0.1.0", "identifier": "com.tauri.app-settings-manager", "build": { + "devUrl": "http://localhost:1420", "frontendDist": "../dist" }, "app": { diff --git a/plugins/store/guest-js/index.ts b/plugins/store/guest-js/index.ts index 259b0662..1df89fd5 100644 --- a/plugins/store/guest-js/index.ts +++ b/plugins/store/guest-js/index.ts @@ -8,8 +8,10 @@ import { invoke, Resource } from '@tauri-apps/api/core' interface ChangePayload { path: string + resourceId?: number key: string - value: T | null + value: T + exists: boolean } /** @@ -17,41 +19,213 @@ interface ChangePayload { */ export type StoreOptions = { /** - * Auto save on modification with debounce duration in milliseconds + * Auto save on modification with debounce duration in milliseconds, it's 100ms by default, pass in `false` to disable it */ - autoSave?: boolean + autoSave?: boolean | number + /** + * Name of a serialize function registered in the rust side plugin builder + */ + serializeFnName?: string + /** + * Name of a deserialize function registered in the rust side plugin builder + */ + deserializeFnName?: string + /** + * Force create a new store with default values even if it already exists. + */ + createNew?: boolean +} + +/** + * Create a new Store or load the existing store with the path. + * + * @example + * ```typescript + * import { Store } from '@tauri-apps/api/store'; + * const store = await Store.load('store.json'); + * ``` + * + * @param path Path to save the store in `app_data_dir` + * @param options Store configuration options + */ +export async function load( + path: string, + options?: StoreOptions +): Promise { + return await Store.load(path, options) } /** - * @param path: Path to save the store in `app_data_dir` - * @param options: Store configuration options + * Gets an already loaded store. + * + * If the store is not loaded, returns `null`. In this case you must {@link Store.load load} it. + * + * This function is more useful when you already know the store is loaded + * and just need to access its instance. Prefer {@link Store.load} otherwise. + * + * @example + * ```typescript + * import { getStore } from '@tauri-apps/api/store'; + * const store = await getStore('store.json'); + * ``` + * + * @param path Path of the store. */ -export async function createStore(path: string, options?: StoreOptions) { - const resourceId = await invoke('plugin:store|create_store', { - path, - ...options - }) - return new Store(resourceId, path) +export async function getStore(path: string): Promise { + return await Store.get(path) } /** * A lazy loaded key-value store persisted by the backend layer. */ -export class Store extends Resource { +export class LazyStore implements IStore { + private _store?: Promise + + private get store(): Promise { + if (!this._store) { + this._store = load(this.path, this.options) + } + return this._store + } + + /** + * Note that the options are not applied if someone else already created the store + * @param path Path to save the store in `app_data_dir` + * @param options Store configuration options + */ constructor( - rid: number, - private readonly path: string - ) { + private readonly path: string, + private readonly options?: StoreOptions + ) {} + + /** + * Init/load the store if it's not loaded already + */ + async init(): Promise { + await this.store + } + + async set(key: string, value: unknown): Promise { + return (await this.store).set(key, value) + } + + async get(key: string): Promise { + return (await this.store).get(key) + } + + async has(key: string): Promise { + return (await this.store).has(key) + } + + async delete(key: string): Promise { + return (await this.store).delete(key) + } + + async clear(): Promise { + await (await this.store).clear() + } + + async reset(): Promise { + await (await this.store).reset() + } + + async keys(): Promise { + return (await this.store).keys() + } + + async values(): Promise { + return (await this.store).values() + } + + async entries(): Promise> { + return (await this.store).entries() + } + + async length(): Promise { + return (await this.store).length() + } + + async reload(): Promise { + await (await this.store).reload() + } + + async save(): Promise { + await (await this.store).save() + } + + async onKeyChange( + key: string, + cb: (value: T | undefined) => void + ): Promise { + return (await this.store).onKeyChange(key, cb) + } + + async onChange( + cb: (key: string, value: T | undefined) => void + ): Promise { + return (await this.store).onChange(cb) + } + + async close(): Promise { + if (this._store) { + await (await this._store).close() + } + } +} + +/** + * A key-value store persisted by the backend layer. + */ +export class Store extends Resource implements IStore { + private constructor(rid: number) { super(rid) } /** - * Inserts a key-value pair into the store. + * Create a new Store or load the existing store with the path. * - * @param key - * @param value - * @returns + * @example + * ```typescript + * import { Store } from '@tauri-apps/api/store'; + * const store = await Store.load('store.json'); + * ``` + * + * @param path Path to save the store in `app_data_dir` + * @param options Store configuration options */ + static async load(path: string, options?: StoreOptions): Promise { + const rid = await invoke('plugin:store|load', { + path, + ...options + }) + return new Store(rid) + } + + /** + * Gets an already loaded store. + * + * If the store is not loaded, returns `null`. In this case you must {@link Store.load load} it. + * + * This function is more useful when you already know the store is loaded + * and just need to access its instance. Prefer {@link Store.load} otherwise. + * + * @example + * ```typescript + * import { Store } from '@tauri-apps/api/store'; + * let store = await Store.get('store.json'); + * if (!store) { + * store = await Store.load('store.json'); + * } + * ``` + * + * @param path Path of the store. + */ + static async get(path: string): Promise { + return await invoke('plugin:store|get_store', { path }).then( + (rid) => (rid ? new Store(rid) : null) + ) + } + async set(key: string, value: unknown): Promise { await invoke('plugin:store|set', { rid: this.rid, @@ -60,18 +234,102 @@ export class Store extends Resource { }) } + async get(key: string): Promise { + const [value, exists] = await invoke<[T, boolean]>('plugin:store|get', { + rid: this.rid, + key + }) + return exists ? value : undefined + } + + async has(key: string): Promise { + return await invoke('plugin:store|has', { + rid: this.rid, + key + }) + } + + async delete(key: string): Promise { + return await invoke('plugin:store|delete', { + rid: this.rid, + key + }) + } + + async clear(): Promise { + await invoke('plugin:store|clear', { rid: this.rid }) + } + + async reset(): Promise { + await invoke('plugin:store|reset', { rid: this.rid }) + } + + async keys(): Promise { + return await invoke('plugin:store|keys', { rid: this.rid }) + } + + async values(): Promise { + return await invoke('plugin:store|values', { rid: this.rid }) + } + + async entries(): Promise> { + return await invoke('plugin:store|entries', { rid: this.rid }) + } + + async length(): Promise { + return await invoke('plugin:store|length', { rid: this.rid }) + } + + async reload(): Promise { + await invoke('plugin:store|reload', { rid: this.rid }) + } + + async save(): Promise { + await invoke('plugin:store|save', { rid: this.rid }) + } + + async onKeyChange( + key: string, + cb: (value: T | undefined) => void + ): Promise { + return await listen>('store://change', (event) => { + if (event.payload.resourceId === this.rid && event.payload.key === key) { + cb(event.payload.exists ? event.payload.value : undefined) + } + }) + } + + async onChange( + cb: (key: string, value: T | undefined) => void + ): Promise { + return await listen>('store://change', (event) => { + if (event.payload.resourceId === this.rid) { + cb( + event.payload.key, + event.payload.exists ? event.payload.value : undefined + ) + } + }) + } +} + +interface IStore { /** - * Returns the value for the given `key` or `null` the key does not exist. + * Inserts a key-value pair into the store. * * @param key + * @param value * @returns */ - async get(key: string): Promise { - return await invoke('plugin:store|get', { - rid: this.rid, - key - }) - } + set(key: string, value: unknown): Promise + + /** + * Returns the value for the given `key` or `undefined` if the key does not exist. + * + * @param key + * @returns + */ + get(key: string): Promise /** * Returns `true` if the given `key` exists in the store. @@ -79,12 +337,7 @@ export class Store extends Resource { * @param key * @returns */ - async has(key: string): Promise { - return await invoke('plugin:store|has', { - rid: this.rid, - key - }) - } + has(key: string): Promise /** * Removes a key-value pair from the store. @@ -92,91 +345,67 @@ export class Store extends Resource { * @param key * @returns */ - async delete(key: string): Promise { - return await invoke('plugin:store|delete', { - rid: this.rid, - key - }) - } + delete(key: string): Promise /** * Clears the store, removing all key-value pairs. * - * Note: To clear the storage and reset it to it's `default` value, use `reset` instead. + * Note: To clear the storage and reset it to its `default` value, use {@linkcode reset} instead. * @returns */ - async clear(): Promise { - await invoke('plugin:store|clear', { rid: this.rid }) - } + clear(): Promise /** - * Resets the store to it's `default` value. + * Resets the store to its `default` value. * - * If no default value has been set, this method behaves identical to `clear`. + * If no default value has been set, this method behaves identical to {@linkcode clear}. * @returns */ - async reset(): Promise { - await invoke('plugin:store|reset', { rid: this.rid }) - } + reset(): Promise /** - * Returns a list of all key in the store. + * Returns a list of all keys in the store. * * @returns */ - async keys(): Promise { - return await invoke('plugin:store|keys', { rid: this.rid }) - } + keys(): Promise /** * Returns a list of all values in the store. * * @returns */ - async values(): Promise { - return await invoke('plugin:store|values', { rid: this.rid }) - } + values(): Promise /** * Returns a list of all entries in the store. * * @returns */ - async entries(): Promise> { - return await invoke('plugin:store|entries', { rid: this.rid }) - } + entries(): Promise> /** * Returns the number of key-value pairs in the store. * * @returns */ - async length(): Promise { - return await invoke('plugin:store|length', { rid: this.rid }) - } + length(): Promise /** - * Attempts to load the on-disk state at the stores `path` into memory. + * Attempts to load the on-disk state at the store's `path` into memory. * * This method is useful if the on-disk state was edited by the user and you want to synchronize the changes. * * Note: This method does not emit change events. * @returns */ - async load(): Promise { - await invoke('plugin:store|load', { rid: this.rid }) - } + reload(): Promise /** - * Saves the store to disk at the stores `path`. - * - * As the store is only persisted to disk before the apps exit, changes might be lost in a crash. - * This method lets you persist the store to disk whenever you deem necessary. + * Saves the store to disk at the store's `path`. * @returns */ - async save(): Promise { - await invoke('plugin:store|save', { rid: this.rid }) - } + save(): Promise /** * Listen to changes on a store key. @@ -186,16 +415,10 @@ export class Store extends Resource { * * @since 2.0.0 */ - async onKeyChange( + onKeyChange( key: string, - cb: (value: T | null) => void - ): Promise { - return await listen>('store://change', (event) => { - if (event.payload.path === this.path && event.payload.key === key) { - cb(event.payload.value) - } - }) - } + cb: (value: T | undefined) => void + ): Promise /** * Listen to changes on the store. @@ -204,13 +427,13 @@ export class Store extends Resource { * * @since 2.0.0 */ - async onChange( - cb: (key: string, value: T | null) => void - ): Promise { - return await listen>('store://change', (event) => { - if (event.payload.path === this.path) { - cb(event.payload.key, event.payload.value) - } - }) - } + onChange( + cb: (key: string, value: T | undefined) => void + ): Promise + + /** + * Close the store and cleans up this resource from memory. + * **You should not call any method on this object anymore and should drop any reference to it.** + */ + close(): Promise } diff --git a/plugins/store/permissions/autogenerated/commands/create_store.toml b/plugins/store/permissions/autogenerated/commands/create_store.toml deleted file mode 100644 index cde71c24..00000000 --- a/plugins/store/permissions/autogenerated/commands/create_store.toml +++ /dev/null @@ -1,13 +0,0 @@ -# Automatically generated - DO NOT EDIT! - -"$schema" = "../../schemas/schema.json" - -[[permission]] -identifier = "allow-create-store" -description = "Enables the create_store command without any pre-configured scope." -commands.allow = ["create_store"] - -[[permission]] -identifier = "deny-create-store" -description = "Denies the create_store command without any pre-configured scope." -commands.deny = ["create_store"] diff --git a/plugins/store/permissions/autogenerated/commands/get_store.toml b/plugins/store/permissions/autogenerated/commands/get_store.toml new file mode 100644 index 00000000..7c19173a --- /dev/null +++ b/plugins/store/permissions/autogenerated/commands/get_store.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-get-store" +description = "Enables the get_store command without any pre-configured scope." +commands.allow = ["get_store"] + +[[permission]] +identifier = "deny-get-store" +description = "Denies the get_store command without any pre-configured scope." +commands.deny = ["get_store"] diff --git a/plugins/store/permissions/autogenerated/commands/reload.toml b/plugins/store/permissions/autogenerated/commands/reload.toml new file mode 100644 index 00000000..92e25253 --- /dev/null +++ b/plugins/store/permissions/autogenerated/commands/reload.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-reload" +description = "Enables the reload command without any pre-configured scope." +commands.allow = ["reload"] + +[[permission]] +identifier = "deny-reload" +description = "Denies the reload command without any pre-configured scope." +commands.deny = ["reload"] diff --git a/plugins/store/permissions/autogenerated/reference.md b/plugins/store/permissions/autogenerated/reference.md index 4e9bf2cc..5640415d 100644 --- a/plugins/store/permissions/autogenerated/reference.md +++ b/plugins/store/permissions/autogenerated/reference.md @@ -9,19 +9,20 @@ All operations are enabled by default. -- `allow-create-store` -- `allow-clear` -- `allow-delete` -- `allow-entries` +- `allow-load` +- `allow-get-store` +- `allow-set` - `allow-get` - `allow-has` +- `allow-delete` +- `allow-clear` +- `allow-reset` - `allow-keys` +- `allow-values` +- `allow-entries` - `allow-length` -- `allow-load` -- `allow-reset` +- `allow-reload` - `allow-save` -- `allow-set` -- `allow-values` ## Permission Table @@ -61,12 +62,12 @@ Denies the clear command without any pre-configured scope. -`store:allow-create-store` +`store:allow-delete` -Enables the create_store command without any pre-configured scope. +Enables the delete command without any pre-configured scope. @@ -74,12 +75,12 @@ Enables the create_store command without any pre-configured scope. -`store:deny-create-store` +`store:deny-delete` -Denies the create_store command without any pre-configured scope. +Denies the delete command without any pre-configured scope. @@ -87,12 +88,12 @@ Denies the create_store command without any pre-configured scope. -`store:allow-delete` +`store:allow-entries` -Enables the delete command without any pre-configured scope. +Enables the entries command without any pre-configured scope. @@ -100,12 +101,12 @@ Enables the delete command without any pre-configured scope. -`store:deny-delete` +`store:deny-entries` -Denies the delete command without any pre-configured scope. +Denies the entries command without any pre-configured scope. @@ -113,12 +114,12 @@ Denies the delete command without any pre-configured scope. -`store:allow-entries` +`store:allow-get` -Enables the entries command without any pre-configured scope. +Enables the get command without any pre-configured scope. @@ -126,12 +127,12 @@ Enables the entries command without any pre-configured scope. -`store:deny-entries` +`store:deny-get` -Denies the entries command without any pre-configured scope. +Denies the get command without any pre-configured scope. @@ -139,12 +140,12 @@ Denies the entries command without any pre-configured scope. -`store:allow-get` +`store:allow-get-store` -Enables the get command without any pre-configured scope. +Enables the get_store command without any pre-configured scope. @@ -152,12 +153,12 @@ Enables the get command without any pre-configured scope. -`store:deny-get` +`store:deny-get-store` -Denies the get command without any pre-configured scope. +Denies the get_store command without any pre-configured scope. @@ -269,6 +270,32 @@ Denies the load command without any pre-configured scope. +`store:allow-reload` + + + + +Enables the reload command without any pre-configured scope. + + + + + + + +`store:deny-reload` + + + + +Denies the reload command without any pre-configured scope. + + + + + + + `store:allow-reset` diff --git a/plugins/store/permissions/default.toml b/plugins/store/permissions/default.toml index bf888679..3a3e4b3a 100644 --- a/plugins/store/permissions/default.toml +++ b/plugins/store/permissions/default.toml @@ -11,17 +11,18 @@ All operations are enabled by default. """ permissions = [ - "allow-create-store", - "allow-clear", - "allow-delete", - "allow-entries", + "allow-load", + "allow-get-store", + "allow-set", "allow-get", "allow-has", + "allow-delete", + "allow-clear", + "allow-reset", "allow-keys", + "allow-values", + "allow-entries", "allow-length", - "allow-load", - "allow-reset", + "allow-reload", "allow-save", - "allow-set", - "allow-values", ] diff --git a/plugins/store/permissions/schemas/schema.json b/plugins/store/permissions/schemas/schema.json index 6ebf788e..4237bc62 100644 --- a/plugins/store/permissions/schemas/schema.json +++ b/plugins/store/permissions/schemas/schema.json @@ -304,16 +304,6 @@ "type": "string", "const": "deny-clear" }, - { - "description": "Enables the create_store command without any pre-configured scope.", - "type": "string", - "const": "allow-create-store" - }, - { - "description": "Denies the create_store command without any pre-configured scope.", - "type": "string", - "const": "deny-create-store" - }, { "description": "Enables the delete command without any pre-configured scope.", "type": "string", @@ -344,6 +334,16 @@ "type": "string", "const": "deny-get" }, + { + "description": "Enables the get_store command without any pre-configured scope.", + "type": "string", + "const": "allow-get-store" + }, + { + "description": "Denies the get_store command without any pre-configured scope.", + "type": "string", + "const": "deny-get-store" + }, { "description": "Enables the has command without any pre-configured scope.", "type": "string", @@ -384,6 +384,16 @@ "type": "string", "const": "deny-load" }, + { + "description": "Enables the reload command without any pre-configured scope.", + "type": "string", + "const": "allow-reload" + }, + { + "description": "Denies the reload command without any pre-configured scope.", + "type": "string", + "const": "deny-reload" + }, { "description": "Enables the reset command without any pre-configured scope.", "type": "string", diff --git a/plugins/store/src/error.rs b/plugins/store/src/error.rs index afd43add..ef5ee593 100644 --- a/plugins/store/src/error.rs +++ b/plugins/store/src/error.rs @@ -3,7 +3,6 @@ // SPDX-License-Identifier: MIT use serde::{Serialize, Serializer}; -use std::path::PathBuf; pub type Result = std::result::Result; @@ -21,9 +20,15 @@ pub enum Error { /// IO error. #[error(transparent)] Io(#[from] std::io::Error), - /// Store not found - #[error("Store \"{0}\" not found")] - NotFound(PathBuf), + // /// Store already exists + // #[error("Store at \"{0}\" already exists")] + // AlreadyExists(PathBuf), + /// Serialize function not found + #[error("Serialize Function \"{0}\" not found")] + SerializeFunctionNotFound(String), + /// Deserialize function not found + #[error("Deserialize Function \"{0}\" not found")] + DeserializeFunctionNotFound(String), /// Some Tauri API failed #[error(transparent)] Tauri(#[from] tauri::Error), diff --git a/plugins/store/src/lib.rs b/plugins/store/src/lib.rs index b05bf4b4..310e80ec 100644 --- a/plugins/store/src/lib.rs +++ b/plugins/store/src/lib.rs @@ -12,234 +12,392 @@ )] pub use error::{Error, Result}; -use log::warn; -use serde::Serialize; +use serde::{Deserialize, Serialize}; pub use serde_json::Value as JsonValue; use std::{ collections::HashMap, path::{Path, PathBuf}, - sync::{Mutex, Weak}, + sync::{Arc, Mutex}, time::Duration, }; -pub use store::{Store, StoreBuilder, StoreInner}; +pub use store::{resolve_store_path, DeserializeFn, SerializeFn, Store, StoreBuilder}; use tauri::{ plugin::{self, TauriPlugin}, - AppHandle, Manager, ResourceId, RunEvent, Runtime, Webview, + AppHandle, Manager, ResourceId, RunEvent, Runtime, State, }; mod error; mod store; #[derive(Serialize, Clone)] +#[serde(rename_all = "camelCase")] struct ChangePayload<'a> { path: &'a Path, + resource_id: Option, key: &'a str, - value: &'a JsonValue, + value: Option<&'a JsonValue>, + exists: bool, } -pub struct StoreCollection { - stores: Mutex>>>>, - // frozen: bool, +#[derive(Debug)] +struct StoreState { + stores: Arc>>, + serialize_fns: HashMap, + deserialize_fns: HashMap, + default_serialize: SerializeFn, + default_deserialize: DeserializeFn, } -#[tauri::command] -async fn create_store( +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +enum AutoSave { + DebounceDuration(u64), + Bool(bool), +} + +fn builder( app: AppHandle, - webview: Webview, + store_state: State<'_, StoreState>, path: PathBuf, - auto_save: Option, -) -> Result { + auto_save: Option, + serialize_fn_name: Option, + deserialize_fn_name: Option, + create_new: bool, +) -> Result> { let mut builder = app.store_builder(path); if let Some(auto_save) = auto_save { - builder = builder.auto_save(Duration::from_millis(auto_save)); + match auto_save { + AutoSave::DebounceDuration(duration) => { + builder = builder.auto_save(Duration::from_millis(duration)); + } + AutoSave::Bool(false) => { + builder = builder.disable_auto_save(); + } + _ => {} + } + } + + if let Some(serialize_fn_name) = serialize_fn_name { + let serialize_fn = store_state + .serialize_fns + .get(&serialize_fn_name) + .ok_or_else(|| crate::Error::SerializeFunctionNotFound(serialize_fn_name))?; + builder = builder.serialize(*serialize_fn); + } + + if let Some(deserialize_fn_name) = deserialize_fn_name { + let deserialize_fn = store_state + .deserialize_fns + .get(&deserialize_fn_name) + .ok_or_else(|| crate::Error::DeserializeFunctionNotFound(deserialize_fn_name))?; + builder = builder.deserialize(*deserialize_fn); } - let store = builder.build(); - Ok(webview.resources_table().add(store)) + + if create_new { + builder = builder.create_new(); + } + + Ok(builder) +} + +#[tauri::command] +async fn load( + app: AppHandle, + store_state: State<'_, StoreState>, + path: PathBuf, + auto_save: Option, + serialize_fn_name: Option, + deserialize_fn_name: Option, + create_new: Option, +) -> Result { + let builder = builder( + app, + store_state, + path, + auto_save, + serialize_fn_name, + deserialize_fn_name, + create_new.unwrap_or_default(), + )?; + let (_, rid) = builder.build_inner()?; + Ok(rid) +} + +#[tauri::command] +async fn get_store( + app: AppHandle, + store_state: State<'_, StoreState>, + path: PathBuf, +) -> Result> { + let stores = store_state.stores.lock().unwrap(); + Ok(stores.get(&resolve_store_path(&app, path)?).copied()) } #[tauri::command] async fn set( - webview: Webview, + app: AppHandle, rid: ResourceId, key: String, value: JsonValue, ) -> Result<()> { - let store = webview.resources_table().get::>(rid)?; + let store = app.resources_table().get::>(rid)?; store.set(key, value); Ok(()) } #[tauri::command] async fn get( - webview: Webview, + app: AppHandle, rid: ResourceId, key: String, -) -> Result> { - let store = webview.resources_table().get::>(rid)?; - Ok(store.get(key)) +) -> Result<(Option, bool)> { + let store = app.resources_table().get::>(rid)?; + let value = store.get(key); + let exists = value.is_some(); + Ok((value, exists)) } #[tauri::command] -async fn has(webview: Webview, rid: ResourceId, key: String) -> Result { - let store = webview.resources_table().get::>(rid)?; +async fn has(app: AppHandle, rid: ResourceId, key: String) -> Result { + let store = app.resources_table().get::>(rid)?; Ok(store.has(key)) } #[tauri::command] -async fn delete(webview: Webview, rid: ResourceId, key: String) -> Result { - let store = webview.resources_table().get::>(rid)?; +async fn delete(app: AppHandle, rid: ResourceId, key: String) -> Result { + let store = app.resources_table().get::>(rid)?; Ok(store.delete(key)) } #[tauri::command] -async fn clear(webview: Webview, rid: ResourceId) -> Result<()> { - let store = webview.resources_table().get::>(rid)?; +async fn clear(app: AppHandle, rid: ResourceId) -> Result<()> { + let store = app.resources_table().get::>(rid)?; store.clear(); Ok(()) } #[tauri::command] -async fn reset(webview: Webview, rid: ResourceId) -> Result<()> { - let store = webview.resources_table().get::>(rid)?; +async fn reset(app: AppHandle, rid: ResourceId) -> Result<()> { + let store = app.resources_table().get::>(rid)?; store.reset(); Ok(()) } #[tauri::command] -async fn keys(webview: Webview, rid: ResourceId) -> Result> { - let store = webview.resources_table().get::>(rid)?; +async fn keys(app: AppHandle, rid: ResourceId) -> Result> { + let store = app.resources_table().get::>(rid)?; Ok(store.keys()) } #[tauri::command] -async fn values(webview: Webview, rid: ResourceId) -> Result> { - let store = webview.resources_table().get::>(rid)?; +async fn values(app: AppHandle, rid: ResourceId) -> Result> { + let store = app.resources_table().get::>(rid)?; Ok(store.values()) } #[tauri::command] async fn entries( - webview: Webview, + app: AppHandle, rid: ResourceId, ) -> Result> { - let store = webview.resources_table().get::>(rid)?; + let store = app.resources_table().get::>(rid)?; Ok(store.entries()) } #[tauri::command] -async fn length(webview: Webview, rid: ResourceId) -> Result { - let store = webview.resources_table().get::>(rid)?; +async fn length(app: AppHandle, rid: ResourceId) -> Result { + let store = app.resources_table().get::>(rid)?; Ok(store.length()) } #[tauri::command] -async fn load(webview: Webview, rid: ResourceId) -> Result<()> { - let store = webview.resources_table().get::>(rid)?; - store.load() +async fn reload(app: AppHandle, rid: ResourceId) -> Result<()> { + let store = app.resources_table().get::>(rid)?; + store.reload() } #[tauri::command] -async fn save(webview: Webview, rid: ResourceId) -> Result<()> { - let store = webview.resources_table().get::>(rid)?; +async fn save(app: AppHandle, rid: ResourceId) -> Result<()> { + let store = app.resources_table().get::>(rid)?; store.save() } pub trait StoreExt { - fn store(&self, path: impl AsRef) -> Store; + /// Create a store or load an existing store with default settings at the given path. + /// + /// If the store is already loaded, its instance is automatically returned. + /// + /// # Examples + /// + /// ``` + /// use tauri_plugin_store::StoreExt; + /// + /// tauri::Builder::default() + /// .plugin(tauri_plugin_store::Builder::default().build()) + /// .setup(|app| { + /// let store = app.store("my-store")?; + /// Ok(()) + /// }); + /// ``` + fn store(&self, path: impl AsRef) -> Result>>; + /// Get a store builder. + /// + /// The builder can be used to configure the store. + /// To use the default settings see [`Self::store`]. + /// + /// # Examples + /// + /// ``` + /// use tauri_plugin_store::StoreExt; + /// use std::time::Duration; + /// + /// tauri::Builder::default() + /// .plugin(tauri_plugin_store::Builder::default().build()) + /// .setup(|app| { + /// let store = app.store_builder("users.json").auto_save(Duration::from_secs(1)).build()?; + /// Ok(()) + /// }); + /// ``` fn store_builder(&self, path: impl AsRef) -> StoreBuilder; + /// Get a handle of an already loaded store. + /// + /// If the store is not loaded or does not exist, it returns `None`. + /// + /// Note that using this function can cause race conditions if you fallback to creating or loading the store, + /// so you should consider using [`Self::store`] if you are not sure if the store is loaded or not. + /// + /// # Examples + /// + /// ``` + /// use tauri_plugin_store::StoreExt; + /// + /// tauri::Builder::default() + /// .plugin(tauri_plugin_store::Builder::default().build()) + /// .setup(|app| { + /// let store = if let Some(s) = app.get_store("store.json") { + /// s + /// } else { + /// // this is not thread safe; if another thread is doing the same load/create, + /// // there will be a race condition; in this case we could remove the get_store + /// // and only run app.store() as it will return the existing store if it has been loaded + /// app.store("store.json")? + /// }; + /// Ok(()) + /// }); + /// ``` + fn get_store(&self, path: impl AsRef) -> Option>>; } impl> StoreExt for T { - fn store(&self, path: impl AsRef) -> Store { + fn store(&self, path: impl AsRef) -> Result>> { StoreBuilder::new(self.app_handle(), path).build() } fn store_builder(&self, path: impl AsRef) -> StoreBuilder { StoreBuilder::new(self.app_handle(), path) } + + fn get_store(&self, path: impl AsRef) -> Option>> { + let collection = self.state::(); + let stores = collection.stores.lock().unwrap(); + stores + .get(&resolve_store_path(self.app_handle(), path.as_ref()).ok()?) + .and_then(|rid| self.resources_table().get(*rid).ok()) + } +} + +fn default_serialize( + cache: &HashMap, +) -> std::result::Result, Box> { + Ok(serde_json::to_vec_pretty(&cache)?) +} + +fn default_deserialize( + bytes: &[u8], +) -> std::result::Result, Box> { + serde_json::from_slice(bytes).map_err(Into::into) } -// #[derive(Default)] -pub struct Builder { - stores: HashMap>, - // frozen: bool, +pub struct Builder { + serialize_fns: HashMap, + deserialize_fns: HashMap, + default_serialize: SerializeFn, + default_deserialize: DeserializeFn, } -impl Default for Builder { +impl Default for Builder { fn default() -> Self { Self { - stores: Default::default(), - // frozen: false, + serialize_fns: Default::default(), + deserialize_fns: Default::default(), + default_serialize, + default_deserialize, } } } -impl Builder { +impl Builder { pub fn new() -> Self { Self::default() } - // /// Registers a store with the plugin. - // /// - // /// # Examples - // /// - // /// ``` - // /// use tauri_plugin_store::{StoreBuilder, Builder}; - // /// - // /// tauri::Builder::default() - // /// .setup(|app| { - // /// let store = StoreBuilder::new("store.bin").build(app.handle().clone()); - // /// let builder = Builder::default().store(store); - // /// Ok(()) - // /// }); - // /// ``` - // pub fn store(mut self, store: Store) -> Self { - // self.stores.insert(store.path.clone(), store); - // self - // } - - // /// Registers multiple stores with the plugin. - // /// - // /// # Examples - // /// - // /// ``` - // /// use tauri_plugin_store::{StoreBuilder, Builder}; - // /// - // /// tauri::Builder::default() - // /// .setup(|app| { - // /// let store = StoreBuilder::new("store.bin").build(app.handle().clone()); - // /// let builder = Builder::default().stores([store]); - // /// Ok(()) - // /// }); - // /// ``` - // pub fn stores>>(mut self, stores: T) -> Self { - // self.stores = stores - // .into_iter() - // .map(|store| (store.path.clone(), store)) - // .collect(); - // self - // } - - // /// Freezes the collection. - // /// - // /// This causes requests for plugins that haven't been registered to fail - // /// - // /// # Examples - // /// - // /// ``` - // /// use tauri_plugin_store::{StoreBuilder, Builder}; - // /// - // /// tauri::Builder::default() - // /// .setup(|app| { - // /// let store = StoreBuilder::new("store.bin").build(app.handle().clone()); - // /// app.handle().plugin(Builder::default().freeze().build()); - // /// Ok(()) - // /// }); - // /// ``` - // pub fn freeze(mut self) -> Self { - // self.frozen = true; - // self - // } + /// Register a serialize function to access it from the JavaScript side + /// + /// # Examples + /// + /// ``` + /// fn no_pretty_json( + /// cache: &std::collections::HashMap, + /// ) -> Result, Box> { + /// Ok(serde_json::to_vec(&cache)?) + /// } + /// + /// tauri::Builder::default() + /// .plugin( + /// tauri_plugin_store::Builder::default() + /// .register_serialize_fn("no-pretty-json".to_owned(), no_pretty_json) + /// .build(), + /// ); + /// ``` + pub fn register_serialize_fn(mut self, name: String, serialize_fn: SerializeFn) -> Self { + self.serialize_fns.insert(name, serialize_fn); + self + } + + /// Register a deserialize function to access it from the JavaScript side + pub fn register_deserialize_fn(mut self, name: String, deserialize_fn: DeserializeFn) -> Self { + self.deserialize_fns.insert(name, deserialize_fn); + self + } + + /// Use this serialize function for stores by default + /// + /// # Examples + /// + /// ``` + /// fn no_pretty_json( + /// cache: &std::collections::HashMap, + /// ) -> Result, Box> { + /// Ok(serde_json::to_vec(&cache)?) + /// } + /// + /// tauri::Builder::default() + /// .plugin( + /// tauri_plugin_store::Builder::default() + /// .default_serialize_fn(no_pretty_json) + /// .build(), + /// ); + /// ``` + pub fn default_serialize_fn(mut self, serialize_fn: SerializeFn) -> Self { + self.default_serialize = serialize_fn; + self + } + + /// Use this deserialize function for stores by default + pub fn default_deserialize_fn(mut self, deserialize_fn: DeserializeFn) -> Self { + self.default_deserialize = deserialize_fn; + self + } /// Builds the plugin. /// @@ -249,56 +407,37 @@ impl Builder { /// tauri::Builder::default() /// .plugin(tauri_plugin_store::Builder::default().build()) /// .setup(|app| { - /// let store = tauri_plugin_store::StoreBuilder::new(app, "store.bin").build(); + /// let store = tauri_plugin_store::StoreBuilder::new(app, "store.bin").build()?; /// Ok(()) /// }); /// ``` - pub fn build(mut self) -> TauriPlugin { + pub fn build(self) -> TauriPlugin { plugin::Builder::new("store") .invoke_handler(tauri::generate_handler![ - create_store, - set, - get, - has, - delete, - clear, - reset, - keys, - values, - length, - entries, - load, - save + load, get_store, set, get, has, delete, clear, reset, keys, values, length, + entries, reload, save, ]) .setup(move |app_handle, _api| { - for (path, store) in self.stores.iter_mut() { - // ignore loading errors, just use the default - if let Err(err) = store.load() { - warn!( - "Failed to load store {path:?} from disk: {err}. Falling back to default values." - ); - } - } - - app_handle.manage(StoreCollection:: { - stores: Mutex::new(HashMap::new()), - // frozen: self.frozen, + app_handle.manage(StoreState { + stores: Arc::new(Mutex::new(HashMap::new())), + serialize_fns: self.serialize_fns, + deserialize_fns: self.deserialize_fns, + default_serialize: self.default_serialize, + default_deserialize: self.default_deserialize, }); - Ok(()) }) - .on_event(|_app_handle, event| { + .on_event(|app_handle, event| { if let RunEvent::Exit = event { - // let collection = app_handle.state::>(); - - // for store in collection.stores.lock().expect("mutex poisoned").values_mut() { - // if let Some(sender) = store.auto_save_debounce_sender.take() { - // let _ = sender.send(AutoSaveMessage::Cancel); - // } - // if let Err(err) = store.save() { - // eprintln!("failed to save store {:?} with error {:?}", store.path, err); - // } - // } + let collection = app_handle.state::(); + let stores = collection.stores.lock().unwrap(); + for (path, rid) in stores.iter() { + if let Ok(store) = app_handle.resources_table().get::>(*rid) { + if let Err(err) = store.save() { + log::error!("failed to save store {path:?} with error {err:?}"); + } + } + } } }) .build() diff --git a/plugins/store/src/store.rs b/plugins/store/src/store.rs index d610525d..1dc5e1d2 100644 --- a/plugins/store/src/store.rs +++ b/plugins/store/src/store.rs @@ -2,38 +2,32 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use crate::{ChangePayload, StoreCollection}; +use crate::{ChangePayload, StoreState}; use serde_json::Value as JsonValue; use std::{ collections::HashMap, - fs::{create_dir_all, read, File}, - io::Write, + fs, path::{Path, PathBuf}, sync::{Arc, Mutex}, time::Duration, }; -use tauri::{AppHandle, Emitter, Manager, Resource, Runtime}; +use tauri::{path::BaseDirectory, AppHandle, Emitter, Manager, Resource, ResourceId, Runtime}; use tokio::{ select, sync::mpsc::{unbounded_channel, UnboundedSender}, time::sleep, }; -type SerializeFn = +pub type SerializeFn = fn(&HashMap) -> Result, Box>; -pub(crate) type DeserializeFn = +pub type DeserializeFn = fn(&[u8]) -> Result, Box>; -fn default_serialize( - cache: &HashMap, -) -> Result, Box> { - Ok(serde_json::to_vec(&cache)?) -} - -fn default_deserialize( - bytes: &[u8], -) -> Result, Box> { - serde_json::from_slice(bytes).map_err(Into::into) +pub fn resolve_store_path( + app: &AppHandle, + path: impl AsRef, +) -> crate::Result { + Ok(dunce::simplified(&app.path().resolve(path, BaseDirectory::AppData)?).to_path_buf()) } /// Builds a [`Store`] @@ -41,10 +35,10 @@ pub struct StoreBuilder { app: AppHandle, path: PathBuf, defaults: Option>, - cache: HashMap, - serialize: SerializeFn, - deserialize: DeserializeFn, + serialize_fn: SerializeFn, + deserialize_fn: DeserializeFn, auto_save: Option, + create_new: bool, } impl StoreBuilder { @@ -60,15 +54,18 @@ impl StoreBuilder { /// }); /// ``` pub fn new, P: AsRef>(manager: &M, path: P) -> Self { + let app = manager.app_handle().clone(); + let state = app.state::(); + let serialize_fn = state.default_serialize; + let deserialize_fn = state.default_deserialize; Self { - app: manager.app_handle().clone(), - // Since Store.path is only exposed to the user in emit calls we may as well simplify it here already. - path: dunce::simplified(path.as_ref()).to_path_buf(), + app, + path: path.as_ref().to_path_buf(), defaults: None, - cache: Default::default(), - serialize: default_serialize, - deserialize: default_deserialize, - auto_save: None, + serialize_fn, + deserialize_fn, + auto_save: Some(Duration::from_millis(100)), + create_new: false, } } @@ -84,17 +81,16 @@ impl StoreBuilder { /// /// let store = tauri_plugin_store::StoreBuilder::new(app, "store.bin") /// .defaults(defaults) - /// .build(); + /// .build()?; /// Ok(()) /// }); /// ``` pub fn defaults(mut self, defaults: HashMap) -> Self { - self.cache.clone_from(&defaults); self.defaults = Some(defaults); self } - /// Inserts multiple key-value pairs. + /// Inserts multiple default key-value pairs. /// /// # Examples /// ``` @@ -103,14 +99,13 @@ impl StoreBuilder { /// .setup(|app| { /// let store = tauri_plugin_store::StoreBuilder::new(app, "store.bin") /// .default("foo".to_string(), "bar") - /// .build(); + /// .build()?; /// Ok(()) /// }); /// ``` pub fn default(mut self, key: impl Into, value: impl Into) -> Self { let key = key.into(); let value = value.into(); - self.cache.insert(key.clone(), value.clone()); self.defaults .get_or_insert(HashMap::new()) .insert(key, value); @@ -126,12 +121,12 @@ impl StoreBuilder { /// .setup(|app| { /// let store = tauri_plugin_store::StoreBuilder::new(app, "store.json") /// .serialize(|cache| serde_json::to_vec(&cache).map_err(Into::into)) - /// .build(); + /// .build()?; /// Ok(()) /// }); /// ``` pub fn serialize(mut self, serialize: SerializeFn) -> Self { - self.serialize = serialize; + self.serialize_fn = serialize; self } @@ -144,28 +139,25 @@ impl StoreBuilder { /// .setup(|app| { /// let store = tauri_plugin_store::StoreBuilder::new(app, "store.json") /// .deserialize(|bytes| serde_json::from_slice(&bytes).map_err(Into::into)) - /// .build(); + /// .build()?; /// Ok(()) /// }); /// ``` pub fn deserialize(mut self, deserialize: DeserializeFn) -> Self { - self.deserialize = deserialize; + self.deserialize_fn = deserialize; self } /// Auto save on modified with a debounce duration /// - /// Note: only works if this store is managed by the plugin (e.g. made using [`crate::with_store`] or inserted into [`crate::Builder`]) - /// /// # Examples /// ``` - /// /// tauri::Builder::default() /// .plugin(tauri_plugin_store::Builder::default().build()) /// .setup(|app| { /// let store = tauri_plugin_store::StoreBuilder::new(app, "store.json") /// .auto_save(std::time::Duration::from_millis(100)) - /// .build(); + /// .build()?; /// Ok(()) /// }); /// ``` @@ -174,7 +166,64 @@ impl StoreBuilder { self } - /// Builds the [`Store`]. + /// Disable auto save on modified with a debounce duration. + pub fn disable_auto_save(mut self) -> Self { + self.auto_save = None; + self + } + + /// Force create a new store with default values even if it already exists. + pub fn create_new(mut self) -> Self { + self.create_new = true; + self + } + + pub(crate) fn build_inner(mut self) -> crate::Result<(Arc>, ResourceId)> { + let stores = self.app.state::().stores.clone(); + let mut stores = stores.lock().unwrap(); + + self.path = resolve_store_path(&self.app, self.path)?; + + if self.create_new { + if let Some(rid) = stores.remove(&self.path) { + let _ = self.app.resources_table().take::>(rid); + } + } else if let Some(rid) = stores.get(&self.path) { + return Ok((self.app.resources_table().get(*rid).unwrap(), *rid)); + } + + // if stores.contains_key(&self.path) { + // return Err(crate::Error::AlreadyExists(self.path)); + // } + + let mut store_inner = StoreInner::new( + self.app.clone(), + self.path.clone(), + self.defaults.take(), + self.serialize_fn, + self.deserialize_fn, + ); + + if !self.create_new { + let _ = store_inner.load(); + } + + let store = Store { + auto_save: self.auto_save, + auto_save_debounce_sender: Arc::new(Mutex::new(None)), + store: Arc::new(Mutex::new(store_inner)), + }; + + let store = Arc::new(store); + let rid = self.app.resources_table().add_arc(store.clone()); + stores.insert(self.path, rid); + + Ok((store, rid)) + } + + /// Load the existing store with the same path or creates a new [`Store`]. + /// + /// If a store with the same path has already been loaded its instance is returned. /// /// # Examples /// ``` @@ -185,131 +234,116 @@ impl StoreBuilder { /// Ok(()) /// }); /// ``` - pub fn build(self) -> Store { - let collection = self.app.state::>(); - let mut stores = collection.stores.lock().unwrap(); - let store = stores - .get(&self.path) - .and_then(|store| store.upgrade()) - .unwrap_or_else(|| { - let mut store = StoreInner::new(self.app.clone(), self.path.clone()); - let _ = store.load(self.deserialize); - let store = Arc::new(Mutex::new(store)); - stores.insert( - self.path.clone(), - Arc::>>::downgrade(&store), - ); - store - }); - drop(stores); - Store { - defaults: self.defaults, - serialize: self.serialize, - deserialize: self.deserialize, - auto_save: self.auto_save, - auto_save_debounce_sender: Arc::new(Mutex::new(None)), - store, - } + pub fn build(self) -> crate::Result>> { + let (store, _) = self.build_inner()?; + Ok(store) } } -pub(crate) enum AutoSaveMessage { +enum AutoSaveMessage { Reset, Cancel, } #[derive(Clone)] -pub struct StoreInner { - pub(crate) app: AppHandle, - pub(crate) path: PathBuf, - pub(crate) cache: HashMap, +struct StoreInner { + app: AppHandle, + path: PathBuf, + cache: HashMap, + defaults: Option>, + serialize_fn: SerializeFn, + deserialize_fn: DeserializeFn, } impl StoreInner { - pub fn new(app: AppHandle, path: PathBuf) -> Self { + fn new( + app: AppHandle, + path: PathBuf, + defaults: Option>, + serialize_fn: SerializeFn, + deserialize_fn: DeserializeFn, + ) -> Self { Self { app, path, - cache: HashMap::new(), + cache: defaults.clone().unwrap_or_default(), + defaults, + serialize_fn, + deserialize_fn, } } - pub fn save(&self, serialize_fn: SerializeFn) -> crate::Result<()> { - let app_dir = self - .app - .path() - .app_data_dir() - .expect("failed to resolve app dir"); - let store_path = app_dir.join(&self.path); - - create_dir_all(store_path.parent().expect("invalid store path"))?; + /// Saves the store to disk at the store's `path`. + pub fn save(&self) -> crate::Result<()> { + fs::create_dir_all(self.path.parent().expect("invalid store path"))?; - let bytes = serialize_fn(&self.cache).map_err(crate::Error::Serialize)?; - let mut f = File::create(&store_path)?; - f.write_all(&bytes)?; + let bytes = (self.serialize_fn)(&self.cache).map_err(crate::Error::Serialize)?; + fs::write(&self.path, bytes)?; Ok(()) } /// Update the store from the on-disk state - pub fn load(&mut self, deserialize_fn: DeserializeFn) -> crate::Result<()> { - let app_dir = self - .app - .path() - .app_data_dir() - .expect("failed to resolve app dir"); - let store_path = app_dir.join(&self.path); - - let bytes = read(store_path)?; + pub fn load(&mut self) -> crate::Result<()> { + let bytes = fs::read(&self.path)?; self.cache - .extend(deserialize_fn(&bytes).map_err(crate::Error::Deserialize)?); + .extend((self.deserialize_fn)(&bytes).map_err(crate::Error::Deserialize)?); Ok(()) } - pub fn insert(&mut self, key: impl Into, value: impl Into) { + /// Inserts a key-value pair into the store. + pub fn set(&mut self, key: impl Into, value: impl Into) { let key = key.into(); let value = value.into(); self.cache.insert(key.clone(), value.clone()); - let _ = self.emit_change_event(&key, &value); + let _ = self.emit_change_event(&key, Some(&value)); } + /// Returns a reference to the value corresponding to the key. pub fn get(&self, key: impl AsRef) -> Option<&JsonValue> { self.cache.get(key.as_ref()) } + /// Returns `true` if the given `key` exists in the store. pub fn has(&self, key: impl AsRef) -> bool { self.cache.contains_key(key.as_ref()) } + /// Removes a key-value pair from the store. pub fn delete(&mut self, key: impl AsRef) -> bool { let flag = self.cache.remove(key.as_ref()).is_some(); if flag { - let _ = self.emit_change_event(key.as_ref(), &JsonValue::Null); + let _ = self.emit_change_event(key.as_ref(), None); } flag } + /// Clears the store, removing all key-value pairs. + /// + /// Note: To clear the storage and reset it to its `default` value, use [`reset`](Self::reset) instead. pub fn clear(&mut self) { let keys: Vec = self.cache.keys().cloned().collect(); self.cache.clear(); for key in &keys { - let _ = self.emit_change_event(key, &JsonValue::Null); + let _ = self.emit_change_event(key, None); } } - pub fn reset(&mut self, defaults: &Option>) { - if let Some(defaults) = &defaults { + /// Resets the store to its `default` value. + /// + /// If no default value has been set, this method behaves identical to [`clear`](Self::clear). + pub fn reset(&mut self) { + if let Some(defaults) = &self.defaults { for (key, value) in &self.cache { if defaults.get(key) != Some(value) { - let _ = - self.emit_change_event(key, defaults.get(key).unwrap_or(&JsonValue::Null)); + let _ = self.emit_change_event(key, defaults.get(key)); } } for (key, value) in defaults { if !self.cache.contains_key(key) { - let _ = self.emit_change_event(key, value); + let _ = self.emit_change_event(key, Some(value)); } } self.cache.clone_from(defaults); @@ -318,33 +352,43 @@ impl StoreInner { } } + /// An iterator visiting all keys in arbitrary order. pub fn keys(&self) -> impl Iterator { self.cache.keys() } + /// An iterator visiting all values in arbitrary order. pub fn values(&self) -> impl Iterator { self.cache.values() } + /// An iterator visiting all key-value pairs in arbitrary order. pub fn entries(&self) -> impl Iterator { self.cache.iter() } + /// Returns the number of elements in the store. pub fn len(&self) -> usize { self.cache.len() } + /// Returns true if the store contains no elements. pub fn is_empty(&self) -> bool { self.cache.is_empty() } - fn emit_change_event(&self, key: &str, value: &JsonValue) -> crate::Result<()> { + fn emit_change_event(&self, key: &str, value: Option<&JsonValue>) -> crate::Result<()> { + let state = self.app.state::(); + let stores = state.stores.lock().unwrap(); + let exists = value.is_some(); self.app.emit( "store://change", ChangePayload { path: &self.path, + resource_id: stores.get(&self.path).copied(), key, value, + exists, }, )?; Ok(()) @@ -361,38 +405,45 @@ impl std::fmt::Debug for StoreInner { } pub struct Store { - defaults: Option>, - serialize: SerializeFn, - deserialize: DeserializeFn, auto_save: Option, auto_save_debounce_sender: Arc>>>, store: Arc>>, } -impl Resource for Store {} - -impl Store { - pub fn with_store( - &self, - f: impl FnOnce(&mut StoreInner) -> crate::Result, - ) -> crate::Result { - let mut store = self.store.lock().unwrap(); - f(&mut store) +impl Resource for Store { + fn close(self: Arc) { + let store = self.store.lock().unwrap(); + let state = store.app.state::(); + let mut stores = state.stores.lock().unwrap(); + stores.remove(&store.path); } +} +impl Store { + // /// Do something with the inner store, + // /// useful for batching some work if you need higher performance + // pub fn with_store(&self, f: impl FnOnce(&mut StoreInner) -> T) -> T { + // let mut store = self.store.lock().unwrap(); + // f(&mut store) + // } + + /// Inserts a key-value pair into the store. pub fn set(&self, key: impl Into, value: impl Into) { - self.store.lock().unwrap().insert(key.into(), value.into()); + self.store.lock().unwrap().set(key.into(), value.into()); let _ = self.trigger_auto_save(); } + /// Returns the value for the given `key` or `None` if the key does not exist. pub fn get(&self, key: impl AsRef) -> Option { self.store.lock().unwrap().get(key).cloned() } + /// Returns `true` if the given `key` exists in the store. pub fn has(&self, key: impl AsRef) -> bool { self.store.lock().unwrap().has(key) } + /// Removes a key-value pair from the store. pub fn delete(&self, key: impl AsRef) -> bool { let deleted = self.store.lock().unwrap().delete(key); if deleted { @@ -401,24 +452,33 @@ impl Store { deleted } + /// Clears the store, removing all key-value pairs. + /// + /// Note: To clear the storage and reset it to its `default` value, use [`reset`](Self::reset) instead. pub fn clear(&self) { self.store.lock().unwrap().clear(); let _ = self.trigger_auto_save(); } + /// Resets the store to its `default` value. + /// + /// If no default value has been set, this method behaves identical to [`clear`](Self::clear). pub fn reset(&self) { - self.store.lock().unwrap().reset(&self.defaults); + self.store.lock().unwrap().reset(); let _ = self.trigger_auto_save(); } + /// Returns a list of all keys in the store. pub fn keys(&self) -> Vec { self.store.lock().unwrap().keys().cloned().collect() } + /// Returns a list of all values in the store. pub fn values(&self) -> Vec { self.store.lock().unwrap().values().cloned().collect() } + /// Returns a list of all key-value pairs in the store. pub fn entries(&self) -> Vec<(String, JsonValue)> { self.store .lock() @@ -428,19 +488,40 @@ impl Store { .collect() } + /// Returns the number of elements in the store. pub fn length(&self) -> usize { self.store.lock().unwrap().len() } - pub fn load(&self) -> crate::Result<()> { - self.store.lock().unwrap().load(self.deserialize) + /// Returns true if the store contains no elements. + pub fn is_empty(&self) -> bool { + self.store.lock().unwrap().is_empty() + } + + /// Update the store from the on-disk state + pub fn reload(&self) -> crate::Result<()> { + self.store.lock().unwrap().load() } + /// Saves the store to disk at the store's `path`. pub fn save(&self) -> crate::Result<()> { if let Some(sender) = self.auto_save_debounce_sender.lock().unwrap().take() { let _ = sender.send(AutoSaveMessage::Cancel); } - self.store.lock().unwrap().save(self.serialize) + self.store.lock().unwrap().save() + } + + /// Removes the store from the resource table + pub fn close_resource(&self) { + let store = self.store.lock().unwrap(); + let app = store.app.clone(); + let state = app.state::(); + let stores = state.stores.lock().unwrap(); + if let Some(rid) = stores.get(&store.path).copied() { + drop(store); + drop(stores); + let _ = app.resources_table().close(rid); + } } fn trigger_auto_save(&self) -> crate::Result<()> { @@ -459,7 +540,6 @@ impl Store { auto_save_debounce_sender.replace(sender); drop(auto_save_debounce_sender); let store = self.store.clone(); - let serialize_fn = self.serialize; let auto_save_debounce_sender = self.auto_save_debounce_sender.clone(); tauri::async_runtime::spawn(async move { loop { @@ -471,7 +551,7 @@ impl Store { } _ = sleep(auto_save_delay) => { auto_save_debounce_sender.lock().unwrap().take(); - let _ = store.lock().unwrap().save(serialize_fn); + let _ = store.lock().unwrap().save(); return; } }; @@ -479,4 +559,18 @@ impl Store { }); Ok(()) } + + fn apply_pending_auto_save(&self) { + // Cancel and save if auto save is pending + if let Some(sender) = self.auto_save_debounce_sender.lock().unwrap().take() { + let _ = sender.send(AutoSaveMessage::Cancel); + let _ = self.save(); + }; + } +} + +impl Drop for Store { + fn drop(&mut self) { + self.apply_pending_auto_save(); + } } From 1c2f137a8a26136b98c5f51ac4de1a736fa80b76 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 19 Oct 2024 11:12:38 +0800 Subject: [PATCH 04/13] chore(deps): lock file maintenance (#1929) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 265 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 191 insertions(+), 74 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 01113a82..c8208655 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -396,9 +396,9 @@ dependencies = [ [[package]] name = "async-compression" -version = "0.4.13" +version = "0.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e614738943d3f68c628ae3dbce7c3daffb196665f82f8c8ea6b65de73c79429" +checksum = "103db485efc3e41214fe4fda9f3dbeae2eb9082f48fd236e6095627a9422066e" dependencies = [ "brotli 7.0.0", "flate2", @@ -598,9 +598,9 @@ dependencies = [ [[package]] name = "avif-serialize" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "876c75a42f6364451a033496a14c44bffe41f5f4a8236f697391f11024e596d2" +checksum = "e335041290c43101ca215eed6f43ec437eb5a42125573f600fc3fa42b9bddd62" dependencies = [ "arrayvec", ] @@ -867,9 +867,9 @@ dependencies = [ [[package]] name = "bytemuck" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94bbb0ad554ad961ddc5da507a12a29b14e4ae5bda06b19f575a3e6079d2e2ae" +checksum = "8334215b81e418a0a7bdb8ef0849474f40bb10c8b71f1c4ed315cff49f32494d" [[package]] name = "byteorder" @@ -961,9 +961,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.28" +version = "1.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e80e3b6a3ab07840e1cae9b0666a63970dc28e8ed5ffbcdacbfc760c281bfc1" +checksum = "b16803a61b81d9eabb7eae2588776c4c1e584b738ede45fdbb4c972cec1e9945" dependencies = [ "jobserver", "libc", @@ -2895,9 +2895,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" +checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" dependencies = [ "bytes", "futures-channel", @@ -3029,9 +3029,9 @@ dependencies = [ [[package]] name = "image" -version = "0.25.2" +version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99314c8a2152b8ddb211f924cdae532d8c5e4c8bb54728e12fff1b0cd5963a10" +checksum = "d97eb9a8e0cd5b76afea91d7eecd5cf8338cd44ced04256cf1f800474b227c52" dependencies = [ "bytemuck", "byteorder-lite", @@ -3052,9 +3052,9 @@ dependencies = [ [[package]] name = "image-webp" -version = "0.1.3" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f79afb8cbee2ef20f59ccd477a218c12a93943d075b492015ecb1bb81f8ee904" +checksum = "e031e8e3d94711a9ccb5d6ea357439ef3dcbed361798bd4071dc4d9793fbe22f" dependencies = [ "byteorder-lite", "quick-error 2.0.1", @@ -3062,9 +3062,9 @@ dependencies = [ [[package]] name = "imgref" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44feda355f4159a7c757171a77de25daf6411e217b4cabd03bd6650690468126" +checksum = "d0263a3d970d5c054ed9312c0057b4f3bde9c0b33836d3637361d4a9e6e7a408" [[package]] name = "indexmap" @@ -3330,9 +3330,9 @@ checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0" [[package]] name = "js-sys" -version = "0.3.70" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" +checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" dependencies = [ "wasm-bindgen", ] @@ -3458,9 +3458,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.159" +version = "0.2.160" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" +checksum = "f0b21006cd1874ae9e650973c565615676dc4a274c965bb0a73796dac838ce4f" [[package]] name = "libflate" @@ -3536,9 +3536,9 @@ dependencies = [ [[package]] name = "libsodium-sys-stable" -version = "1.21.2" +version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42631d334de875c636a1aae7adb515653ac2e771e5a2ce74b1053f5a4412df3a" +checksum = "90e7b5bc5a90cb1a680d8b0340f935d575292b8458e077f8da8cf134289d7dcf" dependencies = [ "cc", "libc", @@ -3935,9 +3935,9 @@ dependencies = [ [[package]] name = "notify-debouncer-full" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f5dab59c348b9b50cf7f261960a20e389feb2713636399cd9082cd4b536154" +checksum = "fb7fd166739789c9ff169e654dc1501373db9d80a4c3f972817c8a4d7cf8f34e" dependencies = [ "crossbeam-channel", "file-id", @@ -4100,6 +4100,9 @@ name = "objc-sys" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310" +dependencies = [ + "cc", +] [[package]] name = "objc2" @@ -4127,6 +4130,30 @@ dependencies = [ "objc2-quartz-core", ] +[[package]] +name = "objc2-cloud-kit" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74dd3b56391c7a0596a295029734d3c1c5e7e510a4cb30245f8221ccea96b009" +dependencies = [ + "bitflags 2.6.0", + "block2", + "objc2", + "objc2-core-location", + "objc2-foundation", +] + +[[package]] +name = "objc2-contacts" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5ff520e9c33812fd374d8deecef01d4a840e7b41862d849513de77e44aa4889" +dependencies = [ + "block2", + "objc2", + "objc2-foundation", +] + [[package]] name = "objc2-core-data" version = "0.2.2" @@ -4151,6 +4178,18 @@ dependencies = [ "objc2-metal", ] +[[package]] +name = "objc2-core-location" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "000cfee34e683244f284252ee206a27953279d370e309649dc3ee317b37e5781" +dependencies = [ + "block2", + "objc2", + "objc2-contacts", + "objc2-foundation", +] + [[package]] name = "objc2-encode" version = "4.0.3" @@ -4170,6 +4209,18 @@ dependencies = [ "objc2", ] +[[package]] +name = "objc2-link-presentation" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1a1ae721c5e35be65f01a03b6d2ac13a54cb4fa70d8a5da293d7b0020261398" +dependencies = [ + "block2", + "objc2", + "objc2-app-kit", + "objc2-foundation", +] + [[package]] name = "objc2-metal" version = "0.2.2" @@ -4195,6 +4246,74 @@ dependencies = [ "objc2-metal", ] +[[package]] +name = "objc2-symbols" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a684efe3dec1b305badae1a28f6555f6ddd3bb2c2267896782858d5a78404dc" +dependencies = [ + "objc2", + "objc2-foundation", +] + +[[package]] +name = "objc2-ui-kit" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8bb46798b20cd6b91cbd113524c490f1686f4c4e8f49502431415f3512e2b6f" +dependencies = [ + "bitflags 2.6.0", + "block2", + "objc2", + "objc2-cloud-kit", + "objc2-core-data", + "objc2-core-image", + "objc2-core-location", + "objc2-foundation", + "objc2-link-presentation", + "objc2-quartz-core", + "objc2-symbols", + "objc2-uniform-type-identifiers", + "objc2-user-notifications", +] + +[[package]] +name = "objc2-uniform-type-identifiers" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44fa5f9748dbfe1ca6c0b79ad20725a11eca7c2218bceb4b005cb1be26273bfe" +dependencies = [ + "block2", + "objc2", + "objc2-foundation", +] + +[[package]] +name = "objc2-user-notifications" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76cfcbf642358e8689af64cee815d139339f3ed8ad05103ed5eaf73db8d84cb3" +dependencies = [ + "bitflags 2.6.0", + "block2", + "objc2", + "objc2-core-location", + "objc2-foundation", +] + +[[package]] +name = "objc2-web-kit" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68bc69301064cebefc6c4c90ce9cba69225239e4b8ff99d445a2b5563797da65" +dependencies = [ + "bitflags 2.6.0", + "block2", + "objc2", + "objc2-app-kit", + "objc2-foundation", +] + [[package]] name = "objc_id" version = "0.1.1" @@ -4238,9 +4357,9 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.66" +version = "0.10.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1" +checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" dependencies = [ "bitflags 2.6.0", "cfg-if", @@ -4279,9 +4398,9 @@ dependencies = [ [[package]] name = "openssl-sys" -version = "0.9.103" +version = "0.9.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" +checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" dependencies = [ "cc", "libc", @@ -4399,9 +4518,9 @@ checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "pathdiff" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" +checksum = "d61c5ce1153ab5b689d0c074c4e7fc613e942dfb7dd9eea5ab202d2ad91fe361" [[package]] name = "pbkdf2" @@ -4749,27 +4868,27 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" [[package]] name = "proc-macro2" -version = "1.0.87" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" +checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9" dependencies = [ "unicode-ident", ] [[package]] name = "profiling" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43d84d1d7a6ac92673717f9f6d1518374ef257669c24ebc5ac25d5033828be58" +checksum = "afbdc74edc00b6f6a218ca6a5364d6226a259d4b8ea1af4a0ea063f27e179f4d" dependencies = [ "profiling-procmacros", ] [[package]] name = "profiling-procmacros" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8021cf59c8ec9c432cfc2526ac6b8aa508ecaf29cd415f271b8406c1b851c3fd" +checksum = "a65f2e60fbf1063868558d69c6beacf412dc755f9fc020f514b7955fc914fe30" dependencies = [ "quote", "syn 2.0.79", @@ -5242,9 +5361,6 @@ name = "rgb" version = "0.8.50" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57397d16646700483b67d2dd6511d79318f9d057fdbd21a4066aeac8b41d310a" -dependencies = [ - "bytemuck", -] [[package]] name = "ring" @@ -5402,9 +5518,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.14" +version = "0.23.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "415d9944693cb90382053259f89fbb077ea730ad7273047ec63b19bc9b160ba8" +checksum = "5fbb44d7acc4e873d613422379f69f237a1b141928c02f6bc6ccfddddc2d7993" dependencies = [ "once_cell", "ring", @@ -5438,9 +5554,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e696e35370c65c9c541198af4543ccd580cf17fc25d8e05c5a242b202488c55" +checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" [[package]] name = "rustls-webpki" @@ -6490,9 +6606,9 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "tauri" -version = "2.0.2" +version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5920aad0804ea5e86808d4b6e8753d3bcbae7efc8f4e41a4da00b45427559868" +checksum = "44438500b50708bfc1e6083844e135d1b516325aae58710dcd8fb67e050ae87c" dependencies = [ "anyhow", "bytes", @@ -7086,9 +7202,9 @@ dependencies = [ [[package]] name = "tauri-runtime" -version = "2.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af12ad1af974b274ef1d32a94e6eba27a312b429ef28fcb98abc710df7f9151d" +checksum = "c8f437293d6f5e5dce829250f4dbdce4e0b52905e297a6689cc2963eb53ac728" dependencies = [ "dpi", "gtk", @@ -7105,9 +7221,9 @@ dependencies = [ [[package]] name = "tauri-runtime-wry" -version = "2.0.1" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e45e88aa0b11b302d836e6ea3e507a6359044c4a8bc86b865ba99868c695753d" +checksum = "1431602bcc71f2f840ad623915c9842ecc32999b867c4a787d975a17a9625cc6" dependencies = [ "gtk", "http", @@ -7533,9 +7649,9 @@ dependencies = [ [[package]] name = "tray-icon" -version = "0.19.0" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "533fc2d4105e0e3d96ce1c71f2d308c9fbbe2ef9c587cab63dd627ab5bde218f" +checksum = "7c92af36a182b46206723bdf8a7942e20838cde1cf062e5b97854d57eb01763b" dependencies = [ "core-graphics 0.24.0", "crossbeam-channel", @@ -7782,9 +7898,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" +checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" dependencies = [ "getrandom 0.2.15", "serde", @@ -7893,9 +8009,9 @@ checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" [[package]] name = "wasm-bindgen" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" +checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" dependencies = [ "cfg-if", "once_cell", @@ -7904,9 +8020,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" +checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" dependencies = [ "bumpalo", "log", @@ -7919,9 +8035,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.43" +version = "0.4.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" +checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" dependencies = [ "cfg-if", "js-sys", @@ -7931,9 +8047,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" +checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -7941,9 +8057,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" +checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", @@ -7954,9 +8070,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" [[package]] name = "wasm-streams" @@ -8033,9 +8149,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.70" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" +checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" dependencies = [ "js-sys", "wasm-bindgen", @@ -8668,14 +8784,12 @@ dependencies = [ [[package]] name = "wry" -version = "0.44.1" +version = "0.46.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "440600584cfbd8b0d28eace95c1f2c253db05dae43780b79380aa1e868f04c73" +checksum = "6fa1c8c760041c64ce6be99f83d6cb55fe3fcd85a1ad46d32895f6e65cee87ba" dependencies = [ "base64 0.22.1", - "block", - "cocoa", - "core-graphics 0.24.0", + "block2", "crossbeam-channel", "dpi", "dunce", @@ -8688,8 +8802,11 @@ dependencies = [ "kuchikiki", "libc", "ndk", - "objc", - "objc_id", + "objc2", + "objc2-app-kit", + "objc2-foundation", + "objc2-ui-kit", + "objc2-web-kit", "once_cell", "percent-encoding", "raw-window-handle", From 854754e10b24369adfbeadafc5d5cd288334ab7c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 19 Oct 2024 11:13:06 +0800 Subject: [PATCH 05/13] chore(deps): update dependency typescript-eslint to v8.10.0 (#1949) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- pnpm-lock.yaml | 102 ++++++++++++++++++++++++------------------------- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/package.json b/package.json index 1d1897fb..a1444408 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "rollup": "4.22.4", "tslib": "2.7.0", "typescript": "5.6.3", - "typescript-eslint": "8.9.0" + "typescript-eslint": "8.10.0" }, "resolutions": { "semver": ">=7.5.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a975f431..5b1034bf 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -52,8 +52,8 @@ importers: specifier: 5.6.3 version: 5.6.3 typescript-eslint: - specifier: 8.9.0 - version: 8.9.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) + specifier: 8.10.0 + version: 8.10.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) examples/api: dependencies: @@ -1028,8 +1028,8 @@ packages: '@types/unist@2.0.11': resolution: {integrity: sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA==} - '@typescript-eslint/eslint-plugin@8.9.0': - resolution: {integrity: sha512-Y1n621OCy4m7/vTXNlCbMVp87zSd7NH0L9cXD8aIpOaNlzeWxIK4+Q19A68gSmTNRZn92UjocVUWDthGxtqHFg==} + '@typescript-eslint/eslint-plugin@8.10.0': + resolution: {integrity: sha512-phuB3hoP7FFKbRXxjl+DRlQDuJqhpOnm5MmtROXyWi3uS/Xg2ZXqiQfcG2BJHiN4QKyzdOJi3NEn/qTnjUlkmQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: '@typescript-eslint/parser': ^8.0.0 || ^8.0.0-alpha.0 @@ -1039,8 +1039,8 @@ packages: typescript: optional: true - '@typescript-eslint/parser@8.9.0': - resolution: {integrity: sha512-U+BLn2rqTTHnc4FL3FJjxaXptTxmf9sNftJK62XLz4+GxG3hLHm/SUNaaXP5Y4uTiuYoL5YLy4JBCJe3+t8awQ==} + '@typescript-eslint/parser@8.10.0': + resolution: {integrity: sha512-E24l90SxuJhytWJ0pTQydFT46Nk0Z+bsLKo/L8rtQSL93rQ6byd1V/QbDpHUTdLPOMsBCcYXZweADNCfOCmOAg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 @@ -1049,12 +1049,12 @@ packages: typescript: optional: true - '@typescript-eslint/scope-manager@8.9.0': - resolution: {integrity: sha512-bZu9bUud9ym1cabmOYH9S6TnbWRzpklVmwqICeOulTCZ9ue2/pczWzQvt/cGj2r2o1RdKoZbuEMalJJSYw3pHQ==} + '@typescript-eslint/scope-manager@8.10.0': + resolution: {integrity: sha512-AgCaEjhfql9MDKjMUxWvH7HjLeBqMCBfIaBbzzIcBbQPZE7CPh1m6FF+L75NUMJFMLYhCywJXIDEMa3//1A0dw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typescript-eslint/type-utils@8.9.0': - resolution: {integrity: sha512-JD+/pCqlKqAk5961vxCluK+clkppHY07IbV3vett97KOV+8C6l+CPEPwpUuiMwgbOz/qrN3Ke4zzjqbT+ls+1Q==} + '@typescript-eslint/type-utils@8.10.0': + resolution: {integrity: sha512-PCpUOpyQSpxBn230yIcK+LeCQaXuxrgCm2Zk1S+PTIRJsEfU6nJ0TtwyH8pIwPK/vJoA+7TZtzyAJSGBz+s/dg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: typescript: '*' @@ -1062,12 +1062,12 @@ packages: typescript: optional: true - '@typescript-eslint/types@8.9.0': - resolution: {integrity: sha512-SjgkvdYyt1FAPhU9c6FiYCXrldwYYlIQLkuc+LfAhCna6ggp96ACncdtlbn8FmnG72tUkXclrDExOpEYf1nfJQ==} + '@typescript-eslint/types@8.10.0': + resolution: {integrity: sha512-k/E48uzsfJCRRbGLapdZgrX52csmWJ2rcowwPvOZ8lwPUv3xW6CcFeJAXgx4uJm+Ge4+a4tFOkdYvSpxhRhg1w==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typescript-eslint/typescript-estree@8.9.0': - resolution: {integrity: sha512-9iJYTgKLDG6+iqegehc5+EqE6sqaee7kb8vWpmHZ86EqwDjmlqNNHeqDVqb9duh+BY6WCNHfIGvuVU3Tf9Db0g==} + '@typescript-eslint/typescript-estree@8.10.0': + resolution: {integrity: sha512-3OE0nlcOHaMvQ8Xu5gAfME3/tWVDpb/HxtpUZ1WeOAksZ/h/gwrBzCklaGzwZT97/lBbbxJ16dMA98JMEngW4w==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: typescript: '*' @@ -1075,14 +1075,14 @@ packages: typescript: optional: true - '@typescript-eslint/utils@8.9.0': - resolution: {integrity: sha512-PKgMmaSo/Yg/F7kIZvrgrWa1+Vwn036CdNUvYFEkYbPwOH4i8xvkaRlu148W3vtheWK9ckKRIz7PBP5oUlkrvQ==} + '@typescript-eslint/utils@8.10.0': + resolution: {integrity: sha512-Oq4uZ7JFr9d1ZunE/QKy5egcDRXT/FrS2z/nlxzPua2VHFtmMvFNDvpq1m/hq0ra+T52aUezfcjGRIB7vNJF9w==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 - '@typescript-eslint/visitor-keys@8.9.0': - resolution: {integrity: sha512-Ht4y38ubk4L5/U8xKUBfKNYGmvKvA1CANoxiTRMM+tOLk3lbF3DvzZCxJCRSE+2GdCMSh6zq9VZJc3asc1XuAA==} + '@typescript-eslint/visitor-keys@8.10.0': + resolution: {integrity: sha512-k8nekgqwr7FadWk548Lfph6V3r9OVqjzAIVskE7orMZR23cGJjAOVazsZSJW+ElyjfTM4wx/1g88Mi70DDtG9A==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} '@unocss/astro@0.63.1': @@ -2145,8 +2145,8 @@ packages: resolution: {integrity: sha512-Ne2YiiGN8bmrmJJEuTWTLJR32nh/JdL1+PSicowtNb0WFpn59GK8/lfD61bVtzguz7b3PBt74nxpv/Pw5po5Rg==} engines: {node: '>=8'} - typescript-eslint@8.9.0: - resolution: {integrity: sha512-AuD/FXGYRQyqyOBCpNLldMlsCGvmDNxptQ3Dp58/NXeB+FqyvTfXmMyba3PYa0Vi9ybnj7G8S/yd/4Cw8y47eA==} + typescript-eslint@8.10.0: + resolution: {integrity: sha512-YIu230PeN7z9zpu/EtqCIuRVHPs4iSlqW6TEvjbyDAE3MZsSl2RXBo+5ag+lbABCG8sFM1WVKEXhlQ8Ml8A3Fw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: typescript: '*' @@ -2857,14 +2857,14 @@ snapshots: '@types/unist@2.0.11': {} - '@typescript-eslint/eslint-plugin@8.9.0(@typescript-eslint/parser@8.9.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3))(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3)': + '@typescript-eslint/eslint-plugin@8.10.0(@typescript-eslint/parser@8.10.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3))(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3)': dependencies: '@eslint-community/regexpp': 4.11.1 - '@typescript-eslint/parser': 8.9.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) - '@typescript-eslint/scope-manager': 8.9.0 - '@typescript-eslint/type-utils': 8.9.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) - '@typescript-eslint/utils': 8.9.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) - '@typescript-eslint/visitor-keys': 8.9.0 + '@typescript-eslint/parser': 8.10.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) + '@typescript-eslint/scope-manager': 8.10.0 + '@typescript-eslint/type-utils': 8.10.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) + '@typescript-eslint/utils': 8.10.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) + '@typescript-eslint/visitor-keys': 8.10.0 eslint: 9.12.0(jiti@2.0.0) graphemer: 1.4.0 ignore: 5.3.2 @@ -2875,12 +2875,12 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/parser@8.9.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3)': + '@typescript-eslint/parser@8.10.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3)': dependencies: - '@typescript-eslint/scope-manager': 8.9.0 - '@typescript-eslint/types': 8.9.0 - '@typescript-eslint/typescript-estree': 8.9.0(typescript@5.6.3) - '@typescript-eslint/visitor-keys': 8.9.0 + '@typescript-eslint/scope-manager': 8.10.0 + '@typescript-eslint/types': 8.10.0 + '@typescript-eslint/typescript-estree': 8.10.0(typescript@5.6.3) + '@typescript-eslint/visitor-keys': 8.10.0 debug: 4.3.7(supports-color@8.1.1) eslint: 9.12.0(jiti@2.0.0) optionalDependencies: @@ -2888,15 +2888,15 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/scope-manager@8.9.0': + '@typescript-eslint/scope-manager@8.10.0': dependencies: - '@typescript-eslint/types': 8.9.0 - '@typescript-eslint/visitor-keys': 8.9.0 + '@typescript-eslint/types': 8.10.0 + '@typescript-eslint/visitor-keys': 8.10.0 - '@typescript-eslint/type-utils@8.9.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3)': + '@typescript-eslint/type-utils@8.10.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3)': dependencies: - '@typescript-eslint/typescript-estree': 8.9.0(typescript@5.6.3) - '@typescript-eslint/utils': 8.9.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) + '@typescript-eslint/typescript-estree': 8.10.0(typescript@5.6.3) + '@typescript-eslint/utils': 8.10.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) debug: 4.3.7(supports-color@8.1.1) ts-api-utils: 1.3.0(typescript@5.6.3) optionalDependencies: @@ -2905,12 +2905,12 @@ snapshots: - eslint - supports-color - '@typescript-eslint/types@8.9.0': {} + '@typescript-eslint/types@8.10.0': {} - '@typescript-eslint/typescript-estree@8.9.0(typescript@5.6.3)': + '@typescript-eslint/typescript-estree@8.10.0(typescript@5.6.3)': dependencies: - '@typescript-eslint/types': 8.9.0 - '@typescript-eslint/visitor-keys': 8.9.0 + '@typescript-eslint/types': 8.10.0 + '@typescript-eslint/visitor-keys': 8.10.0 debug: 4.3.7(supports-color@8.1.1) fast-glob: 3.3.2 is-glob: 4.0.3 @@ -2922,20 +2922,20 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@8.9.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3)': + '@typescript-eslint/utils@8.10.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3)': dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@9.12.0(jiti@2.0.0)) - '@typescript-eslint/scope-manager': 8.9.0 - '@typescript-eslint/types': 8.9.0 - '@typescript-eslint/typescript-estree': 8.9.0(typescript@5.6.3) + '@typescript-eslint/scope-manager': 8.10.0 + '@typescript-eslint/types': 8.10.0 + '@typescript-eslint/typescript-estree': 8.10.0(typescript@5.6.3) eslint: 9.12.0(jiti@2.0.0) transitivePeerDependencies: - supports-color - typescript - '@typescript-eslint/visitor-keys@8.9.0': + '@typescript-eslint/visitor-keys@8.10.0': dependencies: - '@typescript-eslint/types': 8.9.0 + '@typescript-eslint/types': 8.10.0 eslint-visitor-keys: 3.4.3 '@unocss/astro@0.63.1(rollup@4.22.4)(vite@5.4.8(terser@5.34.1))': @@ -4137,11 +4137,11 @@ snapshots: type-fest@0.7.1: {} - typescript-eslint@8.9.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3): + typescript-eslint@8.10.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3): dependencies: - '@typescript-eslint/eslint-plugin': 8.9.0(@typescript-eslint/parser@8.9.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3))(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) - '@typescript-eslint/parser': 8.9.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) - '@typescript-eslint/utils': 8.9.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) + '@typescript-eslint/eslint-plugin': 8.10.0(@typescript-eslint/parser@8.10.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3))(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) + '@typescript-eslint/parser': 8.10.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) + '@typescript-eslint/utils': 8.10.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) optionalDependencies: typescript: 5.6.3 transitivePeerDependencies: From 36207a93f34c45fae506e2df16b0cea82cb56aab Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 19 Oct 2024 11:14:14 +0800 Subject: [PATCH 06/13] chore(deps): update dependency @tauri-apps/cli to v2.0.3 (#1925) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- examples/api/package.json | 2 +- plugins/deep-link/examples/app/package.json | 2 +- .../examples/vanilla/package.json | 2 +- .../examples/AppSettingsManager/package.json | 2 +- .../websocket/examples/tauri-app/package.json | 2 +- pnpm-lock.yaml | 106 +++++++++--------- 6 files changed, 58 insertions(+), 58 deletions(-) diff --git a/examples/api/package.json b/examples/api/package.json index 690c19f9..33468570 100644 --- a/examples/api/package.json +++ b/examples/api/package.json @@ -33,7 +33,7 @@ "@iconify-json/codicon": "^1.1.37", "@iconify-json/ph": "^1.1.8", "@sveltejs/vite-plugin-svelte": "^3.0.1", - "@tauri-apps/cli": "2.0.2", + "@tauri-apps/cli": "2.0.3", "@unocss/extractor-svelte": "^0.63.0", "svelte": "^4.2.19", "unocss": "^0.63.0", diff --git a/plugins/deep-link/examples/app/package.json b/plugins/deep-link/examples/app/package.json index 2ef38bd3..5b9e8efc 100644 --- a/plugins/deep-link/examples/app/package.json +++ b/plugins/deep-link/examples/app/package.json @@ -14,7 +14,7 @@ "@tauri-apps/plugin-deep-link": "2.0.0" }, "devDependencies": { - "@tauri-apps/cli": "2.0.2", + "@tauri-apps/cli": "2.0.3", "typescript": "^5.2.2", "vite": "^5.4.7" } diff --git a/plugins/single-instance/examples/vanilla/package.json b/plugins/single-instance/examples/vanilla/package.json index 5b736d55..7b0d2c5d 100644 --- a/plugins/single-instance/examples/vanilla/package.json +++ b/plugins/single-instance/examples/vanilla/package.json @@ -9,6 +9,6 @@ "author": "", "license": "MIT", "devDependencies": { - "@tauri-apps/cli": "2.0.2" + "@tauri-apps/cli": "2.0.3" } } diff --git a/plugins/store/examples/AppSettingsManager/package.json b/plugins/store/examples/AppSettingsManager/package.json index e36d1bb3..cd2cb198 100644 --- a/plugins/store/examples/AppSettingsManager/package.json +++ b/plugins/store/examples/AppSettingsManager/package.json @@ -8,7 +8,7 @@ "tauri": "tauri" }, "devDependencies": { - "@tauri-apps/cli": "2.0.2", + "@tauri-apps/cli": "2.0.3", "vite": "^5.0.12", "typescript": "^5.4.7" } diff --git a/plugins/websocket/examples/tauri-app/package.json b/plugins/websocket/examples/tauri-app/package.json index 4bfbdfd5..e0d196e9 100644 --- a/plugins/websocket/examples/tauri-app/package.json +++ b/plugins/websocket/examples/tauri-app/package.json @@ -9,7 +9,7 @@ "preview": "vite preview" }, "devDependencies": { - "@tauri-apps/cli": "2.0.2", + "@tauri-apps/cli": "2.0.3", "typescript": "^5.3.3", "vite": "^5.4.7" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5b1034bf..e6b89a14 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -125,8 +125,8 @@ importers: specifier: ^3.0.1 version: 3.1.2(svelte@4.2.19)(vite@5.4.8(terser@5.34.1)) '@tauri-apps/cli': - specifier: 2.0.2 - version: 2.0.2 + specifier: 2.0.3 + version: 2.0.3 '@unocss/extractor-svelte': specifier: ^0.63.0 version: 0.63.1 @@ -186,8 +186,8 @@ importers: version: link:../.. devDependencies: '@tauri-apps/cli': - specifier: 2.0.2 - version: 2.0.2 + specifier: 2.0.3 + version: 2.0.3 typescript: specifier: ^5.2.2 version: 5.6.3 @@ -276,8 +276,8 @@ importers: plugins/single-instance/examples/vanilla: devDependencies: '@tauri-apps/cli': - specifier: 2.0.2 - version: 2.0.2 + specifier: 2.0.3 + version: 2.0.3 plugins/sql: dependencies: @@ -294,8 +294,8 @@ importers: plugins/store/examples/AppSettingsManager: devDependencies: '@tauri-apps/cli': - specifier: 2.0.2 - version: 2.0.2 + specifier: 2.0.3 + version: 2.0.3 typescript: specifier: ^5.4.7 version: 5.6.3 @@ -334,8 +334,8 @@ importers: version: link:../.. devDependencies: '@tauri-apps/cli': - specifier: 2.0.2 - version: 2.0.2 + specifier: 2.0.3 + version: 2.0.3 typescript: specifier: ^5.3.3 version: 5.6.3 @@ -939,68 +939,68 @@ packages: '@tauri-apps/api@2.0.2': resolution: {integrity: sha512-3wSwmG+1kr6WrgAFKK5ijkNFPp8TT3FLj3YHUb5EwMO+3FxX4uWlfSWkeeBy+Kc1RsKzugtYLuuya+98Flj+3w==} - '@tauri-apps/cli-darwin-arm64@2.0.2': - resolution: {integrity: sha512-B+/a8Q6wAqmB4A4HVeK0oQP5TdQGKW60ZLOI9O2ktH2HPr9ETr3XkwXPuJ2uAOuGEgtRZHBgFOIgG000vMnKlg==} + '@tauri-apps/cli-darwin-arm64@2.0.3': + resolution: {integrity: sha512-jIsbxGWS+As1ZN7umo90nkql/ZAbrDK0GBT6UsgHSz5zSwwArICsZFFwE1pLZip5yoiV5mn3TGG2c1+v+0puzQ==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] - '@tauri-apps/cli-darwin-x64@2.0.2': - resolution: {integrity: sha512-kaurhn6XT4gAVCPAQSSHl/CHFxTS0ljc47N7iGTSlYJ03sCWPRZeNuVa/bn6rolz9MA2JfnRnFqB1pUL6jzp9Q==} + '@tauri-apps/cli-darwin-x64@2.0.3': + resolution: {integrity: sha512-ROITHtLTA1muyrwgyuwyasmaLCGtT4as/Kd1kerXaSDtFcYrnxiM984ZD0+FDUEDl5BgXtYa/sKKkKQFjgmM0A==} engines: {node: '>= 10'} cpu: [x64] os: [darwin] - '@tauri-apps/cli-linux-arm-gnueabihf@2.0.2': - resolution: {integrity: sha512-bVrofjlacMxmGMcqK18iBW05tsZXOd19/MnqruFFcHSVjvkGGIXHMtUbMXnZNXBPkHDsnfytNtkY9SZGfCFaBA==} + '@tauri-apps/cli-linux-arm-gnueabihf@2.0.3': + resolution: {integrity: sha512-bQ3EZwCFfrLg/ZQ2I8sLuifSxESz4TP56SleTkKsPtTIZgNnKpM88PRDz4neiRroHVOq8NK0X276qi9LjGcXPw==} engines: {node: '>= 10'} cpu: [arm] os: [linux] - '@tauri-apps/cli-linux-arm64-gnu@2.0.2': - resolution: {integrity: sha512-7XCBn0TTBVQGnV42dXcbHPLg/9W8kJoVzuliIozvNGyRWxfXqDbQYzpI48HUQG3LgHMabcw8+pVZAfGhevLrCA==} + '@tauri-apps/cli-linux-arm64-gnu@2.0.3': + resolution: {integrity: sha512-aLfAA8P9OTErVUk3sATxtXqpAtlfDPMPp4fGjDysEELG/MyekGhmh2k/kG/i32OdPeCfO+Nr37wJksARJKubGw==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] - '@tauri-apps/cli-linux-arm64-musl@2.0.2': - resolution: {integrity: sha512-1xi2SreGVlpAL68MCsDUY63rdItUdPZreXIAcOVqvUehcJRYOa1XGSBhrV0YXRgZeh0AtKC19z6PRzcv4rosZA==} + '@tauri-apps/cli-linux-arm64-musl@2.0.3': + resolution: {integrity: sha512-I4MVD7nf6lLLRmNQPpe5beEIFM6q7Zkmh77ROA5BNu/+vHNL5kiTMD+bmd10ZL2r753A6pO7AvqkIxcBuIl0tg==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] - '@tauri-apps/cli-linux-x64-gnu@2.0.2': - resolution: {integrity: sha512-WVjwYzPWFqZVg1fx6KSU5w47Q0VbMyaCp34qs5EcS8EIU0/RnofdzqUoOYqvgGVgNgoz7Pj5dXK2SkS8BHXMmA==} + '@tauri-apps/cli-linux-x64-gnu@2.0.3': + resolution: {integrity: sha512-C6Jkx2zZGKkoi+sg5FK9GoH/0EvAaOgrZfF5azV5EALGba46g7VpWcZgp9zFUd7K2IzTi+0OOY8TQ2OVfKZgew==} engines: {node: '>= 10'} cpu: [x64] os: [linux] - '@tauri-apps/cli-linux-x64-musl@2.0.2': - resolution: {integrity: sha512-h5miE2mctgaQNn/BbG9o1pnJcrx+VGBi2A6JFqGu934lFgSV5+s28M8Gc8AF2JgFH4hQV4IuMkeSw8Chu5Dodg==} + '@tauri-apps/cli-linux-x64-musl@2.0.3': + resolution: {integrity: sha512-qi4ghmTfSAl+EEUDwmwI9AJUiOLNSmU1RgiGgcPRE+7A/W+Am9UnxYySAiRbB/gJgTl9sj/pqH5Y9duP1/sqHg==} engines: {node: '>= 10'} cpu: [x64] os: [linux] - '@tauri-apps/cli-win32-arm64-msvc@2.0.2': - resolution: {integrity: sha512-2b8oO0+dYonahG5PfA/zoq0zlafLclfmXgqoWDZ++UiPtQHJNpNeEQ8GWbSFKGHQ494Jo6jHvazOojGRE1kqAg==} + '@tauri-apps/cli-win32-arm64-msvc@2.0.3': + resolution: {integrity: sha512-UXxHkYmFesC97qVmZre4vY7oDxRDtC2OeKNv0bH+iSnuUp/ROxzJYGyaelnv9Ybvgl4YVqDCnxgB28qMM938TA==} engines: {node: '>= 10'} cpu: [arm64] os: [win32] - '@tauri-apps/cli-win32-ia32-msvc@2.0.2': - resolution: {integrity: sha512-axgICLunFi0To3EibdCBgbST5RocsSmtM4c04+CbcX8WQQosJ9ziWlCSrrOTRr+gJERAMSvEyVUS98f6bWMw9A==} + '@tauri-apps/cli-win32-ia32-msvc@2.0.3': + resolution: {integrity: sha512-D+xoaa35RGlkXDpnL5uDTpj29untuC5Wp6bN9snfgFDagD0wnFfC8+2ZQGu16bD0IteWqDI0OSoIXhNvy+F+wg==} engines: {node: '>= 10'} cpu: [ia32] os: [win32] - '@tauri-apps/cli-win32-x64-msvc@2.0.2': - resolution: {integrity: sha512-JR17cM6+DyExZRgpXr2/DdqvcFYi/EKvQt8dI5R1/uQoesWd8jeNnrU7c1FG1Zmw9+pTzDztsNqEKsrNq2sNIg==} + '@tauri-apps/cli-win32-x64-msvc@2.0.3': + resolution: {integrity: sha512-eWV9XWb4dSYHXl13OtYWLjX1JHphUEkHkkGwJrhr8qFBm7RbxXxQvrsUEprSi51ug/dwJenjJgM4zR8By4htfw==} engines: {node: '>= 10'} cpu: [x64] os: [win32] - '@tauri-apps/cli@2.0.2': - resolution: {integrity: sha512-R4ontHZvXORArERAHIidp5zRfZEshZczTiK+poslBv7AGKpQZoMw+E49zns7mOmP64i2Cq9Ci0pJvi4Rm8Okzw==} + '@tauri-apps/cli@2.0.3': + resolution: {integrity: sha512-JwEyhc5BAVpn4E8kxzY/h7+bVOiXQdudR1r3ODMfyyumZBfgIWqpD/WuTcPq6Yjchju1BSS+80jAE/oYwI/RKg==} engines: {node: '>= 10'} hasBin: true @@ -2791,48 +2791,48 @@ snapshots: '@tauri-apps/api@2.0.2': {} - '@tauri-apps/cli-darwin-arm64@2.0.2': + '@tauri-apps/cli-darwin-arm64@2.0.3': optional: true - '@tauri-apps/cli-darwin-x64@2.0.2': + '@tauri-apps/cli-darwin-x64@2.0.3': optional: true - '@tauri-apps/cli-linux-arm-gnueabihf@2.0.2': + '@tauri-apps/cli-linux-arm-gnueabihf@2.0.3': optional: true - '@tauri-apps/cli-linux-arm64-gnu@2.0.2': + '@tauri-apps/cli-linux-arm64-gnu@2.0.3': optional: true - '@tauri-apps/cli-linux-arm64-musl@2.0.2': + '@tauri-apps/cli-linux-arm64-musl@2.0.3': optional: true - '@tauri-apps/cli-linux-x64-gnu@2.0.2': + '@tauri-apps/cli-linux-x64-gnu@2.0.3': optional: true - '@tauri-apps/cli-linux-x64-musl@2.0.2': + '@tauri-apps/cli-linux-x64-musl@2.0.3': optional: true - '@tauri-apps/cli-win32-arm64-msvc@2.0.2': + '@tauri-apps/cli-win32-arm64-msvc@2.0.3': optional: true - '@tauri-apps/cli-win32-ia32-msvc@2.0.2': + '@tauri-apps/cli-win32-ia32-msvc@2.0.3': optional: true - '@tauri-apps/cli-win32-x64-msvc@2.0.2': + '@tauri-apps/cli-win32-x64-msvc@2.0.3': optional: true - '@tauri-apps/cli@2.0.2': + '@tauri-apps/cli@2.0.3': optionalDependencies: - '@tauri-apps/cli-darwin-arm64': 2.0.2 - '@tauri-apps/cli-darwin-x64': 2.0.2 - '@tauri-apps/cli-linux-arm-gnueabihf': 2.0.2 - '@tauri-apps/cli-linux-arm64-gnu': 2.0.2 - '@tauri-apps/cli-linux-arm64-musl': 2.0.2 - '@tauri-apps/cli-linux-x64-gnu': 2.0.2 - '@tauri-apps/cli-linux-x64-musl': 2.0.2 - '@tauri-apps/cli-win32-arm64-msvc': 2.0.2 - '@tauri-apps/cli-win32-ia32-msvc': 2.0.2 - '@tauri-apps/cli-win32-x64-msvc': 2.0.2 + '@tauri-apps/cli-darwin-arm64': 2.0.3 + '@tauri-apps/cli-darwin-x64': 2.0.3 + '@tauri-apps/cli-linux-arm-gnueabihf': 2.0.3 + '@tauri-apps/cli-linux-arm64-gnu': 2.0.3 + '@tauri-apps/cli-linux-arm64-musl': 2.0.3 + '@tauri-apps/cli-linux-x64-gnu': 2.0.3 + '@tauri-apps/cli-linux-x64-musl': 2.0.3 + '@tauri-apps/cli-win32-arm64-msvc': 2.0.3 + '@tauri-apps/cli-win32-ia32-msvc': 2.0.3 + '@tauri-apps/cli-win32-x64-msvc': 2.0.3 '@types/eslint@9.6.1': dependencies: From 415bf2abc340f47816029e3b261d9420e1cb6427 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 20 Oct 2024 16:54:34 +0800 Subject: [PATCH 07/13] chore(deps): update eslint monorepo to v9.13.0 (#1951) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 4 +-- pnpm-lock.yaml | 76 +++++++++++++++++++++++++------------------------- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/package.json b/package.json index a1444408..3daae86c 100644 --- a/package.json +++ b/package.json @@ -10,13 +10,13 @@ "format:check": "prettier --check ." }, "devDependencies": { - "@eslint/js": "9.12.0", + "@eslint/js": "9.13.0", "@rollup/plugin-node-resolve": "15.3.0", "@rollup/plugin-terser": "0.4.4", "@rollup/plugin-typescript": "11.1.6", "@types/eslint__js": "8.42.3", "covector": "^0.12.3", - "eslint": "9.12.0", + "eslint": "9.13.0", "eslint-config-prettier": "9.1.0", "eslint-plugin-security": "3.0.1", "prettier": "3.3.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e6b89a14..5d1da82d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,8 +13,8 @@ importers: .: devDependencies: '@eslint/js': - specifier: 9.12.0 - version: 9.12.0 + specifier: 9.13.0 + version: 9.13.0 '@rollup/plugin-node-resolve': specifier: 15.3.0 version: 15.3.0(rollup@4.22.4) @@ -31,11 +31,11 @@ importers: specifier: ^0.12.3 version: 0.12.3(mocha@10.7.3) eslint: - specifier: 9.12.0 - version: 9.12.0(jiti@2.0.0) + specifier: 9.13.0 + version: 9.13.0(jiti@2.0.0) eslint-config-prettier: specifier: 9.1.0 - version: 9.1.0(eslint@9.12.0(jiti@2.0.0)) + version: 9.1.0(eslint@9.13.0(jiti@2.0.0)) eslint-plugin-security: specifier: 3.0.1 version: 3.0.1 @@ -53,7 +53,7 @@ importers: version: 5.6.3 typescript-eslint: specifier: 8.10.0 - version: 8.10.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) + version: 8.10.0(eslint@9.13.0(jiti@2.0.0))(typescript@5.6.3) examples/api: dependencies: @@ -717,16 +717,16 @@ packages: resolution: {integrity: sha512-fTxvnS1sRMu3+JjXwJG0j/i4RT9u4qJ+lqS/yCGap4lH4zZGzQ7tu+xZqQmcMZq5OBZDL4QRxQzRjkWcGt8IVw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@eslint/core@0.6.0': - resolution: {integrity: sha512-8I2Q8ykA4J0x0o7cg67FPVnehcqWTBehu/lmY+bolPFHGjh49YzGBMXTvpqVgEbBdvNCSxj6iFgiIyHzf03lzg==} + '@eslint/core@0.7.0': + resolution: {integrity: sha512-xp5Jirz5DyPYlPiKat8jaq0EmYvDXKKpzTbxXMpT9eqlRJkRKIz9AGMdlvYjih+im+QlhWrpvVjl8IPC/lHlUw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} '@eslint/eslintrc@3.1.0': resolution: {integrity: sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@eslint/js@9.12.0': - resolution: {integrity: sha512-eohesHH8WFRUprDNyEREgqP6beG6htMeUYeCpkEgBCieCMme5r9zFWjzAJp//9S+Kub4rqE+jXe9Cp1a7IYIIA==} + '@eslint/js@9.13.0': + resolution: {integrity: sha512-IFLyoY4d72Z5y/6o/BazFBezupzI/taV8sGumxTAVw3lXG9A6md1Dc34T9s1FoD/an9pJH8RHbAxsaEbBed9lA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} '@eslint/object-schema@2.1.4': @@ -1431,8 +1431,8 @@ packages: resolution: {integrity: sha512-Q7lok0mqMUSf5a/AdAZkA5a/gHcO6snwQClVNNvFKCAVlxXucdU8pKydU5ZVZjBx5xr37vGbFFWtLQYreLzrZg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - eslint@9.12.0: - resolution: {integrity: sha512-UVIOlTEWxwIopRL1wgSQYdnVDcEvs2wyaO6DGo5mXqe3r16IoCNWkR29iHhyaP4cICWjbgbmFUGAhh0GJRuGZw==} + eslint@9.13.0: + resolution: {integrity: sha512-EYZK6SX6zjFHST/HRytOdA/zE72Cq/bfw45LSyuwrdvcclb/gqV8RRQxywOBEWO2+WDpva6UZa4CcDeJKzUCFA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} hasBin: true peerDependencies: @@ -2575,9 +2575,9 @@ snapshots: '@esbuild/win32-x64@0.23.1': optional: true - '@eslint-community/eslint-utils@4.4.0(eslint@9.12.0(jiti@2.0.0))': + '@eslint-community/eslint-utils@4.4.0(eslint@9.13.0(jiti@2.0.0))': dependencies: - eslint: 9.12.0(jiti@2.0.0) + eslint: 9.13.0(jiti@2.0.0) eslint-visitor-keys: 3.4.3 '@eslint-community/regexpp@4.11.1': {} @@ -2590,7 +2590,7 @@ snapshots: transitivePeerDependencies: - supports-color - '@eslint/core@0.6.0': {} + '@eslint/core@0.7.0': {} '@eslint/eslintrc@3.1.0': dependencies: @@ -2606,7 +2606,7 @@ snapshots: transitivePeerDependencies: - supports-color - '@eslint/js@9.12.0': {} + '@eslint/js@9.13.0': {} '@eslint/object-schema@2.1.4': {} @@ -2857,15 +2857,15 @@ snapshots: '@types/unist@2.0.11': {} - '@typescript-eslint/eslint-plugin@8.10.0(@typescript-eslint/parser@8.10.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3))(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3)': + '@typescript-eslint/eslint-plugin@8.10.0(@typescript-eslint/parser@8.10.0(eslint@9.13.0(jiti@2.0.0))(typescript@5.6.3))(eslint@9.13.0(jiti@2.0.0))(typescript@5.6.3)': dependencies: '@eslint-community/regexpp': 4.11.1 - '@typescript-eslint/parser': 8.10.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) + '@typescript-eslint/parser': 8.10.0(eslint@9.13.0(jiti@2.0.0))(typescript@5.6.3) '@typescript-eslint/scope-manager': 8.10.0 - '@typescript-eslint/type-utils': 8.10.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) - '@typescript-eslint/utils': 8.10.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) + '@typescript-eslint/type-utils': 8.10.0(eslint@9.13.0(jiti@2.0.0))(typescript@5.6.3) + '@typescript-eslint/utils': 8.10.0(eslint@9.13.0(jiti@2.0.0))(typescript@5.6.3) '@typescript-eslint/visitor-keys': 8.10.0 - eslint: 9.12.0(jiti@2.0.0) + eslint: 9.13.0(jiti@2.0.0) graphemer: 1.4.0 ignore: 5.3.2 natural-compare: 1.4.0 @@ -2875,14 +2875,14 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/parser@8.10.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3)': + '@typescript-eslint/parser@8.10.0(eslint@9.13.0(jiti@2.0.0))(typescript@5.6.3)': dependencies: '@typescript-eslint/scope-manager': 8.10.0 '@typescript-eslint/types': 8.10.0 '@typescript-eslint/typescript-estree': 8.10.0(typescript@5.6.3) '@typescript-eslint/visitor-keys': 8.10.0 debug: 4.3.7(supports-color@8.1.1) - eslint: 9.12.0(jiti@2.0.0) + eslint: 9.13.0(jiti@2.0.0) optionalDependencies: typescript: 5.6.3 transitivePeerDependencies: @@ -2893,10 +2893,10 @@ snapshots: '@typescript-eslint/types': 8.10.0 '@typescript-eslint/visitor-keys': 8.10.0 - '@typescript-eslint/type-utils@8.10.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3)': + '@typescript-eslint/type-utils@8.10.0(eslint@9.13.0(jiti@2.0.0))(typescript@5.6.3)': dependencies: '@typescript-eslint/typescript-estree': 8.10.0(typescript@5.6.3) - '@typescript-eslint/utils': 8.10.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) + '@typescript-eslint/utils': 8.10.0(eslint@9.13.0(jiti@2.0.0))(typescript@5.6.3) debug: 4.3.7(supports-color@8.1.1) ts-api-utils: 1.3.0(typescript@5.6.3) optionalDependencies: @@ -2922,13 +2922,13 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@8.10.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3)': + '@typescript-eslint/utils@8.10.0(eslint@9.13.0(jiti@2.0.0))(typescript@5.6.3)': dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@9.12.0(jiti@2.0.0)) + '@eslint-community/eslint-utils': 4.4.0(eslint@9.13.0(jiti@2.0.0)) '@typescript-eslint/scope-manager': 8.10.0 '@typescript-eslint/types': 8.10.0 '@typescript-eslint/typescript-estree': 8.10.0(typescript@5.6.3) - eslint: 9.12.0(jiti@2.0.0) + eslint: 9.13.0(jiti@2.0.0) transitivePeerDependencies: - supports-color - typescript @@ -3371,9 +3371,9 @@ snapshots: escape-string-regexp@4.0.0: {} - eslint-config-prettier@9.1.0(eslint@9.12.0(jiti@2.0.0)): + eslint-config-prettier@9.1.0(eslint@9.13.0(jiti@2.0.0)): dependencies: - eslint: 9.12.0(jiti@2.0.0) + eslint: 9.13.0(jiti@2.0.0) eslint-plugin-security@3.0.1: dependencies: @@ -3388,14 +3388,14 @@ snapshots: eslint-visitor-keys@4.1.0: {} - eslint@9.12.0(jiti@2.0.0): + eslint@9.13.0(jiti@2.0.0): dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@9.12.0(jiti@2.0.0)) + '@eslint-community/eslint-utils': 4.4.0(eslint@9.13.0(jiti@2.0.0)) '@eslint-community/regexpp': 4.11.1 '@eslint/config-array': 0.18.0 - '@eslint/core': 0.6.0 + '@eslint/core': 0.7.0 '@eslint/eslintrc': 3.1.0 - '@eslint/js': 9.12.0 + '@eslint/js': 9.13.0 '@eslint/plugin-kit': 0.2.0 '@humanfs/node': 0.16.5 '@humanwhocodes/module-importer': 1.0.1 @@ -4137,11 +4137,11 @@ snapshots: type-fest@0.7.1: {} - typescript-eslint@8.10.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3): + typescript-eslint@8.10.0(eslint@9.13.0(jiti@2.0.0))(typescript@5.6.3): dependencies: - '@typescript-eslint/eslint-plugin': 8.10.0(@typescript-eslint/parser@8.10.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3))(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) - '@typescript-eslint/parser': 8.10.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) - '@typescript-eslint/utils': 8.10.0(eslint@9.12.0(jiti@2.0.0))(typescript@5.6.3) + '@typescript-eslint/eslint-plugin': 8.10.0(@typescript-eslint/parser@8.10.0(eslint@9.13.0(jiti@2.0.0))(typescript@5.6.3))(eslint@9.13.0(jiti@2.0.0))(typescript@5.6.3) + '@typescript-eslint/parser': 8.10.0(eslint@9.13.0(jiti@2.0.0))(typescript@5.6.3) + '@typescript-eslint/utils': 8.10.0(eslint@9.13.0(jiti@2.0.0))(typescript@5.6.3) optionalDependencies: typescript: 5.6.3 transitivePeerDependencies: From 44c50c1275335bd4f785e9c8eff1ee4cb03d394f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 20 Oct 2024 17:28:39 +0800 Subject: [PATCH 08/13] chore(deps): update rust crate tauri to 2.0.4 (#1952) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 8cdb23a9..a17d33ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ resolver = "2" [workspace.dependencies] serde = { version = "1", features = ["derive"] } log = "0.4" -tauri = { version = "2.0.2", default-features = false } +tauri = { version = "2.0.4", default-features = false } tauri-build = "2.0.1" tauri-plugin = "2.0.1" tauri-utils = "2.0.1" From 2302c2db1c49673e61dcbda8cdb01b2c57e9ba6f Mon Sep 17 00:00:00 2001 From: Tony <68118705+Legend-Master@users.noreply.github.com> Date: Sun, 20 Oct 2024 19:48:45 +0800 Subject: [PATCH 09/13] fix(dialog): `ask` and `confirm` not using system button texts (#1910) * Fix `ask`'s button texts being ok and cancel * Update change file --- .changes/dialog-native-button-texts.md | 6 ++++ plugins/dialog/api-iife.js | 2 +- plugins/dialog/guest-js/index.ts | 8 ++--- plugins/dialog/src/commands.rs | 44 ++++++++++++++------------ plugins/dialog/src/desktop.rs | 1 + plugins/dialog/src/lib.rs | 3 ++ plugins/dialog/src/models.rs | 2 ++ 7 files changed, 40 insertions(+), 26 deletions(-) create mode 100644 .changes/dialog-native-button-texts.md diff --git a/.changes/dialog-native-button-texts.md b/.changes/dialog-native-button-texts.md new file mode 100644 index 00000000..f8e055bc --- /dev/null +++ b/.changes/dialog-native-button-texts.md @@ -0,0 +1,6 @@ +--- +"dialog": "patch" +"dialog-js": "patch" +--- + +Fix `ask` and `confirm` not using system button texts diff --git a/plugins/dialog/api-iife.js b/plugins/dialog/api-iife.js index ee604570..c2e0870c 100644 --- a/plugins/dialog/api-iife.js +++ b/plugins/dialog/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_PLUGIN_DIALOG__=function(t){"use strict";async function n(t,n={},e){return window.__TAURI_INTERNALS__.invoke(t,n,e)}return"function"==typeof SuppressedError&&SuppressedError,t.ask=async function(t,e){const i="string"==typeof e?{title:e}:e;return await n("plugin:dialog|ask",{message:t.toString(),title:i?.title?.toString(),kind:i?.kind,okButtonLabel:i?.okLabel?.toString()??"Yes",cancelButtonLabel:i?.cancelLabel?.toString()??"No"})},t.confirm=async function(t,e){const i="string"==typeof e?{title:e}:e;return await n("plugin:dialog|confirm",{message:t.toString(),title:i?.title?.toString(),kind:i?.kind,okButtonLabel:i?.okLabel?.toString()??"Ok",cancelButtonLabel:i?.cancelLabel?.toString()??"Cancel"})},t.message=async function(t,e){const i="string"==typeof e?{title:e}:e;await n("plugin:dialog|message",{message:t.toString(),title:i?.title?.toString(),kind:i?.kind,okButtonLabel:i?.okLabel?.toString()})},t.open=async function(t={}){return"object"==typeof t&&Object.freeze(t),await n("plugin:dialog|open",{options:t})},t.save=async function(t={}){return"object"==typeof t&&Object.freeze(t),await n("plugin:dialog|save",{options:t})},t}({});Object.defineProperty(window.__TAURI__,"dialog",{value:__TAURI_PLUGIN_DIALOG__})} +if("__TAURI__"in window){var __TAURI_PLUGIN_DIALOG__=function(t){"use strict";async function n(t,n={},e){return window.__TAURI_INTERNALS__.invoke(t,n,e)}return"function"==typeof SuppressedError&&SuppressedError,t.ask=async function(t,e){const i="string"==typeof e?{title:e}:e;return await n("plugin:dialog|ask",{message:t.toString(),title:i?.title?.toString(),kind:i?.kind,yesButtonLabel:i?.okLabel?.toString(),noButtonLabel:i?.cancelLabel?.toString()})},t.confirm=async function(t,e){const i="string"==typeof e?{title:e}:e;return await n("plugin:dialog|confirm",{message:t.toString(),title:i?.title?.toString(),kind:i?.kind,okButtonLabel:i?.okLabel?.toString(),cancelButtonLabel:i?.cancelLabel?.toString()})},t.message=async function(t,e){const i="string"==typeof e?{title:e}:e;await n("plugin:dialog|message",{message:t.toString(),title:i?.title?.toString(),kind:i?.kind,okButtonLabel:i?.okLabel?.toString()})},t.open=async function(t={}){return"object"==typeof t&&Object.freeze(t),await n("plugin:dialog|open",{options:t})},t.save=async function(t={}){return"object"==typeof t&&Object.freeze(t),await n("plugin:dialog|save",{options:t})},t}({});Object.defineProperty(window.__TAURI__,"dialog",{value:__TAURI_PLUGIN_DIALOG__})} diff --git a/plugins/dialog/guest-js/index.ts b/plugins/dialog/guest-js/index.ts index a6301ebe..150be95a 100644 --- a/plugins/dialog/guest-js/index.ts +++ b/plugins/dialog/guest-js/index.ts @@ -257,8 +257,8 @@ async function ask( message: message.toString(), title: opts?.title?.toString(), kind: opts?.kind, - okButtonLabel: opts?.okLabel?.toString() ?? 'Yes', - cancelButtonLabel: opts?.cancelLabel?.toString() ?? 'No' + yesButtonLabel: opts?.okLabel?.toString(), + noButtonLabel: opts?.cancelLabel?.toString() }) } @@ -287,8 +287,8 @@ async function confirm( message: message.toString(), title: opts?.title?.toString(), kind: opts?.kind, - okButtonLabel: opts?.okLabel?.toString() ?? 'Ok', - cancelButtonLabel: opts?.cancelLabel?.toString() ?? 'Cancel' + okButtonLabel: opts?.okLabel?.toString(), + cancelButtonLabel: opts?.cancelLabel?.toString() }) } diff --git a/plugins/dialog/src/commands.rs b/plugins/dialog/src/commands.rs index 8690a8b0..4129b7b6 100644 --- a/plugins/dialog/src/commands.rs +++ b/plugins/dialog/src/commands.rs @@ -10,7 +10,7 @@ use tauri_plugin_fs::FsExt; use crate::{ Dialog, FileDialogBuilder, FilePath, MessageDialogButtons, MessageDialogKind, Result, CANCEL, - OK, + NO, OK, YES, }; #[derive(Serialize)] @@ -299,8 +299,8 @@ pub(crate) async fn ask( title: Option, message: String, kind: Option, - ok_button_label: Option, - cancel_button_label: Option, + yes_button_label: Option, + no_button_label: Option, ) -> Result { Ok(message_dialog( window, @@ -308,7 +308,16 @@ pub(crate) async fn ask( title, message, kind, - get_ok_cancel_type(ok_button_label, cancel_button_label), + if let Some(yes_button_label) = yes_button_label { + MessageDialogButtons::OkCancelCustom( + yes_button_label, + no_button_label.unwrap_or(NO.to_string()), + ) + } else if let Some(no_button_label) = no_button_label { + MessageDialogButtons::OkCancelCustom(YES.to_string(), no_button_label) + } else { + MessageDialogButtons::YesNo + }, )) } @@ -328,22 +337,15 @@ pub(crate) async fn confirm( title, message, kind, - get_ok_cancel_type(ok_button_label, cancel_button_label), + if let Some(ok_button_label) = ok_button_label { + MessageDialogButtons::OkCancelCustom( + ok_button_label, + cancel_button_label.unwrap_or(CANCEL.to_string()), + ) + } else if let Some(cancel_button_label) = cancel_button_label { + MessageDialogButtons::OkCancelCustom(OK.to_string(), cancel_button_label) + } else { + MessageDialogButtons::OkCancel + }, )) } - -fn get_ok_cancel_type( - ok_button_label: Option, - cancel_button_label: Option, -) -> MessageDialogButtons { - if let Some(ok_button_label) = ok_button_label { - MessageDialogButtons::OkCancelCustom( - ok_button_label, - cancel_button_label.unwrap_or(CANCEL.to_string()), - ) - } else if let Some(cancel_button_label) = cancel_button_label { - MessageDialogButtons::OkCancelCustom(OK.to_string(), cancel_button_label) - } else { - MessageDialogButtons::OkCancel - } -} diff --git a/plugins/dialog/src/desktop.rs b/plugins/dialog/src/desktop.rs index d30f6bfe..d1a3e8b2 100644 --- a/plugins/dialog/src/desktop.rs +++ b/plugins/dialog/src/desktop.rs @@ -112,6 +112,7 @@ impl From for rfd::MessageButtons { match value { MessageDialogButtons::Ok => Self::Ok, MessageDialogButtons::OkCancel => Self::OkCancel, + MessageDialogButtons::YesNo => Self::YesNo, MessageDialogButtons::OkCustom(ok) => Self::OkCustom(ok), MessageDialogButtons::OkCancelCustom(ok, cancel) => Self::OkCancelCustom(ok, cancel), } diff --git a/plugins/dialog/src/lib.rs b/plugins/dialog/src/lib.rs index a7538e1b..3d7464d9 100644 --- a/plugins/dialog/src/lib.rs +++ b/plugins/dialog/src/lib.rs @@ -43,6 +43,8 @@ use mobile::*; pub(crate) const OK: &str = "Ok"; pub(crate) const CANCEL: &str = "Cancel"; +pub(crate) const YES: &str = "Yes"; +pub(crate) const NO: &str = "No"; macro_rules! blocking_fn { ($self:ident, $fn:ident) => {{ @@ -236,6 +238,7 @@ impl MessageDialogBuilder { let (ok_button_label, cancel_button_label) = match &self.buttons { MessageDialogButtons::Ok => (Some(OK), None), MessageDialogButtons::OkCancel => (Some(OK), Some(CANCEL)), + MessageDialogButtons::YesNo => (Some(YES), Some(NO)), MessageDialogButtons::OkCustom(ok) => (Some(ok.as_str()), Some(CANCEL)), MessageDialogButtons::OkCancelCustom(ok, cancel) => { (Some(ok.as_str()), Some(cancel.as_str())) diff --git a/plugins/dialog/src/models.rs b/plugins/dialog/src/models.rs index 3f9eb6c1..d6452bce 100644 --- a/plugins/dialog/src/models.rs +++ b/plugins/dialog/src/models.rs @@ -59,6 +59,8 @@ pub enum MessageDialogButtons { Ok, /// 2 buttons `Ok` and `Cancel` with OS default dialog texts OkCancel, + /// 2 buttons `Yes` and `No` with OS default dialog texts + YesNo, /// A single `Ok` button with custom text OkCustom(String), /// 2 buttons `Ok` and `Cancel` with custom texts From ae8024565f074f313084777c8b10d1b5e3bbe220 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Sun, 20 Oct 2024 14:49:01 +0300 Subject: [PATCH 10/13] perf(fs): improve `FileHandle.read` performance (#1950) * perf(fs): improve `FileHandle.read` performance * handle different target pointer width * improve `writeTextFile` performance * revert packageManager field * change file --------- Co-authored-by: Lucas Nogueira --- .changes/fs-perf.md | 6 ++ plugins/fs/api-iife.js | 2 +- plugins/fs/guest-js/index.ts | 42 +++++++++++-- plugins/fs/src/commands.rs | 111 +++++++++++++++++++---------------- 4 files changed, 104 insertions(+), 57 deletions(-) create mode 100644 .changes/fs-perf.md diff --git a/.changes/fs-perf.md b/.changes/fs-perf.md new file mode 100644 index 00000000..3d4e82c3 --- /dev/null +++ b/.changes/fs-perf.md @@ -0,0 +1,6 @@ +--- +"fs": patch +"fs-js": patch +--- + +Improve performance of the `FileHandle.read` and `writeTextFile` APIs. diff --git a/plugins/fs/api-iife.js b/plugins/fs/api-iife.js index b855277d..e863d7a9 100644 --- a/plugins/fs/api-iife.js +++ b/plugins/fs/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_PLUGIN_FS__=function(t){"use strict";function e(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)}function n(t,e,n,i,o){if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,n),n}var i,o,r,a,s,c;"function"==typeof SuppressedError&&SuppressedError;class f{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,i.set(this,(()=>{})),o.set(this,0),r.set(this,{}),this.id=function(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}((({message:t,id:a})=>{if(a===e(this,o,"f")){n(this,o,a+1),e(this,i,"f").call(this,t);const s=Object.keys(e(this,r,"f"));if(s.length>0){let t=a+1;for(const n of s.sort()){if(parseInt(n)!==t)break;{const o=e(this,r,"f")[n];delete e(this,r,"f")[n],e(this,i,"f").call(this,o),t+=1}}n(this,o,t)}}else e(this,r,"f")[a.toString()]=t}))}set onmessage(t){n(this,i,t)}get onmessage(){return e(this,i,"f")}toJSON(){return`__CHANNEL__:${this.id}`}}async function l(t,e={},n){return window.__TAURI_INTERNALS__.invoke(t,e,n)}i=new WeakMap,o=new WeakMap,r=new WeakMap;class u{get rid(){return e(this,a,"f")}constructor(t){a.set(this,void 0),n(this,a,t)}async close(){return l("plugin:resources|close",{rid:this.rid})}}function p(t){return{isFile:t.isFile,isDirectory:t.isDirectory,isSymlink:t.isSymlink,size:t.size,mtime:null!==t.mtime?new Date(t.mtime):null,atime:null!==t.atime?new Date(t.atime):null,birthtime:null!==t.birthtime?new Date(t.birthtime):null,readonly:t.readonly,fileAttributes:t.fileAttributes,dev:t.dev,ino:t.ino,mode:t.mode,nlink:t.nlink,uid:t.uid,gid:t.gid,rdev:t.rdev,blksize:t.blksize,blocks:t.blocks}}a=new WeakMap,t.BaseDirectory=void 0,(s=t.BaseDirectory||(t.BaseDirectory={}))[s.Audio=1]="Audio",s[s.Cache=2]="Cache",s[s.Config=3]="Config",s[s.Data=4]="Data",s[s.LocalData=5]="LocalData",s[s.Document=6]="Document",s[s.Download=7]="Download",s[s.Picture=8]="Picture",s[s.Public=9]="Public",s[s.Video=10]="Video",s[s.Resource=11]="Resource",s[s.Temp=12]="Temp",s[s.AppConfig=13]="AppConfig",s[s.AppData=14]="AppData",s[s.AppLocalData=15]="AppLocalData",s[s.AppCache=16]="AppCache",s[s.AppLog=17]="AppLog",s[s.Desktop=18]="Desktop",s[s.Executable=19]="Executable",s[s.Font=20]="Font",s[s.Home=21]="Home",s[s.Runtime=22]="Runtime",s[s.Template=23]="Template",t.SeekMode=void 0,(c=t.SeekMode||(t.SeekMode={}))[c.Start=0]="Start",c[c.Current=1]="Current",c[c.End=2]="End";class w extends u{async read(t){if(0===t.byteLength)return 0;const[e,n]=await l("plugin:fs|read",{rid:this.rid,len:t.byteLength});return t.set(e),0===n?null:n}async seek(t,e){return await l("plugin:fs|seek",{rid:this.rid,offset:t,whence:e})}async stat(){return p(await l("plugin:fs|fstat",{rid:this.rid}))}async truncate(t){await l("plugin:fs|ftruncate",{rid:this.rid,len:t})}async write(t){return await l("plugin:fs|write",{rid:this.rid,data:t})}}async function h(t){await l("plugin:fs|unwatch",{rid:t})}return t.FileHandle=w,t.copyFile=async function(t,e,n){if(t instanceof URL&&"file:"!==t.protocol||e instanceof URL&&"file:"!==e.protocol)throw new TypeError("Must be a file URL.");await l("plugin:fs|copy_file",{fromPath:t instanceof URL?t.toString():t,toPath:e instanceof URL?e.toString():e,options:n})},t.create=async function(t,e){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");const n=await l("plugin:fs|create",{path:t instanceof URL?t.toString():t,options:e});return new w(n)},t.exists=async function(t,e){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");return await l("plugin:fs|exists",{path:t instanceof URL?t.toString():t,options:e})},t.lstat=async function(t,e){return p(await l("plugin:fs|lstat",{path:t instanceof URL?t.toString():t,options:e}))},t.mkdir=async function(t,e){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");await l("plugin:fs|mkdir",{path:t instanceof URL?t.toString():t,options:e})},t.open=async function(t,e){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");const n=await l("plugin:fs|open",{path:t instanceof URL?t.toString():t,options:e});return new w(n)},t.readDir=async function(t,e){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");return await l("plugin:fs|read_dir",{path:t instanceof URL?t.toString():t,options:e})},t.readFile=async function(t,e){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");const n=await l("plugin:fs|read_file",{path:t instanceof URL?t.toString():t,options:e});return n instanceof ArrayBuffer?new Uint8Array(n):Uint8Array.from(n)},t.readTextFile=async function(t,e){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");return await l("plugin:fs|read_text_file",{path:t instanceof URL?t.toString():t,options:e})},t.readTextFileLines=async function(t,e){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");const n=t instanceof URL?t.toString():t;return await Promise.resolve({path:n,rid:null,async next(){null===this.rid&&(this.rid=await l("plugin:fs|read_text_file_lines",{path:n,options:e}));const[t,i]=await l("plugin:fs|read_text_file_lines_next",{rid:this.rid});return i&&(this.rid=null),{value:i?"":t,done:i}},[Symbol.asyncIterator](){return this}})},t.remove=async function(t,e){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");await l("plugin:fs|remove",{path:t instanceof URL?t.toString():t,options:e})},t.rename=async function(t,e,n){if(t instanceof URL&&"file:"!==t.protocol||e instanceof URL&&"file:"!==e.protocol)throw new TypeError("Must be a file URL.");await l("plugin:fs|rename",{oldPath:t instanceof URL?t.toString():t,newPath:e instanceof URL?e.toString():e,options:n})},t.stat=async function(t,e){return p(await l("plugin:fs|stat",{path:t instanceof URL?t.toString():t,options:e}))},t.truncate=async function(t,e,n){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");await l("plugin:fs|truncate",{path:t instanceof URL?t.toString():t,len:e,options:n})},t.watch=async function(t,e,n){const i={recursive:!1,delayMs:2e3,...n},o=Array.isArray(t)?t:[t];for(const t of o)if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");const r=new f;r.onmessage=e;const a=await l("plugin:fs|watch",{paths:o.map((t=>t instanceof URL?t.toString():t)),options:i,onEvent:r});return()=>{h(a)}},t.watchImmediate=async function(t,e,n){const i={recursive:!1,...n,delayMs:null},o=Array.isArray(t)?t:[t];for(const t of o)if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");const r=new f;r.onmessage=e;const a=await l("plugin:fs|watch",{paths:o.map((t=>t instanceof URL?t.toString():t)),options:i,onEvent:r});return()=>{h(a)}},t.writeFile=async function(t,e,n){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");await l("plugin:fs|write_file",e,{headers:{path:encodeURIComponent(t instanceof URL?t.toString():t),options:JSON.stringify(n)}})},t.writeTextFile=async function(t,e,n){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");await l("plugin:fs|write_text_file",{path:t instanceof URL?t.toString():t,data:e,options:n})},t}({});Object.defineProperty(window.__TAURI__,"fs",{value:__TAURI_PLUGIN_FS__})} +if("__TAURI__"in window){var __TAURI_PLUGIN_FS__=function(t){"use strict";function e(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)}function n(t,e,n,i,o){if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,n),n}var i,o,r,a,s,c;"function"==typeof SuppressedError&&SuppressedError;class f{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,i.set(this,(()=>{})),o.set(this,0),r.set(this,{}),this.id=function(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}((({message:t,id:a})=>{if(a===e(this,o,"f")){n(this,o,a+1),e(this,i,"f").call(this,t);const s=Object.keys(e(this,r,"f"));if(s.length>0){let t=a+1;for(const n of s.sort()){if(parseInt(n)!==t)break;{const o=e(this,r,"f")[n];delete e(this,r,"f")[n],e(this,i,"f").call(this,o),t+=1}}n(this,o,t)}}else e(this,r,"f")[a.toString()]=t}))}set onmessage(t){n(this,i,t)}get onmessage(){return e(this,i,"f")}toJSON(){return`__CHANNEL__:${this.id}`}}async function l(t,e={},n){return window.__TAURI_INTERNALS__.invoke(t,e,n)}i=new WeakMap,o=new WeakMap,r=new WeakMap;class u{get rid(){return e(this,a,"f")}constructor(t){a.set(this,void 0),n(this,a,t)}async close(){return l("plugin:resources|close",{rid:this.rid})}}function p(t){return{isFile:t.isFile,isDirectory:t.isDirectory,isSymlink:t.isSymlink,size:t.size,mtime:null!==t.mtime?new Date(t.mtime):null,atime:null!==t.atime?new Date(t.atime):null,birthtime:null!==t.birthtime?new Date(t.birthtime):null,readonly:t.readonly,fileAttributes:t.fileAttributes,dev:t.dev,ino:t.ino,mode:t.mode,nlink:t.nlink,uid:t.uid,gid:t.gid,rdev:t.rdev,blksize:t.blksize,blocks:t.blocks}}a=new WeakMap,t.BaseDirectory=void 0,(s=t.BaseDirectory||(t.BaseDirectory={}))[s.Audio=1]="Audio",s[s.Cache=2]="Cache",s[s.Config=3]="Config",s[s.Data=4]="Data",s[s.LocalData=5]="LocalData",s[s.Document=6]="Document",s[s.Download=7]="Download",s[s.Picture=8]="Picture",s[s.Public=9]="Public",s[s.Video=10]="Video",s[s.Resource=11]="Resource",s[s.Temp=12]="Temp",s[s.AppConfig=13]="AppConfig",s[s.AppData=14]="AppData",s[s.AppLocalData=15]="AppLocalData",s[s.AppCache=16]="AppCache",s[s.AppLog=17]="AppLog",s[s.Desktop=18]="Desktop",s[s.Executable=19]="Executable",s[s.Font=20]="Font",s[s.Home=21]="Home",s[s.Runtime=22]="Runtime",s[s.Template=23]="Template",t.SeekMode=void 0,(c=t.SeekMode||(t.SeekMode={}))[c.Start=0]="Start",c[c.Current=1]="Current",c[c.End=2]="End";class w extends u{async read(t){if(0===t.byteLength)return 0;const e=await l("plugin:fs|read",{rid:this.rid,len:t.byteLength}),n=function(t){const e=new Uint8ClampedArray(t),n=e.byteLength;let i=0;for(let t=0;tt instanceof URL?t.toString():t)),options:i,onEvent:r});return()=>{h(a)}},t.watchImmediate=async function(t,e,n){const i={recursive:!1,...n,delayMs:null},o=Array.isArray(t)?t:[t];for(const t of o)if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");const r=new f;r.onmessage=e;const a=await l("plugin:fs|watch",{paths:o.map((t=>t instanceof URL?t.toString():t)),options:i,onEvent:r});return()=>{h(a)}},t.writeFile=async function(t,e,n){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");await l("plugin:fs|write_file",e,{headers:{path:encodeURIComponent(t instanceof URL?t.toString():t),options:JSON.stringify(n)}})},t.writeTextFile=async function(t,e,n){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");const i=new TextEncoder;await l("plugin:fs|write_text_file",i.encode(e),{headers:{path:t instanceof URL?t.toString():t,options:JSON.stringify(n)}})},t}({});Object.defineProperty(window.__TAURI__,"fs",{value:__TAURI_PLUGIN_FS__})} diff --git a/plugins/fs/guest-js/index.ts b/plugins/fs/guest-js/index.ts index 1f314f71..57e7518d 100644 --- a/plugins/fs/guest-js/index.ts +++ b/plugins/fs/guest-js/index.ts @@ -243,6 +243,25 @@ function parseFileInfo(r: UnparsedFileInfo): FileInfo { } } +// https://mstn.github.io/2018/06/08/fixed-size-arrays-in-typescript/ +type FixedSizeArray = ReadonlyArray & { + length: N +} + +// https://gist.github.com/zapthedingbat/38ebfbedd98396624e5b5f2ff462611d +/** Converts a big-endian eight byte array to number */ +function fromBytes(buffer: FixedSizeArray): number { + const bytes = new Uint8ClampedArray(buffer) + const size = bytes.byteLength + let x = 0 + for (let i = 0; i < size; i++) { + const byte = bytes[i] + x *= 0x100 + x += byte + } + return x +} + /** * The Tauri abstraction for reading and writing files. * @@ -285,12 +304,20 @@ class FileHandle extends Resource { return 0 } - const [data, nread] = await invoke<[number[], number]>('plugin:fs|read', { + const data = await invoke('plugin:fs|read', { rid: this.rid, len: buffer.byteLength }) - buffer.set(data) + // Rust side will never return an empty array for this command and + // ensure there is at least 8 elements there. + // + // This is an optimization to include the number of read bytes (as bigendian bytes) + // at the end of returned array to avoid serialization overhead of separate values. + const nread = fromBytes(data.slice(-8) as FixedSizeArray) + + const bytes = data instanceof ArrayBuffer ? new Uint8Array(data) : data + buffer.set(bytes.slice(0, bytes.length - 8)) return nread === 0 ? null : nread } @@ -1041,10 +1068,13 @@ async function writeTextFile( throw new TypeError('Must be a file URL.') } - await invoke('plugin:fs|write_text_file', { - path: path instanceof URL ? path.toString() : path, - data, - options + const encoder = new TextEncoder() + + await invoke('plugin:fs|write_text_file', encoder.encode(data), { + headers: { + path: path instanceof URL ? path.toString() : path, + options: JSON.stringify(options) + } }) } diff --git a/plugins/fs/src/commands.rs b/plugins/fs/src/commands.rs index cb40c3ee..58f2ce62 100644 --- a/plugins/fs/src/commands.rs +++ b/plugins/fs/src/commands.rs @@ -9,7 +9,7 @@ use tauri::{ ipc::{CommandScope, GlobalScope}, path::BaseDirectory, utils::config::FsScope, - AppHandle, Manager, Resource, ResourceId, Runtime, Webview, + Manager, Resource, ResourceId, Runtime, Webview, }; use std::{ @@ -301,13 +301,34 @@ pub async fn read_dir( pub async fn read( webview: Webview, rid: ResourceId, - len: u32, -) -> CommandResult<(Vec, usize)> { - let mut data = vec![0; len as usize]; + len: usize, +) -> CommandResult { + let mut data = vec![0; len]; let file = webview.resources_table().get::(rid)?; let nread = StdFileResource::with_lock(&file, |mut file| file.read(&mut data)) .map_err(|e| format!("faied to read bytes from file with error: {e}"))?; - Ok((data, nread)) + + // This is an optimization to include the number of read bytes (as bigendian bytes) + // at the end of returned vector so we can use `tauri::ipc::Response` + // and avoid serialization overhead of separate values. + #[cfg(target_pointer_width = "16")] + let nread = { + let nread = nread.to_be_bytes(); + let mut out = [0; 8]; + out[6..].copy_from_slice(&nread); + }; + #[cfg(target_pointer_width = "32")] + let nread = { + let nread = nread.to_be_bytes(); + let mut out = [0; 8]; + out[4..].copy_from_slice(&nread); + }; + #[cfg(target_pointer_width = "64")] + let nread = nread.to_be_bytes(); + + data.extend(nread); + + Ok(tauri::ipc::Response::new(data)) } #[tauri::command] @@ -783,10 +804,34 @@ fn write_file_inner( webview: Webview, global_scope: &GlobalScope, command_scope: &CommandScope, - path: SafeFilePath, - data: &[u8], - options: Option, + request: tauri::ipc::Request<'_>, ) -> CommandResult<()> { + let data = match request.body() { + tauri::ipc::InvokeBody::Raw(data) => Cow::Borrowed(data), + tauri::ipc::InvokeBody::Json(serde_json::Value::Array(data)) => Cow::Owned( + data.iter() + .flat_map(|v| v.as_number().and_then(|v| v.as_u64().map(|v| v as u8))) + .collect(), + ), + _ => return Err(anyhow::anyhow!("unexpected invoke body").into()), + }; + + let path = request + .headers() + .get("path") + .ok_or_else(|| anyhow::anyhow!("missing file path").into()) + .and_then(|p| { + percent_encoding::percent_decode(p.as_ref()) + .decode_utf8() + .map_err(|_| anyhow::anyhow!("path is not a valid UTF-8").into()) + }) + .and_then(|p| SafeFilePath::from_str(&p).map_err(CommandError::from))?; + let options: Option = request + .headers() + .get("options") + .and_then(|p| p.to_str().ok()) + .and_then(|opts| serde_json::from_str(opts).ok()); + let (mut file, path) = resolve_file( &webview, global_scope, @@ -823,7 +868,7 @@ fn write_file_inner( }, )?; - file.write_all(data) + file.write_all(&data) .map_err(|e| { format!( "failed to write bytes to file at path: {} with error: {e}", @@ -840,52 +885,18 @@ pub async fn write_file( command_scope: CommandScope, request: tauri::ipc::Request<'_>, ) -> CommandResult<()> { - let data = match request.body() { - tauri::ipc::InvokeBody::Raw(data) => Cow::Borrowed(data), - tauri::ipc::InvokeBody::Json(serde_json::Value::Array(data)) => Cow::Owned( - data.iter() - .flat_map(|v| v.as_number().and_then(|v| v.as_u64().map(|v| v as u8))) - .collect(), - ), - _ => return Err(anyhow::anyhow!("unexpected invoke body").into()), - }; - - let path = request - .headers() - .get("path") - .ok_or_else(|| anyhow::anyhow!("missing file path").into()) - .and_then(|p| { - percent_encoding::percent_decode(p.as_ref()) - .decode_utf8() - .map_err(|_| anyhow::anyhow!("path is not a valid UTF-8").into()) - }) - .and_then(|p| SafeFilePath::from_str(&p).map_err(CommandError::from))?; - let options = request - .headers() - .get("options") - .and_then(|p| p.to_str().ok()) - .and_then(|opts| serde_json::from_str(opts).ok()); - write_file_inner(webview, &global_scope, &command_scope, path, &data, options) + write_file_inner(webview, &global_scope, &command_scope, request) } +// TODO, in v3, remove this command and rely on `write_file` command only #[tauri::command] pub async fn write_text_file( - #[allow(unused)] app: AppHandle, - #[allow(unused)] webview: Webview, - #[allow(unused)] global_scope: GlobalScope, - #[allow(unused)] command_scope: CommandScope, - path: SafeFilePath, - data: String, - #[allow(unused)] options: Option, + webview: Webview, + global_scope: GlobalScope, + command_scope: CommandScope, + request: tauri::ipc::Request<'_>, ) -> CommandResult<()> { - write_file_inner( - webview, - &global_scope, - &command_scope, - path, - data.as_bytes(), - options, - ) + write_file_inner(webview, &global_scope, &command_scope, request) } #[tauri::command] From 3fd283121f5ee739ac8a5149fa7e7520f992aeb0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 20 Oct 2024 08:54:26 -0300 Subject: [PATCH 11/13] publish new versions (#1909) Co-authored-by: lucasfernog --- .changes/dialog-native-button-texts.md | 6 ----- .changes/fix-android-mime-type.md | 6 ----- .changes/fix-handleIconState.md | 6 ----- .changes/fs-perf.md | 6 ----- .changes/http-allow-skip-origin.md | 6 ----- .changes/http-headers-order.md | 6 ----- .changes/shell-open-hang-windows.md | 6 ----- .changes/store-plugin-rework-js-feat.md | 7 ----- .changes/store-plugin-rework.md | 23 ----------------- Cargo.lock | 16 ++++++------ examples/api/CHANGELOG.md | 10 ++++++++ examples/api/package.json | 12 ++++----- examples/api/src-tauri/CHANGELOG.md | 10 ++++++++ examples/api/src-tauri/Cargo.toml | 12 ++++----- plugins/dialog/CHANGELOG.md | 7 +++++ plugins/dialog/Cargo.toml | 4 +-- plugins/dialog/package.json | 2 +- plugins/fs/CHANGELOG.md | 4 +++ plugins/fs/Cargo.toml | 2 +- plugins/fs/package.json | 2 +- plugins/http/CHANGELOG.md | 8 ++++++ plugins/http/Cargo.toml | 4 +-- plugins/http/package.json | 2 +- plugins/persisted-scope/CHANGELOG.md | 6 +++++ plugins/persisted-scope/Cargo.toml | 4 +-- plugins/positioner/CHANGELOG.md | 4 +++ plugins/positioner/Cargo.toml | 2 +- plugins/positioner/package.json | 2 +- plugins/shell/CHANGELOG.md | 4 +++ plugins/shell/Cargo.toml | 2 +- plugins/shell/package.json | 2 +- plugins/store/CHANGELOG.md | 16 ++++++++++++ plugins/store/Cargo.toml | 2 +- plugins/store/package.json | 2 +- pnpm-lock.yaml | 34 +++++++++++++------------ 35 files changed, 123 insertions(+), 124 deletions(-) delete mode 100644 .changes/dialog-native-button-texts.md delete mode 100644 .changes/fix-android-mime-type.md delete mode 100644 .changes/fix-handleIconState.md delete mode 100644 .changes/fs-perf.md delete mode 100644 .changes/http-allow-skip-origin.md delete mode 100644 .changes/http-headers-order.md delete mode 100644 .changes/shell-open-hang-windows.md delete mode 100644 .changes/store-plugin-rework-js-feat.md delete mode 100644 .changes/store-plugin-rework.md diff --git a/.changes/dialog-native-button-texts.md b/.changes/dialog-native-button-texts.md deleted file mode 100644 index f8e055bc..00000000 --- a/.changes/dialog-native-button-texts.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"dialog": "patch" -"dialog-js": "patch" ---- - -Fix `ask` and `confirm` not using system button texts diff --git a/.changes/fix-android-mime-type.md b/.changes/fix-android-mime-type.md deleted file mode 100644 index f9d92237..00000000 --- a/.changes/fix-android-mime-type.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"dialog": patch -"dialog-js": patch ---- - -Set `save` dialog mime type from the `filters` extensions on Android. diff --git a/.changes/fix-handleIconState.md b/.changes/fix-handleIconState.md deleted file mode 100644 index 0b5eec3d..00000000 --- a/.changes/fix-handleIconState.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"positioner": patch -"positioner-js": patch ---- - -Added missing permission for `handleIconState` and fixed its event processing logic. diff --git a/.changes/fs-perf.md b/.changes/fs-perf.md deleted file mode 100644 index 3d4e82c3..00000000 --- a/.changes/fs-perf.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"fs": patch -"fs-js": patch ---- - -Improve performance of the `FileHandle.read` and `writeTextFile` APIs. diff --git a/.changes/http-allow-skip-origin.md b/.changes/http-allow-skip-origin.md deleted file mode 100644 index 99062245..00000000 --- a/.changes/http-allow-skip-origin.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"http": "patch" -"http-js": "patch" ---- - -Allow skipping sending `Origin` header in HTTP requests by setting `Origin` header to an empty string when calling `fetch`. diff --git a/.changes/http-headers-order.md b/.changes/http-headers-order.md deleted file mode 100644 index 66940b83..00000000 --- a/.changes/http-headers-order.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"http": "patch" -"http-js": "patch" ---- - -Retain headers order. \ No newline at end of file diff --git a/.changes/shell-open-hang-windows.md b/.changes/shell-open-hang-windows.md deleted file mode 100644 index e9c22c68..00000000 --- a/.changes/shell-open-hang-windows.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"shell": "patch" -"shell-js": "patch" ---- - -On Windows, Fix `open` JS API hanging and freezing the app. \ No newline at end of file diff --git a/.changes/store-plugin-rework-js-feat.md b/.changes/store-plugin-rework-js-feat.md deleted file mode 100644 index 3306af24..00000000 --- a/.changes/store-plugin-rework-js-feat.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -"store-js": minor:feat ---- - -- Add `getStore` -- Add an option to use pre-stored (de)serialize functions (registered on rust) -- Add `LazyStore` diff --git a/.changes/store-plugin-rework.md b/.changes/store-plugin-rework.md deleted file mode 100644 index 0d9584af..00000000 --- a/.changes/store-plugin-rework.md +++ /dev/null @@ -1,23 +0,0 @@ ---- -"store": minor:breaking ---- - -### Breaking changes: - -- Renamed `StoreCollection` to `StoreState` -- `StoreBuilder::build` now returns a `Result` -- `StoreExt::store` now returns `Result>` - -### Enhancements: - -- Save and cancel pending auto save on drop -- Use absolute path as store's key, fix #984 -- Share store to resource table by default -- Enable auto save with 100ms debounce time by default -- Use pretty json by default, close #1690 - -### New features: - -- Add `get_store` to get shared stores across js and rust side -- Add default (de)serialize functions settings `default_serialize_fn` and `default_deserialize_fn` -- Allow js to use pre-stored (de)serialize functions registered by `register_serialize_fn` and `register_deserialize_fn` diff --git a/Cargo.lock b/Cargo.lock index c8208655..3aeae077 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -218,7 +218,7 @@ checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" [[package]] name = "api" -version = "2.0.2" +version = "2.0.3" dependencies = [ "log", "serde", @@ -6825,7 +6825,7 @@ dependencies = [ [[package]] name = "tauri-plugin-dialog" -version = "2.0.1" +version = "2.0.2" dependencies = [ "log", "raw-window-handle", @@ -6841,7 +6841,7 @@ dependencies = [ [[package]] name = "tauri-plugin-fs" -version = "2.0.1" +version = "2.0.2" dependencies = [ "anyhow", "dunce", @@ -6901,7 +6901,7 @@ dependencies = [ [[package]] name = "tauri-plugin-http" -version = "2.0.1" +version = "2.0.2" dependencies = [ "data-url", "http", @@ -7005,7 +7005,7 @@ dependencies = [ [[package]] name = "tauri-plugin-persisted-scope" -version = "2.0.1" +version = "2.0.2" dependencies = [ "aho-corasick", "bincode", @@ -7019,7 +7019,7 @@ dependencies = [ [[package]] name = "tauri-plugin-positioner" -version = "2.0.1" +version = "2.0.2" dependencies = [ "log", "serde", @@ -7040,7 +7040,7 @@ dependencies = [ [[package]] name = "tauri-plugin-shell" -version = "2.0.1" +version = "2.0.2" dependencies = [ "encoding_rs", "log", @@ -7091,7 +7091,7 @@ dependencies = [ [[package]] name = "tauri-plugin-store" -version = "2.0.1" +version = "2.1.0" dependencies = [ "dunce", "log", diff --git a/examples/api/CHANGELOG.md b/examples/api/CHANGELOG.md index 022ce3f2..0fc70ec0 100644 --- a/examples/api/CHANGELOG.md +++ b/examples/api/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## \[2.0.1] + +### Dependencies + +- Upgraded to `dialog-js@2.0.1` +- Upgraded to `fs-js@2.0.1` +- Upgraded to `http-js@2.0.1` +- Upgraded to `shell-js@2.0.1` +- Upgraded to `store-js@2.1.0` + ## \[2.0.0] - [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. diff --git a/examples/api/package.json b/examples/api/package.json index 33468570..8336c7d4 100644 --- a/examples/api/package.json +++ b/examples/api/package.json @@ -1,7 +1,7 @@ { "name": "svelte-app", "private": true, - "version": "2.0.0", + "version": "2.0.1", "type": "module", "scripts": { "dev": "vite --clearScreen false", @@ -14,18 +14,18 @@ "@tauri-apps/plugin-biometric": "2.0.0", "@tauri-apps/plugin-cli": "2.0.0", "@tauri-apps/plugin-clipboard-manager": "2.0.0", - "@tauri-apps/plugin-dialog": "2.0.0", - "@tauri-apps/plugin-fs": "2.0.0", + "@tauri-apps/plugin-dialog": "2.0.1", + "@tauri-apps/plugin-fs": "2.0.1", "@tauri-apps/plugin-geolocation": "2.0.0", "@tauri-apps/plugin-global-shortcut": "2.0.0", "@tauri-apps/plugin-haptics": "2.0.0", - "@tauri-apps/plugin-http": "2.0.0", + "@tauri-apps/plugin-http": "2.0.1", "@tauri-apps/plugin-nfc": "2.0.0", "@tauri-apps/plugin-notification": "2.0.0", "@tauri-apps/plugin-os": "2.0.0", "@tauri-apps/plugin-process": "2.0.0", - "@tauri-apps/plugin-shell": "2.0.0", - "@tauri-apps/plugin-store": "2.0.0", + "@tauri-apps/plugin-shell": "2.0.1", + "@tauri-apps/plugin-store": "2.1.0", "@tauri-apps/plugin-updater": "2.0.0", "@zerodevx/svelte-json-view": "1.0.11" }, diff --git a/examples/api/src-tauri/CHANGELOG.md b/examples/api/src-tauri/CHANGELOG.md index 0f557732..c8070e63 100644 --- a/examples/api/src-tauri/CHANGELOG.md +++ b/examples/api/src-tauri/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## \[2.0.3] + +### Dependencies + +- Upgraded to `dialog@2.0.2` +- Upgraded to `fs@2.0.2` +- Upgraded to `http@2.0.2` +- Upgraded to `shell@2.0.2` +- Upgraded to `store@2.1.0` + ## \[2.0.2] - [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. diff --git a/examples/api/src-tauri/Cargo.toml b/examples/api/src-tauri/Cargo.toml index 50cd940f..b09e54a6 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.2" +version = "2.0.3" description = "An example Tauri Application showcasing the api" edition = "2021" rust-version = { workspace = true } @@ -20,21 +20,21 @@ serde = { workspace = true } tiny_http = "0.12" log = { workspace = true } tauri-plugin-log = { path = "../../../plugins/log", version = "2.0.1" } -tauri-plugin-fs = { path = "../../../plugins/fs", version = "2.0.1", features = [ +tauri-plugin-fs = { path = "../../../plugins/fs", version = "2.0.2", features = [ "watch", ] } tauri-plugin-clipboard-manager = { path = "../../../plugins/clipboard-manager", version = "2.0.1" } -tauri-plugin-dialog = { path = "../../../plugins/dialog", version = "2.0.1" } +tauri-plugin-dialog = { path = "../../../plugins/dialog", version = "2.0.2" } tauri-plugin-http = { path = "../../../plugins/http", features = [ "multipart", -], version = "2.0.1" } +], version = "2.0.2" } tauri-plugin-notification = { path = "../../../plugins/notification", version = "2.0.1", features = [ "windows7-compat", ] } tauri-plugin-os = { path = "../../../plugins/os", version = "2.0.1" } tauri-plugin-process = { path = "../../../plugins/process", version = "2.0.1" } -tauri-plugin-shell = { path = "../../../plugins/shell", version = "2.0.1" } -tauri-plugin-store = { path = "../../../plugins/store", version = "2.0.1" } +tauri-plugin-shell = { path = "../../../plugins/shell", version = "2.0.2" } +tauri-plugin-store = { path = "../../../plugins/store", version = "2.1.0" } [dependencies.tauri] workspace = true diff --git a/plugins/dialog/CHANGELOG.md b/plugins/dialog/CHANGELOG.md index 150e092e..c124b2ff 100644 --- a/plugins/dialog/CHANGELOG.md +++ b/plugins/dialog/CHANGELOG.md @@ -2,6 +2,11 @@ ## \[2.0.1] +- [`2302c2db`](https://github.com/tauri-apps/plugins-workspace/commit/2302c2db1c49673e61dcbda8cdb01b2c57e9ba6f) ([#1910](https://github.com/tauri-apps/plugins-workspace/pull/1910) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Fix `ask` and `confirm` not using system button texts +- [`aee14ed4`](https://github.com/tauri-apps/plugins-workspace/commit/aee14ed4261cdedc4ed7cc2686f01f437859a5c7) ([#1892](https://github.com/tauri-apps/plugins-workspace/pull/1892) by [@nashaofu](https://github.com/tauri-apps/plugins-workspace/../../nashaofu)) Set `save` dialog mime type from the `filters` extensions on Android. + +## \[2.0.1] + - [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. ### Dependencies @@ -288,3 +293,5 @@ pull/371)) First v2 alpha release! lpha release! pull/371)) First v2 alpha release! +lease! + pull/371)) First v2 alpha release! diff --git a/plugins/dialog/Cargo.toml b/plugins/dialog/Cargo.toml index eec855bd..4b6e88b1 100644 --- a/plugins/dialog/Cargo.toml +++ b/plugins/dialog/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tauri-plugin-dialog" -version = "2.0.1" +version = "2.0.2" description = "Native system dialogs for opening and saving files along with message dialogs on your Tauri application." edition = { workspace = true } authors = { workspace = true } @@ -34,7 +34,7 @@ tauri = { workspace = true } log = { workspace = true } thiserror = { workspace = true } url = { workspace = true } -tauri-plugin-fs = { path = "../fs", version = "2.0.1" } +tauri-plugin-fs = { path = "../fs", version = "2.0.2" } [target.'cfg(target_os = "ios")'.dependencies] tauri = { workspace = true, features = ["wry"] } diff --git a/plugins/dialog/package.json b/plugins/dialog/package.json index 72ebd27a..27814aed 100644 --- a/plugins/dialog/package.json +++ b/plugins/dialog/package.json @@ -1,6 +1,6 @@ { "name": "@tauri-apps/plugin-dialog", - "version": "2.0.0", + "version": "2.0.1", "license": "MIT OR Apache-2.0", "authors": [ "Tauri Programme within The Commons Conservancy" diff --git a/plugins/fs/CHANGELOG.md b/plugins/fs/CHANGELOG.md index 41e6411a..bf04cd1e 100644 --- a/plugins/fs/CHANGELOG.md +++ b/plugins/fs/CHANGELOG.md @@ -2,6 +2,10 @@ ## \[2.0.1] +- [`ae802456`](https://github.com/tauri-apps/plugins-workspace/commit/ae8024565f074f313084777c8b10d1b5e3bbe220) ([#1950](https://github.com/tauri-apps/plugins-workspace/pull/1950) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Improve performance of the `FileHandle.read` and `writeTextFile` APIs. + +## \[2.0.1] + - [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. ## \[2.0.0] diff --git a/plugins/fs/Cargo.toml b/plugins/fs/Cargo.toml index 1d9b5f34..17eba40a 100644 --- a/plugins/fs/Cargo.toml +++ b/plugins/fs/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tauri-plugin-fs" -version = "2.0.1" +version = "2.0.2" description = "Access the file system." authors = { workspace = true } license = { workspace = true } diff --git a/plugins/fs/package.json b/plugins/fs/package.json index 7a6cf527..0bce5c6c 100644 --- a/plugins/fs/package.json +++ b/plugins/fs/package.json @@ -1,6 +1,6 @@ { "name": "@tauri-apps/plugin-fs", - "version": "2.0.0", + "version": "2.0.1", "description": "Access the file system.", "license": "MIT OR Apache-2.0", "authors": [ diff --git a/plugins/http/CHANGELOG.md b/plugins/http/CHANGELOG.md index 508780fa..b08ac758 100644 --- a/plugins/http/CHANGELOG.md +++ b/plugins/http/CHANGELOG.md @@ -2,6 +2,11 @@ ## \[2.0.1] +- [`cfd48b3b`](https://github.com/tauri-apps/plugins-workspace/commit/cfd48b3b2ec0fccfc162197518694ed59ceda22c) ([#1941](https://github.com/tauri-apps/plugins-workspace/pull/1941) by [@Nipsuli](https://github.com/tauri-apps/plugins-workspace/../../Nipsuli)) Allow skipping sending `Origin` header in HTTP requests by setting `Origin` header to an empty string when calling `fetch`. +- [`9b2840db`](https://github.com/tauri-apps/plugins-workspace/commit/9b2840db9464cf08db75806270e4441f0af81e5d) ([#1884](https://github.com/tauri-apps/plugins-workspace/pull/1884) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Retain headers order. + +## \[2.0.1] + - [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. ### Dependencies @@ -286,3 +291,6 @@ ha release! ! 371\)) First v2 alpha release! +lease! + ! + 371\)) First v2 alpha release! diff --git a/plugins/http/Cargo.toml b/plugins/http/Cargo.toml index 64b9aa75..bd2359b2 100644 --- a/plugins/http/Cargo.toml +++ b/plugins/http/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tauri-plugin-http" -version = "2.0.1" +version = "2.0.2" description = "Access an HTTP client written in Rust." edition = { workspace = true } authors = { workspace = true } @@ -34,7 +34,7 @@ serde_json = { workspace = true } tauri = { workspace = true } thiserror = { workspace = true } tokio = { version = "1", features = ["sync", "macros"] } -tauri-plugin-fs = { path = "../fs", version = "2.0.1" } +tauri-plugin-fs = { path = "../fs", version = "2.0.2" } urlpattern = "0.3" regex = "1" http = "1" diff --git a/plugins/http/package.json b/plugins/http/package.json index 24fb27f7..493caf75 100644 --- a/plugins/http/package.json +++ b/plugins/http/package.json @@ -1,6 +1,6 @@ { "name": "@tauri-apps/plugin-http", - "version": "2.0.0", + "version": "2.0.1", "license": "MIT OR Apache-2.0", "authors": [ "Tauri Programme within The Commons Conservancy" diff --git a/plugins/persisted-scope/CHANGELOG.md b/plugins/persisted-scope/CHANGELOG.md index b27277fa..0684eac1 100644 --- a/plugins/persisted-scope/CHANGELOG.md +++ b/plugins/persisted-scope/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## \[2.0.2] + +### Dependencies + +- Upgraded to `fs@2.0.2` + ## \[2.0.1] - [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. diff --git a/plugins/persisted-scope/Cargo.toml b/plugins/persisted-scope/Cargo.toml index c03276d0..754eda37 100644 --- a/plugins/persisted-scope/Cargo.toml +++ b/plugins/persisted-scope/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tauri-plugin-persisted-scope" -version = "2.0.1" +version = "2.0.2" description = "Save filesystem and asset scopes and restore them when the app is reopened." authors = { workspace = true } license = { workspace = true } @@ -27,7 +27,7 @@ log = { workspace = true } thiserror = { workspace = true } aho-corasick = "1" bincode = "1" -tauri-plugin-fs = { path = "../fs", version = "2.0.1" } +tauri-plugin-fs = { path = "../fs", version = "2.0.2" } [features] protocol-asset = ["tauri/protocol-asset"] diff --git a/plugins/positioner/CHANGELOG.md b/plugins/positioner/CHANGELOG.md index ee4c473f..acbc2cda 100644 --- a/plugins/positioner/CHANGELOG.md +++ b/plugins/positioner/CHANGELOG.md @@ -2,6 +2,10 @@ ## \[2.0.1] +- [`3c1f3874`](https://github.com/tauri-apps/plugins-workspace/commit/3c1f3874f4c828637b3aa983cba13c77427faf58) ([#1911](https://github.com/tauri-apps/plugins-workspace/pull/1911) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Added missing permission for `handleIconState` and fixed its event processing logic. + +## \[2.0.1] + - [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. ## \[2.0.0] diff --git a/plugins/positioner/Cargo.toml b/plugins/positioner/Cargo.toml index 807d1ed9..2288999c 100644 --- a/plugins/positioner/Cargo.toml +++ b/plugins/positioner/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tauri-plugin-positioner" -version = "2.0.1" +version = "2.0.2" description = "Position your windows at well-known locations." authors = { workspace = true } license = { workspace = true } diff --git a/plugins/positioner/package.json b/plugins/positioner/package.json index faba11e2..b738a342 100644 --- a/plugins/positioner/package.json +++ b/plugins/positioner/package.json @@ -1,6 +1,6 @@ { "name": "@tauri-apps/plugin-positioner", - "version": "2.0.0", + "version": "2.0.1", "description": "Position your windows at well-known locations.", "license": "MIT OR Apache-2.0", "authors": [ diff --git a/plugins/shell/CHANGELOG.md b/plugins/shell/CHANGELOG.md index bcc894c8..a1cfc195 100644 --- a/plugins/shell/CHANGELOG.md +++ b/plugins/shell/CHANGELOG.md @@ -2,6 +2,10 @@ ## \[2.0.1] +- [`51ddf6a7`](https://github.com/tauri-apps/plugins-workspace/commit/51ddf6a71544acfb261ffc9393dab1342da0a219) ([#1881](https://github.com/tauri-apps/plugins-workspace/pull/1881) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) On Windows, Fix `open` JS API hanging and freezing the app. + +## \[2.0.1] + - [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. ## \[2.0.0] diff --git a/plugins/shell/Cargo.toml b/plugins/shell/Cargo.toml index 31c0cc97..d170cd46 100644 --- a/plugins/shell/Cargo.toml +++ b/plugins/shell/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tauri-plugin-shell" -version = "2.0.1" +version = "2.0.2" description = "Access the system shell. Allows you to spawn child processes and manage files and URLs using their default application." edition = { workspace = true } authors = { workspace = true } diff --git a/plugins/shell/package.json b/plugins/shell/package.json index 0975f8f9..abbc33ea 100644 --- a/plugins/shell/package.json +++ b/plugins/shell/package.json @@ -1,6 +1,6 @@ { "name": "@tauri-apps/plugin-shell", - "version": "2.0.0", + "version": "2.0.1", "license": "MIT OR Apache-2.0", "authors": [ "Tauri Programme within The Commons Conservancy" diff --git a/plugins/store/CHANGELOG.md b/plugins/store/CHANGELOG.md index 59d4b9b1..51ac5ed2 100644 --- a/plugins/store/CHANGELOG.md +++ b/plugins/store/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## \[2.1.0] + +### feat + +- [`8c67d44a`](https://github.com/tauri-apps/plugins-workspace/commit/8c67d44aef60b1427019538d8420787ef35bd3d5) ([#1860](https://github.com/tauri-apps/plugins-workspace/pull/1860) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) - Add `getStore` + - Add an option to use pre-stored (de)serialize functions (registered on rust) + - Add `LazyStore` + ## \[2.0.1] - [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. @@ -125,3 +133,11 @@ com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! plugins-workspace/pull/371)) First v2 alpha release! com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! +) First v2 alpha release! + com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! + eb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! + ps://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! + 717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! + com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! + plugins-workspace/pull/371)) First v2 alpha release! + com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! diff --git a/plugins/store/Cargo.toml b/plugins/store/Cargo.toml index d270b1f1..ff181ea4 100644 --- a/plugins/store/Cargo.toml +++ b/plugins/store/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tauri-plugin-store" -version = "2.0.1" +version = "2.1.0" description = "Simple, persistent key-value store." authors = { workspace = true } license = { workspace = true } diff --git a/plugins/store/package.json b/plugins/store/package.json index 034f8873..e310463c 100644 --- a/plugins/store/package.json +++ b/plugins/store/package.json @@ -1,6 +1,6 @@ { "name": "@tauri-apps/plugin-store", - "version": "2.0.0", + "version": "2.1.0", "description": "Simple, persistent key-value store.", "license": "MIT OR Apache-2.0", "authors": [ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5d1da82d..4abfcf4e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -73,10 +73,10 @@ importers: specifier: 2.0.0 version: link:../../plugins/clipboard-manager '@tauri-apps/plugin-dialog': - specifier: 2.0.0 + specifier: 2.0.1 version: link:../../plugins/dialog '@tauri-apps/plugin-fs': - specifier: 2.0.0 + specifier: 2.0.1 version: link:../../plugins/fs '@tauri-apps/plugin-geolocation': specifier: 2.0.0 @@ -88,7 +88,7 @@ importers: specifier: 2.0.0 version: link:../../plugins/haptics '@tauri-apps/plugin-http': - specifier: 2.0.0 + specifier: 2.0.1 version: link:../../plugins/http '@tauri-apps/plugin-nfc': specifier: 2.0.0 @@ -103,10 +103,10 @@ importers: specifier: 2.0.0 version: link:../../plugins/process '@tauri-apps/plugin-shell': - specifier: 2.0.0 + specifier: 2.0.1 version: link:../../plugins/shell '@tauri-apps/plugin-store': - specifier: 2.0.0 + specifier: 2.1.0 version: link:../../plugins/store '@tauri-apps/plugin-updater': specifier: 2.0.0 @@ -2334,9 +2334,9 @@ snapshots: - encoding - mocha - '@covector/assemble@0.12.0': + '@covector/assemble@0.12.0(mocha@10.7.3)': dependencies: - '@covector/command': 0.8.0 + '@covector/command': 0.8.0(mocha@10.7.3) '@covector/files': 0.8.0 effection: 2.0.8(mocha@10.7.3) js-yaml: 4.1.0 @@ -2347,9 +2347,10 @@ snapshots: unified: 9.2.2 transitivePeerDependencies: - encoding + - mocha - supports-color - '@covector/changelog@0.12.0': + '@covector/changelog@0.12.0(mocha@10.7.3)': dependencies: '@covector/files': 0.8.0 effection: 2.0.8(mocha@10.7.3) @@ -2359,14 +2360,16 @@ snapshots: unified: 9.2.2 transitivePeerDependencies: - encoding + - mocha - supports-color - '@covector/command@0.8.0': + '@covector/command@0.8.0(mocha@10.7.3)': dependencies: - '@effection/process': 2.1.4 + '@effection/process': 2.1.4(mocha@10.7.3) effection: 2.0.8(mocha@10.7.3) transitivePeerDependencies: - encoding + - mocha '@covector/files@0.8.0': dependencies: @@ -2413,10 +2416,8 @@ snapshots: dependencies: effection: 2.0.8(mocha@10.7.3) mocha: 10.7.3 - transitivePeerDependencies: - - encoding - '@effection/process@2.1.4': + '@effection/process@2.1.4(mocha@10.7.3)': dependencies: cross-spawn: 7.0.3 ctrlc-windows: 2.1.0 @@ -2424,6 +2425,7 @@ snapshots: shellwords: 0.1.1 transitivePeerDependencies: - encoding + - mocha '@effection/stream@2.0.6': dependencies: @@ -3234,9 +3236,9 @@ snapshots: dependencies: '@clack/prompts': 0.7.0 '@covector/apply': 0.10.0(mocha@10.7.3) - '@covector/assemble': 0.12.0 - '@covector/changelog': 0.12.0 - '@covector/command': 0.8.0 + '@covector/assemble': 0.12.0(mocha@10.7.3) + '@covector/changelog': 0.12.0(mocha@10.7.3) + '@covector/command': 0.8.0(mocha@10.7.3) '@covector/files': 0.8.0 effection: 2.0.8(mocha@10.7.3) globby: 11.1.0 From 14cee64c82a72655ae6a4ac0892736a2959dbda5 Mon Sep 17 00:00:00 2001 From: bWanShiTong <157274881+bWanShiTong@users.noreply.github.com> Date: Mon, 21 Oct 2024 14:07:55 +0200 Subject: [PATCH 12/13] fix(fs): fix compilation on targets with pointer width 16 and 32 (#1958) --- .changes/change-pr-1958.md | 5 +++++ plugins/fs/src/commands.rs | 2 ++ 2 files changed, 7 insertions(+) create mode 100644 .changes/change-pr-1958.md diff --git a/.changes/change-pr-1958.md b/.changes/change-pr-1958.md new file mode 100644 index 00000000..59f8fc8a --- /dev/null +++ b/.changes/change-pr-1958.md @@ -0,0 +1,5 @@ +--- +"fs": patch +--- + +Fix compilation on targets with pointer width of `16` or `32` diff --git a/plugins/fs/src/commands.rs b/plugins/fs/src/commands.rs index 58f2ce62..99eb5aa0 100644 --- a/plugins/fs/src/commands.rs +++ b/plugins/fs/src/commands.rs @@ -316,12 +316,14 @@ pub async fn read( let nread = nread.to_be_bytes(); let mut out = [0; 8]; out[6..].copy_from_slice(&nread); + out }; #[cfg(target_pointer_width = "32")] let nread = { let nread = nread.to_be_bytes(); let mut out = [0; 8]; out[4..].copy_from_slice(&nread); + out }; #[cfg(target_pointer_width = "64")] let nread = nread.to_be_bytes(); From 525abc4be552b80621b4af2b26d142e0c87b819e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 21 Oct 2024 15:13:27 +0300 Subject: [PATCH 13/13] Publish New Versions (v2) (#1961) Co-authored-by: amrbashir --- .changes/change-pr-1958.md | 5 ----- Cargo.lock | 10 +++++----- examples/api/src-tauri/CHANGELOG.md | 8 ++++++++ examples/api/src-tauri/Cargo.toml | 8 ++++---- plugins/dialog/CHANGELOG.md | 8 +++++++- plugins/dialog/Cargo.toml | 4 ++-- plugins/fs/CHANGELOG.md | 4 ++++ plugins/fs/Cargo.toml | 2 +- plugins/http/CHANGELOG.md | 8 +++++++- plugins/http/Cargo.toml | 4 ++-- plugins/persisted-scope/CHANGELOG.md | 6 ++++++ plugins/persisted-scope/Cargo.toml | 4 ++-- 12 files changed, 48 insertions(+), 23 deletions(-) delete mode 100644 .changes/change-pr-1958.md diff --git a/.changes/change-pr-1958.md b/.changes/change-pr-1958.md deleted file mode 100644 index 59f8fc8a..00000000 --- a/.changes/change-pr-1958.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"fs": patch ---- - -Fix compilation on targets with pointer width of `16` or `32` diff --git a/Cargo.lock b/Cargo.lock index 3aeae077..2522f63d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -218,7 +218,7 @@ checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" [[package]] name = "api" -version = "2.0.3" +version = "2.0.4" dependencies = [ "log", "serde", @@ -6825,7 +6825,7 @@ dependencies = [ [[package]] name = "tauri-plugin-dialog" -version = "2.0.2" +version = "2.0.3" dependencies = [ "log", "raw-window-handle", @@ -6841,7 +6841,7 @@ dependencies = [ [[package]] name = "tauri-plugin-fs" -version = "2.0.2" +version = "2.0.3" dependencies = [ "anyhow", "dunce", @@ -6901,7 +6901,7 @@ dependencies = [ [[package]] name = "tauri-plugin-http" -version = "2.0.2" +version = "2.0.3" dependencies = [ "data-url", "http", @@ -7005,7 +7005,7 @@ dependencies = [ [[package]] name = "tauri-plugin-persisted-scope" -version = "2.0.2" +version = "2.0.3" dependencies = [ "aho-corasick", "bincode", diff --git a/examples/api/src-tauri/CHANGELOG.md b/examples/api/src-tauri/CHANGELOG.md index c8070e63..b914893a 100644 --- a/examples/api/src-tauri/CHANGELOG.md +++ b/examples/api/src-tauri/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## \[2.0.4] + +### Dependencies + +- Upgraded to `fs@2.0.3` +- Upgraded to `dialog@2.0.3` +- Upgraded to `http@2.0.3` + ## \[2.0.3] ### Dependencies diff --git a/examples/api/src-tauri/Cargo.toml b/examples/api/src-tauri/Cargo.toml index b09e54a6..db6ec283 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.3" +version = "2.0.4" description = "An example Tauri Application showcasing the api" edition = "2021" rust-version = { workspace = true } @@ -20,14 +20,14 @@ serde = { workspace = true } tiny_http = "0.12" log = { workspace = true } tauri-plugin-log = { path = "../../../plugins/log", version = "2.0.1" } -tauri-plugin-fs = { path = "../../../plugins/fs", version = "2.0.2", features = [ +tauri-plugin-fs = { path = "../../../plugins/fs", version = "2.0.3", features = [ "watch", ] } tauri-plugin-clipboard-manager = { path = "../../../plugins/clipboard-manager", version = "2.0.1" } -tauri-plugin-dialog = { path = "../../../plugins/dialog", version = "2.0.2" } +tauri-plugin-dialog = { path = "../../../plugins/dialog", version = "2.0.3" } tauri-plugin-http = { path = "../../../plugins/http", features = [ "multipart", -], version = "2.0.2" } +], version = "2.0.3" } tauri-plugin-notification = { path = "../../../plugins/notification", version = "2.0.1", features = [ "windows7-compat", ] } diff --git a/plugins/dialog/CHANGELOG.md b/plugins/dialog/CHANGELOG.md index c124b2ff..57c51092 100644 --- a/plugins/dialog/CHANGELOG.md +++ b/plugins/dialog/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## \[2.0.3] + +### Dependencies + +- Upgraded to `fs@2.0.3` + ## \[2.0.1] - [`2302c2db`](https://github.com/tauri-apps/plugins-workspace/commit/2302c2db1c49673e61dcbda8cdb01b2c57e9ba6f) ([#1910](https://github.com/tauri-apps/plugins-workspace/pull/1910) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Fix `ask` and `confirm` not using system button texts @@ -293,5 +299,5 @@ pull/371)) First v2 alpha release! lpha release! pull/371)) First v2 alpha release! -lease! + lease! pull/371)) First v2 alpha release! diff --git a/plugins/dialog/Cargo.toml b/plugins/dialog/Cargo.toml index 4b6e88b1..664416a7 100644 --- a/plugins/dialog/Cargo.toml +++ b/plugins/dialog/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tauri-plugin-dialog" -version = "2.0.2" +version = "2.0.3" description = "Native system dialogs for opening and saving files along with message dialogs on your Tauri application." edition = { workspace = true } authors = { workspace = true } @@ -34,7 +34,7 @@ tauri = { workspace = true } log = { workspace = true } thiserror = { workspace = true } url = { workspace = true } -tauri-plugin-fs = { path = "../fs", version = "2.0.2" } +tauri-plugin-fs = { path = "../fs", version = "2.0.3" } [target.'cfg(target_os = "ios")'.dependencies] tauri = { workspace = true, features = ["wry"] } diff --git a/plugins/fs/CHANGELOG.md b/plugins/fs/CHANGELOG.md index bf04cd1e..707733ee 100644 --- a/plugins/fs/CHANGELOG.md +++ b/plugins/fs/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## \[2.0.3] + +- [`14cee64c`](https://github.com/tauri-apps/plugins-workspace/commit/14cee64c82a72655ae6a4ac0892736a2959dbda5) ([#1958](https://github.com/tauri-apps/plugins-workspace/pull/1958) by [@bWanShiTong](https://github.com/tauri-apps/plugins-workspace/../../bWanShiTong)) Fix compilation on targets with pointer width of `16` or `32` + ## \[2.0.1] - [`ae802456`](https://github.com/tauri-apps/plugins-workspace/commit/ae8024565f074f313084777c8b10d1b5e3bbe220) ([#1950](https://github.com/tauri-apps/plugins-workspace/pull/1950) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Improve performance of the `FileHandle.read` and `writeTextFile` APIs. diff --git a/plugins/fs/Cargo.toml b/plugins/fs/Cargo.toml index 17eba40a..cd4e7716 100644 --- a/plugins/fs/Cargo.toml +++ b/plugins/fs/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tauri-plugin-fs" -version = "2.0.2" +version = "2.0.3" description = "Access the file system." authors = { workspace = true } license = { workspace = true } diff --git a/plugins/http/CHANGELOG.md b/plugins/http/CHANGELOG.md index b08ac758..e814ddd9 100644 --- a/plugins/http/CHANGELOG.md +++ b/plugins/http/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## \[2.0.3] + +### Dependencies + +- Upgraded to `fs@2.0.3` + ## \[2.0.1] - [`cfd48b3b`](https://github.com/tauri-apps/plugins-workspace/commit/cfd48b3b2ec0fccfc162197518694ed59ceda22c) ([#1941](https://github.com/tauri-apps/plugins-workspace/pull/1941) by [@Nipsuli](https://github.com/tauri-apps/plugins-workspace/../../Nipsuli)) Allow skipping sending `Origin` header in HTTP requests by setting `Origin` header to an empty string when calling `fetch`. @@ -291,6 +297,6 @@ ha release! ! 371\)) First v2 alpha release! -lease! + lease! ! 371\)) First v2 alpha release! diff --git a/plugins/http/Cargo.toml b/plugins/http/Cargo.toml index bd2359b2..8c1801a3 100644 --- a/plugins/http/Cargo.toml +++ b/plugins/http/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tauri-plugin-http" -version = "2.0.2" +version = "2.0.3" description = "Access an HTTP client written in Rust." edition = { workspace = true } authors = { workspace = true } @@ -34,7 +34,7 @@ serde_json = { workspace = true } tauri = { workspace = true } thiserror = { workspace = true } tokio = { version = "1", features = ["sync", "macros"] } -tauri-plugin-fs = { path = "../fs", version = "2.0.2" } +tauri-plugin-fs = { path = "../fs", version = "2.0.3" } urlpattern = "0.3" regex = "1" http = "1" diff --git a/plugins/persisted-scope/CHANGELOG.md b/plugins/persisted-scope/CHANGELOG.md index 0684eac1..b2c1628c 100644 --- a/plugins/persisted-scope/CHANGELOG.md +++ b/plugins/persisted-scope/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## \[2.0.3] + +### Dependencies + +- Upgraded to `fs@2.0.3` + ## \[2.0.2] ### Dependencies diff --git a/plugins/persisted-scope/Cargo.toml b/plugins/persisted-scope/Cargo.toml index 754eda37..070cf21b 100644 --- a/plugins/persisted-scope/Cargo.toml +++ b/plugins/persisted-scope/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tauri-plugin-persisted-scope" -version = "2.0.2" +version = "2.0.3" description = "Save filesystem and asset scopes and restore them when the app is reopened." authors = { workspace = true } license = { workspace = true } @@ -27,7 +27,7 @@ log = { workspace = true } thiserror = { workspace = true } aho-corasick = "1" bincode = "1" -tauri-plugin-fs = { path = "../fs", version = "2.0.2" } +tauri-plugin-fs = { path = "../fs", version = "2.0.3" } [features] protocol-asset = ["tauri/protocol-asset"]