nucleus-core-ts 0.10.183 → 0.10.185

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/dist/.build-ok +1 -1
  2. package/dist/fe/components/DemoFilm/_components/Caption/index.d.ts +11 -0
  3. package/dist/fe/components/DemoFilm/_components/Caption/index.js +42 -0
  4. package/dist/fe/components/DemoFilm/_components/DemoFilmRoot/index.d.ts +15 -0
  5. package/dist/fe/components/DemoFilm/_components/DemoFilmRoot/index.js +26 -0
  6. package/dist/fe/components/DemoFilm/_components/DeviceFrame/BrowserBar.d.ts +8 -0
  7. package/dist/fe/components/DemoFilm/_components/DeviceFrame/BrowserBar.js +50 -0
  8. package/dist/fe/components/DemoFilm/_components/DeviceFrame/Island.d.ts +5 -0
  9. package/dist/fe/components/DemoFilm/_components/DeviceFrame/Island.js +16 -0
  10. package/dist/fe/components/DemoFilm/_components/DeviceFrame/index.d.ts +11 -0
  11. package/dist/fe/components/DemoFilm/_components/DeviceFrame/index.js +46 -0
  12. package/dist/fe/components/DemoFilm/_components/FilmImage/index.d.ts +11 -0
  13. package/dist/fe/components/DemoFilm/_components/FilmImage/index.js +14 -0
  14. package/dist/fe/components/DemoFilm/_components/FilmPlayer/index.d.ts +25 -0
  15. package/dist/fe/components/DemoFilm/_components/FilmPlayer/index.js +86 -0
  16. package/dist/fe/components/DemoFilm/_components/Highlight/index.d.ts +13 -0
  17. package/dist/fe/components/DemoFilm/_components/Highlight/index.js +62 -0
  18. package/dist/fe/components/DemoFilm/_components/RoleStage/Body.d.ts +14 -0
  19. package/dist/fe/components/DemoFilm/_components/RoleStage/Body.js +67 -0
  20. package/dist/fe/components/DemoFilm/_components/RoleStage/RoleLabel.d.ts +10 -0
  21. package/dist/fe/components/DemoFilm/_components/RoleStage/RoleLabel.js +30 -0
  22. package/dist/fe/components/DemoFilm/_components/RoleStage/index.d.ts +8 -0
  23. package/dist/fe/components/DemoFilm/_components/RoleStage/index.js +36 -0
  24. package/dist/fe/components/DemoFilm/_components/ScreenImage/index.d.ts +11 -0
  25. package/dist/fe/components/DemoFilm/_components/ScreenImage/index.js +58 -0
  26. package/dist/fe/components/DemoFilm/_components/index.d.ts +8 -0
  27. package/dist/fe/components/DemoFilm/_components/index.js +8 -0
  28. package/dist/fe/components/DemoFilm/_hooks/index.d.ts +5 -0
  29. package/dist/fe/components/DemoFilm/_hooks/index.js +5 -0
  30. package/dist/fe/components/DemoFilm/_hooks/useDemoBeat.d.ts +3 -0
  31. package/dist/fe/components/DemoFilm/_hooks/useDemoBeat.js +24 -0
  32. package/dist/fe/components/DemoFilm/_hooks/useDemoFilm.d.ts +4 -0
  33. package/dist/fe/components/DemoFilm/_hooks/useDemoFilm.js +7 -0
  34. package/dist/fe/components/DemoFilm/_hooks/useFilmClock.d.ts +4 -0
  35. package/dist/fe/components/DemoFilm/_hooks/useFilmClock.js +7 -0
  36. package/dist/fe/components/DemoFilm/_hooks/usePlayback.d.ts +25 -0
  37. package/dist/fe/components/DemoFilm/_hooks/usePlayback.js +102 -0
  38. package/dist/fe/components/DemoFilm/_hooks/useReducedMotion.d.ts +2 -0
  39. package/dist/fe/components/DemoFilm/_hooks/useReducedMotion.js +14 -0
  40. package/dist/fe/components/DemoFilm/_host/index.d.ts +2 -0
  41. package/dist/fe/components/DemoFilm/_host/index.js +2 -0
  42. package/dist/fe/components/DemoFilm/_host/mountDemoFilmHost.d.ts +9 -0
  43. package/dist/fe/components/DemoFilm/_host/mountDemoFilmHost.js +60 -0
  44. package/dist/fe/components/DemoFilm/_host/types.d.ts +35 -0
  45. package/dist/fe/components/DemoFilm/_host/types.js +1 -0
  46. package/dist/fe/components/DemoFilm/_types/clock.d.ts +31 -0
  47. package/dist/fe/components/DemoFilm/_types/clock.js +1 -0
  48. package/dist/fe/components/DemoFilm/_types/device.d.ts +18 -0
  49. package/dist/fe/components/DemoFilm/_types/device.js +1 -0
  50. package/dist/fe/components/DemoFilm/_types/index.d.ts +6 -0
  51. package/dist/fe/components/DemoFilm/_types/index.js +6 -0
  52. package/dist/fe/components/DemoFilm/_types/player.d.ts +25 -0
  53. package/dist/fe/components/DemoFilm/_types/player.js +1 -0
  54. package/dist/fe/components/DemoFilm/_types/stage.d.ts +28 -0
  55. package/dist/fe/components/DemoFilm/_types/stage.js +1 -0
  56. package/dist/fe/components/DemoFilm/_types/theme.d.ts +38 -0
  57. package/dist/fe/components/DemoFilm/_types/theme.js +1 -0
  58. package/dist/fe/components/DemoFilm/_types/timeline.d.ts +49 -0
  59. package/dist/fe/components/DemoFilm/_types/timeline.js +5 -0
  60. package/dist/fe/components/DemoFilm/_utils/demoAssetUrl.d.ts +5 -0
  61. package/dist/fe/components/DemoFilm/_utils/demoAssetUrl.js +6 -0
  62. package/dist/fe/components/DemoFilm/_utils/device.d.ts +7 -0
  63. package/dist/fe/components/DemoFilm/_utils/device.js +50 -0
  64. package/dist/fe/components/DemoFilm/_utils/easing.d.ts +6 -0
  65. package/dist/fe/components/DemoFilm/_utils/easing.js +71 -0
  66. package/dist/fe/components/DemoFilm/_utils/index.d.ts +10 -0
  67. package/dist/fe/components/DemoFilm/_utils/index.js +10 -0
  68. package/dist/fe/components/DemoFilm/_utils/interpolate.d.ts +14 -0
  69. package/dist/fe/components/DemoFilm/_utils/interpolate.js +46 -0
  70. package/dist/fe/components/DemoFilm/_utils/motion.d.ts +6 -0
  71. package/dist/fe/components/DemoFilm/_utils/motion.js +19 -0
  72. package/dist/fe/components/DemoFilm/_utils/spring.d.ts +24 -0
  73. package/dist/fe/components/DemoFilm/_utils/spring.js +73 -0
  74. package/dist/fe/components/DemoFilm/_utils/stageSize.d.ts +9 -0
  75. package/dist/fe/components/DemoFilm/_utils/stageSize.js +19 -0
  76. package/dist/fe/components/DemoFilm/_utils/text.d.ts +3 -0
  77. package/dist/fe/components/DemoFilm/_utils/text.js +3 -0
  78. package/dist/fe/components/DemoFilm/_utils/theme.d.ts +7 -0
  79. package/dist/fe/components/DemoFilm/_utils/theme.js +137 -0
  80. package/dist/fe/components/DemoFilm/_utils/timeline.d.ts +13 -0
  81. package/dist/fe/components/DemoFilm/_utils/timeline.js +32 -0
  82. package/dist/fe/components/DemoFilm/index.d.ts +4 -0
  83. package/dist/fe/components/DemoFilm/index.js +4 -0
  84. package/dist/fe/index.d.ts +1 -0
  85. package/dist/fe/index.js +1 -0
  86. package/dist/index.js +8 -8
  87. package/dist/server.js +11 -11
  88. package/dist/src/Data/exprTypes.d.ts +29 -0
  89. package/dist/src/Data/index.d.ts +3 -2
  90. package/dist/src/Data/ruleContext.d.ts +3 -1
  91. package/dist/src/Data/ruleRefusals.d.ts +9 -0
  92. package/dist/src/Data/ruleTestKit.d.ts +2 -1
  93. package/dist/src/Data/ruleTypes.d.ts +12 -1
  94. package/dist/src/Data/unitBypass.d.ts +24 -0
  95. package/dist/src/Data/unitTypes.d.ts +8 -0
  96. package/dist/src/Data/viewAggTestKit.d.ts +1 -1
  97. package/dist/src/Nucleus/routes/auth/sessionPools.d.ts +16 -0
  98. package/dist/src/Nucleus/routes/tenant/selfSignupRateLimit.d.ts +19 -0
  99. package/dist/src/Nucleus/routes/tenant/types.d.ts +3 -0
  100. package/dist/src/Services/Auth/accountErasure.d.ts +6 -0
  101. package/dist/src/types.d.ts +2 -0
  102. package/package.json +21 -3
  103. package/scripts/demo-film/chrome.ts +75 -0
  104. package/scripts/demo-film/encoder.ts +99 -0
  105. package/scripts/demo-film/film.testkit.tsx +23 -0
  106. package/scripts/demo-film/frames.ts +47 -0
  107. package/scripts/demo-film/index.ts +17 -0
  108. package/scripts/demo-film/mp4.ts +62 -0
  109. package/scripts/demo-film/pageGlobals.d.ts +21 -0
  110. package/scripts/demo-film/render.test.ts +133 -0
  111. package/scripts/demo-film/renderFilm.ts +53 -0
  112. package/scripts/demo-film/renderStill.ts +30 -0
  113. package/scripts/demo-film/session.ts +66 -0
  114. package/scripts/demo-film/site.ts +97 -0
  115. package/scripts/demo-film/types.ts +63 -0
