mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-11 10:43:31 +02:00
Compare commits
344 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7fd4ca0aef | ||
|
|
0dfd5f875f | ||
|
|
14b3667420 | ||
|
|
bf804657f5 | ||
|
|
93452b791a | ||
|
|
6d6b6e653e | ||
|
|
40f137c214 | ||
|
|
e8e214b72e | ||
|
|
eae0150b0a | ||
|
|
51460340bf | ||
|
|
dfb5f52d3c | ||
|
|
80069e1dc0 | ||
|
|
5fcb55e420 | ||
|
|
ee71c31fd0 | ||
|
|
6ff801e27d | ||
|
|
44b4e2ee00 | ||
|
|
5a1d86b346 | ||
|
|
f4c9635724 | ||
|
|
565dc3baa7 | ||
|
|
a3c9754950 | ||
|
|
708efbd9b7 | ||
|
|
da30753754 | ||
|
|
0b46637eba | ||
|
|
d3e4fb20b5 | ||
|
|
919d96dd8a | ||
|
|
6c7eac7288 | ||
|
|
901ce937d6 | ||
|
|
81b9c505cc | ||
|
|
7489f96697 | ||
|
|
a926b49a01 | ||
|
|
5fdc616df9 | ||
|
|
1487b18dcb | ||
|
|
7f820ee190 | ||
|
|
54c6f158d9 | ||
|
|
23282873e7 | ||
|
|
eb1ec0416c | ||
|
|
5e0c4489df | ||
|
|
d788d23071 | ||
|
|
a7ee5ca7c3 | ||
|
|
ff4ea1eabb | ||
|
|
57c6bf07bb | ||
|
|
38ee5066e7 | ||
|
|
8c07076e25 | ||
|
|
2f70d8da2b | ||
|
|
c46c09f31d | ||
|
|
c2867a65d8 | ||
|
|
058469114d | ||
|
|
00c60097c5 | ||
|
|
1d0de2a558 | ||
|
|
1fa729b218 | ||
|
|
808deecfff | ||
|
|
b7a2ce2c63 | ||
|
|
3536aa00d1 | ||
|
|
1c8229fbe2 | ||
|
|
e513b69d98 | ||
|
|
cfcc7f3c20 | ||
|
|
5fdf8dcb8e | ||
|
|
36e4837cea | ||
|
|
17bf7f1f0f | ||
|
|
46e6187c89 | ||
|
|
3d16461b68 | ||
|
|
8661e4a0d7 | ||
|
|
f6c3ea6faa | ||
|
|
bfa69691a5 | ||
|
|
e8014a7f61 | ||
|
|
138cb8d739 | ||
|
|
852e11e17b | ||
|
|
c9364c2a4c | ||
|
|
a8d640b3c6 | ||
|
|
b72adc0a66 | ||
|
|
7e8e0e76ec | ||
|
|
50576a5e1e | ||
|
|
314f0e212f | ||
|
|
f7ac2e9250 | ||
|
|
db7765edad | ||
|
|
d20a728892 | ||
|
|
9da996073f | ||
|
|
ed6b81b29d | ||
|
|
b0d3128597 | ||
|
|
2d9936931a | ||
|
|
0d6bc3b583 | ||
|
|
aff1fd2c7d | ||
|
|
7a17c1e89f | ||
|
|
e71e375c29 | ||
|
|
36540ce3c3 | ||
|
|
275800a603 | ||
|
|
f29c56da8c | ||
|
|
328583e12e | ||
|
|
26f306d65c | ||
|
|
87ea607ef4 | ||
|
|
763f0bdcb0 | ||
|
|
27fa1022ee | ||
|
|
e601b9a790 | ||
|
|
60e6f6c3f1 | ||
|
|
35b587c830 | ||
|
|
b9559b35d1 | ||
|
|
d4f89af18d | ||
|
|
8fb1df8aa6 | ||
|
|
e0631d379c | ||
|
|
581b515e08 | ||
|
|
20ff1f4596 | ||
|
|
fc193a502f | ||
|
|
d4d6a98d98 | ||
|
|
a822a6ad74 | ||
|
|
6ed2b04872 | ||
|
|
7ccfa2fb0b | ||
|
|
1b9f0ec350 | ||
|
|
2455328f81 | ||
|
|
f4fe3beb84 | ||
|
|
54a4a14b41 | ||
|
|
b3591d46e6 | ||
|
|
0b4882ed92 | ||
|
|
ca3a53005a | ||
|
|
6ccfce4180 | ||
|
|
7aca4527e8 | ||
|
|
9d543f6ed3 | ||
|
|
2761dd037f | ||
|
|
9afbeb6b7a | ||
|
|
6e60bd637c | ||
|
|
8e4820642e | ||
|
|
a788aea85d | ||
|
|
7aab3e2076 | ||
|
|
05662b3129 | ||
|
|
62f8659bef | ||
|
|
8ac2f412be | ||
|
|
01b876761a | ||
|
|
8eabb09e80 | ||
|
|
49dff27ef1 | ||
|
|
b08ae637a0 | ||
|
|
8c842a54a6 | ||
|
|
72aa17f79a | ||
|
|
7ae67dde69 | ||
|
|
2809171fb4 | ||
|
|
4b9a5af3cf | ||
|
|
d2df2e831b | ||
|
|
c94e1326a7 | ||
|
|
4892637f83 | ||
|
|
ce76d95ab1 | ||
|
|
2265e09718 | ||
|
|
6d5dc9489c | ||
|
|
d703c7f459 | ||
|
|
281714e567 | ||
|
|
c1d84e8127 | ||
|
|
04ddee91e8 | ||
|
|
864dfe4de5 | ||
|
|
077605f58b | ||
|
|
00e1efaa9b | ||
|
|
7a8d570db7 | ||
|
|
0d5835d133 | ||
|
|
488a7562bb | ||
|
|
3f35b45263 | ||
|
|
146a794cb6 | ||
|
|
ff99a9bf74 | ||
|
|
bf550f94cc | ||
|
|
f439122622 | ||
|
|
9d2144128f | ||
|
|
f5305de251 | ||
|
|
d17027e1a0 | ||
|
|
72621892fe | ||
|
|
89602cdce3 | ||
|
|
c2608423b6 | ||
|
|
1956a3aeda | ||
|
|
14d567f7ec | ||
|
|
72389b00d7 | ||
|
|
4f2fd4dcf7 | ||
|
|
cf0986491c | ||
|
|
d7ffa7f95e | ||
|
|
015020760a | ||
|
|
a02c6c4c81 | ||
|
|
cd8c074ae6 | ||
|
|
f7a080a121 | ||
|
|
bca09f7f5f | ||
|
|
2bf9c27375 | ||
|
|
3dc38b150e | ||
|
|
28133c5155 | ||
|
|
1efe861d3c | ||
|
|
0eddb812c6 | ||
|
|
19ec53fae4 | ||
|
|
73fd60eef2 | ||
|
|
5fd4d20e3b | ||
|
|
4ab5545b7a | ||
|
|
233e43b0c3 | ||
|
|
d0d873e39a | ||
|
|
9db9e6c037 | ||
|
|
62144ef3be | ||
|
|
eaf0d71779 | ||
|
|
75a0c79dea | ||
|
|
c14b1df372 | ||
|
|
41a471b23a | ||
|
|
9e7ce0a8ee | ||
|
|
b293da35dd | ||
|
|
fdcd77338c | ||
|
|
9093ef3314 | ||
|
|
ffe21e0225 | ||
|
|
4f087cfd92 | ||
|
|
7225501c13 | ||
|
|
9c632ee35d | ||
|
|
b5059d77e9 | ||
|
|
f81c3f2922 | ||
|
|
8866ecac3c | ||
|
|
0f26960891 | ||
|
|
c7bffb01be | ||
|
|
9d872ab872 | ||
|
|
b6027b2dd2 | ||
|
|
2a0b2cea03 | ||
|
|
873840a204 | ||
|
|
445a8b6062 | ||
|
|
677db85877 | ||
|
|
c0989848b9 | ||
|
|
04681a6b13 | ||
|
|
2d545eff58 | ||
|
|
0e8d3a6f16 | ||
|
|
b490308c88 | ||
|
|
527bd9feea | ||
|
|
d710946064 | ||
|
|
15ebeb1851 | ||
|
|
50fbd49273 | ||
|
|
677838ccfa | ||
|
|
168c3d0148 | ||
|
|
2eec3e13fb | ||
|
|
a883c31088 | ||
|
|
f2d7405df4 | ||
|
|
1ecaeb29aa | ||
|
|
7e3d672b9b | ||
|
|
bb2510876d | ||
|
|
ed43ff3243 | ||
|
|
5fe68b1cec | ||
|
|
3d37ed38c7 | ||
|
|
830ae97955 | ||
|
|
67f14b4ce8 | ||
|
|
6e879742f0 | ||
|
|
a836373328 | ||
|
|
2e1bd04775 | ||
|
|
45a5cd569b | ||
|
|
3afccfce17 | ||
|
|
1aba1780de | ||
|
|
878421beb7 | ||
|
|
777c086590 | ||
|
|
60e08605d5 | ||
|
|
d8b996c00a | ||
|
|
7aaf27ce5f | ||
|
|
014aeca11f | ||
|
|
e7078a3030 | ||
|
|
b41447b811 | ||
|
|
aa119f2836 | ||
|
|
99fe1c562f | ||
|
|
9b1a6a1c02 | ||
|
|
c6321a610c | ||
|
|
e055c69c23 | ||
|
|
582c25a0f0 | ||
|
|
dc9269bc8d | ||
|
|
6c13840cee | ||
|
|
2d9c2b4724 | ||
|
|
23859f7502 | ||
|
|
ab29908aba | ||
|
|
873b9aee90 | ||
|
|
35264b4c18 | ||
|
|
a178f95d68 | ||
|
|
cc186c7a0e | ||
|
|
79dd6e16a7 | ||
|
|
9417ce401c | ||
|
|
7a231cd1c9 | ||
|
|
6ca8a056e8 | ||
|
|
e599d92681 | ||
|
|
a3a70218f3 | ||
|
|
cb6ee77e69 | ||
|
|
5b1e99f264 | ||
|
|
e00b1e5f94 | ||
|
|
161d5be49a | ||
|
|
e7ccbd8573 | ||
|
|
9076d5d2e7 | ||
|
|
ef41c5bfd4 | ||
|
|
0b43033c5c | ||
|
|
a65b5fea3d | ||
|
|
87ebf4e084 | ||
|
|
e37b7677cd | ||
|
|
fc2bac959b | ||
|
|
9d8b377481 | ||
|
|
4137ab44a8 | ||
|
|
bddf59e5d0 | ||
|
|
b713aed21b | ||
|
|
d23d6f60e8 | ||
|
|
357480f4ae | ||
|
|
95f467add5 | ||
|
|
b8bf8e0fac | ||
|
|
60bf067913 | ||
|
|
49f06ca4b9 | ||
|
|
4036e15f5a | ||
|
|
8357ce5b2e | ||
|
|
ecf6a8ad10 | ||
|
|
208ce34f1e | ||
|
|
4cbdf0fb1c | ||
|
|
f756cd5e7e | ||
|
|
a5861d8294 | ||
|
|
1129f4f575 | ||
|
|
d4cac20292 | ||
|
|
095b18620b | ||
|
|
a4aec9f0a8 | ||
|
|
39bf895b73 | ||
|
|
7c0fa1f3f9 | ||
|
|
a6c94119d8 | ||
|
|
321f3fed19 | ||
|
|
39443b4350 | ||
|
|
6f41a27124 | ||
|
|
1377f8e13b | ||
|
|
8f1ace7795 | ||
|
|
63011ca84e | ||
|
|
73d9cd51b2 | ||
|
|
a06dc69931 | ||
|
|
ca3cd8b3d1 | ||
|
|
0d3a97ec7b | ||
|
|
04201d43b1 | ||
|
|
d9d430e5a5 | ||
|
|
5d89905e39 | ||
|
|
eedfa5e618 | ||
|
|
7d9aa3987e | ||
|
|
1dd722c4a7 | ||
|
|
f98e1b128c | ||
|
|
82e915c487 | ||
|
|
628285c1cf | ||
|
|
54c337e06f | ||
|
|
e8e2853830 | ||
|
|
b9316a64ea | ||
|
|
ae65951bc4 | ||
|
|
08a44490d7 | ||
|
|
3baa6ac9b8 | ||
|
|
aec5537de0 | ||
|
|
4c5a30370c | ||
|
|
013fb354d9 | ||
|
|
adba73a9ff | ||
|
|
1d7171a1ec | ||
|
|
ecb489a77c | ||
|
|
0563fe3d46 | ||
|
|
18b17a954c | ||
|
|
60c15750c1 | ||
|
|
ee9706d8ae | ||
|
|
7950fcb9a8 | ||
|
|
e4292ce7be | ||
|
|
db26aaf2b4 | ||
|
|
c8445a69ca | ||
|
|
c764408da7 | ||
|
|
2954f6d252 | ||
|
|
0967da262e | ||
|
|
e939e6d9e4 |
2
.cargo/config
Normal file
2
.cargo/config
Normal file
@@ -0,0 +1,2 @@
|
||||
[env]
|
||||
__TAURI_WORKSPACE__ = "true"
|
||||
@@ -5,10 +5,10 @@
|
||||
"rust": {
|
||||
"errorOnVersionRange": "^2.0.0-0",
|
||||
"version": true,
|
||||
"getPublishedVersion": "cargo search ${ pkgFile.pkg.package.name } --limit 1 | sed -nE \"s/^[^\\\"]*\\\"//; s/\\\".*//1p\"",
|
||||
"getPublishedVersion": "node ../../.scripts/covector/package-latest-version.js cargo ${ pkgFile.pkg.package.name } ${ pkgFile.pkg.package.version }",
|
||||
"prepublish": [
|
||||
"sudo apt-get update",
|
||||
"sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf",
|
||||
"sudo apt-get install -y webkit2gtk-4.0 libayatana-appindicator3-dev",
|
||||
"cargo install cargo-audit --features=fix",
|
||||
{
|
||||
"command": "cargo generate-lockfile",
|
||||
@@ -70,7 +70,7 @@
|
||||
"javascript": {
|
||||
"errorOnVersionRange": "^2.0.0-0",
|
||||
"version": true,
|
||||
"getPublishedVersion": "npm view ${ pkgFile.pkg.name } version",
|
||||
"getPublishedVersion": "node ../../.scripts/covector/package-latest-version.js npm ${ pkgFile.pkg.name } ${ pkgFile.pkg.version }",
|
||||
"prepublish": [
|
||||
{
|
||||
"command": "yarn",
|
||||
@@ -209,7 +209,10 @@
|
||||
"path": "./core/tauri-build",
|
||||
"manager": "rust",
|
||||
"dependencies": ["tauri-codegen", "tauri-utils"],
|
||||
"postversion": "node ../../.scripts/covector/sync-cli-metadata.js ${ pkg.pkg } ${ release.type }",
|
||||
"postversion": [
|
||||
"node ../../.scripts/covector/sync-cli-metadata.js ${ pkg.pkg } ${ release.type }",
|
||||
"cargo build --manifest-path ../tauri-config-schema/Cargo.toml"
|
||||
],
|
||||
"assets": [
|
||||
{
|
||||
"path": "./tooling/cli/schema.json",
|
||||
@@ -231,8 +234,12 @@
|
||||
"cli.js": {
|
||||
"path": "./tooling/cli/node",
|
||||
"manager": "javascript",
|
||||
"getPublishedVersion": "node ../../../.scripts/covector/package-latest-version.js npm ${ pkgFile.pkg.name } ${ pkgFile.pkg.version }",
|
||||
"dependencies": ["cli.rs"],
|
||||
"postversion": "node ../../../.scripts/covector/sync-cli-metadata.js ${ pkg.pkg } ${ release.type }",
|
||||
"postversion": [
|
||||
"node ../../../.scripts/covector/sync-cli-metadata.js ${ pkg.pkg } ${ release.type }",
|
||||
"cargo build --manifest-path ../../../core/tauri-config-schema/Cargo.toml"
|
||||
],
|
||||
"prepublish": [],
|
||||
"publish": [],
|
||||
"postpublish": []
|
||||
@@ -241,7 +248,10 @@
|
||||
"path": "./tooling/cli",
|
||||
"manager": "rust",
|
||||
"dependencies": ["tauri-bundler", "tauri-utils"],
|
||||
"postversion": "cargo check",
|
||||
"postversion": [
|
||||
"cargo check",
|
||||
"cargo build --manifest-path ../../core/tauri-config-schema/Cargo.toml"
|
||||
],
|
||||
"assets": [
|
||||
{
|
||||
"path": "${ pkg.path }/target/package/tauri-cli-${ pkgFile.version }.crate",
|
||||
|
||||
31
.changes/readme.md
Normal file
31
.changes/readme.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# Changes
|
||||
|
||||
##### via https://github.com/jbolda/covector
|
||||
|
||||
As you create PRs and make changes that require a version bump, please add a new markdown file in this folder. You do not note the version _number_, but rather the type of bump that you expect: major, minor, or patch. The filename is not important, as long as it is a `.md`, but we recommend that it represents the overall change for organizational purposes.
|
||||
|
||||
When you select the version bump required, you do _not_ need to consider dependencies. Only note the package with the actual change, and any packages that depend on that package will be bumped automatically in the process.
|
||||
|
||||
Use the following format:
|
||||
|
||||
```md
|
||||
---
|
||||
"package-a": patch
|
||||
"package-b": patch
|
||||
---
|
||||
|
||||
Change summary goes here
|
||||
|
||||
```
|
||||
|
||||
Summaries do not have a specific character limit, but are text only. These summaries are used within the (future implementation of) changelogs. They will give context to the change and also point back to the original PR if more details and context are needed.
|
||||
|
||||
Changes will be designated as a `major`, `minor` or `patch` as further described in [semver](https://semver.org/).
|
||||
|
||||
Given a version number MAJOR.MINOR.PATCH, increment the:
|
||||
|
||||
- MAJOR version when you make incompatible API changes,
|
||||
- MINOR version when you add functionality in a backwards compatible manner, and
|
||||
- PATCH version when you make backwards compatible bug fixes.
|
||||
|
||||
Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format, but will be discussed prior to usage (as extra steps will be necessary in consideration of merging and publishing).
|
||||
6
.github/FUNDING.yml
vendored
6
.github/FUNDING.yml
vendored
@@ -1,6 +1,10 @@
|
||||
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: nothingismagick
|
||||
github: tauri-apps
|
||||
patreon: #
|
||||
open_collective: tauri
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
|
||||
9
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
9
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@@ -1,3 +1,7 @@
|
||||
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
name: 🐞 Bug Report
|
||||
title: '[bug] '
|
||||
description: Report a bug
|
||||
@@ -43,6 +47,7 @@ body:
|
||||
attributes:
|
||||
label: Platform and versions
|
||||
description: "Output of `npm run tauri info` or `cargo tauri info`"
|
||||
render: text
|
||||
validations:
|
||||
required: true
|
||||
|
||||
@@ -50,8 +55,8 @@ body:
|
||||
id: logs
|
||||
attributes:
|
||||
label: Stack trace
|
||||
render: shell
|
||||
|
||||
render: text
|
||||
|
||||
- type: textarea
|
||||
id: context
|
||||
attributes:
|
||||
|
||||
4
.github/ISSUE_TEMPLATE/config.yml
vendored
4
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -1,3 +1,7 @@
|
||||
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
contact_links:
|
||||
- name: 💬 Discord Chat
|
||||
url: https://discord.com/invite/tauri
|
||||
|
||||
4
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
4
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
@@ -1,3 +1,7 @@
|
||||
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
name: 💡 Feature Request
|
||||
title: '[feat] '
|
||||
description: Suggest an idea
|
||||
|
||||
3
.github/config.yml
vendored
3
.github/config.yml
vendored
@@ -0,0 +1,3 @@
|
||||
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
74
.github/workflows/artifacts-updater.yml
vendored
74
.github/workflows/artifacts-updater.yml
vendored
@@ -1,13 +1,11 @@
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
name: updater test artifacts
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
- next
|
||||
schedule:
|
||||
- cron: '0 0 * * *'
|
||||
pull_request:
|
||||
paths:
|
||||
- '.github/workflows/artifacts-updater.yml'
|
||||
@@ -16,7 +14,6 @@ on:
|
||||
|
||||
env:
|
||||
RUST_BACKTRACE: 1
|
||||
CARGO_INCREMENTAL: 0 # This is set to 0 by the https://github.com/Swatinem/rust-cache
|
||||
CARGO_PROFILE_DEV_DEBUG: 0 # This would add unnecessary bloat to the target folder, decreasing cache efficiency.
|
||||
|
||||
concurrency:
|
||||
@@ -43,61 +40,13 @@ jobs:
|
||||
if: matrix.platform == 'ubuntu-latest'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf
|
||||
sudo apt-get install -y webkit2gtk-4.0 libayatana-appindicator3-dev
|
||||
|
||||
- name: Get current date
|
||||
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
|
||||
if: matrix.platform == 'macos-latest' || matrix.platform == 'ubuntu-latest'
|
||||
|
||||
- name: Get current date
|
||||
if: matrix.platform == 'windows-latest'
|
||||
run: echo "CURRENT_DATE=$(Get-Date -Format "yyyy-MM-dd")" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
|
||||
- name: Cache cargo state
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cargo_state
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
~/.cargo/bin
|
||||
key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
|
||||
restore-keys: |
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-
|
||||
${{ matrix.platform }}-stable-
|
||||
${{ matrix.platform }}-
|
||||
|
||||
- name: Cache core cargo target
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cargo_core
|
||||
with:
|
||||
path: target
|
||||
# Add date to the cache to keep it up to date
|
||||
key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('core/**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
|
||||
# Restore from outdated cache for speed
|
||||
restore-keys: |
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('core/**/Cargo.toml') }}
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-
|
||||
${{ matrix.platform }}-stable-
|
||||
${{ matrix.platform }}-
|
||||
|
||||
- name: Cache CLI cargo target
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cargo_cli
|
||||
with:
|
||||
path: tooling/cli/target
|
||||
# Add date to the cache to keep it up to date
|
||||
key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('tooling/cli/Cargo.lock') }}-${{ env.CURRENT_DATE }}
|
||||
# Restore from outdated cache for speed
|
||||
restore-keys: |
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('tooling/cli/Cargo.lock') }}
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-
|
||||
${{ matrix.platform }}-stable-
|
||||
${{ matrix.platform }}-
|
||||
workspaces: |
|
||||
core -> ../target
|
||||
tooling/cli
|
||||
|
||||
- name: build and install cli.rs
|
||||
run: cargo install --path tooling/cli --force
|
||||
@@ -108,13 +57,14 @@ jobs:
|
||||
run: |
|
||||
echo "Enable code signing: ${{ env.ENABLE_CODE_SIGNING != '' }}"
|
||||
echo "::set-output name=enabled::${{ env.ENABLE_CODE_SIGNING != '' }}"
|
||||
|
||||
# run only on tauri-apps/tauri repo (require secrets)
|
||||
- name: build sample artifacts + code signing (updater)
|
||||
if: steps.enablecodesigning.outputs.enabled == 'true'
|
||||
working-directory: ./examples/updater
|
||||
run: |
|
||||
yarn install
|
||||
cargo tauri build
|
||||
cargo tauri build --verbose
|
||||
env:
|
||||
# Notarization (disabled)
|
||||
# FIXME: enable only on `dev` push maybe? as it take some times...
|
||||
@@ -128,15 +78,17 @@ jobs:
|
||||
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
|
||||
# Updater signature is exposed here to make sure it works in PR's
|
||||
TAURI_PRIVATE_KEY: dW50cnVzdGVkIGNvbW1lbnQ6IHJzaWduIGVuY3J5cHRlZCBzZWNyZXQga2V5ClJXUlRZMEl5YTBGV3JiTy9lRDZVd3NkL0RoQ1htZmExNDd3RmJaNmRMT1ZGVjczWTBKZ0FBQkFBQUFBQUFBQUFBQUlBQUFBQWdMekUzVkE4K0tWQ1hjeGt1Vkx2QnRUR3pzQjVuV0ZpM2czWXNkRm9hVUxrVnB6TUN3K1NheHJMREhQbUVWVFZRK3NIL1VsMDBHNW5ET1EzQno0UStSb21nRW4vZlpTaXIwZFh5ZmRlL1lSN0dKcHdyOUVPclVvdzFhVkxDVnZrbHM2T1o4Tk1NWEU9Cg==
|
||||
TAURI_KEY_PASSWORD:
|
||||
# run on PRs and forks
|
||||
- name: build sample artifacts (updater)
|
||||
if: steps.enablecodesigning.outputs.enabled != 'true'
|
||||
working-directory: ./examples/updater
|
||||
run: |
|
||||
yarn install
|
||||
cargo tauri build
|
||||
cargo tauri build --verbose
|
||||
env:
|
||||
TAURI_PRIVATE_KEY: dW50cnVzdGVkIGNvbW1lbnQ6IHJzaWduIGVuY3J5cHRlZCBzZWNyZXQga2V5ClJXUlRZMEl5YTBGV3JiTy9lRDZVd3NkL0RoQ1htZmExNDd3RmJaNmRMT1ZGVjczWTBKZ0FBQkFBQUFBQUFBQUFBQUlBQUFBQWdMekUzVkE4K0tWQ1hjeGt1Vkx2QnRUR3pzQjVuV0ZpM2czWXNkRm9hVUxrVnB6TUN3K1NheHJMREhQbUVWVFZRK3NIL1VsMDBHNW5ET1EzQno0UStSb21nRW4vZlpTaXIwZFh5ZmRlL1lSN0dKcHdyOUVPclVvdzFhVkxDVnZrbHM2T1o4Tk1NWEU9Cg==
|
||||
TAURI_KEY_PASSWORD:
|
||||
# upload assets
|
||||
- uses: actions/upload-artifact@v2
|
||||
if: matrix.platform == 'ubuntu-latest'
|
||||
|
||||
2
.github/workflows/audit.yml
vendored
2
.github/workflows/audit.yml
vendored
@@ -1,4 +1,4 @@
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
66
.github/workflows/bench.yml
vendored
66
.github/workflows/bench.yml
vendored
@@ -1,3 +1,7 @@
|
||||
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
name: benches
|
||||
|
||||
on:
|
||||
@@ -9,8 +13,8 @@ on:
|
||||
|
||||
env:
|
||||
RUST_BACKTRACE: 1
|
||||
CARGO_INCREMENTAL: 0 # This is set to 0 by the https://github.com/Swatinem/rust-cache
|
||||
CARGO_PROFILE_DEV_DEBUG: 0 # This would add unnecessary bloat to the target folder, decreasing cache efficiency.
|
||||
LC_ALL: en_US.UTF-8 # This prevents strace from changing it's number format to use commas.
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
@@ -23,7 +27,7 @@ jobs:
|
||||
matrix:
|
||||
rust: [nightly]
|
||||
platform:
|
||||
- { target: x86_64-unknown-linux-gnu, os: ubuntu-latest }
|
||||
- { target: x86_64-unknown-linux-gnu, os: ubuntu-20.04 }
|
||||
|
||||
runs-on: ${{ matrix.platform.os }}
|
||||
|
||||
@@ -34,72 +38,30 @@ jobs:
|
||||
with:
|
||||
toolchain: ${{ matrix.rust }}
|
||||
override: true
|
||||
default: true
|
||||
components: rust-src
|
||||
target: ${{ matrix.platform.target }}
|
||||
|
||||
- name: setup python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.x'
|
||||
python-version: '3.10'
|
||||
architecture: x64
|
||||
|
||||
- name: install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf xvfb
|
||||
sudo apt-get install -y webkit2gtk-4.0 libayatana-appindicator3-dev xvfb
|
||||
wget https://github.com/sharkdp/hyperfine/releases/download/v1.11.0/hyperfine_1.11.0_amd64.deb
|
||||
sudo dpkg -i hyperfine_1.11.0_amd64.deb
|
||||
pip install memory_profiler
|
||||
|
||||
- name: Get current date
|
||||
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
|
||||
|
||||
- name: Cache cargo state
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cargo_state
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
~/.cargo/bin
|
||||
key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
|
||||
restore-keys: |
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-
|
||||
${{ matrix.platform }}-stable-
|
||||
${{ matrix.platform }}-
|
||||
|
||||
- name: Cache core cargo target
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cargo_core
|
||||
with:
|
||||
path: target
|
||||
# Add date to the cache to keep it up to date
|
||||
key: ${{ matrix.platform }}-${{ matrix.rust }}-${{ env.cache-name }}-${{ hashFiles('core/**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
|
||||
# Restore from outdated cache for speed
|
||||
restore-keys: |
|
||||
${{ matrix.platform }}-${{ matrix.rust }}-${{ env.cache-name }}-${{ hashFiles('core/**/Cargo.toml') }}
|
||||
${{ matrix.platform }}-${{ matrix.rust }}-${{ env.cache-name }}-
|
||||
${{ matrix.platform }}-${{ matrix.rust }}-
|
||||
${{ matrix.platform }}-
|
||||
|
||||
- name: cache cargo `tooling/bench/tests` target
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cargo_benches
|
||||
with:
|
||||
path: tooling/bench/tests/target
|
||||
# Add date to the cache to keep it up to date
|
||||
key: ${{ matrix.platform }}-${{ matrix.rust }}-${{ env.cache-name }}-${{ hashFiles('tooling/bench/tests/Cargo.lock') }}-${{ env.CURRENT_DATE }}
|
||||
# Restore from outdated cache for speed
|
||||
restore-keys: |
|
||||
${{ matrix.platform }}-${{ matrix.rust }}-${{ env.cache-name }}-${{ hashFiles('tooling/bench/tests/Cargo.lock') }}
|
||||
${{ matrix.platform }}-${{ matrix.rust }}-${{ env.cache-name }}-
|
||||
${{ matrix.platform }}-${{ matrix.rust }}-
|
||||
${{ matrix.platform }}-
|
||||
workspaces: |
|
||||
core -> ../target
|
||||
tooling/bench/tests
|
||||
|
||||
- name: run benchmarks
|
||||
run: |
|
||||
@@ -126,7 +88,7 @@ jobs:
|
||||
git commit --message "Update Tauri benchmarks"
|
||||
git push origin gh-pages
|
||||
|
||||
- name: Worker info
|
||||
- name: Print worker info
|
||||
run: |
|
||||
cat /proc/cpuinfo
|
||||
cat /proc/meminfo
|
||||
|
||||
2
.github/workflows/change-status-on-PR.yml
vendored
2
.github/workflows/change-status-on-PR.yml
vendored
@@ -1,4 +1,4 @@
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
96
.github/workflows/check-generated-files.yml
vendored
Normal file
96
.github/workflows/check-generated-files.yml
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
name: Check generated files
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- '.github/workflows/check-generated-files.yml'
|
||||
- 'tooling/api/src/**'
|
||||
- 'core/tauri/scripts/bundle.global.js'
|
||||
- 'core/tauri-utils/src/config.rs'
|
||||
- 'tooling/cli/schema.json'
|
||||
- 'core/tauri-config-schema/schema.json'
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
paths:
|
||||
- '.github/workflows/check-generated-files.yml'
|
||||
- 'tooling/api/src/**'
|
||||
- 'core/tauri/scripts/bundle.global.js'
|
||||
- 'core/tauri-utils/src/config.rs'
|
||||
- 'tooling/cli/schema.json'
|
||||
- 'core/tauri-config-schema/schema.json'
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
changes:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
api: ${{ steps.filter.outputs.api }}
|
||||
schema: ${{ steps.filter.outputs.schema }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: dorny/paths-filter@v2
|
||||
id: filter
|
||||
with:
|
||||
filters: |
|
||||
api:
|
||||
- 'tooling/api/src/**'
|
||||
- 'tooling/api/docs/js-api.json'
|
||||
- 'core/tauri/scripts/bundle.global.js'
|
||||
schema:
|
||||
- 'core/tauri-utils/src/config.rs'
|
||||
- 'tooling/cli/schema.json'
|
||||
- 'core/tauri-config-schema/schema.json'
|
||||
|
||||
check-api:
|
||||
runs-on: ubuntu-latest
|
||||
needs: changes
|
||||
if: needs.changes.outputs.api == 'true'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: build api
|
||||
working-directory: tooling/api
|
||||
run: yarn && yarn build
|
||||
- name: check api
|
||||
run: |
|
||||
git restore tooling/api/docs/js-api.json
|
||||
./.scripts/ci/has-diff.sh
|
||||
|
||||
check-schema:
|
||||
runs-on: ubuntu-latest
|
||||
needs: changes
|
||||
if: needs.changes.outputs.schema == 'true'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: install stable
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
|
||||
- name: install Linux dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libgtk-3-dev
|
||||
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
workspaces: core -> ../target
|
||||
|
||||
- name: generate schema.json
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: build
|
||||
args: --manifest-path ./core/tauri-config-schema/Cargo.toml
|
||||
|
||||
- name: check schema
|
||||
run: ./.scripts/ci/has-diff.sh
|
||||
28
.github/workflows/check-license-header.yml
vendored
Normal file
28
.github/workflows/check-license-header.yml
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
name: Check generated files
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: dorny/paths-filter@v2
|
||||
id: filter
|
||||
with:
|
||||
list-files: shell
|
||||
filters: |
|
||||
added:
|
||||
- added: '**'
|
||||
- name: check header license on new files
|
||||
if: ${{ steps.filter.outputs.added == 'true' }}
|
||||
run: node check-license-header.js ${{ steps.filter.outputs.added_files }}
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -16,8 +16,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
# platform: [ubuntu-latest, macos-latest, windows-latest]
|
||||
platform: [ubuntu-latest, macos-latest]
|
||||
platform: [ubuntu-latest, macos-latest, windows-latest]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@@ -31,61 +30,13 @@ jobs:
|
||||
if: matrix.platform == 'ubuntu-latest'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf
|
||||
sudo apt-get install -y webkit2gtk-4.0 libayatana-appindicator3-dev libfuse2
|
||||
|
||||
- name: Get current date
|
||||
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
|
||||
if: matrix.platform == 'macos-latest' || matrix.platform == 'ubuntu-latest'
|
||||
|
||||
- name: Get current date
|
||||
if: matrix.platform == 'windows-latest'
|
||||
run: echo "CURRENT_DATE=$(Get-Date -Format "yyyy-MM-dd")" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
|
||||
- name: Cache cargo state
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cargo_state
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
~/.cargo/bin
|
||||
key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
|
||||
restore-keys: |
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-
|
||||
${{ matrix.platform }}-stable-
|
||||
${{ matrix.platform }}-
|
||||
|
||||
- name: Cache core cargo target
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cargo_core
|
||||
with:
|
||||
path: target
|
||||
# Add date to the cache to keep it up to date
|
||||
key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('core/**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
|
||||
# Restore from outdated cache for speed
|
||||
restore-keys: |
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('core/**/Cargo.toml') }}
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-
|
||||
${{ matrix.platform }}-stable-
|
||||
${{ matrix.platform }}-
|
||||
|
||||
- name: Cache CLI cargo target
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cargo_cli
|
||||
with:
|
||||
path: tooling/cli/target
|
||||
# Add date to the cache to keep it up to date
|
||||
key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('tooling/cli/Cargo.lock') }}-${{ env.CURRENT_DATE }}
|
||||
# Restore from outdated cache for speed
|
||||
restore-keys: |
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('tooling/cli/Cargo.lock') }}
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-
|
||||
${{ matrix.platform }}-stable-
|
||||
${{ matrix.platform }}-
|
||||
workspaces: |
|
||||
core -> ../target
|
||||
tooling/cli
|
||||
|
||||
- name: build CLI
|
||||
uses: actions-rs/cargo@v1
|
||||
@@ -126,7 +77,7 @@ jobs:
|
||||
cache-dependency-path: tooling/*/yarn.lock
|
||||
|
||||
- name: cargo login
|
||||
run: cargo login ${{ secrets.crate_token }}
|
||||
run: cargo login ${{ secrets.ORG_CRATES_IO_TOKEN }}
|
||||
- name: git config
|
||||
run: |
|
||||
git config --global user.name "${{ github.event.pusher.name }}"
|
||||
@@ -136,7 +87,7 @@ jobs:
|
||||
uses: jbolda/covector/packages/action@covector-v0
|
||||
id: covector
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
NODE_AUTH_TOKEN: ${{ secrets.ORG_NPM_TOKEN }}
|
||||
CARGO_AUDIT_OPTIONS: ${{ secrets.CARGO_AUDIT_OPTIONS }}
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -145,7 +96,7 @@ jobs:
|
||||
|
||||
- name: Create Pull Request With Versions Bumped
|
||||
if: steps.covector.outputs.commandRan == 'version'
|
||||
uses: tauri-apps/create-pull-request@v3.4.1
|
||||
uses: tauri-apps/create-pull-request@v3
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
branch: release/version-updates
|
||||
@@ -155,10 +106,12 @@ jobs:
|
||||
body: ${{ steps.covector.outputs.change }}
|
||||
|
||||
- name: Trigger doc update
|
||||
if: steps.covector.outputs.successfulPublish == 'true'
|
||||
if: |
|
||||
steps.covector.outputs.successfulPublish == 'true' &&
|
||||
steps.covector.outputs.packagesPublished != ''
|
||||
uses: peter-evans/repository-dispatch@v1
|
||||
with:
|
||||
token: ${{ secrets.TAURI_BOT_PAT }}
|
||||
token: ${{ secrets.ORG_TAURI_BOT_PAT }}
|
||||
repository: tauri-apps/tauri-docs
|
||||
event-type: update-docs
|
||||
|
||||
@@ -168,7 +121,7 @@ jobs:
|
||||
contains(steps.covector.outputs.packagesPublished, 'cli.rs')
|
||||
uses: peter-evans/repository-dispatch@v1
|
||||
with:
|
||||
token: ${{ secrets.TAURI_BOT_PAT }}
|
||||
token: ${{ secrets.ORG_TAURI_BOT_PAT }}
|
||||
repository: tauri-apps/tauri
|
||||
event-type: publish-clijs
|
||||
client-payload: '{"releaseId": "${{ steps.covector.outputs.cli.js-releaseId }}" }'
|
||||
@@ -179,6 +132,6 @@ jobs:
|
||||
contains(steps.covector.outputs.packagesPublished, 'cli.rs')
|
||||
uses: peter-evans/repository-dispatch@v1
|
||||
with:
|
||||
token: ${{ secrets.TAURI_BOT_PAT }}
|
||||
token: ${{ secrets.ORG_TAURI_BOT_PAT }}
|
||||
repository: tauri-apps/tauri
|
||||
event-type: publish-clirs
|
||||
|
||||
7
.github/workflows/docker.yml
vendored
7
.github/workflows/docker.yml
vendored
@@ -1,3 +1,7 @@
|
||||
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
name: docker
|
||||
|
||||
on:
|
||||
@@ -67,6 +71,7 @@ jobs:
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
default: true
|
||||
target: ${{ matrix.target.name }}
|
||||
|
||||
- name: Setup node
|
||||
@@ -110,7 +115,7 @@ jobs:
|
||||
- name: install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf
|
||||
sudo apt-get install -y webkit2gtk-4.0 libayatana-appindicator3-dev
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
|
||||
39
.github/workflows/lint-fmt-cli.yml
vendored
39
.github/workflows/lint-fmt-cli.yml
vendored
@@ -1,4 +1,4 @@
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -16,7 +16,6 @@ on:
|
||||
|
||||
env:
|
||||
RUST_BACKTRACE: 1
|
||||
CARGO_INCREMENTAL: 0 # This is set to 0 by the https://github.com/Swatinem/rust-cache
|
||||
CARGO_PROFILE_DEV_DEBUG: 0 # This would add unnecessary bloat to the target folder, decreasing cache efficiency.
|
||||
|
||||
concurrency:
|
||||
@@ -55,44 +54,14 @@ jobs:
|
||||
override: true
|
||||
components: clippy
|
||||
|
||||
- name: install Linux dependencies
|
||||
- name: install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libgtk-3-dev
|
||||
|
||||
- name: Get current date
|
||||
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
|
||||
|
||||
- name: Cache cargo state
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cargo_state
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
~/.cargo/bin
|
||||
key: ubuntu-latest-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
|
||||
restore-keys: |
|
||||
ubuntu-latest-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-
|
||||
ubuntu-latest-stable-${{ env.cache-name }}-
|
||||
ubuntu-latest-stable-
|
||||
ubuntu-latest-
|
||||
|
||||
- name: Cache CLI cargo target
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cargo_cli
|
||||
with:
|
||||
path: tooling/cli/target
|
||||
# Add date to the cache to keep it up to date
|
||||
key: ubuntu-latest-stable-${{ env.cache-name }}-${{ hashFiles('tooling/cli/Cargo.lock') }}-${{ env.CURRENT_DATE }}
|
||||
# Restore from outdated cache for speed
|
||||
restore-keys: |
|
||||
ubuntu-latest-stable-${{ env.cache-name }}-${{ hashFiles('tooling/cli/Cargo.lock') }}
|
||||
ubuntu-latest-stable-${{ env.cache-name }}-
|
||||
ubuntu-latest-stable-
|
||||
ubuntu-latest-
|
||||
workspaces: tooling/cli
|
||||
|
||||
- uses: actions-rs/clippy-check@v1
|
||||
with:
|
||||
|
||||
51
.github/workflows/lint-fmt-core.yml
vendored
51
.github/workflows/lint-fmt-core.yml
vendored
@@ -1,4 +1,4 @@
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -13,11 +13,11 @@ on:
|
||||
paths:
|
||||
- '.github/workflows/lint-fmt-core.yml'
|
||||
- 'core/**'
|
||||
- '!core/tauri/scripts/**'
|
||||
- 'examples/**'
|
||||
|
||||
env:
|
||||
RUST_BACKTRACE: 1
|
||||
CARGO_INCREMENTAL: 0 # This is set to 0 by the https://github.com/Swatinem/rust-cache
|
||||
CARGO_PROFILE_DEV_DEBUG: 0 # This would add unnecessary bloat to the target folder, decreasing cache efficiency.
|
||||
|
||||
concurrency:
|
||||
@@ -50,7 +50,7 @@ jobs:
|
||||
clippy:
|
||||
- { args: '', key: 'empty' }
|
||||
- {
|
||||
args: '--features compression,wry,isolation,custom-protocol,api-all,cli,updater,system-tray,windows7-compat,http-multipart',
|
||||
args: '--features compression,wry,linux-protocol-headers,isolation,custom-protocol,api-all,cli,updater,system-tray,windows7-compat,http-multipart',
|
||||
key: 'all'
|
||||
}
|
||||
- { args: '--features custom-protocol', key: 'custom-protocol' }
|
||||
@@ -58,10 +58,11 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: install webkit2gtk
|
||||
|
||||
- name: install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf
|
||||
sudo apt-get install -y webkit2gtk-4.0 libayatana-appindicator3-dev
|
||||
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
@@ -70,44 +71,10 @@ jobs:
|
||||
override: true
|
||||
components: clippy
|
||||
|
||||
- name: Get current date
|
||||
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
|
||||
if: matrix.platform == 'macos-latest' || matrix.platform == 'ubuntu-latest'
|
||||
|
||||
- name: Get current date
|
||||
if: matrix.platform == 'windows-latest'
|
||||
run: echo "CURRENT_DATE=$(Get-Date -Format "yyyy-MM-dd")" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
|
||||
- name: Cache cargo state
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cargo_state
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
~/.cargo/bin
|
||||
key: ubuntu-latest-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
|
||||
restore-keys: |
|
||||
ubuntu-latest-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-
|
||||
ubuntu-latest-stable-${{ env.cache-name }}-
|
||||
ubuntu-latest-stable-
|
||||
ubuntu-latest-
|
||||
|
||||
- name: Cache core cargo target
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cargo_core
|
||||
with:
|
||||
path: target
|
||||
# Add date to the cache to keep it up to date
|
||||
key: ubuntu-latest-stable-${{ env.cache-name }}-${{ hashFiles('core/**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
|
||||
# Restore from outdated cache for speed
|
||||
restore-keys: |
|
||||
ubuntu-latest-stable-${{ env.cache-name }}-${{ hashFiles('core/**/Cargo.toml') }}
|
||||
ubuntu-latest-stable-${{ env.cache-name }}-
|
||||
ubuntu-latest-stable-
|
||||
ubuntu-latest-
|
||||
workspaces: core -> ../target
|
||||
save-if: ${{ matrix.clippy.key == 'all' }}
|
||||
|
||||
- uses: actions-rs/clippy-check@v1
|
||||
with:
|
||||
|
||||
2
.github/workflows/lint-js.yml
vendored
2
.github/workflows/lint-js.yml
vendored
@@ -1,4 +1,4 @@
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
22
.github/workflows/publish-cli-js.yml
vendored
22
.github/workflows/publish-cli-js.yml
vendored
@@ -1,3 +1,7 @@
|
||||
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
name: publish cli.js
|
||||
env:
|
||||
DEBUG: napi:*
|
||||
@@ -5,6 +9,10 @@ env:
|
||||
MACOSX_DEPLOYMENT_TARGET: '10.13'
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
releaseId:
|
||||
description: 'ID of the cli.js release'
|
||||
required: true
|
||||
repository_dispatch:
|
||||
types: [publish-clijs]
|
||||
|
||||
@@ -194,7 +202,6 @@ jobs:
|
||||
- host: windows-latest
|
||||
target: x86_64-pc-windows-msvc
|
||||
node:
|
||||
- '12'
|
||||
- '14'
|
||||
- '16'
|
||||
- '18'
|
||||
@@ -228,7 +235,6 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node:
|
||||
- '12'
|
||||
- '14'
|
||||
- '16'
|
||||
- '18'
|
||||
@@ -255,7 +261,7 @@ jobs:
|
||||
- name: install system dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf
|
||||
sudo apt-get install -y webkit2gtk-4.0 libayatana-appindicator3-dev
|
||||
- name: Test bindings
|
||||
run: yarn test
|
||||
test-linux-x64-musl-binding:
|
||||
@@ -266,7 +272,6 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node:
|
||||
- '12'
|
||||
- '14'
|
||||
- '16'
|
||||
- '18'
|
||||
@@ -294,7 +299,7 @@ jobs:
|
||||
shell: bash
|
||||
- name: Install system dependencies
|
||||
run: |
|
||||
apk add openssl-dev musl-dev glib-dev cairo-dev pkgconfig gdk-pixbuf-dev webkit2gtk-dev curl libappindicator-dev patchelf librsvg-dev gtk+3.0-dev
|
||||
apk add openssl-dev musl-dev glib-dev cairo-dev pkgconfig gdk-pixbuf-dev webkit2gtk-dev curl libappindicator-dev gtk+3.0-dev
|
||||
- name: Setup and run tests
|
||||
run: |
|
||||
yarn tauri --help
|
||||
@@ -314,7 +319,6 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node:
|
||||
- '12'
|
||||
- '14'
|
||||
- '16'
|
||||
- '18'
|
||||
@@ -351,7 +355,7 @@ jobs:
|
||||
set -e
|
||||
export PATH=/usr/local/cargo/bin/:/usr/local/fnm:$PATH
|
||||
apt-get update
|
||||
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install --no-install-recommends -y unzip libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf
|
||||
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install --no-install-recommends -y unzip webkit2gtk-4.0 libayatana-appindicator3-dev
|
||||
bash
|
||||
curl https://sh.rustup.rs -sSf | bash -s -- -y
|
||||
curl -fsSL https://fnm.vercel.app/install | bash -s -- --install-dir "/usr/local/fnm" --skip-shell
|
||||
@@ -396,5 +400,5 @@ jobs:
|
||||
npm publish
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
RELEASE_ID: ${{ github.event.client_payload.releaseId }}
|
||||
NPM_TOKEN: ${{ secrets.ORG_NPM_TOKEN }}
|
||||
RELEASE_ID: ${{ github.event.client_payload.releaseId || github.event.inputs.releaseId }}
|
||||
|
||||
49
.github/workflows/publish-cli-rs.yml
vendored
49
.github/workflows/publish-cli-rs.yml
vendored
@@ -1,3 +1,7 @@
|
||||
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
name: publish cli.rs
|
||||
env:
|
||||
MACOSX_DEPLOYMENT_TARGET: '10.13'
|
||||
@@ -8,40 +12,45 @@ on:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ matrix.target.platform }}
|
||||
runs-on: ${{ matrix.config.os }}
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
target:
|
||||
- {
|
||||
name: 'x86_64-unknown-linux-gnu',
|
||||
platform: 'ubuntu-18.04',
|
||||
ext: ''
|
||||
}
|
||||
- { name: 'x86_64-apple-darwin', platform: 'macos-latest', ext: '' }
|
||||
- {
|
||||
name: 'x86_64-pc-windows-msvc',
|
||||
platform: 'windows-latest',
|
||||
ext: '.exe'
|
||||
}
|
||||
config:
|
||||
- os: ubuntu-18.04
|
||||
rust_target: x86_64-unknown-linux-gnu
|
||||
ext: ''
|
||||
- os: macos-latest
|
||||
rust_target: x86_64-apple-darwin
|
||||
ext: ''
|
||||
- os: macos-latest
|
||||
rust_target: aarch64-apple-darwin
|
||||
ext: ''
|
||||
- os: windows-latest
|
||||
rust_target: x86_64-pc-windows-msvc
|
||||
ext: '.exe'
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: install stable
|
||||
uses: actions-rs/toolchain@v1
|
||||
- name: 'Setup Rust'
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
toolchain: stable
|
||||
targets: ${{ matrix.config.rust_target }}
|
||||
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
key: ${{ matrix.config.rust_target }}
|
||||
|
||||
- name: install Linux dependencies
|
||||
if: matrix.target.platform == 'ubuntu-latest'
|
||||
if: matrix.config.os == 'ubuntu-latest'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libgtk-3-dev
|
||||
|
||||
- name: build CLI
|
||||
- name: Build CLI
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: build
|
||||
@@ -50,8 +59,8 @@ jobs:
|
||||
- name: Upload CLI
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: cargo-tauri-${{ matrix.target.name }}${{ matrix.target.ext }}
|
||||
path: tooling/cli/target/release/cargo-tauri${{ matrix.target.ext }}
|
||||
name: cargo-tauri-${{ matrix.config.rust_target }}${{ matrix.config.ext }}
|
||||
path: tooling/cli/target/release/cargo-tauri${{ matrix.config.ext }}
|
||||
if-no-files-found: error
|
||||
|
||||
upload:
|
||||
|
||||
84
.github/workflows/test-bundler.yml
vendored
84
.github/workflows/test-bundler.yml
vendored
@@ -1,4 +1,4 @@
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -16,7 +16,6 @@ on:
|
||||
|
||||
env:
|
||||
RUST_BACKTRACE: 1
|
||||
CARGO_INCREMENTAL: 0 # This is set to 0 by the https://github.com/Swatinem/rust-cache
|
||||
CARGO_PROFILE_DEV_DEBUG: 0 # This would add unnecessary bloat to the target folder, decreasing cache efficiency.
|
||||
|
||||
concurrency:
|
||||
@@ -34,49 +33,15 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: install stable
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
|
||||
- name: Get current date
|
||||
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
|
||||
if: matrix.platform == 'macos-latest' || matrix.platform == 'ubuntu-latest'
|
||||
|
||||
- name: Get current date
|
||||
if: matrix.platform == 'windows-latest'
|
||||
run: echo "CURRENT_DATE=$(Get-Date -Format "yyyy-MM-dd")" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
|
||||
- name: Cache cargo state
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cargo_state
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
~/.cargo/bin
|
||||
key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
|
||||
restore-keys: |
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-
|
||||
${{ matrix.platform }}-stable-
|
||||
${{ matrix.platform }}-
|
||||
|
||||
- name: Cache bundler cargo target
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cargo_bundler
|
||||
with:
|
||||
path: tooling/bundler/target
|
||||
# Add date to the cache to keep it up to date
|
||||
key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('tooling/bundler/Cargo.lock') }}-${{ env.CURRENT_DATE }}
|
||||
# Restore from outdated cache for speed
|
||||
restore-keys: |
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('tooling/bundler/Cargo.lock') }}
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-
|
||||
${{ matrix.platform }}-stable-
|
||||
${{ matrix.platform }}-
|
||||
workspaces: tooling/bundler
|
||||
|
||||
- name: test
|
||||
run: |
|
||||
@@ -106,52 +71,19 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: install minimal stable with clippy and rustfmt
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
default: true
|
||||
components: rustfmt, clippy
|
||||
|
||||
- name: Get current date
|
||||
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
|
||||
if: matrix.platform == 'macos-latest' || matrix.platform == 'ubuntu-latest'
|
||||
|
||||
- name: Get current date
|
||||
if: matrix.platform == 'windows-latest'
|
||||
run: echo "CURRENT_DATE=$(Get-Date -Format "yyyy-MM-dd")" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
|
||||
- name: Cache cargo state
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cargo_state
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
~/.cargo/bin
|
||||
key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
|
||||
restore-keys: |
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-
|
||||
${{ matrix.platform }}-stable-
|
||||
${{ matrix.platform }}-
|
||||
|
||||
- name: Cache bundler cargo target
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cargo_bundler
|
||||
with:
|
||||
path: tooling/bundler/target
|
||||
# Add date to the cache to keep it up to date
|
||||
key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('tooling/bundler/Cargo.lock') }}-${{ env.CURRENT_DATE }}
|
||||
# Restore from outdated cache for speed
|
||||
restore-keys: |
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('tooling/bundler/Cargo.lock') }}
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-
|
||||
${{ matrix.platform }}-stable-
|
||||
${{ matrix.platform }}-
|
||||
workspaces: tooling/bundler
|
||||
|
||||
- name: clippy check
|
||||
uses: actions-rs/clippy-check@v1
|
||||
|
||||
62
.github/workflows/test-cli-js.yml
vendored
62
.github/workflows/test-cli-js.yml
vendored
@@ -1,4 +1,4 @@
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -17,7 +17,6 @@ on:
|
||||
|
||||
env:
|
||||
RUST_BACKTRACE: 1
|
||||
CARGO_INCREMENTAL: 0 # This is set to 0 by the https://github.com/Swatinem/rust-cache
|
||||
CARGO_PROFILE_DEV_DEBUG: 0 # This would add unnecessary bloat to the target folder, decreasing cache efficiency.
|
||||
|
||||
concurrency:
|
||||
@@ -35,6 +34,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: install Rust stable
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
@@ -51,61 +51,13 @@ jobs:
|
||||
if: matrix.platform == 'ubuntu-latest'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf
|
||||
sudo apt-get install -y webkit2gtk-4.0 libayatana-appindicator3-dev
|
||||
|
||||
- name: Get current date
|
||||
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
|
||||
if: matrix.platform == 'macos-latest' || matrix.platform == 'ubuntu-latest'
|
||||
|
||||
- name: Get current date
|
||||
if: matrix.platform == 'windows-latest'
|
||||
run: echo "CURRENT_DATE=$(Get-Date -Format "yyyy-MM-dd")" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
|
||||
- name: Cache cargo state
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cargo_state
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
~/.cargo/bin
|
||||
key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
|
||||
restore-keys: |
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-
|
||||
${{ matrix.platform }}-stable-
|
||||
${{ matrix.platform }}-
|
||||
|
||||
- name: Cache CLI cargo target
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cargo_cli
|
||||
with:
|
||||
path: tooling/cli/target
|
||||
# Add date to the cache to keep it up to date
|
||||
key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('tooling/cli/Cargo.lock') }}-${{ env.CURRENT_DATE }}
|
||||
# Restore from outdated cache for speed
|
||||
restore-keys: |
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('tooling/cli/Cargo.lock') }}
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-
|
||||
${{ matrix.platform }}-stable-
|
||||
${{ matrix.platform }}-
|
||||
|
||||
- name: Cache template cargo target
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cargo_template
|
||||
with:
|
||||
path: tooling/cli/node/test/jest/fixtures/empty/src-tauri/target
|
||||
# Add date to the cache to keep it up to date
|
||||
key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('tooling/cli/templates/app/**') }}-${{ env.CURRENT_DATE }}
|
||||
# Restore from outdated cache for speed
|
||||
restore-keys: |
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('tooling/cli/templates/app/**') }}
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-
|
||||
${{ matrix.platform }}-stable-
|
||||
${{ matrix.platform }}-
|
||||
workspaces: |
|
||||
tooling/cli
|
||||
tooling/cli/node/test/jest/fixtures/empty/src-tauri
|
||||
|
||||
- name: test
|
||||
timeout-minutes: 30
|
||||
|
||||
43
.github/workflows/test-cli-rs.yml
vendored
43
.github/workflows/test-cli-rs.yml
vendored
@@ -1,4 +1,4 @@
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -16,7 +16,6 @@ on:
|
||||
|
||||
env:
|
||||
RUST_BACKTRACE: 1
|
||||
CARGO_INCREMENTAL: 0 # This is set to 0 by the https://github.com/Swatinem/rust-cache
|
||||
CARGO_PROFILE_DEV_DEBUG: 0 # This would add unnecessary bloat to the target folder, decreasing cache efficiency.
|
||||
|
||||
concurrency:
|
||||
@@ -34,6 +33,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: install stable
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
@@ -46,44 +46,9 @@ jobs:
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libgtk-3-dev
|
||||
|
||||
- name: Get current date
|
||||
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
|
||||
if: matrix.platform == 'macos-latest' || matrix.platform == 'ubuntu-latest'
|
||||
|
||||
- name: Get current date
|
||||
if: matrix.platform == 'windows-latest'
|
||||
run: echo "CURRENT_DATE=$(Get-Date -Format "yyyy-MM-dd")" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
|
||||
- name: Cache cargo state
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cargo_state
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
~/.cargo/bin
|
||||
key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
|
||||
restore-keys: |
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-
|
||||
${{ matrix.platform }}-stable-
|
||||
${{ matrix.platform }}-
|
||||
|
||||
- name: Cache CLI cargo target
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cargo_cli
|
||||
with:
|
||||
path: tooling/cli/target
|
||||
# Add date to the cache to keep it up to date
|
||||
key: ${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('tooling/cli/Cargo.lock') }}-${{ env.CURRENT_DATE }}
|
||||
# Restore from outdated cache for speed
|
||||
restore-keys: |
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-${{ hashFiles('tooling/cli/Cargo.lock') }}
|
||||
${{ matrix.platform }}-stable-${{ env.cache-name }}-
|
||||
${{ matrix.platform }}-stable-
|
||||
${{ matrix.platform }}-
|
||||
workspaces: tooling/cli
|
||||
|
||||
- name: build CLI
|
||||
uses: actions-rs/cargo@v1
|
||||
|
||||
75
.github/workflows/test-core.yml
vendored
75
.github/workflows/test-core.yml
vendored
@@ -1,4 +1,4 @@
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -13,10 +13,10 @@ on:
|
||||
paths:
|
||||
- '.github/workflows/test-core.yml'
|
||||
- 'core/**'
|
||||
- '!core/tauri/scripts/**'
|
||||
|
||||
env:
|
||||
RUST_BACKTRACE: 1
|
||||
CARGO_INCREMENTAL: 0 # This is set to 0 by the https://github.com/Swatinem/rust-cache
|
||||
CARGO_PROFILE_DEV_DEBUG: 0 # This would add unnecessary bloat to the target folder, decreasing cache efficiency.
|
||||
|
||||
concurrency:
|
||||
@@ -39,73 +39,48 @@ jobs:
|
||||
- {
|
||||
target: x86_64-unknown-linux-gnu,
|
||||
os: ubuntu-latest,
|
||||
toolchain: '1.57.0'
|
||||
toolchain: '1.60.0'
|
||||
}
|
||||
- {
|
||||
target: x86_64-apple-darwin,
|
||||
os: macos-latest,
|
||||
toolchain: '1.57.0'
|
||||
toolchain: '1.60.0'
|
||||
}
|
||||
features:
|
||||
- {
|
||||
args: --no-default-features,
|
||||
key: no-default
|
||||
}
|
||||
- {
|
||||
args: --features api-all,
|
||||
key: api-all
|
||||
}
|
||||
- {
|
||||
args: --features compression,wry,linux-protocol-headers,isolation,custom-protocol,api-all,cli,updater,system-tray,windows7-compat,http-multipart,
|
||||
key: all
|
||||
}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: install stable
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: ${{ matrix.platform.toolchain }}
|
||||
target: ${{ matrix.platform.target }}
|
||||
override: true
|
||||
default: true
|
||||
|
||||
- name: install Linux dependencies
|
||||
if: contains(matrix.platform.target, 'unknown-linux')
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf
|
||||
sudo apt-get install -y webkit2gtk-4.0 libayatana-appindicator3-dev
|
||||
|
||||
- name: Get current date
|
||||
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
|
||||
if: matrix.platform.os == 'macos-latest' || matrix.platform.os == 'ubuntu-latest'
|
||||
|
||||
- name: Get current date
|
||||
if: matrix.platform.os == 'windows-latest'
|
||||
run: echo "CURRENT_DATE=$(Get-Date -Format "yyyy-MM-dd")" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
|
||||
- name: Cache cargo state
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cargo_state
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
~/.cargo/bin
|
||||
key: ${{ matrix.platform.os }}-${{ matrix.platform.toolchain }}-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
|
||||
restore-keys: |
|
||||
${{ matrix.platform.os }}-${{ matrix.platform.toolchain }}-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-
|
||||
${{ matrix.platform.os }}-${{ matrix.platform.toolchain }}-${{ env.cache-name }}-
|
||||
${{ matrix.platform.os }}-${{ matrix.platform.toolchain }}-
|
||||
${{ matrix.platform.os }}-
|
||||
|
||||
- name: Cache core cargo target
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cargo_core
|
||||
with:
|
||||
path: target
|
||||
# Add date to the cache to keep it up to date
|
||||
key: ${{ matrix.platform.os }}-${{ matrix.platform.toolchain }}-${{ env.cache-name }}-${{ hashFiles('core/**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
|
||||
# Restore from outdated cache for speed
|
||||
restore-keys: |
|
||||
${{ matrix.platform.os }}-${{ matrix.platform.toolchain }}-${{ env.cache-name }}-${{ hashFiles('core/**/Cargo.toml') }}
|
||||
${{ matrix.platform.os }}-${{ matrix.platform.toolchain }}-${{ env.cache-name }}-
|
||||
${{ matrix.platform.os }}-${{ matrix.platform.toolchain }}-
|
||||
${{ matrix.platform.os }}-
|
||||
|
||||
- name: pin time
|
||||
run: |
|
||||
cargo update -p time --precise 0.3.13
|
||||
workspaces: core -> ../target
|
||||
save-if: ${{ matrix.features.key == 'all' }}
|
||||
|
||||
- name: test
|
||||
run: |
|
||||
cargo test --target ${{ matrix.platform.target }}
|
||||
cargo test --target ${{ matrix.platform.target }} --features api-all
|
||||
cargo test --target ${{ matrix.platform.target }} --features compression,wry,isolation,custom-protocol,api-all,cli,updater,system-tray,windows7-compat,http-multipart
|
||||
run: cargo test --target ${{ matrix.platform.target }} ${{ matrix.features.args }}
|
||||
|
||||
75
.github/workflows/udeps.yml
vendored
75
.github/workflows/udeps.yml
vendored
@@ -1,4 +1,4 @@
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -12,7 +12,6 @@ on:
|
||||
|
||||
env:
|
||||
RUST_BACKTRACE: 1
|
||||
CARGO_INCREMENTAL: 0 # This is set to 0 by the https://github.com/Swatinem/rust-cache
|
||||
CARGO_PROFILE_DEV_DEBUG: 0 # This would add unnecessary bloat to the target folder, decreasing cache efficiency.
|
||||
|
||||
concurrency:
|
||||
@@ -40,6 +39,7 @@ jobs:
|
||||
filters: |
|
||||
tauri:
|
||||
- 'core/tauri/**'
|
||||
- '!core/tauri/scripts/**'
|
||||
build:
|
||||
- 'core/tauri-build/**'
|
||||
codegen:
|
||||
@@ -134,74 +134,17 @@ jobs:
|
||||
toolchain: nightly
|
||||
override: true
|
||||
|
||||
- name: install Linux dependencies
|
||||
- name: install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libgtk-3-dev
|
||||
|
||||
- name: Get current date
|
||||
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
|
||||
|
||||
- name: Cache cargo state
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cargo_state
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
~/.cargo/bin
|
||||
key: ubuntu-latest-nightly-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
|
||||
restore-keys: |
|
||||
ubuntu-latest-nightly-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}-
|
||||
ubuntu-latest-nightly-${{ env.cache-name }}-
|
||||
ubuntu-latest-nightly-
|
||||
ubuntu-latest-
|
||||
|
||||
- name: Cache core cargo target
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cargo_core
|
||||
with:
|
||||
path: target
|
||||
# Add date to the cache to keep it up to date
|
||||
key: ubuntu-latest-nightly-${{ env.cache-name }}-${{ hashFiles('core/**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
|
||||
# Restore from outdated cache for speed
|
||||
restore-keys: |
|
||||
ubuntu-latest-nightly-${{ env.cache-name }}-${{ hashFiles('core/**/Cargo.toml') }}
|
||||
ubuntu-latest-nightly-${{ env.cache-name }}-
|
||||
ubuntu-latest-nightly-
|
||||
ubuntu-latest-
|
||||
|
||||
- name: Cache bundler cargo target
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cargo_bundler
|
||||
with:
|
||||
path: tooling/bundler/target
|
||||
# Add date to the cache to keep it up to date
|
||||
key: ubuntu-latest-nightly-${{ env.cache-name }}-${{ hashFiles('tooling/bundler/Cargo.lock') }}-${{ env.CURRENT_DATE }}
|
||||
# Restore from outdated cache for speed
|
||||
restore-keys: |
|
||||
ubuntu-latest-nightly-${{ env.cache-name }}-${{ hashFiles('tooling/bundler/Cargo.lock') }}
|
||||
ubuntu-latest-nightly-${{ env.cache-name }}-
|
||||
ubuntu-latest-nightly-
|
||||
ubuntu-latest-
|
||||
|
||||
- name: Cache CLI cargo target
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cargo_cli
|
||||
with:
|
||||
path: tooling/cli/target
|
||||
# Add date to the cache to keep it up to date
|
||||
key: ubuntu-latest-nightly-${{ env.cache-name }}-${{ hashFiles('tooling/cli/Cargo.lock') }}-${{ env.CURRENT_DATE }}
|
||||
# Restore from outdated cache for speed
|
||||
restore-keys: |
|
||||
ubuntu-latest-nightly-${{ env.cache-name }}-${{ hashFiles('tooling/cli/Cargo.lock') }}
|
||||
ubuntu-latest-nightly-${{ env.cache-name }}-
|
||||
ubuntu-latest-nightly-
|
||||
ubuntu-latest-
|
||||
workspaces: |
|
||||
core -> ../target
|
||||
tooling/cli
|
||||
tooling/bundler
|
||||
|
||||
- name: Download udeps
|
||||
uses: actions/download-artifact@v3
|
||||
@@ -214,7 +157,7 @@ jobs:
|
||||
- name: Install required packages
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf
|
||||
sudo apt-get install -y webkit2gtk-4.0 libayatana-appindicator3-dev
|
||||
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
13
.prettierignore
Normal file
13
.prettierignore
Normal file
@@ -0,0 +1,13 @@
|
||||
/.github
|
||||
/.husky
|
||||
/.vscode
|
||||
/audits
|
||||
node_modules
|
||||
target
|
||||
dist
|
||||
/core/tauri/scripts
|
||||
/tooling/cli/templates
|
||||
/tooling/cli/node
|
||||
/tooling/cli/schema.json
|
||||
/tooling/api/docs/js-api.json
|
||||
/core/tauri-config-schema/schema.json
|
||||
@@ -1,3 +1,7 @@
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
module.exports = {
|
||||
singleQuote: true,
|
||||
semi: false,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env pwsh
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env sh
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
9
.scripts/ci/has-diff.sh
Executable file
9
.scripts/ci/has-diff.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
if git diff --quiet --ignore-submodules HEAD
|
||||
then
|
||||
echo "working directory is clean"
|
||||
else
|
||||
echo "found diff"
|
||||
exit 1
|
||||
fi
|
||||
56
.scripts/covector/package-latest-version.js
Normal file
56
.scripts/covector/package-latest-version.js
Normal file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env node
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
/*
|
||||
This script is solely intended to be run as part of the `covector publish` step to
|
||||
check the latest version of a crate, considering the current minor version.
|
||||
*/
|
||||
|
||||
const https = require('https')
|
||||
|
||||
const kind = process.argv[2]
|
||||
const packageName = process.argv[3]
|
||||
const packageVersion = process.argv[4]
|
||||
const target = packageVersion.substring(0, packageVersion.lastIndexOf('.'))
|
||||
|
||||
let url = null
|
||||
switch (kind) {
|
||||
case 'cargo':
|
||||
url = `https://crates.io/api/v1/crates/${packageName}`
|
||||
break
|
||||
case 'npm':
|
||||
url = `https://registry.npmjs.org/${packageName}`
|
||||
break
|
||||
default:
|
||||
throw new Error('unexpected kind ' + kind)
|
||||
}
|
||||
|
||||
const options = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Accept: 'application/json',
|
||||
'User-Agent': 'tauri (https://github.com/tauri-apps/tauri)'
|
||||
}
|
||||
}
|
||||
|
||||
https.get(url, options, (response) => {
|
||||
let chunks = []
|
||||
response.on('data', function (chunk) {
|
||||
chunks.push(chunk)
|
||||
})
|
||||
|
||||
response.on('end', function () {
|
||||
const data = JSON.parse(chunks.join(''))
|
||||
if (kind === 'cargo') {
|
||||
const versions = data.versions.filter((v) => v.num.startsWith(target))
|
||||
console.log(versions.length ? versions[0].num : '0.0.0')
|
||||
} else if (kind === 'npm') {
|
||||
const versions = Object.keys(data.versions).filter((v) =>
|
||||
v.startsWith(target)
|
||||
)
|
||||
console.log(versions[versions.length - 1] || '0.0.0')
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env node
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -10,34 +10,39 @@ we should look to find a more "rusty way" to import / "pin" a version value in o
|
||||
rust binaries.
|
||||
*/
|
||||
|
||||
const {
|
||||
readFileSync,
|
||||
writeFileSync
|
||||
} = require('fs')
|
||||
const { readFileSync, writeFileSync } = require('fs')
|
||||
|
||||
const packageNickname = process.argv[2]
|
||||
const filePath = packageNickname === 'cli.js' ? `../../../tooling/cli/metadata.json` : `../../tooling/cli/metadata.json`
|
||||
const filePath =
|
||||
packageNickname === 'cli.js'
|
||||
? `../../../tooling/cli/metadata.json`
|
||||
: `../../tooling/cli/metadata.json`
|
||||
const bump = process.argv[3]
|
||||
let index = null
|
||||
|
||||
switch (bump) {
|
||||
case 'major':
|
||||
index = 0;
|
||||
break;
|
||||
index = 0
|
||||
break
|
||||
case 'minor':
|
||||
index = 1;
|
||||
break;
|
||||
index = 1
|
||||
break
|
||||
case 'patch':
|
||||
index = 2;
|
||||
break;
|
||||
index = 2
|
||||
break
|
||||
default:
|
||||
throw new Error('unexpected bump ' + bump)
|
||||
}
|
||||
|
||||
const inc = (version) => {
|
||||
const v = version.split('.')
|
||||
const n = v[index]
|
||||
v[index] = String(Number(n) + 1)
|
||||
for (let i = 0; i < v.length; i++) {
|
||||
if (i === index) {
|
||||
v[i] = String(Number(v[i]) + 1)
|
||||
} else if (i > index) {
|
||||
v[i] = 0
|
||||
}
|
||||
}
|
||||
return v.join('.')
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env pwsh
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#!/usr/bin/env sh
|
||||
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
declare -a examples=("api" "sidecar" "updater" "resources" "tauri-dynamic-lib")
|
||||
declare -a examples=("api" "sidecar" "updater" "resources" "tauri-dynamic-lib" "workspace")
|
||||
declare -a tooling=("bench" "cli" "webdriver")
|
||||
|
||||
for example in "${examples[@]}"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
@ECHO OFF
|
||||
|
||||
REM Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
REM Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
REM SPDX-License-Identifier: Apache-2.0
|
||||
REM SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -8,10 +8,11 @@ members = [
|
||||
"core/tauri-utils",
|
||||
"core/tauri-build",
|
||||
"core/tauri-codegen",
|
||||
"core/tauri-config-schema",
|
||||
|
||||
# integration tests
|
||||
"core/tests/restart",
|
||||
"core/tests/app-updater"
|
||||
"core/tests/app-updater",
|
||||
]
|
||||
|
||||
exclude = [
|
||||
@@ -19,7 +20,9 @@ exclude = [
|
||||
"examples/api/src-tauri",
|
||||
"examples/updater/src-tauri",
|
||||
"examples/resources/src-tauri",
|
||||
"examples/sidecar/src-tauri"
|
||||
"examples/sidecar/src-tauri",
|
||||
"examples/web/core",
|
||||
"examples/workspace",
|
||||
]
|
||||
|
||||
# default to small, optimized workspace release binaries
|
||||
|
||||
66
README.md
66
README.md
@@ -78,22 +78,16 @@ For **running** Tauri apps we support the below configurations (these are automa
|
||||
|
||||
<sup>1</sup> `appindicator` is only required if system trays are used
|
||||
|
||||
### App Bundles
|
||||
### Features
|
||||
|
||||
- [x] App Icons
|
||||
- [x] Build on macOS (.app, .dmg)
|
||||
- [x] Build on Linux (.deb, AppImage)
|
||||
- [x] Build on Windows (.exe, .msi)
|
||||
- [x] Copy Buffer
|
||||
- [x] Device Notifications (toast)
|
||||
- [x] Desktop Bundler (.app, .dmg, .deb, AppImage, .msi)
|
||||
- [x] Self Updater
|
||||
- [x] App Signing
|
||||
- [x] Frameless Mode
|
||||
- [x] Transparent Mode
|
||||
- [x] Multiwindow Mode
|
||||
- [x] Tray
|
||||
- [ ] deeplink RPC (in progress)
|
||||
- [ ] One-Time commands (coming soon)
|
||||
- [x] Native Notifications (toast)
|
||||
- [x] App Tray
|
||||
- [x] Core Plugin System
|
||||
- [x] Scoped Filesystem
|
||||
- [x] Sidecar
|
||||
|
||||
### Security Features
|
||||
|
||||
@@ -106,39 +100,9 @@ For **running** Tauri apps we support the below configurations (these are automa
|
||||
|
||||
### Utilities
|
||||
|
||||
- [x] Rust-based CLI
|
||||
- [x] GH Action for creating binaries for all platforms
|
||||
- [x] VS Code Extension
|
||||
- [x] Tauri Core Plugins
|
||||
- [x] Update core dependencies automatically from the command line
|
||||
- [x] Rust-based CLI
|
||||
|
||||
### Comparison between Tauri and Electron
|
||||
|
||||
| Detail | Tauri | Electron |
|
||||
| -------------------------- | ------ | -------------------- |
|
||||
| Installer Size Linux | 3.1 MB | 52.1 MB |
|
||||
| Memory Consumption Linux | 180 MB | 462 MB |
|
||||
| Launch Time Linux | 0.39s | 0.80s |
|
||||
| Interface Service Provider | WRY | Chromium |
|
||||
| Backend Binding | Rust | Node.js (ECMAScript) |
|
||||
| Underlying Engine | Rust | V8 (C/C++) |
|
||||
| FLOSS | Yes | No |
|
||||
| Multithreading | Yes | Yes |
|
||||
| Bytecode Delivery | Yes | No |
|
||||
| Multiple Windows | Yes | Yes |
|
||||
| Auto Updater | Yes | Yes<sup>1</sup> |
|
||||
| Custom App Icon | Yes | Yes |
|
||||
| Windows Binary | Yes | Yes |
|
||||
| macOS Binary | Yes | Yes |
|
||||
| Linux Binary | Yes | Yes |
|
||||
| iOS Binary | Soon | No |
|
||||
| Android Binary | Soon | No |
|
||||
| Desktop Tray | Yes | Yes |
|
||||
| Sidecar Binaries | Yes | No |
|
||||
|
||||
#### Notes
|
||||
|
||||
1. Electron has no native auto updater on Linux, but is offered by electron-packager
|
||||
|
||||
## Development
|
||||
|
||||
@@ -153,18 +117,6 @@ Tauri is a system composed of a number of moving pieces:
|
||||
- Netlify-hosted documentation website
|
||||
- DigitalOcean Meilisearch instance
|
||||
|
||||
### Major Runtimes
|
||||
|
||||
- Node.js for running the CLI (deno and pure rust are on the roadmap)
|
||||
- Cargo for testing, running the dev service, building binaries and as the runtime harness for the webview
|
||||
|
||||
### Major Languages
|
||||
|
||||
- Rust for the CLI
|
||||
- ECMAScript bindings to the Rust API, written in typescript
|
||||
- Rust for bindings, rust side of the API, harnesses
|
||||
- Rust plugins to Tauri backend
|
||||
|
||||
### Operating systems
|
||||
|
||||
Tauri core can be developed on Mac, Linux and Windows, but you are encouraged to use the latest possible operating systems and build tools for your OS.
|
||||
@@ -186,7 +138,7 @@ Documentation in a polyglot system is a tricky proposition. To this end, we pref
|
||||
Test all the things! We have a number of test suites, but are always looking to improve our coverage:
|
||||
|
||||
- Rust (`cargo test`) => sourced via inline `#[cfg(test)]` declarations
|
||||
- TS (`jest`) => via spec files
|
||||
- Typescript (`jest`) => via spec files
|
||||
- Smoke Tests (run on merges to latest)
|
||||
- eslint, clippy
|
||||
|
||||
|
||||
11
SECURITY.md
11
SECURITY.md
@@ -13,7 +13,16 @@ If you have found a potential security threat, vulnerability or exploit in Tauri
|
||||
or one of its upstream dependencies, please DON’T create a pull-request, DON’T
|
||||
file an issue on GitHub, DON’T mention it on Discord and DON’T create a forum thread.
|
||||
|
||||
We will be adding contact information to this page very soon.
|
||||
Please submit your report via the GitHub Private Vulnerability Disclosure functionality.
|
||||
|
||||
Find out more about the reporting process [here](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability).
|
||||
|
||||
Our team will triage your report and keep you informed about the progress.
|
||||
We may ask questions or request further guidance on reproduction of the vulnerability in the comments of the advisory, which will be publicized.
|
||||
|
||||
Additionally, we may ask you to independently verify our patch, which will be available in the private advisory branch. Please do not publish your vulnerability during the process or before coordinated public disclosure from our side. We try to adhere to common standards of publication within 90-Days of disclosure.
|
||||
|
||||
Depending on your decision to accept or deny credit for the vulnerability, you will be publicly attributed to the vulnerability and may be mentioned in our announcements.
|
||||
|
||||
At the current time we do not have the financial ability to reward bounties,
|
||||
but in extreme cases will at our discretion consider a reward.
|
||||
|
||||
102
check-license-header.js
Normal file
102
check-license-header.js
Normal file
@@ -0,0 +1,102 @@
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const readline = require('readline')
|
||||
|
||||
const header = `Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
SPDX-License-Identifier: MIT`
|
||||
const bundlerLicense = '// Copyright 2016-2019 Cargo-Bundle developers <https://github.com/burtonageo/cargo-bundle>'
|
||||
|
||||
const extensions = ['.rs', '.js', '.ts', '.yml']
|
||||
const ignore = ['target', 'templates', 'node_modules', 'gen', 'dist', 'bundle.js', 'bundle.global.js']
|
||||
|
||||
async function checkFile(file) {
|
||||
if (extensions.some(e => file.endsWith(e))) {
|
||||
const fileStream = fs.createReadStream(file)
|
||||
const rl = readline.createInterface({
|
||||
input: fileStream,
|
||||
crlfDelay: Infinity
|
||||
})
|
||||
|
||||
let contents = ``
|
||||
let i = 0
|
||||
for await (let line of rl) {
|
||||
// ignore empty lines, allow shebang and bundler license
|
||||
if (line.length === 0 || line.startsWith("#!") || line === bundlerLicense) {
|
||||
continue
|
||||
}
|
||||
|
||||
// strip comment marker
|
||||
if (line.startsWith('// ')) {
|
||||
line = line.substring(3)
|
||||
} else if (line.startsWith('# ')) {
|
||||
line = line.substring(2)
|
||||
}
|
||||
|
||||
contents += line
|
||||
if (++i === 3) {
|
||||
break
|
||||
}
|
||||
contents += '\n'
|
||||
}
|
||||
if (contents !== header) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
async function check(src) {
|
||||
const missingHeader = []
|
||||
|
||||
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
|
||||
const p = path.join(src, entry.name)
|
||||
|
||||
if (entry.isSymbolicLink() || ignore.includes(entry.name)) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
const missing = await check(p)
|
||||
missingHeader.push(...missing)
|
||||
} else {
|
||||
const isMissing = await checkFile(p)
|
||||
if (isMissing) {
|
||||
missingHeader.push(p)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return missingHeader
|
||||
}
|
||||
|
||||
const [_bin, _script, ...files] = process.argv
|
||||
|
||||
if (files.length > 0) {
|
||||
async function run() {
|
||||
const missing = []
|
||||
for (const f of files) {
|
||||
const isMissing = await checkFile(f)
|
||||
if (isMissing) {
|
||||
missing.push(f)
|
||||
}
|
||||
}
|
||||
if (missing.length > 0) {
|
||||
console.log(missing.join('\n'))
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
run()
|
||||
} else {
|
||||
check('.').then(missing => {
|
||||
if (missing.length > 0) {
|
||||
console.log(missing.join('\n'))
|
||||
process.exit(1)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1,5 +1,34 @@
|
||||
# Changelog
|
||||
|
||||
## \[1.3.0]
|
||||
|
||||
- Bump minimum supported Rust version to 1.60.
|
||||
- [5fdc616d](https://www.github.com/tauri-apps/tauri/commit/5fdc616df9bea633810dcb814ac615911d77222c) feat: Use the zbus-backed of notify-rust ([#6332](https://www.github.com/tauri-apps/tauri/pull/6332)) on 2023-03-31
|
||||
- Add initial support for building `nsis` bundles on non-Windows platforms.
|
||||
- [60e6f6c3](https://www.github.com/tauri-apps/tauri/commit/60e6f6c3f1605f3064b5bb177992530ff788ccf0) feat(bundler): Add support for creating NSIS bundles on unix hosts ([#5788](https://www.github.com/tauri-apps/tauri/pull/5788)) on 2023-01-19
|
||||
- Add `WindowsAttributes::app_manifest` to specify the application manifest on Windows.
|
||||
- [bca09f7f](https://www.github.com/tauri-apps/tauri/commit/bca09f7f5ff1c9c5a4b51da043bdd5da668a179b) feat(tauri-build): add option to specify Windows manifest, closes [#5584](https://www.github.com/tauri-apps/tauri/pull/5584) ([#5730](https://www.github.com/tauri-apps/tauri/pull/5730)) on 2022-12-14
|
||||
- Added support for Cargo's workspace inheritance for package information. The cli now also detects inherited `tauri` and `tauri-build` dependencies and disables manifest rewrites accordingly.
|
||||
- [cd8c074a](https://www.github.com/tauri-apps/tauri/commit/cd8c074ae6592303d3f6844a4fb6d262eae913b2) feat(cli): add support for Cargo's workspace inheritance for the package version, closes [#5070](https://www.github.com/tauri-apps/tauri/pull/5070) ([#5775](https://www.github.com/tauri-apps/tauri/pull/5775)) on 2022-12-14
|
||||
- [d20a7288](https://www.github.com/tauri-apps/tauri/commit/d20a728892eee1858ab525ab6216cd721f473ab5) feat: Further improve workspace inheritance, closes [#6122](https://www.github.com/tauri-apps/tauri/pull/6122), [#5070](https://www.github.com/tauri-apps/tauri/pull/5070) ([#6144](https://www.github.com/tauri-apps/tauri/pull/6144)) on 2023-01-26
|
||||
- Pin `winnow` crate to 0.4.1 to keep the 1.60 MSRV.
|
||||
|
||||
## \[1.2.1]
|
||||
|
||||
- Fix `allowlist > app > show/hide` always disabled when `allowlist > app > all: false`.
|
||||
- Bumped due to a bump in tauri-utils.
|
||||
- [bb251087](https://www.github.com/tauri-apps/tauri/commit/bb2510876d0bdff736d36bf3a465cdbe4ad2b90c) fix(core): extend allowlist with `app`'s allowlist, closes [#5650](https://www.github.com/tauri-apps/tauri/pull/5650) ([#5652](https://www.github.com/tauri-apps/tauri/pull/5652)) on 2022-11-18
|
||||
|
||||
## \[1.2.0]
|
||||
|
||||
- - [7d9aa398](https://www.github.com/tauri-apps/tauri/commit/7d9aa3987efce2d697179ffc33646d086c68030c) feat: bump MSRV to 1.59 ([#5296](https://www.github.com/tauri-apps/tauri/pull/5296)) on 2022-09-28
|
||||
|
||||
## \[1.1.1]
|
||||
|
||||
- Add missing allowlist config for `set_cursor_grab`, `set_cursor_visible`, `set_cursor_icon` and `set_cursor_position` APIs.
|
||||
- Bumped due to a bump in tauri-utils.
|
||||
- [c764408d](https://www.github.com/tauri-apps/tauri/commit/c764408da7fae123edd41115bda42fa75a4731d2) fix: Add missing allowlist config for cursor apis, closes [#5207](https://www.github.com/tauri-apps/tauri/pull/5207) ([#5211](https://www.github.com/tauri-apps/tauri/pull/5211)) on 2022-09-16
|
||||
|
||||
## \[1.1.0]
|
||||
|
||||
- Rerun codegen if assets or icons change.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "tauri-build"
|
||||
version = "1.1.0"
|
||||
version = "1.3.0"
|
||||
authors = [ "Tauri Programme within The Commons Conservancy" ]
|
||||
categories = [ "gui", "web-programming" ]
|
||||
license = "Apache-2.0 OR MIT"
|
||||
@@ -8,7 +8,7 @@ homepage = "https://tauri.app"
|
||||
repository = "https://github.com/tauri-apps/tauri/tree/dev/core/tauri-build"
|
||||
description = "build time code to pair with https://crates.io/crates/tauri"
|
||||
edition = "2021"
|
||||
rust-version = "1.57"
|
||||
rust-version = "1.60"
|
||||
exclude = [ "CHANGELOG.md", "/target" ]
|
||||
readme = "README.md"
|
||||
|
||||
@@ -19,15 +19,15 @@ rustdoc-args = [ "--cfg", "doc_cfg" ]
|
||||
[dependencies]
|
||||
anyhow = "1"
|
||||
quote = { version = "1", optional = true }
|
||||
tauri-codegen = { version = "1.1.0", path = "../tauri-codegen", optional = true }
|
||||
tauri-utils = { version = "1.1.0", path = "../tauri-utils", features = [ "build", "resources" ] }
|
||||
cargo_toml = "0.11"
|
||||
tauri-codegen = { version = "1.3.0", path = "../tauri-codegen", optional = true }
|
||||
tauri-utils = { version = "1.3.0", path = "../tauri-utils", features = [ "build", "resources" ] }
|
||||
cargo_toml = "0.15"
|
||||
winnow = "=0.4.1"
|
||||
serde = "1"
|
||||
serde_json = "1"
|
||||
heck = "0.4"
|
||||
json-patch = "0.2"
|
||||
|
||||
[target."cfg(windows)".dependencies]
|
||||
winres = "0.1"
|
||||
json-patch = "1.0"
|
||||
tauri-winres = "0.1"
|
||||
semver = "1"
|
||||
|
||||
[features]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -86,7 +86,7 @@ impl CodegenContext {
|
||||
pub fn build(self) -> PathBuf {
|
||||
match self.try_build() {
|
||||
Ok(out) => out,
|
||||
Err(error) => panic!("Error found during Codegen::build: {}", error),
|
||||
Err(error) => panic!("Error found during Codegen::build: {error}"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ impl CodegenContext {
|
||||
)
|
||||
})?;
|
||||
|
||||
writeln!(file, "{}", code).with_context(|| {
|
||||
writeln!(file, "{code}").with_context(|| {
|
||||
format!(
|
||||
"Unable to write tokenstream to out file during tauri-build {}",
|
||||
out.display()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#![cfg_attr(doc_cfg, feature(doc_cfg))]
|
||||
|
||||
pub use anyhow::Result;
|
||||
use cargo_toml::{Dependency, Manifest};
|
||||
use heck::AsShoutySnakeCase;
|
||||
|
||||
use tauri_utils::resources::{external_binaries, resource_relpath, ResourcePaths};
|
||||
use tauri_utils::{
|
||||
config::Config,
|
||||
resources::{external_binaries, resource_relpath, ResourcePaths},
|
||||
};
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
#[cfg(feature = "codegen")]
|
||||
mod codegen;
|
||||
#[cfg(windows)]
|
||||
mod static_vcruntime;
|
||||
|
||||
#[cfg(feature = "codegen")]
|
||||
@@ -35,8 +38,8 @@ fn copy_file(from: impl AsRef<Path>, to: impl AsRef<Path>) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn copy_binaries<'a>(
|
||||
binaries: ResourcePaths<'a>,
|
||||
fn copy_binaries(
|
||||
binaries: ResourcePaths,
|
||||
target_triple: &str,
|
||||
path: &Path,
|
||||
package_name: Option<&String>,
|
||||
@@ -48,7 +51,7 @@ fn copy_binaries<'a>(
|
||||
.file_name()
|
||||
.expect("failed to extract external binary filename")
|
||||
.to_string_lossy()
|
||||
.replace(&format!("-{}", target_triple), "");
|
||||
.replace(&format!("-{target_triple}"), "");
|
||||
|
||||
if package_name.map_or(false, |n| n == &file_name) {
|
||||
return Err(anyhow::anyhow!(
|
||||
@@ -72,7 +75,7 @@ fn copy_resources(resources: ResourcePaths<'_>, path: &Path) -> Result<()> {
|
||||
let src = src?;
|
||||
println!("cargo:rerun-if-changed={}", src.display());
|
||||
let dest = path.join(resource_relpath(&src));
|
||||
copy_file(&src, &dest)?;
|
||||
copy_file(&src, dest)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -90,7 +93,7 @@ fn has_feature(feature: &str) -> bool {
|
||||
// `alias` must be a snake case string.
|
||||
fn cfg_alias(alias: &str, has_feature: bool) {
|
||||
if has_feature {
|
||||
println!("cargo:rustc-cfg={}", alias);
|
||||
println!("cargo:rustc-cfg={alias}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,6 +113,15 @@ pub struct WindowsAttributes {
|
||||
///
|
||||
/// If it is left unset, it will look up a path in the registry, i.e. HKLM\SOFTWARE\Microsoft\Windows Kits\Installed Roots
|
||||
sdk_dir: Option<PathBuf>,
|
||||
/// A string containing an [application manifest] to be included with the application on Windows.
|
||||
///
|
||||
/// Defaults to:
|
||||
/// ```ignore
|
||||
#[doc = include_str!("window-app-manifest.xml")]
|
||||
/// ```
|
||||
///
|
||||
/// [application manifest]: https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests
|
||||
app_manifest: Option<String>,
|
||||
}
|
||||
|
||||
impl WindowsAttributes {
|
||||
@@ -135,6 +147,45 @@ impl WindowsAttributes {
|
||||
self.sdk_dir = Some(sdk_dir.as_ref().into());
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the Windows app [manifest].
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// The following manifest will brand the exe as requesting administrator privileges.
|
||||
/// Thus, everytime it is executed, a Windows UAC dialog will appear.
|
||||
///
|
||||
/// Note that you can move the manifest contents to a separate file and use `include_str!("manifest.xml")`
|
||||
/// instead of the inline string.
|
||||
///
|
||||
/// ```rust,no_run
|
||||
/// let mut windows = tauri_build::WindowsAttributes::new();
|
||||
/// windows = windows.app_manifest(r#"
|
||||
/// <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
/// <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
/// <security>
|
||||
/// <requestedPrivileges>
|
||||
/// <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
|
||||
/// </requestedPrivileges>
|
||||
/// </security>
|
||||
/// </trustInfo>
|
||||
/// </assembly>
|
||||
/// "#);
|
||||
/// tauri_build::try_build(
|
||||
/// tauri_build::Attributes::new().windows_attributes(windows)
|
||||
/// ).expect("failed to run build script");
|
||||
/// ```
|
||||
///
|
||||
/// Defaults to:
|
||||
/// ```ignore
|
||||
#[doc = include_str!("window-app-manifest.xml")]
|
||||
/// [manifest]: https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests
|
||||
/// ```
|
||||
#[must_use]
|
||||
pub fn app_manifest<S: AsRef<str>>(mut self, manifest: S) -> Self {
|
||||
self.app_manifest = Some(manifest.as_ref().to_string());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
/// The attributes used on the build.
|
||||
@@ -179,8 +230,8 @@ impl Attributes {
|
||||
/// This is typically desirable when running inside a build script; see [`try_build`] for no panics.
|
||||
pub fn build() {
|
||||
if let Err(error) = try_build(Attributes::default()) {
|
||||
let error = format!("{:#}", error);
|
||||
println!("{}", error);
|
||||
let error = format!("{error:#}");
|
||||
println!("{error}");
|
||||
if error.starts_with("unknown field") {
|
||||
print!("found an unknown configuration field. This usually means that you are using a CLI version that is newer than `tauri-build` and is incompatible. ");
|
||||
println!(
|
||||
@@ -195,8 +246,6 @@ pub fn build() {
|
||||
#[allow(unused_variables)]
|
||||
pub fn try_build(attributes: Attributes) -> Result<()> {
|
||||
use anyhow::anyhow;
|
||||
use cargo_toml::{Dependency, Manifest};
|
||||
use tauri_utils::config::{Config, TauriConfig};
|
||||
|
||||
println!("cargo:rerun-if-env-changed=TAURI_CONFIG");
|
||||
println!("cargo:rerun-if-changed=tauri.conf.json");
|
||||
@@ -221,49 +270,33 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
|
||||
|
||||
cfg_alias("dev", !has_feature("custom-protocol"));
|
||||
|
||||
let mut manifest = Manifest::from_path("Cargo.toml")?;
|
||||
let ws_path = get_workspace_dir()?;
|
||||
let mut manifest =
|
||||
Manifest::<cargo_toml::Value>::from_slice_with_metadata(&std::fs::read("Cargo.toml")?)?;
|
||||
|
||||
if let Ok(ws_manifest) = Manifest::from_path(ws_path.join("Cargo.toml")) {
|
||||
Manifest::complete_from_path_and_workspace(
|
||||
&mut manifest,
|
||||
Path::new("Cargo.toml"),
|
||||
Some((&ws_manifest, ws_path.as_path())),
|
||||
)?;
|
||||
} else {
|
||||
Manifest::complete_from_path(&mut manifest, Path::new("Cargo.toml"))?;
|
||||
}
|
||||
|
||||
if let Some(tauri_build) = manifest.build_dependencies.remove("tauri-build") {
|
||||
let error_message = check_features(&config, tauri_build, true);
|
||||
|
||||
if !error_message.is_empty() {
|
||||
return Err(anyhow!("
|
||||
The `tauri-build` dependency features on the `Cargo.toml` file does not match the allowlist defined under `tauri.conf.json`.
|
||||
Please run `tauri dev` or `tauri build` or {}.
|
||||
", error_message));
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(tauri) = manifest.dependencies.remove("tauri") {
|
||||
let features = match tauri {
|
||||
Dependency::Simple(_) => Vec::new(),
|
||||
Dependency::Detailed(dep) => dep.features,
|
||||
};
|
||||
|
||||
let all_cli_managed_features = TauriConfig::all_features();
|
||||
let diff = features_diff(
|
||||
&features
|
||||
.into_iter()
|
||||
.filter(|f| all_cli_managed_features.contains(&f.as_str()))
|
||||
.collect::<Vec<String>>(),
|
||||
&config
|
||||
.tauri
|
||||
.features()
|
||||
.into_iter()
|
||||
.map(|f| f.to_string())
|
||||
.collect::<Vec<String>>(),
|
||||
);
|
||||
|
||||
let mut error_message = String::new();
|
||||
if !diff.remove.is_empty() {
|
||||
error_message.push_str("remove the `");
|
||||
error_message.push_str(&diff.remove.join(", "));
|
||||
error_message.push_str(if diff.remove.len() == 1 {
|
||||
"` feature"
|
||||
} else {
|
||||
"` features"
|
||||
});
|
||||
if !diff.add.is_empty() {
|
||||
error_message.push_str(" and ");
|
||||
}
|
||||
}
|
||||
if !diff.add.is_empty() {
|
||||
error_message.push_str("add the `");
|
||||
error_message.push_str(&diff.add.join(", "));
|
||||
error_message.push_str(if diff.add.len() == 1 {
|
||||
"` feature"
|
||||
} else {
|
||||
"` features"
|
||||
});
|
||||
}
|
||||
let error_message = check_features(&config, tauri, false);
|
||||
|
||||
if !error_message.is_empty() {
|
||||
return Err(anyhow!("
|
||||
@@ -295,25 +328,25 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
|
||||
|
||||
#[allow(unused_mut, clippy::redundant_clone)]
|
||||
let mut resources = config.tauri.bundle.resources.clone().unwrap_or_default();
|
||||
#[cfg(windows)]
|
||||
if let Some(fixed_webview2_runtime_path) = &config.tauri.bundle.windows.webview_fixed_runtime_path
|
||||
{
|
||||
resources.push(fixed_webview2_runtime_path.display().to_string());
|
||||
if target_triple.contains("windows") {
|
||||
if let Some(fixed_webview2_runtime_path) =
|
||||
&config.tauri.bundle.windows.webview_fixed_runtime_path
|
||||
{
|
||||
resources.push(fixed_webview2_runtime_path.display().to_string());
|
||||
}
|
||||
}
|
||||
copy_resources(ResourcePaths::new(resources.as_slice(), true), target_dir)?;
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
if let Some(version) = config.tauri.bundle.macos.minimum_system_version {
|
||||
println!("cargo:rustc-env=MACOSX_DEPLOYMENT_TARGET={}", version);
|
||||
if target_triple.contains("darwin") {
|
||||
if let Some(version) = &config.tauri.bundle.macos.minimum_system_version {
|
||||
println!("cargo:rustc-env=MACOSX_DEPLOYMENT_TARGET={version}");
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
{
|
||||
if target_triple.contains("windows") {
|
||||
use anyhow::Context;
|
||||
use semver::Version;
|
||||
use winres::{VersionInfo, WindowsResource};
|
||||
use tauri_winres::{VersionInfo, WindowsResource};
|
||||
|
||||
fn find_icon<F: Fn(&&String) -> bool>(config: &Config, predicate: F, default: &str) -> PathBuf {
|
||||
let icon_path = config
|
||||
@@ -335,24 +368,11 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
|
||||
if window_icon_path.exists() {
|
||||
let mut res = WindowsResource::new();
|
||||
|
||||
res.set_manifest(
|
||||
r#"
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="*"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
</assembly>
|
||||
"#,
|
||||
);
|
||||
if let Some(manifest) = attributes.windows_attributes.app_manifest {
|
||||
res.set_manifest(&manifest);
|
||||
} else {
|
||||
res.set_manifest(include_str!("window-app-manifest.xml"));
|
||||
}
|
||||
|
||||
if let Some(sdk_dir) = &attributes.windows_attributes.sdk_dir {
|
||||
if let Some(sdk_dir_str) = sdk_dir.to_str() {
|
||||
@@ -450,6 +470,89 @@ fn features_diff(current: &[String], expected: &[String]) -> Diff {
|
||||
Diff { remove, add }
|
||||
}
|
||||
|
||||
fn check_features(config: &Config, dependency: Dependency, is_tauri_build: bool) -> String {
|
||||
use tauri_utils::config::{PatternKind, TauriConfig};
|
||||
|
||||
let features = match dependency {
|
||||
Dependency::Simple(_) => Vec::new(),
|
||||
Dependency::Detailed(dep) => dep.features,
|
||||
Dependency::Inherited(dep) => dep.features,
|
||||
};
|
||||
|
||||
let all_cli_managed_features = if is_tauri_build {
|
||||
vec!["isolation"]
|
||||
} else {
|
||||
TauriConfig::all_features()
|
||||
};
|
||||
|
||||
let expected = if is_tauri_build {
|
||||
match config.tauri.pattern {
|
||||
PatternKind::Isolation { .. } => vec!["isolation".to_string()],
|
||||
_ => vec![],
|
||||
}
|
||||
} else {
|
||||
config
|
||||
.tauri
|
||||
.features()
|
||||
.into_iter()
|
||||
.map(|f| f.to_string())
|
||||
.collect::<Vec<String>>()
|
||||
};
|
||||
|
||||
let diff = features_diff(
|
||||
&features
|
||||
.into_iter()
|
||||
.filter(|f| all_cli_managed_features.contains(&f.as_str()))
|
||||
.collect::<Vec<String>>(),
|
||||
&expected,
|
||||
);
|
||||
|
||||
let mut error_message = String::new();
|
||||
if !diff.remove.is_empty() {
|
||||
error_message.push_str("remove the `");
|
||||
error_message.push_str(&diff.remove.join(", "));
|
||||
error_message.push_str(if diff.remove.len() == 1 {
|
||||
"` feature"
|
||||
} else {
|
||||
"` features"
|
||||
});
|
||||
if !diff.add.is_empty() {
|
||||
error_message.push_str(" and ");
|
||||
}
|
||||
}
|
||||
if !diff.add.is_empty() {
|
||||
error_message.push_str("add the `");
|
||||
error_message.push_str(&diff.add.join(", "));
|
||||
error_message.push_str(if diff.add.len() == 1 {
|
||||
"` feature"
|
||||
} else {
|
||||
"` features"
|
||||
});
|
||||
}
|
||||
|
||||
error_message
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
struct CargoMetadata {
|
||||
workspace_root: PathBuf,
|
||||
}
|
||||
|
||||
fn get_workspace_dir() -> Result<PathBuf> {
|
||||
let output = std::process::Command::new("cargo")
|
||||
.args(["metadata", "--no-deps", "--format-version", "1"])
|
||||
.output()?;
|
||||
|
||||
if !output.status.success() {
|
||||
return Err(anyhow::anyhow!(
|
||||
"cargo metadata command exited with a non zero exit code: {}",
|
||||
String::from_utf8(output.stderr)?
|
||||
));
|
||||
}
|
||||
|
||||
Ok(serde_json::from_slice::<CargoMetadata>(&output.stdout)?.workspace_root)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::Diff;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -48,11 +48,11 @@ fn override_msvcrt_lib() {
|
||||
let f = fs::OpenOptions::new()
|
||||
.write(true)
|
||||
.create_new(true)
|
||||
.open(&path);
|
||||
.open(path);
|
||||
if let Ok(mut f) = f {
|
||||
f.write_all(machine).unwrap();
|
||||
f.write_all(bytes).unwrap();
|
||||
}
|
||||
// Add the output directory to the native library path.
|
||||
println!("cargo:rustc-link-search=native={}", out_dir);
|
||||
println!("cargo:rustc-link-search=native={out_dir}");
|
||||
}
|
||||
|
||||
14
core/tauri-build/src/window-app-manifest.xml
Normal file
14
core/tauri-build/src/window-app-manifest.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="*"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
</assembly>
|
||||
@@ -1,5 +1,30 @@
|
||||
# Changelog
|
||||
|
||||
## \[1.3.0]
|
||||
|
||||
- Bump minimum supported Rust version to 1.60.
|
||||
- [5fdc616d](https://www.github.com/tauri-apps/tauri/commit/5fdc616df9bea633810dcb814ac615911d77222c) feat: Use the zbus-backed of notify-rust ([#6332](https://www.github.com/tauri-apps/tauri/pull/6332)) on 2023-03-31
|
||||
- Pin `time` to `0.3.15`.
|
||||
- [3d16461b](https://www.github.com/tauri-apps/tauri/commit/3d16461b68583ba7db037fbc217786e79b46ddf2) fix(core): pin time to 0.3.15 ([#6312](https://www.github.com/tauri-apps/tauri/pull/6312)) on 2023-02-19
|
||||
|
||||
## \[1.2.1]
|
||||
|
||||
- Fix `allowlist > app > show/hide` always disabled when `allowlist > app > all: false`.
|
||||
- Bumped due to a bump in tauri-utils.
|
||||
- [bb251087](https://www.github.com/tauri-apps/tauri/commit/bb2510876d0bdff736d36bf3a465cdbe4ad2b90c) fix(core): extend allowlist with `app`'s allowlist, closes [#5650](https://www.github.com/tauri-apps/tauri/pull/5650) ([#5652](https://www.github.com/tauri-apps/tauri/pull/5652)) on 2022-11-18
|
||||
|
||||
## \[1.2.0]
|
||||
|
||||
- Properly serialize HTML template tags.
|
||||
- [aec5537d](https://www.github.com/tauri-apps/tauri/commit/aec5537de0205f62b2ae5c89da04d21930a6fc2e) fix(codegen): serialize template tags, closes [#4410](https://www.github.com/tauri-apps/tauri/pull/4410) ([#5247](https://www.github.com/tauri-apps/tauri/pull/5247)) on 2022-09-28
|
||||
- - [7d9aa398](https://www.github.com/tauri-apps/tauri/commit/7d9aa3987efce2d697179ffc33646d086c68030c) feat: bump MSRV to 1.59 ([#5296](https://www.github.com/tauri-apps/tauri/pull/5296)) on 2022-09-28
|
||||
|
||||
## \[1.1.1]
|
||||
|
||||
- Add missing allowlist config for `set_cursor_grab`, `set_cursor_visible`, `set_cursor_icon` and `set_cursor_position` APIs.
|
||||
- Bumped due to a bump in tauri-utils.
|
||||
- [c764408d](https://www.github.com/tauri-apps/tauri/commit/c764408da7fae123edd41115bda42fa75a4731d2) fix: Add missing allowlist config for cursor apis, closes [#5207](https://www.github.com/tauri-apps/tauri/pull/5207) ([#5211](https://www.github.com/tauri-apps/tauri/pull/5211)) on 2022-09-16
|
||||
|
||||
## \[1.1.0]
|
||||
|
||||
- Use `TARGET` environment variable for code generation inside build scripts.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "tauri-codegen"
|
||||
version = "1.1.0"
|
||||
version = "1.3.0"
|
||||
authors = [ "Tauri Programme within The Commons Conservancy" ]
|
||||
categories = [ "gui", "web-programming" ]
|
||||
license = "Apache-2.0 OR MIT"
|
||||
@@ -8,31 +8,31 @@ homepage = "https://tauri.app"
|
||||
repository = "https://github.com/tauri-apps/tauri/tree/dev/core/tauri-codegen"
|
||||
description = "code generation meant to be consumed inside of `tauri` through `tauri-build` or `tauri-macros`"
|
||||
edition = "2021"
|
||||
rust-version = "1.57"
|
||||
rust-version = "1.60"
|
||||
exclude = [ "CHANGELOG.md", "/target" ]
|
||||
readme = "README.md"
|
||||
|
||||
[dependencies]
|
||||
sha2 = "0.10"
|
||||
base64 = "0.13"
|
||||
base64 = "0.21"
|
||||
proc-macro2 = "1"
|
||||
quote = "1"
|
||||
serde = { version = "1", features = [ "derive" ] }
|
||||
serde_json = "1"
|
||||
tauri-utils = { version = "1.1.0", path = "../tauri-utils", features = [ "build" ] }
|
||||
tauri-utils = { version = "1.3.0", path = "../tauri-utils", features = [ "build" ] }
|
||||
thiserror = "1"
|
||||
walkdir = "2"
|
||||
brotli = { version = "3", optional = true, default-features = false, features = [ "std" ] }
|
||||
regex = { version = "1.6.0", optional = true }
|
||||
regex = { version = "1.7.1", optional = true }
|
||||
uuid = { version = "1", features = [ "v4" ] }
|
||||
semver = "1"
|
||||
ico = "0.1"
|
||||
ico = "0.3"
|
||||
png = "0.17"
|
||||
json-patch = "0.2"
|
||||
json-patch = "1.0"
|
||||
|
||||
[target."cfg(target_os = \"macos\")".dependencies]
|
||||
plist = "1"
|
||||
time = { version = "0.3", features = [ "parsing", "formatting" ] }
|
||||
time = { version = "=0.3.15", features = [ "parsing", "formatting" ] }
|
||||
|
||||
[features]
|
||||
default = [ "compression" ]
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::{ffi::OsStr, str::FromStr};
|
||||
|
||||
use base64::Engine;
|
||||
use proc_macro2::TokenStream;
|
||||
use quote::quote;
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
use tauri_utils::assets::AssetKey;
|
||||
use tauri_utils::config::{AppUrl, Config, PatternKind, WindowUrl};
|
||||
use tauri_utils::html::{inject_nonce_token, parse as parse_html};
|
||||
use tauri_utils::html::{
|
||||
inject_nonce_token, parse as parse_html, serialize_node as serialize_html_node,
|
||||
};
|
||||
|
||||
#[cfg(feature = "shell-scope")]
|
||||
use tauri_utils::config::{ShellAllowedArg, ShellAllowedArgs, ShellAllowlistScope};
|
||||
@@ -37,10 +40,10 @@ fn map_core_assets(
|
||||
options.dangerous_disable_asset_csp_modification.clone();
|
||||
move |key, path, input, csp_hashes| {
|
||||
if path.extension() == Some(OsStr::new("html")) {
|
||||
let mut document = parse_html(String::from_utf8_lossy(input).into_owned());
|
||||
|
||||
#[allow(clippy::collapsible_if)]
|
||||
if csp {
|
||||
let mut document = parse_html(String::from_utf8_lossy(input).into_owned());
|
||||
|
||||
if target == Target::Linux {
|
||||
::tauri_utils::html::inject_csp_token(&mut document);
|
||||
}
|
||||
@@ -55,7 +58,10 @@ fn map_core_assets(
|
||||
let mut hasher = Sha256::new();
|
||||
hasher.update(&script);
|
||||
let hash = hasher.finalize();
|
||||
scripts.push(format!("'sha256-{}'", base64::encode(&hash)));
|
||||
scripts.push(format!(
|
||||
"'sha256-{}'",
|
||||
base64::engine::general_purpose::STANDARD.encode(hash)
|
||||
));
|
||||
}
|
||||
csp_hashes
|
||||
.inline_scripts
|
||||
@@ -72,14 +78,15 @@ fn map_core_assets(
|
||||
let mut hasher = Sha256::new();
|
||||
hasher.update(tauri_utils::pattern::isolation::IFRAME_STYLE);
|
||||
let hash = hasher.finalize();
|
||||
csp_hashes
|
||||
.styles
|
||||
.push(format!("'sha256-{}'", base64::encode(&hash)));
|
||||
csp_hashes.styles.push(format!(
|
||||
"'sha256-{}'",
|
||||
base64::engine::general_purpose::STANDARD.encode(hash)
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*input = document.to_string().as_bytes().to_vec();
|
||||
*input = serialize_html_node(&document);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -139,7 +146,7 @@ pub fn context_codegen(data: ContextData) -> Result<TokenStream, EmbeddedAssetsE
|
||||
} else if target.contains("apple-ios") {
|
||||
Target::Ios
|
||||
} else {
|
||||
panic!("unknown codegen target {}", target);
|
||||
panic!("unknown codegen target {target}");
|
||||
}
|
||||
} else if cfg!(target_os = "linux") {
|
||||
Target::Linux
|
||||
@@ -360,14 +367,15 @@ pub fn context_codegen(data: ContextData) -> Result<TokenStream, EmbeddedAssetsE
|
||||
|
||||
let pattern = match &options.pattern {
|
||||
PatternKind::Brownfield => quote!(#root::Pattern::Brownfield(std::marker::PhantomData)),
|
||||
#[cfg(not(feature = "isolation"))]
|
||||
PatternKind::Isolation { dir: _ } => {
|
||||
quote!(#root::Pattern::Brownfield(std::marker::PhantomData))
|
||||
}
|
||||
#[cfg(feature = "isolation")]
|
||||
PatternKind::Isolation { dir } => {
|
||||
let dir = config_parent.join(dir);
|
||||
if !dir.exists() {
|
||||
panic!(
|
||||
"The isolation application path is set to `{:?}` but it does not exist",
|
||||
dir
|
||||
)
|
||||
panic!("The isolation application path is set to `{dir:?}` but it does not exist")
|
||||
}
|
||||
|
||||
let mut sets_isolation_hook = false;
|
||||
@@ -408,7 +416,7 @@ pub fn context_codegen(data: ContextData) -> Result<TokenStream, EmbeddedAssetsE
|
||||
let shell_scope_open = match &config.tauri.allowlist.shell.open {
|
||||
ShellAllowlistOpen::Flag(false) => quote!(::std::option::Option::None),
|
||||
ShellAllowlistOpen::Flag(true) => {
|
||||
quote!(::std::option::Option::Some(#root::regex::Regex::new("^https?://").unwrap()))
|
||||
quote!(::std::option::Option::Some(#root::regex::Regex::new(r#"^((mailto:\w+)|(tel:\w+)|(https?://\w+)).+"#).unwrap()))
|
||||
}
|
||||
ShellAllowlistOpen::Validate(regex) => match Regex::new(regex) {
|
||||
Ok(_) => quote!(::std::option::Option::Some(#root::regex::Regex::new(#regex).unwrap())),
|
||||
@@ -451,7 +459,7 @@ fn ico_icon<P: AsRef<Path>>(
|
||||
path: P,
|
||||
) -> Result<TokenStream, EmbeddedAssetsError> {
|
||||
let path = path.as_ref();
|
||||
let bytes = std::fs::read(&path)
|
||||
let bytes = std::fs::read(path)
|
||||
.unwrap_or_else(|e| panic!("failed to read icon {}: {}", path.display(), e))
|
||||
.to_vec();
|
||||
let icon_dir = ico::IconDir::read(std::io::Cursor::new(bytes))
|
||||
@@ -479,7 +487,7 @@ fn ico_icon<P: AsRef<Path>>(
|
||||
|
||||
fn raw_icon<P: AsRef<Path>>(out_dir: &Path, path: P) -> Result<TokenStream, EmbeddedAssetsError> {
|
||||
let path = path.as_ref();
|
||||
let bytes = std::fs::read(&path)
|
||||
let bytes = std::fs::read(path)
|
||||
.unwrap_or_else(|e| panic!("failed to read icon {}: {}", path.display(), e))
|
||||
.to_vec();
|
||||
|
||||
@@ -501,7 +509,7 @@ fn png_icon<P: AsRef<Path>>(
|
||||
path: P,
|
||||
) -> Result<TokenStream, EmbeddedAssetsError> {
|
||||
let path = path.as_ref();
|
||||
let bytes = std::fs::read(&path)
|
||||
let bytes = std::fs::read(path)
|
||||
.unwrap_or_else(|e| panic!("failed to read icon {}: {}", path.display(), e))
|
||||
.to_vec();
|
||||
let decoder = png::Decoder::new(std::io::Cursor::new(bytes));
|
||||
@@ -531,13 +539,13 @@ fn write_if_changed(out_path: &Path, data: &[u8]) -> std::io::Result<()> {
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
|
||||
if let Ok(curr) = std::fs::read(&out_path) {
|
||||
if let Ok(curr) = std::fs::read(out_path) {
|
||||
if curr == data {
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
let mut out_file = File::create(&out_path)?;
|
||||
let mut out_file = File::create(out_path)?;
|
||||
out_file.write_all(data)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
use base64::Engine;
|
||||
use proc_macro2::TokenStream;
|
||||
use quote::{quote, ToTokens, TokenStreamExt};
|
||||
use sha2::{Digest, Sha256};
|
||||
@@ -181,9 +182,10 @@ impl CspHashes {
|
||||
})?,
|
||||
);
|
||||
let hash = hasher.finalize();
|
||||
self
|
||||
.scripts
|
||||
.push(format!("'sha256-{}'", base64::encode(hash)));
|
||||
self.scripts.push(format!(
|
||||
"'sha256-{}'",
|
||||
base64::engine::general_purpose::STANDARD.encode(hash)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,14 +345,14 @@ impl EmbeddedAssets {
|
||||
|
||||
let mut hex = String::with_capacity(2 * bytes.len());
|
||||
for b in bytes {
|
||||
write!(hex, "{:02x}", b).map_err(EmbeddedAssetsError::Hex)?;
|
||||
write!(hex, "{b:02x}").map_err(EmbeddedAssetsError::Hex)?;
|
||||
}
|
||||
hex
|
||||
};
|
||||
|
||||
// use the content hash to determine filename, keep extensions that exist
|
||||
let out_path = if let Some(ext) = path.extension().and_then(|e| e.to_str()) {
|
||||
out_dir.join(format!("{}.{}", hash, ext))
|
||||
out_dir.join(format!("{hash}.{ext}"))
|
||||
} else {
|
||||
out_dir.join(hash)
|
||||
};
|
||||
@@ -431,6 +433,7 @@ impl ToTokens for EmbeddedAssets {
|
||||
|
||||
// we expect phf related items to be in path when generating the path code
|
||||
tokens.append_all(quote! {{
|
||||
#[allow(unused)]
|
||||
use ::tauri::utils::assets::{CspHash, EmbeddedAssets, phf, phf::phf_map};
|
||||
EmbeddedAssets::new(phf_map! { #assets }, &[#global_hashes], phf_map! { #html_hashes })
|
||||
}});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
2
core/tauri-codegen/src/vendor/mod.rs
vendored
2
core/tauri-codegen/src/vendor/mod.rs
vendored
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
15
core/tauri-config-schema/Cargo.toml
Normal file
15
core/tauri-config-schema/Cargo.toml
Normal file
@@ -0,0 +1,15 @@
|
||||
[package]
|
||||
name = "tauri-tauri-config-schema"
|
||||
version = "0.0.0"
|
||||
edition = "2021"
|
||||
publish = false
|
||||
|
||||
[build-dependencies]
|
||||
tauri-utils = { version = "1.0.0", features = [
|
||||
"schema",
|
||||
], path = "../tauri-utils" }
|
||||
schemars = { version = "0.8", features = ["url", "preserve_order"] }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
serde_with = "1.12"
|
||||
url = { version = "2.3", features = ["serde"] }
|
||||
25
core/tauri-config-schema/build.rs
Normal file
25
core/tauri-config-schema/build.rs
Normal file
@@ -0,0 +1,25 @@
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
use std::{
|
||||
error::Error,
|
||||
fs::File,
|
||||
io::{BufWriter, Write},
|
||||
path::PathBuf,
|
||||
};
|
||||
|
||||
pub fn main() -> Result<(), Box<dyn Error>> {
|
||||
let schema = schemars::schema_for!(tauri_utils::config::Config);
|
||||
let schema_str = serde_json::to_string_pretty(&schema).unwrap();
|
||||
let crate_dir = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR")?);
|
||||
for file in [
|
||||
crate_dir.join("schema.json"),
|
||||
crate_dir.join("../../tooling/cli/schema.json"),
|
||||
] {
|
||||
let mut schema_file = BufWriter::new(File::create(file)?);
|
||||
write!(schema_file, "{schema_str}")?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
3009
core/tauri-config-schema/schema.json
Normal file
3009
core/tauri-config-schema/schema.json
Normal file
File diff suppressed because it is too large
Load Diff
5
core/tauri-config-schema/src/main.rs
Normal file
5
core/tauri-config-schema/src/main.rs
Normal file
@@ -0,0 +1,5 @@
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
fn main() {}
|
||||
@@ -1,5 +1,26 @@
|
||||
# Changelog
|
||||
|
||||
## \[1.3.0]
|
||||
|
||||
- Bump minimum supported Rust version to 1.60.
|
||||
- [5fdc616d](https://www.github.com/tauri-apps/tauri/commit/5fdc616df9bea633810dcb814ac615911d77222c) feat: Use the zbus-backed of notify-rust ([#6332](https://www.github.com/tauri-apps/tauri/pull/6332)) on 2023-03-31
|
||||
|
||||
## \[1.2.1]
|
||||
|
||||
- Fix `allowlist > app > show/hide` always disabled when `allowlist > app > all: false`.
|
||||
- Bumped due to a bump in tauri-utils.
|
||||
- [bb251087](https://www.github.com/tauri-apps/tauri/commit/bb2510876d0bdff736d36bf3a465cdbe4ad2b90c) fix(core): extend allowlist with `app`'s allowlist, closes [#5650](https://www.github.com/tauri-apps/tauri/pull/5650) ([#5652](https://www.github.com/tauri-apps/tauri/pull/5652)) on 2022-11-18
|
||||
|
||||
## \[1.2.0]
|
||||
|
||||
- - [7d9aa398](https://www.github.com/tauri-apps/tauri/commit/7d9aa3987efce2d697179ffc33646d086c68030c) feat: bump MSRV to 1.59 ([#5296](https://www.github.com/tauri-apps/tauri/pull/5296)) on 2022-09-28
|
||||
|
||||
## \[1.1.1]
|
||||
|
||||
- Add missing allowlist config for `set_cursor_grab`, `set_cursor_visible`, `set_cursor_icon` and `set_cursor_position` APIs.
|
||||
- Bumped due to a bump in tauri-utils.
|
||||
- [c764408d](https://www.github.com/tauri-apps/tauri/commit/c764408da7fae123edd41115bda42fa75a4731d2) fix: Add missing allowlist config for cursor apis, closes [#5207](https://www.github.com/tauri-apps/tauri/pull/5207) ([#5211](https://www.github.com/tauri-apps/tauri/pull/5211)) on 2022-09-16
|
||||
|
||||
## \[1.1.0]
|
||||
|
||||
- Added support to configuration files in TOML format (Tauri.toml file).
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "tauri-macros"
|
||||
version = "1.1.0"
|
||||
version = "1.3.0"
|
||||
authors = [ "Tauri Programme within The Commons Conservancy" ]
|
||||
categories = [ "gui", "os", "filesystem", "web-programming" ]
|
||||
license = "Apache-2.0 OR MIT"
|
||||
@@ -8,7 +8,7 @@ homepage = "https://tauri.app"
|
||||
repository = "https://github.com/tauri-apps/tauri"
|
||||
description = "Macros for the tauri crate."
|
||||
edition = "2021"
|
||||
rust-version = "1.57"
|
||||
rust-version = "1.60"
|
||||
exclude = [ "CHANGELOG.md", "/target" ]
|
||||
readme = "README.md"
|
||||
|
||||
@@ -20,8 +20,8 @@ proc-macro2 = "1"
|
||||
quote = "1"
|
||||
syn = { version = "1", features = [ "full" ] }
|
||||
heck = "0.4"
|
||||
tauri-codegen = { version = "1.1.0", default-features = false, path = "../tauri-codegen" }
|
||||
tauri-utils = { version = "1.1.0", path = "../tauri-utils" }
|
||||
tauri-codegen = { version = "1.3.0", default-features = false, path = "../tauri-codegen" }
|
||||
tauri-utils = { version = "1.3.0", path = "../tauri-utils" }
|
||||
|
||||
[features]
|
||||
custom-protocol = [ ]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,40 +1,83 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
use heck::{ToLowerCamelCase, ToSnakeCase};
|
||||
use proc_macro::TokenStream;
|
||||
use proc_macro2::TokenStream as TokenStream2;
|
||||
use quote::{format_ident, quote};
|
||||
use syn::{
|
||||
ext::IdentExt,
|
||||
parse::{Parse, ParseBuffer},
|
||||
parse::{Parse, ParseStream},
|
||||
parse_macro_input,
|
||||
spanned::Spanned,
|
||||
FnArg, Ident, ItemFn, Pat, Token, Visibility,
|
||||
FnArg, Ident, ItemFn, Lit, Meta, Pat, Token, Visibility,
|
||||
};
|
||||
|
||||
struct WrapperAttributes {
|
||||
execution_context: ExecutionContext,
|
||||
argument_case: ArgumentCase,
|
||||
}
|
||||
|
||||
impl Parse for WrapperAttributes {
|
||||
fn parse(input: ParseStream) -> syn::Result<Self> {
|
||||
let mut wrapper_attributes = WrapperAttributes {
|
||||
execution_context: ExecutionContext::Blocking,
|
||||
argument_case: ArgumentCase::Camel,
|
||||
};
|
||||
|
||||
loop {
|
||||
match input.parse::<Meta>() {
|
||||
Ok(Meta::List(_)) => {}
|
||||
Ok(Meta::NameValue(v)) => {
|
||||
if v.path.is_ident("rename_all") {
|
||||
if let Lit::Str(s) = v.lit {
|
||||
wrapper_attributes.argument_case = match s.value().as_str() {
|
||||
"snake_case" => ArgumentCase::Snake,
|
||||
"camelCase" => ArgumentCase::Camel,
|
||||
_ => {
|
||||
return Err(syn::Error::new(
|
||||
s.span(),
|
||||
"expected \"camelCase\" or \"snake_case\"",
|
||||
))
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(Meta::Path(p)) => {
|
||||
if p.is_ident("async") {
|
||||
wrapper_attributes.execution_context = ExecutionContext::Async;
|
||||
} else {
|
||||
return Err(syn::Error::new(p.span(), "expected `async`"));
|
||||
}
|
||||
}
|
||||
Err(_e) => {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let lookahead = input.lookahead1();
|
||||
if lookahead.peek(Token![,]) {
|
||||
input.parse::<Token![,]>()?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(wrapper_attributes)
|
||||
}
|
||||
}
|
||||
|
||||
/// The execution context of the command.
|
||||
enum ExecutionContext {
|
||||
Async,
|
||||
Blocking,
|
||||
}
|
||||
|
||||
impl Parse for ExecutionContext {
|
||||
fn parse(input: &ParseBuffer<'_>) -> syn::Result<Self> {
|
||||
if input.is_empty() {
|
||||
return Ok(Self::Blocking);
|
||||
}
|
||||
|
||||
input
|
||||
.parse::<Token![async]>()
|
||||
.map(|_| Self::Async)
|
||||
.map_err(|_| {
|
||||
syn::Error::new(
|
||||
input.span(),
|
||||
"only a single item `async` is currently allowed",
|
||||
)
|
||||
})
|
||||
}
|
||||
/// The case of each argument name.
|
||||
#[derive(Copy, Clone)]
|
||||
enum ArgumentCase {
|
||||
Snake,
|
||||
Camel,
|
||||
}
|
||||
|
||||
/// The bindings we attach to `tauri::Invoke`.
|
||||
@@ -61,14 +104,16 @@ pub fn wrapper(attributes: TokenStream, item: TokenStream) -> TokenStream {
|
||||
};
|
||||
|
||||
// body to the command wrapper or a `compile_error!` of an error occurred while parsing it.
|
||||
let body = syn::parse::<ExecutionContext>(attributes)
|
||||
.map(|context| match function.sig.asyncness {
|
||||
Some(_) => ExecutionContext::Async,
|
||||
None => context,
|
||||
let body = syn::parse::<WrapperAttributes>(attributes)
|
||||
.map(|mut attrs| {
|
||||
if function.sig.asyncness.is_some() {
|
||||
attrs.execution_context = ExecutionContext::Async;
|
||||
}
|
||||
attrs
|
||||
})
|
||||
.and_then(|context| match context {
|
||||
ExecutionContext::Async => body_async(&function, &invoke),
|
||||
ExecutionContext::Blocking => body_blocking(&function, &invoke),
|
||||
.and_then(|attrs| match attrs.execution_context {
|
||||
ExecutionContext::Async => body_async(&function, &invoke, attrs.argument_case),
|
||||
ExecutionContext::Blocking => body_blocking(&function, &invoke, attrs.argument_case),
|
||||
})
|
||||
.unwrap_or_else(syn::Error::into_compile_error);
|
||||
|
||||
@@ -105,9 +150,9 @@ pub fn wrapper(attributes: TokenStream, item: TokenStream) -> TokenStream {
|
||||
/// See the [`tauri::command`] module for all the items and traits that make this possible.
|
||||
///
|
||||
/// [`tauri::command`]: https://docs.rs/tauri/*/tauri/runtime/index.html
|
||||
fn body_async(function: &ItemFn, invoke: &Invoke) -> syn::Result<TokenStream2> {
|
||||
fn body_async(function: &ItemFn, invoke: &Invoke, case: ArgumentCase) -> syn::Result<TokenStream2> {
|
||||
let Invoke { message, resolver } = invoke;
|
||||
parse_args(function, message).map(|args| {
|
||||
parse_args(function, message, case).map(|args| {
|
||||
quote! {
|
||||
#resolver.respond_async_serialized(async move {
|
||||
let result = $path(#(#args?),*);
|
||||
@@ -123,9 +168,13 @@ fn body_async(function: &ItemFn, invoke: &Invoke) -> syn::Result<TokenStream2> {
|
||||
/// See the [`tauri::command`] module for all the items and traits that make this possible.
|
||||
///
|
||||
/// [`tauri::command`]: https://docs.rs/tauri/*/tauri/runtime/index.html
|
||||
fn body_blocking(function: &ItemFn, invoke: &Invoke) -> syn::Result<TokenStream2> {
|
||||
fn body_blocking(
|
||||
function: &ItemFn,
|
||||
invoke: &Invoke,
|
||||
case: ArgumentCase,
|
||||
) -> syn::Result<TokenStream2> {
|
||||
let Invoke { message, resolver } = invoke;
|
||||
let args = parse_args(function, message)?;
|
||||
let args = parse_args(function, message, case)?;
|
||||
|
||||
// the body of a `match` to early return any argument that wasn't successful in parsing.
|
||||
let match_body = quote!({
|
||||
@@ -141,17 +190,26 @@ fn body_blocking(function: &ItemFn, invoke: &Invoke) -> syn::Result<TokenStream2
|
||||
}
|
||||
|
||||
/// Parse all arguments for the command wrapper to use from the signature of the command function.
|
||||
fn parse_args(function: &ItemFn, message: &Ident) -> syn::Result<Vec<TokenStream2>> {
|
||||
fn parse_args(
|
||||
function: &ItemFn,
|
||||
message: &Ident,
|
||||
case: ArgumentCase,
|
||||
) -> syn::Result<Vec<TokenStream2>> {
|
||||
function
|
||||
.sig
|
||||
.inputs
|
||||
.iter()
|
||||
.map(|arg| parse_arg(&function.sig.ident, arg, message))
|
||||
.map(|arg| parse_arg(&function.sig.ident, arg, message, case))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Transform a [`FnArg`] into a command argument.
|
||||
fn parse_arg(command: &Ident, arg: &FnArg, message: &Ident) -> syn::Result<TokenStream2> {
|
||||
fn parse_arg(
|
||||
command: &Ident,
|
||||
arg: &FnArg,
|
||||
message: &Ident,
|
||||
case: ArgumentCase,
|
||||
) -> syn::Result<TokenStream2> {
|
||||
// we have no use for self arguments
|
||||
let mut arg = match arg {
|
||||
FnArg::Typed(arg) => arg.pat.as_ref().clone(),
|
||||
@@ -185,9 +243,13 @@ fn parse_arg(command: &Ident, arg: &FnArg, message: &Ident) -> syn::Result<Token
|
||||
));
|
||||
}
|
||||
|
||||
// snake_case -> camelCase
|
||||
if key.as_str().contains('_') {
|
||||
key = snake_case_to_camel_case(key.as_str());
|
||||
match case {
|
||||
ArgumentCase::Camel => {
|
||||
key = key.to_lower_camel_case();
|
||||
}
|
||||
ArgumentCase::Snake => {
|
||||
key = key.to_snake_case();
|
||||
}
|
||||
}
|
||||
|
||||
Ok(quote!(::tauri::command::CommandArg::from_command(
|
||||
@@ -198,19 +260,3 @@ fn parse_arg(command: &Ident, arg: &FnArg, message: &Ident) -> syn::Result<Token
|
||||
}
|
||||
)))
|
||||
}
|
||||
|
||||
/// Convert a snake_case string into camelCase, no underscores will be left.
|
||||
fn snake_case_to_camel_case(key: &str) -> String {
|
||||
let mut camel = String::with_capacity(key.len());
|
||||
let mut to_upper = false;
|
||||
|
||||
for c in key.chars() {
|
||||
match c {
|
||||
'_' => to_upper = true,
|
||||
c if std::mem::take(&mut to_upper) => camel.push(c.to_ascii_uppercase()),
|
||||
c => camel.push(c),
|
||||
}
|
||||
}
|
||||
|
||||
camel
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,5 +1,87 @@
|
||||
# Changelog
|
||||
|
||||
## \[0.13.0]
|
||||
|
||||
- Added the `additional_browser_args` option when creating a window.
|
||||
- [3dc38b15](https://www.github.com/tauri-apps/tauri/commit/3dc38b150ea8c59c8ba67fd586f921016928f47c) feat(core): expose additional_browser_args to window config (fix: [#5757](https://www.github.com/tauri-apps/tauri/pull/5757)) ([#5799](https://www.github.com/tauri-apps/tauri/pull/5799)) on 2022-12-14
|
||||
- Added the `content_protected` option when creating a window and `Window::set_content_protected` to change it at runtime.
|
||||
- [4ab5545b](https://www.github.com/tauri-apps/tauri/commit/4ab5545b7a831c549f3c65e74de487ede3ab7ce5) feat: add content protection api, closes [#5132](https://www.github.com/tauri-apps/tauri/pull/5132) ([#5513](https://www.github.com/tauri-apps/tauri/pull/5513)) on 2022-12-13
|
||||
- Added `Builder::device_event_filter` and `App::set_device_event_filter` methods.
|
||||
- [73fd60ee](https://www.github.com/tauri-apps/tauri/commit/73fd60eef2b60f5dc84525ef9c315f4d80c4414f) expose set_device_event_filter in tauri ([#5562](https://www.github.com/tauri-apps/tauri/pull/5562)) on 2022-12-13
|
||||
- Fixes tray events not being delivered.
|
||||
- [138cb8d7](https://www.github.com/tauri-apps/tauri/commit/138cb8d739b15bccdb388e555c20f17ffe16318c) fix(tauri-runtime-wry): tray event listener not registered ([#6270](https://www.github.com/tauri-apps/tauri/pull/6270)) on 2023-02-14
|
||||
- Add `is_minimized()` window method.
|
||||
- [62144ef3](https://www.github.com/tauri-apps/tauri/commit/62144ef3be63b237869e511826edfb938e2c7174) feat: add is_minimized (fix [#3878](https://www.github.com/tauri-apps/tauri/pull/3878)) ([#5618](https://www.github.com/tauri-apps/tauri/pull/5618)) on 2022-12-13
|
||||
- Disable cursor mouse events on Linux.
|
||||
- [8c842a54](https://www.github.com/tauri-apps/tauri/commit/8c842a54a6f3dc5327b4d737df7123dcddaa5769) feature: disable mouse event when building windows on Linux, closes [#5913](https://www.github.com/tauri-apps/tauri/pull/5913) ([#6025](https://www.github.com/tauri-apps/tauri/pull/6025)) on 2023-01-16
|
||||
- Bump minimum supported Rust version to 1.60.
|
||||
- [5fdc616d](https://www.github.com/tauri-apps/tauri/commit/5fdc616df9bea633810dcb814ac615911d77222c) feat: Use the zbus-backed of notify-rust ([#6332](https://www.github.com/tauri-apps/tauri/pull/6332)) on 2023-03-31
|
||||
- Pin raw-window-handle to 0.5.0 to keep MSRV.
|
||||
- [c46c09f3](https://www.github.com/tauri-apps/tauri/commit/c46c09f31d9f5169ca8a7e62406a9ea170e3a5c5) fix(deps): pin raw-window-handle to 0.5.0 ([#6480](https://www.github.com/tauri-apps/tauri/pull/6480)) on 2023-03-17
|
||||
- Add `title` getter on window.
|
||||
- [233e43b0](https://www.github.com/tauri-apps/tauri/commit/233e43b0c34fada1ca025378533a0b76931a6540) feat: add `title` getter on window, closes [#5023](https://www.github.com/tauri-apps/tauri/pull/5023) ([#5515](https://www.github.com/tauri-apps/tauri/pull/5515)) on 2022-12-13
|
||||
- Added `TrayHandle::set_tooltip` and `SystemTray::with_tooltip`.
|
||||
- [2265e097](https://www.github.com/tauri-apps/tauri/commit/2265e09718f6ebfeb1d200f11e1e1e069075af6e) feat(windows): implement `with_tooltip` ([#5938](https://www.github.com/tauri-apps/tauri/pull/5938)) on 2023-01-01
|
||||
- Added window's `url()` getter.
|
||||
- [d17027e1](https://www.github.com/tauri-apps/tauri/commit/d17027e1a0db3e8c5ae81fc4f472c5918fbce611) feat: expose url method ([#5914](https://www.github.com/tauri-apps/tauri/pull/5914)) on 2022-12-26
|
||||
- On Windows, change webview theme based on Window theme for more accurate `prefers-color-scheme` support.
|
||||
- [7a8d570d](https://www.github.com/tauri-apps/tauri/commit/7a8d570db72667367eb24b75ddc5dd07a968f7c0) fix: sync webview theme with window theme on Windows, closes [#5802](https://www.github.com/tauri-apps/tauri/pull/5802) ([#5874](https://www.github.com/tauri-apps/tauri/pull/5874)) on 2022-12-27
|
||||
- On Windows, Fix missing `WindowEvent::Focused` in `App::run` callback.
|
||||
- [ff4ea1ea](https://www.github.com/tauri-apps/tauri/commit/ff4ea1eabbf2874b113c6b4698002929bbac737a) fix: dispatch focus event to app.run on Windows, closes [#6460](https://www.github.com/tauri-apps/tauri/pull/6460) ([#6504](https://www.github.com/tauri-apps/tauri/pull/6504)) on 2023-03-31
|
||||
- Implement the webview navigation handler.
|
||||
- [3f35b452](https://www.github.com/tauri-apps/tauri/commit/3f35b452637ef1c794a423f1eda62a15d2ddaf42) Expose wry navigation_handler via WindowBuilder closes [#4080](https://www.github.com/tauri-apps/tauri/pull/4080) ([#5686](https://www.github.com/tauri-apps/tauri/pull/5686)) on 2022-12-27
|
||||
|
||||
## \[0.12.2]
|
||||
|
||||
- Fix compatibility with older Linux distributions.
|
||||
- [b490308c](https://www.github.com/tauri-apps/tauri/commit/b490308c8897b893292951754607c2253abbc6e1) fix(core): compilation error on older Linux versions, fixes [#5684](https://www.github.com/tauri-apps/tauri/pull/5684) ([#5697](https://www.github.com/tauri-apps/tauri/pull/5697)) on 2022-11-28
|
||||
- Update wry to 0.23.
|
||||
- [fdcd7733](https://www.github.com/tauri-apps/tauri/commit/fdcd77338c1a3a7ef8a8ea1907351c5c350ea7ba) chore(deps): update wry to 0.23 on 2022-12-08
|
||||
|
||||
## \[0.12.1]
|
||||
|
||||
- Fix `allowlist > app > show/hide` always disabled when `allowlist > app > all: false`.
|
||||
- Bumped due to a bump in tauri-utils.
|
||||
- [bb251087](https://www.github.com/tauri-apps/tauri/commit/bb2510876d0bdff736d36bf3a465cdbe4ad2b90c) fix(core): extend allowlist with `app`'s allowlist, closes [#5650](https://www.github.com/tauri-apps/tauri/pull/5650) ([#5652](https://www.github.com/tauri-apps/tauri/pull/5652)) on 2022-11-18
|
||||
|
||||
## \[0.12.0]
|
||||
|
||||
- Add `accept_first_mouse` option for macOS windows.
|
||||
- [95f467ad](https://www.github.com/tauri-apps/tauri/commit/95f467add51448319983c54e2f382c7c09fb72d6) feat(core): add window `accept_first_mouse` option, closes [#5347](https://www.github.com/tauri-apps/tauri/pull/5347) ([#5374](https://www.github.com/tauri-apps/tauri/pull/5374)) on 2022-10-17
|
||||
- Disable automatic window tabbing on macOS when the `tabbing_identifier` option is not defined, the window is transparent or does not have decorations.
|
||||
- [4137ab44](https://www.github.com/tauri-apps/tauri/commit/4137ab44a81d739556cbc7583485887e78952bf1) feat(macos): add `tabbing_identifier` option, closes [#2804](https://www.github.com/tauri-apps/tauri/pull/2804), [#3912](https://www.github.com/tauri-apps/tauri/pull/3912) ([#5399](https://www.github.com/tauri-apps/tauri/pull/5399)) on 2022-10-19
|
||||
- Drop the WebContext when the WebView is dropped.
|
||||
- [9d8b3774](https://www.github.com/tauri-apps/tauri/commit/9d8b377481abf975dc37f9050d2ac7b63ce353e9) feat(tauri-runtime-wry): drop the WebContext on WebView drop ([#5240](https://www.github.com/tauri-apps/tauri/pull/5240)) on 2022-10-19
|
||||
- Readd the option to create an unfocused window via the `focused` method. The `focus` function has been deprecated.
|
||||
- [4036e15f](https://www.github.com/tauri-apps/tauri/commit/4036e15f5af933bdc0d0913508b5103958afc143) feat(core): reimplement window initial focus flag, closes [#5120](https://www.github.com/tauri-apps/tauri/pull/5120) ([#5338](https://www.github.com/tauri-apps/tauri/pull/5338)) on 2022-10-08
|
||||
- Add `hidden_title` option for macOS windows.
|
||||
- [321f3fed](https://www.github.com/tauri-apps/tauri/commit/321f3fed19df40c1223099bce953332b7f00f7a9) feat(macos): `title_bar_style` and `hidden_title` window options, closes [#2663](https://www.github.com/tauri-apps/tauri/pull/2663) ([#3965](https://www.github.com/tauri-apps/tauri/pull/3965)) on 2022-09-30
|
||||
- Custom protocol headers are now implemented on Linux when running on webkit2gtk 2.36 or above.
|
||||
- [357480f4](https://www.github.com/tauri-apps/tauri/commit/357480f4ae43aa8da99f7ba61ae2ee51b4552c60) feat(core): custom protocol headers on Linux, closes [#4496](https://www.github.com/tauri-apps/tauri/pull/4496) ([#5421](https://www.github.com/tauri-apps/tauri/pull/5421)) on 2022-10-17
|
||||
- Added `Runtime::show()`, `RuntimeHandle::show()`, `Runtime::hide()`, `RuntimeHandle::hide()` for hiding/showing the entire application on macOS.
|
||||
- [39bf895b](https://www.github.com/tauri-apps/tauri/commit/39bf895b73ec6b53f5758815396ba85dda6b9c67) feat(macOS): Add application `show` and `hide` methods ([#3689](https://www.github.com/tauri-apps/tauri/pull/3689)) on 2022-10-03
|
||||
- Fix regression in `SystemTray::with_menu_on_left_click`
|
||||
- [f8a3becb](https://www.github.com/tauri-apps/tauri/commit/f8a3becb287942db7f7b551b5db6aeb5a2e939ee) feat(core): add option to disable tray menu on left click, closes [#4584](https://www.github.com/tauri-apps/tauri/pull/4584) ([#4587](https://www.github.com/tauri-apps/tauri/pull/4587)) on 2022-07-05
|
||||
- [7bbf167c](https://www.github.com/tauri-apps/tauri/commit/7bbf167c1c84493ea6e2353f720edafd7daa47e4) Apply Version Updates From Current Changes ([#4560](https://www.github.com/tauri-apps/tauri/pull/4560)) on 2022-07-06
|
||||
- [63011ca8](https://www.github.com/tauri-apps/tauri/commit/63011ca84e7a22c8c0d8bd1c1be6592140f93ff2) fix(macos): fix regression in `with_menu_on_left_click`, closes [#5220](https://www.github.com/tauri-apps/tauri/pull/5220) ([#5235](https://www.github.com/tauri-apps/tauri/pull/5235)) on 2022-09-30
|
||||
- - [7d9aa398](https://www.github.com/tauri-apps/tauri/commit/7d9aa3987efce2d697179ffc33646d086c68030c) feat: bump MSRV to 1.59 ([#5296](https://www.github.com/tauri-apps/tauri/pull/5296)) on 2022-09-28
|
||||
- Added `tabbing_identifier` to the window builder on macOS.
|
||||
- [4137ab44](https://www.github.com/tauri-apps/tauri/commit/4137ab44a81d739556cbc7583485887e78952bf1) feat(macos): add `tabbing_identifier` option, closes [#2804](https://www.github.com/tauri-apps/tauri/pull/2804), [#3912](https://www.github.com/tauri-apps/tauri/pull/3912) ([#5399](https://www.github.com/tauri-apps/tauri/pull/5399)) on 2022-10-19
|
||||
- Add `title_bar_style` option for macOS windows.
|
||||
- [321f3fed](https://www.github.com/tauri-apps/tauri/commit/321f3fed19df40c1223099bce953332b7f00f7a9) feat(macos): `title_bar_style` and `hidden_title` window options, closes [#2663](https://www.github.com/tauri-apps/tauri/pull/2663) ([#3965](https://www.github.com/tauri-apps/tauri/pull/3965)) on 2022-09-30
|
||||
- Fix regression introduce in tauri@1.1 which prevented removing tray icon when the app exits on Windows.
|
||||
- [f756cd5e](https://www.github.com/tauri-apps/tauri/commit/f756cd5e7ecc86f178f8d602eded1e1b6ecb51f3) fix(core): wait for tray cleanup before exiting app, closes [#5244](https://www.github.com/tauri-apps/tauri/pull/5244) ([#5245](https://www.github.com/tauri-apps/tauri/pull/5245)) on 2022-10-04
|
||||
- Added methods to set the system tray title on macOS.
|
||||
- [8f1ace77](https://www.github.com/tauri-apps/tauri/commit/8f1ace77956ac3477826ceb059a191e55b3fff93) feat: expose `set_title` for MacOS tray ([#5182](https://www.github.com/tauri-apps/tauri/pull/5182)) on 2022-09-30
|
||||
- Added the `user_agent` option when creating a window.
|
||||
- [a6c94119](https://www.github.com/tauri-apps/tauri/commit/a6c94119d8545d509723b147c273ca5edfe3729f) feat(core): expose user_agent to window config ([#5317](https://www.github.com/tauri-apps/tauri/pull/5317)) on 2022-10-02
|
||||
|
||||
## \[0.11.1]
|
||||
|
||||
- Add missing allowlist config for `set_cursor_grab`, `set_cursor_visible`, `set_cursor_icon` and `set_cursor_position` APIs.
|
||||
- Bumped due to a bump in tauri-utils.
|
||||
- [c764408d](https://www.github.com/tauri-apps/tauri/commit/c764408da7fae123edd41115bda42fa75a4731d2) fix: Add missing allowlist config for cursor apis, closes [#5207](https://www.github.com/tauri-apps/tauri/pull/5207) ([#5211](https://www.github.com/tauri-apps/tauri/pull/5211)) on 2022-09-16
|
||||
|
||||
## \[0.11.0]
|
||||
|
||||
- Ignore window events with unknown IDs.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "tauri-runtime-wry"
|
||||
version = "0.11.0"
|
||||
version = "0.13.0"
|
||||
authors = [ "Tauri Programme within The Commons Conservancy" ]
|
||||
categories = [ "gui", "web-programming" ]
|
||||
license = "Apache-2.0 OR MIT"
|
||||
@@ -8,17 +8,17 @@ homepage = "https://tauri.app"
|
||||
repository = "https://github.com/tauri-apps/tauri"
|
||||
description = "Wry bindings to the Tauri runtime"
|
||||
edition = "2021"
|
||||
rust-version = "1.57"
|
||||
rust-version = "1.60"
|
||||
exclude = [ "CHANGELOG.md", "/target" ]
|
||||
readme = "README.md"
|
||||
|
||||
[dependencies]
|
||||
wry = { version = "0.21", default-features = false, features = [ "file-drop", "protocol" ] }
|
||||
tauri-runtime = { version = "0.11.0", path = "../tauri-runtime" }
|
||||
tauri-utils = { version = "1.1.0", path = "../tauri-utils" }
|
||||
wry = { version = "0.24.1", default-features = false, features = [ "file-drop", "protocol" ] }
|
||||
tauri-runtime = { version = "0.13.0", path = "../tauri-runtime" }
|
||||
tauri-utils = { version = "1.3.0", path = "../tauri-utils" }
|
||||
uuid = { version = "1", features = [ "v4" ] }
|
||||
rand = "0.8"
|
||||
raw-window-handle = "0.5"
|
||||
raw-window-handle = "=0.5.0"
|
||||
|
||||
[target."cfg(windows)".dependencies]
|
||||
webview2-com = "0.19.1"
|
||||
@@ -29,7 +29,7 @@ webview2-com = "0.19.1"
|
||||
|
||||
[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies]
|
||||
gtk = { version = "0.15", features = [ "v3_20" ] }
|
||||
webkit2gtk = { version = "0.18", features = [ "v2_22" ] }
|
||||
webkit2gtk = { version = "0.18.2", features = [ "v2_22" ] }
|
||||
percent-encoding = "2.1"
|
||||
|
||||
[target."cfg(any(target_os = \"ios\", target_os = \"macos\"))".dependencies]
|
||||
@@ -47,3 +47,4 @@ macos-private-api = [
|
||||
objc-exception = [ "wry/objc-exception" ]
|
||||
global-shortcut = [ "tauri-runtime/global-shortcut" ]
|
||||
clipboard = [ "tauri-runtime/clipboard" ]
|
||||
linux-headers = [ "wry/linux-headers", "webkit2gtk/v2_36" ]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// `alias` must be a snake case string.
|
||||
fn alias(alias: &str, has_feature: bool) {
|
||||
if has_feature {
|
||||
println!("cargo:rustc-cfg={}", alias);
|
||||
println!("cargo:rustc-cfg={alias}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -6,10 +6,7 @@
|
||||
|
||||
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle, RawDisplayHandle};
|
||||
use tauri_runtime::{
|
||||
http::{
|
||||
Request as HttpRequest, RequestParts as HttpRequestParts, Response as HttpResponse,
|
||||
ResponseParts as HttpResponseParts,
|
||||
},
|
||||
http::{header::CONTENT_TYPE, Request as HttpRequest, RequestParts, Response as HttpResponse},
|
||||
menu::{AboutMetadata, CustomMenuItem, Menu, MenuEntry, MenuHash, MenuId, MenuItem, MenuUpdate},
|
||||
monitor::Monitor,
|
||||
webview::{WebviewIpcHandler, WindowBuilder, WindowBuilderBase},
|
||||
@@ -17,8 +14,8 @@ use tauri_runtime::{
|
||||
dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize, Position, Size},
|
||||
CursorIcon, DetachedWindow, FileDropEvent, JsEventListenerKey, PendingWindow, WindowEvent,
|
||||
},
|
||||
Dispatch, Error, EventLoopProxy, ExitRequestedEventAction, Icon, Result, RunEvent, RunIteration,
|
||||
Runtime, RuntimeHandle, UserAttentionType, UserEvent,
|
||||
DeviceEventFilter, Dispatch, Error, EventLoopProxy, ExitRequestedEventAction, Icon, Result,
|
||||
RunEvent, RunIteration, Runtime, RuntimeHandle, UserAttentionType, UserEvent,
|
||||
};
|
||||
|
||||
use tauri_runtime::window::MenuEvent;
|
||||
@@ -29,12 +26,18 @@ use webview2_com::FocusChangedEventHandler;
|
||||
#[cfg(windows)]
|
||||
use windows::Win32::{Foundation::HWND, System::WinRT::EventRegistrationToken};
|
||||
#[cfg(target_os = "macos")]
|
||||
use wry::application::platform::macos::EventLoopWindowTargetExtMacOS;
|
||||
#[cfg(target_os = "macos")]
|
||||
use wry::application::platform::macos::WindowBuilderExtMacOS;
|
||||
#[cfg(target_os = "linux")]
|
||||
use wry::application::platform::unix::{WindowBuilderExtUnix, WindowExtUnix};
|
||||
#[cfg(windows)]
|
||||
use wry::application::platform::windows::{WindowBuilderExtWindows, WindowExtWindows};
|
||||
#[cfg(windows)]
|
||||
use wry::webview::WebViewBuilderExtWindows;
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
use tauri_utils::TitleBarStyle;
|
||||
use tauri_utils::{config::WindowConfig, debug_eprintln, Theme};
|
||||
use uuid::Uuid;
|
||||
use wry::{
|
||||
@@ -46,7 +49,8 @@ use wry::{
|
||||
},
|
||||
event::{Event, StartCause, WindowEvent as WryWindowEvent},
|
||||
event_loop::{
|
||||
ControlFlow, EventLoop, EventLoopProxy as WryEventLoopProxy, EventLoopWindowTarget,
|
||||
ControlFlow, DeviceEventFilter as WryDeviceEventFilter, EventLoop,
|
||||
EventLoopProxy as WryEventLoopProxy, EventLoopWindowTarget,
|
||||
},
|
||||
menu::{
|
||||
AboutMetadata as WryAboutMetadata, CustomMenuItem as WryCustomMenuItem, MenuBar,
|
||||
@@ -59,14 +63,10 @@ use wry::{
|
||||
UserAttentionType as WryUserAttentionType,
|
||||
},
|
||||
},
|
||||
http::{
|
||||
Request as WryHttpRequest, RequestParts as WryRequestParts, Response as WryHttpResponse,
|
||||
ResponseParts as WryResponseParts,
|
||||
},
|
||||
webview::{FileDropEvent as WryFileDropEvent, WebContext, WebView, WebViewBuilder},
|
||||
http::{Request as WryRequest, Response as WryResponse},
|
||||
webview::{FileDropEvent as WryFileDropEvent, Url, WebContext, WebView, WebViewBuilder},
|
||||
};
|
||||
|
||||
pub use wry;
|
||||
pub use wry::application::window::{Window, WindowBuilder as WryWindowBuilder, WindowId};
|
||||
|
||||
#[cfg(windows)]
|
||||
@@ -81,6 +81,7 @@ pub use wry::application::platform::macos::{
|
||||
};
|
||||
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
cell::RefCell,
|
||||
collections::{
|
||||
hash_map::Entry::{Occupied, Vacant},
|
||||
@@ -160,7 +161,10 @@ macro_rules! window_getter {
|
||||
}};
|
||||
}
|
||||
|
||||
fn send_user_message<T: UserEvent>(context: &Context<T>, message: Message<T>) -> Result<()> {
|
||||
pub(crate) fn send_user_message<T: UserEvent>(
|
||||
context: &Context<T>,
|
||||
message: Message<T>,
|
||||
) -> Result<()> {
|
||||
if current_thread().id() == context.main_thread_id {
|
||||
handle_user_message(
|
||||
&context.main_thread.window_target,
|
||||
@@ -210,6 +214,7 @@ impl<T: UserEvent> Context<T> {
|
||||
impl<T: UserEvent> Context<T> {
|
||||
fn create_webview(&self, pending: PendingWindow<T, Wry<T>>) -> Result<DetachedWindow<T, Wry<T>>> {
|
||||
let label = pending.label.clone();
|
||||
let current_url = pending.current_url.clone();
|
||||
let menu_ids = pending.menu_ids.clone();
|
||||
let js_event_listeners = pending.js_event_listeners.clone();
|
||||
let context = self.clone();
|
||||
@@ -231,6 +236,7 @@ impl<T: UserEvent> Context<T> {
|
||||
};
|
||||
Ok(DetachedWindow {
|
||||
label,
|
||||
current_url,
|
||||
dispatcher,
|
||||
menu_ids,
|
||||
js_event_listeners,
|
||||
@@ -269,70 +275,36 @@ impl<T: UserEvent> fmt::Debug for Context<T> {
|
||||
}
|
||||
}
|
||||
|
||||
struct HttpRequestPartsWrapper(HttpRequestParts);
|
||||
|
||||
impl From<HttpRequestPartsWrapper> for HttpRequestParts {
|
||||
fn from(parts: HttpRequestPartsWrapper) -> Self {
|
||||
Self {
|
||||
method: parts.0.method,
|
||||
uri: parts.0.uri,
|
||||
headers: parts.0.headers,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<HttpRequestParts> for HttpRequestPartsWrapper {
|
||||
fn from(request: HttpRequestParts) -> Self {
|
||||
Self(HttpRequestParts {
|
||||
method: request.method,
|
||||
uri: request.uri,
|
||||
headers: request.headers,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl From<WryRequestParts> for HttpRequestPartsWrapper {
|
||||
fn from(request: WryRequestParts) -> Self {
|
||||
Self(HttpRequestParts {
|
||||
method: request.method,
|
||||
uri: request.uri,
|
||||
headers: request.headers,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
struct HttpRequestWrapper(HttpRequest);
|
||||
|
||||
impl From<&WryHttpRequest> for HttpRequestWrapper {
|
||||
fn from(req: &WryHttpRequest) -> Self {
|
||||
Self(HttpRequest::new_internal(
|
||||
HttpRequestPartsWrapper::from(req.head.clone()).0,
|
||||
req.body.clone(),
|
||||
))
|
||||
impl From<&WryRequest<Vec<u8>>> for HttpRequestWrapper {
|
||||
fn from(req: &WryRequest<Vec<u8>>) -> Self {
|
||||
let parts = RequestParts {
|
||||
uri: req.uri().to_string(),
|
||||
method: req.method().clone(),
|
||||
headers: req.headers().clone(),
|
||||
};
|
||||
Self(HttpRequest::new_internal(parts, req.body().clone()))
|
||||
}
|
||||
}
|
||||
|
||||
// response
|
||||
struct HttpResponsePartsWrapper(WryResponseParts);
|
||||
impl From<HttpResponseParts> for HttpResponsePartsWrapper {
|
||||
fn from(response: HttpResponseParts) -> Self {
|
||||
Self(WryResponseParts {
|
||||
mimetype: response.mimetype,
|
||||
status: response.status,
|
||||
version: response.version,
|
||||
headers: response.headers,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
struct HttpResponseWrapper(WryHttpResponse);
|
||||
struct HttpResponseWrapper(WryResponse<Cow<'static, [u8]>>);
|
||||
impl From<HttpResponse> for HttpResponseWrapper {
|
||||
fn from(response: HttpResponse) -> Self {
|
||||
let (parts, body) = response.into_parts();
|
||||
Self(WryHttpResponse {
|
||||
body,
|
||||
head: HttpResponsePartsWrapper::from(parts).0,
|
||||
})
|
||||
let mut res_builder = WryResponse::builder()
|
||||
.status(parts.status)
|
||||
.version(parts.version);
|
||||
if let Some(mime) = parts.mimetype {
|
||||
res_builder = res_builder.header(CONTENT_TYPE, mime);
|
||||
}
|
||||
for (name, val) in parts.headers.iter() {
|
||||
res_builder = res_builder.header(name, val);
|
||||
}
|
||||
|
||||
let res = res_builder.body(Cow::Owned(body)).unwrap();
|
||||
Self(res)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,6 +369,18 @@ impl From<MenuItem> for MenuItemWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct DeviceEventFilterWrapper(pub WryDeviceEventFilter);
|
||||
|
||||
impl From<DeviceEventFilter> for DeviceEventFilterWrapper {
|
||||
fn from(item: DeviceEventFilter) -> Self {
|
||||
match item {
|
||||
DeviceEventFilter::Always => Self(WryDeviceEventFilter::Always),
|
||||
DeviceEventFilter::Never => Self(WryDeviceEventFilter::Never),
|
||||
DeviceEventFilter::Unfocused => Self(WryDeviceEventFilter::Unfocused),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
pub struct NativeImageWrapper(pub WryNativeImage);
|
||||
|
||||
@@ -713,6 +697,8 @@ impl From<CursorIcon> for CursorIconWrapper {
|
||||
pub struct WindowBuilderWrapper {
|
||||
inner: WryWindowBuilder,
|
||||
center: bool,
|
||||
#[cfg(target_os = "macos")]
|
||||
tabbing_identifier: Option<String>,
|
||||
menu: Option<Menu>,
|
||||
}
|
||||
|
||||
@@ -723,7 +709,7 @@ unsafe impl Send for WindowBuilderWrapper {}
|
||||
impl WindowBuilderBase for WindowBuilderWrapper {}
|
||||
impl WindowBuilder for WindowBuilderWrapper {
|
||||
fn new() -> Self {
|
||||
Default::default()
|
||||
Self::default().focused(true)
|
||||
}
|
||||
|
||||
fn with_config(config: WindowConfig) -> Self {
|
||||
@@ -736,9 +722,20 @@ impl WindowBuilder for WindowBuilderWrapper {
|
||||
.decorations(config.decorations)
|
||||
.maximized(config.maximized)
|
||||
.always_on_top(config.always_on_top)
|
||||
.content_protected(config.content_protected)
|
||||
.skip_taskbar(config.skip_taskbar)
|
||||
.theme(config.theme);
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
window = window
|
||||
.hidden_title(config.hidden_title)
|
||||
.title_bar_style(config.title_bar_style);
|
||||
if let Some(identifier) = &config.tabbing_identifier {
|
||||
window = window.tabbing_identifier(identifier);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(not(target_os = "macos"), feature = "macos-private-api"))]
|
||||
{
|
||||
window = window.transparent(config.transparent);
|
||||
@@ -755,6 +752,12 @@ impl WindowBuilder for WindowBuilderWrapper {
|
||||
");
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
// Mouse event is disabled on Linux since sudden event bursts could block event loop.
|
||||
window.inner = window.inner.with_cursor_moved_event(false);
|
||||
}
|
||||
|
||||
if let (Some(min_width), Some(min_height)) = (config.min_width, config.min_height) {
|
||||
window = window.min_inner_size(min_width, min_height);
|
||||
}
|
||||
@@ -829,9 +832,8 @@ impl WindowBuilder for WindowBuilderWrapper {
|
||||
self
|
||||
}
|
||||
|
||||
/// Deprecated since 0.1.4 (noop)
|
||||
/// Windows is automatically focused when created.
|
||||
fn focus(self) -> Self {
|
||||
fn focused(mut self, focused: bool) -> Self {
|
||||
self.inner = self.inner.with_focused(focused);
|
||||
self
|
||||
}
|
||||
|
||||
@@ -861,6 +863,11 @@ impl WindowBuilder for WindowBuilderWrapper {
|
||||
self
|
||||
}
|
||||
|
||||
fn content_protected(mut self, protected: bool) -> Self {
|
||||
self.inner = self.inner.with_content_protection(protected);
|
||||
self
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn parent_window(mut self, parent: HWND) -> Self {
|
||||
self.inner = self.inner.with_parent_window(parent);
|
||||
@@ -879,6 +886,39 @@ impl WindowBuilder for WindowBuilderWrapper {
|
||||
self
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn title_bar_style(mut self, style: TitleBarStyle) -> Self {
|
||||
match style {
|
||||
TitleBarStyle::Visible => {
|
||||
self.inner = self.inner.with_titlebar_transparent(false);
|
||||
// Fixes rendering issue when resizing window with devtools open (https://github.com/tauri-apps/tauri/issues/3914)
|
||||
self.inner = self.inner.with_fullsize_content_view(true);
|
||||
}
|
||||
TitleBarStyle::Transparent => {
|
||||
self.inner = self.inner.with_titlebar_transparent(true);
|
||||
self.inner = self.inner.with_fullsize_content_view(false);
|
||||
}
|
||||
TitleBarStyle::Overlay => {
|
||||
self.inner = self.inner.with_titlebar_transparent(true);
|
||||
self.inner = self.inner.with_fullsize_content_view(true);
|
||||
}
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn hidden_title(mut self, hidden: bool) -> Self {
|
||||
self.inner = self.inner.with_title_hidden(hidden);
|
||||
self
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn tabbing_identifier(mut self, identifier: &str) -> Self {
|
||||
self.inner = self.inner.with_tabbing_identifier(identifier);
|
||||
self.tabbing_identifier.replace(identifier.into());
|
||||
self
|
||||
}
|
||||
|
||||
fn icon(mut self, icon: Icon) -> Result<Self> {
|
||||
self.inner = self
|
||||
.inner
|
||||
@@ -986,6 +1026,13 @@ unsafe impl Send for GtkWindow {}
|
||||
pub struct RawWindowHandle(pub raw_window_handle::RawWindowHandle);
|
||||
unsafe impl Send for RawWindowHandle {}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum ApplicationMessage {
|
||||
Show,
|
||||
Hide,
|
||||
}
|
||||
|
||||
pub enum WindowMessage {
|
||||
#[cfg(desktop)]
|
||||
WithWebview(Box<dyn FnOnce(Webview) + Send>),
|
||||
@@ -999,16 +1046,19 @@ pub enum WindowMessage {
|
||||
#[cfg(any(debug_assertions, feature = "devtools"))]
|
||||
IsDevToolsOpen(Sender<bool>),
|
||||
// Getters
|
||||
Url(Sender<Url>),
|
||||
ScaleFactor(Sender<f64>),
|
||||
InnerPosition(Sender<Result<PhysicalPosition<i32>>>),
|
||||
OuterPosition(Sender<Result<PhysicalPosition<i32>>>),
|
||||
InnerSize(Sender<PhysicalSize<u32>>),
|
||||
OuterSize(Sender<PhysicalSize<u32>>),
|
||||
IsFullscreen(Sender<bool>),
|
||||
IsMinimized(Sender<bool>),
|
||||
IsMaximized(Sender<bool>),
|
||||
IsDecorated(Sender<bool>),
|
||||
IsResizable(Sender<bool>),
|
||||
IsVisible(Sender<bool>),
|
||||
Title(Sender<String>),
|
||||
IsMenuVisible(Sender<bool>),
|
||||
CurrentMonitor(Sender<Option<MonitorHandle>>),
|
||||
PrimaryMonitor(Sender<Option<MonitorHandle>>),
|
||||
@@ -1039,6 +1089,7 @@ pub enum WindowMessage {
|
||||
Close,
|
||||
SetDecorations(bool),
|
||||
SetAlwaysOnTop(bool),
|
||||
SetContentProtected(bool),
|
||||
SetSize(Size),
|
||||
SetMinSize(Option<Size>),
|
||||
SetMaxSize(Option<Size>),
|
||||
@@ -1051,6 +1102,7 @@ pub enum WindowMessage {
|
||||
SetCursorVisible(bool),
|
||||
SetCursorIcon(CursorIcon),
|
||||
SetCursorPosition(Position),
|
||||
SetIgnoreCursorEvents(bool),
|
||||
DragWindow,
|
||||
UpdateMenuItem(u16, MenuUpdate),
|
||||
RequestRedraw,
|
||||
@@ -1078,8 +1130,11 @@ pub enum TrayMessage {
|
||||
UpdateIcon(Icon),
|
||||
#[cfg(target_os = "macos")]
|
||||
UpdateIconAsTemplate(bool),
|
||||
#[cfg(target_os = "macos")]
|
||||
UpdateTitle(String),
|
||||
UpdateTooltip(String),
|
||||
Create(SystemTray, Sender<Result<()>>),
|
||||
Destroy,
|
||||
Destroy(Sender<Result<()>>),
|
||||
}
|
||||
|
||||
pub type CreateWebviewClosure<T> = Box<
|
||||
@@ -1088,6 +1143,8 @@ pub type CreateWebviewClosure<T> = Box<
|
||||
|
||||
pub enum Message<T: 'static> {
|
||||
Task(Box<dyn FnOnce() + Send>),
|
||||
#[cfg(target_os = "macos")]
|
||||
Application(ApplicationMessage),
|
||||
Window(WebviewId, WindowMessage),
|
||||
Webview(WebviewId, WebviewMessage),
|
||||
#[cfg(all(desktop, feature = "system-tray"))]
|
||||
@@ -1192,6 +1249,10 @@ impl<T: UserEvent> Dispatch<T> for WryDispatcher<T> {
|
||||
|
||||
// Getters
|
||||
|
||||
fn url(&self) -> Result<Url> {
|
||||
window_getter!(self, WindowMessage::Url)
|
||||
}
|
||||
|
||||
fn scale_factor(&self) -> Result<f64> {
|
||||
window_getter!(self, WindowMessage::ScaleFactor)
|
||||
}
|
||||
@@ -1216,6 +1277,10 @@ impl<T: UserEvent> Dispatch<T> for WryDispatcher<T> {
|
||||
window_getter!(self, WindowMessage::IsFullscreen)
|
||||
}
|
||||
|
||||
fn is_minimized(&self) -> Result<bool> {
|
||||
window_getter!(self, WindowMessage::IsMinimized)
|
||||
}
|
||||
|
||||
fn is_maximized(&self) -> Result<bool> {
|
||||
window_getter!(self, WindowMessage::IsMaximized)
|
||||
}
|
||||
@@ -1234,6 +1299,10 @@ impl<T: UserEvent> Dispatch<T> for WryDispatcher<T> {
|
||||
window_getter!(self, WindowMessage::IsVisible)
|
||||
}
|
||||
|
||||
fn title(&self) -> Result<String> {
|
||||
window_getter!(self, WindowMessage::Title)
|
||||
}
|
||||
|
||||
fn is_menu_visible(&self) -> Result<bool> {
|
||||
window_getter!(self, WindowMessage::IsMenuVisible)
|
||||
}
|
||||
@@ -1403,6 +1472,16 @@ impl<T: UserEvent> Dispatch<T> for WryDispatcher<T> {
|
||||
)
|
||||
}
|
||||
|
||||
fn set_content_protected(&self, protected: bool) -> Result<()> {
|
||||
send_user_message(
|
||||
&self.context,
|
||||
Message::Window(
|
||||
self.window_id,
|
||||
WindowMessage::SetContentProtected(protected),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
fn set_size(&self, size: Size) -> Result<()> {
|
||||
send_user_message(
|
||||
&self.context,
|
||||
@@ -1493,6 +1572,13 @@ impl<T: UserEvent> Dispatch<T> for WryDispatcher<T> {
|
||||
)
|
||||
}
|
||||
|
||||
fn set_ignore_cursor_events(&self, ignore: bool) -> crate::Result<()> {
|
||||
send_user_message(
|
||||
&self.context,
|
||||
Message::Window(self.window_id, WindowMessage::SetIgnoreCursorEvents(ignore)),
|
||||
)
|
||||
}
|
||||
|
||||
fn start_dragging(&self) -> Result<()> {
|
||||
send_user_message(
|
||||
&self.context,
|
||||
@@ -1520,10 +1606,30 @@ impl<T: UserEvent> Dispatch<T> for WryDispatcher<T> {
|
||||
|
||||
#[derive(Clone)]
|
||||
enum WindowHandle {
|
||||
Webview(Arc<WebView>),
|
||||
Webview {
|
||||
inner: Arc<WebView>,
|
||||
context_store: WebContextStore,
|
||||
// the key of the WebContext if it's not shared
|
||||
context_key: Option<PathBuf>,
|
||||
},
|
||||
Window(Arc<Window>),
|
||||
}
|
||||
|
||||
impl Drop for WindowHandle {
|
||||
fn drop(&mut self) {
|
||||
if let Self::Webview {
|
||||
inner,
|
||||
context_store,
|
||||
context_key,
|
||||
} = self
|
||||
{
|
||||
if Arc::get_mut(inner).is_some() {
|
||||
context_store.lock().unwrap().remove(context_key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for WindowHandle {
|
||||
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
Ok(())
|
||||
@@ -1536,7 +1642,7 @@ impl Deref for WindowHandle {
|
||||
#[inline(always)]
|
||||
fn deref(&self) -> &Window {
|
||||
match self {
|
||||
Self::Webview(w) => w.window(),
|
||||
Self::Webview { inner, .. } => inner.window(),
|
||||
Self::Window(w) => w,
|
||||
}
|
||||
}
|
||||
@@ -1546,7 +1652,7 @@ impl WindowHandle {
|
||||
fn inner_size(&self) -> WryPhysicalSize<u32> {
|
||||
match self {
|
||||
WindowHandle::Window(w) => w.inner_size(),
|
||||
WindowHandle::Webview(w) => w.inner_size(),
|
||||
WindowHandle::Webview { inner, .. } => inner.inner_size(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1733,6 +1839,7 @@ impl<T: UserEvent> RuntimeHandle<T> for WryHandle<T> {
|
||||
)?;
|
||||
rx.recv().unwrap()?;
|
||||
Ok(SystemTrayHandle {
|
||||
context: self.context.clone(),
|
||||
id,
|
||||
proxy: self.context.proxy.clone(),
|
||||
})
|
||||
@@ -1741,6 +1848,22 @@ impl<T: UserEvent> RuntimeHandle<T> for WryHandle<T> {
|
||||
fn raw_display_handle(&self) -> RawDisplayHandle {
|
||||
self.context.main_thread.window_target.raw_display_handle()
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn show(&self) -> tauri_runtime::Result<()> {
|
||||
send_user_message(
|
||||
&self.context,
|
||||
Message::Application(ApplicationMessage::Show),
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn hide(&self) -> tauri_runtime::Result<()> {
|
||||
send_user_message(
|
||||
&self.context,
|
||||
Message::Application(ApplicationMessage::Hide),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: UserEvent> Wry<T> {
|
||||
@@ -1864,6 +1987,7 @@ impl<T: UserEvent> Runtime<T> for Wry<T> {
|
||||
|
||||
fn create_window(&self, pending: PendingWindow<T, Self>) -> Result<DetachedWindow<T, Self>> {
|
||||
let label = pending.label.clone();
|
||||
let current_url = pending.current_url.clone();
|
||||
let menu_ids = pending.menu_ids.clone();
|
||||
let js_event_listeners = pending.js_event_listeners.clone();
|
||||
let window_id = rand::random();
|
||||
@@ -1890,6 +2014,7 @@ impl<T: UserEvent> Runtime<T> for Wry<T> {
|
||||
|
||||
Ok(DetachedWindow {
|
||||
label,
|
||||
current_url,
|
||||
dispatcher,
|
||||
menu_ids,
|
||||
js_event_listeners,
|
||||
@@ -1921,6 +2046,7 @@ impl<T: UserEvent> Runtime<T> for Wry<T> {
|
||||
);
|
||||
|
||||
Ok(SystemTrayHandle {
|
||||
context: self.context.clone(),
|
||||
id,
|
||||
proxy: self.event_loop.create_proxy(),
|
||||
})
|
||||
@@ -1950,6 +2076,22 @@ impl<T: UserEvent> Runtime<T> for Wry<T> {
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn show(&self) {
|
||||
self.event_loop.show_application();
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn hide(&self) {
|
||||
self.event_loop.hide_application();
|
||||
}
|
||||
|
||||
fn set_device_event_filter(&mut self, filter: DeviceEventFilter) {
|
||||
self
|
||||
.event_loop
|
||||
.set_device_event_filter(DeviceEventFilterWrapper::from(filter).0);
|
||||
}
|
||||
|
||||
#[cfg(desktop)]
|
||||
fn run_iteration<F: FnMut(RunEvent<T>) + 'static>(&mut self, mut callback: F) -> RunIteration {
|
||||
use wry::application::platform::run_return::EventLoopExtRunReturn;
|
||||
@@ -2140,6 +2282,15 @@ fn handle_user_message<T: UserEvent>(
|
||||
} = context;
|
||||
match message {
|
||||
Message::Task(task) => task(),
|
||||
#[cfg(target_os = "macos")]
|
||||
Message::Application(application_message) => match application_message {
|
||||
ApplicationMessage::Show => {
|
||||
event_loop.show_application();
|
||||
}
|
||||
ApplicationMessage::Hide => {
|
||||
event_loop.hide_application();
|
||||
}
|
||||
},
|
||||
Message::Window(id, window_message) => {
|
||||
if let WindowMessage::UpdateMenuItem(item_id, update) = window_message {
|
||||
if let Some(menu_items) = windows.borrow_mut().get_mut(&id).map(|w| &mut w.menu_items) {
|
||||
@@ -2168,7 +2319,7 @@ fn handle_user_message<T: UserEvent>(
|
||||
match window_message {
|
||||
#[cfg(desktop)]
|
||||
WindowMessage::WithWebview(f) => {
|
||||
if let WindowHandle::Webview(w) = window {
|
||||
if let WindowHandle::Webview { inner: w, .. } = &window {
|
||||
#[cfg(any(
|
||||
target_os = "linux",
|
||||
target_os = "dragonfly",
|
||||
@@ -2209,25 +2360,30 @@ fn handle_user_message<T: UserEvent>(
|
||||
|
||||
#[cfg(any(debug_assertions, feature = "devtools"))]
|
||||
WindowMessage::OpenDevTools => {
|
||||
if let WindowHandle::Webview(w) = &window {
|
||||
if let WindowHandle::Webview { inner: w, .. } = &window {
|
||||
w.open_devtools();
|
||||
}
|
||||
}
|
||||
#[cfg(any(debug_assertions, feature = "devtools"))]
|
||||
WindowMessage::CloseDevTools => {
|
||||
if let WindowHandle::Webview(w) = &window {
|
||||
if let WindowHandle::Webview { inner: w, .. } = &window {
|
||||
w.close_devtools();
|
||||
}
|
||||
}
|
||||
#[cfg(any(debug_assertions, feature = "devtools"))]
|
||||
WindowMessage::IsDevToolsOpen(tx) => {
|
||||
if let WindowHandle::Webview(w) = &window {
|
||||
if let WindowHandle::Webview { inner: w, .. } = &window {
|
||||
tx.send(w.is_devtools_open()).unwrap();
|
||||
} else {
|
||||
tx.send(false).unwrap();
|
||||
}
|
||||
}
|
||||
// Getters
|
||||
WindowMessage::Url(tx) => {
|
||||
if let WindowHandle::Webview { inner: w, .. } = &window {
|
||||
tx.send(w.url()).unwrap();
|
||||
}
|
||||
}
|
||||
WindowMessage::ScaleFactor(tx) => tx.send(window.scale_factor()).unwrap(),
|
||||
WindowMessage::InnerPosition(tx) => tx
|
||||
.send(
|
||||
@@ -2252,10 +2408,12 @@ fn handle_user_message<T: UserEvent>(
|
||||
.send(PhysicalSizeWrapper(window.outer_size()).into())
|
||||
.unwrap(),
|
||||
WindowMessage::IsFullscreen(tx) => tx.send(window.fullscreen().is_some()).unwrap(),
|
||||
WindowMessage::IsMinimized(tx) => tx.send(window.is_minimized()).unwrap(),
|
||||
WindowMessage::IsMaximized(tx) => tx.send(window.is_maximized()).unwrap(),
|
||||
WindowMessage::IsDecorated(tx) => tx.send(window.is_decorated()).unwrap(),
|
||||
WindowMessage::IsResizable(tx) => tx.send(window.is_resizable()).unwrap(),
|
||||
WindowMessage::IsVisible(tx) => tx.send(window.is_visible()).unwrap(),
|
||||
WindowMessage::Title(tx) => tx.send(window.title()).unwrap(),
|
||||
WindowMessage::IsMenuVisible(tx) => tx.send(window.is_menu_visible()).unwrap(),
|
||||
WindowMessage::CurrentMonitor(tx) => tx.send(window.current_monitor()).unwrap(),
|
||||
WindowMessage::PrimaryMonitor(tx) => tx.send(window.primary_monitor()).unwrap(),
|
||||
@@ -2300,6 +2458,9 @@ fn handle_user_message<T: UserEvent>(
|
||||
}
|
||||
WindowMessage::SetDecorations(decorations) => window.set_decorations(decorations),
|
||||
WindowMessage::SetAlwaysOnTop(always_on_top) => window.set_always_on_top(always_on_top),
|
||||
WindowMessage::SetContentProtected(protected) => {
|
||||
window.set_content_protection(protected)
|
||||
}
|
||||
WindowMessage::SetSize(size) => {
|
||||
window.set_inner_size(SizeWrapper::from(size).0);
|
||||
}
|
||||
@@ -2342,6 +2503,9 @@ fn handle_user_message<T: UserEvent>(
|
||||
WindowMessage::SetCursorPosition(position) => {
|
||||
let _ = window.set_cursor_position(PositionWrapper::from(position).0);
|
||||
}
|
||||
WindowMessage::SetIgnoreCursorEvents(ignore) => {
|
||||
let _ = window.set_ignore_cursor_events(ignore);
|
||||
}
|
||||
WindowMessage::DragWindow => {
|
||||
let _ = window.drag_window();
|
||||
}
|
||||
@@ -2357,7 +2521,7 @@ fn handle_user_message<T: UserEvent>(
|
||||
}
|
||||
Message::Webview(id, webview_message) => match webview_message {
|
||||
WebviewMessage::EvaluateScript(script) => {
|
||||
if let Some(WindowHandle::Webview(webview)) =
|
||||
if let Some(WindowHandle::Webview { inner: webview, .. }) =
|
||||
windows.borrow().get(&id).and_then(|w| w.inner.as_ref())
|
||||
{
|
||||
if let Err(e) = webview.evaluate_script(&script) {
|
||||
@@ -2366,27 +2530,13 @@ fn handle_user_message<T: UserEvent>(
|
||||
}
|
||||
}
|
||||
WebviewMessage::Print => {
|
||||
if let Some(WindowHandle::Webview(webview)) =
|
||||
if let Some(WindowHandle::Webview { inner: webview, .. }) =
|
||||
windows.borrow().get(&id).and_then(|w| w.inner.as_ref())
|
||||
{
|
||||
let _ = webview.print();
|
||||
}
|
||||
}
|
||||
WebviewMessage::WebviewEvent(event) => {
|
||||
let window_event_listeners = windows
|
||||
.borrow()
|
||||
.get(&id)
|
||||
.map(|w| w.window_event_listeners.clone());
|
||||
if let Some(window_event_listeners) = window_event_listeners {
|
||||
if let Some(event) = WindowEventWrapper::from(&event).0 {
|
||||
let listeners = window_event_listeners.lock().unwrap();
|
||||
let handlers = listeners.values();
|
||||
for handler in handlers {
|
||||
handler(&event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
WebviewMessage::WebviewEvent(_event) => { /* already handled */ }
|
||||
},
|
||||
Message::CreateWebview(window_id, handler) => match handler(event_loop, web_context) {
|
||||
Ok(webview) => {
|
||||
@@ -2423,14 +2573,18 @@ fn handle_user_message<T: UserEvent>(
|
||||
Message::Tray(tray_id, tray_message) => {
|
||||
let mut trays = system_tray_manager.trays.lock().unwrap();
|
||||
|
||||
if let TrayMessage::Create(tray, tx) = tray_message {
|
||||
if let TrayMessage::Create(mut tray, tx) = tray_message {
|
||||
let mut listeners = Vec::new();
|
||||
if let Some(l) = tray.on_event.take() {
|
||||
listeners.push(Arc::new(l));
|
||||
}
|
||||
match create_tray(WryTrayId(tray_id), tray, event_loop) {
|
||||
Ok((tray, items)) => {
|
||||
trays.insert(
|
||||
tray_id,
|
||||
TrayContext {
|
||||
tray: Arc::new(Mutex::new(Some(tray))),
|
||||
listeners: Default::default(),
|
||||
listeners: Arc::new(Mutex::new(listeners)),
|
||||
items: Arc::new(Mutex::new(items)),
|
||||
},
|
||||
);
|
||||
@@ -2477,13 +2631,25 @@ fn handle_user_message<T: UserEvent>(
|
||||
tray.set_icon_as_template(is_template);
|
||||
}
|
||||
}
|
||||
#[cfg(target_os = "macos")]
|
||||
TrayMessage::UpdateTitle(title) => {
|
||||
if let Some(tray) = &mut *tray_context.tray.lock().unwrap() {
|
||||
tray.set_title(&title);
|
||||
}
|
||||
}
|
||||
TrayMessage::UpdateTooltip(tooltip) => {
|
||||
if let Some(tray) = &mut *tray_context.tray.lock().unwrap() {
|
||||
tray.set_tooltip(&tooltip);
|
||||
}
|
||||
}
|
||||
TrayMessage::Create(_tray, _tx) => {
|
||||
// already handled
|
||||
}
|
||||
TrayMessage::Destroy => {
|
||||
TrayMessage::Destroy(tx) => {
|
||||
*tray_context.tray.lock().unwrap() = None;
|
||||
tray_context.listeners.lock().unwrap().clear();
|
||||
tray_context.items.lock().unwrap().clear();
|
||||
tx.send(Ok(())).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2612,14 +2778,13 @@ fn handle_event_loop<T: UserEvent>(
|
||||
items.contains_key(&menu_id.0)
|
||||
};
|
||||
if has_menu {
|
||||
listeners.replace(tray_context.listeners.clone());
|
||||
listeners.replace(tray_context.listeners.lock().unwrap().clone());
|
||||
tray_id = *id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
drop(trays);
|
||||
if let Some(listeners) = listeners {
|
||||
let listeners = listeners.lock().unwrap();
|
||||
let handlers = listeners.iter();
|
||||
for handler in handlers {
|
||||
handler(&event);
|
||||
@@ -2665,6 +2830,24 @@ fn handle_event_loop<T: UserEvent>(
|
||||
global_listener(id.0, &event);
|
||||
}
|
||||
}
|
||||
Event::UserEvent(Message::Webview(id, WebviewMessage::WebviewEvent(event))) => {
|
||||
if let Some(event) = WindowEventWrapper::from(&event).0 {
|
||||
let windows = windows.borrow();
|
||||
let window = windows.get(&id);
|
||||
if let Some(window) = window {
|
||||
callback(RunEvent::WindowEvent {
|
||||
label: window.label.clone(),
|
||||
event: event.clone(),
|
||||
});
|
||||
|
||||
let listeners = window.window_event_listeners.lock().unwrap();
|
||||
let handlers = listeners.values();
|
||||
for handler in handlers {
|
||||
handler(&event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Event::WindowEvent {
|
||||
event, window_id, ..
|
||||
} => {
|
||||
@@ -2692,6 +2875,19 @@ fn handle_event_loop<T: UserEvent>(
|
||||
}
|
||||
|
||||
match event {
|
||||
#[cfg(windows)]
|
||||
WryWindowEvent::ThemeChanged(theme) => {
|
||||
if let Some(window) = windows.borrow().get(&window_id) {
|
||||
if let Some(WindowHandle::Webview { inner, .. }) = &window.inner {
|
||||
let theme = match theme {
|
||||
WryTheme::Dark => wry::webview::Theme::Dark,
|
||||
WryTheme::Light => wry::webview::Theme::Light,
|
||||
_ => wry::webview::Theme::Light,
|
||||
};
|
||||
inner.set_theme(theme);
|
||||
}
|
||||
}
|
||||
}
|
||||
WryWindowEvent::CloseRequested => {
|
||||
on_close_requested(callback, window_id, windows.clone());
|
||||
}
|
||||
@@ -2837,7 +3033,7 @@ fn to_wry_menu(
|
||||
fn create_webview<T: UserEvent>(
|
||||
window_id: WebviewId,
|
||||
event_loop: &EventLoopWindowTarget<Message<T>>,
|
||||
web_context: &WebContextStore,
|
||||
web_context_store: &WebContextStore,
|
||||
context: Context<T>,
|
||||
pending: PendingWindow<T, Wry<T>>,
|
||||
) -> Result<WindowWrapper> {
|
||||
@@ -2848,7 +3044,7 @@ fn create_webview<T: UserEvent>(
|
||||
mut window_builder,
|
||||
ipc_handler,
|
||||
label,
|
||||
url,
|
||||
current_url,
|
||||
menu_ids,
|
||||
js_event_listeners,
|
||||
..
|
||||
@@ -2859,10 +3055,6 @@ fn create_webview<T: UserEvent>(
|
||||
|
||||
let window_event_listeners = WindowEventListeners::default();
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
window_builder.inner = window_builder.inner.with_fullsize_content_view(true);
|
||||
}
|
||||
#[cfg(windows)]
|
||||
{
|
||||
window_builder.inner = window_builder
|
||||
@@ -2870,6 +3062,19 @@ fn create_webview<T: UserEvent>(
|
||||
.with_drag_and_drop(webview_attributes.file_drop_handler_enabled);
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
let window_theme = window_builder.inner.window.preferred_theme;
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
if window_builder.tabbing_identifier.is_none()
|
||||
|| window_builder.inner.window.transparent
|
||||
|| !window_builder.inner.window.decorations
|
||||
{
|
||||
window_builder.inner = window_builder.inner.with_automatic_window_tabbing(false);
|
||||
}
|
||||
}
|
||||
|
||||
let is_window_transparent = window_builder.inner.window.transparent;
|
||||
let menu_items = if let Some(menu) = window_builder.menu {
|
||||
let mut menu_items = HashMap::new();
|
||||
@@ -2888,17 +3093,42 @@ fn create_webview<T: UserEvent>(
|
||||
}
|
||||
let mut webview_builder = WebViewBuilder::new(window)
|
||||
.map_err(|e| Error::CreateWebview(Box::new(e)))?
|
||||
.with_url(&url)
|
||||
.with_url(current_url.lock().unwrap().as_str())
|
||||
.unwrap() // safe to unwrap because we validate the URL beforehand
|
||||
.with_transparent(is_window_transparent);
|
||||
.with_transparent(is_window_transparent)
|
||||
.with_accept_first_mouse(webview_attributes.accept_first_mouse);
|
||||
if webview_attributes.file_drop_handler_enabled {
|
||||
webview_builder = webview_builder
|
||||
.with_file_drop_handler(create_file_drop_handler(window_event_listeners.clone()));
|
||||
}
|
||||
if let Some(navigation_handler) = pending.navigation_handler {
|
||||
webview_builder = webview_builder.with_navigation_handler(move |url| {
|
||||
Url::parse(&url).map(&navigation_handler).unwrap_or(true)
|
||||
});
|
||||
}
|
||||
if let Some(user_agent) = webview_attributes.user_agent {
|
||||
webview_builder = webview_builder.with_user_agent(&user_agent);
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
if let Some(additional_browser_args) = webview_attributes.additional_browser_args {
|
||||
webview_builder = webview_builder.with_additional_browser_args(&additional_browser_args);
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
if let Some(theme) = window_theme {
|
||||
webview_builder = webview_builder.with_theme(match theme {
|
||||
WryTheme::Dark => wry::webview::Theme::Dark,
|
||||
WryTheme::Light => wry::webview::Theme::Light,
|
||||
_ => wry::webview::Theme::Light,
|
||||
});
|
||||
}
|
||||
|
||||
if let Some(handler) = ipc_handler {
|
||||
webview_builder = webview_builder.with_ipc_handler(create_ipc_handler(
|
||||
context,
|
||||
label.clone(),
|
||||
current_url,
|
||||
menu_ids,
|
||||
js_event_listeners,
|
||||
handler,
|
||||
@@ -2916,19 +3146,18 @@ fn create_webview<T: UserEvent>(
|
||||
webview_builder = webview_builder.with_initialization_script(&script);
|
||||
}
|
||||
|
||||
let mut web_context = web_context.lock().expect("poisoned WebContext store");
|
||||
let mut web_context = web_context_store.lock().expect("poisoned WebContext store");
|
||||
let is_first_context = web_context.is_empty();
|
||||
let automation_enabled = std::env::var("TAURI_AUTOMATION").as_deref() == Ok("true");
|
||||
let entry = web_context.entry(
|
||||
// force a unique WebContext when automation is false;
|
||||
let web_context_key = // force a unique WebContext when automation is false;
|
||||
// the context must be stored on the HashMap because it must outlive the WebView on macOS
|
||||
if automation_enabled {
|
||||
webview_attributes.data_directory.clone()
|
||||
} else {
|
||||
// random unique key
|
||||
Some(Uuid::new_v4().as_hyphenated().to_string().into())
|
||||
},
|
||||
);
|
||||
};
|
||||
let entry = web_context.entry(web_context_key.clone());
|
||||
let web_context = match entry {
|
||||
Occupied(occupied) => occupied.into_mut(),
|
||||
Vacant(vacant) => {
|
||||
@@ -2991,7 +3220,15 @@ fn create_webview<T: UserEvent>(
|
||||
|
||||
Ok(WindowWrapper {
|
||||
label,
|
||||
inner: Some(WindowHandle::Webview(Arc::new(webview))),
|
||||
inner: Some(WindowHandle::Webview {
|
||||
inner: Arc::new(webview),
|
||||
context_store: web_context_store.clone(),
|
||||
context_key: if automation_enabled {
|
||||
None
|
||||
} else {
|
||||
web_context_key
|
||||
},
|
||||
}),
|
||||
menu_items,
|
||||
window_event_listeners,
|
||||
menu_event_listeners: Default::default(),
|
||||
@@ -3002,6 +3239,7 @@ fn create_webview<T: UserEvent>(
|
||||
fn create_ipc_handler<T: UserEvent>(
|
||||
context: Context<T>,
|
||||
label: String,
|
||||
current_url: Arc<Mutex<Url>>,
|
||||
menu_ids: Arc<Mutex<HashMap<MenuHash, MenuId>>>,
|
||||
js_event_listeners: Arc<Mutex<HashMap<JsEventListenerKey, HashSet<u64>>>>,
|
||||
handler: WebviewIpcHandler<T, Wry<T>>,
|
||||
@@ -3010,6 +3248,7 @@ fn create_ipc_handler<T: UserEvent>(
|
||||
let window_id = context.webview_id_map.get(&window.id()).unwrap();
|
||||
handler(
|
||||
DetachedWindow {
|
||||
current_url: current_url.clone(),
|
||||
dispatcher: WryDispatcher {
|
||||
window_id,
|
||||
context: context.clone(),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -27,7 +27,7 @@ pub use wry::application::platform::macos::{
|
||||
|
||||
use wry::application::system_tray::{SystemTray as WrySystemTray, SystemTrayBuilder};
|
||||
|
||||
use crate::{Error, Message, Result, TrayId, TrayMessage};
|
||||
use crate::{send_user_message, Context, Error, Message, Result, TrayId, TrayMessage};
|
||||
|
||||
use tauri_runtime::{menu::MenuHash, SystemTray, UserEvent};
|
||||
|
||||
@@ -105,7 +105,17 @@ pub fn create_tray<T>(
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
builder = builder.with_icon_as_template(system_tray.icon_as_template)
|
||||
builder = builder
|
||||
.with_icon_as_template(system_tray.icon_as_template)
|
||||
.with_menu_on_left_click(system_tray.menu_on_left_click);
|
||||
|
||||
if let Some(title) = system_tray.title {
|
||||
builder = builder.with_title(&title);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(tooltip) = system_tray.tooltip {
|
||||
builder = builder.with_tooltip(&tooltip);
|
||||
}
|
||||
|
||||
let tray = builder
|
||||
@@ -117,6 +127,7 @@ pub fn create_tray<T>(
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SystemTrayHandle<T: UserEvent> {
|
||||
pub(crate) context: Context<T>,
|
||||
pub(crate) id: TrayId,
|
||||
pub(crate) proxy: EventLoopProxy<super::Message<T>>,
|
||||
}
|
||||
@@ -154,12 +165,36 @@ impl<T: UserEvent> TrayHandle for SystemTrayHandle<T> {
|
||||
.map_err(|_| Error::FailedToSendMessage)
|
||||
}
|
||||
|
||||
fn destroy(&self) -> Result<()> {
|
||||
#[cfg(target_os = "macos")]
|
||||
fn set_title(&self, title: &str) -> tauri_runtime::Result<()> {
|
||||
self
|
||||
.proxy
|
||||
.send_event(Message::Tray(self.id, TrayMessage::Destroy))
|
||||
.send_event(Message::Tray(
|
||||
self.id,
|
||||
TrayMessage::UpdateTitle(title.to_owned()),
|
||||
))
|
||||
.map_err(|_| Error::FailedToSendMessage)
|
||||
}
|
||||
|
||||
fn set_tooltip(&self, tooltip: &str) -> Result<()> {
|
||||
self
|
||||
.proxy
|
||||
.send_event(Message::Tray(
|
||||
self.id,
|
||||
TrayMessage::UpdateTooltip(tooltip.to_owned()),
|
||||
))
|
||||
.map_err(|_| Error::FailedToSendMessage)
|
||||
}
|
||||
|
||||
fn destroy(&self) -> Result<()> {
|
||||
let (tx, rx) = std::sync::mpsc::channel();
|
||||
send_user_message(
|
||||
&self.context,
|
||||
Message::Tray(self.id, TrayMessage::Destroy(tx)),
|
||||
)?;
|
||||
rx.recv().unwrap()?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<SystemTrayMenuItem> for crate::MenuItemWrapper {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,5 +1,56 @@
|
||||
# Changelog
|
||||
|
||||
## \[0.13.0]
|
||||
|
||||
- Added the `additional_browser_args` option when creating a window.
|
||||
- [3dc38b15](https://www.github.com/tauri-apps/tauri/commit/3dc38b150ea8c59c8ba67fd586f921016928f47c) feat(core): expose additional_browser_args to window config (fix: [#5757](https://www.github.com/tauri-apps/tauri/pull/5757)) ([#5799](https://www.github.com/tauri-apps/tauri/pull/5799)) on 2022-12-14
|
||||
- Added the `content_protected` option when creating a window and `Window::set_content_protected` to change it at runtime.
|
||||
- [4ab5545b](https://www.github.com/tauri-apps/tauri/commit/4ab5545b7a831c549f3c65e74de487ede3ab7ce5) feat: add content protection api, closes [#5132](https://www.github.com/tauri-apps/tauri/pull/5132) ([#5513](https://www.github.com/tauri-apps/tauri/pull/5513)) on 2022-12-13
|
||||
- Added `Builder::device_event_filter` and `App::set_device_event_filter` methods.
|
||||
- [73fd60ee](https://www.github.com/tauri-apps/tauri/commit/73fd60eef2b60f5dc84525ef9c315f4d80c4414f) expose set_device_event_filter in tauri ([#5562](https://www.github.com/tauri-apps/tauri/pull/5562)) on 2022-12-13
|
||||
- Add `is_minimized()` window method.
|
||||
- [62144ef3](https://www.github.com/tauri-apps/tauri/commit/62144ef3be63b237869e511826edfb938e2c7174) feat: add is_minimized (fix [#3878](https://www.github.com/tauri-apps/tauri/pull/3878)) ([#5618](https://www.github.com/tauri-apps/tauri/pull/5618)) on 2022-12-13
|
||||
- Bump minimum supported Rust version to 1.60.
|
||||
- [5fdc616d](https://www.github.com/tauri-apps/tauri/commit/5fdc616df9bea633810dcb814ac615911d77222c) feat: Use the zbus-backed of notify-rust ([#6332](https://www.github.com/tauri-apps/tauri/pull/6332)) on 2023-03-31
|
||||
- Pin raw-window-handle to 0.5.0 to keep MSRV.
|
||||
- [c46c09f3](https://www.github.com/tauri-apps/tauri/commit/c46c09f31d9f5169ca8a7e62406a9ea170e3a5c5) fix(deps): pin raw-window-handle to 0.5.0 ([#6480](https://www.github.com/tauri-apps/tauri/pull/6480)) on 2023-03-17
|
||||
- Added `navigation_handler` field on `PendingWindow`.
|
||||
- [3f35b452](https://www.github.com/tauri-apps/tauri/commit/3f35b452637ef1c794a423f1eda62a15d2ddaf42) Expose wry navigation_handler via WindowBuilder closes [#4080](https://www.github.com/tauri-apps/tauri/pull/4080) ([#5686](https://www.github.com/tauri-apps/tauri/pull/5686)) on 2022-12-27
|
||||
- Add `title` getter on window.
|
||||
- [233e43b0](https://www.github.com/tauri-apps/tauri/commit/233e43b0c34fada1ca025378533a0b76931a6540) feat: add `title` getter on window, closes [#5023](https://www.github.com/tauri-apps/tauri/pull/5023) ([#5515](https://www.github.com/tauri-apps/tauri/pull/5515)) on 2022-12-13
|
||||
- Added `TrayHandle::set_tooltip` and `SystemTray::with_tooltip`.
|
||||
- [2265e097](https://www.github.com/tauri-apps/tauri/commit/2265e09718f6ebfeb1d200f11e1e1e069075af6e) feat(windows): implement `with_tooltip` ([#5938](https://www.github.com/tauri-apps/tauri/pull/5938)) on 2023-01-01
|
||||
- Added window's `url()` getter.
|
||||
- [d17027e1](https://www.github.com/tauri-apps/tauri/commit/d17027e1a0db3e8c5ae81fc4f472c5918fbce611) feat: expose url method ([#5914](https://www.github.com/tauri-apps/tauri/pull/5914)) on 2022-12-26
|
||||
- On Windows, change webview theme based on Window theme for more accurate `prefers-color-scheme` support.
|
||||
- [7a8d570d](https://www.github.com/tauri-apps/tauri/commit/7a8d570db72667367eb24b75ddc5dd07a968f7c0) fix: sync webview theme with window theme on Windows, closes [#5802](https://www.github.com/tauri-apps/tauri/pull/5802) ([#5874](https://www.github.com/tauri-apps/tauri/pull/5874)) on 2022-12-27
|
||||
|
||||
## \[0.12.1]
|
||||
|
||||
- Fix `allowlist > app > show/hide` always disabled when `allowlist > app > all: false`.
|
||||
- Bumped due to a bump in tauri-utils.
|
||||
- [bb251087](https://www.github.com/tauri-apps/tauri/commit/bb2510876d0bdff736d36bf3a465cdbe4ad2b90c) fix(core): extend allowlist with `app`'s allowlist, closes [#5650](https://www.github.com/tauri-apps/tauri/pull/5650) ([#5652](https://www.github.com/tauri-apps/tauri/pull/5652)) on 2022-11-18
|
||||
|
||||
## \[0.12.0]
|
||||
|
||||
- Readd the option to create an unfocused window via the `focused` method. The `focus` function has been deprecated.
|
||||
- [4036e15f](https://www.github.com/tauri-apps/tauri/commit/4036e15f5af933bdc0d0913508b5103958afc143) feat(core): reimplement window initial focus flag, closes [#5120](https://www.github.com/tauri-apps/tauri/pull/5120) ([#5338](https://www.github.com/tauri-apps/tauri/pull/5338)) on 2022-10-08
|
||||
- Added `Runtime::show()`, `RuntimeHandle::show()`, `Runtime::hide()`, `RuntimeHandle::hide()` for hiding/showing the entire application on macOS.
|
||||
- [39bf895b](https://www.github.com/tauri-apps/tauri/commit/39bf895b73ec6b53f5758815396ba85dda6b9c67) feat(macOS): Add application `show` and `hide` methods ([#3689](https://www.github.com/tauri-apps/tauri/pull/3689)) on 2022-10-03
|
||||
- - [7d9aa398](https://www.github.com/tauri-apps/tauri/commit/7d9aa3987efce2d697179ffc33646d086c68030c) feat: bump MSRV to 1.59 ([#5296](https://www.github.com/tauri-apps/tauri/pull/5296)) on 2022-09-28
|
||||
- Added `tabbing_identifier` to the window builder on macOS.
|
||||
- [4137ab44](https://www.github.com/tauri-apps/tauri/commit/4137ab44a81d739556cbc7583485887e78952bf1) feat(macos): add `tabbing_identifier` option, closes [#2804](https://www.github.com/tauri-apps/tauri/pull/2804), [#3912](https://www.github.com/tauri-apps/tauri/pull/3912) ([#5399](https://www.github.com/tauri-apps/tauri/pull/5399)) on 2022-10-19
|
||||
- Added methods to set the system tray title on macOS.
|
||||
- [8f1ace77](https://www.github.com/tauri-apps/tauri/commit/8f1ace77956ac3477826ceb059a191e55b3fff93) feat: expose `set_title` for MacOS tray ([#5182](https://www.github.com/tauri-apps/tauri/pull/5182)) on 2022-09-30
|
||||
- Added the `user_agent` option when creating a window.
|
||||
- [a6c94119](https://www.github.com/tauri-apps/tauri/commit/a6c94119d8545d509723b147c273ca5edfe3729f) feat(core): expose user_agent to window config ([#5317](https://www.github.com/tauri-apps/tauri/pull/5317)) on 2022-10-02
|
||||
|
||||
## \[0.11.1]
|
||||
|
||||
- Add missing allowlist config for `set_cursor_grab`, `set_cursor_visible`, `set_cursor_icon` and `set_cursor_position` APIs.
|
||||
- Bumped due to a bump in tauri-utils.
|
||||
- [c764408d](https://www.github.com/tauri-apps/tauri/commit/c764408da7fae123edd41115bda42fa75a4731d2) fix: Add missing allowlist config for cursor apis, closes [#5207](https://www.github.com/tauri-apps/tauri/pull/5207) ([#5211](https://www.github.com/tauri-apps/tauri/pull/5211)) on 2022-09-16
|
||||
|
||||
## \[0.11.0]
|
||||
|
||||
- Added APIs to create a system tray at runtime.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "tauri-runtime"
|
||||
version = "0.11.0"
|
||||
version = "0.13.0"
|
||||
authors = [ "Tauri Programme within The Commons Conservancy" ]
|
||||
categories = [ "gui", "web-programming" ]
|
||||
license = "Apache-2.0 OR MIT"
|
||||
@@ -8,7 +8,7 @@ homepage = "https://tauri.app"
|
||||
repository = "https://github.com/tauri-apps/tauri"
|
||||
description = "Runtime for Tauri applications"
|
||||
edition = "2021"
|
||||
rust-version = "1.57"
|
||||
rust-version = "1.60"
|
||||
exclude = [ "CHANGELOG.md", "/target" ]
|
||||
readme = "README.md"
|
||||
|
||||
@@ -26,13 +26,13 @@ targets = [
|
||||
serde = { version = "1.0", features = [ "derive" ] }
|
||||
serde_json = "1.0"
|
||||
thiserror = "1.0"
|
||||
tauri-utils = { version = "1.1.0", path = "../tauri-utils" }
|
||||
tauri-utils = { version = "1.3.0", path = "../tauri-utils" }
|
||||
uuid = { version = "1", features = [ "v4" ] }
|
||||
http = "0.2.4"
|
||||
http-range = "0.1.4"
|
||||
infer = "0.7"
|
||||
raw-window-handle = "0.5"
|
||||
raw-window-handle = "=0.5.0"
|
||||
rand = "0.8"
|
||||
url = { version = "2" }
|
||||
|
||||
[target."cfg(windows)".dependencies]
|
||||
webview2-com = "0.19.1"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// `alias` must be a snake case string.
|
||||
fn alias(alias: &str, has_feature: bool) {
|
||||
if has_feature {
|
||||
println!("cargo:rustc-cfg={}", alias);
|
||||
println!("cargo:rustc-cfg={alias}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// custom wry types
|
||||
mod mime_type;
|
||||
mod request;
|
||||
mod response;
|
||||
|
||||
pub use self::{
|
||||
mime_type::MimeType,
|
||||
request::{Request, RequestParts},
|
||||
response::{Builder as ResponseBuilder, Response, ResponseParts},
|
||||
};
|
||||
|
||||
pub use tauri_utils::mime_type::MimeType;
|
||||
|
||||
// re-expose default http types
|
||||
pub use http::{header, method, status, uri::InvalidUri, version, Uri};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -10,6 +10,7 @@ use raw_window_handle::RawDisplayHandle;
|
||||
use serde::Deserialize;
|
||||
use std::{fmt::Debug, sync::mpsc::Sender};
|
||||
use tauri_utils::Theme;
|
||||
use url::Url;
|
||||
use uuid::Uuid;
|
||||
|
||||
pub mod http;
|
||||
@@ -50,7 +51,10 @@ pub struct SystemTray {
|
||||
pub icon_as_template: bool,
|
||||
#[cfg(target_os = "macos")]
|
||||
pub menu_on_left_click: bool,
|
||||
#[cfg(target_os = "macos")]
|
||||
pub title: Option<String>,
|
||||
pub on_event: Option<Box<TrayEventHandler>>,
|
||||
pub tooltip: Option<String>,
|
||||
}
|
||||
|
||||
#[cfg(all(desktop, feature = "system-tray"))]
|
||||
@@ -63,7 +67,8 @@ impl fmt::Debug for SystemTray {
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
d.field("icon_as_template", &self.icon_as_template)
|
||||
.field("menu_on_left_click", &self.menu_on_left_click);
|
||||
.field("menu_on_left_click", &self.menu_on_left_click)
|
||||
.field("title", &self.title);
|
||||
}
|
||||
d.finish()
|
||||
}
|
||||
@@ -81,6 +86,9 @@ impl Clone for SystemTray {
|
||||
icon_as_template: self.icon_as_template,
|
||||
#[cfg(target_os = "macos")]
|
||||
menu_on_left_click: self.menu_on_left_click,
|
||||
#[cfg(target_os = "macos")]
|
||||
title: self.title.clone(),
|
||||
tooltip: self.tooltip.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -96,7 +104,10 @@ impl Default for SystemTray {
|
||||
icon_as_template: false,
|
||||
#[cfg(target_os = "macos")]
|
||||
menu_on_left_click: false,
|
||||
#[cfg(target_os = "macos")]
|
||||
title: None,
|
||||
on_event: None,
|
||||
tooltip: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -142,6 +153,24 @@ impl SystemTray {
|
||||
self
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
#[must_use]
|
||||
pub fn with_title(mut self, title: &str) -> Self {
|
||||
self.title = Some(title.to_owned());
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the tray icon tooltip.
|
||||
///
|
||||
/// ## Platform-specific:
|
||||
///
|
||||
/// - **Linux:** Unsupported
|
||||
#[must_use]
|
||||
pub fn with_tooltip(mut self, tooltip: &str) -> Self {
|
||||
self.tooltip = Some(tooltip.to_owned());
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the menu to show when the system tray is right clicked.
|
||||
#[must_use]
|
||||
pub fn with_menu(mut self, menu: menu::SystemTrayMenu) -> Self {
|
||||
@@ -170,6 +199,23 @@ pub enum UserAttentionType {
|
||||
Informational,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize)]
|
||||
#[serde(tag = "type")]
|
||||
pub enum DeviceEventFilter {
|
||||
/// Always filter out device events.
|
||||
Always,
|
||||
/// Filter out device events while the window is not focused.
|
||||
Unfocused,
|
||||
/// Report all device events regardless of window focus.
|
||||
Never,
|
||||
}
|
||||
|
||||
impl Default for DeviceEventFilter {
|
||||
fn default() -> Self {
|
||||
Self::Unfocused
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
#[non_exhaustive]
|
||||
pub enum Error {
|
||||
@@ -338,6 +384,16 @@ pub trait RuntimeHandle<T: UserEvent>: Debug + Clone + Send + Sync + Sized + 'st
|
||||
) -> Result<<Self::Runtime as Runtime<T>>::TrayHandler>;
|
||||
|
||||
fn raw_display_handle(&self) -> RawDisplayHandle;
|
||||
|
||||
/// Shows the application, but does not automatically focus it.
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg_attr(doc_cfg, doc(cfg(target_os = "macos")))]
|
||||
fn show(&self) -> Result<()>;
|
||||
|
||||
/// Hides the application.
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg_attr(doc_cfg, doc(cfg(target_os = "macos")))]
|
||||
fn hide(&self) -> Result<()>;
|
||||
}
|
||||
|
||||
/// A global shortcut manager.
|
||||
@@ -427,6 +483,29 @@ pub trait Runtime<T: UserEvent>: Debug + Sized + 'static {
|
||||
#[cfg_attr(doc_cfg, doc(cfg(target_os = "macos")))]
|
||||
fn set_activation_policy(&mut self, activation_policy: ActivationPolicy);
|
||||
|
||||
/// Shows the application, but does not automatically focus it.
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg_attr(doc_cfg, doc(cfg(target_os = "macos")))]
|
||||
fn show(&self);
|
||||
|
||||
/// Hides the application.
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg_attr(doc_cfg, doc(cfg(target_os = "macos")))]
|
||||
fn hide(&self);
|
||||
|
||||
/// Change the device event filter mode.
|
||||
///
|
||||
/// Since the DeviceEvent capture can lead to high CPU usage for unfocused windows, [`tao`]
|
||||
/// will ignore them by default for unfocused windows on Windows. This method allows changing
|
||||
/// the filter to explicitly capture them again.
|
||||
///
|
||||
/// ## Platform-specific
|
||||
///
|
||||
/// - ** Linux / macOS / iOS / Android**: Unsupported.
|
||||
///
|
||||
/// [`tao`]: https://crates.io/crates/tao
|
||||
fn set_device_event_filter(&mut self, filter: DeviceEventFilter);
|
||||
|
||||
/// Runs the one step of the webview runtime event loop and returns control flow to the caller.
|
||||
#[cfg(desktop)]
|
||||
fn run_iteration<F: Fn(RunEvent<T>) + 'static>(&mut self, callback: F) -> RunIteration;
|
||||
@@ -466,6 +545,9 @@ pub trait Dispatch<T: UserEvent>: Debug + Clone + Send + Sync + Sized + 'static
|
||||
|
||||
// GETTERS
|
||||
|
||||
/// Returns the webview's current URL.
|
||||
fn url(&self) -> Result<Url>;
|
||||
|
||||
/// Returns the scale factor that can be used to map logical pixels to physical pixels, and vice versa.
|
||||
fn scale_factor(&self) -> Result<f64>;
|
||||
|
||||
@@ -488,6 +570,9 @@ pub trait Dispatch<T: UserEvent>: Debug + Clone + Send + Sync + Sized + 'static
|
||||
/// Gets the window's current fullscreen state.
|
||||
fn is_fullscreen(&self) -> Result<bool>;
|
||||
|
||||
/// Gets the window's current minimized state.
|
||||
fn is_minimized(&self) -> Result<bool>;
|
||||
|
||||
/// Gets the window's current maximized state.
|
||||
fn is_maximized(&self) -> Result<bool>;
|
||||
|
||||
@@ -499,6 +584,8 @@ pub trait Dispatch<T: UserEvent>: Debug + Clone + Send + Sync + Sized + 'static
|
||||
|
||||
/// Gets the window's current visibility state.
|
||||
fn is_visible(&self) -> Result<bool>;
|
||||
/// Gets the window's current title.
|
||||
fn title(&self) -> Result<String>;
|
||||
|
||||
/// Gets the window menu current visibility state.
|
||||
fn is_menu_visible(&self) -> Result<bool>;
|
||||
@@ -589,6 +676,9 @@ pub trait Dispatch<T: UserEvent>: Debug + Clone + Send + Sync + Sized + 'static
|
||||
/// Updates the window alwaysOnTop flag.
|
||||
fn set_always_on_top(&self, always_on_top: bool) -> Result<()>;
|
||||
|
||||
/// Prevents the window contents from being captured by other apps.
|
||||
fn set_content_protected(&self, protected: bool) -> Result<()>;
|
||||
|
||||
/// Resizes the window.
|
||||
fn set_size(&self, size: Size) -> Result<()>;
|
||||
|
||||
@@ -610,7 +700,7 @@ pub trait Dispatch<T: UserEvent>: Debug + Clone + Send + Sync + Sized + 'static
|
||||
/// Updates the window icon.
|
||||
fn set_icon(&self, icon: Icon) -> Result<()>;
|
||||
|
||||
/// Whether to show the window icon in the task bar or not.
|
||||
/// Whether to hide the window icon from the taskbar or not.
|
||||
fn set_skip_taskbar(&self, skip: bool) -> Result<()>;
|
||||
|
||||
/// Grabs the cursor, preventing it from leaving the window.
|
||||
@@ -630,6 +720,9 @@ pub trait Dispatch<T: UserEvent>: Debug + Clone + Send + Sync + Sized + 'static
|
||||
/// Changes the position of the cursor in window coordinates.
|
||||
fn set_cursor_position<Pos: Into<Position>>(&self, position: Pos) -> Result<()>;
|
||||
|
||||
/// Ignores the window cursor events.
|
||||
fn set_ignore_cursor_events(&self, ignore: bool) -> Result<()>;
|
||||
|
||||
/// Starts dragging the window.
|
||||
fn start_dragging(&self) -> Result<()>;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -152,6 +152,9 @@ pub trait TrayHandle: fmt::Debug + Clone + Send + Sync {
|
||||
fn update_item(&self, id: u16, update: MenuUpdate) -> crate::Result<()>;
|
||||
#[cfg(target_os = "macos")]
|
||||
fn set_icon_as_template(&self, is_template: bool) -> crate::Result<()>;
|
||||
#[cfg(target_os = "macos")]
|
||||
fn set_title(&self, title: &str) -> crate::Result<()>;
|
||||
fn set_tooltip(&self, tooltip: &str) -> crate::Result<()>;
|
||||
fn destroy(&self) -> crate::Result<()>;
|
||||
}
|
||||
|
||||
@@ -582,13 +585,13 @@ impl AboutMetadata {
|
||||
self
|
||||
}
|
||||
|
||||
/// Defines the application version.
|
||||
/// Defines the application's website link.
|
||||
pub fn website(mut self, website: impl Into<String>) -> Self {
|
||||
self.website.replace(website.into());
|
||||
self
|
||||
}
|
||||
|
||||
/// Defines the application version.
|
||||
/// Defines the application's website link name.
|
||||
pub fn website_label(mut self, website_label: impl Into<String>) -> Self {
|
||||
self.website_label.replace(website_label.into());
|
||||
self
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
use crate::{menu::Menu, window::DetachedWindow, Icon};
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
use tauri_utils::TitleBarStyle;
|
||||
use tauri_utils::{
|
||||
config::{WindowConfig, WindowUrl},
|
||||
Theme,
|
||||
@@ -20,10 +22,13 @@ use std::{fmt, path::PathBuf};
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct WebviewAttributes {
|
||||
pub url: WindowUrl,
|
||||
pub user_agent: Option<String>,
|
||||
pub initialization_scripts: Vec<String>,
|
||||
pub data_directory: Option<PathBuf>,
|
||||
pub file_drop_handler_enabled: bool,
|
||||
pub clipboard: bool,
|
||||
pub accept_first_mouse: bool,
|
||||
pub additional_browser_args: Option<String>,
|
||||
}
|
||||
|
||||
impl WebviewAttributes {
|
||||
@@ -31,13 +36,23 @@ impl WebviewAttributes {
|
||||
pub fn new(url: WindowUrl) -> Self {
|
||||
Self {
|
||||
url,
|
||||
user_agent: None,
|
||||
initialization_scripts: Vec::new(),
|
||||
data_directory: None,
|
||||
file_drop_handler_enabled: true,
|
||||
clipboard: false,
|
||||
accept_first_mouse: false,
|
||||
additional_browser_args: None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets the user agent
|
||||
#[must_use]
|
||||
pub fn user_agent(mut self, user_agent: &str) -> Self {
|
||||
self.user_agent = Some(user_agent.to_string());
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the init script.
|
||||
#[must_use]
|
||||
pub fn initialization_script(mut self, script: &str) -> Self {
|
||||
@@ -68,6 +83,20 @@ impl WebviewAttributes {
|
||||
self.clipboard = true;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets whether clicking an inactive window also clicks through to the webview.
|
||||
#[must_use]
|
||||
pub fn accept_first_mouse(mut self, accept: bool) -> Self {
|
||||
self.accept_first_mouse = accept;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets additional browser arguments. **Windows Only**
|
||||
#[must_use]
|
||||
pub fn additional_browser_args(mut self, additional_args: &str) -> Self {
|
||||
self.additional_browser_args = Some(additional_args.to_string());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
/// Do **NOT** implement this trait except for use in a custom [`Runtime`](crate::Runtime).
|
||||
@@ -122,9 +151,9 @@ pub trait WindowBuilder: WindowBuilderBase {
|
||||
#[must_use]
|
||||
fn fullscreen(self, fullscreen: bool) -> Self;
|
||||
|
||||
/// Whether the window will be initially hidden or focused.
|
||||
/// Whether the window will be initially focused or not.
|
||||
#[must_use]
|
||||
fn focus(self) -> Self;
|
||||
fn focused(self, focused: bool) -> Self;
|
||||
|
||||
/// Whether the window should be maximized upon creation.
|
||||
#[must_use]
|
||||
@@ -152,6 +181,10 @@ pub trait WindowBuilder: WindowBuilderBase {
|
||||
#[must_use]
|
||||
fn always_on_top(self, always_on_top: bool) -> Self;
|
||||
|
||||
/// Prevents the window contents from being captured by other apps.
|
||||
#[must_use]
|
||||
fn content_protected(self, protected: bool) -> Self;
|
||||
|
||||
/// Sets the window icon.
|
||||
fn icon(self, icon: Icon) -> crate::Result<Self>;
|
||||
|
||||
@@ -189,6 +222,26 @@ pub trait WindowBuilder: WindowBuilderBase {
|
||||
#[must_use]
|
||||
fn owner_window(self, owner: HWND) -> Self;
|
||||
|
||||
/// Hide the titlebar. Titlebar buttons will still be visible.
|
||||
#[cfg(target_os = "macos")]
|
||||
#[must_use]
|
||||
fn title_bar_style(self, style: TitleBarStyle) -> Self;
|
||||
|
||||
/// Hide the window title.
|
||||
#[cfg(target_os = "macos")]
|
||||
#[must_use]
|
||||
fn hidden_title(self, hidden: bool) -> Self;
|
||||
|
||||
/// Defines the window [tabbing identifier] for macOS.
|
||||
///
|
||||
/// Windows with matching tabbing identifiers will be grouped together.
|
||||
/// If the tabbing identifier is not set, automatic tabbing will be disabled.
|
||||
///
|
||||
/// [tabbing identifier]: <https://developer.apple.com/documentation/appkit/nswindow/1644704-tabbingidentifier>
|
||||
#[cfg(target_os = "macos")]
|
||||
#[must_use]
|
||||
fn tabbing_identifier(self, identifier: &str) -> Self;
|
||||
|
||||
/// Forces a theme or uses the system settings if None was provided.
|
||||
fn theme(self, theme: Option<Theme>) -> Self;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -12,6 +12,7 @@ use crate::{
|
||||
};
|
||||
use serde::{Deserialize, Deserializer, Serialize};
|
||||
use tauri_utils::{config::WindowConfig, Theme};
|
||||
use url::Url;
|
||||
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
@@ -224,14 +225,17 @@ pub struct PendingWindow<T: UserEvent, R: Runtime<T>> {
|
||||
/// How to handle IPC calls on the webview window.
|
||||
pub ipc_handler: Option<WebviewIpcHandler<T, R>>,
|
||||
|
||||
/// The resolved URL to load on the webview.
|
||||
pub url: String,
|
||||
|
||||
/// Maps runtime id to a string menu id.
|
||||
pub menu_ids: Arc<Mutex<HashMap<MenuHash, MenuId>>>,
|
||||
|
||||
/// A HashMap mapping JS event names with associated listener ids.
|
||||
pub js_event_listeners: Arc<Mutex<HashMap<JsEventListenerKey, HashSet<u64>>>>,
|
||||
|
||||
/// A handler to decide if incoming url is allowed to navigate.
|
||||
pub navigation_handler: Option<Box<dyn Fn(Url) -> bool + Send>>,
|
||||
|
||||
/// The current webview URL.
|
||||
pub current_url: Arc<Mutex<Url>>,
|
||||
}
|
||||
|
||||
pub fn is_label_valid(label: &str) -> bool {
|
||||
@@ -268,9 +272,10 @@ impl<T: UserEvent, R: Runtime<T>> PendingWindow<T, R> {
|
||||
uri_scheme_protocols: Default::default(),
|
||||
label,
|
||||
ipc_handler: None,
|
||||
url: "tauri://localhost".to_string(),
|
||||
menu_ids: Arc::new(Mutex::new(menu_ids)),
|
||||
js_event_listeners: Default::default(),
|
||||
navigation_handler: Default::default(),
|
||||
current_url: Arc::new(Mutex::new("tauri://localhost".parse().unwrap())),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -297,9 +302,10 @@ impl<T: UserEvent, R: Runtime<T>> PendingWindow<T, R> {
|
||||
uri_scheme_protocols: Default::default(),
|
||||
label,
|
||||
ipc_handler: None,
|
||||
url: "tauri://localhost".to_string(),
|
||||
menu_ids: Arc::new(Mutex::new(menu_ids)),
|
||||
js_event_listeners: Default::default(),
|
||||
navigation_handler: Default::default(),
|
||||
current_url: Arc::new(Mutex::new("tauri://localhost".parse().unwrap())),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -340,6 +346,9 @@ pub struct JsEventListenerKey {
|
||||
/// A webview window that is not yet managed by Tauri.
|
||||
#[derive(Debug)]
|
||||
pub struct DetachedWindow<T: UserEvent, R: Runtime<T>> {
|
||||
/// The current webview URL.
|
||||
pub current_url: Arc<Mutex<Url>>,
|
||||
|
||||
/// Name of the window
|
||||
pub label: String,
|
||||
|
||||
@@ -356,6 +365,7 @@ pub struct DetachedWindow<T: UserEvent, R: Runtime<T>> {
|
||||
impl<T: UserEvent, R: Runtime<T>> Clone for DetachedWindow<T, R> {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
current_url: self.current_url.clone(),
|
||||
label: self.label.clone(),
|
||||
dispatcher: self.dispatcher.clone(),
|
||||
menu_ids: self.menu_ids.clone(),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,5 +1,54 @@
|
||||
# Changelog
|
||||
|
||||
## \[1.3.0]
|
||||
|
||||
- Added the `additional_browser_args` option to the window configuration.
|
||||
- [3dc38b15](https://www.github.com/tauri-apps/tauri/commit/3dc38b150ea8c59c8ba67fd586f921016928f47c) feat(core): expose additional_browser_args to window config (fix: [#5757](https://www.github.com/tauri-apps/tauri/pull/5757)) ([#5799](https://www.github.com/tauri-apps/tauri/pull/5799)) on 2022-12-14
|
||||
- Added the `content_protected` option to the window configuration.
|
||||
- [4ab5545b](https://www.github.com/tauri-apps/tauri/commit/4ab5545b7a831c549f3c65e74de487ede3ab7ce5) feat: add content protection api, closes [#5132](https://www.github.com/tauri-apps/tauri/pull/5132) ([#5513](https://www.github.com/tauri-apps/tauri/pull/5513)) on 2022-12-13
|
||||
- Correctly determine mime type of `.less`, `.sass` and `.styl` files.
|
||||
- [5fdf8dcb](https://www.github.com/tauri-apps/tauri/commit/5fdf8dcb8ed171d06121dceb32078a7e4f86cc64) fix(core): mime type of .less, .sass and .styl files ([#6316](https://www.github.com/tauri-apps/tauri/pull/6316)) on 2023-02-19
|
||||
- Bump minimum supported Rust version to 1.60.
|
||||
- [5fdc616d](https://www.github.com/tauri-apps/tauri/commit/5fdc616df9bea633810dcb814ac615911d77222c) feat: Use the zbus-backed of notify-rust ([#6332](https://www.github.com/tauri-apps/tauri/pull/6332)) on 2023-03-31
|
||||
- Add initial support for building `nsis` bundles on non-Windows platforms.
|
||||
- [60e6f6c3](https://www.github.com/tauri-apps/tauri/commit/60e6f6c3f1605f3064b5bb177992530ff788ccf0) feat(bundler): Add support for creating NSIS bundles on unix hosts ([#5788](https://www.github.com/tauri-apps/tauri/pull/5788)) on 2023-01-19
|
||||
- Add `nsis` bundle target
|
||||
- [c94e1326](https://www.github.com/tauri-apps/tauri/commit/c94e1326a7c0767a13128a8b1d327a00156ece12) feat(bundler): add `nsis`, closes [#4450](https://www.github.com/tauri-apps/tauri/pull/4450), closes [#2319](https://www.github.com/tauri-apps/tauri/pull/2319) ([#4674](https://www.github.com/tauri-apps/tauri/pull/4674)) on 2023-01-03
|
||||
- Added configuration to specify remote URLs allowed to access the IPC.
|
||||
- [ee71c31f](https://www.github.com/tauri-apps/tauri/commit/ee71c31fd09cc5427da6d29d37c003a914547696) feat(core): allow configuring remote domains with IPC access, closes [#5088](https://www.github.com/tauri-apps/tauri/pull/5088) ([#5918](https://www.github.com/tauri-apps/tauri/pull/5918)) on 2023-04-11
|
||||
|
||||
## \[1.2.1]
|
||||
|
||||
- Fix `allowlist > app > show/hide` always disabled when `allowlist > app > all: false`.
|
||||
- [bb251087](https://www.github.com/tauri-apps/tauri/commit/bb2510876d0bdff736d36bf3a465cdbe4ad2b90c) fix(core): extend allowlist with `app`'s allowlist, closes [#5650](https://www.github.com/tauri-apps/tauri/pull/5650) ([#5652](https://www.github.com/tauri-apps/tauri/pull/5652)) on 2022-11-18
|
||||
|
||||
## \[1.2.0]
|
||||
|
||||
- Validate `package > productName` in the tauri config and produce errors if it contains one of the following characters `/\:*?\"<>|`
|
||||
- [b9316a64](https://www.github.com/tauri-apps/tauri/commit/b9316a64eaa9348c79efafb8b94960d9b4d5b27a) fix(cli): validate `productName` in config, closes [#5233](https://www.github.com/tauri-apps/tauri/pull/5233) ([#5262](https://www.github.com/tauri-apps/tauri/pull/5262)) on 2022-09-28
|
||||
- Properly serialize HTML template tags.
|
||||
- [aec5537d](https://www.github.com/tauri-apps/tauri/commit/aec5537de0205f62b2ae5c89da04d21930a6fc2e) fix(codegen): serialize template tags, closes [#4410](https://www.github.com/tauri-apps/tauri/pull/4410) ([#5247](https://www.github.com/tauri-apps/tauri/pull/5247)) on 2022-09-28
|
||||
- `PatternKind::Isolation` is now defined even without the `isolation` feature.
|
||||
- [a178f95d](https://www.github.com/tauri-apps/tauri/commit/a178f95d68b773779b40235a3a22115a5e36aa6a) feat: config schema generator ([#5193](https://www.github.com/tauri-apps/tauri/pull/5193)) on 2022-10-28
|
||||
- Added the `app` allowlist module.
|
||||
- [39bf895b](https://www.github.com/tauri-apps/tauri/commit/39bf895b73ec6b53f5758815396ba85dda6b9c67) feat(macOS): Add application `show` and `hide` methods ([#3689](https://www.github.com/tauri-apps/tauri/pull/3689)) on 2022-10-03
|
||||
- - [7d9aa398](https://www.github.com/tauri-apps/tauri/commit/7d9aa3987efce2d697179ffc33646d086c68030c) feat: bump MSRV to 1.59 ([#5296](https://www.github.com/tauri-apps/tauri/pull/5296)) on 2022-09-28
|
||||
- Add `tauri.conf.json > bundle > publisher` field to specify the app publisher.
|
||||
- [628285c1](https://www.github.com/tauri-apps/tauri/commit/628285c1cf43f03ed62378f3b6cc0c991317526f) feat(bundler): add `publisher` field, closes [#5273](https://www.github.com/tauri-apps/tauri/pull/5273) ([#5283](https://www.github.com/tauri-apps/tauri/pull/5283)) on 2022-09-28
|
||||
- Canonicalize the return value of `platform::resource_dir`.
|
||||
- [a06dc699](https://www.github.com/tauri-apps/tauri/commit/a06dc6993148f10ff7623c9dcc81f313dd960ad0) fix(core): canonicalize resource dir to fix scope check, closes [#5196](https://www.github.com/tauri-apps/tauri/pull/5196) ([#5218](https://www.github.com/tauri-apps/tauri/pull/5218)) on 2022-09-29
|
||||
- Added `title` option on the system tray configuration (macOS only).
|
||||
- [8f1ace77](https://www.github.com/tauri-apps/tauri/commit/8f1ace77956ac3477826ceb059a191e55b3fff93) feat: expose `set_title` for MacOS tray ([#5182](https://www.github.com/tauri-apps/tauri/pull/5182)) on 2022-09-30
|
||||
- Added the `user_agent` option to the window configuration.
|
||||
- [a6c94119](https://www.github.com/tauri-apps/tauri/commit/a6c94119d8545d509723b147c273ca5edfe3729f) feat(core): expose user_agent to window config ([#5317](https://www.github.com/tauri-apps/tauri/pull/5317)) on 2022-10-02
|
||||
- Add `mime_type` module.
|
||||
- [54c337e0](https://www.github.com/tauri-apps/tauri/commit/54c337e06f3bc624c4780cf002bc54790f446c90) feat(cli): hotreload support for frontend static files, closes [#2173](https://www.github.com/tauri-apps/tauri/pull/2173) ([#5256](https://www.github.com/tauri-apps/tauri/pull/5256)) on 2022-09-28
|
||||
|
||||
## \[1.1.1]
|
||||
|
||||
- Add missing allowlist config for `set_cursor_grab`, `set_cursor_visible`, `set_cursor_icon` and `set_cursor_position` APIs.
|
||||
- [c764408d](https://www.github.com/tauri-apps/tauri/commit/c764408da7fae123edd41115bda42fa75a4731d2) fix: Add missing allowlist config for cursor apis, closes [#5207](https://www.github.com/tauri-apps/tauri/pull/5207) ([#5211](https://www.github.com/tauri-apps/tauri/pull/5211)) on 2022-09-16
|
||||
|
||||
## \[1.1.0]
|
||||
|
||||
- Allow adding `build > beforeBundleCommand` in tauri.conf.json to run a shell command before the bundling phase.
|
||||
|
||||
@@ -1,40 +1,41 @@
|
||||
[package]
|
||||
name = "tauri-utils"
|
||||
version = "1.1.0"
|
||||
version = "1.3.0"
|
||||
authors = [ "Tauri Programme within The Commons Conservancy" ]
|
||||
license = "Apache-2.0 OR MIT"
|
||||
homepage = "https://tauri.app"
|
||||
repository = "https://github.com/tauri-apps/tauri"
|
||||
description = "Utilities for Tauri"
|
||||
edition = "2021"
|
||||
rust-version = "1.57"
|
||||
rust-version = "1.60"
|
||||
exclude = [ "CHANGELOG.md", "/target" ]
|
||||
readme = "README.md"
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0", features = [ "derive" ] }
|
||||
serde_json = "1.0"
|
||||
thiserror = "1.0.30"
|
||||
serde = { version = "1", features = [ "derive" ] }
|
||||
serde_json = "1"
|
||||
thiserror = "1"
|
||||
phf = { version = "0.10", features = [ "macros" ] }
|
||||
brotli = { version = "3", optional = true, default-features = false, features = [ "std" ] }
|
||||
url = { version = "2.2", features = [ "serde" ] }
|
||||
url = { version = "2", features = [ "serde" ] }
|
||||
kuchiki = "0.8"
|
||||
html5ever = "0.25"
|
||||
proc-macro2 = { version = "1.0", optional = true }
|
||||
quote = { version = "1.0", optional = true }
|
||||
proc-macro2 = { version = "1", optional = true }
|
||||
quote = { version = "1", optional = true }
|
||||
schemars = { version = "0.8", features = [ "url" ], optional = true }
|
||||
serde_with = "1.12"
|
||||
aes-gcm = { version = "0.9", optional = true }
|
||||
serde_with = "2"
|
||||
aes-gcm = { version = "0.10", optional = true }
|
||||
getrandom = { version = "0.2", optional = true, features = [ "std" ] }
|
||||
serialize-to-javascript = { version = "=0.1.1", optional = true }
|
||||
ctor = "0.1"
|
||||
json5 = { version = "0.4", optional = true }
|
||||
toml = { version = "0.5", optional = true }
|
||||
json-patch = "0.2"
|
||||
glob = { version = "0.3.0", optional = true }
|
||||
json-patch = "1.0"
|
||||
glob = { version = "0.3", optional = true }
|
||||
walkdir = { version = "2", optional = true }
|
||||
memchr = "2.4"
|
||||
memchr = "2"
|
||||
semver = "1"
|
||||
infer = "0.12"
|
||||
|
||||
[target."cfg(target_os = \"linux\")".dependencies]
|
||||
heck = "0.4"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -174,8 +174,7 @@ impl Assets for EmbeddedAssets {
|
||||
.get(html_path.as_ref())
|
||||
.copied()
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.into_iter(),
|
||||
.flatten(),
|
||||
)
|
||||
.copied(),
|
||||
)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -34,6 +34,8 @@ use std::{
|
||||
/// Items to help with parsing content into a [`Config`].
|
||||
pub mod parse;
|
||||
|
||||
use crate::TitleBarStyle;
|
||||
|
||||
pub use self::parse::parse;
|
||||
|
||||
/// An URL to open on a Tauri webview window.
|
||||
@@ -53,7 +55,7 @@ pub enum WindowUrl {
|
||||
impl fmt::Display for WindowUrl {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::External(url) => write!(f, "{}", url),
|
||||
Self::External(url) => write!(f, "{url}"),
|
||||
Self::App(path) => write!(f, "{}", path.display()),
|
||||
}
|
||||
}
|
||||
@@ -76,6 +78,8 @@ pub enum BundleType {
|
||||
AppImage,
|
||||
/// The Microsoft Installer bundle (.msi).
|
||||
Msi,
|
||||
/// The NSIS bundle (.exe).
|
||||
Nsis,
|
||||
/// The macOS application bundle (.app).
|
||||
App,
|
||||
/// The Apple Disk Image bundle (.dmg).
|
||||
@@ -93,6 +97,7 @@ impl Display for BundleType {
|
||||
Self::Deb => "deb",
|
||||
Self::AppImage => "appimage",
|
||||
Self::Msi => "msi",
|
||||
Self::Nsis => "nsis",
|
||||
Self::App => "app",
|
||||
Self::Dmg => "dmg",
|
||||
Self::Updater => "updater",
|
||||
@@ -120,10 +125,11 @@ impl<'de> Deserialize<'de> for BundleType {
|
||||
"deb" => Ok(Self::Deb),
|
||||
"appimage" => Ok(Self::AppImage),
|
||||
"msi" => Ok(Self::Msi),
|
||||
"nsis" => Ok(Self::Nsis),
|
||||
"app" => Ok(Self::App),
|
||||
"dmg" => Ok(Self::Dmg),
|
||||
"updater" => Ok(Self::Updater),
|
||||
_ => Err(DeError::custom(format!("unknown bundle target '{}'", s))),
|
||||
_ => Err(DeError::custom(format!("unknown bundle target '{s}'"))),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -221,7 +227,7 @@ impl<'de> Deserialize<'de> for BundleTarget {
|
||||
|
||||
match BundleTargetInner::deserialize(deserializer)? {
|
||||
BundleTargetInner::All(s) if s.to_lowercase() == "all" => Ok(Self::All),
|
||||
BundleTargetInner::All(t) => Err(DeError::custom(format!("invalid bundle type {}", t))),
|
||||
BundleTargetInner::All(t) => Err(DeError::custom(format!("invalid bundle type {t}"))),
|
||||
BundleTargetInner::List(l) => Ok(Self::List(l)),
|
||||
BundleTargetInner::One(t) => Ok(Self::One(t)),
|
||||
}
|
||||
@@ -241,6 +247,8 @@ impl BundleTarget {
|
||||
}
|
||||
|
||||
/// Configuration for AppImage bundles.
|
||||
///
|
||||
/// See more: https://tauri.app/v1/api/config#appimageconfig
|
||||
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
@@ -252,6 +260,8 @@ pub struct AppImageConfig {
|
||||
}
|
||||
|
||||
/// Configuration for Debian (.deb) bundles.
|
||||
///
|
||||
/// See more: https://tauri.app/v1/api/config#debconfig
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
@@ -276,6 +286,8 @@ where
|
||||
}
|
||||
|
||||
/// Configuration for the macOS bundles.
|
||||
///
|
||||
/// See more: https://tauri.app/v1/api/config#macconfig
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
@@ -332,6 +344,8 @@ fn minimum_system_version() -> Option<String> {
|
||||
}
|
||||
|
||||
/// Configuration for a target language for the WiX build.
|
||||
///
|
||||
/// See more: https://tauri.app/v1/api/config#wixlanguageconfig
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
@@ -361,6 +375,8 @@ impl Default for WixLanguage {
|
||||
}
|
||||
|
||||
/// Configuration for the MSI bundle using WiX.
|
||||
///
|
||||
/// See more: https://tauri.app/v1/api/config#wixconfig
|
||||
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
@@ -414,6 +430,71 @@ pub struct WixConfig {
|
||||
pub dialog_image_path: Option<PathBuf>,
|
||||
}
|
||||
|
||||
/// Configuration for the Installer bundle using NSIS.
|
||||
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
pub struct NsisConfig {
|
||||
/// The path to the license file to render on the installer.
|
||||
pub license: Option<PathBuf>,
|
||||
/// The path to a bitmap file to display on the header of installers pages.
|
||||
///
|
||||
/// The recommended dimensions are 150px x 57px.
|
||||
#[serde(alias = "header-image")]
|
||||
pub header_image: Option<PathBuf>,
|
||||
/// The path to a bitmap file for the Welcome page and the Finish page.
|
||||
///
|
||||
/// The recommended dimensions are 164px x 314px.
|
||||
#[serde(alias = "sidebar-image")]
|
||||
pub sidebar_image: Option<PathBuf>,
|
||||
/// The path to an icon file used as the installer icon.
|
||||
#[serde(alias = "install-icon")]
|
||||
pub installer_icon: Option<PathBuf>,
|
||||
/// Whether the installation will be for all users or just the current user.
|
||||
#[serde(default, alias = "install-mode")]
|
||||
pub install_mode: NSISInstallerMode,
|
||||
/// A list of installer languages.
|
||||
/// By default the OS language is used. If the OS language is not in the list of languages, the first language will be used.
|
||||
/// To allow the user to select the language, set `display_language_selector` to `true`.
|
||||
///
|
||||
/// See <https://github.com/kichik/nsis/tree/9465c08046f00ccb6eda985abbdbf52c275c6c4d/Contrib/Language%20files> for the complete list of languages.
|
||||
pub languages: Option<Vec<String>>,
|
||||
/// Whether to display a language selector dialog before the installer and uninstaller windows are rendered or not.
|
||||
/// By default the OS language is selected, with a fallback to the first language in the `languages` array.
|
||||
#[serde(default, alias = "display-language-selector")]
|
||||
pub display_language_selector: bool,
|
||||
}
|
||||
|
||||
/// Install Modes for the NSIS installer.
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
pub enum NSISInstallerMode {
|
||||
/// Default mode for the installer.
|
||||
///
|
||||
/// Install the app by default in a directory that doesn't require Administrator access.
|
||||
///
|
||||
/// Installer metadata will be saved under the `HKCU` registry path.
|
||||
CurrentUser,
|
||||
/// Install the app by default in the `Program Files` folder directory requires Administrator
|
||||
/// access for the installation.
|
||||
///
|
||||
/// Installer metadata will be saved under the `HKLM` registry path.
|
||||
PerMachine,
|
||||
/// Combines both modes and allows the user to choose at install time
|
||||
/// whether to install for the current user or per machine. Note that this mode
|
||||
/// will require Administrator access even if the user wants to install it for the current user only.
|
||||
///
|
||||
/// Installer metadata will be saved under the `HKLM` or `HKCU` registry path based on the user's choice.
|
||||
Both,
|
||||
}
|
||||
|
||||
impl Default for NSISInstallerMode {
|
||||
fn default() -> Self {
|
||||
Self::CurrentUser
|
||||
}
|
||||
}
|
||||
|
||||
/// Install modes for the Webview2 runtime.
|
||||
/// Note that for the updater bundle [`Self::DownloadBootstrapper`] is used.
|
||||
///
|
||||
@@ -425,7 +506,7 @@ pub enum WebviewInstallMode {
|
||||
/// Do not install the Webview2 as part of the Windows Installer.
|
||||
Skip,
|
||||
/// Download the bootstrapper and run it.
|
||||
/// Requires internet connection.
|
||||
/// Requires an internet connection.
|
||||
/// Results in a smaller installer size, but is not recommended on Windows 7.
|
||||
DownloadBootstrapper {
|
||||
/// Instructs the installer to run the bootstrapper in silent mode. Defaults to `true`.
|
||||
@@ -433,7 +514,7 @@ pub enum WebviewInstallMode {
|
||||
silent: bool,
|
||||
},
|
||||
/// Embed the bootstrapper and run it.
|
||||
/// Requires internet connection.
|
||||
/// Requires an internet connection.
|
||||
/// Increases the installer size by around 1.8MB, but offers better support on Windows 7.
|
||||
EmbedBootstrapper {
|
||||
/// Instructs the installer to run the bootstrapper in silent mode. Defaults to `true`.
|
||||
@@ -441,7 +522,7 @@ pub enum WebviewInstallMode {
|
||||
silent: bool,
|
||||
},
|
||||
/// Embed the offline installer and run it.
|
||||
/// Does not require internet connection.
|
||||
/// Does not require an internet connection.
|
||||
/// Increases the installer size by around 127MB.
|
||||
OfflineInstaller {
|
||||
/// Instructs the installer to run the installer in silent mode. Defaults to `true`.
|
||||
@@ -472,6 +553,8 @@ impl Default for WebviewInstallMode {
|
||||
}
|
||||
|
||||
/// Windows bundler configuration.
|
||||
///
|
||||
/// See more: https://tauri.app/v1/api/config#windowsconfig
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
@@ -510,6 +593,8 @@ pub struct WindowsConfig {
|
||||
pub allow_downgrades: bool,
|
||||
/// Configuration for the MSI generated with WiX.
|
||||
pub wix: Option<WixConfig>,
|
||||
/// Configuration for the installer generated with NSIS.
|
||||
pub nsis: Option<NsisConfig>,
|
||||
}
|
||||
|
||||
impl Default for WindowsConfig {
|
||||
@@ -523,6 +608,7 @@ impl Default for WindowsConfig {
|
||||
webview_fixed_runtime_path: None,
|
||||
allow_downgrades: default_allow_downgrades(),
|
||||
wix: None,
|
||||
nsis: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -532,6 +618,8 @@ fn default_allow_downgrades() -> bool {
|
||||
}
|
||||
|
||||
/// Configuration for tauri-bundler.
|
||||
///
|
||||
/// See more: https://tauri.app/v1/api/config#bundleconfig
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
@@ -540,7 +628,7 @@ pub struct BundleConfig {
|
||||
/// Whether Tauri should bundle your application or just output the executable.
|
||||
#[serde(default)]
|
||||
pub active: bool,
|
||||
/// The bundle targets, currently supports ["deb", "appimage", "msi", "app", "dmg", "updater"] or "all".
|
||||
/// The bundle targets, currently supports ["deb", "appimage", "nsis", "msi", "app", "dmg", "updater"] or "all".
|
||||
#[serde(default)]
|
||||
pub targets: BundleTarget,
|
||||
/// The application identifier in reverse domain name notation (e.g. `com.tauri.example`).
|
||||
@@ -549,6 +637,9 @@ pub struct BundleConfig {
|
||||
/// This string must contain only alphanumeric characters (A–Z, a–z, and 0–9), hyphens (-),
|
||||
/// and periods (.).
|
||||
pub identifier: String,
|
||||
/// The application's publisher. Defaults to the second element in the identifier string.
|
||||
/// Currently maps to the Manufacturer property of the Windows Installer.
|
||||
pub publisher: Option<String>,
|
||||
/// The app's icons
|
||||
#[serde(default)]
|
||||
pub icon: Vec<String>,
|
||||
@@ -717,6 +808,8 @@ pub struct CliArg {
|
||||
}
|
||||
|
||||
/// describes a CLI configuration
|
||||
///
|
||||
/// See more: https://tauri.app/v1/api/config#cliconfig
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
@@ -780,6 +873,8 @@ impl CliConfig {
|
||||
}
|
||||
|
||||
/// The window configuration object.
|
||||
///
|
||||
/// See more: https://tauri.app/v1/api/config#windowconfig
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
@@ -791,6 +886,9 @@ pub struct WindowConfig {
|
||||
/// The window webview URL.
|
||||
#[serde(default)]
|
||||
pub url: WindowUrl,
|
||||
/// The user agent for the webview
|
||||
#[serde(alias = "user-agent")]
|
||||
pub user_agent: Option<String>,
|
||||
/// Whether the file drop is enabled or not on the webview. By default it is enabled.
|
||||
///
|
||||
/// Disabling it is required to use drag and drop on the frontend on Windows.
|
||||
@@ -830,7 +928,7 @@ pub struct WindowConfig {
|
||||
/// Whether the window starts as fullscreen or not.
|
||||
#[serde(default)]
|
||||
pub fullscreen: bool,
|
||||
/// Whether the window will be initially hidden or focused.
|
||||
/// Whether the window will be initially focused or not.
|
||||
#[serde(default = "default_focus")]
|
||||
pub focus: bool,
|
||||
/// Whether the window is transparent or not.
|
||||
@@ -851,11 +949,35 @@ pub struct WindowConfig {
|
||||
/// Whether the window should always be on top of other windows.
|
||||
#[serde(default, alias = "always-on-top")]
|
||||
pub always_on_top: bool,
|
||||
/// Whether or not the window icon should be added to the taskbar.
|
||||
/// Prevents the window contents from being captured by other apps.
|
||||
#[serde(default, alias = "content-protected")]
|
||||
pub content_protected: bool,
|
||||
/// If `true`, hides the window icon from the taskbar on Windows and Linux.
|
||||
#[serde(default, alias = "skip-taskbar")]
|
||||
pub skip_taskbar: bool,
|
||||
/// The initial window theme. Defaults to the system theme. Only implemented on Windows and macOS 10.14+.
|
||||
pub theme: Option<crate::Theme>,
|
||||
/// The style of the macOS title bar.
|
||||
#[serde(default, alias = "title-bar-style")]
|
||||
pub title_bar_style: TitleBarStyle,
|
||||
/// If `true`, sets the window title to be hidden on macOS.
|
||||
#[serde(default, alias = "hidden-title")]
|
||||
pub hidden_title: bool,
|
||||
/// Whether clicking an inactive window also clicks through to the webview on macOS.
|
||||
#[serde(default, alias = "accept-first-mouse")]
|
||||
pub accept_first_mouse: bool,
|
||||
/// Defines the window [tabbing identifier] for macOS.
|
||||
///
|
||||
/// Windows with matching tabbing identifiers will be grouped together.
|
||||
/// If the tabbing identifier is not set, automatic tabbing will be disabled.
|
||||
///
|
||||
/// [tabbing identifier]: <https://developer.apple.com/documentation/appkit/nswindow/1644704-tabbingidentifier>
|
||||
#[serde(default, alias = "tabbing-identifier")]
|
||||
pub tabbing_identifier: Option<String>,
|
||||
/// Defines additional browser arguments on Windows. By default wry passes `--disable-features=msWebOOUI,msPdfOOUI,msSmartScreenProtection`
|
||||
/// so if you use this method, you also need to disable these components by yourself if you want.
|
||||
#[serde(default, alias = "additional-browser-args")]
|
||||
pub additional_browser_args: Option<String>,
|
||||
}
|
||||
|
||||
impl Default for WindowConfig {
|
||||
@@ -863,6 +985,7 @@ impl Default for WindowConfig {
|
||||
Self {
|
||||
label: default_window_label(),
|
||||
url: WindowUrl::default(),
|
||||
user_agent: None,
|
||||
file_drop_enabled: default_file_drop_enabled(),
|
||||
center: false,
|
||||
x: None,
|
||||
@@ -882,8 +1005,14 @@ impl Default for WindowConfig {
|
||||
visible: default_visible(),
|
||||
decorations: default_decorations(),
|
||||
always_on_top: false,
|
||||
content_protected: false,
|
||||
skip_taskbar: false,
|
||||
theme: None,
|
||||
title_bar_style: Default::default(),
|
||||
hidden_title: false,
|
||||
accept_first_mouse: false,
|
||||
tabbing_identifier: None,
|
||||
additional_browser_args: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -955,7 +1084,7 @@ impl CspDirectiveSources {
|
||||
/// Whether the given source is configured on this directive or not.
|
||||
pub fn contains(&self, source: &str) -> bool {
|
||||
match self {
|
||||
Self::Inline(s) => s.contains(&format!("{} ", source)) || s.contains(&format!(" {}", source)),
|
||||
Self::Inline(s) => s.contains(&format!("{source} ")) || s.contains(&format!(" {source}")),
|
||||
Self::List(l) => l.contains(&source.into()),
|
||||
}
|
||||
}
|
||||
@@ -1021,7 +1150,7 @@ impl From<Csp> for HashMap<String, CspDirectiveSources> {
|
||||
impl Display for Csp {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::Policy(s) => write!(f, "{}", s),
|
||||
Self::Policy(s) => write!(f, "{s}"),
|
||||
Self::DirectiveMap(m) => {
|
||||
let len = m.len();
|
||||
let mut i = 0;
|
||||
@@ -1067,7 +1196,28 @@ impl Default for DisabledCspModificationKind {
|
||||
}
|
||||
}
|
||||
|
||||
/// External command access definition.
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
pub struct RemoteDomainAccessScope {
|
||||
/// The URL scheme to allow. By default, all schemas are allowed.
|
||||
pub scheme: Option<String>,
|
||||
/// The domain to allow.
|
||||
pub domain: String,
|
||||
/// The list of window labels this scope applies to.
|
||||
pub windows: Vec<String>,
|
||||
/// The list of plugins that are allowed in this scope.
|
||||
#[serde(default)]
|
||||
pub plugins: Vec<String>,
|
||||
/// Enables access to the Tauri API.
|
||||
#[serde(default, rename = "enableTauriAPI", alias = "enable-tauri-api")]
|
||||
pub enable_tauri_api: bool,
|
||||
}
|
||||
|
||||
/// Security configuration.
|
||||
///
|
||||
/// See more: https://tauri.app/v1/api/config#securityconfig
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
@@ -1102,6 +1252,20 @@ pub struct SecurityConfig {
|
||||
/// Your application might be vulnerable to XSS attacks without this Tauri protection.
|
||||
#[serde(default, alias = "dangerous-disable-asset-csp-modification")]
|
||||
pub dangerous_disable_asset_csp_modification: DisabledCspModificationKind,
|
||||
/// Allow external domains to send command to Tauri.
|
||||
///
|
||||
/// By default, external domains do not have access to `window.__TAURI__`, which means they cannot
|
||||
/// communicate with the commands defined in Rust. This prevents attacks where an externally
|
||||
/// loaded malicious or compromised sites could start executing commands on the user's device.
|
||||
///
|
||||
/// This configuration allows a set of external domains to have access to the Tauri commands.
|
||||
/// When you configure a domain to be allowed to access the IPC, all subpaths are allowed. Subdomains are not allowed.
|
||||
///
|
||||
/// **WARNING:** Only use this option if you either have internal checks against malicious
|
||||
/// external sites or you can trust the allowed external sites. You application might be
|
||||
/// vulnerable to dangerous Tauri command related attacks otherwise.
|
||||
#[serde(default, alias = "dangerous-remote-domain-ipc-access")]
|
||||
pub dangerous_remote_domain_ipc_access: Vec<RemoteDomainAccessScope>,
|
||||
}
|
||||
|
||||
/// Defines an allowlist type.
|
||||
@@ -1126,7 +1290,8 @@ macro_rules! check_feature {
|
||||
/// Each pattern can start with a variable that resolves to a system base directory.
|
||||
/// The variables are: `$AUDIO`, `$CACHE`, `$CONFIG`, `$DATA`, `$LOCALDATA`, `$DESKTOP`,
|
||||
/// `$DOCUMENT`, `$DOWNLOAD`, `$EXE`, `$FONT`, `$HOME`, `$PICTURE`, `$PUBLIC`, `$RUNTIME`,
|
||||
/// `$TEMPLATE`, `$VIDEO`, `$RESOURCE`, `$APP`, `$LOG`, `$TEMP`.
|
||||
/// `$TEMPLATE`, `$VIDEO`, `$RESOURCE`, `$APP`, `$LOG`, `$TEMP`, `$APPCONFIG`, `$APPDATA`,
|
||||
/// `$APPLOCALDATA`, `$APPCACHE`, `$APPLOG`.
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[serde(untagged)]
|
||||
@@ -1170,6 +1335,8 @@ impl FsAllowlistScope {
|
||||
}
|
||||
|
||||
/// Allowlist for the file system APIs.
|
||||
///
|
||||
/// See more: https://tauri.app/v1/api/config#fsallowlistconfig
|
||||
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
@@ -1249,6 +1416,8 @@ impl Allowlist for FsAllowlistConfig {
|
||||
}
|
||||
|
||||
/// Allowlist for the window APIs.
|
||||
///
|
||||
/// See more: https://tauri.app/v1/api/config#windowallowlistconfig
|
||||
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
@@ -1298,6 +1467,9 @@ pub struct WindowAllowlistConfig {
|
||||
/// Allows setting the always_on_top flag of the window.
|
||||
#[serde(default, alias = "set-always-on-top")]
|
||||
pub set_always_on_top: bool,
|
||||
/// Allows preventing the window contents from being captured by other apps.
|
||||
#[serde(default, alias = "set-content-protected")]
|
||||
pub set_content_protected: bool,
|
||||
/// Allows setting the window size.
|
||||
#[serde(default, alias = "set-size")]
|
||||
pub set_size: bool,
|
||||
@@ -1322,6 +1494,21 @@ pub struct WindowAllowlistConfig {
|
||||
/// Allows setting the skip_taskbar flag of the window.
|
||||
#[serde(default, alias = "set-skip-taskbar")]
|
||||
pub set_skip_taskbar: bool,
|
||||
/// Allows grabbing the cursor.
|
||||
#[serde(default, alias = "set-cursor-grab")]
|
||||
pub set_cursor_grab: bool,
|
||||
/// Allows setting the cursor visibility.
|
||||
#[serde(default, alias = "set-cursor-visible")]
|
||||
pub set_cursor_visible: bool,
|
||||
/// Allows changing the cursor icon.
|
||||
#[serde(default, alias = "set-cursor-icon")]
|
||||
pub set_cursor_icon: bool,
|
||||
/// Allows setting the cursor position.
|
||||
#[serde(default, alias = "set-cursor-position")]
|
||||
pub set_cursor_position: bool,
|
||||
/// Allows ignoring cursor events.
|
||||
#[serde(default, alias = "set-ignore-cursor-events")]
|
||||
pub set_ignore_cursor_events: bool,
|
||||
/// Allows start dragging on the window.
|
||||
#[serde(default, alias = "start-dragging")]
|
||||
pub start_dragging: bool,
|
||||
@@ -1348,6 +1535,7 @@ impl Allowlist for WindowAllowlistConfig {
|
||||
close: true,
|
||||
set_decorations: true,
|
||||
set_always_on_top: true,
|
||||
set_content_protected: false,
|
||||
set_size: true,
|
||||
set_min_size: true,
|
||||
set_max_size: true,
|
||||
@@ -1356,6 +1544,11 @@ impl Allowlist for WindowAllowlistConfig {
|
||||
set_focus: true,
|
||||
set_icon: true,
|
||||
set_skip_taskbar: true,
|
||||
set_cursor_grab: true,
|
||||
set_cursor_visible: true,
|
||||
set_cursor_icon: true,
|
||||
set_cursor_position: true,
|
||||
set_ignore_cursor_events: true,
|
||||
start_dragging: true,
|
||||
print: true,
|
||||
};
|
||||
@@ -1393,6 +1586,12 @@ impl Allowlist for WindowAllowlistConfig {
|
||||
set_always_on_top,
|
||||
"window-set-always-on-top"
|
||||
);
|
||||
check_feature!(
|
||||
self,
|
||||
features,
|
||||
set_content_protected,
|
||||
"window-set-content-protected"
|
||||
);
|
||||
check_feature!(self, features, set_size, "window-set-size");
|
||||
check_feature!(self, features, set_min_size, "window-set-min-size");
|
||||
check_feature!(self, features, set_max_size, "window-set-max-size");
|
||||
@@ -1401,6 +1600,26 @@ impl Allowlist for WindowAllowlistConfig {
|
||||
check_feature!(self, features, set_focus, "window-set-focus");
|
||||
check_feature!(self, features, set_icon, "window-set-icon");
|
||||
check_feature!(self, features, set_skip_taskbar, "window-set-skip-taskbar");
|
||||
check_feature!(self, features, set_cursor_grab, "window-set-cursor-grab");
|
||||
check_feature!(
|
||||
self,
|
||||
features,
|
||||
set_cursor_visible,
|
||||
"window-set-cursor-visible"
|
||||
);
|
||||
check_feature!(self, features, set_cursor_icon, "window-set-cursor-icon");
|
||||
check_feature!(
|
||||
self,
|
||||
features,
|
||||
set_cursor_position,
|
||||
"window-set-cursor-position"
|
||||
);
|
||||
check_feature!(
|
||||
self,
|
||||
features,
|
||||
set_ignore_cursor_events,
|
||||
"window-set-ignore-cursor-events"
|
||||
);
|
||||
check_feature!(self, features, start_dragging, "window-start-dragging");
|
||||
check_feature!(self, features, print, "window-print");
|
||||
features
|
||||
@@ -1422,7 +1641,8 @@ pub struct ShellAllowedCommand {
|
||||
/// It can start with a variable that resolves to a system base directory.
|
||||
/// The variables are: `$AUDIO`, `$CACHE`, `$CONFIG`, `$DATA`, `$LOCALDATA`, `$DESKTOP`,
|
||||
/// `$DOCUMENT`, `$DOWNLOAD`, `$EXE`, `$FONT`, `$HOME`, `$PICTURE`, `$PUBLIC`, `$RUNTIME`,
|
||||
/// `$TEMPLATE`, `$VIDEO`, `$RESOURCE`, `$APP`, `$LOG`, `$TEMP`.
|
||||
/// `$TEMPLATE`, `$VIDEO`, `$RESOURCE`, `$APP`, `$LOG`, `$TEMP`, `$APPCONFIG`, `$APPDATA`,
|
||||
/// `$APPLOCALDATA`, `$APPCACHE`, `$APPLOG`.
|
||||
#[serde(rename = "cmd", default)] // use default just so the schema doesn't flag it as required
|
||||
pub command: PathBuf,
|
||||
|
||||
@@ -1527,7 +1747,7 @@ pub struct ShellAllowlistScope(pub Vec<ShellAllowedCommand>);
|
||||
pub enum ShellAllowlistOpen {
|
||||
/// If the shell open API should be enabled.
|
||||
///
|
||||
/// If enabled, the default validation regex (`^https?://`) is used.
|
||||
/// If enabled, the default validation regex (`^((mailto:\w+)|(tel:\w+)|(https?://\w+)).+`) is used.
|
||||
Flag(bool),
|
||||
|
||||
/// Enable the shell open API, with a custom regex that the opened path must match against.
|
||||
@@ -1544,6 +1764,8 @@ impl Default for ShellAllowlistOpen {
|
||||
}
|
||||
|
||||
/// Allowlist for the shell APIs.
|
||||
///
|
||||
/// See more: https://tauri.app/v1/api/config#shellallowlistconfig
|
||||
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
@@ -1600,6 +1822,8 @@ impl Allowlist for ShellAllowlistConfig {
|
||||
}
|
||||
|
||||
/// Allowlist for the dialog APIs.
|
||||
///
|
||||
/// See more: https://tauri.app/v1/api/config#dialogallowlistconfig
|
||||
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
@@ -1668,6 +1892,8 @@ impl Allowlist for DialogAllowlistConfig {
|
||||
pub struct HttpAllowlistScope(pub Vec<Url>);
|
||||
|
||||
/// Allowlist for the HTTP APIs.
|
||||
///
|
||||
/// See more: https://tauri.app/v1/api/config#httpallowlistconfig
|
||||
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
@@ -1707,6 +1933,8 @@ impl Allowlist for HttpAllowlistConfig {
|
||||
}
|
||||
|
||||
/// Allowlist for the notification APIs.
|
||||
///
|
||||
/// See more: https://tauri.app/v1/api/config#notificationallowlistconfig
|
||||
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
@@ -1734,6 +1962,8 @@ impl Allowlist for NotificationAllowlistConfig {
|
||||
}
|
||||
|
||||
/// Allowlist for the global shortcut APIs.
|
||||
///
|
||||
/// See more: https://tauri.app/v1/api/config#globalshortcutallowlistconfig
|
||||
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
@@ -1761,6 +1991,8 @@ impl Allowlist for GlobalShortcutAllowlistConfig {
|
||||
}
|
||||
|
||||
/// Allowlist for the OS APIs.
|
||||
///
|
||||
/// See more: https://tauri.app/v1/api/config#osallowlistconfig
|
||||
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
@@ -1788,6 +2020,8 @@ impl Allowlist for OsAllowlistConfig {
|
||||
}
|
||||
|
||||
/// Allowlist for the path APIs.
|
||||
///
|
||||
/// See more: https://tauri.app/v1/api/config#pathallowlistconfig
|
||||
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
@@ -1815,6 +2049,8 @@ impl Allowlist for PathAllowlistConfig {
|
||||
}
|
||||
|
||||
/// Allowlist for the custom protocols.
|
||||
///
|
||||
/// See more: https://tauri.app/v1/api/config#protocolallowlistconfig
|
||||
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
@@ -1854,6 +2090,8 @@ impl Allowlist for ProtocolAllowlistConfig {
|
||||
}
|
||||
|
||||
/// Allowlist for the process APIs.
|
||||
///
|
||||
/// See more: https://tauri.app/v1/api/config#processallowlistconfig
|
||||
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
@@ -1911,6 +2149,8 @@ impl Allowlist for ProcessAllowlistConfig {
|
||||
}
|
||||
|
||||
/// Allowlist for the clipboard APIs.
|
||||
///
|
||||
/// See more: https://tauri.app/v1/api/config#clipboardallowlistconfig
|
||||
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
@@ -1950,7 +2190,58 @@ impl Allowlist for ClipboardAllowlistConfig {
|
||||
}
|
||||
}
|
||||
|
||||
/// Allowlist configuration.
|
||||
/// Allowlist for the app APIs.
|
||||
///
|
||||
/// See more: https://tauri.app/v1/api/config#appallowlistconfig
|
||||
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
pub struct AppAllowlistConfig {
|
||||
/// Use this flag to enable all app APIs.
|
||||
#[serde(default)]
|
||||
pub all: bool,
|
||||
/// Enables the app's `show` API.
|
||||
#[serde(default)]
|
||||
pub show: bool,
|
||||
/// Enables the app's `hide` API.
|
||||
#[serde(default)]
|
||||
pub hide: bool,
|
||||
}
|
||||
|
||||
impl Allowlist for AppAllowlistConfig {
|
||||
fn all_features() -> Vec<&'static str> {
|
||||
let allowlist = Self {
|
||||
all: false,
|
||||
show: true,
|
||||
hide: true,
|
||||
};
|
||||
let mut features = allowlist.to_features();
|
||||
features.push("app-all");
|
||||
features
|
||||
}
|
||||
|
||||
fn to_features(&self) -> Vec<&'static str> {
|
||||
if self.all {
|
||||
vec!["app-all"]
|
||||
} else {
|
||||
let mut features = Vec::new();
|
||||
check_feature!(self, features, show, "app-show");
|
||||
check_feature!(self, features, hide, "app-hide");
|
||||
features
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Allowlist configuration. The allowlist is a translation of the [Cargo allowlist features](https://docs.rs/tauri/latest/tauri/#cargo-allowlist-features).
|
||||
///
|
||||
/// # Notes
|
||||
///
|
||||
/// - Endpoints that don't have their own allowlist option are enabled by default.
|
||||
/// - There is only "opt-in", no "opt-out". Setting an option to `false` has no effect.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// - * [`"app-all": true`](https://tauri.app/v1/api/config/#appallowlistconfig.all) will make the [hide](https://tauri.app/v1/api/js/app#hide) endpoint be available regardless of whether `hide` is set to `false` or `true` in the allowlist.
|
||||
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
@@ -1994,6 +2285,9 @@ pub struct AllowlistConfig {
|
||||
/// Clipboard APIs allowlist.
|
||||
#[serde(default)]
|
||||
pub clipboard: ClipboardAllowlistConfig,
|
||||
/// App APIs allowlist.
|
||||
#[serde(default)]
|
||||
pub app: AppAllowlistConfig,
|
||||
}
|
||||
|
||||
impl Allowlist for AllowlistConfig {
|
||||
@@ -2011,6 +2305,7 @@ impl Allowlist for AllowlistConfig {
|
||||
features.extend(ProtocolAllowlistConfig::all_features());
|
||||
features.extend(ProcessAllowlistConfig::all_features());
|
||||
features.extend(ClipboardAllowlistConfig::all_features());
|
||||
features.extend(AppAllowlistConfig::all_features());
|
||||
features
|
||||
}
|
||||
|
||||
@@ -2031,6 +2326,7 @@ impl Allowlist for AllowlistConfig {
|
||||
features.extend(self.protocol.to_features());
|
||||
features.extend(self.process.to_features());
|
||||
features.extend(self.clipboard.to_features());
|
||||
features.extend(self.app.to_features());
|
||||
features
|
||||
}
|
||||
}
|
||||
@@ -2045,7 +2341,6 @@ pub enum PatternKind {
|
||||
/// Brownfield pattern.
|
||||
Brownfield,
|
||||
/// Isolation pattern. Recommended for security purposes.
|
||||
#[cfg(feature = "isolation")]
|
||||
Isolation {
|
||||
/// The dir containing the index.html file that contains the secure isolation application.
|
||||
dir: PathBuf,
|
||||
@@ -2059,6 +2354,8 @@ impl Default for PatternKind {
|
||||
}
|
||||
|
||||
/// The Tauri configuration object.
|
||||
///
|
||||
/// See more: https://tauri.app/v1/api/config#tauriconfig
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
@@ -2123,7 +2420,6 @@ impl TauriConfig {
|
||||
if self.macos_private_api {
|
||||
features.push("macos-private-api");
|
||||
}
|
||||
#[cfg(feature = "isolation")]
|
||||
if let PatternKind::Isolation { .. } = self.pattern {
|
||||
features.push("isolation");
|
||||
}
|
||||
@@ -2172,7 +2468,7 @@ pub enum WindowsUpdateInstallMode {
|
||||
/// Specifies there's a basic UI during the installation process, including a final dialog box at the end.
|
||||
BasicUi,
|
||||
/// The quiet mode means there's no user interaction required.
|
||||
/// Requires admin privileges if the installer does.
|
||||
/// Requires admin privileges if the installer does (WiX).
|
||||
Quiet,
|
||||
/// Specifies unattended mode, which means the installation only shows a progress bar.
|
||||
Passive,
|
||||
@@ -2231,25 +2527,31 @@ impl<'de> Deserialize<'de> for WindowsUpdateInstallMode {
|
||||
"quiet" => Ok(Self::Quiet),
|
||||
"passive" => Ok(Self::Passive),
|
||||
_ => Err(DeError::custom(format!(
|
||||
"unknown update install mode '{}'",
|
||||
s
|
||||
"unknown update install mode '{s}'"
|
||||
))),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The updater configuration for Windows.
|
||||
///
|
||||
/// See more: https://tauri.app/v1/api/config#updaterwindowsconfig
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Default, PartialEq, Eq, Clone, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
pub struct UpdaterWindowsConfig {
|
||||
/// Additional arguments given to the NSIS or WiX installer.
|
||||
#[serde(default, alias = "installer-args")]
|
||||
pub installer_args: Vec<String>,
|
||||
/// The installation mode for the update on Windows. Defaults to `passive`.
|
||||
#[serde(default, alias = "install-mode")]
|
||||
pub install_mode: WindowsUpdateInstallMode,
|
||||
}
|
||||
|
||||
/// The Updater configuration object.
|
||||
///
|
||||
/// See more: https://tauri.app/v1/api/config#updaterconfig
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
@@ -2329,6 +2631,8 @@ impl Default for UpdaterConfig {
|
||||
}
|
||||
|
||||
/// Configuration for application system tray icon.
|
||||
///
|
||||
/// See more: https://tauri.app/v1/api/config#systemtrayconfig
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
@@ -2346,6 +2650,8 @@ pub struct SystemTrayConfig {
|
||||
alias = "menu-on-left-click"
|
||||
)]
|
||||
pub menu_on_left_click: bool,
|
||||
/// Title for MacOS tray
|
||||
pub title: Option<String>,
|
||||
}
|
||||
|
||||
fn default_tray_menu_on_left_click() -> bool {
|
||||
@@ -2374,7 +2680,7 @@ pub enum AppUrl {
|
||||
impl std::fmt::Display for AppUrl {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Url(url) => write!(f, "{}", url),
|
||||
Self::Url(url) => write!(f, "{url}"),
|
||||
Self::Files(files) => write!(f, "{}", serde_json::to_string(files).unwrap()),
|
||||
}
|
||||
}
|
||||
@@ -2416,6 +2722,8 @@ pub enum HookCommand {
|
||||
}
|
||||
|
||||
/// The Build configuration object.
|
||||
///
|
||||
/// See more: https://tauri.app/v1/api/config#buildconfig
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
@@ -2513,9 +2821,9 @@ impl<'d> serde::Deserialize<'d> for PackageVersion {
|
||||
let path = PathBuf::from(value);
|
||||
if path.exists() {
|
||||
let json_str = read_to_string(&path)
|
||||
.map_err(|e| DeError::custom(format!("failed to read version JSON file: {}", e)))?;
|
||||
.map_err(|e| DeError::custom(format!("failed to read version JSON file: {e}")))?;
|
||||
let package_json: serde_json::Value = serde_json::from_str(&json_str)
|
||||
.map_err(|e| DeError::custom(format!("failed to read version JSON file: {}", e)))?;
|
||||
.map_err(|e| DeError::custom(format!("failed to read version JSON file: {e}")))?;
|
||||
if let Some(obj) = package_json.as_object() {
|
||||
let version = obj
|
||||
.get("version")
|
||||
@@ -2549,12 +2857,15 @@ impl<'d> serde::Deserialize<'d> for PackageVersion {
|
||||
}
|
||||
|
||||
/// The package configuration.
|
||||
///
|
||||
/// See more: https://tauri.app/v1/api/config#packageconfig
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
pub struct PackageConfig {
|
||||
/// App name.
|
||||
#[serde(alias = "product-name")]
|
||||
#[cfg_attr(feature = "schema", validate(regex(pattern = "^[^/\\:*?\"<>|]+$")))]
|
||||
pub product_name: Option<String>,
|
||||
/// App version. It is a semver version number or a path to a `package.json` file containing the `version` field.
|
||||
#[serde(deserialize_with = "version_deserializer", default)]
|
||||
@@ -2677,6 +2988,8 @@ pub struct Config {
|
||||
}
|
||||
|
||||
/// The plugin configs holds a HashMap mapping a plugin name to its configuration object.
|
||||
///
|
||||
/// See more: https://tauri.app/v1/api/config#pluginconfig
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
pub struct PluginConfig(pub HashMap<String, JsonValue>);
|
||||
@@ -2864,7 +3177,7 @@ mod build {
|
||||
|
||||
tokens.append_all(match self {
|
||||
Self::App(path) => {
|
||||
let path = path_buf_lit(&path);
|
||||
let path = path_buf_lit(path);
|
||||
quote! { #prefix::App(#path) }
|
||||
}
|
||||
Self::External(url) => {
|
||||
@@ -2886,10 +3199,23 @@ mod build {
|
||||
}
|
||||
}
|
||||
|
||||
impl ToTokens for crate::TitleBarStyle {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||
let prefix = quote! { ::tauri::utils::TitleBarStyle };
|
||||
|
||||
tokens.append_all(match self {
|
||||
Self::Visible => quote! { #prefix::Visible },
|
||||
Self::Transparent => quote! { #prefix::Transparent },
|
||||
Self::Overlay => quote! { #prefix::Overlay },
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl ToTokens for WindowConfig {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||
let label = str_lit(&self.label);
|
||||
let url = &self.url;
|
||||
let user_agent = opt_str_lit(self.user_agent.as_ref());
|
||||
let file_drop_enabled = self.file_drop_enabled;
|
||||
let center = self.center;
|
||||
let x = opt_lit(self.x.as_ref());
|
||||
@@ -2909,14 +3235,21 @@ mod build {
|
||||
let visible = self.visible;
|
||||
let decorations = self.decorations;
|
||||
let always_on_top = self.always_on_top;
|
||||
let content_protected = self.content_protected;
|
||||
let skip_taskbar = self.skip_taskbar;
|
||||
let theme = opt_lit(self.theme.as_ref());
|
||||
let title_bar_style = &self.title_bar_style;
|
||||
let hidden_title = self.hidden_title;
|
||||
let accept_first_mouse = self.accept_first_mouse;
|
||||
let tabbing_identifier = opt_str_lit(self.tabbing_identifier.as_ref());
|
||||
let additional_browser_args = opt_str_lit(self.additional_browser_args.as_ref());
|
||||
|
||||
literal_struct!(
|
||||
tokens,
|
||||
WindowConfig,
|
||||
label,
|
||||
url,
|
||||
user_agent,
|
||||
file_drop_enabled,
|
||||
center,
|
||||
x,
|
||||
@@ -2936,8 +3269,14 @@ mod build {
|
||||
visible,
|
||||
decorations,
|
||||
always_on_top,
|
||||
content_protected,
|
||||
skip_taskbar,
|
||||
theme
|
||||
theme,
|
||||
title_bar_style,
|
||||
hidden_title,
|
||||
accept_first_mouse,
|
||||
tabbing_identifier,
|
||||
additional_browser_args
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -3045,6 +3384,8 @@ mod build {
|
||||
|
||||
tokens.append_all(match self {
|
||||
Self::Brownfield => quote! { #prefix::Brownfield },
|
||||
#[cfg(not(feature = "isolation"))]
|
||||
Self::Isolation { dir: _ } => quote! { #prefix::Brownfield },
|
||||
#[cfg(feature = "isolation")]
|
||||
Self::Isolation { dir } => {
|
||||
let dir = path_buf_lit(dir);
|
||||
@@ -3070,7 +3411,7 @@ mod build {
|
||||
quote! { #prefix::OfflineInstaller { silent: #silent } }
|
||||
}
|
||||
Self::FixedRuntime { path } => {
|
||||
let path = path_buf_lit(&path);
|
||||
let path = path_buf_lit(path);
|
||||
quote! { #prefix::FixedRuntime { path: #path } }
|
||||
}
|
||||
})
|
||||
@@ -3097,6 +3438,7 @@ mod build {
|
||||
impl ToTokens for BundleConfig {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||
let identifier = str_lit(&self.identifier);
|
||||
let publisher = quote!(None);
|
||||
let icon = vec_lit(&self.icon, str_lit);
|
||||
let active = self.active;
|
||||
let targets = quote!(Default::default());
|
||||
@@ -3116,6 +3458,7 @@ mod build {
|
||||
BundleConfig,
|
||||
active,
|
||||
identifier,
|
||||
publisher,
|
||||
icon,
|
||||
targets,
|
||||
resources,
|
||||
@@ -3189,7 +3532,8 @@ mod build {
|
||||
impl ToTokens for UpdaterWindowsConfig {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||
let install_mode = &self.install_mode;
|
||||
literal_struct!(tokens, UpdaterWindowsConfig, install_mode);
|
||||
let installer_args = vec_lit(&self.installer_args, str_lit);
|
||||
literal_struct!(tokens, UpdaterWindowsConfig, install_mode, installer_args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3279,12 +3623,34 @@ mod build {
|
||||
}
|
||||
}
|
||||
|
||||
impl ToTokens for RemoteDomainAccessScope {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||
let scheme = opt_str_lit(self.scheme.as_ref());
|
||||
let domain = str_lit(&self.domain);
|
||||
let windows = vec_lit(&self.windows, str_lit);
|
||||
let plugins = vec_lit(&self.plugins, str_lit);
|
||||
let enable_tauri_api = self.enable_tauri_api;
|
||||
|
||||
literal_struct!(
|
||||
tokens,
|
||||
RemoteDomainAccessScope,
|
||||
scheme,
|
||||
domain,
|
||||
windows,
|
||||
plugins,
|
||||
enable_tauri_api
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
impl ToTokens for SecurityConfig {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||
let csp = opt_lit(self.csp.as_ref());
|
||||
let dev_csp = opt_lit(self.dev_csp.as_ref());
|
||||
let freeze_prototype = self.freeze_prototype;
|
||||
let dangerous_disable_asset_csp_modification = &self.dangerous_disable_asset_csp_modification;
|
||||
let dangerous_remote_domain_ipc_access =
|
||||
vec_lit(&self.dangerous_remote_domain_ipc_access, identity);
|
||||
|
||||
literal_struct!(
|
||||
tokens,
|
||||
@@ -3292,7 +3658,8 @@ mod build {
|
||||
csp,
|
||||
dev_csp,
|
||||
freeze_prototype,
|
||||
dangerous_disable_asset_csp_modification
|
||||
dangerous_disable_asset_csp_modification,
|
||||
dangerous_remote_domain_ipc_access
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -3302,12 +3669,14 @@ mod build {
|
||||
let icon_as_template = self.icon_as_template;
|
||||
let menu_on_left_click = self.menu_on_left_click;
|
||||
let icon_path = path_buf_lit(&self.icon_path);
|
||||
let title = opt_str_lit(self.title.as_ref());
|
||||
literal_struct!(
|
||||
tokens,
|
||||
SystemTrayConfig,
|
||||
icon_path,
|
||||
icon_as_template,
|
||||
menu_on_left_click
|
||||
menu_on_left_click,
|
||||
title
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -3529,6 +3898,7 @@ mod test {
|
||||
active: false,
|
||||
targets: Default::default(),
|
||||
identifier: String::from(""),
|
||||
publisher: None,
|
||||
icon: Vec::new(),
|
||||
resources: None,
|
||||
copyright: None,
|
||||
@@ -3554,6 +3924,7 @@ mod test {
|
||||
dev_csp: None,
|
||||
freeze_prototype: false,
|
||||
dangerous_disable_asset_csp_modification: DisabledCspModificationKind::Flag(false),
|
||||
dangerous_remote_domain_ipc_access: Vec::new(),
|
||||
},
|
||||
allowlist: AllowlistConfig::default(),
|
||||
system_tray: None,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -141,6 +141,33 @@ pub enum ConfigError {
|
||||
},
|
||||
}
|
||||
|
||||
/// Determines if the given folder has a configuration file.
|
||||
pub fn folder_has_configuration_file(folder: &Path) -> bool {
|
||||
folder.join(ConfigFormat::Json.into_file_name()).exists()
|
||||
|| folder.join(ConfigFormat::Json5.into_file_name()).exists()
|
||||
|| folder.join(ConfigFormat::Toml.into_file_name()).exists()
|
||||
// platform file names
|
||||
|| folder.join(ConfigFormat::Json.into_platform_file_name()).exists()
|
||||
|| folder.join(ConfigFormat::Json5.into_platform_file_name()).exists()
|
||||
|| folder.join(ConfigFormat::Toml.into_platform_file_name()).exists()
|
||||
}
|
||||
|
||||
/// Determines if the given file path represents a Tauri configuration file.
|
||||
pub fn is_configuration_file(path: &Path) -> bool {
|
||||
path
|
||||
.file_name()
|
||||
.map(|file_name| {
|
||||
file_name == OsStr::new(ConfigFormat::Json.into_file_name())
|
||||
|| file_name == OsStr::new(ConfigFormat::Json5.into_file_name())
|
||||
|| file_name == OsStr::new(ConfigFormat::Toml.into_file_name())
|
||||
// platform file names
|
||||
|| file_name == OsStr::new(ConfigFormat::Json.into_platform_file_name())
|
||||
|| file_name == OsStr::new(ConfigFormat::Json5.into_platform_file_name())
|
||||
|| file_name == OsStr::new(ConfigFormat::Toml.into_platform_file_name())
|
||||
})
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Reads the configuration from the given root directory.
|
||||
///
|
||||
/// It first looks for a `tauri.conf.json[5]` file on the given directory. The file must exist.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -6,9 +6,15 @@
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use html5ever::{interface::QualName, namespace_url, ns, tendril::TendrilSink, LocalName};
|
||||
use html5ever::{
|
||||
interface::QualName,
|
||||
namespace_url, ns,
|
||||
serialize::{HtmlSerializer, SerializeOpts, Serializer, TraversalScope},
|
||||
tendril::TendrilSink,
|
||||
LocalName,
|
||||
};
|
||||
pub use kuchiki::NodeRef;
|
||||
use kuchiki::{Attribute, ExpandedName};
|
||||
use kuchiki::{Attribute, ExpandedName, NodeData};
|
||||
use serde::Serialize;
|
||||
#[cfg(feature = "isolation")]
|
||||
use serialize_to_javascript::DefaultTemplate;
|
||||
@@ -24,6 +30,90 @@ pub const SCRIPT_NONCE_TOKEN: &str = "__TAURI_SCRIPT_NONCE__";
|
||||
/// The token used for style nonces.
|
||||
pub const STYLE_NONCE_TOKEN: &str = "__TAURI_STYLE_NONCE__";
|
||||
|
||||
// taken from https://github.com/kuchiki-rs/kuchiki/blob/57ee6920d835315a498e748ba4b07a851ae5e498/src/serializer.rs#L12
|
||||
fn serialize_node_ref_internal<S: Serializer>(
|
||||
node: &NodeRef,
|
||||
serializer: &mut S,
|
||||
traversal_scope: TraversalScope,
|
||||
) -> crate::Result<()> {
|
||||
match (traversal_scope, node.data()) {
|
||||
(ref scope, NodeData::Element(element)) => {
|
||||
if *scope == TraversalScope::IncludeNode {
|
||||
let attrs = element.attributes.borrow();
|
||||
|
||||
// Unfortunately we need to allocate something to hold these &'a QualName
|
||||
let attrs = attrs
|
||||
.map
|
||||
.iter()
|
||||
.map(|(name, attr)| {
|
||||
(
|
||||
QualName::new(attr.prefix.clone(), name.ns.clone(), name.local.clone()),
|
||||
&attr.value,
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
serializer.start_elem(
|
||||
element.name.clone(),
|
||||
attrs.iter().map(|&(ref name, value)| (name, &**value)),
|
||||
)?
|
||||
}
|
||||
|
||||
let children = match element.template_contents.as_ref() {
|
||||
Some(template_root) => template_root.children(),
|
||||
None => node.children(),
|
||||
};
|
||||
for child in children {
|
||||
serialize_node_ref_internal(&child, serializer, TraversalScope::IncludeNode)?
|
||||
}
|
||||
|
||||
if *scope == TraversalScope::IncludeNode {
|
||||
serializer.end_elem(element.name.clone())?
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
(_, &NodeData::DocumentFragment) | (_, &NodeData::Document(_)) => {
|
||||
for child in node.children() {
|
||||
serialize_node_ref_internal(&child, serializer, TraversalScope::IncludeNode)?
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
(TraversalScope::ChildrenOnly(_), _) => Ok(()),
|
||||
|
||||
(TraversalScope::IncludeNode, NodeData::Doctype(doctype)) => {
|
||||
serializer.write_doctype(&doctype.name).map_err(Into::into)
|
||||
}
|
||||
(TraversalScope::IncludeNode, NodeData::Text(text)) => {
|
||||
serializer.write_text(&text.borrow()).map_err(Into::into)
|
||||
}
|
||||
(TraversalScope::IncludeNode, NodeData::Comment(text)) => {
|
||||
serializer.write_comment(&text.borrow()).map_err(Into::into)
|
||||
}
|
||||
(TraversalScope::IncludeNode, NodeData::ProcessingInstruction(contents)) => {
|
||||
let contents = contents.borrow();
|
||||
serializer
|
||||
.write_processing_instruction(&contents.0, &contents.1)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Serializes the node to HTML.
|
||||
pub fn serialize_node(node: &NodeRef) -> Vec<u8> {
|
||||
let mut u8_vec = Vec::new();
|
||||
let mut ser = HtmlSerializer::new(
|
||||
&mut u8_vec,
|
||||
SerializeOpts {
|
||||
traversal_scope: TraversalScope::IncludeNode,
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
serialize_node_ref_internal(node, &mut ser, TraversalScope::IncludeNode).unwrap();
|
||||
u8_vec
|
||||
}
|
||||
|
||||
/// Parses the given HTML string.
|
||||
pub fn parse(html: String) -> NodeRef {
|
||||
kuchiki::parse_html().one(html)
|
||||
@@ -122,7 +212,6 @@ impl From<&PatternKind> for PatternObject {
|
||||
fn from(pattern_kind: &PatternKind) -> Self {
|
||||
match pattern_kind {
|
||||
PatternKind::Brownfield => Self::Brownfield,
|
||||
#[cfg(feature = "isolation")]
|
||||
PatternKind::Isolation { .. } => Self::Isolation {
|
||||
side: IsolationSide::default(),
|
||||
},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
//! Tauri utility helpers
|
||||
#![warn(missing_docs, rust_2018_idioms)]
|
||||
|
||||
use std::fmt::Display;
|
||||
use std::{
|
||||
fmt::Display,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use semver::Version;
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
@@ -14,6 +17,7 @@ pub mod assets;
|
||||
pub mod config;
|
||||
pub mod html;
|
||||
pub mod io;
|
||||
pub mod mime_type;
|
||||
pub mod platform;
|
||||
/// Prepare application resources and sidecars.
|
||||
#[cfg(feature = "resources")]
|
||||
@@ -49,6 +53,68 @@ impl PackageInfo {
|
||||
}
|
||||
}
|
||||
|
||||
/// How the window title bar should be displayed on macOS.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub enum TitleBarStyle {
|
||||
/// A normal title bar.
|
||||
Visible,
|
||||
/// Makes the title bar transparent, so the window background color is shown instead.
|
||||
///
|
||||
/// Useful if you don't need to have actual HTML under the title bar. This lets you avoid the caveats of using `TitleBarStyle::Overlay`. Will be more useful when Tauri lets you set a custom window background color.
|
||||
Transparent,
|
||||
/// Shows the title bar as a transparent overlay over the window's content.
|
||||
///
|
||||
/// Keep in mind:
|
||||
/// - The height of the title bar is different on different OS versions, which can lead to window the controls and title not being where you don't expect.
|
||||
/// - You need to define a custom drag region to make your window draggable, however due to a limitation you can't drag the window when it's not in focus <https://github.com/tauri-apps/tauri/issues/4316>.
|
||||
/// - The color of the window title depends on the system theme.
|
||||
Overlay,
|
||||
}
|
||||
|
||||
impl Default for TitleBarStyle {
|
||||
fn default() -> Self {
|
||||
Self::Visible
|
||||
}
|
||||
}
|
||||
|
||||
impl Serialize for TitleBarStyle {
|
||||
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
serializer.serialize_str(self.to_string().as_ref())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de> Deserialize<'de> for TitleBarStyle {
|
||||
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let s = String::deserialize(deserializer)?;
|
||||
Ok(match s.to_lowercase().as_str() {
|
||||
"transparent" => Self::Transparent,
|
||||
"overlay" => Self::Overlay,
|
||||
_ => Self::Visible,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for TitleBarStyle {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{}",
|
||||
match self {
|
||||
Self::Visible => "Visible",
|
||||
Self::Transparent => "Transparent",
|
||||
Self::Overlay => "Overlay",
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// System theme.
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
@@ -231,3 +297,12 @@ macro_rules! debug_eprintln {
|
||||
$crate::consume_unused_variable!($($arg)*);
|
||||
};
|
||||
}
|
||||
|
||||
/// Reconstructs a path from its components using the platform separator then converts it to String
|
||||
pub fn display_path<P: AsRef<Path>>(p: P) -> String {
|
||||
p.as_ref()
|
||||
.components()
|
||||
.collect::<PathBuf>()
|
||||
.display()
|
||||
.to_string()
|
||||
}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
//! Determine a mime type from a URI or file contents.
|
||||
|
||||
use std::fmt;
|
||||
|
||||
const MIMETYPE_PLAIN: &str = "text/plain";
|
||||
|
||||
/// [Web Compatible MimeTypes](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types#important_mime_types_for_web_developers)
|
||||
#[allow(missing_docs)]
|
||||
pub enum MimeType {
|
||||
Css,
|
||||
Csv,
|
||||
@@ -36,7 +39,7 @@ impl std::fmt::Display for MimeType {
|
||||
MimeType::Svg => "image/svg+xml",
|
||||
MimeType::Mp4 => "video/mp4",
|
||||
};
|
||||
write!(f, "{}", mime)
|
||||
write!(f, "{mime}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +49,7 @@ impl MimeType {
|
||||
let suffix = uri.split('.').last();
|
||||
match suffix {
|
||||
Some("bin") => Self::OctetStream,
|
||||
Some("css") => Self::Css,
|
||||
Some("css" | "less" | "sass" | "styl") => Self::Css,
|
||||
Some("csv") => Self::Csv,
|
||||
Some("html") => Self::Html,
|
||||
Some("ico") => Self::Ico,
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
algorithm.iv = window.crypto.getRandomValues(new Uint8Array(12))
|
||||
|
||||
let encoder = new TextEncoder()
|
||||
let payloadRaw = encoder.encode(JSON.stringify(data))
|
||||
let payloadRaw = encoder.encode(__RAW_stringify_ipc_message_fn__(data))
|
||||
|
||||
return window.crypto.subtle
|
||||
.encrypt(algorithm, aesGcmKey, payloadRaw)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
@@ -8,7 +8,7 @@ use std::fmt::{Debug, Formatter};
|
||||
use std::string::FromUtf8Error;
|
||||
|
||||
use aes_gcm::aead::Aead;
|
||||
use aes_gcm::{aead::NewAead, Aes256Gcm, Nonce};
|
||||
use aes_gcm::{Aes256Gcm, KeyInit, Nonce};
|
||||
use getrandom::{getrandom, Error as CsprngError};
|
||||
use serialize_to_javascript::{default_template, Template};
|
||||
|
||||
@@ -57,7 +57,7 @@ impl AesGcmPair {
|
||||
fn new() -> Result<Self, Error> {
|
||||
let mut raw = [0u8; 32];
|
||||
getrandom(&mut raw)?;
|
||||
let key = aes_gcm::Key::from_slice(&raw);
|
||||
let key = aes_gcm::Key::<Aes256Gcm>::from_slice(&raw);
|
||||
Ok(Self {
|
||||
raw,
|
||||
key: Aes256Gcm::new(key),
|
||||
@@ -141,6 +141,9 @@ pub struct IsolationJavascriptCodegen {
|
||||
pub struct IsolationJavascriptRuntime<'a> {
|
||||
/// The key used on the Rust backend and the Isolation Javascript
|
||||
pub runtime_aes_gcm_key: &'a [u8; 32],
|
||||
/// The function that stringifies a IPC message.
|
||||
#[raw]
|
||||
pub stringify_ipc_message_fn: &'a str,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user