mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-09-22 21:30:44 +02:00
chore: update to tauri alpha.16, api alpha.9 (#673)
Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>
This commit is contained in:
co-authored by
Amr Bashir
parent
b7c5407cac
commit
5c137365c6
@@ -24,11 +24,7 @@
|
||||
* @module
|
||||
*/
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
__TAURI_INVOKE__: <T>(cmd: string, args?: unknown) => Promise<T>;
|
||||
}
|
||||
}
|
||||
import { invoke } from "@tauri-apps/api/primitives";
|
||||
|
||||
/**
|
||||
* Options to configure the Rust client used to make fetch requests
|
||||
@@ -76,7 +72,7 @@ export async function fetch(
|
||||
const buffer = await req.arrayBuffer();
|
||||
const reqData = buffer.byteLength ? Array.from(new Uint8Array(buffer)) : null;
|
||||
|
||||
const rid = await window.__TAURI_INVOKE__<number>("plugin:http|fetch", {
|
||||
const rid = await invoke<number>("plugin:http|fetch", {
|
||||
method: req.method,
|
||||
url: req.url,
|
||||
headers: Array.from(req.headers.entries()),
|
||||
@@ -86,7 +82,7 @@ export async function fetch(
|
||||
});
|
||||
|
||||
req.signal.addEventListener("abort", () => {
|
||||
window.__TAURI_INVOKE__("plugin:http|fetch_cancel", {
|
||||
invoke("plugin:http|fetch_cancel", {
|
||||
rid,
|
||||
});
|
||||
});
|
||||
@@ -98,18 +94,17 @@ export async function fetch(
|
||||
url: string;
|
||||
}
|
||||
|
||||
const { status, statusText, url, headers } =
|
||||
await window.__TAURI_INVOKE__<FetchSendResponse>("plugin:http|fetch_send", {
|
||||
rid,
|
||||
});
|
||||
|
||||
const body = await window.__TAURI_INVOKE__<number[]>(
|
||||
"plugin:http|fetch_read_body",
|
||||
const { status, statusText, url, headers } = await invoke<FetchSendResponse>(
|
||||
"plugin:http|fetch_send",
|
||||
{
|
||||
rid,
|
||||
},
|
||||
);
|
||||
|
||||
const body = await invoke<number[]>("plugin:http|fetch_read_body", {
|
||||
rid,
|
||||
});
|
||||
|
||||
const res = new Response(new Uint8Array(body), {
|
||||
headers,
|
||||
status,
|
||||
|
||||
Reference in New Issue
Block a user