@fkn/lib 0.9.35 → 0.9.36

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 (43) hide show
  1. package/{api-CfmRAze5.d.ts → api-CaFuvyyV.d.ts} +1 -1
  2. package/api.d.ts +2 -2
  3. package/attach-policy.cjs +1 -1
  4. package/attach-policy.js +1 -1
  5. package/cloud/dns.d.ts +1 -1
  6. package/cloud/fetch.d.ts +1 -1
  7. package/cloud/net.d.ts +1 -1
  8. package/{cloud-B9Sd7V1g.js → cloud-CDRoRstb.js} +189 -183
  9. package/{cloud-DxitkM7z.d.ts → cloud-Cqdq7Ujd.d.ts} +3 -3
  10. package/cloud-DG_-Rt-L.cjs +1 -0
  11. package/cloud.cjs +1 -1
  12. package/cloud.d.ts +3 -3
  13. package/cloud.js +1 -1
  14. package/{contract-D37GGkou.d.ts → contract-BIHGp6cz.d.ts} +2 -2
  15. package/contract.d.ts +1 -1
  16. package/dgram.d.ts +2 -2
  17. package/dns.d.ts +1 -1
  18. package/{extension-TRYu_aG-.d.ts → extension-C9BRlqEY.d.ts} +2 -2
  19. package/extension-DisWHU7m.cjs +1 -0
  20. package/extension-jDvl0U_P.js +89 -0
  21. package/extension.cjs +1 -1
  22. package/extension.d.ts +2 -2
  23. package/extension.js +3 -3
  24. package/{hosts-C4-8lWwz.js → hosts-77UAJbm1.js} +28 -18
  25. package/hosts-COiOMjp-.cjs +1 -0
  26. package/http.d.ts +1 -1
  27. package/{index-C_Lqta5o.d.ts → index-BWJSnpRB.d.ts} +56 -5
  28. package/index.cjs +1 -1
  29. package/index.d.ts +8 -5
  30. package/index.js +12 -12
  31. package/lib-DCPdYk-N.cjs +53 -0
  32. package/{lib-B-jGWfsv.js → lib-hd9k5xOX.js} +389 -365
  33. package/{net-0SlODFSM.d.ts → net-BWFTx3k_.d.ts} +2 -2
  34. package/net.d.ts +1 -1
  35. package/package.json +1 -1
  36. package/packages.d.ts +1 -1
  37. package/{proxy-Bmb2wxG1.d.ts → proxy-DaljzPSa.d.ts} +2 -2
  38. package/rooms.d.ts +1 -1
  39. package/cloud-DCWD_0sd.cjs +0 -1
  40. package/extension-DJQ0oYdk.js +0 -89
  41. package/extension-DSrUjoLw.cjs +0 -1
  42. package/hosts-DD4rDeQH.cjs +0 -1
  43. package/lib-Cjd91q7g.cjs +0 -53
@@ -1,20 +1,20 @@
1
1
  import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
2
- import { b as t, c as n, d as r, et as i, f as a, g as o, l as s, m as c, o as l, s as u, u as d, w as f, x as p } from "./lib-B-jGWfsv.js";
3
- import { f as m, s as h, t as g } from "./hosts-C4-8lWwz.js";
4
- import { a as _, c as v, n as y, o as b } from "./api-CtiKFcK3.js";
5
- import { t as x } from "./busy-B189uX--.js";
6
- import { t as S } from "./proxy-DDwY3AVG.js";
7
- import { frameFetchVerdict as C } from "./attach-policy.js";
8
- import { ATTACH_FRAME_KEY as w, ATTACH_WINDOW_KEY as T, ATTACH_WINDOW_MESSAGE as E, WINDOW_HANDSHAKE_TIMEOUT_MS as ee } from "./contract.js";
9
- import { t as D } from "./dns.js";
10
- import { t as O } from "./cloud/fs.js";
11
- import { t as k } from "./net.js";
12
- import { t as A } from "./dgram.js";
13
- import { t as j } from "./http.js";
14
- import { expose as M } from "osra";
2
+ import { C as t, T as n, b as r, c as i, d as a, f as o, g as s, l as c, m as l, o as u, s as d, tt as f, u as p, x as m } from "./lib-hd9k5xOX.js";
3
+ import { c as h, p as g, t as _ } from "./hosts-77UAJbm1.js";
4
+ import { a as v, c as y, n as b, o as x } from "./api-CtiKFcK3.js";
5
+ import { t as S } from "./busy-B189uX--.js";
6
+ import { t as C } from "./proxy-DDwY3AVG.js";
7
+ import { frameFetchVerdict as w } from "./attach-policy.js";
8
+ import { ATTACH_FRAME_KEY as T, ATTACH_WINDOW_KEY as E, ATTACH_WINDOW_MESSAGE as D, WINDOW_HANDSHAKE_TIMEOUT_MS as ee } from "./contract.js";
9
+ import { t as O } from "./dns.js";
10
+ import { t as k } from "./cloud/fs.js";
11
+ import { t as A } from "./net.js";
12
+ import { t as j } from "./dgram.js";
13
+ import { t as M } from "./http.js";
14
+ import { expose as N } from "osra";
15
15
  //#region src/cloud/frame-broker.ts
