@alpha2-sh/editor 0.4.6 → 0.5.1

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.
Files changed (81) hide show
  1. package/dist/browser/bridge.d.ts +15 -16
  2. package/dist/browser/bridge.js +393 -312
  3. package/dist/browser/extensions-worker.d.ts +12 -16
  4. package/dist/browser/extensions-worker.js +17 -24
  5. package/dist/browser/hash-worker.d.ts +4 -5
  6. package/dist/browser/hash-worker.js +7 -8
  7. package/dist/browser/jobs.d.ts +17 -19
  8. package/dist/browser/jobs.js +41 -28
  9. package/dist/browser/resources.d.ts +6 -11
  10. package/dist/browser/resources.js +5 -9
  11. package/dist/browser/runtime/assets.d.ts +52 -28
  12. package/dist/browser/runtime/assets.js +136 -45
  13. package/dist/browser/runtime/audio.d.ts +16 -11
  14. package/dist/browser/runtime/audio.js +102 -59
  15. package/dist/browser/runtime/budget.d.ts +4 -5
  16. package/dist/browser/runtime/budget.js +4 -5
  17. package/dist/browser/runtime/caption-fonts.d.ts +3 -7
  18. package/dist/browser/runtime/caption-fonts.js +4 -8
  19. package/dist/browser/runtime/engine.d.ts +44 -44
  20. package/dist/browser/runtime/engine.js +87 -64
  21. package/dist/browser/runtime/export-audio.d.ts +6 -6
  22. package/dist/browser/runtime/export-audio.js +8 -9
  23. package/dist/browser/runtime/exporter.d.ts +33 -66
  24. package/dist/browser/runtime/exporter.js +111 -137
  25. package/dist/browser/runtime/extension-import.d.ts +28 -35
  26. package/dist/browser/runtime/extension-import.js +36 -46
  27. package/dist/browser/runtime/fingerprint.d.ts +11 -14
  28. package/dist/browser/runtime/fingerprint.js +20 -24
  29. package/dist/browser/runtime/generators.d.ts +2 -3
  30. package/dist/browser/runtime/generators.js +5 -7
  31. package/dist/browser/runtime/locks.d.ts +5 -7
  32. package/dist/browser/runtime/locks.js +5 -7
  33. package/dist/browser/runtime/output.d.ts +7 -9
  34. package/dist/browser/runtime/output.js +17 -21
  35. package/dist/browser/runtime/preview-utils.js +10 -6
  36. package/dist/browser/runtime/proxies.d.ts +19 -19
  37. package/dist/browser/runtime/proxies.js +72 -51
  38. package/dist/browser/runtime/proxy-storage.d.ts +15 -19
  39. package/dist/browser/runtime/proxy-storage.js +20 -24
  40. package/dist/browser/runtime/sources.d.ts +23 -31
  41. package/dist/browser/runtime/sources.js +85 -103
  42. package/dist/browser/runtime/staging.d.ts +2 -6
  43. package/dist/browser/runtime/staging.js +7 -11
  44. package/dist/browser/runtime/still.d.ts +2 -6
  45. package/dist/browser/runtime/still.js +6 -12
  46. package/dist/browser/runtime/text.d.ts +14 -0
  47. package/dist/browser/runtime/text.js +27 -0
  48. package/dist/browser/runtime/wasm.d.ts +4 -5
  49. package/dist/browser/runtime/wasm.js +4 -5
  50. package/dist/browser/types.d.ts +244 -239
  51. package/dist/browser/worker.d.ts +10 -10
  52. package/dist/browser/worker.js +64 -22
  53. package/dist/core/captions.d.ts +8 -10
  54. package/dist/core/captions.js +10 -18
  55. package/dist/core/clip-time.d.ts +8 -10
  56. package/dist/core/clip-time.js +12 -15
  57. package/dist/core/commands.d.ts +46 -46
  58. package/dist/core/commands.js +38 -36
  59. package/dist/core/compositions.d.ts +78 -112
  60. package/dist/core/compositions.js +66 -94
  61. package/dist/core/document.d.ts +59 -92
  62. package/dist/core/document.js +65 -90
  63. package/dist/core/keyframes.d.ts +11 -12
  64. package/dist/core/keyframes.js +11 -13
  65. package/dist/core/presets.d.ts +14 -20
  66. package/dist/core/presets.js +12 -18
  67. package/dist/core/session.d.ts +26 -38
  68. package/dist/core/session.js +38 -53
  69. package/dist/core/text.d.ts +2 -3
  70. package/dist/core/text.js +2 -3
  71. package/dist/core/timeline-index.d.ts +2 -3
  72. package/dist/core/timeline-index.js +11 -7
  73. package/dist/core/transitions.js +4 -5
  74. package/dist/core/validated.d.ts +6 -7
  75. package/dist/core/validated.js +8 -11
  76. package/dist/native-client/index.d.ts +31 -32
  77. package/dist/native-client/index.js +40 -41
  78. package/dist/ports/index.d.ts +19 -20
  79. package/dist/react/index.d.ts +5 -6
  80. package/dist/react/index.js +5 -6
  81. package/package.json +4 -4
