@lumencast/runtime 0.5.0 → 0.6.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.
@@ -1,77 +1,77 @@
1
- import { batch as y, signal as d } from "@preact/signals-react";
2
- import { createRoot as q } from "react-dom/client";
3
- import { createContext as B, useContext as W, lazy as S, Suspense as H, createElement as z } from "react";
4
- import { jsx as h } from "react/jsx-runtime";
5
- import { useSignals as G } from "@preact/signals-react/runtime";
6
- import { AnimatePresence as X, motion as Y } from "framer-motion";
7
- import { SequenceTracker as K, encodeFrame as R, input as J, WS_SUBPROTOCOLS as Q, WS_SUBPROTOCOL_V1_1 as Z, subscribe as V, decodeServerFrame as ee, LumencastError as A } from "@lumencast/protocol";
8
- const M = B(null);
9
- function te({
1
+ import { batch as T, signal as p } from "@preact/signals-react";
2
+ import { createRoot as B } from "react-dom/client";
3
+ import { createContext as W, useContext as z, lazy as y, Suspense as H, createElement as G } from "react";
4
+ import { jsx as f } from "react/jsx-runtime";
5
+ import { useSignals as X } from "@preact/signals-react/runtime";
6
+ import { AnimatePresence as Y, motion as K } from "framer-motion";
7
+ import { SequenceTracker as J, encodeFrame as R, input as Q, WS_SUBPROTOCOLS as Z, WS_SUBPROTOCOL_V1_1 as V, subscribe as ee, decodeServerFrame as te, LumencastError as A } from "@lumencast/protocol";
8
+ const P = W(null);
9
+ function se({
10
10
  value: t,
11
11
  children: e
12
12
  }) {
13
- return /* @__PURE__ */ h(M.Provider, { value: t, children: e });
13
+ return /* @__PURE__ */ f(P.Provider, { value: t, children: e });
14
14
  }
15
15
  function Ye() {
16
- const t = W(M);
16
+ const t = z(P);
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
- const se = S(
24
- () => import("./broadcast-3vYij4k-.js").then((t) => ({ default: t.BroadcastMode }))
25
- ), ne = S(
26
- () => import("./control-BFNkY7-6.js").then((t) => ({ default: t.ControlMode }))
27
- ), re = S(() => import("./test-ByRec1kd.js").then((t) => ({ default: t.TestMode })));
28
- function ie({
23
+ const ne = y(
24
+ () => import("./broadcast-DO7jEkix.js").then((t) => ({ default: t.BroadcastMode }))
25
+ ), re = y(
26
+ () => import("./control-BSfl4_cO.js").then((t) => ({ default: t.ControlMode }))
27
+ ), ie = y(() => import("./test-_hh1JvAd.js").then((t) => ({ default: t.TestMode })));
28
+ function oe({
29
29
  mode: t,
30
30
  store: e,
31
31
  bundleSignal: s,
32
32
  statusSignal: n,
33
33
  crossfadeKeySignal: r,
34
- sendInput: i
34
+ sendInput: o
35
35
  }) {
36
- G();
37
- const c = s.value, b = n.value, f = r.value;
36
+ X();
37
+ const c = s.value, a = n.value, d = r.value;
38
38
  if (!c) return null;
39
- const a = t === "broadcast" ? se : t === "control" ? ne : re;
40
- return /* @__PURE__ */ h(X, { mode: "sync", children: /* @__PURE__ */ h(
41
- Y.div,
39
+ const l = t === "broadcast" ? ne : t === "control" ? re : ie;
40
+ return /* @__PURE__ */ f(Y, { mode: "sync", children: /* @__PURE__ */ f(
41
+ K.div,
42
42
  {
43
43
  initial: { opacity: 0 },
44
44
  animate: { opacity: 1 },
45
45
  exit: { opacity: 0 },
46
46
  transition: { duration: 0.4, ease: "easeInOut" },
47
47
  style: { position: "absolute", inset: 0 },
48
- children: /* @__PURE__ */ h(
49
- te,
48
+ children: /* @__PURE__ */ f(
49
+ se,
50
50
  {
51
51
  value: {
52
52
  mode: t,
53
53
  store: e,
54
54
  bundle: c,
55
- status: b,
56
- sendInput: i
55
+ status: a,
56
+ sendInput: o
57
57
  },
58
- children: /* @__PURE__ */ h(H, { fallback: null, children: /* @__PURE__ */ h(a, {}) })
58
+ children: /* @__PURE__ */ f(H, { fallback: null, children: /* @__PURE__ */ f(l, {}) })
59
59
  }
60
60
  )
61
61
  },
62
- f
62
+ d
63
63
  ) });
64
64
  }
65
- const oe = "<anon>", g = /* @__PURE__ */ new Set();
66
- function ce(t) {
67
- return g.add(t), () => {
68
- g.delete(t);
65
+ const ce = "<anon>", b = /* @__PURE__ */ new Set();
66
+ function ae(t) {
67
+ return b.add(t), () => {
68
+ b.delete(t);
69
69
  };
70
70
  }
71
- function P(t, e, s) {
72
- const n = { nodeId: t ?? oe, field: e, reason: s };
73
- if (g.size > 0) {
74
- for (const r of g)
71
+ function $(t, e, s) {
72
+ const n = { nodeId: t ?? ce, field: e, reason: s };
73
+ if (b.size > 0) {
74
+ for (const r of b)
75
75
  try {
76
76
  r(n);
77
77
  } catch {
@@ -79,41 +79,41 @@ function P(t, e, s) {
79
79
  return;
80
80
  }
81
81
  }
82
- const ae = 100, le = 4, ue = 64, he = {
83
- blur: ae,
84
- brightness: le
82
+ const le = 100, ue = 4, he = 64, fe = {
83
+ blur: le,
84
+ brightness: ue
85
85
  };
86
86
  function O(t, e) {
87
87
  if (typeof e != "number" || !Number.isFinite(e) || e < 0 || Object.is(e, -0)) return null;
88
- const s = he[t];
88
+ const s = fe[t];
89
89
  return e > s ? s : e;
90
90
  }
91
- const fe = /^blur\((\d{1,7}(?:\.\d{1,4})?)px\) brightness\((\d{1,7}(?:\.\d{1,4})?)\)$/, Ke = "blur(0px) brightness(1)";
92
- function de(t) {
93
- if (typeof t != "string" || t.length === 0 || t.length > ue) return null;
94
- const e = fe.exec(t);
91
+ const de = /^blur\((\d{1,7}(?:\.\d{1,4})?)px\) brightness\((\d{1,7}(?:\.\d{1,4})?)\)$/, Ke = "blur(0px) brightness(1)";
92
+ function me(t) {
93
+ if (typeof t != "string" || t.length === 0 || t.length > he) return null;
94
+ const e = de.exec(t);
95
95
  if (!e) return null;
96
96
  const s = O("blur", Number(e[1])), n = O("brightness", Number(e[2]));
97
97
  return s === null || n === null ? null : `blur(${s}px) brightness(${n})`;
98
98
  }
99
- function me(t, e) {
100
- P(
99
+ function pe(t, e) {
100
+ $(
101
101
  e,
102
102
  t,
103
103
  "rejected unsafe filter value : outside the R8 caps or not a finite number >= 0"
104
104
  );
105
105
  }
106
- const pe = { duration: 0 }, ge = {
106
+ const ge = { duration: 0 }, be = {
107
107
  linear: "linear",
108
108
  "cubic-in": "easeIn",
109
109
  "cubic-out": "easeOut",
110
110
  "cubic-in-out": "easeInOut"
111
111
  };
112
112
  function Je(t) {
113
- return !t || t.kind === "none" ? pe : t.kind === "tween" ? {
113
+ return !t || t.kind === "none" ? ge : t.kind === "tween" ? {
114
114
  type: "tween",
115
115
  duration: (t.duration_ms ?? 0) / 1e3,
116
- ease: t.ease ? ge[t.ease] ?? "easeOut" : "easeOut"
116
+ ease: t.ease ? be[t.ease] ?? "easeOut" : "easeOut"
117
117
  } : t.kind === "spring" ? {
118
118
  type: "spring",
119
119
  ...t.stiffness !== void 0 ? { stiffness: t.stiffness } : {},
@@ -125,7 +125,7 @@ function Je(t) {
125
125
  ease: "easeInOut"
126
126
  };
127
127
  }
128
- const be = {
128
+ const ve = {
129
129
  opacity: 1,
130
130
  scale: 1,
131
131
  scaleX: 1,
@@ -137,7 +137,7 @@ const be = {
137
137
  // framer interpolates between structurally-identical filter lists
138
138
  // (the compiler emits the same two-function form, clamped per R8).
139
139
  filter: "blur(0px) brightness(1)"
140
- }, ve = {
140
+ }, ke = {
141
141
  kind: "tween",
142
142
  duration_ms: 400,
143
143
  ease: "cubic-out"
@@ -152,7 +152,7 @@ function Qe(t, e, s) {
152
152
  const r = t(n);
153
153
  if (r !== void 0) return r;
154
154
  }
155
- return ve;
155
+ return ke;
156
156
  }
157
157
  }
158
158
  function Ze(t, e, s) {
@@ -160,15 +160,15 @@ function Ze(t, e, s) {
160
160
  return { initial: t, animate: t };
161
161
  let n = e;
162
162
  if (e.filter !== void 0) {
163
- const i = de(e.filter);
164
- n = { ...e }, i === null ? (me("animate_initial.filter", s), delete n.filter) : n.filter = i;
163
+ const o = me(e.filter);
164
+ n = { ...e }, o === null ? (pe("animate_initial.filter", s), delete n.filter) : n.filter = o;
165
165
  }
166
166
  const r = { ...t };
167
- for (const i of Object.keys(n))
168
- i in r || (r[i] = be[i] ?? 0);
167
+ for (const o of Object.keys(n))
168
+ o in r || (r[o] = ve[o] ?? 0);
169
169
  return { initial: n, animate: r };
170
170
  }
171
- function ke(t) {
171
+ function Te(t) {
172
172
  if (typeof t != "object" || t === null) return;
173
173
  const e = t, s = e.kind;
174
174
  if (s === "snap")
@@ -189,9 +189,9 @@ const ye = {
189
189
  "ease-in-out": "cubic-in-out"
190
190
  };
191
191
  function Se(t, e) {
192
- y(() => {
192
+ T(() => {
193
193
  for (const s of e.patches) {
194
- const n = ke(s.transition);
194
+ const n = Te(s.transition);
195
195
  n !== void 0 ? t.setWithTransition(s.path, s.value, n) : t.set(s.path, s.value);
196
196
  }
197
197
  });
@@ -199,36 +199,36 @@ function Se(t, e) {
199
199
  function we(t, e) {
200
200
  t.reset(e.state);
201
201
  }
202
- class Te {
202
+ class _e {
203
203
  signals = /* @__PURE__ */ new Map();
204
204
  transitions = /* @__PURE__ */ new Map();
205
205
  signal(e) {
206
206
  let s = this.signals.get(e);
207
- return s || (s = d(void 0), this.signals.set(e, s)), s;
207
+ return s || (s = p(void 0), this.signals.set(e, s)), s;
208
208
  }
209
209
  transitionSignal(e) {
210
210
  let s = this.transitions.get(e);
211
- return s || (s = d(void 0), this.transitions.set(e, s)), s;
211
+ return s || (s = p(void 0), this.transitions.set(e, s)), s;
212
212
  }
213
213
  set(e, s) {
214
214
  const n = this.signal(e);
215
215
  k(n.peek(), s) || (n.value = s);
216
216
  }
217
217
  setWithTransition(e, s, n) {
218
- y(() => {
218
+ T(() => {
219
219
  const r = this.transitionSignal(e);
220
220
  r.peek() !== n && (r.value = n);
221
- const i = this.signal(e);
222
- k(i.peek(), s) || (i.value = s);
221
+ const o = this.signal(e);
222
+ k(o.peek(), s) || (o.value = s);
223
223
  });
224
224
  }
225
225
  reset(e) {
226
- y(() => {
226
+ T(() => {
227
227
  const s = /* @__PURE__ */ new Set();
228
228
  for (const [n, r] of Object.entries(e)) {
229
229
  s.add(n);
230
- const i = this.signal(n);
231
- k(i.peek(), r) || (i.value = r);
230
+ const o = this.signal(n);
231
+ k(o.peek(), r) || (o.value = r);
232
232
  const c = this.transitions.get(n);
233
233
  c && c.peek() !== void 0 && (c.value = void 0);
234
234
  }
@@ -246,8 +246,8 @@ class Te {
246
246
  return e;
247
247
  }
248
248
  }
249
- function _e() {
250
- return new Te();
249
+ function Ee() {
250
+ return new _e();
251
251
  }
252
252
  function k(t, e) {
253
253
  if (t === e) return !0;
@@ -258,20 +258,20 @@ function k(t, e) {
258
258
  if (t[c] !== e[c]) return !1;
259
259
  return !0;
260
260
  }
261
- const s = t, n = e, r = Object.keys(s), i = Object.keys(n);
262
- if (r.length !== i.length) return !1;
261
+ const s = t, n = e, r = Object.keys(s), o = Object.keys(n);
262
+ if (r.length !== o.length) return !1;
263
263
  for (const c of r)
264
264
  if (s[c] !== n[c]) return !1;
265
265
  return !0;
266
266
  }
267
- const Ee = /* @__PURE__ */ new Set([
267
+ const Ie = /* @__PURE__ */ new Set([
268
268
  "x-lumencast.color-srgb-1.0"
269
- ]), Ie = /^x-[a-z0-9-]+(?:\.[a-z0-9-]+)*$/, Re = /^(?:0|[1-9][0-9]*)$/, N = ".authoring";
270
- function Ae(t) {
269
+ ]), Re = /^x-[a-z0-9-]+(?:\.[a-z0-9-]+)*$/, Ae = /^(?:0|[1-9][0-9]*)$/, N = ".authoring";
270
+ function Oe(t) {
271
271
  const e = t.indexOf("/");
272
272
  if (e < 0) return !1;
273
273
  const s = t.slice(0, e), n = t.slice(e + 1);
274
- return !Re.test(n) || !s.endsWith(N) ? !1 : Ie.test(s.slice(0, -N.length));
274
+ return !Ae.test(n) || !s.endsWith(N) ? !1 : Re.test(s.slice(0, -N.length));
275
275
  }
276
276
  class L extends Error {
277
277
  code = "BUNDLE_INCOMPATIBLE";
@@ -284,24 +284,34 @@ class L extends Error {
284
284
  ), this.name = "BundleIncompatibleError", this.unsupportedProfiles = e;
285
285
  }
286
286
  }
287
- function U(t, e = Ee) {
287
+ function U(t, e = Ie) {
288
288
  const s = t.profiles;
289
289
  if (!s) return;
290
290
  if (!Array.isArray(s))
291
291
  throw new L(["<malformed: profiles is not an array>"]);
292
292
  if (s.length === 0) return;
293
- const n = s.filter((r) => typeof r != "string" || !Ae(r) && !e.has(r)).map((r) => typeof r == "string" ? r : "<malformed: non-string profile entry>");
293
+ const n = s.filter((r) => typeof r != "string" || !Oe(r) && !e.has(r)).map((r) => typeof r == "string" ? r : "<malformed: non-string profile entry>");
294
294
  if (n.length > 0)
295
295
  throw new L(n);
296
296
  }
297
- class Oe {
297
+ class Ne {
298
298
  cache = /* @__PURE__ */ new Map();
299
299
  baseUrl;
300
300
  pathPrefix;
301
301
  resolveUrl;
302
+ getAuthToken;
302
303
  fetchImpl;
303
304
  constructor(e) {
304
- this.baseUrl = e.baseUrl.replace(/\/$/, ""), this.pathPrefix = (e.pathPrefix ?? "/lsdp/v1/scenes").replace(/\/$/, ""), this.resolveUrl = e.resolveUrl, this.fetchImpl = e.fetchImpl ?? globalThis.fetch.bind(globalThis);
305
+ this.baseUrl = e.baseUrl.replace(/\/$/, ""), this.pathPrefix = (e.pathPrefix ?? "/lsdp/v1/scenes").replace(/\/$/, ""), this.resolveUrl = e.resolveUrl, this.getAuthToken = e.getAuthToken, this.fetchImpl = e.fetchImpl ?? globalThis.fetch.bind(globalThis);
306
+ }
307
+ /** Build the request init carrying the bearer token, if any. Returns
308
+ * `undefined` when no token is available — the fetch stays header-less,
309
+ * preserving v0.5.0 behaviour. */
310
+ async buildInit() {
311
+ if (!this.getAuthToken) return;
312
+ const e = await this.getAuthToken();
313
+ if (e)
314
+ return { headers: { Authorization: `Bearer ${e}` } };
305
315
  }
306
316
  buildUrl(e, s) {
307
317
  return this.resolveUrl ? this.resolveUrl(e, s) : `${this.baseUrl}${this.pathPrefix}/${encodeURIComponent(e)}/bundle?v=${encodeURIComponent(s)}`;
@@ -312,27 +322,27 @@ class Oe {
312
322
  async get(e, s) {
313
323
  const n = this.cache.get(s);
314
324
  if (n) return n;
315
- const r = this.buildUrl(e, s), i = await this.fetchImpl(r);
316
- if (!i.ok)
317
- throw new Error(`bundle fetch failed: ${i.status} ${i.statusText}`);
318
- const c = await i.json();
319
- if (c.scene_version !== s)
325
+ const r = this.buildUrl(e, s), o = await this.buildInit(), c = o ? await this.fetchImpl(r, o) : await this.fetchImpl(r);
326
+ if (!c.ok)
327
+ throw new Error(`bundle fetch failed: ${c.status} ${c.statusText}`);
328
+ const a = await c.json();
329
+ if (a.scene_version !== s)
320
330
  throw new Error(
321
- `bundle scene_version mismatch: expected ${s}, got ${c.scene_version}`
331
+ `bundle scene_version mismatch: expected ${s}, got ${a.scene_version}`
322
332
  );
323
- return U(c), this.cache.set(s, c), c;
333
+ return U(a), this.cache.set(s, a), a;
324
334
  }
325
335
  }
326
- function Ne(t) {
327
- return new Oe(t);
336
+ function Le(t) {
337
+ return new Ne(t);
328
338
  }
329
- const p = {
339
+ const g = {
330
340
  initial: 200,
331
341
  max: 5e3,
332
342
  factor: 2,
333
343
  jitter: 0.2
334
344
  };
335
- class Le {
345
+ class Ue {
336
346
  constructor(e, s) {
337
347
  this.opts = e, this.random = s;
338
348
  }
@@ -356,20 +366,20 @@ class Le {
356
366
  this._attempt = 0;
357
367
  }
358
368
  }
359
- function Ue(t = {}) {
369
+ function xe(t = {}) {
360
370
  const e = {
361
- initial: t.initial ?? p.initial,
362
- max: t.max ?? p.max,
363
- factor: t.factor ?? p.factor,
364
- jitter: t.jitter ?? p.jitter
371
+ initial: t.initial ?? g.initial,
372
+ max: t.max ?? g.max,
373
+ factor: t.factor ?? g.factor,
374
+ jitter: t.jitter ?? g.jitter
365
375
  };
366
376
  if (e.initial <= 0) throw new RangeError("initial must be > 0");
367
377
  if (e.max < e.initial) throw new RangeError("max must be >= initial");
368
378
  if (e.factor < 1) throw new RangeError("factor must be >= 1");
369
379
  if (e.jitter < 0 || e.jitter > 1) throw new RangeError("jitter must be within [0, 1]");
370
- return new Le(e, t.random ?? Math.random);
380
+ return new Ue(e, t.random ?? Math.random);
371
381
  }
372
- class u extends Error {
382
+ class h extends Error {
373
383
  recoverable;
374
384
  code;
375
385
  cause;
@@ -377,14 +387,14 @@ class u extends Error {
377
387
  super(e), this.name = "TransportError", this.recoverable = s, this.code = n, this.cause = r;
378
388
  }
379
389
  }
380
- class xe {
390
+ class Me {
381
391
  status = "disconnected";
382
392
  socket = null;
383
393
  token;
384
394
  url;
385
395
  WebSocketCtor;
386
396
  schedule;
387
- seq = new K();
397
+ seq = new J();
388
398
  opts;
389
399
  scheduler;
390
400
  reconnectTimer = null;
@@ -396,7 +406,7 @@ class xe {
396
406
  throw new TypeError(
397
407
  "Lumencast WsClient: no WebSocket implementation found in this environment"
398
408
  );
399
- this.WebSocketCtor = s, this.schedule = Ue(e.reconnect), this.scheduler = e.scheduler ?? {
409
+ this.WebSocketCtor = s, this.schedule = xe(e.reconnect), this.scheduler = e.scheduler ?? {
400
410
  setTimeout: globalThis.setTimeout.bind(globalThis),
401
411
  clearTimeout: globalThis.clearTimeout.bind(globalThis)
402
412
  };
@@ -405,9 +415,16 @@ class xe {
405
415
  start() {
406
416
  this.active && (this.socket || this.status === "connecting" || this.openSocket());
407
417
  }
418
+ /** Resolve the current session token (the one used for the WS
419
+ * subscription). Mirrors `setToken` swaps. Used by the bundle fetcher to
420
+ * authenticate the render-bundle GET with the same credential. A
421
+ * `LumencastTokenProvider` is awaited. */
422
+ resolveCurrentToken() {
423
+ return x(this.token);
424
+ }
408
425
  /** Send `input` patches to the server. No-op if not connected. */
409
426
  sendInput(e) {
410
- !this.socket || this.socket.readyState !== this.WebSocketCtor.OPEN || e.length !== 0 && this.socket.send(R(J(e)));
427
+ !this.socket || this.socket.readyState !== this.WebSocketCtor.OPEN || e.length !== 0 && this.socket.send(R(Q(e)));
411
428
  }
412
429
  /** Replace the auth token. Closes and reopens with the new token. */
413
430
  setToken(e) {
@@ -423,10 +440,10 @@ class xe {
423
440
  this.setStatus("connecting");
424
441
  let e;
425
442
  try {
426
- e = await Me(this.token);
443
+ e = await x(this.token);
427
444
  } catch (n) {
428
445
  this.opts.onTransportError?.(
429
- new u(
446
+ new h(
430
447
  `failed to resolve token: ${n.message}`,
431
448
  !0,
432
449
  "AUTH_DENIED",
@@ -438,10 +455,10 @@ class xe {
438
455
  if (!this.active) return;
439
456
  let s;
440
457
  try {
441
- s = new this.WebSocketCtor(this.url, [...Q]);
458
+ s = new this.WebSocketCtor(this.url, [...Z]);
442
459
  } catch (n) {
443
460
  this.opts.onTransportError?.(
444
- new u(
461
+ new h(
445
462
  `failed to open WebSocket: ${n.message}`,
446
463
  !0,
447
464
  "INTERNAL",
@@ -454,25 +471,25 @@ class xe {
454
471
  }
455
472
  handleOpen(e) {
456
473
  if (!this.socket) return;
457
- const n = this.socket.protocol === Z && this.seq.last > 0, r = n ? this.seq.last : void 0;
474
+ const n = this.socket.protocol === V && this.seq.last > 0, r = n ? this.seq.last : void 0;
458
475
  n || this.seq.reset();
459
- const i = V({
476
+ const o = ee({
460
477
  token: e,
461
478
  ...this.opts.scene !== void 0 ? { scene: this.opts.scene } : {},
462
479
  ...this.opts.session !== void 0 ? { session: this.opts.session } : {},
463
480
  ...r !== void 0 ? { since_sequence: r } : {}
464
481
  });
465
- this.socket.send(R(i));
482
+ this.socket.send(R(o));
466
483
  }
467
484
  handleMessage(e) {
468
485
  const s = typeof e.data == "string" ? e.data : "";
469
486
  if (!s) return;
470
487
  let n;
471
488
  try {
472
- n = ee(s);
489
+ n = te(s);
473
490
  } catch (r) {
474
- const i = (r instanceof A, r.message), c = r instanceof A ? r.code : "INTERNAL";
475
- this.opts.onTransportError?.(new u(`codec: ${i}`, !0, c, r)), this.closeSocket(), this.scheduleReconnect();
491
+ const o = (r instanceof A, r.message), c = r instanceof A ? r.code : "INTERNAL";
492
+ this.opts.onTransportError?.(new h(`codec: ${o}`, !0, c, r)), this.closeSocket(), this.scheduleReconnect();
476
493
  return;
477
494
  }
478
495
  if (n !== null)
@@ -480,7 +497,7 @@ class xe {
480
497
  case "snapshot": {
481
498
  if (n.seq < 1) {
482
499
  this.opts.onTransportError?.(
483
- new u(`snapshot seq must be >= 1, got ${n.seq}`, !0, "VERSION_GAP")
500
+ new h(`snapshot seq must be >= 1, got ${n.seq}`, !0, "VERSION_GAP")
484
501
  ), this.closeSocket(), this.scheduleReconnect();
485
502
  return;
486
503
  }
@@ -491,7 +508,7 @@ class xe {
491
508
  const r = this.seq.observe(n.seq);
492
509
  if (r.kind === "gap") {
493
510
  this.opts.onTransportError?.(
494
- new u(
511
+ new h(
495
512
  `sequence gap: expected ${this.seq.last + 1}, got ${n.seq}`,
496
513
  !0,
497
514
  "VERSION_GAP"
@@ -524,7 +541,7 @@ class xe {
524
541
  }
525
542
  if (e.code === 4401 || e.code === 4403 || e.code === 1008) {
526
543
  this.opts.onTransportError?.(
527
- new u(`server closed: ${e.code} ${e.reason}`, !1, "AUTH_DENIED")
544
+ new h(`server closed: ${e.code} ${e.reason}`, !1, "AUTH_DENIED")
528
545
  ), this.close();
529
546
  return;
530
547
  }
@@ -554,7 +571,7 @@ class xe {
554
571
  this.status !== e && (this.status = e, this.opts.onStatus?.(e));
555
572
  }
556
573
  }
557
- async function Me(t) {
574
+ async function x(t) {
558
575
  return typeof t == "string" ? t : await t.fetch();
559
576
  }
560
577
  function Pe(t) {
@@ -571,94 +588,95 @@ function Pe(t) {
571
588
  }
572
589
  function Ve(t) {
573
590
  Pe(t), t.onStatus?.("disconnected");
574
- const e = _e(), s = je(t.serverUrl), n = Ne({
591
+ const e = Ee(), s = je(t.serverUrl), n = Le({
575
592
  baseUrl: s,
576
- ...t.resolveBundleUrl !== void 0 ? { resolveUrl: t.resolveBundleUrl } : {}
577
- }), r = d(null), i = d("disconnected"), c = d("__initial__"), b = (o) => {
578
- i.value = o, t.onStatus?.(o);
579
- }, f = (o) => {
580
- t.onError?.(o);
593
+ ...t.resolveBundleUrl !== void 0 ? { resolveUrl: t.resolveBundleUrl } : {},
594
+ getAuthToken: () => m.resolveCurrentToken()
595
+ }), r = p(null), o = p("disconnected"), c = p("__initial__"), a = (i) => {
596
+ o.value = i, t.onStatus?.(i);
597
+ }, d = (i) => {
598
+ t.onError?.(i);
581
599
  };
582
- let a = !0;
583
- const $ = t.onDiagnostic ? ce(t.onDiagnostic) : void 0, m = new xe({
600
+ let l = !0;
601
+ const j = t.onDiagnostic ? ae(t.onDiagnostic) : void 0, m = new Me({
584
602
  url: t.serverUrl,
585
603
  token: t.token,
586
604
  ...t.scene !== void 0 ? { scene: t.scene } : {},
587
605
  ...t.testSession !== void 0 ? { session: t.testSession } : {},
588
- onStatus: b,
589
- onSnapshot: (o) => {
590
- a && (j(
606
+ onStatus: a,
607
+ onSnapshot: (i) => {
608
+ l && (C(
591
609
  n,
592
610
  r,
593
611
  c,
594
- o.scene_id,
595
- o.scene_version,
596
- () => we(e, o),
597
- f
612
+ i.scene_id,
613
+ i.scene_version,
614
+ () => we(e, i),
615
+ d
598
616
  ), t.onMetric?.({
599
617
  name: "snapshot_received",
600
- scene_id: o.scene_id,
601
- path_count: Object.keys(o.state).length
618
+ scene_id: i.scene_id,
619
+ path_count: Object.keys(i.state).length
602
620
  }));
603
621
  },
604
- onDelta: (o) => {
605
- if (!a) return;
622
+ onDelta: (i) => {
623
+ if (!l) return;
606
624
  const v = performance.now();
607
- Se(e, o), t.onMetric?.({
625
+ Se(e, i), t.onMetric?.({
608
626
  name: "delta_applied",
609
627
  duration_ms: performance.now() - v
610
- }), t.onMetric?.({ name: "delta_received", count: 1, path_count: o.patches.length });
628
+ }), t.onMetric?.({ name: "delta_received", count: 1, path_count: i.patches.length });
611
629
  },
612
- onSceneChanged: (o) => {
613
- a && t.onMetric?.({
630
+ onSceneChanged: (i) => {
631
+ l && t.onMetric?.({
614
632
  name: "scene_changed",
615
633
  from: r.value?.scene_version ?? null,
616
- to: o.scene_version
634
+ to: i.scene_version
617
635
  });
618
636
  },
619
- onServerError: (o) => {
620
- f({
621
- code: o.code,
622
- message: o.message,
623
- recoverable: o.recoverable
637
+ onServerError: (i) => {
638
+ d({
639
+ code: i.code,
640
+ message: i.message,
641
+ recoverable: i.recoverable
624
642
  });
625
643
  },
626
- onTransportError: (o) => {
627
- f($e(o));
644
+ onTransportError: (i) => {
645
+ d($e(i));
628
646
  }
629
647
  });
630
648
  m.start();
631
- const w = q(t.target);
632
- return w.render(
633
- z(ie, {
649
+ const S = B(t.target);
650
+ return S.render(
651
+ G(oe, {
634
652
  mode: t.mode,
635
653
  store: e,
636
654
  bundleSignal: r,
637
- statusSignal: i,
655
+ statusSignal: o,
638
656
  crossfadeKeySignal: c,
639
- sendInput: (o) => m.sendInput(o)
657
+ sendInput: (i) => m.sendInput(i)
640
658
  })
641
659
  ), {
642
660
  disconnect() {
643
- a && (a = !1, $?.(), m.close(), w.unmount());
661
+ l && (l = !1, j?.(), m.close(), S.unmount());
644
662
  },
645
- setToken(o) {
646
- a && m.setToken(o);
663
+ setToken(i) {
664
+ l && m.setToken(i);
647
665
  }
648
666
  };
649
- async function j(o, v, C, T, _, D, F) {
667
+ async function C(i, v, D, w, _, F, q) {
650
668
  let E;
651
669
  try {
652
- E = await o.get(T, _);
670
+ E = await i.get(w, _);
653
671
  } catch (I) {
654
- F({
672
+ q({
655
673
  code: "BUNDLE_FETCH_FAILED",
656
674
  message: I instanceof Error ? I.message : "render bundle fetch failed",
657
675
  recoverable: !0
658
676
  });
659
677
  return;
660
678
  }
661
- a && (D(), v.value = E, C.value = `${T}::${_}`);
679
+ l && (F(), v.value = E, D.value = `${w}::${_}`);
662
680
  }
663
681
  }
664
682
  function $e(t) {
@@ -677,13 +695,13 @@ function je(t) {
677
695
  }
678
696
  }
679
697
  const Ce = ["visible", "opacity", "universal_opacity", "rotation", "sizing"];
680
- function l(t) {
698
+ function u(t) {
681
699
  return /* @__PURE__ */ new Set([...Ce, ...t]);
682
700
  }
683
701
  const De = {
684
- stack: l(["direction", "gap", "wrap", "crossGap", "align", "justify"]),
685
- grid: l(["cols", "rows", "gap"]),
686
- frame: l([
702
+ stack: u(["direction", "gap", "wrap", "crossGap", "align", "justify"]),
703
+ grid: u(["cols", "rows", "gap"]),
704
+ frame: u([
687
705
  "x",
688
706
  "y",
689
707
  "width",
@@ -694,7 +712,7 @@ const De = {
694
712
  "backgrounds",
695
713
  "clipsContent"
696
714
  ]),
697
- text: l([
715
+ text: u([
698
716
  "value",
699
717
  "size",
700
718
  "font",
@@ -708,8 +726,8 @@ const De = {
708
726
  "fontStyle",
709
727
  "maxLines"
710
728
  ]),
711
- image: l(["src", "alt", "fit", "position", "width", "height"]),
712
- shape: l([
729
+ image: u(["src", "alt", "fit", "position", "width", "height"]),
730
+ shape: u([
713
731
  "geometry",
714
732
  "kind",
715
733
  "width",
@@ -724,8 +742,8 @@ const De = {
724
742
  "paths",
725
743
  "ariaLabel"
726
744
  ]),
727
- media: l(["src", "loop", "mute", "autoplay", "fit"]),
728
- instance: l(["scene_id", "scene_version", "size", "position"]),
745
+ media: u(["src", "loop", "mute", "autoplay", "fit"]),
746
+ instance: u(["scene_id", "scene_version", "size", "position"]),
729
747
  // `repeat` is dispatched specially by the tree ; its only consumed
730
748
  // binding is `items`.
731
749
  repeat: /* @__PURE__ */ new Set(["items"])
@@ -734,39 +752,39 @@ function Fe(t, e) {
734
752
  const s = De[t];
735
753
  return !!(s === void 0 || s.has(e) || t === "instance" && (e === "params" || e.startsWith("params.")));
736
754
  }
737
- const x = /* @__PURE__ */ new WeakSet();
755
+ const M = /* @__PURE__ */ new WeakSet();
738
756
  function et(t) {
739
- if (x.has(t)) return;
740
- x.add(t);
757
+ if (M.has(t)) return;
758
+ M.add(t);
741
759
  const e = /* @__PURE__ */ new Set([
742
760
  ...Object.keys(t.props ?? {}),
743
761
  ...Object.keys(t.bindings ?? {})
744
762
  ]);
745
763
  for (const s of e)
746
- Fe(t.kind, s) || P(
764
+ Fe(t.kind, s) || $(
747
765
  t.id,
748
766
  `${t.kind}.${s}`,
749
767
  "is not consumed by this primitive's renderer ; the prop is ignored (anti-silent-drop, ADR 001 §3.4)"
750
768
  );
751
769
  }
752
770
  export {
753
- oe as A,
771
+ ce as A,
754
772
  L as B,
755
773
  Ke as F,
756
774
  De as P,
757
- Ee as S,
775
+ Ie as S,
758
776
  et as a,
759
- ce as b,
777
+ ae as b,
760
778
  O as c,
761
779
  Ve as d,
762
- P as e,
763
- Ae as i,
780
+ $ as e,
781
+ Oe as i,
764
782
  Ze as m,
765
783
  Qe as r,
766
- de as s,
784
+ me as s,
767
785
  Je as t,
768
786
  Ye as u,
769
787
  U as v,
770
- me as w
788
+ pe as w
771
789
  };
772
- //# sourceMappingURL=index-CyOlpZAL.js.map
790
+ //# sourceMappingURL=index-Crkij3C4.js.map