@fkn/lib 0.9.0 → 0.9.1

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 (69) hide show
  1. package/account.cjs +1 -1
  2. package/account.js +1 -1
  3. package/api-BwrS6P0x.cjs +1 -0
  4. package/api-CAZo3BT0.js +73 -0
  5. package/{api-Bdzns9Sb.d.ts → api-CLpsJzJy.d.ts} +18 -0
  6. package/{background-Bgznrosz.cjs → background-DMESyLZ6.cjs} +1 -1
  7. package/{background-EwGRMga_.js → background-DxYR_JMs.js} +1 -1
  8. package/cloud/dgram.cjs +1 -1
  9. package/cloud/dgram.js +1 -1
  10. package/cloud/fs/promises.d.ts +1 -1
  11. package/cloud/fs.cjs +1 -1
  12. package/cloud/fs.d.ts +2 -2
  13. package/cloud/fs.js +1 -1
  14. package/cloud/net.cjs +1 -1
  15. package/cloud/net.d.ts +1 -1
  16. package/cloud/net.js +1 -1
  17. package/{cloud-BPd7yisS.d.ts → cloud-7C3sOMF_.d.ts} +3 -3
  18. package/{cloud-Gs4fvw2S.cjs → cloud-BcpPsNs3.cjs} +1 -1
  19. package/{cloud-C-QB3sIK.js → cloud-DArHoBaw.js} +4 -4
  20. package/cloud.cjs +1 -1
  21. package/cloud.d.ts +3 -3
  22. package/cloud.js +4 -4
  23. package/{dgram-CKRbKVzG.js → dgram-C1yYxLEI.js} +1 -1
  24. package/{dgram-DcvdNkg6.cjs → dgram-pCNllfov.cjs} +1 -1
  25. package/dgram.cjs +1 -1
  26. package/dgram.d.ts +1 -1
  27. package/dgram.js +1 -1
  28. package/dns.cjs +1 -1
  29. package/dns.js +1 -1
  30. package/{extension-BeARgX1g.cjs → extension-CjJNj5Yl.cjs} +1 -1
  31. package/{extension-CgXBc_iM.js → extension-Qs02HPzR.js} +2 -2
  32. package/extension.cjs +1 -1
  33. package/extension.js +2 -2
  34. package/fs/promises.cjs +1 -1
  35. package/fs/promises.d.ts +2 -2
  36. package/fs/promises.js +1 -1
  37. package/fs-B8Rc1zRI.cjs +1 -0
  38. package/fs-CvCcDnzN.js +260 -0
  39. package/{fs-B8A_hQbv.d.ts → fs-DTmSCXwa.d.ts} +1 -1
  40. package/fs.cjs +1 -1
  41. package/fs.d.ts +3 -92
  42. package/fs.js +2 -2
  43. package/http.cjs +1 -1
  44. package/http.d.ts +1 -1
  45. package/http.js +1 -1
  46. package/index-Bt2VAVEC.d.ts +136 -0
  47. package/{index-C6ZoDJg8.d.ts → index-CJ0vHTcS.d.ts} +5 -2
  48. package/index.cjs +1 -1
  49. package/index.d.ts +3 -3
  50. package/index.js +7 -7
  51. package/{net-EaGR0bVe.d.ts → net--o3_puH-.d.ts} +1 -1
  52. package/{net-BPpdNdpy.cjs → net-BOyLJ3mh.cjs} +1 -1
  53. package/{net-BFYMbE4N.js → net-VAkfxAvn.js} +1 -1
  54. package/net.cjs +1 -1
  55. package/net.d.ts +1 -1
  56. package/net.js +1 -1
  57. package/opfs/promises.d.ts +1 -1
  58. package/opfs.d.ts +1 -1
  59. package/package.json +1 -1
  60. package/packages.cjs +1 -1
  61. package/packages.js +1 -1
  62. package/{proxy-CuuSsVoC.js → proxy-B3rliZN8.js} +2 -2
  63. package/{proxy-Bo-8GoRU.cjs → proxy-g2yknq7C.cjs} +1 -1
  64. package/{storage-ezLkqmQR.cjs → storage-C1BT8jwJ.cjs} +1 -1
  65. package/{storage-DMETg6sP.js → storage-InqJHrkf.js} +1 -1
  66. package/api--bnCFd4w.js +0 -67
  67. package/api-DD5v1qP9.cjs +0 -1
  68. package/fs-CP-81e-c.cjs +0 -1
  69. package/fs-DhPpGH0c.js +0 -82
