@typecaast/react 0.1.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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/dist/index.cjs ADDED
@@ -0,0 +1,397 @@
1
+ 'use strict';
2
+
3
+ var react = require('react');
4
+ var core = require('@typecaast/core');
5
+ var skinKit = require('@typecaast/skin-kit');
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+
8
+ // src/typecaast.tsx
9
+ function configToEngine(config, theme, capabilities) {
10
+ return core.createEngine(config, theme, capabilities);
11
+ }
12
+ var QUERY = "(prefers-color-scheme: dark)";
13
+ function getMql() {
14
+ if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
15
+ return null;
16
+ }
17
+ return window.matchMedia(QUERY);
18
+ }
19
+ function subscribe(onChange) {
20
+ const mql = getMql();
21
+ if (!mql) return () => {
22
+ };
23
+ mql.addEventListener("change", onChange);
24
+ return () => mql.removeEventListener("change", onChange);
25
+ }
26
+ function getSnapshot() {
27
+ return getMql()?.matches ?? false;
28
+ }
29
+ function getServerSnapshot() {
30
+ return false;
31
+ }
32
+ function usePrefersDark() {
33
+ return react.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
34
+ }
35
+ function useResolvedTheme(mode) {
36
+ const prefersDark = usePrefersDark();
37
+ if (mode === "light") return "light";
38
+ if (mode === "dark") return "dark";
39
+ return prefersDark ? "dark" : "light";
40
+ }
41
+
42
+ // src/use-typecaast.ts
43
+ function useTypecaast(config, options = {}) {
44
+ const {
45
+ theme,
46
+ autoplay = false,
47
+ loop = false,
48
+ rate = 1,
49
+ capabilities
50
+ } = options;
51
+ const resolved = useResolvedTheme(theme ?? config.meta.theme);
52
+ const player = react.useMemo(() => {
53
+ const engine = configToEngine(config, resolved, capabilities);
54
+ return core.createPlayer(engine.getStateAt, {
55
+ durationMs: engine.durationMs,
56
+ steps: engine.steps,
57
+ loop,
58
+ rate
59
+ });
60
+ }, [config, resolved, capabilities, loop, rate]);
61
+ const [state, setState] = react.useState(() => player.state);
62
+ const [currentMs, setCurrentMs] = react.useState(() => player.currentMs);
63
+ const [playing, setPlaying] = react.useState(() => player.playing);
64
+ react.useEffect(() => {
65
+ const sync = () => {
66
+ setState(player.state);
67
+ setCurrentMs(player.currentMs);
68
+ };
69
+ sync();
70
+ setPlaying(player.playing);
71
+ const offs = [
72
+ player.on("tick", sync),
73
+ player.on("seek", sync),
74
+ player.on("play", () => setPlaying(true)),
75
+ player.on("pause", () => setPlaying(false))
76
+ ];
77
+ if (autoplay) player.play();
78
+ return () => {
79
+ offs.forEach((off) => off());
80
+ player.destroy();
81
+ };
82
+ }, [player, autoplay]);
83
+ return {
84
+ state,
85
+ currentMs,
86
+ play: () => player.play(),
87
+ pause: () => player.pause(),
88
+ seek: (t) => player.seek(t),
89
+ scrubTo: (t) => player.scrubTo(t),
90
+ setRate: (r) => player.setRate(r),
91
+ stepNext: () => player.stepNext(),
92
+ stepPrev: () => player.stepPrev(),
93
+ duration: player.durationMs,
94
+ rate: player.rate,
95
+ playing,
96
+ player
97
+ };
98
+ }
99
+ function useSkinFonts(skin) {
100
+ const fonts = skin.meta.fonts;
101
+ const [state, setState] = react.useState(
102
+ () => fonts && fonts.length > 0 ? "loading" : "loaded"
103
+ );
104
+ react.useEffect(() => {
105
+ if (!fonts || fonts.length === 0) {
106
+ setState("loaded");
107
+ return;
108
+ }
109
+ let cancelled = false;
110
+ setState("loading");
111
+ skinKit.loadSkinFonts(fonts).finally(() => {
112
+ if (!cancelled) setState("loaded");
113
+ });
114
+ return () => {
115
+ cancelled = true;
116
+ };
117
+ }, [fonts]);
118
+ return state;
119
+ }
120
+ var QUERY2 = "(prefers-reduced-motion: reduce)";
121
+ function getMql2() {
122
+ if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
123
+ return null;
124
+ }
125
+ return window.matchMedia(QUERY2);
126
+ }
127
+ function subscribe2(onChange) {
128
+ const mql = getMql2();
129
+ if (!mql) return () => {
130
+ };
131
+ mql.addEventListener("change", onChange);
132
+ return () => mql.removeEventListener("change", onChange);
133
+ }
134
+ var getSnapshot2 = () => getMql2()?.matches ?? false;
135
+ var getServerSnapshot2 = () => false;
136
+ function useReducedMotion() {
137
+ return react.useSyncExternalStore(subscribe2, getSnapshot2, getServerSnapshot2);
138
+ }
139
+
140
+ // src/transcript.ts
141
+ function buildTranscript(config) {
142
+ const name = new Map(config.participants.map((p) => [p.id, p.name]));
143
+ const lines = [];
144
+ for (const step of config.timeline) {
145
+ let from;
146
+ let text;
147
+ if (step.type === "message" || step.type === "system") {
148
+ from = step.from;
149
+ text = step.text;
150
+ } else if (step.type === "composerType") {
151
+ from = step.from;
152
+ text = step.text;
153
+ }
154
+ if (text) {
155
+ lines.push({ name: from ? name.get(from) ?? from : "System", text });
156
+ }
157
+ }
158
+ return lines;
159
+ }
160
+ function TypecaastStage({
161
+ state,
162
+ skin,
163
+ participants,
164
+ options
165
+ }) {
166
+ const theme = state.theme;
167
+ const byId = react.useMemo(() => {
168
+ const map = /* @__PURE__ */ new Map();
169
+ for (const p of participants) map.set(p.id, p);
170
+ return map;
171
+ }, [participants]);
172
+ const { Frame, Message, SystemMessage, TypingIndicator, Composer } = skin.components;
173
+ const tokens = skin.tokens?.[theme];
174
+ const composerAuthor = state.composer.from ? byId.get(state.composer.from) : void 0;
175
+ return /* @__PURE__ */ jsxRuntime.jsx(skinKit.ThemeProvider, { theme, tokens, children: /* @__PURE__ */ jsxRuntime.jsxs(Frame, { theme, options, children: [
176
+ /* @__PURE__ */ jsxRuntime.jsxs(
177
+ "div",
178
+ {
179
+ "data-typecaast-thread": "",
180
+ style: {
181
+ display: "flex",
182
+ flexDirection: "column",
183
+ justifyContent: "flex-end",
184
+ flex: "1 1 auto",
185
+ minHeight: 0,
186
+ overflow: "hidden"
187
+ },
188
+ children: [
189
+ state.messages.map((message, i) => {
190
+ const author = byId.get(message.from);
191
+ if (!author) return null;
192
+ if (message.variant === "system") {
193
+ return /* @__PURE__ */ jsxRuntime.jsx(
194
+ SystemMessage,
195
+ {
196
+ theme,
197
+ message,
198
+ author
199
+ },
200
+ message.id
201
+ );
202
+ }
203
+ const prev = state.messages[i - 1];
204
+ const previousAuthor = prev ? byId.get(prev.from) : void 0;
205
+ return /* @__PURE__ */ jsxRuntime.jsx(
206
+ Message,
207
+ {
208
+ theme,
209
+ message,
210
+ author,
211
+ previousAuthor
212
+ },
213
+ message.id
214
+ );
215
+ }),
216
+ state.typingIndicators.map((typing, i) => {
217
+ const author = byId.get(typing.from);
218
+ if (!author) return null;
219
+ return /* @__PURE__ */ jsxRuntime.jsx(
220
+ TypingIndicator,
221
+ {
222
+ theme,
223
+ typing,
224
+ author
225
+ },
226
+ `typing-${typing.from}-${i}`
227
+ );
228
+ })
229
+ ]
230
+ }
231
+ ),
232
+ composerAuthor ? /* @__PURE__ */ jsxRuntime.jsx(
233
+ Composer,
234
+ {
235
+ theme,
236
+ composer: state.composer,
237
+ author: composerAuthor
238
+ }
239
+ ) : null
240
+ ] }) });
241
+ }
242
+ function FitBox({
243
+ fit,
244
+ canvas,
245
+ children,
246
+ className,
247
+ style
248
+ }) {
249
+ const ref = react.useRef(null);
250
+ const [container, setContainer] = react.useState(
251
+ null
252
+ );
253
+ react.useLayoutEffect(() => {
254
+ const el = ref.current;
255
+ if (!el || typeof ResizeObserver === "undefined") return;
256
+ const ro = new ResizeObserver((entries) => {
257
+ const rect = entries[0]?.contentRect;
258
+ if (rect) setContainer({ w: rect.width, h: rect.height });
259
+ });
260
+ ro.observe(el);
261
+ return () => ro.disconnect();
262
+ }, []);
263
+ if (fit === "reflow") {
264
+ return /* @__PURE__ */ jsxRuntime.jsx(
265
+ "div",
266
+ {
267
+ ref,
268
+ className,
269
+ "data-fit": "reflow",
270
+ style: { width: "100%", ...style },
271
+ children
272
+ }
273
+ );
274
+ }
275
+ if (fit === "fixed") {
276
+ return /* @__PURE__ */ jsxRuntime.jsx(
277
+ "div",
278
+ {
279
+ ref,
280
+ className,
281
+ "data-fit": "fixed",
282
+ style: {
283
+ width: canvas.width,
284
+ height: canvas.height,
285
+ overflow: "hidden",
286
+ ...style
287
+ },
288
+ children
289
+ }
290
+ );
291
+ }
292
+ const scale = container ? Math.min(container.w / canvas.width, container.h / canvas.height) : 1;
293
+ return /* @__PURE__ */ jsxRuntime.jsx(
294
+ "div",
295
+ {
296
+ ref,
297
+ className,
298
+ "data-fit": "scale",
299
+ style: { width: "100%", height: "100%", overflow: "hidden", ...style },
300
+ children: /* @__PURE__ */ jsxRuntime.jsx(
301
+ "div",
302
+ {
303
+ "data-fit-canvas": "",
304
+ style: {
305
+ width: canvas.width,
306
+ height: canvas.height,
307
+ transform: `scale(${scale})`,
308
+ transformOrigin: "top left"
309
+ },
310
+ children
311
+ }
312
+ )
313
+ }
314
+ );
315
+ }
316
+ var SR_ONLY = {
317
+ position: "absolute",
318
+ width: 1,
319
+ height: 1,
320
+ padding: 0,
321
+ margin: -1,
322
+ overflow: "hidden",
323
+ clipPath: "inset(50%)",
324
+ whiteSpace: "nowrap",
325
+ border: 0
326
+ };
327
+ function Typecaast({
328
+ config,
329
+ skin,
330
+ theme,
331
+ autoplay,
332
+ loop,
333
+ rate,
334
+ fit,
335
+ label,
336
+ className,
337
+ style
338
+ }) {
339
+ const reduced = useReducedMotion();
340
+ const tc = useTypecaast(config, {
341
+ theme,
342
+ autoplay: autoplay && !reduced,
343
+ loop: loop && !reduced,
344
+ rate,
345
+ capabilities: skin.meta.capabilities
346
+ });
347
+ const fonts = useSkinFonts(skin);
348
+ react.useEffect(() => {
349
+ if (reduced) tc.seek(tc.duration);
350
+ }, [reduced, tc]);
351
+ const transcript = react.useMemo(() => buildTranscript(config), [config]);
352
+ return /* @__PURE__ */ jsxRuntime.jsxs(
353
+ "div",
354
+ {
355
+ className,
356
+ style: { position: "relative", ...style },
357
+ "data-typecaast": "",
358
+ "data-fonts": fonts,
359
+ role: "figure",
360
+ "aria-label": label ?? `Chat simulation (${skin.meta.name})`,
361
+ children: [
362
+ /* @__PURE__ */ jsxRuntime.jsx("ol", { style: SR_ONLY, children: transcript.map((line, i) => /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
363
+ line.name,
364
+ ": ",
365
+ line.text
366
+ ] }, i)) }),
367
+ /* @__PURE__ */ jsxRuntime.jsx("div", { "aria-hidden": "true", style: { height: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsx(FitBox, { fit: fit ?? config.meta.fit, canvas: config.meta.canvas, children: /* @__PURE__ */ jsxRuntime.jsx(
368
+ TypecaastStage,
369
+ {
370
+ state: tc.state,
371
+ skin,
372
+ participants: config.participants,
373
+ options: config.meta.skin.options
374
+ }
375
+ ) }) })
376
+ ]
377
+ }
378
+ );
379
+ }
380
+
381
+ // src/resolve-theme.ts
382
+ function resolveTheme(mode) {
383
+ return mode === "dark" ? "dark" : mode === "light" ? "light" : "light";
384
+ }
385
+
386
+ exports.FitBox = FitBox;
387
+ exports.Typecaast = Typecaast;
388
+ exports.TypecaastStage = TypecaastStage;
389
+ exports.buildTranscript = buildTranscript;
390
+ exports.resolveTheme = resolveTheme;
391
+ exports.usePrefersDark = usePrefersDark;
392
+ exports.useReducedMotion = useReducedMotion;
393
+ exports.useResolvedTheme = useResolvedTheme;
394
+ exports.useSkinFonts = useSkinFonts;
395
+ exports.useTypecaast = useTypecaast;
396
+ //# sourceMappingURL=index.cjs.map
397
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/engine-adapter.ts","../src/use-resolved-theme.ts","../src/use-typecaast.ts","../src/use-skin-fonts.ts","../src/use-reduced-motion.ts","../src/transcript.ts","../src/stage.tsx","../src/fit-box.tsx","../src/typecaast.tsx","../src/resolve-theme.ts"],"names":["createEngine","useSyncExternalStore","useMemo","createPlayer","useState","useEffect","loadSkinFonts","QUERY","getMql","subscribe","getSnapshot","getServerSnapshot","ThemeProvider","j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ADZ,CAET,CACD,CAAA,EACH,CAAA;AAAA,wBACAC,eAAC,KAAA,EAAA,EAAI,aAAA,EAAY,QAAO,KAAA,EAAO,EAAE,MAAA,EAAQ,MAAA,EAAO,EAC9C,QAAA,kBAAAA,eAAC,MAAA,EAAA,EAAO,GAAA,EAAK,OAAO,MAAA,CAAO,IAAA,CAAK,KAAK,MAAA,EAAQ,MAAA,CAAO,IAAA,CAAK,MAAA,EACvD,QAAA,kBAAAA,cAAAA;AAAA,UAAC,cAAA;AAAA,UAAA;AAAA,YACC,OAAO,EAAA,CAAG,KAAA;AAAA,YACV,IAAA;AAAA,YACA,cAAc,MAAA,CAAO,YAAA;AAAA,YACrB,OAAA,EAAS,MAAA,CAAO,IAAA,CAAK,IAAA,CAAK;AAAA;AAAA,WAE9B,CAAA,EACF;AAAA;AAAA;AAAA,GACF;AAEJ;;;AC7FO,SAAS,aAAa,IAAA,EAAgC;AAC3D,EAAA,OAAO,IAAA,KAAS,MAAA,GAAS,MAAA,GAAS,IAAA,KAAS,UAAU,OAAA,GAAU,OAAA;AACjE","file":"index.cjs","sourcesContent":["import type { Config } from \"@typecaast/schema\";\nimport {\n createEngine,\n type Capabilities,\n type EngineHandle,\n type ResolvedTheme,\n} from \"@typecaast/core\";\n\nexport type Engine = EngineHandle;\n\n/**\n * The single seam between a config and a playable engine. M1-UI ran this over a\n * hand-mocked timeline; M1-engine swaps in the real `compile` + `getStateAt`\n * here — and nothing else in the renderer changed (same `Engine` shape).\n *\n * Optional `capabilities` (from the active skin) drop unsupported events/content\n * from the sampled state while leaving the config intact.\n */\nexport function configToEngine(\n config: Config,\n theme: ResolvedTheme,\n capabilities?: Capabilities,\n): Engine {\n return createEngine(config, theme, capabilities);\n}\n","import { useSyncExternalStore } from \"react\";\nimport type { ThemeMode } from \"@typecaast/schema\";\nimport type { ResolvedTheme } from \"@typecaast/core\";\n\nconst QUERY = \"(prefers-color-scheme: dark)\";\n\nfunction getMql(): MediaQueryList | null {\n if (\n typeof window === \"undefined\" ||\n typeof window.matchMedia !== \"function\"\n ) {\n return null;\n }\n return window.matchMedia(QUERY);\n}\n\nfunction subscribe(onChange: () => void): () => void {\n const mql = getMql();\n if (!mql) return () => {};\n mql.addEventListener(\"change\", onChange);\n return () => mql.removeEventListener(\"change\", onChange);\n}\n\nfunction getSnapshot(): boolean {\n return getMql()?.matches ?? false;\n}\n\n/** No `matchMedia` on the server → default to light (consistent with export). */\nfunction getServerSnapshot(): boolean {\n return false;\n}\n\n/** Reactively tracks the host's `prefers-color-scheme: dark`. */\nexport function usePrefersDark(): boolean {\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n\n/**\n * Resolve a theme mode to a concrete theme. `light`/`dark` are forced; `auto`\n * tracks the host `prefers-color-scheme` reactively and falls back to `light`\n * when no preference signal is available.\n */\nexport function useResolvedTheme(mode: ThemeMode): ResolvedTheme {\n const prefersDark = usePrefersDark();\n if (mode === \"light\") return \"light\";\n if (mode === \"dark\") return \"dark\";\n return prefersDark ? \"dark\" : \"light\";\n}\n","import { useEffect, useMemo, useState } from \"react\";\nimport type { Config, ThemeMode } from \"@typecaast/schema\";\nimport {\n createPlayer,\n type Capabilities,\n type Player,\n type SimState,\n} from \"@typecaast/core\";\nimport { configToEngine } from \"./engine-adapter.js\";\nimport { useResolvedTheme } from \"./use-resolved-theme.js\";\n\nexport interface UseTypecaastOptions {\n /** Force a theme; otherwise resolved from `config.meta.theme`. */\n theme?: ThemeMode;\n autoplay?: boolean;\n loop?: boolean;\n rate?: number;\n /** The active skin's capabilities, to drop what it can't render. */\n capabilities?: Capabilities;\n}\n\n/** Imperative controls + live state returned by {@link useTypecaast}. */\nexport interface TypecaastControls {\n state: SimState;\n /** Current playback time in ms (reactive). */\n currentMs: number;\n play(): void;\n pause(): void;\n seek(timeMs: number): void;\n scrubTo(timeMs: number): void;\n setRate(rate: number): void;\n stepNext(): void;\n stepPrev(): void;\n duration: number;\n rate: number;\n playing: boolean;\n /** Escape hatch to the underlying player. */\n player: Player;\n}\n\n/**\n * Mount a player for a config and expose live state + controls. The player\n * owns the clock (rAF in the browser); this hook bridges its ticks into React\n * state. The builder uses these controls for preview-as-you-go editing.\n *\n * In M1-UI the player runs over the mocked engine (see engine-adapter); the\n * hook's surface is the final one and does not change when the real engine\n * lands.\n */\nexport function useTypecaast(\n config: Config,\n options: UseTypecaastOptions = {},\n): TypecaastControls {\n const {\n theme,\n autoplay = false,\n loop = false,\n rate = 1,\n capabilities,\n } = options;\n const resolved = useResolvedTheme(theme ?? config.meta.theme);\n\n const player = useMemo<Player>(() => {\n const engine = configToEngine(config, resolved, capabilities);\n return createPlayer(engine.getStateAt, {\n durationMs: engine.durationMs,\n steps: engine.steps,\n loop,\n rate,\n });\n }, [config, resolved, capabilities, loop, rate]);\n\n const [state, setState] = useState<SimState>(() => player.state);\n const [currentMs, setCurrentMs] = useState<number>(() => player.currentMs);\n const [playing, setPlaying] = useState<boolean>(() => player.playing);\n\n useEffect(() => {\n const sync = () => {\n setState(player.state);\n setCurrentMs(player.currentMs);\n };\n sync();\n setPlaying(player.playing);\n const offs = [\n player.on(\"tick\", sync),\n player.on(\"seek\", sync),\n player.on(\"play\", () => setPlaying(true)),\n player.on(\"pause\", () => setPlaying(false)),\n ];\n if (autoplay) player.play();\n return () => {\n offs.forEach((off) => off());\n player.destroy();\n };\n }, [player, autoplay]);\n\n return {\n state,\n currentMs,\n play: () => player.play(),\n pause: () => player.pause(),\n seek: (t) => player.seek(t),\n scrubTo: (t) => player.scrubTo(t),\n setRate: (r) => player.setRate(r),\n stepNext: () => player.stepNext(),\n stepPrev: () => player.stepPrev(),\n duration: player.durationMs,\n rate: player.rate,\n playing,\n player,\n };\n}\n","import { useEffect, useState } from \"react\";\nimport { loadSkinFonts, type Skin } from \"@typecaast/skin-kit\";\n\nexport type FontLoadState = \"loading\" | \"loaded\";\n\n/**\n * Load a skin's declared web fonts on mount so the live preview renders in the\n * correct typeface (PLAN §19) — never relying on a host OS font. SSR-safe and\n * a no-op off the DOM (resolves \"loaded\"). Re-runs if the skin's fonts change.\n */\nexport function useSkinFonts(skin: Skin): FontLoadState {\n const fonts = skin.meta.fonts;\n const [state, setState] = useState<FontLoadState>(() =>\n fonts && fonts.length > 0 ? \"loading\" : \"loaded\",\n );\n\n useEffect(() => {\n if (!fonts || fonts.length === 0) {\n setState(\"loaded\");\n return;\n }\n let cancelled = false;\n setState(\"loading\");\n loadSkinFonts(fonts).finally(() => {\n if (!cancelled) setState(\"loaded\");\n });\n return () => {\n cancelled = true;\n };\n }, [fonts]);\n\n return state;\n}\n","import { useSyncExternalStore } from \"react\";\n\nconst QUERY = \"(prefers-reduced-motion: reduce)\";\n\nfunction getMql(): MediaQueryList | null {\n if (\n typeof window === \"undefined\" ||\n typeof window.matchMedia !== \"function\"\n ) {\n return null;\n }\n return window.matchMedia(QUERY);\n}\n\nfunction subscribe(onChange: () => void): () => void {\n const mql = getMql();\n if (!mql) return () => {};\n mql.addEventListener(\"change\", onChange);\n return () => mql.removeEventListener(\"change\", onChange);\n}\n\nconst getSnapshot = (): boolean => getMql()?.matches ?? false;\nconst getServerSnapshot = (): boolean => false;\n\n/**\n * Tracks `prefers-reduced-motion: reduce`. When true, the player snaps to the\n * final state instead of animating (PLAN §20).\n */\nexport function useReducedMotion(): boolean {\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n","import type { Config } from \"@typecaast/schema\";\n\nexport interface TranscriptLine {\n name: string;\n text: string;\n}\n\n/**\n * Build a plain-text transcript from the authored config — the accessible\n * representation of the conversation for screen readers (PLAN §20). The config\n * is already structured text, so this is a faithful, non-animated version.\n */\nexport function buildTranscript(config: Config): TranscriptLine[] {\n const name = new Map(config.participants.map((p) => [p.id, p.name]));\n const lines: TranscriptLine[] = [];\n for (const step of config.timeline) {\n let from: string | undefined;\n let text: string | undefined;\n if (step.type === \"message\" || step.type === \"system\") {\n from = step.from;\n text = step.text;\n } else if (step.type === \"composerType\") {\n from = step.from;\n text = step.text;\n }\n if (text) {\n lines.push({ name: from ? (name.get(from) ?? from) : \"System\", text });\n }\n }\n return lines;\n}\n","import { useMemo, type ReactNode } from \"react\";\nimport type { Participant } from \"@typecaast/schema\";\nimport type { SimState } from \"@typecaast/core\";\nimport { ThemeProvider, type Skin } from \"@typecaast/skin-kit\";\n\nexport interface TypecaastStageProps {\n state: SimState;\n skin: Skin;\n participants: Participant[];\n /** Skin-specific options from `meta.skin.options`. */\n options?: Record<string, unknown>;\n}\n\n/**\n * Maps a `SimState` onto a skin's components: a `Frame` wrapping the thread\n * items (Message / SystemMessage), the typing indicators, and the composer.\n * Reactions render inside the skin's `Message` (it reads `message.reactions`).\n */\nexport function TypecaastStage({\n state,\n skin,\n participants,\n options,\n}: TypecaastStageProps): ReactNode {\n const theme = state.theme;\n const byId = useMemo(() => {\n const map = new Map<string, Participant>();\n for (const p of participants) map.set(p.id, p);\n return map;\n }, [participants]);\n\n const { Frame, Message, SystemMessage, TypingIndicator, Composer } =\n skin.components;\n const tokens = skin.tokens?.[theme];\n const composerAuthor = state.composer.from\n ? byId.get(state.composer.from)\n : undefined;\n\n return (\n <ThemeProvider theme={theme} tokens={tokens}>\n <Frame theme={theme} options={options}>\n {/* Thread viewport: bottom-anchored + clipped, so as the thread grows\n older items shift up out of view (\"content shifts up\", PLAN §7).\n The engine's scroll.targetOffset is honored here once real layout\n measurement lands; for now the flex anchor gives the same feel. */}\n <div\n data-typecaast-thread=\"\"\n style={{\n display: \"flex\",\n flexDirection: \"column\",\n justifyContent: \"flex-end\",\n flex: \"1 1 auto\",\n minHeight: 0,\n overflow: \"hidden\",\n }}\n >\n {state.messages.map((message, i) => {\n const author = byId.get(message.from);\n if (!author) return null;\n if (message.variant === \"system\") {\n return (\n <SystemMessage\n key={message.id}\n theme={theme}\n message={message}\n author={author}\n />\n );\n }\n const prev = state.messages[i - 1];\n const previousAuthor = prev ? byId.get(prev.from) : undefined;\n return (\n <Message\n key={message.id}\n theme={theme}\n message={message}\n author={author}\n previousAuthor={previousAuthor}\n />\n );\n })}\n {state.typingIndicators.map((typing, i) => {\n const author = byId.get(typing.from);\n if (!author) return null;\n return (\n <TypingIndicator\n key={`typing-${typing.from}-${i}`}\n theme={theme}\n typing={typing}\n author={author}\n />\n );\n })}\n </div>\n {composerAuthor ? (\n <Composer\n theme={theme}\n composer={state.composer}\n author={composerAuthor}\n />\n ) : null}\n </Frame>\n </ThemeProvider>\n );\n}\n","import {\n useLayoutEffect,\n useRef,\n useState,\n type CSSProperties,\n type ReactNode,\n} from \"react\";\nimport type { FitMode, Size } from \"@typecaast/schema\";\n\nexport interface FitBoxProps {\n fit: FitMode;\n canvas: Size;\n children: ReactNode;\n className?: string;\n style?: CSSProperties;\n}\n\n/**\n * Applies the `fit` strategy between the authoring canvas and the host\n * container (PLAN §7):\n * - `reflow`: fills width; content re-wraps (container query / ResizeObserver).\n * - `scale`: renders at exact canvas size, CSS-scaled to fit (layout preserved).\n * - `fixed`: exact canvas size, clipped.\n */\nexport function FitBox({\n fit,\n canvas,\n children,\n className,\n style,\n}: FitBoxProps): ReactNode {\n const ref = useRef<HTMLDivElement>(null);\n const [container, setContainer] = useState<{ w: number; h: number } | null>(\n null,\n );\n\n useLayoutEffect(() => {\n const el = ref.current;\n if (!el || typeof ResizeObserver === \"undefined\") return;\n const ro = new ResizeObserver((entries) => {\n const rect = entries[0]?.contentRect;\n if (rect) setContainer({ w: rect.width, h: rect.height });\n });\n ro.observe(el);\n return () => ro.disconnect();\n }, []);\n\n if (fit === \"reflow\") {\n return (\n <div\n ref={ref}\n className={className}\n data-fit=\"reflow\"\n style={{ width: \"100%\", ...style }}\n >\n {children}\n </div>\n );\n }\n\n if (fit === \"fixed\") {\n return (\n <div\n ref={ref}\n className={className}\n data-fit=\"fixed\"\n style={{\n width: canvas.width,\n height: canvas.height,\n overflow: \"hidden\",\n ...style,\n }}\n >\n {children}\n </div>\n );\n }\n\n // scale: fit the exact-size canvas into the measured container.\n const scale = container\n ? Math.min(container.w / canvas.width, container.h / canvas.height)\n : 1;\n return (\n <div\n ref={ref}\n className={className}\n data-fit=\"scale\"\n style={{ width: \"100%\", height: \"100%\", overflow: \"hidden\", ...style }}\n >\n <div\n data-fit-canvas=\"\"\n style={{\n width: canvas.width,\n height: canvas.height,\n transform: `scale(${scale})`,\n transformOrigin: \"top left\",\n }}\n >\n {children}\n </div>\n </div>\n );\n}\n","import { useEffect, useMemo, type CSSProperties, type ReactNode } from \"react\";\nimport type { Config, FitMode, ThemeMode } from \"@typecaast/schema\";\nimport type { Skin } from \"@typecaast/skin-kit\";\nimport { useTypecaast } from \"./use-typecaast.js\";\nimport { useSkinFonts } from \"./use-skin-fonts.js\";\nimport { useReducedMotion } from \"./use-reduced-motion.js\";\nimport { buildTranscript } from \"./transcript.js\";\nimport { TypecaastStage } from \"./stage.js\";\nimport { FitBox } from \"./fit-box.js\";\n\nexport interface TypecaastProps {\n config: Config;\n skin: Skin;\n /** Force a theme; otherwise resolved from `config.meta.theme`. */\n theme?: ThemeMode;\n autoplay?: boolean;\n loop?: boolean;\n rate?: number;\n /** Container fit mode; defaults to `config.meta.fit`. */\n fit?: FitMode;\n /** Accessible label for the simulation. */\n label?: string;\n className?: string;\n style?: CSSProperties;\n}\n\nconst SR_ONLY: CSSProperties = {\n position: \"absolute\",\n width: 1,\n height: 1,\n padding: 0,\n margin: -1,\n overflow: \"hidden\",\n clipPath: \"inset(50%)\",\n whiteSpace: \"nowrap\",\n border: 0,\n};\n\n/**\n * Mounts the real-time player and renders the resolved skin from live state.\n * The animated visuals are `aria-hidden`; an accessible transcript carries the\n * conversation for screen readers, and `prefers-reduced-motion` snaps to the\n * final state instead of animating (PLAN §20).\n */\nexport function Typecaast({\n config,\n skin,\n theme,\n autoplay,\n loop,\n rate,\n fit,\n label,\n className,\n style,\n}: TypecaastProps): ReactNode {\n const reduced = useReducedMotion();\n const tc = useTypecaast(config, {\n theme,\n autoplay: autoplay && !reduced,\n loop: loop && !reduced,\n rate,\n capabilities: skin.meta.capabilities,\n });\n const fonts = useSkinFonts(skin);\n\n // Reduced motion: hold the completed conversation, no animation.\n useEffect(() => {\n if (reduced) tc.seek(tc.duration);\n }, [reduced, tc]);\n\n const transcript = useMemo(() => buildTranscript(config), [config]);\n\n return (\n <div\n className={className}\n style={{ position: \"relative\", ...style }}\n data-typecaast=\"\"\n data-fonts={fonts}\n role=\"figure\"\n aria-label={label ?? `Chat simulation (${skin.meta.name})`}\n >\n <ol style={SR_ONLY}>\n {transcript.map((line, i) => (\n <li key={i}>\n {line.name}: {line.text}\n </li>\n ))}\n </ol>\n <div aria-hidden=\"true\" style={{ height: \"100%\" }}>\n <FitBox fit={fit ?? config.meta.fit} canvas={config.meta.canvas}>\n <TypecaastStage\n state={tc.state}\n skin={skin}\n participants={config.participants}\n options={config.meta.skin.options}\n />\n </FitBox>\n </div>\n </div>\n );\n}\n","import type { ThemeMode } from \"@typecaast/schema\";\nimport type { ResolvedTheme } from \"@typecaast/core\";\n\n/**\n * Resolve a theme mode to a concrete theme. `auto` falls back to `light`\n * here; M1U.4 makes `auto` reactive against the host `prefers-color-scheme`\n * via a hook layered on top of this.\n */\nexport function resolveTheme(mode: ThemeMode): ResolvedTheme {\n return mode === \"dark\" ? \"dark\" : mode === \"light\" ? \"light\" : \"light\";\n}\n"]}