@fkn/lib 0.9.15 → 0.9.17
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 +1 -1
- package/api-DLGGoSnx.cjs +3 -0
- package/{api-B6FNNKl0.d.ts → api-Dhc2hNCz.d.ts} +1 -26
- package/{api-DAQQBty8.js → api-X8SBbrBZ.js} +97 -72
- 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.d.ts +3 -2
- package/cloud/fs.js +21 -18
- package/cloud/net.cjs +1 -1
- package/cloud/net.d.ts +1 -1
- package/cloud/net.js +1 -1
- package/{cloud-9cCFUQiG.cjs → cloud-CcKsidlt.cjs} +1 -1
- package/{cloud--8SYg1so.d.ts → cloud-CvEqxYM6.d.ts} +3 -3
- package/{cloud-DWnpupeb.js → cloud-DohLHbg2.js} +4 -4
- package/cloud.cjs +1 -1
- package/cloud.d.ts +4 -4
- package/cloud.js +4 -4
- package/dgram-CW53Betg.cjs +1 -0
- package/{dgram-BDXvc69t.js → dgram-qpKjZosS.js} +15 -8
- package/dgram.cjs +1 -1
- package/dgram.d.ts +56 -1
- package/dgram.js +1 -1
- package/dns.cjs +1 -1
- package/dns.js +1 -1
- package/{extension-DPlyfEPO.cjs → extension-1l_UXQsi.cjs} +1 -1
- package/{extension-xVdvgkZL.js → extension-DQcp_LKK.js} +2 -2
- package/extension.cjs +1 -1
- package/extension.js +1 -1
- package/fs/promises.cjs +1 -1
- package/fs/promises.js +1 -1
- package/{fs-MJ2u5qvV.js → fs-B-NZzzSX.js} +58 -58
- package/{fs-DKseuFE2.cjs → fs-C5L6CqmF.cjs} +1 -1
- package/{fs-DTmSCXwa.d.ts → fs-D5LFP4_n.d.ts} +23 -2
- 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.cjs +1 -1
- package/index.d.ts +2 -2
- package/index.js +6 -6
- package/{net-BDAN5Mvc.js → net-B-LNnKps.js} +1 -1
- package/{net-BnGcJpUb.d.ts → net-BtdN07IP.d.ts} +1 -1
- package/{net-kma1sFhK.cjs → net-luhw3yr7.cjs} +1 -1
- package/net.cjs +1 -1
- package/net.d.ts +1 -1
- package/net.js +1 -1
- package/package.json +1 -1
- package/packages.cjs +1 -1
- package/packages.js +1 -1
- package/{proxy-BsimoT14.cjs → proxy-B0W1qzCo.cjs} +1 -1
- package/{proxy-BthoIRuv.js → proxy-CtS_JiZL.js} +1 -1
- package/{proxy-BihVUSnB.d.ts → proxy-etZJARWe.d.ts} +1 -1
- package/storage-CXIXrIxB.d.ts +38 -0
- package/storage-D2a8SsY5.cjs +1 -0
- package/storage-XKGhInxm.js +37 -0
- package/api-D5ioM3pa.cjs +0 -3
- package/dgram-C1E6TUWN.cjs +0 -1
- package/storage-DRhPPtAl.js +0 -30
- package/storage-Di1ZseFg.cjs +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
2
|
-
import { t } from "./api-
|
|
2
|
+
import { t } from "./api-X8SBbrBZ.js";
|
|
3
3
|
import { l as n, n as r, o as i, s as a } from "./utils-DVlbuXmW.js";
|
|
4
4
|
import { Buffer as o } from "buffer";
|
|
5
5
|
import { EventEmitter as s } from "events";
|
|
@@ -25,7 +25,7 @@ var u = /* @__PURE__ */ e({
|
|
|
25
25
|
_peerTailCache = /* @__PURE__ */ new Map();
|
|
26
26
|
constructor(e) {
|
|
27
27
|
if (super(e), !e) throw Error("Missing options");
|
|
28
|
-
this._type = e.type;
|
|
28
|
+
this._type = e.type, e.connection && this.__webvpn_udp_socket_init__(e.connection);
|
|
29
29
|
}
|
|
30
30
|
_lastRecvBufferSize = 0;
|
|
31
31
|
_lastSendBufferSize = 0;
|
|
@@ -141,13 +141,22 @@ var u = /* @__PURE__ */ e({
|
|
|
141
141
|
return this._localAddress;
|
|
142
142
|
}
|
|
143
143
|
bind(...e) {
|
|
144
|
-
let n = i(...e), r = this._type === "udp6" ? "::" : "0.0.0.0"
|
|
145
|
-
return this._webVPNUdpSocketPromise = t.then((e) => e.cloud.webvpn.udpSocket({
|
|
144
|
+
let n = i(...e), r = this._type === "udp6" ? "::" : "0.0.0.0", a = this.__webvpn_udp_socket_init__(t.then((e) => e.cloud.webvpn.udpSocket({
|
|
146
145
|
type: this._type,
|
|
147
146
|
address: n.address ?? r,
|
|
148
147
|
port: n.port,
|
|
149
148
|
dataPort: !0
|
|
150
|
-
}))
|
|
149
|
+
})));
|
|
150
|
+
return n.callback && a.then((e) => {
|
|
151
|
+
e && n.callback.call(this);
|
|
152
|
+
}), this;
|
|
153
|
+
}
|
|
154
|
+
__webvpn_udp_socket_init__(e, t) {
|
|
155
|
+
return t && (this._localAddress = {
|
|
156
|
+
address: t.localAddress,
|
|
157
|
+
family: t.localFamily,
|
|
158
|
+
port: t.localPort
|
|
159
|
+
}), this._webVPNUdpSocketPromise = e.then((e) => {
|
|
151
160
|
if (e.dataPort) this._socketId = e.socketId, this._dataPort = e.dataPort, this._dataPortAcks = e.dataPortAcks === !0, this._dataPort.onmessage = (e) => {
|
|
152
161
|
try {
|
|
153
162
|
this._onDataPortBatch(e.data);
|
|
@@ -179,9 +188,7 @@ var u = /* @__PURE__ */ e({
|
|
|
179
188
|
this.emit("error", e);
|
|
180
189
|
}), this._webVPNUdpSocketPromise.then((e) => {
|
|
181
190
|
e && this.emit("listening");
|
|
182
|
-
}),
|
|
183
|
-
e && n.callback.call(this);
|
|
184
|
-
}), this;
|
|
191
|
+
}), this._webVPNUdpSocketPromise;
|
|
185
192
|
}
|
|
186
193
|
close(e) {
|
|
187
194
|
if (!this._webVPNUdpSocketPromise) throw Error("Socket not bound");
|
package/dgram.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./dgram-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./dgram-CW53Betg.cjs");exports.Socket=e.t,exports.createSocket=e.n,exports.default=e.r;
|
package/dgram.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as UdpSocketOption, t as Resolvers } from "./api-
|
|
1
|
+
import { n as UdpSocketOption, t as Resolvers } from "./api-Dhc2hNCz.js";
|
|
2
2
|
import { Buffer } from "buffer";
|
|
3
3
|
import { AddressInfo } from "net";
|
|
4
4
|
import { EventEmitter } from "events";
|
|
@@ -60,6 +60,61 @@ declare class Socket extends EventEmitter implements Socket$2 {
|
|
|
60
60
|
bind(port?: number | undefined, callback?: (() => void) | undefined): this;
|
|
61
61
|
bind(callback?: (() => void) | undefined): this;
|
|
62
62
|
bind(options: BindOptions, callback?: (() => void) | undefined): this;
|
|
63
|
+
/**
|
|
64
|
+
* Wire a datagram socket up from a connection already in hand, and report it as bound.
|
|
65
|
+
*
|
|
66
|
+
* `endpoints` publishes the local address SYNCHRONOUSLY, for the same reason net.ts's TCP
|
|
67
|
+
* equivalent does: `address()` throws EBADF until the promise below resolves, so a caller that
|
|
68
|
+
* reads it in the same turn as the bind gets an exception rather than the answer. Node fills an
|
|
69
|
+
* address in before it reports a socket as bound.
|
|
70
|
+
*
|
|
71
|
+
* Splitting this out of `bind()` is also what gives a test a seam. Everything a refused bind does
|
|
72
|
+
* lives past `apiPromise`, so without this the only way to reach it is to mock the resolver, and
|
|
73
|
+
* the guard on that path stayed untested through the whole period the relay could not refuse a
|
|
74
|
+
* bind at all.
|
|
75
|
+
*/
|
|
76
|
+
__webvpn_udp_socket_init__(connection: ReturnType<WebVpnUdpSocket>, endpoints?: Awaited<ReturnType<WebVpnUdpSocket>>): Promise<{
|
|
77
|
+
socketId: number;
|
|
78
|
+
dataPort: MessagePort | undefined;
|
|
79
|
+
dataPortAcks: true | undefined;
|
|
80
|
+
closed: Promise<{
|
|
81
|
+
reason: string;
|
|
82
|
+
}>;
|
|
83
|
+
localAddress: string;
|
|
84
|
+
localFamily: "IPv4" | "IPv6";
|
|
85
|
+
localPort: number;
|
|
86
|
+
dataReadableStream: ReadableStream<{
|
|
87
|
+
data: ArrayBuffer;
|
|
88
|
+
size: number;
|
|
89
|
+
family: 'IPv4' | 'IPv6';
|
|
90
|
+
address: string;
|
|
91
|
+
port: number;
|
|
92
|
+
}>;
|
|
93
|
+
connect: ({
|
|
94
|
+
remoteAddress: _remoteAddress,
|
|
95
|
+
remotePort
|
|
96
|
+
}: {
|
|
97
|
+
remoteAddress: string;
|
|
98
|
+
remotePort: number;
|
|
99
|
+
}) => Promise<{
|
|
100
|
+
local: boolean;
|
|
101
|
+
address: string;
|
|
102
|
+
family: "IPv4" | "IPv6";
|
|
103
|
+
port: number;
|
|
104
|
+
}>;
|
|
105
|
+
disconnect: () => Promise<void>;
|
|
106
|
+
send: ({
|
|
107
|
+
message,
|
|
108
|
+
address: _remoteAddress,
|
|
109
|
+
port: remotePort
|
|
110
|
+
}: {
|
|
111
|
+
message: ArrayBuffer;
|
|
112
|
+
address?: string;
|
|
113
|
+
port?: number;
|
|
114
|
+
}) => Promise<void>;
|
|
115
|
+
close: () => Promise<void>;
|
|
116
|
+
setOption: (option: UdpSocketOption) => Promise<void>;
|
|
117
|
+
} | undefined>;
|
|
63
118
|
close(callback?: (() => void) | undefined): this;
|
|
64
119
|
connect(port: number, address?: string, callback?: () => void): void;
|
|
65
120
|
connect(port: number, callback: () => void): void;
|
package/dgram.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as e, r as t, t as n } from "./dgram-
|
|
1
|
+
import { n as e, r as t, t as n } from "./dgram-qpKjZosS.js";
|
|
2
2
|
export { n as Socket, e as createSocket, t as default };
|
package/dns.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./api-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./api-DLGGoSnx.cjs");var n=e.t({lookup:()=>r}),r=(e,n)=>t.t.then(t=>t.cloud.dns.lookup(e,n));exports.lookup=r,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return n}});
|
package/dns.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
2
|
-
import { t } from "./api-
|
|
2
|
+
import { t } from "./api-X8SBbrBZ.js";
|
|
3
3
|
//#region src/lib/dns.ts
|
|
4
4
|
var n = /* @__PURE__ */ e({ lookup: () => r }), r = (e, n) => t.then((t) => t.cloud.dns.lookup(e, n));
|
|
5
5
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./lib-ulyxIbTr.cjs"),n=require("./api-
|
|
1
|
+
const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./lib-ulyxIbTr.cjs"),n=require("./api-DLGGoSnx.cjs"),r=require("./proxy-B0W1qzCo.cjs"),i=require("./desktop.cjs");var a=async e=>{if(typeof window>`u`)return!1;if(t.P())return!0;let r=await n.t,i=null,a=new Promise(e=>{i=()=>{t.P()&&e(!0)},t.N.addEventListener(`statuschange`,i)}),o=r.installPrompt.show(e).then(()=>!1),s=await Promise.race([a,o]);return i&&t.N.removeEventListener(`statuschange`,i),await r.installPrompt.hide().catch(()=>{}),s},o=null;t.F(()=>(o||=a().then(()=>void 0).finally(()=>{o=null}),o));var s=()=>typeof document<`u`&&t.P(),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.C(e,n)}return s()?t.C(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.k,LOCATOR_DENIED:()=>t.g,LOCATOR_ERROR:()=>t.u,LOCATOR_UNSUPPORTED:()=>t.h,assertAttachableFrameUrl:()=>t.s,assertFetchableUrl:()=>t.S,assertForgeableHeaders:()=>t.A,assertLockdownApplicable:()=>t.c,assertOneCookieIdentity:()=>t.j,attachFrame:()=>t.r,attachFramePermission:()=>t.i,available:()=>s,box:()=>t.R,cookies:()=>t.b,createFrame:()=>t.a,createVideoElementHandle:()=>t.z,events:()=>t.N,extension:()=>t.N,fetch:()=>t.C,fetchCredentialedPermission:()=>t.w,fetchLocalPermission:()=>t.T,fetchPermission:()=>t.E,gotoPermission:()=>t.o,handleRevivableModules:()=>t.L,hasForgedCookie:()=>t.M,isBlockedFetchUrl:()=>t.D,isBlockedFrameUrl:()=>t.l,isExtensionExposed:()=>t.P,isLocalNetworkUrl:()=>t.O,isLocatorDenied:()=>t.d,isLocatorUnsupported:()=>t.m,isTerminalError:()=>t.p,isType:()=>t.B,modifyRequestHeadersPermission:()=>t._,permissions:()=>t.t,promptInstall:()=>a,readCookiePermission:()=>t.x,removeRequestHeaderRule:()=>t.v,revive:()=>t.V,setMissingExtensionHandler:()=>t.F,setRequestHeaderRule:()=>t.y,type:()=>t.H,waitForExtensionExposure:()=>t.I});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}});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
2
2
|
import { A as t, B as n, C as r, D as i, E as a, F as o, H as s, I as c, L as l, M as u, N as d, O as f, P as p, R as m, S as h, T as g, V as _, _ as v, a as y, b, c as x, d as S, g as C, h as w, i as T, j as E, k as D, l as O, m as k, n as A, o as j, p as M, r as N, s as P, t as F, u as I, v as L, w as R, x as z, y as B, z as V } from "./lib-CegQxwDI.js";
|
|
3
|
-
import { t as H } from "./api-
|
|
4
|
-
import { n as U, t as W } from "./proxy-
|
|
3
|
+
import { t as H } from "./api-X8SBbrBZ.js";
|
|
4
|
+
import { n as U, t as W } from "./proxy-CtS_JiZL.js";
|
|
5
5
|
import { available as G, fetch as K } from "./desktop.js";
|
|
6
6
|
//#region src/lib/extension-prompt.ts
|
|
7
7
|
var q = async (e) => {
|
package/extension.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./lib-ulyxIbTr.cjs"),t=require("./extension-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./lib-ulyxIbTr.cjs"),t=require("./extension-1l_UXQsi.cjs");exports.ATTACH_FRAME_EVENT_KEY=e.n,exports.FORGEABLE_HEADERS=e.k,exports.LOCATOR_DENIED=e.g,exports.LOCATOR_ERROR=e.u,exports.LOCATOR_UNSUPPORTED=e.h,exports.assertAttachableFrameUrl=e.s,exports.assertFetchableUrl=e.S,exports.assertForgeableHeaders=e.A,exports.assertLockdownApplicable=e.c,exports.assertOneCookieIdentity=e.j,exports.attachFrame=e.r,exports.attachFramePermission=e.i,exports.available=t.r,exports.box=e.R,exports.cookies=e.b,exports.createFrame=e.a,exports.createVideoElementHandle=e.z,exports.events=e.N,exports.extension=e.N,exports.fetch=e.C,exports.fetchCredentialedPermission=e.w,exports.fetchLocalPermission=e.T,exports.fetchPermission=e.E,exports.gotoPermission=e.o,exports.handleRevivableModules=e.L,exports.hasForgedCookie=e.M,exports.isBlockedFetchUrl=e.D,exports.isBlockedFrameUrl=e.l,exports.isExtensionExposed=e.P,exports.isLocalNetworkUrl=e.O,exports.isLocatorDenied=e.d,exports.isLocatorUnsupported=e.m,exports.isTerminalError=e.p,exports.isType=e.B,exports.modifyRequestHeadersPermission=e._,exports.permissions=e.t,exports.promptInstall=t.i,exports.readCookiePermission=e.x,exports.removeRequestHeaderRule=e.v,exports.revive=e.V,exports.setMissingExtensionHandler=e.F,exports.setRequestHeaderRule=e.y,exports.type=e.H,exports.waitForExtensionExposure=e.I;
|
package/extension.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
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, V as g, _, 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-CegQxwDI.js";
|
|
2
|
-
import { i as V, r as H } from "./extension-
|
|
2
|
+
import { i as V, r as H } from "./extension-DQcp_LKK.js";
|
|
3
3
|
export { k as ATTACH_FRAME_EVENT_KEY, E as FORGEABLE_HEADERS, S as LOCATOR_DENIED, F as LOCATOR_ERROR, C as LOCATOR_UNSUPPORTED, N as assertAttachableFrameUrl, m as assertFetchableUrl, e as assertForgeableHeaders, b as assertLockdownApplicable, T as assertOneCookieIdentity, M as attachFrame, w as attachFramePermission, H as available, p as box, y as cookies, v as createFrame, B as createVideoElementHandle, u as events, u as extension, n as fetch, L as fetchCredentialedPermission, h as fetchLocalPermission, i as fetchPermission, A as gotoPermission, c as handleRevivableModules, l as hasForgedCookie, r as isBlockedFetchUrl, D as isBlockedFrameUrl, f as isExtensionExposed, d as isLocalNetworkUrl, x as isLocatorDenied, O as isLocatorUnsupported, j as isTerminalError, t as isType, _ as modifyRequestHeadersPermission, P as permissions, V as promptInstall, R as readCookiePermission, I as removeRequestHeaderRule, g as revive, a as setMissingExtensionHandler, z as setRequestHeaderRule, o as type, s 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-C5L6CqmF.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-B-NZzzSX.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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
2
2
|
import { t } from "./node-fs-DKfokOlh.js";
|
|
3
|
-
import {
|
|
3
|
+
import { c as n, f as r, l as i, o as a, r as o } from "./storage-XKGhInxm.js";
|
|
4
4
|
import { a as s, i as c, n as l, o as u, t as d } from "./opfs-BibrNGF0.js";
|
|
5
5
|
//#region src/lib/fs/hybrid.ts
|
|
6
6
|
var f = /* @__PURE__ */ e({
|
|
@@ -16,7 +16,7 @@ var f = /* @__PURE__ */ e({
|
|
|
16
16
|
remove: () => se,
|
|
17
17
|
replicating: () => k,
|
|
18
18
|
writeFile: () => oe
|
|
19
|
-
}), ee, p = async () => await (ee ??= d().catch(() => !1)) ? !0 : (ee = void 0, !1), m = () =>
|
|
19
|
+
}), ee, p = async () => await (ee ??= d().catch(() => !1)) ? !0 : (ee = void 0, !1), m = () => o().catch(() => !1), te = async () => await p() || await m(), h = "fkn:fs:pending", g = "fkn:fs:pending-delete", _ = "fkn:fs:adopt-declined", v = !0, y = /* @__PURE__ */ new Map(), b = (e) => {
|
|
20
20
|
try {
|
|
21
21
|
let t = localStorage.getItem(e);
|
|
22
22
|
if (!t) return {};
|
|
@@ -41,9 +41,9 @@ var f = /* @__PURE__ */ e({
|
|
|
41
41
|
}, E = (e) => {
|
|
42
42
|
let t = T();
|
|
43
43
|
e in t && (delete t[e], x(g, t));
|
|
44
|
-
}, D = () => Object.keys(S()), O = () => Object.keys(T()), k = () => v, A = null, re = null, j = () => re ??= import("./api-
|
|
44
|
+
}, D = () => Object.keys(S()), O = () => Object.keys(T()), k = () => v, A = null, re = null, j = () => re ??= import("./api-X8SBbrBZ.js").then((e) => e.n).then((e) => e.apiPromise), ie = async () => {
|
|
45
45
|
me();
|
|
46
|
-
let e = await m(), [t,
|
|
46
|
+
let e = await m(), [t, n] = await Promise.all([p().then((e) => e ? l() : []).catch(() => []), e ? a().then((e) => ({
|
|
47
47
|
ok: !0,
|
|
48
48
|
entries: e
|
|
49
49
|
})).catch(() => ({
|
|
@@ -53,60 +53,60 @@ var f = /* @__PURE__ */ e({
|
|
|
53
53
|
ok: !0,
|
|
54
54
|
entries: []
|
|
55
55
|
})]);
|
|
56
|
-
v =
|
|
57
|
-
let
|
|
56
|
+
v = n.ok, n.ok && (y = new Map(n.entries.map((e) => [e.path, e.updatedAt])));
|
|
57
|
+
let r = /* @__PURE__ */ new Map(), i = (e) => {
|
|
58
58
|
let t = Date.parse(e.updatedAt ?? "");
|
|
59
59
|
return Number.isFinite(t) ? t : 0;
|
|
60
60
|
}, o = (e) => {
|
|
61
|
-
let t =
|
|
62
|
-
(!t ||
|
|
61
|
+
let t = r.get(e.path);
|
|
62
|
+
(!t || i(e) >= i(t)) && r.set(e.path, e);
|
|
63
63
|
};
|
|
64
64
|
for (let e of t) o(e);
|
|
65
|
-
for (let e of
|
|
66
|
-
if (
|
|
67
|
-
pe(t,
|
|
65
|
+
for (let e of n.entries) o(e);
|
|
66
|
+
if (n.ok && e) {
|
|
67
|
+
pe(t, n.entries).catch(() => {});
|
|
68
68
|
let e = Object.keys(S()).length || Object.keys(T()).length;
|
|
69
69
|
e && !A ? A = P(!1).catch(() => {}).finally(() => {
|
|
70
70
|
A = null;
|
|
71
71
|
}) : e || R({
|
|
72
72
|
local: t,
|
|
73
|
-
remote:
|
|
73
|
+
remote: n.entries
|
|
74
74
|
}).catch(() => {});
|
|
75
75
|
}
|
|
76
|
-
return [...
|
|
76
|
+
return [...r.values()];
|
|
77
77
|
}, ae = async (e) => {
|
|
78
78
|
if (await p()) try {
|
|
79
79
|
return await c(e);
|
|
80
80
|
} catch (e) {
|
|
81
81
|
if (e?.name !== "NotFoundError") throw e;
|
|
82
82
|
}
|
|
83
|
-
let t = await
|
|
83
|
+
let t = await n(e);
|
|
84
84
|
return await p() && u(e, t).catch(() => {}), t;
|
|
85
85
|
}, oe = async (e, t, n) => {
|
|
86
|
-
let
|
|
86
|
+
let i = t instanceof Blob ? t : new Blob([t], n?.contentType ? { type: n.contentType } : void 0);
|
|
87
87
|
if (await p()) {
|
|
88
|
-
if (await u(e,
|
|
88
|
+
if (await u(e, i, n), !await m()) return;
|
|
89
89
|
if (!v) {
|
|
90
90
|
C(e);
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
|
-
|
|
93
|
+
r(e, i, n).then(() => w(e)).catch((t) => {
|
|
94
94
|
C(e), console.warn("fs: cloud replicate failed, queued for adopt()", t);
|
|
95
95
|
});
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
|
-
if (await m()) return
|
|
98
|
+
if (await m()) return r(e, i, n);
|
|
99
99
|
throw Error("fs: no storage backend available");
|
|
100
100
|
}, se = async (e) => {
|
|
101
101
|
let t = [];
|
|
102
102
|
await p() && t.push(s(e).catch(() => {}));
|
|
103
103
|
let n = await m();
|
|
104
|
-
if (n && t.push(
|
|
104
|
+
if (n && t.push(i(e).then(() => E(e)).catch((t) => {
|
|
105
105
|
ne(e), console.warn("fs: cloud delete failed, queued for retry", t);
|
|
106
106
|
})), !t.length) throw Error("fs: no storage backend available");
|
|
107
107
|
n && w(e), await Promise.all(t);
|
|
108
108
|
}, ce = async (e) => {
|
|
109
|
-
let t = await
|
|
109
|
+
let t = await n(e);
|
|
110
110
|
return await p() && await u(e, t), t;
|
|
111
111
|
}, M = null, N = (e) => (M = e, () => {
|
|
112
112
|
M === e && (M = null);
|
|
@@ -132,23 +132,23 @@ var f = /* @__PURE__ */ e({
|
|
|
132
132
|
};
|
|
133
133
|
if (!await m()) throw Error("fs: this needs a signed-in account");
|
|
134
134
|
if (!await p()) return t;
|
|
135
|
-
let [
|
|
135
|
+
let [o, s] = await Promise.all([l(), a()]), d = new Map(s.map((e) => [e.path, e])), f = S();
|
|
136
136
|
for (let [e, n] of Object.entries(T())) {
|
|
137
|
-
let
|
|
138
|
-
if (!
|
|
137
|
+
let r = d.get(e);
|
|
138
|
+
if (!r) {
|
|
139
139
|
E(e);
|
|
140
140
|
continue;
|
|
141
141
|
}
|
|
142
|
-
if (
|
|
142
|
+
if (o.some((t) => t.path === e)) {
|
|
143
143
|
E(e);
|
|
144
144
|
continue;
|
|
145
145
|
}
|
|
146
|
-
if (
|
|
146
|
+
if (r.updatedAt !== n) {
|
|
147
147
|
E(e);
|
|
148
148
|
continue;
|
|
149
149
|
}
|
|
150
150
|
try {
|
|
151
|
-
await
|
|
151
|
+
await i(e), E(e), t.deleted.push(e);
|
|
152
152
|
} catch (n) {
|
|
153
153
|
t.failed.push({
|
|
154
154
|
path: e,
|
|
@@ -156,56 +156,56 @@ var f = /* @__PURE__ */ e({
|
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
for (let
|
|
160
|
-
let
|
|
161
|
-
if (!
|
|
162
|
-
|
|
159
|
+
for (let i of o) {
|
|
160
|
+
let a = d.get(i.path), o = i.path in f;
|
|
161
|
+
if (!o && (a || !e)) {
|
|
162
|
+
a && t.kept.push(i.path);
|
|
163
163
|
continue;
|
|
164
164
|
}
|
|
165
|
-
if (
|
|
165
|
+
if (o && a && a.updatedAt !== f[i.path]) {
|
|
166
166
|
let e = await ue({
|
|
167
|
-
path:
|
|
167
|
+
path: i.path,
|
|
168
168
|
local: {
|
|
169
|
-
size:
|
|
170
|
-
updatedAt:
|
|
169
|
+
size: i.size,
|
|
170
|
+
updatedAt: i.updatedAt
|
|
171
171
|
},
|
|
172
172
|
cloud: {
|
|
173
|
-
size:
|
|
174
|
-
updatedAt:
|
|
173
|
+
size: a.size,
|
|
174
|
+
updatedAt: a.updatedAt
|
|
175
175
|
},
|
|
176
|
-
readLocal: () => c(
|
|
177
|
-
readCloud: () => i
|
|
176
|
+
readLocal: () => c(i.path),
|
|
177
|
+
readCloud: () => n(i.path)
|
|
178
178
|
});
|
|
179
179
|
if (!e) {
|
|
180
|
-
t.unresolved.push(
|
|
180
|
+
t.unresolved.push(i.path);
|
|
181
181
|
continue;
|
|
182
182
|
}
|
|
183
183
|
try {
|
|
184
|
-
if (e === "cloud") await u(
|
|
184
|
+
if (e === "cloud") await u(i.path, await n(i.path));
|
|
185
185
|
else {
|
|
186
|
-
let t = e === "local" ? await c(
|
|
187
|
-
await
|
|
186
|
+
let t = e === "local" ? await c(i.path) : e.merged;
|
|
187
|
+
await r(i.path, t, i.contentType ? { contentType: i.contentType } : void 0), e !== "local" && await u(i.path, t);
|
|
188
188
|
}
|
|
189
|
-
w(
|
|
190
|
-
path:
|
|
189
|
+
w(i.path), t.resolved.push({
|
|
190
|
+
path: i.path,
|
|
191
191
|
choice: e === "local" || e === "cloud" ? e : "merged"
|
|
192
192
|
});
|
|
193
193
|
} catch (e) {
|
|
194
194
|
if (e?.code === "FKN_E2E_LOCKED") throw e;
|
|
195
195
|
t.failed.push({
|
|
196
|
-
path:
|
|
196
|
+
path: i.path,
|
|
197
197
|
error: e instanceof Error ? e.message : String(e)
|
|
198
198
|
});
|
|
199
199
|
}
|
|
200
200
|
continue;
|
|
201
201
|
}
|
|
202
202
|
try {
|
|
203
|
-
let e = await c(
|
|
204
|
-
await
|
|
203
|
+
let e = await c(i.path);
|
|
204
|
+
await r(i.path, e, i.contentType ? { contentType: i.contentType } : void 0), w(i.path), t.uploaded.push(i.path);
|
|
205
205
|
} catch (e) {
|
|
206
|
-
if (C(
|
|
206
|
+
if (C(i.path), e?.code === "FKN_E2E_LOCKED") throw e;
|
|
207
207
|
t.failed.push({
|
|
208
|
-
path:
|
|
208
|
+
path: i.path,
|
|
209
209
|
error: e instanceof Error ? e.message : String(e)
|
|
210
210
|
});
|
|
211
211
|
}
|
|
@@ -216,10 +216,10 @@ var f = /* @__PURE__ */ e({
|
|
|
216
216
|
paths: [],
|
|
217
217
|
bytes: 0
|
|
218
218
|
};
|
|
219
|
-
let [e, t] = await Promise.all([l(),
|
|
219
|
+
let [e, t] = await Promise.all([l(), a()]), n = new Set(t.map((e) => e.path)), r = e.filter((e) => !n.has(e.path));
|
|
220
220
|
return {
|
|
221
|
-
paths:
|
|
222
|
-
bytes:
|
|
221
|
+
paths: r.map((e) => e.path),
|
|
222
|
+
bytes: r.reduce((e, t) => e + t.size, 0)
|
|
223
223
|
};
|
|
224
224
|
}, de = () => new Set(Object.keys(b(_))), fe = (e) => {
|
|
225
225
|
let t = b(_);
|
|
@@ -229,17 +229,17 @@ var f = /* @__PURE__ */ e({
|
|
|
229
229
|
if (!await m()) return;
|
|
230
230
|
let t = e ?? (await p() ? {
|
|
231
231
|
local: await l(),
|
|
232
|
-
remote: await
|
|
232
|
+
remote: await a()
|
|
233
233
|
} : null);
|
|
234
234
|
if (!t) return;
|
|
235
|
-
let
|
|
236
|
-
if (!
|
|
237
|
-
let o = await j(), s =
|
|
235
|
+
let n = new Set(t.remote.map((e) => e.path)), r = de(), i = t.local.filter((e) => !n.has(e.path) && !r.has(e.path));
|
|
236
|
+
if (!i.length) return;
|
|
237
|
+
let o = await j(), s = i.reduce((e, t) => e + t.size, 0);
|
|
238
238
|
if (!await o.cloud.fs.promptAdopt({
|
|
239
|
-
files:
|
|
239
|
+
files: i.length,
|
|
240
240
|
bytes: s
|
|
241
241
|
}).catch(() => !1)) {
|
|
242
|
-
fe(
|
|
242
|
+
fe(i.map((e) => e.path));
|
|
243
243
|
return;
|
|
244
244
|
}
|
|
245
245
|
await F();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./node-fs-BMR2yCEt.cjs"),n=require("./storage-
|
|
1
|
+
const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./node-fs-BMR2yCEt.cjs"),n=require("./storage-D2a8SsY5.cjs"),r=require("./opfs-CXMESVLc.cjs");var i=e.t({adopt:()=>E,adoptable:()=>D,available:()=>c,list:()=>ie,onConflict:()=>le,pending:()=>te,pendingDeletes:()=>ne,pull:()=>ce,readFile:()=>ae,remove:()=>se,replicating:()=>x,writeFile:()=>oe}),a,o=async()=>await(a??=r.t().catch(()=>!1))?!0:(a=void 0,!1),s=()=>n.r().catch(()=>!1),c=async()=>await o()||await s(),l=`fkn:fs:pending`,u=`fkn:fs:pending-delete`,d=`fkn:fs:adopt-declined`,f=!0,p=new Map,m=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{}}},h=(e,t)=>{try{Object.keys(t).length?localStorage.setItem(e,JSON.stringify(t)):localStorage.removeItem(e)}catch{}},g=()=>m(l),_=e=>{let t=g();e in t||(t[e]=p.get(e)??null,h(l,t))},v=e=>{let t=g();e in t&&(delete t[e],h(l,t))},y=()=>m(u),ee=e=>{let t=y();e in t||(t[e]=p.get(e)??null,h(u,t))},b=e=>{let t=y();e in t&&(delete t[e],h(u,t))},te=()=>Object.keys(g()),ne=()=>Object.keys(y()),x=()=>f,S=null,re=null,C=()=>re??=Promise.resolve().then(()=>require("./api-DLGGoSnx.cjs")).then(e=>e.n).then(e=>e.apiPromise),ie=async()=>{he();let e=await s(),[t,i]=await Promise.all([o().then(e=>e?r.n():[]).catch(()=>[]),e?n.o().then(e=>({ok:!0,entries:e})).catch(()=>({ok:!1,entries:[]})):Promise.resolve({ok:!0,entries:[]})]);f=i.ok,i.ok&&(p=new Map(i.entries.map(e=>[e.path,e.updatedAt])));let a=new Map,c=e=>{let t=Date.parse(e.updatedAt??``);return Number.isFinite(t)?t:0},l=e=>{let t=a.get(e.path);(!t||c(e)>=c(t))&&a.set(e.path,e)};for(let e of t)l(e);for(let e of i.entries)l(e);if(i.ok&&e){me(t,i.entries).catch(()=>{});let e=Object.keys(g()).length||Object.keys(y()).length;e&&!S?S=T(!1).catch(()=>{}).finally(()=>{S=null}):e||k({local:t,remote:i.entries}).catch(()=>{})}return[...a.values()]},ae=async e=>{if(await o())try{return await r.i(e)}catch(e){if(e?.name!==`NotFoundError`)throw e}let t=await n.c(e);return await o()&&r.o(e,t).catch(()=>{}),t},oe=async(e,t,i)=>{let a=t instanceof Blob?t:new Blob([t],i?.contentType?{type:i.contentType}:void 0);if(await o()){if(await r.o(e,a,i),!await s())return;if(!f){_(e);return}n.f(e,a,i).then(()=>v(e)).catch(t=>{_(e),console.warn(`fs: cloud replicate failed, queued for adopt()`,t)});return}if(await s())return n.f(e,a,i);throw Error(`fs: no storage backend available`)},se=async e=>{let t=[];await o()&&t.push(r.a(e).catch(()=>{}));let i=await s();if(i&&t.push(n.l(e).then(()=>b(e)).catch(t=>{ee(e),console.warn(`fs: cloud delete failed, queued for retry`,t)})),!t.length)throw Error(`fs: no storage backend available`);i&&v(e),await Promise.all(t)},ce=async e=>{let t=await n.c(e);return await o()&&await r.o(e,t),t},w=null,le=e=>(w=e,()=>{w===e&&(w=null)}),ue=async e=>(await C()).cloud.fs.promptConflict({path:e.path,local:e.local,cloud:e.cloud}).catch(()=>null),de=async e=>{if(w)try{return await w(e)}catch{return null}return ue(e)},T=async e=>{let t={uploaded:[],kept:[],resolved:[],unresolved:[],deleted:[],failed:[]};if(!await s())throw Error(`fs: this needs a signed-in account`);if(!await o())return t;let[i,a]=await Promise.all([r.n(),n.o()]),c=new Map(a.map(e=>[e.path,e])),l=g();for(let[e,r]of Object.entries(y())){let a=c.get(e);if(!a){b(e);continue}if(i.some(t=>t.path===e)){b(e);continue}if(a.updatedAt!==r){b(e);continue}try{await n.l(e),b(e),t.deleted.push(e)}catch(n){t.failed.push({path:e,error:n instanceof Error?n.message:String(n)})}}for(let a of i){let i=c.get(a.path),o=a.path in l;if(!o&&(i||!e)){i&&t.kept.push(a.path);continue}if(o&&i&&i.updatedAt!==l[a.path]){let e=await de({path:a.path,local:{size:a.size,updatedAt:a.updatedAt},cloud:{size:i.size,updatedAt:i.updatedAt},readLocal:()=>r.i(a.path),readCloud:()=>n.c(a.path)});if(!e){t.unresolved.push(a.path);continue}try{if(e===`cloud`)await r.o(a.path,await n.c(a.path));else{let t=e===`local`?await r.i(a.path):e.merged;await n.f(a.path,t,a.contentType?{contentType:a.contentType}:void 0),e!==`local`&&await r.o(a.path,t)}v(a.path),t.resolved.push({path:a.path,choice:e===`local`||e===`cloud`?e:`merged`})}catch(e){if(e?.code===`FKN_E2E_LOCKED`)throw e;t.failed.push({path:a.path,error:e instanceof Error?e.message:String(e)})}continue}try{let e=await r.i(a.path);await n.f(a.path,e,a.contentType?{contentType:a.contentType}:void 0),v(a.path),t.uploaded.push(a.path)}catch(e){if(_(a.path),e?.code===`FKN_E2E_LOCKED`)throw e;t.failed.push({path:a.path,error:e instanceof Error?e.message:String(e)})}}return t},E=()=>T(!0),D=async()=>{if(!await s()||!await o())return{paths:[],bytes:0};let[e,t]=await Promise.all([r.n(),n.o()]),i=new Set(t.map(e=>e.path)),a=e.filter(e=>!i.has(e.path));return{paths:a.map(e=>e.path),bytes:a.reduce((e,t)=>e+t.size,0)}},fe=()=>new Set(Object.keys(m(d))),pe=e=>{let t=m(d);for(let n of e)t[n]=null;h(d,t)},O=null,k=e=>O||(O=(async()=>{if(!await s())return;let t=e??(await o()?{local:await r.n(),remote:await n.o()}:null);if(!t)return;let i=new Set(t.remote.map(e=>e.path)),a=fe(),c=t.local.filter(e=>!i.has(e.path)&&!a.has(e.path));if(!c.length)return;let l=await C(),u=c.reduce((e,t)=>e+t.size,0);if(!await l.cloud.fs.promptAdopt({files:c.length,bytes:u}).catch(()=>!1)){pe(c.map(e=>e.path));return}await E()})().catch(()=>{}).finally(()=>{O=null}),O),me=async(e,t)=>{let n=new Set(t.map(e=>e.path)),r=e.filter(e=>!n.has(e.path)),i=await C(),a=async()=>{await E().catch(()=>{});let e=await D().catch(()=>({paths:[],bytes:0}));await i.cloud.fs.setAdoptSource({files:e.paths.length,bytes:e.bytes},a).catch(()=>{})};await i.cloud.fs.setAdoptSource({files:r.length,bytes:r.reduce((e,t)=>e+t.size,0)},a)},A=!1,he=()=>{A||typeof window>`u`||(A=!0,Promise.resolve().then(()=>require("./account.cjs")).then(e=>e.onChange(()=>{k().catch(()=>{})})).catch(()=>{}))},ge=e.t({adopt:()=>q,adoptable:()=>J,appendFile:()=>ye,appendFileSync:()=>F,available:()=>M,default:()=>$,exists:()=>Ee,existsSync:()=>I,flush:()=>G,lstatSync:()=>R,mkdir:()=>Se,mkdirSync:()=>B,mount:()=>Oe,onConflict:()=>Q,pending:()=>Y,pendingDeletes:()=>X,promises:()=>De,pull:()=>K,readFile:()=>W,readFileSync:()=>N,readdir:()=>xe,readdirSync:()=>z,remount:()=>ke,rename:()=>Te,renameSync:()=>U,replicating:()=>Z,rm:()=>Ce,rmSync:()=>V,rmdirSync:()=>_e,stat:()=>be,statSync:()=>L,unlink:()=>we,unlinkSync:()=>H,writeFile:()=>ve,writeFileSync:()=>P}),j=t.t(i,{memfs:!0}),{available:M,readFileSync:N,writeFileSync:P,appendFileSync:F,existsSync:I,statSync:L,lstatSync:R,readdirSync:z,mkdirSync:B,rmSync:V,rmdirSync:_e,unlinkSync:H,renameSync:U,readFile:W,writeFile:ve,appendFile:ye,stat:be,readdir:xe,mkdir:Se,rm:Ce,unlink:we,rename:Te,exists:Ee,promises:De,mount:Oe,flush:G,remount:ke}=j,K=ce,q=E,J=D,Y=te,X=ne,Z=x,Q=le,$={...j,pull:K,adopt:q,adoptable:J,pending:Y,pendingDeletes:X,replicating:Z,onConflict:Q};Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return we}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return X}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return Se}}),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 F}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return be}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return De}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return K}});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { n as STORAGE_NOT_FOUND } from "./storage-CXIXrIxB.js";
|
|
1
2
|
import { a as Stats, i as ReadOptions, n as Callback, o as WriteData, r as MakeOptions, s as WriteOptions } from "./index-CJ0vHTcS.js";
|
|
2
3
|
|
|
3
4
|
//#region src/lib/storage.d.ts
|
|
@@ -24,11 +25,31 @@ declare class StorageLockedError extends Error {
|
|
|
24
25
|
code: string;
|
|
25
26
|
constructor();
|
|
26
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* There is no object at this path. Test `err.code === STORAGE_NOT_FOUND`, never the message.
|
|
30
|
+
*
|
|
31
|
+
* Absence arrives from two places that word it completely differently: the api refusing to presign
|
|
32
|
+
* a path with no committed row says "Not found", and a presign that succeeded followed by an object
|
|
33
|
+
* fetch that 404s says "storage: read failed (404)". Neither is a fault, both mean the same thing,
|
|
34
|
+
* and matching either by hand means matching both. Ripple matched only the first, so a missing
|
|
35
|
+
* backup read as a transient failure, retried forever, and a library went un-backed-up for a day
|
|
36
|
+
* without a single error anywhere.
|
|
37
|
+
*
|
|
38
|
+
* The distinction matters more than it sounds. "There is nothing here" is safe to overwrite;
|
|
39
|
+
* "I could not tell you" is not, and a caller that confuses them either never writes a first
|
|
40
|
+
* backup or destroys a real one.
|
|
41
|
+
*/
|
|
42
|
+
declare class StorageNotFoundError extends Error {
|
|
43
|
+
code: string;
|
|
44
|
+
constructor(message?: string);
|
|
45
|
+
}
|
|
46
|
+
/** Whether an error from this module means the path is empty, as opposed to unreadable. */
|
|
47
|
+
declare const isNotFound: (error: unknown) => boolean;
|
|
27
48
|
declare const quota: () => Promise<StorageQuota>;
|
|
28
49
|
declare const encryption: () => Promise<EncryptionStatus>;
|
|
29
50
|
declare const unlock: () => Promise<boolean>;
|
|
30
51
|
declare namespace fs_d_exports {
|
|
31
|
-
export { EncryptionStatus, FileEntry, Stats, StorageLockedError, StorageQuota, available, encryption, mkdir, promises, quota, readFile, readdir, rename, rm, stat, unlink, unlock, writeFile };
|
|
52
|
+
export { EncryptionStatus, FileEntry, STORAGE_NOT_FOUND, Stats, StorageLockedError, StorageNotFoundError, StorageQuota, available, encryption, isNotFound, mkdir, promises, quota, readFile, readdir, rename, rm, stat, unlink, unlock, writeFile };
|
|
32
53
|
}
|
|
33
54
|
declare const available: () => Promise<boolean>, readFile: (path: import("node:fs").PathLike, a: ReadOptions | Callback<Buffer | string>, b?: Callback<Buffer | string>) => void, writeFile: (path: import("node:fs").PathLike, data: WriteData, a: WriteOptions | Callback<void>, b?: Callback<void>) => void, unlink: (path: import("node:fs").PathLike, callback: Callback<void>) => void, rename: (from: import("node:fs").PathLike, to: import("node:fs").PathLike, callback: Callback<void>) => void, readdir: (path: import("node:fs").PathLike, a: unknown, b?: Callback<string[]>) => void, mkdir: (path: import("node:fs").PathLike, a: MakeOptions | Callback<void>, b?: Callback<void>) => void, rm: (path: import("node:fs").PathLike, a: {
|
|
34
55
|
recursive?: boolean;
|
|
@@ -50,4 +71,4 @@ declare const available: () => Promise<boolean>, readFile: (path: import("node:f
|
|
|
50
71
|
access: (path: import("node:fs").PathLike) => Promise<void>;
|
|
51
72
|
};
|
|
52
73
|
//#endregion
|
|
53
|
-
export {
|
|
74
|
+
export { encryption as _, readFile as a, unlock as b, rm as c, writeFile as d, EncryptionStatus as f, StorageQuota as g, StorageNotFoundError as h, promises as i, stat as l, StorageLockedError as m, fs_d_exports as n, readdir as o, FileEntry as p, mkdir as r, rename as s, available as t, unlink as u, isNotFound as v, quota 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-C5L6CqmF.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-B-NZzzSX.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-luhw3yr7.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-BtdN07IP.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-B-LNnKps.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
|