@fkn/lib 0.9.39 → 0.9.40

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