fix(http): remove `cmd` property from `http|fetch` invoke, closes #587 (#588)

* Remove `cmd` property from `http|fetch` invoke

* Build generated JS file

* Create http-remove-cmd-property.md

* Fix incompatible declaration for reading body

Co-authored-by: Louis Bailleau <Bricklou@users.noreply.github.com>

* Build generated JS file

Co-authored-by: Louis Bailleau <Bricklou@users.noreply.github.com>

---------

Co-authored-by: Louis Bailleau <Bricklou@users.noreply.github.com>
pull/590/head
i-c-b 2 years ago committed by GitHub
parent 319de692bf
commit 2cb0fa719b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,5 @@
---
"http": patch
---
Remove `cmd` property which breaks invoke call.

@ -77,7 +77,6 @@ export async function fetch(
const reqData = buffer.byteLength ? Array.from(new Uint8Array(buffer)) : null;
const rid = await window.__TAURI_INVOKE__<number>("plugin:http|fetch", {
cmd: "fetch",
method: req.method,
url: req.url,
headers: Array.from(req.headers.entries()),
@ -111,7 +110,7 @@ export async function fetch(
},
);
const res = new Response(Uint8Array.from(body), {
const res = new Response(new Uint8Array(body), {
headers,
status,
statusText,

@ -1 +1 @@
if("__TAURI__"in window){var __TAURI_HTTP__=function(e){"use strict";return e.fetch=async function(e,t){const n=null==t?void 0:t.maxRedirections,r=null==t?void 0:t.maxRedirections;t&&(delete t.maxRedirections,delete t.connectTimeout);const _=new Request(e,t),i=await _.arrayBuffer(),a=i.byteLength?Array.from(new Uint8Array(i)):null,d=await window.__TAURI_INVOKE__("plugin:http|fetch",{cmd:"fetch",method:_.method,url:_.url,headers:Array.from(_.headers.entries()),data:a,maxRedirections:n,connectTimeout:r});_.signal.addEventListener("abort",(()=>{window.__TAURI_INVOKE__("plugin:http|fetch_cancel",{rid:d})}));const{status:o,statusText:s,url:c,headers:u}=await window.__TAURI_INVOKE__("plugin:http|fetch_send",{rid:d}),l=await window.__TAURI_INVOKE__("plugin:http|fetch_read_body",{rid:d}),w=new Response(Uint8Array.from(l),{headers:u,status:o,statusText:s});return Object.defineProperty(w,"url",{value:c}),w},e}({});Object.defineProperty(window.__TAURI__,"http",{value:__TAURI_HTTP__})}
if("__TAURI__"in window){var __TAURI_HTTP__=function(e){"use strict";return e.fetch=async function(e,t){const n=null==t?void 0:t.maxRedirections,r=null==t?void 0:t.maxRedirections;t&&(delete t.maxRedirections,delete t.connectTimeout);const _=new Request(e,t),i=await _.arrayBuffer(),a=i.byteLength?Array.from(new Uint8Array(i)):null,d=await window.__TAURI_INVOKE__("plugin:http|fetch",{method:_.method,url:_.url,headers:Array.from(_.headers.entries()),data:a,maxRedirections:n,connectTimeout:r});_.signal.addEventListener("abort",(()=>{window.__TAURI_INVOKE__("plugin:http|fetch_cancel",{rid:d})}));const{status:o,statusText:s,url:u,headers:c}=await window.__TAURI_INVOKE__("plugin:http|fetch_send",{rid:d}),l=await window.__TAURI_INVOKE__("plugin:http|fetch_read_body",{rid:d}),w=new Response(new Uint8Array(l),{headers:c,status:o,statusText:s});return Object.defineProperty(w,"url",{value:u}),w},e}({});Object.defineProperty(window.__TAURI__,"http",{value:__TAURI_HTTP__})}

Loading…
Cancel
Save