@motionscript/browser 0.1.0-alpha.7 → 0.1.0-alpha.9
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/CHANGELOG.md +12 -0
- package/LICENSE +201 -201
- package/NOTICE +49 -48
- package/README.md +141 -118
- package/dist/asset-bytes.d.ts +7 -4
- package/dist/asset-bytes.d.ts.map +1 -1
- package/dist/asset-bytes.js +9 -4
- package/dist/asset-bytes.js.map +1 -1
- package/dist/audio/bus-graph.d.ts.map +1 -1
- package/dist/audio/bus-graph.js +15 -6
- package/dist/audio/bus-graph.js.map +1 -1
- package/dist/audio/effect-graph.d.ts +62 -0
- package/dist/audio/effect-graph.d.ts.map +1 -0
- package/dist/audio/effect-graph.js +234 -0
- package/dist/audio/effect-graph.js.map +1 -0
- package/dist/audio/index.d.ts.map +1 -1
- package/dist/audio/index.js +2 -3
- package/dist/audio/index.js.map +1 -1
- package/dist/audio/loop-region.js.map +1 -1
- package/dist/audio/mixer.d.ts +4 -4
- package/dist/audio/mixer.d.ts.map +1 -1
- package/dist/audio/mixer.js +18 -38
- package/dist/audio/mixer.js.map +1 -1
- package/dist/audio/player.d.ts +12 -6
- package/dist/audio/player.d.ts.map +1 -1
- package/dist/audio/player.js +49 -62
- package/dist/audio/player.js.map +1 -1
- package/dist/browser/THIRD_PARTY_LICENSES.txt +379 -27
- package/dist/browser/audio.js +1 -1
- package/dist/browser/chunks/chunk-F3AZKPHU.js +2 -0
- package/dist/browser/chunks/chunk-F3AZKPHU.js.map +7 -0
- package/dist/browser/chunks/chunk-KLXMRKTL.js +2 -0
- package/dist/browser/chunks/chunk-L5UFQACH.js +163 -0
- package/dist/browser/chunks/chunk-L5UFQACH.js.map +7 -0
- package/dist/browser/chunks/mediabunny-mp3-encoder-ZCIHVVTJ.js +14 -0
- package/dist/browser/chunks/mediabunny-mp3-encoder-ZCIHVVTJ.js.map +7 -0
- package/dist/browser/index.js +51 -1343
- package/dist/browser/index.js.map +4 -4
- package/dist/browser/manifest.json +8 -8
- package/dist/browser/ms_renderer_bg.wasm +0 -0
- package/dist/concat.d.ts +33 -7
- package/dist/concat.d.ts.map +1 -1
- package/dist/concat.js +117 -72
- package/dist/concat.js.map +1 -1
- package/dist/deliver.d.ts +10 -0
- package/dist/deliver.d.ts.map +1 -0
- package/dist/deliver.js +22 -0
- package/dist/deliver.js.map +1 -0
- package/dist/dynamic-nodes.d.ts.map +1 -1
- package/dist/dynamic-nodes.js +2 -3
- package/dist/dynamic-nodes.js.map +1 -1
- package/dist/engine.d.ts +37 -9
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +41 -32
- package/dist/engine.js.map +1 -1
- package/dist/export-audio.d.ts +36 -0
- package/dist/export-audio.d.ts.map +1 -0
- package/dist/export-audio.js +56 -0
- package/dist/export-audio.js.map +1 -0
- package/dist/exporter.d.ts +125 -14
- package/dist/exporter.d.ts.map +1 -1
- package/dist/exporter.js +133 -89
- package/dist/exporter.js.map +1 -1
- package/dist/formats.d.ts +36 -0
- package/dist/formats.d.ts.map +1 -0
- package/dist/formats.js +83 -0
- package/dist/formats.js.map +1 -0
- package/dist/frame-loop.d.ts +190 -0
- package/dist/frame-loop.d.ts.map +1 -0
- package/dist/frame-loop.js +304 -0
- package/dist/frame-loop.js.map +1 -0
- package/dist/index.d.ts +12 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -21
- package/dist/index.js.map +1 -1
- package/dist/mix-timeline-audio.d.ts +5 -5
- package/dist/mix-timeline-audio.d.ts.map +1 -1
- package/dist/mix-timeline-audio.js +10 -12
- package/dist/mix-timeline-audio.js.map +1 -1
- package/dist/parallel/export-parallel.d.ts +32 -0
- package/dist/parallel/export-parallel.d.ts.map +1 -0
- package/dist/parallel/export-parallel.js +114 -0
- package/dist/parallel/export-parallel.js.map +1 -0
- package/dist/parallel/governor.d.ts +57 -0
- package/dist/parallel/governor.d.ts.map +1 -0
- package/dist/parallel/governor.js +79 -0
- package/dist/parallel/governor.js.map +1 -0
- package/dist/parallel/lane.d.ts +45 -0
- package/dist/parallel/lane.d.ts.map +1 -0
- package/dist/parallel/lane.js +2 -0
- package/dist/parallel/lane.js.map +1 -0
- package/dist/parallel/lanes.d.ts +20 -0
- package/dist/parallel/lanes.d.ts.map +1 -0
- package/dist/parallel/lanes.js +152 -0
- package/dist/parallel/lanes.js.map +1 -0
- package/dist/parallel/plan.d.ts +23 -0
- package/dist/parallel/plan.d.ts.map +1 -0
- package/dist/parallel/plan.js +30 -0
- package/dist/parallel/plan.js.map +1 -0
- package/dist/parallel/run-lanes.d.ts +38 -0
- package/dist/parallel/run-lanes.d.ts.map +1 -0
- package/dist/parallel/run-lanes.js +164 -0
- package/dist/parallel/run-lanes.js.map +1 -0
- package/dist/parallel/session.d.ts +9 -0
- package/dist/parallel/session.d.ts.map +1 -0
- package/dist/parallel/session.js +79 -0
- package/dist/parallel/session.js.map +1 -0
- package/dist/renderer.d.ts +22 -0
- package/dist/renderer.d.ts.map +1 -0
- package/dist/renderer.js +23 -0
- package/dist/renderer.js.map +1 -0
- package/dist/screenshot.d.ts +4 -4
- package/dist/screenshot.d.ts.map +1 -1
- package/dist/screenshot.js +3 -3
- package/dist/screenshot.js.map +1 -1
- package/dist/still.d.ts +17 -19
- package/dist/still.d.ts.map +1 -1
- package/dist/still.js +27 -34
- package/dist/still.js.map +1 -1
- package/dist/ticker.d.ts +22 -8
- package/dist/ticker.d.ts.map +1 -1
- package/dist/ticker.js +55 -20
- package/dist/ticker.js.map +1 -1
- package/package.json +9 -10
- package/dist/audio/filter-graph.d.ts +0 -59
- package/dist/audio/filter-graph.d.ts.map +0 -1
- package/dist/audio/filter-graph.js +0 -241
- package/dist/audio/filter-graph.js.map +0 -1
- package/dist/browser/chunks/GLTFLoader-PGXD4V5B.js +0 -2
- package/dist/browser/chunks/GLTFLoader-PGXD4V5B.js.map +0 -7
- package/dist/browser/chunks/SkeletonUtils-XYDMTGTM.js +0 -2
- package/dist/browser/chunks/chunk-2MAFJWBZ.js +0 -2
- package/dist/browser/chunks/chunk-2MAFJWBZ.js.map +0 -7
- package/dist/browser/chunks/chunk-CTLBXZSU.js +0 -4119
- package/dist/browser/chunks/chunk-CTLBXZSU.js.map +0 -7
- package/dist/browser/chunks/chunk-FQ32PDIU.js +0 -2
- package/dist/browser/chunks/chunk-FQ32PDIU.js.map +0 -7
- package/dist/browser/chunks/chunk-FY3BTKY4.js +0 -2
- package/dist/browser/chunks/chunk-FY3BTKY4.js.map +0 -7
- package/dist/browser/chunks/three.module-Z4EOVUWF.js +0 -2
- package/dist/browser/chunks/three.module-Z4EOVUWF.js.map +0 -7
- package/dist/decode/image-levels.d.ts +0 -137
- package/dist/decode/image-levels.d.ts.map +0 -1
- package/dist/decode/image-levels.js +0 -477
- package/dist/decode/image-levels.js.map +0 -1
- package/dist/decode/levels.d.ts +0 -37
- package/dist/decode/levels.d.ts.map +0 -1
- package/dist/decode/levels.js +0 -68
- package/dist/decode/levels.js.map +0 -1
- package/dist/decode/video-levels.d.ts +0 -37
- package/dist/decode/video-levels.d.ts.map +0 -1
- package/dist/decode/video-levels.js +0 -95
- package/dist/decode/video-levels.js.map +0 -1
- package/dist/getter.d.ts +0 -10
- package/dist/getter.d.ts.map +0 -1
- package/dist/getter.js +0 -38
- package/dist/getter.js.map +0 -1
- package/dist/measure-context.d.ts +0 -12
- package/dist/measure-context.d.ts.map +0 -1
- package/dist/measure-context.js +0 -12
- package/dist/measure-context.js.map +0 -1
- package/dist/render-context.d.ts +0 -32
- package/dist/render-context.d.ts.map +0 -1
- package/dist/render-context.js +0 -59
- package/dist/render-context.js.map +0 -1
- package/dist/storage-adapter.d.ts +0 -367
- package/dist/storage-adapter.d.ts.map +0 -1
- package/dist/storage-adapter.js +0 -1280
- package/dist/storage-adapter.js.map +0 -1
- package/dist/three/renderer.d.ts +0 -47
- package/dist/three/renderer.d.ts.map +0 -1
- package/dist/three/renderer.js +0 -182
- package/dist/three/renderer.js.map +0 -1
- /package/dist/browser/chunks/{SkeletonUtils-XYDMTGTM.js.map → chunk-KLXMRKTL.js.map} +0 -0
package/dist/engine.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Engine, } from "@motionscript/core";
|
|
2
|
-
import {
|
|
2
|
+
import { loadRenderer } from "./renderer";
|
|
3
3
|
import { resolveDynamicNodes } from "./dynamic-nodes";
|
|
4
4
|
import { WebAudioSink } from "./audio/player";
|
|
5
5
|
import { WebTicker } from "./ticker";
|
|
6
|
-
import { WebMeasureContext } from "./measure-context";
|
|
7
|
-
import { WebRenderContext } from "./render-context";
|
|
8
|
-
import { WebStorageAdapter } from "./storage-adapter";
|
|
9
6
|
import { exportVideo as exportVideoFile } from "./exporter";
|
|
7
|
+
import { exportAudio } from "./export-audio";
|
|
8
|
+
import { isAudioFormat } from "./formats";
|
|
10
9
|
import { StillRenderer } from "./still";
|
|
11
10
|
/**
|
|
12
11
|
* The browser's {@link Exporter}: WebCodecs + mediabunny for video, the
|
|
@@ -16,24 +15,36 @@ import { StillRenderer } from "./still";
|
|
|
16
15
|
* adapter's viewport clamps the resolution images decode at — `StorageAdapter`
|
|
17
16
|
* documents that it has no setter for exactly this reason — so handing an export
|
|
18
17
|
* the preview's adapter would paint a 2× render from decodes sized for 1×, and
|
|
19
|
-
* the result would be soft in a way nothing reports. What is
|
|
20
|
-
*
|
|
18
|
+
* the result would be soft in a way nothing reports. What is shared is the
|
|
19
|
+
* engine's renderer backend, the same one its sessions draw with.
|
|
21
20
|
*/
|
|
22
21
|
class WebExporter {
|
|
23
|
-
|
|
22
|
+
backend;
|
|
24
23
|
defaults;
|
|
25
|
-
wasmUrl;
|
|
26
24
|
still = null;
|
|
27
25
|
stillRegistry = null;
|
|
28
26
|
/** Settles once every still asked for so far has been encoded. */
|
|
29
27
|
stillQueue = Promise.resolve();
|
|
30
|
-
constructor(
|
|
31
|
-
this.
|
|
28
|
+
constructor(backend, defaults) {
|
|
29
|
+
this.backend = backend;
|
|
32
30
|
this.defaults = defaults;
|
|
33
|
-
this.wasmUrl = wasmUrl;
|
|
34
31
|
}
|
|
35
32
|
async exportVideo(request) {
|
|
36
33
|
const encode = (request.encode ?? {});
|
|
34
|
+
if (encode.format && isAudioFormat(encode.format)) {
|
|
35
|
+
return exportAudio({
|
|
36
|
+
document: request.project,
|
|
37
|
+
registry: request.registry,
|
|
38
|
+
manifest: request.manifest,
|
|
39
|
+
format: encode.format,
|
|
40
|
+
audio: encode.audio ?? this.defaults.audio,
|
|
41
|
+
filename: encode.filename,
|
|
42
|
+
returnBytes: encode.download !== true,
|
|
43
|
+
onProgress: request.onProgress,
|
|
44
|
+
signal: request.signal,
|
|
45
|
+
rendererWasmUrl: this.defaults.rendererWasmUrl,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
37
48
|
return exportVideoFile({
|
|
38
49
|
document: request.project,
|
|
39
50
|
registry: request.registry,
|
|
@@ -41,6 +52,7 @@ class WebExporter {
|
|
|
41
52
|
manifest: request.manifest,
|
|
42
53
|
includeAudio: request.includeAudio,
|
|
43
54
|
frames: request.frames,
|
|
55
|
+
format: encode.format,
|
|
44
56
|
video: encode.video ?? this.defaults.video,
|
|
45
57
|
audio: encode.audio ?? this.defaults.audio,
|
|
46
58
|
supersample: encode.supersample,
|
|
@@ -49,13 +61,14 @@ class WebExporter {
|
|
|
49
61
|
// the DOM anchor path this function offers a page.
|
|
50
62
|
returnBytes: encode.download !== true,
|
|
51
63
|
onProgress: request.onProgress,
|
|
64
|
+
onIssue: request.onIssue,
|
|
52
65
|
signal: request.signal,
|
|
53
|
-
|
|
66
|
+
rendererWasmUrl: this.defaults.rendererWasmUrl,
|
|
54
67
|
});
|
|
55
68
|
}
|
|
56
69
|
/**
|
|
57
70
|
* Queued, rather than a renderer per call: the one renderer is what keeps a
|
|
58
|
-
*
|
|
71
|
+
* GPU surface and the decode cache warm between stills, and its draw and the
|
|
59
72
|
* encode of it are two steps another call's draw would land between.
|
|
60
73
|
*/
|
|
61
74
|
exportStill(request) {
|
|
@@ -71,6 +84,7 @@ class WebExporter {
|
|
|
71
84
|
const renderer = this.renderer(request);
|
|
72
85
|
const drawn = await renderer.render(request.project, {
|
|
73
86
|
scale: request.scale,
|
|
87
|
+
onIssue: request.onIssue,
|
|
74
88
|
...frameOption(request.frame),
|
|
75
89
|
});
|
|
76
90
|
const bytes = await renderer.toBytes({
|
|
@@ -92,7 +106,7 @@ class WebExporter {
|
|
|
92
106
|
// A renderer compiles against the registry it was built with.
|
|
93
107
|
if (this.still && this.stillRegistry !== registry)
|
|
94
108
|
this.dispose();
|
|
95
|
-
this.still ??= new StillRenderer(this.
|
|
109
|
+
this.still ??= new StillRenderer(this.backend, {
|
|
96
110
|
viewport: project.viewport,
|
|
97
111
|
fps: project.fps,
|
|
98
112
|
manifest: request.manifest,
|
|
@@ -112,9 +126,10 @@ function frameOption(frame) {
|
|
|
112
126
|
return { frame: frame.kind };
|
|
113
127
|
}
|
|
114
128
|
/**
|
|
115
|
-
* An engine backed by the browser:
|
|
129
|
+
* An engine backed by the browser: WebGPU surfaces, Web Audio, WebCodecs.
|
|
130
|
+
* Rejects with `WebGpuUnavailableError` where this browser has no WebGPU adapter.
|
|
116
131
|
*
|
|
117
|
-
* Async because
|
|
132
|
+
* Async because the renderer is a wasm module and every seam below needs it. Await
|
|
118
133
|
* once, at app start, and share the result — the caches underneath (registered
|
|
119
134
|
* fonts, decoded images, shaped paragraphs) are the point of keeping one engine
|
|
120
135
|
* rather than one per canvas.
|
|
@@ -142,35 +157,29 @@ export async function createBrowserEngine(options = {}) {
|
|
|
142
157
|
// `engine.registerNode(source)` works even when `nodes` carried no
|
|
143
158
|
// string at boot.
|
|
144
159
|
const dynamicNodes = resolveDynamicNodes(options.dynamicNodes, options.compilerWasmUrl);
|
|
145
|
-
const
|
|
146
|
-
const exporter = new WebExporter(
|
|
160
|
+
const renderer = await loadRenderer(options);
|
|
161
|
+
const exporter = new WebExporter(renderer, { video: options.video, audio: options.audio, rendererWasmUrl: options.rendererWasmUrl });
|
|
147
162
|
const platform = {
|
|
148
|
-
createStorageAdapter(
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
createRenderContext(storage) {
|
|
152
|
-
return new WebRenderContext(canvasKit, storage);
|
|
153
|
-
},
|
|
154
|
-
createMeasureContext(storage) {
|
|
155
|
-
return new WebMeasureContext(storage);
|
|
156
|
-
},
|
|
163
|
+
createStorageAdapter: (deps) => renderer.createStorageAdapter(deps),
|
|
164
|
+
createRenderContext: (storage) => renderer.createRenderContext(storage),
|
|
165
|
+
createMeasureContext: (storage) => renderer.createMeasureContext(storage),
|
|
157
166
|
createAudioSink() {
|
|
158
167
|
return new WebAudioSink();
|
|
159
168
|
},
|
|
160
169
|
createTicker(fps, audioDevice) {
|
|
161
170
|
// Shares the device's own `AudioContext`: two independent timebases
|
|
162
171
|
// in one session drift against each other, and sound is the one that
|
|
163
|
-
// cannot be nudged back.
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
});
|
|
172
|
+
// cannot be nudged back. A getter, so neither creates it before it
|
|
173
|
+
// is needed (the first play, or the first sound to decode).
|
|
174
|
+
const sink = audioDevice;
|
|
175
|
+
return new WebTicker({ context: () => sink.getContext(), fps });
|
|
168
176
|
},
|
|
169
177
|
createExporter() {
|
|
170
178
|
return exporter;
|
|
171
179
|
},
|
|
172
180
|
dispose() {
|
|
173
181
|
exporter.dispose();
|
|
182
|
+
renderer.dispose?.();
|
|
174
183
|
},
|
|
175
184
|
};
|
|
176
185
|
const engine = new Engine(platform, { ...options, nodes: classNodes, dynamicNodes });
|
package/dist/engine.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AACA,OAAO,EAEH,MAAM,GAeT,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OA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QACD,eAAe;YACX,OAAO,IAAI,YAAY,EAAE,CAAC;QAC9B,CAAC;QACD,YAAY,CAAC,GAAW,EAAE,WAAsB;YAC5C,oEAAoE;YACpE,qEAAqE;YACrE,yBAAyB;YACzB,OAAO,IAAI,SAAS,CAAC;gBACjB,OAAO,EAAG,WAA4B,CAAC,UAAU,EAAE;gBACnD,GAAG;aACN,CAAC,CAAC;QACP,CAAC;QACD,cAAc;YACV,OAAO,QAAQ,CAAC;QACpB,CAAC;QACD,OAAO;YACH,QAAQ,CAAC,OAAO,EAAE,CAAC;QACvB,CAAC;KACJ,CAAC;IAEF,MAAM,MAAM,GAAG,IAAI,MAAM,CAAoB,QAAQ,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC,CAAC;IACxG,KAAK,MAAM,MAAM,IAAI,WAAW,EAAE,CAAC;QAC/B,gEAAgE;QAChE,+DAA+D;QAC/D,MAAM,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import type { CanvasKit } from \"@motionscript/canvaskit\";\r\nimport {\r\n AudioSink,\r\n Engine,\r\n EngineOptions,\r\n EnginePlatform,\r\n EngineRenderContext,\r\n Exporter,\r\n ExportStillRequest,\r\n ExportVideoRequest,\r\n ExportedStill,\r\n Registry,\r\n Ticker,\r\n MeasureContext2D,\r\n PlatformDeps,\r\n type DynamicNodeConfig,\r\n type NodeConstructor,\r\n type NodeTypeMap,\r\n} from \"@motionscript/core\";\r\n\r\nimport { getCanvasKit } from \"./getter\";\r\nimport { resolveDynamicNodes } from \"./dynamic-nodes\";\r\nimport { WebAudioSink } from \"./audio/player\";\r\nimport { WebTicker } from \"./ticker\";\r\nimport { WebMeasureContext } from \"./measure-context\";\r\nimport { WebRenderContext } from \"./render-context\";\r\nimport { WebStorageAdapter } from \"./storage-adapter\";\r\nimport { exportVideo as exportVideoFile, type AudioEncoderOptions, type VideoEncoderOptions } from \"./exporter\";\r\nimport { StillRenderer } from \"./still\";\r\n\r\nexport interface BrowserEngineOptions extends Omit<EngineOptions, \"nodes\" | \"dynamicNodes\"> {\r\n /**\r\n * Node types any document opened here may name — components as an array\r\n * or a record naming each key outright, same as `EngineOptions`, plus a\r\n * TS source string in the **array** form only. A string default-exports a\r\n * component, whose `key` is its key — the record form takes no string, so\r\n * there is exactly one place a dynamic node's key comes from, not two that\r\n * could disagree.\r\n */\r\n nodes?: readonly (NodeConstructor | string)[] | NodeTypeMap;\r\n /**\r\n * Enables a source string in `nodes`, and `engine.registerNode(source)`\r\n * at any point afterward. Any field left unset falls back to `browser`'s\r\n * own default — `@motionscript/core/sdk` for `sdk`, a lazily-loaded\r\n * `esbuild-wasm` for `compile` — so this never needs to be passed at all\r\n * for the common case. `modules` has no default: only the host knows\r\n * which loaded packages a script it compiles may reach.\r\n */\r\n dynamicNodes?: Partial<DynamicNodeConfig>;\r\n /**\r\n * Where `esbuild-wasm`'s own `.wasm` binary is served — only read if the\r\n * default compiler is actually used. Mirrors `wasmUrl` for CanvasKit.\r\n */\r\n compilerWasmUrl?: string;\r\n /** URL of the CanvasKit `.wasm` binary, forwarded to `getCanvasKit`. */\r\n wasmUrl?: string;\r\n /** Default video encoder settings for `session.export()`. Overridable per call. */\r\n video?: VideoEncoderOptions;\r\n /** Default audio encoder settings for `session.export()`. Overridable per call. */\r\n audio?: AudioEncoderOptions;\r\n}\r\n\r\n/** What `session.export({ encode })` accepts in this environment. */\r\nexport interface BrowserEncodeOptions {\r\n video?: VideoEncoderOptions;\r\n audio?: AudioEncoderOptions;\r\n supersample?: number;\r\n /** Set false to get the bytes back instead of triggering a browser download. */\r\n download?: boolean;\r\n filename?: string;\r\n}\r\n\r\n/**\r\n * The browser's {@link Exporter}: WebCodecs + mediabunny for video, the\r\n * browser's own image codecs for a still.\r\n *\r\n * **It does not reuse a session's storage adapter, and that is deliberate.** An\r\n * adapter's viewport clamps the resolution images decode at — `StorageAdapter`\r\n * documents that it has no setter for exactly this reason — so handing an export\r\n * the preview's adapter would paint a 2× render from decodes sized for 1×, and\r\n * the result would be soft in a way nothing reports. What is safely shared is\r\n * CanvasKit itself, which `getCanvasKit` already memoizes process-wide.\r\n */\r\nclass WebExporter implements Exporter {\r\n private still: StillRenderer | null = null;\r\n private stillRegistry: Registry | null = null;\r\n /** Settles once every still asked for so far has been encoded. */\r\n private stillQueue: Promise<unknown> = Promise.resolve();\r\n\r\n constructor(\r\n private readonly canvasKit: CanvasKit,\r\n private readonly defaults: { video?: VideoEncoderOptions; audio?: AudioEncoderOptions },\r\n private readonly wasmUrl?: string,\r\n ) { }\r\n\r\n async exportVideo(request: ExportVideoRequest): Promise<Uint8Array | void> {\r\n const encode = (request.encode ?? {}) as BrowserEncodeOptions;\r\n return exportVideoFile({\r\n document: request.project,\r\n registry: request.registry,\r\n scale: request.scale,\r\n manifest: request.manifest,\r\n includeAudio: request.includeAudio,\r\n frames: request.frames,\r\n video: encode.video ?? this.defaults.video,\r\n audio: encode.audio ?? this.defaults.audio,\r\n supersample: encode.supersample,\r\n filename: encode.filename,\r\n // A `Session` asks for bytes; only an explicit `download: true` takes\r\n // the DOM anchor path this function offers a page.\r\n returnBytes: encode.download !== true,\r\n onProgress: request.onProgress,\r\n signal: request.signal,\r\n wasmUrl: this.wasmUrl,\r\n });\r\n }\r\n\r\n /**\r\n * Queued, rather than a renderer per call: the one renderer is what keeps a\r\n * GL context and the decode cache warm between stills, and its draw and the\r\n * encode of it are two steps another call's draw would land between.\r\n */\r\n exportStill(request: ExportStillRequest): Promise<ExportedStill> {\r\n const still = this.stillQueue.then(() => this.drawStill(request));\r\n this.stillQueue = still.catch(() => undefined);\r\n return still;\r\n }\r\n\r\n dispose(): void {\r\n this.still?.dispose();\r\n this.still = null;\r\n }\r\n\r\n private async drawStill(request: ExportStillRequest): Promise<ExportedStill> {\r\n const renderer = this.renderer(request);\r\n const drawn = await renderer.render(request.project, {\r\n scale: request.scale,\r\n ...frameOption(request.frame),\r\n });\r\n const bytes = await renderer.toBytes({\r\n format: request.format,\r\n quality: request.quality,\r\n });\r\n return { bytes, frame: drawn.frame, totalFrames: drawn.totalFrames };\r\n }\r\n\r\n /**\r\n * One `StillRenderer`, reused across calls and re-viewported when the ask\r\n * changes — `setViewport` is a no-op when the size already matches, and a\r\n * full reset when it does not, which is the same trade the class documents.\r\n */\r\n private renderer(request: ExportStillRequest): StillRenderer {\r\n const { project, registry } = request;\r\n if (project.viewport === undefined || project.fps === undefined) {\r\n throw new Error(\"exportStill takes a project whose fps and viewport are resolved — see Session.\");\r\n }\r\n // A renderer compiles against the registry it was built with.\r\n if (this.still && this.stillRegistry !== registry) this.dispose();\r\n this.still ??= new StillRenderer(this.canvasKit, {\r\n viewport: project.viewport,\r\n fps: project.fps,\r\n manifest: request.manifest,\r\n registry,\r\n });\r\n this.stillRegistry = registry;\r\n this.still.setViewport(project.viewport);\r\n if (request.manifest) this.still.setManifest(request.manifest);\r\n return this.still;\r\n }\r\n}\r\n\r\n/** `ExportStillRequest.frame` in the shape `StillRenderer.render` accepts. */\r\nfunction frameOption(frame: ExportStillRequest[\"frame\"]): { frame?: number | \"first\" | \"last\" } {\r\n if (frame.kind === \"frame\") return { frame: frame.frame };\r\n return { frame: frame.kind };\r\n}\r\n\r\n/**\r\n * An engine backed by the browser: WebGL/Skia surfaces, Web Audio, WebCodecs.\r\n *\r\n * Async because CanvasKit is a wasm module and every seam below needs it. Await\r\n * once, at app start, and share the result — the caches underneath (registered\r\n * fonts, decoded images, shaped paragraphs) are the point of keeping one engine\r\n * rather than one per canvas.\r\n *\r\n * ```ts\r\n * const engine = await createBrowserEngine({ nodes: { pulseRing: PulseRing } });\r\n * const session = engine.open({ document, target: canvasEl });\r\n * session.playback!.play();\r\n * ```\r\n */\r\nexport async function createBrowserEngine(\r\n options: BrowserEngineOptions = {},\r\n): Promise<Engine<WebStorageAdapter>> {\r\n const rawNodes = options.nodes;\r\n // `Array.isArray` doesn't narrow a `readonly T[] | U` union cleanly against\r\n // its `arg is any[]` (mutable) predicate — the `.filter` predicate below\r\n // already guarantees no string survives, so the cast is just recovering\r\n // what the runtime check already proved.\r\n const classNodes = (\r\n Array.isArray(rawNodes)\r\n ? rawNodes.filter((n): n is NodeConstructor => typeof n !== \"string\")\r\n : rawNodes\r\n ) as NodeTypeMap | readonly NodeConstructor[] | undefined;\r\n const sourceNodes = Array.isArray(rawNodes)\r\n ? rawNodes.filter((n): n is string => typeof n === \"string\")\r\n : [];\r\n // Cheap — see dynamic-nodes.ts: no WASM import happens here, only on\r\n // `compile`'s first actual call. Attached unconditionally so a later\r\n // `engine.registerNode(source)` works even when `nodes` carried no\r\n // string at boot.\r\n const dynamicNodes = resolveDynamicNodes(options.dynamicNodes, options.compilerWasmUrl);\r\n\r\n const canvasKit = await getCanvasKit(options.wasmUrl);\r\n const exporter = new WebExporter(\r\n canvasKit,\r\n { video: options.video, audio: options.audio },\r\n options.wasmUrl,\r\n );\r\n\r\n const platform: EnginePlatform<WebStorageAdapter> = {\r\n createStorageAdapter({ catalog, viewport, fps }: PlatformDeps): WebStorageAdapter {\r\n return new WebStorageAdapter(canvasKit, catalog, viewport, fps);\r\n },\r\n createRenderContext(storage: WebStorageAdapter): EngineRenderContext {\r\n return new WebRenderContext(canvasKit, storage);\r\n },\r\n createMeasureContext(storage: WebStorageAdapter): MeasureContext2D {\r\n return new WebMeasureContext(storage);\r\n },\r\n createAudioSink(): AudioSink {\r\n return new WebAudioSink();\r\n },\r\n createTicker(fps: number, audioDevice: AudioSink): Ticker {\r\n // Shares the device's own `AudioContext`: two independent timebases\r\n // in one session drift against each other, and sound is the one that\r\n // cannot be nudged back.\r\n return new WebTicker({\r\n context: (audioDevice as WebAudioSink).getContext(),\r\n fps,\r\n });\r\n },\r\n createExporter(): Exporter {\r\n return exporter;\r\n },\r\n dispose(): void {\r\n exporter.dispose();\r\n },\r\n };\r\n\r\n const engine = new Engine<WebStorageAdapter>(platform, { ...options, nodes: classNodes, dynamicNodes });\r\n for (const source of sourceNodes) {\r\n // Sequential — one script's error shouldn't mask another's, and\r\n // registration order should match array order for determinism.\r\n await engine.registerNode(source);\r\n }\r\n return engine;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,MAAM,GAgBT,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,YAAY,EAA2B,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,WAAW,IAAI,eAAe,EAAsD,MAAM,YAAY,CAAC;AAChH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAqB,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAuExC;;;;;;;;;;GAUG;AACH,MAAM,WAAW;IAOQ;IACA;IAPb,KAAK,GAAyB,IAAI,CAAC;IACnC,aAAa,GAAoB,IAAI,CAAC;IAC9C,kEAAkE;IAC1D,UAAU,GAAqB,OAAO,CAAC,OAAO,EAAE,CAAC;IAEzD,YACqB,OAAwB,EACxB,QAA2F;QAD3F,YAAO,GAAP,OAAO,CAAiB;QACxB,aAAQ,GAAR,QAAQ,CAAmF;IAC5G,CAAC;IAEL,KAAK,CAAC,WAAW,CAAC,OAA2B;QACzC,MAAM,MAAM,GAAG,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAyB,CAAC;QAC9D,IAAI,MAAM,CAAC,MAAM,IAAI,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YAChD,OAAO,WAAW,CAAC;gBACf,QAAQ,EAAE,OAAO,CAAC,OAAO;gBACzB,Q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AO,QAAQ,CAAC;QACpB,CAAC;QACD,OAAO;YACH,QAAQ,CAAC,OAAO,EAAE,CAAC;YACnB,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC;QACzB,CAAC;KACJ,CAAC;IAEF,MAAM,MAAM,GAAG,IAAI,MAAM,CAAqB,QAAQ,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC,CAAC;IACzG,KAAK,MAAM,MAAM,IAAI,WAAW,EAAE,CAAC;QAC/B,gEAAgE;QAChE,+DAA+D;QAC/D,MAAM,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import {\n AudioSink,\n Engine,\n EngineOptions,\n EnginePlatform,\n EngineRenderContext,\n Exporter,\n ExportStillRequest,\n ExportVideoRequest,\n ExportedStill,\n Registry,\n Ticker,\n MeasureContext2D,\n PlatformDeps,\n StorageAdapter,\n type DynamicNodeConfig,\n type NodeConstructor,\n type NodeTypeMap,\n} from \"@motionscript/core\";\n\nimport type { WgpuStorageAdapter } from \"@motionscript/renderer\";\nimport { loadRenderer, type RendererWasmOption } from \"./renderer\";\nimport { resolveDynamicNodes } from \"./dynamic-nodes\";\nimport { WebAudioSink } from \"./audio/player\";\nimport { WebTicker } from \"./ticker\";\nimport { exportVideo as exportVideoFile, type AudioEncoderOptions, type VideoEncoderOptions } from \"./exporter\";\nimport { exportAudio } from \"./export-audio\";\nimport { isAudioFormat, type ExportFormat } from \"./formats\";\nimport { StillRenderer } from \"./still\";\n\nexport interface BrowserEngineOptions extends Omit<EngineOptions, \"nodes\" | \"dynamicNodes\">, RendererWasmOption {\n /**\n * Node types any document opened here may name — components as an array\n * or a record naming each key outright, same as `EngineOptions`, plus a\n * TS source string in the **array** form only. A string default-exports a\n * component, whose `key` is its key — the record form takes no string, so\n * there is exactly one place a dynamic node's key comes from, not two that\n * could disagree.\n */\n nodes?: readonly (NodeConstructor | string)[] | NodeTypeMap;\n /**\n * Enables a source string in `nodes`, and `engine.registerNode(source)`\n * at any point afterward. Any field left unset falls back to `browser`'s\n * own default — `@motionscript/core/sdk` for `sdk`, a lazily-loaded\n * `esbuild-wasm` for `compile` — so this never needs to be passed at all\n * for the common case. `modules` has no default: only the host knows\n * which loaded packages a script it compiles may reach.\n */\n dynamicNodes?: Partial<DynamicNodeConfig>;\n /**\n * Where `esbuild-wasm`'s own `.wasm` binary is served — only read if the\n * default compiler is actually used.\n */\n compilerWasmUrl?: string;\n /** Default video encoder settings for `session.export()`. Overridable per call. */\n video?: VideoEncoderOptions;\n /** Default audio encoder settings for `session.export()`. Overridable per call. */\n audio?: AudioEncoderOptions;\n}\n\n/** What a session's frames are drawn with, and the storage and measurement it reads from. */\nexport interface BrowserRenderer<TStorage extends StorageAdapter = StorageAdapter> {\n createStorageAdapter(deps: PlatformDeps): TStorage;\n createRenderContext(storage: TStorage): BrowserRenderContext;\n createMeasureContext(storage: TStorage): MeasureContext2D;\n dispose?(): void;\n}\n\n/** A render context as this package drives it: an engine one, plus what exports and stills ask of it. */\nexport type BrowserRenderContext = EngineRenderContext & {\n /**\n * Settles once the surface `mount` began can draw. A backend whose surface\n * comes up asynchronously (a GPU device) must have it, or the first frame\n * draws onto nothing.\n */\n whenMounted?(): Promise<void>;\n /**\n * The frame last drawn, copied into a fresh 2D canvas, or `undefined` before\n * one was. What a still encodes; a WebGPU canvas is readable only in the task\n * that drew it, so a backend may draw it again here.\n */\n snapshotCanvas?(): HTMLCanvasElement | undefined;\n};\n\n/** What `session.export({ encode })` accepts in this environment. */\nexport interface BrowserEncodeOptions {\n /**\n * Defaults to `'mp4'`. An audio format (`'wav'`, `'mp3'`, `'m4a'`) renders no\n * frames and ignores `scale`, `frames`, `includeAudio`, `video` and `supersample`.\n */\n format?: ExportFormat;\n video?: VideoEncoderOptions;\n audio?: AudioEncoderOptions;\n supersample?: number;\n /** Set false to get the bytes back instead of triggering a browser download. */\n download?: boolean;\n filename?: string;\n}\n\n/**\n * The browser's {@link Exporter}: WebCodecs + mediabunny for video, the\n * browser's own image codecs for a still.\n *\n * **It does not reuse a session's storage adapter, and that is deliberate.** An\n * adapter's viewport clamps the resolution images decode at — `StorageAdapter`\n * documents that it has no setter for exactly this reason — so handing an export\n * the preview's adapter would paint a 2× render from decodes sized for 1×, and\n * the result would be soft in a way nothing reports. What is shared is the\n * engine's renderer backend, the same one its sessions draw with.\n */\nclass WebExporter implements Exporter {\n private still: StillRenderer | null = null;\n private stillRegistry: Registry | null = null;\n /** Settles once every still asked for so far has been encoded. */\n private stillQueue: Promise<unknown> = Promise.resolve();\n\n constructor(\n private readonly backend: BrowserRenderer,\n private readonly defaults: { video?: VideoEncoderOptions; audio?: AudioEncoderOptions } & RendererWasmOption,\n ) { }\n\n async exportVideo(request: ExportVideoRequest): Promise<Uint8Array | void> {\n const encode = (request.encode ?? {}) as BrowserEncodeOptions;\n if (encode.format && isAudioFormat(encode.format)) {\n return exportAudio({\n document: request.project,\n registry: request.registry,\n manifest: request.manifest,\n format: encode.format,\n audio: encode.audio ?? this.defaults.audio,\n filename: encode.filename,\n returnBytes: encode.download !== true,\n onProgress: request.onProgress,\n signal: request.signal,\n rendererWasmUrl: this.defaults.rendererWasmUrl,\n });\n }\n return exportVideoFile({\n document: request.project,\n registry: request.registry,\n scale: request.scale,\n manifest: request.manifest,\n includeAudio: request.includeAudio,\n frames: request.frames,\n format: encode.format,\n video: encode.video ?? this.defaults.video,\n audio: encode.audio ?? this.defaults.audio,\n supersample: encode.supersample,\n filename: encode.filename,\n // A `Session` asks for bytes; only an explicit `download: true` takes\n // the DOM anchor path this function offers a page.\n returnBytes: encode.download !== true,\n onProgress: request.onProgress,\n onIssue: request.onIssue,\n signal: request.signal,\n rendererWasmUrl: this.defaults.rendererWasmUrl,\n });\n }\n\n /**\n * Queued, rather than a renderer per call: the one renderer is what keeps a\n * GPU surface and the decode cache warm between stills, and its draw and the\n * encode of it are two steps another call's draw would land between.\n */\n exportStill(request: ExportStillRequest): Promise<ExportedStill> {\n const still = this.stillQueue.then(() => this.drawStill(request));\n this.stillQueue = still.catch(() => undefined);\n return still;\n }\n\n dispose(): void {\n this.still?.dispose();\n this.still = null;\n }\n\n private async drawStill(request: ExportStillRequest): Promise<ExportedStill> {\n const renderer = this.renderer(request);\n const drawn = await renderer.render(request.project, {\n scale: request.scale,\n onIssue: request.onIssue,\n ...frameOption(request.frame),\n });\n const bytes = await renderer.toBytes({\n format: request.format,\n quality: request.quality,\n });\n return { bytes, frame: drawn.frame, totalFrames: drawn.totalFrames };\n }\n\n /**\n * One `StillRenderer`, reused across calls and re-viewported when the ask\n * changes — `setViewport` is a no-op when the size already matches, and a\n * full reset when it does not, which is the same trade the class documents.\n */\n private renderer(request: ExportStillRequest): StillRenderer {\n const { project, registry } = request;\n if (project.viewport === undefined || project.fps === undefined) {\n throw new Error(\"exportStill takes a project whose fps and viewport are resolved — see Session.\");\n }\n // A renderer compiles against the registry it was built with.\n if (this.still && this.stillRegistry !== registry) this.dispose();\n this.still ??= new StillRenderer(this.backend, {\n viewport: project.viewport,\n fps: project.fps,\n manifest: request.manifest,\n registry,\n });\n this.stillRegistry = registry;\n this.still.setViewport(project.viewport);\n if (request.manifest) this.still.setManifest(request.manifest);\n return this.still;\n }\n}\n\n/** `ExportStillRequest.frame` in the shape `StillRenderer.render` accepts. */\nfunction frameOption(frame: ExportStillRequest[\"frame\"]): { frame?: number | \"first\" | \"last\" } {\n if (frame.kind === \"frame\") return { frame: frame.frame };\n return { frame: frame.kind };\n}\n\n/**\n * An engine backed by the browser: WebGPU surfaces, Web Audio, WebCodecs.\n * Rejects with `WebGpuUnavailableError` where this browser has no WebGPU adapter.\n *\n * Async because the renderer is a wasm module and every seam below needs it. Await\n * once, at app start, and share the result — the caches underneath (registered\n * fonts, decoded images, shaped paragraphs) are the point of keeping one engine\n * rather than one per canvas.\n *\n * ```ts\n * const engine = await createBrowserEngine({ nodes: { pulseRing: PulseRing } });\n * const session = engine.open({ document, target: canvasEl });\n * session.playback!.play();\n * ```\n */\nexport async function createBrowserEngine(\n options: BrowserEngineOptions = {},\n): Promise<Engine<WgpuStorageAdapter>> {\n const rawNodes = options.nodes;\n // `Array.isArray` doesn't narrow a `readonly T[] | U` union cleanly against\n // its `arg is any[]` (mutable) predicate — the `.filter` predicate below\n // already guarantees no string survives, so the cast is just recovering\n // what the runtime check already proved.\n const classNodes = (\n Array.isArray(rawNodes)\n ? rawNodes.filter((n): n is NodeConstructor => typeof n !== \"string\")\n : rawNodes\n ) as NodeTypeMap | readonly NodeConstructor[] | undefined;\n const sourceNodes = Array.isArray(rawNodes)\n ? rawNodes.filter((n): n is string => typeof n === \"string\")\n : [];\n // Cheap — see dynamic-nodes.ts: no WASM import happens here, only on\n // `compile`'s first actual call. Attached unconditionally so a later\n // `engine.registerNode(source)` works even when `nodes` carried no\n // string at boot.\n const dynamicNodes = resolveDynamicNodes(options.dynamicNodes, options.compilerWasmUrl);\n\n const renderer: BrowserRenderer<WgpuStorageAdapter> = await loadRenderer(options);\n const exporter = new WebExporter(renderer, { video: options.video, audio: options.audio, rendererWasmUrl: options.rendererWasmUrl });\n\n const platform: EnginePlatform<WgpuStorageAdapter> = {\n createStorageAdapter: (deps) => renderer.createStorageAdapter(deps),\n createRenderContext: (storage) => renderer.createRenderContext(storage),\n createMeasureContext: (storage) => renderer.createMeasureContext(storage),\n createAudioSink(): AudioSink {\n return new WebAudioSink();\n },\n createTicker(fps: number, audioDevice: AudioSink): Ticker {\n // Shares the device's own `AudioContext`: two independent timebases\n // in one session drift against each other, and sound is the one that\n // cannot be nudged back. A getter, so neither creates it before it\n // is needed (the first play, or the first sound to decode).\n const sink = audioDevice as WebAudioSink;\n return new WebTicker({ context: () => sink.getContext(), fps });\n },\n createExporter(): Exporter {\n return exporter;\n },\n dispose(): void {\n exporter.dispose();\n renderer.dispose?.();\n },\n };\n\n const engine = new Engine<WgpuStorageAdapter>(platform, { ...options, nodes: classNodes, dynamicNodes });\n for (const source of sourceNodes) {\n // Sequential — one script's error shouldn't mask another's, and\n // registration order should match array order for determinism.\n await engine.registerNode(source);\n }\n return engine;\n}\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { AssetManifest, ProjectDocument, Registry, Size2D, VisualDocument } from "@motionscript/core";
|
|
2
|
+
import type { RendererWasmOption } from "./renderer";
|
|
3
|
+
import type { AudioEncoderOptions, ExportProgressCallback } from "./exporter";
|
|
4
|
+
import { type AudioFormat } from "./formats";
|
|
5
|
+
export type ExportAudioParams = RendererWasmOption & {
|
|
6
|
+
/** A project, or a lone still or composition as the one track of one. */
|
|
7
|
+
document: ProjectDocument | VisualDocument;
|
|
8
|
+
/** The vocabulary its clips compile against. Defaults to what the library ships. */
|
|
9
|
+
registry?: Registry;
|
|
10
|
+
/** Discovery lays clips out at this size and rate; 1920×1080 at 60 fps when neither the document nor this says. */
|
|
11
|
+
viewport?: Size2D;
|
|
12
|
+
fps?: number;
|
|
13
|
+
manifest?: AssetManifest;
|
|
14
|
+
/** Defaults to `'wav'`, which needs no encoder. */
|
|
15
|
+
format?: AudioFormat;
|
|
16
|
+
audio?: AudioEncoderOptions;
|
|
17
|
+
/** Defaults to `export.<extension>`. */
|
|
18
|
+
filename?: string;
|
|
19
|
+
onProgress?: ExportProgressCallback;
|
|
20
|
+
signal?: AbortSignal;
|
|
21
|
+
/** When true, the encoded bytes are returned instead of triggering a browser download. */
|
|
22
|
+
returnBytes?: boolean;
|
|
23
|
+
};
|
|
24
|
+
/** The timeline schedules no sound, so an audio-only export has nothing to write. */
|
|
25
|
+
export declare class NoAudioError extends Error {
|
|
26
|
+
readonly name = "NoAudioError";
|
|
27
|
+
constructor();
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Mix the timeline's audio and encode it alone: WAV, MP3 or M4A (AAC). Nothing
|
|
31
|
+
* is drawn, so no frame is rendered and no GPU surface is made.
|
|
32
|
+
*
|
|
33
|
+
* @throws {NoAudioError} when nothing on the timeline plays, rather than writing a silent file.
|
|
34
|
+
*/
|
|
35
|
+
export declare function exportAudio(params: ExportAudioParams): Promise<Uint8Array | void>;
|
|
36
|
+
//# sourceMappingURL=export-audio.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export-audio.d.ts","sourceRoot":"","sources":["../src/export-audio.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAI3G,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAC9E,OAAO,EAAoD,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAG/F,MAAM,MAAM,iBAAiB,GAAG,kBAAkB,GAAG;IACjD,yEAAyE;IACzE,QAAQ,EAAE,eAAe,GAAG,cAAc,CAAC;IAC3C,oFAAoF;IACpF,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,mHAAmH;IACnH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,mDAAmD;IACnD,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,sBAAsB,CAAC;IACpC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,0FAA0F;IAC1F,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,qFAAqF;AACrF,qBAAa,YAAa,SAAQ,KAAK;IACnC,SAAkB,IAAI,kBAAkB;;CAK3C;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAqCvF"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { BufferTarget, Output } from "mediabunny";
|
|
2
|
+
import { deliver } from "./deliver";
|
|
3
|
+
import { audioTrackSource, ensureAudioEncoder, formatSpec } from "./formats";
|
|
4
|
+
import { mixTimelineAudio } from "./mix-timeline-audio";
|
|
5
|
+
/** The timeline schedules no sound, so an audio-only export has nothing to write. */
|
|
6
|
+
export class NoAudioError extends Error {
|
|
7
|
+
name = "NoAudioError";
|
|
8
|
+
constructor() {
|
|
9
|
+
super("The timeline has no audio to export.");
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Mix the timeline's audio and encode it alone: WAV, MP3 or M4A (AAC). Nothing
|
|
14
|
+
* is drawn, so no frame is rendered and no GPU surface is made.
|
|
15
|
+
*
|
|
16
|
+
* @throws {NoAudioError} when nothing on the timeline plays, rather than writing a silent file.
|
|
17
|
+
*/
|
|
18
|
+
export async function exportAudio(params) {
|
|
19
|
+
const { format = "wav", audio = {}, onProgress, signal, returnBytes = false } = params;
|
|
20
|
+
const spec = formatSpec(format);
|
|
21
|
+
if (spec.kind !== "audio")
|
|
22
|
+
throw new RangeError(`exportAudio writes audio; "${format}" is video, which exportVideo writes.`);
|
|
23
|
+
signal?.throwIfAborted();
|
|
24
|
+
// Before the mix, so a browser that cannot encode the format fails fast.
|
|
25
|
+
await ensureAudioEncoder(format);
|
|
26
|
+
const mixed = await mixTimelineAudio({
|
|
27
|
+
document: params.document,
|
|
28
|
+
registry: params.registry,
|
|
29
|
+
viewport: params.viewport,
|
|
30
|
+
fps: params.fps,
|
|
31
|
+
manifest: params.manifest,
|
|
32
|
+
sampleRate: audio.sampleRate,
|
|
33
|
+
rendererWasmUrl: params.rendererWasmUrl,
|
|
34
|
+
});
|
|
35
|
+
if (mixed === null)
|
|
36
|
+
throw new NoAudioError();
|
|
37
|
+
signal?.throwIfAborted();
|
|
38
|
+
onProgress?.(0.5);
|
|
39
|
+
const target = new BufferTarget();
|
|
40
|
+
const output = new Output({ format: spec.container(), target });
|
|
41
|
+
const source = audioTrackSource(format, audio.bitrate);
|
|
42
|
+
output.addAudioTrack(source);
|
|
43
|
+
await output.start();
|
|
44
|
+
await source.add(mixed);
|
|
45
|
+
source.close();
|
|
46
|
+
await output.finalize();
|
|
47
|
+
if (!target.buffer)
|
|
48
|
+
throw new Error("Export produced no data");
|
|
49
|
+
onProgress?.(1);
|
|
50
|
+
return deliver(new Uint8Array(target.buffer), {
|
|
51
|
+
returnBytes,
|
|
52
|
+
filename: params.filename ?? `export.${spec.extension}`,
|
|
53
|
+
mimeType: spec.mimeType,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=export-audio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export-audio.js","sourceRoot":"","sources":["../src/export-audio.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,UAAU,EAAoB,MAAM,WAAW,CAAC;AAC/F,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAsBxD,qFAAqF;AACrF,MAAM,OAAO,YAAa,SAAQ,KAAK;IACjB,IAAI,GAAG,cAAc,CAAC;IAExC;QACI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAClD,CAAC;CACJ;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,MAAyB;IACvD,MAAM,EAAE,MAAM,GAAG,KAAK,EAAE,KAAK,GAAG,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,GAAG,KAAK,EAAE,GAAG,MAAM,CAAC;IACvF,MAAM,IAAI,GAAG,UAAU,CAAC,MAA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AAC,CAAC;IAC/D,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC;IAEhB,OAAO,OAAO,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;QAC1C,WAAW;QACX,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,UAAU,IAAI,CAAC,SAAS,EAAE;QACvD,QAAQ,EAAE,IAAI,CAAC,QAAQ;KAC1B,CAAC,CAAC;AACP,CAAC","sourcesContent":["import type { AssetManifest, ProjectDocument, Registry, Size2D, VisualDocument } from \"@motionscript/core\";\nimport { BufferTarget, Output } from \"mediabunny\";\n\nimport { deliver } from \"./deliver\";\nimport type { RendererWasmOption } from \"./renderer\";\nimport type { AudioEncoderOptions, ExportProgressCallback } from \"./exporter\";\nimport { audioTrackSource, ensureAudioEncoder, formatSpec, type AudioFormat } from \"./formats\";\nimport { mixTimelineAudio } from \"./mix-timeline-audio\";\n\nexport type ExportAudioParams = RendererWasmOption & {\n /** A project, or a lone still or composition as the one track of one. */\n document: ProjectDocument | VisualDocument;\n /** The vocabulary its clips compile against. Defaults to what the library ships. */\n registry?: Registry;\n /** Discovery lays clips out at this size and rate; 1920×1080 at 60 fps when neither the document nor this says. */\n viewport?: Size2D;\n fps?: number;\n manifest?: AssetManifest;\n /** Defaults to `'wav'`, which needs no encoder. */\n format?: AudioFormat;\n audio?: AudioEncoderOptions;\n /** Defaults to `export.<extension>`. */\n filename?: string;\n onProgress?: ExportProgressCallback;\n signal?: AbortSignal;\n /** When true, the encoded bytes are returned instead of triggering a browser download. */\n returnBytes?: boolean;\n};\n\n/** The timeline schedules no sound, so an audio-only export has nothing to write. */\nexport class NoAudioError extends Error {\n override readonly name = \"NoAudioError\";\n\n constructor() {\n super(\"The timeline has no audio to export.\");\n }\n}\n\n/**\n * Mix the timeline's audio and encode it alone: WAV, MP3 or M4A (AAC). Nothing\n * is drawn, so no frame is rendered and no GPU surface is made.\n *\n * @throws {NoAudioError} when nothing on the timeline plays, rather than writing a silent file.\n */\nexport async function exportAudio(params: ExportAudioParams): Promise<Uint8Array | void> {\n const { format = \"wav\", audio = {}, onProgress, signal, returnBytes = false } = params;\n const spec = formatSpec(format);\n if (spec.kind !== \"audio\") throw new RangeError(`exportAudio writes audio; \"${format}\" is video, which exportVideo writes.`);\n signal?.throwIfAborted();\n // Before the mix, so a browser that cannot encode the format fails fast.\n await ensureAudioEncoder(format);\n\n const mixed = await mixTimelineAudio({\n document: params.document,\n registry: params.registry,\n viewport: params.viewport,\n fps: params.fps,\n manifest: params.manifest,\n sampleRate: audio.sampleRate,\n rendererWasmUrl: params.rendererWasmUrl,\n });\n if (mixed === null) throw new NoAudioError();\n signal?.throwIfAborted();\n onProgress?.(0.5);\n\n const target = new BufferTarget();\n const output = new Output({ format: spec.container(), target });\n const source = audioTrackSource(format, audio.bitrate);\n output.addAudioTrack(source);\n await output.start();\n await source.add(mixed);\n source.close();\n await output.finalize();\n if (!target.buffer) throw new Error(\"Export produced no data\");\n onProgress?.(1);\n\n return deliver(new Uint8Array(target.buffer), {\n returnBytes,\n filename: params.filename ?? `export.${spec.extension}`,\n mimeType: spec.mimeType,\n });\n}\n"]}
|
package/dist/exporter.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { Registry, type AssetManifest, type FrameRange, type ProjectDocument, type VisualDocument, type Size2D, type Theme } from "@motionscript/core";
|
|
2
|
-
import { type
|
|
1
|
+
import { ManifestAssetCatalog, Registry, type AssetManifest, type FrameRange, type ProjectDocument, type RenderIssue, type VisualDocument, type Size2D, type StorageAdapter, type Theme } from "@motionscript/core";
|
|
2
|
+
import { type VideoFrameSink } from "./frame-loop";
|
|
3
|
+
import { type Quality, type VideoCodec } from 'mediabunny';
|
|
4
|
+
import type { BrowserRenderContext } from "./engine";
|
|
5
|
+
import { type RendererWasmOption } from "./renderer";
|
|
6
|
+
import { type VideoFormat } from "./formats";
|
|
3
7
|
/** Reports export progress in [0, 1]; video encoding occupies most of the range, audio mixing/finalize the tail. */
|
|
4
8
|
export type ExportProgressCallback = (progress: number) => void;
|
|
5
9
|
/**
|
|
@@ -10,17 +14,19 @@ export type ExportProgressCallback = (progress: number) => void;
|
|
|
10
14
|
*/
|
|
11
15
|
export type VideoEncoderOptions = {
|
|
12
16
|
/**
|
|
13
|
-
* Which codec the video track is encoded with. Defaults to
|
|
14
|
-
* which every player, editor and upload target
|
|
17
|
+
* Which codec the video track is encoded with. Defaults to the format's own:
|
|
18
|
+
* `'avc'` (H.264) for MP4, which every player, editor and upload target
|
|
19
|
+
* accepts, and `'vp9'` for WebM.
|
|
15
20
|
*
|
|
16
21
|
* `'hevc'` and `'av1'` reconstruct sharp edges far better at the same
|
|
17
22
|
* bitrate, which is what a listing of syntax-highlighted code or a hairline
|
|
18
23
|
* stroke is made of — worth reaching for when the file is going somewhere
|
|
19
24
|
* that decodes them. Both are still 4:2:0, so they narrow the gap rather
|
|
20
25
|
* than close it. Availability depends on the platform's encoders; an
|
|
21
|
-
* unsupported choice
|
|
26
|
+
* unsupported choice, or one the container cannot hold (`'avc'` in WebM),
|
|
27
|
+
* falls back to the format's default rather than failing the export.
|
|
22
28
|
*/
|
|
23
|
-
codec?: 'avc' | 'hevc' | 'av1' | 'vp9';
|
|
29
|
+
codec?: 'avc' | 'hevc' | 'av1' | 'vp9' | 'vp8';
|
|
24
30
|
/**
|
|
25
31
|
* Which encoder implementation WebCodecs should prefer.
|
|
26
32
|
*
|
|
@@ -88,12 +94,12 @@ export type VideoEncoderOptions = {
|
|
|
88
94
|
export declare function motionGraphicsBitrate(width: number, height: number, fps: number): number;
|
|
89
95
|
/** How the mixed audio track is encoded. */
|
|
90
96
|
export type AudioEncoderOptions = {
|
|
91
|
-
/**
|
|
97
|
+
/** Bitrate in bits per second for AAC, Opus and MP3; WAV ignores it. Defaults to 192 kbps. */
|
|
92
98
|
bitrate?: number;
|
|
93
|
-
/** Mixdown sample rate in Hz. Defaults to the mixer's own (44100). */
|
|
99
|
+
/** Mixdown sample rate in Hz. Defaults to the mixer's own (44100); Opus is resampled to 48 kHz. */
|
|
94
100
|
sampleRate?: number;
|
|
95
101
|
};
|
|
96
|
-
export type ExportParams = {
|
|
102
|
+
export type ExportParams = RendererWasmOption & {
|
|
97
103
|
/** A project, or a lone still or composition as the one track of one. */
|
|
98
104
|
document: ProjectDocument | VisualDocument;
|
|
99
105
|
/** The vocabulary its clips compile against. Defaults to what the library ships. */
|
|
@@ -102,12 +108,15 @@ export type ExportParams = {
|
|
|
102
108
|
viewport?: Size2D;
|
|
103
109
|
fps?: number;
|
|
104
110
|
scale?: number;
|
|
111
|
+
/** The container, and with it the default codecs: H.264 and AAC for `'mp4'` (the default), VP9 and Opus for `'webm'`. */
|
|
112
|
+
format?: VideoFormat;
|
|
113
|
+
/** Defaults to `export.<extension>`. */
|
|
105
114
|
filename?: string;
|
|
106
115
|
manifest?: AssetManifest;
|
|
107
116
|
/** Theme for a document that carries none of its own. */
|
|
108
117
|
theme?: Theme;
|
|
109
118
|
/**
|
|
110
|
-
* Set false to produce a silent
|
|
119
|
+
* Set false to produce a silent file — no audio track is added to the
|
|
111
120
|
* container and the mix is skipped entirely. Defaults to true.
|
|
112
121
|
*/
|
|
113
122
|
includeAudio?: boolean;
|
|
@@ -123,7 +132,12 @@ export type ExportParams = {
|
|
|
123
132
|
frames?: FrameRange;
|
|
124
133
|
onProgress?: ExportProgressCallback;
|
|
125
134
|
signal?: AbortSignal;
|
|
126
|
-
|
|
135
|
+
/**
|
|
136
|
+
* What the renderer drew but not as the document says, once per kind,
|
|
137
|
+
* feature and node. A lost GPU device fails the export with a
|
|
138
|
+
* `RenderBackendError` instead.
|
|
139
|
+
*/
|
|
140
|
+
onIssue?: (issue: RenderIssue) => void;
|
|
127
141
|
/**
|
|
128
142
|
* Render each frame at this multiple of the output resolution and downsample
|
|
129
143
|
* it before encoding. **Defaults to 2**; pass 1 to turn it off.
|
|
@@ -150,20 +164,117 @@ export type ExportParams = {
|
|
|
150
164
|
*/
|
|
151
165
|
supersample?: number;
|
|
152
166
|
/**
|
|
153
|
-
* When true, the encoded
|
|
167
|
+
* When true, the encoded bytes are returned instead of triggering a
|
|
154
168
|
* browser download. Used by headless drivers (e.g. the CLI) that capture
|
|
155
169
|
* the output themselves and write it to disk; leave unset for the
|
|
156
170
|
* interactive player, which downloads via an `<a>` element.
|
|
157
171
|
*/
|
|
158
172
|
returnBytes?: boolean;
|
|
159
173
|
};
|
|
174
|
+
/**
|
|
175
|
+
* mediabunny/WebCodecs implementation of the frame sink, writing whichever
|
|
176
|
+
* container `format` names.
|
|
177
|
+
*
|
|
178
|
+
* Wraps the very `<canvas>` the renderer draws into, so `addFrame` costs nothing but
|
|
179
|
+
* a timestamp — WebCodecs pulls the pixels from the canvas itself, with no
|
|
180
|
+
* GPU→CPU readback. That is why the seam signals a frame rather than passing one.
|
|
181
|
+
*
|
|
182
|
+
* The readback claim holds only while the encoder is a hardware one, which is
|
|
183
|
+
* why {@link VideoEncoderOptions.hardwareAcceleration} defaults to letting the
|
|
184
|
+
* platform choose: a software encoder has to be handed CPU pixels, so it drags
|
|
185
|
+
* a full-frame copy off the GPU on every single frame.
|
|
186
|
+
*/
|
|
187
|
+
export declare class MediabunnyVideoSink implements VideoFrameSink<AudioBuffer> {
|
|
188
|
+
private readonly format;
|
|
189
|
+
private readonly audioOptions;
|
|
190
|
+
private readonly target;
|
|
191
|
+
private readonly output;
|
|
192
|
+
private readonly video;
|
|
193
|
+
private audio;
|
|
194
|
+
constructor(canvas: HTMLCanvasElement,
|
|
195
|
+
/** Encoded output size, which is the canvas' own unless supersampling is on. */
|
|
196
|
+
output: {
|
|
197
|
+
width: number;
|
|
198
|
+
height: number;
|
|
199
|
+
}, format: VideoFormat, encoding: ResolvedVideoEncoding, audioOptions?: AudioEncoderOptions);
|
|
200
|
+
start(info: {
|
|
201
|
+
fps: number;
|
|
202
|
+
hasAudio: boolean;
|
|
203
|
+
}): Promise<void>;
|
|
204
|
+
addFrame(timestamp: number, duration: number): Promise<void>;
|
|
205
|
+
addAudio(mixed: AudioBuffer): Promise<void>;
|
|
206
|
+
finalize(): Promise<Uint8Array>;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Every encoder setting, decided. A split export pins one of these across its
|
|
210
|
+
* segments, since `concatVideoSegments` refuses parts encoded differently. With
|
|
211
|
+
* a numeric `bitrate` (see {@link plainVideoEncoding}) it is plain data and
|
|
212
|
+
* crosses a process boundary.
|
|
213
|
+
*/
|
|
214
|
+
export interface ResolvedVideoEncoding {
|
|
215
|
+
codec: VideoCodec;
|
|
216
|
+
/** A `Quality` is left for the encoder to size, as an export always has. */
|
|
217
|
+
bitrate: number | Quality;
|
|
218
|
+
hardwareAcceleration: NonNullable<VideoEncoderOptions['hardwareAcceleration']>;
|
|
219
|
+
keyFrameInterval: number;
|
|
220
|
+
latencyMode: NonNullable<VideoEncoderOptions['latencyMode']>;
|
|
221
|
+
contentHint: string;
|
|
222
|
+
bitrateMode?: VideoEncoderOptions['bitrateMode'];
|
|
223
|
+
}
|
|
224
|
+
/** {@link VideoEncoderOptions} with its defaults applied against the encoded size and rate. */
|
|
225
|
+
export declare function resolveVideoEncoding(video: VideoEncoderOptions | undefined, format: VideoFormat, output: {
|
|
226
|
+
width: number;
|
|
227
|
+
height: number;
|
|
228
|
+
}, fps: number): Promise<ResolvedVideoEncoding>;
|
|
229
|
+
/**
|
|
230
|
+
* The encoding with a `Quality` turned into the bits per second mediabunny would
|
|
231
|
+
* give it at this size, since a class instance cannot cross a `MessagePort`.
|
|
232
|
+
*/
|
|
233
|
+
export declare function plainVideoEncoding(encoding: ResolvedVideoEncoding, output: {
|
|
234
|
+
width: number;
|
|
235
|
+
height: number;
|
|
236
|
+
}): ResolvedVideoEncoding & {
|
|
237
|
+
bitrate: number;
|
|
238
|
+
};
|
|
239
|
+
/** The encoded size, rounded up to even, and how far each frame is supersampled. */
|
|
240
|
+
export declare function exportGeometry(viewport: Size2D, scale: number, supersample: number): {
|
|
241
|
+
output: {
|
|
242
|
+
width: number;
|
|
243
|
+
height: number;
|
|
244
|
+
};
|
|
245
|
+
oversample: number;
|
|
246
|
+
renderScale: number;
|
|
247
|
+
};
|
|
248
|
+
/** A hidden canvas with a mounted render context, reusable across renders of one project. */
|
|
249
|
+
export interface ExportSurface {
|
|
250
|
+
canvas: HTMLCanvasElement;
|
|
251
|
+
renderContext: BrowserRenderContext;
|
|
252
|
+
storageAdapter: StorageAdapter;
|
|
253
|
+
assetCatalog: ManifestAssetCatalog;
|
|
254
|
+
dispose(): void;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Open the canvas, renderer, storage and render context an export draws with,
|
|
258
|
+
* resolving once the surface can draw (a frame drawn before an asynchronously
|
|
259
|
+
* started surface is ready encodes blank). The canvas is a whole multiple of the
|
|
260
|
+
* output, so the downsample is exact.
|
|
261
|
+
*/
|
|
262
|
+
export declare function openExportSurface(params: {
|
|
263
|
+
canvasSize: {
|
|
264
|
+
width: number;
|
|
265
|
+
height: number;
|
|
266
|
+
};
|
|
267
|
+
viewport: Size2D;
|
|
268
|
+
fps: number;
|
|
269
|
+
manifest: AssetManifest;
|
|
270
|
+
} & RendererWasmOption): Promise<ExportSurface>;
|
|
160
271
|
/**
|
|
161
272
|
* Renders a document frame-by-frame to an offscreen canvas and muxes the result
|
|
162
|
-
* into an MP4 via mediabunny.
|
|
273
|
+
* into an MP4 or WebM via mediabunny.
|
|
163
274
|
*
|
|
164
275
|
* The frame loop itself — discovery, state evaluation, the warm-and-re-render retry
|
|
165
276
|
* that keeps every frame accurate, audio scheduling, progress and cancellation —
|
|
166
|
-
* lives in
|
|
277
|
+
* lives in `renderTimeline` (frame-loop.ts). What this function
|
|
167
278
|
* supplies is the browser-specific half: a canvas to draw into, a WebCodecs sink,
|
|
168
279
|
* a Web Audio mixer, and the `<a download>` delivery.
|
|
169
280
|
*/
|
package/dist/exporter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exporter.d.ts","sourceRoot":"","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