@fkn/lib 0.9.19 → 0.9.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/account.cjs +1 -1
- package/account.js +24 -17
- package/{api-DnO1DsJC.d.ts → api-B0qRPCcX.d.ts} +36 -37
- package/api-BqRjtWm_.js +311 -0
- package/api-CKO3Hw-O.cjs +3 -0
- package/busy-Bp1E3JPT.js +24 -0
- package/busy-Dv8wzE5M.cjs +1 -0
- package/cloud/dgram.cjs +1 -1
- package/cloud/dgram.js +1 -1
- package/cloud/fetch.cjs +1 -1
- package/cloud/fetch.d.ts +1 -1
- package/cloud/fetch.js +1 -1
- package/cloud/fs.cjs +1 -1
- package/cloud/fs.js +2 -2
- package/cloud/net.cjs +1 -1
- package/cloud/net.d.ts +1 -1
- package/cloud/net.js +1 -1
- package/cloud-BCQTex58.cjs +1 -0
- package/{cloud-uE4g-WqI.d.ts → cloud-BTpJn4jy.d.ts} +3 -3
- package/cloud-BlR1He17.js +212 -0
- package/cloud.cjs +1 -1
- package/cloud.d.ts +3 -3
- package/cloud.js +4 -4
- package/dgram-9hn582qO.cjs +1 -0
- package/{dgram-DlGl_ho1.js → dgram-TB03kqMr.js} +55 -49
- package/dgram.cjs +1 -1
- package/dgram.d.ts +2 -1
- package/dgram.js +1 -1
- package/dns.cjs +1 -1
- package/dns.js +1 -1
- package/extension-BI2NxGtC.js +78 -0
- package/{extension-CN9oFZ0Q.d.ts → extension-CMPZjuaV.d.ts} +1 -1
- package/extension-rFQQpEqJ.cjs +1 -0
- package/extension.cjs +1 -1
- package/extension.d.ts +2 -2
- package/extension.js +3 -3
- package/fs/promises.cjs +1 -1
- package/fs/promises.js +1 -1
- package/fs-BUcpl9k4.cjs +1 -0
- package/fs-bpb3Ysdd.js +347 -0
- package/fs.cjs +1 -1
- package/fs.js +1 -1
- package/http.cjs +1 -1
- package/http.d.ts +1 -1
- package/http.js +1 -1
- package/{index-DLaonjpx.d.ts → index-DY8WjklJ.d.ts} +82 -0
- package/index.cjs +1 -1
- package/index.d.ts +12 -18
- package/index.js +92 -39
- package/lib-DbiVHPXE.cjs +53 -0
- package/{lib-CegQxwDI.js → lib-k3lstfa4.js} +178 -131
- package/net-C2fIMWFr.cjs +1 -0
- package/{net-l7JVHsIR.d.ts → net-CnYxw_sB.d.ts} +3 -1
- package/{net-BbmQeMpt.js → net-Ct8ywVAk.js} +52 -41
- package/net.cjs +1 -1
- package/net.d.ts +1 -1
- package/net.js +1 -1
- package/node-fs-BZCQUmeE.js +404 -0
- package/node-fs-DZPGCYWg.cjs +1 -0
- package/opfs.cjs +1 -1
- package/opfs.js +1 -1
- package/package.json +1 -1
- package/{packages-vX-1yfRK.d.ts → packages-Cn8S-Hkn.d.ts} +20 -20
- package/packages.cjs +1 -1
- package/packages.d.ts +1 -1
- package/packages.js +165 -149
- package/proxy--aljNHvG.js +69 -0
- package/{proxy-7ib45Uo-.d.ts → proxy-CuXtzxSQ.d.ts} +1 -1
- package/proxy-oHfEx1cn.cjs +1 -0
- package/{storage-C8hBot2f.js → storage-C1nW5Tvh.js} +1 -1
- package/{storage-BW-jDLUL.cjs → storage-rXHvV2FU.cjs} +1 -1
- package/api-DQ-V4Lls.js +0 -220
- package/api-kHMHDGar.cjs +0 -3
- package/cloud-BQoppUw4.cjs +0 -1
- package/cloud-C8CeqUht.js +0 -130
- package/dgram-D2Or5f2e.cjs +0 -1
- package/extension-4BM5hKrn.cjs +0 -1
- package/extension-DVO10P3i.js +0 -78
- package/fs-BW5mVMmu.js +0 -340
- package/fs-DJm0bhjg.cjs +0 -1
- package/lib-ulyxIbTr.cjs +0 -53
- package/net-COzDDBnS.cjs +0 -1
- package/node-fs-BMR2yCEt.cjs +0 -1
- package/node-fs-DKfokOlh.js +0 -401
- package/proxy-B0gNjT8-.cjs +0 -1
- package/proxy-BpqvCJmA.js +0 -43
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as fetch$1, A as LOCATOR_DENIED, B as SelectorPart, C as RemoteVideoElement, D as isType, E as createVideoElementHandle, F as isTerminalError, G as setRequestHeaderRule, H as RequestHeaderRule, I as Executor, J as cookies, K as CookieDetails, L as Gate, M as LOCATOR_UNSUPPORTED, N as isLocatorDenied, O as revive, P as isLocatorUnsupported, Q as assertFetchableUrl, R as GateTools, S as BoxedVideoElement, T as box, U as modifyRequestHeadersPermission, V as HeaderOperation, W as removeRequestHeaderRule, X as FetchInit, Y as readCookiePermission, Z as ProxyFetchRequest, _ as gotoPermission, a as PermissionGrant, at as FORGEABLE_HEADERS, b as isBlockedFrameUrl, c as ATTACH_FRAME_EVENT_KEY, ct as hasForgedCookie, d as Frame, et as fetchCredentialedPermission, f as FrameBackend, g as createFrame, h as attachFramePermission, i as waitForExtensionExposure, it as isLocalNetworkUrl, j as LOCATOR_ERROR, k as type, l as attachFrame, m as Locator, n as isExtensionExposed, nt as fetchPermission, o as PermissionRequest, ot as assertForgeableHeaders, p as GotoOptions, q as SiteCookie, r as setMissingExtensionHandler, rt as isBlockedFetchUrl, s as permissions, st as assertOneCookieIdentity, t as extension, tt as fetchLocalPermission, u as AttachFrameOptions, v as assertAttachableFrameUrl, w as VideoElementState, x as handleRevivableModules, y as assertLockdownApplicable, z as OperationRequest } from "./index-
|
|
1
|
+
import { $ as fetch$1, A as LOCATOR_DENIED, B as SelectorPart, C as RemoteVideoElement, D as isType, E as createVideoElementHandle, F as isTerminalError, G as setRequestHeaderRule, H as RequestHeaderRule, I as Executor, J as cookies, K as CookieDetails, L as Gate, M as LOCATOR_UNSUPPORTED, N as isLocatorDenied, O as revive, P as isLocatorUnsupported, Q as assertFetchableUrl, R as GateTools, S as BoxedVideoElement, T as box, U as modifyRequestHeadersPermission, V as HeaderOperation, W as removeRequestHeaderRule, X as FetchInit, Y as readCookiePermission, Z as ProxyFetchRequest, _ as gotoPermission, a as PermissionGrant, at as FORGEABLE_HEADERS, b as isBlockedFrameUrl, c as ATTACH_FRAME_EVENT_KEY, ct as hasForgedCookie, d as Frame, et as fetchCredentialedPermission, f as FrameBackend, g as createFrame, h as attachFramePermission, i as waitForExtensionExposure, it as isLocalNetworkUrl, j as LOCATOR_ERROR, k as type, l as attachFrame, m as Locator, n as isExtensionExposed, nt as fetchPermission, o as PermissionRequest, ot as assertForgeableHeaders, p as GotoOptions, q as SiteCookie, r as setMissingExtensionHandler, rt as isBlockedFetchUrl, s as permissions, st as assertOneCookieIdentity, t as extension, tt as fetchLocalPermission, u as AttachFrameOptions, v as assertAttachableFrameUrl, w as VideoElementState, x as handleRevivableModules, y as assertLockdownApplicable, z as OperationRequest } from "./index-DY8WjklJ.js";
|
|
2
2
|
|
|
3
3
|
//#region src/lib/extension-prompt.d.ts
|
|
4
4
|
declare const promptInstall: (reason?: string) => Promise<boolean>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./lib-DbiVHPXE.cjs"),n=require("./api-CKO3Hw-O.cjs"),r=require("./proxy-oHfEx1cn.cjs"),i=require("./desktop.cjs");var a=async e=>{if(typeof window>`u`)return!1;if(t.F())return!0;let r=await n.r,i=null,a=new Promise(e=>{i=()=>{t.F()&&e(!0)},t.P.addEventListener(`statuschange`,i)}),o=r.installPrompt.show(e).then(()=>!1),s=await Promise.race([a,o]);return i&&t.P.removeEventListener(`statuschange`,i),await r.installPrompt.hide().catch(()=>{}),s},o=null;t.I(()=>(o||=a().then(()=>void 0).finally(()=>{o=null}),o));var s=()=>typeof document<`u`&&t.F(),c=async(e,n)=>{if(r.n(e),n?.credentials===`include`){if(typeof document>`u`)throw Error(`fetch with credentials needs the FKN extension, which only exists in window realms`);return t.w(e,n)}return s()?t.w(e,{...n,credentials:`omit`}):i.available()?i.fetch(e,n):r.t(e,n)},l=e.t({ATTACH_FRAME_EVENT_KEY:()=>t.n,FORGEABLE_HEADERS:()=>t.A,LOCATOR_DENIED:()=>t.h,LOCATOR_ERROR:()=>t.g,LOCATOR_UNSUPPORTED:()=>t.m,assertAttachableFrameUrl:()=>t.s,assertFetchableUrl:()=>t.C,assertForgeableHeaders:()=>t.j,assertLockdownApplicable:()=>t.c,assertOneCookieIdentity:()=>t.M,attachFrame:()=>t.r,attachFramePermission:()=>t.i,available:()=>s,box:()=>t.z,cookies:()=>t.x,createFrame:()=>t.a,createVideoElementHandle:()=>t.B,events:()=>t.P,extension:()=>t.P,fetch:()=>t.w,fetchCredentialedPermission:()=>t.T,fetchLocalPermission:()=>t.E,fetchPermission:()=>t.D,gotoPermission:()=>t.o,handleRevivableModules:()=>t.R,hasForgedCookie:()=>t.N,isBlockedFetchUrl:()=>t.O,isBlockedFrameUrl:()=>t.l,isExtensionExposed:()=>t.F,isLocalNetworkUrl:()=>t.k,isLocatorDenied:()=>t.p,isLocatorUnsupported:()=>t.u,isTerminalError:()=>t.d,isType:()=>t.V,modifyRequestHeadersPermission:()=>t.v,permissions:()=>t.t,promptInstall:()=>a,readCookiePermission:()=>t.S,removeRequestHeaderRule:()=>t.y,revive:()=>t.H,setMissingExtensionHandler:()=>t.I,setRequestHeaderRule:()=>t.b,type:()=>t.U,waitForExtensionExposure:()=>t.L});Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return l}});
|
package/extension.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./lib-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./lib-DbiVHPXE.cjs"),t=require("./extension-rFQQpEqJ.cjs");exports.ATTACH_FRAME_EVENT_KEY=e.n,exports.FORGEABLE_HEADERS=e.A,exports.LOCATOR_DENIED=e.h,exports.LOCATOR_ERROR=e.g,exports.LOCATOR_UNSUPPORTED=e.m,exports.assertAttachableFrameUrl=e.s,exports.assertFetchableUrl=e.C,exports.assertForgeableHeaders=e.j,exports.assertLockdownApplicable=e.c,exports.assertOneCookieIdentity=e.M,exports.attachFrame=e.r,exports.attachFramePermission=e.i,exports.available=t.r,exports.box=e.z,exports.cookies=e.x,exports.createFrame=e.a,exports.createVideoElementHandle=e.B,exports.events=e.P,exports.extension=e.P,exports.fetch=e.w,exports.fetchCredentialedPermission=e.T,exports.fetchLocalPermission=e.E,exports.fetchPermission=e.D,exports.gotoPermission=e.o,exports.handleRevivableModules=e.R,exports.hasForgedCookie=e.N,exports.isBlockedFetchUrl=e.O,exports.isBlockedFrameUrl=e.l,exports.isExtensionExposed=e.F,exports.isLocalNetworkUrl=e.k,exports.isLocatorDenied=e.p,exports.isLocatorUnsupported=e.u,exports.isTerminalError=e.d,exports.isType=e.V,exports.modifyRequestHeadersPermission=e.v,exports.permissions=e.t,exports.promptInstall=t.i,exports.readCookiePermission=e.S,exports.removeRequestHeaderRule=e.y,exports.revive=e.H,exports.setMissingExtensionHandler=e.I,exports.setRequestHeaderRule=e.b,exports.type=e.U,exports.waitForExtensionExposure=e.L;
|
package/extension.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { $ as fetch, A as LOCATOR_DENIED, B as SelectorPart, C as RemoteVideoElement, D as isType, E as createVideoElementHandle, F as isTerminalError, G as setRequestHeaderRule, H as RequestHeaderRule, I as Executor, J as cookies, K as CookieDetails, L as Gate, M as LOCATOR_UNSUPPORTED, N as isLocatorDenied, O as revive, P as isLocatorUnsupported, Q as assertFetchableUrl, R as GateTools, S as BoxedVideoElement, T as box, U as modifyRequestHeadersPermission, V as HeaderOperation, W as removeRequestHeaderRule, X as FetchInit, Y as readCookiePermission, Z as ProxyFetchRequest, _ as gotoPermission, a as PermissionGrant, at as FORGEABLE_HEADERS, b as isBlockedFrameUrl, c as ATTACH_FRAME_EVENT_KEY, ct as hasForgedCookie, d as Frame, et as fetchCredentialedPermission, f as FrameBackend, g as createFrame, h as attachFramePermission, i as waitForExtensionExposure, it as isLocalNetworkUrl, j as LOCATOR_ERROR, k as type, l as attachFrame, m as Locator, n as isExtensionExposed, nt as fetchPermission, o as PermissionRequest, ot as assertForgeableHeaders, p as GotoOptions, q as SiteCookie, r as setMissingExtensionHandler, rt as isBlockedFetchUrl, s as permissions, st as assertOneCookieIdentity, t as extension, tt as fetchLocalPermission, u as AttachFrameOptions, v as assertAttachableFrameUrl, w as VideoElementState, x as handleRevivableModules, y as assertLockdownApplicable, z as OperationRequest } from "./index-
|
|
2
|
-
import { i as promptInstall, r as isExtensionAvailable } from "./extension-
|
|
1
|
+
import { $ as fetch, A as LOCATOR_DENIED, B as SelectorPart, C as RemoteVideoElement, D as isType, E as createVideoElementHandle, F as isTerminalError, G as setRequestHeaderRule, H as RequestHeaderRule, I as Executor, J as cookies, K as CookieDetails, L as Gate, M as LOCATOR_UNSUPPORTED, N as isLocatorDenied, O as revive, P as isLocatorUnsupported, Q as assertFetchableUrl, R as GateTools, S as BoxedVideoElement, T as box, U as modifyRequestHeadersPermission, V as HeaderOperation, W as removeRequestHeaderRule, X as FetchInit, Y as readCookiePermission, Z as ProxyFetchRequest, _ as gotoPermission, a as PermissionGrant, at as FORGEABLE_HEADERS, b as isBlockedFrameUrl, c as ATTACH_FRAME_EVENT_KEY, ct as hasForgedCookie, d as Frame, et as fetchCredentialedPermission, f as FrameBackend, g as createFrame, h as attachFramePermission, i as waitForExtensionExposure, it as isLocalNetworkUrl, j as LOCATOR_ERROR, k as type, l as attachFrame, m as Locator, n as isExtensionExposed, nt as fetchPermission, o as PermissionRequest, ot as assertForgeableHeaders, p as GotoOptions, q as SiteCookie, r as setMissingExtensionHandler, rt as isBlockedFetchUrl, s as permissions, st as assertOneCookieIdentity, t as extension, tt as fetchLocalPermission, u as AttachFrameOptions, v as assertAttachableFrameUrl, w as VideoElementState, x as handleRevivableModules, y as assertLockdownApplicable, z as OperationRequest } from "./index-DY8WjklJ.js";
|
|
2
|
+
import { i as promptInstall, r as isExtensionAvailable } from "./extension-CMPZjuaV.js";
|
|
3
3
|
export { ATTACH_FRAME_EVENT_KEY, AttachFrameOptions, BoxedVideoElement, CookieDetails, type Executor, FORGEABLE_HEADERS, FetchInit, Frame, FrameBackend, type Gate, type GateTools, GotoOptions, HeaderOperation, LOCATOR_DENIED, LOCATOR_ERROR, LOCATOR_UNSUPPORTED, Locator, type OperationRequest, PermissionGrant, PermissionRequest, ProxyFetchRequest, RemoteVideoElement, RequestHeaderRule, type SelectorPart, SiteCookie, VideoElementState, assertAttachableFrameUrl, assertFetchableUrl, assertForgeableHeaders, assertLockdownApplicable, assertOneCookieIdentity, attachFrame, attachFramePermission, isExtensionAvailable as available, box, cookies, createFrame, createVideoElementHandle, extension as events, extension, fetch, fetchCredentialedPermission, fetchLocalPermission, fetchPermission, gotoPermission, handleRevivableModules, hasForgedCookie, isBlockedFetchUrl, isBlockedFrameUrl, isExtensionExposed, isLocalNetworkUrl, isLocatorDenied, isLocatorUnsupported, isTerminalError, isType, modifyRequestHeadersPermission, permissions, promptInstall, readCookiePermission, removeRequestHeaderRule, revive, setMissingExtensionHandler, setRequestHeaderRule, type, waitForExtensionExposure };
|
package/extension.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as e, B as t, C as n, D as r, E as i, F as a, H as o, I as s, L as c, M as l, N as u, O as d, P as f, R as p, S as m, T as h,
|
|
2
|
-
import { i as V, r as H } from "./extension-
|
|
3
|
-
export { k as ATTACH_FRAME_EVENT_KEY,
|
|
1
|
+
import { A as e, B as t, C as n, D as r, E as i, F as a, H as o, I as s, L as c, M as l, N as u, O as d, P as f, R as p, S as m, T as h, U as g, V as _, a as v, b as y, c as b, d as x, g as S, h as C, i as w, j as T, k as E, l as D, m as O, n as k, o as A, p as j, r as M, s as N, t as P, u as F, v as I, w as L, x as R, y as z, z as B } from "./lib-k3lstfa4.js";
|
|
2
|
+
import { i as V, r as H } from "./extension-BI2NxGtC.js";
|
|
3
|
+
export { k as ATTACH_FRAME_EVENT_KEY, e as FORGEABLE_HEADERS, C as LOCATOR_DENIED, S as LOCATOR_ERROR, O as LOCATOR_UNSUPPORTED, N as assertAttachableFrameUrl, n as assertFetchableUrl, T as assertForgeableHeaders, b as assertLockdownApplicable, l as assertOneCookieIdentity, M as attachFrame, w as attachFramePermission, H as available, B as box, R as cookies, v as createFrame, t as createVideoElementHandle, f as events, f as extension, L as fetch, h as fetchCredentialedPermission, i as fetchLocalPermission, r as fetchPermission, A as gotoPermission, p as handleRevivableModules, u as hasForgedCookie, d as isBlockedFetchUrl, D as isBlockedFrameUrl, a as isExtensionExposed, E as isLocalNetworkUrl, j as isLocatorDenied, F as isLocatorUnsupported, x as isTerminalError, _ as isType, I as modifyRequestHeadersPermission, P as permissions, V as promptInstall, m as readCookiePermission, z as removeRequestHeaderRule, o as revive, s as setMissingExtensionHandler, y as setRequestHeaderRule, g as type, c as waitForExtensionExposure };
|
package/fs/promises.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../fs-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../fs-BUcpl9k4.cjs");var{readFile:t,writeFile:n,appendFile:r,unlink:i,rename:a,readdir:o,mkdir:s,rm:c,rmdir:l,stat:u,lstat:d,access:f}=e.v,p=e.v;exports.access=f,exports.appendFile=r,exports.default=p,exports.lstat=d,exports.mkdir=s,exports.readFile=t,exports.readdir=o,exports.rename=a,exports.rm=c,exports.rmdir=l,exports.stat=u,exports.unlink=i,exports.writeFile=n;
|
package/fs/promises.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { v as e } from "../fs-
|
|
1
|
+
import { v as e } from "../fs-bpb3Ysdd.js";
|
|
2
2
|
//#region src/lib/fs/promises.ts
|
|
3
3
|
var { readFile: t, writeFile: n, appendFile: r, unlink: i, rename: a, readdir: o, mkdir: s, rm: c, rmdir: l, stat: u, lstat: d, access: f } = e, p = e;
|
|
4
4
|
//#endregion
|
package/fs-BUcpl9k4.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./busy-Dv8wzE5M.cjs"),n=require("./node-fs-DZPGCYWg.cjs"),r=require("./storage-rXHvV2FU.cjs"),i=require("./opfs-CXMESVLc.cjs");var a=e.t({adopt:()=>I,adoptable:()=>L,available:()=>u,list:()=>re,onConflict:()=>ce,pending:()=>w,pendingDeletes:()=>ee,pull:()=>se,readFile:()=>ie,remove:()=>oe,replicating:()=>T,writeFile:()=>ae}),o,s=async()=>await(o??=i.t().catch(()=>!1))?!0:(o=void 0,!1),c=()=>r.r().catch(()=>`unknown`),l=async()=>await c()===`connected`,u=async()=>await s()||await l(),d=`fkn:fs:pending`,f=`fkn:fs:pending-delete`,p=`fkn:fs:adopt-declined`,m=!0,h=new Map,g=e=>{try{let t=localStorage.getItem(e);if(!t)return{};let n=JSON.parse(t);return Array.isArray(n)?Object.fromEntries(n.filter(e=>typeof e==`string`).map(e=>[e,null])):n&&typeof n==`object`?n:{}}catch{return{}}},_=(e,t)=>{try{Object.keys(t).length?localStorage.setItem(e,JSON.stringify(t)):localStorage.removeItem(e)}catch{}},v=()=>g(d),y=(e,t)=>{let n=v();e in n||(n[e]=t===void 0?h.get(e)??null:t,_(d,n))},b=e=>{let t=v();e in t&&(delete t[e],_(d,t),D()||(k=O))},x=()=>g(f),S=e=>{let t=x();e in t||(t[e]=h.get(e)??null,_(f,t))},C=e=>{let t=x();e in t&&(delete t[e],_(f,t),D()||(k=O))},w=()=>Object.keys(v()),ee=()=>Object.keys(x()),T=()=>m,E=null;t.r(`storage replication`,()=>E!==null||R!==null);var D=()=>Object.keys(v()).length>0||Object.keys(x()).length>0,O=6e4,te=10*6e4,k=O,A=null,j=()=>{A||typeof window>`u`||!D()||(A=setTimeout(()=>{A=null,M()},k),k=Math.min(k*2,te))},M=()=>{E||!D()||(E=F(!1).then(e=>{if(!D()){k=O;return}e.failed.length&&j()}).catch(()=>{j()}).finally(()=>{E=null}))},ne=null,N=()=>ne??=Promise.resolve().then(()=>require("./api-CKO3Hw-O.cjs")).then(e=>e.i).then(e=>e.apiPromise),re=async()=>{U();let e=await c(),t=e===`connected`,[n,a]=await Promise.all([s().then(e=>e?i.n():[]).catch(()=>[]),t?r.o().then(e=>({ok:!0,entries:e})).catch(()=>({ok:!1,entries:[]})):Promise.resolve({ok:e===`disconnected`,entries:[]})]);e!==`unknown`&&(m=a.ok),a.ok&&e!==`unknown`&&(h=new Map(a.entries.map(e=>[e.path,e.updatedAt])));let o=new Map,l=e=>{let t=Date.parse(e.updatedAt??``);return Number.isFinite(t)?t:0},u=e=>{let t=o.get(e.path);(!t||l(e)>=l(t))&&o.set(e.path,e)};for(let e of n)u(e);for(let e of a.entries)u(e);return a.ok&&t&&(pe(n,a.entries).catch(()=>{}),D()?M():z({local:n,remote:a.entries}).catch(()=>{})),[...o.values()]},ie=async e=>{if(await s())try{return await i.i(e)}catch(e){if(e?.name!==`NotFoundError`)throw e}let t=await r.c(e);return await s()&&i.o(e,t).catch(()=>{}),t},ae=async(e,t,n)=>{let a=t instanceof Blob?t:new Blob([t],n?.contentType?{type:n.contentType}:void 0);if(await s()){await i.o(e,a,n),U();let t=h.get(e)??null,o=await c();if(o===`disconnected`)return;if(o===`unknown`||!m){y(e,t),j();return}r.f(e,a,n).then(()=>b(e)).catch(n=>{y(e,t),j(),console.warn(`fs: cloud replicate failed, queued for adopt()`,n)});return}let o=await c();if(o===`connected`)return r.f(e,a,n);throw Error(o===`unknown`?`fs: cloud unreachable`:`fs: no storage backend available`)},oe=async e=>{U();let t=[];await s()&&t.push(i.a(e).catch(()=>{}));let n=await c();if(n===`connected`?t.push(r.l(e).then(()=>C(e)).catch(t=>{S(e),j(),console.warn(`fs: cloud delete failed, queued for retry`,t)})):n===`unknown`&&t.length&&h.has(e)&&(S(e),j()),!t.length)throw Error(n===`unknown`?`fs: cloud unreachable`:`fs: no storage backend available`);b(e),await Promise.all(t)},se=async e=>{let t=await r.c(e);return await s()&&await i.o(e,t),t},P=null,ce=e=>(P=e,()=>{P===e&&(P=null)}),le=async e=>(await N()).cloud.fs.promptConflict({path:e.path,local:e.local,cloud:e.cloud}).catch(()=>null),ue=async e=>{if(P)try{return await P(e)}catch{return null}return le(e)},F=async e=>{let t={uploaded:[],kept:[],resolved:[],unresolved:[],deleted:[],failed:[]},n=await c();if(n===`unknown`)throw Error(`fs: cloud unreachable`);if(n!==`connected`)throw Error(`fs: this needs a signed-in account`);let a=await s(),[o,l]=await Promise.all([a?i.n():Promise.resolve([]),r.o()]),u=new Map(l.map(e=>[e.path,e])),d=v();if(a)for(let e of Object.keys(d))o.some(t=>t.path===e)||b(e);for(let[e,n]of Object.entries(x())){let i=u.get(e);if(!i){C(e);continue}if(o.some(t=>t.path===e)){C(e);continue}if(i.updatedAt!==n){C(e);continue}try{await r.l(e),C(e),t.deleted.push(e)}catch(n){t.failed.push({path:e,error:n instanceof Error?n.message:String(n)})}}for(let n of o){let a=u.get(n.path),o=n.path in d;if(!o&&(a||!e)){a&&t.kept.push(n.path);continue}if(o&&a&&a.updatedAt!==d[n.path]){let e=await ue({path:n.path,local:{size:n.size,updatedAt:n.updatedAt},cloud:{size:a.size,updatedAt:a.updatedAt},readLocal:()=>i.i(n.path),readCloud:()=>r.c(n.path)});if(!e){t.unresolved.push(n.path);continue}try{if(e===`cloud`)await i.o(n.path,await r.c(n.path));else{let t=e===`local`?await i.i(n.path):e.merged;await r.f(n.path,t,n.contentType?{contentType:n.contentType}:void 0),e!==`local`&&await i.o(n.path,t)}b(n.path),t.resolved.push({path:n.path,choice:e===`local`||e===`cloud`?e:`merged`})}catch(e){if(e?.code===`FKN_E2E_LOCKED`)throw e;t.failed.push({path:n.path,error:e instanceof Error?e.message:String(e)})}continue}try{let e=await i.i(n.path);await r.f(n.path,e,n.contentType?{contentType:n.contentType}:void 0),b(n.path),t.uploaded.push(n.path)}catch(e){if(y(n.path),e?.code===`FKN_E2E_LOCKED`)throw e;t.failed.push({path:n.path,error:e instanceof Error?e.message:String(e)})}}return t},I=async()=>{for(;E;)await E;let e=F(!0);E=e.then(()=>{},()=>{});try{return await e}finally{E=null}},L=async()=>{if(!await l()||!await s())return{paths:[],bytes:0};let[e,t]=await Promise.all([i.n(),r.o()]),n=new Set(t.map(e=>e.path)),a=e.filter(e=>!n.has(e.path));return{paths:a.map(e=>e.path),bytes:a.reduce((e,t)=>e+t.size,0)}},de=()=>new Set(Object.keys(g(p))),fe=e=>{let t=g(p);for(let n of e)t[n]=null;_(p,t)},R=null,z=e=>R||(R=(async()=>{if(!await l())return;let t=e??(await s()?{local:await i.n(),remote:await r.o()}:null);if(!t)return;let n=new Set(t.remote.map(e=>e.path)),a=de(),o=t.local.filter(e=>!n.has(e.path)&&!a.has(e.path));if(!o.length)return;let c=await N(),u=o.reduce((e,t)=>e+t.size,0);if(!await c.cloud.fs.promptAdopt({files:o.length,bytes:u}).catch(()=>!1)){fe(o.map(e=>e.path));return}await I()})().catch(()=>{}).finally(()=>{R=null}),R),B=null,V=!1,pe=async(e,t)=>{let n=new Set(t.map(e=>e.path)),r=e.filter(e=>!n.has(e.path)),i=await N(),a=async()=>{await I().catch(()=>{});let e=await L().catch(()=>({paths:[],bytes:0}));await i.cloud.fs.setAdoptSource({files:e.paths.length,bytes:e.bytes},a).catch(()=>{})},o={files:r.length,bytes:r.reduce((e,t)=>e+t.size,0)};B=()=>{i.cloud.fs.setAdoptSource(o,a).catch(()=>{})},V||(V=!0,Promise.resolve().then(()=>require("./api-CKO3Hw-O.cjs")).then(e=>e.i).then(e=>e.onApiEpoch((e,t)=>{t>1&&B?.()})).catch(()=>{})),await i.cloud.fs.setAdoptSource(o,a)},H=!1,U=()=>{H||typeof window>`u`||(H=!0,window.addEventListener(`online`,()=>{M()}),Promise.resolve().then(()=>require("./account.cjs")).then(e=>e.onChange(()=>{z().catch(()=>{}),M()})).catch(()=>{}))},me=e.t({adopt:()=>q,adoptable:()=>J,appendFile:()=>ke,appendFileSync:()=>ve,available:()=>he,default:()=>$,exists:()=>Ie,existsSync:()=>ye,flush:()=>ze,lstatSync:()=>xe,mkdir:()=>Me,mkdirSync:()=>Se,mount:()=>Re,onConflict:()=>Q,pending:()=>Y,pendingDeletes:()=>X,promises:()=>Le,pull:()=>K,readFile:()=>De,readFileSync:()=>ge,readdir:()=>je,readdirSync:()=>G,remount:()=>Be,rename:()=>Fe,renameSync:()=>Ee,replicating:()=>Z,rm:()=>Ne,rmSync:()=>Ce,rmdirSync:()=>we,stat:()=>Ae,statSync:()=>be,unlink:()=>Pe,unlinkSync:()=>Te,writeFile:()=>Oe,writeFileSync:()=>_e}),W=n.t(a,{memfs:!0}),{available:he,readFileSync:ge,writeFileSync:_e,appendFileSync:ve,existsSync:ye,statSync:be,lstatSync:xe,readdirSync:G,mkdirSync:Se,rmSync:Ce,rmdirSync:we,unlinkSync:Te,renameSync:Ee,readFile:De,writeFile:Oe,appendFile:ke,stat:Ae,readdir:je,mkdir:Me,rm:Ne,unlink:Pe,rename:Fe,exists:Ie,promises:Le,mount:Re,flush:ze,remount:Be}=W,K=se,q=I,J=L,Y=w,X=ee,Z=T,Q=ce,$={...W,pull:K,adopt:q,adoptable:J,pending:Y,pendingDeletes:X,replicating:Z,onConflict:Q};Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return we}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return be}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return je}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return X}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return he}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return De}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return me}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return K}});
|
package/fs-bpb3Ysdd.js
ADDED
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
2
|
+
import { r as t } from "./busy-Bp1E3JPT.js";
|
|
3
|
+
import { t as n } from "./node-fs-BZCQUmeE.js";
|
|
4
|
+
import { c as r, f as i, l as a, o, r as s } from "./storage-C1nW5Tvh.js";
|
|
5
|
+
import { a as c, i as l, n as u, o as d, t as ee } from "./opfs-BibrNGF0.js";
|
|
6
|
+
//#region src/lib/fs/hybrid.ts
|
|
7
|
+
var f = /* @__PURE__ */ e({
|
|
8
|
+
adopt: () => H,
|
|
9
|
+
adoptable: () => U,
|
|
10
|
+
available: () => te,
|
|
11
|
+
list: () => oe,
|
|
12
|
+
onConflict: () => B,
|
|
13
|
+
pending: () => k,
|
|
14
|
+
pendingDeletes: () => A,
|
|
15
|
+
pull: () => ue,
|
|
16
|
+
readFile: () => se,
|
|
17
|
+
remove: () => le,
|
|
18
|
+
replicating: () => re,
|
|
19
|
+
writeFile: () => ce
|
|
20
|
+
}), p, m = async () => await (p ??= ee().catch(() => !1)) ? !0 : (p = void 0, !1), h = () => s().catch(() => "unknown"), g = async () => await h() === "connected", te = async () => await m() || await g(), _ = "fkn:fs:pending", v = "fkn:fs:pending-delete", y = "fkn:fs:adopt-declined", b = !0, x = /* @__PURE__ */ new Map(), S = (e) => {
|
|
21
|
+
try {
|
|
22
|
+
let t = localStorage.getItem(e);
|
|
23
|
+
if (!t) return {};
|
|
24
|
+
let n = JSON.parse(t);
|
|
25
|
+
return Array.isArray(n) ? Object.fromEntries(n.filter((e) => typeof e == "string").map((e) => [e, null])) : n && typeof n == "object" ? n : {};
|
|
26
|
+
} catch {
|
|
27
|
+
return {};
|
|
28
|
+
}
|
|
29
|
+
}, C = (e, t) => {
|
|
30
|
+
try {
|
|
31
|
+
Object.keys(t).length ? localStorage.setItem(e, JSON.stringify(t)) : localStorage.removeItem(e);
|
|
32
|
+
} catch {}
|
|
33
|
+
}, w = () => S(_), T = (e, t) => {
|
|
34
|
+
let n = w();
|
|
35
|
+
e in n || (n[e] = t === void 0 ? x.get(e) ?? null : t, C(_, n));
|
|
36
|
+
}, E = (e) => {
|
|
37
|
+
let t = w();
|
|
38
|
+
e in t && (delete t[e], C(_, t), M() || (P = N));
|
|
39
|
+
}, D = () => S(v), ne = (e) => {
|
|
40
|
+
let t = D();
|
|
41
|
+
e in t || (t[e] = x.get(e) ?? null, C(v, t));
|
|
42
|
+
}, O = (e) => {
|
|
43
|
+
let t = D();
|
|
44
|
+
e in t && (delete t[e], C(v, t), M() || (P = N));
|
|
45
|
+
}, k = () => Object.keys(w()), A = () => Object.keys(D()), re = () => b, j = null;
|
|
46
|
+
t("storage replication", () => j !== null || W !== null);
|
|
47
|
+
var M = () => Object.keys(w()).length > 0 || Object.keys(D()).length > 0, N = 6e4, ie = 10 * 6e4, P = N, F = null, I = () => {
|
|
48
|
+
F || typeof window > "u" || !M() || (F = setTimeout(() => {
|
|
49
|
+
F = null, L();
|
|
50
|
+
}, P), P = Math.min(P * 2, ie));
|
|
51
|
+
}, L = () => {
|
|
52
|
+
j || !M() || (j = V(!1).then((e) => {
|
|
53
|
+
if (!M()) {
|
|
54
|
+
P = N;
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
e.failed.length && I();
|
|
58
|
+
}).catch(() => {
|
|
59
|
+
I();
|
|
60
|
+
}).finally(() => {
|
|
61
|
+
j = null;
|
|
62
|
+
}));
|
|
63
|
+
}, ae = null, R = () => ae ??= import("./api-BqRjtWm_.js").then((e) => e.i).then((e) => e.apiPromise), oe = async () => {
|
|
64
|
+
G();
|
|
65
|
+
let e = await h(), t = e === "connected", [n, r] = await Promise.all([m().then((e) => e ? u() : []).catch(() => []), t ? o().then((e) => ({
|
|
66
|
+
ok: !0,
|
|
67
|
+
entries: e
|
|
68
|
+
})).catch(() => ({
|
|
69
|
+
ok: !1,
|
|
70
|
+
entries: []
|
|
71
|
+
})) : Promise.resolve({
|
|
72
|
+
ok: e === "disconnected",
|
|
73
|
+
entries: []
|
|
74
|
+
})]);
|
|
75
|
+
e !== "unknown" && (b = r.ok), r.ok && e !== "unknown" && (x = new Map(r.entries.map((e) => [e.path, e.updatedAt])));
|
|
76
|
+
let i = /* @__PURE__ */ new Map(), a = (e) => {
|
|
77
|
+
let t = Date.parse(e.updatedAt ?? "");
|
|
78
|
+
return Number.isFinite(t) ? t : 0;
|
|
79
|
+
}, s = (e) => {
|
|
80
|
+
let t = i.get(e.path);
|
|
81
|
+
(!t || a(e) >= a(t)) && i.set(e.path, e);
|
|
82
|
+
};
|
|
83
|
+
for (let e of n) s(e);
|
|
84
|
+
for (let e of r.entries) s(e);
|
|
85
|
+
return r.ok && t && (ve(n, r.entries).catch(() => {}), M() ? L() : he({
|
|
86
|
+
local: n,
|
|
87
|
+
remote: r.entries
|
|
88
|
+
}).catch(() => {})), [...i.values()];
|
|
89
|
+
}, se = async (e) => {
|
|
90
|
+
if (await m()) try {
|
|
91
|
+
return await l(e);
|
|
92
|
+
} catch (e) {
|
|
93
|
+
if (e?.name !== "NotFoundError") throw e;
|
|
94
|
+
}
|
|
95
|
+
let t = await r(e);
|
|
96
|
+
return await m() && d(e, t).catch(() => {}), t;
|
|
97
|
+
}, ce = async (e, t, n) => {
|
|
98
|
+
let r = t instanceof Blob ? t : new Blob([t], n?.contentType ? { type: n.contentType } : void 0);
|
|
99
|
+
if (await m()) {
|
|
100
|
+
await d(e, r, n), G();
|
|
101
|
+
let t = x.get(e) ?? null, a = await h();
|
|
102
|
+
if (a === "disconnected") return;
|
|
103
|
+
if (a === "unknown" || !b) {
|
|
104
|
+
T(e, t), I();
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
i(e, r, n).then(() => E(e)).catch((n) => {
|
|
108
|
+
T(e, t), I(), console.warn("fs: cloud replicate failed, queued for adopt()", n);
|
|
109
|
+
});
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
let a = await h();
|
|
113
|
+
if (a === "connected") return i(e, r, n);
|
|
114
|
+
throw Error(a === "unknown" ? "fs: cloud unreachable" : "fs: no storage backend available");
|
|
115
|
+
}, le = async (e) => {
|
|
116
|
+
G();
|
|
117
|
+
let t = [];
|
|
118
|
+
await m() && t.push(c(e).catch(() => {}));
|
|
119
|
+
let n = await h();
|
|
120
|
+
if (n === "connected" ? t.push(a(e).then(() => O(e)).catch((t) => {
|
|
121
|
+
ne(e), I(), console.warn("fs: cloud delete failed, queued for retry", t);
|
|
122
|
+
})) : n === "unknown" && t.length && x.has(e) && (ne(e), I()), !t.length) throw Error(n === "unknown" ? "fs: cloud unreachable" : "fs: no storage backend available");
|
|
123
|
+
E(e), await Promise.all(t);
|
|
124
|
+
}, ue = async (e) => {
|
|
125
|
+
let t = await r(e);
|
|
126
|
+
return await m() && await d(e, t), t;
|
|
127
|
+
}, z = null, B = (e) => (z = e, () => {
|
|
128
|
+
z === e && (z = null);
|
|
129
|
+
}), de = async (e) => (await R()).cloud.fs.promptConflict({
|
|
130
|
+
path: e.path,
|
|
131
|
+
local: e.local,
|
|
132
|
+
cloud: e.cloud
|
|
133
|
+
}).catch(() => null), fe = async (e) => {
|
|
134
|
+
if (z) try {
|
|
135
|
+
return await z(e);
|
|
136
|
+
} catch {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
return de(e);
|
|
140
|
+
}, V = async (e) => {
|
|
141
|
+
let t = {
|
|
142
|
+
uploaded: [],
|
|
143
|
+
kept: [],
|
|
144
|
+
resolved: [],
|
|
145
|
+
unresolved: [],
|
|
146
|
+
deleted: [],
|
|
147
|
+
failed: []
|
|
148
|
+
}, n = await h();
|
|
149
|
+
if (n === "unknown") throw Error("fs: cloud unreachable");
|
|
150
|
+
if (n !== "connected") throw Error("fs: this needs a signed-in account");
|
|
151
|
+
let s = await m(), [c, ee] = await Promise.all([s ? u() : Promise.resolve([]), o()]), f = new Map(ee.map((e) => [e.path, e])), p = w();
|
|
152
|
+
if (s) for (let e of Object.keys(p)) c.some((t) => t.path === e) || E(e);
|
|
153
|
+
for (let [e, n] of Object.entries(D())) {
|
|
154
|
+
let r = f.get(e);
|
|
155
|
+
if (!r) {
|
|
156
|
+
O(e);
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
if (c.some((t) => t.path === e)) {
|
|
160
|
+
O(e);
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
if (r.updatedAt !== n) {
|
|
164
|
+
O(e);
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
try {
|
|
168
|
+
await a(e), O(e), t.deleted.push(e);
|
|
169
|
+
} catch (n) {
|
|
170
|
+
t.failed.push({
|
|
171
|
+
path: e,
|
|
172
|
+
error: n instanceof Error ? n.message : String(n)
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
for (let n of c) {
|
|
177
|
+
let a = f.get(n.path), o = n.path in p;
|
|
178
|
+
if (!o && (a || !e)) {
|
|
179
|
+
a && t.kept.push(n.path);
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
if (o && a && a.updatedAt !== p[n.path]) {
|
|
183
|
+
let e = await fe({
|
|
184
|
+
path: n.path,
|
|
185
|
+
local: {
|
|
186
|
+
size: n.size,
|
|
187
|
+
updatedAt: n.updatedAt
|
|
188
|
+
},
|
|
189
|
+
cloud: {
|
|
190
|
+
size: a.size,
|
|
191
|
+
updatedAt: a.updatedAt
|
|
192
|
+
},
|
|
193
|
+
readLocal: () => l(n.path),
|
|
194
|
+
readCloud: () => r(n.path)
|
|
195
|
+
});
|
|
196
|
+
if (!e) {
|
|
197
|
+
t.unresolved.push(n.path);
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
try {
|
|
201
|
+
if (e === "cloud") await d(n.path, await r(n.path));
|
|
202
|
+
else {
|
|
203
|
+
let t = e === "local" ? await l(n.path) : e.merged;
|
|
204
|
+
await i(n.path, t, n.contentType ? { contentType: n.contentType } : void 0), e !== "local" && await d(n.path, t);
|
|
205
|
+
}
|
|
206
|
+
E(n.path), t.resolved.push({
|
|
207
|
+
path: n.path,
|
|
208
|
+
choice: e === "local" || e === "cloud" ? e : "merged"
|
|
209
|
+
});
|
|
210
|
+
} catch (e) {
|
|
211
|
+
if (e?.code === "FKN_E2E_LOCKED") throw e;
|
|
212
|
+
t.failed.push({
|
|
213
|
+
path: n.path,
|
|
214
|
+
error: e instanceof Error ? e.message : String(e)
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
try {
|
|
220
|
+
let e = await l(n.path);
|
|
221
|
+
await i(n.path, e, n.contentType ? { contentType: n.contentType } : void 0), E(n.path), t.uploaded.push(n.path);
|
|
222
|
+
} catch (e) {
|
|
223
|
+
if (T(n.path), e?.code === "FKN_E2E_LOCKED") throw e;
|
|
224
|
+
t.failed.push({
|
|
225
|
+
path: n.path,
|
|
226
|
+
error: e instanceof Error ? e.message : String(e)
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return t;
|
|
231
|
+
}, H = async () => {
|
|
232
|
+
for (; j;) await j;
|
|
233
|
+
let e = V(!0);
|
|
234
|
+
j = e.then(() => {}, () => {});
|
|
235
|
+
try {
|
|
236
|
+
return await e;
|
|
237
|
+
} finally {
|
|
238
|
+
j = null;
|
|
239
|
+
}
|
|
240
|
+
}, U = async () => {
|
|
241
|
+
if (!await g() || !await m()) return {
|
|
242
|
+
paths: [],
|
|
243
|
+
bytes: 0
|
|
244
|
+
};
|
|
245
|
+
let [e, t] = await Promise.all([u(), o()]), n = new Set(t.map((e) => e.path)), r = e.filter((e) => !n.has(e.path));
|
|
246
|
+
return {
|
|
247
|
+
paths: r.map((e) => e.path),
|
|
248
|
+
bytes: r.reduce((e, t) => e + t.size, 0)
|
|
249
|
+
};
|
|
250
|
+
}, pe = () => new Set(Object.keys(S(y))), me = (e) => {
|
|
251
|
+
let t = S(y);
|
|
252
|
+
for (let n of e) t[n] = null;
|
|
253
|
+
C(y, t);
|
|
254
|
+
}, W = null, he = (e) => W || (W = (async () => {
|
|
255
|
+
if (!await g()) return;
|
|
256
|
+
let t = e ?? (await m() ? {
|
|
257
|
+
local: await u(),
|
|
258
|
+
remote: await o()
|
|
259
|
+
} : null);
|
|
260
|
+
if (!t) return;
|
|
261
|
+
let n = new Set(t.remote.map((e) => e.path)), r = pe(), i = t.local.filter((e) => !n.has(e.path) && !r.has(e.path));
|
|
262
|
+
if (!i.length) return;
|
|
263
|
+
let a = await R(), s = i.reduce((e, t) => e + t.size, 0);
|
|
264
|
+
if (!await a.cloud.fs.promptAdopt({
|
|
265
|
+
files: i.length,
|
|
266
|
+
bytes: s
|
|
267
|
+
}).catch(() => !1)) {
|
|
268
|
+
me(i.map((e) => e.path));
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
await H();
|
|
272
|
+
})().catch(() => {}).finally(() => {
|
|
273
|
+
W = null;
|
|
274
|
+
}), W), ge = null, _e = !1, ve = async (e, t) => {
|
|
275
|
+
let n = new Set(t.map((e) => e.path)), r = e.filter((e) => !n.has(e.path)), i = await R(), a = async () => {
|
|
276
|
+
await H().catch(() => {});
|
|
277
|
+
let e = await U().catch(() => ({
|
|
278
|
+
paths: [],
|
|
279
|
+
bytes: 0
|
|
280
|
+
}));
|
|
281
|
+
await i.cloud.fs.setAdoptSource({
|
|
282
|
+
files: e.paths.length,
|
|
283
|
+
bytes: e.bytes
|
|
284
|
+
}, a).catch(() => {});
|
|
285
|
+
}, o = {
|
|
286
|
+
files: r.length,
|
|
287
|
+
bytes: r.reduce((e, t) => e + t.size, 0)
|
|
288
|
+
};
|
|
289
|
+
ge = () => {
|
|
290
|
+
i.cloud.fs.setAdoptSource(o, a).catch(() => {});
|
|
291
|
+
}, _e || (_e = !0, import("./api-BqRjtWm_.js").then((e) => e.i).then((e) => e.onApiEpoch((e, t) => {
|
|
292
|
+
t > 1 && ge?.();
|
|
293
|
+
})).catch(() => {})), await i.cloud.fs.setAdoptSource(o, a);
|
|
294
|
+
}, ye = !1, G = () => {
|
|
295
|
+
ye || typeof window > "u" || (ye = !0, window.addEventListener("online", () => {
|
|
296
|
+
L();
|
|
297
|
+
}), import("./account.js").then((e) => e.onChange(() => {
|
|
298
|
+
he().catch(() => {}), L();
|
|
299
|
+
})).catch(() => {}));
|
|
300
|
+
}, be = /* @__PURE__ */ e({
|
|
301
|
+
adopt: () => J,
|
|
302
|
+
adoptable: () => Y,
|
|
303
|
+
appendFile: () => Le,
|
|
304
|
+
appendFileSync: () => Te,
|
|
305
|
+
available: () => Se,
|
|
306
|
+
default: () => Je,
|
|
307
|
+
exists: () => Ue,
|
|
308
|
+
existsSync: () => Ee,
|
|
309
|
+
flush: () => Ke,
|
|
310
|
+
lstatSync: () => Oe,
|
|
311
|
+
mkdir: () => Be,
|
|
312
|
+
mkdirSync: () => Ae,
|
|
313
|
+
mount: () => Ge,
|
|
314
|
+
onConflict: () => $,
|
|
315
|
+
pending: () => X,
|
|
316
|
+
pendingDeletes: () => Z,
|
|
317
|
+
promises: () => We,
|
|
318
|
+
pull: () => q,
|
|
319
|
+
readFile: () => Fe,
|
|
320
|
+
readFileSync: () => Ce,
|
|
321
|
+
readdir: () => ze,
|
|
322
|
+
readdirSync: () => ke,
|
|
323
|
+
remount: () => qe,
|
|
324
|
+
rename: () => He,
|
|
325
|
+
renameSync: () => Pe,
|
|
326
|
+
replicating: () => Q,
|
|
327
|
+
rm: () => Ve,
|
|
328
|
+
rmSync: () => je,
|
|
329
|
+
rmdirSync: () => Me,
|
|
330
|
+
stat: () => Re,
|
|
331
|
+
statSync: () => De,
|
|
332
|
+
unlink: () => K,
|
|
333
|
+
unlinkSync: () => Ne,
|
|
334
|
+
writeFile: () => Ie,
|
|
335
|
+
writeFileSync: () => we
|
|
336
|
+
}), xe = n(f, { memfs: !0 }), { available: Se, readFileSync: Ce, writeFileSync: we, appendFileSync: Te, existsSync: Ee, statSync: De, lstatSync: Oe, readdirSync: ke, mkdirSync: Ae, rmSync: je, rmdirSync: Me, unlinkSync: Ne, renameSync: Pe, readFile: Fe, writeFile: Ie, appendFile: Le, stat: Re, readdir: ze, mkdir: Be, rm: Ve, unlink: K, rename: He, exists: Ue, promises: We, mount: Ge, flush: Ke, remount: qe } = xe, q = ue, J = H, Y = U, X = k, Z = A, Q = re, $ = B, Je = {
|
|
337
|
+
...xe,
|
|
338
|
+
pull: q,
|
|
339
|
+
adopt: J,
|
|
340
|
+
adoptable: Y,
|
|
341
|
+
pending: X,
|
|
342
|
+
pendingDeletes: Z,
|
|
343
|
+
replicating: Q,
|
|
344
|
+
onConflict: $
|
|
345
|
+
};
|
|
346
|
+
//#endregion
|
|
347
|
+
export { Me as A, ke as C, Q as D, Pe as E, Ie as F, we as I, De as M, K as N, Ve as O, Ne as P, ze as S, He as T, Z as _, Se as a, Fe as b, Ke as c, Oe as d, Be as f, X as g, $ as h, Te as i, Re as j, je as k, Je as l, Ge as m, Y as n, Ue as o, Ae as p, Le as r, Ee as s, J as t, be as u, We as v, qe as w, Ce as x, q as y };
|
package/fs.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./fs-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./fs-BUcpl9k4.cjs");exports.adopt=e.t,exports.adoptable=e.n,exports.appendFile=e.r,exports.appendFileSync=e.i,exports.available=e.a,exports.default=e.l,exports.exists=e.o,exports.existsSync=e.s,exports.flush=e.c,exports.lstatSync=e.d,exports.mkdir=e.f,exports.mkdirSync=e.p,exports.mount=e.m,exports.onConflict=e.h,exports.pending=e.g,exports.pendingDeletes=e._,exports.promises=e.v,exports.pull=e.y,exports.readFile=e.b,exports.readFileSync=e.x,exports.readdir=e.S,exports.readdirSync=e.C,exports.remount=e.w,exports.rename=e.T,exports.renameSync=e.E,exports.replicating=e.D,exports.rm=e.O,exports.rmSync=e.k,exports.rmdirSync=e.A,exports.stat=e.j,exports.statSync=e.M,exports.unlink=e.N,exports.unlinkSync=e.P,exports.writeFile=e.F,exports.writeFileSync=e.I;
|
package/fs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as e, C as t, D as n, E as r, F as i, I as a, M as o, N as s, O as c, P as l, S as u, T as d, _ as f, a as p, b as m, c as h, d as g, f as _, g as v, h as y, i as b, j as x, k as S, l as C, m as w, n as T, o as E, p as D, r as O, s as k, t as A, v as j, w as M, x as N, y as P } from "./fs-
|
|
1
|
+
import { A as e, C as t, D as n, E as r, F as i, I as a, M as o, N as s, O as c, P as l, S as u, T as d, _ as f, a as p, b as m, c as h, d as g, f as _, g as v, h as y, i as b, j as x, k as S, l as C, m as w, n as T, o as E, p as D, r as O, s as k, t as A, v as j, w as M, x as N, y as P } from "./fs-bpb3Ysdd.js";
|
|
2
2
|
export { A as adopt, T as adoptable, O as appendFile, b as appendFileSync, p as available, C as default, E as exists, k as existsSync, h as flush, g as lstatSync, _ as mkdir, D as mkdirSync, w as mount, y as onConflict, v as pending, f as pendingDeletes, j as promises, P as pull, m as readFile, N as readFileSync, u as readdir, t as readdirSync, M as remount, d as rename, r as renameSync, n as replicating, c as rm, S as rmSync, e as rmdirSync, x as stat, o as statSync, s as unlink, l as unlinkSync, i as writeFile, a as writeFileSync };
|
package/http.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./net-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./net-C2fIMWFr.cjs");let n=require("buffer"),r=require("stream");var i=e.t({Agent:()=>T,ClientRequest:()=>S,HTTPParser:()=>g,IncomingMessage:()=>v,METHODS:()=>o,STATUS_CODES:()=>s,Server:()=>w,ServerResponse:()=>b,_default:()=>A,createServer:()=>k,default:()=>A,get:()=>O,globalAgent:()=>E,request:()=>D}),a=new TextDecoder(`latin1`),o=`ACL.BIND.CHECKOUT.CONNECT.COPY.DELETE.GET.HEAD.LINK.LOCK.M-SEARCH.MERGE.MKACTIVITY.MKCALENDAR.MKCOL.MOVE.NOTIFY.OPTIONS.PATCH.POST.PROPFIND.PROPPATCH.PURGE.PUT.REBIND.REPORT.SEARCH.SOURCE.SUBSCRIBE.TRACE.UNBIND.UNLINK.UNLOCK.UNSUBSCRIBE`.split(`.`),s={100:`Continue`,101:`Switching Protocols`,102:`Processing`,103:`Early Hints`,200:`OK`,201:`Created`,202:`Accepted`,203:`Non-Authoritative Information`,204:`No Content`,205:`Reset Content`,206:`Partial Content`,207:`Multi-Status`,208:`Already Reported`,226:`IM Used`,300:`Multiple Choices`,301:`Moved Permanently`,302:`Found`,303:`See Other`,304:`Not Modified`,305:`Use Proxy`,307:`Temporary Redirect`,308:`Permanent Redirect`,400:`Bad Request`,401:`Unauthorized`,402:`Payment Required`,403:`Forbidden`,404:`Not Found`,405:`Method Not Allowed`,406:`Not Acceptable`,407:`Proxy Authentication Required`,408:`Request Timeout`,409:`Conflict`,410:`Gone`,411:`Length Required`,412:`Precondition Failed`,413:`Payload Too Large`,414:`URI Too Long`,415:`Unsupported Media Type`,416:`Range Not Satisfiable`,417:`Expectation Failed`,418:`I'm a Teapot`,421:`Misdirected Request`,422:`Unprocessable Entity`,423:`Locked`,424:`Failed Dependency`,425:`Too Early`,426:`Upgrade Required`,428:`Precondition Required`,429:`Too Many Requests`,431:`Request Header Fields Too Large`,451:`Unavailable For Legal Reasons`,500:`Internal Server Error`,501:`Not Implemented`,502:`Bad Gateway`,503:`Service Unavailable`,504:`Gateway Timeout`,505:`HTTP Version Not Supported`,506:`Variant Also Negotiates`,507:`Insufficient Storage`,508:`Loop Detected`,509:`Bandwidth Limit Exceeded`,510:`Not Extended`,511:`Network Authentication Required`},c=new Set([`content-type`,`content-length`,`user-agent`,`referer`,`host`,`authorization`,`proxy-authorization`,`if-modified-since`,`if-unmodified-since`,`from`,`location`,`max-forwards`,`retry-after`,`etag`,`last-modified`,`server`,`age`,`expires`]),l=13,u=10,d=/^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/,f=(e,t)=>(e.code=t,e),p=(e,t)=>{if(e.length===0)return t;if(t.length===0)return e;let n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n},m=(e,t)=>{for(let n=t;n+1<e.length;n++)if(e[n]===l&&e[n+1]===u)return n;return-1},h=e=>{for(let t=0;t+3<e.length;t++)if(e[t]===l&&e[t+1]===u&&e[t+2]===l&&e[t+3]===u)return t;return-1},g=class{mode;handlers;buf=new Uint8Array;state=`HEAD`;framing=`none`;bodyRemaining=0;chunkState=`size`;skipBody=!1;constructor(e,t){this.mode=e,this.handlers=t}execute(e){this.buf=p(this.buf,e);let t=!0;for(;t;)if(t=!1,this.state===`HEAD`){let e=h(this.buf);if(e===-1)return;let n=this.buf.subarray(0,e);this.buf=this.buf.subarray(e+4);let r=this.parseHead(n);this.handlers.onHeaders(r),this.setupBody(r),this.framing===`none`?(this.handlers.onComplete(),this.reset(),t=this.buf.length>0):(this.state=`BODY`,t=!0)}else this.consumeBody()&&(this.handlers.onComplete(),this.reset(),t=this.buf.length>0)}finish(){this.state===`BODY`&&this.framing===`eof`&&(this.handlers.onComplete(),this.reset())}reset(){this.state=`HEAD`,this.framing=`none`,this.bodyRemaining=0,this.chunkState=`size`,this.skipBody=!1}parseHead(e){let t=a.decode(e).split(`\r
|
|
2
2
|
`),n=t.shift()??``,r=[];for(let e of t)(e.startsWith(` `)||e.startsWith(` `))&&r.length>0?r[r.length-1]+=` `+e.trim():r.push(e);let i=[],o={};for(let e of r){if(!e)continue;let t=e.indexOf(`:`);if(t===-1)continue;let n=e.slice(0,t).trim(),r=e.slice(t+1).trim();i.push(n,r),this.addHeader(o,n,r)}let s={httpVersionMajor:1,httpVersionMinor:1,httpVersion:`1.1`,headers:o,rawHeaders:i};if(this.mode===`request`){let[e,t,r]=n.split(` `);s.method=(e??`GET`).toUpperCase(),s.url=t??`/`,this.applyVersion(s,r)}else{let e=n.indexOf(` `),t=n.slice(0,e),r=n.slice(e+1),i=r.indexOf(` `),a=i===-1?r:r.slice(0,i);s.statusCode=parseInt(a,10)||0,s.statusMessage=i===-1?``:r.slice(i+1),this.applyVersion(s,t)}return s}applyVersion(e,t){let n=/HTTP\/(\d)\.(\d)/i.exec(t??``);n&&(e.httpVersionMajor=parseInt(n[1],10),e.httpVersionMinor=parseInt(n[2],10),e.httpVersion=`${e.httpVersionMajor}.${e.httpVersionMinor}`)}addHeader(e,t,n){let r=t.toLowerCase();if(r===`set-cookie`){let t=e[`set-cookie`];Array.isArray(t)?t.push(n):e[`set-cookie`]=[n];return}let i=e[r];i===void 0?e[r]=n:c.has(r)||(e[r]=`${i}, ${n}`)}setupBody(e){if(this.skipBody){this.framing=`none`;return}let t=e.headers[`transfer-encoding`];if(typeof t==`string`&&t.toLowerCase().includes(`chunked`)){this.framing=`chunked`,this.chunkState=`size`;return}let n=e.headers[`content-length`];if(typeof n==`string`&&n!==``){let e=parseInt(n,10);e>0?(this.framing=`length`,this.bodyRemaining=e):this.framing=`none`;return}if(this.mode===`response`){let t=e.statusCode??0;t>=100&&t<200||t===204||t===304?this.framing=`none`:this.framing=`eof`}else this.framing=`none`}consumeBody(){if(this.framing===`length`){if(this.buf.length===0)return!1;let e=Math.min(this.bodyRemaining,this.buf.length);return this.handlers.onBody(this.buf.subarray(0,e)),this.buf=this.buf.subarray(e),this.bodyRemaining-=e,this.bodyRemaining===0}return this.framing===`eof`?(this.buf.length>0&&(this.handlers.onBody(this.buf),this.buf=new Uint8Array),!1):this.framing===`chunked`?this.consumeChunked():!0}consumeChunked(){for(;;)if(this.chunkState===`size`){let e=m(this.buf,0);if(e===-1)return!1;let t=a.decode(this.buf.subarray(0,e)),n=parseInt(t.split(`;`)[0].trim(),16);if(this.buf=this.buf.subarray(e+2),Number.isNaN(n))return!0;n===0?this.chunkState=`trailer`:(this.bodyRemaining=n,this.chunkState=`data`)}else if(this.chunkState===`data`){if(this.buf.length===0)return!1;let e=Math.min(this.bodyRemaining,this.buf.length);this.handlers.onBody(this.buf.subarray(0,e)),this.buf=this.buf.subarray(e),this.bodyRemaining-=e,this.bodyRemaining===0&&(this.chunkState=`dataCRLF`)}else if(this.chunkState===`dataCRLF`){if(this.buf.length<2)return!1;this.buf=this.buf.subarray(2),this.chunkState=`size`}else{let e=m(this.buf,0);if(e===-1)return!1;let t=e===0;if(this.buf=this.buf.subarray(e+2),t)return!0}}},_=(e,t)=>n.Buffer.isBuffer(e)?e:typeof e==`string`?n.Buffer.from(e,t??`utf8`):e instanceof Uint8Array?n.Buffer.from(e):e instanceof ArrayBuffer?n.Buffer.from(new Uint8Array(e)):n.Buffer.from(String(e)),v=class extends r.Stream.Readable{httpVersion=`1.1`;httpVersionMajor=1;httpVersionMinor=1;headers={};rawHeaders=[];trailers={};rawTrailers=[];method;url;statusCode;statusMessage;complete=!1;socket;constructor(e){super(),this.socket=e}get connection(){return this.socket}_applyHead(e){this.httpVersion=e.httpVersion,this.httpVersionMajor=e.httpVersionMajor,this.httpVersionMinor=e.httpVersionMinor,this.headers=e.headers,this.rawHeaders=e.rawHeaders,this.method=e.method,this.url=e.url,this.statusCode=e.statusCode,this.statusMessage=e.statusMessage}_read(){}setTimeout(e,t){return this.socket.setTimeout(e,t),this}},y=class extends r.Stream.Writable{_headerStore=new Map;headersSent=!1;chunkedEncoding=!1;finished=!1;_bodyWritten=!1;setHeader(e,t){if(this.headersSent)throw f(Error(`Cannot set headers after they are sent to the client`),`ERR_HTTP_HEADERS_SENT`);if(typeof e!=`string`||!d.test(e))throw f(TypeError(`Header name must be a valid HTTP token [${JSON.stringify(String(e))}]`),`ERR_INVALID_HTTP_TOKEN`);if(t===void 0)throw f(TypeError(`Invalid value "undefined" for header "${e}"`),`ERR_HTTP_INVALID_HEADER_VALUE`);return this._headerStore.set(e.toLowerCase(),[e,Array.isArray(t)?[...t]:t]),this}getHeader(e){return this._headerStore.get(e.toLowerCase())?.[1]}getHeaderNames(){return[...this._headerStore.values()].map(([e])=>e)}getHeaders(){let e={};for(let[t,n]of this._headerStore.values())e[t]=n;return e}hasHeader(e){return this._headerStore.has(e.toLowerCase())}removeHeader(e){if(this.headersSent)throw Error(`Cannot remove headers after they are sent to the client`);this._headerStore.delete(e.toLowerCase())}_storeHeader(e){let t=this.hasHeader(`content-length`),n=this.getHeader(`transfer-encoding`);typeof n==`string`&&n.toLowerCase().includes(`chunked`)?this.chunkedEncoding=!0:!t&&this._shouldSendBody()&&(this.chunkedEncoding=!0,this.setHeader(`Transfer-Encoding`,`chunked`));let r=e+`\r
|
|
3
3
|
`;for(let[e,t]of this._headerStore.values())if(Array.isArray(t))for(let n of t)r+=`${e}: ${n}\r\n`;else r+=`${e}: ${t}\r\n`;return r+=`\r
|
|
4
4
|
`,r}_writeToSocket(e,t){if(!this.socket){t(Error(`Socket is not available`));return}this.socket.write(e,t)}write(e,t,n){return this._bodyWritten=!0,super.write(e,t,n)}_write(e,t,r){let i=_(e),a=[];if(this.headersSent||=(this._implicitHeader(),a.push(n.Buffer.from(this._headBlock,`latin1`)),!0),this.chunkedEncoding?i.length>0&&(a.push(n.Buffer.from(`${i.length.toString(16)}\r\n`,`latin1`)),a.push(i),a.push(n.Buffer.from(`\r
|
package/http.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as Socket, t as Server$1 } from "./net-
|
|
1
|
+
import { n as Socket, t as Server$1 } from "./net-CnYxw_sB.js";
|
|
2
2
|
import { Buffer } from "buffer";
|
|
3
3
|
import { Stream } from "stream";
|
|
4
4
|
import { IncomingHttpHeaders, OutgoingHttpHeaders, RequestOptions } from "http";
|
package/http.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
2
|
-
import { n as t, t as n } from "./net-
|
|
2
|
+
import { n as t, t as n } from "./net-Ct8ywVAk.js";
|
|
3
3
|
import { Buffer as r } from "buffer";
|
|
4
4
|
import { Stream as i } from "stream";
|
|
5
5
|
//#region src/lib/webvpn/http.ts
|
|
@@ -118,6 +118,21 @@ type SelectorModule = {
|
|
|
118
118
|
};
|
|
119
119
|
type OperationModule = {
|
|
120
120
|
resolve: (context: LocatorContext, ...args: any[]) => unknown;
|
|
121
|
+
/**
|
|
122
|
+
* Pins the operation to one chain kind, opting it out of the executor's cross-kind fallback.
|
|
123
|
+
*
|
|
124
|
+
* That fallback is deliberate and load bearing in the frame-to-element direction:
|
|
125
|
+
* `frameLocator('#f').click()` resolves to kind `frame`, the frame kind has no `click`, and the
|
|
126
|
+
* element `click` then runs against the child's `documentElement`. It is also bidirectional, so
|
|
127
|
+
* without this an operation registered only on the `frame` kind is silently reachable from an
|
|
128
|
+
* element chain too.
|
|
129
|
+
*
|
|
130
|
+
* For most operations that is a convenience. For one whose whole meaning is WHICH REALM it runs
|
|
131
|
+
* in, it is a silent identity confusion: `locator('#x').fetch()` would run in the document that
|
|
132
|
+
* CONTAINS `#x` while reading as though it ran in `#x`. Pin those, so the wrong spelling is
|
|
133
|
+
* refused by name instead of quietly doing something else.
|
|
134
|
+
*/
|
|
135
|
+
kind?: ChainKind;
|
|
121
136
|
};
|
|
122
137
|
type KindModules = {
|
|
123
138
|
selectors: Record<string, SelectorModule>;
|
|
@@ -160,6 +175,46 @@ type AddStyleTagOptions$1 = OperationOptions & {
|
|
|
160
175
|
noSanitize?: boolean;
|
|
161
176
|
};
|
|
162
177
|
//#endregion
|
|
178
|
+
//#region node_modules/@mfkn/frame-locator/lib/fetch.d.ts
|
|
179
|
+
/**
|
|
180
|
+
* A request issued from the realm the chain LANDS in, so the browser supplies that document's own
|
|
181
|
+
* identity: its cookie jar (partitioned, on the extension path), its `Origin`, its `Referer` and its
|
|
182
|
+
* `Sec-Fetch-*`. Nothing here synthesizes any of those, which is the point: a synthesized initiator is
|
|
183
|
+
* exactly the degraded shape a CSRF-protected private API refuses.
|
|
184
|
+
*
|
|
185
|
+
* This module is the MECHANISM only. It carries no allowlist and no consent, because frame-locator has
|
|
186
|
+
* no idea what an app is. The consumer gates it: in the FKN extension that is `LOCATOR_PERMISSIONS`,
|
|
187
|
+
* whose `satisfies Record<LocatorOperation, OperationPermission>` makes registering this operation
|
|
188
|
+
* without a permission a type error, plus an authoritative origin check in the content-script resolver.
|
|
189
|
+
* Do not add a "convenience" path that skips the consumer's gate.
|
|
190
|
+
*/
|
|
191
|
+
type FrameFetchInit = OperationOptions & {
|
|
192
|
+
method?: string;
|
|
193
|
+
headers?: Record<string, string> | [string, string][];
|
|
194
|
+
body?: string | ArrayBuffer | null;
|
|
195
|
+
redirect?: RequestRedirect;
|
|
196
|
+
/**
|
|
197
|
+
* `include` by default, which is the whole capability: the frame spends the session it holds. An
|
|
198
|
+
* app that wants a cookieless request has an ordinary fetch for that and does not need this.
|
|
199
|
+
*/
|
|
200
|
+
credentials?: RequestCredentials;
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* Deliberately NOT a `Response`. It crosses at least one RPC boundary, and a `Response` rebuilt on the
|
|
204
|
+
* far side with `new Response()` would be a different object with different headers anyway, so the
|
|
205
|
+
* shape says plainly what actually survives.
|
|
206
|
+
*/
|
|
207
|
+
type FrameFetchResult = {
|
|
208
|
+
status: number;
|
|
209
|
+
statusText: string;
|
|
210
|
+
ok: boolean; /** Where the response came from AFTER redirects, which is the only honest answer to "who replied". */
|
|
211
|
+
url: string;
|
|
212
|
+
redirected: boolean;
|
|
213
|
+
type: ResponseType;
|
|
214
|
+
headers: [string, string][];
|
|
215
|
+
body: ArrayBuffer;
|
|
216
|
+
};
|
|
217
|
+
//#endregion
|
|
163
218
|
//#region node_modules/@mfkn/frame-locator/lib/operations.d.ts
|
|
164
219
|
type PositionOptions$1 = OperationOptions & {
|
|
165
220
|
position?: {
|
|
@@ -289,6 +344,10 @@ declare const defaultModules: {
|
|
|
289
344
|
readonly addStyleTag: {
|
|
290
345
|
readonly resolve: (context: LocatorContext, options: AddStyleTagOptions$1) => void;
|
|
291
346
|
};
|
|
347
|
+
readonly fetch: {
|
|
348
|
+
readonly kind: ChainKind;
|
|
349
|
+
readonly resolve: (context: LocatorContext, url: string, init?: FrameFetchInit) => Promise<FrameFetchResult>;
|
|
350
|
+
};
|
|
292
351
|
};
|
|
293
352
|
};
|
|
294
353
|
};
|
|
@@ -450,6 +509,7 @@ type AddStyleTagOptions = LocatorOptions & {
|
|
|
450
509
|
content: string;
|
|
451
510
|
noSanitize?: boolean;
|
|
452
511
|
};
|
|
512
|
+
type FrameFetchOptions = LocatorOptions & FrameFetchInit;
|
|
453
513
|
declare const locatorModules: Extended<{
|
|
454
514
|
readonly element: {
|
|
455
515
|
readonly selectors: {
|
|
@@ -570,6 +630,10 @@ declare const locatorModules: Extended<{
|
|
|
570
630
|
readonly addStyleTag: {
|
|
571
631
|
readonly resolve: (context: LocatorContext, options: AddStyleTagOptions$1) => void;
|
|
572
632
|
};
|
|
633
|
+
readonly fetch: {
|
|
634
|
+
readonly kind: ChainKind;
|
|
635
|
+
readonly resolve: (context: LocatorContext, url: string, init?: FrameFetchInit) => Promise<FrameFetchResult>;
|
|
636
|
+
};
|
|
573
637
|
};
|
|
574
638
|
};
|
|
575
639
|
}, {
|
|
@@ -609,6 +673,10 @@ declare const locatorModules: Extended<{
|
|
|
609
673
|
addStyleTag: {
|
|
610
674
|
resolve: (context: LocatorContext, options: AddStyleTagOptions) => void;
|
|
611
675
|
};
|
|
676
|
+
fetch: {
|
|
677
|
+
resolve: (context: LocatorContext, url: string, init?: FrameFetchOptions) => Promise<FrameFetchResult>;
|
|
678
|
+
kind: ChainKind;
|
|
679
|
+
};
|
|
612
680
|
};
|
|
613
681
|
};
|
|
614
682
|
}>;
|
|
@@ -754,6 +822,20 @@ declare const PERMISSIONS: readonly [{
|
|
|
754
822
|
readonly severity: 0;
|
|
755
823
|
readonly title: 'Open a website inside this app';
|
|
756
824
|
readonly description: 'Lets the app navigate to another site without leaving its window.';
|
|
825
|
+
}, {
|
|
826
|
+
readonly scope: 'frame.fetchRead';
|
|
827
|
+
readonly category: 'network';
|
|
828
|
+
readonly severity: 3;
|
|
829
|
+
readonly unsafe: true;
|
|
830
|
+
readonly title: 'Read your account data on this site';
|
|
831
|
+
readonly description: 'Lets the app read pages and data from this site as you, using the session in the frame.';
|
|
832
|
+
}, {
|
|
833
|
+
readonly scope: 'frame.fetchWrite';
|
|
834
|
+
readonly category: 'network';
|
|
835
|
+
readonly severity: 3;
|
|
836
|
+
readonly unsafe: true;
|
|
837
|
+
readonly title: 'Change your account data on this site';
|
|
838
|
+
readonly description: 'Lets the app send changes to this site as you, using the session in the frame.';
|
|
757
839
|
}, {
|
|
758
840
|
readonly scope: 'network.fetch';
|
|
759
841
|
readonly category: 'network';
|