package/fs-CvCcDnzN.js ADDED
@@ -0,0 +1,260 @@
1
+ import { n as e } from "./rolldown-runtime-DF993M8W.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-InqJHrkf.js";
4
+ import { a as s, i as c, n as l, o as u, t as d } from "./opfs-7_GmzQ93.js";
5
+ //#region src/lib/fs/hybrid.ts
6
+ var ee = /* @__PURE__ */ e({
7
+ adopt: () => O,
8
+ adoptable: () => k,
9
+ available: () => ne,
10
+ list: () => ae,
11
+ onConflict: () => E,
12
+ pending: () => re,
13
+ pull: () => w,
14
+ readFile: () => oe,
15
+ remove: () => ce,
16
+ replicating: () => ie,
17
+ writeFile: () => se
18
+ }), te, f = async () => await (te ??= d().catch(() => !1)) ? !0 : (te = void 0, !1), p = () => r().catch(() => !1), ne = async () => await f() || await p(), m = "fkn:fs:pending", h = "fkn:fs:adopt-declined", g = !0, _ = /* @__PURE__ */ new Map(), v = (e) => {
19
+ try {
20
+ let t = localStorage.getItem(e);
21
+ if (!t) return {};
22
+ let n = JSON.parse(t);
23
+ return Array.isArray(n) ? Object.fromEntries(n.filter((e) => typeof e == "string").map((e) => [e, null])) : n && typeof n == "object" ? n : {};
24
+ } catch {
25
+ return {};
26
+ }
27
+ }, y = (e, t) => {
28
+ try {
29
+ Object.keys(t).length ? localStorage.setItem(e, JSON.stringify(t)) : localStorage.removeItem(e);
30
+ } catch {}
31
+ }, b = () => v(m), x = (e) => {
32
+ let t = b();
33
+ e in t || (t[e] = _.get(e) ?? null, y(m, t));
34
+ }, S = (e) => {
35
+ let t = b();
36
+ e in t && (delete t[e], y(m, t));
37
+ }, re = () => Object.keys(b()), ie = () => g, C = null, ae = async () => {
38
+ pe();
39
+ let e = await p(), [t, r] = await Promise.all([f().then((e) => e ? l() : []).catch(() => []), e ? n().then((e) => ({
40
+ ok: !0,
41
+ entries: e
42
+ })).catch(() => ({
43
+ ok: !1,
44
+ entries: []
45
+ })) : Promise.resolve({
46
+ ok: !0,
47
+ entries: []
48
+ })]);
49
+ g = r.ok, r.ok && (_ = new Map(r.entries.map((e) => [e.path, e.updatedAt])));
50
+ let i = /* @__PURE__ */ new Map(), a = (e) => {
51
+ let t = Date.parse(e.updatedAt ?? "");
52
+ return Number.isFinite(t) ? t : 0;
53
+ }, o = (e) => {
54
+ let t = i.get(e.path);
55
+ (!t || a(e) >= a(t)) && i.set(e.path, e);
56
+ };
57
+ for (let e of t) o(e);
58
+ for (let e of r.entries) o(e);
59
+ return r.ok && e && !C && (Object.keys(b()).length ? C = D(!1).catch(() => {}).finally(() => {
60
+ C = null;
61
+ }) : j({
62
+ local: t,
63
+ remote: r.entries
64
+ }).catch(() => {})), [...i.values()];
65
+ }, oe = async (e) => {
66
+ if (await f()) try {
67
+ return await c(e);
68
+ } catch (e) {
69
+ if (e?.name !== "NotFoundError") throw e;
70
+ }
71
+ let t = await i(e);
72
+ return await f() && u(e, t).catch(() => {}), t;
73
+ }, se = async (e, t, n) => {
74
+ let r = t instanceof Blob ? t : new Blob([t], n?.contentType ? { type: n.contentType } : void 0);
75
+ if (await f()) {
76
+ if (await u(e, r, n), !await p()) return;
77
+ if (!g) {
78
+ x(e);
79
+ return;
80
+ }
81
+ o(e, r, n).then(() => S(e)).catch((t) => {
82
+ x(e), console.warn("fs: cloud replicate failed, queued for adopt()", t);
83
+ });
84
+ return;
85
+ }
86
+ if (await p()) return o(e, r, n);
87
+ throw Error("fs: no storage backend available");
88
+ }, ce = async (e) => {
89
+ let t = [];
90
+ if (await f() && t.push(s(e).catch(() => {})), await p() && t.push(a(e).catch(() => {})), !t.length) throw Error("fs: no storage backend available");
91
+ await Promise.all(t);
92
+ }, w = async (e) => {
93
+ let t = await i(e);
94
+ return await f() && await u(e, t), t;
95
+ }, T = null, E = (e) => (T = e, () => {
96
+ T === e && (T = null);
97
+ }), le = async (e) => {
98
+ let { apiPromise: t } = await import("./api-CAZo3BT0.js").then((e) => e.n);
99
+ return (await t).cloud.fs.promptConflict({
100
+ path: e.path,
101
+ local: e.local,
102
+ cloud: e.cloud
103
+ }).catch(() => null);
104
+ }, ue = async (e) => {
105
+ if (T) try {
106
+ return await T(e);
107
+ } catch {
108
+ return null;
109
+ }
110
+ return le(e);
111
+ }, D = async (e) => {
112
+ let t = {
113
+ uploaded: [],
114
+ kept: [],
115
+ resolved: [],
116
+ unresolved: [],
117
+ failed: []
118
+ };
119
+ if (!await p()) throw Error("fs: this needs a signed-in account");
120
+ if (!await f()) return t;
121
+ let [r, a] = await Promise.all([l(), n()]), s = new Map(a.map((e) => [e.path, e])), d = b();
122
+ for (let n of r) {
123
+ let r = s.get(n.path), a = n.path in d;
124
+ if (!a && (r || !e)) {
125
+ r && t.kept.push(n.path);
126
+ continue;
127
+ }
128
+ if (a && r && r.updatedAt !== d[n.path]) {
129
+ let e = await ue({
130
+ path: n.path,
131
+ local: {
132
+ size: n.size,
133
+ updatedAt: n.updatedAt
134
+ },
135
+ cloud: {
136
+ size: r.size,
137
+ updatedAt: r.updatedAt
138
+ },
139
+ readLocal: () => c(n.path),
140
+ readCloud: () => i(n.path)
141
+ });
142
+ if (!e) {
143
+ t.unresolved.push(n.path);
144
+ continue;
145
+ }
146
+ try {
147
+ if (e === "cloud") await u(n.path, await i(n.path));
148
+ else {
149
+ let t = e === "local" ? await c(n.path) : e.merged;
150
+ await o(n.path, t, n.contentType ? { contentType: n.contentType } : void 0), e !== "local" && await u(n.path, t);
151
+ }
152
+ S(n.path), t.resolved.push({
153
+ path: n.path,
154
+ choice: e === "local" || e === "cloud" ? e : "merged"
155
+ });
156
+ } catch (e) {
157
+ if (e?.code === "FKN_E2E_LOCKED") throw e;
158
+ t.failed.push({
159
+ path: n.path,
160
+ error: e instanceof Error ? e.message : String(e)
161
+ });
162
+ }
163
+ continue;
164
+ }
165
+ try {
166
+ let e = await c(n.path);
167
+ await o(n.path, e, n.contentType ? { contentType: n.contentType } : void 0), S(n.path), t.uploaded.push(n.path);
168
+ } catch (e) {
169
+ if (x(n.path), e?.code === "FKN_E2E_LOCKED") throw e;
170
+ t.failed.push({
171
+ path: n.path,
172
+ error: e instanceof Error ? e.message : String(e)
173
+ });
174
+ }
175
+ }
176
+ return t;
177
+ }, O = () => D(!0), k = async () => {
178
+ if (!await p() || !await f()) return {
179
+ paths: [],
180
+ bytes: 0
181
+ };
182
+ let [e, t] = await Promise.all([l(), n()]), r = new Set(t.map((e) => e.path)), i = e.filter((e) => !r.has(e.path));
183
+ return {
184
+ paths: i.map((e) => e.path),
185
+ bytes: i.reduce((e, t) => e + t.size, 0)
186
+ };
187
+ }, de = () => new Set(Object.keys(v(h))), fe = (e) => {
188
+ let t = v(h);
189
+ for (let n of e) t[n] = null;
190
+ y(h, t);
191
+ }, A = null, j = (e) => A || (A = (async () => {
192
+ if (!await p()) return;
193
+ let t = e ?? (await f() ? {
194
+ local: await l(),
195
+ remote: await n()
196
+ } : null);
197
+ if (!t) return;
198
+ 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));
199
+ if (!a.length) return;
200
+ let { apiPromise: o } = await import("./api-CAZo3BT0.js").then((e) => e.n), s = await o, c = a.reduce((e, t) => e + t.size, 0);
201
+ if (!await s.cloud.fs.promptAdopt({
202
+ files: a.length,
203
+ bytes: c
204
+ }).catch(() => !1)) {
205
+ fe(a.map((e) => e.path));
206
+ return;
207
+ }
208
+ await O();
209
+ })().catch(() => {}).finally(() => {
210
+ A = null;
211
+ }), A), M = !1, pe = () => {
212
+ M || typeof window > "u" || (M = !0, import("./account.js").then((e) => e.onChange(() => {
213
+ j().catch(() => {});
214
+ })).catch(() => {}));
215
+ }, me = /* @__PURE__ */ e({
216
+ adopt: () => J,
217
+ adoptable: () => Y,
218
+ appendFile: () => ve,
219
+ appendFileSync: () => L,
220
+ available: () => P,
221
+ default: () => $,
222
+ exists: () => Te,
223
+ existsSync: () => R,
224
+ flush: () => K,
225
+ lstatSync: () => B,
226
+ mkdir: () => xe,
227
+ mkdirSync: () => he,
228
+ mount: () => De,
229
+ onConflict: () => Q,
230
+ pending: () => X,
231
+ promises: () => Ee,
232
+ pull: () => q,
233
+ readFile: () => ge,
234
+ readFileSync: () => F,
235
+ readdir: () => be,
236
+ readdirSync: () => V,
237
+ remount: () => Oe,
238
+ rename: () => we,
239
+ renameSync: () => G,
240
+ replicating: () => Z,
241
+ rm: () => Se,
242
+ rmSync: () => H,
243
+ rmdirSync: () => U,
244
+ stat: () => ye,
245
+ statSync: () => z,
246
+ unlink: () => Ce,
247
+ unlinkSync: () => W,
248
+ writeFile: () => _e,
249
+ writeFileSync: () => I
250
+ }), N = t(ee, { memfs: !0 }), { available: P, readFileSync: F, writeFileSync: I, appendFileSync: L, existsSync: R, statSync: z, lstatSync: B, readdirSync: V, mkdirSync: he, rmSync: H, rmdirSync: U, unlinkSync: W, renameSync: G, readFile: ge, writeFile: _e, appendFile: ve, stat: ye, readdir: be, mkdir: xe, rm: Se, unlink: Ce, rename: we, exists: Te, promises: Ee, mount: De, flush: K, remount: Oe } = N, q = w, J = O, Y = k, X = re, Z = ie, Q = E, $ = {
251
+ ...N,
252
+ pull: q,
253
+ adopt: J,
254
+ adoptable: Y,
255
+ pending: X,
256
+ replicating: Z,
257
+ onConflict: Q
258
+ };
259
+ //#endregion
260
+ export { ye as A, Oe as C, Se as D, Z as E, I as F, Ce as M, W as N, H as O, _e as P, V as S, G as T, Ee as _, P as a, F as b, K as c, B as d, xe as f, X as g, Q as h, L as i, z as j, U as k, $ as l, De as m, Y as n, Te as o, he as p, ve as r, R as s, J as t, me as u, q as v, we as w, be as x, ge as y };
@@ -1,4 +1,4 @@
1
- import { a as WriteData, i as Stats, n as MakeOptions, o as WriteOptions, r as ReadOptions, t as Callback } from "./index-C6ZoDJg8.js";
1
+ import { a as Stats, i as ReadOptions, n as Callback, o as WriteData, r as MakeOptions, s as WriteOptions } from "./index-CJ0vHTcS.js";
2
2
 
