@alpha2-sh/editor 0.5.2 → 0.6.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 +60 -3
- package/dist/browser/bridge.d.ts +5 -4
- package/dist/browser/bridge.js +390 -67
- package/dist/browser/extensions-worker.d.ts +4 -3
- package/dist/browser/extensions-worker.js +13 -6
- package/dist/browser/jobs.d.ts +17 -0
- package/dist/browser/jobs.js +40 -0
- package/dist/browser/resources.d.ts +9 -4
- package/dist/browser/resources.js +17 -5
- package/dist/browser/runtime/assets.d.ts +14 -2
- package/dist/browser/runtime/assets.js +37 -27
- package/dist/browser/runtime/audio.d.ts +12 -2
- package/dist/browser/runtime/audio.js +124 -14
- package/dist/browser/runtime/engine.js +8 -1
- package/dist/browser/runtime/exporter.d.ts +2 -1
- package/dist/browser/runtime/exporter.js +15 -4
- package/dist/browser/runtime/extension-import.d.ts +30 -10
- package/dist/browser/runtime/extension-import.js +52 -9
- package/dist/browser/runtime/preview-utils.d.ts +12 -0
- package/dist/browser/runtime/preview-utils.js +45 -0
- package/dist/browser/runtime/sources.d.ts +2 -2
- package/dist/browser/runtime/sources.js +23 -40
- package/dist/browser/runtime/wasm.d.ts +5 -5
- package/dist/browser/runtime/wasm.js +6 -13
- package/dist/browser/types.d.ts +138 -26
- package/dist/browser/worker.d.ts +4 -2
- package/dist/browser/worker.js +75 -25
- package/dist/core/commands.d.ts +46 -3
- package/dist/core/commands.js +212 -40
- package/dist/core/compositions.d.ts +27 -0
- package/dist/core/compositions.js +43 -0
- package/dist/core/data.d.ts +34 -0
- package/dist/core/data.js +69 -0
- package/dist/core/document.d.ts +20 -1
- package/dist/core/document.js +138 -8
- package/dist/core/keyframes.d.ts +3 -2
- package/dist/core/keyframes.js +6 -2
- package/dist/core/sameness.d.ts +6 -0
- package/dist/core/sameness.js +42 -0
- package/dist/core/session.d.ts +85 -7
- package/dist/core/session.js +124 -13
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/native-client/index.d.ts +2 -2
- package/dist/native-client/index.js +2 -2
- package/dist/ports/index.d.ts +5 -4
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -31,11 +31,68 @@ editor.dispose();
|
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
- An editor document holds an engine project (`document.project`), the editor's metadata, and a descriptor of each asset. `serializeDocument` and `parseDocument` write and read it as JSON; `parseDocument` also reads a plain engine project.
|
|
34
|
-
- `dispatch` applies one `Command` (the typed union covers the project, tracks, clips, effects, transitions, caption cues, composition graphs, assets and markers); a `transaction` applies several and is checked once, by the document it ends with. A command the document's rules refuse returns `{ ok: false, error }` and changes nothing. `canExecute` asks without applying.
|
|
34
|
+
- `dispatch` applies one `Command` (the typed union covers the project, tracks, clips, effects, transitions, caption cues, composition graphs, assets, data sets and markers); a `transaction` applies several and is checked once, by the document it ends with. A command the document's rules refuse returns `{ ok: false, error }` and changes nothing. `canExecute` asks without applying.
|
|
35
35
|
- Every change that commits is one undo step. The history keeps up to 120 steps and 64 MiB by default (`createEditor({ historyLimit, historyByteLimit })`).
|
|
36
36
|
- `beginGesture()` previews a drag: each `update(command)` shows a candidate in `editor.draft` without touching the document or the history, and `commit()` adds one undo step (`cancel()` adds none).
|
|
37
37
|
- `subscribe`, `getSnapshot` and `subscribeSelector` notify views of changes. A refusal is an `EditorError`, whose `code` says which check failed.
|
|
38
38
|
|
|
39
|
+
## Data sets
|
|
40
|
+
|
|
41
|
+
A project's data sets (tracking points, levels, words, intervals an extractor returned) are changed by commands, so adding one and binding to it is one undo step.
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
import { dataValue } from "@alpha2-sh/editor";
|
|
45
|
+
|
|
46
|
+
editor.dispatch({
|
|
47
|
+
type: "transaction",
|
|
48
|
+
commands: [
|
|
49
|
+
{ type: "data.put", dataSet: faceTrack }, // replaces the set with its id in place
|
|
50
|
+
{
|
|
51
|
+
type: "clip.update",
|
|
52
|
+
id: "title",
|
|
53
|
+
patch: { visual: { position: dataValue({ data: faceTrack.id, channel: "face", via: { clip: "interview" }, space: "canvas" }) } },
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
});
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
- `data.remove` is refused with `data_referenced` while anything reads the set; `error.details.references` lists the places (`dataReferences` from `alpha2/project` lists them for any project). `asset.remove`, `clip.delete` and `track.remove` are refused the same way while a data set is anchored to the source or a binding reads through the clip.
|
|
60
|
+
- Timeline commands keep data consistent as the engine's edit operations do: a ripple that reaches every track (every other track sync-locked) cuts or opens timeline-anchored sets with the timeline, a split points the right part's bindings that read through the clip at the new part, and a pasted clip's bindings through itself read through its new id. Source-anchored sets never change.
|
|
61
|
+
- Keyframe helpers throw `data_bound` on a value that follows data (`isDataBound`).
|
|
62
|
+
- A replaced set is held whole in the undo history, so a put of a set near `MAX_DATA_VALUES` can evict most of it under the 64 MiB default.
|
|
63
|
+
|
|
64
|
+
## Edit operations
|
|
65
|
+
|
|
66
|
+
The engine's edit operations (`remove_ranges`, `split_at`, `bake`) run in the runtime you already have; the session applies the result as one undo step, refusing it (`stale_edit`) when the document changed after the project was read.
|
|
67
|
+
|
|
68
|
+
```js
|
|
69
|
+
// Desktop: @alpha2-sh/node computes, no WebAssembly in the app.
|
|
70
|
+
const request = { op: "remove_ranges", ranges: { data: "silence" }, target: { track: "v1" } };
|
|
71
|
+
const { project, read } = editor.editProject();
|
|
72
|
+
const applied = await client.edit(project, request);
|
|
73
|
+
const result = editor.applyEdit(applied, { read, request }); // { document, report }
|
|
74
|
+
|
|
75
|
+
// Bake a binding and drop its data set in the same step.
|
|
76
|
+
editor.applyEdit(baked, { read, request: bakeRequest, then: [{ type: "data.remove", id: "face" }] });
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
- In a page, `bridge.applyEdit(request, { then, label })` does all of it with the bridge's own engine and waits for the engine to load.
|
|
80
|
+
- Refusals (`unknown_data`, `nothing_to_bake`, ...) come from the engine call itself. Clips the operation creates keep the editor metadata of the clip they were cut from (`report.created[].from`).
|
|
81
|
+
- A step applied with a label (by default the operation's name) shows it as `snapshot.undoLabel` and `snapshot.redoLabel`.
|
|
82
|
+
|
|
83
|
+
## Extraction
|
|
84
|
+
|
|
85
|
+
Extractors run in the runtime too; the session puts their data sets in as one undo step. A timeline-anchored result is refused (`stale_extraction`) when the timeline changed while the extractor ran; data put in between does not count.
|
|
86
|
+
|
|
87
|
+
```js
|
|
88
|
+
const { project, read } = editor.extractionProject();
|
|
89
|
+
const { dataSets } = await client.extract({ project, assets, request, plugin: { manifest, sha256 } });
|
|
90
|
+
editor.applyExtraction({ dataSets, timings: {} }, { read });
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
- In a page, `bridge.extract(run, { plugin, signal, onProgress })` reads the source's original media held by the bridge and resolves with `{ result, read }` for `applyExtraction`. It reads source input; timeline input is refused there.
|
|
94
|
+
- `bridge.conform()` lists data sets made from media that has since changed in `stale_data`; their `made_by` says how to run them again.
|
|
95
|
+
|
|
39
96
|
## Browser bridge
|
|
40
97
|
|
|
41
98
|
`@alpha2-sh/editor/browser` connects a session to the engine in the browser: import, preview, playback with audio, and export to an MP4, MOV, MKV or WebM file through WebCodecs.
|
|
@@ -83,8 +140,8 @@ await bridge.dispose();
|
|
|
83
140
|
await editor.dispose();
|
|
84
141
|
```
|
|
85
142
|
|
|
86
|
-
- Import checks each file with the engine (media, fonts, `.cube` LUTs, SRT and WebVTT captions through `importCaptions`) and adds it to the document in one undoable step. `importSequence` imports numbered PNG or OpenEXR files as one image sequence.
|
|
87
|
-
- `bindPreview` draws on a canvas. With `runtimeAssets.workerFactory`, a worker running the `@alpha2-sh/editor/preview-worker` entry renders the preview off the main thread; without one, or when the worker fails, the main thread does. `hashWorkerFactory` (`@alpha2-sh/editor/hash-worker`) and `extensionsWorkerFactory` (`@alpha2-sh/editor/extensions-worker`, with `extensionsWasmUrl`) move file hashing and SVG, animated image, Lottie and
|
|
143
|
+
- Import checks each file with the engine (media, fonts, `.cube` LUTs, SRT and WebVTT captions through `importCaptions`) and adds it to the document in one undoable step. `importSequence` imports numbered PNG or OpenEXR files as one image sequence. A source whose provider reads no file, such as a LaTeX formula (`{ format: "latex", latex, font_size }`), is kept in the project itself: `putProviderSource` adds or edits one in one undoable step, and it draws in preview and both exports with no file to relink.
|
|
144
|
+
- `bindPreview` draws on a canvas. With `runtimeAssets.workerFactory`, a worker running the `@alpha2-sh/editor/preview-worker` entry renders the preview off the main thread; without one, or when the worker fails, the main thread does. `hashWorkerFactory` (`@alpha2-sh/editor/hash-worker`) and `extensionsWorkerFactory` (`@alpha2-sh/editor/extensions-worker`, with `extensionsWasmUrl` and `extensionModuleUrls` such as `{ pdf }`) move file hashing and SVG, animated image, Lottie, OpenEXR and PDF reading into workers too.
|
|
88
145
|
- `seek`, `play` and `pause` move the playhead; with audio, playback follows the audio clock. Audio preview needs a cross-origin isolated page; editing and video preview do not.
|
|
89
146
|
- `startExport` returns a job with `result`, progress (`subscribe`) and `cancel`. `container` (`mp4` by default, `mov`, `mkv` or `webm`) names the file and decides the codecs: an absent `videoCodec` or `audioCodec` is the container's default (H.264 and AAC, or VP9 and Opus for WebM, with Opus where a browser cannot encode AAC in MP4 or MKV), and one the container does not offer is refused. The output goes to a temporary file in the origin's private storage by default (`release()` deletes it), to a file the user picked (`output: { kind: "file", handle }`), or to memory (`output: { kind: "memory", maxBytes }`). Whether the browser encodes a codec is the browser's to say: `bridge.videoEncoders()` asks ahead, and an export with a codec the browser does not encode is refused before it renders.
|
|
90
147
|
|
package/dist/browser/bridge.d.ts
CHANGED
|
@@ -5,13 +5,14 @@
|
|
|
5
5
|
* per file from `extensionsWorkerFactory` (terminated on cancel or past
|
|
6
6
|
* `EXTENSIONS_CALL_TIMEOUT_MS`), or on this thread without one. Fonts are checked with the engine's
|
|
7
7
|
* parser and also registered with the page's `FontFace` set. Content hashes run in a
|
|
8
|
-
* `hashWorkerFactory` worker when given. HDR video without planes
|
|
9
|
-
*
|
|
10
|
-
* @param {{ extensionsWasmUrl?: string | URL, wasmUrl?: string | URL, hashWorkerFactory?: () => Worker, extensionsWorkerFactory?: () => Worker, hdrWithoutPlanes?: "refuse" | "preview-degraded" }} [options]
|
|
8
|
+
* `hashWorkerFactory` worker when given. `hdrWithoutPlanes` says whether HDR video without planes
|
|
9
|
+
* imports degraded or is refused.
|
|
10
|
+
* @param {{ extensionsWasmUrl?: string | URL, extensionModuleUrls?: import("alpha2/extensions").ExtensionWasmUrls, wasmUrl?: string | URL, hashWorkerFactory?: () => Worker, extensionsWorkerFactory?: () => Worker, hdrWithoutPlanes?: "refuse" | "preview-degraded" }} [options]
|
|
11
11
|
* @returns {import("./types.js").BrowserMediaAdapter}
|
|
12
12
|
*/
|
|
13
|
-
export function createMediaAdapter({ extensionsWasmUrl, wasmUrl, hashWorkerFactory, extensionsWorkerFactory, hdrWithoutPlanes, }?: {
|
|
13
|
+
export function createMediaAdapter({ extensionsWasmUrl, extensionModuleUrls, wasmUrl, hashWorkerFactory, extensionsWorkerFactory, hdrWithoutPlanes, }?: {
|
|
14
14
|
extensionsWasmUrl?: string | URL;
|
|
15
|
+
extensionModuleUrls?: import("alpha2/extensions").ExtensionWasmUrls;
|
|
15
16
|
wasmUrl?: string | URL;
|
|
16
17
|
hashWorkerFactory?: () => Worker;
|
|
17
18
|
extensionsWorkerFactory?: () => Worker;
|