@alpha2-sh/editor 0.4.6 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/bridge.d.ts +15 -16
- package/dist/browser/bridge.js +396 -312
- package/dist/browser/extensions-worker.d.ts +12 -16
- package/dist/browser/extensions-worker.js +17 -24
- package/dist/browser/hash-worker.d.ts +4 -5
- package/dist/browser/hash-worker.js +7 -8
- package/dist/browser/jobs.d.ts +17 -19
- package/dist/browser/jobs.js +41 -28
- package/dist/browser/resources.d.ts +6 -11
- package/dist/browser/resources.js +5 -9
- package/dist/browser/runtime/assets.d.ts +47 -28
- package/dist/browser/runtime/assets.js +129 -45
- package/dist/browser/runtime/audio.d.ts +16 -11
- package/dist/browser/runtime/audio.js +58 -31
- package/dist/browser/runtime/budget.d.ts +4 -5
- package/dist/browser/runtime/budget.js +4 -5
- package/dist/browser/runtime/caption-fonts.d.ts +3 -7
- package/dist/browser/runtime/caption-fonts.js +4 -8
- package/dist/browser/runtime/engine.d.ts +39 -44
- package/dist/browser/runtime/engine.js +78 -64
- package/dist/browser/runtime/export-audio.d.ts +6 -6
- package/dist/browser/runtime/export-audio.js +8 -9
- package/dist/browser/runtime/exporter.d.ts +33 -66
- package/dist/browser/runtime/exporter.js +111 -137
- package/dist/browser/runtime/extension-import.d.ts +28 -35
- package/dist/browser/runtime/extension-import.js +36 -46
- package/dist/browser/runtime/fingerprint.d.ts +11 -14
- package/dist/browser/runtime/fingerprint.js +20 -24
- package/dist/browser/runtime/generators.d.ts +2 -3
- package/dist/browser/runtime/generators.js +5 -7
- package/dist/browser/runtime/locks.d.ts +5 -7
- package/dist/browser/runtime/locks.js +5 -7
- package/dist/browser/runtime/output.d.ts +7 -9
- package/dist/browser/runtime/output.js +17 -21
- package/dist/browser/runtime/preview-utils.js +10 -6
- package/dist/browser/runtime/proxies.d.ts +10 -17
- package/dist/browser/runtime/proxies.js +33 -45
- package/dist/browser/runtime/proxy-storage.d.ts +15 -19
- package/dist/browser/runtime/proxy-storage.js +20 -24
- package/dist/browser/runtime/sources.d.ts +23 -31
- package/dist/browser/runtime/sources.js +85 -103
- package/dist/browser/runtime/staging.d.ts +2 -6
- package/dist/browser/runtime/staging.js +7 -11
- package/dist/browser/runtime/still.d.ts +2 -6
- package/dist/browser/runtime/still.js +6 -12
- package/dist/browser/runtime/text.d.ts +14 -0
- package/dist/browser/runtime/text.js +27 -0
- package/dist/browser/runtime/wasm.d.ts +4 -5
- package/dist/browser/runtime/wasm.js +4 -5
- package/dist/browser/types.d.ts +233 -238
- package/dist/browser/worker.d.ts +8 -9
- package/dist/browser/worker.js +50 -21
- package/dist/core/captions.d.ts +8 -10
- package/dist/core/captions.js +10 -18
- package/dist/core/clip-time.d.ts +8 -10
- package/dist/core/clip-time.js +12 -15
- package/dist/core/commands.d.ts +46 -46
- package/dist/core/commands.js +38 -36
- package/dist/core/compositions.d.ts +78 -112
- package/dist/core/compositions.js +66 -94
- package/dist/core/document.d.ts +59 -92
- package/dist/core/document.js +64 -90
- package/dist/core/keyframes.d.ts +11 -12
- package/dist/core/keyframes.js +11 -13
- package/dist/core/presets.d.ts +14 -20
- package/dist/core/presets.js +12 -18
- package/dist/core/session.d.ts +26 -38
- package/dist/core/session.js +38 -53
- package/dist/core/text.d.ts +2 -3
- package/dist/core/text.js +2 -3
- package/dist/core/timeline-index.d.ts +2 -3
- package/dist/core/timeline-index.js +11 -7
- package/dist/core/transitions.js +4 -5
- package/dist/core/validated.d.ts +6 -7
- package/dist/core/validated.js +8 -11
- package/dist/native-client/index.d.ts +31 -32
- package/dist/native-client/index.js +40 -41
- package/dist/ports/index.d.ts +19 -20
- package/dist/react/index.d.ts +5 -6
- package/dist/react/index.js +5 -6
- package/package.json +4 -4
package/dist/core/commands.js
CHANGED
|
@@ -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
|
|
60
|
-
*
|
|
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
|
|
87
|
-
*
|
|
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
|
|
105
|
-
*
|
|
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
|
|
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
|
|
202
|
-
*
|
|
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
|
-
/**
|
|
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
|
|
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
|
|
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
|
-
//
|
|
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,
|
|
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
|
|
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
|
|
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
|
|
1026
|
-
* reach
|
|
1027
|
-
*
|
|
1028
|
-
*
|
|
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
|
|
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
|
-
//
|
|
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
|
|
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
|
|
11
|
-
*
|
|
12
|
-
*
|
|
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`.
|
|
20
|
-
*
|
|
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
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
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
|
|
35
|
-
* rewritten as that chain, or removed with the reference when the stack is empty.
|
|
36
|
-
*
|
|
37
|
-
*
|
|
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
|
|
47
|
-
*
|
|
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
|
|
52
|
-
* composition it shows, so the edit that stops
|
|
53
|
-
*
|
|
54
|
-
*
|
|
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
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
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
|
|
76
|
-
* definitions of
|
|
77
|
-
*
|
|
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
|
|
83
|
-
*
|
|
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
|
|
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
|
|
94
|
-
* compositions' outputs need
|
|
95
|
-
*
|
|
96
|
-
*
|
|
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
|
|
103
|
-
* transition nodes
|
|
104
|
-
*
|
|
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
|
|
129
|
-
*
|
|
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
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
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
|
-
*
|
|
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
|
|
162
|
-
*
|
|
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.
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
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
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
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
|
|
214
|
-
*
|
|
215
|
-
*
|
|
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`,
|
|
220
|
-
*
|
|
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
|
|
227
|
-
*
|
|
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`
|
|
232
|
-
* `definitionId
|
|
233
|
-
*
|
|
234
|
-
*
|
|
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
|
|
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
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
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;
|