Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.
TypeScript 3dagent-skillsai-agentsai-videobevyclaude-codegame-enginegpulinuxmacosmotion-designmotion-graphicsreactrusttypescriptvideo-editingvideo-renderingwgpuwindows
TL11b: the timeline SDK as raea/editor, with its reference page. sdk/raea/src/editor.ts re-exports @raea/timeline (raea/timeline was already the Sequence module's), now in sdk/tsconfig.base.json so a bundle copies it; its import of the effect table is @raea/video/effects (a relative path across packages didn't survive a bundle). Every field of its types has a doc comment (85 had none), and docs/manual/examples/edits.tsx builds a timeline, splits it, keys a fade, speeds a half up with the magnet closing the gap, and undoes it all from the inverses
shinyobjectz8fefa2922d04
diff --git a/docs/manual/examples/edits.tsx b/docs/manual/examples/edits.tsxnew file mode 100644index 00000000..a040aa4d--- /dev/null+++ b/docs/manual/examples/edits.tsx@@ -0,0 +1,76 @@+// check: frames 0,45,89+import { AbsoluteFill, Composition, registerRoot, useCurrentFrame } from "raea";+import { applyAll, empty, end, length, valueAt, type Clip, type Op, type Timeline } from "raea/editor";++// A timeline made in code and edited by operations, as the feed's editor and an agent's script both edit one: two+// shots on the main track and a title over them.+const before: Timeline = {+ ...empty(30),+ tracks: [+ { id: "text", kind: "text", clips: [{ id: "title", kind: "text", name: "Title", start: 0, length: 60 }] },+ {+ id: "main",+ kind: "main",+ clips: [+ { id: "a", kind: "video", name: "Shot A", start: 0, length: 90, in: 0, source: 300 },+ { id: "b", kind: "video", name: "Shot B", start: 90, length: 90, in: 0, source: 300 },+ ],+ },+ ],+};++// Shot A split at one second, and the title faded in by two keys on its opacity.+const first: Op[] = [+ { op: "split", at: 30, ids: ["a"] },+ { op: "key", id: "title", prop: "opacity", at: 0, value: 0, ease: [0.42, 0, 0.58, 1] },+ { op: "key", id: "title", prop: "opacity", at: 20, value: 1 },+];+const cut = applyAll(before, first);+// The half the split made is found where it starts, and played twice as fast: the main track's magnet closes the+// gap, so Shot B comes in earlier.+const half = cut.timeline.tracks[1].clips.find((c) => c.start === 30)!;+const after = applyAll(cut.timeline, [{ op: "set", id: half.id, set: { speed: 2 } }]);+// Every operation gives back its inverse: applied last first, they put the timeline back as it was.+const undone = applyAll(after.timeline, [...after.inverse, ...cut.inverse]).timeline;++const SCALE = 5; // px a frame+const COLOR: Record<string, string> = { video: "#3d7bd9", text: "#c9853d" };++function Row({ clips, top, frame }: { clips: Clip[]; top: number; frame: number }) {+ return (+ <>+ {clips.map((c) => {+ const on = frame >= c.start && frame < end(c);+ const opacity = typeof valueAt(c.keys?.opacity, frame - c.start) === "number" ? (valueAt(c.keys?.opacity, frame - c.start) as number) : 1;+ return (+ <div+ key={c.id}+ style={{ position: "absolute", left: 80 + c.start * SCALE, top, width: c.length * SCALE - 4, height: 64, borderRadius: 8, background: COLOR[c.kind] ?? "#777", opacity: on ? Math.max(0.35, opacity) : 0.35, color: "#fff", fontSize: 26, padding: "16px 14px", boxSizing: "border-box", overflow: "hidden", whiteSpace: "nowrap" }}+ >+ {c.name}+ {c.speed && c.speed !== 1 ? ` · ${c.speed}x` : ""}+ </div>+ );+ })}+ </>+ );+}++function Edits() {+ const frame = useCurrentFrame();+ const label = (y: number, text: string) => <div style={{ position: "absolute", left: 80, top: y, color: "#aaa", fontSize: 28 }}>{text}</div>;+ return (+ <AbsoluteFill style={{ background: "#16181c", fontFamily: "sans-serif" }}>+ {label(100, `Before: ${length(before)} frames`)}+ <Row clips={before.tracks[0].clips} top={144} frame={frame} />+ <Row clips={before.tracks[1].clips} top={218} frame={frame} />+ {label(330, `After ${first.length + 1} edits: ${length(after.timeline)} frames`)}+ <Row clips={after.timeline.tracks[0].clips} top={374} frame={frame} />+ <Row clips={after.timeline.tracks[1].clips} top={448} frame={frame} />+ {label(560, `Undone: ${JSON.stringify(undone) === JSON.stringify(before) ? "as it was" : "changed"}`)}+ <div style={{ position: "absolute", left: 80 + frame * SCALE, top: 134, width: 3, height: 392, background: "#ff4d4d" }} />+ </AbsoluteFill>+ );+}++registerRoot(() => <Composition id="edits" component={Edits} width={1280} height={720} fps={30} durationInFrames={90} />);diff --git a/docs/manual/reference/sdk/editor.md b/docs/manual/reference/sdk/editor.mdnew file mode 100644index 00000000..b662d504--- /dev/null+++ b/docs/manual/reference/sdk/editor.md@@ -0,0 +1,844 @@+---+title: "raea/editor"+summary: "the timeline the feed edits a film, a scene or a sound on, as data. Tracks, clips, keys and markers; every edit an operation with its inverse (apply); a composition's sequences read into it (sequenceRows) and the edits written back as SeqEdit; easings, speed curves, snapping, the frame store's keys and what a plugin adds. No React and no DOM: an agent's script, the app's host and a test use the same model the app's strip does."+order: 48+sources: ["sdk/raea/src/editor.ts"]+---++the timeline the feed edits a film, a scene or a sound on, as data. Tracks, clips, keys and markers; every edit an operation with its inverse (apply); a composition's sequences read into it (sequenceRows) and the edits written back as SeqEdit; easings, speed curves, snapping, the frame store's keys and what a plugin adds. No React and no DOM: an agent's script, the app's host and a test use the same model the app's strip does.++<!-- generated:begin by tools/manual-ref/sdk.ts from the SDK's exports and doc comments; edit outside this block -->++```ts+import { ahead, apply, applyAll, bezier } from "raea/editor"+```++`raea/editor` exports 50 functions, 14 values, 31 types. Bevy's counterpart: `raea's own; Bevy has no timeline editor`. Source: [sdk/raea/src/editor.ts](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/src/editor.ts).++## Functions++### `ahead`++The ranges to draw next while there is time: what isn't kept from the playhead on, nearest first, each+at most `chunk` frames, then what is before it.++```ts+function ahead(length: number, kept: Range[], playhead: number, chunk: number): Range[]+```++### `apply`++The operation applied, or why it can't be.++```ts+function apply(t: Timeline, op: Op): Applied+```++### `applyAll`++Operations in order, stopping at the first refused: the timeline they give, and each one's inverse (last first).++```ts+function applyAll(t: Timeline, ops: Op[]): { timeline: Timeline; inverse: Op[]; refused?: { op: Op; why: string; } | undefined; }+```++Used in: [manual: edits](https://github.com/shinyobjectz/raea/blob/main/docs/manual/examples/edits.tsx).++### `bezier`++y at x on the cubic bezier (0,0) (x1,y1) (x2,y2) (1,1): x is solved by Newton's steps, then bisection where the+slope is too flat for them. The handles' x are kept in 0..1 so the curve is a function of time.++```ts+function bezier(x1: number, y1: number, x2: number, y2: number): (x: number) => number+```++### `changed`++The frames whose picture or sound differ between two states of a timeline: wherever what is drawn over a frame+isn't what was. Moving a clip from 2:00-2:05 to 2:10-2:15 gives those two ranges and nothing else; a+split of footage gives none.++```ts+function changed(before: Timeline, after: Timeline): Range[]+```++### `clipEdits`++The file clips that differ between the timeline as it was read and as it stands, each with its span before and+after: what a sound's hand edit carries (its `clips`). A clip that was removed or made here isn't one of these.++```ts+function clipEdits(read: Timeline, now: Timeline): { id: string; src: string; from: ClipSpan; to: ClipSpan; }[]+```++### `clips`++```ts+function clips(t: Timeline): Clip[]+```++### `cut`++The keys either side of a cut at `frame` (TL3d: a split clip's keys stay at their frames): the left clip's, and+the right clip's in its own frames. A cut between two keys puts a key of the value there on both sides, so each+half moves as the whole did up to the cut.++```ts+function cut(keys: Key[], frame: number): [Key[], Key[]]+```++### `eased`++How far along (0..1, or past it for a handle that overshoots) a value is at `p` of the way between two keys.++```ts+function eased(ease: Ease | undefined, p: number): number+```++### `effectFilter`++The CSS filter of `kind` at `amount` (0 to 1, clamped); undefined for a kind raea doesn't draw.++```ts+function effectFilter(kind: string, amount?: number): string | undefined+```++### `effectParts`++An effect clip's parts, kept in its props as JSON: read back when they are well formed.++```ts+function effectParts(v: unknown): EffectPart[] | undefined+```++### `empty`++```ts+function empty(fps?: number): Timeline+```++Used in: [manual: edits](https://github.com/shinyobjectz/raea/blob/main/docs/manual/examples/edits.tsx).++### `end`++```ts+function end(c: Clip): number+```++Used in: [manual: edits](https://github.com/shinyobjectz/raea/blob/main/docs/manual/examples/edits.tsx).++### `evict`++The keys to drop so the store is at most `limit` bytes: stale ones first, then the least recently played. What+is under the playhead (`hold`) stays while anything else can go.++```ts+function evict(kept: Kept[], limit: number, hold?: Set<string>): string[]+```++### `find`++```ts+function find(t: Timeline, id: string): { track: Track; clip: Clip; } | undefined+```++### `fits`++Whether `c` has room on the track (it overlaps none of the others).++```ts+function fits(track: Track, c: Pick<Clip, "start" | "length" | "id">): boolean+```++### `frameOf`++The timeline frame at which clip `id` shows source frame `source`, when it does (a constant-speed clip).++```ts+function frameOf(t: Timeline, id: string, source: number): number | undefined+```++### `fromRender`++A film with no composition behind it: its scenes as clips of one main track (cut where the picture cuts). Each+clip is the film's picture and its sound together, as footage is until its sound is extracted, so a cut,+a move or a speed takes both. Its magnet is on: a scene removed closes up, as a cut of footage does.++```ts+function fromRender(o: { frames: number; fps: number; cuts?: number[]; captions?: { text: string; start: number; end: number; }[] | undefined; }): Timeline+```++### `fromSequences`++The composition's sequences as a timeline: a track a lane, the first lane on top as the strip draws it. The first+lane is the main track, its magnet on, only when its clips already run from frame 0 with no gap: a composition's+sequences are where its code puts them, and nothing here moves one that wasn't dragged.++```ts+function fromSequences(rows: SeqRow[], fps: number): Timeline+```++### `fromTracks`++A sound's tracks as a timeline: a sound track each, by its bus; a clip of a file keeps its place in the file+(its offset) and its level. Notes and lines are clips too, locked here: they are edited where they are written+(the roll, the words). No magnet: a mix's clips are where they were put.++```ts+function fromTracks(tracks: SoundTrack[], fps: number): Timeline+```++### `gridFrames`++The frames a snap grid marks in a timeline `length` frames long (none for a grid finer than a frame, or of more than 5,000 marks).++```ts+function gridFrames(grid: SnapGrid, fps: number, length: number): number[]+```++### `joined`++Ranges in order, touching and overlapping ones joined, empty ones dropped.++```ts+function joined(ranges: Range[]): Range[]+```++### `keyOf`++What a range of kept frames is kept under: everything that draws it. Two states of a timeline that draw the+range the same give the same key, so frames drawn before an edit elsewhere (or before an undo) are found again.++```ts+function keyOf(t: Timeline, [from, to]: Range, media?: (clip: Clip) => string): string+```++### `length`++The timeline's length: its last clip's end.++```ts+function length(t: Timeline): number+```++Used in: [manual: edits](https://github.com/shinyobjectz/raea/blob/main/docs/manual/examples/edits.tsx).++### `next`++Where the player goes when what it is playing ends at timeline frame `frame`: the next clip's first frame (at+or after it), or undefined at the film's end.++```ts+function next(t: Timeline, frame: number): number | undefined+```++### `palette`++Everything offered: raea's own, then each plugin's in order (a name a plugin before it took stays that one's).++```ts+function palette(plugins?: Adds[]): { eases: Record<string, Ease>; curves: Record<string, SpeedPoint[]>; transitions: TransitionKind[]; tracks: TrackKindInfo[]; effects: EffectInfo[]; texts: TextStyle[]; tools: Preset[]; snaps: SnapGrid[]; }+```++### `partsFilter`++The CSS filter of an effect given as parts, at `amount` (0 to 1, clamped).++```ts+function partsFilter(parts: EffectPart[], amount?: number): string+```++### `played`++How many frames `source` frames of source take to play under the curve.++```ts+function played(curve: SpeedPoint[], source: number): number+```++### `playLength`++The timeline's length as it plays: its main track's end.++```ts+function playLength(t: Timeline): number+```++### `points`++The curve as points from 0 to 1 in order, each speed in range.++```ts+function points(curve: SpeedPoint[]): SpeedPoint[]+```++### `presetError`++Why `p` isn't a preset, or undefined when it is.++```ts+function presetError(p: unknown): string | undefined+```++### `profile`++The speed at each of `n` places along the clip's own time (the line drawn over the clip, TL6b).++```ts+function profile(curve: SpeedPoint[], source: number, n: number): number[]+```++### `readAdds`++A plugin's additions as written in its manifest, checked: what is well formed, and why the rest isn't.++```ts+function readAdds(raw: unknown): { adds: Adds; errors: string[]; }+```++### `readTimeline`++A timeline as an agent wrote it on a feed item or a controller's field (its own data: a schedule, a set list, a+shot plan), checked and made whole: what is well formed, and why the rest isn't. Frames are rounded to whole+ones; a track with no kind is an overlay; ids must be there and not repeat.++```ts+function readTimeline(raw: unknown): { timeline?: Timeline; errors: string[]; }+```++### `ready`++The timeline ranges that are ready to play, given the source ranges that are (frames of the file the player has+buffered): each main-track clip's part whose source is in one of them.++```ts+function ready(t: Timeline, source: Range[]): Range[]+```++### `segmentsOf`++A render's cut, as the frames of the source played in order (the hand edit's `segments`): what a film's main+track is after its scenes were moved, trimmed, split and removed.++```ts+function segmentsOf(t: Timeline): [number, number][]+```++### `seqEdits`++What the host is asked to do to the composition's sequences for `op` on timeline `t` (read from them), in order;+or why this operation isn't one the sequences can take yet. Each edit names sequences as they are before it.++```ts+function seqEdits(t: Timeline, op: Op): SeqEdit[] | { why: string; }+```++### `showing`++What shows at timeline frame `frame`: the main-track clip over it, the source frame, and the rate. Undefined+in a gap or past the end.++```ts+function showing(t: Timeline, frame: number): Showing | undefined+```++### `slot`++Where a track of this kind goes among the others: after the last of its own kind, else in ORDER's place.++```ts+function slot(tracks: Track[], kind: TrackKind): number+```++### `snap`++`frame` moved to the nearest target within `within` frames (8 px at the strip's zoom), and what it snapped to.++```ts+function snap(frame: number, to: Target[], within: number): { frame: number; to?: Target; }+```++### `snapMove`++A moved clip (its start and length) snapped by whichever of its edges is nearer a target: how far it moves.++```ts+function snapMove(start: number, len: number, to: Target[], within: number): { by: number; to?: Target; }+```++### `sorted`++The keys in time order (two at one frame: the later one written wins).++```ts+function sorted(keys: Key[]): Key[]+```++### `sourceAt`++The source frame showing `time` frames into the clip, under the curve over `source` frames of source.++```ts+function sourceAt(curve: SpeedPoint[], source: number, time: number): number+```++### `speedOf`++A clip's speed where it is constant.++```ts+function speedOf(c: Clip): number+```++### `targets`++Every frame an edge can snap to, leaving out the clips being moved (`not`).++```ts+function targets(t: Timeline, o?: { not?: string[]; playhead?: number; beats?: number[]; }): Target[]+```++### `textStyleError`++Why `t` isn't a text style, or undefined when it is.++```ts+function textStyleError(t: unknown): string | undefined+```++### `textStyleOf`++A text clip's style, kept in its props as JSON: read back when it is well formed.++```ts+function textStyleOf(v: unknown): TextStyle | undefined+```++### `timecode`++mm:ss:ff, drawn from frames.++```ts+function timecode(frames: number, fps: number): string+```++### `valueAt`++The property's value at `frame` (frames from its clip's start), or undefined with no keys.++```ts+function valueAt(keys: Key[] | undefined, frame: number): Value | undefined+```++Used in: [manual: edits](https://github.com/shinyobjectz/raea/blob/main/docs/manual/examples/edits.tsx).++### `without`++`ranges` with `cut` taken out of them.++```ts+function without(ranges: Range[], cut: Range[]): Range[]+```++## Values++### `CODE_KINDS`++The transitions a composition's <Transition> draws (sdk/video transition.tsx).++### `CURVES`++CapCut's curve presets, as points over the source; a plugin adds its own.++### `EASES`++The easing presets raea registers; a plugin adds its own beside them.++### `EFFECTS`++### `FASTEST`++### `KEYED`++The properties a sequence's <Nudge> can key (sdk/video nudge.tsx).++### `ORDER`++### `PRESET_PROPS`++The props a preset may set: a clip's placement (what the editor's own tools set).++### `SLOWEST`++### `TEXT_PROPS`++The CSS a text style may set: type and colour, nothing that lays the frame out.++### `TEXTS`++raea's own text styles. Sizes are the composition's pixels (a 1080-line frame).++### `TRACKS`++raea's own kinds of track, in the order they stack.++### `TRANSITIONS`++raea's own transitions: the kinds its <Transition> draws (sdk/video transition.tsx). Two parts that only+touch have no frames of each other to mix, so there is no dissolve: a fade goes through black.++### `under`++Kinds a plugin said stack under the picture, with the sound (registry.ts sets them).++## Types++### `Adds`++What one plugin adds.++| Field | Type | What it is |+| --- | --- | --- |+| `eases` | `Record<string, Ease>` | easings of its own, by name |+| `curves` | `Record<string, SpeedPoint[]>` | speed curves of its own, by name |+| `transitions` | `TransitionKind[]` | transitions of its own |+| `tracks` | `TrackKindInfo[]` | kinds of track of its own: a clip posted or added on one is drawn and edited like any other |+| `effects` | `EffectInfo[]` | effects of its own (TL7b, TL11a), each drawn by its parts: CSS filter functions from amount 0 to amount 1 |+| `texts` | `TextStyle[]` | text styles of its own (TL7c, TL11a) |+| `tools` | `Preset[]` | tools of its own: presets put on the picked clips |+| `snaps` | `SnapGrid[]` | marks edges snap to: grids in seconds |++### `Applied`++```ts+type Applied = { ok: true; timeline: Timeline; inverse: Op } | { ok: false; why: string }+```++### `Clip`++A span of something on a track: footage, a sound, words, a composition's sequence, an effect.++| Field | Type | What it is |+| --- | --- | --- |+| `id` (required) | `string` | its own id, unique on the timeline |+| `kind` (required) | `string` | what it is: "video", "audio", "text", "sequence", "component", "effect", a plugin's own |+| `name` | `string` | what its head says (its file's or its sequence's name when unset) |+| `start` (required) | `Frames` | where it starts on the timeline |+| `length` (required) | `Frames` | how long it lasts on the timeline |+| `in` | `Frames` | media: the first source frame it shows |+| `source` | `Frames` | media: how many frames the source has (unset: no end to trim against) |+| `speed` | `number` | a constant speed (1 when unset, TL6a) |+| `curve` | `SpeedPoint[]` | a speed curve, which wins over `speed` |+| `shows` | `Frames` | under a curve: how many source frames the clip shows (its length is the time the curve takes over them) |+| `reverse` | `boolean` | footage played backward: its last source frame first |+| `freeze` | `boolean` | a still: the source frame `in` held for the clip's whole length |+| `off` | `boolean` | turned off: drawn dimmed, left out of the picture and the sound |+| `locked` | `string` | it can't be changed here, and why ("set in code", TL0c) |+| `group` | `string` | clips with one group pick and move as one |+| `props` | `Record<string, Value \| boolean>` | its still values by property (x, y, scale, rotate, opacity, text, a plugin's): a keyed one is ignored |+| `keys` | `Record<string, Key[]>` | its keys by property, in frame order |+| `volume` | `number` | sound: its level, 1 as recorded |+| `fadeIn` | `Frames` | sound: how long it fades in from its start |+| `fadeOut` | `Frames` | sound: how long it fades out to its end |+| `at` | `string` | its element in the code |+| `markers` | `Marker[]` | markers on the clip itself, in frames from its start |+| `inside` | `{ kind: TrackKind; clip: Clip }[]` | a compound clip: the clips it holds, each with the kind of track it came from, their starts in frames from this clip's own start |++### `ClipSpan`++A clip's span and level, in seconds and dB: what the host writes back for a clip that was moved, trimmed or+turned up or down (raea-feed host/clips.ts).++| Field | Type | What it is |+| --- | --- | --- |+| `start` (required) | `number` | where it starts, in seconds of the render |+| `end` (required) | `number` | where it ends, in seconds of the render |+| `offset` (required) | `number` | where in its file it starts playing, in seconds |+| `gainDb` (required) | `number` | its level change, in dB (0 as recorded) |++### `Ease`++How a value travels from one key to the next: a straight line, no travel (it holds, then jumps), or a cubic+bezier's two handles [x1, y1, x2, y2] as CSS writes them.++```ts+type Ease = "linear" | "hold" | [number, number, number, number]+```++### `EffectInfo`++An effect the palette offers: raea's own by its kind, a plugin's with the parts that draw it.++| Field | Type | What it is |+| --- | --- | --- |+| `kind` (required) | `string` | its kind, as <Effect kind> takes it |+| `title` (required) | `string` | what the bar and the clip's head say |+| `parts` | `EffectPart[]` | a plugin's: the CSS filter functions that draw it, each from amount 0 to amount 1 |++### `EffectKind`++| Field | Type | What it is |+| --- | --- | --- |+| `kind` (required) | `string` | its name in the composition's code: <Effect kind> |+| `title` (required) | `string` | what the person sees |+| `filter` (required) | `(amount: number) => string` | the CSS filter at `amount` |++### `EffectPart`++An effect as data: each part one CSS filter function, its value going+from `from` (amount 0, where it changes nothing) to `to` (amount 1), with its unit: ["blur", 0, 6, "px"].++```ts+type EffectPart = [fn: string, from: number, to: number, unit?: string]+```++### `Frames`++A count of frames, always whole.++```ts+type Frames = number+```++### `Kept`++A drawn range in the store, as the clearing reads it.++| Field | Type | What it is |+| --- | --- | --- |+| `key` (required) | `string` | the range's key (rangeKey): what it is drawn from |+| `bytes` (required) | `number` | what it takes on disk |+| `used` (required) | `number` | when it was last played (ms) |+| `stale` | `boolean` | it belongs to a version that was closed or discarded: it goes at once |++### `Key`++A property's value at a frame of its clip (frames from the clip's start), and how it leaves for the next key.++| Field | Type | What it is |+| --- | --- | --- |+| `at` (required) | `Frames` | the frame it is at, counted from its clip's start |+| `value` (required) | `Value` | the property's value there: a number, a list of them (a colour, a point) or a string |+| `ease` | `Ease` | how the value travels to the next key (linear when unset) |++### `Marker`++A mark at a frame: a beat, a comment's time or one put there by hand.++| Field | Type | What it is |+| --- | --- | --- |+| `id` (required) | `string` | its own id, unique on the timeline |+| `at` (required) | `Frames` | its frame on the timeline (on a clip: from the clip's start) |+| `name` | `string` | what it says, shown on hover |+| `color` | `string` | its colour, any CSS colour |++### `Op`++```ts+type Op = | { op: "move"; ids: string[]; by: Frames; track?: string } /** a clip's start or end dragged to the timeline frame `to` */ | { op: "trim"; id: string; edge: "start" | "end"; to: Frames } /** the clips `ids` split at `at`; with none named, every clip under it (Cmd+B, Cmd+Shift+B: TL3d) */ | { op:…+```++### `Preset`++A tool a plugin adds: one press sets these on every picked clip, as one edit each.++| Field | Type | What it is |+| --- | --- | --- |+| `id` (required) | `string` | its id: lowercase letters, digits and dashes |+| `title` (required) | `string` | what the bar says |+| `set` (required) | `{ props?: Record<string, number \| boolean>; speed?: number; volume?: number }` | what it sets on each picked clip: placement props (PRESET_PROPS), a speed, a level |++### `Range`++```ts+type Range = [from: Frames, to: Frames]+```++### `SeqEdit`++The host's edit to a sequence: its new span, a split, a delete.++```ts+type SeqEdit = | { op: "move"; i: number; from: number; to: number } | { op: "split"; i: number; at: number } | { op: "delete"; i: number } /** the sequence's keyed properties as they now stand: written as its <Nudge keys>, one a property (TL5d) */ | { op: "keys"; i: number; keys: Record<string, [number, number…+```++### `SeqLook`++A sequence's still placement: its <Nudge>'s props (sdk/video nudge.tsx). `crop` is left, top, right, bottom.++| Field | Type | What it is |+| --- | --- | --- |+| `x` | `number` | moved right, in px of the composition |+| `y` | `number` | moved down, in px of the composition |+| `scale` | `number` | times its size (1 as it is) |+| `rotate` | `number` | turned clockwise, in degrees |+| `opacity` | `number` | from 0 (gone) to 1 (as it is) |+| `mirror` | `boolean` | flipped left to right |+| `crop` | `[number, number, number, number]` | cut in from each edge, in % of its size: left, top, right, bottom |++### `SeqRow`++A <Sequence> as the host lists it: its place among the file's elements, its span in the composition's frames,+the lane it sits on (nested ones below their parent, overlapping ones apart), and why it can't be rewritten.++| Field | Type | What it is |+| --- | --- | --- |+| `i` (required) | `number` | its place among the file's <Sequence> elements, in source order: what an edit names it by |+| `name` (required) | `string` | its name prop, or what the host calls it when it has none |+| `label` | `string` | what its clip's head says, when it isn't the name |+| `from` (required) | `number` | its first frame in the composition |+| `to` (required) | `number` | the frame after its last |+| `lane` (required) | `number` | the lane it sits on: 0 the top, nested ones below their parent, overlapping ones apart |+| `locked` | `string` | why it can't be rewritten (a span from a variable, a loop), when it can't |+| `keys` | `Record<string, [number, number, Ease?][]>` | the keys its <Nudge> holds, each [frame of the sequence, value, ease?] |+| `speed` | `number` | how fast the footage it holds plays (its media's playbackRate), when it holds footage at one rate |+| `curve` | `[number, number][]` | its footage's speed as a curve, each [place 0 to 1, speed] (its media's speedCurve), over `shows` source frames |+| `shows` | `number` | under `curve`: how many source frames it shows |+| `look` | `SeqLook` | how it is placed, as its <Nudge> says without keys: moved, scaled, turned, faded, mirrored, cropped |+| `text` | `string` | the words it shows, when words are all it shows: a text clip, its words changed by renaming it |+| `effect` | `{ kind: string; amount: number; /** a plugin's: the parts that draw it */ parts?: Effec…` | the effect it puts on the picture under it, when an <Effect> is all it holds: an effect clip |+| `in` | `{ kind: string; frames: number }` | how it comes in and goes out: its <Transition>'s in and out |+| `out` | `{ kind: string; frames: number }` | how it goes out: its <Transition>'s out |+| `media` | `"video" \| "audio"` | a <Video> or an <Audio> of its own: it plays where the sequence it is in does, from `startFrom` of its file, at its own level |+| `startFrom` | `number` | its media's first frame used, in frames of its file |+| `volume` | `number` | its media's level, 1 as recorded |++### `Showing`++What the player shows at a frame of the edited timeline.++| Field | Type | What it is |+| --- | --- | --- |+| `clip` (required) | `Clip` | the main track's clip there |+| `source` (required) | `number` | the source frame to show |+| `rate` (required) | `number` | how fast the source runs there (the player's rate) |++### `SnapGrid`++Marks edges snap to that a plugin adds: a grid, one mark every `every` seconds from the start.++| Field | Type | What it is |+| --- | --- | --- |+| `id` (required) | `string` | its id: lowercase letters, digits and dashes |+| `title` (required) | `string` | what the snap menu says |+| `every` (required) | `number` | seconds between its marks, from 0.01 to 600 |++### `SoundTrack`++A track of a sound in the feed as its host lists it (raea-feed host/sounds.ts), in seconds of the render.++| Field | Type | What it is |+| --- | --- | --- |+| `id` (required) | `string` | its id in the sound's file |+| `name` (required) | `string` | what its head says |+| `kind` (required) | `"notes" \| "clips" \| "lines"` | what it holds: notes (a part played from notes), clips (files placed in time) or lines (words sung or said) |+| `bus` (required) | `string` | the bus it plays through |+| `clips` (required) | `{ id: string; from: number; to: number; label: string; src?: string; offset?: number; g…` | its clips, each with its span in seconds, what it is, its file, where in the file it starts and its level in dB |++### `SpeedPoint`++A point of a speed curve: how fast the source plays at a place in it (0 its first frame shown, 1 its last).++| Field | Type | What it is |+| --- | --- | --- |+| `at` (required) | `number` | where in the source, from 0 (its first frame shown) to 1 (its last) |+| `speed` (required) | `number` | how fast it plays there: 1 as recorded, 2 twice as fast, 0.5 half |++### `Target`++A frame an edge snaps to.++| Field | Type | What it is |+| --- | --- | --- |+| `at` (required) | `Frames` | its frame on the timeline |+| `what` (required) | `"clip" \| "playhead" \| "marker" \| "beat" \| "start"` | what is there, for the line drawn where it snapped |++### `TextStyle`++A way words are put on the picture: where they stand, and how they are drawn (CSS, as React writes it).++| Field | Type | What it is |+| --- | --- | --- |+| `kind` (required) | `string` | its kind, kept in a text clip's props |+| `title` (required) | `string` | what the bar says |+| `place` (required) | `"top" \| "center" \| "bottom"` | where the words stand on the picture |+| `style` (required) | `Record<string, string \| number>` | how they are drawn: type and colour, as React writes CSS (TEXT_PROPS lists what it may set) |++### `Timeline`++A whole timeline: its tracks top to bottom, its marks, its transitions and its three switches.++| Field | Type | What it is |+| --- | --- | --- |+| `fps` (required) | `number` | frames a second, which every Frames value counts in |+| `tracks` (required) | `Track[]` | its tracks, top to bottom |+| `markers` (required) | `Marker[]` | marks on the ruler |+| `transitions` (required) | `Transition[]` | transitions on cuts |+| `magnet` (required) | `boolean` | the main track holds no gap (P, TL4a) |+| `snapping` (required) | `boolean` | edges snap to cuts, the playhead, marks and beats (N, TL4b) |+| `linkage` (required) | `boolean` | what sits over a main clip moves with it (~, TL4c) |++### `Track`++A row of clips that don't overlap, with its head's switches.++| Field | Type | What it is |+| --- | --- | --- |+| `id` (required) | `string` | its own id, unique on the timeline |+| `kind` (required) | `TrackKind` | what it holds, which places it in the stack |+| `name` | `string` | what its head says (its kind's title when unset) |+| `locked` | `boolean` | its clips can't be picked or changed |+| `hidden` | `boolean` | left out of the picture |+| `muted` | `boolean` | left out of the sound |+| `height` | `number` | drawn this tall, in px |+| `clips` (required) | `Clip[]` | its clips, in start order |++### `TrackKind`++A track's kind, in the order they stack from the top: effect, text, overlay, main, sound. A plugin adds+its own; an unknown kind sorts with the overlays.++```ts+type TrackKind = "effect" | "text" | "overlay" | "main" | "sound" | (string & {})+```++### `TrackKindInfo`++A kind of track: what its head says, and where it stacks (with the tracks over the picture, or with the sound+under it). A clip on it is of that kind.++| Field | Type | What it is |+| --- | --- | --- |+| `kind` (required) | `string` | its kind, as a Track's kind names it |+| `title` (required) | `string` | what its head says |+| `under` | `boolean` | it stacks with the sound, under the main track |++### `Transition`++A transition on the cut between two clips that touch on one track: the cut is the end of clip `after`,+so it follows that cut wherever an edit moves it.++| Field | Type | What it is |+| --- | --- | --- |+| `id` (required) | `string` | its own id, unique on the timeline |+| `kind` (required) | `string` | its kind: fade, slide, wipe, zoom or a plugin's (TRANSITIONS) |+| `after` (required) | `string` | the clip whose end is the cut it sits on |+| `length` (required) | `Frames` | how long it takes, centred on the cut |++### `TransitionKind`++| Field | Type | What it is |+| --- | --- | --- |+| `kind` (required) | `string` | the component's name in the composition's code |+| `title` (required) | `string` | what the cut's menu says |++### `Value`++A property's value: a number, a list of numbers (a colour, a point) or a string.++```ts+type Value = number | number[] | string+```++<!-- generated:end -->diff --git a/docs/manual/reference/sdk/index.md b/docs/manual/reference/sdk/index.mdindex 2873bb17..359bef66 100644--- a/docs/manual/reference/sdk/index.md+++ b/docs/manual/reference/sdk/index.md@@ -51,7 +51,7 @@ Frames, animation, springs, states and input, and holding a frame until it's rea## Video, sound and text-Footage, pictures, sound, words and colour.+Footage, pictures, sound, words and colour, and the timeline they are edited on.| Import | What it's for | Exports || --- | --- | --- |@@ -61,6 +61,7 @@ Footage, pictures, sound, words and colour.| [`raea/image`](image.md) | Pictures on the page and in the world, and texture atlases packed from them. | 3 components, 1 class, 5 types || [`raea/asset`](asset.md) | Files the project holds and assets made for it: staticFile, generated sound and music, and glTF bytes. | 9 functions, 1 value, 8 types || [`raea/color`](color.md) | Bevy's colour types: Srgba, LinearRgba, Hsla, Oklab, Oklch and the rest, with their conversions. | 2 functions, 7 classes |+| [`raea/editor`](editor.md) | the timeline the feed edits a film, a scene or a sound on, as data. Tracks, clips, keys and markers; every edit an operation with its inverse (apply); a composition's sequences read into it (sequenceRows) and the edits written back as SeqEdit; easings, speed curves, snapping, the frame store's keys and what a plugin adds. No React and no DOM: an agent's script, the app's host and a test use the same model the app's strip does. | 50 functions, 14 values, 31 types |## 3Ddiff --git a/docs/manual/reference/sdk/raea.md b/docs/manual/reference/sdk/raea.mdindex 5f3575ed..1d1aff13 100644--- a/docs/manual/reference/sdk/raea.md+++ b/docs/manual/reference/sdk/raea.md@@ -52,7 +52,7 @@ A box over the whole of its parent, laid out as a flex column; `style` is merged| `className` | `string` | Tailwind or CSS classes || `children` | `ReactNode` | what fills it |-Used in: [ui/images/image_node](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/image_node.tsx), [ui/images/ui_texture_slice_flip_and_tile](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/ui_texture_slice_flip_and_tile.tsx), [ui/images/image_node_resizing](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/image_node_resizing.tsx), [ui/images/ui_texture_atlas_slice](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/ui_texture_atlas_slice.tsx), [ui/images/ui_texture_slice](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/ui_texture_slice.tsx), [ui/images/ui_texture_atlas](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/ui_texture_atlas.tsx), [ui/layout/grid](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/layout/grid.tsx), [ui/layout/ghost_nodes](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/layout/ghost_nodes.tsx), and 98 more.+Used in: [ui/images/image_node](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/image_node.tsx), [ui/images/ui_texture_slice_flip_and_tile](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/ui_texture_slice_flip_and_tile.tsx), [ui/images/image_node_resizing](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/image_node_resizing.tsx), [ui/images/ui_texture_atlas_slice](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/ui_texture_atlas_slice.tsx), [ui/images/ui_texture_slice](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/ui_texture_slice.tsx), [ui/images/ui_texture_atlas](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/ui_texture_atlas.tsx), [ui/layout/grid](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/layout/grid.tsx), [ui/layout/ghost_nodes](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/layout/ghost_nodes.tsx), and 99 more.### `Animate`@@ -108,7 +108,7 @@ Declares a composition inside the root. It draws nothing itself; a renderer find| `defaultProps` | `P` | the props it's rendered with (JSON-like values only) || `edit` | `Edit` | a hand edit laid over the composition (docs/craft-system.md, L): written back by the app's timeline |-Used in: [ui/images/image_node](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/image_node.tsx), [ui/images/ui_texture_slice_flip_and_tile](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/ui_texture_slice_flip_and_tile.tsx), [ui/images/image_node_resizing](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/image_node_resizing.tsx), [ui/images/ui_texture_atlas_slice](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/ui_texture_atlas_slice.tsx), [ui/images/ui_texture_slice](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/ui_texture_slice.tsx), [ui/images/ui_texture_atlas](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/ui_texture_atlas.tsx), [ui/layout/grid](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/layout/grid.tsx), [ui/layout/ghost_nodes](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/layout/ghost_nodes.tsx), and 152 more.+Used in: [ui/images/image_node](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/image_node.tsx), [ui/images/ui_texture_slice_flip_and_tile](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/ui_texture_slice_flip_and_tile.tsx), [ui/images/image_node_resizing](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/image_node_resizing.tsx), [ui/images/ui_texture_atlas_slice](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/ui_texture_atlas_slice.tsx), [ui/images/ui_texture_slice](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/ui_texture_slice.tsx), [ui/images/ui_texture_atlas](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/ui_texture_atlas.tsx), [ui/layout/grid](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/layout/grid.tsx), [ui/layout/ghost_nodes](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/layout/ghost_nodes.tsx), and 153 more.### `Effect`@@ -291,7 +291,7 @@ The frame being rendered, counted from the start of the nearest enclosing Sequenfunction useCurrentFrame(): number```-Used in: [ui/scroll_and_overflow/overflow_transform](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/scroll_and_overflow/overflow_transform.tsx), [ui/render_ui_to_texture](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/render_ui_to_texture.tsx), [ui/ui_material](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/ui_material.tsx), [ui/styling/gradients](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/styling/gradients.tsx), [ui/text/text_debug](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/text/text_debug.tsx), [ui/text/text](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/text/text.tsx), [ui/text/font_atlas_debug](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/text/font_atlas_debug.tsx), [3d/fog_volumes](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/3d/fog_volumes.tsx), and 46 more.+Used in: [ui/scroll_and_overflow/overflow_transform](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/scroll_and_overflow/overflow_transform.tsx), [ui/render_ui_to_texture](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/render_ui_to_texture.tsx), [ui/ui_material](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/ui_material.tsx), [ui/styling/gradients](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/styling/gradients.tsx), [ui/text/text_debug](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/text/text_debug.tsx), [ui/text/text](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/text/text.tsx), [ui/text/font_atlas_debug](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/text/font_atlas_debug.tsx), [3d/fog_volumes](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/3d/fog_volumes.tsx), and 47 more.### `useGameEvents`@@ -651,7 +651,7 @@ Names the root component the renderer starts from, and records its compositions.function registerRoot(given: ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentType): void```-Used in: [ui/images/image_node](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/image_node.tsx), [ui/images/ui_texture_slice_flip_and_tile](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/ui_texture_slice_flip_and_tile.tsx), [ui/images/image_node_resizing](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/image_node_resizing.tsx), [ui/images/ui_texture_atlas_slice](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/ui_texture_atlas_slice.tsx), [ui/images/ui_texture_slice](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/ui_texture_slice.tsx), [ui/images/ui_texture_atlas](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/ui_texture_atlas.tsx), [ui/layout/grid](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/layout/grid.tsx), [ui/layout/ghost_nodes](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/layout/ghost_nodes.tsx), and 152 more.+Used in: [ui/images/image_node](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/image_node.tsx), [ui/images/ui_texture_slice_flip_and_tile](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/ui_texture_slice_flip_and_tile.tsx), [ui/images/image_node_resizing](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/image_node_resizing.tsx), [ui/images/ui_texture_atlas_slice](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/ui_texture_atlas_slice.tsx), [ui/images/ui_texture_slice](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/ui_texture_slice.tsx), [ui/images/ui_texture_atlas](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/ui_texture_atlas.tsx), [ui/layout/grid](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/layout/grid.tsx), [ui/layout/ghost_nodes](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/layout/ghost_nodes.tsx), and 153 more.### `replayDecider`diff --git a/sdk/raea/src/editor.ts b/sdk/raea/src/editor.tsnew file mode 100644index 00000000..f47d2f61--- /dev/null+++ b/sdk/raea/src/editor.ts@@ -0,0 +1,6 @@+// raea/editor (raea's own; Bevy has no timeline editor): docs/timeline.feature TL11b. The timeline the feed edits a film, a scene or a sound on,+// as data. Tracks, clips, keys and markers; every edit an operation with its inverse (apply); a composition's+// sequences read into it (sequenceRows) and the edits written back as SeqEdit; easings, speed curves, snapping, the+// frame store's keys and what a plugin adds. No React and no DOM: an agent's script, the app's host and a test use+// the same model the app's strip does.+export * from "@raea/timeline";diff --git a/sdk/timeline/src/cache.ts b/sdk/timeline/src/cache.tsindex 6c7070fe..fd92650c 100644--- a/sdk/timeline/src/cache.ts+++ b/sdk/timeline/src/cache.ts@@ -76,8 +76,11 @@ export function keyOf(t: Timeline, [from, to]: Range, media: (clip: Clip) => strreturn `${from}-${to}-${h.toString(16).padStart(8, "0")}`}+/** A drawn range in the store, as the clearing reads it (TL10e). */export interface Kept {+ /** the range's key (rangeKey): what it is drawn from */key: string+ /** what it takes on disk */bytes: number/** when it was last played (ms) */used: numberdiff --git a/sdk/timeline/src/model.ts b/sdk/timeline/src/model.tsindex 73aaf19b..abcfb838 100644--- a/sdk/timeline/src/model.ts+++ b/sdk/timeline/src/model.ts@@ -1,6 +1,7 @@// The timeline's model (docs/timeline.feature TL0). Time is whole frames (TL0a): a clip's start, length and trim, a// key and a marker are integers; seconds and timecodes are drawn from them, never the other way.+/** A count of frames, always whole (TL0a). */export type Frames = number/** A track's kind, in the order they stack from the top (TL1a): effect, text, overlay, main, sound. A plugin adds@@ -12,41 +13,58 @@ export const ORDER: TrackKind[] = ["effect", "text", "overlay", "main", "sound"]* bezier's two handles [x1, y1, x2, y2] as CSS writes them (TL5c). */export type Ease = "linear" | "hold" | [number, number, number, number]+/** A property's value: a number, a list of numbers (a colour, a point) or a string. */export type Value = number | number[] | string/** A property's value at a frame of its clip (frames from the clip's start), and how it leaves for the next key. */export interface Key {+ /** the frame it is at, counted from its clip's start */at: Frames+ /** the property's value there: a number, a list of them (a colour, a point) or a string */value: Value+ /** how the value travels to the next key (linear when unset) */ease?: Ease}/** A point of a speed curve (TL6b): how fast the source plays at a place in it (0 its first frame shown, 1 its last). */export interface SpeedPoint {+ /** where in the source, from 0 (its first frame shown) to 1 (its last) */at: number+ /** how fast it plays there: 1 as recorded, 2 twice as fast, 0.5 half */speed: number}+/** A mark at a frame (TL2e): a beat, a comment's time (TL12b) or one put there by hand. */export interface Marker {+ /** its own id, unique on the timeline */id: string+ /** its frame on the timeline (on a clip: from the clip's start) */at: Frames+ /** what it says, shown on hover */name?: string+ /** its colour, any CSS colour */color?: string}+/** A span of something on a track: footage, a sound, words, a composition's sequence, an effect. */export interface Clip {+ /** its own id, unique on the timeline */id: string/** what it is: "video", "audio", "text", "sequence", "component", "effect", a plugin's own */kind: string+ /** what its head says (its file's or its sequence's name when unset) */name?: string- /** where it starts on the timeline, and for how long */+ /** where it starts on the timeline */start: Frames+ /** how long it lasts on the timeline */length: Frames- /** media: the first source frame it shows, and how many frames the source has (unset: no end to trim against) */+ /** media: the first source frame it shows */in?: Frames+ /** media: how many frames the source has (unset: no end to trim against) */source?: Frames- /** a constant speed (1 when unset), or a curve, which wins (TL6) */+ /** a constant speed (1 when unset, TL6a) */speed?: number+ /** a speed curve, which wins over `speed` (TL6b) */curve?: SpeedPoint[]/** under a curve: how many source frames the clip shows (its length is the time the curve takes over them) */shows?: Frames@@ -60,12 +78,15 @@ export interface Clip {locked?: string/** clips with one group pick and move as one (TL3g) */group?: string- /** still values, and keyed ones (TL5): a keyed property's still value is ignored */+ /** its still values by property (x, y, scale, rotate, opacity, text, a plugin's): a keyed one is ignored */props?: Record<string, Value | boolean>+ /** its keys by property, in frame order (TL5) */keys?: Record<string, Key[]>- /** sound: its level (1 as recorded) and its fades' lengths (TL8a) */+ /** sound: its level, 1 as recorded (TL8a) */volume?: number+ /** sound: how long it fades in from its start */fadeIn?: Frames+ /** sound: how long it fades out to its end */fadeOut?: Frames/** its element in the code (file:line:col, docs/editing.feature E2) */at?: string@@ -76,35 +97,54 @@ export interface Clip {inside?: { kind: TrackKind; clip: Clip }[]}+/** A row of clips that don't overlap, with its head's switches (TL1b). */export interface Track {+ /** its own id, unique on the timeline */id: string+ /** what it holds, which places it in the stack (TL1a) */kind: TrackKind+ /** what its head says (its kind's title when unset) */name?: string+ /** its clips can't be picked or changed */locked?: boolean+ /** left out of the picture */hidden?: boolean+ /** left out of the sound */muted?: boolean/** drawn this tall, in px (TL1c) */height?: number+ /** its clips, in start order */clips: Clip[]}/** A transition on the cut between two clips that touch on one track (TL7a): the cut is the end of clip `after`,* so it follows that cut wherever an edit moves it. */export interface Transition {+ /** its own id, unique on the timeline */id: string+ /** its kind: fade, slide, wipe, zoom or a plugin's (TRANSITIONS) */kind: string+ /** the clip whose end is the cut it sits on */after: string+ /** how long it takes, centred on the cut */length: Frames}+/** A whole timeline: its tracks top to bottom, its marks, its transitions and its three switches. */export interface Timeline {+ /** frames a second, which every Frames value counts in */fps: number+ /** its tracks, top to bottom */tracks: Track[]+ /** marks on the ruler (TL2e) */markers: Marker[]+ /** transitions on cuts (TL7a) */transitions: Transition[]- /** the main track holds no gap (TL4a), edges snap (TL4b), what sits over a main clip follows it (TL4c) */+ /** the main track holds no gap (P, TL4a) */magnet: boolean+ /** edges snap to cuts, the playhead, marks and beats (N, TL4b) */snapping: boolean+ /** what sits over a main clip moves with it (~, TL4c) */linkage: boolean}diff --git a/sdk/timeline/src/play.ts b/sdk/timeline/src/play.tsindex ee3bb612..a9a0a29d 100644--- a/sdk/timeline/src/play.ts+++ b/sdk/timeline/src/play.ts@@ -8,7 +8,9 @@ import { played, sourceAt as curveAt } from "./speed"const main = (t: Timeline): Clip[] => (t.tracks.find((k) => k.kind === "main" && !k.hidden)?.clips ?? []).filter((c) => !c.off && c.in !== undefined).sort((a, b) => a.start - b.start)+/** What the player shows at a frame of the edited timeline (TL10a). */export interface Showing {+ /** the main track's clip there */clip: Clip/** the source frame to show */source: numberdiff --git a/sdk/timeline/src/read.ts b/sdk/timeline/src/read.tsindex 799e953f..ca3aef8e 100644--- a/sdk/timeline/src/read.ts+++ b/sdk/timeline/src/read.ts@@ -16,7 +16,7 @@ export function textStyleOf(v: unknown): TextStyle | undefined {return undefined}}-import { effectPartsError } from "../../video/src/effects"+import { effectPartsError } from "@raea/video/effects"/** An effect clip's parts, kept in its props as JSON: read back when they are well formed. */export function effectParts(v: unknown): EffectPart[] | undefined {@@ -32,12 +32,19 @@ export function effectParts(v: unknown): EffectPart[] | undefined {/** A <Sequence> as the host lists it: its place among the file's elements, its span in the composition's frames,* the lane it sits on (nested ones below their parent, overlapping ones apart), and why it can't be rewritten. */export interface SeqRow {+ /** its place among the file's <Sequence> elements, in source order: what an edit names it by */i: number+ /** its name prop, or what the host calls it when it has none */name: string+ /** what its clip's head says, when it isn't the name */label?: string+ /** its first frame in the composition */from: number+ /** the frame after its last */to: number+ /** the lane it sits on: 0 the top, nested ones below their parent, overlapping ones apart */lane: number+ /** why it can't be rewritten (a span from a variable, a loop), when it can't */locked?: string/** the keys its <Nudge> holds, each [frame of the sequence, value, ease?] (TL5d) */keys?: Record<string, [number, number, Ease?][]>@@ -45,6 +52,7 @@ export interface SeqRow {speed?: number/** its footage's speed as a curve, each [place 0 to 1, speed] (its media's speedCurve), over `shows` source frames (TL6b) */curve?: [number, number][]+ /** under `curve`: how many source frames it shows */shows?: number/** how it is placed, as its <Nudge> says without keys: moved, scaled, turned, faded, mirrored, cropped (TL3h) */look?: SeqLook@@ -54,21 +62,31 @@ export interface SeqRow {effect?: { kind: string; amount: number; /** a plugin's: the parts that draw it */ parts?: EffectPart[] }/** how it comes in and goes out: its <Transition>'s in and out (TL7a) */in?: { kind: string; frames: number }+ /** how it goes out: its <Transition>'s out */out?: { kind: string; frames: number }/** a <Video> or an <Audio> of its own (TL0c): it plays where the sequence it is in does, from `startFrom` of its* file, at its own level */media?: "video" | "audio"+ /** its media's first frame used, in frames of its file */startFrom?: number+ /** its media's level, 1 as recorded */volume?: number}/** A sequence's still placement: its <Nudge>'s props (sdk/video nudge.tsx). `crop` is left, top, right, bottom. */export interface SeqLook {+ /** moved right, in px of the composition */x?: number+ /** moved down, in px of the composition */y?: number+ /** times its size (1 as it is) */scale?: number+ /** turned clockwise, in degrees */rotate?: number+ /** from 0 (gone) to 1 (as it is) */opacity?: number+ /** flipped left to right */mirror?: boolean+ /** cut in from each edge, in % of its size: left, top, right, bottom */crop?: [number, number, number, number]}const CROPS = ["cropLeft", "cropTop", "cropRight", "cropBottom"]@@ -315,18 +333,27 @@ export function seqEdits(t: Timeline, op: Op): SeqEdit[] | { why: string } {/** A track of a sound in the feed as its host lists it (raea-feed host/sounds.ts), in seconds of the render. */export interface SoundTrack {+ /** its id in the sound's file */id: string+ /** what its head says */name: string+ /** what it holds: notes (a part played from notes), clips (files placed in time) or lines (words sung or said) */kind: "notes" | "clips" | "lines"+ /** the bus it plays through */bus: string+ /** its clips, each with its span in seconds, what it is, its file, where in the file it starts and its level in dB */clips: { id: string; from: number; to: number; label: string; src?: string; offset?: number; gainDb?: number }[]}/** A clip's span and level, in seconds and dB: what the host writes back for a clip that was moved, trimmed or* turned up or down (raea-feed host/clips.ts). */export interface ClipSpan {+ /** where it starts, in seconds of the render */start: number+ /** where it ends, in seconds of the render */end: number+ /** where in its file it starts playing, in seconds */offset: number+ /** its level change, in dB (0 as recorded) */gainDb: number}diff --git a/sdk/timeline/src/registry.ts b/sdk/timeline/src/registry.tsindex aabc3136..4f870f3b 100644--- a/sdk/timeline/src/registry.ts+++ b/sdk/timeline/src/registry.ts@@ -5,36 +5,47 @@ import { EASES } from "./keys"import { type Ease, type SpeedPoint, under } from "./model"import { CURVES, FASTEST, SLOWEST } from "./speed"// raea's effects (TL7b): the one table the engine's <Effect> draws from, so a preview here is what a render shows-import { EFFECTS, effectFilter, type EffectKind, type EffectPart, effectPartsError, partsFilter } from "../../video/src/effects"+import { EFFECTS, effectFilter, type EffectKind, type EffectPart, effectPartsError, partsFilter } from "@raea/video/effects"export { EFFECTS, effectFilter, type EffectKind, type EffectPart, partsFilter }/** An effect the palette offers: raea's own by its kind, a plugin's with the parts that draw it. */export interface EffectInfo {+ /** its kind, as <Effect kind> takes it */kind: string+ /** what the bar and the clip's head say */title: string+ /** a plugin's: the CSS filter functions that draw it, each from amount 0 to amount 1 */parts?: EffectPart[]}export interface TransitionKind {/** the component's name in the composition's code */kind: string+ /** what the cut's menu says */title: string}/** A kind of track: what its head says, and where it stacks (with the tracks over the picture, or with the sound* under it). A clip on it is of that kind. */export interface TrackKindInfo {+ /** its kind, as a Track's kind names it */kind: string+ /** what its head says */title: string+ /** it stacks with the sound, under the main track */under?: boolean}/** A way words are put on the picture (TL7c): where they stand, and how they are drawn (CSS, as React writes it). */export interface TextStyle {+ /** its kind, kept in a text clip's props */kind: string+ /** what the bar says */title: string+ /** where the words stand on the picture */place: "top" | "center" | "bottom"+ /** how they are drawn: type and colour, as React writes CSS (TEXT_PROPS lists what it may set) */style: Record<string, string | number>}/** The CSS a text style may set: type and colour, nothing that lays the frame out. */@@ -61,14 +72,20 @@ export function textStyleError(t: unknown): string | undefined {/** A tool a plugin adds (TL11a): one press sets these on every picked clip, as one edit each. */export interface Preset {+ /** its id: lowercase letters, digits and dashes */id: string+ /** what the bar says */title: string+ /** what it sets on each picked clip: placement props (PRESET_PROPS), a speed, a level */set: { props?: Record<string, number | boolean>; speed?: number; volume?: number }}/** Marks edges snap to that a plugin adds (TL11a): a grid, one mark every `every` seconds from the start. */export interface SnapGrid {+ /** its id: lowercase letters, digits and dashes */id: string+ /** what the snap menu says */title: string+ /** seconds between its marks, from 0.01 to 600 */every: number}/** The props a preset may set: a clip's placement (what the editor's own tools set). */@@ -98,8 +115,11 @@ export function gridFrames(grid: SnapGrid, fps: number, length: number): number[/** What one plugin adds. */export interface Adds {+ /** easings of its own, by name (TL5c) */eases?: Record<string, Ease>+ /** speed curves of its own, by name (TL6b) */curves?: Record<string, SpeedPoint[]>+ /** transitions of its own (TL7a) */transitions?: TransitionKind[]/** kinds of track of its own (TL11a): a clip posted or added on one is drawn and edited like any other */tracks?: TrackKindInfo[]diff --git a/sdk/timeline/src/snap.ts b/sdk/timeline/src/snap.tsindex f70b3c09..4650450b 100644--- a/sdk/timeline/src/snap.ts+++ b/sdk/timeline/src/snap.ts@@ -2,7 +2,9 @@// beats and the film's ends. (The main track's magnet is the operations' own: ops.ts settles it.)import { type Clip, end, type Frames, type Timeline, type Track } from "./model"+/** A frame an edge snaps to. */export interface Target {+ /** its frame on the timeline */at: Frames/** what is there, for the line drawn where it snapped */what: "clip" | "playhead" | "marker" | "beat" | "start"diff --git a/sdk/tsconfig.base.json b/sdk/tsconfig.base.jsonindex 6a05dad6..188ccd06 100644--- a/sdk/tsconfig.base.json+++ b/sdk/tsconfig.base.json@@ -88,6 +88,8 @@"@raea/audio/*": ["./audio/src/*"],"@raea/video": ["./video/src/index.ts"],"@raea/video/*": ["./video/src/*"],+ "@raea/timeline": ["./timeline/src/index.ts"],+ "@raea/timeline/*": ["./timeline/src/*"],"@raea/character": ["./character/src/index.ts"],"@raea/character/*": ["./character/src/*"],"@raea/asset": ["./asset/src/index.ts"],diff --git a/tools/manual-ref/sdk.ts b/tools/manual-ref/sdk.tsindex 8fa67970..c7143e51 100644--- a/tools/manual-ref/sdk.ts+++ b/tools/manual-ref/sdk.ts@@ -24,7 +24,7 @@ const problems: string[] = []const GROUPS: [string, string, string[]][] = [["Start here", "The composition, the app, and the specs and notes an agent writes.", ["raea", "app", "brief", "note"]],["Time and motion", "Frames, animation, springs, states and input, and holding a frame until it's ready.", ["time", "animation", "math", "state", "input", "hold"]],- ["Video, sound and text", "Footage, pictures, sound, words and colour.", ["video", "audio", "text", "image", "asset", "color"]],+ ["Video, sound and text", "Footage, pictures, sound, words and colour, and the timeline they are edited on.", ["video", "audio", "text", "image", "asset", "color", "editor"]],["3D", "Bevy's 3D: cameras, lights, materials, meshes and the frame after it's drawn.", ["3d", "camera", "light", "pbr", "mesh", "transform", "post_process", "picking", "gizmos"]],["2D and UI", "Sprites and flat shapes, bevy_ui and Bevy's widgets.", ["sprite", "ui", "feathers"]],["Tools", "Checks, lints and a headless App you can drive.", ["check", "fingerprint", "dev_tools", "remote"]],