Merge branch 'dev' into fix/persisted-scope-memory-leak

pull/328/head
FabianLars 2 years ago
commit b6e5849a3d
No known key found for this signature in database
GPG Key ID: 3B12BC1DEBF61125

@ -38,9 +38,10 @@ fi
if [[ -z "$COMMIT_MESSAGE" ]]; then if [[ -z "$COMMIT_MESSAGE" ]]; then
MONOREPO_COMMIT_MESSAGE=$(cd "${SOURCE_DIR:-.}" && git show -s --format=%B $GITHUB_SHA) MONOREPO_COMMIT_MESSAGE=$(cd "${SOURCE_DIR:-.}" && git show -s --format=%B $GITHUB_SHA)
COMMIT_MESSAGE=$( printf "%s\n\nCommitted via a GitHub action: https://github.com/%s/actions/runs/%s\n" "$MONOREPO_COMMIT_MESSAGE" "$GITHUB_REPOSITORY" "$GITHUB_RUN_ID" ) COMMIT_MESSAGE=$( printf "%s\n\nCommitted via a GitHub action: https://github.com/%s/actions/runs/%s" "$MONOREPO_COMMIT_MESSAGE" "$GITHUB_REPOSITORY" "$GITHUB_RUN_ID" )
fi fi
COMMIT_ORIGINAL_AUTHOR="${GITHUB_ACTOR} <${GITHUB_ACTOR}@users.noreply.github.com>" COMMIT_ACTOR="${GITHUB_ACTOR} <${GITHUB_ACTOR}@users.noreply.github.com>"
COMMIT_AUTHOR=$(cd "${SOURCE_DIR:-.}" &&git show -s --format="%an <%ae>" $GITHUB_SHA)
if [[ "$GITHUB_REF" =~ ^refs/heads/ ]]; then if [[ "$GITHUB_REF" =~ ^refs/heads/ ]]; then
BRANCH=${GITHUB_REF#refs/heads/} BRANCH=${GITHUB_REF#refs/heads/}
@ -98,7 +99,8 @@ while read -r PLUGIN_NAME; do
if [[ -n "$FORCE_COMMIT" || -n "$(git status --porcelain)" ]]; then if [[ -n "$FORCE_COMMIT" || -n "$(git status --porcelain)" ]]; then
echo "Committing to $PLUGIN_NAME" echo "Committing to $PLUGIN_NAME"
if git commit $FORCE_COMMIT --author="${COMMIT_ORIGINAL_AUTHOR}" -m "${COMMIT_MESSAGE}" && GIT_CLI_COMMIT_MESSAGE=$( printf "%s \n\nCo-authored-by: %s" "$COMMIT_MESSAGE" "$COMMIT_ACTOR" )
if git commit $FORCE_COMMIT --author="${COMMIT_AUTHOR}" -m "${GIT_CLI_COMMIT_MESSAGE}" &&
{ [[ -z "$CI" ]] || git push origin "$BRANCH"; } # Only do the actual push from the GitHub Action { [[ -z "$CI" ]] || git push origin "$BRANCH"; } # Only do the actual push from the GitHub Action
then then
# echo "$BUILD_BASE/changes.diff" # echo "$BUILD_BASE/changes.diff"

@ -38,8 +38,9 @@ jobs:
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
node-version: 18 node-version: 18
- uses: pnpm/action-setup@v2.2.4 - uses: pnpm/action-setup@v2
with: with:
version: 7.x.x
run_install: true run_install: true
- name: audit - name: audit
run: pnpm audit run: pnpm audit

@ -28,6 +28,6 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions-rs/audit-check@v1 - uses: rustsec/audit-check@v1
with: with:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}

@ -41,8 +41,9 @@ jobs:
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
node-version: 18 node-version: 18
- uses: pnpm/action-setup@v2.2.4 - uses: pnpm/action-setup@v2
with: with:
version: 7.x.x
run_install: true run_install: true
- name: eslint - name: eslint
run: pnpm lint run: pnpm lint
@ -60,8 +61,9 @@ jobs:
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
node-version: 18 node-version: 18
- uses: pnpm/action-setup@v2.2.4 - uses: pnpm/action-setup@v2
with: with:
version: 7.x.x
run_install: true run_install: true
- name: prettier check - name: prettier check
run: pnpm format-check run: pnpm format-check

@ -5,18 +5,18 @@ on:
branches: branches:
- dev - dev
paths: paths:
- '.github/workflows/msrv-check.yml' - ".github/workflows/msrv-check.yml"
- 'plugins/*/src/**' - "plugins/*/src/**"
- '**/Cargo.toml' - "**/Cargo.toml"
- '**/Cargo.lock' - "**/Cargo.lock"
pull_request: pull_request:
branches: branches:
- dev - dev
paths: paths:
- '.github/workflows/msrv-check.yml' - ".github/workflows/msrv-check.yml"
- 'plugins/*/src/**' - "plugins/*/src/**"
- '**/Cargo.toml' - "**/Cargo.toml"
- '**/Cargo.lock' - "**/Cargo.lock"
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.ref }} group: ${{ github.workflow }}-${{ github.ref }}

@ -25,8 +25,9 @@ jobs:
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
node-version: 18 node-version: 18
- uses: pnpm/action-setup@v2.2.4 - uses: pnpm/action-setup@v2
with: with:
version: 7.x.x
run_install: true run_install: true
- name: Build packages - name: Build packages
run: pnpm build run: pnpm build

148
Cargo.lock generated

