Skip to content

Commit 626165e

Browse files
fix: mock context without dynamic-acl feature (#13455)
1 parent 638804e commit 626165e

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/tauri-codegen/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ walkdir = "2"
2828
brotli = { version = "8", optional = true, default-features = false, features = [
2929
"std",
3030
] }
31-
regex = { version = "1", optional = true }
3231
uuid = { version = "1", features = ["v4"] }
3332
semver = "1"
3433
ico = "0.4"

crates/tauri-codegen/src/context.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,7 @@ pub fn context_codegen(data: ContextData) -> EmbeddedAssetsResult<TokenStream> {
409409
identity,
410410
);
411411

412-
let runtime_authority =
413-
quote!(#root::runtime_acl!(#root::ipc::RuntimeAuthority::new, #acl_tokens, #resolved));
412+
let runtime_authority = quote!(#root::runtime_authority!(#acl_tokens, #resolved));
414413

415414
let plugin_global_api_scripts = if config.app.with_global_tauri {
416415
if let Some(scripts) = tauri_utils::plugin::read_global_api_scripts(&out_dir) {

crates/tauri/src/app.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,9 @@ impl<R: Runtime> AssetResolver<R> {
294294
self.get_for_scheme(path, use_https_scheme)
295295
}
296296

297-
/// Same as [AssetResolver::get] but resolves the custom protocol scheme based on a parameter.
297+
/// Same as [`AssetResolver::get`] but resolves the custom protocol scheme based on a parameter.
298298
///
299-
/// - `use_https_scheme`: If `true` when using [`Pattern::Isolation`](tauri::Pattern::Isolation),
299+
/// - `use_https_scheme`: If `true` when using [`Pattern::Isolation`](crate::Pattern::Isolation),
300300
/// the csp header will contain `https://tauri.localhost` instead of `http://tauri.localhost`
301301
pub fn get_for_scheme(&self, path: String, use_https_scheme: bool) -> Option<Asset> {
302302
#[cfg(dev)]

crates/tauri/src/ipc/authority.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl Origin {
6666
}
6767
}
6868

69-
/// This is used internally by [`crate::generate_handler!`]
69+
/// This is used internally by [`crate::generate_handler!`] for constructing [`RuntimeAuthority`]
7070
/// to only include the raw ACL when it's needed
7171
///
7272
/// ## Stability
@@ -77,13 +77,13 @@ impl Origin {
7777
#[cfg(any(feature = "dynamic-acl", debug_assertions))]
7878
#[doc(hidden)]
7979
#[macro_export]
80-
macro_rules! runtime_acl {
81-
($func:path, $acl:expr, $resolved_acl:expr) => {
82-
$func($acl, $resolved_acl)
80+
macro_rules! runtime_authority {
81+
($acl:expr, $resolved_acl:expr) => {
82+
$crate::ipc::RuntimeAuthority::new($acl, $resolved_acl)
8383
};
8484
}
8585

86-
/// This is used internally by [`crate::generate_handler!`]
86+
/// This is used internally by [`crate::generate_handler!`] for constructing [`RuntimeAuthority`]
8787
/// to only include the raw ACL when it's needed
8888
///
8989
/// ## Stability
@@ -94,13 +94,16 @@ macro_rules! runtime_acl {
9494
#[cfg(not(any(feature = "dynamic-acl", debug_assertions)))]
9595
#[doc(hidden)]
9696
#[macro_export]
97-
macro_rules! runtime_acl {
98-
($func:path, $_acl:expr, $resolved_acl:expr) => {
99-
$func($resolved_acl)
97+
macro_rules! runtime_authority {
98+
($_acl:expr, $resolved_acl:expr) => {
99+
$crate::ipc::RuntimeAuthority::new($resolved_acl)
100100
};
101101
}
102102

103103
impl RuntimeAuthority {
104+
/// Contruct a new [`RuntimeAuthority`] from the ACL
105+
///
106+
/// **Please prefer using the [`runtime_authority`] macro instead of calling this directly**
104107
#[doc(hidden)]
105108
pub fn new(
106109
#[cfg(any(feature = "dynamic-acl", debug_assertions))] acl: BTreeMap<String, Manifest>,

crates/tauri/src/test/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ use serialize_to_javascript::DefaultTemplate;
5959
use std::{borrow::Cow, collections::HashMap, fmt::Debug};
6060

6161
use crate::{
62-
ipc::{InvokeError, InvokeResponse, InvokeResponseBody, RuntimeAuthority},
62+
ipc::{InvokeError, InvokeResponse, InvokeResponseBody},
6363
webview::InvokeRequest,
6464
App, Assets, Builder, Context, Pattern, Runtime, Webview,
6565
};
@@ -139,7 +139,7 @@ pub fn mock_context<R: Runtime, A: Assets<R>>(assets: A) -> crate::Context<R> {
139139
crate_name: "test",
140140
},
141141
pattern: Pattern::Brownfield,
142-
runtime_authority: RuntimeAuthority::new(Default::default(), Resolved::default()),
142+
runtime_authority: crate::runtime_authority!(Default::default(), Resolved::default()),
143143
plugin_global_api_scripts: None,
144144

145145
#[cfg(dev)]

0 commit comments

Comments
 (0)