@fkn/lib 0.9.26 → 0.9.28

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 (47) hide show
  1. package/{api-CesI0aMl.d.ts → api-CKoF03Me.d.ts} +327 -1
  2. package/api.d.ts +2 -2
  3. package/cloud/dns.d.ts +1 -1
  4. package/cloud/fetch.d.ts +1 -1
  5. package/cloud/fs/promises.d.ts +1 -1
  6. package/cloud/fs.cjs +1 -1
  7. package/cloud/fs.d.ts +3 -2
  8. package/cloud/fs.js +20 -19
  9. package/cloud/net.d.ts +1 -1
  10. package/{cloud-B7pI3pp1.d.ts → cloud-BX_24NAz.d.ts} +4 -4
  11. package/cloud.d.ts +4 -4
  12. package/{contract-D6ksmIm6.d.ts → contract-BzdjfQge.d.ts} +118 -1
  13. package/contract.d.ts +2 -2
  14. package/dgram.d.ts +2 -2
  15. package/dns.d.ts +1 -1
  16. package/{extension-CJUeVRXf.d.ts → extension-DwQOshkM.d.ts} +1 -1
  17. package/extension.d.ts +2 -2
  18. package/fs/promises.cjs +1 -1
  19. package/fs/promises.d.ts +1 -1
  20. package/fs/promises.js +1 -1
  21. package/fs-CBVaShOR.d.ts +27 -0
  22. package/fs-Cvx2NT6o.js +360 -0
  23. package/fs-J5h3i5eg.cjs +1 -0
  24. package/fs.cjs +1 -1
  25. package/fs.d.ts +3 -2
  26. package/fs.js +2 -2
  27. package/http.d.ts +1 -1
  28. package/{index-CGJTVju4.d.ts → index-Cg6y_FTi.d.ts} +22 -6
  29. package/{index-BhO-wymH.d.ts → index-DH3_12nU.d.ts} +36 -36
  30. package/index.cjs +1 -1
  31. package/index.d.ts +7 -6
  32. package/index.js +48 -47
  33. package/{net-DAOcF3Eb.d.ts → net-Cy6QOTK3.d.ts} +2 -2
  34. package/net.d.ts +1 -1
  35. package/package.json +6 -1
  36. package/packages.d.ts +1 -1
  37. package/{proxy-BubvP9sg.d.ts → proxy-DahCiavd.d.ts} +2 -2
  38. package/rooms.cjs +1 -0
  39. package/rooms.d.ts +46 -0
  40. package/rooms.js +142 -0
  41. package/{storage-BjGr_vC4.js → storage-BL8vxHlW.js} +23 -7
  42. package/storage-Dr5F1jil.cjs +1 -0
  43. package/storage-WZEvw3KN.d.ts +69 -0
  44. package/fs-DYP7utdw.cjs +0 -1
  45. package/fs-DlGE0ZNu.d.ts +0 -73
  46. package/fs-d2ANVBkm.js +0 -347
  47. package/storage-DLB4ciMf.cjs +0 -1
@@ -1,4 +1,4 @@
1
- import { C as OperationRequest, S as GateTools, _ as isType, a as FrameBackend, b as Executor, c as attachFramePermission, d as handleRevivableModules, f as BoxedVideoElement, g as createVideoElementHandle, h as box, i as Frame, l as createFrame, m as VideoElementState, n as attachFrame, o as GotoOptions, p as RemoteVideoElement, r as AttachFrameOptions, s as Locator, t as ATTACH_FRAME_EVENT_KEY, u as gotoPermission, v as revive, w as SelectorPart, x as Gate, y as type } from "./index-BhO-wymH.js";
1
+ import { C as OperationRequest, S as GateTools, _ as isType, a as FrameBackend, b as Executor, c as attachFramePermission, d as handleRevivableModules, f as BoxedVideoElement, g as createVideoElementHandle, h as box, i as Frame, l as createFrame, m as VideoElementState, n as attachFrame, o as GotoOptions, p as RemoteVideoElement, r as AttachFrameOptions, s as Locator, t as ATTACH_FRAME_EVENT_KEY, u as gotoPermission, v as revive, w as SelectorPart, x as Gate, y as type } from "./index-DH3_12nU.js";
2
2
  //#region ../web-extension/lib/lib/forgeable-headers.d.ts
3
3
  declare const FORGEABLE_HEADERS: string[];
4
4
  declare const hasForgedCookie: (unsafeHeaders: [string, string][] | undefined) => boolean;
