@fkn/lib 0.9.1 → 0.9.3

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.
Files changed (77) hide show
  1. package/account.cjs +1 -1
  2. package/account.js +2 -2
  3. package/{api-CLpsJzJy.d.ts → api-BFqrrvzI.d.ts} +7 -0
  4. package/{api-CAZo3BT0.js → api-CtmJlpfo.js} +1 -1
  5. package/{api-BwrS6P0x.cjs → api-UzF-KbxK.cjs} +1 -1
  6. package/cloud/dgram.cjs +1 -1
  7. package/cloud/dgram.js +1 -1
  8. package/cloud/fs.cjs +1 -1
  9. package/cloud/fs.js +2 -2
  10. package/cloud/net.cjs +1 -1
  11. package/cloud/net.d.ts +1 -1
  12. package/cloud/net.js +1 -1
  13. package/{cloud-BcpPsNs3.cjs → cloud-B_Q0iiCr.cjs} +1 -1
  14. package/{cloud-7C3sOMF_.d.ts → cloud-CAOIpDIH.d.ts} +3 -3
  15. package/{cloud-DArHoBaw.js → cloud-CnddU57R.js} +20 -18
  16. package/cloud.cjs +1 -1
  17. package/cloud.d.ts +2 -2
  18. package/cloud.js +4 -4
  19. package/desktop.cjs +1 -1
  20. package/desktop.js +1 -1
  21. package/{dgram-C1yYxLEI.js → dgram-Bq_i0wX0.js} +2 -2
  22. package/{dgram-pCNllfov.cjs → dgram-C6ADuKcR.cjs} +1 -1
  23. package/dgram.cjs +1 -1
  24. package/dgram.d.ts +1 -1
  25. package/dgram.js +1 -1
  26. package/dns.cjs +1 -1
  27. package/dns.js +2 -2
  28. package/extension-D7SSKewV.d.ts +16 -0
  29. package/extension-H9AUHZdt.js +73 -0
  30. package/extension-QRMx3Qhh.cjs +1 -0
  31. package/extension.cjs +1 -1
  32. package/extension.d.ts +3 -3
  33. package/extension.js +3 -3
  34. package/fs/promises.cjs +1 -1
  35. package/fs/promises.d.ts +1 -1
  36. package/fs/promises.js +1 -1
  37. package/fs-DU9rph4j.js +315 -0
  38. package/fs-V_Sx6o9N.cjs +1 -0
  39. package/fs.cjs +1 -1
  40. package/fs.d.ts +2 -2
  41. package/fs.js +2 -2
  42. package/http.cjs +1 -1
  43. package/http.d.ts +1 -1
  44. package/http.js +2 -2
  45. package/{index-Bt2VAVEC.d.ts → index-BIZeEsNu.d.ts} +5 -2
  46. package/{index-BJztAQIP.d.ts → index-pr5vLVVT.d.ts} +499 -406
  47. package/index.cjs +1 -1
  48. package/index.d.ts +6 -6
  49. package/index.js +28 -28
  50. package/{net--o3_puH-.d.ts → net-MbSFrO35.d.ts} +1 -1
  51. package/{net-BOyLJ3mh.cjs → net-eFlsYreG.cjs} +1 -1
  52. package/{net-VAkfxAvn.js → net-kkSsmaSz.js} +2 -2
  53. package/net.cjs +1 -1
  54. package/net.d.ts +1 -1
  55. package/net.js +1 -1
  56. package/{opfs-7_GmzQ93.js → opfs-BibrNGF0.js} +1 -1
  57. package/{opfs-uClkgnb5.cjs → opfs-CXMESVLc.cjs} +1 -1
  58. package/opfs.cjs +1 -1
  59. package/opfs.js +2 -2
  60. package/package.json +1 -1
  61. package/packages.cjs +1 -1
  62. package/packages.js +2 -2
  63. package/{proxy-B3rliZN8.js → proxy-8bvtaeNn.js} +505 -603
  64. package/proxy-D2cxusWD.cjs +53 -0
  65. package/rolldown-runtime-BIInC43l.cjs +1 -0
  66. package/{rolldown-runtime-DF993M8W.js → rolldown-runtime-Dy4uBu1J.js} +2 -2
  67. package/{storage-InqJHrkf.js → storage-YL0pIVoy.js} +2 -2
  68. package/{storage-C1BT8jwJ.cjs → storage-fSj65-d5.cjs} +1 -1
  69. package/background-DMESyLZ6.cjs +0 -1
  70. package/background-DxYR_JMs.js +0 -1028
  71. package/extension-3pxUYwrA.d.ts +0 -16
  72. package/extension-CjJNj5Yl.cjs +0 -1
  73. package/extension-Qs02HPzR.js +0 -67
  74. package/fs-B8Rc1zRI.cjs +0 -1
  75. package/fs-CvCcDnzN.js +0 -260
  76. package/proxy-g2yknq7C.cjs +0 -53
  77. package/rolldown-runtime-Doa5O59j.cjs +0 -1