16
- var N = async () => {
17
- let e = () => b("frame consent");
16
+ var P = async () => {
17
+ let e = () => x("frame consent");
18
18
  try {
19
19
  let t = await e();
20
20
  return {
@@ -22,112 +22,112 @@ var N = async () => {
22
22
  ensure: t.frameConsent.ensure
23
23
  };
24
24
  } catch (t) {
25
- if (!(t instanceof y)) throw t;
25
+ if (!(t instanceof b)) throw t;
26
26
  return {
27
27
  request: void 0,
28
28
  ensure: (t) => e().then((e) => e.frameConsent.ensure(t))
29
29
  };
30
30
  }
31
- }, P = "frame: this frame no longer holds the document the app attached it to", F = !1, te = () => {
32
- F || (F = !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
- }, ne = (e) => [...e].flatMap((e) => {
31
+ }, F = 3e4, te = () => t(`frame.evaluate: the code did not settle within ${F}ms`, "evaluate"), ne = "frame: this frame no longer holds the document the app attached it to", I = !1, re = () => {
32
+ I || (I = !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
+ }, ie = (e) => [...e].flatMap((e) => {
34
34
  try {
35
35
  return [new URL(e).hostname];
36
36
  } catch {
37
37
  return [];
38
38
  }
39
- }), I = (e, t, n) => n === null ? `frame.${e}: the user did not grant ${t} here` : `frame.${e}: the user did not grant ${t} on ${n}`, re = (e) => {
40
- let { assertLive: t, attach: r, current: i, declaredHosts: a, documentHost: o, ensure: c, request: l, session: u, approvedOrigins: p } = e, _ = /* @__PURE__ */ new Set(), v = async () => o ? await o() : (() => {
39
+ }), L = (e, t, n) => n === null ? `frame.${e}: the user did not grant ${t} here` : `frame.${e}: the user did not grant ${t} on ${n}`, ae = (e) => {
40
+ let { assertLive: t, attach: r, current: a, declaredHosts: o, documentHost: s, ensure: l, request: u, session: d, approvedOrigins: f } = e, m = /* @__PURE__ */ new Set(), v = async () => s ? await s() : (() => {
41
41
  try {
42
- return new URL(i()).hostname;
42
+ return new URL(a()).hostname;
43
43
  } catch {
44
44
  return "";
45
45
  }
46
- })(), y = () => g([...a, ...ne(p)]), b = async (e) => (await l([e]))[0] ?? !1;
46
+ })(), y = () => _([...o, ...ie(f)]), b = async (e) => (await u([e]))[0] ?? !1;
47
47
  return {
48
- gate: async ({ operation: e, args: n, phase: i }) => {
48
+ gate: async ({ operation: e, args: i, phase: a }) => {
49
49
  t();
50
- let o = m(e, n);
51
- if (o === null) return;
52
- let x = d(o);
50
+ let s = g(e, i);
51
+ if (s === null) return;
52
+ let x = p(s);
53
53
  if (x === void 0 || x === "auto") return;
54
54
  if (e === "fetch") {
55
- let e = C({
56
- session: u,
57
- declaredHosts: a,
58
- approvedOrigins: p
59
- }, i === "ensure" ? void 0 : n[0], { classifier: "fetchTarget" });
60
- if (i === "ensure" && !u) throw f(e.kind === "refuse" ? e.reason : "", "fetch");
61
- if (i !== "ensure" && e.kind === "refuse") throw f(e.reason, "fetch");
62
- if (!l) {
63
- if (e.kind === "refuse") throw f(e.reason, "fetch");
64
- if (!await c({
65
- scope: h(n[0], n[1]).scope,
55
+ let e = w({
56
+ session: d,
57
+ declaredHosts: o,
58
+ approvedOrigins: f
59
+ }, a === "ensure" ? void 0 : i[0], { classifier: "fetchTarget" });
60
+ if (a === "ensure" && !d) throw n(e.kind === "refuse" ? e.reason : "", "fetch");
61
+ if (a !== "ensure" && e.kind === "refuse") throw n(e.reason, "fetch");
62
+ if (!u) {
63
+ if (e.kind === "refuse") throw n(e.reason, "fetch");
64
+ if (!await l({
65
+ scope: h(i[0], i[1]).scope,
66
66
  hosts: e.promptHosts
67
- })) throw f("frame.fetch: the user did not grant this", "fetch");
67
+ })) throw n("frame.fetch: the user did not grant this", "fetch");
68
68
  return;
69
69
  }
70
- let t = e.kind === "consent" ? e.targetHost : await v(), r = g([t, ...a]);
71
- if (!r.length) throw f("frame: navigate the frame before fetch", "fetch");
70
+ let t = e.kind === "consent" ? e.targetHost : await v(), r = _([t, ...o]);
71
+ if (!r.length) throw n("frame: navigate the frame before fetch", "fetch");
72
72
  if (await b({
73
73
  category: "network",
74
74
  hosts: r
75
- }) === !1) throw f(I("fetch", "network", t || null), "fetch");
75
+ }) === !1) throw n(L("fetch", "network", t || null), "fetch");
76
76
  return;
77
77
  }
78
78
  let S = await v();
79
- if (!S) throw f(`frame: navigate the frame before ${e}`, e);
80
- if (!y().includes(S)) throw f(P, e);
81
- if (!l) return;
82
- let w = s(o);
83
- if (w === void 0 || x === "critical" && _.has(`${o} ${S}`)) return;
84
- let T = g([S, ...a]), E = await b(x === "critical" ? {
85
- key: o,
79
+ if (!S) throw n(`frame: navigate the frame before ${e}`, e);
80
+ if (!y().includes(S)) throw n(ne, e);
81
+ if (!u) return;
82
+ let C = c(s);
83
+ if (C === void 0 || x === "critical" && m.has(`${s} ${S}`)) return;
84
+ let T = _([S, ...o]), E = await b(x === "critical" ? {
85
+ key: s,
86
86
  hosts: T,
87
87
  attach: r
88
88
  } : {
89
- category: w,
89
+ category: C,
90
90
  hosts: T
91
91
  });
92
- if (E === !1) throw f(I(e, w, null), e);
93
- if (E === "once" && i !== "ensure") for (let e of T) _.add(`${o} ${e}`);
92
+ if (E === !1) throw n(L(e, C, null), e);
93
+ if (E === "once" && a !== "ensure") for (let e of T) m.add(`${s} ${e}`);
94
94
  },
95
95
  requestCategories: async (e) => {
96
96
  t();
97
- let i = await v(), o = g(i ? [i, ...a] : a);
98
- if (!o.length) throw TypeError("frame.request: navigate the frame or declare domains first");
97
+ let n = await v(), a = _(n ? [n, ...o] : o);
98
+ if (!a.length) throw TypeError("frame.request: navigate the frame or declare domains first");
99
99
  let s = e.map((e) => {
100
100
  let t = e.key;
101
101
  return {
102
102
  named: t,
103
- critical: t !== void 0 && d(t) === "critical",
104
- category: e.category ?? (t === void 0 ? void 0 : n(t)) ?? "interaction"
103
+ critical: t !== void 0 && p(t) === "critical",
104
+ category: e.category ?? (t === void 0 ? void 0 : i(t)) ?? "interaction"
105
105
  };
106
106
  }), c = ({ named: e, critical: t, category: n }, r) => ({
107
107
  category: n,
108
108
  ...t ? { key: e } : {},
109
- hosts: o,
109
+ hosts: a,
110
110
  allow: r
111
111
  });
112
- if (!l) return te(), s.map((e) => c(e, !1));
113
- let u = await l(s.map(({ named: e, critical: t, category: n }) => t ? {
112
+ if (!u) return re(), s.map((e) => c(e, !1));
113
+ let l = await u(s.map(({ named: e, critical: t, category: n }) => t ? {
114
114
  key: e,
115
- hosts: o,
115
+ hosts: a,
116
116
  attach: r
117
117
  } : {
118
118
  category: n,
119
- hosts: o
119
+ hosts: a
120
120
  }));
121
- return s.map((e, t) => c(e, u[t] !== void 0 && u[t] !== !1));
121
+ return s.map((e, t) => c(e, l[t] !== void 0 && l[t] !== !1));
122
122
  }
123
123
  };
124
- }, L = (e) => e, ie = 5e3, ae = /* @__PURE__ */ new Set([]), R = () => "https://fkn.app", z = (e) => e ? "" : `incognito-${crypto.randomUUID()}`, B = (e, t, n) => {
124
+ }, R = (e) => e, oe = 5e3, se = /* @__PURE__ */ new Set([]), z = () => "https://fkn.app", B = (e) => e ? "" : `incognito-${crypto.randomUUID()}`, V = (e, t, n) => {
125
125
  let r, i = new Promise((e, i) => {
126
- r = setTimeout(() => i(Error(n)), t);
126
+ r = setTimeout(() => i(typeof n == "string" ? Error(n) : n()), t);
127
127
  });
128
128
  return Promise.race([e, i]).finally(() => clearTimeout(r));
129
- }, V = (e) => Object.assign(Error(e), { name: t }), H = ({ control: e, target: t, session: n, declaredHosts: r, approvedOrigins: i, attach: a, assertLive: o, guard: s, consent: l, onNavigated: u }) => {
130
- let d = t, { gate: f, requestCategories: m } = re({
129
+ }, H = (e) => Object.assign(Error(e), { name: r }), U = ({ control: e, target: t, session: n, declaredHosts: r, approvedOrigins: i, attach: a, assertLive: o, guard: s, consent: c, onNavigated: u }) => {
130
+ let d = t, { gate: f, requestCategories: p } = ae({
131
131
  session: n,
132
132
  declaredHosts: r,
133
133
  approvedOrigins: i,
@@ -135,15 +135,21 @@ var N = async () => {
135
135
  assertLive: o,
136
136
  documentHost: typeof e.documentHost == "function" ? () => s(() => e.documentHost()) : void 0,
137
137
  current: () => d,
138
- ...l
138
+ ...c
139
139
  });
140
- return c({
140
+ return l({
141
141
  executor: {
142
- execute: (t, n, r) => ae.has(n) ? Promise.reject(p(n, "cloud")) : (o(), s(() => e.executeLocator(t, n, r))),
142
+ execute: (t, n, r) => se.has(n) ? Promise.reject(m(n, "cloud")) : (o(), s(() => e.executeLocator(t, n, r))),
143
143
  highlight: async () => {}
144
144
  },
145
145
  gate: f,
146
- request: m,
146
+ request: p,
147
+ evaluate: async (t, n) => (o(), await f({
148
+ parts: [],
149
+ operation: "evaluate",
150
+ args: [t, n],
151
+ phase: "execute"
152
+ }), V(s(() => e.executeLocator([], "evaluate", [t, n])), F, te)),
147
153
  goto: async (t, n = {}) => {
148
154
  let r = new URL(t, location.href).href;
149
155
  o();
@@ -156,7 +162,7 @@ var N = async () => {
156
162
  })(), l = c !== "" && !i.has(c);
157
163
  l && i.add(c);
158
164
  try {
159
- await B(s(() => e.goto(r, n)), (a ?? 3e4) + ie, "cloud.attachFrame: the render proxy did not answer goto; the frame may have been detached or its page reloaded");
165
+ await V(s(() => e.goto(r, n)), (a ?? 3e4) + oe, "cloud.attachFrame: the render proxy did not answer goto; the frame may have been detached or its page reloaded");
160
166
  } catch (e) {
161
167
  throw l && i.delete(c), e;
162
168
  }
@@ -164,84 +170,84 @@ var N = async () => {
164
170
  },
165
171
  url: () => d
166
172
  });
167
- }, oe = 250, U = 500, W = 65e3, G = 2e3, K = 2e3, se = 2, ce = 2e3, le = 2e3, ue = ({ origin: e, target: t, session: n, domains: r, attach: i }) => {
173
+ }, W = 250, G = 500, K = 65e3, ce = 2e3, le = 2e3, ue = 2, q = 2e3, de = 2e3, fe = ({ origin: e, target: t, session: n, domains: r, attach: i }) => {
168
174
  let a = new URL("/attach-window", e);
169
175
  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;
170
- }, de = (e, t) => {
176
+ }, pe = (e, t) => {
171
177
  let n = document.createElement("iframe"), r = new URL("/attach-jar", e);
172
178
  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;
173
- }, fe = (e, t) => {
179
+ }, me = (e, t) => {
174
180
  let n = new MutationObserver(() => {
175
181
  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"));
176
182
  });
177
183
  e.parentNode && n.observe(e.parentNode, { childList: !0 }), n.observe(document.documentElement, { childList: !0 }), t.addEventListener("abort", () => n.disconnect(), { once: !0 });
178
- }, q = () => V("cloud.attachFrame: the attached window closed, reloaded or left the page FKN attached; attach a fresh window"), J = () => V("cloud.attachFrame: the attached window stopped answering; attach a fresh window"), pe = () => V("cloud.attachFrame: the window went away before it connected; attach a fresh window"), me = () => V("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"), he = async (e) => {
184
+ }, J = () => H("cloud.attachFrame: the attached window closed, reloaded or left the page FKN attached; attach a fresh window"), Y = () => H("cloud.attachFrame: the attached window stopped answering; attach a fresh window"), he = () => H("cloud.attachFrame: the window went away before it connected; attach a fresh window"), ge = () => H("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"), _e = async (e) => {
179
185
  if (typeof window > "u") throw Error("cloud.attachFrame needs a window realm");
180
- let { domains: t = [], syncCookies: n = !0, permissions: o } = e, { url: s, width: c, height: l } = u(e.window);
181
- if (window.origin === "null") throw new a("opaque-opener");
182
- let d = R(), f = crypto.randomUUID(), p = z(n), m = g(t), h = /* @__PURE__ */ new Set();
183
- s && h.add(new URL(s).origin);
184
- let _ = n ? de(d, f) : null, v = window.open(ue({
185
- origin: d,
186
- target: s,
186
+ let { domains: t = [], syncCookies: n = !0, permissions: r } = e, { url: i, width: s, height: c } = d(e.window);
187
+ if (window.origin === "null") throw new o("opaque-opener");
188
+ let l = z(), u = crypto.randomUUID(), p = B(n), m = _(t), h = /* @__PURE__ */ new Set();
189
+ i && h.add(new URL(i).origin);
190
+ let g = n ? pe(l, u) : null, v = window.open(fe({
191
+ origin: l,
192
+ target: i,
187
193
  session: p,
188
194
  domains: m,
189
- attach: f
190
- }), "_blank", `popup,width=${c},height=${l}`);
191
- if (!v) throw _?.remove(), new r();
192
- let y = new AbortController(), b = !1, S = null, C = (e, t = !1) => {
193
- if (S === null) {
194
- S = e, y.abort(t ? J() : q());
195
+ attach: u
196
+ }), "_blank", `popup,width=${s},height=${c}`);
197
+ if (!v) throw g?.remove(), new a();
198
+ let y = new AbortController(), b = !1, x = null, C = (e, t = !1) => {
199
+ if (x === null) {
200
+ x = e, y.abort(t ? Y() : J());
195
201
  try {
196
202
  v.closed || v.postMessage({
197
- type: E.detach,
198
- attach: f,
203
+ type: D.detach,
204
+ attach: u,
199
205
  ...t ? { unanswered: t } : {}
200
- }, d);
206
+ }, l);
201
207
  } catch {}
202
- _ && setTimeout(() => _.remove(), le);
208
+ g && setTimeout(() => g.remove(), de);
203
209
  }
204
210
  };
205
- _ && fe(_, y.signal);
211
+ g && me(g, y.signal);
206
212
  let w = new Promise((e, t) => {
207
213
  y.signal.addEventListener("abort", () => t(y.signal.reason), { once: !0 });
208
214
  });
209
215
  w.catch(() => {});
210
- let D = w.then(() => {}, () => {}), O = () => {
216
+ let T = w.then(() => {}, () => {}), O = () => {
211
217
  if (y.signal.aborted) throw y.signal.reason;
212
- }, k = (e) => y.signal.aborted ? Promise.reject(y.signal.reason) : Promise.race([e(), w]), A = (e) => e.source === v && e.origin === d;
218
+ }, k = (e) => y.signal.aborted ? Promise.reject(y.signal.reason) : Promise.race([e(), w]), A = (e) => e.source === v && e.origin === l;
213
219
  window.addEventListener("message", (e) => {
214
220
  if (!A(e)) return;
215
221
  let t = e.data;
216
- typeof t == "object" && t && t.attach === f && (t.type === E.refused ? C(new a(t.reason)) : t.type === E.gone && C(b ? q() : pe()));
217
- }, { signal: y.signal }), window.addEventListener("pagehide", () => C(q()), { signal: y.signal });
222
+ typeof t == "object" && t && t.attach === u && (t.type === D.refused ? C(new o(t.reason)) : t.type === D.gone && C(b ? J() : he()));
223
+ }, { signal: y.signal }), window.addEventListener("pagehide", () => C(J()), { signal: y.signal });
218
224
  let j = () => {
219
225
  try {
220
226
  v.postMessage({
221
- type: E.hello,
222
- attach: f
223
- }, d);
227
+ type: D.hello,
228
+ attach: u
229
+ }, l);
224
230
  } catch {}
225
231
  };
226
232
  j();
227
- let N = setInterval(j, oe), P = setInterval(() => {
228
- v.closed && C(b ? q() : me());
229
- }, U);
233
+ let M = setInterval(j, W), P = setInterval(() => {
234
+ v.closed && C(b ? J() : ge());
235
+ }, G);
230
236
  y.signal.addEventListener("abort", () => {
231
- clearInterval(N), clearInterval(P);
237
+ clearInterval(M), clearInterval(P);
232
238
  }, { once: !0 });
233
239
  let F = async (e) => {
234
240
  try {
235
241
  return await Promise.race([e, w]);
236
242
  } catch (e) {
237
- throw S ?? e;
243
+ throw x ?? e;
238
244
  }
239
245
  };
240
246
  try {
241
- let e = await F(B(M({}, {
242
- key: T,
247
+ let e = await F(V(N({}, {
248
+ key: E,
243
249
  transport: {
244
- emit: (e, t) => v.postMessage(e, d, t ?? []),
250
+ emit: (e, t) => v.postMessage(e, l, t ?? []),
245
251
  receive: (e) => {
246
252
  let t = (t) => {
247
253
  A(t) && e(t.data, {
@@ -253,26 +259,26 @@ var N = async () => {
253
259
  }
254
260
  },
255
261
  unregisterSignal: y.signal,
256
- revivableModules: L(i)
262
+ revivableModules: R(f)
257
263
  }), ee, "cloud.attachFrame: timed out connecting to the window"));
258
- b = !0, clearInterval(N);
264
+ b = !0, clearInterval(M);
259
265
  let t = 0, n = setInterval(() => {
260
- B(k(() => e.ping()), K, "ping").then(() => {
266
+ V(k(() => e.ping()), le, "ping").then(() => {
261
267
  t = 0;
262
268
  }, () => {
263
- y.signal.aborted || (document.visibilityState === "hidden" ? t = 0 : ++t >= se && C(J(), !0));
269
+ y.signal.aborted || (document.visibilityState === "hidden" ? t = 0 : ++t >= ue && C(Y(), !0));
264
270
  });
265
- }, G);
266
- y.signal.addEventListener("abort", () => clearInterval(n), { once: !0 }), await F(B(e.ready(), W, "cloud.attachFrame: the window never became ready"));
267
- let r = x("attached frame");
268
- y.signal.aborted ? r() : y.signal.addEventListener("abort", r, { once: !0 });
269
- let a = H({
271
+ }, ce);
272
+ y.signal.addEventListener("abort", () => clearInterval(n), { once: !0 }), await F(V(e.ready(), K, "cloud.attachFrame: the window never became ready"));
273
+ let a = S("attached frame");
274
+ y.signal.aborted ? a() : y.signal.addEventListener("abort", a, { once: !0 });
275
+ let o = U({
270
276
  control: e,
271
- target: s,
277
+ target: i,
272
278
  session: p,
273
279
  declaredHosts: m,
274
280
  approvedOrigins: h,
275
- attach: f,
281
+ attach: u,
276
282
  assertLive: O,
277
283
  guard: k,
278
284
  consent: {
@@ -280,29 +286,29 @@ var N = async () => {
280
286
  ensure: (t) => k(() => e.requestConsent([t])).then(([e]) => e !== void 0 && e !== !1)
281
287
  },
282
288
  onNavigated: () => {}
283
- }), c = null, l = () => c ??= (async () => {
284
- y.signal.aborted || await B(Promise.allSettled([k(() => e.flushCookies()), k(() => e.sweepStorage())]), ce, "close").catch(() => {});
289
+ }), s = null, c = () => s ??= (async () => {
290
+ y.signal.aborted || await V(Promise.allSettled([k(() => e.flushCookies()), k(() => e.sweepStorage())]), q, "close").catch(() => {});
285
291
  try {
286
292
  v.close();
287
293
  } catch {}
288
- C(q());
289
- })(), u = {
290
- ...a,
291
- close: l,
292
- closed: D
294
+ C(J());
295
+ })(), d = {
296
+ ...o,
297
+ close: c,
298
+ closed: T
293
299
  };
294
- return o?.length && await F(u.request(o)), u;
300
+ return r?.length && await F(d.request(r)), d;
295
301
  } catch (e) {
296
- let t = S ?? e;
297
- if (!(t instanceof a)) try {
302
+ let t = x ?? e;
303
+ if (!(t instanceof o)) try {
298
304
  v.close();
299
305
  } catch {}
300
306
  throw C(t), t;
301
307
  }
302
- }, ge = "autoplay; fullscreen; encrypted-media; picture-in-picture; clipboard-read; clipboard-write", _e = 2e4, ve = 65e3, ye = (e) => !e || e === "about:blank", be = ({ target: e, session: t, domains: n, attach: r }) => {
303
- let i = new URL("/attach-frame", R());
308
+ }, ve = "autoplay; fullscreen; encrypted-media; picture-in-picture; clipboard-read; clipboard-write", ye = 2e4, be = 65e3, xe = (e) => !e || e === "about:blank", Se = ({ target: e, session: t, domains: n, attach: r }) => {
309
+ let i = new URL("/attach-frame", z());
304
310
  return e && i.searchParams.set("url", e), t && i.searchParams.set("session", t), n.length && i.searchParams.set("domains", n.join(",")), i.searchParams.set("attach", r), i.href;
305
- }, xe = (e, t) => {
311
+ }, Ce = (e, t) => {
306
312
  let n = () => {
307
313
  a(), t();
308
314
  }, r = e.parentNode, i = new MutationObserver(() => {
@@ -311,10 +317,10 @@ var N = async () => {
311
317
  window.removeEventListener("pagehide", n), i.disconnect();
312
318
  };
313
319
  window.addEventListener("pagehide", n, { once: !0 }), r && i.observe(r, { childList: !0 }), e.isConnected || (a(), t());
314
- }, Se = () => V("cloud.attachFrame: the attached iframe left the document or was reloaded; attach a fresh iframe"), Ce = (e, t) => {
320
+ }, we = () => H("cloud.attachFrame: the attached iframe left the document or was reloaded; attach a fresh iframe"), Te = (e, t) => {
315
321
  let n = [...e.split(";"), ...t.split(";")].map((e) => e.trim()).filter(Boolean);
316
322
  return [...new Set(n)].join("; ");
317
- }, Y = [
323
+ }, Ee = [
318
324
  300,
319
325
  1200,
320
326
  4e3
@@ -327,76 +333,76 @@ var N = async () => {
327
333
  }, 50));
328
334
  };
329
335
  t();
330
- for (let e of Y) setTimeout(t, e);
331
- }, we = (e) => {
336
+ for (let e of Ee) setTimeout(t, e);
337
+ }, De = (e) => {
332
338
  let t = e.getAttribute("sandbox");
333
339
  if (t === null) return;
334
340
  let n = new Set(t.toLowerCase().split(/\s+/).filter(Boolean)), r = ["allow-scripts", "allow-same-origin"].filter((e) => !n.has(e));
335
341
  if (r.length) throw Error(`cloud.attachFrame: the iframe's sandbox attribute must include ${r.join(" and ")} for the render proxy to load`);
336
- }, Te = async ({ iframe: e, domains: t = [], syncCookies: n = !0, lockdown: r = !1, permissions: a }) => {
342
+ }, Oe = async ({ iframe: e, domains: t = [], syncCookies: n = !0, lockdown: r = !1, permissions: i }) => {
337
343
  if (typeof window > "u") throw Error("cloud.attachFrame needs a window realm");
338
344
  if (r) throw Error("cloud.attachFrame does not support lockdown; use the extension backend for a sealed frame");
339
345
  if (!e.isConnected) throw Error("cloud.attachFrame: the iframe must be connected to the document before attaching");
340
- we(e);
341
- let s = e.getAttribute("src") ?? "", c = (() => {
342
- if (ye(s)) return null;
346
+ De(e);
347
+ let a = e.getAttribute("src") ?? "", o = (() => {
348
+ if (xe(a)) return null;
343
349
  try {
344
- return new URL(e.src || s, location.href);
350
+ return new URL(e.src || a, location.href);
345
351
  } catch {
346
- throw Error(`cloud.attachFrame: the iframe src is not a valid URL: ${s}`);
352
+ throw Error(`cloud.attachFrame: the iframe src is not a valid URL: ${a}`);
347
353
  }
348
354
  })();
349
- if (c) {
350
- let e = new URL("/attach-frame", R());
351
- 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");
355
+ if (o) {
356
+ let e = new URL("/attach-frame", z());
357
+ if (o.origin === e.origin && o.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");
352
358
  }
353
- let l = c?.href ?? "";
354
- l && o(l);
355
- let u = z(n), d = g(t), f = /* @__PURE__ */ new Set();
359
+ let c = o?.href ?? "";
360
+ c && s(c);
361
+ let l = B(n), u = _(t), d = /* @__PURE__ */ new Set();
356
362
  try {
357
- f.add(new URL(l).origin);
363
+ d.add(new URL(c).origin);
358
364
  } catch {}
359
- let p = new AbortController(), m = e.referrerPolicy, h = e.allow, _ = crypto.randomUUID();
360
- if (e.referrerPolicy = "origin", e.allow = Ce(ge, e.allow), e.src = be({
361
- target: l,
362
- session: u,
363
- domains: d,
364
- attach: _
365
+ let p = new AbortController(), m = e.referrerPolicy, h = e.allow, g = crypto.randomUUID();
366
+ if (e.referrerPolicy = "origin", e.allow = Te(ve, e.allow), e.src = Se({
367
+ target: c,
368
+ session: l,
369
+ domains: u,
370
+ attach: g
365
371
  }), !e.contentWindow) throw Error("cloud.attachFrame: the iframe window is not available");
366
372
  try {
367
- let t = await B(M({}, {
368
- key: w,
369
- origin: R(),
373
+ let t = await V(N({}, {
374
+ key: T,
375
+ origin: z(),
370
376
  transport: {
371
377
  receive: window,
372
378
  emit: e.contentWindow
373
379
  },
374
380
  unregisterSignal: p.signal,
375
- revivableModules: L(i)
376
- }), _e, "cloud.attachFrame: timed out connecting to the render proxy page");
377
- await B(t.ready(), ve, "cloud.attachFrame: the render proxy never became ready"), l && X(e), xe(e, () => p.abort());
378
- let n = x("attached frame");
381
+ revivableModules: R(f)
382
+ }), ye, "cloud.attachFrame: timed out connecting to the render proxy page");
383
+ await V(t.ready(), be, "cloud.attachFrame: the render proxy never became ready"), c && X(e), Ce(e, () => p.abort());
384
+ let n = S("attached frame");
379
385
  p.signal.aborted ? n() : p.signal.addEventListener("abort", n, { once: !0 });
380
- let r = e.contentWindow, o = H({
386
+ let r = e.contentWindow, a = U({
381
387
  control: t,
382
- target: l,
383
- session: u,
384
- declaredHosts: d,
385
- approvedOrigins: f,
386
- attach: _,
388
+ target: c,
389
+ session: l,
390
+ declaredHosts: u,
391
+ approvedOrigins: d,
392
+ attach: g,
387
393
  assertLive: () => {
388
- if (p.signal.aborted || !e.isConnected || e.contentWindow !== r) throw p.abort(), Se();
394
+ if (p.signal.aborted || !e.isConnected || e.contentWindow !== r) throw p.abort(), we();
389
395
  },
390
396
  guard: (e) => e(),
391
- consent: await N(),
397
+ consent: await P(),
392
398
  onNavigated: () => X(e)
393
399
  });
394
- return a?.length && await o.request(a), o;
400
+ return i?.length && await a.request(i), a;
395
401
  } catch (t) {
396
- throw p.abort(), e.referrerPolicy = m, e.allow = h, e.src = l || "about:blank", t;
402
+ throw p.abort(), e.referrerPolicy = m, e.allow = h, e.src = c || "about:blank", t;
397
403
  }
398
- }, Z = (async (e) => l(e) === "window" ? he(e) : Te(e)), Ee = () => typeof window < "u" && !0, Q = async () => {
399
- let e = await _.then((e) => e.cloud.quota());
404
+ }, Z = (async (e) => u(e) === "window" ? _e(e) : Oe(e)), ke = () => typeof window < "u" && !0, Q = async () => {
405
+ let e = await v.then((e) => e.cloud.quota());
400
406
  return {
401
407
  premium: e.premium,
402
408
  overQuota: e.overQuota,
@@ -407,16 +413,16 @@ var N = async () => {
407
413
  bytesPerSecond: e.bytesPerSecond,
408
414
  bitsPerSecond: e.bytesPerSecond * 8
409
415
  };
410
- }, De = /* @__PURE__ */ e({
416
+ }, Ae = /* @__PURE__ */ e({
411
417
  attachFrame: () => Z,
412
418
  available: () => $,
413
- dgram: () => A,
414
- dns: () => D,
415
- fetch: () => S,
416
- fs: () => O,
417
- http: () => j,
418
- net: () => k,
419
+ dgram: () => j,
420
+ dns: () => O,
421
+ fetch: () => C,
422
+ fs: () => k,
423
+ http: () => M,
424
+ net: () => A,
419
425
  quota: () => Q
420
- }), $ = () => v;
426
+ }), $ = () => y;
421
427
  //#endregion
422
- export { Ee as a, Z as i, De as n, Q as r, $ as t };
428
+ export { ke as a, Z as i, Ae as n, Q as r, $ as t };
@@ -1,8 +1,8 @@
1
- import { r as AttachFrameFunction } from "./index-C_Lqta5o.js";
2
- import { t as cloudFetch } from "./proxy-Bmb2wxG1.js";
1
+ import { r as AttachFrameFunction } from "./index-BWJSnpRB.js";
2
+ import { t as cloudFetch } from "./proxy-DaljzPSa.js";
3
3
  import { t as dns_d_exports } from "./dns.js";
4
4
  import { n as fs_d_exports } from "./fs--NhtUyYa.js";
5
- import { s as net_d_exports } from "./net-0SlODFSM.js";
5
+ import { s as net_d_exports } from "./net-BWFTx3k_.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