@fkn/lib 0.9.40 → 0.9.42

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 (98) hide show
  1. package/account-generation-B-6Pn0b5.cjs +1 -0
  2. package/account-generation-XNWOvLea.js +28 -0
  3. package/account.cjs +1 -1
  4. package/account.d.ts +11 -0
  5. package/account.js +8 -20
  6. package/api--LOXTOpv.cjs +3 -0
  7. package/{api-Dp-2AT3u.js → api-DIgTslNb.js} +154 -114
  8. package/{api-BE5zPvFZ.d.ts → api-SwxtiYVU.d.ts} +38 -14
  9. package/api.cjs +1 -1
  10. package/api.d.ts +3 -3
  11. package/api.js +2 -2
  12. package/attach-policy.cjs +1 -1
  13. package/attach-policy.js +2 -2
  14. package/cloud/dns.d.ts +1 -1
  15. package/cloud/fetch.cjs +1 -1
  16. package/cloud/fetch.d.ts +1 -1
  17. package/cloud/fetch.js +1 -1
  18. package/cloud/fs/promises.d.ts +1 -1
  19. package/cloud/fs.cjs +1 -1
  20. package/cloud/fs.d.ts +4 -4
  21. package/cloud/fs.js +31 -24
  22. package/cloud/net.d.ts +1 -1
  23. package/cloud-868OlBKn.cjs +1 -0
  24. package/{cloud-5eldoFxK.d.ts → cloud-DUH-v10C.d.ts} +6 -4
  25. package/cloud-f3j4s8yZ.js +545 -0
  26. package/cloud.cjs +1 -1
  27. package/cloud.d.ts +4 -4
  28. package/cloud.js +2 -2
  29. package/{contract-Cvr_8gCL.d.ts → contract-CCxPKIC7.d.ts} +105 -13
  30. package/contract.d.ts +3 -2
  31. package/dgram.cjs +1 -1
  32. package/dgram.d.ts +2 -2
  33. package/dgram.js +1 -1
  34. package/dns.cjs +1 -1
  35. package/dns.d.ts +1 -1
  36. package/dns.js +1 -1
  37. package/extension-BOBuYwZc.js +92 -0
  38. package/extension-hoUs5yJ7.cjs +1 -0
  39. package/{extension-DMU-CwMw.d.ts → extension-yhwDSIiD.d.ts} +22 -3
  40. package/extension.cjs +1 -1
  41. package/extension.d.ts +3 -3
  42. package/extension.js +3 -3
  43. package/fs/promises.cjs +1 -1
  44. package/fs/promises.d.ts +1 -1
  45. package/fs/promises.js +1 -1
  46. package/fs-CVnmXRf7.js +513 -0
  47. package/{fs--NhtUyYa.d.ts → fs-D0MMRnHC.d.ts} +8 -4
  48. package/fs-p0bOOj5n.cjs +1 -0
  49. package/fs.cjs +1 -1
  50. package/fs.d.ts +4 -3
  51. package/fs.js +4 -2
  52. package/{hosts-9dYv63ud.cjs → hosts-GNBhZO3-.cjs} +1 -1
  53. package/{hosts-BzbzOhG8.js → hosts-t7CKGTRz.js} +4 -1
  54. package/http.d.ts +1 -1
  55. package/{index-D2CA-NX5.d.ts → index-BtFiGoVQ.d.ts} +465 -51
  56. package/{index-kuPqkS_-.d.ts → index-D2lvaQDs.d.ts} +28 -38
  57. package/index.cjs +1 -1
  58. package/index.d.ts +17 -17
  59. package/index.js +62 -59
  60. package/lib-CfdmsLoI.cjs +53 -0
  61. package/{lib-C4Eeg9eM.js → lib-DppqX10G.js} +470 -302
  62. package/{messages-C66ghz_A.d.ts → messages-CRcziTuC.d.ts} +17 -1
  63. package/messages.cjs +1 -1
  64. package/messages.d.ts +2 -2
  65. package/messages.js +2 -2
  66. package/{net-zThwNoA8.d.ts → net-DcLF-6E-.d.ts} +2 -2
  67. package/net.cjs +1 -1
  68. package/net.d.ts +1 -1
  69. package/net.js +1 -1
  70. package/{node-fs-BZy9bzKd.js → node-fs-CK2wWIYS.js} +140 -137
  71. package/node-fs-nfX7wisL.cjs +1 -0
  72. package/opfs.cjs +1 -1
  73. package/opfs.js +1 -1
  74. package/package.json +1 -1
  75. package/packages.cjs +1 -1
  76. package/packages.d.ts +1 -1
  77. package/packages.js +14 -14
  78. package/{proxy-Dc0gDOxz.d.ts → proxy-CE46SkyA.d.ts} +2 -2
  79. package/{proxy-DjoPtJH9.cjs → proxy-CFK-KiwE.cjs} +1 -1
  80. package/{proxy-DMTdQ4dN.js → proxy-Dixbk1WL.js} +1 -1
  81. package/rooms.cjs +1 -1
  82. package/rooms.d.ts +1 -1
  83. package/rooms.js +11 -11
  84. package/storage-BVr2Rb-d.d.ts +167 -0
  85. package/storage-D2cUJlVH.cjs +1 -0
  86. package/storage-Dn1gTLSZ.js +123 -0
  87. package/api-jOTOA-5n.cjs +0 -3
  88. package/cloud-BLv19j-W.js +0 -480
  89. package/cloud-D7aQY4GH.cjs +0 -1
  90. package/extension-B9v933cT.js +0 -89
  91. package/extension-D2zMdc2f.cjs +0 -1
  92. package/fs-CaQFRiIT.cjs +0 -1
  93. package/fs-D3IsGdnN.js +0 -360
  94. package/lib-BfAg9mHD.cjs +0 -53
  95. package/node-fs-BNTPsX5c.cjs +0 -1
  96. package/storage-BJd-mWHE.cjs +0 -1
  97. package/storage-DSvL-t80.js +0 -67
  98. package/storage-ZrY4Y4L5.d.ts +0 -88
@@ -1,5 +1,5 @@
1
1
  import { o as TcpSocketOption, v as UdpSocketOption } from "./wire-Gbo-D74t.js";