package/extension.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { A as modifyRequestHeadersPermission, B as fetch, C as LOCATOR_ERROR, D as isTerminalError, E as isLocatorUnsupported, F as cookies, G as isLocalNetworkUrl, H as fetchLocalPermission, I as readCookiePermission, J as assertOneCookieIdentity, K as FORGEABLE_HEADERS, L as FetchInit, M as setRequestHeaderRule, N as CookieDetails, O as HeaderOperation, P as SiteCookie, R as ProxyFetchRequest, S as LOCATOR_DENIED, T as isLocatorDenied, U as fetchPermission, V as fetchCredentialedPermission, W as isBlockedFetchUrl, Y as hasForgedCookie, _ as PermissionRequest, a as extension, b as assertLockdownApplicable, c as setMissingExtensionHandler, d as ExtensionHandshake, f as ExtensionOperationUnsupportedError, g as PermissionGrant, h as supportsOperation, i as promptInstall, j as removeRequestHeaderRule, k as RequestHeaderRule, l as waitForExtensionExposure, m as REQUIRED_EXTENSION_ABI, o as isExtensionExposed, p as ExtensionOutdatedError, q as assertForgeableHeaders, r as isExtensionAvailable, s as readExtensionHandshake, u as EXTENSION_ABI, v as permissions, w as LOCATOR_UNSUPPORTED, x as isBlockedFrameUrl, y as assertAttachableFrameUrl, z as assertFetchableUrl } from "./extension-CJUeVRXf.js";
2
- import { C as OperationRequest, S as GateTools, _ as isType, a as FrameBackend, b as Executor, c as attachFramePermission, d as handleRevivableModules, f as BoxedVideoElement, g as createVideoElementHandle, h as box, i as Frame, l as createFrame, m as VideoElementState, n as attachFrame, o as GotoOptions, p as RemoteVideoElement, r as AttachFrameOptions, s as Locator, t as ATTACH_FRAME_EVENT_KEY, u as gotoPermission, v as revive, w as SelectorPart, x as Gate, y as type } from "./index-BhO-wymH.js";
1
+ import { A as modifyRequestHeadersPermission, B as fetch, C as LOCATOR_ERROR, D as isTerminalError, E as isLocatorUnsupported, F as cookies, G as isLocalNetworkUrl, H as fetchLocalPermission, I as readCookiePermission, J as assertOneCookieIdentity, K as FORGEABLE_HEADERS, L as FetchInit, M as setRequestHeaderRule, N as CookieDetails, O as HeaderOperation, P as SiteCookie, R as ProxyFetchRequest, S as LOCATOR_DENIED, T as isLocatorDenied, U as fetchPermission, V as fetchCredentialedPermission, W as isBlockedFetchUrl, Y as hasForgedCookie, _ as PermissionRequest, a as extension, b as assertLockdownApplicable, c as setMissingExtensionHandler, d as ExtensionHandshake, f as ExtensionOperationUnsupportedError, g as PermissionGrant, h as supportsOperation, i as promptInstall, j as removeRequestHeaderRule, k as RequestHeaderRule, l as waitForExtensionExposure, m as REQUIRED_EXTENSION_ABI, o as isExtensionExposed, p as ExtensionOutdatedError, q as assertForgeableHeaders, r as isExtensionAvailable, s as readExtensionHandshake, u as EXTENSION_ABI, v as permissions, w as LOCATOR_UNSUPPORTED, x as isBlockedFrameUrl, y as assertAttachableFrameUrl, z as assertFetchableUrl } from "./extension-DwQOshkM.js";
2
+ import { C as OperationRequest, S as GateTools, _ as isType, a as FrameBackend, b as Executor, c as attachFramePermission, d as handleRevivableModules, f as BoxedVideoElement, g as createVideoElementHandle, h as box, i as Frame, l as createFrame, m as VideoElementState, n as attachFrame, o as GotoOptions, p as RemoteVideoElement, r as AttachFrameOptions, s as Locator, t as ATTACH_FRAME_EVENT_KEY, u as gotoPermission, v as revive, w as SelectorPart, x as Gate, y as type } from "./index-DH3_12nU.js";
3
3
  export { ATTACH_FRAME_EVENT_KEY, AttachFrameOptions, BoxedVideoElement, CookieDetails, EXTENSION_ABI, type Executor, type ExtensionHandshake, ExtensionOperationUnsupportedError, ExtensionOutdatedError, FORGEABLE_HEADERS, FetchInit, Frame, FrameBackend, type Gate, type GateTools, GotoOptions, HeaderOperation, LOCATOR_DENIED, LOCATOR_ERROR, LOCATOR_UNSUPPORTED, Locator, type OperationRequest, PermissionGrant, PermissionRequest, ProxyFetchRequest, REQUIRED_EXTENSION_ABI, RemoteVideoElement, RequestHeaderRule, type SelectorPart, SiteCookie, VideoElementState, assertAttachableFrameUrl, assertFetchableUrl, assertForgeableHeaders, assertLockdownApplicable, assertOneCookieIdentity, attachFrame, attachFramePermission, isExtensionAvailable as available, box, cookies, createFrame, createVideoElementHandle, extension as events, extension, fetch, fetchCredentialedPermission, fetchLocalPermission, fetchPermission, gotoPermission, handleRevivableModules, hasForgedCookie, isBlockedFetchUrl, isBlockedFrameUrl, isExtensionExposed, isLocalNetworkUrl, isLocatorDenied, isLocatorUnsupported, isTerminalError, isType, modifyRequestHeadersPermission, permissions, promptInstall, readCookiePermission, readExtensionHandshake, removeRequestHeaderRule, revive, setMissingExtensionHandler, setRequestHeaderRule, supportsOperation, type, waitForExtensionExposure };
package/fs/promises.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../fs-DYP7utdw.cjs");var{readFile:t,writeFile:n,appendFile:r,unlink:i,rename:a,readdir:o,mkdir:s,rm:c,rmdir:l,stat:u,lstat:d,access:f}=e.v,p=e.v;exports.access=f,exports.appendFile=r,exports.default=p,exports.lstat=d,exports.mkdir=s,exports.readFile=t,exports.readdir=o,exports.rename=a,exports.rm=c,exports.rmdir=l,exports.stat=u,exports.unlink=i,exports.writeFile=n;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../fs-J5h3i5eg.cjs");var{readFile:t,writeFile:n,appendFile:r,unlink:i,rename:a,readdir:o,mkdir:s,rm:c,rmdir:l,stat:u,lstat:d,access:f}=e.v,p=e.v;exports.access=f,exports.appendFile=r,exports.default=p,exports.lstat=d,exports.mkdir=s,exports.readFile=t,exports.readdir=o,exports.rename=a,exports.rm=c,exports.rmdir=l,exports.stat=u,exports.unlink=i,exports.writeFile=n;
package/fs/promises.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { a as WriteData, i as Stats, n as MakeOptions, o as WriteOptions, r as ReadOptions } from "../index-BQgZVQl7.js";
2
- import { v as promises } from "../index-CGJTVju4.js";
2
+ import { v as promises } from "../index-Cg6y_FTi.js";
3
3
  //#region src/fs/promises.d.ts