@ -201,7 +201,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c3d816ce6f0e2909a96830d6911c2aff044370b1ef92d7f267b43bae5addedd" checksum = "2c3d816ce6f0e2909a96830d6911c2aff044370b1ef92d7f267b43bae5addedd"
dependencies = [ dependencies = [
"atk-sys", "atk-sys",
"bitflags", "bitflags 1.3.2",
"glib", "glib",
"libc", "libc",
] ]
@ -244,7 +244,7 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08cee7a0952628fde958e149507c2bb321ab4fccfafd225da0b20adc956ef88a" checksum = "08cee7a0952628fde958e149507c2bb321ab4fccfafd225da0b20adc956ef88a"
dependencies = [ dependencies = [
"bitflags", "bitflags 1.3.2",
"core-foundation", "core-foundation",
"devd-rs", "devd-rs",
"libc", "libc",
@ -311,6 +311,12 @@ version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4f6e5df9abedba5099a01a6567c6086a6fbcff57af07c360d356737f9e0c644"
[[package]] [[package]]
name = "blake2" name = "blake2"
version = "0.10.6" version = "0.10.6"
@ -436,7 +442,7 @@ version = "0.15.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c76ee391b03d35510d9fa917357c7f1855bd9a6659c95a1b392e33f49b3369bc" checksum = "c76ee391b03d35510d9fa917357c7f1855bd9a6659c95a1b392e33f49b3369bc"
dependencies = [ dependencies = [
"bitflags", "bitflags 1.3.2",
"cairo-sys-rs", "cairo-sys-rs",
"glib", "glib",
"libc", "libc",
@ -561,7 +567,7 @@ version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f425db7937052c684daec3bd6375c8abe2d146dca4b8b143d6db777c39138f3a" checksum = "f425db7937052c684daec3bd6375c8abe2d146dca4b8b143d6db777c39138f3a"
dependencies = [ dependencies = [
"bitflags", "bitflags 1.3.2",
"block", "block",
"cocoa-foundation", "cocoa-foundation",
"core-foundation", "core-foundation",
@ -577,7 +583,7 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ade49b65d560ca58c403a479bb396592b155c0185eada742ee323d1d68d6318" checksum = "7ade49b65d560ca58c403a479bb396592b155c0185eada742ee323d1d68d6318"
dependencies = [ dependencies = [
"bitflags", "bitflags 1.3.2",
"block", "block",
"core-foundation", "core-foundation",
"core-graphics-types", "core-graphics-types",
@ -672,7 +678,7 @@ version = "0.22.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb" checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb"
dependencies = [ dependencies = [
"bitflags", "bitflags 1.3.2",
"core-foundation", "core-foundation",
"core-graphics-types", "core-graphics-types",
"foreign-types", "foreign-types",
@ -685,7 +691,7 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a68b68b3446082644c91ac778bf50cd4104bfb002b5a6a7c44cca5a2c70788b" checksum = "3a68b68b3446082644c91ac778bf50cd4104bfb002b5a6a7c44cca5a2c70788b"
dependencies = [ dependencies = [
"bitflags", "bitflags 1.3.2",
"core-foundation", "core-foundation",
"foreign-types", "foreign-types",
"libc", "libc",
@ -1360,7 +1366,7 @@ version = "0.15.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6e05c1f572ab0e1f15be94217f0dc29088c248b14f792a5ff0af0d84bcda9e8" checksum = "a6e05c1f572ab0e1f15be94217f0dc29088c248b14f792a5ff0af0d84bcda9e8"
dependencies = [ dependencies = [
"bitflags", "bitflags 1.3.2",
"cairo-rs", "cairo-rs",
"gdk-pixbuf", "gdk-pixbuf",
"gdk-sys", "gdk-sys",
@ -1376,7 +1382,7 @@ version = "0.15.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad38dd9cc8b099cceecdf41375bb6d481b1b5a7cd5cd603e10a69a9383f8619a" checksum = "ad38dd9cc8b099cceecdf41375bb6d481b1b5a7cd5cd603e10a69a9383f8619a"
dependencies = [ dependencies = [
"bitflags", "bitflags 1.3.2",
"gdk-pixbuf-sys", "gdk-pixbuf-sys",
"gio", "gio",
"glib", "glib",
@ -1489,7 +1495,7 @@ version = "0.15.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68fdbc90312d462781a395f7a16d96a2b379bb6ef8cd6310a2df272771c4283b" checksum = "68fdbc90312d462781a395f7a16d96a2b379bb6ef8cd6310a2df272771c4283b"
dependencies = [ dependencies = [
"bitflags", "bitflags 1.3.2",
"futures-channel", "futures-channel",
"futures-core", "futures-core",
"futures-io", "futures-io",
@ -1519,7 +1525,7 @@ version = "0.15.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edb0306fbad0ab5428b0ca674a23893db909a98582969c9b537be4ced78c505d" checksum = "edb0306fbad0ab5428b0ca674a23893db909a98582969c9b537be4ced78c505d"
dependencies = [ dependencies = [
"bitflags", "bitflags 1.3.2",
"futures-channel", "futures-channel",
"futures-core", "futures-core",
"futures-executor", "futures-executor",
@ -1595,7 +1601,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92e3004a2d5d6d8b5057d2b57b3712c9529b62e82c77f25c1fecde1fd5c23bd0" checksum = "92e3004a2d5d6d8b5057d2b57b3712c9529b62e82c77f25c1fecde1fd5c23bd0"
dependencies = [ dependencies = [
"atk", "atk",
"bitflags", "bitflags 1.3.2",
"cairo-rs", "cairo-rs",
"field-offset", "field-offset",
"futures-channel", "futures-channel",
@ -1937,7 +1943,7 @@ version = "0.9.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8069d3ec154eb856955c1c0fbffefbf5f3c40a104ec912d4797314c1801abff" checksum = "f8069d3ec154eb856955c1c0fbffefbf5f3c40a104ec912d4797314c1801abff"
dependencies = [ dependencies = [
"bitflags", "bitflags 1.3.2",
"inotify-sys", "inotify-sys",
"libc", "libc",
] ]
@ -1988,9 +1994,9 @@ dependencies = [
[[package]] [[package]]
name = "iota-crypto" name = "iota-crypto"
version = "0.16.0" version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d1d447f89ea13f2cd26d50195378bb2f76a0f9320ae4db3c0811b25fe6ed6c1" checksum = "ef4f42fc99281d9677950005223e2d0b122f5b08da6c92d91833017b279373db"
dependencies = [ dependencies = [
"autocfg", "autocfg",
] ]
@ -2055,7 +2061,7 @@ version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf053e7843f2812ff03ef5afe34bb9c06ffee120385caad4f6b9967fcd37d41c" checksum = "bf053e7843f2812ff03ef5afe34bb9c06ffee120385caad4f6b9967fcd37d41c"
dependencies = [ dependencies = [
"bitflags", "bitflags 1.3.2",
"glib", "glib",
"javascriptcore-rs-sys", "javascriptcore-rs-sys",
] ]
@ -2128,7 +2134,7 @@ version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8367585489f01bc55dd27404dcf56b95e6da061a256a666ab23be9ba96a2e587" checksum = "8367585489f01bc55dd27404dcf56b95e6da061a256a666ab23be9ba96a2e587"
dependencies = [ dependencies = [
"bitflags", "bitflags 1.3.2",
"libc", "libc",
] ]
@ -2420,7 +2426,7 @@ version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2032c77e030ddee34a6787a64166008da93f6a352b629261d0fee232b8742dd4" checksum = "2032c77e030ddee34a6787a64166008da93f6a352b629261d0fee232b8742dd4"
dependencies = [ dependencies = [
"bitflags", "bitflags 1.3.2",
"jni-sys", "jni-sys",
"ndk-sys", "ndk-sys",
"num_enum", "num_enum",
@ -2454,7 +2460,7 @@ version = "0.24.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069"
dependencies = [ dependencies = [
"bitflags", "bitflags 1.3.2",
"cfg-if", "cfg-if",
"libc", "libc",
"memoffset", "memoffset",
@ -2467,7 +2473,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4" checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"bitflags", "bitflags 1.3.2",
"cfg-if", "cfg-if",
"libc", "libc",
"memoffset", "memoffset",
@ -2505,7 +2511,7 @@ version = "5.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58ea850aa68a06e48fdb069c0ec44d0d64c8dbffa49bf3b6f7f0a901fdea1ba9" checksum = "58ea850aa68a06e48fdb069c0ec44d0d64c8dbffa49bf3b6f7f0a901fdea1ba9"
dependencies = [ dependencies = [
"bitflags", "bitflags 1.3.2",
"crossbeam-channel", "crossbeam-channel",
"filetime", "filetime",
"fsevent-sys", "fsevent-sys",
@ -2695,7 +2701,7 @@ version = "0.10.45"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1" checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1"
dependencies = [ dependencies = [
"bitflags", "bitflags 1.3.2",
"cfg-if", "cfg-if",
"foreign-types", "foreign-types",
"libc", "libc",
@ -2756,7 +2762,7 @@ version = "0.15.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22e4045548659aee5313bde6c582b0d83a627b7904dd20dc2d9ef0895d414e4f" checksum = "22e4045548659aee5313bde6c582b0d83a627b7904dd20dc2d9ef0895d414e4f"
dependencies = [ dependencies = [
"bitflags", "bitflags 1.3.2",
"glib", "glib",
"libc", "libc",
"once_cell", "once_cell",
@ -3047,7 +3053,7 @@ version = "0.17.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d708eaf860a19b19ce538740d2b4bdeeb8337fa53f7738455e706623ad5c638" checksum = "5d708eaf860a19b19ce538740d2b4bdeeb8337fa53f7738455e706623ad5c638"
dependencies = [ dependencies = [
"bitflags", "bitflags 1.3.2",
"crc32fast", "crc32fast",
"flate2", "flate2",
"miniz_oxide", "miniz_oxide",
@ -3282,7 +3288,7 @@ version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
dependencies = [ dependencies = [
"bitflags", "bitflags 1.3.2",
] ]
[[package]] [[package]]
@ -3544,7 +3550,7 @@ version = "2.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254" checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254"
dependencies = [ dependencies = [
"bitflags", "bitflags 1.3.2",
"core-foundation", "core-foundation",
"core-foundation-sys", "core-foundation-sys",
"libc", "libc",
@ -3567,7 +3573,7 @@ version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df320f1889ac4ba6bc0cdc9c9af7af4bd64bb927bccdf32d81140dc1f9be12fe" checksum = "df320f1889ac4ba6bc0cdc9c9af7af4bd64bb927bccdf32d81140dc1f9be12fe"
dependencies = [ dependencies = [
"bitflags", "bitflags 1.3.2",
"cssparser", "cssparser",
"derive_more", "derive_more",
"fxhash", "fxhash",
@ -3797,7 +3803,7 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2b4d76501d8ba387cf0fefbe055c3e0a59891d09f0f995ae4e4b16f6b60f3c0" checksum = "b2b4d76501d8ba387cf0fefbe055c3e0a59891d09f0f995ae4e4b16f6b60f3c0"
dependencies = [ dependencies = [
"bitflags", "bitflags 1.3.2",
"gio", "gio",
"glib", "glib",
"libc", "libc",
@ -3811,7 +3817,7 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "009ef427103fcb17f802871647a7fa6c60cbb654b4c4e4c0ac60a31c5f6dc9cf" checksum = "009ef427103fcb17f802871647a7fa6c60cbb654b4c4e4c0ac60a31c5f6dc9cf"
dependencies = [ dependencies = [
"bitflags", "bitflags 1.3.2",
"gio-sys", "gio-sys",
"glib-sys", "glib-sys",
"gobject-sys", "gobject-sys",
@ -3874,7 +3880,7 @@ dependencies = [
"ahash", "ahash",
"atoi", "atoi",
"base64 0.13.1", "base64 0.13.1",
"bitflags", "bitflags 1.3.2",
"byteorder", "byteorder",
"bytes 1.4.0", "bytes 1.4.0",
"crc", "crc",
@ -4139,7 +4145,7 @@ version = "0.15.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac8e6399427c8494f9849b58694754d7cc741293348a6836b6c8d2c5aa82d8e6" checksum = "ac8e6399427c8494f9849b58694754d7cc741293348a6836b6c8d2c5aa82d8e6"
dependencies = [ dependencies = [
"bitflags", "bitflags 1.3.2",
"cairo-rs", "cairo-rs",
"cc", "cc",
"cocoa", "cocoa",
@ -4281,7 +4287,7 @@ name = "tauri-plugin-authenticator"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"authenticator", "authenticator",
"base64 0.13.1", "base64 0.21.0",
"chrono", "chrono",
"log", "log",
"once_cell", "once_cell",
@ -4392,7 +4398,7 @@ dependencies = [
"serde_json", "serde_json",
"tauri", "tauri",
"thiserror", "thiserror",
"windows-sys 0.45.0", "windows-sys 0.48.0",
"zbus", "zbus",
] ]
@ -4427,7 +4433,7 @@ name = "tauri-plugin-stronghold"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"hex", "hex",
"iota-crypto 0.16.0", "iota-crypto 0.17.0",
"iota_stronghold", "iota_stronghold",
"log", "log",
"rand 0.8.5", "rand 0.8.5",
@ -4475,7 +4481,7 @@ name = "tauri-plugin-window-state"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"bincode", "bincode",
"bitflags", "bitflags 2.0.0",
"log", "log",
"serde", "serde",
"serde_json", "serde_json",
@ -5221,7 +5227,7 @@ version = "0.18.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8f859735e4a452aeb28c6c56a852967a8a76c8eb1cc32dbf931ad28a13d6370" checksum = "b8f859735e4a452aeb28c6c56a852967a8a76c8eb1cc32dbf931ad28a13d6370"
dependencies = [ dependencies = [
"bitflags", "bitflags 1.3.2",
"cairo-rs", "cairo-rs",
"gdk", "gdk",
"gdk-sys", "gdk-sys",
@ -5246,7 +5252,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d76ca6ecc47aeba01ec61e480139dda143796abcae6f83bcddf50d6b5b1dcf3" checksum = "4d76ca6ecc47aeba01ec61e480139dda143796abcae6f83bcddf50d6b5b1dcf3"
dependencies = [ dependencies = [
"atk-sys", "atk-sys",
"bitflags", "bitflags 1.3.2",
"cairo-sys-rs", "cairo-sys-rs",
"gdk-pixbuf-sys", "gdk-pixbuf-sys",
"gdk-sys", "gdk-sys",
@ -5428,37 +5434,37 @@ version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7"
dependencies = [ dependencies = [
"windows_aarch64_gnullvm", "windows_aarch64_gnullvm 0.42.1",
"windows_aarch64_msvc 0.42.1", "windows_aarch64_msvc 0.42.1",
"windows_i686_gnu 0.42.1", "windows_i686_gnu 0.42.1",
"windows_i686_msvc 0.42.1", "windows_i686_msvc 0.42.1",
"windows_x86_64_gnu 0.42.1", "windows_x86_64_gnu 0.42.1",
"windows_x86_64_gnullvm", "windows_x86_64_gnullvm 0.42.1",
"windows_x86_64_msvc 0.42.1", "windows_x86_64_msvc 0.42.1",
] ]
[[package]] [[package]]
name = "windows-sys" name = "windows-sys"
version = "0.45.0" version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
dependencies = [ dependencies = [
"windows-targets", "windows-targets",
] ]
[[package]] [[package]]
name = "windows-targets" name = "windows-targets"
version = "0.42.1" version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5"
dependencies = [ dependencies = [
"windows_aarch64_gnullvm", "windows_aarch64_gnullvm 0.48.0",
"windows_aarch64_msvc 0.42.1", "windows_aarch64_msvc 0.48.0",
"windows_i686_gnu 0.42.1", "windows_i686_gnu 0.48.0",
"windows_i686_msvc 0.42.1", "windows_i686_msvc 0.48.0",
"windows_x86_64_gnu 0.42.1", "windows_x86_64_gnu 0.48.0",
"windows_x86_64_gnullvm", "windows_x86_64_gnullvm 0.48.0",
"windows_x86_64_msvc 0.42.1", "windows_x86_64_msvc 0.48.0",
] ]
[[package]] [[package]]
@ -5473,6 +5479,12 @@ version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608"
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc"
[[package]] [[package]]
name = "windows_aarch64_msvc" name = "windows_aarch64_msvc"
version = "0.36.1" version = "0.36.1"
@ -5491,6 +5503,12 @@ version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7"
[[package]]
name = "windows_aarch64_msvc"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3"
[[package]] [[package]]
name = "windows_i686_gnu" name = "windows_i686_gnu"
version = "0.36.1" version = "0.36.1"
@ -5509,6 +5527,12 @@ version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640"
[[package]]
name = "windows_i686_gnu"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241"
[[package]] [[package]]
name = "windows_i686_msvc" name = "windows_i686_msvc"
version = "0.36.1" version = "0.36.1"
@ -5527,6 +5551,12 @@ version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605"
[[package]]
name = "windows_i686_msvc"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00"
[[package]] [[package]]
name = "windows_x86_64_gnu" name = "windows_x86_64_gnu"
version = "0.36.1" version = "0.36.1"
@ -5545,12 +5575,24 @@ version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45"
[[package]]
name = "windows_x86_64_gnu"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1"
[[package]] [[package]]
name = "windows_x86_64_gnullvm" name = "windows_x86_64_gnullvm"
version = "0.42.1" version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953"
[[package]] [[package]]
name = "windows_x86_64_msvc" name = "windows_x86_64_msvc"
version = "0.36.1" version = "0.36.1"
@ -5569,6 +5611,12 @@ version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd"
[[package]]
name = "windows_x86_64_msvc"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
[[package]] [[package]]
name = "winreg" name = "winreg"
version = "0.10.1" version = "0.10.1"

@ -10,20 +10,22 @@
"format-check": "prettier --check ." "format-check": "prettier --check ."
}, },
"devDependencies": { "devDependencies": {
"@rollup/plugin-node-resolve": "^15.0.1", "@rollup/plugin-node-resolve": "^15.0.2",
"@rollup/plugin-terser": "^0.4.0", "@rollup/plugin-terser": "^0.4.1",
"@rollup/plugin-typescript": "^11.0.0", "@rollup/plugin-typescript": "^11.1.0",
"@typescript-eslint/eslint-plugin": "^5.0.0", "@typescript-eslint/eslint-plugin": "^5.58.0",
"@typescript-eslint/parser": "^5.46.1", "@typescript-eslint/parser": "^5.58.0",
"eslint": "^8.0.1", "eslint": "^8.38.0",
"eslint-config-prettier": "^8.5.0", "eslint-config-prettier": "^8.8.0",
"eslint-config-standard-with-typescript": "^34.0.0", "eslint-config-standard-with-typescript": "^34.0.1",
"eslint-plugin-import": "^2.25.2", "eslint-plugin-import": "^2.27.5",
"eslint-plugin-n": "^15.0.0", "eslint-plugin-n": "^15.7.0",
"eslint-plugin-promise": "^6.0.0", "eslint-plugin-promise": "^6.1.1",
"prettier": "^2.8.1", "prettier": "^2.8.7",
"rollup": "^3.7.4", "rollup": "^3.20.4",
"typescript": "^4.9.4" "typescript": "^5.0.4"
}, },
"packageManager": "pnpm@7.18.1" "engines": {
"pnpm": ">=7.24.2"
}
} }

@ -18,7 +18,7 @@ thiserror.workspace = true
authenticator = "0.3.1" authenticator = "0.3.1"
once_cell = "1" once_cell = "1"
sha2 = "0.10" sha2 = "0.10"
base64 = { version = "^0.13" } base64 = "0.21"
u2f = "0.2" u2f = "0.2"
chrono = "0.4" chrono = "0.4"

@ -25,7 +25,7 @@
"LICENSE" "LICENSE"
], ],
"devDependencies": { "devDependencies": {
"tslib": "^2.4.1" "tslib": "^2.5.0"
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "^1.2.0" "@tauri-apps/api": "^1.2.0"

@ -6,7 +6,7 @@ use authenticator::{
authenticatorservice::AuthenticatorService, statecallback::StateCallback, authenticatorservice::AuthenticatorService, statecallback::StateCallback,
AuthenticatorTransports, KeyHandle, RegisterFlags, SignFlags, StatusUpdate, AuthenticatorTransports, KeyHandle, RegisterFlags, SignFlags, StatusUpdate,
}; };
use base64::{decode_config, encode_config, URL_SAFE_NO_PAD}; use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine};
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use serde::Serialize; use serde::Serialize;
use sha2::{Digest, Sha256}; use sha2::{Digest, Sha256};
@ -75,9 +75,9 @@ pub fn register(application: String, timeout: u64, challenge: String) -> crate::
let (key_handle, public_key) = let (key_handle, public_key) =
_u2f_get_key_handle_and_public_key_from_register_response(&register_data).unwrap(); _u2f_get_key_handle_and_public_key_from_register_response(&register_data).unwrap();
let key_handle_base64 = encode_config(key_handle, URL_SAFE_NO_PAD); let key_handle_base64 = URL_SAFE_NO_PAD.encode(key_handle);
let public_key_base64 = encode_config(public_key, URL_SAFE_NO_PAD); let public_key_base64 = URL_SAFE_NO_PAD.encode(public_key);
let register_data_base64 = encode_config(&register_data, URL_SAFE_NO_PAD); let register_data_base64 = URL_SAFE_NO_PAD.encode(&register_data);
println!("Key Handle: {}", &key_handle_base64); println!("Key Handle: {}", &key_handle_base64);
println!("Public Key: {}", &public_key_base64); println!("Public Key: {}", &public_key_base64);
@ -108,7 +108,7 @@ pub fn sign(
challenge: String, challenge: String,
key_handle: String, key_handle: String,
) -> crate::Result<String> { ) -> crate::Result<String> {
let credential = match decode_config(key_handle, URL_SAFE_NO_PAD) { let credential = match URL_SAFE_NO_PAD.decode(key_handle) {
Ok(v) => v, Ok(v) => v,
Err(e) => { Err(e) => {
return Err(e.into()); return Err(e.into());
@ -152,19 +152,16 @@ pub fn sign(
let (_, handle_used, sign_data, device_info) = sign_result.unwrap(); let (_, handle_used, sign_data, device_info) = sign_result.unwrap();
let sig = encode_config(sign_data, URL_SAFE_NO_PAD); let sig = URL_SAFE_NO_PAD.encode(sign_data);
println!("Sign result: {sig}"); println!("Sign result: {sig}");
println!( println!("Key handle used: {}", URL_SAFE_NO_PAD.encode(&handle_used));
"Key handle used: {}",
encode_config(&handle_used, URL_SAFE_NO_PAD)
);
println!("Device info: {}", &device_info); println!("Device info: {}", &device_info);
println!("Done."); println!("Done.");
let res = serde_json::to_string(&Signature { let res = serde_json::to_string(&Signature {
sign_data: sig, sign_data: sig,
key_handle: encode_config(&handle_used, URL_SAFE_NO_PAD), key_handle: URL_SAFE_NO_PAD.encode(&handle_used),
})?; })?;
Ok(res) Ok(res)
} }

@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
use base64::{decode_config, encode_config, URL_SAFE_NO_PAD}; use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine};
use chrono::prelude::*; use chrono::prelude::*;
use serde::Serialize; use serde::Serialize;
use std::convert::Into; use std::convert::Into;
@ -15,7 +15,7 @@ static VERSION: &str = "U2F_V2";
pub fn make_challenge(app_id: &str, challenge_bytes: Vec<u8>) -> Challenge { pub fn make_challenge(app_id: &str, challenge_bytes: Vec<u8>) -> Challenge {
let utc: DateTime<Utc> = Utc::now(); let utc: DateTime<Utc> = Utc::now();
Challenge { Challenge {
challenge: encode_config(challenge_bytes, URL_SAFE_NO_PAD), challenge: URL_SAFE_NO_PAD.encode(challenge_bytes),
timestamp: format!("{utc:?}"), timestamp: format!("{utc:?}"),
app_id: app_id.to_string(), app_id: app_id.to_string(),
} }
@ -35,10 +35,10 @@ pub fn verify_registration(
register_data: String, register_data: String,
client_data: String, client_data: String,
) -> crate::Result<String> { ) -> crate::Result<String> {
let challenge_bytes = decode_config(challenge, URL_SAFE_NO_PAD)?; let challenge_bytes = URL_SAFE_NO_PAD.decode(challenge)?;
let challenge = make_challenge(&app_id, challenge_bytes); let challenge = make_challenge(&app_id, challenge_bytes);
let client_data_bytes: Vec<u8> = client_data.as_bytes().into(); let client_data_bytes: Vec<u8> = client_data.as_bytes().into();
let client_data_base64 = encode_config(client_data_bytes, URL_SAFE_NO_PAD); let client_data_base64 = URL_SAFE_NO_PAD.encode(client_data_bytes);
let client = U2f::new(app_id); let client = U2f::new(app_id);
match client.register_response( match client.register_response(
challenge, challenge,
@ -50,8 +50,8 @@ pub fn verify_registration(
) { ) {
Ok(v) => { Ok(v) => {
let rv = RegistrationVerification { let rv = RegistrationVerification {
key_handle: encode_config(&v.key_handle, URL_SAFE_NO_PAD), key_handle: URL_SAFE_NO_PAD.encode(&v.key_handle),
pubkey: encode_config(&v.pub_key, URL_SAFE_NO_PAD), pubkey: URL_SAFE_NO_PAD.encode(&v.pub_key),
device_name: v.device_name, device_name: v.device_name,
}; };
Ok(serde_json::to_string(&rv)?) Ok(serde_json::to_string(&rv)?)
@ -74,12 +74,12 @@ pub fn verify_signature(
key_handle: String, key_handle: String,
pub_key: String, pub_key: String,
) -> crate::Result<u32> { ) -> crate::Result<u32> {
let challenge_bytes = decode_config(challenge, URL_SAFE_NO_PAD)?; let challenge_bytes = URL_SAFE_NO_PAD.decode(challenge)?;
let chal = make_challenge(&app_id, challenge_bytes); let chal = make_challenge(&app_id, challenge_bytes);
let client_data_bytes: Vec<u8> = client_data.as_bytes().into(); let client_data_bytes: Vec<u8> = client_data.as_bytes().into();
let client_data_base64 = encode_config(client_data_bytes, URL_SAFE_NO_PAD); let client_data_base64 = URL_SAFE_NO_PAD.encode(client_data_bytes);
let key_handle_bytes = decode_config(&key_handle, URL_SAFE_NO_PAD)?; let key_handle_bytes = URL_SAFE_NO_PAD.decode(&key_handle)?;
let pubkey_bytes = decode_config(pub_key, URL_SAFE_NO_PAD)?; let pubkey_bytes = URL_SAFE_NO_PAD.decode(pub_key)?;
let client = U2f::new(app_id); let client = U2f::new(app_id);
let mut _counter: u32 = 0; let mut _counter: u32 = 0;
match client.sign_response( match client.sign_response(

@ -24,7 +24,7 @@
"LICENSE" "LICENSE"
], ],
"devDependencies": { "devDependencies": {
"tslib": "^2.4.1" "tslib": "^2.5.0"
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "^1.2.0" "@tauri-apps/api": "^1.2.0"

@ -25,7 +25,7 @@
"LICENSE" "LICENSE"
], ],
"devDependencies": { "devDependencies": {
"tslib": "^2.4.1" "tslib": "^2.5.0"
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "^1.2.0" "@tauri-apps/api": "^1.2.0"

@ -25,7 +25,7 @@
"LICENSE" "LICENSE"
], ],
"devDependencies": { "devDependencies": {
"tslib": "^2.4.1" "tslib": "^2.5.0"
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "^1.2.0" "@tauri-apps/api": "^1.2.0"

@ -25,7 +25,7 @@
"LICENSE" "LICENSE"
], ],
"devDependencies": { "devDependencies": {
"tslib": "^2.4.1" "tslib": "^2.5.0"
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "^1.2.0" "@tauri-apps/api": "^1.2.0"

@ -25,7 +25,7 @@
"LICENSE" "LICENSE"
], ],
"devDependencies": { "devDependencies": {
"tslib": "^2.4.1" "tslib": "^2.5.0"
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "^1.2.0" "@tauri-apps/api": "^1.2.0"

@ -18,7 +18,7 @@ log.workspace = true
thiserror.workspace = true thiserror.workspace = true
[target.'cfg(target_os = "windows")'.dependencies.windows-sys] [target.'cfg(target_os = "windows")'.dependencies.windows-sys]
version = "0.45" version = "0.48"
features = [ features = [
"Win32_System_Threading", "Win32_System_Threading",
"Win32_System_DataExchange", "Win32_System_DataExchange",

@ -8,7 +8,7 @@
}, },
"author": "", "author": "",
"license": "MIT", "license": "MIT",
"dependencies": { "devDependencies": {
"@tauri-apps/cli": "^1.0.0" "@tauri-apps/cli": "^1.2.3"
} }
} }

@ -25,7 +25,7 @@
"LICENSE" "LICENSE"
], ],
"devDependencies": { "devDependencies": {
"tslib": "^2.4.1" "tslib": "^2.5.0"
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "^1.2.0" "@tauri-apps/api": "^1.2.0"

@ -210,7 +210,9 @@ async fn execute(
let db = instances.get_mut(&db).ok_or(Error::DatabaseNotLoaded(db))?; let db = instances.get_mut(&db).ok_or(Error::DatabaseNotLoaded(db))?;
let mut query = sqlx::query(&query); let mut query = sqlx::query(&query);
for value in values { for value in values {
if value.is_string() { if value.is_null() {
query = query.bind(None::<JsonValue>);
} else if value.is_string() {
query = query.bind(value.as_str().unwrap().to_owned()) query = query.bind(value.as_str().unwrap().to_owned())
} else { } else {
query = query.bind(value); query = query.bind(value);
@ -237,7 +239,9 @@ async fn select(
let db = instances.get_mut(&db).ok_or(Error::DatabaseNotLoaded(db))?; let db = instances.get_mut(&db).ok_or(Error::DatabaseNotLoaded(db))?;
let mut query = sqlx::query(&query); let mut query = sqlx::query(&query);
for value in values { for value in values {
if value.is_string() { if value.is_null() {
query = query.bind(None::<JsonValue>);
} else if value.is_string() {
query = query.bind(value.as_str().unwrap().to_owned()) query = query.bind(value.as_str().unwrap().to_owned())
} else { } else {
query = query.bind(value); query = query.bind(value);

@ -64,7 +64,9 @@ await store.save(); // this manually saves the store, otherwise the store is onl
``` ```
### Persisting values ### Persisting values
Values added to the store are not persisted between application loads unless: Values added to the store are not persisted between application loads unless:
1. The application is closed gracefully (plugin automatically saves) 1. The application is closed gracefully (plugin automatically saves)
2. The store is manually saved (using `store.save()`) 2. The store is manually saved (using `store.save()`)
@ -73,7 +75,7 @@ Values added to the store are not persisted between application loads unless:
You can also access Stores from Rust, you can create new stores: You can also access Stores from Rust, you can create new stores:
```rust ```rust
use tauri_plugin_store::store::StoreBuilder; use tauri_plugin_store::StoreBuilder;
use serde_json::json; use serde_json::json;
fn main() { fn main() {

@ -3,8 +3,7 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
import { invoke } from "@tauri-apps/api/tauri"; import { invoke } from "@tauri-apps/api/tauri";
import { UnlistenFn } from "@tauri-apps/api/event"; import { listen, UnlistenFn } from "@tauri-apps/api/event";
import { appWindow } from "@tauri-apps/api/window";
interface ChangePayload<T> { interface ChangePayload<T> {
path: string; path: string;
@ -180,14 +179,11 @@ export class Store {
key: string, key: string,
cb: (value: T | null) => void cb: (value: T | null) => void
): Promise<UnlistenFn> { ): Promise<UnlistenFn> {
return await appWindow.listen<ChangePayload<T>>( return await listen<ChangePayload<T>>("store://change", (event) => {
"store://change",
(event) => {
if (event.payload.path === this.path && event.payload.key === key) { if (event.payload.path === this.path && event.payload.key === key) {
cb(event.payload.value); cb(event.payload.value);
} }
} });
);
} }
/** /**
@ -198,13 +194,10 @@ export class Store {
async onChange<T>( async onChange<T>(
cb: (key: string, value: T | null) => void cb: (key: string, value: T | null) => void
): Promise<UnlistenFn> { ): Promise<UnlistenFn> {
return await appWindow.listen<ChangePayload<T>>( return await listen<ChangePayload<T>>("store://change", (event) => {
"store://change",
(event) => {
if (event.payload.path === this.path) { if (event.payload.path === this.path) {
cb(event.payload.key, event.payload.value); cb(event.payload.key, event.payload.value);
} }
} });
);
} }
} }

@ -25,7 +25,7 @@
"LICENSE" "LICENSE"
], ],
"devDependencies": { "devDependencies": {
"tslib": "^2.4.1" "tslib": "^2.5.0"
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "^1.2.0" "@tauri-apps/api": "^1.2.0"

@ -185,7 +185,8 @@ impl<R: Runtime> Store<R> {
let bytes = read(store_path)?; let bytes = read(store_path)?;
self.cache = (self.deserialize)(&bytes).map_err(Error::Deserialize)?; self.cache
.extend((self.deserialize)(&bytes).map_err(Error::Deserialize)?);
Ok(()) Ok(())
} }

@ -16,7 +16,7 @@ tauri.workspace = true
log.workspace = true log.workspace = true
thiserror.workspace = true thiserror.workspace = true
iota_stronghold = "1" iota_stronghold = "1"
iota-crypto = "0.16" iota-crypto = "0.17"
hex = "0.4" hex = "0.4"
zeroize = { version = "1", features = ["zeroize_derive"] } zeroize = { version = "1", features = ["zeroize_derive"] }

@ -25,7 +25,7 @@
"LICENSE" "LICENSE"
], ],
"devDependencies": { "devDependencies": {
"tslib": "^2.4.1" "tslib": "^2.5.0"
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "^1.2.0" "@tauri-apps/api": "^1.2.0"

@ -25,7 +25,7 @@
"LICENSE" "LICENSE"
], ],
"devDependencies": { "devDependencies": {
"tslib": "^2.4.1" "tslib": "^2.5.0"
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "^1.2.0" "@tauri-apps/api": "^1.2.0"

@ -11,16 +11,16 @@
"tauri": "tauri" "tauri": "tauri"
}, },
"devDependencies": { "devDependencies": {
"@sveltejs/adapter-auto": "^1.0.0", "@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/kit": "^1.0.0", "@sveltejs/kit": "^1.15.5",
"svelte": "^3.54.0", "@tauri-apps/cli": "^1.2.3",
"svelte-check": "^2.9.2", "svelte": "^3.58.0",
"tslib": "^2.4.1", "svelte-check": "^3.2.0",
"typescript": "^4.9.3", "tslib": "^2.5.0",
"vite": "^4.0.0" "typescript": "^5.0.4",
"vite": "^4.2.1"
}, },
"dependencies": { "dependencies": {
"@tauri-apps/cli": "^1.0.0",
"tauri-plugin-websocket-api": "link:../../" "tauri-plugin-websocket-api": "link:../../"
}, },
"type": "module" "type": "module"

@ -49,7 +49,7 @@ dependencies = [
"tauri-build", "tauri-build",
"tauri-plugin-websocket", "tauri-plugin-websocket",
"tokio", "tokio",
"tokio-tungstenite 0.15.0", "tokio-tungstenite",
] ]
[[package]] [[package]]
@ -78,9 +78,9 @@ dependencies = [
[[package]] [[package]]
name = "autocfg" name = "autocfg"
version = "1.0.1" version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]] [[package]]
name = "base64" name = "base64"
@ -100,15 +100,6 @@ version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
[[package]]
name = "block-buffer"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4"
dependencies = [
"generic-array",
]
[[package]] [[package]]
name = "block-buffer" name = "block-buffer"
version = "0.10.2" version = "0.10.2"
@ -331,15 +322,6 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "cpufeatures"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66c99696f6c9dd7f35d486b9d04d7e6e202aa3e8c40d553f2fdf5e7e0c6a71ef"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "cpufeatures" name = "cpufeatures"
version = "0.2.1" version = "0.2.1"
@ -490,22 +472,13 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "digest"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066"
dependencies = [
"generic-array",
]
[[package]] [[package]]
name = "digest" name = "digest"
version = "0.10.6" version = "0.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f"
dependencies = [ dependencies = [
"block-buffer 0.10.2", "block-buffer",
"crypto-common", "crypto-common",
] ]
@ -1411,7 +1384,7 @@ dependencies = [
"libc", "libc",
"log", "log",
"wasi 0.11.0+wasi-snapshot-preview1", "wasi 0.11.0+wasi-snapshot-preview1",
"windows-sys", "windows-sys 0.42.0",
] ]
[[package]] [[package]]
@ -1568,12 +1541,6 @@ version = "1.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66"
[[package]]
name = "opaque-debug"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
[[package]] [[package]]
name = "openssl" name = "openssl"
version = "0.10.35" version = "0.10.35"
@ -1658,7 +1625,7 @@ dependencies = [
"libc", "libc",
"redox_syscall", "redox_syscall",
"smallvec", "smallvec",
"windows-sys", "windows-sys 0.42.0",
] ]
[[package]] [[package]]
@ -1780,26 +1747,6 @@ dependencies = [
"siphasher", "siphasher",
] ]
[[package]]
name = "pin-project"
version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "576bc800220cc65dac09e99e97b08b358cfab6e17078de8dc5fee223bd2d0c08"
dependencies = [
"pin-project-internal",
]
[[package]]
name = "pin-project-internal"
version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e8fe8163d14ce7f0cdac2e040116f22eac817edabff0be91e8aff7e9accf389"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "pin-project-lite" name = "pin-project-lite"
version = "0.2.7" version = "0.2.7"
@ -2290,19 +2237,6 @@ dependencies = [
"stable_deref_trait", "stable_deref_trait",
] ]
[[package]]
name = "sha-1"
version = "0.9.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a0c8611594e2ab4ebbf06ec7cbbf0a99450b8570e96cbf5188b5d5f6ef18d81"
dependencies = [
"block-buffer 0.9.0",
"cfg-if",
"cpufeatures 0.1.5",
"digest 0.9.0",
"opaque-debug",
]
[[package]] [[package]]
name = "sha1" name = "sha1"
version = "0.10.5" version = "0.10.5"
@ -2310,8 +2244,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"cpufeatures 0.2.1", "cpufeatures",
"digest 0.10.6", "digest",
] ]
[[package]] [[package]]
@ -2321,8 +2255,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99c3bd8169c58782adad9290a9af5939994036b76187f7b4f0e6de91dbbfc0ec" checksum = "99c3bd8169c58782adad9290a9af5939994036b76187f7b4f0e6de91dbbfc0ec"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"cpufeatures 0.2.1", "cpufeatures",
"digest 0.10.6", "digest",
] ]
[[package]] [[package]]
@ -2345,9 +2279,9 @@ checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
[[package]] [[package]]
name = "socket2" name = "socket2"
version = "0.4.7" version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662"
dependencies = [ dependencies = [
"libc", "libc",
"winapi", "winapi",
@ -2633,7 +2567,7 @@ dependencies = [
"tauri", "tauri",
"thiserror", "thiserror",
"tokio", "tokio",
"tokio-tungstenite 0.18.0", "tokio-tungstenite",
] ]
[[package]] [[package]]
@ -2808,19 +2742,18 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.19.2" version = "1.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c51a52ed6686dd62c320f9b89299e9dfb46f730c7a48e635c19f21d116cb1439" checksum = "d0de47a4eecbe11f498978a9b29d792f0d2692d1dd003650c24c76510e3bc001"
dependencies = [ dependencies = [
"autocfg",
"bytes", "bytes",
"libc", "libc",
"memchr",
"mio", "mio",
"num_cpus", "num_cpus",
"once_cell",
"pin-project-lite", "pin-project-lite",
"socket2", "socket2",
"winapi", "windows-sys 0.45.0",
] ]
[[package]] [[package]]
@ -2833,19 +2766,6 @@ dependencies = [
"tokio", "tokio",
] ]
[[package]]
name = "tokio-tungstenite"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "511de3f85caf1c98983545490c3d09685fa8eb634e57eec22bb4db271f46cbd8"
dependencies = [
"futures-util",
"log",
"pin-project",
"tokio",
"tungstenite 0.14.0",
]
[[package]] [[package]]
name = "tokio-tungstenite" name = "tokio-tungstenite"
version = "0.18.0" version = "0.18.0"
@ -2857,7 +2777,7 @@ dependencies = [
"native-tls", "native-tls",
"tokio", "tokio",
"tokio-native-tls", "tokio-native-tls",
"tungstenite 0.18.0", "tungstenite",
] ]
[[package]] [[package]]
@ -2878,25 +2798,6 @@ dependencies = [
"serde_json", "serde_json",
] ]
[[package]]
name = "tungstenite"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0b2d8558abd2e276b0a8df5c05a2ec762609344191e5fd23e292c910e9165b5"
dependencies = [
"base64",
"byteorder",
"bytes",
"http",
"httparse",
"log",
"rand 0.8.4",
"sha-1",
"thiserror",
"url",
"utf-8",
]
[[package]] [[package]]
name = "tungstenite" name = "tungstenite"
version = "0.18.0" version = "0.18.0"
@ -3238,12 +3139,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7"
dependencies = [ dependencies = [
"windows_aarch64_gnullvm", "windows_aarch64_gnullvm",
"windows_aarch64_msvc 0.42.0", "windows_aarch64_msvc 0.42.2",
"windows_i686_gnu 0.42.0", "windows_i686_gnu 0.42.2",
"windows_i686_msvc 0.42.0", "windows_i686_msvc 0.42.2",
"windows_x86_64_gnu 0.42.0", "windows_x86_64_gnu 0.42.2",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc 0.42.2",
]
[[package]]
name = "windows-sys"
version = "0.45.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc 0.42.2",
"windows_i686_gnu 0.42.2",
"windows_i686_msvc 0.42.2",
"windows_x86_64_gnu 0.42.2",
"windows_x86_64_gnullvm", "windows_x86_64_gnullvm",
"windows_x86_64_msvc 0.42.0", "windows_x86_64_msvc 0.42.2",
] ]
[[package]] [[package]]
@ -3260,9 +3185,9 @@ checksum = "f838de2fe15fe6bac988e74b798f26499a8b21a9d97edec321e79b28d1d7f597"
[[package]] [[package]]
name = "windows_aarch64_gnullvm" name = "windows_aarch64_gnullvm"
version = "0.42.0" version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
[[package]] [[package]]
name = "windows_aarch64_msvc" name = "windows_aarch64_msvc"
@ -3278,9 +3203,9 @@ checksum = "ec7711666096bd4096ffa835238905bb33fb87267910e154b18b44eaabb340f2"
[[package]] [[package]]
name = "windows_aarch64_msvc" name = "windows_aarch64_msvc"
version = "0.42.0" version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
[[package]] [[package]]
name = "windows_i686_gnu" name = "windows_i686_gnu"
@ -3296,9 +3221,9 @@ checksum = "763fc57100a5f7042e3057e7e8d9bdd7860d330070251a73d003563a3bb49e1b"
[[package]] [[package]]
name = "windows_i686_gnu" name = "windows_i686_gnu"
version = "0.42.0" version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
[[package]] [[package]]
name = "windows_i686_msvc" name = "windows_i686_msvc"
@ -3314,9 +3239,9 @@ checksum = "7bc7cbfe58828921e10a9f446fcaaf649204dcfe6c1ddd712c5eebae6bda1106"
[[package]] [[package]]
name = "windows_i686_msvc" name = "windows_i686_msvc"
version = "0.42.0" version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
[[package]] [[package]]
name = "windows_x86_64_gnu" name = "windows_x86_64_gnu"
@ -3332,15 +3257,15 @@ checksum = "6868c165637d653ae1e8dc4d82c25d4f97dd6605eaa8d784b5c6e0ab2a252b65"
[[package]] [[package]]
name = "windows_x86_64_gnu" name = "windows_x86_64_gnu"
version = "0.42.0" version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
[[package]] [[package]]
name = "windows_x86_64_gnullvm" name = "windows_x86_64_gnullvm"
version = "0.42.0" version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
[[package]] [[package]]
name = "windows_x86_64_msvc" name = "windows_x86_64_msvc"
@ -3356,9 +3281,9 @@ checksum = "5e4d40883ae9cae962787ca76ba76390ffa29214667a111db9e0a1ad8377e809"
[[package]] [[package]]
name = "windows_x86_64_msvc" name = "windows_x86_64_msvc"
version = "0.42.0" version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
[[package]] [[package]]
name = "winres" name = "winres"

@ -10,10 +10,10 @@ edition = "2021"
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
serde_json = "1" serde_json = "1"
tauri = { version = "1", features = [] } tauri = { version = "1", features = [] }
tokio = { version = "1.11", features = ["net"] } tokio = { version = "1", features = ["net"] }
futures-util = "0.3" futures-util = "0.3"
tauri-plugin-websocket = { path = "../../../" } tauri-plugin-websocket = { path = "../../../" }
tokio-tungstenite = "0.15" tokio-tungstenite = "0.18"
[build-dependencies] [build-dependencies]
tauri-build = { version = "1", features = [] } tauri-build = { version = "1", features = [] }

@ -24,7 +24,7 @@
"LICENSE" "LICENSE"
], ],
"devDependencies": { "devDependencies": {
"tslib": "^2.4.1" "tslib": "^2.5.0"
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "^1.2.0" "@tauri-apps/api": "^1.2.0"

@ -0,0 +1 @@
node_modules

@ -1,7 +1,7 @@
[package] [package]
name = "tauri-plugin-window-state" name = "tauri-plugin-window-state"
version = "0.1.0" version = "0.1.0"
description = "Save window positions and sizse and restore them when the app is reopened." description = "Save window positions and sizes and restore them when the app is reopened."
authors.workspace = true authors.workspace = true
license.workspace = true license.workspace = true
edition.workspace = true edition.workspace = true
@ -16,4 +16,4 @@ tauri.workspace = true
log.workspace = true log.workspace = true
thiserror.workspace = true thiserror.workspace = true
bincode = "1.3" bincode = "1.3"
bitflags = "1" bitflags = "2"

@ -21,6 +21,18 @@ Install the Core plugin by adding the following to your `Cargo.toml` file:
tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "dev" } tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "dev" }
``` ```
You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
> Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use.
```sh
pnpm add https://github.com/tauri-apps/tauri-plugin-window-state
# or
npm add https://github.com/tauri-apps/tauri-plugin-window-state
# or
yarn add https://github.com/tauri-apps/tauri-plugin-window-state
```
## Usage ## Usage
First you need to register the core plugin with Tauri: First you need to register the core plugin with Tauri:
@ -38,7 +50,7 @@ fn main() {
Afterwards all windows will remember their state when the app is being closed and will restore to their previous state on the next launch. Afterwards all windows will remember their state when the app is being closed and will restore to their previous state on the next launch.
Optionally you can also tell the plugin to save the state of all open window to disk my using the `save_window_state()` method exposed by the `AppHandleExt` trait: Optionally you can also tell the plugin to save the state of all open window to disk by using the `save_window_state()` method exposed by the `AppHandleExt` trait:
```rust ```rust
use tauri_plugin_window_state::{AppHandleExt, StateFlags}; use tauri_plugin_window_state::{AppHandleExt, StateFlags};
@ -47,6 +59,14 @@ use tauri_plugin_window_state::{AppHandleExt, StateFlags};
app.save_window_state(StateFlags::all()); // will save the state of all open windows to disk app.save_window_state(StateFlags::all()); // will save the state of all open windows to disk
``` ```
or through Javascript
```javascript
import { saveWindowState, StateFlags } from "tauri-plugin-window-state-api";
saveWindowState(StateFlags.ALL);
```
To manually restore a windows state from disk you can call the `restore_state()` method exposed by the `WindowExt` trait: To manually restore a windows state from disk you can call the `restore_state()` method exposed by the `WindowExt` trait:
```rust ```rust
@ -56,6 +76,14 @@ use tauri_plugin_window_state::{WindowExt, StateFlags};
window.restore_state(StateFlags::all()); // will restore the windows state from disk window.restore_state(StateFlags::all()); // will restore the windows state from disk
``` ```
or through Javascript
```javascript
import { restoreStateCurrent, StateFlags } from "tauri-plugin-window-state-api";
restoreStateCurrent(StateFlags.ALL);
```
## Contributing ## Contributing
PRs accepted. Please make sure to read the Contributing Guide before making a pull request. PRs accepted. Please make sure to read the Contributing Guide before making a pull request.

@ -0,0 +1,35 @@
import { invoke } from "@tauri-apps/api/tauri";
import { WindowLabel, getCurrent } from "@tauri-apps/api/window";
export enum StateFlags {
SIZE = 1 << 0,
POSITION = 1 << 1,
MAXIMIZED = 1 << 2,
VISIBLE = 1 << 3,
DECORATIONS = 1 << 4,
FULLSCREEN = 1 << 5,
ALL = SIZE | POSITION | MAXIMIZED | VISIBLE | DECORATIONS | FULLSCREEN,
}
/**
* Save the state of all open windows to disk.
*/
async function saveWindowState(flags: StateFlags) {
invoke("plugin:window-state|js_save_window_state", { flags });
}
/**
* Restore the state for the specified window from disk.
*/
async function restoreState(label: WindowLabel, flags: StateFlags) {
invoke("plugin:window-state|js_restore_state", { label, flags });
}
/**
* Restore the state for the current window from disk.
*/
async function restoreStateCurrent(flags: StateFlags) {
restoreState(getCurrent().label, flags);
}
export { restoreState, restoreStateCurrent, saveWindowState };

@ -0,0 +1,33 @@
{
"name": "tauri-plugin-window-state-api",
"version": "0.1.0",
"description": "Save window positions and sizes and restore them when the app is reopened.",
"license": "MIT or APACHE-2.0",
"authors": [
"Tauri Programme within The Commons Conservancy"
],
"type": "module",
"browser": "dist-js/index.min.js",
"module": "dist-js/index.mjs",
"types": "dist-js/index.d.ts",
"exports": {
"import": "./dist-js/index.mjs",
"types": "./dist-js/index.d.ts",
"browser": "./dist-js/index.min.js"
},
"scripts": {
"build": "rollup -c"
},
"files": [
"dist-js",
"!dist-js/**/*.map",
"README.md",
"LICENSE"
],
"devDependencies": {
"tslib": "^2.5.0"
},
"dependencies": {
"@tauri-apps/api": "^1.2.0"
}
}

@ -0,0 +1,11 @@
import { readFileSync } from "fs";
import { createConfig } from "../../shared/rollup.config.mjs";
export default createConfig({
input: "guest-js/index.ts",
pkg: JSON.parse(
readFileSync(new URL("./package.json", import.meta.url), "utf8")
),
external: [/^@tauri-apps\/api/],
});

@ -0,0 +1,28 @@
use crate::{AppHandleExt, StateFlags, WindowExt};
use tauri::{command, AppHandle, Manager, Runtime};
#[command]
pub async fn save_window_state<R: Runtime>(
app: AppHandle<R>,
flags: u32,
) -> std::result::Result<(), String> {
let flags = StateFlags::from_bits(flags)
.ok_or_else(|| format!("Invalid state flags bits: {}", flags))?;
app.save_window_state(flags).map_err(|e| e.to_string())?;
Ok(())
}
#[command]
pub async fn restore_state<R: Runtime>(
app: AppHandle<R>,
label: String,
flags: u32,
) -> std::result::Result<(), String> {
let flags = StateFlags::from_bits(flags)
.ok_or_else(|| format!("Invalid state flags bits: {}", flags))?;
app.get_window(&label)
.ok_or_else(|| format!("Couldn't find window with label: {}", label))?
.restore_state(flags)
.map_err(|e| e.to_string())?;
Ok(())
}

@ -17,6 +17,8 @@ use std::{
sync::{Arc, Mutex}, sync::{Arc, Mutex},
}; };
mod cmd;
pub const STATE_FILENAME: &str = ".window-state"; pub const STATE_FILENAME: &str = ".window-state";
#[derive(Debug, thiserror::Error)] #[derive(Debug, thiserror::Error)]
@ -34,6 +36,7 @@ pub enum Error {
pub type Result<T> = std::result::Result<T, Error>; pub type Result<T> = std::result::Result<T, Error>;
bitflags! { bitflags! {
#[derive(Clone, Copy, Debug)]
pub struct StateFlags: u32 { pub struct StateFlags: u32 {
const SIZE = 1 << 0; const SIZE = 1 << 0;
const POSITION = 1 << 1; const POSITION = 1 << 1;
@ -50,7 +53,7 @@ impl Default for StateFlags {
} }
} }
#[derive(Debug, Default, Deserialize, Serialize)] #[derive(Debug, Default, Deserialize, Serialize, PartialEq)]
struct WindowState { struct WindowState {
width: f64, width: f64,
height: f64, height: f64,
@ -64,6 +67,7 @@ struct WindowState {
struct WindowStateCache(Arc<Mutex<HashMap<String, WindowState>>>); struct WindowStateCache(Arc<Mutex<HashMap<String, WindowState>>>);
pub trait AppHandleExt { pub trait AppHandleExt {
/// Saves all open windows state to disk
fn save_window_state(&self, flags: StateFlags) -> Result<()>; fn save_window_state(&self, flags: StateFlags) -> Result<()>;
} }
@ -93,6 +97,7 @@ impl<R: Runtime> AppHandleExt for tauri::AppHandle<R> {
} }
pub trait WindowExt { pub trait WindowExt {
/// Restores this window state from disk
fn restore_state(&self, flags: StateFlags) -> tauri::Result<()>; fn restore_state(&self, flags: StateFlags) -> tauri::Result<()>;
} }
@ -100,9 +105,15 @@ impl<R: Runtime> WindowExt for Window<R> {
fn restore_state(&self, flags: StateFlags) -> tauri::Result<()> { fn restore_state(&self, flags: StateFlags) -> tauri::Result<()> {
let cache = self.state::<WindowStateCache>(); let cache = self.state::<WindowStateCache>();
let mut c = cache.0.lock().unwrap(); let mut c = cache.0.lock().unwrap();
let mut should_show = true; let mut should_show = true;
if let Some(state) = c.get(self.label()) { if let Some(state) = c.get(self.label()) {
// avoid restoring the default zeroed state
if *state == WindowState::default() {
return Ok(());
}
if flags.contains(StateFlags::DECORATIONS) { if flags.contains(StateFlags::DECORATIONS) {
self.set_decorations(state.decorated)?; self.set_decorations(state.decorated)?;
} }
@ -225,7 +236,7 @@ impl<R: Runtime> WindowExtInternal for Window<R> {
} }
if flags.contains(StateFlags::POSITION) { if flags.contains(StateFlags::POSITION) {
let position = self.inner_position()?; let position = self.outer_position()?;
if let Ok(Some(monitor)) = self.current_monitor() { if let Ok(Some(monitor)) = self.current_monitor() {
// save only window positions that are inside the current monitor // save only window positions that are inside the current monitor
if monitor.contains(position) && !is_maximized { if monitor.contains(position) && !is_maximized {
@ -269,6 +280,10 @@ impl Builder {
pub fn build<R: Runtime>(self) -> TauriPlugin<R> { pub fn build<R: Runtime>(self) -> TauriPlugin<R> {
let flags = self.state_flags; let flags = self.state_flags;
PluginBuilder::new("window-state") PluginBuilder::new("window-state")
.invoke_handler(tauri::generate_handler![
cmd::save_window_state,
cmd::restore_state
])
.setup(|app| { .setup(|app| {
let cache: Arc<Mutex<HashMap<String, WindowState>>> = if let Some(app_dir) = let cache: Arc<Mutex<HashMap<String, WindowState>>> = if let Some(app_dir) =
app.path_resolver().app_config_dir() app.path_resolver().app_config_dir()
@ -304,6 +319,17 @@ impl Builder {
let label = window.label().to_string(); let label = window.label().to_string();
let window_clone = window.clone(); let window_clone = window.clone();
let flags = self.state_flags; let flags = self.state_flags;
// insert a default state if this window should be tracked and
// the disk cache doesn't have a state for it
{
cache
.lock()
.unwrap()
.entry(label.clone())
.or_insert_with(WindowState::default);
}
window.on_window_event(move |e| { window.on_window_event(move |e| {
if let WindowEvent::CloseRequested { .. } = e { if let WindowEvent::CloseRequested { .. } = e {
let mut c = cache.lock().unwrap(); let mut c = cache.lock().unwrap();

@ -0,0 +1 @@
../../shared/tsconfig.json

File diff suppressed because it is too large Load Diff

@ -1,6 +1,16 @@
{ {
"extends": ["config:base"], "extends": ["config:base"],
"enabledManagers": ["cargo", "npm"], "enabledManagers": ["cargo", "npm"],
"semanticCommitType": "chore",
"ignorePaths": [
"**/node_modules/**",
"**/bower_components/**",
"**/vendor/**",
"**/__tests__/**",
"**/test/**",
"**/tests/**",
"**/__fixtures__/**"
],
"packageRules": [ "packageRules": [
{ {
"description": "Disable node/pnpm version updates", "description": "Disable node/pnpm version updates",

@ -14,7 +14,7 @@
"strict": true, "strict": true,
"target": "ES2019", "target": "ES2019",
"declaration": true, "declaration": true,
"declarationDir": "dist" "declarationDir": "./"
}, },
"exclude": ["dist-js", "node_modules", "test/types"] "exclude": ["dist-js", "node_modules", "test/types"]
} }

Loading…
Cancel
Save