2
- import { A as OverlayState, At as WriteData, C as InstallOptions, Ct as UdpDatagram, F as PickOptions, G as RoomClaimOptions, I as Placement, N as PackagesErrorCode, Q as RoomMailbox, R as ProxyFetchInit, T as IpFamily, U as Resolvers, Y as RoomEvent, Z as RoomJoinOptions, c as ConflictChoice, d as ConnectAvailability, f as ConnectOptions, it as RoomsErrorCode, j as PackageQuery, l as ConflictRequest, nt as RoomPermission, o as AdoptRequest, s as AdoptState, tt as RoomOpenOptions, v as FrameConsentAnswer, wt as UdpSocketOptions, xt as TcpSocketOptions, y as FrameConsentRequest, yt as TcpSocketListenerOptions, z as ProxyFetchInput } from "./contract-Cvr_8gCL.js";
2
+ import { D as IpFamily, Dt as UdpSocketOptions, Et as UdpDatagram, H as ProxyFetchInput, I as PackagesErrorCode, J as RoomClaimOptions, K as Resolvers, N as OverlayState, Nt as WriteData, P as PackageQuery, Q as RoomEvent, R as PickOptions, St as TcpSocketListenerOptions, T as InstallOptions, V as ProxyFetchInit, a as AccountChange, at as RoomPermission, b as FrameConsentAnswer, c as AdoptRequest, d as ConflictRequest, et as RoomJoinOptions, it as RoomOpenOptions, l as AdoptState, m as ConnectOptions, o as AccountPinOptions, p as ConnectAvailability, st as RoomsErrorCode, tt as RoomMailbox, u as ConflictChoice, wt as TcpSocketOptions, x as FrameConsentRequest, z as Placement } from "./contract-CCxPKIC7.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;
@@ -12,6 +12,12 @@ type Api = Remote<Resolvers>;
12
12
  * stable facade that always routes to the NEWEST connection, so holding the resolved value across a
13
13
  * broker replacement is safe. A call in flight at the moment of replacement rejects with a named
14
14
  * error instead of hanging.
15
+ *
16
+ * A window realm that relays its channel to a worker (`relayWorker`) moves its own calls to a channel
17
+ * of their own, never back to the relayed one. There it also settles once the realm relays, a call in
18
+ * flight on the relayed channel then rejects as on a replacement, and a call waits for the realm's own
19
+ * channel within the deadline below, rejecting with `OwnChannelUnavailableError` when the broker never
20
+ * answers there.
15
21
  */
16
22
  declare const apiPromise: Promise<Api>;
17
23
  /**
@@ -37,6 +43,22 @@ declare const API_DEADLINE_MS = 8000;
37
43
  declare class BrokerUnreachableError extends Error {
38
44
  constructor(what: string, ms: number);
39
45
  }
46
+ /**
47
+ * A page's own call, refused because the page relays its FKN channel to a worker (`relayWorker`) and
48
+ * the broker it reached never answered on the page's own channel within the deadline: a broker
49
+ * document from before that channel, as fkn.app's service worker can still serve from its cache. The
50
+ * page's own calls never fall back to the relayed channel, so this is the answer until a reload
51
+ * reaches a newer broker. The relayed worker's calls are unaffected.
52
+ *
53
+ * What the page registered on the relayed channel went with it, and nothing registers it again until
54
+ * then: FKN's UI on this page (the prompts and header the broker draws over it, those the worker's
55
+ * calls raise included) is no longer placed, and account changes are no longer heard. So the realm also logs this error
56
+ * once with `console.error` when the deadline passes, whether or not the page calls.
57
+ */
58
+ declare class OwnChannelUnavailableError extends Error {
59
+ constructor();
60
+ }
61
+ /** In a realm that relays, this waits for the realm's own channel and rejects with `OwnChannelUnavailableError` instead. */
40
62
  declare const apiWithin: (what: string) => Promise<Api>;