package/fs-DU9rph4j.js ADDED
@@ -0,0 +1,315 @@
1
+ import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
2
+ import { t } from "./node-fs-DKfokOlh.js";
3
+ import { i as n, n as r, o as i, s as a, u as o } from "./storage-YL0pIVoy.js";
4
+ import { a as s, i as c, n as l, o as u, t as d } from "./opfs-BibrNGF0.js";
5
+ //#region src/lib/fs/hybrid.ts
6
+ var f = /* @__PURE__ */ e({
7
+ adopt: () => F,
8
+ adoptable: () => I,
9
+ available: () => te,
10
+ list: () => ie,
11
+ onConflict: () => N,
12
+ pending: () => D,
13
+ pendingDeletes: () => O,
14
+ pull: () => ce,
15
+ readFile: () => ae,
16
+ remove: () => se,
17
+ replicating: () => k,
18
+ writeFile: () => oe
19
+ }), ee, p = async () => await (ee ??= d().catch(() => !1)) ? !0 : (ee = void 0, !1), m = () => r().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
+ try {
21
+ let t = localStorage.getItem(e);
22
+ if (!t) return {};
23
+ let n = JSON.parse(t);
24
+ return Array.isArray(n) ? Object.fromEntries(n.filter((e) => typeof e == "string").map((e) => [e, null])) : n && typeof n == "object" ? n : {};
25
+ } catch {
26
+ return {};
27
+ }
28
+ }, x = (e, t) => {
29
+ try {
30
+ Object.keys(t).length ? localStorage.setItem(e, JSON.stringify(t)) : localStorage.removeItem(e);
31
+ } catch {}
32
+ }, S = () => b(h), C = (e) => {
33
+ let t = S();
34
+ e in t || (t[e] = y.get(e) ?? null, x(h, t));
35
+ }, w = (e) => {
36
+ let t = S();
37
+ e in t && (delete t[e], x(h, t));
38
+ }, T = () => b(g), ne = (e) => {
39
+ let t = T();
40
+ e in t || (t[e] = y.get(e) ?? null, x(g, t));
41
+ }, E = (e) => {
42
+ let t = T();
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-CtmJlpfo.js").then((e) => e.n).then((e) => e.apiPromise), ie = async () => {
45
+ me();
46
+ let e = await m(), [t, r] = await Promise.all([p().then((e) => e ? l() : []).catch(() => []), e ? n().then((e) => ({
47
+ ok: !0,
48
+ entries: e
49
+ })).catch(() => ({
50
+ ok: !1,
51
+ entries: []
52
+ })) : Promise.resolve({
53
+ ok: !0,
54
+ entries: []
55
+ })]);
56
+ v = r.ok, r.ok && (y = new Map(r.entries.map((e) => [e.path, e.updatedAt])));
57
+ let i = /* @__PURE__ */ new Map(), a = (e) => {
58
+ let t = Date.parse(e.updatedAt ?? "");
59
+ return Number.isFinite(t) ? t : 0;
60
+ }, o = (e) => {
61
+ let t = i.get(e.path);
62
+ (!t || a(e) >= a(t)) && i.set(e.path, e);
63
+ };
64
+ for (let e of t) o(e);
65
+ for (let e of r.entries) o(e);
66
+ if (r.ok && e) {
67
+ pe(t, r.entries).catch(() => {});
68
+ let e = Object.keys(S()).length || Object.keys(T()).length;
69
+ e && !A ? A = P(!1).catch(() => {}).finally(() => {
70
+ A = null;
71
+ }) : e || R({
72
+ local: t,
73
+ remote: r.entries
74
+ }).catch(() => {});
75
+ }
76
+ return [...i.values()];
77
+ }, ae = async (e) => {
78
+ if (await p()) try {
79
+ return await c(e);
80
+ } catch (e) {
81
+ if (e?.name !== "NotFoundError") throw e;
82
+ }
83
+ let t = await i(e);
84
+ return await p() && u(e, t).catch(() => {}), t;
85
+ }, oe = async (e, t, n) => {
86
+ let r = t instanceof Blob ? t : new Blob([t], n?.contentType ? { type: n.contentType } : void 0);
87
+ if (await p()) {
88
+ if (await u(e, r, n), !await m()) return;
89
+ if (!v) {
90
+ C(e);
91
+ return;
92
+ }
93
+ o(e, r, n).then(() => w(e)).catch((t) => {
94
+ C(e), console.warn("fs: cloud replicate failed, queued for adopt()", t);
95
+ });
96
+ return;
97
+ }
98
+ if (await m()) return o(e, r, n);
99
+ throw Error("fs: no storage backend available");
100
+ }, se = async (e) => {
101
+ let t = [];
102
+ await p() && t.push(s(e).catch(() => {}));
103
+ let n = await m();
104
+ if (n && t.push(a(e).then(() => E(e)).catch((t) => {
105
+ ne(e), console.warn("fs: cloud delete failed, queued for retry", t);
106
+ })), !t.length) throw Error("fs: no storage backend available");
107
+ n && w(e), await Promise.all(t);
108
+ }, ce = async (e) => {
109
+ let t = await i(e);
110
+ return await p() && await u(e, t), t;
111
+ }, M = null, N = (e) => (M = e, () => {
112
+ M === e && (M = null);
113
+ }), le = async (e) => (await j()).cloud.fs.promptConflict({
114
+ path: e.path,
115
+ local: e.local,
116
+ cloud: e.cloud
117
+ }).catch(() => null), ue = async (e) => {
118
+ if (M) try {
119
+ return await M(e);
120
+ } catch {
121
+ return null;
122
+ }
123
+ return le(e);
124
+ }, P = async (e) => {
125
+ let t = {
126
+ uploaded: [],
127
+ kept: [],
128
+ resolved: [],
129
+ unresolved: [],
130
+ deleted: [],
131
+ failed: []
132
+ };
133
+ if (!await m()) throw Error("fs: this needs a signed-in account");
134
+ if (!await p()) return t;
135
+ let [r, s] = await Promise.all([l(), n()]), d = new Map(s.map((e) => [e.path, e])), f = S();
136
+ for (let [e, n] of Object.entries(T())) {
137
+ let i = d.get(e);
138
+ if (!i) {
139
+ E(e);
140
+ continue;
141
+ }
142
+ if (r.some((t) => t.path === e)) {
143
+ E(e);
144
+ continue;
145
+ }
146
+ if (i.updatedAt !== n) {
147
+ E(e);
148
+ continue;
149
+ }
150
+ try {
151
+ await a(e), E(e), t.deleted.push(e);
152
+ } catch (n) {
153
+ t.failed.push({
154
+ path: e,
155
+ error: n instanceof Error ? n.message : String(n)
156
+ });
157
+ }
158
+ }
159
+ for (let n of r) {
160
+ let r = d.get(n.path), a = n.path in f;
161
+ if (!a && (r || !e)) {
162
+ r && t.kept.push(n.path);
163
+ continue;
164
+ }
165
+ if (a && r && r.updatedAt !== f[n.path]) {
166
+ let e = await ue({
167
+ path: n.path,
168
+ local: {
169
+ size: n.size,
170
+ updatedAt: n.updatedAt
171
+ },
172
+ cloud: {
173
+ size: r.size,
174
+ updatedAt: r.updatedAt
175
+ },
176
+ readLocal: () => c(n.path),
177
+ readCloud: () => i(n.path)
178
+ });
179
+ if (!e) {
180
+ t.unresolved.push(n.path);
181
+ continue;
182
+ }
183
+ try {
184
+ if (e === "cloud") await u(n.path, await i(n.path));
185
+ else {
186
+ let t = e === "local" ? await c(n.path) : e.merged;
187
+ await o(n.path, t, n.contentType ? { contentType: n.contentType } : void 0), e !== "local" && await u(n.path, t);
188
+ }
189
+ w(n.path), t.resolved.push({
190
+ path: n.path,
191
+ choice: e === "local" || e === "cloud" ? e : "merged"
192
+ });
193
+ } catch (e) {
194
+ if (e?.code === "FKN_E2E_LOCKED") throw e;
195
+ t.failed.push({
196
+ path: n.path,
197
+ error: e instanceof Error ? e.message : String(e)
198
+ });
199
+ }
200
+ continue;
201
+ }
202
+ try {
203
+ let e = await c(n.path);
204
+ await o(n.path, e, n.contentType ? { contentType: n.contentType } : void 0), w(n.path), t.uploaded.push(n.path);
205
+ } catch (e) {
206
+ if (C(n.path), e?.code === "FKN_E2E_LOCKED") throw e;
207
+ t.failed.push({
208
+ path: n.path,
209
+ error: e instanceof Error ? e.message : String(e)
210
+ });
211
+ }
212
+ }
213
+ return t;
214
+ }, F = () => P(!0), I = async () => {
215
+ if (!await m() || !await p()) return {
216
+ paths: [],
217
+ bytes: 0
218
+ };
219
+ let [e, t] = await Promise.all([l(), n()]), r = new Set(t.map((e) => e.path)), i = e.filter((e) => !r.has(e.path));
220
+ return {
221
+ paths: i.map((e) => e.path),
222
+ bytes: i.reduce((e, t) => e + t.size, 0)
223
+ };
224
+ }, de = () => new Set(Object.keys(b(_))), fe = (e) => {
225
+ let t = b(_);
226
+ for (let n of e) t[n] = null;
227
+ x(_, t);
228
+ }, L = null, R = (e) => L || (L = (async () => {
229
+ if (!await m()) return;
230
+ let t = e ?? (await p() ? {
231
+ local: await l(),
232
+ remote: await n()
233
+ } : null);
234
+ if (!t) return;
235
+ let r = new Set(t.remote.map((e) => e.path)), i = de(), a = t.local.filter((e) => !r.has(e.path) && !i.has(e.path));
236
+ if (!a.length) return;
237
+ let o = await j(), s = a.reduce((e, t) => e + t.size, 0);
238
+ if (!await o.cloud.fs.promptAdopt({
239
+ files: a.length,
240
+ bytes: s
241
+ }).catch(() => !1)) {
242
+ fe(a.map((e) => e.path));
243
+ return;
244
+ }
245
+ await F();
246
+ })().catch(() => {}).finally(() => {
247
+ L = null;
248
+ }), L), pe = async (e, t) => {
249
+ let n = new Set(t.map((e) => e.path)), r = e.filter((e) => !n.has(e.path)), i = await j(), a = async () => {
250
+ await F().catch(() => {});
251
+ let e = await I().catch(() => ({
252
+ paths: [],
253
+ bytes: 0
254
+ }));
255
+ await i.cloud.fs.setAdoptSource({
256
+ files: e.paths.length,
257
+ bytes: e.bytes
258
+ }, a).catch(() => {});
259
+ };
260
+ await i.cloud.fs.setAdoptSource({
261
+ files: r.length,
262
+ bytes: r.reduce((e, t) => e + t.size, 0)
263
+ }, a);
264
+ }, z = !1, me = () => {
265
+ z || typeof window > "u" || (z = !0, import("./account.js").then((e) => e.onChange(() => {
266
+ R().catch(() => {});
267
+ })).catch(() => {}));
268
+ }, he = /* @__PURE__ */ e({
269
+ adopt: () => J,
270
+ adoptable: () => Y,
271
+ appendFile: () => Ee,
272
+ appendFileSync: () => W,
273
+ available: () => V,
274
+ default: () => Le,
275
+ exists: () => Ne,
276
+ existsSync: () => G,
277
+ flush: () => Fe,
278
+ lstatSync: () => _e,
279
+ mkdir: () => ke,
280
+ mkdirSync: () => ye,
281
+ mount: () => K,
282
+ onConflict: () => $,
283
+ pending: () => X,
284
+ pendingDeletes: () => Z,
285
+ promises: () => Pe,
286
+ pull: () => q,
287
+ readFile: () => we,
288
+ readFileSync: () => H,
289
+ readdir: () => Oe,
290
+ readdirSync: () => ve,
291
+ remount: () => Ie,
292
+ rename: () => Me,
293
+ renameSync: () => Ce,
294
+ replicating: () => Q,
295
+ rm: () => Ae,
296
+ rmSync: () => be,
297
+ rmdirSync: () => xe,
298
+ stat: () => De,
299
+ statSync: () => ge,
300
+ unlink: () => je,
301
+ unlinkSync: () => Se,
302
+ writeFile: () => Te,
303
+ writeFileSync: () => U
304
+ }), B = t(f, { memfs: !0 }), { available: V, readFileSync: H, writeFileSync: U, appendFileSync: W, existsSync: G, statSync: ge, lstatSync: _e, readdirSync: ve, mkdirSync: ye, rmSync: be, rmdirSync: xe, unlinkSync: Se, renameSync: Ce, readFile: we, writeFile: Te, appendFile: Ee, stat: De, readdir: Oe, mkdir: ke, rm: Ae, unlink: je, rename: Me, exists: Ne, promises: Pe, mount: K, flush: Fe, remount: Ie } = B, q = ce, J = F, Y = I, X = D, Z = O, Q = k, $ = N, Le = {
305
+ ...B,
306
+ pull: q,
307
+ adopt: J,
308
+ adoptable: Y,
309
+ pending: X,
310
+ pendingDeletes: Z,
311
+ replicating: Q,
312
+ onConflict: $
313
+ };
314
+ //#endregion
315
+ export { xe as A, ve as C, Q as D, Ce as E, Te as F, U as I, ge as M, je as N, Ae as O, Se as P, Oe as S, Me as T, Z as _, V as a, we as b, Fe as c, _e as d, ke as f, X as g, $ as h, W as i, De as j, be as k, Le as l, K as m, Y as n, Ne as o, ye as p, Ee as r, G as s, J as t, he as u, Pe as v, Ie as w, H as x, q as y };
@@ -0,0 +1 @@
1
+ const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./node-fs-BMR2yCEt.cjs"),n=require("./storage-fSj65-d5.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.n().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-UzF-KbxK.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.i().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.o(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.u(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.u(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.s(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.o(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.i()]),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.s(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.o(a.path)});if(!e){t.unresolved.push(a.path);continue}try{if(e===`cloud`)await r.o(a.path,await n.o(a.path));else{let t=e===`local`?await r.i(a.path):e.merged;await n.u(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.u(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.i()]),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.i()}: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}});
package/fs.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./fs-B8Rc1zRI.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.promises=e._,exports.pull=e.v,exports.readFile=e.y,exports.readFileSync=e.b,exports.readdir=e.x,exports.readdirSync=e.S,exports.remount=e.C,exports.rename=e.w,exports.renameSync=e.T,exports.replicating=e.E,exports.rm=e.D,exports.rmSync=e.O,exports.rmdirSync=e.k,exports.stat=e.A,exports.statSync=e.j,exports.unlink=e.M,exports.unlinkSync=e.N,exports.writeFile=e.P,exports.writeFileSync=e.F;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./fs-V_Sx6o9N.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.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import { a as Stats } from "./index-CJ0vHTcS.js";
2
- import { A as stat, B as FileConflict, C as remount, D as rm, E as replicating, F as writeFileSync, I as AdoptSummary, L as ConflictChoice, M as unlink, N as unlinkSync, O as rmSync, P as writeFile, R as ConflictResolver, S as readdirSync, T as renameSync, _ as promises, a as appendFileSync, b as readFileSync, c as existsSync, d as lstatSync, f as mkdir, g as pending, h as onConflict, i as appendFile, j as statSync, k as rmdirSync, l as flush, m as mount, n as adopt, o as available, p as mkdirSync, r as adoptable, s as exists, t as _default, v as pull, w as rename, x as readdir, y as readFile, z as ConflictSide } from "./index-Bt2VAVEC.js";
3
- export { type AdoptSummary, type ConflictChoice, type ConflictResolver, type ConflictSide, type FileConflict, type Stats, adopt, adoptable, appendFile, appendFileSync, available, _default as default, exists, existsSync, flush, lstatSync, mkdir, mkdirSync, mount, onConflict, pending, promises, pull, readFile, readFileSync, readdir, readdirSync, remount, rename, renameSync, replicating, rm, rmSync, rmdirSync, stat, statSync, unlink, unlinkSync, writeFile, writeFileSync };
2
+ import { A as rmdirSync, B as ConflictSide, C as readdirSync, D as replicating, E as renameSync, F as writeFile, I as writeFileSync, L as AdoptSummary, M as statSync, N as unlink, O as rm, P as unlinkSync, R as ConflictChoice, S as readdir, T as rename, V as FileConflict, _ as pendingDeletes, a as appendFileSync, b as readFile, c as existsSync, d as lstatSync, f as mkdir, g as pending, h as onConflict, i as appendFile, j as stat, k as rmSync, l as flush, m as mount, n as adopt, o as available, p as mkdirSync, r as adoptable, s as exists, t as _default, v as promises, w as remount, x as readFileSync, y as pull, z as ConflictResolver } from "./index-BIZeEsNu.js";
3
+ export { type AdoptSummary, type ConflictChoice, type ConflictResolver, type ConflictSide, type FileConflict, type Stats, adopt, adoptable, appendFile, appendFileSync, available, _default as default, exists, existsSync, flush, lstatSync, mkdir, mkdirSync, mount, onConflict, pending, pendingDeletes, promises, pull, readFile, readFileSync, readdir, readdirSync, remount, rename, renameSync, replicating, rm, rmSync, rmdirSync, stat, statSync, unlink, unlinkSync, writeFile, writeFileSync };
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, M as a, N as o, O as s, P as c, S as l, T as u, _ as d, a as f, b as p, c as m, d as h, f as g, g as _, h as v, i as y, j as b, k as x, l as S, m as C, n as w, o as T, p as E, r as D, s as O, t as k, v as A, w as j, x as M, y as N } from "./fs-CvCcDnzN.js";
2
- export { k as adopt, w as adoptable, D as appendFile, y as appendFileSync, f as available, S as default, T as exists, O as existsSync, m as flush, h as lstatSync, g as mkdir, E as mkdirSync, C as mount, v as onConflict, _ as pending, d as promises, A as pull, N as readFile, p as readFileSync, M as readdir, l as readdirSync, t as remount, j as rename, u as renameSync, r as replicating, n as rm, s as rmSync, x as rmdirSync, e as stat, b as statSync, a as unlink, o as unlinkSync, c as writeFile, i as writeFileSync };
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-DU9rph4j.js";
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-Doa5O59j.cjs"),t=require("./net-BOyLJ3mh.cjs");let n=require("buffer"),r=require("stream");var i=e.n({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
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./net-eFlsYreG.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--o3_puH-.js";
1
+ import { n as Socket, t as Server$1 } from "./net-MbSFrO35.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
- import { n as e } from "./rolldown-runtime-DF993M8W.js";
2
- import { n as t, t as n } from "./net-VAkfxAvn.js";
1
+ import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
2
+ import { n as t, t as n } from "./net-kkSsmaSz.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
@@ -9,6 +9,7 @@ type AdoptSummary = {
9
9
  choice: 'local' | 'cloud' | 'merged';
10
10
  }[];
