@fkn/lib 0.9.26 → 0.9.27

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.
@@ -1,5 +1,5 @@
1
1
  import { o as TcpSocketOption, v as UdpSocketOption } from "./wire-Gbo-D74t.js";
2
- import { A as ProxyFetchInit, C as PackageQuery, D as PickOptions, K as WriteData, O as Placement, P as Resolvers, S as OverlayState, T as PackagesErrorCode, U as UdpDatagram, V as TcpSocketOptions, W as UdpSocketOptions, _ as InstallOptions, a as ConflictChoice, c as ConnectAvailability, i as AdoptState, j as ProxyFetchInput, l as ConnectOptions, m as FrameConsentRequest, o as ConflictRequest, r as AdoptRequest, y as IpFamily, z as TcpSocketListenerOptions } from "./contract-D6ksmIm6.js";
2
+ import { A as ProxyFetchInit, C as PackageQuery, D as PickOptions, K as WriteData, O as Placement, P as Resolvers, S as OverlayState, T as PackagesErrorCode, U as UdpDatagram, V as TcpSocketOptions, W as UdpSocketOptions, _ as InstallOptions, a as ConflictChoice, c as ConnectAvailability, i as AdoptState, j as ProxyFetchInput, l as ConnectOptions, m as FrameConsentRequest, o as ConflictRequest, r as AdoptRequest, y as IpFamily, z as TcpSocketListenerOptions } from "./contract-BergoFCw.js";
3
3
  import { Remote } from "osra";
4
4
  //#region src/api-epochs.d.ts
5
5
  type EpochListener<T> = (remote: T, epoch: number) => void;
