@fkn/lib 0.9.39 → 0.9.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/account-generation-CSnZiN18.cjs +1 -0
- package/account-generation-D7TpIoKt.js +28 -0
- package/account.cjs +1 -1
- package/account.d.ts +11 -0
- package/account.js +5 -17
- package/{api-BxXnHxbd.d.ts → api-Cbty0JUM.d.ts} +15 -13
- package/api.d.ts +2 -2
- package/cloud/dns.d.ts +1 -1
- package/cloud/fetch.d.ts +1 -1
- package/cloud/fs/promises.d.ts +1 -1
- package/cloud/fs.cjs +1 -1
- package/cloud/fs.d.ts +4 -4
- package/cloud/fs.js +31 -24
- package/cloud/net.d.ts +1 -1
- package/{cloud-B8QYSmW3.d.ts → cloud-4t1WoEZn.d.ts} +3 -3
- package/{cloud-oMACx7NL.js → cloud-BLv19j-W.js} +200 -196
- package/cloud-D7aQY4GH.cjs +1 -0
- package/cloud.cjs +1 -1
- package/cloud.d.ts +4 -4
- package/cloud.js +1 -1
- package/{contract-sDmsw-9f.d.ts → contract-BRc2ptdC.d.ts} +33 -10
- package/contract.d.ts +2 -2
- package/dgram.d.ts +2 -2
- package/dns.d.ts +1 -1
- package/extension-B9v933cT.js +89 -0
- package/extension-D2zMdc2f.cjs +1 -0
- package/extension.cjs +1 -1
- package/extension.js +3 -3
- package/fs/promises.cjs +1 -1
- package/fs/promises.d.ts +1 -1
- package/fs/promises.js +1 -1
- package/fs-BTyRnUPI.cjs +1 -0
- package/{fs--NhtUyYa.d.ts → fs-D0MMRnHC.d.ts} +8 -4
- package/fs-q7Kg51hq.js +513 -0
- package/fs.cjs +1 -1
- package/fs.d.ts +4 -3
- package/fs.js +4 -2
- package/http.d.ts +1 -1
- package/{index-kuPqkS_-.d.ts → index-D2lvaQDs.d.ts} +28 -38
- package/index.cjs +1 -1
- package/index.d.ts +3 -3
- package/index.js +13 -13
- package/{lib-tQKlXzhv.cjs → lib-BfAg9mHD.cjs} +1 -1
- package/{lib-BlyFPeSv.js → lib-C4Eeg9eM.js} +2 -2
- package/{messages-C66ghz_A.d.ts → messages-CRcziTuC.d.ts} +17 -1
- package/messages.cjs +1 -1
- package/messages.d.ts +2 -2
- package/messages.js +2 -2
- package/{net-Qmt9L_7t.d.ts → net-CcEZP6Bb.d.ts} +2 -2
- package/net.d.ts +1 -1
- package/{node-fs-BZy9bzKd.js → node-fs-CK2wWIYS.js} +140 -137
- package/node-fs-nfX7wisL.cjs +1 -0
- package/opfs.cjs +1 -1
- package/opfs.js +1 -1
- package/package.json +1 -1
- package/packages.d.ts +1 -1
- package/{proxy-CxRQLGNG.d.ts → proxy-D6YtsO1g.d.ts} +2 -2
- package/rooms.d.ts +1 -1
- package/storage-BS5WMO4f.cjs +1 -0
- package/storage-BVr2Rb-d.d.ts +167 -0
- package/storage-BWmGrO6a.js +123 -0
- package/cloud-BZIJFvPF.cjs +0 -1
- package/extension-Bl5ZNj0d.cjs +0 -1
- package/extension-ChZyZgAL.js +0 -89
- package/fs-CaQFRiIT.cjs +0 -1
- package/fs-D3IsGdnN.js +0 -360
- package/node-fs-BNTPsX5c.cjs +0 -1
- package/storage-BJd-mWHE.cjs +0 -1
- package/storage-DSvL-t80.js +0 -67
- package/storage-ZrY4Y4L5.d.ts +0 -88
package/fs-q7Kg51hq.js
ADDED
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
2
|
+
import { r as t } from "./busy-B189uX--.js";
|
|
3
|
+
import { t as n } from "./node-fs-CK2wWIYS.js";
|
|
4
|
+
import { STORAGE_ACCOUNT_CHANGED as r, STORAGE_ACCOUNT_PIN_UNSUPPORTED as i } from "./messages.js";
|
|
5
|
+
import { _ as a, a as o, b as s, c, d as l, f as u, g as ee, h as d, l as te, n as ne, o as f, p as re, t as ie } from "./storage-BWmGrO6a.js";
|
|
6
|
+
import { a as ae, i as p, n as m, o as h, t as oe } from "./opfs-D0goLAQW.js";
|
|
7
|
+
//#region src/fs/hybrid.ts
|
|
8
|
+
var se = /* @__PURE__ */ e({
|
|
9
|
+
adopt: () => V,
|
|
10
|
+
adoptable: () => U,
|
|
11
|
+
available: () => ue,
|
|
12
|
+
captureAccount: () => ce,
|
|
13
|
+
list: () => Ae,
|
|
14
|
+
onConflict: () => Ie,
|
|
15
|
+
pending: () => Se,
|
|
16
|
+
pendingDeletes: () => Ce,
|
|
17
|
+
pull: () => Fe,
|
|
18
|
+
readFile: () => je,
|
|
19
|
+
readFileSealed: () => Me,
|
|
20
|
+
remove: () => Pe,
|
|
21
|
+
replicating: () => we,
|
|
22
|
+
writeFile: () => Ne
|
|
23
|
+
}), ce = f, le, g = async () => await (le ??= oe().catch(() => !1)) ? !0 : (le = void 0, !1), _ = () => o().catch(() => "unknown"), v = async () => await _() === "connected", ue = async () => await g() || await v(), de = "fkn:fs:pending", fe = "fkn:fs:pending-delete", pe = "fkn:fs:adopt-declined", y = !0, me = /* @__PURE__ */ new Map(), he = null, ge = (e, t) => {
|
|
24
|
+
if (e === null) return !1;
|
|
25
|
+
if ("generation" in e && "generation" in t) return e.generation === t.generation;
|
|
26
|
+
let n = (e) => "pin" in e ? e.pin : l(e), r = n(e);
|
|
27
|
+
return r !== void 0 && r === n(t);
|
|
28
|
+
}, b = (e, t) => ge(he, t) ? me.get(e) ?? null : null, x = (e) => e === "write" ? de : fe, S = (e) => {
|
|
29
|
+
try {
|
|
30
|
+
let t = localStorage.getItem(x(e));
|
|
31
|
+
if (!t) return {};
|
|
32
|
+
let n = JSON.parse(t);
|
|
33
|
+
if (Array.isArray(n)) return Object.fromEntries(n.filter((e) => typeof e == "string").map((e) => [e, {
|
|
34
|
+
base: null,
|
|
35
|
+
pin: null
|
|
36
|
+
}]));
|
|
37
|
+
if (!n || typeof n != "object") return {};
|
|
38
|
+
let r = {};
|
|
39
|
+
for (let [e, t] of Object.entries(n)) if (t === null || typeof t == "string") r[e] = {
|
|
40
|
+
base: t,
|
|
41
|
+
pin: null
|
|
42
|
+
};
|
|
43
|
+
else if (typeof t == "object") {
|
|
44
|
+
let { base: n, pin: i } = t;
|
|
45
|
+
r[e] = {
|
|
46
|
+
base: typeof n == "string" ? n : null,
|
|
47
|
+
pin: typeof i == "string" && i ? i : null
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return r;
|
|
51
|
+
} catch {
|
|
52
|
+
return {};
|
|
53
|
+
}
|
|
54
|
+
}, C = (e, t) => {
|
|
55
|
+
try {
|
|
56
|
+
Object.keys(t).length ? localStorage.setItem(x(e), JSON.stringify(t)) : localStorage.removeItem(x(e));
|
|
57
|
+
} catch {}
|
|
58
|
+
}, _e = () => {
|
|
59
|
+
try {
|
|
60
|
+
let e = JSON.parse(localStorage.getItem(pe) ?? "{}");
|
|
61
|
+
return e && typeof e == "object" && !Array.isArray(e) ? e : {};
|
|
62
|
+
} catch {
|
|
63
|
+
return {};
|
|
64
|
+
}
|
|
65
|
+
}, w = /* @__PURE__ */ new Map(), ve = (e) => "pin" in e ? e.pin : l(e) ?? null, ye = (e, t, n, r) => {
|
|
66
|
+
let i = S(e), a = i[t], o = ve(r);
|
|
67
|
+
a && o !== null && a.pin === o || (i[t] = {
|
|
68
|
+
base: a ? a.base : n,
|
|
69
|
+
pin: o
|
|
70
|
+
}, C(e, i), o === null && "generation" in r ? w.set(`${e}:${t}`, r) : w.delete(`${e}:${t}`));
|
|
71
|
+
}, be = (e, t) => {
|
|
72
|
+
w.delete(`${e}:${t}`);
|
|
73
|
+
let n = S(e);
|
|
74
|
+
t in n && (delete n[t], C(e, n), j() || (N = M));
|
|
75
|
+
}, T = (e, t, n) => ye("write", e, t, n), E = (e) => be("write", e), xe = (e, t) => ye("delete", e, b(e, t), t), D = (e) => be("delete", e), Se = () => Object.keys(S("write")), Ce = () => Object.keys(S("delete")), we = () => y, O = /* @__PURE__ */ new Map(), Te = (e) => O.get(e) === f().generation, Ee = (e, t, n) => n.pin === null && !w.has(`${e}:${t}`), k = null, A = !1;
|
|
76
|
+
t("storage replication", () => k !== null || W !== null);
|
|
77
|
+
var j = () => ["write", "delete"].some((e) => Object.entries(S(e)).some(([t, n]) => n.pin === null ? !Ee(e, t, n) : !Te(n.pin))), M = 6e4, De = 6e5, N = M, P = null, F = () => {
|
|
78
|
+
!P && typeof window < "u" && j() && (P = setTimeout(() => {
|
|
79
|
+
P = null, I();
|
|
80
|
+
}, N), N = Math.min(N * 2, De));
|
|
81
|
+
}, I = () => {
|
|
82
|
+
if (k) {
|
|
83
|
+
A = !0;
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
j() && (k = He(!1, f()).then((e) => {
|
|
87
|
+
if (!j()) {
|
|
88
|
+
N = M;
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
e.failed.length && F();
|
|
92
|
+
}).catch(() => {
|
|
93
|
+
F();
|
|
94
|
+
}).finally(() => {
|
|
95
|
+
k = null, Oe();
|
|
96
|
+
}));
|
|
97
|
+
}, Oe = () => {
|
|
98
|
+
A && (A = !1, I());
|
|
99
|
+
}, ke = null, L = () => ke ??= import("./api.js").then((e) => e.apiPromise), Ae = async (e) => {
|
|
100
|
+
let t = e?.pin ?? f();
|
|
101
|
+
q();
|
|
102
|
+
let n = await _(), r = n === "connected", [i, a] = await Promise.all([g().then((e) => e ? m() : []).catch(() => []), r ? u({ pin: t }).then((e) => ({
|
|
103
|
+
ok: !0,
|
|
104
|
+
entries: e
|
|
105
|
+
}), (e) => ({
|
|
106
|
+
ok: !1,
|
|
107
|
+
entries: [],
|
|
108
|
+
changed: c(e) ? e : void 0
|
|
109
|
+
})) : Promise.resolve({
|
|
110
|
+
ok: n === "disconnected",
|
|
111
|
+
entries: []
|
|
112
|
+
})]);
|
|
113
|
+
if (n !== "unknown" && (y = a.ok), a.ok && n !== "unknown" && (me = new Map(a.entries.map((e) => [e.path, e.updatedAt])), he = t), a.changed) throw a.changed;
|
|
114
|
+
let o = /* @__PURE__ */ new Map(), s = (e) => {
|
|
115
|
+
let t = Date.parse(e.updatedAt ?? "");
|
|
116
|
+
return Number.isFinite(t) ? t : 0;
|
|
117
|
+
}, l = (e) => {
|
|
118
|
+
let t = o.get(e.path);
|
|
119
|
+
(!t || s(e) >= s(t)) && o.set(e.path, e);
|
|
120
|
+
};
|
|
121
|
+
for (let e of i) l(e);
|
|
122
|
+
for (let e of a.entries) l(e);
|
|
123
|
+
return a.ok && r && (Ye(i, a.entries).catch(() => {}), j() ? I() : K({
|
|
124
|
+
local: i,
|
|
125
|
+
remote: a.entries,
|
|
126
|
+
from: t
|
|
127
|
+
}).catch(() => {})), [...o.values()];
|
|
128
|
+
}, je = async (e, t) => {
|
|
129
|
+
let n = t?.pin ?? f();
|
|
130
|
+
if (await g()) try {
|
|
131
|
+
return await p(e);
|
|
132
|
+
} catch (e) {
|
|
133
|
+
if (e?.name !== "NotFoundError") throw e;
|
|
134
|
+
}
|
|
135
|
+
let r = await d(e, { pin: n });
|
|
136
|
+
return await g() && h(e, r).catch(() => {}), r;
|
|
137
|
+
}, Me = async (e, t) => {
|
|
138
|
+
let n = t?.pin ?? f();
|
|
139
|
+
if (await g()) try {
|
|
140
|
+
let t = await p(e);
|
|
141
|
+
return {
|
|
142
|
+
data: new Uint8Array(await t.arrayBuffer()),
|
|
143
|
+
sealedAt: null
|
|
144
|
+
};
|
|
145
|
+
} catch (e) {
|
|
146
|
+
if (e?.name !== "NotFoundError") throw e;
|
|
147
|
+
}
|
|
148
|
+
return ee(e, { pin: n });
|
|
149
|
+
}, Ne = async (e, t, n) => {
|
|
150
|
+
let r = n?.pin ?? f(), i = n?.contentType, a = i ? { contentType: i } : void 0, o = t instanceof Blob ? t : new Blob([t], a ? { type: a.contentType } : void 0);
|
|
151
|
+
if (await g()) {
|
|
152
|
+
await h(e, o, a), q();
|
|
153
|
+
let t = b(e, r), n = await _();
|
|
154
|
+
if (n === "disconnected") return;
|
|
155
|
+
if (n === "unknown" || !y) {
|
|
156
|
+
T(e, t, r), F();
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
s(e, o, {
|
|
160
|
+
...a,
|
|
161
|
+
pin: r
|
|
162
|
+
}).then(() => E(e)).catch((n) => {
|
|
163
|
+
T(e, t, r), c(n) || F(), console.warn("fs: cloud replicate failed, queued for adopt()", n);
|
|
164
|
+
});
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
let l = await _();
|
|
168
|
+
if (l === "connected") return s(e, o, {
|
|
169
|
+
...a,
|
|
170
|
+
pin: r
|
|
171
|
+
});
|
|
172
|
+
throw Error(l === "unknown" ? "fs: cloud unreachable" : "fs: no storage backend available");
|
|
173
|
+
}, Pe = async (e, t) => {
|
|
174
|
+
let n = t?.pin ?? f();
|
|
175
|
+
q();
|
|
176
|
+
let r = [];
|
|
177
|
+
await g() && r.push(ae(e).catch(() => {}));
|
|
178
|
+
let i = await _();
|
|
179
|
+
if (i === "connected" ? r.push(a(e, { pin: n }).then(() => D(e)).catch((t) => {
|
|
180
|
+
xe(e, n), c(t) || F(), console.warn("fs: cloud delete failed, queued for retry", t);
|
|
181
|
+
})) : i === "unknown" && r.length && b(e, n) !== null && (xe(e, n), F()), !r.length) throw Error(i === "unknown" ? "fs: cloud unreachable" : "fs: no storage backend available");
|
|
182
|
+
E(e), await Promise.all(r);
|
|
183
|
+
}, Fe = async (e) => {
|
|
184
|
+
let t = f(), n = await d(e, { pin: t });
|
|
185
|
+
return await g() && await h(e, n), n;
|
|
186
|
+
}, R = null, Ie = (e) => (R = e, () => {
|
|
187
|
+
R === e && (R = null);
|
|
188
|
+
}), Le = async (e) => {
|
|
189
|
+
let t = await (await L()).cloud.fs.promptConflict({
|
|
190
|
+
path: e.path,
|
|
191
|
+
local: e.local,
|
|
192
|
+
cloud: e.cloud
|
|
193
|
+
}).catch(() => null);
|
|
194
|
+
return t === "local" ? e.readLocal() : t === "cloud" ? e.readCloud() : null;
|
|
195
|
+
}, Re = async (e) => {
|
|
196
|
+
if (R) try {
|
|
197
|
+
return await R(e);
|
|
198
|
+
} catch {
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
return Le(e);
|
|
202
|
+
}, z = class extends Error {}, B = (e) => e instanceof Error ? e.message : String(e), ze = () => {
|
|
203
|
+
let e = /* @__PURE__ */ new Map(), t = (t) => {
|
|
204
|
+
let n = e.get(t);
|
|
205
|
+
return n || e.set(t, n = {
|
|
206
|
+
writes: /* @__PURE__ */ new Map(),
|
|
207
|
+
deletes: /* @__PURE__ */ new Map()
|
|
208
|
+
}), n;
|
|
209
|
+
};
|
|
210
|
+
for (let [e, n] of Object.entries(S("write"))) t(n.pin).writes.set(e, n.base);
|
|
211
|
+
for (let [e, n] of Object.entries(S("delete"))) t(n.pin).deletes.set(e, n.base);
|
|
212
|
+
return e;
|
|
213
|
+
}, Be = async () => {
|
|
214
|
+
for (let [e, t] of [...w]) {
|
|
215
|
+
let n = e.startsWith("write:") ? "write" : "delete", r = e.slice(n.length + 1), i;
|
|
216
|
+
try {
|
|
217
|
+
i = await re(t);
|
|
218
|
+
} catch (t) {
|
|
219
|
+
c(t) && w.delete(e);
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
if (w.get(e) !== t) continue;
|
|
223
|
+
w.delete(e);
|
|
224
|
+
let a = S(n), o = a[r];
|
|
225
|
+
o && o.pin === null && (a[r] = {
|
|
226
|
+
base: o.base,
|
|
227
|
+
pin: i
|
|
228
|
+
}, C(n, a));
|
|
229
|
+
}
|
|
230
|
+
}, Ve = async (e, t, n, r, i, o) => {
|
|
231
|
+
let l = new Map(t.map((e) => [e.path, e])), u = (e) => {
|
|
232
|
+
if (c(e)) throw new z();
|
|
233
|
+
};
|
|
234
|
+
for (let [t, o] of e.deletes) {
|
|
235
|
+
let e = l.get(t);
|
|
236
|
+
if (!e) {
|
|
237
|
+
D(t);
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
if (r.some((e) => e.path === t)) {
|
|
241
|
+
D(t);
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
if (e.updatedAt !== o) {
|
|
245
|
+
D(t);
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
try {
|
|
249
|
+
await a(t, n), D(t), i.deleted.push(t);
|
|
250
|
+
} catch (e) {
|
|
251
|
+
u(e), i.failed.push({
|
|
252
|
+
path: t,
|
|
253
|
+
error: B(e)
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
for (let t of r) {
|
|
258
|
+
let r = l.get(t.path), a = e.writes.has(t.path);
|
|
259
|
+
if (!a) {
|
|
260
|
+
if (!o(t)) continue;
|
|
261
|
+
if (r) {
|
|
262
|
+
i.kept.push(t.path);
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
let c = e.writes.get(t.path) ?? null;
|
|
267
|
+
if (a && r && r.updatedAt !== c) {
|
|
268
|
+
let e = null, a = null, o = await Re({
|
|
269
|
+
path: t.path,
|
|
270
|
+
local: {
|
|
271
|
+
size: t.size,
|
|
272
|
+
updatedAt: t.updatedAt
|
|
273
|
+
},
|
|
274
|
+
cloud: {
|
|
275
|
+
size: r.size,
|
|
276
|
+
updatedAt: r.updatedAt
|
|
277
|
+
},
|
|
278
|
+
readLocal: () => e ??= p(t.path),
|
|
279
|
+
readCloud: () => a ??= d(t.path, n)
|
|
280
|
+
});
|
|
281
|
+
if (o == null) {
|
|
282
|
+
i.unresolved.push(t.path);
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
try {
|
|
286
|
+
let r = e !== null && o === await e, c = a !== null && o === await a;
|
|
287
|
+
c || await s(t.path, o, t.contentType ? {
|
|
288
|
+
contentType: t.contentType,
|
|
289
|
+
...n
|
|
290
|
+
} : n), r || await h(t.path, o), E(t.path), i.resolved.push({
|
|
291
|
+
path: t.path,
|
|
292
|
+
choice: r ? "local" : c ? "cloud" : "merged"
|
|
293
|
+
});
|
|
294
|
+
} catch (e) {
|
|
295
|
+
if (u(e), e?.code === "FKN_E2E_LOCKED") throw e;
|
|
296
|
+
i.failed.push({
|
|
297
|
+
path: t.path,
|
|
298
|
+
error: B(e)
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
try {
|
|
304
|
+
let e = await p(t.path);
|
|
305
|
+
await s(t.path, e, t.contentType ? {
|
|
306
|
+
contentType: t.contentType,
|
|
307
|
+
...n
|
|
308
|
+
} : n), E(t.path), i.uploaded.push(t.path);
|
|
309
|
+
} catch (e) {
|
|
310
|
+
if (a || T(t.path, r?.updatedAt ?? null, n.pin), u(e), e?.code === "FKN_E2E_LOCKED") throw e;
|
|
311
|
+
i.failed.push({
|
|
312
|
+
path: t.path,
|
|
313
|
+
error: B(e)
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}, He = async (e, t) => {
|
|
318
|
+
let n = {
|
|
319
|
+
uploaded: [],
|
|
320
|
+
kept: [],
|
|
321
|
+
resolved: [],
|
|
322
|
+
unresolved: [],
|
|
323
|
+
deleted: [],
|
|
324
|
+
failed: []
|
|
325
|
+
}, r = await _();
|
|
326
|
+
if (r === "unknown") throw Error("fs: cloud unreachable");
|
|
327
|
+
if (r !== "connected") throw Error("fs: this needs a signed-in account");
|
|
328
|
+
let i = await g(), a = i ? await m() : [];
|
|
329
|
+
if (i) for (let e of Object.keys(S("write"))) a.some((t) => t.path === e) || E(e);
|
|
330
|
+
await Be();
|
|
331
|
+
for (let [e, r] of ze()) {
|
|
332
|
+
if (e === null || Te(e)) continue;
|
|
333
|
+
let i = { pin: { pin: e } }, o;
|
|
334
|
+
try {
|
|
335
|
+
o = await u(i);
|
|
336
|
+
} catch (n) {
|
|
337
|
+
if (c(n)) {
|
|
338
|
+
O.set(e, t.generation);
|
|
339
|
+
continue;
|
|
340
|
+
}
|
|
341
|
+
if (te(n)) {
|
|
342
|
+
Ue(e);
|
|
343
|
+
continue;
|
|
344
|
+
}
|
|
345
|
+
throw n;
|
|
346
|
+
}
|
|
347
|
+
try {
|
|
348
|
+
await Ve(r, o, i, a, n, () => !1);
|
|
349
|
+
} catch (n) {
|
|
350
|
+
if (!(n instanceof z)) throw n;
|
|
351
|
+
O.set(e, t.generation);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
if (e) {
|
|
355
|
+
let e = { pin: t }, r = await u(e), i = S("write"), o = ze().get(null) ?? {
|
|
356
|
+
writes: /* @__PURE__ */ new Map(),
|
|
357
|
+
deletes: /* @__PURE__ */ new Map()
|
|
358
|
+
}, s = /* @__PURE__ */ new Set([
|
|
359
|
+
...n.uploaded,
|
|
360
|
+
...n.resolved.map(({ path: e }) => e),
|
|
361
|
+
...n.unresolved,
|
|
362
|
+
...n.failed.map(({ path: e }) => e)
|
|
363
|
+
]), c = (e) => !(e.path in i) && !s.has(e.path);
|
|
364
|
+
try {
|
|
365
|
+
await Ve(o, r, e, a, n, c);
|
|
366
|
+
} catch (e) {
|
|
367
|
+
throw e instanceof z ? new ie() : e;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return n;
|
|
371
|
+
}, Ue = (e) => {
|
|
372
|
+
for (let t of ["write", "delete"]) {
|
|
373
|
+
let n = S(t), r = !1;
|
|
374
|
+
for (let t of Object.values(n)) t.pin === e && (t.pin = null, r = !0);
|
|
375
|
+
r && C(t, n);
|
|
376
|
+
}
|
|
377
|
+
}, We = async (e) => {
|
|
378
|
+
for (; k;) await k;
|
|
379
|
+
let t = He(!0, e);
|
|
380
|
+
k = t.then(() => {}, () => {});
|
|
381
|
+
try {
|
|
382
|
+
return await t;
|
|
383
|
+
} finally {
|
|
384
|
+
k = null, Oe();
|
|
385
|
+
}
|
|
386
|
+
}, V = () => We(f()), H = (e, t) => {
|
|
387
|
+
let n = new Set(t.map((e) => e.path)), r = S("write");
|
|
388
|
+
return e.filter((e) => {
|
|
389
|
+
let t = r[e.path];
|
|
390
|
+
return t ? Ee("write", e.path, t) : !n.has(e.path);
|
|
391
|
+
});
|
|
392
|
+
}, U = async () => {
|
|
393
|
+
let e = f();
|
|
394
|
+
if (!await v() || !await g()) return {
|
|
395
|
+
paths: [],
|
|
396
|
+
bytes: 0
|
|
397
|
+
};
|
|
398
|
+
let [t, n] = await Promise.all([m(), u({ pin: e })]), r = H(t, n);
|
|
399
|
+
return {
|
|
400
|
+
paths: r.map((e) => e.path),
|
|
401
|
+
bytes: r.reduce((e, t) => e + t.size, 0)
|
|
402
|
+
};
|
|
403
|
+
}, Ge = () => new Set(Object.keys(_e())), Ke = (e) => {
|
|
404
|
+
let t = _e();
|
|
405
|
+
for (let n of e) t[n] = null;
|
|
406
|
+
try {
|
|
407
|
+
localStorage.setItem(pe, JSON.stringify(t));
|
|
408
|
+
} catch {}
|
|
409
|
+
}, W = null, G = !1, K = (e) => {
|
|
410
|
+
if (W) return G = !0, W;
|
|
411
|
+
let t = e?.from ?? f();
|
|
412
|
+
return W = (async () => {
|
|
413
|
+
if (!await v()) return;
|
|
414
|
+
let n = e ?? (await g() ? {
|
|
415
|
+
local: await m(),
|
|
416
|
+
remote: await u({ pin: t })
|
|
417
|
+
} : null);
|
|
418
|
+
if (!n) return;
|
|
419
|
+
let r = Ge(), i = H(n.local, n.remote).filter((e) => !r.has(e.path));
|
|
420
|
+
if (!i.length) return;
|
|
421
|
+
let a = await L(), o = i.reduce((e, t) => e + t.size, 0);
|
|
422
|
+
if (!await a.cloud.fs.promptAdopt({
|
|
423
|
+
files: i.length,
|
|
424
|
+
bytes: o
|
|
425
|
+
}).catch(() => !1)) {
|
|
426
|
+
Ke(i.map((e) => e.path));
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
"generation" in t && await We(t);
|
|
430
|
+
})().catch(() => {}).finally(() => {
|
|
431
|
+
W = null, G && (G = !1, K());
|
|
432
|
+
}), W;
|
|
433
|
+
}, qe = null, Je = !1, Ye = async (e, t) => {
|
|
434
|
+
let n = H(e, t), r = await L(), i = async () => {
|
|
435
|
+
await V().catch(() => {});
|
|
436
|
+
let e = await U().catch(() => ({
|
|
437
|
+
paths: [],
|
|
438
|
+
bytes: 0
|
|
439
|
+
}));
|
|
440
|
+
await r.cloud.fs.setAdoptSource({
|
|
441
|
+
files: e.paths.length,
|
|
442
|
+
bytes: e.bytes
|
|
443
|
+
}, i).catch(() => {});
|
|
444
|
+
}, a = {
|
|
445
|
+
files: n.length,
|
|
446
|
+
bytes: n.reduce((e, t) => e + t.size, 0)
|
|
447
|
+
};
|
|
448
|
+
qe = () => {
|
|
449
|
+
r.cloud.fs.setAdoptSource(a, i).catch(() => {});
|
|
450
|
+
}, Je || (Je = !0, import("./api.js").then((e) => e.onApiEpoch((e, t) => {
|
|
451
|
+
t > 1 && qe?.();
|
|
452
|
+
})).catch(() => {})), await r.cloud.fs.setAdoptSource(a, i);
|
|
453
|
+
}, Xe = !1, q = () => {
|
|
454
|
+
Xe || typeof window > "u" || (Xe = !0, window.addEventListener("online", () => {
|
|
455
|
+
I();
|
|
456
|
+
}), import("./account.js").then((e) => e.onChange(() => {
|
|
457
|
+
K().catch(() => {}), I();
|
|
458
|
+
})).catch(() => {}));
|
|
459
|
+
}, Ze = /* @__PURE__ */ e({
|
|
460
|
+
STORAGE_ACCOUNT_CHANGED: () => r,
|
|
461
|
+
STORAGE_ACCOUNT_PIN_UNSUPPORTED: () => i,
|
|
462
|
+
StorageAccountChangedError: () => ie,
|
|
463
|
+
StorageAccountPinUnsupportedError: () => ne,
|
|
464
|
+
adopt: () => X,
|
|
465
|
+
adoptable: () => Z,
|
|
466
|
+
appendFile: () => mt,
|
|
467
|
+
appendFileSync: () => nt,
|
|
468
|
+
available: () => $e,
|
|
469
|
+
default: () => Ot,
|
|
470
|
+
exists: () => xt,
|
|
471
|
+
existsSync: () => rt,
|
|
472
|
+
flush: () => wt,
|
|
473
|
+
isAccountChanged: () => c,
|
|
474
|
+
lstatSync: () => at,
|
|
475
|
+
mkdir: () => _t,
|
|
476
|
+
mkdirSync: () => st,
|
|
477
|
+
mount: () => Ct,
|
|
478
|
+
onConflict: () => Dt,
|
|
479
|
+
pending: () => Q,
|
|
480
|
+
pendingDeletes: () => $,
|
|
481
|
+
promises: () => St,
|
|
482
|
+
pull: () => J,
|
|
483
|
+
readFile: () => ft,
|
|
484
|
+
readFileSealed: () => Y,
|
|
485
|
+
readFileSync: () => et,
|
|
486
|
+
readdir: () => gt,
|
|
487
|
+
readdirSync: () => ot,
|
|
488
|
+
remount: () => Tt,
|
|
489
|
+
rename: () => bt,
|
|
490
|
+
renameSync: () => dt,
|
|
491
|
+
replicating: () => Et,
|
|
492
|
+
rm: () => vt,
|
|
493
|
+
rmSync: () => ct,
|
|
494
|
+
rmdirSync: () => lt,
|
|
495
|
+
stat: () => ht,
|
|
496
|
+
statSync: () => it,
|
|
497
|
+
unlink: () => yt,
|
|
498
|
+
unlinkSync: () => ut,
|
|
499
|
+
writeFile: () => pt,
|
|
500
|
+
writeFileSync: () => tt
|
|
501
|
+
}), Qe = n(se, { memfs: !0 }), { available: $e, readFileSync: et, writeFileSync: tt, appendFileSync: nt, existsSync: rt, statSync: it, lstatSync: at, readdirSync: ot, mkdirSync: st, rmSync: ct, rmdirSync: lt, unlinkSync: ut, renameSync: dt, readFile: ft, writeFile: pt, appendFile: mt, stat: ht, readdir: gt, mkdir: _t, rm: vt, unlink: yt, rename: bt, exists: xt, promises: St, mount: Ct, flush: wt, remount: Tt } = Qe, J = Fe, Y = Me, X = V, Z = U, Q = Se, $ = Ce, Et = we, Dt = Ie, Ot = {
|
|
502
|
+
...Qe,
|
|
503
|
+
pull: J,
|
|
504
|
+
readFileSealed: Y,
|
|
505
|
+
adopt: X,
|
|
506
|
+
adoptable: Z,
|
|
507
|
+
pending: Q,
|
|
508
|
+
pendingDeletes: $,
|
|
509
|
+
replicating: Et,
|
|
510
|
+
onConflict: Dt
|
|
511
|
+
};
|
|
512
|
+
//#endregion
|
|
513
|
+
export { ct as A, gt as C, dt as D, bt as E, ut as F, pt as I, tt as L, ht as M, it as N, Et as O, yt as P, et as S, Tt as T, $ as _, $e as a, ft as b, wt as c, at as d, _t as f, Q as g, Dt as h, nt as i, lt as j, vt as k, Ot as l, Ct as m, Z as n, xt as o, st as p, mt as r, rt as s, X as t, Ze as u, St as v, ot as w, Y as x, J as y };
|
package/fs.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./fs-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./messages.cjs"),t=require("./storage-BS5WMO4f.cjs"),n=require("./fs-BTyRnUPI.cjs");exports.STORAGE_ACCOUNT_CHANGED=e.STORAGE_ACCOUNT_CHANGED,exports.STORAGE_ACCOUNT_PIN_UNSUPPORTED=e.STORAGE_ACCOUNT_PIN_UNSUPPORTED,exports.StorageAccountChangedError=t.t,exports.StorageAccountPinUnsupportedError=t.n,exports.adopt=n.t,exports.adoptable=n.n,exports.appendFile=n.r,exports.appendFileSync=n.i,exports.available=n.a,exports.default=n.l,exports.exists=n.o,exports.existsSync=n.s,exports.flush=n.c,exports.isAccountChanged=t.c,exports.lstatSync=n.d,exports.mkdir=n.f,exports.mkdirSync=n.p,exports.mount=n.m,exports.onConflict=n.h,exports.pending=n.g,exports.pendingDeletes=n._,exports.promises=n.v,exports.pull=n.y,exports.readFile=n.b,exports.readFileSealed=n.x,exports.readFileSync=n.S,exports.readdir=n.C,exports.readdirSync=n.w,exports.remount=n.T,exports.rename=n.E,exports.renameSync=n.D,exports.replicating=n.O,exports.rm=n.k,exports.rmSync=n.A,exports.rmdirSync=n.j,exports.stat=n.M,exports.statSync=n.N,exports.unlink=n.P,exports.unlinkSync=n.F,exports.writeFile=n.I,exports.writeFileSync=n.L;
|
package/fs.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { i as Stats } from "./index-BQgZVQl7.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
2
|
+
import { a as StorageAccountChangedError, i as SealedRead, o as StorageAccountPinUnsupportedError, p as isAccountChanged } from "./storage-BVr2Rb-d.js";
|
|
3
|
+
import { c as STORAGE_ACCOUNT_CHANGED, l as STORAGE_ACCOUNT_PIN_UNSUPPORTED } from "./messages-CRcziTuC.js";
|
|
4
|
+
import { A as rmSync, B as ConflictResolver, C as readdir, D as renameSync, E as rename, F as unlinkSync, H as FileConflict, I as writeFile, L as writeFileSync, M as stat, N as statSync, O as replicating, P as unlink, R as AdoptSummary, S as readFileSync, T as remount, V as ConflictSide, _ 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 rmdirSync, k as rm, 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 readdirSync, x as readFileSealed, y as pull, z as ConflictResolution } from "./index-D2lvaQDs.js";
|
|
5
|
+
export { type AdoptSummary, type ConflictResolution, type ConflictResolver, type ConflictSide, type FileConflict, STORAGE_ACCOUNT_CHANGED, STORAGE_ACCOUNT_PIN_UNSUPPORTED, type SealedRead, type Stats, StorageAccountChangedError, StorageAccountPinUnsupportedError, adopt, adoptable, appendFile, appendFileSync, available, _default as default, exists, existsSync, flush, isAccountChanged, lstatSync, mkdir, mkdirSync, mount, onConflict, pending, pendingDeletes, promises, pull, readFile, readFileSealed, readFileSync, readdir, readdirSync, remount, rename, renameSync, replicating, rm, rmSync, rmdirSync, stat, statSync, unlink, unlinkSync, writeFile, writeFileSync };
|
package/fs.js
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { STORAGE_ACCOUNT_CHANGED as e, STORAGE_ACCOUNT_PIN_UNSUPPORTED as t } from "./messages.js";
|
|
2
|
+
import { c as n, n as r, t as i } from "./storage-BWmGrO6a.js";
|
|
3
|
+
import { A as a, C as o, D as s, E as c, F as l, I as u, L as d, M as f, N as p, O as m, P as h, S as g, T as _, _ as v, a as y, b, c as x, d as S, f as C, g as w, h as T, i as E, j as D, k as O, l as k, m as A, n as j, o as M, p as N, r as P, s as F, t as I, v as L, w as R, x as z, y as B } from "./fs-q7Kg51hq.js";
|
|
4
|
+
export { e as STORAGE_ACCOUNT_CHANGED, t as STORAGE_ACCOUNT_PIN_UNSUPPORTED, i as StorageAccountChangedError, r as StorageAccountPinUnsupportedError, I as adopt, j as adoptable, P as appendFile, E as appendFileSync, y as available, k as default, M as exists, F as existsSync, x as flush, n as isAccountChanged, S as lstatSync, C as mkdir, N as mkdirSync, A as mount, T as onConflict, w as pending, v as pendingDeletes, L as promises, B as pull, b as readFile, z as readFileSealed, g as readFileSync, o as readdir, R as readdirSync, _ as remount, c as rename, s as renameSync, m as replicating, O as rm, a as rmSync, D as rmdirSync, f as stat, p as statSync, h as unlink, l as unlinkSync, u as writeFile, d as writeFileSync };
|
package/http.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as Socket, t as Server$1 } from "./net-
|
|
1
|
+
import { n as Socket, t as Server$1 } from "./net-CcEZP6Bb.js";
|
|
2
2
|
import { Buffer } from "buffer";
|
|
3
3
|
import { Stream } from "stream";
|
|
4
4
|
import { IncomingHttpHeaders, OutgoingHttpHeaders, RequestOptions } from "http";
|