@lumencast/runtime 0.10.0 → 0.11.0

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 (44) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/{broadcast-L5wm2I6J.js → broadcast-DtHoU_fS.js} +3 -3
  3. package/dist/{broadcast-L5wm2I6J.js.map → broadcast-DtHoU_fS.js.map} +1 -1
  4. package/dist/{control-eEUG7unp.js → control-B9frEbNG.js} +4 -4
  5. package/dist/{control-eEUG7unp.js.map → control-B9frEbNG.js.map} +1 -1
  6. package/dist/{index-Clrya_9l.js → index-Dz27r92m.js} +378 -332
  7. package/dist/index-Dz27r92m.js.map +1 -0
  8. package/dist/index.d.ts +1 -0
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.html +1 -1
  11. package/dist/index.js +5 -0
  12. package/dist/index.js.map +1 -1
  13. package/dist/lumencast.js +22 -18
  14. package/dist/mount.d.ts.map +1 -1
  15. package/dist/mount.js +11 -0
  16. package/dist/mount.js.map +1 -1
  17. package/dist/render/primitives/index.d.ts.map +1 -1
  18. package/dist/render/primitives/index.js +6 -0
  19. package/dist/render/primitives/index.js.map +1 -1
  20. package/dist/render/primitives/meet-peer-slot.d.ts +29 -0
  21. package/dist/render/primitives/meet-peer-slot.d.ts.map +1 -0
  22. package/dist/render/primitives/meet-peer-slot.js +46 -0
  23. package/dist/render/primitives/meet-peer-slot.js.map +1 -0
  24. package/dist/state/reserved-leaves.d.ts +37 -0
  25. package/dist/state/reserved-leaves.d.ts.map +1 -0
  26. package/dist/state/reserved-leaves.js +96 -0
  27. package/dist/state/reserved-leaves.js.map +1 -0
  28. package/dist/{status-pill-elORkMrh.js → status-pill-B2vBTwRC.js} +2 -2
  29. package/dist/{status-pill-elORkMrh.js.map → status-pill-B2vBTwRC.js.map} +1 -1
  30. package/dist/{test-7q_KJkdX.js → test-DD2SBDku.js} +4 -4
  31. package/dist/{test-7q_KJkdX.js.map → test-DD2SBDku.js.map} +1 -1
  32. package/dist/{tree-BMxx5170.js → tree-CgU_sUwI.js} +213 -197
  33. package/dist/tree-CgU_sUwI.js.map +1 -0
  34. package/dist/types.d.ts +12 -0
  35. package/dist/types.d.ts.map +1 -1
  36. package/package.json +4 -4
  37. package/src/index.ts +12 -0
  38. package/src/mount.ts +12 -0
  39. package/src/render/primitives/index.ts +6 -0
  40. package/src/render/primitives/meet-peer-slot.tsx +55 -0
  41. package/src/state/reserved-leaves.ts +121 -0
  42. package/src/types.ts +12 -0
  43. package/dist/index-Clrya_9l.js.map +0 -1
  44. package/dist/tree-BMxx5170.js.map +0 -1