@@ -84,6 +84,10 @@ declare const onApiEpoch: (listener: EpochListener<{
84
84
  maxObjects: number;
85
85
  }>;
86
86
  readFile: (path: string) => Promise<Uint8Array<ArrayBufferLike>>;
87
+ readFileSealed: (path: string) => Promise<{
88
+ bytes: Uint8Array;
89
+ sealedAt: number | null;
90
+ }>;
87
91
  writeFile: (path: string, data: WriteData, contentType: string | null) => Promise<void>;
88
92
  remove: (path: string) => Promise<void>;
89
93
  encryption: () => Promise<{
@@ -397,6 +401,10 @@ declare const currentApiEpoch: () => {
397
401
  maxObjects: number;
398
402
  }>;
399
403
  readFile: (path: string) => Promise<Uint8Array<ArrayBufferLike>>;
404
+ readFileSealed: (path: string) => Promise<{
405
+ bytes: Uint8Array;
406
+ sealedAt: number | null;
407
+ }>;
400
408
  writeFile: (path: string, data: WriteData, contentType: string | null) => Promise<void>;
401
409
  remove: (path: string) => Promise<void>;
402
410
  encryption: () => Promise<{
package/api.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { P as Resolvers } from "./contract-D6ksmIm6.js";
2
- import { a as apiPromise, c as hasTransport, i as apiLastCall, l as onApiEpoch, n as BrokerUnreachableError, o as apiWithin, r as apiInFlight, s as currentApiEpoch, t as API_DEADLINE_MS } from "./api-CesI0aMl.js";
1
+ import { P as Resolvers } from "./contract-BergoFCw.js";
2
+ import { a as apiPromise, c as hasTransport, i as apiLastCall, l as onApiEpoch, n as BrokerUnreachableError, o as apiWithin, r as apiInFlight, s as currentApiEpoch, t as API_DEADLINE_MS } from "./api-Dv7Fy_CF.js";
3
3
  export { API_DEADLINE_MS, BrokerUnreachableError, type Resolvers, apiInFlight, apiLastCall, apiPromise, apiWithin, currentApiEpoch, hasTransport, onApiEpoch };
package/cloud/dns.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { n as AddressLookupResult } from "../contract-D6ksmIm6.js";
1
+ import { n as AddressLookupResult } from "../contract-BergoFCw.js";
2
2
  import { lookup } from "../dns.js";
3
3
  export { type AddressLookupResult, lookup };
package/cloud/fetch.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { t as cloudFetch } from "../proxy-BubvP9sg.js";
1
+ import { t as cloudFetch } from "../proxy-DkuZfeI4.js";
2
2
  export { cloudFetch as fetch };
@@ -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 "../../fs-DlGE0ZNu.js";
2
+ import "../../fs-CBVaShOR.js";
3
3
  //#region src/cloud/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>, 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/cloud/fs.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../rolldown-runtime-BIInC43l.cjs"),t=require("../node-fs-DZPGCYWg.cjs"),n=require("../messages.cjs"),r=require("../storage-DLB4ciMf.cjs");var i=e.t({STORAGE_NOT_FOUND:()=>n.STORAGE_NOT_FOUND,StorageLockedError:()=>r.t,StorageNotFoundError:()=>r.n,available:()=>a,encryption:()=>r.i,isNotFound:()=>r.a,mkdir:()=>d,promises:()=>m,quota:()=>r.s,readFile:()=>o,readdir:()=>u,rename:()=>l,rm:()=>f,stat:()=>p,unlink:()=>c,unlock:()=>r.d,writeFile:()=>s}),{available:a,readFile:o,writeFile:s,unlink:c,rename:l,readdir:u,mkdir:d,rm:f,stat:p,promises:m}=t.t(r.u,{memfs:!1});exports.STORAGE_NOT_FOUND=n.STORAGE_NOT_FOUND,exports.StorageLockedError=r.t,exports.StorageNotFoundError=r.n,exports.available=a,exports.encryption=r.i,exports.isNotFound=r.a,exports.mkdir=d,exports.promises=m,exports.quota=r.s,exports.readFile=o,exports.readdir=u,exports.rename=l,exports.rm=f,exports.stat=p,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return i}}),exports.unlink=c,exports.unlock=r.d,exports.writeFile=s;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../rolldown-runtime-BIInC43l.cjs"),t=require("../node-fs-DZPGCYWg.cjs"),n=require("../messages.cjs"),r=require("../storage-Dr5F1jil.cjs");var i=e.t({STORAGE_NOT_FOUND:()=>n.STORAGE_NOT_FOUND,StorageLockedError:()=>r.t,StorageNotFoundError:()=>r.n,available:()=>a,encryption:()=>r.i,isNotFound:()=>r.a,mkdir:()=>d,promises:()=>m,quota:()=>r.s,readFile:()=>o,readFileSealed:()=>r.l,readdir:()=>u,rename:()=>l,rm:()=>f,stat:()=>p,unlink:()=>c,unlock:()=>r.f,writeFile:()=>s}),{available:a,readFile:o,writeFile:s,unlink:c,rename:l,readdir:u,mkdir:d,rm:f,stat:p,promises:m}=t.t(r.d,{memfs:!1});exports.STORAGE_NOT_FOUND=n.STORAGE_NOT_FOUND,exports.StorageLockedError=r.t,exports.StorageNotFoundError=r.n,exports.available=a,exports.encryption=r.i,exports.isNotFound=r.a,exports.mkdir=d,exports.promises=m,exports.quota=r.s,exports.readFile=o,exports.readFileSealed=r.l,exports.readdir=u,exports.rename=l,exports.rm=f,exports.stat=p,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return i}}),exports.unlink=c,exports.unlock=r.f,exports.writeFile=s;
package/cloud/fs.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { i as Stats } from "../index-BQgZVQl7.js";
2
- import { _ as encryption, a as readFile, b as unlock, c as rm, d as writeFile, f as EncryptionStatus, g as StorageQuota, h as StorageNotFoundError, i as promises, l as stat, m as StorageLockedError, o as readdir, p as FileEntry, r as mkdir, s as rename, t as available, u as unlink, v as isNotFound, y as quota } from "../fs-DlGE0ZNu.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
3
  import { i as STORAGE_NOT_FOUND } from "../messages-DvpKMTsY.js";
4
- export { type EncryptionStatus, type FileEntry, STORAGE_NOT_FOUND, type Stats, StorageLockedError, StorageNotFoundError, type StorageQuota, available, encryption, isNotFound, mkdir, promises, quota, readFile, readdir, rename, rm, stat, unlink, unlock, writeFile };
4
+ import { a as readFile, c as rm, d as writeFile, i as promises, l as stat, o as readdir, r as mkdir, s as rename, t as available, u as unlink } from "../fs-CBVaShOR.js";
5
+ export { type EncryptionStatus, type FileEntry, STORAGE_NOT_FOUND, type SealedRead, type Stats, StorageLockedError, StorageNotFoundError, type StorageQuota, available, encryption, isNotFound, mkdir, promises, quota, readFile, readFileSealed, readdir, rename, rm, stat, unlink, unlock, writeFile };
package/cloud/fs.js CHANGED
@@ -1,26 +1,27 @@
1
1
  import { t as e } from "../rolldown-runtime-Dy4uBu1J.js";
2
2
  import { t } from "../node-fs-C9ECR_9H.js";
3
3
  import { STORAGE_NOT_FOUND as n } from "../messages.js";
4
- import { a as r, d as i, i as a, n as o, s, t as c, u as l } from "../storage-BjGr_vC4.js";
4
+ import { a as r, d as i, f as a, i as o, l as s, n as c, s as l, t as u } from "../storage-BL8vxHlW.js";
5
5
  //#region src/cloud/fs.ts
6
- var u = /* @__PURE__ */ e({
6
+ var d = /* @__PURE__ */ e({
7
7
  STORAGE_NOT_FOUND: () => n,
8
- StorageLockedError: () => c,
9
- StorageNotFoundError: () => o,
10
- available: () => d,
11
- encryption: () => a,
8
+ StorageLockedError: () => u,
9
+ StorageNotFoundError: () => c,
10
+ available: () => f,
11
+ encryption: () => o,
12
12
  isNotFound: () => r,
13
- mkdir: () => _,
14
- promises: () => b,
15
- quota: () => s,
16
- readFile: () => f,
17
- readdir: () => g,
18
- rename: () => h,
19
- rm: () => v,
20
- stat: () => y,
21
- unlink: () => m,
22
- unlock: () => i,
23
- writeFile: () => p
24
- }), { available: d, readFile: f, writeFile: p, unlink: m, rename: h, readdir: g, mkdir: _, rm: v, stat: y, promises: b } = t(l, { memfs: !1 });
13
+ mkdir: () => v,
14
+ promises: () => x,
15
+ quota: () => l,
16
+ readFile: () => p,
17
+ readFileSealed: () => s,
18
+ readdir: () => _,
19
+ rename: () => g,
20
+ rm: () => y,
21
+ stat: () => b,
22
+ unlink: () => h,
23
+ unlock: () => a,
24
+ writeFile: () => m
25
+ }), { available: f, readFile: p, writeFile: m, unlink: h, rename: g, readdir: _, mkdir: v, rm: y, stat: b, promises: x } = t(i, { memfs: !1 });
25
26
  //#endregion
26
- export { n as STORAGE_NOT_FOUND, c as StorageLockedError, o as StorageNotFoundError, d as available, a as encryption, r as isNotFound, _ as mkdir, b as promises, s as quota, f as readFile, g as readdir, h as rename, v as rm, y as stat, u as t, m as unlink, i as unlock, p as writeFile };
27
+ export { n as STORAGE_NOT_FOUND, u as StorageLockedError, c as StorageNotFoundError, f as available, o as encryption, r as isNotFound, v as mkdir, x as promises, l as quota, p as readFile, s as readFileSealed, _ as readdir, g as rename, y as rm, b as stat, d as t, h as unlink, a as unlock, m as writeFile };
package/cloud/net.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as createConnection, c as isIP, i as connect, l as isIPv4, n as Socket, o as createServer, r as _default, t as Server, u as isIPv6 } from "../net-DAOcF3Eb.js";
1
+ import { a as createConnection, c as isIP, i as connect, l as isIPv4, n as Socket, o as createServer, r as _default, t as Server, u as isIPv6 } from "../net-C9Me0zVw.js";
2
2
  export { Server, Socket, _default, _default as default, connect, createConnection, createServer, isIP, isIPv4, isIPv6 };
@@ -1,8 +1,8 @@
1
- import { t as cloudFetch } from "./proxy-BubvP9sg.js";
1
+ import { t as cloudFetch } from "./proxy-DkuZfeI4.js";
2
2
  import { i as Frame, r as AttachFrameOptions } from "./index-BhO-wymH.js";
3
3
  import { t as dns_d_exports } from "./dns.js";
4
- import { n as fs_d_exports } from "./fs-DlGE0ZNu.js";
5
- import { s as net_d_exports } from "./net-DAOcF3Eb.js";
4
+ import { n as fs_d_exports } from "./fs-CBVaShOR.js";
5
+ import { s as net_d_exports } from "./net-C9Me0zVw.js";
6
6
  import { t as dgram_d_exports } from "./dgram.js";
7
7
  import { t as http_d_exports } from "./http.js";
8
8
  //#region src/cloud/frame.d.ts
package/cloud.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { t as cloudFetch } from "./proxy-BubvP9sg.js";
2
- import { a as attachFrame, i as quota, r as QuotaStatus, t as available } from "./cloud-B7pI3pp1.js";
1
+ import { t as cloudFetch } from "./proxy-DkuZfeI4.js";
2
+ import { a as attachFrame, i as quota, r as QuotaStatus, t as available } from "./cloud-ZRqclRzO.js";
3
3
  import { t as dns_d_exports } from "./dns.js";
4
- import { n as fs_d_exports } from "./fs-DlGE0ZNu.js";
5
- import { s as net_d_exports } from "./net-DAOcF3Eb.js";
4
+ import { n as fs_d_exports } from "./fs-CBVaShOR.js";
5
+ import { s as net_d_exports } from "./net-C9Me0zVw.js";
6
6
  import { t as dgram_d_exports } from "./dgram.js";
7
7
  import { t as http_d_exports } from "./http.js";
8
8
  export { type QuotaStatus, attachFrame, available, dgram_d_exports as dgram, dns_d_exports as dns, cloudFetch as fetch, fs_d_exports as fs, http_d_exports as http, net_d_exports as net, quota };
@@ -306,6 +306,18 @@ type Resolvers = {
306
306
  list: () => Promise<StorageEntry[]>;
307
307
  quota: () => Promise<StorageQuota>;
308
308
  readFile: (path: string) => Promise<Uint8Array>;
309
+ /**
310
+ * The same read as `readFile`, plus the seal time the envelope authenticates, in milliseconds,
311
+ * or null for an envelope that carries no such field.
312
+ *
313
+ * Authenticated means the server can neither forge nor alter it, because it is covered by the
314
+ * envelope's AAD; it is still the WRITER's own claim about when it sealed, so on its own it
315
+ * does not prove that this copy is the newest one.
316
+ */
317
+ readFileSealed: (path: string) => Promise<{
318
+ bytes: Uint8Array;
319
+ sealedAt: number | null;
320
+ }>;
309
321
  writeFile: (path: string, data: WriteData, contentType: string | null) => Promise<void>;
310
322
  remove: (path: string) => Promise<void>;
311
323
  encryption: () => Promise<EncryptionState>;
package/contract.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import { o as TcpSocketOption, v as UdpSocketOption } from "./wire-Gbo-D74t.js";
2
- import { A as ProxyFetchInit, B as TcpSocketListenerResult, C as PackageQuery, D as PickOptions, E as PackagesFail, F as SetOverlayHost, G as UdpSocketResult, H as TcpSocketResult, I as StorageEntry, K as WriteData, L as StorageQuota, M as Quota, N as Radii, O as Placement, P as Resolvers, R as SurfaceRect, S as OverlayState, T as PackagesErrorCode, U as UdpDatagram, V as TcpSocketOptions, W as UdpSocketOptions, _ as InstallOptions, a as ConflictChoice, b as MountDescriptor, c as ConnectAvailability, d as DisplayLevel, f as DnsLookup, g as HiddenSurface, h as FrameFetchScope, i as AdoptState, j as ProxyFetchInput, k as ProxyFetch, l as ConnectOptions, m as FrameConsentRequest, n as AddressLookupResult, o as ConflictRequest, p as EncryptionState, r as AdoptRequest, s as ConflictSide, t as Account, u as DisplayCause, v as InstalledPackage, w as PackageResult, x as OverlayRect, y as IpFamily, z as TcpSocketListenerOptions } from "./contract-D6ksmIm6.js";
2
+ import { A as ProxyFetchInit, B as TcpSocketListenerResult, C as PackageQuery, D as PickOptions, E as PackagesFail, F as SetOverlayHost, G as UdpSocketResult, H as TcpSocketResult, I as StorageEntry, K as WriteData, L as StorageQuota, M as Quota, N as Radii, O as Placement, P as Resolvers, R as SurfaceRect, S as OverlayState, T as PackagesErrorCode, U as UdpDatagram, V as TcpSocketOptions, W as UdpSocketOptions, _ as InstallOptions, a as ConflictChoice, b as MountDescriptor, c as ConnectAvailability, d as DisplayLevel, f as DnsLookup, g as HiddenSurface, h as FrameFetchScope, i as AdoptState, j as ProxyFetchInput, k as ProxyFetch, l as ConnectOptions, m as FrameConsentRequest, n as AddressLookupResult, o as ConflictRequest, p as EncryptionState, r as AdoptRequest, s as ConflictSide, t as Account, u as DisplayCause, v as InstalledPackage, w as PackageResult, x as OverlayRect, y as IpFamily, z as TcpSocketListenerOptions } from "./contract-BergoFCw.js";
3
3
  export { Account, AddressLookupResult, AdoptRequest, AdoptState, ConflictChoice, ConflictRequest, ConflictSide, ConnectAvailability, ConnectOptions, DisplayCause, DisplayLevel, DnsLookup, EncryptionState, FrameConsentRequest, FrameFetchScope, HiddenSurface, InstallOptions, InstalledPackage, IpFamily, MountDescriptor, OverlayRect, OverlayState, PackageQuery, PackageResult, PackagesErrorCode, PackagesFail, PickOptions, Placement, ProxyFetch, ProxyFetchInit, ProxyFetchInput, Quota, Radii, Resolvers, SetOverlayHost, StorageEntry, StorageQuota, SurfaceRect, TcpSocketListenerOptions, TcpSocketListenerResult, type TcpSocketOption, TcpSocketOptions, TcpSocketResult, UdpDatagram, type UdpSocketOption, UdpSocketOptions, UdpSocketResult, WriteData };
package/dgram.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { v as UdpSocketOption } from "./wire-Gbo-D74t.js";
2
- import { G as UdpSocketResult, P as Resolvers } from "./contract-D6ksmIm6.js";
3
- import "./api-CesI0aMl.js";
2
+ import { G as UdpSocketResult, P as Resolvers } from "./contract-BergoFCw.js";
3
+ import "./api-Dv7Fy_CF.js";
4
4
  import { Buffer } from "buffer";
5
5
  import { AddressInfo } from "net";
6
6
  import { EventEmitter } from "events";
package/dns.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as AddressLookupResult } from "./contract-D6ksmIm6.js";
1
+ import { n as AddressLookupResult } from "./contract-BergoFCw.js";
2
2
  declare namespace dns_d_exports {
3
3
  export { AddressLookupResult, lookup };
4
4
  }
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}});