mirror of
https://github.com/tauri-apps/tauri-plugin-http.git
synced 2026-01-31 00:45:17 +01:00
chore(deps): replace dependency eslint-config-standard-with-typescript with eslint-config-love 43.1.0 (#1228)
* chore(deps): replace dependency eslint-config-standard-with-typescript with eslint-config-love 43.1.0 * actually apply the rules lol * rebuild --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: FabianLars <fabianlars@fabianlars.de> Committed via a GitHub action: https://github.com/tauri-apps/plugins-workspace/actions/runs/8791882915 Co-authored-by: FabianLars <FabianLars@users.noreply.github.com>
This commit is contained in:
@@ -1 +1 @@
|
||||
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__})}
|
||||
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;null!=r&&(delete r.maxRedirections,delete r.connectTimeout,delete r.proxy);const s=r?.signal,o=(null==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),u=await d.arrayBuffer(),c=0!==u.byteLength?Array.from(new Uint8Array(u)):null,_=await t("plugin:http|fetch",{clientConfig:{method:d.method,url:d.url,headers:o,data:c,maxRedirections:n,connectTimeout:a,proxy:i}});s?.addEventListener("abort",(()=>{t("plugin:http|fetch_cancel",{rid:_})}));const{status:l,statusText:f,url:h,headers:p,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&&0!==T.byteLength?T:T instanceof Array&&T.length>0?new Uint8Array(T):null,{headers:p,status:l,statusText:f});return Object.defineProperty(w,"url",{value:h}),w},e}({});Object.defineProperty(window.__TAURI__,"http",{value:__TAURI_PLUGIN_HTTP__})}
|
||||
|
||||
@@ -45,13 +45,13 @@ async function fetch(input, init) {
|
||||
const connectTimeout = init?.connectTimeout;
|
||||
const proxy = init?.proxy;
|
||||
// Remove these fields before creating the request
|
||||
if (init) {
|
||||
if (init != null) {
|
||||
delete init.maxRedirections;
|
||||
delete init.connectTimeout;
|
||||
delete init.proxy;
|
||||
}
|
||||
const signal = init?.signal;
|
||||
const headers = !init?.headers
|
||||
const headers = init?.headers == null
|
||||
? []
|
||||
: init.headers instanceof Headers
|
||||
? Array.from(init.headers.entries())
|
||||
@@ -66,7 +66,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 reqData = buffer.byteLength !== 0 ? Array.from(new Uint8Array(buffer)) : null;
|
||||
const rid = await core.invoke("plugin:http|fetch", {
|
||||
clientConfig: {
|
||||
method: req.method,
|
||||
@@ -79,7 +79,7 @@ async function fetch(input, init) {
|
||||
},
|
||||
});
|
||||
signal?.addEventListener("abort", () => {
|
||||
core.invoke("plugin:http|fetch_cancel", {
|
||||
void core.invoke("plugin:http|fetch_cancel", {
|
||||
rid,
|
||||
});
|
||||
});
|
||||
@@ -89,9 +89,9 @@ async function fetch(input, init) {
|
||||
const body = await core.invoke("plugin:http|fetch_read_body", {
|
||||
rid: responseRid,
|
||||
});
|
||||
const res = new Response(body instanceof ArrayBuffer && body.byteLength
|
||||
const res = new Response(body instanceof ArrayBuffer && body.byteLength !== 0
|
||||
? body
|
||||
: body instanceof Array && body.length
|
||||
: body instanceof Array && body.length > 0
|
||||
? new Uint8Array(body)
|
||||
: null, {
|
||||
headers: responseHeaders,
|
||||
|
||||
6
dist-js/index.d.ts
vendored
6
dist-js/index.d.ts
vendored
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
export type Proxy = {
|
||||
export interface Proxy {
|
||||
/**
|
||||
* Proxy all traffic to the passed URL.
|
||||
*/
|
||||
@@ -16,7 +16,7 @@ export type Proxy = {
|
||||
* Proxy all HTTPS traffic to the passed URL.
|
||||
*/
|
||||
https?: string | ProxyConfig;
|
||||
};
|
||||
}
|
||||
export interface ProxyConfig {
|
||||
/**
|
||||
* The URL of the proxy server.
|
||||
@@ -30,7 +30,7 @@ export interface ProxyConfig {
|
||||
password: string;
|
||||
};
|
||||
/**
|
||||
* A configuration for filtering out requests that shouldn’t be proxied.
|
||||
* A configuration for filtering out requests that shouldn't be proxied.
|
||||
* Entries are expected to be comma-separated (whitespace between entries is ignored)
|
||||
*/
|
||||
noProxy?: string;
|
||||
|
||||
@@ -43,13 +43,13 @@ async function fetch(input, init) {
|
||||
const connectTimeout = init?.connectTimeout;
|
||||
const proxy = init?.proxy;
|
||||
// Remove these fields before creating the request
|
||||
if (init) {
|
||||
if (init != null) {
|
||||
delete init.maxRedirections;
|
||||
delete init.connectTimeout;
|
||||
delete init.proxy;
|
||||
}
|
||||
const signal = init?.signal;
|
||||
const headers = !init?.headers
|
||||
const headers = init?.headers == null
|
||||
? []
|
||||
: init.headers instanceof Headers
|
||||
? Array.from(init.headers.entries())
|
||||
@@ -64,7 +64,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 reqData = buffer.byteLength !== 0 ? Array.from(new Uint8Array(buffer)) : null;
|
||||
const rid = await invoke("plugin:http|fetch", {
|
||||
clientConfig: {
|
||||
method: req.method,
|
||||
@@ -77,7 +77,7 @@ async function fetch(input, init) {
|
||||
},
|
||||
});
|
||||
signal?.addEventListener("abort", () => {
|
||||
invoke("plugin:http|fetch_cancel", {
|
||||
void invoke("plugin:http|fetch_cancel", {
|
||||
rid,
|
||||
});
|
||||
});
|
||||
@@ -87,9 +87,9 @@ async function fetch(input, init) {
|
||||
const body = await invoke("plugin:http|fetch_read_body", {
|
||||
rid: responseRid,
|
||||
});
|
||||
const res = new Response(body instanceof ArrayBuffer && body.byteLength
|
||||
const res = new Response(body instanceof ArrayBuffer && body.byteLength !== 0
|
||||
? body
|
||||
: body instanceof Array && body.length
|
||||
: body instanceof Array && body.length > 0
|
||||
? new Uint8Array(body)
|
||||
: null, {
|
||||
headers: responseHeaders,
|
||||
|
||||
@@ -31,7 +31,7 @@ import { invoke } from "@tauri-apps/api/core";
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
export type Proxy = {
|
||||
export interface Proxy {
|
||||
/**
|
||||
* Proxy all traffic to the passed URL.
|
||||
*/
|
||||
@@ -44,7 +44,7 @@ export type Proxy = {
|
||||
* Proxy all HTTPS traffic to the passed URL.
|
||||
*/
|
||||
https?: string | ProxyConfig;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ProxyConfig {
|
||||
/**
|
||||
@@ -59,7 +59,7 @@ export interface ProxyConfig {
|
||||
password: string;
|
||||
};
|
||||
/**
|
||||
* A configuration for filtering out requests that shouldn’t be proxied.
|
||||
* A configuration for filtering out requests that shouldn't be proxied.
|
||||
* Entries are expected to be comma-separated (whitespace between entries is ignored)
|
||||
*/
|
||||
noProxy?: string;
|
||||
@@ -107,7 +107,7 @@ export async function fetch(
|
||||
const proxy = init?.proxy;
|
||||
|
||||
// Remove these fields before creating the request
|
||||
if (init) {
|
||||
if (init != null) {
|
||||
delete init.maxRedirections;
|
||||
delete init.connectTimeout;
|
||||
delete init.proxy;
|
||||
@@ -115,15 +115,16 @@ export async function fetch(
|
||||
|
||||
const signal = init?.signal;
|
||||
|
||||
const headers = !init?.headers
|
||||
? []
|
||||
: init.headers instanceof Headers
|
||||
? Array.from(init.headers.entries())
|
||||
: Array.isArray(init.headers)
|
||||
? init.headers
|
||||
: Object.entries(init.headers);
|
||||
const headers =
|
||||
init?.headers == null
|
||||
? []
|
||||
: init.headers instanceof Headers
|
||||
? Array.from(init.headers.entries())
|
||||
: Array.isArray(init.headers)
|
||||
? init.headers
|
||||
: Object.entries(init.headers);
|
||||
|
||||
const mappedHeaders: [string, string][] = headers.map(([name, val]) => [
|
||||
const mappedHeaders: Array<[string, string]> = headers.map(([name, val]) => [
|
||||
name,
|
||||
// we need to ensure we have all values as strings
|
||||
// eslint-disable-next-line
|
||||
@@ -132,7 +133,8 @@ export async function fetch(
|
||||
|
||||
const req = new Request(input, init);
|
||||
const buffer = await req.arrayBuffer();
|
||||
const reqData = buffer.byteLength ? Array.from(new Uint8Array(buffer)) : null;
|
||||
const reqData =
|
||||
buffer.byteLength !== 0 ? Array.from(new Uint8Array(buffer)) : null;
|
||||
|
||||
const rid = await invoke<number>("plugin:http|fetch", {
|
||||
clientConfig: {
|
||||
@@ -147,7 +149,7 @@ export async function fetch(
|
||||
});
|
||||
|
||||
signal?.addEventListener("abort", () => {
|
||||
invoke("plugin:http|fetch_cancel", {
|
||||
void invoke("plugin:http|fetch_cancel", {
|
||||
rid,
|
||||
});
|
||||
});
|
||||
@@ -178,9 +180,9 @@ export async function fetch(
|
||||
);
|
||||
|
||||
const res = new Response(
|
||||
body instanceof ArrayBuffer && body.byteLength
|
||||
body instanceof ArrayBuffer && body.byteLength !== 0
|
||||
? body
|
||||
: body instanceof Array && body.length
|
||||
: body instanceof Array && body.length > 0
|
||||
? new Uint8Array(body)
|
||||
: null,
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user