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:
Lucas Fernandes Nogueira
2024-03-19 15:03:20 -03:00
committed by GitHub
parent 9dec9605ed
commit a04ea2f382
80 changed files with 108 additions and 73 deletions
-1
View File
@@ -1 +0,0 @@
if("__TAURI__"in window){var __TAURI_PLUGIN_HTTP__=function(e){"use strict";async function t(e,t={},r){return window.__TAURI_INTERNALS__.invoke(e,t,r)}return"function"==typeof SuppressedError&&SuppressedError,e.fetch=async function(e,r){const n=r?.maxRedirections,a=r?.connectTimeout,i=r?.proxy;r&&(delete r.maxRedirections,delete r.connectTimeout,delete r.proxy);const s=r?.signal,o=(r?.headers?r.headers instanceof Headers?Array.from(r.headers.entries()):Array.isArray(r.headers)?r.headers:Object.entries(r.headers):[]).map((([e,t])=>[e,"string"==typeof t?t:t.toString()])),d=new Request(e,r),c=await d.arrayBuffer(),u=c.byteLength?Array.from(new Uint8Array(c)):null,_=await t("plugin:http|fetch",{clientConfig:{method:d.method,url:d.url,headers:o,data:u,maxRedirections:n,connectTimeout:a,proxy:i}});s?.addEventListener("abort",(()=>{t("plugin:http|fetch_cancel",{rid:_})}));const{status:f,statusText:h,url:p,headers:l,rid:y}=await t("plugin:http|fetch_send",{rid:_}),T=await t("plugin:http|fetch_read_body",{rid:y}),w=new Response(T instanceof ArrayBuffer&&T.byteLength?T:T instanceof Array&&T.length?new Uint8Array(T):null,{headers:l,status:f,statusText:h});return Object.defineProperty(w,"url",{value:p}),w},e}({});Object.defineProperty(window.__TAURI__,"http",{value:__TAURI_PLUGIN_HTTP__})}
-1
View File
@@ -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,