3
3
  //#region src/lib/storage.d.ts
4
4
  type FileEntry = {
package/fs.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./fs-CP-81e-c.cjs");exports.appendFile=e.t,exports.appendFileSync=e.n,exports.available=e.r,exports.default=e.s,exports.exists=e.i,exports.existsSync=e.a,exports.flush=e.o,exports.lstatSync=e.l,exports.mkdir=e.u,exports.mkdirSync=e.d,exports.mount=e.f,exports.promises=e.p,exports.pull=e.m,exports.readFile=e.h,exports.readFileSync=e.g,exports.readdir=e._,exports.readdirSync=e.v,exports.remount=e.y,exports.rename=e.b,exports.renameSync=e.x,exports.rm=e.S,exports.rmSync=e.C,exports.rmdirSync=e.w,exports.stat=e.T,exports.statSync=e.E,exports.unlink=e.D,exports.unlinkSync=e.O,exports.writeFile=e.k,exports.writeFileSync=e.A;
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;
package/fs.d.ts CHANGED
@@ -1,92 +1,3 @@
1
- import { a as WriteData, i as Stats, n as MakeOptions, o as WriteOptions, r as ReadOptions, t as Callback } from "./index-C6ZoDJg8.js";
2
-
3
- //#region src/lib/fs/index.d.ts
4
- declare namespace index_d_exports {
5
- export { Stats, appendFile, appendFileSync, available, _default as default, exists, existsSync, flush, lstatSync, mkdir, mkdirSync, mount, promises, pull, readFile, readFileSync, readdir, readdirSync, remount, rename, renameSync, rm, rmSync, rmdirSync, stat, statSync, unlink, unlinkSync, writeFile, writeFileSync };
6
- }
7
- declare const available: () => Promise<boolean>, readFileSync: (path: import("node:fs").PathLike, options?: ReadOptions) => Buffer | string, writeFileSync: (path: import("node:fs").PathLike, data: WriteData, options?: WriteOptions) => void, appendFileSync: (path: import("node:fs").PathLike, data: WriteData, 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?: {
8
- recursive?: boolean;
9
- force?: boolean;
10
- }) => void, rmdirSync: (path: import("node:fs").PathLike, options?: {
11
- recursive?: boolean;
12
- }) => void, unlinkSync: (path: import("node:fs").PathLike) => void, renameSync: (from: import("node:fs").PathLike, to: import("node:fs").PathLike) => void, 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, appendFile: (path: import("node:fs").PathLike, data: WriteData, a: WriteOptions | Callback<void>, b?: Callback<void>) => void, stat: (path: import("node:fs").PathLike, callback: Callback<Stats>) => 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: {
13
- recursive?: boolean;
14
- force?: boolean;
15
- } | 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, exists: (path: import("node:fs").PathLike, callback: (exists: boolean) => void) => void, promises: {
16
- readFile: (path: import("node:fs").PathLike, options?: ReadOptions) => Promise<Buffer | string>;
17
- writeFile: (path: import("node:fs").PathLike, data: WriteData, options?: WriteOptions) => Promise<void>;
18
- appendFile: (path: import("node:fs").PathLike, data: WriteData, options?: WriteOptions) => Promise<void>;
19
- stat: (path: import("node:fs").PathLike) => Promise<Stats>;
20
- lstat: (path: import("node:fs").PathLike) => Promise<Stats>;
21
- readdir: (path: import("node:fs").PathLike) => Promise<string[]>;
22
- mkdir: (path: import("node:fs").PathLike, options?: MakeOptions) => Promise<void>;
23
- rm: (path: import("node:fs").PathLike, options?: {
24
- recursive?: boolean;
25
- force?: boolean;
26
- }) => Promise<void>;
27
- rmdir: (path: import("node:fs").PathLike, options?: {
28
- recursive?: boolean;
29
- }) => Promise<void>;
30
- unlink: (path: import("node:fs").PathLike) => Promise<void>;
31
- rename: (from: import("node:fs").PathLike, to: import("node:fs").PathLike) => Promise<void>;
32
- access: (path: import("node:fs").PathLike) => Promise<void>;
33
- }, mount: () => Promise<void>, flush: () => Promise<void>, remount: () => Promise<void>;
34
- declare const pull: (path: string) => Promise<Blob>;
35
- declare const _default: {
36
- available: () => Promise<boolean>;
37
- readFileSync: (path: import("node:fs").PathLike, options?: ReadOptions) => Buffer | string;
38
- writeFileSync: (path: import("node:fs").PathLike, data: WriteData, options?: WriteOptions) => void;
39
- appendFileSync: (path: import("node:fs").PathLike, data: WriteData, options?: WriteOptions) => void;
40
- existsSync: (path: import("node:fs").PathLike) => boolean;
41
- statSync: (path: import("node:fs").PathLike) => Stats;
42
- lstatSync: (path: import("node:fs").PathLike) => Stats;
43
- readdirSync: (path: import("node:fs").PathLike) => string[];
44
- mkdirSync: (path: import("node:fs").PathLike, options?: MakeOptions) => void;
45
- rmSync: (path: import("node:fs").PathLike, options?: {
46
- recursive?: boolean;
47
- force?: boolean;
48
- }) => void;
49
- rmdirSync: (path: import("node:fs").PathLike, options?: {
50
- recursive?: boolean;
51
- }) => void;
52
- unlinkSync: (path: import("node:fs").PathLike) => void;
53
- renameSync: (from: import("node:fs").PathLike, to: import("node:fs").PathLike) => void;
54
- readFile: (path: import("node:fs").PathLike, a: ReadOptions | Callback<Buffer | string>, b?: Callback<Buffer | string>) => void;
55
- writeFile: (path: import("node:fs").PathLike, data: WriteData, a: WriteOptions | Callback<void>, b?: Callback<void>) => void;
56
- appendFile: (path: import("node:fs").PathLike, data: WriteData, a: WriteOptions | Callback<void>, b?: Callback<void>) => void;
57
- stat: (path: import("node:fs").PathLike, callback: Callback<Stats>) => void;
58
- readdir: (path: import("node:fs").PathLike, a: unknown, b?: Callback<string[]>) => void;
59
- mkdir: (path: import("node:fs").PathLike, a: MakeOptions | Callback<void>, b?: Callback<void>) => void;
60
- rm: (path: import("node:fs").PathLike, a: {
61
- recursive?: boolean;
62
- force?: boolean;
63
- } | Callback<void>, b?: Callback<void>) => void;
64
- unlink: (path: import("node:fs").PathLike, callback: Callback<void>) => void;
65
- rename: (from: import("node:fs").PathLike, to: import("node:fs").PathLike, callback: Callback<void>) => void;
66
- exists: (path: import("node:fs").PathLike, callback: (exists: boolean) => void) => void;
67
- promises: {
68
- readFile: (path: import("node:fs").PathLike, options?: ReadOptions) => Promise<Buffer | string>;
69
- writeFile: (path: import("node:fs").PathLike, data: WriteData, options?: WriteOptions) => Promise<void>;
70
- appendFile: (path: import("node:fs").PathLike, data: WriteData, options?: WriteOptions) => Promise<void>;
71
- stat: (path: import("node:fs").PathLike) => Promise<Stats>;
72
- lstat: (path: import("node:fs").PathLike) => Promise<Stats>;
73
- readdir: (path: import("node:fs").PathLike) => Promise<string[]>;
74
- mkdir: (path: import("node:fs").PathLike, options?: MakeOptions) => Promise<void>;
75
- rm: (path: import("node:fs").PathLike, options?: {
76
- recursive?: boolean;
77
- force?: boolean;
78
- }) => Promise<void>;
79
- rmdir: (path: import("node:fs").PathLike, options?: {
80
- recursive?: boolean;
81
- }) => Promise<void>;
82
- unlink: (path: import("node:fs").PathLike) => Promise<void>;
83
- rename: (from: import("node:fs").PathLike, to: import("node:fs").PathLike) => Promise<void>;
84
- access: (path: import("node:fs").PathLike) => Promise<void>;
85
- };
86
- mount: () => Promise<void>;
87
- flush: () => Promise<void>;
88
- remount: () => Promise<void>;
89
- pull: (path: string) => Promise<Blob>;
90
- };
91
- //#endregion
92
- export { type Stats, appendFile, appendFileSync, available, _default as default, exists, existsSync, flush, lstatSync, mkdir, mkdirSync, mount, promises, pull, readFile, readFileSync, readdir, readdirSync, remount, rename, renameSync, rm, rmSync, rmdirSync, stat, statSync, index_d_exports as t, unlink, unlinkSync, writeFile, writeFileSync };
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 };
package/fs.js CHANGED
@@ -1,2 +1,2 @@
1
- import { A as e, C as t, D as n, E as r, O as i, S as a, T as o, _ as s, a as c, b as l, d as u, f as d, g as f, h as p, i as m, k as h, l as g, m as _, n as v, o as y, p as b, r as x, s as S, t as C, u as w, v as T, w as E, x as D, y as O } from "./fs-DhPpGH0c.js";
2
- export { C as appendFile, v as appendFileSync, x as available, S as default, m as exists, c as existsSync, y as flush, g as lstatSync, w as mkdir, u as mkdirSync, d as mount, b as promises, _ as pull, p as readFile, f as readFileSync, s as readdir, T as readdirSync, O as remount, l as rename, D as renameSync, a as rm, t as rmSync, E as rmdirSync, o as stat, r as statSync, n as unlink, i as unlinkSync, h as writeFile, e as writeFileSync };
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 };
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-BPpdNdpy.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-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
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-EaGR0bVe.js";
1
+ import { n as Socket, t as Server$1 } from "./net--o3_puH-.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 { n as e } from "./rolldown-runtime-DF993M8W.js";
2
- import { n as t, t as n } from "./net-BFYMbE4N.js";
2
+ import { n as t, t as n } from "./net-VAkfxAvn.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
@@ -0,0 +1,136 @@
1
+ import { a as Stats, i as ReadOptions, n as Callback, o as WriteData$1, r as MakeOptions, s as WriteOptions, t as WriteData } from "./index-CJ0vHTcS.js";
2
+
3
+ //#region src/lib/fs/hybrid.d.ts
4
+ type AdoptSummary = {
5
+ uploaded: string[];
6
+ kept: string[];
7
+ resolved: {
8
+ path: string;
9
+ choice: 'local' | 'cloud' | 'merged';
10
+ }[];
11
+ unresolved: string[];
12
+ failed: {
13
+ path: string;
14
+ error: string;
15
+ }[];
16
+ };
17
+ type ConflictSide = {
18
+ size: number;
19
+ updatedAt: string | null;
20
+ };
21
+ type FileConflict = {
22
+ path: string;
23
+ local: ConflictSide;
24
+ cloud: ConflictSide;
25
+ readLocal: () => Promise<Blob>;
26
+ readCloud: () => Promise<Blob>;
27
+ };
28
+ type ConflictChoice = 'local' | 'cloud' | {
29
+ merged: WriteData;
30
+ } | null;
31
+ type ConflictResolver = (conflict: FileConflict) => Promise<ConflictChoice> | ConflictChoice;
32
+ 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
+ }
35
+ 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
+ recursive?: boolean;
37
+ force?: boolean;
38
+ }) => void, rmdirSync: (path: import("node:fs").PathLike, options?: {
39
+ recursive?: boolean;
40
+ }) => void, unlinkSync: (path: import("node:fs").PathLike) => void, renameSync: (from: import("node:fs").PathLike, to: import("node:fs").PathLike) => void, readFile: (path: import("node:fs").PathLike, a: ReadOptions | Callback<Buffer | string>, b?: Callback<Buffer | string>) => void, writeFile: (path: import("node:fs").PathLike, data: WriteData$1, a: WriteOptions | Callback<void>, b?: Callback<void>) => void, appendFile: (path: import("node:fs").PathLike, data: WriteData$1, a: WriteOptions | Callback<void>, b?: Callback<void>) => void, stat: (path: import("node:fs").PathLike, callback: Callback<Stats>) => 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: {
41
+ recursive?: boolean;
42
+ force?: boolean;
43
+ } | 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, exists: (path: import("node:fs").PathLike, callback: (exists: boolean) => void) => void, promises: {
44
+ readFile: (path: import("node:fs").PathLike, options?: ReadOptions) => Promise<Buffer | string>;
45
+ writeFile: (path: import("node:fs").PathLike, data: WriteData$1, options?: WriteOptions) => Promise<void>;
46
+ appendFile: (path: import("node:fs").PathLike, data: WriteData$1, options?: WriteOptions) => Promise<void>;
47
+ stat: (path: import("node:fs").PathLike) => Promise<Stats>;
48
+ lstat: (path: import("node:fs").PathLike) => Promise<Stats>;
49
+ readdir: (path: import("node:fs").PathLike) => Promise<string[]>;
50
+ mkdir: (path: import("node:fs").PathLike, options?: MakeOptions) => Promise<void>;
51
+ rm: (path: import("node:fs").PathLike, options?: {
52
+ recursive?: boolean;
53
+ force?: boolean;
54
+ }) => Promise<void>;
55
+ rmdir: (path: import("node:fs").PathLike, options?: {
56
+ recursive?: boolean;
57
+ }) => Promise<void>;
58
+ unlink: (path: import("node:fs").PathLike) => Promise<void>;
59
+ rename: (from: import("node:fs").PathLike, to: import("node:fs").PathLike) => Promise<void>;
60
+ access: (path: import("node:fs").PathLike) => Promise<void>;
61
+ }, mount: () => Promise<void>, flush: () => Promise<void>, remount: () => Promise<void>;
62
+ declare const pull: (path: string) => Promise<Blob>;
63
+ declare const adopt: () => Promise<AdoptSummary>;
64
+ declare const adoptable: () => Promise<{
65
+ paths: string[];
66
+ bytes: number;
67
+ }>;
68
+ declare const pending: () => string[];
69
+ declare const replicating: () => boolean;
70
+ declare const onConflict: (next: ConflictResolver) => (() => void);
71
+ declare const _default: {
72
+ available: () => Promise<boolean>;
73
+ readFileSync: (path: import("node:fs").PathLike, options?: ReadOptions) => Buffer | string;
74
+ writeFileSync: (path: import("node:fs").PathLike, data: WriteData$1, options?: WriteOptions) => void;
75
+ appendFileSync: (path: import("node:fs").PathLike, data: WriteData$1, options?: WriteOptions) => void;
76
+ existsSync: (path: import("node:fs").PathLike) => boolean;
77
+ statSync: (path: import("node:fs").PathLike) => Stats;
78
+ lstatSync: (path: import("node:fs").PathLike) => Stats;
79
+ readdirSync: (path: import("node:fs").PathLike) => string[];
80
+ mkdirSync: (path: import("node:fs").PathLike, options?: MakeOptions) => void;
81
+ rmSync: (path: import("node:fs").PathLike, options?: {
82
+ recursive?: boolean;
83
+ force?: boolean;
84
+ }) => void;
85
+ rmdirSync: (path: import("node:fs").PathLike, options?: {
86
+ recursive?: boolean;
87
+ }) => void;
88
+ unlinkSync: (path: import("node:fs").PathLike) => void;
89
+ renameSync: (from: import("node:fs").PathLike, to: import("node:fs").PathLike) => void;
90
+ readFile: (path: import("node:fs").PathLike, a: ReadOptions | Callback<Buffer | string>, b?: Callback<Buffer | string>) => void;
91
+ writeFile: (path: import("node:fs").PathLike, data: WriteData$1, a: WriteOptions | Callback<void>, b?: Callback<void>) => void;
92
+ appendFile: (path: import("node:fs").PathLike, data: WriteData$1, a: WriteOptions | Callback<void>, b?: Callback<void>) => void;
93
+ stat: (path: import("node:fs").PathLike, callback: Callback<Stats>) => void;
94
+ readdir: (path: import("node:fs").PathLike, a: unknown, b?: Callback<string[]>) => void;
95
+ mkdir: (path: import("node:fs").PathLike, a: MakeOptions | Callback<void>, b?: Callback<void>) => void;
96
+ rm: (path: import("node:fs").PathLike, a: {
97
+ recursive?: boolean;
98
+ force?: boolean;
99
+ } | Callback<void>, b?: Callback<void>) => void;
100
+ unlink: (path: import("node:fs").PathLike, callback: Callback<void>) => void;
101
+ rename: (from: import("node:fs").PathLike, to: import("node:fs").PathLike, callback: Callback<void>) => void;
102
+ exists: (path: import("node:fs").PathLike, callback: (exists: boolean) => void) => void;
103
+ promises: {
104
+ readFile: (path: import("node:fs").PathLike, options?: ReadOptions) => Promise<Buffer | string>;
105
+ writeFile: (path: import("node:fs").PathLike, data: WriteData$1, options?: WriteOptions) => Promise<void>;
106
+ appendFile: (path: import("node:fs").PathLike, data: WriteData$1, options?: WriteOptions) => Promise<void>;
107
+ stat: (path: import("node:fs").PathLike) => Promise<Stats>;
108
+ lstat: (path: import("node:fs").PathLike) => Promise<Stats>;
109
+ readdir: (path: import("node:fs").PathLike) => Promise<string[]>;
110
+ mkdir: (path: import("node:fs").PathLike, options?: MakeOptions) => Promise<void>;
111
+ rm: (path: import("node:fs").PathLike, options?: {
112
+ recursive?: boolean;
113
+ force?: boolean;
114
+ }) => Promise<void>;
115
+ rmdir: (path: import("node:fs").PathLike, options?: {
116
+ recursive?: boolean;
117
+ }) => Promise<void>;
118
+ unlink: (path: import("node:fs").PathLike) => Promise<void>;
119
+ rename: (from: import("node:fs").PathLike, to: import("node:fs").PathLike) => Promise<void>;
120
+ access: (path: import("node:fs").PathLike) => Promise<void>;
121
+ };
122
+ mount: () => Promise<void>;
123
+ flush: () => Promise<void>;
124
+ remount: () => Promise<void>;
125
+ pull: (path: string) => Promise<Blob>;
126
+ adopt: () => Promise<AdoptSummary>;
127
+ adoptable: () => Promise<{
128
+ paths: string[];
129
+ bytes: number;
130
+ }>;
131
+ pending: () => string[];
132
+ replicating: () => boolean;
133
+ onConflict: (next: ConflictResolver) => (() => void);
134
+ };
135
+ //#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 };
@@ -11,7 +11,7 @@ type WriteOptions = BufferEncoding | {
11
11
  flag?: string;
12
12
  contentType?: string;
13
13
  } | null | undefined;
