mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-11 10:43:31 +02:00
Compare commits
5 Commits
tauri-runt
...
refactor/a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c6bb5dfd7 | ||
|
|
6f3a2b38f0 | ||
|
|
0ab2b33064 | ||
|
|
983e7800b6 | ||
|
|
be683e2ac3 |
@@ -107,7 +107,7 @@
|
||||
"pipe": true
|
||||
},
|
||||
{
|
||||
"command": "pnpm publish --access public --loglevel silly --tag next --no-git-checks",
|
||||
"command": "pnpm publish --access public --loglevel silly --no-git-checks",
|
||||
"dryRunCommand": "npm publish --dry-run --access public --no-git-checks",
|
||||
"pipe": true
|
||||
},
|
||||
|
||||
16
.changes/msrv-1.77.2.md
Normal file
16
.changes/msrv-1.77.2.md
Normal file
@@ -0,0 +1,16 @@
|
||||
---
|
||||
"tauri": patch:changes
|
||||
"tauri-utils": patch:changes
|
||||
"tauri-runtime": patch:changes
|
||||
"tauri-runtime-wry": patch:changes
|
||||
"tauri-codegen": patch:changes
|
||||
"tauri-macros": patch:changes
|
||||
"tauri-plugin": patch:changes
|
||||
"tauri-build": patch:changes
|
||||
"tauri-cli": patch:changes
|
||||
"tauri-macos-sign": patch:changes
|
||||
"tauri-bundler": patch:changes
|
||||
"tauri-driver": patch:changes
|
||||
---
|
||||
|
||||
Downgrade MSRV to 1.77.2 to support Windows.
|
||||
2
.github/workflows/publish-cli-js.yml
vendored
2
.github/workflows/publish-cli-js.yml
vendored
@@ -382,7 +382,7 @@ jobs:
|
||||
- name: Publish
|
||||
run: |
|
||||
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
|
||||
npm publish --tag next
|
||||
npm publish
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
NPM_TOKEN: ${{ secrets.ORG_NPM_TOKEN }}
|
||||
|
||||
20
.github/workflows/test-core.yml
vendored
20
.github/workflows/test-core.yml
vendored
@@ -37,35 +37,35 @@ jobs:
|
||||
- {
|
||||
target: x86_64-pc-windows-msvc,
|
||||
os: windows-latest,
|
||||
toolchain: '1.78.0',
|
||||
toolchain: '1.77.2',
|
||||
cross: false,
|
||||
command: 'test'
|
||||
}
|
||||
- {
|
||||
target: x86_64-unknown-linux-gnu,
|
||||
os: ubuntu-latest,
|
||||
toolchain: '1.78.0',
|
||||
toolchain: '1.77.2',
|
||||
cross: false,
|
||||
command: 'test'
|
||||
}
|
||||
- {
|
||||
target: aarch64-apple-darwin,
|
||||
os: macos-14,
|
||||
toolchain: '1.78.0',
|
||||
toolchain: '1.77.2',
|
||||
cross: false,
|
||||
command: 'test'
|
||||
}
|
||||
- {
|
||||
target: aarch64-apple-ios,
|
||||
os: macos-latest,
|
||||
toolchain: '1.78.0',
|
||||
toolchain: '1.77.2',
|
||||
cross: false,
|
||||
command: 'build'
|
||||
}
|
||||
- {
|
||||
target: aarch64-linux-android,
|
||||
os: ubuntu-latest,
|
||||
toolchain: '1.78.0',
|
||||
toolchain: '1.77.2',
|
||||
cross: true,
|
||||
command: 'build'
|
||||
}
|
||||
@@ -88,6 +88,16 @@ jobs:
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y webkit2gtk-4.1 libxdo-dev libayatana-appindicator3-dev
|
||||
|
||||
- name: downgrade crates with MSRV conflict
|
||||
run: |
|
||||
cargo update -p ravif --precise 0.11.5
|
||||
cargo update -p aws-config --precise 1.5.5
|
||||
cargo update -p aws-sdk-ssooidc --precise 1.40.0
|
||||
cargo update -p aws-sdk-s3 --precise 1.46.0
|
||||
cargo update -p aws-sdk-sts --precise 1.39.0
|
||||
cargo update -p aws-sdk-sso --precise 1.39.0
|
||||
cargo update -p bitstream-io --precise 2.3.0
|
||||
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
prefix-key: v2
|
||||
|
||||
34
Cargo.lock
generated
34
Cargo.lock
generated
@@ -579,9 +579,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "aws-config"
|
||||
version = "1.5.7"
|
||||
version = "1.5.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8191fb3091fa0561d1379ef80333c3c7191c6f0435d986e85821bcf7acbd1126"
|
||||
checksum = "4e95816a168520d72c0e7680c405a5a8c1fb6a035b4bc4b9d7b0de8e1a941697"
|
||||
dependencies = [
|
||||
"aws-credential-types",
|
||||
"aws-runtime",
|
||||
@@ -647,9 +647,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "aws-sdk-s3"
|
||||
version = "1.52.0"
|
||||
version = "1.46.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f571deb0a80c20d21d9f3e8418c1712af9ff4bf399d057e5549a934eca4844e2"
|
||||
checksum = "4abf69a87be33b6f125a93d5046b5f7395c26d1f449bf8d3927f5577463b6de0"
|
||||
dependencies = [
|
||||
"ahash 0.8.11",
|
||||
"aws-credential-types",
|
||||
@@ -682,9 +682,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "aws-sdk-sso"
|
||||
version = "1.44.0"
|
||||
version = "1.39.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b90cfe6504115e13c41d3ea90286ede5aa14da294f3fe077027a6e83850843c"
|
||||
checksum = "11822090cf501c316c6f75711d77b96fba30658e3867a7762e5e2f5d32d31e81"
|
||||
dependencies = [
|
||||
"aws-credential-types",
|
||||
"aws-runtime",
|
||||
@@ -704,9 +704,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "aws-sdk-ssooidc"
|
||||
version = "1.45.0"
|
||||
version = "1.40.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "167c0fad1f212952084137308359e8e4c4724d1c643038ce163f06de9662c1d0"
|
||||
checksum = "78a2a06ff89176123945d1bbe865603c4d7101bea216a550bb4d2e4e9ba74d74"
|
||||
dependencies = [
|
||||
"aws-credential-types",
|
||||
"aws-runtime",
|
||||
@@ -726,9 +726,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "aws-sdk-sts"
|
||||
version = "1.44.0"
|
||||
version = "1.39.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2cb5f98188ec1435b68097daa2a37d74b9d17c9caa799466338a8d1544e71b9d"
|
||||
checksum = "a20a91795850826a6f456f4a48eff1dfa59a0e69bdbf5b8c50518fd372106574"
|
||||
dependencies = [
|
||||
"aws-credential-types",
|
||||
"aws-runtime",
|
||||
@@ -1167,9 +1167,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "bitstream-io"
|
||||
version = "2.5.3"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b81e1519b0d82120d2fd469d5bfb2919a9361c48b02d82d04befc1cdd2002452"
|
||||
checksum = "7c12d1856e42f0d817a835fe55853957c85c8c8a470114029143d3f12671446e"
|
||||
|
||||
[[package]]
|
||||
name = "bitvec"
|
||||
@@ -4695,7 +4695,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"windows-targets 0.52.6",
|
||||
"windows-targets 0.48.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4879,6 +4879,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ea1f30cedd69f0a2954655f7188c6a834246d2bcf1e315e2ac40c4b24dc9519"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"rayon",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -6851,15 +6852,16 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ravif"
|
||||
version = "0.11.10"
|
||||
version = "0.11.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a8f0bfd976333248de2078d350bfdf182ff96e168a24d23d2436cef320dd4bdd"
|
||||
checksum = "bc13288f5ab39e6d7c9d501759712e6969fcc9734220846fc9ed26cae2cc4234"
|
||||
dependencies = [
|
||||
"avif-serialize",
|
||||
"imgref",
|
||||
"loop9",
|
||||
"quick-error 2.0.1",
|
||||
"rav1e",
|
||||
"rayon",
|
||||
"rgb",
|
||||
]
|
||||
|
||||
@@ -10465,7 +10467,7 @@ version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
||||
dependencies = [
|
||||
"windows-sys 0.59.0",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -43,7 +43,7 @@ repository = "https://github.com/tauri-apps/tauri"
|
||||
categories = ["gui", "web-programming"]
|
||||
license = "Apache-2.0 OR MIT"
|
||||
edition = "2021"
|
||||
rust-version = "1.78"
|
||||
rust-version = "1.77.2"
|
||||
|
||||
# default to small, optimized workspace release binaries
|
||||
[profile.release]
|
||||
|
||||
@@ -3,7 +3,7 @@ name = "tauri_bench"
|
||||
version = "0.1.0"
|
||||
authors = ["Tauri Programme within The Commons Conservancy"]
|
||||
edition = "2021"
|
||||
rust-version = "1.78"
|
||||
rust-version = "1.77.2"
|
||||
license = "Apache-2.0 OR MIT"
|
||||
description = "Cross-platform WebView rendering library"
|
||||
repository = "https://github.com/tauri-apps/wry"
|
||||
|
||||
@@ -3,7 +3,7 @@ name = "bench_cpu_intensive"
|
||||
version = "0.1.0"
|
||||
description = "A very simple Tauri Application"
|
||||
edition = "2021"
|
||||
rust-version = "1.78"
|
||||
rust-version = "1.77.2"
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { path = "../../../../crates/tauri-build", features = [
|
||||
|
||||
@@ -3,7 +3,7 @@ name = "bench_files_transfer"
|
||||
version = "0.1.0"
|
||||
description = "A very simple Tauri Application"
|
||||
edition = "2021"
|
||||
rust-version = "1.78"
|
||||
rust-version = "1.77.2"
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { path = "../../../../crates/tauri-build", features = [
|
||||
|
||||
@@ -3,7 +3,7 @@ name = "bench_helloworld"
|
||||
version = "0.1.0"
|
||||
description = "A very simple Tauri Application"
|
||||
edition = "2021"
|
||||
rust-version = "1.78"
|
||||
rust-version = "1.77.2"
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { path = "../../../../crates/tauri-build", features = [
|
||||
|
||||
@@ -11,7 +11,7 @@ keywords = ["bundle", "cargo", "tauri"]
|
||||
repository = "https://github.com/tauri-apps/tauri"
|
||||
description = "Wrap rust executables in OS-specific app bundles for Tauri"
|
||||
edition = "2021"
|
||||
rust-version = "1.78"
|
||||
rust-version = "1.77.2"
|
||||
exclude = ["CHANGELOG.md", "/target", "rustfmt.toml"]
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -3,7 +3,7 @@ name = "tauri-cli"
|
||||
version = "2.0.0"
|
||||
authors = ["Tauri Programme within The Commons Conservancy"]
|
||||
edition = "2021"
|
||||
rust-version = "1.78"
|
||||
rust-version = "1.77.2"
|
||||
categories = ["gui", "web-programming"]
|
||||
license = "Apache-2.0 OR MIT"
|
||||
homepage = "https://tauri.app"
|
||||
|
||||
@@ -103,7 +103,7 @@ impl From<Options> for DevOptions {
|
||||
no_dev_server: options.no_dev_server,
|
||||
port: options.port,
|
||||
release_mode: options.release_mode,
|
||||
host: None,
|
||||
host: options.host.unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -197,12 +197,7 @@ fn run_dev(
|
||||
noise_level: NoiseLevel,
|
||||
) -> Result<()> {
|
||||
// when running on an actual device we must use the network IP
|
||||
if options.host.is_some()
|
||||
|| device
|
||||
.as_ref()
|
||||
.map(|device| !device.serial_no().starts_with("emulator"))
|
||||
.unwrap_or(false)
|
||||
{
|
||||
if options.host.is_some() {
|
||||
use_network_address_for_dev_url(&tauri_config, &mut dev_options, options.force_ip_prompt)?;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ authors = ["you"]
|
||||
license = ""
|
||||
repository = ""
|
||||
edition = "2021"
|
||||
rust-version = "1.78"
|
||||
rust-version = "1.77.2"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ version = "0.1.0"
|
||||
authors = [ "{{ author }}" ]
|
||||
description = ""
|
||||
edition = "2021"
|
||||
rust-version = "1.78"
|
||||
rust-version = "1.77.2"
|
||||
exclude = ["/examples", "/webview-dist", "/webview-src", "/node_modules"]
|
||||
links = "tauri-plugin-{{ plugin_name }}"
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ authors = ["you"]
|
||||
license = ""
|
||||
repository = ""
|
||||
edition = "2021"
|
||||
rust-version = "1.78"
|
||||
rust-version = "1.77.2"
|
||||
|
||||
[lib]
|
||||
name = "tauri_app_lib"
|
||||
|
||||
@@ -6,7 +6,7 @@ authors = ["you"]
|
||||
license = ""
|
||||
repository = ""
|
||||
edition = "2021"
|
||||
rust-version = "1.78"
|
||||
rust-version = "1.77.2"
|
||||
|
||||
[lib]
|
||||
name = "tauri_app_lib"
|
||||
|
||||
@@ -9,7 +9,7 @@ repository = "https://github.com/tauri-apps/tauri"
|
||||
description = "Webdriver server for Tauri applications"
|
||||
readme = "README.md"
|
||||
edition = "2021"
|
||||
rust-version = "1.78"
|
||||
rust-version = "1.77.2"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1"
|
||||
|
||||
@@ -7,7 +7,7 @@ keywords = ["codesign", "signing", "macos", "ios", "tauri"]
|
||||
repository = "https://github.com/tauri-apps/tauri"
|
||||
description = "Code signing utilities for macOS and iOS apps"
|
||||
edition = "2021"
|
||||
rust-version = "1.78"
|
||||
rust-version = "1.77.2"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1"
|
||||
|
||||
@@ -766,6 +766,10 @@ pub trait Manager<R: Runtime>: sealed::ManagerBase<R> {
|
||||
|
||||
/// Adds a capability to the app.
|
||||
///
|
||||
/// Note that by default every capability file in the `src-tauri/capabilities` folder
|
||||
/// are automatically enabled unless specific capabilities are configured in [`tauri.conf.json > app > security > capabilities`],
|
||||
/// so you should use a different director for the runtime-added capabilities or use [tauri_build::Attributes::capabilities_path_pattern].
|
||||
///
|
||||
/// # Examples
|
||||
/// ```
|
||||
/// use tauri::Manager;
|
||||
@@ -773,10 +777,35 @@ pub trait Manager<R: Runtime>: sealed::ManagerBase<R> {
|
||||
/// tauri::Builder::default()
|
||||
/// .setup(|app| {
|
||||
/// #[cfg(feature = "beta")]
|
||||
/// app.add_capability(include_str!("../capabilities/beta.json"));
|
||||
/// app.add_capability(include_str!("../capabilities/beta/cap.json"));
|
||||
///
|
||||
/// #[cfg(feature = "stable")]
|
||||
/// app.add_capability(include_str!("../capabilities/stable/cap.json"));
|
||||
/// Ok(())
|
||||
/// });
|
||||
/// ```
|
||||
///
|
||||
/// The above example assumes the following directory layout:
|
||||
/// ```md
|
||||
/// ├── capabilities
|
||||
/// │ ├── app (default capabilities used by any app flavor)
|
||||
/// | | |-- cap.json
|
||||
/// │ ├── beta (capabilities only added to a `beta` flavor)
|
||||
/// | | |-- cap.json
|
||||
/// │ ├── stable (capabilities only added to a `stable` flavor)
|
||||
/// | |-- cap.json
|
||||
/// ```
|
||||
///
|
||||
/// For this layout to be properly parsed by Tauri, we need to change the build script to
|
||||
///
|
||||
/// ```skip
|
||||
/// // only pick up capabilities in the capabilities/app folder by default
|
||||
/// let attributes = tauri_build::Attributes::new().capabilities_path_pattern("./capabilities/app/*.json");
|
||||
/// tauri_build::try_build(attributes).unwrap();
|
||||
/// ```
|
||||
///
|
||||
/// [`tauri.conf.json > app > security > capabilities`]: https://tauri.app/reference/config/#capabilities
|
||||
/// [tauri_build::Attributes::capabilities_path_pattern]: https://docs.rs/tauri-build/2/tauri_build/struct.Attributes.html#method.capabilities_path_pattern
|
||||
fn add_capability(&self, capability: impl RuntimeCapability) -> Result<()> {
|
||||
self
|
||||
.manager()
|
||||
|
||||
@@ -6,6 +6,7 @@ use std::{
|
||||
borrow::Cow,
|
||||
collections::HashMap,
|
||||
fmt,
|
||||
net::Ipv4Addr,
|
||||
sync::{Arc, Mutex, MutexGuard},
|
||||
};
|
||||
|
||||
@@ -332,6 +333,20 @@ impl<R: Runtime> AppManager<R> {
|
||||
self.config.build.dev_url.as_ref()
|
||||
}
|
||||
|
||||
pub(crate) fn proxy_dev_server_url(&self) -> Option<Url> {
|
||||
let proxy = cfg!(mobile)
|
||||
&& cfg!(dev)
|
||||
&& self.config.build.dev_url.as_ref().map_or(false, |url| {
|
||||
url.host().map_or(false, |host| match host {
|
||||
url::Host::Domain(d) => d != "localhost",
|
||||
url::Host::Ipv4(ip) => ip != Ipv4Addr::LOCALHOST,
|
||||
_ => false,
|
||||
})
|
||||
});
|
||||
|
||||
proxy.then(|| self.get_url().into_owned())
|
||||
}
|
||||
|
||||
pub(crate) fn protocol_url(&self) -> Cow<'_, Url> {
|
||||
if cfg!(windows) || cfg!(target_os = "android") {
|
||||
Cow::Owned(Url::parse("http://tauri.localhost").unwrap())
|
||||
|
||||
@@ -34,12 +34,6 @@ use super::{
|
||||
AppManager,
|
||||
};
|
||||
|
||||
// we need to proxy the dev server on mobile because we can't use `localhost`, so we use the local IP address
|
||||
// and we do not get a secure context without the custom protocol that proxies to the dev server
|
||||
// additionally, we need the custom protocol to inject the initialization scripts on Android
|
||||
// must also keep in sync with the `let mut response` assignment in prepare_uri_scheme_protocol
|
||||
pub(crate) const PROXY_DEV_SERVER: bool = cfg!(all(dev, mobile));
|
||||
|
||||
pub(crate) const PROCESS_IPC_MESSAGE_FN: &str =
|
||||
include_str!("../../scripts/process-ipc-message-fn.js");
|
||||
|
||||
@@ -403,10 +397,12 @@ impl<R: Runtime> WebviewManager<R> {
|
||||
|
||||
let app_manager = manager.manager();
|
||||
|
||||
let proxy_dev_server = app_manager.proxy_dev_server_url().is_some();
|
||||
|
||||
#[allow(unused_mut)] // mut url only for the data-url parsing
|
||||
let mut url = match &pending.webview_attributes.url {
|
||||
WebviewUrl::App(path) => {
|
||||
let url = if PROXY_DEV_SERVER {
|
||||
let url = if proxy_dev_server {
|
||||
Cow::Owned(Url::parse("tauri://localhost").unwrap())
|
||||
} else {
|
||||
app_manager.get_url()
|
||||
@@ -426,7 +422,7 @@ impl<R: Runtime> WebviewManager<R> {
|
||||
let config_url = app_manager.get_url();
|
||||
let is_local = config_url.make_relative(url).is_some();
|
||||
let mut url = url.clone();
|
||||
if is_local && PROXY_DEV_SERVER {
|
||||
if is_local && proxy_dev_server {
|
||||
url.set_scheme("tauri").unwrap();
|
||||
url.set_host(Some("localhost")).unwrap();
|
||||
}
|
||||
|
||||
@@ -7,15 +7,13 @@ use std::{borrow::Cow, sync::Arc};
|
||||
use http::{header::CONTENT_TYPE, Request, Response as HttpResponse, StatusCode};
|
||||
|
||||
use crate::{
|
||||
manager::{webview::PROXY_DEV_SERVER, AppManager},
|
||||
manager::AppManager,
|
||||
webview::{UriSchemeProtocolHandler, WebResourceRequestHandler},
|
||||
Runtime,
|
||||
};
|
||||
|
||||
#[cfg(all(dev, mobile))]
|
||||
use std::{collections::HashMap, sync::Mutex};
|
||||
|
||||
#[cfg(all(dev, mobile))]
|
||||
#[derive(Clone)]
|
||||
struct CachedResponse {
|
||||
status: http::StatusCode,
|
||||
@@ -28,18 +26,8 @@ pub fn get<R: Runtime>(
|
||||
window_origin: &str,
|
||||
web_resource_request_handler: Option<Box<WebResourceRequestHandler>>,
|
||||
) -> UriSchemeProtocolHandler {
|
||||
#[cfg(all(dev, mobile))]
|
||||
let url = {
|
||||
let mut url = manager.get_url().as_str().to_string();
|
||||
if url.ends_with('/') {
|
||||
url.pop();
|
||||
}
|
||||
url
|
||||
};
|
||||
|
||||
let window_origin = window_origin.to_string();
|
||||
|
||||
#[cfg(all(dev, mobile))]
|
||||
let response_cache = Arc::new(Mutex::new(HashMap::new()));
|
||||
|
||||
Box::new(move |request, responder| {
|
||||
@@ -48,8 +36,7 @@ pub fn get<R: Runtime>(
|
||||
&manager,
|
||||
&window_origin,
|
||||
web_resource_request_handler.as_deref(),
|
||||
#[cfg(all(dev, mobile))]
|
||||
(&url, &response_cache),
|
||||
&response_cache,
|
||||
) {
|
||||
Ok(response) => responder.respond(response),
|
||||
Err(e) => responder.respond(
|
||||
@@ -66,16 +53,15 @@ pub fn get<R: Runtime>(
|
||||
|
||||
fn get_response<R: Runtime>(
|
||||
request: Request<Vec<u8>>,
|
||||
#[allow(unused_variables)] manager: &AppManager<R>,
|
||||
manager: &AppManager<R>,
|
||||
window_origin: &str,
|
||||
web_resource_request_handler: Option<&WebResourceRequestHandler>,
|
||||
#[cfg(all(dev, mobile))] (url, response_cache): (
|
||||
&str,
|
||||
&Arc<Mutex<HashMap<String, CachedResponse>>>,
|
||||
),
|
||||
response_cache: &Arc<Mutex<HashMap<String, CachedResponse>>>,
|
||||
) -> Result<HttpResponse<Cow<'static, [u8]>>, Box<dyn std::error::Error>> {
|
||||
let proxy_dev_server_url = manager.proxy_dev_server_url();
|
||||
|
||||
// use the entire URI as we are going to proxy the request
|
||||
let path = if PROXY_DEV_SERVER {
|
||||
let path = if proxy_dev_server_url.is_some() {
|
||||
request.uri().to_string()
|
||||
} else {
|
||||
// ignore query string and fragment
|
||||
@@ -97,14 +83,13 @@ fn get_response<R: Runtime>(
|
||||
|
||||
let mut builder = HttpResponse::builder().header("Access-Control-Allow-Origin", window_origin);
|
||||
|
||||
#[cfg(all(dev, mobile))]
|
||||
let mut response = {
|
||||
let mut response = if let Some(proxy_dev_server_url) = proxy_dev_server_url {
|
||||
let decoded_path = percent_encoding::percent_decode(path.as_bytes())
|
||||
.decode_utf8_lossy()
|
||||
.to_string();
|
||||
let url = format!(
|
||||
"{}/{}",
|
||||
url.trim_end_matches('/'),
|
||||
proxy_dev_server_url.as_str().trim_end_matches('/'),
|
||||
decoded_path.trim_start_matches('/')
|
||||
);
|
||||
|
||||
@@ -148,10 +133,7 @@ fn get_response<R: Runtime>(
|
||||
return Err(Box::new(e));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#[cfg(not(all(dev, mobile)))]
|
||||
let mut response = {
|
||||
} else {
|
||||
let asset = manager.get_asset(path)?;
|
||||
builder = builder.header(CONTENT_TYPE, &asset.mime_type);
|
||||
if let Some(csp) = &asset.csp_header {
|
||||
@@ -159,6 +141,7 @@ fn get_response<R: Runtime>(
|
||||
}
|
||||
builder.body(asset.bytes.into())?
|
||||
};
|
||||
|
||||
if let Some(handler) = &web_resource_request_handler {
|
||||
handler(request, &mut response);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ name = "api"
|
||||
version = "0.1.0"
|
||||
description = "An example Tauri Application showcasing the api"
|
||||
edition = "2021"
|
||||
rust-version = "1.78"
|
||||
rust-version = "1.77.2"
|
||||
license = "Apache-2.0 OR MIT"
|
||||
|
||||
[lib]
|
||||
|
||||
@@ -3,7 +3,7 @@ name = "tauri-file-associations-demo"
|
||||
version = "0.1.0"
|
||||
description = "A Tauri application that associate file types"
|
||||
edition = "2021"
|
||||
rust-version = "1.78"
|
||||
rust-version = "1.77.2"
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { path = "../../../crates/tauri-build", features = ["codegen"] }
|
||||
|
||||
@@ -3,7 +3,7 @@ name = "resources"
|
||||
version = "0.1.0"
|
||||
description = "A Tauri application that uses Node.js with app resources"
|
||||
edition = "2021"
|
||||
rust-version = "1.78"
|
||||
rust-version = "1.77.2"
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { path = "../../../crates/tauri-build", features = ["codegen"] }
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# Changelog
|
||||
|
||||
## \[2.0.1]
|
||||
|
||||
### What's Changed
|
||||
|
||||
- [`be683e2ac`](https://www.github.com/tauri-apps/tauri/commit/be683e2ac36df9c51a5c050d9d500247bd019090) ([#11199](https://www.github.com/tauri-apps/tauri/pull/11199) by [@lucasfernog](https://www.github.com/tauri-apps/tauri/../../lucasfernog)) Publish package with the latest NPM tag.
|
||||
|
||||
## \[2.0.0]
|
||||
|
||||
### What's Changed
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@tauri-apps/api",
|
||||
"version": "2.0.0",
|
||||
"version": "2.0.1",
|
||||
"description": "Tauri API definitions",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
|
||||
Reference in New Issue
Block a user