chore: fix ci and cleanup leftovers (#6925)

* chore: fix ci and cleanup leftovers

1. removed leftover feature flags
2. remove zip/extract apis which are not used anymore
3. removed leftoever scopes
4. removed leftover allowlist and updater options
5. updated the example api

* remove leftover updater structs

* move updater under bundle and remove uneeded options

* fix cli on linux

* remove create_proxy

* clippy

* more clippy

* clippppy

* readd path api

* fix api example

* remove window allowlist

* remove window from allowlist config

* remove `all` allowlist option

* remove file_move

* lint

* fix windows build

* remvoe unused deps

* remvoe allowlist config option, move protocol to `security > asset_protocol`

* fix diffing features

* fmt and test

* fix scope alias

* change files

* android lint

* simplify allow_file impl

* Revert "simplify allow_file impl"

This reverts commit b8882f2fd0.

* expose scopes

* remove unused error variants

* protocol-asset on docs.rs

* ignore reqwest on udeps

---------

Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
Co-authored-by: Lucas Nogueira <lucas@tauri.app>
This commit is contained in:
Amr Bashir 2023-05-13 13:48:28 +03:00 committed by GitHub
parent 9a79dc0858
commit e1e85dc2a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
80 changed files with 587 additions and 9578 deletions

View File

@ -0,0 +1,6 @@
---
"tauri": patch
"tauri-utils": patch
---
Moved the `protocol` scope configuration to the `asset_protocol` field in `SecurityConfig`.

View File

@ -0,0 +1,8 @@
---
"tauri": patch
"tauri-utils": patch
"cli.rs": patch
"cli.js": patch
---
Moved the updater configuration to the `BundleConfig`.

View File

@ -0,0 +1,8 @@
---
"tauri": patch
"tauri-utils": patch
"cli.rs": patch
"cli.js": patch
---
Removed the allowlist configuration.

View File

@ -0,0 +1,5 @@
---
"tauri": patch
---
Removed extract and move APIs from `tauri::api::file`.

View File

@ -0,0 +1,6 @@
---
"tauri": patch
---
Removed `UpdaterEvent`. See `tauri-plugin-updater` for new usage.

View File

@ -71,7 +71,7 @@ The code for the bundler is located in `[Tauri repo root]/tooling/bundler`, and
### Developing Tauri Core and Related Components (Rust API, Macros, Codegen, and Utils)
The code for Tauri Core is located in `[Tauri repo root]/core/tauri`, and the Rust API, Macros, and Utils are in `[Tauri repo root]/core/tauri-(api/macros/utils)`. The easiest way to test your changes is to use the `[Tauri repo root]/examples/helloworld` app. It automatically rebuilds and uses your local copy of the Tauri core packages. Just run `yarn tauri build` or `yarn tauri dev` in the helloworld app directory after making changes to test them out. To use your local changes in another project, edit its `src-tauri/Cargo.toml` file so that the `tauri` key looks like `tauri = { path = "PATH", features = [ "api-all" ] }`, where `PATH` is the relative path to `[Tauri repo root]/core/tauri`. Then, your local copy of the Tauri core packages will be rebuilt and used whenever you build that project.
The code for Tauri Core is located in `[Tauri repo root]/core/tauri`, and the Rust API, Macros, and Utils are in `[Tauri repo root]/core/tauri-(api/macros/utils)`. The easiest way to test your changes is to use the `[Tauri repo root]/examples/helloworld` app. It automatically rebuilds and uses your local copy of the Tauri core packages. Just run `yarn tauri build` or `yarn tauri dev` in the helloworld app directory after making changes to test them out. To use your local changes in another project, edit its `src-tauri/Cargo.toml` file so that the `tauri` key looks like `tauri = { path = "PATH" }`, where `PATH` is the relative path to `[Tauri repo root]/core/tauri`. Then, your local copy of the Tauri core packages will be rebuilt and used whenever you build that project.
#### Building the documentation locally

View File

@ -50,11 +50,10 @@ jobs:
clippy:
- { args: '', key: 'empty' }
- {
args: '--features compression,wry,linux-protocol-headers,isolation,custom-protocol,api-all,updater,system-tray',
args: '--features compression,wry,linux-protocol-headers,isolation,custom-protocol,system-tray',
key: 'all'
}
- { args: '--features custom-protocol', key: 'custom-protocol' }
- { args: '--features api-all', key: 'api-all' }
steps:
- uses: actions/checkout@v2

View File

@ -72,11 +72,7 @@ jobs:
key: no-default
}
- {
args: --features api-all,
key: api-all
}
- {
args: --features compression,wry,linux-protocol-headers,isolation,custom-protocol,api-all,updater,system-tray,
args: --features compression,wry,linux-protocol-headers,isolation,custom-protocol,system-tray,
key: all
}

View File

@ -27,7 +27,6 @@ serde_json = "1"
heck = "0.4"
json-patch = "1.0"
walkdir = "2"
filetime = "0.2"
tauri-winres = "0.1"
semver = "1"

View File

