@lumencast/runtime 0.3.0 → 0.5.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/README.md +57 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/animate/frame-coalescer.d.ts +13 -0
- package/dist/animate/frame-coalescer.d.ts.map +1 -0
- package/dist/animate/frame-coalescer.js +46 -0
- package/dist/animate/frame-coalescer.js.map +1 -0
- package/dist/animate/keyframes.d.ts +1 -1
- package/dist/animate/keyframes.d.ts.map +1 -1
- package/dist/animate/keyframes.js +20 -6
- package/dist/animate/keyframes.js.map +1 -1
- package/dist/animate/transitions.d.ts +33 -1
- package/dist/animate/transitions.d.ts.map +1 -1
- package/dist/animate/transitions.js +78 -3
- package/dist/animate/transitions.js.map +1 -1
- package/dist/{broadcast-B82fQPph.js → broadcast-3vYij4k-.js} +3 -3
- package/dist/{broadcast-B82fQPph.js.map → broadcast-3vYij4k-.js.map} +1 -1
- package/dist/{control-DIfwMYRb.js → control-BFNkY7-6.js} +4 -4
- package/dist/{control-DIfwMYRb.js.map → control-BFNkY7-6.js.map} +1 -1
- package/dist/{index-BFZXQAD7.js → index-CyOlpZAL.js} +318 -145
- package/dist/index-CyOlpZAL.js.map +1 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.html +1 -1
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/dist/lumencast.js +9 -2
- package/dist/mount.d.ts.map +1 -1
- package/dist/mount.js +11 -1
- package/dist/mount.js.map +1 -1
- package/dist/render/bind-animate.d.ts +40 -0
- package/dist/render/bind-animate.d.ts.map +1 -0
- package/dist/render/bind-animate.js +329 -0
- package/dist/render/bind-animate.js.map +1 -0
- package/dist/render/bundle.d.ts +48 -6
- package/dist/render/bundle.d.ts.map +1 -1
- package/dist/render/bundle.js +71 -4
- package/dist/render/bundle.js.map +1 -1
- package/dist/render/color-interp.d.ts +18 -0
- package/dist/render/color-interp.d.ts.map +1 -0
- package/dist/render/color-interp.js +303 -0
- package/dist/render/color-interp.js.map +1 -0
- package/dist/render/css-color.d.ts +16 -0
- package/dist/render/css-color.d.ts.map +1 -0
- package/dist/render/css-color.js +130 -0
- package/dist/render/css-color.js.map +1 -0
- package/dist/render/diagnostics.d.ts +26 -0
- package/dist/render/diagnostics.d.ts.map +1 -0
- package/dist/render/diagnostics.js +58 -0
- package/dist/render/diagnostics.js.map +1 -0
- package/dist/render/fill.d.ts +15 -3
- package/dist/render/fill.d.ts.map +1 -1
- package/dist/render/fill.js +81 -14
- package/dist/render/fill.js.map +1 -1
- package/dist/render/filter-clamp.d.ts +35 -0
- package/dist/render/filter-clamp.d.ts.map +1 -0
- package/dist/render/filter-clamp.js +90 -0
- package/dist/render/filter-clamp.js.map +1 -0
- package/dist/render/keyframe-player.d.ts +4 -1
- package/dist/render/keyframe-player.d.ts.map +1 -1
- package/dist/render/keyframe-player.js +2 -2
- package/dist/render/keyframe-player.js.map +1 -1
- package/dist/render/primitives/frame.d.ts +16 -1
- package/dist/render/primitives/frame.d.ts.map +1 -1
- package/dist/render/primitives/frame.js +44 -13
- package/dist/render/primitives/frame.js.map +1 -1
- package/dist/render/primitives/image.d.ts +1 -1
- package/dist/render/primitives/image.d.ts.map +1 -1
- package/dist/render/primitives/image.js +8 -5
- package/dist/render/primitives/image.js.map +1 -1
- package/dist/render/primitives/index.d.ts +3 -0
- package/dist/render/primitives/index.d.ts.map +1 -1
- package/dist/render/primitives/index.js.map +1 -1
- package/dist/render/primitives/instance.d.ts +1 -1
- package/dist/render/primitives/instance.d.ts.map +1 -1
- package/dist/render/primitives/instance.js +10 -13
- package/dist/render/primitives/instance.js.map +1 -1
- package/dist/render/primitives/shape.d.ts +9 -3
- package/dist/render/primitives/shape.d.ts.map +1 -1
- package/dist/render/primitives/shape.js +58 -14
- package/dist/render/primitives/shape.js.map +1 -1
- package/dist/render/primitives/text.d.ts +35 -4
- package/dist/render/primitives/text.d.ts.map +1 -1
- package/dist/render/primitives/text.js +181 -9
- package/dist/render/primitives/text.js.map +1 -1
- package/dist/render/prop-allowlist.d.ts +10 -0
- package/dist/render/prop-allowlist.d.ts.map +1 -0
- package/dist/render/prop-allowlist.js +112 -0
- package/dist/render/prop-allowlist.js.map +1 -0
- package/dist/render/svg-path.d.ts +35 -0
- package/dist/render/svg-path.d.ts.map +1 -0
- package/dist/render/svg-path.js +211 -0
- package/dist/render/svg-path.js.map +1 -0
- package/dist/render/tree.d.ts.map +1 -1
- package/dist/render/tree.js +30 -5
- package/dist/render/tree.js.map +1 -1
- package/dist/{status-pill-DNHbHdag.js → status-pill-DIpXc5du.js} +2 -2
- package/dist/{status-pill-DNHbHdag.js.map → status-pill-DIpXc5du.js.map} +1 -1
- package/dist/{test-Dp0QrKYM.js → test-ByRec1kd.js} +4 -4
- package/dist/{test-Dp0QrKYM.js.map → test-ByRec1kd.js.map} +1 -1
- package/dist/tree-D5wYHpPu.js +1230 -0
- package/dist/tree-D5wYHpPu.js.map +1 -0
- package/dist/types.d.ts +26 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/animate/frame-coalescer.ts +63 -0
- package/src/animate/keyframes.ts +24 -5
- package/src/animate/transitions.ts +85 -3
- package/src/index.ts +24 -0
- package/src/mount.ts +12 -1
- package/src/render/bind-animate.tsx +370 -0
- package/src/render/bundle.ts +102 -10
- package/src/render/color-interp.ts +303 -0
- package/src/render/css-color.ts +145 -0
- package/src/render/diagnostics.ts +75 -0
- package/src/render/fill.tsx +85 -14
- package/src/render/filter-clamp.ts +99 -0
- package/src/render/keyframe-player.tsx +10 -2
- package/src/render/primitives/frame.tsx +53 -14
- package/src/render/primitives/image.tsx +8 -4
- package/src/render/primitives/index.ts +3 -0
- package/src/render/primitives/instance.tsx +14 -15
- package/src/render/primitives/shape.tsx +78 -14
- package/src/render/primitives/text.tsx +226 -9
- package/src/render/prop-allowlist.ts +119 -0
- package/src/render/svg-path.ts +215 -0
- package/src/render/tree.tsx +41 -6
- package/src/types.ts +27 -0
- package/dist/index-BFZXQAD7.js.map +0 -1
- package/dist/tree-x5Qd9Kq0.js +0 -508
- package/dist/tree-x5Qd9Kq0.js.map +0 -1
|
@@ -1,135 +1,205 @@
|
|
|
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 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({
|
|
10
10
|
value: t,
|
|
11
11
|
children: e
|
|
12
12
|
}) {
|
|
13
|
-
return /* @__PURE__ */
|
|
13
|
+
return /* @__PURE__ */ h(M.Provider, { value: t, children: e });
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
const t =
|
|
15
|
+
function Ye() {
|
|
16
|
+
const t = W(M);
|
|
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 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({
|
|
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
|
|
38
|
-
if (!
|
|
39
|
-
const a = t === "broadcast" ?
|
|
40
|
-
return /* @__PURE__ */
|
|
41
|
-
|
|
36
|
+
G();
|
|
37
|
+
const c = s.value, b = n.value, f = r.value;
|
|
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,
|
|
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__ */ h(
|
|
49
|
+
te,
|
|
50
50
|
{
|
|
51
51
|
value: {
|
|
52
52
|
mode: t,
|
|
53
53
|
store: e,
|
|
54
|
-
bundle:
|
|
55
|
-
status:
|
|
56
|
-
sendInput:
|
|
54
|
+
bundle: c,
|
|
55
|
+
status: b,
|
|
56
|
+
sendInput: i
|
|
57
57
|
},
|
|
58
|
-
children: /* @__PURE__ */
|
|
58
|
+
children: /* @__PURE__ */ h(H, { fallback: null, children: /* @__PURE__ */ h(a, {}) })
|
|
59
59
|
}
|
|
60
60
|
)
|
|
61
61
|
},
|
|
62
|
-
|
|
62
|
+
f
|
|
63
63
|
) });
|
|
64
64
|
}
|
|
65
|
-
const
|
|
65
|
+
const oe = "<anon>", g = /* @__PURE__ */ new Set();
|
|
66
|
+
function ce(t) {
|
|
67
|
+
return g.add(t), () => {
|
|
68
|
+
g.delete(t);
|
|
69
|
+
};
|
|
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)
|
|
75
|
+
try {
|
|
76
|
+
r(n);
|
|
77
|
+
} catch {
|
|
78
|
+
}
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const ae = 100, le = 4, ue = 64, he = {
|
|
83
|
+
blur: ae,
|
|
84
|
+
brightness: le
|
|
85
|
+
};
|
|
86
|
+
function O(t, e) {
|
|
87
|
+
if (typeof e != "number" || !Number.isFinite(e) || e < 0 || Object.is(e, -0)) return null;
|
|
88
|
+
const s = he[t];
|
|
89
|
+
return e > s ? s : e;
|
|
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);
|
|
95
|
+
if (!e) return null;
|
|
96
|
+
const s = O("blur", Number(e[1])), n = O("brightness", Number(e[2]));
|
|
97
|
+
return s === null || n === null ? null : `blur(${s}px) brightness(${n})`;
|
|
98
|
+
}
|
|
99
|
+
function me(t, e) {
|
|
100
|
+
P(
|
|
101
|
+
e,
|
|
102
|
+
t,
|
|
103
|
+
"rejected unsafe filter value : outside the R8 caps or not a finite number >= 0"
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
const pe = { duration: 0 }, ge = {
|
|
66
107
|
linear: "linear",
|
|
67
108
|
"cubic-in": "easeIn",
|
|
68
109
|
"cubic-out": "easeOut",
|
|
69
110
|
"cubic-in-out": "easeInOut"
|
|
70
111
|
};
|
|
71
|
-
function
|
|
72
|
-
return !t || t.kind === "none" ?
|
|
112
|
+
function Je(t) {
|
|
113
|
+
return !t || t.kind === "none" ? pe : t.kind === "tween" ? {
|
|
73
114
|
type: "tween",
|
|
74
115
|
duration: (t.duration_ms ?? 0) / 1e3,
|
|
75
|
-
ease: t.ease ?
|
|
116
|
+
ease: t.ease ? ge[t.ease] ?? "easeOut" : "easeOut"
|
|
76
117
|
} : t.kind === "spring" ? {
|
|
77
118
|
type: "spring",
|
|
78
119
|
...t.stiffness !== void 0 ? { stiffness: t.stiffness } : {},
|
|
79
|
-
...t.damping !== void 0 ? { damping: t.damping } : {}
|
|
120
|
+
...t.damping !== void 0 ? { damping: t.damping } : {},
|
|
121
|
+
...t.mass !== void 0 ? { mass: t.mass } : {}
|
|
80
122
|
} : {
|
|
81
123
|
type: "tween",
|
|
82
124
|
duration: (t.duration_ms ?? 400) / 1e3,
|
|
83
125
|
ease: "easeInOut"
|
|
84
126
|
};
|
|
85
127
|
}
|
|
86
|
-
const
|
|
128
|
+
const be = {
|
|
87
129
|
opacity: 1,
|
|
88
130
|
scale: 1,
|
|
131
|
+
scaleX: 1,
|
|
132
|
+
scaleY: 1,
|
|
89
133
|
rotate: 0,
|
|
90
134
|
x: 0,
|
|
91
|
-
y: 0
|
|
135
|
+
y: 0,
|
|
136
|
+
// LSML §6.1 filter identity — both functions are always present so
|
|
137
|
+
// framer interpolates between structurally-identical filter lists
|
|
138
|
+
// (the compiler emits the same two-function form, clamped per R8).
|
|
139
|
+
filter: "blur(0px) brightness(1)"
|
|
140
|
+
}, ve = {
|
|
141
|
+
kind: "tween",
|
|
142
|
+
duration_ms: 400,
|
|
143
|
+
ease: "cubic-out"
|
|
92
144
|
};
|
|
93
|
-
function
|
|
145
|
+
function Qe(t, e, s) {
|
|
146
|
+
for (const n of e) {
|
|
147
|
+
const r = t(n);
|
|
148
|
+
if (r !== void 0) return r;
|
|
149
|
+
}
|
|
150
|
+
if (s && Object.keys(s).length > 0) {
|
|
151
|
+
for (const n of Object.keys(s)) {
|
|
152
|
+
const r = t(n);
|
|
153
|
+
if (r !== void 0) return r;
|
|
154
|
+
}
|
|
155
|
+
return ve;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
function Ze(t, e, s) {
|
|
94
159
|
if (!e || Object.keys(e).length === 0)
|
|
95
160
|
return { initial: t, animate: t };
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
161
|
+
let n = e;
|
|
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;
|
|
165
|
+
}
|
|
166
|
+
const r = { ...t };
|
|
167
|
+
for (const i of Object.keys(n))
|
|
168
|
+
i in r || (r[i] = be[i] ?? 0);
|
|
169
|
+
return { initial: n, animate: r };
|
|
100
170
|
}
|
|
101
|
-
function
|
|
171
|
+
function ke(t) {
|
|
102
172
|
if (typeof t != "object" || t === null) return;
|
|
103
173
|
const e = t, s = e.kind;
|
|
104
174
|
if (s === "snap")
|
|
105
175
|
return { kind: "none" };
|
|
106
176
|
if (s === "tween") {
|
|
107
|
-
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 = ye[e.easing] ?? "cubic-out";
|
|
108
178
|
return { kind: "tween", duration_ms: n, ease: r };
|
|
109
179
|
}
|
|
110
180
|
if (s === "spring") {
|
|
111
181
|
const n = { kind: "spring" };
|
|
112
|
-
return typeof e.stiffness == "number" && (n.stiffness = e.stiffness), typeof e.damping == "number" && (n.damping = e.damping), n;
|
|
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;
|
|
113
183
|
}
|
|
114
184
|
}
|
|
115
|
-
const
|
|
185
|
+
const ye = {
|
|
116
186
|
linear: "linear",
|
|
117
187
|
"ease-in": "cubic-in",
|
|
118
188
|
"ease-out": "cubic-out",
|
|
119
189
|
"ease-in-out": "cubic-in-out"
|
|
120
190
|
};
|
|
121
|
-
function
|
|
122
|
-
|
|
191
|
+
function Se(t, e) {
|
|
192
|
+
y(() => {
|
|
123
193
|
for (const s of e.patches) {
|
|
124
|
-
const n =
|
|
194
|
+
const n = ke(s.transition);
|
|
125
195
|
n !== void 0 ? t.setWithTransition(s.path, s.value, n) : t.set(s.path, s.value);
|
|
126
196
|
}
|
|
127
197
|
});
|
|
128
198
|
}
|
|
129
|
-
function
|
|
199
|
+
function we(t, e) {
|
|
130
200
|
t.reset(e.state);
|
|
131
201
|
}
|
|
132
|
-
class
|
|
202
|
+
class Te {
|
|
133
203
|
signals = /* @__PURE__ */ new Map();
|
|
134
204
|
transitions = /* @__PURE__ */ new Map();
|
|
135
205
|
signal(e) {
|
|
@@ -142,25 +212,25 @@ class oe {
|
|
|
142
212
|
}
|
|
143
213
|
set(e, s) {
|
|
144
214
|
const n = this.signal(e);
|
|
145
|
-
|
|
215
|
+
k(n.peek(), s) || (n.value = s);
|
|
146
216
|
}
|
|
147
217
|
setWithTransition(e, s, n) {
|
|
148
|
-
|
|
218
|
+
y(() => {
|
|
149
219
|
const r = this.transitionSignal(e);
|
|
150
220
|
r.peek() !== n && (r.value = n);
|
|
151
|
-
const
|
|
152
|
-
|
|
221
|
+
const i = this.signal(e);
|
|
222
|
+
k(i.peek(), s) || (i.value = s);
|
|
153
223
|
});
|
|
154
224
|
}
|
|
155
225
|
reset(e) {
|
|
156
|
-
|
|
226
|
+
y(() => {
|
|
157
227
|
const s = /* @__PURE__ */ new Set();
|
|
158
228
|
for (const [n, r] of Object.entries(e)) {
|
|
159
229
|
s.add(n);
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
const
|
|
163
|
-
|
|
230
|
+
const i = this.signal(n);
|
|
231
|
+
k(i.peek(), r) || (i.value = r);
|
|
232
|
+
const c = this.transitions.get(n);
|
|
233
|
+
c && c.peek() !== void 0 && (c.value = void 0);
|
|
164
234
|
}
|
|
165
235
|
for (const n of this.signals.keys())
|
|
166
236
|
if (!s.has(n)) {
|
|
@@ -176,28 +246,34 @@ class oe {
|
|
|
176
246
|
return e;
|
|
177
247
|
}
|
|
178
248
|
}
|
|
179
|
-
function
|
|
180
|
-
return new
|
|
249
|
+
function _e() {
|
|
250
|
+
return new Te();
|
|
181
251
|
}
|
|
182
|
-
function
|
|
252
|
+
function k(t, e) {
|
|
183
253
|
if (t === e) return !0;
|
|
184
254
|
if (t === null || e === null || typeof t != typeof e || typeof t != "object" || Array.isArray(t) !== Array.isArray(e)) return !1;
|
|
185
255
|
if (Array.isArray(t) && Array.isArray(e)) {
|
|
186
256
|
if (t.length !== e.length) return !1;
|
|
187
|
-
for (let
|
|
188
|
-
if (t[
|
|
257
|
+
for (let c = 0; c < t.length; c++)
|
|
258
|
+
if (t[c] !== e[c]) return !1;
|
|
189
259
|
return !0;
|
|
190
260
|
}
|
|
191
|
-
const s = t, n = e, r = Object.keys(s),
|
|
192
|
-
if (r.length !==
|
|
193
|
-
for (const
|
|
194
|
-
if (s[
|
|
261
|
+
const s = t, n = e, r = Object.keys(s), i = Object.keys(n);
|
|
262
|
+
if (r.length !== i.length) return !1;
|
|
263
|
+
for (const c of r)
|
|
264
|
+
if (s[c] !== n[c]) return !1;
|
|
195
265
|
return !0;
|
|
196
266
|
}
|
|
197
|
-
const
|
|
267
|
+
const Ee = /* @__PURE__ */ new Set([
|
|
198
268
|
"x-lumencast.color-srgb-1.0"
|
|
199
|
-
]);
|
|
200
|
-
|
|
269
|
+
]), Ie = /^x-[a-z0-9-]+(?:\.[a-z0-9-]+)*$/, Re = /^(?:0|[1-9][0-9]*)$/, N = ".authoring";
|
|
270
|
+
function Ae(t) {
|
|
271
|
+
const e = t.indexOf("/");
|
|
272
|
+
if (e < 0) return !1;
|
|
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));
|
|
275
|
+
}
|
|
276
|
+
class L extends Error {
|
|
201
277
|
code = "BUNDLE_INCOMPATIBLE";
|
|
202
278
|
unsupportedProfiles;
|
|
203
279
|
constructor(e) {
|
|
@@ -208,40 +284,47 @@ class ae extends Error {
|
|
|
208
284
|
), this.name = "BundleIncompatibleError", this.unsupportedProfiles = e;
|
|
209
285
|
}
|
|
210
286
|
}
|
|
211
|
-
function
|
|
287
|
+
function U(t, e = Ee) {
|
|
212
288
|
const s = t.profiles;
|
|
213
|
-
if (!s
|
|
214
|
-
|
|
289
|
+
if (!s) return;
|
|
290
|
+
if (!Array.isArray(s))
|
|
291
|
+
throw new L(["<malformed: profiles is not an array>"]);
|
|
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>");
|
|
215
294
|
if (n.length > 0)
|
|
216
|
-
throw new
|
|
295
|
+
throw new L(n);
|
|
217
296
|
}
|
|
218
|
-
class
|
|
297
|
+
class Oe {
|
|
219
298
|
cache = /* @__PURE__ */ new Map();
|
|
220
299
|
baseUrl;
|
|
221
300
|
pathPrefix;
|
|
301
|
+
resolveUrl;
|
|
222
302
|
fetchImpl;
|
|
223
303
|
constructor(e) {
|
|
224
|
-
this.baseUrl = e.baseUrl.replace(/\/$/, ""), this.pathPrefix = (e.pathPrefix ?? "/lsdp/v1/scenes").replace(/\/$/, ""), this.fetchImpl = e.fetchImpl ?? globalThis.fetch.bind(globalThis);
|
|
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
|
+
}
|
|
306
|
+
buildUrl(e, s) {
|
|
307
|
+
return this.resolveUrl ? this.resolveUrl(e, s) : `${this.baseUrl}${this.pathPrefix}/${encodeURIComponent(e)}/bundle?v=${encodeURIComponent(s)}`;
|
|
225
308
|
}
|
|
226
309
|
preload(e) {
|
|
227
|
-
|
|
310
|
+
U(e), this.cache.set(e.scene_version, e);
|
|
228
311
|
}
|
|
229
312
|
async get(e, s) {
|
|
230
313
|
const n = this.cache.get(s);
|
|
231
314
|
if (n) return n;
|
|
232
|
-
const r =
|
|
233
|
-
if (!
|
|
234
|
-
throw new Error(`bundle fetch failed: ${
|
|
235
|
-
const
|
|
236
|
-
if (
|
|
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)
|
|
237
320
|
throw new Error(
|
|
238
|
-
`bundle scene_version mismatch: expected ${s}, got ${
|
|
321
|
+
`bundle scene_version mismatch: expected ${s}, got ${c.scene_version}`
|
|
239
322
|
);
|
|
240
|
-
return
|
|
323
|
+
return U(c), this.cache.set(s, c), c;
|
|
241
324
|
}
|
|
242
325
|
}
|
|
243
|
-
function
|
|
244
|
-
return new
|
|
326
|
+
function Ne(t) {
|
|
327
|
+
return new Oe(t);
|
|
245
328
|
}
|
|
246
329
|
const p = {
|
|
247
330
|
initial: 200,
|
|
@@ -249,7 +332,7 @@ const p = {
|
|
|
249
332
|
factor: 2,
|
|
250
333
|
jitter: 0.2
|
|
251
334
|
};
|
|
252
|
-
class
|
|
335
|
+
class Le {
|
|
253
336
|
constructor(e, s) {
|
|
254
337
|
this.opts = e, this.random = s;
|
|
255
338
|
}
|
|
@@ -273,7 +356,7 @@ class he {
|
|
|
273
356
|
this._attempt = 0;
|
|
274
357
|
}
|
|
275
358
|
}
|
|
276
|
-
function
|
|
359
|
+
function Ue(t = {}) {
|
|
277
360
|
const e = {
|
|
278
361
|
initial: t.initial ?? p.initial,
|
|
279
362
|
max: t.max ?? p.max,
|
|
@@ -284,7 +367,7 @@ function de(t = {}) {
|
|
|
284
367
|
if (e.max < e.initial) throw new RangeError("max must be >= initial");
|
|
285
368
|
if (e.factor < 1) throw new RangeError("factor must be >= 1");
|
|
286
369
|
if (e.jitter < 0 || e.jitter > 1) throw new RangeError("jitter must be within [0, 1]");
|
|
287
|
-
return new
|
|
370
|
+
return new Le(e, t.random ?? Math.random);
|
|
288
371
|
}
|
|
289
372
|
class u extends Error {
|
|
290
373
|
recoverable;
|
|
@@ -294,14 +377,14 @@ class u extends Error {
|
|
|
294
377
|
super(e), this.name = "TransportError", this.recoverable = s, this.code = n, this.cause = r;
|
|
295
378
|
}
|
|
296
379
|
}
|
|
297
|
-
class
|
|
380
|
+
class xe {
|
|
298
381
|
status = "disconnected";
|
|
299
382
|
socket = null;
|
|
300
383
|
token;
|
|
301
384
|
url;
|
|
302
385
|
WebSocketCtor;
|
|
303
386
|
schedule;
|
|
304
|
-
seq = new
|
|
387
|
+
seq = new K();
|
|
305
388
|
opts;
|
|
306
389
|
scheduler;
|
|
307
390
|
reconnectTimer = null;
|
|
@@ -313,7 +396,7 @@ class fe {
|
|
|
313
396
|
throw new TypeError(
|
|
314
397
|
"Lumencast WsClient: no WebSocket implementation found in this environment"
|
|
315
398
|
);
|
|
316
|
-
this.WebSocketCtor = s, this.schedule =
|
|
399
|
+
this.WebSocketCtor = s, this.schedule = Ue(e.reconnect), this.scheduler = e.scheduler ?? {
|
|
317
400
|
setTimeout: globalThis.setTimeout.bind(globalThis),
|
|
318
401
|
clearTimeout: globalThis.clearTimeout.bind(globalThis)
|
|
319
402
|
};
|
|
@@ -324,7 +407,7 @@ class fe {
|
|
|
324
407
|
}
|
|
325
408
|
/** Send `input` patches to the server. No-op if not connected. */
|
|
326
409
|
sendInput(e) {
|
|
327
|
-
!this.socket || this.socket.readyState !== this.WebSocketCtor.OPEN || e.length !== 0 && this.socket.send(
|
|
410
|
+
!this.socket || this.socket.readyState !== this.WebSocketCtor.OPEN || e.length !== 0 && this.socket.send(R(J(e)));
|
|
328
411
|
}
|
|
329
412
|
/** Replace the auth token. Closes and reopens with the new token. */
|
|
330
413
|
setToken(e) {
|
|
@@ -340,7 +423,7 @@ class fe {
|
|
|
340
423
|
this.setStatus("connecting");
|
|
341
424
|
let e;
|
|
342
425
|
try {
|
|
343
|
-
e = await
|
|
426
|
+
e = await Me(this.token);
|
|
344
427
|
} catch (n) {
|
|
345
428
|
this.opts.onTransportError?.(
|
|
346
429
|
new u(
|
|
@@ -355,7 +438,7 @@ class fe {
|
|
|
355
438
|
if (!this.active) return;
|
|
356
439
|
let s;
|
|
357
440
|
try {
|
|
358
|
-
s = new this.WebSocketCtor(this.url, [...
|
|
441
|
+
s = new this.WebSocketCtor(this.url, [...Q]);
|
|
359
442
|
} catch (n) {
|
|
360
443
|
this.opts.onTransportError?.(
|
|
361
444
|
new u(
|
|
@@ -371,25 +454,25 @@ class fe {
|
|
|
371
454
|
}
|
|
372
455
|
handleOpen(e) {
|
|
373
456
|
if (!this.socket) return;
|
|
374
|
-
const n = this.socket.protocol ===
|
|
457
|
+
const n = this.socket.protocol === Z && this.seq.last > 0, r = n ? this.seq.last : void 0;
|
|
375
458
|
n || this.seq.reset();
|
|
376
|
-
const
|
|
459
|
+
const i = V({
|
|
377
460
|
token: e,
|
|
378
461
|
...this.opts.scene !== void 0 ? { scene: this.opts.scene } : {},
|
|
379
462
|
...this.opts.session !== void 0 ? { session: this.opts.session } : {},
|
|
380
463
|
...r !== void 0 ? { since_sequence: r } : {}
|
|
381
464
|
});
|
|
382
|
-
this.socket.send(
|
|
465
|
+
this.socket.send(R(i));
|
|
383
466
|
}
|
|
384
467
|
handleMessage(e) {
|
|
385
468
|
const s = typeof e.data == "string" ? e.data : "";
|
|
386
469
|
if (!s) return;
|
|
387
470
|
let n;
|
|
388
471
|
try {
|
|
389
|
-
n =
|
|
472
|
+
n = ee(s);
|
|
390
473
|
} catch (r) {
|
|
391
|
-
const
|
|
392
|
-
this.opts.onTransportError?.(new u(`codec: ${
|
|
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();
|
|
393
476
|
return;
|
|
394
477
|
}
|
|
395
478
|
if (n !== null)
|
|
@@ -471,10 +554,10 @@ class fe {
|
|
|
471
554
|
this.status !== e && (this.status = e, this.opts.onStatus?.(e));
|
|
472
555
|
}
|
|
473
556
|
}
|
|
474
|
-
async function
|
|
557
|
+
async function Me(t) {
|
|
475
558
|
return typeof t == "string" ? t : await t.fetch();
|
|
476
559
|
}
|
|
477
|
-
function
|
|
560
|
+
function Pe(t) {
|
|
478
561
|
if (!(t.target instanceof HTMLElement))
|
|
479
562
|
throw new TypeError("mount: `target` must be an HTMLElement");
|
|
480
563
|
if (typeof t.serverUrl != "string" || t.serverUrl.length === 0)
|
|
@@ -486,29 +569,32 @@ function me(t) {
|
|
|
486
569
|
throw new TypeError("mount: `scene` is required when mode === 'test'");
|
|
487
570
|
}
|
|
488
571
|
}
|
|
489
|
-
function
|
|
490
|
-
|
|
491
|
-
const e =
|
|
492
|
-
|
|
493
|
-
|
|
572
|
+
function Ve(t) {
|
|
573
|
+
Pe(t), t.onStatus?.("disconnected");
|
|
574
|
+
const e = _e(), s = je(t.serverUrl), n = Ne({
|
|
575
|
+
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) => {
|
|
494
580
|
t.onError?.(o);
|
|
495
581
|
};
|
|
496
582
|
let a = !0;
|
|
497
|
-
const
|
|
583
|
+
const $ = t.onDiagnostic ? ce(t.onDiagnostic) : void 0, m = new xe({
|
|
498
584
|
url: t.serverUrl,
|
|
499
585
|
token: t.token,
|
|
500
586
|
...t.scene !== void 0 ? { scene: t.scene } : {},
|
|
501
587
|
...t.testSession !== void 0 ? { session: t.testSession } : {},
|
|
502
|
-
onStatus:
|
|
588
|
+
onStatus: b,
|
|
503
589
|
onSnapshot: (o) => {
|
|
504
|
-
a && (
|
|
590
|
+
a && (j(
|
|
505
591
|
n,
|
|
506
592
|
r,
|
|
507
|
-
|
|
593
|
+
c,
|
|
508
594
|
o.scene_id,
|
|
509
595
|
o.scene_version,
|
|
510
|
-
() =>
|
|
511
|
-
|
|
596
|
+
() => we(e, o),
|
|
597
|
+
f
|
|
512
598
|
), t.onMetric?.({
|
|
513
599
|
name: "snapshot_received",
|
|
514
600
|
scene_id: o.scene_id,
|
|
@@ -517,10 +603,10 @@ function Oe(t) {
|
|
|
517
603
|
},
|
|
518
604
|
onDelta: (o) => {
|
|
519
605
|
if (!a) return;
|
|
520
|
-
const
|
|
521
|
-
|
|
606
|
+
const v = performance.now();
|
|
607
|
+
Se(e, o), t.onMetric?.({
|
|
522
608
|
name: "delta_applied",
|
|
523
|
-
duration_ms: performance.now() -
|
|
609
|
+
duration_ms: performance.now() - v
|
|
524
610
|
}), t.onMetric?.({ name: "delta_received", count: 1, path_count: o.patches.length });
|
|
525
611
|
},
|
|
526
612
|
onSceneChanged: (o) => {
|
|
@@ -531,58 +617,58 @@ function Oe(t) {
|
|
|
531
617
|
});
|
|
532
618
|
},
|
|
533
619
|
onServerError: (o) => {
|
|
534
|
-
|
|
620
|
+
f({
|
|
535
621
|
code: o.code,
|
|
536
622
|
message: o.message,
|
|
537
623
|
recoverable: o.recoverable
|
|
538
624
|
});
|
|
539
625
|
},
|
|
540
626
|
onTransportError: (o) => {
|
|
541
|
-
|
|
627
|
+
f($e(o));
|
|
542
628
|
}
|
|
543
629
|
});
|
|
544
|
-
|
|
545
|
-
const
|
|
546
|
-
return
|
|
547
|
-
|
|
630
|
+
m.start();
|
|
631
|
+
const w = q(t.target);
|
|
632
|
+
return w.render(
|
|
633
|
+
z(ie, {
|
|
548
634
|
mode: t.mode,
|
|
549
635
|
store: e,
|
|
550
636
|
bundleSignal: r,
|
|
551
|
-
statusSignal:
|
|
552
|
-
crossfadeKeySignal:
|
|
553
|
-
sendInput: (o) =>
|
|
637
|
+
statusSignal: i,
|
|
638
|
+
crossfadeKeySignal: c,
|
|
639
|
+
sendInput: (o) => m.sendInput(o)
|
|
554
640
|
})
|
|
555
641
|
), {
|
|
556
642
|
disconnect() {
|
|
557
|
-
a && (a = !1,
|
|
643
|
+
a && (a = !1, $?.(), m.close(), w.unmount());
|
|
558
644
|
},
|
|
559
645
|
setToken(o) {
|
|
560
|
-
a &&
|
|
646
|
+
a && m.setToken(o);
|
|
561
647
|
}
|
|
562
648
|
};
|
|
563
|
-
async function
|
|
649
|
+
async function j(o, v, C, T, _, D, F) {
|
|
564
650
|
let E;
|
|
565
651
|
try {
|
|
566
|
-
E = await o.get(
|
|
567
|
-
} catch (
|
|
568
|
-
|
|
652
|
+
E = await o.get(T, _);
|
|
653
|
+
} catch (I) {
|
|
654
|
+
F({
|
|
569
655
|
code: "BUNDLE_FETCH_FAILED",
|
|
570
|
-
message:
|
|
656
|
+
message: I instanceof Error ? I.message : "render bundle fetch failed",
|
|
571
657
|
recoverable: !0
|
|
572
658
|
});
|
|
573
659
|
return;
|
|
574
660
|
}
|
|
575
|
-
a && (
|
|
661
|
+
a && (D(), v.value = E, C.value = `${T}::${_}`);
|
|
576
662
|
}
|
|
577
663
|
}
|
|
578
|
-
function
|
|
664
|
+
function $e(t) {
|
|
579
665
|
return {
|
|
580
666
|
code: t.code,
|
|
581
667
|
message: t.message,
|
|
582
668
|
recoverable: t.recoverable
|
|
583
669
|
};
|
|
584
670
|
}
|
|
585
|
-
function
|
|
671
|
+
function je(t) {
|
|
586
672
|
try {
|
|
587
673
|
const e = new URL(t);
|
|
588
674
|
return `${e.protocol === "wss:" ? "https:" : "http:"}//${e.host}`;
|
|
@@ -590,10 +676,97 @@ function ve(t) {
|
|
|
590
676
|
return "";
|
|
591
677
|
}
|
|
592
678
|
}
|
|
679
|
+
const Ce = ["visible", "opacity", "universal_opacity", "rotation", "sizing"];
|
|
680
|
+
function l(t) {
|
|
681
|
+
return /* @__PURE__ */ new Set([...Ce, ...t]);
|
|
682
|
+
}
|
|
683
|
+
const De = {
|
|
684
|
+
stack: l(["direction", "gap", "wrap", "crossGap", "align", "justify"]),
|
|
685
|
+
grid: l(["cols", "rows", "gap"]),
|
|
686
|
+
frame: l([
|
|
687
|
+
"x",
|
|
688
|
+
"y",
|
|
689
|
+
"width",
|
|
690
|
+
"height",
|
|
691
|
+
"scale",
|
|
692
|
+
"rotate",
|
|
693
|
+
"background",
|
|
694
|
+
"backgrounds",
|
|
695
|
+
"clipsContent"
|
|
696
|
+
]),
|
|
697
|
+
text: l([
|
|
698
|
+
"value",
|
|
699
|
+
"size",
|
|
700
|
+
"font",
|
|
701
|
+
"weight",
|
|
702
|
+
"colour",
|
|
703
|
+
"align",
|
|
704
|
+
"lineHeight",
|
|
705
|
+
"letterSpacing",
|
|
706
|
+
"textTransform",
|
|
707
|
+
"textDecoration",
|
|
708
|
+
"fontStyle",
|
|
709
|
+
"maxLines"
|
|
710
|
+
]),
|
|
711
|
+
image: l(["src", "alt", "fit", "position", "width", "height"]),
|
|
712
|
+
shape: l([
|
|
713
|
+
"geometry",
|
|
714
|
+
"kind",
|
|
715
|
+
"width",
|
|
716
|
+
"height",
|
|
717
|
+
"radius",
|
|
718
|
+
"fill",
|
|
719
|
+
"fills",
|
|
720
|
+
"stroke",
|
|
721
|
+
"stroke_width",
|
|
722
|
+
"strokes",
|
|
723
|
+
"pathData",
|
|
724
|
+
"paths",
|
|
725
|
+
"ariaLabel"
|
|
726
|
+
]),
|
|
727
|
+
media: l(["src", "loop", "mute", "autoplay", "fit"]),
|
|
728
|
+
instance: l(["scene_id", "scene_version", "size", "position"]),
|
|
729
|
+
// `repeat` is dispatched specially by the tree ; its only consumed
|
|
730
|
+
// binding is `items`.
|
|
731
|
+
repeat: /* @__PURE__ */ new Set(["items"])
|
|
732
|
+
};
|
|
733
|
+
function Fe(t, e) {
|
|
734
|
+
const s = De[t];
|
|
735
|
+
return !!(s === void 0 || s.has(e) || t === "instance" && (e === "params" || e.startsWith("params.")));
|
|
736
|
+
}
|
|
737
|
+
const x = /* @__PURE__ */ new WeakSet();
|
|
738
|
+
function et(t) {
|
|
739
|
+
if (x.has(t)) return;
|
|
740
|
+
x.add(t);
|
|
741
|
+
const e = /* @__PURE__ */ new Set([
|
|
742
|
+
...Object.keys(t.props ?? {}),
|
|
743
|
+
...Object.keys(t.bindings ?? {})
|
|
744
|
+
]);
|
|
745
|
+
for (const s of e)
|
|
746
|
+
Fe(t.kind, s) || P(
|
|
747
|
+
t.id,
|
|
748
|
+
`${t.kind}.${s}`,
|
|
749
|
+
"is not consumed by this primitive's renderer ; the prop is ignored (anti-silent-drop, ADR 001 §3.4)"
|
|
750
|
+
);
|
|
751
|
+
}
|
|
593
752
|
export {
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
753
|
+
oe as A,
|
|
754
|
+
L as B,
|
|
755
|
+
Ke as F,
|
|
756
|
+
De as P,
|
|
757
|
+
Ee as S,
|
|
758
|
+
et as a,
|
|
759
|
+
ce as b,
|
|
760
|
+
O as c,
|
|
761
|
+
Ve as d,
|
|
762
|
+
P as e,
|
|
763
|
+
Ae as i,
|
|
764
|
+
Ze as m,
|
|
765
|
+
Qe as r,
|
|
766
|
+
de as s,
|
|
767
|
+
Je as t,
|
|
768
|
+
Ye as u,
|
|
769
|
+
U as v,
|
|
770
|
+
me as w
|
|
598
771
|
};
|
|
599
|
-
//# sourceMappingURL=index-
|
|
772
|
+
//# sourceMappingURL=index-CyOlpZAL.js.map
|