Clone any viral video with AI agents. Not just a script, the whole workflow: swap the face, the words, the B-roll, ship 100 variants in one command, and get your 100M views.
TypeScript agentic-aiaiai-agentsai-videocompilerdslffmpeggenerative-aillmmarkup-languagemonorepoplugin-systemprogramming-languagetext-to-videotypescriptvideovideo-automationvideo-clonevideo-editingvideo-generation
fix: follow main's Frontend, Record, and Semantic Map contracts (#6)
rponeawac331c379e5d7
diff --git a/.agents/skills/narratage/SKILL.md b/.agents/skills/narratage/SKILL.mdindex 1eb3538a..d1aee06e 100644--- a/.agents/skills/narratage/SKILL.md+++ b/.agents/skills/narratage/SKILL.md@@ -20,10 +20,49 @@ Source, and the declarative `svml.runtime.json` Runtime Profile separate.`references/playbooks/craft/visual-continuity.md`, then the relevant craft/format file.- Reference-video reconstruction → read `references/reference-vlm.md`; emit `main.svml`, optional`studio.svs`, and `build.svrun` directly.+- Showing an author what they have so far → start the SVML Playground and send them the link.+ See "Show the work" below.- Execution, Runtime control, Build inspection, or output retrieval → read`references/runtime.md`; diagnose and start the durable Runtime, `check` Author Source, `plan`before paid work, then submit, inspect, and retrieve the Build.+## Show the work++After each step that changes a Source — a Script edit, a Frame moved, a B-roll+placed, a Recipe adjusted — start the Playground and give the author the link.+Reading a diff is not the same as seeing where a cutaway lands.++```bash+pkill -f svml-playground || true # never leave the old one holding the port+pnpm svml:playground -- --source path/to/main.svml \+ --run path/to/build.svrun \+ --runtime path/to/svml.runtime.json &+# then send the author: http://localhost:5179/+```++Kill the previous server first. A second one silently picks another port, and the+author ends up looking at a stale preview while you describe a new one.++Both extra arguments are optional and each answers one question. `--run` says+which material and which timings to read the Source with. `--runtime` says where+material earlier Builds produced is kept, and is needed only by a Source that+reuses an accepted shot through `<build-record>`; without it that one shot is+refused by name and everything else still draws.++The preview compiles the Source with the real compiler and runs the same+Producers a build runs, so a Source that will not build does not preview. It+needs no build of its own: a directory holding `main.svml` and its `.svs` is+enough.++What it cannot know, it stands in for and says so. Words are placed at an+ordinary delivery pace, except where the Source declares a length — a take that+says it is eight seconds long gets eight seconds of words. A shot nobody has+made shows the picture it names, or a black frame if it names none. Captions+nobody has phrased are cut every few words. Each Track says which of these it is+showing, so say that rather than implying a preview is a render.++Read `docs/guide/svml-playground.md` before explaining what an author is seeing.+## Ordinary loop```bashdiff --git a/.agents/skills/narratage/references/playbooks/craft/b-roll.md b/.agents/skills/narratage/references/playbooks/craft/b-roll.mdindex e758e0ec..d0631844 100644--- a/.agents/skills/narratage/references/playbooks/craft/b-roll.md+++ b/.agents/skills/narratage/references/playbooks/craft/b-roll.md@@ -1,3 +1,24 @@+++## See it before you generate it++Where a cutaway lands, how long it holds, and whether its Frame sits in the right+part of the picture are all decided by the Source, not by the footage. The SVML+Playground answers all three without a generation:++```bash+pkill -f svml-playground || true+pnpm svml:playground -- --source path/to/main.svml --run path/to/build.svrun &+# send the author http://localhost:5179/+```++Each Item shows real frames when its source already exists and already lives in+the program's frame rate, and a painted box when it does not, so an unresolved+B-roll is still placed and still scrubbable. Timings are estimated until a build+or a Run Source supplies measured ones — the badges say which, and an estimated+cut point will move once WhisperX has heard the audio.++Do this after placing a Selection and before paying for a generation.# B-roll craftB-roll is authored visual evidence, context, or emotional progression outside the primary speakingdiff --git a/.gitignore b/.gitignoreindex 4b3361ea..7c72ba6d 100644--- a/.gitignore+++ b/.gitignore@@ -55,3 +55,4 @@ services/media-lambda/build/# macOS Finder metadata.DS_Store+examples/**/.svml/diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.tsindex e3022442..8ddf7893 100644--- a/docs/.vitepress/config.ts+++ b/docs/.vitepress/config.ts@@ -155,6 +155,7 @@ const enTheme = {{ text: "Adding an Author Package", link: "/guide/author-packages" },{ text: "Adding a Provider", link: "/guide/providers" },{ text: "Runtime Profile", link: "/guide/runtime-profile" },+ { text: "SVML Playground", link: "/guide/svml-playground" },{ text: "Caption Playground", link: "/guide/caption-playground" },{ text: "Local Services", link: "/guide/services" },{ text: "Testing", link: "/guide/testing" },@@ -198,6 +199,7 @@ const zhTheme = {{ text: "添加 Author 包", link: "/zh/guide/author-packages" },{ text: "添加 Provider", link: "/zh/guide/providers" },{ text: "Runtime Profile", link: "/zh/guide/runtime-profile" },+ { text: "SVML Playground", link: "/zh/guide/svml-playground" },{ text: "字幕 Playground", link: "/zh/guide/caption-playground" },{ text: "本地服务", link: "/zh/guide/services" },{ text: "测试", link: "/zh/guide/testing" },diff --git a/docs/guide/svml-playground.md b/docs/guide/svml-playground.mdnew file mode 100644index 00000000..b347771c--- /dev/null+++ b/docs/guide/svml-playground.md@@ -0,0 +1,159 @@+# SVML Playground++A read-only preview of one Source: the code on the right, the picture top-left,+and a timeline bottom-left rendered from the SVML itself.++```bash+pnpm svml:playground -- --source examples/talking-film-broll-preview/main.svml+# ➜ http://localhost:5179/+```++| Argument | Meaning |+| --- | --- |+| `--source <main.svml>` | The Author Source to read. Required. |+| `--run <build.svrun>` | A Run Source, read for material and timings it already names. |+| `--runtime <svml.runtime.json>` | Where material earlier Builds produced is kept. Only a Source that reuses an accepted shot needs one. |+| `--port <number>` | Defaults to `5179`. |++The Playground never writes. There is no route that can change what you wrote,+and no form that edits a Recipe — that is the+[Caption Playground](./caption-playground)'s job.++## What it is for++Reading a Source as a timeline **before** anything has been generated. It+answers "where does this B-roll land, how long is it, and is the card in the+right part of the frame" without a Seedance generation, a WhisperX alignment, an+FFmpeg render or a headless browser.++It runs on a directory holding nothing but `main.svml` and its `.svs` style+sheet. No package lock, no Runtime Profile, no build.++## Three ways into one selection++The timeline, the source and the picture are three views of the same thing, so+selecting in any of them selects in all three.++- **Click a timeline clip** and the playhead moves to its first frame, the+ picture draws a box around it, and the source scrolls to the+ `<media-track:Item>` that placed it.+- **Click a marked line in the source** and the same happens. Lines that bind a+ clip carry a coloured bar in the gutter, so what is clickable is visible+ standing still. A Script marker pair and the clip it binds share a colour.+- **Click the picture** and whatever is drawn under the pointer is selected.++Clicking marked prose lands **inside the marker you clicked**, not at the start+of whatever encloses it — a marker that places nothing still means something.++Scrub by dragging the ruler or an empty part of a track. `Space` plays and+pauses, `←` and `→` step one frame with `Shift` ten, `Home` and `End` jump to the+ends, and `Esc` clears the selection.++## Levels++A Segment encloses a Selection, which can enclose another Selection. Each level+is drawn in its own colour, in the source, on the timeline and on the picture,+and **an enclosing range stays outlined while an inner one is** — the nesting is+what the markers are for. Two ranges at the same level are the same kind of+thing and read the same.++Everything the playhead is inside is outlined as it passes, whether or not a+Track was hung on it.++## Sound++HyperFrames renders a silent picture on purpose: programme audio is a separate+Track the media pipeline muxes in at the end. A preview is not a render, and+placing B-roll against speech means hearing the speech, so the Speech Spine's own+material is allowed to sound while the transport is running. Cutaways stay+silent, as they are in a build unless they ask otherwise. The speaker button+turns it off.++## What is real and what is estimated++Everything structural is real. Placement Frames, padding, stacking order, motion+and the Track layout are computed by the same functions a build calls, from your+Source and your style sheet.++Timings are another matter, and the header says which you are looking at:++| Badge | Meaning |+| --- | --- |+| `timing: measured` | Read from a completed build's aligned transcript. |+| `timing: estimated` | Derived from the Script text at normal delivery pace. |+| `picture: measured` | Every element shows real material. |+| `picture: estimated` | Some shots have not been made, and stand in. |+| `picture: estimated` | Nothing has been shot or generated yet. |++The two are separate claims. A Source can have all its footage and still have an+estimated timeline, because where a cut lands is a question about speech, not+about files.++The Playground prefers real things, in this order:++1. **A Run Source.** Which material and which timings a Source is read with is+ an authoring decision, so `<satisfy>` is where it is made:++ | Candidate | Supplies |+ | --- | --- |+ | `<file from="./shot.mp4" media-type="video/mp4"/>` | Material you already have. |+ | `<value type="…" from="./timing.json"/>` | A value on disk, such as an alignment produced elsewhere. |+ | `<build-record build="…" output="take.video"/>` | Something an earlier Build made. Needs `--runtime`. |++ Timings are called measured only when both `timing.map` and the Program Space+ were supplied. One without the other is still an estimate, and says so.++2. **An earlier Build.** A shot that has been generated and accepted is named by+ the Build it came from, not by a path — a produced Artifact has an identity+ rather than a location. Given `--runtime`, the Playground reads that Build's+ Record and the Artifact bytes behind it, so a take generated yesterday is the+ take on screen today. Without it, the Run Source is still read and only the+ Build Record is refused, with the Build named.++3. **The Script text.** Word durations come from `@narratage/estimate`, the same+ syllable model the pipeline uses before generation.++An estimated timeline is a proportion, not a prediction: real cut points move+once WhisperX has aligned real audio.++## What stands in for what has not been made++A Track cannot be built without the material it places, and refusing to draw+anything until every shot exists would make the preview useless for the part of+the work it is meant for. So three things stand in, each announced rather than+presented as fact:++| Missing | Shown instead |+| --- | --- |+| A generated shot that names a picture | That picture, held for the length the shot declares |+| A generated shot that names nothing | A black frame of the programme's shape |+| Caption phrasing nobody has planned | The words cut every few Atoms, in the Program's own runs |++The first is why a preview is worth looking at before anything is generated: a+reference frame is not the take, but it is the right subject in the right shape.+Both stand-ins are marked on the clip itself — hatched for a picture, dimmed for+a black frame — and named in full when the clip is selected. Drawing them needs+`ffmpeg`; without it the shots stay unmade and the Tracks say so.++## What it draws++Every Track the Source produces, whichever package made it. The Playground asks+the compiled Source for its exports and builds the ones typed `VisualTrack` or+`AudioTrack` — so a package that grows a new kind of Track appears here without+the Playground being taught about it.++Each Track is built on its own. A Track waiting on a Provider this machine has+no key for costs only itself; the rest of the programme still plays, and the+Track says what it was waiting for rather than disappearing.++This is the compiler, not a reading of it. The Source is compiled by+`compileSourceClosure` and executed by the same Producers a build runs, so a+Source that will not build does not silently preview. Two thin decorators keep+the source positions the compiler discards — nothing else is re-implemented.++## A note on `<space:Frame>`++`right` and `bottom` are **absolute edge positions**, not insets. A Frame+spanning the middle 80% of its parent is `left="8%" right="92%"`, not+`left="8%" right="8%"` — the latter resolves to zero width and is rejected. The+Playground reports that with the offending element highlighted.diff --git a/docs/quickstart/tracks.md b/docs/quickstart/tracks.mdindex 77f13d27..c1d52561 100644--- a/docs/quickstart/tracks.md+++ b/docs/quickstart/tracks.md@@ -186,7 +186,10 @@ Placement is an explicit Spatial Frame edge; appearance and motion remain reusab````left`, `top`, `right` and `bottom` are edge coordinates inside the parent Frame; `right` and-`bottom` are not CSS-style margins. The Selection contributes semantic points; Media performs the package-owned window projection.+`bottom` are not CSS-style margins. A Frame covering the middle 84% of the canvas horizontally is+`left="8%" right="92%"`, and `right="8%"` would place its right edge to the left of its left edge,+which is rejected. The Selection contributes semantic points; Media performs the package-owned+window projection.The same Item model also covers full-canvas cutaways, split screens and corner overlays. Orderedchild layers, source occupancy and explicit Sequences are available when one source is not enough.diff --git a/docs/zh/guide/svml-playground.md b/docs/zh/guide/svml-playground.mdnew file mode 100644index 00000000..84472bbe--- /dev/null+++ b/docs/zh/guide/svml-playground.md@@ -0,0 +1,134 @@+# SVML Playground++单个 Source 的只读预览:右边是代码,左上是画面,左下是直接从 SVML 渲染出的时间轴。++```bash+pnpm svml:playground -- --source examples/talking-film-broll-preview/main.svml+# ➜ http://localhost:5179/+```++| 参数 | 含义 |+| --- | --- |+| `--source <main.svml>` | 要读取的 Author Source,必填。 |+| `--run <build.svrun>` | Run Source,用来读取其中已经指名的素材与时间戳。 |+| `--runtime <svml.runtime.json>` | 早先构建产出的素材存放在哪里。只有复用已验收镜头的 Source 才需要。 |+| `--port <number>` | 默认 `5179`。 |++Playground 从不写入。它没有任何可以改动你所写内容的路由,也没有编辑 Recipe 的表单+—— 那是[字幕 Playground](./caption-playground) 的职责。++## 它解决什么问题++**在任何东西被生成之前**,把 Source 当成时间轴来读。不需要 Seedance 生成、不需要+WhisperX 对齐、不需要 FFmpeg 渲染、不需要无头浏览器,就能回答「这条 B-roll 落在哪、+多长、卡片在画面里的位置对不对」。++一个只装着 `main.svml` 和它的 `.svs` 样式表的目录就能跑。不需要 package lock、+不需要 Runtime Profile、不需要构建。++## 通往同一个选中的三条路++时间轴、源码和画面是同一件事的三种视图,在任何一处选中,三处同时选中。++- **点时间轴的片段**:播放头移到它的第一帧,画面上把它框出来,源码滚动到放置它的+ 那个 `<media-track:Item>`。+- **点源码里被标记的行**:结果相同。绑定了片段的行在行号旁有一条彩色竖条,所以哪里+ 可点是静止可见的,不用靠鼠标扫过去发现。一对 Script 标记和它绑定的片段共用一个颜色。+- **点画面**:指针下面画的是什么就选中什么。++点击被标记的散文会落在**你点的那个标记里面**,而不是被甩到包着它的那一层的开头 ——+一个什么都不放置的标记依然有含义。++拖动标尺或轨道空白处可以 scrub。`空格` 播放/暂停,`←` `→` 逐帧(配合 `Shift` 为十+帧),`Home` / `End` 跳到首尾,`Esc` 取消选中。++## 层级++Segment 包着 Selection,Selection 还能再包 Selection。**每一层有自己的颜色**,在源码、+时间轴和画面上一致;而且**内层被框住时外层保持框住** —— 嵌套关系正是这些标记存在的+理由。同一层的两个范围是同一种东西,读起来也相同。++播放头经过的每一个范围都会被框出来,不管有没有轨道挂在它上面。++## 声音++HyperFrames **刻意只渲染无声画面**:programme audio 是独立的 Track,由 media pipeline+在最后 mux 进去。但预览不是渲染 —— 检查 B-roll 落点的前提就是能听见那句话,所以播放时+Speech Spine 自己的素材允许发声。Cutaway 保持静音,这和真实构建里的行为一致(除非显式+声明要带音频)。喇叭按钮可以关掉。++## 哪些是真实的,哪些是估算的++结构性的一切都是真实的。Placement Frame、padding、层叠顺序、动效和轨道布局,都由构建+所调用的同一批函数、从你的 Source 和样式表算出。++时间则是另一回事,顶栏的徽章会说明你正在看的是哪一种:++| 徽章 | 含义 |+| --- | --- |+| `timing: measured` | 读自已完成构建的对齐转写。 |+| `timing: estimated` | 按常速语速从 Script 文本推导。 |+| `picture: measured` | 每个元素都显示真实素材。 |+| `picture: estimated` | 有些镜头还没做出来,用替身顶着。 |+| `picture: estimated` | 尚无任何拍摄或生成产物。 |++两者是**独立的判断**。一份 Source 可以素材齐备而时间轴仍是估算的 —— 剪切点落在哪里+是关于语音的问题,不是关于文件的问题。++Playground 按以下顺序优先采用真实来源:++1. **Run Source。** 用哪些素材、哪份时间戳是**作者的决定**,所以由 `<satisfy>` 指定:++ | 候选 | 提供什么 |+ | --- | --- |+ | `<file from="./shot.mp4" media-type="video/mp4"/>` | 你手上已有的素材。 |+ | `<value type="…" from="./timing.json"/>` | 磁盘上的一个值,例如别处产出的对齐结果。 |+ | `<build-record build="…" output="take.video"/>` | 上一次构建做出来的东西。需要 `--runtime`。 |++ 只有 `timing.map` 和 Program Space **两者都被提供**时才算实测;只给其中一个仍然+ 是估算,并且会照实说。++2. **上一次构建。** 已经生成并验收的镜头,是按**它出自哪次构建**来指名的,不是按路径+ —— 产出物有身份,没有位置。给了 `--runtime`,Playground 就去读那次构建的记录和它+ 背后的 Artifact 字节,于是昨天生成的镜头就是今天屏幕上的镜头。不给的话,Run Source+ 照读,只有那条 build record 被拒绝,并说明是哪一次构建。++3. **Script 文本。** 词的时长来自 `@narratage/estimate`,也就是流水线在生成之前使用的+ 同一套音节模型。**凡是 Source 已经声明了时长的地方,以声明为准** —— 一段 take 说自己+ 是 8 秒,它的词就铺满这 8 秒,音节模型只提供词与词之间的比例。++估算出的时间轴是**比例,不是预测**:真实的剪切点会在 WhisperX 对齐真实音频之后移动。++## 没做出来的东西用什么顶上++一条 Track 没有素材就建不出来,而"所有镜头都拍完之前什么都不画"会让预览在它最该派上+用场的阶段毫无用处。所以有三种顶替,每一种都写明,不会被说成是成品:++| 缺什么 | 顶上的东西 |+| --- | --- |+| 一个引用了图片的生成镜头 | 那张图,按镜头声明的时长撑开 |+| 一个什么都没引用的生成镜头 | 与节目同尺寸的黑场 |+| 没人规划过的字幕分句 | 按 Program 自己的 run,每几个 Atom 切一屏 |++第一种正是"还没生成就值得预览"的原因:参考图不是成片,但主体对、画幅对。两种顶替都+标在片段本身上,选中时会写明是哪一种。画它们需要 `ffmpeg`;没有的话镜头就保持未做,+轨道会照实说。++## 它画哪些东西++这份 Source 产出的每一条 Track,无论出自哪个包。Playground 向编译结果要它的导出,+把类型是 `VisualTrack` 或 `AudioTrack` 的那些建出来 —— 所以某个包新长出一种 Track,+不需要教 Playground 就会出现在这里。++每条 Track 各自构建。某条轨道在等一个这台机器没有密钥的 Provider,代价只有它自己:+其余部分照常播放,而那条轨道会说明它在等什么,而不是凭空消失。++这是编译器本身,不是对它的一种解读。Source 由 `compileSourceClosure` 编译,由构建时+同一批 Producer 执行,所以**构建不出来的 Source 不会悄悄预览成功**。两个很薄的装饰器+留住了编译器丢弃的源码位置,除此之外没有任何东西被重新实现。++## 关于 `<space:Frame>` 的一点说明++`right` 和 `bottom` 是**绝对边位置**,不是内缩量。占据父级中间 80% 的 Frame 写作+`left="8%" right="92%"`,而不是 `left="8%" right="8%"` —— 后者解出的宽度为零,会被+拒绝。Playground 会报出这一点,并高亮出错的元素。diff --git a/examples/all-components-preview/README.md b/examples/all-components-preview/README.mdnew file mode 100644index 00000000..bc4105a4--- /dev/null+++ b/examples/all-components-preview/README.md@@ -0,0 +1,18 @@+# All components++One Source that writes every kind of Track at once: speech, a ranking board, a+media card, a screen treatment, typography and captions, over a take nobody has+generated yet.++It exists to be previewed rather than built. A Source in this state — no+footage, no recording, no caption plan — is the state most Sources are in for+most of their life, and it is the state the preview has to be honest about:++```+pnpm svml:playground -- --source examples/all-components-preview/main.svml+```++Every Track builds. The takes stand in as the reference picture they name, held+for the length they declare; the words are placed at an ordinary delivery pace;+the captions are cut every few words because nothing has phrased them. All three+are reported as estimates rather than shown as fact.diff --git a/examples/all-components-preview/build.svrun b/examples/all-components-preview/build.svrunnew file mode 100644index 00000000..278c7bef--- /dev/null+++ b/examples/all-components-preview/build.svrun@@ -0,0 +1,6 @@+<?svml using="@narratage/run-markup@1"?>++<svrun version="1">+ <author source="./main.svml"/>+ <target output="final.video"/>+</svrun>diff --git a/examples/all-components-preview/image-only.svrun b/examples/all-components-preview/image-only.svrunnew file mode 100644index 00000000..6dcd51c4--- /dev/null+++ b/examples/all-components-preview/image-only.svrun@@ -0,0 +1,6 @@+<?svml using="@narratage/run-markup@1"?>++<svrun version="1">+ <author source="./main.svml"/>+ <target output="presenter.image"/>+</svrun>diff --git a/examples/all-components-preview/main.svml b/examples/all-components-preview/main.svmlnew file mode 100644index 00000000..08e929a6--- /dev/null+++ b/examples/all-components-preview/main.svml@@ -0,0 +1,146 @@+<?svml using="@narratage/markup@1"?>++<svml>+ <import from="@narratage/script@1"/>+ <import as="wording" from="@narratage/text@1"/>+ <import as="seedance" from="@narratage/seedance@1"/>+ <import as="media" from="@narratage/media@1"/>+ <import as="gpt" from="@narratage/gpt-image@1"/>+ <import as="speech" from="@narratage/speech-spine@1"/>+ <import as="whisperx" from="@narratage/whisperx@1"/>+ <import as="media-track" from="@narratage/media-track@1"/>+ <import as="ranking" from="@narratage/ranking@1"/>+ <import as="screen" from="@narratage/screen-overlay@1"/>+ <import as="deck" from="@narratage/deck-track@1"/>+ <import as="caption" from="@narratage/caption@1"/>+ <import as="caption-fine" from="@narratage/caption-fine@1"/>+ <import as="caption-ai" from="@narratage/caption-gemini@1"/>+ <import as="fonts" from="@narratage/fonts-open@1"/>+ <import as="text" from="@narratage/typography-track@1"/>+ <import as="space" from="@narratage/spatial@1"/>+ <import as="film" from="@narratage/film@1"/>+ <import as="render" from="@narratage/render-hyperframes@1"/>+ <import as="studio" source="./studio.svs"/>++ <!-- One Script, written so every Track below is placed by something said+ rather than by a timecode: a Segment per take, a Selection per cutaway+ and per board row, and a Moment where the board settles. -->+ <script id="story">+ <opening>+ <HOST>@board This is every component at once. @title A card cuts in+ here@/title, @overlay the picture flashes@/overlay, and the board fills+ as each one is named.+ <HOST>Spatial. @place!@deal-one! Typography. @place!@deal-two!+ </opening>+ <closing>+ <HOST>Ranking. @place!@deal-three! Captions. @place!@deal-four!+ <HOST>That is the whole of it@/board. @done!+ </closing>+ </script>++ <space:Canvas id="vertical" width="1080" height="1920"/>+ <space:Frame id="full" within={vertical} left="0%" top="0%" right="100%" bottom="100%"/>+ <!-- A board fills from its bottom edge upward, so the Frame is sized to the+ rows it holds: four rows, three gaps and the Recipe's padding. A taller+ Frame would leave the rows floating at the bottom of an empty box. -->+ <space:Frame id="board-frame" within={vertical} left="4%" top="14%" right="38%" bottom="32.85%"/>+ <space:Frame id="card-frame" within={vertical} left="10%" top="60%" right="90%" bottom="86%"/>+ <space:Frame id="title-frame" within={vertical} left="0%" top="6%" right="100%" bottom="13%"/>++ <!-- A generated take, so the preview has something with no material behind it+ and a reference picture to stand in with. -->+ <wording:Value id="direction">A presenter talking straight to camera, plain background.</wording:Value>+ <wording:Value id="look">A friendly presenter in a plain grey studio, waist up, facing camera,+ soft even light, neutral expression.</wording:Value>+ <gpt:Image id="presenter" prompt={look} aspect-ratio="9:16" resolution="2K"/>+ <seedance:ReferenceVideo id="take-opening" model="mini" prompt={direction} duration="8"+ generate-audio="true">+ <seedance:Reference image={presenter.image}/>+ </seedance:ReferenceVideo>+ <seedance:ReferenceVideo id="take-closing" model="mini" prompt={direction} duration="8"+ generate-audio="true">+ <seedance:Reference image={presenter.image}/>+ </seedance:ReferenceVideo>++ <!-- Pictures on disk, so the Media Track and the board have real material. -->+ <media:Image id="card-shot" src="./assets/card.webp"/>+ <media:Image id="icon-spatial" src="./assets/icon-1.webp"/>+ <media:Image id="icon-type" src="./assets/icon-2.webp"/>+ <media:Image id="icon-ranking" src="./assets/icon-3.webp"/>+ <media:Image id="icon-caption" src="./assets/icon-4.webp"/>+ <space:Extent id="portrait" width="540" height="960"/>+ <space:Extent id="square" width="192" height="192"/>++ <speech:Spine id="speech" frame-rate="30"+ visual-frame={full} visual-appearance={studio.speech.visual} visual-z="0">+ <speech:Take video={take-opening.video} segment={story.segment.opening}/>+ <speech:Take video={take-closing.video} segment={story.segment.closing}/>+ </speech:Spine>+ <whisperx:Alignment id="timing" narrative={story} audio={speech.audio}/>++ <fonts:Stack id="ui-font" family="inter" weight="700" style="normal"/>++ <!-- A board, filled one row per `@place!` and cleared on `@done!`. -->+ <ranking:ColumnStyle id="board-style" recipe={studio.ranking.board} font={ui-font}/>+ <ranking:Column id="board" map={timing.map} space={speech.space} frame={board-frame}+ during={story.selection.board} triggers={story.moment.place} terminal={story.moment.done}+ style={board-style}>+ <ranking:ColumnItem id="row-spatial" label="Spatial" icon={icon-spatial}/>+ <ranking:ColumnItem id="row-type" label="Typography" icon={icon-type}/>+ <ranking:ColumnItem id="row-ranking" label="Ranking" icon={icon-ranking}/>+ <ranking:ColumnItem id="row-caption" label="Captions" icon={icon-caption}/>+ </ranking:Column>++ <!-- A card, held for exactly as long as its Selection is spoken. -->+ <media-track:Track id="cards" map={timing.map} space={speech.space} canvas={vertical}>+ <media-track:Item id="card" image={card-shot} extent={portrait}+ during={story.selection.title} frame={card-frame}+ appearance={studio.media.card} motion={studio.motion.card}/>+ </media-track:Track>++ <!-- A treatment over the whole picture, placed by a Selection like anything else. -->+ <screen:Track id="effects" space={speech.space} canvas={vertical}>+ <screen:Flash during={story.selection.overlay} map={timing.map} z="80"+ color="#ffffff" intensity="0.6" attack="2" hold="2" decay="6"/>+ </screen:Track>++ <!-- A deck, one card per board row, stepping forward as each is named. The+ preview was never taught about this Track; it appears because the package+ produces one. -->+ <space:Frame id="deck-frame" within={vertical} left="44%" top="60%" right="98%" bottom="88%"/>+ <deck:DepthStack id="deck" map={timing.map} space={speech.space} canvas={vertical}+ frame={deck-frame} appearance={studio.deck.stack} until={story.moment.done}>+ <deck:Card id="card-spatial" source={icon-spatial} extent={square} at={story.moment.deal-one}/>+ <deck:Card id="card-type" source={icon-type} extent={square} at={story.moment.deal-two}/>+ <deck:Card id="card-ranking" source={icon-ranking} extent={square} at={story.moment.deal-three}/>+ <deck:Card id="card-caption" source={icon-caption} extent={square} at={story.moment.deal-four}/>+ </deck:DepthStack>++ <text:Style id="title-style" recipe={studio.text.title} font={ui-font}/>+ <text:Track id="titles" space={speech.space}>+ <text:Area id="headline" placement={title-frame} style={title-style} during="program">+ EVERY COMPONENT AT ONCE+ </text:Area>+ </text:Track>++ <caption-fine:Style id="base-caption" recipe={studio.caption.base} font={ui-font}/>+ <caption:Program id="caption-program" display={story.caption} default={base-caption}/>+ <caption-ai:Planner id="cue-plan" display={story.caption} program={caption-program}+ model="gemini-2.5-flash"/>+ <caption-fine:Track id="captions" display={story.caption}+ correspondence={story.caption.correspondence}+ map={timing.map} space={speech.space}+ plan={cue-plan.plan} program={caption-program}/>++ <film:Film id="main" canvas={vertical} space={speech.space} appearance={studio.film.vertical}>+ <film:Track source={speech.visual}/>+ <film:Track source={speech.audioTrack}/>+ <film:Track source={board.visual}/>+ <film:Track source={cards.visual}/>+ <film:Track source={effects.track}/>+ <film:Track source={deck.track}/>+ <film:Track source={titles.track}/>+ <film:Track source={captions.track}/>+ </film:Film>+ <render:Video id="final" composition={main.composition} space={speech.space}/>+</svml>diff --git a/examples/all-components-preview/reuse.svrun b/examples/all-components-preview/reuse.svrunnew file mode 100644index 00000000..29543cc6--- /dev/null+++ b/examples/all-components-preview/reuse.svrun@@ -0,0 +1,13 @@+<?svml using="@narratage/run-markup@1"?>++<svrun version="1">+ <author source="./main.svml"/>+ <target output="final.video"/>++ <!-- The presenter frame this project already generated. Naming the Build is+ how a Source reuses an accepted shot; there is no path to write. -->+ <build-record id="accepted-presenter"+ build="sha256:6aea2d417b84985d09824ab9621939925854dc5fe7a8c606ce9aba8b14ef4191"+ output="presenter.image"/>+ <satisfy output="presenter.image" candidate="accepted-presenter"/>+</svrun>diff --git a/examples/all-components-preview/studio.svs b/examples/all-components-preview/studio.svsnew file mode 100644index 00000000..e0469d90--- /dev/null+++ b/examples/all-components-preview/studio.svs@@ -0,0 +1,62 @@+<?svml using="@narratage/svs@1"?>++<sheet version="1">+ film.vertical { background: #05060a; }+ speech.visual { fit: cover; }++ /* The board: a dark panel on the left third, one row per app, filling from the+ bottom rank upward as each name is spoken. */+ ranking.board {+ board-background: #070810EF;+ board-border-color: #FFFFFF2E; board-border-width: 1; board-radius: 6;+ board-shadow-x: 0; board-shadow-y: 6; board-shadow-blur: 18; board-shadow-spread: 0;+ board-shadow-color: #00000059;+ rank-colors: #ff3f56|#ffa72d|#eadc2a|#84c654|#31add0;+ padding: 18; row-height: 74; row-gap: 10;+ icon-size: 58; icon-radius: 13; icon-fit: contain;+ stage-x: 0.5; stage-y: 0.5; stage-size: 96;+ font-size: 34; font-weight: 900; text-color: #FFFFFF; line-height: 1.1;+ appear-frames: 11; move-frames: 13; motion-easing: ease-out;+ board-stack: 20; item-stack: 30; stage-stack: 25;+ }++ /* A cutaway replaces the shot, so it carries no box treatment. */+ /* A card sits inside the picture, so it keeps a box treatment. */+ /* A deck: the card being spoken about sits front, the ones before and after+ it stepping back behind it. */+ deck.stack {+ visible-previous: 2; visible-next: 2;+ current-x: 0.5; current-y: 0.5; current-scale: 1; current-opacity: 1; current-stacking: 50;+ previous-x-step: -0.16; previous-scale-step: 0.86; previous-opacity-step: 0.7;+ previous-rotation-step: -5; previous-stacking-step: -6;+ next-x-step: 0.16; next-scale-step: 0.86; next-opacity-step: 0.7;+ next-rotation-step: 5; next-stacking-step: -6;+ reflow-frames: 9; reflow-easing: ease-out;+ }++ media.card {+ stack-order: 60; fit: cover; clip: rounded; radius: 18; padding: 10 10;+ frame-paint: #14141c;+ }+ motion.card {+ enter: fade; enter-frames: 2; enter-easing: linear;+ exit: fade; exit-frames: 2; exit-easing: linear;+ }++ text.title {+ stack-order: 90;+ weight: 900; size: 62; align: center; fill: #FFFFFF; tracking: -1;+ padding: 14 22;+ }++ caption.base {+ cue-min-words: 1; cue-max-words: 3;+ stack-order: 70; x: 0.68; y: 0.56; width: 0.6; anchor-x: center; anchor-y: top;+ size: 50; line-height: 1.05; align: center;+ fill: #FFFFFF; stroke-color: #05060A; stroke-width: 2;+ shadow-color: #000000; shadow-opacity: 0.72; shadow-x: 0; shadow-y: 2; shadow-blur: 6;+ background: #00000000; border-color: #00000000; border-width: 0; padding: 0 0; radius: 0;+ karaoke: current; karaoke-transition: step; active-fill: #FFD34A;+ cue-enter: fade; cue-enter-frames: 2; cue-exit: fade; cue-exit-frames: 2;+ }+</sheet>diff --git a/examples/all-components-preview/svml.packages.lock b/examples/all-components-preview/svml.packages.locknew file mode 100644index 00000000..3e014d4b--- /dev/null+++ b/examples/all-components-preview/svml.packages.lock@@ -0,0 +1,1235 @@+{+ "format": "svml.node-package-lock@1",+ "selected": [+ "@narratage/caption",+ "@narratage/caption-fine",+ "@narratage/caption-gemini",+ "@narratage/film",+ "@narratage/fonts-open",+ "@narratage/gpt-image",+ "@narratage/media",+ "@narratage/media-track",+ "@narratage/ranking",+ "@narratage/render-hyperframes",+ "@narratage/run-markup",+ "@narratage/screen-overlay",+ "@narratage/script",+ "@narratage/seedance",+ "@narratage/spatial",+ "@narratage/speech-spine",+ "@narratage/svs",+ "@narratage/text",+ "@narratage/typography-track",+ "@narratage/whisperx"+ ],+ "artifacts": [+ {+ "name": "@fontsource-variable/archivo",+ "version": "5.3.0",+ "digest": "sha256:d0756ae991869df099871e469cc1a3206efc9c50ab34298da0b97aec284fec88"+ },+ {+ "name": "@fontsource-variable/bodoni-moda",+ "version": "5.3.0",+ "digest": "sha256:124e5f7bd2cd952ba895a72847b89bc4fa0a0d831644466393efe61b050622f8"+ },+ {+ "name": "@fontsource-variable/cabin",+ "version": "5.3.0",+ "digest": "sha256:c0da1888b21a3fdc8b391a08b7a59459ce2bdde5a4550bbd34cd6aaf381af93c"+ },+ {+ "name": "@fontsource-variable/caveat",+ "version": "5.3.0",+ "digest": "sha256:21e2ae66cd592a9bd0b53714d04b4aa9adeda6c9340d6180f174829155af2dbe"+ },+ {+ "name": "@fontsource-variable/cinzel",+ "version": "5.3.0",+ "digest": "sha256:883ab987aaf354347d03b5c4a6e59068611dff971011b75c0a2cd8785d084b85"+ },+ {+ "name": "@fontsource-variable/cormorant-garamond",+ "version": "5.3.0",+ "digest": "sha256:5fb212991abe42dc54820a0e99a50d54fd68b8794e05e01fcecd88bc3d9b718f"+ },+ {+ "name": "@fontsource-variable/crimson-pro",+ "version": "5.3.0",+ "digest": "sha256:2af0252ef3293e7f7213467bf2908cbd92a1ac1ef2de8a37ed3134aa553b0854"+ },+ {+ "name": "@fontsource-variable/dm-sans",+ "version": "5.3.0",+ "digest": "sha256:282b5942ecdf37ecb2946c271874f16053e32d7984e465bafa848cd70979b7c5"+ },+ {+ "name": "@fontsource-variable/eb-garamond",+ "version": "5.3.0",+ "digest": "sha256:3f839e82eff702919083009237af1c1975b80f8d9766ac5f97a291cfbf82dea0"+ },+ {+ "name": "@fontsource-variable/figtree",+ "version": "5.3.0",+ "digest": "sha256:bbd1e28aae1070c95fe09ce9bdc94e310b950d35e13d0817fce344d2a57a5c07"+ },+ {+ "name": "@fontsource-variable/fira-code",+ "version": "5.3.0",+ "digest": "sha256:26593d3b4aab4bef1d37b2f7b301739efd6861020b1f44e2cddf14b933453d72"+ },+ {+ "name": "@fontsource-variable/fraunces",+ "version": "5.3.0",+ "digest": "sha256:1da79839589a15663f4c0a75f91899450e20b8d6bd91044c826d07f4ca4d3771"+ },+ {+ "name": "@fontsource-variable/fredoka",+ "version": "5.3.0",+ "digest": "sha256:aeb50015a5e92b2033e5358f391f1221cf7a461f5793ab28d516fa0ee535af85"+ },+ {+ "name": "@fontsource-variable/geist-mono",+ "version": "5.3.0",+ "digest": "sha256:9122fc7e67d7f2788cb82b2eacd489a9430435133488962cbe9ab40ff952dccd"+ },+ {+ "name": "@fontsource-variable/geist",+ "version": "5.3.0",+ "digest": "sha256:01af74b4d77592a1d560c1992568eca3e719117b81b5c2c8798281680180a8c4"+ },+ {+ "name": "@fontsource-variable/instrument-sans",+ "version": "5.3.0",+ "digest": "sha256:10b5fd92cf05d3259b0dfca0b37971b7c522f29b17b5804ddc5bb404ceefc7e3"+ },+ {+ "name": "@fontsource-variable/inter",+ "version": "5.3.0",+ "digest": "sha256:e4ca49893204e3b3d156d22daddb4f96c06a94cc0d0767d6f7613d84d8e3d4fe"+ },+ {+ "name": "@fontsource-variable/jetbrains-mono",+ "version": "5.3.0",+ "digest": "sha256:0445625a317f4ff6cfe58c4272334b4af720309df2339356d3fb81e40c375210"+ },+ {+ "name": "@fontsource-variable/josefin-sans",+ "version": "5.3.0",+ "digest": "sha256:5780323301d2480c3e111de34f9dfc11d24fc165be4fcfbc9293dd34da0dcadd"+ },+ {+ "name": "@fontsource-variable/jost",+ "version": "5.3.0",+ "digest": "sha256:875e424e28d005d8b467aa576de202ae3b84c243eaa52d971e946243c1973439"+ },+ {+ "name": "@fontsource-variable/league-spartan",+ "version": "5.3.0",+ "digest": "sha256:6b05150ad1aeede4aed7505507c8b69187bd25f7897dd43ff7f2e93a0028c37c"+ },+ {+ "name": "@fontsource-variable/lexend",+ "version": "5.3.0",+ "digest": "sha256:ca5800b1c654c71ad3c93a47801c2f5748e49cff9b0985ed375c67f500bd1166"+ },+ {+ "name": "@fontsource-variable/libre-baskerville",+ "version": "5.3.0",+ "digest": "sha256:5297642650a09c5a59f7e602b88b7756d379397da7c6e4dfe273b8f1cc6a225c"+ },+ {+ "name": "@fontsource-variable/lora",+ "version": "5.3.0",+ "digest": "sha256:fdea73d2d75785a45046ef9e2dd1ccac35a1194e31ddabfb0f0b95582d418943"+ },+ {+ "name": "@fontsource-variable/manrope",+ "version": "5.3.0",+ "digest": "sha256:c7821cba633009f45db0ae545cbdcd1de1ec764d299b503ade1b8da6ad7f6f07"+ },+ {+ "name": "@fontsource-variable/merriweather",+ "version": "5.3.0",+ "digest": "sha256:0c264e97ca3f76da2d31726727b120a44910ab2620a45f3e09ae938d0fdcc9c4"+ },+ {+ "name": "@fontsource-variable/montserrat",+ "version": "5.3.0",+ "digest": "sha256:b457c7e96aae71eeee8683e6af5eb766c025b2a889d03daa5298fa2e1abc2855"+ },+ {+ "name": "@fontsource-variable/mulish",+ "version": "5.3.0",+ "digest": "sha256:5ce4f4131ef5c5a7ba7f78e7ea82dc45ea0c4ec0550699cf64568e09e54dbb2d"+ },+ {+ "name": "@fontsource-variable/newsreader",+ "version": "5.3.0",+ "digest": "sha256:3c7c5e41a7d778f342a4108253e062deba68ce5bcba1bad7b3cb962e57132a7a"+ },+ {+ "name": "@fontsource-variable/noto-emoji",+ "version": "5.3.0",+ "digest": "sha256:c135feb03a6be9cabe5bef963d63cfa08c97d3ecdf521aa309324c00cacd9964"+ },+ {+ "name": "@fontsource-variable/noto-naskh-arabic",+ "version": "5.3.0",+ "digest": "sha256:f7637a644a70cf88203426e0ebce7dcb8dc672baf63370437c39fbee8b125b8e"+ },+ {+ "name": "@fontsource-variable/noto-sans-arabic",+ "version": "5.3.0",+ "digest": "sha256:5981bdd510158a68c72e42557bcb3387d6ef9ba958bf5000500fa26fe7373767"+ },+ {+ "name": "@fontsource-variable/noto-sans-devanagari",+ "version": "5.3.0",+ "digest": "sha256:dae73904faa148f60a06af6b267916b6ce656c4c333f1b1de63828b8a5639686"+ },+ {+ "name": "@fontsource-variable/noto-sans-hebrew",+ "version": "5.3.0",+ "digest": "sha256:ff616f500efb9d965be8a95d46ca13f3113704360472286f0596aa0bff5dfbc3"+ },+ {+ "name": "@fontsource-variable/noto-sans-hk",+ "version": "5.3.0",+ "digest": "sha256:faa4e754134193f0c0ffa957c9aae3b75779bd443373a3c1e9759ce5876463d5"+ },+ {+ "name": "@fontsource-variable/noto-sans-jp",+ "version": "5.3.0",+ "digest": "sha256:adf3c03671005935de55199037a2e26ebb81471f95268d7327b54aa6ffbacf62"+ },+ {+ "name": "@fontsource-variable/noto-sans-kr",+ "version": "5.3.0",+ "digest": "sha256:97da1dc319b8f42deda034729ac2bfadb0e3b0992f8034edaa39d7270ba2b042"+ },+ {+ "name": "@fontsource-variable/noto-sans-sc",+ "version": "5.3.0",+ "digest": "sha256:1c49ddaaa5d7aeb0503cfa78914bb4957259108c3dfb262d5f4b2bc49549af89"+ },+ {+ "name": "@fontsource-variable/noto-sans-tc",+ "version": "5.3.0",+ "digest": "sha256:08085bc109242c4034e966d2a9580ee02b261ea04d01dbfc27e316f99223c849"+ },+ {+ "name": "@fontsource-variable/noto-sans-thai",+ "version": "5.3.0",+ "digest": "sha256:ff0050b1cc056bcf88fd713d1dc74f42b0e8799f7931ea89da03a51a03dc4588"+ },+ {+ "name": "@fontsource-variable/noto-sans",+ "version": "5.3.0",+ "digest": "sha256:d27afb70065955c963fc96bf65580a086e6d05c9e4b81177941eb730c5e44dd4"+ },+ {+ "name": "@fontsource-variable/noto-serif-jp",+ "version": "5.3.0",+ "digest": "sha256:c442057a769b0293012b790df56d250f08ec7abf5bcbcbc6ef39b9103329ef68"+ },+ {+ "name": "@fontsource-variable/noto-serif-kr",+ "version": "5.3.0",+ "digest": "sha256:000000dfd6e3700d029217bff41b83cfd0266af9fade349b32441f16facd8dce"+ },+ {+ "name": "@fontsource-variable/noto-serif-sc",+ "version": "5.3.0",+ "digest": "sha256:7d845bd433554bc7a9dc656dc7e0818d6083b080a3e9d69956b97b2cf4221d16"+ },+ {+ "name": "@fontsource-variable/noto-serif-tc",+ "version": "5.3.0",+ "digest": "sha256:58b67399101d6fbfbd1a73c0c06c5de29e24889a1592d922f5afd1f6e550e15d"+ },+ {+ "name": "@fontsource-variable/nunito-sans",+ "version": "5.3.0",+ "digest": "sha256:491045f06b188718c4945f753678c851b0a16348e087e62ec6bd9d91a7f29f07"+ },+ {+ "name": "@fontsource-variable/onest",+ "version": "5.3.0",+ "digest": "sha256:dc69d3aba9dca697a3704954a2c9ed6ad2dde3a508f9cff3cfabf06fed2e7518"+ },+ {+ "name": "@fontsource-variable/open-sans",+ "version": "5.3.0",+ "digest": "sha256:bfa7bb83169eaf59da9c2492b9f87adaf4b07a8a2c5580ae235801842ad74b84"+ },+ {+ "name": "@fontsource-variable/oswald",+ "version": "5.3.0",+ "digest": "sha256:25e3819b4bfdd9fc8786d8d4cbc4bcc5121ad617180ab4e38e33573678a64b28"+ },+ {+ "name": "@fontsource-variable/outfit",+ "version": "5.3.0",+ "digest": "sha256:7da0bec12f2f4cc25652bd2bdfdb8686982121bf96f5182e45df5e7a67e3d134"+ },+ {+ "name": "@fontsource-variable/playfair-display",+ "version": "5.3.0",+ "digest": "sha256:9169e0b0212478bec819d29137e25a5e6770cb59508678a2b3d642706c099551"+ },+ {+ "name": "@fontsource-variable/playpen-sans",+ "version": "5.3.0",+ "digest": "sha256:0cdc396f3617afb4d405378726f48b9ef1dab85e3d1c9c4658450a09cb4335a3"+ },+ {+ "name": "@fontsource-variable/plus-jakarta-sans",+ "version": "5.3.0",+ "digest": "sha256:0d3387379914e9c6e57e67a1ccef7a943b372da8ec46de6956a5fd214e3b2609"+ },+ {+ "name": "@fontsource-variable/quicksand",+ "version": "5.3.0",+ "digest": "sha256:8443330eed78c79d91c3582df8b93d22bd82cd7bc4b7c9ae5c3c0f1499a6cac1"+ },+ {+ "name": "@fontsource-variable/raleway",+ "version": "5.3.0",+ "digest": "sha256:ac1f6114679c0177df758499b8d34def94f5b579a939bf2bb3456023ac2be6dc"+ },+ {+ "name": "@fontsource-variable/rethink-sans",+ "version": "5.3.0",+ "digest": "sha256:90242c18b19a9737e80a66ae6922a9c5bd5250a8972981ac1c09e4f8f8aee372"+ },+ {+ "name": "@fontsource-variable/roboto-condensed",+ "version": "5.3.0",+ "digest": "sha256:2b77bf05ddb63c0ebc2827d267235ee6b2851e0371c559f7a93eaf599d329b54"+ },+ {+ "name": "@fontsource-variable/roboto-mono",+ "version": "5.3.0",+ "digest": "sha256:a83a97b73d190630c8d4801333a73e2c265e0ad2480bc77056ad6a5db1672aae"+ },+ {+ "name": "@fontsource-variable/roboto-slab",+ "version": "5.3.0",+ "digest": "sha256:b6d68b8e9932671733d77695b50c09a23e804e952b7ab8da1a05f06ac827cfef"+ },+ {+ "name": "@fontsource-variable/roboto",+ "version": "5.3.0",+ "digest": "sha256:22fd32070d7eb714439e18dfd00da736b833a4ea4f661c8a3b1761ffe8895b30"+ },+ {+ "name": "@fontsource-variable/rubik",+ "version": "5.3.0",+ "digest": "sha256:b66dbc0f67e2c1e9b075f6ee5ed7eff18a3f7398bfdbc3c463962d1bb5064487"+ },+ {+ "name": "@fontsource-variable/shantell-sans",+ "version": "5.3.0",+ "digest": "sha256:18dcfa8618a3ff5bd420e46bac5fcdbc659242f3c0a67f45fc3ef598a9709fae"+ },+ {+ "name": "@fontsource-variable/sora",+ "version": "5.3.0",+ "digest": "sha256:bd5ff142c0797c37b763ae0a97bd1e9469ae163d084887a4660c73d2cf019693"+ },+ {+ "name": "@fontsource-variable/source-serif-4",+ "version": "5.3.0",+ "digest": "sha256:9833b70d7a2c410496ec00794b3c26034593353ac76fe173f3a6df2e958f6167"+ },+ {+ "name": "@fontsource-variable/space-grotesk",+ "version": "5.3.0",+ "digest": "sha256:9a601acdf9e2b9656f537f6691b40152dbc0c9043b249eeda4980281bcced5e5"+ },+ {+ "name": "@fontsource-variable/unbounded",+ "version": "5.3.0",+ "digest": "sha256:f664f5bbef08608533b00016c00a89b623df987b10a89d4832251b2440370c16"+ },+ {+ "name": "@fontsource-variable/urbanist",+ "version": "5.3.0",+ "digest": "sha256:06b9993e23960a5295ad059f44632e0f37ef3157f69ee06fae315fc47765c289"+ },+ {+ "name": "@fontsource-variable/vollkorn",+ "version": "5.3.0",+ "digest": "sha256:a177bb9b23a8c92311a189943fc8f0fb818b68909a792d82e5dd962795c4e663"+ },+ {+ "name": "@fontsource-variable/work-sans",+ "version": "5.3.0",+ "digest": "sha256:e14b9500f229c1fb1500e6c2c5e816601b95a008ac82a05b7d9fd1abc0421efb"+ },+ {+ "name": "@fontsource/abril-fatface",+ "version": "5.3.0",+ "digest": "sha256:5450fc572771171fa509f606b94038bb34722e3baf643d4f892f51d8fb83bca7"+ },+ {+ "name": "@fontsource/alfa-slab-one",+ "version": "5.3.0",+ "digest": "sha256:f3c3900506c54a7a6e15d1edf4181e10638e7d4aa4686db8114a5ff9287138cc"+ },+ {+ "name": "@fontsource/anton",+ "version": "5.3.0",+ "digest": "sha256:8327a2b26073d4deb0ec66643312e1abd4593ea07631a0e1a414e28743513947"+ },+ {+ "name": "@fontsource/architects-daughter",+ "version": "5.3.0",+ "digest": "sha256:8f944b7f148e1f5c6dcdc8108d6e29a99c23423568ee717bd47fc327a0456d3d"+ },+ {+ "name": "@fontsource/archivo-black",+ "version": "5.3.0",+ "digest": "sha256:abef23f9387cc85892ca65e550546ad47a9cd865a965b80b4c954eb48c14d430"+ },+ {+ "name": "@fontsource/bangers",+ "version": "5.3.0",+ "digest": "sha256:93cc064d70ee9bb054fcab65756111ad2adec1a2563b298ad0e0b423a1bbf8a5"+ },+ {+ "name": "@fontsource/barlow-condensed",+ "version": "5.3.0",+ "digest": "sha256:2bd19ad50f89e4e3697aa36fe7a18780b88d1bf4197a8112d709886bb7f52e47"+ },+ {+ "name": "@fontsource/barlow",+ "version": "5.3.0",+ "digest": "sha256:78fe6d1de271b8a49ebdcc588c7d3b91e46ed8f645d1747b360426c7f3b95a55"+ },+ {+ "name": "@fontsource/bebas-neue",+ "version": "5.3.0",+ "digest": "sha256:19e030c987fb0a607c7c5b7cc49e215319547b4a5bdbad23a847dd72559c0be9"+ },+ {+ "name": "@fontsource/black-ops-one",+ "version": "5.3.0",+ "digest": "sha256:a886f9fa9d0125a8f58a41134c5a68cbfa1d9a9ecac554e28d6749dd3c001d6f"+ },+ {+ "name": "@fontsource/bungee",+ "version": "5.3.0",+ "digest": "sha256:2f6397365b231b67179119ac7c639dd8898753b589549599630e3ad875f6ef10"+ },+ {+ "name": "@fontsource/coming-soon",+ "version": "5.3.0",+ "digest": "sha256:962fff0e0ca29eb40abcade296c2338ad1f4bf17fec694b887e8b0fecd9027f0"+ },+ {+ "name": "@fontsource/dm-serif-display",+ "version": "5.3.0",+ "digest": "sha256:7baa767191a29dcc38c3c1e3d88b18c2aedcda780f0ee96ad371d85121c37105"+ },+ {+ "name": "@fontsource/fira-sans-condensed",+ "version": "5.3.0",+ "digest": "sha256:467d333d5891df9e2648a9d56448d5964c62da005ecb52314ddda3d5ade900f0"+ },+ {+ "name": "@fontsource/gloock",+ "version": "5.3.0",+ "digest": "sha256:3f83f5e92b102434e658b8819a52c5a4684c840788d4a51e57973076e15951be"+ },+ {+ "name": "@fontsource/handlee",+ "version": "5.3.0",+ "digest": "sha256:95e1df2590271e9161503f9de5ec9be5b04a4760638fd508c0d8373105d80963"+ },+ {+ "name": "@fontsource/ibm-plex-mono",+ "version": "5.3.0",+ "digest": "sha256:ce4e3dc94b06c85c8a46a6abd9d80e9dc6550731efdd57fefb1fd352c9271313"+ },+ {+ "name": "@fontsource/instrument-serif",+ "version": "5.3.0",+ "digest": "sha256:788b83afa32264554f58562af494b587f7c955f54c172a3e6b655ec7e5cdbf20"+ },+ {+ "name": "@fontsource/kalam",+ "version": "5.3.0",+ "digest": "sha256:8b628b2523d1f66bfa793f674a5a11b2469b2fe175b48fb5154a34dd50ac58d2"+ },+ {+ "name": "@fontsource/kanit",+ "version": "5.3.0",+ "digest": "sha256:44b66731e8b69804fa498661337bcd20012ed4f15a85a27376dea9175f9a4d2d"+ },+ {+ "name": "@fontsource/lato",+ "version": "5.3.0",+ "digest": "sha256:7b9301126b2841096a8c3c2019c8ff0bc6d3f0cec82666dcc817cc9ae171ca5f"+ },+ {+ "name": "@fontsource/lilita-one",+ "version": "5.3.0",+ "digest": "sha256:b068bbb59d6eefcbc234c2c86751f69cf612ceb342c89929999d2d8964d02f8d"+ },+ {+ "name": "@fontsource/liu-jian-mao-cao",+ "version": "5.3.0",+ "digest": "sha256:f9057013c9fd6c031d093311429c8a05b5d633738edfb5be7d597c6f7ec6b638"+ },+ {+ "name": "@fontsource/long-cang",+ "version": "5.3.0",+ "digest": "sha256:9afe14768b363325209e3c150cf80fc516c80c9241fd369949991bb895f96af0"+ },+ {+ "name": "@fontsource/luckiest-guy",+ "version": "5.3.0",+ "digest": "sha256:6ee2cb66ca3a5d27517685e14e68ff2ea3810a2b8bf68927890312ed7796701d"+ },+ {+ "name": "@fontsource/ma-shan-zheng",+ "version": "5.3.0",+ "digest": "sha256:a02ffc7b1d3c7a419280d698475267a50c6c17065a189197a150afaa2d780651"+ },+ {+ "name": "@fontsource/pacifico",+ "version": "5.3.0",+ "digest": "sha256:4f73e816d6d4873df136642f5dccec552b9b86eb1d893aa0831ffa1dc3d7ebf5"+ },+ {+ "name": "@fontsource/patrick-hand",+ "version": "5.3.0",+ "digest": "sha256:3b90fe2b3da647db3b16b85272baa7260043a242e0308428151d2ad9c6c3f985"+ },+ {+ "name": "@fontsource/permanent-marker",+ "version": "5.3.0",+ "digest": "sha256:e0a02a5f2bf71402f6031b495315dbc8f908ffe45f62dcf2c25aeab9e3445e9d"+ },+ {+ "name": "@fontsource/pinyon-script",+ "version": "5.3.0",+ "digest": "sha256:6a04c8fb82f82c7c778bd9bc4c4de80c9883693dda54b8bd5177f44974c1094e"+ },+ {+ "name": "@fontsource/poppins",+ "version": "5.3.0",+ "digest": "sha256:a6062360c1fb29ca3ea309989341b960051a6dbec3618c30c458c642bf7dad32"+ },+ {+ "name": "@fontsource/righteous",+ "version": "5.3.0",+ "digest": "sha256:79e84f71bdeec58c7a8f9f27713b9ce0bc69c03172deb27303efd39587fb2980"+ },+ {+ "name": "@fontsource/satisfy",+ "version": "5.3.0",+ "digest": "sha256:c7dffc71d3f7cacd478896455d11633b6529ea3b6b90b3a8ea33a3baeaf1e766"+ },+ {+ "name": "@fontsource/shadows-into-light",+ "version": "5.3.0",+ "digest": "sha256:d2ada94bd5e183d93b51e7e971711f6a85f3a0f4469e138f0af7362ee2fc17b6"+ },+ {+ "name": "@fontsource/short-stack",+ "version": "5.3.0",+ "digest": "sha256:f3f57149b79b7aa692199846414def30dd13ff6ed8f837d1731be8d261233e10"+ },+ {+ "name": "@fontsource/space-mono",+ "version": "5.3.0",+ "digest": "sha256:3d45b28d3e4c26cd7aac85d6df23808117dfdde126926394e63f6aa9ae1f355d"+ },+ {+ "name": "@fontsource/zcool-kuaile",+ "version": "5.3.0",+ "digest": "sha256:92769d2814bb9186e26e388dc0656a8a0e2e883829646352024c0aec41dbbbbd"+ },+ {+ "name": "@fontsource/zcool-qingke-huangyou",+ "version": "5.3.0",+ "digest": "sha256:15854638d77023d0e32383f53f490e060cd8e0f8cf4994b2c99fe8522bf74e43"+ },+ {+ "name": "@fontsource/zcool-xiaowei",+ "version": "5.3.0",+ "digest": "sha256:79a87ecebfb75fc4fc01b36db09fe67d2080c090b73e145dc605dd2375974284"+ },+ {+ "name": "@infolektuell/noto-color-emoji",+ "version": "0.2.0",+ "digest": "sha256:1cb876e4d1fbd09da62f17c1599935b132427288052b2ab3afa8a8458329a720"+ },+ {+ "name": "@narratage/artifact",+ "version": "0.0.0-dev",+ "digest": "sha256:e1839b39b3ec1bc560ad7d0876e72cef09903f40ba3e0669b355f54a39d2fc82"+ },+ {+ "name": "@narratage/caption-fine",+ "version": "0.0.0-dev",+ "digest": "sha256:cb8fdd4207865c201e83e6a843a85322b73b96cc7a2c40130d439bbc960daed6"+ },+ {+ "name": "@narratage/caption-gemini",+ "version": "0.0.0-dev",+ "digest": "sha256:2411d92a3eec5dac75ef53d9a9715f88d6cec8241e6b752c802537c18e91bf3a"+ },+ {+ "name": "@narratage/caption",+ "version": "0.0.0-dev",+ "digest": "sha256:c43dcd0defd89f3079c81075859a7c63179a58911f9fb43c78e499bf8c9073e8"+ },+ {+ "name": "@narratage/component-kit",+ "version": "0.0.0-dev",+ "digest": "sha256:0a42292eed0b924b9f2bc4d22187818bb7136ea8f5f122f97962a27f10a30dd1"+ },+ {+ "name": "@narratage/composition",+ "version": "0.0.0-dev",+ "digest": "sha256:af8c81e17a6c90b292c37ac3577a43263dab7cfbe30d0a84a4d507d68ffc4d9e"+ },+ {+ "name": "@narratage/core",+ "version": "0.0.0-dev",+ "digest": "sha256:9ade54b00fd6728287f036aaa1ae38f3f7c756be9e2e1015b74c29ee3339c95b"+ },+ {+ "name": "@narratage/elaborator",+ "version": "0.0.0-dev",+ "digest": "sha256:7f2d21ae5e0c8c113e82dcc7169aa7f20b2062ffb79a0db86861c8ab069cb219"+ },+ {+ "name": "@narratage/film",+ "version": "0.0.0-dev",+ "digest": "sha256:40d71029ce8d1fceeb5f6cc03dddebb1e0179f692a855647750150cf1efd8aa3"+ },+ {+ "name": "@narratage/fonts-open",+ "version": "0.0.0-dev",+ "digest": "sha256:e145b8fe1ab5dca02f91b60d4ec3301c9a8022f5bf46ffe47a2284cdb3dcc0d0"+ },+ {+ "name": "@narratage/generation",+ "version": "0.0.0-dev",+ "digest": "sha256:fa629ce58731fb544aec83f10348352af019a5c8f441699e1b0035ec489dac6e"+ },+ {+ "name": "@narratage/gpt-image",+ "version": "0.0.0-dev",+ "digest": "sha256:3d122d467dffbfa5172a87d11b04a3765b5bee83ac8c992c4675575db098ff0c"+ },+ {+ "name": "@narratage/host",+ "version": "0.0.0-dev",+ "digest": "sha256:4fb020ec30c6024e74994eae5492fb98c75eb2e055a4a289a16afa26d84fcb4e"+ },+ {+ "name": "@narratage/hyperframes",+ "version": "0.0.0-dev",+ "digest": "sha256:9a736f281f46eeb4a1998ae9438b0869722f00cdef9b53e219d94ac04497231d"+ },+ {+ "name": "@narratage/image-transform",+ "version": "0.0.0-dev",+ "digest": "sha256:7d3a79c10d987e1199e745d95367d43ef57daaf2d571ec25f2cb13e54a52da3e"+ },+ {+ "name": "@narratage/markup",+ "version": "0.0.0-dev",+ "digest": "sha256:3d54f0d3a0947f628d406628ec78f441b8cb5da633ebc4a7fbb5ef176d68924b"+ },+ {+ "name": "@narratage/media-pipeline",+ "version": "0.0.0-dev",+ "digest": "sha256:d30dfe6cf81b969e77678d870a34eb13ae48d8e486bfa5b300b452e79cc3d83e"+ },+ {+ "name": "@narratage/media-track",+ "version": "0.0.0-dev",+ "digest": "sha256:49af374a0b3d235c6e0f675d16c80ae5bf4bcdb8b9fc125f910391b4362dbede"+ },+ {+ "name": "@narratage/media",+ "version": "0.0.0-dev",+ "digest": "sha256:3517862f3a4d8fcb5225b00a2295264feff9baed0f08b49e5894bb9f8a6100a1"+ },+ {+ "name": "@narratage/model-kit",+ "version": "0.0.0-dev",+ "digest": "sha256:ccc8c4bee06bea96d57400fc348a16b0c149e9acd5152ca331d2b0cfe85d1f15"+ },+ {+ "name": "@narratage/narrative",+ "version": "0.0.0-dev",+ "digest": "sha256:5823b08047e4d1b099675112b6a58243a563d4ea1bcdb592fdcb10e6e3ef73ab"+ },+ {+ "name": "@narratage/program-space",+ "version": "0.0.0-dev",+ "digest": "sha256:b0b6413c2dd0fbd2894250b5d79d927a92bae8a3fbe755a5f3f7b18424504e03"+ },+ {+ "name": "@narratage/protocol",+ "version": "0.0.0-dev",+ "digest": "sha256:8bec54ebf8fc9c8ac8ae8e24a3fce912267039d666183d16e7485c072923e462"+ },+ {+ "name": "@narratage/ranking",+ "version": "0.0.0-dev",+ "digest": "sha256:3733bdb9bcf5128f628cd43fee8e37436f16ac3e58ecb1201c086698c246643e"+ },+ {+ "name": "@narratage/raster",+ "version": "0.0.0-dev",+ "digest": "sha256:a731c1647651a6aedff8457dbd990b2860db23b59c1dd424d7b79f7630a9e19f"+ },+ {+ "name": "@narratage/render-hyperframes",+ "version": "0.0.0-dev",+ "digest": "sha256:6a436385accd1290988cf6e424e0b9b67b8c758045092281a41844284d135643"+ },+ {+ "name": "@narratage/run-markup",+ "version": "0.0.0-dev",+ "digest": "sha256:3ec93949ccc358327c63229f0bfd9ee3ebca487943dba544e70eb87a8a1d33ab"+ },+ {+ "name": "@narratage/run",+ "version": "0.0.0-dev",+ "digest": "sha256:eed752e2b89f5611a75e7c90e13c142059faf6e5155bce8140ae45dfb1e04e91"+ },+ {+ "name": "@narratage/screen-overlay",+ "version": "0.0.0-dev",+ "digest": "sha256:7719003476c2d45045265c5bc247a42052b9dabad60f3f2f097c8bf3182ae93b"+ },+ {+ "name": "@narratage/script",+ "version": "0.0.0-dev",+ "digest": "sha256:77ebf0d0b25d6e71a5abc40eb0b05517e713901231caf56fbd6d4064c84a5942"+ },+ {+ "name": "@narratage/seedance",+ "version": "0.0.0-dev",+ "digest": "sha256:5d44f162719a383284cbb62c860d9bbee7aa7af5c693f57c22f31a63f5d3e309"+ },+ {+ "name": "@narratage/semantic-map",+ "version": "0.0.0-dev",+ "digest": "sha256:cc3b158e95dae35f5c67dbc926f0c69389f0ccc0260425cd6491f5c927510657"+ },+ {+ "name": "@narratage/source",+ "version": "0.0.0-dev",+ "digest": "sha256:f35e680ec01059de899247b7ec5d550e0641a7b880d0bfd75d34b2c930947a7e"+ },+ {+ "name": "@narratage/spatial",+ "version": "0.0.0-dev",+ "digest": "sha256:13305323045486cf9526bf51951467427c93f63e53be0ed4504c542349fc4a21"+ },+ {+ "name": "@narratage/speech-alignment",+ "version": "0.0.0-dev",+ "digest": "sha256:70dabc2dfc7603791cd0291e7e507d29837ed4ab1cdf386a46bd1fc3661aadb3"+ },+ {+ "name": "@narratage/speech-basis",+ "version": "0.0.0-dev",+ "digest": "sha256:1b76c55aedf45de5cd9ec3fe4f523b97f08d600cf375ce0b7d65de41d857d934"+ },+ {+ "name": "@narratage/speech-evidence",+ "version": "0.0.0-dev",+ "digest": "sha256:8112726350bf8ccb13883f8268490b4119f4821097222517d5101c14ed46d6d5"+ },+ {+ "name": "@narratage/speech-spine",+ "version": "0.0.0-dev",+ "digest": "sha256:a3dc6eac1d4415bd169180dcfea631619c97c1d6e75eb4ba71bb5959cabfbe20"+ },+ {+ "name": "@narratage/speech",+ "version": "0.0.0-dev",+ "digest": "sha256:76b8c81a6a78ae392991a21eed847f5f0d1f6ba1f0a6fa41538c78ff96a2a2d2"+ },+ {+ "name": "@narratage/svs",+ "version": "0.0.0-dev",+ "digest": "sha256:7dce3e185ebf3d1f56b3e934fe79c804c6a67640468be65991cceeab25fd04a9"+ },+ {+ "name": "@narratage/temporal",+ "version": "0.0.0-dev",+ "digest": "sha256:5566cc222d97435a2072b626183b90f592fb20a09d72f207cd9222a413b4e172"+ },+ {+ "name": "@narratage/text",+ "version": "0.0.0-dev",+ "digest": "sha256:bb58dc8de88a8a70f7597e6f578a6b4d90d43e99638110d2b367a68992f234ae"+ },+ {+ "name": "@narratage/typography-track",+ "version": "0.0.0-dev",+ "digest": "sha256:09c00d85038e22b00ffa68f4393c9f6869471deb8524a210ce7cde424c40361f"+ },+ {+ "name": "@narratage/validation",+ "version": "0.0.0-dev",+ "digest": "sha256:0808de7090f09bab5e762833b8fa19b357908e72778394bd994d4db9b377fd32"+ },+ {+ "name": "@narratage/visual-ir",+ "version": "0.0.0-dev",+ "digest": "sha256:cd133df7e104188444ad34ad76f33d3674f5d12ba8aa5d942a8db145aba7415a"+ },+ {+ "name": "@narratage/whisperx",+ "version": "0.0.0-dev",+ "digest": "sha256:ed7b57ad0a47e7f788fd087918e06c20b8cb58a68e149b34fcfa9687fcf3f03a"+ }+ ],+ "packages": [+ {+ "specifier": "@narratage/artifact",+ "package": {+ "name": "@narratage/artifact",+ "version": "0.0.0-dev"+ },+ "provides": [],+ "facetsDigest": "sha256:72524ad8d5599450b4ab199680a6382c72c40cbf760f9c0265687f340aa60650",+ "closureDigest": "sha256:62a2d8a5788671adf06df7347da70df41d5cbfc9651f330bbb05f4f163f77846"+ },+ {+ "specifier": "@narratage/caption",+ "package": {+ "name": "@narratage/caption",+ "version": "0.0.0-dev"+ },+ "provides": [+ "@narratage/caption",+ "@narratage/caption@1"+ ],+ "facetsDigest": "sha256:1b7b07dfb828c3f95e321841a956e371c044dad8f39c117d92096e9be19b0032",+ "closureDigest": "sha256:563563ad6da139632b43318d170ce714e055014786a344d656f81c94f51d9ca9"+ },+ {+ "specifier": "@narratage/caption-fine",+ "package": {+ "name": "@narratage/caption-fine",+ "version": "0.0.0-dev"+ },+ "provides": [+ "@narratage/caption-fine",+ "@narratage/caption-fine@1"+ ],+ "facetsDigest": "sha256:cb9fb74a5edc730f01772e4819f7d7a55ecf914984d48116f72f64a1837cf128",+ "closureDigest": "sha256:adeba9eee745b343d1e058fe48a8e8d346d72a6c0ec4c7ca3878643a29aee75d"+ },+ {+ "specifier": "@narratage/caption-gemini",+ "package": {+ "name": "@narratage/caption-gemini",+ "version": "0.0.0-dev"+ },+ "provides": [+ "@narratage/caption-gemini",+ "@narratage/caption-gemini@1"+ ],+ "facetsDigest": "sha256:733cd8ac6415d69fffe460f77870787e7d3146fe11c937461bc9d849edc94106",+ "closureDigest": "sha256:41b6986b13c5c99906127e05e4f6e3cbc232a2133f5aa811472ee2450512a1c9"+ },+ {+ "specifier": "@narratage/composition",+ "package": {+ "name": "@narratage/composition",+ "version": "0.0.0-dev"+ },+ "provides": [],+ "facetsDigest": "sha256:b86fe5e147a331d36843aecbe7c64a4e83ad98b755242d8d1a1ba6c62551f509",+ "closureDigest": "sha256:ddfbaf79774806fa3cf79b85a7f8765ec77fa888a7c1b9e9d91b7424f7e5201b"+ },+ {+ "specifier": "@narratage/film",+ "package": {+ "name": "@narratage/film",+ "version": "0.0.0-dev"+ },+ "provides": [+ "@narratage/film",+ "@narratage/film@1"+ ],+ "facetsDigest": "sha256:8e6a1a585e853ef9b621feb918c15a2925da4ea1f05467e652d41f9202f10025",+ "closureDigest": "sha256:7870bcb9f57c04a05a75f1c99bc3e868051057a8eda6799ac63f2daf2af721d0"+ },+ {+ "specifier": "@narratage/fonts-open",+ "package": {+ "name": "@narratage/fonts-open",+ "version": "0.0.0-dev"+ },+ "provides": [+ "@narratage/fonts-open",+ "@narratage/fonts-open@1"+ ],+ "facetsDigest": "sha256:2117122b06d7c1cd6bee519e72aff22bc3b50f179b50da21dcc84ddf7014457f",+ "closureDigest": "sha256:4f4efe9e75e162bf26ac50cdade55ccac665cd3a208eeb8b011e482a3f20a617"+ },+ {+ "specifier": "@narratage/generation",+ "package": {+ "name": "@narratage/generation",+ "version": "0.0.0-dev"+ },+ "provides": [],+ "facetsDigest": "sha256:d74a57a3210267e665366513324db5c313b3ca0f770da66e74cc38aee5048efb",+ "closureDigest": "sha256:3638f93e6a983a5a44768eef160a6dbf49e80d065f890bc5bd14555ad023b7ec"+ },+ {+ "specifier": "@narratage/gpt-image",+ "package": {+ "name": "@narratage/gpt-image",+ "version": "0.0.0-dev"+ },+ "provides": [+ "@narratage/gpt-image",+ "@narratage/gpt-image/clean",+ "@narratage/gpt-image/clean@1",+ "@narratage/gpt-image@1"+ ],+ "facetsDigest": "sha256:a2b436f6f26fe95102c568ac5c668d6cca6c9a3050a1826577ac2be58be64490",+ "closureDigest": "sha256:68a04fa295eec178a0a0ba9c8260cf706c8605483e2324d8c2608dab81753a68"+ },+ {+ "specifier": "@narratage/hyperframes",+ "package": {+ "name": "@narratage/hyperframes",+ "version": "0.0.0-dev"+ },+ "provides": [],+ "facetsDigest": "sha256:4b2a86382c5d544fac8c194047f6e18ff554361d97d62e165533061b03b94ae9",+ "closureDigest": "sha256:3d288affb92c4b81527cb167947dd96a448b5091bf9c4c057e417be50a4b2623"+ },+ {+ "specifier": "@narratage/image-transform",+ "package": {+ "name": "@narratage/image-transform",+ "version": "0.0.0-dev"+ },+ "provides": [+ "@narratage/image-transform",+ "@narratage/image-transform@1"+ ],+ "facetsDigest": "sha256:68299f48d920b13f3fa0c71cca12edc7d541ad7703616d7b367269ad59de7d8f",+ "closureDigest": "sha256:de74370f17e53f475120befc85e4ccef6a1506fb4dc0d485237f7b9a4bb1e54e"+ },+ {+ "specifier": "@narratage/media",+ "package": {+ "name": "@narratage/media",+ "version": "0.0.0-dev"+ },+ "provides": [+ "@narratage/media",+ "@narratage/media@1"+ ],+ "facetsDigest": "sha256:f0974c7d88918ca4796dbb86dea24b6d29f8f5f44430c4845f9928f1df5b22e5",+ "closureDigest": "sha256:8ceaff731f4c0d5c4b88f708bdd75c5d6a4a00abe71607c6ddf0b8fe0da400c3"+ },+ {+ "specifier": "@narratage/media-pipeline",+ "package": {+ "name": "@narratage/media-pipeline",+ "version": "0.0.0-dev"+ },+ "provides": [+ "@narratage/media-pipeline",+ "@narratage/media-pipeline@1"+ ],+ "facetsDigest": "sha256:6df6afa9661002801d95b5075309a7cf31484d7ad300a5ab3f90119d34042224",+ "closureDigest": "sha256:020673ebf48c557a7c318b5cd1e97e096bf8e4681a459fa4fbd2b352fb6ff402"+ },+ {+ "specifier": "@narratage/media-track",+ "package": {+ "name": "@narratage/media-track",+ "version": "0.0.0-dev"+ },+ "provides": [+ "@narratage/media-track",+ "@narratage/media-track@1"+ ],+ "facetsDigest": "sha256:c7cea22dcf6e37c4359284d4c2bd2a146d752aa6bf65b944a9eaa13c895675be",+ "closureDigest": "sha256:49a71bacc460de88b692194fad37c63d39734c3423e3f624dd0178a8d836d5ca"+ },+ {+ "specifier": "@narratage/narrative",+ "package": {+ "name": "@narratage/narrative",+ "version": "0.0.0-dev"+ },+ "provides": [],+ "facetsDigest": "sha256:703db7ad343b00701dc39e3b316992dc371307f0c6c2ad15d1e0269257ffb326",+ "closureDigest": "sha256:c197675dfd711b5ac42fc0f084b1b7574de4f4061fda2fbabe69352faff1cd01"+ },+ {+ "specifier": "@narratage/program-space",+ "package": {+ "name": "@narratage/program-space",+ "version": "0.0.0-dev"+ },+ "provides": [],+ "facetsDigest": "sha256:b1e4eab41a135914556872f0f47a0c02b8ce76920366cbf86121b720af069052",+ "closureDigest": "sha256:d732dd805f1577ff3b7aaea5d05722d43bb03958095861a3eae7bf47d5f2504c"+ },+ {+ "specifier": "@narratage/ranking",+ "package": {+ "name": "@narratage/ranking",+ "version": "0.0.0-dev"+ },+ "provides": [+ "@narratage/ranking",+ "@narratage/ranking@1"+ ],+ "facetsDigest": "sha256:fde20e59477e833bf45f624f9ddc726e41220f9e086ed0f48a2acbdf0167a484",+ "closureDigest": "sha256:b81bb21c38bf5bce723ef478159e8f734217aeea473705ceb781b13a122ffb9b"+ },+ {+ "specifier": "@narratage/raster",+ "package": {+ "name": "@narratage/raster",+ "version": "0.0.0-dev"+ },+ "provides": [+ "@narratage/raster",+ "@narratage/raster@1"+ ],+ "facetsDigest": "sha256:0d0efefd9ac25e696ee7c3fc2b036887ee6ce3d8058e3676aff723d5390df159",+ "closureDigest": "sha256:9d4443d9a513f0eb0f267169cd5d71b275faafc38a2fd1bc3e1d432256c7dc66"+ },+ {+ "specifier": "@narratage/render-hyperframes",+ "package": {+ "name": "@narratage/render-hyperframes",+ "version": "0.0.0-dev"+ },+ "provides": [+ "@narratage/render-hyperframes",+ "@narratage/render-hyperframes@1"+ ],+ "facetsDigest": "sha256:2b5edae659a7d3e92e19ed591ca7d5f784f4a3b6164d33c0e201c9b180ef0323",+ "closureDigest": "sha256:53134fcfc4451213e40f207ed42f8b465b7090f617b835398cb06ec0b23db32d"+ },+ {+ "specifier": "@narratage/run-markup",+ "package": {+ "name": "@narratage/run-markup",+ "version": "0.0.0-dev"+ },+ "provides": [+ "@narratage/run-markup@1"+ ],+ "facetsDigest": "sha256:fb3a8a5be9a0ef0aa914026a199be641f4e20df27f9b284be196f52fd260be55",+ "closureDigest": "sha256:fbe76b58961bf0dba04cb91194c7756e0940e61b18a219510b90f97438f3dae2"+ },+ {+ "specifier": "@narratage/screen-overlay",+ "package": {+ "name": "@narratage/screen-overlay",+ "version": "0.0.0-dev"+ },+ "provides": [+ "@narratage/screen-overlay",+ "@narratage/screen-overlay@1"+ ],+ "facetsDigest": "sha256:25d4e8f5465e4092ad5de0722f14ad88f86d759b2ca8ddbb8adfd4f90c01b47a",+ "closureDigest": "sha256:3f7c40b80eab09b51a80af98256abda35e6a194db5f7352684974810f67e644d"+ },+ {+ "specifier": "@narratage/script",+ "package": {+ "name": "@narratage/script",+ "version": "0.0.0-dev"+ },+ "provides": [+ "@narratage/script",+ "@narratage/script@1"+ ],+ "facetsDigest": "sha256:69e1c08a5f07c73a506ca8286426a0386485738649e86463cca0b291f319ee4e",+ "closureDigest": "sha256:ee9962537eafe56bb339574fbb9bdba9c00dab39ce8c5b9da89aabdc41c64d22"+ },+ {+ "specifier": "@narratage/seedance",+ "package": {+ "name": "@narratage/seedance",+ "version": "0.0.0-dev"+ },+ "provides": [+ "@narratage/seedance",+ "@narratage/seedance@1"+ ],+ "facetsDigest": "sha256:df015abfb273de3629eec0da456a6fa90e7a55a5ed092d76a74c3d1dc4a5f705",+ "closureDigest": "sha256:51da9127b77edc1c46c7a9c88786c49df3c8d91eeec0bca236b8554ef16709b1"+ },+ {+ "specifier": "@narratage/semantic-map",+ "package": {+ "name": "@narratage/semantic-map",+ "version": "0.0.0-dev"+ },+ "provides": [],+ "facetsDigest": "sha256:510a57287945426449c8b2580d22a2d7f90ccaf1cb5bdd4fa5071b5b05ee91c0",+ "closureDigest": "sha256:8b6838a4057fcec08cbb74c66d405f8be9a93234ce20df5cdd94fd8d9a5ae914"+ },+ {+ "specifier": "@narratage/spatial",+ "package": {+ "name": "@narratage/spatial",+ "version": "0.0.0-dev"+ },+ "provides": [+ "@narratage/spatial",+ "@narratage/spatial@1"+ ],+ "facetsDigest": "sha256:5062281ffadb46495ec12e1a67185b57fe13879e90f03bcf544e93fd1d273716",+ "closureDigest": "sha256:73d113e95dd6cbd1feb6f45070e244850e6737fa5c09c23f68c5ecfb8a377d36"+ },+ {+ "specifier": "@narratage/speech",+ "package": {+ "name": "@narratage/speech",+ "version": "0.0.0-dev"+ },+ "provides": [],+ "facetsDigest": "sha256:6d1be76a2ee9486146436fde148c99eccdc055948a39c5098de2ff4122d80c7a",+ "closureDigest": "sha256:8d6d71bf808b4aeceed1f500f68ff648e19131940d3da0e0e0426e48c179e100"+ },+ {+ "specifier": "@narratage/speech-alignment",+ "package": {+ "name": "@narratage/speech-alignment",+ "version": "0.0.0-dev"+ },+ "provides": [],+ "facetsDigest": "sha256:78162875012523865df9c69770127a1db6ef9a8f5fc5af72255360af2a9c4370",+ "closureDigest": "sha256:c3dece181c80c8cfbf3186dd55a2654d6114765384188df4e6b6e21b1bf45c77"+ },+ {+ "specifier": "@narratage/speech-basis",+ "package": {+ "name": "@narratage/speech-basis",+ "version": "0.0.0-dev"+ },+ "provides": [],+ "facetsDigest": "sha256:97aaeabe85b3e4d6a8715ea9a41ac27ef71804ae99359b631546a4382bbac9df",+ "closureDigest": "sha256:0fea160882535c9746d56d1f668607aa9d1a46a40c60bbb2859f8b307145a0e4"+ },+ {+ "specifier": "@narratage/speech-evidence",+ "package": {+ "name": "@narratage/speech-evidence",+ "version": "0.0.0-dev"+ },+ "provides": [],+ "facetsDigest": "sha256:989d191644ea472a3cbd386bd4a6992f1f7f5ef82f1f8da53c9a4efa99d3d2d1",+ "closureDigest": "sha256:fed18a41121b44960b5a9cd2a6cd6f6954bc3016d7abbc7bf4b0a26798f28742"+ },+ {+ "specifier": "@narratage/speech-spine",+ "package": {+ "name": "@narratage/speech-spine",+ "version": "0.0.0-dev"+ },+ "provides": [+ "@narratage/speech-spine",+ "@narratage/speech-spine@1"+ ],+ "facetsDigest": "sha256:81a038765324b7a48ceb44c638faf128df31573a122989116d649dca3b3cb6d3",+ "closureDigest": "sha256:f6e6f346541422f115905fe77b967ae113dcff0e77905d1876f9353810e61234"+ },+ {+ "specifier": "@narratage/svs",+ "package": {+ "name": "@narratage/svs",+ "version": "0.0.0-dev"+ },+ "provides": [+ "@narratage/svs@1"+ ],+ "facetsDigest": "sha256:9cc7c397d2cd97b5a3e814886b6553b6d236fd8825df0d056e328b7f0cf20163",+ "closureDigest": "sha256:43a43083ff729f30cc31edf9ddf2b44722430bde9a9ad6e73cc0ae1114d5d522"+ },+ {+ "specifier": "@narratage/temporal",+ "package": {+ "name": "@narratage/temporal",+ "version": "0.0.0-dev"+ },+ "provides": [],+ "facetsDigest": "sha256:2e9c4804f142e08e87b2e11af79aa17770109fb573e865397bed14ed7a4f1d0e",+ "closureDigest": "sha256:23665c9c41bf398eeb83164f0541b48e6bb10c1e2c886c351ee72c9d42d2cddd"+ },+ {+ "specifier": "@narratage/text",+ "package": {+ "name": "@narratage/text",+ "version": "0.0.0-dev"+ },+ "provides": [+ "@narratage/text",+ "@narratage/text/svs@1",+ "@narratage/text@1"+ ],+ "facetsDigest": "sha256:4435dd4bd38e5e017013f775e28e379e3e235211649ee8f3913378f7f9e60b58",+ "closureDigest": "sha256:4e1ae6017ad16c4d27128f858b83ff04fabd33a03e6d015f010b543f154e7e1a"+ },+ {+ "specifier": "@narratage/typography-track",+ "package": {+ "name": "@narratage/typography-track",+ "version": "0.0.0-dev"+ },+ "provides": [+ "@narratage/typography-track",+ "@narratage/typography-track@1"+ ],+ "facetsDigest": "sha256:feacd6f8891a8792935a81fd0251f6c42c470067cf68bd4532e202c0a387e72d",+ "closureDigest": "sha256:360436ecefd6f299a0c22675db347a60bc48035fd8e3dec930b769959ecb8e5b"+ },+ {+ "specifier": "@narratage/visual-ir",+ "package": {+ "name": "@narratage/visual-ir",+ "version": "0.0.0-dev"+ },+ "provides": [],+ "facetsDigest": "sha256:8c577a635a48ee04441068df1f3dc2c18a602bff091fddca8883a3843ce4ce37",+ "closureDigest": "sha256:4606d4ea45276ed1a5a34ed109e545961ca3d72787a13bf85e976e20082528f0"+ },+ {+ "specifier": "@narratage/whisperx",+ "package": {+ "name": "@narratage/whisperx",+ "version": "0.0.0-dev"+ },+ "provides": [+ "@narratage/whisperx",+ "@narratage/whisperx@1"+ ],+ "facetsDigest": "sha256:ed9ebd9eea0b92c20357ec67dc14c4aa211836dc815c3edcb48e4946972f94c5",+ "closureDigest": "sha256:74176a63a7a62d4de6896a66f0e2883466defce32fed33dbe9d9688beccdff13"+ }+ ],+ "digest": "sha256:c1d53f47e68f34ee4ed145758d7c0d4628a31a79dc79b219c72a22130d0e9023"+}diff --git a/examples/all-components-preview/svml.runtime-packages.lock b/examples/all-components-preview/svml.runtime-packages.locknew file mode 100644index 00000000..c5c3b006--- /dev/null+++ b/examples/all-components-preview/svml.runtime-packages.lock@@ -0,0 +1,1014 @@+{+ "format": "svml.node-package-lock@1",+ "selected": [+ "@narratage/artifact-store-fs",+ "@narratage/credential-store-env",+ "@narratage/local",+ "@narratage/provider-google-vertex",+ "@narratage/provider-hyperframes-local",+ "@narratage/provider-kie",+ "@narratage/provider-media-local",+ "@narratage/provider-whisperx-local",+ "@narratage/store-sqlite"+ ],+ "artifacts": [+ {+ "name": "@esbuild/darwin-arm64",+ "version": "0.25.12",+ "digest": "sha256:f3ca2a2dd0e67a3e2beaf9d45626a7209a22ca5725e076d1e04008691655cd43"+ },+ {+ "name": "@google/genai",+ "version": "1.52.0",+ "digest": "sha256:39117de2d79f62402c4905b9b7ed58fa34c04c4d9e85c6272613437a0ff60f5c"+ },+ {+ "name": "@hono/node-server",+ "version": "2.0.12",+ "digest": "sha256:87923b51e3cbe9ca6b5d712bd97d5a1181a21d269f06cfca6931d827627986ba"+ },+ {+ "name": "@img/colour",+ "version": "1.1.0",+ "digest": "sha256:07db37307451577b10a7e1b851470ec9b290ae05459a1540102d91e553ad607b"+ },+ {+ "name": "@isaacs/fs-minipass",+ "version": "4.0.1",+ "digest": "sha256:774ff19c91750abdf4d4b8d715bc0e12246bdaf2239f3e7441b9cdd21f224d72"+ },+ {+ "name": "@narratage/artifact-store-fs",+ "version": "0.0.0-dev",+ "digest": "sha256:0014af9a67ac52b9b231f783ecdd5f4ac51e32a51117bf9ad117e52f9f654d4a"+ },+ {+ "name": "@narratage/artifact",+ "version": "0.0.0-dev",+ "digest": "sha256:e1839b39b3ec1bc560ad7d0876e72cef09903f40ba3e0669b355f54a39d2fc82"+ },+ {+ "name": "@narratage/background-removal",+ "version": "0.0.0-dev",+ "digest": "sha256:2d2d25c858b60b066f662ed3c8b1c9bc694894afed42ff9aa6c4ddce5ce5bb55"+ },+ {+ "name": "@narratage/caption-gemini",+ "version": "0.0.0-dev",+ "digest": "sha256:2411d92a3eec5dac75ef53d9a9715f88d6cec8241e6b752c802537c18e91bf3a"+ },+ {+ "name": "@narratage/caption",+ "version": "0.0.0-dev",+ "digest": "sha256:c43dcd0defd89f3079c81075859a7c63179a58911f9fb43c78e499bf8c9073e8"+ },+ {+ "name": "@narratage/compiler-node",+ "version": "0.0.0-dev",+ "digest": "sha256:f85b4b0cc1f28ab2d9caf4e472590e4effc53406f69ef344ac724395a22cb266"+ },+ {+ "name": "@narratage/component-kit",+ "version": "0.0.0-dev",+ "digest": "sha256:0a42292eed0b924b9f2bc4d22187818bb7136ea8f5f122f97962a27f10a30dd1"+ },+ {+ "name": "@narratage/composition",+ "version": "0.0.0-dev",+ "digest": "sha256:af8c81e17a6c90b292c37ac3577a43263dab7cfbe30d0a84a4d507d68ffc4d9e"+ },+ {+ "name": "@narratage/core",+ "version": "0.0.0-dev",+ "digest": "sha256:9ade54b00fd6728287f036aaa1ae38f3f7c756be9e2e1015b74c29ee3339c95b"+ },+ {+ "name": "@narratage/credential-store-env",+ "version": "0.0.0-dev",+ "digest": "sha256:98307815f89ca9ec4391c3baf9e5c00329faacd8e7430e0e4e151800229a6822"+ },+ {+ "name": "@narratage/driver-node",+ "version": "0.0.0-dev",+ "digest": "sha256:d185260bf475480fbc2197b0eccfb8139beab1b84a66c9b6d5c9642857240e5d"+ },+ {+ "name": "@narratage/elaborator",+ "version": "0.0.0-dev",+ "digest": "sha256:7f2d21ae5e0c8c113e82dcc7169aa7f20b2062ffb79a0db86861c8ab069cb219"+ },+ {+ "name": "@narratage/endpoint-kit",+ "version": "0.0.0-dev",+ "digest": "sha256:5a26c0d299503b81928e937ad9e1a5e0803ebaade53ca16d4b0cefaef5fabd54"+ },+ {+ "name": "@narratage/generation",+ "version": "0.0.0-dev",+ "digest": "sha256:fa629ce58731fb544aec83f10348352af019a5c8f441699e1b0035ec489dac6e"+ },+ {+ "name": "@narratage/host",+ "version": "0.0.0-dev",+ "digest": "sha256:4fb020ec30c6024e74994eae5492fb98c75eb2e055a4a289a16afa26d84fcb4e"+ },+ {+ "name": "@narratage/hyperframes",+ "version": "0.0.0-dev",+ "digest": "sha256:9a736f281f46eeb4a1998ae9438b0869722f00cdef9b53e219d94ac04497231d"+ },+ {+ "name": "@narratage/local",+ "version": "0.0.0-dev",+ "digest": "sha256:c7c87cc87778678a72e0323f220eacc0f33fe0a42d81fce9d5a9aaec9f1f08dd"+ },+ {+ "name": "@narratage/markup",+ "version": "0.0.0-dev",+ "digest": "sha256:3d54f0d3a0947f628d406628ec78f441b8cb5da633ebc4a7fbb5ef176d68924b"+ },+ {+ "name": "@narratage/media-execution",+ "version": "0.0.0-dev",+ "digest": "sha256:7ae1fb05418962f1403c99ecc02622f6b1e9f5fa2451c29177a5a1acfe6a6fe5"+ },+ {+ "name": "@narratage/media-pipeline",+ "version": "0.0.0-dev",+ "digest": "sha256:d30dfe6cf81b969e77678d870a34eb13ae48d8e486bfa5b300b452e79cc3d83e"+ },+ {+ "name": "@narratage/media",+ "version": "0.0.0-dev",+ "digest": "sha256:3517862f3a4d8fcb5225b00a2295264feff9baed0f08b49e5894bb9f8a6100a1"+ },+ {+ "name": "@narratage/narrative",+ "version": "0.0.0-dev",+ "digest": "sha256:5823b08047e4d1b099675112b6a58243a563d4ea1bcdb592fdcb10e6e3ef73ab"+ },+ {+ "name": "@narratage/package-loader-node",+ "version": "0.0.0-dev",+ "digest": "sha256:4ac8289e175f4a3e4fb2f40d4e2115404835fc640e8d4d971ed96a5d8b9bd72a"+ },+ {+ "name": "@narratage/program-space",+ "version": "0.0.0-dev",+ "digest": "sha256:b0b6413c2dd0fbd2894250b5d79d927a92bae8a3fbe755a5f3f7b18424504e03"+ },+ {+ "name": "@narratage/protocol",+ "version": "0.0.0-dev",+ "digest": "sha256:8bec54ebf8fc9c8ac8ae8e24a3fce912267039d666183d16e7485c072923e462"+ },+ {+ "name": "@narratage/provider-google-vertex",+ "version": "0.0.0-dev",+ "digest": "sha256:a59c5815ef5c2cf8fd24ba0b3413226dffcbd33ac8444cd65bd5719f4ba88e87"+ },+ {+ "name": "@narratage/provider-hyperframes-local",+ "version": "0.0.0-dev",+ "digest": "sha256:e8ecf79ffa7eb54a3fa801f6430d1c7b241db7f2a3f9fd15511bd05f0f2f7a94"+ },+ {+ "name": "@narratage/provider-kie",+ "version": "0.0.0-dev",+ "digest": "sha256:34a9598abc290d2b6b64ba352647b66b32146574a2365f1a6485b008018af064"+ },+ {+ "name": "@narratage/provider-media-local",+ "version": "0.0.0-dev",+ "digest": "sha256:660c667d2dbce0e0bb3385fa2766e1562c921dee3279aa4e3a76d67cd725f67f"+ },+ {+ "name": "@narratage/provider-whisperx-local",+ "version": "0.0.0-dev",+ "digest": "sha256:0a7e334a3c38fcf26307d5fb963826c0589f451c071765c7218997a58f10e914"+ },+ {+ "name": "@narratage/render-hyperframes",+ "version": "0.0.0-dev",+ "digest": "sha256:6a436385accd1290988cf6e424e0b9b67b8c758045092281a41844284d135643"+ },+ {+ "name": "@narratage/run",+ "version": "0.0.0-dev",+ "digest": "sha256:eed752e2b89f5611a75e7c90e13c142059faf6e5155bce8140ae45dfb1e04e91"+ },+ {+ "name": "@narratage/runtime-adapter-node",+ "version": "0.0.0-dev",+ "digest": "sha256:767e12f845be87f96b13fd8e147007a5adae1ebfe2e1192d94a15590b5542601"+ },+ {+ "name": "@narratage/runtime-adapter",+ "version": "0.0.0-dev",+ "digest": "sha256:4135319241131dcbda85c94c136bdaf2427007638d6577baa2f5c379589202c2"+ },+ {+ "name": "@narratage/runtime",+ "version": "0.0.0-dev",+ "digest": "sha256:ba12544fdca923e0b61139302e70411f0555276ae8c6735e29aa81681e9ac491"+ },+ {+ "name": "@narratage/semantic-map",+ "version": "0.0.0-dev",+ "digest": "sha256:cc3b158e95dae35f5c67dbc926f0c69389f0ccc0260425cd6491f5c927510657"+ },+ {+ "name": "@narratage/source",+ "version": "0.0.0-dev",+ "digest": "sha256:f35e680ec01059de899247b7ec5d550e0641a7b880d0bfd75d34b2c930947a7e"+ },+ {+ "name": "@narratage/spatial",+ "version": "0.0.0-dev",+ "digest": "sha256:13305323045486cf9526bf51951467427c93f63e53be0ed4504c542349fc4a21"+ },+ {+ "name": "@narratage/speech-alignment",+ "version": "0.0.0-dev",+ "digest": "sha256:70dabc2dfc7603791cd0291e7e507d29837ed4ab1cdf386a46bd1fc3661aadb3"+ },+ {+ "name": "@narratage/speech-evidence",+ "version": "0.0.0-dev",+ "digest": "sha256:8112726350bf8ccb13883f8268490b4119f4821097222517d5101c14ed46d6d5"+ },+ {+ "name": "@narratage/speech",+ "version": "0.0.0-dev",+ "digest": "sha256:76b8c81a6a78ae392991a21eed847f5f0d1f6ba1f0a6fa41538c78ff96a2a2d2"+ },+ {+ "name": "@narratage/store-sqlite",+ "version": "0.0.0-dev",+ "digest": "sha256:5c07e38f6b4fc747dfd43c63011d8644a050bb5f8537fd63c7f625bf8a9543ef"+ },+ {+ "name": "@narratage/svs",+ "version": "0.0.0-dev",+ "digest": "sha256:7dce3e185ebf3d1f56b3e934fe79c804c6a67640468be65991cceeab25fd04a9"+ },+ {+ "name": "@narratage/text",+ "version": "0.0.0-dev",+ "digest": "sha256:bb58dc8de88a8a70f7597e6f578a6b4d90d43e99638110d2b367a68992f234ae"+ },+ {+ "name": "@narratage/validation",+ "version": "0.0.0-dev",+ "digest": "sha256:0808de7090f09bab5e762833b8fa19b357908e72778394bd994d4db9b377fd32"+ },+ {+ "name": "@narratage/visual-ir",+ "version": "0.0.0-dev",+ "digest": "sha256:cd133df7e104188444ad34ad76f33d3674f5d12ba8aa5d942a8db145aba7415a"+ },+ {+ "name": "@narratage/whisperx",+ "version": "0.0.0-dev",+ "digest": "sha256:ed7b57ad0a47e7f788fd087918e06c20b8cb58a68e149b34fcfa9687fcf3f03a"+ },+ {+ "name": "@narratage/workspace-fs-node",+ "version": "0.0.0-dev",+ "digest": "sha256:078b83eec447cb0624057e9db3b37fc1ece5b6bca64b03c6ed1a8c9113f95ecd"+ },+ {+ "name": "@protobufjs/aspromise",+ "version": "1.1.2",+ "digest": "sha256:f2add582f001704c44380f69857f6d90976f8253b0d50aa78a3a18f07631f13b"+ },+ {+ "name": "@protobufjs/base64",+ "version": "1.1.2",+ "digest": "sha256:06b2c0c727a5c9245ca32469d0e5dd3476a1e16ba784de9a95e74378dad3be9f"+ },+ {+ "name": "@protobufjs/codegen",+ "version": "2.0.5",+ "digest": "sha256:1c2559930a27a866b83dcb32f945cb64c250d1b9a3d4846e10f9d67da7768fb1"+ },+ {+ "name": "@protobufjs/eventemitter",+ "version": "1.1.1",+ "digest": "sha256:c7ca7d4689ac40f5eaced3b446878c365640bab53923cfeeab0700393c78fa6d"+ },+ {+ "name": "@protobufjs/fetch",+ "version": "1.1.1",+ "digest": "sha256:4994a6ce027bf9c7cacf231612c9abf1c3bca106f1449981d2a950f4d5374fa5"+ },+ {+ "name": "@protobufjs/float",+ "version": "1.0.2",+ "digest": "sha256:6b39ca0e75f52ebbe0677dfc91289f771ed6ef764fe9b16b1089bba341df7e1b"+ },+ {+ "name": "@protobufjs/path",+ "version": "1.1.2",+ "digest": "sha256:f08474b157f229b416f4dfcd18af1394d6958099d2fb45f19196cace5ab8eb2a"+ },+ {+ "name": "@protobufjs/pool",+ "version": "1.1.0",+ "digest": "sha256:7fa58344bd7fd34f3d82ff681a2b9a1c1563f59bc525b04af18b83cc6862e351"+ },+ {+ "name": "@protobufjs/utf8",+ "version": "1.1.2",+ "digest": "sha256:a6e8be152be53993c5419c77351035d2f50c96548ea68a93ada5174872cab407"+ },+ {+ "name": "@puppeteer/browsers",+ "version": "3.1.0",+ "digest": "sha256:9c4a4b23834c62a8501f9cff553920437bc5241e5f2544d315784988b9b4d22c"+ },+ {+ "name": "@swc/helpers",+ "version": "0.5.23",+ "digest": "sha256:01e3a2aad97cb967224f124ee00312ed152a533f41c000975a3210efd6772315"+ },+ {+ "name": "@types/node",+ "version": "24.10.1",+ "digest": "sha256:8fa0086cef5b28049d3962a131ab7b458f6c6c123fd34439963f2b49c92e26aa"+ },+ {+ "name": "@types/retry",+ "version": "0.12.0",+ "digest": "sha256:3c0d455fdb883a9189bef24b8c28c20e38b1b81790627941fc52345f883776df"+ },+ {+ "name": "adm-zip",+ "version": "0.6.0",+ "digest": "sha256:b406b53cc1036ecd32ccd3a8f3be7910407e0206e47ac1f66e9024c37dedcdcb"+ },+ {+ "name": "agent-base",+ "version": "7.1.4",+ "digest": "sha256:87c907df716766b5486f32790957525a8d90af4ebec634205d4a2c22a767cae7"+ },+ {+ "name": "ansi-regex",+ "version": "6.2.2",+ "digest": "sha256:68e9c06b4a3650fed19bf0a3c20b215197209ddf856caa9a1a37b7f65de5a261"+ },+ {+ "name": "ansi-styles",+ "version": "6.2.3",+ "digest": "sha256:08da2e7a0903460c053d125d67ba55ac722d241ad858a09d3c6a0dfddf463e9e"+ },+ {+ "name": "base64-js",+ "version": "1.5.1",+ "digest": "sha256:21a8ff2186d871c92b2c8958df9d84ec967c2ecc26cb34a4632ee97856a7f3e1"+ },+ {+ "name": "bignumber.js",+ "version": "9.3.1",+ "digest": "sha256:c92307157c59bc4c56472278bb6ff718de1c31b56966927fa4eed154a3346e10"+ },+ {+ "name": "boolean",+ "version": "3.2.0",+ "digest": "sha256:9b07b070e89665a6ac71741ea8dd263a61b6bc3092f5c0236539cfe27c261ae5"+ },+ {+ "name": "brotli",+ "version": "1.3.3",+ "digest": "sha256:6e0c406465c179419228a0d4216e6224c40f37f60b19633e40c5b82a6bb3ba85"+ },+ {+ "name": "buffer-equal-constant-time",+ "version": "1.0.1",+ "digest": "sha256:8d532751643065156075c5b68d933386cde05759e773cccef4b77b2603f5d710"+ },+ {+ "name": "bundle-name",+ "version": "4.1.0",+ "digest": "sha256:56f299ebfb4532b990395d71ada619f840f8c53e8eef6308ce7bde7637c00e42"+ },+ {+ "name": "chownr",+ "version": "3.0.0",+ "digest": "sha256:480200db20b6b01b0187ae42d558bdf27e6f73c125c6c9563484bb588efdd52e"+ },+ {+ "name": "chromium-bidi",+ "version": "17.0.2",+ "digest": "sha256:7bce511709957dca1ea983de42c287aceebb65c0bfd6187487bcd30d52043275"+ },+ {+ "name": "citty",+ "version": "0.2.2",+ "digest": "sha256:2b96f0ef41541f40c6f3a67af0c3a743a56e2bf112d9243f52d492ac291b4fc6"+ },+ {+ "name": "cliui",+ "version": "9.0.1",+ "digest": "sha256:2f6fb31a6f05a074d8adde9542a46b71d956e278023349a21faaecfc1c6eb3f9"+ },+ {+ "name": "clone",+ "version": "2.1.2",+ "digest": "sha256:6b43f7ff5c6b3d978e723fc90dd0189436551098ec7138745f78b4a2f0b9f92a"+ },+ {+ "name": "compare-versions",+ "version": "6.1.1",+ "digest": "sha256:0ecd82fb4bbcae3fb65167f1df07c5a20edf3a48bac63ac2c184807bc56ecb2e"+ },+ {+ "name": "data-uri-to-buffer",+ "version": "4.0.1",+ "digest": "sha256:c83b4a18728c036e0a089e8d87706b7518784740ab58dc58ab7359d01cf3f1a4"+ },+ {+ "name": "debug",+ "version": "4.4.3",+ "digest": "sha256:304ed6a95b411a078e03c3916e660500aa9f9de06bf11cc06033ad54a707159a"+ },+ {+ "name": "default-browser-id",+ "version": "5.0.1",+ "digest": "sha256:b82fe817c2d5f1c050e5b584b1eb8ce0451a17cceebb89f44d99e92957e53cbd"+ },+ {+ "name": "default-browser",+ "version": "5.5.0",+ "digest": "sha256:170da580f2ba618cf36559651c369ce0e0b4c41c7faa4e147dfceefc22623c91"+ },+ {+ "name": "define-data-property",+ "version": "1.1.4",+ "digest": "sha256:fca69f48ebf1f761ed87558da2bf54e89279c2584fcde2dfe5251eeb1bbe49ba"+ },+ {+ "name": "define-lazy-prop",+ "version": "3.0.0",+ "digest": "sha256:d2ae304cf9cedf0e9884084f1b12c57ac626c35ed65591209bd1ed28e1c636cd"+ },+ {+ "name": "define-properties",+ "version": "1.2.1",+ "digest": "sha256:14a3c2884fe52795ff8d4989c42ac4eef50b03e43f092906e8bb9840f8c604ed"+ },+ {+ "name": "detect-libc",+ "version": "2.1.2",+ "digest": "sha256:f6d1cbe84b3768d0e4ec3a27f4935426f28d6db884b5154d316a3eb602b4f05a"+ },+ {+ "name": "detect-node",+ "version": "2.1.0",+ "digest": "sha256:e23f21cd23c3ac8eeb414fdd1cf07b444d5304d9e911489d093a54598eeec6f0"+ },+ {+ "name": "devtools-protocol",+ "version": "0.0.1653615",+ "digest": "sha256:0bc61b4492f895d3371a959e93936a707d30f0594ea1eb78924930392348c953"+ },+ {+ "name": "dfa",+ "version": "1.2.0",+ "digest": "sha256:f03697bc42cb361276cadcea1f3354f3192f359929d16589ff76cdfb772190da"+ },+ {+ "name": "ecdsa-sig-formatter",+ "version": "1.0.11",+ "digest": "sha256:c55a4220e735c26105c997912755884cf1f28e199c254bbd20522697c78b75c5"+ },+ {+ "name": "emoji-regex",+ "version": "10.6.0",+ "digest": "sha256:d4264fdc970ebe1e634439e4ccdf6b36bfb6e26ebad76ca797dcf18f58502433"+ },+ {+ "name": "es-define-property",+ "version": "1.0.1",+ "digest": "sha256:e65a28b769b86eb72a671971474f14d847c452b610cdedca2034ac4f487b41b1"+ },+ {+ "name": "es-errors",+ "version": "1.3.0",+ "digest": "sha256:15f3b370a55bf67732a9cf17b937e397921adeab248d83f24180d2e14d9b6bde"+ },+ {+ "name": "es6-error",+ "version": "4.1.1",+ "digest": "sha256:71b2330b85518b245ca6adefb1d77a696e750066d7229fd77ee51faea2a5d5a0"+ },+ {+ "name": "esbuild",+ "version": "0.25.12",+ "digest": "sha256:58ef98602a2a5a155d726d179960fe0db6963873d4ce384214c6356f99af465d"+ },+ {+ "name": "escalade",+ "version": "3.2.0",+ "digest": "sha256:3bb68ed8d0bf46965d493d7dc86d31eed3e8bcc82a07e20add860f51c106fd76"+ },+ {+ "name": "escape-string-regexp",+ "version": "4.0.0",+ "digest": "sha256:bf695cc4ec820bb7987a35f1af3d14f282a12a38594034836c2c292fc5050f98"+ },+ {+ "name": "extend",+ "version": "3.0.2",+ "digest": "sha256:c750753a00e753b94978ebf4a84d2bd75353fee1b88a8d85ac1e20ff6a1a365d"+ },+ {+ "name": "fast-deep-equal",+ "version": "3.1.3",+ "digest": "sha256:42ed3c3d2be15e877da479f9efe80816a085c7b3d57fe775d8e27e017546df5d"+ },+ {+ "name": "fetch-blob",+ "version": "3.2.0",+ "digest": "sha256:8a36c6aa8a9c8590e310d56fbf34b18f50687671554f7e812720acdfec8a7a0b"+ },+ {+ "name": "fontkit",+ "version": "2.0.4",+ "digest": "sha256:d2d7bf266cf637cbf1c1793701cdb859e99c16f12a3fb695d3f51341508c25d0"+ },+ {+ "name": "formdata-polyfill",+ "version": "4.0.10",+ "digest": "sha256:b9e931ab6b16d43c9381acd755f875752bff06fb508bdf07ff7ea0880b48d17a"+ },+ {+ "name": "gaxios",+ "version": "7.3.0",+ "digest": "sha256:2991703a4dafa9356326e924f7d66845f1f194662f5ef6a7ee6b8d7a29069cf5"+ },+ {+ "name": "gcp-metadata",+ "version": "8.1.2",+ "digest": "sha256:af943933cc72cc8a0a8cbd66933574b4c7820b1c938bf3ae870dc2d29daa69e9"+ },+ {+ "name": "get-caller-file",+ "version": "2.0.5",+ "digest": "sha256:9299b9f4312e40ce1abc93cf8508accfb7b9dfe0e2296e76861aee9832953f2b"+ },+ {+ "name": "get-east-asian-width",+ "version": "1.6.0",+ "digest": "sha256:80eb6329f500e01c525d107113329a5e19875dccee4a2dedd44bdb5d25928aeb"+ },+ {+ "name": "giget",+ "version": "3.3.1",+ "digest": "sha256:9095c8b2da2f8477877a1989dd7916da8bfb9a5545012d3da7a7bb50ff9eaa6c"+ },+ {+ "name": "global-agent",+ "version": "3.0.0",+ "digest": "sha256:138a78e1e7a5b8a3239361cbe4caf161c508f052b1b304cc6669470fb72816c2"+ },+ {+ "name": "globalthis",+ "version": "1.0.4",+ "digest": "sha256:df76d0da25ab8f020149cf066d2b62f82b65507c51a9c52cf6a3789e9a95ed8d"+ },+ {+ "name": "google-auth-library",+ "version": "10.9.1",+ "digest": "sha256:b7f30655126e71587c52c64baca556ce2ab5d3e2fbc2030f4f396acaa1b7afe0"+ },+ {+ "name": "google-logging-utils",+ "version": "1.1.3",+ "digest": "sha256:30c7f506015c8218718eceacd978339dfc50cee3a95cdbb04d5d7d677973f044"+ },+ {+ "name": "gopd",+ "version": "1.2.0",+ "digest": "sha256:463bf770beed8a51af109438a6555033de1bda940f5107edd84ace4e6ae3abb7"+ },+ {+ "name": "has-property-descriptors",+ "version": "1.0.2",+ "digest": "sha256:47f1621c5f96430ea46c12fa90c0b41c5e4648f3c5e3e8b6956ec6da91019d9c"+ },+ {+ "name": "hono",+ "version": "4.12.32",+ "digest": "sha256:ae1c33cc0a384ff91e495e9cc15265037386a0e80b23e0f29c27414a21bc1790"+ },+ {+ "name": "https-proxy-agent",+ "version": "7.0.6",+ "digest": "sha256:1013657bea7f02247aee642cbfdf6dca7a534d331b6eed367cf52c08b3c178ca"+ },+ {+ "name": "hyperframes",+ "version": "0.7.101",+ "digest": "sha256:24b78079c74422ce7aa3c3fd4ef79a2b40e2ea00127e7a8a7eb8be5d865e0853"+ },+ {+ "name": "ignore",+ "version": "5.3.2",+ "digest": "sha256:7ce8e139988a7b67710913ff265acfc7993aff1fba9b86bb984b3b999ef4d8b1"+ },+ {+ "name": "is-docker",+ "version": "3.0.0",+ "digest": "sha256:d43df9b09e7fd1e920406578921e339b79b4c6a523c25b3a0174b852caad2b41"+ },+ {+ "name": "is-inside-container",+ "version": "1.0.0",+ "digest": "sha256:7c224fc7e359fea06620a9f78c40826d544960685f9300451f58da95f6824aa1"+ },+ {+ "name": "is-wsl",+ "version": "3.1.1",+ "digest": "sha256:cd19b82a536ef031451c4e195351671f5c605cc1e2e6c435d38be0d439ebbc80"+ },+ {+ "name": "json-bigint",+ "version": "1.0.0",+ "digest": "sha256:78dbd36c1b196e087861980c4b198b2d2a4184856ab0cde2e9a2d8b640447b7a"+ },+ {+ "name": "json-stringify-safe",+ "version": "5.0.1",+ "digest": "sha256:cf420f3e9067d97fbd8718cce170ee811dcbe682296a80ea9c2a1b84fa49418d"+ },+ {+ "name": "jwa",+ "version": "2.0.1",+ "digest": "sha256:1ce4c87eefeff5866cc15c5358d465af06e4d1c762aa4d3bcca1dd77b085733d"+ },+ {+ "name": "jws",+ "version": "4.0.1",+ "digest": "sha256:9600a6d676cf870a248805ccc40bfda53e1194edf481e78fe7deab6c6f5ff123"+ },+ {+ "name": "long",+ "version": "5.3.2",+ "digest": "sha256:3d4d047be707c9fcd186c912864dcc9e0937a69dddf2f64b659d0a5e352d9c3e"+ },+ {+ "name": "matcher",+ "version": "3.0.0",+ "digest": "sha256:5bd2c657e8d48258b4eee6b85abfd6baeea1905880e1961b87e2f5d1b666f363"+ },+ {+ "name": "minipass",+ "version": "7.1.3",+ "digest": "sha256:b3c7c7268719f290572b07cc710c208f964e7e03cd5e4c87f6ee78931cb42d8e"+ },+ {+ "name": "minizlib",+ "version": "3.1.0",+ "digest": "sha256:ccd3f7ae56753854094bd4c874baf36ed0464f627c80c902402d7266c9b61339"+ },+ {+ "name": "mitt",+ "version": "3.0.1",+ "digest": "sha256:ce6aef694a3aa3a2aa0238ced1462fdd1e6365fa2ff5e49a175a9fad1f5c29a9"+ },+ {+ "name": "modern-tar",+ "version": "0.7.7",+ "digest": "sha256:891e12cd4440bfdcb4db46ba8e4a3a3f7a752ad42d26d3f4c5948762894a31b2"+ },+ {+ "name": "ms",+ "version": "2.1.3",+ "digest": "sha256:a141890e3a2dfb54d5bdd95b901821c311d9841e7f2ce2e3e5dbabee3af4e66d"+ },+ {+ "name": "nanoid",+ "version": "3.3.16",+ "digest": "sha256:ed57ac355bbd0cd97a4325bef9895b2d842a9b46ada0ba3a255a93c496872768"+ },+ {+ "name": "node-domexception",+ "version": "1.0.0",+ "digest": "sha256:8415ab26ce05a24c58531f511872cc884be27733e9879a9b14c0644f0f288ef3"+ },+ {+ "name": "node-fetch",+ "version": "3.3.2",+ "digest": "sha256:3cf962b70037de2f7ddc2d715b498cdec94400649ea3907c1a1f4c760e553b3e"+ },+ {+ "name": "object-keys",+ "version": "1.1.1",+ "digest": "sha256:e93bdcdfbfebe00ef728b53ec4d1ec41dfa3e7598520255106b84fe25c4600cf"+ },+ {+ "name": "onnxruntime-common",+ "version": "1.21.1",+ "digest": "sha256:8ecfbe59731de65bdff1f5b82652af349f93b66db55de3f49aa4b067e5b6a9ff"+ },+ {+ "name": "onnxruntime-node",+ "version": "1.21.1",+ "digest": "sha256:de224ff89b23f42422f15ba1d1a40a8624436a246f60ffa21dc5d6eb8bbe7bc9"+ },+ {+ "name": "open",+ "version": "10.2.0",+ "digest": "sha256:704838b6e442ca0c07b232e471e2d33e3f8c3907ff4dac65c34cc5452e690f80"+ },+ {+ "name": "p-retry",+ "version": "4.6.2",+ "digest": "sha256:ad26b9b16e3bcac0fd71295607fb400e5cccc3e9cebaef2477b187cc06820c40"+ },+ {+ "name": "pako",+ "version": "0.2.9",+ "digest": "sha256:bc932e8cd7a506f19b273d28312c01eca0eb29a8277b3341d52f72c8a3c6dc87"+ },+ {+ "name": "picocolors",+ "version": "1.1.1",+ "digest": "sha256:533a587e52703f20267c68cce3bb13d15f0d111e77641b4fc15dfd0909541da7"+ },+ {+ "name": "postcss",+ "version": "8.5.25",+ "digest": "sha256:86cae1a4a2f7db456622414bdc5fab2f2894a814431206dae3bd56b5da0c8da7"+ },+ {+ "name": "prettier",+ "version": "3.9.6",+ "digest": "sha256:ab64dd2b905d298318673b85f56619555497b4c4ca587e65cc87cbd0088be18f"+ },+ {+ "name": "protobufjs",+ "version": "7.6.5",+ "digest": "sha256:f261811e191755ef6c287354088d20f040f51f8106917669940f0efe90c51378"+ },+ {+ "name": "puppeteer-core",+ "version": "25.5.0",+ "digest": "sha256:c7081e270d302135c3febe5e13145104041d2ce60307b1fba3cba83d8a9ac5e7"+ },+ {+ "name": "restructure",+ "version": "3.0.2",+ "digest": "sha256:afe0b1af07f709de30108a7f34d1cbc24240d5af47058908b3ab948387411f47"+ },+ {+ "name": "retry",+ "version": "0.13.1",+ "digest": "sha256:20439b301564d3af33e4a4ae5a14fdb20546f77d4f467706301b444645d3a3f7"+ },+ {+ "name": "roarr",+ "version": "2.15.4",+ "digest": "sha256:95a31fad16046a827ad5f4aecede3eabca4590bebb7c558fb4319f692c382f2e"+ },+ {+ "name": "run-applescript",+ "version": "7.1.0",+ "digest": "sha256:7a1b536c998db95296d89b6adfcdde3849eae8ebb938a88343dd7880feb1010f"+ },+ {+ "name": "safe-buffer",+ "version": "5.2.1",+ "digest": "sha256:bf6c4b10b5ebca05c55cb32fc8da545f8200e8ac3e73233d9b8d30d3206b229e"+ },+ {+ "name": "semver-compare",+ "version": "1.0.0",+ "digest": "sha256:3b5950314b60d01814af7091f197e54621d66500d0c6b30f1622f12fd2fbe86c"+ },+ {+ "name": "semver",+ "version": "7.8.5",+ "digest": "sha256:782f8f680bcdbb9a8adad55a695c158f2c75a3ca1a7440d7174ba0164f666b1d"+ },+ {+ "name": "serialize-error",+ "version": "7.0.1",+ "digest": "sha256:16c05ffdf0930c58bdf64a77ff384fdfc90d41006e640cfb58a2dd2772931b4d"+ },+ {+ "name": "sharp",+ "version": "0.35.3",+ "digest": "sha256:d5a0288867e280eafbb69100ba8df01a02b6ee36a0106111d083f06e2e6093f2"+ },+ {+ "name": "source-map-js",+ "version": "1.2.1",+ "digest": "sha256:ebeb8811bac667d76a17286fb9e2398e970224d4caf437039330b6a7a1cbd6e8"+ },+ {+ "name": "sprintf-js",+ "version": "1.1.3",+ "digest": "sha256:c745235a5311cf6565a67449381ba71ab68fbb1f244180b547d4c7783b530d94"+ },+ {+ "name": "string-width",+ "version": "7.2.0",+ "digest": "sha256:6d33893de56cb9280537fad3eac2a768c279e403431764010cdfae3051f061fd"+ },+ {+ "name": "string-width",+ "version": "8.2.2",+ "digest": "sha256:ff4c8083cc6990b6514251a1430f6f5ea1fc5df49eb09085ece93ebea3a8a8bd"+ },+ {+ "name": "strip-ansi",+ "version": "7.2.0",+ "digest": "sha256:d93d07a9c18cd1a7c3b97b06ab2b67771b10ec1bd3e8a566d71042e8f75c5103"+ },+ {+ "name": "tar",+ "version": "7.5.22",+ "digest": "sha256:cd33e317cf398c1e65cde8099cb2f6ad40797b59bc950b5ae21cc174f263604a"+ },+ {+ "name": "tiny-inflate",+ "version": "1.0.3",+ "digest": "sha256:1bf162535f9aa8155774d4be09711f32730e6a5b5433706155e485b7b6ed8d46"+ },+ {+ "name": "tslib",+ "version": "2.8.1",+ "digest": "sha256:be0ff64197522f7466475b202e5642ac2fc7453bf77bd401e3c5af405fae5e08"+ },+ {+ "name": "type-fest",+ "version": "0.13.1",+ "digest": "sha256:7ecf27eb506bbdff58c42c4fa8ca5d7f9fe371d77503a41d8d0dd96070ff5ba9"+ },+ {+ "name": "typed-query-selector",+ "version": "2.12.2",+ "digest": "sha256:03010157f77e88b71831120e82c8d607d61c13d0dde047793fe2752e26bd9bab"+ },+ {+ "name": "undici-types",+ "version": "7.16.0",+ "digest": "sha256:56b851f33e38ba7913791a0d6cd2d862088b1efabe04fc599f961cf0611e12f5"+ },+ {+ "name": "unicode-properties",+ "version": "1.4.1",+ "digest": "sha256:f32f120a86229d5ddc6253bd8362ca9f3ec6665c55dcd4b12207db642a506524"+ },+ {+ "name": "unicode-trie",+ "version": "2.0.0",+ "digest": "sha256:32767668f5e23f4e9882cff32feae4b9dae6a9a5516ad4aeabf0fd01e856e6a5"+ },+ {+ "name": "web-streams-polyfill",+ "version": "3.3.3",+ "digest": "sha256:a9a0913d9acc78134f762f33c210311fada5ec4dcc0cb913bd237338f2fb8840"+ },+ {+ "name": "webdriver-bidi-protocol",+ "version": "0.4.2",+ "digest": "sha256:fe55ecd5a6990c02d57aa3149d4d4bcbd62cd27fcd69ee859739c91a0673f36c"+ },+ {+ "name": "wrap-ansi",+ "version": "9.0.2",+ "digest": "sha256:7db579468d39db77518c5f6951ac1b36330b5d81253e762ca171872aa9a6a3f3"+ },+ {+ "name": "ws",+ "version": "8.21.1",+ "digest": "sha256:e301f9237b858df0cc503d608fd5918640518c3378d8373d1f8a763e7977f838"+ },+ {+ "name": "wsl-utils",+ "version": "0.1.0",+ "digest": "sha256:5a8be00a56eb39f7923f42016f86f7ef3d15f36794d189ca9615d8b84ef8245f"+ },+ {+ "name": "y18n",+ "version": "5.0.8",+ "digest": "sha256:b60b70efd3b784a66f22536369d3c445582c3a76b6903615726c9743fff936e3"+ },+ {+ "name": "yallist",+ "version": "5.0.0",+ "digest": "sha256:d16e9bce9588bb0f5b3cf3a3d16e6628b0d234b58d6d85961a946fabf52ad4ee"+ },+ {+ "name": "yargs-parser",+ "version": "22.0.0",+ "digest": "sha256:4341e3a4b3ea190fc549c665549a24b30bb0ca67e8607cbf4e72eaa497d7b493"+ },+ {+ "name": "yargs",+ "version": "18.1.0",+ "digest": "sha256:c2f28503e8f01b19f87037b16b4bcd7145bad43dbe79bed7beab51c031cbc39d"+ },+ {+ "name": "zod",+ "version": "3.25.76",+ "digest": "sha256:6771243deb9b85f002496af9a1ffd198078b61794ef04e352fbe062c9cfa083a"+ }+ ],+ "packages": [+ {+ "specifier": "@narratage/artifact-store-fs",+ "package": {+ "name": "@narratage/artifact-store-fs",+ "version": "0.0.0-dev"+ },+ "provides": [],+ "facetsDigest": "sha256:914018276b9218afc13940ca5c362dc95fa19d574fc07b06b6fe005c5eb30315",+ "closureDigest": "sha256:d883017faf93520a745a27456cb5f81fce6dff9b0787214b2ba0a51028e9d948"+ },+ {+ "specifier": "@narratage/credential-store-env",+ "package": {+ "name": "@narratage/credential-store-env",+ "version": "0.0.0-dev"+ },+ "provides": [],+ "facetsDigest": "sha256:ee33ba638bbf2f88eee8f34a2f3179f435a0af9ccbae3fbb7d2a81bd6aeac612",+ "closureDigest": "sha256:d8c0a576a247ad8bdc3771c6bccc1c842fb086dc36700c6680c8656fec88b1f9"+ },+ {+ "specifier": "@narratage/local",+ "package": {+ "name": "@narratage/local",+ "version": "0.0.0-dev"+ },+ "provides": [],+ "facetsDigest": "sha256:6689aed79b0947c7315aef65e46806ce73da01de3d73b454e1497b8d847ffa61",+ "closureDigest": "sha256:302f4d817cead3171fc77e36084e3a16e427329c308e7d7c79fdb204f24ad830"+ },+ {+ "specifier": "@narratage/provider-google-vertex",+ "package": {+ "name": "@narratage/provider-google-vertex",+ "version": "0.0.0-dev"+ },+ "provides": [],+ "facetsDigest": "sha256:b2636492ab0b0b500d674899ab2ff14fc61c7f2b22ef44eb8f816f141b21ec4d",+ "closureDigest": "sha256:57fe88c1e75a3cab8ee1d771f948d285d6ea3edb8e88d6b89146adb5418e6f13"+ },+ {+ "specifier": "@narratage/provider-hyperframes-local",+ "package": {+ "name": "@narratage/provider-hyperframes-local",+ "version": "0.0.0-dev"+ },+ "provides": [],+ "facetsDigest": "sha256:b14b721bdc0c9d5d9ced1c345107c92a3a5878f3383dea2ecd3e310442c2a40c",+ "closureDigest": "sha256:fbf7d7f36af0545315f10f86af289d93ec3f1bb0e4c0269a18913a5a3d781df2"+ },+ {+ "specifier": "@narratage/provider-kie",+ "package": {+ "name": "@narratage/provider-kie",+ "version": "0.0.0-dev"+ },+ "provides": [],+ "facetsDigest": "sha256:e61ebb911a33d4c5d0e4e4ee4fb69cdb790f4ced050ef35f7472bfbd72013d9b",+ "closureDigest": "sha256:3d7389bce84a29a20d795a2ecd62078516e42963b456e34186dcb2df10631c0e"+ },+ {+ "specifier": "@narratage/provider-media-local",+ "package": {+ "name": "@narratage/provider-media-local",+ "version": "0.0.0-dev"+ },+ "provides": [],+ "facetsDigest": "sha256:701abcc923bf8a711c20b6e308d8cc8be27bf560f249b8c5a801e1dbd9cb3979",+ "closureDigest": "sha256:4e6c4b8d9049775087bea1e59464a80e7944b6452a034f5bf439cdb8b06250c5"+ },+ {+ "specifier": "@narratage/provider-whisperx-local",+ "package": {+ "name": "@narratage/provider-whisperx-local",+ "version": "0.0.0-dev"+ },+ "provides": [],+ "facetsDigest": "sha256:3686b84c42cc2b1bcaccf57cbdcda25a15c7d9d3778fb92d25437f9880ed8f5d",+ "closureDigest": "sha256:9aacef85c04d31f412a4d4cc8881879b949f8bba422dadacf72b2fcffd1ce1e0"+ },+ {+ "specifier": "@narratage/store-sqlite",+ "package": {+ "name": "@narratage/store-sqlite",+ "version": "0.0.0-dev"+ },+ "provides": [],+ "facetsDigest": "sha256:5bccf73cd953710fc31ef44672fef1bfc396fd4aa2eff4b53108e8ff87e749c3",+ "closureDigest": "sha256:01b21eab61e3f11067d7c25dbc0b1644e71d3c599d0bc64f37bb0ba7a7b9d10e"+ }+ ],+ "digest": "sha256:0c17fa76d24fccd468f8ae19e1f38475be7c8655997ad5e25aa025c6b43a2af7"+}diff --git a/examples/all-components-preview/svml.runtime.json b/examples/all-components-preview/svml.runtime.jsonnew file mode 100644index 00000000..afa7055d--- /dev/null+++ b/examples/all-components-preview/svml.runtime.json@@ -0,0 +1,99 @@+{+ "format": "svml.runtime-config@1",+ "packageLock": "./svml.packages.lock",+ "runtimePackageLock": "./svml.runtime-packages.lock",+ "runtimeServices": [+ {+ "use": "@narratage/local",+ "instance": "execution"+ },+ {+ "use": "@narratage/store-sqlite",+ "instance": "state",+ "config": {+ "path": ".svml/runtime.sqlite"+ }+ },+ {+ "use": "@narratage/artifact-store-fs",+ "instance": "artifacts",+ "config": {+ "path": ".svml/artifacts"+ }+ },+ {+ "use": "@narratage/credential-store-env",+ "instance": "credentials.env",+ "config": {}+ }+ ],+ "services": {+ "scheduler": "execution.scheduler",+ "worker": "execution.worker",+ "stores": {+ "build": "state.builds",+ "operations": "state.operations",+ "dispatch": "state.dispatch",+ "journal": "state.journal",+ "artifacts": "artifacts",+ "credentials": [+ "credentials.env"+ ]+ }+ },+ "endpoints": [+ {+ "use": "@narratage/provider-kie",+ "instance": "kie.all-components",+ "authority": "generation",+ "config": {+ "apiKey": {+ "store": "env",+ "key": "KIE_API_KEY"+ },+ "defaultConcurrency": 2+ }+ },+ {+ "use": "@narratage/provider-media-local",+ "instance": "media.all-components",+ "authority": "media",+ "config": {+ "defaultConcurrency": 2+ }+ },+ {+ "use": "@narratage/provider-whisperx-local",+ "instance": "whisperx.all-components",+ "authority": "alignment",+ "config": {+ "defaultConcurrency": 1+ }+ },+ {+ "use": "@narratage/provider-hyperframes-local",+ "instance": "hyperframes.all-components",+ "authority": "render",+ "config": {+ "defaultConcurrency": 1+ }+ },+ {+ "use": "@narratage/provider-google-vertex",+ "instance": "vertex.all-components",+ "authority": "planning",+ "config": {+ "projectEnv": "GOOGLE_CLOUD_PROJECT",+ "location": "global",+ "credentials": {+ "store": "env",+ "key": "GOOGLE_VERTEX_CREDENTIALS_JSON"+ },+ "defaultConcurrency": 1+ }+ }+ ],+ "scheduling": {+ "maxConcurrency": 4+ }+}diff --git a/examples/regen-ranking-preview/build.svrun b/examples/regen-ranking-preview/build.svrunnew file mode 100644index 00000000..7b8ef5bb--- /dev/null+++ b/examples/regen-ranking-preview/build.svrun@@ -0,0 +1,16 @@+<?svml using="@narratage/run-markup@1"?>++<svrun version="1">+ <author source="./main.svml"/>+ <target output="final.video"/>++ <!-- The three takes the documentation site ships for this piece, one per+ Segment. -->+ <file id="take-1" from="../../docs/public/regen-ranking/avatar-1.mp4" media-type="video/mp4"/>+ <file id="take-2" from="../../docs/public/regen-ranking/avatar-2.mp4" media-type="video/mp4"/>+ <file id="take-3" from="../../docs/public/regen-ranking/avatar-3.mp4" media-type="video/mp4"/>++ <satisfy output="take-intro.video" candidate="take-1"/>+ <satisfy output="take-middle.video" candidate="take-2"/>+ <satisfy output="take-payoff.video" candidate="take-3"/>+</svrun>diff --git a/examples/regen-ranking-preview/main.svml b/examples/regen-ranking-preview/main.svmlnew file mode 100644index 00000000..ee32a676--- /dev/null+++ b/examples/regen-ranking-preview/main.svml@@ -0,0 +1,153 @@+<?svml using="@narratage/markup@1"?>++<svml>+ <import from="@narratage/script@1"/>+ <import as="wording" from="@narratage/text@1"/>+ <import as="seedance" from="@narratage/seedance@1"/>+ <import as="media" from="@narratage/media@1"/>+ <import as="speech" from="@narratage/speech-spine@1"/>+ <import as="whisperx" from="@narratage/whisperx@1"/>+ <import as="media-track" from="@narratage/media-track@1"/>+ <import as="ranking" from="@narratage/ranking@1"/>+ <import as="caption" from="@narratage/caption@1"/>+ <import as="caption-fine" from="@narratage/caption-fine@1"/>+ <import as="caption-ai" from="@narratage/caption-gemini@1"/>+ <import as="fonts" from="@narratage/fonts-open@1"/>+ <import as="text" from="@narratage/typography-track@1"/>+ <import as="space" from="@narratage/spatial@1"/>+ <import as="film" from="@narratage/film@1"/>+ <import as="render" from="@narratage/render-hyperframes@1"/>+ <import as="studio" source="./studio.svs"/>++ <!-- The spoken words of the ranking demo. Each app is a Selection, so the+ board row it fills and the moment it settles are both derived from the+ Script rather than restated as timecodes. `@place!` fires once per app. -->+ <script id="story">+ <intro>+ <NARRATOR>@board @photoshop Photoshop. @place!+ <SPEAKER>Powerful, but only if you know how to use it. Otherwise, your new profile+ picture becomes a three-hour design project@/photoshop.+ <NARRATOR>@facetune Facetune. @place!+ <SPEAKER>Fast and great for touch-ups. But it still leaves you with the same awkward+ pose and the same dorm-room background@/facetune.+ </intro>+ <middle>+ <NARRATOR>@remini Remini. @place!+ <SPEAKER>Great for blurry photos. It restores detail, but it can't fix the pose,+ outfit, or background. You get the same bad photo in HD@/remini.+ <NARRATOR>@chatgpt ChatGPT. @place!+ <SPEAKER>More flexible. It can create a new shot, but getting your face and the+ details right becomes a prompt-writing group project@/chatgpt.+ </middle>+ <payoff>+ <NARRATOR>@regen ReGen. @place!+ <SPEAKER>Pick a photo you love, and the app @handsome-1 rebuilds it around you with+ a@/handsome-1~ @handsome-2 better pose, outfit, and setting.@/handsome-2 From one+ selfie, you can make @dating-photo a dating photo,@/dating-photo~+ @linkedin-headshot LinkedIn headshot,@/linkedin-headshot~+ @instagram-post or Instagram post,@/instagram-post @done! so you get what you+ wanted instead of fixing a bad shot@/regen.@/board+ </payoff>+ </script>++ <space:Canvas id="vertical" width="1080" height="1920"/>+ <space:Frame id="speech-frame" within={vertical}+ left="0%" top="0%" right="100%" bottom="100%"/>+ <!-- The board sits on the left third, as it does in the demo. -->+ <space:Frame id="board-frame" within={vertical}+ left="0%" top="16.98%" right="30.46%" bottom="58.65%"/>+ <space:Frame id="title-frame" within={vertical}+ left="0%" top="9.9%" right="100%" bottom="17.7%"/>+ <space:Frame id="broll-frame" within={vertical}+ left="0%" top="0%" right="100%" bottom="100%"/>++ <wording:Value id="direction">Vertical talking head, casual room, direct address to camera.</wording:Value>+ <seedance:TextVideo id="take-intro" model="mini" prompt={direction} duration="12" generate-audio="true"/>+ <seedance:TextVideo id="take-middle" model="mini" prompt={direction} duration="12" generate-audio="true"/>+ <seedance:TextVideo id="take-payoff" model="mini" prompt={direction} duration="12" generate-audio="true"/>++ <!-- The cutaways and the board's icons are pictures on disk, so they are+ named as files rather than as material a Provider has to make. The site+ numbers the cutaways in the order they leave, so broll-5 is shown first. -->+ <space:Extent id="portrait" width="540" height="960"/>+ <space:Extent id="square" width="192" height="192"/>+ <media:Image id="shot-handsome-1" src="../../docs/public/regen-ranking/broll-5.webp"/>+ <media:Image id="shot-handsome-2" src="../../docs/public/regen-ranking/broll-4.webp"/>+ <media:Image id="shot-dating" src="../../docs/public/regen-ranking/broll-3.webp"/>+ <media:Image id="shot-linkedin" src="../../docs/public/regen-ranking/broll-2.webp"/>+ <media:Image id="shot-instagram" src="../../docs/public/regen-ranking/broll-1.webp"/>+ <media:Image id="icon-regen" src="../../docs/public/regen-ranking/ranking-icon-1.webp"/>+ <media:Image id="icon-chatgpt" src="../../docs/public/regen-ranking/ranking-icon-2.webp"/>+ <media:Image id="icon-remini" src="../../docs/public/regen-ranking/ranking-icon-3.webp"/>+ <media:Image id="icon-facetune" src="../../docs/public/regen-ranking/ranking-icon-4.webp"/>+ <media:Image id="icon-photoshop" src="../../docs/public/regen-ranking/ranking-icon-5.webp"/>++ <speech:Spine id="speech" frame-rate="24"+ visual-frame={speech-frame} visual-appearance={studio.speech.visual} visual-z="0">+ <speech:Take video={take-intro.video} segment={story.segment.intro}/>+ <speech:Take video={take-middle.video} segment={story.segment.middle}/>+ <speech:Take video={take-payoff.video} segment={story.segment.payoff}/>+ </speech:Spine>+ <whisperx:Alignment id="timing" narrative={story} audio={speech.audio}/>++ <fonts:Stack id="ui-font" family="inter" weight="700" style="normal"/>+ <fonts:Stack id="title-font" family="archivo" weight="900" style="normal"/>++ <!-- The board. Rank order is the child order; each row settles on the next+ `@place!` and the whole board leaves on `@done!`. -->+ <ranking:ColumnStyle id="board-style" recipe={studio.ranking.board} font={ui-font}/>+ <ranking:Column id="board" map={timing.map} space={speech.space} frame={board-frame}+ during={story.selection.board} triggers={story.moment.place} terminal={story.moment.done}+ style={board-style}>+ <ranking:ColumnItem id="row-regen" label="ReGen" icon={icon-regen}/>+ <ranking:ColumnItem id="row-chatgpt" label="ChatGPT" icon={icon-chatgpt}/>+ <ranking:ColumnItem id="row-remini" label="Remini" icon={icon-remini}/>+ <ranking:ColumnItem id="row-facetune" label="Facetune" icon={icon-facetune}/>+ <ranking:ColumnItem id="row-photoshop" label="Photoshop" icon={icon-photoshop}/>+ </ranking:Column>++ <!-- Five stills cut in over the payoff, each on its own Selection. -->+ <media-track:Track id="shots" map={timing.map} space={speech.space} canvas={vertical}>+ <media-track:Item id="handsome-1" image={shot-handsome-1} extent={portrait}+ during={story.selection.handsome-1} frame={broll-frame}+ appearance={studio.media.shot} motion={studio.motion.cut}/>+ <media-track:Item id="handsome-2" image={shot-handsome-2} extent={portrait}+ during={story.selection.handsome-2} frame={broll-frame}+ appearance={studio.media.shot} motion={studio.motion.cut}/>+ <media-track:Item id="dating-photo" image={shot-dating} extent={portrait}+ during={story.selection.dating-photo} frame={broll-frame}+ appearance={studio.media.shot} motion={studio.motion.cut}/>+ <media-track:Item id="linkedin-headshot" image={shot-linkedin} extent={portrait}+ during={story.selection.linkedin-headshot} frame={broll-frame}+ appearance={studio.media.shot} motion={studio.motion.cut}/>+ <media-track:Item id="instagram-post" image={shot-instagram} extent={portrait}+ during={story.selection.instagram-post} frame={broll-frame}+ appearance={studio.media.shot} motion={studio.motion.cut}/>+ </media-track:Track>++ <text:Style id="title-style" recipe={studio.text.title} font={title-font}/>+ <text:Track id="titles" space={speech.space}>+ <text:Area id="headline" placement={title-frame} style={title-style} during="program">+ RANKING AI PHOTO APPS FOR GUYS WITH NO GOOD PICS+ </text:Area>+ </text:Track>++ <caption-fine:Style id="base-caption" recipe={studio.caption.base} font={ui-font}/>+ <caption:Program id="caption-program" display={story.caption} default={base-caption}/>+ <caption-ai:Planner id="cue-plan" display={story.caption} program={caption-program}+ model="gemini-2.5-flash"/>+ <caption-fine:Track id="captions" display={story.caption}+ correspondence={story.caption.correspondence}+ map={timing.map} space={speech.space}+ plan={cue-plan.plan} program={caption-program}/>++ <film:Film id="main" canvas={vertical} space={speech.space} appearance={studio.film.vertical}>+ <film:Track source={speech.visual}/>+ <film:Track source={speech.audioTrack}/>+ <film:Track source={board.visual}/>+ <film:Track source={titles.track}/>+ <film:Track source={captions.track}/>+ <film:Track source={shots.visual}/>+ </film:Film>+ <render:Video id="final" composition={main.composition} space={speech.space}/>+</svml>diff --git a/examples/regen-ranking-preview/studio.svs b/examples/regen-ranking-preview/studio.svsnew file mode 100644index 00000000..2c044205--- /dev/null+++ b/examples/regen-ranking-preview/studio.svs@@ -0,0 +1,46 @@+<?svml using="@narratage/svs@1"?>++<sheet version="1">+ film.vertical { background: #05060a; }+ speech.visual { fit: cover; }++ /* The board: a dark panel on the left third, one row per app, filling from the+ bottom rank upward as each name is spoken. */+ ranking.board {+ board-background: #070810EF;+ board-border-color: #FFFFFF2E; board-border-width: 1; board-radius: 6;+ board-shadow-x: 0; board-shadow-y: 6; board-shadow-blur: 18; board-shadow-spread: 0;+ board-shadow-color: #00000059;+ rank-colors: #ff3f56|#ffa72d|#eadc2a|#84c654|#31add0;+ padding: 18; row-height: 74; row-gap: 10;+ icon-size: 58; icon-radius: 13; icon-fit: contain;+ stage-x: 0.66; stage-y: 0.73; stage-size: 356;+ font-size: 34; font-weight: 900; text-color: #FFFFFF; line-height: 1.1;+ appear-frames: 11; move-frames: 13; motion-easing: ease-out;+ board-stack: 20; item-stack: 30; stage-stack: 25;+ }++ /* A cutaway replaces the shot, so it carries no box treatment. */+ media.shot { stack-order: 60; fit: contain; }+ motion.cut {+ enter: fade; enter-frames: 2; enter-easing: linear;+ exit: fade; exit-frames: 2; exit-easing: linear;+ }++ text.title {+ stack-order: 90;+ weight: 900; size: 62; align: center; fill: #FFFFFF; tracking: -1;+ padding: 14 22;+ }++ caption.base {+ cue-min-words: 1; cue-max-words: 3;+ stack-order: 70; x: 0.68; y: 0.56; width: 0.6; anchor-x: center; anchor-y: top;+ size: 50; line-height: 1.05; align: center;+ fill: #FFFFFF; stroke-color: #05060A; stroke-width: 2;+ shadow-color: #000000; shadow-opacity: 0.72; shadow-x: 0; shadow-y: 2; shadow-blur: 6;+ background: #00000000; border-color: #00000000; border-width: 0; padding: 0 0; radius: 0;+ karaoke: current; karaoke-transition: step; active-fill: #FFD34A;+ cue-enter: fade; cue-enter-frames: 2; cue-exit: fade; cue-exit-frames: 2;+ }+</sheet>diff --git a/examples/street-interview-preview/README.md b/examples/street-interview-preview/README.mdnew file mode 100644index 00000000..37f3f6f6--- /dev/null+++ b/examples/street-interview-preview/README.md@@ -0,0 +1,77 @@+# street-interview-preview++A four-scene street interview with three cutaways and captions, read by the+[SVML Playground](../../docs/guide/svml-playground.md) against **real footage and+real speech timings**.++```bash+pnpm svml:playground -- \+ --source examples/street-interview-preview/main.svml \+ --run examples/street-interview-preview/build.svrun+```++Both badges read `measured`. Nothing here has been built: the footage and the+transcript already exist, and the Run Source says so.++## Where the timings come from++`docs/public/street-interview/transcript.json` is a word-level transcript of the+recording, but a transcript is not a SemanticMap. A map is keyed by *this*+Script's own anchor identities, and pairing loose words with authored tokens is+the aligner's job. `align-transcript.ts` runs the real one — `locateSpeechTiming`+from `@narratage/speech-alignment` — and writes two values:++```bash+node --import tsx examples/street-interview-preview/align-transcript.ts+# Aligned 101 transcript words onto 102 Script tokens.+```++The Run Source then satisfies the two Outputs a timeline needs:++```xml+<value id="aligned-map" type="@narratage/semantic-map@1#CompleteSemanticMap" from="./timing.json"/>+<satisfy output="timing.map" candidate="aligned-map"/>+```++Which timings a Source is read with is an authoring decision, so it is made in+the Run Source rather than guessed by the tool. Drop the two `<satisfy>` lines+and the same Source falls back to the syllable estimate, which lands on 26.0s+against a programme that runs 31.3s — the badge changes to `timing: estimated`+and the cutaways move.++## Where the picture comes from++Each `<file>` candidate names footage the documentation site already ships, and+each `<satisfy>` binds it to the Output that Take or Item was authored against.+The footage is 24 fps, which is the frame rate this Source declares, so the+preview shows it as authored. Material of another frame rate is refused with a+reason rather than resampled — normalizing is a real transcode and belongs to+the media pipeline.++## What it demonstrates++**Three cutaways, one Track.** `@bags`, `@fee` and `@receipt` are disjoint+Selections, so all three share a single timeline row.++**Full-frame cutaways.** All three are shot 9:16 like the scenes, so they cut+away from the whole frame rather than sitting inside it. `motion.cut` fades them+in over two frames, which is what a cut looks like; `@receipt` uses `motion.drop`+instead, so one of the three is visibly doing something else.++**Captions on the same map.** Cue times come from the aligned map, placed by the+Script tokens each Atom corresponds to, so the words appear when they are said.++**Three levels of marker.** `<rainbow>` encloses `@fee`, which encloses+`@amount`. Each level is outlined in its own colour as the playhead passes+through, and `@amount` places nothing at all — a marker means something whether+or not a Track was hung on it.++**Markers that bind nothing.** `@seat` and `@loan` are marked in the Script but+no Media Item uses them, so they are coloured in the source and absent from the+timeline. That is a legitimate state, not an error.++## Files++`timing.json` and `space.json` are generated, and committed so the example runs+without ffprobe. Regenerate them whenever the Script text changes — the map is+keyed by the Script's tokens, so editing a word invalidates it.diff --git a/examples/street-interview-preview/align-transcript.ts b/examples/street-interview-preview/align-transcript.tsnew file mode 100644index 00000000..03b38968--- /dev/null+++ b/examples/street-interview-preview/align-transcript.ts@@ -0,0 +1,142 @@+/**+ * Turn the recorded transcript into a measured timeline for this Source.+ *+ * The footage in `docs/public/street-interview/` ships with a word-level+ * transcript, but a transcript is not a SemanticMap: a map is keyed by *this*+ * Script's own anchor identities, and pairing loose words with authored tokens+ * is the aligner's job, not a rename. So this runs the real aligner —+ * `locateSpeechTiming` — over evidence built from the transcript, and writes the+ * two values a Run Source can then satisfy `timing.map` and `speech.space` with.+ *+ * node --import tsx examples/street-interview-preview/align-transcript.ts+ *+ * Doing it here rather than in the Playground is deliberate. The preview reads;+ * deriving a new value from evidence is authoring, and it belongs next to the+ * Source whose words it is about.+ */+import { execFileSync } from "node:child_process";+import { createHash } from "node:crypto";+import { readFileSync, writeFileSync } from "node:fs";+import { dirname, join } from "node:path";+import { fileURLToPath } from "node:url";++import { parseScript } from "@narratage/script";+import type { AlignedTranscriptEvidence, AlignedTranscriptSegment } from "@narratage/speech-evidence";+import { locateSpeechTiming } from "@narratage/speech-alignment";+import type { SpeechAudioBasis } from "@narratage/speech";+import { programSpaceFrameCount, sealProgramSpace } from "@narratage/program-space";+import type { ProgramSpace } from "@narratage/program-space";++const here = dirname(fileURLToPath(import.meta.url));+const repoRoot = join(here, "../..");+const FRAME_RATE = { numerator: 24, denominator: 1 } as const;++/** Scene files in Script order. Each one is a Segment's worth of speech. */+const SCENES = [+ { segmentId: "hook", file: "scene-1.mp4" },+ { segmentId: "price", file: "scene-2.mp4" },+ { segmentId: "rainbow", file: "scene-3.mp4" },+ { segmentId: "payment", file: "scene-4.mp4" },+] as const;++type Word = { readonly text: string; readonly start: number; readonly end: number };++function sceneDuration(file: string): number {+ // Probing keeps the split honest: the boundary between two Segments is where+ // one recording ends, not where a hand-written constant says it does.+ const raw = execFileSync("ffprobe", [+ "-v", "error", "-show_entries", "format=duration", "-of", "csv=p=0",+ join(repoRoot, "docs/public/street-interview", file),+ ], { encoding: "utf8" });+ return Number(raw.trim());+}++function scriptBody(source: string): { readonly text: string; readonly offset: number } {+ const open = source.indexOf(">", source.indexOf("<script"));+ const close = source.indexOf("</script>");+ if (open < 0 || close < 0) throw new Error("main.svml has no <script> body.");+ return { text: source.slice(open + 1, close), offset: open + 1 };+}++const source = readFileSync(join(here, "main.svml"), "utf8");+const body = scriptBody(source);+const narrative = parseScript("main.svml", body.text, body.offset);++const transcript = JSON.parse(+ readFileSync(join(repoRoot, "docs/public/street-interview/transcript.json"), "utf8"),+) as readonly Word[];++// The programme is the four recordings back to back, so a Segment's window is+// its own scene's window on that timeline.+const bounds: { segmentId: string; startSec: number; endSec: number }[] = [];+let elapsed = 0;+for (const scene of SCENES) {+ const startSec = elapsed;+ elapsed += sceneDuration(scene.file);+ bounds.push({ segmentId: scene.segmentId, startSec, endSec: elapsed });+}++// A ProgramSpace must end on an exact frame boundary, so the programme is as+// long as the whole frames its recordings occupy.+const frameCount = Math.ceil(elapsed * FRAME_RATE.numerator / FRAME_RATE.denominator);+const space: ProgramSpace = sealProgramSpace({+ contract: "svml.program-space@1",+ durationSec: frameCount * FRAME_RATE.denominator / FRAME_RATE.numerator,+ frameRate: { ...FRAME_RATE },+});+if (programSpaceFrameCount(space) !== frameCount) throw new Error("ProgramSpace does not round-trip.");+bounds[bounds.length - 1] = { ...bounds.at(-1)!, endSec: space.durationSec };++const segments: AlignedTranscriptSegment[] = bounds.map((segment) => ({+ sourceSegmentId: segment.segmentId,+ startSec: segment.startSec,+ endSec: segment.endSec,+ words: transcript+ .filter((word) => word.start >= segment.startSec && word.start < segment.endSec)+ .map((word) => ({+ text: word.text,+ startSec: word.start,+ endSec: Math.min(word.end, segment.endSec),+ })),+ // WhisperX can emit character alignment; this transcript carries none, and+ // the aligner treats its absence as "no finer evidence" rather than an error.+ chars: [],+}));++const evidence: AlignedTranscriptEvidence = {+ contract: "svml.aligned-transcript-evidence@1",+ durationSec: space.durationSec,+ segments,+};++/**+ * The audio this transcript describes is inside the scene files rather than+ * beside them, so the basis names it by a digest over what is actually known+ * about it. The aligner reads the digest for identity only; it never fetches+ * the bytes.+ */+const basis: SpeechAudioBasis = {+ contract: "svml.speech-audio-basis@1",+ programSpace: space,+ audio: {+ kind: "blob",+ digest: `sha256:${createHash("sha256")+ .update(`street-interview ${SCENES.map((scene) => scene.file).join(" ")} ${space.durationSec}`)+ .digest("hex")}`,+ size: 0,+ mediaType: "audio/wav",+ },+ segments: bounds.map(({ segmentId, startSec, endSec }) => ({ segmentId, startSec, endSec })),+};++const map = locateSpeechTiming(narrative, basis, evidence);++writeFileSync(join(here, "timing.json"), `${JSON.stringify(map, null, 2)}\n`, "utf8");+writeFileSync(join(here, "space.json"), `${JSON.stringify(space, null, 2)}\n`, "utf8");++const words = segments.reduce((sum, segment) => sum + segment.words.length, 0);+process.stdout.write(+ `Aligned ${words} transcript words onto ${narrative.tokens.length} Script tokens.\n`+ + `${map.anchors.length} anchors across ${frameCount} frames (${space.durationSec.toFixed(3)}s).\n`+ + "Wrote timing.json and space.json.\n",+);diff --git a/examples/street-interview-preview/build.svrun b/examples/street-interview-preview/build.svrunnew file mode 100644index 00000000..7ccd3ffb--- /dev/null+++ b/examples/street-interview-preview/build.svrun@@ -0,0 +1,33 @@+<?svml using="@narratage/run-markup@1"?>++<svrun version="1">+ <author source="./main.svml"/>+ <target output="final.video"/>++ <!-- Footage the documentation site already ships. It is 24 fps, which is the+ frame rate this Source declares, so the preview can show it as authored+ rather than normalizing it. -->+ <file id="scene-hook" from="../../docs/public/street-interview/scene-1.mp4" media-type="video/mp4"/>+ <file id="scene-price" from="../../docs/public/street-interview/scene-2.mp4" media-type="video/mp4"/>+ <file id="scene-rainbow" from="../../docs/public/street-interview/scene-3.mp4" media-type="video/mp4"/>+ <file id="scene-payment" from="../../docs/public/street-interview/scene-4.mp4" media-type="video/mp4"/>+ <file id="cut-bags" from="../../docs/public/street-interview/broll-2.mp4" media-type="video/mp4"/>+ <file id="cut-fee" from="../../docs/public/street-interview/broll-3.mp4" media-type="video/mp4"/>+ <file id="cut-receipt" from="../../docs/public/street-interview/broll-4.mp4" media-type="video/mp4"/>++ <!-- The recorded transcript, aligned onto this Script's own anchors by+ ./align-transcript.ts. Which timings a Source is read with is an+ authoring decision, so it is made here. -->+ <value id="aligned-map" type="@narratage/semantic-map@1#CompleteSemanticMap" from="./timing.json"/>+ <value id="aligned-space" type="@narratage/program-space@1#ProgramSpace" from="./space.json"/>+ <satisfy output="timing.map" candidate="aligned-map"/>+ <satisfy output="speech.space" candidate="aligned-space"/>++ <satisfy output="take-hook.video" candidate="scene-hook"/>+ <satisfy output="take-price.video" candidate="scene-price"/>+ <satisfy output="take-rainbow.video" candidate="scene-rainbow"/>+ <satisfy output="take-payment.video" candidate="scene-payment"/>+ <satisfy output="cutaway-bags.video" candidate="cut-bags"/>+ <satisfy output="cutaway-fee.video" candidate="cut-fee"/>+ <satisfy output="cutaway-receipt.video" candidate="cut-receipt"/>+</svrun>diff --git a/examples/street-interview-preview/main.svml b/examples/street-interview-preview/main.svmlnew file mode 100644index 00000000..48a3ca6d--- /dev/null+++ b/examples/street-interview-preview/main.svml@@ -0,0 +1,103 @@+<?svml using="@narratage/markup@1"?>++<svml>+ <import from="@narratage/script@1"/>+ <import as="wording" from="@narratage/text@1"/>+ <import as="seedance" from="@narratage/seedance@1"/>+ <import as="speech" from="@narratage/speech-spine@1"/>+ <import as="whisperx" from="@narratage/whisperx@1"/>+ <import as="media-track" from="@narratage/media-track@1"/>+ <import as="caption" from="@narratage/caption@1"/>+ <import as="caption-fine" from="@narratage/caption-fine@1"/>+ <import as="caption-ai" from="@narratage/caption-gemini@1"/>+ <import as="fonts" from="@narratage/fonts-open@1"/>+ <import as="space" from="@narratage/spatial@1"/>+ <import as="film" from="@narratage/film@1"/>+ <import as="render" from="@narratage/render-hyperframes@1"/>+ <import as="studio" source="./studio.svs"/>++ <!-- The words are the ones actually spoken in the recorded interview, so the+ Script and the picture describe the same programme. -->+ <script id="story">+ <hook>+ <A>How much was your flight?+ <B>$49. That's cheap. @seat The seat was cheap. The rainbow wasn't.@/seat+ </hook>+ <price>+ <A>They charged you for the rainbow?+ <B>@bags They counted it as seven carry-ons.@/bags+ <A>Why seven?+ <B>One bag for each color.+ </price>+ <rainbow>+ <A>Couldn't you turn it off?+ <B>I tried. @fee They charged me a @amount $35@/amount rainbow deactivation fee.@/fee+ <A>What was the total?+ <B>$2,846.+ <A>Do you have the receipt?+ <B>@receipt Yeah, but I can't screenshot the whole thing. It's still scrolling.@/receipt+ </rainbow>+ <payment>+ <A>How did you pay for it?+ <B>I took out a student loan.+ <A>But you're not in college.+ <B>@loan I am now. The airline enrolled me so I could finance the baggage fees.@/loan+ </payment>+ </script>++ <space:Canvas id="vertical" width="1080" height="1920"/>+ <space:Frame id="speech-frame" within={vertical}+ left="0%" top="0%" right="100%" bottom="100%"/>+ <!-- The cutaways are shot 9:16 like the scenes, so they cut away from the+ whole frame rather than sitting inside it. right and bottom are edge+ positions, not insets. -->+ <space:Frame id="full" within={vertical}+ left="0%" top="0%" right="100%" bottom="100%"/>++ <wording:Value id="direction">Handheld street interview, late afternoon, two speakers.</wording:Value>+ <seedance:TextVideo id="take-hook" model="mini" prompt={direction} duration="5" generate-audio="true"/>+ <seedance:TextVideo id="take-price" model="mini" prompt={direction} duration="6" generate-audio="true"/>+ <seedance:TextVideo id="take-rainbow" model="mini" prompt={direction} duration="11" generate-audio="true"/>+ <seedance:TextVideo id="take-payment" model="mini" prompt={direction} duration="9" generate-audio="true"/>+ <seedance:TextVideo id="cutaway-bags" model="mini" prompt={direction} duration="4"/>+ <seedance:TextVideo id="cutaway-fee" model="mini" prompt={direction} duration="4"/>+ <seedance:TextVideo id="cutaway-receipt" model="mini" prompt={direction} duration="5"/>++ <speech:Spine id="speech" frame-rate="24"+ visual-frame={speech-frame} visual-appearance={studio.speech.visual} visual-z="0">+ <speech:Take video={take-hook.video} segment={story.segment.hook}/>+ <speech:Take video={take-price.video} segment={story.segment.price}/>+ <speech:Take video={take-rainbow.video} segment={story.segment.rainbow}/>+ <speech:Take video={take-payment.video} segment={story.segment.payment}/>+ </speech:Spine>+ <whisperx:Alignment id="timing" narrative={story} audio={speech.audio}/>++ <fonts:Stack id="caption-font" family="inter" weight="700" style="normal"/>+ <caption-fine:Style id="base-caption" recipe={studio.caption.base} font={caption-font}/>+ <caption:Program id="caption-program" display={story.caption} default={base-caption}/>+ <caption-ai:Planner id="cue-plan" display={story.caption} program={caption-program}+ model="gemini-2.5-flash"/>+ <caption-fine:Track id="captions" display={story.caption}+ correspondence={story.caption.correspondence}+ map={timing.map} space={speech.space}+ plan={cue-plan.plan} program={caption-program}/>++ <!-- Three cutaways on one Track. Their Selections do not overlap, so they+ share a single timeline row the way an editor would lay them out. -->+ <media-track:Track id="cutaways" map={timing.map} space={speech.space} canvas={vertical}>+ <media-track:Item id="bags" video={cutaway-bags.video} during={story.selection.bags}+ frame={full} appearance={studio.media.cutaway} motion={studio.motion.cut}/>+ <media-track:Item id="fee" video={cutaway-fee.video} during={story.selection.fee}+ frame={full} appearance={studio.media.cutaway} motion={studio.motion.cut}/>+ <media-track:Item id="receipt" video={cutaway-receipt.video} during={story.selection.receipt}+ frame={full} appearance={studio.media.cutaway} motion={studio.motion.drop}/>+ </media-track:Track>++ <film:Film id="main" canvas={vertical} space={speech.space} appearance={studio.film.vertical}>+ <film:Track source={speech.visual}/>+ <film:Track source={speech.audioTrack}/>+ <film:Track source={cutaways.visual}/>+ <film:Track source={captions.track}/>+ </film:Film>+ <render:Video id="final" composition={main.composition} space={speech.space}/>+</svml>diff --git a/examples/street-interview-preview/space.json b/examples/street-interview-preview/space.jsonnew file mode 100644index 00000000..d897c40c--- /dev/null+++ b/examples/street-interview-preview/space.json@@ -0,0 +1,8 @@+{+ "contract": "svml.program-space@1",+ "durationSec": 31.291666666666668,+ "frameRate": {+ "numerator": 24,+ "denominator": 1+ }+}diff --git a/examples/street-interview-preview/studio.svs b/examples/street-interview-preview/studio.svsnew file mode 100644index 00000000..8749e196--- /dev/null+++ b/examples/street-interview-preview/studio.svs@@ -0,0 +1,39 @@+<?svml using="@narratage/svs@1"?>++<sheet version="1">+ film.vertical { background: #08080a; }+ speech.visual { fit: cover; }++ /* A full-frame cutaway replaces the shot, so it has no box treatment at all. */+ media.cutaway { stack-order: 40; fit: cover; playback: hold-start; }++ /* An inset card, for contrast: rounded, padded and framed. */+ media.card {+ stack-order: 41; fit: cover; playback: hold-start;+ frame-paint: #17171f; clip: rounded; radius: 26; padding: 14 14;+ border-width: 1; border-color: #ffffff2b;+ shadows: 0 18 40 -8 #000000cc;+ }++ /* A cutaway cuts; it does not slide. */+ motion.cut {+ enter: fade; enter-frames: 2; enter-easing: linear;+ exit: fade; exit-frames: 2; exit-easing: linear;+ }+ motion.drop {+ enter: scale; enter-frames: 6; enter-amount: 0.88; enter-easing: ease-out;+ sustain: float 6 2;+ exit: slide; exit-frames: 5; exit-direction: down; exit-easing: ease-in;+ }++ caption.base {+ cue-min-words: 1; cue-max-words: 5;+ stack-order: 70; x: 0.5; y: 0.84; width: 0.86; anchor-x: center; anchor-y: bottom;+ size: 56; line-height: 1.05; align: center;+ fill: #FFFFFF; stroke-color: #08080A; stroke-width: 2;+ shadow-color: #000000; shadow-opacity: 0.7; shadow-x: 0; shadow-y: 3; shadow-blur: 8;+ background: #08080ACC; border-color: #FFFFFF20; border-width: 1; padding: 14 22; radius: 16;+ karaoke: trail; karaoke-transition: wipe; active-fill: #FFD54A;+ cue-enter: fade; cue-enter-frames: 3; cue-exit: fade; cue-exit-frames: 3;+ }+</sheet>diff --git a/examples/street-interview-preview/timing.json b/examples/street-interview-preview/timing.jsonnew file mode 100644index 00000000..b9ad5bd9--- /dev/null+++ b/examples/street-interview-preview/timing.json@@ -0,0 +1,1883 @@+{+ "contract": "svml.complete-semantic-map@1",+ "tokens": [+ {+ "tokenId": "segment:hook:token:1",+ "segmentId": "hook",+ "startSec": 0.041666666666666664,+ "endSec": 0.125,+ "startFrame": 1,+ "endFrame": 3+ },+ {+ "tokenId": "segment:hook:token:2",+ "segmentId": "hook",+ "startSec": 0.20833333333333334,+ "endSec": 0.25,+ "startFrame": 5,+ "endFrame": 6+ },+ {+ "tokenId": "segment:hook:token:3",+ "segmentId": "hook",+ "startSec": 0.375,+ "endSec": 0.5416666666666666,+ "startFrame": 9,+ "endFrame": 13+ },+ {+ "tokenId": "segment:hook:token:4",+ "segmentId": "hook",+ "startSec": 0.5416666666666666,+ "endSec": 0.625,+ "startFrame": 13,+ "endFrame": 15+ },+ {+ "tokenId": "segment:hook:token:5",+ "segmentId": "hook",+ "startSec": 0.75,+ "endSec": 1.25,+ "startFrame": 18,+ "endFrame": 30+ },+ {+ "tokenId": "segment:hook:token:6",+ "segmentId": "hook",+ "startSec": 1.2916666666666667,+ "endSec": 2.3333333333333335,+ "startFrame": 31,+ "endFrame": 56+ },+ {+ "tokenId": "segment:hook:token:7",+ "segmentId": "hook",+ "startSec": 2.375,+ "endSec": 2.5833333333333335,+ "startFrame": 57,+ "endFrame": 62+ },+ {+ "tokenId": "segment:hook:token:8",+ "segmentId": "hook",+ "startSec": 2.7083333333333335,+ "endSec": 3.1666666666666665,+ "startFrame": 65,+ "endFrame": 76+ },+ {+ "tokenId": "segment:hook:token:9",+ "segmentId": "hook",+ "startSec": 3.2083333333333335,+ "endSec": 3.2916666666666665,+ "startFrame": 77,+ "endFrame": 79+ },+ {+ "tokenId": "segment:hook:token:10",+ "segmentId": "hook",+ "startSec": 3.3333333333333335,+ "endSec": 3.5416666666666665,+ "startFrame": 80,+ "endFrame": 85+ },+ {+ "tokenId": "segment:hook:token:11",+ "segmentId": "hook",+ "startSec": 3.5416666666666665,+ "endSec": 3.7083333333333335,+ "startFrame": 85,+ "endFrame": 89+ },+ {+ "tokenId": "segment:hook:token:12",+ "segmentId": "hook",+ "startSec": 3.7083333333333335,+ "endSec": 4.125,+ "startFrame": 89,+ "endFrame": 99+ },+ {+ "tokenId": "segment:hook:token:13",+ "segmentId": "hook",+ "startSec": 4.208333333333333,+ "endSec": 4.291666666666667,+ "startFrame": 101,+ "endFrame": 103+ },+ {+ "tokenId": "segment:hook:token:14",+ "segmentId": "hook",+ "startSec": 4.333333333333333,+ "endSec": 4.583333333333333,+ "startFrame": 104,+ "endFrame": 110+ },+ {+ "tokenId": "segment:hook:token:15",+ "segmentId": "hook",+ "startSec": 4.666666666666667,+ "endSec": 5.083333333333333,+ "startFrame": 112,+ "endFrame": 122+ },+ {+ "tokenId": "segment:price:token:1",+ "segmentId": "price",+ "startSec": 5.166666666666667,+ "endSec": 5.333333333333333,+ "startFrame": 124,+ "endFrame": 128+ },+ {+ "tokenId": "segment:price:token:2",+ "segmentId": "price",+ "startSec": 5.333333333333333,+ "endSec": 5.75,+ "startFrame": 128,+ "endFrame": 138+ },+ {+ "tokenId": "segment:price:token:3",+ "segmentId": "price",+ "startSec": 5.875,+ "endSec": 5.916666666666667,+ "startFrame": 141,+ "endFrame": 142+ },+ {+ "tokenId": "segment:price:token:4",+ "segmentId": "price",+ "startSec": 5.916666666666667,+ "endSec": 6.083333333333333,+ "startFrame": 142,+ "endFrame": 146+ },+ {+ "tokenId": "segment:price:token:5",+ "segmentId": "price",+ "startSec": 6.083333333333333,+ "endSec": 6.083333333333333,+ "startFrame": 146,+ "endFrame": 146+ },+ {+ "tokenId": "segment:price:token:6",+ "segmentId": "price",+ "startSec": 6.458333333333333,+ "endSec": 6.833333333333333,+ "startFrame": 155,+ "endFrame": 164+ },+ {+ "tokenId": "segment:price:token:7",+ "segmentId": "price",+ "startSec": 6.875,+ "endSec": 7.083333333333333,+ "startFrame": 165,+ "endFrame": 170+ },+ {+ "tokenId": "segment:price:token:8",+ "segmentId": "price",+ "startSec": 7.083333333333333,+ "endSec": 7.458333333333333,+ "startFrame": 170,+ "endFrame": 179+ },+ {+ "tokenId": "segment:price:token:9",+ "segmentId": "price",+ "startSec": 7.583333333333333,+ "endSec": 7.625,+ "startFrame": 182,+ "endFrame": 183+ },+ {+ "tokenId": "segment:price:token:10",+ "segmentId": "price",+ "startSec": 7.625,+ "endSec": 7.75,+ "startFrame": 183,+ "endFrame": 186+ },+ {+ "tokenId": "segment:price:token:11",+ "segmentId": "price",+ "startSec": 7.75,+ "endSec": 7.791666666666667,+ "startFrame": 186,+ "endFrame": 187+ },+ {+ "tokenId": "segment:price:token:12",+ "segmentId": "price",+ "startSec": 8.166666666666666,+ "endSec": 8.791666666666666,+ "startFrame": 196,+ "endFrame": 211+ },+ {+ "tokenId": "segment:price:token:13",+ "segmentId": "price",+ "startSec": 8.833333333333334,+ "endSec": 9.041666666666666,+ "startFrame": 212,+ "endFrame": 217+ },+ {+ "tokenId": "segment:price:token:14",+ "segmentId": "price",+ "startSec": 9.041666666666666,+ "endSec": 9.708333333333334,+ "startFrame": 217,+ "endFrame": 233+ },+ {+ "tokenId": "segment:price:token:15",+ "segmentId": "price",+ "startSec": 9.75,+ "endSec": 9.916666666666666,+ "startFrame": 234,+ "endFrame": 238+ },+ {+ "tokenId": "segment:price:token:16",+ "segmentId": "price",+ "startSec": 9.916666666666666,+ "endSec": 10.125,+ "startFrame": 238,+ "endFrame": 243+ },+ {+ "tokenId": "segment:price:token:17",+ "segmentId": "price",+ "startSec": 10.125,+ "endSec": 10.333333333333334,+ "startFrame": 243,+ "endFrame": 248+ },+ {+ "tokenId": "segment:price:token:18",+ "segmentId": "price",+ "startSec": 10.333333333333334,+ "endSec": 10.583333333333334,+ "startFrame": 248,+ "endFrame": 254+ },+ {+ "tokenId": "segment:price:token:19",+ "segmentId": "price",+ "startSec": 10.583333333333334,+ "endSec": 11.125,+ "startFrame": 254,+ "endFrame": 267+ },+ {+ "tokenId": "segment:rainbow:token:1",+ "segmentId": "rainbow",+ "startSec": 11.166666666666666,+ "endSec": 11.5,+ "startFrame": 268,+ "endFrame": 276+ },+ {+ "tokenId": "segment:rainbow:token:2",+ "segmentId": "rainbow",+ "startSec": 11.5,+ "endSec": 11.541666666666666,+ "startFrame": 276,+ "endFrame": 277+ },+ {+ "tokenId": "segment:rainbow:token:3",+ "segmentId": "rainbow",+ "startSec": 11.625,+ "endSec": 11.75,+ "startFrame": 279,+ "endFrame": 282+ },+ {+ "tokenId": "segment:rainbow:token:4",+ "segmentId": "rainbow",+ "startSec": 11.875,+ "endSec": 11.916666666666666,+ "startFrame": 285,+ "endFrame": 286+ },+ {+ "tokenId": "segment:rainbow:token:5",+ "segmentId": "rainbow",+ "startSec": 11.916666666666666,+ "endSec": 12.083333333333334,+ "startFrame": 286,+ "endFrame": 290+ },+ {+ "tokenId": "segment:rainbow:token:6",+ "segmentId": "rainbow",+ "startSec": 12.25,+ "endSec": 12.291666666666666,+ "startFrame": 294,+ "endFrame": 295+ },+ {+ "tokenId": "segment:rainbow:token:7",+ "segmentId": "rainbow",+ "startSec": 12.291666666666666,+ "endSec": 13.041666666666666,+ "startFrame": 295,+ "endFrame": 313+ },+ {+ "tokenId": "segment:rainbow:token:8",+ "segmentId": "rainbow",+ "startSec": 13.083333333333334,+ "endSec": 13.291666666666666,+ "startFrame": 314,+ "endFrame": 319+ },+ {+ "tokenId": "segment:rainbow:token:9",+ "segmentId": "rainbow",+ "startSec": 13.291666666666666,+ "endSec": 13.666666666666666,+ "startFrame": 319,+ "endFrame": 328+ },+ {+ "tokenId": "segment:rainbow:token:10",+ "segmentId": "rainbow",+ "startSec": 13.666666666666666,+ "endSec": 13.791666666666666,+ "startFrame": 328,+ "endFrame": 331+ },+ {+ "tokenId": "segment:rainbow:token:11",+ "segmentId": "rainbow",+ "startSec": 13.791666666666666,+ "endSec": 13.833333333333334,+ "startFrame": 331,+ "endFrame": 332+ },+ {+ "tokenId": "segment:rainbow:token:12",+ "segmentId": "rainbow",+ "startSec": 13.833333333333334,+ "endSec": 14.041666666666666,+ "startFrame": 332,+ "endFrame": 337+ },+ {+ "tokenId": "segment:rainbow:token:13",+ "segmentId": "rainbow",+ "startSec": 14.375,+ "endSec": 14.583333333333334,+ "startFrame": 345,+ "endFrame": 350+ },+ {+ "tokenId": "segment:rainbow:token:14",+ "segmentId": "rainbow",+ "startSec": 14.583333333333334,+ "endSec": 15.166666666666666,+ "startFrame": 350,+ "endFrame": 364+ },+ {+ "tokenId": "segment:rainbow:token:15",+ "segmentId": "rainbow",+ "startSec": 15.416666666666666,+ "endSec": 15.625,+ "startFrame": 370,+ "endFrame": 375+ },+ {+ "tokenId": "segment:rainbow:token:16",+ "segmentId": "rainbow",+ "startSec": 15.666666666666666,+ "endSec": 15.833333333333334,+ "startFrame": 376,+ "endFrame": 380+ },+ {+ "tokenId": "segment:rainbow:token:17",+ "segmentId": "rainbow",+ "startSec": 15.833333333333334,+ "endSec": 15.875,+ "startFrame": 380,+ "endFrame": 381+ },+ {+ "tokenId": "segment:rainbow:token:18",+ "segmentId": "rainbow",+ "startSec": 16,+ "endSec": 16.166666666666668,+ "startFrame": 384,+ "endFrame": 388+ },+ {+ "tokenId": "segment:rainbow:token:19",+ "segmentId": "rainbow",+ "startSec": 16.166666666666668,+ "endSec": 16.583333333333332,+ "startFrame": 388,+ "endFrame": 398+ },+ {+ "tokenId": "segment:rainbow:token:20",+ "segmentId": "rainbow",+ "startSec": 16.666666666666668,+ "endSec": 17.166666666666668,+ "startFrame": 400,+ "endFrame": 412+ },+ {+ "tokenId": "segment:rainbow:token:21",+ "segmentId": "rainbow",+ "startSec": 17.166666666666668,+ "endSec": 18.75,+ "startFrame": 412,+ "endFrame": 450+ },+ {+ "tokenId": "segment:rainbow:token:22",+ "segmentId": "rainbow",+ "startSec": 18.791666666666668,+ "endSec": 18.875,+ "startFrame": 451,+ "endFrame": 453+ },+ {+ "tokenId": "segment:rainbow:token:23",+ "segmentId": "rainbow",+ "startSec": 18.875,+ "endSec": 19,+ "startFrame": 453,+ "endFrame": 456+ },+ {+ "tokenId": "segment:rainbow:token:24",+ "segmentId": "rainbow",+ "startSec": 19,+ "endSec": 19.041666666666668,+ "startFrame": 456,+ "endFrame": 457+ },+ {+ "tokenId": "segment:rainbow:token:25",+ "segmentId": "rainbow",+ "startSec": 19.166666666666668,+ "endSec": 19.208333333333332,+ "startFrame": 460,+ "endFrame": 461+ },+ {+ "tokenId": "segment:rainbow:token:26",+ "segmentId": "rainbow",+ "startSec": 19.291666666666668,+ "endSec": 19.708333333333332,+ "startFrame": 463,+ "endFrame": 473+ },+ {+ "tokenId": "segment:rainbow:token:27",+ "segmentId": "rainbow",+ "startSec": 19.75,+ "endSec": 19.958333333333332,+ "startFrame": 474,+ "endFrame": 479+ },+ {+ "tokenId": "segment:rainbow:token:28",+ "segmentId": "rainbow",+ "startSec": 19.958333333333332,+ "endSec": 20.083333333333332,+ "startFrame": 479,+ "endFrame": 482+ },+ {+ "tokenId": "segment:rainbow:token:29",+ "segmentId": "rainbow",+ "startSec": 20.083333333333332,+ "endSec": 20.125,+ "startFrame": 482,+ "endFrame": 483+ },+ {+ "tokenId": "segment:rainbow:token:30",+ "segmentId": "rainbow",+ "startSec": 20.125,+ "endSec": 20.333333333333332,+ "startFrame": 483,+ "endFrame": 488+ },+ {+ "tokenId": "segment:rainbow:token:31",+ "segmentId": "rainbow",+ "startSec": 20.458333333333332,+ "endSec": 20.666666666666668,+ "startFrame": 491,+ "endFrame": 496+ },+ {+ "tokenId": "segment:rainbow:token:32",+ "segmentId": "rainbow",+ "startSec": 20.666666666666668,+ "endSec": 21,+ "startFrame": 496,+ "endFrame": 504+ },+ {+ "tokenId": "segment:rainbow:token:33",+ "segmentId": "rainbow",+ "startSec": 21,+ "endSec": 21.125,+ "startFrame": 504,+ "endFrame": 507+ },+ {+ "tokenId": "segment:rainbow:token:34",+ "segmentId": "rainbow",+ "startSec": 21.125,+ "endSec": 21.375,+ "startFrame": 507,+ "endFrame": 513+ },+ {+ "tokenId": "segment:rainbow:token:35",+ "segmentId": "rainbow",+ "startSec": 21.375,+ "endSec": 21.5,+ "startFrame": 513,+ "endFrame": 516+ },+ {+ "tokenId": "segment:rainbow:token:36",+ "segmentId": "rainbow",+ "startSec": 21.541666666666668,+ "endSec": 21.625,+ "startFrame": 517,+ "endFrame": 519+ },+ {+ "tokenId": "segment:rainbow:token:37",+ "segmentId": "rainbow",+ "startSec": 21.75,+ "endSec": 22.208333333333332,+ "startFrame": 522,+ "endFrame": 533+ },+ {+ "tokenId": "segment:payment:token:1",+ "segmentId": "payment",+ "startSec": 22.25,+ "endSec": 22.416666666666668,+ "startFrame": 534,+ "endFrame": 538+ },+ {+ "tokenId": "segment:payment:token:2",+ "segmentId": "payment",+ "startSec": 22.416666666666668,+ "endSec": 22.625,+ "startFrame": 538,+ "endFrame": 543+ },+ {+ "tokenId": "segment:payment:token:3",+ "segmentId": "payment",+ "startSec": 22.625,+ "endSec": 22.833333333333332,+ "startFrame": 543,+ "endFrame": 548+ },+ {+ "tokenId": "segment:payment:token:4",+ "segmentId": "payment",+ "startSec": 22.958333333333332,+ "endSec": 23.083333333333332,+ "startFrame": 551,+ "endFrame": 554+ },+ {+ "tokenId": "segment:payment:token:5",+ "segmentId": "payment",+ "startSec": 23.083333333333332,+ "endSec": 23.166666666666668,+ "startFrame": 554,+ "endFrame": 556+ },+ {+ "tokenId": "segment:payment:token:6",+ "segmentId": "payment",+ "startSec": 23.458333333333332,+ "endSec": 23.666666666666668,+ "startFrame": 563,+ "endFrame": 568+ },+ {+ "tokenId": "segment:payment:token:7",+ "segmentId": "payment",+ "startSec": 23.708333333333332,+ "endSec": 23.75,+ "startFrame": 569,+ "endFrame": 570+ },+ {+ "tokenId": "segment:payment:token:8",+ "segmentId": "payment",+ "startSec": 23.75,+ "endSec": 23.916666666666668,+ "startFrame": 570,+ "endFrame": 574+ },+ {+ "tokenId": "segment:payment:token:9",+ "segmentId": "payment",+ "startSec": 24.041666666666668,+ "endSec": 24.291666666666668,+ "startFrame": 577,+ "endFrame": 583+ },+ {+ "tokenId": "segment:payment:token:10",+ "segmentId": "payment",+ "startSec": 24.291666666666668,+ "endSec": 24.291666666666668,+ "startFrame": 583,+ "endFrame": 583+ },+ {+ "tokenId": "segment:payment:token:11",+ "segmentId": "payment",+ "startSec": 24.416666666666668,+ "endSec": 24.666666666666668,+ "startFrame": 586,+ "endFrame": 592+ },+ {+ "tokenId": "segment:payment:token:12",+ "segmentId": "payment",+ "startSec": 25,+ "endSec": 25.458333333333332,+ "startFrame": 600,+ "endFrame": 611+ },+ {+ "tokenId": "segment:payment:token:13",+ "segmentId": "payment",+ "startSec": 25.5,+ "endSec": 25.583333333333332,+ "startFrame": 612,+ "endFrame": 614+ },+ {+ "tokenId": "segment:payment:token:14",+ "segmentId": "payment",+ "startSec": 25.666666666666668,+ "endSec": 26.041666666666668,+ "startFrame": 616,+ "endFrame": 625+ },+ {+ "tokenId": "segment:payment:token:15",+ "segmentId": "payment",+ "startSec": 26.041666666666668,+ "endSec": 26.208333333333332,+ "startFrame": 625,+ "endFrame": 629+ },+ {+ "tokenId": "segment:payment:token:16",+ "segmentId": "payment",+ "startSec": 26.208333333333332,+ "endSec": 26.333333333333332,+ "startFrame": 629,+ "endFrame": 632+ },+ {+ "tokenId": "segment:payment:token:17",+ "segmentId": "payment",+ "startSec": 26.333333333333332,+ "endSec": 27.041666666666668,+ "startFrame": 632,+ "endFrame": 649+ },+ {+ "tokenId": "segment:payment:token:18",+ "segmentId": "payment",+ "startSec": 27.083333333333332,+ "endSec": 27.125,+ "startFrame": 650,+ "endFrame": 651+ },+ {+ "tokenId": "segment:payment:token:19",+ "segmentId": "payment",+ "startSec": 27.125,+ "endSec": 27.291666666666668,+ "startFrame": 651,+ "endFrame": 655+ },+ {+ "tokenId": "segment:payment:token:20",+ "segmentId": "payment",+ "startSec": 27.416666666666668,+ "endSec": 27.958333333333332,+ "startFrame": 658,+ "endFrame": 671+ },+ {+ "tokenId": "segment:payment:token:21",+ "segmentId": "payment",+ "startSec": 28,+ "endSec": 28.083333333333332,+ "startFrame": 672,+ "endFrame": 674+ },+ {+ "tokenId": "segment:payment:token:22",+ "segmentId": "payment",+ "startSec": 28.166666666666668,+ "endSec": 28.583333333333332,+ "startFrame": 676,+ "endFrame": 686+ },+ {+ "tokenId": "segment:payment:token:23",+ "segmentId": "payment",+ "startSec": 28.583333333333332,+ "endSec": 28.916666666666668,+ "startFrame": 686,+ "endFrame": 694+ },+ {+ "tokenId": "segment:payment:token:24",+ "segmentId": "payment",+ "startSec": 28.916666666666668,+ "endSec": 29.291666666666668,+ "startFrame": 694,+ "endFrame": 703+ },+ {+ "tokenId": "segment:payment:token:25",+ "segmentId": "payment",+ "startSec": 29.291666666666668,+ "endSec": 29.291666666666668,+ "startFrame": 703,+ "endFrame": 703+ },+ {+ "tokenId": "segment:payment:token:26",+ "segmentId": "payment",+ "startSec": 29.291666666666668,+ "endSec": 29.375,+ "startFrame": 703,+ "endFrame": 705+ },+ {+ "tokenId": "segment:payment:token:27",+ "segmentId": "payment",+ "startSec": 29.375,+ "endSec": 29.666666666666668,+ "startFrame": 705,+ "endFrame": 712+ },+ {+ "tokenId": "segment:payment:token:28",+ "segmentId": "payment",+ "startSec": 29.666666666666668,+ "endSec": 30.083333333333332,+ "startFrame": 712,+ "endFrame": 722+ },+ {+ "tokenId": "segment:payment:token:29",+ "segmentId": "payment",+ "startSec": 30.125,+ "endSec": 30.125,+ "startFrame": 723,+ "endFrame": 723+ },+ {+ "tokenId": "segment:payment:token:30",+ "segmentId": "payment",+ "startSec": 30.333333333333332,+ "endSec": 30.708333333333332,+ "startFrame": 728,+ "endFrame": 737+ },+ {+ "tokenId": "segment:payment:token:31",+ "segmentId": "payment",+ "startSec": 30.708333333333332,+ "endSec": 31.041666666666668,+ "startFrame": 737,+ "endFrame": 745+ }+ ],+ "anchors": [+ {+ "identity": "segment:hook:start",+ "timeSec": 0,+ "frame": 0+ },+ {+ "identity": "segment:hook:token:1:start",+ "timeSec": 0.041666666666666664,+ "frame": 1+ },+ {+ "identity": "segment:hook:token:1:end",+ "timeSec": 0.125,+ "frame": 3+ },+ {+ "identity": "segment:hook:token:2:start",+ "timeSec": 0.20833333333333334,+ "frame": 5+ },+ {+ "identity": "segment:hook:token:2:end",+ "timeSec": 0.25,+ "frame": 6+ },+ {+ "identity": "segment:hook:token:3:start",+ "timeSec": 0.375,+ "frame": 9+ },+ {+ "identity": "segment:hook:token:3:end",+ "timeSec": 0.5416666666666666,+ "frame": 13+ },+ {+ "identity": "segment:hook:token:4:start",+ "timeSec": 0.5416666666666666,+ "frame": 13+ },+ {+ "identity": "segment:hook:token:4:end",+ "timeSec": 0.625,+ "frame": 15+ },+ {+ "identity": "segment:hook:token:5:start",+ "timeSec": 0.75,+ "frame": 18+ },+ {+ "identity": "segment:hook:token:5:end",+ "timeSec": 1.25,+ "frame": 30+ },+ {+ "identity": "segment:hook:token:6:start",+ "timeSec": 1.2916666666666667,+ "frame": 31+ },+ {+ "identity": "segment:hook:token:6:end",+ "timeSec": 2.3333333333333335,+ "frame": 56+ },+ {+ "identity": "segment:hook:token:7:start",+ "timeSec": 2.375,+ "frame": 57+ },+ {+ "identity": "segment:hook:token:7:end",+ "timeSec": 2.5833333333333335,+ "frame": 62+ },+ {+ "identity": "segment:hook:token:8:start",+ "timeSec": 2.7083333333333335,+ "frame": 65+ },+ {+ "identity": "segment:hook:token:8:end",+ "timeSec": 3.1666666666666665,+ "frame": 76+ },+ {+ "identity": "segment:hook:token:9:start",+ "timeSec": 3.2083333333333335,+ "frame": 77+ },+ {+ "identity": "segment:hook:token:9:end",+ "timeSec": 3.2916666666666665,+ "frame": 79+ },+ {+ "identity": "segment:hook:token:10:start",+ "timeSec": 3.3333333333333335,+ "frame": 80+ },+ {+ "identity": "segment:hook:token:10:end",+ "timeSec": 3.5416666666666665,+ "frame": 85+ },+ {+ "identity": "segment:hook:token:11:start",+ "timeSec": 3.5416666666666665,+ "frame": 85+ },+ {+ "identity": "segment:hook:token:11:end",+ "timeSec": 3.7083333333333335,+ "frame": 89+ },+ {+ "identity": "segment:hook:token:12:start",+ "timeSec": 3.7083333333333335,+ "frame": 89+ },+ {+ "identity": "segment:hook:token:12:end",+ "timeSec": 4.125,+ "frame": 99+ },+ {+ "identity": "segment:hook:token:13:start",+ "timeSec": 4.208333333333333,+ "frame": 101+ },+ {+ "identity": "segment:hook:token:13:end",+ "timeSec": 4.291666666666667,+ "frame": 103+ },+ {+ "identity": "segment:hook:token:14:start",+ "timeSec": 4.333333333333333,+ "frame": 104+ },+ {+ "identity": "segment:hook:token:14:end",+ "timeSec": 4.583333333333333,+ "frame": 110+ },+ {+ "identity": "segment:hook:token:15:start",+ "timeSec": 4.666666666666667,+ "frame": 112+ },+ {+ "identity": "segment:hook:token:15:end",+ "timeSec": 5.083333333333333,+ "frame": 122+ },+ {+ "identity": "segment:hook:end",+ "timeSec": 5.083333333333333,+ "frame": 122+ },+ {+ "identity": "segment:price:start",+ "timeSec": 5.083333333333333,+ "frame": 122+ },+ {+ "identity": "segment:price:token:1:start",+ "timeSec": 5.166666666666667,+ "frame": 124+ },+ {+ "identity": "segment:price:token:1:end",+ "timeSec": 5.333333333333333,+ "frame": 128+ },+ {+ "identity": "segment:price:token:2:start",+ "timeSec": 5.333333333333333,+ "frame": 128+ },+ {+ "identity": "segment:price:token:2:end",+ "timeSec": 5.75,+ "frame": 138+ },+ {+ "identity": "segment:price:token:3:start",+ "timeSec": 5.875,+ "frame": 141+ },+ {+ "identity": "segment:price:token:3:end",+ "timeSec": 5.916666666666667,+ "frame": 142+ },+ {+ "identity": "segment:price:token:4:start",+ "timeSec": 5.916666666666667,+ "frame": 142+ },+ {+ "identity": "segment:price:token:4:end",+ "timeSec": 6.083333333333333,+ "frame": 146+ },+ {+ "identity": "segment:price:token:5:start",+ "timeSec": 6.083333333333333,+ "frame": 146+ },+ {+ "identity": "segment:price:token:5:end",+ "timeSec": 6.083333333333333,+ "frame": 146+ },+ {+ "identity": "segment:price:token:6:start",+ "timeSec": 6.458333333333333,+ "frame": 155+ },+ {+ "identity": "segment:price:token:6:end",+ "timeSec": 6.833333333333333,+ "frame": 164+ },+ {+ "identity": "segment:price:token:7:start",+ "timeSec": 6.875,+ "frame": 165+ },+ {+ "identity": "segment:price:token:7:end",+ "timeSec": 7.083333333333333,+ "frame": 170+ },+ {+ "identity": "segment:price:token:8:start",+ "timeSec": 7.083333333333333,+ "frame": 170+ },+ {+ "identity": "segment:price:token:8:end",+ "timeSec": 7.458333333333333,+ "frame": 179+ },+ {+ "identity": "segment:price:token:9:start",+ "timeSec": 7.583333333333333,+ "frame": 182+ },+ {+ "identity": "segment:price:token:9:end",+ "timeSec": 7.625,+ "frame": 183+ },+ {+ "identity": "segment:price:token:10:start",+ "timeSec": 7.625,+ "frame": 183+ },+ {+ "identity": "segment:price:token:10:end",+ "timeSec": 7.75,+ "frame": 186+ },+ {+ "identity": "segment:price:token:11:start",+ "timeSec": 7.75,+ "frame": 186+ },+ {+ "identity": "segment:price:token:11:end",+ "timeSec": 7.791666666666667,+ "frame": 187+ },+ {+ "identity": "segment:price:token:12:start",+ "timeSec": 8.166666666666666,+ "frame": 196+ },+ {+ "identity": "segment:price:token:12:end",+ "timeSec": 8.791666666666666,+ "frame": 211+ },+ {+ "identity": "segment:price:token:13:start",+ "timeSec": 8.833333333333334,+ "frame": 212+ },+ {+ "identity": "segment:price:token:13:end",+ "timeSec": 9.041666666666666,+ "frame": 217+ },+ {+ "identity": "segment:price:token:14:start",+ "timeSec": 9.041666666666666,+ "frame": 217+ },+ {+ "identity": "segment:price:token:14:end",+ "timeSec": 9.708333333333334,+ "frame": 233+ },+ {+ "identity": "segment:price:token:15:start",+ "timeSec": 9.75,+ "frame": 234+ },+ {+ "identity": "segment:price:token:15:end",+ "timeSec": 9.916666666666666,+ "frame": 238+ },+ {+ "identity": "segment:price:token:16:start",+ "timeSec": 9.916666666666666,+ "frame": 238+ },+ {+ "identity": "segment:price:token:16:end",+ "timeSec": 10.125,+ "frame": 243+ },+ {+ "identity": "segment:price:token:17:start",+ "timeSec": 10.125,+ "frame": 243+ },+ {+ "identity": "segment:price:token:17:end",+ "timeSec": 10.333333333333334,+ "frame": 248+ },+ {+ "identity": "segment:price:token:18:start",+ "timeSec": 10.333333333333334,+ "frame": 248+ },+ {+ "identity": "segment:price:token:18:end",+ "timeSec": 10.583333333333334,+ "frame": 254+ },+ {+ "identity": "segment:price:token:19:start",+ "timeSec": 10.583333333333334,+ "frame": 254+ },+ {+ "identity": "segment:price:token:19:end",+ "timeSec": 11.125,+ "frame": 267+ },+ {+ "identity": "segment:price:end",+ "timeSec": 11.125,+ "frame": 267+ },+ {+ "identity": "segment:rainbow:start",+ "timeSec": 11.125,+ "frame": 267+ },+ {+ "identity": "segment:rainbow:token:1:start",+ "timeSec": 11.166666666666666,+ "frame": 268+ },+ {+ "identity": "segment:rainbow:token:1:end",+ "timeSec": 11.5,+ "frame": 276+ },+ {+ "identity": "segment:rainbow:token:2:start",+ "timeSec": 11.5,+ "frame": 276+ },+ {+ "identity": "segment:rainbow:token:2:end",+ "timeSec": 11.541666666666666,+ "frame": 277+ },+ {+ "identity": "segment:rainbow:token:3:start",+ "timeSec": 11.625,+ "frame": 279+ },+ {+ "identity": "segment:rainbow:token:3:end",+ "timeSec": 11.75,+ "frame": 282+ },+ {+ "identity": "segment:rainbow:token:4:start",+ "timeSec": 11.875,+ "frame": 285+ },+ {+ "identity": "segment:rainbow:token:4:end",+ "timeSec": 11.916666666666666,+ "frame": 286+ },+ {+ "identity": "segment:rainbow:token:5:start",+ "timeSec": 11.916666666666666,+ "frame": 286+ },+ {+ "identity": "segment:rainbow:token:5:end",+ "timeSec": 12.083333333333334,+ "frame": 290+ },+ {+ "identity": "segment:rainbow:token:6:start",+ "timeSec": 12.25,+ "frame": 294+ },+ {+ "identity": "segment:rainbow:token:6:end",+ "timeSec": 12.291666666666666,+ "frame": 295+ },+ {+ "identity": "segment:rainbow:token:7:start",+ "timeSec": 12.291666666666666,+ "frame": 295+ },+ {+ "identity": "segment:rainbow:token:7:end",+ "timeSec": 13.041666666666666,+ "frame": 313+ },+ {+ "identity": "segment:rainbow:token:8:start",+ "timeSec": 13.083333333333334,+ "frame": 314+ },+ {+ "identity": "segment:rainbow:token:8:end",+ "timeSec": 13.291666666666666,+ "frame": 319+ },+ {+ "identity": "segment:rainbow:token:9:start",+ "timeSec": 13.291666666666666,+ "frame": 319+ },+ {+ "identity": "segment:rainbow:token:9:end",+ "timeSec": 13.666666666666666,+ "frame": 328+ },+ {+ "identity": "segment:rainbow:token:10:start",+ "timeSec": 13.666666666666666,+ "frame": 328+ },+ {+ "identity": "segment:rainbow:token:10:end",+ "timeSec": 13.791666666666666,+ "frame": 331+ },+ {+ "identity": "segment:rainbow:token:11:start",+ "timeSec": 13.791666666666666,+ "frame": 331+ },+ {+ "identity": "segment:rainbow:token:11:end",+ "timeSec": 13.833333333333334,+ "frame": 332+ },+ {+ "identity": "segment:rainbow:token:12:start",+ "timeSec": 13.833333333333334,+ "frame": 332+ },+ {+ "identity": "segment:rainbow:token:12:end",+ "timeSec": 14.041666666666666,+ "frame": 337+ },+ {+ "identity": "segment:rainbow:token:13:start",+ "timeSec": 14.375,+ "frame": 345+ },+ {+ "identity": "segment:rainbow:token:13:end",+ "timeSec": 14.583333333333334,+ "frame": 350+ },+ {+ "identity": "segment:rainbow:token:14:start",+ "timeSec": 14.583333333333334,+ "frame": 350+ },+ {+ "identity": "segment:rainbow:token:14:end",+ "timeSec": 15.166666666666666,+ "frame": 364+ },+ {+ "identity": "segment:rainbow:token:15:start",+ "timeSec": 15.416666666666666,+ "frame": 370+ },+ {+ "identity": "segment:rainbow:token:15:end",+ "timeSec": 15.625,+ "frame": 375+ },+ {+ "identity": "segment:rainbow:token:16:start",+ "timeSec": 15.666666666666666,+ "frame": 376+ },+ {+ "identity": "segment:rainbow:token:16:end",+ "timeSec": 15.833333333333334,+ "frame": 380+ },+ {+ "identity": "segment:rainbow:token:17:start",+ "timeSec": 15.833333333333334,+ "frame": 380+ },+ {+ "identity": "segment:rainbow:token:17:end",+ "timeSec": 15.875,+ "frame": 381+ },+ {+ "identity": "segment:rainbow:token:18:start",+ "timeSec": 16,+ "frame": 384+ },+ {+ "identity": "segment:rainbow:token:18:end",+ "timeSec": 16.166666666666668,+ "frame": 388+ },+ {+ "identity": "segment:rainbow:token:19:start",+ "timeSec": 16.166666666666668,+ "frame": 388+ },+ {+ "identity": "segment:rainbow:token:19:end",+ "timeSec": 16.583333333333332,+ "frame": 398+ },+ {+ "identity": "segment:rainbow:token:20:start",+ "timeSec": 16.666666666666668,+ "frame": 400+ },+ {+ "identity": "segment:rainbow:token:20:end",+ "timeSec": 17.166666666666668,+ "frame": 412+ },+ {+ "identity": "segment:rainbow:token:21:start",+ "timeSec": 17.166666666666668,+ "frame": 412+ },+ {+ "identity": "segment:rainbow:token:21:end",+ "timeSec": 18.75,+ "frame": 450+ },+ {+ "identity": "segment:rainbow:token:22:start",+ "timeSec": 18.791666666666668,+ "frame": 451+ },+ {+ "identity": "segment:rainbow:token:22:end",+ "timeSec": 18.875,+ "frame": 453+ },+ {+ "identity": "segment:rainbow:token:23:start",+ "timeSec": 18.875,+ "frame": 453+ },+ {+ "identity": "segment:rainbow:token:23:end",+ "timeSec": 19,+ "frame": 456+ },+ {+ "identity": "segment:rainbow:token:24:start",+ "timeSec": 19,+ "frame": 456+ },+ {+ "identity": "segment:rainbow:token:24:end",+ "timeSec": 19.041666666666668,+ "frame": 457+ },+ {+ "identity": "segment:rainbow:token:25:start",+ "timeSec": 19.166666666666668,+ "frame": 460+ },+ {+ "identity": "segment:rainbow:token:25:end",+ "timeSec": 19.208333333333332,+ "frame": 461+ },+ {+ "identity": "segment:rainbow:token:26:start",+ "timeSec": 19.291666666666668,+ "frame": 463+ },+ {+ "identity": "segment:rainbow:token:26:end",+ "timeSec": 19.708333333333332,+ "frame": 473+ },+ {+ "identity": "segment:rainbow:token:27:start",+ "timeSec": 19.75,+ "frame": 474+ },+ {+ "identity": "segment:rainbow:token:27:end",+ "timeSec": 19.958333333333332,+ "frame": 479+ },+ {+ "identity": "segment:rainbow:token:28:start",+ "timeSec": 19.958333333333332,+ "frame": 479+ },+ {+ "identity": "segment:rainbow:token:28:end",+ "timeSec": 20.083333333333332,+ "frame": 482+ },+ {+ "identity": "segment:rainbow:token:29:start",+ "timeSec": 20.083333333333332,+ "frame": 482+ },+ {+ "identity": "segment:rainbow:token:29:end",+ "timeSec": 20.125,+ "frame": 483+ },+ {+ "identity": "segment:rainbow:token:30:start",+ "timeSec": 20.125,+ "frame": 483+ },+ {+ "identity": "segment:rainbow:token:30:end",+ "timeSec": 20.333333333333332,+ "frame": 488+ },+ {+ "identity": "segment:rainbow:token:31:start",+ "timeSec": 20.458333333333332,+ "frame": 491+ },+ {+ "identity": "segment:rainbow:token:31:end",+ "timeSec": 20.666666666666668,+ "frame": 496+ },+ {+ "identity": "segment:rainbow:token:32:start",+ "timeSec": 20.666666666666668,+ "frame": 496+ },+ {+ "identity": "segment:rainbow:token:32:end",+ "timeSec": 21,+ "frame": 504+ },+ {+ "identity": "segment:rainbow:token:33:start",+ "timeSec": 21,+ "frame": 504+ },+ {+ "identity": "segment:rainbow:token:33:end",+ "timeSec": 21.125,+ "frame": 507+ },+ {+ "identity": "segment:rainbow:token:34:start",+ "timeSec": 21.125,+ "frame": 507+ },+ {+ "identity": "segment:rainbow:token:34:end",+ "timeSec": 21.375,+ "frame": 513+ },+ {+ "identity": "segment:rainbow:token:35:start",+ "timeSec": 21.375,+ "frame": 513+ },+ {+ "identity": "segment:rainbow:token:35:end",+ "timeSec": 21.5,+ "frame": 516+ },+ {+ "identity": "segment:rainbow:token:36:start",+ "timeSec": 21.541666666666668,+ "frame": 517+ },+ {+ "identity": "segment:rainbow:token:36:end",+ "timeSec": 21.625,+ "frame": 519+ },+ {+ "identity": "segment:rainbow:token:37:start",+ "timeSec": 21.75,+ "frame": 522+ },+ {+ "identity": "segment:rainbow:token:37:end",+ "timeSec": 22.208333333333332,+ "frame": 533+ },+ {+ "identity": "segment:rainbow:end",+ "timeSec": 22.208333333333332,+ "frame": 533+ },+ {+ "identity": "segment:payment:start",+ "timeSec": 22.208333333333332,+ "frame": 533+ },+ {+ "identity": "segment:payment:token:1:start",+ "timeSec": 22.25,+ "frame": 534+ },+ {+ "identity": "segment:payment:token:1:end",+ "timeSec": 22.416666666666668,+ "frame": 538+ },+ {+ "identity": "segment:payment:token:2:start",+ "timeSec": 22.416666666666668,+ "frame": 538+ },+ {+ "identity": "segment:payment:token:2:end",+ "timeSec": 22.625,+ "frame": 543+ },+ {+ "identity": "segment:payment:token:3:start",+ "timeSec": 22.625,+ "frame": 543+ },+ {+ "identity": "segment:payment:token:3:end",+ "timeSec": 22.833333333333332,+ "frame": 548+ },+ {+ "identity": "segment:payment:token:4:start",+ "timeSec": 22.958333333333332,+ "frame": 551+ },+ {+ "identity": "segment:payment:token:4:end",+ "timeSec": 23.083333333333332,+ "frame": 554+ },+ {+ "identity": "segment:payment:token:5:start",+ "timeSec": 23.083333333333332,+ "frame": 554+ },+ {+ "identity": "segment:payment:token:5:end",+ "timeSec": 23.166666666666668,+ "frame": 556+ },+ {+ "identity": "segment:payment:token:6:start",+ "timeSec": 23.458333333333332,+ "frame": 563+ },+ {+ "identity": "segment:payment:token:6:end",+ "timeSec": 23.666666666666668,+ "frame": 568+ },+ {+ "identity": "segment:payment:token:7:start",+ "timeSec": 23.708333333333332,+ "frame": 569+ },+ {+ "identity": "segment:payment:token:7:end",+ "timeSec": 23.75,+ "frame": 570+ },+ {+ "identity": "segment:payment:token:8:start",+ "timeSec": 23.75,+ "frame": 570+ },+ {+ "identity": "segment:payment:token:8:end",+ "timeSec": 23.916666666666668,+ "frame": 574+ },+ {+ "identity": "segment:payment:token:9:start",+ "timeSec": 24.041666666666668,+ "frame": 577+ },+ {+ "identity": "segment:payment:token:9:end",+ "timeSec": 24.291666666666668,+ "frame": 583+ },+ {+ "identity": "segment:payment:token:10:start",+ "timeSec": 24.291666666666668,+ "frame": 583+ },+ {+ "identity": "segment:payment:token:10:end",+ "timeSec": 24.291666666666668,+ "frame": 583+ },+ {+ "identity": "segment:payment:token:11:start",+ "timeSec": 24.416666666666668,+ "frame": 586+ },+ {+ "identity": "segment:payment:token:11:end",+ "timeSec": 24.666666666666668,+ "frame": 592+ },+ {+ "identity": "segment:payment:token:12:start",+ "timeSec": 25,+ "frame": 600+ },+ {+ "identity": "segment:payment:token:12:end",+ "timeSec": 25.458333333333332,+ "frame": 611+ },+ {+ "identity": "segment:payment:token:13:start",+ "timeSec": 25.5,+ "frame": 612+ },+ {+ "identity": "segment:payment:token:13:end",+ "timeSec": 25.583333333333332,+ "frame": 614+ },+ {+ "identity": "segment:payment:token:14:start",+ "timeSec": 25.666666666666668,+ "frame": 616+ },+ {+ "identity": "segment:payment:token:14:end",+ "timeSec": 26.041666666666668,+ "frame": 625+ },+ {+ "identity": "segment:payment:token:15:start",+ "timeSec": 26.041666666666668,+ "frame": 625+ },+ {+ "identity": "segment:payment:token:15:end",+ "timeSec": 26.208333333333332,+ "frame": 629+ },+ {+ "identity": "segment:payment:token:16:start",+ "timeSec": 26.208333333333332,+ "frame": 629+ },+ {+ "identity": "segment:payment:token:16:end",+ "timeSec": 26.333333333333332,+ "frame": 632+ },+ {+ "identity": "segment:payment:token:17:start",+ "timeSec": 26.333333333333332,+ "frame": 632+ },+ {+ "identity": "segment:payment:token:17:end",+ "timeSec": 27.041666666666668,+ "frame": 649+ },+ {+ "identity": "segment:payment:token:18:start",+ "timeSec": 27.083333333333332,+ "frame": 650+ },+ {+ "identity": "segment:payment:token:18:end",+ "timeSec": 27.125,+ "frame": 651+ },+ {+ "identity": "segment:payment:token:19:start",+ "timeSec": 27.125,+ "frame": 651+ },+ {+ "identity": "segment:payment:token:19:end",+ "timeSec": 27.291666666666668,+ "frame": 655+ },+ {+ "identity": "segment:payment:token:20:start",+ "timeSec": 27.416666666666668,+ "frame": 658+ },+ {+ "identity": "segment:payment:token:20:end",+ "timeSec": 27.958333333333332,+ "frame": 671+ },+ {+ "identity": "segment:payment:token:21:start",+ "timeSec": 28,+ "frame": 672+ },+ {+ "identity": "segment:payment:token:21:end",+ "timeSec": 28.083333333333332,+ "frame": 674+ },+ {+ "identity": "segment:payment:token:22:start",+ "timeSec": 28.166666666666668,+ "frame": 676+ },+ {+ "identity": "segment:payment:token:22:end",+ "timeSec": 28.583333333333332,+ "frame": 686+ },+ {+ "identity": "segment:payment:token:23:start",+ "timeSec": 28.583333333333332,+ "frame": 686+ },+ {+ "identity": "segment:payment:token:23:end",+ "timeSec": 28.916666666666668,+ "frame": 694+ },+ {+ "identity": "segment:payment:token:24:start",+ "timeSec": 28.916666666666668,+ "frame": 694+ },+ {+ "identity": "segment:payment:token:24:end",+ "timeSec": 29.291666666666668,+ "frame": 703+ },+ {+ "identity": "segment:payment:token:25:start",+ "timeSec": 29.291666666666668,+ "frame": 703+ },+ {+ "identity": "segment:payment:token:25:end",+ "timeSec": 29.291666666666668,+ "frame": 703+ },+ {+ "identity": "segment:payment:token:26:start",+ "timeSec": 29.291666666666668,+ "frame": 703+ },+ {+ "identity": "segment:payment:token:26:end",+ "timeSec": 29.375,+ "frame": 705+ },+ {+ "identity": "segment:payment:token:27:start",+ "timeSec": 29.375,+ "frame": 705+ },+ {+ "identity": "segment:payment:token:27:end",+ "timeSec": 29.666666666666668,+ "frame": 712+ },+ {+ "identity": "segment:payment:token:28:start",+ "timeSec": 29.666666666666668,+ "frame": 712+ },+ {+ "identity": "segment:payment:token:28:end",+ "timeSec": 30.083333333333332,+ "frame": 722+ },+ {+ "identity": "segment:payment:token:29:start",+ "timeSec": 30.125,+ "frame": 723+ },+ {+ "identity": "segment:payment:token:29:end",+ "timeSec": 30.125,+ "frame": 723+ },+ {+ "identity": "segment:payment:token:30:start",+ "timeSec": 30.333333333333332,+ "frame": 728+ },+ {+ "identity": "segment:payment:token:30:end",+ "timeSec": 30.708333333333332,+ "frame": 737+ },+ {+ "identity": "segment:payment:token:31:start",+ "timeSec": 30.708333333333332,+ "frame": 737+ },+ {+ "identity": "segment:payment:token:31:end",+ "timeSec": 31.041666666666668,+ "frame": 745+ },+ {+ "identity": "segment:payment:end",+ "timeSec": 31.291666666666668,+ "frame": 751+ }+ ]+}diff --git a/examples/talking-film-broll-preview/README.md b/examples/talking-film-broll-preview/README.mdnew file mode 100644index 00000000..4208d795--- /dev/null+++ b/examples/talking-film-broll-preview/README.md@@ -0,0 +1,36 @@+# talking-film-broll-preview++A vertical talking film with two B-roll inserts on one Media Track, written to be+read by the SVML Playground:++```bash+pnpm svml:playground -- --source examples/talking-film-broll-preview/main.svml+```++## What it demonstrates++**Two inserts, one Track.** `@claim` and `@proof` are disjoint Selections, so+`broll-one` and `broll-two` share a single timeline row the way an editor would+lay them out.++**Placement you can check by eye.** `card-a` and `card-b` differ in every+dimension, so a coordinate mistake is visible rather than accidentally correct.++**Frame versus content box.** `media.card` is rounded and padded; `media.wide` is+flush with a border. The Playground draws the Placement Frame and the painted+content box separately, and only the first Item has an inset.++**Motion.** `motion.card` slides in and fades out, so the box moves across the+first frames of `broll-one` and holds still for `broll-two`, which declares none.++## Frame edges++`<space:Frame>` takes `right` and `bottom` as absolute edge positions, not+insets. `card-a` spans `left="8%"` to `right="92%"` — 86.4px to 993.6px of a+1080px canvas.++## Building it++The Source is complete, so it builds like any other example once a Runtime+Profile and credentials are in place. Nothing here is required to preview it: the+Playground reads `main.svml` and `studio.svs` alone.diff --git a/examples/talking-film-broll-preview/main.svml b/examples/talking-film-broll-preview/main.svmlnew file mode 100644index 00000000..93964d35--- /dev/null+++ b/examples/talking-film-broll-preview/main.svml@@ -0,0 +1,55 @@+<?svml using="@narratage/markup@1"?>++<svml>+ <import from="@narratage/script@1"/>+ <import as="wording" from="@narratage/text@1"/>+ <import as="seedance" from="@narratage/seedance@1"/>+ <import as="speech" from="@narratage/speech-spine@1"/>+ <import as="whisperx" from="@narratage/whisperx@1"/>+ <import as="media-track" from="@narratage/media-track@1"/>+ <import as="space" from="@narratage/spatial@1"/>+ <import as="film" from="@narratage/film@1"/>+ <import as="render" from="@narratage/render-hyperframes@1"/>+ <import as="studio" source="./studio.svs"/>++ <script id="story">+ <opening><HOST>A @claim shallow preview reads the source directly@/claim, so the+ @proof timeline you scrub is the SVML itself@/proof, not a rendered file.</opening>+ </script>++ <space:Canvas id="vertical" width="1080" height="1920"/>+ <!-- right and bottom are edge positions, not insets: this Frame is full bleed. -->+ <space:Frame id="speech-frame" within={vertical}+ left="0%" top="0%" right="100%" bottom="100%"/>+ <space:Frame id="card-a" within={vertical}+ left="8%" top="16%" right="92%" bottom="46%"/>+ <space:Frame id="card-b" within={vertical}+ left="12%" top="52%" right="88%" bottom="78%"/>++ <wording:Value id="direction">Locked medium close-up in a quiet daylight studio. Spoken dialogue.</wording:Value>+ <seedance:TextVideo id="take" model="mini" prompt={direction} duration="10" generate-audio="true"/>+ <seedance:TextVideo id="motion-a" model="mini" prompt={direction} duration="5"/>+ <seedance:TextVideo id="motion-b" model="mini" prompt={direction} duration="5"/>++ <speech:Spine id="speech" frame-rate="30"+ visual-frame={speech-frame} visual-appearance={studio.speech.visual} visual-z="0">+ <speech:Take video={take.video} segment={story.segment.opening}/>+ </speech:Spine>+ <whisperx:Alignment id="timing" narrative={story} audio={speech.audio}/>++ <!-- Two B-roll inserts on one Track. Their Selections do not overlap, so they+ share a single timeline row the way an editor would lay them out. -->+ <media-track:Track id="broll" map={timing.map} space={speech.space} canvas={vertical}>+ <media-track:Item id="broll-one" video={motion-a.video} during={story.selection.claim}+ frame={card-a} appearance={studio.media.card} motion={studio.motion.card}/>+ <media-track:Item id="broll-two" video={motion-b.video} during={story.selection.proof}+ frame={card-b} appearance={studio.media.wide} motion={studio.motion.card}/>+ </media-track:Track>++ <film:Film id="main" canvas={vertical} space={speech.space} appearance={studio.film.vertical}>+ <film:Track source={speech.visual}/>+ <film:Track source={speech.audioTrack}/>+ <film:Track source={broll.visual}/>+ </film:Film>+ <render:Video id="final" composition={main.composition} space={speech.space}/>+</svml>diff --git a/examples/talking-film-broll-preview/studio.svs b/examples/talking-film-broll-preview/studio.svsnew file mode 100644index 00000000..08c1b268--- /dev/null+++ b/examples/talking-film-broll-preview/studio.svs@@ -0,0 +1,23 @@+<?svml using="@narratage/svs@1"?>++<sheet version="1">+ film.vertical { background: #09090B; }+ speech.visual { fit: cover; }++ /* Rounded and padded, so the painted content box is visibly inset from the+ Placement Frame the Playground draws as a guide. */+ media.card {+ stack-order: 40; fit: cover; playback: hold-start;+ frame-paint: #16161d; clip: rounded; radius: 24; padding: 12 12;+ }+ /* Square and flush, for contrast with media.card. */+ media.wide {+ stack-order: 41; fit: cover; playback: hold-start;+ frame-paint: #1d1620; clip: frame;+ border-width: 2; border-color: #ee7b6255;+ }+ motion.card {+ enter: slide; enter-frames: 5; enter-direction: up; enter-easing: ease-out;+ exit: fade; exit-frames: 5; exit-easing: ease-in;+ }+</sheet>diff --git a/package.json b/package.jsonindex a50afc20..b5697ad9 100644--- a/package.json+++ b/package.json@@ -18,6 +18,7 @@"smoke:kie": "node --import tsx packages/provider-kie/test/live-smoke.ts","narratage": "node --disable-warning=ExperimentalWarning --import tsx packages/video-cli/src/cli.ts","caption:playground": "pnpm --filter @narratage/caption-playground exec node --import tsx start.ts",+ "svml:playground": "pnpm --filter @narratage/svml-playground exec node --import tsx start.ts","build:media-lambda": "pnpm --filter @narratage/media-lambda build","build:media-lambda-layer": "pnpm --filter @narratage/media-lambda build:layer"},diff --git a/packages/video-domain/package.json b/packages/video-domain/package.jsonnew file mode 100644index 00000000..ab01d7a0--- /dev/null+++ b/packages/video-domain/package.json@@ -0,0 +1,33 @@+{+ "name": "@narratage/video-domain",+ "version": "0.0.0-dev",+ "license": "SEE LICENSE IN LICENSE",+ "private": true,+ "type": "module",+ "exports": {+ ".": "./src/index.ts"+ },+ "dependencies": {+ "@narratage/artifact": "workspace:*",+ "@narratage/component-kit": "workspace:*",+ "@narratage/composition": "workspace:*",+ "@narratage/core": "workspace:*",+ "@narratage/driver-node": "workspace:*",+ "@narratage/elaborator": "workspace:*",+ "@narratage/generation": "workspace:*",+ "@narratage/markup": "workspace:*",+ "@narratage/media": "workspace:*",+ "@narratage/narrative": "workspace:*",+ "@narratage/program-space": "workspace:*",+ "@narratage/protocol": "workspace:*",+ "@narratage/semantic-map": "workspace:*",+ "@narratage/spatial": "workspace:*",+ "@narratage/speech": "workspace:*",+ "@narratage/speech-alignment": "workspace:*",+ "@narratage/speech-basis": "workspace:*",+ "@narratage/speech-evidence": "workspace:*",+ "@narratage/temporal": "workspace:*",+ "@narratage/validation": "workspace:*",+ "@narratage/visual-ir": "workspace:*"+ }+}diff --git a/packages/video-domain/src/index.ts b/packages/video-domain/src/index.tsnew file mode 100644index 00000000..a86b928b--- /dev/null+++ b/packages/video-domain/src/index.ts@@ -0,0 +1,214 @@+/**+ * Every package a video Source may name, assembled into the registries a+ * compiler needs.+ *+ * Nothing here is new behaviour. Each package already declares its own Types,+ * Surfaces, Producers and Validators in its activation; this module only+ * collects them so a caller that is not the CLI - a test, or a preview - can+ * compile and execute a Source without a package lock, a filesystem scan or a+ * Provider.+ */++import { artifactManifest } from "@narratage/artifact";+import { compositionManifest } from "@narratage/composition";+import { mediaManifest } from "@narratage/media";+import { narrativeManifest } from "@narratage/narrative";+import { programSpaceManifest } from "@narratage/program-space";+import { semanticMapManifest } from "@narratage/semantic-map";+import { spatialManifest } from "@narratage/spatial";+import { speechManifest } from "@narratage/speech";+import { speechEvidenceManifest } from "@narratage/speech-evidence";+import { temporalManifest } from "@narratage/temporal";+import { generationManifest } from "@narratage/generation";+import { speechBasisManifest } from "@narratage/speech-basis";+import { speechAlignmentManifest } from "@narratage/speech-alignment";+import { visualIrManifest } from "@narratage/visual-ir";++import { existsSync, readdirSync, readFileSync } from "node:fs";+import { join, resolve } from "node:path";+import { pathToFileURL } from "node:url";++import { registerProducerFacets, registerTypeValidatorFacets } from "@narratage/component-kit";+import type { ComponentPackage } from "@narratage/component-kit";+import { createResolvedClosure } from "@narratage/core";+import { ProducerRegistry } from "@narratage/driver-node";+import {+ AuthorFrontendRegistry, installAuthorFrontendHostFacets,+} from "@narratage/elaborator";+import { createMarkupAuthorFrontend, installMarkupSurfaceHostFacets, MarkupSurfaceRegistry } from "@narratage/markup";+import type { MarkupSurfaceRegistryLike } from "@narratage/markup";+import type { ModuleManifest, ModuleRef, ResolvedModuleClosure } from "@narratage/protocol";+import { TypeValidatorRegistry } from "@narratage/validation";++/**+ * Types with no Surface of their own. A Source never writes these tags, but+ * every Type a Surface produces has to resolve against something.+ */+export const videoContractManifests = [+ artifactManifest,+ narrativeManifest,+ mediaManifest,+ programSpaceManifest,+ speechManifest,+ speechEvidenceManifest,+ semanticMapManifest,+ spatialManifest,+ temporalManifest,+ generationManifest,+ speechBasisManifest,+ speechAlignmentManifest,+ visualIrManifest,+ compositionManifest,+] as const;++/** The shape every package's `activation.ts` default-exports. */+export type VideoDomainPackage = {+ readonly name: string;+ readonly modules?: readonly {+ readonly manifest: ModuleManifest;+ /** Absent on packages a Source reaches through another module rather than by name. */+ readonly specifiers?: readonly string[];+ }[];+ readonly components?: readonly ComponentPackage[];+ readonly hostFacets?: readonly unknown[];+ /** The directory it was discovered in; an activation does not name itself. */+ readonly from?: string;+ /** Sources that are not markup, such as a Style Sheet. */+};++/**+ * Discover every installed package, the way the package loader does: each one+ * declares where its activation lives in its own `package.json`, so this list+ * is the workspace rather than a copy of it that can fall behind.+ */+async function discover(): Promise<readonly VideoDomainPackage[]> {+ if (discovered !== undefined) return discovered;+ const root = resolve(import.meta.dirname, "../..");+ const found: VideoDomainPackage[] = [];+ for (const entry of readdirSync(root, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {+ if (!entry.isDirectory()) continue;+ const manifestPath = join(root, entry.name, "package.json");+ if (!existsSync(manifestPath)) continue;+ const declared = JSON.parse(readFileSync(manifestPath, "utf8")) as {+ readonly svml?: { readonly activation?: string };+ };+ if (declared.svml?.activation === undefined) continue;+ const loaded = await import(pathToFileURL(join(root, entry.name, declared.svml.activation)).href) as+ { readonly default?: VideoDomainPackage };+ if (loaded.default !== undefined) found.push({ ...loaded.default, from: entry.name });+ }+ discovered = found;+ return found;+}++let discovered: readonly VideoDomainPackage[] | undefined;++/** Every package a Source may `<import from="...">`. */+export async function videoDomainPackages(): Promise<readonly VideoDomainPackage[]> {+ return await discover();+}++let cachedManifests: readonly ModuleManifest[] | undefined;++async function manifests(): Promise<readonly ModuleManifest[]> {+ const seen = new Map<string, ModuleManifest>();+ for (const manifest of videoContractManifests) seen.set(manifest.name, manifest);+ for (const item of await discover()) {+ for (const declared of item.modules ?? []) seen.set(declared.manifest.name, declared.manifest);+ }+ cachedManifests = [...seen.values()];+ return cachedManifests;+}++async function components(): Promise<readonly ComponentPackage[]> {+ // Every package that carries a Validator activates itself, so the discovery+ // scan is the whole list; keyed by where it was found, because two packages+ // may each contribute a Component at the same index.+ const seen = new Map<string, ComponentPackage>();+ for (const item of await discover()) {+ for (const [index, component] of (item.components ?? []).entries()) {+ seen.set(`${item.from}:${index}`, component);+ }+ }+ return [...seen.values()];+}++/** The Types every Source in this domain may name. */+export async function videoDomainClosure(): Promise<ResolvedModuleClosure> {+ return createResolvedClosure(await manifests());+}++/** The Surfaces that decode authored markup, keyed as the frontend looks them up. */+export async function videoDomainSurfaces(): Promise<MarkupSurfaceRegistry> {+ const registry = new MarkupSurfaceRegistry();+ for (const item of await discover()) {+ installMarkupSurfaceHostFacets((item.hostFacets ?? []) as never, registry);+ }+ return registry;+}++/**+ * Every Author Frontend a Source closure can reach: the markup frontend built+ * over the Surfaces above, plus the packages that read a Source of their own+ * rather than markup.+ */+export async function videoDomainFrontends(+ resolveModule: (request: { readonly from: string }) => ModuleRef,+ /**+ * The Surfaces the markup Frontend decodes with. A caller that wants to watch+ * a decode passes its own registry over the discovered one; the Frontend is+ * built the same way either way.+ */+ surfaces?: MarkupSurfaceRegistryLike,+): Promise<AuthorFrontendRegistry> {+ const registry = new AuthorFrontendRegistry();+ registry.register(createMarkupAuthorFrontend({+ registry: surfaces ?? await videoDomainSurfaces(), resolveModule,+ }) as never);+ // A Frontend travels as a Host Facet, the same way a Surface does, so a+ // package that publishes one is never asked to name it twice.+ for (const item of await discover()) {+ installAuthorFrontendHostFacets((item.hostFacets ?? []) as never, registry as never);+ }+ return registry;+}++/** The implementations behind every Producer a fragment can name. */+export async function videoDomainProducers(): Promise<ProducerRegistry> {+ const registry = new ProducerRegistry();+ for (const component of await components()) registerProducerFacets(registry, component.producers ?? []);+ return registry;+}++/** The checks a Record must pass before it is admitted. */+export async function videoDomainValidators(): Promise<TypeValidatorRegistry> {+ const registry = new TypeValidatorRegistry();+ for (const component of await components()) registerTypeValidatorFacets(registry, component.validators ?? []);+ return registry;+}++/**+ * Resolve an `<import from="...">` specifier to the module that declares it.+ * The specifiers are the ones each package publishes, so a Source that names a+ * module this domain does not carry fails by name rather than silently.+ */+export function videoDomainModule(specifier: string): ModuleRef | undefined {+ if (discovered === undefined) {+ throw new Error("videoDomainModule needs the domain discovered first; await videoDomainClosure().");+ }+ for (const item of discovered) {+ for (const declared of item.modules ?? []) {+ if ((declared.specifiers ?? []).includes(specifier)) {+ return { name: declared.manifest.name, version: declared.manifest.version };+ }+ }+ }+ // A Source may also name a contract module directly, to write a Type it holds+ // rather than a tag it declares.+ for (const manifest of cachedManifests ?? []) {+ if (specifier === manifest.name || specifier === `${manifest.name}@${manifest.version}`) {+ return { name: manifest.name, version: manifest.version };+ }+ }+ return undefined;+}diff --git a/packages/video-domain/test/compile.test.ts b/packages/video-domain/test/compile.test.tsnew file mode 100644index 00000000..77e270f3--- /dev/null+++ b/packages/video-domain/test/compile.test.ts@@ -0,0 +1,82 @@+import assert from "node:assert/strict";+import { createHash } from "node:crypto";+import { existsSync, readdirSync, readFileSync } from "node:fs";+import { dirname, join, resolve } from "node:path";+import test from "node:test";++import { compileSourceClosure } from "@narratage/elaborator";+import { createRecordAdmitter } from "@narratage/validation";++import {+ videoDomainClosure, videoDomainFrontends, videoDomainModule, videoDomainValidators,+} from "../src/index.js";++const examples = resolve(import.meta.dirname, "../../../examples");++async function compile(entryPath: string): Promise<unknown> {+ // Discovery has to run before a module can be resolved by name.+ const closure = await videoDomainClosure();+ return await compileSourceClosure({+ entry: { id: entryPath, name: "main.svml", text: readFileSync(entryPath, "utf8") },+ closure,+ frontends: await videoDomainFrontends((request) => {+ const found = videoDomainModule(request.from);+ if (found === undefined) throw new Error(`no module for ${request.from}`);+ return found;+ }),+ admitRecord: createRecordAdmitter(await videoDomainValidators()),+ resolveSource(importer: { id: string }, request: { from: string }) {+ const path = resolve(dirname(importer.id), request.from);+ return { id: path, name: request.from, text: readFileSync(path, "utf8") };+ },+ resolveAsset(importer: { id: string }, request: { from: string; mediaType: string; bytes?: Uint8Array }) {+ // A package Surface hands its own bytes over; an authored asset is a path+ // beside the Source.+ const bytes = request.bytes ?? readFileSync(resolve(dirname(importer.id), request.from));+ return {+ artifact: {+ kind: "blob" as const,+ digest: `sha256:${createHash("sha256").update(bytes).digest("hex")}`,+ size: bytes.byteLength,+ mediaType: request.mediaType,+ },+ };+ },+ } as never);+}++/**+ * Compile every committed example the way a build does.+ *+ * A Surface may only emit Types its manifest declares, and the frontend is the+ * only thing that checks. Two packages shipped Surfaces that emitted more than+ * they admitted, and nothing noticed because no Source here wrote those tags.+ * `all-components-preview` writes every kind of Track for exactly that reason.+ *+ * A Surface is only exercised when a real Source names it, so a package can+ * declare a tag whose Types or graph do not agree with what its handler emits+ * and nothing notices. This is the test that notices: it needs no Provider, no+ * lock and no filesystem beyond the example itself.+ */+for (const name of readdirSync(examples, { withFileTypes: true })+ .filter((entry) => entry.isDirectory())+ .map((entry) => entry.name)+ .sort()) {+ const entryPath = join(examples, name, "main.svml");+ if (!existsSync(entryPath)) continue;+ test(`the ${name} example compiles`, async (context) => {+ // Generated stills are deliberately not committed; the example READMEs say+ // to supply them. Absent material is not a compiler failure.+ const assets = join(examples, name, "assets");+ if (existsSync(join(examples, name, "README.md"))+ && readFileSync(entryPath, "utf8").includes("./assets/")+ && !existsSync(assets)) {+ context.skip(`${name} needs assets that are not committed`);+ return;+ }+ const compiled = await compile(entryPath) as {+ graph: { outputs: readonly unknown[] };+ };+ assert.ok(compiled.graph.outputs.length >= 0);+ });+}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 97aa922e..f371acbd 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -2708,6 +2708,72 @@ importers:specifier: workspace:*version: link:../workspace-fs-node+ packages/video-domain:+ dependencies:+ '@narratage/artifact':+ specifier: workspace:*+ version: link:../artifact+ '@narratage/component-kit':+ specifier: workspace:*+ version: link:../component-kit+ '@narratage/composition':+ specifier: workspace:*+ version: link:../composition+ '@narratage/core':+ specifier: workspace:*+ version: link:../core+ '@narratage/driver-node':+ specifier: workspace:*+ version: link:../driver-node+ '@narratage/elaborator':+ specifier: workspace:*+ version: link:../elaborator+ '@narratage/generation':+ specifier: workspace:*+ version: link:../generation+ '@narratage/markup':+ specifier: workspace:*+ version: link:../markup+ '@narratage/media':+ specifier: workspace:*+ version: link:../media+ '@narratage/narrative':+ specifier: workspace:*+ version: link:../narrative+ '@narratage/program-space':+ specifier: workspace:*+ version: link:../program-space+ '@narratage/protocol':+ specifier: workspace:*+ version: link:../protocol+ '@narratage/semantic-map':+ specifier: workspace:*+ version: link:../semantic-map+ '@narratage/spatial':+ specifier: workspace:*+ version: link:../spatial+ '@narratage/speech':+ specifier: workspace:*+ version: link:../speech+ '@narratage/speech-alignment':+ specifier: workspace:*+ version: link:../speech-alignment+ '@narratage/speech-basis':+ specifier: workspace:*+ version: link:../speech-basis+ '@narratage/speech-evidence':+ specifier: workspace:*+ version: link:../speech-evidence+ '@narratage/temporal':+ specifier: workspace:*+ version: link:../temporal+ '@narratage/validation':+ specifier: workspace:*+ version: link:../validation+ '@narratage/visual-ir':+ specifier: workspace:*+ version: link:../visual-ir+packages/visual-ir:dependencies:'@narratage/protocol':@@ -2845,6 +2911,111 @@ importers:specifier: 5.4.21version: 5.4.21(@types/[email protected])+ tools/svml-playground:+ dependencies:+ '@narratage/caption':+ specifier: workspace:*+ version: link:../../packages/caption+ '@narratage/caption-fine':+ specifier: workspace:*+ version: link:../../packages/caption-fine+ '@narratage/compiler-node':+ specifier: workspace:*+ version: link:../../packages/compiler-node+ '@narratage/component-kit':+ specifier: workspace:*+ version: link:../../packages/component-kit+ '@narratage/composition':+ specifier: workspace:*+ version: link:../../packages/composition+ '@narratage/core':+ specifier: workspace:*+ version: link:../../packages/core+ '@narratage/driver-node':+ specifier: workspace:*+ version: link:../../packages/driver-node+ '@narratage/elaborator':+ specifier: workspace:*+ version: link:../../packages/elaborator+ '@narratage/endpoint-kit':+ specifier: workspace:*+ version: link:../../packages/endpoint-kit+ '@narratage/estimate':+ specifier: workspace:*+ version: link:../../packages/estimate+ '@narratage/film':+ specifier: workspace:*+ version: link:../../packages/film+ '@narratage/fonts-open':+ specifier: workspace:*+ version: link:../../packages/fonts-open+ '@narratage/hyperframes':+ specifier: workspace:*+ version: link:../../packages/hyperframes+ '@narratage/markup':+ specifier: workspace:*+ version: link:../../packages/markup+ '@narratage/media':+ specifier: workspace:*+ version: link:../../packages/media+ '@narratage/media-track':+ specifier: workspace:*+ version: link:../../packages/media-track+ '@narratage/narrative':+ specifier: workspace:*+ version: link:../../packages/narrative+ '@narratage/program-space':+ specifier: workspace:*+ version: link:../../packages/program-space+ '@narratage/protocol':+ specifier: workspace:*+ version: link:../../packages/protocol+ '@narratage/provider-hyperframes-local':+ specifier: workspace:*+ version: link:../../packages/provider-hyperframes-local+ '@narratage/provider-media-local':+ specifier: workspace:*+ version: link:../../packages/provider-media-local+ '@narratage/provider-whisperx-local':+ specifier: workspace:*+ version: link:../../packages/provider-whisperx-local+ '@narratage/ranking':+ specifier: workspace:*+ version: link:../../packages/ranking+ '@narratage/run':+ specifier: workspace:*+ version: link:../../packages/run+ '@narratage/run-markup':+ specifier: workspace:*+ version: link:../../packages/run-markup+ '@narratage/runtime':+ specifier: workspace:*+ version: link:../../packages/runtime+ '@narratage/script':+ specifier: workspace:*+ version: link:../../packages/script+ '@narratage/semantic-map':+ specifier: workspace:*+ version: link:../../packages/semantic-map+ '@narratage/spatial':+ specifier: workspace:*+ version: link:../../packages/spatial+ '@narratage/svs':+ specifier: workspace:*+ version: link:../../packages/svs+ '@narratage/temporal':+ specifier: workspace:*+ version: link:../../packages/temporal+ '@narratage/validation':+ specifier: workspace:*+ version: link:../../packages/validation+ '@narratage/video-domain':+ specifier: workspace:*+ version: link:../../packages/video-domain+ vite:+ specifier: 5.4.21+ version: 5.4.21(@types/[email protected])+packages:'@algolia/[email protected]':diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yamlindex 5a5c8b48..57c27420 100644--- a/pnpm-workspace.yaml+++ b/pnpm-workspace.yaml@@ -2,3 +2,4 @@ packages:- packages/*- services/media-lambda- tools/caption-playground+ - tools/svml-playgrounddiff --git a/tools/svml-playground/README.md b/tools/svml-playground/README.mdnew file mode 100644index 00000000..f53ac2e3--- /dev/null+++ b/tools/svml-playground/README.md@@ -0,0 +1,90 @@+# SVML Playground++A read-only preview of one `.svml` Source: the code on the right, the picture+top-left, and a timeline bottom-left rendered from the Source itself.++```bash+pnpm svml:playground -- --source examples/talking-film-broll-preview/main.svml+# ➜ http://localhost:5179/+```++Optional: `--run <build.svrun>` to read material a Run Source already names, and+`--port <number>`.++Selecting works from any of the three panes and selects in all of them: click a+timeline clip, marked text in the source, or the picture itself. Lines that bind+a clip carry a coloured bar in the gutter.++A Segment encloses a Selection, which can enclose another. Each level has its+own colour, and an enclosing range stays outlined while an inner one is — the+nesting is what the markers are for. Everything the playhead is inside is+outlined as it passes, and clicking marked prose lands inside the marker you+clicked rather than at the start of whatever encloses it.++`Space` plays and pauses, `←` and `→` step a frame with `Shift` ten, `Home` and+`End` jump to the ends, `Esc` clears. The Speech Spine's material sounds during+playback; the speaker button turns it off.++## What it is for++Reading a Source as a timeline **before** anything has been generated. It answers+"where does this B-roll land, how long is it, and is the card in the right part+of the frame" without a Seedance generation, a WhisperX alignment, an FFmpeg+render or a headless browser.++It never writes. There is no route that can change what an author wrote, and no+form that edits a Recipe — that is the Caption Playground's job, not this one.++## What is real and what is estimated++Everything structural is real. Placement Frames, padding, stacking order, motion+and the Track layout are computed by the same functions the build calls, from the+Source and its style sheet.++**Timings prefer real things,** in this order, and the header badges say which+you are looking at:++1. A completed build in `.svml/state.sqlite` — its `timing.map` and+ `speech.space` replace the estimate outright, and its `final.video` becomes+ the picture.+2. A Run Source — `<file>` bound by `<satisfy>` is material you already have, so+ it can be the picture with no build at all.+3. The Script text — token windows from `@narratage/estimate`, the same+ delivery-density model the pipeline uses before generation.++Real cut points move once WhisperX has aligned real audio, so treat an estimated+timeline as a proportion, not a prediction. If a store is from a newer schema, or+its build never completed, the Playground falls back to estimates rather than+showing a measured timeline it cannot vouch for.++**Material degrades one element at a time.** A Take or an Item shows real frames+when its source already exists and already lives in the program's frame domain,+and a painted rectangle when it does not. Reading a file's frame rate needs+`ffprobe` on the path; without it every Item keeps its placeholder and says so. Normalizing footage of another frame+rate is the media pipeline's job and takes a real transcode, so the preview+refuses and says which file and why rather than quietly resampling.++## How it reads a Source++A shallow interpreter, not the compiler. It walks the authored markup with+`@narratage/markup`'s own parser and calls each package's own pure projection+functions — `frameFromEdges`, `appendSelectionMediaItem`, `finalizeMediaTrack`,+`projectMediaVisualTrack`. It never elaborates the graph, never resolves a+package lock, and never constructs a Host, so it runs on a directory containing+nothing but `main.svml` and `studio.svs`.++Interpreted: `<script>`, the Spatial Frames, `<speech:Spine>` and its Takes,+`<media-track:Track>` and its Items, `<fonts:Stack>`, `<caption-fine:Style>` and+`<caption-fine:Track>`, `<film:Film>` (for the clear colour), and `.svs` source+imports.++Everything else — every generation Surface, `<whisperx:Alignment>`, the+Typography Tracks, `<render:Video>` — is read, listed under "not projected",+and skipped. A Source is worth previewing even when most of+it is produced by Providers.++## A note on `<space:Frame>`++`right` and `bottom` are **absolute edge positions**, not insets. A Frame+spanning the middle 80% of its parent is `left="8%" right="92%"`, not+`left="8%" right="8%"` — the latter resolves to zero width and is rejected.diff --git a/tools/svml-playground/index.html b/tools/svml-playground/index.htmlnew file mode 100644index 00000000..c4e5044f--- /dev/null+++ b/tools/svml-playground/index.html@@ -0,0 +1,14 @@+<!doctype html>+<html lang="en">+ <head>+ <meta charset="utf-8" />+ <meta name="viewport" content="width=device-width,initial-scale=1" />+ <link rel="icon" href="data:," />+ <link rel="preconnect" href="https://fonts.googleapis.com" />+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />+ <link rel="stylesheet"+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@24,400,1,0&display=block" />+ <title>SVML Playground - Narratage</title>+ </head>+ <body><div id="app"></div><script type="module" src="/src/ui/main.ts"></script></body>+</html>diff --git a/tools/svml-playground/package.json b/tools/svml-playground/package.jsonnew file mode 100644index 00000000..8a1f01c8--- /dev/null+++ b/tools/svml-playground/package.json@@ -0,0 +1,42 @@+{+ "name": "@narratage/svml-playground",+ "version": "0.0.0-dev",+ "private": true,+ "type": "module",+ "dependencies": {+ "@narratage/caption": "workspace:*",+ "@narratage/caption-fine": "workspace:*",+ "@narratage/compiler-node": "workspace:*",+ "@narratage/component-kit": "workspace:*",+ "@narratage/composition": "workspace:*",+ "@narratage/core": "workspace:*",+ "@narratage/driver-node": "workspace:*",+ "@narratage/elaborator": "workspace:*",+ "@narratage/endpoint-kit": "workspace:*",+ "@narratage/estimate": "workspace:*",+ "@narratage/film": "workspace:*",+ "@narratage/fonts-open": "workspace:*",+ "@narratage/hyperframes": "workspace:*",+ "@narratage/markup": "workspace:*",+ "@narratage/media": "workspace:*",+ "@narratage/media-track": "workspace:*",+ "@narratage/narrative": "workspace:*",+ "@narratage/program-space": "workspace:*",+ "@narratage/protocol": "workspace:*",+ "@narratage/provider-hyperframes-local": "workspace:*",+ "@narratage/provider-media-local": "workspace:*",+ "@narratage/provider-whisperx-local": "workspace:*",+ "@narratage/ranking": "workspace:*",+ "@narratage/run": "workspace:*",+ "@narratage/run-markup": "workspace:*",+ "@narratage/runtime": "workspace:*",+ "@narratage/script": "workspace:*",+ "@narratage/semantic-map": "workspace:*",+ "@narratage/spatial": "workspace:*",+ "@narratage/svs": "workspace:*",+ "@narratage/temporal": "workspace:*",+ "@narratage/validation": "workspace:*",+ "@narratage/video-domain": "workspace:*",+ "vite": "5.4.21"+ }+}diff --git a/tools/svml-playground/src/pipeline/archive.ts b/tools/svml-playground/src/pipeline/archive.tsnew file mode 100644index 00000000..a35f07fd--- /dev/null+++ b/tools/svml-playground/src/pipeline/archive.ts@@ -0,0 +1,68 @@+/**+ * The record of what has already been made.+ *+ * A Source that reuses an accepted take names the Build it came from, not a+ * path, because a produced Artifact has an identity rather than a location. So+ * a preview that is to show those takes has to read the same archive a build+ * writes - opened read-only, because a preview may not change what was accepted.+ */+import {+ createRuntimeArchiveFromConfig, createRuntimeArtifactAccessFromConfig,+} from "@narratage/local/config";+import type { BuildState } from "@narratage/protocol";++export type Archive = {+ /** A prior Build by its authored id, or undefined when it is not on this machine. */+ readonly readBuild: (id: string) => Promise<BuildState | undefined>;+ /** A public output alias, resolved to the Logical Output it names. */+ readonly resolveOutput: (id: string, output: string) => Promise<string | undefined>;+ /** Bytes for an Artifact this archive holds. */+ readonly read: (digest: string) => Promise<Uint8Array | undefined>;+ readonly close: () => Promise<void>;+};++/**+ * Open the archive a Runtime profile points at. The profile is the only thing+ * that says where it lives, which is why it is the one extra argument a preview+ * needs to show produced material.+ */+export async function openArchive(profilePath: string, packageRoot: string): Promise<Archive> {+ const control = await createRuntimeArchiveFromConfig(profilePath, { packageRoot } as never);+ // Which Build accepted what, and the bytes behind it, are two stores now.+ const artifacts = await createRuntimeArtifactAccessFromConfig(profilePath, { packageRoot } as never);+ const seen = new Map<string, Awaited<ReturnType<typeof control.status>>>();+ const status = async (id: string): Promise<Awaited<ReturnType<typeof control.status>>> => {+ const held = seen.get(id);+ if (held !== undefined) return held;+ const fresh = await control.status(id);+ seen.set(id, fresh);+ return fresh;+ };+ return {+ async readBuild(id) {+ try {+ return (await status(id)).build?.state;+ } catch {+ // An archive that does not hold this Build is not a broken archive.+ return undefined;+ }+ },+ async resolveOutput(id, output) {+ try {+ const alias = (await status(id)).catalog?.aliases.find((item: { name: string }) => item.name === output);+ if (alias === undefined) return output;+ return alias.ref.kind === "logical-output" ? alias.ref.id : undefined;+ } catch {+ return undefined;+ }+ },+ async read(digest) {+ try {+ return await artifacts.readArtifact(digest as never) ?? undefined;+ } catch {+ return undefined;+ }+ },+ close: async () => { await artifacts.close(); await control.close(); },+ };+}diff --git a/tools/svml-playground/src/pipeline/caption-plan.ts b/tools/svml-playground/src/pipeline/caption-plan.tsnew file mode 100644index 00000000..ed9d0a6f--- /dev/null+++ b/tools/svml-playground/src/pipeline/caption-plan.ts@@ -0,0 +1,58 @@+/**+ * Provisional caption phrasing, for a Source nobody has planned yet.+ *+ * Deciding which words share a screen is a judgement, and the package that+ * makes it asks a model. A preview cannot, so it falls back to the plainest+ * rule there is - a fixed number of Atoms per cue, in the order they were+ * written - and says the phrasing is a stand-in rather than a plan.+ */++/** The words a Source declared as captionable, in display order. */+type DisplaySequence = {+ readonly id: string;+ readonly atoms: readonly { readonly id: string; readonly wordIds?: readonly string[] }[];+};++/** Which words each run covers, and in which Style. The Program decides this. */+type Program = {+ readonly runs: readonly {+ readonly id: string;+ readonly styleId: string;+ readonly wordIds: readonly string[];+ }[];+};++/** How many Atoms share a screen when nobody has decided. */+const ATOMS_PER_CUE = 3;++/**+ * One run over the whole sequence, cut every few Atoms.+ *+ * Every Atom appears exactly once and in order, so the captions say what the+ * Source says; only where the line breaks fall is invented.+ */+export function evenCaptionPlan(display: DisplaySequence, program: Program): unknown {+ const runs = program.runs.map((run) => {+ const words = new Set(run.wordIds);+ // An Atom belongs to the run that covers the words it holds, so the phrasing+ // never moves a word out of the Style the Program gave it.+ const own = display.atoms.filter((atom) => (atom.wordIds ?? []).some((id) => words.has(id)));+ const cues: { id: string; atomIds: string[]; fields: never[] }[] = [];+ for (let index = 0; index < own.length; index += ATOMS_PER_CUE) {+ const atoms = own.slice(index, index + ATOMS_PER_CUE);+ cues.push({+ id: `${run.id}:cue:${String(cues.length + 1).padStart(4, "0")}`,+ atomIds: atoms.map((atom) => atom.id),+ fields: [],+ });+ }+ return { id: run.id, styleId: run.styleId, cues };+ });+ return { runs };+}++/** Whether a sequence has anything to phrase at all. */+export function hasAtoms(value: unknown): value is DisplaySequence {+ const held = value as DisplaySequence | undefined;+ return Array.isArray(held?.atoms) && held.atoms.length > 0;+}diff --git a/tools/svml-playground/src/pipeline/compile.ts b/tools/svml-playground/src/pipeline/compile.tsnew file mode 100644index 00000000..5c25546b--- /dev/null+++ b/tools/svml-playground/src/pipeline/compile.ts@@ -0,0 +1,139 @@+/**+ * Compile a Source exactly as a build does.+ *+ * The preview reads nothing itself. Every tag is decoded by the package that+ * declares it, so what the preview shows is what a build would produce, and a+ * Source that will not build does not silently preview.+ */+import { createHash } from "node:crypto";+import { readFileSync } from "node:fs";+import { dirname, isAbsolute, relative, resolve } from "node:path";++import { compileSourceClosure, resolveCompiledSourceExport } from "@narratage/elaborator";+import type { Digest } from "@narratage/protocol";+import { createRecordAdmitter } from "@narratage/validation";+import {+ videoDomainClosure, videoDomainFrontends, videoDomainModule, videoDomainSurfaces,+ videoDomainValidators,+} from "@narratage/video-domain";++import { createObserver } from "./observe.js";+import type { Observations } from "./observe.js";++/** Bytes a Source named, kept so the preview can serve the exact file. */+export type ServedFile = { readonly mediaType: string; readonly bytes: Uint8Array };++export type CompiledSource = {+ readonly compiled: CompiledClosure;+ readonly observations: Observations;+ /** Assets the Source pulled in, by digest, ready to serve. */+ readonly served: ReadonlyMap<string, ServedFile>;+ /** Resolve a value the author named, such as `main.composition`. */+ readonly exportRef: (name: string) => string | undefined;+ /** Every export, so the preview can find what it needs by Type. */+ readonly exports: readonly { readonly name: string; readonly type: string; readonly ref: string }[];+};++type CompiledClosure = {+ readonly program: unknown;+ readonly elaboration: { readonly graph: { readonly id: string } };+ readonly exports: readonly {+ readonly name: string;+ readonly type: { readonly name: string };+ readonly ref: { readonly kind: string; readonly id: string };+ }[];+};++/** An error the author can act on, pointed at the tag that caused it. */+export class CompileFailure extends Error {+ readonly range: { readonly start: number; readonly end: number } | undefined;++ constructor(message: string, range?: { readonly start: number; readonly end: number }) {+ super(message);+ this.name = "CompileFailure";+ this.range = range;+ }+}++/** Whether a path sits inside a directory, rather than merely starting with it. */+function within(root: string, path: string): boolean {+ const inside = relative(root, path);+ return inside === "" || (!inside.startsWith("..") && !isAbsolute(inside));+}++function digestOfBytes(bytes: Uint8Array): Digest {+ return `sha256:${createHash("sha256").update(bytes).digest("hex")}`;+}++export async function compileSource(entryPath: string): Promise<CompiledSource> {+ const served = new Map<string, ServedFile>();+ // Everything a Source reads has to sit beside it, as it must in a build.+ const root = dirname(entryPath);+ const resolveModule = (request: { readonly from: string }) => {+ const found = videoDomainModule(request.from);+ if (found === undefined) {+ throw new CompileFailure(`No package in this preview declares ${request.from}.`);+ }+ return found;+ };+ // Discovery has to run before a module can be resolved by name.+ const closure = await videoDomainClosure();+ const observer = createObserver(await videoDomainSurfaces(), resolveModule);++ let compiled: CompiledClosure;+ try {+ compiled = await compileSourceClosure({+ entry: { id: entryPath, name: "main.svml", text: readFileSync(entryPath, "utf8") },+ closure,+ frontends: await videoDomainFrontends(resolveModule, observer.surfaces),+ admitRecord: createRecordAdmitter(await videoDomainValidators()),+ resolveSource(importer: { readonly id: string }, request: { readonly from: string }) {+ const path = resolve(dirname(importer.id), request.from);+ return { id: path, name: request.from, text: readFileSync(path, "utf8") };+ },+ resolveAsset(importer: { readonly id: string }, request: {+ readonly from: string;+ readonly mediaType: string;+ readonly bytes?: Uint8Array;+ }) {+ // A package Surface hands over its own bytes; an authored asset is a+ // path beside the Source, and a build will only read one that sits+ // inside the Source's own directory. Reading further would let the+ // preview show a Source no build would accept.+ if (request.bytes === undefined) {+ const asset = resolve(dirname(importer.id), request.from);+ if (!within(root, asset)) {+ throw new CompileFailure(+ `Source asset ${asset} is outside ${root}, so a build would refuse to read it.`,+ );+ }+ }+ const bytes = request.bytes ?? readFileSync(resolve(dirname(importer.id), request.from));+ const digest = digestOfBytes(bytes);+ served.set(digest, { mediaType: request.mediaType, bytes });+ return { artifact: { kind: "blob", digest, size: bytes.byteLength, mediaType: request.mediaType } };+ },+ } as never) as unknown as CompiledClosure;+ } catch (error) {+ const held = error as { message?: string; range?: { start: number; end: number } };+ // The tag that failed is the one the Surfaces were last handed.+ const last = observer.observations().placements.at(-1);+ throw new CompileFailure(held.message ?? String(error), held.range ?? last?.range);+ }++ const exports = compiled.exports.map((item) => ({+ name: item.name, type: item.type.name, ref: item.ref.id,+ }));+ return {+ compiled,+ observations: observer.observations(),+ served,+ exports,+ exportRef(name) {+ const found = exports.find((item) => item.name === name);+ return found?.ref;+ },+ };+}++export { resolveCompiledSourceExport };diff --git a/tools/svml-playground/src/pipeline/estimate.ts b/tools/svml-playground/src/pipeline/estimate.tsnew file mode 100644index 00000000..1f50bbbf--- /dev/null+++ b/tools/svml-playground/src/pipeline/estimate.ts@@ -0,0 +1,218 @@+/**+ * Provisional timings, for a Source nobody has recorded yet.+ *+ * When a Run Source carries measured timings the preview uses those and this+ * never runs. Otherwise every word still has to land somewhere, so each one is+ * given the time its own syllables would take at an ordinary delivery pace.+ * The identities and the rates are the packages' own - only the arithmetic that+ * spreads words across frames is here, and it is announced as an estimate+ * rather than presented as a measurement.+ */+import {+ countSpeechEstimateUnits, resolveSpeechEstimateLanguage, resolveSpeechEstimateRate,+ sealSpeechEstimatePolicy,+} from "@narratage/estimate";++/** The Narrative a Script sealed, as the preview reads it. */+type Narrative = {+ readonly segments: readonly {+ readonly id: string;+ readonly startAnchorId: string;+ readonly endAnchorId: string;+ }[];+ readonly tokens: readonly {+ readonly id: string;+ readonly segmentId: string;+ readonly startAnchorId: string;+ readonly endAnchorId: string;+ readonly text: string;+ }[];+};++export type EstimatedTiming = {+ readonly map: unknown;+ readonly space: unknown;+ readonly frameCount: number;+};++/**+ * Place every token, then close each Segment around the tokens it holds.+ *+ * Frames are accumulated from a running total rather than summed per token, so+ * rounding cannot drift across a long Script, and every token is given at least+ * one frame: a word that occupies no time cannot be pointed at.+ */+export function estimateTiming(+ narrative: Narrative,+ frameRate: { readonly numerator: number; readonly denominator: number },+ /**+ * Seconds a Segment's own material declares, when it declares any. A take+ * that says it is eight seconds long will be eight seconds long, so its words+ * belong across those eight seconds rather than across a guess at how fast+ * they might be read.+ */+ declared: ReadonlyMap<string, number> = new Map(),+): EstimatedTiming {+ const perSecond = frameRate.numerator / frameRate.denominator;+ // Ordinary delivery, with the clamps a whole-utterance estimate would apply+ // turned off: each word is placed on its own here.+ const policy = sealSpeechEstimatePolicy({+ language: "auto", pace: "normal",+ rounding: "none", minimumSec: 0, maximumSec: Number.MAX_SAFE_INTEGER,+ } as never);+ const spoken = narrative.tokens.map((token) => token.text).join(" ");+ const language = resolveSpeechEstimateLanguage(spoken, "auto" as never);+ const rate = resolveSpeechEstimateRate(policy as never, language);++ const anchors: { identity: string; frame: number }[] = [];+ // Anchors are how a marker addresses time, but a consumer that reads a window+ // over words - a Caption, say - reads the token ranges, so both are placed.+ const timed: {+ tokenId: string; segmentId: string;+ startFrame: number; endFrameExclusive: number;+ }[] = [];+ const at = new Map<string, number>();+ let seconds = 0;+ let frame = 0;+ const place = (identity: string, value: number): void => {+ at.set(identity, value);+ anchors.push({ identity, frame: value });+ };++ const bounds = new Map<string, { first: number; last: number }>();+ for (const token of narrative.tokens) {+ const began = frame;+ place(token.startAnchorId, began);+ const units = countSpeechEstimateUnits(token.text, language);+ // Punctuation carries no syllables and still occupies the frame it is on.+ seconds += Math.max(1 / perSecond, units / rate);+ frame = Math.max(began + 1, Math.round(seconds * perSecond));+ place(token.endAnchorId, frame);+ timed.push({+ tokenId: token.id, segmentId: token.segmentId,+ startFrame: began, endFrameExclusive: frame,+ });+ const held = bounds.get(token.segmentId);+ bounds.set(token.segmentId, { first: held?.first ?? began, last: frame });+ }++ // A Segment opens where its first word does and closes where its last one+ // ends, so a Segment with no words at all still spans nothing rather than+ // spanning the programme.+ for (const segment of narrative.segments) {+ const held = bounds.get(segment.id) ?? { first: frame, last: frame };+ if (!at.has(segment.startAnchorId)) place(segment.startAnchorId, held.first);+ if (!at.has(segment.endAnchorId)) place(segment.endAnchorId, held.last);+ }+ if (declared.size > 0) {+ return stretched(narrative, frameRate, anchors, timed, declared);+ }+ const frameCount = Math.max(1, frame);+ return {+ map: { tokens: timed, anchors },+ space: {+ durationSec: frameCount * frameRate.denominator / frameRate.numerator,+ frameRate: { ...frameRate },+ },+ frameCount,+ };+}++/**+ * Fit the guess to what the Source already knows.+ *+ * Word durations are a proportion, not a prediction: a syllable model says+ * which word takes longer than which, and nothing about how fast this speaker+ * talks. Where the material declares a length, that length is the truth, so+ * each Segment's words are stretched across it and the Segments laid end to+ * end. What is preserved is the shape of the speech; what is replaced is a+ * pace nobody claimed.+ */+function stretched(+ narrative: Narrative,+ frameRate: { readonly numerator: number; readonly denominator: number },+ anchors: readonly { identity: string; frame: number }[],+ timed: readonly {+ tokenId: string; segmentId: string;+ startFrame: number; endFrameExclusive: number;+ }[],+ declared: ReadonlyMap<string, number>,+): EstimatedTiming {+ const perSecond = frameRate.numerator / frameRate.denominator;+ const guessed = new Map<string, { first: number; last: number }>();+ for (const token of timed) {+ const held = guessed.get(token.segmentId);+ guessed.set(token.segmentId, {+ first: Math.min(held?.first ?? token.startFrame, token.startFrame),+ last: Math.max(held?.last ?? token.endFrameExclusive, token.endFrameExclusive),+ });+ }++ // Each Segment takes the length its material declares, or the length it was+ // guessed at when nothing declares one.+ const span = new Map<string, { from: number; scale: number }>();+ let cursor = 0;+ for (const segment of narrative.segments) {+ const held = guessed.get(segment.id);+ const natural = held === undefined ? 0 : held.last - held.first;+ const wanted = declared.has(segment.id)+ ? Math.max(1, Math.round(declared.get(segment.id)! * perSecond))+ : natural;+ span.set(segment.id, {+ from: cursor,+ scale: natural === 0 ? 0 : wanted / natural,+ });+ cursor += wanted;+ }++ const moved = new Map<string, number>();+ const at = (segmentId: string, frame: number): number => {+ const held = span.get(segmentId);+ const start = guessed.get(segmentId)?.first ?? 0;+ if (held === undefined) return frame;+ return Math.round(held.from + (frame - start) * held.scale);+ };++ const placedTokens = timed.map((token) => {+ const startFrame = at(token.segmentId, token.startFrame);+ const endFrameExclusive = Math.max(startFrame + 1, at(token.segmentId, token.endFrameExclusive));+ moved.set(`${token.tokenId}:start`, startFrame);+ moved.set(`${token.tokenId}:end`, endFrameExclusive);+ return {+ tokenId: token.tokenId, segmentId: token.segmentId,+ startFrame, endFrameExclusive,+ };+ });++ const byToken = new Map(narrative.tokens.map((token) => [token.id, token]));+ const placedAnchors = anchors.map((anchor) => {+ const token = narrative.tokens.find((item) =>+ item.startAnchorId === anchor.identity || item.endAnchorId === anchor.identity);+ if (token !== undefined) {+ const edge = token.startAnchorId === anchor.identity ? "start" : "end";+ const frame = moved.get(`${token.id}:${edge}`) ?? anchor.frame;+ return { identity: anchor.identity, frame };+ }+ // A Segment's own edges close around the words it holds.+ const segment = narrative.segments.find((item) =>+ item.startAnchorId === anchor.identity || item.endAnchorId === anchor.identity);+ if (segment === undefined) return anchor;+ const held = span.get(segment.id);+ const own = placedTokens.filter((item) => item.segmentId === segment.id);+ const frame = segment.startAnchorId === anchor.identity+ ? own[0]?.startFrame ?? held?.from ?? anchor.frame+ : own.at(-1)?.endFrameExclusive ?? held?.from ?? anchor.frame;+ return { identity: anchor.identity, frame };+ });+ void byToken;++ const frameCount = Math.max(1, cursor);+ return {+ map: { tokens: placedTokens, anchors: placedAnchors },+ space: {+ durationSec: frameCount * frameRate.denominator / frameRate.numerator,+ frameRate: { ...frameRate },+ },+ frameCount,+ };+}diff --git a/tools/svml-playground/src/pipeline/execute.ts b/tools/svml-playground/src/pipeline/execute.tsnew file mode 100644index 00000000..f0097936--- /dev/null+++ b/tools/svml-playground/src/pipeline/execute.ts@@ -0,0 +1,85 @@+/**+ * Run a planned build with whatever this machine can actually serve.+ *+ * A preview is a Host like any other: it registers the Providers it has and+ * says plainly which Capabilities it cannot answer. Nothing here knows what a+ * Capability means - the Providers declare what they fulfil, and a Need nobody+ * can fulfil is reported rather than faked.+ */+import { EndpointRegistry, MemoryArtifactStore, NodeDriver } from "@narratage/driver-node";+import type { EndpointPackage } from "@narratage/endpoint-kit";+import type { ArtifactStore } from "@narratage/runtime";+import type { BuildState } from "@narratage/protocol";+import { createLocalHyperframesProvider } from "@narratage/provider-hyperframes-local";+import { createLocalMediaProvider } from "@narratage/provider-media-local";+import { createLocalWhisperXProvider } from "@narratage/provider-whisperx-local";+import { videoDomainProducers, videoDomainValidators } from "@narratage/video-domain";++/** A Capability no Provider on this machine could answer. */+export type Unserved = { readonly capability: string; readonly count: number };++export type Executed = {+ readonly state: BuildState;+ readonly status: string;+ readonly unserved: readonly Unserved[];+ /** Producers that threw, with what they said. */+ readonly errors: readonly string[];+ readonly outcomes: readonly { readonly status: string; readonly message?: string }[];+};++/**+ * The Providers a developer's own machine can run. They are the same ones a+ * local build uses, so a picture the preview draws is a picture that renders.+ */+function localProviders(): readonly EndpointPackage[] {+ const built: EndpointPackage[] = [];+ for (const create of [+ () => createLocalMediaProvider({ instance: "media.local", authority: "media.local" }),+ () => createLocalHyperframesProvider({ instance: "hyperframes.local", authority: "hyperframes.local" }),+ () => createLocalWhisperXProvider({ instance: "whisperx.local", authority: "whisperx.local" }),+ ]) {+ // A Provider whose tool is not installed is simply one the preview does+ // not have, which is the same as any other unserved Capability.+ try { built.push(create()); } catch { continue; }+ }+ return built;+}++async function endpoints(): Promise<EndpointRegistry> {+ const registry = new EndpointRegistry();+ // Each Provider installs the Capabilities it declares. The preview names+ // none of them, so a Provider that grows a Capability grows the preview too.+ for (const provider of localProviders()) {+ await provider.install(registry);+ }+ return registry;+}++export async function execute(planned: BuildState, artifacts: ArtifactStore): Promise<Executed> {+ const result = await new NodeDriver({+ producers: await videoDomainProducers(),+ validators: await videoDomainValidators(),+ endpoints: await endpoints(),+ artifacts,+ }).run(planned);++ // A Need that was answered stays on the state, so what is unserved is what+ // the driver could not move past.+ const counts = new Map<string, number>();+ for (const item of result.blocked) {+ const need = result.state.needs.find((candidate) => item.subject.includes(candidate.capability.name));+ const name = need?.capability.name ?? item.subject;+ counts.set(name, (counts.get(name) ?? 0) + 1);+ }+ return {+ state: result.state,+ status: result.status,+ unserved: [...counts].map(([capability, count]) => ({ capability, count })),+ outcomes: result.outcomes as never,+ errors: result.outcomes+ .filter((entry: { status: string }) => entry.status === "error")+ .map((entry: { message?: string }) => entry.message ?? "a Producer failed without saying why"),+ };+}++export { MemoryArtifactStore };diff --git a/tools/svml-playground/src/pipeline/observe.ts b/tools/svml-playground/src/pipeline/observe.tsnew file mode 100644index 00000000..12e6b522--- /dev/null+++ b/tools/svml-playground/src/pipeline/observe.ts@@ -0,0 +1,220 @@+/**+ * Watch a compile without changing it.+ *+ * A preview has to point at the words that produced a picture, and the compiler+ * does not carry that: an element's source range reaches its Surface and is+ * dropped when the Records it returns are sealed. Rather than decode the Source+ * a second time, both decorators here delegate to the real implementation and+ * keep what passes through.+ */+import type {+ MarkupSurfaceRegistryLike, RegisteredSurface, StructuredElement, SurfaceDecodeOutput,+} from "@narratage/markup";+import type { ModuleRef } from "@narratage/protocol";+import { parseScript } from "@narratage/script";++import type { Range } from "../shared.js";++/** One authored element, where it was written, and what it produced. */+export type Placement = {+ readonly tag: string;+ readonly id?: string;+ readonly range: Range;+ /** Records this element sealed, so a value can be traced back to its tag. */+ readonly records: readonly string[];+ /** Graph outputs this element declared, named as the author would write them. */+ readonly outputs: readonly string[];+ /** Children the author wrote inside it, so a Clip can point at its own tag. */+ readonly children: readonly {+ readonly tag: string;+ readonly id?: string;+ readonly range: Range;+ /** What the child itself points at, which is how it is placed. */+ readonly references: readonly string[];+ }[];+ /** What the author wrote on it: plain text as written, references by path. */+ readonly attributes: Readonly<Record<string, string>>;+ /** Paths this element and its children reference, in the order written. */+ readonly references: readonly string[];+};++export type Observations = {+ readonly placements: readonly Placement[];+ /** Whatever the Surfaces mapped back onto the Source, such as a Script's markers. */+ readonly sourceMaps: readonly Record<string, unknown>[];+};++export type Observer = {+ readonly surfaces: MarkupSurfaceRegistryLike;+ readonly frontend: <T extends { readonly id: string }>(frontend: T) => T;+ readonly observations: () => Observations;+};++/**+ * Wrap the Surface registry and the markup Frontend a compile will use.+ *+ * Neither wrapper decides anything: the Surface still decodes the element and+ * the Frontend still decodes the Source. Only the positions they discard are+ * kept, which is why this stays correct as packages change.+ */+/** Attributes the author wrote as plain text, by name. */+function written(element: StructuredElement): Record<string, string> {+ const held: Record<string, string> = {};+ for (const [name, value] of Object.entries(element.attributes)) {+ if (typeof value === "string") held[name] = value;+ }+ return held;+}++/** Every whole-value reference an element points at, in written order. */+function referenced(element: StructuredElement): string[] {+ return Object.values(element.attributes)+ .filter((value): value is { kind: "reference"; path: string } =>+ typeof value === "object" && value !== null+ && (value as { kind?: string }).kind === "reference")+ .map((value) => value.path);+}++export function createObserver(+ surfaces: MarkupSurfaceRegistryLike,+ resolveModule: (request: { readonly from: string }) => ModuleRef,+): Observer {+ const placements: Placement[] = [];+ const sourceMaps: Record<string, unknown>[] = [];++ // A Frontend may reach a Surface by name or by walking a module's whole list,+ // so both ways in are wrapped: an unwatched Surface decodes silently and the+ // preview loses the tag that placed the picture.+ const watch = (found: RegisteredSurface | undefined): RegisteredSurface | undefined => {+ // A raw Surface parses its own body and reports its own positions, so+ // there is nothing here to recover.+ if (found === undefined) return found;+ if (found.mode !== "structured") {+ const raw = found.handler as (input: RawInput) => unknown;+ return {+ ...found,+ async handler(input: RawInput) {+ const output = await raw(input);+ harvestScript(input, sourceMaps);+ return output;+ },+ } as RegisteredSurface;+ }+ const handler = found.handler as (input: { element: StructuredElement }) => unknown;+ return {+ ...found,+ async handler(input: { element: StructuredElement }) {+ const output = await handler(input) as SurfaceDecodeOutput;+ const id = input.element.attributes.id;+ placements.push({+ tag: input.element.name,+ ...(typeof id === "string" ? { id } : {}),+ range: { start: input.element.range.start, end: input.element.range.end },+ records: output.records.map((record) => record.id),+ outputs: output.components.flatMap((component) => Object.values(component.outputs)),+ attributes: written(input.element),+ references: [+ ...referenced(input.element),+ ...input.element.children+ .filter((child): child is StructuredElement => child.kind === "element")+ .flatMap(referenced),+ ],+ children: input.element.children+ .filter((child): child is StructuredElement => child.kind === "element")+ .map((child) => {+ const childId = child.attributes.id;+ return {+ tag: child.name,+ ...(typeof childId === "string" ? { id: childId } : {}),+ range: { start: child.range.start, end: child.range.end },+ references: referenced(child),+ };+ }),+ });+ return output;+ },+ } as RegisteredSurface;+ };++ const watchedSurfaces: MarkupSurfaceRegistryLike = {+ surfaces(module) {+ return surfaces.surfaces(module).map((found) => watch(found)!) as readonly RegisteredSurface[];+ },+ resolve(module, surface) { return watch(surfaces.resolve(module, surface)); },+ };++ return {+ surfaces: watchedSurfaces,+ frontend<T extends { readonly id: string }>(frontend: T): T { return frontend; },+ observations: () => ({ placements, sourceMaps }),+ };+}++/** The Frontend registry a compile is handed, with every Frontend observed. */+export function observeFrontends<R extends { resolve(id: string): unknown }>(+ registry: R,+ observer: Observer,+): R {+ return {+ resolve(id: string) {+ const frontend = registry.resolve(id) as { readonly id: string } | undefined;+ return frontend === undefined ? undefined : observer.frontend(frontend);+ },+ } as unknown as R;+}++/** What a raw Surface is handed: the whole Source and where its body begins. */+type RawInput = {+ readonly sourceName: string;+ readonly source: string;+ readonly tag: string;+ readonly openingStart: number;+ readonly contentStart: number;+ readonly attributes: Readonly<Record<string, unknown>>;+};++/**+ * Where a Script wrote its markers.+ *+ * The compiler carries no Source map, and a Script is a raw Surface that parses+ * its own body, so the same parser is asked again for the one thing the compile+ * discards: the offsets. Nothing is decoded here that the package does not+ * decode itself.+ */+function harvestScript(input: RawInput, into: Record<string, unknown>[]): void {+ if (input.tag.split(":").at(-1) !== "script") return;+ const id = input.attributes.id;+ if (typeof id !== "string") return;+ const closing = `</${input.tag}>`;+ const end = input.source.indexOf(closing, input.contentStart);+ if (end < 0) return;+ try {+ const parsed = parseScript(+ input.sourceName,+ input.source.slice(input.contentStart, end),+ input.contentStart,+ );+ into.push({+ format: "svml.script-source-map@1",+ record: id,+ range: { start: input.openingStart, end: end + closing.length },+ segments: parsed.segments.map((segment) => ({ id: segment.id, range: segment.range })),+ selections: parsed.selections.map((selection) => ({+ id: selection.id,+ occurrences: selection.occurrences.map((held) => ({+ occurrence: held.occurrence, open: held.open.range, close: held.close.range,+ })),+ })),+ moments: parsed.moments.map((moment) => ({+ id: moment.id,+ occurrences: moment.occurrences.map((held) => ({+ occurrence: held.occurrence, range: held.range,+ })),+ })),+ tokens: parsed.tokens.map((token) => ({ id: token.id, range: token.range })),+ });+ } catch {+ // A Script the parser refuses is a Source that will not compile either, and+ // the compile is what should report it.+ }+}diff --git a/tools/svml-playground/src/pipeline/placeholder.ts b/tools/svml-playground/src/pipeline/placeholder.tsnew file mode 100644index 00000000..e8a71d82--- /dev/null+++ b/tools/svml-playground/src/pipeline/placeholder.ts@@ -0,0 +1,89 @@+/**+ * Stand-in footage, so a Source can be seen before anything has been shot.+ *+ * A Track cannot be built without the material it places, and refusing to draw+ * anything until every shot exists would make the preview useless for the part+ * of the work it is meant for. So material nobody has supplied becomes a black+ * frame of the right shape - announced as a placeholder, never as footage.+ */+import { execFileSync } from "node:child_process";+import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";+import { tmpdir } from "node:os";+import { join } from "node:path";++export type Placeholder = { readonly bytes: Uint8Array; readonly mediaType: string };++/** One black stand-in per shape and length, since each costs an ffmpeg run. */+const cache = new Map<string, Placeholder | null>();++/**+ * A picture the Source already points at, held for as long as the shot it+ * stands in for. A reference frame is not the take, but it is the right subject+ * in the right shape, which is what makes a preview worth looking at before+ * anything has been generated.+ */+export function heldPicture(+ bytes: Uint8Array,+ seconds: number,+ frameRate: { readonly numerator: number; readonly denominator: number },+ size: { readonly width: number; readonly height: number },+): Placeholder | undefined {+ const directory = mkdtempSync(join(tmpdir(), "svml-playground-held-"));+ const source = join(directory, "reference");+ const path = join(directory, "held.mp4");+ writeFileSync(source, bytes);+ try {+ execFileSync("ffmpeg", [+ "-v", "error", "-y",+ "-loop", "1", "-i", source,+ "-f", "lavfi", "-i", "anullsrc=channel_layout=stereo:sample_rate=48000",+ "-t", String(Math.max(1, seconds)),+ "-r", `${frameRate.numerator}/${frameRate.denominator}`,+ "-vf", `scale=${size.width}:${size.height}:force_original_aspect_ratio=increase,`+ + `crop=${size.width}:${size.height},setsar=1`,+ "-shortest", "-c:v", "libx264", "-pix_fmt", "yuv420p", "-c:a", "aac", path,+ ], { timeout: 120_000 });+ return { bytes: readFileSync(path), mediaType: "video/mp4" };+ } catch {+ // Without ffmpeg there is no stand-in of any kind, which the caller already+ // handles by leaving the material unsupplied.+ return undefined;+ } finally {+ rmSync(directory, { recursive: true, force: true });+ }+}++/**+ * Black at the Source's own frame rate, with silence, for as long as the shot+ * it stands in for declares. A stand-in of the wrong length would make the+ * timeline disagree with the picture about how long the programme is.+ */+export function blackFrames(+ frameRate: { readonly numerator: number; readonly denominator: number },+ size: { readonly width: number; readonly height: number },+ seconds: number,+): Placeholder | undefined {+ const key = `${frameRate.numerator}/${frameRate.denominator}:${size.width}x${size.height}:${seconds}`;+ const kept = cache.get(key);+ if (kept !== undefined) return kept ?? undefined;+ const directory = mkdtempSync(join(tmpdir(), "svml-playground-black-"));+ const path = join(directory, "black.mp4");+ const rate = `${frameRate.numerator}/${frameRate.denominator}`;+ try {+ execFileSync("ffmpeg", [+ "-v", "error", "-y",+ "-f", "lavfi", "-i",+ `color=c=black:s=${size.width}x${size.height}:r=${rate}:d=${Math.max(1, seconds)}`,+ "-f", "lavfi", "-i", "anullsrc=channel_layout=stereo:sample_rate=48000",+ "-shortest", "-c:v", "libx264", "-pix_fmt", "yuv420p", "-c:a", "aac", path,+ ], { timeout: 60_000 });+ cache.set(key, { bytes: readFileSync(path), mediaType: "video/mp4" });+ } catch {+ // No ffmpeg, so there is no stand-in either, and the Tracks that needed+ // material will say what they were waiting for.+ cache.set(key, null);+ } finally {+ rmSync(directory, { recursive: true, force: true });+ }+ return cache.get(key) ?? undefined;+}diff --git a/tools/svml-playground/src/pipeline/preview.ts b/tools/svml-playground/src/pipeline/preview.tsnew file mode 100644index 00000000..1131715a--- /dev/null+++ b/tools/svml-playground/src/pipeline/preview.ts@@ -0,0 +1,581 @@+/**+ * Build the pictures a Source describes, with whatever it has been given.+ *+ * A preview asks for Tracks rather than for a film: a Track that cannot be+ * built costs only itself, so a Source waiting on one Provider still shows+ * everything else. Which Tracks exist is a question the packages answer - the+ * preview asks for every export that is a Track and knows nothing else about+ * them.+ */+import { createHash } from "node:crypto";++import { createProvidedCandidate } from "@narratage/run";+import { videoDomainClosure, videoDomainValidators } from "@narratage/video-domain";+import { validateValue } from "@narratage/validation";++import { compileSource } from "./compile.js";+import type { CompiledSource, ServedFile } from "./compile.js";+import type { Placement } from "./observe.js";+import { evenCaptionPlan, hasAtoms } from "./caption-plan.js";+import { estimateTiming } from "./estimate.js";+import { blackFrames, heldPicture } from "./placeholder.js";+import type { Placeholder } from "./placeholder.js";+import { execute, MemoryArtifactStore } from "./execute.js";+import type { Archive } from "./archive.js";+import { applyRunSource, emptyRun } from "./run-source.js";+import type { Refusal, RunPlan } from "./run-source.js";++/** Types the preview can play. Anything else is a value, not a picture. */+const PLAYABLE = new Set(["VisualTrack", "AudioTrack"]);+/** The timings every Track is placed against. */+const TIMING = "CompleteSemanticMap";+const SPACE = "ProgramSpace";+/** Material a Source names but nobody has supplied. */+const MATERIAL = "BlobArtifact";+/** Which words share a screen. A model decides this; a preview cannot. */+const PHRASING = "CaptionPlan";++export type BuiltTrack = {+ readonly name: string;+ readonly type: string;+ /** The Track value, or undefined when it could not be built. */+ readonly track?: unknown;+ /** Capabilities no Provider on this machine could answer. */+ readonly unserved: readonly string[];+ readonly errors: readonly string[];+};++export type Preview = {+ readonly source: CompiledSource;+ readonly tracks: readonly BuiltTrack[];+ readonly timing: "measured" | "estimated";+ readonly refused: readonly Refusal[];+ readonly served: ReadonlyMap<string, ServedFile>;+ /** Outputs that were shown as a black frame because no material was supplied. */+ readonly placeholders: readonly string[];+ /** Captions whose phrasing was cut mechanically because nobody planned it. */+ readonly phrasing: readonly string[];+ /** Shots shown as a picture the Source already points at, for want of the take. */+ readonly stoodIn: readonly string[];+ /** The Canvas and frame rate every Track was placed in. */+ readonly canvas: { readonly width: number; readonly height: number; readonly clearColor: string };+ readonly frameRate: { readonly numerator: number; readonly denominator: number };+ /** The Program Space the Tracks agree on, for the renderer. */+ readonly space: unknown;+ /** Anchor identity to frame, however the timings were arrived at. */+ readonly anchors: ReadonlyMap<string, number>;+ /** Token identity to the anchors that open and close it. */+ readonly tokens: readonly {+ readonly id: string;+ readonly startAnchorId: string;+ readonly endAnchorId: string;+ }[];+};++/**+ * The frame rate the Source declares, read off whatever compile-time Record+ * carries one. Every Track is placed in one Program Space, so the first is the+ * programme's.+ */+function authoredFrameRate(compiled: unknown): { numerator: number; denominator: number } {+ const records = (compiled as { program: { records: readonly { value: { kind: string; value?: unknown } }[] } })+ .program.records;+ for (const record of records) {+ if (record.value.kind !== "inline") continue;+ const rate = (record.value.value as { frameRate?: { numerator?: number; denominator?: number } }).frameRate;+ if (typeof rate?.numerator === "number" && typeof rate.denominator === "number") {+ return { numerator: rate.numerator, denominator: rate.denominator };+ }+ }+ // Nothing declared one, so the preview picks the rate a Source most often has.+ return { numerator: 30, denominator: 1 };+}++/** The Canvas the Source declares, so a stand-in is the shape of the programme. */+function authoredCanvas(compiled: unknown): { width: number; height: number } {+ const records = (compiled as { program: { records: readonly { value: { kind: string; value?: unknown } }[] } })+ .program.records;+ for (const record of records) {+ if (record.value.kind !== "inline") continue;+ const canvas = record.value.value as { widthPx?: number; heightPx?: number; contract?: string };+ if (canvas.contract === "svml.canvas-space@1"+ && typeof canvas.widthPx === "number" && typeof canvas.heightPx === "number") {+ return { width: canvas.widthPx, height: canvas.heightPx };+ }+ }+ return { width: 1080, height: 1920 };+}++function inlineRecord(compiled: unknown, id: string): unknown {+ const records = (compiled as { program: { records: readonly { id: string; value: { kind: string; value?: unknown } }[] } })+ .program.records;+ const found = records.find((record) => record.id === id);+ return found?.value.kind === "inline" ? found.value.value : undefined;+}++/**+ * Read a Source, and every Track in it, as a build would.+ *+ * `runPath` names the Run Source that says which material and which timings to+ * read with. Without one, or where it leaves the timings unsaid, the Script's+ * own words are used to place them and the result is announced as an estimate.+ */+export async function preview(+ entryPath: string,+ runPath?: string,+ archive?: Archive,+): Promise<Preview> {+ const source = await compileSource(entryPath);++ let base: RunPlan;+ const unread: Refusal[] = [];+ if (runPath === undefined) base = await emptyRun(entryPath, source.compiled);+ else {+ try {+ base = await applyRunSource({+ runPath, compiled: source.compiled,+ served: source.served as Map<string, ServedFile>,+ ...(archive === undefined ? {} : { archive }),+ });+ } catch (error) {+ // A Run Source that names material this machine has never made is not a+ // broken Source. Read what it says, stand in for what it cannot reach,+ // and say which is which.+ unread.push({+ output: runPath,+ reason: (error as Error).message,+ });+ base = await emptyRun(entryPath, source.compiled);+ }+ }++ // What the author asked to build, when they asked for anything. That is how+ // a Source is taken only as far as one produced thing rather than all the+ // way to a film.+ // Only a target this preview can draw is worth honouring: nearly every Run+ // Source asks for the finished film, and a film is not something a timeline+ // can show. Asking for one produced Track, though, is exactly how a Source is+ // taken only as far as that Track.+ const asked = source.exports.filter((item) =>+ PLAYABLE.has(item.type) && base.targets.some((name) => name === item.ref || name === item.name));+ const targets = asked.length > 0+ ? asked+ : source.exports.filter((item) => PLAYABLE.has(item.type));++ // Timings a Run Source supplied are measurements. Where it said nothing, the+ // Script still has to be placed somewhere, so it is estimated and said so.+ const satisfied = new Set(base.run.graph.satisfactions.map((item) => item.output));+ const unsaid = source.exports.filter((item) =>+ (item.type === TIMING || item.type === SPACE) && !satisfied.has(item.ref));+ let timing: "measured" | "estimated" = unsaid.length === 0 ? "measured" : "estimated";++ let run = base.run;+ let anchors = new Map<string, number>();+ if (unsaid.length > 0) {+ const narrative = source.exports.find((item) => item.type === "Narrative");+ const value = narrative === undefined+ ? undefined+ : inlineRecord(source.compiled, narrative.ref);+ if (value === undefined) {+ // Nothing to estimate from either, so the Tracks that need timings will+ // report what they were waiting for rather than being invented.+ timing = "measured";+ } else {+ const estimated = estimateTiming(+ value as never, authoredFrameRate(source.compiled), declaredSpans(source),+ );+ anchors = new Map((estimated.map as { anchors: readonly { identity: string; frame: number }[] })+ .anchors.map((anchor) => [anchor.identity, anchor.frame]));+ const closure = await videoDomainClosure();+ const validators = await videoDomainValidators();+ const added: unknown[] = [];+ const satisfactions = [...base.run.graph.satisfactions];+ for (const output of unsaid) {+ const supplied = output.type === TIMING ? estimated.map : estimated.space;+ const type = outputType(source, output.ref);+ const stored = { kind: "inline" as const, value: supplied as never };+ const validation = await validateValue(closure, type as never, stored, validators);+ const candidate = createProvidedCandidate({+ type: type as never,+ value: stored,+ ...(validation === undefined ? {} : { validation }),+ } as never);+ added.push(candidate);+ satisfactions.push({ output: output.ref, candidate: candidate.id });+ }+ run = {+ ...base.run,+ graph: {+ ...base.run.graph,+ candidates: [...base.run.graph.candidates, ...added],+ satisfactions,+ },+ };+ }+ }++ // Material nobody supplied is stood in for, so the shape of the programme can+ // be seen before it has been shot.+ const placeholders: string[] = [];+ const stoodIn: string[] = [];+ // Only something the graph produces can be missing. A Record the Source read+ // at compile time already is its value, and standing in for it would replace+ // a picture the author supplied.+ const satisfiedNow = new Set(run.graph.satisfactions.map((item) => item.output));+ // What a Candidate already supplies, by the output it satisfies. A picture an+ // earlier Build made arrives this way rather than as a compile-time Record.+ const byCandidate = new Map(run.graph.candidates.map((item) => [(item as { id: string }).id, item]));+ const supplied = new Map<string, string>();+ for (const item of run.graph.satisfactions) {+ const root = (byCandidate.get(item.candidate) as {+ root?: { value?: { digest?: string; value?: { digest?: string } } };+ } | undefined)?.root;+ const digest = root?.value?.digest ?? root?.value?.value?.digest;+ const named = source.exports.find((held) => held.ref === item.output)?.name;+ if (digest !== undefined && named !== undefined) supplied.set(named, digest);+ }+ const consumed = new Set(source.observations.placements.flatMap((item) => item.references));+ const unsupplied = source.exports.filter((item) =>+ item.type === MATERIAL && isOutput(source, item.ref)+ && !satisfiedNow.has(item.ref) && consumed.has(item.name));+ if (unsupplied.length > 0) {+ // Measured timings arrive as a Candidate the Run Source supplied; either way+ // the anchors are what places every word.+ if (anchors.size === 0) {+ for (const candidate of run.graph.candidates) {+ const root = (candidate as { root?: { value?: { kind?: string; value?: unknown } } }).root;+ const held = root?.value?.kind === "inline" ? root.value.value : undefined;+ const shape = held as {+ anchors?: readonly { identity: string; frame: number }[]; tokens?: readonly unknown[];+ };+ const listed = shape?.anchors;+ if (!Array.isArray(listed) || !Array.isArray(shape?.tokens)) continue;+ anchors = new Map((listed ?? []).map((anchor) => [anchor.identity, anchor.frame]));+ break;+ }+ }+ const narrativeExport = source.exports.find((item) => item.type === "Narrative");+ const narrativeValue = narrativeExport === undefined+ ? undefined+ : inlineRecord(source.compiled, narrativeExport.ref) as+ { tokens?: readonly { id: string; startAnchorId: string; endAnchorId: string }[] } | undefined;++ const canvas = authoredCanvas(source.compiled);+ const rate = authoredFrameRate(source.compiled);+ // Every stand-in is as long as the shot it stands in for, so the timeline+ // and the picture cannot disagree about how long the programme runs.+ const black = blackFrames(rate, canvas, 1);+ if (black !== undefined) {+ const digest = `sha256:${createHash("sha256").update(black.bytes).digest("hex")}`;+ (source.served as Map<string, ServedFile>).set(digest, {+ mediaType: black.mediaType, bytes: black.bytes,+ });+ const added = new Map<string, unknown>(+ run.graph.candidates.map((item) => [(item as { id: string }).id, item]));+ const satisfactions = [...run.graph.satisfactions];+ for (const output of unsupplied) {+ // A shot that points at a picture already in hand stands in as that+ // picture. It is not the take, but it is the right subject held for the+ // right length, which is what makes a preview worth looking at.+ const held = await standIn(source, output.name, rate, canvas, archive, supplied);+ const owner = output.name.includes(".")+ ? output.name.slice(0, output.name.indexOf("."))+ : output.name;+ const placement = source.observations.placements.find((item) => item.id === owner);+ const seconds = placement === undefined ? undefined : declaredSeconds(source, placement);+ const own = seconds === undefined ? undefined : blackFrames(rate, canvas, seconds);+ const dark: Placeholder = own ?? black;+ const darkDigest = dark === black+ ? digest+ : `sha256:${createHash("sha256").update(dark.bytes).digest("hex")}`;+ if (dark !== black) {+ (source.served as Map<string, ServedFile>).set(darkDigest, {+ mediaType: dark.mediaType, bytes: dark.bytes,+ });+ }+ const shown = held ?? { bytes: dark.bytes, mediaType: dark.mediaType, digest: darkDigest };+ if (held !== undefined) {+ (source.served as Map<string, ServedFile>).set(held.digest, {+ mediaType: held.mediaType, bytes: held.bytes,+ });+ }+ // The same bytes are the same Candidate, however many shots they cover.+ const candidate = createProvidedCandidate({+ type: outputType(source, output.ref) as never,+ value: {+ kind: "blob", digest: shown.digest,+ size: shown.bytes.byteLength, mediaType: shown.mediaType,+ } as never,+ } as never);+ added.set(candidate.id, candidate);+ satisfactions.push({ output: output.ref, candidate: candidate.id });+ (held === undefined ? placeholders : stoodIn).push(output.name);+ }+ run = { ...run, graph: { ...run.graph, candidates: [...added.values()], satisfactions } };+ }+ }++ // Everything a build produces has to be servable too: a picture references+ // the normalized material, not the file it came from.+ const store = new MemoryArtifactStore();+ const served = source.served as Map<string, ServedFile>;+ // Phrasing nobody planned is cut mechanically, so captions read the Source's+ // own words even where no model has grouped them.+ const phrasing: string[] = [];+ const unplanned = source.exports.filter((item) =>+ item.type === PHRASING && !new Set(run.graph.satisfactions.map((s) => s.output)).has(item.ref));+ if (unplanned.length > 0) {+ const display = source.exports.find((item) => item.type === "CaptionDisplaySequence");+ const sequence = display === undefined ? undefined : inlineRecord(source.compiled, display.ref);+ const programExport = source.exports.find((item) => item.type === "CaptionProgram");+ const program = programExport === undefined+ ? undefined+ : inlineRecord(source.compiled, programExport.ref) as { runs?: readonly never[] } | undefined;+ if (hasAtoms(sequence) && Array.isArray(program?.runs) && program.runs.length > 0) {+ const closure = await videoDomainClosure();+ const validators = await videoDomainValidators();+ const added = new Map<string, unknown>(+ run.graph.candidates.map((item) => [(item as { id: string }).id, item]));+ const satisfactions = [...run.graph.satisfactions];+ for (const output of unplanned) {+ const plan = evenCaptionPlan(sequence, program as never);+ const type = outputType(source, output.ref);+ const stored = { kind: "inline" as const, value: plan as never };+ const validation = await validateValue(closure, type as never, stored, validators);+ const candidate = createProvidedCandidate({+ type: type as never, value: stored,+ ...(validation === undefined ? {} : { validation }),+ } as never);+ added.set(candidate.id, candidate);+ satisfactions.push({ output: output.ref, candidate: candidate.id });+ phrasing.push(output.name);+ }+ run = { ...run, graph: { ...run.graph, candidates: [...added.values()], satisfactions } };+ }+ }++ const artifacts = {+ // Material this Build produced is in the store; material an earlier Build+ // produced is in the archive. Both are addressed the same way.+ async get(digest: never) {+ const held = await store.get(digest);+ if (held !== undefined) return held;+ const kept = await archive?.read(digest as string);+ if (kept !== undefined) served.set(digest as string, { mediaType: "application/octet-stream", bytes: kept });+ return kept;+ },+ async put(bytes: Uint8Array, mediaType: string) {+ const ref = await store.put(bytes, mediaType);+ served.set((ref as { digest: string }).digest, { mediaType, bytes });+ return ref;+ },+ };+ const tracks: BuiltTrack[] = [];+ for (const target of targets) {+ const planned = base.plan(run, [target.ref]);+ for (const [, file] of [...served]) await artifacts.put(file.bytes, file.mediaType);+ const out = await execute(planned.state, artifacts as never);+ const selection = out.state.plan.selections.find((item) => item.output === target.ref);+ const record = out.state.records.find((item) => item.id === selection?.record);+ const stored = record?.value as { kind: string; value?: unknown } | undefined;+ tracks.push({+ name: target.name,+ type: target.type,+ ...(stored?.kind === "inline" ? { track: stored.value } : {}),+ unserved: out.unserved.map((item) => item.capability),+ errors: out.errors,+ });+ }++ // Measured timings arrive as a Candidate the Run Source supplied; either way+ // the anchors are what places every word.+ if (anchors.size === 0) {+ for (const candidate of run.graph.candidates) {+ const root = (candidate as { root?: { value?: { kind?: string; value?: unknown } } }).root;+ const held = root?.value?.kind === "inline" ? root.value.value : undefined;+ const shape = held as {+ anchors?: readonly { identity: string; frame: number }[]; tokens?: readonly unknown[];+ };+ const listed = shape?.anchors;+ if (!Array.isArray(listed) || !Array.isArray(shape?.tokens)) continue;+ anchors = new Map((listed ?? []).map((anchor) => [anchor.identity, anchor.frame]));+ break;+ }+ }+ const narrativeExport = source.exports.find((item) => item.type === "Narrative");+ const narrativeValue = narrativeExport === undefined+ ? undefined+ : inlineRecord(source.compiled, narrativeExport.ref) as+ { tokens?: readonly { id: string; startAnchorId: string; endAnchorId: string }[] } | undefined;++ const canvas = authoredCanvas(source.compiled);+ const frameRate = authoredFrameRate(source.compiled);+ // Whatever placed the words also says how long the programme is.+ const declaredFrames = Math.max(0, ...[...anchors.values()]);+ const space = builtSpace(tracks, declaredFrames, frameRate);+ return {+ source, tracks, timing, refused: [...base.refused, ...unread], served: source.served, placeholders, phrasing, stoodIn,+ canvas: { ...canvas, clearColor: authoredClearColor(source.compiled) },+ frameRate,+ space,+ anchors,+ tokens: narrativeValue?.tokens ?? [],+ };+}++/** The clear colour the Film declares, or black when it declares none. */+function authoredClearColor(compiled: unknown): string {+ const records = (compiled as { program: { records: readonly { value: { kind: string; value?: unknown } }[] } })+ .program.records;+ for (const record of records) {+ if (record.value.kind !== "inline") continue;+ const held = record.value.value as { clearColor?: unknown; canvas?: { clearColor?: unknown } };+ const colour = held.clearColor ?? held.canvas?.clearColor;+ if (typeof colour === "string") return colour;+ }+ return "#000000";+}++/**+ * The Program Space every Track was placed in.+ *+ * How long a programme runs is what the Source says, not what this machine+ * managed to draw. A Track that could not be built because there is no tool to+ * draw a stand-in does not make the programme shorter, and saying it did put+ * the timeline and the words at odds on any machine without ffmpeg.+ */+function builtSpace(+ tracks: readonly BuiltTrack[],+ declaredFrames: number,+ frameRate: { readonly numerator: number; readonly denominator: number },+): unknown {+ const drawn = tracks.flatMap((track) =>+ ((track.track as { presents?: readonly { span: { endFrameExclusive: number } }[] } | undefined)?.presents ?? [])+ .map((present) => present.span.endFrameExclusive));+ const frameCount = Math.max(1, declaredFrames, ...drawn);+ return {+ durationSec: frameCount * frameRate.denominator / frameRate.numerator,+ frameRate: { ...frameRate },+ };+}++/**+ * A picture this output already points at.+ *+ * An element that names another value the Source can already produce - a+ * reference frame, a first frame - names something worth showing while the+ * shot itself does not exist. How long to hold it is what the element itself+ * declared, so the stand-in occupies the span the take would have.+ */+async function standIn(+ source: CompiledSource,+ name: string,+ frameRate: { readonly numerator: number; readonly denominator: number },+ canvas: { readonly width: number; readonly height: number },+ archive: Archive | undefined,+ supplied: ReadonlyMap<string, string>,+): Promise<{ readonly bytes: Uint8Array; readonly mediaType: string; readonly digest: string } | undefined> {+ const owner = name.includes(".") ? name.slice(0, name.indexOf(".")) : name;+ const placement = source.observations.placements.find((item) => item.id === owner);+ if (placement === undefined) return undefined;+ for (const path of placement.references) {+ const referenced = source.exports.find((item) => item.name === path);+ if (referenced?.type !== MATERIAL) continue;+ const bytes = await pictureFor(source, referenced.ref, archive, supplied.get(path));+ if (bytes === undefined) continue;+ const made = heldPicture(bytes, declaredSeconds(source, placement) ?? 2, frameRate, canvas);+ if (made === undefined) return undefined;+ return {+ ...made,+ digest: `sha256:${createHash("sha256").update(made.bytes).digest("hex")}`,+ };+ }+ return undefined;+}++/**+ * How long the shot was declared to run.+ *+ * An element may say so itself, or point at something that does - a Source that+ * estimates its own speech names that estimate rather than repeating a number.+ */+function declaredSeconds(source: CompiledSource, placement: Placement): number | undefined {+ const own = Number(placement.attributes.duration);+ if (Number.isFinite(own) && own > 0) return own;+ for (const path of placement.references) {+ const referenced = source.exports.find((item) => item.name === path);+ if (referenced === undefined) continue;+ const value = inlineRecord(source.compiled, referenced.ref) as Record<string, unknown> | undefined;+ for (const key of ["seconds", "durationSec", "secondsExact"]) {+ const held = Number(value?.[key]);+ if (Number.isFinite(held) && held > 0) return held;+ }+ }+ return undefined;+}++/** Bytes already in hand for an output, if the Source read them at compile time. */+async function pictureFor(+ source: CompiledSource,+ ref: string,+ archive: Archive | undefined,+ fromCandidate: string | undefined,+): Promise<Uint8Array | undefined> {+ const value = inlineRecord(source.compiled, ref) as { digest?: string } | undefined;+ const digest = fromCandidate ?? value?.digest ?? blobDigest(source.compiled, ref);+ if (digest === undefined) return undefined;+ // A picture the Source read at compile time is in hand; one an earlier Build+ // produced is in the archive, and both are addressed the same way.+ return source.served.get(digest)?.bytes ?? await archive?.read(digest);+}++/** A Record stored as the blob it is, rather than wrapped. */+function blobDigest(compiled: unknown, id: string): string | undefined {+ const records = (compiled as { program: { records: readonly { id: string; value: { kind: string; digest?: string } }[] } })+ .program.records;+ const found = records.find((record) => record.id === id);+ return found?.value.kind === "blob" ? found.value.digest : undefined;+}++/**+ * How long each Segment's own material says it is.+ *+ * A guess at reading pace is a proportion, not a prediction, and a Source that+ * already declares a length knows better. An element that names both a Segment+ * and something with a declared duration is that Segment's material, whichever+ * package wrote it.+ */+function declaredSpans(source: CompiledSource): ReadonlyMap<string, number> {+ const spans = new Map<string, number>();+ const byId = new Map(source.observations.placements.map((item) => [item.id ?? "", item]));+ const declaredBy = (path: string): number | undefined => {+ const seconds = Number(byId.get(path.split(".")[0] ?? "")?.attributes.duration);+ return Number.isFinite(seconds) && seconds > 0 ? seconds : undefined;+ };+ for (const placement of source.observations.placements) {+ const groups = [placement.references, ...placement.children.map((child) => child.references)];+ for (const references of groups) {+ const segment = references.find((path) => path.includes(".segment."));+ const seconds = references.map(declaredBy).find((held) => held !== undefined);+ if (segment === undefined || seconds === undefined) continue;+ spans.set(segment.slice(segment.lastIndexOf(".") + 1), seconds);+ }+ }+ return spans;+}++/** Whether an export is something the graph produces rather than a Record read from the Source. */+function isOutput(source: CompiledSource, ref: string): boolean {+ const compiled = source.compiled as unknown as {+ exports: readonly { ref: { kind: string; id: string } }[];+ };+ return compiled.exports.find((item) => item.ref.id === ref)?.ref.kind === "logical-output";+}++/** The declared Type of an export, as the compiler recorded it. */+function outputType(source: CompiledSource, ref: string): unknown {+ const compiled = source.compiled as unknown as {+ exports: readonly { ref: { id: string }; type: unknown }[];+ };+ return compiled.exports.find((item) => item.ref.id === ref)?.type;+}diff --git a/tools/svml-playground/src/pipeline/run-source.ts b/tools/svml-playground/src/pipeline/run-source.tsnew file mode 100644index 00000000..8bbc0eae--- /dev/null+++ b/tools/svml-playground/src/pipeline/run-source.ts@@ -0,0 +1,166 @@+/**+ * Apply a Run Source.+ *+ * Which material a Source is read with is an authoring decision, and a `.svrun`+ * is where it is written. The preview does not interpret that file: the Run+ * packages parse it, resolve its Candidates and overlay them on the compiled+ * graph, exactly as a build does. The only thing supplied here is how to read a+ * path, because that is the part a Host owns.+ */+import { createHash } from "node:crypto";+import { readFileSync } from "node:fs";+import { dirname, resolve } from "node:path";++import { NodeRunCompiler } from "@narratage/compiler-node";+import type { PlannedBuild } from "@narratage/compiler-node";+import type { Digest, StoredValue } from "@narratage/protocol";+import {+ compileRunSource, RunFragmentRegistry, RunFrontendRegistry, resolveRunDocument,+} from "@narratage/run";+import { runMarkupFrontend } from "@narratage/run-markup";+import { videoDomainClosure, videoDomainValidators } from "@narratage/video-domain";++import type { Archive } from "./archive.js";+import type { ServedFile } from "./compile.js";++/** Material a Run Source named that the preview could not read, and why. */+export type Refusal = { readonly output: string; readonly reason: string };++/** The parts of a resolved Run Source the preview overlays and extends. */+export type RunCompilation = {+ readonly graph: {+ readonly candidates: readonly unknown[];+ readonly operations: readonly unknown[];+ readonly satisfactions: readonly { readonly output: string; readonly candidate: string }[];+ readonly targets: readonly { readonly output: string }[];+ };+};++/** What the Run Source said, and how to build one target against it. */+export type RunPlan = {+ readonly run: RunCompilation;+ readonly refused: readonly Refusal[];+ /** Targets the author asked for, when the Run Source names any. */+ readonly targets: readonly string[];+ /** Plan a single target. A Track that will not build costs only itself. */+ readonly plan: (run: RunCompilation, targets: readonly string[]) => PlannedBuild;+};++function digestOfBytes(bytes: Uint8Array): Digest {+ return `sha256:${createHash("sha256").update(bytes).digest("hex")}`;+}++async function planner(+ compiled: unknown,+ source: string,+ authorSource: string,+): Promise<RunPlan["plan"]> {+ const frontends = new RunFrontendRegistry();+ frontends.register(runMarkupFrontend);+ const compiler = new NodeRunCompiler({+ frontends, closure: await videoDomainClosure(), validators: await videoDomainValidators(),+ } as never);+ return (run, targets) => compiler.planCompilation({+ source,+ authorSource,+ author: { ...(compiled as object), attachments: [] },+ program: (compiled as { program: never }).program,+ run: { ...run, graph: { ...run.graph, targets: targets.map((output) => ({ output })) } },+ attachments: [],+ } as never);+}++/** A Source read on its own: no material bound and nothing satisfied. */+export async function emptyRun(entryPath: string, compiled: unknown): Promise<RunPlan> {+ return {+ run: { graph: { candidates: [], operations: [], satisfactions: [], targets: [] } },+ refused: [],+ targets: [],+ plan: await planner(compiled, entryPath, entryPath),+ };+}++/**+ * Resolve a Run Source against an already compiled Author Source. Files it+ * names are staged into `served` so the preview can hand the exact bytes to a+ * picture.+ */+export async function applyRunSource(input: {+ readonly runPath: string;+ readonly compiled: unknown;+ readonly served: Map<string, ServedFile>;+ /** Where already-produced material can be read, when the preview was given one. */+ readonly archive?: Archive;+}): Promise<RunPlan> {+ const refused: Refusal[] = [];+ const frontends = new RunFrontendRegistry();+ frontends.register(runMarkupFrontend);++ const text = readFileSync(input.runPath, "utf8");+ const { document, closure } = await compileRunSource(+ { id: input.runPath, name: input.runPath, text } as never,+ frontends,+ );++ // A Run Source usually names several things, and one of them being out of+ // reach says nothing about the rest. Drop only what cannot be read, so the+ // footage and timings the author did supply are still used.+ const reachable = { ...document } as {+ candidates: readonly { kind: string; id: string; build?: string }[];+ satisfactions: readonly { candidate: string }[];+ };+ const unreadable = new Set<string>();+ for (const declaration of reachable.candidates) {+ if (declaration.kind !== "build-record") continue;+ const held = await input.archive?.readBuild(declaration.build!);+ if (held !== undefined) continue;+ unreadable.add(declaration.id);+ refused.push({+ output: declaration.id,+ reason: input.archive === undefined+ ? `build ${declaration.build} holds this material; pass --runtime to read it.`+ : `build ${declaration.build} is not in this machine's archive.`,+ });+ }+ const named = unreadable.size === 0 ? document : {+ ...document,+ candidates: reachable.candidates.filter((item) => !unreadable.has(item.id)),+ satisfactions: reachable.satisfactions.filter((item) => !unreadable.has(item.candidate)),+ };++ const beside = (from: string): string => resolve(dirname(input.runPath), from);+ const run = await resolveRunDocument(named as never, {+ compilation: input.compiled as never,+ sourceClosure: closure,+ fragments: new RunFragmentRegistry(),+ readStoredValue(from: string): StoredValue {+ return { kind: "inline", value: JSON.parse(readFileSync(beside(from), "utf8")) };+ },+ readFile(from: string, mediaType: string): StoredValue {+ const bytes = readFileSync(beside(from));+ const digest = digestOfBytes(bytes);+ input.served.set(digest, { mediaType, bytes });+ return { kind: "blob", digest, size: bytes.byteLength, mediaType };+ },+ // Only Builds already found reachable get this far.+ readBuild(id: string) {+ return input.archive?.readBuild(id);+ },+ resolveBuildOutput(id: string, output: string) {+ return input.archive?.resolveOutput(id, output) ?? output;+ },+ } as never);++ const resolved = run as unknown as RunCompilation;+ return {+ run: resolved,+ refused,+ // What the author asked to build. Honouring it is what lets a Source be+ // taken only as far as one produced thing.+ targets: resolved.graph.targets.map((target) => target.output),+ plan: await planner(+ input.compiled, input.runPath,+ (document as { author: { source: string } }).author.source,+ ),+ };+}diff --git a/tools/svml-playground/src/pipeline/session.ts b/tools/svml-playground/src/pipeline/session.tsnew file mode 100644index 00000000..dde45687--- /dev/null+++ b/tools/svml-playground/src/pipeline/session.ts@@ -0,0 +1,81 @@+/**+ * One reading of a Source: compile it, build every Track in it, render the+ * result, and hand back what the panels display.+ */+import { createHash } from "node:crypto";+import { readFileSync } from "node:fs";++import { renderPreview } from "../preview/render.js";+import type { PlaygroundSnapshot } from "../shared.js";+import { openArchive } from "./archive.js";+import type { Archive } from "./archive.js";+import type { ServedFile } from "./compile.js";+import { preview } from "./preview.js";+import { snapshot } from "./snapshot.js";++export type Session = {+ readonly snapshot: PlaygroundSnapshot;+ /** Files the Source named, by digest, for the preview to serve. */+ readonly material: ReadonlyMap<string, ServedFile>;+};++export async function readSource(input: {+ readonly source: string;+ readonly run?: string;+ /** A Runtime profile, so material earlier builds produced can be read. */+ readonly runtime?: string;+ readonly packageRoot: string;+ readonly revision: number;+}): Promise<Session> {+ const archive = input.runtime === undefined+ ? undefined+ : await openArchive(input.runtime, input.packageRoot);+ try {+ return await read(input, archive);+ } finally {+ await archive?.close();+ }+}++async function read(+ input: { readonly source: string; readonly run?: string; readonly revision: number },+ archive: Archive | undefined,+): Promise<Session> {+ const built = await preview(input.source, input.run, archive);+ const text = readFileSync(input.source, "utf8");++ // Only Tracks that were built can be drawn; the rest are reported as waiting.+ const drawable = built.tracks+ .map((track) => track.track)+ .filter((track): track is object => track !== undefined);+ const srcdoc = renderPreview({+ id: "preview",+ canvas: built.canvas,+ space: built.space as never,+ tracks: drawable as never,+ served: new Set(built.served.keys()),+ ...(audible(built) === undefined ? {} : { audibleTrack: audible(built)! }),+ });++ return {+ snapshot: snapshot(built, {+ revision: input.revision,+ path: input.source,+ text,+ digest: `sha256:${createHash("sha256").update(text).digest("hex")}`,+ canvas: built.canvas,+ frameRate: built.frameRate,+ preview: { kind: "hyperframes", srcdoc },+ }),+ material: built.served,+ };+}++/**+ * A preview is silent unless something carries the programme's speech. The+ * Audio Track a Source built is that thing, whichever package made it.+ */+function audible(built: Awaited<ReturnType<typeof preview>>): string | undefined {+ const found = built.tracks.find((track) => track.type === "AudioTrack" && track.track !== undefined);+ return found === undefined ? undefined : (found.track as { id?: string }).id;+}diff --git a/tools/svml-playground/src/pipeline/snapshot.ts b/tools/svml-playground/src/pipeline/snapshot.tsnew file mode 100644index 00000000..cb557c0d--- /dev/null+++ b/tools/svml-playground/src/pipeline/snapshot.ts@@ -0,0 +1,310 @@+/**+ * Turn a built programme into what the panels read.+ *+ * A timeline is the Presents of every Track, and a Present carries a span, an+ * identity and a stacking order - the whole contract, for every package. So the+ * timeline is assembled without knowing what made any of it, and a package that+ * grows a new Track shows up without this file changing.+ */+import type { Clip, PlaygroundSnapshot, Range, ScriptMap, Track } from "../shared.js";+import type { Placement } from "./observe.js";+import type { Preview } from "./preview.js";++type Present = {+ readonly id: string;+ readonly span: { readonly startFrame: number; readonly endFrameExclusive: number };+ readonly stacking: { readonly order: number };+};++/** Sound is placed in samples rather than frames, in the canonical 48 kHz. */+const SAMPLE_RATE = 48_000;++type AudioClip = {+ readonly id: string;+ readonly target: { readonly startSample: number; readonly endSampleExclusive: number };+};++/**+ * Both kinds of Track say the same thing in their own domain: a named span.+ * Reading them into one shape is what lets the timeline hold both without+ * knowing which package made either.+ */+function spans(+ track: unknown,+ frameRate: { readonly numerator: number; readonly denominator: number },+): readonly { id: string; startFrame: number; endFrameExclusive: number; stackOrder: number }[] {+ const held = track as { presents?: readonly Present[]; clips?: readonly AudioClip[] } | undefined;+ if (held?.presents !== undefined) {+ return held.presents.map((present) => ({+ id: present.id,+ startFrame: present.span.startFrame,+ endFrameExclusive: present.span.endFrameExclusive,+ stackOrder: present.stacking.order,+ }));+ }+ const perSecond = frameRate.numerator / frameRate.denominator;+ return (held?.clips ?? []).map((clip) => ({+ id: clip.id,+ startFrame: Math.floor(clip.target.startSample / SAMPLE_RATE * perSecond),+ endFrameExclusive: Math.max(+ Math.floor(clip.target.startSample / SAMPLE_RATE * perSecond) + 1,+ Math.ceil(clip.target.endSampleExclusive / SAMPLE_RATE * perSecond),+ ),+ // Sound is under every picture, so it sits at the bottom of the timeline.+ stackOrder: Number.MIN_SAFE_INTEGER,+ }));+}++/** Where an authored id was written, whatever kind of thing it names. */+type Located = { readonly id: string; readonly range: Range };++function authored(placements: readonly Placement[]): readonly Located[] {+ const found: Located[] = [];+ for (const placement of placements) {+ if (placement.id !== undefined) found.push({ id: placement.id, range: placement.range });+ for (const child of placement.children) {+ if (child.id !== undefined) found.push({ id: child.id, range: child.range });+ }+ }+ // Longest first, so `handsome-1` wins over `handsome`.+ return found.sort((left, right) => right.id.length - left.id.length);+}++/**+ * A Present is named after the things that produced it, so the authored id it+ * mentions is the tag to point at. Matching on whole delimited parts keeps+ * `bags` from matching inside `bagsful`.+ */+function locate(presentId: string, located: readonly Located[]): Located | undefined {+ const parts = new Set(presentId.split(/[:#+]/u).filter(Boolean));+ return located.find((item) => parts.has(item.id));+}++function scriptMap(+ maps: readonly Record<string, unknown>[],+ built: Preview,+): ScriptMap | undefined {+ const found = maps.find((map) => map.format === "svml.script-source-map@1");+ if (found === undefined) return undefined;+ const selections = (found.selections ?? []) as ScriptMap["selections"];+ const segments = (found.segments ?? []) as ScriptMap["segments"];+ const moments = (found.moments ?? []) as ScriptMap["moments"];+ return {+ recordId: String(found.record ?? ""),+ range: (found.range ?? { start: 0, end: 0 }) as Range,+ // A Segment is the outermost range a Script declares; a Selection written+ // inside one is a level down, and one inside that another.+ segments: segments.map((segment) => ({ ...segment, depth: 0 })),+ selections: selections.map((selection) => ({+ ...selection,+ depth: depthOf(selection, selections),+ })),+ moments,+ // A Script says where a word is written; the timings say when it is said.+ tokens: ((found.tokens ?? []) as readonly { id: string; range: Range }[]).flatMap((token) => {+ const placed = built.tokens.find((item) => item.id === token.id);+ const startFrame = placed === undefined ? undefined : built.anchors.get(placed.startAnchorId);+ const endFrame = placed === undefined ? undefined : built.anchors.get(placed.endAnchorId);+ if (startFrame === undefined || endFrame === undefined) return [];+ return [{ id: token.id, range: token.range, startFrame, endFrame }];+ }),+ };+}++/** The element an output belongs to: `take-opening.video` is `take-opening`. */+/**+ * Whether this clip is showing a stand-in. A Present is named after what made+ * it, so either the tag that drew it or the identity itself says which shot it+ * came from.+ */+function standInFor(+ presentId: string,+ elementId: string | undefined,+ standIns: ReadonlyMap<string, "picture" | "black">,+): "picture" | "black" | undefined {+ if (elementId !== undefined && standIns.has(elementId)) return standIns.get(elementId);+ for (const part of presentId.split(/[:#+]/u)) {+ const held = standIns.get(part);+ if (held !== undefined) return held;+ }+ return undefined;+}++function depthOf(+ selection: ScriptMap["selections"][number],+ all: readonly ScriptMap["selections"][number][],+): number {+ const own = selection.occurrences[0];+ if (own === undefined) return 1;+ let depth = 1;+ for (const other of all) {+ if (other.id === selection.id) continue;+ for (const occurrence of other.occurrences) {+ if (occurrence.open.start < own.open.start && occurrence.close.end > own.close.end) depth += 1;+ }+ }+ return depth;+}++export function snapshot(built: Preview, input: {+ readonly revision: number;+ readonly path: string;+ readonly text: string;+ readonly digest: string;+ readonly canvas: { readonly width: number; readonly height: number; readonly clearColor: string };+ readonly frameRate: { readonly numerator: number; readonly denominator: number };+ readonly preview: PlaygroundSnapshot["preview"];+}): PlaygroundSnapshot {+ const located = authored(built.source.observations.placements);+ // Which shots are not the shot. A clip is drawn from an output, so the output+ // that was stood in for is the clip that has to say so.+ const stood = new Map<string, "picture" | "black">([+ ...built.stoodIn.map((name) => [name, "picture"] as const),+ ...built.placeholders.map((name) => [name, "black"] as const),+ ]);+ // A shot reaches a picture through whatever consumed it - a Take, an Item -+ // so an element is showing a stand-in when anything it points at was one.+ const standIns = new Map<string, "picture" | "black">();+ for (const placement of built.source.observations.placements) {+ const paths = [+ ...placement.references,+ ...placement.children.flatMap((child) => child.references),+ ];+ for (const path of paths) {+ const held = stood.get(path);+ if (held === undefined) continue;+ if (placement.id !== undefined) standIns.set(placement.id, held);+ for (const child of placement.children) {+ if (child.id !== undefined && child.references.includes(path)) standIns.set(child.id, held);+ }+ }+ }+ const script = scriptMap(built.source.observations.sourceMaps, built);+ // A clip is coloured by the marker that placed it, not by the tag that drew+ // it, so a cutaway and the words that call for it read as the same thing.+ const markers = new Set([+ ...(script?.selections ?? []).map((item) => item.id),+ ...(script?.segments ?? []).map((item) => item.id),+ ...(script?.moments ?? []).map((item) => item.id),+ ]);+ const markerFor = (elementId: string): string | undefined => {+ // The tag may be the element itself or one written inside it; either way+ // what places it is something it points at.+ for (const placement of built.source.observations.placements) {+ const child = placement.children.find((item) => item.id === elementId);+ const paths = placement.id === elementId ? placement.references : child?.references;+ for (const path of paths ?? []) {+ const named = path.slice(path.lastIndexOf(".") + 1);+ if (markers.has(named)) return named;+ }+ }+ return undefined;+ };+ const placeholders = new Set(built.placeholders);++ const tracks: Track[] = [];+ for (const item of built.tracks) {+ const clips: Clip[] = spans(item.track, input.frameRate).map((span) => {+ const where = locate(span.id, located);+ // A Track is named after the element that owns it, which is the last+ // place to look when the Present itself names no shot.+ const owner = item.name.includes(".") ? item.name.slice(0, item.name.indexOf(".")) : item.name;+ const shown = standInFor(span.id, where?.id, standIns) ?? standIns.get(owner);+ const named = [...new Set(span.id.split(/[:#+]/u))].find((part) => markers.has(part));+ const marker = named ?? (where === undefined ? undefined : markerFor(where.id));+ // A clip is itself before it is what placed it: four rows of one board+ // are four things, and collapsing them onto the marker they share would+ // make them one.+ const identity = where?.id ?? marker ?? item.name;+ return {+ id: span.id,+ authoredId: identity,+ ...(marker === undefined ? {} : { markerId: marker }),+ label: where?.id ?? span.id,+ startFrame: span.startFrame,+ endFrameExclusive: span.endFrameExclusive,+ ...(where === undefined ? {} : { elementRange: where.range }),+ ...(shown === undefined ? {} : { standIn: shown }),+ stackOrder: span.stackOrder,+ };+ });+ // A Track says for itself where its picture came from. One badge for the+ // whole programme hid that a Track was real while the one beside it was not.+ const stands = new Set(clips.map((clip) => clip.standIn).filter(Boolean));+ const source = item.track === undefined+ ? "waiting" as const+ : stands.has("black") ? "black" as const+ : stands.has("picture") ? "stand-in" as const+ : "made" as const;+ tracks.push({+ id: item.name,+ label: item.name,+ row: 0,+ clips,+ source,+ timing: built.timing,+ ...(item.track === undefined+ ? { waiting: item.unserved.length > 0 ? item.unserved : ["something this preview could not build"] }+ : {}),+ });+ }+ // The lowest Present sits at the bottom of the timeline, as it does in the+ // picture. A Track nobody could build keeps its place rather than vanishing.+ const depth = (track: Track): number =>+ track.clips.length === 0 ? Number.MAX_SAFE_INTEGER : Math.min(...track.clips.map((clip) => clip.stackOrder));+ const ordered = [...tracks].sort((left, right) => depth(right) - depth(left));+ const rows = ordered.map((track, row) => ({ ...track, row }));++ const declared = (built.space as { durationSec?: number; frameRate?: { numerator: number; denominator: number } })+ ?.durationSec;+ const frameCount = Math.max(+ 1,+ declared === undefined+ ? 0+ : Math.round(declared * input.frameRate.numerator / input.frameRate.denominator),+ ...rows.flatMap((track) => track.clips.map((clip) => clip.endFrameExclusive)),+ );+ return {+ revision: input.revision,+ source: { path: input.path, text: input.text, digest: input.digest },+ ...(script === undefined ? {} : { script }),+ space: {+ canvasWidth: input.canvas.width,+ canvasHeight: input.canvas.height,+ clearColor: input.canvas.clearColor,+ frameRate: input.frameRate,+ frameCount,+ durationSec: frameCount * input.frameRate.denominator / input.frameRate.numerator,+ },+ tracks: rows,+ preview: input.preview,+ provenance: {+ timing: built.timing,+ picture: placeholders.size === 0 ? "measured" : "estimated",+ note: note(built),+ },+ refused: built.refused,+ };+}++function note(built: Preview): string {+ const parts: string[] = [];+ parts.push(built.timing === "measured"+ ? "Timings are the ones the Run Source supplied."+ : "No timings were supplied, so words are placed at an ordinary delivery pace.");+ if (built.stoodIn.length > 0) {+ parts.push(`${built.stoodIn.length} shots have not been made, and show the picture they name instead.`);+ }+ if (built.placeholders.length > 0) {+ parts.push(`${built.placeholders.length} shots have no material yet and stand in as black frames.`);+ }+ if (built.phrasing.length > 0) {+ parts.push("Nothing has decided which words share a screen, so captions are cut every few words.");+ }+ const waiting = built.tracks.filter((track) => track.track === undefined);+ if (waiting.length > 0) {+ parts.push(`${waiting.map((track) => track.name).join(", ")} could not be built here: `+ + `${[...new Set(waiting.flatMap((track) => track.unserved))].join(", ")}.`);+ }+ return parts.join(" ");+}diff --git a/tools/svml-playground/src/preview/render.ts b/tools/svml-playground/src/preview/render.tsnew file mode 100644index 00000000..9cdb2d11--- /dev/null+++ b/tools/svml-playground/src/preview/render.ts@@ -0,0 +1,42 @@+import { sealComposition } from "@narratage/composition";+import type { Composition, Track } from "@narratage/composition";+import { compileHyperframesDocument, materializeHyperframesHtml } from "@narratage/hyperframes";+import type { ProgramSpace } from "@narratage/program-space";++import { injectRuntimeShim } from "./runtime-shim.js";++export type RenderInput = {+ readonly id: string;+ readonly canvas: Composition["canvas"];+ readonly space: ProgramSpace;+ readonly tracks: readonly Track[];+ /** Digests the Playground can serve, for material an author already has. */+ readonly served?: ReadonlySet<string>;+ /** The Track whose material carries the programme's speech. */+ readonly audibleTrack?: string;+};++/**+ * Compile the interpreted Tracks into the same HyperFrames document the real+ * renderer photographs frame by frame, and hand it back as an `iframe` srcdoc.+ *+ * Nothing is approximated here: the placement, stacking, clipping and motion are+ * the renderer's own, and only the material inside each box is a placeholder.+ */+export function renderPreview(input: RenderInput): string {+ const document = compileHyperframesDocument(sealComposition({+ id: input.id,+ canvas: input.canvas,+ tracks: input.tracks,+ }), input.space);+ const html = materializeHyperframesHtml(document, (artifact) => {+ // The only Artifacts a preview can reference are files the author already+ // has. Anything else would be a Provider's output, which does not exist yet,+ // and failing loudly beats serving a picture with holes in it.+ if (input.served?.has(artifact.digest) !== true) {+ throw new Error(`Preview composition references Artifact ${artifact.digest}, which it cannot serve.`);+ }+ return `/__svml/material/${artifact.digest}`;+ });+ return injectRuntimeShim(html, input.audibleTrack);+}diff --git a/tools/svml-playground/src/preview/runtime-shim.ts b/tools/svml-playground/src/preview/runtime-shim.tsnew file mode 100644index 00000000..2c7dffbd--- /dev/null+++ b/tools/svml-playground/src/preview/runtime-shim.ts@@ -0,0 +1,91 @@+/**+ * The bridge between the transport bar and the composition inside the iframe.+ *+ * A HyperFrames document drives its own motion. On load it samples every+ * animated element frame by frame, cancels the CSS animation and sets+ * `animation-name: none`, then waits for an `hf-seek` event carrying a time in+ * seconds. Reaching for the Web Animations API here would find nothing to move,+ * which is exactly how motion ends up frozen on its first keyframe.+ *+ * What the document does not do is decide which Presents are on screen, or run+ * real material, because those are the driver's job. So this shim owns two+ * things and delegates the third: it hides Presents outside their span, keeps+ * material on the same instant, and asks the document to place its own+ * animations.+ */+function shim(audibleTrack: string | undefined): string {+ return String.raw`+<script>+(function () {+ var audible = ${JSON.stringify(audibleTrack ?? null)};+ var muted = false;+ var root = document.querySelector('[data-composition-id]');+ var fpsAttr = (root && root.getAttribute('data-fps')) || '30';+ var slash = fpsAttr.indexOf('/');+ var fps = slash === -1+ ? parseFloat(fpsAttr)+ : parseFloat(fpsAttr.slice(0, slash)) / parseFloat(fpsAttr.slice(slash + 1));+ if (root) {+ root.style.width = (root.getAttribute('data-width') || '0') + 'px';+ root.style.height = (root.getAttribute('data-height') || '0') + 'px';+ }+ /**+ * Place the composition at one instant.+ *+ * Scrubbing and playing are different requests of the same material. A seek is+ * a discrete jump, so material is paused and moved. Playback is continuous, so+ * material runs on its own clock and is only corrected when it has drifted —+ * setting currentTime every frame would ask the decoder for a fresh seek+ * dozens of times a second, and the picture would fall behind the playhead+ * while the transport insisted it was keeping time.+ */+ function apply(seconds, scrubbing) {+ var clips = document.querySelectorAll('.svml-visual-present');+ for (var i = 0; i < clips.length; i++) {+ var clip = clips[i];+ var start = parseFloat(clip.getAttribute('data-start') || '0') || 0;+ var duration = parseFloat(clip.getAttribute('data-duration') || '0') || 0;+ var local = seconds - start;+ var inside = local >= 0 && local < duration;+ clip.style.visibility = inside ? 'visible' : 'hidden';+ var media = clip.querySelectorAll('video');+ for (var m = 0; m < media.length; m++) {+ var element = media[m];+ var mediaStart = parseFloat(element.getAttribute('data-media-start') || '0') || 0;+ var rate = parseFloat(element.getAttribute('data-playback-rate') || '1') || 1;+ var target = mediaStart + Math.max(0, local) * rate;+ // HyperFrames renders a silent picture, because programme audio is a+ // separate Track the media pipeline muxes in. A preview is not a+ // render, and placing B-roll against speech means hearing the speech,+ // so the Spine's own material is allowed to sound.+ var track = clip.getAttribute('data-svml-track-id');+ element.muted = muted || scrubbing || audible === null || track !== audible;+ try {+ if (!inside) { element.pause(); continue; }+ if (scrubbing) { element.pause(); element.currentTime = target; continue; }+ // Quarter of a second is below the threshold of noticing and well+ // above the jitter of a decoder keeping its own time.+ if (Math.abs(element.currentTime - target) > 0.25) element.currentTime = target;+ element.playbackRate = rate;+ if (element.paused) { var played = element.play(); if (played) played.catch(function () {}); }+ } catch (error) { /* the media is not ready yet */ }+ }+ }+ // The document's own runtimes place every animated element and every text+ // flow from their sampled timelines.+ window.dispatchEvent(new CustomEvent('hf-seek', { detail: { time: seconds } }));+ }+ window.__svmlSetMuted = function (value) { muted = !!value; };+ window.__svmlSeekFrame = function (frame) { apply(frame / fps, true); };+ window.__svmlPlayFrame = function (frame) { apply(frame / fps, false); };+ apply(0, true);+ window.addEventListener('load', function () { apply(0, true); });+})();+</script>`;+}++export function injectRuntimeShim(html: string, audibleTrack?: string): string {+ const script = shim(audibleTrack);+ const at = html.lastIndexOf("</body>");+ return at < 0 ? html + script : html.slice(0, at) + script + html.slice(at);+}diff --git a/tools/svml-playground/src/server.ts b/tools/svml-playground/src/server.tsnew file mode 100644index 00000000..13cb0abf--- /dev/null+++ b/tools/svml-playground/src/server.ts@@ -0,0 +1,128 @@+import { resolve } from "node:path";++import type { Plugin, ViteDevServer } from "vite";++import type { ServedFile } from "./pipeline/compile.js";+import { readSource } from "./pipeline/session.js";+import type { PlaygroundFailure, PlaygroundSnapshot, Range } from "./shared.js";++export type SvmlPlaygroundOptions = {+ readonly source: string;+ /** The directory the author invoked from, so displayed paths read as typed. */+ readonly root: string;+ /** A Run Source, read for material it already names. */+ readonly run?: string;+ /** A Runtime profile, so material earlier builds produced can be read. */+ readonly runtime?: string;+ /** Where the installed packages live, as the Runtime profile expects. */+ readonly packageRoot: string;+};++function json(response: import("node:http").ServerResponse, status: number, value: unknown): void {+ response.statusCode = status;+ response.setHeader("content-type", "application/json; charset=utf-8");+ response.end(`${JSON.stringify(value)}\n`);+}++function rangeOf(error: unknown): Range | undefined {+ if (typeof error !== "object" || error === null) return undefined;+ const range = (error as { range?: unknown }).range;+ if (typeof range === "object" && range !== null && "start" in range && "end" in range) {+ return range as Range;+ }+ // A parser error owns no element but does know where it gave up, which is+ // still the one place worth looking.+ const offset = (error as { offset?: unknown }).offset;+ return typeof offset === "number" && Number.isFinite(offset)+ ? { start: offset, end: offset + 1 }+ : undefined;+}++/**+ * Serve one Source as a read-only preview. The plugin owns no mutating route:+ * the Playground reads the file, watches it, and republishes. Nothing it exposes+ * can change what an author wrote.+ */+export function svmlPlaygroundPlugin(options: SvmlPlaygroundOptions): Plugin {+ let snapshot: PlaygroundSnapshot | undefined;+ let failure: PlaygroundFailure | undefined;+ let material: ReadonlyMap<string, ServedFile> = new Map();+ let revision = 0;+ let server: ViteDevServer | undefined;+ let timer: ReturnType<typeof setTimeout> | undefined;++ const publish = async (): Promise<void> => {+ revision += 1;+ try {+ const result = await readSource({+ source: options.source,+ ...(options.run === undefined ? {} : { run: options.run }),+ ...(options.runtime === undefined ? {} : { runtime: options.runtime }),+ packageRoot: options.packageRoot,+ revision,+ });+ snapshot = result.snapshot;+ material = result.material;+ failure = undefined;+ server?.ws.send({ type: "custom", event: "svml:snapshot", data: snapshot });+ } catch (error) {+ const range = rangeOf(error);+ failure = {+ revision,+ error: error instanceof Error ? error.message : String(error),+ ...(range === undefined ? {} : { range }),+ };+ server?.ws.send({ type: "custom", event: "svml:error", data: failure });+ }+ };++ const schedule = (): void => {+ if (timer !== undefined) clearTimeout(timer);+ timer = setTimeout(() => void publish(), 80);+ };++ return {+ name: "narratage-svml-playground",+ configureServer(value) {+ server = value;+ value.watcher.add([options.source, ...(options.run === undefined ? [] : [options.run])]);+ value.watcher.on("change", (path) => {+ // Style sheets reached through a source import are watched too: their+ // Recipes decide placement and motion, so a change there changes the+ // timeline. Vite already watches everything under the project root.+ const changed = resolve(path);+ if (changed === options.source || changed === options.run || path.endsWith(".svs")) schedule();+ });+ value.middlewares.use((request, response, next) => {+ const url = new URL(request.url ?? "/", "http://svml.local");+ if (request.method !== "GET" && request.method !== "HEAD") {+ next();+ return;+ }+ if (url.pathname === "/__svml/session") {+ void (async () => {+ if (snapshot === undefined && failure === undefined) await publish();+ if (snapshot !== undefined) json(response, 200, snapshot);+ else json(response, 500, failure);+ })();+ return;+ }+ const digest = /^\/__svml\/material\/(sha256:[a-f0-9]{64})$/u.exec(url.pathname)?.[1];+ if (digest !== undefined) {+ const file = material.get(digest);+ if (file === undefined) {+ response.statusCode = 404;+ response.end();+ return;+ }+ response.statusCode = 200;+ response.setHeader("content-type", file.mediaType);+ response.setHeader("cache-control", "no-store");+ response.end(Buffer.from(file.bytes));+ return;+ }+ next();+ });+ },+ };+}diff --git a/tools/svml-playground/src/shared.ts b/tools/svml-playground/src/shared.tsnew file mode 100644index 00000000..03ee4890--- /dev/null+++ b/tools/svml-playground/src/shared.ts@@ -0,0 +1,137 @@+/**+ * The only module imported by both the Node interpreter and the browser. It+ * declares types alone so the browser never pulls a Node dependency through it.+ */++/** UTF-16 offsets into the exact source text carried by the snapshot. */+export type Range = { readonly start: number; readonly end: number };++/**+ * One Visual Present, which is the whole of what a Track says about a picture:+ * an identity, a span and where it sits in the stack. The box it paints into is+ * measured from the rendered picture rather than restated here, because motion+ * moves it and only the picture knows where it ended up.+ */+export type Clip = {+ /** The Present's own id, identical to the preview's data-svml-present-id. */+ readonly id: string;+ /** The authored id this Present is named after, when it names one. */+ readonly authoredId: string;+ /** The Script marker that placed it, when something said put it there. */+ readonly markerId?: string;+ readonly label: string;+ readonly startFrame: number;+ readonly endFrameExclusive: number;+ /** Where that authored tag was written. */+ readonly elementRange?: Range;+ /**+ * What is actually on screen for this clip. Absent means the material the+ * Source names; otherwise the shot has not been made and this says what was+ * put there instead.+ */+ readonly standIn?: "picture" | "black";+ readonly stackOrder: number;+};++export type Track = {+ readonly id: string;+ readonly label: string;+ /** Render order in the timeline; 0 is the top row. */+ readonly row: number;+ readonly clips: readonly Clip[];+ /** Capabilities this machine could not answer, when the Track has no picture. */+ readonly waiting?: readonly string[];+ /**+ * Where this Track's own picture came from. `made` is the material the Source+ * names; `stand-in` is a picture it named for a shot nobody has made; `black`+ * is neither. A Track drawn from more than one is reported by its weakest.+ */+ readonly source: "made" | "stand-in" | "black" | "waiting";+ /** Whether this Track's times were supplied or estimated. */+ readonly timing: "measured" | "estimated";+};++export type ScriptMap = {+ readonly recordId: string;+ readonly range: Range;+ readonly selections: readonly {+ readonly id: string;+ /** How many Selections enclose this one. Nesting is what depth means. */+ readonly depth: number;+ readonly occurrences: readonly {+ readonly occurrence: number;+ readonly open: Range;+ readonly close: Range;+ }[];+ }[];+ readonly segments: readonly {+ readonly id: string;+ /** Always 0: a Segment is the outermost range the Script declares. */+ readonly depth: number;+ readonly range: Range;+ }[];+ readonly moments: readonly {+ readonly id: string;+ readonly occurrences: readonly { readonly occurrence: number; readonly range: Range }[];+ }[];+ /**+ * Spoken words placed on the timeline. Whether these are measured or estimated+ * is the snapshot's `provenance.timing`.+ */+ readonly tokens: readonly {+ readonly id: string;+ readonly range: Range;+ readonly startFrame: number;+ readonly endFrame: number;+ }[];+};++export type PlaygroundSnapshot = {+ readonly revision: number;+ readonly source: {+ readonly path: string;+ readonly text: string;+ readonly digest: string;+ };+ readonly script?: ScriptMap;+ readonly space: {+ readonly canvasWidth: number;+ readonly canvasHeight: number;+ readonly clearColor: string;+ readonly frameRate: { readonly numerator: number; readonly denominator: number };+ readonly frameCount: number;+ readonly durationSec: number;+ };+ readonly tracks: readonly Track[];+ /**+ * The picture, ready to mount. Real material is the base layer rather than the+ * whole picture: the Tracks above it have not been rendered into that file, so+ * they are composited over it exactly as they are in `hyperframes` mode.+ */+ /** The Tracks, compiled into the document the renderer photographs. */+ readonly preview: { readonly kind: "hyperframes"; readonly srcdoc: string };+ readonly provenance: {+ /** Where the timeline came from. The frame domain always shares its source. */+ readonly timing: "measured" | "estimated";+ /**+ * Whether the picture is real material. `partial` when some elements have+ * their footage and others are still placeholders, which is the normal+ * state part-way through a production.+ */+ readonly picture: "measured" | "estimated";+ /** What the badges above are standing for, in one sentence. */+ readonly note: string;+ };+ /**+ * Material an author supplied that the preview will not show, and why. A+ * placeholder next to a file they know exists reads as a bug otherwise.+ */+ readonly refused: readonly { readonly output: string; readonly reason: string }[];+};++export type PlaygroundFailure = {+ readonly revision: number;+ readonly error: string;+ /** Points the code pane at the offending element when the interpreter knows it. */+ readonly range?: Range;+};diff --git a/tools/svml-playground/src/style.css b/tools/svml-playground/src/style.cssnew file mode 100644index 00000000..44c30c90--- /dev/null+++ b/tools/svml-playground/src/style.css@@ -0,0 +1,235 @@+:root {+ color-scheme: dark; --bg:#09090b; --panel:#131316; --panel2:#18181c; --line:#2a2a30;+ --text:#f4f4f5; --muted:#96969f; --accent:#ee7b62; --marker:#ffd34d; --danger:#ff6868;+ --ok:#75d69b;+ font: 13px/1.45 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;+}+* { box-sizing:border-box; }+html, body, #app { margin:0; height:100%; overflow:hidden; background:var(--bg); color:var(--text); }+#app { display:flex; flex-direction:column; position:relative; }++.topbar { height:54px; flex:none; display:flex; align-items:center; gap:16px; padding:0 18px; border-bottom:1px solid var(--line); background:#101013; }+.topbar strong { font-size:15px; letter-spacing:-.01em; }+.topbar span { margin-left:10px; color:var(--muted); }+.meta { color:#63636e; font-size:11px; font-variant-numeric:tabular-nums; white-space:pre; }+.badges { display:flex; gap:6px; margin-left:auto; }+.badge { padding:3px 8px; border-radius:999px; font-size:11px; border:1px solid var(--line); background:#101013; color:var(--muted); cursor:default; }+.badge-measured { color:var(--ok); border-color:#2f6b48; }+.badge-estimated { color:var(--marker); border-color:#6b5a25; }+.status { color:var(--muted); font-size:12px; min-width:220px; text-align:right; }+.status.ok { color:var(--ok); } .status.error { color:var(--danger); }++main { flex:1; min-height:0; display:grid; grid-template-columns:minmax(0,1fr) auto 520px; }+.left { min-width:0; min-height:0; display:flex; flex-direction:column; }+.right { min-width:0; min-height:0; border-left:1px solid var(--line); background:var(--panel); display:flex; }++.pane-heading { flex:none; display:flex; align-items:baseline; gap:10px; padding:13px 18px 10px; border-bottom:1px solid var(--line); background:var(--panel2); }+.pane-heading h2 { margin:0; font-size:13px; }+.pane-heading span { color:var(--muted); font-size:11px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }++.code { flex:1; min-width:0; display:flex; flex-direction:column; }+.code-scroll { position:relative; flex:1; min-height:0; overflow-x:hidden; overflow-y:auto; padding:10px 10px 40px 0; font:12px/20px ui-monospace, SFMono-Regular, Menlo, monospace; }+.code-line { position:relative; display:flex; align-items:flex-start; }+.code-line .line-number { flex:none; width:46px; padding-right:22px; text-align:right; color:#55555f; user-select:none; }+/* A line that binds a clip is clickable, and says so standing still. One bar+ per level it sits inside, outermost first, so a Selection inside a Segment+ reads as two bars side by side rather than as the inner one alone. */+.code-line.bound { cursor:pointer; }+.code-line .gutter-bar {+ position:absolute; top:0; bottom:0; width:3px;+ background:var(--tone, #ffffff); opacity:.9; pointer-events:none;+}+.code-line.bound:hover .gutter-bar { opacity:1; }+.code-line.bound:hover .line-number { color:var(--tone, #ffffff); }+.tok-marker { cursor:pointer; }+/* Wrap rather than scroll sideways: a wrapped attribute list still reads, and a+ horizontal scrollbar would hide the right-hand end of every long line. */+.code-line code { flex:1; min-width:0; font:inherit; color:#8a8a95; white-space:pre-wrap; overflow-wrap:break-word; }+.tok-header { color:#5c5c68; font-style:italic; }+.tok-comment { color:#5c5c68; font-style:italic; }+.tok-punct { color:#6a6a76; }+.tok-tag { color:#7fb4ff; }+.tok-attr { color:#c2a0e8; }+.tok-string { color:#8bd6a4; }+.tok-reference { color:var(--accent); }+.tok-marker { color:var(--marker); font-weight:650; }+.tok-role { color:#f08faf; }++/* One tone per nesting depth, shared with the timeline clip and the box on the+ picture, so a pair and what it places read as the same thing. */+.tone-0 { --tone:#ffd34d; } .tone-1 { --tone:#6fd3f7; }+.tone-2 { --tone:#9ee493; } .tone-3 { --tone:#f79ad3; }+.tok-marker.tone-0, .tok-marker.tone-1,+.tok-marker.tone-2, .tok-marker.tone-3 {+ color:var(--tone); background:color-mix(in srgb, var(--tone) 14%, transparent);+ box-shadow:inset 0 0 0 1px color-mix(in srgb, var(--tone) 38%, transparent);+ border-radius:3px; padding:0 1px;+}+.range-canvas { position:absolute; inset:0; pointer-events:none; z-index:0; }+/* The word being spoken at the playhead, drawn over the text rather than+ wrapped around it so every measured offset stays where it was. */+.spoken { position:absolute; z-index:0; pointer-events:none; border-radius:3px; background:#ffd34d26; box-shadow:inset 0 0 0 1px #ffd34d66; transition:left .08s linear, width .08s linear; }+.range { transition:opacity .08s linear; }+.range-element { fill:#ffffff14; stroke:#ffffff; stroke-width:1.5; }+/* Drawn at this frame, but not the thing chosen. Present without competing. */+.range-binding { fill:color-mix(in srgb, var(--tone, var(--marker)) 12%, transparent);+ stroke:var(--tone, var(--marker)); stroke-width:1.5; }++/* The picture takes the room that is left; the strip and the timeline are rows+ of the layout, so neither can ever cover the frame or the transport. */+.left { display:grid; grid-template-rows:minmax(0,1fr) auto auto 288px; }+.left > div { min-height:0; }++/* Stage --------------------------------------------------------------- */+.stage { height:100%; display:flex; flex-direction:column; background:#0d0d11; }+.stage-viewport { flex:1; min-height:0; overflow:hidden; display:flex; align-items:center; justify-content:center; padding:14px; }+.stage-scaler { position:relative; transform-origin:top left; }+/* The picture is a rendered composition, not a document to interact with. An+ iframe would otherwise swallow every click before the stage could read it. */+.stage iframe { display:block; transform-origin:top left; border:0; background:#000; pointer-events:none; box-shadow:0 20px 70px #0009, 0 0 0 1px #ffffff1c; }+/* The scaler already carries the canvas aspect ratio, so a rendered programme+ fills it exactly and the letterbox falls outside, where the overlay is not. */+.stage video { display:none; width:100%; height:100%; background:#000; pointer-events:none; box-shadow:0 20px 70px #0009, 0 0 0 1px #ffffff1c; }+.stage-real iframe { display:none; }+.stage-real video { display:block; }++/* The overlay covers the letterboxed picture exactly, and its viewBox is the+ canvas, so a box is written in the composition's own pixels. */+.stage-overlay { position:absolute; inset:0; width:100%; height:100%; pointer-events:none; overflow:visible; }+.box { --tone:#ffffff; }+.box-content { fill:color-mix(in srgb, var(--tone) 10%, transparent); stroke:var(--tone); stroke-width:2; }+/* Where padded material will land; the placeholder paint fills the whole Frame. */+.box-content-guide { fill:none; stroke:color-mix(in srgb, var(--tone) 45%, transparent); stroke-width:1; stroke-dasharray:3 4; }+.box-label { fill:var(--tone); font:600 26px Inter, ui-sans-serif, sans-serif; paint-order:stroke; stroke:#000000cc; stroke-width:5px; }+.box-elsewhere { opacity:.4; }+.stage-scaler { cursor:default; }+/* No scrubber here: the timeline below is the one place a playhead is dragged,+ and a second one would be a second answer to the same question. */+.stage-bar { height:42px; flex:none; display:flex; align-items:center; justify-content:center; background:#0f0f12; border-top:1px solid var(--line); }+.stage-bar button { display:flex; align-items:center; justify-content:center; width:34px; height:34px; padding:0; color:var(--muted); border:0; background:none; border-radius:50%; cursor:pointer; }+.stage-bar button:hover { color:var(--text); background:#ffffff12; }+.stage-bar button:active { background:#ffffff1f; }+.stage-bar button:focus-visible { outline:2px solid #ffffff; outline-offset:2px; }+.material-symbols-rounded { font-family:"Material Symbols Rounded"; font-size:26px; line-height:1; font-weight:400; font-style:normal; letter-spacing:normal; text-transform:none; white-space:nowrap; direction:ltr; -webkit-font-feature-settings:"liga"; font-variation-settings:"FILL" 1; }++/* Inspector strip ----------------------------------------------------- */+/* Not a scroll container: an overflow of any kind would clip the popover below+ rather than merely stack it. The cells wrap instead. */+.inspector { position:relative; z-index:2; display:flex; flex-wrap:wrap; align-items:center; gap:6px 26px; min-height:52px; padding:8px 16px; background:var(--panel); border-top:1px solid var(--line); }+.inspector .cell { min-width:0; display:flex; flex-direction:column; gap:2px; }+.inspector .cell.wide { min-width:120px; }+/* Written as they read. Letter-spacing only ever served the capitals. */+.inspector dt { color:#63636e; font-size:11px; }+.inspector dd { margin:0; font-size:12px; white-space:nowrap; font-variant-numeric:tabular-nums; }+.inspector .cell.wide dd { color:var(--text); font-weight:600; }+.skipped { margin-left:auto; position:relative; }+.skipped summary { cursor:pointer; color:var(--muted); font-size:11px; white-space:nowrap; }+.skipped-list { position:absolute; right:0; bottom:22px; z-index:6; display:flex; flex-direction:column; min-width:190px; max-height:40vh; overflow-y:auto; padding:6px; background:#131318; border:1px solid var(--line); border-radius:8px; box-shadow:0 12px 30px #000a; }+.skipped-list button { padding:5px 8px; text-align:left; color:var(--muted); background:none; border:0; border-radius:5px; cursor:pointer; font:inherit; font-size:11px; }+.skipped-list button:hover { color:var(--text); background:#20202a; }+/* Timeline ------------------------------------------------------------- */+.timeline { height:100%; min-height:0; display:flex; flex-direction:column; border-top:1px solid var(--line); background:#0d0d10; }+.timeline .pane-heading { justify-content:space-between; }+.timeline [data-readout] { font-variant-numeric:tabular-nums; }+.timeline-body { flex:1; min-height:0; display:grid; grid-template-columns:104px minmax(0,1fr); overflow-x:hidden; overflow-y:auto; }+.timeline-labels { position:sticky; left:0; z-index:3; border-right:1px solid var(--line); background:var(--panel2); }+.label-corner { position:sticky; top:0; z-index:4; background:var(--panel2); height:24px; display:flex; align-items:center; justify-content:flex-end; padding-right:10px; border-bottom:1px solid var(--line); color:#55555f; font-size:10px; font-variant-numeric:tabular-nums; }+.track-label { min-height:52px; min-width:0; display:flex; flex-direction:column; justify-content:center; gap:2px; padding:0 10px; border-bottom:1px solid var(--line); }+.track-label strong { font-size:11px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }+.track-label small { color:#63636e; font-size:10px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }+.track-label.track-waiting strong { color:var(--muted); }++.timeline-lanes { position:relative; min-width:0; cursor:crosshair; user-select:none; }+.ruler { position:sticky; top:0; z-index:2; background:var(--panel); height:24px; border-bottom:1px solid var(--line); }+.tick { position:absolute; top:0; padding-left:4px; border-left:1px solid #2f2f36; height:24px; line-height:24px; color:#55555f; font-size:10px; font-variant-numeric:tabular-nums; white-space:nowrap; }+.lane { position:relative; min-height:52px; border-bottom:1px solid var(--line); background:#0f0f13; }++.clip { position:absolute; margin-top:6px; height:40px; min-width:3px; display:flex; flex-direction:column; justify-content:center; gap:2px; padding:0 8px; overflow:hidden; text-align:left; border:1px solid transparent; border-radius:6px; color:var(--text); cursor:pointer; }+.clip[class*="tone-"] {+ background:color-mix(in srgb, var(--tone) 20%, #14141b);+ border-color:color-mix(in srgb, var(--tone) 52%, transparent);+}+.clip[class*="tone-"] .clip-name { color:var(--tone); }+.clip:hover { border-color:#7b7b8a; }+/* Live means the playhead is inside it, which is a different claim from being+ selected, so it reads differently: lit rather than ringed. */+.clip.live { box-shadow:inset 0 0 0 1px color-mix(in srgb, var(--tone, #fff) 60%, transparent); filter:brightness(1.25); }+.clip-name { font-size:11px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }+.clip-meta { font-size:10px; color:#b6b6c2; font-variant-numeric:tabular-nums; }++.playhead { position:absolute; top:0; bottom:0; width:1px; background:#ffffff; pointer-events:none; z-index:2; }+.playhead-grip { position:sticky; top:0; display:block; margin-left:-5px; width:11px; height:9px; background:#ffffff; clip-path:polygon(0 0,100% 0,50% 100%); z-index:3; }++.failure { position:absolute; left:18px; right:538px; bottom:18px; z-index:5; max-height:180px; overflow:auto; margin:0; padding:12px; color:#ffb0b0; background:#310f13e8; border:1px solid #8d3039; border-radius:8px; white-space:pre-wrap; }+.failure:empty { display:none; }++@media (max-width:1100px) { main { grid-template-columns:minmax(0,1fr) 400px; } .failure { right:418px; } }+.inspector .cell.warn dt { color:var(--marker); }+.inspector .cell.warn dd { color:var(--muted); white-space:normal; max-width:420px; }+.badge-partial { color:#7fb4ff; border-color:#2f4a6b; }+/* HyperFrames renders a silent picture; a preview is not a render, so the+ Spine's own material is allowed to sound and this turns it off again. */+.stage-bar { gap:4px; }+.stage-mute { width:30px; height:30px; }+.stage-mute .material-symbols-rounded { font-size:20px; }++/* A clip that is not the shot says so standing still: hatched for a stand-in+ picture, dimmed for a black frame. Reading the note is not the same as being+ able to see which of the two a clip is. */+/* A stand-in is marked by a line down its leading edge rather than a texture. */+.clip-stand-in-picture { box-shadow:inset 3px 0 0 var(--tone, var(--muted)); }+.clip-stand-in-black { opacity:.5; }+.clip-stand-in-black .clip-name::after { content:" (black)"; color:var(--muted); }++/* The edge between two panels, wide enough to grab and quiet until pointed at. */+.handle { background:transparent; }+.handle-column { width:6px; cursor:col-resize; margin-left:-3px; }+.handle-row { height:6px; cursor:row-resize; margin-bottom:-3px; }+.handle:hover, .handle:focus-visible { background:#ffffff2e; outline:none; }++/* A Track says what it is showing. Real material is unremarkable; anything+ standing in for a shot that has not been made says so without shouting. */+.track-label small { display:block; }+.track-label.source-made small { color:#63636e; }+.track-label.source-stand-in small { color:var(--marker); }+.track-label.source-black small { color:var(--muted); }+.track-label.source-waiting small { color:var(--danger); }++/* The whole programme, with the part on the timeline as a window inside it. */+.timeline-zoom { flex:none; height:28px; padding:5px 10px 5px 114px; background:var(--panel2); border-top:1px solid var(--line); }+.zoom { position:relative; height:18px; border-radius:8px; background:#0d0d10; box-shadow:inset 0 0 0 1px var(--line); cursor:pointer; }+.zoom-window { position:absolute; top:0; bottom:0; border-radius:8px; background:#ffffff1f; box-shadow:inset 0 0 0 1px #ffffff5c; cursor:grab; }+.zoom-window:active { cursor:grabbing; }+.zoom-grip { position:absolute; top:50%; width:12px; height:12px; margin-top:-6px; border-radius:50%; background:#ffffffe6; box-shadow:0 1px 4px #0009; cursor:col-resize; }+.zoom-grip-start { left:3px; }+.zoom-grip-end { right:3px; }++/* What a Track is showing is a footnote, not a sentence: an icon that opens the+ detail, so a long explanation cannot push the strip out of the panel. */+.track-note { display:inline-flex; align-items:center; justify-content:center; width:15px; height:15px; margin-left:4px; padding:0; border:0; border-radius:50%; background:#ffffff1a; color:var(--muted); font-size:10px; line-height:1; cursor:pointer; vertical-align:middle; }+.track-note:hover { background:#ffffff2e; color:var(--text); }+.track-note.note-stand-in { color:var(--marker); }+.track-note.note-black { color:var(--muted); }+.track-note.note-waiting { color:var(--danger); }++/* The final mark reads back from its own line, so no label hangs past the strip. */+.tick-last { padding-left:0; padding-right:4px; transform:translateX(-100%); border-left:0; border-right:1px solid #2f2f36; }++/* A footnote that appears where it is pointed at and leaves when the pointer+ does. A dialog for a sentence would stop the reader to say very little. */+.track-note { position:relative; }+.track-note .note-bubble {+ position:fixed; z-index:60; width:280px; padding:9px 11px; border-radius:8px;+ background:#1b1b21; box-shadow:0 10px 30px #000a, 0 0 0 1px var(--line);+ color:var(--text); font-size:11px; line-height:1.45; text-align:left;+ opacity:0; pointer-events:none; transition:opacity .1s linear;+}+.track-note:hover .note-bubble, .track-note:focus-visible .note-bubble { opacity:1; }++.clip.selected { border-color:#ffffff; }+/* A footnote wraps rather than running off the side of the window. */+.track-note .note-bubble { white-space:normal; word-break:break-word; max-width:min(320px, 42vw); }++/* Opening a Track shows the rows behind its front one. */+.track-fold { margin-left:6px; padding:0 5px; height:15px; border:0; border-radius:7px; background:#ffffff1a; color:var(--muted); font-size:10px; line-height:15px; cursor:pointer; vertical-align:middle; }+.track-fold:hover { background:#ffffff2e; color:var(--text); }diff --git a/tools/svml-playground/src/ui/code.ts b/tools/svml-playground/src/ui/code.tsnew file mode 100644index 00000000..6565844f--- /dev/null+++ b/tools/svml-playground/src/ui/code.ts@@ -0,0 +1,360 @@+import type { PlaygroundSnapshot, Range } from "../shared.js";+import { markerTones } from "./markers.js";+import { tokenizeSvml } from "./syntax.js";+import type { Token } from "./syntax.js";++const SVG_NS = "http://www.w3.org/2000/svg";++export type Highlight = {+ readonly range: Range;+ /**+ * `element` outlines the authored tag, `binding` the Script marker, and+ * `onscreen` a tag that is merely drawn at this frame rather than chosen.+ */+ readonly tone: "element" | "binding" | "onscreen";+ /** Nesting depth, so an inner pair is drawn distinctly from the one enclosing it. */+ readonly depth?: number;+};++export type CodePane = {+ readonly element: HTMLElement;+ show(snapshot: PlaygroundSnapshot): void;+ highlight(values: readonly Highlight[], scrollIntoView: boolean): void;+ /** Mark the word being spoken at the playhead, or nothing outside speech. */+ speak(range: Range | undefined): void;+ /** Absolute source offset under a pointer event, or undefined outside the text. */+ offsetAt(event: MouseEvent): number | undefined;+};++/** One text node and the absolute source span it covers. */+type Piece = { readonly node: Text; readonly start: number; readonly end: number };++type Line = {+ readonly element: HTMLElement;+ readonly code: HTMLElement;+ readonly start: number;+ readonly end: number;+ readonly pieces: readonly Piece[];+};++/** A point on the rendered glyph grid, in scroll-container coordinates. */+type Caret = { readonly x: number; readonly y: number; readonly height: number };++/**+ * One rounded outline through an arbitrary polygon. Ported from the Narratage+ * demo so a highlight here reads the same as a highlight on the site.+ */+function roundedRangePath(points: readonly { x: number; y: number }[], radius = 6): string {+ return `${points.map((point, index) => {+ const previous = points[(index - 1 + points.length) % points.length]!;+ const next = points[(index + 1) % points.length]!;+ const previousLength = Math.hypot(previous.x - point.x, previous.y - point.y) || 1;+ const nextLength = Math.hypot(next.x - point.x, next.y - point.y) || 1;+ const corner = Math.min(radius, previousLength / 2, nextLength / 2);+ const before = {+ x: point.x + (previous.x - point.x) * corner / previousLength,+ y: point.y + (previous.y - point.y) * corner / previousLength,+ };+ const after = {+ x: point.x + (next.x - point.x) * corner / nextLength,+ y: point.y + (next.y - point.y) * corner / nextLength,+ };+ return `${index === 0 ? "M" : "L"} ${before.x} ${before.y} Q ${point.x} ${point.y} ${after.x} ${after.y}`;+ }).join(" ")} Z`;+}++/**+ * The gutter holds one bar per nesting level. `GUTTER_LEFT` is where the+ * outermost bar starts, past the right edge of a three-digit line number.+ */+const GUTTER_LEFT = 27;+const GUTTER_STEP = 3;+const GUTTER_LEVELS = 4;+/** Where a range outline may begin: clear of every bar the gutter can hold. */+const GUTTER_TEXT = GUTTER_LEFT + GUTTER_STEP * GUTTER_LEVELS + 2;++export function createCodePane(): CodePane {+ const element = document.createElement("section");+ element.className = "code";+ element.innerHTML = `+ <div class="pane-heading"><h2>Source</h2><span data-path></span></div>+ <div class="code-scroll"><svg class="range-canvas" aria-hidden="true"></svg></div>`;+ const path = element.querySelector<HTMLElement>("[data-path]")!;+ const scroll = element.querySelector<HTMLElement>(".code-scroll")!;+ const canvas = element.querySelector<SVGSVGElement>(".range-canvas")!;++ let lines: Line[] = [];+ let current: readonly Highlight[] = [];+ let spoken: HTMLElement | undefined;++ const lineAt = (offset: number): Line | undefined =>+ lines.find((line) => offset >= line.start && offset <= line.end);++ /**+ * Measure one absolute offset. Text is wrapped, so a collapsed DOM range at a+ * wrap boundary can report no rectangles at all: measure a real character and+ * take the edge that faces the offset instead.+ */+ const caret = (offset: number, edge: "start" | "end"): Caret | undefined => {+ const line = lineAt(offset);+ if (line === undefined) return undefined;+ const box = scroll.getBoundingClientRect();+ const toLocal = (rect: DOMRect, x: number): Caret => ({+ x: x - box.left + scroll.scrollLeft,+ y: (rect.top + rect.bottom) / 2 - box.top + scroll.scrollTop,+ height: rect.height,+ });++ const piece = edge === "start"+ ? line.pieces.find((item) => offset >= item.start && offset < item.end)+ ?? line.pieces.find((item) => offset <= item.start)+ : line.pieces.find((item) => offset > item.start && offset <= item.end)+ ?? line.pieces.findLast((item) => offset >= item.end);++ const range = document.createRange();+ if (piece !== undefined) {+ const within = Math.max(0, Math.min(offset - piece.start, piece.node.length));+ if (within < piece.node.length) {+ range.setStart(piece.node, within);+ range.setEnd(piece.node, within + 1);+ const rect = range.getClientRects()[0];+ if (rect !== undefined) return toLocal(rect, rect.left);+ }+ if (within > 0) {+ range.setStart(piece.node, within - 1);+ range.setEnd(piece.node, within);+ const rect = range.getClientRects()[0];+ if (rect !== undefined) return toLocal(rect, rect.right);+ }+ }+ const rect = line.code.getBoundingClientRect();+ return toLocal(rect, edge === "start" ? rect.left : rect.right);+ };++ const draw = (): void => {+ const width = scroll.clientWidth;+ const last = lines.at(-1)?.element;+ const height = Math.max(scroll.clientHeight, last === undefined ? 0 : last.offsetTop + last.offsetHeight);+ canvas.setAttribute("width", String(width));+ canvas.setAttribute("height", String(height));+ canvas.setAttribute("viewBox", `0 0 ${width} ${height}`);+ canvas.replaceChildren();+ if (width === 0) return;++ for (const item of current) {+ const start = caret(item.range.start, "start");+ const end = caret(item.range.end, "end");+ if (start === undefined || end === undefined) continue;+ const lineHeight = start.height || Number.parseFloat(getComputedStyle(scroll).lineHeight) || 20;+ // The outline's left edge sits clear of the gutter bars rather than over+ // the first characters of the code.+ const left = GUTTER_TEXT;+ const right = width - 10;+ const startX = Math.max(left, start.x - 3);+ const endX = Math.max(left, end.x + 3);+ const top = start.y - lineHeight / 2;+ const bottom = end.y + lineHeight / 2;+ // Wrapping means "same line" is a question about rendered rows, not about+ // source lines: compare the measured baselines.+ const sameRow = Math.abs(start.y - end.y) < lineHeight / 2;+ // A multi-row range becomes one flag rather than a stack of boxes, so the+ // whole region reads as a single selection.+ const points = sameRow+ ? [{ x: startX, y: top }, { x: endX, y: top }, { x: endX, y: bottom }, { x: startX, y: bottom }]+ : [+ { x: startX, y: top }, { x: right, y: top },+ { x: right, y: end.y - lineHeight / 2 }, { x: endX, y: end.y - lineHeight / 2 },+ { x: endX, y: bottom }, { x: left, y: bottom },+ { x: left, y: start.y + lineHeight / 2 }, { x: startX, y: start.y + lineHeight / 2 },+ ];+ const node = document.createElementNS(SVG_NS, "path");+ node.setAttribute("d", roundedRangePath(points));+ node.setAttribute("class",+ `range range-${item.tone}${item.depth === undefined ? "" : ` tone-${item.depth}`}`);+ canvas.append(node);+ }+ };++ scroll.addEventListener("scroll", draw);+ new ResizeObserver(draw).observe(scroll);++ return {+ element,+ show(snapshot) {+ path.textContent = snapshot.source.path;+ const source = snapshot.source.text;+ const tokens: readonly Token[] = tokenizeSvml(source);+ const tones = markerTones(snapshot);+ lines = [];+ const fragment = document.createDocumentFragment();+ let offset = 0;+ let index = 0;++ for (const [number, value] of source.split("\n").entries()) {+ const lineStart = offset;+ const lineEnd = offset + value.length;+ const row = document.createElement("div");+ row.className = "code-line";+ row.dataset.offset = String(lineStart);+ const gutter = document.createElement("span");+ gutter.className = "line-number";+ gutter.textContent = String(number + 1);+ const code = document.createElement("code");+ const pieces: Piece[] = [];++ // Emit one text node per token and per gap between tokens, clipped to+ // this line, so the concatenation stays byte-identical to the source.+ const emit = (from: number, to: number, token?: Token): void => {+ if (to <= from) return;+ const node = document.createTextNode(source.slice(from, to));+ if (token === undefined) code.append(node);+ else {+ const span = document.createElement("span");+ // A marker pair shares a tone with the clip it binds, so the two+ // ends of `@claim … @/claim` read as one thing.+ const tone = token.id === undefined ? undefined : tones.get(token.id);+ span.className = `tok tok-${token.kind}${tone === undefined ? "" : ` tone-${tone}`}`;+ if (token.id !== undefined) span.dataset.marker = token.id;+ span.append(node);+ code.append(span);+ }+ pieces.push({ node, start: from, end: to });+ };++ while (index < tokens.length && tokens[index]!.end <= lineStart) index += 1;+ let cursor = lineStart;+ for (let scan = index; scan < tokens.length && tokens[scan]!.start < lineEnd; scan += 1) {+ const token = tokens[scan]!;+ const from = Math.max(token.start, lineStart);+ const to = Math.min(token.end, lineEnd);+ if (to <= cursor) continue;+ emit(cursor, from);+ emit(from, to, token);+ cursor = to;+ }+ emit(cursor, lineEnd);+ // An empty line still needs a box to measure and click.+ if (pieces.length === 0) code.append(document.createTextNode(" "));++ row.append(gutter, code);+ fragment.append(row);+ lines.push({ element: row, code, start: lineStart, end: lineEnd, pieces });+ offset = lineEnd + 1;+ }++ // Mark every line that can be clicked, at the level it belongs to. Only a+ // small part of a Source binds to anything, so what is clickable has to be+ // visible standing still rather than discovered by sweeping the pointer+ // over it — and a Script range is as clickable as an authored element.+ const clickable: { range: Range; tone: number | undefined }[] = [];+ for (const segment of snapshot.script?.segments ?? []) {+ clickable.push({ range: segment.range, tone: tones.get(segment.id) });+ }+ for (const selection of snapshot.script?.selections ?? []) {+ for (const occurrence of selection.occurrences) {+ clickable.push({+ range: { start: occurrence.open.start, end: occurrence.close.end },+ tone: tones.get(selection.id),+ });+ }+ }+ for (const track of snapshot.tracks) {+ for (const clip of track.clips) {+ if (clip.elementRange === undefined) continue;+ clickable.push({ range: clip.elementRange, tone: tones.get(clip.authoredId) });+ }+ }+ for (const line of lines) {+ // Widest first: a bar per level the line sits inside, laid left to+ // right so the enclosing pair stays visible beside the nested one+ // instead of being covered by it.+ // Several clips can be drawn from one tag - a Caption Track is one tag+ // and a dozen cues - and a bar per clip would say the line is nested a+ // dozen deep. One bar per distinct range is what nesting means.+ const distinct = new Map<string, { range: Range; tone: number | undefined }>();+ for (const item of clickable) {+ if (line.end < item.range.start || line.start > item.range.end) continue;+ const key = `${item.range.start}:${item.range.end}`;+ if (!distinct.has(key)) distinct.set(key, item);+ }+ const covering = [...distinct.values()]+ .sort((left, right) =>+ (right.range.end - right.range.start) - (left.range.end - left.range.start))+ .slice(0, GUTTER_LEVELS);+ if (covering.length === 0) continue;+ line.element.classList.add("bound");+ // The tightest range is what the line means, so the line-number hover+ // colour still follows the innermost level.+ const innermost = covering[covering.length - 1]!;+ if (innermost.tone !== undefined) line.element.classList.add(`tone-${innermost.tone}`);+ for (const [level, item] of covering.entries()) {+ const bar = document.createElement("span");+ bar.className = item.tone === undefined ? "gutter-bar" : `gutter-bar tone-${item.tone}`;+ bar.style.left = `${GUTTER_LEFT + level * GUTTER_STEP}px`;+ line.element.append(bar);+ }+ }++ scroll.replaceChildren(canvas, fragment);+ draw();+ },+ speak(range) {+ spoken?.remove();+ spoken = undefined;+ if (range === undefined) return;+ const line = lineAt(range.start);+ const piece = line?.pieces.find((item) => range.start >= item.start && range.start < item.end);+ // A word is highlighted by drawing over it rather than by rewriting the+ // text: the offsets every other measurement depends on stay put.+ const start = caret(range.start, "start");+ const end = caret(range.end, "end");+ if (line === undefined || piece === undefined || start === undefined || end === undefined) return;+ if (Math.abs(start.y - end.y) > (start.height || 20) / 2) return;+ const mark = document.createElement("div");+ mark.className = "spoken";+ mark.style.left = `${start.x - 2}px`;+ mark.style.top = `${start.y - (start.height || 20) / 2}px`;+ mark.style.width = `${Math.max(2, end.x - start.x + 4)}px`;+ mark.style.height = `${start.height || 20}px`;+ scroll.append(mark);+ spoken = mark;+ },+ highlight(values, scrollIntoView) {+ current = values;+ draw();+ const first = values[0];+ if (!scrollIntoView || first === undefined) return;+ lineAt(first.range.start)?.element.scrollIntoView({ behavior: "smooth", block: "center" });+ },+ offsetAt(event) {+ const row = (event.target as HTMLElement | null)?.closest<HTMLElement>(".code-line");+ const line = row === null || row === undefined+ ? undefined+ : lines.find((item) => item.element === row);+ if (line === undefined) return undefined;+ // Pick the character whose rendered box contains the pointer. Wrapping+ // makes this a two-dimensional question, so the row has to match too.+ const range = document.createRange();+ let best = line.start;+ let bestDistance = Number.POSITIVE_INFINITY;+ for (const piece of line.pieces) {+ for (let within = 0; within < piece.node.length; within += 1) {+ range.setStart(piece.node, within);+ range.setEnd(piece.node, within + 1);+ const rect = range.getClientRects()[0];+ if (rect === undefined) continue;+ const dy = event.clientY < rect.top ? rect.top - event.clientY+ : event.clientY > rect.bottom ? event.clientY - rect.bottom : 0;+ const dx = event.clientX < rect.left ? rect.left - event.clientX+ : event.clientX > rect.right ? event.clientX - rect.right : 0;+ const distance = dy * 1000 + dx;+ if (distance < bestDistance) {+ bestDistance = distance;+ best = piece.start + within;+ }+ }+ }+ return best;+ },+ };+}diff --git a/tools/svml-playground/src/ui/main.ts b/tools/svml-playground/src/ui/main.tsnew file mode 100644index 00000000..6b9d9d7d--- /dev/null+++ b/tools/svml-playground/src/ui/main.ts@@ -0,0 +1,281 @@+import type { PlaygroundFailure, PlaygroundSnapshot, Range as SourceRange } from "../shared.js";+import { createCodePane } from "./code.js";+import { createHandle } from "./resize.js";+import type { Highlight } from "./code.js";+import { liveRanges, markerTones, spanAtOffset } from "./markers.js";+import { clipAtOffset, createStore } from "./selection.js";+import { createStage } from "./stage.js";+import { createTimeline } from "./timeline.js";+import "../style.css";++const app = document.querySelector<HTMLElement>("#app")!;+app.innerHTML = `+ <header class="topbar">+ <div><strong>SVML Playground</strong></div>+ <div class="meta" data-meta></div>+ <div class="badges" data-badges></div>+ <div class="status" data-status>Reading…</div>+ </header>+ <main>+ <div class="left">+ <div data-stage></div>+ <section class="inspector" data-inspector></section>+ <div data-timeline></div>+ </div>+ <div class="right" data-code></div>+ </main>+ <pre class="failure" data-failure></pre>`;++const store = createStore();+const code = createCodePane();+const timeline = createTimeline(store);+const stage = createStage(store);+app.querySelector<HTMLElement>("[data-code]")!.append(code.element);+app.querySelector<HTMLElement>("[data-timeline]")!.append(timeline.element);+app.querySelector<HTMLElement>("[data-stage]")!.append(stage.element);++// How much room the Source needs against how much the picture needs depends on+// the Source and on what is being worked on, so both edges are the reader's.+const shell = app.querySelector<HTMLElement>("main")!;+const left = app.querySelector<HTMLElement>(".left")!;+shell.insertBefore(createHandle({+ axis: "column", initial: 520, minimum: 320, invert: true,+ maximum: () => Math.max(360, shell.clientWidth - 420),+ apply: (size) => { shell.style.gridTemplateColumns = `minmax(0,1fr) auto ${size}px`; },+ remember: "svml-playground.code-width",+}), app.querySelector<HTMLElement>(".right")!);+left.insertBefore(createHandle({+ axis: "row", initial: 288, minimum: 140, invert: true,+ maximum: () => Math.max(160, left.clientHeight - 260),+ apply: (size) => { left.style.gridTemplateRows = `minmax(0,1fr) auto auto ${size}px`; },+ remember: "svml-playground.timeline-height",+}), app.querySelector<HTMLElement>("[data-timeline]")!);+const inspector = app.querySelector<HTMLElement>("[data-inspector]")!;+const meta = app.querySelector<HTMLElement>("[data-meta]")!;+const badges = app.querySelector<HTMLElement>("[data-badges]")!;+const status = app.querySelector<HTMLElement>("[data-status]")!;+const failureView = app.querySelector<HTMLElement>("[data-failure]")!;++/**+ * How much of what is shown was invented.+ *+ * One badge over the whole programme said "picture: measured" while two Tracks+ * were showing a stand-in, because a single word cannot describe seven Tracks+ * that differ. Each Track now says its own; this counts them, and clicking it+ * is the same as reading them.+ */+function renderBadges(snapshot: PlaygroundSnapshot): void {+ badges.replaceChildren();+ const standing = snapshot.tracks.filter((track) => track.source !== "made");+ if (standing.length === 0) return;+ const badge = document.createElement("span");+ badge.className = "badge badge-estimated";+ badge.textContent = `${standing.length} of ${snapshot.tracks.length} tracks are standing in`;+ badge.title = snapshot.provenance.note;+ badges.append(badge);+}++// Program-level facts never change while a Source is being read, so they live in+// the header rather than taking a panel that would have to sit over something.+function renderMeta(snapshot: PlaygroundSnapshot): void {+ const { space } = snapshot;+ meta.textContent = [+ `${space.canvasWidth}x${space.canvasHeight}`,+ `${space.frameRate.numerator}/${space.frameRate.denominator}fps`,+ `${space.frameCount}f (${space.durationSec.toFixed(2)}s)`,+ ].join(" ");+}++function cell(label: string, value: string, tone?: string): HTMLElement {+ const node = document.createElement("div");+ node.className = `cell${tone === undefined ? "" : ` ${tone}`}`;+ node.innerHTML = "<dt></dt><dd></dd>";+ node.querySelector("dt")!.textContent = label;+ node.querySelector("dd")!.textContent = value;+ return node;+}++/** The Script marker a clip is bound to, or its own id when it binds nothing. */+function bindingId(clip: { readonly binding: { readonly kind: string; readonly id?: string }; readonly id: string }): string {+ return clip.binding.id ?? clip.id;+}++function box(value: { widthPx: number; heightPx: number; xPx: number; yPx: number }): string {+ return `${Math.round(value.widthPx)}x${Math.round(value.heightPx)}`+ + ` at ${Math.round(value.xPx)},${Math.round(value.yPx)}`;+}++/**+ * A single strip between the picture and the timeline. It is a row of the+ * layout rather than a floating card, so it can never cover the frame being+ * inspected or the transport used to reach it.+ */+function renderInspector(snapshot: PlaygroundSnapshot, clipId: string | undefined): void {+ const clip = clipId === undefined ? undefined : store.clip(clipId);+ const cells: HTMLElement[] = [];++ if (clip === undefined) {+ cells.push(cell("selected", "nothing - click a marked line or a timeline clip"));+ } else {+ const fps = snapshot.space.frameRate.numerator / snapshot.space.frameRate.denominator;+ const seconds = (clip.endFrameExclusive - clip.startFrame) / fps;+ cells.push(+ cell("clip", clip.label, "wide"),+ cell("present", clip.id),+ cell("span", `${clip.startFrame}-${clip.endFrameExclusive}f (${seconds.toFixed(2)}s)`),+ cell("stack", String(clip.stackOrder)),+ );+ if (clip.standIn !== undefined) {+ cells.push(cell("showing", clip.standIn === "picture"+ ? "a picture this shot names - the shot itself has not been made"+ : "a black frame - this shot has no material and names no picture", "warn"));+ }+ }++ for (const item of snapshot.refused) {+ cells.push(cell(`${item.output} not shown`, item.reason, "warn"));+ }++ for (const track of snapshot.tracks) {+ if (track.waiting === undefined) continue;+ cells.push(cell(`${track.label} not shown`, `waiting on ${track.waiting.join(", ")}`, "warn"));+ }+ inspector.replaceChildren(...cells);+}++// The word being spoken at the playhead, which is the point of carrying token+// timings at all: it ties the Script text to the frame on screen.+store.subscribe(({ snapshot, playhead }) => {+ const token = snapshot.script?.tokens.find((item) =>+ playhead.frame >= item.startFrame && playhead.frame < item.endFrame);+ code.speak(token?.range);+});++let described = "";+let scrolledTo = "";++store.subscribe(({ snapshot, selection, playhead }) => {+ const origin = selection.kind === "clip" ? selection.origin : undefined;+ const chosen = selection.kind === "clip" ? store.clip(selection.clipId) : undefined;+ // Rebuilding this every frame of playback would be DOM churn for no change.+ const describes = `${snapshot.revision}:${chosen?.id ?? ""}`;+ if (describes !== described) {+ described = describes;+ renderInspector(snapshot, chosen?.id);+ }++ // Every Selection the playhead is inside is outlined, not only what was+ // clicked, and not only what has a clip. A Selection inside another Selection+ // is still inside it, so the enclosing pair stays outlined while the inner one+ // is — that nesting is the whole point of the markers.+ const tones = markerTones(snapshot);+ const live = store.clipsAt(playhead.frame);+ const highlights: Highlight[] = liveRanges(snapshot, playhead.frame).map((selection) => ({+ range: selection.range,+ tone: "binding" as const,+ depth: tones.get(selection.id) ?? 0,+ }));+ // The element that placed what is on screen is outlined too. Knowing a cutaway+ // is running is half the answer; the other half is which line put it there.+ // Only what was chosen is outlined. What is merely drawn at this frame is+ // already said by the gutter bars, and a second outline for it made a board+ // look picked when one of its rows was.+ if (chosen?.elementRange !== undefined) {+ highlights.push({ range: chosen.elementRange, tone: "element" });+ }++ // Scroll only when the selection actually moved, and never toward the pane+ // the author is pointing at: following the playhead every frame would drag+ // the source out from under whoever is reading it.+ const focused = chosen === undefined ? "" : `${snapshot.revision}:${chosen.id}`;+ const moved = focused.length > 0 && focused !== scrolledTo;+ scrolledTo = focused;+ code.highlight(highlights, moved && origin !== "code");+});++// Clicking a marked region in the source selects what it binds and looks at the+// instant it covers. The lines that bind something carry a coloured gutter bar,+// so what is clickable is visible standing still.+code.element.addEventListener("click", (event) => {+ const state = store.current();+ if (state === undefined) return;+ const offset = code.offsetAt(event);+ // Below the last line, or in the heading: nothing is being pointed at.+ if (offset === undefined) {+ store.clearSelection();+ return;+ }+ const clip = clipAtOffset(state.snapshot, offset);++ // A click inside marked prose lands inside the innermost marker written there,+ // not at the start of whatever encloses it. `@amount` places nothing, so+ // resolving through clips alone would throw the playhead out to `@fee`.+ const span = spanAtOffset(state.snapshot, offset);+ // Prose is anywhere a marker was written; whether a clip also covers that+ // offset only decides which clip to select, not whether the click counts.+ const inProse = span !== undefined+ && (clip?.elementRange === undefined+ || !(offset >= clip.elementRange.start && offset <= clip.elementRange.end));+ if (inProse) {+ // A clip is named after itself and remembers what placed it, so a marker+ // finds the clips it put there through the second, not the first.+ const bound = state.snapshot.tracks+ .flatMap((track) => track.clips)+ .find((item) => item.markerId === span.id || item.authoredId === span.id);+ // A marker that places nothing still sits inside one that does, so the+ // enclosing clip stays selected rather than leaving the inspector blank.+ const target = bound?.id ?? clip?.id;+ if (target === undefined) store.seek(span.startFrame, "code");+ else store.focus(span.startFrame, target, "code");+ return;+ }+ if (clip === undefined) store.clearSelection();+ else store.selectClip(clip.id, "code");+});++window.addEventListener("keydown", (event) => {+ const state = store.current();+ if (state === undefined || event.metaKey || event.ctrlKey || event.altKey) return;+ // Space is the transport everywhere else; typing in a field is not transport.+ const editing = (event.target as HTMLElement | null)?.closest("input, textarea, select") !== null;+ if (event.key === " " && !editing) {+ stage.toggle();+ event.preventDefault();+ return;+ }+ const step = event.shiftKey ? 10 : 1;+ if (event.key === "ArrowLeft") store.seek(state.playhead.frame - step, "timeline");+ else if (event.key === "ArrowRight") store.seek(state.playhead.frame + step, "timeline");+ else if (event.key === "Home") store.seek(0, "timeline");+ else if (event.key === "End") store.seek(state.snapshot.space.frameCount - 1, "timeline");+ else if (event.key === "Escape") store.clearSelection();+ else return;+ event.preventDefault();+});++function applySnapshot(snapshot: PlaygroundSnapshot): void {+ failureView.textContent = "";+ status.className = "status ok";+ status.textContent = `Watching ${snapshot.source.path} - revision ${snapshot.revision}`;+ renderMeta(snapshot);+ renderBadges(snapshot);+ code.show(snapshot);+ store.load(snapshot);+}++function applyFailure(failure: PlaygroundFailure): void {+ status.className = "status error";+ status.textContent = `Read failed - revision ${failure.revision}`;+ failureView.textContent = failure.error;+ if (failure.range !== undefined) code.highlight([{ range: failure.range, tone: "element" }], true);+}++const response = await fetch("/__svml/session");+const initial = await response.json() as PlaygroundSnapshot | PlaygroundFailure;+if (response.ok && "tracks" in initial) applySnapshot(initial);+else applyFailure(initial as PlaygroundFailure);++type Hot = { on(event: string, listener: (value: unknown) => void): void };+const hot = (import.meta as ImportMeta & { hot?: Hot }).hot;+hot?.on("svml:snapshot", (value) => applySnapshot(value as PlaygroundSnapshot));+hot?.on("svml:error", (value) => applyFailure(value as PlaygroundFailure));diff --git a/tools/svml-playground/src/ui/markers.ts b/tools/svml-playground/src/ui/markers.tsnew file mode 100644index 00000000..1bcdca58--- /dev/null+++ b/tools/svml-playground/src/ui/markers.ts@@ -0,0 +1,122 @@+import type { PlaygroundSnapshot, Range } from "../shared.js";++/** How many distinct depth tones the stylesheet defines. */+export const MARKER_TONES = 4;++/**+ * A tone per Script marker, shared by the code pane, the timeline and the box+ * drawn over the picture.+ *+ * Markers are coloured by **nesting depth**, not by identity. Depth is the only+ * difference between two Selections that means anything — an inner one is a+ * narrower claim about the same speech — so two markers at the same depth read+ * the same, and an inner pair reads as sitting inside its outer pair rather than+ * as an unrelated thing.+ *+ * The three panes have to agree, or the colour would carry no meaning: a marker+ * pair in the prose and the clip it binds are the same fact seen twice.+ */+export function markerTones(snapshot: PlaygroundSnapshot): ReadonlyMap<string, number> {+ const tones = new Map<string, number>();+ for (const segment of snapshot.script?.segments ?? []) {+ tones.set(segment.id, segment.depth % MARKER_TONES);+ }+ for (const selection of snapshot.script?.selections ?? []) {+ tones.set(selection.id, selection.depth % MARKER_TONES);+ }+ // A Moment marks an instant, so it sits at whatever level it was written in+ // rather than enclosing anything. One level in from its Segment is honest.+ for (const moment of snapshot.script?.moments ?? []) tones.set(moment.id, 1 % MARKER_TONES);+ // A clip is coloured by what placed it, so a cutaway and the words that call+ // for it read as one thing. But several clips can share one marker - the rows+ // of a board do - and colouring them alike would say they are the same clip.+ // Siblings therefore step through the tones from their marker's own.+ const seen = new Map<string, number>();+ let spare = 0;+ for (const track of snapshot.tracks) {+ for (const clip of track.clips) {+ if (tones.has(clip.authoredId)) continue;+ const marker = clip.markerId === undefined ? undefined : tones.get(clip.markerId);+ if (marker === undefined) {+ // Nothing said to put this here, so it takes the next tone along.+ tones.set(clip.authoredId, spare % MARKER_TONES);+ spare += 1;+ continue;+ }+ const index = seen.get(clip.markerId!) ?? 0;+ seen.set(clip.markerId!, index + 1);+ tones.set(clip.authoredId, (marker + index) % MARKER_TONES);+ }+ }+ return tones;+}++/**+ * The Script ranges whose speech the playhead is inside, outermost first.+ *+ * Segments and Selections alike, because a Segment is a level too: `<price>`+ * encloses `@bags`, so drawing only the Selection would show a nesting with its+ * outermost level missing.+ *+ * Derived from the Script tokens each range encloses rather than from the clips+ * bound to it, because a range is a claim about speech whether or not anything+ * was placed on it. `@amount` inside `@fee` is still inside `@fee` even when+ * only the outer one drives a Media Item.+ */+export type ScriptSpan = {+ readonly id: string;+ readonly depth: number;+ readonly range: Range;+ readonly startFrame: number;+ readonly endFrame: number;+};++/** Every Segment and Selection, placed on the timeline by the tokens it holds. */+export function scriptSpans(snapshot: PlaygroundSnapshot): readonly ScriptSpan[] {+ const tokens = snapshot.script?.tokens ?? [];+ const placed: ScriptSpan[] = [];+ const spans = [+ ...(snapshot.script?.segments ?? []).map((segment) => ({+ id: segment.id, depth: segment.depth, range: segment.range,+ })),+ ...(snapshot.script?.selections ?? []).flatMap((selection) =>+ selection.occurrences.map((occurrence) => ({+ id: selection.id,+ depth: selection.depth,+ range: { start: occurrence.open.start, end: occurrence.close.end },+ }))),+ ];+ for (const { id, depth, range } of spans) {+ const within = tokens.filter((token) =>+ token.range.start >= range.start && token.range.end <= range.end);+ if (within.length === 0) continue;+ placed.push({+ id, depth, range,+ startFrame: Math.min(...within.map((token) => token.startFrame)),+ endFrame: Math.max(...within.map((token) => token.endFrame)),+ });+ }+ return placed;+}++export function liveRanges(snapshot: PlaygroundSnapshot, frame: number): readonly ScriptSpan[] {+ // Outermost first: an inner outline is drawn last and sits inside its parent.+ return scriptSpans(snapshot)+ .filter((span) => frame >= span.startFrame && frame < span.endFrame)+ .sort((left, right) => left.depth - right.depth);+}++/**+ * The tightest Script range written around a source offset.+ *+ * Clicking marked prose should land inside the thing that was clicked, and the+ * innermost marker is the most specific claim there. Resolving to a clip alone+ * would send a click on `@amount` to whatever encloses it, because a marker that+ * places nothing still means something.+ */+export function spanAtOffset(snapshot: PlaygroundSnapshot, offset: number): ScriptSpan | undefined {+ return scriptSpans(snapshot)+ .filter((span) => offset >= span.range.start && offset <= span.range.end)+ .sort((left, right) =>+ (left.range.end - left.range.start) - (right.range.end - right.range.start))[0];+}diff --git a/tools/svml-playground/src/ui/overlay.ts b/tools/svml-playground/src/ui/overlay.tsnew file mode 100644index 00000000..8242c636--- /dev/null+++ b/tools/svml-playground/src/ui/overlay.ts@@ -0,0 +1,132 @@+import type { Clip, PlaygroundSnapshot } from "../shared.js";+import { markerTones } from "./markers.js";+import type { Store } from "./selection.js";++const SVG_NS = "http://www.w3.org/2000/svg";++/**+ * Where a clip is actually drawn, in canvas pixels, or undefined when the+ * picture has not mounted yet.+ */+/** A box on the canvas, in canvas pixels. */+export type Box = {+ readonly xPx: number; readonly yPx: number;+ readonly widthPx: number; readonly heightPx: number;+};++export type Measure = (clipId: string) => Box | undefined;++export type Overlay = {+ readonly element: SVGSVGElement;+ /** The topmost clip drawn at a point, in client coordinates. */+ hitTest(clientX: number, clientY: number): Clip | undefined;+ /** Redraw against the picture, once it has mounted or moved. */+ refresh(): void;+};++function rect(box: Box, className: string): SVGRectElement {+ const node = document.createElementNS(SVG_NS, "rect");+ node.setAttribute("x", String(box.xPx));+ node.setAttribute("y", String(box.yPx));+ node.setAttribute("width", String(box.widthPx));+ node.setAttribute("height", String(box.heightPx));+ node.setAttribute("rx", "6");+ // preserveAspectRatio is none, so a scaled stroke would be drawn unevenly.+ node.setAttribute("vector-effect", "non-scaling-stroke");+ node.setAttribute("class", className);+ return node;+}++function inside(box: Box, x: number, y: number): boolean {+ return x >= box.xPx && x <= box.xPx + box.widthPx+ && y >= box.yPx && y <= box.yPx + box.heightPx;+}++/**+ * The box drawn over the picture for the selected clip.+ *+ * The overlay shares the composition's own coordinate system through its+ * viewBox, so a box is written in canvas pixels with no transform to keep in+ * step with the iframe's scale.+ *+ * The box itself is measured from the rendered picture rather than recomputed+ * from the Placement Frame. Two things move a clip away from that Frame:+ * lifecycle motion displaces it for the length of its enter and exit, and the+ * frame paint fills the Frame while padded material does not. Measuring what+ * was drawn is exact for both, and stays exact for whatever the renderer does+ * next. The interpreted Frame is only the fallback for the moment before the+ * picture has mounted.+ */+export function createOverlay(store: Store, measure: Measure): Overlay {+ const element = document.createElementNS(SVG_NS, "svg");+ element.setAttribute("class", "stage-overlay");+ element.setAttribute("preserveAspectRatio", "none");++ let live: readonly Clip[] = [];+ let canvas = { width: 1, height: 1 };+ let last: { snapshot: PlaygroundSnapshot; selected: Clip | undefined; frame: number } | undefined;++ /**+ * The box is measured off the picture rather than restated from the Source:+ * motion moves an element across its span, so only what was drawn knows where+ * it ended up. A Present that has not mounted has no box to draw.+ */+ const drawnBox = (clip: Clip): Box | undefined => measure(clip.id);++ const draw = (): void => {+ if (last === undefined) return;+ const { snapshot, selected, frame } = last;+ canvas = { width: snapshot.space.canvasWidth, height: snapshot.space.canvasHeight };+ element.setAttribute("viewBox", `0 0 ${canvas.width} ${canvas.height}`);+ element.replaceChildren();+ // Only clips actually on screen can be picked out of the picture.+ live = store.clipsAt(frame);++ if (selected === undefined) return;+ const tones = markerTones(snapshot);+ const tone = tones.get(selected.authoredId);+ const onScreen = frame >= selected.startFrame && frame < selected.endFrameExclusive;+ const box = drawnBox(selected);+ // A Present that is not on screen at this frame was never drawn, so there+ // is nothing to put a box around.+ if (box === undefined) return;+ const group = document.createElementNS(SVG_NS, "g");+ group.setAttribute("class", `box${onScreen ? "" : " box-elsewhere"}${tone === undefined ? "" : ` tone-${tone}`}`);++ group.append(rect(box, "box-content"));++ const label = document.createElementNS(SVG_NS, "text");+ label.setAttribute("x", String(box.xPx + 10));+ label.setAttribute("y", String(Math.max(28, box.yPx - 12)));+ label.setAttribute("class", "box-label");+ label.textContent = onScreen ? selected.label : `${selected.label} (not at this frame)`;+ group.append(label);+ element.append(group);+ };++ store.subscribe(({ snapshot, selection, playhead }) => {+ last = {+ snapshot,+ selected: selection.kind === "clip" ? store.clip(selection.clipId) : undefined,+ frame: playhead.frame,+ };+ draw();+ });++ return {+ element,+ refresh: draw,+ hitTest(clientX, clientY) {+ const box = element.getBoundingClientRect();+ if (box.width === 0 || box.height === 0) return undefined;+ const x = (clientX - box.left) / box.width * canvas.width;+ const y = (clientY - box.top) / box.height * canvas.height;+ // clipsAt already returns topmost first, so the first hit is the one an+ // author would say they clicked on.+ return live.find((clip) => {+ const box = drawnBox(clip);+ return box !== undefined && inside(box, x, y);+ });+ },+ };+}diff --git a/tools/svml-playground/src/ui/resize.ts b/tools/svml-playground/src/ui/resize.tsnew file mode 100644index 00000000..651f3bb2--- /dev/null+++ b/tools/svml-playground/src/ui/resize.ts@@ -0,0 +1,74 @@+/**+ * Panels the reader can size.+ *+ * How much room the Source needs against how much the picture needs is not a+ * decision this tool can make: it depends on the Source, and on which of the+ * two the reader is working on right now. So both edges are draggable, and+ * where they were put is remembered.+ */++type Axis = "column" | "row";++/**+ * A grab handle on the edge between two panels.+ *+ * `apply` receives the size in pixels of the panel being sized; clamping is the+ * caller's, because only it knows what its own panel needs to stay usable.+ */+export function createHandle(input: {+ readonly axis: Axis;+ readonly initial: number;+ readonly minimum: number;+ readonly maximum: () => number;+ /** Which way the pointer moves to make the panel larger. */+ readonly invert?: boolean;+ readonly apply: (size: number) => void;+ /** Where to remember it, so a reload keeps the layout. */+ readonly remember: string;+}): HTMLElement {+ const element = document.createElement("div");+ element.className = `handle handle-${input.axis}`;+ element.setAttribute("role", "separator");+ element.setAttribute("aria-orientation", input.axis === "column" ? "vertical" : "horizontal");+ element.tabIndex = 0;++ const held = Number(localStorage.getItem(input.remember));+ let size = Number.isFinite(held) && held > 0 ? held : input.initial;+ const settle = (value: number): void => {+ size = Math.max(input.minimum, Math.min(input.maximum(), value));+ input.apply(size);+ localStorage.setItem(input.remember, String(size));+ };+ settle(size);++ element.addEventListener("pointerdown", (event) => {+ event.preventDefault();+ element.setPointerCapture(event.pointerId);+ const from = input.axis === "column" ? event.clientX : event.clientY;+ const began = size;+ const move = (moved: PointerEvent): void => {+ const at = input.axis === "column" ? moved.clientX : moved.clientY;+ const delta = (at - from) * (input.invert === true ? -1 : 1);+ settle(began + delta);+ };+ const done = (): void => {+ element.removeEventListener("pointermove", move);+ element.removeEventListener("pointerup", done);+ element.releasePointerCapture(event.pointerId);+ };+ element.addEventListener("pointermove", move);+ element.addEventListener("pointerup", done);+ });++ // A handle nobody can reach with a keyboard is a handle half the readers do+ // not have.+ element.addEventListener("keydown", (event) => {+ const step = event.shiftKey ? 48 : 12;+ if (event.key === "ArrowLeft" || event.key === "ArrowUp") settle(size - step);+ else if (event.key === "ArrowRight" || event.key === "ArrowDown") settle(size + step);+ else return;+ event.preventDefault();+ });++ return element;+}diff --git a/tools/svml-playground/src/ui/selection.ts b/tools/svml-playground/src/ui/selection.tsnew file mode 100644index 00000000..b95d9501--- /dev/null+++ b/tools/svml-playground/src/ui/selection.ts@@ -0,0 +1,135 @@+import type { Clip, PlaygroundSnapshot } from "../shared.js";++/**+ * Which pane the user acted in. Panes ignore events they originated, which is+ * the only thing keeping timeline, code and picture from driving each other in+ * a loop.+ */+export type Origin = "timeline" | "code" | "video";++export type Selection =+ | { readonly kind: "none" }+ | { readonly kind: "clip"; readonly clipId: string; readonly origin: Origin };++export type Playhead = { readonly frame: number; readonly origin: Origin | "play" };++export type State = {+ readonly snapshot: PlaygroundSnapshot;+ readonly selection: Selection;+ readonly playhead: Playhead;+};++export type Store = {+ /** Undefined until the first snapshot arrives. */+ current(): State | undefined;+ clip(clipId: string): Clip | undefined;+ /** Clips covering a frame, topmost track first. */+ clipsAt(frame: number): readonly Clip[];+ load(snapshot: PlaygroundSnapshot): void;+ selectClip(clipId: string, origin: Origin): void;+ /**+ * Look at one instant, optionally selecting a clip there. Used when the thing+ * an author pointed at is a Script range rather than a clip, which has no+ * first frame of its own to jump to.+ */+ focus(frame: number, clipId: string | undefined, origin: Origin): void;+ clearSelection(): void;+ seek(frame: number, origin: Origin | "play"): void;+ subscribe(listener: (state: State) => void): void;+};++/**+ * The clip an author is pointing at in the source text.+ *+ * A Script marker wins over the element that binds it: `@claim … @/claim` sits+ * inside the `<script>` element, so without that preference every click in the+ * prose would select the Speech Take instead of the B-roll. Ties break toward+ * the tightest range, which is the most specific thing under the cursor.+ */+export function clipAtOffset(snapshot: PlaygroundSnapshot, offset: number): Clip | undefined {+ const clips = snapshot.tracks.flatMap((track) => track.clips);+ const within = (range: { readonly start: number; readonly end: number } | undefined): number =>+ range === undefined || offset < range.start || offset > range.end+ ? Number.POSITIVE_INFINITY+ : range.end - range.start;++ let best: Clip | undefined;+ let bestScore = Number.POSITIVE_INFINITY;+ for (const clip of clips) {+ const score = within(clip.elementRange);+ if (score < bestScore) {+ bestScore = score;+ best = clip;+ }+ }+ return best;+}++export function createStore(): Store {+ let snapshot: PlaygroundSnapshot | undefined;+ let selection: Selection = { kind: "none" };+ let playhead: Playhead = { frame: 0, origin: "timeline" };+ const listeners: ((state: State) => void)[] = [];++ const clips = (): readonly Clip[] => snapshot?.tracks.flatMap((track) => track.clips) ?? [];++ const emit = (): void => {+ if (snapshot === undefined) return;+ const state: State = { snapshot, selection, playhead };+ for (const listener of listeners) listener(state);+ };++ const clamp = (frame: number): number =>+ Math.max(0, Math.min(Math.round(frame), (snapshot?.space.frameCount ?? 1) - 1));++ return {+ current: () => snapshot === undefined ? undefined : { snapshot, selection, playhead },+ clip: (clipId) => clips().find((clip) => clip.id === clipId),+ clipsAt(frame) {+ return clips()+ .filter((clip) => frame >= clip.startFrame && frame < clip.endFrameExclusive)+ .sort((left, right) => right.stackOrder - left.stackOrder);+ },+ load(value) {+ snapshot = value;+ // A recompiled Source may have dropped the selected clip, and its frame+ // count may have moved under the playhead.+ const held = selection;+ if (held.kind === "clip" && !clips().some((clip) => clip.id === held.clipId)) {+ selection = { kind: "none" };+ }+ playhead = { frame: clamp(playhead.frame), origin: playhead.origin };+ emit();+ },+ selectClip(clipId, origin) {+ const clip = clips().find((item) => item.id === clipId);+ if (clip === undefined) return;+ selection = { kind: "clip", clipId, origin };+ // Selecting is also a seek: "show me this B-roll" means showing the frame+ // it starts on, not wherever the playhead happened to be.+ playhead = { frame: clamp(clip.startFrame), origin };+ emit();+ },+ focus(frame, clipId, origin) {+ const clip = clipId === undefined ? undefined : clips().find((item) => item.id === clipId);+ selection = clip === undefined ? { kind: "none" } : { kind: "clip", clipId: clip.id, origin };+ playhead = { frame: clamp(frame), origin };+ emit();+ },+ clearSelection() {+ if (selection.kind === "none") return;+ selection = { kind: "none" };+ emit();+ },+ seek(frame, origin) {+ const next = clamp(frame);+ if (next === playhead.frame && origin === playhead.origin) return;+ playhead = { frame: next, origin };+ emit();+ },+ subscribe(listener) {+ listeners.push(listener);+ if (snapshot !== undefined) listener({ snapshot, selection, playhead });+ },+ };+}diff --git a/tools/svml-playground/src/ui/stage.ts b/tools/svml-playground/src/ui/stage.tsnew file mode 100644index 00000000..51b98ea8--- /dev/null+++ b/tools/svml-playground/src/ui/stage.ts@@ -0,0 +1,205 @@+import type { PlaygroundSnapshot } from "../shared.js";+import { createOverlay } from "./overlay.js";+import type { State, Store } from "./selection.js";++export type Stage = {+ readonly element: HTMLElement;+ /** Start or stop playback, however the request arrived. */+ toggle(): void;+};++/**+ * The picture.+ *+ * The synthetic preview is the real HyperFrames document in an iframe, scrubbed+ * by pausing its animations and setting their time. The transport therefore+ * drives frames, not seconds, and lands on exactly the frame the renderer would+ * photograph.+ */+export function createStage(store: Store): Stage {+ const element = document.createElement("section");+ element.className = "stage";+ element.innerHTML = `+ <div class="stage-viewport">+ <div class="stage-scaler">+ <iframe title="Preview" sandbox="allow-scripts allow-same-origin"></iframe>+ </div>+ </div>+ <div class="stage-bar">+ <button type="button" data-play aria-label="Play">+ <span class="material-symbols-rounded" data-icon>play_arrow</span>+ </button>+ <button type="button" data-mute aria-label="Mute" class="stage-mute">+ <span class="material-symbols-rounded" data-mute-icon>volume_up</span>+ </button>+ </div>`;++ const viewport = element.querySelector<HTMLElement>(".stage-viewport")!;+ const scaler = element.querySelector<HTMLElement>(".stage-scaler")!;+ const iframe = element.querySelector<HTMLIFrameElement>("iframe")!;+ /**+ * Measure a clip in the rendered picture.+ *+ * The iframe is sized to the canvas, so coordinates inside its document are+ * canvas pixels already and need no conversion. `getBoundingClientRect`+ * reflects the paused animation's transform, which is the whole point:+ * lifecycle motion displaces a clip from its Placement Frame for the length+ * of its enter and exit, and selecting a clip lands the playhead on exactly+ * the frame where that displacement is largest.+ */+ const measure = (clipId: string): { xPx: number; yPx: number; widthPx: number; heightPx: number } | undefined => {+ const document_ = iframe.contentDocument;+ if (document_ === null) return undefined;+ const present = document_.querySelector(`[data-svml-present-id="${CSS.escape(clipId)}"]`);+ // The present spans the whole canvas; the drawn box is its frame element.+ const drawn = present?.querySelector(`[data-svml-element-id="${CSS.escape(`${clipId}:frame`)}"]`)+ ?? present?.querySelector("[data-svml-element-id]");+ if (drawn === null || drawn === undefined) return undefined;+ const box = drawn.getBoundingClientRect();+ if (box.width === 0 && box.height === 0) return undefined;+ return { xPx: box.left, yPx: box.top, widthPx: box.width, heightPx: box.height };+ };++ // The overlay is a sibling of the iframe inside the scaler, so it inherits the+ // letterboxed content box and needs no transform of its own.+ const overlay = createOverlay(store, measure);+ scaler.append(overlay.element);++ // Clicking the picture selects whatever is drawn under the pointer, which is+ // the third way into the same selection.+ scaler.addEventListener("click", (event) => {+ const clip = overlay.hitTest(event.clientX, event.clientY);+ if (clip !== undefined) store.selectClip(clip.id, "video");+ else store.clearSelection();+ });+ // The room around the picture is empty in the plainest sense.+ viewport.addEventListener("click", (event) => {+ if (event.target === viewport) store.clearSelection();+ });+ const play = element.querySelector<HTMLButtonElement>("[data-play]")!;+ const icon = element.querySelector<HTMLElement>("[data-icon]")!;+ const mute = element.querySelector<HTMLButtonElement>("[data-mute]")!;+ const muteIcon = element.querySelector<HTMLElement>("[data-mute-icon]")!;++ type SeekWindow = Window & {+ __svmlSeekFrame?: (frame: number) => void;+ __svmlPlayFrame?: (frame: number) => void;+ __svmlSetMuted?: (muted: boolean) => void;+ };+ let state: State | undefined;+ let mounted = -1;+ let ready = false;+ let playing = false;+ let muted = false;+ let raf = 0;+ // The transport counts frames from where it was last told to be. Jumping to a+ // clip mid-playback moves that origin rather than stopping, so playback+ // carries on from the frame the author asked for.+ let fromFrame = 0;+ let began = 0;++ const fps = (snapshot: PlaygroundSnapshot): number =>+ snapshot.space.frameRate.numerator / snapshot.space.frameRate.denominator;++ const fit = (): void => {+ if (state === undefined) return;+ const { canvasWidth, canvasHeight } = state.snapshot.space;+ const room = viewport.getBoundingClientRect();+ const scale = Math.min(+ (room.width - 28) / canvasWidth,+ (room.height - 28) / canvasHeight,+ 1,+ );+ // A zero-sized viewport during layout would otherwise produce NaN.+ const valid = Number.isFinite(scale) && scale > 0 ? scale : 1;+ scaler.style.width = `${canvasWidth * valid}px`;+ scaler.style.height = `${canvasHeight * valid}px`;+ iframe.style.width = `${canvasWidth}px`;+ iframe.style.height = `${canvasHeight}px`;+ iframe.style.transform = `scale(${valid})`;+ };++ const stop = (): void => {+ const wasPlaying = playing;+ playing = false;+ icon.textContent = "play_arrow";+ play.setAttribute("aria-label", "Play");+ if (raf !== 0) cancelAnimationFrame(raf);+ raf = 0;+ // Settle the picture on the frame the transport stopped at.+ if (wasPlaying && state !== undefined && ready) {+ (iframe.contentWindow as SeekWindow | null)?.__svmlSeekFrame?.(state.playhead.frame);+ }+ };++ const toggle = (): void => {+ if (state === undefined) return;+ if (playing) { stop(); return; }+ playing = true;+ icon.textContent = "pause";+ play.setAttribute("aria-label", "Pause");+ const total = state.snapshot.space.frameCount;+ const rate = fps(state.snapshot);+ fromFrame = state.playhead.frame >= total - 1 ? 0 : state.playhead.frame;+ began = performance.now();+ const step = (now: number): void => {+ const at = fromFrame + Math.round((now - began) / 1000 * rate);+ if (!playing || at >= total) { store.seek(total - 1, "play"); stop(); return; }+ store.seek(at, "play");+ raf = requestAnimationFrame(step);+ };+ raf = requestAnimationFrame(step);+ };+ play.addEventListener("click", toggle);++ const applyMuted = (): void => {+ muteIcon.textContent = muted ? "volume_off" : "volume_up";+ mute.setAttribute("aria-label", muted ? "Unmute" : "Mute");+ (iframe.contentWindow as SeekWindow | null)?.__svmlSetMuted?.(muted);+ };+ mute.addEventListener("click", () => { muted = !muted; applyMuted(); });++ iframe.addEventListener("load", () => {+ ready = true;+ if (state !== undefined) (iframe.contentWindow as SeekWindow | null)?.__svmlSeekFrame?.(state.playhead.frame);+ applyMuted();+ // The box could not be measured until now.+ overlay.refresh();+ });++ new ResizeObserver(fit).observe(viewport);++ store.subscribe((value) => {+ const first = state === undefined;+ state = value;+ if (value.snapshot.revision !== mounted) {+ mounted = value.snapshot.revision;+ stop();+ ready = false;+ const preview = value.snapshot.preview;+ iframe.srcdoc = preview.srcdoc;+ fit();+ }+ if (first) fit();++ // Playing and scrubbing are different requests: one lets material run on+ // its own clock, the other moves it. Asking a decoder for a fresh seek+ // every frame is what makes a picture fall behind its own transport.+ // A jump that arrives while the transport runs is both: the picture moves+ // now, and playback continues from there.+ const jumped = value.playhead.origin !== "play";+ if (jumped && playing) {+ fromFrame = value.playhead.frame;+ began = performance.now();+ }+ if (!ready) return;+ const frame = (iframe.contentWindow as SeekWindow | null);+ if (playing) frame?.__svmlPlayFrame?.(value.playhead.frame);+ else frame?.__svmlSeekFrame?.(value.playhead.frame);+ // The overlay subscribed first, so it measured the picture as it was before+ // this seek. Redraw now that the picture has moved.+ overlay.refresh();+ });++ return { element, toggle };+}diff --git a/tools/svml-playground/src/ui/syntax.ts b/tools/svml-playground/src/ui/syntax.tsnew file mode 100644index 00000000..624e4d9f--- /dev/null+++ b/tools/svml-playground/src/ui/syntax.ts@@ -0,0 +1,195 @@+/**+ * A tokenizer for SVML's own surface syntax.+ *+ * SVML has a small, closed grammar — tags, quoted strings, whole-value+ * references, and Script prose with markers — so it is tokenized directly rather+ * than through a general highlighter that has no grammar for it. The Script+ * markers are the point: `@claim … @/claim` is what a Media Item binds to, so it+ * has to read as a distinct thing from an ordinary attribute.+ *+ * Tokens are non-overlapping and in source order. Gaps between them are plain+ * text; the renderer emits those verbatim, so the concatenation of everything is+ * always byte-identical to the source.+ */++export type TokenKind =+ | "header"+ | "comment"+ | "punct"+ | "tag"+ | "attr"+ | "string"+ | "reference"+ | "marker"+ | "role";++export type Token = {+ readonly start: number;+ readonly end: number;+ readonly kind: TokenKind;+ /** For `marker` tokens, the Selection or Moment the marker names. */+ readonly id?: string;+};++const NAME = /^[A-Za-z_][A-Za-z0-9_.:-]*/u;+const ATTRIBUTE = /^[A-Za-z_][A-Za-z0-9_.:-]*/u;+/**+ * The Script's own marker grammar: `@id` opens a Selection, `@/id` closes one,+ * `@id!` marks a Moment, and a leading `~` or trailing `~` chooses which side of+ * the neighbouring word the marker binds to.+ */+const MARKER = /^~?@\/?[a-z][a-z0-9_-]*[!~]?/u;++function localName(tag: string): string {+ const colon = tag.indexOf(":");+ return colon < 0 ? tag : tag.slice(colon + 1);+}++function isSpace(value: string | undefined): boolean {+ return value === " " || value === "\t" || value === "\n" || value === "\r";+}++export function tokenizeSvml(source: string): readonly Token[] {+ const tokens: Token[] = [];+ const push = (start: number, end: number, kind: TokenKind, id?: string): void => {+ if (end > start) tokens.push({ start, end, kind, ...(id === undefined ? {} : { id }) });+ };++ let cursor = 0;+ while (cursor < source.length) {+ if (source.startsWith("<?", cursor)) {+ const end = source.indexOf("?>", cursor + 2);+ const stop = end < 0 ? source.length : end + 2;+ push(cursor, stop, "header");+ cursor = stop;+ continue;+ }++ if (source.startsWith("<!--", cursor)) {+ const end = source.indexOf("-->", cursor + 4);+ const stop = end < 0 ? source.length : end + 3;+ push(cursor, stop, "comment");+ cursor = stop;+ continue;+ }++ if (source[cursor] === "<") {+ const closing = source[cursor + 1] === "/";+ const nameStart = cursor + (closing ? 2 : 1);+ const name = NAME.exec(source.slice(nameStart));+ if (name === null) {+ // A bare `<` in prose. Leave it as plain text so offsets never drift.+ cursor += 1;+ continue;+ }+ push(cursor, nameStart, "punct");+ push(nameStart, nameStart + name[0].length, "tag");+ cursor = nameStart + name[0].length;+ cursor = tokenizeAttributes(source, cursor, push);++ // Script is the language's one Raw Surface: its body is prose with+ // markers, not markup, and must be scanned by different rules.+ if (!closing && localName(name[0]) === "script" && source[cursor - 2] !== "/") {+ cursor = tokenizeScriptBody(source, cursor, name[0], push);+ }+ continue;+ }++ cursor += 1;+ }+ return tokens;+}++type Push = (start: number, end: number, kind: TokenKind, id?: string) => void;++/** Consume attributes through the tag's `>` or `/>`, whichever closes it. */+function tokenizeAttributes(source: string, from: number, push: Push): number {+ let cursor = from;+ while (cursor < source.length) {+ while (isSpace(source[cursor])) cursor += 1;+ if (source.startsWith("/>", cursor)) {+ push(cursor, cursor + 2, "punct");+ return cursor + 2;+ }+ if (source[cursor] === ">") {+ push(cursor, cursor + 1, "punct");+ return cursor + 1;+ }+ const name = ATTRIBUTE.exec(source.slice(cursor));+ if (name === null) return cursor + 1;+ push(cursor, cursor + name[0].length, "attr");+ cursor += name[0].length;++ while (isSpace(source[cursor])) cursor += 1;+ if (source[cursor] !== "=") continue;+ push(cursor, cursor + 1, "punct");+ cursor += 1;+ while (isSpace(source[cursor])) cursor += 1;++ const quote = source[cursor];+ if (quote === "\"" || quote === "'") {+ const close = source.indexOf(quote, cursor + 1);+ const stop = close < 0 ? source.length : close + 1;+ push(cursor, stop, "string");+ cursor = stop;+ continue;+ }+ if (quote === "{") {+ const close = source.indexOf("}", cursor + 1);+ const stop = close < 0 ? source.length : close + 1;+ push(cursor, stop, "reference");+ cursor = stop;+ continue;+ }+ }+ return cursor;+}++/** Script prose: Segment and Role Cue tags stay tags; `@id` markers stand out. */+function tokenizeScriptBody(source: string, from: number, tag: string, push: Push): number {+ const close = `</${tag}>`;+ let cursor = from;+ while (cursor < source.length) {+ if (source.startsWith(close, cursor)) {+ push(cursor, cursor + 2, "punct");+ push(cursor + 2, cursor + 2 + tag.length, "tag");+ push(cursor + 2 + tag.length, cursor + close.length, "punct");+ return cursor + close.length;+ }+ if (source.startsWith("<!--", cursor)) {+ const end = source.indexOf("-->", cursor + 4);+ const stop = end < 0 ? source.length : end + 3;+ push(cursor, stop, "comment");+ cursor = stop;+ continue;+ }+ if (source[cursor] === "<") {+ const closing = source[cursor + 1] === "/";+ const nameStart = cursor + (closing ? 2 : 1);+ const name = NAME.exec(source.slice(nameStart));+ if (name === null) { cursor += 1; continue; }+ const end = source.indexOf(">", nameStart);+ const stop = end < 0 ? source.length : end + 1;+ push(cursor, nameStart, "punct");+ // An upper-case tag inside Script is a Role Cue, not a Segment.+ push(nameStart, nameStart + name[0].length, /^[A-Z]/u.test(name[0]) ? "role" : "tag");+ push(nameStart + name[0].length, stop, "punct");+ cursor = stop;+ continue;+ }+ // A leading `~` binds the marker to the word on its left, and is part of it.+ if (source[cursor] === "@" || (source[cursor] === "~" && source[cursor + 1] === "@")) {+ const marker = MARKER.exec(source.slice(cursor));+ if (marker !== null) {+ // Strip the affinity sigils, the `@` and the closing `/` so an opening+ // marker, its closing marker and a Moment all report the same name.+ const id = marker[0].replace(/^~?@\/?/u, "").replace(/[!~]$/u, "");+ push(cursor, cursor + marker[0].length, "marker", id);+ cursor += marker[0].length;+ continue;+ }+ }+ cursor += 1;+ }+ return cursor;+}diff --git a/tools/svml-playground/src/ui/timeline.ts b/tools/svml-playground/src/ui/timeline.tsnew file mode 100644index 00000000..75f74a4f--- /dev/null+++ b/tools/svml-playground/src/ui/timeline.ts@@ -0,0 +1,302 @@+import type { PlaygroundSnapshot } from "../shared.js";+import { markerTones } from "./markers.js";+import type { State, Store } from "./selection.js";+import { createZoom } from "./zoom.js";++export type Timeline = { readonly element: HTMLElement };++/** Ruler ticks land on whole seconds until that gets too dense, then on 5s / 10s. */+function tickSeconds(durationSec: number, widthPx: number): number {+ for (const step of [1, 2, 5, 10, 15, 30, 60]) {+ if (durationSec / step <= Math.max(2, widthPx / 64)) return step;+ }+ return 120;+}++function timecode(seconds: number): string {+ const whole = Math.floor(seconds);+ return `${Math.floor(whole / 60)}:${String(whole % 60).padStart(2, "0")}`;+}++/**+ * A cutting-room timeline read straight from the Source: the Speech Spine on the+ * bottom track, every Media Item above it on one shared track, exactly as an+ * editor would lay them out.+ */+/** One row of one Track. A Track with overlapping clips is several rows tall. */+const LANE_HEIGHT = 52;++/** Tracks the reader has opened. A Track shows only its front row until then. */+const opened = new Set<string>();++/**+ * Where a frame sits across the strip, once the zoom window is taken into+ * account. Everything the timeline draws goes through here, so the ruler, the+ * clips and the playhead cannot disagree about where a moment is.+ */+function place(frame: number, frameCount: number, shown: { start: number; end: number }): number {+ const span = Math.max(1e-6, shown.end - shown.start);+ return (frame / Math.max(1, frameCount) - shown.start) / span;+}++export function createTimeline(store: Store): Timeline {+ const element = document.createElement("section");+ element.className = "timeline";+ element.innerHTML = `+ <div class="pane-heading">+ <h2>Timeline</h2>+ <span data-readout></span>+ </div>+ <div class="timeline-body">+ <div class="timeline-labels" data-labels></div>+ <div class="timeline-lanes" data-lanes>+ <div class="ruler" data-ruler></div>+ <div class="lanes" data-rows></div>+ <div class="playhead" data-playhead><div class="playhead-grip"></div></div>+ </div>+ </div>+ <div class="timeline-zoom" data-zoom></div>`;++ const readout = element.querySelector<HTMLElement>("[data-readout]")!;+ const labels = element.querySelector<HTMLElement>("[data-labels]")!;+ const lanes = element.querySelector<HTMLElement>("[data-lanes]")!;+ // The whole programme as a bar, with the shown part as a window inside it.+ const zoom = createZoom();+ element.querySelector<HTMLElement>("[data-zoom]")!.append(zoom.element);+ // Positions are computed against the window rather than scaled, so a clip's+ // label stays the size it was however far in the reader has zoomed.+ const ruler = element.querySelector<HTMLElement>("[data-ruler]")!;+ const rows = element.querySelector<HTMLElement>("[data-rows]")!;+ const playhead = element.querySelector<HTMLElement>("[data-playhead]")!;++ let state: State | undefined;+ let built = -1;++ const fps = (snapshot: PlaygroundSnapshot): number =>+ snapshot.space.frameRate.numerator / snapshot.space.frameRate.denominator;++ const frameAt = (clientX: number): number => {+ const box = lanes.getBoundingClientRect();+ if (box.width === 0 || state === undefined) return 0;+ // Where the pointer is inside the window that is shown, not inside the+ // whole programme; zoomed in, the two are different places.+ const across = (clientX - box.left) / box.width;+ const shown = zoom.window();+ const ratio = shown.start + across * (shown.end - shown.start);+ return Math.floor(ratio * state.snapshot.space.frameCount);+ };++ const scrub = (event: PointerEvent): void => {+ // Capture keeps a drag alive past the edge of the lanes, but it is not+ // essential: never let it stop the seek that the author actually asked for.+ try { lanes.setPointerCapture(event.pointerId); } catch { /* drag stays local */ }+ store.seek(frameAt(event.clientX), "timeline");+ };++ lanes.addEventListener("pointerdown", (event) => {+ // A click on a clip selects it; a click on open track or the ruler moves the+ // playhead and lets go of whatever was selected, because open track is the+ // one place that plainly means "not that one".+ if ((event.target as HTMLElement).closest(".clip") !== null) return;+ store.clearSelection();+ scrub(event);+ });+ lanes.addEventListener("pointermove", (event) => {+ if (event.buttons === 1 && lanes.hasPointerCapture(event.pointerId)) {+ store.seek(frameAt(event.clientX), "timeline");+ }+ });++ const drawRuler = (snapshot: PlaygroundSnapshot): void => {+ ruler.replaceChildren();+ const width = lanes.clientWidth;+ const step = tickSeconds(snapshot.space.durationSec, width);+ for (let seconds = 0; seconds <= snapshot.space.durationSec; seconds += step) {+ const tick = document.createElement("span");+ tick.className = "tick";+ const frame = seconds * snapshot.space.frameRate.numerator / snapshot.space.frameRate.denominator;+ const at = place(frame, snapshot.space.frameCount, zoom.window());+ tick.style.left = `${at * 100}%`;+ // A label near the end would hang past the strip and give the panel a+ // width nothing occupies, so the last one reads back from its own mark.+ if (at > 0.94) tick.classList.add("tick-last");+ tick.textContent = timecode(seconds);+ ruler.append(tick);+ }+ };++ const build = (snapshot: PlaygroundSnapshot): void => {+ labels.replaceChildren();+ rows.replaceChildren();+ const tones = markerTones(snapshot);++ const corner = document.createElement("div");+ corner.className = "label-corner";+ corner.textContent = `${snapshot.space.frameCount}f`;+ labels.append(corner);++ for (const track of snapshot.tracks) {+ const label = document.createElement("div");+ label.className = track.waiting === undefined ? "track-label" : "track-label track-waiting";+ label.innerHTML = "<strong></strong><small></small>";+ label.querySelector("strong")!.textContent = track.label;+ // What this Track is showing. Real material at measured times needs no+ // remark; anything else is a footnote the reader can open, because the+ // full sentence would not fit beside the strip.+ const said = {+ made: "Material this Source names.",+ "stand-in": "This shot has not been made. It shows a picture the Source names for it.",+ black: "This shot has no material and names no picture, so it shows a black frame.",+ waiting: `Not built here: waiting on ${(track.waiting ?? []).join(", ")}.`,+ }[track.source];+ const timing = track.timing === "measured"+ ? "Times were supplied."+ : "No times were supplied, so words are placed at an ordinary delivery pace.";+ const plain = track.source === "made" && track.timing === "measured";+ label.querySelector("small")!.textContent =+ `${track.clips.length} clip${track.clips.length === 1 ? "" : "s"}`;+ if (!plain) {+ const note = document.createElement("button");+ note.type = "button";+ note.className = `track-note note-${track.source}`;+ note.append("i");+ note.setAttribute("aria-label", `${said} ${timing}`);+ const bubble = document.createElement("span");+ bubble.className = "note-bubble";+ bubble.textContent = `${said} ${timing}`;+ note.append(bubble);+ // Fixed to the viewport so the panel it hangs out of cannot clip it,+ // which means it has to be told where the note is each time.+ note.addEventListener("pointerenter", () => {+ const box = note.getBoundingClientRect();+ bubble.style.left = `${box.right + 8}px`;+ bubble.style.top = `${Math.max(8, box.top + box.height / 2 - 30)}px`;+ });+ label.querySelector("small")!.append(note);+ }+ labels.append(label);++ // Clips that overlap in time cannot share a row without hiding each+ // other, so a Track is as many rows tall as it needs. A board's panel+ // runs the whole programme and its rows settle underneath it.+ // Packed by what is in front: the topmost row holds whatever is drawn over+ // everything else, so a folded Track shows the picture the viewer sees.+ const freeFrom: number[] = [];+ const rowOf = new Map<string, number>();+ const ordered = [...track.clips].sort((a, b) =>+ b.stackOrder - a.stackOrder || a.startFrame - b.startFrame);+ for (const clip of ordered) {+ let row = freeFrom.findIndex((free) => free <= clip.startFrame);+ if (row < 0) { row = freeFrom.length; freeFrom.push(0); }+ freeFrom[row] = clip.endFrameExclusive;+ rowOf.set(clip.id, row);+ }+ const depth = Math.max(1, freeFrom.length);+ const folded = depth > 1 && !opened.has(track.id);+ const shownRows = folded ? 1 : depth;+ label.style.height = `${shownRows * LANE_HEIGHT}px`;+ if (depth > 1) {+ const fold = document.createElement("button");+ fold.type = "button";+ fold.className = "track-fold";+ fold.textContent = folded ? `+${depth - 1}` : "\u2212";+ fold.title = folded ? `Show all ${depth} rows` : "Show only what is in front";+ fold.setAttribute("aria-expanded", String(!folded));+ fold.addEventListener("click", (event) => {+ event.stopPropagation();+ if (opened.has(track.id)) opened.delete(track.id);+ else opened.add(track.id);+ build(snapshot);+ paint();+ });+ label.querySelector("small")!.append(fold);+ }++ const lane = document.createElement("div");+ lane.className = "lane";+ lane.style.height = `${shownRows * LANE_HEIGHT}px`;+ for (const clip of track.clips) {+ const node = document.createElement("button");+ node.type = "button";+ node.className = "clip";+ node.dataset.clip = clip.id;+ const from = place(clip.startFrame, snapshot.space.frameCount, zoom.window());+ const to = place(clip.endFrameExclusive, snapshot.space.frameCount, zoom.window());+ node.style.left = `${from * 100}%`;+ const row = rowOf.get(clip.id) ?? 0;+ if (folded && row > 0) continue;+ node.style.top = `${row * LANE_HEIGHT}px`;+ node.style.width = `${(to - from) * 100}%`;+ node.title = `${clip.label} (${clip.startFrame}-${clip.endFrameExclusive}f)`;+ node.innerHTML = `<span class="clip-name"></span><span class="clip-meta"></span>`;+ node.querySelector(".clip-name")!.textContent = clip.label;+ node.querySelector(".clip-meta")!.textContent =+ `${((clip.endFrameExclusive - clip.startFrame) / fps(snapshot)).toFixed(2)}s`;+ if (clip.standIn !== undefined) node.classList.add(`clip-stand-in-${clip.standIn}`);+ // Same tone as the Script marker this clip is named after.+ const tone = tones.get(clip.authoredId);+ if (tone !== undefined) node.classList.add(`tone-${tone}`);+ node.addEventListener("click", () => store.selectClip(clip.id, "timeline"));+ lane.append(node);+ }+ rows.append(lane);+ }+ drawRuler(snapshot);+ };++ const paint = (): void => {+ if (state === undefined) return;+ const { snapshot, selection, playhead: head } = state;+ const percent = place(head.frame, snapshot.space.frameCount, zoom.window()) * 100;+ playhead.style.left = `${percent}%`;+ readout.textContent =+ `${head.frame} / ${snapshot.space.frameCount - 1}f (${(head.frame / fps(snapshot)).toFixed(2)}s)`;+ for (const node of Array.from(rows.querySelectorAll<HTMLElement>(".clip"))) {+ const id = node.dataset.clip!;+ node.classList.toggle("selected", selection.kind === "clip" && selection.clipId === id);+ const clip = store.clip(id);+ node.classList.toggle(+ "live",+ clip !== undefined && head.frame >= clip.startFrame && head.frame < clip.endFrameExclusive,+ );+ }+ };++ // A trackpad pinch is a wheel event with ctrlKey set; two fingers sideways is+ // a wheel with deltaX. Both are how a reader expects to move around a strip.+ lanes.addEventListener("wheel", (event) => {+ if (event.ctrlKey) {+ event.preventDefault();+ const box = lanes.getBoundingClientRect();+ const at = box.width === 0 ? 0.5 : (event.clientX - box.left) / box.width;+ zoom.pinch(at, Math.exp(event.deltaY * 0.01));+ return;+ }+ if (Math.abs(event.deltaX) <= Math.abs(event.deltaY)) return;+ event.preventDefault();+ zoom.slide(event.deltaX / Math.max(1, lanes.clientWidth));+ }, { passive: false });++ // Subscribed here rather than where the zoom is made: it reports its window+ // at once, and there is nothing to redraw until a Source has been read.+ zoom.subscribe(() => {+ if (state === undefined) return;+ build(state.snapshot);+ paint();+ });++ store.subscribe((value) => {+ state = value;+ if (value.snapshot.revision !== built) {+ built = value.snapshot.revision;+ build(value.snapshot);+ }+ paint();+ });++ new ResizeObserver(() => {+ if (state !== undefined) drawRuler(state.snapshot);+ }).observe(lanes);++ return { element };+}diff --git a/tools/svml-playground/src/ui/zoom.ts b/tools/svml-playground/src/ui/zoom.tsnew file mode 100644index 00000000..f5cd4df8--- /dev/null+++ b/tools/svml-playground/src/ui/zoom.ts@@ -0,0 +1,119 @@+/**+ * How much of the programme the timeline shows.+ *+ * A sixteen-second Source fits; a three-minute one does not, and reading a+ * cutaway that lasts twelve frames out of five thousand is not possible at one+ * pixel per forty frames. So the whole programme is drawn as a bar, and the+ * part currently on the timeline is a window inside it - dragged to move, or+ * taken by either edge to widen and narrow.+ */++export type Window = { readonly start: number; readonly end: number };++export type Zoom = {+ readonly element: HTMLElement;+ /** The visible fraction of the programme, from 0 to 1. */+ window(): Window;+ subscribe(listen: (window: Window) => void): void;+ /** Zoom about a point, given as a fraction across the visible window. */+ pinch(at: number, factor: number): void;+ /** Slide the window by a fraction of its own width. */+ slide(by: number): void;+};++/** Nothing smaller than this is readable, and nothing larger than all of it exists. */+const NARROWEST = 0.01;++export function createZoom(): Zoom {+ const element = document.createElement("div");+ element.className = "zoom";+ element.innerHTML = `+ <div class="zoom-window" data-window>+ <span class="zoom-grip zoom-grip-start" data-start></span>+ <span class="zoom-grip zoom-grip-end" data-end></span>+ </div>`;+ const held = element.querySelector<HTMLElement>("[data-window]")!;+ const startGrip = element.querySelector<HTMLElement>("[data-start]")!;+ const endGrip = element.querySelector<HTMLElement>("[data-end]")!;++ let window_: Window = { start: 0, end: 1 };+ const listeners: ((window: Window) => void)[] = [];++ const paint = (): void => {+ held.style.left = `${window_.start * 100}%`;+ held.style.width = `${(window_.end - window_.start) * 100}%`;+ for (const listen of listeners) listen(window_);+ };++ const settle = (start: number, end: number): void => {+ const width = Math.max(NARROWEST, Math.min(1, end - start));+ const from = Math.max(0, Math.min(1 - width, start));+ window_ = { start: from, end: from + width };+ paint();+ };++ /** Where a pointer is along the whole bar, as a fraction. */+ const fraction = (event: PointerEvent): number => {+ const box = element.getBoundingClientRect();+ return box.width === 0 ? 0 : Math.max(0, Math.min(1, (event.clientX - box.left) / box.width));+ };++ const drag = (+ node: HTMLElement,+ onMove: (at: number, began: Window, from: number) => void,+ ): void => {+ node.addEventListener("pointerdown", (event) => {+ event.preventDefault();+ event.stopPropagation();+ node.setPointerCapture(event.pointerId);+ const began = window_;+ const from = fraction(event);+ const move = (moved: PointerEvent): void => onMove(fraction(moved), began, from);+ const done = (): void => {+ node.removeEventListener("pointermove", move);+ node.removeEventListener("pointerup", done);+ node.releasePointerCapture(event.pointerId);+ };+ node.addEventListener("pointermove", move);+ node.addEventListener("pointerup", done);+ });+ };++ drag(held, (at, began, from) => {+ const shift = at - from;+ settle(began.start + shift, began.end + shift);+ });+ drag(startGrip, (at, began) => settle(Math.min(at, began.end - NARROWEST), began.end));+ drag(endGrip, (at, began) => settle(began.start, Math.max(at, began.start + NARROWEST)));++ // Clicking the bar outside the window centres the window there, which is the+ // fastest way across a long programme.+ element.addEventListener("pointerdown", (event) => {+ const width = window_.end - window_.start;+ const at = fraction(event);+ settle(at - width / 2, at + width / 2);+ });++ paint();+ return {+ element,+ window: () => window_,+ subscribe(listen) { listeners.push(listen); listen(window_); },+ /**+ * Pinching over the strip zooms about the point under the fingers, which is+ * how every other timeline behaves and the only gesture that keeps the clip+ * being read where it was.+ */+ pinch(at: number, factor: number) {+ const width = window_.end - window_.start;+ const wanted = Math.max(NARROWEST, Math.min(1, width * factor));+ const held = window_.start + width * Math.max(0, Math.min(1, at));+ settle(held - wanted * at, held + wanted * (1 - at));+ },+ /** Two fingers moved sideways slide the window without resizing it. */+ slide(by: number) {+ const width = window_.end - window_.start;+ settle(window_.start + by * width, window_.end + by * width);+ },+ };+}diff --git a/tools/svml-playground/start.ts b/tools/svml-playground/start.tsnew file mode 100644index 00000000..2a535642--- /dev/null+++ b/tools/svml-playground/start.ts@@ -0,0 +1,76 @@+import { dirname, resolve } from "node:path";+import { fileURLToPath } from "node:url";++import { createServer } from "vite";++import { svmlPlaygroundPlugin } from "./src/server.js";++const here = dirname(fileURLToPath(import.meta.url));+const repoRoot = resolve(here, "../..");++function usage(message?: string): never {+ if (message !== undefined) process.stderr.write(`${message}\n\n`);+ process.stderr.write(`Usage:+ pnpm svml:playground -- --source <main.svml> [--run <build.svrun>]+ [--runtime <svml.runtime.json>] [--port <number>]++The Playground reads the Source. It never writes to it, and it never runs a+Provider: with no build present it estimates timings from the Script text.+A Run Source is read for material it already names.+`);+ process.exit(1);+}++function argumentsByName(argv: readonly string[]): ReadonlyMap<string, string> {+ const result = new Map<string, string>();+ for (let index = 0; index < argv.length; index += 2) {+ const flag = argv[index];+ const value = argv[index + 1];+ if (flag === undefined || !flag.startsWith("--") || value === undefined || value.startsWith("--")) {+ usage(`Malformed argument near ${flag ?? "end of command"}`);+ }+ result.set(flag.slice(2), value);+ }+ return result;+}++const rawArguments = process.argv.slice(2);+const values = argumentsByName(rawArguments[0] === "--" ? rawArguments.slice(1) : rawArguments);+const sourceArgument = values.get("source");+if (sourceArgument === undefined || !sourceArgument.trim()) usage("Missing --source");+// `pnpm --filter … exec` runs inside the package directory, so a relative+// --source must be resolved against the directory the author typed it in.+const invokedFrom = process.env.INIT_CWD ?? process.cwd();+const source = resolve(invokedFrom, sourceArgument);+const runArgument = values.get("run");+const run = runArgument === undefined ? undefined : resolve(invokedFrom, runArgument);+// A Runtime profile says where material earlier builds produced is kept. Only a+// Source that reuses an accepted take needs one.+const runtimeArgument = values.get("runtime");+const runtime = runtimeArgument === undefined ? undefined : resolve(invokedFrom, runtimeArgument);+const packageRoot = resolve(repoRoot, "packages/video-cli/src");+const port = Number(values.get("port") ?? "5179");+if (!Number.isSafeInteger(port) || port <= 0) usage("--port must be a positive integer");++const server = await createServer({+ configFile: false,+ root: here,+ server: {+ port,+ fs: {+ allow: [...new Set([+ repoRoot, dirname(source),+ ...(run === undefined ? [] : [dirname(run)]),+ ...(runtime === undefined ? [] : [dirname(runtime)]),+ ])],+ },+ },+ plugins: [svmlPlaygroundPlugin({+ source, root: invokedFrom, packageRoot,+ ...(run === undefined ? {} : { run }),+ ...(runtime === undefined ? {} : { runtime }),+ })],+});++await server.listen();+server.printUrls();diff --git a/tools/svml-playground/test/markers.test.ts b/tools/svml-playground/test/markers.test.tsnew file mode 100644index 00000000..f7cf89b3--- /dev/null+++ b/tools/svml-playground/test/markers.test.ts@@ -0,0 +1,138 @@+import assert from "node:assert/strict";+import { mkdtempSync, writeFileSync } from "node:fs";+import { tmpdir } from "node:os";+import { join } from "node:path";+import test from "node:test";++import { readSource } from "../src/pipeline/session.js";+import { liveRanges, markerTones, spanAtOffset } from "../src/ui/markers.js";+import type { PlaygroundSnapshot } from "../src/shared.js";++/** `@outer` encloses `@inner`, and both sit inside the `<opening>` Segment. */+const SOURCE = `<?svml using="@narratage/markup@1"?>++<svml>+ <import from="@narratage/script@1"/>+ <import as="wording" from="@narratage/text@1"/>+ <import as="seedance" from="@narratage/seedance@1"/>+ <import as="whisperx" from="@narratage/whisperx@1"/>+ <import as="speech" from="@narratage/speech-spine@1"/>+ <import as="media-track" from="@narratage/media-track@1"/>+ <import as="space" from="@narratage/spatial@1"/>+ <import as="studio" source="./studio.svs"/>++ <script id="story">+ <opening><HOST>One @outer two three @inner four five@/inner six@/outer seven.</opening>+ <answer><HOST>Eight nine ten.</answer>+ </script>++ <space:Canvas id="vertical" width="1080" height="1920"/>+ <space:Frame id="full" within={vertical} left="0%" top="0%" right="100%" bottom="100%"/>++ <wording:Value id="direction">A person talking to camera.</wording:Value>+ <seedance:TextVideo id="take" model="mini" prompt={direction} duration="10" generate-audio="true"/>++ <speech:Spine id="speech" frame-rate="30"+ visual-frame={full} visual-appearance={studio.speech.visual} visual-z="0">+ <speech:Take video={take.video} segment={story.segment.opening}/>+ <speech:Take video={take.video} segment={story.segment.answer}/>+ </speech:Spine>+ <whisperx:Alignment id="timing" narrative={story} audio={speech.audio}/>++ <media-track:Track id="broll" map={timing.map} space={speech.space} canvas={vertical}>+ <media-track:Item id="on-outer" video={take.video} during={story.selection.outer}+ frame={full} appearance={studio.media.card}/>+ </media-track:Track>+</svml>+`;++const STYLES = `<?svml using="@narratage/svs@1"?>++<sheet version="1">+ speech.visual { fit: cover; }+ media.card { stack-order: 40; fit: cover; frame-paint: #16161d; }+</sheet>+`;++async function fixture(): Promise<PlaygroundSnapshot> {+ const directory = mkdtempSync(join(tmpdir(), "svml-playground-markers-"));+ writeFileSync(join(directory, "main.svml"), SOURCE, "utf8");+ writeFileSync(join(directory, "studio.svs"), STYLES, "utf8");+ return (await readSource({+ source: join(directory, "main.svml"), packageRoot: directory, revision: 1,+ })).snapshot;+}++test("a Segment is the outermost level and Selections nest inside it", async () => {+ const snapshot = await fixture();+ const segment = snapshot.script!.segments.find((item) => item.id === "opening")!;+ const outer = snapshot.script!.selections.find((item) => item.id === "outer")!;+ const inner = snapshot.script!.selections.find((item) => item.id === "inner")!;+ assert.equal(segment.depth, 0, "nothing encloses a Segment");+ assert.equal(outer.depth, 1, "its Segment encloses it");+ assert.equal(inner.depth, 2, "its Segment and @outer both enclose it");+});++test("tones follow the level, not the identity", async () => {+ const snapshot = await fixture();+ const tones = markerTones(snapshot);+ // Two Segments are the same kind of thing, so they read the same.+ assert.equal(tones.get("opening"), tones.get("answer"));+ assert.notEqual(tones.get("opening"), tones.get("outer"));+ assert.notEqual(tones.get("outer"), tones.get("inner"));+});++test("an enclosing range stays live while an inner one is", async () => {+ const snapshot = await fixture();+ const inner = snapshot.script!.selections.find((item) => item.id === "inner")!;+ const tokens = snapshot.script!.tokens.filter((token) =>+ token.range.start >= inner.occurrences[0]!.open.start+ && token.range.end <= inner.occurrences[0]!.close.end);+ const middle = Math.floor((tokens[0]!.startFrame + tokens.at(-1)!.endFrame) / 2);++ // Nesting is the whole point of the markers: replacing the outer outline with+ // the inner one would hide the relationship being expressed.+ const live = liveRanges(snapshot, middle).map((span) => span.id);+ assert.deepEqual(live, ["opening", "outer", "inner"], "outermost first");+});++test("a range that binds nothing is still live", async () => {+ // Only @outer drives a Media Item. @inner places nothing, and still means+ // something, so it must appear.+ const snapshot = await fixture();+ const bound = snapshot.tracks.flatMap((track) => track.clips).map((clip) => clip.authoredId);+ assert.ok(!bound.includes("inner"));+ const inner = snapshot.script!.selections.find((item) => item.id === "inner")!;+ const tokens = snapshot.script!.tokens.filter((token) =>+ token.range.start >= inner.occurrences[0]!.open.start+ && token.range.end <= inner.occurrences[0]!.close.end);+ const middle = Math.floor((tokens[0]!.startFrame + tokens.at(-1)!.endFrame) / 2);+ assert.ok(liveRanges(snapshot, middle).some((span) => span.id === "inner"));+});++test("nothing is live outside the speech", async () => {+ const snapshot = await fixture();+ assert.deepEqual(liveRanges(snapshot, snapshot.space.frameCount + 100), []);+});++test("an offset resolves to the tightest range written around it", async () => {+ const snapshot = await fixture();+ const text = snapshot.source.text;+ // Clicking marked prose should land in the innermost claim, not its parent.+ assert.equal(spanAtOffset(snapshot, text.indexOf("four"))?.id, "inner");+ assert.equal(spanAtOffset(snapshot, text.indexOf("two"))?.id, "outer");+ assert.equal(spanAtOffset(snapshot, text.indexOf("seven"))?.id, "opening");+ assert.equal(spanAtOffset(snapshot, text.indexOf("Eight"))?.id, "answer");+ assert.equal(spanAtOffset(snapshot, text.indexOf("<space:Canvas")), undefined);+});++test("a resolved span carries the frame its speech starts on", async () => {+ const snapshot = await fixture();+ const text = snapshot.source.text;+ const inner = spanAtOffset(snapshot, text.indexOf("four"))!;+ const outer = spanAtOffset(snapshot, text.indexOf("two"))!;+ // Landing on the inner marker's own first frame is what keeps a click from+ // being thrown out to whatever encloses it.+ assert.ok(inner.startFrame > outer.startFrame);+ assert.ok(inner.endFrame <= outer.endFrame);+});diff --git a/tools/svml-playground/test/pipeline.test.ts b/tools/svml-playground/test/pipeline.test.tsnew file mode 100644index 00000000..2b7c79ae--- /dev/null+++ b/tools/svml-playground/test/pipeline.test.ts@@ -0,0 +1,264 @@+import assert from "node:assert/strict";+import { execFileSync } from "node:child_process";+import { mkdtempSync, writeFileSync } from "node:fs";+import { tmpdir } from "node:os";+import { join } from "node:path";+import test from "node:test";++import { estimateTiming } from "../src/pipeline/estimate.js";+import { preview } from "../src/pipeline/preview.js";+import { readSource } from "../src/pipeline/session.js";++const SOURCE = `<?svml using="@narratage/markup@1"?>++<svml>+ <import from="@narratage/script@1"/>+ <import as="wording" from="@narratage/text@1"/>+ <import as="seedance" from="@narratage/seedance@1"/>+ <import as="whisperx" from="@narratage/whisperx@1"/>+ <import as="speech" from="@narratage/speech-spine@1"/>+ <import as="media-track" from="@narratage/media-track@1"/>+ <import as="space" from="@narratage/spatial@1"/>+ <import as="studio" source="./studio.svs"/>++ <script id="story">+ <opening><HOST>One @claim two three four@/claim five six.</opening>+ </script>++ <space:Canvas id="vertical" width="1080" height="1920"/>+ <space:Frame id="full" within={vertical} left="0%" top="0%" right="100%" bottom="100%"/>++ <wording:Value id="direction">A person talking to camera.</wording:Value>+ <seedance:TextVideo id="take" model="mini" prompt={direction} duration="10" generate-audio="true"/>+ <seedance:TextVideo id="cut" model="mini" prompt={direction} duration="5"/>++ <speech:Spine id="speech" frame-rate="24"+ visual-frame={full} visual-appearance={studio.speech.visual} visual-z="0">+ <speech:Take video={take.video} segment={story.segment.opening}/>+ </speech:Spine>+ <whisperx:Alignment id="timing" narrative={story} audio={speech.audio}/>++ <media-track:Track id="broll" map={timing.map} space={speech.space} canvas={vertical}>+ <media-track:Item id="on-claim" video={cut.video} during={story.selection.claim}+ frame={full} appearance={studio.media.card}/>+ </media-track:Track>+</svml>+`;++const STYLES = `<?svml using="@narratage/svs@1"?>++<sheet version="1">+ speech.visual { fit: cover; }+ media.card { stack-order: 40; fit: cover; frame-paint: #16161d; }+</sheet>+`;++/**+ * Standing in for material nobody has shot needs a tool to draw with. Where+ * there is none - which is every machine that has not installed ffmpeg, CI+ * among them - a Track with no footage cannot be built, and the preview says so+ * instead of drawing something.+ */+const CAN_DRAW = (() => {+ try {+ execFileSync("ffmpeg", ["-version"], { stdio: "ignore", timeout: 10_000 });+ return true;+ } catch {+ return false;+ }+})();++function project(run?: string): string {+ const directory = mkdtempSync(join(tmpdir(), "svml-playground-pipeline-"));+ writeFileSync(join(directory, "main.svml"), SOURCE, "utf8");+ writeFileSync(join(directory, "studio.svs"), STYLES, "utf8");+ if (run !== undefined) writeFileSync(join(directory, "build.svrun"), run, "utf8");+ return directory;+}++/**+ * A Source on its own has neither footage nor timings, which is the state it+ * spends most of its life in. It still has to be watchable, and it has to say+ * which parts of what is shown were invented.+ */+test("a Source with no Run Source still builds every Track", async () => {+ const directory = project();+ const built = await preview(join(directory, "main.svml"));++ // Timings are placed from the Script's own words, which needs no tool at all.+ assert.equal(built.timing, "estimated", "nothing supplied timings");+ assert.ok(built.tracks.length > 0, "the Source's Tracks were found");+ if (!CAN_DRAW) {+ assert.equal(built.placeholders.length, 0, "nothing was stood in for without a tool to draw it");+ return;+ }+ assert.ok(built.placeholders.length > 0, "material nobody supplied stands in");+ const drawn = built.tracks.filter((track) => track.track !== undefined);+ assert.ok(drawn.length >= 2, `speech and B-roll both build; built ${drawn.map((t) => t.name).join(",")}`);+ // Placing words at a guessed pace is not knowing when they are said, and a+ // preview that does not distinguish the two is lying about what it shows.+ assert.ok(+ built.tracks.every((track) => track.track === undefined || track.unserved.length === 0),+ "a Track that was built was not also reported as waiting",+ );+});++test("a Track nobody can build costs only itself", async () => {+ const directory = project();+ const built = await preview(join(directory, "main.svml"));+ // A Track that could not be built has to say what it was waiting for,+ // whether that is a Provider or the material itself.+ for (const track of built.tracks) {+ if (track.track !== undefined) continue;+ assert.ok(+ track.unserved.length > 0 || track.errors.length > 0,+ `${track.name} says why it has no picture`,+ );+ }+ if (!CAN_DRAW) return;+ assert.ok(+ built.tracks.some((track) => track.track !== undefined),+ "one Track waiting does not stop the others",+ );+});++/**+ * A Run Source that names material this machine has never produced is an+ * ordinary state part-way through a production, not a broken Source.+ */+test("material an earlier build produced is refused with a reason, not a crash", async () => {+ const directory = project(`<?svml using="@narratage/run-markup@1"?>++<svrun version="1">+ <author source="./main.svml"/>+ <target output="broll.visual"/>+ <build-record id="accepted" build="never-built-here" output="take.video"/>+ <satisfy output="take.video" candidate="accepted"/>+</svrun>+`);+ const built = await preview(join(directory, "main.svml"), join(directory, "build.svrun"));+ // Reading the Run Source and reporting what it could not reach needs no tool;+ // only drawing a stand-in does.+ assert.ok(built.refused.length > 0, "the preview says what it could not read");+ assert.ok(built.tracks.length > 0, "and still opens");+ if (CAN_DRAW) assert.ok(built.tracks.some((track) => track.track !== undefined));+ assert.match(built.refused.map((item) => item.reason).join(" "), /never-built-here/u);+});++test("a snapshot points its clips back at the tags that placed them", async () => {+ const directory = project();+ const { snapshot } = await readSource({+ source: join(directory, "main.svml"), packageRoot: directory, revision: 7,+ });+ assert.equal(snapshot.revision, 7);+ // Without a tool to draw stand-ins there are no Presents, so there is no+ // timeline to point anywhere.+ if (!CAN_DRAW) return;+ assert.ok(snapshot.space.frameCount > 1);+ const clips = snapshot.tracks.flatMap((track) => track.clips);+ assert.ok(clips.length > 0, "the timeline is not empty");+ const placed = clips.filter((clip) => clip.elementRange !== undefined);+ assert.ok(placed.length > 0, "at least one clip knows which tag placed it");+ for (const clip of placed) {+ const written = snapshot.source.text.slice(clip.elementRange!.start, clip.elementRange!.end);+ assert.match(written, /^</u, `${clip.id} points at a tag, not at the middle of one`);+ }+ // Every Present the picture draws must be addressable, or selecting a clip+ // could not box it.+ assert.match(snapshot.preview.srcdoc, /data-svml-present-id/u);+});++test("the Script's markers carry the frames its words are said on", async () => {+ const directory = project();+ const { snapshot } = await readSource({+ source: join(directory, "main.svml"), packageRoot: directory, revision: 1,+ });+ assert.ok(snapshot.script !== undefined, "the Script reported where its markers are");+ assert.ok(snapshot.script.selections.some((item) => item.id === "claim"));+ assert.ok(snapshot.script.tokens.length > 0, "words are placed on the timeline");+ for (const token of snapshot.script.tokens) {+ assert.ok(token.endFrame >= token.startFrame, `${token.id} does not run backwards`);+ }+});++/** Estimation is arithmetic over identities the packages own, and must be stable. */+test("estimated timings are strictly increasing and reproducible", () => {+ const narrative = {+ segments: [{ id: "a", startAnchorId: "segment:a:start", endAnchorId: "segment:a:end" }],+ tokens: [+ { id: "t1", segmentId: "a", startAnchorId: "t1:s", endAnchorId: "t1:e", text: "Extraordinary" },+ { id: "t2", segmentId: "a", startAnchorId: "t2:s", endAnchorId: "t2:e", text: "," },+ { id: "t3", segmentId: "a", startAnchorId: "t3:s", endAnchorId: "t3:e", text: "yes" },+ ],+ };+ const rate = { numerator: 24, denominator: 1 };+ const first = estimateTiming(narrative, rate);+ assert.deepEqual(first, estimateTiming(narrative, rate), "the same words give the same times");++ const anchors = (first.map as { anchors: readonly { identity: string; frame: number }[] }).anchors;+ const frames = new Map(anchors.map((anchor) => [anchor.identity, anchor.frame]));+ // A word that occupies no frames cannot be pointed at, and punctuation is+ // still a word for this purpose.+ for (const token of narrative.tokens) {+ assert.ok(frames.get(token.endAnchorId)! > frames.get(token.startAnchorId)!, `${token.text} occupies time`);+ }+ assert.equal(frames.get("segment:a:start"), 0, "a Segment opens where its first word does");+ assert.equal(frames.get("segment:a:end"), frames.get("t3:e"), "and closes where its last one ends");+});++/**+ * A build reads assets only from the Source's own directory. A preview that+ * read further would show a Source that cannot be built, which is the one thing+ * it must never do.+ */+test("an asset outside the Source's directory is refused, as a build refuses it", async () => {+ const directory = mkdtempSync(join(tmpdir(), "svml-playground-boundary-"));+ const outside = mkdtempSync(join(tmpdir(), "svml-playground-outside-"));+ writeFileSync(join(outside, "stray.png"), "not really a picture", "utf8");+ writeFileSync(join(directory, "main.svml"), `<?svml using="@narratage/markup@1"?>++<svml>+ <import from="@narratage/script@1"/>+ <import as="media" from="@narratage/media@1"/>+ <script id="story"><opening><HOST>One two.</opening></script>+ <media:Image id="stray" src="${join(outside, "stray.png")}"/>+</svml>+`, "utf8");++ await assert.rejects(+ async () => await preview(join(directory, "main.svml")),+ (error: unknown) => {+ const message = (error as Error).message;+ assert.match(message, /outside/u, "the reason names the boundary");+ assert.match(message, /stray\.png/u, "and the file that crossed it");+ return true;+ },+ );+});++/**+ * How long a programme runs is what the Source says, not what this machine+ * managed to draw. Stand-ins need a tool to draw with, and a machine without+ * one drew nothing; the timeline shrank to a single frame while the words still+ * ran to the end, so a marker past the end read as live. Every machine has to+ * agree about the length, whatever it can picture.+ */+test("the programme is as long as the Source says, drawn or not", async () => {+ const directory = project();+ const built = await preview(join(directory, "main.svml"));+ const { snapshot } = await readSource({+ source: join(directory, "main.svml"), packageRoot: directory, revision: 1,+ });++ const spoken = Math.max(0, ...(snapshot.script?.tokens ?? []).map((token) => token.endFrame));+ assert.ok(spoken > 0, "the Script was placed");+ assert.ok(+ snapshot.space.frameCount >= spoken,+ `the timeline (${snapshot.space.frameCount}f) covers every word (${spoken}f)`,+ );+ // Which is the same claim the Tracks were built against.+ const drawn = Math.max(0, ...built.tracks.flatMap((track) =>+ ((track.track as { presents?: readonly { span: { endFrameExclusive: number } }[] } | undefined)?.presents ?? [])+ .map((present) => present.span.endFrameExclusive)));+ assert.ok(snapshot.space.frameCount >= drawn, "and covers every clip");+});diff --git a/tools/svml-playground/test/syntax.test.ts b/tools/svml-playground/test/syntax.test.tsnew file mode 100644index 00000000..c4f1008b--- /dev/null+++ b/tools/svml-playground/test/syntax.test.ts@@ -0,0 +1,79 @@+import assert from "node:assert/strict";+import { readFileSync } from "node:fs";+import test from "node:test";++import { tokenizeSvml } from "../src/ui/syntax.js";++const SOURCE = readFileSync(+ new URL("../../../examples/talking-film-broll-preview/main.svml", import.meta.url),+ "utf8",+);++function kindsOf(source: string): readonly string[] {+ return tokenizeSvml(source).map((token) => source.slice(token.start, token.end) + `:${token.kind}`);+}++test("tokens are ordered and never overlap", () => {+ let previous = 0;+ for (const token of tokenizeSvml(SOURCE)) {+ assert.ok(token.start >= previous, `token at ${token.start} overlaps the one before it`);+ assert.ok(token.end > token.start, "a token must cover at least one character");+ previous = token.end;+ }+});++test("the rendered text reconstructs the source exactly", () => {+ // The code pane emits one text node per token and per gap, so any character+ // the tokenizer skipped or double-counted would corrupt the pane and every+ // offset the highlight geometry depends on.+ let rebuilt = "";+ let cursor = 0;+ for (const token of tokenizeSvml(SOURCE)) {+ rebuilt += SOURCE.slice(cursor, token.start) + SOURCE.slice(token.start, token.end);+ cursor = token.end;+ }+ rebuilt += SOURCE.slice(cursor);+ assert.equal(rebuilt, SOURCE);+});++test("the Source Header, tags, attributes and references are distinguished", () => {+ const kinds = kindsOf(`<?svml using="@narratage/markup@1"?>+<svml>+ <space:Frame id="card-a" within={vertical} left="8%"/>+</svml>+`);+ assert.ok(kinds.includes(`<?svml using="@narratage/markup@1"?>:header`));+ assert.ok(kinds.includes("space:Frame:tag"));+ assert.ok(kinds.includes("id:attr"));+ assert.ok(kinds.includes(`"card-a":string`));+ assert.ok(kinds.includes("{vertical}:reference"));+});++test("Script markers and Role Cues are highlighted inside the Script body", () => {+ const kinds = kindsOf(`<svml>+ <script id="story">+ <opening><HOST>A @claim marked phrase@/claim ends here.</opening>+ </script>+</svml>+`);+ assert.ok(kinds.includes("@claim:marker"), "an opening marker is a marker");+ assert.ok(kinds.includes("@/claim:marker"), "a closing marker is a marker");+ assert.ok(kinds.includes("HOST:role"), "an upper-case Script tag is a Role Cue");+ assert.ok(kinds.includes("opening:tag"), "a lower-case Script tag is a Segment");+ // Prose between markers stays untokenized, so it renders in the plain colour.+ assert.ok(!kinds.some((entry) => entry.startsWith("marked phrase")));+});++test("comments are one token, including any markup inside them", () => {+ const kinds = kindsOf("<svml>\n <!-- <space:Frame id=\"x\"/> -->\n</svml>\n");+ assert.ok(kinds.includes(`<!-- <space:Frame id="x"/> -->:comment`));+ assert.ok(!kinds.includes("space:Frame:tag"), "markup inside a comment is not a tag");+});++test("an unterminated construct consumes the rest rather than looping", () => {+ for (const broken of ["<?svml using=", "<!-- open", "<space:Frame id=\"x", "<space:Frame id={x"]) {+ const tokens = tokenizeSvml(broken);+ assert.ok(tokens.length > 0, `${broken} produced no tokens`);+ assert.ok(tokens.at(-1)!.end <= broken.length);+ }+});diff --git a/tsconfig.json b/tsconfig.jsonindex 7846525f..3708592d 100644--- a/tsconfig.json+++ b/tsconfig.json@@ -20,7 +20,8 @@"include": ["packages/**/*.ts","services/media-lambda/src/**/*.ts",- "tools/caption-playground/**/*.ts"+ "tools/caption-playground/**/*.ts",+ "tools/svml-playground/**/*.ts"],"exclude": ["dist",