odori 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{brand-D71KbhAe.d.ts → brand-B-Mv4S_Z.d.ts} +8 -5
- package/dist/{chunk-VQLDJUK4.js → chunk-7NPIGLFR.js} +2 -2
- package/dist/{chunk-PXG45HYV.js → chunk-V34N2I4A.js} +6 -3
- package/dist/chunk-V34N2I4A.js.map +1 -0
- package/dist/{chunk-2SROZSZM.js → chunk-XN6DA264.js} +48 -10
- package/dist/chunk-XN6DA264.js.map +1 -0
- package/dist/index.d.ts +61 -10
- package/dist/index.js +47 -14
- package/dist/index.js.map +1 -1
- package/dist/{manifest-CEuFXG0U.d.ts → manifest-d7-HWIFj.d.ts} +56 -5
- package/dist/manifest.d.ts +2 -2
- package/dist/manifest.js +2 -2
- package/dist/preview.d.ts +77 -3
- package/dist/preview.js +67 -16
- package/dist/preview.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-2SROZSZM.js.map +0 -1
- package/dist/chunk-PXG45HYV.js.map +0 -1
- /package/dist/{chunk-VQLDJUK4.js.map → chunk-7NPIGLFR.js.map} +0 -0
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
type Duration = number | `${number}s` | `${number}ms` | `${number}f` | string;
|
|
2
|
+
declare const framesFromDuration: (duration: Duration, fps: number) => number;
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
+
* A position on the timeline, which may be zero.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
6
|
+
* `framesFromDuration` floors at one frame, because a length of zero is
|
|
7
|
+
* nothing you can show. A position of zero is the first frame and perfectly
|
|
8
|
+
* ordinary, so an offset gets its own function rather than a special case at
|
|
9
|
+
* every call site that places something.
|
|
7
10
|
*/
|
|
8
|
-
declare const
|
|
11
|
+
declare const framesFromOffset: (offset: Duration, fps: number) => number;
|
|
9
12
|
declare const secondsFromFrames: (frames: number, fps: number) => number;
|
|
10
13
|
declare const formatTimecode: (frames: number, fps: number) => string;
|
|
11
14
|
|
|
@@ -250,4 +253,4 @@ declare const defaultBrand: Brand;
|
|
|
250
253
|
declare const defineBrand: (input: BrandInput) => Brand;
|
|
251
254
|
declare const brandCssVariables: (brand: Brand) => Record<string, string>;
|
|
252
255
|
|
|
253
|
-
export {
|
|
256
|
+
export { normalize as A, type Brand as B, type ChordQuality as C, type Duration as D, type Envelope as E, note as F, pad as G, seamless as H, seconds as I, secondsFromFrames as J, seeded as K, sequence as L, shape as M, silence as N, sine as O, step as P, sweep as Q, triangle as R, type Signal as S, type BrandColors as a, type BrandFont as b, type BrandInput as c, type BrandTypography as d, type CueContext as e, type CueDefinition as f, SAMPLE_RATE as g, type Step as h, brandCssVariables as i, chord as j, cueSamples as k, cueSignature as l, cueUrl as m, defaultBrand as n, defineBrand as o, defineCue as p, formatTimecode as q, framesFromDuration as r, framesFromOffset as s, gain as t, highPass as u, isCueDefinition as v, loop as w, lowPass as x, mix as y, noise as z };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
framesFromDuration,
|
|
4
4
|
hashValue
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-V34N2I4A.js";
|
|
6
6
|
|
|
7
7
|
// src/manifest.ts
|
|
8
8
|
var createRenderManifest = ({
|
|
@@ -59,4 +59,4 @@ var createRenderManifest = ({
|
|
|
59
59
|
export {
|
|
60
60
|
createRenderManifest
|
|
61
61
|
};
|
|
62
|
-
//# sourceMappingURL=chunk-
|
|
62
|
+
//# sourceMappingURL=chunk-7NPIGLFR.js.map
|
|
@@ -27,7 +27,7 @@ var hashValue = (value) => hashString(canonicalJson(value));
|
|
|
27
27
|
|
|
28
28
|
// src/time.ts
|
|
29
29
|
var PATTERN = /^(-?\d*\.?\d+)\s*(s|ms|f|frames?|sec|seconds?)?$/;
|
|
30
|
-
var
|
|
30
|
+
var secondsFromDuration = (duration, fps) => {
|
|
31
31
|
if (!Number.isFinite(fps) || fps <= 0) {
|
|
32
32
|
throw new Error(`Invalid fps: ${String(fps)}`);
|
|
33
33
|
}
|
|
@@ -45,8 +45,10 @@ var framesFromDuration = (duration, fps) => {
|
|
|
45
45
|
return value;
|
|
46
46
|
})();
|
|
47
47
|
if (seconds < 0) throw new Error(`Duration cannot be negative: ${String(duration)}`);
|
|
48
|
-
return
|
|
48
|
+
return seconds;
|
|
49
49
|
};
|
|
50
|
+
var framesFromDuration = (duration, fps) => Math.max(1, Math.round(secondsFromDuration(duration, fps) * fps));
|
|
51
|
+
var framesFromOffset = (offset, fps) => Math.max(0, Math.round(secondsFromDuration(offset, fps) * fps));
|
|
50
52
|
var secondsFromFrames = (frames, fps) => frames / fps;
|
|
51
53
|
var formatTimecode = (frames, fps) => {
|
|
52
54
|
const totalSeconds = Math.floor(frames / fps);
|
|
@@ -62,7 +64,8 @@ export {
|
|
|
62
64
|
hashString,
|
|
63
65
|
hashValue,
|
|
64
66
|
framesFromDuration,
|
|
67
|
+
framesFromOffset,
|
|
65
68
|
secondsFromFrames,
|
|
66
69
|
formatTimecode
|
|
67
70
|
};
|
|
68
|
-
//# sourceMappingURL=chunk-
|
|
71
|
+
//# sourceMappingURL=chunk-V34N2I4A.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hash.ts","../src/time.ts"],"sourcesContent":["/**\n * Deterministic, dependency-free content hash.\n *\n * The renderer only needs stable identity for cache keys and frozen manifests,\n * so a 128-bit FNV-1a variant over canonical JSON is sufficient and runs\n * identically in Node and the browser.\n */\nexport const canonicalJson = (value: unknown): string => {\n const walk = (input: unknown): unknown => {\n if (input === null || typeof input !== \"object\") return input;\n if (Array.isArray(input)) return input.map(walk);\n const entries = Object.entries(input as Record<string, unknown>)\n .filter(([, item]) => item !== undefined)\n .sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0));\n return Object.fromEntries(entries.map(([key, item]) => [key, walk(item)]));\n };\n return JSON.stringify(walk(value)) ?? \"null\";\n};\n\nexport const hashString = (input: string): string => {\n let high = 0x811c9dc5;\n let low = 0xcbf29ce4;\n for (let index = 0; index < input.length; index += 1) {\n const code = input.charCodeAt(index);\n low ^= code;\n high ^= code * 31 + index;\n low = Math.imul(low, 0x01000193) >>> 0;\n high = Math.imul(high, 0x01000195) >>> 0;\n }\n const pad = (value: number) => (value >>> 0).toString(16).padStart(8, \"0\");\n return `${pad(high)}${pad(low)}${pad(Math.imul(high ^ low, 0x27220a95))}${pad(input.length * 2654435761)}`;\n};\n\nexport const hashValue = (value: unknown): string => hashString(canonicalJson(value));\n","export type Duration = number | `${number}s` | `${number}ms` | `${number}f` | string;\n\nconst PATTERN = /^(-?\\d*\\.?\\d+)\\s*(s|ms|f|frames?|sec|seconds?)?$/;\n\n/**\n * Convert an authoring duration into whole frames.\n *\n * Numbers are seconds, matching the JSX authoring model where `duration={4}`\n * reads as four seconds. Suffixed strings are explicit.\n */\nconst secondsFromDuration = (duration: Duration, fps: number): number => {\n if (!Number.isFinite(fps) || fps <= 0) {\n throw new Error(`Invalid fps: ${String(fps)}`);\n }\n\n const seconds = (() => {\n if (typeof duration === \"number\") {\n if (!Number.isFinite(duration)) throw new Error(`Invalid duration: ${String(duration)}`);\n return duration;\n }\n\n const match = PATTERN.exec(duration.trim());\n if (!match) throw new Error(`Invalid duration: ${duration}`);\n const value = Number(match[1]);\n const unit = match[2] ?? \"s\";\n if (unit === \"ms\") return value / 1000;\n if (unit === \"f\" || unit.startsWith(\"frame\")) return value / fps;\n return value;\n })();\n\n if (seconds < 0) throw new Error(`Duration cannot be negative: ${String(duration)}`);\n return seconds;\n};\n\nexport const framesFromDuration = (duration: Duration, fps: number): number =>\n Math.max(1, Math.round(secondsFromDuration(duration, fps) * fps));\n\n/**\n * A position on the timeline, which may be zero.\n *\n * `framesFromDuration` floors at one frame, because a length of zero is\n * nothing you can show. A position of zero is the first frame and perfectly\n * ordinary, so an offset gets its own function rather than a special case at\n * every call site that places something.\n */\nexport const framesFromOffset = (offset: Duration, fps: number): number =>\n Math.max(0, Math.round(secondsFromDuration(offset, fps) * fps));\n\nexport const secondsFromFrames = (frames: number, fps: number): number => frames / fps;\n\nexport const formatTimecode = (frames: number, fps: number): string => {\n const totalSeconds = Math.floor(frames / fps);\n const minutes = Math.floor(totalSeconds / 60);\n const seconds = totalSeconds % 60;\n const remainder = Math.round(frames % fps);\n const pad = (value: number, size = 2) => String(value).padStart(size, \"0\");\n return `${pad(minutes)}:${pad(seconds)}.${pad(remainder)}`;\n};\n"],"mappings":";;;AAOO,IAAM,gBAAgB,CAAC,UAA2B;AACvD,QAAM,OAAO,CAAC,UAA4B;AACxC,QAAI,UAAU,QAAQ,OAAO,UAAU,SAAU,QAAO;AACxD,QAAI,MAAM,QAAQ,KAAK,EAAG,QAAO,MAAM,IAAI,IAAI;AAC/C,UAAM,UAAU,OAAO,QAAQ,KAAgC,EAC5D,OAAO,CAAC,CAAC,EAAE,IAAI,MAAM,SAAS,MAAS,EACvC,KAAK,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,MAAO,OAAO,QAAQ,KAAK,OAAO,QAAQ,IAAI,CAAE;AACvE,WAAO,OAAO,YAAY,QAAQ,IAAI,CAAC,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC;AAAA,EAC3E;AACA,SAAO,KAAK,UAAU,KAAK,KAAK,CAAC,KAAK;AACxC;AAEO,IAAM,aAAa,CAAC,UAA0B;AACnD,MAAI,OAAO;AACX,MAAI,MAAM;AACV,WAAS,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS,GAAG;AACpD,UAAM,OAAO,MAAM,WAAW,KAAK;AACnC,WAAO;AACP,YAAQ,OAAO,KAAK;AACpB,UAAM,KAAK,KAAK,KAAK,QAAU,MAAM;AACrC,WAAO,KAAK,KAAK,MAAM,QAAU,MAAM;AAAA,EACzC;AACA,QAAM,MAAM,CAAC,WAAmB,UAAU,GAAG,SAAS,EAAE,EAAE,SA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D,IAAM,oBAAoB,CAAC,QAAgB,QAAwB,SAAS;AAE5E,IAAM,iBAAiB,CAAC,QAAgB,QAAwB;AACrE,QAAM,eAAe,KAAK,MAAM,SAAS,GAAG;AAC5C,QAAM,UAAU,KAAK,MAAM,eAAe,EAAE;AAC5C,QAAM,UAAU,eAAe;AAC/B,QAAM,YAAY,KAAK,MAAM,SAAS,GAAG;AACzC,QAAM,MAAM,CAAC,OAAe,OAAO,MAAM,OAAO,KAAK,EAAE,SAAS,MAAM,GAAG;AACzE,SAAO,GAAG,IAAI,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,IAAI,SAAS,CAAC;AAC1D;","names":[]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
framesFromDuration,
|
|
4
|
+
framesFromOffset,
|
|
4
5
|
hashValue
|
|
5
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-V34N2I4A.js";
|
|
6
7
|
|
|
7
8
|
// src/context.ts
|
|
8
9
|
import { createContext, useContext } from "react";
|
|
@@ -546,13 +547,15 @@ var defaultLayout = {
|
|
|
546
547
|
};
|
|
547
548
|
var defineVideoLayout = (input = {}) => {
|
|
548
549
|
const base = input.extends ?? defaultLayout;
|
|
550
|
+
const brand = input.brand ?? base.brand;
|
|
551
|
+
const inheritedTarget = base.audio.targetLufs === defaultLayout.audio.targetLufs ? brand.audio.targetLufs : base.audio.targetLufs;
|
|
549
552
|
return {
|
|
550
553
|
kind: "odori-layout",
|
|
551
554
|
format: { ...base.format, ...input.format },
|
|
552
|
-
brand
|
|
555
|
+
brand,
|
|
553
556
|
safeArea: input.safeArea ?? base.safeArea,
|
|
554
557
|
motion: { ...base.motion, ...input.motion },
|
|
555
|
-
audio: { ...base.audio, ...input.audio },
|
|
558
|
+
audio: { ...base.audio, targetLufs: inheritedTarget, ...input.audio },
|
|
556
559
|
transition: input.transition ?? base.transition
|
|
557
560
|
};
|
|
558
561
|
};
|
|
@@ -613,6 +616,7 @@ var Scene = ({
|
|
|
613
616
|
children,
|
|
614
617
|
id,
|
|
615
618
|
name,
|
|
619
|
+
transition: treatment = "fade",
|
|
616
620
|
__start = 0,
|
|
617
621
|
__index = 0,
|
|
618
622
|
__durationInFrames = 1,
|
|
@@ -643,7 +647,7 @@ var Scene = ({
|
|
|
643
647
|
height: config.height,
|
|
644
648
|
durationInFrames: __durationInFrames
|
|
645
649
|
},
|
|
646
|
-
children: /* @__PURE__ */ jsx(SceneTransitionContext.Provider, { value: transition, children: /* @__PURE__ */ jsx(Fill, { "data-odori-scene": sceneId, children: joined ? /* @__PURE__ */ jsx(Fill, { children }) : /* @__PURE__ */ jsx(SceneEnvelope, { durationInFrames: __durationInFrames, children }) }) })
|
|
650
|
+
children: /* @__PURE__ */ jsx(SceneTransitionContext.Provider, { value: transition, children: /* @__PURE__ */ jsx(Fill, { "data-odori-scene": sceneId, children: joined || treatment === "cut" ? /* @__PURE__ */ jsx(Fill, { children }) : /* @__PURE__ */ jsx(SceneEnvelope, { durationInFrames: __durationInFrames, children }) }) })
|
|
647
651
|
}
|
|
648
652
|
) });
|
|
649
653
|
};
|
|
@@ -657,7 +661,7 @@ var Stagger = ({ children, from = 0, duration }) => {
|
|
|
657
661
|
if (local < 0 || local >= window2) return null;
|
|
658
662
|
return /* @__PURE__ */ jsx(FrameContext.Provider, { value: { ...config, frame: local, durationInFrames: window2 }, children: /* @__PURE__ */ jsx(Fill, { children }) });
|
|
659
663
|
};
|
|
660
|
-
var
|
|
664
|
+
var Repeat = ({
|
|
661
665
|
children,
|
|
662
666
|
duration,
|
|
663
667
|
times
|
|
@@ -669,7 +673,30 @@ var Loop = ({
|
|
|
669
673
|
if (times !== void 0 && pass >= times) return null;
|
|
670
674
|
return /* @__PURE__ */ jsx(FrameContext.Provider, { value: { ...config, frame: frame % window2, durationInFrames: window2 }, children: /* @__PURE__ */ jsx(Fill, { children }) });
|
|
671
675
|
};
|
|
672
|
-
var
|
|
676
|
+
var Clip = ({
|
|
677
|
+
children,
|
|
678
|
+
id,
|
|
679
|
+
from = 0,
|
|
680
|
+
duration
|
|
681
|
+
}) => {
|
|
682
|
+
const config = useVideo();
|
|
683
|
+
const frame = useFrame();
|
|
684
|
+
const forceMount = useContext2(ForceMountContext);
|
|
685
|
+
const start = framesFromOffset(from, config.fps);
|
|
686
|
+
const window2 = duration === void 0 ? Math.max(1, config.durationInFrames - start) : framesFromDuration(duration, config.fps);
|
|
687
|
+
const local = frame - start;
|
|
688
|
+
const active = local >= 0 && local < window2;
|
|
689
|
+
if (!active && !forceMount) return null;
|
|
690
|
+
return /* @__PURE__ */ jsx(
|
|
691
|
+
FrameContext.Provider,
|
|
692
|
+
{
|
|
693
|
+
value: { ...config, frame: Math.max(0, Math.min(window2 - 1, local)), durationInFrames: window2 },
|
|
694
|
+
children: /* @__PURE__ */ jsx(Fill, { "data-odori-clip": id ?? true, children })
|
|
695
|
+
}
|
|
696
|
+
);
|
|
697
|
+
};
|
|
698
|
+
Clip.__odoriClip = true;
|
|
699
|
+
var Hold = ({ children, at = 0 }) => {
|
|
673
700
|
const config = useVideo();
|
|
674
701
|
const held = framesFromDuration(at, config.fps);
|
|
675
702
|
return /* @__PURE__ */ jsx(FrameContext.Provider, { value: { ...config, frame: Math.max(0, held) }, children: /* @__PURE__ */ jsx(Fill, { children }) });
|
|
@@ -718,6 +745,7 @@ var Audio = ({
|
|
|
718
745
|
};
|
|
719
746
|
Audio.__odoriAudio = true;
|
|
720
747
|
var isSceneElement = (node) => isValidElement(node) && node.type?.__odoriScene === true;
|
|
748
|
+
var isClipElement = (node) => isValidElement(node) && node.type?.__odoriClip === true;
|
|
721
749
|
var Video = ({ children, style }) => {
|
|
722
750
|
const config = useVideo();
|
|
723
751
|
const frame = useFrame();
|
|
@@ -759,7 +787,16 @@ var Video = ({ children, style }) => {
|
|
|
759
787
|
__exitOverlap: overlaps[index + 1] ?? 0
|
|
760
788
|
});
|
|
761
789
|
});
|
|
762
|
-
|
|
790
|
+
const total = Math.max(cursor, config.durationInFrames);
|
|
791
|
+
const clips = [];
|
|
792
|
+
for (const node of nodes) {
|
|
793
|
+
if (!isClipElement(node)) continue;
|
|
794
|
+
const index = clips.length;
|
|
795
|
+
const start = framesFromOffset(node.props.from ?? 0, config.fps);
|
|
796
|
+
const durationInFrames = node.props.duration === void 0 ? Math.max(1, total - start) : framesFromDuration(node.props.duration, config.fps);
|
|
797
|
+
clips.push({ id: node.props.id ?? `clip-${index + 1}`, index, start, durationInFrames });
|
|
798
|
+
}
|
|
799
|
+
return { laidOut: output, timeline: { scenes, clips, durationInFrames: cursor } };
|
|
763
800
|
}, [children, config.fps]);
|
|
764
801
|
const publish = () => {
|
|
765
802
|
const signature = JSON.stringify(timeline);
|
|
@@ -942,12 +979,13 @@ export {
|
|
|
942
979
|
useSceneTransition,
|
|
943
980
|
Scene,
|
|
944
981
|
Stagger,
|
|
945
|
-
|
|
946
|
-
|
|
982
|
+
Repeat,
|
|
983
|
+
Clip,
|
|
984
|
+
Hold,
|
|
947
985
|
Audio,
|
|
948
986
|
Video,
|
|
949
987
|
resolveEntryLayout,
|
|
950
988
|
entryDurationInFrames,
|
|
951
989
|
OdoriRuntime
|
|
952
990
|
};
|
|
953
|
-
//# sourceMappingURL=chunk-
|
|
991
|
+
//# sourceMappingURL=chunk-XN6DA264.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/context.ts","../src/audio.ts","../src/synth.ts","../src/cue.ts","../src/easing.ts","../src/brand.ts","../src/layout.ts","../src/runtime.tsx"],"sourcesContent":["\"use client\";\n\nimport {createContext, useContext} from \"react\";\nimport {type AudioCue} from \"./audio\";\nimport {type Brand} from \"./brand\";\nimport {type VideoLayout} from \"./layout\";\n\nexport type FrameState = {frame: number; fps: number; width: number; height: number; durationInFrames: number};\nexport type SceneState = {id: string; name?: string; index: number; start: number; durationInFrames: number};\n\nexport type AssetRegistry = {\n resolve(reference: string): string;\n list(): Array<{reference: string; url: string}>;\n ready: boolean;\n};\n\nexport const FrameContext = createContext<FrameState | null>(null);\nexport const SceneContext = createContext<SceneState | null>(null);\nexport const BrandContext = createContext<Brand | null>(null);\nexport const LayoutContext = createContext<VideoLayout | null>(null);\nexport const AssetContext = createContext<AssetRegistry | null>(null);\n\nexport type AudioSink = {register(cue: AudioCue): void};\n\n/** Present only during the audio collection pass. */\nexport const AudioSinkContext = createContext<AudioSink | null>(null);\n\n/** Forces scenes to mount so their audio can be collected without seeking. */\nexport const ForceMountContext = createContext(false);\n\nexport type Readiness = {\n /** Hold the frame open. Call the returned function when the work is done. */\n hold(): () => void;\n};\n\nexport const ReadinessContext = createContext<Readiness | null>(null);\n\n/**\n * Block the frame until asynchronous work finishes.\n *\n * The driver waits for the frame attribute, and the runtime only writes it once\n * every held handle is released. Without this a component that decodes an image\n * would be screenshotted before it had anything to show.\n */\nexport const useReadiness = (): Readiness => {\n const readiness = useContext(ReadinessContext);\n // Outside a runtime, holding is a no-op rather than an error, so a component\n // stays usable in a test or a storybook-style harness.\n return readiness ?? {hold: () => () => undefined};\n};\n\nconst required = <Value,>(value: Value | null, hook: string): Value => {\n if (value === null) throw new Error(`${hook} must be called inside a <Video> tree.`);\n return value;\n};\n\n/** The frame index local to the nearest scene, or the video frame at the top level. */\nexport const useFrame = (): number => required(useContext(FrameContext), \"useFrame()\").frame;\n\nexport const useVideo = (): Omit<FrameState, \"frame\"> => {\n const state = required(useContext(FrameContext), \"useVideo()\");\n return {\n fps: state.fps,\n width: state.width,\n height: state.height,\n durationInFrames: state.durationInFrames,\n };\n};\n\n/**\n * A single number components multiply their design values by.\n *\n * Sizing from the shorter side keeps type and spacing readable when the same\n * component is composed into a 16:9, 9:16, or 1:1 frame. A width-derived scale\n * would shrink a vertical cut into unreadable text.\n */\nexport const useDesignScale = (reference = 1080): number => {\n const state = required(useContext(FrameContext), \"useDesignScale()\");\n return Math.min(state.width, state.height) / reference;\n};\n\nexport const useBrand = (): Brand => required(useContext(BrandContext), \"useBrand()\");\nexport const useLayout = (): VideoLayout => required(useContext(LayoutContext), \"useLayout()\");\nexport const useScene = (): SceneState => required(useContext(SceneContext), \"useScene()\");\n\nexport const useAssets = (): AssetRegistry => {\n const registry = useContext(AssetContext);\n return registry ?? {resolve: (reference: string) => reference, list: () => [], ready: true};\n};\n\nexport const createAssetRegistry = (entries: Array<{reference: string; url: string}>): AssetRegistry => {\n const table = new Map(entries.map((entry) => [entry.reference, entry.url]));\n return {\n ready: true,\n list: () => entries,\n resolve(reference) {\n const url = table.get(reference);\n if (!url) throw new Error(`Unknown asset reference: ${reference}. Declare it in prepare.ts or odori.config.ts.`);\n return url;\n },\n };\n};\n","import {type Duration} from \"./time\";\n\nexport type AudioCue = {\n /** Stable identity, derived from the source and its placement. */\n id: string;\n src: string;\n fromFrame: number;\n durationInFrames: number;\n /** Linear gain. 1 is unchanged. */\n gain: number;\n /**\n * An authored curve, sampled from a `gain` function at compile time. A\n * function cannot enter a manifest or an FFmpeg filter; its samples can.\n */\n gainPoints?: EnvelopePoint[];\n fadeInFrames: number;\n fadeOutFrames: number;\n /** Seconds skipped at the head of the source file. */\n trimStartSeconds: number;\n loop: boolean;\n /** Ducked cues are attenuated while a louder cue overlaps them. */\n duckUnder: boolean;\n};\n\nexport type AudioTrack = {cues: AudioCue[]; durationInFrames: number};\n\nexport type AudioProps = {\n src: string;\n /** Offset from the enclosing scene, or from the video when used at the top level. */\n from?: Duration;\n duration?: Duration;\n /**\n * A number, or a curve. The function is evaluated once per frame of the\n * cue's window when the timeline compiles, so preview and export read the\n * same points rather than running your code twice.\n */\n gain?: number | ((frame: number) => number);\n fadeIn?: Duration;\n fadeOut?: Duration;\n trimStart?: Duration;\n loop?: boolean;\n duckUnder?: boolean;\n};\n\nexport const cueId = (src: string, fromFrame: number): string => `${src}@${fromFrame}`;\n\n/**\n * A source is either a URL the dev server and the render worker both serve, or\n * a reference declared in `odori.config.ts`. Anything that is not obviously a\n * path is treated as a reference, so `<Audio src=\"score\" />` and\n * `useAssets().resolve(\"score\")` name the same file.\n */\nexport const isAssetReference = (src: string): boolean => !/^(https?:\\/\\/|\\/|\\.\\/|\\.\\.\\/|data:|blob:)/.test(src);\n\n/** Deterministic ordering so a manifest hash does not depend on mount order. */\nexport const sortCues = (cues: AudioCue[]): AudioCue[] =>\n [...cues].sort((left, right) => left.fromFrame - right.fromFrame || left.id.localeCompare(right.id));\n\nexport const trackDuration = (cues: AudioCue[]): number =>\n cues.reduce((total, cue) => Math.max(total, cue.fromFrame + cue.durationInFrames), 0);\n\n/**\n * Linear gain at one frame, including fades. The renderer applies the same\n * curve through FFmpeg, so preview and export agree on shape.\n */\nexport const gainAtFrame = (cue: AudioCue, frame: number): number => {\n const local = frame - cue.fromFrame;\n if (local < 0 || local >= cue.durationInFrames) return 0;\n const fadeIn = cue.fadeInFrames > 0 ? Math.min(1, local / cue.fadeInFrames) : 1;\n const remaining = cue.durationInFrames - local;\n const fadeOut = cue.fadeOutFrames > 0 ? Math.min(1, remaining / cue.fadeOutFrames) : 1;\n const authored = cue.gainPoints ? envelopeAtFrame(cue.gainPoints, frame) : 1;\n return cue.gain * authored * fadeIn * fadeOut;\n};\n\n/**\n * Sample a gain function across a window, then drop the points a straight line\n * already describes. One point per frame would compile into a filter\n * expression hundreds of branches deep for a curve the ear cannot tell from a\n * dozen segments.\n */\nexport const sampleGainCurve = (\n curve: (frame: number) => number,\n fromFrame: number,\n durationInFrames: number,\n tolerance = 0.01,\n): EnvelopePoint[] => {\n const raw: EnvelopePoint[] = [];\n for (let frame = fromFrame; frame < fromFrame + durationInFrames; frame += 1) {\n const value = curve(frame - fromFrame);\n raw.push({frame, value: Number.isFinite(value) ? value : 1});\n }\n if (raw.length <= 2) return raw;\n\n const kept: EnvelopePoint[] = [raw[0]];\n for (let index = 1; index < raw.length - 1; index += 1) {\n const previous = kept[kept.length - 1];\n const next = raw[index + 1];\n const span = next.frame - previous.frame;\n const predicted =\n span === 0\n ? previous.value\n : previous.value + ((next.value - previous.value) * (raw[index].frame - previous.frame)) / span;\n if (Math.abs(raw[index].value - predicted) > tolerance) kept.push(raw[index]);\n }\n kept.push(raw[raw.length - 1]);\n return kept;\n};\n\n/** How far a ducked cue drops while a non-ducked cue is sounding. */\nexport const DUCK_GAIN = 0.35;\n\n/** Ramp into and out of a duck, so the drop is heard as mixing, not as a cut. */\nexport const DUCK_RAMP_FRAMES = 6;\n\nexport type EnvelopePoint = {frame: number; value: number};\n\nconst clampFrame = (frame: number, durationInFrames: number) => Math.max(0, Math.min(durationInFrames, frame));\n\n/**\n * The duck envelope for one cue against the rest of the track.\n *\n * A duck lasts only while a non-ducked cue overlaps, rather than for the whole\n * file: a one second confirmation should not hold a music bed down for the\n * length of the video. Preview evaluates these points directly and the encoder\n * compiles them into a volume expression, so both paths hear one envelope.\n */\nexport const duckEnvelope = (cue: AudioCue, cues: AudioCue[]): EnvelopePoint[] => {\n const end = cue.fromFrame + cue.durationInFrames;\n if (!cue.duckUnder) return [{frame: cue.fromFrame, value: 1}, {frame: end, value: 1}];\n\n const windows = cues\n .filter((other) => other.id !== cue.id && !other.duckUnder)\n .map((other) => ({\n start: Math.max(cue.fromFrame, other.fromFrame),\n end: Math.min(end, other.fromFrame + other.durationInFrames),\n }))\n .filter((window) => window.end > window.start)\n .sort((left, right) => left.start - right.start);\n\n // Overlapping windows duck once, not once per cue.\n const merged: Array<{start: number; end: number}> = [];\n for (const window of windows) {\n const last = merged[merged.length - 1];\n if (last && window.start <= last.end) last.end = Math.max(last.end, window.end);\n else merged.push({...window});\n }\n\n const points: EnvelopePoint[] = [{frame: cue.fromFrame, value: 1}];\n for (const window of merged) {\n points.push(\n {frame: clampFrame(window.start - DUCK_RAMP_FRAMES, end), value: 1},\n {frame: clampFrame(window.start, end), value: DUCK_GAIN},\n {frame: clampFrame(window.end, end), value: DUCK_GAIN},\n {frame: clampFrame(window.end + DUCK_RAMP_FRAMES, end), value: 1},\n );\n }\n points.push({frame: end, value: 1});\n return simplify(points.sort((left, right) => left.frame - right.frame));\n};\n\n/**\n * Two points at one frame are a step, and three points at one level are a\n * straight line. Collapsing both keeps the envelope, and the volume expression\n * compiled from it, as short as the shape actually requires.\n */\nconst simplify = (points: EnvelopePoint[]): EnvelopePoint[] => {\n const stepped: EnvelopePoint[] = [];\n for (const point of points) {\n const last = stepped[stepped.length - 1];\n if (last && last.frame === point.frame) stepped[stepped.length - 1] = point;\n else stepped.push(point);\n }\n\n return stepped.filter((point, index) => {\n const previous = stepped[index - 1];\n const next = stepped[index + 1];\n return !previous || !next || previous.value !== point.value || next.value !== point.value;\n });\n};\n\n/** Linear interpolation between envelope points. */\nexport const envelopeAtFrame = (points: EnvelopePoint[], frame: number): number => {\n if (points.length === 0) return 1;\n if (frame <= points[0].frame) return points[0].value;\n for (let index = 1; index < points.length; index += 1) {\n const previous = points[index - 1];\n const current = points[index];\n if (frame > current.frame) continue;\n const span = current.frame - previous.frame;\n if (span <= 0) return current.value;\n return previous.value + ((current.value - previous.value) * (frame - previous.frame)) / span;\n }\n return points[points.length - 1].value;\n};\n\n/**\n * Everything that shapes a cue's level at one frame: its own gain and fades,\n * and the duck the rest of the track imposes on it.\n */\nexport const trackGainAtFrame = (cue: AudioCue, cues: AudioCue[], frame: number): number =>\n gainAtFrame(cue, frame) * envelopeAtFrame(duckEnvelope(cue, cues), frame);\n","/**\n * Deterministic synthesis. A cue is code that produces samples, so a sound\n * diffs, reviews, and upgrades like every other piece of source, and preview\n * and export can run the identical function.\n *\n * The rules are the frame runtime's rules: no wall clock, no unseeded\n * randomness, one sample rate. Same score in, same bytes out, on any machine.\n */\n\n/** Every cue renders at this rate, so a score never depends on the host. */\nexport const SAMPLE_RATE = 48000;\n\nexport type Signal = {\n /** One array per channel. Mono is one; the mix upmixes when it needs to. */\n channels: Float32Array[];\n sampleRate: number;\n};\n\nexport type Envelope = {\n /** Seconds from the start of the cue to full level. */\n attack?: number;\n /** Seconds from full level to the sustain level. */\n decay?: number;\n /** Level held after the decay, 0 to 1. */\n sustain?: number;\n /** Seconds to fall from the sustain level to silence. */\n release?: number;\n};\n\nconst clamp = (value: number, low: number, high: number) => Math.max(low, Math.min(high, value));\n\n/**\n * A seeded generator, so noise is reproducible. Mulberry32: small, fast, and\n * good enough for audio noise, where the requirement is \"no audible pattern\"\n * rather than cryptographic quality.\n */\nexport const seeded = (seed: number): (() => number) => {\n let state = seed >>> 0;\n return () => {\n state = (state + 0x6d2b79f5) >>> 0;\n let t = Math.imul(state ^ (state >>> 15), 1 | state);\n t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296;\n };\n};\n\nexport const silence = (samples: number, channels = 1): Signal => ({\n channels: Array.from({length: channels}, () => new Float32Array(samples)),\n sampleRate: SAMPLE_RATE,\n});\n\n/** A sine partial. The building block for tones, ticks, and sub weight. */\nexport const sine = (samples: number, frequency: number, phase = 0): Signal => {\n const data = new Float32Array(samples);\n const increment = (Math.PI * 2 * frequency) / SAMPLE_RATE;\n for (let index = 0; index < samples; index += 1) data[index] = Math.sin(phase + increment * index);\n return {channels: [data], sampleRate: SAMPLE_RATE};\n};\n\n/** A triangle partial: softer than a square, brighter than a sine. */\nexport const triangle = (samples: number, frequency: number): Signal => {\n const data = new Float32Array(samples);\n const period = SAMPLE_RATE / frequency;\n for (let index = 0; index < samples; index += 1) {\n const position = (index % period) / period;\n data[index] = 4 * Math.abs(position - 0.5) - 1;\n }\n return {channels: [data], sampleRate: SAMPLE_RATE};\n};\n\n/** White noise from a seeded generator, so a click is the same click twice. */\nexport const noise = (samples: number, seed = 1): Signal => {\n const random = seeded(seed);\n const data = new Float32Array(samples);\n for (let index = 0; index < samples; index += 1) data[index] = random() * 2 - 1;\n return {channels: [data], sampleRate: SAMPLE_RATE};\n};\n\n/**\n * A frequency sweep, which is what a riser is. Linear in frequency rather than\n * in pitch, because the shape is easier to reason about when writing one.\n */\nexport const sweep = (samples: number, from: number, to: number): Signal => {\n const data = new Float32Array(samples);\n let phase = 0;\n for (let index = 0; index < samples; index += 1) {\n const position = samples <= 1 ? 1 : index / (samples - 1);\n const frequency = from + (to - from) * position;\n phase += (Math.PI * 2 * frequency) / SAMPLE_RATE;\n data[index] = Math.sin(phase);\n }\n return {channels: [data], sampleRate: SAMPLE_RATE};\n};\n\n/** Apply an ADSR shape. Anything omitted is skipped rather than defaulted. */\nexport const shape = (signal: Signal, envelope: Envelope): Signal => {\n const {attack = 0, decay = 0, sustain = 1, release = 0} = envelope;\n const length = signal.channels[0]?.length ?? 0;\n const attackEnd = Math.round(attack * SAMPLE_RATE);\n const decayEnd = attackEnd + Math.round(decay * SAMPLE_RATE);\n const releaseStart = Math.max(decayEnd, length - Math.round(release * SAMPLE_RATE));\n\n const level = (index: number): number => {\n if (index < attackEnd) return attackEnd === 0 ? 1 : index / attackEnd;\n if (index < decayEnd) {\n const position = (index - attackEnd) / Math.max(1, decayEnd - attackEnd);\n return 1 + (sustain - 1) * position;\n }\n if (index < releaseStart) return sustain;\n const remaining = length - releaseStart;\n return remaining <= 0 ? 0 : sustain * (1 - (index - releaseStart) / remaining);\n };\n\n return {\n sampleRate: signal.sampleRate,\n channels: signal.channels.map((channel) => {\n const out = new Float32Array(channel.length);\n for (let index = 0; index < channel.length; index += 1) out[index] = channel[index] * level(index);\n return out;\n }),\n };\n};\n\nexport const gain = (signal: Signal, amount: number): Signal => ({\n sampleRate: signal.sampleRate,\n channels: signal.channels.map((channel) => {\n const out = new Float32Array(channel.length);\n for (let index = 0; index < channel.length; index += 1) out[index] = channel[index] * amount;\n return out;\n }),\n});\n\n/** Sum signals, padding to the longest. Levels are the caller's business. */\nexport const mix = (...signals: Signal[]): Signal => {\n const length = Math.max(0, ...signals.map((signal) => signal.channels[0]?.length ?? 0));\n const width = Math.max(1, ...signals.map((signal) => signal.channels.length));\n const channels = Array.from({length: width}, () => new Float32Array(length));\n\n for (const signal of signals) {\n for (let channel = 0; channel < width; channel += 1) {\n const source = signal.channels[channel] ?? signal.channels[0];\n if (!source) continue;\n const target = channels[channel];\n for (let index = 0; index < source.length; index += 1) target[index] += source[index];\n }\n }\n\n return {channels, sampleRate: SAMPLE_RATE};\n};\n\n/**\n * One pole filters. Enough to shape a click or take the top off a pad, and\n * cheap enough to stay readable next to the sound it is making.\n */\nexport const lowPass = (signal: Signal, frequency: number): Signal => {\n const coefficient = clamp(1 - Math.exp((-2 * Math.PI * frequency) / SAMPLE_RATE), 0, 1);\n return {\n sampleRate: signal.sampleRate,\n channels: signal.channels.map((channel) => {\n const out = new Float32Array(channel.length);\n let previous = 0;\n for (let index = 0; index < channel.length; index += 1) {\n previous += coefficient * (channel[index] - previous);\n out[index] = previous;\n }\n return out;\n }),\n };\n};\n\nexport const highPass = (signal: Signal, frequency: number): Signal => {\n const low = lowPass(signal, frequency);\n return {\n sampleRate: signal.sampleRate,\n channels: signal.channels.map((channel, index) => {\n const out = new Float32Array(channel.length);\n const removed = low.channels[index];\n for (let sample = 0; sample < channel.length; sample += 1) out[sample] = channel[sample] - removed[sample];\n return out;\n }),\n };\n};\n\n/**\n * Ramp the first and last few milliseconds to zero.\n *\n * A buffer that starts or ends on a non-zero sample is a step change, and a\n * step change is a click. Every cue gets this, because the alternative is a\n * score that sounds correct in isolation and glitches at its edges.\n */\nexport const declick = (signal: Signal, milliseconds = 3): Signal => {\n const ramp = Math.max(1, Math.round((milliseconds / 1000) * SAMPLE_RATE));\n return {\n sampleRate: signal.sampleRate,\n channels: signal.channels.map((channel) => {\n const out = Float32Array.from(channel);\n const span = Math.min(ramp, Math.floor(out.length / 2));\n for (let index = 0; index < span; index += 1) {\n const level = index / span;\n out[index] *= level;\n out[out.length - 1 - index] *= level;\n }\n return out;\n }),\n };\n};\n\n/**\n * Join a signal's tail to its own head, so repeating it is inaudible.\n *\n * `declick` is wrong for a loop: ramping both edges to zero puts a hole at\n * every seam, once per bar for the length of the video. Instead the tail is\n * crossfaded over the head, which is the same trick a sampler uses — the last\n * few milliseconds fade out while the copy of them under the first few\n * milliseconds fades in, so the two ends already agree when they meet.\n *\n * The crossfade eats `milliseconds` from the end, which is why a looping score\n * should be written a hair long rather than exactly one bar.\n */\nexport const seamless = (signal: Signal, milliseconds = 12): Signal => {\n const fade = Math.max(1, Math.round((milliseconds / 1000) * SAMPLE_RATE));\n return {\n sampleRate: signal.sampleRate,\n channels: signal.channels.map((channel) => {\n const span = Math.min(fade, Math.floor(channel.length / 2));\n if (span <= 1) return Float32Array.from(channel);\n // The loop body is everything but the tail the crossfade consumes.\n const out = Float32Array.from(channel.subarray(0, channel.length - span));\n for (let index = 0; index < span; index += 1) {\n const level = index / span;\n out[index] = out[index] * level + channel[channel.length - span + index] * (1 - level);\n }\n return out;\n }),\n };\n};\n\n/** Peak normalize, so a cue lands predictably before the mix's loudness pass. */\nexport const normalize = (signal: Signal, peak = 0.9): Signal => {\n let highest = 0;\n for (const channel of signal.channels) {\n for (let index = 0; index < channel.length; index += 1) {\n const value = Math.abs(channel[index]);\n if (value > highest) highest = value;\n }\n }\n return highest === 0 ? signal : gain(signal, peak / highest);\n};\n\n/** Repeat a signal until it fills `samples`, for beds under a long scene. */\nexport const loop = (signal: Signal, samples: number): Signal => ({\n sampleRate: signal.sampleRate,\n channels: signal.channels.map((channel) => {\n const out = new Float32Array(samples);\n if (channel.length === 0) return out;\n for (let index = 0; index < samples; index += 1) out[index] = channel[index % channel.length];\n return out;\n }),\n});\n\n/** Seconds to samples at the fixed rate, so scores read in musical time. */\nexport const seconds = (value: number): number => Math.max(0, Math.round(value * SAMPLE_RATE));\n\n/**\n * The musical layer.\n *\n * Everything above is a waveform. A bed is not a waveform, it is a phrase: the\n * same voice at different pitches, placed on a grid. These four keep a score\n * readable at that level, so a bed reads as \"these notes, this tempo\" rather\n * than as arithmetic over sample indices — and so two beds written by two\n * people share a vocabulary instead of each inventing one.\n *\n * The rules do not change: pure functions, seeded randomness, one sample rate.\n */\n\nconst SEMITONES = {c: 0, d: 2, e: 4, f: 5, g: 7, a: 9, b: 11} as const;\n\n/**\n * Scientific pitch to frequency: `a4` is 440 Hz, `c#3` and `db3` are the same\n * key. A score names notes because \"a2\" survives transposition and reading,\n * and 110 does neither.\n */\nexport const note = (name: string): number => {\n const match = /^([a-gA-G])([#b]?)(-?\\d+)$/.exec(name.trim());\n if (!match) throw new Error(`Not a note name: \"${name}\". Use scientific pitch, for example \"a4\" or \"c#3\".`);\n const [, letter, accidental, octave] = match;\n const semitone =\n SEMITONES[letter.toLowerCase() as keyof typeof SEMITONES] +\n (accidental === \"#\" ? 1 : accidental === \"b\" ? -1 : 0) +\n (Number(octave) + 1) * 12;\n // MIDI 69 is a4 at 440 Hz; equal temperament from there.\n return 440 * 2 ** ((semitone - 69) / 12);\n};\n\n/** Samples in one step of a grid, so a score can size its own voices. */\nexport const step = (bpm: number, division = 4): number =>\n Math.max(1, Math.round((60 / bpm / (division / 4)) * SAMPLE_RATE));\n\nexport type Step = {\n /** Grid position, in steps from the start. Fractions are allowed. */\n at: number;\n /** The voice to place there, built at whatever length it needs. */\n play: (samples: number) => Signal;\n /** Length in steps. Defaults to one step. */\n length?: number;\n /** Linear gain for this hit. */\n gain?: number;\n};\n\n/**\n * Place voices on a tempo grid.\n *\n * A step's `play` receives the samples its length works out to, so one voice\n * definition serves a sixteenth and a whole bar. Swing delays every odd step\n * by a fraction of a step, which is the difference between a drum machine and\n * a groove; it is off by default because a bed under narration should not\n * shuffle unless it was asked to.\n */\nexport const sequence = (\n steps: Step[],\n options: {bpm: number; division?: number; swing?: number; samples?: number},\n): Signal => {\n const {bpm, division = 4, swing = 0, samples} = options;\n const width = step(bpm, division);\n const placed = steps.map((item) => {\n const length = Math.max(1, Math.round((item.length ?? 1) * width));\n const shuffle = swing > 0 && Math.round(item.at) % 2 === 1 ? swing * width : 0;\n const offset = Math.round(item.at * width + shuffle);\n return {offset, signal: item.gain === undefined ? item.play(length) : gain(item.play(length), item.gain)};\n });\n\n const total =\n samples ?? Math.max(0, ...placed.map(({offset, signal}) => offset + (signal.channels[0]?.length ?? 0)));\n const channelCount = Math.max(1, ...placed.map(({signal}) => signal.channels.length));\n const channels = Array.from({length: channelCount}, () => new Float32Array(total));\n\n for (const {offset, signal} of placed) {\n for (let channel = 0; channel < channelCount; channel += 1) {\n const source = signal.channels[channel] ?? signal.channels[0];\n if (!source) continue;\n const target = channels[channel];\n // A voice that runs past the end is cut, not wrapped: a phrase that\n // needs its tail should be written long enough to hold it.\n for (let index = 0; index < source.length && offset + index < total; index += 1) {\n target[offset + index] += source[index];\n }\n }\n }\n\n return {channels, sampleRate: SAMPLE_RATE};\n};\n\n/** Intervals from the root, in semitones. Enough colour for product scoring. */\nconst QUALITIES = {\n major: [0, 4, 7],\n minor: [0, 3, 7],\n sus2: [0, 2, 7],\n sus4: [0, 5, 7],\n major7: [0, 4, 7, 11],\n minor7: [0, 3, 7, 10],\n add9: [0, 4, 7, 14],\n} as const;\n\nexport type ChordQuality = keyof typeof QUALITIES;\n\n/**\n * The frequencies of a chord, root first. Voicing is left to the caller: what\n * makes a pad sound like a pad is which of these you hand to which oscillator,\n * and at what level.\n */\nexport const chord = (root: string | number, quality: ChordQuality = \"major\"): number[] => {\n const base = typeof root === \"number\" ? root : note(root);\n return QUALITIES[quality].map((interval) => base * 2 ** (interval / 12));\n};\n\n/**\n * Sustained tones under one envelope: the sound of a bed that is holding\n * rather than playing. Each voice is detuned by a few cents against the last\n * so the stack beats slowly instead of standing still, which is what separates\n * a pad from a test tone.\n */\nexport const pad = (\n frequencies: number[],\n samples: number,\n options: {envelope?: Envelope; detuneCents?: number; level?: number} = {},\n): Signal => {\n const {envelope = {attack: 0.4, sustain: 1, release: 0.6}, detuneCents = 4, level = 1 / Math.max(1, frequencies.length)} =\n options;\n const voices = frequencies.flatMap((frequency, index) => {\n const detune = 2 ** ((detuneCents * (index % 2 === 0 ? 1 : -1)) / 1200);\n return [gain(sine(samples, frequency), level), gain(sine(samples, frequency * detune), level * 0.6)];\n });\n return shape(mix(...voices), envelope);\n};\n","import {hashValue} from \"./hash\";\nimport {declick, SAMPLE_RATE, seamless, type Signal} from \"./synth\";\n\nexport type CueContext = {\n /** How many samples the cue must fill. */\n samples: number;\n sampleRate: number;\n};\n\nexport type CueDefinition = {\n readonly kind: \"odori-cue\";\n /** The name a brand registers and a video asks for. */\n name: string;\n /** Length at 30fps, which is how a contract states it. */\n durationInFrames: number;\n /**\n * Whether this score is one repeatable phrase rather than a single event.\n *\n * A looping cue renders its phrase once, at `durationInFrames`, and the\n * placement repeats it for as long as the window runs: one render, cached by\n * content, however long the scene. It also changes how the edges are\n * treated — see `defineCue` — and makes `<Audio>` loop by default, so a bed\n * fills its scene without the author restating what the cue already knows.\n */\n loops: boolean;\n /**\n * Anything the score reads. Held separately from the function so the\n * manifest can hash what a cue depends on: two cues that differ only in a\n * parameter are two different sounds and must not share a cached render.\n */\n params: Record<string, number | string | boolean>;\n render(context: CueContext): Signal;\n};\n\nexport type CueInput = Omit<CueDefinition, \"kind\" | \"loops\" | \"params\"> & {\n loops?: boolean;\n params?: Record<string, number | string | boolean>;\n};\n\n/**\n * A sound as source. The function runs unchanged in the browser for preview and\n * in Node for export, so the cue a reviewer approves is the cue that ships.\n */\nexport const defineCue = (input: CueInput): CueDefinition => ({\n kind: \"odori-cue\",\n loops: false,\n params: {},\n ...input,\n // A score is about the sound, not about remembering what a buffer does at\n // its edges. A one shot is declicked, because a buffer that stops\n // mid-waveform is a click. A loop is made seamless instead, because\n // declicking it would put that same silence at every seam.\n render: (context) => (input.loops ? seamless(input.render(context)) : declick(input.render(context))),\n});\n\nexport const isCueDefinition = (value: unknown): value is CueDefinition =>\n typeof value === \"object\" && value !== null && (value as CueDefinition).kind === \"odori-cue\";\n\n/**\n * Identity of a rendered cue. The name alone is not enough, because a project\n * can redefine what a name means; the params and the duration are what change\n * the samples, so they are what the cache and the manifest key on.\n */\nexport const cueSignature = (cue: CueDefinition): string =>\n hashValue({\n name: cue.name,\n durationInFrames: cue.durationInFrames,\n loops: cue.loops,\n params: cue.params,\n }).slice(0, 16);\n\n/** The samples a cue occupies at the given frame rate. */\nexport const cueSamples = (cue: CueDefinition, fps: number): number =>\n Math.max(1, Math.round((cue.durationInFrames / fps) * SAMPLE_RATE));\n\n/**\n * A generated cue resolves to a URL that names its own content, so the render\n * worker can serve it, the mix can find it on disk, and an unchanged cue is\n * never rendered twice.\n */\nexport const cueUrl = (cue: CueDefinition): string => `/__odori/cue/${cue.name}-${cueSignature(cue)}.wav`;\n","export type EasingFunction = (value: number) => number;\n\nconst solveBezierCoordinate = (time: number, a1: number, a2: number) => {\n const inverse = 1 - time;\n return 3 * inverse * inverse * time * a1 + 3 * inverse * time * time * a2 + time ** 3;\n};\n\nconst solveBezierSlope = (time: number, a1: number, a2: number) =>\n 3 * (1 - time) ** 2 * a1 + 6 * (1 - time) * time * (a2 - a1) + 3 * time ** 2 * (1 - a2);\n\nconst cubicBezier =\n (x1: number, y1: number, x2: number, y2: number): EasingFunction =>\n (value) => {\n if (value <= 0 || value >= 1) return value;\n let time = value;\n for (let index = 0; index < 8; index += 1) {\n const error = solveBezierCoordinate(time, x1, x2) - value;\n const slope = solveBezierSlope(time, x1, x2);\n if (Math.abs(error) < 0.000001 || Math.abs(slope) < 0.000001) break;\n time -= error / slope;\n }\n return solveBezierCoordinate(Math.min(1, Math.max(0, time)), y1, y2);\n };\n\nexport const Easing = {\n linear: (value: number) => value,\n bezier: cubicBezier,\n standard: cubicBezier(0.16, 1, 0.3, 1),\n quad: (value: number) => value * value,\n cubic: (value: number) => value ** 3,\n in: (easing: EasingFunction): EasingFunction => easing,\n out:\n (easing: EasingFunction): EasingFunction =>\n (value) =>\n 1 - easing(1 - value),\n inOut:\n (easing: EasingFunction): EasingFunction =>\n (value) =>\n value < 0.5 ? easing(value * 2) / 2 : 1 - easing((1 - value) * 2) / 2,\n};\n\nexport type InterpolateOptions = {\n easing?: EasingFunction;\n extrapolateLeft?: \"extend\" | \"clamp\";\n extrapolateRight?: \"extend\" | \"clamp\";\n};\n\nexport function interpolate(value: number, input: number[], output: number[], options?: InterpolateOptions): number;\nexport function interpolate(value: number, input: number[], output: string[], options?: InterpolateOptions): string;\nexport function interpolate(\n value: number,\n input: number[],\n output: Array<number | string>,\n options: InterpolateOptions = {},\n): number | string {\n if (input.length !== output.length || input.length < 2) {\n throw new Error(\"interpolate() requires matching input and output ranges.\");\n }\n\n let resolved = value;\n if (options.extrapolateLeft !== \"extend\") resolved = Math.max(input[0], resolved);\n if (options.extrapolateRight !== \"extend\") resolved = Math.min(input[input.length - 1], resolved);\n\n let rangeIndex = input.length - 2;\n for (let index = 0; index < input.length - 1; index += 1) {\n if (resolved <= input[index + 1]) {\n rangeIndex = index;\n break;\n }\n }\n\n const inputStart = input[rangeIndex];\n const inputEnd = input[rangeIndex + 1];\n const progress = inputEnd === inputStart ? 0 : (resolved - inputStart) / (inputEnd - inputStart);\n const eased = (options.easing ?? Easing.linear)(progress);\n const startValue = output[rangeIndex];\n const endValue = output[rangeIndex + 1];\n\n if (typeof startValue === \"number\" && typeof endValue === \"number\") {\n return startValue + (endValue - startValue) * eased;\n }\n if (typeof startValue === \"string\" && typeof endValue === \"string\") {\n const startNumbers = startValue.match(/-?\\d*\\.?\\d+/g)?.map(Number) ?? [];\n const endNumbers = endValue.match(/-?\\d*\\.?\\d+/g)?.map(Number) ?? [];\n if (startNumbers.length !== endNumbers.length) {\n throw new Error(\"String interpolation requires matching numeric segments.\");\n }\n let segment = 0;\n return startValue.replace(/-?\\d*\\.?\\d+/g, () => {\n const result = startNumbers[segment] + (endNumbers[segment] - startNumbers[segment]) * eased;\n segment += 1;\n return Number(result.toFixed(4)).toString();\n });\n }\n throw new Error(\"interpolate() output values must share a type.\");\n}\n\nexport type SpringOptions = {\n frame: number;\n fps: number;\n from?: number;\n to?: number;\n stiffness?: number;\n damping?: number;\n mass?: number;\n delayInFrames?: number;\n};\n\n/**\n * A deterministic damped-spring solve. The value depends only on the frame\n * index, so preview and render always agree.\n */\nexport const spring = ({\n frame,\n fps,\n from = 0,\n to = 1,\n stiffness = 120,\n damping = 20,\n mass = 1,\n delayInFrames = 0,\n}: SpringOptions): number => {\n const elapsed = Math.max(0, frame - delayInFrames);\n const step = 1 / fps;\n let position = 0;\n let velocity = 0;\n for (let index = 0; index < elapsed; index += 1) {\n const force = -stiffness * (position - 1) - damping * velocity;\n velocity += (force / mass) * step;\n position += velocity * step;\n }\n return from + (to - from) * position;\n};\n","import {type CueDefinition} from \"./cue\";\n\nexport type BrandColors = {\n background: string;\n surface: string;\n foreground: string;\n muted: string;\n accent: string;\n border: string;\n};\n\nexport type BrandTypography = {\n sans: string;\n mono: string;\n display?: string;\n};\n\nexport type BrandFont = {family: string; url: string; weight?: string; integrity?: string};\n\nexport type Brand = {\n readonly kind: \"odori-brand\";\n name: string;\n colors: BrandColors;\n typography: BrandTypography;\n fonts: BrandFont[];\n logos: Record<string, string>;\n motion: {standard: [number, number, number, number]; staggerFrames: number};\n audio: {\n /**\n * Symbolic cue names, so a video says what a sound means and the brand\n * decides which file that is. Values are asset references or URLs.\n */\n cues: Record<string, string | CueDefinition>;\n targetLufs: number;\n };\n};\n\nexport type BrandInput = {\n name?: string;\n colors?: Partial<BrandColors>;\n typography?: Partial<BrandTypography>;\n fonts?: BrandFont[];\n logos?: Record<string, string>;\n motion?: Partial<Brand[\"motion\"]>;\n audio?: Partial<Brand[\"audio\"]>;\n};\n\nexport const defaultBrand: Brand = {\n kind: \"odori-brand\",\n name: \"odori\",\n colors: {\n background: \"#000000\",\n surface: \"#0a0a0a\",\n foreground: \"#ededed\",\n muted: \"#a1a1a1\",\n accent: \"#ffffff\",\n border: \"#1f1f1f\",\n },\n /**\n * System faces, deliberately.\n *\n * A default that leads with a licensed family it does not ship is a default\n * that renders through a fallback on every machine while claiming not to —\n * and `odori test` is right to fail it, which meant a freshly scaffolded\n * project failed its own contract check the first time it installed a\n * component. A brand that wants Geist names it and adds the file, and the\n * check then protects that choice instead of punishing the default.\n */\n typography: {\n sans: 'system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif',\n mono: 'ui-monospace, SFMono-Regular, \"SF Mono\", Menlo, Consolas, monospace',\n },\n fonts: [],\n logos: {},\n motion: {standard: [0.16, 1, 0.3, 1], staggerFrames: 4},\n audio: {cues: {}, targetLufs: -14},\n};\n\nexport const defineBrand = (input: BrandInput): Brand => ({\n kind: \"odori-brand\",\n name: input.name ?? defaultBrand.name,\n colors: {...defaultBrand.colors, ...input.colors},\n typography: {...defaultBrand.typography, ...input.typography},\n fonts: input.fonts ?? [],\n logos: {...input.logos},\n motion: {...defaultBrand.motion, ...input.motion},\n audio: {...defaultBrand.audio, ...input.audio, cues: {...defaultBrand.audio.cues, ...input.audio?.cues}},\n});\n\nexport const brandCssVariables = (brand: Brand): Record<string, string> => ({\n \"--odori-background\": brand.colors.background,\n \"--odori-surface\": brand.colors.surface,\n \"--odori-foreground\": brand.colors.foreground,\n \"--odori-muted\": brand.colors.muted,\n \"--odori-accent\": brand.colors.accent,\n \"--odori-border\": brand.colors.border,\n \"--odori-font-sans\": brand.typography.sans,\n \"--odori-font-mono\": brand.typography.mono,\n});\n","import {type Brand, defaultBrand} from \"./brand\";\n\nexport type VideoFormat = {width: number; height: number; fps: number};\nexport type SafeArea = {x: number; y: number};\nexport type MotionPolicy = {enter: [number, number, number, number]; staggerFrames: number; reducedMotion?: boolean};\nexport type AudioPolicy = {palette: string; targetLufs: number};\n\nexport type VideoLayout = {\n readonly kind: \"odori-layout\";\n format: VideoFormat;\n brand: Brand;\n safeArea: SafeArea;\n motion: MotionPolicy;\n audio: AudioPolicy;\n transition: {crossfadeFrames: number};\n};\n\nexport type VideoLayoutInput = {\n extends?: VideoLayout;\n format?: Partial<VideoFormat>;\n brand?: Brand;\n safeArea?: SafeArea;\n motion?: Partial<MotionPolicy>;\n audio?: Partial<AudioPolicy>;\n transition?: {crossfadeFrames: number};\n};\n\nexport const defaultLayout: VideoLayout = {\n kind: \"odori-layout\",\n format: {width: 1920, height: 1080, fps: 30},\n brand: defaultBrand,\n safeArea: {x: 96, y: 72},\n motion: {enter: [0.16, 1, 0.3, 1], staggerFrames: 4},\n audio: {palette: \"product-cinematic\", targetLufs: -14},\n transition: {crossfadeFrames: 8},\n};\n\n/**\n * Merge rules from the docs: scalar format values replace, safe areas replace\n * as a unit, motion and audio policies merge onto the inherited policy, and\n * brand replaces because a brand is itself a resolved policy object.\n */\nexport const defineVideoLayout = (input: VideoLayoutInput = {}): VideoLayout => {\n const base = input.extends ?? defaultLayout;\n const brand = input.brand ?? base.brand;\n /**\n * Loudness is stated on the brand. That is where the docs put it, where the\n * scaffold writes it, and where `odori add` edits it, so a brand that asks\n * for a quiet mix has to get one: reading a layout default instead meant the\n * encoder normalised every project to the same number and the brand's own\n * figure was silently discarded. A layout that names a target still wins,\n * and so does one inherited from a layout that named one.\n */\n const inheritedTarget =\n base.audio.targetLufs === defaultLayout.audio.targetLufs ? brand.audio.targetLufs : base.audio.targetLufs;\n return {\n kind: \"odori-layout\",\n format: {...base.format, ...input.format},\n brand,\n safeArea: input.safeArea ?? base.safeArea,\n motion: {...base.motion, ...input.motion},\n audio: {...base.audio, targetLufs: inheritedTarget, ...input.audio},\n transition: input.transition ?? base.transition,\n };\n};\n","\"use client\";\n\nimport {\n Children,\n cloneElement,\n createContext,\n isValidElement,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type ComponentPropsWithoutRef,\n type ReactElement,\n type ReactNode,\n} from \"react\";\nimport {\n AssetContext,\n AudioSinkContext,\n BrandContext,\n ForceMountContext,\n FrameContext,\n LayoutContext,\n ReadinessContext,\n SceneContext,\n createAssetRegistry,\n useAssets,\n useFrame,\n useVideo,\n type Readiness,\n} from \"./context\";\nimport {\n cueId,\n isAssetReference,\n sampleGainCurve,\n sortCues,\n trackDuration,\n type AudioCue,\n type AudioProps,\n type AudioTrack,\n} from \"./audio\";\nimport {cueUrl, isCueDefinition} from \"./cue\";\nimport {Easing, interpolate} from \"./easing\";\nimport {brandCssVariables, defaultBrand, type Brand} from \"./brand\";\nimport {type VideoLayout, defaultLayout} from \"./layout\";\nimport {framesFromDuration, framesFromOffset, type Duration} from \"./time\";\n\nexport type CompiledScene = {\n id: string;\n name?: string;\n index: number;\n start: number;\n durationInFrames: number;\n /** Frames this scene starts before the previous one ends. Zero is a cut. */\n overlap: number;\n};\n/**\n * A clip on the video's own clock. Clips placed inside a scene belong to that\n * scene's internals and are not listed here: this is the video timeline.\n */\nexport type CompiledClip = {\n id: string;\n index: number;\n start: number;\n durationInFrames: number;\n};\n\nexport type CompiledTimeline = {\n scenes: CompiledScene[];\n /** Absolutely placed children of `<Video>`, in source order. */\n clips: CompiledClip[];\n durationInFrames: number;\n};\n\ntype TimelineSink = {report(timeline: CompiledTimeline): void};\n\nconst TimelineContext = createContext<TimelineSink | null>(null);\n\nexport const Fill = ({style, ...props}: ComponentPropsWithoutRef<\"div\">) => (\n <div\n {...props}\n style={{\n position: \"absolute\",\n inset: 0,\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n flexDirection: \"column\",\n overflow: \"hidden\",\n ...style,\n }}\n />\n);\n\n/** Content inset by the inherited layout safe area. */\nexport const SafeArea = ({children, style}: {children: ReactNode; style?: CSSProperties}) => {\n const layout = useContext(LayoutContext) ?? defaultLayout;\n return (\n <Fill style={{padding: `${layout.safeArea.y}px ${layout.safeArea.x}px`, ...style}}>{children}</Fill>\n );\n};\n\ntype SceneProps = {\n children: ReactNode;\n duration: Duration;\n id?: string;\n name?: string;\n /**\n * Start this many frames before the previous scene ends, so both are on\n * screen together and a transition can span the cut. The video gets shorter\n * by the same amount: an overlap is a join, not an extra beat.\n */\n overlap?: Duration;\n /**\n * How this scene meets its neighbours. `fade` dissolves it in and out, which\n * is forgiving when a scene has no entrance of its own. `cut` shows it whole\n * from its first frame, which is what most film actually does and the only\n * way to reproduce a reference that cuts.\n */\n transition?: \"fade\" | \"cut\";\n /** Injected by <Video>. Authors never pass these. */\n __start?: number;\n __index?: number;\n __durationInFrames?: number;\n __enterOverlap?: number;\n __exitOverlap?: number;\n __videoFrame?: number;\n};\n\nexport type SceneTransition = {\n /** 0 to 1 while this scene is arriving over its predecessor. */\n entering: number;\n /** 0 to 1 while its successor is arriving over it. */\n leaving: number;\n /** Frames of overlap at each end, for a component that needs the raw counts. */\n enterFrames: number;\n exitFrames: number;\n};\n\nconst SceneTransitionContext = createContext<SceneTransition>({\n entering: 1,\n leaving: 0,\n enterFrames: 0,\n exitFrames: 0,\n});\n\n/**\n * How far this scene is through the joins at its edges.\n *\n * A transition that spans a cut needs to know two things the scene itself\n * cannot see: that it is arriving over something, and that something is\n * arriving over it. Both are numbers rather than a reference to the other\n * scene — a component that could reach into its neighbour's tree would couple\n * two scenes together, and the point of the timeline is that they compose.\n *\n * Outside an overlap this reports a scene fully present and nothing leaving,\n * so a component written against it also works on an ordinary cut.\n */\nexport const useSceneTransition = (): SceneTransition => useContext(SceneTransitionContext);\n\nconst SceneEnvelope = ({children, durationInFrames}: {children: ReactNode; durationInFrames: number}) => {\n const frame = useFrame();\n const edge = Math.max(1, Math.min(10, Math.floor(durationInFrames / 6)));\n const opacity = interpolate(\n frame,\n [0, edge, Math.max(edge + 1, durationInFrames - edge), Math.max(edge + 2, durationInFrames - 1)],\n [0, 1, 1, 0],\n {easing: Easing.standard},\n );\n return <Fill style={{opacity}}>{children}</Fill>;\n};\n\n/**\n * A timeline segment with a local frame clock starting at zero.\n */\nexport const Scene = ({\n children,\n id,\n name,\n transition: treatment = \"fade\",\n __start = 0,\n __index = 0,\n __durationInFrames = 1,\n __enterOverlap = 0,\n __exitOverlap = 0,\n __videoFrame = 0,\n}: SceneProps) => {\n const config = useVideo();\n const forceMount = useContext(ForceMountContext);\n const sceneId = id ?? `scene-${__index + 1}`;\n const localFrame = __videoFrame - __start;\n const active = localFrame >= 0 && localFrame < __durationInFrames;\n if (!active && !forceMount) return null;\n\n const joined = __enterOverlap > 0 || __exitOverlap > 0;\n const transition: SceneTransition = {\n entering: __enterOverlap > 0 ? Math.min(1, Math.max(0, localFrame / __enterOverlap)) : 1,\n leaving:\n __exitOverlap > 0\n ? Math.min(1, Math.max(0, (localFrame - (__durationInFrames - __exitOverlap)) / __exitOverlap))\n : 0,\n enterFrames: __enterOverlap,\n exitFrames: __exitOverlap,\n };\n\n return (\n <SceneContext.Provider value={{id: sceneId, name, index: __index, start: __start, durationInFrames: __durationInFrames}}>\n <FrameContext.Provider\n value={{\n frame: Math.max(0, Math.min(__durationInFrames - 1, localFrame)),\n fps: config.fps,\n width: config.width,\n height: config.height,\n durationInFrames: __durationInFrames,\n }}\n >\n <SceneTransitionContext.Provider value={transition}>\n <Fill data-odori-scene={sceneId}>\n {/* Two scenes own their own edges: a joined one, because the\n envelope would fade it out underneath whatever the transition\n is doing, and one that asked to cut, because a dissolve is\n exactly what it said it did not want. */}\n {joined || treatment === \"cut\" ? (\n <Fill>{children}</Fill>\n ) : (\n <SceneEnvelope durationInFrames={__durationInFrames}>{children}</SceneEnvelope>\n )}\n </Fill>\n </SceneTransitionContext.Provider>\n </FrameContext.Provider>\n </SceneContext.Provider>\n );\n};\nScene.__odoriScene = true as const;\n\n/** An explicit offset window inside a scene, for staggered layers. */\nexport const Stagger = ({children, from = 0, duration}: {children: ReactNode; from?: Duration; duration?: Duration}) => {\n const config = useVideo();\n const frame = useFrame();\n const start = typeof from === \"number\" && Number.isInteger(from) && from > 1 ? from : framesFromDuration(from, config.fps);\n const window = duration === undefined ? config.durationInFrames : framesFromDuration(duration, config.fps);\n const local = frame - start;\n if (local < 0 || local >= window) return null;\n return (\n <FrameContext.Provider value={{...config, frame: local, durationInFrames: window}}>\n <Fill>{children}</Fill>\n </FrameContext.Provider>\n );\n};\n\n/**\n * Repeat children on a local clock.\n *\n * The frame inside is the frame within one pass, so a component written for a\n * two second window needs no idea it is being repeated. Everything stays a\n * pure function of the frame — the tenth repetition is not the first one\n * mutated ten times, it is the same computation with the same input, which is\n * why scrubbing backwards into a loop lands exactly where playing forwards\n * did.\n */\nexport const Repeat = ({\n children,\n duration,\n times,\n}: {\n children: ReactNode;\n /** Length of one pass. */\n duration: Duration;\n /** How many passes before it stops. Unlimited by default. */\n times?: number;\n}) => {\n const config = useVideo();\n const frame = useFrame();\n const window = Math.max(1, framesFromDuration(duration, config.fps));\n const pass = Math.floor(frame / window);\n if (times !== undefined && pass >= times) return null;\n\n return (\n <FrameContext.Provider value={{...config, frame: frame % window, durationInFrames: window}}>\n <Fill>{children}</Fill>\n </FrameContext.Provider>\n );\n};\n\n/**\n * Content placed at a time, rather than after the thing before it.\n *\n * A scene is a length in a sequence: it starts where the previous one ended,\n * so its position is a consequence of its siblings. That is the right model\n * for the spine of a cut, and the wrong one for anything that has to appear\n * over a scene already running — a lower third, a callout, a caption, a mark\n * that outlives the shot it started in. A clip is placed instead: it names its\n * own start, takes no space in the sequence, and moves nothing when its length\n * changes.\n *\n * It reads its clock from wherever it sits, which is what makes it compose. A\n * direct child of `<Video>` is placed against the whole cut; the same clip\n * inside a `<Scene>` is placed against that scene and disappears with it. Its\n * children see a clock starting at zero either way, so a component written for\n * a scene behaves identically inside a clip.\n *\n * Without a `duration` it runs to the end of whatever it is placed in, which\n * is what a watermark wants.\n */\nexport const Clip = ({\n children,\n id,\n from = 0,\n duration,\n}: {\n children: ReactNode;\n /** Names it on the timeline. Defaults to its position among the clips. */\n id?: string;\n /** When it starts, on the clock of whatever contains it. */\n from?: Duration;\n /** How long it lasts. To the end of the container by default. */\n duration?: Duration;\n}) => {\n const config = useVideo();\n const frame = useFrame();\n const forceMount = useContext(ForceMountContext);\n const start = framesFromOffset(from, config.fps);\n const window =\n duration === undefined\n ? Math.max(1, config.durationInFrames - start)\n : framesFromDuration(duration, config.fps);\n const local = frame - start;\n const active = local >= 0 && local < window;\n // A still of one frame mounts everything, so a contact sheet and the\n // component catalog can show a clip that this frame is not inside.\n if (!active && !forceMount) return null;\n\n return (\n <FrameContext.Provider\n value={{...config, frame: Math.max(0, Math.min(window - 1, local)), durationInFrames: window}}\n >\n <Fill data-odori-clip={id ?? true}>{children}</Fill>\n </FrameContext.Provider>\n );\n};\n\nClip.__odoriClip = true as const;\n\n/**\n * Hold children at one frame.\n *\n * Useful for the still half of a comparison, for a poster frame, and for\n * pausing an animation on the moment that makes the point. It is the frame\n * clock that stops, not the render: children still mount and lay out\n * normally, they simply always see the same number.\n */\nexport const Hold = ({children, at = 0}: {children: ReactNode; at?: Duration}) => {\n const config = useVideo();\n const held = framesFromDuration(at, config.fps);\n return (\n <FrameContext.Provider value={{...config, frame: Math.max(0, held)}}>\n <Fill>{children}</Fill>\n </FrameContext.Provider>\n );\n};\n\n/**\n * A sound placed on the timeline. Audio is declarative like a scene: it\n * registers a cue rather than starting playback, so the player, a still, and\n * the encoder all read the same track.\n */\nexport const Audio = ({\n src,\n from = 0,\n duration,\n gain = 1,\n fadeIn = 0,\n fadeOut = 0,\n trimStart = 0,\n loop,\n duckUnder = false,\n}: AudioProps) => {\n const config = useVideo();\n const sink = useContext(AudioSinkContext);\n const scene = useContext(SceneContext);\n const assets = useAssets();\n const brand = useContext(BrandContext) ?? defaultBrand;\n const frames = (value: Duration) => framesFromDuration(value, config.fps);\n // A path is a path. A name the brand knows is whatever the brand points it\n // at, which is how one edit re-scores every video. Anything else is an\n // asset reference.\n const named = brand.audio.cues[src];\n // A generated cue names itself by content, so the same score is fetched,\n // decoded, and mixed once however many videos ask for it.\n const source = isCueDefinition(named) ? cueUrl(named) : (named ?? src);\n const url = isAssetReference(source) ? assets.resolve(source) : source;\n // A looping cue is one phrase that repeats, and it says so. Taking the\n // default from the score means a bed fills its scene without every\n // composition restating what the cue already declares; `loop` on the element\n // is still the override when a video wants the other behaviour.\n const repeats = loop ?? (isCueDefinition(named) ? named.loops : false);\n\n if (sink) {\n const offset = (from === 0 ? 0 : frames(from)) + (scene?.start ?? 0);\n const window = duration === undefined ? (scene?.durationInFrames ?? config.durationInFrames) : frames(duration);\n sink.register({\n id: cueId(url, offset),\n src: url,\n fromFrame: offset,\n durationInFrames: window,\n // A curve is sampled here, once, where the window is known. Downstream\n // only ever sees points.\n gain: typeof gain === \"function\" ? 1 : gain,\n gainPoints: typeof gain === \"function\" ? sampleGainCurve(gain, offset, window) : undefined,\n fadeInFrames: fadeIn === 0 ? 0 : frames(fadeIn),\n fadeOutFrames: fadeOut === 0 ? 0 : frames(fadeOut),\n trimStartSeconds: trimStart === 0 ? 0 : frames(trimStart) / config.fps,\n loop: repeats,\n duckUnder,\n });\n }\n\n return null;\n};\nAudio.__odoriAudio = true as const;\n\nconst isSceneElement = (node: ReactNode): node is ReactElement<SceneProps> =>\n isValidElement(node) && (node.type as {__odoriScene?: boolean})?.__odoriScene === true;\n\ntype ClipProps = {children: ReactNode; id?: string; from?: Duration; duration?: Duration};\n\nconst isClipElement = (node: ReactNode): node is ReactElement<ClipProps> =>\n isValidElement(node) && (node.type as {__odoriClip?: boolean})?.__odoriClip === true;\n\n/**\n * Provides timeline structure. `<Video>` adds no duration of its own: scene\n * children are laid out in order, other children render for the whole video.\n */\nexport const Video = ({children, style}: {children: ReactNode; style?: CSSProperties}) => {\n const config = useVideo();\n const frame = useFrame();\n const sink = useContext(TimelineContext);\n const reported = useRef(\"\");\n const nodes = Children.toArray(children);\n\n const {laidOut, timeline} = useMemo(() => {\n let cursor = 0;\n let sceneIndex = 0;\n const scenes: CompiledScene[] = [];\n const overlaps: number[] = [];\n\n // Two passes: the first places every scene, because a scene's exit overlap\n // is the next scene's entry overlap and is therefore not known until the\n // next scene has been read.\n const placed = nodes.map((node) => {\n if (!isSceneElement(node)) return null;\n const durationInFrames = Math.max(1, framesFromDuration(node.props.duration, config.fps));\n const requested = node.props.overlap === undefined ? 0 : framesFromDuration(node.props.overlap, config.fps);\n // An overlap cannot be longer than either scene, or the two would cross\n // and the timeline would run backwards.\n const previous = scenes[scenes.length - 1];\n const overlap =\n sceneIndex === 0 ? 0 : Math.max(0, Math.min(requested, durationInFrames, previous?.durationInFrames ?? 0));\n\n const start = Math.max(0, cursor - overlap);\n const index = sceneIndex;\n scenes.push({id: node.props.id ?? `scene-${index + 1}`, name: node.props.name, index, start, durationInFrames, overlap});\n overlaps.push(overlap);\n cursor = start + durationInFrames;\n sceneIndex += 1;\n return {start, index, durationInFrames};\n });\n\n let placedIndex = 0;\n const output = nodes.map((node, key) => {\n if (!isSceneElement(node)) return node;\n const entry = placed[key] ?? placed.find((item) => item !== null);\n const index = placedIndex;\n placedIndex += 1;\n if (!entry) return node;\n return cloneElement(node, {\n key: `odori-scene-${key}`,\n __start: entry.start,\n __index: entry.index,\n __durationInFrames: entry.durationInFrames,\n __enterOverlap: overlaps[index] ?? 0,\n __exitOverlap: overlaps[index + 1] ?? 0,\n });\n });\n // Clips are placed, so they are read after the spine is known: an open\n // ended clip runs to the end of the video, and the video is as long as\n // its scenes unless its metadata says otherwise.\n const total = Math.max(cursor, config.durationInFrames);\n const clips: CompiledClip[] = [];\n for (const node of nodes) {\n if (!isClipElement(node)) continue;\n const index = clips.length;\n const start = framesFromOffset(node.props.from ?? 0, config.fps);\n const durationInFrames =\n node.props.duration === undefined\n ? Math.max(1, total - start)\n : framesFromDuration(node.props.duration, config.fps);\n clips.push({id: node.props.id ?? `clip-${index + 1}`, index, start, durationInFrames});\n }\n\n return {laidOut: output, timeline: {scenes, clips, durationInFrames: cursor}};\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [children, config.fps]);\n\n // The compiled timeline is recomputed whenever children change identity,\n // which happens on every frame. Report only when it actually differs, so a\n // consumer that stores it in state cannot be driven into a render loop.\n const publish = () => {\n const signature = JSON.stringify(timeline);\n if (signature === reported.current) return;\n reported.current = signature;\n sink?.report(timeline);\n };\n\n // On the server there is no effect phase, so report inline. In the browser\n // the effect keeps the report out of the render pass.\n if (typeof window === \"undefined\") publish();\n useEffect(publish);\n\n return (\n <Fill data-odori-video style={style}>\n {laidOut.map((node) =>\n isSceneElement(node) ? cloneElement(node, {__videoFrame: frame}) : node,\n )}\n </Fill>\n );\n};\n\nexport type VideoEntry = {\n component: (props: any) => ReactNode;\n metadata: {\n id: string;\n title: string;\n description?: string;\n duration?: Duration;\n layout?: VideoLayout;\n schema?: {parse(input: unknown): unknown};\n defaultProps?: Record<string, unknown>;\n tags?: string[];\n thumbnailFrame?: number;\n };\n};\n\nexport type OdoriRuntimeProps = {\n entry: VideoEntry;\n frame: number;\n input?: Record<string, unknown>;\n prepared?: unknown;\n assets?: Array<{reference: string; url: string}>;\n layout?: VideoLayout;\n onTimeline?: (timeline: CompiledTimeline) => void;\n onAudio?: (track: AudioTrack) => void;\n};\n\nexport const resolveEntryLayout = (entry: VideoEntry, override?: VideoLayout): VideoLayout =>\n override ?? entry.metadata.layout ?? defaultLayout;\n\nexport const entryDurationInFrames = (entry: VideoEntry, layout: VideoLayout): number =>\n entry.metadata.duration === undefined ? 0 : framesFromDuration(entry.metadata.duration, layout.format.fps);\n\nconst fontFaceCss = (fonts: Brand[\"fonts\"]) =>\n fonts\n .map(\n (font) =>\n `@font-face{font-family:\"${font.family}\";src:url(\"${font.url}\") format(\"woff2\");font-weight:${\n font.weight ?? \"100 900\"\n };font-display:block;font-style:normal;}`,\n )\n .join(\"\");\n\n/** Faces already installed in this document, so a remount never reloads them. */\nconst installedFonts = new Set<string>();\n\n/**\n * Brand fonts are declared as policy, not imported by components, so preview,\n * stills, and the export worker all load the same faces before the first frame\n * is captured.\n *\n * In the browser the rules are installed once at the document level and never\n * removed. Rendering them inside the tree would drop every face each time a\n * video unmounts, which reloads the fonts and reflows the whole page.\n */\nconst FontFaces = ({fonts}: {fonts: Brand[\"fonts\"]}) => {\n const css = useMemo(() => fontFaceCss(fonts), [fonts]);\n\n useEffect(() => {\n if (!css || installedFonts.has(css)) return;\n installedFonts.add(css);\n const style = document.createElement(\"style\");\n style.dataset.odoriFonts = \"\";\n style.textContent = css;\n document.head.append(style);\n }, [css]);\n\n // Server rendering has no effect phase, so the faces stay inline there.\n return typeof window === \"undefined\" && css ? <style data-odori-fonts>{css}</style> : null;\n};\n\n/**\n * Mounts every scene at once, invisibly, so `<Audio>` cues can be collected\n * without seeking through the whole timeline first.\n */\nconst AudioPass = ({\n children,\n onAudio,\n durationInFrames,\n}: {\n children: ReactNode;\n onAudio: (track: AudioTrack) => void;\n durationInFrames: number;\n}) => {\n const collected = useRef(new Map<string, AudioCue>());\n const reported = useRef(\"\");\n const sink = useMemo(\n () => ({\n register: (cue: AudioCue) => {\n collected.current.set(cue.id, cue);\n },\n }),\n [],\n );\n\n collected.current.clear();\n const tree = (\n <AudioSinkContext.Provider value={sink}>\n <ForceMountContext.Provider value>{children}</ForceMountContext.Provider>\n </AudioSinkContext.Provider>\n );\n\n const publish = () => {\n const cues = sortCues([...collected.current.values()]);\n const signature = JSON.stringify(cues);\n if (signature === reported.current) return;\n reported.current = signature;\n onAudio({cues, durationInFrames: Math.max(durationInFrames, trackDuration(cues))});\n };\n\n useEffect(publish);\n\n return (\n <div aria-hidden data-odori-audio-pass style={{display: \"none\"}}>\n {tree}\n {/* Rendered after the tree, so on the server every cue has registered\n by the time this publishes. */}\n <Publisher publish={publish} />\n </div>\n );\n};\n\nconst Publisher = ({publish}: {publish: () => void}) => {\n if (typeof window === \"undefined\") publish();\n return null;\n};\n\nexport const OdoriRuntime = ({entry, frame, input, prepared, assets, layout, onTimeline, onAudio}: OdoriRuntimeProps) => {\n const resolvedLayout = resolveEntryLayout(entry, layout);\n const {format, brand} = resolvedLayout;\n const registry = useMemo(() => createAssetRegistry(assets ?? []), [assets]);\n const sink = useMemo<TimelineSink>(() => ({report: (timeline) => onTimeline?.(timeline)}), [onTimeline]);\n\n const props = useMemo(() => {\n const merged = {...entry.metadata.defaultProps, ...input};\n return entry.metadata.schema ? (entry.metadata.schema.parse(merged) as Record<string, unknown>) : merged;\n }, [entry, input]);\n\n const durationInFrames = entryDurationInFrames(entry, resolvedLayout);\n const Composition = entry.component;\n\n // The frame attribute is the readiness handshake the render worker waits on,\n // so it is written only once every held handle has been released.\n const [pending, setPending] = useState(0);\n const readiness = useMemo<Readiness>(\n () => ({\n hold: () => {\n setPending((count) => count + 1);\n let released = false;\n return () => {\n if (released) return;\n released = true;\n setPending((count) => Math.max(0, count - 1));\n };\n },\n }),\n [],\n );\n\n return (\n <LayoutContext.Provider value={resolvedLayout}>\n <BrandContext.Provider value={brand}>\n <AssetContext.Provider value={registry}>\n <ReadinessContext.Provider value={readiness}>\n <TimelineContext.Provider value={sink}>\n <FrameContext.Provider\n value={{\n frame,\n fps: format.fps,\n width: format.width,\n height: format.height,\n durationInFrames: durationInFrames || 1,\n }}\n >\n <Fill\n data-odori-frame={pending === 0 ? frame : undefined}\n style={\n {\n backgroundColor: brand.colors.background,\n color: brand.colors.foreground,\n fontFamily: brand.typography.sans,\n ...brandCssVariables(brand),\n } as CSSProperties\n }\n >\n <FontFaces fonts={brand.fonts} />\n <Composition {...props} prepared={prepared} />\n {/* The pass is keyed by composition: it dedupes against what it\n last published, so a consumer that clears its track when the\n selection changes would otherwise never be handed the cues\n again for two videos that share one cue signature. */}\n {onAudio ? (\n <AudioPass key={entry.metadata.id} onAudio={onAudio} durationInFrames={durationInFrames}>\n <Composition {...props} prepared={prepared} />\n </AudioPass>\n ) : null}\n </Fill>\n </FrameContext.Provider>\n </TimelineContext.Provider>\n </ReadinessContext.Provider>\n </AssetContext.Provider>\n </BrandContext.Provider>\n </LayoutContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;AAEA,SAAQ,eAAe,kBAAiB;AAcjC,IAAM,eAAe,cAAiC,IAAI;AAC1D,IAAM,eAAe,cAAiC,IAAI;AAC1D,IAAM,eAAe,cAA4B,IAAI;AACrD,IAAM,gBAAgB,cAAkC,IAAI;AAC5D,IAAM,eAAe,cAAoC,IAAI;AAK7D,IAAM,mBAAmB,cAAgC,IAAI;AAG7D,IAAM,oBAAoB,cAAc,KAAK;AAO7C,IAAM,mBAAmB,cAAgC,IAAI;AAS7D,IAAM,eAAe,MAAiB;AAC3C,QAAM,YAAY,WAAW,gBAAgB;AAG7C,SAAO,aAAa,EAAC,MAAM,MAAM,MAAM,OAAS;AAClD;AAEA,IAAM,WAAW,CAAS,OA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BAAkB,YAAY,IAAI,QAAQ;AAAA,UAC1C,OACE;AAAA,YACE,iBAAiB,MAAM,OAAO;AAAA,YAC9B,OAAO,MAAM,OAAO;AAAA,YACpB,YAAY,MAAM,WAAW;AAAA,YAC7B,GAAG,kBAAkB,KAAK;AAAA,UAC5B;AAAA,UAGF;AAAA,gCAAC,aAAU,OAAO,MAAM,OAAO;AAAA,YAC/B,oBAAC,eAAa,GAAG,OAAO,UAAoB;AAAA,YAK3C,UACC,oBAAC,aAAkC,SAAkB,kBACnD,8BAAC,eAAa,GAAG,OAAO,UAAoB,KAD9B,MAAM,SAAS,EAE/B,IACE;AAAA;AAAA;AAAA,MACN;AAAA;AAAA,EACF,GACF,GACA,GACF,GACF,GACF;AAEJ;","names":["window","step","createContext","useContext","createContext","useContext","window","gain","loop"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { V as VideoEntry, a as VideoLayout, C as CompiledTimeline, A as AudioTrack } from './manifest-
|
|
2
|
-
export { b as Audio, c as AudioCue, d as AudioPolicy, e as AudioProps, f as
|
|
1
|
+
import { V as VideoEntry, a as VideoLayout, C as CompiledTimeline, A as AudioTrack } from './manifest-d7-HWIFj.js';
|
|
2
|
+
export { b as Audio, c as AudioCue, d as AudioPolicy, e as AudioProps, f as Clip, g as CompiledScene, h as CreateManifestOptions, D as DUCK_GAIN, i as DUCK_RAMP_FRAMES, E as EnvelopePoint, j as ExportJob, F as Fill, H as Hold, M as ManifestAsset, k as ManifestAudioCue, l as ManifestFont, m as MotionPolicy, O as OdoriRuntime, n as OdoriRuntimeProps, R as RenderManifest, o as Repeat, S as SafeArea, p as SafeAreaPolicy, q as Scene, r as SceneTransition, s as Stagger, t as Video, u as VideoFormat, v as VideoLayoutInput, w as createRenderManifest, x as cueId, y as defaultLayout, z as defineVideoLayout, B as duckEnvelope, G as entryDurationInFrames, I as envelopeAtFrame, J as gainAtFrame, K as isAssetReference, L as resolveEntryLayout, N as sampleGainCurve, P as sortCues, Q as trackDuration, T as trackGainAtFrame, U as useSceneTransition } from './manifest-d7-HWIFj.js';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import { CSSProperties, RefObject } from 'react';
|
|
5
|
-
import { B as Brand, S as Signal, D as Duration } from './brand-
|
|
6
|
-
export { a as BrandColors, b as BrandFont, c as BrandInput, d as BrandTypography, C as ChordQuality, e as CueContext, f as CueDefinition, E as Envelope, g as SAMPLE_RATE, h as Step, i as brandCssVariables, j as chord, k as cueSamples, l as cueSignature, m as cueUrl, n as defaultBrand, o as defineBrand, p as defineCue, q as formatTimecode, r as framesFromDuration, s as
|
|
5
|
+
import { B as Brand, S as Signal, D as Duration } from './brand-B-Mv4S_Z.js';
|
|
6
|
+
export { a as BrandColors, b as BrandFont, c as BrandInput, d as BrandTypography, C as ChordQuality, e as CueContext, f as CueDefinition, E as Envelope, g as SAMPLE_RATE, h as Step, i as brandCssVariables, j as chord, k as cueSamples, l as cueSignature, m as cueUrl, n as defaultBrand, o as defineBrand, p as defineCue, q as formatTimecode, r as framesFromDuration, s as framesFromOffset, t as gain, u as highPass, v as isCueDefinition, w as loop, x as lowPass, y as mix, z as noise, A as normalize, F as note, G as pad, H as seamless, I as seconds, J as secondsFromFrames, K as seeded, L as sequence, M as shape, N as silence, O as sine, P as step, Q as sweep, R as triangle } from './brand-B-Mv4S_Z.js';
|
|
7
7
|
import { P as ParsableSchema } from './schema-DXxRezrk.js';
|
|
8
8
|
export { F as FieldDescriptor, I as InputSchema, d as defineInputSchema, i as isOdoriSchema, p as parseWithSchema } from './schema-DXxRezrk.js';
|
|
9
9
|
|
|
@@ -28,7 +28,7 @@ type Biquad = {
|
|
|
28
28
|
*/
|
|
29
29
|
declare const integratedLufs: (channels: Float32Array[], sampleRate: number) => number | null;
|
|
30
30
|
|
|
31
|
-
type
|
|
31
|
+
type ViewerProps = {
|
|
32
32
|
entry: VideoEntry;
|
|
33
33
|
input?: Record<string, unknown>;
|
|
34
34
|
prepared?: unknown;
|
|
@@ -48,11 +48,19 @@ type PlayerProps = {
|
|
|
48
48
|
onAudio?: (track: AudioTrack) => void;
|
|
49
49
|
};
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
51
|
+
* A composition, embeddable and seekable, for a product surface rather than
|
|
52
|
+
* for Studio.
|
|
53
|
+
*
|
|
54
|
+
* Playback advances a fractional frame counter from wall-clock deltas, but
|
|
55
|
+
* React only ever sees an integer frame, so a paused viewer and a render
|
|
56
|
+
* worker produce identical output: what somebody watches in your app is the
|
|
57
|
+
* file you would export.
|
|
58
|
+
*
|
|
59
|
+
* The controls here are the plain ones. A surface that wants its own transport
|
|
60
|
+
* imports `usePlayback` instead and keeps this out of it, which is what Studio
|
|
61
|
+
* and the documentation site both do.
|
|
54
62
|
*/
|
|
55
|
-
declare const
|
|
63
|
+
declare const Viewer: ({ entry, input, prepared, assets, layout, initialFrame, autoPlay, loop, controls, muted, style, onFrame, onTimeline, onAudio, }: ViewerProps) => react_jsx_runtime.JSX.Element;
|
|
56
64
|
|
|
57
65
|
type AudioPlaybackOptions = {
|
|
58
66
|
track: AudioTrack | null;
|
|
@@ -288,6 +296,49 @@ declare const cursorAt: (stops: CursorStop[], frame: number) => CursorState;
|
|
|
288
296
|
/** The last frame an authored path is still on screen, for sizing a scene. */
|
|
289
297
|
declare const cursorDuration: (stops: CursorStop[]) => number;
|
|
290
298
|
|
|
299
|
+
type TypingOptions = {
|
|
300
|
+
/** Frame the first character lands on. */
|
|
301
|
+
from?: number;
|
|
302
|
+
/** Characters revealed per second. */
|
|
303
|
+
charactersPerSecond?: number;
|
|
304
|
+
/**
|
|
305
|
+
* Characters revealed per step. Typing one character at a time reads as a
|
|
306
|
+
* machine at high speeds; two or three at a time reads as hands, because
|
|
307
|
+
* that is roughly what a fast typist does between glances at the screen.
|
|
308
|
+
*/
|
|
309
|
+
chunk?: number;
|
|
310
|
+
/** Frames the caret stays solid after the last character before it blinks. */
|
|
311
|
+
settle?: number;
|
|
312
|
+
};
|
|
313
|
+
type TypingState = {
|
|
314
|
+
/** What is on screen at this frame. */
|
|
315
|
+
text: string;
|
|
316
|
+
/** How many characters of the source are revealed. */
|
|
317
|
+
length: number;
|
|
318
|
+
/** True once every character is on screen. */
|
|
319
|
+
done: boolean;
|
|
320
|
+
/**
|
|
321
|
+
* Whether the caret is drawn this frame: solid while typing and for a beat
|
|
322
|
+
* after, blinking once the line is finished, the way a terminal waits.
|
|
323
|
+
*/
|
|
324
|
+
caret: boolean;
|
|
325
|
+
/** 0 before the first character, 1 at the last. */
|
|
326
|
+
progress: number;
|
|
327
|
+
};
|
|
328
|
+
/** Frames the typing itself occupies, for laying out what comes after it. */
|
|
329
|
+
declare const typingFrames: (text: string, options?: TypingOptions, fps?: number) => number;
|
|
330
|
+
/**
|
|
331
|
+
* What a line of typed text looks like at one frame.
|
|
332
|
+
*
|
|
333
|
+
* A pure function of the frame, so scrubbing backwards untypes the line
|
|
334
|
+
* exactly and two render workers on either side of a chunk boundary agree
|
|
335
|
+
* character for character. The caret is part of the state rather than a
|
|
336
|
+
* separate blink timer for the same reason.
|
|
337
|
+
*/
|
|
338
|
+
declare const typedAt: (text: string, frame: number, options?: TypingOptions, fps?: number) => TypingState;
|
|
339
|
+
/** `typedAt` bound to the current frame. */
|
|
340
|
+
declare const useTyping: (text: string, options?: TypingOptions) => TypingState;
|
|
341
|
+
|
|
291
342
|
/**
|
|
292
343
|
* Randomness that survives a re-render.
|
|
293
344
|
*
|
|
@@ -461,4 +512,4 @@ declare const canonicalJson: (value: unknown) => string;
|
|
|
461
512
|
declare const hashString: (input: string) => string;
|
|
462
513
|
declare const hashValue: (value: unknown) => string;
|
|
463
514
|
|
|
464
|
-
export { type AssetRegistry, type AudioPlaybackOptions, AudioTrack, type Biquad, Brand, type CanvasDraw, CompiledTimeline, type CursorState, type CursorStop, Duration, Easing, type EasingFunction, type FrameState, type InterpolateOptions, ParsableSchema, type PlaceholderOptions, type Playback, type PlaybackOptions,
|
|
515
|
+
export { type AssetRegistry, type AudioPlaybackOptions, AudioTrack, type Biquad, Brand, type CanvasDraw, CompiledTimeline, type CursorState, type CursorStop, Duration, Easing, type EasingFunction, type FrameState, type InterpolateOptions, ParsableSchema, type PlaceholderOptions, type Playback, type PlaybackOptions, type PrepareContext, type PrepareFunction, type Readiness, RenderSurface, type SceneState, Signal, type SpringOptions, type TypingOptions, type TypingState, VideoEntry, VideoLayout, type VideoMetadata, type VideoMetadataInput, Viewer, type ViewerProps, advanceFrames, canonicalJson, createAssetRegistry, cursorAt, cursorDuration, definePrepare, defineVideoMetadata, drawHtml, encodeWav, hashString, hashValue, integratedLufs, interpolate, isValidVideoId, placeholderFrame, placeholderImage, placeholderSvg, random, randomBetween, randomOrder, randomPick, resolveVideoId, spring, typedAt, typingFrames, useAssets, useAudioPlayback, useBrand, useCanvas, useDesignScale, useFrame, useLayout, usePlayback, useReadiness, useScene, useTyping, useVideo };
|