@@ -1,4 +1,5 @@
1
1
  import { addTransition, resizeTransition, removeTransition, } from "./transitions.js";
2
+ import { splitCue, trimCue } from "alpha2/captions";
2
3
  import * as edit from "alpha2/edit";
3
4
  import { drawnEffectResources, effectStack, findComposition, freeCompositionId, freeNodeId, groupNodes, ungroupNode, acceptsInput, correspondingCompositions, ownComposition, withEffectStack, withoutUndrawn, withInput, withoutNodes, shownSources, } from "./compositions.js";
4
5
  import { rememberValid, withValidated } from "./validated.js";
@@ -56,8 +57,8 @@ function changeComposition(document, id, update) {
56
57
  };
57
58
  }
58
59
  /**
59
- * `document` with `update` applied to every group node that draws composition `id`. A composition
60
- * without one stays the same object: the track lock tells what an edit changed by identity.
60
+ * `document` with `update` applied to every group node drawing composition `id`. Unaffected
61
+ * compositions keep their identity, since the track lock detects changes by identity.
61
62
  */
62
63
  function mapGroupNodes(document, id, update) {
63
64
  const draws = (node) => node.op.type === "group" && node.op.composition === id;
@@ -83,8 +84,8 @@ function nodeIn(composition, id) {
83
84
  return node;
84
85
  }
85
86
  /**
86
- * The tracks a ripple edit on `trackId` moves too: every other sync-locked track. A locked one
87
- * among them still refuses the edit, as any change to a locked track does.
87
+ * The other sync-locked tracks a ripple edit on `trackId` also moves. A locked one among them still
88
+ * refuses the edit.
88
89
  */
89
90
  function syncTrackIds(document, trackId) {
90
91
  return document.project.timeline.tracks
@@ -101,9 +102,8 @@ function patchedMarker(marker, patch) {
101
102
  }
102
103
  /**
103
104
  * `document` with every timeline marker (and range marker end) at or after `pivot` moved by
104
- * `delta`. A negative `delta` closes the time `[pivot + delta, pivot)`: a marker with any time
105
- * there refuses the edit (`sync_conflict`), as content there on a sync-locked track does, rather
106
- * than land on what the edit pulls in.
105
+ * `delta`. A negative `delta` closes `[pivot + delta, pivot)`, and a marker in that span refuses
106
+ * the edit (`sync_conflict`) as sync-locked content there does.
107
107
  */
108
108
  function shiftMarkers(document, pivot, delta) {
109
109
  if (!delta)
@@ -127,7 +127,7 @@ function shiftMarkers(document, pivot, delta) {
127
127
  fail("The edit would move a marker before the timeline start");
128
128
  return { ...document, metadata: { ...document.metadata, markers } };
129
129
  }
130
- /** The metadata the right part `newId` of a clip `leftId` cut in two inherits. */
130
+ /** The metadata right part `newId` of split clip `leftId` inherits. */
131
131
  function afterSplit(document, newId, leftId) {
132
132
  if (!indexDocument(document).clips.has(newId))
133
133
  return document;
@@ -149,10 +149,7 @@ function afterSplit(document, newId, leftId) {
149
149
  ? withCopiedGraphs(next, correspondingCompositions(next.project, left, right))
150
150
  : next;
151
151
  }
152
- /**
153
- * `document` with each copy in `copies` (by original id) drawn in the node editor where its
154
- * original is, under its name.
155
- */
152
+ /** `document` with each copy in `copies` (by original id) placed and named as its original. */
156
153
  function withCopiedGraphs(document, copies) {
157
154
  const layout = graphLayout(document);
158
155
  const names = graphNames(document);
@@ -198,8 +195,8 @@ function withoutGraphs(document, removed) {
198
195
  }
199
196
  /**
200
197
  * The project an `alpha2/edit` operation made for `command`, or its refusal as an `EditorError`
201
- * about `id`. Outside a transaction the edit validated what it made, so `executeCommand` does not
202
- * validate the same project again.
198
+ * about `id`. Outside a transaction the edit already validated the project, so `executeCommand`
199
+ * skips that.
203
200
  */
204
201
  function edited(result, command, id) {
205
202
  if (!result.ok)
@@ -208,7 +205,7 @@ function edited(result, command, id) {
208
205
  rememberValid(result.project);
209
206
  return result.project;
210
207
  }
211
- /** How many transactions `apply` is inside: their edits leave validation to `executeCommand`. */
208
+ /** Transaction nesting depth; edits inside leave validation to `executeCommand`. */
212
209
  let transactions = 0;
213
210
  function fail(message, id) {
214
211
  throw new EditorError("invalid_command", message, "dispatch", id);
@@ -287,7 +284,7 @@ function reduce(document, command) {
287
284
  metadata: { ...document.metadata, ...command.patch },
288
285
  };
289
286
  case "track.add": {
290
- // Each brought clip shows its own copy of a shared composition, as clip.insert does.
287
+ // Each clip gets its own copy of a shared composition, as with clip.insert.
291
288
  const withTrack = (on, track) => ({
292
289
  ...on,
293
290
  timeline: {
@@ -518,7 +515,7 @@ function reduce(document, command) {
518
515
  }),
519
516
  };
520
517
  }
521
- // A delete that closes nothing is validated with the rest.
518
+ // A delete that closes no gap is validated with the rest.
522
519
  const made = command.type === "clip.delete" && !command.ripple && result.ok
523
520
  ? result.project
524
521
  : edited(result, command, command.id);
@@ -544,7 +541,7 @@ function reduce(document, command) {
544
541
  case "clip.update":
545
542
  return changeClip(document, command.id, (c) => {
546
543
  const next = { ...c, ...command.patch };
547
- // `auto` is the default the engine writes by leaving the field out.
544
+ // The engine writes `auto` by omitting the field.
548
545
  if (next.cache === "auto")
549
546
  delete next.cache;
550
547
  return next;
@@ -637,7 +634,7 @@ function reduce(document, command) {
637
634
  };
638
635
  });
639
636
  case "graph.node.remove": {
640
- // A control goes with the node it exposes, and so do the values group nodes set for it.
637
+ // A control goes with the node it exposes, as do the values group nodes set for it.
641
638
  let dropped = [];
642
639
  const next = changeComposition(document, command.compositionId, (c) => {
643
640
  for (const id of command.ids)
@@ -718,7 +715,7 @@ function reduce(document, command) {
718
715
  fail(error.message, command.compositionId);
719
716
  }
720
717
  const layout = graphLayout(document)[command.compositionId] ?? {};
721
- // What moved into the definition: a selected group input stays where it is.
718
+ // What moved into the definition; selected group inputs stay.
722
719
  const moved = new Set((grouped.definition.nodes ?? []).map((node) => node.id));
723
720
  const grouping = command.ids.filter((id) => moved.has(id));
724
721
  const placed = grouping
@@ -761,8 +758,7 @@ function reduce(document, command) {
761
758
  const group = nodeIn(composition, command.nodeId);
762
759
  if (group.op.type !== "group")
763
760
  fail("Only a group node ungroups", command.nodeId);
764
- // A bypassed group passes its first input through and draws nothing of its definition, which
765
- // inlined nodes cannot say in general.
761
+ // A bypassed group passes its first input through, which inlined nodes cannot express.
766
762
  if (group.bypass)
767
763
  fail(`Turn group ${command.nodeId} on before ungrouping it: ungrouped, its nodes would draw`, command.nodeId);
768
764
  const definition = findComposition(project, group.op.composition);
@@ -897,7 +893,9 @@ function reduce(document, command) {
897
893
  return withLayout(document, command.compositionId, command.positions);
898
894
  case "cue.add":
899
895
  case "cue.update":
900
- case "cue.remove": {
896
+ case "cue.remove":
897
+ case "cue.split":
898
+ case "cue.trim": {
901
899
  if (!track?.captions)
902
900
  fail("Not a caption track", command.trackId);
903
901
  const key = `${track.id}/cues`;
@@ -919,10 +917,19 @@ function reduce(document, command) {
919
917
  const i = nextIds.indexOf(command.instanceId);
920
918
  if (i < 0)
921
919
  fail("Unknown cue");
922
- cues.splice(i, 1);
920
+ const [held] = cues.splice(i, 1);
923
921
  nextIds.splice(i, 1);
924
922
  if (command.type === "cue.update")
925
923
  place(command.instanceId, command.cue);
924
+ if (command.type === "cue.split") {
925
+ if (nextIds.includes(command.newInstanceId))
926
+ fail("Duplicate cue");
927
+ const [first, second] = splitCue(held, command.at);
928
+ place(command.instanceId, first);
929
+ place(command.newInstanceId, second);
930
+ }
931
+ if (command.type === "cue.trim")
932
+ place(command.instanceId, trimCue(held, command.start, command.end));
926
933
  }
927
934
  return ids({
928
935
  ...document,
@@ -973,10 +980,7 @@ function reduce(document, command) {
973
980
  }
974
981
  }
975
982
  }
976
- /**
977
- * Ids of the compositions `clips` draw: their own and their sources', and those these use through
978
- * group nodes and composition sources.
979
- */
983
+ /** Ids of the compositions `clips` draw, their sources', and transitively what those use. */
980
984
  function reachedCompositions(project, clips) {
981
985
  const sources = new Map(project.sources.map((s) => [s.id, s]));
982
986
  const reached = new Set();
@@ -1022,11 +1026,10 @@ function apply(document, command) {
1022
1026
  }
1023
1027
  /**
1024
1028
  * Refuses `command` when it changed what a locked track renders, directly or through a ripple,
1025
- * matte, graph or asset edit: the track and its clips, their metadata, the compositions its clips
1026
- * reach (with the groups and composition sources they draw), and the sources it draws and the
1027
- * effect resources its drawn nodes and transitions read, with their bin assets. Fonts are the whole
1028
- * project's fallback stack, which no clip names, so they are not among them. A part the edit left
1029
- * as the same object is not looked into.
1029
+ * matte, graph or asset edit. That covers the track, its clips and their metadata, the compositions
1030
+ * its clips reach, the sources it draws, and the effect resources its nodes and transitions read,
1031
+ * with their bin assets. Fonts are a project-wide fallback stack no clip names, so they are
1032
+ * excluded. Parts the edit left as the same object are skipped.
1030
1033
  */
1031
1034
  function assertLocksKept(document, next, command) {
1032
1035
  const locked = document.project.timeline.tracks.filter((t) => document.metadata.tracks[t.id]?.locked);
@@ -1082,8 +1085,7 @@ function assertLocksKept(document, next, command) {
1082
1085
  }
1083
1086
  /**
1084
1087
  * Applies `command` to `document` and validates the result. `gesture` checks only what a pointer
1085
- * move can change (see `validateDocumentShape`); the gesture validates in full once, when it
1086
- * commits.
1088
+ * move can change (see `validateDocumentShape`); the gesture validates in full when it commits.
1087
1089
  *
1088
1090
  * Never throws: a refusal is `{ ok: false }` with an `EditorError` (`invalid_command`, `locked`, a
1089
1091
  * validation code, or an edit code from `alpha2/edit`). `document` and `command` are not modified;
@@ -1095,7 +1097,7 @@ export function executeCommand(document, command, { gesture = false } = {}) {
1095
1097
  const reduced = apply(document, structuredClone(command));
1096
1098
  // A clip owns the composition it shows: what the command stopped drawing goes.
1097
1099
  const undrawn = withoutUndrawn(document.project, reduced.project);
1098
- // What the command brought in is put in the forms the engine writes, as all of a document is.
1100
+ // Canonicalize what the command brought in.
1099
1101
  const next = withInstanceIds(canonicalDocument(withoutGraphs(undrawn.removed.size
1100
1102
  ? { ...reduced, project: undrawn.project }
1101
1103
  : reduced, undrawn.removed)));
@@ -1,5 +1,5 @@
1
1
  import type { Clip, ClipEffect, Composition, CompositionNode, Project } from "alpha2/project";
2
- /** One effect of a clip's effect stack: an effect node of its composition. */
2
+ /** One entry of a clip's effect stack, an effect node of its composition. */
3
3
  export interface StackEntry {
4
4
  /** The effect node's id, stable across edits. */
5
5
  readonly id: string;
@@ -7,52 +7,46 @@ export interface StackEntry {
7
7
  readonly bypass: boolean;
8
8
  }
9
9
  /**
10
- * A composition of `P`: in the forms the engine writes when `P` is a document's `CanonicalProject`,
11
- * as written when `P` is a `Project`. The helpers below return parts in the form their input has:
12
- * they rearrange what they are given, and what they add (ids, inputs, effect and group nodes) holds
13
- * no color or paint, so a canonical project stays canonical through them.
10
+ * A composition of `P`, canonical when `P` is a `CanonicalProject`. The helpers below return parts
11
+ * in their input's form; what they add holds no color or paint, so canonical projects stay
12
+ * canonical.
14
13
  */
15
14
  export type CompositionOf<P extends Project> = NonNullable<P["compositions"]>[number];
16
15
  /** A clip of `P`, in the form `P` holds it (see {@link CompositionOf}). */
17
16
  export type ClipOf<P extends Project> = NonNullable<P["timeline"]["tracks"][number]["clips"]>[number];
18
17
  /**
19
- * The composition `id` names in `project`. Looked up in an index of the project's compositions
20
- * array, made once per array, so walks that find many compositions stay linear. An index a changed
21
- * array no longer matches is made again, and an id it lacks is looked for in the array itself.
18
+ * The composition `id` names in `project`. Uses an index cached per compositions array so walks
19
+ * that find many compositions stay linear; a stale index is rebuilt.
22
20
  */
23
21
  export declare function findComposition<P extends Project>(project: P, id: string): CompositionOf<P> | undefined;
24
22
  /**
25
- * A clip's effects as a stack: its composition when that is the clip's picture through a chain of
26
- * effect nodes and nothing else, bottom first. A clip without a composition has an empty stack.
27
- * `undefined` means the composition is a graph a stack cannot show: it branches, merges, reads
28
- * other sources, or has loose nodes.
23
+ * A clip's effects as a stack, bottom first, when its composition is just a chain of effect nodes
24
+ * over the clip's picture. A clip without a composition has an empty stack. `undefined` when the
25
+ * composition is a graph a stack cannot show (it branches, merges, reads other sources, or has
26
+ * loose nodes).
29
27
  */
30
28
  export declare function effectStack(project: Project, clip: Clip): readonly StackEntry[] | undefined;
31
29
  /** An id based on `base` that no composition in `project` has. */
32
30
  export declare function freeCompositionId(project: Project, base: string): string;
33
31
  /**
34
- * `project` with clip `clipId` showing its picture through `stack`, bottom first: its composition
35
- * rewritten as that chain, or removed with the reference when the stack is empty. The composition
36
- * keeps its id and the clip its time mapping; a clip without one gets `<clip id>-fx`.
37
- * Throws when `clipId` names no clip.
32
+ * `project` with clip `clipId` showing its picture through `stack`, bottom first. Its composition
33
+ * is rewritten as that chain, or removed with the reference when the stack is empty. It keeps its
34
+ * id and the clip its time mapping; a clip without one gets `<clip id>-fx`. Throws when `clipId`
35
+ * names no clip.
38
36
  */
39
37
  export declare function withEffectStack<P extends Project>(project: P, clipId: string, stack: readonly StackEntry[]): P;
40
- /**
41
- * The compositions `id` draws: itself and, through group nodes, the group definitions it uses, each
42
- * once.
43
- */
38
+ /** The compositions `id` draws: itself and the group definitions it uses, each once. */
44
39
  export declare function compositionTree<P extends Project>(project: P, id: string): CompositionOf<P>[];
45
40
  /**
46
- * Ids of the compositions `project` draws: those clips show and composition sources show (Library
47
- * items), and those these use through group nodes and composition sources, as far as they go.
41
+ * Ids of the compositions `project` draws: those clips and composition sources (Library items)
42
+ * show, and transitively those they use through group nodes and composition sources.
48
43
  */
49
44
  export declare function drawnCompositions(project: Project): Set<string>;
50
45
  /**
51
- * `after` without the compositions `before` drew and `after` no longer does: a clip owns the
52
- * composition it shows, so the edit that stops the last drawing of one (deleting its clip or track,
53
- * removing its Library source or the group node that drew it, emptying an effect stack) removes it,
54
- * and the group definitions only it drew with it. A composition `before` did not draw stays, so one
55
- * added for a later edit (a macro's definition) waits for it. Returns the ids it removed.
46
+ * `after` without the compositions `before` drew and `after` no longer does, plus group definitions
47
+ * only they drew. A clip owns the composition it shows, so the edit that stops its last use removes
48
+ * it. Compositions `before` did not draw stay, so one added for a later edit (a macro's definition)
49
+ * survives. Returns the removed ids.
56
50
  */
57
51
  export declare function withoutUndrawn<P extends Project>(before: Project, after: P): {
58
52
  readonly project: P;
@@ -60,11 +54,10 @@ export declare function withoutUndrawn<P extends Project>(before: Project, after
60
54
  };
61
55
  /**
62
56
  * `project` with `clip` given compositions no other clip draws, for a clip a command puts down (a
63
- * paste, a duplicate). With `compositions`, those the clip drew when it was copied, it shows a copy
64
- * of them whatever the project has now. Otherwise it shows a copy of its composition when anything
65
- * else draws that composition or a group definition in it, and the composition itself when nothing
66
- * does. A copy takes free ids based on `<root>~<clip id>` ({@link copyComposition}), so the clip is
67
- * edited independently of its original. Returns the copies' ids by their originals'.
57
+ * paste, a duplicate). With `compositions` (those the clip drew when copied) it shows copies of
58
+ * them. Otherwise it shows a copy of its composition when anything else draws it or a group
59
+ * definition in it, and the composition itself when nothing does. Copies take free ids based on
60
+ * `<root>~<clip id>` ({@link copyComposition}). Returns the copies' ids by their originals'.
68
61
  */
69
62
  export declare function ownComposition<P extends Project>(project: P, clip: ClipOf<P>, compositions?: readonly CompositionOf<P>[]): {
70
63
  readonly project: P;
@@ -72,37 +65,33 @@ export declare function ownComposition<P extends Project>(project: P, clip: Clip
72
65
  readonly copies: ReadonlyMap<string, string>;
73
66
  };
74
67
  /**
75
- * The compositions `copy` draws for those `original` draws, by id: the two themselves, and the
76
- * definitions of their group nodes of the same id, as far as they go. A composition copied for a
77
- * split or a paste corresponds to its original this way.
68
+ * The compositions `copy` draws for those `original` draws, by id: the two roots and, recursively,
69
+ * the definitions of same-id group nodes. Compositions copied for a split or paste correspond this
70
+ * way.
78
71
  */
79
72
  export declare function correspondingCompositions(project: Project, original: string, copy: string): Map<string, string>;
80
73
  /**
81
74
  * Composition time at timeline time `tick` for `clip`: `offset + (tick - start) * scale`, rounded
82
- * down, as the engine maps it. Without a composition, timeline time. Time is whole ticks; a
83
- * fraction (a curve sampled between ticks) reads as the tick it falls in.
75
+ * down as the engine does. Timeline time without a composition. A fractional tick reads as the tick
76
+ * it falls in.
84
77
  */
85
78
  export declare function compositionTime(clip: Clip, tick: number): number;
86
79
  /**
87
80
  * The first timeline time at which `clip` shows composition time `time`: the inverse of
88
- * {@link compositionTime}, rounded up to a tick. A fractional `time` is first rounded up to the
89
- * next whole tick.
81
+ * {@link compositionTime}, rounded up. A fractional `time` is rounded up first.
90
82
  */
91
83
  export declare function timelineTime(clip: Clip, time: number): number;
92
84
  /**
93
- * Ids of the sources `tracks`' clips draw: each clip's own, and those the media nodes its
94
- * compositions' outputs need read (the inputs {@link CompositionReads.neededInputs} names: of a
95
- * group node only the ports its composition reads), through group nodes and composition sources
96
- * too. A clip's composition source counts only where the clip's own composition draws the clip. The
97
- * engine's `Project::used_sources` is the same set; `tests/cases/used-sources-corpus.json` holds both to
98
- * it.
85
+ * Ids of the sources `tracks`' clips draw: each clip's own, and those read by media nodes their
86
+ * compositions' outputs need ({@link CompositionReads.neededInputs}), through group nodes and
87
+ * composition sources. A clip's own source counts only where its composition draws the clip.
88
+ * Matches the engine's `Project::used_sources`; `tests/cases/used-sources-corpus.json` checks both.
99
89
  */
100
90
  export declare function shownSources(project: Project, tracks?: Project["timeline"]["tracks"]): Set<string>;
101
91
  /**
102
- * Ids of the effect resources (`effect_resources`) what `tracks` draw reads: those the effect and
103
- * transition nodes drawing {@link shownSources} evaluates name (not a bypassed node's), and those
104
- * the tracks' transitions name. Only these must be registered for a render: the engine asks for a
105
- * resource when a node it evaluates needs one.
92
+ * Ids of the effect resources read by what `tracks` draw: those named by evaluated (not bypassed)
93
+ * effect and transition nodes and by the tracks' transitions. Only these must be registered for a
94
+ * render.
106
95
  */
107
96
  export declare function drawnEffectResources(project: Project, tracks?: Project["timeline"]["tracks"]): Set<string>;
108
97
  /**
@@ -112,74 +101,57 @@ export declare function drawnEffectResources(project: Project, tracks?: Project[
112
101
  export type InputKey = "input" | "from" | "to" | "matte" | `inputs.${string}` | number;
113
102
  /** The input keys of a node's operation, in order. */
114
103
  export declare function inputKeys(op: CompositionNode["op"]): InputKey[];
115
- /**
116
- * The inputs drawing `node` reads: only its pass-through input (the first) when it is bypassed, and
117
- * every input otherwise.
118
- */
104
+ /** The inputs drawing `node` reads: only its pass-through input (the first) when bypassed. */
119
105
  export declare function neededInputs(node: CompositionNode): InputKey[];
120
106
  /** What each composition's output reads, as alpha2-model's `CompositionReads`. */
121
107
  export interface CompositionReads {
122
- /**
123
- * Whether composition `id`'s output reads its group input `port`; true for a composition it does
124
- * not know.
125
- */
108
+ /** Whether composition `id`'s output reads group input `port`; true if `id` is unknown. */
126
109
  readsPort(id: string, port: number): boolean;
127
110
  /**
128
- * Whether composition `id`, shown by a clip, draws the clip's picture: its output reaches a clip
129
- * node, directly or in a group. True for a composition it does not know.
111
+ * Whether composition `id` draws its clip's picture (its output reaches a clip node, directly or
112
+ * in a group). True for an unknown composition.
130
113
  */
131
114
  drawsClip(id: string): boolean;
132
- /**
133
- * The inputs drawing `node` reads: its {@link neededInputs}, of a group node only the ports its
134
- * composition reads.
135
- */
115
+ /** The inputs drawing `node` reads: {@link neededInputs}, limited to read ports for groups. */
136
116
  neededInputs(node: CompositionNode): InputKey[];
137
117
  }
138
118
  /**
139
- * What each of `compositions` reads: the group inputs and clip nodes a walk from its output
140
- * reaches, along the inputs drawing each node reads, into the compositions its group nodes draw. A
141
- * group draws what its nodes would inline, so a group node needs only the ports its composition
142
- * reads: a port it never reads may be left unconnected, and what a connected one reads is not
143
- * drawn. A composition that uses itself (which validation refuses) reads every port and draws the
144
- * clip.
119
+ * What each composition's output reaches along needed inputs, into the compositions its group nodes
120
+ * draw. A group draws what its nodes would inline, so a group node needs only the ports its
121
+ * composition reads; an unread port may stay unconnected and what a connected one reads is not
122
+ * drawn. A self-referencing composition (refused by validation) reads all ports and draws the clip.
145
123
  */
146
124
  export declare function compositionReads(compositions: readonly Composition[]): CompositionReads;
147
125
  /** The node an input reads, or `undefined` when it is unconnected or absent. */
148
126
  export declare function inputOf(op: CompositionNode["op"], key: InputKey): string | undefined;
149
- /**
150
- * Whether `op` has input `key`, or can take it: an effect node takes any well-named
151
- * `inputs.<name>`, whether or not its definition declares it.
152
- */
127
+ /** Whether `op` has or can take input `key`; effect nodes take any well-formed `inputs.<name>`. */
153
128
  export declare function acceptsInput(op: CompositionNode["op"], key: InputKey): boolean;
154
129
  /**
155
- * `op` with input `key` reading `node` (`null` disconnects it, keeping an effect's named input).
156
- * An effect's named input is added when it has none of the name. Throws when `op` cannot take
157
- * input `key`.
130
+ * `op` with input `key` reading `node` (`null` disconnects it, keeping an effect's named input,
131
+ * which is added if absent). Throws when `op` cannot take input `key`.
158
132
  */
159
133
  export declare function withInput<O extends CompositionNode["op"]>(op: O, key: InputKey, node: string | null): O;
160
134
  /**
161
- * `op` without its effect input `name`; an effect left with none has no `inputs`, as the model
162
- * writes it. Any other operation is returned as it is.
135
+ * `op` without its effect input `name`, dropping `inputs` when none remain. Other operations are
136
+ * returned unchanged.
163
137
  */
164
138
  export declare function withoutEffectInput<O extends CompositionNode["op"]>(op: O, name: string): O;
165
139
  /**
166
140
  * How a composition is drawn, which decides what its clip nodes and group inputs read, as the
167
141
  * engine plans it.
168
142
  *
169
- * - `clip`: a clip's own composition. Its clip nodes draw the clip; no group node feeds its group
170
- * inputs.
171
- * - `source`: a composition source, drawn by a clip or a media node. Nothing feeds its clip nodes
172
- * or its group inputs.
173
- * - `group`: a group's definition, opened on its own. Its group inputs read the group node's
174
- * inputs, and whether its clip nodes draw anything depends on where the group is drawn, so
175
- * neither is an issue here.
143
+ * - `clip`: a clip's own composition. Clip nodes draw the clip; nothing feeds group inputs.
144
+ * - `source`: a composition source, drawn by a clip or a media node. Nothing feeds clip nodes or
145
+ * group inputs.
146
+ * - `group`: a group definition opened on its own. Group inputs read the group node's inputs and
147
+ * clip nodes depend on where the group is drawn, so neither is an issue.
176
148
  */
177
149
  export type GraphUse = "clip" | "source" | "group";
178
150
  /**
179
- * Why a composition's output cannot be drawn: the engine's four reasons for refusing it as an
180
- * incomplete composition (`INCOMPLETE_COMPOSITION`). An issue inside a composition that a group or
181
- * media node draws names its node as the engine does, prefixed by the drawing node's id and `/`
182
- * (`group/blur`); a `no_output` there names the drawing node.
151
+ * Why a composition's output cannot be drawn: the engine's reasons for `INCOMPLETE_COMPOSITION`.
152
+ * Issues inside a composition a group or media node draws name the node as the engine does,
153
+ * prefixed by the drawing node's id and `/` (`group/blur`); `no_output` there names the drawing
154
+ * node.
183
155
  */
184
156
  export type GraphIssue = {
185
157
  readonly kind: "no_output";
@@ -199,9 +171,7 @@ export type GraphIssue = {
199
171
  readonly kind: "clip_without_clip";
200
172
  readonly node: string;
201
173
  };
202
- /**
203
- * What {@link graphIssues} reads to follow group and media nodes into the compositions they draw.
204
- */
174
+ /** What {@link graphIssues} reads to follow group and media nodes into what they draw. */
205
175
  export interface GraphProject {
206
176
  readonly compositions?: readonly Composition[] | null;
207
177
  readonly sources: readonly {
@@ -210,44 +180,40 @@ export interface GraphProject {
210
180
  }[];
211
181
  }
212
182
  /**
213
- * What stops `composition`'s output from rendering when it is drawn as `use`: no output, an
214
- * unconnected input a node the output reaches uses (only the pass-through input of a bypassed node,
215
- * and of a group node only the ports its composition reads), a group input nothing feeds, or a clip
216
- * node where there is no clip. The engine refuses the same frames with `INCOMPLETE_COMPOSITION`;
217
- * this lets an editor mark the nodes before it asks.
183
+ * What stops `composition`'s output from rendering when drawn as `use`: no output, an unconnected
184
+ * needed input, a group input nothing feeds, or a clip node without a clip. The engine refuses the
185
+ * same frames with `INCOMPLETE_COMPOSITION`; this lets an editor mark the nodes first.
218
186
  *
219
- * With `project`, the issues of the compositions the output's group and media nodes draw are
220
- * included, as the engine plans them inline; without it those nodes are taken as drawn.
187
+ * With `project`, issues of compositions drawn by group and media nodes are included, as the engine
188
+ * plans them inline; without it those nodes count as drawn.
221
189
  */
222
190
  export declare function graphIssues(composition: Composition, use: GraphUse, project?: GraphProject): GraphIssue[];
223
191
  /** An id based on `base` that no node of `composition` has. */
224
192
  export declare function freeNodeId(composition: Composition, base: string): string;
225
193
  /**
226
- * `composition` without the nodes `ids`, every input that read one of them disconnected, no output
227
- * if it was one of them, and no control that exposed one of them.
194
+ * `composition` without nodes `ids`, disconnecting inputs that read them and dropping the output
195
+ * and controls that refer to them.
228
196
  */
229
197
  export declare function withoutNodes<C extends Composition>(composition: C, ids: readonly string[]): C;
230
198
  /**
231
- * `composition` with nodes `ids` folded into a group node `groupId` that draws a new composition
232
- * `definitionId` of them: each node outside the selection that a selected node reads becomes one of
233
- * its inputs, in the order first read, and the one selected node read from outside (or the output)
234
- * becomes its output. A selected group input stays in `composition`: it reads `composition`'s own
235
- * input, which a node inside the group reads through a port like any node outside. The picture does
199
+ * `composition` with nodes `ids` folded into a group node `groupId` drawing a new composition
200
+ * `definitionId`. Outside nodes that selected nodes read become group inputs in first-read order,
201
+ * and the one selected node read from outside (or the output) becomes its output. Selected group
202
+ * inputs stay in `composition` and are read through a port like any outside node. The picture does
236
203
  * not change.
237
204
  *
238
205
  * @throws When the selection is empty or only group inputs, names an absent node, `groupId` names
239
- * an unselected node, or other than one selected node's picture leaves the selection.
206
+ * an unselected node, or not exactly one selected node's picture leaves the selection.
240
207
  */
241
208
  export declare function groupNodes<C extends Composition>(composition: C, ids: readonly string[], groupId: string, definitionId: string): {
242
209
  readonly parent: C;
243
210
  readonly definition: C;
244
211
  };
245
212
  /**
246
- * `composition` with group node `groupId` replaced by the nodes of the composition it draws, under
247
- * ids based on `<group>-<node>`: its group inputs read what the group node's inputs read, its
248
- * controls keep the values the group node set, and what read the group reads its output. Returns
249
- * the new ids by inner id. The picture does not change.
250
- * Throws when `groupId` is not a group node of `composition`.
213
+ * `composition` with group node `groupId` replaced by its definition's nodes, under ids based on
214
+ * `<group>-<node>`. Group inputs read what the group node's inputs read, controls keep the group
215
+ * node's values, and readers of the group read its output. Returns new ids by inner id. The picture
216
+ * does not change. Throws when `groupId` is not a group node of `composition`.
251
217
  */
252
218
  export declare function ungroupNode<C extends Composition>(composition: C, groupId: string, definition: C): {
253
219
  readonly parent: C;