mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-02-06 13:17:02 +00:00
fix: mock context without dynamic-acl feature (#13455)
This commit is contained in:
parent
638804e9c4
commit
626165eeb4
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -8570,7 +8570,6 @@ dependencies = [
|
||||
"png",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"regex",
|
||||
"semver",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
||||
@ -28,7 +28,6 @@ walkdir = "2"
|
||||
brotli = { version = "8", optional = true, default-features = false, features = [
|
||||
"std",
|
||||
] }
|
||||
regex = { version = "1", optional = true }
|
||||
uuid = { version = "1", features = ["v4"] }
|
||||
semver = "1"
|
||||
ico = "0.4"
|
||||
|
||||
@ -409,8 +409,7 @@ pub fn context_codegen(data: ContextData) -> EmbeddedAssetsResult<TokenStream> {
|
||||
identity,
|
||||
);
|
||||
|
||||
let runtime_authority =
|
||||
quote!(#root::runtime_acl!(#root::ipc::RuntimeAuthority::new, #acl_tokens, #resolved));
|
||||
let runtime_authority = quote!(#root::runtime_authority!(#acl_tokens, #resolved));
|
||||
|
||||
let plugin_global_api_scripts = if config.app.with_global_tauri {
|
||||
if let Some(scripts) = tauri_utils::plugin::read_global_api_scripts(&out_dir) {
|
||||
|
||||
@ -294,9 +294,9 @@ impl<R: Runtime> AssetResolver<R> {
|
||||
self.get_for_scheme(path, use_https_scheme)
|
||||
}
|
||||
|
||||
/// Same as [AssetResolver::get] but resolves the custom protocol scheme based on a parameter.
|
||||
/// Same as [`AssetResolver::get`] but resolves the custom protocol scheme based on a parameter.
|
||||
///
|
||||
/// - `use_https_scheme`: If `true` when using [`Pattern::Isolation`](tauri::Pattern::Isolation),
|
||||
/// - `use_https_scheme`: If `true` when using [`Pattern::Isolation`](crate::Pattern::Isolation),
|
||||
/// the csp header will contain `https://tauri.localhost` instead of `http://tauri.localhost`
|
||||
pub fn get_for_scheme(&self, path: String, use_https_scheme: bool) -> Option<Asset> {
|
||||
#[cfg(dev)]
|
||||
|
||||
@ -66,7 +66,7 @@ impl Origin {
|
||||
}
|
||||
}
|
||||
|
||||
/// This is used internally by [`crate::generate_handler!`]
|
||||
/// This is used internally by [`crate::generate_handler!`] for constructing [`RuntimeAuthority`]
|
||||
/// to only include the raw ACL when it's needed
|
||||
///
|
||||
/// ## Stability
|
||||
@ -77,13 +77,13 @@ impl Origin {
|
||||
#[cfg(any(feature = "dynamic-acl", debug_assertions))]
|
||||
#[doc(hidden)]
|
||||
#[macro_export]
|
||||
macro_rules! runtime_acl {
|
||||
($func:path, $acl:expr, $resolved_acl:expr) => {
|
||||
$func($acl, $resolved_acl)
|
||||
macro_rules! runtime_authority {
|
||||
($acl:expr, $resolved_acl:expr) => {
|
||||
$crate::ipc::RuntimeAuthority::new($acl, $resolved_acl)
|
||||
};
|
||||
}
|
||||
|
||||
/// This is used internally by [`crate::generate_handler!`]
|
||||
/// This is used internally by [`crate::generate_handler!`] for constructing [`RuntimeAuthority`]
|
||||
/// to only include the raw ACL when it's needed
|
||||
///
|
||||
/// ## Stability
|
||||
@ -94,13 +94,16 @@ macro_rules! runtime_acl {
|
||||
#[cfg(not(any(feature = "dynamic-acl", debug_assertions)))]
|
||||
#[doc(hidden)]
|
||||
#[macro_export]
|
||||
macro_rules! runtime_acl {
|
||||
($func:path, $_acl:expr, $resolved_acl:expr) => {
|
||||
$func($resolved_acl)
|
||||
macro_rules! runtime_authority {
|
||||
($_acl:expr, $resolved_acl:expr) => {
|
||||
$crate::ipc::RuntimeAuthority::new($resolved_acl)
|
||||
};
|
||||
}
|
||||
|
||||
impl RuntimeAuthority {
|
||||
/// Contruct a new [`RuntimeAuthority`] from the ACL
|
||||
///
|
||||
/// **Please prefer using the [`runtime_authority`] macro instead of calling this directly**
|
||||
#[doc(hidden)]
|
||||
pub fn new(
|
||||
#[cfg(any(feature = "dynamic-acl", debug_assertions))] acl: BTreeMap<String, Manifest>,
|
||||
|
||||
@ -59,7 +59,7 @@ use serialize_to_javascript::DefaultTemplate;
|
||||
use std::{borrow::Cow, collections::HashMap, fmt::Debug};
|
||||
|
||||
use crate::{
|
||||
ipc::{InvokeError, InvokeResponse, InvokeResponseBody, RuntimeAuthority},
|
||||
ipc::{InvokeError, InvokeResponse, InvokeResponseBody},
|
||||
webview::InvokeRequest,
|
||||
App, Assets, Builder, Context, Pattern, Runtime, Webview,
|
||||
};
|
||||
@ -139,7 +139,7 @@ pub fn mock_context<R: Runtime, A: Assets<R>>(assets: A) -> crate::Context<R> {
|
||||
crate_name: "test",
|
||||
},
|
||||
pattern: Pattern::Brownfield,
|
||||
runtime_authority: RuntimeAuthority::new(Default::default(), Resolved::default()),
|
||||
runtime_authority: crate::runtime_authority!(Default::default(), Resolved::default()),
|
||||
plugin_global_api_scripts: None,
|
||||
|
||||
#[cfg(dev)]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user