@ -349,7 +349,7 @@ dependencies {"
if !error_message.is_empty() {
return Err(anyhow!("
The `tauri` dependency features on the `Cargo.toml` file does not match the allowlist defined under `tauri.conf.json`.
The `tauri` dependency features on the `Cargo.toml` file does not match the `tauri.conf.json` config.
Please run `tauri dev` or `tauri build` or {}.
", error_message));
}

View File

@ -11,5 +11,4 @@ tauri-utils = { version = "2.0.0-alpha.4", features = [
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"] }

File diff suppressed because it is too large Load Diff

View File

@ -23,9 +23,9 @@ raw-window-handle = "0.5"
[target."cfg(windows)".dependencies]
webview2-com = "0.22"
[target."cfg(windows)".dependencies.windows]
version = "0.44"
features = [ "Win32_Foundation" ]
[target."cfg(windows)".dependencies.windows]
version = "0.44"
features = [ "Win32_Foundation" ]
[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies]
gtk = { version = "0.16", features = [ "v3_24" ] }

View File

@ -34,12 +34,9 @@ raw-window-handle = "0.5"
rand = "0.8"
url = { version = "2" }
[target."cfg(windows)".dependencies]
webview2-com = "0.22"
[target."cfg(windows)".dependencies.windows]
version = "0.44"
features = [ "Win32_Foundation" ]
[target."cfg(windows)".dependencies.windows]
version = "0.44"
features = [ "Win32_Foundation" ]
[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies]
gtk = { version = "0.16", features = [ "v3_24" ] }

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,10 @@
[package]
authors = [ "Tauri Programme within The Commons Conservancy" ]
categories = [ "gui", "web-programming" ]
authors = ["Tauri Programme within The Commons Conservancy"]
categories = ["gui", "web-programming"]
description = "Make tiny, secure apps for all desktop platforms with Tauri"
edition = "2021"
rust-version = "1.65"
exclude = [ "/test", "/.scripts", "CHANGELOG.md", "/target" ]
exclude = ["/test", "/.scripts", "CHANGELOG.md", "/target"]
homepage = "https://tauri.app"
license = "Apache-2.0 OR MIT"
name = "tauri"
@ -18,28 +18,29 @@ no-default-features = true
features = [
"wry",
"custom-protocol",
"api-all",
"updater",
"fs-extract-api",
"system-tray",
"devtools",
"icon-png",
"dox"
"protocol-asset",
"dox",
]
rustdoc-args = [ "--cfg", "doc_cfg" ]
rustdoc-args = ["--cfg", "doc_cfg"]
default-target = "x86_64-unknown-linux-gnu"
targets = [
"x86_64-pc-windows-msvc",
"x86_64-unknown-linux-gnu",
"x86_64-apple-darwin"
"x86_64-apple-darwin",
]
[package.metadata.cargo-udeps.ignore]
normal = ["reqwest"]
[dependencies]
serde_json = { version = "1.0", features = [ "raw_value" ] }
serde = { version = "1.0", features = [ "derive" ] }
serde_json = { version = "1.0", features = ["raw_value"] }
serde = { version = "1.0", features = ["derive"] }
tokio = { version = "1", features = [ "rt", "rt-multi-thread", "sync", "fs", "io-util" ] }
futures-util = "0.3"
uuid = { version = "1", features = [ "v4" ] }
uuid = { version = "1", features = ["v4"] }
url = { version = "2.3" }
anyhow = "1.0"
thiserror = "1.0"
@ -49,19 +50,15 @@ tauri-macros = { version = "2.0.0-alpha.4", path = "../tauri-macros" }
tauri-utils = { version = "2.0.0-alpha.4", features = [ "resources" ], path = "../tauri-utils" }
tauri-runtime-wry = { version = "0.13.0-alpha.4", path = "../tauri-runtime-wry", optional = true }
rand = "0.8"
semver = { version = "1.0", features = [ "serde" ] }
semver = { version = "1.0", features = ["serde"] }
serde_repr = "0.1"
state = "0.5"
tar = "0.4.38"
tempfile = "3"
zip = { version = "0.6", default-features = false, optional = true }
ignore = "0.4"
flate2 = "1.0"
http = "0.2"
dirs-next = "2.0"
percent-encoding = "2.2"
reqwest = { version = "0.11", default-features = false, features = [ "json", "stream" ] }
bytes = { version = "1", features = [ "serde" ] }
bytes = { version = "1", features = ["serde"] }
raw-window-handle = "0.5"
time = { version = "0.3", optional = true }
glob = "0.3"
@ -70,12 +67,11 @@ serialize-to-javascript = "=0.1.1"
infer = { version = "0.9", optional = true }
png = { version = "0.17", optional = true }
ico = { version = "0.2.0", optional = true }
encoding_rs = "0.8.31"
[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies]
gtk = { version = "0.16", features = [ "v3_24" ] }
gtk = { version = "0.16", features = ["v3_24"] }
glib = "0.16"
webkit2gtk = { version = "0.19.1", features = [ "v2_38" ] }
webkit2gtk = { version = "0.19.1", features = ["v2_38"] }
[target."cfg(target_os = \"macos\")".dependencies]
embed_plist = "1.2"
@ -85,9 +81,9 @@ objc = "0.2"
[target."cfg(windows)".dependencies]
webview2-com = "0.22"
[target."cfg(windows)".dependencies.windows]
version = "0.44"
features = [ "Win32_Foundation" ]
[target."cfg(windows)".dependencies.windows]
version = "0.44"
features = ["Win32_Foundation"]
[target."cfg(any(target_os = \"android\", target_os = \"ios\"))".dependencies]
log = "0.4"
@ -111,165 +107,38 @@ tauri-build = { path = "../tauri-build/", version = "2.0.0-alpha.1" }
proptest = "1.0.0"
quickcheck = "1.0.3"
quickcheck_macros = "1.0.0"
serde = { version = "1.0", features = [ "derive" ] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tauri = { path = ".", default-features = false, features = [ "wry" ] }
tokio = { version = "1", features = [ "full" ] }
tauri = { path = ".", default-features = false, features = ["wry"] }
tokio = { version = "1", features = ["full"] }
cargo_toml = "0.11"
winnow = "=0.4.1"
[features]
default = [ "wry", "compression", "objc-exception" ]
compression = [ "tauri-macros/compression", "tauri-utils/compression" ]
wry = [ "tauri-runtime-wry" ]
objc-exception = [ "tauri-runtime-wry/objc-exception" ]
linux-protocol-headers = [ "tauri-runtime-wry/linux-headers", "webkit2gtk/v2_36" ]
isolation = [ "tauri-utils/isolation", "tauri-macros/isolation" ]
custom-protocol = [ "tauri-macros/custom-protocol" ]
updater = [ "time" ]
fs-extract-api = [ "zip" ]
native-tls = [ "reqwest/native-tls" ]
native-tls-vendored = [ "reqwest/native-tls-vendored" ]
rustls-tls = [ "reqwest/rustls-tls" ]
system-tray = [ "tauri-runtime/system-tray", "tauri-runtime-wry/system-tray" ]
devtools = [ "tauri-runtime/devtools", "tauri-runtime-wry/devtools" ]
dox = [ "tauri-runtime-wry/dox" ]
default = ["wry", "compression", "objc-exception"]
compression = ["tauri-macros/compression", "tauri-utils/compression"]
wry = ["tauri-runtime-wry"]
objc-exception = ["tauri-runtime-wry/objc-exception"]
linux-protocol-headers = ["tauri-runtime-wry/linux-headers", "webkit2gtk/v2_36"]
isolation = ["tauri-utils/isolation", "tauri-macros/isolation"]
custom-protocol = ["tauri-macros/custom-protocol"]
native-tls = ["reqwest/native-tls"]
native-tls-vendored = ["reqwest/native-tls-vendored"]
rustls-tls = ["reqwest/rustls-tls"]
system-tray = ["tauri-runtime/system-tray", "tauri-runtime-wry/system-tray"]
devtools = ["tauri-runtime/devtools", "tauri-runtime-wry/devtools"]
dox = ["tauri-runtime-wry/dox"]
process-relaunch-dangerous-allow-symlink-macos = [ "tauri-utils/process-relaunch-dangerous-allow-symlink-macos" ]
macos-private-api = [
"tauri-runtime/macos-private-api",
"tauri-runtime-wry/macos-private-api"
"tauri-runtime-wry/macos-private-api",
]
window-data-url = [ "data-url" ]
api-all = [
"clipboard-all",
"dialog-all",
"fs-all",
"global-shortcut-all",
"http-all",
"notification-all",
"os-all",
"path-all",
"process-all",
"protocol-all",
"shell-all",
"window-all",
"app-all"
]
clipboard-all = [ "clipboard-write-text", "clipboard-read-text" ]
clipboard-read-text = [ ]
clipboard-write-text = [ ]
dialog-all = [ "dialog-open", "dialog-save", "dialog-message", "dialog-ask" ]
dialog-ask = [ ]
dialog-confirm = [ ]
dialog-message = [ ]
dialog-open = [ ]
dialog-save = [ ]
fs-all = [
"fs-copy-file",
"fs-create-dir",
"fs-exists",
"fs-read-file",
"fs-read-dir",
"fs-remove-dir",
"fs-remove-file",
"fs-rename-file",
"fs-write-file"
]
fs-copy-file = [ ]
fs-create-dir = [ ]
fs-exists = [ ]
fs-read-file = [ ]
fs-read-dir = [ ]
fs-remove-dir = [ ]
fs-remove-file = [ ]
fs-rename-file = [ ]
fs-write-file = [ ]
global-shortcut-all = [ ]
http-all = [ "http-request" ]
http-request = [ ]
notification-all = [ ]
os-all = [ ]
path-all = [ ]
process-all = [ "process-relaunch", "process-exit" ]
process-exit = [ ]
process-relaunch = [ ]
process-relaunch-dangerous-allow-symlink-macos = [ "tauri-utils/process-relaunch-dangerous-allow-symlink-macos" ]
protocol-all = [ "protocol-asset" ]
protocol-asset = [ ]
shell-all = [ "shell-execute", "shell-sidecar", "shell-open" ]
shell-execute = [ ]
shell-sidecar = [ ]
shell-open = [ ]
window-all = [
"window-create",
"window-center",
"window-request-user-attention",
"window-set-resizable",
"window-set-title",
"window-maximize",
"window-unmaximize",
"window-minimize",
"window-unminimize",
"window-show",
"window-hide",
"window-close",
"window-set-decorations",
"window-set-shadow",
"window-set-always-on-top",
"window-set-content-protected",
"window-set-size",
"window-set-min-size",
"window-set-max-size",
"window-set-position",
"window-set-fullscreen",
"window-set-focus",
"window-set-icon",
"window-set-skip-taskbar",
"window-set-cursor-grab",
"window-set-cursor-visible",
"window-set-cursor-icon",
"window-set-cursor-position",
"window-set-ignore-cursor-events",
"window-start-dragging",
"window-print"
]
window-create = [ ]
window-center = [ ]
window-request-user-attention = [ ]
window-set-resizable = [ ]
window-set-title = [ ]
window-maximize = [ ]
window-unmaximize = [ ]
window-minimize = [ ]
window-unminimize = [ ]
window-show = [ ]
window-hide = [ ]
window-close = [ ]
window-set-decorations = [ ]
window-set-shadow = [ ]
window-set-always-on-top = [ ]
window-set-content-protected = [ ]
window-set-size = [ ]
window-set-min-size = [ ]
window-set-max-size = [ ]
window-set-position = [ ]
window-set-fullscreen = [ ]
window-set-focus = [ ]
window-set-icon = [ ]
window-set-skip-taskbar = [ ]
window-set-cursor-grab = [ ]
window-set-cursor-visible = [ ]
window-set-cursor-icon = [ ]
window-set-cursor-position = [ ]
window-set-ignore-cursor-events = [ ]
window-start-dragging = [ ]
window-print = [ ]
app-all = [ "app-show", "app-hide" ]
app-show = [ ]
app-hide = [ ]
config-json5 = [ "tauri-macros/config-json5" ]
config-toml = [ "tauri-macros/config-toml" ]
icon-ico = [ "infer", "ico" ]
icon-png = [ "infer", "png" ]
window-data-url = ["data-url"]
protocol-asset = []
config-json5 = ["tauri-macros/config-json5"]
config-toml = ["tauri-macros/config-toml"]
icon-ico = ["infer", "ico"]
icon-png = ["infer", "png"]
[[example]]
name = "commands"
@ -282,7 +151,6 @@ path = "../../examples/helloworld/main.rs"
[[example]]
name = "multiwindow"
path = "../../examples/multiwindow/main.rs"
required-features = [ "window-create" ]
[[example]]
name = "parent-window"
@ -291,7 +159,6 @@ path = "../../examples/parent-window/main.rs"
[[example]]
name = "navigation"
path = "../../examples/navigation/main.rs"
required-features = [ "window-create" ]
[[example]]
name = "splashscreen"
@ -308,4 +175,4 @@ path = "../../examples/streaming/main.rs"
[[example]]
name = "isolation"
path = "../../examples/isolation/main.rs"
required-features = [ "isolation" ]
required-features = ["isolation"]

View File

@ -3,8 +3,6 @@
// SPDX-License-Identifier: MIT
use heck::AsShoutySnakeCase;
use heck::AsSnakeCase;
use heck::ToSnakeCase;
use once_cell::sync::OnceCell;
@ -46,97 +44,12 @@ fn alias(alias: &str, has_feature: bool) {
fn main() {
alias("custom_protocol", has_feature("custom-protocol"));
alias("dev", !has_feature("custom-protocol"));
alias("updater", has_feature("updater"));
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
let mobile = target_os == "ios" || target_os == "android";
alias("desktop", !mobile);
alias("mobile", mobile);
let api_all = has_feature("api-all");
alias("api_all", api_all);
alias_module(
"fs",
&[
"read-file",
"write-file",
"read-dir",
"copy-file",
"create-dir",
"remove-dir",
"remove-file",
"rename-file",
"exists",
],
api_all,
);
alias_module(
"window",
&[
"create",
"center",
"request-user-attention",
"set-resizable",
"set-title",
"maximize",
"unmaximize",
"minimize",
"unminimize",
"show",
"hide",
"close",
"set-decorations",
"set-shadow",
"set-always-on-top",
"set-content-protected",
"set-size",
"set-min-size",
"set-max-size",
"set-position",
"set-fullscreen",
"set-focus",
"set-icon",
"set-skip-taskbar",
"set-cursor-grab",
"set-cursor-visible",
"set-cursor-icon",
"set-cursor-position",
"set-ignore-cursor-events",
"start-dragging",
"print",
],
api_all,
);
alias_module("shell", &["execute", "sidecar", "open"], api_all);
if !mobile {
alias_module(
"dialog",
&["open", "save", "message", "ask", "confirm"],
api_all,
);
}
alias_module("http", &["request"], api_all);
if !mobile {
alias_module("notification", &[], api_all);
alias_module("global-shortcut", &[], api_all);
}
alias_module("os", &[], api_all);
alias_module("path", &[], api_all);
alias_module("protocol", &["asset"], api_all);
alias_module("process", &["relaunch", "exit"], api_all);
alias_module("clipboard", &["write-text", "read-text"], api_all);
alias_module("app", &["show", "hide"], api_all);
let checked_features_out_path = Path::new(&var("OUT_DIR").unwrap()).join("checked_features");
std::fs::write(
checked_features_out_path,
@ -219,34 +132,6 @@ fn main() {
}
}
// create aliases for the given module with its apis.
// each api is translated into a feature flag in the format of `<module>-<api>`
// and aliased as `<module_snake_case>_<api_snake_case>`.
//
// The `<module>-all` feature is also aliased to `<module>_all`.
//
// If any of the features is enabled, the `<module_snake_case>_any` alias is created.
//
// Note that both `module` and `apis` strings must be written in kebab case.
fn alias_module(module: &str, apis: &[&str], api_all: bool) {
let all_feature_name = format!("{module}-all");
let all = has_feature(&all_feature_name) || api_all;
alias(&all_feature_name.to_snake_case(), all);
let mut any = all;
for api in apis {
let has = has_feature(&format!("{module}-{api}")) || all;
alias(
&format!("{}_{}", AsSnakeCase(module), AsSnakeCase(api)),
has,
);
any = any || has;
}
alias(&format!("{}_any", AsSnakeCase(module)), any);
}
fn add_manifest() {
static WINDOWS_MANIFEST_FILE: &str = "window-app-manifest.xml";

View File

@ -6,33 +6,6 @@
#[derive(thiserror::Error, Debug)]
#[non_exhaustive]
pub enum Error {
/// Command error.
#[error("Command Error: {0}")]
Command(String),
/// The path operation error.
#[error("Path Error: {0}")]
Path(String),
/// The path StripPrefixError error.
#[error("Path Error: {0}")]
PathPrefix(#[from] std::path::StripPrefixError),
/// Error showing the dialog.
#[error("Dialog Error: {0}")]
Dialog(String),
/// The dialog operation was cancelled by the user.
#[error("user cancelled the dialog")]
DialogCancelled,
/// Invalid HTTP header value.
#[error(transparent)]
HttpHeaderValue(#[from] http::header::InvalidHeaderValue),
/// Invalid HTTP header value.
#[error(transparent)]
HttpHeader(#[from] http::header::InvalidHeaderName),
/// Failed to convert bytes to string.
#[error(transparent)]
Utf8(#[from] std::string::FromUtf8Error),
/// HTTP form to must be an object.
#[error("http form must be an object")]
InvalidHttpForm,
/// Semver error.
#[error(transparent)]
Semver(#[from] semver::Error),
@ -42,30 +15,4 @@ pub enum Error {
/// IO error.
#[error(transparent)]
Io(#[from] std::io::Error),
/// Ignore error.
#[error("failed to walkdir: {0}")]
Ignore(#[from] ignore::Error),
/// ZIP error.
#[cfg(feature = "fs-extract-api")]
#[error(transparent)]
Zip(#[from] zip::result::ZipError),
/// Extract error.
#[cfg(feature = "fs-extract-api")]
#[error("Failed to extract: {0}")]
Extract(String),
/// Url error.
#[error(transparent)]
Url(#[from] url::ParseError),
/// failed to detect the current platform.
#[error("failed to detect platform: {0}")]
FailedToDetectPlatform(String),
/// Shell error.
#[error("shell error: {0}")]
Shell(String),
/// Unknown program name.
#[error("unknown program name: {0}")]
UnknownProgramName(String),
/// HTTP error.
#[error(transparent)]
Http(#[from] http::Error),
}

View File

@ -4,16 +4,8 @@
//! Types and functions related to file operations.
#[cfg(feature = "fs-extract-api")]
mod extract;
mod file_move;
use std::{fs, path::Path};
#[cfg(feature = "fs-extract-api")]
pub use extract::*;
pub use file_move::*;
/// Reads the entire contents of a file into a string.
pub fn read_string<P: AsRef<Path>>(file: P) -> crate::api::Result<String> {
fs::read_to_string(file).map_err(Into::into)

View File

@ -1,328 +0,0 @@
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
use std::{
borrow::Cow,
fs,
io::{self, Cursor, Read, Seek},
path::{self, Path, PathBuf},
};
/// The archive reader.
#[derive(Debug)]
pub enum ArchiveReader<R: Read + Seek> {
/// A plain reader.
Plain(R),
/// A GZ- compressed reader (decoder).
GzCompressed(Box<flate2::read::GzDecoder<R>>),
}
impl<R: Read + Seek> Read for ArchiveReader<R> {
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
match self {
Self::Plain(r) => r.read(buf),
Self::GzCompressed(decoder) => decoder.read(buf),
}
}
}
impl<R: Read + Seek> ArchiveReader<R> {
#[allow(dead_code)]
fn get_mut(&mut self) -> &mut R {
match self {
Self::Plain(r) => r,
Self::GzCompressed(decoder) => decoder.get_mut(),
}
}
}
/// The supported archive formats.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum ArchiveFormat {
/// Tar archive.
Tar(Option<Compression>),
/// Zip archive.
Zip,
}
/// The supported compression types.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum Compression {
/// Gz compression (e.g. `.tar.gz` archives)
Gz,
}
/// The zip entry.
pub struct ZipEntry {
path: PathBuf,
is_dir: bool,
file_contents: Vec<u8>,
}
/// A read-only view into an entry of an archive.
#[non_exhaustive]
pub enum Entry<'a, R: Read> {
/// An entry of a tar archive.
#[non_exhaustive]
Tar(Box<tar::Entry<'a, R>>),
/// An entry of a zip archive.
#[non_exhaustive]
Zip(ZipEntry),
}
impl<'a, R: Read> Entry<'a, R> {
/// The entry path.
pub fn path(&self) -> crate::api::Result<Cow<'_, Path>> {
match self {
Self::Tar(e) => e.path().map_err(Into::into),
Self::Zip(e) => Ok(Cow::Borrowed(&e.path)),
}
}
/// Extract this entry into `into_path`.
/// If it's a directory, the target will be created, if it's a file, it'll be extracted at this location.
/// Note: You need to include the complete path, with file name and extension.
pub fn extract(self, into_path: &path::Path) -> crate::api::Result<()> {
match self {
Self::Tar(mut entry) => {
// determine if it's a file or a directory
if entry.header().entry_type() == tar::EntryType::Directory {
// this is a directory, lets create it
match fs::create_dir_all(into_path) {
Ok(_) => (),
Err(e) => {
if e.kind() != io::ErrorKind::AlreadyExists {
return Err(e.into());
}
}
}
} else {
let mut out_file = fs::File::create(into_path)?;
io::copy(&mut entry, &mut out_file)?;
// make sure we set permissions
if let Ok(mode) = entry.header().mode() {
set_perms(into_path, Some(&mut out_file), mode, true)?;
}
}
}
Self::Zip(entry) => {
if entry.is_dir {
// this is a directory, lets create it
match fs::create_dir_all(into_path) {
Ok(_) => (),
Err(e) => {
if e.kind() != io::ErrorKind::AlreadyExists {
return Err(e.into());
}
}
}
} else {
let mut out_file = fs::File::create(into_path)?;
io::copy(&mut Cursor::new(entry.file_contents), &mut out_file)?;
}
}
}
Ok(())
}
}
/// The extract manager to retrieve files from archives.
pub struct Extract<'a, R: Read + Seek> {
reader: ArchiveReader<R>,
archive_format: ArchiveFormat,
tar_archive: Option<tar::Archive<&'a mut ArchiveReader<R>>>,
}
impl<'a, R: std::fmt::Debug + Read + Seek> std::fmt::Debug for Extract<'a, R> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Extract")
.field("reader", &self.reader)
.field("archive_format", &self.archive_format)
.finish()
}
}
impl<'a, R: Read + Seek> Extract<'a, R> {
/// Create archive from reader.
pub fn from_cursor(mut reader: R, archive_format: ArchiveFormat) -> Extract<'a, R> {
if reader.rewind().is_err() {
#[cfg(debug_assertions)]
eprintln!("Could not seek to start of the file");
}
let compression = if let ArchiveFormat::Tar(compression) = archive_format {
compression
} else {
None
};
Extract {
reader: match compression {
Some(Compression::Gz) => {
ArchiveReader::GzCompressed(Box::new(flate2::read::GzDecoder::new(reader)))
}
_ => ArchiveReader::Plain(reader),
},
archive_format,
tar_archive: None,
}
}
/// Reads the archive content.
pub fn with_files<
E: Into<crate::api::Error>,
F: FnMut(Entry<'_, &mut ArchiveReader<R>>) -> std::result::Result<bool, E>,
>(
&'a mut self,
mut f: F,
) -> crate::api::Result<()> {
match self.archive_format {
ArchiveFormat::Tar(_) => {
let archive = tar::Archive::new(&mut self.reader);
self.tar_archive.replace(archive);
for entry in self.tar_archive.as_mut().unwrap().entries()? {
let entry = entry?;
if entry.path().is_ok() {
let stop = f(Entry::Tar(Box::new(entry))).map_err(Into::into)?;
if stop {
break;
}
}
}
}
ArchiveFormat::Zip => {
#[cfg(feature = "fs-extract-api")]
{
let mut archive = zip::ZipArchive::new(self.reader.get_mut())?;
let file_names = archive
.file_names()
.map(|f| f.to_string())
.collect::<Vec<String>>();
for path in file_names {
let mut zip_file = archive.by_name(&path)?;
let is_dir = zip_file.is_dir();
let mut file_contents = Vec::new();
zip_file.read_to_end(&mut file_contents)?;
let stop = f(Entry::Zip(ZipEntry {
path: path.into(),
is_dir,
file_contents,
}))
.map_err(Into::into)?;
if stop {
break;
}
}
}
}
}
Ok(())
}
/// Extract an entire source archive into a specified path. If the source is a single compressed
/// file and not an archive, it will be extracted into a file with the same name inside of
/// `into_dir`.
pub fn extract_into(&mut self, into_dir: &path::Path) -> crate::api::Result<()> {
match self.archive_format {
ArchiveFormat::Tar(_) => {
let mut archive = tar::Archive::new(&mut self.reader);
archive.unpack(into_dir)?;
}
ArchiveFormat::Zip => {
#[cfg(feature = "fs-extract-api")]
{
let mut archive = zip::ZipArchive::new(self.reader.get_mut())?;
for i in 0..archive.len() {
let mut file = archive.by_index(i)?;
// Decode the file name from raw bytes instead of using file.name() directly.
// file.name() uses String::from_utf8_lossy() which may return messy characters
// such as: 爱交易.app/, that does not work as expected.
// Here we require the file name must be a valid UTF-8.
let file_name = String::from_utf8(file.name_raw().to_vec())?;
let out_path = into_dir.join(file_name);
if file.is_dir() {
fs::create_dir_all(&out_path)?;
} else {
if let Some(out_path_parent) = out_path.parent() {
fs::create_dir_all(out_path_parent)?;
}
let mut out_file = fs::File::create(&out_path)?;
io::copy(&mut file, &mut out_file)?;
}
// Get and Set permissions
#[cfg(unix)]
{
use std::os::unix::fs::PermissionsExt;
if let Some(mode) = file.unix_mode() {
fs::set_permissions(&out_path, fs::Permissions::from_mode(mode))?;
}
}
}
}
}
}
Ok(())
}
}
fn set_perms(
dst: &Path,
f: Option<&mut std::fs::File>,
mode: u32,
preserve: bool,
) -> crate::api::Result<()> {
_set_perms(dst, f, mode, preserve).map_err(|_| {
crate::api::Error::Extract(format!(
"failed to set permissions to {mode:o} \
for `{}`",
dst.display()
))
})
}
#[cfg(unix)]
fn _set_perms(
dst: &Path,
f: Option<&mut std::fs::File>,
mode: u32,
preserve: bool,
) -> io::Result<()> {
use std::os::unix::prelude::*;
let mode = if preserve { mode } else { mode & 0o777 };
let perm = fs::Permissions::from_mode(mode as _);
match f {
Some(f) => f.set_permissions(perm),
None => fs::set_permissions(dst, perm),
}
}
#[cfg(windows)]
fn _set_perms(
dst: &Path,
f: Option<&mut std::fs::File>,
mode: u32,
_preserve: bool,
) -> io::Result<()> {
if mode & 0o200 == 0o200 {
return Ok(());
}
match f {
Some(f) => {
let mut perm = f.metadata()?.permissions();
perm.set_readonly(true);
f.set_permissions(perm)
}
None => {
let mut perm = fs::metadata(dst)?.permissions();
perm.set_readonly(true);
fs::set_permissions(dst, perm)
}
}
}

View File

@ -1,114 +0,0 @@
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
use ignore::WalkBuilder;
use std::{fs, path};
/// Moves a file from the given path to the specified destination.
///
/// `source` and `dest` must be on the same filesystem.
/// If `replace_using_temp` is specified, the destination file will be
/// replaced using the given temporary path.
///
/// * Errors:
/// * Io - copying / renaming
#[derive(Debug)]
pub struct Move<'a> {
source: &'a path::Path,
temp: Option<&'a path::Path>,
}
impl<'a> Move<'a> {
/// Specify source file
pub fn from_source(source: &'a path::Path) -> Move<'a> {
Self { source, temp: None }
}
/// If specified and the destination file already exists, the "destination"
/// file will be moved to the given temporary location before the "source"
/// file is moved to the "destination" file.
///
/// In the event of an `io` error while renaming "source" to "destination",
/// the temporary file will be moved back to "destination".
///
/// The `temp` dir must be explicitly provided since `rename` operations require
/// files to live on the same filesystem.
pub fn replace_using_temp(&mut self, temp: &'a path::Path) -> &mut Self {
self.temp = Some(temp);
self
}
/// Move source file to specified destination (replace whole directory)
pub fn to_dest(&self, dest: &path::Path) -> crate::api::Result<()> {
match self.temp {
None => {
fs::rename(self.source, dest)?;
}
Some(temp) => {
if dest.exists() {
fs::rename(dest, temp)?;
if let Err(e) = fs::rename(self.source, dest) {
fs::rename(temp, dest)?;
return Err(e.into());
}
} else {
fs::rename(self.source, dest)?;
}
}
};
Ok(())
}
/// Walk in the source and copy all files and create directories if needed by
/// replacing existing elements. (equivalent to a cp -R)
pub fn walk_to_dest(&self, dest: &path::Path) -> crate::api::Result<()> {
match self.temp {
None => {
// got no temp -- no need to backup
walkdir_and_copy(self.source, dest)?;
}
Some(temp) => {
if dest.exists() {
// we got temp and our dest exist, lets make a backup
// of current files
walkdir_and_copy(dest, temp)?;
if let Err(e) = walkdir_and_copy(self.source, dest) {
// if we got something wrong we reset the dest with our backup
fs::rename(temp, dest)?;
return Err(e);
}
} else {
// got temp but dest didnt exist
walkdir_and_copy(self.source, dest)?;
}
}
};
Ok(())
}
}
// Walk into the source and create directories, and copy files
// Overwriting existing items but keeping untouched the files in the dest
// not provided in the source.
fn walkdir_and_copy(source: &path::Path, dest: &path::Path) -> crate::api::Result<()> {
let walkdir = WalkBuilder::new(source).hidden(false).build();
for entry in walkdir {
// Check if it's a file
let element = entry?;
let metadata = element.metadata()?;
let destination = dest.join(element.path().strip_prefix(source)?);
// we make sure it's a directory and destination doesnt exist
if metadata.is_dir() && !&destination.exists() {
fs::create_dir_all(&destination)?;
}
// we make sure it's a file
if metadata.is_file() {
fs::copy(element.path(), destination)?;
}
}
Ok(())
}

View File

@ -19,7 +19,7 @@ use crate::{
window::{PendingWindow, WindowEvent as RuntimeWindowEvent},
ExitRequestedEventAction, RunEvent as RuntimeRunEvent,
},
scope::{FsScope, IpcScope},
scope::IpcScope,
sealed::{ManagerBase, RuntimeOrDispatch},
utils::config::Config,
utils::{assets::Assets, Env},
@ -27,6 +27,9 @@ use crate::{
Runtime, Scopes, StateManager, Theme, Window,
};
#[cfg(feature = "protocol-asset")]
use crate::scope::FsScope;
use raw_window_handle::HasRawDisplayHandle;
use tauri_macros::default_runtime;
use tauri_runtime::window::{
@ -174,18 +177,11 @@ pub enum RunEvent {
///
/// This event is useful as a place to put your code that should be run after all state-changing events have been handled and you want to do stuff (updating state, performing calculations, etc) that happens as the “main body” of your event loop.
MainEventsCleared,
/// Updater event.
#[cfg(updater)]
#[cfg_attr(doc_cfg, doc(cfg(feature = "updater")))]
Updater(crate::UpdaterEvent),
}
impl From<EventLoopMessage> for RunEvent {
fn from(event: EventLoopMessage) -> Self {
match event {
#[cfg(updater)]
EventLoopMessage::Updater(event) => RunEvent::Updater(event),
}
match event {}
}
}
@ -252,13 +248,6 @@ pub struct AppHandle<R: Runtime> {
pub(crate) manager: WindowManager<R>,
}
impl<R: Runtime> AppHandle<R> {
/// Creates a proxy to send events through the event loop.
pub fn create_proxy(&self) -> R::EventLoopProxy {
self.runtime_handle.create_proxy()
}
}
/// APIs specific to the wry runtime.
#[cfg(feature = "wry")]
impl AppHandle<crate::Wry> {
@ -1347,12 +1336,8 @@ impl<R: Runtime> Builder<R> {
app.manage(Scopes {
ipc: IpcScope::new(&app.config()),
fs: FsScope::for_fs_api(&app, &app.config().tauri.allowlist.fs.scope)?,
#[cfg(protocol_asset)]
asset_protocol: FsScope::for_fs_api(
&app,
&app.config().tauri.allowlist.protocol.asset_scope,
)?,
#[cfg(feature = "protocol-asset")]
asset_protocol: FsScope::for_fs_api(&app, &app.config().tauri.security.asset_protocol.scope)?,
});
#[cfg(windows)]

View File

@ -34,18 +34,9 @@ pub enum Error {
/// Runtime error.
#[error("runtime error: {0}")]
Runtime(#[from] tauri_runtime::Error),
/// Failed to create window.
#[error("failed to create window")]
CreateWindow,
/// Window label must be unique.
#[error("a window with label `{0}` already exists")]
WindowLabelAlreadyExists(String),
/// Can't access webview dispatcher because the webview was closed or not found.
#[error("webview not found: invalid label or it was closed")]
WebviewNotFound,
/// Failed to send message to webview.
#[error("failed to send message to the webview")]
FailedToSendMessage,
/// Embedded asset not found.
#[error("asset not found: {0}")]
AssetNotFound(String),
@ -61,9 +52,6 @@ pub enum Error {
/// Failed to load window icon.
#[error("invalid icon: {0}")]
InvalidIcon(std::io::Error),
/// API not whitelisted on tauri.conf.json
#[error("'{0}' not in the allowlist (https://tauri.app/docs/api/config#tauri.allowlist)")]
ApiNotAllowlisted(String),
/// Invalid args when running a command.
#[error("invalid args `{1}` for command `{0}`: {2}")]
InvalidArgs(&'static str, &'static str, serde_json::Error),

View File

@ -16,15 +16,12 @@
//! - **linux-protocol-headers**: Enables headers support for custom protocol requests on Linux. Requires webkit2gtk v2.36 or above.
//! - **isolation**: Enables the isolation pattern. Enabled by default if the `tauri > pattern > use` config option is set to `isolation` on the `tauri.conf.json` file.
//! - **custom-protocol**: Feature managed by the Tauri CLI. When enabled, Tauri assumes a production environment instead of a development one.
//! - **updater**: Enables the application auto updater. Enabled by default if the `updater` config is defined on the `tauri.conf.json` file.
//! - **devtools**: Enables the developer tools (Web inspector) and [`Window::open_devtools`]. Enabled by default on debug builds.
//! On macOS it uses private APIs, so you can't enable it if your app will be published to the App Store.
//! - **native-tls**: Provides TLS support to connect over HTTPS.
//! - **native-tls-vendored**: Compile and statically link to a vendored copy of OpenSSL.
//! - **rustls-tls**: Provides TLS support to connect over HTTPS using rustls.
//! - **process-relaunch-dangerous-allow-symlink-macos**: Allows the [`process::current_binary`] function to allow symlinks on macOS (this is dangerous, see the Security section in the documentation website).
//! - **dialog**: Enables the [`api::dialog`] module.
//! - **fs-extract-api**: Enabled the `tauri::api::file::Extract` API.
//! - **system-tray**: Enables application system tray API. Enabled by default if the `systemTray` config is defined on the `tauri.conf.json` file.
//! - **macos-private-api**: Enables features only available in **macOS**'s private APIs, currently the `transparent` window functionality and the `fullScreenEnabled` preference setting to `true`. Enabled by default if the `tauri > macosPrivateApi` config flag is set to `true` on the `tauri.conf.json` file.
//! - **window-data-url**: Enables usage of data URLs on the webview.
@ -39,115 +36,9 @@
//! The following are a list of [Cargo features](https://doc.rust-lang.org/stable/cargo/reference/manifest.html#the-features-section) that enables commands for Tauri's API package.
//! These features are automatically enabled by the Tauri CLI based on the `allowlist` configuration under `tauri.conf.json`.
//!
//! - **api-all**: Enables all API endpoints.
//!
//! ### Clipboard allowlist
//!
//! - **clipboard-all**: Enables all [Clipboard APIs](https://tauri.app/en/docs/api/js/modules/clipboard/).
//! - **clipboard-read-text**: Enables the [`readText` API](https://tauri.app/en/docs/api/js/modules/clipboard/#readtext).
//! - **clipboard-write-text**: Enables the [`writeText` API](https://tauri.app/en/docs/api/js/modules/clipboard/#writetext).
//!
//! ### Dialog allowlist
//!
//! - **dialog-all**: Enables all [Dialog APIs](https://tauri.app/en/docs/api/js/modules/dialog).
//! - **dialog-ask**: Enables the [`ask` API](https://tauri.app/en/docs/api/js/modules/dialog#ask).
//! - **dialog-confirm**: Enables the [`confirm` API](https://tauri.app/en/docs/api/js/modules/dialog#confirm).
//! - **dialog-message**: Enables the [`message` API](https://tauri.app/en/docs/api/js/modules/dialog#message).
//! - **dialog-open**: Enables the [`open` API](https://tauri.app/en/docs/api/js/modules/dialog#open).
//! - **dialog-save**: Enables the [`save` API](https://tauri.app/en/docs/api/js/modules/dialog#save).
//!
//! ### Filesystem allowlist
//!
//! - **fs-all**: Enables all [Filesystem APIs](https://tauri.app/en/docs/api/js/modules/fs).
//! - **fs-copy-file**: Enables the [`copyFile` API](https://tauri.app/en/docs/api/js/modules/fs#copyfile).
//! - **fs-create-dir**: Enables the [`createDir` API](https://tauri.app/en/docs/api/js/modules/fs#createdir).
//! - **fs-exists**: Enables the [`exists` API](https://tauri.app/en/docs/api/js/modules/fs#exists).
//! - **fs-read-dir**: Enables the [`readDir` API](https://tauri.app/en/docs/api/js/modules/fs#readdir).
//! - **fs-read-file**: Enables the [`readTextFile` API](https://tauri.app/en/docs/api/js/modules/fs#readtextfile) and the [`readBinaryFile` API](https://tauri.app/en/docs/api/js/modules/fs#readbinaryfile).
//! - **fs-remove-dir**: Enables the [`removeDir` API](https://tauri.app/en/docs/api/js/modules/fs#removedir).
//! - **fs-remove-file**: Enables the [`removeFile` API](https://tauri.app/en/docs/api/js/modules/fs#removefile).
//! - **fs-rename-file**: Enables the [`renameFile` API](https://tauri.app/en/docs/api/js/modules/fs#renamefile).
//! - **fs-write-file**: Enables the [`writeFile` API](https://tauri.app/en/docs/api/js/modules/fs#writefile) and the [`writeBinaryFile` API](https://tauri.app/en/docs/api/js/modules/fs#writebinaryfile).
//!
//! ### Global shortcut allowlist
//!
//! - **global-shortcut-all**: Enables all [GlobalShortcut APIs](https://tauri.app/en/docs/api/js/modules/globalShortcut).
//!
//! ### HTTP allowlist
//!
//! - **http-all**: Enables all [HTTP APIs](https://tauri.app/en/docs/api/js/modules/http).
//! - **http-request**: Enables the [`request` APIs](https://tauri.app/en/docs/api/js/classes/http.client/).
//!
//! ### Notification allowlist
//!
//! - **notification-all**: Enables all [Notification APIs](https://tauri.app/en/docs/api/js/modules/notification).
//!
//! ### OS allowlist
//!
//! - **os-all**: Enables all [OS APIs](https://tauri.app/en/docs/api/js/modules/os).
//!
//! ### Path allowlist
//!
//! - **path-all**: Enables all [Path APIs](https://tauri.app/en/docs/api/js/modules/path).
//!
//! ### Process allowlist
//!
//! - **process-all**: Enables all [Process APIs](https://tauri.app/en/docs/api/js/modules/process).
//! - **process-exit**: Enables the [`exit` API](https://tauri.app/en/docs/api/js/modules/process#exit).
//! - **process-relaunch**: Enables the [`relaunch` API](https://tauri.app/en/docs/api/js/modules/process#relaunch).
//!
//! ### Protocol allowlist
//!
//! - **protocol-all**: Enables all Protocol APIs.
//! - **protocol-asset**: Enables the `asset` custom protocol.
//!
//! ### Shell allowlist
//!
//! - **shell-all**: Enables all [Clipboard APIs](https://tauri.app/en/docs/api/js/modules/shell).
//! - **shell-execute**: Enables [executing arbitrary programs](https://tauri.app/en/docs/api/js/classes/shell.Command#constructor).
//! - **shell-sidecar**: Enables [executing a `sidecar` program](https://tauri.app/en/docs/api/js/classes/shell.Command#sidecar).
//! - **shell-open**: Enables the [`open` API](https://tauri.app/en/docs/api/js/modules/shell#open).
//!
//! ### Window allowlist
//!
//! - **window-all**: Enables all [Window APIs](https://tauri.app/en/docs/api/js/modules/window).
//! - **window-create**: Enables the API used to [create new windows](https://tauri.app/en/docs/api/js/classes/window.webviewwindow/).
//! - **window-center**: Enables the [`center` API](https://tauri.app/en/docs/api/js/classes/window.WebviewWindow#center).
//! - **window-request-user-attention**: Enables the [`requestUserAttention` API](https://tauri.app/en/docs/api/js/classes/window.WebviewWindow#requestuserattention).
//! - **window-set-resizable**: Enables the [`setResizable` API](https://tauri.app/en/docs/api/js/classes/window.WebviewWindow#setresizable).
//! - **window-set-title**: Enables the [`setTitle` API](https://tauri.app/en/docs/api/js/classes/window.WebviewWindow#settitle).
//! - **window-maximize**: Enables the [`maximize` API](https://tauri.app/en/docs/api/js/classes/window.WebviewWindow#maximize).
//! - **window-unmaximize**: Enables the [`unmaximize` API](https://tauri.app/en/docs/api/js/classes/window.WebviewWindow#unmaximize).
//! - **window-minimize**: Enables the [`minimize` API](https://tauri.app/en/docs/api/js/classes/window.WebviewWindow#minimize).
//! - **window-unminimize**: Enables the [`unminimize` API](https://tauri.app/en/docs/api/js/classes/window.WebviewWindow#unminimize).
//! - **window-show**: Enables the [`show` API](https://tauri.app/en/docs/api/js/classes/window.WebviewWindow#show).
//! - **window-hide**: Enables the [`hide` API](https://tauri.app/en/docs/api/js/classes/window.WebviewWindow#hide).
//! - **window-close**: Enables the [`close` API](https://tauri.app/en/docs/api/js/classes/window.WebviewWindow#close).
//! - **window-set-decorations**: Enables the [`setDecorations` API](https://tauri.app/en/docs/api/js/classes/window.WebviewWindow#setdecorations).
//! - **window-set-shadow**: Enables the [`setShadow` API](https://tauri.app/en/docs/api/js/classes/window.WebviewWindow#setshadow).
//! - **window-set-always-on-top**: Enables the [`setAlwaysOnTop` API](https://tauri.app/en/docs/api/js/classes/window.WebviewWindow#setalwaysontop).
//! - **window-set-content-protected**: Enables the [`setContentProtected` API](https://tauri.app/en/docs/api/js/classes/window.WebviewWindow#setcontentprotected).
//! - **window-set-size**: Enables the [`setSize` API](https://tauri.app/en/docs/api/js/classes/window.WebviewWindow#setsize).
//! - **window-set-min-size**: Enables the [`setMinSize` API](https://tauri.app/en/docs/api/js/classes/window.WebviewWindow#setminsize).
//! - **window-set-max-size**: Enables the [`setMaxSize` API](https://tauri.app/en/docs/api/js/classes/window.WebviewWindow#setmaxsize).
//! - **window-set-position**: Enables the [`setPosition` API](https://tauri.app/en/docs/api/js/classes/window.WebviewWindow#setposition).
//! - **window-set-fullscreen**: Enables the [`setFullscreen` API](https://tauri.app/en/docs/api/js/classes/window.WebviewWindow#setfullscreen).
//! - **window-set-focus**: Enables the [`setFocus` API](https://tauri.app/en/docs/api/js/classes/window.WebviewWindow#setfocus).
//! - **window-set-icon**: Enables the [`setIcon` API](https://tauri.app/en/docs/api/js/classes/window.WebviewWindow#seticon).
//! - **window-set-skip-taskbar**: Enables the [`setSkipTaskbar` API](https://tauri.app/en/docs/api/js/classes/window.WebviewWindow#setskiptaskbar).
//! - **window-set-cursor-grab**: Enables the [`setCursorGrab` API](https://tauri.app/en/docs/api/js/classes/window.WebviewWindow#setcursorgrab).
//! - **window-set-cursor-visible**: Enables the [`setCursorVisible` API](https://tauri.app/en/docs/api/js/classes/window.WebviewWindow#setcursorvisible).
//! - **window-set-cursor-icon**: Enables the [`setCursorIcon` API](https://tauri.app/en/docs/api/js/classes/window.WebviewWindow#setcursoricon).
//! - **window-set-cursor-position**: Enables the [`setCursorPosition` API](https://tauri.app/en/docs/api/js/classes/window.WebviewWindow#setcursorposition).
//! - **window-set-ignore-cursor-events**: Enables the [`setIgnoreCursorEvents` API](https://tauri.app/en/docs/api/js/classes/window.WebviewWindow#setignorecursorevents).
//! - **window-start-dragging**: Enables the [`startDragging` API](https://tauri.app/en/docs/api/js/classes/window.WebviewWindow#startdragging).
//! - **window-print**: Enables the [`print` API](https://tauri.app/en/docs/api/js/classes/window.WebviewWindow#print).
//!
//! ### App allowlist
//!
//! - **app-all**: Enables all [App APIs](https://tauri.app/en/docs/api/js/modules/app).
//! - **app-show**: Enables the [`show` API](https://tauri.app/en/docs/api/js/modules/app#show).
//! - **app-hide**: Enables the [`hide` API](https://tauri.app/en/docs/api/js/modules/app#hide).
#![warn(missing_docs, rust_2018_idioms)]
#![cfg_attr(doc_cfg, feature(doc_cfg))]
@ -338,48 +229,9 @@ pub fn log_stdout() {
});
}
/// Updater events.
#[cfg(updater)]
#[cfg_attr(doc_cfg, doc(cfg(feature = "updater")))]
#[derive(Debug, Clone)]
pub enum UpdaterEvent {
/// An update is available.
UpdateAvailable {
/// The update body.
body: String,
/// The update release date.
date: Option<time::OffsetDateTime>,
/// The update version.
version: String,
},
/// The update is pending and about to be downloaded.
Pending,
/// The update download received a progress event.
DownloadProgress {
/// The amount that was downloaded on this iteration.
/// Does not accumulate with previous chunks.
chunk_length: usize,
/// The total
content_length: Option<u64>,
},
/// The update has been downloaded and is now about to be installed.
Downloaded,
/// The update has been applied and the app is now up to date.
Updated,
/// The app is already up to date.
AlreadyUpToDate,
/// An error occurred while updating.
Error(String),
}
/// The user event type.
#[derive(Debug, Clone)]
pub enum EventLoopMessage {
/// Updater event.
#[cfg(updater)]
#[cfg_attr(doc_cfg, doc(cfg(feature = "updater")))]
Updater(UpdaterEvent),
}
pub enum EventLoopMessage {}
/// The webview runtime interface. A wrapper around [`runtime::Runtime`] with the proper user event type associated.
pub trait Runtime: runtime::Runtime<EventLoopMessage> {}
@ -845,18 +697,13 @@ pub trait Manager<R: Runtime>: sealed::ManagerBase<R> {
self.state::<Env>().inner().clone()
}
/// Gets the scope for the filesystem APIs.
fn fs_scope(&self) -> FsScope {
self.state::<Scopes>().inner().fs.clone()
}
/// Gets the scope for the IPC.
fn ipc_scope(&self) -> IpcScope {
self.state::<Scopes>().inner().ipc.clone()
}
/// Gets the scope for the asset protocol.
#[cfg(protocol_asset)]
#[cfg(feature = "protocol-asset")]
fn asset_protocol_scope(&self) -> FsScope {
self.state::<Scopes>().inner().asset_protocol.clone()
}
@ -937,53 +784,6 @@ mod tests {
}
}
}
#[test]
fn all_allowlist_features_are_aliased() {
let manifest = get_manifest();
let all_modules = manifest
.features
.iter()
.find(|(f, _)| f.as_str() == "api-all")
.map(|(_, enabled)| enabled)
.expect("api-all feature must exist");
let checked_features = CHECKED_FEATURES.split(',').collect::<Vec<&str>>();
assert!(
checked_features.contains(&"api-all"),
"`api-all` is not aliased"
);
// features that look like an allowlist feature, but are not
let allowed = [
"fs-extract-api",
"process-relaunch-dangerous-allow-symlink-macos",
"window-data-url",
];
for module_all_feature in all_modules {
let module = module_all_feature.replace("-all", "");
assert!(
checked_features.contains(&module_all_feature.as_str()),
"`{module}` is not aliased"
);
let module_prefix = format!("{module}-");
// we assume that module features are the ones that start with `<module>-`
// though it's not 100% accurate, we have an allowed list to fix it
let module_features = manifest
.features
.keys()
.filter(|f| f.starts_with(&module_prefix));
for module_feature in module_features {
assert!(
allowed.contains(&module_feature.as_str())
|| checked_features.contains(&module_feature.as_str()),
"`{module_feature}` is not aliased"
);
}
}
}
}
#[cfg(test)]

View File

@ -505,7 +505,7 @@ impl<R: Runtime> WindowManager<R> {
registered_scheme_protocols.push("tauri".into());
}
#[cfg(protocol_asset)]
#[cfg(feature = "protocol-asset")]
if !registered_scheme_protocols.contains(&"asset".into()) {
use crate::path::SafePathBuf;
use tokio::io::{AsyncReadExt, AsyncSeekExt};
@ -1321,6 +1321,7 @@ impl<R: Runtime> WindowManager<R> {
pending,
&label,
window_labels,
#[allow(clippy::redundant_clone)]
app_handle.clone(),
web_resource_request_handler,
)?;

View File

@ -10,11 +10,8 @@ use std::{
};
pub use glob::Pattern;
use tauri_utils::config::FsAllowlistScope;
use uuid::Uuid;
use crate::{Manager, Runtime};
/// Scope change event.
#[derive(Debug, Clone)]
pub enum Event {
@ -81,9 +78,10 @@ fn push_pattern<P: AsRef<Path>, F: Fn(&str) -> Result<Pattern, glob::PatternErro
impl Scope {
/// Creates a new scope from a `FsAllowlistScope` configuration.
pub(crate) fn for_fs_api<R: Runtime, M: Manager<R>>(
#[allow(unused)]
pub(crate) fn for_fs_api<R: crate::Runtime, M: crate::Manager<R>>(
manager: &M,
scope: &FsAllowlistScope,
scope: &tauri_utils::config::FsScope,
) -> crate::Result<Self> {
let mut allowed_patterns = HashSet::new();
for path in scope.allowed_paths() {

View File

@ -10,27 +10,35 @@ pub use self::ipc::Scope as IpcScope;
pub use fs::{Event as FsScopeEvent, Pattern as GlobPattern, Scope as FsScope};
use std::path::Path;
pub(crate) struct Scopes {
pub ipc: IpcScope,
pub fs: FsScope,
#[cfg(protocol_asset)]
pub asset_protocol: FsScope,
/// Managed state for all the core scopes in a tauri application.
pub struct Scopes {
pub(crate) ipc: IpcScope,
#[cfg(feature = "protocol-asset")]
pub(crate) asset_protocol: FsScope,
}
impl Scopes {
#[allow(dead_code)]
pub(crate) fn allow_directory(&self, path: &Path, recursive: bool) -> crate::Result<()> {
self.fs.allow_directory(path, recursive)?;
#[cfg(protocol_asset)]
/// Allows a directory on the scopes.
#[allow(unused)]
pub fn allow_directory<P: AsRef<Path>>(&self, path: P, recursive: bool) -> crate::Result<()> {
#[cfg(feature = "protocol-asset")]
self.asset_protocol.allow_directory(path, recursive)?;
Ok(())
}
#[allow(dead_code)]
pub(crate) fn allow_file(&self, path: &Path) -> crate::Result<()> {
self.fs.allow_file(path)?;
#[cfg(protocol_asset)]
/// Allows a file on the scopes.
#[allow(unused)]
pub fn allow_file<P: AsRef<Path>>(&self, path: P) -> crate::Result<()> {
#[cfg(feature = "protocol-asset")]
self.asset_protocol.allow_file(path)?;
Ok(())
}
/// Forbids a file on the scopes.
#[allow(unused)]
pub fn forbid_file<P: AsRef<Path>>(&self, path: P) -> crate::Result<()> {
#[cfg(feature = "protocol-asset")]
self.asset_protocol.forbid_file(path)?;
Ok(())
}
}

View File

@ -44,9 +44,7 @@ pub fn mock_context<A: Assets>(assets: A) -> crate::Context<A> {
pattern: PatternKind::Brownfield,
windows: Vec::new(),
bundle: Default::default(),
allowlist: Default::default(),
security: Default::default(),
updater: Default::default(),
system_tray: None,
macos_private_api: false,
},

View File

@ -1582,7 +1582,6 @@ impl<R: Runtime> Window<R> {
objects::JObject,
JNIEnv,
};
use crate::api::ipc::CallbackFn;
fn handle_message<R: Runtime>(
plugin: &str,

View File

@ -9,9 +9,6 @@
"identifier": "studio.tauri.example",
"active": true
},
"allowlist": {
"all": true
},
"windows": [
{
"title": "Tauri App"
@ -19,9 +16,6 @@
],
"security": {
"csp": "default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self'"
},
"updater": {
"active": false
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -43,15 +43,6 @@ dependencies = [
"subtle",
]
[[package]]
name = "aho-corasick"
version = "0.7.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac"
dependencies = [
"memchr",
]
[[package]]
name = "aho-corasick"
version = "1.0.1"
@ -264,16 +255,6 @@ dependencies = [
"alloc-stdlib",
]
[[package]]
name = "bstr"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3d4260bcc2e8fc9df1eac4919a720effeb63a3f0952f5bf4944adfa18897f09"
dependencies = [
"memchr",
"serde",
]
[[package]]
name = "bumpalo"
version = "3.12.1"
@ -892,18 +873,6 @@ dependencies = [
"rustc_version",
]
[[package]]
name = "filetime"
version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5cbc844cecaee9d4443931972e1289c8ff485cb4cc2767cb03ca139ed6885153"
dependencies = [
"cfg-if",
"libc",
"redox_syscall 0.2.16",
"windows-sys 0.48.0",
]
[[package]]
name = "flate2"
version = "1.0.26"
@ -1262,19 +1231,6 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
[[package]]
name = "globset"
version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc"
dependencies = [
"aho-corasick 0.7.20",
"bstr",
"fnv",
"log",
"regex",
]
[[package]]
name = "gobject-sys"
version = "0.16.3"
@ -1531,23 +1487,6 @@ dependencies = [
"unicode-normalization",
]
[[package]]
name = "ignore"
version = "0.4.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbe7873dab538a9a44ad79ede1faf5f30d49f9a5c883ddbab48bce81b64b7492"
dependencies = [
"globset",
"lazy_static",
"log",
"memchr",
"regex",
"same-file",
"thread_local",
"walkdir",
"winapi-util",
]
[[package]]
name = "image"
version = "0.24.6"
@ -2494,7 +2433,7 @@ version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370"
dependencies = [
"aho-corasick 1.0.1",
"aho-corasick",
"memchr",
"regex-syntax 0.7.1",
]
@ -3020,17 +2959,6 @@ dependencies = [
"syn 1.0.109",
]
[[package]]
name = "tar"
version = "0.4.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b55807c0344e1e6c04d7c965f5289c39a8d94ae23ed5c0b57aabac549f871c6"
dependencies = [
"filetime",
"libc",
"xattr",
]
[[package]]
name = "target-lexicon"
version = "0.12.7"
@ -3046,8 +2974,6 @@ dependencies = [
"cocoa",
"dirs-next",
"embed_plist",
"encoding_rs",
"flate2",
"futures-util",
"glib",
"glob",
@ -3055,7 +2981,6 @@ dependencies = [
"heck",
"http",
"ico 0.2.0",
"ignore",
"infer 0.9.0",
"jni",
"libc",
@ -3074,7 +2999,6 @@ dependencies = [
"serialize-to-javascript",
"state",
"swift-rs",
"tar",
"tauri-build",
"tauri-macros",
"tauri-runtime",
@ -3096,7 +3020,6 @@ version = "2.0.0-alpha.4"
dependencies = [
"anyhow",
"cargo_toml",
"filetime",
"heck",
"json-patch",
"quote",
@ -3206,7 +3129,6 @@ dependencies = [
"thiserror",
"url",
"uuid",
"webview2-com",
"windows 0.44.0",
]
@ -4221,12 +4143,3 @@ dependencies = [
"once_cell",
"pkg-config",
]
[[package]]
name = "xattr"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d1526bbe5aaeb5eb06885f4d987bcdfa5e23187055de9b83fe00156a821fabc"
dependencies = [
"libc",
]

View File

@ -7,6 +7,7 @@ rust-version = "1.65"
license = "Apache-2.0 OR MIT"
[lib]
name = "api_lib"
crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies]
@ -34,7 +35,7 @@ tauri-build = { path = "../../../core/tauri-build" }
[dependencies.tauri]
path = "../../../core/tauri"
features = [
"api-all",
"protocol-asset",
"icon-ico",
"icon-png",
"isolation",

View File

@ -45,7 +45,6 @@ pub fn run() {
#[cfg(desktop)]
{
window_builder = window_builder
.user_agent("Tauri API")
.title("Tauri API Validation")
.inner_size(1000., 800.)
.min_inner_size(600., 400.)

View File

@ -7,5 +7,5 @@
fn main() {
#[cfg(desktop)]
api::run();
api_lib::run();
}

View File

@ -26,11 +26,7 @@
"name": "theme",
"takesValue": true,
"description": "App theme",
"possibleValues": [
"light",
"dark",
"system"
]
"possibleValues": ["light", "dark", "system"]
},
{
"short": "v",
@ -79,76 +75,31 @@
}
}
}
}
},
"allowlist": {
"all": true,
"fs": {
"scope": {
"allow": [
"$APPDATA/db/**",
"$DOWNLOAD/**",
"$RESOURCE/**"
],
"deny": [
"$APPDATA/db/*.stronghold"
]
},
"updater": {
"active": true,
"pubkey": "asdasd",
"windows": {
"installMode": "passive"
}
},
"shell": {
"open": true,
"scope": [
{
"name": "sh",
"cmd": "sh",
"args": [
"-c",
{
"validator": "\\S+"
}
]
},
{
"name": "cmd",
"cmd": "cmd",
"args": [
"/C",
{
"validator": "\\S+"
}
]
}
]
},
"protocol": {
"asset": true,
"assetScope": {
"allow": [
"$APPDATA/db/**",
"$RESOURCE/**"
],
"deny": [
"$APPDATA/db/*.stronghold"
]
}
},
"http": {
"scope": [
"http://localhost:3003"
]
}
},
"windows": [],
"security": {
"csp": {
"default-src": "'self' customprotocol: asset:",
"font-src": [
"https://fonts.gstatic.com"
],
"font-src": ["https://fonts.gstatic.com"],
"img-src": "'self' asset: https://asset.localhost blob: data:",
"style-src": "'unsafe-inline' 'self' https://fonts.googleapis.com"
},
"freezePrototype": true
"freezePrototype": true,
"assetProtocol": {
"enable": true,
"scope": {
"allow": ["$APPDATA/db/**", "$RESOURCE/**"],
"deny": ["$APPDATA/db/*.stronghold"]
}
}
},
"systemTray": {
"iconPath": "../../.icons/tray_icon_with_transparency.png",
@ -156,4 +107,4 @@
"menuOnLeftClick": false
}
}
}
}

View File

@ -1,12 +1,11 @@
<script>
import { onMount } from 'svelte'
import { writable } from 'svelte/store'
import Welcome from './views/Welcome.svelte'
import Communication from './views/Communication.svelte'
import WebRTC from './views/WebRTC.svelte'
import { onMount } from 'svelte'
const userAgent = navigator.userAgent.toLowerCase()
const isMobile = userAgent.includes('android') || userAgent.includes('iphone')
@ -191,7 +190,7 @@
<aside
id="sidebar"
class="lt-sm:h-screen lt-sm:shadow-lg lt-sm:shadow lt-sm:transition-transform lt-sm:absolute lt-sm:z-1999
bg-darkPrimaryLighter transition-colors-250 overflow-hidden grid select-none px-2"
bg-darkPrimaryLighter transition-colors-250 overflow-hidden grid grid-rows-[min-content_auto] select-none px-2"
>
<img
class="self-center p-7 cursor-pointer"

View File

@ -5,7 +5,3 @@
development process. In the future, this app will be used on Tauri's integration
tests.
</p>
<br />
<br />
<br />

View File

@ -37,9 +37,6 @@
"exceptionDomain": ""
}
},
"allowlist": {
"all": false
},
"windows": [
{
"title": "Welcome to Tauri!",
@ -51,9 +48,6 @@
],
"security": {
"csp": "default-src 'self'"
},
"updater": {
"active": false
}
}
}

View File

@ -36,9 +36,6 @@
"exceptionDomain": ""
}
},
"allowlist": {
"all": false
},
"windows": [
{
"title": "Welcome to Tauri!",

View File

@ -50,9 +50,6 @@
"timestampUrl": ""
}
},
"updater": {
"active": false
},
"windows": [
{
"title": "Isolation",

View File

@ -26,11 +26,6 @@
"copyright": "",
"category": "DeveloperTool"
},
"allowlist": {
"window": {
"create": true
}
},
"windows": [
{
"label": "Main",
@ -49,9 +44,6 @@
],
"security": {
"csp": "default-src 'self'"
},
"updater": {
"active": false
}
}
}

View File

@ -37,11 +37,6 @@
"exceptionDomain": ""
}
},
"allowlist": {
"window": {
"create": true
}
},
"windows": [
{
"title": "Welcome to Tauri!",
@ -53,9 +48,6 @@
],
"security": {
"csp": "default-src 'self'"
},
"updater": {
"active": false
}
}
}

View File

@ -26,12 +26,8 @@
"copyright": "",
"category": "DeveloperTool"
},
"allowlist": {},
"security": {
"csp": "default-src 'self'"
},
"updater": {
"active": false
}
}
}

View File

@ -37,12 +37,6 @@
"exceptionDomain": ""
}
},
"allowlist": {
"all": false,
"shell": {
"execute": true
}
},
"windows": [
{
"title": "Welcome to Tauri!",
@ -54,9 +48,6 @@
],
"security": {
"csp": "default-src 'self'"
},
"updater": {
"active": false
}
}
}

View File

@ -1,43 +0,0 @@
# Sidecar example
This example demonstrates how to use the Tauri sidecar feature. It uses [pkg](https://github.com/vercel/pkg) to compile a Node.js application and bundle it on the Tauri application.
## Running the example
- Compile Tauri
go to root of the Tauri repo and run:
Linux / Mac:
```
# choose to install node cli (1)
bash .scripts/setup.sh
```
Windows:
```
./.scripts/setup.ps1
```
- Install dependencies (Run inside of this folder `examples/sidecar/`)
```bash
# with yarn
$ yarn
# with npm
$ npm install
$ yarn tauri
$ yarn package
```
- Run the app in development mode (Run inside of this folder `examples/sidecar/`)
```bash
# with yarn
$ yarn tauri dev
# with npm
$ npm run tauri dev
```
- Build an run the release app (Run inside of this folder `examples/sidecar/`)
```bash
$ yarn tauri build
$ ./src-tauri/target/release/app
```

View File

@ -1,55 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Sidecar</title>
<style>
.container {
display: flex;
}
.container > div {
flex: 1;
}
</style>
</head>
<body>
<div class="container">
<div id="backend"></div>
<div id="frontend"></div>
</div>
<script>
function addMessage(div, message) {
const p = document.createElement('p')
p.innerText = message
div.appendChild(p)
}
const backendDiv = document.getElementById('backend')
window.__TAURI__.event.listen('message', (event) => {
addMessage(backendDiv, event.payload)
})
const frontendDiv = document.getElementById('frontend')
const { Command } = window.__TAURI__.shell
const command = Command.sidecar('binaries/app')
command.on('close', (data) => {
addMessage(
frontendDiv,
`command finished with code ${data.code} and signal ${data.signal}`
)
})
command.on('error', (error) =>
addMessage(frontendDiv, `command error: "${error}"`)
)
command.stdout.on('data', (line) =>
addMessage(frontendDiv, `command stdout: "${line}"`)
)
command.stderr.on('data', (line) =>
addMessage(frontendDiv, `command stderr: "${line}"`)
)
command.spawn()
</script>
</body>
</html>

View File

@ -1,18 +0,0 @@
{
"name": "sidecar",
"version": "1.0.0",
"bin": "src/index.js",
"pkg": {
"assets": [
"src/**/*"
]
},
"scripts": {
"tauri": "node ../../tooling/cli/node/tauri.js",
"package": "pkg package.json --output src-tauri/binaries/app && node scripts/move-binary.js"
},
"devDependencies": {
"execa": "5.1.1",
"pkg": "5.2.1"
}
}

View File

@ -1,32 +0,0 @@
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
/**
* This script is used to rename the binary with the platform specific postfix.
* When `tauri build` is ran, it looks for the binary name appended with the platform specific postfix.
*/
const execa = require('execa')
const fs = require('fs')
let extension = ''
if (process.platform === 'win32') {
extension = '.exe'
}
async function main() {
const rustInfo = (await execa('rustc', ['-vV'])).stdout
const targetTriple = /host: (\S+)/g.exec(rustInfo)[1]
if (!targetTriple) {
console.error('Failed to determine platform target triple')
}
fs.renameSync(
`src-tauri/binaries/app${extension}`,
`src-tauri/binaries/app-${targetTriple}${extension}`
)
}
main().catch((e) => {
throw e
})

View File

@ -1,4 +0,0 @@
# Generated by Cargo
# will have compiled files and executables
/target/
binaries/

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +0,0 @@
[package]
name = "sidecar"
version = "0.1.0"
description = "A Tauri application with a sidecar binary"
edition = "2021"
rust-version = "1.65"
[build-dependencies]
tauri-build = { path = "../../../core/tauri-build", features = ["codegen"] }
[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = [ "derive" ] }
tauri = { path = "../../../core/tauri", features = ["process-command-api", "shell-sidecar"] }
[features]
custom-protocol = [ "tauri/custom-protocol" ]

View File

@ -1,7 +0,0 @@
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
fn main() {
tauri_build::build()
}

View File

@ -1,41 +0,0 @@
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use tauri::{
process::{Command, CommandEvent},
Manager,
};
fn main() {
tauri::Builder::default()
.setup(|app| {
let window = app.get_window("main").unwrap();
tauri::async_runtime::spawn(async move {
let (mut rx, mut child) = Command::new_sidecar("app")
.expect("failed to setup `app` sidecar")
.spawn()
.expect("Failed to spawn packaged node");
let mut i = 0;
while let Some(event) = rx.recv().await {
if let CommandEvent::Stdout(line) = event {
window
.emit("message", Some(format!("'{}'", line)))
.expect("failed to emit event");
i += 1;
if i == 4 {
child.write("message from Rust\n".as_bytes()).unwrap();
i = 0;
}
}
}
});
Ok(())
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

View File

@ -1,68 +0,0 @@
{
"$schema": "../../../core/tauri-config-schema/schema.json",
"build": {
"distDir": ["../index.html"],
"devPath": ["../index.html"],
"beforeDevCommand": "yarn package",
"beforeBuildCommand": "yarn package",
"withGlobalTauri": true
},
"package": {
"productName": "Sidecar",
"version": "0.1.0"
},
"tauri": {
"bundle": {
"active": true,
"targets": "all",
"identifier": "com.tauri.sidecar",
"icon": [
"../../.icons/32x32.png",
"../../.icons/128x128.png",
"../../.icons/128x128@2x.png",
"../../.icons/icon.icns",
"../../.icons/icon.ico"
],
"resources": [],
"externalBin": ["binaries/app"],
"copyright": "",
"category": "DeveloperTool",
"shortDescription": "",
"longDescription": "",
"deb": {
"depends": []
},
"macOS": {
"frameworks": [],
"exceptionDomain": ""
}
},
"allowlist": {
"all": false,
"shell": {
"sidecar": true,
"scope": [
{
"name": "binaries/app",
"sidecar": true
}
]
}
},
"windows": [
{
"title": "Sidecar",
"width": 800,
"height": 600,
"resizable": true,
"fullscreen": false
}
],
"security": {
"csp": "default-src 'self'"
},
"updater": {
"active": false
}
}
}

View File

@ -1,22 +0,0 @@
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
const readline = require('readline')
module.exports = {
onMessage(cb) {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
})
rl.on('line', function (line) {
cb(line)
})
},
write(message) {
console.log(message)
}
}

View File

@ -1,13 +0,0 @@
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
const { write, onMessage } = require('./communication')
onMessage((line) => {
write(`read ${line}`)
})
setInterval(() => {
write(`[${new Date().toLocaleTimeString()}] new message`)
}, 500)

File diff suppressed because it is too large Load Diff

View File

@ -26,9 +26,6 @@
"copyright": "",
"category": "DeveloperTool"
},
"allowlist": {
"all": false
},
"windows": [
{
"label": "main",
@ -48,9 +45,6 @@
],
"security": {
"csp": "default-src 'self'"
},
"updater": {
"active": false
}
}
}

View File

@ -37,9 +37,6 @@
"exceptionDomain": ""
}
},
"allowlist": {
"all": false
},
"windows": [
{
"title": "Welcome to Tauri!",
@ -51,9 +48,6 @@
],
"security": {
"csp": "default-src 'self'"
},
"updater": {
"active": false
}
}
}

View File

@ -37,12 +37,6 @@
"exceptionDomain": ""
}
},
"allowlist": {
"all": false,
"protocol": {
"assetScope": ["**/test_video.mp4"]
}
},
"windows": [
{
"title": "Welcome to Tauri!",
@ -53,10 +47,10 @@
}
],
"security": {
"csp": "default-src 'self'; media-src stream: https://stream.localhost asset: https://asset.localhost"
},
"updater": {
"active": false
"csp": "default-src 'self'; media-src stream: https://stream.localhost asset: https://asset.localhost",
"assetProtocol": {
"scope": ["**/test_video.mp4"]
}
}
}
}

View File

@ -36,9 +36,6 @@
"exceptionDomain": ""
}
},
"allowlist": {
"all": false
},
"windows": [
{
"title": "Welcome to Tauri!",
@ -50,9 +47,6 @@
],
"security": {
"csp": "default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self'"
},
"updater": {
"active": false
}
}
}

View File

@ -10,9 +10,6 @@
"version": "0.1.0"
},
"tauri": {
"allowlist": {
"all": false
},
"bundle": {
"active": true,
"category": "DeveloperTool",
@ -59,4 +56,4 @@
}
]
}
}
}

