chore: update to tauri alpha.16, api alpha.9 (#673)

Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>

Committed via a GitHub action: https://github.com/tauri-apps/plugins-workspace/actions/runs/6590505706

Co-authored-by: lucasfernog <lucasfernog@users.noreply.github.com>
This commit is contained in:
Lucas Fernandes Nogueira
2023-10-20 16:51:56 +00:00
committed by tauri-bot
parent eb6f5f2115
commit a6361dfacd
11 changed files with 72 additions and 54 deletions

View File

@@ -5,6 +5,7 @@ description = "Access an HTTP client written in Rust."
edition = { workspace = true }
authors = { workspace = true }
license = { workspace = true }
rust-version = { workspace = true }
[package.metadata.docs.rs]
features = [ "tauri/dox" ]

View File

@@ -4,7 +4,7 @@ Access the HTTP client written in Rust.
## Install
_This plugin requires a Rust version of at least **1.65**_
_This plugin requires a Rust version of at least **1.70**_
There are three general methods of installation that we can recommend.

26
dist-js/index.d.ts vendored
View File

@@ -1,29 +1,3 @@
/**
* Make HTTP requests with the Rust backend.
*
* ## Security
*
* This API has a scope configuration that forces you to restrict the URLs and paths that can be accessed using glob patterns.
*
* For instance, this scope configuration only allows making HTTP requests to the GitHub API for the `tauri-apps` organization:
* ```json
* {
* "plugins": {
* "http": {
* "scope": ["https://api.github.com/repos/tauri-apps/*"]
* }
* }
* }
* ```
* Trying to execute any API with a URL not configured on the scope results in a promise rejection due to denied access.
*
* @module
*/
declare global {
interface Window {
__TAURI_INVOKE__: <T>(cmd: string, args?: unknown) => Promise<T>;
}
}
/**
* Options to configure the Rust client used to make fetch requests
*

33
dist-js/index.min.js vendored
View File

@@ -1,6 +1,31 @@
var f=Object.defineProperty;var g=(a,b)=>{for(var c in b)f(a,c,{get:b[c],enumerable:!0});};var e=(a,b,c)=>{if(!b.has(a))throw TypeError("Cannot "+c)};var h=(a,b,c)=>(e(a,b,"read from private field"),c?c.call(a):b.get(a)),i$1=(a,b,c)=>{if(b.has(a))throw TypeError("Cannot add the same private member more than once");b instanceof WeakSet?b.add(a):b.set(a,c);},j=(a,b,c,d)=>(e(a,b,"write to private field"),d?d.call(a,c):b.set(a,c),c);
var T={};g(T,{Channel:()=>i,PluginListener:()=>o,addPluginListener:()=>l,convertFileSrc:()=>v,invoke:()=>u,transformCallback:()=>_});function _(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}var r,i=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0;i$1(this,r,()=>{});this.id=_(n=>{h(this,r).call(this,n);});}set onmessage(n){j(this,r,n);}get onmessage(){return h(this,r)}toJSON(){return `__CHANNEL__:${this.id}`}};r=new WeakMap;var o=class{constructor(n,s,t){this.plugin=n,this.event=s,this.channelId=t;}async unregister(){return u(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function l(e,n,s){let t=new i;return t.onmessage=s,u(`plugin:${e}|register_listener`,{event:n,handler:t}).then(()=>new o(e,n,t.id))}async function u(e,n={},s){return window.__TAURI_INTERNALS__.invoke(e,n,s)}function v(e,n="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,n)}
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
/**
* Make HTTP requests with the Rust backend.
*
* ## Security
*
* This API has a scope configuration that forces you to restrict the URLs and paths that can be accessed using glob patterns.
*
* For instance, this scope configuration only allows making HTTP requests to the GitHub API for the `tauri-apps` organization:
* ```json
* {
* "plugins": {
* "http": {
* "scope": ["https://api.github.com/repos/tauri-apps/*"]
* }
* }
* }
* ```
* Trying to execute any API with a URL not configured on the scope results in a promise rejection due to denied access.
*
* @module
*/
/**
* Fetch a resource from the network. It returns a `Promise` that resolves to the
* `Response` to that `Request`, whether it is successful or not.
@@ -26,7 +51,7 @@ async function fetch(input, init) {
const req = new Request(input, init);
const buffer = await req.arrayBuffer();
const reqData = buffer.byteLength ? Array.from(new Uint8Array(buffer)) : null;
const rid = await window.__TAURI_INVOKE__("plugin:http|fetch", {
const rid = await u("plugin:http|fetch", {
method: req.method,
url: req.url,
headers: Array.from(req.headers.entries()),
@@ -35,14 +60,14 @@ async function fetch(input, init) {
connectTimeout,
});
req.signal.addEventListener("abort", () => {
window.__TAURI_INVOKE__("plugin:http|fetch_cancel", {
u("plugin:http|fetch_cancel", {
rid,
});
});
const { status, statusText, url, headers } = await window.__TAURI_INVOKE__("plugin:http|fetch_send", {
const { status, statusText, url, headers } = await u("plugin:http|fetch_send", {
rid,
});
const body = await window.__TAURI_INVOKE__("plugin:http|fetch_read_body", {
const body = await u("plugin:http|fetch_read_body", {
rid,
});
const res = new Response(new Uint8Array(body), {

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,29 @@
import { invoke } from '@tauri-apps/api/primitives';
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
/**
* Make HTTP requests with the Rust backend.
*
* ## Security
*
* This API has a scope configuration that forces you to restrict the URLs and paths that can be accessed using glob patterns.
*
* For instance, this scope configuration only allows making HTTP requests to the GitHub API for the `tauri-apps` organization:
* ```json
* {
* "plugins": {
* "http": {
* "scope": ["https://api.github.com/repos/tauri-apps/*"]
* }
* }
* }
* ```
* Trying to execute any API with a URL not configured on the scope results in a promise rejection due to denied access.
*
* @module
*/
/**
* Fetch a resource from the network. It returns a `Promise` that resolves to the
* `Response` to that `Request`, whether it is successful or not.
@@ -26,7 +49,7 @@ async function fetch(input, init) {
const req = new Request(input, init);
const buffer = await req.arrayBuffer();
const reqData = buffer.byteLength ? Array.from(new Uint8Array(buffer)) : null;
const rid = await window.__TAURI_INVOKE__("plugin:http|fetch", {
const rid = await invoke("plugin:http|fetch", {
method: req.method,
url: req.url,
headers: Array.from(req.headers.entries()),
@@ -35,14 +58,14 @@ async function fetch(input, init) {
connectTimeout,
});
req.signal.addEventListener("abort", () => {
window.__TAURI_INVOKE__("plugin:http|fetch_cancel", {
invoke("plugin:http|fetch_cancel", {
rid,
});
});
const { status, statusText, url, headers } = await window.__TAURI_INVOKE__("plugin:http|fetch_send", {
const { status, statusText, url, headers } = await invoke("plugin:http|fetch_send", {
rid,
});
const body = await window.__TAURI_INVOKE__("plugin:http|fetch_read_body", {
const body = await invoke("plugin:http|fetch_read_body", {
rid,
});
const res = new Response(new Uint8Array(body), {

View File

@@ -1 +1 @@
{"version":3,"file":"index.mjs","sources":["../guest-js/index.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AA6CA;;;;;;;;;;;;;AAaG;AACI,eAAe,KAAK,CACzB,KAA6B,EAC7B,IAAkC,EAAA;IAElC,MAAM,eAAe,GAAG,IAAI,KAAA,IAAA,IAAJ,IAAI,KAAJ,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,IAAI,CAAE,eAAe,CAAC;IAC9C,MAAM,cAAc,GAAG,IAAI,KAAA,IAAA,IAAJ,IAAI,KAAJ,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,IAAI,CAAE,eAAe,CAAC;;AAG7C,IAAA,IAAI,IAAI,EAAE;QACR,OAAO,IAAI,CAAC,eAAe,CAAC;QAC5B,OAAO,IAAI,CAAC,cAAc,CAAC;AAC5B,KAAA;IAED,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACrC,IAAA,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,WAAW,EAAE,CAAC;IACvC,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC;IAE9E,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,gBAAgB,CAAS,mBAAmB,EAAE;QACrE,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,GAAG,EAAE,GAAG,CAAC,GAAG;QACZ,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;AAC1C,QAAA,IAAI,EAAE,OAAO;QACb,eAAe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AK,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;AAElD,IAAA,OAAO,GAAG,CAAC;AACb;;;;"}

View File

@@ -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,

2
node_modules/@tauri-apps/api generated vendored
View File

@@ -1 +1 @@
../../../../node_modules/.pnpm/@tauri-apps+api@2.0.0-alpha.8/node_modules/@tauri-apps/api
../../../../node_modules/.pnpm/@tauri-apps+api@2.0.0-alpha.9/node_modules/@tauri-apps/api

View File

@@ -27,6 +27,6 @@
"tslib": "^2.5.0"
},
"dependencies": {
"@tauri-apps/api": "2.0.0-alpha.8"
"@tauri-apps/api": "2.0.0-alpha.9"
}
}

View File

@@ -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",{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__})}
if("__TAURI__"in window){var __TAURI_HTTP__=function(e){"use strict";var t=Object.defineProperty,n=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},r=(e,t,r)=>(n(e,t,"read from private field"),r?r.call(e):t.get(e));function i(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}((e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})})({},{Channel:()=>s,PluginListener:()=>o,addPluginListener:()=>c,convertFileSrc:()=>_,invoke:()=>l,transformCallback:()=>i});var a,s=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,((e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)})(this,a,(()=>{})),this.id=i((e=>{r(this,a).call(this,e)}))}set onmessage(e){var t,r,i,s;i=e,n(t=this,r=a,"write to private field"),s?s.call(t,i):r.set(t,i)}get onmessage(){return r(this,a)}toJSON(){return`__CHANNEL__:${this.id}`}};a=new WeakMap;var o=class{constructor(e,t,n){this.plugin=e,this.event=t,this.channelId=n}async unregister(){return l(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function c(e,t,n){let r=new s;return r.onmessage=n,l(`plugin:${e}|register_listener`,{event:t,handler:r}).then((()=>new o(e,t,r.id)))}async function l(e,t={},n){return window.__TAURI_INTERNALS__.invoke(e,t,n)}function _(e,t="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,t)}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 i=new Request(e,t),a=await i.arrayBuffer(),s=a.byteLength?Array.from(new Uint8Array(a)):null,o=await l("plugin:http|fetch",{method:i.method,url:i.url,headers:Array.from(i.headers.entries()),data:s,maxRedirections:n,connectTimeout:r});i.signal.addEventListener("abort",(()=>{l("plugin:http|fetch_cancel",{rid:o})}));const{status:c,statusText:_,url:d,headers:u}=await l("plugin:http|fetch_send",{rid:o}),h=await l("plugin:http|fetch_read_body",{rid:o}),f=new Response(new Uint8Array(h),{headers:u,status:c,statusText:_});return Object.defineProperty(f,"url",{value:d}),f},e}({});Object.defineProperty(window.__TAURI__,"http",{value:__TAURI_HTTP__})}