11
11
  unresolved: string[];
12
+ deleted: string[];
12
13
  failed: {
13
14
  path: string;
14
15
  error: string;
@@ -30,7 +31,7 @@ type ConflictChoice = 'local' | 'cloud' | {
30
31
  } | null;
31
32
  type ConflictResolver = (conflict: FileConflict) => Promise<ConflictChoice> | ConflictChoice;
32
33
  declare namespace index_d_exports {
33
- export { AdoptSummary, ConflictChoice, ConflictResolver, ConflictSide, FileConflict, Stats, adopt, adoptable, appendFile, appendFileSync, available, _default as default, exists, existsSync, flush, lstatSync, mkdir, mkdirSync, mount, onConflict, pending, promises, pull, readFile, readFileSync, readdir, readdirSync, remount, rename, renameSync, replicating, rm, rmSync, rmdirSync, stat, statSync, unlink, unlinkSync, writeFile, writeFileSync };
34
+ export { AdoptSummary, ConflictChoice, ConflictResolver, ConflictSide, FileConflict, Stats, adopt, adoptable, appendFile, appendFileSync, available, _default as default, exists, existsSync, flush, lstatSync, mkdir, mkdirSync, mount, onConflict, pending, pendingDeletes, promises, pull, readFile, readFileSync, readdir, readdirSync, remount, rename, renameSync, replicating, rm, rmSync, rmdirSync, stat, statSync, unlink, unlinkSync, writeFile, writeFileSync };
34
35
  }
35
36
  declare const available: () => Promise<boolean>, readFileSync: (path: import("node:fs").PathLike, options?: ReadOptions) => Buffer | string, writeFileSync: (path: import("node:fs").PathLike, data: WriteData$1, options?: WriteOptions) => void, appendFileSync: (path: import("node:fs").PathLike, data: WriteData$1, options?: WriteOptions) => void, existsSync: (path: import("node:fs").PathLike) => boolean, statSync: (path: import("node:fs").PathLike) => Stats, lstatSync: (path: import("node:fs").PathLike) => Stats, readdirSync: (path: import("node:fs").PathLike) => string[], mkdirSync: (path: import("node:fs").PathLike, options?: MakeOptions) => void, rmSync: (path: import("node:fs").PathLike, options?: {
36
37
  recursive?: boolean;
@@ -66,6 +67,7 @@ declare const adoptable: () => Promise<{
66
67
  bytes: number;
67
68
  }>;
68
69
  declare const pending: () => string[];
70
+ declare const pendingDeletes: () => string[];
69
71
  declare const replicating: () => boolean;
70
72
  declare const onConflict: (next: ConflictResolver) => (() => void);
71
73
  declare const _default: {
@@ -129,8 +131,9 @@ declare const _default: {
129
131
  bytes: number;
130
132
  }>;
131
133
  pending: () => string[];
134
+ pendingDeletes: () => string[];
132
135
  replicating: () => boolean;
133
136
  onConflict: (next: ConflictResolver) => (() => void);
134
137
  };
135
138
  //#endregion
136
- export { stat as A, FileConflict as B, remount as C, rm as D, replicating as E, writeFileSync as F, AdoptSummary as I, ConflictChoice as L, unlink as M, unlinkSync as N, rmSync as O, writeFile as P, ConflictResolver as R, readdirSync as S, renameSync as T, promises as _, appendFileSync as a, readFileSync as b, existsSync as c, lstatSync as d, mkdir as f, pending as g, onConflict as h, appendFile as i, statSync as j, rmdirSync as k, flush as l, mount as m, adopt as n, available as o, mkdirSync as p, adoptable as r, exists as s, _default as t, index_d_exports as u, pull as v, rename as w, readdir as x, readFile as y, ConflictSide as z };
139
+ export { rmdirSync as A, ConflictSide as B, readdirSync as C, replicating as D, renameSync as E, writeFile as F, writeFileSync as I, AdoptSummary as L, statSync as M, unlink as N, rm as O, unlinkSync as P, ConflictChoice as R, readdir as S, rename as T, FileConflict as V, pendingDeletes as _, appendFileSync as a, readFile as b, existsSync as c, lstatSync as d, mkdir as f, pending as g, onConflict as h, appendFile as i, stat as j, rmSync as k, flush as l, mount as m, adopt as n, available as o, mkdirSync as p, adoptable as r, exists as s, _default as t, index_d_exports as u, promises as v, remount as w, readFileSync as x, pull as y, ConflictResolver as z };