View File

@ -11,9 +11,6 @@
"productName": "workspace"
},
"tauri": {
"allowlist": {
"all": false
},
"bundle": {
"active": true,
"category": "DeveloperTool",
@ -60,4 +57,4 @@
}
]
}
}
}

File diff suppressed because one or more lines are too long

View File

@ -14,8 +14,8 @@
*/
import * as event from './event'
import * as path from './path'
import * as tauri from './tauri'
import * as path from './path'
/** @ignore */
const invoke = tauri.invoke

View File

@ -7,18 +7,6 @@
*
* This package is also accessible with `window.__TAURI__.path` when [`build.withGlobalTauri`](https://tauri.app/v1/api/config/#buildconfig.withglobaltauri) in `tauri.conf.json` is set to `true`.
*
* The APIs must be added to [`tauri.allowlist.path`](https://tauri.app/v1/api/config/#allowlistconfig.path) in `tauri.conf.json`:
* ```json
* {
* "tauri": {
* "allowlist": {
* "path": {
* "all": true, // enable all Path APIs
* }
* }
* }
* }
* ```
* It is recommended to allowlist only the APIs you use for optimal bundle size and security.
* @module
*/

View File

@ -1,21 +1,8 @@
{
"entryPoints": [
"src/app.ts",
"src/cli.ts",
"src/clipboard.ts",
"src/dialog.ts",
"src/event.ts",
"src/fs.ts",
"src/globalShortcut.ts",
"src/http.ts",
"src/mocks.ts",
"src/notification.ts",
"src/os.ts",
"src/path.ts",
"src/process.ts",
"src/shell.ts",
"src/tauri.ts",
"src/updater.ts",
"src/window.ts"
],
"githubPages": false,

View File

@ -33,9 +33,6 @@
"exceptionDomain": ""
}
},
"allowlist": {
"all": false
},
"windows": [
{
"title": "Welcome to Tauri!",
@ -49,4 +46,4 @@
"csp": "default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self'"
}
}
}
}

