mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-01-31 00:35:19 +01:00
feat(core): implement new config structure (#8723)
* feat(core): implement new config structure RFC#5f3e82a6b0c/texts/0005-tauri-config-restructure.md* fixes * remove tauri-plugin copy [skip ci] * move platform specific configs * fix build * fix cli * doctests * change files * read updater plugin config on CLI * doctests * remove env var from docs * fix getting pubkey * add migrations * clippy * update change file [skip ci] * rename frontendDist to prodFrontend? * Revert "rename frontendDist to prodFrontend?" This reverts commitef7394f085. * fix all_features check * fix field name * single license getter on bundler * readd msiexec_args * remove unused fixture * update template * Update .changes/tauri-bundle-settings-rfc-5.md * Update .changes/config-restructure-rfc-5.md * lint bundler, fix change file * rename AppUrl to FrontendDist, add explicit variants for docs * fix build * lint --------- Co-authored-by: Lucas Nogueira <lucas@tauri.studio> Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.app>
This commit is contained in:
25
.changes/config-restructure-rfc-5.md
Normal file
25
.changes/config-restructure-rfc-5.md
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
'tauri': 'major:breaking'
|
||||
'tauri-utils': 'major:breaking'
|
||||
'tauri-build': 'major:breaking'
|
||||
'tauri-codegen': 'major:breaking'
|
||||
'tauri-cli': 'major:breaking'
|
||||
'@tauri-apps/cli': 'major:breaking'
|
||||
---
|
||||
|
||||
Restructured Tauri config per [RFC#5](https://github.com/tauri-apps/rfcs/blob/f3e82a6b0c5390401e855850d47dc7b7d9afd684/texts/0005-tauri-config-restructure.md):
|
||||
|
||||
- Moved `package.productName`, `package.version` and `tauri.bundle.identifier` fields to the top-level.
|
||||
- Removed `package` object.
|
||||
- Renamed `tauri` object to `app`.
|
||||
- Moved `tauri.bundle` object to the top-level.
|
||||
- Renamed `build.distDir` field to `frontendDist`.
|
||||
- Renamed `build.devPath` field to `devUrl` and will no longer accepts paths, it will only accept URLs.
|
||||
- Moved `tauri.pattern` to `app.security.pattern`.
|
||||
- Removed `tauri.bundle.updater` object, and its fields have been moved to the updater plugin under `plugins.updater` object.
|
||||
- Moved `build.withGlobalTauri` to `app.withGlobalTauri`.
|
||||
- Moved `tauri.bundle.dmg` object to `bundle.macOS.dmg`.
|
||||
- Moved `tauri.bundle.deb` object to `bundle.linux.deb`.
|
||||
- Moved `tauri.bundle.appimage` object to `bundle.linux.appimage`.
|
||||
- Removed all license fields from each bundle configuration object and instead added `bundle.license` and `bundle.licenseFile`.
|
||||
- Renamed `AppUrl` to `FrontendDist` and refactored its variants to be more explicit.
|
||||
5
.changes/tauri-bundle-settings-rfc-5.md
Normal file
5
.changes/tauri-bundle-settings-rfc-5.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'tauri-bundler': 'major:breaking'
|
||||
---
|
||||
|
||||
- Removed all license fields from `WixSettings`, `NsisSettings` and `MacOsSettings` and replaced with `license` and `license_file` fields in `BundlerSettings`.
|
||||
@@ -10,7 +10,7 @@ use std::{
|
||||
path::PathBuf,
|
||||
};
|
||||
use tauri_codegen::{context_codegen, ContextData};
|
||||
use tauri_utils::config::{AppUrl, WebviewUrl};
|
||||
use tauri_utils::config::FrontendDist;
|
||||
|
||||
// TODO docs
|
||||
/// A builder for generating a Tauri application context during compile time.
|
||||
@@ -82,16 +82,11 @@ impl CodegenContext {
|
||||
let (config, config_parent) = tauri_codegen::get_config(&self.config_path)?;
|
||||
|
||||
// rerun if changed
|
||||
let app_url = if self.dev {
|
||||
&config.build.dev_path
|
||||
} else {
|
||||
&config.build.dist_dir
|
||||
};
|
||||
match app_url {
|
||||
Some(AppUrl::Url(WebviewUrl::App(p))) => {
|
||||
match &config.build.frontend_dist {
|
||||
Some(FrontendDist::Dist(p)) => {
|
||||
println!("cargo:rerun-if-changed={}", config_parent.join(p).display());
|
||||
}
|
||||
Some(AppUrl::Files(files)) => {
|
||||
Some(FrontendDist::Files(files)) => {
|
||||
for path in files {
|
||||
println!(
|
||||
"cargo:rerun-if-changed={}",
|
||||
@@ -101,13 +96,13 @@ impl CodegenContext {
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
for icon in &config.tauri.bundle.icon {
|
||||
for icon in &config.bundle.icon {
|
||||
println!(
|
||||
"cargo:rerun-if-changed={}",
|
||||
config_parent.join(icon).display()
|
||||
);
|
||||
}
|
||||
if let Some(tray_icon) = config.tauri.tray_icon.as_ref().map(|t| &t.icon_path) {
|
||||
if let Some(tray_icon) = config.app.tray_icon.as_ref().map(|t| &t.icon_path) {
|
||||
println!(
|
||||
"cargo:rerun-if-changed={}",
|
||||
config_parent.join(tray_icon).display()
|
||||
|
||||
@@ -437,7 +437,7 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
|
||||
}
|
||||
let config: Config = serde_json::from_value(config)?;
|
||||
|
||||
let s = config.tauri.bundle.identifier.split('.');
|
||||
let s = config.identifier.split('.');
|
||||
let last = s.clone().count() - 1;
|
||||
let mut android_package_prefix = String::new();
|
||||
for (i, w) in s.enumerate() {
|
||||
@@ -501,7 +501,7 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
|
||||
.parent()
|
||||
.unwrap();
|
||||
|
||||
if let Some(paths) = &config.tauri.bundle.external_bin {
|
||||
if let Some(paths) = &config.bundle.external_bin {
|
||||
copy_binaries(
|
||||
ResourcePaths::new(external_binaries(paths, &target_triple).as_slice(), true),
|
||||
&target_triple,
|
||||
@@ -512,16 +512,15 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
|
||||
|
||||
#[allow(unused_mut, clippy::redundant_clone)]
|
||||
let mut resources = config
|
||||
.tauri
|
||||
.bundle
|
||||
.resources
|
||||
.clone()
|
||||
.unwrap_or_else(|| BundleResources::List(Vec::new()));
|
||||
if target_triple.contains("windows") {
|
||||
if let Some(fixed_webview2_runtime_path) =
|
||||
match &config.tauri.bundle.windows.webview_fixed_runtime_path {
|
||||
match &config.bundle.windows.webview_fixed_runtime_path {
|
||||
Some(path) => Some(path),
|
||||
None => match &config.tauri.bundle.windows.webview_install_mode {
|
||||
None => match &config.bundle.windows.webview_install_mode {
|
||||
WebviewInstallMode::FixedRuntime { path } => Some(path),
|
||||
_ => None,
|
||||
},
|
||||
@@ -538,7 +537,7 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
|
||||
}
|
||||
|
||||
if target_triple.contains("darwin") {
|
||||
if let Some(frameworks) = &config.tauri.bundle.macos.frameworks {
|
||||
if let Some(frameworks) = &config.bundle.macos.frameworks {
|
||||
if !frameworks.is_empty() {
|
||||
let frameworks_dir = target_dir.parent().unwrap().join("Frameworks");
|
||||
let _ = std::fs::remove_dir_all(&frameworks_dir);
|
||||
@@ -552,7 +551,7 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(version) = &config.tauri.bundle.macos.minimum_system_version {
|
||||
if let Some(version) = &config.bundle.macos.minimum_system_version {
|
||||
println!("cargo:rustc-env=MACOSX_DEPLOYMENT_TARGET={version}");
|
||||
}
|
||||
}
|
||||
@@ -563,7 +562,6 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
|
||||
|
||||
fn find_icon<F: Fn(&&String) -> bool>(config: &Config, predicate: F, default: &str) -> PathBuf {
|
||||
let icon_path = config
|
||||
.tauri
|
||||
.bundle
|
||||
.icon
|
||||
.iter()
|
||||
@@ -586,7 +584,7 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
|
||||
res.set_manifest(include_str!("window-app-manifest.xml"));
|
||||
}
|
||||
|
||||
if let Some(version_str) = &config.package.version {
|
||||
if let Some(version_str) = &config.version {
|
||||
if let Ok(v) = Version::parse(version_str) {
|
||||
let version = v.major << 48 | v.minor << 32 | v.patch << 16;
|
||||
res.set_version_info(VersionInfo::FILEVERSION, version);
|
||||
@@ -594,15 +592,15 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(product_name) = &config.package.product_name {
|
||||
if let Some(product_name) = &config.product_name {
|
||||
res.set("ProductName", product_name);
|
||||
}
|
||||
|
||||
if let Some(short_description) = &config.tauri.bundle.short_description {
|
||||
if let Some(short_description) = &config.bundle.short_description {
|
||||
res.set("FileDescription", short_description);
|
||||
}
|
||||
|
||||
if let Some(copyright) = &config.tauri.bundle.copyright {
|
||||
if let Some(copyright) = &config.bundle.copyright {
|
||||
res.set("LegalCopyright", copyright);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
use cargo_toml::{Dependency, Manifest};
|
||||
use tauri_utils::config::{Config, PatternKind, TauriConfig};
|
||||
use tauri_utils::config::{AppConfig, Config, PatternKind};
|
||||
|
||||
#[derive(Debug, Default, PartialEq, Eq)]
|
||||
struct Diff {
|
||||
@@ -34,7 +34,7 @@ pub fn check(config: &Config, manifest: &mut Manifest) -> Result<()> {
|
||||
alias: None,
|
||||
kind: DependencyKind::Build,
|
||||
all_cli_managed_features: Some(vec!["isolation"]),
|
||||
expected_features: match config.tauri.pattern {
|
||||
expected_features: match config.app.security.pattern {
|
||||
PatternKind::Isolation { .. } => vec!["isolation".to_string()],
|
||||
_ => vec![],
|
||||
},
|
||||
@@ -44,13 +44,13 @@ pub fn check(config: &Config, manifest: &mut Manifest) -> Result<()> {
|
||||
alias: None,
|
||||
kind: DependencyKind::Normal,
|
||||
all_cli_managed_features: Some(
|
||||
TauriConfig::all_features()
|
||||
AppConfig::all_features()
|
||||
.into_iter()
|
||||
.filter(|f| f != &"tray-icon")
|
||||
.collect(),
|
||||
),
|
||||
expected_features: config
|
||||
.tauri
|
||||
.app
|
||||
.features()
|
||||
.into_iter()
|
||||
.filter(|f| f != &"tray-icon")
|
||||
|
||||
@@ -15,7 +15,7 @@ use tauri_utils::acl::capability::Capability;
|
||||
use tauri_utils::acl::plugin::Manifest;
|
||||
use tauri_utils::acl::resolved::Resolved;
|
||||
use tauri_utils::assets::AssetKey;
|
||||
use tauri_utils::config::{AppUrl, Config, PatternKind, WebviewUrl};
|
||||
use tauri_utils::config::{Config, FrontendDist, PatternKind};
|
||||
use tauri_utils::html::{
|
||||
inject_nonce_token, parse as parse_html, serialize_node as serialize_html_node,
|
||||
};
|
||||
@@ -134,53 +134,43 @@ pub fn context_codegen(data: ContextData) -> Result<TokenStream, EmbeddedAssetsE
|
||||
.map(Target::from_triple)
|
||||
.unwrap_or_else(|_| Target::current());
|
||||
|
||||
let mut options = AssetOptions::new(config.tauri.pattern.clone())
|
||||
.freeze_prototype(config.tauri.security.freeze_prototype)
|
||||
let mut options = AssetOptions::new(config.app.security.pattern.clone())
|
||||
.freeze_prototype(config.app.security.freeze_prototype)
|
||||
.dangerous_disable_asset_csp_modification(
|
||||
config
|
||||
.tauri
|
||||
.app
|
||||
.security
|
||||
.dangerous_disable_asset_csp_modification
|
||||
.clone(),
|
||||
);
|
||||
let csp = if dev {
|
||||
config
|
||||
.tauri
|
||||
.app
|
||||
.security
|
||||
.dev_csp
|
||||
.as_ref()
|
||||
.or(config.tauri.security.csp.as_ref())
|
||||
.or(config.app.security.csp.as_ref())
|
||||
} else {
|
||||
config.tauri.security.csp.as_ref()
|
||||
config.app.security.csp.as_ref()
|
||||
};
|
||||
if csp.is_some() {
|
||||
options = options.with_csp();
|
||||
}
|
||||
|
||||
let app_url = if dev {
|
||||
&config.build.dev_path
|
||||
} else {
|
||||
&config.build.dist_dir
|
||||
};
|
||||
|
||||
let assets = match app_url {
|
||||
let assets = match &config.build.frontend_dist {
|
||||
Some(url) => match url {
|
||||
AppUrl::Url(url) => match url {
|
||||
WebviewUrl::External(_) | WebviewUrl::CustomProtocol(_) => Default::default(),
|
||||
WebviewUrl::App(path) => {
|
||||
let assets_path = config_parent.join(path);
|
||||
if !assets_path.exists() {
|
||||
panic!(
|
||||
"The `{}` configuration is set to `{:?}` but this path doesn't exist",
|
||||
if dev { "devPath" } else { "distDir" },
|
||||
path
|
||||
)
|
||||
}
|
||||
EmbeddedAssets::new(assets_path, &options, map_core_assets(&options, target))?
|
||||
FrontendDist::Url(_url) => Default::default(),
|
||||
FrontendDist::Dist(path) => {
|
||||
let assets_path = config_parent.join(path);
|
||||
if !assets_path.exists() {
|
||||
panic!(
|
||||
"The `frontendDist` configuration is set to `{:?}` but this path doesn't exist",
|
||||
path
|
||||
)
|
||||
}
|
||||
_ => unimplemented!(),
|
||||
},
|
||||
AppUrl::Files(files) => EmbeddedAssets::new(
|
||||
EmbeddedAssets::new(assets_path, &options, map_core_assets(&options, target))?
|
||||
}
|
||||
FrontendDist::Files(files) => EmbeddedAssets::new(
|
||||
files
|
||||
.iter()
|
||||
.map(|p| config_parent.join(p))
|
||||
@@ -257,12 +247,12 @@ pub fn context_codegen(data: ContextData) -> Result<TokenStream, EmbeddedAssetsE
|
||||
quote!(::std::option::Option::None)
|
||||
};
|
||||
|
||||
let package_name = if let Some(product_name) = &config.package.product_name {
|
||||
let package_name = if let Some(product_name) = &config.product_name {
|
||||
quote!(#product_name.to_string())
|
||||
} else {
|
||||
quote!(env!("CARGO_PKG_NAME").to_string())
|
||||
};
|
||||
let package_version = if let Some(version) = &config.package.version {
|
||||
let package_version = if let Some(version) = &config.version {
|
||||
semver::Version::from_str(version)?;
|
||||
quote!(#version.to_string())
|
||||
} else {
|
||||
@@ -279,7 +269,7 @@ pub fn context_codegen(data: ContextData) -> Result<TokenStream, EmbeddedAssetsE
|
||||
);
|
||||
|
||||
let with_tray_icon_code = if target.is_desktop() {
|
||||
if let Some(tray) = &config.tauri.tray_icon {
|
||||
if let Some(tray) = &config.app.tray_icon {
|
||||
let tray_icon_icon_path = config_parent.join(&tray.icon_path);
|
||||
let ext = tray_icon_icon_path.extension();
|
||||
if ext.map_or(false, |e| e == "ico") {
|
||||
@@ -311,10 +301,10 @@ pub fn context_codegen(data: ContextData) -> Result<TokenStream, EmbeddedAssetsE
|
||||
};
|
||||
|
||||
if let Some(plist) = info_plist.as_dictionary_mut() {
|
||||
if let Some(product_name) = &config.package.product_name {
|
||||
if let Some(product_name) = &config.product_name {
|
||||
plist.insert("CFBundleName".into(), product_name.clone().into());
|
||||
}
|
||||
if let Some(version) = &config.package.version {
|
||||
if let Some(version) = &config.version {
|
||||
plist.insert("CFBundleShortVersionString".into(), version.clone().into());
|
||||
}
|
||||
let format =
|
||||
@@ -533,7 +523,6 @@ fn find_icon<F: Fn(&&String) -> bool>(
|
||||
default: &str,
|
||||
) -> PathBuf {
|
||||
let icon_path = config
|
||||
.tauri
|
||||
.bundle
|
||||
.icon
|
||||
.iter()
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -316,15 +316,31 @@ pub struct DebConfig {
|
||||
pub desktop_template: Option<PathBuf>,
|
||||
}
|
||||
|
||||
/// Configuration for Linux bundles.
|
||||
///
|
||||
/// See more: <https://tauri.app/v1/api/config#linuxconfig>
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
pub struct LinuxConfig {
|
||||
/// Configuration for the AppImage bundle.
|
||||
#[serde(default)]
|
||||
pub appimage: AppImageConfig,
|
||||
/// Configuration for the Debian bundle.
|
||||
#[serde(default)]
|
||||
pub deb: DebConfig,
|
||||
/// Configuration for the RPM bundle.
|
||||
#[serde(default)]
|
||||
pub rpm: RpmConfig,
|
||||
}
|
||||
|
||||
/// Configuration for RPM bundles.
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
pub struct RpmConfig {
|
||||
/// The package's license identifier. If not set, defaults to the license from
|
||||
/// the Cargo.toml file.
|
||||
pub license: Option<String>,
|
||||
/// The list of RPM dependencies your application relies on.
|
||||
pub depends: Option<Vec<String>>,
|
||||
/// The RPM release tag.
|
||||
@@ -345,7 +361,6 @@ pub struct RpmConfig {
|
||||
impl Default for RpmConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
license: None,
|
||||
depends: None,
|
||||
release: default_release(),
|
||||
epoch: 0,
|
||||
@@ -476,8 +491,6 @@ pub struct MacConfig {
|
||||
/// It should be a lowercase, without port and protocol domain name.
|
||||
#[serde(alias = "exception-domain")]
|
||||
pub exception_domain: Option<String>,
|
||||
/// The path to the license file to add to the DMG bundle.
|
||||
pub license: Option<String>,
|
||||
/// Identity to use for code signing.
|
||||
#[serde(alias = "signing-identity")]
|
||||
pub signing_identity: Option<String>,
|
||||
@@ -486,6 +499,9 @@ pub struct MacConfig {
|
||||
pub provider_short_name: Option<String>,
|
||||
/// Path to the entitlements file.
|
||||
pub entitlements: Option<String>,
|
||||
/// DMG-specific settings.
|
||||
#[serde(default)]
|
||||
pub dmg: DmgConfig,
|
||||
}
|
||||
|
||||
impl Default for MacConfig {
|
||||
@@ -495,10 +511,10 @@ impl Default for MacConfig {
|
||||
files: HashMap::new(),
|
||||
minimum_system_version: minimum_system_version(),
|
||||
exception_domain: None,
|
||||
license: None,
|
||||
signing_identity: None,
|
||||
provider_short_name: None,
|
||||
entitlements: None,
|
||||
dmg: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -573,10 +589,6 @@ pub struct WixConfig {
|
||||
/// Will be removed in v2, prefer the [`WindowsConfig::webview_install_mode`] option.
|
||||
#[serde(default, alias = "skip-webview-install")]
|
||||
pub skip_webview_install: bool,
|
||||
/// The path to the license file to render on the installer.
|
||||
///
|
||||
/// Must be an RTF file, so if a different extension is provided, we convert it to the RTF format.
|
||||
pub license: Option<PathBuf>,
|
||||
/// Create an elevated update task within Windows Task Scheduler.
|
||||
#[serde(default, alias = "enable-elevated-update-task")]
|
||||
pub enable_elevated_update_task: bool,
|
||||
@@ -616,8 +628,6 @@ pub enum NsisCompression {
|
||||
pub struct NsisConfig {
|
||||
/// A custom .nsi template to use.
|
||||
pub template: Option<PathBuf>,
|
||||
/// 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.
|
||||
@@ -885,65 +895,6 @@ pub struct DeepLinkProtocol {
|
||||
pub role: BundleTypeRole,
|
||||
}
|
||||
|
||||
/// 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))]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
pub struct UpdaterConfig {
|
||||
/// Whether the updater is active or not.
|
||||
#[serde(default)]
|
||||
pub active: bool,
|
||||
/// Signature public key.
|
||||
#[serde(default)] // use default just so the schema doesn't flag it as required
|
||||
pub pubkey: String,
|
||||
/// The Windows configuration for the updater.
|
||||
#[serde(default)]
|
||||
pub windows: UpdaterWindowsConfig,
|
||||
}
|
||||
|
||||
impl<'de> Deserialize<'de> for UpdaterConfig {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
#[derive(Deserialize)]
|
||||
struct InnerUpdaterConfig {
|
||||
#[serde(default)]
|
||||
active: bool,
|
||||
pubkey: Option<String>,
|
||||
#[serde(default)]
|
||||
windows: UpdaterWindowsConfig,
|
||||
}
|
||||
|
||||
let config = InnerUpdaterConfig::deserialize(deserializer)?;
|
||||
|
||||
if config.active && config.pubkey.is_none() {
|
||||
return Err(DeError::custom(
|
||||
"The updater `pubkey` configuration is required.",
|
||||
));
|
||||
}
|
||||
|
||||
Ok(UpdaterConfig {
|
||||
active: config.active,
|
||||
pubkey: config.pubkey.unwrap_or_default(),
|
||||
windows: config.windows,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for UpdaterConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
active: false,
|
||||
pubkey: "".into(),
|
||||
windows: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Definition for bundle resources.
|
||||
/// Can be either a list of paths to include or a map of source to target paths.
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
@@ -983,12 +934,6 @@ pub struct BundleConfig {
|
||||
/// The bundle targets, currently supports ["deb", "rpm", "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`).
|
||||
/// This string must be unique across applications since it is used in system configurations like
|
||||
/// the bundle ID and path to the webview data directory.
|
||||
/// 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>,
|
||||
@@ -1001,6 +946,12 @@ pub struct BundleConfig {
|
||||
pub resources: Option<BundleResources>,
|
||||
/// A copyright string associated with your application.
|
||||
pub copyright: Option<String>,
|
||||
/// The package's license identifier to be included in the appropriate bundles.
|
||||
/// If not set, defaults to the license from the Cargo.toml file.
|
||||
pub license: Option<String>,
|
||||
/// The path to the license file to be included in the appropriate bundles.
|
||||
#[serde(alias = "license-file")]
|
||||
pub license_file: Option<PathBuf>,
|
||||
/// The application kind.
|
||||
///
|
||||
/// Should be one of the following:
|
||||
@@ -1014,21 +965,6 @@ pub struct BundleConfig {
|
||||
/// A longer, multi-line description of the application.
|
||||
#[serde(alias = "long-description")]
|
||||
pub long_description: Option<String>,
|
||||
/// Configuration for the AppImage bundle.
|
||||
#[serde(default)]
|
||||
pub appimage: AppImageConfig,
|
||||
/// Configuration for the Debian bundle.
|
||||
#[serde(default)]
|
||||
pub deb: DebConfig,
|
||||
/// Configuration for the RPM bundle.
|
||||
#[serde(default)]
|
||||
pub rpm: RpmConfig,
|
||||
/// DMG-specific settings.
|
||||
#[serde(default)]
|
||||
pub dmg: DmgConfig,
|
||||
/// Configuration for the macOS bundles.
|
||||
#[serde(rename = "macOS", default)]
|
||||
pub macos: MacConfig,
|
||||
/// A list of—either absolute or relative—paths to binaries to embed with your application.
|
||||
///
|
||||
/// Note that Tauri will look for system-specific binaries following the pattern "binary-name{-target-triple}{.system-extension}".
|
||||
@@ -1042,18 +978,21 @@ pub struct BundleConfig {
|
||||
/// so don't forget to provide binaries for all targeted platforms.
|
||||
#[serde(alias = "external-bin")]
|
||||
pub external_bin: Option<Vec<String>>,
|
||||
/// Configuration for the Windows bundle.
|
||||
/// Configuration for the Windows bundles.
|
||||
#[serde(default)]
|
||||
pub windows: WindowsConfig,
|
||||
/// Configuration for the Linux bundles.
|
||||
#[serde(default)]
|
||||
pub linux: LinuxConfig,
|
||||
/// Configuration for the macOS bundles.
|
||||
#[serde(rename = "macOS", alias = "macos", default)]
|
||||
pub macos: MacConfig,
|
||||
/// iOS configuration.
|
||||
#[serde(rename = "iOS", default)]
|
||||
#[serde(rename = "iOS", alias = "ios", default)]
|
||||
pub ios: IosConfig,
|
||||
/// Android configuration.
|
||||
#[serde(default)]
|
||||
pub android: AndroidConfig,
|
||||
/// The updater configuration.
|
||||
#[serde(default)]
|
||||
pub updater: UpdaterConfig,
|
||||
}
|
||||
|
||||
/// a tuple struct of RGBA colors. Each value has minimum of 0 and maximum of 255.
|
||||
@@ -1616,6 +1555,9 @@ pub struct SecurityConfig {
|
||||
/// Custom protocol config.
|
||||
#[serde(default, alias = "asset-protocol")]
|
||||
pub asset_protocol: AssetProtocolConfig,
|
||||
/// The pattern to use.
|
||||
#[serde(default)]
|
||||
pub pattern: PatternKind,
|
||||
}
|
||||
|
||||
/// The application pattern.
|
||||
@@ -1639,23 +1581,17 @@ impl Default for PatternKind {
|
||||
}
|
||||
}
|
||||
|
||||
/// The Tauri configuration object.
|
||||
/// The App configuration object.
|
||||
///
|
||||
/// See more: <https://tauri.app/v1/api/config#tauriconfig>
|
||||
/// See more: <https://tauri.app/v1/api/config#appconfig>
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
pub struct TauriConfig {
|
||||
/// The pattern to use.
|
||||
#[serde(default)]
|
||||
pub pattern: PatternKind,
|
||||
pub struct AppConfig {
|
||||
/// The windows configuration.
|
||||
#[serde(default)]
|
||||
pub windows: Vec<WindowConfig>,
|
||||
/// The bundler configuration.
|
||||
#[serde(default)]
|
||||
pub bundle: BundleConfig,
|
||||
/// Security configuration.
|
||||
#[serde(default)]
|
||||
pub security: SecurityConfig,
|
||||
@@ -1665,16 +1601,19 @@ pub struct TauriConfig {
|
||||
/// MacOS private API configuration. Enables the transparent background API and sets the `fullScreenEnabled` preference to `true`.
|
||||
#[serde(rename = "macOSPrivateApi", alias = "macos-private-api", default)]
|
||||
pub macos_private_api: bool,
|
||||
/// Whether we should inject the Tauri API on `window.__TAURI__` or not.
|
||||
#[serde(default, alias = "with-global-tauri")]
|
||||
pub with_global_tauri: bool,
|
||||
}
|
||||
|
||||
impl TauriConfig {
|
||||
impl AppConfig {
|
||||
/// Returns all Cargo features.
|
||||
pub fn all_features() -> Vec<&'static str> {
|
||||
vec![
|
||||
"tray-icon",
|
||||
"macos-private-api",
|
||||
"isolation",
|
||||
"protocol-asset",
|
||||
"isolation",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1687,112 +1626,19 @@ impl TauriConfig {
|
||||
if self.macos_private_api {
|
||||
features.push("macos-private-api");
|
||||
}
|
||||
if let PatternKind::Isolation { .. } = self.pattern {
|
||||
features.push("isolation");
|
||||
}
|
||||
if self.security.asset_protocol.enable {
|
||||
features.push("protocol-asset");
|
||||
}
|
||||
|
||||
if let PatternKind::Isolation { .. } = self.security.pattern {
|
||||
features.push("isolation");
|
||||
}
|
||||
|
||||
features.sort_unstable();
|
||||
features
|
||||
}
|
||||
}
|
||||
|
||||
/// Install modes for the Windows update.
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[cfg_attr(feature = "schema", schemars(rename_all = "camelCase"))]
|
||||
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.
|
||||
Quiet,
|
||||
/// Specifies unattended mode, which means the installation only shows a progress bar.
|
||||
Passive,
|
||||
// to add more modes, we need to check if the updater relaunch makes sense
|
||||
// i.e. for a full UI mode, the user can also mark the installer to start the app
|
||||
}
|
||||
|
||||
impl WindowsUpdateInstallMode {
|
||||
/// Returns the associated `msiexec.exe` arguments.
|
||||
pub fn msiexec_args(&self) -> &'static [&'static str] {
|
||||
match self {
|
||||
Self::BasicUi => &["/qb+"],
|
||||
Self::Quiet => &["/quiet"],
|
||||
Self::Passive => &["/passive"],
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the associated nsis arguments.
|
||||
pub fn nsis_args(&self) -> &'static [&'static str] {
|
||||
match self {
|
||||
Self::Passive => &["/P", "/R"],
|
||||
Self::Quiet => &["/S", "/R"],
|
||||
_ => &[],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for WindowsUpdateInstallMode {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{}",
|
||||
match self {
|
||||
Self::BasicUi => "basicUI",
|
||||
Self::Quiet => "quiet",
|
||||
Self::Passive => "passive",
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for WindowsUpdateInstallMode {
|
||||
fn default() -> Self {
|
||||
Self::Passive
|
||||
}
|
||||
}
|
||||
|
||||
impl Serialize for WindowsUpdateInstallMode {
|
||||
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 WindowsUpdateInstallMode {
|
||||
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let s = String::deserialize(deserializer)?;
|
||||
match s.to_lowercase().as_str() {
|
||||
"basicui" => Ok(Self::BasicUi),
|
||||
"quiet" => Ok(Self::Quiet),
|
||||
"passive" => Ok(Self::Passive),
|
||||
_ => Err(DeError::custom(format!(
|
||||
"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 {
|
||||
/// The installation mode for the update on Windows. Defaults to `passive`.
|
||||
#[serde(default, alias = "install-mode")]
|
||||
pub install_mode: WindowsUpdateInstallMode,
|
||||
}
|
||||
|
||||
/// Configuration for application tray icon.
|
||||
///
|
||||
/// See more: <https://tauri.app/v1/api/config#trayiconconfig>
|
||||
@@ -1859,17 +1705,20 @@ fn default_min_sdk_version() -> u32 {
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[serde(untagged, deny_unknown_fields)]
|
||||
#[non_exhaustive]
|
||||
pub enum AppUrl {
|
||||
/// The app's external URL, or the path to the directory containing the app assets.
|
||||
Url(WebviewUrl),
|
||||
pub enum FrontendDist {
|
||||
/// An external URL that should be used as the default application URL.
|
||||
Url(Url),
|
||||
/// Path to a directory containing the frontend dist assets.
|
||||
Dist(PathBuf),
|
||||
/// An array of files to embed on the app.
|
||||
Files(Vec<PathBuf>),
|
||||
}
|
||||
|
||||
impl std::fmt::Display for AppUrl {
|
||||
impl std::fmt::Display for FrontendDist {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Url(url) => write!(f, "{url}"),
|
||||
Self::Dist(p) => write!(f, "{}", p.display()),
|
||||
Self::Files(files) => write!(f, "{}", serde_json::to_string(files).unwrap()),
|
||||
}
|
||||
}
|
||||
@@ -1920,28 +1769,30 @@ pub enum HookCommand {
|
||||
pub struct BuildConfig {
|
||||
/// The binary used to build and run the application.
|
||||
pub runner: Option<String>,
|
||||
/// The path to the application assets or URL to load in development.
|
||||
/// The URL to load in development.
|
||||
///
|
||||
/// This is usually an URL to a dev server, which serves your application assets
|
||||
/// with live reloading. Most modern JavaScript bundlers provides a way to start a dev server by default.
|
||||
/// This is usually an URL to a dev server, which serves your application assets with hot-reload and HMR.
|
||||
/// Most modern JavaScript bundlers like [vite](https://vitejs.dev/guide/) provides a way to start a dev server by default.
|
||||
///
|
||||
/// See [vite](https://vitejs.dev/guide/), [Webpack DevServer](https://webpack.js.org/configuration/dev-server/) and [sirv](https://github.com/lukeed/sirv)
|
||||
/// for examples on how to set up a dev server.
|
||||
#[serde(alias = "dev-path")]
|
||||
pub dev_path: Option<AppUrl>,
|
||||
/// The path to the application assets or URL to load in production.
|
||||
/// If you don't have a dev server or don't want to use one, ignore this option and use [`frontendDist`](BuildConfig::frontend_dist)
|
||||
/// and point to a web assets directory, and Tauri CLI will run its built-in dev server and provide a simple hot-reload experience.
|
||||
#[serde(alias = "dev-url")]
|
||||
pub dev_url: Option<Url>,
|
||||
/// The path to the application assets (usually the `dist` folder of your javascript bundler)
|
||||
/// or a URL that could be either a custom protocol registered in the tauri app (for example: `myprotocol://`)
|
||||
/// or a remote URL (for example: `https://site.com/app`).
|
||||
///
|
||||
/// When a path relative to the configuration file is provided,
|
||||
/// it is read recursively and all files are embedded in the application binary.
|
||||
/// Tauri then looks for an `index.html` file unless you provide a custom window URL.
|
||||
/// Tauri then looks for an `index.html` and serves it as the default entry point for your application.
|
||||
///
|
||||
/// You can also provide a list of paths to be embedded, which allows granular control over what files are added to the binary.
|
||||
/// In this case, all files are added to the root and you must reference it that way in your HTML files.
|
||||
///
|
||||
/// When an URL is provided, the application won't have bundled assets
|
||||
/// When a URL is provided, the application won't have bundled assets
|
||||
/// and the application will load that URL by default.
|
||||
#[serde(alias = "dist-dir")]
|
||||
pub dist_dir: Option<AppUrl>,
|
||||
#[serde(alias = "frontend-dist")]
|
||||
pub frontend_dist: Option<FrontendDist>,
|
||||
/// A shell command to run before `tauri dev` kicks in.
|
||||
///
|
||||
/// The TAURI_ENV_PLATFORM, TAURI_ENV_ARCH, TAURI_ENV_FAMILY, TAURI_ENV_PLATFORM_VERSION, TAURI_ENV_PLATFORM_TYPE and TAURI_ENV_DEBUG environment variables are set if you perform conditional compilation.
|
||||
@@ -1959,9 +1810,6 @@ pub struct BuildConfig {
|
||||
pub before_bundle_command: Option<HookCommand>,
|
||||
/// Features passed to `cargo` commands.
|
||||
pub features: Option<Vec<String>>,
|
||||
/// Whether we should inject the Tauri API on `window.__TAURI__` or not.
|
||||
#[serde(default, alias = "with-global-tauri")]
|
||||
pub with_global_tauri: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
@@ -2020,22 +1868,6 @@ 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. If removed the version number from `Cargo.toml` is used.
|
||||
#[serde(deserialize_with = "version_deserializer", default)]
|
||||
pub version: Option<String>,
|
||||
}
|
||||
|
||||
fn version_deserializer<'de, D>(deserializer: D) -> Result<Option<String>, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
@@ -2043,21 +1875,6 @@ where
|
||||
Option::<PackageVersion>::deserialize(deserializer).map(|v| v.map(|v| v.0))
|
||||
}
|
||||
|
||||
impl PackageConfig {
|
||||
/// The binary name.
|
||||
#[allow(dead_code)]
|
||||
pub fn binary_name(&self) -> Option<String> {
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
self.product_name.as_ref().map(|n| n.to_kebab_case())
|
||||
}
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
{
|
||||
self.product_name.clone()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The Tauri configuration object.
|
||||
/// It is read from a file where you can define your frontend assets,
|
||||
/// configure the bundler and define a tray icon.
|
||||
@@ -2089,24 +1906,21 @@ impl PackageConfig {
|
||||
/// The configuration is composed of the following objects:
|
||||
///
|
||||
/// - [`package`](#packageconfig): Package settings
|
||||
/// - [`tauri`](#tauriconfig): The Tauri config
|
||||
/// - [`app`](#appconfig): The Tauri config
|
||||
/// - [`build`](#buildconfig): The build configuration
|
||||
/// - [`plugins`](#pluginconfig): The plugins config
|
||||
///
|
||||
/// ```json title="Example tauri.config.json file"
|
||||
/// {
|
||||
/// "productName": "tauri-app",
|
||||
/// "version": "0.1.0"
|
||||
/// "build": {
|
||||
/// "beforeBuildCommand": "",
|
||||
/// "beforeDevCommand": "",
|
||||
/// "devPath": "../dist",
|
||||
/// "distDir": "../dist"
|
||||
/// "devUrl": "../dist",
|
||||
/// "frontendDist": "../dist"
|
||||
/// },
|
||||
/// "package": {
|
||||
/// "productName": "tauri-app",
|
||||
/// "version": "0.1.0"
|
||||
/// },
|
||||
/// "tauri": {
|
||||
/// "bundle": {},
|
||||
/// "app": {
|
||||
/// "security": {
|
||||
/// "csp": null
|
||||
/// },
|
||||
@@ -2119,7 +1933,8 @@ impl PackageConfig {
|
||||
/// "width": 800
|
||||
/// }
|
||||
/// ]
|
||||
/// }
|
||||
/// },
|
||||
/// "bundle": {}
|
||||
/// }
|
||||
/// ```
|
||||
#[skip_serializing_none]
|
||||
@@ -2130,20 +1945,49 @@ pub struct Config {
|
||||
/// The JSON schema for the Tauri config.
|
||||
#[serde(rename = "$schema")]
|
||||
pub schema: Option<String>,
|
||||
/// Package settings.
|
||||
/// 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. If removed the version number from `Cargo.toml` is used.
|
||||
#[serde(deserialize_with = "version_deserializer", default)]
|
||||
pub version: Option<String>,
|
||||
/// The application identifier in reverse domain name notation (e.g. `com.tauri.example`).
|
||||
/// This string must be unique across applications since it is used in system configurations like
|
||||
/// the bundle ID and path to the webview data directory.
|
||||
/// This string must contain only alphanumeric characters (A–Z, a–z, and 0–9), hyphens (-),
|
||||
/// and periods (.).
|
||||
#[serde(default)]
|
||||
pub package: PackageConfig,
|
||||
/// The Tauri configuration.
|
||||
pub identifier: String,
|
||||
/// The App configuration.
|
||||
#[serde(default)]
|
||||
pub tauri: TauriConfig,
|
||||
pub app: AppConfig,
|
||||
/// The build configuration.
|
||||
#[serde(default = "default_build")]
|
||||
pub build: BuildConfig,
|
||||
/// The bundler configuration.
|
||||
#[serde(default)]
|
||||
pub bundle: BundleConfig,
|
||||
/// The plugins config.
|
||||
#[serde(default)]
|
||||
pub plugins: PluginConfig,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
/// The binary name. Returns the product name as kebab-case on Linux,
|
||||
/// and returns it as is on all other platforms.
|
||||
pub fn binary_name(&self) -> Option<String> {
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
self.product_name.as_ref().map(|n| n.to_kebab_case())
|
||||
}
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
{
|
||||
self.product_name.clone()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The plugin configs holds a HashMap mapping a plugin name to its configuration object.
|
||||
///
|
||||
/// See more: <https://tauri.app/v1/api/config#pluginconfig>
|
||||
@@ -2154,13 +1998,12 @@ pub struct PluginConfig(pub HashMap<String, JsonValue>);
|
||||
fn default_build() -> BuildConfig {
|
||||
BuildConfig {
|
||||
runner: None,
|
||||
dev_path: None,
|
||||
dist_dir: None,
|
||||
dev_url: None,
|
||||
frontend_dist: None,
|
||||
before_dev_command: None,
|
||||
before_build_command: None,
|
||||
before_bundle_command: None,
|
||||
features: None,
|
||||
with_global_tauri: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2442,25 +2285,8 @@ mod build {
|
||||
}
|
||||
}
|
||||
|
||||
impl ToTokens for UpdaterConfig {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||
let active = self.active;
|
||||
let pubkey = str_lit(&self.pubkey);
|
||||
let windows = &self.windows;
|
||||
|
||||
literal_struct!(
|
||||
tokens,
|
||||
::tauri::utils::config::UpdaterConfig,
|
||||
active,
|
||||
pubkey,
|
||||
windows
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -2471,53 +2297,53 @@ mod build {
|
||||
let file_associations = quote!(None);
|
||||
let short_description = quote!(None);
|
||||
let long_description = quote!(None);
|
||||
let appimage = quote!(Default::default());
|
||||
let deb = quote!(Default::default());
|
||||
let rpm = quote!(Default::default());
|
||||
let dmg = quote!(Default::default());
|
||||
let macos = quote!(Default::default());
|
||||
let external_bin = opt_vec_lit(self.external_bin.as_ref(), str_lit);
|
||||
let windows = &self.windows;
|
||||
let license = opt_lit(self.license.as_ref());
|
||||
let license_file = opt_lit(self.license_file.as_ref().map(path_buf_lit).as_ref());
|
||||
let linux = quote!(Default::default());
|
||||
let macos = quote!(Default::default());
|
||||
let ios = quote!(Default::default());
|
||||
let android = quote!(Default::default());
|
||||
let updater = &self.updater;
|
||||
|
||||
literal_struct!(
|
||||
tokens,
|
||||
::tauri::utils::config::BundleConfig,
|
||||
active,
|
||||
identifier,
|
||||
publisher,
|
||||
icon,
|
||||
targets,
|
||||
resources,
|
||||
copyright,
|
||||
category,
|
||||
license,
|
||||
license_file,
|
||||
file_associations,
|
||||
short_description,
|
||||
long_description,
|
||||
appimage,
|
||||
deb,
|
||||
rpm,
|
||||
dmg,
|
||||
macos,
|
||||
external_bin,
|
||||
windows,
|
||||
linux,
|
||||
macos,
|
||||
ios,
|
||||
android,
|
||||
updater
|
||||
android
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
impl ToTokens for AppUrl {
|
||||
impl ToTokens for FrontendDist {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||
let prefix = quote! { ::tauri::utils::config::AppUrl };
|
||||
let prefix = quote! { ::tauri::utils::config::FrontendDist };
|
||||
|
||||
tokens.append_all(match self {
|
||||
Self::Url(url) => {
|
||||
let url = url_lit(url);
|
||||
quote! { #prefix::Url(#url) }
|
||||
}
|
||||
Self::Dist(path) => {
|
||||
let path = path_buf_lit(path);
|
||||
quote! { #prefix::Dist(#path) }
|
||||
}
|
||||
Self::Files(files) => {
|
||||
let files = vec_lit(files, path_buf_lit);
|
||||
quote! { #prefix::Files(#files) }
|
||||
@@ -2528,9 +2354,8 @@ mod build {
|
||||
|
||||
impl ToTokens for BuildConfig {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||
let dev_path = opt_lit(self.dev_path.as_ref());
|
||||
let dist_dir = opt_lit(self.dist_dir.as_ref());
|
||||
let with_global_tauri = self.with_global_tauri;
|
||||
let dev_url = opt_lit(self.dev_url.as_ref().map(url_lit).as_ref());
|
||||
let frontend_dist = opt_lit(self.frontend_dist.as_ref());
|
||||
let runner = quote!(None);
|
||||
let before_dev_command = quote!(None);
|
||||
let before_build_command = quote!(None);
|
||||
@@ -2541,9 +2366,8 @@ mod build {
|
||||
tokens,
|
||||
::tauri::utils::config::BuildConfig,
|
||||
runner,
|
||||
dev_path,
|
||||
dist_dir,
|
||||
with_global_tauri,
|
||||
dev_url,
|
||||
frontend_dist,
|
||||
before_dev_command,
|
||||
before_build_command,
|
||||
before_bundle_command,
|
||||
@@ -2552,29 +2376,6 @@ mod build {
|
||||
}
|
||||
}
|
||||
|
||||
impl ToTokens for WindowsUpdateInstallMode {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||
let prefix = quote! { ::tauri::utils::config::WindowsUpdateInstallMode };
|
||||
|
||||
tokens.append_all(match self {
|
||||
Self::BasicUi => quote! { #prefix::BasicUi },
|
||||
Self::Quiet => quote! { #prefix::Quiet },
|
||||
Self::Passive => quote! { #prefix::Passive },
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl ToTokens for UpdaterWindowsConfig {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||
let install_mode = &self.install_mode;
|
||||
literal_struct!(
|
||||
tokens,
|
||||
::tauri::utils::config::UpdaterWindowsConfig,
|
||||
install_mode
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
impl ToTokens for CspDirectiveSources {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||
let prefix = quote! { ::tauri::utils::config::CspDirectiveSources };
|
||||
@@ -2655,6 +2456,7 @@ mod build {
|
||||
let freeze_prototype = self.freeze_prototype;
|
||||
let dangerous_disable_asset_csp_modification = &self.dangerous_disable_asset_csp_modification;
|
||||
let asset_protocol = &self.asset_protocol;
|
||||
let pattern = &self.pattern;
|
||||
|
||||
literal_struct!(
|
||||
tokens,
|
||||
@@ -2663,7 +2465,8 @@ mod build {
|
||||
dev_csp,
|
||||
freeze_prototype,
|
||||
dangerous_disable_asset_csp_modification,
|
||||
asset_protocol
|
||||
asset_protocol,
|
||||
pattern
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2715,24 +2518,22 @@ mod build {
|
||||
}
|
||||
}
|
||||
|
||||
impl ToTokens for TauriConfig {
|
||||
impl ToTokens for AppConfig {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||
let pattern = &self.pattern;
|
||||
let windows = vec_lit(&self.windows, identity);
|
||||
let bundle = &self.bundle;
|
||||
let security = &self.security;
|
||||
let tray_icon = opt_lit(self.tray_icon.as_ref());
|
||||
let macos_private_api = self.macos_private_api;
|
||||
let with_global_tauri = self.with_global_tauri;
|
||||
|
||||
literal_struct!(
|
||||
tokens,
|
||||
::tauri::utils::config::TauriConfig,
|
||||
pattern,
|
||||
::tauri::utils::config::AppConfig,
|
||||
windows,
|
||||
bundle,
|
||||
security,
|
||||
tray_icon,
|
||||
macos_private_api
|
||||
macos_private_api,
|
||||
with_global_tauri
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2749,35 +2550,27 @@ mod build {
|
||||
}
|
||||
}
|
||||
|
||||
impl ToTokens for PackageConfig {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||
let product_name = opt_str_lit(self.product_name.as_ref());
|
||||
let version = opt_str_lit(self.version.as_ref());
|
||||
|
||||
literal_struct!(
|
||||
tokens,
|
||||
::tauri::utils::config::PackageConfig,
|
||||
product_name,
|
||||
version
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
impl ToTokens for Config {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||
let schema = quote!(None);
|
||||
let package = &self.package;
|
||||
let tauri = &self.tauri;
|
||||
let product_name = opt_str_lit(self.product_name.as_ref());
|
||||
let version = opt_str_lit(self.version.as_ref());
|
||||
let identifier = str_lit(&self.identifier);
|
||||
let app = &self.app;
|
||||
let build = &self.build;
|
||||
let bundle = &self.bundle;
|
||||
let plugins = &self.plugins;
|
||||
|
||||
literal_struct!(
|
||||
tokens,
|
||||
::tauri::utils::config::Config,
|
||||
schema,
|
||||
package,
|
||||
tauri,
|
||||
product_name,
|
||||
version,
|
||||
identifier,
|
||||
app,
|
||||
build,
|
||||
bundle,
|
||||
plugins
|
||||
);
|
||||
}
|
||||
@@ -2793,8 +2586,8 @@ mod test {
|
||||
#[test]
|
||||
// test all of the default functions
|
||||
fn test_defaults() {
|
||||
// get default tauri config
|
||||
let t_config = TauriConfig::default();
|
||||
// get default app config
|
||||
let a_config = AppConfig::default();
|
||||
// get default build config
|
||||
let b_config = BuildConfig::default();
|
||||
// get default window
|
||||
@@ -2803,59 +2596,58 @@ mod test {
|
||||
let d_bundle = BundleConfig::default();
|
||||
|
||||
// create a tauri config.
|
||||
let tauri = TauriConfig {
|
||||
pattern: Default::default(),
|
||||
let app = AppConfig {
|
||||
windows: vec![],
|
||||
bundle: BundleConfig {
|
||||
active: false,
|
||||
targets: Default::default(),
|
||||
identifier: String::from(""),
|
||||
publisher: None,
|
||||
icon: Vec::new(),
|
||||
resources: None,
|
||||
copyright: None,
|
||||
category: None,
|
||||
file_associations: None,
|
||||
short_description: None,
|
||||
long_description: None,
|
||||
appimage: Default::default(),
|
||||
deb: Default::default(),
|
||||
rpm: Default::default(),
|
||||
dmg: Default::default(),
|
||||
macos: Default::default(),
|
||||
external_bin: None,
|
||||
windows: Default::default(),
|
||||
ios: Default::default(),
|
||||
android: Default::default(),
|
||||
updater: Default::default(),
|
||||
},
|
||||
security: SecurityConfig {
|
||||
csp: None,
|
||||
dev_csp: None,
|
||||
freeze_prototype: false,
|
||||
dangerous_disable_asset_csp_modification: DisabledCspModificationKind::Flag(false),
|
||||
asset_protocol: AssetProtocolConfig::default(),
|
||||
pattern: Default::default(),
|
||||
},
|
||||
tray_icon: None,
|
||||
macos_private_api: false,
|
||||
with_global_tauri: false,
|
||||
};
|
||||
|
||||
// create a build config
|
||||
let build = BuildConfig {
|
||||
runner: None,
|
||||
dev_path: None,
|
||||
dist_dir: None,
|
||||
dev_url: None,
|
||||
frontend_dist: None,
|
||||
before_dev_command: None,
|
||||
before_build_command: None,
|
||||
before_bundle_command: None,
|
||||
features: None,
|
||||
with_global_tauri: false,
|
||||
};
|
||||
|
||||
// create a bundle config
|
||||
let bundle = BundleConfig {
|
||||
active: false,
|
||||
targets: Default::default(),
|
||||
publisher: None,
|
||||
icon: Vec::new(),
|
||||
resources: None,
|
||||
copyright: None,
|
||||
category: None,
|
||||
file_associations: None,
|
||||
short_description: None,
|
||||
long_description: None,
|
||||
license: None,
|
||||
license_file: None,
|
||||
linux: Default::default(),
|
||||
macos: Default::default(),
|
||||
external_bin: None,
|
||||
windows: Default::default(),
|
||||
ios: Default::default(),
|
||||
android: Default::default(),
|
||||
};
|
||||
|
||||
// test the configs
|
||||
assert_eq!(t_config, tauri);
|
||||
assert_eq!(a_config, app);
|
||||
assert_eq!(b_config, build);
|
||||
assert_eq!(d_bundle, tauri.bundle);
|
||||
assert_eq!(d_windows, tauri.windows);
|
||||
assert_eq!(d_bundle, bundle);
|
||||
assert_eq!(d_windows, app.windows);
|
||||
}
|
||||
}
|
||||
|
||||
315
core/tauri/permissions/event/schemas/schema.json
Normal file
315
core/tauri/permissions/event/schemas/schema.json
Normal file
@@ -0,0 +1,315 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "PermissionFile",
|
||||
"description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"default": {
|
||||
"description": "The default permission set for the plugin",
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/DefaultPermission"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"set": {
|
||||
"description": "A list of permissions sets defined",
|
||||
"default": [],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/PermissionSet"
|
||||
}
|
||||
},
|
||||
"permission": {
|
||||
"description": "A list of inlined permissions",
|
||||
"default": [],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/Permission"
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"DefaultPermission": {
|
||||
"description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"permissions"
|
||||
],
|
||||
"properties": {
|
||||
"version": {
|
||||
"description": "The version of the permission.",
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"format": "uint64",
|
||||
"minimum": 1.0
|
||||
},
|
||||
"description": {
|
||||
"description": "Human-readable description of what the permission does.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"permissions": {
|
||||
"description": "All permissions this set contains.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"PermissionSet": {
|
||||
"description": "A set of direct permissions grouped together under a new name.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"description",
|
||||
"identifier",
|
||||
"permissions"
|
||||
],
|
||||
"properties": {
|
||||
"identifier": {
|
||||
"description": "A unique identifier for the permission.",
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"description": "Human-readable description of what the permission does.",
|
||||
"type": "string"
|
||||
},
|
||||
"permissions": {
|
||||
"description": "All permissions this set contains.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/PermissionKind"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Permission": {
|
||||
"description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"identifier"
|
||||
],
|
||||
"properties": {
|
||||
"version": {
|
||||
"description": "The version of the permission.",
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"format": "uint64",
|
||||
"minimum": 1.0
|
||||
},
|
||||
"identifier": {
|
||||
"description": "A unique identifier for the permission.",
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"description": "Human-readable description of what the permission does.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"commands": {
|
||||
"description": "Allowed or denied commands when using this permission.",
|
||||
"default": {
|
||||
"allow": [],
|
||||
"deny": []
|
||||
},
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/Commands"
|
||||
}
|
||||
]
|
||||
},
|
||||
"scope": {
|
||||
"description": "Allowed or denied scoped when using this permission.",
|
||||
"default": {},
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/Scopes"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"Commands": {
|
||||
"description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"allow": {
|
||||
"description": "Allowed command.",
|
||||
"default": [],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"deny": {
|
||||
"description": "Denied command, which takes priority.",
|
||||
"default": [],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Scopes": {
|
||||
"description": "A restriction of the command/endpoint functionality.\n\nIt can be of any serde serializable type and is used for allowing or preventing certain actions inside a Tauri command.\n\nThe scope is passed to the command and handled/enforced by the command itself.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"allow": {
|
||||
"description": "Data that defines what is allowed by the scope.",
|
||||
"type": [
|
||||
"array",
|
||||
"null"
|
||||
],
|
||||
"items": {
|
||||
"$ref": "#/definitions/Value"
|
||||
}
|
||||
},
|
||||
"deny": {
|
||||
"description": "Data that defines what is denied by the scope.",
|
||||
"type": [
|
||||
"array",
|
||||
"null"
|
||||
],
|
||||
"items": {
|
||||
"$ref": "#/definitions/Value"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Value": {
|
||||
"description": "All supported ACL values.",
|
||||
"anyOf": [
|
||||
{
|
||||
"description": "Represents a null JSON value.",
|
||||
"type": "null"
|
||||
},
|
||||
{
|
||||
"description": "Represents a [`bool`].",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"description": "Represents a valid ACL [`Number`].",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/Number"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Represents a [`String`].",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"description": "Represents a list of other [`Value`]s.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/Value"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Represents a map of [`String`] keys to [`Value`]s.",
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"$ref": "#/definitions/Value"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"Number": {
|
||||
"description": "A valid ACL number.",
|
||||
"anyOf": [
|
||||
{
|
||||
"description": "Represents an [`i64`].",
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
{
|
||||
"description": "Represents a [`f64`].",
|
||||
"type": "number",
|
||||
"format": "double"
|
||||
}
|
||||
]
|
||||
},
|
||||
"PermissionKind": {
|
||||
"type": "string",
|
||||
"oneOf": [
|
||||
{
|
||||
"description": "allow-emit -> Enables the emit command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-emit"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-emit -> Denies the emit command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-emit"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-emit-to -> Enables the emit_to command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-emit-to"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-emit-to -> Denies the emit_to command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-emit-to"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-listen -> Enables the listen command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-listen"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-listen -> Denies the listen command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-listen"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-unlisten -> Enables the unlisten command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-unlisten"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-unlisten -> Denies the unlisten command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-unlisten"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "default -> Default permissions for the plugin.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"default"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
567
core/tauri/permissions/menu/schemas/schema.json
Normal file
567
core/tauri/permissions/menu/schemas/schema.json
Normal file
@@ -0,0 +1,567 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "PermissionFile",
|
||||
"description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"default": {
|
||||
"description": "The default permission set for the plugin",
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/DefaultPermission"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"set": {
|
||||
"description": "A list of permissions sets defined",
|
||||
"default": [],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/PermissionSet"
|
||||
}
|
||||
},
|
||||
"permission": {
|
||||
"description": "A list of inlined permissions",
|
||||
"default": [],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/Permission"
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"DefaultPermission": {
|
||||
"description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"permissions"
|
||||
],
|
||||
"properties": {
|
||||
"version": {
|
||||
"description": "The version of the permission.",
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"format": "uint64",
|
||||
"minimum": 1.0
|
||||
},
|
||||
"description": {
|
||||
"description": "Human-readable description of what the permission does.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"permissions": {
|
||||
"description": "All permissions this set contains.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"PermissionSet": {
|
||||
"description": "A set of direct permissions grouped together under a new name.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"description",
|
||||
"identifier",
|
||||
"permissions"
|
||||
],
|
||||
"properties": {
|
||||
"identifier": {
|
||||
"description": "A unique identifier for the permission.",
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"description": "Human-readable description of what the permission does.",
|
||||
"type": "string"
|
||||
},
|
||||
"permissions": {
|
||||
"description": "All permissions this set contains.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/PermissionKind"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Permission": {
|
||||
"description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"identifier"
|
||||
],
|
||||
"properties": {
|
||||
"version": {
|
||||
"description": "The version of the permission.",
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"format": "uint64",
|
||||
"minimum": 1.0
|
||||
},
|
||||
"identifier": {
|
||||
"description": "A unique identifier for the permission.",
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"description": "Human-readable description of what the permission does.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"commands": {
|
||||
"description": "Allowed or denied commands when using this permission.",
|
||||
"default": {
|
||||
"allow": [],
|
||||
"deny": []
|
||||
},
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/Commands"
|
||||
}
|
||||
]
|
||||
},
|
||||
"scope": {
|
||||
"description": "Allowed or denied scoped when using this permission.",
|
||||
"default": {},
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/Scopes"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"Commands": {
|
||||
"description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"allow": {
|
||||
"description": "Allowed command.",
|
||||
"default": [],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"deny": {
|
||||
"description": "Denied command, which takes priority.",
|
||||
"default": [],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Scopes": {
|
||||
"description": "A restriction of the command/endpoint functionality.\n\nIt can be of any serde serializable type and is used for allowing or preventing certain actions inside a Tauri command.\n\nThe scope is passed to the command and handled/enforced by the command itself.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"allow": {
|
||||
"description": "Data that defines what is allowed by the scope.",
|
||||
"type": [
|
||||
"array",
|
||||
"null"
|
||||
],
|
||||
"items": {
|
||||
"$ref": "#/definitions/Value"
|
||||
}
|
||||
},
|
||||
"deny": {
|
||||
"description": "Data that defines what is denied by the scope.",
|
||||
"type": [
|
||||
"array",
|
||||
"null"
|
||||
],
|
||||
"items": {
|
||||
"$ref": "#/definitions/Value"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Value": {
|
||||
"description": "All supported ACL values.",
|
||||
"anyOf": [
|
||||
{
|
||||
"description": "Represents a null JSON value.",
|
||||
"type": "null"
|
||||
},
|
||||
{
|
||||
"description": "Represents a [`bool`].",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"description": "Represents a valid ACL [`Number`].",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/Number"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Represents a [`String`].",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"description": "Represents a list of other [`Value`]s.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/Value"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Represents a map of [`String`] keys to [`Value`]s.",
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"$ref": "#/definitions/Value"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"Number": {
|
||||
"description": "A valid ACL number.",
|
||||
"anyOf": [
|
||||
{
|
||||
"description": "Represents an [`i64`].",
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
{
|
||||
"description": "Represents a [`f64`].",
|
||||
"type": "number",
|
||||
"format": "double"
|
||||
}
|
||||
]
|
||||
},
|
||||
"PermissionKind": {
|
||||
"type": "string",
|
||||
"oneOf": [
|
||||
{
|
||||
"description": "allow-append -> Enables the append command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-append"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-append -> Denies the append command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-append"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-create-default -> Enables the create_default command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-create-default"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-create-default -> Denies the create_default command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-create-default"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-get -> Enables the get command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-get"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-get -> Denies the get command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-get"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-insert -> Enables the insert command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-insert"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-insert -> Denies the insert command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-insert"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-is-checked -> Enables the is_checked command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-is-checked"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-is-checked -> Denies the is_checked command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-is-checked"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-is-enabled -> Enables the is_enabled command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-is-enabled"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-is-enabled -> Denies the is_enabled command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-is-enabled"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-items -> Enables the items command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-items"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-items -> Denies the items command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-items"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-new -> Enables the new command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-new"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-new -> Denies the new command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-new"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-popup -> Enables the popup command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-popup"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-popup -> Denies the popup command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-popup"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-prepend -> Enables the prepend command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-prepend"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-prepend -> Denies the prepend command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-prepend"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-remove -> Enables the remove command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-remove"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-remove -> Denies the remove command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-remove"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-remove-at -> Enables the remove_at command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-remove-at"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-remove-at -> Denies the remove_at command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-remove-at"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-set-accelerator -> Enables the set_accelerator command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-set-accelerator"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-set-accelerator -> Denies the set_accelerator command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-set-accelerator"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-set-as-app-menu -> Enables the set_as_app_menu command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-set-as-app-menu"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-set-as-app-menu -> Denies the set_as_app_menu command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-set-as-app-menu"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-set-as-help-menu-for-nsapp -> Enables the set_as_help_menu_for_nsapp command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-set-as-help-menu-for-nsapp"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-set-as-help-menu-for-nsapp -> Denies the set_as_help_menu_for_nsapp command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-set-as-help-menu-for-nsapp"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-set-as-window-menu -> Enables the set_as_window_menu command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-set-as-window-menu"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-set-as-window-menu -> Denies the set_as_window_menu command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-set-as-window-menu"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-set-as-windows-menu-for-nsapp -> Enables the set_as_windows_menu_for_nsapp command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-set-as-windows-menu-for-nsapp"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-set-as-windows-menu-for-nsapp -> Denies the set_as_windows_menu_for_nsapp command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-set-as-windows-menu-for-nsapp"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-set-checked -> Enables the set_checked command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-set-checked"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-set-checked -> Denies the set_checked command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-set-checked"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-set-enabled -> Enables the set_enabled command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-set-enabled"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-set-enabled -> Denies the set_enabled command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-set-enabled"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-set-icon -> Enables the set_icon command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-set-icon"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-set-icon -> Denies the set_icon command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-set-icon"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-set-text -> Enables the set_text command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-set-text"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-set-text -> Denies the set_text command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-set-text"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-text -> Enables the text command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-text"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-text -> Denies the text command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-text"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "default -> Default permissions for the plugin.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"default"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
371
core/tauri/permissions/path/schemas/schema.json
Normal file
371
core/tauri/permissions/path/schemas/schema.json
Normal file
@@ -0,0 +1,371 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "PermissionFile",
|
||||
"description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"default": {
|
||||
"description": "The default permission set for the plugin",
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/DefaultPermission"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"set": {
|
||||
"description": "A list of permissions sets defined",
|
||||
"default": [],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/PermissionSet"
|
||||
}
|
||||
},
|
||||
"permission": {
|
||||
"description": "A list of inlined permissions",
|
||||
"default": [],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/Permission"
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"DefaultPermission": {
|
||||
"description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"permissions"
|
||||
],
|
||||
"properties": {
|
||||
"version": {
|
||||
"description": "The version of the permission.",
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"format": "uint64",
|
||||
"minimum": 1.0
|
||||
},
|
||||
"description": {
|
||||
"description": "Human-readable description of what the permission does.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"permissions": {
|
||||
"description": "All permissions this set contains.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"PermissionSet": {
|
||||
"description": "A set of direct permissions grouped together under a new name.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"description",
|
||||
"identifier",
|
||||
"permissions"
|
||||
],
|
||||
"properties": {
|
||||
"identifier": {
|
||||
"description": "A unique identifier for the permission.",
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"description": "Human-readable description of what the permission does.",
|
||||
"type": "string"
|
||||
},
|
||||
"permissions": {
|
||||
"description": "All permissions this set contains.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/PermissionKind"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Permission": {
|
||||
"description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"identifier"
|
||||
],
|
||||
"properties": {
|
||||
"version": {
|
||||
"description": "The version of the permission.",
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"format": "uint64",
|
||||
"minimum": 1.0
|
||||
},
|
||||
"identifier": {
|
||||
"description": "A unique identifier for the permission.",
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"description": "Human-readable description of what the permission does.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"commands": {
|
||||
"description": "Allowed or denied commands when using this permission.",
|
||||
"default": {
|
||||
"allow": [],
|
||||
"deny": []
|
||||
},
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/Commands"
|
||||
}
|
||||
]
|
||||
},
|
||||
"scope": {
|
||||
"description": "Allowed or denied scoped when using this permission.",
|
||||
"default": {},
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/Scopes"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"Commands": {
|
||||
"description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"allow": {
|
||||
"description": "Allowed command.",
|
||||
"default": [],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"deny": {
|
||||
"description": "Denied command, which takes priority.",
|
||||
"default": [],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Scopes": {
|
||||
"description": "A restriction of the command/endpoint functionality.\n\nIt can be of any serde serializable type and is used for allowing or preventing certain actions inside a Tauri command.\n\nThe scope is passed to the command and handled/enforced by the command itself.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"allow": {
|
||||
"description": "Data that defines what is allowed by the scope.",
|
||||
"type": [
|
||||
"array",
|
||||
"null"
|
||||
],
|
||||
"items": {
|
||||
"$ref": "#/definitions/Value"
|
||||
}
|
||||
},
|
||||
"deny": {
|
||||
"description": "Data that defines what is denied by the scope.",
|
||||
"type": [
|
||||
"array",
|
||||
"null"
|
||||
],
|
||||
"items": {
|
||||
"$ref": "#/definitions/Value"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Value": {
|
||||
"description": "All supported ACL values.",
|
||||
"anyOf": [
|
||||
{
|
||||
"description": "Represents a null JSON value.",
|
||||
"type": "null"
|
||||
},
|
||||
{
|
||||
"description": "Represents a [`bool`].",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"description": "Represents a valid ACL [`Number`].",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/Number"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Represents a [`String`].",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"description": "Represents a list of other [`Value`]s.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/Value"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Represents a map of [`String`] keys to [`Value`]s.",
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"$ref": "#/definitions/Value"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"Number": {
|
||||
"description": "A valid ACL number.",
|
||||
"anyOf": [
|
||||
{
|
||||
"description": "Represents an [`i64`].",
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
{
|
||||
"description": "Represents a [`f64`].",
|
||||
"type": "number",
|
||||
"format": "double"
|
||||
}
|
||||
]
|
||||
},
|
||||
"PermissionKind": {
|
||||
"type": "string",
|
||||
"oneOf": [
|
||||
{
|
||||
"description": "allow-basename -> Enables the basename command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-basename"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-basename -> Denies the basename command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-basename"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-dirname -> Enables the dirname command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-dirname"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-dirname -> Denies the dirname command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-dirname"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-extname -> Enables the extname command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-extname"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-extname -> Denies the extname command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-extname"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-is-absolute -> Enables the is_absolute command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-is-absolute"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-is-absolute -> Denies the is_absolute command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-is-absolute"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-join -> Enables the join command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-join"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-join -> Denies the join command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-join"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-normalize -> Enables the normalize command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-normalize"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-normalize -> Denies the normalize command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-normalize"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-resolve -> Enables the resolve command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-resolve"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-resolve -> Denies the resolve command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-resolve"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-resolve-directory -> Enables the resolve_directory command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-resolve-directory"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-resolve-directory -> Denies the resolve_directory command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-resolve-directory"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "default -> Default permissions for the plugin.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"default"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
273
core/tauri/permissions/resources/schemas/schema.json
Normal file
273
core/tauri/permissions/resources/schemas/schema.json
Normal file
@@ -0,0 +1,273 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "PermissionFile",
|
||||
"description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"default": {
|
||||
"description": "The default permission set for the plugin",
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/DefaultPermission"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"set": {
|
||||
"description": "A list of permissions sets defined",
|
||||
"default": [],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/PermissionSet"
|
||||
}
|
||||
},
|
||||
"permission": {
|
||||
"description": "A list of inlined permissions",
|
||||
"default": [],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/Permission"
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"DefaultPermission": {
|
||||
"description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"permissions"
|
||||
],
|
||||
"properties": {
|
||||
"version": {
|
||||
"description": "The version of the permission.",
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"format": "uint64",
|
||||
"minimum": 1.0
|
||||
},
|
||||
"description": {
|
||||
"description": "Human-readable description of what the permission does.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"permissions": {
|
||||
"description": "All permissions this set contains.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"PermissionSet": {
|
||||
"description": "A set of direct permissions grouped together under a new name.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"description",
|
||||
"identifier",
|
||||
"permissions"
|
||||
],
|
||||
"properties": {
|
||||
"identifier": {
|
||||
"description": "A unique identifier for the permission.",
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"description": "Human-readable description of what the permission does.",
|
||||
"type": "string"
|
||||
},
|
||||
"permissions": {
|
||||
"description": "All permissions this set contains.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/PermissionKind"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Permission": {
|
||||
"description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"identifier"
|
||||
],
|
||||
"properties": {
|
||||
"version": {
|
||||
"description": "The version of the permission.",
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"format": "uint64",
|
||||
"minimum": 1.0
|
||||
},
|
||||
"identifier": {
|
||||
"description": "A unique identifier for the permission.",
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"description": "Human-readable description of what the permission does.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"commands": {
|
||||
"description": "Allowed or denied commands when using this permission.",
|
||||
"default": {
|
||||
"allow": [],
|
||||
"deny": []
|
||||
},
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/Commands"
|
||||
}
|
||||
]
|
||||
},
|
||||
"scope": {
|
||||
"description": "Allowed or denied scoped when using this permission.",
|
||||
"default": {},
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/Scopes"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"Commands": {
|
||||
"description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"allow": {
|
||||
"description": "Allowed command.",
|
||||
"default": [],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"deny": {
|
||||
"description": "Denied command, which takes priority.",
|
||||
"default": [],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Scopes": {
|
||||
"description": "A restriction of the command/endpoint functionality.\n\nIt can be of any serde serializable type and is used for allowing or preventing certain actions inside a Tauri command.\n\nThe scope is passed to the command and handled/enforced by the command itself.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"allow": {
|
||||
"description": "Data that defines what is allowed by the scope.",
|
||||
"type": [
|
||||
"array",
|
||||
"null"
|
||||
],
|
||||
"items": {
|
||||
"$ref": "#/definitions/Value"
|
||||
}
|
||||
},
|
||||
"deny": {
|
||||
"description": "Data that defines what is denied by the scope.",
|
||||
"type": [
|
||||
"array",
|
||||
"null"
|
||||
],
|
||||
"items": {
|
||||
"$ref": "#/definitions/Value"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Value": {
|
||||
"description": "All supported ACL values.",
|
||||
"anyOf": [
|
||||
{
|
||||
"description": "Represents a null JSON value.",
|
||||
"type": "null"
|
||||
},
|
||||
{
|
||||
"description": "Represents a [`bool`].",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"description": "Represents a valid ACL [`Number`].",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/Number"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Represents a [`String`].",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"description": "Represents a list of other [`Value`]s.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/Value"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Represents a map of [`String`] keys to [`Value`]s.",
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"$ref": "#/definitions/Value"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"Number": {
|
||||
"description": "A valid ACL number.",
|
||||
"anyOf": [
|
||||
{
|
||||
"description": "Represents an [`i64`].",
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
{
|
||||
"description": "Represents a [`f64`].",
|
||||
"type": "number",
|
||||
"format": "double"
|
||||
}
|
||||
]
|
||||
},
|
||||
"PermissionKind": {
|
||||
"type": "string",
|
||||
"oneOf": [
|
||||
{
|
||||
"description": "allow-close -> Enables the close command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-close"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-close -> Denies the close command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-close"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "default -> Default permissions for the plugin.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"default"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
385
core/tauri/permissions/tray/schemas/schema.json
Normal file
385
core/tauri/permissions/tray/schemas/schema.json
Normal file
@@ -0,0 +1,385 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "PermissionFile",
|
||||
"description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"default": {
|
||||
"description": "The default permission set for the plugin",
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/DefaultPermission"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"set": {
|
||||
"description": "A list of permissions sets defined",
|
||||
"default": [],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/PermissionSet"
|
||||
}
|
||||
},
|
||||
"permission": {
|
||||
"description": "A list of inlined permissions",
|
||||
"default": [],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/Permission"
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"DefaultPermission": {
|
||||
"description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"permissions"
|
||||
],
|
||||
"properties": {
|
||||
"version": {
|
||||
"description": "The version of the permission.",
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"format": "uint64",
|
||||
"minimum": 1.0
|
||||
},
|
||||
"description": {
|
||||
"description": "Human-readable description of what the permission does.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"permissions": {
|
||||
"description": "All permissions this set contains.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"PermissionSet": {
|
||||
"description": "A set of direct permissions grouped together under a new name.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"description",
|
||||
"identifier",
|
||||
"permissions"
|
||||
],
|
||||
"properties": {
|
||||
"identifier": {
|
||||
"description": "A unique identifier for the permission.",
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"description": "Human-readable description of what the permission does.",
|
||||
"type": "string"
|
||||
},
|
||||
"permissions": {
|
||||
"description": "All permissions this set contains.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/PermissionKind"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Permission": {
|
||||
"description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"identifier"
|
||||
],
|
||||
"properties": {
|
||||
"version": {
|
||||
"description": "The version of the permission.",
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"format": "uint64",
|
||||
"minimum": 1.0
|
||||
},
|
||||
"identifier": {
|
||||
"description": "A unique identifier for the permission.",
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"description": "Human-readable description of what the permission does.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"commands": {
|
||||
"description": "Allowed or denied commands when using this permission.",
|
||||
"default": {
|
||||
"allow": [],
|
||||
"deny": []
|
||||
},
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/Commands"
|
||||
}
|
||||
]
|
||||
},
|
||||
"scope": {
|
||||
"description": "Allowed or denied scoped when using this permission.",
|
||||
"default": {},
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/Scopes"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"Commands": {
|
||||
"description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"allow": {
|
||||
"description": "Allowed command.",
|
||||
"default": [],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"deny": {
|
||||
"description": "Denied command, which takes priority.",
|
||||
"default": [],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Scopes": {
|
||||
"description": "A restriction of the command/endpoint functionality.\n\nIt can be of any serde serializable type and is used for allowing or preventing certain actions inside a Tauri command.\n\nThe scope is passed to the command and handled/enforced by the command itself.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"allow": {
|
||||
"description": "Data that defines what is allowed by the scope.",
|
||||
"type": [
|
||||
"array",
|
||||
"null"
|
||||
],
|
||||
"items": {
|
||||
"$ref": "#/definitions/Value"
|
||||
}
|
||||
},
|
||||
"deny": {
|
||||
"description": "Data that defines what is denied by the scope.",
|
||||
"type": [
|
||||
"array",
|
||||
"null"
|
||||
],
|
||||
"items": {
|
||||
"$ref": "#/definitions/Value"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Value": {
|
||||
"description": "All supported ACL values.",
|
||||
"anyOf": [
|
||||
{
|
||||
"description": "Represents a null JSON value.",
|
||||
"type": "null"
|
||||
},
|
||||
{
|
||||
"description": "Represents a [`bool`].",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"description": "Represents a valid ACL [`Number`].",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/Number"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Represents a [`String`].",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"description": "Represents a list of other [`Value`]s.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/Value"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Represents a map of [`String`] keys to [`Value`]s.",
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"$ref": "#/definitions/Value"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"Number": {
|
||||
"description": "A valid ACL number.",
|
||||
"anyOf": [
|
||||
{
|
||||
"description": "Represents an [`i64`].",
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
{
|
||||
"description": "Represents a [`f64`].",
|
||||
"type": "number",
|
||||
"format": "double"
|
||||
}
|
||||
]
|
||||
},
|
||||
"PermissionKind": {
|
||||
"type": "string",
|
||||
"oneOf": [
|
||||
{
|
||||
"description": "allow-new -> Enables the new command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-new"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-new -> Denies the new command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-new"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-set-icon -> Enables the set_icon command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-set-icon"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-set-icon -> Denies the set_icon command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-set-icon"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-set-icon-as-template -> Enables the set_icon_as_template command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-set-icon-as-template"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-set-icon-as-template -> Denies the set_icon_as_template command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-set-icon-as-template"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-set-menu -> Enables the set_menu command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-set-menu"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-set-menu -> Denies the set_menu command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-set-menu"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-set-show-menu-on-left-click -> Enables the set_show_menu_on_left_click command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-set-show-menu-on-left-click"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-set-show-menu-on-left-click -> Denies the set_show_menu_on_left_click command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-set-show-menu-on-left-click"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-set-temp-dir-path -> Enables the set_temp_dir_path command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-set-temp-dir-path"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-set-temp-dir-path -> Denies the set_temp_dir_path command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-set-temp-dir-path"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-set-title -> Enables the set_title command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-set-title"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-set-title -> Denies the set_title command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-set-title"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-set-tooltip -> Enables the set_tooltip command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-set-tooltip"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-set-tooltip -> Denies the set_tooltip command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-set-tooltip"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-set-visible -> Enables the set_visible command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-set-visible"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-set-visible -> Denies the set_visible command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-set-visible"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "default -> Default permissions for the plugin.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"default"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
399
core/tauri/permissions/webview/schemas/schema.json
Normal file
399
core/tauri/permissions/webview/schemas/schema.json
Normal file
@@ -0,0 +1,399 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "PermissionFile",
|
||||
"description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"default": {
|
||||
"description": "The default permission set for the plugin",
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/DefaultPermission"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"set": {
|
||||
"description": "A list of permissions sets defined",
|
||||
"default": [],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/PermissionSet"
|
||||
}
|
||||
},
|
||||
"permission": {
|
||||
"description": "A list of inlined permissions",
|
||||
"default": [],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/Permission"
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"DefaultPermission": {
|
||||
"description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"permissions"
|
||||
],
|
||||
"properties": {
|
||||
"version": {
|
||||
"description": "The version of the permission.",
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"format": "uint64",
|
||||
"minimum": 1.0
|
||||
},
|
||||
"description": {
|
||||
"description": "Human-readable description of what the permission does.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"permissions": {
|
||||
"description": "All permissions this set contains.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"PermissionSet": {
|
||||
"description": "A set of direct permissions grouped together under a new name.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"description",
|
||||
"identifier",
|
||||
"permissions"
|
||||
],
|
||||
"properties": {
|
||||
"identifier": {
|
||||
"description": "A unique identifier for the permission.",
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"description": "Human-readable description of what the permission does.",
|
||||
"type": "string"
|
||||
},
|
||||
"permissions": {
|
||||
"description": "All permissions this set contains.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/PermissionKind"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Permission": {
|
||||
"description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"identifier"
|
||||
],
|
||||
"properties": {
|
||||
"version": {
|
||||
"description": "The version of the permission.",
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"format": "uint64",
|
||||
"minimum": 1.0
|
||||
},
|
||||
"identifier": {
|
||||
"description": "A unique identifier for the permission.",
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"description": "Human-readable description of what the permission does.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"commands": {
|
||||
"description": "Allowed or denied commands when using this permission.",
|
||||
"default": {
|
||||
"allow": [],
|
||||
"deny": []
|
||||
},
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/Commands"
|
||||
}
|
||||
]
|
||||
},
|
||||
"scope": {
|
||||
"description": "Allowed or denied scoped when using this permission.",
|
||||
"default": {},
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/Scopes"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"Commands": {
|
||||
"description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"allow": {
|
||||
"description": "Allowed command.",
|
||||
"default": [],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"deny": {
|
||||
"description": "Denied command, which takes priority.",
|
||||
"default": [],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Scopes": {
|
||||
"description": "A restriction of the command/endpoint functionality.\n\nIt can be of any serde serializable type and is used for allowing or preventing certain actions inside a Tauri command.\n\nThe scope is passed to the command and handled/enforced by the command itself.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"allow": {
|
||||
"description": "Data that defines what is allowed by the scope.",
|
||||
"type": [
|
||||
"array",
|
||||
"null"
|
||||
],
|
||||
"items": {
|
||||
"$ref": "#/definitions/Value"
|
||||
}
|
||||
},
|
||||
"deny": {
|
||||
"description": "Data that defines what is denied by the scope.",
|
||||
"type": [
|
||||
"array",
|
||||
"null"
|
||||
],
|
||||
"items": {
|
||||
"$ref": "#/definitions/Value"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Value": {
|
||||
"description": "All supported ACL values.",
|
||||
"anyOf": [
|
||||
{
|
||||
"description": "Represents a null JSON value.",
|
||||
"type": "null"
|
||||
},
|
||||
{
|
||||
"description": "Represents a [`bool`].",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"description": "Represents a valid ACL [`Number`].",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/Number"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Represents a [`String`].",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"description": "Represents a list of other [`Value`]s.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/Value"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Represents a map of [`String`] keys to [`Value`]s.",
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"$ref": "#/definitions/Value"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"Number": {
|
||||
"description": "A valid ACL number.",
|
||||
"anyOf": [
|
||||
{
|
||||
"description": "Represents an [`i64`].",
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
{
|
||||
"description": "Represents a [`f64`].",
|
||||
"type": "number",
|
||||
"format": "double"
|
||||
}
|
||||
]
|
||||
},
|
||||
"PermissionKind": {
|
||||
"type": "string",
|
||||
"oneOf": [
|
||||
{
|
||||
"description": "allow-create-webview -> Enables the create_webview command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-create-webview"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-create-webview -> Denies the create_webview command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-create-webview"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-create-webview-window -> Enables the create_webview_window command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-create-webview-window"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-create-webview-window -> Denies the create_webview_window command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-create-webview-window"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-internal-toggle-devtools -> Enables the internal_toggle_devtools command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-internal-toggle-devtools"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-internal-toggle-devtools -> Denies the internal_toggle_devtools command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-internal-toggle-devtools"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-print -> Enables the print command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-print"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-print -> Denies the print command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-print"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-set-webview-focus -> Enables the set_webview_focus command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-set-webview-focus"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-set-webview-focus -> Denies the set_webview_focus command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-set-webview-focus"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-set-webview-position -> Enables the set_webview_position command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-set-webview-position"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-set-webview-position -> Denies the set_webview_position command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-set-webview-position"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-set-webview-size -> Enables the set_webview_size command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-set-webview-size"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-set-webview-size -> Denies the set_webview_size command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-set-webview-size"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-webview-close -> Enables the webview_close command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-webview-close"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-webview-close -> Denies the webview_close command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-webview-close"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-webview-position -> Enables the webview_position command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-webview-position"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-webview-position -> Denies the webview_position command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-webview-position"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "allow-webview-size -> Enables the webview_size command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"allow-webview-size"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "deny-webview-size -> Denies the webview_size command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"deny-webview-size"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "default -> Default permissions for the plugin.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"default"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
1127
core/tauri/permissions/window/schemas/schema.json
Normal file
1127
core/tauri/permissions/window/schemas/schema.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1638,7 +1638,7 @@ tauri::Builder::default()
|
||||
#[cfg(feature = "protocol-asset")]
|
||||
asset_protocol: crate::scope::fs::Scope::new(
|
||||
&app,
|
||||
&app.config().tauri.security.asset_protocol.scope,
|
||||
&app.config().app.security.asset_protocol.scope,
|
||||
)?,
|
||||
});
|
||||
|
||||
@@ -1647,13 +1647,8 @@ tauri::Builder::default()
|
||||
|
||||
#[cfg(windows)]
|
||||
{
|
||||
if let crate::utils::config::WebviewInstallMode::FixedRuntime { path } = &app
|
||||
.manager
|
||||
.config()
|
||||
.tauri
|
||||
.bundle
|
||||
.windows
|
||||
.webview_install_mode
|
||||
if let crate::utils::config::WebviewInstallMode::FixedRuntime { path } =
|
||||
&app.manager.config().bundle.windows.webview_install_mode
|
||||
{
|
||||
if let Ok(resource_dir) = app.path().resource_dir() {
|
||||
std::env::set_var(
|
||||
@@ -1675,7 +1670,7 @@ tauri::Builder::default()
|
||||
#[cfg(all(desktop, feature = "tray-icon"))]
|
||||
{
|
||||
let config = app.config();
|
||||
if let Some(tray_config) = &config.tauri.tray_icon {
|
||||
if let Some(tray_config) = &config.app.tray_icon {
|
||||
let mut tray =
|
||||
TrayIconBuilder::with_id(tray_config.id.clone().unwrap_or_else(|| "main".into()))
|
||||
.icon_as_template(tray_config.icon_as_template)
|
||||
@@ -1753,7 +1748,7 @@ fn setup<R: Runtime>(app: &mut App<R>) -> crate::Result<()> {
|
||||
|
||||
let window_labels = app
|
||||
.config()
|
||||
.tauri
|
||||
.app
|
||||
.windows
|
||||
.iter()
|
||||
.map(|p| p.label.clone())
|
||||
@@ -1766,7 +1761,7 @@ fn setup<R: Runtime>(app: &mut App<R>) -> crate::Result<()> {
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
for window_config in app.config().tauri.windows.clone() {
|
||||
for window_config in app.config().app.windows.clone() {
|
||||
WebviewWindowBuilder::from_config(app.handle(), &window_config)?
|
||||
.build_internal(&window_labels, &webview_labels)?;
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ pub enum Error {
|
||||
UnstableFeatureNotSupported,
|
||||
/// Failed to deserialize scope object.
|
||||
#[error("error deserializing scope: {0}")]
|
||||
CannotDeserializeScope(Box<dyn std::error::Error>),
|
||||
CannotDeserializeScope(Box<dyn std::error::Error + Send>),
|
||||
}
|
||||
|
||||
/// `Result<T, ::tauri::Error>`
|
||||
|
||||
@@ -363,7 +363,7 @@ pub struct ScopeManager {
|
||||
/// though this is useful if you need to do some initialization logic on the type itself.
|
||||
pub trait ScopeObject: Sized + Send + Sync + Debug + 'static {
|
||||
/// The error type.
|
||||
type Error: std::error::Error;
|
||||
type Error: std::error::Error + Send;
|
||||
/// Deserialize the raw scope value.
|
||||
fn deserialize<R: Runtime>(app: &AppHandle<R>, raw: Value) -> Result<Self, Self::Error>;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
//! - **objc-exception**: Wrap each msg_send! in a @try/@catch and panics if an exception is caught, preventing Objective-C from unwinding into Rust.
|
||||
//! - **linux-ipc-protocol**: Use custom protocol for faster IPC on Linux. Requires webkit2gtk v2.40 or above.
|
||||
//! - **linux-libxdo**: Enables linking to libxdo which enables Cut, Copy, Paste and SelectAll menu items to work on Linux.
|
||||
//! - **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.
|
||||
//! - **isolation**: Enables the isolation pattern. Enabled by default if the `app > security > 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.
|
||||
//! - **devtools**: Enables the developer tools (Web inspector) and [`window::Window#method.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.
|
||||
|
||||
@@ -25,11 +25,7 @@ use crate::{
|
||||
event::{assert_event_name_is_valid, Event, EventId, EventTarget, Listeners},
|
||||
ipc::{Invoke, InvokeHandler, InvokeResponder, RuntimeAuthority},
|
||||
plugin::PluginStore,
|
||||
utils::{
|
||||
assets::Assets,
|
||||
config::{AppUrl, Config, WebviewUrl},
|
||||
PackageInfo,
|
||||
},
|
||||
utils::{assets::Assets, config::Config, PackageInfo},
|
||||
Context, Pattern, Runtime, StateManager, Window,
|
||||
};
|
||||
use crate::{event::EmitArgs, resources::ResourceTable, Webview};
|
||||
@@ -80,7 +76,7 @@ fn set_csp<R: Runtime>(
|
||||
|
||||
let dangerous_disable_asset_csp_modification = &manager
|
||||
.config()
|
||||
.tauri
|
||||
.app
|
||||
.security
|
||||
.dangerous_disable_asset_csp_modification;
|
||||
if dangerous_disable_asset_csp_modification.can_modify("script-src") {
|
||||
@@ -295,28 +291,20 @@ impl<R: Runtime> AppManager<R> {
|
||||
|
||||
/// Get the base path to serve data from.
|
||||
///
|
||||
/// * In dev mode, this will be based on the `devPath` configuration value.
|
||||
/// * Otherwise, this will be based on the `distDir` configuration value.
|
||||
/// * In dev mode, this will be based on the `devUrl` configuration value.
|
||||
/// * Otherwise, this will be based on the `frontendDist` configuration value.
|
||||
#[cfg(not(dev))]
|
||||
fn base_path(&self) -> Option<&AppUrl> {
|
||||
self.config.build.dist_dir.as_ref()
|
||||
fn base_path(&self) -> Option<&Url> {
|
||||
use crate::utils::config::FrontendDist;
|
||||
match self.config.build.frontend_dist.as_ref() {
|
||||
Some(FrontendDist::Url(url)) => Some(url),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(dev)]
|
||||
fn base_path(&self) -> Option<&AppUrl> {
|
||||
self.config.build.dev_path.as_ref()
|
||||
}
|
||||
|
||||
/// Get the base URL to use for webview requests.
|
||||
///
|
||||
/// In dev mode, this will be based on the `devPath` configuration value.
|
||||
pub(crate) fn get_url(&self) -> Cow<'_, Url> {
|
||||
match self.base_path() {
|
||||
Some(AppUrl::Url(WebviewUrl::External(url) | WebviewUrl::CustomProtocol(url))) => {
|
||||
Cow::Borrowed(url)
|
||||
}
|
||||
_ => self.protocol_url(),
|
||||
}
|
||||
fn base_path(&self) -> Option<&Url> {
|
||||
self.config.build.dev_url.as_ref()
|
||||
}
|
||||
|
||||
pub(crate) fn protocol_url(&self) -> Cow<'_, Url> {
|
||||
@@ -327,17 +315,27 @@ impl<R: Runtime> AppManager<R> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the base URL to use for webview requests.
|
||||
///
|
||||
/// In dev mode, this will be based on the `devUrl` configuration value.
|
||||
pub(crate) fn get_url(&self) -> Cow<'_, Url> {
|
||||
match self.base_path() {
|
||||
Some(url) => Cow::Borrowed(url),
|
||||
_ => self.protocol_url(),
|
||||
}
|
||||
}
|
||||
|
||||
fn csp(&self) -> Option<Csp> {
|
||||
if cfg!(feature = "custom-protocol") {
|
||||
self.config.tauri.security.csp.clone()
|
||||
self.config.app.security.csp.clone()
|
||||
} else {
|
||||
self
|
||||
.config
|
||||
.tauri
|
||||
.app
|
||||
.security
|
||||
.dev_csp
|
||||
.clone()
|
||||
.or_else(|| self.config.tauri.security.csp.clone())
|
||||
.or_else(|| self.config.app.security.csp.clone())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ impl<R: Runtime> WebviewManager<R> {
|
||||
) -> crate::Result<PendingWebview<EventLoopMessage, R>> {
|
||||
let app_manager = manager.manager();
|
||||
|
||||
let is_init_global = app_manager.config.build.with_global_tauri;
|
||||
let is_init_global = app_manager.config.app.with_global_tauri;
|
||||
let plugin_init = app_manager
|
||||
.plugins
|
||||
.lock()
|
||||
@@ -353,7 +353,7 @@ impl<R: Runtime> WebviewManager<R> {
|
||||
""
|
||||
};
|
||||
|
||||
let freeze_prototype = if app_manager.config.tauri.security.freeze_prototype {
|
||||
let freeze_prototype = if app_manager.config.app.security.freeze_prototype {
|
||||
include_str!("../../scripts/freeze_prototype.js")
|
||||
} else {
|
||||
""
|
||||
@@ -500,7 +500,7 @@ impl<R: Runtime> WebviewManager<R> {
|
||||
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
||||
if pending.webview_attributes.data_directory.is_none() {
|
||||
let local_app_data = manager.path().resolve(
|
||||
&app_manager.config.tauri.bundle.identifier,
|
||||
&app_manager.config.identifier,
|
||||
crate::path::BaseDirectory::LocalData,
|
||||
);
|
||||
if let Ok(user_data_dir) = local_app_data {
|
||||
|
||||
@@ -142,8 +142,8 @@ impl<R: Runtime> Menu<R> {
|
||||
let about_metadata = AboutMetadata {
|
||||
name: Some(pkg_info.name.clone()),
|
||||
version: Some(pkg_info.version.to_string()),
|
||||
copyright: config.tauri.bundle.copyright.clone(),
|
||||
authors: config.tauri.bundle.publisher.clone().map(|p| vec![p]),
|
||||
copyright: config.bundle.copyright.clone(),
|
||||
authors: config.bundle.publisher.clone().map(|p| vec![p]),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ impl<R: Runtime> PathResolver<R> {
|
||||
pub fn app_config_dir(&self) -> Result<PathBuf> {
|
||||
dirs_next::config_dir()
|
||||
.ok_or(Error::UnknownPath)
|
||||
.map(|dir| dir.join(&self.0.config().tauri.bundle.identifier))
|
||||
.map(|dir| dir.join(&self.0.config().identifier))
|
||||
}
|
||||
|
||||
/// Returns the path to the suggested directory for your app's data files.
|
||||
@@ -207,7 +207,7 @@ impl<R: Runtime> PathResolver<R> {
|
||||
pub fn app_data_dir(&self) -> Result<PathBuf> {
|
||||
dirs_next::data_dir()
|
||||
.ok_or(Error::UnknownPath)
|
||||
.map(|dir| dir.join(&self.0.config().tauri.bundle.identifier))
|
||||
.map(|dir| dir.join(&self.0.config().identifier))
|
||||
}
|
||||
|
||||
/// Returns the path to the suggested directory for your app's local data files.
|
||||
@@ -216,7 +216,7 @@ impl<R: Runtime> PathResolver<R> {
|
||||
pub fn app_local_data_dir(&self) -> Result<PathBuf> {
|
||||
dirs_next::data_local_dir()
|
||||
.ok_or(Error::UnknownPath)
|
||||
.map(|dir| dir.join(&self.0.config().tauri.bundle.identifier))
|
||||
.map(|dir| dir.join(&self.0.config().identifier))
|
||||
}
|
||||
|
||||
/// Returns the path to the suggested directory for your app's cache files.
|
||||
@@ -225,7 +225,7 @@ impl<R: Runtime> PathResolver<R> {
|
||||
pub fn app_cache_dir(&self) -> Result<PathBuf> {
|
||||
dirs_next::cache_dir()
|
||||
.ok_or(Error::UnknownPath)
|
||||
.map(|dir| dir.join(&self.0.config().tauri.bundle.identifier))
|
||||
.map(|dir| dir.join(&self.0.config().identifier))
|
||||
}
|
||||
|
||||
/// Returns the path to the suggested directory for your app's log files.
|
||||
@@ -237,20 +237,14 @@ impl<R: Runtime> PathResolver<R> {
|
||||
/// - **Windows:** Resolves to [`data_local_dir`](self.data_local_dir)`/${bundle_identifier}/logs`.
|
||||
pub fn app_log_dir(&self) -> Result<PathBuf> {
|
||||
#[cfg(target_os = "macos")]
|
||||
let path = dirs_next::home_dir().ok_or(Error::UnknownPath).map(|dir| {
|
||||
dir
|
||||
.join("Library/Logs")
|
||||
.join(&self.0.config().tauri.bundle.identifier)
|
||||
});
|
||||
let path = dirs_next::home_dir()
|
||||
.ok_or(Error::UnknownPath)
|
||||
.map(|dir| dir.join("Library/Logs").join(&self.0.config().identifier));
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
let path = dirs_next::data_local_dir()
|
||||
.ok_or(Error::UnknownPath)
|
||||
.map(|dir| {
|
||||
dir
|
||||
.join(&self.0.config().tauri.bundle.identifier)
|
||||
.join("logs")
|
||||
});
|
||||
.map(|dir| dir.join(&self.0.config().identifier).join("logs"));
|
||||
|
||||
path
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ use crate::{
|
||||
use tauri_utils::{
|
||||
acl::resolved::Resolved,
|
||||
assets::{AssetKey, Assets, CspHash},
|
||||
config::{Config, PatternKind, TauriConfig},
|
||||
config::{AppConfig, Config},
|
||||
};
|
||||
|
||||
/// An empty [`Assets`] implementation.
|
||||
@@ -98,15 +98,17 @@ pub fn mock_context<A: Assets>(assets: A) -> crate::Context<A> {
|
||||
Context {
|
||||
config: Config {
|
||||
schema: None,
|
||||
package: Default::default(),
|
||||
tauri: TauriConfig {
|
||||
pattern: PatternKind::Brownfield,
|
||||
product_name: Default::default(),
|
||||
version: Default::default(),
|
||||
identifier: Default::default(),
|
||||
app: AppConfig {
|
||||
with_global_tauri: Default::default(),
|
||||
windows: Vec::new(),
|
||||
bundle: Default::default(),
|
||||
security: Default::default(),
|
||||
tray_icon: None,
|
||||
macos_private_api: false,
|
||||
},
|
||||
bundle: Default::default(),
|
||||
build: Default::default(),
|
||||
plugins: Default::default(),
|
||||
},
|
||||
|
||||
@@ -324,7 +324,7 @@ async fn create_window(app: tauri::AppHandle) {
|
||||
```
|
||||
#[tauri::command]
|
||||
async fn reopen_window(app: tauri::AppHandle) {
|
||||
let window = tauri::window::WindowBuilder::from_config(&app, &app.config().tauri.windows.get(0).unwrap().clone())
|
||||
let window = tauri::window::WindowBuilder::from_config(&app, &app.config().app.windows.get(0).unwrap().clone())
|
||||
.unwrap()
|
||||
.build()
|
||||
.unwrap();
|
||||
@@ -1030,7 +1030,7 @@ fn main() {
|
||||
&& current_url.domain() == protocol_url.domain()
|
||||
}) ||
|
||||
|
||||
// or if relative to `distDir` or `devPath`
|
||||
// or if relative to `devUrl` or `frontendDist`
|
||||
self
|
||||
.manager()
|
||||
.get_url()
|
||||
|
||||
@@ -122,7 +122,7 @@ impl<'a, R: Runtime, M: Manager<R>> WebviewWindowBuilder<'a, R, M> {
|
||||
```
|
||||
#[tauri::command]
|
||||
async fn reopen_window(app: tauri::AppHandle) {
|
||||
let webview_window = tauri::window::WindowBuilder::from_config(&app, &app.config().tauri.windows.get(0).unwrap().clone())
|
||||
let webview_window = tauri::window::WindowBuilder::from_config(&app, &app.config().app.windows.get(0).unwrap().clone())
|
||||
.unwrap()
|
||||
.build()
|
||||
.unwrap();
|
||||
@@ -585,7 +585,6 @@ impl<'a, R: Runtime, M: Manager<R>> WebviewWindowBuilder<'a, R, M> {
|
||||
///
|
||||
/// For more information, see <https://docs.microsoft.com/en-us/windows/win32/winmsg/window-features#owned-windows>
|
||||
#[cfg(windows)]
|
||||
#[must_use]
|
||||
pub fn owner(mut self, owner: &WebviewWindow<R>) -> crate::Result<Self> {
|
||||
self.window_builder = self.window_builder.owner(&owner.webview.window)?;
|
||||
Ok(self)
|
||||
@@ -653,6 +652,7 @@ impl<'a, R: Runtime, M: Manager<R>> WebviewWindowBuilder<'a, R, M> {
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
))]
|
||||
#[must_use]
|
||||
pub fn transient_for_raw(mut self, parent: &impl gtk::glib::IsA<gtk::Window>) -> Self {
|
||||
self.window_builder = self.window_builder.transient_for_raw(parent);
|
||||
self
|
||||
|
||||
@@ -226,7 +226,7 @@ async fn create_window(app: tauri::AppHandle) {
|
||||
```
|
||||
#[tauri::command]
|
||||
async fn reopen_window(app: tauri::AppHandle) {
|
||||
let window = tauri::window::WindowBuilder::from_config(&app, &app.config().tauri.windows.get(0).unwrap().clone())
|
||||
let window = tauri::window::WindowBuilder::from_config(&app, &app.config().app.windows.get(0).unwrap().clone())
|
||||
.unwrap()
|
||||
.build()
|
||||
.unwrap();
|
||||
@@ -705,7 +705,6 @@ impl<'a, R: Runtime, M: Manager<R>> WindowBuilder<'a, R, M> {
|
||||
///
|
||||
/// For more information, see <https://docs.microsoft.com/en-us/windows/win32/winmsg/window-features#owned-windows>
|
||||
#[cfg(windows)]
|
||||
#[must_use]
|
||||
pub fn owner(mut self, owner: &Window<R>) -> crate::Result<Self> {
|
||||
self.window_builder = self.window_builder.owner(owner.hwnd()?);
|
||||
Ok(self)
|
||||
@@ -783,6 +782,7 @@ impl<'a, R: Runtime, M: Manager<R>> WindowBuilder<'a, R, M> {
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
))]
|
||||
#[must_use]
|
||||
pub fn transient_for_raw(mut self, parent: &impl gtk::glib::IsA<gtk::Window>) -> Self {
|
||||
self.window_builder = self.window_builder.transient_for(parent);
|
||||
self
|
||||
|
||||
@@ -1 +1 @@
|
||||
{ "devPath": "http://localhost" }
|
||||
{ "devUrl": "http://localhost" }
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
{
|
||||
"$schema": "../../../../../core/tauri-config-schema/schema.json",
|
||||
"identifier": "studio.tauri.example",
|
||||
"build": {
|
||||
"distDir": "../dist",
|
||||
"devPath": "http://localhost:4000"
|
||||
"frontendDist": "../dist",
|
||||
"devUrl": "http://localhost:4000"
|
||||
},
|
||||
"tauri": {
|
||||
"bundle": {
|
||||
"identifier": "studio.tauri.example",
|
||||
"active": true
|
||||
},
|
||||
"app": {
|
||||
"windows": [
|
||||
{
|
||||
"title": "Tauri App"
|
||||
@@ -17,5 +14,8 @@
|
||||
"security": {
|
||||
"csp": "default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self'; connect-src ipc: http://ipc.localhost"
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"active": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,40 @@
|
||||
{
|
||||
"$schema": "../../../core/tauri-config-schema/schema.json",
|
||||
"productName": "Tauri API",
|
||||
"version": "1.0.0",
|
||||
"identifier": "com.tauri.api",
|
||||
"build": {
|
||||
"distDir": "../dist",
|
||||
"devPath": "http://localhost:1420",
|
||||
"frontendDist": "../dist",
|
||||
"devUrl": "http://localhost:1420",
|
||||
"beforeDevCommand": "yarn dev",
|
||||
"beforeBuildCommand": "yarn build",
|
||||
"withGlobalTauri": true
|
||||
"beforeBuildCommand": "yarn build"
|
||||
},
|
||||
"package": {
|
||||
"productName": "Tauri API",
|
||||
"version": "1.0.0"
|
||||
"app": {
|
||||
"withGlobalTauri": true,
|
||||
"macOSPrivateApi": true,
|
||||
"security": {
|
||||
"pattern": {
|
||||
"use": "isolation",
|
||||
"options": {
|
||||
"dir": "../isolation-dist/"
|
||||
}
|
||||
},
|
||||
"csp": {
|
||||
"default-src": "'self' customprotocol: asset:",
|
||||
"connect-src": "ipc: http://ipc.localhost",
|
||||
"font-src": ["https://fonts.gstatic.com"],
|
||||
"img-src": "'self' asset: http://asset.localhost blob: data:",
|
||||
"style-src": "'unsafe-inline' 'self' https://fonts.googleapis.com"
|
||||
},
|
||||
"freezePrototype": true,
|
||||
"assetProtocol": {
|
||||
"enable": true,
|
||||
"scope": {
|
||||
"allow": ["$APPDATA/db/**", "$RESOURCE/**"],
|
||||
"deny": ["$APPDATA/db/*.stronghold"]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"plugins": {
|
||||
"cli": {
|
||||
@@ -48,58 +73,23 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"tauri": {
|
||||
"pattern": {
|
||||
"use": "isolation",
|
||||
"options": {
|
||||
"dir": "../isolation-dist/"
|
||||
}
|
||||
},
|
||||
"macOSPrivateApi": true,
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"identifier": "com.tauri.api",
|
||||
"icon": [
|
||||
"../../.icons/32x32.png",
|
||||
"../../.icons/128x128.png",
|
||||
"../../.icons/128x128@2x.png",
|
||||
"../../.icons/icon.icns",
|
||||
"../../.icons/icon.ico"
|
||||
],
|
||||
"windows": {
|
||||
"wix": {
|
||||
"language": {
|
||||
"en-US": {},
|
||||
"pt-BR": {
|
||||
"localePath": "locales/pt-BR.wxl"
|
||||
}
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"icon": [
|
||||
"../../.icons/32x32.png",
|
||||
"../../.icons/128x128.png",
|
||||
"../../.icons/128x128@2x.png",
|
||||
"../../.icons/icon.icns",
|
||||
"../../.icons/icon.ico"
|
||||
],
|
||||
"windows": {
|
||||
"wix": {
|
||||
"language": {
|
||||
"en-US": {},
|
||||
"pt-BR": {
|
||||
"localePath": "locales/pt-BR.wxl"
|
||||
}
|
||||
}
|
||||
},
|
||||
"updater": {
|
||||
"active": true,
|
||||
"pubkey": "asdasd",
|
||||
"windows": {
|
||||
"installMode": "passive"
|
||||
}
|
||||
}
|
||||
},
|
||||
"windows": [],
|
||||
"security": {
|
||||
"csp": {
|
||||
"default-src": "'self' customprotocol: asset:",
|
||||
"connect-src": "ipc: http://ipc.localhost",
|
||||
"font-src": ["https://fonts.gstatic.com"],
|
||||
"img-src": "'self' asset: http://asset.localhost blob: data:",
|
||||
"style-src": "'unsafe-inline' 'self' https://fonts.googleapis.com"
|
||||
},
|
||||
"freezePrototype": true,
|
||||
"assetProtocol": {
|
||||
"enable": true,
|
||||
"scope": {
|
||||
"allow": ["$APPDATA/db/**", "$RESOURCE/**"],
|
||||
"deny": ["$APPDATA/db/*.stronghold"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,46 +1,13 @@
|
||||
{
|
||||
"$schema": "../../core/tauri-config-schema/schema.json",
|
||||
"productName": "Commands",
|
||||
"version": "0.1.0",
|
||||
"identifier": "com.tauri.dev",
|
||||
"build": {
|
||||
"distDir": [
|
||||
"index.html"
|
||||
],
|
||||
"devPath": [
|
||||
"index.html"
|
||||
],
|
||||
"beforeDevCommand": "",
|
||||
"beforeBuildCommand": "",
|
||||
"withGlobalTauri": true
|
||||
"frontendDist": ["index.html"]
|
||||
},
|
||||
"package": {
|
||||
"productName": "Commands",
|
||||
"version": "0.1.0"
|
||||
},
|
||||
"tauri": {
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"identifier": "com.tauri.dev",
|
||||
"icon": [
|
||||
"../.icons/32x32.png",
|
||||
"../.icons/128x128.png",
|
||||
"../.icons/128x128@2x.png",
|
||||
"../.icons/icon.icns",
|
||||
"../.icons/icon.ico"
|
||||
],
|
||||
"resources": [],
|
||||
"externalBin": [],
|
||||
"copyright": "",
|
||||
"category": "DeveloperTool",
|
||||
"shortDescription": "",
|
||||
"longDescription": "",
|
||||
"deb": {
|
||||
"depends": []
|
||||
},
|
||||
"macOS": {
|
||||
"frameworks": [],
|
||||
"exceptionDomain": ""
|
||||
}
|
||||
},
|
||||
"app": {
|
||||
"withGlobalTauri": true,
|
||||
"windows": [
|
||||
{
|
||||
"title": "Welcome to Tauri!",
|
||||
@@ -53,5 +20,16 @@
|
||||
"security": {
|
||||
"csp": "default-src 'self'; connect-src ipc: http://ipc.localhost"
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"icon": [
|
||||
"../.icons/32x32.png",
|
||||
"../.icons/128x128.png",
|
||||
"../.icons/128x128@2x.png",
|
||||
"../.icons/icon.icns",
|
||||
"../.icons/icon.ico"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,58 +1,37 @@
|
||||
{
|
||||
"$schema": "../../../tooling/cli/schema.json",
|
||||
"identifier": "com.tauri.dev-file-associations-demo",
|
||||
"build": {
|
||||
"distDir": [
|
||||
"../index.html"
|
||||
],
|
||||
"devPath": [
|
||||
"../index.html"
|
||||
],
|
||||
"beforeDevCommand": "",
|
||||
"beforeBuildCommand": ""
|
||||
"frontendDist": ["../index.html"]
|
||||
},
|
||||
"tauri": {
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"identifier": "com.tauri.dev-file-associations-demo",
|
||||
"icon": [
|
||||
"../../.icons/32x32.png",
|
||||
"../../.icons/128x128.png",
|
||||
"../../.icons/128x128@2x.png",
|
||||
"../../.icons/icon.icns",
|
||||
"../../.icons/icon.ico"
|
||||
],
|
||||
"resources": [],
|
||||
"externalBin": [],
|
||||
"copyright": "",
|
||||
"category": "DeveloperTool",
|
||||
"fileAssociations": [
|
||||
{
|
||||
"ext": ["png"],
|
||||
"mimeType": "image/png"
|
||||
},
|
||||
{
|
||||
"ext": ["jpg", "jpeg"],
|
||||
"mimeType": "image/jpeg"
|
||||
},
|
||||
{
|
||||
"ext": ["gif"],
|
||||
"mimeType": "image/gif"
|
||||
}
|
||||
],
|
||||
"shortDescription": "",
|
||||
"longDescription": "",
|
||||
"deb": {
|
||||
"depends": []
|
||||
},
|
||||
"macOS": {
|
||||
"frameworks": [],
|
||||
"exceptionDomain": ""
|
||||
}
|
||||
},
|
||||
"windows": [],
|
||||
"app": {
|
||||
"security": {
|
||||
"csp": "default-src 'self'"
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"icon": [
|
||||
"../../.icons/32x32.png",
|
||||
"../../.icons/128x128.png",
|
||||
"../../.icons/128x128@2x.png",
|
||||
"../../.icons/icon.icns",
|
||||
"../../.icons/icon.ico"
|
||||
],
|
||||
"fileAssociations": [
|
||||
{
|
||||
"ext": ["png"],
|
||||
"mimeType": "image/png"
|
||||
},
|
||||
{
|
||||
"ext": ["jpg", "jpeg"],
|
||||
"mimeType": "image/jpeg"
|
||||
},
|
||||
{
|
||||
"ext": ["gif"],
|
||||
"mimeType": "image/gif"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,46 +1,12 @@
|
||||
{
|
||||
"$schema": "../../core/tauri-config-schema/schema.json",
|
||||
"productName": "Hello World",
|
||||
"version": "0.1.0",
|
||||
"identifier": "com.tauri.dev",
|
||||
"build": {
|
||||
"distDir": [
|
||||
"index.html"
|
||||
],
|
||||
"devPath": [
|
||||
"index.html"
|
||||
],
|
||||
"beforeDevCommand": "",
|
||||
"beforeBuildCommand": ""
|
||||
"frontendDist": ["index.html"]
|
||||
},
|
||||
"package": {
|
||||
"productName": "Hello World",
|
||||
"version": "0.1.0"
|
||||
},
|
||||
"tauri": {
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"identifier": "com.tauri.dev",
|
||||
"icon": [
|
||||
"../.icons/32x32.png",
|
||||
"../.icons/128x128.png",
|
||||
"../.icons/128x128@2x.png",
|
||||
"../.icons/icon.icns",
|
||||
"../.icons/icon.ico"
|
||||
],
|
||||
"resources": [],
|
||||
"externalBin": [],
|
||||
"copyright": "",
|
||||
"category": "DeveloperTool",
|
||||
"shortDescription": "",
|
||||
"longDescription": "",
|
||||
"deb": {
|
||||
"depends": []
|
||||
},
|
||||
"macOS": {
|
||||
"frameworks": [],
|
||||
"files": {},
|
||||
"exceptionDomain": ""
|
||||
}
|
||||
},
|
||||
"app": {
|
||||
"windows": [
|
||||
{
|
||||
"title": "Welcome to Tauri!",
|
||||
@@ -53,5 +19,16 @@
|
||||
"security": {
|
||||
"csp": "default-src 'self'; connect-src ipc: http://ipc.localhost"
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"icon": [
|
||||
"../.icons/32x32.png",
|
||||
"../.icons/128x128.png",
|
||||
"../.icons/128x128@2x.png",
|
||||
"../.icons/icon.icns",
|
||||
"../.icons/icon.ico"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,55 +1,15 @@
|
||||
{
|
||||
"$schema": "../../core/tauri-config-schema/schema.json",
|
||||
"package": {
|
||||
"productName": "Isolation",
|
||||
"version": "0.1.0"
|
||||
},
|
||||
"productName": "Isolation",
|
||||
"version": "0.1.0",
|
||||
"identifier": "com.tauri.dev",
|
||||
"build": {
|
||||
"distDir": "dist",
|
||||
"devPath": "dist",
|
||||
"frontendDist": "dist",
|
||||
"beforeDevCommand": "",
|
||||
"beforeBuildCommand": "",
|
||||
"withGlobalTauri": true
|
||||
"beforeBuildCommand": ""
|
||||
},
|
||||
"tauri": {
|
||||
"pattern": {
|
||||
"use": "isolation",
|
||||
"options": {
|
||||
"dir": "isolation-dist"
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"identifier": "com.tauri.dev",
|
||||
"icon": [
|
||||
"../.icons/32x32.png",
|
||||
"../.icons/128x128.png",
|
||||
"../.icons/128x128@2x.png",
|
||||
"../.icons/icon.icns",
|
||||
"../.icons/icon.ico"
|
||||
],
|
||||
"resources": [],
|
||||
"externalBin": [],
|
||||
"copyright": "",
|
||||
"category": "DeveloperTool",
|
||||
"shortDescription": "",
|
||||
"longDescription": "",
|
||||
"deb": {
|
||||
"depends": []
|
||||
},
|
||||
"macOS": {
|
||||
"frameworks": [],
|
||||
"exceptionDomain": "",
|
||||
"signingIdentity": null,
|
||||
"entitlements": null
|
||||
},
|
||||
"windows": {
|
||||
"certificateThumbprint": null,
|
||||
"digestAlgorithm": "sha256",
|
||||
"timestampUrl": ""
|
||||
}
|
||||
},
|
||||
"app": {
|
||||
"withGlobalTauri": true,
|
||||
"windows": [
|
||||
{
|
||||
"title": "Isolation",
|
||||
@@ -60,7 +20,24 @@
|
||||
}
|
||||
],
|
||||
"security": {
|
||||
"csp": "default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'; connect-src ipc: http://ipc.localhost"
|
||||
"csp": "default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'; connect-src ipc: http://ipc.localhost",
|
||||
"pattern": {
|
||||
"use": "isolation",
|
||||
"options": {
|
||||
"dir": "isolation-dist"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"icon": [
|
||||
"../.icons/32x32.png",
|
||||
"../.icons/128x128.png",
|
||||
"../.icons/128x128@2x.png",
|
||||
"../.icons/icon.icns",
|
||||
"../.icons/icon.ico"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,43 +1,25 @@
|
||||
{
|
||||
"productName": "MultiWebview",
|
||||
"version": "0.1.0",
|
||||
"identifier": "com.tauri.dev",
|
||||
"$schema": "../../core/tauri-config-schema/schema.json",
|
||||
"build": {
|
||||
"distDir": ["index.html"],
|
||||
"devPath": ["index.html"],
|
||||
"beforeDevCommand": "",
|
||||
"beforeBuildCommand": ""
|
||||
"frontendDist": ["index.html"]
|
||||
},
|
||||
"package": {
|
||||
"productName": "MultiWebview",
|
||||
"version": "0.1.0"
|
||||
},
|
||||
"tauri": {
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"identifier": "com.tauri.dev",
|
||||
"icon": [
|
||||
"../.icons/32x32.png",
|
||||
"../.icons/128x128.png",
|
||||
"../.icons/128x128@2x.png",
|
||||
"../.icons/icon.icns",
|
||||
"../.icons/icon.ico"
|
||||
],
|
||||
"resources": [],
|
||||
"externalBin": [],
|
||||
"copyright": "",
|
||||
"category": "DeveloperTool",
|
||||
"shortDescription": "",
|
||||
"longDescription": "",
|
||||
"deb": {
|
||||
"depends": []
|
||||
},
|
||||
"macOS": {
|
||||
"frameworks": [],
|
||||
"exceptionDomain": ""
|
||||
}
|
||||
},
|
||||
"app": {
|
||||
"security": {
|
||||
"csp": "default-src 'self'; connect-src ipc: http://ipc.localhost"
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"icon": [
|
||||
"../.icons/32x32.png",
|
||||
"../.icons/128x128.png",
|
||||
"../.icons/128x128@2x.png",
|
||||
"../.icons/icon.icns",
|
||||
"../.icons/icon.ico"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +1,13 @@
|
||||
{
|
||||
"$schema": "../../core/tauri-config-schema/schema.json",
|
||||
"productName": "Multi Window",
|
||||
"version": "0.1.0",
|
||||
"identifier": "com.tauri.dev",
|
||||
"build": {
|
||||
"distDir": [
|
||||
"index.html"
|
||||
],
|
||||
"devPath": [
|
||||
"index.html"
|
||||
],
|
||||
"withGlobalTauri": true
|
||||
"frontendDist": ["index.html"]
|
||||
},
|
||||
"package": {
|
||||
"productName": "Multi Window",
|
||||
"version": "0.1.0"
|
||||
},
|
||||
"tauri": {
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"identifier": "com.tauri.dev",
|
||||
"icon": [
|
||||
"../.icons/32x32.png",
|
||||
"../.icons/128x128.png",
|
||||
"../.icons/128x128@2x.png",
|
||||
"../.icons/icon.icns",
|
||||
"../.icons/icon.ico"
|
||||
],
|
||||
"resources": [],
|
||||
"externalBin": [],
|
||||
"copyright": "",
|
||||
"category": "DeveloperTool"
|
||||
},
|
||||
"app": {
|
||||
"withGlobalTauri": true,
|
||||
"windows": [
|
||||
{
|
||||
"label": "Main",
|
||||
@@ -49,5 +27,20 @@
|
||||
"security": {
|
||||
"csp": "default-src 'self'; connect-src ipc: http://ipc.localhost"
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"icon": [
|
||||
"../.icons/32x32.png",
|
||||
"../.icons/128x128.png",
|
||||
"../.icons/128x128@2x.png",
|
||||
"../.icons/icon.icns",
|
||||
"../.icons/icon.ico"
|
||||
],
|
||||
"resources": [],
|
||||
"externalBin": [],
|
||||
"copyright": "",
|
||||
"category": "DeveloperTool"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,42 +1,13 @@
|
||||
{
|
||||
"$schema": "../../core/tauri-config-schema/schema.json",
|
||||
"productName": "Navigation",
|
||||
"version": "0.1.0",
|
||||
"identifier": "com.tauri.dev",
|
||||
"build": {
|
||||
"distDir": "public",
|
||||
"devPath": "public",
|
||||
"beforeDevCommand": "",
|
||||
"beforeBuildCommand": "",
|
||||
"withGlobalTauri": true
|
||||
"frontendDist": "public"
|
||||
},
|
||||
"package": {
|
||||
"productName": "Navigation",
|
||||
"version": "0.1.0"
|
||||
},
|
||||
"tauri": {
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"identifier": "com.tauri.dev",
|
||||
"icon": [
|
||||
"../.icons/32x32.png",
|
||||
"../.icons/128x128.png",
|
||||
"../.icons/128x128@2x.png",
|
||||
"../.icons/icon.icns",
|
||||
"../.icons/icon.ico"
|
||||
],
|
||||
"resources": [],
|
||||
"externalBin": [],
|
||||
"copyright": "",
|
||||
"category": "DeveloperTool",
|
||||
"shortDescription": "",
|
||||
"longDescription": "",
|
||||
"deb": {
|
||||
"depends": []
|
||||
},
|
||||
"macOS": {
|
||||
"frameworks": [],
|
||||
"exceptionDomain": ""
|
||||
}
|
||||
},
|
||||
"app": {
|
||||
"withGlobalTauri": true,
|
||||
"windows": [
|
||||
{
|
||||
"title": "Welcome to Tauri!",
|
||||
@@ -49,5 +20,16 @@
|
||||
"security": {
|
||||
"csp": "default-src 'self'; connect-src ipc: http://ipc.localhost"
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"icon": [
|
||||
"../.icons/32x32.png",
|
||||
"../.icons/128x128.png",
|
||||
"../.icons/128x128@2x.png",
|
||||
"../.icons/icon.icns",
|
||||
"../.icons/icon.ico"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,37 +1,27 @@
|
||||
{
|
||||
"$schema": "../../core/tauri-config-schema/schema.json",
|
||||
"productName": "Parent Window",
|
||||
"version": "0.1.0",
|
||||
"identifier": "com.tauri.dev",
|
||||
"build": {
|
||||
"distDir": [
|
||||
"index.html"
|
||||
],
|
||||
"devPath": [
|
||||
"index.html"
|
||||
],
|
||||
"withGlobalTauri": true
|
||||
"frontendDist": ["index.html"]
|
||||
},
|
||||
"package": {
|
||||
"productName": "Parent Window",
|
||||
"version": "0.1.0"
|
||||
},
|
||||
"tauri": {
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"identifier": "com.tauri.dev",
|
||||
"icon": [
|
||||
"../.icons/32x32.png",
|
||||
"../.icons/128x128.png",
|
||||
"../.icons/128x128@2x.png",
|
||||
"../.icons/icon.icns",
|
||||
"../.icons/icon.ico"
|
||||
],
|
||||
"resources": [],
|
||||
"externalBin": [],
|
||||
"copyright": "",
|
||||
"category": "DeveloperTool"
|
||||
},
|
||||
"app": {
|
||||
"withGlobalTauri": true,
|
||||
|
||||
"security": {
|
||||
"csp": "default-src 'self'; connect-src ipc: http://ipc.localhost"
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"icon": [
|
||||
"../.icons/32x32.png",
|
||||
"../.icons/128x128.png",
|
||||
"../.icons/128x128@2x.png",
|
||||
"../.icons/icon.icns",
|
||||
"../.icons/icon.ico"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Resource example
|
||||
|
||||
This example demonstrates the Tauri bundle resources functionality. The example adds `src-tauri/assets/index.js` as a resource (defined on `tauri.conf.json > tauri > bundle > resources`) and executes it using `Node.js`, locating the JavaScript file using the `tauri::App::path_resolver` APIs.
|
||||
This example demonstrates the Tauri bundle resources functionality. The example adds `src-tauri/assets/index.js` as a resource (defined on `tauri.conf.json > bundle > resources`) and executes it using `Node.js`, locating the JavaScript file using the `tauri::App::path_resolver` APIs.
|
||||
|
||||
## Running the example
|
||||
|
||||
|
||||
@@ -1,48 +1,14 @@
|
||||
{
|
||||
"$schema": "../../../core/tauri-config-schema/schema.json",
|
||||
"productName": "Resources",
|
||||
"version": "0.1.0",
|
||||
"identifier": "com.tauri.resources",
|
||||
"build": {
|
||||
"distDir": [
|
||||
"../index.html"
|
||||
],
|
||||
"devPath": [
|
||||
"../index.html"
|
||||
],
|
||||
"beforeDevCommand": "",
|
||||
"beforeBuildCommand": "",
|
||||
"withGlobalTauri": true
|
||||
"frontendDist": ["../index.html"]
|
||||
},
|
||||
"package": {
|
||||
"productName": "Resources",
|
||||
"version": "0.1.0"
|
||||
},
|
||||
"tauri": {
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"identifier": "com.tauri.resources",
|
||||
"icon": [
|
||||
"../../.icons/32x32.png",
|
||||
"../../.icons/128x128.png",
|
||||
"../../.icons/128x128@2x.png",
|
||||
"../../.icons/icon.icns",
|
||||
"../../.icons/icon.ico"
|
||||
],
|
||||
"resources": [
|
||||
"assets/*"
|
||||
],
|
||||
"externalBin": [],
|
||||
"copyright": "",
|
||||
"category": "DeveloperTool",
|
||||
"shortDescription": "",
|
||||
"longDescription": "",
|
||||
"deb": {
|
||||
"depends": []
|
||||
},
|
||||
"macOS": {
|
||||
"frameworks": [],
|
||||
"exceptionDomain": ""
|
||||
}
|
||||
},
|
||||
"app": {
|
||||
"withGlobalTauri": true,
|
||||
|
||||
"windows": [
|
||||
{
|
||||
"title": "Welcome to Tauri!",
|
||||
@@ -55,5 +21,17 @@
|
||||
"security": {
|
||||
"csp": "default-src 'self'; connect-src ipc: http://ipc.localhost"
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"icon": [
|
||||
"../../.icons/32x32.png",
|
||||
"../../.icons/128x128.png",
|
||||
"../../.icons/128x128@2x.png",
|
||||
"../../.icons/icon.icns",
|
||||
"../../.icons/icon.ico"
|
||||
],
|
||||
"resources": ["assets/*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,46 +1,12 @@
|
||||
{
|
||||
"$schema": "../../core/tauri-config-schema/schema.json",
|
||||
"productName": "RunIteration",
|
||||
"version": "0.1.0",
|
||||
"identifier": "com.tauri.dev",
|
||||
"build": {
|
||||
"distDir": [
|
||||
"index.html"
|
||||
],
|
||||
"devPath": [
|
||||
"index.html"
|
||||
],
|
||||
"beforeDevCommand": "",
|
||||
"beforeBuildCommand": ""
|
||||
"frontendDist": ["index.html"]
|
||||
},
|
||||
"package": {
|
||||
"productName": "RunIteration",
|
||||
"version": "0.1.0"
|
||||
},
|
||||
"tauri": {
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"identifier": "com.tauri.dev",
|
||||
"icon": [
|
||||
"../.icons/32x32.png",
|
||||
"../.icons/128x128.png",
|
||||
"../.icons/128x128@2x.png",
|
||||
"../.icons/icon.icns",
|
||||
"../.icons/icon.ico"
|
||||
],
|
||||
"resources": [],
|
||||
"externalBin": [],
|
||||
"copyright": "",
|
||||
"category": "DeveloperTool",
|
||||
"shortDescription": "",
|
||||
"longDescription": "",
|
||||
"deb": {
|
||||
"depends": []
|
||||
},
|
||||
"macOS": {
|
||||
"frameworks": [],
|
||||
"files": {},
|
||||
"exceptionDomain": ""
|
||||
}
|
||||
},
|
||||
"app": {
|
||||
"windows": [
|
||||
{
|
||||
"title": "Welcome to Tauri!",
|
||||
@@ -53,5 +19,16 @@
|
||||
"security": {
|
||||
"csp": "default-src 'self'; connect-src ipc: http://ipc.localhost"
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"icon": [
|
||||
"../.icons/32x32.png",
|
||||
"../.icons/128x128.png",
|
||||
"../.icons/128x128@2x.png",
|
||||
"../.icons/icon.icns",
|
||||
"../.icons/icon.ico"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +1,13 @@
|
||||
{
|
||||
"$schema": "../../core/tauri-config-schema/schema.json",
|
||||
"productName": "Splashscreen",
|
||||
"version": "0.1.0",
|
||||
"identifier": "com.tauri.dev",
|
||||
"build": {
|
||||
"distDir": "dist",
|
||||
"devPath": "dist",
|
||||
"withGlobalTauri": true
|
||||
"frontendDist": "dist"
|
||||
},
|
||||
"package": {
|
||||
"productName": "Splashscreen",
|
||||
"version": "0.1.0"
|
||||
},
|
||||
"tauri": {
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"identifier": "com.tauri.dev",
|
||||
"icon": [
|
||||
"../.icons/32x32.png",
|
||||
"../.icons/128x128.png",
|
||||
"../.icons/128x128@2x.png",
|
||||
"../.icons/icon.icns",
|
||||
"../.icons/icon.ico"
|
||||
],
|
||||
"resources": [],
|
||||
"externalBin": [],
|
||||
"copyright": "",
|
||||
"category": "DeveloperTool"
|
||||
},
|
||||
"app": {
|
||||
"withGlobalTauri": true,
|
||||
"windows": [
|
||||
{
|
||||
"label": "main",
|
||||
@@ -46,5 +28,16 @@
|
||||
"security": {
|
||||
"csp": "default-src 'self'; connect-src ipc: http://ipc.localhost"
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"icon": [
|
||||
"../.icons/32x32.png",
|
||||
"../.icons/128x128.png",
|
||||
"../.icons/128x128@2x.png",
|
||||
"../.icons/icon.icns",
|
||||
"../.icons/icon.ico"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,46 +1,13 @@
|
||||
{
|
||||
"$schema": "../../core/tauri-config-schema/schema.json",
|
||||
"productName": "State",
|
||||
"version": "0.1.0",
|
||||
"identifier": "com.tauri.dev",
|
||||
"build": {
|
||||
"distDir": [
|
||||
"index.html"
|
||||
],
|
||||
"devPath": [
|
||||
"index.html"
|
||||
],
|
||||
"beforeDevCommand": "",
|
||||
"beforeBuildCommand": "",
|
||||
"withGlobalTauri": true
|
||||
"frontendDist": ["index.html"]
|
||||
},
|
||||
"package": {
|
||||
"productName": "State",
|
||||
"version": "0.1.0"
|
||||
},
|
||||
"tauri": {
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"identifier": "com.tauri.dev",
|
||||
"icon": [
|
||||
"../.icons/32x32.png",
|
||||
"../.icons/128x128.png",
|
||||
"../.icons/128x128@2x.png",
|
||||
"../.icons/icon.icns",
|
||||
"../.icons/icon.ico"
|
||||
],
|
||||
"resources": [],
|
||||
"externalBin": [],
|
||||
"copyright": "",
|
||||
"category": "DeveloperTool",
|
||||
"shortDescription": "",
|
||||
"longDescription": "",
|
||||
"deb": {
|
||||
"depends": []
|
||||
},
|
||||
"macOS": {
|
||||
"frameworks": [],
|
||||
"exceptionDomain": ""
|
||||
}
|
||||
},
|
||||
"app": {
|
||||
"withGlobalTauri": true,
|
||||
"windows": [
|
||||
{
|
||||
"title": "Welcome to Tauri!",
|
||||
@@ -53,5 +20,16 @@
|
||||
"security": {
|
||||
"csp": "default-src 'self'; connect-src ipc: http://ipc.localhost"
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"icon": [
|
||||
"../.icons/32x32.png",
|
||||
"../.icons/128x128.png",
|
||||
"../.icons/128x128@2x.png",
|
||||
"../.icons/icon.icns",
|
||||
"../.icons/icon.ico"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,46 +1,13 @@
|
||||
{
|
||||
"$schema": "../../core/tauri-config-schema/schema.json",
|
||||
"productName": "Streaming",
|
||||
"version": "0.1.0",
|
||||
"identifier": "com.tauri.dev",
|
||||
"build": {
|
||||
"distDir": [
|
||||
"index.html"
|
||||
],
|
||||
"devPath": [
|
||||
"index.html"
|
||||
],
|
||||
"beforeDevCommand": "",
|
||||
"beforeBuildCommand": "",
|
||||
"withGlobalTauri": true
|
||||
"frontendDist": ["index.html"]
|
||||
},
|
||||
"package": {
|
||||
"productName": "Streaming",
|
||||
"version": "0.1.0"
|
||||
},
|
||||
"tauri": {
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"identifier": "com.tauri.dev",
|
||||
"icon": [
|
||||
"../.icons/32x32.png",
|
||||
"../.icons/128x128.png",
|
||||
"../.icons/128x128@2x.png",
|
||||
"../.icons/icon.icns",
|
||||
"../.icons/icon.ico"
|
||||
],
|
||||
"resources": [],
|
||||
"externalBin": [],
|
||||
"copyright": "",
|
||||
"category": "DeveloperTool",
|
||||
"shortDescription": "",
|
||||
"longDescription": "",
|
||||
"deb": {
|
||||
"depends": []
|
||||
},
|
||||
"macOS": {
|
||||
"frameworks": [],
|
||||
"exceptionDomain": ""
|
||||
}
|
||||
},
|
||||
"app": {
|
||||
"withGlobalTauri": true,
|
||||
"windows": [
|
||||
{
|
||||
"title": "Welcome to Tauri!",
|
||||
@@ -53,10 +20,19 @@
|
||||
"security": {
|
||||
"csp": "default-src 'self'; connect-src ipc: http://ipc.localhost; media-src stream: http://stream.localhost asset: http://asset.localhost",
|
||||
"assetProtocol": {
|
||||
"scope": [
|
||||
"**/test_video.mp4"
|
||||
]
|
||||
"scope": ["**/test_video.mp4"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"icon": [
|
||||
"../.icons/32x32.png",
|
||||
"../.icons/128x128.png",
|
||||
"../.icons/128x128@2x.png",
|
||||
"../.icons/icon.icns",
|
||||
"../.icons/icon.ico"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
# Readme
|
||||
|
||||
This is an example of compiling tauri as a dynamic shared library and running it from another app.
|
||||
|
||||
* src-tauri is an example of a library containing code to launch a tauri webview window.
|
||||
* src-app1 is a small example of calling tauri from a dynamic shared library through FFI.
|
||||
|
||||
Note that bundling of resources via tauri.conf.json may not work in some cases due to the nature of the build.
|
||||
So you have to be aware of copying any files needed to the correct paths for html / js etc.
|
||||
|
||||
## Rust libraries
|
||||
|
||||
Typically there are 3 types of libraries rust can generate
|
||||
|
||||
* rlib - rust static libraries
|
||||
* dylib - rust shared libraries
|
||||
* cdylib - dynamic shared libraries that can be used to interop with other languages.
|
||||
|
||||
Typically cdylib libraries are used for interop with C / C++ Projects but this can also include other languages.
|
||||
The src-tauri example uses the cdylib crate type
|
||||
|
||||
## Building / Running
|
||||
|
||||
``` bash
|
||||
# First build the library
|
||||
cd src-tauri
|
||||
cargo build
|
||||
cd ..
|
||||
|
||||
# Next build the app
|
||||
cd src-app1
|
||||
cargo build
|
||||
|
||||
# Next run the app
|
||||
cargo run
|
||||
```
|
||||
@@ -1,9 +0,0 @@
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
/target/
|
||||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
|
||||
config.json
|
||||
bundle.json
|
||||
48
examples/tauri-dynamic-lib/src-app1/Cargo.lock
generated
48
examples/tauri-dynamic-lib/src-app1/Cargo.lock
generated
@@ -1,48 +0,0 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "app1"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"libloading",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
version = "0.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "afe203d669ec979b7128619bae5a63b7b42e9203c1b29146079ee05e2f604b52"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
@@ -1,11 +0,0 @@
|
||||
[package]
|
||||
name = "app1"
|
||||
version = "0.1.0"
|
||||
description = "A simple app that makes a dll call"
|
||||
edition = "2021"
|
||||
rust-version = "1.70"
|
||||
|
||||
[workspace]
|
||||
|
||||
[dependencies]
|
||||
libloading = "0.7.2"
|
||||
@@ -1,22 +0,0 @@
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// This is an example of an application that loads and runs a dll
|
||||
// Typically this could be c++, we use rust here just for convenience
|
||||
// See https://michael-f-bryan.github.io/rust-ffi-guide/dynamic_loading.html
|
||||
|
||||
use libloading::{library_filename, Library, Symbol};
|
||||
type LibFunctionType1 = fn();
|
||||
|
||||
fn main() {
|
||||
let library_path = library_filename("../src-tauri/target/debug/tauri_app");
|
||||
println!("Loading run_tauri() from {:?}", library_path);
|
||||
|
||||
unsafe {
|
||||
let lib = Library::new(library_path).unwrap();
|
||||
let run_tauri: Symbol<LibFunctionType1> = lib.get(b"run_tauri").unwrap();
|
||||
println!("Launching webview");
|
||||
run_tauri()
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
/target/
|
||||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
|
||||
config.json
|
||||
bundle.json
|
||||
3120
examples/tauri-dynamic-lib/src-tauri/Cargo.lock
generated
3120
examples/tauri-dynamic-lib/src-tauri/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,22 +0,0 @@
|
||||
[package]
|
||||
name = "tauri_app"
|
||||
version = "0.1.0"
|
||||
description = "A very simple Dll Library that runs tauri and launches a webview window"
|
||||
edition = "2021"
|
||||
rust-version = "1.70"
|
||||
|
||||
[workspace]
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[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 = [] }
|
||||
|
||||
[features]
|
||||
custom-protocol = [ "tauri/custom-protocol" ]
|
||||
@@ -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()
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Welcome to Tauri!</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Welcome to Tauri!</h1>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,15 +0,0 @@
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// This is an example of a tauri app built into a dll
|
||||
// Calling lib_test1 within the dll will launch the webview
|
||||
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn run_tauri() {
|
||||
tauri::Builder::default()
|
||||
.run(tauri::generate_context!("./tauri.conf.json"))
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
{
|
||||
"$schema": "../../../core/tauri-config-schema/schema.json",
|
||||
"build": {
|
||||
"distDir": [
|
||||
"src/index.html"
|
||||
],
|
||||
"devPath": [
|
||||
"src/index.html"
|
||||
],
|
||||
"beforeDevCommand": "",
|
||||
"beforeBuildCommand": ""
|
||||
},
|
||||
"package": {
|
||||
"productName": "Dynamic Lib",
|
||||
"version": "0.1.0"
|
||||
},
|
||||
"tauri": {
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"identifier": "com.tauri.dev",
|
||||
"icon": [
|
||||
"../../.icons/32x32.png",
|
||||
"../../.icons/128x128.png",
|
||||
"../../.icons/128x128@2x.png",
|
||||
"../../.icons/icon.icns",
|
||||
"../../.icons/icon.ico"
|
||||
],
|
||||
"resources": [],
|
||||
"externalBin": [],
|
||||
"copyright": "",
|
||||
"category": "DeveloperTool",
|
||||
"shortDescription": "",
|
||||
"longDescription": "",
|
||||
"deb": {
|
||||
"depends": []
|
||||
},
|
||||
"macOS": {
|
||||
"frameworks": [],
|
||||
"exceptionDomain": ""
|
||||
}
|
||||
},
|
||||
"windows": [
|
||||
{
|
||||
"title": "Welcome to Tauri!",
|
||||
"width": 800,
|
||||
"height": 600,
|
||||
"resizable": true,
|
||||
"fullscreen": false
|
||||
}
|
||||
],
|
||||
"security": {
|
||||
"csp": "default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self'; connect-src ipc: http://ipc.localhost"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,48 +1,15 @@
|
||||
{
|
||||
"$schema": "../../../../core/tauri-config-schema/schema.json",
|
||||
"productName": "app",
|
||||
"version": "0.1.0",
|
||||
"identifier": "com.tauri.app",
|
||||
"build": {
|
||||
"beforeBuildCommand": "yarn build:tauri",
|
||||
"beforeDevCommand": "yarn dev:tauri",
|
||||
"devPath": "http://localhost:5173",
|
||||
"distDir": "../../build"
|
||||
"devUrl": "http://localhost:5173",
|
||||
"frontendDist": "../../build"
|
||||
},
|
||||
"package": {
|
||||
"productName": "app",
|
||||
"version": "0.1.0"
|
||||
},
|
||||
"tauri": {
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"category": "DeveloperTool",
|
||||
"copyright": "",
|
||||
"deb": {
|
||||
"depends": []
|
||||
},
|
||||
"externalBin": [],
|
||||
"icon": [
|
||||
"../../../.icons/32x32.png",
|
||||
"../../../.icons/128x128.png",
|
||||
"../../../.icons/128x128@2x.png",
|
||||
"../../../.icons/icon.icns",
|
||||
"../../../.icons/icon.ico"
|
||||
],
|
||||
"identifier": "com.tauri.app",
|
||||
"longDescription": "",
|
||||
"macOS": {
|
||||
"entitlements": null,
|
||||
"exceptionDomain": "",
|
||||
"frameworks": [],
|
||||
"providerShortName": null,
|
||||
"signingIdentity": null
|
||||
},
|
||||
"resources": [],
|
||||
"shortDescription": "",
|
||||
"targets": "all",
|
||||
"windows": {
|
||||
"certificateThumbprint": null,
|
||||
"digestAlgorithm": "sha256",
|
||||
"timestampUrl": ""
|
||||
}
|
||||
},
|
||||
"app": {
|
||||
"security": {
|
||||
"csp": null
|
||||
},
|
||||
@@ -55,5 +22,16 @@
|
||||
"width": 800
|
||||
}
|
||||
]
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"icon": [
|
||||
"../../../.icons/32x32.png",
|
||||
"../../../.icons/128x128.png",
|
||||
"../../../.icons/128x128@2x.png",
|
||||
"../../../.icons/icon.icns",
|
||||
"../../../.icons/icon.ico"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,49 +1,12 @@
|
||||
{
|
||||
"$schema": "../../../core/tauri-config-schema/schema.json",
|
||||
"productName": "workspace",
|
||||
"version": "0.1.0",
|
||||
"identifier": "com.tauri.workspace",
|
||||
"build": {
|
||||
"distDir": [
|
||||
"../index.html"
|
||||
],
|
||||
"devPath": [
|
||||
"../index.html"
|
||||
]
|
||||
"frontendDist": ["../index.html"]
|
||||
},
|
||||
"package": {
|
||||
"productName": "workspace"
|
||||
},
|
||||
"tauri": {
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"category": "DeveloperTool",
|
||||
"copyright": "",
|
||||
"deb": {
|
||||
"depends": []
|
||||
},
|
||||
"externalBin": [],
|
||||
"icon": [
|
||||
"../../.icons/32x32.png",
|
||||
"../../.icons/128x128.png",
|
||||
"../../.icons/128x128@2x.png",
|
||||
"../../.icons/icon.icns",
|
||||
"../../.icons/icon.ico"
|
||||
],
|
||||
"identifier": "com.tauri.workspace",
|
||||
"longDescription": "",
|
||||
"macOS": {
|
||||
"entitlements": null,
|
||||
"exceptionDomain": "",
|
||||
"frameworks": [],
|
||||
"providerShortName": null,
|
||||
"signingIdentity": null
|
||||
},
|
||||
"resources": [],
|
||||
"shortDescription": "",
|
||||
"targets": "all",
|
||||
"windows": {
|
||||
"certificateThumbprint": null,
|
||||
"digestAlgorithm": "sha256",
|
||||
"timestampUrl": ""
|
||||
}
|
||||
},
|
||||
"app": {
|
||||
"security": {
|
||||
"csp": null
|
||||
},
|
||||
@@ -56,5 +19,16 @@
|
||||
"width": 800
|
||||
}
|
||||
]
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"icon": [
|
||||
"../../.icons/32x32.png",
|
||||
"../../.icons/128x128.png",
|
||||
"../../.icons/128x128@2x.png",
|
||||
"../../.icons/icon.icns",
|
||||
"../../.icons/icon.ico"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
/**
|
||||
* Invoke your custom commands.
|
||||
*
|
||||
* This package is also accessible with `window.__TAURI__.tauri` when [`build.withGlobalTauri`](https://tauri.app/v1/api/config/#buildconfig.withglobaltauri) in `tauri.conf.json` is set to `true`.
|
||||
* This package is also accessible with `window.__TAURI__.tauri` when [`app.withGlobalTauri`](https://tauri.app/v1/api/config/#appconfig.withglobaltauri) in `tauri.conf.json` is set to `true`.
|
||||
* @module
|
||||
*/
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
/**
|
||||
* The event system allows you to emit events to the backend and listen to events from it.
|
||||
*
|
||||
* This package is also accessible with `window.__TAURI__.event` when [`build.withGlobalTauri`](https://tauri.app/v1/api/config/#buildconfig.withglobaltauri) in `tauri.conf.json` is set to `true`.
|
||||
* This package is also accessible with `window.__TAURI__.event` when [`app.withGlobalTauri`](https://tauri.app/v1/api/config/#appconfig.withglobaltauri) in `tauri.conf.json` is set to `true`.
|
||||
* @module
|
||||
*/
|
||||
|
||||
|
||||
@@ -12,6 +12,6 @@ export * from './menu/predefinedMenuItem'
|
||||
/**
|
||||
* Menu types and utilities.
|
||||
*
|
||||
* This package is also accessible with `window.__TAURI__.menu` when [`build.withGlobalTauri`](https://tauri.app/v1/api/config/#buildconfig.withglobaltauri) in `tauri.conf.json` is set to `true`.
|
||||
* This package is also accessible with `window.__TAURI__.menu` when [`app.withGlobalTauri`](https://tauri.app/v1/api/config/#appconfig.withglobaltauri) in `tauri.conf.json` is set to `true`.
|
||||
* @module
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
/**
|
||||
* The path module provides utilities for working with file and directory paths.
|
||||
*
|
||||
* 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`.
|
||||
* This package is also accessible with `window.__TAURI__.path` when [`app.withGlobalTauri`](https://tauri.app/v1/api/config/#appconfig.withglobaltauri) in `tauri.conf.json` is set to `true`.
|
||||
*
|
||||
* It is recommended to allowlist only the APIs you use for optimal bundle size and security.
|
||||
* @module
|
||||
@@ -423,7 +423,7 @@ async function resourceDir(): Promise<string> {
|
||||
* ```
|
||||
*
|
||||
* @param resourcePath The path to the resource.
|
||||
* Must follow the same syntax as defined in `tauri.conf.json > tauri > bundle > resources`, i.e. keeping subfolders and parent dir components (`../`).
|
||||
* Must follow the same syntax as defined in `tauri.conf.json > bundle > resources`, i.e. keeping subfolders and parent dir components (`../`).
|
||||
* @returns The full path to the resource.
|
||||
*
|
||||
* @since 1.0.0
|
||||
|
||||
@@ -38,7 +38,7 @@ export interface TrayIconEvent {
|
||||
/**
|
||||
* Tray icon types and utilities.
|
||||
*
|
||||
* This package is also accessible with `window.__TAURI__.tray` when [`build.withGlobalTauri`](https://tauri.app/v1/api/config/#buildconfig.withglobaltauri) in `tauri.conf.json` is set to `true`.
|
||||
* This package is also accessible with `window.__TAURI__.tray` when [`app.withGlobalTauri`](https://tauri.app/v1/api/config/#appconfig.withglobaltauri) in `tauri.conf.json` is set to `true`.
|
||||
* @module
|
||||
*/
|
||||
|
||||
|
||||
@@ -765,7 +765,7 @@ interface WebviewOptions {
|
||||
height: number
|
||||
/**
|
||||
* Whether the webview is transparent or not.
|
||||
* Note that on `macOS` this requires the `macos-private-api` feature flag, enabled under `tauri.conf.json > tauri > macOSPrivateApi`.
|
||||
* Note that on `macOS` this requires the `macos-private-api` feature flag, enabled under `tauri.conf.json > app > macOSPrivateApi`.
|
||||
* WARNING: Using private APIs on `macOS` prevents your application from being accepted to the `App Store`.
|
||||
*/
|
||||
transparent?: boolean
|
||||
|
||||
@@ -2018,7 +2018,7 @@ interface WindowOptions {
|
||||
focus?: boolean
|
||||
/**
|
||||
* Whether the window is transparent or not.
|
||||
* Note that on `macOS` this requires the `macos-private-api` feature flag, enabled under `tauri.conf.json > tauri > macOSPrivateApi`.
|
||||
* Note that on `macOS` this requires the `macos-private-api` feature flag, enabled under `tauri.conf.json > app > macOSPrivateApi`.
|
||||
* WARNING: Using private APIs on `macOS` prevents your application from being accepted to the `App Store`.
|
||||
*/
|
||||
transparent?: boolean
|
||||
|
||||
@@ -1,38 +1,11 @@
|
||||
{
|
||||
"$schema": "../../../../../core/tauri-config-schema/schema.json",
|
||||
"identifier": "com.tauri.dev",
|
||||
"build": {
|
||||
"distDir": "../public",
|
||||
"devPath": "../public",
|
||||
"beforeDevCommand": "",
|
||||
"beforeBuildCommand": "",
|
||||
"withGlobalTauri": true
|
||||
"frontendDist": "../public"
|
||||
},
|
||||
"tauri": {
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"identifier": "com.tauri.dev",
|
||||
"icon": [
|
||||
"../../../../../examples/.icons/32x32.png",
|
||||
"../../../../../examples/.icons/128x128.png",
|
||||
"../../../../../examples/.icons/128x128@2x.png",
|
||||
"../../../../../examples/.icons/icon.icns",
|
||||
"../../../../../examples/.icons/icon.ico"
|
||||
],
|
||||
"resources": [],
|
||||
"externalBin": [],
|
||||
"copyright": "",
|
||||
"category": "DeveloperTool",
|
||||
"shortDescription": "",
|
||||
"longDescription": "",
|
||||
"deb": {
|
||||
"depends": []
|
||||
},
|
||||
"macOS": {
|
||||
"frameworks": [],
|
||||
"exceptionDomain": ""
|
||||
}
|
||||
},
|
||||
"app": {
|
||||
"withGlobalTauri": true,
|
||||
"windows": [
|
||||
{
|
||||
"title": "Welcome to Tauri!",
|
||||
@@ -45,5 +18,16 @@
|
||||
"security": {
|
||||
"csp": "default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self'; connect-src ipc: http://ipc.localhost"
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"icon": [
|
||||
"../../../../../examples/.icons/32x32.png",
|
||||
"../../../../../examples/.icons/128x128.png",
|
||||
"../../../../../examples/.icons/128x128@2x.png",
|
||||
"../../../../../examples/.icons/icon.icns",
|
||||
"../../../../../examples/.icons/icon.ico"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,38 +1,11 @@
|
||||
{
|
||||
"$schema": "../../../../../core/tauri-config-schema/schema.json",
|
||||
"identifier": "com.tauri.dev",
|
||||
"build": {
|
||||
"distDir": "../public",
|
||||
"devPath": "../public",
|
||||
"beforeDevCommand": "",
|
||||
"beforeBuildCommand": "",
|
||||
"withGlobalTauri": true
|
||||
"frontendDist": "../public"
|
||||
},
|
||||
"tauri": {
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"identifier": "com.tauri.dev",
|
||||
"icon": [
|
||||
"../../../../../examples/.icons/32x32.png",
|
||||
"../../../../../examples/.icons/128x128.png",
|
||||
"../../../../../examples/.icons/128x128@2x.png",
|
||||
"../../../../../examples/.icons/icon.icns",
|
||||
"../../../../../examples/.icons/icon.ico"
|
||||
],
|
||||
"resources": [],
|
||||
"externalBin": [],
|
||||
"copyright": "",
|
||||
"category": "DeveloperTool",
|
||||
"shortDescription": "",
|
||||
"longDescription": "",
|
||||
"deb": {
|
||||
"depends": []
|
||||
},
|
||||
"macOS": {
|
||||
"frameworks": [],
|
||||
"exceptionDomain": ""
|
||||
}
|
||||
},
|
||||
"app": {
|
||||
"withGlobalTauri": true,
|
||||
"windows": [
|
||||
{
|
||||
"title": "Welcome to Tauri!",
|
||||
@@ -45,5 +18,16 @@
|
||||
"security": {
|
||||
"csp": "default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self'; connect-src ipc: http://ipc.localhost"
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"icon": [
|
||||
"../../../../../examples/.icons/32x32.png",
|
||||
"../../../../../examples/.icons/128x128.png",
|
||||
"../../../../../examples/.icons/128x128@2x.png",
|
||||
"../../../../../examples/.icons/icon.icns",
|
||||
"../../../../../examples/.icons/icon.ico"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,38 +1,13 @@
|
||||
{
|
||||
"$schema": "../../../../../core/tauri-config-schema/schema.json",
|
||||
"identifier": "com.tauri.dev",
|
||||
"build": {
|
||||
"distDir": "../public",
|
||||
"devPath": "../public",
|
||||
"frontendDist": "../public",
|
||||
"beforeDevCommand": "",
|
||||
"beforeBuildCommand": "",
|
||||
"withGlobalTauri": true
|
||||
"beforeBuildCommand": ""
|
||||
},
|
||||
"tauri": {
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"identifier": "com.tauri.dev",
|
||||
"icon": [
|
||||
"../../../../../examples/.icons/32x32.png",
|
||||
"../../../../../examples/.icons/128x128.png",
|
||||
"../../../../../examples/.icons/128x128@2x.png",
|
||||
"../../../../../examples/.icons/icon.icns",
|
||||
"../../../../../examples/.icons/icon.ico"
|
||||
],
|
||||
"resources": [],
|
||||
"externalBin": [],
|
||||
"copyright": "",
|
||||
"category": "DeveloperTool",
|
||||
"shortDescription": "",
|
||||
"longDescription": "",
|
||||
"deb": {
|
||||
"depends": []
|
||||
},
|
||||
"macOS": {
|
||||
"frameworks": [],
|
||||
"exceptionDomain": ""
|
||||
}
|
||||
},
|
||||
"app": {
|
||||
"withGlobalTauri": true,
|
||||
"windows": [
|
||||
{
|
||||
"title": "Welcome to Tauri!",
|
||||
@@ -45,5 +20,16 @@
|
||||
"security": {
|
||||
"csp": "default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self'; connect-src ipc: http://ipc.localhost"
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"icon": [
|
||||
"../../../../../examples/.icons/32x32.png",
|
||||
"../../../../../examples/.icons/128x128.png",
|
||||
"../../../../../examples/.icons/128x128@2x.png",
|
||||
"../../../../../examples/.icons/icon.icns",
|
||||
"../../../../../examples/.icons/icon.ico"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ This is a fork of the awesome [cargo-bundle](https://github.com/burtonageo/cargo
|
||||
|
||||
## Configuration
|
||||
|
||||
Tauri automatically loads configurations from the `tauri.conf.json > tauri > bundle` object, but this library doesn't rely on it and can be used by non-Tauri apps.
|
||||
Tauri automatically loads configurations from the `tauri.conf.json > bundle` object, but this library doesn't rely on it and can be used by non-Tauri apps.
|
||||
|
||||
### General settings
|
||||
|
||||
@@ -80,35 +80,32 @@ These settings are used only when bundling `app` and `dmg` packages.
|
||||
|
||||
```json
|
||||
{
|
||||
"package": {
|
||||
"productName": "Your Awesome App",
|
||||
"version": "0.1.0"
|
||||
},
|
||||
"tauri": {
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"identifier": "com.my.app",
|
||||
"shortDescription": "",
|
||||
"longDescription": "",
|
||||
"copyright": "Copyright (c) You 2021. All rights reserved.",
|
||||
"icon": [
|
||||
"icons/32x32.png",
|
||||
"icons/128x128.png",
|
||||
"icons/128x128@2x.png",
|
||||
"icons/icon.icns",
|
||||
"icons/icon.ico"
|
||||
],
|
||||
"resources": ["./assets/**/*.png"],
|
||||
"deb": {
|
||||
"depends": ["debian-dependency1", "debian-dependency2"]
|
||||
},
|
||||
"macOS": {
|
||||
"frameworks": [],
|
||||
"minimumSystemVersion": "10.11",
|
||||
"license": "./LICENSE"
|
||||
},
|
||||
"externalBin": ["./sidecar-app"]
|
||||
}
|
||||
"productName": "Your Awesome App",
|
||||
"version": "0.1.0",
|
||||
"identifier": "com.my.app",
|
||||
"app": { },
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"shortDescription": "",
|
||||
"longDescription": "",
|
||||
"copyright": "Copyright (c) You 2021. All rights reserved.",
|
||||
"icon": [
|
||||
"icons/32x32.png",
|
||||
"icons/128x128.png",
|
||||
"icons/128x128@2x.png",
|
||||
"icons/icon.icns",
|
||||
"icons/icon.ico"
|
||||
],
|
||||
"resources": ["./assets/**/*.png"],
|
||||
"deb": {
|
||||
"depends": ["debian-dependency1", "debian-dependency2"]
|
||||
},
|
||||
"macOS": {
|
||||
"frameworks": [],
|
||||
"minimumSystemVersion": "10.11",
|
||||
"license": "./LICENSE"
|
||||
},
|
||||
"externalBin": ["./sidecar-app"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -6,11 +6,10 @@
|
||||
use log::debug;
|
||||
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
ffi::OsStr,
|
||||
fs::{self, File},
|
||||
io::{self, BufRead, BufReader, BufWriter},
|
||||
path::{Path, PathBuf},
|
||||
path::Path,
|
||||
process::{Command, ExitStatus, Output, Stdio},
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
@@ -136,8 +135,15 @@ pub fn copy_dir(from: &Path, to: &Path) -> crate::Result<()> {
|
||||
///
|
||||
/// Expects a HashMap of PathBuf entries, representing destination and source paths,
|
||||
/// and also a path of a directory. The files will be stored with respect to this directory.
|
||||
#[cfg(any(
|
||||
target_os = "linux",
|
||||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
))]
|
||||
pub fn copy_custom_files(
|
||||
files_map: &HashMap<PathBuf, PathBuf>,
|
||||
files_map: &std::collections::HashMap<std::path::PathBuf, std::path::PathBuf>,
|
||||
data_dir: &Path,
|
||||
) -> crate::Result<()> {
|
||||
for (pkg_path, path) in files_map.iter() {
|
||||
|
||||
@@ -29,13 +29,6 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
|
||||
other => other,
|
||||
};
|
||||
|
||||
let license = settings
|
||||
.rpm()
|
||||
.license
|
||||
.as_deref()
|
||||
.or_else(|| settings.license())
|
||||
.unwrap_or_default();
|
||||
|
||||
let summary = settings.short_description().trim();
|
||||
|
||||
let package_base_name = format!("{name}-{version}-{release}.{arch}");
|
||||
@@ -52,7 +45,11 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
|
||||
|
||||
info!(action = "Bundling"; "{} ({})", package_name, package_path.display());
|
||||
|
||||
let mut builder = rpm::PackageBuilder::new(name, version, license, arch, summary)
|
||||
let license = settings
|
||||
.license_file()
|
||||
.map(|l| std::fs::read_to_string(l).expect("failed to read license"))
|
||||
.unwrap_or_default();
|
||||
let mut builder = rpm::PackageBuilder::new(name, version, &license, arch, summary)
|
||||
.epoch(epoch)
|
||||
.release(release);
|
||||
|
||||
@@ -134,9 +131,9 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
|
||||
}
|
||||
}
|
||||
|
||||
let pkg = if let Ok(raw_secret_key) = env::var("RPM_SIGN_KEY") {
|
||||
let pkg = if let Ok(raw_secret_key) = env::var("TAURI_SIGNING_RPM_KEY") {
|
||||
let mut signer = pgp::Signer::load_from_asc(&raw_secret_key)?;
|
||||
if let Ok(passphrase) = env::var("RPM_SIGN_KEY_PASSPHRASE") {
|
||||
if let Ok(passphrase) = env::var("TAURI_SIGNING_RPM_KEY_PASSPHRASE") {
|
||||
signer = signer.with_key_passphrase(passphrase);
|
||||
}
|
||||
builder.build_and_sign(signer)?
|
||||
|
||||
@@ -156,7 +156,7 @@ pub fn bundle_project(settings: &Settings, bundles: &[Bundle]) -> crate::Result<
|
||||
bundle_dmg_cmd.arg(icon);
|
||||
}
|
||||
|
||||
let license_path = if let Some(license_path) = &settings.macos().license {
|
||||
let license_path = if let Some(license_path) = settings.license_file() {
|
||||
Some(env::current_dir()?.join(license_path))
|
||||
} else {
|
||||
None
|
||||
|
||||
@@ -149,8 +149,6 @@ pub struct PackageSettings {
|
||||
pub homepage: Option<String>,
|
||||
/// the package's authors.
|
||||
pub authors: Option<Vec<String>>,
|
||||
/// the package's license.
|
||||
pub license: Option<String>,
|
||||
/// the default binary to run.
|
||||
pub default_run: Option<String>,
|
||||
}
|
||||
@@ -158,8 +156,6 @@ pub struct PackageSettings {
|
||||
/// The updater settings.
|
||||
#[derive(Debug, Default, Clone)]
|
||||
pub struct UpdaterSettings {
|
||||
/// Whether the updater is active or not.
|
||||
pub active: bool,
|
||||
/// Signature public key.
|
||||
pub pubkey: String,
|
||||
/// Args to pass to `msiexec.exe` to run the updater on Windows.
|
||||
@@ -196,8 +192,6 @@ pub struct AppImageSettings {
|
||||
/// The RPM bundle settings.
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct RpmSettings {
|
||||
/// The name of the package's license.
|
||||
pub license: Option<String>,
|
||||
/// The list of RPM dependencies your application relies on.
|
||||
pub depends: Option<Vec<String>>,
|
||||
/// The RPM release tag.
|
||||
@@ -271,9 +265,6 @@ pub struct MacOsSettings {
|
||||
/// A version string indicating the minimum MacOS version that the bundled app supports (e.g. `"10.11"`).
|
||||
/// If you are using this config field, you may also want have your `build.rs` script emit `cargo:rustc-env=MACOSX_DEPLOYMENT_TARGET=10.11`.
|
||||
pub minimum_system_version: Option<String>,
|
||||
/// The path to the LICENSE file for macOS apps.
|
||||
/// Currently only used by the dmg bundle.
|
||||
pub license: Option<String>,
|
||||
/// The exception domain to use on the macOS .app bundle.
|
||||
///
|
||||
/// This allows communication to the outside world e.g. a web server you're shipping.
|
||||
@@ -327,8 +318,6 @@ pub struct WixSettings {
|
||||
pub merge_refs: Vec<String>,
|
||||
/// Disables the Webview2 runtime installation after app install. Will be removed in v2, use [`WindowsSettings::webview_install_mode`] instead.
|
||||
pub skip_webview_install: bool,
|
||||
/// The path to the LICENSE file.
|
||||
pub license: Option<PathBuf>,
|
||||
/// Create an elevated update task within Windows Task Scheduler.
|
||||
pub enable_elevated_update_task: bool,
|
||||
/// Path to a bitmap file to use as the installation user interface banner.
|
||||
@@ -350,8 +339,6 @@ pub struct WixSettings {
|
||||
pub struct NsisSettings {
|
||||
/// A custom .nsi template to use.
|
||||
pub template: Option<PathBuf>,
|
||||
/// 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.
|
||||
@@ -459,6 +446,11 @@ pub struct BundleSettings {
|
||||
pub resources_map: Option<HashMap<String, String>>,
|
||||
/// the app's copyright.
|
||||
pub copyright: Option<String>,
|
||||
/// The package's license identifier to be included in the appropriate bundles.
|
||||
/// If not set, defaults to the license from the Cargo.toml file.
|
||||
pub license: Option<String>,
|
||||
/// The path to the license file to be included in the appropriate bundles.
|
||||
pub license_file: Option<PathBuf>,
|
||||
/// the app's category.
|
||||
pub category: Option<AppCategory>,
|
||||
/// the file associations
|
||||
@@ -767,9 +759,8 @@ impl Settings {
|
||||
}
|
||||
};
|
||||
|
||||
// add updater if needed
|
||||
if self.is_update_enabled() {
|
||||
platform_types.push(PackageType::Updater)
|
||||
platform_types.push(PackageType::Updater);
|
||||
}
|
||||
|
||||
if let Some(package_types) = &self.package_types {
|
||||
@@ -895,9 +886,17 @@ impl Settings {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the package's license.
|
||||
pub fn license(&self) -> Option<&str> {
|
||||
self.package.license.as_deref()
|
||||
/// Returns the bundle license file.
|
||||
pub fn license_file(&self) -> Option<PathBuf> {
|
||||
self.bundle_settings.license_file.clone().or_else(|| {
|
||||
self.bundle_settings.license.as_deref().map(|l| {
|
||||
let p = self
|
||||
.project_out_directory()
|
||||
.join(format!("{}-license", self.bundle_identifier()));
|
||||
std::fs::write(&p, l).expect("failed to write license to a temp file");
|
||||
p
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns the package's homepage URL, defaulting to "" if not defined.
|
||||
@@ -972,9 +971,11 @@ impl Settings {
|
||||
|
||||
/// Is update enabled
|
||||
pub fn is_update_enabled(&self) -> bool {
|
||||
match &self.bundle_settings.updater {
|
||||
Some(val) => val.active,
|
||||
None => false,
|
||||
}
|
||||
self
|
||||
.bundle_settings
|
||||
.updater
|
||||
.as_ref()
|
||||
.map(|u| !u.pubkey.is_empty())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -485,33 +485,31 @@ pub fn build_wix_app_installer(
|
||||
}
|
||||
}
|
||||
|
||||
let language_map: HashMap<String, LanguageMetadata> =
|
||||
serde_json::from_str(include_str!("./languages.json")).unwrap();
|
||||
|
||||
if let Some(wix) = &settings.windows().wix {
|
||||
if let Some(license) = &wix.license {
|
||||
if license.ends_with(".rtf") {
|
||||
data.insert("license", to_json(license));
|
||||
} else {
|
||||
let license_contents = read_to_string(license)?;
|
||||
let license_rtf = format!(
|
||||
r#"{{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{{\fonttbl{{\f0\fnil\fcharset0 Calibri;}}}}
|
||||
if let Some(license) = settings.license_file() {
|
||||
if license.ends_with(".rtf") {
|
||||
data.insert("license", to_json(license));
|
||||
} else {
|
||||
let license_contents = read_to_string(license)?;
|
||||
let license_rtf = format!(
|
||||
r#"{{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{{\fonttbl{{\f0\fnil\fcharset0 Calibri;}}}}
|
||||
{{\*\generator Riched20 10.0.18362}}\viewkind4\uc1
|
||||
\pard\sa200\sl276\slmult1\f0\fs22\lang9 {}\par
|
||||
}}
|
||||
"#,
|
||||
license_contents.replace('\n', "\\par ")
|
||||
);
|
||||
let rtf_output_path = settings
|
||||
.project_out_directory()
|
||||
.join("wix")
|
||||
.join("LICENSE.rtf");
|
||||
std::fs::write(&rtf_output_path, license_rtf)?;
|
||||
data.insert("license", to_json(rtf_output_path));
|
||||
}
|
||||
"#,
|
||||
license_contents.replace('\n', "\\par ")
|
||||
);
|
||||
let rtf_output_path = settings
|
||||
.project_out_directory()
|
||||
.join("wix")
|
||||
.join("LICENSE.rtf");
|
||||
std::fs::write(&rtf_output_path, license_rtf)?;
|
||||
data.insert("license", to_json(rtf_output_path));
|
||||
}
|
||||
}
|
||||
|
||||
let language_map: HashMap<String, LanguageMetadata> =
|
||||
serde_json::from_str(include_str!("./languages.json")).unwrap();
|
||||
|
||||
let configured_languages = settings
|
||||
.windows()
|
||||
.wix
|
||||
|
||||
@@ -211,6 +211,10 @@ fn build_nsis_app_installer(
|
||||
to_json(settings.windows().allow_downgrades),
|
||||
);
|
||||
|
||||
if let Some(license) = settings.license_file() {
|
||||
data.insert("license", to_json(dunce::canonicalize(license)?));
|
||||
}
|
||||
|
||||
let mut install_mode = NSISInstallerMode::CurrentUser;
|
||||
let mut languages = vec!["English".into()];
|
||||
let mut custom_template_path = None;
|
||||
@@ -223,9 +227,6 @@ fn build_nsis_app_installer(
|
||||
languages.clear();
|
||||
languages.extend_from_slice(langs);
|
||||
}
|
||||
if let Some(license) = &nsis.license {
|
||||
data.insert("license", to_json(dunce::canonicalize(license)?));
|
||||
}
|
||||
if let Some(installer_icon) = &nsis.installer_icon {
|
||||
data.insert(
|
||||
"installer_icon",
|
||||
@@ -270,7 +271,7 @@ fn build_nsis_app_installer(
|
||||
if let Some(data) = get_lang_data(lang, custom_language_files.as_ref())? {
|
||||
languages_data.push(data);
|
||||
} else {
|
||||
log::warn!("Custom tauri messages for {lang} are not translated.\nIf it is a valid language listed on <https://github.com/kichik/nsis/tree/9465c08046f00ccb6eda985abbdbf52c275c6c4d/Contrib/Language%20files>, please open a Tauri feature request\n or you can provide a custom language file for it in `tauri.conf.json > tauri > bundle > windows > nsis > custom_language_files`");
|
||||
log::warn!("Custom tauri messages for {lang} are not translated.\nIf it is a valid language listed on <https://github.com/kichik/nsis/tree/9465c08046f00ccb6eda985abbdbf52c275c6c4d/Contrib/Language%20files>, please open a Tauri feature request\n or you can provide a custom language file for it in `tauri.conf.json > bundle > windows > nsis > custom_language_files`");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,11 @@ These environment variables are inputs to the CLI which may have an equivalent C
|
||||
- `TAURI_CLI_NO_DEV_SERVER_WAIT` — Skip waiting for the frontend dev server to start before building the tauri application.
|
||||
- `TAURI_LINUX_AYATANA_APPINDICATOR` — Set this var to `true` or `1` to force usage of `libayatana-appindicator` for system tray on Linux.
|
||||
- `TAURI_BUNDLER_WIX_FIPS_COMPLIANT` — Specify the bundler's WiX `FipsCompliant` option.
|
||||
- `TAURI_SKIP_SIDECAR_SIGNATURE_CHECK` - Skip signing sidecars.
|
||||
- `TAURI_SIGNING_PRIVATE_KEY` — Private key used to sign your app bundles, can be either a string or a path to the file.
|
||||
- `TAURI_SIGNING_PRIVATE_KEY_PASSWORD` — The signing private key password, see `TAURI_SIGNING_PRIVATE_KEY`.
|
||||
- `TAURI_SIGNING_RPM_KEY` — The private GPG key used to sign the RPM bundle, exported to its ASCII-armored format.
|
||||
- `TAURI_SIGNING_RPM_KEY_PASSPHRASE` — The GPG key passphrase for `TAURI_SIGNING_RPM_KEY`, if needed.
|
||||
- `APPLE_CERTIFICATE` — Base64 encoded of the `.p12` certificate for code signing. To get this value, run `openssl base64 -in MyCertificate.p12 -out MyCertificate-base64.txt`.
|
||||
- `APPLE_CERTIFICATE_PASSWORD` — The password you used to export the certificate.
|
||||
- `APPLE_ID` — The Apple ID used to notarize the application. If this environment variable is provided, `APPLE_PASSWORD` and `APPLE_TEAM_ID` must also be set. Alternatively, `APPLE_API_KEY` and `APPLE_API_ISSUER` can be used to authenticate.
|
||||
@@ -26,15 +29,13 @@ These environment variables are inputs to the CLI which may have an equivalent C
|
||||
- See [creating API keys](https://developer.apple.com/documentation/appstoreconnectapi/creating_api_keys_for_app_store_connect_api) for more information.
|
||||
- `API_PRIVATE_KEYS_DIR` — Specify the directory where your AuthKey file is located. See `APPLE_API_KEY`.
|
||||
- `APPLE_API_ISSUER` — Issuer ID. Required if `APPLE_API_KEY` is specified.
|
||||
- `APPLE_API_KEY_PATH` - path to the API key `.p8` file. If not specified, the bundler searches the following directories in sequence for a private key file with the name of 'AuthKey_<api_key>.p8': './private_keys', '~/private_keys', '~/.private_keys', and '~/.appstoreconnect/private_keys'.
|
||||
- `APPLE_SIGNING_IDENTITY` — The identity used to code sign. Overwrites `tauri.conf.json > tauri > bundle > macOS > signingIdentity`.
|
||||
- `APPLE_PROVIDER_SHORT_NAME` — If your Apple ID is connected to multiple teams, you have to specify the provider short name of the team you want to use to notarize your app. Overwrites `tauri.conf.json > tauri > bundle > macOS > providerShortName`.
|
||||
- `APPLE_API_KEY_PATH` - path to the API key `.p8` file. If not specified, the bundler searches the following directories in sequence for a private key file with the name of 'AuthKey\_<api_key>.p8': './private_keys', '~/private_keys', '~/.private_keys', and '~/.appstoreconnect/private_keys'.
|
||||
- `APPLE_SIGNING_IDENTITY` — The identity used to code sign. Overwrites `tauri.conf.json > bundle > macOS > signingIdentity`.
|
||||
- `APPLE_PROVIDER_SHORT_NAME` — If your Apple ID is connected to multiple teams, you have to specify the provider short name of the team you want to use to notarize your app. Overwrites `tauri.conf.json > bundle > macOS > providerShortName`.
|
||||
- `APPLE_DEVELOPMENT_TEAM` — TODO
|
||||
- `TAURI_WEBVIEW_AUTOMATION` — Enables webview automation (Linux Only).
|
||||
- `TAURI_ANDROID_PROJECT_PATH` — Path of the tauri android project, usually will be `<project>/src-tauri/gen/android`.
|
||||
- `TAURI_IOS_PROJECT_PATH` — Path of the tauri iOS project, usually will be `<project>/src-tauri/gen/ios`.
|
||||
- `RPM_SIGN_KEY` — The private GPG key used to sign the RPM bundle, exported to its ASCII-armored format.
|
||||
- `RPM_SIGN_KEY_PASSPHRASE` — The GPG key passphrase for `RPM_SIGN_KEY`, if needed.
|
||||
|
||||
### Tauri CLI Hook Commands
|
||||
|
||||
|
||||
@@ -1,134 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<script>
|
||||
function callBackEnd(route, args) {
|
||||
console.log(route)
|
||||
console.log(args)
|
||||
window.__TAURI__.http
|
||||
.fetch('http://localhost:7000/' + route, {
|
||||
method: 'POST',
|
||||
body: window.__TAURI__.http.Body.json(args),
|
||||
responseType: window.__TAURI__.http.ResponseType.Binary
|
||||
})
|
||||
.catch(console.error)
|
||||
}
|
||||
|
||||
function reply(args) {
|
||||
return callBackEnd('reply', args)
|
||||
}
|
||||
|
||||
function sendError(error) {
|
||||
return callBackEnd('error', error)
|
||||
}
|
||||
|
||||
function testFs(dir) {
|
||||
const contents = 'TAURI E2E TEST FILE'
|
||||
const commandSuffix = dir ? 'WithDir' : ''
|
||||
|
||||
const options = {
|
||||
dir: dir || null
|
||||
}
|
||||
|
||||
return window.__TAURI__.fs
|
||||
.writeTextFile('tauri-test.txt', contents, options)
|
||||
.then(function (res) {
|
||||
reply({
|
||||
cmd: 'writeFile' + commandSuffix
|
||||
})
|
||||
return window.__TAURI__.fs
|
||||
.readTextFile('tauri-test.txt', options)
|
||||
.then(function (res) {
|
||||
if (res === contents) {
|
||||
reply({
|
||||
cmd: 'readFile' + commandSuffix
|
||||
})
|
||||
|
||||
return window.__TAURI__.fs
|
||||
.readDir('.', options)
|
||||
.then((res) => {
|
||||
reply({
|
||||
cmd: 'readDir' + commandSuffix
|
||||
})
|
||||
|
||||
return window.__TAURI__.fs
|
||||
.copyFile(
|
||||
'tauri-test.txt',
|
||||
'tauri-test-copy.txt',
|
||||
options
|
||||
)
|
||||
.then(function (res) {
|
||||
reply({
|
||||
cmd: 'copyFile' + commandSuffix
|
||||
})
|
||||
|
||||
return window.__TAURI__.fs
|
||||
.createDir('tauri-test-dir', options)
|
||||
.then(function (res) {
|
||||
reply({
|
||||
cmd: 'createDir' + commandSuffix
|
||||
})
|
||||
return window.__TAURI__.fs
|
||||
.removeDir('tauri-test-dir', options)
|
||||
.then(function (res) {
|
||||
reply({
|
||||
cmd: 'removeDir' + commandSuffix
|
||||
})
|
||||
})
|
||||
})
|
||||
.then(function (res) {
|
||||
return window.__TAURI__.fs
|
||||
.renameFile(
|
||||
'tauri-test.txt',
|
||||
'tauri.testt.txt',
|
||||
options
|
||||
)
|
||||
.then(function (res) {
|
||||
reply({
|
||||
cmd: 'renameFile' + commandSuffix
|
||||
})
|
||||
return Promise.all([
|
||||
window.__TAURI__.fs.removeFile(
|
||||
'tauri.testt.txt',
|
||||
options
|
||||
),
|
||||
window.__TAURI__.fs.removeFile(
|
||||
'tauri-test-copy.txt',
|
||||
options
|
||||
)
|
||||
]).then(function (res) {
|
||||
reply({
|
||||
cmd: 'removeFile' + commandSuffix
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
} else {
|
||||
sendError('expected "' + contents + '" found "' + res + '"')
|
||||
}
|
||||
})
|
||||
})
|
||||
.catch(sendError)
|
||||
}
|
||||
|
||||
window.__TAURI__.event.listen('reply', function (res) {
|
||||
reply({
|
||||
cmd: 'listen'
|
||||
})
|
||||
})
|
||||
window.onTauriInit = function () {
|
||||
window.__TAURI__.event.emit('hello')
|
||||
}
|
||||
|
||||
testFs(null).then(function () {
|
||||
testFs(window.__TAURI__.path.BaseDirectory.Config)
|
||||
})
|
||||
|
||||
setTimeout(function () {
|
||||
window.__TAURI__.invoke('exit')
|
||||
}, 15000)
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,57 +0,0 @@
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
const express = require('express')
|
||||
const cors = require('cors')
|
||||
const app = express()
|
||||
app.use(cors())
|
||||
app.use(express.json())
|
||||
const port = 7000
|
||||
let appPid
|
||||
|
||||
app.post('/reply', (req, res) => {
|
||||
if (req.body && req.body.msg !== 'TEST') {
|
||||
throw new Error(`unexpected reply ${JSON.stringify(req.body)}`)
|
||||
}
|
||||
console.log('App event replied')
|
||||
exit(0)
|
||||
})
|
||||
|
||||
const server = app.listen(port, () =>
|
||||
console.log(`Test listening on port ${port}!`)
|
||||
)
|
||||
|
||||
const exit = (code) => {
|
||||
server.close()
|
||||
process.kill(appPid)
|
||||
process.exit(code)
|
||||
}
|
||||
|
||||
const path = require('path')
|
||||
const dist = path.resolve(__dirname, 'dist')
|
||||
|
||||
const build = require('../tooling/cli.js/dist/api/build')
|
||||
build({
|
||||
build: {
|
||||
devPath: dist
|
||||
},
|
||||
ctx: {
|
||||
debug: true
|
||||
}
|
||||
}).then(() => {
|
||||
const spawn = require('../tooling/cli.js/dist/helpers/spawn').spawn
|
||||
const artifactPath = path.resolve(__dirname, 'src-tauri/target/debug/app')
|
||||
appPid = spawn(
|
||||
process.platform === 'win32'
|
||||
? `${artifactPath}.exe`
|
||||
: artifactPath.replace('debug/app', 'debug/./app'),
|
||||
[],
|
||||
null
|
||||
)
|
||||
|
||||
// if it didn't reply, throw an error
|
||||
setTimeout(() => {
|
||||
throw new Error("App didn't reply")
|
||||
}, 2000)
|
||||
})
|
||||
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"name": "test",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"tauri:prod": "tauri",
|
||||
"tauri:source": "node ../../../../bin/tauri",
|
||||
"tauri:source:init": "yarn tauri:source init --tauriPath ..",
|
||||
"tauri:prod:init": "yarn tauri:prod init",
|
||||
"tauri:source:dev": "yarn tauri:source dev",
|
||||
"tauri:prod:dev": "yarn tauri:prod dev",
|
||||
"tauri:source:build": "yarn tauri:source build",
|
||||
"tauri:prod:build": "yarn tauri:prod build"
|
||||
},
|
||||
"author": "",
|
||||
"license": "Apache-2.0 OR MIT",
|
||||
"dependencies": {
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.17.1"
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
/target/
|
||||
|
||||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
||||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
||||
Cargo.lock
|
||||
@@ -1,34 +0,0 @@
|
||||
workspace = { }
|
||||
|
||||
[package]
|
||||
name = "app"
|
||||
version = "0.1.0"
|
||||
description = "A Tauri App"
|
||||
authors = [ "Tauri Programme within The Commons Conservancy" ]
|
||||
license = ""
|
||||
repository = ""
|
||||
edition = "2021"
|
||||
rust-version = "1.70"
|
||||
|
||||
[package.metadata.bundle]
|
||||
identifier = "com.tauri.dev"
|
||||
icon = [
|
||||
"icons/32x32.png",
|
||||
"icons/128x128.png",
|
||||
"icons/128x128@2x.png",
|
||||
"icons/icon.icns",
|
||||
"icons/icon.ico"
|
||||
]
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { path = "../../../../../../../../core/tauri-build", features = [] }
|
||||
|
||||
[dependencies]
|
||||
serde_json = "1.0.108"
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
tauri = { path = "../../../../../../../../core/tauri", features = ["api-all"] }
|
||||
|
||||
[features]
|
||||
default = [ "custom-protocol" ]
|
||||
custom-protocol = [ "tauri/custom-protocol" ]
|
||||
@@ -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()
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.4 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 6.8 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 974 B |
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 85 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 14 KiB |
@@ -1,14 +0,0 @@
|
||||
max_width = 100
|
||||
hard_tabs = false
|
||||
tab_spaces = 2
|
||||
newline_style = "Auto"
|
||||
use_small_heuristics = "Default"
|
||||
reorder_imports = true
|
||||
reorder_modules = true
|
||||
remove_nested_parens = true
|
||||
edition = "2021"
|
||||
merge_derives = true
|
||||
use_try_shorthand = false
|
||||
use_field_init_shorthand = false
|
||||
force_explicit_abi = true
|
||||
imports_granularity = "Crate"
|
||||
@@ -1,26 +0,0 @@
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#[tauri::command(with_window)]
|
||||
fn exit(window: tauri::Window) {
|
||||
window.close().unwrap();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
tauri::Builder::default()
|
||||
.on_page_load(|window, payload| {
|
||||
if payload.event() == tauri::window::PageLoadEvent::Finished {
|
||||
let window_ = window.clone();
|
||||
window.listen("hello".into(), move |_| {
|
||||
window_
|
||||
.emit(&"reply".to_string(), Some("{ msg: 'TEST' }".to_string()))
|
||||
.unwrap();
|
||||
});
|
||||
window.eval("window.onTauriInit()").unwrap();
|
||||
}
|
||||
})
|
||||
.invoke_handler(tauri::generate_handler![exit])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error encountered while running tauri application");
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
{
|
||||
"$schema": "../../../../../../../../core/tauri-config-schema/schema.json",
|
||||
"build": {
|
||||
"devPath": "../dist",
|
||||
"distDir": "../dist",
|
||||
"withGlobalTauri": true
|
||||
},
|
||||
"tauri": {
|
||||
"bundle": {
|
||||
"icon": [
|
||||
"icons/32x32.png",
|
||||
"icons/128x128.png",
|
||||
"icons/128x128@2x.png",
|
||||
"icons/icon.icns",
|
||||
"icons/icon.ico"
|
||||
],
|
||||
"identifier": "fixture.app"
|
||||
},
|
||||
"windows": [
|
||||
{
|
||||
"title": "Fixture",
|
||||
"visible": false
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -6,19 +6,20 @@ use crate::{
|
||||
helpers::{
|
||||
app_paths::{app_dir, tauri_dir},
|
||||
command_env,
|
||||
config::{get as get_config, AppUrl, HookCommand, WebviewUrl, MERGE_CONFIG_EXTENSION_NAME},
|
||||
config::{get as get_config, FrontendDist, HookCommand, MERGE_CONFIG_EXTENSION_NAME},
|
||||
resolve_merge_config,
|
||||
updater_signature::{read_key_from_file, secret_key as updater_secret_key, sign_file},
|
||||
updater_signature::{secret_key as updater_secret_key, sign_file},
|
||||
},
|
||||
interface::{AppInterface, AppSettings, Interface},
|
||||
CommandExt, Result,
|
||||
};
|
||||
use anyhow::{bail, Context};
|
||||
use base64::Engine;
|
||||
use clap::{ArgAction, Parser};
|
||||
use clap::Parser;
|
||||
use log::{debug, error, info, warn};
|
||||
use std::{
|
||||
env::{set_current_dir, var_os},
|
||||
ffi::OsString,
|
||||
path::{Path, PathBuf},
|
||||
process::Command,
|
||||
};
|
||||
@@ -28,7 +29,7 @@ use tauri_utils::platform::Target;
|
||||
#[derive(Debug, Clone, Parser)]
|
||||
#[clap(
|
||||
about = "Build your app in release mode and generate bundles and installers",
|
||||
long_about = "Build your app in release mode and generate bundles and installers. It makes use of the `build.distDir` property from your `tauri.conf.json` file. It also runs your `build.beforeBuildCommand` which usually builds your frontend into `build.distDir`. This will also run `build.beforeBundleCommand` before generating the bundles and installers of your app."
|
||||
long_about = "Build your app in release mode and generate bundles and installers. It makes use of the `build.frontendDist` property from your `tauri.conf.json` file. It also runs your `build.beforeBuildCommand` which usually builds your frontend into `build.frontendDist`. This will also run `build.beforeBundleCommand` before generating the bundles and installers of your app."
|
||||
)]
|
||||
pub struct Options {
|
||||
/// Binary to use to build the application, defaults to `cargo`
|
||||
@@ -45,7 +46,7 @@ pub struct Options {
|
||||
#[clap(short, long)]
|
||||
pub target: Option<String>,
|
||||
/// Space or comma separated list of features to activate
|
||||
#[clap(short, long, action = ArgAction::Append, num_args(0..))]
|
||||
#[clap(short, long, value_delimiter = ',')]
|
||||
pub features: Option<Vec<String>>,
|
||||
/// Space or comma separated list of bundles to package.
|
||||
///
|
||||
@@ -53,7 +54,7 @@ pub struct Options {
|
||||
/// If `none` is specified, the bundler will be skipped.
|
||||
///
|
||||
/// Note that the `updater` bundle is not automatically added so you must specify it if the updater is enabled.
|
||||
#[clap(short, long, action = ArgAction::Append, num_args(0..))]
|
||||
#[clap(short, long, value_delimiter = ',')]
|
||||
pub bundles: Option<Vec<String>>,
|
||||
/// JSON string or path to JSON file to merge with tauri.conf.json
|
||||
#[clap(short, long)]
|
||||
@@ -97,17 +98,17 @@ pub fn command(mut options: Options, verbosity: u8) -> Result<()> {
|
||||
|
||||
let app_settings = interface.app_settings();
|
||||
|
||||
if config_.tauri.bundle.active {
|
||||
if config_.bundle.active {
|
||||
let package_types = if let Some(names) = &options.bundles {
|
||||
let mut types = vec![];
|
||||
for name in names
|
||||
.iter()
|
||||
.flat_map(|n| n.split(',').map(|s| s.to_string()).collect::<Vec<String>>())
|
||||
{
|
||||
let mut skip = false;
|
||||
for name in names {
|
||||
if name == "none" {
|
||||
skip = true;
|
||||
break;
|
||||
}
|
||||
match PackageType::from_short_name(&name) {
|
||||
|
||||
match PackageType::from_short_name(name) {
|
||||
Some(package_type) => {
|
||||
types.push(package_type);
|
||||
}
|
||||
@@ -118,9 +119,14 @@ pub fn command(mut options: Options, verbosity: u8) -> Result<()> {
|
||||
}
|
||||
}
|
||||
}
|
||||
Some(types)
|
||||
|
||||
if skip {
|
||||
None
|
||||
} else {
|
||||
Some(types)
|
||||
}
|
||||
} else {
|
||||
let targets = config_.tauri.bundle.targets.to_vec();
|
||||
let targets = config_.bundle.targets.to_vec();
|
||||
if targets.is_empty() {
|
||||
None
|
||||
} else {
|
||||
@@ -128,9 +134,21 @@ pub fn command(mut options: Options, verbosity: u8) -> Result<()> {
|
||||
}
|
||||
};
|
||||
|
||||
let updater_pub_key = config_
|
||||
.plugins
|
||||
.0
|
||||
.get("updater")
|
||||
.and_then(|k| k.get("pubkey"))
|
||||
.and_then(|v| v.as_str())
|
||||
.map(|v| v.to_string());
|
||||
if let Some(types) = &package_types {
|
||||
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.");
|
||||
if updater_pub_key
|
||||
.as_ref()
|
||||
.map(|v| !v.is_empty())
|
||||
.unwrap_or(false)
|
||||
&& !types.contains(&PackageType::Updater)
|
||||
{
|
||||
warn!("`plugins > updater > pubkey` is set, but the bundle target list does not contain `updater`, so the updater artifacts won't be generated.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +177,7 @@ pub fn command(mut options: Options, verbosity: u8) -> Result<()> {
|
||||
// set env vars used by the bundler
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
if config_.tauri.bundle.appimage.bundle_media_framework {
|
||||
if config_.bundle.linux.appimage.bundle_media_framework {
|
||||
std::env::set_var("APPIMAGE_BUNDLE_GSTREAMER", "1");
|
||||
}
|
||||
|
||||
@@ -182,52 +200,63 @@ pub fn command(mut options: Options, verbosity: u8) -> Result<()> {
|
||||
.iter()
|
||||
.filter(|bundle| bundle.package_type == PackageType::Updater)
|
||||
.collect();
|
||||
|
||||
// If updater is active and we bundled it
|
||||
if config_.tauri.bundle.updater.active && !updater_bundles.is_empty() {
|
||||
// if no password provided we use an empty string
|
||||
let password = var_os("TAURI_SIGNING_PRIVATE_KEY_PASSWORD")
|
||||
.map(|v| v.to_str().unwrap().to_string())
|
||||
.or_else(|| if ci { Some("".into()) } else { None });
|
||||
// get the private key
|
||||
let secret_key = if let Some(mut private_key) =
|
||||
var_os("TAURI_SIGNING_PRIVATE_KEY").map(|v| v.to_str().unwrap().to_string())
|
||||
{
|
||||
// check if env var points to a file..
|
||||
let pk_dir = Path::new(&private_key);
|
||||
// Check if user provided a path or a key
|
||||
// We validate if the path exist or not.
|
||||
if pk_dir.exists() {
|
||||
// read file content and use it as private key
|
||||
private_key = read_key_from_file(pk_dir)?;
|
||||
if !updater_bundles.is_empty() {
|
||||
if let Some(pubkey) = updater_pub_key {
|
||||
// get the public key
|
||||
// check if pubkey points to a file...
|
||||
let maybe_path = Path::new(&pubkey);
|
||||
let pubkey = if maybe_path.exists() {
|
||||
std::fs::read_to_string(maybe_path)?
|
||||
} else {
|
||||
pubkey
|
||||
};
|
||||
|
||||
// if no password provided we use an empty string
|
||||
let password = var_os("TAURI_SIGNING_PRIVATE_KEY_PASSWORD")
|
||||
.map(|v| v.to_str().unwrap().to_string())
|
||||
.or_else(|| if ci { Some("".into()) } else { None });
|
||||
|
||||
// get the private key
|
||||
let secret_key = match var_os("TAURI_SIGNING_PRIVATE_KEY") {
|
||||
Some(private_key) => {
|
||||
// check if private_key points to a file...
|
||||
let maybe_path = Path::new(&private_key);
|
||||
let private_key = if maybe_path.exists() {
|
||||
OsString::from(std::fs::read_to_string(maybe_path)?)
|
||||
} else {
|
||||
private_key
|
||||
};
|
||||
updater_secret_key(private_key.as_encoded_bytes(), password)
|
||||
}
|
||||
updater_secret_key(private_key, password)
|
||||
} else {
|
||||
Err(anyhow::anyhow!("A public key has been found, but no private key. Make sure to set `TAURI_SIGNING_PRIVATE_KEY` environment variable."))
|
||||
_ => Err(anyhow::anyhow!("A public key has been found, but no private key. Make sure to set `TAURI_SIGNING_PRIVATE_KEY` environment variable.")),
|
||||
}?;
|
||||
|
||||
let 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()?;
|
||||
let pubkey = base64::engine::general_purpose::STANDARD.decode(pubkey)?;
|
||||
let pub_key_decoded = String::from_utf8_lossy(&pubkey);
|
||||
let public_key =
|
||||
minisign::PublicKeyBox::from_string(&pub_key_decoded)?.into_public_key()?;
|
||||
|
||||
// make sure we have our package built
|
||||
let mut signed_paths = Vec::new();
|
||||
for elem in updater_bundles {
|
||||
// we expect to have only one path in the vec but we iter if we add
|
||||
// another type of updater package who require multiple file signature
|
||||
for path in elem.bundle_paths.iter() {
|
||||
// sign our path from environment variables
|
||||
let (signature_path, signature) = sign_file(&secret_key, path)?;
|
||||
if signature.keynum() != public_key.keynum() {
|
||||
log::warn!(
|
||||
"The updater secret key from `TAURI_PRIVATE_KEY` does not match the public key defined in `tauri.conf.json > tauri > updater > pubkey`. If you are not rotating keys, this means your configuration is wrong and won't be accepted at runtime."
|
||||
// make sure we have our package built
|
||||
let mut signed_paths = Vec::new();
|
||||
for elem in updater_bundles {
|
||||
// we expect to have only one path in the vec but we iter if we add
|
||||
// another type of updater package who require multiple file signature
|
||||
for path in elem.bundle_paths.iter() {
|
||||
// sign our path from environment variables
|
||||
let (signature_path, signature) = sign_file(&secret_key, path)?;
|
||||
if signature.keynum() != public_key.keynum() {
|
||||
log::warn!(
|
||||
"The updater secret key from `TAURI_PRIVATE_KEY` does not match the public key from `plugins > updater > pubkey`. If you are not rotating keys, this means your configuration is wrong and won't be accepted at runtime when performing update."
|
||||
);
|
||||
}
|
||||
signed_paths.push(signature_path);
|
||||
}
|
||||
signed_paths.push(signature_path);
|
||||
}
|
||||
}
|
||||
|
||||
print_signed_updater_archive(&signed_paths)?;
|
||||
print_signed_updater_archive(&signed_paths)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,24 +286,22 @@ pub fn setup(
|
||||
None => "tauri.conf.json".into(),
|
||||
};
|
||||
|
||||
if config_.tauri.bundle.identifier == "com.tauri.dev" {
|
||||
if config_.identifier == "com.tauri.dev" {
|
||||
error!(
|
||||
"You must change the bundle identifier in `{} > tauri > bundle > identifier`. The default value `com.tauri.dev` is not allowed as it must be unique across applications.",
|
||||
"You must change the bundle identifier in `{} identifier`. The default value `com.tauri.dev` is not allowed as it must be unique across applications.",
|
||||
bundle_identifier_source
|
||||
);
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
if config_
|
||||
.tauri
|
||||
.bundle
|
||||
.identifier
|
||||
.chars()
|
||||
.any(|ch| !(ch.is_alphanumeric() || ch == '-' || ch == '.'))
|
||||
{
|
||||
error!(
|
||||
"The bundle identifier \"{}\" set in `{} > tauri > bundle > identifier`. The bundle identifier string must contain only alphanumeric characters (A-Z, a-z, and 0-9), hyphens (-), and periods (.).",
|
||||
config_.tauri.bundle.identifier,
|
||||
"The bundle identifier \"{}\" set in `{} identifier`. The bundle identifier string must contain only alphanumeric characters (A-Z, a-z, and 0-9), hyphens (-), and periods (.).",
|
||||
config_.identifier,
|
||||
bundle_identifier_source
|
||||
);
|
||||
std::process::exit(1);
|
||||
@@ -284,18 +311,17 @@ pub fn setup(
|
||||
run_hook("beforeBuildCommand", before_build, interface, options.debug)?;
|
||||
}
|
||||
|
||||
if let Some(AppUrl::Url(WebviewUrl::App(web_asset_path))) = &config_.build.dist_dir {
|
||||
if let Some(FrontendDist::Dist(web_asset_path)) = &config_.build.frontend_dist {
|
||||
if !web_asset_path.exists() {
|
||||
return Err(anyhow::anyhow!(
|
||||
"Unable to find your web assets, did you forget to build your web app? Your distDir is set to \"{:?}\".",
|
||||
"Unable to find your web assets, did you forget to build your web app? Your frontendDist is set to \"{:?}\".",
|
||||
web_asset_path
|
||||
));
|
||||
}
|
||||
if web_asset_path.canonicalize()?.file_name() == Some(std::ffi::OsStr::new("src-tauri")) {
|
||||
return Err(anyhow::anyhow!(
|
||||
"The configured distDir is the `src-tauri` folder.
|
||||
Please isolate your web assets on a separate folder and update `tauri.conf.json > build > distDir`.",
|
||||
));
|
||||
"The configured frontendDist is the `src-tauri` folder. Please isolate your web assets on a separate folder and update `tauri.conf.json > build > frontendDist`.",
|
||||
));
|
||||
}
|
||||
|
||||
let mut out_folders = Vec::new();
|
||||
@@ -306,7 +332,7 @@ pub fn setup(
|
||||
}
|
||||
if !out_folders.is_empty() {
|
||||
return Err(anyhow::anyhow!(
|
||||
"The configured distDir includes the `{:?}` {}. Please isolate your web assets on a separate folder and update `tauri.conf.json > build > distDir`.",
|
||||
"The configured frontendDist includes the `{:?}` {}. Please isolate your web assets on a separate folder and update `tauri.conf.json > build > frontendDist`.",
|
||||
out_folders,
|
||||
if out_folders.len() == 1 { "folder" }else { "folders" }
|
||||
)
|
||||
|
||||
@@ -6,7 +6,7 @@ use crate::{
|
||||
helpers::{
|
||||
app_paths::{app_dir, tauri_dir},
|
||||
command_env,
|
||||
config::{get as get_config, reload as reload_config, AppUrl, BeforeDevCommand, WebviewUrl},
|
||||
config::{get as get_config, reload as reload_config, BeforeDevCommand, FrontendDist},
|
||||
resolve_merge_config,
|
||||
},
|
||||
interface::{AppInterface, DevProcess, ExitReason, Interface},
|
||||
@@ -41,7 +41,7 @@ pub const TAURI_CLI_BUILTIN_WATCHER_IGNORE_FILE: &[u8] =
|
||||
#[derive(Debug, Clone, Parser)]
|
||||
#[clap(
|
||||
about = "Run your app in development mode",
|
||||
long_about = "Run your app in development mode with hot-reloading for the Rust code. It makes use of the `build.devPath` property from your `tauri.conf.json` file. It also runs your `build.beforeDevCommand` which usually starts your frontend devServer.",
|
||||
long_about = "Run your app in development mode with hot-reloading for the Rust code. It makes use of the `build.devUrl` property from your `tauri.conf.json` file. It also runs your `build.beforeDevCommand` which usually starts your frontend devServer.",
|
||||
trailing_var_arg(true)
|
||||
)]
|
||||
pub struct Options {
|
||||
@@ -173,13 +173,13 @@ pub fn setup(
|
||||
let tauri_path = tauri_dir();
|
||||
set_current_dir(tauri_path).with_context(|| "failed to change current working directory")?;
|
||||
|
||||
let mut dev_path = config
|
||||
let mut dev_url = config
|
||||
.lock()
|
||||
.unwrap()
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.build
|
||||
.dev_path
|
||||
.dev_url
|
||||
.clone();
|
||||
|
||||
if let Some(before_dev) = config
|
||||
@@ -204,13 +204,13 @@ pub fn setup(
|
||||
if mobile {
|
||||
let local_ip_address = local_ip_address(options.force_ip_prompt).to_string();
|
||||
before_dev = before_dev.replace("$HOST", &local_ip_address);
|
||||
if let Some(AppUrl::Url(WebviewUrl::External(url))) = dev_path.as_mut() {
|
||||
if let Some(url) = &mut dev_url {
|
||||
url.set_host(Some(&local_ip_address))?;
|
||||
}
|
||||
} else {
|
||||
before_dev = before_dev.replace(
|
||||
"$HOST",
|
||||
if let Some(AppUrl::Url(WebviewUrl::External(url))) = &dev_path {
|
||||
if let Some(url) = &dev_url {
|
||||
url.host_str().unwrap_or("0.0.0.0")
|
||||
} else {
|
||||
"0.0.0.0"
|
||||
@@ -314,17 +314,25 @@ pub fn setup(
|
||||
cargo_features.extend(features.clone());
|
||||
}
|
||||
|
||||
let mut dev_path = config
|
||||
let mut dev_url = config
|
||||
.lock()
|
||||
.unwrap()
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.build
|
||||
.dev_path
|
||||
.dev_url
|
||||
.clone();
|
||||
if !options.no_dev_server {
|
||||
if let Some(AppUrl::Url(WebviewUrl::App(path))) = &dev_path {
|
||||
use crate::helpers::web_dev_server::start_dev_server;
|
||||
let frontend_dist = config
|
||||
.lock()
|
||||
.unwrap()
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.build
|
||||
.frontend_dist
|
||||
.clone();
|
||||
if !options.no_dev_server && dev_url.is_none() {
|
||||
if let Some(FrontendDist::Dist(path)) = &frontend_dist {
|
||||
use crate::helpers::web_dev_server;
|
||||
if path.exists() {
|
||||
let path = path.canonicalize()?;
|
||||
let ip = if mobile {
|
||||
@@ -332,18 +340,16 @@ pub fn setup(
|
||||
} else {
|
||||
Ipv4Addr::new(127, 0, 0, 1).into()
|
||||
};
|
||||
let server_url = start_dev_server(path, ip, options.port)?;
|
||||
let server_url = web_dev_server::start(path, ip, options.port)?;
|
||||
let server_url = format!("http://{server_url}");
|
||||
dev_path = Some(AppUrl::Url(WebviewUrl::External(
|
||||
server_url.parse().unwrap(),
|
||||
)));
|
||||
dev_url = Some(server_url.parse().unwrap());
|
||||
|
||||
if let Some(c) = &options.config {
|
||||
let mut c: tauri_utils::config::Config = serde_json::from_str(c)?;
|
||||
c.build.dev_path = dev_path.clone();
|
||||
c.build.dev_url = dev_url.clone();
|
||||
options.config = Some(serde_json::to_string(&c).unwrap());
|
||||
} else {
|
||||
options.config = Some(format!(r#"{{ "build": {{ "devPath": "{server_url}" }} }}"#))
|
||||
options.config = Some(format!(r#"{{ "build": {{ "devUrl": "{server_url}" }} }}"#))
|
||||
}
|
||||
|
||||
reload_config(options.config.as_deref())?;
|
||||
@@ -352,11 +358,11 @@ pub fn setup(
|
||||
}
|
||||
|
||||
if !options.no_dev_server_wait {
|
||||
if let Some(AppUrl::Url(WebviewUrl::External(dev_server_url))) = dev_path {
|
||||
let host = dev_server_url
|
||||
if let Some(url) = dev_url {
|
||||
let host = url
|
||||
.host()
|
||||
.unwrap_or_else(|| panic!("No host name in the URL"));
|
||||
let port = dev_server_url
|
||||
let port = url
|
||||
.port_or_known_default()
|
||||
.unwrap_or_else(|| panic!("No port number in the URL"));
|
||||
let addrs;
|
||||
@@ -388,17 +394,11 @@ pub fn setup(
|
||||
}
|
||||
|
||||
if i % 3 == 1 {
|
||||
warn!(
|
||||
"Waiting for your frontend dev server to start on {}...",
|
||||
dev_server_url
|
||||
);
|
||||
warn!("Waiting for your frontend dev server to start on {url}...",);
|
||||
}
|
||||
i += 1;
|
||||
if i == max_attempts {
|
||||
error!(
|
||||
"Could not connect to `{}` after {}s. Please make sure that is the URL to your dev server.",
|
||||
dev_server_url, i * sleep_interval.as_secs()
|
||||
);
|
||||
error!("Could not connect to `{url}` after {}s. Please make sure that is the URL to your dev server.", i * sleep_interval.as_secs());
|
||||
exit(1);
|
||||
}
|
||||
std::thread::sleep(sleep_interval);
|
||||
|
||||
@@ -51,7 +51,7 @@ impl ConfigMetadata {
|
||||
.and_then(|bundle_config| bundle_config.get("identifier"))
|
||||
.and_then(|id| id.as_str())
|
||||
{
|
||||
if identifier == self.inner.tauri.bundle.identifier {
|
||||
if identifier == self.inner.identifier {
|
||||
return Some(ext.clone());
|
||||
}
|
||||
}
|
||||
@@ -90,7 +90,6 @@ pub fn wix_settings(config: WixConfig) -> tauri_bundler::WixSettings {
|
||||
feature_refs: config.feature_refs,
|
||||
merge_refs: config.merge_refs,
|
||||
skip_webview_install: config.skip_webview_install,
|
||||
license: config.license,
|
||||
enable_elevated_update_task: config.enable_elevated_update_task,
|
||||
banner_path: config.banner_path,
|
||||
dialog_image_path: config.dialog_image_path,
|
||||
@@ -101,7 +100,6 @@ pub fn wix_settings(config: WixConfig) -> tauri_bundler::WixSettings {
|
||||
pub fn nsis_settings(config: NsisConfig) -> tauri_bundler::NsisSettings {
|
||||
tauri_bundler::NsisSettings {
|
||||
template: config.template,
|
||||
license: config.license,
|
||||
header_image: config.header_image,
|
||||
sidebar_image: config.sidebar_image,
|
||||
installer_icon: config.installer_icon,
|
||||
|
||||
@@ -21,7 +21,7 @@ pub enum Framework {
|
||||
}
|
||||
|
||||
impl Framework {
|
||||
pub fn dev_path(&self) -> String {
|
||||
pub fn dev_url(&self) -> String {
|
||||
match self {
|
||||
Self::SolidJS => "http://localhost:3000",
|
||||
Self::SolidStart => "http://localhost:3000",
|
||||
@@ -39,7 +39,7 @@ impl Framework {
|
||||
.into()
|
||||
}
|
||||
|
||||
pub fn dist_dir(&self) -> String {
|
||||
pub fn frontend_dist(&self) -> String {
|
||||
match self {
|
||||
Self::SolidJS => "../dist",
|
||||
Self::SolidStart => "../dist/public",
|
||||
|
||||
@@ -45,7 +45,7 @@ pub fn generate_key(password: Option<String>) -> crate::Result<KeyPair> {
|
||||
}
|
||||
|
||||
/// Transform a base64 String to readable string for the main signer
|
||||
pub fn decode_key(base64_key: String) -> crate::Result<String> {
|
||||
pub fn decode_key<S: AsRef<[u8]>>(base64_key: S) -> crate::Result<String> {
|
||||
let decoded_str = &base64::engine::general_purpose::STANDARD.decode(base64_key)?[..];
|
||||
Ok(String::from(str::from_utf8(decoded_str)?))
|
||||
}
|
||||
@@ -91,14 +91,6 @@ where
|
||||
Ok((fs::canonicalize(sk_path)?, fs::canonicalize(pk_path)?))
|
||||
}
|
||||
|
||||
/// Read key from file
|
||||
pub fn read_key_from_file<P>(sk_path: P) -> crate::Result<String>
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
{
|
||||
Ok(fs::read_to_string(sk_path)?)
|
||||
}
|
||||
|
||||
/// Sign files
|
||||
pub fn sign_file<P>(secret_key: &SecretKey, bin_path: P) -> crate::Result<(PathBuf, SignatureBox)>
|
||||
where
|
||||
@@ -136,7 +128,10 @@ where
|
||||
}
|
||||
|
||||
/// Gets the updater secret key from the given private key and password.
|
||||
pub fn secret_key(private_key: String, password: Option<String>) -> crate::Result<SecretKey> {
|
||||
pub fn secret_key<S: AsRef<[u8]>>(
|
||||
private_key: S,
|
||||
password: Option<String>,
|
||||
) -> crate::Result<SecretKey> {
|
||||
let decoded_secret = decode_key(private_key)?;
|
||||
let sk_box = SecretKeyBox::from_string(&decoded_secret)
|
||||
.with_context(|| "failed to load updater private key")?;
|
||||
|
||||
@@ -31,11 +31,7 @@ struct State {
|
||||
tx: Sender<()>,
|
||||
}
|
||||
|
||||
pub fn start_dev_server<P: AsRef<Path>>(
|
||||
path: P,
|
||||
ip: IpAddr,
|
||||
port: Option<u16>,
|
||||
) -> crate::Result<SocketAddr> {
|
||||
pub fn start<P: AsRef<Path>>(path: P, ip: IpAddr, port: Option<u16>) -> crate::Result<SocketAddr> {
|
||||
let serve_dir = path.as_ref().to_path_buf();
|
||||
|
||||
let (server_url_tx, server_url_rx) = std::sync::mpsc::channel();
|
||||
|
||||
@@ -17,7 +17,7 @@ pub fn items(app_dir: Option<&PathBuf>, tauri_dir: Option<&Path>) -> Vec<Section
|
||||
let config_guard = config.lock().unwrap();
|
||||
let config = config_guard.as_ref().unwrap();
|
||||
|
||||
let bundle_or_build = if config.tauri.bundle.active {
|
||||
let bundle_or_build = if config.bundle.active {
|
||||
"bundle"
|
||||
} else {
|
||||
"build"
|
||||
@@ -25,7 +25,7 @@ pub fn items(app_dir: Option<&PathBuf>, tauri_dir: Option<&Path>) -> Vec<Section
|
||||
items.push(SectionItem::new().description(format!("build-type: {bundle_or_build}")));
|
||||
|
||||
let csp = config
|
||||
.tauri
|
||||
.app
|
||||
.security
|
||||
.csp
|
||||
.clone()
|
||||
@@ -33,12 +33,12 @@ pub fn items(app_dir: Option<&PathBuf>, tauri_dir: Option<&Path>) -> Vec<Section
|
||||
.unwrap_or_else(|| "unset".to_string());
|
||||
items.push(SectionItem::new().description(format!("CSP: {csp}")));
|
||||
|
||||
if let Some(dist_dir) = &config.build.dist_dir {
|
||||
items.push(SectionItem::new().description(format!("distDir: {dist_dir}")));
|
||||
if let Some(frontend_dist) = &config.build.frontend_dist {
|
||||
items.push(SectionItem::new().description(format!("frontendDist: {frontend_dist}")));
|
||||
}
|
||||
|
||||
if let Some(dev_path) = &config.build.dev_path {
|
||||
items.push(SectionItem::new().description(format!("devPath: {dev_path}")));
|
||||
if let Some(dev_url) = &config.build.dev_url {
|
||||
items.push(SectionItem::new().description(format!("devUrl: {dev_url}")));
|
||||
}
|
||||
|
||||
if let Some(app_dir) = app_dir {
|
||||
|
||||
@@ -56,10 +56,10 @@ pub struct Options {
|
||||
window_title: Option<String>,
|
||||
/// Web assets location, relative to <project-dir>/src-tauri
|
||||
#[clap(short = 'D', long)]
|
||||
dist_dir: Option<String>,
|
||||
frontend_dist: Option<String>,
|
||||
/// Url of your dev server
|
||||
#[clap(short = 'P', long)]
|
||||
dev_path: Option<String>,
|
||||
dev_url: Option<String>,
|
||||
/// A shell command to run before `tauri dev` kicks in.
|
||||
#[clap(long)]
|
||||
before_dev_command: Option<String>,
|
||||
@@ -109,17 +109,17 @@ impl Options {
|
||||
)
|
||||
})?;
|
||||
|
||||
self.dist_dir = self.dist_dir.map(|s| Ok(Some(s))).unwrap_or_else(|| request_input(
|
||||
self.frontend_dist = self.frontend_dist.map(|s| Ok(Some(s))).unwrap_or_else(|| request_input(
|
||||
r#"Where are your web assets (HTML/CSS/JS) located, relative to the "<current dir>/src-tauri/tauri.conf.json" file that will be created?"#,
|
||||
init_defaults.framework.as_ref().map(|f| f.dist_dir()),
|
||||
init_defaults.framework.as_ref().map(|f| f.frontend_dist()),
|
||||
self.ci,
|
||||
false,
|
||||
))?;
|
||||
|
||||
self.dev_path = self.dev_path.map(|s| Ok(Some(s))).unwrap_or_else(|| {
|
||||
self.dev_url = self.dev_url.map(|s| Ok(Some(s))).unwrap_or_else(|| {
|
||||
request_input(
|
||||
"What is the url of your dev server?",
|
||||
init_defaults.framework.map(|f| f.dev_path()),
|
||||
init_defaults.framework.map(|f| f.dev_url()),
|
||||
self.ci,
|
||||
false,
|
||||
)
|
||||
@@ -190,14 +190,18 @@ pub fn command(mut options: Options) -> Result<()> {
|
||||
data.insert("tauri_dep", to_json(tauri_dep));
|
||||
data.insert("tauri_build_dep", to_json(tauri_build_dep));
|
||||
data.insert(
|
||||
"dist_dir",
|
||||
to_json(options.dist_dir.unwrap_or_else(|| "../dist".to_string())),
|
||||
);
|
||||
data.insert(
|
||||
"dev_path",
|
||||
"frontend_dist",
|
||||
to_json(
|
||||
options
|
||||
.dev_path
|
||||
.frontend_dist
|
||||
.unwrap_or_else(|| "../dist".to_string()),
|
||||
),
|
||||
);
|
||||
data.insert(
|
||||
"dev_url",
|
||||
to_json(
|
||||
options
|
||||
.dev_url
|
||||
.unwrap_or_else(|| "http://localhost:4000".to_string()),
|
||||
),
|
||||
);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user