14
- type WriteData = string | Uint8Array | ArrayBuffer | DataView;
14
+ type WriteData$1 = string | Uint8Array | ArrayBuffer | DataView;
15
15
  type MakeOptions = {
16
16
  recursive?: boolean;
17
17
  } | number | null | undefined;
@@ -28,4 +28,7 @@ type Stats = {
28
28
  isSymbolicLink: () => boolean;
29
29
  };
30
30
  //#endregion
31
- export { WriteData as a, Stats as i, MakeOptions as n, WriteOptions as o, ReadOptions as r, Callback as t };
31
+ //#region src/lib/fs/types.d.ts
32
+ type WriteData = Blob | ArrayBuffer | Uint8Array | string;
33
+ //#endregion
34
+ export { Stats as a, ReadOptions as i, Callback as n, WriteData$1 as o, MakeOptions as r, WriteOptions as s, WriteData as t };
package/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./proxy-Bo-8GoRU.cjs"),t=require("./api-DD5v1qP9.cjs"),n=require("./cloud-Gs4fvw2S.cjs"),r=require("./dns.cjs"),i=require("./net-BPpdNdpy.cjs"),a=require("./dgram-DcvdNkg6.cjs"),o=require("./http.cjs"),s=require("./extension-BeARgX1g.cjs"),c=require("./desktop.cjs"),l=require("./fs-CP-81e-c.cjs"),u=require("./opfs.cjs"),d=require("./packages.cjs"),f=require("./account.cjs"),p=require("./connect-button-BBEjXzB3.cjs");let m=require("osra");var h=1e4,g=150,_=()=>new Promise(t=>{if(e.P())return t(!0);let n,r=setTimeout(()=>i(e.P()),h),i=e=>{clearTimeout(n),clearTimeout(r),o.disconnect(),document.removeEventListener(`readystatechange`,s),t(e)},a=()=>{clearTimeout(n),n=setTimeout(()=>i(e.P()),g)},o=new MutationObserver(()=>{e.P()&&i(!0)}),s=()=>{document.readyState===`complete`&&!e.P()&&a()};o.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-fkn-extension`]}),document.addEventListener(`readystatechange`,s),document.readyState===`complete`&&a()}),v=async t=>s.r()||t.lockdown||!n.a()||await _()?e.a(t):n.i(t),y=`https://fkn.app`,b=(e,n)=>{if(typeof window>`u`)throw Error(`FKN @fkn/lib: relayWorker must be called from the main thread`);if(!t.r?.contentWindow)throw Error(`FKN @fkn/lib: relayWorker called before the FKN iframe was injected`);(0,m.relay)({receive:window,emit:t.r.contentWindow},e,{key:`fkn-api`,originA:n?.originA??y,originB:n?.originB??`*`,unregisterSignal:n?.unregisterSignal})},x=async()=>typeof window>`u`?!1:(await t.t).connect.prompt(location.origin).catch(()=>!1),S=async()=>typeof window>`u`?null:(await t.t).relay.prompt().catch(()=>null);exports.ATTACH_FRAME_EVENT_KEY=e.i,Object.defineProperty(exports,"account",{enumerable:!0,get:function(){return f.t}}),exports.assertAttachableFrameUrl=e.l,exports.assertFetchableUrl=e.E,exports.assertLockdownApplicable=e.u,exports.attachFrame=v,exports.attachFramePermission=e.o,exports.box=e.R,Object.defineProperty(exports,"cloud",{enumerable:!0,get:function(){return n.n}}),exports.connect=x,exports.connectButtonUrl=p.t,exports.cookies=e.w,exports.createFrame=e.s,exports.createVideoElementHandle=e.z,Object.defineProperty(exports,"desktop",{enumerable:!0,get:function(){return c.t}}),Object.defineProperty(exports,"dgram",{enumerable:!0,get:function(){return a.i}}),Object.defineProperty(exports,"dns",{enumerable:!0,get:function(){return r.t}}),Object.defineProperty(exports,"extension",{enumerable:!0,get:function(){return s.t}}),exports.fetch=s.n,exports.fetchCredentialedPermission=e.O,exports.fetchLocalPermission=e.k,exports.fetchPermission=e.A,Object.defineProperty(exports,"fs",{enumerable:!0,get:function(){return l.c}}),exports.gotoPermission=e.c,exports.handleRevivableModules=e.L,Object.defineProperty(exports,"http",{enumerable:!0,get:function(){return o.t}}),exports.isBlockedFetchUrl=e.j,exports.isBlockedFrameUrl=e.d,exports.isExtensionExposed=e.P,exports.isLocalNetworkUrl=e.M,exports.isType=e.B,exports.modifyRequestHeadersPermission=e.x,Object.defineProperty(exports,"net",{enumerable:!0,get:function(){return i.s}}),Object.defineProperty(exports,"opfs",{enumerable:!0,get:function(){return u.t}}),Object.defineProperty(exports,"packages",{enumerable:!0,get:function(){return d.t}}),exports.permissions=e.r,exports.promptInstall=s.i,exports.promptRelay=S,exports.readCookiePermission=e.T,exports.relayWorker=b,exports.removeRequestHeaderRule=e.S,exports.revive=e.V,exports.setMissingExtensionHandler=e.F,exports.setRequestHeaderRule=e.C,exports.type=e.H,exports.waitForExtensionExposure=e.I;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./proxy-g2yknq7C.cjs"),t=require("./api-BwrS6P0x.cjs"),n=require("./cloud-BcpPsNs3.cjs"),r=require("./dns.cjs"),i=require("./net-BOyLJ3mh.cjs"),a=require("./dgram-pCNllfov.cjs"),o=require("./http.cjs"),s=require("./extension-CjJNj5Yl.cjs"),c=require("./desktop.cjs"),l=require("./fs-B8Rc1zRI.cjs"),u=require("./opfs.cjs"),d=require("./packages.cjs"),f=require("./account.cjs"),p=require("./connect-button-BBEjXzB3.cjs");let m=require("osra");var h=1e4,g=150,_=()=>new Promise(t=>{if(e.P())return t(!0);let n,r=setTimeout(()=>i(e.P()),h),i=e=>{clearTimeout(n),clearTimeout(r),o.disconnect(),document.removeEventListener(`readystatechange`,s),t(e)},a=()=>{clearTimeout(n),n=setTimeout(()=>i(e.P()),g)},o=new MutationObserver(()=>{e.P()&&i(!0)}),s=()=>{document.readyState===`complete`&&!e.P()&&a()};o.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-fkn-extension`]}),document.addEventListener(`readystatechange`,s),document.readyState===`complete`&&a()}),v=async t=>s.r()||t.lockdown||!n.a()||await _()?e.a(t):n.i(t),y=`https://fkn.app`,b=(e,n)=>{if(typeof window>`u`)throw Error(`FKN @fkn/lib: relayWorker must be called from the main thread`);if(!t.i?.contentWindow)throw Error(`FKN @fkn/lib: relayWorker called before the FKN iframe was injected`);(0,m.relay)({receive:window,emit:t.i.contentWindow},e,{key:`fkn-api`,originA:n?.originA??y,originB:n?.originB??`*`,unregisterSignal:n?.unregisterSignal})},x=async()=>typeof window>`u`?!1:(await t.t).connect.prompt(location.origin).catch(()=>!1),S=async()=>typeof window>`u`?null:(await t.t).relay.prompt().catch(()=>null);exports.ATTACH_FRAME_EVENT_KEY=e.i,Object.defineProperty(exports,"account",{enumerable:!0,get:function(){return f.t}}),exports.assertAttachableFrameUrl=e.l,exports.assertFetchableUrl=e.E,exports.assertLockdownApplicable=e.u,exports.attachFrame=v,exports.attachFramePermission=e.o,exports.box=e.R,Object.defineProperty(exports,"cloud",{enumerable:!0,get:function(){return n.n}}),exports.connect=x,exports.connectButtonUrl=p.t,exports.cookies=e.w,exports.createFrame=e.s,exports.createVideoElementHandle=e.z,Object.defineProperty(exports,"desktop",{enumerable:!0,get:function(){return c.t}}),Object.defineProperty(exports,"dgram",{enumerable:!0,get:function(){return a.i}}),Object.defineProperty(exports,"dns",{enumerable:!0,get:function(){return r.t}}),Object.defineProperty(exports,"extension",{enumerable:!0,get:function(){return s.t}}),exports.fetch=s.n,exports.fetchCredentialedPermission=e.O,exports.fetchLocalPermission=e.k,exports.fetchPermission=e.A,Object.defineProperty(exports,"fs",{enumerable:!0,get:function(){return l.u}}),exports.gotoPermission=e.c,exports.handleRevivableModules=e.L,Object.defineProperty(exports,"http",{enumerable:!0,get:function(){return o.t}}),exports.isBlockedFetchUrl=e.j,exports.isBlockedFrameUrl=e.d,exports.isExtensionExposed=e.P,exports.isLocalNetworkUrl=e.M,exports.isType=e.B,exports.modifyRequestHeadersPermission=e.x,Object.defineProperty(exports,"net",{enumerable:!0,get:function(){return i.s}}),Object.defineProperty(exports,"opfs",{enumerable:!0,get:function(){return u.t}}),Object.defineProperty(exports,"packages",{enumerable:!0,get:function(){return d.t}}),exports.permissions=e.r,exports.promptInstall=s.i,exports.promptRelay=S,exports.readCookiePermission=e.T,exports.relayWorker=b,exports.removeRequestHeaderRule=e.S,exports.revive=e.V,exports.setMissingExtensionHandler=e.F,exports.setRequestHeaderRule=e.C,exports.type=e.H,exports.waitForExtensionExposure=e.I;
package/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  import { t as account_d_exports } from "./account.js";
2
2
  import { m as packages_d_exports } from "./packages-CErlrrLB.js";
3
- import { n as cloud_d_exports } from "./cloud-BPd7yisS.js";
3
+ import { n as cloud_d_exports } from "./cloud-7C3sOMF_.js";
4
4
  import { A as RequestHeaderRule, B as assertFetchableUrl, C as attachFramePermission, D as assertLockdownApplicable, E as assertAttachableFrameUrl, F as SiteCookie, G as isBlockedFetchUrl, H as fetchCredentialedPermission, I as cookies, K as isLocalNetworkUrl, L as readCookiePermission, M as removeRequestHeaderRule, N as setRequestHeaderRule, O as isBlockedFrameUrl, P as CookieDetails, R as FetchInit, S as GotoOptions, T as gotoPermission, U as fetchLocalPermission, W as fetchPermission, _ as ATTACH_FRAME_EVENT_KEY, a as handleRevivableModules, b as Frame, c as VideoElementState, d as isType, f as revive, g as permissions, h as PermissionRequest, i as waitForExtensionExposure, j as modifyRequestHeadersPermission, k as HeaderOperation, l as box, m as PermissionGrant, n as isExtensionExposed, o as BoxedVideoElement, p as type, r as setMissingExtensionHandler, s as RemoteVideoElement, u as createVideoElementHandle, w as createFrame, x as FrameBackend, y as AttachFrameOptions, z as ProxyFetchRequest } from "./index-BJztAQIP.js";
5
5
  import { t as dns_d_exports } from "./dns.js";
6
- import { s as net_d_exports } from "./net-EaGR0bVe.js";
6
+ import { s as net_d_exports } from "./net--o3_puH-.js";
7
7
  import { t as dgram_d_exports } from "./dgram.js";
8
8
  import { t as http_d_exports } from "./http.js";
9
9
  import { t as desktop_d_exports } from "./desktop.js";
10
10
  import { i as promptInstall, n as fetch, t as extension_d_exports } from "./extension-3pxUYwrA.js";
11
- import { t as index_d_exports } from "./fs.js";
11
+ import { u as index_d_exports } from "./index-Bt2VAVEC.js";
12
12
  import { t as index_d_exports$1 } from "./opfs.js";
13
13
  import { t as connectButtonUrl } from "./connect-button-D8KXSL6s.js";
14
14