@@ -1328,6 +1328,53 @@ impl<R: Runtime> Builder<R> {
1328
1328
self
1329
1329
}
1330
1330
1331
+ /// Append a custom initialization script.
1332
+ ///
1333
+ /// Allow to append custom initialization script instend of replacing entire invoke system.
1334
+ ///
1335
+ /// # Examples
1336
+ ///
1337
+ /// ```
1338
+ /// let custom_script = r#"
1339
+ /// // A custom call system bridge build on top of tauri invoke system.
1340
+ /// async function invoke(cmd, args = {}) {
1341
+ /// if (!args) args = {};
1342
+ ///
1343
+ /// let prefix = "";
1344
+ ///
1345
+ /// if (args?.__module) {
1346
+ /// prefix = `plugin:hybridcall.${args.__module}|`;
1347
+ /// }
1348
+ ///
1349
+ /// const command = `${prefix}tauri_${cmd}`;
1350
+ ///
1351
+ /// const invoke = window.__TAURI_INTERNALS__.invoke;
1352
+ ///
1353
+ /// return invoke(command, args).then(result => {
1354
+ /// if (window.build.debug) {
1355
+ /// console.log(`call: ${command}`);
1356
+ /// console.log(`args: ${JSON.stringify(args)}`);
1357
+ /// console.log(`return: ${JSON.stringify(result)}`);
1358
+ /// }
1359
+ ///
1360
+ /// return result;
1361
+ /// });
1362
+ /// }
1363
+ /// "#;
1364
+ ///
1365
+ /// tauri::Builder::default()
1366
+ /// .append_invoke_initialization_script(custom_script);
1367
+ /// ```
1368
+ pub fn append_invoke_initialization_script (
1369
+ mut self ,
1370
+ initialization_script : impl AsRef < str > ,
1371
+ ) -> Self {
1372
+ self
1373
+ . invoke_initialization_script
1374
+ . push_str ( initialization_script. as_ref ( ) ) ;
1375
+ self
1376
+ }
1377
+
1331
1378
/// Defines the setup hook.
1332
1379
///
1333
1380
/// # Examples
0 commit comments