@skilldeck/studio 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "studio",
3
+ "version": "0.1.0",
4
+ "description": "Make videos from HTML, deterministically: compositions with a seekable clock, timed scenes and SRT/VTT captions, a linter for timeline gaps, overlaps, missing assets and non-deterministic code, and a frame-by-frame renderer that drives local headless Chrome over CDP and encodes with ffmpeg. Zero-dependency Node.js 22, no cloud services.",
5
+ "author": {
6
+ "name": "SkillDeck"
7
+ },
8
+ "license": "MIT",
9
+ "keywords": [
10
+ "video",
11
+ "html-to-video",
12
+ "motion-graphics",
13
+ "captions",
14
+ "headless-chrome",
15
+ "ffmpeg"
16
+ ]
17
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 kitasid
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,60 @@
1
- # Temporary Holding Version
1
+ # studio
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **Make videos from HTML, deterministically.**
4
+
5
+ Title cards, captioned clips, product walkthroughs and chart animations are easiest to build as web pages, and hardest to turn into a video that looks the same every time. This pack gives a coding agent two skills and four zero-dependency tools: write the composition as HTML on a seekable clock, lint it for the bugs that ruin renders, then render it frame by frame with your own headless Chrome and ffmpeg.
6
+
7
+ | Skill | Use when | Tools |
8
+ |---|---|---|
9
+ | `video-compose` | Building a video, clip, title card or animated chart from code | `init` copies a working starter (runtime, scenes, captions); contract and pattern references |
10
+ | `video-render` | Turning a composition into MP4 / WebM / MOV / GIF, or debugging flicker and black frames | `lint-comp.mjs`, `render.mjs` (snapshot + render over raw CDP), `doctor.mjs` |
11
+
12
+ Everything runs locally. No cloud renderer, no account, no upload: Chrome listens on 127.0.0.1 only, and the composition is loaded from `file://`.
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ npx @skilldeck/studio install # Claude Code, user-wide
18
+ npx @skilldeck/studio install --project # this repo only
19
+ npx @skilldeck/studio install --agent all # also Codex and .agents
20
+ # or, with every SkillDeck pack available:
21
+ npx @skilldeck/cli add studio
22
+ ```
23
+
24
+ Claude Code marketplace: `/plugin marketplace add kitasid/skilldeck`, then `/plugin install studio@skilldeck`.
25
+
26
+ Requires Node 22+ (for the built-in WebSocket), a Chromium browser (Chrome, Chromium, Edge or Brave; or set `CHROME_PATH`), and ffmpeg on PATH to encode. Without ffmpeg, `render` writes PNG frames and prints the exact command.
27
+
28
+ ## Use the tools yourself
29
+
30
+ ```bash
31
+ npx @skilldeck/studio doctor --launch # Node, Chrome, ffmpeg, and a live CDP round trip
32
+ npx @skilldeck/studio init clip.html --captions subs.srt # starter composition with your captions
33
+ npx @skilldeck/studio lint clip.html # timeline, assets, determinism, fonts, captions
34
+ npx @skilldeck/studio snapshot clip.html --at 0,2.5,5 # PNG stills of exact frames
35
+ npx @skilldeck/studio render clip.html --out clip.mp4 # every frame, then ffmpeg
36
+ ```
37
+
38
+ Each script also runs directly with `node` and takes `--json`. Exit codes everywhere: `0` ok, `1` findings or failure, `2` usage or environment error.
39
+
40
+ ## How a composition works
41
+
42
+ ```html
43
+ <main data-composition data-width="1920" data-height="1080" data-fps="30" data-duration="6">
44
+ <section data-scene id="title" data-start="0" data-duration="2">…</section>
45
+ <section data-scene id="chart" data-start="2" data-duration="4">…</section>
46
+ <section data-scene id="captions" data-track="1" data-start="0" data-duration="6"><p data-caption-target></p></section>
47
+ </main>
48
+ ```
49
+
50
+ The inline runtime exposes `window.__studio.seek(t)`. On each seek it toggles scenes, shows the active caption cue, runs `onSeek` hooks, pauses every CSS and Web Animation and sets its time relative to its scene, seeks media, and waits for fonts and paint. The renderer calls it for `t = i / fps` and screenshots each frame, so the same file always produces the same pixels. Open the file in a browser for a scrubber that uses the same clock.
51
+
52
+ ## What the linter catches
53
+
54
+ - **Timeline:** gaps and overlaps on the main track, overlaps within overlay tracks, scenes past the end, cuts between frames.
55
+ - **Assets:** missing local files (HTML, CSS `url()`, `srcset`, inline styles, linked stylesheets and scripts), root-absolute paths, anything remote.
56
+ - **Determinism:** `Math.random`, `Date.now`, `new Date()`, `performance.now`, `setInterval`, `setTimeout` and `requestAnimationFrame` loops, `fetch` / XHR / WebSocket, CSS transitions, `<video autoplay>`.
57
+ - **Fonts:** webfont services and `@font-face` files without a `<link rel="preload">`.
58
+ - **Captions:** malformed SRT/VTT timings, overlapping cues, cues past the end, no caption target.
59
+
60
+ MIT licensed. Node 22+. No dependencies beyond `@skilldeck/core` for the installer.
package/bin/studio.mjs ADDED
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env node
2
+ import { spawnSync } from 'node:child_process'
3
+ import { runPackCli } from '@skilldeck/core'
4
+ import pack, { scripts } from '../index.mjs'
5
+
6
+ // Commands run the exact scripts the skills ship, so CLI and agent behave identically.
7
+ function run(script, args) {
8
+ const r = spawnSync(process.execPath, [script, ...args], { stdio: 'inherit' })
9
+ process.exitCode = r.status ?? 1
10
+ }
11
+
12
+ await runPackCli(pack, process.argv.slice(2), {
13
+ extraCommands: {
14
+ init: (args) => run(scripts.init, args),
15
+ lint: (args) => run(scripts.lint, args),
16
+ snapshot: (args) => run(scripts.render, ['snapshot', ...args]),
17
+ render: (args) => run(scripts.render, ['render', ...args]),
18
+ doctor: (args) => run(scripts.doctor, args),
19
+ },
20
+ extraHelp: `
21
+ Video commands (no agent needed; add --json for machine-readable output):
22
+ studio-skills init [file] [--captions subs.srt] start a composition from the template
23
+ studio-skills lint <comp.html> [--strict] timeline, assets, determinism, fonts, captions
24
+ studio-skills snapshot <comp.html> [--at 0,1.5] PNG stills at given times (default: each scene)
25
+ studio-skills render <comp.html> [--out clip.mp4] frame-by-frame render, encoded with ffmpeg
26
+ studio-skills doctor [--launch] check Node 22, Chrome and ffmpeg
27
+
28
+ Exit codes: 0 ok, 1 findings or failure, 2 usage or environment error.
29
+ `,
30
+ })
package/index.mjs ADDED
@@ -0,0 +1,24 @@
1
+ import fs from 'node:fs'
2
+ import path from 'node:path'
3
+ import { fileURLToPath } from 'node:url'
4
+
5
+ const root = path.dirname(fileURLToPath(import.meta.url))
6
+ const { version } = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'))
7
+
8
+ /** Pack descriptor consumed by @skilldeck/core. */
9
+ export default {
10
+ name: 'studio',
11
+ version,
12
+ root,
13
+ description: 'Deterministic HTML-to-video: compose scenes on a seekable clock, lint, snapshot, render with local Chrome + ffmpeg.',
14
+ skills: ['video-compose', 'video-render'],
15
+ }
16
+
17
+ export const scripts = {
18
+ init: path.join(root, 'skills', 'video-compose', 'scripts', 'init.mjs'),
19
+ lint: path.join(root, 'skills', 'video-render', 'scripts', 'lint-comp.mjs'),
20
+ render: path.join(root, 'skills', 'video-render', 'scripts', 'render.mjs'),
21
+ doctor: path.join(root, 'skills', 'video-render', 'scripts', 'doctor.mjs'),
22
+ }
23
+
24
+ export const template = path.join(root, 'skills', 'video-compose', 'templates', 'composition.html')
package/package.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "@skilldeck/studio",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Turn HTML into video, deterministically: author compositions with a seekable clock, scenes and captions, lint them for timeline and determinism bugs, then render frame by frame with local headless Chrome and ffmpeg. Zero-dependency Node.js, nothing uploaded.",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": "./index.mjs"
8
+ },
9
+ "main": "./index.mjs",
10
+ "bin": {
11
+ "studio-skills": "bin/studio.mjs"
12
+ },
13
+ "files": [
14
+ "index.mjs",
15
+ "bin/",
16
+ "skills/",
17
+ ".claude-plugin/",
18
+ "README.md",
19
+ "LICENSE"
20
+ ],
21
+ "dependencies": {
22
+ "@skilldeck/core": "^0.1.1"
23
+ },
24
+ "engines": {
25
+ "node": ">=22"
26
+ },
27
+ "license": "MIT",
28
+ "keywords": [
29
+ "claude-code",
30
+ "agent-skills",
31
+ "skill-md",
32
+ "video",
33
+ "html-to-video",
34
+ "motion-graphics",
35
+ "captions",
36
+ "srt",
37
+ "webvtt",
38
+ "headless-chrome",
39
+ "cdp",
40
+ "ffmpeg"
41
+ ],
42
+ "publishConfig": {
43
+ "access": "public"
44
+ },
45
+ "author": "kitasid"
46
+ }
@@ -0,0 +1,106 @@
1
+ ---
2
+ name: video-compose
3
+ description: Use when asked to make a video, animated clip, title card, explainer, product walkthrough, captioned social clip or chart animation from code, before writing any HTML for it; covers authoring a deterministic HTML composition with timed scenes, a seekable clock and SRT/VTT captions that renders identically every time.
4
+ ---
5
+
6
+ # Video Compose
7
+
8
+ A video made from HTML is only as good as its determinism. The renderer does not play the page; it seeks a clock to each frame time and takes a screenshot. If any pixel depends on wall-clock time, randomness, the network or load order, frames flicker and two renders differ. This skill writes compositions where every frame is a pure function of `t`.
9
+
10
+ Announce: "Using video-compose to build a <length>s <size> composition for <purpose>."
11
+
12
+ ## The Rule
13
+
14
+ ```
15
+ Every pixel is a function of the seek time t. Nothing else.
16
+ ```
17
+
18
+ No `Math.random`, no `Date.now`, no timers, no network, no CSS transitions. Motion comes from `@keyframes` (positioned by the runtime) or from `__studio.onSeek(fn)`.
19
+
20
+ **File locations.** The template is `${CLAUDE_SKILL_DIR}/templates/composition.html`; the contract and patterns are in `${CLAUDE_SKILL_DIR}/references/`. If `CLAUDE_SKILL_DIR` is not set, use the directory holding this SKILL.md. The renderer and linter live in the sibling [[video-render]] skill.
21
+
22
+ ## Checklist
23
+
24
+ ```
25
+ - [ ] 1. Brief pinned: purpose, length, size, fps, scenes with timings, captions, assets
26
+ - [ ] 2. Started from the template (runtime included)
27
+ - [ ] 3. Main track covers 0..duration with no gaps or overlaps; overlays on track 1+
28
+ - [ ] 4. Motion from scene-relative @keyframes or onSeek hooks only
29
+ - [ ] 5. Assets local and relative; fonts preloaded; captions embedded
30
+ - [ ] 6. Lint clean, then snapshots reviewed, before any full render
31
+ ```
32
+
33
+ ## 1. Pin the brief
34
+
35
+ Before writing markup, settle and state:
36
+
37
+ - **Output:** `1920x1080` landscape, `1080x1920` vertical or `1080x1080` square; `30` fps unless the user wants `24` (filmic) or `60` (UI motion).
38
+ - **Duration and a scene table:** `id`, start, duration, what is on screen, what moves. Durations sum to the total. Cut on frame boundaries (at 30 fps, multiples of 1/30s; tenths of a second are safe at 30).
39
+ - **Captions:** an SRT/VTT file to embed, or lines to write.
40
+ - **Assets:** which images, recordings, fonts and data the user provides. Anything remote gets downloaded next to the HTML first.
41
+
42
+ If the user gave only a goal ("a 10s launch clip"), propose the scene table and confirm it.
43
+
44
+ ## 2. Start from the template
45
+
46
+ ```bash
47
+ npx @skilldeck/studio init video/launch.html --captions subs.srt # or:
48
+ cp ${CLAUDE_SKILL_DIR}/templates/composition.html video/launch.html
49
+ ```
50
+
51
+ The template is a working 6s composition: title card, chart reveal, end card and a caption overlay, with the runtime inline in `<script data-studio-runtime>`. Keep the runtime and the "studio base" CSS. Replace the scenes.
52
+
53
+ ## 3. Lay out the timeline
54
+
55
+ ```html
56
+ <main data-composition data-width="1920" data-height="1080" data-fps="30" data-duration="9">
57
+ <section data-scene id="title" data-start="0" data-duration="2.5">…</section>
58
+ <section data-scene id="demo" data-start="2.5" data-duration="5">…</section>
59
+ <section data-scene id="end" data-start="7.5" data-duration="1.5">…</section>
60
+ <section data-scene id="captions" data-track="1" data-start="0" data-duration="9">
61
+ <p data-caption-target></p>
62
+ </section>
63
+ </main>
64
+ ```
65
+
66
+ Track 0 is the main timeline: contiguous, no overlaps. Captions, logos and wipes live on track 1 or higher. Full rules: `references/composition-contract.md`.
67
+
68
+ ## 4. Animate on the clock
69
+
70
+ - **Keyframes:** `animation: rise .6s ease-out .3s both;` inside a scene starts 0.3s after that scene starts. Always use `both`.
71
+ - **Hooks:** for counters, cameras, cursors, SVG and canvas, register `__studio.onSeek(function (t, s) { … })` and compute from `s.scenes.<id>.local`. Use `__studio.interp`, `__studio.ease`, and `__studio.random(seed)` (generated once at setup).
72
+ - Hooks must not depend on the previous seek; the renderer can jump backwards.
73
+
74
+ Patterns for title cards, lower thirds, product walkthroughs, chart reveals, transitions and seeded particles: `references/patterns.md`.
75
+
76
+ ## 5. Assets, fonts, captions
77
+
78
+ - Relative paths only (`assets/shot.png`), never `/abs` paths or URLs.
79
+ - Webfonts: download the `.woff2`, declare `@font-face`, and add `<link rel="preload" as="font" href="…" crossorigin>`. Or use a system font stack.
80
+ - Data: inline JSON in `<script type="application/json">`; `fetch` fails under `file://`.
81
+ - Captions: SRT/VTT inside `<script type="text/plain" data-captions="srt">`, shown in `[data-caption-target]`.
82
+
83
+ ## 6. Check before rendering
84
+
85
+ Open the file in a browser: the preview bar scrubs the same `seek(t)` the renderer uses. Then hand off to [[video-render]]: lint must be clean and snapshots at each scene's midpoint must look right before a full render.
86
+
87
+ ## Output
88
+
89
+ ```
90
+ Composition: video/launch.html 1920x1080 @ 30fps, 9s (270 frames)
91
+ Scenes: title 0-2.5 | demo 2.5-7.5 | end 7.5-9 | captions (track 1) 0-9
92
+ Assets: assets/dashboard.png, fonts/Inter.woff2 (preloaded)
93
+ Captions: 6 cues from subs.srt
94
+ Next: lint, snapshot, render (video-render)
95
+ ```
96
+
97
+ ## Red flags
98
+
99
+ | Thought | Reality |
100
+ |---|---|
101
+ | "A little `Math.random()` jitter is harmless." | Every render and every re-seek differs. Use `__studio.random(seed)` once at setup. |
102
+ | "A CSS transition is simpler." | Transitions start on state changes, not on `t`. They cannot be seeked. Use `@keyframes`. |
103
+ | "I'll load the font from Google Fonts." | Network at render time, and frame 0 may use a fallback face. Download and preload it. |
104
+ | "Scenes can overlap a bit for a crossfade." | Not on track 0. Fade out the end of one scene and fade in the next, or put a wipe on track 1. |
105
+ | "I'll `display: none` the inactive scenes." | That deletes their CSS animations. The runtime toggles `visibility` through `data-active`. |
106
+ | "It looked fine in the browser, render it." | The browser preview hides timing bugs. Lint and snapshot first ([[video-render]]). |
@@ -0,0 +1,97 @@
1
+ # The composition contract
2
+
3
+ A composition is one HTML file that renders the same pixels for the same time `t`, every time. The renderer never plays it. It opens the page, calls `window.__studio.seek(t)` for each frame, waits for the returned promise, and screenshots the viewport. Anything that is not a function of `t` will flicker, drift or differ between renders.
4
+
5
+ ## 1. The root
6
+
7
+ Exactly one element carries `data-composition`:
8
+
9
+ ```html
10
+ <main id="comp" data-composition data-width="1920" data-height="1080" data-fps="30" data-duration="6">
11
+ ```
12
+
13
+ | Attribute | Meaning | Rules |
14
+ |---|---|---|
15
+ | `data-width`, `data-height` | Output size in CSS pixels | Whole numbers. Keep both even for H.264 (`yuv420p`). |
16
+ | `data-fps` | Frames per second | 24, 25, 30 or 60 in practice. Frame `i` is at `t = i / fps`. |
17
+ | `data-duration` | Length in seconds | Total frames = `round(fps * duration)`. The last frame is at `duration - 1/fps`. |
18
+
19
+ The runtime sets the root's pixel size and a CSS custom property `--u` equal to 1% of the height. Size type and spacing in `calc(var(--u) * n)` so a 1080x1920 vertical cut or a 1280x720 draft keeps its proportions.
20
+
21
+ ## 2. Scenes
22
+
23
+ A scene is any element with `data-scene`, `data-start` and `data-duration` (seconds). It is visible when `start <= t < start + duration`.
24
+
25
+ ```html
26
+ <section data-scene id="title" data-start="0" data-duration="2">…</section>
27
+ <section data-scene id="demo" data-start="2" data-duration="3.5">…</section>
28
+ <section data-scene id="end" data-start="5.5" data-duration="1.5">…</section>
29
+ <section data-scene id="captions" data-track="1" data-start="0" data-duration="7">…</section>
30
+ ```
31
+
32
+ - **Track 0 (the default) is the main timeline.** It must cover `0 .. duration` with no gaps and no overlaps. A gap is a black frame; an overlap is two scenes fighting for the screen.
33
+ - **Overlays go on another track** (`data-track="1"`, `"2"`, …): captions, a logo bug, a progress bar. Scenes on one track must not overlap each other, but tracks may overlap freely. Later tracks paint on top when they come later in the DOM.
34
+ - **Cut on frame boundaries.** At 30 fps, `1.5` is fine, `1.55` falls between frames. The linter warns about off-frame cuts.
35
+ - Scene ids appear in lint output and in `onSeek` state, so give every scene an `id`.
36
+
37
+ The base CSS keeps every scene laid out (`position: absolute; inset: 0`) and toggles `visibility` through a `data-active` attribute. Do not use `display: none` on scenes: it destroys their CSS animations.
38
+
39
+ ## 3. The clock: `window.__studio`
40
+
41
+ The template ships the runtime inline in `<script data-studio-runtime>`. Do not edit it; if you replace it, implement the same surface.
42
+
43
+ | Member | What it does |
44
+ |---|---|
45
+ | `ready` | Promise that resolves with the config once fonts, images and media have loaded and frame 0 is drawn. The renderer awaits it. |
46
+ | `seek(t)` | Move the whole composition to `t` seconds. Returns a promise that resolves after media has seeked, fonts are ready and two animation frames have painted. |
47
+ | `onSeek(fn)` | Register `fn(t, state)`, called on every seek before animations are positioned. `state` has `t`, `frame`, `fps`, `duration`, `progress` and `scenes[id] = { active, local, progress }`. |
48
+ | `random(seed)` | Seeded PRNG (mulberry32). Same seed, same sequence on every render. Use it instead of `Math.random`. |
49
+ | `interp(t, t0, t1, v0, v1, ease?)` | Value at `t` moving from `v0` to `v1` over `t0..t1`, clamped. |
50
+ | `ease` | `linear`, `inCubic`, `outCubic`, `inOutCubic`. |
51
+ | `config`, `scenes`, `cues`, `time` | Parsed root config, scene list, caption cues, last seeked time. |
52
+
53
+ What `seek(t)` does, in order:
54
+
55
+ 1. Clamps `t` to `0 .. duration`, sets `--t` on the root.
56
+ 2. Toggles `data-active` on each scene and sets `--scene-t` (seconds into the scene) and `--scene-progress` (0..1) on it.
57
+ 3. Shows the caption cue active at `t` in every `[data-caption-target]`.
58
+ 4. Calls every `onSeek` hook.
59
+ 5. For each animation in `document.getAnimations()` whose target is inside the root: `pause()`, then `currentTime = (t - sceneStart) * 1000`, where `sceneStart` is the `data-start` of the nearest enclosing scene (0 outside scenes).
60
+ 6. Seeks every `<video>` and `<audio>` inside the root to `t - sceneStart + data-offset` and waits for `seeked`.
61
+ 7. Awaits `document.fonts.ready` and two `requestAnimationFrame`s.
62
+
63
+ ## 4. Animation rules
64
+
65
+ - **CSS `@keyframes` animations are scene-relative.** `animation-delay: .3s` inside a scene starting at 2s fires at `t = 2.3`. Use `both` fill mode so the element holds its first keyframe before the delay and its last after the end.
66
+ - **Web Animations (`el.animate(...)`) work the same way.** Create them once at setup, not inside a hook; the runtime pauses and positions them.
67
+ - **Everything else goes through `onSeek`.** Counters, SVG path lengths, canvas drawing and chart values are computed from `state.scenes[id].local` or `t`. A hook must be a pure function of its arguments: same `t` in, same DOM out, regardless of the previous seek. The renderer may seek backwards.
68
+ - **Not allowed:** `Math.random`, `Date.now`, `new Date()`, `performance.now`, `setInterval`, `setTimeout`-driven or `requestAnimationFrame`-driven animation, CSS `transition` (it starts on a state change, so it is not seekable), `<video autoplay>`.
69
+
70
+ ## 5. Captions
71
+
72
+ Paste SRT or WebVTT into a data block. The runtime parses it at load; the linter checks it.
73
+
74
+ ```html
75
+ <script type="text/plain" data-captions="srt">
76
+ 1
77
+ 00:00:00,300 --> 00:00:01,900
78
+ Here is what changed this release.
79
+ </script>
80
+ ```
81
+
82
+ - `data-captions` is `srt`, `vtt` or empty (auto-detected: `WEBVTT` header means VTT).
83
+ - Cue text is shown in every `[data-caption-target]` element while the cue is active; the element is empty otherwise, so style `:empty { display: none }`.
84
+ - Inline tags such as `<i>` or `<v Speaker>` are stripped. Cue settings after the end time are ignored.
85
+ - `studio-skills init --captions subs.srt` embeds a file for you. A separate `.srt` file is not loaded at render time: `fetch` over `file://` is blocked.
86
+
87
+ ## 6. Assets
88
+
89
+ - **Everything is local and relative.** Images, video, fonts and scripts sit next to the HTML (an `assets/` folder is fine) and are referenced with relative paths. Root-absolute paths (`/img/logo.png`) resolve to the filesystem root under `file://`.
90
+ - **No network at render time.** No CDN scripts, no Google Fonts, no remote images, no `fetch` or XHR. Download what you need once and commit it. Data goes inline as `<script type="application/json" id="data">…</script>` and is read with `JSON.parse(document.getElementById('data').textContent)`.
91
+ - **Fonts are preloaded.** Every `@font-face` file also gets `<link rel="preload" as="font" href="fonts/Inter.woff2" crossorigin>`, so frame 0 never renders in a fallback face. System font stacks need nothing.
92
+ - **Video sources** should be H.264 MP4 or VP9 WebM with frequent keyframes (`-g 15`) so seeking is exact and fast. Use `data-offset="12.5"` on a `<video>` to start it 12.5s in. Video and audio inside the composition are muted in the render; pass the soundtrack with `render --audio`.
93
+ - **Images** are decoded before `ready` resolves.
94
+
95
+ ## 7. Preview
96
+
97
+ Opening the file in a normal browser shows a play button and a frame scrubber under a scaled stage. Both call the same `seek(t)`, so what you scrub is what renders. The renderer sets `window.__STUDIO_RENDER__ = true` before load, which hides the controls and leaves the stage at 1:1 in the top-left corner.
@@ -0,0 +1,177 @@
1
+ # Composition patterns
2
+
3
+ Each pattern is a scene (or overlay) that follows the contract in `composition-contract.md`: timing from `data-start` / `data-duration`, motion from `@keyframes` with scene-relative delays or from `__studio.onSeek`. Sizes use `--u` (1% of the composition height). Copy, then change words, colours and timings.
4
+
5
+ ## Title card
6
+
7
+ Kicker, headline, accent rule; staggered entrances, then a clean exit at the end of the scene.
8
+
9
+ ```html
10
+ <section data-scene id="title" data-start="0" data-duration="2.5">
11
+ <div class="card">
12
+ <div class="kicker">Release 2.0</div>
13
+ <h1>Search that reads<br>your whole repo</h1>
14
+ <div class="rule"></div>
15
+ </div>
16
+ </section>
17
+ ```
18
+
19
+ ```css
20
+ #title { display: grid; place-content: center; text-align: center; }
21
+ #title .kicker { color: var(--accent); letter-spacing: .3em; text-transform: uppercase; font-size: calc(var(--u) * 2.4);
22
+ animation: rise .6s cubic-bezier(.2,.7,.2,1) .15s both; }
23
+ #title h1 { font-size: calc(var(--u) * 10); line-height: .95; animation: rise .7s cubic-bezier(.2,.7,.2,1) .3s both; }
24
+ #title .rule { height: calc(var(--u) * .5); width: calc(var(--u) * 18); margin: calc(var(--u) * 4) auto 0; background: var(--accent);
25
+ transform-origin: left; animation: grow .6s cubic-bezier(.6,0,.2,1) .6s both; }
26
+ /* exit: starts 0.4s before the scene ends (2.5 - 0.4 = 2.1s) */
27
+ #title .card { animation: fade-out .4s ease-in 2.1s both; }
28
+ @keyframes fade-out { to { opacity: 0; transform: translateY(calc(var(--u) * -2)); } }
29
+ ```
30
+
31
+ Timing rule of thumb: entrances 0.4-0.8s, 0.1-0.15s stagger between lines, the headline fully readable for at least 1.2s.
32
+
33
+ ## Lower-third captions
34
+
35
+ Two layers: a name/role lower third inside the scene, and the caption track as an overlay on track 1 so it spans scene cuts.
36
+
37
+ ```html
38
+ <section data-scene id="talk" data-start="2.5" data-duration="6">
39
+ <video src="assets/talk.mp4" muted playsinline></video>
40
+ <div class="lower-third"><strong>Ada Park</strong><span>Staff engineer, Search</span></div>
41
+ </section>
42
+
43
+ <section data-scene id="captions" data-track="1" data-start="0" data-duration="10">
44
+ <p data-caption-target></p>
45
+ </section>
46
+
47
+ <script type="text/plain" data-captions="srt">
48
+ 1
49
+ 00:00:02,800 --> 00:00:05,000
50
+ We index every file on push, not on query.
51
+ </script>
52
+ ```
53
+
54
+ ```css
55
+ #talk video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
56
+ .lower-third { position: absolute; left: calc(var(--u) * 6); bottom: calc(var(--u) * 16); padding: calc(var(--u) * 1.4) calc(var(--u) * 2.4);
57
+ background: var(--accent); color: #111; display: grid; animation: slide-in .5s cubic-bezier(.2,.7,.2,1) .4s both,
58
+ fade-out .3s ease-in 3.4s both; }
59
+ .lower-third strong { font-size: calc(var(--u) * 3.4); }
60
+ .lower-third span { font-size: calc(var(--u) * 2.2); }
61
+ [data-caption-target] { position: absolute; left: 50%; bottom: calc(var(--u) * 6); transform: translateX(-50%); max-width: 80%;
62
+ background: rgba(0,0,0,.72); color: #fff; font-size: calc(var(--u) * 3.6); padding: calc(var(--u) * 1) calc(var(--u) * 2.2); white-space: pre-line; }
63
+ [data-caption-target]:empty { display: none; }
64
+ @keyframes slide-in { from { transform: translateX(-110%); } }
65
+ ```
66
+
67
+ Keep captions to two lines of about 42 characters, on screen for at least 1s each. When a lower third and a caption would collide, raise the lower third rather than moving the captions.
68
+
69
+ ## Product walkthrough
70
+
71
+ A screenshot (or screen recording) in a device frame, a camera move that zooms to the feature, and a cursor that travels and clicks. The camera and cursor are keyframed in one `onSeek` hook so they stay in sync.
72
+
73
+ ```html
74
+ <section data-scene id="walkthrough" data-start="2.5" data-duration="5">
75
+ <div class="camera">
76
+ <img class="screen" src="assets/dashboard.png" alt="">
77
+ <div class="cursor"></div>
78
+ <div class="ripple"></div>
79
+ </div>
80
+ <div class="callout">Filter by owner in one click</div>
81
+ </section>
82
+ ```
83
+
84
+ ```css
85
+ #walkthrough { overflow: hidden; background: #1b1e26; }
86
+ .camera { position: absolute; left: 50%; top: 50%; width: calc(var(--u) * 150); transform-origin: 0 0; }
87
+ .screen { width: 100%; border-radius: calc(var(--u) * 1); box-shadow: 0 calc(var(--u) * 3) calc(var(--u) * 8) rgba(0,0,0,.5); }
88
+ .cursor { position: absolute; width: calc(var(--u) * 2.4); height: calc(var(--u) * 2.4); background: #fff; border: 2px solid #000;
89
+ border-radius: 50% 50% 50% 0; transform: rotate(-45deg); }
90
+ .ripple { position: absolute; width: calc(var(--u) * 6); height: calc(var(--u) * 6); margin: calc(var(--u) * -3); border-radius: 50%;
91
+ border: 3px solid var(--accent); opacity: 0; }
92
+ .callout { position: absolute; right: calc(var(--u) * 6); top: calc(var(--u) * 8); font-size: calc(var(--u) * 4);
93
+ animation: rise .5s ease-out 2.6s both; }
94
+ ```
95
+
96
+ ```js
97
+ // Keyframes in scene-local seconds. Positions are fractions of the screenshot.
98
+ var cam = [ { t: 0, x: .5, y: .5, z: 1 }, { t: 1.2, x: .5, y: .5, z: 1 }, { t: 2.2, x: .22, y: .3, z: 2.2 }, { t: 5, x: .22, y: .3, z: 2.2 } ]
99
+ var cur = [ { t: 0.8, x: .7, y: .8 }, { t: 2.0, x: .21, y: .29 } ]
100
+ var click = 2.2
101
+ function at(keys, t) {
102
+ var a = keys[0], b = keys[keys.length - 1]
103
+ for (var i = 0; i < keys.length - 1; i++) if (t >= keys[i].t && t <= keys[i + 1].t) { a = keys[i]; b = keys[i + 1]; break }
104
+ var p = __studio.ease.inOutCubic(__studio.clamp01((t - a.t) / ((b.t - a.t) || 1)))
105
+ var out = {}
106
+ for (var k in a) out[k] = a[k] + (b[k] - a[k]) * p
107
+ return out
108
+ }
109
+ var camera = document.querySelector('#walkthrough .camera')
110
+ var cursor = document.querySelector('#walkthrough .cursor')
111
+ var ripple = document.querySelector('#walkthrough .ripple')
112
+ __studio.onSeek(function (t, s) {
113
+ var local = s.scenes.walkthrough.local
114
+ var c = at(cam, local), m = at(cur, local)
115
+ var w = camera.offsetWidth, h = camera.offsetHeight
116
+ camera.style.transform = 'scale(' + c.z + ') translate(' + (-c.x * w) + 'px,' + (-c.y * h) + 'px)'
117
+ cursor.style.left = ripple.style.left = (m.x * 100) + '%'
118
+ cursor.style.top = ripple.style.top = (m.y * 100) + '%'
119
+ var r = __studio.clamp01((local - click) / 0.5)
120
+ ripple.style.opacity = r > 0 && r < 1 ? String(1 - r) : '0'
121
+ ripple.style.transform = 'scale(' + (0.4 + r) + ')'
122
+ })
123
+ ```
124
+
125
+ Use screenshots at 2x the size they appear so zooms stay sharp. One idea per scene; three zooms in five seconds reads as shaking.
126
+
127
+ ## Data chart reveal
128
+
129
+ Bars grow with staggered keyframes; numbers count up in a hook using the same delays and easing, so value and bar arrive together. This is the chart scene in the starter template.
130
+
131
+ ```html
132
+ <div class="bars">
133
+ <div class="bar" style="--i:0"><div class="value" data-count="1200">0</div><div class="fill" style="--h:24%"></div><div class="label">Jan</div></div>
134
+ <div class="bar" style="--i:1"><div class="value" data-count="4800">0</div><div class="fill" style="--h:96%"></div><div class="label">Apr</div></div>
135
+ </div>
136
+ ```
137
+
138
+ ```css
139
+ .fill { height: var(--h); transform-origin: bottom; animation: grow-y .8s cubic-bezier(.2,.7,.2,1) calc(.3s + var(--i) * .12s) both; }
140
+ .value { animation: fade .3s ease-out calc(.3s + var(--i) * .12s) both; font-variant-numeric: tabular-nums; }
141
+ @keyframes grow-y { from { transform: scaleY(0); } }
142
+ ```
143
+
144
+ ```js
145
+ var counters = document.querySelectorAll('#chart [data-count]')
146
+ __studio.onSeek(function (t, s) {
147
+ var local = s.scenes.chart.local
148
+ counters.forEach(function (el, i) {
149
+ var start = 0.3 + i * 0.12
150
+ el.textContent = Math.round(__studio.interp(local, start, start + 0.8, 0, +el.dataset.count, __studio.ease.outCubic)).toLocaleString('en-US')
151
+ })
152
+ })
153
+ ```
154
+
155
+ Compute bar heights from the data once (max value = 100%) rather than by hand, keep `tabular-nums` so digits do not jitter, and pass an explicit locale to `toLocaleString` so the output does not depend on the machine.
156
+
157
+ For line charts, draw an SVG `<path>` with `pathLength="1"`, `stroke-dasharray: 1`, and animate `stroke-dashoffset` from 1 to 0 in `@keyframes`.
158
+
159
+ ## Scene transitions
160
+
161
+ Track 0 forbids overlaps, so transitions are an exit at the end of one scene plus an entrance at the start of the next:
162
+
163
+ - **Dip to colour:** each scene fades out over its last 0.3s and the next fades in over its first 0.3s. The root background shows in between.
164
+ - **Wipe:** an overlay scene on track 1, 0.6s long, centred on the cut, with a full-frame panel that animates `transform: translateX(-100%)` to `translateX(100%)`.
165
+ - **Hard cut on the beat:** often the best choice. Put cuts on frame boundaries.
166
+
167
+ ## Seeded variety
168
+
169
+ Particles, confetti or jittered grids need randomness that repeats exactly:
170
+
171
+ ```js
172
+ var rand = __studio.random(42)
173
+ var dots = Array.from({ length: 60 }, function () { return { x: rand(), y: rand(), speed: 0.2 + rand() * 0.8 } })
174
+ __studio.onSeek(function (t) { /* position each dot from its seed values and t */ })
175
+ ```
176
+
177
+ Generate all random values once at setup, then derive positions from `t`. Never call `rand()` inside a hook: the sequence would depend on how many frames were seeked before.