4
4
  declare const readFile: (path: import("node:fs").PathLike, options?: ReadOptions) => Promise<Buffer | string>, writeFile: (path: import("node:fs").PathLike, data: WriteData, options?: WriteOptions) => Promise<void>, appendFile: (path: import("node:fs").PathLike, data: WriteData, options?: WriteOptions) => Promise<void>, unlink: (path: import("node:fs").PathLike) => Promise<void>, rename: (from: import("node:fs").PathLike, to: import("node:fs").PathLike) => Promise<void>, readdir: (path: import("node:fs").PathLike) => Promise<string[]>, mkdir: (path: import("node:fs").PathLike, options?: MakeOptions) => Promise<void>, rm: (path: import("node:fs").PathLike, options?: {
5
5
  recursive?: boolean;
package/fs/promises.js CHANGED
@@ -1,4 +1,4 @@
1
- import { v as e } from "../fs-d2ANVBkm.js";
1
+ import { v as e } from "../fs-Cvx2NT6o.js";
2
2
  //#region src/fs/promises.ts
3
3
  var { readFile: t, writeFile: n, appendFile: r, unlink: i, rename: a, readdir: o, mkdir: s, rm: c, rmdir: l, stat: u, lstat: d, access: f } = e, p = e;
4
4
  //#endregion
@@ -0,0 +1,27 @@
1
+ import { a as WriteData, i as Stats, n as MakeOptions, o as WriteOptions, r as ReadOptions, t as Callback } from "./index-BQgZVQl7.js";
2
+ import { a as StorageNotFoundError, c as isNotFound, d as unlock, i as StorageLockedError, l as quota, n as FileEntry, o as StorageQuota, r as SealedRead, s as encryption, t as EncryptionStatus, u as readFileSealed } from "./storage-WZEvw3KN.js";
3
+ import { i as STORAGE_NOT_FOUND } from "./messages-DvpKMTsY.js";
4
+ declare namespace fs_d_exports {
5
+ export { EncryptionStatus, FileEntry, STORAGE_NOT_FOUND, SealedRead, Stats, StorageLockedError, StorageNotFoundError, StorageQuota, available, encryption, isNotFound, mkdir, promises, quota, readFile, readFileSealed, readdir, rename, rm, stat, unlink, unlock, writeFile };
6
+ }
7
+ declare const available: () => Promise<boolean>, readFile: (path: import("node:fs").PathLike, a: ReadOptions | Callback<Buffer | string>, b?: Callback<Buffer | string>) => void, writeFile: (path: import("node:fs").PathLike, data: WriteData, a: WriteOptions | Callback<void>, b?: Callback<void>) => void, unlink: (path: import("node:fs").PathLike, callback: Callback<void>) => void, rename: (from: import("node:fs").PathLike, to: import("node:fs").PathLike, callback: Callback<void>) => void, readdir: (path: import("node:fs").PathLike, a: unknown, b?: Callback<string[]>) => void, mkdir: (path: import("node:fs").PathLike, a: MakeOptions | Callback<void>, b?: Callback<void>) => void, rm: (path: import("node:fs").PathLike, a: {
8
+ recursive?: boolean;
9
+ } | Callback<void>, b?: Callback<void>) => void, stat: (path: import("node:fs").PathLike, callback: Callback<Stats>) => void, promises: {
10
+ readFile: (path: import("node:fs").PathLike, options?: ReadOptions) => Promise<Buffer | string>;
11
+ writeFile: (path: import("node:fs").PathLike, data: WriteData, options?: WriteOptions) => Promise<void>;
12
+ unlink: (path: import("node:fs").PathLike) => Promise<void>;
13
+ rename: (from: import("node:fs").PathLike, to: import("node:fs").PathLike) => Promise<void>;
14
+ readdir: (path: import("node:fs").PathLike) => Promise<string[]>;
15
+ mkdir: (_path?: import("node:fs").PathLike, _options?: MakeOptions) => Promise<void>;
16
+ rm: (path: import("node:fs").PathLike, options?: {
17
+ recursive?: boolean;
18
+ }) => Promise<void>;
19
+ rmdir: (path: import("node:fs").PathLike, options?: {
20
+ recursive?: boolean;
21
+ }) => Promise<void>;
22
+ stat: (path: import("node:fs").PathLike) => Promise<Stats>;
23
+ lstat: (path: import("node:fs").PathLike) => Promise<Stats>;
24
+ access: (path: import("node:fs").PathLike) => Promise<void>;
25
+ };
26
+ //#endregion
27
+ export { readFile as a, rm as c, writeFile as d, promises as i, stat as l, fs_d_exports as n, readdir as o, mkdir as r, rename as s, available as t, unlink as u };
package/fs-Cvx2NT6o.js ADDED
@@ -0,0 +1,360 @@
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-C9ECR_9H.js";
4
+ import { c as r, l as i, o as a, p as o, r as s, u as c } from "./storage-BL8vxHlW.js";
5
+ import { a as l, i as u, n as d, o as f, t as p } from "./opfs-D0goLAQW.js";
6
+ //#region src/fs/hybrid.ts
7
+ var m = /* @__PURE__ */ e({
8
+ adopt: () => V,
9
+ adoptable: () => H,
10
+ available: () => te,
11
+ list: () => ce,
12
+ onConflict: () => z,
13
+ pending: () => re,
14
+ pendingDeletes: () => ie,
15
+ pull: () => pe,
16
+ readFile: () => le,
17
+ readFileSealed: () => ue,
18
+ remove: () => fe,
19
+ replicating: () => ae,
20
+ writeFile: () => de
21
+ }), ee, h = async () => await (ee ??= p().catch(() => !1)) ? !0 : (ee = void 0, !1), g = () => s().catch(() => "unknown"), _ = async () => await g() === "connected", te = async () => await h() || await _(), v = "fkn:fs:pending", y = "fkn:fs:pending-delete", b = "fkn:fs:adopt-declined", x = !0, S = /* @__PURE__ */ new Map(), C = (e) => {
22
+ try {
23
+ let t = localStorage.getItem(e);
24
+ if (!t) return {};
25
+ let n = JSON.parse(t);
26
+ return Array.isArray(n) ? Object.fromEntries(n.filter((e) => typeof e == "string").map((e) => [e, null])) : n && typeof n == "object" ? n : {};
27
+ } catch {
28
+ return {};
29
+ }
30
+ }, w = (e, t) => {
31
+ try {
32
+ Object.keys(t).length ? localStorage.setItem(e, JSON.stringify(t)) : localStorage.removeItem(e);
33
+ } catch {}
34
+ }, T = () => C(v), E = (e, t) => {
35
+ let n = T();
36
+ e in n || (n[e] = t === void 0 ? S.get(e) ?? null : t, w(v, n));
37
+ }, D = (e) => {
38
+ let t = T();
39
+ e in t && (delete t[e], w(v, t), j() || (N = M));
40
+ }, O = () => C(y), ne = (e) => {
41
+ let t = O();
42
+ e in t || (t[e] = S.get(e) ?? null, w(y, t));
43
+ }, k = (e) => {
44
+ let t = O();
45
+ e in t && (delete t[e], w(y, t), j() || (N = M));
46
+ }, re = () => Object.keys(T()), ie = () => Object.keys(O()), ae = () => x, A = null;
47
+ t("storage replication", () => A !== null || U !== null);
48
+ var j = () => Object.keys(T()).length > 0 || Object.keys(O()).length > 0, M = 6e4, oe = 6e5, N = M, P = null, F = () => {
49
+ P || typeof window > "u" || !j() || (P = setTimeout(() => {
50
+ P = null, I();
51
+ }, N), N = Math.min(N * 2, oe));
52
+ }, I = () => {
53
+ A || !j() || (A = B(!1).then((e) => {
54
+ if (!j()) {
55
+ N = M;
56
+ return;
57
+ }
58
+ e.failed.length && F();
59
+ }).catch(() => {
60
+ F();
61
+ }).finally(() => {
62
+ A = null;
63
+ }));
64
+ }, se = null, L = () => se ??= import("./api.js").then((e) => e.apiPromise), ce = async () => {
65
+ W();
66
+ let e = await g(), t = e === "connected", [n, r] = await Promise.all([h().then((e) => e ? d() : []).catch(() => []), t ? a().then((e) => ({
67
+ ok: !0,
68
+ entries: e
69
+ })).catch(() => ({
70
+ ok: !1,
71
+ entries: []
72
+ })) : Promise.resolve({
73
+ ok: e === "disconnected",
74
+ entries: []
75
+ })]);
76
+ e !== "unknown" && (x = r.ok), r.ok && e !== "unknown" && (S = new Map(r.entries.map((e) => [e.path, e.updatedAt])));
77
+ let i = /* @__PURE__ */ new Map(), o = (e) => {
78
+ let t = Date.parse(e.updatedAt ?? "");
79
+ return Number.isFinite(t) ? t : 0;
80
+ }, s = (e) => {
81
+ let t = i.get(e.path);
82
+ (!t || o(e) >= o(t)) && i.set(e.path, e);
83
+ };
84
+ for (let e of n) s(e);
85
+ for (let e of r.entries) s(e);
86
+ return r.ok && t && (xe(n, r.entries).catch(() => {}), j() ? I() : ve({
87
+ local: n,
88
+ remote: r.entries
89
+ }).catch(() => {})), [...i.values()];
90
+ }, le = async (e) => {
91
+ if (await h()) try {
92
+ return await u(e);
93
+ } catch (e) {
94
+ if (e?.name !== "NotFoundError") throw e;
95
+ }
96
+ let t = await r(e);
97
+ return await h() && f(e, t).catch(() => {}), t;
98
+ }, ue = async (e) => {
99
+ if (await h()) try {
100
+ let t = await u(e);
101
+ return {
102
+ data: new Uint8Array(await t.arrayBuffer()),
103
+ sealedAt: null
104
+ };
105
+ } catch (e) {
106
+ if (e?.name !== "NotFoundError") throw e;
107
+ }
108
+ return i(e);
109
+ }, de = async (e, t, n) => {
110
+ let r = t instanceof Blob ? t : new Blob([t], n?.contentType ? { type: n.contentType } : void 0);
111
+ if (await h()) {
112
+ await f(e, r, n), W();
113
+ let t = S.get(e) ?? null, i = await g();
114
+ if (i === "disconnected") return;
115
+ if (i === "unknown" || !x) {
116
+ E(e, t), F();
117
+ return;
118
+ }
119
+ o(e, r, n).then(() => D(e)).catch((n) => {
120
+ E(e, t), F(), console.warn("fs: cloud replicate failed, queued for adopt()", n);
121
+ });
122
+ return;
123
+ }
124
+ let i = await g();
125
+ if (i === "connected") return o(e, r, n);
126
+ throw Error(i === "unknown" ? "fs: cloud unreachable" : "fs: no storage backend available");
127
+ }, fe = async (e) => {
128
+ W();
129
+ let t = [];
130
+ await h() && t.push(l(e).catch(() => {}));
131
+ let n = await g();
132
+ if (n === "connected" ? t.push(c(e).then(() => k(e)).catch((t) => {
133
+ ne(e), F(), console.warn("fs: cloud delete failed, queued for retry", t);
134
+ })) : n === "unknown" && t.length && S.has(e) && (ne(e), F()), !t.length) throw Error(n === "unknown" ? "fs: cloud unreachable" : "fs: no storage backend available");
135
+ D(e), await Promise.all(t);
136
+ }, pe = async (e) => {
137
+ let t = await r(e);
138
+ return await h() && await f(e, t), t;
139
+ }, R = null, z = (e) => (R = e, () => {
140
+ R === e && (R = null);
141
+ }), me = async (e) => {
142
+ let t = await (await L()).cloud.fs.promptConflict({
143
+ path: e.path,
144
+ local: e.local,
145
+ cloud: e.cloud
146
+ }).catch(() => null);
147
+ return t === "local" ? e.readLocal() : t === "cloud" ? e.readCloud() : null;
148
+ }, he = async (e) => {
149
+ if (R) try {
150
+ return await R(e);
151
+ } catch {
152
+ return null;
153
+ }
154
+ return me(e);
155
+ }, B = async (e) => {
156
+ let t = {
157
+ uploaded: [],
158
+ kept: [],
159
+ resolved: [],
160
+ unresolved: [],
161
+ deleted: [],
162
+ failed: []
163
+ }, n = await g();
164
+ if (n === "unknown") throw Error("fs: cloud unreachable");
165
+ if (n !== "connected") throw Error("fs: this needs a signed-in account");
166
+ let i = await h(), [s, l] = await Promise.all([i ? d() : Promise.resolve([]), a()]), p = new Map(l.map((e) => [e.path, e])), m = T();
167
+ if (i) for (let e of Object.keys(m)) s.some((t) => t.path === e) || D(e);
168
+ for (let [e, n] of Object.entries(O())) {
169
+ let r = p.get(e);
170
+ if (!r) {
171
+ k(e);
172
+ continue;
173
+ }
174
+ if (s.some((t) => t.path === e)) {
175
+ k(e);
176
+ continue;
177
+ }
178
+ if (r.updatedAt !== n) {
179
+ k(e);
180
+ continue;
181
+ }
182
+ try {
183
+ await c(e), k(e), t.deleted.push(e);
184
+ } catch (n) {
185
+ t.failed.push({
186
+ path: e,
187
+ error: n instanceof Error ? n.message : String(n)
188
+ });
189
+ }
190
+ }
191
+ for (let n of s) {
192
+ let i = p.get(n.path), a = n.path in m;
193
+ if (!a && (i || !e)) {
194
+ i && t.kept.push(n.path);
195
+ continue;
196
+ }
197
+ if (a && i && i.updatedAt !== m[n.path]) {
198
+ let e = null, a = null, s = await he({
199
+ path: n.path,
200
+ local: {
201
+ size: n.size,
202
+ updatedAt: n.updatedAt
203
+ },
204
+ cloud: {
205
+ size: i.size,
206
+ updatedAt: i.updatedAt
207
+ },
208
+ readLocal: () => e ??= u(n.path),
209
+ readCloud: () => a ??= r(n.path)
210
+ });
211
+ if (s == null) {
212
+ t.unresolved.push(n.path);
213
+ continue;
214
+ }
215
+ try {
216
+ let r = e !== null && s === await e, i = a !== null && s === await a;
217
+ i || await o(n.path, s, n.contentType ? { contentType: n.contentType } : void 0), r || await f(n.path, s), D(n.path), t.resolved.push({
218
+ path: n.path,
219
+ choice: r ? "local" : i ? "cloud" : "merged"
220
+ });
221
+ } catch (e) {
222
+ if (e?.code === "FKN_E2E_LOCKED") throw e;
223
+ t.failed.push({
224
+ path: n.path,
225
+ error: e instanceof Error ? e.message : String(e)
226
+ });
227
+ }
228
+ continue;
229
+ }
230
+ try {
231
+ let e = await u(n.path);
232
+ await o(n.path, e, n.contentType ? { contentType: n.contentType } : void 0), D(n.path), t.uploaded.push(n.path);
233
+ } catch (e) {
234
+ if (E(n.path), e?.code === "FKN_E2E_LOCKED") throw e;
235
+ t.failed.push({
236
+ path: n.path,
237
+ error: e instanceof Error ? e.message : String(e)
238
+ });
239
+ }
240
+ }
241
+ return t;
242
+ }, V = async () => {
243
+ for (; A;) await A;
244
+ let e = B(!0);
245
+ A = e.then(() => {}, () => {});
246
+ try {
247
+ return await e;
248
+ } finally {
249
+ A = null;
250
+ }
251
+ }, H = async () => {
252
+ if (!await _() || !await h()) return {
253
+ paths: [],
254
+ bytes: 0
255
+ };
256
+ let [e, t] = await Promise.all([d(), a()]), n = new Set(t.map((e) => e.path)), r = e.filter((e) => !n.has(e.path));
257
+ return {
258
+ paths: r.map((e) => e.path),
259
+ bytes: r.reduce((e, t) => e + t.size, 0)
260
+ };
261
+ }, ge = () => new Set(Object.keys(C(b))), _e = (e) => {
262
+ let t = C(b);
263
+ for (let n of e) t[n] = null;
264
+ w(b, t);
265
+ }, U = null, ve = (e) => U || (U = (async () => {
266
+ if (!await _()) return;
267
+ let t = e ?? (await h() ? {
268
+ local: await d(),
269
+ remote: await a()
270
+ } : null);
271
+ if (!t) return;
272
+ let n = new Set(t.remote.map((e) => e.path)), r = ge(), i = t.local.filter((e) => !n.has(e.path) && !r.has(e.path));
273
+ if (!i.length) return;
274
+ let o = await L(), s = i.reduce((e, t) => e + t.size, 0);
275
+ if (!await o.cloud.fs.promptAdopt({
276
+ files: i.length,
277
+ bytes: s
278
+ }).catch(() => !1)) {
279
+ _e(i.map((e) => e.path));
280
+ return;
281
+ }
282
+ await V();
283
+ })().catch(() => {}).finally(() => {
284
+ U = null;
285
+ }), U), ye = null, be = !1, xe = async (e, t) => {
286
+ let n = new Set(t.map((e) => e.path)), r = e.filter((e) => !n.has(e.path)), i = await L(), a = async () => {
287
+ await V().catch(() => {});
288
+ let e = await H().catch(() => ({
289
+ paths: [],
290
+ bytes: 0
291
+ }));
292
+ await i.cloud.fs.setAdoptSource({
293
+ files: e.paths.length,
294
+ bytes: e.bytes
295
+ }, a).catch(() => {});
296
+ }, o = {
297
+ files: r.length,
298
+ bytes: r.reduce((e, t) => e + t.size, 0)
299
+ };
300
+ ye = () => {
301
+ i.cloud.fs.setAdoptSource(o, a).catch(() => {});
302
+ }, be || (be = !0, import("./api.js").then((e) => e.onApiEpoch((e, t) => {
303
+ t > 1 && ye?.();
304
+ })).catch(() => {})), await i.cloud.fs.setAdoptSource(o, a);
305
+ }, Se = !1, W = () => {
306
+ Se || typeof window > "u" || (Se = !0, window.addEventListener("online", () => {
307
+ I();
308
+ }), import("./account.js").then((e) => e.onChange(() => {
309
+ ve().catch(() => {}), I();
310
+ })).catch(() => {}));
311
+ }, Ce = /* @__PURE__ */ e({
312
+ adopt: () => J,
313
+ adoptable: () => Y,
314
+ appendFile: () => Be,
315
+ appendFileSync: () => Oe,
316
+ available: () => Te,
317
+ default: () => Ze,
318
+ exists: () => qe,
319
+ existsSync: () => ke,
320
+ flush: () => G,
321
+ lstatSync: () => je,
322
+ mkdir: () => Ue,
323
+ mkdirSync: () => Ne,
324
+ mount: () => Ye,
325
+ onConflict: () => $,
326
+ pending: () => X,
327
+ pendingDeletes: () => Z,
328
+ promises: () => Je,
329
+ pull: () => K,
330
+ readFile: () => Re,
331
+ readFileSealed: () => q,
332
+ readFileSync: () => Ee,
333
+ readdir: () => He,
334
+ readdirSync: () => Me,
335
+ remount: () => Xe,
336
+ rename: () => Ke,
337
+ renameSync: () => Le,
338
+ replicating: () => Q,
339
+ rm: () => We,
340
+ rmSync: () => Pe,
341
+ rmdirSync: () => Fe,
342
+ stat: () => Ve,
343
+ statSync: () => Ae,
344
+ unlink: () => Ge,
345
+ unlinkSync: () => Ie,
346
+ writeFile: () => ze,
347
+ writeFileSync: () => De
348
+ }), we = n(m, { memfs: !0 }), { available: Te, readFileSync: Ee, writeFileSync: De, appendFileSync: Oe, existsSync: ke, statSync: Ae, lstatSync: je, readdirSync: Me, mkdirSync: Ne, rmSync: Pe, rmdirSync: Fe, unlinkSync: Ie, renameSync: Le, readFile: Re, writeFile: ze, appendFile: Be, stat: Ve, readdir: He, mkdir: Ue, rm: We, unlink: Ge, rename: Ke, exists: qe, promises: Je, mount: Ye, flush: G, remount: Xe } = we, K = pe, q = ue, J = V, Y = H, X = re, Z = ie, Q = ae, $ = z, Ze = {
349
+ ...we,
350
+ pull: K,
351
+ readFileSealed: q,
352
+ adopt: J,
353
+ adoptable: Y,
354
+ pending: X,
355
+ pendingDeletes: Z,
356
+ replicating: Q,
357
+ onConflict: $
358
+ };
359
+ //#endregion
360
+ export { Pe as A, He as C, Le as D, Ke as E, Ie as F, ze as I, De as L, Ve as M, Ae as N, Q as O, Ge as P, Ee as S, Xe as T, Z as _, Te as a, Re as b, G as c, je as d, Ue as f, X as g, $ as h, Oe as i, Fe as j, We as k, Ze as l, Ye as m, Y as n, qe as o, Ne as p, Be as r, ke as s, J as t, Ce as u, Je as v, Me as w, q as x, K as y };
@@ -0,0 +1 @@
1
+ const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./busy-Dv8wzE5M.cjs"),n=require("./node-fs-DZPGCYWg.cjs"),r=require("./storage-Dr5F1jil.cjs"),i=require("./opfs-CXMESVLc.cjs");var a=e.t({adopt:()=>I,adoptable:()=>L,available:()=>u,list:()=>re,onConflict:()=>le,pending:()=>C,pendingDeletes:()=>w,pull:()=>ce,readFile:()=>ie,readFileSealed:()=>ae,remove:()=>se,replicating:()=>T,writeFile:()=>oe}),o,s=async()=>await(o??=i.t().catch(()=>!1))?!0:(o=void 0,!1),c=()=>r.r().catch(()=>`unknown`),l=async()=>await c()===`connected`,u=async()=>await s()||await l(),d=`fkn:fs:pending`,f=`fkn:fs:pending-delete`,p=`fkn:fs:adopt-declined`,m=!0,h=new Map,g=e=>{try{let t=localStorage.getItem(e);if(!t)return{};let n=JSON.parse(t);return Array.isArray(n)?Object.fromEntries(n.filter(e=>typeof e==`string`).map(e=>[e,null])):n&&typeof n==`object`?n:{}}catch{return{}}},_=(e,t)=>{try{Object.keys(t).length?localStorage.setItem(e,JSON.stringify(t)):localStorage.removeItem(e)}catch{}},v=()=>g(d),y=(e,t)=>{let n=v();e in n||(n[e]=t===void 0?h.get(e)??null:t,_(d,n))},b=e=>{let t=v();e in t&&(delete t[e],_(d,t),D()||(k=O))},x=()=>g(f),ee=e=>{let t=x();e in t||(t[e]=h.get(e)??null,_(f,t))},S=e=>{let t=x();e in t&&(delete t[e],_(f,t),D()||(k=O))},C=()=>Object.keys(v()),w=()=>Object.keys(x()),T=()=>m,E=null;t.r(`storage replication`,()=>E!==null||R!==null);var D=()=>Object.keys(v()).length>0||Object.keys(x()).length>0,O=6e4,te=6e5,k=O,A=null,j=()=>{A||typeof window>`u`||!D()||(A=setTimeout(()=>{A=null,M()},k),k=Math.min(k*2,te))},M=()=>{E||!D()||(E=F(!1).then(e=>{if(!D()){k=O;return}e.failed.length&&j()}).catch(()=>{j()}).finally(()=>{E=null}))},ne=null,N=()=>ne??=Promise.resolve().then(()=>require("./api.cjs")).then(e=>e.apiPromise),re=async()=>{U();let e=await c(),t=e===`connected`,[n,a]=await Promise.all([s().then(e=>e?i.n():[]).catch(()=>[]),t?r.o().then(e=>({ok:!0,entries:e})).catch(()=>({ok:!1,entries:[]})):Promise.resolve({ok:e===`disconnected`,entries:[]})]);e!==`unknown`&&(m=a.ok),a.ok&&e!==`unknown`&&(h=new Map(a.entries.map(e=>[e.path,e.updatedAt])));let o=new Map,l=e=>{let t=Date.parse(e.updatedAt??``);return Number.isFinite(t)?t:0},u=e=>{let t=o.get(e.path);(!t||l(e)>=l(t))&&o.set(e.path,e)};for(let e of n)u(e);for(let e of a.entries)u(e);return a.ok&&t&&(me(n,a.entries).catch(()=>{}),D()?M():z({local:n,remote:a.entries}).catch(()=>{})),[...o.values()]},ie=async e=>{if(await s())try{return await i.i(e)}catch(e){if(e?.name!==`NotFoundError`)throw e}let t=await r.c(e);return await s()&&i.o(e,t).catch(()=>{}),t},ae=async e=>{if(await s())try{let t=await i.i(e);return{data:new Uint8Array(await t.arrayBuffer()),sealedAt:null}}catch(e){if(e?.name!==`NotFoundError`)throw e}return r.l(e)},oe=async(e,t,n)=>{let a=t instanceof Blob?t:new Blob([t],n?.contentType?{type:n.contentType}:void 0);if(await s()){await i.o(e,a,n),U();let t=h.get(e)??null,o=await c();if(o===`disconnected`)return;if(o===`unknown`||!m){y(e,t),j();return}r.p(e,a,n).then(()=>b(e)).catch(n=>{y(e,t),j(),console.warn(`fs: cloud replicate failed, queued for adopt()`,n)});return}let o=await c();if(o===`connected`)return r.p(e,a,n);throw Error(o===`unknown`?`fs: cloud unreachable`:`fs: no storage backend available`)},se=async e=>{U();let t=[];await s()&&t.push(i.a(e).catch(()=>{}));let n=await c();if(n===`connected`?t.push(r.u(e).then(()=>S(e)).catch(t=>{ee(e),j(),console.warn(`fs: cloud delete failed, queued for retry`,t)})):n===`unknown`&&t.length&&h.has(e)&&(ee(e),j()),!t.length)throw Error(n===`unknown`?`fs: cloud unreachable`:`fs: no storage backend available`);b(e),await Promise.all(t)},ce=async e=>{let t=await r.c(e);return await s()&&await i.o(e,t),t},P=null,le=e=>(P=e,()=>{P===e&&(P=null)}),ue=async e=>{let t=await(await N()).cloud.fs.promptConflict({path:e.path,local:e.local,cloud:e.cloud}).catch(()=>null);return t===`local`?e.readLocal():t===`cloud`?e.readCloud():null},de=async e=>{if(P)try{return await P(e)}catch{return null}return ue(e)},F=async e=>{let t={uploaded:[],kept:[],resolved:[],unresolved:[],deleted:[],failed:[]},n=await c();if(n===`unknown`)throw Error(`fs: cloud unreachable`);if(n!==`connected`)throw Error(`fs: this needs a signed-in account`);let a=await s(),[o,l]=await Promise.all([a?i.n():Promise.resolve([]),r.o()]),u=new Map(l.map(e=>[e.path,e])),d=v();if(a)for(let e of Object.keys(d))o.some(t=>t.path===e)||b(e);for(let[e,n]of Object.entries(x())){let i=u.get(e);if(!i){S(e);continue}if(o.some(t=>t.path===e)){S(e);continue}if(i.updatedAt!==n){S(e);continue}try{await r.u(e),S(e),t.deleted.push(e)}catch(n){t.failed.push({path:e,error:n instanceof Error?n.message:String(n)})}}for(let n of o){let a=u.get(n.path),o=n.path in d;if(!o&&(a||!e)){a&&t.kept.push(n.path);continue}if(o&&a&&a.updatedAt!==d[n.path]){let e=null,o=null,s=await de({path:n.path,local:{size:n.size,updatedAt:n.updatedAt},cloud:{size:a.size,updatedAt:a.updatedAt},readLocal:()=>e??=i.i(n.path),readCloud:()=>o??=r.c(n.path)});if(s==null){t.unresolved.push(n.path);continue}try{let a=e!==null&&s===await e,c=o!==null&&s===await o;c||await r.p(n.path,s,n.contentType?{contentType:n.contentType}:void 0),a||await i.o(n.path,s),b(n.path),t.resolved.push({path:n.path,choice:a?`local`:c?`cloud`:`merged`})}catch(e){if(e?.code===`FKN_E2E_LOCKED`)throw e;t.failed.push({path:n.path,error:e instanceof Error?e.message:String(e)})}continue}try{let e=await i.i(n.path);await r.p(n.path,e,n.contentType?{contentType:n.contentType}:void 0),b(n.path),t.uploaded.push(n.path)}catch(e){if(y(n.path),e?.code===`FKN_E2E_LOCKED`)throw e;t.failed.push({path:n.path,error:e instanceof Error?e.message:String(e)})}}return t},I=async()=>{for(;E;)await E;let e=F(!0);E=e.then(()=>{},()=>{});try{return await e}finally{E=null}},L=async()=>{if(!await l()||!await s())return{paths:[],bytes:0};let[e,t]=await Promise.all([i.n(),r.o()]),n=new Set(t.map(e=>e.path)),a=e.filter(e=>!n.has(e.path));return{paths:a.map(e=>e.path),bytes:a.reduce((e,t)=>e+t.size,0)}},fe=()=>new Set(Object.keys(g(p))),pe=e=>{let t=g(p);for(let n of e)t[n]=null;_(p,t)},R=null,z=e=>R||(R=(async()=>{if(!await l())return;let t=e??(await s()?{local:await i.n(),remote:await r.o()}:null);if(!t)return;let n=new Set(t.remote.map(e=>e.path)),a=fe(),o=t.local.filter(e=>!n.has(e.path)&&!a.has(e.path));if(!o.length)return;let c=await N(),u=o.reduce((e,t)=>e+t.size,0);if(!await c.cloud.fs.promptAdopt({files:o.length,bytes:u}).catch(()=>!1)){pe(o.map(e=>e.path));return}await I()})().catch(()=>{}).finally(()=>{R=null}),R),B=null,V=!1,me=async(e,t)=>{let n=new Set(t.map(e=>e.path)),r=e.filter(e=>!n.has(e.path)),i=await N(),a=async()=>{await I().catch(()=>{});let e=await L().catch(()=>({paths:[],bytes:0}));await i.cloud.fs.setAdoptSource({files:e.paths.length,bytes:e.bytes},a).catch(()=>{})},o={files:r.length,bytes:r.reduce((e,t)=>e+t.size,0)};B=()=>{i.cloud.fs.setAdoptSource(o,a).catch(()=>{})},V||(V=!0,Promise.resolve().then(()=>require("./api.cjs")).then(e=>e.onApiEpoch((e,t)=>{t>1&&B?.()})).catch(()=>{})),await i.cloud.fs.setAdoptSource(o,a)},H=!1,U=()=>{H||typeof window>`u`||(H=!0,window.addEventListener(`online`,()=>{M()}),Promise.resolve().then(()=>require("./account.cjs")).then(e=>e.onChange(()=>{z().catch(()=>{}),M()})).catch(()=>{}))},he=e.t({adopt:()=>q,adoptable:()=>J,appendFile:()=>je,appendFileSync:()=>be,available:()=>_e,default:()=>$,exists:()=>Re,existsSync:()=>xe,flush:()=>Ve,lstatSync:()=>Ce,mkdir:()=>Pe,mkdirSync:()=>we,mount:()=>Be,onConflict:()=>Q,pending:()=>Y,pendingDeletes:()=>X,promises:()=>ze,pull:()=>G,readFile:()=>ke,readFileSealed:()=>K,readFileSync:()=>ve,readdir:()=>Ne,readdirSync:()=>W,remount:()=>He,rename:()=>Le,renameSync:()=>Oe,replicating:()=>Z,rm:()=>Fe,rmSync:()=>Te,rmdirSync:()=>Ee,stat:()=>Me,statSync:()=>Se,unlink:()=>Ie,unlinkSync:()=>De,writeFile:()=>Ae,writeFileSync:()=>ye}),ge=n.t(a,{memfs:!0}),{available:_e,readFileSync:ve,writeFileSync:ye,appendFileSync:be,existsSync:xe,statSync:Se,lstatSync:Ce,readdirSync:W,mkdirSync:we,rmSync:Te,rmdirSync:Ee,unlinkSync:De,renameSync:Oe,readFile:ke,writeFile:Ae,appendFile:je,stat:Me,readdir:Ne,mkdir:Pe,rm:Fe,unlink:Ie,rename:Le,exists:Re,promises:ze,mount:Be,flush:Ve,remount:He}=ge,G=ce,K=ae,q=I,J=L,Y=C,X=w,Z=T,Q=le,$={...ge,pull:G,readFileSealed:K,adopt:q,adoptable:J,pending:Y,pendingDeletes:X,replicating:Z,onConflict:Q};Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return De}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(exports,"L",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return He}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return X}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return Ve}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return Pe}}),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 be}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return we}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return je}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return he}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return G}});
package/fs.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./fs-DYP7utdw.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;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./fs-J5h3i5eg.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.readFileSealed=e.x,exports.readFileSync=e.S,exports.readdir=e.C,exports.readdirSync=e.w,exports.remount=e.T,exports.rename=e.E,exports.renameSync=e.D,exports.replicating=e.O,exports.rm=e.k,exports.rmSync=e.A,exports.rmdirSync=e.j,exports.stat=e.M,exports.statSync=e.N,exports.unlink=e.P,exports.unlinkSync=e.F,exports.writeFile=e.I,exports.writeFileSync=e.L;
package/fs.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  import { i as Stats } from "./index-BQgZVQl7.js";
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-CGJTVju4.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 };
2
+ 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-Cg6y_FTi.js";
3
+ import { r as SealedRead } from "./storage-WZEvw3KN.js";
4
+ export { type AdoptSummary, type ConflictResolution, type ConflictResolver, type ConflictSide, type FileConflict, type SealedRead, type Stats, adopt, adoptable, appendFile, appendFileSync, available, _default as default, exists, existsSync, flush, 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,2 @@
1
- import { A as e, C as t, D as n, E as r, F as i, I as a, M as o, N as s, O as c, P as l, S as u, T as d, _ as f, a as p, b as m, c as h, d as g, f as _, g as v, h as y, i as b, j as x, k as S, l as C, m as w, n as T, o as E, p as D, r as O, s as k, t as A, v as j, w as M, x as N, y as P } from "./fs-d2ANVBkm.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 };
1
+ import { A as e, C as t, D as n, E as r, F as i, I as a, L as o, M as s, N as c, O as l, P as u, S as d, T as f, _ as p, a as m, b as h, c as g, d as _, f as v, g as y, h as b, i as x, j as S, k as C, l as w, m as T, n as E, o as D, p as O, r as k, s as A, t as j, v as M, w as N, x as P, y as F } from "./fs-Cvx2NT6o.js";
2
+ export { j as adopt, E as adoptable, k as appendFile, x as appendFileSync, m as available, w as default, D as exists, A as existsSync, g as flush, _ as lstatSync, v as mkdir, O as mkdirSync, T as mount, b as onConflict, y as pending, p as pendingDeletes, M as promises, F as pull, h as readFile, P as readFileSealed, d as readFileSync, t as readdir, N as readdirSync, f as remount, r as rename, n as renameSync, l as replicating, C as rm, e as rmSync, S as rmdirSync, s as stat, c as statSync, u as unlink, i as unlinkSync, a as writeFile, o as writeFileSync };
package/http.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as Socket, t as Server$1 } from "./net-DAOcF3Eb.js";
1
+ import { n as Socket, t as Server$1 } from "./net-Cy6QOTK3.js";
2
2
  import { Buffer } from "buffer";
3
3
  import { Stream } from "stream";
4
4
  import { IncomingHttpHeaders, OutgoingHttpHeaders, RequestOptions } from "http";
@@ -1,4 +1,5 @@
1
1
  import { a as WriteData$1, i as Stats, n as MakeOptions, o as WriteOptions, r as ReadOptions, t as Callback } from "./index-BQgZVQl7.js";
2
+ import { r as SealedRead } from "./storage-WZEvw3KN.js";
2
3
  //#region src/fs/types.d.ts
3
4
  type WriteData = Blob | ArrayBuffer | Uint8Array | string;
4
5
  //#endregion
@@ -6,6 +7,7 @@ type WriteData = Blob | ArrayBuffer | Uint8Array | string;
6
7
  declare const pending$1: () => string[];
7
8
  declare const pendingDeletes$1: () => string[];
8
9
  declare const replicating$1: () => boolean;
10
+ declare const readFileSealed$1: (path: string) => Promise<SealedRead>;
9
11
  declare const pull$1: (path: string) => Promise<Blob>;
10
12
  type AdoptSummary = {
11
13
  uploaded: string[];
@@ -32,10 +34,22 @@ type FileConflict = {
32
34
  readLocal: () => Promise<Blob>;
33
35
  readCloud: () => Promise<Blob>;
34
36
  };
35
- type ConflictChoice = 'local' | 'cloud' | {
36
- merged: WriteData;
37
- } | null;
38
- type ConflictResolver = (conflict: FileConflict) => Promise<ConflictChoice> | ConflictChoice;
37
+ /**
38
+ * What should be at that path. Return one side's bytes, or anything else as a merge; null leaves the
39
+ * file alone and the summary reports it unresolved.
40
+ *
41
+ * There is no vocabulary to learn: whatever comes back is what wins. Returning the very Blob that
42
+ * `readLocal()` or `readCloud()` handed you is recognised by identity, so picking a side costs one
43
+ * write rather than two.
44
+ *
45
+ * That identity is sound only because the resolver runs in THIS realm: the reads are memoized here,
46
+ * so the object the app holds is the object compared. A value that crosses osra arrives as a
47
+ * different object with equal content, in both directions, which `tests/osra-identity.browser.test.ts`
48
+ * pins against a real channel. So a resolver whose answer ever crossed a realm would simply read as a
49
+ * merge: one redundant write, never a wrong file.
50
+ */
51
+ type ConflictResolution = WriteData | null;
52
+ type ConflictResolver = (conflict: FileConflict) => Promise<ConflictResolution> | ConflictResolution;
39
53
  declare const onConflict$1: (next: ConflictResolver) => (() => void);
40
54
  declare const adopt$1: () => Promise<AdoptSummary>;
41
55
  declare const adoptable$1: () => Promise<{
@@ -43,7 +57,7 @@ declare const adoptable$1: () => Promise<{
43
57
  bytes: number;
44
58
  }>;
45
59
  declare namespace index_d_exports {
46
- 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 };
60
+ export { AdoptSummary, ConflictResolution, ConflictResolver, ConflictSide, FileConflict, SealedRead, Stats, adopt, adoptable, appendFile, appendFileSync, available, _default as default, exists, existsSync, flush, 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 };
47
61
  }
48
62
  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?: {
49
63
  recursive?: boolean;
@@ -73,6 +87,7 @@ declare const available: () => Promise<boolean>, readFileSync: (path: import("no
73
87
  access: (path: import("node:fs").PathLike) => Promise<void>;
74
88
  }, mount: () => Promise<void>, flush: () => Promise<void>, remount: () => Promise<void>;
75
89
  declare const pull: typeof pull$1;
90
+ declare const readFileSealed: typeof readFileSealed$1;
76
91
  declare const adopt: typeof adopt$1;
77
92
  declare const adoptable: typeof adoptable$1;
78
93
  declare const pending: typeof pending$1;
@@ -134,6 +149,7 @@ declare const _default: {
134
149
  flush: () => Promise<void>;
135
150
  remount: () => Promise<void>;
136
151
  pull: typeof pull$1;
152
+ readFileSealed: typeof readFileSealed$1;
137
153
  adopt: typeof adopt$1;
138
154
  adoptable: typeof adoptable$1;
139
155
  pending: typeof pending$1;
@@ -142,4 +158,4 @@ declare const _default: {
142
158
  onConflict: typeof onConflict$1;
143
159
  };
144
160
  //#endregion
145
- 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 };
161
+ export { rmSync as A, ConflictResolver as B, readdir as C, renameSync as D, rename as E, unlinkSync as F, FileConflict as H, writeFile as I, writeFileSync as L, stat as M, statSync as N, replicating as O, unlink as P, AdoptSummary as R, readFileSync as S, remount as T, ConflictSide 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, rmdirSync as j, rm 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, readdirSync as w, readFileSealed as x, pull as y, ConflictResolution as z };