@fkn/lib 0.9.57 → 0.9.59

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 (80) hide show
  1. package/{account-generation-ORsS9Z2F.js → account-generation-2ZvMy2tZ.js} +1 -1
  2. package/{account-generation-B6qSQaTA.cjs → account-generation-DIsOqkSQ.cjs} +1 -1
  3. package/{account-storage-Bi47np3p.cjs → account-storage-CPTct4Vz.cjs} +1 -1
  4. package/{account-storage-CVlvzWav.js → account-storage-Cmzz-67T.js} +2 -2
  5. package/account.cjs +1 -1
  6. package/account.d.ts +1 -1
  7. package/account.js +2 -2
  8. package/{api-DvS3QcoU.js → api-C-N5AVos.js} +4 -4
  9. package/{api-DTJ5gCWb.d.ts → api-_LPVMHpt.d.ts} +24 -1
  10. package/{api-CNYWAaFu.cjs → api-ibGqkmtA.cjs} +1 -1
  11. package/api.cjs +1 -1
  12. package/api.d.ts +2 -2
  13. package/api.js +1 -1
  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.cjs +1 -1
  19. package/cloud/fs.js +1 -1
  20. package/cloud/net.d.ts +1 -1
  21. package/{cloud-zSEiIhvg.js → cloud-B6B2XcRU.js} +205 -184
  22. package/{cloud-DdAgVqlV.d.ts → cloud-BBQOLP4h.d.ts} +3 -3
  23. package/cloud-C0hcBrFd.cjs +1 -0
  24. package/cloud.cjs +1 -1
  25. package/cloud.d.ts +3 -3
  26. package/cloud.js +2 -2
  27. package/{contract-t5YLkrMK.d.ts → contract-m0ztKGCd.d.ts} +45 -5
  28. package/contract.cjs +1 -1
  29. package/contract.d.ts +3 -3
  30. package/contract.js +2 -2
  31. package/dgram.cjs +1 -1
  32. package/dgram.d.ts +10 -5
  33. package/dgram.js +64 -60
  34. package/dns.cjs +1 -1
  35. package/dns.d.ts +1 -1
  36. package/dns.js +1 -1
  37. package/extension-AidgSVhb.js +101 -0
  38. package/{extension-kE9yzbkW.d.ts → extension-C_eOfEjv.d.ts} +3 -2
  39. package/extension-M8bUhlML.cjs +1 -0
  40. package/extension.cjs +1 -1
  41. package/extension.d.ts +3 -3
  42. package/extension.js +1 -1
  43. package/fs/promises.cjs +1 -1
  44. package/fs/promises.js +1 -1
  45. package/{fs-igMZHzs7.cjs → fs-BlRxCJQW.cjs} +1 -1
  46. package/{fs-dqvJytOJ.js → fs-C_RmxWk9.js} +2 -2
  47. package/fs.cjs +1 -1
  48. package/fs.js +2 -2
  49. package/http.cjs +1 -1
  50. package/http.d.ts +4 -1
  51. package/http.js +2 -1
  52. package/{index-BQ5OZQhf.d.ts → index-C5DdoMGo.d.ts} +38 -1
  53. package/index.cjs +1 -1
  54. package/index.d.ts +7 -5
  55. package/index.js +53 -51
  56. package/{net-C94nCjW2.d.ts → net-dxm4WUEH.d.ts} +14 -7
  57. package/net.cjs +1 -1
  58. package/net.d.ts +1 -1
  59. package/net.js +52 -46
  60. package/package.json +1 -1
  61. package/packages.cjs +1 -1
  62. package/packages.d.ts +1 -1
  63. package/packages.js +1 -1
  64. package/proxy-C1RlnrDC.js +61 -0
  65. package/proxy-CII2NFYV.cjs +1 -0
  66. package/{proxy-C-Y5NiAa.d.ts → proxy-CzciyJH2.d.ts} +2 -2
  67. package/relay-choice-BGwXRC5d.js +14 -0
  68. package/relay-choice-JC_JJY_M.cjs +1 -0
  69. package/relay-choice-ka0GQUF2.d.ts +28 -0
  70. package/rooms.cjs +1 -1
  71. package/rooms.d.ts +6 -6
  72. package/rooms.js +1 -1
  73. package/storage.cjs +1 -1
  74. package/storage.d.ts +1 -1
  75. package/storage.js +3 -3
  76. package/cloud-V4wvwQaO.cjs +0 -1
  77. package/extension-52n-tLJd.cjs +0 -1
  78. package/extension-DPNgKyHp.js +0 -95
  79. package/proxy-Cp9iO8Wr.js +0 -60
  80. package/proxy-D9PZwEZJ.cjs +0 -1
@@ -1,17 +1,18 @@
1
1
  import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
2
2
  import { D as t, E as n, N as r, O as i, T as a, _ as o, c as s, f as c, ft as l, g as u, h as d, j as f, k as p, l as m, m as h, o as g, p as _, s as v, u as y, x as b, y as x } from "./lib-BGAmzIcU.js";
3
3
  import { c as S, m as C, t as w } from "./hosts-t7CKGTRz.js";
4
- import { l as T, m as E, n as D, o as O, s as k } from "./api-DvS3QcoU.js";
4
+ import { l as T, m as E, n as D, o as O, s as k } from "./api-C-N5AVos.js";
5
5
  import { r as A } from "./busy-DsMWrSzc.js";