41
63
  /**
42
64
  * Runs for the current broker connection on subscribe (if one exists) and for every later one.
@@ -69,7 +91,7 @@ declare const onApiEpoch: (listener: EpochListener<{
69
91
  fs: {
70
92
  available: () => Promise<boolean>;
71
93
  availability: () => Promise<ConnectAvailability>;
72
- list: () => Promise<{
94
+ list: (opts?: AccountPinOptions | undefined) => Promise<{
73
95
  path: string;
74
96
  size: number;
75
97
  contentType: string | null;
@@ -83,13 +105,14 @@ declare const onApiEpoch: (listener: EpochListener<{
83
105
  objects: number;
84
106
  maxObjects: number;
85
107
  }>;
86
- readFile: (path: string) => Promise<Uint8Array<ArrayBufferLike>>;
87
- readFileSealed: (path: string) => Promise<{
108
+ readFile: (path: string, opts?: AccountPinOptions | undefined) => Promise<Uint8Array<ArrayBufferLike>>;
109
+ readFileSealed: (path: string, opts?: AccountPinOptions | undefined) => Promise<{
88
110
  bytes: Uint8Array;
89
111
  sealedAt: number | null;
90
112
  }>;
91
- writeFile: (path: string, data: WriteData, contentType: string | null) => Promise<void>;
92
- remove: (path: string) => Promise<void>;
113
+ writeFile: (path: string, data: WriteData, contentType: string | null, opts?: AccountPinOptions | undefined) => Promise<void>;
114
+ remove: (path: string, opts?: AccountPinOptions | undefined) => Promise<void>;
115
+ accountPin: () => Promise<string>;
93
116
  encryption: () => Promise<{
94
117
  unlocked: boolean;
95
118
  enrolled: boolean;
@@ -683,7 +706,7 @@ declare const onApiEpoch: (listener: EpochListener<{
683
706
  } | null>;
684
707
  login: (consumerOrigin: string) => Promise<boolean>;
685
708
  logout: () => Promise<void>;
686
- onChange: (listener: () => void) => Promise<() => Promise<void>>;
709
+ onChange: (listener: (change?: AccountChange) => void) => Promise<() => Promise<void>>;
687
710
  };
688
711
  shell: {
689
712
  updateReady: () => Promise<boolean>;
@@ -785,7 +808,7 @@ declare const currentApiEpoch: () => {
785
808
  fs: {
786
809
  available: () => Promise<boolean>;
787
810
  availability: () => Promise<ConnectAvailability>;
788
- list: () => Promise<{
811
+ list: (opts?: AccountPinOptions | undefined) => Promise<{
789
812
  path: string;
790
813
  size: number;
791
814
  contentType: string | null;
@@ -799,13 +822,14 @@ declare const currentApiEpoch: () => {
799
822
  objects: number;
800
823
  maxObjects: number;
801
824
  }>;
802
- readFile: (path: string) => Promise<Uint8Array<ArrayBufferLike>>;
803
- readFileSealed: (path: string) => Promise<{
825
+ readFile: (path: string, opts?: AccountPinOptions | undefined) => Promise<Uint8Array<ArrayBufferLike>>;
826
+ readFileSealed: (path: string, opts?: AccountPinOptions | undefined) => Promise<{
804
827
  bytes: Uint8Array;
805
828
  sealedAt: number | null;
806
829
  }>;
807
- writeFile: (path: string, data: WriteData, contentType: string | null) => Promise<void>;
808
- remove: (path: string) => Promise<void>;
830
+ writeFile: (path: string, data: WriteData, contentType: string | null, opts?: AccountPinOptions | undefined) => Promise<void>;
831
+ remove: (path: string, opts?: AccountPinOptions | undefined) => Promise<void>;
832
+ accountPin: () => Promise<string>;
809
833
  encryption: () => Promise<{
810
834
  unlocked: boolean;
811
835
  enrolled: boolean;
@@ -1399,7 +1423,7 @@ declare const currentApiEpoch: () => {
1399
1423
  } | null>;
1400
1424
  login: (consumerOrigin: string) => Promise<boolean>;
1401
1425
  logout: () => Promise<void>;
1402
- onChange: (listener: () => void) => Promise<() => Promise<void>>;
1426
+ onChange: (listener: (change?: AccountChange) => void) => Promise<() => Promise<void>>;
1403
1427
  };
1404
1428
  shell: {
1405
1429
  updateReady: () => Promise<boolean>;
@@ -1480,4 +1504,4 @@ declare const currentApiEpoch: () => {
1480
1504
  declare const apiLastCall: () => number;
1481
1505
  declare const apiInFlight: () => number;
1482
1506
  //#endregion
1483
- export { apiPromise as a, hasTransport as c, apiLastCall as i, onApiEpoch as l, BrokerUnreachableError as n, apiWithin as o, apiInFlight as r, currentApiEpoch as s, API_DEADLINE_MS as t };
1507
+ export { apiLastCall as a, currentApiEpoch as c, apiInFlight as i, hasTransport as l, BrokerUnreachableError as n, apiPromise as o, OwnChannelUnavailableError as r, apiWithin as s, API_DEADLINE_MS as t, onApiEpoch as u };
package/api.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./api-jOTOA-5n.cjs");exports.API_DEADLINE_MS=e.t,exports.BrokerUnreachableError=e.n,exports.apiInFlight=e.r,exports.apiLastCall=e.i,exports.apiPromise=e.a,exports.apiWithin=e.o,exports.currentApiEpoch=e.s,exports.hasTransport=e.c,exports.onApiEpoch=e.l;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./api--LOXTOpv.cjs");exports.API_DEADLINE_MS=e.t,exports.BrokerUnreachableError=e.n,exports.OwnChannelUnavailableError=e.r,exports.apiInFlight=e.i,exports.apiLastCall=e.a,exports.apiPromise=e.o,exports.apiWithin=e.s,exports.currentApiEpoch=e.c,exports.hasTransport=e.l,exports.onApiEpoch=e.u;
package/api.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { U as Resolvers } from "./contract-Cvr_8gCL.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-BE5zPvFZ.js";
3
- export { API_DEADLINE_MS, BrokerUnreachableError, type Resolvers, apiInFlight, apiLastCall, apiPromise, apiWithin, currentApiEpoch, hasTransport, onApiEpoch };
1
+ import { K as Resolvers } from "./contract-CCxPKIC7.js";
2
+ import { a as apiLastCall, c as currentApiEpoch, i as apiInFlight, l as hasTransport, n as BrokerUnreachableError, o as apiPromise, r as OwnChannelUnavailableError, s as apiWithin, t as API_DEADLINE_MS, u as onApiEpoch } from "./api-SwxtiYVU.js";
3
+ export { API_DEADLINE_MS, BrokerUnreachableError, OwnChannelUnavailableError, type Resolvers, apiInFlight, apiLastCall, apiPromise, apiWithin, currentApiEpoch, hasTransport, onApiEpoch };
package/api.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c } from "./api-Dp-2AT3u.js";
2
- export { c as API_DEADLINE_MS, i as BrokerUnreachableError, o as apiInFlight, n as apiLastCall, e as apiPromise, a as apiWithin, s as currentApiEpoch, t as hasTransport, r as onApiEpoch };
1
+ import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c, u as l } from "./api-DIgTslNb.js";
2
+ export { c as API_DEADLINE_MS, i as BrokerUnreachableError, o as OwnChannelUnavailableError, n as apiInFlight, e as apiLastCall, a as apiPromise, s as apiWithin, t as currentApiEpoch, r as hasTransport, l as onApiEpoch };
package/attach-policy.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./hosts-9dYv63ud.cjs");var t=(t,n,{classifier:r=`no-base`}={})=>{if(!t.session)return{kind:`refuse`,reason:`frame.fetch on the cloud backend needs its own session: attach with syncCookies: false`};if(typeof n!=`string`)return{kind:`refuse`,reason:`frame.fetch: url must be a string`};let i;try{i=new URL(n)}catch{return{kind:`refuse`,reason:`frame.fetch on the cloud backend needs an absolute url`}}if(r===`fetchTarget`&&e.l(n).kind!==`absolute`)return{kind:`refuse`,reason:`frame.fetch on the cloud backend needs an absolute url`};if(i.protocol!==`https:`&&i.protocol!==`http:`)return{kind:`refuse`,reason:`frame.fetch: only http(s) urls are supported`};if(!(t.declaredHosts.includes(i.hostname)||t.approvedOrigins.has(i.origin)))return{kind:`refuse`,reason:`frame.fetch: the target is outside the origins this attachment declared`};let a=t.declaredHosts.length?t.declaredHosts:[i.hostname];return{kind:`consent`,targetHost:i.hostname,promptHosts:a}};exports.frameFetchVerdict=t,exports.normalizeDeclaredHosts=e.t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./hosts-GNBhZO3-.cjs");var t=(t,n,{classifier:r=`no-base`}={})=>{if(!t.session)return{kind:`refuse`,reason:`frame.fetch on the cloud backend needs its own session: attach with cookies: 'ephemeral'`};if(typeof n!=`string`)return{kind:`refuse`,reason:`frame.fetch: url must be a string`};let i;try{i=new URL(n)}catch{return{kind:`refuse`,reason:`frame.fetch on the cloud backend needs an absolute url`}}if(r===`fetchTarget`&&e.l(n).kind!==`absolute`)return{kind:`refuse`,reason:`frame.fetch on the cloud backend needs an absolute url`};if(i.protocol!==`https:`&&i.protocol!==`http:`)return{kind:`refuse`,reason:`frame.fetch: only http(s) urls are supported`};if(!(t.declaredHosts.includes(i.hostname)||t.approvedOrigins.has(i.origin)))return{kind:`refuse`,reason:`frame.fetch: the target is outside the origins this attachment declared`};let a=t.declaredHosts.length?t.declaredHosts:[i.hostname];return{kind:`consent`,targetHost:i.hostname,promptHosts:a}};exports.frameFetchVerdict=t,exports.normalizeDeclaredHosts=e.t;
package/attach-policy.js CHANGED
@@ -1,9 +1,9 @@
1
- import { l as e, t } from "./hosts-BzbzOhG8.js";
1
+ import { l as e, t } from "./hosts-t7CKGTRz.js";
2
2
  //#region src/attach-policy.ts
3
3
  var n = (t, n, { classifier: r = "no-base" } = {}) => {
4
4
  if (!t.session) return {
5
5
  kind: "refuse",
6
- reason: "frame.fetch on the cloud backend needs its own session: attach with syncCookies: false"
6
+ reason: "frame.fetch on the cloud backend needs its own session: attach with cookies: 'ephemeral'"
7
7
  };
8
8
  if (typeof n != "string") return {
9
9
  kind: "refuse",
package/cloud/dns.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { a as AddressLookupResult } from "../contract-Cvr_8gCL.js";
1
+ import { s as AddressLookupResult } from "../contract-CCxPKIC7.js";
2
2
  import { lookup } from "../dns.js";
3
3
  export { type AddressLookupResult, lookup };
package/cloud/fetch.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../proxy-DjoPtJH9.cjs");exports.fetch=e.t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../proxy-CFK-KiwE.cjs");exports.fetch=e.t;
package/cloud/fetch.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { t as cloudFetch } from "../proxy-Dc0gDOxz.js";
1
+ import { t as cloudFetch } from "../proxy-CE46SkyA.js";
2
2
  export { cloudFetch as fetch };
package/cloud/fetch.js CHANGED
@@ -1,2 +1,2 @@
1
- import { t as e } from "../proxy-DMTdQ4dN.js";
1
+ import { t as e } from "../proxy-Dixbk1WL.js";
2
2
  export { e 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--NhtUyYa.js";
2
+ import "../../fs-D0MMRnHC.js";
3
3
  //#region src/cloud/fs-promises.d.ts
4
4
  export 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-BNTPsX5c.cjs"),n=require("../messages.cjs"),r=require("../storage-BJd-mWHE.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;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../rolldown-runtime-BIInC43l.cjs"),t=require("../node-fs-nfX7wisL.cjs"),n=require("../messages.cjs"),r=require("../storage-D2cUJlVH.cjs");var i=e.t({STORAGE_ACCOUNT_CHANGED:()=>n.STORAGE_ACCOUNT_CHANGED,STORAGE_ACCOUNT_PIN_UNSUPPORTED:()=>n.STORAGE_ACCOUNT_PIN_UNSUPPORTED,STORAGE_NOT_FOUND:()=>n.STORAGE_NOT_FOUND,StorageAccountChangedError:()=>r.t,StorageAccountPinUnsupportedError:()=>r.n,StorageLockedError:()=>r.r,StorageNotFoundError:()=>r.i,availability:()=>r.a,available:()=>a,encryption:()=>r.s,isAccountChanged:()=>r.c,isNotFound:()=>r.u,list:()=>h,mkdir:()=>d,promises:()=>m,quota:()=>r.m,readFile:()=>o,readFileSealed:()=>g,readdir:()=>u,rename:()=>l,rm:()=>f,stat:()=>p,unlink:()=>c,unlock:()=>r.y,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.v,{memfs:!1}),h=()=>r.f(),g=e=>r.g(e);exports.STORAGE_ACCOUNT_CHANGED=n.STORAGE_ACCOUNT_CHANGED,exports.STORAGE_ACCOUNT_PIN_UNSUPPORTED=n.STORAGE_ACCOUNT_PIN_UNSUPPORTED,exports.STORAGE_NOT_FOUND=n.STORAGE_NOT_FOUND,exports.StorageAccountChangedError=r.t,exports.StorageAccountPinUnsupportedError=r.n,exports.StorageLockedError=r.r,exports.StorageNotFoundError=r.i,exports.availability=r.a,exports.available=a,exports.encryption=r.s,exports.isAccountChanged=r.c,exports.isNotFound=r.u,exports.list=h,exports.mkdir=d,exports.promises=m,exports.quota=r.m,exports.readFile=o,exports.readFileSealed=g,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.y,exports.writeFile=s;
package/cloud/fs.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { i as Stats } from "../index-BQgZVQl7.js";
2
- import { a as StorageNotFoundError, c as isNotFound, f 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-ZrY4Y4L5.js";
3
- import { a as STORAGE_NOT_FOUND } from "../messages-C66ghz_A.js";
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--NhtUyYa.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 };
2
+ import { _ as unlock, a as StorageAccountChangedError, c as StorageNotFoundError, f as encryption, h as quota, i as SealedRead, l as StorageQuota, m as isNotFound, n as EncryptionStatus, o as StorageAccountPinUnsupportedError, p as isAccountChanged, r as FileEntry, s as StorageLockedError, t as CloudAvailability, u as availability } from "../storage-BVr2Rb-d.js";
3
+ import { c as STORAGE_ACCOUNT_CHANGED, l as STORAGE_ACCOUNT_PIN_UNSUPPORTED, u as STORAGE_NOT_FOUND } from "../messages-CRcziTuC.js";
4
+ import { a as promises, c as readdir, d as stat, f as unlink, i as mkdir, l as rename, o as readFile, p as writeFile, r as list, s as readFileSealed, t as available, u as rm } from "../fs-D0MMRnHC.js";
5
+ export { type CloudAvailability, type EncryptionStatus, type FileEntry, STORAGE_ACCOUNT_CHANGED, STORAGE_ACCOUNT_PIN_UNSUPPORTED, STORAGE_NOT_FOUND, type SealedRead, type Stats, StorageAccountChangedError, StorageAccountPinUnsupportedError, StorageLockedError, StorageNotFoundError, type StorageQuota, availability, available, encryption, isAccountChanged, isNotFound, list, mkdir, promises, quota, readFile, readFileSealed, readdir, rename, rm, stat, unlink, unlock, writeFile };
package/cloud/fs.js CHANGED
@@ -1,27 +1,34 @@
1
1
  import { t as e } from "../rolldown-runtime-Dy4uBu1J.js";
2
- import { t } from "../node-fs-BZy9bzKd.js";
3
- import { STORAGE_NOT_FOUND as n } from "../messages.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-DSvL-t80.js";
2
+ import { t } from "../node-fs-CK2wWIYS.js";
3
+ import { STORAGE_ACCOUNT_CHANGED as n, STORAGE_ACCOUNT_PIN_UNSUPPORTED as r, STORAGE_NOT_FOUND as i } from "../messages.js";
4
+ import { a, c as o, f as s, g as c, i as l, m as u, n as d, r as f, s as p, t as m, u as h, v as g, y as _ } from "../storage-Dn1gTLSZ.js";
5
5
  //#region src/cloud/fs.ts
6
- var d = /* @__PURE__ */ e({
7
- STORAGE_NOT_FOUND: () => n,
8
- StorageLockedError: () => u,
9
- StorageNotFoundError: () => c,
10
- available: () => f,
11
- encryption: () => o,
12
- isNotFound: () => r,
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 });
6
+ var v = /* @__PURE__ */ e({
7
+ STORAGE_ACCOUNT_CHANGED: () => n,
8
+ STORAGE_ACCOUNT_PIN_UNSUPPORTED: () => r,
9
+ STORAGE_NOT_FOUND: () => i,
10
+ StorageAccountChangedError: () => m,
11
+ StorageAccountPinUnsupportedError: () => d,
12
+ StorageLockedError: () => f,
13
+ StorageNotFoundError: () => l,
14
+ availability: () => a,
15
+ available: () => y,
16
+ encryption: () => p,
17
+ isAccountChanged: () => o,
18
+ isNotFound: () => h,
19
+ list: () => k,
20
+ mkdir: () => T,
21
+ promises: () => O,
22
+ quota: () => u,
23
+ readFile: () => b,
24
+ readFileSealed: () => A,
25
+ readdir: () => w,
26
+ rename: () => C,
27
+ rm: () => E,
28
+ stat: () => D,
29
+ unlink: () => S,
30
+ unlock: () => _,
31
+ writeFile: () => x
32
+ }), { available: y, readFile: b, writeFile: x, unlink: S, rename: C, readdir: w, mkdir: T, rm: E, stat: D, promises: O } = t(g, { memfs: !1 }), k = () => s(), A = (e) => c(e);
26
33
  //#endregion
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 };
34
+ export { n as STORAGE_ACCOUNT_CHANGED, r as STORAGE_ACCOUNT_PIN_UNSUPPORTED, i as STORAGE_NOT_FOUND, m as StorageAccountChangedError, d as StorageAccountPinUnsupportedError, f as StorageLockedError, l as StorageNotFoundError, a as availability, y as available, p as encryption, o as isAccountChanged, h as isNotFound, k as list, T as mkdir, O as promises, u as quota, b as readFile, A as readFileSealed, w as readdir, C as rename, E as rm, D as stat, v as t, S as unlink, _ as unlock, x 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-zThwNoA8.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-DcLF-6E-.js";
2
2
  export { Server, Socket, _default, _default as default, connect, createConnection, createServer, isIP, isIPv4, isIPv6 };
@@ -0,0 +1 @@
1
+ const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./lib-CfdmsLoI.cjs"),n=require("./hosts-GNBhZO3-.cjs"),r=require("./api--LOXTOpv.cjs"),i=require("./busy-Dv8wzE5M.cjs"),a=require("./proxy-CFK-KiwE.cjs"),o=require("./attach-policy.cjs"),s=require("./contract.cjs"),c=require("./dns.cjs"),l=require("./cloud/fs.cjs"),u=require("./net.cjs"),d=require("./dgram.cjs"),f=require("./http.cjs");let p=require("osra");var m=async()=>{let e=()=>r.s(`frame consent`);try{let t=await e();return{request:typeof t.frameConsent.request==`function`?t.frameConsent.request:void 0,ensure:t.frameConsent.ensure}}catch(t){if(!(t instanceof r.n))throw t;return{request:void 0,ensure:t=>e().then(e=>e.frameConsent.ensure(t))}}},h=`frame: this frame no longer holds the document the app attached it to`,g=!1,_=()=>{g||(g=!0,console.warn(`[fkn-frame] this FKN broker is too old to ask for permission categories, so nothing was asked for upfront and each capability is asked for as it is first used. Reloading the page picks up the current broker.`))},v=e=>[...e].flatMap(e=>{try{return[new URL(e).hostname]}catch{return[]}}),y=(e,t,n)=>n===null?`frame.${e}: the user did not grant ${t} here`:`frame.${e}: the user did not grant ${t} on ${n}`,b=e=>{let{assertLive:r,attach:i,consent:a,current:s,declaredHosts:c,documentHost:l,freshBlank:u,session:d,approvedOrigins:f}=e,p=new Set,m=()=>{try{return new URL(s()).hostname}catch{return``}},g=async()=>l?await l():m(),b=()=>n.t([...c,...v(f)]),x=async(e,t)=>(await e([t]))[0]??!1;return{gate:async({operation:e,args:s,phase:l})=>{r();let _=n.m(e,s);if(_===null)return;let v=t.m(_);if(v===void 0||v===`auto`)return;if(e===`fetch`){let e=o.frameFetchVerdict({session:d,declaredHosts:c,approvedOrigins:f},l===`ensure`?void 0:s[0],{classifier:`fetchTarget`});if(l===`ensure`&&!d)throw t.D(e.kind===`refuse`?e.reason:``,`fetch`);if(l!==`ensure`&&e.kind===`refuse`)throw t.D(e.reason,`fetch`);let{request:r,ensure:i}=await a();if(!r){if(e.kind===`refuse`)throw t.D(e.reason,`fetch`);if(!await i({scope:n.c(s[0],s[1]).scope,hosts:e.promptHosts}))throw t.D(`frame.fetch: the user did not grant this`,`fetch`);return}let u=e.kind===`consent`?e.targetHost:await g(),p=n.t([u,...c]);if(!p.length)throw t.D(`frame: navigate the frame before fetch`,`fetch`);if(await x(r,{category:`network`,hosts:p})===!1)throw t.D(y(`fetch`,`network`,u||null),`fetch`);return}let S=await g();if(!S)throw t.D(`frame: navigate the frame before ${e}`,e);if(!b().includes(S))throw t.D(h,e);let C=t.p(_);if(C===void 0||C===`evaluation`&&S===m()&&await u?.()||v===`critical`&&p.has(`${_} ${S}`))return;let{request:w}=await a();if(!w)return;let T=n.t([S,...c]),E=await x(w,v===`critical`?{key:_,hosts:T,attach:i}:{category:C,hosts:T});if(E===!1)throw t.D(y(e,C,null),e);if(E===`once`&&l!==`ensure`)for(let e of T)p.add(`${_} ${e}`)},requestCategories:async e=>{r(),t.d(`frame.requestPermissions`,e);let o=await g(),s=n.t(o?[o,...c]:c);if(!s.length)throw TypeError(`frame.requestPermissions: navigate the frame or declare domains first`);let l=e.map(e=>{let n=e.key;return n===void 0?{named:void 0,critical:!1,category:e.category}:{named:n,critical:t.m(n)===`critical`,category:t.f(n)}}),u=({named:e,critical:t,category:n},r)=>({category:n,...t?{key:e}:{},hosts:s,allow:r}),{request:d}=await a();if(!d)return _(),l.map(e=>u(e,!1));let f=await d(l.map(({named:e,critical:t,category:n})=>t?{key:e,hosts:s,attach:i}:{category:n,hosts:s}));return l.map((e,t)=>u(e,f[t]!==void 0&&f[t]!==!1))},boundary:b}},x=e=>e,S=5e3,C=new Set([]),w=()=>`https://fkn.app`,T=e=>e===`persistent`?``:`incognito-${crypto.randomUUID()}`,E=(e,n,r)=>{let i,a=new Promise((e,a)=>{i=setTimeout(()=>a(typeof r==`string`?new t.w(r):r()),n)});return Promise.race([e,a]).finally(()=>clearTimeout(i))},D=e=>Object.assign(Error(e),{name:t.T}),O=`frame.postMessage: this FKN page predates frame messaging; reload the app to load the current one`,k=`frame.addScriptTag: this render proxy predates addScriptTag; reload the app`,A=`frame.addScriptTag: no answer within ${t.l}ms; the script may or may not have run`,j=`frame.clearCookies: this FKN page predates clearCookies; reload the app to load the current one`,M=`frame.clearCookies: this attachment reaches no site yet; attach a url, goto one, or declare it in domains`,N=3e4,P=`frame.clearCookies: the render proxy did not answer within ${N}ms; the cookies may or may not be gone, and calling it again is safe`,F=e=>t.E(e)&&e.message===t.k(`addScriptTag`).message,I=!1,L=()=>{I||(I=!0,console.warn(`[fkn-frame] this FKN page predates frame messaging, so the page's messages and documents are never reported. Reloading the app loads the current one.`))},R=({from:e,origin:t,attach:n,signal:r})=>i=>{let a=r=>{if(r.source===null||r.source!==e()||r.origin!==t)return;let a=r.data;typeof a==`object`&&a&&a.type===`fkn-frame-message`&&a.attach===n&&typeof a.origin==`string`&&(a.kind===`message`?i({type:`message`,data:a.data,origin:a.origin,ports:r.ports}):a.kind===`document`&&i({type:`document`,origin:a.origin}))};return window.addEventListener(`message`,a,{signal:r}),()=>window.removeEventListener(`message`,a)},z=e=>{if(typeof e!=`function`)return()=>Promise.resolve(e);let t=null;return()=>t??=e().catch(e=>{throw t=null,e})},B=({control:e,target:n,blank:r=!1,session:i,declaredHosts:a,approvedOrigins:o,attach:s,assertLive:c,guard:l,consent:u,onNavigated:d,relay:f})=>{let p=n,m=r&&i!==``,g=async()=>{if(!m)return!1;let t=typeof e.blank==`function`?await l(()=>e.blank()):``;return(typeof t!=`string`||t.split(`#`)[0]!==n.split(`#`)[0])&&(m=!1),m},_=Promise.resolve(),{gate:v,requestCategories:y,boundary:x}=b({session:i,declaredHosts:a,approvedOrigins:o,attach:s,assertLive:c,documentHost:typeof e.documentHost==`function`?()=>l(()=>e.documentHost()):void 0,current:()=>p,consent:z(u),freshBlank:g});return t.v({backend:`cloud`,executor:{execute:(n,r,i)=>C.has(r)?Promise.reject(t.k(r,`cloud`)):(c(),l(()=>e.executeLocator(n,r,i))),highlight:async()=>{}},gate:v,requestPermissions:y,evaluate:async(n,r)=>(c(),await v({parts:[],operation:`evaluate`,args:[n,r],phase:`execute`}),E(l(()=>e.executeLocator([],`evaluate`,[n,r])),t.l,t.u)),addScriptTag:async(n,r)=>{c();let i=[n,r];await v({parts:[],operation:`addScriptTag`,args:i,phase:`execute`});try{await E(l(()=>e.executeLocator([],`addScriptTag`,i)),t.l,A)}catch(e){throw F(e)?t.j(k,`addScriptTag`,`cloud`):e}},clearCookies:async n=>{if(c(),typeof e.clearCookies!=`function`)throw t.j(j,`clearCookies`,`cloud`);if(x().length===0)throw t.D(M,`clearCookies`);await E(l(()=>e.clearCookies(n)),N,P)},postMessage:(n,r,i)=>{if(c(),typeof e.messaging!=`function`)throw t.j(O,`postMessage`,`cloud`);if(r!==`*`&&!x().includes(new URL(r).hostname))throw t.D(h,`postMessage`);let{port1:a,port2:o}=new MessageChannel;a.postMessage({data:n,transfer:i},i);let s=[o,r],u=_.then(async()=>(await v({parts:[],operation:`postMessage`,args:s,phase:`execute`}),{answer:l(()=>e.executeLocator([],`postMessage`,s))}));return _=u.catch(()=>{}),u.then(async({answer:e})=>{await e})},listen:t=>(typeof e.messaging!=`function`&&L(),f(t)),goto:async(n,{timeout:r,...i}={})=>{let a=new URL(n,location.href).href;c(),m=!1;let s=(()=>{try{return new URL(a).origin}catch{return``}})(),u=s!==``&&!o.has(s);u&&o.add(s);try{await E(l(()=>e.goto(a,r===void 0?i:{...i,timeoutMs:r})),(r??3e4)+S,`cloud.attachFrame: the render proxy did not answer goto; the frame may have been detached or its page reloaded`)}catch(e){throw u&&o.delete(s),t.c(e)}p=a,d()},url:()=>p})},ee=250,te=500,ne=65e3,re=2e3,ie=2e3,ae=2,oe=2e3,se=2e3,ce=({origin:e,target:t,session:n,domains:r,attach:i})=>{let a=new URL(`/attach-window`,e);return a.searchParams.set(`attach`,i),t&&a.searchParams.set(`url`,t),n&&a.searchParams.set(`session`,n),r.length&&a.searchParams.set(`domains`,r.join(`,`)),a.href},V=(e,t)=>{let n=document.createElement(`iframe`),r=new URL(`/attach-jar`,e);return r.searchParams.set(`attach`,t),n.src=r.href,n.tabIndex=-1,n.setAttribute(`aria-hidden`,`true`),n.setAttribute(`style`,`display:none`),(document.body??document.documentElement).appendChild(n),n},H=(e,t)=>{let n=new MutationObserver(()=>{e.isConnected||t.aborted||(n.disconnect(),console.warn(`cloud.attachFrame: the window's jar anchor was removed from this page, so a sign-in in the window no longer reaches this app's cookie jar`))});e.parentNode&&n.observe(e.parentNode,{childList:!0}),n.observe(document.documentElement,{childList:!0}),t.addEventListener(`abort`,()=>n.disconnect(),{once:!0})},U=()=>D(`cloud.attachFrame: the attached window closed, reloaded or left the page FKN attached; attach a fresh window`),W=()=>D(`cloud.attachFrame: the attached window stopped answering; attach a fresh window`),le=()=>D(`cloud.attachFrame: the window went away before it connected; attach a fresh window`),ue=()=>D(`cloud.attachFrame: the window closed before it connected. Either the user closed it, or this page's Cross-Origin-Opener-Policy cut its link to the window`),de=async(e,r)=>{if(typeof window>`u`)throw Error(`cloud.attachFrame needs a window realm`);let{domains:a=[],permissions:o}=e,{url:c,width:l,height:u}=t.s(e.window);if(window.origin===`null`)throw new t.g(`opaque-opener`);let d=w(),f=crypto.randomUUID(),m=T(r),h=n.t(a),g=new Set;c&&g.add(new URL(c).origin);let _=r===`persistent`?V(d,f):null,v=window.open(ce({origin:d,target:c,session:m,domains:h,attach:f}),`_blank`,`popup,width=${l},height=${u}`);if(!v)throw _?.remove(),new t.h;let y=new AbortController,b=!1,S=null,C=(e,t=!1)=>{if(S===null){S=e,y.abort(t?W():U());try{v.closed||v.postMessage({type:s.ATTACH_WINDOW_MESSAGE.detach,attach:f,...t?{unanswered:t}:{}},d)}catch{}_&&setTimeout(()=>_.remove(),se)}};_&&H(_,y.signal);let D=new Promise((e,t)=>{y.signal.addEventListener(`abort`,()=>t(y.signal.reason),{once:!0})});D.catch(()=>{});let O=D.then(()=>{},()=>{}),k=()=>{if(y.signal.aborted)throw y.signal.reason},A=e=>y.signal.aborted?Promise.reject(y.signal.reason):Promise.race([e(),D]),j=e=>e.source===v&&e.origin===d;window.addEventListener(`message`,e=>{if(!j(e))return;let n=e.data;typeof n==`object`&&n&&n.attach===f&&(n.type===s.ATTACH_WINDOW_MESSAGE.refused?C(new t.g(n.reason)):n.type===s.ATTACH_WINDOW_MESSAGE.gone&&C(b?U():le()))},{signal:y.signal}),window.addEventListener(`pagehide`,()=>C(U()),{signal:y.signal});let M=()=>{try{v.postMessage({type:s.ATTACH_WINDOW_MESSAGE.hello,attach:f},d)}catch{}};M();let N=setInterval(M,ee),P=setInterval(()=>{v.closed&&C(b?U():ue())},te);y.signal.addEventListener(`abort`,()=>{clearInterval(N),clearInterval(P)},{once:!0});let F=async e=>{try{return await Promise.race([e,D])}catch(e){throw S??e}};try{let e=await F(E((0,p.expose)({},{key:s.ATTACH_WINDOW_KEY,transport:{emit:(e,t)=>v.postMessage(e,d,t??[]),receive:e=>{let t=t=>{j(t)&&e(t.data,{source:t.source,origin:t.origin})};return window.addEventListener(`message`,t),()=>window.removeEventListener(`message`,t)}},unregisterSignal:y.signal,revivableModules:x(t.ct)}),s.WINDOW_HANDSHAKE_TIMEOUT_MS,`cloud.attachFrame: timed out connecting to the window`));b=!0,clearInterval(N);let n=0,r=setInterval(()=>{E(A(()=>e.ping()),ie,`ping`).then(()=>{n=0},()=>{y.signal.aborted||(document.visibilityState===`hidden`?n=0:++n>=ae&&C(W(),!0))})},re);y.signal.addEventListener(`abort`,()=>clearInterval(r),{once:!0}),await F(E(e.ready(),ne,`cloud.attachFrame: the window never became ready`));let a=i.t(`attached frame`);y.signal.aborted?a():y.signal.addEventListener(`abort`,a,{once:!0});let l=B({control:e,target:c,session:m,declaredHosts:h,approvedOrigins:g,attach:f,assertLive:k,guard:A,consent:{request:t=>A(()=>e.requestConsent(t)),ensure:t=>A(()=>e.requestConsent([t])).then(([e])=>e!==void 0&&e!==!1)},onNavigated:()=>{},relay:R({from:()=>v,origin:d,attach:f,signal:y.signal})}),u=null,_=Object.assign(l,{close:()=>u??=(async()=>{y.signal.aborted||await E(Promise.allSettled([A(()=>e.flushCookies()),A(()=>e.sweepStorage())]),oe,`close`).catch(()=>{});try{v.close()}catch{}C(U())})(),closed:O});return o?.length&&await F(_.requestPermissions(o)),_}catch(e){let n=S??e;if(!(n instanceof t.g))try{v.close()}catch{}throw C(n),n}},fe=2e4,G=65e3,K=e=>!e||e===`about:blank`,pe=`cloud.attachFrame: this FKN page predates blank pages; reload the app to load the current one`,me=`cloud.attachFrame: cookies: 'native' needs the FKN browser extension; the cloud render proxy has no browser cookies`,q=e=>e.split(`#`)[0]??``,J=({iframe:e,lockdown:n,cookies:r,blank:i})=>{if(i===void 0)return``;if(typeof i!=`object`||!i)throw TypeError(`attachFrame: blank must be an object { url }`);let a=Object.keys(i).find(e=>e!==`url`);if(a!==void 0)throw TypeError(`attachFrame: blank takes { url }, not "${a}"`);let{url:o}=i,s=(()=>{try{return typeof o==`string`?new URL(o):null}catch{return null}})();if(!s||s.protocol!==`http:`&&s.protocol!==`https:`)throw TypeError(`attachFrame: blank.url must be an absolute http or https url, not "${String(o)}"`);let c=e.getAttribute(`src`)??``;if(!K(c))throw TypeError(`attachFrame: blank needs an iframe with no src; this one has "${c}"`);if(n)throw TypeError(`attachFrame: blank does not combine with lockdown`);if(r===`native`)throw TypeError(`attachFrame: blank runs on the cloud render proxy, which has no browser cookies; pass cookies: 'persistent' or 'ephemeral'`);if(t.b(s.href),!Se())throw Error(`attachFrame: a blank page is served by the cloud render proxy, which this build does not configure`);return s.href},he=({target:e,blank:t,session:n,domains:r,attach:i})=>{let a=new URL(`/attach-frame`,w());return t?a.searchParams.set(`blank`,t):e&&a.searchParams.set(`url`,e),n&&a.searchParams.set(`session`,n),r.length&&a.searchParams.set(`domains`,r.join(`,`)),a.searchParams.set(`attach`,i),a.href},ge=(e,t)=>{let n=()=>{a(),t()},r=e.parentNode,i=new MutationObserver(()=>{(!e.isConnected||e.parentNode!==r)&&(a(),t())}),a=()=>{window.removeEventListener(`pagehide`,n),i.disconnect()};window.addEventListener(`pagehide`,n,{once:!0}),r&&i.observe(r,{childList:!0}),e.isConnected||(a(),t())},_e=()=>D(`cloud.attachFrame: the attached iframe left the document or was reloaded; attach a fresh iframe`),ve=(e,t)=>{let n=[...e.split(`;`),...t.split(`;`)].map(e=>e.trim()).filter(Boolean);return[...new Set(n)].join(`; `)},ye=[300,1200,4e3],Y=e=>{let t=()=>{if(!e.isConnected)return;let t=e.style.height,n=e.getBoundingClientRect();n.height&&(e.style.height=`${n.height-1}px`,setTimeout(()=>{e.style.height=t},50))};t();for(let e of ye)setTimeout(t,e)},X=e=>{let t=e.getAttribute(`sandbox`);if(t===null)return;let n=new Set(t.toLowerCase().split(/\s+/).filter(Boolean)),r=[`allow-scripts`,`allow-same-origin`].filter(e=>!n.has(e));if(r.length)throw Error(`cloud.attachFrame: the iframe's sandbox attribute must include ${r.join(` and `)} for the render proxy to load`)},be=async(e,n)=>{let r=typeof e.blank==`function`?await E(e.blank(),G,`cloud.attachFrame: the render proxy never became ready`):``;if(typeof r!=`string`||q(r)!==q(n))throw t.j(pe,`blank`,`cloud`)},xe=async(e,a)=>{let o=J(e),{iframe:c,domains:l=[],permissions:u}=e;if(typeof window>`u`)throw Error(`cloud.attachFrame needs a window realm`);if(!c.isConnected)throw Error(`cloud.attachFrame: the iframe must be connected to the document before attaching`);X(c);let d=c.getAttribute(`src`)??``,f=(()=>{if(K(d))return null;try{return new URL(c.src||d,location.href)}catch{throw Error(`cloud.attachFrame: the iframe src is not a valid URL: ${d}`)}})();if(f){let e=new URL(`/attach-frame`,w());if(f.origin===e.origin&&f.pathname===e.pathname)throw Error(`cloud.attachFrame: this iframe is already attached; navigate with the Frame returned by that attach or use a fresh iframe`)}let h=f?.href??``;h&&t.b(h);let g=T(a),_=n.t(l),v=new Set;try{v.add(new URL(o||h).origin)}catch{}let y=new AbortController,b=c.referrerPolicy,S=c.allow,C=crypto.randomUUID();if(c.referrerPolicy=`origin`,c.allow=ve(r.m(),c.allow),c.src=he({target:h,blank:o,session:g,domains:_,attach:C}),!c.contentWindow)throw Error(`cloud.attachFrame: the iframe window is not available`);try{let e=await E((0,p.expose)({},{key:s.ATTACH_FRAME_KEY,origin:w(),transport:{receive:window,emit:c.contentWindow},unregisterSignal:y.signal,revivableModules:x(t.ct)}),fe,`cloud.attachFrame: timed out connecting to the render proxy page`);await E(e.ready(),G,`cloud.attachFrame: the render proxy never became ready`),o&&await be(e,o),(h||o)&&Y(c),ge(c,()=>y.abort());let n=i.t(`attached frame`);y.signal.aborted?n():y.signal.addEventListener(`abort`,n,{once:!0});let r=c.contentWindow,a=B({control:e,target:o||h,blank:o!==``,session:g,declaredHosts:_,approvedOrigins:v,attach:C,assertLive:()=>{if(y.signal.aborted||!c.isConnected||c.contentWindow!==r)throw y.abort(),_e()},guard:e=>e(),consent:m,onNavigated:()=>Y(c),relay:R({from:()=>r,origin:w(),attach:C,signal:y.signal})});return u?.length&&await a.requestPermissions(u),a}catch(e){throw y.abort(),c.referrerPolicy=b,c.allow=S,c.src=h||`about:blank`,e}},Z=(async e=>{let{kind:n,cookies:r}=t.o(e);if(r===`native`)throw TypeError(me);return n===`window`?de(e,r):xe(e,r)}),Se=()=>typeof window<`u`&&!0,Q=async()=>{let e=await r.o.then(e=>e.cloud.quota());return{premium:e.premium,overQuota:e.overQuota,throttled:e.overQuota&&!e.premium,usedBytes:e.usedBytes,limitBytes:e.limitBytes,remainingBytes:e.remaining,bytesPerSecond:e.bytesPerSecond,bitsPerSecond:e.bytesPerSecond*8}},Ce=e.t({attachFrame:()=>Z,available:()=>$,dgram:()=>d.t,dns:()=>c.t,fetch:()=>a.t,fs:()=>l.t,http:()=>f.t,net:()=>u.t,quota:()=>Q}),$=()=>r.l;Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return $}});
@@ -1,14 +1,16 @@
1
- import { r as AttachFrameFunction } from "./index-D2CA-NX5.js";
2
- import { t as cloudFetch } from "./proxy-Dc0gDOxz.js";
1
+ import { r as AttachFrameFunction } from "./index-BtFiGoVQ.js";
2
+ import { t as cloudFetch } from "./proxy-CE46SkyA.js";
3
3
  import { t as dns_d_exports } from "./dns.js";
4
- import { n as fs_d_exports } from "./fs--NhtUyYa.js";
5
- import { s as net_d_exports } from "./net-zThwNoA8.js";
4
+ import { n as fs_d_exports } from "./fs-D0MMRnHC.js";
5
+ import { s as net_d_exports } from "./net-DcLF-6E-.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
9
9
  /**
10
10
  * Attaches the render proxy to an iframe the app mounted, or opens it in a window of its own with
11
11
  * `{ window }`. A window opens before the first await, so call this directly in a click handler.
12
+ * Serves `cookies: 'persistent'`, the default, and `'ephemeral'`; `'native'`, the browser's own
13
+ * cookies, is a TypeError before anything is attached or opened (`AttachCookies`).
12
14
  */
13
15
  declare const attachFrame: AttachFrameFunction;
14
16
  //#endregion