mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-01-31 00:45:24 +01:00
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 <lucas@tauri.app>
This commit is contained in:
@@ -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"
|
||||
"RUSTSEC-2021-0145",
|
||||
]
|
||||
16
.github/workflows/audit-javascript.yml
vendored
16
.github/workflows/audit-javascript.yml
vendored
@@ -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
|
||||
|
||||
14
.github/workflows/audit-rust.yml
vendored
14
.github/workflows/audit-rust.yml
vendored
@@ -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 }}
|
||||
|
||||
6
.github/workflows/check-generated-files.yml
vendored
6
.github/workflows/check-generated-files.yml
vendored
@@ -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
|
||||
|
||||
@@ -27,4 +27,4 @@ jobs:
|
||||
uses: jbolda/covector/packages/action@covector-v0
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
command: "status"
|
||||
command: 'status'
|
||||
|
||||
2
.github/workflows/covector-status.yml
vendored
2
.github/workflows/covector-status.yml
vendored
@@ -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
|
||||
@@ -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 }}
|
||||
|
||||
59
.github/workflows/fmt.yml
vendored
Normal file
59
.github/workflows/fmt.yml
vendored
Normal file
@@ -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
|
||||
8
.github/workflows/integration-tests.yml
vendored
8
.github/workflows/integration-tests.yml
vendored
@@ -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:
|
||||
|
||||
46
.github/workflows/lint-javascript.yml
vendored
46
.github/workflows/lint-javascript.yml
vendored
@@ -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
|
||||
|
||||
34
.github/workflows/lint-rust.yml
vendored
34
.github/workflows/lint-rust.yml
vendored
@@ -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
|
||||
|
||||
2
.github/workflows/sync.yml
vendored
2
.github/workflows/sync.yml
vendored
@@ -34,7 +34,7 @@ jobs:
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "lts/*"
|
||||
node-version: 'lts/*'
|
||||
|
||||
- uses: pnpm/action-setup@v4
|
||||
with:
|
||||
|
||||
44
.github/workflows/test-rust.yml
vendored
44
.github/workflows/test-rust.yml
vendored
@@ -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
|
||||
|
||||
60
.gitignore
vendored
60
.gitignore
vendored
@@ -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
|
||||
debug.log
|
||||
TODO.md
|
||||
@@ -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
|
||||
5
.prettierrc
Normal file
5
.prettierrc
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"singleQuote": true,
|
||||
"semi": false,
|
||||
"trailingComma": "none"
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
8
.vscode/extensions.json
vendored
Normal file
8
.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"rust-lang.rust-analyzer",
|
||||
"EditorConfig.EditorConfig",
|
||||
"esbenp.prettier-vscode",
|
||||
"tamasfe.even-better-toml"
|
||||
]
|
||||
}
|
||||
58
README.md
58
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**_
|
||||
|
||||
|
||||
@@ -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 }
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
6
examples/api/.gitignore
vendored
6
examples/api/.gitignore
vendored
@@ -1,4 +1,2 @@
|
||||
/node_modules/
|
||||
/.vscode/
|
||||
.DS_Store
|
||||
.cargo
|
||||
/dist/*
|
||||
!/dist/.gitkeep
|
||||
|
||||
0
examples/api/dist/.gitkeep
vendored
Normal file
0
examples/api/dist/.gitkeep
vendored
Normal file
@@ -3,5 +3,5 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
window.__TAURI_ISOLATION_HOOK__ = (payload) => {
|
||||
return payload;
|
||||
};
|
||||
return payload
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
font-family: "Rubik", sans-serif;
|
||||
font-family: 'Rubik', sans-serif;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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]
|
||||
})
|
||||
|
||||
@@ -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']
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1
plugins/autostart/.gitignore
vendored
1
plugins/autostart/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
node_modules
|
||||
@@ -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 }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<boolean> {
|
||||
return await invoke("plugin:autostart|is_enabled");
|
||||
return await invoke('plugin:autostart|is_enabled')
|
||||
}
|
||||
|
||||
export async function enable(): Promise<void> {
|
||||
await invoke("plugin:autostart|enable");
|
||||
await invoke('plugin:autostart|enable')
|
||||
}
|
||||
|
||||
export async function disable(): Promise<void> {
|
||||
await invoke("plugin:autostart|disable");
|
||||
await invoke('plugin:autostart|disable')
|
||||
}
|
||||
|
||||
@@ -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"]
|
||||
|
||||
@@ -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()
|
||||
|
||||
1
plugins/barcode-scanner/.gitignore
vendored
1
plugins/barcode-scanner/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
/.tauri
|
||||
@@ -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 }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<Scanned> {
|
||||
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<void> {
|
||||
await invoke("plugin:barcode-scanner|cancel");
|
||||
await invoke('plugin:barcode-scanner|cancel')
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,8 +58,8 @@ export async function cancel(): Promise<void> {
|
||||
*/
|
||||
export async function checkPermissions(): Promise<PermissionState> {
|
||||
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<PermissionState> {
|
||||
*/
|
||||
export async function requestPermissions(): Promise<PermissionState> {
|
||||
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<void> {
|
||||
await invoke("plugin:barcode-scanner|open_app_settings");
|
||||
await invoke('plugin:barcode-scanner|open_app_settings')
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
1
plugins/biometric/.gitignore
vendored
1
plugins/biometric/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
/.tauri
|
||||
@@ -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 }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<Status> {
|
||||
return await invoke("plugin:biometric|status");
|
||||
return await invoke('plugin:biometric|status')
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,10 +68,10 @@ export async function checkStatus(): Promise<Status> {
|
||||
*/
|
||||
export async function authenticate(
|
||||
reason: string,
|
||||
options?: AuthOptions,
|
||||
options?: AuthOptions
|
||||
): Promise<void> {
|
||||
await invoke("plugin:biometric|authenticate", {
|
||||
await invoke('plugin:biometric|authenticate', {
|
||||
reason,
|
||||
...options,
|
||||
});
|
||||
...options
|
||||
})
|
||||
}
|
||||
|
||||
@@ -10,7 +10,4 @@ It allows acccess to all biometric commands.
|
||||
|
||||
"""
|
||||
|
||||
permissions = [
|
||||
"allow-authenticate",
|
||||
"allow-status",
|
||||
]
|
||||
permissions = ["allow-authenticate", "allow-status"]
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -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
|
||||
}
|
||||
```
|
||||
|
||||
@@ -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<string, ArgMatch>;
|
||||
subcommand: SubcommandMatch | null;
|
||||
args: Record<string, ArgMatch>
|
||||
subcommand: SubcommandMatch | null
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,9 +64,9 @@ interface CliMatches {
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function getMatches(): Promise<CliMatches> {
|
||||
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 }
|
||||
|
||||
@@ -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()
|
||||
|
||||
1
plugins/clipboard-manager/.gitignore
vendored
1
plugins/clipboard-manager/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
/.tauri
|
||||
@@ -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 }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<void> {
|
||||
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<string> {
|
||||
return await invoke("plugin:clipboard-manager|read_text");
|
||||
return await invoke('plugin:clipboard-manager|read_text')
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,11 +66,11 @@ async function readText(): Promise<string> {
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function writeImage(
|
||||
image: string | Image | Uint8Array | ArrayBuffer | number[],
|
||||
image: string | Image | Uint8Array | ArrayBuffer | number[]
|
||||
): Promise<void> {
|
||||
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<Image> {
|
||||
return await invoke<number>("plugin:clipboard-manager|read_image").then(
|
||||
(rid) => new Image(rid),
|
||||
);
|
||||
return await invoke<number>('plugin:clipboard-manager|read_image').then(
|
||||
(rid) => new Image(rid)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,10 +106,10 @@ async function readImage(): Promise<Image> {
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function writeHtml(html: string, altHtml?: string): Promise<void> {
|
||||
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<void> {
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function clear(): Promise<void> {
|
||||
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 }
|
||||
|
||||
@@ -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()
|
||||
|
||||
1
plugins/deep-link/.gitignore
vendored
1
plugins/deep-link/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
/.tauri
|
||||
@@ -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)
|
||||
})
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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}/`)
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
|
||||
@@ -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
|
||||
}
|
||||
})
|
||||
|
||||
@@ -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<string[] | null> {
|
||||
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<string[] | null> {
|
||||
* @since 2.0.0
|
||||
*/
|
||||
export async function register(protocol: string): Promise<null> {
|
||||
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<null> {
|
||||
* @since 2.0.0
|
||||
*/
|
||||
export async function unregister(protocol: string): Promise<null> {
|
||||
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<null> {
|
||||
* @since 2.0.0
|
||||
*/
|
||||
export async function isRegistered(protocol: string): Promise<boolean> {
|
||||
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<boolean> {
|
||||
* @since 2.0.0
|
||||
*/
|
||||
export async function onOpenUrl(
|
||||
handler: (urls: string[]) => void,
|
||||
handler: (urls: string[]) => void
|
||||
): Promise<UnlistenFn> {
|
||||
const current = await getCurrent();
|
||||
const current = await getCurrent()
|
||||
if (current) {
|
||||
handler(current);
|
||||
handler(current)
|
||||
}
|
||||
|
||||
return await listen<string[]>("deep-link://new-url", (event) => {
|
||||
handler(event.payload);
|
||||
});
|
||||
return await listen<string[]>('deep-link://new-url', (event) => {
|
||||
handler(event.payload)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
1
plugins/dialog/.gitignore
vendored
1
plugins/dialog/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
.tauri
|
||||
@@ -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 }
|
||||
|
||||
@@ -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 extends OpenDialogOptions> = T["directory"] extends true
|
||||
? T["multiple"] extends true
|
||||
type OpenDialogReturn<T extends OpenDialogOptions> = 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 extends OpenDialogOptions> = T["directory"] extends true
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function open<T extends OpenDialogOptions>(
|
||||
options: T = {} as T,
|
||||
options: T = {} as T
|
||||
): Promise<OpenDialogReturn<T>> {
|
||||
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<T extends OpenDialogOptions>(
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function save(options: SaveDialogOptions = {}): Promise<string | null> {
|
||||
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<string | null> {
|
||||
*/
|
||||
async function message(
|
||||
message: string,
|
||||
options?: string | MessageDialogOptions,
|
||||
options?: string | MessageDialogOptions
|
||||
): Promise<void> {
|
||||
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<boolean> {
|
||||
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<boolean> {
|
||||
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 }
|
||||
|
||||
@@ -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()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
]
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
1
plugins/fs/.gitignore
vendored
1
plugins/fs/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
node_modules
|
||||
@@ -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 }
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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",
|
||||
]
|
||||
|
||||
@@ -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",
|
||||
]
|
||||
|
||||
@@ -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]]
|
||||
|
||||
@@ -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",
|
||||
|
||||
]
|
||||
|
||||
@@ -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",
|
||||
]
|
||||
|
||||
@@ -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",
|
||||
]
|
||||
|
||||
@@ -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()
|
||||
|
||||
1
plugins/geolocation/.gitignore
vendored
1
plugins/geolocation/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
/.tauri
|
||||
@@ -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 }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -9,77 +9,77 @@
|
||||
|
||||
export const commands = {
|
||||
async getCurrentPosition(
|
||||
options: PositionOptions | null,
|
||||
options: PositionOptions | null
|
||||
): Promise<Result<Position, Error>> {
|
||||
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<Result<null, Error>> {
|
||||
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<Result<null, Error>> {
|
||||
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<Result<PermissionStatus, Error>> {
|
||||
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<Result<PermissionStatus, Error>> {
|
||||
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__<T> = {
|
||||
listen: (
|
||||
cb: TAURI_API_EVENT.EventCallback<T>,
|
||||
) => ReturnType<typeof TAURI_API_EVENT.listen<T>>;
|
||||
cb: TAURI_API_EVENT.EventCallback<T>
|
||||
) => ReturnType<typeof TAURI_API_EVENT.listen<T>>
|
||||
once: (
|
||||
cb: TAURI_API_EVENT.EventCallback<T>,
|
||||
) => ReturnType<typeof TAURI_API_EVENT.once<T>>;
|
||||
cb: TAURI_API_EVENT.EventCallback<T>
|
||||
) => ReturnType<typeof TAURI_API_EVENT.once<T>>
|
||||
emit: T extends null
|
||||
? (payload?: T) => ReturnType<typeof TAURI_API_EVENT.emit>
|
||||
: (payload: T) => ReturnType<typeof TAURI_API_EVENT.emit>;
|
||||
};
|
||||
: (payload: T) => ReturnType<typeof TAURI_API_EVENT.emit>
|
||||
}
|
||||
|
||||
export type Result<T, E> =
|
||||
| { status: "ok"; data: T }
|
||||
| { status: "error"; error: E };
|
||||
| { status: 'ok'; data: T }
|
||||
| { status: 'error'; error: E }
|
||||
|
||||
function __makeEvents__<T extends Record<string, any>>(
|
||||
mappings: Record<keyof T, string>,
|
||||
mappings: Record<keyof T, string>
|
||||
) {
|
||||
return new Proxy(
|
||||
{} as unknown as {
|
||||
[K in keyof T]: __EventObj__<T[K]> & {
|
||||
(handle: __WebviewWindow__): __EventObj__<T[K]>;
|
||||
};
|
||||
(handle: __WebviewWindow__): __EventObj__<T[K]>
|
||||
}
|
||||
},
|
||||
{
|
||||
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__<any>) => {
|
||||
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)
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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<number> {
|
||||
const channel = new Channel<Position>();
|
||||
channel.onmessage = cb;
|
||||
await commands.watchPosition(options, channel);
|
||||
return channel.id;
|
||||
const channel = new Channel<Position>()
|
||||
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 };
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<void> {
|
||||
const h = new Channel<ShortcutEvent>();
|
||||
h.onmessage = handler;
|
||||
const h = new Channel<ShortcutEvent>()
|
||||
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<void> {
|
||||
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<void> {
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function unregisterAll(): Promise<void> {
|
||||
return await invoke("plugin:global-shortcut|unregister_all", {});
|
||||
return await invoke('plugin:global-shortcut|unregister_all', {})
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,9 +115,9 @@ async function unregisterAll(): Promise<void> {
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function isRegistered(shortcut: string): Promise<boolean> {
|
||||
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 }
|
||||
|
||||
@@ -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()
|
||||
|
||||
1
plugins/haptics/.gitignore
vendored
1
plugins/haptics/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
/.tauri
|
||||
@@ -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 }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -11,54 +11,54 @@ export const commands = {
|
||||
async vibrate(duration: number): Promise<Result<null, Error>> {
|
||||
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<Result<null, Error>> {
|
||||
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<Result<null, Error>> {
|
||||
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<Result<null, Error>> {
|
||||
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__<T> = {
|
||||
listen: (
|
||||
cb: TAURI_API_EVENT.EventCallback<T>,
|
||||
) => ReturnType<typeof TAURI_API_EVENT.listen<T>>;
|
||||
cb: TAURI_API_EVENT.EventCallback<T>
|
||||
) => ReturnType<typeof TAURI_API_EVENT.listen<T>>
|
||||
once: (
|
||||
cb: TAURI_API_EVENT.EventCallback<T>,
|
||||
) => ReturnType<typeof TAURI_API_EVENT.once<T>>;
|
||||
cb: TAURI_API_EVENT.EventCallback<T>
|
||||
) => ReturnType<typeof TAURI_API_EVENT.once<T>>
|
||||
emit: T extends null
|
||||
? (payload?: T) => ReturnType<typeof TAURI_API_EVENT.emit>
|
||||
: (payload: T) => ReturnType<typeof TAURI_API_EVENT.emit>;
|
||||
};
|
||||
: (payload: T) => ReturnType<typeof TAURI_API_EVENT.emit>
|
||||
}
|
||||
|
||||
export type Result<T, E> =
|
||||
| { status: "ok"; data: T }
|
||||
| { status: "error"; error: E };
|
||||
| { status: 'ok'; data: T }
|
||||
| { status: 'error'; error: E }
|
||||
|
||||
function __makeEvents__<T extends Record<string, any>>(
|
||||
mappings: Record<keyof T, string>,
|
||||
mappings: Record<keyof T, string>
|
||||
) {
|
||||
return new Proxy(
|
||||
{} as unknown as {
|
||||
[K in keyof T]: __EventObj__<T[K]> & {
|
||||
(handle: __WebviewWindow__): __EventObj__<T[K]>;
|
||||
};
|
||||
(handle: __WebviewWindow__): __EventObj__<T[K]>
|
||||
}
|
||||
},
|
||||
{
|
||||
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__<any>) => {
|
||||
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)
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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 };
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user