6
- import { t as j } from "./proxy-Cp9iO8Wr.js";
7
- import { frameFetchVerdict as M } from "./attach-policy.js";
8
- import { ATTACH_FRAME_KEY as N, ATTACH_WINDOW_KEY as ee, ATTACH_WINDOW_MESSAGE as P, WINDOW_HANDSHAKE_TIMEOUT_MS as te } from "./contract.js";
6
+ import { ATTACH_FRAME_KEY as j, ATTACH_WINDOW_KEY as ee, ATTACH_WINDOW_MESSAGE as M, RELAY_CHOICE_UNSUPPORTED as N, WINDOW_HANDSHAKE_TIMEOUT_MS as te } from "./contract.js";
7
+ import { a as P, i as F, t as I } from "./relay-choice-BGwXRC5d.js";
8
+ import { t as L } from "./proxy-C1RlnrDC.js";
9
+ import { frameFetchVerdict as R } from "./attach-policy.js";
9
10
  import { t as ne } from "./dns.js";
10
11
  import { t as re } from "./cloud/fs.js";
11
12
  import { t as ie } from "./net.js";
12
13
  import { t as ae } from "./dgram.js";
13
14
  import { t as oe } from "./http.js";
14
- import { expose as F } from "osra";
15
+ import { expose as z } from "osra";
15
16
  //#region src/cloud/frame-broker.ts
16
17
  var se = async () => {
17
18
  let e = () => k("frame consent");
@@ -28,15 +29,15 @@ var se = async () => {
28
29
  ensure: (t) => e().then((e) => e.frameConsent.ensure(t))
29
30
  };
30
31
  }