@@ -0,0 +1,58 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useDemoBeat } from '../../_hooks/useDemoBeat';
3
+ import { useDemoFilm } from '../../_hooks/useDemoFilm';
4
+ import { demoAssetUrl } from '../../_utils/demoAssetUrl';
5
+ import { filmReveal } from '../../_utils/motion';
6
+ import { frameOf } from '../../_utils/timeline';
7
+ import { FilmImage } from '../FilmImage';
8
+ import { DemoFilmHighlight } from '../Highlight';
9
+ const CROSSFADE_FRAMES = 12;
10
+ /**
11
+ * What a role's screen shows now: its latest capture, crossfaded from the previous one when this
12
+ * beat brought a new capture, with the beat's highlight ring on top (only in the beat that captured it).
13
+ */ export function DemoFilmScreen({ role, screenWidth, spotlight }) {
14
+ const { timeline, assetBase } = useDemoFilm();
15
+ const { index, beat, localFrame, fps } = useDemoBeat();
16
+ const current = frameOf(timeline, role, index);
17
+ const viewport = timeline.viewports[role];
18
+ if (current === null || viewport === undefined) return /*#__PURE__*/ _jsx("div", {
19
+ style: {
20
+ position: 'absolute',
21
+ inset: 0,
22
+ background: 'var(--film-surface2)'
23
+ }
24
+ });
25
+ const fresh = beat.frames[role] !== undefined;
26
+ const previous = fresh && index > 0 ? frameOf(timeline, role, index - 1) : null;
27
+ const scale = screenWidth / viewport.width;
28
+ const mix = previous !== null && previous.image !== current.image ? filmReveal(localFrame, 0, CROSSFADE_FRAMES) : 1;
29
+ const fill = {
30
+ position: 'absolute',
31
+ inset: 0,
32
+ width: '100%',
33
+ height: '100%',
34
+ objectFit: 'fill'
35
+ };
36
+ return /*#__PURE__*/ _jsxs(_Fragment, {
37
+ children: [
38
+ previous !== null && mix < 1 && /*#__PURE__*/ _jsx(FilmImage, {
39
+ src: demoAssetUrl(assetBase, previous.image),
40
+ style: fill
41
+ }),
42
+ /*#__PURE__*/ _jsx(FilmImage, {
43
+ src: demoAssetUrl(assetBase, current.image),
44
+ style: {
45
+ ...fill,
46
+ opacity: mix
47
+ }
48
+ }),
49
+ fresh && current.highlight !== null && /*#__PURE__*/ _jsx(DemoFilmHighlight, {
50
+ box: current.highlight,
51
+ scale: scale,
52
+ localFrame: localFrame,
53
+ fps: fps,
54
+ spotlight: spotlight
55
+ })
56
+ ]
57
+ });
58
+ }
@@ -0,0 +1,8 @@
1
+ export * from './Caption';
2
+ export * from './DemoFilmRoot';
3
+ export * from './DeviceFrame';
4
+ export * from './FilmImage';
5
+ export * from './FilmPlayer';
6
+ export * from './Highlight';
7
+ export * from './RoleStage';
8
+ export * from './ScreenImage';
@@ -0,0 +1,8 @@
1
+ export * from './Caption';
2
+ export * from './DemoFilmRoot';
3
+ export * from './DeviceFrame';
4
+ export * from './FilmImage';
5
+ export * from './FilmPlayer';
6
+ export * from './Highlight';
7
+ export * from './RoleStage';
8
+ export * from './ScreenImage';
@@ -0,0 +1,5 @@
1
+ export * from './useDemoBeat';
2
+ export * from './useDemoFilm';
3
+ export * from './useFilmClock';
4
+ export * from './usePlayback';
5
+ export * from './useReducedMotion';
@@ -0,0 +1,5 @@
1
+ export * from './useDemoBeat';
2
+ export * from './useDemoFilm';
3
+ export * from './useFilmClock';
4
+ export * from './usePlayback';
5
+ export * from './useReducedMotion';
@@ -0,0 +1,3 @@
1
+ import type { BeatClock } from '../_types';
2
+ /** Which beat plays at the current frame, and how far into it we are. */
3
+ export declare function useDemoBeat(): BeatClock;
@@ -0,0 +1,24 @@
1
+ import { beatStarts } from '../_utils/timeline';
2
+ import { useDemoFilm } from './useDemoFilm';
3
+ import { useFilmClock } from './useFilmClock';
4
+ /** Which beat plays at the current frame, and how far into it we are. */ export function useDemoBeat() {
5
+ const { timeline } = useDemoFilm();
6
+ const { frame, fps } = useFilmClock();
7
+ const starts = beatStarts(timeline);
8
+ let index = 0;
9
+ for(let i = 0; i < starts.length; i++){
10
+ const start = starts[i];
11
+ if (start !== undefined && Math.round(start * fps) <= frame) index = i;
12
+ }
13
+ const beat = timeline.beats[index];
14
+ if (beat === undefined) throw new Error('The timeline has no beats');
15
+ const startFrame = Math.round((starts[index] ?? 0) * fps);
16
+ return {
17
+ frame,
18
+ fps,
19
+ index,
20
+ beat,
21
+ localFrame: frame - startFrame,
22
+ beatFrames: Math.max(1, Math.round(beat.seconds * fps))
23
+ };
24
+ }
@@ -0,0 +1,4 @@
1
+ import type { DemoFilmValue } from '../_types';
2
+ export declare const DemoFilmContext: import("react").Context<DemoFilmValue<string> | null>;
3
+ /** The timeline, asset base and language of the surrounding film. */
4
+ export declare function useDemoFilm(): DemoFilmValue;
@@ -0,0 +1,7 @@
1
+ import { createContext, useContext } from 'react';
2
+ export const DemoFilmContext = createContext(null);
3
+ /** The timeline, asset base and language of the surrounding film. */ export function useDemoFilm() {
4
+ const value = useContext(DemoFilmContext);
5
+ if (value === null) throw new Error('useDemoFilm needs a surrounding <DemoFilmContext.Provider>');
6
+ return value;
7
+ }
@@ -0,0 +1,4 @@
1
+ import type { FilmClock } from '../_types';
2
+ export declare const FilmClockContext: import("react").Context<FilmClock | null>;
3
+ /** The clock of the surrounding player or renderer. */
4
+ export declare function useFilmClock(): FilmClock;
@@ -0,0 +1,7 @@
1
+ import { createContext, useContext } from 'react';
2
+ export const FilmClockContext = createContext(null);
3
+ /** The clock of the surrounding player or renderer. */ export function useFilmClock() {
4
+ const clock = useContext(FilmClockContext);
5
+ if (clock === null) throw new Error('useFilmClock needs a surrounding <FilmClockContext.Provider>');
6
+ return clock;
7
+ }
@@ -0,0 +1,25 @@
1
+ import type { FilmPlayerListener } from '../_types';
2
+ interface PlaybackOptions {
3
+ durationInFrames: number;
4
+ fps: number;
5
+ /** Speed multiplier, 1 is real time. */
6
+ rate: number;
7
+ initialFrame: number;
8
+ autoPlay: boolean;
9
+ emit: FilmPlayerListener;
10
+ }
11
+ export interface Playback {
12
+ /** The whole frame to paint. */
13
+ frame: number;
14
+ play: () => void;
15
+ pause: () => void;
16
+ seekTo: (frame: number) => void;
17
+ isPlaying: () => boolean;
18
+ }
19
+ /**
20
+ * The frame clock of a player: requestAnimationFrame advances a wall-clock position at
21
+ * `fps * rate` frames per second and publishes the whole frame. The position is derived from time
22
+ * elapsed, never from a count of ticks, so a slow display drops frames instead of slowing the film.
23
+ */
24
+ export declare function usePlayback({ durationInFrames, fps, rate, initialFrame, autoPlay, emit, }: PlaybackOptions): Playback;
25
+ export {};
@@ -0,0 +1,102 @@
1
+ import { useEffect, useEffectEvent, useRef, useState } from 'react';
2
+ /**
3
+ * The frame clock of a player: requestAnimationFrame advances a wall-clock position at
4
+ * `fps * rate` frames per second and publishes the whole frame. The position is derived from time
5
+ * elapsed, never from a count of ticks, so a slow display drops frames instead of slowing the film.
6
+ */ export function usePlayback({ durationInFrames, fps, rate, initialFrame, autoPlay, emit }) {
7
+ const last = Math.max(0, durationInFrames - 1);
8
+ const clampFrame = (frame)=>Math.min(last, Math.max(0, Math.round(frame)));
9
+ const [frame, setFrame] = useState(()=>clampFrame(initialFrame));
10
+ const shown = useRef(frame);
11
+ const position = useRef(frame);
12
+ const run = useRef(null);
13
+ const handle = useRef(0);
14
+ const publish = (next)=>{
15
+ if (next === shown.current) return;
16
+ shown.current = next;
17
+ setFrame(next);
18
+ emit({
19
+ type: 'frameupdate',
20
+ detail: {
21
+ frame: next
22
+ }
23
+ });
24
+ };
25
+ const halt = ()=>{
26
+ run.current = null;
27
+ cancelAnimationFrame(handle.current);
28
+ };
29
+ const tick = useEffectEvent((now)=>{
30
+ const current = run.current;
31
+ if (current === null) return;
32
+ const target = current.from + (now - current.startedAt) / 1000 * fps * rate;
33
+ position.current = Math.min(last, target);
34
+ publish(Math.floor(position.current));
35
+ if (target >= last) {
36
+ halt();
37
+ emit({
38
+ type: 'pause'
39
+ });
40
+ emit({
41
+ type: 'ended'
42
+ });
43
+ return;
44
+ }
45
+ handle.current = requestAnimationFrame((time)=>tick(time));
46
+ });
47
+ const play = ()=>{
48
+ if (run.current !== null) return;
49
+ if (position.current >= last && last > 0) {
50
+ position.current = 0;
51
+ publish(0);
52
+ }
53
+ run.current = {
54
+ startedAt: performance.now(),
55
+ from: position.current
56
+ };
57
+ handle.current = requestAnimationFrame((time)=>tick(time));
58
+ emit({
59
+ type: 'play'
60
+ });
61
+ };
62
+ const pause = ()=>{
63
+ if (run.current === null) return;
64
+ halt();
65
+ emit({
66
+ type: 'pause'
67
+ });
68
+ };
69
+ const seekTo = (target)=>{
70
+ const next = clampFrame(target);
71
+ position.current = next;
72
+ if (run.current !== null) run.current = {
73
+ startedAt: performance.now(),
74
+ from: next
75
+ };
76
+ publish(next);
77
+ };
78
+ const rebase = useEffectEvent(()=>{
79
+ if (run.current !== null) run.current = {
80
+ startedAt: performance.now(),
81
+ from: position.current
82
+ };
83
+ });
84
+ const start = useEffectEvent(()=>{
85
+ if (autoPlay) play();
86
+ });
87
+ const stop = useEffectEvent(()=>halt());
88
+ useEffect(()=>rebase(), [
89
+ rate
90
+ ]);
91
+ useEffect(()=>{
92
+ start();
93
+ return ()=>stop();
94
+ }, []);
95
+ return {
96
+ frame,
97
+ play,
98
+ pause,
99
+ seekTo,
100
+ isPlaying: ()=>run.current !== null
101
+ };
102
+ }
@@ -0,0 +1,2 @@
1
+ /** True when the visitor asked for reduced motion; the film then waits for a press on play. */
2
+ export declare function useReducedMotion(): boolean;
@@ -0,0 +1,14 @@
1
+ 'use client';
2
+ import { useSyncExternalStore } from 'react';
3
+ const QUERY = '(prefers-reduced-motion: reduce)';
4
+ function subscribe(onChange) {
5
+ const list = window.matchMedia(QUERY);
6
+ list.addEventListener('change', onChange);
7
+ return ()=>list.removeEventListener('change', onChange);
8
+ }
9
+ function snapshot() {
10
+ return window.matchMedia(QUERY).matches;
11
+ }
12
+ /** True when the visitor asked for reduced motion; the film then waits for a press on play. */ export function useReducedMotion() {
13
+ return useSyncExternalStore(subscribe, snapshot, ()=>false);
14
+ }
@@ -0,0 +1,2 @@
1
+ export * from './mountDemoFilmHost';
2
+ export * from './types';
@@ -0,0 +1,2 @@
1
+ export * from './mountDemoFilmHost';
2
+ export * from './types';
@@ -0,0 +1,9 @@
1
+ import type { DemoTimeline } from '../_types';
2
+ import type { DemoFilmHostOptions } from './types';
3
+ /**
4
+ * The browser entry of the render page: mounts the composition the renderer asked for and offers
5
+ * `window.__film.seek(frame)` (paint exactly that frame, then wait until every image is decoded).
6
+ * `renderFilm` and `renderStill` of `nucleus-core-ts/demo-film` drive it through puppeteer and take
7
+ * a screenshot after each seek. Call it once from the app's composition entry file.
8
+ */
9
+ export declare function mountDemoFilmHost<T extends DemoTimeline>(options: DemoFilmHostOptions<T>): Promise<void>;
@@ -0,0 +1,60 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { flushSync } from 'react-dom';
3
+ import { createRoot } from 'react-dom/client';
4
+ import { FilmClockContext } from '../_hooks/useFilmClock';
5
+ import { filmFrames } from '../_utils/timeline';
6
+ /** Resolves once every `<img>` on the page is decoded; rejects naming the one that is not. */ async function decodeImages() {
7
+ await Promise.all(Array.from(document.images, async (image)=>{
8
+ try {
9
+ await image.decode();
10
+ } catch {
11
+ throw new Error(`Image failed to load: ${image.src}`);
12
+ }
13
+ }));
14
+ }
15
+ /**
16
+ * The browser entry of the render page: mounts the composition the renderer asked for and offers
17
+ * `window.__film.seek(frame)` (paint exactly that frame, then wait until every image is decoded).
18
+ * `renderFilm` and `renderStill` of `nucleus-core-ts/demo-film` drive it through puppeteer and take
19
+ * a screenshot after each seek. Call it once from the app's composition entry file.
20
+ */ export async function mountDemoFilmHost(options) {
21
+ try {
22
+ const response = await fetch('/__input.json');
23
+ const input = await response.json();
24
+ const host = document.getElementById('root');
25
+ if (host === null) throw new Error('The render page has no #root');
26
+ const Composition = options.compositions[input.composition];
27
+ if (Composition === undefined) throw new Error(`The entry registers no composition named "${input.composition}"`);
28
+ const { fps, width, height, timeline, assetBase } = input;
29
+ const durationInFrames = filmFrames(timeline, fps);
30
+ const root = createRoot(host);
31
+ const paint = (frame)=>{
32
+ const clock = {
33
+ frame,
34
+ fps,
35
+ durationInFrames,
36
+ width,
37
+ height
38
+ };
39
+ flushSync(()=>root.render(/*#__PURE__*/ _jsx(FilmClockContext.Provider, {
40
+ value: clock,
41
+ children: /*#__PURE__*/ _jsx(Composition, {
42
+ timeline: timeline,
43
+ assetBase: assetBase
44
+ })
45
+ })));
46
+ };
47
+ await options.loadFonts?.();
48
+ paint(0);
49
+ await decodeImages();
50
+ window.__film = {
51
+ durationInFrames,
52
+ seek: async (frame)=>{
53
+ paint(Math.min(durationInFrames - 1, Math.max(0, Math.round(frame))));
54
+ await decodeImages();
55
+ }
56
+ };
57
+ } catch (error) {
58
+ window.__filmError = error instanceof Error ? error.message : String(error);
59
+ }
60
+ }
@@ -0,0 +1,35 @@
1
+ import type { ComponentType } from 'react';
2
+ import type { DemoTimeline } from '../_types';
3
+ /** What the render server hands the composition page (`/__input.json`). */
4
+ export interface DemoFilmHostInput<T extends DemoTimeline = DemoTimeline> {
5
+ /** The key of the composition to mount, as registered by the entry. */
6
+ composition: string;
7
+ timeline: T;
8
+ /** URL path of the run folder, e.g. `/assets/tr-light`. */
9
+ assetBase: string;
10
+ fps: number;
11
+ width: number;
12
+ height: number;
13
+ }
14
+ export interface DemoFilmHostOptions<T extends DemoTimeline = DemoTimeline> {
15
+ /** Every composition the entry can render, by name. */
16
+ compositions: Record<string, ComponentType<{
17
+ timeline: T;
18
+ assetBase: string;
19
+ }>>;
20
+ /** Registers the product's font faces; the first frame waits for it. */
21
+ loadFonts?: () => Promise<void>;
22
+ }
23
+ /** What the composition page offers the renderer. */
24
+ export interface DemoFilmHostApi {
25
+ readonly durationInFrames: number;
26
+ /** Paints one frame and resolves once its images are decoded, so a screenshot shows it complete. */
27
+ seek: (frame: number) => Promise<void>;
28
+ }
29
+ declare global {
30
+ interface Window {
31
+ __film?: DemoFilmHostApi;
32
+ /** Set instead of `__film` when the composition page could not start. */
33
+ __filmError?: string;
34
+ }
35
+ }
@@ -0,0 +1 @@
1
+ /** What the composition page offers the renderer. */ export { };
@@ -0,0 +1,31 @@
1
+ import type { DemoBeat, DemoTimeline } from './timeline';
2
+ /**
3
+ * The film clock: everything a composition may know about time. A composition renders purely from
4
+ * this and its props, so the same frame always paints the same picture (player, still or encode).
5
+ */
6
+ export interface FilmClock {
7
+ /** The frame to paint, 0-based. */
8
+ frame: number;
9
+ fps: number;
10
+ durationInFrames: number;
11
+ /** Composition size in px. */
12
+ width: number;
13
+ height: number;
14
+ }
15
+ /** The timeline, asset base and language of the surrounding film. */
16
+ export interface DemoFilmValue<Role extends string = string> {
17
+ timeline: DemoTimeline<Role>;
18
+ assetBase: string;
19
+ locale: string;
20
+ }
21
+ /** Where in the film the current frame is. */
22
+ export interface BeatClock<Role extends string = string> {
23
+ frame: number;
24
+ fps: number;
25
+ index: number;
26
+ beat: DemoBeat<Role>;
27
+ /** Frames since this beat started. */
28
+ localFrame: number;
29
+ /** Frames this beat lasts. */
30
+ beatFrames: number;
31
+ }
@@ -0,0 +1 @@
1
+ /** Where in the film the current frame is. */ export { };
@@ -0,0 +1,18 @@
1
+ export type DeviceKind = 'phone' | 'tablet' | 'browser';
2
+ /** Which device a role is shown on; a role without an entry is a browser window. */
3
+ export type DeviceMap<Role extends string> = Partial<Record<Role, DeviceKind>>;
4
+ export interface DeviceChrome {
5
+ kind: DeviceKind;
6
+ /** Bezel on the left, right and bottom. */
7
+ pad: number;
8
+ /** Bezel above the screen (the browser's tab and address bar included). */
9
+ top: number;
10
+ radius: number;
11
+ }
12
+ export interface DeviceFit {
13
+ screenWidth: number;
14
+ screenHeight: number;
15
+ chrome: DeviceChrome;
16
+ width: number;
17
+ height: number;
18
+ }
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,6 @@
1
+ export * from './clock';
2
+ export * from './device';
3
+ export * from './player';
4
+ export * from './stage';
5
+ export * from './theme';
6
+ export * from './timeline';
@@ -0,0 +1,6 @@
1
+ export * from './clock';
2
+ export * from './device';
3
+ export * from './player';
4
+ export * from './stage';
5
+ export * from './theme';
6
+ export * from './timeline';
@@ -0,0 +1,25 @@
1
+ /** What a player tells its listeners. `frameupdate` fires whenever the shown frame changes. */
2
+ export type FilmPlayerEvent = {
3
+ type: 'frameupdate';
4
+ detail: {
5
+ frame: number;
6
+ };
7
+ } | {
8
+ type: 'play';
9
+ } | {
10
+ type: 'pause';
11
+ } | {
12
+ type: 'ended';
13
+ };
14
+ export type FilmPlayerListener = (event: FilmPlayerEvent) => void;
15
+ /** The remote control of a FilmPlayer. */
16
+ export interface FilmPlayerHandle {
17
+ play: () => void;
18
+ pause: () => void;
19
+ /** Jump to a frame (clamped to the film); keeps playing if it was playing. */
20
+ seekTo: (frame: number) => void;
21
+ getCurrentFrame: () => number;
22
+ isPlaying: () => boolean;
23
+ /** Returns the function that removes the listener. */
24
+ subscribe: (listener: FilmPlayerListener) => () => void;
25
+ }
@@ -0,0 +1 @@
1
+ /** What a player tells its listeners. `frameupdate` fires whenever the shown frame changes. */ /** The remote control of a FilmPlayer. */ export { };
@@ -0,0 +1,28 @@
1
+ import type { DeviceMap } from './device';
2
+ import type { DemoFilmThemeOverride } from './theme';
3
+ import type { DemoText, DemoTimeline } from './timeline';
4
+ export interface RoleStageProps<Role extends string> {
5
+ timeline: DemoTimeline<Role>;
6
+ role: Role;
7
+ /** Where the run folder is served: a URL or an absolute path. */
8
+ assetBase: string;
9
+ /** Caption language; defaults to the timeline's. */
10
+ locale?: string;
11
+ /** Which device each role is shown on; a role without an entry is a browser window. */
12
+ devices?: DeviceMap<Role>;
13
+ /** The address shown in each browser window's bar. */
14
+ addresses?: Partial<Record<Role, string>>;
15
+ /** The words printed under a thumbnail (`compact`); the role's name when missing. */
16
+ labels?: Partial<Record<Role, DemoText>>;
17
+ /** Palette and fonts instead of the defaults. */
18
+ theme?: DemoFilmThemeOverride;
19
+ /** Pixel box to fill; defaults to the composition. */
20
+ box?: {
21
+ width: number;
22
+ height: number;
23
+ };
24
+ /** Part of a bigger scene (the film's thumbnails): no theme root, no caption. */
25
+ embedded?: boolean;
26
+ /** Thumbnail look: no spotlight, a label under the device. */
27
+ compact?: boolean;
28
+ }
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,38 @@
1
+ import type { DemoTheme } from './timeline';
2
+ /** The colours of one theme, painted as `--film-*` CSS variables on the film root. */
3
+ export interface DemoFilmPalette {
4
+ bg: string;
5
+ surface: string;
6
+ surface2: string;
7
+ ink: string;
8
+ soft: string;
9
+ faint: string;
10
+ line: string;
11
+ accent: string;
12
+ accentInk: string;
13
+ onAccent: string;
14
+ /** Full CSS `box-shadow` of a device. */
15
+ shadow: string;
16
+ /** Phone and tablet bezel. */
17
+ bezel: string;
18
+ bezelLine: string;
19
+ }
20
+ export interface DemoFilmFonts {
21
+ display: string;
22
+ sans: string;
23
+ mono: string;
24
+ }
25
+ export interface DemoFilmTheme {
26
+ light: DemoFilmPalette;
27
+ dark: DemoFilmPalette;
28
+ fonts: DemoFilmFonts;
29
+ /** Extra variables a product's own scenes use, by full custom-property name (`--film-slab`), per theme. */
30
+ extra?: Partial<Record<DemoTheme, Readonly<Record<string, string>>>>;
31
+ }
32
+ /** What a product passes to change the defaults; every group is merged key by key. */
33
+ export interface DemoFilmThemeOverride {
34
+ light?: Partial<DemoFilmPalette>;
35
+ dark?: Partial<DemoFilmPalette>;
36
+ fonts?: Partial<DemoFilmFonts>;
37
+ extra?: DemoFilmTheme['extra'];
38
+ }
@@ -0,0 +1 @@
1
+ /** What a product passes to change the defaults; every group is merged key by key. */ export { };
@@ -0,0 +1,49 @@
1
+ /**
2
+ * The demo timeline contract. A product writes one run (a `timeline.json` plus the captured frames),
3
+ * the film compositions read it. The contract is generic over the product's role names; anything a
4
+ * product adds (counters, acts, clocks) extends these interfaces in the product.
5
+ */
6
+ export type DemoTheme = 'light' | 'dark';
7
+ /** One sentence per language, keyed by locale code (`{ en: '...', tr: '...' }`). */
8
+ export type DemoText = Readonly<Record<string, string>>;
9
+ /** A box on the captured image, in the image's CSS pixels (before the device scale factor). */
10
+ export interface DemoBox {
11
+ x: number;
12
+ y: number;
13
+ w: number;
14
+ h: number;
15
+ }
16
+ /** The viewport a role is captured at. */
17
+ export interface DemoViewport {
18
+ width: number;
19
+ height: number;
20
+ scale: number;
21
+ }
22
+ export interface DemoFrame {
23
+ /** Path relative to the run folder, e.g. `frames/b06-guest.webp`. */
24
+ image: string;
25
+ highlight: DemoBox | null;
26
+ }
27
+ export interface DemoBeat<Role extends string = string> {
28
+ /** Stable id, `b01` to `b99`. */
29
+ id: string;
30
+ caption: DemoText;
31
+ /** Only the roles whose screen changed in this beat; a player holds each role's last frame. */
32
+ frames: Partial<Record<Role, DemoFrame>>;
33
+ /** The role the film shows for this beat. */
34
+ focus: Role;
35
+ /** Seconds the film spends on this beat. */
36
+ seconds: number;
37
+ }
38
+ export interface DemoTimeline<Role extends string = string> {
39
+ version: 1;
40
+ /** Default caption language. */
41
+ locale: string;
42
+ theme: DemoTheme;
43
+ /** True on a placeholder run: a public page never shows it. */
44
+ fixture?: boolean;
45
+ /** ISO time of the run that produced the frames. */
46
+ recordedAt: string;
47
+ viewports: Record<Role, DemoViewport>;
48
+ beats: DemoBeat<Role>[];
49
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The demo timeline contract. A product writes one run (a `timeline.json` plus the captured frames),
3
+ * the film compositions read it. The contract is generic over the product's role names; anything a
4
+ * product adds (counters, acts, clocks) extends these interfaces in the product.
5
+ */ export { };