mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-01-31 00:45:24 +01:00
refactor: only inject API IIFE script when withGlobalTauri is true (#1071)
* refactor: only inject API IIFE script when withGlobalTauri is true * fmt * update tauri
This commit is contained in:
committed by
GitHub
parent
9dec9605ed
commit
a04ea2f382
32
.changes/global-api-script-refactor.md
Normal file
32
.changes/global-api-script-refactor.md
Normal file
@@ -0,0 +1,32 @@
|
||||
---
|
||||
"authenticator": patch
|
||||
"autostart": patch
|
||||
"barcode-scanner": patch
|
||||
"biometric": patch
|
||||
"cli": patch
|
||||
"clipboard-manager": patch
|
||||
"deep-link": patch
|
||||
"dialog": patch
|
||||
"fs": patch
|
||||
"global-shortcut": patch
|
||||
"http": patch
|
||||
"localhost": patch
|
||||
"log-plugin": patch
|
||||
"nfc": patch
|
||||
"notification": patch
|
||||
"os": patch
|
||||
"persisted-scope": patch
|
||||
"positioner": patch
|
||||
"process": patch
|
||||
"shell": patch
|
||||
"single-instance": patch
|
||||
"sql": patch
|
||||
"store": patch
|
||||
"stronghold": patch
|
||||
"updater": patch
|
||||
"upload": patch
|
||||
"websocket": patch
|
||||
"window-state": patch
|
||||
---
|
||||
|
||||
The global API script is now only added to the binary when the `withGlobalTauri` config is true.
|
||||
@@ -2363,7 +2363,7 @@
|
||||
"type": "object",
|
||||
"required": [
|
||||
"args",
|
||||
"command",
|
||||
"cmd",
|
||||
"name",
|
||||
"sidecar"
|
||||
],
|
||||
@@ -2376,7 +2376,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"command": {
|
||||
"cmd": {
|
||||
"description": "The command name. It can start with a variable that resolves to a system base directory. The variables are: `$AUDIO`, `$CACHE`, `$CONFIG`, `$DATA`, `$LOCALDATA`, `$DESKTOP`, `$DOCUMENT`, `$DOWNLOAD`, `$EXE`, `$FONT`, `$HOME`, `$PICTURE`, `$PUBLIC`, `$RUNTIME`, `$TEMPLATE`, `$VIDEO`, `$RESOURCE`, `$APP`, `$LOG`, `$TEMP`, `$APPCONFIG`, `$APPDATA`, `$APPLOCALDATA`, `$APPCACHE`, `$APPLOG`.",
|
||||
"type": "string"
|
||||
},
|
||||
@@ -2398,7 +2398,7 @@
|
||||
"type": "object",
|
||||
"required": [
|
||||
"args",
|
||||
"command",
|
||||
"cmd",
|
||||
"name",
|
||||
"sidecar"
|
||||
],
|
||||
@@ -2411,7 +2411,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"command": {
|
||||
"cmd": {
|
||||
"description": "The command name. It can start with a variable that resolves to a system base directory. The variables are: `$AUDIO`, `$CACHE`, `$CONFIG`, `$DATA`, `$LOCALDATA`, `$DESKTOP`, `$DOCUMENT`, `$DOWNLOAD`, `$EXE`, `$FONT`, `$HOME`, `$PICTURE`, `$PUBLIC`, `$RUNTIME`, `$TEMPLATE`, `$VIDEO`, `$RESOURCE`, `$APP`, `$LOG`, `$TEMP`, `$APPCONFIG`, `$APPDATA`, `$APPLOCALDATA`, `$APPCACHE`, `$APPLOG`.",
|
||||
"type": "string"
|
||||
},
|
||||
|
||||
@@ -11,5 +11,7 @@ const COMMANDS: &[&str] = &[
|
||||
];
|
||||
|
||||
fn main() {
|
||||
tauri_plugin::Builder::new(COMMANDS).build();
|
||||
tauri_plugin::Builder::new(COMMANDS)
|
||||
.global_api_script_path("./api-iife.js")
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -78,7 +78,6 @@ fn verify_signature(
|
||||
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
PluginBuilder::new("authenticator")
|
||||
.js_init_script(include_str!("api-iife.js").to_string())
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
init_auth,
|
||||
register,
|
||||
|
||||
@@ -5,5 +5,7 @@
|
||||
const COMMANDS: &[&str] = &["enable", "disable", "is_enabled"];
|
||||
|
||||
fn main() {
|
||||
tauri_plugin::Builder::new(COMMANDS).build();
|
||||
tauri_plugin::Builder::new(COMMANDS)
|
||||
.global_api_script_path("./api-iife.js")
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -107,7 +107,6 @@ pub fn init<R: Runtime>(
|
||||
args: Option<Vec<&'static str>>,
|
||||
) -> TauriPlugin<R> {
|
||||
Builder::new("autostart")
|
||||
.js_init_script(include_str!("api-iife.js").to_string())
|
||||
.invoke_handler(tauri::generate_handler![enable, disable, is_enabled])
|
||||
.setup(move |app, _api| {
|
||||
let mut builder = AutoLaunchBuilder::new();
|
||||
|
||||
@@ -13,6 +13,7 @@ const COMMANDS: &[&str] = &[
|
||||
|
||||
fn main() {
|
||||
if let Err(error) = tauri_plugin::Builder::new(COMMANDS)
|
||||
.global_api_script_path("./api-iife.js")
|
||||
.android_path("android")
|
||||
.ios_path("ios")
|
||||
.try_build()
|
||||
|
||||
@@ -6,6 +6,7 @@ const COMMANDS: &[&str] = &["authenticate", "status"];
|
||||
|
||||
fn main() {
|
||||
tauri_plugin::Builder::new(COMMANDS)
|
||||
.global_api_script_path("./api-iife.js")
|
||||
.android_path("android")
|
||||
.ios_path("ios")
|
||||
.build();
|
||||
|
||||
@@ -59,7 +59,6 @@ impl<R: Runtime, T: Manager<R>> crate::BiometricExt<R> for T {
|
||||
/// Initializes the plugin.
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
Builder::new("biometric")
|
||||
.js_init_script(include_str!("api-iife.js").to_string())
|
||||
.setup(|app, api| {
|
||||
#[cfg(target_os = "android")]
|
||||
let handle = api.register_android_plugin(PLUGIN_IDENTIFIER, "BiometricPlugin")?;
|
||||
|
||||
@@ -5,5 +5,7 @@
|
||||
const COMMANDS: &[&str] = &["cli_matches"];
|
||||
|
||||
fn main() {
|
||||
tauri_plugin::Builder::new(COMMANDS).build();
|
||||
tauri_plugin::Builder::new(COMMANDS)
|
||||
.global_api_script_path("./api-iife.js")
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -51,7 +51,6 @@ fn cli_matches<R: Runtime>(_app: AppHandle<R>, cli: State<'_, Cli<R>>) -> Result
|
||||
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R, Config> {
|
||||
Builder::new("cli")
|
||||
.js_init_script(include_str!("api-iife.js").to_string())
|
||||
.invoke_handler(tauri::generate_handler![cli_matches])
|
||||
.setup(|app, api| {
|
||||
app.manage(Cli(api));
|
||||
|
||||
@@ -13,6 +13,7 @@ const COMMANDS: &[&str] = &[
|
||||
|
||||
fn main() {
|
||||
if let Err(error) = tauri_plugin::Builder::new(COMMANDS)
|
||||
.global_api_script_path("./api-iife.js")
|
||||
.android_path("android")
|
||||
.ios_path("ios")
|
||||
.try_build()
|
||||
|
||||
@@ -48,7 +48,6 @@ impl<R: Runtime, T: Manager<R>> crate::ClipboardExt<R> for T {
|
||||
/// Initializes the plugin.
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
Builder::new("clipboard-manager")
|
||||
.js_init_script(include_str!("api-iife.js").to_string())
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
commands::write_text,
|
||||
commands::read_text,
|
||||
|
||||
@@ -33,6 +33,7 @@ fn intent_filter(domain: &AssociatedDomain) -> String {
|
||||
|
||||
fn main() {
|
||||
if let Err(error) = tauri_plugin::Builder::new(COMMANDS)
|
||||
.global_api_script_path("./api-iife.js")
|
||||
.android_path("android")
|
||||
.try_build()
|
||||
{
|
||||
|
||||
@@ -128,7 +128,6 @@ impl<R: Runtime, T: Manager<R>> crate::DeepLinkExt<R> for T {
|
||||
/// Initializes the plugin.
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R, Option<config::Config>> {
|
||||
Builder::new("deep-link")
|
||||
.js_init_script(include_str!("api-iife.js").to_string())
|
||||
.invoke_handler(tauri::generate_handler![commands::get_current])
|
||||
.setup(|app, api| {
|
||||
app.manage(init_deep_link(app, api)?);
|
||||
|
||||
@@ -6,6 +6,7 @@ const COMMANDS: &[&str] = &["open", "save", "message", "ask", "confirm"];
|
||||
|
||||
fn main() {
|
||||
if let Err(error) = tauri_plugin::Builder::new(COMMANDS)
|
||||
.global_api_script_path("./api-iife.js")
|
||||
.android_path("android")
|
||||
.ios_path("ios")
|
||||
.try_build()
|
||||
|
||||
@@ -84,13 +84,7 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
// Dialogs are implemented natively on Android
|
||||
#[cfg(not(target_os = "android"))]
|
||||
{
|
||||
let mut init_script = include_str!("init-iife.js").to_string();
|
||||
init_script.push_str(include_str!("api-iife.js"));
|
||||
builder = builder.js_init_script(init_script);
|
||||
}
|
||||
#[cfg(target_os = "android")]
|
||||
{
|
||||
builder = builder.js_init_script(include_str!("api-iife.js").to_string());
|
||||
builder = builder.js_init_script(include_str!("init-iife.js").to_string());
|
||||
}
|
||||
|
||||
builder
|
||||
|
||||
@@ -162,6 +162,7 @@ permissions = [
|
||||
}
|
||||
|
||||
tauri_plugin::Builder::new(COMMANDS)
|
||||
.global_api_script_path("./api-iife.js")
|
||||
.global_scope_schema(schemars::schema_for!(scope::Entry))
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -69,7 +69,6 @@ impl ScopeObject for scope::Entry {
|
||||
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R, Option<config::Config>> {
|
||||
PluginBuilder::<R, Option<config::Config>>::new("fs")
|
||||
.js_init_script(include_str!("api-iife.js").to_string())
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
commands::create,
|
||||
commands::open,
|
||||
|
||||
@@ -11,5 +11,7 @@ const COMMANDS: &[&str] = &[
|
||||
];
|
||||
|
||||
fn main() {
|
||||
tauri_plugin::Builder::new(COMMANDS).build();
|
||||
tauri_plugin::Builder::new(COMMANDS)
|
||||
.global_api_script_path("./api-iife.js")
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -353,7 +353,6 @@ impl<R: Runtime> Builder<R> {
|
||||
let handler = self.handler;
|
||||
let shortcuts = self.shortcuts;
|
||||
PluginBuilder::new("global-shortcut")
|
||||
.js_init_script(include_str!("api-iife.js").to_string())
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
register,
|
||||
register_all,
|
||||
|
||||
@@ -68,6 +68,7 @@ impl From<ScopeEntry> for scope::Entry {
|
||||
|
||||
fn main() {
|
||||
tauri_plugin::Builder::new(COMMANDS)
|
||||
.global_api_script_path("./api-iife.js")
|
||||
.global_scope_schema(schemars::schema_for!(ScopeEntry))
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ impl<R: Runtime, T: Manager<R>> HttpExt<R> for T {
|
||||
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
Builder::<R>::new("http")
|
||||
.js_init_script(include_str!("api-iife.js").to_string())
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
commands::fetch,
|
||||
commands::fetch_cancel,
|
||||
|
||||
@@ -5,5 +5,8 @@
|
||||
const COMMANDS: &[&str] = &["log"];
|
||||
|
||||
fn main() {
|
||||
tauri_plugin::Builder::new(COMMANDS).ios_path("ios").build();
|
||||
tauri_plugin::Builder::new(COMMANDS)
|
||||
.global_api_script_path("./api-iife.js")
|
||||
.ios_path("ios")
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -396,7 +396,6 @@ impl Builder {
|
||||
|
||||
pub fn build<R: Runtime>(mut self) -> TauriPlugin<R> {
|
||||
plugin::Builder::new("log")
|
||||
.js_init_script(include_str!("api-iife.js").to_string())
|
||||
.invoke_handler(tauri::generate_handler![log])
|
||||
.setup(move |app_handle, _api| {
|
||||
let app_name = &app_handle.package_info().name;
|
||||
|
||||
@@ -6,6 +6,7 @@ const COMMANDS: &[&str] = &["is_available", "write", "scan"];
|
||||
|
||||
fn main() {
|
||||
tauri_plugin::Builder::new(COMMANDS)
|
||||
.global_api_script_path("./api-iife.js")
|
||||
.android_path("android")
|
||||
.ios_path("ios")
|
||||
.build();
|
||||
|
||||
@@ -71,7 +71,6 @@ impl<R: Runtime, T: Manager<R>> crate::NfcExt<R> for T {
|
||||
/// Initializes the plugin.
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
Builder::new("nfc")
|
||||
.js_init_script(include_str!("api-iife.js").to_string())
|
||||
.setup(|app, api| {
|
||||
#[cfg(target_os = "android")]
|
||||
let handle = api.register_android_plugin(PLUGIN_IDENTIFIER, "NfcPlugin")?;
|
||||
|
||||
@@ -6,6 +6,7 @@ const COMMANDS: &[&str] = &["notify", "request_permission", "is_permission_grant
|
||||
|
||||
fn main() {
|
||||
if let Err(error) = tauri_plugin::Builder::new(COMMANDS)
|
||||
.global_api_script_path("./api-iife.js")
|
||||
.android_path("android")
|
||||
.ios_path("ios")
|
||||
.try_build()
|
||||
|
||||
@@ -224,15 +224,13 @@ impl<R: Runtime, T: Manager<R>> crate::NotificationExt<R> for T {
|
||||
|
||||
/// Initializes the plugin.
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
let mut init_script = include_str!("init-iife.js").to_string();
|
||||
init_script.push_str(include_str!("api-iife.js"));
|
||||
Builder::new("notification")
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
commands::notify,
|
||||
commands::request_permission,
|
||||
commands::is_permission_granted
|
||||
])
|
||||
.js_init_script(init_script)
|
||||
.js_init_script(include_str!("init-iife.js").to_string())
|
||||
.setup(|app, api| {
|
||||
#[cfg(mobile)]
|
||||
let notification = mobile::init(app, api)?;
|
||||
|
||||
@@ -14,5 +14,7 @@ const COMMANDS: &[&str] = &[
|
||||
];
|
||||
|
||||
fn main() {
|
||||
tauri_plugin::Builder::new(COMMANDS).build();
|
||||
tauri_plugin::Builder::new(COMMANDS)
|
||||
.global_api_script_path("./api-iife.js")
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -8,5 +8,3 @@ Object.defineProperty(window, "__TAURI_OS_PLUGIN_INTERNALS__", {
|
||||
eol: __TEMPLATE_eol__,
|
||||
},
|
||||
});
|
||||
|
||||
__RAW_global_os_api__;
|
||||
|
||||
@@ -103,14 +103,11 @@ pub fn hostname() -> String {
|
||||
#[derive(Template)]
|
||||
#[default_template("./init.js")]
|
||||
struct InitJavascript {
|
||||
#[raw]
|
||||
global_os_api: &'static str,
|
||||
eol: &'static str,
|
||||
}
|
||||
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
let init_js = InitJavascript {
|
||||
global_os_api: include_str!("api-iife.js"),
|
||||
#[cfg(windows)]
|
||||
eol: "\r\n",
|
||||
#[cfg(not(windows))]
|
||||
|
||||
@@ -5,5 +5,7 @@
|
||||
const COMMANDS: &[&str] = &["move_window"];
|
||||
|
||||
fn main() {
|
||||
tauri_plugin::Builder::new(COMMANDS).build();
|
||||
tauri_plugin::Builder::new(COMMANDS)
|
||||
.global_api_script_path("./api-iife.js")
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -57,9 +57,8 @@ async fn move_window<R: Runtime>(window: tauri::Window<R>, position: Position) -
|
||||
|
||||
/// The Tauri plugin that exposes [`WindowExt::move_window`] to the webview.
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
let plugin = plugin::Builder::new("positioner")
|
||||
.js_init_script(include_str!("api-iife.js").to_string())
|
||||
.invoke_handler(tauri::generate_handler![move_window]);
|
||||
let plugin =
|
||||
plugin::Builder::new("positioner").invoke_handler(tauri::generate_handler![move_window]);
|
||||
|
||||
#[cfg(feature = "tray-icon")]
|
||||
let plugin = plugin.setup(|app_handle, _api| {
|
||||
|
||||
@@ -5,5 +5,7 @@
|
||||
const COMMANDS: &[&str] = &["exit", "restart"];
|
||||
|
||||
fn main() {
|
||||
tauri_plugin::Builder::new(COMMANDS).build();
|
||||
tauri_plugin::Builder::new(COMMANDS)
|
||||
.global_api_script_path("./api-iife.js")
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ mod commands;
|
||||
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
Builder::new("process")
|
||||
.js_init_script(include_str!("api-iife.js").to_string())
|
||||
.invoke_handler(tauri::generate_handler![commands::exit, commands::restart])
|
||||
.build()
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ const COMMANDS: &[&str] = &["execute", "stdin_write", "kill", "open"];
|
||||
|
||||
fn main() {
|
||||
tauri_plugin::Builder::new(COMMANDS)
|
||||
.global_api_script_path("./api-iife.js")
|
||||
.global_scope_schema(schemars::schema_for!(scope_entry::Entry))
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -77,11 +77,8 @@ impl<R: Runtime, T: Manager<R>> ShellExt<R> for T {
|
||||
}
|
||||
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R, Option<config::Config>> {
|
||||
let mut init_script = include_str!("init-iife.js").to_string();
|
||||
init_script.push_str(include_str!("api-iife.js"));
|
||||
|
||||
Builder::<R, Option<config::Config>>::new("shell")
|
||||
.js_init_script(init_script)
|
||||
.js_init_script(include_str!("init-iife.js").to_string())
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
commands::execute,
|
||||
commands::stdin_write,
|
||||
|
||||
@@ -5,5 +5,7 @@
|
||||
const COMMANDS: &[&str] = &["load", "execute", "select", "close"];
|
||||
|
||||
fn main() {
|
||||
tauri_plugin::Builder::new(COMMANDS).build();
|
||||
tauri_plugin::Builder::new(COMMANDS)
|
||||
.global_api_script_path("./api-iife.js")
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -288,7 +288,6 @@ impl Builder {
|
||||
|
||||
pub fn build<R: Runtime>(mut self) -> TauriPlugin<R, Option<PluginConfig>> {
|
||||
PluginBuilder::<R, Option<PluginConfig>>::new("sql")
|
||||
.js_init_script(include_str!("api-iife.js").to_string())
|
||||
.invoke_handler(tauri::generate_handler![load, execute, select, close])
|
||||
.setup(|app, api| {
|
||||
let config = api.config().clone().unwrap_or_default();
|
||||
|
||||
@@ -9,6 +9,7 @@ const COMMANDS: &[&str] = &[
|
||||
|
||||
fn main() {
|
||||
tauri_plugin::Builder::new(COMMANDS)
|
||||
.global_api_script_path("./api-iife.js")
|
||||
.android_path("android")
|
||||
.ios_path("ios")
|
||||
.build();
|
||||
|
||||
@@ -315,7 +315,6 @@ impl<R: Runtime> Builder<R> {
|
||||
/// ```
|
||||
pub fn build(mut self) -> TauriPlugin<R> {
|
||||
plugin::Builder::new("store")
|
||||
.js_init_script(include_str!("api-iife.js").to_string())
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
set, get, has, delete, clear, reset, keys, values, length, entries, load, save
|
||||
])
|
||||
|
||||
@@ -17,5 +17,7 @@ const COMMANDS: &[&str] = &[
|
||||
];
|
||||
|
||||
fn main() {
|
||||
tauri_plugin::Builder::new(COMMANDS).build();
|
||||
tauri_plugin::Builder::new(COMMANDS)
|
||||
.global_api_script_path("./api-iife.js")
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -456,19 +456,17 @@ impl Builder {
|
||||
pub fn build<R: Runtime>(self) -> TauriPlugin<R> {
|
||||
let password_hash_function = self.password_hash_function;
|
||||
|
||||
let plugin_builder = PluginBuilder::new("stronghold")
|
||||
.js_init_script(include_str!("api-iife.js").to_string())
|
||||
.setup(move |app, _api| {
|
||||
app.manage(StrongholdCollection::default());
|
||||
app.manage(PasswordHashFunction(match password_hash_function {
|
||||
#[cfg(feature = "kdf")]
|
||||
PasswordHashFunctionKind::Argon2(path) => {
|
||||
Box::new(move |p| kdf::KeyDerivation::argon2(p, &path))
|
||||
}
|
||||
PasswordHashFunctionKind::Custom(f) => f,
|
||||
}));
|
||||
Ok(())
|
||||
});
|
||||
let plugin_builder = PluginBuilder::new("stronghold").setup(move |app, _api| {
|
||||
app.manage(StrongholdCollection::default());
|
||||
app.manage(PasswordHashFunction(match password_hash_function {
|
||||
#[cfg(feature = "kdf")]
|
||||
PasswordHashFunctionKind::Argon2(path) => {
|
||||
Box::new(move |p| kdf::KeyDerivation::argon2(p, &path))
|
||||
}
|
||||
PasswordHashFunctionKind::Custom(f) => f,
|
||||
}));
|
||||
Ok(())
|
||||
});
|
||||
|
||||
Builder::invoke_stronghold_handlers_and_build(plugin_builder)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
const COMMANDS: &[&str] = &["check", "download_and_install"];
|
||||
|
||||
fn main() {
|
||||
tauri_plugin::Builder::new(COMMANDS).build();
|
||||
tauri_plugin::Builder::new(COMMANDS)
|
||||
.global_api_script_path("./api-iife.js")
|
||||
.build();
|
||||
|
||||
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
|
||||
let mobile = target_os == "ios" || target_os == "android";
|
||||
|
||||
@@ -166,7 +166,6 @@ impl Builder {
|
||||
let target = self.target;
|
||||
let installer_args = self.installer_args;
|
||||
PluginBuilder::<R, Config>::new("updater")
|
||||
.js_init_script(include_str!("api-iife.js").to_string())
|
||||
.setup(move |app, api| {
|
||||
let mut config = api.config().clone();
|
||||
if let Some(pubkey) = pubkey {
|
||||
|
||||
@@ -5,5 +5,7 @@
|
||||
const COMMANDS: &[&str] = &["download", "upload"];
|
||||
|
||||
fn main() {
|
||||
tauri_plugin::Builder::new(COMMANDS).build();
|
||||
tauri_plugin::Builder::new(COMMANDS)
|
||||
.global_api_script_path("./api-iife.js")
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -130,7 +130,6 @@ fn file_to_body(channel: Channel, file: File) -> reqwest::Body {
|
||||
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
PluginBuilder::new("upload")
|
||||
.js_init_script(include_str!("api-iife.js").to_string())
|
||||
.invoke_handler(tauri::generate_handler![download, upload])
|
||||
.build()
|
||||
}
|
||||
|
||||
@@ -5,5 +5,7 @@
|
||||
const COMMANDS: &[&str] = &["connect", "send"];
|
||||
|
||||
fn main() {
|
||||
tauri_plugin::Builder::new(COMMANDS).build();
|
||||
tauri_plugin::Builder::new(COMMANDS)
|
||||
.global_api_script_path("./api-iife.js")
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -200,7 +200,6 @@ async fn send(
|
||||
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
PluginBuilder::new("websocket")
|
||||
.js_init_script(include_str!("api-iife.js").to_string())
|
||||
.invoke_handler(tauri::generate_handler![connect, send])
|
||||
.setup(|app, _api| {
|
||||
app.manage(ConnectionManager::default());
|
||||
|
||||
@@ -5,5 +5,7 @@
|
||||
const COMMANDS: &[&str] = &["save_window_state", "restore_window_state"];
|
||||
|
||||
fn main() {
|
||||
tauri_plugin::Builder::new(COMMANDS).build();
|
||||
tauri_plugin::Builder::new(COMMANDS)
|
||||
.global_api_script_path("./api-iife.js")
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -319,7 +319,6 @@ impl Builder {
|
||||
pub fn build<R: Runtime>(self) -> TauriPlugin<R> {
|
||||
let flags = self.state_flags;
|
||||
PluginBuilder::new("window-state")
|
||||
.js_init_script(include_str!("api-iife.js").to_string())
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
cmd::save_window_state,
|
||||
cmd::restore_state
|
||||
|
||||
@@ -73,7 +73,7 @@ export function createConfig(options = {}) {
|
||||
banner: "if ('__TAURI__' in window) {",
|
||||
// the last `}` closes the if in the banner
|
||||
footer: `Object.defineProperty(window.__TAURI__, '${pluginJsName}', { value: ${iifeVarName} }) }`,
|
||||
file: "src/api-iife.js",
|
||||
file: "api-iife.js",
|
||||
},
|
||||
// and var is not guaranteed to assign to the global `window` object so we make sure to assign it
|
||||
plugins: [typescript(), terser(), nodeResolve()],
|
||||
|
||||
@@ -6,6 +6,7 @@ const COMMANDS: &[&str] = &["execute"];
|
||||
|
||||
fn main() {
|
||||
if let Err(error) = tauri_plugin::Builder::new(COMMANDS)
|
||||
.global_api_script_path("./api-iife.js")
|
||||
.android_path("android")
|
||||
.ios_path("ios")
|
||||
.run()
|
||||
|
||||
@@ -39,7 +39,6 @@ impl<R: Runtime, T: Manager<R>> crate::{{ plugin_name_pascal_case }}Ext<R> for T
|
||||
/// Initializes the plugin.
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
Builder::new("{{ plugin_name }}")
|
||||
.js_init_script(include_str!("api-iife.js").to_string())
|
||||
.invoke_handler(tauri::generate_handler![commands::execute])
|
||||
.setup(|app, api| {
|
||||
#[cfg(mobile)]
|
||||
|
||||
Reference in New Issue
Block a user