31
- }, I = "frame: this frame no longer holds the document the app attached it to", L = !1, ce = () => {
32
- L || (L = !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."));
32
+ }, B = "frame: this frame no longer holds the document the app attached it to", V = !1, ce = () => {
33
+ V || (V = !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."));
33
34
  }, le = (e) => [...e].flatMap((e) => {
34
35
  try {
35
36
  return [new URL(e).hostname];
36
37
  } catch {
37
38
  return [];
38
39
  }
39
- }), R = (e) => typeof e?.reason == "string" ? { reason: e.reason } : {}, z = (e, t, n) => n === null ? `frame.${e}: the user did not grant ${t} here` : `frame.${e}: the user did not grant ${t} on ${n}`, ue = (e) => {
40
+ }), H = (e) => typeof e?.reason == "string" ? { reason: e.reason } : {}, U = (e, t, n) => n === null ? `frame.${e}: the user did not grant ${t} here` : `frame.${e}: the user did not grant ${t} on ${n}`, ue = (e) => {
40
41
  let { assertLive: t, attach: n, consent: r, current: i, declaredHosts: o, documentHost: s, freshBlank: l, session: u, approvedOrigins: f } = e, m = /* @__PURE__ */ new Set(), g = () => {
41
42
  try {
42
43
  return new URL(i()).hostname;
@@ -52,7 +53,7 @@ var se = async () => {
52
53
  let _ = d(c);
53
54
  if (_ === void 0 || _ === "auto") return;
54
55
  if (e === "fetch") {
55
- let e = M({
56
+ let e = R({
56
57
  session: u,
57
58
  declaredHosts: o,
58
59
  approvedOrigins: f
@@ -73,18 +74,18 @@ var se = async () => {
73
74
  if (await b(t, {
74
75
  category: "network",
75
76
  hosts: l,
76
- ...R(a(i))
77
- }) === !1) throw p(z("fetch", "network", c || null), "fetch");
77
+ ...H(a(i))
78
+ }) === !1) throw p(U("fetch", "network", c || null), "fetch");
78
79
  return;
79
80
  }
80
81
  let x = await v();
81
82
  if (!x) throw p(`frame: navigate the frame before ${e}`, e);
82
- if (!y().includes(x)) throw p(I, e);
83
+ if (!y().includes(x)) throw p(B, e);
83
84
  let T = h(c);
84
85
  if (T === void 0 || T === "evaluation" && x === g() && await l?.() || _ === "critical" && m.has(`${c} ${x}`)) return;
85
86
  let { request: E } = await r();
86
87
  if (!E) return;
87
- let D = w([x, ...o]), O = R(a(i)), k = _ === "critical" ? {
88
+ let D = w([x, ...o]), O = H(a(i)), k = _ === "critical" ? {
88
89
  key: c,
89
90
  hosts: D,
90
91
  attach: n,
@@ -94,7 +95,7 @@ var se = async () => {
94
95
  hosts: D,
95
96
  ...O
96
97
  }, A = await b(E, k);
97
- if (A === !1) throw p(z(e, T, null), e);
98
+ if (A === !1) throw p(U(e, T, null), e);
98
99
  if (A === "once" && s !== "ensure") for (let e of D) m.add(`${c} ${e}`);
99
100
  },
100
101
  requestCategories: async (e) => {
@@ -120,7 +121,7 @@ var se = async () => {
120
121
  }), { request: u } = await r();
121
122
  if (!u) return ce(), s.map((e) => l(e, !1));
122
123
  let f = await u(s.map(({ named: t, critical: r, category: i }, o) => {
123
- let s = R(e[o]);
124
+ let s = H(e[o]);
124
125
  return r ? {
125
126
  key: t,
126
127
  hosts: a,
@@ -136,21 +137,21 @@ var se = async () => {
136
137
  },
137
138
  boundary: y
138
139
  };
139
- }, B = (e) => e, de = 5e3, fe = /* @__PURE__ */ new Set([]), V = () => "https://fkn.app", H = (e) => e === "persistent" ? "" : `incognito-${crypto.randomUUID()}`, U = (e, t, r) => {
140
+ }, W = (e) => e, de = 5e3, fe = /* @__PURE__ */ new Set([]), G = () => "https://fkn.app", K = (e) => e === "persistent" ? "" : `incognito-${crypto.randomUUID()}`, q = (e, t, r) => {
140
141
  let i, a = new Promise((e, a) => {
141
142
  i = setTimeout(() => a(typeof r == "string" ? new n(r) : r()), t);
142
143
  });
143
144
  return Promise.race([e, a]).finally(() => clearTimeout(i));
144
- }, W = (e) => Object.assign(Error(e), { name: t }), pe = "frame.postMessage: this FKN page predates frame messaging; reload the app to load the current one", me = "frame.addScriptTag: this render proxy predates addScriptTag; reload the app", he = `frame.addScriptTag: no answer within ${m}ms; the script may or may not have run`, ge = "frame.clearCookies: this FKN page predates clearCookies; reload the app to load the current one", _e = "frame.clearCookies: this attachment reaches no site yet; attach a url, goto one, or declare it in domains", G = 3e4, K = "attachFrame: this FKN page predates storageState; reload the app to load the current one", ve = 2e4, q = async (e, t) => {
145
- if (typeof e.seed != "function") throw r(K, "storageState", "cloud");
145
+ }, J = (e) => Object.assign(Error(e), { name: t }), pe = "frame.postMessage: this FKN page predates frame messaging; reload the app to load the current one", me = "frame.addScriptTag: this render proxy predates addScriptTag; reload the app", he = `frame.addScriptTag: no answer within ${m}ms; the script may or may not have run`, ge = "frame.clearCookies: this FKN page predates clearCookies; reload the app to load the current one", _e = "frame.clearCookies: this attachment reaches no site yet; attach a url, goto one, or declare it in domains", Y = 3e4, X = "attachFrame: this FKN page predates storageState; reload the app to load the current one", ve = 2e4, ye = async (e, t) => {
146
+ if (typeof e.seed != "function") throw r(X, "storageState", "cloud");
146
147
  try {
147
- await U(e.seed(t), ve, "attachFrame: the render proxy did not take the storageState seed");
148
+ await q(e.seed(t), ve, "attachFrame: the render proxy did not take the storageState seed");
148
149
  } catch (e) {
149
- throw i(e) ? r(K, "storageState", "cloud") : e;
150
+ throw i(e) ? r(X, "storageState", "cloud") : e;
150
151
  }
151
- }, ye = `frame.clearCookies: the render proxy did not answer within ${G}ms; the cookies may or may not be gone, and calling it again is safe`, be = (e) => i(e) && e.message === f("addScriptTag").message, J = !1, xe = () => {
152
- J || (J = !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."));
153
- }, Y = ({ from: e, origin: t, attach: n, signal: r }) => (i) => {
152
+ }, be = `frame.clearCookies: the render proxy did not answer within ${Y}ms; the cookies may or may not be gone, and calling it again is safe`, xe = (e) => i(e) && e.message === f("addScriptTag").message, Se = !1, Ce = () => {
153
+ Se || (Se = !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."));
154
+ }, we = ({ from: e, origin: t, attach: n, signal: r }) => (i) => {
154
155
  let a = (r) => {
155
156
  if (r.source === null || r.source !== e() || r.origin !== t) return;
156
157
  let a = r.data;
@@ -165,13 +166,13 @@ var se = async () => {
165
166
  }));
166
167
  };
167
168
  return window.addEventListener("message", a, { signal: r }), () => window.removeEventListener("message", a);
168
- }, Se = (e) => {
169
+ }, Te = (e) => {
169
170
  if (typeof e != "function") return () => Promise.resolve(e);
170
171
  let t = null;
171
172
  return () => t ??= e().catch((e) => {
172
173
  throw t = null, e;
173
174
  });
174
- }, X = ({ control: e, target: t, blank: n = !1, session: i, declaredHosts: a, approvedOrigins: o, attach: c, assertLive: l, guard: u, consent: d, onNavigated: h, relay: g }) => {
175
+ }, Ee = ({ control: e, target: t, blank: n = !1, session: i, declaredHosts: a, approvedOrigins: o, attach: c, assertLive: l, guard: u, consent: d, onNavigated: h, relay: g }) => {
175
176
  let _ = t, v = n && i !== "", b = async () => {
176
177
  if (!v) return !1;
177
178
  let n = typeof e.blank == "function" ? await u(() => e.blank()) : "";
@@ -184,7 +185,7 @@ var se = async () => {
184
185
  assertLive: l,
185
186
  documentHost: typeof e.documentHost == "function" ? () => u(() => e.documentHost()) : void 0,
186
187
  current: () => _,
187
- consent: Se(d),
188
+ consent: Te(d),
188
189
  freshBlank: b
189
190
  });
190
191
  return x({
@@ -200,7 +201,7 @@ var se = async () => {
200
201
  operation: "evaluate",
201
202
  args: [t],
202
203
  phase: "execute"
203
- }), U(u(() => e.executeLocator([], "evaluate", [t, n])), m, y)),
204
+ }), q(u(() => e.executeLocator([], "evaluate", [t, n])), m, y)),
204
205
  addScriptTag: async (t, n) => {
205
206
  l();
206
207
  let i = [t, n];
@@ -211,19 +212,19 @@ var se = async () => {
211
212
  phase: "execute"
212
213
  });
213
214
  try {
214
- await U(u(() => e.executeLocator([], "addScriptTag", i)), m, he);
215
+ await q(u(() => e.executeLocator([], "addScriptTag", i)), m, he);
215
216
  } catch (e) {
216
- throw be(e) ? r(me, "addScriptTag", "cloud") : e;
217
+ throw xe(e) ? r(me, "addScriptTag", "cloud") : e;
217
218
  }
218
219
  },
219
220
  clearCookies: async (t) => {
220
221
  if (l(), typeof e.clearCookies != "function") throw r(ge, "clearCookies", "cloud");
221
222
  if (T().length === 0) throw p(_e, "clearCookies");
222
- await U(u(() => e.clearCookies(t)), G, ye);
223
+ await q(u(() => e.clearCookies(t)), Y, be);
223
224
  },
224
225
  postMessage: (t, n, i) => {
225
226
  if (l(), typeof e.messaging != "function") throw r(pe, "postMessage", "cloud");
226
- if (n !== "*" && !T().includes(new URL(n).hostname)) throw p(I, "postMessage");
227
+ if (n !== "*" && !T().includes(new URL(n).hostname)) throw p(B, "postMessage");
227
228
  let { port1: a, port2: o } = new MessageChannel();
228
229
  a.postMessage({
229
230
  data: t,
@@ -239,7 +240,7 @@ var se = async () => {
239
240
  await e;
240
241
  });
241
242
  },
242
- listen: (t) => (typeof e.messaging != "function" && xe(), g(t)),
243
+ listen: (t) => (typeof e.messaging != "function" && Ce(), g(t)),
243
244
  goto: async (t, { timeout: n, ...r } = {}) => {
244
245
  let i = new URL(t, location.href).href;
245
246
  l(), v = !1;
@@ -252,7 +253,7 @@ var se = async () => {
252
253
  })(), c = a !== "" && !o.has(a);
253
254
  c && o.add(a);
254
255
  try {
255
- await U(u(() => e.goto(i, n === void 0 ? r : {
256
+ await q(u(() => e.goto(i, n === void 0 ? r : {
256
257
  ...r,
257
258
  timeoutMs: n
258
259
  })), (n ?? 3e4) + de, "cloud.attachFrame: the render proxy did not answer goto; the frame may have been detached or its page reloaded");
@@ -263,87 +264,106 @@ var se = async () => {
263
264
  },
264
265
  url: () => _
265
266
  });
266
- }, Ce = 250, we = 500, Te = 65e3, Ee = 2e3, De = 2e3, Oe = 2, ke = 2e3, Ae = 2e3, je = ({ origin: e, target: t, session: n, domains: r, attach: i }) => {
267
+ }, De = async (e) => {
268
+ if (e === void 0) {
269
+ let e = await k("a relay").catch(() => void 0);
270
+ if (typeof e?.relay?.resolve != "function") return;
271
+ let t = await e.relay.resolve().catch(() => void 0);
272
+ return t && "id" in t ? t.id : void 0;
273
+ }
274
+ let t = await k("a relay choice");
275
+ I(t, "attachFrame");
276
+ let n = await t.relay.resolve(e);
277
+ if ("refused" in n) throw F(`attachFrame: ${n.refused}`);
278
+ return n.id;
279
+ }, Oe = async (e, t) => {
280
+ if ((typeof e.relay == "function" ? await e.relay() : "") !== t) throw F(`attachFrame: ${N}`);
281
+ }, ke = 250, Ae = 500, je = 65e3, Me = 2e3, Ne = 2e3, Pe = 2, Fe = 2e3, Ie = 2e3, Le = ({ origin: e, target: t, session: n, domains: r, attach: i }) => {
267
282
  let a = new URL("/attach-window", e);
268
283
  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;
269
- }, Me = (e, t) => {
284
+ }, Re = (e, t) => {
270
285
  let n = document.createElement("iframe"), r = new URL("/attach-jar", e);
271
286
  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;
272
- }, Ne = (e, t) => {
287
+ }, ze = (e, t) => {
273
288
  let n = new MutationObserver(() => {
274
289
  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"));
275
290
  });
276
291
  e.parentNode && n.observe(e.parentNode, { childList: !0 }), n.observe(document.documentElement, { childList: !0 }), t.addEventListener("abort", () => n.disconnect(), { once: !0 });
277
- }, Z = () => W("cloud.attachFrame: the attached window closed, reloaded or left the page FKN attached; attach a fresh window"), Pe = () => W("cloud.attachFrame: the attached window stopped answering; attach a fresh window"), Fe = () => W("cloud.attachFrame: the window went away before it connected; attach a fresh window"), Ie = () => W("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"), Le = async (e, t, n) => {
292
+ }, Z = () => J("cloud.attachFrame: the attached window closed, reloaded or left the page FKN attached; attach a fresh window"), Be = () => J("cloud.attachFrame: the attached window stopped answering; attach a fresh window"), Ve = () => J("cloud.attachFrame: the window went away before it connected; attach a fresh window"), He = () => J("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"), Ue = async (e, t, n) => {
278
293
  if (typeof window > "u") throw Error("cloud.attachFrame needs a window realm");
279
- let { domains: r = [], permissions: i } = e, { url: a, width: s, height: c } = v(e.window);
294
+ let { domains: r = [], permissions: i, relay: a } = e, { url: s, width: c, height: d } = v(e.window);
280
295
  if (window.origin === "null") throw new o("opaque-opener");
281
- let d = V(), f = crypto.randomUUID(), p = H(t), m = w(r), h = /* @__PURE__ */ new Set();
282
- a && h.add(new URL(a).origin);
283
- let g = t === "persistent" ? Me(d, f) : null, _ = window.open(je({
284
- origin: d,
285
- target: n === void 0 ? a : "",
286
- session: p,
287
- domains: m,
288
- attach: f
289
- }), "_blank", `popup,width=${s},height=${c}`);
290
- if (!_) throw g?.remove(), new u();
291
- let y = new AbortController(), b = !1, x = null, S = (e, t = !1) => {
292
- if (x === null) {
293
- x = e, y.abort(t ? Pe() : Z());
296
+ let f = G(), p = crypto.randomUUID(), m = K(t), h = w(r), g = /* @__PURE__ */ new Set();
297
+ s && g.add(new URL(s).origin);
298
+ let _ = t === "persistent" ? Re(f, p) : null, y = window.open(Le({
299
+ origin: f,
300
+ target: n === void 0 ? s : "",
301
+ session: m,
302
+ domains: h,
303
+ attach: p
304
+ }), "_blank", `popup,width=${c},height=${d}`);
305
+ if (!y) throw _?.remove(), new u();
306
+ let b = new AbortController(), x = !1, S = null, C = (e, t = !1) => {
307
+ if (S === null) {
308
+ S = e, b.abort(t ? Be() : Z());
294
309
  try {
295
- _.closed || _.postMessage({
296
- type: P.detach,
297
- attach: f,
310
+ y.closed || y.postMessage({
311
+ type: M.detach,
312
+ attach: p,
298
313
  ...t ? { unanswered: t } : {}
299
- }, d);
314
+ }, f);
300
315
  } catch {}
301
- g && setTimeout(() => g.remove(), Ae);
316
+ _ && setTimeout(() => _.remove(), Ie);
302
317
  }
303
318
  };
304
- g && Ne(g, y.signal);
305
- let C = new Promise((e, t) => {
306
- y.signal.addEventListener("abort", () => t(y.signal.reason), { once: !0 });
319
+ _ && ze(_, b.signal);
320
+ let T = new Promise((e, t) => {
321
+ b.signal.addEventListener("abort", () => t(b.signal.reason), { once: !0 });
307
322
  });
308
- C.catch(() => {});
309
- let T = C.then(() => {}, () => {}), E = () => {
310
- if (y.signal.aborted) throw y.signal.reason;
311
- }, D = (e) => y.signal.aborted ? Promise.reject(y.signal.reason) : Promise.race([e(), C]), O = (e) => e.source === _ && e.origin === d;
323
+ T.catch(() => {});
324
+ let E = T.then(() => {}, () => {}), D = () => {
325
+ if (b.signal.aborted) throw b.signal.reason;
326
+ }, O = (e) => b.signal.aborted ? Promise.reject(b.signal.reason) : Promise.race([e(), T]), k = (e) => e.source === y && e.origin === f;
312
327
  window.addEventListener("message", (e) => {
313
- if (!O(e)) return;
328
+ if (!k(e)) return;
314
329
  let t = e.data;
315
- typeof t == "object" && t && t.attach === f && (t.type === P.refused ? S(new o(t.reason)) : t.type === P.gone && S(b ? Z() : Fe()));
316
- }, { signal: y.signal }), window.addEventListener("pagehide", () => S(Z()), { signal: y.signal });
317
- let k = () => {
318
- try {
319
- _.postMessage({
320
- type: P.hello,
321
- attach: f
322
- }, d);
323
- } catch {}
330
+ typeof t == "object" && t && t.attach === p && (t.type === M.refused ? C(new o(t.reason)) : t.type === M.gone && C(x ? Z() : Ve()));
331
+ }, { signal: b.signal }), window.addEventListener("pagehide", () => C(Z()), { signal: b.signal });
332
+ let j = De(a), N, F, I = () => {
333
+ let e = () => {
334
+ try {
335
+ y.postMessage({
336
+ type: M.hello,
337
+ attach: p,
338
+ ...N ? { relay: N } : {}
339
+ }, f);
340
+ } catch {}
341
+ };
342
+ e(), F = setInterval(e, ke);
324
343
  };
325
- k();
326
- let j = setInterval(k, Ce), M = setInterval(() => {
327
- _.closed && S(b ? Z() : Ie());
328
- }, we);
329
- y.signal.addEventListener("abort", () => {
330
- clearInterval(j), clearInterval(M);
344
+ a === void 0 && I();
345
+ let L = setInterval(() => {
346
+ y.closed && C(x ? Z() : He());
347
+ }, Ae);
348
+ b.signal.addEventListener("abort", () => {
349
+ clearInterval(F), clearInterval(L);
331
350
  }, { once: !0 });
332
- let N = async (e) => {
351
+ let R = async (e) => {
333
352
  try {
334
- return await Promise.race([e, C]);
353
+ return await Promise.race([e, T]);
335
354
  } catch (e) {
336
- throw x ?? e;
355
+ throw S ?? e;
337
356
  }
338
357
  };
339
358
  try {
340
- let e = await N(U(F({}, {
359
+ a !== void 0 && (N = await R(j), I());
360
+ let e = await R(q(z({}, {
341
361
  key: ee,
342
362
  transport: {
343
- emit: (e, t) => _.postMessage(e, d, t ?? []),
363
+ emit: (e, t) => y.postMessage(e, f, t ?? []),
344
364
  receive: (e) => {
345
365
  let t = (t) => {
346
- O(t) && e(t.data, {
366
+ k(t) && e(t.data, {
347
367
  source: t.source,
348
368
  origin: t.origin
349
369
  });
@@ -351,57 +371,57 @@ var se = async () => {
351
371
  return window.addEventListener("message", t), () => window.removeEventListener("message", t);
352
372
  }
353
373
  },
354
- unregisterSignal: y.signal,
355
- revivableModules: B(l)
374
+ unregisterSignal: b.signal,
375
+ revivableModules: W(l)
356
376
  }), te, "cloud.attachFrame: timed out connecting to the window"));
357
- b = !0, clearInterval(j);
377
+ x = !0, clearInterval(F);
358
378
  let t = 0, r = setInterval(() => {
359
- U(D(() => e.ping()), De, "ping").then(() => {
379
+ q(O(() => e.ping()), Ne, "ping").then(() => {
360
380
  t = 0;
361
381
  }, () => {
362
- y.signal.aborted || (document.visibilityState === "hidden" ? t = 0 : ++t >= Oe && S(Pe(), !0));
382
+ b.signal.aborted || (document.visibilityState === "hidden" ? t = 0 : ++t >= Pe && C(Be(), !0));
363
383
  });
364
- }, Ee);
365
- y.signal.addEventListener("abort", () => clearInterval(r), { once: !0 }), await N(U(e.ready(), Te, "cloud.attachFrame: the window never became ready")), n !== void 0 && await N(q(e, n)), A("attached frame", y.signal);
366
- let o = X({
384
+ }, Me);
385
+ b.signal.addEventListener("abort", () => clearInterval(r), { once: !0 }), N && await R(q(Oe(e, N), je, "cloud.attachFrame: the window never became ready")), await R(q(e.ready(), je, "cloud.attachFrame: the window never became ready")), n !== void 0 && await R(ye(e, n)), A("attached frame", b.signal);
386
+ let o = Ee({
367
387
  control: e,
368
- target: a,
369
- session: p,
370
- declaredHosts: m,
371
- approvedOrigins: h,
372
- attach: f,
373
- assertLive: E,
374
- guard: D,
388
+ target: s,
389
+ session: m,
390
+ declaredHosts: h,
391
+ approvedOrigins: g,
392
+ attach: p,
393
+ assertLive: D,
394
+ guard: O,
375
395
  consent: {
376
- request: (t) => D(() => e.requestConsent(t)),
377
- ensure: (t) => D(() => e.requestConsent([t])).then(([e]) => e !== void 0 && e !== !1)
396
+ request: (t) => O(() => e.requestConsent(t)),
397
+ ensure: (t) => O(() => e.requestConsent([t])).then(([e]) => e !== void 0 && e !== !1)
378
398
  },
379
399
  onNavigated: () => {},
380
- relay: Y({
381
- from: () => _,
382
- origin: d,
383
- attach: f,
384
- signal: y.signal
400
+ relay: we({
401
+ from: () => y,
402
+ origin: f,
403
+ attach: p,
404
+ signal: b.signal
385
405
  })
386
- }), s = null, c = Object.assign(o, {
387
- close: () => s ??= (async () => {
388
- y.signal.aborted || await U(Promise.allSettled([D(() => e.flushCookies()), D(() => e.sweepStorage())]), ke, "close").catch(() => {});
406
+ }), c = null, u = Object.assign(o, {
407
+ close: () => c ??= (async () => {
408
+ b.signal.aborted || await q(Promise.allSettled([O(() => e.flushCookies()), O(() => e.sweepStorage())]), Fe, "close").catch(() => {});
389
409
  try {
390
- _.close();
410
+ y.close();
391
411
  } catch {}
392
- S(Z());
412
+ C(Z());
393
413
  })(),
394
- closed: T
414
+ closed: E
395
415
  });
396
- return n !== void 0 && a && await N(c.goto(a)), i?.length && await N(c.requestPermissions(i)), c;
416
+ return N ? P(u, N) : j.then((e) => P(u, e)), n !== void 0 && s && await R(u.goto(s)), i?.length && await R(u.requestPermissions(i)), u;
397
417
  } catch (e) {
398
- let t = x ?? e;
418
+ let t = S ?? e;
399
419
  if (!(t instanceof o)) try {
400
- _.close();
420
+ y.close();
401
421
  } catch {}
402
- throw S(t), t;
422
+ throw C(t), t;
403
423
  }
404
- }, Re = 2e4, Q = 65e3, ze = (e) => !e || e === "about:blank", Be = "cloud.attachFrame: this FKN page predates blank pages; reload the app to load the current one", Ve = "cloud.attachFrame: cookies: 'native' needs the FKN browser extension; the cloud render proxy has no browser cookies", He = (e) => e.split("#")[0] ?? "", Ue = ({ iframe: e, lockdown: t, cookies: n, blank: r }) => {
424
+ }, We = 2e4, Q = 65e3, $ = (e) => !e || e === "about:blank", Ge = "cloud.attachFrame: this FKN page predates blank pages; reload the app to load the current one", Ke = "cloud.attachFrame: cookies: 'native' needs the FKN browser extension; the cloud render proxy has no browser cookies", qe = (e) => e.split("#")[0] ?? "", Je = ({ iframe: e, lockdown: t, cookies: n, blank: r }) => {
405
425
  if (r === void 0) return "";
406
426
  if (typeof r != "object" || !r) throw TypeError("attachFrame: blank must be an object { url }");
407
427
  let i = Object.keys(r).find((e) => e !== "url");
@@ -415,15 +435,15 @@ var se = async () => {
415
435
  })();
416
436
  if (!o || o.protocol !== "http:" && o.protocol !== "https:") throw TypeError(`attachFrame: blank.url must be an absolute http or https url, not "${String(a)}"`);
417
437
  let s = e.getAttribute("src") ?? "";
418
- if (!ze(s)) throw TypeError(`attachFrame: blank needs an iframe with no src; this one has "${s}"`);
438
+ if (!$(s)) throw TypeError(`attachFrame: blank needs an iframe with no src; this one has "${s}"`);
419
439
  if (t) throw TypeError("attachFrame: blank does not combine with lockdown");
420
440
  if (n === "native") throw TypeError("attachFrame: blank runs on the cloud render proxy, which has no browser cookies; pass cookies: 'persistent' or 'ephemeral'");
421
- if (b(o.href), !et()) throw Error("attachFrame: a blank page is served by the cloud render proxy, which this build does not configure");
441
+ if (b(o.href), !at()) throw Error("attachFrame: a blank page is served by the cloud render proxy, which this build does not configure");
422
442
  return o.href;
423
- }, We = ({ target: e, blank: t, session: n, domains: r, attach: i }) => {
424
- let a = new URL("/attach-frame", V());
425
- 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;
426
- }, Ge = (e, t) => {
443
+ }, Ye = ({ target: e, blank: t, session: n, domains: r, attach: i, relay: a }) => {
444
+ let o = new URL("/attach-frame", G());
445
+ return t ? o.searchParams.set("blank", t) : e && o.searchParams.set("url", e), n && o.searchParams.set("session", n), r.length && o.searchParams.set("domains", r.join(",")), o.searchParams.set("attach", i), a && o.searchParams.set("relay", a), o.href;
446
+ }, Xe = (e, t) => {
427
447
  let n = () => {
428
448
  a(), t();
429
449
  }, r = e.parentNode, i = new MutationObserver(() => {
@@ -432,14 +452,14 @@ var se = async () => {
432
452
  window.removeEventListener("pagehide", n), i.disconnect();
433
453
  };
434
454
  window.addEventListener("pagehide", n, { once: !0 }), r && i.observe(r, { childList: !0 }), e.isConnected || (a(), t());
435
- }, Ke = () => W("cloud.attachFrame: the attached iframe left the document or was reloaded; attach a fresh iframe"), qe = (e, t) => {
455
+ }, Ze = () => J("cloud.attachFrame: the attached iframe left the document or was reloaded; attach a fresh iframe"), Qe = (e, t) => {
436
456
  let n = [...e.split(";"), ...t.split(";")].map((e) => e.trim()).filter(Boolean);
437
457
  return [...new Set(n)].join("; ");
438
- }, Je = [
458
+ }, $e = [
439
459
  300,
440
460
  1200,
441
461
  4e3
442
- ], Ye = (e) => {
462
+ ], et = (e) => {
443
463
  let t = () => {
444
464
  if (!e.isConnected) return;
445
465
  let t = e.style.height, n = e.getBoundingClientRect();
@@ -448,88 +468,89 @@ var se = async () => {
448
468
  }, 50));
449
469
  };
450
470
  t();
451
- for (let e of Je) setTimeout(t, e);
452
- }, Xe = (e) => {
471
+ for (let e of $e) setTimeout(t, e);
472
+ }, tt = (e) => {
453
473
  let t = e.getAttribute("sandbox");
454
474
  if (t === null) return;
455
475
  let n = new Set(t.toLowerCase().split(/\s+/).filter(Boolean)), r = ["allow-scripts", "allow-same-origin"].filter((e) => !n.has(e));
456
476
  if (r.length) throw Error(`cloud.attachFrame: the iframe's sandbox attribute must include ${r.join(" and ")} for the render proxy to load`);
457
- }, Ze = async (e, t) => {
458
- let n = typeof e.blank == "function" ? await U(e.blank(), Q, "cloud.attachFrame: the render proxy never became ready") : "";
459
- if (typeof n != "string" || He(n) !== He(t)) throw r(Be, "blank", "cloud");
460
- }, Qe = async (e, t, n) => {
461
- let r = Ue(e), { iframe: i, domains: a = [], permissions: o } = e;
477
+ }, nt = async (e, t) => {
478
+ let n = typeof e.blank == "function" ? await q(e.blank(), Q, "cloud.attachFrame: the render proxy never became ready") : "";
479
+ if (typeof n != "string" || qe(n) !== qe(t)) throw r(Ge, "blank", "cloud");
480
+ }, rt = async (e, t, n) => {
481
+ let r = Je(e), { iframe: i, domains: a = [], permissions: o, relay: s } = e;
462
482
  if (typeof window > "u") throw Error("cloud.attachFrame needs a window realm");
463
483
  if (!i.isConnected) throw Error("cloud.attachFrame: the iframe must be connected to the document before attaching");
464
- Xe(i);
465
- let s = i.getAttribute("src") ?? "", c = (() => {
466
- if (ze(s)) return null;
484
+ tt(i);
485
+ let c = i.getAttribute("src") ?? "", u = (() => {
486
+ if ($(c)) return null;
467
487
  try {
468
- return new URL(i.src || s, location.href);
488
+ return new URL(i.src || c, location.href);
469
489
  } catch {
470
- throw Error(`cloud.attachFrame: the iframe src is not a valid URL: ${s}`);
490
+ throw Error(`cloud.attachFrame: the iframe src is not a valid URL: ${c}`);
471
491
  }
472
492
  })();
473
- if (c) {
474
- let e = new URL("/attach-frame", V());
475
- if (c.origin === e.origin && c.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");
493
+ if (u) {
494
+ let e = new URL("/attach-frame", G());
495
+ if (u.origin === e.origin && u.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");
476
496
  }
477
- let u = c?.href ?? "";
478
- u && b(u);
479
- let d = n === void 0 ? u : "", f = H(t), p = w(a), m = /* @__PURE__ */ new Set();
497
+ let d = u?.href ?? "";
498
+ d && b(d);
499
+ let f = n === void 0 ? d : "", p = K(t), m = w(a), h = /* @__PURE__ */ new Set();
480
500
  try {
481
- m.add(new URL(r || u).origin);
501
+ h.add(new URL(r || d).origin);
482
502
  } catch {}
483
- let h = new AbortController(), g = i.referrerPolicy, _ = i.allow, v = crypto.randomUUID();
484
- if (i.referrerPolicy = "origin", i.allow = qe(E(), i.allow), i.src = We({
485
- target: d,
503
+ let g = De(s), _ = s === void 0 ? void 0 : await g, v = new AbortController(), y = i.referrerPolicy, x = i.allow, S = crypto.randomUUID();
504
+ if (i.referrerPolicy = "origin", i.allow = Qe(E(), i.allow), i.src = Ye({
505
+ target: f,
486
506
  blank: r,
487
- session: f,
488
- domains: p,
489
- attach: v
507
+ session: p,
508
+ domains: m,
509
+ attach: S,
510
+ relay: _
490
511
  }), !i.contentWindow) throw Error("cloud.attachFrame: the iframe window is not available");
491
512
  try {
492
- let e = await U(F({}, {
493
- key: N,
494
- origin: V(),
513
+ let e = await q(z({}, {
514
+ key: j,
515
+ origin: G(),
495
516
  transport: {
496
517
  receive: window,
497
518
  emit: i.contentWindow
498
519
  },
499
- unregisterSignal: h.signal,
500
- revivableModules: B(l)
501
- }), Re, "cloud.attachFrame: timed out connecting to the render proxy page");
502
- await U(e.ready(), Q, "cloud.attachFrame: the render proxy never became ready"), r && await Ze(e, r), n !== void 0 && await q(e, n), (u || r) && Ye(i), Ge(i, () => h.abort()), A("attached frame", h.signal);
503
- let t = i.contentWindow, a = X({
520
+ unregisterSignal: v.signal,
521
+ revivableModules: W(l)
522
+ }), We, "cloud.attachFrame: timed out connecting to the render proxy page");
523
+ _ && await q(Oe(e, _), Q, "cloud.attachFrame: the render proxy never became ready"), await q(e.ready(), Q, "cloud.attachFrame: the render proxy never became ready"), r && await nt(e, r), n !== void 0 && await ye(e, n), (d || r) && et(i), Xe(i, () => v.abort()), A("attached frame", v.signal);
524
+ let t = i.contentWindow, a = Ee({
504
525
  control: e,
505
- target: r || u,
526
+ target: r || d,
506
527
  blank: r !== "",
507
- session: f,
508
- declaredHosts: p,
509
- approvedOrigins: m,
510
- attach: v,
528
+ session: p,
529
+ declaredHosts: m,
530
+ approvedOrigins: h,
531
+ attach: S,
511
532
  assertLive: () => {
512
- if (h.signal.aborted || !i.isConnected || i.contentWindow !== t) throw h.abort(), Ke();
533
+ if (v.signal.aborted || !i.isConnected || i.contentWindow !== t) throw v.abort(), Ze();
513
534
  },
514
535
  guard: (e) => e(),
515
536
  consent: se,
516
- onNavigated: () => Ye(i),
517
- relay: Y({
537
+ onNavigated: () => et(i),
538
+ relay: we({
518
539
  from: () => t,
519
- origin: V(),
520
- attach: v,
521
- signal: h.signal
540
+ origin: G(),
541
+ attach: S,
542
+ signal: v.signal
522
543
  })
523
544
  });
524
- return n !== void 0 && u && await a.goto(u), o?.length && await a.requestPermissions(o), a;
545
+ return _ ? P(a, _) : g.then((e) => P(a, e)), n !== void 0 && d && await a.goto(d), o?.length && await a.requestPermissions(o), a;
525
546
  } catch (e) {
526
- throw h.abort(), i.referrerPolicy = g, i.allow = _, i.src = d || "about:blank", e;
547
+ throw v.abort(), i.referrerPolicy = y, i.allow = x, i.src = f || "about:blank", e;
527
548
  }
528
- }, $e = (async (e) => {
549
+ }, it = (async (e) => {
529
550
  let { kind: t, cookies: n, storageState: r } = g(e);
530
- if (n === "native") throw TypeError(Ve);
531
- return t === "window" ? Le(e, n, r) : Qe(e, n, r);
532
- }), et = () => typeof window < "u" && !0, tt = async () => {
551
+ if (n === "native") throw TypeError(Ke);
552
+ return t === "window" ? Ue(e, n, r) : rt(e, n, r);
553
+ }), at = () => typeof window < "u" && !0, ot = async () => {
533
554
  let e = await O.then((e) => e.cloud.quota());
534
555
  return {
535
556
  premium: e.premium,
@@ -541,16 +562,16 @@ var se = async () => {
541
562
  bytesPerSecond: e.bytesPerSecond,
542
563
  bitsPerSecond: e.bytesPerSecond * 8
543
564
  };
544
- }, nt = /* @__PURE__ */ e({
545
- attachFrame: () => $e,
546
- available: () => $,
565
+ }, st = /* @__PURE__ */ e({
566
+ attachFrame: () => it,
567
+ available: () => ct,
547
568
  dgram: () => ae,
548
569
  dns: () => ne,
549
- fetch: () => j,
570
+ fetch: () => L,
550
571
  fs: () => re,
551
572
  http: () => oe,
552
573
  net: () => ie,
553
- quota: () => tt
554
- }), $ = () => T;
574
+ quota: () => ot
575
+ }), ct = () => T;
555
576
  //#endregion
556
- export { Ue as a, $e as i, nt as n, tt as r, $ as t };
577
+ export { Je as a, it as i, st as n, ot as r, ct as t };