From cf4d7d4e6cc52bdfa26d1287976c06b6ec152c4e Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Wed, 4 Sep 2024 14:54:23 +0300 Subject: [PATCH] chore: adjust prettier config, .gitignore and use taplo to format toml files (#1728) * chore: adjust prettier config, .gitignore and use taplo to format toml files This brings the plugins-workspace repository to the same code style of the main tauri repo * format toml * ignore examples gen dir * add .vscode/extensions.json * remove packageManager field * fmt * fix audit * taplo ignore permissions autogenerated files * remove create dummy dist * fix prettier workflow * install fmt in prettier workflow --------- Co-authored-by: Lucas Nogueira --- .cargo/audit.toml | 4 +- .github/workflows/audit-javascript.yml | 16 +- .github/workflows/audit-rust.yml | 14 +- .github/workflows/check-generated-files.yml | 6 +- .../workflows/covector-comment-on-fork.yml | 2 +- .github/workflows/covector-status.yml | 4 +- .../workflows/covector-version-or-publish.yml | 14 +- .github/workflows/fmt.yml | 59 ++ .github/workflows/integration-tests.yml | 8 +- .github/workflows/lint-javascript.yml | 46 +- .github/workflows/lint-rust.yml | 34 +- .github/workflows/sync.yml | 2 +- .github/workflows/test-rust.yml | 44 +- .gitignore | 60 +- .prettierignore | 26 +- .prettierrc | 5 + .scripts/ci/check-license-header.js | 118 ++-- .vscode/extensions.json | 8 + README.md | 58 +- SECURITY.md | 2 +- eslint.config.js | 46 +- examples/api/.gitignore | 6 +- examples/api/dist/.gitkeep | 0 examples/api/isolation-dist/index.js | 4 +- examples/api/jsconfig.json | 10 +- examples/api/package.json | 2 +- examples/api/src-tauri/gen/apple/project.yml | 4 +- examples/api/src/app.css | 2 +- examples/api/src/lib/utils.js | 14 +- examples/api/src/main.js | 12 +- examples/api/unocss.config.js | 90 +-- examples/api/vite.config.js | 30 +- package.json | 9 +- plugins/autostart/.gitignore | 1 - plugins/autostart/Cargo.toml | 6 +- plugins/autostart/README.md | 8 +- plugins/autostart/SECURITY.md | 2 +- plugins/autostart/guest-js/index.ts | 8 +- plugins/autostart/permissions/default.toml | 6 +- plugins/autostart/rollup.config.js | 4 +- plugins/barcode-scanner/.gitignore | 1 - plugins/barcode-scanner/Cargo.toml | 8 +- plugins/barcode-scanner/README.md | 4 +- plugins/barcode-scanner/SECURITY.md | 1 - plugins/barcode-scanner/guest-js/index.ts | 58 +- plugins/barcode-scanner/rollup.config.js | 4 +- plugins/biometric/.gitignore | 1 - plugins/biometric/Cargo.toml | 8 +- plugins/biometric/README.md | 4 +- plugins/biometric/SECURITY.md | 2 +- plugins/biometric/guest-js/index.ts | 56 +- plugins/biometric/permissions/default.toml | 5 +- plugins/biometric/rollup.config.js | 4 +- plugins/cli/Cargo.toml | 6 +- plugins/cli/README.md | 12 +- plugins/cli/SECURITY.md | 2 +- plugins/cli/guest-js/index.ts | 20 +- plugins/cli/rollup.config.js | 4 +- plugins/clipboard-manager/.gitignore | 1 - plugins/clipboard-manager/Cargo.toml | 8 +- plugins/clipboard-manager/README.md | 12 +- plugins/clipboard-manager/SECURITY.md | 2 +- plugins/clipboard-manager/guest-js/index.ts | 38 +- plugins/clipboard-manager/rollup.config.js | 4 +- plugins/deep-link/.gitignore | 1 - plugins/deep-link/.test-server/server.js | 30 +- plugins/deep-link/Cargo.toml | 6 +- plugins/deep-link/README.md | 6 +- plugins/deep-link/SECURITY.md | 2 +- .../app/src-tauri/gen/apple/project.yml | 4 +- .../examples/app/src-tauri/server.js | 32 +- plugins/deep-link/examples/app/src/main.ts | 34 +- plugins/deep-link/examples/app/vite.config.ts | 22 +- plugins/deep-link/guest-js/index.ts | 24 +- plugins/deep-link/rollup.config.js | 4 +- plugins/dialog/.gitignore | 1 - plugins/dialog/Cargo.toml | 8 +- plugins/dialog/SECURITY.md | 2 +- plugins/dialog/guest-js/index.ts | 104 ++-- plugins/dialog/guest-js/init.ts | 18 +- plugins/dialog/permissions/default.toml | 10 +- plugins/dialog/rollup.config.js | 22 +- plugins/fs/.gitignore | 1 - plugins/fs/Cargo.toml | 6 +- plugins/fs/README.md | 4 +- plugins/fs/SECURITY.md | 2 - plugins/fs/guest-js/index.ts | 536 +++++++++--------- .../permissions/create-app-specific-dirs.toml | 2 +- plugins/fs/permissions/default.toml | 6 +- plugins/fs/permissions/read-all.toml | 28 +- .../read-app-specific-dirs-recursive.toml | 14 +- plugins/fs/permissions/read-files.toml | 22 +- plugins/fs/permissions/write-all.toml | 20 +- plugins/fs/permissions/write-files.toml | 18 +- plugins/fs/rollup.config.js | 4 +- plugins/geolocation/.gitignore | 1 - plugins/geolocation/Cargo.toml | 8 +- plugins/geolocation/README.md | 8 +- plugins/geolocation/SECURITY.md | 2 +- plugins/geolocation/guest-js/bindings.ts | 176 +++--- plugins/geolocation/guest-js/index.ts | 22 +- plugins/geolocation/rollup.config.js | 4 +- plugins/global-shortcut/Cargo.toml | 6 +- plugins/global-shortcut/README.md | 10 +- plugins/global-shortcut/SECURITY.md | 2 +- plugins/global-shortcut/guest-js/index.ts | 38 +- plugins/global-shortcut/rollup.config.js | 4 +- plugins/haptics/.gitignore | 1 - plugins/haptics/Cargo.toml | 8 +- plugins/haptics/README.md | 12 +- plugins/haptics/SECURITY.md | 2 +- plugins/haptics/guest-js/bindings.ts | 120 ++-- plugins/haptics/guest-js/index.ts | 8 +- plugins/haptics/rollup.config.js | 4 +- plugins/http/Cargo.toml | 6 +- plugins/http/README.md | 10 +- plugins/http/SECURITY.md | 2 +- plugins/http/guest-js/index.ts | 122 ++-- plugins/http/rollup.config.js | 4 +- plugins/localhost/Cargo.toml | 4 +- plugins/localhost/SECURITY.md | 2 +- plugins/log/.gitignore | 2 - plugins/log/Cargo.toml | 6 +- plugins/log/README.md | 12 +- plugins/log/SECURITY.md | 1 + plugins/log/guest-js/index.ts | 98 ++-- plugins/log/rollup.config.js | 4 +- plugins/nfc/.gitignore | 1 - plugins/nfc/Cargo.toml | 8 +- plugins/nfc/README.md | 6 +- plugins/nfc/SECURITY.md | 2 +- plugins/nfc/guest-js/index.ts | 212 ++++--- plugins/nfc/permissions/default.toml | 5 +- plugins/nfc/rollup.config.js | 4 +- plugins/notification/.gitignore | 1 - plugins/notification/Cargo.toml | 6 +- plugins/notification/README.md | 15 +- plugins/notification/SECURITY.md | 2 +- plugins/notification/guest-js/index.ts | 258 ++++----- plugins/notification/guest-js/init.ts | 85 ++- plugins/notification/permissions/default.toml | 2 +- plugins/notification/rollup.config.js | 22 +- plugins/os/Cargo.toml | 6 +- plugins/os/README.md | 4 +- plugins/os/SECURITY.md | 2 +- plugins/os/guest-js/index.ts | 90 +-- plugins/os/permissions/default.toml | 16 +- plugins/os/rollup.config.js | 4 +- plugins/os/src/init.js | 8 +- plugins/persisted-scope/Cargo.toml | 4 +- plugins/persisted-scope/SECURITY.md | 2 +- plugins/positioner/.gitignore | 1 - plugins/positioner/Cargo.toml | 6 +- plugins/positioner/README.md | 4 +- plugins/positioner/SECURITY.md | 2 +- plugins/positioner/guest-js/index.ts | 10 +- plugins/positioner/rollup.config.js | 4 +- plugins/process/Cargo.toml | 6 +- plugins/process/README.md | 6 +- plugins/process/SECURITY.md | 2 +- plugins/process/guest-js/index.ts | 8 +- plugins/process/permissions/default.toml | 5 +- plugins/process/rollup.config.js | 4 +- plugins/shell/.gitignore | 1 - plugins/shell/Cargo.toml | 6 +- plugins/shell/README.md | 4 +- plugins/shell/SECURITY.md | 2 +- plugins/shell/guest-js/index.ts | 256 ++++----- plugins/shell/guest-js/init.ts | 40 +- plugins/shell/permissions/default.toml | 4 +- plugins/shell/rollup.config.js | 22 +- plugins/single-instance/Cargo.toml | 4 +- plugins/single-instance/SECURITY.md | 2 +- plugins/sql/.gitignore | 1 - plugins/sql/Cargo.toml | 6 +- plugins/sql/README.md | 38 +- plugins/sql/SECURITY.md | 2 +- plugins/sql/guest-js/index.ts | 48 +- plugins/sql/permissions/default.toml | 6 +- plugins/sql/rollup.config.js | 4 +- plugins/store/.gitignore | 1 - plugins/store/Cargo.toml | 6 +- plugins/store/README.md | 18 +- plugins/store/SECURITY.md | 2 +- .../examples/AppSettingsManager/src/main.ts | 10 +- .../AppSettingsManager/vite.config.ts | 8 +- plugins/store/guest-js/index.ts | 102 ++-- plugins/store/rollup.config.js | 4 +- plugins/stronghold/.gitignore | 1 - plugins/stronghold/Cargo.toml | 6 +- plugins/stronghold/SECURITY.md | 2 +- plugins/stronghold/guest-js/index.ts | 286 +++++----- plugins/stronghold/rollup.config.js | 4 +- plugins/updater/Cargo.toml | 8 +- plugins/updater/README.md | 10 +- plugins/updater/SECURITY.md | 2 +- plugins/updater/guest-js/index.ts | 108 ++-- plugins/updater/permissions/default.toml | 8 +- plugins/updater/rollup.config.js | 4 +- plugins/upload/.gitignore | 1 - plugins/upload/Cargo.toml | 6 +- plugins/upload/README.md | 20 +- plugins/upload/SECURITY.md | 2 +- plugins/upload/guest-js/index.ts | 46 +- plugins/upload/permissions/default.toml | 5 +- plugins/upload/rollup.config.js | 4 +- plugins/websocket/.gitignore | 2 - plugins/websocket/Cargo.toml | 6 +- plugins/websocket/README.md | 8 +- plugins/websocket/SECURITY.md | 2 +- .../websocket/examples/tauri-app/src/main.ts | 48 +- .../examples/tauri-app/src/style.css | 4 +- plugins/websocket/guest-js/index.ts | 92 +-- plugins/websocket/rollup.config.js | 4 +- plugins/window-state/.gitignore | 1 - plugins/window-state/Cargo.toml | 6 +- plugins/window-state/README.md | 10 +- plugins/window-state/SECURITY.md | 2 +- plugins/window-state/guest-js/index.ts | 18 +- plugins/window-state/rollup.config.js | 4 +- pnpm-lock.yaml | 54 +- shared/rollup.config.js | 58 +- shared/template/.gitignore | 1 - shared/template/Cargo.toml | 6 +- shared/template/SECURITY.md | 2 +- shared/template/rollup.config.js | 4 +- taplo.toml | 1 + 227 files changed, 2533 insertions(+), 2504 deletions(-) create mode 100644 .github/workflows/fmt.yml create mode 100644 .prettierrc create mode 100644 .vscode/extensions.json create mode 100644 examples/api/dist/.gitkeep delete mode 100644 plugins/autostart/.gitignore delete mode 100644 plugins/barcode-scanner/.gitignore delete mode 100644 plugins/biometric/.gitignore delete mode 100644 plugins/clipboard-manager/.gitignore delete mode 100644 plugins/deep-link/.gitignore delete mode 100644 plugins/dialog/.gitignore delete mode 100644 plugins/fs/.gitignore delete mode 100644 plugins/geolocation/.gitignore delete mode 100644 plugins/haptics/.gitignore delete mode 100644 plugins/log/.gitignore delete mode 100644 plugins/nfc/.gitignore delete mode 100644 plugins/notification/.gitignore delete mode 100644 plugins/positioner/.gitignore delete mode 100644 plugins/shell/.gitignore delete mode 100644 plugins/sql/.gitignore delete mode 100644 plugins/store/.gitignore delete mode 100644 plugins/stronghold/.gitignore delete mode 100644 plugins/upload/.gitignore delete mode 100644 plugins/websocket/.gitignore delete mode 100644 plugins/window-state/.gitignore delete mode 100644 shared/template/.gitignore create mode 100644 taplo.toml diff --git a/.cargo/audit.toml b/.cargo/audit.toml index 23c3852b7..268d3716b 100644 --- a/.cargo/audit.toml +++ b/.cargo/audit.toml @@ -7,5 +7,5 @@ ignore = [ # wry needs kuchiki on Android "RUSTSEC-2023-0019", # atty is only used when the `colored` feature is enabled on tauri-plugin-log - "RUSTSEC-2021-0145" -] \ No newline at end of file + "RUSTSEC-2021-0145", +] diff --git a/.github/workflows/audit-javascript.yml b/.github/workflows/audit-javascript.yml index ac6f6af13..702811c24 100644 --- a/.github/workflows/audit-javascript.yml +++ b/.github/workflows/audit-javascript.yml @@ -7,23 +7,23 @@ name: Audit JavaScript on: workflow_dispatch: schedule: - - cron: "0 0 * * *" + - cron: '0 0 * * *' push: branches: - v1 - v2 paths: - - ".github/workflows/audit-javascript.yml" - - "**/pnpm-lock.yaml" - - "**/package.json" + - '.github/workflows/audit-javascript.yml' + - '**/pnpm-lock.yaml' + - '**/package.json' pull_request: branches: - v1 - v2 paths: - - ".github/workflows/audit-javascript.yml" - - "**/pnpm-lock.yaml" - - "**/package.json" + - '.github/workflows/audit-javascript.yml' + - '**/pnpm-lock.yaml' + - '**/package.json' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -43,7 +43,7 @@ jobs: ${{ runner.os }}- - uses: actions/setup-node@v4 with: - node-version: "lts/*" + node-version: 'lts/*' - uses: pnpm/action-setup@v4 with: version: 9.x.x diff --git a/.github/workflows/audit-rust.yml b/.github/workflows/audit-rust.yml index 70674c1cb..e0c72a899 100644 --- a/.github/workflows/audit-rust.yml +++ b/.github/workflows/audit-rust.yml @@ -7,23 +7,23 @@ name: Audit Rust on: workflow_dispatch: schedule: - - cron: "0 0 * * *" + - cron: '0 0 * * *' push: branches: - v1 - v2 paths: - - ".github/workflows/audit-rust.yml" - - "**/Cargo.lock" - - "**/Cargo.toml" + - '.github/workflows/audit-rust.yml' + - '**/Cargo.lock' + - '**/Cargo.toml' pull_request: branches: - v1 - v2 paths: - - ".github/workflows/audit-rust.yml" - - "**/Cargo.lock" - - "**/Cargo.toml" + - '.github/workflows/audit-rust.yml' + - '**/Cargo.lock' + - '**/Cargo.toml' concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/check-generated-files.yml b/.github/workflows/check-generated-files.yml index e59198961..96bbdd05a 100644 --- a/.github/workflows/check-generated-files.yml +++ b/.github/workflows/check-generated-files.yml @@ -7,8 +7,8 @@ name: check generated files on: pull_request: paths: - - ".github/workflows/check-generated-files.yml" - - "**/guest-js/**" + - '.github/workflows/check-generated-files.yml' + - '**/guest-js/**' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -136,7 +136,7 @@ jobs: ${{ runner.os }}- - uses: actions/setup-node@v4 with: - node-version: "lts/*" + node-version: 'lts/*' - uses: pnpm/action-setup@v4 with: version: 9.x.x diff --git a/.github/workflows/covector-comment-on-fork.yml b/.github/workflows/covector-comment-on-fork.yml index 69c85857b..494a53488 100644 --- a/.github/workflows/covector-comment-on-fork.yml +++ b/.github/workflows/covector-comment-on-fork.yml @@ -27,4 +27,4 @@ jobs: uses: jbolda/covector/packages/action@covector-v0 with: token: ${{ secrets.GITHUB_TOKEN }} - command: "status" + command: 'status' diff --git a/.github/workflows/covector-status.yml b/.github/workflows/covector-status.yml index 8087bc71a..7eeda427b 100644 --- a/.github/workflows/covector-status.yml +++ b/.github/workflows/covector-status.yml @@ -17,6 +17,6 @@ jobs: uses: jbolda/covector/packages/action@covector-v0 id: covector with: - command: "status" + command: 'status' token: ${{ secrets.GITHUB_TOKEN }} - comment: true \ No newline at end of file + comment: true diff --git a/.github/workflows/covector-version-or-publish.yml b/.github/workflows/covector-version-or-publish.yml index c2af8a678..22e945afd 100644 --- a/.github/workflows/covector-version-or-publish.yml +++ b/.github/workflows/covector-version-or-publish.yml @@ -34,8 +34,8 @@ jobs: - uses: actions/setup-node@v4 with: - node-version: "lts/*" - registry-url: "https://registry.npmjs.org" + node-version: 'lts/*' + registry-url: 'https://registry.npmjs.org' - uses: pnpm/action-setup@v4 with: @@ -65,7 +65,7 @@ jobs: NODE_AUTH_TOKEN: ${{ secrets.ORG_NPM_TOKEN }} with: token: ${{ secrets.GITHUB_TOKEN }} - command: "version-or-publish" + command: 'version-or-publish' createRelease: true recognizeContributors: true @@ -78,8 +78,8 @@ jobs: uses: tauri-apps/create-pull-request@v3 if: steps.covector.outputs.commandRan == 'version' with: - title: "Publish New Versions (${{ github.ref_name }})" - commit-message: "publish new versions" - labels: "version updates" - branch: "ci/release-${{ github.ref_name }}" + title: 'Publish New Versions (${{ github.ref_name }})' + commit-message: 'publish new versions' + labels: 'version updates' + branch: 'ci/release-${{ github.ref_name }}' body: ${{ steps.covector.outputs.change }} diff --git a/.github/workflows/fmt.yml b/.github/workflows/fmt.yml new file mode 100644 index 000000000..bd378799e --- /dev/null +++ b/.github/workflows/fmt.yml @@ -0,0 +1,59 @@ +# Copyright 2019-2023 Tauri Programme within The Commons Conservancy +# SPDX-License-Identifier: Apache-2.0 +# SPDX-License-Identifier: MIT + +name: check formatting + +on: + pull_request: + +jobs: + rustfmt: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: install Rust stable and rustfmt + uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt + + - name: run cargo fmt + run: cargo fmt --all -- --check + + prettier: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Cache pnpm modules + uses: actions/cache@v4 + with: + path: ~/.pnpm-store + key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}- + - uses: actions/setup-node@v4 + with: + node-version: 'lts/*' + - uses: pnpm/action-setup@v4 + with: + version: 9.x.x + run_install: true + - run: pnpm format:check + + taplo: + name: taplo (.toml files) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: install Rust stable + uses: dtolnay/rust-toolchain@stable + + - name: install taplo-cli + uses: taiki-e/install-action@v2 + with: + tool: taplo-cli + + - run: taplo fmt --check --diff diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 5ded783b1..fbbca96ab 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -10,15 +10,15 @@ on: - v1 - v2 paths: - - ".github/workflows/integration-tests.yml" - - "plugins/updater/src/**" + - '.github/workflows/integration-tests.yml' + - 'plugins/updater/src/**' pull_request: branches: - v1 - v2 paths: - - ".github/workflows/integration-tests.yml" - - "plugins/updater/src/**" + - '.github/workflows/integration-tests.yml' + - 'plugins/updater/src/**' jobs: run-integration-tests: diff --git a/.github/workflows/lint-javascript.yml b/.github/workflows/lint-javascript.yml index 82cc7e54b..df6b17d9b 100644 --- a/.github/workflows/lint-javascript.yml +++ b/.github/workflows/lint-javascript.yml @@ -10,23 +10,23 @@ on: - v1 - v2 paths: - - ".github/workflows/lint-javascript.yml" - - "plugins/*/guest-js/**" - - ".eslintignore" - - ".eslintrc.json" - - ".prettierignore" - - "**/package.json" + - '.github/workflows/lint-javascript.yml' + - 'plugins/*/guest-js/**' + - '.eslintignore' + - '.eslintrc.json' + - '.prettierignore' + - '**/package.json' pull_request: branches: - v1 - v2 paths: - - ".github/workflows/lint-javascript.yml" - - "plugins/*/guest-js/**" - - ".eslintignore" - - ".eslintrc.json" - - ".prettierignore" - - "**/package.json" + - '.github/workflows/lint-javascript.yml' + - 'plugins/*/guest-js/**' + - '.eslintignore' + - '.eslintrc.json' + - '.prettierignore' + - '**/package.json' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -46,30 +46,10 @@ jobs: ${{ runner.os }}- - uses: actions/setup-node@v4 with: - node-version: "lts/*" + node-version: 'lts/*' - uses: pnpm/action-setup@v4 with: version: 9.x.x run_install: true - name: eslint run: pnpm lint - prettier: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Cache pnpm modules - uses: actions/cache@v4 - with: - path: ~/.pnpm-store - key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}- - - uses: actions/setup-node@v4 - with: - node-version: "lts/*" - - uses: pnpm/action-setup@v4 - with: - version: 9.x.x - run_install: true - - name: prettier check - run: pnpm format-check diff --git a/.github/workflows/lint-rust.yml b/.github/workflows/lint-rust.yml index abfcbf6cd..74d9d7666 100644 --- a/.github/workflows/lint-rust.yml +++ b/.github/workflows/lint-rust.yml @@ -10,19 +10,19 @@ on: - v1 - v2 paths: - - ".github/workflows/lint-rust.yml" - - "plugins/*/src/**" - - "!plugins/*/src/api-iife.js" - - "**/Cargo.toml" + - '.github/workflows/lint-rust.yml' + - 'plugins/*/src/**' + - '!plugins/*/src/api-iife.js' + - '**/Cargo.toml' pull_request: branches: - v1 - v2 paths: - - ".github/workflows/lint-rust.yml" - - "plugins/*/src/**" - - "!plugins/*/src/api-iife.js" - - "**/Cargo.toml" + - '.github/workflows/lint-rust.yml' + - 'plugins/*/src/**' + - '!plugins/*/src/api-iife.js' + - '**/Cargo.toml' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -147,10 +147,6 @@ jobs: - uses: Swatinem/rust-cache@v2 - - name: create dummy dist - working-directory: examples/api - run: mkdir dist - - name: clippy ${{ matrix.package }} if: matrix.package != 'tauri-plugin-sql' run: cargo clippy --package ${{ matrix.package }} --all-targets -- -D warnings @@ -162,17 +158,3 @@ jobs: - name: clippy ${{ matrix.package }} postgres if: matrix.package == 'tauri-plugin-sql' run: cargo clippy --package ${{ matrix.package }} --all-targets --no-default-features --features postgres -- -D warnings - - fmt: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Install rustfmt with nightly toolchain - uses: dtolnay/rust-toolchain@nightly - with: - components: rustfmt - - - name: Check formatting - run: cargo fmt --all -- --check diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index 702c62f17..3b8e70db4 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -34,7 +34,7 @@ jobs: - uses: actions/setup-node@v4 with: - node-version: "lts/*" + node-version: 'lts/*' - uses: pnpm/action-setup@v4 with: diff --git a/.github/workflows/test-rust.yml b/.github/workflows/test-rust.yml index 7a76cab2f..75b1e55fc 100644 --- a/.github/workflows/test-rust.yml +++ b/.github/workflows/test-rust.yml @@ -10,21 +10,21 @@ on: - v1 - v2 paths: - - ".github/workflows/test-rust.yml" - - "plugins/*/src/**" - - "!plugins/*/src/api-iife.js" - - "**/Cargo.toml" - - "**/Cargo.lock" + - '.github/workflows/test-rust.yml' + - 'plugins/*/src/**' + - '!plugins/*/src/api-iife.js' + - '**/Cargo.toml' + - '**/Cargo.lock' pull_request: branches: - v1 - v2 paths: - - ".github/workflows/test-rust.yml" - - "plugins/*/src/**" - - "!plugins/*/src/api-iife.js" - - "**/Cargo.toml" - - "**/Cargo.lock" + - '.github/workflows/test-rust.yml' + - 'plugins/*/src/**' + - '!plugins/*/src/api-iife.js' + - '**/Cargo.toml' + - '**/Cargo.lock' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -163,32 +163,32 @@ jobs: - { target: x86_64-pc-windows-msvc, os: windows-latest, - runner: "cargo", - command: "test", + runner: 'cargo', + command: 'test' } - { target: x86_64-unknown-linux-gnu, os: ubuntu-latest, - runner: "cargo", - command: "test", + runner: 'cargo', + command: 'test' } - { target: aarch64-apple-darwin, os: macos-latest, - runner: "cargo", - command: "test", + runner: 'cargo', + command: 'test' } - { target: aarch64-apple-ios, os: macos-latest, - runner: "cargo", - command: "build", + runner: 'cargo', + command: 'build' } - { target: aarch64-linux-android, os: ubuntu-latest, - runner: "cross", - command: "build", + runner: 'cross', + command: 'build' } runs-on: ${{ matrix.platform.os }} @@ -210,10 +210,6 @@ jobs: with: key: cache-${{ matrix.package }}-${{ matrix.platform.target }} - - name: create dummy dist - working-directory: examples/api - run: mkdir dist - - name: install cross if: ${{ matrix.platform.runner == 'cross' }} run: cargo +stable install cross --git https://github.com/cross-rs/cross diff --git a/.gitignore b/.gitignore index dc9385b7f..f9d6a360f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,52 @@ -target -node_modules -dist-js -dist +# dependency directories +node_modules/ +target/ + +# Optional npm and yarn cache directory +.npm/ +.yarn/ + +# Output of 'npm pack' +*.tgz + +# dotenv environment variables file +.env + +# .vscode workspace settings file +.vscode/settings.json + +# npm, yarn and bun lock files +package-lock.json +yarn.lock +bun.lockb + +# rust compiled folders +target/ + +# compiled plugins +dist-js/ + +# plugins .tauri director +/plugins/*/.tauri + +# logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# runtime data +pids +*.pid +*.seed +*.pid.lock + +# miscellaneous +/.vs +.DS_Store +.Thumbs.db +*.sublime* .idea -.vscode -.gradle -**/capabilities/schemas -.build -.tauri \ No newline at end of file +debug.log +TODO.md \ No newline at end of file diff --git a/.prettierignore b/.prettierignore index c5d0524a8..82c1a32ef 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,12 +1,22 @@ -target -node_modules -dist -dist-js +/.changes +/.vscode + +# dependcies and artifacts directories +node_modules/ +target/ +dist-js/ +dist/ + +# lock files pnpm-lock.yaml -Cargo.lock -.build -build + +# examples gen directory +examples/*/src-tauri/gen/ +plugins/examples/*/src-tauri/gen/ + +# autogenerated files +**/autogenerated/**/*.md api-iife.js init-iife.js -intermediates/ +CHANGELOG.md *schema.json \ No newline at end of file diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 000000000..299b9e14e --- /dev/null +++ b/.prettierrc @@ -0,0 +1,5 @@ +{ + "singleQuote": true, + "semi": false, + "trailingComma": "none" +} diff --git a/.scripts/ci/check-license-header.js b/.scripts/ci/check-license-header.js index 7c69bb33b..ed6538097 100644 --- a/.scripts/ci/check-license-header.js +++ b/.scripts/ci/check-license-header.js @@ -2,129 +2,129 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import fs from "fs"; -import path from "path"; -import readline from "readline"; +import fs from 'fs' +import path from 'path' +import readline from 'readline' const header = `Copyright 2019-2023 Tauri Programme within The Commons Conservancy SPDX-License-Identifier: Apache-2.0 -SPDX-License-Identifier: MIT`; +SPDX-License-Identifier: MIT` const ignoredLicenses = [ - "// Copyright 2021 Flavio Oliveira", - "// Copyright 2021 Jonas Kruckenberg", - "// Copyright 2018-2023 the Deno authors.", -]; + '// Copyright 2021 Flavio Oliveira', + '// Copyright 2021 Jonas Kruckenberg', + '// Copyright 2018-2023 the Deno authors.' +] -const extensions = [".rs", ".js", ".ts", ".yml", ".swift", ".kt"]; +const extensions = ['.rs', '.js', '.ts', '.yml', '.swift', '.kt'] const ignore = [ - "target", - "templates", - "node_modules", - "gen", - "dist", - "dist-js", - ".svelte-kit", - "api-iife.js", - "init-iife.js", - ".build", - "notify_rust", -]; + 'target', + 'templates', + 'node_modules', + 'gen', + 'dist', + 'dist-js', + '.svelte-kit', + 'api-iife.js', + 'init-iife.js', + '.build', + 'notify_rust' +] async function checkFile(file) { if ( extensions.some((e) => file.endsWith(e)) && !ignore.some((i) => file.includes(`${path.sep}${i}`)) ) { - const fileStream = fs.createReadStream(file); + const fileStream = fs.createReadStream(file) const rl = readline.createInterface({ input: fileStream, - crlfDelay: Infinity, - }); + crlfDelay: Infinity + }) - let contents = ``; - let i = 0; + let contents = `` + let i = 0 for await (let line of rl) { // ignore empty lines, allow shebang, swift-tools-version and bundler license if ( line.length === 0 || - line.startsWith("#!") || - line.startsWith("// swift-tools-version:") || + line.startsWith('#!') || + line.startsWith('// swift-tools-version:') || ignoredLicenses.includes(line) ) { - continue; + continue } // strip comment marker - if (line.startsWith("// ")) { - line = line.substring(3); - } else if (line.startsWith("# ")) { - line = line.substring(2); + if (line.startsWith('// ')) { + line = line.substring(3) + } else if (line.startsWith('# ')) { + line = line.substring(2) } - contents += line; + contents += line if (++i === 3) { - break; + break } - contents += "\n"; + contents += '\n' } if (contents !== header) { - return true; + return true } } - return false; + return false } async function check(src) { - const missingHeader = []; + const missingHeader = [] for (const entry of fs.readdirSync(src, { - withFileTypes: true, + withFileTypes: true })) { - const p = path.join(src, entry.name); + const p = path.join(src, entry.name) if (entry.isSymbolicLink() || ignore.includes(entry.name)) { - continue; + continue } if (entry.isDirectory()) { - const missing = await check(p); - missingHeader.push(...missing); + const missing = await check(p) + missingHeader.push(...missing) } else { - const isMissing = await checkFile(p); + const isMissing = await checkFile(p) if (isMissing) { - missingHeader.push(p); + missingHeader.push(p) } } } - return missingHeader; + return missingHeader } -const [_bin, _script, ...files] = process.argv; +const [_bin, _script, ...files] = process.argv if (files.length > 0) { async function run() { - const missing = []; + const missing = [] for (const f of files) { - const isMissing = await checkFile(f); + const isMissing = await checkFile(f) if (isMissing) { - missing.push(f); + missing.push(f) } } if (missing.length > 0) { - console.log(missing.join("\n")); - process.exit(1); + console.log(missing.join('\n')) + process.exit(1) } } - run(); + run() } else { - check(path.resolve(new URL(import.meta.url).pathname, "../../..")).then( + check(path.resolve(new URL(import.meta.url).pathname, '../../..')).then( (missing) => { if (missing.length > 0) { - console.log(missing.join("\n")); - process.exit(1); + console.log(missing.join('\n')) + process.exit(1) } - }, - ); + } + ) } diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 000000000..68acfc90a --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,8 @@ +{ + "recommendations": [ + "rust-lang.rust-analyzer", + "EditorConfig.EditorConfig", + "esbenp.prettier-vscode", + "tamasfe.even-better-toml" + ] +} diff --git a/README.md b/README.md index c511aa671..9597af5af 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,34 @@ ## Plugins Found Here -| | | Win | Mac | Lin | iOS | And | -| ----------------------------------------------- | ------------------------------------------------------ | --- | --- | --- | --- | --- | -| [autostart](plugins/autostart) | Automatically launch your app at system startup. | ✅ | ✅ | ✅ | ? | ? | -| [barcode-scanner](plugins/barcode-scanner) | Allows your mobile application to use the camera to scan QR codes, EAN-13 and other kinds of barcodes. | ? | ? | ? | ✅ | ✅ | -| [biometric](plugins/biometric) | Prompt the user for biometric authentication on Android and iOS. | ? | ? | ? | ✅ | ✅ | -| [cli](plugins/cli) | Parse arguments from your Command Line Interface | ✅ | ✅ | ✅ | ? | ? | -| [clipboard-manager](plugins/clipboard-manager) | Read and write to the system clipboard. | ✅ | ✅ | ✅ | ✅ | ✅ | -| [deep-link](plugins/deep-link) | Set your Tauri application as the default handler for an URL. | ✅ | ✅ | ✅ | ✅ | ✅ | -| [dialog](plugins/dialog) | Native system dialogs for opening and saving files along with message dialogs. | ✅ | ✅ | ✅ | ✅ | ✅ | -| [fs](plugins/fs) | Access the file system. | ✅ | ✅ | ✅ | ? | ? | -| [global-shortcut](plugins/global-shortcut) | Register global shortcuts. | ✅ | ✅ | ✅ | ? | ? | -| [http](plugins/http) | Access the HTTP client written in Rust. | ✅ | ✅ | ✅ | ✅ | ✅ | -| [localhost](plugins/localhost) | Use a localhost server in production apps. | ✅ | ✅ | ✅ | ? | ? | -| [log](plugins/log) | Configurable logging. | ✅ | ✅ | ✅ | ✅ | ✅ | -| [nfc](plugins/nfc) | Read and write NFC tags on Android and iOS. | ? | ? | ? | ✅ | ✅ | -| [notification](plugins/notification) | Send message notifications (brief auto-expiring OS window element) to your user. Can also be used with the Notification Web API. | ✅ | ✅ | ✅ | ✅ | ✅ | -| [os](plugins/os) | Read information about the operating system. | ✅ | ✅ | ✅ | ✅ | ✅ | -| [persisted-scope](plugins/persisted-scope) | Persist runtime scope changes on the filesystem. | ✅ | ✅ | ✅ | ? | ? | -| [positioner](plugins/positioner) | Move windows to common locations. | ✅ | ✅ | ✅ | ? | ? | -| [process](plugins/process) | This plugin provides APIs to access the current process. To spawn child processes, see the [`shell`](https://github.com/tauri-apps/tauri-plugin-shell) plugin. | ✅ | ✅ | ✅ | ? | ? | -| [shell](plugins/shell) | Access the system shell. Allows you to spawn child processes and manage files and URLs using their default application. | ✅ | ✅ | ✅ | ? | ? | -| [single-instance](plugins/single-instance) | Ensure a single instance of your tauri app is running. | ✅ | ? | ✅ | ? | ? | -| [sql](plugins/sql) | Interface with SQL databases. | ✅ | ✅ | ✅ | ? | ? | -| [store](plugins/store) | Persistent key value storage. | ✅ | ✅ | ✅ | ✅ | ✅ | -| [stronghold](plugins/stronghold) | Encrypted, secure database. | ✅ | ✅ | ✅ | ? | ? | -| [updater](plugins/updater) | In-app updates for Tauri applications. | ✅ | ✅ | ✅ | ? | ? | -| [upload](plugins/upload) | Tauri plugin for file uploads through HTTP. | ✅ | ✅ | ✅ | ? | ? | -| [websocket](plugins/websocket) | Open a WebSocket connection using a Rust client in JS. | ✅ | ✅ | ✅ | ? | ? | -| [window-state](plugins/window-state) | Persist window sizes and positions. | ✅ | ✅ | ✅ | ? | ? | +| | | Win | Mac | Lin | iOS | And | +| ---------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | --- | --- | --- | --- | +| [autostart](plugins/autostart) | Automatically launch your app at system startup. | ✅ | ✅ | ✅ | ? | ? | +| [barcode-scanner](plugins/barcode-scanner) | Allows your mobile application to use the camera to scan QR codes, EAN-13 and other kinds of barcodes. | ? | ? | ? | ✅ | ✅ | +| [biometric](plugins/biometric) | Prompt the user for biometric authentication on Android and iOS. | ? | ? | ? | ✅ | ✅ | +| [cli](plugins/cli) | Parse arguments from your Command Line Interface | ✅ | ✅ | ✅ | ? | ? | +| [clipboard-manager](plugins/clipboard-manager) | Read and write to the system clipboard. | ✅ | ✅ | ✅ | ✅ | ✅ | +| [deep-link](plugins/deep-link) | Set your Tauri application as the default handler for an URL. | ✅ | ✅ | ✅ | ✅ | ✅ | +| [dialog](plugins/dialog) | Native system dialogs for opening and saving files along with message dialogs. | ✅ | ✅ | ✅ | ✅ | ✅ | +| [fs](plugins/fs) | Access the file system. | ✅ | ✅ | ✅ | ? | ? | +| [global-shortcut](plugins/global-shortcut) | Register global shortcuts. | ✅ | ✅ | ✅ | ? | ? | +| [http](plugins/http) | Access the HTTP client written in Rust. | ✅ | ✅ | ✅ | ✅ | ✅ | +| [localhost](plugins/localhost) | Use a localhost server in production apps. | ✅ | ✅ | ✅ | ? | ? | +| [log](plugins/log) | Configurable logging. | ✅ | ✅ | ✅ | ✅ | ✅ | +| [nfc](plugins/nfc) | Read and write NFC tags on Android and iOS. | ? | ? | ? | ✅ | ✅ | +| [notification](plugins/notification) | Send message notifications (brief auto-expiring OS window element) to your user. Can also be used with the Notification Web API. | ✅ | ✅ | ✅ | ✅ | ✅ | +| [os](plugins/os) | Read information about the operating system. | ✅ | ✅ | ✅ | ✅ | ✅ | +| [persisted-scope](plugins/persisted-scope) | Persist runtime scope changes on the filesystem. | ✅ | ✅ | ✅ | ? | ? | +| [positioner](plugins/positioner) | Move windows to common locations. | ✅ | ✅ | ✅ | ? | ? | +| [process](plugins/process) | This plugin provides APIs to access the current process. To spawn child processes, see the [`shell`](https://github.com/tauri-apps/tauri-plugin-shell) plugin. | ✅ | ✅ | ✅ | ? | ? | +| [shell](plugins/shell) | Access the system shell. Allows you to spawn child processes and manage files and URLs using their default application. | ✅ | ✅ | ✅ | ? | ? | +| [single-instance](plugins/single-instance) | Ensure a single instance of your tauri app is running. | ✅ | ? | ✅ | ? | ? | +| [sql](plugins/sql) | Interface with SQL databases. | ✅ | ✅ | ✅ | ? | ? | +| [store](plugins/store) | Persistent key value storage. | ✅ | ✅ | ✅ | ✅ | ✅ | +| [stronghold](plugins/stronghold) | Encrypted, secure database. | ✅ | ✅ | ✅ | ? | ? | +| [updater](plugins/updater) | In-app updates for Tauri applications. | ✅ | ✅ | ✅ | ? | ? | +| [upload](plugins/upload) | Tauri plugin for file uploads through HTTP. | ✅ | ✅ | ✅ | ? | ? | +| [websocket](plugins/websocket) | Open a WebSocket connection using a Rust client in JS. | ✅ | ✅ | ✅ | ? | ? | +| [window-state](plugins/window-state) | Persist window sizes and positions. | ✅ | ✅ | ✅ | ? | ? | _This repo and all plugins require a Rust version of at least **1.75**_ diff --git a/SECURITY.md b/SECURITY.md index 67d831fc9..4f09bbacd 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -20,4 +20,4 @@ We prefer to receive reports in English. Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). -Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). \ No newline at end of file +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/eslint.config.js b/eslint.config.js index 862fd2c29..f34103ee4 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -2,29 +2,29 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import eslint from "@eslint/js"; -import eslintConfigPrettier from "eslint-config-prettier"; -import eslintPluginSecurity from "eslint-plugin-security"; -import tseslint from "typescript-eslint"; +import eslint from '@eslint/js' +import eslintConfigPrettier from 'eslint-config-prettier' +import eslintPluginSecurity from 'eslint-plugin-security' +import tseslint from 'typescript-eslint' export default tseslint.config( { ignores: [ - "**/target", - "**/node_modules", - "**/examples", - "**/dist", - "**/dist-js", - "**/build", - "**/api-iife.js", - "**/init-iife.js", - "**/init.js", - "**/rollup.config.js", - "**/bindings.ts", - "**/.test-server", - ".scripts", - "eslint.config.js", - ], + '**/target', + '**/node_modules', + '**/examples', + '**/dist', + '**/dist-js', + '**/build', + '**/api-iife.js', + '**/init-iife.js', + '**/init.js', + '**/rollup.config.js', + '**/bindings.ts', + '**/.test-server', + '.scripts', + 'eslint.config.js' + ] }, eslint.configs.recommended, eslintConfigPrettier, @@ -32,7 +32,7 @@ export default tseslint.config( ...tseslint.configs.recommendedTypeChecked, { languageOptions: { - parserOptions: { project: true, tsconfigRootDir: import.meta.dirname }, - }, - }, -); + parserOptions: { project: true, tsconfigRootDir: import.meta.dirname } + } + } +) diff --git a/examples/api/.gitignore b/examples/api/.gitignore index ac9643a2b..fb4eb33ac 100644 --- a/examples/api/.gitignore +++ b/examples/api/.gitignore @@ -1,4 +1,2 @@ -/node_modules/ -/.vscode/ -.DS_Store -.cargo +/dist/* +!/dist/.gitkeep diff --git a/examples/api/dist/.gitkeep b/examples/api/dist/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/examples/api/isolation-dist/index.js b/examples/api/isolation-dist/index.js index 83f35e0dd..7e2df30de 100644 --- a/examples/api/isolation-dist/index.js +++ b/examples/api/isolation-dist/index.js @@ -3,5 +3,5 @@ // SPDX-License-Identifier: MIT window.__TAURI_ISOLATION_HOOK__ = (payload) => { - return payload; -}; + return payload +} diff --git a/examples/api/jsconfig.json b/examples/api/jsconfig.json index 42585941e..5696a2de7 100644 --- a/examples/api/jsconfig.json +++ b/examples/api/jsconfig.json @@ -1,14 +1,14 @@ { "compilerOptions": { - "moduleResolution": "node", - "target": "esnext", - "module": "esnext", + "moduleResolution": "bundler", + "target": "ESNext", + "module": "ESNext", /** * svelte-preprocess cannot figure out whether you have * a value or a type, so tell TypeScript to enforce using * `import type` instead of `import` for Types. */ - "importsNotUsedAsValues": "error", + "verbatimModuleSyntax": true, "isolatedModules": true, "resolveJsonModule": true, /** @@ -18,8 +18,6 @@ "sourceMap": true, "esModuleInterop": true, "skipLibCheck": true, - "forceConsistentCasingInFileNames": true, - "baseUrl": ".", /** * Typecheck JS in `.svelte` and `.js` files by default. * Disable this if you'd like to use dynamic types. diff --git a/examples/api/package.json b/examples/api/package.json index cea2e4b57..10232316c 100644 --- a/examples/api/package.json +++ b/examples/api/package.json @@ -33,7 +33,7 @@ "@sveltejs/vite-plugin-svelte": "^3.0.1", "@tauri-apps/cli": "2.0.0-rc.10", "@unocss/extractor-svelte": "^0.62.0", - "svelte": "^4.2.8", + "svelte": "^4.2.19", "unocss": "^0.62.0", "vite": "^5.0.13" } diff --git a/examples/api/src-tauri/gen/apple/project.yml b/examples/api/src-tauri/gen/apple/project.yml index 265d9eb71..dad7b6192 100644 --- a/examples/api/src-tauri/gen/apple/project.yml +++ b/examples/api/src-tauri/gen/apple/project.yml @@ -64,7 +64,7 @@ targets: base: ENABLE_BITCODE: false ARCHS: [arm64, arm64-sim] - VALID_ARCHS: arm64 arm64-sim + VALID_ARCHS: arm64 arm64-sim LIBRARY_SEARCH_PATHS[arch=x86_64]: $(inherited) $(PROJECT_DIR)/Externals/x86_64/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) LIBRARY_SEARCH_PATHS[arch=arm64]: $(inherited) $(PROJECT_DIR)/Externals/arm64/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) LIBRARY_SEARCH_PATHS[arch=arm64-sim]: $(inherited) $(PROJECT_DIR)/Externals/arm64-sim/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) @@ -89,4 +89,4 @@ targets: outputFiles: - $(SRCROOT)/Externals/x86_64/${CONFIGURATION}/libapp.a - $(SRCROOT)/Externals/arm64/${CONFIGURATION}/libapp.a - - $(SRCROOT)/Externals/arm64-sim/${CONFIGURATION}/libapp.a \ No newline at end of file + - $(SRCROOT)/Externals/arm64-sim/${CONFIGURATION}/libapp.a diff --git a/examples/api/src/app.css b/examples/api/src/app.css index 6987e423e..6e8ae62da 100644 --- a/examples/api/src/app.css +++ b/examples/api/src/app.css @@ -5,7 +5,7 @@ * { box-sizing: border-box; - font-family: "Rubik", sans-serif; + font-family: 'Rubik', sans-serif; } ::-webkit-scrollbar { diff --git a/examples/api/src/lib/utils.js b/examples/api/src/lib/utils.js index 442052c2c..a5ddc0584 100644 --- a/examples/api/src/lib/utils.js +++ b/examples/api/src/lib/utils.js @@ -4,12 +4,12 @@ export function arrayBufferToBase64(buffer, callback) { const blob = new Blob([buffer], { - type: "application/octet-binary", - }); - const reader = new FileReader(); + type: 'application/octet-binary' + }) + const reader = new FileReader() reader.onload = function (evt) { - const dataurl = evt.target.result; - callback(dataurl.substr(dataurl.indexOf(",") + 1)); - }; - reader.readAsDataURL(blob); + const dataurl = evt.target.result + callback(dataurl.substr(dataurl.indexOf(',') + 1)) + } + reader.readAsDataURL(blob) } diff --git a/examples/api/src/main.js b/examples/api/src/main.js index f9785b74b..f31a3eb83 100644 --- a/examples/api/src/main.js +++ b/examples/api/src/main.js @@ -2,12 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import "uno.css"; -import "./app.css"; -import App from "./App.svelte"; +import 'uno.css' +import './app.css' +import App from './App.svelte' const app = new App({ - target: document.querySelector("#app"), -}); + target: document.querySelector('#app') +}) -export default app; +export default app diff --git a/examples/api/unocss.config.js b/examples/api/unocss.config.js index 44d926cd8..d2069a49e 100644 --- a/examples/api/unocss.config.js +++ b/examples/api/unocss.config.js @@ -2,43 +2,43 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { defineConfig, presetIcons, presetUno, presetWebFonts } from "unocss"; -import extractorSvelte from "@unocss/extractor-svelte"; +import { defineConfig, presetIcons, presetUno, presetWebFonts } from 'unocss' +import extractorSvelte from '@unocss/extractor-svelte' export default defineConfig({ theme: { colors: { - primary: "#FFFFFF", - primaryLighter: "#e9ecef", - darkPrimary: "#1B1B1D", - darkPrimaryLighter: "#242526", - primaryText: "#1C1E21", - darkPrimaryText: "#E3E3E3", - secondaryText: "#858A91", - darkSecondaryText: "#C2C5CA", - accent: "#3578E5", - accentDark: "#306cce", - accentDarker: "#2d66c3", - accentDarkest: "#2554a0", - accentLight: "#538ce9", - accentLighter: "#72a1ed", - accentLightest: "#9abcf2", - accentText: "#FFFFFF", - darkAccent: "#67d6ed", - darkAccentDark: "#49cee9", - darkAccentDarker: "#39cae8", - darkAccentDarkest: "#19b5d5", - darkAccentLight: "#85def1", - darkAccentLighter: "#95e2f2", - darkAccentLightest: "#c2eff8", - darkAccentText: "#1C1E21", - code: "#d6d8da", - codeDark: "#282a2e", - hoverOverlay: "rgba(0,0,0,.05)", - hoverOverlayDarker: "rgba(0,0,0,.1)", - darkHoverOverlay: "hsla(0,0%,100%,.05)", - darkHoverOverlayDarker: "hsla(0,0%,100%,.1)", - }, + primary: '#FFFFFF', + primaryLighter: '#e9ecef', + darkPrimary: '#1B1B1D', + darkPrimaryLighter: '#242526', + primaryText: '#1C1E21', + darkPrimaryText: '#E3E3E3', + secondaryText: '#858A91', + darkSecondaryText: '#C2C5CA', + accent: '#3578E5', + accentDark: '#306cce', + accentDarker: '#2d66c3', + accentDarkest: '#2554a0', + accentLight: '#538ce9', + accentLighter: '#72a1ed', + accentLightest: '#9abcf2', + accentText: '#FFFFFF', + darkAccent: '#67d6ed', + darkAccentDark: '#49cee9', + darkAccentDarker: '#39cae8', + darkAccentDarkest: '#19b5d5', + darkAccentLight: '#85def1', + darkAccentLighter: '#95e2f2', + darkAccentLightest: '#c2eff8', + darkAccentText: '#1C1E21', + code: '#d6d8da', + codeDark: '#282a2e', + hoverOverlay: 'rgba(0,0,0,.05)', + hoverOverlayDarker: 'rgba(0,0,0,.1)', + darkHoverOverlay: 'hsla(0,0%,100%,.05)', + darkHoverOverlayDarker: 'hsla(0,0%,100%,.1)' + } }, preflights: [ { @@ -54,7 +54,7 @@ export default defineConfig({ code { font-size: ${theme.fontSize.xs[0]}; font-family: ${theme.fontFamily.mono}; - border-radius: ${theme.borderRadius["DEFAULT"]}; + border-radius: ${theme.borderRadius['DEFAULT']}; background-color: ${theme.colors.code}; } @@ -66,8 +66,8 @@ export default defineConfig({ .dark code { background-color: ${theme.colors.codeDark}; } - `, - }, + ` + } ], shortcuts: { btn: `select-none outline-none shadow-md p-2 rd-1 text-primaryText border-none font-400 dark:font-600 @@ -81,20 +81,20 @@ export default defineConfig({ note: `decoration-none flex-inline items-center relative p-2 rd-1 border-l-4 border-accent dark:border-darkAccent bg-accent/10 dark:bg-darkAccent/10`, - "note-red": - "note bg-red-700/10 dark:bg-red-700/10 after:bg-red-700 dark:after:bg-red-700", + 'note-red': + 'note bg-red-700/10 dark:bg-red-700/10 after:bg-red-700 dark:after:bg-red-700', input: - "h-10 flex items-center outline-none border-none p-2 rd-1 shadow-md bg-primaryLighter dark:bg-darkPrimaryLighter text-primaryText dark:text-darkPrimaryText", + 'h-10 flex items-center outline-none border-none p-2 rd-1 shadow-md bg-primaryLighter dark:bg-darkPrimaryLighter text-primaryText dark:text-darkPrimaryText' }, presets: [ presetUno(), presetIcons(), presetWebFonts({ fonts: { - sans: "Rubik", - mono: ["Fira Code", "Fira Mono:400,700"], - }, - }), + sans: 'Rubik', + mono: ['Fira Code', 'Fira Mono:400,700'] + } + }) ], - extractors: [extractorSvelte], -}); + extractors: [extractorSvelte] +}) diff --git a/examples/api/vite.config.js b/examples/api/vite.config.js index 508238eb2..3b34cccd4 100644 --- a/examples/api/vite.config.js +++ b/examples/api/vite.config.js @@ -2,12 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { defineConfig } from "vite"; -import Unocss from "unocss/vite"; -import { svelte } from "@sveltejs/vite-plugin-svelte"; -import process from "process"; +import { defineConfig } from 'vite' +import Unocss from 'unocss/vite' +import { svelte } from '@sveltejs/vite-plugin-svelte' +import process from 'process' -const host = process.env.TAURI_DEV_HOST; +const host = process.env.TAURI_DEV_HOST // https://vitejs.dev/config/ export default defineConfig(async () => { @@ -18,9 +18,9 @@ export default defineConfig(async () => { output: { entryFileNames: `assets/[name].js`, chunkFileNames: `assets/[name].js`, - assetFileNames: `assets/[name].[ext]`, - }, - }, + assetFileNames: `assets/[name].[ext]` + } + } }, server: { host: host || false, @@ -28,14 +28,14 @@ export default defineConfig(async () => { strictPort: true, hmr: host ? { - protocol: "ws", + protocol: 'ws', host, - port: 5183, + port: 5183 } : undefined, fs: { - allow: [".", "../../tooling/api/dist"], - }, - }, - }; -}); + allow: ['.', '../../tooling/api/dist'] + } + } + } +}) diff --git a/package.json b/package.json index 2187ce4f1..6ab87008a 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "scripts": { "build": "pnpm run -r --parallel --filter !plugins-workspace --filter !\"./plugins/*/examples/**\" --filter !\"./examples/*\" build", "lint": "eslint .", - "format": "prettier --write \"./**/*.{cjs,mjs,js,jsx,mts,ts,tsx,html,css,json}\" --ignore-path .prettierignore", - "format-check": "prettier --check \"./**/*.{cjs,mjs,js,jsx,mts,ts,tsx,html,css,json}\" --ignore-path .prettierignore" + "format": "prettier --write .", + "format:check": "prettier --check ." }, "devDependencies": { "@eslint/js": "9.9.1", @@ -31,10 +31,5 @@ }, "engines": { "pnpm": "^9.0.0" - }, - "pnpm": { - "overrides": { - "micromatch@<4.0.8": ">=4.0.8" - } } } diff --git a/plugins/autostart/.gitignore b/plugins/autostart/.gitignore deleted file mode 100644 index b512c09d4..000000000 --- a/plugins/autostart/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules \ No newline at end of file diff --git a/plugins/autostart/Cargo.toml b/plugins/autostart/Cargo.toml index f86fbd3db..5dd503e48 100644 --- a/plugins/autostart/Cargo.toml +++ b/plugins/autostart/Cargo.toml @@ -10,11 +10,11 @@ repository = { workspace = true } links = "tauri-plugin-autostart" [package.metadata.docs.rs] -rustc-args = [ "--cfg", "docsrs" ] -rustdoc-args = [ "--cfg", "docsrs" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] [build-dependencies] -tauri-plugin = { workspace = true, features = [ "build" ] } +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } diff --git a/plugins/autostart/README.md b/plugins/autostart/README.md index 58caac0f3..5855c9892 100644 --- a/plugins/autostart/README.md +++ b/plugins/autostart/README.md @@ -62,13 +62,13 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { enable, isEnabled, disable } from "@tauri-apps/plugin-autostart"; +import { enable, isEnabled, disable } from '@tauri-apps/plugin-autostart' -await enable(); +await enable() -console.log(`registered for autostart? ${await isEnabled()}`); +console.log(`registered for autostart? ${await isEnabled()}`) -disable(); +disable() ``` ## Contributing diff --git a/plugins/autostart/SECURITY.md b/plugins/autostart/SECURITY.md index 67d831fc9..4f09bbacd 100644 --- a/plugins/autostart/SECURITY.md +++ b/plugins/autostart/SECURITY.md @@ -20,4 +20,4 @@ We prefer to receive reports in English. Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). -Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). \ No newline at end of file +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/autostart/guest-js/index.ts b/plugins/autostart/guest-js/index.ts index 81471b74d..fca8344ff 100644 --- a/plugins/autostart/guest-js/index.ts +++ b/plugins/autostart/guest-js/index.ts @@ -2,16 +2,16 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { invoke } from "@tauri-apps/api/core"; +import { invoke } from '@tauri-apps/api/core' export async function isEnabled(): Promise { - return await invoke("plugin:autostart|is_enabled"); + return await invoke('plugin:autostart|is_enabled') } export async function enable(): Promise { - await invoke("plugin:autostart|enable"); + await invoke('plugin:autostart|enable') } export async function disable(): Promise { - await invoke("plugin:autostart|disable"); + await invoke('plugin:autostart|disable') } diff --git a/plugins/autostart/permissions/default.toml b/plugins/autostart/permissions/default.toml index e2f71212e..a2ac766fd 100644 --- a/plugins/autostart/permissions/default.toml +++ b/plugins/autostart/permissions/default.toml @@ -12,8 +12,4 @@ disable the automatic start on boot. """ -permissions = [ - "allow-enable", - "allow-disable", - "allow-is-enabled", -] +permissions = ["allow-enable", "allow-disable", "allow-is-enabled"] diff --git a/plugins/autostart/rollup.config.js b/plugins/autostart/rollup.config.js index 977dfac83..1f349ec8a 100644 --- a/plugins/autostart/rollup.config.js +++ b/plugins/autostart/rollup.config.js @@ -2,6 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { createConfig } from "../../shared/rollup.config.js"; +import { createConfig } from '../../shared/rollup.config.js' -export default createConfig(); +export default createConfig() diff --git a/plugins/barcode-scanner/.gitignore b/plugins/barcode-scanner/.gitignore deleted file mode 100644 index 1b0b469d0..000000000 --- a/plugins/barcode-scanner/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/.tauri diff --git a/plugins/barcode-scanner/Cargo.toml b/plugins/barcode-scanner/Cargo.toml index 8cab6ba65..fde3a2f76 100644 --- a/plugins/barcode-scanner/Cargo.toml +++ b/plugins/barcode-scanner/Cargo.toml @@ -10,12 +10,12 @@ repository = { workspace = true } links = "tauri-plugin-barcode-scanner" [package.metadata.docs.rs] -rustc-args = [ "--cfg", "docsrs" ] -rustdoc-args = [ "--cfg", "docsrs" ] -targets = [ "x86_64-linux-android" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] +targets = ["x86_64-linux-android"] [build-dependencies] -tauri-plugin = { workspace = true, features = [ "build" ] } +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } diff --git a/plugins/barcode-scanner/README.md b/plugins/barcode-scanner/README.md index 57621f282..ee9831301 100644 --- a/plugins/barcode-scanner/README.md +++ b/plugins/barcode-scanner/README.md @@ -60,12 +60,12 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { scan } from "@tauri-apps/plugin-barcode-scanner"; +import { scan } from '@tauri-apps/plugin-barcode-scanner' // `windowed: true` actually sets the webview to transparent // instead of opening a separate view for the camera // make sure your user interface is ready to show what is underneath with a transparent element -scan({ windowed: true, formats: [""] }) +scan({ windowed: true, formats: [''] }) ``` ## Contributing diff --git a/plugins/barcode-scanner/SECURITY.md b/plugins/barcode-scanner/SECURITY.md index 36a863c68..135504ec5 100644 --- a/plugins/barcode-scanner/SECURITY.md +++ b/plugins/barcode-scanner/SECURITY.md @@ -54,7 +54,6 @@ The camera has two modes. The first one is where the user can see the background The second mode allows the developer to assist the user and add a transparent overlay to the image, providing hints or additional information (like a link preview). The overlay could be made non-transparent by the application frontend and as long as the app is open (and in some cases) it could read QR codes in range of the camera lense. - #### Out Of Scope - Exploits in the operating system QR code parsing functionality diff --git a/plugins/barcode-scanner/guest-js/index.ts b/plugins/barcode-scanner/guest-js/index.ts index bf0edf8a5..e8637d111 100644 --- a/plugins/barcode-scanner/guest-js/index.ts +++ b/plugins/barcode-scanner/guest-js/index.ts @@ -5,37 +5,37 @@ import { invoke, requestPermissions as checkPermissions_, - checkPermissions as requestPermissions_, -} from "@tauri-apps/api/core"; + checkPermissions as requestPermissions_ +} from '@tauri-apps/api/core' -export type { PermissionState } from "@tauri-apps/api/core"; +export type { PermissionState } from '@tauri-apps/api/core' export enum Format { - QRCode = "QR_CODE", - UPC_A = "UPC_A", - UPC_E = "UPC_E", - EAN8 = "EAN_8", - EAN13 = "EAN_13", - Code39 = "CODE_39", - Code93 = "CODE_93", - Code128 = "CODE_128", - Codabar = "CODABAR", - ITF = "ITF", - Aztec = "AZTEC", - DataMatrix = "DATA_MATRIX", - PDF417 = "PDF_417", + QRCode = 'QR_CODE', + UPC_A = 'UPC_A', + UPC_E = 'UPC_E', + EAN8 = 'EAN_8', + EAN13 = 'EAN_13', + Code39 = 'CODE_39', + Code93 = 'CODE_93', + Code128 = 'CODE_128', + Codabar = 'CODABAR', + ITF = 'ITF', + Aztec = 'AZTEC', + DataMatrix = 'DATA_MATRIX', + PDF417 = 'PDF_417' } export interface ScanOptions { - cameraDirection?: "back" | "front"; - formats?: Format[]; - windowed?: boolean; + cameraDirection?: 'back' | 'front' + formats?: Format[] + windowed?: boolean } export interface Scanned { - content: string; - format: Format; - bounds: unknown; + content: string + format: Format + bounds: unknown } /** @@ -43,14 +43,14 @@ export interface Scanned { * @param options */ export async function scan(options?: ScanOptions): Promise { - return await invoke("plugin:barcode-scanner|scan", { ...options }); + return await invoke('plugin:barcode-scanner|scan', { ...options }) } /** * Cancel the current scan process. */ export async function cancel(): Promise { - await invoke("plugin:barcode-scanner|cancel"); + await invoke('plugin:barcode-scanner|cancel') } /** @@ -58,8 +58,8 @@ export async function cancel(): Promise { */ export async function checkPermissions(): Promise { return await checkPermissions_<{ camera: PermissionState }>( - "barcode-scanner", - ).then((r) => r.camera); + 'barcode-scanner' + ).then((r) => r.camera) } /** @@ -67,13 +67,13 @@ export async function checkPermissions(): Promise { */ export async function requestPermissions(): Promise { return await requestPermissions_<{ camera: PermissionState }>( - "barcode-scanner", - ).then((r) => r.camera); + 'barcode-scanner' + ).then((r) => r.camera) } /** * Open application settings. Useful if permission was denied and the user must manually enable it. */ export async function openAppSettings(): Promise { - await invoke("plugin:barcode-scanner|open_app_settings"); + await invoke('plugin:barcode-scanner|open_app_settings') } diff --git a/plugins/barcode-scanner/rollup.config.js b/plugins/barcode-scanner/rollup.config.js index 977dfac83..1f349ec8a 100644 --- a/plugins/barcode-scanner/rollup.config.js +++ b/plugins/barcode-scanner/rollup.config.js @@ -2,6 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { createConfig } from "../../shared/rollup.config.js"; +import { createConfig } from '../../shared/rollup.config.js' -export default createConfig(); +export default createConfig() diff --git a/plugins/biometric/.gitignore b/plugins/biometric/.gitignore deleted file mode 100644 index 1b0b469d0..000000000 --- a/plugins/biometric/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/.tauri diff --git a/plugins/biometric/Cargo.toml b/plugins/biometric/Cargo.toml index 23f72eb0d..3135d86b7 100644 --- a/plugins/biometric/Cargo.toml +++ b/plugins/biometric/Cargo.toml @@ -9,12 +9,12 @@ repository = { workspace = true } links = "tauri-plugin-biometric" [package.metadata.docs.rs] -rustc-args = [ "--cfg", "docsrs" ] -rustdoc-args = [ "--cfg", "docsrs" ] -targets = [ "x86_64-linux-android" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] +targets = ["x86_64-linux-android"] [build-dependencies] -tauri-plugin = { workspace = true, features = [ "build" ] } +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } diff --git a/plugins/biometric/README.md b/plugins/biometric/README.md index a7ce11390..bc4708c31 100644 --- a/plugins/biometric/README.md +++ b/plugins/biometric/README.md @@ -62,8 +62,8 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { authenticate } from "@tauri-apps/plugin-biometric"; -await authenticate('Open your wallet'); +import { authenticate } from '@tauri-apps/plugin-biometric' +await authenticate('Open your wallet') ``` ## Contributing diff --git a/plugins/biometric/SECURITY.md b/plugins/biometric/SECURITY.md index 67d831fc9..4f09bbacd 100644 --- a/plugins/biometric/SECURITY.md +++ b/plugins/biometric/SECURITY.md @@ -20,4 +20,4 @@ We prefer to receive reports in English. Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). -Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). \ No newline at end of file +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/biometric/guest-js/index.ts b/plugins/biometric/guest-js/index.ts index 3ff26d0ba..5c3eb8df2 100644 --- a/plugins/biometric/guest-js/index.ts +++ b/plugins/biometric/guest-js/index.ts @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { invoke } from "@tauri-apps/api/core"; +import { invoke } from '@tauri-apps/api/core' export enum BiometryType { None = 0, @@ -11,39 +11,39 @@ export enum BiometryType { // Apple FaceID or Android face authentication FaceID = 2, // Android iris authentication - Iris = 3, + Iris = 3 } export interface Status { - isAvailable: boolean; - biometryType: BiometryType; - error?: string; + isAvailable: boolean + biometryType: BiometryType + error?: string errorCode?: - | "appCancel" - | "authenticationFailed" - | "invalidContext" - | "notInteractive" - | "passcodeNotSet" - | "systemCancel" - | "userCancel" - | "userFallback" - | "biometryLockout" - | "biometryNotAvailable" - | "biometryNotEnrolled"; + | 'appCancel' + | 'authenticationFailed' + | 'invalidContext' + | 'notInteractive' + | 'passcodeNotSet' + | 'systemCancel' + | 'userCancel' + | 'userFallback' + | 'biometryLockout' + | 'biometryNotAvailable' + | 'biometryNotEnrolled' } export interface AuthOptions { - allowDeviceCredential?: boolean; - cancelTitle?: string; + allowDeviceCredential?: boolean + cancelTitle?: string // iOS options - fallbackTitle?: string; + fallbackTitle?: string // android options - title?: string; - subtitle?: string; - confirmationRequired?: boolean; - maxAttemps?: number; + title?: string + subtitle?: string + confirmationRequired?: boolean + maxAttemps?: number } /** @@ -51,7 +51,7 @@ export interface AuthOptions { * @returns a promise resolving to an object containing all the information about the status of the biometry. */ export async function checkStatus(): Promise { - return await invoke("plugin:biometric|status"); + return await invoke('plugin:biometric|status') } /** @@ -68,10 +68,10 @@ export async function checkStatus(): Promise { */ export async function authenticate( reason: string, - options?: AuthOptions, + options?: AuthOptions ): Promise { - await invoke("plugin:biometric|authenticate", { + await invoke('plugin:biometric|authenticate', { reason, - ...options, - }); + ...options + }) } diff --git a/plugins/biometric/permissions/default.toml b/plugins/biometric/permissions/default.toml index f50061b73..651990efe 100644 --- a/plugins/biometric/permissions/default.toml +++ b/plugins/biometric/permissions/default.toml @@ -10,7 +10,4 @@ It allows acccess to all biometric commands. """ -permissions = [ - "allow-authenticate", - "allow-status", -] +permissions = ["allow-authenticate", "allow-status"] diff --git a/plugins/biometric/rollup.config.js b/plugins/biometric/rollup.config.js index 977dfac83..1f349ec8a 100644 --- a/plugins/biometric/rollup.config.js +++ b/plugins/biometric/rollup.config.js @@ -2,6 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { createConfig } from "../../shared/rollup.config.js"; +import { createConfig } from '../../shared/rollup.config.js' -export default createConfig(); +export default createConfig() diff --git a/plugins/cli/Cargo.toml b/plugins/cli/Cargo.toml index 3e493b9c1..eff2b6f26 100644 --- a/plugins/cli/Cargo.toml +++ b/plugins/cli/Cargo.toml @@ -10,11 +10,11 @@ repository = { workspace = true } links = "tauri-plugin-cli" [package.metadata.docs.rs] -rustc-args = [ "--cfg", "docsrs" ] -rustdoc-args = [ "--cfg", "docsrs" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] [build-dependencies] -tauri-plugin = { workspace = true, features = [ "build" ] } +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } diff --git a/plugins/cli/README.md b/plugins/cli/README.md index b186f3590..362597b50 100644 --- a/plugins/cli/README.md +++ b/plugins/cli/README.md @@ -67,16 +67,16 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { getMatches } from "@tauri-apps/plugin-cli"; -const matches = await getMatches(); -if (matches.subcommand?.name === "run") { +import { getMatches } from '@tauri-apps/plugin-cli' +const matches = await getMatches() +if (matches.subcommand?.name === 'run') { // `./your-app run $ARGS` was executed - const args = matches.subcommand?.matches.args; - if ("debug" in args) { + const args = matches.subcommand?.matches.args + if ('debug' in args) { // `./your-app run --debug` was executed } } else { - const args = matches.args; + const args = matches.args // `./your-app $ARGS` was executed } ``` diff --git a/plugins/cli/SECURITY.md b/plugins/cli/SECURITY.md index 67d831fc9..4f09bbacd 100644 --- a/plugins/cli/SECURITY.md +++ b/plugins/cli/SECURITY.md @@ -20,4 +20,4 @@ We prefer to receive reports in English. Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). -Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). \ No newline at end of file +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/cli/guest-js/index.ts b/plugins/cli/guest-js/index.ts index 0ab7868e5..7a7f4acf3 100644 --- a/plugins/cli/guest-js/index.ts +++ b/plugins/cli/guest-js/index.ts @@ -8,7 +8,7 @@ * @module */ -import { invoke } from "@tauri-apps/api/core"; +import { invoke } from '@tauri-apps/api/core' /** * @since 2.0.0 @@ -19,27 +19,27 @@ interface ArgMatch { * boolean if flag * string[] or null if takes multiple values */ - value: string | boolean | string[] | null; + value: string | boolean | string[] | null /** * Number of occurrences */ - occurrences: number; + occurrences: number } /** * @since 2.0.0 */ interface SubcommandMatch { - name: string; - matches: CliMatches; + name: string + matches: CliMatches } /** * @since 2.0.0 */ interface CliMatches { - args: Record; - subcommand: SubcommandMatch | null; + args: Record + subcommand: SubcommandMatch | null } /** @@ -64,9 +64,9 @@ interface CliMatches { * @since 2.0.0 */ async function getMatches(): Promise { - return await invoke("plugin:cli|cli_matches"); + return await invoke('plugin:cli|cli_matches') } -export type { ArgMatch, SubcommandMatch, CliMatches }; +export type { ArgMatch, SubcommandMatch, CliMatches } -export { getMatches }; +export { getMatches } diff --git a/plugins/cli/rollup.config.js b/plugins/cli/rollup.config.js index 977dfac83..1f349ec8a 100644 --- a/plugins/cli/rollup.config.js +++ b/plugins/cli/rollup.config.js @@ -2,6 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { createConfig } from "../../shared/rollup.config.js"; +import { createConfig } from '../../shared/rollup.config.js' -export default createConfig(); +export default createConfig() diff --git a/plugins/clipboard-manager/.gitignore b/plugins/clipboard-manager/.gitignore deleted file mode 100644 index 1b0b469d0..000000000 --- a/plugins/clipboard-manager/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/.tauri diff --git a/plugins/clipboard-manager/Cargo.toml b/plugins/clipboard-manager/Cargo.toml index 96ee1d229..36dc67943 100644 --- a/plugins/clipboard-manager/Cargo.toml +++ b/plugins/clipboard-manager/Cargo.toml @@ -10,12 +10,12 @@ repository = { workspace = true } links = "tauri-plugin-clipboard-manager" [package.metadata.docs.rs] -rustc-args = [ "--cfg", "docsrs" ] -rustdoc-args = [ "--cfg", "docsrs" ] -targets = [ "x86_64-unknown-linux-gnu", "x86_64-linux-android" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] +targets = ["x86_64-unknown-linux-gnu", "x86_64-linux-android"] [build-dependencies] -tauri-plugin = { workspace = true, features = [ "build" ] } +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } diff --git a/plugins/clipboard-manager/README.md b/plugins/clipboard-manager/README.md index f1b3d327d..98ee2da0b 100644 --- a/plugins/clipboard-manager/README.md +++ b/plugins/clipboard-manager/README.md @@ -60,9 +60,15 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { writeText, readText, writeHtml, readHtml, clear } from "@tauri-apps/plugin-clipboard-manager"; -await writeText("Tauri is awesome!"); -assert(await readText(), "Tauri is awesome!"); +import { + writeText, + readText, + writeHtml, + readHtml, + clear +} from '@tauri-apps/plugin-clipboard-manager' +await writeText('Tauri is awesome!') +assert(await readText(), 'Tauri is awesome!') ``` ## Contributing diff --git a/plugins/clipboard-manager/SECURITY.md b/plugins/clipboard-manager/SECURITY.md index 67d831fc9..4f09bbacd 100644 --- a/plugins/clipboard-manager/SECURITY.md +++ b/plugins/clipboard-manager/SECURITY.md @@ -20,4 +20,4 @@ We prefer to receive reports in English. Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). -Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). \ No newline at end of file +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/clipboard-manager/guest-js/index.ts b/plugins/clipboard-manager/guest-js/index.ts index ad261cbe6..f09754e65 100644 --- a/plugins/clipboard-manager/guest-js/index.ts +++ b/plugins/clipboard-manager/guest-js/index.ts @@ -8,8 +8,8 @@ * @module */ -import { invoke } from "@tauri-apps/api/core"; -import { Image, transformImage } from "@tauri-apps/api/image"; +import { invoke } from '@tauri-apps/api/core' +import { Image, transformImage } from '@tauri-apps/api/image' /** * Writes plain text to the clipboard. @@ -26,12 +26,12 @@ import { Image, transformImage } from "@tauri-apps/api/image"; */ async function writeText( text: string, - opts?: { label?: string }, + opts?: { label?: string } ): Promise { - await invoke("plugin:clipboard-manager|write_text", { + await invoke('plugin:clipboard-manager|write_text', { label: opts?.label, - text, - }); + text + }) } /** @@ -44,7 +44,7 @@ async function writeText( * @since 2.0.0 */ async function readText(): Promise { - return await invoke("plugin:clipboard-manager|read_text"); + return await invoke('plugin:clipboard-manager|read_text') } /** @@ -66,11 +66,11 @@ async function readText(): Promise { * @since 2.0.0 */ async function writeImage( - image: string | Image | Uint8Array | ArrayBuffer | number[], + image: string | Image | Uint8Array | ArrayBuffer | number[] ): Promise { - await invoke("plugin:clipboard-manager|write_image", { - image: transformImage(image), - }); + await invoke('plugin:clipboard-manager|write_image', { + image: transformImage(image) + }) } /** @@ -86,9 +86,9 @@ async function writeImage( * @since 2.0.0 */ async function readImage(): Promise { - return await invoke("plugin:clipboard-manager|read_image").then( - (rid) => new Image(rid), - ); + return await invoke('plugin:clipboard-manager|read_image').then( + (rid) => new Image(rid) + ) } /** @@ -106,10 +106,10 @@ async function readImage(): Promise { * @since 2.0.0 */ async function writeHtml(html: string, altHtml?: string): Promise { - await invoke("plugin:clipboard-manager|write_html", { + await invoke('plugin:clipboard-manager|write_html', { html, - altHtml, - }); + altHtml + }) } /** @@ -122,7 +122,7 @@ async function writeHtml(html: string, altHtml?: string): Promise { * @since 2.0.0 */ async function clear(): Promise { - await invoke("plugin:clipboard-manager|clear"); + await invoke('plugin:clipboard-manager|clear') } -export { writeText, readText, writeHtml, clear, readImage, writeImage }; +export { writeText, readText, writeHtml, clear, readImage, writeImage } diff --git a/plugins/clipboard-manager/rollup.config.js b/plugins/clipboard-manager/rollup.config.js index 977dfac83..1f349ec8a 100644 --- a/plugins/clipboard-manager/rollup.config.js +++ b/plugins/clipboard-manager/rollup.config.js @@ -2,6 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { createConfig } from "../../shared/rollup.config.js"; +import { createConfig } from '../../shared/rollup.config.js' -export default createConfig(); +export default createConfig() diff --git a/plugins/deep-link/.gitignore b/plugins/deep-link/.gitignore deleted file mode 100644 index 1b0b469d0..000000000 --- a/plugins/deep-link/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/.tauri diff --git a/plugins/deep-link/.test-server/server.js b/plugins/deep-link/.test-server/server.js index 6eee44e49..0e2fec507 100644 --- a/plugins/deep-link/.test-server/server.js +++ b/plugins/deep-link/.test-server/server.js @@ -2,26 +2,26 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import http from "http"; -import fs from "fs"; +import http from 'http' +import fs from 'fs' -const hostname = "localhost"; -const port = 8080; +const hostname = 'localhost' +const port = 8080 const server = http.createServer(function (req, res) { - console.log(req.url); - if (req.url == "/.well-known/apple-app-site-association") { + console.log(req.url) + if (req.url == '/.well-known/apple-app-site-association') { const association = fs.readFileSync( - ".well-known/apple-app-site-association", - ); - res.writeHead(200, { "Content-Type": "application/json" }); - res.end(association); + '.well-known/apple-app-site-association' + ) + res.writeHead(200, { 'Content-Type': 'application/json' }) + res.end(association) } else { - res.writeHead(404); - res.end("404 NOT FOUND"); + res.writeHead(404) + res.end('404 NOT FOUND') } -}); +}) server.listen(port, hostname, () => { - console.log("Server started on port", port); -}); + console.log('Server started on port', port) +}) diff --git a/plugins/deep-link/Cargo.toml b/plugins/deep-link/Cargo.toml index 2413c14b5..8f4162fba 100644 --- a/plugins/deep-link/Cargo.toml +++ b/plugins/deep-link/Cargo.toml @@ -10,15 +10,15 @@ repository = { workspace = true } links = "tauri-plugin-deep-link" [package.metadata.docs.rs] -rustc-args = [ "--cfg", "docsrs" ] -rustdoc-args = [ "--cfg", "docsrs" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] targets = ["x86_64-linux-android"] [build-dependencies] serde = { workspace = true } serde_json = { workspace = true } tauri-utils = { workspace = true } -tauri-plugin = { workspace = true, features = [ "build" ] } +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } diff --git a/plugins/deep-link/README.md b/plugins/deep-link/README.md index 6080405cb..394f4ece7 100644 --- a/plugins/deep-link/README.md +++ b/plugins/deep-link/README.md @@ -139,10 +139,10 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { onOpenUrl } from "@tauri-apps/plugin-deep-link"; +import { onOpenUrl } from '@tauri-apps/plugin-deep-link' await onOpenUrl((urls) => { - console.log("deep link:", urls); -}); + console.log('deep link:', urls) +}) ``` Note that the Plugin will only emit events on macOS, iOS and Android. On Windows and Linux the OS will spawn a new instance of your app with the URL as a CLI argument. If you want your app to behave on Windows & Linux similar to the other platforms you can use the [single-instance](../single-instance/) plugin. diff --git a/plugins/deep-link/SECURITY.md b/plugins/deep-link/SECURITY.md index 67d831fc9..4f09bbacd 100644 --- a/plugins/deep-link/SECURITY.md +++ b/plugins/deep-link/SECURITY.md @@ -20,4 +20,4 @@ We prefer to receive reports in English. Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). -Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). \ No newline at end of file +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/deep-link/examples/app/src-tauri/gen/apple/project.yml b/plugins/deep-link/examples/app/src-tauri/gen/apple/project.yml index 68eb0f4c5..c924ca77b 100644 --- a/plugins/deep-link/examples/app/src-tauri/gen/apple/project.yml +++ b/plugins/deep-link/examples/app/src-tauri/gen/apple/project.yml @@ -68,7 +68,7 @@ targets: base: ENABLE_BITCODE: false ARCHS: [arm64, arm64-sim] - VALID_ARCHS: arm64 arm64-sim + VALID_ARCHS: arm64 arm64-sim LIBRARY_SEARCH_PATHS[arch=x86_64]: $(inherited) $(PROJECT_DIR)/Externals/x86_64/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) LIBRARY_SEARCH_PATHS[arch=arm64]: $(inherited) $(PROJECT_DIR)/Externals/arm64/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) LIBRARY_SEARCH_PATHS[arch=arm64-sim]: $(inherited) $(PROJECT_DIR)/Externals/arm64-sim/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) @@ -93,4 +93,4 @@ targets: outputFiles: - $(SRCROOT)/Externals/x86_64/${CONFIGURATION}/libapp.a - $(SRCROOT)/Externals/arm64/${CONFIGURATION}/libapp.a - - $(SRCROOT)/Externals/arm64-sim/${CONFIGURATION}/libapp.a \ No newline at end of file + - $(SRCROOT)/Externals/arm64-sim/${CONFIGURATION}/libapp.a diff --git a/plugins/deep-link/examples/app/src-tauri/server.js b/plugins/deep-link/examples/app/src-tauri/server.js index c86866313..24a6ac6f8 100644 --- a/plugins/deep-link/examples/app/src-tauri/server.js +++ b/plugins/deep-link/examples/app/src-tauri/server.js @@ -2,30 +2,30 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import http from "http"; -import fs from "fs"; -import path from "path"; -import * as url from "url"; -const __dirname = url.fileURLToPath(new URL(".", import.meta.url)); +import http from 'http' +import fs from 'fs' +import path from 'path' +import * as url from 'url' +const __dirname = url.fileURLToPath(new URL('.', import.meta.url)) -const port = 8125; +const port = 8125 http .createServer(function (request, response) { - if (request.url === "/.well-known/apple-app-site-association") { + if (request.url === '/.well-known/apple-app-site-association') { // eslint-disable-next-line fs.readFile( - path.resolve(__dirname, "apple-app-site-association"), + path.resolve(__dirname, 'apple-app-site-association'), function (_error, content) { - response.writeHead(200); - response.end(content, "utf-8"); - }, - ); + response.writeHead(200) + response.end(content, 'utf-8') + } + ) } else { - response.writeHead(404); - response.end(); + response.writeHead(404) + response.end() } }) - .listen(port); + .listen(port) -console.log(`Server running at http://127.0.0.1:${port}/`); +console.log(`Server running at http://127.0.0.1:${port}/`) diff --git a/plugins/deep-link/examples/app/src/main.ts b/plugins/deep-link/examples/app/src/main.ts index f87a6afd6..550e0aaa1 100644 --- a/plugins/deep-link/examples/app/src/main.ts +++ b/plugins/deep-link/examples/app/src/main.ts @@ -4,35 +4,35 @@ import { onOpenUrl, - getCurrent as getCurrentDeepLinkUrls, -} from "@tauri-apps/plugin-deep-link"; + getCurrent as getCurrentDeepLinkUrls +} from '@tauri-apps/plugin-deep-link' function handler(urls: string[]) { - console.log(urls); + console.log(urls) // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const updateIntentEl = document.querySelector("#event-intent")!; - updateIntentEl.textContent = JSON.stringify(urls); + const updateIntentEl = document.querySelector('#event-intent')! + updateIntentEl.textContent = JSON.stringify(urls) } -window.addEventListener("DOMContentLoaded", () => { - onOpenUrl(handler); +window.addEventListener('DOMContentLoaded', () => { + onOpenUrl(handler) - document.querySelector("#intent-form")?.addEventListener("submit", (e) => { - e.preventDefault(); + document.querySelector('#intent-form')?.addEventListener('submit', (e) => { + e.preventDefault() getCurrentDeepLinkUrls() .then((res) => { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const updateIntentEl = document.querySelector("#update-intent")!; - updateIntentEl.textContent = res ? JSON.stringify(res) : "none"; + const updateIntentEl = document.querySelector('#update-intent')! + updateIntentEl.textContent = res ? JSON.stringify(res) : 'none' }) - .catch(console.error); - }); + .catch(console.error) + }) getCurrentDeepLinkUrls() .then((res) => { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const initialIntentEl = document.querySelector("#initial-intent")!; - initialIntentEl.textContent = res ? JSON.stringify(res) : "none"; + const initialIntentEl = document.querySelector('#initial-intent')! + initialIntentEl.textContent = res ? JSON.stringify(res) : 'none' }) - .catch(console.error); -}); + .catch(console.error) +}) diff --git a/plugins/deep-link/examples/app/vite.config.ts b/plugins/deep-link/examples/app/vite.config.ts index 82cc08858..b54dc99a7 100644 --- a/plugins/deep-link/examples/app/vite.config.ts +++ b/plugins/deep-link/examples/app/vite.config.ts @@ -2,9 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { defineConfig } from "vite"; +import { defineConfig } from 'vite' -const host = process.env.TAURI_DEV_HOST; +const host = process.env.TAURI_DEV_HOST // https://vitejs.dev/config/ export default defineConfig({ @@ -17,22 +17,22 @@ export default defineConfig({ port: 1420, hmr: host ? { - protocol: "ws", + protocol: 'ws', host, - port: 1421, + port: 1421 } : undefined, - strictPort: true, + strictPort: true }, // to make use of `TAURI_DEBUG` and other env variables // https://tauri.studio/v1/api/config#buildconfig.beforedevcommand - envPrefix: ["VITE_", "TAURI_"], + envPrefix: ['VITE_', 'TAURI_'], build: { // Tauri supports es2021 - target: process.env.TAURI_PLATFORM == "windows" ? "chrome105" : "safari13", + target: process.env.TAURI_PLATFORM == 'windows' ? 'chrome105' : 'safari13', // don't minify for debug builds - minify: !process.env.TAURI_DEBUG ? "esbuild" : false, + minify: !process.env.TAURI_DEBUG ? 'esbuild' : false, // produce sourcemaps for debug builds - sourcemap: !!process.env.TAURI_DEBUG, - }, -}); + sourcemap: !!process.env.TAURI_DEBUG + } +}) diff --git a/plugins/deep-link/guest-js/index.ts b/plugins/deep-link/guest-js/index.ts index 8e78a66e9..e75c9d76c 100644 --- a/plugins/deep-link/guest-js/index.ts +++ b/plugins/deep-link/guest-js/index.ts @@ -2,8 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { invoke } from "@tauri-apps/api/core"; -import { type UnlistenFn, listen } from "@tauri-apps/api/event"; +import { invoke } from '@tauri-apps/api/core' +import { type UnlistenFn, listen } from '@tauri-apps/api/event' /** * Get the current URLs that triggered the deep link. Use this on app load to check whether your app was started via a deep link. @@ -19,7 +19,7 @@ import { type UnlistenFn, listen } from "@tauri-apps/api/event"; * @since 2.0.0 */ export async function getCurrent(): Promise { - return await invoke("plugin:deep-link|get_current"); + return await invoke('plugin:deep-link|get_current') } /** @@ -38,7 +38,7 @@ export async function getCurrent(): Promise { * @since 2.0.0 */ export async function register(protocol: string): Promise { - return await invoke("plugin:deep-link|register", { protocol }); + return await invoke('plugin:deep-link|register', { protocol }) } /** @@ -57,7 +57,7 @@ export async function register(protocol: string): Promise { * @since 2.0.0 */ export async function unregister(protocol: string): Promise { - return await invoke("plugin:deep-link|unregister", { protocol }); + return await invoke('plugin:deep-link|unregister', { protocol }) } /** @@ -76,7 +76,7 @@ export async function unregister(protocol: string): Promise { * @since 2.0.0 */ export async function isRegistered(protocol: string): Promise { - return await invoke("plugin:deep-link|is_registered", { protocol }); + return await invoke('plugin:deep-link|is_registered', { protocol }) } /** @@ -95,14 +95,14 @@ export async function isRegistered(protocol: string): Promise { * @since 2.0.0 */ export async function onOpenUrl( - handler: (urls: string[]) => void, + handler: (urls: string[]) => void ): Promise { - const current = await getCurrent(); + const current = await getCurrent() if (current) { - handler(current); + handler(current) } - return await listen("deep-link://new-url", (event) => { - handler(event.payload); - }); + return await listen('deep-link://new-url', (event) => { + handler(event.payload) + }) } diff --git a/plugins/deep-link/rollup.config.js b/plugins/deep-link/rollup.config.js index 977dfac83..1f349ec8a 100644 --- a/plugins/deep-link/rollup.config.js +++ b/plugins/deep-link/rollup.config.js @@ -2,6 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { createConfig } from "../../shared/rollup.config.js"; +import { createConfig } from '../../shared/rollup.config.js' -export default createConfig(); +export default createConfig() diff --git a/plugins/dialog/.gitignore b/plugins/dialog/.gitignore deleted file mode 100644 index 24ae12805..000000000 --- a/plugins/dialog/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.tauri diff --git a/plugins/dialog/Cargo.toml b/plugins/dialog/Cargo.toml index e08c88c00..378b66da8 100644 --- a/plugins/dialog/Cargo.toml +++ b/plugins/dialog/Cargo.toml @@ -10,15 +10,15 @@ repository = { workspace = true } links = "tauri-plugin-dialog" [package.metadata.docs.rs] -rustc-args = [ "--cfg", "docsrs" ] -rustdoc-args = [ "--cfg", "docsrs" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] targets = ["x86_64-unknown-linux-gnu", "x86_64-linux-android"] [build-dependencies] -tauri-plugin = { workspace = true, features = [ "build" ] } +tauri-plugin = { workspace = true, features = ["build"] } [dev-dependencies] -tauri = { workspace = true, features = [ "wry" ] } +tauri = { workspace = true, features = ["wry"] } [dependencies] serde = { workspace = true } diff --git a/plugins/dialog/SECURITY.md b/plugins/dialog/SECURITY.md index 67d831fc9..4f09bbacd 100644 --- a/plugins/dialog/SECURITY.md +++ b/plugins/dialog/SECURITY.md @@ -20,4 +20,4 @@ We prefer to receive reports in English. Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). -Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). \ No newline at end of file +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/dialog/guest-js/index.ts b/plugins/dialog/guest-js/index.ts index 9624718d6..a6301ebee 100644 --- a/plugins/dialog/guest-js/index.ts +++ b/plugins/dialog/guest-js/index.ts @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { invoke } from "@tauri-apps/api/core"; +import { invoke } from '@tauri-apps/api/core' /** * Extension filters for the file dialog. @@ -11,7 +11,7 @@ import { invoke } from "@tauri-apps/api/core"; */ interface DialogFilter { /** Filter name. */ - name: string; + name: string /** * Extensions to filter, without a `.` prefix. * @example @@ -19,7 +19,7 @@ interface DialogFilter { * extensions: ['svg', 'png'] * ``` */ - extensions: string[]; + extensions: string[] } /** @@ -29,9 +29,9 @@ interface DialogFilter { */ interface OpenDialogOptions { /** The title of the dialog window (desktop only). */ - title?: string; + title?: string /** The filters of the dialog. */ - filters?: DialogFilter[]; + filters?: DialogFilter[] /** * Initial directory or file path. * If it's a directory path, the dialog interface will change to that folder. @@ -40,18 +40,18 @@ interface OpenDialogOptions { * On mobile the file name is always used on the dialog's file name input. * If not provided, Android uses `(invalid).txt` as default file name. */ - defaultPath?: string; + defaultPath?: string /** Whether the dialog allows multiple selection or not. */ - multiple?: boolean; + multiple?: boolean /** Whether the dialog is a directory selection or not. */ - directory?: boolean; + directory?: boolean /** * If `directory` is true, indicates that it will be read recursively later. * Defines whether subdirectories will be allowed on the scope or not. */ - recursive?: boolean; + recursive?: boolean /** Whether to allow creating directories in the dialog. Enabled by default. **macOS Only** */ - canCreateDirectories?: boolean; + canCreateDirectories?: boolean } /** @@ -61,9 +61,9 @@ interface OpenDialogOptions { */ interface SaveDialogOptions { /** The title of the dialog window (desktop only). */ - title?: string; + title?: string /** The filters of the dialog. */ - filters?: DialogFilter[]; + filters?: DialogFilter[] /** * Initial directory or file path. * If it's a directory path, the dialog interface will change to that folder. @@ -72,9 +72,9 @@ interface SaveDialogOptions { * On mobile the file name is always used on the dialog's file name input. * If not provided, Android uses `(invalid).txt` as default file name. */ - defaultPath?: string; + defaultPath?: string /** Whether to allow creating directories in the dialog. Enabled by default. **macOS Only** */ - canCreateDirectories?: boolean; + canCreateDirectories?: boolean } /** @@ -82,31 +82,31 @@ interface SaveDialogOptions { */ interface MessageDialogOptions { /** The title of the dialog. Defaults to the app name. */ - title?: string; + title?: string /** The kind of the dialog. Defaults to `info`. */ - kind?: "info" | "warning" | "error"; + kind?: 'info' | 'warning' | 'error' /** The label of the confirm button. */ - okLabel?: string; + okLabel?: string } interface ConfirmDialogOptions { /** The title of the dialog. Defaults to the app name. */ - title?: string; + title?: string /** The kind of the dialog. Defaults to `info`. */ - kind?: "info" | "warning" | "error"; + kind?: 'info' | 'warning' | 'error' /** The label of the confirm button. */ - okLabel?: string; + okLabel?: string /** The label of the cancel button. */ - cancelLabel?: string; + cancelLabel?: string } -type OpenDialogReturn = T["directory"] extends true - ? T["multiple"] extends true +type OpenDialogReturn = T['directory'] extends true + ? T['multiple'] extends true ? string[] | null : string | null - : T["multiple"] extends true + : T['multiple'] extends true ? string[] | null - : string | null; + : string | null /** * Open a file/directory selection dialog. @@ -161,13 +161,13 @@ type OpenDialogReturn = T["directory"] extends true * @since 2.0.0 */ async function open( - options: T = {} as T, + options: T = {} as T ): Promise> { - if (typeof options === "object") { - Object.freeze(options); + if (typeof options === 'object') { + Object.freeze(options) } - return await invoke("plugin:dialog|open", { options }); + return await invoke('plugin:dialog|open', { options }) } /** @@ -195,11 +195,11 @@ async function open( * @since 2.0.0 */ async function save(options: SaveDialogOptions = {}): Promise { - if (typeof options === "object") { - Object.freeze(options); + if (typeof options === 'object') { + Object.freeze(options) } - return await invoke("plugin:dialog|save", { options }); + return await invoke('plugin:dialog|save', { options }) } /** @@ -221,15 +221,15 @@ async function save(options: SaveDialogOptions = {}): Promise { */ async function message( message: string, - options?: string | MessageDialogOptions, + options?: string | MessageDialogOptions ): Promise { - const opts = typeof options === "string" ? { title: options } : options; - await invoke("plugin:dialog|message", { + const opts = typeof options === 'string' ? { title: options } : options + await invoke('plugin:dialog|message', { message: message.toString(), title: opts?.title?.toString(), kind: opts?.kind, - okButtonLabel: opts?.okLabel?.toString(), - }); + okButtonLabel: opts?.okLabel?.toString() + }) } /** @@ -250,16 +250,16 @@ async function message( */ async function ask( message: string, - options?: string | ConfirmDialogOptions, + options?: string | ConfirmDialogOptions ): Promise { - const opts = typeof options === "string" ? { title: options } : options; - return await invoke("plugin:dialog|ask", { + const opts = typeof options === 'string' ? { title: options } : options + return await invoke('plugin:dialog|ask', { message: message.toString(), title: opts?.title?.toString(), kind: opts?.kind, - okButtonLabel: opts?.okLabel?.toString() ?? "Yes", - cancelButtonLabel: opts?.cancelLabel?.toString() ?? "No", - }); + okButtonLabel: opts?.okLabel?.toString() ?? 'Yes', + cancelButtonLabel: opts?.cancelLabel?.toString() ?? 'No' + }) } /** @@ -280,16 +280,16 @@ async function ask( */ async function confirm( message: string, - options?: string | ConfirmDialogOptions, + options?: string | ConfirmDialogOptions ): Promise { - const opts = typeof options === "string" ? { title: options } : options; - return await invoke("plugin:dialog|confirm", { + const opts = typeof options === 'string' ? { title: options } : options + return await invoke('plugin:dialog|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() ?? 'Ok', + cancelButtonLabel: opts?.cancelLabel?.toString() ?? 'Cancel' + }) } export type { @@ -298,7 +298,7 @@ export type { OpenDialogReturn, SaveDialogOptions, MessageDialogOptions, - ConfirmDialogOptions, -}; + ConfirmDialogOptions +} -export { open, save, message, ask, confirm }; +export { open, save, message, ask, confirm } diff --git a/plugins/dialog/guest-js/init.ts b/plugins/dialog/guest-js/init.ts index 7936d2cd6..520a469a7 100644 --- a/plugins/dialog/guest-js/init.ts +++ b/plugins/dialog/guest-js/init.ts @@ -2,17 +2,17 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { invoke } from "@tauri-apps/api/core"; +import { invoke } from '@tauri-apps/api/core' window.alert = function (message: string) { - void invoke("plugin:dialog|message", { - message: message.toString(), - }); -}; + void invoke('plugin:dialog|message', { + message: message.toString() + }) +} // @ts-expect-error tauri does not have sync IPC :( window.confirm = async function (message: string) { - return await invoke("plugin:dialog|confirm", { - message: message.toString(), - }); -}; + return await invoke('plugin:dialog|confirm', { + message: message.toString() + }) +} diff --git a/plugins/dialog/permissions/default.toml b/plugins/dialog/permissions/default.toml index 59265f546..cc936d901 100644 --- a/plugins/dialog/permissions/default.toml +++ b/plugins/dialog/permissions/default.toml @@ -12,9 +12,9 @@ All dialog types are enabled. """ permissions = [ - "allow-ask", - "allow-confirm", - "allow-message", - "allow-save", - "allow-open", + "allow-ask", + "allow-confirm", + "allow-message", + "allow-save", + "allow-open", ] diff --git a/plugins/dialog/rollup.config.js b/plugins/dialog/rollup.config.js index 0aed70d64..a7dbd4f69 100644 --- a/plugins/dialog/rollup.config.js +++ b/plugins/dialog/rollup.config.js @@ -2,21 +2,21 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { createConfig } from "../../shared/rollup.config.js"; -import { nodeResolve } from "@rollup/plugin-node-resolve"; -import typescript from "@rollup/plugin-typescript"; -import terser from "@rollup/plugin-terser"; +import { createConfig } from '../../shared/rollup.config.js' +import { nodeResolve } from '@rollup/plugin-node-resolve' +import typescript from '@rollup/plugin-typescript' +import terser from '@rollup/plugin-terser' export default createConfig({ additionalConfigs: { - input: "guest-js/init.ts", + input: 'guest-js/init.ts', output: { - file: "src/init-iife.js", - format: "iife", + file: 'src/init-iife.js', + format: 'iife' }, plugins: [typescript(), terser(), nodeResolve()], onwarn: (warning) => { - throw Object.assign(new Error(), warning); - }, - }, -}); + throw Object.assign(new Error(), warning) + } + } +}) diff --git a/plugins/fs/.gitignore b/plugins/fs/.gitignore deleted file mode 100644 index b512c09d4..000000000 --- a/plugins/fs/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules \ No newline at end of file diff --git a/plugins/fs/Cargo.toml b/plugins/fs/Cargo.toml index 07aa09ae7..b5ca8988c 100644 --- a/plugins/fs/Cargo.toml +++ b/plugins/fs/Cargo.toml @@ -10,11 +10,11 @@ repository = { workspace = true } links = "tauri-plugin-fs" [package.metadata.docs.rs] -rustc-args = [ "--cfg", "docsrs" ] -rustdoc-args = [ "--cfg", "docsrs" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] [build-dependencies] -tauri-plugin = { workspace = true, features = [ "build" ] } +tauri-plugin = { workspace = true, features = ["build"] } schemars = { workspace = true } serde = { workspace = true } diff --git a/plugins/fs/README.md b/plugins/fs/README.md index 70084bfdd..8ced39c46 100644 --- a/plugins/fs/README.md +++ b/plugins/fs/README.md @@ -60,9 +60,9 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { metadata } from "@tauri-apps/plugin-fs"; +import { metadata } from '@tauri-apps/plugin-fs' -await metadata("/path/to/file"); +await metadata('/path/to/file') ``` ## Contributing diff --git a/plugins/fs/SECURITY.md b/plugins/fs/SECURITY.md index 1adc7ebb2..838ed6705 100644 --- a/plugins/fs/SECURITY.md +++ b/plugins/fs/SECURITY.md @@ -36,7 +36,6 @@ the restrictions imposed by the scope. The scope is defined at compile time in the used permissions but the user or application developer can grant or revoke access to specific files or folders at runtime by modifying the scope state through the runtime authority, if configured during plugin initialization. - ### Security Assumptions - The filesystem access is limited by user permissions @@ -44,7 +43,6 @@ The scope is defined at compile time in the used permissions but the user or app - The scoping mechanism of the Tauri `fs` commands work as intended and has no bypasses - The user or application developer can grant or revoke access to specific files at runtime by modifying the scope - #### Out Of Scope - Exploits in underlying filesystems diff --git a/plugins/fs/guest-js/index.ts b/plugins/fs/guest-js/index.ts index 718a30cab..bfc018afb 100644 --- a/plugins/fs/guest-js/index.ts +++ b/plugins/fs/guest-js/index.ts @@ -61,13 +61,13 @@ * @module */ -import { BaseDirectory } from "@tauri-apps/api/path"; -import { Channel, invoke, Resource } from "@tauri-apps/api/core"; +import { BaseDirectory } from '@tauri-apps/api/path' +import { Channel, invoke, Resource } from '@tauri-apps/api/core' enum SeekMode { Start = 0, Current = 1, - End = 2, + End = 2 } /** @@ -80,41 +80,41 @@ interface FileInfo { * True if this is info for a regular file. Mutually exclusive to * `FileInfo.isDirectory` and `FileInfo.isSymlink`. */ - isFile: boolean; + isFile: boolean /** * True if this is info for a regular directory. Mutually exclusive to * `FileInfo.isFile` and `FileInfo.isSymlink`. */ - isDirectory: boolean; + isDirectory: boolean /** * True if this is info for a symlink. Mutually exclusive to * `FileInfo.isFile` and `FileInfo.isDirectory`. */ - isSymlink: boolean; + isSymlink: boolean /** * The size of the file, in bytes. */ - size: number; + size: number /** * The last modification time of the file. This corresponds to the `mtime` * field from `stat` on Linux/Mac OS and `ftLastWriteTime` on Windows. This * may not be available on all platforms. */ - mtime: Date | null; + mtime: Date | null /** * The last access time of the file. This corresponds to the `atime` * field from `stat` on Unix and `ftLastAccessTime` on Windows. This may not * be available on all platforms. */ - atime: Date | null; + atime: Date | null /** * The creation time of the file. This corresponds to the `birthtime` * field from `stat` on Mac/BSD and `ftCreationTime` on Windows. This may * not be available on all platforms. */ - birthtime: Date | null; + birthtime: Date | null /** Whether this is a readonly (unwritable) file. */ - readonly: boolean; + readonly: boolean /** * This field contains the file system attribute information for a file * or directory. For possible values and their descriptions, see @@ -124,7 +124,7 @@ interface FileInfo { * * - **macOS / Linux / Android / iOS:** Unsupported. */ - fileAttributes: number | null; + fileAttributes: number | null /** * ID of the device containing the file. * @@ -132,7 +132,7 @@ interface FileInfo { * * - **Windows:** Unsupported. */ - dev: number | null; + dev: number | null /** * Inode number. * @@ -140,7 +140,7 @@ interface FileInfo { * * - **Windows:** Unsupported. */ - ino: number | null; + ino: number | null /** * The underlying raw `st_mode` bits that contain the standard Unix * permissions for this file/directory. @@ -149,7 +149,7 @@ interface FileInfo { * * - **Windows:** Unsupported. */ - mode: number | null; + mode: number | null /** * Number of hard links pointing to this file. * @@ -157,7 +157,7 @@ interface FileInfo { * * - **Windows:** Unsupported. */ - nlink: number | null; + nlink: number | null /** * User ID of the owner of this file. * @@ -165,7 +165,7 @@ interface FileInfo { * * - **Windows:** Unsupported. */ - uid: number | null; + uid: number | null /** * Group ID of the owner of this file. * @@ -173,7 +173,7 @@ interface FileInfo { * * - **Windows:** Unsupported. */ - gid: number | null; + gid: number | null /** * Device ID of this file. * @@ -181,7 +181,7 @@ interface FileInfo { * * - **Windows:** Unsupported. */ - rdev: number | null; + rdev: number | null /** * Blocksize for filesystem I/O. * @@ -189,7 +189,7 @@ interface FileInfo { * * - **Windows:** Unsupported. */ - blksize: number | null; + blksize: number | null /** * Number of blocks allocated to the file, in 512-byte units. * @@ -197,28 +197,28 @@ interface FileInfo { * * - **Windows:** Unsupported. */ - blocks: number | null; + blocks: number | null } interface UnparsedFileInfo { - isFile: boolean; - isDirectory: boolean; - isSymlink: boolean; - size: number; - mtime: number | null; - atime: number | null; - birthtime: number | null; - readonly: boolean; - fileAttributes: number; - dev: number | null; - ino: number | null; - mode: number | null; - nlink: number | null; - uid: number | null; - gid: number | null; - rdev: number | null; - blksize: number | null; - blocks: number | null; + isFile: boolean + isDirectory: boolean + isSymlink: boolean + size: number + mtime: number | null + atime: number | null + birthtime: number | null + readonly: boolean + fileAttributes: number + dev: number | null + ino: number | null + mode: number | null + nlink: number | null + uid: number | null + gid: number | null + rdev: number | null + blksize: number | null + blocks: number | null } function parseFileInfo(r: UnparsedFileInfo): FileInfo { return { @@ -239,8 +239,8 @@ function parseFileInfo(r: UnparsedFileInfo): FileInfo { gid: r.gid, rdev: r.rdev, blksize: r.blksize, - blocks: r.blocks, - }; + blocks: r.blocks + } } /** @@ -282,17 +282,17 @@ class FileHandle extends Resource { */ async read(buffer: Uint8Array): Promise { if (buffer.byteLength === 0) { - return 0; + return 0 } - const [data, nread] = await invoke<[number[], number]>("plugin:fs|read", { + const [data, nread] = await invoke<[number[], number]>('plugin:fs|read', { rid: this.rid, - len: buffer.byteLength, - }); + len: buffer.byteLength + }) - buffer.set(data); + buffer.set(data) - return nread === 0 ? null : nread; + return nread === 0 ? null : nread } /** @@ -328,11 +328,11 @@ class FileHandle extends Resource { * @since 2.0.0 */ async seek(offset: number, whence: SeekMode): Promise { - return await invoke("plugin:fs|seek", { + return await invoke('plugin:fs|seek', { rid: this.rid, offset, - whence, - }); + whence + }) } /** @@ -350,11 +350,11 @@ class FileHandle extends Resource { * @since 2.0.0 */ async stat(): Promise { - const res = await invoke("plugin:fs|fstat", { - rid: this.rid, - }); + const res = await invoke('plugin:fs|fstat', { + rid: this.rid + }) - return parseFileInfo(res); + return parseFileInfo(res) } /** @@ -382,10 +382,10 @@ class FileHandle extends Resource { * @since 2.0.0 */ async truncate(len?: number): Promise { - await invoke("plugin:fs|ftruncate", { + await invoke('plugin:fs|ftruncate', { rid: this.rid, - len, - }); + len + }) } /** @@ -409,10 +409,10 @@ class FileHandle extends Resource { * @since 2.0.0 */ async write(data: Uint8Array): Promise { - return await invoke("plugin:fs|write", { + return await invoke('plugin:fs|write', { rid: this.rid, - data, - }); + data + }) } } @@ -421,7 +421,7 @@ class FileHandle extends Resource { */ interface CreateOptions { /** Base directory for `path` */ - baseDir?: BaseDirectory; + baseDir?: BaseDirectory } /** @@ -440,18 +440,18 @@ interface CreateOptions { */ async function create( path: string | URL, - options?: CreateOptions, + options?: CreateOptions ): Promise { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); + if (path instanceof URL && path.protocol !== 'file:') { + throw new TypeError('Must be a file URL.') } - const rid = await invoke("plugin:fs|create", { + const rid = await invoke('plugin:fs|create', { path: path instanceof URL ? path.toString() : path, - options, - }); + options + }) - return new FileHandle(rid); + return new FileHandle(rid) } /** @@ -462,49 +462,49 @@ interface OpenOptions { * Sets the option for read access. This option, when `true`, means that the * file should be read-able if opened. */ - read?: boolean; + read?: boolean /** * Sets the option for write access. This option, when `true`, means that * the file should be write-able if opened. If the file already exists, * any write calls on it will overwrite its contents, by default without * truncating it. */ - write?: boolean; + write?: boolean /** * Sets the option for the append mode. This option, when `true`, means that * writes will append to a file instead of overwriting previous contents. * Note that setting `{ write: true, append: true }` has the same effect as * setting only `{ append: true }`. */ - append?: boolean; + append?: boolean /** * Sets the option for truncating a previous file. If a file is * successfully opened with this option set it will truncate the file to `0` * size if it already exists. The file must be opened with write access * for truncate to work. */ - truncate?: boolean; + truncate?: boolean /** * Sets the option to allow creating a new file, if one doesn't already * exist at the specified path. Requires write or append access to be * used. */ - create?: boolean; + create?: boolean /** * Defaults to `false`. If set to `true`, no file, directory, or symlink is * allowed to exist at the target location. Requires write or append * access to be used. When createNew is set to `true`, create and truncate * are ignored. */ - createNew?: boolean; + createNew?: boolean /** * Permissions to use if creating the file (defaults to `0o666`, before * the process's umask). * Ignored on Windows. */ - mode?: number; + mode?: number /** Base directory for `path` */ - baseDir?: BaseDirectory; + baseDir?: BaseDirectory } /** @@ -525,18 +525,18 @@ interface OpenOptions { */ async function open( path: string | URL, - options?: OpenOptions, + options?: OpenOptions ): Promise { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); + if (path instanceof URL && path.protocol !== 'file:') { + throw new TypeError('Must be a file URL.') } - const rid = await invoke("plugin:fs|open", { + const rid = await invoke('plugin:fs|open', { path: path instanceof URL ? path.toString() : path, - options, - }); + options + }) - return new FileHandle(rid); + return new FileHandle(rid) } /** @@ -544,9 +544,9 @@ async function open( */ interface CopyFileOptions { /** Base directory for `fromPath`. */ - fromPathBaseDir?: BaseDirectory; + fromPathBaseDir?: BaseDirectory /** Base directory for `toPath`. */ - toPathBaseDir?: BaseDirectory; + toPathBaseDir?: BaseDirectory } /** @@ -562,20 +562,20 @@ interface CopyFileOptions { async function copyFile( fromPath: string | URL, toPath: string | URL, - options?: CopyFileOptions, + options?: CopyFileOptions ): Promise { if ( - (fromPath instanceof URL && fromPath.protocol !== "file:") || - (toPath instanceof URL && toPath.protocol !== "file:") + (fromPath instanceof URL && fromPath.protocol !== 'file:') || + (toPath instanceof URL && toPath.protocol !== 'file:') ) { - throw new TypeError("Must be a file URL."); + throw new TypeError('Must be a file URL.') } - await invoke("plugin:fs|copy_file", { + await invoke('plugin:fs|copy_file', { fromPath: fromPath instanceof URL ? fromPath.toString() : fromPath, toPath: toPath instanceof URL ? toPath.toString() : toPath, - options, - }); + options + }) } /** @@ -583,13 +583,13 @@ async function copyFile( */ interface MkdirOptions { /** Permissions to use when creating the directory (defaults to `0o777`, before the process's umask). Ignored on Windows. */ - mode?: number; + mode?: number /** * Defaults to `false`. If set to `true`, means that any intermediate directories will also be created (as with the shell command `mkdir -p`). * */ - recursive?: boolean; + recursive?: boolean /** Base directory for `path` */ - baseDir?: BaseDirectory; + baseDir?: BaseDirectory } /** @@ -604,16 +604,16 @@ interface MkdirOptions { */ async function mkdir( path: string | URL, - options?: MkdirOptions, + options?: MkdirOptions ): Promise { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); + if (path instanceof URL && path.protocol !== 'file:') { + throw new TypeError('Must be a file URL.') } - await invoke("plugin:fs|mkdir", { + await invoke('plugin:fs|mkdir', { path: path instanceof URL ? path.toString() : path, - options, - }); + options + }) } /** @@ -621,7 +621,7 @@ async function mkdir( */ interface ReadDirOptions { /** Base directory for `path` */ - baseDir?: BaseDirectory; + baseDir?: BaseDirectory } /** @@ -633,13 +633,13 @@ interface ReadDirOptions { */ interface DirEntry { /** The name of the entry (file name with extension or directory name). */ - name: string; + name: string /** Specifies whether this entry is a directory or not. */ - isDirectory: boolean; + isDirectory: boolean /** Specifies whether this entry is a file or not. */ - isFile: boolean; + isFile: boolean /** Specifies whether this entry is a symlink or not. */ - isSymlink: boolean; + isSymlink: boolean } /** @@ -666,16 +666,16 @@ interface DirEntry { */ async function readDir( path: string | URL, - options?: ReadDirOptions, + options?: ReadDirOptions ): Promise { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); + if (path instanceof URL && path.protocol !== 'file:') { + throw new TypeError('Must be a file URL.') } - return await invoke("plugin:fs|read_dir", { + return await invoke('plugin:fs|read_dir', { path: path instanceof URL ? path.toString() : path, - options, - }); + options + }) } /** @@ -683,7 +683,7 @@ async function readDir( */ interface ReadFileOptions { /** Base directory for `path` */ - baseDir?: BaseDirectory; + baseDir?: BaseDirectory } /** @@ -699,20 +699,18 @@ interface ReadFileOptions { */ async function readFile( path: string | URL, - options?: ReadFileOptions, + options?: ReadFileOptions ): Promise { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); + if (path instanceof URL && path.protocol !== 'file:') { + throw new TypeError('Must be a file URL.') } - const arr = await invoke("plugin:fs|read_file", { + const arr = await invoke('plugin:fs|read_file', { path: path instanceof URL ? path.toString() : path, - options, - }); + options + }) - return arr instanceof ArrayBuffer - ? new Uint8Array(arr) - : Uint8Array.from(arr); + return arr instanceof ArrayBuffer ? new Uint8Array(arr) : Uint8Array.from(arr) } /** @@ -727,16 +725,16 @@ async function readFile( */ async function readTextFile( path: string | URL, - options?: ReadFileOptions, + options?: ReadFileOptions ): Promise { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); + if (path instanceof URL && path.protocol !== 'file:') { + throw new TypeError('Must be a file URL.') } - return await invoke("plugin:fs|read_text_file", { + return await invoke('plugin:fs|read_text_file', { path: path instanceof URL ? path.toString() : path, - options, - }); + options + }) } /** @@ -756,42 +754,42 @@ async function readTextFile( */ async function readTextFileLines( path: string | URL, - options?: ReadFileOptions, + options?: ReadFileOptions ): Promise> { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); + if (path instanceof URL && path.protocol !== 'file:') { + throw new TypeError('Must be a file URL.') } - const pathStr = path instanceof URL ? path.toString() : path; + const pathStr = path instanceof URL ? path.toString() : path return await Promise.resolve({ path: pathStr, rid: null as number | null, async next(): Promise> { if (this.rid === null) { - this.rid = await invoke("plugin:fs|read_text_file_lines", { + this.rid = await invoke('plugin:fs|read_text_file_lines', { path: pathStr, - options, - }); + options + }) } const [line, done] = await invoke<[string | null, boolean]>( - "plugin:fs|read_text_file_lines_next", - { rid: this.rid }, - ); + 'plugin:fs|read_text_file_lines_next', + { rid: this.rid } + ) // an iteration is over, reset rid for next iteration - if (done) this.rid = null; + if (done) this.rid = null return { - value: done ? "" : line!, - done, - }; + value: done ? '' : line!, + done + } }, [Symbol.asyncIterator](): AsyncIterableIterator { - return this; - }, - }); + return this + } + }) } /** @@ -799,9 +797,9 @@ async function readTextFileLines( */ interface RemoveOptions { /** Defaults to `false`. If set to `true`, path will be removed even if it's a non-empty directory. */ - recursive?: boolean; + recursive?: boolean /** Base directory for `path` */ - baseDir?: BaseDirectory; + baseDir?: BaseDirectory } /** @@ -818,16 +816,16 @@ interface RemoveOptions { */ async function remove( path: string | URL, - options?: RemoveOptions, + options?: RemoveOptions ): Promise { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); + if (path instanceof URL && path.protocol !== 'file:') { + throw new TypeError('Must be a file URL.') } - await invoke("plugin:fs|remove", { + await invoke('plugin:fs|remove', { path: path instanceof URL ? path.toString() : path, - options, - }); + options + }) } /** @@ -835,9 +833,9 @@ async function remove( */ interface RenameOptions { /** Base directory for `oldPath`. */ - oldPathBaseDir?: BaseDirectory; + oldPathBaseDir?: BaseDirectory /** Base directory for `newPath`. */ - newPathBaseDir?: BaseDirectory; + newPathBaseDir?: BaseDirectory } /** @@ -858,20 +856,20 @@ interface RenameOptions { async function rename( oldPath: string | URL, newPath: string | URL, - options?: RenameOptions, + options?: RenameOptions ): Promise { if ( - (oldPath instanceof URL && oldPath.protocol !== "file:") || - (newPath instanceof URL && newPath.protocol !== "file:") + (oldPath instanceof URL && oldPath.protocol !== 'file:') || + (newPath instanceof URL && newPath.protocol !== 'file:') ) { - throw new TypeError("Must be a file URL."); + throw new TypeError('Must be a file URL.') } - await invoke("plugin:fs|rename", { + await invoke('plugin:fs|rename', { oldPath: oldPath instanceof URL ? oldPath.toString() : oldPath, newPath: newPath instanceof URL ? newPath.toString() : newPath, - options, - }); + options + }) } /** @@ -879,7 +877,7 @@ async function rename( */ interface StatOptions { /** Base directory for `path`. */ - baseDir?: BaseDirectory; + baseDir?: BaseDirectory } /** @@ -897,14 +895,14 @@ interface StatOptions { */ async function stat( path: string | URL, - options?: StatOptions, + options?: StatOptions ): Promise { - const res = await invoke("plugin:fs|stat", { + const res = await invoke('plugin:fs|stat', { path: path instanceof URL ? path.toString() : path, - options, - }); + options + }) - return parseFileInfo(res); + return parseFileInfo(res) } /** @@ -923,14 +921,14 @@ async function stat( */ async function lstat( path: string | URL, - options?: StatOptions, + options?: StatOptions ): Promise { - const res = await invoke("plugin:fs|lstat", { + const res = await invoke('plugin:fs|lstat', { path: path instanceof URL ? path.toString() : path, - options, - }); + options + }) - return parseFileInfo(res); + return parseFileInfo(res) } /** @@ -938,7 +936,7 @@ async function lstat( */ interface TruncateOptions { /** Base directory for `path`. */ - baseDir?: BaseDirectory; + baseDir?: BaseDirectory } /** @@ -964,17 +962,17 @@ interface TruncateOptions { async function truncate( path: string | URL, len?: number, - options?: TruncateOptions, + options?: TruncateOptions ): Promise { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); + if (path instanceof URL && path.protocol !== 'file:') { + throw new TypeError('Must be a file URL.') } - await invoke("plugin:fs|truncate", { + await invoke('plugin:fs|truncate', { path: path instanceof URL ? path.toString() : path, len, - options, - }); + options + }) } /** @@ -982,15 +980,15 @@ async function truncate( */ interface WriteFileOptions { /** Defaults to `false`. If set to `true`, will append to a file instead of overwriting previous contents. */ - append?: boolean; + append?: boolean /** Sets the option to allow creating a new file, if one doesn't already exist at the specified path (defaults to `true`). */ - create?: boolean; + create?: boolean /** Sets the option to create a new file, failing if it already exists. */ - createNew?: boolean; + createNew?: boolean /** File permissions. Ignored on Windows. */ - mode?: number; + mode?: number /** Base directory for `path` */ - baseDir?: BaseDirectory; + baseDir?: BaseDirectory } /** @@ -1009,18 +1007,18 @@ interface WriteFileOptions { async function writeFile( path: string | URL, data: Uint8Array, - options?: WriteFileOptions, + options?: WriteFileOptions ): Promise { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); + if (path instanceof URL && path.protocol !== 'file:') { + throw new TypeError('Must be a file URL.') } - await invoke("plugin:fs|write_file", data, { + await invoke('plugin:fs|write_file', data, { headers: { path: path instanceof URL ? path.toString() : path, - options: JSON.stringify(options), - }, - }); + options: JSON.stringify(options) + } + }) } /** @@ -1037,17 +1035,17 @@ async function writeFile( async function writeTextFile( path: string | URL, data: string, - options?: WriteFileOptions, + options?: WriteFileOptions ): Promise { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); + if (path instanceof URL && path.protocol !== 'file:') { + throw new TypeError('Must be a file URL.') } - await invoke("plugin:fs|write_text_file", { + await invoke('plugin:fs|write_text_file', { path: path instanceof URL ? path.toString() : path, data, - options, - }); + options + }) } /** @@ -1055,7 +1053,7 @@ async function writeTextFile( */ interface ExistsOptions { /** Base directory for `path`. */ - baseDir?: BaseDirectory; + baseDir?: BaseDirectory } /** @@ -1071,16 +1069,16 @@ interface ExistsOptions { */ async function exists( path: string | URL, - options?: ExistsOptions, + options?: ExistsOptions ): Promise { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); + if (path instanceof URL && path.protocol !== 'file:') { + throw new TypeError('Must be a file URL.') } - return await invoke("plugin:fs|exists", { + return await invoke('plugin:fs|exists', { path: path instanceof URL ? path.toString() : path, - options, - }); + options + }) } /** @@ -1088,9 +1086,9 @@ async function exists( */ interface WatchOptions { /** Watch a directory recursively */ - recursive?: boolean; + recursive?: boolean /** Base directory for `path` */ - baseDir?: BaseDirectory; + baseDir?: BaseDirectory } /** @@ -1098,83 +1096,83 @@ interface WatchOptions { */ interface DebouncedWatchOptions extends WatchOptions { /** Debounce delay */ - delayMs?: number; + delayMs?: number } /** * @since 2.0.0 */ interface WatchEvent { - type: WatchEventKind; - paths: string[]; - attrs: unknown; + type: WatchEventKind + paths: string[] + attrs: unknown } /** * @since 2.0.0 */ type WatchEventKind = - | "any" + | 'any' | { access: WatchEventKindAccess } | { create: WatchEventKindCreate } | { modify: WatchEventKindModify } | { remove: WatchEventKindRemove } - | "other"; + | 'other' /** * @since 2.0.0 */ type WatchEventKindAccess = - | { kind: "any" } - | { kind: "close"; mode: "any" | "execute" | "read" | "write" | "other" } - | { kind: "open"; mode: "any" | "execute" | "read" | "write" | "other" } - | { kind: "other" }; + | { kind: 'any' } + | { kind: 'close'; mode: 'any' | 'execute' | 'read' | 'write' | 'other' } + | { kind: 'open'; mode: 'any' | 'execute' | 'read' | 'write' | 'other' } + | { kind: 'other' } /** * @since 2.0.0 */ type WatchEventKindCreate = - | { kind: "any" } - | { kind: "file" } - | { kind: "folder" } - | { kind: "other" }; + | { kind: 'any' } + | { kind: 'file' } + | { kind: 'folder' } + | { kind: 'other' } /** * @since 2.0.0 */ type WatchEventKindModify = - | { kind: "any" } - | { kind: "data"; mode: "any" | "size" | "content" | "other" } + | { kind: 'any' } + | { kind: 'data'; mode: 'any' | 'size' | 'content' | 'other' } | { - kind: "metadata"; + kind: 'metadata' mode: - | "any" - | "access-time" - | "write-time" - | "permissions" - | "ownership" - | "extended" - | "other"; + | 'any' + | 'access-time' + | 'write-time' + | 'permissions' + | 'ownership' + | 'extended' + | 'other' } - | { kind: "rename"; mode: "any" | "to" | "from" | "both" | "other" } - | { kind: "other" }; + | { kind: 'rename'; mode: 'any' | 'to' | 'from' | 'both' | 'other' } + | { kind: 'other' } /** * @since 2.0.0 */ type WatchEventKindRemove = - | { kind: "any" } - | { kind: "file" } - | { kind: "folder" } - | { kind: "other" }; + | { kind: 'any' } + | { kind: 'file' } + | { kind: 'folder' } + | { kind: 'other' } /** * @since 2.0.0 */ -type UnwatchFn = () => void; +type UnwatchFn = () => void async function unwatch(rid: number): Promise { - await invoke("plugin:fs|unwatch", { rid }); + await invoke('plugin:fs|unwatch', { rid }) } /** @@ -1185,34 +1183,34 @@ async function unwatch(rid: number): Promise { async function watch( paths: string | string[] | URL | URL[], cb: (event: WatchEvent) => void, - options?: DebouncedWatchOptions, + options?: DebouncedWatchOptions ): Promise { const opts = { recursive: false, delayMs: 2000, - ...options, - }; + ...options + } - const watchPaths = Array.isArray(paths) ? paths : [paths]; + const watchPaths = Array.isArray(paths) ? paths : [paths] for (const path of watchPaths) { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); + if (path instanceof URL && path.protocol !== 'file:') { + throw new TypeError('Must be a file URL.') } } - const onEvent = new Channel(); - onEvent.onmessage = cb; + const onEvent = new Channel() + onEvent.onmessage = cb - const rid: number = await invoke("plugin:fs|watch", { + const rid: number = await invoke('plugin:fs|watch', { paths: watchPaths.map((p) => (p instanceof URL ? p.toString() : p)), options: opts, - onEvent, - }); + onEvent + }) return () => { - void unwatch(rid); - }; + void unwatch(rid) + } } /** @@ -1223,34 +1221,34 @@ async function watch( async function watchImmediate( paths: string | string[] | URL | URL[], cb: (event: WatchEvent) => void, - options?: WatchOptions, + options?: WatchOptions ): Promise { const opts = { recursive: false, ...options, - delayMs: null, - }; + delayMs: null + } - const watchPaths = Array.isArray(paths) ? paths : [paths]; + const watchPaths = Array.isArray(paths) ? paths : [paths] for (const path of watchPaths) { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); + if (path instanceof URL && path.protocol !== 'file:') { + throw new TypeError('Must be a file URL.') } } - const onEvent = new Channel(); - onEvent.onmessage = cb; + const onEvent = new Channel() + onEvent.onmessage = cb - const rid: number = await invoke("plugin:fs|watch", { + const rid: number = await invoke('plugin:fs|watch', { paths: watchPaths.map((p) => (p instanceof URL ? p.toString() : p)), options: opts, - onEvent, - }); + onEvent + }) return () => { - void unwatch(rid); - }; + void unwatch(rid) + } } export type { @@ -1276,8 +1274,8 @@ export type { WatchEventKindCreate, WatchEventKindModify, WatchEventKindRemove, - UnwatchFn, -}; + UnwatchFn +} export { BaseDirectory, @@ -1300,5 +1298,5 @@ export { writeTextFile, exists, watch, - watchImmediate, -}; + watchImmediate +} diff --git a/plugins/fs/permissions/create-app-specific-dirs.toml b/plugins/fs/permissions/create-app-specific-dirs.toml index 45fa632e1..68a849219 100644 --- a/plugins/fs/permissions/create-app-specific-dirs.toml +++ b/plugins/fs/permissions/create-app-specific-dirs.toml @@ -20,4 +20,4 @@ path = "$APPLOCALDATA" path = "$APPCACHE" [[permission.scope.allow]] -path = "$APPLOG" \ No newline at end of file +path = "$APPLOG" diff --git a/plugins/fs/permissions/default.toml b/plugins/fs/permissions/default.toml index 279fca79e..d519d7583 100644 --- a/plugins/fs/permissions/default.toml +++ b/plugins/fs/permissions/default.toml @@ -28,7 +28,7 @@ On Windows the webview data folder access is denied. """ permissions = [ - "create-app-specific-dirs", - "read-app-specific-dirs-recursive", - "deny-default", + "create-app-specific-dirs", + "read-app-specific-dirs-recursive", + "deny-default", ] diff --git a/plugins/fs/permissions/read-all.toml b/plugins/fs/permissions/read-all.toml index 99cbadf39..d43af5e09 100644 --- a/plugins/fs/permissions/read-all.toml +++ b/plugins/fs/permissions/read-all.toml @@ -4,18 +4,18 @@ identifier = "read-all" description = "This enables all read related commands without any pre-configured accessible paths." commands.allow = [ - "read_dir", - "read_file", - "read", - "open", - "read_text_file", - "read_text_file_lines", - "read_text_file_lines_next", - "seek", - "stat", - "lstat", - "fstat", - "exists", - "watch", - "unwatch", + "read_dir", + "read_file", + "read", + "open", + "read_text_file", + "read_text_file_lines", + "read_text_file_lines_next", + "seek", + "stat", + "lstat", + "fstat", + "exists", + "watch", + "unwatch", ] diff --git a/plugins/fs/permissions/read-app-specific-dirs-recursive.toml b/plugins/fs/permissions/read-app-specific-dirs-recursive.toml index 409f24fcd..af1d0fce9 100644 --- a/plugins/fs/permissions/read-app-specific-dirs-recursive.toml +++ b/plugins/fs/permissions/read-app-specific-dirs-recursive.toml @@ -7,12 +7,12 @@ This permission allows recursive read functionality on the application specific base directories. """ commands.allow = [ - "read_dir", - "read_file", - "read_text_file", - "read_text_file_lines", - "read_text_file_lines_next", - "exists", + "read_dir", + "read_file", + "read_text_file", + "read_text_file_lines", + "read_text_file_lines_next", + "exists", ] [[permission.scope.allow]] @@ -28,4 +28,4 @@ path = "$APPLOCALDATA/**" path = "$APPCACHE/**" [[permission.scope.allow]] -path = "$APPLOG/**" \ No newline at end of file +path = "$APPLOG/**" diff --git a/plugins/fs/permissions/read-files.toml b/plugins/fs/permissions/read-files.toml index a0691b44f..f2685108b 100644 --- a/plugins/fs/permissions/read-files.toml +++ b/plugins/fs/permissions/read-files.toml @@ -4,16 +4,16 @@ identifier = "read-files" description = "This enables file read related commands without any pre-configured accessible paths." commands.allow = [ - "read_file", - "read", - "open", - "read_text_file", - "read_text_file_lines", - "read_text_file_lines_next", - "seek", - "stat", - "lstat", - "fstat", - "exists", + "read_file", + "read", + "open", + "read_text_file", + "read_text_file_lines", + "read_text_file_lines_next", + "seek", + "stat", + "lstat", + "fstat", + "exists", ] diff --git a/plugins/fs/permissions/write-all.toml b/plugins/fs/permissions/write-all.toml index 55a512ded..c18027825 100644 --- a/plugins/fs/permissions/write-all.toml +++ b/plugins/fs/permissions/write-all.toml @@ -4,14 +4,14 @@ identifier = "write-all" description = "This enables all write related commands without any pre-configured accessible paths." commands.allow = [ - "mkdir", - "create", - "copy_file", - "remove", - "rename", - "truncate", - "ftruncate", - "write", - "write_file", - "write_text_file", + "mkdir", + "create", + "copy_file", + "remove", + "rename", + "truncate", + "ftruncate", + "write", + "write_file", + "write_text_file", ] diff --git a/plugins/fs/permissions/write-files.toml b/plugins/fs/permissions/write-files.toml index 239bc60d7..2d6aeffb1 100644 --- a/plugins/fs/permissions/write-files.toml +++ b/plugins/fs/permissions/write-files.toml @@ -4,13 +4,13 @@ identifier = "write-files" description = "This enables all file write related commands without any pre-configured accessible paths." commands.allow = [ - "create", - "copy_file", - "remove", - "rename", - "truncate", - "ftruncate", - "write", - "write_file", - "write_text_file", + "create", + "copy_file", + "remove", + "rename", + "truncate", + "ftruncate", + "write", + "write_file", + "write_text_file", ] diff --git a/plugins/fs/rollup.config.js b/plugins/fs/rollup.config.js index 977dfac83..1f349ec8a 100644 --- a/plugins/fs/rollup.config.js +++ b/plugins/fs/rollup.config.js @@ -2,6 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { createConfig } from "../../shared/rollup.config.js"; +import { createConfig } from '../../shared/rollup.config.js' -export default createConfig(); +export default createConfig() diff --git a/plugins/geolocation/.gitignore b/plugins/geolocation/.gitignore deleted file mode 100644 index 1b0b469d0..000000000 --- a/plugins/geolocation/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/.tauri diff --git a/plugins/geolocation/Cargo.toml b/plugins/geolocation/Cargo.toml index f89a69ff7..9b13a7fc5 100644 --- a/plugins/geolocation/Cargo.toml +++ b/plugins/geolocation/Cargo.toml @@ -9,12 +9,12 @@ repository = { workspace = true } links = "tauri-plugin-geolocation" [package.metadata.docs.rs] -rustc-args = [ "--cfg", "docsrs" ] -rustdoc-args = [ "--cfg", "docsrs" ] -targets = [ "x86_64-linux-android" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] +targets = ["x86_64-linux-android"] [build-dependencies] -tauri-plugin = { workspace = true, features = [ "build" ] } +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } diff --git a/plugins/geolocation/README.md b/plugins/geolocation/README.md index 972542dd3..d6f2baded 100644 --- a/plugins/geolocation/README.md +++ b/plugins/geolocation/README.md @@ -87,16 +87,16 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { getCurrentPosition, watchPosition } from "@tauri-apps/plugin-log"; +import { getCurrentPosition, watchPosition } from '@tauri-apps/plugin-log' -const pos = await getCurrentPosition(); +const pos = await getCurrentPosition() await watchPosition( { enableHighAccuracy: true, timeout: 10000, maximumAge: 0 }, (pos) => { - console.log(pos); + console.log(pos) } -); +) ``` ## Contributing diff --git a/plugins/geolocation/SECURITY.md b/plugins/geolocation/SECURITY.md index 67d831fc9..4f09bbacd 100644 --- a/plugins/geolocation/SECURITY.md +++ b/plugins/geolocation/SECURITY.md @@ -20,4 +20,4 @@ We prefer to receive reports in English. Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). -Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). \ No newline at end of file +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/geolocation/guest-js/bindings.ts b/plugins/geolocation/guest-js/bindings.ts index 6bff7b548..f68ecbc32 100644 --- a/plugins/geolocation/guest-js/bindings.ts +++ b/plugins/geolocation/guest-js/bindings.ts @@ -9,77 +9,77 @@ export const commands = { async getCurrentPosition( - options: PositionOptions | null, + options: PositionOptions | null ): Promise> { try { return { - status: "ok", - data: await TAURI_INVOKE("plugin:geolocation|get_current_position", { - options, - }), - }; + status: 'ok', + data: await TAURI_INVOKE('plugin:geolocation|get_current_position', { + options + }) + } } catch (e) { - if (e instanceof Error) throw e; - else return { status: "error", error: e as any }; + if (e instanceof Error) throw e + else return { status: 'error', error: e as any } } }, async watchPosition( options: PositionOptions, - channel: any, + channel: any ): Promise> { try { return { - status: "ok", - data: await TAURI_INVOKE("plugin:geolocation|watch_position", { + status: 'ok', + data: await TAURI_INVOKE('plugin:geolocation|watch_position', { options, - channel, - }), - }; + channel + }) + } } catch (e) { - if (e instanceof Error) throw e; - else return { status: "error", error: e as any }; + if (e instanceof Error) throw e + else return { status: 'error', error: e as any } } }, async clearWatch(channelId: number): Promise> { try { return { - status: "ok", - data: await TAURI_INVOKE("plugin:geolocation|clear_watch", { - channelId, - }), - }; + status: 'ok', + data: await TAURI_INVOKE('plugin:geolocation|clear_watch', { + channelId + }) + } } catch (e) { - if (e instanceof Error) throw e; - else return { status: "error", error: e as any }; + if (e instanceof Error) throw e + else return { status: 'error', error: e as any } } }, async checkPermissions(): Promise> { try { return { - status: "ok", - data: await TAURI_INVOKE("plugin:geolocation|check_permissions"), - }; + status: 'ok', + data: await TAURI_INVOKE('plugin:geolocation|check_permissions') + } } catch (e) { - if (e instanceof Error) throw e; - else return { status: "error", error: e as any }; + if (e instanceof Error) throw e + else return { status: 'error', error: e as any } } }, async requestPermissions( - permissions: PermissionType[] | null, + permissions: PermissionType[] | null ): Promise> { try { return { - status: "ok", - data: await TAURI_INVOKE("plugin:geolocation|request_permissions", { - permissions, - }), - }; + status: 'ok', + data: await TAURI_INVOKE('plugin:geolocation|request_permissions', { + permissions + }) + } } catch (e) { - if (e instanceof Error) throw e; - else return { status: "error", error: e as any }; + if (e instanceof Error) throw e + else return { status: 'error', error: e as any } } - }, -}; + } +} /** user-defined events **/ @@ -97,31 +97,31 @@ export type Coordinates = { /** * Latitude in decimal degrees. */ - latitude: number; + latitude: number /** * Longitude in decimal degrees. */ - longitude: number; + longitude: number /** * Accuracy level of the latitude and longitude coordinates in meters. */ - accuracy: number; + accuracy: number /** * Accuracy level of the altitude coordinate in meters, if available. * Available on all iOS versions and on Android 8 and above. */ - altitudeAccuracy: number | null; + altitudeAccuracy: number | null /** * The altitude the user is at, if available. */ - altitude: number | null; - speed: number | null; + altitude: number | null + speed: number | null /** * The heading the user is facing, if available. */ - heading: number | null; -}; -export type Error = never; + heading: number | null +} +export type Error = never /** * Permission state. */ @@ -129,15 +129,15 @@ export type PermissionState = /** * Permission access has been granted. */ - | "granted" + | 'granted' /** * Permission access has been denied. */ - | "denied" + | 'denied' /** * The end user should be prompted for permission. */ - | "prompt"; + | 'prompt' export type PermissionStatus = { /** * Permission state for the location alias. @@ -146,7 +146,7 @@ export type PermissionStatus = { * * On iOS it requests/checks location permissions. */ - location: PermissionState; + location: PermissionState /** * Permissions state for the coarseLoaction alias. * @@ -156,93 +156,93 @@ export type PermissionStatus = { * * On iOS it will have the same value as the `location` alias. */ - coarseLocation: PermissionState; -}; -export type PermissionType = "location" | "coarseLocation"; + coarseLocation: PermissionState +} +export type PermissionType = 'location' | 'coarseLocation' export type Position = { /** * Creation time for these coordinates. */ - timestamp: number; + timestamp: number /** * The GPD coordinates along with the accuracy of the data. */ - coords: Coordinates; -}; + coords: Coordinates +} export type PositionOptions = { /** * High accuracy mode (such as GPS, if available) * Will be ignored on Android 12+ if users didn't grant the ACCESS_FINE_LOCATION permission. */ - enableHighAccuracy: boolean; + enableHighAccuracy: boolean /** * The maximum wait time in milliseconds for location updates. * On Android the timeout gets ignored for getCurrentPosition. * Ignored on iOS */ - timeout: number; + timeout: number /** * The maximum age in milliseconds of a possible cached position that is acceptable to return. * Default: 0 * Ignored on iOS */ - maximumAge: number; -}; + maximumAge: number +} //export type RandomNumber = number; /** tauri-specta globals **/ -import { invoke as TAURI_INVOKE } from "@tauri-apps/api/core"; -import * as TAURI_API_EVENT from "@tauri-apps/api/event"; -import { type WebviewWindow as __WebviewWindow__ } from "@tauri-apps/api/webviewWindow"; +import { invoke as TAURI_INVOKE } from '@tauri-apps/api/core' +import * as TAURI_API_EVENT from '@tauri-apps/api/event' +import { type WebviewWindow as __WebviewWindow__ } from '@tauri-apps/api/webviewWindow' type __EventObj__ = { listen: ( - cb: TAURI_API_EVENT.EventCallback, - ) => ReturnType>; + cb: TAURI_API_EVENT.EventCallback + ) => ReturnType> once: ( - cb: TAURI_API_EVENT.EventCallback, - ) => ReturnType>; + cb: TAURI_API_EVENT.EventCallback + ) => ReturnType> emit: T extends null ? (payload?: T) => ReturnType - : (payload: T) => ReturnType; -}; + : (payload: T) => ReturnType +} export type Result = - | { status: "ok"; data: T } - | { status: "error"; error: E }; + | { status: 'ok'; data: T } + | { status: 'error'; error: E } function __makeEvents__>( - mappings: Record, + mappings: Record ) { return new Proxy( {} as unknown as { [K in keyof T]: __EventObj__ & { - (handle: __WebviewWindow__): __EventObj__; - }; + (handle: __WebviewWindow__): __EventObj__ + } }, { get: (_, event) => { - const name = mappings[event as keyof T]; + const name = mappings[event as keyof T] return new Proxy((() => {}) as any, { apply: (_, __, [window]: [__WebviewWindow__]) => ({ listen: (arg: any) => window.listen(name, arg), once: (arg: any) => window.once(name, arg), - emit: (arg: any) => window.emit(name, arg), + emit: (arg: any) => window.emit(name, arg) }), get: (_, command: keyof __EventObj__) => { switch (command) { - case "listen": - return (arg: any) => TAURI_API_EVENT.listen(name, arg); - case "once": - return (arg: any) => TAURI_API_EVENT.once(name, arg); - case "emit": - return (arg: any) => TAURI_API_EVENT.emit(name, arg); + case 'listen': + return (arg: any) => TAURI_API_EVENT.listen(name, arg) + case 'once': + return (arg: any) => TAURI_API_EVENT.once(name, arg) + case 'emit': + return (arg: any) => TAURI_API_EVENT.emit(name, arg) } - }, - }); - }, - }, - ); + } + }) + } + } + ) } diff --git a/plugins/geolocation/guest-js/index.ts b/plugins/geolocation/guest-js/index.ts index a7b89ccb3..ffda74837 100644 --- a/plugins/geolocation/guest-js/index.ts +++ b/plugins/geolocation/guest-js/index.ts @@ -4,26 +4,26 @@ /* eslint-disable @typescript-eslint/unbound-method */ -import { Channel } from "@tauri-apps/api/core"; -import { commands, type PositionOptions, type Position } from "./bindings"; +import { Channel } from '@tauri-apps/api/core' +import { commands, type PositionOptions, type Position } from './bindings' export async function watchPosition( options: PositionOptions, // TODO: This can receive errors too - cb: (location: Position | string) => void, + cb: (location: Position | string) => void ): Promise { - const channel = new Channel(); - channel.onmessage = cb; - await commands.watchPosition(options, channel); - return channel.id; + const channel = new Channel() + channel.onmessage = cb + await commands.watchPosition(options, channel) + return channel.id } export const { getCurrentPosition, clearWatch, checkPermissions, - requestPermissions, -} = commands; + requestPermissions +} = commands export type { PermissionState, @@ -31,7 +31,7 @@ export type { PermissionType, Position, PositionOptions, - Coordinates, -} from "./bindings"; + Coordinates +} from './bindings' // export { events }; diff --git a/plugins/geolocation/rollup.config.js b/plugins/geolocation/rollup.config.js index 977dfac83..1f349ec8a 100644 --- a/plugins/geolocation/rollup.config.js +++ b/plugins/geolocation/rollup.config.js @@ -2,6 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { createConfig } from "../../shared/rollup.config.js"; +import { createConfig } from '../../shared/rollup.config.js' -export default createConfig(); +export default createConfig() diff --git a/plugins/global-shortcut/Cargo.toml b/plugins/global-shortcut/Cargo.toml index 57da0e012..9da8e7ee8 100644 --- a/plugins/global-shortcut/Cargo.toml +++ b/plugins/global-shortcut/Cargo.toml @@ -10,11 +10,11 @@ repository = { workspace = true } links = "tauri-plugin-global-shortcut" [package.metadata.docs.rs] -rustc-args = [ "--cfg", "docsrs" ] -rustdoc-args = [ "--cfg", "docsrs" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] [build-dependencies] -tauri-plugin = { workspace = true, features = [ "build" ] } +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } diff --git a/plugins/global-shortcut/README.md b/plugins/global-shortcut/README.md index 18b370826..68ee4b53e 100644 --- a/plugins/global-shortcut/README.md +++ b/plugins/global-shortcut/README.md @@ -87,12 +87,12 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript bindings: ```javascript -import { register } from "@tauri-apps/plugin-global-shortcut"; -await register("CommandOrControl+Shift+C", (event) => { - if (event.state === "Pressed") { - console.log("Shortcut triggered"); +import { register } from '@tauri-apps/plugin-global-shortcut' +await register('CommandOrControl+Shift+C', (event) => { + if (event.state === 'Pressed') { + console.log('Shortcut triggered') } -}); +}) ``` ## Contributing diff --git a/plugins/global-shortcut/SECURITY.md b/plugins/global-shortcut/SECURITY.md index 67d831fc9..4f09bbacd 100644 --- a/plugins/global-shortcut/SECURITY.md +++ b/plugins/global-shortcut/SECURITY.md @@ -20,4 +20,4 @@ We prefer to receive reports in English. Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). -Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). \ No newline at end of file +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/global-shortcut/guest-js/index.ts b/plugins/global-shortcut/guest-js/index.ts index 4ec9b538b..13e8e50e8 100644 --- a/plugins/global-shortcut/guest-js/index.ts +++ b/plugins/global-shortcut/guest-js/index.ts @@ -8,15 +8,15 @@ * @module */ -import { invoke, Channel } from "@tauri-apps/api/core"; +import { invoke, Channel } from '@tauri-apps/api/core' export interface ShortcutEvent { - shortcut: string; - id: number; - state: "Released" | "Pressed"; + shortcut: string + id: number + state: 'Released' | 'Pressed' } -export type ShortcutHandler = (event: ShortcutEvent) => void; +export type ShortcutHandler = (event: ShortcutEvent) => void /** * Register a global shortcut or a list of shortcuts. @@ -50,15 +50,15 @@ export type ShortcutHandler = (event: ShortcutEvent) => void; */ async function register( shortcuts: string | string[], - handler: ShortcutHandler, + handler: ShortcutHandler ): Promise { - const h = new Channel(); - h.onmessage = handler; + const h = new Channel() + h.onmessage = handler - return await invoke("plugin:global-shortcut|register", { + return await invoke('plugin:global-shortcut|register', { shortcuts: Array.isArray(shortcuts) ? shortcuts : [shortcuts], - handler: h, - }); + handler: h + }) } /** @@ -80,9 +80,9 @@ async function register( * @since 2.0.0 */ async function unregister(shortcuts: string | string[]): Promise { - return await invoke("plugin:global-shortcut|unregister", { - shortcuts: Array.isArray(shortcuts) ? shortcuts : [shortcuts], - }); + return await invoke('plugin:global-shortcut|unregister', { + shortcuts: Array.isArray(shortcuts) ? shortcuts : [shortcuts] + }) } /** @@ -96,7 +96,7 @@ async function unregister(shortcuts: string | string[]): Promise { * @since 2.0.0 */ async function unregisterAll(): Promise { - return await invoke("plugin:global-shortcut|unregister_all", {}); + return await invoke('plugin:global-shortcut|unregister_all', {}) } /** @@ -115,9 +115,9 @@ async function unregisterAll(): Promise { * @since 2.0.0 */ async function isRegistered(shortcut: string): Promise { - return await invoke("plugin:global-shortcut|is_registered", { - shortcut, - }); + return await invoke('plugin:global-shortcut|is_registered', { + shortcut + }) } -export { register, unregister, unregisterAll, isRegistered }; +export { register, unregister, unregisterAll, isRegistered } diff --git a/plugins/global-shortcut/rollup.config.js b/plugins/global-shortcut/rollup.config.js index 977dfac83..1f349ec8a 100644 --- a/plugins/global-shortcut/rollup.config.js +++ b/plugins/global-shortcut/rollup.config.js @@ -2,6 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { createConfig } from "../../shared/rollup.config.js"; +import { createConfig } from '../../shared/rollup.config.js' -export default createConfig(); +export default createConfig() diff --git a/plugins/haptics/.gitignore b/plugins/haptics/.gitignore deleted file mode 100644 index 1b0b469d0..000000000 --- a/plugins/haptics/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/.tauri diff --git a/plugins/haptics/Cargo.toml b/plugins/haptics/Cargo.toml index be3a055bf..97ab3e248 100644 --- a/plugins/haptics/Cargo.toml +++ b/plugins/haptics/Cargo.toml @@ -9,12 +9,12 @@ repository = { workspace = true } links = "tauri-plugin-haptics" [package.metadata.docs.rs] -rustc-args = [ "--cfg", "docsrs" ] -rustdoc-args = [ "--cfg", "docsrs" ] -targets = [ "x86_64-linux-android" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] +targets = ["x86_64-linux-android"] [build-dependencies] -tauri-plugin = { workspace = true, features = [ "build" ] } +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } diff --git a/plugins/haptics/README.md b/plugins/haptics/README.md index dc86d99a1..f29c8c32b 100644 --- a/plugins/haptics/README.md +++ b/plugins/haptics/README.md @@ -68,13 +68,13 @@ import { vibrate, impactFeedback, notificationFeedback, - selectionFeedback, -} from "@tauri-apps/plugin-haptics"; + selectionFeedback +} from '@tauri-apps/plugin-haptics' -await vibrate(1); -await impactFeedback("medium"); -await notificationFeedback("warning"); -await selectionFeedback(); +await vibrate(1) +await impactFeedback('medium') +await notificationFeedback('warning') +await selectionFeedback() ``` ## Contributing diff --git a/plugins/haptics/SECURITY.md b/plugins/haptics/SECURITY.md index 67d831fc9..4f09bbacd 100644 --- a/plugins/haptics/SECURITY.md +++ b/plugins/haptics/SECURITY.md @@ -20,4 +20,4 @@ We prefer to receive reports in English. Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). -Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). \ No newline at end of file +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/haptics/guest-js/bindings.ts b/plugins/haptics/guest-js/bindings.ts index 73623de26..d12920d85 100644 --- a/plugins/haptics/guest-js/bindings.ts +++ b/plugins/haptics/guest-js/bindings.ts @@ -11,54 +11,54 @@ export const commands = { async vibrate(duration: number): Promise> { try { return { - status: "ok", - data: await TAURI_INVOKE("plugin:haptics|vibrate", { duration }), - }; + status: 'ok', + data: await TAURI_INVOKE('plugin:haptics|vibrate', { duration }) + } } catch (e) { - if (e instanceof Error) throw e; - else return { status: "error", error: e as any }; + if (e instanceof Error) throw e + else return { status: 'error', error: e as any } } }, async impactFeedback( - style: ImpactFeedbackStyle, + style: ImpactFeedbackStyle ): Promise> { try { return { - status: "ok", - data: await TAURI_INVOKE("plugin:haptics|impact_feedback", { style }), - }; + status: 'ok', + data: await TAURI_INVOKE('plugin:haptics|impact_feedback', { style }) + } } catch (e) { - if (e instanceof Error) throw e; - else return { status: "error", error: e as any }; + if (e instanceof Error) throw e + else return { status: 'error', error: e as any } } }, async notificationFeedback( - type: NotificationFeedbackType, + type: NotificationFeedbackType ): Promise> { try { return { - status: "ok", - data: await TAURI_INVOKE("plugin:haptics|notification_feedback", { - type, - }), - }; + status: 'ok', + data: await TAURI_INVOKE('plugin:haptics|notification_feedback', { + type + }) + } } catch (e) { - if (e instanceof Error) throw e; - else return { status: "error", error: e as any }; + if (e instanceof Error) throw e + else return { status: 'error', error: e as any } } }, async selectionFeedback(): Promise> { try { return { - status: "ok", - data: await TAURI_INVOKE("plugin:haptics|selection_feedback"), - }; + status: 'ok', + data: await TAURI_INVOKE('plugin:haptics|selection_feedback') + } } catch (e) { - if (e instanceof Error) throw e; - else return { status: "error", error: e as any }; + if (e instanceof Error) throw e + else return { status: 'error', error: e as any } } - }, -}; + } +} /** user-defined events **/ @@ -72,69 +72,69 @@ export const commands = { /** user-defined types **/ -export type Error = never; +export type Error = never export type ImpactFeedbackStyle = - | "light" - | "medium" - | "heavy" - | "soft" - | "rigid"; -export type NotificationFeedbackType = "success" | "warning" | "error"; + | 'light' + | 'medium' + | 'heavy' + | 'soft' + | 'rigid' +export type NotificationFeedbackType = 'success' | 'warning' | 'error' //export type RandomNumber = number; /** tauri-specta globals **/ -import { invoke as TAURI_INVOKE } from "@tauri-apps/api/core"; -import * as TAURI_API_EVENT from "@tauri-apps/api/event"; -import { type WebviewWindow as __WebviewWindow__ } from "@tauri-apps/api/webviewWindow"; +import { invoke as TAURI_INVOKE } from '@tauri-apps/api/core' +import * as TAURI_API_EVENT from '@tauri-apps/api/event' +import { type WebviewWindow as __WebviewWindow__ } from '@tauri-apps/api/webviewWindow' type __EventObj__ = { listen: ( - cb: TAURI_API_EVENT.EventCallback, - ) => ReturnType>; + cb: TAURI_API_EVENT.EventCallback + ) => ReturnType> once: ( - cb: TAURI_API_EVENT.EventCallback, - ) => ReturnType>; + cb: TAURI_API_EVENT.EventCallback + ) => ReturnType> emit: T extends null ? (payload?: T) => ReturnType - : (payload: T) => ReturnType; -}; + : (payload: T) => ReturnType +} export type Result = - | { status: "ok"; data: T } - | { status: "error"; error: E }; + | { status: 'ok'; data: T } + | { status: 'error'; error: E } function __makeEvents__>( - mappings: Record, + mappings: Record ) { return new Proxy( {} as unknown as { [K in keyof T]: __EventObj__ & { - (handle: __WebviewWindow__): __EventObj__; - }; + (handle: __WebviewWindow__): __EventObj__ + } }, { get: (_, event) => { - const name = mappings[event as keyof T]; + const name = mappings[event as keyof T] return new Proxy((() => {}) as any, { apply: (_, __, [window]: [__WebviewWindow__]) => ({ listen: (arg: any) => window.listen(name, arg), once: (arg: any) => window.once(name, arg), - emit: (arg: any) => window.emit(name, arg), + emit: (arg: any) => window.emit(name, arg) }), get: (_, command: keyof __EventObj__) => { switch (command) { - case "listen": - return (arg: any) => TAURI_API_EVENT.listen(name, arg); - case "once": - return (arg: any) => TAURI_API_EVENT.once(name, arg); - case "emit": - return (arg: any) => TAURI_API_EVENT.emit(name, arg); + case 'listen': + return (arg: any) => TAURI_API_EVENT.listen(name, arg) + case 'once': + return (arg: any) => TAURI_API_EVENT.once(name, arg) + case 'emit': + return (arg: any) => TAURI_API_EVENT.emit(name, arg) } - }, - }); - }, - }, - ); + } + }) + } + } + ) } diff --git a/plugins/haptics/guest-js/index.ts b/plugins/haptics/guest-js/index.ts index 0354ce845..23485bdfb 100644 --- a/plugins/haptics/guest-js/index.ts +++ b/plugins/haptics/guest-js/index.ts @@ -4,15 +4,15 @@ /* eslint-disable @typescript-eslint/unbound-method */ -import { commands } from "./bindings"; +import { commands } from './bindings' export const { vibrate, impactFeedback, notificationFeedback, - selectionFeedback, -} = commands; + selectionFeedback +} = commands -export { ImpactFeedbackStyle, NotificationFeedbackType } from "./bindings"; +export { ImpactFeedbackStyle, NotificationFeedbackType } from './bindings' // export { events }; diff --git a/plugins/haptics/rollup.config.js b/plugins/haptics/rollup.config.js index 977dfac83..1f349ec8a 100644 --- a/plugins/haptics/rollup.config.js +++ b/plugins/haptics/rollup.config.js @@ -2,6 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { createConfig } from "../../shared/rollup.config.js"; +import { createConfig } from '../../shared/rollup.config.js' -export default createConfig(); +export default createConfig() diff --git a/plugins/http/Cargo.toml b/plugins/http/Cargo.toml index e1e2eb386..925bddd7c 100644 --- a/plugins/http/Cargo.toml +++ b/plugins/http/Cargo.toml @@ -10,11 +10,11 @@ repository = { workspace = true } links = "tauri-plugin-http" [package.metadata.docs.rs] -rustc-args = [ "--cfg", "docsrs" ] -rustdoc-args = [ "--cfg", "docsrs" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] [build-dependencies] -tauri-plugin = { workspace = true, features = [ "build" ] } +tauri-plugin = { workspace = true, features = ["build"] } schemars = { workspace = true } serde = { workspace = true } url = { workspace = true } diff --git a/plugins/http/README.md b/plugins/http/README.md index b4e7c2b72..d6c6a9800 100644 --- a/plugins/http/README.md +++ b/plugins/http/README.md @@ -60,11 +60,11 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { fetch } from "@tauri-apps/plugin-http"; -const response = await fetch("http://localhost:3003/users/2", { - method: "GET", - timeout: 30, -}); +import { fetch } from '@tauri-apps/plugin-http' +const response = await fetch('http://localhost:3003/users/2', { + method: 'GET', + timeout: 30 +}) ``` ## Contributing diff --git a/plugins/http/SECURITY.md b/plugins/http/SECURITY.md index 67d831fc9..4f09bbacd 100644 --- a/plugins/http/SECURITY.md +++ b/plugins/http/SECURITY.md @@ -20,4 +20,4 @@ We prefer to receive reports in English. Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). -Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). \ No newline at end of file +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/http/guest-js/index.ts b/plugins/http/guest-js/index.ts index 3eb597c0c..4362e893a 100644 --- a/plugins/http/guest-js/index.ts +++ b/plugins/http/guest-js/index.ts @@ -26,7 +26,7 @@ * @module */ -import { invoke } from "@tauri-apps/api/core"; +import { invoke } from '@tauri-apps/api/core' /** * Configuration of a proxy that a Client should pass requests to. @@ -37,34 +37,34 @@ export interface Proxy { /** * Proxy all traffic to the passed URL. */ - all?: string | ProxyConfig; + all?: string | ProxyConfig /** * Proxy all HTTP traffic to the passed URL. */ - http?: string | ProxyConfig; + http?: string | ProxyConfig /** * Proxy all HTTPS traffic to the passed URL. */ - https?: string | ProxyConfig; + https?: string | ProxyConfig } export interface ProxyConfig { /** * The URL of the proxy server. */ - url: string; + url: string /** * Set the `Proxy-Authorization` header using Basic auth. */ basicAuth?: { - username: string; - password: string; - }; + username: string + password: string + } /** * A configuration for filtering out requests that shouldn't be proxied. * Entries are expected to be comma-separated (whitespace between entries is ignored) */ - noProxy?: string; + noProxy?: string } /** @@ -77,16 +77,16 @@ export interface ClientOptions { * Defines the maximum number of redirects the client should follow. * If set to 0, no redirects will be followed. */ - maxRedirections?: number; + maxRedirections?: number /** Timeout in milliseconds */ - connectTimeout?: number; + connectTimeout?: number /** * Configuration of a proxy that a Client should pass requests to. */ - proxy?: Proxy; + proxy?: Proxy } -const ERROR_REQUEST_CANCELLED = "Request canceled"; +const ERROR_REQUEST_CANCELLED = 'Request canceled' /** * Fetch a resource from the network. It returns a `Promise` that resolves to the @@ -104,41 +104,41 @@ const ERROR_REQUEST_CANCELLED = "Request canceled"; */ export async function fetch( input: URL | Request | string, - init?: RequestInit & ClientOptions, + init?: RequestInit & ClientOptions ): Promise { // abort early here if needed - const signal = init?.signal; + const signal = init?.signal if (signal?.aborted) { - throw new Error(ERROR_REQUEST_CANCELLED); + throw new Error(ERROR_REQUEST_CANCELLED) } - const maxRedirections = init?.maxRedirections; - const connectTimeout = init?.connectTimeout; - const proxy = init?.proxy; + const maxRedirections = init?.maxRedirections + const connectTimeout = init?.connectTimeout + const proxy = init?.proxy // Remove these fields before creating the request if (init) { - delete init.maxRedirections; - delete init.connectTimeout; - delete init.proxy; + delete init.maxRedirections + delete init.connectTimeout + delete init.proxy } const headers = init?.headers ? init.headers instanceof Headers ? init.headers : new Headers(init.headers) - : new Headers(); + : new Headers() - const req = new Request(input, init); - const buffer = await req.arrayBuffer(); + const req = new Request(input, init) + const buffer = await req.arrayBuffer() const data = - buffer.byteLength !== 0 ? Array.from(new Uint8Array(buffer)) : null; + buffer.byteLength !== 0 ? Array.from(new Uint8Array(buffer)) : null // append new headers created by the browser `Request` implementation, // if not already declared by the caller of this function for (const [key, value] of req.headers) { if (!headers.get(key)) { - headers.set(key, value); + headers.set(key, value) } } @@ -147,7 +147,7 @@ export async function fetch( ? Array.from(headers.entries()) : Array.isArray(headers) ? headers - : Object.entries(headers); + : Object.entries(headers) // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const mappedHeaders: Array<[string, string]> = headersArray.map( @@ -155,16 +155,16 @@ export async function fetch( name, // we need to ensure we have all header values as strings // eslint-disable-next-line - typeof val === "string" ? val : (val as any).toString(), - ], - ); + typeof val === 'string' ? val : (val as any).toString() + ] + ) // abort early here if needed if (signal?.aborted) { - throw new Error(ERROR_REQUEST_CANCELLED); + throw new Error(ERROR_REQUEST_CANCELLED) } - const rid = await invoke("plugin:http|fetch", { + const rid = await invoke('plugin:http|fetch', { clientConfig: { method: req.method, url: req.url, @@ -172,28 +172,28 @@ export async function fetch( data, maxRedirections, connectTimeout, - proxy, - }, - }); + proxy + } + }) - const abort = () => invoke("plugin:http|fetch_cancel", { rid }); + const abort = () => invoke('plugin:http|fetch_cancel', { rid }) // abort early here if needed if (signal?.aborted) { // we don't care about the result of this proimse // eslint-disable-next-line @typescript-eslint/no-floating-promises - abort(); - throw new Error(ERROR_REQUEST_CANCELLED); + abort() + throw new Error(ERROR_REQUEST_CANCELLED) } - signal?.addEventListener("abort", () => void abort()); + signal?.addEventListener('abort', () => void abort()) interface FetchSendResponse { - status: number; - statusText: string; - headers: [[string, string]]; - url: string; - rid: number; + status: number + statusText: string + headers: [[string, string]] + url: string + rid: number } const { @@ -201,17 +201,17 @@ export async function fetch( statusText, url, headers: responseHeaders, - rid: responseRid, - } = await invoke("plugin:http|fetch_send", { - rid, - }); + rid: responseRid + } = await invoke('plugin:http|fetch_send', { + rid + }) const body = await invoke( - "plugin:http|fetch_read_body", + 'plugin:http|fetch_read_body', { - rid: responseRid, - }, - ); + rid: responseRid + } + ) const res = new Response( body instanceof ArrayBuffer && body.byteLength !== 0 @@ -221,9 +221,9 @@ export async function fetch( : null, { status, - statusText, - }, - ); + statusText + } + ) // url and headers are read only properties // but seems like we can set them like this @@ -231,10 +231,10 @@ export async function fetch( // we define theme like this, because using `Response` // constructor, it removes url and some headers // like `set-cookie` headers - Object.defineProperty(res, "url", { value: url }); - Object.defineProperty(res, "headers", { - value: new Headers(responseHeaders), - }); + Object.defineProperty(res, 'url', { value: url }) + Object.defineProperty(res, 'headers', { + value: new Headers(responseHeaders) + }) - return res; + return res } diff --git a/plugins/http/rollup.config.js b/plugins/http/rollup.config.js index 977dfac83..1f349ec8a 100644 --- a/plugins/http/rollup.config.js +++ b/plugins/http/rollup.config.js @@ -2,6 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { createConfig } from "../../shared/rollup.config.js"; +import { createConfig } from '../../shared/rollup.config.js' -export default createConfig(); +export default createConfig() diff --git a/plugins/localhost/Cargo.toml b/plugins/localhost/Cargo.toml index f1ac6faa4..075cd5c36 100644 --- a/plugins/localhost/Cargo.toml +++ b/plugins/localhost/Cargo.toml @@ -9,8 +9,8 @@ rust-version = { workspace = true } repository = { workspace = true } [package.metadata.docs.rs] -rustc-args = [ "--cfg", "docsrs" ] -rustdoc-args = [ "--cfg", "docsrs" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] [dependencies] serde = { workspace = true } diff --git a/plugins/localhost/SECURITY.md b/plugins/localhost/SECURITY.md index 67d831fc9..4f09bbacd 100644 --- a/plugins/localhost/SECURITY.md +++ b/plugins/localhost/SECURITY.md @@ -20,4 +20,4 @@ We prefer to receive reports in English. Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). -Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). \ No newline at end of file +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/log/.gitignore b/plugins/log/.gitignore deleted file mode 100644 index 28fd5eff9..000000000 --- a/plugins/log/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules -/.tauri diff --git a/plugins/log/Cargo.toml b/plugins/log/Cargo.toml index c18da0b9d..dbb146d89 100644 --- a/plugins/log/Cargo.toml +++ b/plugins/log/Cargo.toml @@ -10,11 +10,11 @@ repository = { workspace = true } links = "tauri-plugin-log" [package.metadata.docs.rs] -rustc-args = [ "--cfg", "docsrs" ] -rustdoc-args = [ "--cfg", "docsrs" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] [build-dependencies] -tauri-plugin = { workspace = true, features = [ "build" ] } +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } diff --git a/plugins/log/README.md b/plugins/log/README.md index 437277fc3..e1410ecf6 100644 --- a/plugins/log/README.md +++ b/plugins/log/README.md @@ -68,17 +68,17 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { trace, info, error, attachConsole } from "@tauri-apps/plugin-log"; +import { trace, info, error, attachConsole } from '@tauri-apps/plugin-log' // with TargetKind::Webview enabled this function will print logs to the browser console -const detach = await attachConsole(); +const detach = await attachConsole() -trace("Trace"); -info("Info"); -error("Error"); +trace('Trace') +info('Info') +error('Error') // detach the browser console from the log stream -detach(); +detach() ``` To log from rust code, add the log crate to your `Cargo.toml`: diff --git a/plugins/log/SECURITY.md b/plugins/log/SECURITY.md index 072f2f09e..d013f6a60 100644 --- a/plugins/log/SECURITY.md +++ b/plugins/log/SECURITY.md @@ -39,6 +39,7 @@ One possible threat you need to consider when using this plugin is that secrets in logs can theoretically be leaked when the application's frontend gets compromised. For this threat to be possible all of the following requirements need to be fulfilled: + - `TargetKind::Webview` enabled OR secrets stem from frontend logs - Frontend application is compromised via something like XSS (cross-site-scripting) OR logs are directly exposed - Logs contain secrets or sensitive information diff --git a/plugins/log/guest-js/index.ts b/plugins/log/guest-js/index.ts index 6fa316e46..bf9d7f980 100644 --- a/plugins/log/guest-js/index.ts +++ b/plugins/log/guest-js/index.ts @@ -2,13 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { invoke } from "@tauri-apps/api/core"; -import { listen, type UnlistenFn, type Event } from "@tauri-apps/api/event"; +import { invoke } from '@tauri-apps/api/core' +import { listen, type UnlistenFn, type Event } from '@tauri-apps/api/event' export interface LogOptions { - file?: string; - line?: number; - keyValues?: Record; + file?: string + line?: number + keyValues?: Record } enum LogLevel { @@ -41,35 +41,35 @@ enum LogLevel { * * Designates very serious errors. */ - Error, + Error } async function log( level: LogLevel, message: string, - options?: LogOptions, + options?: LogOptions ): Promise { - const traces = new Error().stack?.split("\n").map((line) => line.split("@")); + const traces = new Error().stack?.split('\n').map((line) => line.split('@')) const filtered = traces?.filter(([name, location]) => { - return name.length > 0 && location !== "[native code]"; - }); + return name.length > 0 && location !== '[native code]' + }) - const { file, line, keyValues } = options ?? {}; + const { file, line, keyValues } = options ?? {} - let location = filtered?.[0]?.filter((v) => v.length > 0).join("@"); - if (location === "Error") { - location = "webview::unknown"; + let location = filtered?.[0]?.filter((v) => v.length > 0).join('@') + if (location === 'Error') { + location = 'webview::unknown' } - await invoke("plugin:log|log", { + await invoke('plugin:log|log', { level, message, location, file, line, - keyValues, - }); + keyValues + }) } /** @@ -90,9 +90,9 @@ async function log( */ export async function error( message: string, - options?: LogOptions, + options?: LogOptions ): Promise { - await log(LogLevel.Error, message, options); + await log(LogLevel.Error, message, options) } /** @@ -112,9 +112,9 @@ export async function error( */ export async function warn( message: string, - options?: LogOptions, + options?: LogOptions ): Promise { - await log(LogLevel.Warn, message, options); + await log(LogLevel.Warn, message, options) } /** @@ -134,9 +134,9 @@ export async function warn( */ export async function info( message: string, - options?: LogOptions, + options?: LogOptions ): Promise { - await log(LogLevel.Info, message, options); + await log(LogLevel.Info, message, options) } /** @@ -156,9 +156,9 @@ export async function info( */ export async function debug( message: string, - options?: LogOptions, + options?: LogOptions ): Promise { - await log(LogLevel.Debug, message, options); + await log(LogLevel.Debug, message, options) } /** @@ -178,17 +178,17 @@ export async function debug( */ export async function trace( message: string, - options?: LogOptions, + options?: LogOptions ): Promise { - await log(LogLevel.Trace, message, options); + await log(LogLevel.Trace, message, options) } interface RecordPayload { - level: LogLevel; - message: string; + level: LogLevel + message: string } -type LoggerFn = (fn: RecordPayload) => void; +type LoggerFn = (fn: RecordPayload) => void /** * Attaches a listener for the log, and calls the passed function for each log entry. @@ -197,19 +197,19 @@ type LoggerFn = (fn: RecordPayload) => void; * @returns a function to cancel the listener. */ export async function attachLogger(fn: LoggerFn): Promise { - return await listen("log://log", (event: Event) => { - const { level } = event.payload; - let { message } = event.payload; + return await listen('log://log', (event: Event) => { + const { level } = event.payload + let { message } = event.payload // Strip ANSI escape codes message = message.replace( // TODO: Investigate security/detect-unsafe-regex // eslint-disable-next-line no-control-regex, security/detect-unsafe-regex /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, - "", - ); - fn({ message, level }); - }); + '' + ) + fn({ message, level }) + }) } /** @@ -221,23 +221,23 @@ export async function attachConsole(): Promise { return await attachLogger(({ level, message }: RecordPayload) => { switch (level) { case LogLevel.Trace: - console.log(message); - break; + console.log(message) + break case LogLevel.Debug: - console.debug(message); - break; + console.debug(message) + break case LogLevel.Info: - console.info(message); - break; + console.info(message) + break case LogLevel.Warn: - console.warn(message); - break; + console.warn(message) + break case LogLevel.Error: - console.error(message); - break; + console.error(message) + break default: // eslint-disable-next-line @typescript-eslint/restrict-template-expressions - throw new Error(`unknown log level ${level}`); + throw new Error(`unknown log level ${level}`) } - }); + }) } diff --git a/plugins/log/rollup.config.js b/plugins/log/rollup.config.js index 977dfac83..1f349ec8a 100644 --- a/plugins/log/rollup.config.js +++ b/plugins/log/rollup.config.js @@ -2,6 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { createConfig } from "../../shared/rollup.config.js"; +import { createConfig } from '../../shared/rollup.config.js' -export default createConfig(); +export default createConfig() diff --git a/plugins/nfc/.gitignore b/plugins/nfc/.gitignore deleted file mode 100644 index 1b0b469d0..000000000 --- a/plugins/nfc/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/.tauri diff --git a/plugins/nfc/Cargo.toml b/plugins/nfc/Cargo.toml index 983f366ea..852862733 100644 --- a/plugins/nfc/Cargo.toml +++ b/plugins/nfc/Cargo.toml @@ -9,12 +9,12 @@ repository = { workspace = true } links = "tauri-plugin-nfc" [package.metadata.docs.rs] -rustc-args = [ "--cfg", "docsrs" ] -rustdoc-args = [ "--cfg", "docsrs" ] -targets = [ "x86_64-linux-android" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] +targets = ["x86_64-linux-android"] [build-dependencies] -tauri-plugin = { workspace = true, features = [ "build" ] } +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } diff --git a/plugins/nfc/README.md b/plugins/nfc/README.md index 9a679cca8..7ad2213df 100644 --- a/plugins/nfc/README.md +++ b/plugins/nfc/README.md @@ -62,9 +62,9 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { scan, textRecord, write } from "@tauri-apps/plugin-nfc"; -await scan({ type: "tag", keepSessionAlive: true }); -await write([textRecord("Tauri is awesome!")]); +import { scan, textRecord, write } from '@tauri-apps/plugin-nfc' +await scan({ type: 'tag', keepSessionAlive: true }) +await write([textRecord('Tauri is awesome!')]) ``` ## Contributing diff --git a/plugins/nfc/SECURITY.md b/plugins/nfc/SECURITY.md index 67d831fc9..4f09bbacd 100644 --- a/plugins/nfc/SECURITY.md +++ b/plugins/nfc/SECURITY.md @@ -20,4 +20,4 @@ We prefer to receive reports in English. Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). -Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). \ No newline at end of file +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/nfc/guest-js/index.ts b/plugins/nfc/guest-js/index.ts index 447e0c0d0..96f7a72dc 100644 --- a/plugins/nfc/guest-js/index.ts +++ b/plugins/nfc/guest-js/index.ts @@ -2,15 +2,15 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { invoke } from "@tauri-apps/api/core"; +import { invoke } from '@tauri-apps/api/core' -export const RTD_TEXT = [0x54]; // "T" -export const RTD_URI = [0x55]; // "U" +export const RTD_TEXT = [0x54] // "T" +export const RTD_URI = [0x55] // "U" export interface UriFilter { - scheme?: string; - host?: string; - pathPrefix?: string; + scheme?: string + host?: string + pathPrefix?: string } export enum TechKind { @@ -23,19 +23,19 @@ export enum TechKind { NfcB, NfcBarcode, NfcF, - NfcV, + NfcV } export type ScanKind = | { - type: "tag"; - uri?: UriFilter; - mimeType?: string; + type: 'tag' + uri?: UriFilter + mimeType?: string } | { - type: "ndef"; - uri?: UriFilter; - mimeType?: string; + type: 'ndef' + uri?: UriFilter + mimeType?: string /** * Each of the tech-lists is considered independently and the activity is considered a match if * any single tech-list matches the tag that was discovered. @@ -56,25 +56,25 @@ export type ScanKind = * ] * ``` */ - techLists?: TechKind[][]; - }; + techLists?: TechKind[][] + } export interface ScanOptions { - keepSessionAlive?: boolean; + keepSessionAlive?: boolean /** Message displayed in the UI. iOS only. */ - message?: string; + message?: string /** Message displayed in the UI when the message has been read. iOS only. */ - successMessage?: string; + successMessage?: string } export interface WriteOptions { - kind?: ScanKind; + kind?: ScanKind /** Message displayed in the UI when reading the tag. iOS only. */ - message?: string; + message?: string /** Message displayed in the UI when the tag has been read. iOS only. */ - successfulReadMessage?: string; + successfulReadMessage?: string /** Message displayed in the UI when the message has been written. iOS only. */ - successMessage?: string; + successMessage?: string } export enum NFCTypeNameFormat { @@ -84,122 +84,120 @@ export enum NFCTypeNameFormat { AbsoluteURI = 3, NfcExternal = 4, Unknown = 5, - Unchanged = 6, + Unchanged = 6 } export interface TagRecord { - tnf: NFCTypeNameFormat; - kind: number[]; - id: number[]; - payload: number[]; + tnf: NFCTypeNameFormat + kind: number[] + id: number[] + payload: number[] } export interface Tag { - id: number[]; - kind: string[]; - records: TagRecord[]; + id: number[] + kind: string[] + records: TagRecord[] } export interface NFCRecord { - format: NFCTypeNameFormat; - kind: number[]; - id: number[]; - payload: number[]; + format: NFCTypeNameFormat + kind: number[] + id: number[] + payload: number[] } export function record( format: NFCTypeNameFormat, kind: string | number[], id: string | number[], - payload: string | number[], + payload: string | number[] ): NFCRecord { return { format, kind: - typeof kind === "string" + typeof kind === 'string' ? Array.from(new TextEncoder().encode(kind)) : kind, - id: typeof id === "string" ? Array.from(new TextEncoder().encode(id)) : id, + id: typeof id === 'string' ? Array.from(new TextEncoder().encode(id)) : id, payload: - typeof payload === "string" + typeof payload === 'string' ? Array.from(new TextEncoder().encode(payload)) - : payload, - }; + : payload + } } export function textRecord( text: string, id?: string | number[], - language: string = "en", + language: string = 'en' ): NFCRecord { - const payload = Array.from(new TextEncoder().encode(language + text)); - payload.unshift(language.length); - return record(NFCTypeNameFormat.NfcWellKnown, RTD_TEXT, id ?? [], payload); + const payload = Array.from(new TextEncoder().encode(language + text)) + payload.unshift(language.length) + return record(NFCTypeNameFormat.NfcWellKnown, RTD_TEXT, id ?? [], payload) } const protocols = [ - "", - "http://www.", - "https://www.", - "http://", - "https://", - "tel:", - "mailto:", - "ftp://anonymous:anonymous@", - "ftp://ftp.", - "ftps://", - "sftp://", - "smb://", - "nfs://", - "ftp://", - "dav://", - "news:", - "telnet://", - "imap:", - "rtsp://", - "urn:", - "pop:", - "sip:", - "sips:", - "tftp:", - "btspp://", - "btl2cap://", - "btgoep://", - "tcpobex://", - "irdaobex://", - "file://", - "urn:epc:id:", - "urn:epc:tag:", - "urn:epc:pat:", - "urn:epc:raw:", - "urn:epc:", - "urn:nfc:", -]; + '', + 'http://www.', + 'https://www.', + 'http://', + 'https://', + 'tel:', + 'mailto:', + 'ftp://anonymous:anonymous@', + 'ftp://ftp.', + 'ftps://', + 'sftp://', + 'smb://', + 'nfs://', + 'ftp://', + 'dav://', + 'news:', + 'telnet://', + 'imap:', + 'rtsp://', + 'urn:', + 'pop:', + 'sip:', + 'sips:', + 'tftp:', + 'btspp://', + 'btl2cap://', + 'btgoep://', + 'tcpobex://', + 'irdaobex://', + 'file://', + 'urn:epc:id:', + 'urn:epc:tag:', + 'urn:epc:pat:', + 'urn:epc:raw:', + 'urn:epc:', + 'urn:nfc:' +] function encodeURI(uri: string): number[] { - let prefix = ""; + let prefix = '' protocols.slice(1).forEach(function (protocol) { if ( - (prefix.length === 0 || prefix === "urn:") && + (prefix.length === 0 || prefix === 'urn:') && uri.indexOf(protocol) === 0 ) { - prefix = protocol; + prefix = protocol } - }); + }) if (prefix.length === 0) { - prefix = ""; + prefix = '' } - const encoded = Array.from( - new TextEncoder().encode(uri.slice(prefix.length)), - ); - const protocolCode = protocols.indexOf(prefix); + const encoded = Array.from(new TextEncoder().encode(uri.slice(prefix.length))) + const protocolCode = protocols.indexOf(prefix) // prepend protocol code - encoded.unshift(protocolCode); + encoded.unshift(protocolCode) - return encoded; + return encoded } export function uriRecord(uri: string, id?: string | number[]): NFCRecord { @@ -207,13 +205,13 @@ export function uriRecord(uri: string, id?: string | number[]): NFCRecord { NFCTypeNameFormat.NfcWellKnown, RTD_URI, id ?? [], - encodeURI(uri), - ); + encodeURI(uri) + ) } function mapScanKind(kind: ScanKind): Record { - const { type: scanKind, ...kindOptions } = kind; - return { [scanKind]: kindOptions }; + const { type: scanKind, ...kindOptions } = kind + return { [scanKind]: kindOptions } } /** @@ -232,12 +230,12 @@ function mapScanKind(kind: ScanKind): Record { */ export async function scan( kind: ScanKind, - options?: ScanOptions, + options?: ScanOptions ): Promise { - return await invoke("plugin:nfc|scan", { + return await invoke('plugin:nfc|scan', { kind: mapScanKind(kind), - ...options, - }); + ...options + }) } /** @@ -257,19 +255,19 @@ export async function scan( */ export async function write( records: NFCRecord[], - options?: WriteOptions, + options?: WriteOptions ): Promise { - const { kind, ...opts } = options ?? {}; + const { kind, ...opts } = options ?? {} if (kind) { // @ts-expect-error map the property - opts.kind = mapScanKind(kind); + opts.kind = mapScanKind(kind) } - await invoke("plugin:nfc|write", { + await invoke('plugin:nfc|write', { records, - ...opts, - }); + ...opts + }) } export async function isAvailable(): Promise { - return await invoke("plugin:nfc|is_available"); + return await invoke('plugin:nfc|is_available') } diff --git a/plugins/nfc/permissions/default.toml b/plugins/nfc/permissions/default.toml index 3be65b192..d69c7f1bd 100644 --- a/plugins/nfc/permissions/default.toml +++ b/plugins/nfc/permissions/default.toml @@ -12,7 +12,4 @@ and scanning nearby tags is allowed. Writing to tags needs to be manually enabled. """ -permissions = [ - "allow-is-available", - "allow-scan", -] +permissions = ["allow-is-available", "allow-scan"] diff --git a/plugins/nfc/rollup.config.js b/plugins/nfc/rollup.config.js index 977dfac83..1f349ec8a 100644 --- a/plugins/nfc/rollup.config.js +++ b/plugins/nfc/rollup.config.js @@ -2,6 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { createConfig } from "../../shared/rollup.config.js"; +import { createConfig } from '../../shared/rollup.config.js' -export default createConfig(); +export default createConfig() diff --git a/plugins/notification/.gitignore b/plugins/notification/.gitignore deleted file mode 100644 index 1b0b469d0..000000000 --- a/plugins/notification/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/.tauri diff --git a/plugins/notification/Cargo.toml b/plugins/notification/Cargo.toml index 6a5d1f466..0ab0b76c0 100644 --- a/plugins/notification/Cargo.toml +++ b/plugins/notification/Cargo.toml @@ -10,12 +10,12 @@ repository = { workspace = true } links = "tauri-plugin-notification" [package.metadata.docs.rs] -rustc-args = [ "--cfg", "docsrs" ] -rustdoc-args = [ "--cfg", "docsrs" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] targets = ["x86_64-unknown-linux-gnu", "x86_64-linux-android"] [build-dependencies] -tauri-plugin = { workspace = true, features = [ "build" ] } +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } diff --git a/plugins/notification/README.md b/plugins/notification/README.md index 4085cd021..65fd4852d 100644 --- a/plugins/notification/README.md +++ b/plugins/notification/README.md @@ -72,24 +72,27 @@ Then you need to add the permissions to your capabilities file: } ``` - Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { isPermissionGranted, requestPermission, sendNotification } from '@tauri-apps/plugin-notification'; +import { + isPermissionGranted, + requestPermission, + sendNotification +} from '@tauri-apps/plugin-notification' async function checkPermission() { if (!(await isPermissionGranted())) { - return (await requestPermission()) === 'granted'; + return (await requestPermission()) === 'granted' } - return true; + return true } export async function enqueueNotification(title, body) { if (!(await checkPermission())) { - return; + return } - sendNotification({ title, body }); + sendNotification({ title, body }) } ``` diff --git a/plugins/notification/SECURITY.md b/plugins/notification/SECURITY.md index 67d831fc9..4f09bbacd 100644 --- a/plugins/notification/SECURITY.md +++ b/plugins/notification/SECURITY.md @@ -20,4 +20,4 @@ We prefer to receive reports in English. Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). -Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). \ No newline at end of file +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/notification/guest-js/index.ts b/plugins/notification/guest-js/index.ts index efc466a22..9f81a1e18 100644 --- a/plugins/notification/guest-js/index.ts +++ b/plugins/notification/guest-js/index.ts @@ -12,10 +12,10 @@ import { invoke, type PluginListener, - addPluginListener, -} from "@tauri-apps/api/core"; + addPluginListener +} from '@tauri-apps/api/core' -export type { PermissionState } from "@tauri-apps/api/core"; +export type { PermissionState } from '@tauri-apps/api/core' /** * Options to send a notification. @@ -26,54 +26,54 @@ interface Options { /** * The notification identifier to reference this object later. Must be a 32-bit integer. */ - id?: number; + id?: number /** * Identifier of the {@link Channel} that deliveres this notification. * * If the channel does not exist, the notification won't fire. * Make sure the channel exists with {@link listChannels} and {@link createChannel}. */ - channelId?: string; + channelId?: string /** * Notification title. */ - title: string; + title: string /** * Optional notification body. * */ - body?: string; + body?: string /** * Schedule this notification to fire on a later time or a fixed interval. */ - schedule?: Schedule; + schedule?: Schedule /** * Multiline text. * Changes the notification style to big text. * Cannot be used with `inboxLines`. */ - largeBody?: string; + largeBody?: string /** * Detail text for the notification with `largeBody`, `inboxLines` or `groupSummary`. */ - summary?: string; + summary?: string /** * Defines an action type for this notification. */ - actionTypeId?: string; + actionTypeId?: string /** * Identifier used to group multiple notifications. * * https://developer.apple.com/documentation/usernotifications/unmutablenotificationcontent/1649872-threadidentifier */ - group?: string; + group?: string /** * Instructs the system that this notification is the summary of a group on Android. */ - groupSummary?: boolean; + groupSummary?: boolean /** * The sound resource name. Only available on mobile. */ - sound?: string; + sound?: string /** * List of lines to add to the notification. * Changes the notification style to inbox. @@ -81,31 +81,31 @@ interface Options { * * Only supports up to 5 lines. */ - inboxLines?: string[]; + inboxLines?: string[] /** * Notification icon. * * On Android the icon must be placed in the app's `res/drawable` folder. */ - icon?: string; + icon?: string /** * Notification large icon (Android). * * The icon must be placed in the app's `res/drawable` folder. */ - largeIcon?: string; + largeIcon?: string /** * Icon color on Android. */ - iconColor?: string; + iconColor?: string /** * Notification attachments. */ - attachments?: Attachment[]; + attachments?: Attachment[] /** * Extra payload to store in the notification. */ - extra?: Record; + extra?: Record /** * If true, the notification cannot be dismissed by the user on Android. * @@ -113,29 +113,29 @@ interface Options { * It is typically used to indicate a background task that is pending (e.g. a file download) * or the user is engaged with (e.g. playing music). */ - ongoing?: boolean; + ongoing?: boolean /** * Automatically cancel the notification when the user clicks on it. */ - autoCancel?: boolean; + autoCancel?: boolean /** * Changes the notification presentation to be silent on iOS (no badge, no sound, not listed). */ - silent?: boolean; + silent?: boolean /** * Notification visibility. */ - visibility?: Visibility; + visibility?: Visibility /** * Sets the number of items this notification represents on Android. */ - number?: number; + number?: number } interface ScheduleInterval { - year?: number; - month?: number; - day?: number; + year?: number + month?: number + day?: number /** * 1 - Sunday * 2 - Monday @@ -145,79 +145,79 @@ interface ScheduleInterval { * 6 - Friday * 7 - Saturday */ - weekday?: number; - hour?: number; - minute?: number; - second?: number; + weekday?: number + hour?: number + minute?: number + second?: number } enum ScheduleEvery { - Year = "year", - Month = "month", - TwoWeeks = "twoWeeks", - Week = "week", - Day = "day", - Hour = "hour", - Minute = "minute", + Year = 'year', + Month = 'month', + TwoWeeks = 'twoWeeks', + Week = 'week', + Day = 'day', + Hour = 'hour', + Minute = 'minute', /** * Not supported on iOS. */ - Second = "second", + Second = 'second' } class Schedule { at: | { - date: Date; - repeating: boolean; - allowWhileIdle: boolean; + date: Date + repeating: boolean + allowWhileIdle: boolean } - | undefined; + | undefined interval: | { - interval: ScheduleInterval; - allowWhileIdle: boolean; + interval: ScheduleInterval + allowWhileIdle: boolean } - | undefined; + | undefined every: | { - interval: ScheduleEvery; - count: number; - allowWhileIdle: boolean; + interval: ScheduleEvery + count: number + allowWhileIdle: boolean } - | undefined; + | undefined static at(date: Date, repeating = false, allowWhileIdle = false): Schedule { return { at: { date, repeating, allowWhileIdle }, interval: undefined, - every: undefined, - }; + every: undefined + } } static interval( interval: ScheduleInterval, - allowWhileIdle = false, + allowWhileIdle = false ): Schedule { return { at: undefined, interval: { interval, allowWhileIdle }, - every: undefined, - }; + every: undefined + } } static every( kind: ScheduleEvery, count: number, - allowWhileIdle = false, + allowWhileIdle = false ): Schedule { return { at: undefined, interval: undefined, - every: { interval: kind, count, allowWhileIdle }, - }; + every: { interval: kind, count, allowWhileIdle } + } } } @@ -226,58 +226,58 @@ class Schedule { */ interface Attachment { /** Attachment identifier. */ - id: string; + id: string /** Attachment URL. Accepts the `asset` and `file` protocols. */ - url: string; + url: string } interface Action { - id: string; - title: string; - requiresAuthentication?: boolean; - foreground?: boolean; - destructive?: boolean; - input?: boolean; - inputButtonTitle?: string; - inputPlaceholder?: string; + id: string + title: string + requiresAuthentication?: boolean + foreground?: boolean + destructive?: boolean + input?: boolean + inputButtonTitle?: string + inputPlaceholder?: string } interface ActionType { /** * The identifier of this action type */ - id: string; + id: string /** * The list of associated actions */ - actions: Action[]; - hiddenPreviewsBodyPlaceholder?: string; - customDismissAction?: boolean; - allowInCarPlay?: boolean; - hiddenPreviewsShowTitle?: boolean; - hiddenPreviewsShowSubtitle?: boolean; + actions: Action[] + hiddenPreviewsBodyPlaceholder?: string + customDismissAction?: boolean + allowInCarPlay?: boolean + hiddenPreviewsShowTitle?: boolean + hiddenPreviewsShowSubtitle?: boolean } interface PendingNotification { - id: number; - title?: string; - body?: string; - schedule: Schedule; + id: number + title?: string + body?: string + schedule: Schedule } interface ActiveNotification { - id: number; - tag?: string; - title?: string; - body?: string; - group?: string; - groupSummary: boolean; - data: Record; - extra: Record; - attachments: Attachment[]; - actionTypeId?: string; - schedule?: Schedule; - sound?: string; + id: number + tag?: string + title?: string + body?: string + group?: string + groupSummary: boolean + data: Record + extra: Record + attachments: Attachment[] + actionTypeId?: string + schedule?: Schedule + sound?: string } enum Importance { @@ -285,25 +285,25 @@ enum Importance { Min, Low, Default, - High, + High } enum Visibility { Secret = -1, Private, - Public, + Public } interface Channel { - id: string; - name: string; - description?: string; - sound?: string; - lights?: boolean; - lightColor?: string; - vibration?: boolean; - importance?: Importance; - visibility?: Visibility; + id: string + name: string + description?: string + sound?: string + lights?: boolean + lightColor?: string + vibration?: boolean + importance?: Importance + visibility?: Visibility } /** @@ -317,10 +317,10 @@ interface Channel { * @since 2.0.0 */ async function isPermissionGranted(): Promise { - if (window.Notification.permission !== "default") { - return await Promise.resolve(window.Notification.permission === "granted"); + if (window.Notification.permission !== 'default') { + return await Promise.resolve(window.Notification.permission === 'granted') } - return await invoke("plugin:notification|is_permission_granted"); + return await invoke('plugin:notification|is_permission_granted') } /** @@ -340,7 +340,7 @@ async function isPermissionGranted(): Promise { * @since 2.0.0 */ async function requestPermission(): Promise { - return await window.Notification.requestPermission(); + return await window.Notification.requestPermission() } /** @@ -362,10 +362,10 @@ async function requestPermission(): Promise { * @since 2.0.0 */ function sendNotification(options: Options | string): void { - if (typeof options === "string") { - new window.Notification(options); + if (typeof options === 'string') { + new window.Notification(options) } else { - new window.Notification(options.title, options); + new window.Notification(options.title, options) } } @@ -389,7 +389,7 @@ function sendNotification(options: Options | string): void { * @since 2.0.0 */ async function registerActionTypes(types: ActionType[]): Promise { - await invoke("plugin:notification|register_action_types", { types }); + await invoke('plugin:notification|register_action_types', { types }) } /** @@ -406,7 +406,7 @@ async function registerActionTypes(types: ActionType[]): Promise { * @since 2.0.0 */ async function pending(): Promise { - return await invoke("plugin:notification|get_pending"); + return await invoke('plugin:notification|get_pending') } /** @@ -423,7 +423,7 @@ async function pending(): Promise { * @since 2.0.0 */ async function cancel(notifications: number[]): Promise { - await invoke("plugin:notification|cancel", { notifications }); + await invoke('plugin:notification|cancel', { notifications }) } /** @@ -440,7 +440,7 @@ async function cancel(notifications: number[]): Promise { * @since 2.0.0 */ async function cancelAll(): Promise { - await invoke("plugin:notification|cancel"); + await invoke('plugin:notification|cancel') } /** @@ -457,7 +457,7 @@ async function cancelAll(): Promise { * @since 2.0.0 */ async function active(): Promise { - return await invoke("plugin:notification|get_active"); + return await invoke('plugin:notification|get_active') } /** @@ -474,9 +474,9 @@ async function active(): Promise { * @since 2.0.0 */ async function removeActive( - notifications: Array<{ id: number; tag?: string }>, + notifications: Array<{ id: number; tag?: string }> ): Promise { - await invoke("plugin:notification|remove_active", { notifications }); + await invoke('plugin:notification|remove_active', { notifications }) } /** @@ -493,7 +493,7 @@ async function removeActive( * @since 2.0.0 */ async function removeAllActive(): Promise { - await invoke("plugin:notification|remove_active"); + await invoke('plugin:notification|remove_active') } /** @@ -517,7 +517,7 @@ async function removeAllActive(): Promise { * @since 2.0.0 */ async function createChannel(channel: Channel): Promise { - await invoke("plugin:notification|create_channel", { ...channel }); + await invoke('plugin:notification|create_channel', { ...channel }) } /** @@ -534,7 +534,7 @@ async function createChannel(channel: Channel): Promise { * @since 2.0.0 */ async function removeChannel(id: string): Promise { - await invoke("plugin:notification|delete_channel", { id }); + await invoke('plugin:notification|delete_channel', { id }) } /** @@ -551,19 +551,19 @@ async function removeChannel(id: string): Promise { * @since 2.0.0 */ async function channels(): Promise { - return await invoke("plugin:notification|listChannels"); + return await invoke('plugin:notification|listChannels') } async function onNotificationReceived( - cb: (notification: Options) => void, + cb: (notification: Options) => void ): Promise { - return await addPluginListener("notification", "notification", cb); + return await addPluginListener('notification', 'notification', cb) } async function onAction( - cb: (notification: Options) => void, + cb: (notification: Options) => void ): Promise { - return await addPluginListener("notification", "actionPerformed", cb); + return await addPluginListener('notification', 'actionPerformed', cb) } export type { @@ -574,8 +574,8 @@ export type { PendingNotification, ActiveNotification, Channel, - ScheduleInterval, -}; + ScheduleInterval +} export { Importance, @@ -596,5 +596,5 @@ export { onNotificationReceived, onAction, Schedule, - ScheduleEvery, -}; + ScheduleEvery +} diff --git a/plugins/notification/guest-js/init.ts b/plugins/notification/guest-js/init.ts index ec98403d4..42d65fd99 100644 --- a/plugins/notification/guest-js/init.ts +++ b/plugins/notification/guest-js/init.ts @@ -2,92 +2,89 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { invoke } from "@tauri-apps/api/core"; -import type { PermissionState } from "@tauri-apps/api/core"; -import type { Options } from "./index"; - -(function () { - let permissionSettable = false; - let permissionValue = "default"; +import { invoke } from '@tauri-apps/api/core' +import type { PermissionState } from '@tauri-apps/api/core' +import type { Options } from './index' +;(function () { + let permissionSettable = false + let permissionValue = 'default' async function isPermissionGranted(): Promise { // @ts-expect-error __TEMPLATE_windows__ will be replaced in rust before it's injected. - if (window.Notification.permission !== "default" || __TEMPLATE_windows__) { - return await Promise.resolve( - window.Notification.permission === "granted", - ); + if (window.Notification.permission !== 'default' || __TEMPLATE_windows__) { + return await Promise.resolve(window.Notification.permission === 'granted') } - return await invoke("plugin:notification|is_permission_granted"); + return await invoke('plugin:notification|is_permission_granted') } function setNotificationPermission(value: NotificationPermission): void { - permissionSettable = true; + permissionSettable = true // @ts-expect-error we can actually set this value on the webview - window.Notification.permission = value; - permissionSettable = false; + window.Notification.permission = value + permissionSettable = false } async function requestPermission(): Promise { return await invoke( - "plugin:notification|request_permission", + 'plugin:notification|request_permission' ).then((permission) => { setNotificationPermission( - permission === "prompt" || permission === "prompt-with-rationale" - ? "default" - : permission, - ); - return permission; - }); + permission === 'prompt' || permission === 'prompt-with-rationale' + ? 'default' + : permission + ) + return permission + }) } async function sendNotification(options: string | Options): Promise { - if (typeof options === "object") { - Object.freeze(options); + if (typeof options === 'object') { + Object.freeze(options) } - await invoke("plugin:notification|notify", { + await invoke('plugin:notification|notify', { options: - typeof options === "string" + typeof options === 'string' ? { - title: options, + title: options } - : options, - }); + : options + }) } // @ts-expect-error unfortunately we can't implement the whole type, so we overwrite it with our own version window.Notification = function (title, options) { // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - const opts = options || {}; + const opts = options || {} void sendNotification( // eslint-disable-next-line @typescript-eslint/no-unsafe-argument Object.assign(opts, { // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - title, - }), - ); - }; + title + }) + ) + } // @ts-expect-error tauri does not have sync IPC :( - window.Notification.requestPermission = requestPermission; + window.Notification.requestPermission = requestPermission - Object.defineProperty(window.Notification, "permission", { + Object.defineProperty(window.Notification, 'permission', { enumerable: true, get: () => permissionValue, set: (v) => { if (!permissionSettable) { - throw new Error("Readonly property"); + throw new Error('Readonly property') } // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - permissionValue = v; - }, - }); + permissionValue = v + } + }) void isPermissionGranted().then(function (response) { if (response === null) { - setNotificationPermission("default"); + setNotificationPermission('default') } else { - setNotificationPermission(response ? "granted" : "denied"); + setNotificationPermission(response ? 'granted' : 'denied') } - }); -})(); + }) +})() diff --git a/plugins/notification/permissions/default.toml b/plugins/notification/permissions/default.toml index e59d206aa..00b4e1d0c 100644 --- a/plugins/notification/permissions/default.toml +++ b/plugins/notification/permissions/default.toml @@ -26,5 +26,5 @@ permissions = [ "allow-list-channels", "allow-delete-channel", "allow-create-channel", - "allow-permission-state" + "allow-permission-state", ] diff --git a/plugins/notification/rollup.config.js b/plugins/notification/rollup.config.js index 0aed70d64..a7dbd4f69 100644 --- a/plugins/notification/rollup.config.js +++ b/plugins/notification/rollup.config.js @@ -2,21 +2,21 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { createConfig } from "../../shared/rollup.config.js"; -import { nodeResolve } from "@rollup/plugin-node-resolve"; -import typescript from "@rollup/plugin-typescript"; -import terser from "@rollup/plugin-terser"; +import { createConfig } from '../../shared/rollup.config.js' +import { nodeResolve } from '@rollup/plugin-node-resolve' +import typescript from '@rollup/plugin-typescript' +import terser from '@rollup/plugin-terser' export default createConfig({ additionalConfigs: { - input: "guest-js/init.ts", + input: 'guest-js/init.ts', output: { - file: "src/init-iife.js", - format: "iife", + file: 'src/init-iife.js', + format: 'iife' }, plugins: [typescript(), terser(), nodeResolve()], onwarn: (warning) => { - throw Object.assign(new Error(), warning); - }, - }, -}); + throw Object.assign(new Error(), warning) + } + } +}) diff --git a/plugins/os/Cargo.toml b/plugins/os/Cargo.toml index b7152ea71..017ad0dee 100644 --- a/plugins/os/Cargo.toml +++ b/plugins/os/Cargo.toml @@ -10,11 +10,11 @@ repository = { workspace = true } links = "tauri-plugin-os" [package.metadata.docs.rs] -rustc-args = [ "--cfg", "docsrs" ] -rustdoc-args = [ "--cfg", "docsrs" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] [build-dependencies] -tauri-plugin = { workspace = true, features = [ "build" ] } +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } diff --git a/plugins/os/README.md b/plugins/os/README.md index 8fbce2acf..5d82e9972 100644 --- a/plugins/os/README.md +++ b/plugins/os/README.md @@ -60,8 +60,8 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { version } from "@tauri-apps/plugin-os"; -const osVersion = await version(); +import { version } from '@tauri-apps/plugin-os' +const osVersion = await version() ``` ## Contributing diff --git a/plugins/os/SECURITY.md b/plugins/os/SECURITY.md index 67d831fc9..4f09bbacd 100644 --- a/plugins/os/SECURITY.md +++ b/plugins/os/SECURITY.md @@ -20,4 +20,4 @@ We prefer to receive reports in English. Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). -Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). \ No newline at end of file +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/os/guest-js/index.ts b/plugins/os/guest-js/index.ts index ebdf9820d..697ae8ed3 100644 --- a/plugins/os/guest-js/index.ts +++ b/plugins/os/guest-js/index.ts @@ -8,49 +8,49 @@ * @module */ -import { invoke } from "@tauri-apps/api/core"; +import { invoke } from '@tauri-apps/api/core' /** @ignore */ declare global { interface Window { __TAURI_OS_PLUGIN_INTERNALS__: { - eol: string; - os_type: OsType; - platform: Platform; - family: Family; - version: string; - arch: Arch; - exe_extension: string; - }; + eol: string + os_type: OsType + platform: Platform + family: Family + version: string + arch: Arch + exe_extension: string + } } } type Platform = - | "linux" - | "macos" - | "ios" - | "freebsd" - | "dragonfly" - | "netbsd" - | "openbsd" - | "solaris" - | "android" - | "windows"; - -type OsType = "linux" | "windows" | "macos" | "ios" | "android"; + | 'linux' + | 'macos' + | 'ios' + | 'freebsd' + | 'dragonfly' + | 'netbsd' + | 'openbsd' + | 'solaris' + | 'android' + | 'windows' + +type OsType = 'linux' | 'windows' | 'macos' | 'ios' | 'android' type Arch = - | "x86" - | "x86_64" - | "arm" - | "aarch64" - | "mips" - | "mips64" - | "powerpc" - | "powerpc64" - | "riscv64" - | "s390x" - | "sparc64"; + | 'x86' + | 'x86_64' + | 'arm' + | 'aarch64' + | 'mips' + | 'mips64' + | 'powerpc' + | 'powerpc64' + | 'riscv64' + | 's390x' + | 'sparc64' /** * Returns the operating system-specific end-of-line marker. @@ -60,7 +60,7 @@ type Arch = * @since 2.0.0 * */ function eol(): string { - return window.__TAURI_OS_PLUGIN_INTERNALS__.eol; + return window.__TAURI_OS_PLUGIN_INTERNALS__.eol } /** @@ -77,7 +77,7 @@ function eol(): string { * */ function platform(): Platform { - return window.__TAURI_OS_PLUGIN_INTERNALS__.platform; + return window.__TAURI_OS_PLUGIN_INTERNALS__.platform } /** @@ -91,10 +91,10 @@ function platform(): Platform { * @since 2.0.0 */ function version(): string { - return window.__TAURI_OS_PLUGIN_INTERNALS__.version; + return window.__TAURI_OS_PLUGIN_INTERNALS__.version } -type Family = "unix" | "windows"; +type Family = 'unix' | 'windows' /** * Returns the current operating system family. Possible values are `'unix'`, `'windows'`. @@ -107,7 +107,7 @@ type Family = "unix" | "windows"; * @since 2.0.0 */ function family(): Family { - return window.__TAURI_OS_PLUGIN_INTERNALS__.family; + return window.__TAURI_OS_PLUGIN_INTERNALS__.family } /** @@ -121,7 +121,7 @@ function family(): Family { * @since 2.0.0 */ function type(): OsType { - return window.__TAURI_OS_PLUGIN_INTERNALS__.os_type; + return window.__TAURI_OS_PLUGIN_INTERNALS__.os_type } /** @@ -136,7 +136,7 @@ function type(): OsType { * @since 2.0.0 */ function arch(): Arch { - return window.__TAURI_OS_PLUGIN_INTERNALS__.arch; + return window.__TAURI_OS_PLUGIN_INTERNALS__.arch } /** @@ -150,7 +150,7 @@ function arch(): Arch { * @since 2.0.0 */ function exeExtension(): string { - return window.__TAURI_OS_PLUGIN_INTERNALS__.exe_extension; + return window.__TAURI_OS_PLUGIN_INTERNALS__.exe_extension } /** @@ -167,7 +167,7 @@ function exeExtension(): string { * @since 2.0.0 */ async function locale(): Promise { - return await invoke("plugin:os|locale"); + return await invoke('plugin:os|locale') } /** @@ -179,7 +179,7 @@ async function locale(): Promise { * ``` */ async function hostname(): Promise { - return await invoke("plugin:os|hostname"); + return await invoke('plugin:os|hostname') } export { @@ -191,6 +191,6 @@ export { arch, locale, exeExtension, - hostname, -}; -export type { Platform, OsType, Arch, Family }; + hostname +} +export type { Platform, OsType, Arch, Family } diff --git a/plugins/os/permissions/default.toml b/plugins/os/permissions/default.toml index f14e97fb9..217b389cd 100644 --- a/plugins/os/permissions/default.toml +++ b/plugins/os/permissions/default.toml @@ -13,11 +13,11 @@ All information except the host name are available. """ permissions = [ - "allow-arch", - "allow-exe-extension", - "allow-family", - "allow-locale", - "allow-os-type", - "allow-platform", - "allow-version", -] \ No newline at end of file + "allow-arch", + "allow-exe-extension", + "allow-family", + "allow-locale", + "allow-os-type", + "allow-platform", + "allow-version", +] diff --git a/plugins/os/rollup.config.js b/plugins/os/rollup.config.js index 977dfac83..1f349ec8a 100644 --- a/plugins/os/rollup.config.js +++ b/plugins/os/rollup.config.js @@ -2,6 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { createConfig } from "../../shared/rollup.config.js"; +import { createConfig } from '../../shared/rollup.config.js' -export default createConfig(); +export default createConfig() diff --git a/plugins/os/src/init.js b/plugins/os/src/init.js index f3e2d4aa2..97eeab3a7 100644 --- a/plugins/os/src/init.js +++ b/plugins/os/src/init.js @@ -3,7 +3,7 @@ // SPDX-License-Identifier: MIT // eslint-disable-next-line -Object.defineProperty(window, "__TAURI_OS_PLUGIN_INTERNALS__", { +Object.defineProperty(window, '__TAURI_OS_PLUGIN_INTERNALS__', { value: { eol: __TEMPLATE_eol__, os_type: __TEMPLATE_os_type__, @@ -11,6 +11,6 @@ Object.defineProperty(window, "__TAURI_OS_PLUGIN_INTERNALS__", { family: __TEMPLATE_family__, version: __TEMPLATE_version__, arch: __TEMPLATE_arch__, - exe_extension: __TEMPLATE_exe_extension__, - }, -}); + exe_extension: __TEMPLATE_exe_extension__ + } +}) diff --git a/plugins/persisted-scope/Cargo.toml b/plugins/persisted-scope/Cargo.toml index aea4ce842..3d3cb53f4 100644 --- a/plugins/persisted-scope/Cargo.toml +++ b/plugins/persisted-scope/Cargo.toml @@ -9,8 +9,8 @@ rust-version = { workspace = true } repository = { workspace = true } [package.metadata.docs.rs] -rustc-args = [ "--cfg", "docsrs" ] -rustdoc-args = [ "--cfg", "docsrs" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] [dependencies] serde = { workspace = true } diff --git a/plugins/persisted-scope/SECURITY.md b/plugins/persisted-scope/SECURITY.md index 67d831fc9..4f09bbacd 100644 --- a/plugins/persisted-scope/SECURITY.md +++ b/plugins/persisted-scope/SECURITY.md @@ -20,4 +20,4 @@ We prefer to receive reports in English. Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). -Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). \ No newline at end of file +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/positioner/.gitignore b/plugins/positioner/.gitignore deleted file mode 100644 index b512c09d4..000000000 --- a/plugins/positioner/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules \ No newline at end of file diff --git a/plugins/positioner/Cargo.toml b/plugins/positioner/Cargo.toml index e0a6a309d..4a3f5b0b5 100644 --- a/plugins/positioner/Cargo.toml +++ b/plugins/positioner/Cargo.toml @@ -10,11 +10,11 @@ repository = { workspace = true } links = "tauri-plugin-positioner" [package.metadata.docs.rs] -rustc-args = [ "--cfg", "docsrs" ] -rustdoc-args = [ "--cfg", "docsrs" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] [build-dependencies] -tauri-plugin = { workspace = true, features = [ "build" ] } +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } diff --git a/plugins/positioner/README.md b/plugins/positioner/README.md index 0162a6ad9..db9bab5ab 100644 --- a/plugins/positioner/README.md +++ b/plugins/positioner/README.md @@ -73,9 +73,9 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { moveWindow, Position } from "@tauri-apps/plugin-positioner"; +import { moveWindow, Position } from '@tauri-apps/plugin-positioner' -moveWindow(Position.TopRight); +moveWindow(Position.TopRight) ``` If you only intend on moving the window from rust code, you can import the Window trait extension instead of registering the plugin: diff --git a/plugins/positioner/SECURITY.md b/plugins/positioner/SECURITY.md index 67d831fc9..4f09bbacd 100644 --- a/plugins/positioner/SECURITY.md +++ b/plugins/positioner/SECURITY.md @@ -20,4 +20,4 @@ We prefer to receive reports in English. Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). -Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). \ No newline at end of file +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/positioner/guest-js/index.ts b/plugins/positioner/guest-js/index.ts index aba398312..449e3298b 100644 --- a/plugins/positioner/guest-js/index.ts +++ b/plugins/positioner/guest-js/index.ts @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { invoke } from "@tauri-apps/api/core"; +import { invoke } from '@tauri-apps/api/core' /** * Well known window positions. @@ -23,7 +23,7 @@ export enum Position { TrayRight, TrayBottomRight, TrayCenter, - TrayBottomCenter, + TrayBottomCenter } /** @@ -33,7 +33,7 @@ export enum Position { * @param to The {@link Position} to move to. */ export async function moveWindow(to: Position): Promise { - await invoke("plugin:positioner|move_window", { - position: to, - }); + await invoke('plugin:positioner|move_window', { + position: to + }) } diff --git a/plugins/positioner/rollup.config.js b/plugins/positioner/rollup.config.js index 977dfac83..1f349ec8a 100644 --- a/plugins/positioner/rollup.config.js +++ b/plugins/positioner/rollup.config.js @@ -2,6 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { createConfig } from "../../shared/rollup.config.js"; +import { createConfig } from '../../shared/rollup.config.js' -export default createConfig(); +export default createConfig() diff --git a/plugins/process/Cargo.toml b/plugins/process/Cargo.toml index f51438640..d9b7ecf30 100644 --- a/plugins/process/Cargo.toml +++ b/plugins/process/Cargo.toml @@ -10,11 +10,11 @@ repository = { workspace = true } links = "tauri-plugin-process" [package.metadata.docs.rs] -rustc-args = [ "--cfg", "docsrs" ] -rustdoc-args = [ "--cfg", "docsrs" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] [build-dependencies] -tauri-plugin = { workspace = true, features = [ "build" ] } +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] tauri = { workspace = true } diff --git a/plugins/process/README.md b/plugins/process/README.md index 6b8c65077..89c04d5a0 100644 --- a/plugins/process/README.md +++ b/plugins/process/README.md @@ -60,11 +60,11 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { exit, relaunch } from "@tauri-apps/plugin-process"; +import { exit, relaunch } from '@tauri-apps/plugin-process' // exit the app with the given status code -await exit(0); +await exit(0) // restart the app -await relaunch(); +await relaunch() ``` ## Contributing diff --git a/plugins/process/SECURITY.md b/plugins/process/SECURITY.md index 67d831fc9..4f09bbacd 100644 --- a/plugins/process/SECURITY.md +++ b/plugins/process/SECURITY.md @@ -20,4 +20,4 @@ We prefer to receive reports in English. Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). -Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). \ No newline at end of file +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/process/guest-js/index.ts b/plugins/process/guest-js/index.ts index e3c35eb4a..da15831a2 100644 --- a/plugins/process/guest-js/index.ts +++ b/plugins/process/guest-js/index.ts @@ -7,7 +7,7 @@ * @module */ -import { invoke } from "@tauri-apps/api/core"; +import { invoke } from '@tauri-apps/api/core' /** * Exits immediately with the given `exitCode`. @@ -23,7 +23,7 @@ import { invoke } from "@tauri-apps/api/core"; * @since 2.0.0 */ async function exit(code = 0): Promise { - await invoke("plugin:process|exit", { code }); + await invoke('plugin:process|exit', { code }) } /** @@ -39,7 +39,7 @@ async function exit(code = 0): Promise { * @since 2.0.0 */ async function relaunch(): Promise { - await invoke("plugin:process|restart"); + await invoke('plugin:process|restart') } -export { exit, relaunch }; +export { exit, relaunch } diff --git a/plugins/process/permissions/default.toml b/plugins/process/permissions/default.toml index e492c55aa..619eb9d81 100644 --- a/plugins/process/permissions/default.toml +++ b/plugins/process/permissions/default.toml @@ -11,7 +11,4 @@ This enables to quit via `allow-exit` and restart via `allow-restart` the application. """ -permissions = [ - "allow-exit", - "allow-restart", -] \ No newline at end of file +permissions = ["allow-exit", "allow-restart"] diff --git a/plugins/process/rollup.config.js b/plugins/process/rollup.config.js index 977dfac83..1f349ec8a 100644 --- a/plugins/process/rollup.config.js +++ b/plugins/process/rollup.config.js @@ -2,6 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { createConfig } from "../../shared/rollup.config.js"; +import { createConfig } from '../../shared/rollup.config.js' -export default createConfig(); +export default createConfig() diff --git a/plugins/shell/.gitignore b/plugins/shell/.gitignore deleted file mode 100644 index 1b0b469d0..000000000 --- a/plugins/shell/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/.tauri diff --git a/plugins/shell/Cargo.toml b/plugins/shell/Cargo.toml index bd5d1bdb2..d226fa4e3 100644 --- a/plugins/shell/Cargo.toml +++ b/plugins/shell/Cargo.toml @@ -10,11 +10,11 @@ repository = { workspace = true } links = "tauri-plugin-shell" [package.metadata.docs.rs] -rustc-args = [ "--cfg", "docsrs" ] -rustdoc-args = [ "--cfg", "docsrs" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] [build-dependencies] -tauri-plugin = { workspace = true, features = [ "build" ] } +tauri-plugin = { workspace = true, features = ["build"] } schemars = { workspace = true } serde = { workspace = true } diff --git a/plugins/shell/README.md b/plugins/shell/README.md index 2881f2cf3..25137648e 100644 --- a/plugins/shell/README.md +++ b/plugins/shell/README.md @@ -60,8 +60,8 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { Command } from "@tauri-apps/plugin-shell"; -Command.create("git", ["commit", "-m", "the commit message"]); +import { Command } from '@tauri-apps/plugin-shell' +Command.create('git', ['commit', '-m', 'the commit message']) ``` ## Contributing diff --git a/plugins/shell/SECURITY.md b/plugins/shell/SECURITY.md index 67d831fc9..4f09bbacd 100644 --- a/plugins/shell/SECURITY.md +++ b/plugins/shell/SECURITY.md @@ -20,4 +20,4 @@ We prefer to receive reports in English. Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). -Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). \ No newline at end of file +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/shell/guest-js/index.ts b/plugins/shell/guest-js/index.ts index ad90aeb6c..1ed2ac5d7 100644 --- a/plugins/shell/guest-js/index.ts +++ b/plugins/shell/guest-js/index.ts @@ -63,27 +63,27 @@ * @module */ -import { invoke, Channel } from "@tauri-apps/api/core"; +import { invoke, Channel } from '@tauri-apps/api/core' /** * @since 2.0.0 */ interface SpawnOptions { /** Current working directory. */ - cwd?: string; + cwd?: string /** Environment variables. set to `null` to clear the process env. */ - env?: Record; + env?: Record /** * Character encoding for stdout/stderr * * @since 2.0.0 * */ - encoding?: string; + encoding?: string } /** @ignore */ interface InternalSpawnOptions extends SpawnOptions { - sidecar?: boolean; + sidecar?: boolean } /** @@ -91,13 +91,13 @@ interface InternalSpawnOptions extends SpawnOptions { */ interface ChildProcess { /** Exit code of the process. `null` if the process was terminated by a signal on Unix. */ - code: number | null; + code: number | null /** If the process was terminated by a signal, represents that signal. */ - signal: number | null; + signal: number | null /** The data that the process wrote to `stdout`. */ - stdout: O; + stdout: O /** The data that the process wrote to `stderr`. */ - stderr: O; + stderr: O } /** @@ -108,7 +108,7 @@ class EventEmitter> { /** @ignore */ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any private eventListeners: Record void>> = - Object.create(null); + Object.create(null) /** * Alias for `emitter.on(eventName, listener)`. @@ -117,9 +117,9 @@ class EventEmitter> { */ addListener( eventName: N, - listener: (arg: E[typeof eventName]) => void, + listener: (arg: E[typeof eventName]) => void ): this { - return this.on(eventName, listener); + return this.on(eventName, listener) } /** @@ -129,9 +129,9 @@ class EventEmitter> { */ removeListener( eventName: N, - listener: (arg: E[typeof eventName]) => void, + listener: (arg: E[typeof eventName]) => void ): this { - return this.off(eventName, listener); + return this.off(eventName, listener) } /** @@ -146,16 +146,16 @@ class EventEmitter> { */ on( eventName: N, - listener: (arg: E[typeof eventName]) => void, + listener: (arg: E[typeof eventName]) => void ): this { if (eventName in this.eventListeners) { // eslint-disable-next-line security/detect-object-injection - this.eventListeners[eventName].push(listener); + this.eventListeners[eventName].push(listener) } else { // eslint-disable-next-line security/detect-object-injection - this.eventListeners[eventName] = [listener]; + this.eventListeners[eventName] = [listener] } - return this; + return this } /** @@ -168,13 +168,13 @@ class EventEmitter> { */ once( eventName: N, - listener: (arg: E[typeof eventName]) => void, + listener: (arg: E[typeof eventName]) => void ): this { const wrapper = (arg: E[typeof eventName]): void => { - this.removeListener(eventName, wrapper); - listener(arg); - }; - return this.addListener(eventName, wrapper); + this.removeListener(eventName, wrapper) + listener(arg) + } + return this.addListener(eventName, wrapper) } /** @@ -185,15 +185,15 @@ class EventEmitter> { */ off( eventName: N, - listener: (arg: E[typeof eventName]) => void, + listener: (arg: E[typeof eventName]) => void ): this { if (eventName in this.eventListeners) { // eslint-disable-next-line security/detect-object-injection this.eventListeners[eventName] = this.eventListeners[eventName].filter( - (l) => l !== listener, - ); + (l) => l !== listener + ) } - return this; + return this } /** @@ -206,12 +206,12 @@ class EventEmitter> { removeAllListeners(event?: N): this { if (event) { // eslint-disable-next-line security/detect-object-injection - delete this.eventListeners[event]; + delete this.eventListeners[event] } else { // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - this.eventListeners = Object.create(null); + this.eventListeners = Object.create(null) } - return this; + return this } /** @@ -226,11 +226,11 @@ class EventEmitter> { emit(eventName: N, arg: E[typeof eventName]): boolean { if (eventName in this.eventListeners) { // eslint-disable-next-line security/detect-object-injection - const listeners = this.eventListeners[eventName]; - for (const listener of listeners) listener(arg); - return true; + const listeners = this.eventListeners[eventName] + for (const listener of listeners) listener(arg) + return true } - return false; + return false } /** @@ -241,8 +241,8 @@ class EventEmitter> { listenerCount(eventName: N): number { if (eventName in this.eventListeners) // eslint-disable-next-line security/detect-object-injection - return this.eventListeners[eventName].length; - return 0; + return this.eventListeners[eventName].length + return 0 } /** @@ -257,16 +257,16 @@ class EventEmitter> { */ prependListener( eventName: N, - listener: (arg: E[typeof eventName]) => void, + listener: (arg: E[typeof eventName]) => void ): this { if (eventName in this.eventListeners) { // eslint-disable-next-line security/detect-object-injection - this.eventListeners[eventName].unshift(listener); + this.eventListeners[eventName].unshift(listener) } else { // eslint-disable-next-line security/detect-object-injection - this.eventListeners[eventName] = [listener]; + this.eventListeners[eventName] = [listener] } - return this; + return this } /** @@ -279,15 +279,15 @@ class EventEmitter> { */ prependOnceListener( eventName: N, - listener: (arg: E[typeof eventName]) => void, + listener: (arg: E[typeof eventName]) => void ): this { // eslint-disable-next-line @typescript-eslint/no-explicit-any const wrapper = (arg: any): void => { - this.removeListener(eventName, wrapper); + this.removeListener(eventName, wrapper) // eslint-disable-next-line @typescript-eslint/no-unsafe-argument - listener(arg); - }; - return this.prependListener(eventName, wrapper); + listener(arg) + } + return this.prependListener(eventName, wrapper) } } @@ -296,10 +296,10 @@ class EventEmitter> { */ class Child { /** The child process `pid`. */ - pid: number; + pid: number constructor(pid: number) { - this.pid = pid; + this.pid = pid } /** @@ -320,10 +320,10 @@ class Child { * @since 2.0.0 */ async write(data: IOPayload | number[]): Promise { - await invoke("plugin:shell|stdin_write", { + await invoke('plugin:shell|stdin_write', { pid: this.pid, - buffer: data, - }); + buffer: data + }) } /** @@ -334,20 +334,20 @@ class Child { * @since 2.0.0 */ async kill(): Promise { - await invoke("plugin:shell|kill", { - cmd: "killChild", - pid: this.pid, - }); + await invoke('plugin:shell|kill', { + cmd: 'killChild', + pid: this.pid + }) } } interface CommandEvents { - close: TerminatedPayload; - error: string; + close: TerminatedPayload + error: string } interface OutputEvents { - data: O; + data: O } /** @@ -373,15 +373,15 @@ interface OutputEvents { */ class Command extends EventEmitter { /** @ignore Program to execute. */ - private readonly program: string; + private readonly program: string /** @ignore Program arguments */ - private readonly args: string[]; + private readonly args: string[] /** @ignore Spawn options. */ - private readonly options: InternalSpawnOptions; + private readonly options: InternalSpawnOptions /** Event emitter for the `stdout`. Emits the `data` event. */ - readonly stdout = new EventEmitter>(); + readonly stdout = new EventEmitter>() /** Event emitter for the `stderr`. Emits the `data` event. */ - readonly stderr = new EventEmitter>(); + readonly stderr = new EventEmitter>() /** * @ignore @@ -395,25 +395,25 @@ class Command extends EventEmitter { private constructor( program: string, args: string | string[] = [], - options?: SpawnOptions, + options?: SpawnOptions ) { - super(); - this.program = program; - this.args = typeof args === "string" ? [args] : args; - this.options = options ?? {}; + super() + this.program = program + this.args = typeof args === 'string' ? [args] : args + this.options = options ?? {} } - static create(program: string, args?: string | string[]): Command; + static create(program: string, args?: string | string[]): Command static create( program: string, args?: string | string[], - options?: SpawnOptions & { encoding: "raw" }, - ): Command; + options?: SpawnOptions & { encoding: 'raw' } + ): Command static create( program: string, args?: string | string[], - options?: SpawnOptions, - ): Command; + options?: SpawnOptions + ): Command /** * Creates a command to execute the given program. @@ -430,22 +430,22 @@ class Command extends EventEmitter { static create( program: string, args: string | string[] = [], - options?: SpawnOptions, + options?: SpawnOptions ): Command { - return new Command(program, args, options); + return new Command(program, args, options) } - static sidecar(program: string, args?: string | string[]): Command; + static sidecar(program: string, args?: string | string[]): Command static sidecar( program: string, args?: string | string[], - options?: SpawnOptions & { encoding: "raw" }, - ): Command; + options?: SpawnOptions & { encoding: 'raw' } + ): Command static sidecar( program: string, args?: string | string[], - options?: SpawnOptions, - ): Command; + options?: SpawnOptions + ): Command /** * Creates a command to execute the given sidecar program. @@ -462,11 +462,11 @@ class Command extends EventEmitter { static sidecar( program: string, args: string | string[] = [], - options?: SpawnOptions, + options?: SpawnOptions ): Command { - const instance = new Command(program, args, options); - instance.options.sidecar = true; - return instance; + const instance = new Command(program, args, options) + instance.options.sidecar = true + return instance } /** @@ -477,38 +477,38 @@ class Command extends EventEmitter { * @since 2.0.0 */ async spawn(): Promise { - const program = this.program; - const args = this.args; - const options = this.options; + const program = this.program + const args = this.args + const options = this.options - if (typeof args === "object") { - Object.freeze(args); + if (typeof args === 'object') { + Object.freeze(args) } - const onEvent = new Channel>(); + const onEvent = new Channel>() onEvent.onmessage = (event) => { switch (event.event) { - case "Error": - this.emit("error", event.payload); - break; - case "Terminated": - this.emit("close", event.payload); - break; - case "Stdout": - this.stdout.emit("data", event.payload); - break; - case "Stderr": - this.stderr.emit("data", event.payload); - break; + case 'Error': + this.emit('error', event.payload) + break + case 'Terminated': + this.emit('close', event.payload) + break + case 'Stdout': + this.stdout.emit('data', event.payload) + break + case 'Stderr': + this.stderr.emit('data', event.payload) + break } - }; + } - return await invoke("plugin:shell|spawn", { + return await invoke('plugin:shell|spawn', { program, args, options, - onEvent, - }).then((pid) => new Child(pid)); + onEvent + }).then((pid) => new Child(pid)) } /** @@ -528,19 +528,19 @@ class Command extends EventEmitter { * @since 2.0.0 */ async execute(): Promise> { - const program = this.program; - const args = this.args; - const options = this.options; + const program = this.program + const args = this.args + const options = this.options - if (typeof args === "object") { - Object.freeze(args); + if (typeof args === 'object') { + Object.freeze(args) } - return await invoke>("plugin:shell|execute", { + return await invoke>('plugin:shell|execute', { program, args, - options, - }); + options + }) } } @@ -548,8 +548,8 @@ class Command extends EventEmitter { * Describes the event message received from the command. */ interface Event { - event: T; - payload: V; + event: T + payload: V } /** @@ -557,20 +557,20 @@ interface Event { */ interface TerminatedPayload { /** Exit code of the process. `null` if the process was terminated by a signal on Unix. */ - code: number | null; + code: number | null /** If the process was terminated by a signal, represents that signal. */ - signal: number | null; + signal: number | null } /** Event payload type */ -type IOPayload = string | Uint8Array; +type IOPayload = string | Uint8Array /** Events emitted by the child process. */ type CommandEvent = - | Event<"Stdout", O> - | Event<"Stderr", O> - | Event<"Terminated", TerminatedPayload> - | Event<"Error", string>; + | Event<'Stdout', O> + | Event<'Stderr', O> + | Event<'Terminated', TerminatedPayload> + | Event<'Error', string> /** * Opens a path or URL with the system's default app, @@ -599,18 +599,18 @@ type CommandEvent = * @since 2.0.0 */ async function open(path: string, openWith?: string): Promise { - await invoke("plugin:shell|open", { + await invoke('plugin:shell|open', { path, - with: openWith, - }); + with: openWith + }) } -export { Command, Child, EventEmitter, open }; +export { Command, Child, EventEmitter, open } export type { IOPayload, CommandEvents, TerminatedPayload, OutputEvents, ChildProcess, - SpawnOptions, -}; + SpawnOptions +} diff --git a/plugins/shell/guest-js/init.ts b/plugins/shell/guest-js/init.ts index 895d58648..58d0001ef 100644 --- a/plugins/shell/guest-js/init.ts +++ b/plugins/shell/guest-js/init.ts @@ -2,39 +2,39 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { invoke } from "@tauri-apps/api/core"; +import { invoke } from '@tauri-apps/api/core' // open links with the API function openLinks(): void { - document.querySelector("body")?.addEventListener("click", function (e) { - let target: HTMLElement | null = e.target as HTMLElement; + document.querySelector('body')?.addEventListener('click', function (e) { + let target: HTMLElement | null = e.target as HTMLElement while (target) { - if (target.matches("a")) { - const t = target as HTMLAnchorElement; + if (target.matches('a')) { + const t = target as HTMLAnchorElement if ( - t.href !== "" && - ["http://", "https://", "mailto:", "tel:"].some((v) => - t.href.startsWith(v), + t.href !== '' && + ['http://', 'https://', 'mailto:', 'tel:'].some((v) => + t.href.startsWith(v) ) && - t.target === "_blank" + t.target === '_blank' ) { - void invoke("plugin:shell|open", { - path: t.href, - }); - e.preventDefault(); + void invoke('plugin:shell|open', { + path: t.href + }) + e.preventDefault() } - break; + break } - target = target.parentElement; + target = target.parentElement } - }); + }) } if ( - document.readyState === "complete" || - document.readyState === "interactive" + document.readyState === 'complete' || + document.readyState === 'interactive' ) { - openLinks(); + openLinks() } else { - window.addEventListener("DOMContentLoaded", openLinks, true); + window.addEventListener('DOMContentLoaded', openLinks, true) } diff --git a/plugins/shell/permissions/default.toml b/plugins/shell/permissions/default.toml index 4f17daa49..4569b0528 100644 --- a/plugins/shell/permissions/default.toml +++ b/plugins/shell/permissions/default.toml @@ -12,6 +12,4 @@ scope pre-configured. It will allow opening `http(s)://`, `tel:` and `mailto:` links. """ -permissions = [ - "allow-open", -] +permissions = ["allow-open"] diff --git a/plugins/shell/rollup.config.js b/plugins/shell/rollup.config.js index 0aed70d64..a7dbd4f69 100644 --- a/plugins/shell/rollup.config.js +++ b/plugins/shell/rollup.config.js @@ -2,21 +2,21 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { createConfig } from "../../shared/rollup.config.js"; -import { nodeResolve } from "@rollup/plugin-node-resolve"; -import typescript from "@rollup/plugin-typescript"; -import terser from "@rollup/plugin-terser"; +import { createConfig } from '../../shared/rollup.config.js' +import { nodeResolve } from '@rollup/plugin-node-resolve' +import typescript from '@rollup/plugin-typescript' +import terser from '@rollup/plugin-terser' export default createConfig({ additionalConfigs: { - input: "guest-js/init.ts", + input: 'guest-js/init.ts', output: { - file: "src/init-iife.js", - format: "iife", + file: 'src/init-iife.js', + format: 'iife' }, plugins: [typescript(), terser(), nodeResolve()], onwarn: (warning) => { - throw Object.assign(new Error(), warning); - }, - }, -}); + throw Object.assign(new Error(), warning) + } + } +}) diff --git a/plugins/single-instance/Cargo.toml b/plugins/single-instance/Cargo.toml index 0a1ef1728..5ccd95983 100644 --- a/plugins/single-instance/Cargo.toml +++ b/plugins/single-instance/Cargo.toml @@ -10,8 +10,8 @@ repository = { workspace = true } exclude = ["/examples"] [package.metadata.docs.rs] -rustc-args = [ "--cfg", "docsrs" ] -rustdoc-args = [ "--cfg", "docsrs" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] [dependencies] serde = { workspace = true } diff --git a/plugins/single-instance/SECURITY.md b/plugins/single-instance/SECURITY.md index 67d831fc9..4f09bbacd 100644 --- a/plugins/single-instance/SECURITY.md +++ b/plugins/single-instance/SECURITY.md @@ -20,4 +20,4 @@ We prefer to receive reports in English. Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). -Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). \ No newline at end of file +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/sql/.gitignore b/plugins/sql/.gitignore deleted file mode 100644 index b512c09d4..000000000 --- a/plugins/sql/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules \ No newline at end of file diff --git a/plugins/sql/Cargo.toml b/plugins/sql/Cargo.toml index fcd8aeecf..5c9f6b95d 100644 --- a/plugins/sql/Cargo.toml +++ b/plugins/sql/Cargo.toml @@ -11,11 +11,11 @@ links = "tauri-plugin-sql" [package.metadata.docs.rs] features = ["sqlite"] -rustc-args = [ "--cfg", "docsrs" ] -rustdoc-args = [ "--cfg", "docsrs" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] [build-dependencies] -tauri-plugin = { workspace = true, features = [ "build" ] } +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } diff --git a/plugins/sql/README.md b/plugins/sql/README.md index 123527ddf..24ba1bdff 100644 --- a/plugins/sql/README.md +++ b/plugins/sql/README.md @@ -62,16 +62,16 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import Database from "@tauri-apps/plugin-sql"; +import Database from '@tauri-apps/plugin-sql' // sqlite. The path is relative to `tauri::api::path::BaseDirectory::AppConfig`. -const db = await Database.load("sqlite:test.db"); +const db = await Database.load('sqlite:test.db') // mysql -const db = await Database.load("mysql://user:pass@host/database"); +const db = await Database.load('mysql://user:pass@host/database') // postgres -const db = await Database.load("postgres://postgres:password@localhost/test"); +const db = await Database.load('postgres://postgres:password@localhost/test') -await db.execute("INSERT INTO ..."); +await db.execute('INSERT INTO ...') ``` ## Syntax @@ -84,25 +84,25 @@ We use sqlx as our underlying library, adopting their query syntax: ```javascript // INSERT and UPDATE examples for sqlite and postgres const result = await db.execute( - "INSERT into todos (id, title, status) VALUES ($1, $2, $3)", - [todos.id, todos.title, todos.status], -); + 'INSERT into todos (id, title, status) VALUES ($1, $2, $3)', + [todos.id, todos.title, todos.status] +) const result = await db.execute( - "UPDATE todos SET title = $1, status = $2 WHERE id = $3", - [todos.title, todos.status, todos.id], -); + 'UPDATE todos SET title = $1, status = $2 WHERE id = $3', + [todos.title, todos.status, todos.id] +) // INSERT and UPDATE examples for mysql const result = await db.execute( - "INSERT into todos (id, title, status) VALUES (?, ?, ?)", - [todos.id, todos.title, todos.status], -); + 'INSERT into todos (id, title, status) VALUES (?, ?, ?)', + [todos.id, todos.title, todos.status] +) const result = await db.execute( - "UPDATE todos SET title = ?, status = ? WHERE id = ?", - [todos.title, todos.status, todos.id], -); + 'UPDATE todos SET title = ?, status = ? WHERE id = ?', + [todos.title, todos.status, todos.id] +) ``` ## Migrations @@ -173,8 +173,8 @@ To apply the migrations when the plugin is initialized, add the connection strin Alternatively, the client side `load()` also runs the migrations for a given connection string: ```ts -import Database from "@tauri-apps/plugin-sql"; -const db = await Database.load("sqlite:mydatabase.db"); +import Database from '@tauri-apps/plugin-sql' +const db = await Database.load('sqlite:mydatabase.db') ``` Ensure that the migrations are defined in the correct order and are safe to run multiple times. diff --git a/plugins/sql/SECURITY.md b/plugins/sql/SECURITY.md index 67d831fc9..4f09bbacd 100644 --- a/plugins/sql/SECURITY.md +++ b/plugins/sql/SECURITY.md @@ -20,4 +20,4 @@ We prefer to receive reports in English. Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). -Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). \ No newline at end of file +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/sql/guest-js/index.ts b/plugins/sql/guest-js/index.ts index 6cb475847..05eed0e3a 100644 --- a/plugins/sql/guest-js/index.ts +++ b/plugins/sql/guest-js/index.ts @@ -2,11 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { invoke } from "@tauri-apps/api/core"; +import { invoke } from '@tauri-apps/api/core' export interface QueryResult { /** The number of rows affected by the query. */ - rowsAffected: number; + rowsAffected: number /** * The last inserted `id`. * @@ -15,7 +15,7 @@ export interface QueryResult { * must be used, with a `RETURNING` clause * (`INSERT INTO todos (title) VALUES ($1) RETURNING id`). */ - lastInsertId: number; + lastInsertId: number } /** @@ -25,9 +25,9 @@ export interface QueryResult { * communicating with the rust side of the sql plugin. */ export default class Database { - path: string; + path: string constructor(path: string) { - this.path = path; + this.path = path } /** @@ -46,11 +46,11 @@ export default class Database { * ``` */ static async load(path: string): Promise { - const _path = await invoke("plugin:sql|load", { - db: path, - }); + const _path = await invoke('plugin:sql|load', { + db: path + }) - return new Database(_path); + return new Database(_path) } /** @@ -70,7 +70,7 @@ export default class Database { * ``` */ static get(path: string): Database { - return new Database(path); + return new Database(path) } /** @@ -107,17 +107,17 @@ export default class Database { */ async execute(query: string, bindValues?: unknown[]): Promise { const [rowsAffected, lastInsertId] = await invoke<[number, number]>( - "plugin:sql|execute", + 'plugin:sql|execute', { db: this.path, query, - values: bindValues ?? [], - }, - ); + values: bindValues ?? [] + } + ) return { lastInsertId, - rowsAffected, - }; + rowsAffected + } } /** @@ -139,13 +139,13 @@ export default class Database { * ``` */ async select(query: string, bindValues?: unknown[]): Promise { - const result = await invoke("plugin:sql|select", { + const result = await invoke('plugin:sql|select', { db: this.path, query, - values: bindValues ?? [], - }); + values: bindValues ?? [] + }) - return result; + return result } /** @@ -160,9 +160,9 @@ export default class Database { * @param db - Optionally state the name of a database if you are managing more than one. Otherwise, all database pools will be in scope. */ async close(db?: string): Promise { - const success = await invoke("plugin:sql|close", { - db, - }); - return success; + const success = await invoke('plugin:sql|close', { + db + }) + return success } } diff --git a/plugins/sql/permissions/default.toml b/plugins/sql/permissions/default.toml index dbea84f4d..efac54331 100644 --- a/plugins/sql/permissions/default.toml +++ b/plugins/sql/permissions/default.toml @@ -13,8 +13,4 @@ All reading related operations are enabled. Also allows to load or close a connection. """ -permissions = [ - "allow-close", - "allow-load", - "allow-select", -] +permissions = ["allow-close", "allow-load", "allow-select"] diff --git a/plugins/sql/rollup.config.js b/plugins/sql/rollup.config.js index 977dfac83..1f349ec8a 100644 --- a/plugins/sql/rollup.config.js +++ b/plugins/sql/rollup.config.js @@ -2,6 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { createConfig } from "../../shared/rollup.config.js"; +import { createConfig } from '../../shared/rollup.config.js' -export default createConfig(); +export default createConfig() diff --git a/plugins/store/.gitignore b/plugins/store/.gitignore deleted file mode 100644 index b512c09d4..000000000 --- a/plugins/store/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules \ No newline at end of file diff --git a/plugins/store/Cargo.toml b/plugins/store/Cargo.toml index cf5b31858..9ef49952c 100644 --- a/plugins/store/Cargo.toml +++ b/plugins/store/Cargo.toml @@ -10,11 +10,11 @@ repository = { workspace = true } links = "tauri-plugin-store" [package.metadata.docs.rs] -rustc-args = [ "--cfg", "docsrs" ] -rustdoc-args = [ "--cfg", "docsrs" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] [build-dependencies] -tauri-plugin = { workspace = true, features = [ "build" ] } +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } diff --git a/plugins/store/README.md b/plugins/store/README.md index aabfbf8e4..be6fdfaee 100644 --- a/plugins/store/README.md +++ b/plugins/store/README.md @@ -60,22 +60,22 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```typescript -import { Store } from "@tauri-apps/plugin-store"; +import { Store } from '@tauri-apps/plugin-store' -const store = new Store(".settings.dat"); +const store = new Store('.settings.dat') -await store.set("some-key", { value: 5 }); +await store.set('some-key', { value: 5 }) -const val = await store.get<{ value: number }>("some-key"); +const val = await store.get<{ value: number }>('some-key') if (val) { - console.log(val); + console.log(val) } else { - console.log("val is null"); + console.log('val is null') } // This manually saves the store. -await store.save(); +await store.save() ``` ### Persisting Values @@ -85,14 +85,14 @@ As seen above, values added to the store are not persisted between application l You can manually save a store with: ```javascript -await store.save(); +await store.save() ``` Stores are loaded automatically when used from the JavaScript bindings. However, you can also load them manually later like so: ```javascript -await store.load(); +await store.load() ``` ## Usage from Rust diff --git a/plugins/store/SECURITY.md b/plugins/store/SECURITY.md index 67d831fc9..4f09bbacd 100644 --- a/plugins/store/SECURITY.md +++ b/plugins/store/SECURITY.md @@ -20,4 +20,4 @@ We prefer to receive reports in English. Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). -Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). \ No newline at end of file +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/store/examples/AppSettingsManager/src/main.ts b/plugins/store/examples/AppSettingsManager/src/main.ts index eb240e99c..57cbe4b72 100644 --- a/plugins/store/examples/AppSettingsManager/src/main.ts +++ b/plugins/store/examples/AppSettingsManager/src/main.ts @@ -2,8 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -window.addEventListener("DOMContentLoaded", () => { - document.querySelector("#greet-form")?.addEventListener("submit", (e) => { - e.preventDefault(); - }); -}); +window.addEventListener('DOMContentLoaded', () => { + document.querySelector('#greet-form')?.addEventListener('submit', (e) => { + e.preventDefault() + }) +}) diff --git a/plugins/store/examples/AppSettingsManager/vite.config.ts b/plugins/store/examples/AppSettingsManager/vite.config.ts index 03f44f566..661eb2333 100644 --- a/plugins/store/examples/AppSettingsManager/vite.config.ts +++ b/plugins/store/examples/AppSettingsManager/vite.config.ts @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { defineConfig } from "vite"; +import { defineConfig } from 'vite' // https://vitejs.dev/config/ export default defineConfig(async () => ({ @@ -13,9 +13,9 @@ export default defineConfig(async () => ({ // 2. tauri expects a fixed port, fail if that port is not available server: { port: 1420, - strictPort: true, + strictPort: true }, // 3. to make use of `TAURI_DEBUG` and other env variables // https://tauri.studio/v1/api/config#buildconfig.beforedevcommand - envPrefix: ["VITE_", "TAURI_"], -})); + envPrefix: ['VITE_', 'TAURI_'] +})) diff --git a/plugins/store/guest-js/index.ts b/plugins/store/guest-js/index.ts index 043047396..dce545ac1 100644 --- a/plugins/store/guest-js/index.ts +++ b/plugins/store/guest-js/index.ts @@ -2,23 +2,23 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { listen, type UnlistenFn } from "@tauri-apps/api/event"; +import { listen, type UnlistenFn } from '@tauri-apps/api/event' -import { invoke } from "@tauri-apps/api/core"; +import { invoke } from '@tauri-apps/api/core' interface ChangePayload { - path: string; - key: string; - value: T | null; + path: string + key: string + value: T | null } /** * A key-value store persisted by the backend layer. */ export class Store { - path: string; + path: string constructor(path: string) { - this.path = path; + this.path = path } /** @@ -29,11 +29,11 @@ export class Store { * @returns */ async set(key: string, value: unknown): Promise { - await invoke("plugin:store|set", { + await invoke('plugin:store|set', { path: this.path, key, - value, - }); + value + }) } /** @@ -43,10 +43,10 @@ export class Store { * @returns */ async get(key: string): Promise { - return await invoke("plugin:store|get", { + return await invoke('plugin:store|get', { path: this.path, - key, - }); + key + }) } /** @@ -56,10 +56,10 @@ export class Store { * @returns */ async has(key: string): Promise { - return await invoke("plugin:store|has", { + return await invoke('plugin:store|has', { path: this.path, - key, - }); + key + }) } /** @@ -69,10 +69,10 @@ export class Store { * @returns */ async delete(key: string): Promise { - return await invoke("plugin:store|delete", { + return await invoke('plugin:store|delete', { path: this.path, - key, - }); + key + }) } /** @@ -82,9 +82,9 @@ export class Store { * @returns */ async clear(): Promise { - await invoke("plugin:store|clear", { - path: this.path, - }); + await invoke('plugin:store|clear', { + path: this.path + }) } /** @@ -94,9 +94,9 @@ export class Store { * @returns */ async reset(): Promise { - await invoke("plugin:store|reset", { - path: this.path, - }); + await invoke('plugin:store|reset', { + path: this.path + }) } /** @@ -105,9 +105,9 @@ export class Store { * @returns */ async keys(): Promise { - return await invoke("plugin:store|keys", { - path: this.path, - }); + return await invoke('plugin:store|keys', { + path: this.path + }) } /** @@ -116,9 +116,9 @@ export class Store { * @returns */ async values(): Promise { - return await invoke("plugin:store|values", { - path: this.path, - }); + return await invoke('plugin:store|values', { + path: this.path + }) } /** @@ -127,9 +127,9 @@ export class Store { * @returns */ async entries(): Promise> { - return await invoke("plugin:store|entries", { - path: this.path, - }); + return await invoke('plugin:store|entries', { + path: this.path + }) } /** @@ -138,9 +138,9 @@ export class Store { * @returns */ async length(): Promise { - return await invoke("plugin:store|length", { - path: this.path, - }); + return await invoke('plugin:store|length', { + path: this.path + }) } /** @@ -152,9 +152,9 @@ export class Store { * @returns */ async load(): Promise { - await invoke("plugin:store|load", { - path: this.path, - }); + await invoke('plugin:store|load', { + path: this.path + }) } /** @@ -165,9 +165,9 @@ export class Store { * @returns */ async save(): Promise { - await invoke("plugin:store|save", { - path: this.path, - }); + await invoke('plugin:store|save', { + path: this.path + }) } /** @@ -180,13 +180,13 @@ export class Store { */ async onKeyChange( key: string, - cb: (value: T | null) => void, + cb: (value: T | null) => void ): Promise { - return await listen>("store://change", (event) => { + return await listen>('store://change', (event) => { if (event.payload.path === this.path && event.payload.key === key) { - cb(event.payload.value); + cb(event.payload.value) } - }); + }) } /** @@ -197,12 +197,12 @@ export class Store { * @since 2.0.0 */ async onChange( - cb: (key: string, value: T | null) => void, + cb: (key: string, value: T | null) => void ): Promise { - return await listen>("store://change", (event) => { + return await listen>('store://change', (event) => { if (event.payload.path === this.path) { - cb(event.payload.key, event.payload.value); + cb(event.payload.key, event.payload.value) } - }); + }) } } diff --git a/plugins/store/rollup.config.js b/plugins/store/rollup.config.js index 977dfac83..1f349ec8a 100644 --- a/plugins/store/rollup.config.js +++ b/plugins/store/rollup.config.js @@ -2,6 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { createConfig } from "../../shared/rollup.config.js"; +import { createConfig } from '../../shared/rollup.config.js' -export default createConfig(); +export default createConfig() diff --git a/plugins/stronghold/.gitignore b/plugins/stronghold/.gitignore deleted file mode 100644 index b512c09d4..000000000 --- a/plugins/stronghold/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules \ No newline at end of file diff --git a/plugins/stronghold/Cargo.toml b/plugins/stronghold/Cargo.toml index 1544af5e2..f13e51769 100644 --- a/plugins/stronghold/Cargo.toml +++ b/plugins/stronghold/Cargo.toml @@ -10,11 +10,11 @@ repository = { workspace = true } links = "tauri-plugin-stronghold" [package.metadata.docs.rs] -rustc-args = [ "--cfg", "docsrs" ] -rustdoc-args = [ "--cfg", "docsrs" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] [build-dependencies] -tauri-plugin = { workspace = true, features = [ "build" ] } +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } diff --git a/plugins/stronghold/SECURITY.md b/plugins/stronghold/SECURITY.md index 67d831fc9..4f09bbacd 100644 --- a/plugins/stronghold/SECURITY.md +++ b/plugins/stronghold/SECURITY.md @@ -20,4 +20,4 @@ We prefer to receive reports in English. Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). -Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). \ No newline at end of file +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/stronghold/guest-js/index.ts b/plugins/stronghold/guest-js/index.ts index f539b7190..c1945a210 100644 --- a/plugins/stronghold/guest-js/index.ts +++ b/plugins/stronghold/guest-js/index.ts @@ -2,112 +2,112 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { invoke } from "@tauri-apps/api/core"; +import { invoke } from '@tauri-apps/api/core' export type ClientPath = | string | Iterable | ArrayLike - | ArrayBuffer; + | ArrayBuffer export type VaultPath = | string | Iterable | ArrayLike - | ArrayBuffer; + | ArrayBuffer export type RecordPath = | string | Iterable | ArrayLike - | ArrayBuffer; + | ArrayBuffer export type StoreKey = | string | Iterable | ArrayLike - | ArrayBuffer; + | ArrayBuffer export interface ConnectionLimits { - maxPendingIncoming?: number; - maxPendingOutgoing?: number; - maxEstablishedIncoming?: number; - maxEstablishedOutgoing?: number; - maxEstablishedPerPeer?: number; - maxEstablishedTotal?: number; + maxPendingIncoming?: number + maxPendingOutgoing?: number + maxEstablishedIncoming?: number + maxEstablishedOutgoing?: number + maxEstablishedPerPeer?: number + maxEstablishedTotal?: number } export interface PeerAddress { - known: string[]; // multiaddr - use_relay_fallback: boolean; + known: string[] // multiaddr + use_relay_fallback: boolean } export interface AddressInfo { - peers: Map; - relays: string[]; // peers + peers: Map + relays: string[] // peers } export interface ClientAccess { - useVaultDefault?: boolean; - useVaultExceptions?: Map; - writeVaultDefault?: boolean; - writeVaultExceptions?: Map; - cloneVaultDefault?: boolean; - cloneVaultExceptions?: Map; - readStore?: boolean; - writeStore?: boolean; + useVaultDefault?: boolean + useVaultExceptions?: Map + writeVaultDefault?: boolean + writeVaultExceptions?: Map + cloneVaultDefault?: boolean + cloneVaultExceptions?: Map + readStore?: boolean + writeStore?: boolean } export interface Permissions { - default?: ClientAccess; - exceptions?: Map; + default?: ClientAccess + exceptions?: Map } export interface NetworkConfig { - requestTimeout?: Duration; - connectionTimeout?: Duration; - connectionsLimit?: ConnectionLimits; - enableMdns?: boolean; - enableRelay?: boolean; - addresses?: AddressInfo; - peerPermissions?: Map; - permissionsDefault?: Permissions; + requestTimeout?: Duration + connectionTimeout?: Duration + connectionsLimit?: ConnectionLimits + enableMdns?: boolean + enableRelay?: boolean + addresses?: AddressInfo + peerPermissions?: Map + permissionsDefault?: Permissions } /** A duration definition. */ export interface Duration { /** The number of whole seconds contained by this Duration. */ - secs: number; + secs: number /** The fractional part of this Duration, in nanoseconds. Must be greater or equal to 0 and smaller than 1e+9 (the max number of nanoseoncds in a second) */ - nanos: number; + nanos: number } export class Location { - type: string; - payload: Record; + type: string + payload: Record constructor(type: string, payload: Record) { - this.type = type; - this.payload = payload; + this.type = type + this.payload = payload } static generic(vault: VaultPath, record: RecordPath): Location { - return new Location("Generic", { + return new Location('Generic', { vault, - record, - }); + record + }) } static counter(vault: VaultPath, counter: number): Location { - return new Location("Counter", { + return new Location('Counter', { vault, - counter, - }); + counter + }) } } class ProcedureExecutor { - procedureArgs: Record; + procedureArgs: Record constructor(procedureArgs: Record) { - this.procedureArgs = procedureArgs; + this.procedureArgs = procedureArgs } /** @@ -119,18 +119,18 @@ class ProcedureExecutor { */ async generateSLIP10Seed( outputLocation: Location, - sizeBytes?: number, + sizeBytes?: number ): Promise { - return await invoke("plugin:stronghold|execute_procedure", { + return await invoke('plugin:stronghold|execute_procedure', { ...this.procedureArgs, procedure: { - type: "SLIP10Generate", + type: 'SLIP10Generate', payload: { output: outputLocation, - sizeBytes, - }, - }, - }).then((n) => Uint8Array.from(n)); + sizeBytes + } + } + }).then((n) => Uint8Array.from(n)) } /** @@ -144,24 +144,24 @@ class ProcedureExecutor { */ async deriveSLIP10( chain: number[], - source: "Seed" | "Key", + source: 'Seed' | 'Key', sourceLocation: Location, - outputLocation: Location, + outputLocation: Location ): Promise { - return await invoke("plugin:stronghold|execute_procedure", { + return await invoke('plugin:stronghold|execute_procedure', { ...this.procedureArgs, procedure: { - type: "SLIP10Derive", + type: 'SLIP10Derive', payload: { chain, input: { type: source, - payload: sourceLocation, + payload: sourceLocation }, - output: outputLocation, - }, - }, - }).then((n) => Uint8Array.from(n)); + output: outputLocation + } + } + }).then((n) => Uint8Array.from(n)) } /** @@ -175,19 +175,19 @@ class ProcedureExecutor { async recoverBIP39( mnemonic: string, outputLocation: Location, - passphrase?: string, + passphrase?: string ): Promise { - return await invoke("plugin:stronghold|execute_procedure", { + return await invoke('plugin:stronghold|execute_procedure', { ...this.procedureArgs, procedure: { - type: "BIP39Recover", + type: 'BIP39Recover', payload: { mnemonic, passphrase, - output: outputLocation, - }, - }, - }).then((n) => Uint8Array.from(n)); + output: outputLocation + } + } + }).then((n) => Uint8Array.from(n)) } /** @@ -199,18 +199,18 @@ class ProcedureExecutor { */ async generateBIP39( outputLocation: Location, - passphrase?: string, + passphrase?: string ): Promise { - return await invoke("plugin:stronghold|execute_procedure", { + return await invoke('plugin:stronghold|execute_procedure', { ...this.procedureArgs, procedure: { - type: "BIP39Generate", + type: 'BIP39Generate', payload: { output: outputLocation, - passphrase, - }, - }, - }).then((n) => Uint8Array.from(n)); + passphrase + } + } + }).then((n) => Uint8Array.from(n)) } /** @@ -221,16 +221,16 @@ class ProcedureExecutor { * @since 2.0.0 */ async getEd25519PublicKey(privateKeyLocation: Location): Promise { - return await invoke("plugin:stronghold|execute_procedure", { + return await invoke('plugin:stronghold|execute_procedure', { ...this.procedureArgs, procedure: { - type: "PublicKey", + type: 'PublicKey', payload: { - type: "Ed25519", - privateKey: privateKeyLocation, - }, - }, - }).then((n) => Uint8Array.from(n)); + type: 'Ed25519', + privateKey: privateKeyLocation + } + } + }).then((n) => Uint8Array.from(n)) } /** @@ -243,28 +243,28 @@ class ProcedureExecutor { */ async signEd25519( privateKeyLocation: Location, - msg: string, + msg: string ): Promise { - return await invoke("plugin:stronghold|execute_procedure", { + return await invoke('plugin:stronghold|execute_procedure', { ...this.procedureArgs, procedure: { - type: "Ed25519Sign", + type: 'Ed25519Sign', payload: { privateKey: privateKeyLocation, - msg, - }, - }, - }).then((n) => Uint8Array.from(n)); + msg + } + } + }).then((n) => Uint8Array.from(n)) } } export class Client { - path: string; - name: ClientPath; + path: string + name: ClientPath constructor(path: string, name: ClientPath) { - this.path = path; - this.name = name; + this.path = path + this.name = name } /** @@ -274,54 +274,54 @@ export class Client { * @returns */ getVault(name: VaultPath): Vault { - return new Vault(this.path, this.name, name); + return new Vault(this.path, this.name, name) } getStore(): Store { - return new Store(this.path, this.name); + return new Store(this.path, this.name) } } export class Store { - path: string; - client: ClientPath; + path: string + client: ClientPath constructor(path: string, client: ClientPath) { - this.path = path; - this.client = client; + this.path = path + this.client = client } async get(key: StoreKey): Promise { - return await invoke("plugin:stronghold|get_store_record", { + return await invoke('plugin:stronghold|get_store_record', { snapshotPath: this.path, client: this.client, - key, - }).then((v) => v && Uint8Array.from(v)); + key + }).then((v) => v && Uint8Array.from(v)) } async insert( key: StoreKey, value: number[], - lifetime?: Duration, + lifetime?: Duration ): Promise { - await invoke("plugin:stronghold|save_store_record", { + await invoke('plugin:stronghold|save_store_record', { snapshotPath: this.path, client: this.client, key, value, - lifetime, - }); + lifetime + }) } async remove(key: StoreKey): Promise { return await invoke( - "plugin:stronghold|remove_store_record", + 'plugin:stronghold|remove_store_record', { snapshotPath: this.path, client: this.client, - key, - }, - ).then((v) => v && Uint8Array.from(v)); + key + } + ).then((v) => v && Uint8Array.from(v)) } } @@ -332,20 +332,20 @@ export class Store { */ export class Vault extends ProcedureExecutor { /** The vault path. */ - path: string; - client: ClientPath; + path: string + client: ClientPath /** The vault name. */ - name: VaultPath; + name: VaultPath constructor(path: string, client: ClientPath, name: VaultPath) { super({ snapshotPath: path, client, - vault: name, - }); - this.path = path; - this.client = client; - this.name = name; + vault: name + }) + this.path = path + this.client = client + this.name = name } /** @@ -356,13 +356,13 @@ export class Vault extends ProcedureExecutor { * @returns */ async insert(recordPath: RecordPath, secret: number[]): Promise { - await invoke("plugin:stronghold|save_secret", { + await invoke('plugin:stronghold|save_secret', { snapshotPath: this.path, client: this.client, vault: this.name, recordPath, - secret, - }); + secret + }) } /** @@ -372,12 +372,12 @@ export class Vault extends ProcedureExecutor { * @returns */ async remove(location: Location): Promise { - await invoke("plugin:stronghold|remove_secret", { + await invoke('plugin:stronghold|remove_secret', { snapshotPath: this.path, client: this.client, vault: this.name, - recordPath: location.payload.record, - }); + recordPath: location.payload.record + }) } } @@ -385,7 +385,7 @@ export class Vault extends ProcedureExecutor { * A representation of an access to a stronghold. */ export class Stronghold { - path: string; + path: string /** * Initializes a stronghold. @@ -394,7 +394,7 @@ export class Stronghold { * @param password */ private constructor(path: string) { - this.path = path; + this.path = path } /** @@ -403,33 +403,33 @@ export class Stronghold { * @returns */ static async load(path: string, password: string): Promise { - return await invoke("plugin:stronghold|initialize", { + return await invoke('plugin:stronghold|initialize', { snapshotPath: path, - password, - }).then(() => new Stronghold(path)); + password + }).then(() => new Stronghold(path)) } /** * Remove this instance from the cache. */ async unload(): Promise { - await invoke("plugin:stronghold|destroy", { - snapshotPath: this.path, - }); + await invoke('plugin:stronghold|destroy', { + snapshotPath: this.path + }) } async loadClient(client: ClientPath): Promise { - return await invoke("plugin:stronghold|load_client", { + return await invoke('plugin:stronghold|load_client', { snapshotPath: this.path, - client, - }).then(() => new Client(this.path, client)); + client + }).then(() => new Client(this.path, client)) } async createClient(client: ClientPath): Promise { - return await invoke("plugin:stronghold|create_client", { + return await invoke('plugin:stronghold|create_client', { snapshotPath: this.path, - client, - }).then(() => new Client(this.path, client)); + client + }).then(() => new Client(this.path, client)) } /** @@ -437,8 +437,8 @@ export class Stronghold { * @returns */ async save(): Promise { - await invoke("plugin:stronghold|save", { - snapshotPath: this.path, - }); + await invoke('plugin:stronghold|save', { + snapshotPath: this.path + }) } } diff --git a/plugins/stronghold/rollup.config.js b/plugins/stronghold/rollup.config.js index 977dfac83..1f349ec8a 100644 --- a/plugins/stronghold/rollup.config.js +++ b/plugins/stronghold/rollup.config.js @@ -2,6 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { createConfig } from "../../shared/rollup.config.js"; +import { createConfig } from '../../shared/rollup.config.js' -export default createConfig(); +export default createConfig() diff --git a/plugins/updater/Cargo.toml b/plugins/updater/Cargo.toml index 0d5cc8be8..0a035eb28 100644 --- a/plugins/updater/Cargo.toml +++ b/plugins/updater/Cargo.toml @@ -10,13 +10,13 @@ repository = { workspace = true } links = "tauri-plugin-updater" [package.metadata.docs.rs] -rustc-args = [ "--cfg", "docsrs" ] -rustdoc-args = [ "--cfg", "docsrs" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] no-default-features = true -features = [ "zip" ] +features = ["zip"] [build-dependencies] -tauri-plugin = { workspace = true, features = [ "build" ] } +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] tauri = { workspace = true } diff --git a/plugins/updater/README.md b/plugins/updater/README.md index e2309f197..836a63b12 100644 --- a/plugins/updater/README.md +++ b/plugins/updater/README.md @@ -67,12 +67,12 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { check } from "@tauri-apps/plugin-updater"; -import { relaunch } from "@tauri-apps/plugin-process"; -const update = await check(); +import { check } from '@tauri-apps/plugin-updater' +import { relaunch } from '@tauri-apps/plugin-process' +const update = await check() if (update?.available) { - await update.downloadAndInstall(); - await relaunch(); + await update.downloadAndInstall() + await relaunch() } ``` diff --git a/plugins/updater/SECURITY.md b/plugins/updater/SECURITY.md index 67d831fc9..4f09bbacd 100644 --- a/plugins/updater/SECURITY.md +++ b/plugins/updater/SECURITY.md @@ -20,4 +20,4 @@ We prefer to receive reports in English. Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). -Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). \ No newline at end of file +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/updater/guest-js/index.ts b/plugins/updater/guest-js/index.ts index 42e69716e..54d1d1743 100644 --- a/plugins/updater/guest-js/index.ts +++ b/plugins/updater/guest-js/index.ts @@ -2,26 +2,26 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { invoke, Channel, Resource } from "@tauri-apps/api/core"; +import { invoke, Channel, Resource } from '@tauri-apps/api/core' /** Options used when checking for updates */ interface CheckOptions { /** * Request headers */ - headers?: HeadersInit; + headers?: HeadersInit /** * Timeout in milliseconds */ - timeout?: number; + timeout?: number /** * A proxy url to be used when checking and downloading updates. */ - proxy?: string; + proxy?: string /** * Target identifier for the running application. This is sent to the backend. */ - target?: string; + target?: string } /** Options used when downloading an update */ @@ -29,109 +29,109 @@ interface DownloadOptions { /** * Request headers */ - headers?: HeadersInit; + headers?: HeadersInit /** * Timeout in milliseconds */ - timeout?: number; + timeout?: number } interface UpdateMetadata { - rid: number; - available: boolean; - currentVersion: string; - version: string; - date?: string; - body?: string; + rid: number + available: boolean + currentVersion: string + version: string + date?: string + body?: string } /** Updater download event */ type DownloadEvent = - | { event: "Started"; data: { contentLength?: number } } - | { event: "Progress"; data: { chunkLength: number } } - | { event: "Finished" }; + | { event: 'Started'; data: { contentLength?: number } } + | { event: 'Progress'; data: { chunkLength: number } } + | { event: 'Finished' } class Update extends Resource { - available: boolean; - currentVersion: string; - version: string; - date?: string; - body?: string; - private downloadedBytes?: Resource; + available: boolean + currentVersion: string + version: string + date?: string + body?: string + private downloadedBytes?: Resource constructor(metadata: UpdateMetadata) { - super(metadata.rid); - this.available = metadata.available; - this.currentVersion = metadata.currentVersion; - this.version = metadata.version; - this.date = metadata.date; - this.body = metadata.body; + super(metadata.rid) + this.available = metadata.available + this.currentVersion = metadata.currentVersion + this.version = metadata.version + this.date = metadata.date + this.body = metadata.body } /** Download the updater package */ async download( onEvent?: (progress: DownloadEvent) => void, - options?: DownloadOptions, + options?: DownloadOptions ): Promise { - const channel = new Channel(); + const channel = new Channel() if (onEvent) { - channel.onmessage = onEvent; + channel.onmessage = onEvent } - const downloadedBytesRid = await invoke("plugin:updater|download", { + const downloadedBytesRid = await invoke('plugin:updater|download', { onEvent: channel, rid: this.rid, - ...options, - }); - this.downloadedBytes = new Resource(downloadedBytesRid); + ...options + }) + this.downloadedBytes = new Resource(downloadedBytesRid) } /** Install downloaded updater package */ async install(): Promise { if (!this.downloadedBytes) { - throw new Error("Update.install called before Update.download"); + throw new Error('Update.install called before Update.download') } - await invoke("plugin:updater|install", { + await invoke('plugin:updater|install', { updateRid: this.rid, - bytesRid: this.downloadedBytes.rid, - }); + bytesRid: this.downloadedBytes.rid + }) // Don't need to call close, we did it in rust side already - this.downloadedBytes = undefined; + this.downloadedBytes = undefined } /** Downloads the updater package and installs it */ async downloadAndInstall( onEvent?: (progress: DownloadEvent) => void, - options?: DownloadOptions, + options?: DownloadOptions ): Promise { - const channel = new Channel(); + const channel = new Channel() if (onEvent) { - channel.onmessage = onEvent; + channel.onmessage = onEvent } - await invoke("plugin:updater|download_and_install", { + await invoke('plugin:updater|download_and_install', { onEvent: channel, rid: this.rid, - ...options, - }); + ...options + }) } async close(): Promise { - await this.downloadedBytes?.close(); - await super.close(); + await this.downloadedBytes?.close() + await super.close() } } /** Check for updates, resolves to `null` if no updates are available */ async function check(options?: CheckOptions): Promise { if (options?.headers) { - options.headers = Array.from(new Headers(options.headers).entries()); + options.headers = Array.from(new Headers(options.headers).entries()) } - return await invoke("plugin:updater|check", { - ...options, - }).then((meta) => (meta.available ? new Update(meta) : null)); + return await invoke('plugin:updater|check', { + ...options + }).then((meta) => (meta.available ? new Update(meta) : null)) } -export type { CheckOptions, DownloadOptions, DownloadEvent }; -export { check, Update }; +export type { CheckOptions, DownloadOptions, DownloadEvent } +export { check, Update } diff --git a/plugins/updater/permissions/default.toml b/plugins/updater/permissions/default.toml index 6ae34b6b9..fcf08fa82 100644 --- a/plugins/updater/permissions/default.toml +++ b/plugins/updater/permissions/default.toml @@ -11,8 +11,8 @@ is enabled. """ permissions = [ - "allow-check", - "allow-download", - "allow-install", - "allow-download-and-install", + "allow-check", + "allow-download", + "allow-install", + "allow-download-and-install", ] diff --git a/plugins/updater/rollup.config.js b/plugins/updater/rollup.config.js index 977dfac83..1f349ec8a 100644 --- a/plugins/updater/rollup.config.js +++ b/plugins/updater/rollup.config.js @@ -2,6 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { createConfig } from "../../shared/rollup.config.js"; +import { createConfig } from '../../shared/rollup.config.js' -export default createConfig(); +export default createConfig() diff --git a/plugins/upload/.gitignore b/plugins/upload/.gitignore deleted file mode 100644 index b512c09d4..000000000 --- a/plugins/upload/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules \ No newline at end of file diff --git a/plugins/upload/Cargo.toml b/plugins/upload/Cargo.toml index f32dd3493..a80217553 100644 --- a/plugins/upload/Cargo.toml +++ b/plugins/upload/Cargo.toml @@ -10,11 +10,11 @@ repository = { workspace = true } links = "tauri-plugin-upload" [package.metadata.docs.rs] -rustc-args = [ "--cfg", "docsrs" ] -rustdoc-args = [ "--cfg", "docsrs" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] [build-dependencies] -tauri-plugin = { workspace = true, features = [ "build" ] } +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } diff --git a/plugins/upload/README.md b/plugins/upload/README.md index 34e73d1ef..a675ad6a4 100644 --- a/plugins/upload/README.md +++ b/plugins/upload/README.md @@ -61,25 +61,25 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import { upload } from "@tauri-apps/plugin-upload"; +import { upload } from '@tauri-apps/plugin-upload' upload( - "https://example.com/file-upload", - "./path/to/my/file.txt", + 'https://example.com/file-upload', + './path/to/my/file.txt', (progress, total) => console.log(`Uploaded ${progress} of ${total} bytes`), // a callback that will be called with the upload progress - { "Content-Type": "text/plain" }, // optional headers to send with the request -); + { 'Content-Type': 'text/plain' } // optional headers to send with the request +) ``` ```javascript -import { download } from "@tauri-apps/plugin-upload"; +import { download } from '@tauri-apps/plugin-upload' download( - "https://example.com/file-download-link", - "./path/to/save/my/file.txt", + 'https://example.com/file-download-link', + './path/to/save/my/file.txt', (progress, total) => console.log(`Downloaded ${progress} of ${total} bytes`), // a callback that will be called with the download progress - { "Content-Type": "text/plain" }, // optional headers to send with the request -); + { 'Content-Type': 'text/plain' } // optional headers to send with the request +) ``` ## Contributing diff --git a/plugins/upload/SECURITY.md b/plugins/upload/SECURITY.md index 67d831fc9..4f09bbacd 100644 --- a/plugins/upload/SECURITY.md +++ b/plugins/upload/SECURITY.md @@ -20,4 +20,4 @@ We prefer to receive reports in English. Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). -Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). \ No newline at end of file +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/upload/guest-js/index.ts b/plugins/upload/guest-js/index.ts index 40e847f9a..9586a241a 100644 --- a/plugins/upload/guest-js/index.ts +++ b/plugins/upload/guest-js/index.ts @@ -2,37 +2,37 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { invoke, Channel } from "@tauri-apps/api/core"; +import { invoke, Channel } from '@tauri-apps/api/core' interface ProgressPayload { - progress: number; - total: number; + progress: number + total: number } -type ProgressHandler = (progress: ProgressPayload) => void; +type ProgressHandler = (progress: ProgressPayload) => void async function upload( url: string, filePath: string, progressHandler?: ProgressHandler, - headers?: Map, + headers?: Map ): Promise { - const ids = new Uint32Array(1); - window.crypto.getRandomValues(ids); - const id = ids[0]; + const ids = new Uint32Array(1) + window.crypto.getRandomValues(ids) + const id = ids[0] - const onProgress = new Channel(); + const onProgress = new Channel() if (progressHandler) { - onProgress.onmessage = progressHandler; + onProgress.onmessage = progressHandler } - return await invoke("plugin:upload|upload", { + return await invoke('plugin:upload|upload', { id, url, filePath, headers: headers ?? {}, - onProgress, - }); + onProgress + }) } /// Download file from given url. @@ -43,24 +43,24 @@ async function download( url: string, filePath: string, progressHandler?: ProgressHandler, - headers?: Map, + headers?: Map ): Promise { - const ids = new Uint32Array(1); - window.crypto.getRandomValues(ids); - const id = ids[0]; + const ids = new Uint32Array(1) + window.crypto.getRandomValues(ids) + const id = ids[0] - const onProgress = new Channel(); + const onProgress = new Channel() if (progressHandler) { - onProgress.onmessage = progressHandler; + onProgress.onmessage = progressHandler } - await invoke("plugin:upload|download", { + await invoke('plugin:upload|download', { id, url, filePath, headers: headers ?? {}, - onProgress, - }); + onProgress + }) } -export { download, upload }; +export { download, upload } diff --git a/plugins/upload/permissions/default.toml b/plugins/upload/permissions/default.toml index 8ef4bfe21..74a2eb9fd 100644 --- a/plugins/upload/permissions/default.toml +++ b/plugins/upload/permissions/default.toml @@ -10,7 +10,4 @@ operations are available from the upload plugin. All operations are enabled by default. """ -permissions = [ - "allow-upload", - "allow-download" -] +permissions = ["allow-upload", "allow-download"] diff --git a/plugins/upload/rollup.config.js b/plugins/upload/rollup.config.js index 977dfac83..1f349ec8a 100644 --- a/plugins/upload/rollup.config.js +++ b/plugins/upload/rollup.config.js @@ -2,6 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { createConfig } from "../../shared/rollup.config.js"; +import { createConfig } from '../../shared/rollup.config.js' -export default createConfig(); +export default createConfig() diff --git a/plugins/websocket/.gitignore b/plugins/websocket/.gitignore deleted file mode 100644 index 24122248a..000000000 --- a/plugins/websocket/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules -gen/schemas diff --git a/plugins/websocket/Cargo.toml b/plugins/websocket/Cargo.toml index a1a3c7751..a36b8761d 100644 --- a/plugins/websocket/Cargo.toml +++ b/plugins/websocket/Cargo.toml @@ -11,11 +11,11 @@ links = "tauri-plugin-websocket" exclude = ["/examples"] [package.metadata.docs.rs] -rustc-args = [ "--cfg", "docsrs" ] -rustdoc-args = [ "--cfg", "docsrs" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] [build-dependencies] -tauri-plugin = { workspace = true, features = [ "build" ] } +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } diff --git a/plugins/websocket/README.md b/plugins/websocket/README.md index eeadc48a9..db4d1ada6 100644 --- a/plugins/websocket/README.md +++ b/plugins/websocket/README.md @@ -60,13 +60,13 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import WebSocket from "@tauri-apps/plugin-websocket"; +import WebSocket from '@tauri-apps/plugin-websocket' -const ws = await WebSocket.connect("wss://example.com"); +const ws = await WebSocket.connect('wss://example.com') -await ws.send("Hello World"); +await ws.send('Hello World') -await ws.disconnect(); +await ws.disconnect() ``` ## Contributing diff --git a/plugins/websocket/SECURITY.md b/plugins/websocket/SECURITY.md index 67d831fc9..4f09bbacd 100644 --- a/plugins/websocket/SECURITY.md +++ b/plugins/websocket/SECURITY.md @@ -20,4 +20,4 @@ We prefer to receive reports in English. Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). -Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). \ No newline at end of file +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/websocket/examples/tauri-app/src/main.ts b/plugins/websocket/examples/tauri-app/src/main.ts index 834e39a9c..05fecfe8f 100644 --- a/plugins/websocket/examples/tauri-app/src/main.ts +++ b/plugins/websocket/examples/tauri-app/src/main.ts @@ -2,57 +2,57 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import WebSocket from "tauri-plugin-websocket-api"; -import "./style.css"; +import WebSocket from 'tauri-plugin-websocket-api' +import './style.css' -let ws: WebSocket; +let ws: WebSocket -document.addEventListener("DOMContentLoaded", async () => { - document.querySelector("#send")?.addEventListener("click", send); - document.querySelector("#disconnect")?.addEventListener("click", disconnect); - await connect(); -}); +document.addEventListener('DOMContentLoaded', async () => { + document.querySelector('#send')?.addEventListener('click', send) + document.querySelector('#disconnect')?.addEventListener('click', disconnect) + await connect() +}) function _updateResponse(returnValue: unknown) { - const msg = document.createElement("p"); + const msg = document.createElement('p') msg.textContent = - typeof returnValue === "string" ? returnValue : JSON.stringify(returnValue); - document.querySelector("#response-container")?.appendChild(msg); + typeof returnValue === 'string' ? returnValue : JSON.stringify(returnValue) + document.querySelector('#response-container')?.appendChild(msg) } async function connect() { try { - ws = await WebSocket.connect("ws://127.0.0.1:8080").then((r) => { - _updateResponse("Connected"); - return r; - }); + ws = await WebSocket.connect('ws://127.0.0.1:8080').then((r) => { + _updateResponse('Connected') + return r + }) } catch (e) { - _updateResponse(e); + _updateResponse(e) } - ws.addListener(_updateResponse); + ws.addListener(_updateResponse) } function send() { - ws.send(document.querySelector("#msg-input")?.textContent || "") + ws.send(document.querySelector('#msg-input')?.textContent || '') .then(() => { - _updateResponse("Message sent"); + _updateResponse('Message sent') }) - .catch(_updateResponse); + .catch(_updateResponse) } function disconnect() { ws.disconnect() .then(() => { - _updateResponse("Disconnected"); + _updateResponse('Disconnected') }) - .catch(_updateResponse); + .catch(_updateResponse) } -document.querySelector("#app")!.innerHTML = ` +document.querySelector('#app')!.innerHTML = `
-`; +` diff --git a/plugins/websocket/examples/tauri-app/src/style.css b/plugins/websocket/examples/tauri-app/src/style.css index 21d7637f3..915efaee9 100644 --- a/plugins/websocket/examples/tauri-app/src/style.css +++ b/plugins/websocket/examples/tauri-app/src/style.css @@ -10,8 +10,8 @@ body { margin: 0; padding: 8px; box-sizing: border-box; - font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, - Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, + Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif; } a { diff --git a/plugins/websocket/guest-js/index.ts b/plugins/websocket/guest-js/index.ts index 4f7de803a..8d787742a 100644 --- a/plugins/websocket/guest-js/index.ts +++ b/plugins/websocket/guest-js/index.ts @@ -2,97 +2,97 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { invoke, Channel } from "@tauri-apps/api/core"; +import { invoke, Channel } from '@tauri-apps/api/core' export interface ConnectionConfig { - writeBufferSize?: number; - maxWriteBufferSize?: number; - maxMessageSize?: number; - maxFrameSize?: number; - acceptUnmaskedFrames?: boolean; - headers?: HeadersInit; + writeBufferSize?: number + maxWriteBufferSize?: number + maxMessageSize?: number + maxFrameSize?: number + acceptUnmaskedFrames?: boolean + headers?: HeadersInit } export interface MessageKind { - type: T; - data: D; + type: T + data: D } export interface CloseFrame { - code: number; - reason: string; + code: number + reason: string } export type Message = - | MessageKind<"Text", string> - | MessageKind<"Binary", number[]> - | MessageKind<"Ping", number[]> - | MessageKind<"Pong", number[]> - | MessageKind<"Close", CloseFrame | null>; + | MessageKind<'Text', string> + | MessageKind<'Binary', number[]> + | MessageKind<'Ping', number[]> + | MessageKind<'Pong', number[]> + | MessageKind<'Close', CloseFrame | null> export default class WebSocket { - id: number; - private readonly listeners: Array<(arg: Message) => void>; + id: number + private readonly listeners: Array<(arg: Message) => void> constructor(id: number, listeners: Array<(arg: Message) => void>) { - this.id = id; - this.listeners = listeners; + this.id = id + this.listeners = listeners } static async connect( url: string, - config?: ConnectionConfig, + config?: ConnectionConfig ): Promise { - const listeners: Array<(arg: Message) => void> = []; + const listeners: Array<(arg: Message) => void> = [] - const onMessage = new Channel(); + const onMessage = new Channel() onMessage.onmessage = (message: Message): void => { listeners.forEach((l) => { - l(message); - }); - }; + l(message) + }) + } if (config?.headers) { - config.headers = Array.from(new Headers(config.headers).entries()); + config.headers = Array.from(new Headers(config.headers).entries()) } - return await invoke("plugin:websocket|connect", { + return await invoke('plugin:websocket|connect', { url, onMessage, - config, - }).then((id) => new WebSocket(id, listeners)); + config + }).then((id) => new WebSocket(id, listeners)) } addListener(cb: (arg: Message) => void): void { - this.listeners.push(cb); + this.listeners.push(cb) } async send(message: Message | string | number[]): Promise { - let m: Message; - if (typeof message === "string") { - m = { type: "Text", data: message }; - } else if (typeof message === "object" && "type" in message) { - m = message; + let m: Message + if (typeof message === 'string') { + m = { type: 'Text', data: message } + } else if (typeof message === 'object' && 'type' in message) { + m = message } else if (Array.isArray(message)) { - m = { type: "Binary", data: message }; + m = { type: 'Binary', data: message } } else { throw new Error( - "invalid `message` type, expected a `{ type: string, data: any }` object, a string or a numeric array", - ); + 'invalid `message` type, expected a `{ type: string, data: any }` object, a string or a numeric array' + ) } - await invoke("plugin:websocket|send", { + await invoke('plugin:websocket|send', { id: this.id, - message: m, - }); + message: m + }) } async disconnect(): Promise { await this.send({ - type: "Close", + type: 'Close', data: { code: 1000, - reason: "Disconnected by client", - }, - }); + reason: 'Disconnected by client' + } + }) } } diff --git a/plugins/websocket/rollup.config.js b/plugins/websocket/rollup.config.js index 977dfac83..1f349ec8a 100644 --- a/plugins/websocket/rollup.config.js +++ b/plugins/websocket/rollup.config.js @@ -2,6 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { createConfig } from "../../shared/rollup.config.js"; +import { createConfig } from '../../shared/rollup.config.js' -export default createConfig(); +export default createConfig() diff --git a/plugins/window-state/.gitignore b/plugins/window-state/.gitignore deleted file mode 100644 index 3c3629e64..000000000 --- a/plugins/window-state/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules diff --git a/plugins/window-state/Cargo.toml b/plugins/window-state/Cargo.toml index 6c276826a..ea0c9963f 100644 --- a/plugins/window-state/Cargo.toml +++ b/plugins/window-state/Cargo.toml @@ -10,11 +10,11 @@ repository = { workspace = true } links = "tauri-plugin-window-state" [package.metadata.docs.rs] -rustc-args = [ "--cfg", "docsrs" ] -rustdoc-args = [ "--cfg", "docsrs" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] [build-dependencies] -tauri-plugin = { workspace = true, features = [ "build" ] } +tauri-plugin = { workspace = true, features = ["build"] } [dependencies] serde = { workspace = true } diff --git a/plugins/window-state/README.md b/plugins/window-state/README.md index 350ff5b6b..8781ea612 100644 --- a/plugins/window-state/README.md +++ b/plugins/window-state/README.md @@ -71,9 +71,9 @@ app.save_window_state(StateFlags::all()); // will save the state of all open win or through Javascript ```javascript -import { saveWindowState, StateFlags } from "@tauri-apps/plugin-window-state"; +import { saveWindowState, StateFlags } from '@tauri-apps/plugin-window-state' -saveWindowState(StateFlags.ALL); +saveWindowState(StateFlags.ALL) ``` To manually restore a windows state from disk you can call the `restore_state()` method exposed by the `WindowExt` trait: @@ -90,10 +90,10 @@ or through Javascript ```javascript import { restoreStateCurrent, - StateFlags, -} from "@tauri-apps/plugin-window-state"; + StateFlags +} from '@tauri-apps/plugin-window-state' -restoreStateCurrent(StateFlags.ALL); +restoreStateCurrent(StateFlags.ALL) ``` ## Contributing diff --git a/plugins/window-state/SECURITY.md b/plugins/window-state/SECURITY.md index 67d831fc9..4f09bbacd 100644 --- a/plugins/window-state/SECURITY.md +++ b/plugins/window-state/SECURITY.md @@ -20,4 +20,4 @@ We prefer to receive reports in English. Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). -Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). \ No newline at end of file +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/plugins/window-state/guest-js/index.ts b/plugins/window-state/guest-js/index.ts index c0de16f6d..f922f3f04 100644 --- a/plugins/window-state/guest-js/index.ts +++ b/plugins/window-state/guest-js/index.ts @@ -2,8 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { invoke } from "@tauri-apps/api/core"; -import { type WindowLabel, getCurrentWindow } from "@tauri-apps/api/window"; +import { invoke } from '@tauri-apps/api/core' +import { type WindowLabel, getCurrentWindow } from '@tauri-apps/api/window' export enum StateFlags { SIZE = 1 << 0, @@ -12,14 +12,14 @@ export enum StateFlags { VISIBLE = 1 << 3, DECORATIONS = 1 << 4, FULLSCREEN = 1 << 5, - ALL = SIZE | POSITION | MAXIMIZED | VISIBLE | DECORATIONS | FULLSCREEN, + ALL = SIZE | POSITION | MAXIMIZED | VISIBLE | DECORATIONS | FULLSCREEN } /** * Save the state of all open windows to disk. */ async function saveWindowState(flags: StateFlags): Promise { - await invoke("plugin:window-state|save_window_state", { flags }); + await invoke('plugin:window-state|save_window_state', { flags }) } /** @@ -27,22 +27,22 @@ async function saveWindowState(flags: StateFlags): Promise { */ async function restoreState( label: WindowLabel, - flags: StateFlags, + flags: StateFlags ): Promise { - await invoke("plugin:window-state|restore_state", { label, flags }); + await invoke('plugin:window-state|restore_state', { label, flags }) } /** * Restore the state for the current window from disk. */ async function restoreStateCurrent(flags: StateFlags): Promise { - await restoreState(getCurrentWindow().label, flags); + await restoreState(getCurrentWindow().label, flags) } /** * Get the name of the file used to store window state. */ async function filename(): Promise { - return await invoke("plugin:window-state|filename"); + return await invoke('plugin:window-state|filename') } -export { restoreState, restoreStateCurrent, saveWindowState, filename }; +export { restoreState, restoreStateCurrent, saveWindowState, filename } diff --git a/plugins/window-state/rollup.config.js b/plugins/window-state/rollup.config.js index 977dfac83..1f349ec8a 100644 --- a/plugins/window-state/rollup.config.js +++ b/plugins/window-state/rollup.config.js @@ -2,6 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { createConfig } from "../../shared/rollup.config.js"; +import { createConfig } from '../../shared/rollup.config.js' -export default createConfig(); +export default createConfig() diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d4d7f65ac..c11248f86 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7,7 +7,6 @@ settings: overrides: semver: '>=7.5.2' optionator: '>=0.9.3' - micromatch@<4.0.8: '>=4.0.8' importers: @@ -108,7 +107,7 @@ importers: version: link:../../plugins/updater '@zerodevx/svelte-json-view': specifier: 1.0.10 - version: 1.0.10(svelte@4.2.18) + version: 1.0.10(svelte@4.2.19) devDependencies: '@iconify-json/codicon': specifier: ^1.1.37 @@ -118,7 +117,7 @@ importers: version: 1.1.14 '@sveltejs/vite-plugin-svelte': specifier: ^3.0.1 - version: 3.1.1(svelte@4.2.18)(vite@5.4.0(terser@5.31.5)) + version: 3.1.1(svelte@4.2.19)(vite@5.4.0(terser@5.31.5)) '@tauri-apps/cli': specifier: 2.0.0-rc.10 version: 2.0.0-rc.10 @@ -126,8 +125,8 @@ importers: specifier: ^0.62.0 version: 0.62.0 svelte: - specifier: ^4.2.8 - version: 4.2.18 + specifier: ^4.2.19 + version: 4.2.19 unocss: specifier: ^0.62.0 version: 0.62.0(postcss@8.4.41)(rollup@4.21.2)(vite@5.4.0(terser@5.31.5)) @@ -2319,8 +2318,8 @@ packages: peerDependencies: svelte: ^3.19.0 || ^4.0.0 - svelte@4.2.18: - resolution: {integrity: sha512-d0FdzYIiAePqRJEb90WlJDkjUEx42xhivxN8muUBmfZnP+tzUgz12DJ2hRJi8sIHCME7jeK1PTMgKPSfTd8JrA==} + svelte@4.2.19: + resolution: {integrity: sha512-IY1rnGr6izd10B0A8LqsBfmlT5OILVuZ7XsI0vdGPEvuonFV7NYEUK4dAkm9Zg2q0Um92kYjTpS1CAP3Nh/KWw==} engines: {node: '>=16'} terser@5.31.5: @@ -2766,13 +2765,14 @@ snapshots: picocolors: 1.0.1 sisteransi: 1.0.5 - '@covector/apply@0.10.0': + '@covector/apply@0.10.0(mocha@10.7.3)': dependencies: '@covector/files': 0.8.0 effection: 2.0.8(mocha@10.7.3) semver: 7.6.3 transitivePeerDependencies: - encoding + - mocha '@covector/assemble@0.12.0(mocha@10.7.3)': dependencies: @@ -2790,7 +2790,7 @@ snapshots: - 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) @@ -2800,11 +2800,12 @@ snapshots: unified: 9.2.2 transitivePeerDependencies: - encoding + - mocha - supports-color '@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 @@ -2855,10 +2856,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 @@ -2866,6 +2865,7 @@ snapshots: shellwords: 0.1.1 transitivePeerDependencies: - encoding + - mocha '@effection/stream@2.0.6': dependencies: @@ -3196,24 +3196,24 @@ snapshots: '@rollup/rollup-win32-x64-msvc@4.21.2': optional: true - '@sveltejs/vite-plugin-svelte-inspector@2.1.0(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.4.0(terser@5.31.5)))(svelte@4.2.18)(vite@5.4.0(terser@5.31.5))': + '@sveltejs/vite-plugin-svelte-inspector@2.1.0(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.19)(vite@5.4.0(terser@5.31.5)))(svelte@4.2.19)(vite@5.4.0(terser@5.31.5))': dependencies: - '@sveltejs/vite-plugin-svelte': 3.1.1(svelte@4.2.18)(vite@5.4.0(terser@5.31.5)) + '@sveltejs/vite-plugin-svelte': 3.1.1(svelte@4.2.19)(vite@5.4.0(terser@5.31.5)) debug: 4.3.6(supports-color@8.1.1) - svelte: 4.2.18 + svelte: 4.2.19 vite: 5.4.0(terser@5.31.5) transitivePeerDependencies: - supports-color - '@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.4.0(terser@5.31.5))': + '@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.19)(vite@5.4.0(terser@5.31.5))': dependencies: - '@sveltejs/vite-plugin-svelte-inspector': 2.1.0(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.4.0(terser@5.31.5)))(svelte@4.2.18)(vite@5.4.0(terser@5.31.5)) + '@sveltejs/vite-plugin-svelte-inspector': 2.1.0(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.19)(vite@5.4.0(terser@5.31.5)))(svelte@4.2.19)(vite@5.4.0(terser@5.31.5)) debug: 4.3.6(supports-color@8.1.1) deepmerge: 4.3.1 kleur: 4.1.5 magic-string: 0.30.11 - svelte: 4.2.18 - svelte-hmr: 0.16.0(svelte@4.2.18) + svelte: 4.2.19 + svelte-hmr: 0.16.0(svelte@4.2.19) vite: 5.4.0(terser@5.31.5) vitefu: 0.2.5(vite@5.4.0(terser@5.31.5)) transitivePeerDependencies: @@ -3528,9 +3528,9 @@ snapshots: - rollup - supports-color - '@zerodevx/svelte-json-view@1.0.10(svelte@4.2.18)': + '@zerodevx/svelte-json-view@1.0.10(svelte@4.2.19)': dependencies: - svelte: 4.2.18 + svelte: 4.2.19 abort-controller@3.0.0: dependencies: @@ -3706,9 +3706,9 @@ snapshots: covector@0.12.3(mocha@10.7.3): dependencies: '@clack/prompts': 0.7.0 - '@covector/apply': 0.10.0 + '@covector/apply': 0.10.0(mocha@10.7.3) '@covector/assemble': 0.12.0(mocha@10.7.3) - '@covector/changelog': 0.12.0 + '@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) @@ -4604,11 +4604,11 @@ snapshots: supports-preserve-symlinks-flag@1.0.0: {} - svelte-hmr@0.16.0(svelte@4.2.18): + svelte-hmr@0.16.0(svelte@4.2.19): dependencies: - svelte: 4.2.18 + svelte: 4.2.19 - svelte@4.2.18: + svelte@4.2.19: dependencies: '@ampproject/remapping': 2.3.0 '@jridgewell/sourcemap-codec': 1.5.0 diff --git a/shared/rollup.config.js b/shared/rollup.config.js index 4e36f4f48..09bfb889e 100644 --- a/shared/rollup.config.js +++ b/shared/rollup.config.js @@ -2,12 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { readFileSync } from "fs"; -import { join } from "path"; -import { cwd } from "process"; -import { nodeResolve } from "@rollup/plugin-node-resolve"; -import typescript from "@rollup/plugin-typescript"; -import terser from "@rollup/plugin-terser"; +import { readFileSync } from 'fs' +import { join } from 'path' +import { cwd } from 'process' +import { nodeResolve } from '@rollup/plugin-node-resolve' +import typescript from '@rollup/plugin-typescript' +import terser from '@rollup/plugin-terser' /** * Create a base rollup config @@ -21,21 +21,21 @@ import terser from "@rollup/plugin-terser"; */ export function createConfig(options = {}) { const { - input = "guest-js/index.ts", + input = 'guest-js/index.ts', external = [/^@tauri-apps\/api/], - additionalConfigs = [], - } = options; + additionalConfigs = [] + } = options // eslint-disable-next-line security/detect-non-literal-fs-filename - const pkg = JSON.parse(readFileSync(join(cwd(), "package.json"), "utf8")); + const pkg = JSON.parse(readFileSync(join(cwd(), 'package.json'), 'utf8')) const pluginJsName = pkg.name - .replace("@tauri-apps/plugin-", "") - .replace(/-./g, (x) => x[1].toUpperCase()); + .replace('@tauri-apps/plugin-', '') + .replace(/-./g, (x) => x[1].toUpperCase()) const iifeVarName = `__TAURI_PLUGIN_${pkg.name - .replace("@tauri-apps/plugin-", "") - .replace("-", (x) => "_") - .toUpperCase()}__`; + .replace('@tauri-apps/plugin-', '') + .replace('-', (x) => '_') + .toUpperCase()}__` return [ { @@ -43,50 +43,50 @@ export function createConfig(options = {}) { output: [ { file: pkg.exports.import, - format: "esm", + format: 'esm' }, { file: pkg.exports.require, - format: "cjs", - }, + format: 'cjs' + } ], plugins: [ typescript({ declaration: true, - declarationDir: `./${pkg.exports.import.split("/")[0]}`, - }), + declarationDir: `./${pkg.exports.import.split('/')[0]}` + }) ], external: [ ...external, ...Object.keys(pkg.dependencies || {}), - ...Object.keys(pkg.peerDependencies || {}), + ...Object.keys(pkg.peerDependencies || {}) ], onwarn: (warning) => { - throw Object.assign(new Error(), warning); - }, + throw Object.assign(new Error(), warning) + } }, { input, output: { - format: "iife", + format: 'iife', name: iifeVarName, // IIFE is in the format `var ${iifeVarName} = (() => {})()` // we check if __TAURI__ exists and inject the API object banner: "if ('__TAURI__' in window) {", // the last `}` closes the if in the banner footer: `Object.defineProperty(window.__TAURI__, '${pluginJsName}', { value: ${iifeVarName} }) }`, - file: "api-iife.js", + file: 'api-iife.js' }, // and var is not guaranteed to assign to the global `window` object so we make sure to assign it plugins: [typescript(), terser(), nodeResolve()], onwarn: (warning) => { - throw Object.assign(new Error(), warning); - }, + throw Object.assign(new Error(), warning) + } }, ...(Array.isArray(additionalConfigs) ? additionalConfigs - : [additionalConfigs]), - ]; + : [additionalConfigs]) + ] } diff --git a/shared/template/.gitignore b/shared/template/.gitignore deleted file mode 100644 index 1b0b469d0..000000000 --- a/shared/template/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/.tauri diff --git a/shared/template/Cargo.toml b/shared/template/Cargo.toml index 63391a80e..97bc04818 100644 --- a/shared/template/Cargo.toml +++ b/shared/template/Cargo.toml @@ -8,11 +8,11 @@ repository = { workspace = true } links = "tauri-plugin-PLUGIN_NAME" [package.metadata.docs.rs] -rustc-args = [ "--cfg", "docsrs" ] -rustdoc-args = [ "--cfg", "docsrs" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] [build-dependencies] -tauri-plugin = { workspace = true, features = [ "build" ] } +tauri-plugin = { workspace = true, features = ["build"] } # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/shared/template/SECURITY.md b/shared/template/SECURITY.md index 67d831fc9..4f09bbacd 100644 --- a/shared/template/SECURITY.md +++ b/shared/template/SECURITY.md @@ -20,4 +20,4 @@ We prefer to receive reports in English. Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). -Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). \ No newline at end of file +Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/shared/template/rollup.config.js b/shared/template/rollup.config.js index 977dfac83..1f349ec8a 100644 --- a/shared/template/rollup.config.js +++ b/shared/template/rollup.config.js @@ -2,6 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -import { createConfig } from "../../shared/rollup.config.js"; +import { createConfig } from '../../shared/rollup.config.js' -export default createConfig(); +export default createConfig() diff --git a/taplo.toml b/taplo.toml new file mode 100644 index 000000000..e628d2689 --- /dev/null +++ b/taplo.toml @@ -0,0 +1 @@ +exclude = ["plugins/*/permissions/autogenerated/**.toml"]