View File

@ -33,15 +33,6 @@
"exceptionDomain": ""
}
},
"allowlist": {
"all": false,
"fs": {
"readFile": true,
"scope": [
"$HOME/.tauri_3mb.json"
]
}
},
"windows": [
{
"title": "Welcome to Tauri!",
@ -55,4 +46,4 @@
"csp": "default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self'"
}
}
}
}

View File

@ -33,9 +33,6 @@
"exceptionDomain": ""
}
},
"allowlist": {
"all": false
},
"windows": [
{
"title": "Welcome to Tauri!",
@ -49,4 +46,4 @@
"csp": "default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self'"
}
}
}
}

View File

@ -137,8 +137,6 @@ pub struct PackageSettings {
pub struct UpdaterSettings {
/// Whether the updater is active or not.
pub active: bool,
/// The updater endpoints.
pub endpoints: Option<Vec<String>>,
/// Signature public key.
pub pubkey: String,
/// Args to pass to `msiexec.exe` to run the updater on Windows.

View File

@ -6,9 +6,6 @@
"withGlobalTauri": true
},
"tauri": {
"allowlist": {
"all": true
},
"bundle": {
"icon": [
"icons/32x32.png",

File diff suppressed because it is too large Load Diff

View File

@ -112,7 +112,7 @@ pub fn command(mut options: Options, verbosity: u8) -> Result<()> {
};
if let Some(types) = &package_types {
if config_.tauri.updater.active && !types.contains(&PackageType::Updater) {
if config_.tauri.bundle.updater.active && !types.contains(&PackageType::Updater) {
warn!("The updater is enabled but the bundle target list does not contain `updater`, so the updater artifacts won't be generated.");
}
}
@ -142,13 +142,6 @@ pub fn command(mut options: Options, verbosity: u8) -> Result<()> {
// set env vars used by the bundler
#[cfg(target_os = "linux")]
{
use crate::helpers::config::ShellAllowlistOpen;
if matches!(
config_.tauri.allowlist.shell.open,
ShellAllowlistOpen::Flag(true) | ShellAllowlistOpen::Validate(_)
) {
std::env::set_var("APPIMAGE_BUNDLE_XDG_OPEN", "1");
}
if config_.tauri.system_tray.is_some() {
if let Ok(tray) = std::env::var("TAURI_TRAY") {
std::env::set_var(
@ -188,7 +181,7 @@ pub fn command(mut options: Options, verbosity: u8) -> Result<()> {
.filter(|bundle| bundle.package_type == PackageType::Updater)
.collect();
// If updater is active and we bundled it
if config_.tauri.updater.active && !updater_bundles.is_empty() {
if config_.tauri.bundle.updater.active && !updater_bundles.is_empty() {
// if no password provided we use an empty string
let password = var_os("TAURI_KEY_PASSWORD")
.map(|v| v.to_str().unwrap().to_string())
@ -211,7 +204,7 @@ pub fn command(mut options: Options, verbosity: u8) -> Result<()> {
}?;
let pubkey =
base64::engine::general_purpose::STANDARD.decode(&config_.tauri.updater.pubkey)?;
base64::engine::general_purpose::STANDARD.decode(&config_.tauri.bundle.updater.pubkey)?;
let pub_key_decoded = String::from_utf8_lossy(&pubkey);
let public_key = minisign::PublicKeyBox::from_string(&pub_key_decoded)?.into_public_key()?;

View File

@ -693,7 +693,6 @@ impl AppSettings for RustAppSettings {
features,
config.tauri.bundle.clone(),
config.tauri.system_tray.clone(),
config.tauri.updater.clone(),
)
}
@ -1029,7 +1028,6 @@ fn tauri_config_to_bundle_settings(
features: &[String],
config: crate::helpers::config::BundleConfig,
system_tray_config: Option<crate::helpers::config::SystemTrayConfig>,
updater_config: crate::helpers::config::UpdaterConfig,
) -> crate::Result<BundleSettings> {
let enabled_features = manifest.all_enabled_features(features);
@ -1159,12 +1157,9 @@ fn tauri_config_to_bundle_settings(
allow_downgrades: config.windows.allow_downgrades,
},
updater: Some(UpdaterSettings {
active: updater_config.active,
pubkey: updater_config.pubkey,
endpoints: updater_config
.endpoints
.map(|endpoints| endpoints.iter().map(|e| e.to_string()).collect()),
msiexec_args: Some(updater_config.windows.install_mode.msiexec_args()),
active: config.updater.active,
pubkey: config.updater.pubkey,
msiexec_args: Some(config.updater.windows.install_mode.msiexec_args()),
}),
..Default::default()
})

View File

@ -11,9 +11,6 @@
"version": "0.0.0"
},
"tauri": {
"allowlist": {
"all": true
},
"bundle": {
"active": true,
"category": "DeveloperTool",
@ -50,9 +47,6 @@
"security": {
"csp": null
},
"updater": {
"active": false
},
"windows": [
{
"fullscreen": false,

View File

@ -40,12 +40,6 @@
"timestampUrl": ""
}
},
"updater": {
"active": false
},
"allowlist": {
"all": false
},
"windows": [
{
"title": "app",

View File

@ -43,9 +43,6 @@
"timestampUrl": ""
}
},
"allowlist": {
"all": false
},
"windows": [
{
"title": "{{ window_title }}",
@ -59,4 +56,4 @@
"csp": null
}
}
}
}