From 2ce8b36d5141fd7e6af70cbe5540fc75dd83c1f0 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 22 Apr 2024 22:41:46 +0000 Subject: [PATCH] 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 Committed via a GitHub action: https://github.com/tauri-apps/plugins-workspace/actions/runs/8791882915 Co-authored-by: FabianLars --- api-iife.js | 2 +- dist-js/index.cjs | 12 ++++++------ dist-js/index.d.ts | 6 +++--- dist-js/index.js | 12 ++++++------ guest-js/index.ts | 34 ++++++++++++++++++---------------- 5 files changed, 34 insertions(+), 32 deletions(-) diff --git a/api-iife.js b/api-iife.js index 40a09cb..25a6b77 100644 --- a/api-iife.js +++ b/api-iife.js @@ -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__})} diff --git a/dist-js/index.cjs b/dist-js/index.cjs index dd5736c..c855628 100644 --- a/dist-js/index.cjs +++ b/dist-js/index.cjs @@ -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, diff --git a/dist-js/index.d.ts b/dist-js/index.d.ts index 35d2b62..c5b8711 100644 --- a/dist-js/index.d.ts +++ b/dist-js/index.d.ts @@ -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; diff --git a/dist-js/index.js b/dist-js/index.js index b95775b..74ae891 100644 --- a/dist-js/index.js +++ b/dist-js/index.js @@ -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, diff --git a/guest-js/index.ts b/guest-js/index.ts index a1a6d77..49b1830 100644 --- a/guest-js/index.ts +++ b/guest-js/index.ts @@ -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("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, {