@alpha2-sh/editor 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +107 -1
- package/dist/browser/bridge.d.ts +44 -0
- package/dist/browser/bridge.js +2176 -0
- package/dist/browser/extensions-worker-entry.js +3 -0
- package/dist/browser/extensions-worker.d.ts +46 -0
- package/dist/browser/extensions-worker.js +149 -0
- package/dist/browser/hash-worker-entry.d.ts +1 -0
- package/dist/browser/hash-worker-entry.js +3 -0
- package/dist/browser/hash-worker.d.ts +24 -0
- package/dist/browser/hash-worker.js +87 -0
- package/dist/browser/index.d.ts +11 -0
- package/dist/browser/index.js +9 -0
- package/dist/browser/jobs.d.ts +82 -0
- package/dist/browser/jobs.js +291 -0
- package/dist/browser/resources.d.ts +40 -0
- package/dist/browser/resources.js +83 -0
- package/dist/browser/runtime/assets.d.ts +233 -0
- package/dist/browser/runtime/assets.js +633 -0
- package/dist/browser/runtime/audio.d.ts +60 -0
- package/dist/browser/runtime/audio.js +549 -0
- package/dist/browser/runtime/budget.d.ts +11 -0
- package/dist/browser/runtime/budget.js +26 -0
- package/dist/browser/runtime/caption-fonts.d.ts +34 -0
- package/dist/browser/runtime/caption-fonts.js +69 -0
- package/dist/browser/runtime/color.d.ts +7 -0
- package/dist/browser/runtime/color.js +12 -0
- package/dist/browser/runtime/engine.d.ts +91 -0
- package/dist/browser/runtime/engine.js +352 -0
- package/dist/browser/runtime/export-audio.d.ts +23 -0
- package/dist/browser/runtime/export-audio.js +75 -0
- package/dist/browser/runtime/exporter.d.ts +140 -0
- package/dist/browser/runtime/exporter.js +751 -0
- package/dist/browser/runtime/extension-import.d.ts +196 -0
- package/dist/browser/runtime/extension-import.js +521 -0
- package/dist/browser/runtime/fingerprint.d.ts +57 -0
- package/dist/browser/runtime/fingerprint.js +157 -0
- package/dist/browser/runtime/generators.d.ts +188 -0
- package/dist/browser/runtime/generators.js +173 -0
- package/dist/browser/runtime/locks.d.ts +32 -0
- package/dist/browser/runtime/locks.js +86 -0
- package/dist/browser/runtime/output.d.ts +87 -0
- package/dist/browser/runtime/output.js +230 -0
- package/dist/browser/runtime/preview-utils.d.ts +3 -0
- package/dist/browser/runtime/preview-utils.js +49 -0
- package/dist/browser/runtime/proxies.d.ts +72 -0
- package/dist/browser/runtime/proxies.js +369 -0
- package/dist/browser/runtime/proxy-storage.d.ts +59 -0
- package/dist/browser/runtime/proxy-storage.js +119 -0
- package/dist/browser/runtime/sources.d.ts +82 -0
- package/dist/browser/runtime/sources.js +819 -0
- package/dist/browser/runtime/staging.d.ts +10 -0
- package/dist/browser/runtime/staging.js +32 -0
- package/dist/browser/runtime/still.d.ts +21 -0
- package/dist/browser/runtime/still.js +52 -0
- package/dist/browser/runtime/wasm.d.ts +9 -0
- package/dist/browser/runtime/wasm.js +20 -0
- package/dist/browser/types.d.ts +549 -0
- package/dist/browser/types.js +1 -0
- package/dist/browser/worker-entry.d.ts +1 -0
- package/dist/browser/worker-entry.js +2 -0
- package/dist/browser/worker.d.ts +24 -0
- package/dist/browser/worker.js +239 -0
- package/dist/core/captions.d.ts +34 -0
- package/dist/core/captions.js +108 -0
- package/dist/core/clip-time.d.ts +31 -0
- package/dist/core/clip-time.js +125 -0
- package/dist/core/commands.d.ts +413 -0
- package/dist/core/commands.js +1118 -0
- package/dist/core/compositions.d.ts +234 -0
- package/dist/core/compositions.js +851 -0
- package/dist/core/document.d.ts +245 -0
- package/dist/core/document.js +683 -0
- package/dist/core/keyframes.d.ts +82 -0
- package/dist/core/keyframes.js +153 -0
- package/dist/core/presets.d.ts +64 -0
- package/dist/core/presets.js +241 -0
- package/dist/core/session.d.ts +150 -0
- package/dist/core/session.js +541 -0
- package/dist/core/text.d.ts +17 -0
- package/dist/core/text.js +17 -0
- package/dist/core/time.d.ts +19 -0
- package/dist/core/time.js +39 -0
- package/dist/core/timeline-index.d.ts +44 -0
- package/dist/core/timeline-index.js +59 -0
- package/dist/core/transitions.d.ts +20 -0
- package/dist/core/transitions.js +118 -0
- package/dist/core/validated.d.ts +23 -0
- package/dist/core/validated.js +52 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +11 -0
- package/dist/native-client/index.d.ts +131 -0
- package/dist/native-client/index.js +354 -0
- package/dist/ports/index.d.ts +146 -0
- package/dist/ports/index.js +1 -0
- package/dist/react/index.d.ts +37 -0
- package/dist/react/index.js +94 -0
- package/package.json +69 -8
- /package/{index.js → dist/browser/extensions-worker-entry.d.ts} +0 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import type { ExportFailureCode } from "alpha2/export-failure";
|
|
2
|
+
import type { ClipTransition, MediaFingerprint, Project, Track, Clip, ProjectSettings, TimeRange } from "alpha2/project";
|
|
3
|
+
/** A JSON value: what editor metadata and asset authoring data may hold. */
|
|
4
|
+
export type Json = null | boolean | number | string | readonly Json[] | {
|
|
5
|
+
readonly [key: string]: Json;
|
|
6
|
+
};
|
|
7
|
+
/** A bin asset: what the editor knows about a project source or effect resource. */
|
|
8
|
+
export interface AssetDescriptor {
|
|
9
|
+
/** The id of the project source or effect resource it describes. */
|
|
10
|
+
readonly id: string;
|
|
11
|
+
/**
|
|
12
|
+
* The source kind (`video`, `image`, `generated`, ...), or an editor-only kind such as
|
|
13
|
+
* `captions`.
|
|
14
|
+
*/
|
|
15
|
+
readonly kind: string;
|
|
16
|
+
/** The display name, usually the imported file's name. */
|
|
17
|
+
readonly name: string;
|
|
18
|
+
/**
|
|
19
|
+
* A non-negative safe integer that changes whenever the asset's content is replaced (a relink).
|
|
20
|
+
*/
|
|
21
|
+
readonly contentRevision: number;
|
|
22
|
+
/** Whether the asset's media is offline. */
|
|
23
|
+
readonly missing?: boolean;
|
|
24
|
+
/** Where the media is read from, when it is not kept in the document. */
|
|
25
|
+
readonly locator?: string;
|
|
26
|
+
/** Data the asset is built from: a text asset's `text` style, a captions asset's cue rows. */
|
|
27
|
+
readonly authoring?: Json;
|
|
28
|
+
/** Evidence of the file imported, as the project source records it too. */
|
|
29
|
+
readonly fingerprint?: MediaFingerprint;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A track's editor metadata. A `locked` track refuses every edit that changes what it renders; a
|
|
33
|
+
* track with `enabled: false` draws and plays nothing (see {@link compileEditorDocument}).
|
|
34
|
+
*/
|
|
35
|
+
export interface TrackMetadata {
|
|
36
|
+
readonly locked?: boolean;
|
|
37
|
+
readonly enabled?: boolean;
|
|
38
|
+
/** A `#rrggbb` color. */
|
|
39
|
+
readonly color?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Whether a ripple edit on another track moves this track's content after the edit point too,
|
|
42
|
+
* keeping it in sync.
|
|
43
|
+
*/
|
|
44
|
+
readonly syncLock?: boolean;
|
|
45
|
+
}
|
|
46
|
+
/** A clip's editor metadata. A clip without a `name` shows its source's name. */
|
|
47
|
+
export interface ClipMetadata {
|
|
48
|
+
readonly name?: string;
|
|
49
|
+
}
|
|
50
|
+
/** A timeline marker: an instant, or a range when it has an `end`. */
|
|
51
|
+
export interface Marker {
|
|
52
|
+
readonly id: string;
|
|
53
|
+
/** Where it is, in timeline ticks. */
|
|
54
|
+
readonly time: number;
|
|
55
|
+
/** Where a range marker ends; after `time`. */
|
|
56
|
+
readonly end?: number;
|
|
57
|
+
readonly name: string;
|
|
58
|
+
readonly note?: string;
|
|
59
|
+
/** A `#rrggbb` color. */
|
|
60
|
+
readonly color?: string;
|
|
61
|
+
/** Whether what it notes is done. */
|
|
62
|
+
readonly done?: boolean;
|
|
63
|
+
}
|
|
64
|
+
/** A node's place in the node editor, in canvas pixels. */
|
|
65
|
+
export interface GraphPosition {
|
|
66
|
+
readonly x: number;
|
|
67
|
+
readonly y: number;
|
|
68
|
+
}
|
|
69
|
+
/** Node positions by composition, then node: editor metadata, not render input. */
|
|
70
|
+
export type GraphLayout = Readonly<Record<string, Readonly<Record<string, GraphPosition>>>>;
|
|
71
|
+
/** What the editor keeps beside the engine project: none of it is render input. */
|
|
72
|
+
export interface EditorMetadata {
|
|
73
|
+
/** By track id. */
|
|
74
|
+
readonly tracks: Readonly<Record<string, TrackMetadata>>;
|
|
75
|
+
/** By clip id. */
|
|
76
|
+
readonly clips: Readonly<Record<string, ClipMetadata>>;
|
|
77
|
+
/**
|
|
78
|
+
* Stable ids for list items the project keeps without one, by list (`<trackId>/cues`,
|
|
79
|
+
* `<trackId>/transitions`, `<clipId>/masks`). Maintained by {@link withInstanceIds}.
|
|
80
|
+
*/
|
|
81
|
+
readonly instanceIds: Readonly<Record<string, readonly string[]>>;
|
|
82
|
+
readonly markers: readonly Marker[];
|
|
83
|
+
/** The range an export renders by default, in timeline ticks; `null` for the whole timeline. */
|
|
84
|
+
readonly exportRange: TimeRange | null;
|
|
85
|
+
/** Node positions of the effect graph view. */
|
|
86
|
+
readonly graphLayout?: GraphLayout;
|
|
87
|
+
/**
|
|
88
|
+
* Names of compositions drawn as groups, by composition id: editor metadata, not render input.
|
|
89
|
+
*/
|
|
90
|
+
readonly graphNames?: Readonly<Record<string, string>>;
|
|
91
|
+
}
|
|
92
|
+
/** An editor project file: the engine project plus editor metadata and bin assets. */
|
|
93
|
+
export interface EditorDocument {
|
|
94
|
+
readonly format: "alpha2-editor-project";
|
|
95
|
+
readonly version: 1;
|
|
96
|
+
readonly project: Project;
|
|
97
|
+
readonly metadata: EditorMetadata;
|
|
98
|
+
readonly assets: Readonly<Record<string, AssetDescriptor>>;
|
|
99
|
+
}
|
|
100
|
+
/** An editor refusal or failure, with a machine-readable `code` (a snake_case identifier). */
|
|
101
|
+
export declare class EditorError extends Error {
|
|
102
|
+
readonly code: string;
|
|
103
|
+
readonly operation: string;
|
|
104
|
+
readonly entityId?: string | undefined;
|
|
105
|
+
readonly recoverable: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* @param code What went wrong, such as `invalid_command` or `locked`.
|
|
108
|
+
* @param message A human-readable description.
|
|
109
|
+
* @param operation The operation that failed, such as `validate`, `open` or a command name.
|
|
110
|
+
* @param entityId The track, clip, asset or other entity the error concerns, when there is one.
|
|
111
|
+
* @param recoverable Whether the editor stays usable after the error. Defaults to `true`.
|
|
112
|
+
*/
|
|
113
|
+
constructor(code: string, message: string, operation: string, entityId?: string | undefined, recoverable?: boolean, options?: ErrorOptions);
|
|
114
|
+
/**
|
|
115
|
+
* The export failure class this error is evidence of, which `classifyBrowserFailure` reads: the
|
|
116
|
+
* editor knows what its own refusals mean. `UNKNOWN` for a code without a class.
|
|
117
|
+
*/
|
|
118
|
+
get failureCode(): ExportFailureCode;
|
|
119
|
+
}
|
|
120
|
+
/** The outcome of an operation that reports its refusal instead of throwing it. */
|
|
121
|
+
export type Result<T> = {
|
|
122
|
+
readonly ok: true;
|
|
123
|
+
readonly value: T;
|
|
124
|
+
} | {
|
|
125
|
+
readonly ok: false;
|
|
126
|
+
readonly error: EditorError;
|
|
127
|
+
};
|
|
128
|
+
/** Deep-freezes `value` in place and returns it. Already frozen objects are not descended into. */
|
|
129
|
+
export declare function freeze<T>(value: T): T;
|
|
130
|
+
/**
|
|
131
|
+
* The deepest nesting of arrays and objects an editor document may have: the engine's for its
|
|
132
|
+
* project ({@link MAX_JSON_DEPTH}), and one more for the document that holds it.
|
|
133
|
+
*/
|
|
134
|
+
export declare const MAX_DOCUMENT_JSON_DEPTH: number;
|
|
135
|
+
/**
|
|
136
|
+
* Throws an `EditorError` (`invalid_document`) unless `value` is plain JSON: finite numbers, and
|
|
137
|
+
* arrays and plain objects of JSON values only, nested at most `maxDepth` arrays and objects deep
|
|
138
|
+
* ({@link MAX_DOCUMENT_JSON_DEPTH} by default).
|
|
139
|
+
*/
|
|
140
|
+
export declare function assertJson(value: unknown, maxDepth?: number): void;
|
|
141
|
+
/**
|
|
142
|
+
* Throws an `EditorError` unless `document` is a valid editor document: finite JSON within the
|
|
143
|
+
* engine and editor file size limits, a supported format and version, a project the engine
|
|
144
|
+
* accepts, and well-formed editor metadata and assets.
|
|
145
|
+
*/
|
|
146
|
+
export declare function validateDocument(document: EditorDocument): void;
|
|
147
|
+
/**
|
|
148
|
+
* Throws the first `invalid_projection` error of `document`'s projection (the project without what
|
|
149
|
+
* disabled tracks draw and play), so a document that opens is one the engine renders.
|
|
150
|
+
*/
|
|
151
|
+
export declare function assertProjection(document: EditorDocument): void;
|
|
152
|
+
/**
|
|
153
|
+
* The checks a gesture's candidate needs on every pointer move: the format and the project's
|
|
154
|
+
* rules. What `validateDocument` adds (every value is finite JSON, the engine JSON and the editor
|
|
155
|
+
* file fit their size limits) walks or serializes the whole document, so a gesture runs it once,
|
|
156
|
+
* when it commits. The project's rules cost a candidate the parts its command changed:
|
|
157
|
+
* `validateProject` reuses what it found of the frozen parts the candidate shares with the
|
|
158
|
+
* gesture's start. Throws an `EditorError` (`unsupported_version` or `invalid_project`).
|
|
159
|
+
*/
|
|
160
|
+
export declare function validateDocumentShape(document: EditorDocument): void;
|
|
161
|
+
/**
|
|
162
|
+
* The largest editor file {@link parseDocument} opens. Every document that validates fits it, as
|
|
163
|
+
* {@link serializeDocument} writes it.
|
|
164
|
+
*/
|
|
165
|
+
export declare const MAX_EDITOR_FILE_BYTES: number;
|
|
166
|
+
/**
|
|
167
|
+
* A new frozen document holding a copy of `project`, with an asset for each source and effect
|
|
168
|
+
* resource (offline unless generated or a composition) overridden by `assets`. Throws an
|
|
169
|
+
* `EditorError` when the result does not validate.
|
|
170
|
+
*/
|
|
171
|
+
export declare function createDocument(project: Project, assets?: EditorDocument["assets"]): EditorDocument;
|
|
172
|
+
/** A new document with no media: 1920x1080 at 30 fps and 48 kHz unless `settings` say otherwise. */
|
|
173
|
+
export declare function createEmptyDocument(settings?: Partial<ProjectSettings>): EditorDocument;
|
|
174
|
+
/**
|
|
175
|
+
* The editor file of `document`: compact JSON, so a document that validates is a file
|
|
176
|
+
* {@link parseDocument} opens. Throws an `EditorError` when the document does not validate.
|
|
177
|
+
*/
|
|
178
|
+
export declare function serializeDocument(document: EditorDocument): string;
|
|
179
|
+
/**
|
|
180
|
+
* Opens an editor file, or a bare engine project (JSON with `schema_version`) as a new document.
|
|
181
|
+
* Returns a frozen document. Every refusal is an `EditorError`: `too_large` for a file over
|
|
182
|
+
* {@link MAX_EDITOR_FILE_BYTES}, `invalid_document` for text that is not an editor document's JSON,
|
|
183
|
+
* and the code of the check a document (or project) fails otherwise.
|
|
184
|
+
*/
|
|
185
|
+
export declare function parseDocument(text: string): EditorDocument;
|
|
186
|
+
/**
|
|
187
|
+
* The id of `transition` on track `trackId`: the edge it joins, which a track has one transition
|
|
188
|
+
* on. It stays the transition's own while other transitions come and go, and changes when its clips
|
|
189
|
+
* do (a split hands an outgoing transition to the right part).
|
|
190
|
+
*/
|
|
191
|
+
export declare function transitionInstanceId(trackId: string, transition: Pick<ClipTransition, "from_clip" | "to_clip">): string;
|
|
192
|
+
/**
|
|
193
|
+
* `document` with an instance id for every caption cue, transition and clip mask: each track's
|
|
194
|
+
* transitions named by {@link transitionInstanceId}; cues and masks keep the ids they have, and
|
|
195
|
+
* those without one get a new one no other in the list has. Returns `document` itself when nothing
|
|
196
|
+
* changes, and leaves a document of the wrong shape for validation to refuse.
|
|
197
|
+
*/
|
|
198
|
+
export declare function withInstanceIds(document: EditorDocument): EditorDocument;
|
|
199
|
+
/** A document's tracks and clips by id. */
|
|
200
|
+
export interface EntityIndex {
|
|
201
|
+
readonly tracks: ReadonlyMap<string, Track>;
|
|
202
|
+
readonly clips: ReadonlyMap<string, {
|
|
203
|
+
readonly clip: Clip;
|
|
204
|
+
readonly trackId: string;
|
|
205
|
+
}>;
|
|
206
|
+
}
|
|
207
|
+
/** The {@link EntityIndex} of `document`, built once per document object and cached. */
|
|
208
|
+
export declare function indexDocument(document: EditorDocument): EntityIndex;
|
|
209
|
+
/** What the engine renders of a document. */
|
|
210
|
+
export interface CompiledEditorDocument {
|
|
211
|
+
/**
|
|
212
|
+
* The project as the engine renders it: what disabled tracks draw and play left out, the mattes
|
|
213
|
+
* enabled clips name kept (see `compileEditorDocument`).
|
|
214
|
+
*/
|
|
215
|
+
readonly project: Project;
|
|
216
|
+
/** The engine's validation errors for `project`, as `invalid_projection` errors. */
|
|
217
|
+
readonly diagnostics: readonly EditorError[];
|
|
218
|
+
/** The projection's JSON: equal keys render the same. Serialized on first read. */
|
|
219
|
+
readonly revisionKey: string;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* The project the engine renders for `document`. A disabled track draws and plays nothing: it is
|
|
223
|
+
* left out, but for the clips enabled clips name as mattes (never drawn themselves), kept on it
|
|
224
|
+
* muted; a track that ducks under a disabled track does not duck; a clip only disabled clips name
|
|
225
|
+
* as their matte draws nothing but still plays. Never throws for an invalid projection; the errors
|
|
226
|
+
* are in `diagnostics`. Cached for frozen documents.
|
|
227
|
+
*/
|
|
228
|
+
export declare function compileEditorDocument(document: EditorDocument): CompiledEditorDocument;
|
|
229
|
+
/**
|
|
230
|
+
* Where `project`'s timeline ends, in ticks: the end of its last clip or caption cue, 0 when it has
|
|
231
|
+
* neither.
|
|
232
|
+
*/
|
|
233
|
+
export declare function sequenceEnd(project: Project): number;
|
|
234
|
+
/**
|
|
235
|
+
* Where `document`'s program ends, in ticks: the {@link sequenceEnd} of what the engine renders of
|
|
236
|
+
* it ({@link compileEditorDocument}), so a disabled track adds no length. Playback without an
|
|
237
|
+
* export range stops there, an export without one ends there, and an export range with only its
|
|
238
|
+
* start set runs to it.
|
|
239
|
+
*/
|
|
240
|
+
export declare function programEnd(document: EditorDocument): number;
|
|
241
|
+
/**
|
|
242
|
+
* Seeds the {@link indexDocument} cache of `next` from that of `previous`, rebuilding entries only
|
|
243
|
+
* for tracks that changed. Does nothing when `previous` has no index.
|
|
244
|
+
*/
|
|
245
|
+
export declare function inheritDocumentIndex(previous: EditorDocument, next: EditorDocument): void;
|