odori 0.0.1 → 0.0.2

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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/loudness.ts","../src/player.tsx","../src/playback.ts","../src/audio-playback.ts","../src/render-surface.tsx","../src/wav.ts","../src/cursor.ts","../src/random.ts","../src/canvas.ts","../src/placeholder.ts","../src/metadata.ts","../src/schema.ts"],"sourcesContent":["/**\n * Integrated loudness, ITU-R BS.1770-4.\n *\n * The number a mix is judged by is not peak or RMS: it is K-weighted, gated\n * loudness. Studio measures what it is about to hand the encoder so the\n * brand's target is something you can mix toward rather than discover after an\n * export.\n */\n\nexport type Biquad = {b0: number; b1: number; b2: number; a1: number; a2: number};\n\n/** Stage 1: the head shelf, and stage 2: the high pass, from the spec's filter table. */\nconst SHELF = {frequency: 1681.974450955533, gainDb: 3.999843853973347, q: 0.7071752369554196};\nconst HIGH_PASS = {frequency: 38.13547087602444, q: 0.5003270373238773};\n\n/**\n * The spec tabulates coefficients at 48 kHz. Deriving them per rate keeps a\n * 44.1 kHz source from being measured with the wrong filter.\n */\nexport const shelfCoefficients = (sampleRate: number): Biquad => {\n const amplitude = 10 ** (SHELF.gainDb / 40);\n const omega = (2 * Math.PI * SHELF.frequency) / sampleRate;\n const alpha = Math.sin(omega) / (2 * SHELF.q);\n const cos = Math.cos(omega);\n const shared = 2 * Math.sqrt(amplitude) * alpha;\n const a0 = amplitude + 1 - (amplitude - 1) * cos + shared;\n return {\n b0: (amplitude * (amplitude + 1 + (amplitude - 1) * cos + shared)) / a0,\n b1: (-2 * amplitude * (amplitude - 1 + (amplitude + 1) * cos)) / a0,\n b2: (amplitude * (amplitude + 1 + (amplitude - 1) * cos - shared)) / a0,\n a1: (2 * (amplitude - 1 - (amplitude + 1) * cos)) / a0,\n a2: (amplitude + 1 - (amplitude - 1) * cos - shared) / a0,\n };\n};\n\nexport const highPassCoefficients = (sampleRate: number): Biquad => {\n const omega = (2 * Math.PI * HIGH_PASS.frequency) / sampleRate;\n const alpha = Math.sin(omega) / (2 * HIGH_PASS.q);\n const cos = Math.cos(omega);\n const a0 = 1 + alpha;\n return {\n b0: (1 + cos) / 2 / a0,\n b1: (-(1 + cos)) / a0,\n b2: (1 + cos) / 2 / a0,\n a1: (-2 * cos) / a0,\n a2: (1 - alpha) / a0,\n };\n};\n\nconst filter = (samples: Float32Array, {b0, b1, b2, a1, a2}: Biquad): Float32Array => {\n const output = new Float32Array(samples.length);\n let x1 = 0;\n let x2 = 0;\n let y1 = 0;\n let y2 = 0;\n for (let index = 0; index < samples.length; index += 1) {\n const x0 = samples[index];\n const y0 = b0 * x0 + b1 * x1 + b2 * x2 - a1 * y1 - a2 * y2;\n output[index] = y0;\n x2 = x1;\n x1 = x0;\n y2 = y1;\n y1 = y0;\n }\n return output;\n};\n\nconst BLOCK_SECONDS = 0.4;\n/** Blocks overlap by 75%, so a short transient cannot hide between them. */\nconst STEP = 0.25;\nconst ABSOLUTE_GATE = -70;\nconst RELATIVE_GATE = -10;\nconst OFFSET = -0.691;\n\nconst loudnessOf = (meanSquares: number[]) =>\n OFFSET + 10 * Math.log10(meanSquares.reduce((total, value) => total + value, 0) || Number.MIN_VALUE);\n\n/**\n * Channel weights for stereo. Surround weights the surround channels higher;\n * a video mix is stereo, so both channels count equally.\n */\nexport const integratedLufs = (channels: Float32Array[], sampleRate: number): number | null => {\n if (channels.length === 0 || channels[0].length === 0) return null;\n const weighted = channels.map((channel) => filter(filter(channel, shelfCoefficients(sampleRate)), highPassCoefficients(sampleRate)));\n\n const blockSize = Math.round(BLOCK_SECONDS * sampleRate);\n const hop = Math.round(BLOCK_SECONDS * STEP * sampleRate);\n if (weighted[0].length < blockSize) return null;\n\n // One mean square per channel per block, kept apart so gating can sum them.\n const blocks: number[][] = [];\n for (let start = 0; start + blockSize <= weighted[0].length; start += hop) {\n blocks.push(\n weighted.map((channel) => {\n let sum = 0;\n for (let index = start; index < start + blockSize; index += 1) sum += channel[index] * channel[index];\n return sum / blockSize;\n }),\n );\n }\n if (blocks.length === 0) return null;\n\n const above = blocks.filter((block) => loudnessOf(block) > ABSOLUTE_GATE);\n if (above.length === 0) return null;\n\n // The relative gate is measured against the ungated mean of what survived.\n const mean = above[0].map((_, channel) => above.reduce((total, block) => total + block[channel], 0) / above.length);\n const threshold = loudnessOf(mean) + RELATIVE_GATE;\n const gated = above.filter((block) => loudnessOf(block) > threshold);\n if (gated.length === 0) return null;\n\n const integrated = gated[0].map((_, channel) => gated.reduce((total, block) => total + block[channel], 0) / gated.length);\n return loudnessOf(integrated);\n};\n","\"use client\";\n\nimport {useCallback, useMemo, useState, type CSSProperties} from \"react\";\nimport {OdoriRuntime, entryDurationInFrames, resolveEntryLayout, type CompiledTimeline, type VideoEntry} from \"./runtime\";\nimport {type VideoLayout} from \"./layout\";\nimport {formatTimecode} from \"./time\";\nimport {usePlayback} from \"./playback\";\nimport {useAudioPlayback} from \"./audio-playback\";\nimport {type AudioTrack} from \"./audio\";\n\nexport type PlayerProps = {\n entry: VideoEntry;\n input?: Record<string, unknown>;\n prepared?: unknown;\n assets?: Array<{reference: string; url: string}>;\n layout?: VideoLayout;\n initialFrame?: number;\n autoPlay?: boolean;\n loop?: boolean;\n controls?: boolean;\n style?: CSSProperties;\n muted?: boolean;\n onFrame?: (frame: number) => void;\n onTimeline?: (timeline: CompiledTimeline) => void;\n onAudio?: (track: AudioTrack) => void;\n};\n\n/**\n * The seekable frame clock. Playback advances a fractional frame counter from\n * wall-clock deltas, but React only ever sees an integer frame, so a paused\n * player and a render worker produce identical output.\n */\nexport const Player = ({\n entry,\n input,\n prepared,\n assets,\n layout,\n initialFrame = 0,\n autoPlay = false,\n loop = true,\n controls = true,\n muted = false,\n style,\n onFrame,\n onTimeline,\n onAudio,\n}: PlayerProps) => {\n const resolvedLayout = resolveEntryLayout(entry, layout);\n const {fps, width, height} = resolvedLayout.format;\n const [timeline, setTimeline] = useState<CompiledTimeline | null>(null);\n const [track, setTrack] = useState<AudioTrack | null>(null);\n const declared = entryDurationInFrames(entry, resolvedLayout);\n const durationInFrames = Math.max(1, declared || timeline?.durationInFrames || fps);\n\n const playback = usePlayback({fps, durationInFrames, initialFrame, autoPlay, loop, onFrame});\n const {frame} = playback;\n\n useAudioPlayback({track, frame: playback.frame, fps, playing: playback.playing, muted});\n\n const handleAudio = useCallback(\n (next: AudioTrack) => {\n setTrack(next);\n onAudio?.(next);\n },\n [onAudio],\n );\n\n const handleTimeline = useCallback(\n (next: CompiledTimeline) => {\n // Comparing the count and total would hold a stale timeline when two\n // scenes trade frames between them: same length, same total, different\n // boundaries.\n setTimeline((current) => (JSON.stringify(current) === JSON.stringify(next) ? current : next));\n onTimeline?.(next);\n },\n [onTimeline],\n );\n\n const aspectRatio = useMemo(() => `${width} / ${height}`, [height, width]);\n const activeScene = timeline?.scenes.find(\n (scene) => frame >= scene.start && frame < scene.start + scene.durationInFrames,\n );\n\n return (\n <div className=\"odori-player\" style={{display: \"grid\", gap: 12, width: \"100%\", ...style}}>\n <div\n data-odori-player\n style={{\n aspectRatio,\n background: resolvedLayout.brand.colors.background,\n borderRadius: 10,\n overflow: \"hidden\",\n position: \"relative\",\n width: \"100%\",\n }}\n >\n <OdoriRuntime\n entry={entry}\n frame={frame}\n input={input}\n prepared={prepared}\n assets={assets}\n layout={layout}\n onTimeline={handleTimeline}\n onAudio={handleAudio}\n />\n </div>\n {controls ? (\n <div className=\"odori-player-controls\" style={{alignItems: \"center\", display: \"flex\", gap: 10}}>\n <button type=\"button\" onClick={playback.toggle}>\n {playback.playing ? \"Pause\" : \"Play\"}\n </button>\n <button type=\"button\" onClick={() => playback.step(-1)} aria-label=\"Previous frame\">\n {\"\\u2039\"}\n </button>\n <button type=\"button\" onClick={() => playback.step(1)} aria-label=\"Next frame\">\n {\"\\u203a\"}\n </button>\n <input\n aria-label=\"Timeline\"\n type=\"range\"\n min={0}\n max={durationInFrames - 1}\n value={frame}\n onChange={(event) => {\n playback.pause();\n playback.seek(Number(event.currentTarget.value));\n }}\n style={{flex: 1}}\n />\n <output style={{fontVariantNumeric: \"tabular-nums\", minWidth: 132, textAlign: \"right\"}}>\n {formatTimecode(frame, fps)} {\"·\"} {frame}/{durationInFrames - 1}\n {activeScene ? ` · ${activeScene.name ?? activeScene.id}` : \"\"}\n </output>\n </div>\n ) : null}\n </div>\n );\n};\n","\"use client\";\n\nimport {useCallback, useEffect, useRef, useState} from \"react\";\n\nexport type PlaybackOptions = {\n fps: number;\n durationInFrames: number;\n initialFrame?: number;\n autoPlay?: boolean;\n loop?: boolean;\n /** Wall-clock multiplier. The frame clock keeps its rate; only time moves. */\n rate?: number;\n onFrame?: (frame: number) => void;\n};\n\nexport type Playback = {\n frame: number;\n playing: boolean;\n rate: number;\n play(): void;\n pause(): void;\n toggle(): void;\n seek(frame: number): void;\n step(delta: number): void;\n restart(): void;\n};\n\n/**\n * The seekable frame clock. Playback advances a fractional counter from\n * wall-clock deltas, but React only ever sees an integer frame, so a paused\n * player, a still, and the export worker agree by construction.\n */\n/**\n * How far the clock moves for a wall-clock delta.\n *\n * Rate scales elapsed time, never the frame index, so frame 90 is the same\n * image at 0.25x, 1x, and 4x, and an export ignores rate entirely.\n */\nexport const advanceFrames = (fractional: number, deltaMs: number, fps: number, rate = 1): number =>\n fractional + (deltaMs / 1000) * fps * rate;\n\nexport const usePlayback = ({\n fps,\n durationInFrames,\n initialFrame = 0,\n autoPlay = false,\n loop = true,\n rate = 1,\n onFrame,\n}: PlaybackOptions): Playback => {\n const [frame, setFrame] = useState(initialFrame);\n const [playing, setPlaying] = useState(autoPlay);\n const animation = useRef<number | null>(null);\n const previousTime = useRef<number | null>(null);\n const fractional = useRef(initialFrame);\n const frameRef = useRef(initialFrame);\n\n const commit = useCallback(\n (next: number) => {\n const clamped = Math.max(0, Math.min(Math.round(next), Math.max(0, durationInFrames - 1)));\n frameRef.current = clamped;\n setFrame(clamped);\n onFrame?.(clamped);\n },\n [durationInFrames, onFrame],\n );\n\n useEffect(() => {\n if (!playing) {\n previousTime.current = null;\n fractional.current = frameRef.current;\n return;\n }\n const tick = (now: number) => {\n const previous = previousTime.current ?? now;\n previousTime.current = now;\n fractional.current = advanceFrames(fractional.current, now - previous, fps, rate);\n if (fractional.current >= durationInFrames) {\n if (!loop) {\n commit(durationInFrames - 1);\n setPlaying(false);\n return;\n }\n fractional.current %= durationInFrames;\n }\n commit(Math.floor(fractional.current));\n animation.current = requestAnimationFrame(tick);\n };\n animation.current = requestAnimationFrame(tick);\n return () => {\n if (animation.current !== null) cancelAnimationFrame(animation.current);\n };\n }, [commit, durationInFrames, fps, loop, playing, rate]);\n\n const seek = useCallback(\n (next: number) => {\n fractional.current = next;\n commit(next);\n },\n [commit],\n );\n\n return {\n frame,\n playing,\n rate,\n play: () => setPlaying(true),\n pause: () => setPlaying(false),\n toggle: () => setPlaying((value) => !value),\n seek,\n step: (delta: number) => {\n setPlaying(false);\n seek(frameRef.current + delta);\n },\n restart: () => {\n seek(0);\n setPlaying(true);\n },\n };\n};\n","\"use client\";\n\nimport {useEffect, useRef} from \"react\";\nimport {trackGainAtFrame, type AudioTrack} from \"./audio\";\n\nexport type AudioPlaybackOptions = {\n track: AudioTrack | null;\n frame: number;\n fps: number;\n playing: boolean;\n muted?: boolean;\n masterGain?: number;\n /** Cue id to hear alone, or null for the whole mix. */\n soloCue?: string | null;\n /** True while the playhead is being dragged, which auditions under the cursor. */\n scrubbing?: boolean;\n /** Playback rate, so cues stay with the frame clock when it is sped up. */\n rate?: number;\n /**\n * Called when the browser refuses to start a cue without a user gesture, and\n * again when it relents. Autoplay policy is the difference between a silent\n * preview and a broken one, so it is reported rather than swallowed.\n */\n onBlocked?: (blocked: boolean) => void;\n /**\n * Called with the cues whose files failed to load or decode. A cue pointing\n * at a missing or wrong file is silence with no other symptom, so it is\n * reported rather than swallowed.\n */\n onFailed?: (sources: string[]) => void;\n};\n\n/**\n * Drives one HTMLAudioElement per cue from the frame clock.\n *\n * Audio is the one thing that cannot be derived from a frame index, so preview\n * playback resyncs whenever the element drifts more than a frame from where the\n * timeline says it should be. The exported mix is built separately by the\n * encoder from the same cues, which keeps the file frame accurate.\n */\nexport const useAudioPlayback = ({\n track,\n frame,\n fps,\n playing,\n muted = false,\n masterGain = 1,\n soloCue = null,\n scrubbing = false,\n rate = 1,\n onBlocked,\n onFailed,\n}: AudioPlaybackOptions) => {\n const elements = useRef(new Map<string, HTMLAudioElement>());\n // The sync pass, reachable from listeners that fire when the frame has not\n // changed: the clock can stall (a hidden tab throttles rAF, a slow render\n // drops frames) while an audio element keeps running at its own pace.\n const sync = useRef<() => void>(() => {});\n const failed = useRef(new Set<string>());\n\n useEffect(() => {\n const table = elements.current;\n const live = new Set((track?.cues ?? []).map((cue) => cue.id));\n for (const [id, element] of table) {\n if (live.has(id)) continue;\n element.pause();\n table.delete(id);\n }\n return () => {\n for (const element of table.values()) element.pause();\n };\n }, [track]);\n\n useEffect(() => {\n if (typeof window === \"undefined\") return;\n const table = elements.current;\n\n const onTimeUpdate = () => run();\n\n const run = () => {\n // Scrubbing is playback the user is driving by hand, so cues sound under\n // the cursor instead of going silent the moment the transport pauses.\n const audible = playing || scrubbing;\n\n for (const cue of track?.cues ?? []) {\n let element = table.get(cue.id);\n if (!element) {\n element = new window.Audio(cue.src);\n element.preload = \"auto\";\n element.loop = cue.loop;\n // An element that drifts while the clock is stalled corrects itself\n // on its own time updates, so audio can never run away from a\n // frozen picture.\n element.addEventListener(\"timeupdate\", onTimeUpdate);\n element.addEventListener(\"error\", () => {\n failed.current.add(cue.src);\n onFailed?.([...failed.current]);\n });\n table.set(cue.id, element);\n }\n\n const local = frame - cue.fromFrame;\n const inside = local >= 0 && local < cue.durationInFrames;\n /**\n * Where in the file this frame sounds. A looping cue's window is\n * longer than its file, so the position wraps: seeking straight to\n * `local / fps` would land past the end and the browser would clamp\n * it, leaving the bed stuck on its final sample. The wrap needs the\n * file's real length, which only exists once metadata has loaded.\n */\n const span = element.duration;\n const elapsed = local / fps;\n const position =\n cue.loop && Number.isFinite(span) && span > 0 ? elapsed % span : elapsed;\n // Set every pass, not only at creation: an edit that turns looping on\n // does not change the cue's id, so the element it reuses would keep\n // the old behaviour.\n if (element.loop !== cue.loop) element.loop = cue.loop;\n element.volume = Math.max(0, Math.min(1, trackGainAtFrame(cue, track?.cues ?? [], frame) * masterGain));\n element.muted = muted || (soloCue !== null && soloCue !== cue.id);\n\n if (!inside || !audible) {\n if (!element.paused) element.pause();\n if (inside && !audible) {\n const target = cue.trimStartSeconds + position;\n if (Math.abs(element.currentTime - target) > 1 / fps) element.currentTime = target;\n }\n continue;\n }\n\n const target = cue.trimStartSeconds + position;\n // A rate change is a new playbackRate, not a reseek: the element keeps\n // playing and the drift check below catches it if it falls behind.\n if (element.playbackRate !== rate) element.playbackRate = rate;\n if (Math.abs(element.currentTime - target) > (2 / fps) * Math.max(1, rate)) element.currentTime = target;\n if (element.paused) {\n void element.play().then(\n () => onBlocked?.(false),\n (error: unknown) => onBlocked?.((error as Error)?.name === \"NotAllowedError\"),\n );\n }\n }\n };\n\n sync.current = run;\n run();\n\n return () => {\n for (const element of table.values()) element.removeEventListener(\"timeupdate\", onTimeUpdate);\n };\n }, [fps, frame, masterGain, muted, onBlocked, onFailed, playing, rate, scrubbing, soloCue, track]);\n\n // A hidden tab throttles the frame clock, so hold every cue until the tab is\n // visible again and then resync from the frame the timeline actually shows.\n useEffect(() => {\n if (typeof document === \"undefined\") return;\n const onVisibility = () => {\n if (document.hidden) {\n for (const element of elements.current.values()) element.pause();\n return;\n }\n sync.current();\n };\n document.addEventListener(\"visibilitychange\", onVisibility);\n return () => document.removeEventListener(\"visibilitychange\", onVisibility);\n }, []);\n};\n","\"use client\";\n\nimport {useEffect, useState} from \"react\";\nimport {OdoriRuntime, type CompiledTimeline, type VideoEntry} from \"./runtime\";\nimport {type AudioTrack} from \"./audio\";\nimport {type VideoLayout} from \"./layout\";\n\ndeclare global {\n interface Window {\n __ODORI_SET_FRAME__?: (frame: number) => void;\n __ODORI_TIMELINE__?: CompiledTimeline;\n __ODORI_AUDIO__?: AudioTrack;\n __ODORI_READY__?: boolean;\n }\n}\n\n/**\n * The surface the render worker drives. It exposes an explicit frame setter\n * and a readiness handshake instead of relying on timing heuristics.\n */\nexport const RenderSurface = ({\n entry,\n initialFrame = 0,\n input,\n prepared,\n assets,\n layout,\n}: {\n entry: VideoEntry;\n initialFrame?: number;\n input?: Record<string, unknown>;\n prepared?: unknown;\n assets?: Array<{reference: string; url: string}>;\n layout?: VideoLayout;\n}) => {\n const [frame, setFrame] = useState(initialFrame);\n\n useEffect(() => {\n window.__ODORI_SET_FRAME__ = setFrame;\n window.__ODORI_READY__ = true;\n return () => {\n delete window.__ODORI_SET_FRAME__;\n delete window.__ODORI_READY__;\n };\n }, []);\n\n return (\n <OdoriRuntime\n entry={entry}\n frame={frame}\n input={input}\n prepared={prepared}\n assets={assets}\n layout={layout}\n onTimeline={(timeline) => {\n window.__ODORI_TIMELINE__ = timeline;\n }}\n onAudio={(track) => {\n window.__ODORI_AUDIO__ = track;\n }}\n />\n );\n};\n","import {type Signal} from \"./synth\";\n\n/**\n * Signal to a 16 bit PCM WAV. Small, lossless, and readable by FFmpeg without\n * a decoder, which is all the mix needs from a generated cue.\n *\n * Encoding lives in the runtime rather than the CLI so preview and export\n * share it: the browser can hand the same bytes to an AudioContext that the\n * render worker writes to disk.\n */\nexport const encodeWav = (signal: Signal): Uint8Array => {\n const channels = signal.channels.length || 1;\n const frames = signal.channels[0]?.length ?? 0;\n const bytesPerSample = 2;\n const dataBytes = frames * channels * bytesPerSample;\n const buffer = new ArrayBuffer(44 + dataBytes);\n const view = new DataView(buffer);\n\n const ascii = (offset: number, text: string) => {\n for (let index = 0; index < text.length; index += 1) view.setUint8(offset + index, text.charCodeAt(index));\n };\n\n ascii(0, \"RIFF\");\n view.setUint32(4, 36 + dataBytes, true);\n ascii(8, \"WAVE\");\n ascii(12, \"fmt \");\n view.setUint32(16, 16, true);\n view.setUint16(20, 1, true); // PCM\n view.setUint16(22, channels, true);\n view.setUint32(24, signal.sampleRate, true);\n view.setUint32(28, signal.sampleRate * channels * bytesPerSample, true);\n view.setUint16(32, channels * bytesPerSample, true);\n view.setUint16(34, 8 * bytesPerSample, true);\n ascii(36, \"data\");\n view.setUint32(40, dataBytes, true);\n\n let offset = 44;\n for (let frame = 0; frame < frames; frame += 1) {\n for (let channel = 0; channel < channels; channel += 1) {\n const sample = signal.channels[channel]?.[frame] ?? 0;\n // Clamp before quantizing, so a hot score distorts predictably instead\n // of wrapping into noise.\n const clamped = Math.max(-1, Math.min(1, sample));\n view.setInt16(offset, Math.round(clamped * 32767), true);\n offset += bytesPerSample;\n }\n }\n\n return new Uint8Array(buffer);\n};\n","import {Easing, interpolate} from \"./easing\";\n\nexport type CursorStop = {\n /** Frame this stop is reached, from the start of the enclosing scene. */\n frame: number;\n /** Canvas coordinates, in the composition's own pixels. */\n x: number;\n y: number;\n /**\n * A click landing on this stop. The press is drawn at the stop's frame and\n * decays over a few frames, so the pointer visibly does the thing the UI is\n * about to react to.\n */\n click?: boolean;\n /** Hold here until this many frames have passed before moving on. */\n hold?: number;\n};\n\nexport type CursorState = {\n x: number;\n y: number;\n /** 0 before the path starts and after it ends, 1 while it is on screen. */\n visible: number;\n /** 1 at the instant of a click, decaying to 0. Drives the press ring. */\n pressed: number;\n /** True while a click is within its press window, for a UI to react to. */\n clicking: boolean;\n};\n\n/** Frames a press ring takes to expand and fade. */\nconst PRESS_FRAMES = 9;\n\n/**\n * Where an authored pointer is at this frame.\n *\n * Recording a real cursor would make a video that cannot be re-rendered: the\n * path would live in a file, not in the composition, and a change of copy or\n * canvas would leave it pointing at nothing. An authored path is source — it\n * diffs, it survives a reflow, and it produces the same pixels every run.\n *\n * Movement eases between stops rather than running linearly, because a pointer\n * that travels at constant speed reads as a machine. A `hold` keeps the\n * pointer still without needing a duplicate stop at the same coordinates.\n */\nexport const cursorAt = (stops: CursorStop[], frame: number): CursorState => {\n if (stops.length === 0) return {x: 0, y: 0, visible: 0, pressed: 0, clicking: false};\n\n // A hold extends the stop it is on, which shifts everything after it.\n const timed: CursorStop[] = [];\n let shift = 0;\n for (const stop of stops) {\n const start = stop.frame + shift;\n timed.push({...stop, frame: start});\n if (stop.hold) {\n timed.push({...stop, frame: start + stop.hold, click: false});\n shift += stop.hold;\n }\n }\n\n const first = timed[0];\n const last = timed[timed.length - 1];\n if (frame <= first.frame) return {x: first.x, y: first.y, visible: 0, pressed: 0, clicking: false};\n\n const frames = timed.map((stop) => stop.frame);\n const x = interpolate(frame, frames, timed.map((stop) => stop.x), {easing: Easing.standard});\n const y = interpolate(frame, frames, timed.map((stop) => stop.y), {easing: Easing.standard});\n\n // The most recent click at or before this frame owns the press ring.\n let pressed = 0;\n for (const stop of timed) {\n if (!stop.click || stop.frame > frame) continue;\n const age = frame - stop.frame;\n if (age <= PRESS_FRAMES) pressed = Math.max(pressed, 1 - age / PRESS_FRAMES);\n }\n\n return {\n x,\n y,\n // Fade in as it arrives and out after the last stop, so a pointer never\n // pops onto a frame it was not part of.\n visible: interpolate(\n frame,\n [first.frame, first.frame + 6, last.frame + 12, last.frame + 20],\n [0, 1, 1, 0],\n {easing: Easing.standard},\n ),\n pressed,\n clicking: pressed > 0,\n };\n};\n\n/** The last frame an authored path is still on screen, for sizing a scene. */\nexport const cursorDuration = (stops: CursorStop[]): number => {\n const hold = stops.reduce((total, stop) => total + (stop.hold ?? 0), 0);\n return (stops[stops.length - 1]?.frame ?? 0) + hold + 20;\n};\n","/**\n * Randomness that survives a re-render.\n *\n * A frame is a pure function of its number. `Math.random()` breaks that in the\n * quietest possible way: the preview looks fine, every export looks fine, and\n * the two are different — and so are two chunks of the same export, because a\n * render is parallel and each worker rolls its own numbers. Fifty particles\n * that jump between chunk boundaries is the usual symptom, found late.\n *\n * So a composition asks for a number by name instead. The same seed always\n * gives the same value, on every machine and in every worker, and a seed that\n * includes the frame gives motion that is random-looking and reproducible.\n */\n\n/**\n * A 32-bit hash of a string, so a seed can be written as a readable name\n * rather than a magic integer. FNV-1a: small, well distributed for short keys,\n * and stable across engines, which matters because two workers must agree.\n */\nconst hashSeed = (value: string): number => {\n let hash = 0x811c9dc5;\n for (let index = 0; index < value.length; index += 1) {\n hash ^= value.charCodeAt(index);\n hash = Math.imul(hash, 0x01000193);\n }\n return hash >>> 0;\n};\n\nconst toSeed = (seed: number | string): number =>\n typeof seed === \"number\" ? Math.floor(seed) >>> 0 : hashSeed(seed);\n\n/**\n * A number in `[0, 1)` for a seed. The same seed always returns the same\n * number, which is the whole point.\n *\n * ```tsx\n * const drift = random(`particle-${index}`) * 40;\n * const jitter = random([frame, index]) - 0.5;\n * ```\n *\n * An array seed is joined, which is the convenient way to say \"this thing, on\n * this frame\" without building the string by hand.\n */\nexport const random = (seed: number | string | Array<number | string>): number => {\n const key = Array.isArray(seed) ? seed.join(\":\") : seed;\n // Mulberry32, the same generator the audio synthesis uses, so a project has\n // one notion of \"seeded\" rather than two that disagree.\n let state = (toSeed(key) + 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/** A number in `[min, max)`, for a seed. */\nexport const randomBetween = (seed: number | string | Array<number | string>, min: number, max: number): number =>\n min + random(seed) * (max - min);\n\n/** One item from a list, for a seed. Empty lists return undefined. */\nexport const randomPick = <T,>(seed: number | string | Array<number | string>, items: readonly T[]): T | undefined =>\n items.length === 0 ? undefined : items[Math.floor(random(seed) * items.length)];\n\n/**\n * A shuffled copy, for a seed. Fisher-Yates driven by the same generator, so\n * the order is arbitrary but fixed — a list that reshuffles every frame is an\n * animation nobody asked for.\n */\nexport const randomOrder = <T,>(seed: number | string | Array<number | string>, items: readonly T[]): T[] => {\n const key = Array.isArray(seed) ? seed.join(\":\") : String(seed);\n const out = [...items];\n for (let index = out.length - 1; index > 0; index -= 1) {\n const swap = Math.floor(random(`${key}:${index}`) * (index + 1));\n [out[index], out[swap]] = [out[swap], out[index]];\n }\n return out;\n};\n","\"use client\";\n\nimport {useEffect, useLayoutEffect, useRef, type RefObject} from \"react\";\nimport {useFrame, useReadiness, useVideo} from \"./context\";\n\nexport type CanvasDraw = (context: CanvasRenderingContext2D, state: {frame: number; width: number; height: number}) => void;\n\n/** `useLayoutEffect` warns during server rendering, where there is no canvas. */\nconst useIsomorphicLayoutEffect = typeof window === \"undefined\" ? useEffect : useLayoutEffect;\n\n/**\n * Draw to a canvas from the frame clock.\n *\n * The contract a video runs on is that frame N produces the same pixels every\n * time. A canvas is where that is easiest to lose: the obvious way to animate\n * one is `requestAnimationFrame`, which is wall time, and wall time means the\n * export samples wherever the loop happened to be. Two workers rendering\n * neighbouring chunks then disagree, and the seam shows.\n *\n * So the draw is a pure function of the frame, called synchronously before the\n * browser paints, and the frame is held until it has run. The capture waits on\n * the same readiness handshake an image decode uses, which is what makes the\n * screenshot see finished pixels rather than an empty buffer.\n */\nexport const useCanvas = (draw: CanvasDraw, dependencies: readonly unknown[] = []): RefObject<HTMLCanvasElement | null> => {\n const canvas = useRef<HTMLCanvasElement | null>(null);\n const frame = useFrame();\n const {width, height} = useVideo();\n const readiness = useReadiness();\n // The draw is called with the current closure but must not re-run the effect\n // when an inline function identity changes, or every render would repaint.\n const latest = useRef(draw);\n latest.current = draw;\n\n useIsomorphicLayoutEffect(() => {\n const element = canvas.current;\n if (!element) return;\n\n // Held across the draw, so a frame is never captured mid-paint.\n const release = readiness.hold();\n try {\n const context = element.getContext(\"2d\", {alpha: true});\n if (!context) return;\n\n // Reset rather than accumulate: a frame is drawn from nothing, so\n // scrubbing backwards produces the same image as playing forwards.\n context.setTransform(1, 0, 0, 1, 0, 0);\n context.clearRect(0, 0, element.width, element.height);\n latest.current(context, {frame, width: element.width, height: element.height});\n } finally {\n release();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [frame, width, height, ...dependencies]);\n\n return canvas;\n};\n\n/**\n * Rasterize HTML into a canvas, deterministically.\n *\n * The browser will draw an SVG containing a `foreignObject` onto a canvas, and\n * a `foreignObject` can hold ordinary markup. That is the whole trick, and the\n * reason it needs care: the image decode is asynchronous, so the frame has to\n * be held until it lands, and the markup has to carry its own styles because\n * nothing outside the SVG reaches into it.\n *\n * Fonts are the sharp edge. A face that is not loaded when this runs will fall\n * back, and the fallback is what gets baked into the pixels — which is why the\n * caller waits on `document.fonts.ready` before drawing.\n */\nexport const drawHtml = async (\n context: CanvasRenderingContext2D,\n html: string,\n options: {width: number; height: number; style?: string},\n): Promise<void> => {\n const {width, height, style = \"\"} = options;\n if (typeof document !== \"undefined\" && document.fonts?.ready) await document.fonts.ready;\n\n const svg = [\n `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${width}\" height=\"${height}\">`,\n `<foreignObject width=\"100%\" height=\"100%\">`,\n `<div xmlns=\"http://www.w3.org/1999/xhtml\" style=\"width:${width}px;height:${height}px;${style}\">`,\n html,\n `</div></foreignObject></svg>`,\n ].join(\"\");\n\n // A data URL rather than a blob URL: a blob URL has to be revoked, and a\n // leak here is a leak once per frame for the length of the video.\n const encoded = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;\n\n await new Promise<void>((done, fail) => {\n const image = new Image();\n image.onload = () => {\n context.drawImage(image, 0, 0, width, height);\n done();\n };\n image.onerror = () =>\n fail(\n new Error(\n \"The HTML could not be rasterized. Every element inside must carry inline styles, and images must be data URLs: an SVG foreignObject cannot reach outside itself.\",\n ),\n );\n image.src = encoded;\n });\n};\n","import {random} from \"./random\";\n\nexport type PlaceholderOptions = {\n width?: number;\n height?: number;\n /** Drawn across the middle, so a fixture says what it is standing in for. */\n label?: string;\n /** Two colours the gradient runs between. */\n from?: string;\n to?: string;\n /** Seed for the scatter, so two placeholders differ without differing runs. */\n seed?: string;\n};\n\n/**\n * A picture that ships as code.\n *\n * A component that shows media needs media to show, and a fixture that ships a\n * JPEG cannot be reviewed in a diff, cannot be recoloured by a brand, and adds\n * a binary to a repository forever. Generating an SVG instead keeps the\n * registry's rule intact — install copies source — and makes the picture do\n * something a file cannot: describe itself.\n *\n * It is deliberately obviously a placeholder. A fixture that looks like real\n * photography invites someone to ship it.\n */\nexport const placeholderSvg = ({\n width = 1600,\n height = 900,\n label,\n from = \"#1a1a1a\",\n to = \"#0a0a0a\",\n seed = \"placeholder\",\n}: PlaceholderOptions = {}): string => {\n const shapes = Array.from({length: 14}, (_, index) => {\n const x = random([seed, \"x\", index]) * width;\n const y = random([seed, \"y\", index]) * height;\n const radius = (random([seed, \"r\", index]) * 0.16 + 0.03) * Math.min(width, height);\n const opacity = (random([seed, \"o\", index]) * 0.06 + 0.02).toFixed(3);\n return `<circle cx=\"${x.toFixed(1)}\" cy=\"${y.toFixed(1)}\" r=\"${radius.toFixed(1)}\" fill=\"#ffffff\" opacity=\"${opacity}\"/>`;\n }).join(\"\");\n\n const caption = label\n ? `<text x=\"50%\" y=\"50%\" fill=\"#ffffff\" fill-opacity=\"0.42\" font-family=\"ui-monospace, monospace\" font-size=\"${Math.round(\n Math.min(width, height) * 0.06,\n )}\" text-anchor=\"middle\" dominant-baseline=\"middle\">${label.replace(/[<>&]/g, \"\")}</text>`\n : \"\";\n\n return [\n `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${width}\" height=\"${height}\" viewBox=\"0 0 ${width} ${height}\">`,\n `<defs><linearGradient id=\"g\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\">`,\n `<stop offset=\"0\" stop-color=\"${from}\"/><stop offset=\"1\" stop-color=\"${to}\"/>`,\n `</linearGradient></defs>`,\n `<rect width=\"${width}\" height=\"${height}\" fill=\"url(#g)\"/>`,\n shapes,\n `<rect x=\"1\" y=\"1\" width=\"${width - 2}\" height=\"${height - 2}\" fill=\"none\" stroke=\"#ffffff\" stroke-opacity=\"0.08\"/>`,\n caption,\n `</svg>`,\n ].join(\"\");\n};\n\n/**\n * The same picture as a data URL, which is what an `<img>` or a canvas draw\n * wants. Inline rather than fetched: a fixture that needs the network is a\n * fixture that fails on a plane, in CI, and in a sandboxed render.\n */\nexport const placeholderImage = (options: PlaceholderOptions = {}): string =>\n `data:image/svg+xml;charset=utf-8,${encodeURIComponent(placeholderSvg(options))}`;\n\n/**\n * A frame of a placeholder \"clip\": the same picture with a moving marker and a\n * timecode, so a component that plays media has something to play that visibly\n * advances and is still a pure function of the frame.\n */\nexport const placeholderFrame = (frame: number, options: PlaceholderOptions & {fps?: number} = {}): string => {\n const {width = 1600, height = 900, fps = 30, ...rest} = options;\n const seconds = frame / fps;\n const timecode = `${String(Math.floor(seconds / 60)).padStart(2, \"0\")}:${String(Math.floor(seconds % 60)).padStart(2, \"0\")}:${String(\n frame % fps,\n ).padStart(2, \"0\")}`;\n\n const base = placeholderSvg({...rest, width, height, label: undefined});\n const progress = (frame % (fps * 4)) / (fps * 4);\n const marker = [\n `<rect x=\"0\" y=\"${height - 12}\" width=\"${(width * progress).toFixed(1)}\" height=\"12\" fill=\"#ffffff\" fill-opacity=\"0.5\"/>`,\n `<text x=\"${width / 2}\" y=\"${height / 2}\" fill=\"#ffffff\" fill-opacity=\"0.5\" font-family=\"ui-monospace, monospace\" font-size=\"${Math.round(\n Math.min(width, height) * 0.08,\n )}\" text-anchor=\"middle\" dominant-baseline=\"middle\">${timecode}</text>`,\n ].join(\"\");\n\n return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(base.replace(\"</svg>\", `${marker}</svg>`))}`;\n};\n","import {type Duration} from \"./time\";\nimport {type VideoLayout} from \"./layout\";\nimport {type ParsableSchema} from \"./schema\";\n\nexport type VideoMetadata<Input = Record<string, unknown>> = {\n readonly kind: \"odori-video-metadata\";\n id: string;\n title: string;\n description?: string;\n duration?: Duration;\n layout?: VideoLayout;\n schema?: ParsableSchema<Input>;\n defaultProps?: Partial<Input>;\n tags?: string[];\n thumbnailFrame?: number;\n};\n\nexport type VideoMetadataInput<Input = Record<string, unknown>> = Omit<VideoMetadata<Input>, \"kind\" | \"id\"> & {\n /**\n * Defaults to the entry's path under `videos/`, so the directory names a\n * video the way a route names a page. Set it to keep an id stable across a\n * directory move.\n */\n id?: string;\n};\n\n/** A segment of an id: alphanumeric with dashes, the way a directory is named. */\nconst SEGMENT = /^[a-z0-9][a-z0-9-]*$/i;\n\nexport const isValidVideoId = (id: string): boolean =>\n id.length > 0 && id.split(\"/\").every((segment) => SEGMENT.test(segment));\n\n/**\n * An id left unset is resolved from the filesystem by discovery. The empty\n * string is the unresolved state: no entry reaches a manifest, a render, or\n * Studio without an id stamped in.\n */\nexport const resolveVideoId = (id: string | undefined, pathId: string): string => id || pathId;\n\nexport const defineVideoMetadata = <Input = Record<string, unknown>>(\n metadata: VideoMetadataInput<Input>,\n): VideoMetadata<Input> => {\n if (metadata.id !== undefined && !isValidVideoId(metadata.id)) {\n throw new Error(`Video id must be alphanumeric path segments with dashes: ${metadata.id}`);\n }\n return {kind: \"odori-video-metadata\", ...metadata, id: metadata.id ?? \"\"};\n};\n\nexport type PrepareContext<Input> = {\n input: Input;\n assets: {resolve(reference: string): Promise<string>};\n cache: {getOrSet<Value>(key: string, factory: () => Promise<Value>): Promise<Value>};\n signal?: AbortSignal;\n};\n\nexport type PrepareFunction<Input = Record<string, unknown>, Prepared = unknown> = {\n readonly kind: \"odori-prepare\";\n version: string;\n run(context: PrepareContext<Input>): Promise<Prepared>;\n};\n\nexport const definePrepare = <Input = Record<string, unknown>, Prepared = unknown>(\n run: (context: PrepareContext<Input>) => Promise<Prepared>,\n options: {version?: string} = {},\n): PrepareFunction<Input, Prepared> => ({\n kind: \"odori-prepare\",\n version: options.version ?? \"1\",\n run,\n});\n","/**\n * A tiny serializable input contract.\n *\n * Odori needs three things from a schema: validation with defaults, a JSON\n * description Studio can turn into controls, and zero runtime dependencies.\n * Any zod-compatible object with `parse()` is also accepted.\n */\nexport type FieldDescriptor =\n | {type: \"text\"; defaultValue: string; maxLength?: number; multiline?: boolean}\n | {type: \"number\"; defaultValue: number; min?: number; max?: number; step?: number}\n | {type: \"boolean\"; defaultValue: boolean}\n | {type: \"select\"; defaultValue: string; options: string[]}\n | {type: \"color\"; defaultValue: string}\n | {type: \"json\"; defaultValue: unknown};\n\nexport type InputSchema<Value = Record<string, unknown>> = {\n readonly kind: \"odori-schema\";\n readonly fields: Record<string, FieldDescriptor>;\n parse(input: unknown): Value;\n safeParse(input: unknown): {success: true; data: Value} | {success: false; issues: string[]};\n defaults(): Value;\n describe(): Record<string, FieldDescriptor>;\n};\n\nexport type ParsableSchema<Value = unknown> = InputSchema<Value> | {parse(input: unknown): Value};\n\nconst validateField = (name: string, field: FieldDescriptor, value: unknown, issues: string[]): unknown => {\n if (value === undefined) return field.defaultValue;\n switch (field.type) {\n case \"text\":\n case \"color\": {\n if (typeof value !== \"string\") {\n issues.push(`${name} must be a string`);\n return field.defaultValue;\n }\n if (field.type === \"text\" && field.maxLength !== undefined && value.length > field.maxLength) {\n issues.push(`${name} exceeds ${field.maxLength} characters`);\n }\n return value;\n }\n case \"number\": {\n if (typeof value !== \"number\" || !Number.isFinite(value)) {\n issues.push(`${name} must be a finite number`);\n return field.defaultValue;\n }\n if (field.min !== undefined && value < field.min) issues.push(`${name} is below ${field.min}`);\n if (field.max !== undefined && value > field.max) issues.push(`${name} is above ${field.max}`);\n return value;\n }\n case \"boolean\": {\n if (typeof value !== \"boolean\") {\n issues.push(`${name} must be a boolean`);\n return field.defaultValue;\n }\n return value;\n }\n case \"select\": {\n if (typeof value !== \"string\" || !field.options.includes(value)) {\n issues.push(`${name} must be one of ${field.options.join(\", \")}`);\n return field.defaultValue;\n }\n return value;\n }\n default:\n return value;\n }\n};\n\nexport const defineInputSchema = <Fields extends Record<string, FieldDescriptor>>(\n fields: Fields,\n): InputSchema<Record<string, unknown>> => {\n const defaults = () =>\n Object.fromEntries(Object.entries(fields).map(([name, field]) => [name, field.defaultValue]));\n\n const safeParse = (input: unknown) => {\n if (input !== undefined && input !== null && typeof input !== \"object\") {\n return {success: false as const, issues: [\"input must be an object\"]};\n }\n const source = (input ?? {}) as Record<string, unknown>;\n const issues: string[] = [];\n const data: Record<string, unknown> = {};\n for (const [name, field] of Object.entries(fields)) {\n data[name] = validateField(name, field, source[name], issues);\n }\n for (const key of Object.keys(source)) {\n if (!(key in fields)) data[key] = source[key];\n }\n return issues.length > 0\n ? {success: false as const, issues}\n : {success: true as const, data};\n };\n\n return {\n kind: \"odori-schema\",\n fields,\n defaults,\n describe: () => fields,\n safeParse,\n parse(input) {\n const result = safeParse(input);\n if (!result.success) throw new Error(`Invalid video input: ${result.issues.join(\"; \")}`);\n return result.data;\n },\n };\n};\n\nexport const isOdoriSchema = (schema: unknown): schema is InputSchema =>\n typeof schema === \"object\" && schema !== null && (schema as {kind?: string}).kind === \"odori-schema\";\n\nexport const parseWithSchema = <Value>(schema: ParsableSchema<Value> | undefined, input: unknown): Value =>\n schema ? schema.parse(input) : ((input ?? {}) as Value);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,IAAM,QAAQ,EAAC,WAAW,mBAAmB,QAAQ,mBAAmB,GAAG,mBAAkB;AAC7F,IAAM,YAAY,EAAC,WAAW,mBAAmB,GAAG,mBAAkB;AAM/D,IAAM,oBAAoB,CAAC,eAA+B;AAC/D,QAAM,YAAY,OAAO,MAAM,SAAS;AACxC,QAAM,QAAS,IAAI,KAAK,KAAK,MAAM,YAAa;AAChD,QAAM,QAAQ,KAAK,IAAI,KAAK,KAAK,IAAI,MAAM;AAC3C,QAAM,MAAM,KAAK,IAAI,KAAK;AAC1B,QAAM,SAAS,IAAI,KAAK,KAAK,SAAS,IAAI;AAC1C,QAAM,KAAK,YAAY,KAAK,YAAY,KAAK,MAAM;AACnD,SAAO;AAAA,IACL,IAAK,aAAa,YAAY,KAAK,YAAY,KAAK,MAAM,UAAW;AAAA,IACrE,IAAK,KAAK,aAAa,YAAY,KAAK,YAAY,KAAK,OAAQ;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I;AAAA,EACnC;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA,UAAU,MAAM;AAAA,IAChB;AAAA,IACA,MAAM,OAAO;AACX,YAAM,SAAS,UAAU,KAAK;AAC9B,UAAI,CAAC,OAAO,QAAS,OAAM,IAAI,MAAM,wBAAwB,OAAO,OAAO,KAAK,IAAI,CAAC,EAAE;AACvF,aAAO,OAAO;AAAA,IAChB;AAAA,EACF;AACF;AAEO,IAAM,gBAAgB,CAAC,WAC5B,OAAO,WAAW,YAAY,WAAW,QAAS,OAA2B,SAAS;AAEjF,IAAM,kBAAkB,CAAQ,QAA2C,UAChF,SAAS,OAAO,MAAM,KAAK,IAAM,SAAS,CAAC;","names":["useCallback","useState","loop","useEffect","useRef","useRef","useEffect","target","loop","useState","useCallback","useEffect","useState","jsx","useState","useEffect","offset","useEffect","useRef","useEffect","useRef","seconds"]}
@@ -0,0 +1,398 @@
1
+ import { D as Duration, B as Brand } from './brand-D71KbhAe.js';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
+ import { ReactNode, ComponentPropsWithoutRef, CSSProperties } from 'react';
4
+
5
+ type AudioCue = {
6
+ /** Stable identity, derived from the source and its placement. */
7
+ id: string;
8
+ src: string;
9
+ fromFrame: number;
10
+ durationInFrames: number;
11
+ /** Linear gain. 1 is unchanged. */
12
+ gain: number;
13
+ /**
14
+ * An authored curve, sampled from a `gain` function at compile time. A
15
+ * function cannot enter a manifest or an FFmpeg filter; its samples can.
16
+ */
17
+ gainPoints?: EnvelopePoint[];
18
+ fadeInFrames: number;
19
+ fadeOutFrames: number;
20
+ /** Seconds skipped at the head of the source file. */
21
+ trimStartSeconds: number;
22
+ loop: boolean;
23
+ /** Ducked cues are attenuated while a louder cue overlaps them. */
24
+ duckUnder: boolean;
25
+ };
26
+ type AudioTrack = {
27
+ cues: AudioCue[];
28
+ durationInFrames: number;
29
+ };
30
+ type AudioProps = {
31
+ src: string;
32
+ /** Offset from the enclosing scene, or from the video when used at the top level. */
33
+ from?: Duration;
34
+ duration?: Duration;
35
+ /**
36
+ * A number, or a curve. The function is evaluated once per frame of the
37
+ * cue's window when the timeline compiles, so preview and export read the
38
+ * same points rather than running your code twice.
39
+ */
40
+ gain?: number | ((frame: number) => number);
41
+ fadeIn?: Duration;
42
+ fadeOut?: Duration;
43
+ trimStart?: Duration;
44
+ loop?: boolean;
45
+ duckUnder?: boolean;
46
+ };
47
+ declare const cueId: (src: string, fromFrame: number) => string;
48
+ /**
49
+ * A source is either a URL the dev server and the render worker both serve, or
50
+ * a reference declared in `odori.config.ts`. Anything that is not obviously a
51
+ * path is treated as a reference, so `<Audio src="score" />` and
52
+ * `useAssets().resolve("score")` name the same file.
53
+ */
54
+ declare const isAssetReference: (src: string) => boolean;
55
+ /** Deterministic ordering so a manifest hash does not depend on mount order. */
56
+ declare const sortCues: (cues: AudioCue[]) => AudioCue[];
57
+ declare const trackDuration: (cues: AudioCue[]) => number;
58
+ /**
59
+ * Linear gain at one frame, including fades. The renderer applies the same
60
+ * curve through FFmpeg, so preview and export agree on shape.
61
+ */
62
+ declare const gainAtFrame: (cue: AudioCue, frame: number) => number;
63
+ /**
64
+ * Sample a gain function across a window, then drop the points a straight line
65
+ * already describes. One point per frame would compile into a filter
66
+ * expression hundreds of branches deep for a curve the ear cannot tell from a
67
+ * dozen segments.
68
+ */
69
+ declare const sampleGainCurve: (curve: (frame: number) => number, fromFrame: number, durationInFrames: number, tolerance?: number) => EnvelopePoint[];
70
+ /** How far a ducked cue drops while a non-ducked cue is sounding. */
71
+ declare const DUCK_GAIN = 0.35;
72
+ /** Ramp into and out of a duck, so the drop is heard as mixing, not as a cut. */
73
+ declare const DUCK_RAMP_FRAMES = 6;
74
+ type EnvelopePoint = {
75
+ frame: number;
76
+ value: number;
77
+ };
78
+ /**
79
+ * The duck envelope for one cue against the rest of the track.
80
+ *
81
+ * A duck lasts only while a non-ducked cue overlaps, rather than for the whole
82
+ * file: a one second confirmation should not hold a music bed down for the
83
+ * length of the video. Preview evaluates these points directly and the encoder
84
+ * compiles them into a volume expression, so both paths hear one envelope.
85
+ */
86
+ declare const duckEnvelope: (cue: AudioCue, cues: AudioCue[]) => EnvelopePoint[];
87
+ /** Linear interpolation between envelope points. */
88
+ declare const envelopeAtFrame: (points: EnvelopePoint[], frame: number) => number;
89
+ /**
90
+ * Everything that shapes a cue's level at one frame: its own gain and fades,
91
+ * and the duck the rest of the track imposes on it.
92
+ */
93
+ declare const trackGainAtFrame: (cue: AudioCue, cues: AudioCue[], frame: number) => number;
94
+
95
+ type VideoFormat = {
96
+ width: number;
97
+ height: number;
98
+ fps: number;
99
+ };
100
+ type SafeArea$1 = {
101
+ x: number;
102
+ y: number;
103
+ };
104
+ type MotionPolicy = {
105
+ enter: [number, number, number, number];
106
+ staggerFrames: number;
107
+ reducedMotion?: boolean;
108
+ };
109
+ type AudioPolicy = {
110
+ palette: string;
111
+ targetLufs: number;
112
+ };
113
+ type VideoLayout = {
114
+ readonly kind: "odori-layout";
115
+ format: VideoFormat;
116
+ brand: Brand;
117
+ safeArea: SafeArea$1;
118
+ motion: MotionPolicy;
119
+ audio: AudioPolicy;
120
+ transition: {
121
+ crossfadeFrames: number;
122
+ };
123
+ };
124
+ type VideoLayoutInput = {
125
+ extends?: VideoLayout;
126
+ format?: Partial<VideoFormat>;
127
+ brand?: Brand;
128
+ safeArea?: SafeArea$1;
129
+ motion?: Partial<MotionPolicy>;
130
+ audio?: Partial<AudioPolicy>;
131
+ transition?: {
132
+ crossfadeFrames: number;
133
+ };
134
+ };
135
+ declare const defaultLayout: VideoLayout;
136
+ /**
137
+ * Merge rules from the docs: scalar format values replace, safe areas replace
138
+ * as a unit, motion and audio policies merge onto the inherited policy, and
139
+ * brand replaces because a brand is itself a resolved policy object.
140
+ */
141
+ declare const defineVideoLayout: (input?: VideoLayoutInput) => VideoLayout;
142
+
143
+ type CompiledScene = {
144
+ id: string;
145
+ name?: string;
146
+ index: number;
147
+ start: number;
148
+ durationInFrames: number;
149
+ /** Frames this scene starts before the previous one ends. Zero is a cut. */
150
+ overlap: number;
151
+ };
152
+ type CompiledTimeline = {
153
+ scenes: CompiledScene[];
154
+ durationInFrames: number;
155
+ };
156
+ declare const Fill: ({ style, ...props }: ComponentPropsWithoutRef<"div">) => react_jsx_runtime.JSX.Element;
157
+ /** Content inset by the inherited layout safe area. */
158
+ declare const SafeArea: ({ children, style }: {
159
+ children: ReactNode;
160
+ style?: CSSProperties;
161
+ }) => react_jsx_runtime.JSX.Element;
162
+ type SceneProps = {
163
+ children: ReactNode;
164
+ duration: Duration;
165
+ id?: string;
166
+ name?: string;
167
+ /**
168
+ * Start this many frames before the previous scene ends, so both are on
169
+ * screen together and a transition can span the cut. The video gets shorter
170
+ * by the same amount: an overlap is a join, not an extra beat.
171
+ */
172
+ overlap?: Duration;
173
+ /** Injected by <Video>. Authors never pass these. */
174
+ __start?: number;
175
+ __index?: number;
176
+ __durationInFrames?: number;
177
+ __enterOverlap?: number;
178
+ __exitOverlap?: number;
179
+ __videoFrame?: number;
180
+ };
181
+ type SceneTransition = {
182
+ /** 0 to 1 while this scene is arriving over its predecessor. */
183
+ entering: number;
184
+ /** 0 to 1 while its successor is arriving over it. */
185
+ leaving: number;
186
+ /** Frames of overlap at each end, for a component that needs the raw counts. */
187
+ enterFrames: number;
188
+ exitFrames: number;
189
+ };
190
+ /**
191
+ * How far this scene is through the joins at its edges.
192
+ *
193
+ * A transition that spans a cut needs to know two things the scene itself
194
+ * cannot see: that it is arriving over something, and that something is
195
+ * arriving over it. Both are numbers rather than a reference to the other
196
+ * scene — a component that could reach into its neighbour's tree would couple
197
+ * two scenes together, and the point of the timeline is that they compose.
198
+ *
199
+ * Outside an overlap this reports a scene fully present and nothing leaving,
200
+ * so a component written against it also works on an ordinary cut.
201
+ */
202
+ declare const useSceneTransition: () => SceneTransition;
203
+ /**
204
+ * A timeline segment with a local frame clock starting at zero.
205
+ */
206
+ declare const Scene: {
207
+ ({ children, id, name, __start, __index, __durationInFrames, __enterOverlap, __exitOverlap, __videoFrame, }: SceneProps): react_jsx_runtime.JSX.Element | null;
208
+ __odoriScene: true;
209
+ };
210
+ /** An explicit offset window inside a scene, for staggered layers. */
211
+ declare const Stagger: ({ children, from, duration }: {
212
+ children: ReactNode;
213
+ from?: Duration;
214
+ duration?: Duration;
215
+ }) => react_jsx_runtime.JSX.Element | null;
216
+ /**
217
+ * Repeat children on a local clock.
218
+ *
219
+ * The frame inside is the frame within one pass, so a component written for a
220
+ * two second window needs no idea it is being repeated. Everything stays a
221
+ * pure function of the frame — the tenth repetition is not the first one
222
+ * mutated ten times, it is the same computation with the same input, which is
223
+ * why scrubbing backwards into a loop lands exactly where playing forwards
224
+ * did.
225
+ */
226
+ declare const Loop: ({ children, duration, times, }: {
227
+ children: ReactNode;
228
+ /** Length of one pass. */
229
+ duration: Duration;
230
+ /** How many passes before it stops. Unlimited by default. */
231
+ times?: number;
232
+ }) => react_jsx_runtime.JSX.Element | null;
233
+ /**
234
+ * Hold children at one frame.
235
+ *
236
+ * Useful for the still half of a comparison, for a poster frame, and for
237
+ * pausing an animation on the moment that makes the point. It is the frame
238
+ * clock that stops, not the render: children still mount and lay out
239
+ * normally, they simply always see the same number.
240
+ */
241
+ declare const Freeze: ({ children, at }: {
242
+ children: ReactNode;
243
+ at?: Duration;
244
+ }) => react_jsx_runtime.JSX.Element;
245
+ /**
246
+ * A sound placed on the timeline. Audio is declarative like a scene: it
247
+ * registers a cue rather than starting playback, so the player, a still, and
248
+ * the encoder all read the same track.
249
+ */
250
+ declare const Audio: {
251
+ ({ src, from, duration, gain, fadeIn, fadeOut, trimStart, loop, duckUnder, }: AudioProps): null;
252
+ __odoriAudio: true;
253
+ };
254
+ /**
255
+ * Provides timeline structure. `<Video>` adds no duration of its own: scene
256
+ * children are laid out in order, other children render for the whole video.
257
+ */
258
+ declare const Video: ({ children, style }: {
259
+ children: ReactNode;
260
+ style?: CSSProperties;
261
+ }) => react_jsx_runtime.JSX.Element;
262
+ type VideoEntry = {
263
+ component: (props: any) => ReactNode;
264
+ metadata: {
265
+ id: string;
266
+ title: string;
267
+ description?: string;
268
+ duration?: Duration;
269
+ layout?: VideoLayout;
270
+ schema?: {
271
+ parse(input: unknown): unknown;
272
+ };
273
+ defaultProps?: Record<string, unknown>;
274
+ tags?: string[];
275
+ thumbnailFrame?: number;
276
+ };
277
+ };
278
+ type OdoriRuntimeProps = {
279
+ entry: VideoEntry;
280
+ frame: number;
281
+ input?: Record<string, unknown>;
282
+ prepared?: unknown;
283
+ assets?: Array<{
284
+ reference: string;
285
+ url: string;
286
+ }>;
287
+ layout?: VideoLayout;
288
+ onTimeline?: (timeline: CompiledTimeline) => void;
289
+ onAudio?: (track: AudioTrack) => void;
290
+ };
291
+ declare const resolveEntryLayout: (entry: VideoEntry, override?: VideoLayout) => VideoLayout;
292
+ declare const entryDurationInFrames: (entry: VideoEntry, layout: VideoLayout) => number;
293
+ declare const OdoriRuntime: ({ entry, frame, input, prepared, assets, layout, onTimeline, onAudio }: OdoriRuntimeProps) => react_jsx_runtime.JSX.Element;
294
+
295
+ type ManifestAsset = {
296
+ url: string;
297
+ reference?: string;
298
+ integrity: string;
299
+ };
300
+ type ManifestAudioCue = {
301
+ id: string;
302
+ src: string;
303
+ fromFrame: number;
304
+ durationInFrames: number;
305
+ gain: number;
306
+ /** An authored gain curve, already sampled to points. */
307
+ gainPoints?: Array<{
308
+ frame: number;
309
+ value: number;
310
+ }>;
311
+ fadeInFrames: number;
312
+ fadeOutFrames: number;
313
+ trimStartSeconds: number;
314
+ loop: boolean;
315
+ duckUnder: boolean;
316
+ integrity: string;
317
+ };
318
+ type ManifestFont = {
319
+ family: string;
320
+ url: string;
321
+ integrity: string;
322
+ };
323
+ /**
324
+ * The programs that drew and encoded a render.
325
+ *
326
+ * A manifest freezes what a video depends on so an approved cut cannot drift.
327
+ * The toolchain is part of that: the same source through a different browser
328
+ * is a different file, in ways too small to see in review and large enough to
329
+ * matter in a diff. Recording it means two artefacts that disagree can be
330
+ * explained rather than argued about.
331
+ */
332
+ type ManifestToolchain = {
333
+ chrome: string;
334
+ chromeOrigin: string;
335
+ ffmpeg: string;
336
+ ffmpegOrigin: string;
337
+ };
338
+ type RenderManifest = {
339
+ videoId: string;
340
+ sourceHash: string;
341
+ manifestHash: string;
342
+ input: unknown;
343
+ prepared: unknown;
344
+ format: {
345
+ width: number;
346
+ height: number;
347
+ fps: number;
348
+ duration: number;
349
+ durationInFrames: number;
350
+ };
351
+ scenes: Array<{
352
+ id: string;
353
+ start: number;
354
+ durationInFrames: number;
355
+ }>;
356
+ audio: ManifestAudioCue[];
357
+ assets: ManifestAsset[];
358
+ fonts: ManifestFont[];
359
+ /** Null when nothing resolved a toolchain, so the field is always present. */
360
+ toolchain: ManifestToolchain | null;
361
+ createdAt: string;
362
+ };
363
+ type CreateManifestOptions = {
364
+ entry: Pick<VideoEntry, "metadata">;
365
+ layout: VideoLayout;
366
+ input: unknown;
367
+ prepared?: unknown;
368
+ sourceHash: string;
369
+ durationInFrames?: number;
370
+ scenes?: RenderManifest["scenes"];
371
+ audio?: ManifestAudioCue[];
372
+ assets?: ManifestAsset[];
373
+ fonts?: ManifestFont[];
374
+ toolchain?: ManifestToolchain;
375
+ createdAt?: string;
376
+ };
377
+ /**
378
+ * Freeze everything a render depends on. Preview and export consume the same
379
+ * object, so an approved cut cannot drift because a URL or a row changed.
380
+ */
381
+ declare const createRenderManifest: ({ entry, layout, input, prepared, sourceHash, durationInFrames, scenes, audio, assets, fonts: resolvedFonts, toolchain, createdAt, }: CreateManifestOptions) => RenderManifest;
382
+ type ExportJob = {
383
+ id: string;
384
+ videoId: string;
385
+ manifestHash: string;
386
+ status: "queued" | "rendering" | "encoding" | "ready" | "failed";
387
+ progress: number;
388
+ attempts: number;
389
+ /** Process that owns an in-flight render, used to detect a crashed job. */
390
+ pid?: number;
391
+ output?: string;
392
+ logs: string[];
393
+ error?: string;
394
+ createdAt: string;
395
+ updatedAt: string;
396
+ };
397
+
398
+ export { type AudioTrack as A, entryDurationInFrames as B, type CompiledTimeline as C, DUCK_GAIN as D, type EnvelopePoint as E, Fill as F, envelopeAtFrame as G, gainAtFrame as H, isAssetReference as I, resolveEntryLayout as J, sampleGainCurve as K, Loop as L, type ManifestAsset as M, sortCues as N, OdoriRuntime as O, trackDuration as P, trackGainAtFrame as Q, type RenderManifest as R, SafeArea as S, useSceneTransition as T, type ManifestToolchain as U, type VideoEntry as V, type VideoLayout as a, Audio as b, type AudioCue as c, type AudioPolicy as d, type AudioProps as e, type CompiledScene as f, type CreateManifestOptions as g, DUCK_RAMP_FRAMES as h, type ExportJob as i, Freeze as j, type ManifestAudioCue as k, type ManifestFont as l, type MotionPolicy as m, type OdoriRuntimeProps as n, type SafeArea$1 as o, Scene as p, type SceneTransition as q, Stagger as r, Video as s, type VideoFormat as t, type VideoLayoutInput as u, createRenderManifest as v, cueId as w, defaultLayout as x, defineVideoLayout as y, duckEnvelope as z };
@@ -0,0 +1,4 @@
1
+ export { g as CreateManifestOptions, i as ExportJob, M as ManifestAsset, k as ManifestAudioCue, l as ManifestFont, U as ManifestToolchain, R as RenderManifest, v as createRenderManifest } from './manifest-CEuFXG0U.js';
2
+ import './brand-D71KbhAe.js';
3
+ import 'react/jsx-runtime';
4
+ import 'react';
@@ -0,0 +1,9 @@
1
+ "use client";
2
+ import {
3
+ createRenderManifest
4
+ } from "./chunk-VQLDJUK4.js";
5
+ import "./chunk-PXG45HYV.js";
6
+ export {
7
+ createRenderManifest
8
+ };
9
+ //# sourceMappingURL=manifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,92 @@
1
+ import * as react from 'react';
2
+ import { Component, ReactNode, ErrorInfo, ComponentType } from 'react';
3
+ import { f as CueDefinition, D as Duration, B as Brand } from './brand-D71KbhAe.js';
4
+ import { F as FieldDescriptor } from './schema-DXxRezrk.js';
5
+ import * as react_jsx_runtime from 'react/jsx-runtime';
6
+
7
+ type CueWaveProps = {
8
+ /** The score to draw. Its samples are rendered, not approximated. */
9
+ cue: CueDefinition;
10
+ /** Shown under the wave. Defaults to the name the cue registers. */
11
+ label?: string;
12
+ /** Bars across the canvas. More is finer, and slower to render. */
13
+ columns?: number;
14
+ };
15
+ /**
16
+ * A cue drawn from its own samples, with a playhead crossing it in time.
17
+ *
18
+ * A sound needs a picture on a page that cannot make noise until it is
19
+ * clicked, and the honest picture is the waveform the score actually produces:
20
+ * rendering is deterministic, so this is the sound rather than a decorative
21
+ * squiggle. It lives in `odori/preview` because it is preview furniture — a
22
+ * project owns the score it installed, not the chart of it, and fifteen cues
23
+ * should not carry fifteen copies of this loop.
24
+ */
25
+ declare const CueWave: ({ cue, label, columns }: CueWaveProps) => react_jsx_runtime.JSX.Element;
26
+
27
+ type PreviewBoundaryProps = {
28
+ children: ReactNode;
29
+ /**
30
+ * Changing this clears a caught error. Pass whatever identifies the thing
31
+ * being previewed — an entry id, a format, a brand — so switching away from
32
+ * a broken composition shows the next one instead of its predecessor's
33
+ * error. A module edit clears it on its own, through the HMR hook below.
34
+ */
35
+ resetKey?: string | number;
36
+ /** Shown above the message. Defaults to naming the composition generically. */
37
+ label?: string;
38
+ };
39
+ type State = {
40
+ error: Error | null;
41
+ componentStack: string | null;
42
+ };
43
+ /**
44
+ * The designed failure for a composition that throws.
45
+ *
46
+ * Preview only. A render worker must fail loudly and exit non-zero rather than
47
+ * paint an apology into an exported frame, which is why this lives in
48
+ * `odori/preview` and no export path imports it.
49
+ *
50
+ * Without it, one bad component takes the whole surface down and leaves
51
+ * whatever React last painted, with the real message in a console the author
52
+ * may not have open.
53
+ */
54
+ declare class PreviewBoundary extends Component<PreviewBoundaryProps, State> {
55
+ state: State;
56
+ static getDerivedStateFromError(error: Error): Partial<State>;
57
+ componentDidUpdate(previous: PreviewBoundaryProps): void;
58
+ componentDidCatch(error: Error, info: ErrorInfo): void;
59
+ render(): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
60
+ }
61
+
62
+ type ComponentPreview<Props extends object = Record<string, unknown>> = {
63
+ readonly kind: "odori-component-preview";
64
+ title: string;
65
+ category: string;
66
+ description?: string;
67
+ component: ComponentType<Props>;
68
+ canvas: {
69
+ width: number;
70
+ height: number;
71
+ duration: Duration;
72
+ };
73
+ controls?: Record<string, FieldDescriptor>;
74
+ brands?: Brand[];
75
+ examples: Array<{
76
+ name: string;
77
+ props: Partial<Props>;
78
+ }>;
79
+ };
80
+ type ComponentPreviewInput<Props extends object> = Omit<ComponentPreview<Props>, "kind" | "examples"> & {
81
+ examples?: Array<{
82
+ name: string;
83
+ props: Partial<Props>;
84
+ }>;
85
+ };
86
+ /**
87
+ * A development-only fixture. Production bundles never import preview modules,
88
+ * so this contract can be as rich as Studio needs.
89
+ */
90
+ declare const defineComponentPreview: <Props extends object>(preview: ComponentPreviewInput<Props>) => ComponentPreview<Props>;
91
+
92
+ export { type ComponentPreview, type ComponentPreviewInput, CueWave, type CueWaveProps, PreviewBoundary, type PreviewBoundaryProps, defineComponentPreview };