@lumencast/runtime 0.7.0 → 0.8.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.
- package/dist/.tsbuildinfo +1 -1
- package/dist/{broadcast-DUYqvcgo.js → broadcast-Gcd-dmC7.js} +3 -3
- package/dist/{broadcast-DUYqvcgo.js.map → broadcast-Gcd-dmC7.js.map} +1 -1
- package/dist/{control-CL8TWXaE.js → control-C5TfClga.js} +4 -4
- package/dist/{control-CL8TWXaE.js.map → control-C5TfClga.js.map} +1 -1
- package/dist/{index-C6viWFcT.js → index-N-VqrIxN.js} +288 -209
- package/dist/index-N-VqrIxN.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.html +1 -1
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -1
- package/dist/lumencast.js +14 -9
- package/dist/render/asset-resolve.d.ts +27 -0
- package/dist/render/asset-resolve.d.ts.map +1 -0
- package/dist/render/asset-resolve.js +86 -0
- package/dist/render/asset-resolve.js.map +1 -0
- package/dist/render/headless.d.ts +39 -0
- package/dist/render/headless.d.ts.map +1 -0
- package/dist/render/headless.js +83 -0
- package/dist/render/headless.js.map +1 -0
- package/dist/render/primitives/media.d.ts +11 -2
- package/dist/render/primitives/media.d.ts.map +1 -1
- package/dist/render/primitives/media.js +14 -3
- package/dist/render/primitives/media.js.map +1 -1
- package/dist/{status-pill-jJT54n07.js → status-pill-BaLQoIDl.js} +2 -2
- package/dist/{status-pill-jJT54n07.js.map → status-pill-BaLQoIDl.js.map} +1 -1
- package/dist/{test-84XodL1c.js → test-CA30C2By.js} +4 -4
- package/dist/{test-84XodL1c.js.map → test-CA30C2By.js.map} +1 -1
- package/dist/{tree-BIimahCf.js → tree-1coZ32nd.js} +103 -103
- package/dist/tree-1coZ32nd.js.map +1 -0
- package/package.json +6 -5
- package/src/index.ts +24 -0
- package/src/render/asset-resolve.ts +97 -0
- package/src/render/headless.tsx +129 -0
- package/src/render/primitives/media.tsx +14 -3
- package/dist/index-C6viWFcT.js.map +0 -1
- package/dist/tree-BIimahCf.js.map +0 -1
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
import { batch as
|
|
2
|
-
import { createRoot as
|
|
3
|
-
import { createContext as
|
|
4
|
-
import { jsx as
|
|
5
|
-
import { useSignals as
|
|
6
|
-
import { AnimatePresence as
|
|
7
|
-
import { SequenceTracker as
|
|
8
|
-
const
|
|
9
|
-
function
|
|
1
|
+
import { batch as w, signal as p } from "@preact/signals-react";
|
|
2
|
+
import { createRoot as $ } from "react-dom/client";
|
|
3
|
+
import { createContext as Y, useContext as K, lazy as S, Suspense as Z, createElement as J, StrictMode as Q } from "react";
|
|
4
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
5
|
+
import { useSignals as V } from "@preact/signals-react/runtime";
|
|
6
|
+
import { AnimatePresence as ee, motion as te } from "framer-motion";
|
|
7
|
+
import { SequenceTracker as se, encodeFrame as R, input as ne, WS_SUBPROTOCOLS as re, WS_SUBPROTOCOL_V1_1 as ie, subscribe as oe, decodeServerFrame as ce, LumencastError as O } from "@lumencast/protocol";
|
|
8
|
+
const D = Y(null);
|
|
9
|
+
function F({
|
|
10
10
|
value: t,
|
|
11
11
|
children: e
|
|
12
12
|
}) {
|
|
13
|
-
return /* @__PURE__ */
|
|
13
|
+
return /* @__PURE__ */ l(D.Provider, { value: t, children: e });
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
const t =
|
|
15
|
+
function Ve() {
|
|
16
|
+
const t = K(D);
|
|
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
|
|
24
|
-
() => import("./broadcast-
|
|
25
|
-
),
|
|
26
|
-
() => import("./control-
|
|
27
|
-
),
|
|
28
|
-
function
|
|
23
|
+
const ae = S(
|
|
24
|
+
() => import("./broadcast-Gcd-dmC7.js").then((t) => ({ default: t.BroadcastMode }))
|
|
25
|
+
), ue = S(
|
|
26
|
+
() => import("./control-C5TfClga.js").then((t) => ({ default: t.ControlMode }))
|
|
27
|
+
), le = S(() => import("./test-CA30C2By.js").then((t) => ({ default: t.TestMode })));
|
|
28
|
+
function he({
|
|
29
29
|
mode: t,
|
|
30
30
|
store: e,
|
|
31
31
|
bundleSignal: s,
|
|
32
32
|
statusSignal: n,
|
|
33
33
|
crossfadeKeySignal: r,
|
|
34
|
-
sendInput:
|
|
34
|
+
sendInput: i
|
|
35
35
|
}) {
|
|
36
|
-
|
|
37
|
-
const c = s.value, a = n.value,
|
|
36
|
+
V();
|
|
37
|
+
const c = s.value, a = n.value, f = r.value;
|
|
38
38
|
if (!c) return null;
|
|
39
|
-
const
|
|
40
|
-
return /* @__PURE__ */
|
|
41
|
-
|
|
39
|
+
const u = t === "broadcast" ? ae : t === "control" ? ue : le;
|
|
40
|
+
return /* @__PURE__ */ l(ee, { mode: "sync", children: /* @__PURE__ */ l(
|
|
41
|
+
te.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__ */
|
|
49
|
-
|
|
48
|
+
children: /* @__PURE__ */ l(
|
|
49
|
+
F,
|
|
50
50
|
{
|
|
51
51
|
value: {
|
|
52
52
|
mode: t,
|
|
53
53
|
store: e,
|
|
54
54
|
bundle: c,
|
|
55
55
|
status: a,
|
|
56
|
-
sendInput:
|
|
56
|
+
sendInput: i
|
|
57
57
|
},
|
|
58
|
-
children: /* @__PURE__ */
|
|
58
|
+
children: /* @__PURE__ */ l(Z, { fallback: null, children: /* @__PURE__ */ l(u, {}) })
|
|
59
59
|
}
|
|
60
60
|
)
|
|
61
61
|
},
|
|
62
|
-
|
|
62
|
+
f
|
|
63
63
|
) });
|
|
64
64
|
}
|
|
65
|
-
const
|
|
66
|
-
function
|
|
67
|
-
return
|
|
68
|
-
|
|
65
|
+
const fe = "<anon>", v = /* @__PURE__ */ new Set();
|
|
66
|
+
function C(t) {
|
|
67
|
+
return v.add(t), () => {
|
|
68
|
+
v.delete(t);
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
|
-
function
|
|
72
|
-
const n = { nodeId: t ??
|
|
73
|
-
if (
|
|
74
|
-
for (const r of
|
|
71
|
+
function q(t, e, s) {
|
|
72
|
+
const n = { nodeId: t ?? fe, field: e, reason: s };
|
|
73
|
+
if (v.size > 0) {
|
|
74
|
+
for (const r of v)
|
|
75
75
|
try {
|
|
76
76
|
r(n);
|
|
77
77
|
} catch {
|
|
@@ -79,41 +79,41 @@ function $(t, e, s) {
|
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
const
|
|
83
|
-
blur:
|
|
84
|
-
brightness:
|
|
82
|
+
const de = 100, me = 4, pe = 64, ge = {
|
|
83
|
+
blur: de,
|
|
84
|
+
brightness: me
|
|
85
85
|
};
|
|
86
|
-
function
|
|
86
|
+
function L(t, e) {
|
|
87
87
|
if (typeof e != "number" || !Number.isFinite(e) || e < 0 || Object.is(e, -0)) return null;
|
|
88
|
-
const s =
|
|
88
|
+
const s = ge[t];
|
|
89
89
|
return e > s ? s : e;
|
|
90
90
|
}
|
|
91
|
-
const
|
|
92
|
-
function
|
|
93
|
-
if (typeof t != "string" || t.length === 0 || t.length >
|
|
94
|
-
const e =
|
|
91
|
+
const ve = /^blur\((\d{1,7}(?:\.\d{1,4})?)px\) brightness\((\d{1,7}(?:\.\d{1,4})?)\)$/, et = "blur(0px) brightness(1)";
|
|
92
|
+
function be(t) {
|
|
93
|
+
if (typeof t != "string" || t.length === 0 || t.length > pe) return null;
|
|
94
|
+
const e = ve.exec(t);
|
|
95
95
|
if (!e) return null;
|
|
96
|
-
const s =
|
|
96
|
+
const s = L("blur", Number(e[1])), n = L("brightness", Number(e[2]));
|
|
97
97
|
return s === null || n === null ? null : `blur(${s}px) brightness(${n})`;
|
|
98
98
|
}
|
|
99
|
-
function
|
|
100
|
-
|
|
99
|
+
function ye(t, e) {
|
|
100
|
+
q(
|
|
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
|
|
106
|
+
const ke = { duration: 0 }, we = {
|
|
107
107
|
linear: "linear",
|
|
108
108
|
"cubic-in": "easeIn",
|
|
109
109
|
"cubic-out": "easeOut",
|
|
110
110
|
"cubic-in-out": "easeInOut"
|
|
111
111
|
};
|
|
112
|
-
function
|
|
113
|
-
return !t || t.kind === "none" ?
|
|
112
|
+
function tt(t) {
|
|
113
|
+
return !t || t.kind === "none" ? ke : t.kind === "tween" ? {
|
|
114
114
|
type: "tween",
|
|
115
115
|
duration: (t.duration_ms ?? 0) / 1e3,
|
|
116
|
-
ease: t.ease ?
|
|
116
|
+
ease: t.ease ? we[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
|
|
128
|
+
const Se = {
|
|
129
129
|
opacity: 1,
|
|
130
130
|
scale: 1,
|
|
131
131
|
scaleX: 1,
|
|
@@ -137,12 +137,12 @@ const ve = {
|
|
|
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
|
-
},
|
|
140
|
+
}, Te = {
|
|
141
141
|
kind: "tween",
|
|
142
142
|
duration_ms: 400,
|
|
143
143
|
ease: "cubic-out"
|
|
144
144
|
};
|
|
145
|
-
function
|
|
145
|
+
function st(t, e, s) {
|
|
146
146
|
for (const n of e) {
|
|
147
147
|
const r = t(n);
|
|
148
148
|
if (r !== void 0) return r;
|
|
@@ -152,29 +152,29 @@ function Qe(t, e, s) {
|
|
|
152
152
|
const r = t(n);
|
|
153
153
|
if (r !== void 0) return r;
|
|
154
154
|
}
|
|
155
|
-
return
|
|
155
|
+
return Te;
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
|
-
function
|
|
158
|
+
function nt(t, e, s) {
|
|
159
159
|
if (!e || Object.keys(e).length === 0)
|
|
160
160
|
return { initial: t, animate: t };
|
|
161
161
|
let n = e;
|
|
162
162
|
if (e.filter !== void 0) {
|
|
163
|
-
const
|
|
164
|
-
n = { ...e },
|
|
163
|
+
const i = be(e.filter);
|
|
164
|
+
n = { ...e }, i === null ? (ye("animate_initial.filter", s), delete n.filter) : n.filter = i;
|
|
165
165
|
}
|
|
166
166
|
const r = { ...t };
|
|
167
|
-
for (const
|
|
168
|
-
|
|
167
|
+
for (const i of Object.keys(n))
|
|
168
|
+
i in r || (r[i] = Se[i] ?? 0);
|
|
169
169
|
return { initial: n, animate: r };
|
|
170
170
|
}
|
|
171
|
-
function
|
|
171
|
+
function _e(t) {
|
|
172
172
|
if (typeof t != "object" || t === null) return;
|
|
173
173
|
const e = t, s = e.kind;
|
|
174
174
|
if (s === "snap")
|
|
175
175
|
return { kind: "none" };
|
|
176
176
|
if (s === "tween") {
|
|
177
|
-
const n = typeof e.duration_ms == "number" ? e.duration_ms : 0, r =
|
|
177
|
+
const n = typeof e.duration_ms == "number" ? e.duration_ms : 0, r = Ee[e.easing] ?? "cubic-out";
|
|
178
178
|
return { kind: "tween", duration_ms: n, ease: r };
|
|
179
179
|
}
|
|
180
180
|
if (s === "spring") {
|
|
@@ -182,24 +182,24 @@ function ye(t) {
|
|
|
182
182
|
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;
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
|
-
const
|
|
185
|
+
const Ee = {
|
|
186
186
|
linear: "linear",
|
|
187
187
|
"ease-in": "cubic-in",
|
|
188
188
|
"ease-out": "cubic-out",
|
|
189
189
|
"ease-in-out": "cubic-in-out"
|
|
190
190
|
};
|
|
191
|
-
function
|
|
192
|
-
|
|
191
|
+
function Ie(t, e) {
|
|
192
|
+
w(() => {
|
|
193
193
|
for (const s of e.patches) {
|
|
194
|
-
const n =
|
|
194
|
+
const n = _e(s.transition);
|
|
195
195
|
n !== void 0 ? t.setWithTransition(s.path, s.value, n) : t.set(s.path, s.value);
|
|
196
196
|
}
|
|
197
197
|
});
|
|
198
198
|
}
|
|
199
|
-
function
|
|
199
|
+
function Ae(t, e) {
|
|
200
200
|
t.reset(e.state);
|
|
201
201
|
}
|
|
202
|
-
class
|
|
202
|
+
class Re {
|
|
203
203
|
signals = /* @__PURE__ */ new Map();
|
|
204
204
|
transitions = /* @__PURE__ */ new Map();
|
|
205
205
|
signal(e) {
|
|
@@ -215,20 +215,20 @@ class _e {
|
|
|
215
215
|
k(n.peek(), s) || (n.value = s);
|
|
216
216
|
}
|
|
217
217
|
setWithTransition(e, s, n) {
|
|
218
|
-
|
|
218
|
+
w(() => {
|
|
219
219
|
const r = this.transitionSignal(e);
|
|
220
220
|
r.peek() !== n && (r.value = n);
|
|
221
|
-
const
|
|
222
|
-
k(
|
|
221
|
+
const i = this.signal(e);
|
|
222
|
+
k(i.peek(), s) || (i.value = s);
|
|
223
223
|
});
|
|
224
224
|
}
|
|
225
225
|
reset(e) {
|
|
226
|
-
|
|
226
|
+
w(() => {
|
|
227
227
|
const s = /* @__PURE__ */ new Set();
|
|
228
228
|
for (const [n, r] of Object.entries(e)) {
|
|
229
229
|
s.add(n);
|
|
230
|
-
const
|
|
231
|
-
k(
|
|
230
|
+
const i = this.signal(n);
|
|
231
|
+
k(i.peek(), r) || (i.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 _e {
|
|
|
246
246
|
return e;
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
|
-
function
|
|
250
|
-
return new
|
|
249
|
+
function B() {
|
|
250
|
+
return new Re();
|
|
251
251
|
}
|
|
252
252
|
function k(t, e) {
|
|
253
253
|
if (t === e) return !0;
|
|
@@ -258,22 +258,22 @@ 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),
|
|
262
|
-
if (r.length !==
|
|
261
|
+
const s = t, n = e, r = Object.keys(s), i = Object.keys(n);
|
|
262
|
+
if (r.length !== i.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
|
|
267
|
+
const Oe = /* @__PURE__ */ new Set([
|
|
268
268
|
"x-lumencast.color-srgb-1.0"
|
|
269
|
-
]),
|
|
270
|
-
function
|
|
269
|
+
]), Le = /^x-[a-z0-9-]+(?:\.[a-z0-9-]+)*$/, Ne = /^(?:0|[1-9][0-9]*)$/, N = ".authoring";
|
|
270
|
+
function Ue(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 !
|
|
274
|
+
return !Ne.test(n) || !s.endsWith(N) ? !1 : Le.test(s.slice(0, -N.length));
|
|
275
275
|
}
|
|
276
|
-
class
|
|
276
|
+
class U extends Error {
|
|
277
277
|
code = "BUNDLE_INCOMPATIBLE";
|
|
278
278
|
unsupportedProfiles;
|
|
279
279
|
constructor(e) {
|
|
@@ -284,17 +284,17 @@ class L extends Error {
|
|
|
284
284
|
), this.name = "BundleIncompatibleError", this.unsupportedProfiles = e;
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
|
-
function
|
|
287
|
+
function x(t, e = Oe) {
|
|
288
288
|
const s = t.profiles;
|
|
289
289
|
if (!s) return;
|
|
290
290
|
if (!Array.isArray(s))
|
|
291
|
-
throw new
|
|
291
|
+
throw new U(["<malformed: profiles is not an array>"]);
|
|
292
292
|
if (s.length === 0) return;
|
|
293
|
-
const n = s.filter((r) => typeof r != "string" || !
|
|
293
|
+
const n = s.filter((r) => typeof r != "string" || !Ue(r) && !e.has(r)).map((r) => typeof r == "string" ? r : "<malformed: non-string profile entry>");
|
|
294
294
|
if (n.length > 0)
|
|
295
|
-
throw new
|
|
295
|
+
throw new U(n);
|
|
296
296
|
}
|
|
297
|
-
class
|
|
297
|
+
class xe {
|
|
298
298
|
cache = /* @__PURE__ */ new Map();
|
|
299
299
|
baseUrl;
|
|
300
300
|
pathPrefix;
|
|
@@ -317,12 +317,12 @@ class Ne {
|
|
|
317
317
|
return this.resolveUrl ? this.resolveUrl(e, s) : `${this.baseUrl}${this.pathPrefix}/${encodeURIComponent(e)}/bundle?v=${encodeURIComponent(s)}`;
|
|
318
318
|
}
|
|
319
319
|
preload(e) {
|
|
320
|
-
|
|
320
|
+
x(e), this.cache.set(e.scene_version, e);
|
|
321
321
|
}
|
|
322
322
|
async get(e, s) {
|
|
323
323
|
const n = this.cache.get(s);
|
|
324
324
|
if (n) return n;
|
|
325
|
-
const r = this.buildUrl(e, s),
|
|
325
|
+
const r = this.buildUrl(e, s), i = await this.buildInit(), c = i ? await this.fetchImpl(r, i) : await this.fetchImpl(r);
|
|
326
326
|
if (!c.ok)
|
|
327
327
|
throw new Error(`bundle fetch failed: ${c.status} ${c.statusText}`);
|
|
328
328
|
const a = await c.json();
|
|
@@ -330,11 +330,11 @@ class Ne {
|
|
|
330
330
|
throw new Error(
|
|
331
331
|
`bundle scene_version mismatch: expected ${s}, got ${a.scene_version}`
|
|
332
332
|
);
|
|
333
|
-
return
|
|
333
|
+
return x(a), this.cache.set(s, a), a;
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
|
-
function
|
|
337
|
-
return new
|
|
336
|
+
function Pe(t) {
|
|
337
|
+
return new xe(t);
|
|
338
338
|
}
|
|
339
339
|
const g = {
|
|
340
340
|
initial: 200,
|
|
@@ -342,7 +342,7 @@ const g = {
|
|
|
342
342
|
factor: 2,
|
|
343
343
|
jitter: 0.2
|
|
344
344
|
};
|
|
345
|
-
class
|
|
345
|
+
class je {
|
|
346
346
|
constructor(e, s) {
|
|
347
347
|
this.opts = e, this.random = s;
|
|
348
348
|
}
|
|
@@ -366,7 +366,7 @@ class Ue {
|
|
|
366
366
|
this._attempt = 0;
|
|
367
367
|
}
|
|
368
368
|
}
|
|
369
|
-
function
|
|
369
|
+
function Me(t = {}) {
|
|
370
370
|
const e = {
|
|
371
371
|
initial: t.initial ?? g.initial,
|
|
372
372
|
max: t.max ?? g.max,
|
|
@@ -377,9 +377,9 @@ function xe(t = {}) {
|
|
|
377
377
|
if (e.max < e.initial) throw new RangeError("max must be >= initial");
|
|
378
378
|
if (e.factor < 1) throw new RangeError("factor must be >= 1");
|
|
379
379
|
if (e.jitter < 0 || e.jitter > 1) throw new RangeError("jitter must be within [0, 1]");
|
|
380
|
-
return new
|
|
380
|
+
return new je(e, t.random ?? Math.random);
|
|
381
381
|
}
|
|
382
|
-
class
|
|
382
|
+
class m extends Error {
|
|
383
383
|
recoverable;
|
|
384
384
|
code;
|
|
385
385
|
cause;
|
|
@@ -387,14 +387,14 @@ class h extends Error {
|
|
|
387
387
|
super(e), this.name = "TransportError", this.recoverable = s, this.code = n, this.cause = r;
|
|
388
388
|
}
|
|
389
389
|
}
|
|
390
|
-
class
|
|
390
|
+
class $e {
|
|
391
391
|
status = "disconnected";
|
|
392
392
|
socket = null;
|
|
393
393
|
token;
|
|
394
394
|
url;
|
|
395
395
|
WebSocketCtor;
|
|
396
396
|
schedule;
|
|
397
|
-
seq = new
|
|
397
|
+
seq = new se();
|
|
398
398
|
opts;
|
|
399
399
|
scheduler;
|
|
400
400
|
reconnectTimer = null;
|
|
@@ -406,7 +406,7 @@ class Me {
|
|
|
406
406
|
throw new TypeError(
|
|
407
407
|
"Lumencast WsClient: no WebSocket implementation found in this environment"
|
|
408
408
|
);
|
|
409
|
-
this.WebSocketCtor = s, this.schedule =
|
|
409
|
+
this.WebSocketCtor = s, this.schedule = Me(e.reconnect), this.scheduler = e.scheduler ?? {
|
|
410
410
|
setTimeout: globalThis.setTimeout.bind(globalThis),
|
|
411
411
|
clearTimeout: globalThis.clearTimeout.bind(globalThis)
|
|
412
412
|
};
|
|
@@ -420,11 +420,11 @@ class Me {
|
|
|
420
420
|
* authenticate the render-bundle GET with the same credential. A
|
|
421
421
|
* `LumencastTokenProvider` is awaited. */
|
|
422
422
|
resolveCurrentToken() {
|
|
423
|
-
return
|
|
423
|
+
return P(this.token);
|
|
424
424
|
}
|
|
425
425
|
/** Send `input` patches to the server. No-op if not connected. */
|
|
426
426
|
sendInput(e) {
|
|
427
|
-
!this.socket || this.socket.readyState !== this.WebSocketCtor.OPEN || e.length !== 0 && this.socket.send(R(
|
|
427
|
+
!this.socket || this.socket.readyState !== this.WebSocketCtor.OPEN || e.length !== 0 && this.socket.send(R(ne(e)));
|
|
428
428
|
}
|
|
429
429
|
/** Replace the auth token. Closes and reopens with the new token. */
|
|
430
430
|
setToken(e) {
|
|
@@ -440,10 +440,10 @@ class Me {
|
|
|
440
440
|
this.setStatus("connecting");
|
|
441
441
|
let e;
|
|
442
442
|
try {
|
|
443
|
-
e = await
|
|
443
|
+
e = await P(this.token);
|
|
444
444
|
} catch (n) {
|
|
445
445
|
this.opts.onTransportError?.(
|
|
446
|
-
new
|
|
446
|
+
new m(
|
|
447
447
|
`failed to resolve token: ${n.message}`,
|
|
448
448
|
!0,
|
|
449
449
|
"AUTH_DENIED",
|
|
@@ -455,10 +455,10 @@ class Me {
|
|
|
455
455
|
if (!this.active) return;
|
|
456
456
|
let s;
|
|
457
457
|
try {
|
|
458
|
-
s = new this.WebSocketCtor(this.url, [...
|
|
458
|
+
s = new this.WebSocketCtor(this.url, [...re]);
|
|
459
459
|
} catch (n) {
|
|
460
460
|
this.opts.onTransportError?.(
|
|
461
|
-
new
|
|
461
|
+
new m(
|
|
462
462
|
`failed to open WebSocket: ${n.message}`,
|
|
463
463
|
!0,
|
|
464
464
|
"INTERNAL",
|
|
@@ -471,25 +471,25 @@ class Me {
|
|
|
471
471
|
}
|
|
472
472
|
handleOpen(e) {
|
|
473
473
|
if (!this.socket) return;
|
|
474
|
-
const n = this.socket.protocol ===
|
|
474
|
+
const n = this.socket.protocol === ie && this.seq.last > 0, r = n ? this.seq.last : void 0;
|
|
475
475
|
n || this.seq.reset();
|
|
476
|
-
const
|
|
476
|
+
const i = oe({
|
|
477
477
|
token: e,
|
|
478
478
|
...this.opts.scene !== void 0 ? { scene: this.opts.scene } : {},
|
|
479
479
|
...this.opts.session !== void 0 ? { session: this.opts.session } : {},
|
|
480
480
|
...r !== void 0 ? { since_sequence: r } : {}
|
|
481
481
|
});
|
|
482
|
-
this.socket.send(R(
|
|
482
|
+
this.socket.send(R(i));
|
|
483
483
|
}
|
|
484
484
|
handleMessage(e) {
|
|
485
485
|
const s = typeof e.data == "string" ? e.data : "";
|
|
486
486
|
if (!s) return;
|
|
487
487
|
let n;
|
|
488
488
|
try {
|
|
489
|
-
n =
|
|
489
|
+
n = ce(s);
|
|
490
490
|
} catch (r) {
|
|
491
|
-
const
|
|
492
|
-
this.opts.onTransportError?.(new
|
|
491
|
+
const i = (r instanceof O, r.message), c = r instanceof O ? r.code : "INTERNAL";
|
|
492
|
+
this.opts.onTransportError?.(new m(`codec: ${i}`, !0, c, r)), this.closeSocket(), this.scheduleReconnect();
|
|
493
493
|
return;
|
|
494
494
|
}
|
|
495
495
|
if (n !== null)
|
|
@@ -497,7 +497,7 @@ class Me {
|
|
|
497
497
|
case "snapshot": {
|
|
498
498
|
if (n.seq < 1) {
|
|
499
499
|
this.opts.onTransportError?.(
|
|
500
|
-
new
|
|
500
|
+
new m(`snapshot seq must be >= 1, got ${n.seq}`, !0, "VERSION_GAP")
|
|
501
501
|
), this.closeSocket(), this.scheduleReconnect();
|
|
502
502
|
return;
|
|
503
503
|
}
|
|
@@ -508,7 +508,7 @@ class Me {
|
|
|
508
508
|
const r = this.seq.observe(n.seq);
|
|
509
509
|
if (r.kind === "gap") {
|
|
510
510
|
this.opts.onTransportError?.(
|
|
511
|
-
new
|
|
511
|
+
new m(
|
|
512
512
|
`sequence gap: expected ${this.seq.last + 1}, got ${n.seq}`,
|
|
513
513
|
!0,
|
|
514
514
|
"VERSION_GAP"
|
|
@@ -541,7 +541,7 @@ class Me {
|
|
|
541
541
|
}
|
|
542
542
|
if (e.code === 4401 || e.code === 4403 || e.code === 1008) {
|
|
543
543
|
this.opts.onTransportError?.(
|
|
544
|
-
new
|
|
544
|
+
new m(`server closed: ${e.code} ${e.reason}`, !1, "AUTH_DENIED")
|
|
545
545
|
), this.close();
|
|
546
546
|
return;
|
|
547
547
|
}
|
|
@@ -571,10 +571,10 @@ class Me {
|
|
|
571
571
|
this.status !== e && (this.status = e, this.opts.onStatus?.(e));
|
|
572
572
|
}
|
|
573
573
|
}
|
|
574
|
-
async function
|
|
574
|
+
async function P(t) {
|
|
575
575
|
return typeof t == "string" ? t : await t.fetch();
|
|
576
576
|
}
|
|
577
|
-
function
|
|
577
|
+
function De(t) {
|
|
578
578
|
if (!(t.target instanceof HTMLElement))
|
|
579
579
|
throw new TypeError("mount: `target` must be an HTMLElement");
|
|
580
580
|
if (typeof t.serverUrl != "string" || t.serverUrl.length === 0)
|
|
@@ -586,107 +586,107 @@ function Pe(t) {
|
|
|
586
586
|
throw new TypeError("mount: `scene` is required when mode === 'test'");
|
|
587
587
|
}
|
|
588
588
|
}
|
|
589
|
-
function
|
|
590
|
-
|
|
591
|
-
const e =
|
|
589
|
+
function rt(t) {
|
|
590
|
+
De(t), t.onStatus?.("disconnected");
|
|
591
|
+
const e = B(), s = Ce(t.serverUrl), n = Pe({
|
|
592
592
|
baseUrl: s,
|
|
593
593
|
...t.resolveBundleUrl !== void 0 ? { resolveUrl: t.resolveBundleUrl } : {},
|
|
594
|
-
getAuthToken: () =>
|
|
595
|
-
}), r = p(null),
|
|
596
|
-
|
|
597
|
-
},
|
|
598
|
-
t.onError?.(
|
|
594
|
+
getAuthToken: () => d.resolveCurrentToken()
|
|
595
|
+
}), r = p(null), i = p("disconnected"), c = p("__initial__"), a = (o) => {
|
|
596
|
+
i.value = o, t.onStatus?.(o);
|
|
597
|
+
}, f = (o) => {
|
|
598
|
+
t.onError?.(o);
|
|
599
599
|
};
|
|
600
|
-
let
|
|
601
|
-
const
|
|
600
|
+
let u = !0;
|
|
601
|
+
const b = t.onDiagnostic ? C(t.onDiagnostic) : void 0, d = new $e({
|
|
602
602
|
url: t.serverUrl,
|
|
603
603
|
token: t.token,
|
|
604
604
|
...t.scene !== void 0 ? { scene: t.scene } : {},
|
|
605
605
|
...t.testSession !== void 0 ? { session: t.testSession } : {},
|
|
606
606
|
onStatus: a,
|
|
607
|
-
onSnapshot: (
|
|
608
|
-
|
|
607
|
+
onSnapshot: (o) => {
|
|
608
|
+
u && (z(
|
|
609
609
|
n,
|
|
610
610
|
r,
|
|
611
611
|
c,
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
() =>
|
|
615
|
-
|
|
612
|
+
o.scene_id,
|
|
613
|
+
o.scene_version,
|
|
614
|
+
() => Ae(e, o),
|
|
615
|
+
f
|
|
616
616
|
), t.onMetric?.({
|
|
617
617
|
name: "snapshot_received",
|
|
618
|
-
scene_id:
|
|
619
|
-
path_count: Object.keys(
|
|
618
|
+
scene_id: o.scene_id,
|
|
619
|
+
path_count: Object.keys(o.state).length
|
|
620
620
|
}));
|
|
621
621
|
},
|
|
622
|
-
onDelta: (
|
|
623
|
-
if (!
|
|
624
|
-
const
|
|
625
|
-
|
|
622
|
+
onDelta: (o) => {
|
|
623
|
+
if (!u) return;
|
|
624
|
+
const y = performance.now();
|
|
625
|
+
Ie(e, o), t.onMetric?.({
|
|
626
626
|
name: "delta_applied",
|
|
627
|
-
duration_ms: performance.now() -
|
|
628
|
-
}), t.onMetric?.({ name: "delta_received", count: 1, path_count:
|
|
627
|
+
duration_ms: performance.now() - y
|
|
628
|
+
}), t.onMetric?.({ name: "delta_received", count: 1, path_count: o.patches.length });
|
|
629
629
|
},
|
|
630
|
-
onSceneChanged: (
|
|
631
|
-
|
|
630
|
+
onSceneChanged: (o) => {
|
|
631
|
+
u && t.onMetric?.({
|
|
632
632
|
name: "scene_changed",
|
|
633
633
|
from: r.value?.scene_version ?? null,
|
|
634
|
-
to:
|
|
634
|
+
to: o.scene_version
|
|
635
635
|
});
|
|
636
636
|
},
|
|
637
|
-
onServerError: (
|
|
638
|
-
|
|
639
|
-
code:
|
|
640
|
-
message:
|
|
641
|
-
recoverable:
|
|
637
|
+
onServerError: (o) => {
|
|
638
|
+
f({
|
|
639
|
+
code: o.code,
|
|
640
|
+
message: o.message,
|
|
641
|
+
recoverable: o.recoverable
|
|
642
642
|
});
|
|
643
643
|
},
|
|
644
|
-
onTransportError: (
|
|
645
|
-
|
|
644
|
+
onTransportError: (o) => {
|
|
645
|
+
f(Fe(o));
|
|
646
646
|
}
|
|
647
647
|
});
|
|
648
|
-
|
|
649
|
-
const
|
|
650
|
-
return
|
|
651
|
-
|
|
648
|
+
d.start();
|
|
649
|
+
const T = $(t.target);
|
|
650
|
+
return T.render(
|
|
651
|
+
J(he, {
|
|
652
652
|
mode: t.mode,
|
|
653
653
|
store: e,
|
|
654
654
|
bundleSignal: r,
|
|
655
|
-
statusSignal:
|
|
655
|
+
statusSignal: i,
|
|
656
656
|
crossfadeKeySignal: c,
|
|
657
|
-
sendInput: (
|
|
657
|
+
sendInput: (o) => d.sendInput(o)
|
|
658
658
|
})
|
|
659
659
|
), {
|
|
660
660
|
disconnect() {
|
|
661
|
-
|
|
661
|
+
u && (u = !1, b?.(), d.close(), T.unmount());
|
|
662
662
|
},
|
|
663
|
-
setToken(
|
|
664
|
-
|
|
663
|
+
setToken(o) {
|
|
664
|
+
u && d.setToken(o);
|
|
665
665
|
}
|
|
666
666
|
};
|
|
667
|
-
async function
|
|
668
|
-
let
|
|
667
|
+
async function z(o, y, H, _, E, G, X) {
|
|
668
|
+
let I;
|
|
669
669
|
try {
|
|
670
|
-
|
|
671
|
-
} catch (
|
|
672
|
-
|
|
670
|
+
I = await o.get(_, E);
|
|
671
|
+
} catch (A) {
|
|
672
|
+
X({
|
|
673
673
|
code: "BUNDLE_FETCH_FAILED",
|
|
674
|
-
message:
|
|
674
|
+
message: A instanceof Error ? A.message : "render bundle fetch failed",
|
|
675
675
|
recoverable: !0
|
|
676
676
|
});
|
|
677
677
|
return;
|
|
678
678
|
}
|
|
679
|
-
|
|
679
|
+
u && (G(), y.value = I, H.value = `${_}::${E}`);
|
|
680
680
|
}
|
|
681
681
|
}
|
|
682
|
-
function
|
|
682
|
+
function Fe(t) {
|
|
683
683
|
return {
|
|
684
684
|
code: t.code,
|
|
685
685
|
message: t.message,
|
|
686
686
|
recoverable: t.recoverable
|
|
687
687
|
};
|
|
688
688
|
}
|
|
689
|
-
function
|
|
689
|
+
function Ce(t) {
|
|
690
690
|
try {
|
|
691
691
|
const e = new URL(t);
|
|
692
692
|
return `${e.protocol === "wss:" ? "https:" : "http:"}//${e.host}`;
|
|
@@ -694,7 +694,7 @@ function je(t) {
|
|
|
694
694
|
return "";
|
|
695
695
|
}
|
|
696
696
|
}
|
|
697
|
-
const
|
|
697
|
+
const qe = [
|
|
698
698
|
"visible",
|
|
699
699
|
"opacity",
|
|
700
700
|
"universal_opacity",
|
|
@@ -711,13 +711,13 @@ const Ce = [
|
|
|
711
711
|
// compiler and consumed by the Tree (built into a `<mask>` SVG element).
|
|
712
712
|
"mask"
|
|
713
713
|
];
|
|
714
|
-
function
|
|
715
|
-
return /* @__PURE__ */ new Set([...
|
|
714
|
+
function h(t) {
|
|
715
|
+
return /* @__PURE__ */ new Set([...qe, ...t]);
|
|
716
716
|
}
|
|
717
|
-
const
|
|
718
|
-
stack:
|
|
719
|
-
grid:
|
|
720
|
-
frame:
|
|
717
|
+
const Be = {
|
|
718
|
+
stack: h(["direction", "gap", "wrap", "crossGap", "align", "justify"]),
|
|
719
|
+
grid: h(["cols", "rows", "gap"]),
|
|
720
|
+
frame: h([
|
|
721
721
|
"x",
|
|
722
722
|
"y",
|
|
723
723
|
"width",
|
|
@@ -728,7 +728,7 @@ const De = {
|
|
|
728
728
|
"backgrounds",
|
|
729
729
|
"clipsContent"
|
|
730
730
|
]),
|
|
731
|
-
text:
|
|
731
|
+
text: h([
|
|
732
732
|
"value",
|
|
733
733
|
"size",
|
|
734
734
|
"font",
|
|
@@ -742,8 +742,8 @@ const De = {
|
|
|
742
742
|
"fontStyle",
|
|
743
743
|
"maxLines"
|
|
744
744
|
]),
|
|
745
|
-
image:
|
|
746
|
-
shape:
|
|
745
|
+
image: h(["src", "alt", "fit", "position", "width", "height"]),
|
|
746
|
+
shape: h([
|
|
747
747
|
"geometry",
|
|
748
748
|
"kind",
|
|
749
749
|
"width",
|
|
@@ -758,49 +758,128 @@ const De = {
|
|
|
758
758
|
"paths",
|
|
759
759
|
"ariaLabel"
|
|
760
760
|
]),
|
|
761
|
-
media:
|
|
762
|
-
instance:
|
|
761
|
+
media: h(["src", "loop", "mute", "autoplay", "fit"]),
|
|
762
|
+
instance: h(["scene_id", "scene_version", "size", "position"]),
|
|
763
763
|
// `repeat` is dispatched specially by the tree ; its only consumed
|
|
764
764
|
// binding is `items`.
|
|
765
765
|
repeat: /* @__PURE__ */ new Set(["items"])
|
|
766
766
|
};
|
|
767
|
-
function
|
|
768
|
-
const s =
|
|
767
|
+
function We(t, e) {
|
|
768
|
+
const s = Be[t];
|
|
769
769
|
return !!(s === void 0 || s.has(e) || t === "instance" && (e === "params" || e.startsWith("params.")));
|
|
770
770
|
}
|
|
771
|
-
const
|
|
772
|
-
function
|
|
773
|
-
if (
|
|
774
|
-
|
|
771
|
+
const j = /* @__PURE__ */ new WeakSet();
|
|
772
|
+
function it(t) {
|
|
773
|
+
if (j.has(t)) return;
|
|
774
|
+
j.add(t);
|
|
775
775
|
const e = /* @__PURE__ */ new Set([
|
|
776
776
|
...Object.keys(t.props ?? {}),
|
|
777
777
|
...Object.keys(t.bindings ?? {})
|
|
778
778
|
]);
|
|
779
779
|
for (const s of e)
|
|
780
|
-
|
|
780
|
+
We(t.kind, s) || q(
|
|
781
781
|
t.id,
|
|
782
782
|
`${t.kind}.${s}`,
|
|
783
783
|
"is not consumed by this primitive's renderer ; the prop is ignored (anti-silent-drop, ADR 001 §3.4)"
|
|
784
784
|
);
|
|
785
785
|
}
|
|
786
|
+
const ze = { width: 1920, height: 1080 }, He = () => {
|
|
787
|
+
};
|
|
788
|
+
function ot(t) {
|
|
789
|
+
const e = t.stage ?? ze, s = t.target;
|
|
790
|
+
s.style.position ||= "relative", s.style.width = `${e.width}px`, s.style.height = `${e.height}px`, s.style.overflow = "hidden";
|
|
791
|
+
const n = t.onDiagnostic ? C(t.onDiagnostic) : void 0, r = B();
|
|
792
|
+
r.reset(t.defaults ?? {});
|
|
793
|
+
const i = $(s);
|
|
794
|
+
return {
|
|
795
|
+
ready: new Promise((a) => {
|
|
796
|
+
import("./broadcast-Gcd-dmC7.js").then(({ BroadcastMode: f }) => {
|
|
797
|
+
i.render(
|
|
798
|
+
/* @__PURE__ */ l(Q, { children: /* @__PURE__ */ l(
|
|
799
|
+
F,
|
|
800
|
+
{
|
|
801
|
+
value: {
|
|
802
|
+
mode: "broadcast",
|
|
803
|
+
store: r,
|
|
804
|
+
bundle: t.bundle,
|
|
805
|
+
status: "live",
|
|
806
|
+
sendInput: He
|
|
807
|
+
},
|
|
808
|
+
children: /* @__PURE__ */ l(f, {})
|
|
809
|
+
}
|
|
810
|
+
) })
|
|
811
|
+
);
|
|
812
|
+
const u = new Promise((d) => {
|
|
813
|
+
requestAnimationFrame(() => requestAnimationFrame(() => d()));
|
|
814
|
+
}), b = typeof document < "u" && document.fonts ? document.fonts.ready.then(() => {
|
|
815
|
+
}) : Promise.resolve();
|
|
816
|
+
Promise.all([u, b]).then(() => a());
|
|
817
|
+
});
|
|
818
|
+
}),
|
|
819
|
+
unmount() {
|
|
820
|
+
n?.(), i.unmount();
|
|
821
|
+
}
|
|
822
|
+
};
|
|
823
|
+
}
|
|
824
|
+
function W(t, e) {
|
|
825
|
+
if (typeof t != "string") return t;
|
|
826
|
+
if (e[t]) return e[t];
|
|
827
|
+
const s = /^assets\/([A-Za-z0-9]+)\.[A-Za-z0-9]+$/.exec(t);
|
|
828
|
+
return s && s[1] !== void 0 && e[s[1]] ? e[s[1]] : t;
|
|
829
|
+
}
|
|
830
|
+
function M(t, e) {
|
|
831
|
+
if (t === null || typeof t != "object") return;
|
|
832
|
+
if (Array.isArray(t)) {
|
|
833
|
+
for (const n of t) M(n, e);
|
|
834
|
+
return;
|
|
835
|
+
}
|
|
836
|
+
const s = t;
|
|
837
|
+
"src" in s && (s.src = W(s.src, e));
|
|
838
|
+
for (const n of Object.values(s))
|
|
839
|
+
n && typeof n == "object" && M(n, e);
|
|
840
|
+
}
|
|
841
|
+
function ct(t, e) {
|
|
842
|
+
const s = { ...t };
|
|
843
|
+
for (const [n, r] of Object.entries(s))
|
|
844
|
+
n.startsWith("__lit.image.") && (s[n] = W(r, e));
|
|
845
|
+
return s;
|
|
846
|
+
}
|
|
847
|
+
async function at(t) {
|
|
848
|
+
const e = [];
|
|
849
|
+
for (const s of t)
|
|
850
|
+
try {
|
|
851
|
+
const n = new FontFace(s.family, s.src, {
|
|
852
|
+
weight: String(s.weight),
|
|
853
|
+
style: s.style ?? "normal"
|
|
854
|
+
});
|
|
855
|
+
await n.load(), document.fonts.add(n), e.push(s.family);
|
|
856
|
+
} catch {
|
|
857
|
+
}
|
|
858
|
+
return e;
|
|
859
|
+
}
|
|
786
860
|
export {
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
861
|
+
fe as A,
|
|
862
|
+
U as B,
|
|
863
|
+
et as F,
|
|
864
|
+
Be as P,
|
|
865
|
+
Oe as S,
|
|
866
|
+
it as a,
|
|
867
|
+
C as b,
|
|
868
|
+
L as c,
|
|
869
|
+
Ue as d,
|
|
870
|
+
q as e,
|
|
871
|
+
rt as f,
|
|
872
|
+
ot as g,
|
|
873
|
+
W as h,
|
|
874
|
+
at as i,
|
|
875
|
+
ct as j,
|
|
876
|
+
M as k,
|
|
877
|
+
nt as m,
|
|
878
|
+
st as r,
|
|
879
|
+
be as s,
|
|
880
|
+
tt as t,
|
|
881
|
+
Ve as u,
|
|
882
|
+
x as v,
|
|
883
|
+
ye as w
|
|
805
884
|
};
|
|
806
|
-
//# sourceMappingURL=index-
|
|
885
|
+
//# sourceMappingURL=index-N-VqrIxN.js.map
|