@@ -1,84 +1,84 @@
1
- import { batch as T, signal as v } from "@preact/signals-react";
2
- import { createRoot as q } from "react-dom/client";
3
- import { createContext as te, useContext as W, lazy as E, Suspense as se, createElement as ne, StrictMode as re } from "react";
4
- import { jsx as m } from "react/jsx-runtime";
5
- import { useSignals as ie } from "@preact/signals-react/runtime";
6
- import { AnimatePresence as oe, motion as ae } from "framer-motion";
7
- import { SequenceTracker as ce, encodeFrame as O, input as le, WS_SUBPROTOCOLS as ue, WS_SUBPROTOCOL_V1_1 as de, subscribe as he, decodeServerFrame as fe, LumencastError as L } from "@lumencast/protocol";
8
- const I = te(null);
9
- function z({
1
+ import { batch as T, signal as w } from "@preact/signals-react";
2
+ import { createRoot as H } from "react-dom/client";
3
+ import { createContext as oe, useContext as G, lazy as _, Suspense as ae, createElement as ce, StrictMode as le } from "react";
4
+ import { jsx as f } from "react/jsx-runtime";
5
+ import { useSignals as ue } from "@preact/signals-react/runtime";
6
+ import { AnimatePresence as de, motion as he } from "framer-motion";
7
+ import { SequenceTracker as fe, encodeFrame as C, input as me, WS_SUBPROTOCOLS as pe, WS_SUBPROTOCOL_V1_1 as ge, subscribe as ve, decodeServerFrame as we, LumencastError as M } from "@lumencast/protocol";
8
+ const I = oe(null);
9
+ function X({
10
10
  value: t,
11
11
  children: e
12
12
  }) {
13
- return /* @__PURE__ */ m(I.Provider, { value: t, children: e });
13
+ return /* @__PURE__ */ f(I.Provider, { value: t, children: e });
14
14
  }
15
- function at() {
16
- const t = W(I);
15
+ function mt() {
16
+ const t = G(I);
17
17
  if (!t)
18
18
  throw new Error(
19
19
  "Lumencast overlay components must be rendered inside LumencastRuntimeProvider"
20
20
  );
21
21
  return t;
22
22
  }
23
- function ct() {
24
- return W(I);
23
+ function pt() {
24
+ return G(I);
25
25
  }
26
- const me = E(
27
- () => import("./broadcast-L5wm2I6J.js").then((t) => ({ default: t.BroadcastMode }))
28
- ), pe = E(
29
- () => import("./control-eEUG7unp.js").then((t) => ({ default: t.ControlMode }))
30
- ), ge = E(() => import("./test-7q_KJkdX.js").then((t) => ({ default: t.TestMode })));
31
- function ve({
26
+ const ye = _(
27
+ () => import("./broadcast-DtHoU_fS.js").then((t) => ({ default: t.BroadcastMode }))
28
+ ), be = _(
29
+ () => import("./control-B9frEbNG.js").then((t) => ({ default: t.ControlMode }))
30
+ ), Se = _(() => import("./test-DD2SBDku.js").then((t) => ({ default: t.TestMode })));
31
+ function ke({
32
32
  mode: t,
33
33
  store: e,
34
34
  bundleSignal: s,
35
35
  statusSignal: n,
36
36
  crossfadeKeySignal: r,
37
- sendInput: o,
37
+ sendInput: i,
38
38
  resolveCaptureDevice: a,
39
- resolvePeerStream: i,
40
- subscribePeerStream: l
39
+ resolvePeerStream: o,
40
+ subscribePeerStream: u
41
41
  }) {
42
- ie();
43
- const c = s.value, d = n.value, h = r.value;
42
+ ue();
43
+ const c = s.value, d = n.value, m = r.value;
44
44
  if (!c) return null;
45
- const w = t === "broadcast" ? me : t === "control" ? pe : ge;
46
- return /* @__PURE__ */ m(oe, { mode: "sync", children: /* @__PURE__ */ m(
47
- ae.div,
45
+ const p = t === "broadcast" ? ye : t === "control" ? be : Se;
46
+ return /* @__PURE__ */ f(de, { mode: "sync", children: /* @__PURE__ */ f(
47
+ he.div,
48
48
  {
49
49
  initial: { opacity: 0 },
50
50
  animate: { opacity: 1 },
51
51
  exit: { opacity: 0 },
52
52
  transition: { duration: 0.4, ease: "easeInOut" },
53
53
  style: { position: "absolute", inset: 0 },
54
- children: /* @__PURE__ */ m(
55
- z,
54
+ children: /* @__PURE__ */ f(
55
+ X,
56
56
  {
57
57
  value: {
58
58
  mode: t,
59
59
  store: e,
60
60
  bundle: c,
61
61
  status: d,
62
- sendInput: o,
62
+ sendInput: i,
63
63
  ...a !== void 0 ? { resolveCaptureDevice: a } : {},
64
- ...i !== void 0 ? { resolvePeerStream: i } : {},
65
- ...l !== void 0 ? { subscribePeerStream: l } : {}
64
+ ...o !== void 0 ? { resolvePeerStream: o } : {},
65
+ ...u !== void 0 ? { subscribePeerStream: u } : {}
66
66
  },
67
- children: /* @__PURE__ */ m(se, { fallback: null, children: /* @__PURE__ */ m(w, {}) })
67
+ children: /* @__PURE__ */ f(ae, { fallback: null, children: /* @__PURE__ */ f(p, {}) })
68
68
  }
69
69
  )
70
70
  },
71
- h
71
+ m
72
72
  ) });
73
73
  }
74
- const we = "<anon>", b = /* @__PURE__ */ new Set();
75
- function B(t) {
74
+ const Te = "<anon>", b = /* @__PURE__ */ new Set();
75
+ function V(t) {
76
76
  return b.add(t), () => {
77
77
  b.delete(t);
78
78
  };
79
79
  }
80
- function H(t, e, s) {
81
- const n = { nodeId: t ?? we, field: e, reason: s };
80
+ function K(t, e, s) {
81
+ const n = { nodeId: t ?? Te, field: e, reason: s };
82
82
  if (b.size > 0) {
83
83
  for (const r of b)
84
84
  try {
@@ -88,41 +88,41 @@ function H(t, e, s) {
88
88
  return;
89
89
  }
90
90
  }
91
- const ye = 100, be = 4, ke = 64, Se = {
92
- blur: ye,
93
- brightness: be
91
+ const Ee = 100, _e = 4, Ie = 64, Re = {
92
+ blur: Ee,
93
+ brightness: _e
94
94
  };
95
- function M(t, e) {
95
+ function N(t, e) {
96
96
  if (typeof e != "number" || !Number.isFinite(e) || e < 0 || Object.is(e, -0)) return null;
97
- const s = Se[t];
97
+ const s = Re[t];
98
98
  return e > s ? s : e;
99
99
  }
100
- const Te = /^blur\((\d{1,7}(?:\.\d{1,4})?)px\) brightness\((\d{1,7}(?:\.\d{1,4})?)\)$/, lt = "blur(0px) brightness(1)";
101
- function Ee(t) {
102
- if (typeof t != "string" || t.length === 0 || t.length > ke) return null;
103
- const e = Te.exec(t);
100
+ const Ae = /^blur\((\d{1,7}(?:\.\d{1,4})?)px\) brightness\((\d{1,7}(?:\.\d{1,4})?)\)$/, gt = "blur(0px) brightness(1)";
101
+ function Oe(t) {
102
+ if (typeof t != "string" || t.length === 0 || t.length > Ie) return null;
103
+ const e = Ae.exec(t);
104
104
  if (!e) return null;
105
- const s = M("blur", Number(e[1])), n = M("brightness", Number(e[2]));
105
+ const s = N("blur", Number(e[1])), n = N("brightness", Number(e[2]));
106
106
  return s === null || n === null ? null : `blur(${s}px) brightness(${n})`;
107
107
  }
108
- function Ie(t, e) {
109
- H(
108
+ function Pe(t, e) {
109
+ K(
110
110
  e,
111
111
  t,
112
112
  "rejected unsafe filter value : outside the R8 caps or not a finite number >= 0"
113
113
  );
114
114
  }
115
- const _e = { duration: 0 }, Re = {
115
+ const Le = { duration: 0 }, Ce = {
116
116
  linear: "linear",
117
117
  "cubic-in": "easeIn",
118
118
  "cubic-out": "easeOut",
119
119
  "cubic-in-out": "easeInOut"
120
120
  };
121
- function ut(t) {
122
- return !t || t.kind === "none" ? _e : t.kind === "tween" ? {
121
+ function vt(t) {
122
+ return !t || t.kind === "none" ? Le : t.kind === "tween" ? {
123
123
  type: "tween",
124
124
  duration: (t.duration_ms ?? 0) / 1e3,
125
- ease: t.ease ? Re[t.ease] ?? "easeOut" : "easeOut"
125
+ ease: t.ease ? Ce[t.ease] ?? "easeOut" : "easeOut"
126
126
  } : t.kind === "spring" ? {
127
127
  type: "spring",
128
128
  ...t.stiffness !== void 0 ? { stiffness: t.stiffness } : {},
@@ -134,7 +134,7 @@ function ut(t) {
134
134
  ease: "easeInOut"
135
135
  };
136
136
  }
137
- const Ae = {
137
+ const Me = {
138
138
  opacity: 1,
139
139
  scale: 1,
140
140
  scaleX: 1,
@@ -146,12 +146,12 @@ const Ae = {
146
146
  // framer interpolates between structurally-identical filter lists
147
147
  // (the compiler emits the same two-function form, clamped per R8).
148
148
  filter: "blur(0px) brightness(1)"
149
- }, Pe = {
149
+ }, Ne = {
150
150
  kind: "tween",
151
151
  duration_ms: 400,
152
152
  ease: "cubic-out"
153
153
  };
154
- function dt(t, e, s) {
154
+ function wt(t, e, s) {
155
155
  for (const n of e) {
156
156
  const r = t(n);
157
157
  if (r !== void 0) return r;
@@ -161,29 +161,29 @@ function dt(t, e, s) {
161
161
  const r = t(n);
162
162
  if (r !== void 0) return r;
163
163
  }
164
- return Pe;
164
+ return Ne;
165
165
  }
166
166
  }
167
- function ht(t, e, s) {
167
+ function yt(t, e, s) {
168
168
  if (!e || Object.keys(e).length === 0)
169
169
  return { initial: t, animate: t };
170
170
  let n = e;
171
171
  if (e.filter !== void 0) {
172
- const o = Ee(e.filter);
173
- n = { ...e }, o === null ? (Ie("animate_initial.filter", s), delete n.filter) : n.filter = o;
172
+ const i = Oe(e.filter);
173
+ n = { ...e }, i === null ? (Pe("animate_initial.filter", s), delete n.filter) : n.filter = i;
174
174
  }
175
175
  const r = { ...t };
176
- for (const o of Object.keys(n))
177
- o in r || (r[o] = Ae[o] ?? 0);
176
+ for (const i of Object.keys(n))
177
+ i in r || (r[i] = Me[i] ?? 0);
178
178
  return { initial: n, animate: r };
179
179
  }
180
- function Oe(t) {
180
+ function xe(t) {
181
181
  if (typeof t != "object" || t === null) return;
182
182
  const e = t, s = e.kind;
183
183
  if (s === "snap")
184
184
  return { kind: "none" };
185
185
  if (s === "tween") {
186
- const n = typeof e.duration_ms == "number" ? e.duration_ms : 0, r = Le[e.easing] ?? "cubic-out";
186
+ const n = typeof e.duration_ms == "number" ? e.duration_ms : 0, r = je[e.easing] ?? "cubic-out";
187
187
  return { kind: "tween", duration_ms: n, ease: r };
188
188
  }
189
189
  if (s === "spring") {
@@ -191,44 +191,86 @@ function Oe(t) {
191
191
  return typeof e.stiffness == "number" && (n.stiffness = e.stiffness), typeof e.damping == "number" && (n.damping = e.damping), typeof e.mass == "number" && (n.mass = e.mass), n;
192
192
  }
193
193
  }
194
- const Le = {
194
+ const je = {
195
195
  linear: "linear",
196
196
  "ease-in": "cubic-in",
197
197
  "ease-out": "cubic-out",
198
198
  "ease-in-out": "cubic-in-out"
199
199
  };
200
- function Me(t, e) {
200
+ function De(t, e) {
201
201
  T(() => {
202
202
  for (const s of e.patches) {
203
- const n = Oe(s.transition);
203
+ const n = xe(s.transition);
204
204
  n !== void 0 ? t.setWithTransition(s.path, s.value, n) : t.set(s.path, s.value);
205
205
  }
206
206
  });
207
207
  }
208
- function Ce(t, e) {
208
+ function Ue(t, e) {
209
209
  t.reset(e.state);
210
210
  }
211
- class Ne {
211
+ const bt = "__cam.", E = "__cam.slots.", J = "__cam.viewer";
212
+ function x(t) {
213
+ return t === J || t.startsWith(E);
214
+ }
215
+ function $e(t) {
216
+ const e = {};
217
+ let s;
218
+ for (const [n, r] of t)
219
+ if (n === J)
220
+ r != null && (s = r);
221
+ else if (n.startsWith(E)) {
222
+ const i = n.slice(E.length);
223
+ i !== "" && typeof r == "string" && r !== "" && (e[i] = r);
224
+ }
225
+ return s !== void 0 ? { viewer: s, slots: e } : { slots: e };
226
+ }
227
+ function j(t) {
228
+ const e = Object.keys(t.slots).sort().map((n) => `${n}=${t.slots[n]}`).join("&"), s = t.viewer === void 0 ? "" : JSON.stringify(t.viewer);
229
+ return `${e}|${s}`;
230
+ }
231
+ function Fe(t) {
232
+ const e = /* @__PURE__ */ new Map();
233
+ let s = j({ slots: {} });
234
+ const n = () => {
235
+ const r = $e(e), i = j(r);
236
+ i !== s && (s = i, t(r));
237
+ };
238
+ return {
239
+ onSnapshot(r) {
240
+ e.clear();
241
+ for (const [i, a] of Object.entries(r))
242
+ x(i) && e.set(i, a);
243
+ n();
244
+ },
245
+ onDelta(r) {
246
+ let i = !1;
247
+ for (const a of r)
248
+ x(a.path) && (e.set(a.path, a.value), i = !0);
249
+ i && n();
250
+ }
251
+ };
252
+ }
253
+ class We {
212
254
  signals = /* @__PURE__ */ new Map();
213
255
  transitions = /* @__PURE__ */ new Map();
214
256
  signal(e) {
215
257
  let s = this.signals.get(e);
216
- return s || (s = v(void 0), this.signals.set(e, s)), s;
258
+ return s || (s = w(void 0), this.signals.set(e, s)), s;
217
259
  }
218
260
  transitionSignal(e) {
219
261
  let s = this.transitions.get(e);
220
- return s || (s = v(void 0), this.transitions.set(e, s)), s;
262
+ return s || (s = w(void 0), this.transitions.set(e, s)), s;
221
263
  }
222
264
  set(e, s) {
223
265
  const n = this.signal(e);
224
- S(n.peek(), s) || (n.value = s);
266
+ k(n.peek(), s) || (n.value = s);
225
267
  }
226
268
  setWithTransition(e, s, n) {
227
269
  T(() => {
228
270
  const r = this.transitionSignal(e);
229
271
  r.peek() !== n && (r.value = n);
230
- const o = this.signal(e);
231
- S(o.peek(), s) || (o.value = s);
272
+ const i = this.signal(e);
273
+ k(i.peek(), s) || (i.value = s);
232
274
  });
233
275
  }
234
276
  reset(e) {
@@ -236,8 +278,8 @@ class Ne {
236
278
  const s = /* @__PURE__ */ new Set();
237
279
  for (const [n, r] of Object.entries(e)) {
238
280
  s.add(n);
239
- const o = this.signal(n);
240
- S(o.peek(), r) || (o.value = r);
281
+ const i = this.signal(n);
282
+ k(i.peek(), r) || (i.value = r);
241
283
  const a = this.transitions.get(n);
242
284
  a && a.peek() !== void 0 && (a.value = void 0);
243
285
  }
@@ -255,10 +297,10 @@ class Ne {
255
297
  return e;
256
298
  }
257
299
  }
258
- function G() {
259
- return new Ne();
300
+ function Y() {
301
+ return new We();
260
302
  }
261
- function S(t, e) {
303
+ function k(t, e) {
262
304
  if (t === e) return !0;
263
305
  if (t === null || e === null || typeof t != typeof e || typeof t != "object" || Array.isArray(t) !== Array.isArray(e)) return !1;
264
306
  if (Array.isArray(t) && Array.isArray(e)) {
@@ -267,26 +309,26 @@ function S(t, e) {
267
309
  if (t[a] !== e[a]) return !1;
268
310
  return !0;
269
311
  }
270
- const s = t, n = e, r = Object.keys(s), o = Object.keys(n);
271
- if (r.length !== o.length) return !1;
312
+ const s = t, n = e, r = Object.keys(s), i = Object.keys(n);
313
+ if (r.length !== i.length) return !1;
272
314
  for (const a of r)
273
315
  if (s[a] !== n[a]) return !1;
274
316
  return !0;
275
317
  }
276
- const xe = /* @__PURE__ */ new Set([
318
+ const qe = /* @__PURE__ */ new Set([
277
319
  "x-lumencast.color-srgb-1.0",
278
320
  // RFC-0001 / ADR 004 — this runtime ships the Zab capture plugin, so a
279
321
  // bundle declaring `x-zab.capture/1` in `profiles[]` is compatible (it is
280
322
  // NOT rejected as BUNDLE_INCOMPATIBLE, §17.3.1).
281
323
  "x-zab.capture/1"
282
- ]), je = /^x-[a-z0-9-]+(?:\.[a-z0-9-]+)*$/, De = /^(?:0|[1-9][0-9]*)$/, C = ".authoring";
283
- function Ue(t) {
324
+ ]), ze = /^x-[a-z0-9-]+(?:\.[a-z0-9-]+)*$/, Be = /^(?:0|[1-9][0-9]*)$/, D = ".authoring";
325
+ function He(t) {
284
326
  const e = t.indexOf("/");
285
327
  if (e < 0) return !1;
286
328
  const s = t.slice(0, e), n = t.slice(e + 1);
287
- return !De.test(n) || !s.endsWith(C) ? !1 : je.test(s.slice(0, -C.length));
329
+ return !Be.test(n) || !s.endsWith(D) ? !1 : ze.test(s.slice(0, -D.length));
288
330
  }
289
- class N extends Error {
331
+ class U extends Error {
290
332
  code = "BUNDLE_INCOMPATIBLE";
291
333
  unsupportedProfiles;
292
334
  constructor(e) {
@@ -297,17 +339,17 @@ class N extends Error {
297
339
  ), this.name = "BundleIncompatibleError", this.unsupportedProfiles = e;
298
340
  }
299
341
  }
300
- function x(t, e = xe) {
342
+ function $(t, e = qe) {
301
343
  const s = t.profiles;
302
344
  if (!s) return;
303
345
  if (!Array.isArray(s))
304
- throw new N(["<malformed: profiles is not an array>"]);
346
+ throw new U(["<malformed: profiles is not an array>"]);
305
347
  if (s.length === 0) return;
306
- const n = s.filter((r) => typeof r != "string" || !Ue(r) && !e.has(r)).map((r) => typeof r == "string" ? r : "<malformed: non-string profile entry>");
348
+ const n = s.filter((r) => typeof r != "string" || !He(r) && !e.has(r)).map((r) => typeof r == "string" ? r : "<malformed: non-string profile entry>");
307
349
  if (n.length > 0)
308
- throw new N(n);
350
+ throw new U(n);
309
351
  }
310
- class $e {
352
+ class Ge {
311
353
  cache = /* @__PURE__ */ new Map();
312
354
  baseUrl;
313
355
  pathPrefix;
@@ -330,24 +372,24 @@ class $e {
330
372
  return this.resolveUrl ? this.resolveUrl(e, s) : `${this.baseUrl}${this.pathPrefix}/${encodeURIComponent(e)}/bundle?v=${encodeURIComponent(s)}`;
331
373
  }
332
374
  preload(e) {
333
- x(e), this.cache.set(e.scene_version, e);
375
+ $(e), this.cache.set(e.scene_version, e);
334
376
  }
335
377
  async get(e, s) {
336
378
  const n = this.cache.get(s);
337
379
  if (n) return n;
338
- const r = this.buildUrl(e, s), o = await this.buildInit(), a = o ? await this.fetchImpl(r, o) : await this.fetchImpl(r);
380
+ const r = this.buildUrl(e, s), i = await this.buildInit(), a = i ? await this.fetchImpl(r, i) : await this.fetchImpl(r);
339
381
  if (!a.ok)
340
382
  throw new Error(`bundle fetch failed: ${a.status} ${a.statusText}`);
341
- const i = await a.json();
342
- if (i.scene_version !== s)
383
+ const o = await a.json();
384
+ if (o.scene_version !== s)
343
385
  throw new Error(
344
- `bundle scene_version mismatch: expected ${s}, got ${i.scene_version}`
386
+ `bundle scene_version mismatch: expected ${s}, got ${o.scene_version}`
345
387
  );
346
- return x(i), this.cache.set(s, i), i;
388
+ return $(o), this.cache.set(s, o), o;
347
389
  }
348
390
  }
349
- function Fe(t) {
350
- return new $e(t);
391
+ function Xe(t) {
392
+ return new Ge(t);
351
393
  }
352
394
  const y = {
353
395
  initial: 200,
@@ -355,7 +397,7 @@ const y = {
355
397
  factor: 2,
356
398
  jitter: 0.2
357
399
  };
358
- class qe {
400
+ class Ve {
359
401
  constructor(e, s) {
360
402
  this.opts = e, this.random = s;
361
403
  }
@@ -379,7 +421,7 @@ class qe {
379
421
  this._attempt = 0;
380
422
  }
381
423
  }
382
- function We(t = {}) {
424
+ function Ke(t = {}) {
383
425
  const e = {
384
426
  initial: t.initial ?? y.initial,
385
427
  max: t.max ?? y.max,
@@ -390,9 +432,9 @@ function We(t = {}) {
390
432
  if (e.max < e.initial) throw new RangeError("max must be >= initial");
391
433
  if (e.factor < 1) throw new RangeError("factor must be >= 1");
392
434
  if (e.jitter < 0 || e.jitter > 1) throw new RangeError("jitter must be within [0, 1]");
393
- return new qe(e, t.random ?? Math.random);
435
+ return new Ve(e, t.random ?? Math.random);
394
436
  }
395
- class p extends Error {
437
+ class g extends Error {
396
438
  recoverable;
397
439
  code;
398
440
  cause;
@@ -400,14 +442,14 @@ class p extends Error {
400
442
  super(e), this.name = "TransportError", this.recoverable = s, this.code = n, this.cause = r;
401
443
  }
402
444
  }
403
- class ze {
445
+ class Je {
404
446
  status = "disconnected";
405
447
  socket = null;
406
448
  token;
407
449
  url;
408
450
  WebSocketCtor;
409
451
  schedule;
410
- seq = new ce();
452
+ seq = new fe();
411
453
  opts;
412
454
  scheduler;
413
455
  reconnectTimer = null;
@@ -419,7 +461,7 @@ class ze {
419
461
  throw new TypeError(
420
462
  "Lumencast WsClient: no WebSocket implementation found in this environment"
421
463
  );
422
- this.WebSocketCtor = s, this.schedule = We(e.reconnect), this.scheduler = e.scheduler ?? {
464
+ this.WebSocketCtor = s, this.schedule = Ke(e.reconnect), this.scheduler = e.scheduler ?? {
423
465
  setTimeout: globalThis.setTimeout.bind(globalThis),
424
466
  clearTimeout: globalThis.clearTimeout.bind(globalThis)
425
467
  };
@@ -433,11 +475,11 @@ class ze {
433
475
  * authenticate the render-bundle GET with the same credential. A
434
476
  * `LumencastTokenProvider` is awaited. */
435
477
  resolveCurrentToken() {
436
- return j(this.token);
478
+ return F(this.token);
437
479
  }
438
480
  /** Send `input` patches to the server. No-op if not connected. */
439
481
  sendInput(e) {
440
- !this.socket || this.socket.readyState !== this.WebSocketCtor.OPEN || e.length !== 0 && this.socket.send(O(le(e)));
482
+ !this.socket || this.socket.readyState !== this.WebSocketCtor.OPEN || e.length !== 0 && this.socket.send(C(me(e)));
441
483
  }
442
484
  /** Replace the auth token. Closes and reopens with the new token. */
443
485
  setToken(e) {
@@ -453,10 +495,10 @@ class ze {
453
495
  this.setStatus("connecting");
454
496
  let e;
455
497
  try {
456
- e = await j(this.token);
498
+ e = await F(this.token);
457
499
  } catch (n) {
458
500
  this.opts.onTransportError?.(
459
- new p(
501
+ new g(
460
502
  `failed to resolve token: ${n.message}`,
461
503
  !0,
462
504
  "AUTH_DENIED",
@@ -468,10 +510,10 @@ class ze {
468
510
  if (!this.active) return;
469
511
  let s;
470
512
  try {
471
- s = new this.WebSocketCtor(this.url, [...ue]);
513
+ s = new this.WebSocketCtor(this.url, [...pe]);
472
514
  } catch (n) {
473
515
  this.opts.onTransportError?.(
474
- new p(
516
+ new g(
475
517
  `failed to open WebSocket: ${n.message}`,
476
518
  !0,
477
519
  "INTERNAL",
@@ -484,25 +526,25 @@ class ze {
484
526
  }
485
527
  handleOpen(e) {
486
528
  if (!this.socket) return;
487
- const n = this.socket.protocol === de && this.seq.last > 0, r = n ? this.seq.last : void 0;
529
+ const n = this.socket.protocol === ge && this.seq.last > 0, r = n ? this.seq.last : void 0;
488
530
  n || this.seq.reset();
489
- const o = he({
531
+ const i = ve({
490
532
  token: e,
491
533
  ...this.opts.scene !== void 0 ? { scene: this.opts.scene } : {},
492
534
  ...this.opts.session !== void 0 ? { session: this.opts.session } : {},
493
535
  ...r !== void 0 ? { since_sequence: r } : {}
494
536
  });
495
- this.socket.send(O(o));
537
+ this.socket.send(C(i));
496
538
  }
497
539
  handleMessage(e) {
498
540
  const s = typeof e.data == "string" ? e.data : "";
499
541
  if (!s) return;
500
542
  let n;
501
543
  try {
502
- n = fe(s);
544
+ n = we(s);
503
545
  } catch (r) {
504
- const o = (r instanceof L, r.message), a = r instanceof L ? r.code : "INTERNAL";
505
- this.opts.onTransportError?.(new p(`codec: ${o}`, !0, a, r)), this.closeSocket(), this.scheduleReconnect();
546
+ const i = (r instanceof M, r.message), a = r instanceof M ? r.code : "INTERNAL";
547
+ this.opts.onTransportError?.(new g(`codec: ${i}`, !0, a, r)), this.closeSocket(), this.scheduleReconnect();
506
548
  return;
507
549
  }
508
550
  if (n !== null)
@@ -510,7 +552,7 @@ class ze {
510
552
  case "snapshot": {
511
553
  if (n.seq < 1) {
512
554
  this.opts.onTransportError?.(
513
- new p(`snapshot seq must be >= 1, got ${n.seq}`, !0, "VERSION_GAP")
555
+ new g(`snapshot seq must be >= 1, got ${n.seq}`, !0, "VERSION_GAP")
514
556
  ), this.closeSocket(), this.scheduleReconnect();
515
557
  return;
516
558
  }
@@ -521,7 +563,7 @@ class ze {
521
563
  const r = this.seq.observe(n.seq);
522
564
  if (r.kind === "gap") {
523
565
  this.opts.onTransportError?.(
524
- new p(
566
+ new g(
525
567
  `sequence gap: expected ${this.seq.last + 1}, got ${n.seq}`,
526
568
  !0,
527
569
  "VERSION_GAP"
@@ -554,7 +596,7 @@ class ze {
554
596
  }
555
597
  if (e.code === 4401 || e.code === 4403 || e.code === 1008) {
556
598
  this.opts.onTransportError?.(
557
- new p(`server closed: ${e.code} ${e.reason}`, !1, "AUTH_DENIED")
599
+ new g(`server closed: ${e.code} ${e.reason}`, !1, "AUTH_DENIED")
558
600
  ), this.close();
559
601
  return;
560
602
  }
@@ -584,10 +626,10 @@ class ze {
584
626
  this.status !== e && (this.status = e, this.opts.onStatus?.(e));
585
627
  }
586
628
  }
587
- async function j(t) {
629
+ async function F(t) {
588
630
  return typeof t == "string" ? t : await t.fetch();
589
631
  }
590
- function Be(t) {
632
+ function Ye(t) {
591
633
  if (!(t.target instanceof HTMLElement))
592
634
  throw new TypeError("mount: `target` must be an HTMLElement");
593
635
  if (typeof t.serverUrl != "string" || t.serverUrl.length === 0)
@@ -599,75 +641,75 @@ function Be(t) {
599
641
  throw new TypeError("mount: `scene` is required when mode === 'test'");
600
642
  }
601
643
  }
602
- function ft(t) {
603
- Be(t), t.onStatus?.("disconnected");
604
- const e = G(), s = Ge(t.serverUrl), n = Fe({
644
+ function St(t) {
645
+ Ye(t), t.onStatus?.("disconnected");
646
+ const e = Y(), s = Qe(t.serverUrl), n = Xe({
605
647
  baseUrl: s,
606
648
  ...t.resolveBundleUrl !== void 0 ? { resolveUrl: t.resolveBundleUrl } : {},
607
- getAuthToken: () => h.resolveCurrentToken()
608
- }), r = v(null), o = v("disconnected"), a = v("__initial__"), i = (u) => {
609
- o.value = u, t.onStatus?.(u);
610
- }, l = (u) => {
611
- t.onError?.(u);
649
+ getAuthToken: () => p.resolveCurrentToken()
650
+ }), r = w(null), i = w("disconnected"), a = w("__initial__"), o = (l) => {
651
+ i.value = l, t.onStatus?.(l);
652
+ }, u = (l) => {
653
+ t.onError?.(l);
612
654
  };
613
655
  let c = !0;
614
- const d = t.onDiagnostic ? B(t.onDiagnostic) : void 0, h = new ze({
656
+ const d = t.onReservedLeaves ? Fe(t.onReservedLeaves) : void 0, m = t.onDiagnostic ? V(t.onDiagnostic) : void 0, p = new Je({
615
657
  url: t.serverUrl,
616
658
  token: t.token,
617
659
  ...t.scene !== void 0 ? { scene: t.scene } : {},
618
660
  ...t.testSession !== void 0 ? { session: t.testSession } : {},
619
- onStatus: i,
620
- onSnapshot: (u) => {
621
- c && (J(
661
+ onStatus: o,
662
+ onSnapshot: (l) => {
663
+ c && (d?.onSnapshot(l.state), se(
622
664
  n,
623
665
  r,
624
666
  a,
625
- u.scene_id,
626
- u.scene_version,
627
- () => Ce(e, u),
628
- l
667
+ l.scene_id,
668
+ l.scene_version,
669
+ () => Ue(e, l),
670
+ u
629
671
  ), t.onMetric?.({
630
672
  name: "snapshot_received",
631
- scene_id: u.scene_id,
632
- path_count: Object.keys(u.state).length
673
+ scene_id: l.scene_id,
674
+ path_count: Object.keys(l.state).length
633
675
  }));
634
676
  },
635
- onDelta: (u) => {
677
+ onDelta: (l) => {
636
678
  if (!c) return;
637
- const k = performance.now();
638
- Me(e, u), t.onMetric?.({
679
+ const S = performance.now();
680
+ De(e, l), d?.onDelta(l.patches), t.onMetric?.({
639
681
  name: "delta_applied",
640
- duration_ms: performance.now() - k
641
- }), t.onMetric?.({ name: "delta_received", count: 1, path_count: u.patches.length });
682
+ duration_ms: performance.now() - S
683
+ }), t.onMetric?.({ name: "delta_received", count: 1, path_count: l.patches.length });
642
684
  },
643
- onSceneChanged: (u) => {
685
+ onSceneChanged: (l) => {
644
686
  c && t.onMetric?.({
645
687
  name: "scene_changed",
646
688
  from: r.value?.scene_version ?? null,
647
- to: u.scene_version
689
+ to: l.scene_version
648
690
  });
649
691
  },
650
- onServerError: (u) => {
651
- l({
652
- code: u.code,
653
- message: u.message,
654
- recoverable: u.recoverable
692
+ onServerError: (l) => {
693
+ u({
694
+ code: l.code,
695
+ message: l.message,
696
+ recoverable: l.recoverable
655
697
  });
656
698
  },
657
- onTransportError: (u) => {
658
- l(He(u));
699
+ onTransportError: (l) => {
700
+ u(Ze(l));
659
701
  }
660
702
  });
661
- h.start();
662
- const w = q(t.target);
663
- return w.render(
664
- ne(ve, {
703
+ p.start();
704
+ const R = H(t.target);
705
+ return R.render(
706
+ ce(ke, {
665
707
  mode: t.mode,
666
708
  store: e,
667
709
  bundleSignal: r,
668
- statusSignal: o,
710
+ statusSignal: i,
669
711
  crossfadeKeySignal: a,
670
- sendInput: (u) => h.sendInput(u),
712
+ sendInput: (l) => p.sendInput(l),
671
713
  // ADR 004 §A1.3 — thread the host capture resolver to the runtime context
672
714
  // so the `x-zab.capture` primitive's ACQUIRE mode can pin a device.
673
715
  ...t.resolveCaptureDevice !== void 0 ? { resolveCaptureDevice: t.resolveCaptureDevice } : {},
@@ -681,35 +723,35 @@ function ft(t) {
681
723
  })
682
724
  ), {
683
725
  disconnect() {
684
- c && (c = !1, d?.(), h.close(), w.unmount());
726
+ c && (c = !1, m?.(), p.close(), R.unmount());
685
727
  },
686
- setToken(u) {
687
- c && h.setToken(u);
728
+ setToken(l) {
729
+ c && p.setToken(l);
688
730
  }
689
731
  };
690
- async function J(u, k, Z, _, R, Q, ee) {
691
- let A;
732
+ async function se(l, S, ne, A, O, re, ie) {
733
+ let P;
692
734
  try {
693
- A = await u.get(_, R);
694
- } catch (P) {
695
- ee({
735
+ P = await l.get(A, O);
736
+ } catch (L) {
737
+ ie({
696
738
  code: "BUNDLE_FETCH_FAILED",
697
- message: P instanceof Error ? P.message : "render bundle fetch failed",
739
+ message: L instanceof Error ? L.message : "render bundle fetch failed",
698
740
  recoverable: !0
699
741
  });
700
742
  return;
701
743
  }
702
- c && (Q(), k.value = A, Z.value = `${_}::${R}`);
744
+ c && (re(), S.value = P, ne.value = `${A}::${O}`);
703
745
  }
704
746
  }
705
- function He(t) {
747
+ function Ze(t) {
706
748
  return {
707
749
  code: t.code,
708
750
  message: t.message,
709
751
  recoverable: t.recoverable
710
752
  };
711
753
  }
712
- function Ge(t) {
754
+ function Qe(t) {
713
755
  try {
714
756
  const e = new URL(t);
715
757
  return `${e.protocol === "wss:" ? "https:" : "http:"}//${e.host}`;
@@ -717,7 +759,7 @@ function Ge(t) {
717
759
  return "";
718
760
  }
719
761
  }
720
- const Ke = [
762
+ const et = [
721
763
  "visible",
722
764
  "opacity",
723
765
  "universal_opacity",
@@ -734,13 +776,13 @@ const Ke = [
734
776
  // compiler and consumed by the Tree (built into a `<mask>` SVG element).
735
777
  "mask"
736
778
  ];
737
- function f(t) {
738
- return /* @__PURE__ */ new Set([...Ke, ...t]);
779
+ function h(t) {
780
+ return /* @__PURE__ */ new Set([...et, ...t]);
739
781
  }
740
- const Xe = {
741
- stack: f(["direction", "gap", "wrap", "crossGap", "align", "justify"]),
742
- grid: f(["cols", "rows", "gap"]),
743
- frame: f([
782
+ const tt = {
783
+ stack: h(["direction", "gap", "wrap", "crossGap", "align", "justify"]),
784
+ grid: h(["cols", "rows", "gap"]),
785
+ frame: h([
744
786
  "x",
745
787
  "y",
746
788
  "width",
@@ -751,7 +793,7 @@ const Xe = {
751
793
  "backgrounds",
752
794
  "clipsContent"
753
795
  ]),
754
- text: f([
796
+ text: h([
755
797
  "value",
756
798
  "size",
757
799
  "font",
@@ -765,8 +807,8 @@ const Xe = {
765
807
  "fontStyle",
766
808
  "maxLines"
767
809
  ]),
768
- image: f(["src", "alt", "fit", "position", "width", "height"]),
769
- shape: f([
810
+ image: h(["src", "alt", "fit", "position", "width", "height"]),
811
+ shape: h([
770
812
  "geometry",
771
813
  "kind",
772
814
  "width",
@@ -785,7 +827,7 @@ const Xe = {
785
827
  // source is a `meet.peer.peer_label` is rendered in `srcObject` from a host
786
828
  // resolver instead of `<video src>`. Listed so it is NOT flagged as a silent
787
829
  // drop by the anti-drop audit when a scene carries a live source.
788
- media: f(["src", "peerLabel", "loop", "mute", "autoplay", "fit"]),
830
+ media: h(["src", "peerLabel", "loop", "mute", "autoplay", "fit"]),
789
831
  // ADR 006 §3.3/§3.5 — the unified source kind. `peer_label` is the stream
790
832
  // reference (resolved to a MediaStream → srcObject) ; `object_fit`/`muted`
791
833
  // drive the video ; `x-zab.sourceKind` is advisory ; `metadata` carries the
@@ -793,7 +835,7 @@ const Xe = {
793
835
  // but an UNCOMPILED from-scene node carries the NESTED `position`/`size` shape
794
836
  // (the Tree flattens it as a fallback) — listed so neither form is flagged as
795
837
  // a silent drop by the anti-drop audit.
796
- "meet.peer": f([
838
+ "meet.peer": h([
797
839
  "peer_label",
798
840
  "object_fit",
799
841
  "muted",
@@ -802,42 +844,42 @@ const Xe = {
802
844
  "position",
803
845
  "size"
804
846
  ]),
805
- instance: f(["scene_id", "scene_version", "size", "position"]),
847
+ instance: h(["scene_id", "scene_version", "size", "position"]),
806
848
  // RFC-0001 / ADR 004 — vendor capture placeholder. `width`/`height` are the
807
849
  // flattened geometry (universal) ; the `x-zab.*` props are carried as
808
850
  // metadata (the renderer reserves the box, ignores deviceRef). Listed so
809
851
  // they are NOT flagged as silent drops by the anti-drop audit.
810
- "x-zab.capture": f(["x-zab.sourceKind", "x-zab.deviceRef", "width", "height"]),
852
+ "x-zab.capture": h(["x-zab.sourceKind", "x-zab.deviceRef", "width", "height"]),
811
853
  // ADR Blue 009 §3.1 (Amendment 2) — vendor meet-peer SLOT placeholder.
812
854
  // `width`/`height` are the flattened geometry (universal) ; `x-zab.slotRef`
813
855
  // is the logical slot identity carried as metadata (the runtime resolves
814
856
  // `slotRef → peer_label` from stream-level ZabCam state). NO cam/peer
815
857
  // identity is carried. Listed so they are NOT flagged as silent drops.
816
- "x-zab.meet-peer": f(["x-zab.slotRef", "width", "height"]),
858
+ "x-zab.meet-peer": h(["x-zab.slotRef", "width", "height"]),
817
859
  // `repeat` is dispatched specially by the tree ; its only consumed
818
860
  // binding is `items`.
819
861
  repeat: /* @__PURE__ */ new Set(["items"])
820
862
  };
821
- function Ve(t, e) {
822
- const s = Xe[t];
863
+ function st(t, e) {
864
+ const s = tt[t];
823
865
  return !!(s === void 0 || s.has(e) || t === "instance" && (e === "params" || e.startsWith("params.")));
824
866
  }
825
- const D = /* @__PURE__ */ new WeakSet();
826
- function mt(t) {
827
- if (D.has(t)) return;
828
- D.add(t);
867
+ const W = /* @__PURE__ */ new WeakSet();
868
+ function kt(t) {
869
+ if (W.has(t)) return;
870
+ W.add(t);
829
871
  const e = /* @__PURE__ */ new Set([
830
872
  ...Object.keys(t.props ?? {}),
831
873
  ...Object.keys(t.bindings ?? {})
832
874
  ]);
833
875
  for (const s of e)
834
- Ve(t.kind, s) || H(
876
+ st(t.kind, s) || K(
835
877
  t.id,
836
878
  `${t.kind}.${s}`,
837
879
  "is not consumed by this primitive's renderer ; the prop is ignored (anti-silent-drop, ADR 001 §3.4)"
838
880
  );
839
881
  }
840
- class K {
882
+ class Z {
841
883
  constructor(e) {
842
884
  this.options = e, this.deps = {
843
885
  WebSocket: e.deps?.WebSocket ?? globalThis.WebSocket,
@@ -870,13 +912,13 @@ class K {
870
912
  return e.searchParams.set("room", this.options.roomId), e.searchParams.set("token", this.options.token), new Promise((s, n) => {
871
913
  const r = new this.deps.WebSocket(e.toString());
872
914
  this.ws = r;
873
- const o = () => {
915
+ const i = () => {
874
916
  r.removeEventListener("error", a), this.send({ type: "join", name: this.options.name, role: "viewer" }), s();
875
- }, a = (i) => {
876
- r.removeEventListener("open", o), n(i);
917
+ }, a = (o) => {
918
+ r.removeEventListener("open", i), n(o);
877
919
  };
878
- r.addEventListener("open", o, { once: !0 }), r.addEventListener("error", a, { once: !0 }), r.addEventListener("message", (i) => void this.onMessage(i.data)), r.addEventListener("close", (i) => {
879
- this.tearDown(), this.emit("close", { code: i.code, reason: i.reason });
920
+ r.addEventListener("open", i, { once: !0 }), r.addEventListener("error", a, { once: !0 }), r.addEventListener("message", (o) => void this.onMessage(o.data)), r.addEventListener("close", (o) => {
921
+ this.tearDown(), this.emit("close", { code: o.code, reason: o.reason });
880
922
  });
881
923
  });
882
924
  }
@@ -929,15 +971,15 @@ class K {
929
971
  n || (n = this.ensureRemote({ id: e, name: e.slice(0, 8), role: "publisher" }));
930
972
  const { pc: r } = n;
931
973
  if (s.kind === "sdp") {
932
- const o = s.description, a = o.type === "offer" && (n.makingOffer || r.signalingState !== "stable");
974
+ const i = s.description, a = i.type === "offer" && (n.makingOffer || r.signalingState !== "stable");
933
975
  if (n.ignoreOffer = !this.isPolite(e) && a, n.ignoreOffer) return;
934
- await r.setRemoteDescription(o);
935
- for (const i of n.pendingCandidates)
976
+ await r.setRemoteDescription(i);
977
+ for (const o of n.pendingCandidates)
936
978
  try {
937
- await r.addIceCandidate(i);
979
+ await r.addIceCandidate(o);
938
980
  } catch {
939
981
  }
940
- n.pendingCandidates = [], o.type === "offer" && (await r.setLocalDescription(), r.localDescription && this.sendSignal(e, {
982
+ n.pendingCandidates = [], i.type === "offer" && (await r.setLocalDescription(), r.localDescription && this.sendSignal(e, {
941
983
  kind: "sdp",
942
984
  description: {
943
985
  type: r.localDescription.type,
@@ -947,15 +989,15 @@ class K {
947
989
  return;
948
990
  }
949
991
  if (s.kind === "ice") {
950
- const o = s.candidate;
992
+ const i = s.candidate;
951
993
  if (r.remoteDescription)
952
994
  try {
953
- await r.addIceCandidate(o);
995
+ await r.addIceCandidate(i);
954
996
  } catch (a) {
955
997
  if (!n.ignoreOffer) throw a;
956
998
  }
957
999
  else
958
- n.pendingCandidates.push(o);
1000
+ n.pendingCandidates.push(i);
959
1001
  return;
960
1002
  }
961
1003
  }
@@ -966,9 +1008,9 @@ class K {
966
1008
  const n = new this.deps.RTCPeerConnection({
967
1009
  iceServers: this.iceServers,
968
1010
  iceTransportPolicy: "relay"
969
- }), r = new this.deps.MediaStream(), o = n.addTransceiver("audio", { direction: "recvonly" }), a = n.addTransceiver("video", { direction: "recvonly" });
970
- Ye(o, a);
971
- const i = {
1011
+ }), r = new this.deps.MediaStream(), i = n.addTransceiver("audio", { direction: "recvonly" }), a = n.addTransceiver("video", { direction: "recvonly" });
1012
+ nt(i, a);
1013
+ const o = {
972
1014
  info: e,
973
1015
  pc: n,
974
1016
  stream: r,
@@ -979,7 +1021,7 @@ class K {
979
1021
  return n.addEventListener("negotiationneeded", () => {
980
1022
  (async () => {
981
1023
  try {
982
- i.makingOffer = !0, await n.setLocalDescription(), n.localDescription && this.sendSignal(e.id, {
1024
+ o.makingOffer = !0, await n.setLocalDescription(), n.localDescription && this.sendSignal(e.id, {
983
1025
  kind: "sdp",
984
1026
  description: {
985
1027
  type: n.localDescription.type,
@@ -988,11 +1030,11 @@ class K {
988
1030
  });
989
1031
  } catch {
990
1032
  } finally {
991
- i.makingOffer = !1;
1033
+ o.makingOffer = !1;
992
1034
  }
993
1035
  })();
994
- }), n.addEventListener("icecandidate", (l) => {
995
- const c = l.candidate;
1036
+ }), n.addEventListener("icecandidate", (u) => {
1037
+ const c = u.candidate;
996
1038
  c && this.sendSignal(e.id, {
997
1039
  kind: "ice",
998
1040
  candidate: {
@@ -1002,18 +1044,18 @@ class K {
1002
1044
  usernameFragment: c.usernameFragment
1003
1045
  }
1004
1046
  });
1005
- }), n.addEventListener("track", (l) => {
1006
- const c = l.track;
1007
- i.stream.getTracks().includes(c) || i.stream.addTrack(c), c.addEventListener("ended", () => {
1008
- i.stream.removeTrack(c);
1047
+ }), n.addEventListener("track", (u) => {
1048
+ const c = u.track;
1049
+ o.stream.getTracks().includes(c) || o.stream.addTrack(c), c.addEventListener("ended", () => {
1050
+ o.stream.removeTrack(c);
1009
1051
  }), this.emit("remote-track", {
1010
1052
  peerId: e.id,
1011
1053
  peerName: e.name,
1012
- stream: i.stream
1054
+ stream: o.stream
1013
1055
  });
1014
1056
  }), n.addEventListener("connectionstatechange", () => {
1015
1057
  this.emit("connection-state", { peerId: e.id, state: n.connectionState }), (n.connectionState === "failed" || n.connectionState === "closed") && (this.remotes.delete(e.id), this.emit("peer-left", { peerId: e.id, peerName: e.name }));
1016
- }), this.remotes.set(e.id, i), i;
1058
+ }), this.remotes.set(e.id, o), o;
1017
1059
  }
1018
1060
  /* ---- Helpers ------------------------------------------------------ */
1019
1061
  isPolite(e) {
@@ -1028,41 +1070,41 @@ class K {
1028
1070
  for (const r of n) r(s);
1029
1071
  }
1030
1072
  }
1031
- function Ye(t, e) {
1073
+ function nt(t, e) {
1032
1074
  const s = globalThis.RTCRtpReceiver?.getCapabilities;
1033
- typeof s == "function" && (U(e, s("video"), (n) => {
1075
+ typeof s == "function" && (q(e, s("video"), (n) => {
1034
1076
  const r = n.toLowerCase();
1035
1077
  return r === "video/h264" || r === "video/rtx";
1036
- }), U(t, s("audio"), (n) => {
1078
+ }), q(t, s("audio"), (n) => {
1037
1079
  const r = n.toLowerCase();
1038
1080
  return r === "audio/opus" || r === "audio/telephone-event";
1039
1081
  }));
1040
1082
  }
1041
- function U(t, e, s) {
1083
+ function q(t, e, s) {
1042
1084
  const n = t?.setCodecPreferences;
1043
1085
  if (typeof n != "function" || !e) return;
1044
- const r = e.codecs.filter((o) => s(o.mimeType));
1086
+ const r = e.codecs.filter((i) => s(i.mimeType));
1045
1087
  if (r.length !== 0)
1046
1088
  try {
1047
1089
  n.call(t, r);
1048
1090
  } catch {
1049
1091
  }
1050
1092
  }
1051
- function X() {
1093
+ function Q() {
1052
1094
  const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map();
1053
1095
  function s(n) {
1054
1096
  const r = e.get(n);
1055
1097
  if (r === void 0) return;
1056
- const o = t.get(n) ?? null;
1057
- for (const a of r) a(o);
1098
+ const i = t.get(n) ?? null;
1099
+ for (const a of r) a(i);
1058
1100
  }
1059
1101
  return {
1060
1102
  resolve(n) {
1061
1103
  return t.get(n) ?? null;
1062
1104
  },
1063
1105
  subscribe(n, r) {
1064
- let o = e.get(n);
1065
- return o === void 0 && (o = /* @__PURE__ */ new Set(), e.set(n, o)), o.add(r), r(t.get(n) ?? null), () => {
1106
+ let i = e.get(n);
1107
+ return i === void 0 && (i = /* @__PURE__ */ new Set(), e.set(n, i)), i.add(r), r(t.get(n) ?? null), () => {
1066
1108
  const a = e.get(n);
1067
1109
  a !== void 0 && (a.delete(r), a.size === 0 && e.delete(n));
1068
1110
  };
@@ -1080,161 +1122,161 @@ function X() {
1080
1122
  }
1081
1123
  };
1082
1124
  }
1083
- function g(t) {
1125
+ function v(t) {
1084
1126
  return t.toLowerCase().replace(/[^a-z0-9_-]+/g, "_").replace(/^[_-]+|[_-]+$/g, "");
1085
1127
  }
1086
- function V(t, e, s) {
1128
+ function ee(t, e, s) {
1087
1129
  t.on("remote-track", (n) => {
1088
- const r = g(n.peerName);
1130
+ const r = v(n.peerName);
1089
1131
  s.acquire(r, t) && e.set(r, n.stream);
1090
1132
  }), t.on("peer-left", (n) => {
1091
- const r = g(n.peerName);
1133
+ const r = v(n.peerName);
1092
1134
  s.acquire(r, t) && (e.remove(r), s.release(r, t));
1093
1135
  });
1094
1136
  }
1095
- const Je = {
1137
+ const rt = {
1096
1138
  acquire: () => !0,
1097
1139
  release: () => {
1098
1140
  }
1099
1141
  };
1100
- function pt(t) {
1101
- const e = X(), s = new K(t);
1102
- return V(s, e, Je), {
1142
+ function Tt(t) {
1143
+ const e = Q(), s = new Z(t);
1144
+ return ee(s, e, rt), {
1103
1145
  join: () => s.join(),
1104
1146
  leave: () => {
1105
1147
  s.leave(), e.clear();
1106
1148
  },
1107
- resolvePeerStream: (n) => e.resolve(g(n)),
1108
- subscribePeerStream: (n, r) => e.subscribe(g(n), r),
1149
+ resolvePeerStream: (n) => e.resolve(v(n)),
1150
+ subscribePeerStream: (n, r) => e.subscribe(v(n), r),
1109
1151
  registry: e,
1110
1152
  viewer: s
1111
1153
  };
1112
1154
  }
1113
- function $(t) {
1114
- const e = X(), s = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = {
1115
- acquire: (i, l) => {
1116
- const c = n.get(i);
1117
- return c === void 0 ? (n.set(i, l), !0) : c === l;
1155
+ function z(t) {
1156
+ const e = Q(), s = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = {
1157
+ acquire: (o, u) => {
1158
+ const c = n.get(o);
1159
+ return c === void 0 ? (n.set(o, u), !0) : c === u;
1118
1160
  },
1119
- release: (i, l) => {
1120
- n.get(i) === l && n.delete(i);
1161
+ release: (o, u) => {
1162
+ n.get(o) === u && n.delete(o);
1121
1163
  }
1122
1164
  };
1123
- function o(i) {
1124
- if (s.has(i.roomId)) return;
1125
- const l = new K({
1126
- name: i.name ?? "solar-viewer",
1127
- ...i,
1128
- ...t.deps !== void 0 && i.deps === void 0 ? { deps: t.deps } : {}
1165
+ function i(o) {
1166
+ if (s.has(o.roomId)) return;
1167
+ const u = new Z({
1168
+ name: o.name ?? "solar-viewer",
1169
+ ...o,
1170
+ ...t.deps !== void 0 && o.deps === void 0 ? { deps: t.deps } : {}
1129
1171
  });
1130
- V(l, e, r), s.set(i.roomId, { viewer: l });
1172
+ ee(u, e, r), s.set(o.roomId, { viewer: u });
1131
1173
  }
1132
- function a(i) {
1133
- const l = s.get(i);
1134
- if (l !== void 0) {
1174
+ function a(o) {
1175
+ const u = s.get(o);
1176
+ if (u !== void 0) {
1135
1177
  for (const [c, d] of [...n.entries()])
1136
- d === l.viewer && (e.remove(c), n.delete(c));
1137
- l.viewer.leave(), s.delete(i);
1178
+ d === u.viewer && (e.remove(c), n.delete(c));
1179
+ u.viewer.leave(), s.delete(o);
1138
1180
  }
1139
1181
  }
1140
- for (const i of t.rooms) o(i);
1182
+ for (const o of t.rooms) i(o);
1141
1183
  return {
1142
1184
  join: async () => {
1143
- await Promise.all([...s.values()].map((i) => i.viewer.join()));
1185
+ await Promise.all([...s.values()].map((o) => o.viewer.join()));
1144
1186
  },
1145
1187
  leave: () => {
1146
- for (const i of [...s.keys()]) a(i);
1188
+ for (const o of [...s.keys()]) a(o);
1147
1189
  e.clear();
1148
1190
  },
1149
- setRooms: async (i) => {
1150
- const l = new Set(i.map((d) => d.roomId));
1191
+ setRooms: async (o) => {
1192
+ const u = new Set(o.map((d) => d.roomId));
1151
1193
  for (const d of [...s.keys()])
1152
- l.has(d) || a(d);
1194
+ u.has(d) || a(d);
1153
1195
  const c = [];
1154
- for (const d of i)
1196
+ for (const d of o)
1155
1197
  if (!s.has(d.roomId)) {
1156
- o(d);
1157
- const h = s.get(d.roomId);
1158
- h && c.push(h.viewer);
1198
+ i(d);
1199
+ const m = s.get(d.roomId);
1200
+ m && c.push(m.viewer);
1159
1201
  }
1160
1202
  await Promise.all(c.map((d) => d.join()));
1161
1203
  },
1162
- resolvePeerStream: (i) => e.resolve(g(i)),
1163
- subscribePeerStream: (i, l) => e.subscribe(g(i), l),
1204
+ resolvePeerStream: (o) => e.resolve(v(o)),
1205
+ subscribePeerStream: (o, u) => e.subscribe(v(o), u),
1164
1206
  registry: e
1165
1207
  };
1166
1208
  }
1167
- function gt(t) {
1209
+ function Et(t) {
1168
1210
  if ("rooms" in t && Array.isArray(t.rooms))
1169
- return $(t);
1211
+ return z(t);
1170
1212
  const { name: e, deps: s, ...n } = t;
1171
- return $({
1213
+ return z({
1172
1214
  rooms: [{ ...n, ...e !== void 0 ? { name: e } : {} }],
1173
1215
  ...s !== void 0 ? { deps: s } : {}
1174
1216
  });
1175
1217
  }
1176
- const Ze = { width: 1920, height: 1080 }, Qe = () => {
1218
+ const it = { width: 1920, height: 1080 }, ot = () => {
1177
1219
  };
1178
- function vt(t) {
1179
- const e = t.stage ?? Ze, s = t.target;
1220
+ function _t(t) {
1221
+ const e = t.stage ?? it, s = t.target;
1180
1222
  s.style.position ||= "relative", s.style.width = `${e.width}px`, s.style.height = `${e.height}px`, s.style.overflow = "hidden";
1181
- const n = t.onDiagnostic ? B(t.onDiagnostic) : void 0, r = G();
1223
+ const n = t.onDiagnostic ? V(t.onDiagnostic) : void 0, r = Y();
1182
1224
  r.reset(t.defaults ?? {});
1183
- const o = q(s);
1225
+ const i = H(s);
1184
1226
  return {
1185
- ready: new Promise((i) => {
1186
- import("./broadcast-L5wm2I6J.js").then(({ BroadcastMode: l }) => {
1187
- o.render(
1188
- /* @__PURE__ */ m(re, { children: /* @__PURE__ */ m(
1189
- z,
1227
+ ready: new Promise((o) => {
1228
+ import("./broadcast-DtHoU_fS.js").then(({ BroadcastMode: u }) => {
1229
+ i.render(
1230
+ /* @__PURE__ */ f(le, { children: /* @__PURE__ */ f(
1231
+ X,
1190
1232
  {
1191
1233
  value: {
1192
1234
  mode: "broadcast",
1193
1235
  store: r,
1194
1236
  bundle: t.bundle,
1195
1237
  status: "live",
1196
- sendInput: Qe
1238
+ sendInput: ot
1197
1239
  },
1198
- children: /* @__PURE__ */ m(l, {})
1240
+ children: /* @__PURE__ */ f(u, {})
1199
1241
  }
1200
1242
  ) })
1201
1243
  );
1202
- const c = new Promise((h) => {
1203
- requestAnimationFrame(() => requestAnimationFrame(() => h()));
1244
+ const c = new Promise((m) => {
1245
+ requestAnimationFrame(() => requestAnimationFrame(() => m()));
1204
1246
  }), d = typeof document < "u" && document.fonts ? document.fonts.ready.then(() => {
1205
1247
  }) : Promise.resolve();
1206
- Promise.all([c, d]).then(() => i());
1248
+ Promise.all([c, d]).then(() => o());
1207
1249
  });
1208
1250
  }),
1209
1251
  unmount() {
1210
- n?.(), o.unmount();
1252
+ n?.(), i.unmount();
1211
1253
  }
1212
1254
  };
1213
1255
  }
1214
- function Y(t, e) {
1256
+ function te(t, e) {
1215
1257
  if (typeof t != "string") return t;
1216
1258
  if (e[t]) return e[t];
1217
1259
  const s = /^assets\/([A-Za-z0-9]+)\.[A-Za-z0-9]+$/.exec(t);
1218
1260
  return s && s[1] !== void 0 && e[s[1]] ? e[s[1]] : t;
1219
1261
  }
1220
- function F(t, e) {
1262
+ function B(t, e) {
1221
1263
  if (t === null || typeof t != "object") return;
1222
1264
  if (Array.isArray(t)) {
1223
- for (const n of t) F(n, e);
1265
+ for (const n of t) B(n, e);
1224
1266
  return;
1225
1267
  }
1226
1268
  const s = t;
1227
- "src" in s && (s.src = Y(s.src, e));
1269
+ "src" in s && (s.src = te(s.src, e));
1228
1270
  for (const n of Object.values(s))
1229
- n && typeof n == "object" && F(n, e);
1271
+ n && typeof n == "object" && B(n, e);
1230
1272
  }
1231
- function wt(t, e) {
1273
+ function It(t, e) {
1232
1274
  const s = { ...t };
1233
1275
  for (const [n, r] of Object.entries(s))
1234
- n.startsWith("__lit.image.") && (s[n] = Y(r, e));
1276
+ n.startsWith("__lit.image.") && (s[n] = te(r, e));
1235
1277
  return s;
1236
1278
  }
1237
- async function yt(t) {
1279
+ async function Rt(t) {
1238
1280
  const e = [];
1239
1281
  for (const s of t)
1240
1282
  try {
@@ -1248,34 +1290,38 @@ async function yt(t) {
1248
1290
  return e;
1249
1291
  }
1250
1292
  export {
1251
- we as A,
1252
- N as B,
1253
- lt as F,
1254
- K as M,
1255
- Xe as P,
1256
- xe as S,
1257
- ct as a,
1258
- mt as b,
1259
- M as c,
1260
- B as d,
1261
- H as e,
1262
- $ as f,
1263
- X as g,
1264
- pt as h,
1265
- gt as i,
1266
- yt as j,
1267
- Ue as k,
1268
- ft as l,
1269
- ht as m,
1270
- vt as n,
1271
- Y as o,
1272
- wt as p,
1273
- F as q,
1274
- dt as r,
1275
- Ee as s,
1276
- ut as t,
1277
- at as u,
1278
- x as v,
1279
- Ie as w
1293
+ Te as A,
1294
+ U as B,
1295
+ bt as C,
1296
+ gt as F,
1297
+ Z as M,
1298
+ tt as P,
1299
+ qe as S,
1300
+ pt as a,
1301
+ kt as b,
1302
+ N as c,
1303
+ E as d,
1304
+ K as e,
1305
+ J as f,
1306
+ V as g,
1307
+ z as h,
1308
+ Q as i,
1309
+ Tt as j,
1310
+ Et as k,
1311
+ Rt as l,
1312
+ yt as m,
1313
+ He as n,
1314
+ x as o,
1315
+ St as p,
1316
+ _t as q,
1317
+ wt as r,
1318
+ Oe as s,
1319
+ vt as t,
1320
+ mt as u,
1321
+ te as v,
1322
+ Pe as w,
1323
+ It as x,
1324
+ B as y,
1325
+ $ as z
1280
1326
  };
1281
- //# sourceMappingURL=index-Clrya_9l.js.map
1327
+ //# sourceMappingURL=index-Dz27r92m.js.map