alpha2 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 +71 -5
- package/THIRD_PARTY_NOTICES.md +191 -1
- package/dist/apply-edit.d.ts +124 -0
- package/dist/apply-edit.js +15 -0
- package/dist/assets.d.ts +12 -0
- package/dist/audio-layout.js +6 -3
- package/dist/audio-worklet-processor.js +27 -33
- package/dist/audio.d.ts +5 -4
- package/dist/audio.js +8 -6
- package/dist/compose.d.ts +105 -0
- package/dist/compose.js +63 -0
- package/dist/decoder-fallback.d.ts +3 -2
- package/dist/decoder-fallback.js +11 -3
- package/dist/decoder-stall.d.ts +15 -0
- package/dist/decoder-stall.js +52 -0
- package/dist/edit-data.d.ts +24 -0
- package/dist/edit-data.js +224 -0
- package/dist/edit-keys.d.ts +16 -0
- package/dist/edit-keys.js +233 -0
- package/dist/edit.d.ts +41 -8
- package/dist/edit.js +123 -30
- package/dist/export-failure.d.ts +10 -2
- package/dist/export-failure.js +55 -4
- package/dist/export-retry.d.ts +6 -1
- package/dist/export-retry.js +12 -1
- package/dist/exporter.d.ts +11 -7
- package/dist/exporter.js +10 -9
- package/dist/extensions.d.ts +86 -28
- package/dist/extensions.js +204 -61
- package/dist/extract.d.ts +65 -0
- package/dist/extract.js +291 -0
- package/dist/extractor.d.ts +151 -0
- package/dist/extractor.js +141 -0
- package/dist/float32.d.ts +2 -0
- package/dist/float32.js +10 -0
- package/dist/frame-intake.d.ts +5 -0
- package/dist/frame-intake.js +10 -3
- package/dist/generated/builtin-effects.d.ts +3 -0
- package/dist/generated/builtin-effects.js +1804 -0
- package/dist/generated/project-schema.d.ts +696 -41
- package/dist/generated/project-schema.js +67 -0
- package/dist/generated/project-shape.js +986 -383
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/json-text.js +14 -2
- package/dist/layout-values.js +7 -1
- package/dist/layout.d.ts +12 -4
- package/dist/media.d.ts +44 -11
- package/dist/media.js +256 -67
- package/dist/mediabunny.d.ts +32 -12
- package/dist/mediabunny.js +276 -90
- package/dist/player.d.ts +9 -3
- package/dist/player.js +114 -18
- package/dist/plugins.d.ts +62 -0
- package/dist/plugins.js +506 -0
- package/dist/project-data.d.ts +56 -0
- package/dist/project-data.js +765 -0
- package/dist/project.d.ts +36 -1
- package/dist/project.js +515 -42
- package/dist/robustness.d.ts +6 -33
- package/dist/robustness.js +2 -63
- package/dist/sha256.d.ts +3 -2
- package/dist/sha256.js +14 -6
- package/dist/wasm-module.d.ts +37 -0
- package/dist/wasm-module.js +47 -0
- package/dist/worker-error.d.ts +3 -2
- package/dist/worker-error.js +3 -1
- package/dist/worker.d.ts +13 -3
- package/dist/worker.js +36 -9
- package/package.json +36 -2
- package/wasm/alpha2_compose.d.ts +92 -0
- package/wasm/alpha2_compose.js +445 -0
- package/wasm/alpha2_compose_bg.wasm +0 -0
- package/wasm/alpha2_compose_bg.wasm.d.ts +17 -0
- package/wasm/alpha2_extensions.d.ts +4 -4
- package/wasm/alpha2_extensions.js +16 -4
- package/wasm/alpha2_extensions_bg.wasm +0 -0
- package/wasm/alpha2_extensions_pdf.d.ts +227 -0
- package/wasm/alpha2_extensions_pdf.js +841 -0
- package/wasm/alpha2_extensions_pdf_bg.wasm +0 -0
- package/wasm/alpha2_extensions_pdf_bg.wasm.d.ts +38 -0
- package/wasm/alpha2_wasm.d.ts +151 -18
- package/wasm/alpha2_wasm.js +403 -59
- package/wasm/alpha2_wasm_bg.wasm +0 -0
- package/wasm/alpha2_wasm_bg.wasm.d.ts +21 -6
- package/wasm/rust-crate-licenses.md +493 -54
- package/wasm/snippets/alpha2-wasm-1b02e9f302d283ba/inline3.js +7 -0
- /package/wasm/snippets/{alpha2-wasm-a21734ffde826659/inline1.js → alpha2-wasm-1b02e9f302d283ba/inline0.js} +0 -0
- /package/wasm/snippets/{alpha2-wasm-a21734ffde826659/inline2.js → alpha2-wasm-1b02e9f302d283ba/inline1.js} +0 -0
- /package/wasm/snippets/{alpha2-wasm-a21734ffde826659/inline3.js → alpha2-wasm-1b02e9f302d283ba/inline2.js} +0 -0
- /package/wasm/snippets/{alpha2-wasm-a21734ffde826659/inline0.js → alpha2-wasm-1b02e9f302d283ba/inline4.js} +0 -0
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ engine.uploadRgbaImage("image-1", 1280, 720, new Uint8Array(1280 * 720 * 4).fill
|
|
|
35
35
|
engine.renderAt(0n); // draws the frame at time 0 on the canvas
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
- `init()` loads `alpha2_wasm_bg.wasm` from beside the module. A bundler that moves it passes its URL, a `Response`, its bytes or a compiled `WebAssembly.Module` as `init({ module_or_path })`; the files are `alpha2/wasm/alpha2_wasm_bg.wasm` (the engine), `alpha2/wasm/alpha2_audio_worklet.wasm` (the audio worklet)
|
|
38
|
+
- `init()` loads `alpha2_wasm_bg.wasm` from beside the module. A bundler that moves it passes its URL, a `Response`, its bytes or a compiled `WebAssembly.Module` as `init({ module_or_path })`; the files are `alpha2/wasm/alpha2_wasm_bg.wasm` (the engine), `alpha2/wasm/alpha2_audio_worklet.wasm` (the audio worklet) `alpha2/wasm/alpha2_extensions_bg.wasm` (SVG, animated images, Lottie, OpenEXR, image sequences and LaTeX, loaded only for such a source) and `alpha2/wasm/alpha2_extensions_pdf_bg.wasm` (PDF pages, loaded only for a PDF). `loadExtensions` takes the extension files' URLs by module name, `{ core, pdf }`.
|
|
39
39
|
- `createForHtmlCanvas` draws on a page canvas; a worker passes an `OffscreenCanvas` to `createForCanvas`. Either renders with WebGPU, or with WebGL2 when the browser has no WebGPU. The WebGPU device is opened before the canvas is bound, so a failure leaves the canvas free for another context. `{ softwareAdapter: "refuse" }` refuses software adapters (SwiftShader, llvmpipe, WARP, a WebGPU fallback adapter) and rejects `GPU_INIT_FAILED` when the browser offers nothing else.
|
|
40
40
|
- With neither (Chrome with acceleration off, a blocklisted GPU), `WebEffectRegistry.createCpu(canvas)` makes the engine's CPU renderer: the same calls, drawn in wasm on one thread, the preview put on the canvas's 2D context. It draws exactly what the native CPU renderer draws, refuses runtime WGSL effects with `EFFECT_ERROR`, and needs no canvas to export. `createRenderer(binding, canvas, mode)` in `alpha2/renderer-choice` makes the renderer a mode asks for (`"auto"` draws on a hardware GPU, else on the CPU renderer, as the native host's `auto` does) and says which it made. `detectBrowserCapabilities()` reports which renderer `"auto"` gets on the calling thread (`renderer`), probing WebGL2 on an `OffscreenCanvas`, as render hosts draw; a worker host's answer comes from `WorkerRenderBackend.detectCapabilities()`.
|
|
41
41
|
- A project is the engine's JSON document. `alpha2/project` has its TypeScript types, tick conversions and `validateProject`, which reports what the engine would refuse before the document is sent; `alpha2/builder` writes one with times in seconds. `loadProject` checks the document again and throws what it refuses.
|
|
@@ -75,9 +75,67 @@ The engine mixes the project's audio. The application uploads each source's deco
|
|
|
75
75
|
|
|
76
76
|
For preview, `alpha2/audio-timeline` moves the mixed blocks to the audio thread through a ring in shared memory, which needs a cross-origin isolated page (`canShareAudioMemory()` says whether this page is one), and `alpha2/audio-worklet` plays them in an AudioWorklet. `alpha2/loudness` measures loudness (ITU-R BS.1770-4, EBU R128) and plans normalization; `alpha2/waveform` computes waveform summaries.
|
|
77
77
|
|
|
78
|
+
## Extract data
|
|
79
|
+
|
|
80
|
+
`runExtractor` in `alpha2/extract` runs an extractor of your own over a source or the timeline and resolves with data sets ready to put in `project.data`. The browser decodes the source in software (mediabunny), the engine's session in wasm presents and checks every step, and each value is validated as the project validates data:
|
|
81
|
+
|
|
82
|
+
```js
|
|
83
|
+
import { runExtractor } from "alpha2/extract";
|
|
84
|
+
|
|
85
|
+
const { dataSets } = await runExtractor(
|
|
86
|
+
{
|
|
87
|
+
binding: wasm,
|
|
88
|
+
project,
|
|
89
|
+
media: { interview: file },
|
|
90
|
+
request: {
|
|
91
|
+
extractor: "com.example.brightness",
|
|
92
|
+
version: 1,
|
|
93
|
+
input: { from: "source", source_id: "interview", range: { start: 0, end: 600_000 }, size: 64 },
|
|
94
|
+
outputs: { level: "interview-brightness" },
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
describe: () => ({
|
|
99
|
+
id: "com.example.brightness",
|
|
100
|
+
version: 1,
|
|
101
|
+
input: { media: "video", from: ["source"], format: "luma8" },
|
|
102
|
+
outputs: [{ name: "level", kind: "scalars", channels: ["y"] }],
|
|
103
|
+
}),
|
|
104
|
+
video(frame, out) {
|
|
105
|
+
const sum = frame.data.reduce((total, value) => total + value, 0);
|
|
106
|
+
out.sample("level", frame.time, [sum / frame.data.length / 255]);
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
);
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
A timeline input needs `timelineFrame(time, width, height)`, such as the CPU renderer's `readRgbaAt`, and an audio input `audioBinding: wasm`. `loadPlugin(manifest, sha256)` in `alpha2/plugins` loads an [extractor plugin](https://github.com/alpha2-sh/alpha2/blob/main/docs/plugin-abi.md)'s wasm artifact, checked against its pinned hashes; pass it as `plugin` with `plugin.extractor(params)`. `applyEdit` in `alpha2/apply-edit` then applies data to the project, such as `remove_ranges` over silences.
|
|
113
|
+
|
|
114
|
+
## Compose
|
|
115
|
+
|
|
116
|
+
`alpha2/compose` compiles compose specs (videos described by intent: sequences, stacks, grids, media, text and templates) into projects in the browser, with the engine's own compose code, so a spec compiles to the same project here as in Python or in `alpha2-host`. It runs in a wasm module of its own (`alpha2/compose-wasm`, file `alpha2/wasm/alpha2_compose_bg.wasm`), which a page that only plays and exports projects never fetches:
|
|
117
|
+
|
|
118
|
+
```js
|
|
119
|
+
import { bindTemplate, compileCompose, composeRequirements, loadCompose } from "alpha2/compose";
|
|
120
|
+
|
|
121
|
+
const compose = await loadCompose(); // or loadCompose(wasmUrl) when a bundler moved the .wasm
|
|
122
|
+
const spec = bindTemplate(compose, template, { headline: "Summer sale", photo: "beach.jpg" });
|
|
123
|
+
const { media, texts } = composeRequirements(compose, spec); // the files to gather facts about
|
|
124
|
+
const facts = await describeFiles(media, texts); // the application's own probe, shape below
|
|
125
|
+
const fonts = [new Uint8Array(await (await fetch("/fonts/Inter.ttf")).arrayBuffer())];
|
|
126
|
+
const { project, assets, loudness, warnings } = compileCompose(compose, spec, { facts, fonts });
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
- `facts` describes the files the spec names: `{ media: { [path]: { width, height, frame_rate, duration_ticks, has_audio } }, texts: { [path]: text } }`. A video the spec plays unmuted needs `has_audio`.
|
|
130
|
+
- Fonts are font file bytes; text needs at least one font.
|
|
131
|
+
- `compileCompose` takes no templates: bind a spec's own templates with `bindTemplate` first (its `templates` option names node templates; `theme` replaces a video template's theme). Built-in `alpha2/` template nodes expand at compile time; `builtinTemplates` lists them.
|
|
132
|
+
- The result's `project` is a project document; `assets` maps each source id to the path it reads, `loudness` is `null` or the spec's target (`{ target_lufs, true_peak_ceiling_dbtp }`), and `warnings` are notes for the author.
|
|
133
|
+
- `templateDataSchema` gives the JSON Schema of a template's data, for a form, an API or a model to fill in, and `lintTemplate` lists a template's problems (`{ path, code, message, severity }`).
|
|
134
|
+
- A spec, template or data that does not compile or bind throws an `Error` whose message is `path: problem`, with `path` and `problem` as properties.
|
|
135
|
+
|
|
78
136
|
## Preview in a worker
|
|
79
137
|
|
|
80
|
-
`alpha2/worker` runs the engine in a worker that owns the GPU device and an `OffscreenCanvas` (`installRenderWorker`, `createWasmRenderWorkerHost`), and `WorkerRenderBackend` drives it from the page. The host's `renderer` option is `"auto"` (WebGPU, else WebGL2, on a hardware adapter, else the CPU renderer), `"gpu"` (any adapter, software ones included) or `"cpu"`; `WorkerRenderBackend.rendererChoice` says which renderer the worker made and why it draws on the CPU, as the native host's `renderer` and `rendererReason` do. `Alpha2Player` in `alpha2/player` presents times through such a backend: it serializes presentations, asks for the frames a presentation lacks and shows them once they arrive, and recovers a lost GPU through `GpuRecoveryLadder` (`alpha2/gpu-recovery`): the GPU again after a first external loss, the CPU renderer once the loss was the work's own (`GPU_DEVICE_HUNG`), recurred at the same frame, or the page has lost the GPU twice (the browser withdraws GPU access after its next reset). A recovery that needs a new canvas takes one from the player's `replaceSurface` option; `@alpha2-sh/react` supplies it.
|
|
138
|
+
`alpha2/worker` runs the engine in a worker that owns the GPU device and an `OffscreenCanvas` (`installRenderWorker`, `createWasmRenderWorkerHost`), and `WorkerRenderBackend` drives it from the page. The host's `renderer` option is `"auto"` (WebGPU, else WebGL2, on a hardware adapter, else the CPU renderer), `"gpu"` (any adapter, software ones included) or `"cpu"`; `WorkerRenderBackend.rendererChoice` says which renderer the worker made and why it draws on the CPU, as the native host's `renderer` and `rendererReason` do. `Alpha2Player` in `alpha2/player` presents times through such a backend: it serializes presentations (one runs and only the latest request waits), asks for the frames a presentation lacks and shows them once they arrive, and recovers a lost GPU through `GpuRecoveryLadder` (`alpha2/gpu-recovery`): the GPU again after a first external loss, the CPU renderer once the loss was the work's own (`GPU_DEVICE_HUNG`), recurred at the same frame, or the page has lost the GPU twice (the browser withdraws GPU access after its next reset). A recovery that needs a new canvas takes one from the player's `replaceSurface` option; `@alpha2-sh/react` supplies it.
|
|
81
139
|
|
|
82
140
|
## Subpaths
|
|
83
141
|
|
|
@@ -87,11 +145,16 @@ For preview, `alpha2/audio-timeline` moves the mixed blocks to the audio thread
|
|
|
87
145
|
| `alpha2/project` | The project document's types and limits, tick conversions, `validateProject`. |
|
|
88
146
|
| `alpha2/builder` | `ProjectBuilder`: documents from seconds, with generated ids. |
|
|
89
147
|
| `alpha2/edit` | Editing operations on a project: split, trim, ripple, roll, slip, slide, retime, insert, overwrite, append, move. |
|
|
148
|
+
| `alpha2/apply-edit` | `applyEdit`: the engine's edit operations that apply data to a project (`remove_ranges`, `split_at`, `bake`), the same canonical result on every surface. |
|
|
149
|
+
| `alpha2/extract`, `alpha2/plugins` | `runExtractor`: extractors of your own over a source or the timeline, decoded in the browser; `loadPlugin`: [extractor plugins](https://github.com/alpha2-sh/alpha2/blob/main/docs/plugin-abi.md) run sandboxed. |
|
|
150
|
+
| `alpha2/extractor` | The extractor contract every surface shares (`Extractor`, `ExtractorDescriptor`, `ExtractRun`, `ExtractResult`), types only, without a media library. |
|
|
151
|
+
| `alpha2/compose`, `alpha2/compose-wasm` | Compose specs and templates (`loadCompose`, `composeRequirements`, `compileCompose`, `bindTemplate`, `templateDataSchema`, `lintTemplate`, `builtinTemplates`), and the wasm module they load. See [Compose](#compose). |
|
|
90
152
|
| `alpha2/captions` | SRT and WebVTT import into caption tracks. |
|
|
91
153
|
| `alpha2/geometry` | Shape geometry for editors, from the engine's own code: item bounds, hit tests, nearest points, path lengths, trims, resampling, convert to path, motion paths. |
|
|
92
154
|
| `alpha2/layout` | Layout generators: `measureLayout` (where every box lies and what overflows, laid out with the engine's fonts, pixels those of the project canvas) and a builder from CSS-like props, flexbox and grid. See [docs/layout.md](https://github.com/alpha2-sh/alpha2/blob/main/docs/layout.md). |
|
|
93
155
|
| `alpha2/effects` | Effect definitions and the built-in catalog's types; `RuntimeEffectRegistry`, a typed wrapper for registering WGSL effects and effect resources at run time. |
|
|
94
|
-
| `alpha2/extensions`, `alpha2/extensions-wasm` | SVG, animated image, Lottie, OpenEXR
|
|
156
|
+
| `alpha2/extensions`, `alpha2/extensions-wasm`, `alpha2/extensions-pdf-wasm` | SVG, animated image, Lottie, OpenEXR, image sequence, LaTeX and PDF sources, from their own WebAssembly modules (`loadExtensions`). After an abort a module restarts asynchronously; `ready()` resolves once it takes calls again. |
|
|
157
|
+
| `alpha2/wasm-module` | `WasmModule`, which loads a wasm-bindgen module once per realm and restarts it asynchronously. |
|
|
95
158
|
| `alpha2/text` | Text rasterizers: `WasmTextRasterizer` (the engine's, the same pixels as a native export) and `OffscreenTextRasterizer` (the browser's). |
|
|
96
159
|
| `alpha2/assets` | Media identity, proxies and conform reports. |
|
|
97
160
|
| `alpha2/frame-supply` | `FrameSupply`: decodes and uploads the frames a time needs. |
|
|
@@ -103,13 +166,16 @@ For preview, `alpha2/audio-timeline` moves the mixed blocks to the audio thread
|
|
|
103
166
|
| `alpha2/exporter` | `Alpha2Exporter` and `exportToSink`. |
|
|
104
167
|
| `alpha2/export-destination` | Where an export's bytes go: a file, or memory. |
|
|
105
168
|
| `alpha2/export-failure`, `alpha2/export-retry` | How export failures are classified, and a retry policy over them. |
|
|
169
|
+
| `alpha2/export-metrics` | `ExportMetrics` and `BrowserExportPerformance`: the timing and memory of a browser export, under the names the native host's `performance` uses for the same quantities, and the encoder probe results. |
|
|
170
|
+
| `alpha2/worker-error` | Errors as plain data across a worker boundary, keeping their code and failure class (`serializeError`, `Alpha2WasmError`), and `wasmTrapCode`. |
|
|
171
|
+
| `alpha2/abort`, `alpha2/active-clock` | `AbortSignal` helpers (`abortError`, `throwIfAborted`, `raceAbort`); timeouts that count active time, so a frozen or sleeping page does not count as a stall (`activeTimeout`, `withinActiveTime`, `ActiveStopwatch`). |
|
|
106
172
|
| `alpha2/containers` | The export containers (MP4, MOV, MKV, WebM) and the codecs each offers. |
|
|
107
173
|
| `alpha2/rate-control` | Output bitrates for the engine's quality levels. |
|
|
108
174
|
| `alpha2/audio`, `alpha2/audio-worker` | Offline audio rendering into a sink, in a worker or not. |
|
|
109
175
|
| `alpha2/audio-timeline`, `alpha2/audio-worklet`, `alpha2/audio-worklet-processor` | Real-time audio: the shared ring, its pump, and the AudioWorklet and its processor module. |
|
|
110
176
|
| `alpha2/loudness`, `alpha2/waveform` | Loudness measurement and normalization; waveform summaries. |
|
|
111
|
-
| `alpha2/robustness` | Browser capability detection
|
|
112
|
-
| `alpha2` | `alpha2/assets`, `audio`, `audio-timeline`, `audio-worker`, `audio-worklet`, `containers`, `effects`, `exporter`, `extensions`, `frame-supply`, `hdr-frames`, `loudness`, `media`, `player`, `project`, `rate-control`, `robustness`, `text`, `waveform` and `worker` in one import. |
|
|
177
|
+
| `alpha2/robustness` | Browser capability detection. |
|
|
178
|
+
| `alpha2` | `alpha2/assets`, `audio`, `audio-timeline`, `audio-worker`, `audio-worklet`, `compose`, `containers`, `effects`, `exporter`, `export-metrics`, `extensions`, `frame-supply`, `gpu-recovery`, `hdr-frames`, `loudness`, `media`, `player`, `project`, `rate-control`, `renderer-choice`, `robustness`, `text`, `waveform` and `worker` in one import. |
|
|
113
179
|
|
|
114
180
|
Each module's declarations document its API.
|
|
115
181
|
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -4,7 +4,11 @@ alpha2 is under the MIT License (`LICENSE.md`). It also contains third-party wor
|
|
|
4
4
|
|
|
5
5
|
## Rust crates
|
|
6
6
|
|
|
7
|
-
The `alpha2` npm package
|
|
7
|
+
The `alpha2` npm package, the native archives, the `alpha2` Python wheels and the mobile packages each list the third-party Rust crates compiled into them, with their license texts: `wasm/rust-crate-licenses.md` in the npm package, `licenses/rust-crate-licenses.md` in each archive (and in the `alpha2-host` wheel built from it), `rust-crate-licenses.md` in the `.dist-info/licenses/` directory of each `alpha2` wheel, in `META-INF/alpha2/` of the Android library and in each framework of the Swift package's XCFramework. The wheels and the mobile packages carry this file and `LICENSE.md` beside that list.
|
|
8
|
+
|
|
9
|
+
## uniffi (iOS and Android packages)
|
|
10
|
+
|
|
11
|
+
The Swift package and the Android library contain the runtime of uniffi 0.32 (https://github.com/mozilla/uniffi-rs), unmodified, and Swift and Kotlin sources it generated. uniffi is under the Mozilla Public License 2.0 (https://mozilla.org/MPL/2.0/); its source is available from that repository at the tag `v0.32.2`. The packages' crate lists carry the license text. The mobile packages contain no FFmpeg.
|
|
8
12
|
|
|
9
13
|
## FFmpeg
|
|
10
14
|
|
|
@@ -80,6 +84,192 @@ In addition, the Cisco-provided binary of this Software is licensed under Cisco'
|
|
|
80
84
|
v1.0
|
|
81
85
|
```
|
|
82
86
|
|
|
87
|
+
## STIX Two Math and the dvips color names
|
|
88
|
+
|
|
89
|
+
The `alpha2-extensions` crate, the extensions wasm module in the `alpha2` npm package, the native archives (and the `alpha2-host` wheels built from them) and the mobile packages contain the STIX Two Math font (version 2.13) and a modified copy of the dvips color names, both embedded by the `latex-rust` crate (https://github.com/jscarr64/latex-rust) to typeset LaTeX math. The font is under the SIL Open Font License 1.1, below with its copyright and trademark signs and dashes written in ASCII.
|
|
90
|
+
|
|
91
|
+
The color names are a modified copy of `dvipsnam.def` from the `%<*dvipsnames>` section of `drivers.dtx` in the LaTeX graphics bundle, Copyright 1994 David Carlisle and Sebastian Rahtz, Copyright 1995-1999 David Carlisle, Copyright 2000-2026 The LaTeX Project, under the LaTeX Project Public License 1.3c or later (https://www.latex-project.org/lppl.txt). The definitions were rewritten as a tab-separated table and re-sorted by name; the original authors and The LaTeX Project do not maintain or support it. The unmodified graphics bundle is at https://github.com/latex3/latex2e/tree/develop/required/graphics (CTAN: macros/latex/required/graphics).
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
Copyright 2001-2021 The STIX Fonts Project Authors (https://github.com/stipub/stixfonts)
|
|
95
|
+
|
|
96
|
+
STIX Fonts(TM) is a trademark of The Institute of Electrical and
|
|
97
|
+
Electronics Engineers, Inc.
|
|
98
|
+
|
|
99
|
+
Portions copyright (c) 1998-2003 by MicroPress, Inc.
|
|
100
|
+
(www.micropress-inc.com), with Reserved Font Name TM Math.
|
|
101
|
+
To obtain additional mathematical fonts, please contact
|
|
102
|
+
MicroPress, Inc.,
|
|
103
|
+
68-30 Harrow Street,
|
|
104
|
+
Forest Hills, NY 11375,
|
|
105
|
+
USA
|
|
106
|
+
Phone: (718) 575-1816.
|
|
107
|
+
|
|
108
|
+
Portions copyright (c) 1990 by Elsevier, Inc.
|
|
109
|
+
|
|
110
|
+
Portions copyright (c) 2010, 2012, 2014 Adobe Systems Incorporated.
|
|
111
|
+
|
|
112
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
113
|
+
This license is copied below, and is also available with a FAQ at:
|
|
114
|
+
http://scripts.sil.org/OFL
|
|
115
|
+
|
|
116
|
+
-----------------------------------------------------------
|
|
117
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
118
|
+
-----------------------------------------------------------
|
|
119
|
+
|
|
120
|
+
PREAMBLE
|
|
121
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
122
|
+
development of collaborative font projects, to support the font creation
|
|
123
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
124
|
+
open framework in which fonts may be shared and improved in partnership
|
|
125
|
+
with others.
|
|
126
|
+
|
|
127
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
128
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
129
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
130
|
+
redistributed and/or sold with any software provided that any reserved
|
|
131
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
132
|
+
however, cannot be released under any other type of license. The
|
|
133
|
+
requirement for fonts to remain under this license does not apply
|
|
134
|
+
to any document created using the fonts or their derivatives.
|
|
135
|
+
|
|
136
|
+
DEFINITIONS
|
|
137
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
138
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
139
|
+
include source files, build scripts and documentation.
|
|
140
|
+
|
|
141
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
142
|
+
copyright statement(s).
|
|
143
|
+
|
|
144
|
+
"Original Version" refers to the collection of Font Software components as
|
|
145
|
+
distributed by the Copyright Holder(s).
|
|
146
|
+
|
|
147
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
148
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
149
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
150
|
+
new environment.
|
|
151
|
+
|
|
152
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
153
|
+
writer or other person who contributed to the Font Software.
|
|
154
|
+
|
|
155
|
+
PERMISSION & CONDITIONS
|
|
156
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
157
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
158
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
159
|
+
Software, subject to the following conditions:
|
|
160
|
+
|
|
161
|
+
1) Neither the Font Software nor any of its individual components,
|
|
162
|
+
in Original or Modified Versions, may be sold by itself.
|
|
163
|
+
|
|
164
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
165
|
+
redistributed and/or sold with any software, provided that each copy
|
|
166
|
+
contains the above copyright notice and this license. These can be
|
|
167
|
+
included either as stand-alone text files, human-readable headers or
|
|
168
|
+
in the appropriate machine-readable metadata fields within text or
|
|
169
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
170
|
+
|
|
171
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
172
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
173
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
174
|
+
presented to the users.
|
|
175
|
+
|
|
176
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
177
|
+
Software shall not be used to promote, endorse or advertise any
|
|
178
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
179
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
180
|
+
permission.
|
|
181
|
+
|
|
182
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
183
|
+
must be distributed entirely under this license, and must not be
|
|
184
|
+
distributed under any other license. The requirement for fonts to
|
|
185
|
+
remain under this license does not apply to any document created
|
|
186
|
+
using the Font Software.
|
|
187
|
+
|
|
188
|
+
TERMINATION
|
|
189
|
+
This license becomes null and void if any of the above conditions are
|
|
190
|
+
not met.
|
|
191
|
+
|
|
192
|
+
DISCLAIMER
|
|
193
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
194
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
195
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
196
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
197
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
198
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
199
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
200
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
201
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## PDF standard fonts and CMaps
|
|
205
|
+
|
|
206
|
+
The `alpha2-extensions` crate, the extensions wasm module in the `alpha2` npm package, the native archives (and the `alpha2-host` wheels built from them) and the mobile packages contain data the `hayro` crates (https://github.com/LaurenzV/hayro) embed to draw PDF pages: substitutes for the 14 standard PDF fonts, extracted from PDFium (original code copyright 2014 Foxit Software Inc.), and Adobe's predefined CMaps.
|
|
207
|
+
|
|
208
|
+
The standard font substitutes:
|
|
209
|
+
|
|
210
|
+
```
|
|
211
|
+
Copyright 2014 PDFium Authors. All rights reserved.
|
|
212
|
+
|
|
213
|
+
Redistribution and use in source and binary forms, with or without
|
|
214
|
+
modification, are permitted provided that the following conditions are
|
|
215
|
+
met:
|
|
216
|
+
|
|
217
|
+
* Redistributions of source code must retain the above copyright
|
|
218
|
+
notice, this list of conditions and the following disclaimer.
|
|
219
|
+
* Redistributions in binary form must reproduce the above
|
|
220
|
+
copyright notice, this list of conditions and the following disclaimer
|
|
221
|
+
in the documentation and/or other materials provided with the
|
|
222
|
+
distribution.
|
|
223
|
+
* Neither the name of Google Inc. nor the names of its
|
|
224
|
+
contributors may be used to endorse or promote products derived from
|
|
225
|
+
this software without specific prior written permission.
|
|
226
|
+
|
|
227
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
228
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
229
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
230
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
231
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
232
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
233
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
234
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
235
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
236
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
237
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
The CMaps:
|
|
241
|
+
|
|
242
|
+
```
|
|
243
|
+
Copyright 1990-2023 Adobe. All rights reserved.
|
|
244
|
+
|
|
245
|
+
Redistribution and use in source and binary forms, with or without
|
|
246
|
+
modification, are permitted provided that the following conditions are
|
|
247
|
+
met:
|
|
248
|
+
|
|
249
|
+
Redistributions of source code must retain the above copyright notice,
|
|
250
|
+
this list of conditions and the following disclaimer.
|
|
251
|
+
|
|
252
|
+
Redistributions in binary form must reproduce the above copyright
|
|
253
|
+
notice, this list of conditions and the following disclaimer in the
|
|
254
|
+
documentation and/or other materials provided with the distribution.
|
|
255
|
+
|
|
256
|
+
Neither the name of Adobe nor the names of its contributors may be
|
|
257
|
+
used to endorse or promote products derived from this software without
|
|
258
|
+
specific prior written permission.
|
|
259
|
+
|
|
260
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
261
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
262
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
263
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
264
|
+
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
265
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
266
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
267
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
268
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
269
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
270
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
271
|
+
```
|
|
272
|
+
|
|
83
273
|
## gl-transitions
|
|
84
274
|
|
|
85
275
|
The transitions in `crates/alpha2-shaders/shaders/runtime/transitions/` are WGSL ports of shaders from [gl-transitions](https://github.com/gl-transitions/gl-transitions) at commit `902218a1b63773ac0d0d9f491951da3392365bfe`. Each file names the shader it ports and its author.
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edit operations that apply data to a project once, run by the engine's wasm.
|
|
3
|
+
*
|
|
4
|
+
* The operations are named for primitives: `remove_ranges` (drop silences, keep highlights),
|
|
5
|
+
* `split_at` (cut on beats) and `bake` (data bindings to keyframes, words to cues). Kept moments
|
|
6
|
+
* render as before for clip picture and sound, clip keyframes, captions, timeline-anchored data and
|
|
7
|
+
* track and master automation; a matte or a `via` binding follows the part beside it or the edit is
|
|
8
|
+
* refused (`matte_source`, `read_through`). `split_at` leaves out cuts it cannot make exactly
|
|
9
|
+
* (`report.skipped`); `remove_ranges` refuses them. The result is canonical on every runtime.
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* const { project: tight } = applyEdit(wasm, project, {
|
|
13
|
+
* op: "remove_ranges",
|
|
14
|
+
* ranges: { data: "silence" },
|
|
15
|
+
* target: { track: "v1" },
|
|
16
|
+
* padding: 12_000,
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
import type { DataAnchor, Project } from "./generated/project-schema.js";
|
|
21
|
+
/** Ticks on an anchor's clock, `start <= end`. */
|
|
22
|
+
export interface TickRange {
|
|
23
|
+
readonly start: number;
|
|
24
|
+
readonly end: number;
|
|
25
|
+
}
|
|
26
|
+
/** The clips an operation works on: every clip of a track, or these clips. */
|
|
27
|
+
export type EditTarget = {
|
|
28
|
+
readonly track: string;
|
|
29
|
+
} | {
|
|
30
|
+
readonly clips: readonly string[];
|
|
31
|
+
};
|
|
32
|
+
/** One edit operation. Times are ticks. */
|
|
33
|
+
export type EditRequest = {
|
|
34
|
+
readonly op: "remove_ranges";
|
|
35
|
+
/** An `intervals` data set, or a list on an anchor's clock. */
|
|
36
|
+
readonly ranges: {
|
|
37
|
+
readonly data: string;
|
|
38
|
+
} | {
|
|
39
|
+
readonly list: readonly TickRange[];
|
|
40
|
+
readonly anchor: DataAnchor;
|
|
41
|
+
};
|
|
42
|
+
readonly target: EditTarget;
|
|
43
|
+
/** What closes the gaps; `timeline` by default. */
|
|
44
|
+
readonly ripple?: "none" | "track" | "timeline";
|
|
45
|
+
/** Keeps only the ranges, removing their complement within the target clips' extent. */
|
|
46
|
+
readonly invert?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Ticks kept at each edge of every removed range; a negative value widens each range, which
|
|
49
|
+
* never starts before time 0.
|
|
50
|
+
*/
|
|
51
|
+
readonly padding?: number;
|
|
52
|
+
/** Removed ranges shorter than this, after padding, are kept. */
|
|
53
|
+
readonly min_duration?: number;
|
|
54
|
+
} | {
|
|
55
|
+
readonly op: "split_at";
|
|
56
|
+
/** An `intervals` data set's starts, or a list of ticks on an anchor's clock. */
|
|
57
|
+
readonly times: {
|
|
58
|
+
readonly data: string;
|
|
59
|
+
} | {
|
|
60
|
+
readonly list: readonly number[];
|
|
61
|
+
readonly anchor: DataAnchor;
|
|
62
|
+
};
|
|
63
|
+
readonly target: EditTarget;
|
|
64
|
+
} | {
|
|
65
|
+
readonly op: "bake";
|
|
66
|
+
/** Property paths use the lint path syntax (`visual.position`, `effect.params.radius`). */
|
|
67
|
+
readonly targets: readonly ({
|
|
68
|
+
readonly clip: string;
|
|
69
|
+
readonly property: string;
|
|
70
|
+
} | {
|
|
71
|
+
readonly composition: string;
|
|
72
|
+
readonly node: string;
|
|
73
|
+
readonly property: string;
|
|
74
|
+
} | {
|
|
75
|
+
readonly track: string;
|
|
76
|
+
readonly property: string;
|
|
77
|
+
})[];
|
|
78
|
+
};
|
|
79
|
+
/** What an operation changed, so a caller can show and select it. */
|
|
80
|
+
export interface EditReport {
|
|
81
|
+
/** Timeline ranges removed, in the old timeline's time. */
|
|
82
|
+
readonly removed: readonly TickRange[];
|
|
83
|
+
/** Kept stretches that moved. */
|
|
84
|
+
readonly moved: readonly {
|
|
85
|
+
readonly from: TickRange;
|
|
86
|
+
readonly to: TickRange;
|
|
87
|
+
}[];
|
|
88
|
+
/** Clips the operation created, each with the clip it was cut from (which keeps its id). */
|
|
89
|
+
readonly created: readonly {
|
|
90
|
+
readonly id: string;
|
|
91
|
+
readonly from: string;
|
|
92
|
+
}[];
|
|
93
|
+
/**
|
|
94
|
+
* Cuts `split_at` left out because they would change what a clip shows, in clip and time
|
|
95
|
+
* order; absent when it left none out.
|
|
96
|
+
*/
|
|
97
|
+
readonly skipped?: readonly {
|
|
98
|
+
readonly clip: string;
|
|
99
|
+
/** The cut, in timeline ticks. */
|
|
100
|
+
readonly time: number;
|
|
101
|
+
readonly reason: "in_transition" | "in_fade" | "matte_source" | "read_through";
|
|
102
|
+
}[];
|
|
103
|
+
}
|
|
104
|
+
/** An operation's result. */
|
|
105
|
+
export interface AppliedEdit {
|
|
106
|
+
readonly project: Project;
|
|
107
|
+
/** The engine's canonical text of `project`, byte for byte what every surface answers. */
|
|
108
|
+
readonly projectJson: string;
|
|
109
|
+
readonly report: EditReport;
|
|
110
|
+
}
|
|
111
|
+
/** Why an operation refused, as `Alpha2Error.details.refusal` names it. */
|
|
112
|
+
export type EditRefusal = "invalid_project" | "invalid_request" | "unknown_data" | "wrong_kind" | "unknown_target" | "empty_target" | "missing_anchor" | "invalid_range" | "nothing_to_bake" | "correction_not_bakeable" | "unbounded_parameter" | "matte_source" | "read_through" | "in_transition" | "in_fade" | "too_many_clips" | "too_many_cues" | "result_too_large" | "invalid_result";
|
|
113
|
+
/** The generated wasm function this wrapper calls. */
|
|
114
|
+
export interface ApplyEditBinding {
|
|
115
|
+
applyEdit(project: string, request: string): [string, string];
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Applies `request` to `project`; neither is changed.
|
|
119
|
+
*
|
|
120
|
+
* @throws An `Alpha2Error` with code `INVALID_INPUT` for an invalid project or request and for
|
|
121
|
+
* every refusal (`ALPHA2_ERROR` for an edited project that fails validation, a defect);
|
|
122
|
+
* `details.refusal` names why.
|
|
123
|
+
*/
|
|
124
|
+
export declare function applyEdit(binding: ApplyEditBinding, project: Project, request: EditRequest): AppliedEdit;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Applies `request` to `project`; neither is changed.
|
|
3
|
+
*
|
|
4
|
+
* @throws An `Alpha2Error` with code `INVALID_INPUT` for an invalid project or request and for
|
|
5
|
+
* every refusal (`ALPHA2_ERROR` for an edited project that fails validation, a defect);
|
|
6
|
+
* `details.refusal` names why.
|
|
7
|
+
*/
|
|
8
|
+
export function applyEdit(binding, project, request) {
|
|
9
|
+
const [projectJson, report] = binding.applyEdit(JSON.stringify(project), JSON.stringify(request));
|
|
10
|
+
return {
|
|
11
|
+
project: JSON.parse(projectJson),
|
|
12
|
+
projectJson,
|
|
13
|
+
report: JSON.parse(report),
|
|
14
|
+
};
|
|
15
|
+
}
|
package/dist/assets.d.ts
CHANGED
|
@@ -170,6 +170,18 @@ export interface ConformReport {
|
|
|
170
170
|
readonly ready: boolean;
|
|
171
171
|
/** Each host-supplied source a render reads, in project order. */
|
|
172
172
|
readonly sources: readonly SourceConform[];
|
|
173
|
+
/**
|
|
174
|
+
* Data sets made from other media than their source's original now is, in data order. This
|
|
175
|
+
* never blocks, since the data still reads, but it may no longer describe the media.
|
|
176
|
+
*/
|
|
177
|
+
readonly stale_data: readonly StaleData[];
|
|
178
|
+
}
|
|
179
|
+
/** A data set whose `made_from` differs from its source's current original. */
|
|
180
|
+
export interface StaleData {
|
|
181
|
+
readonly data: string;
|
|
182
|
+
readonly source: string;
|
|
183
|
+
/** The parts of the fingerprint that differ. */
|
|
184
|
+
readonly fields: readonly FingerprintField[];
|
|
173
185
|
}
|
|
174
186
|
/** Lists every blocking issue with its source id. */
|
|
175
187
|
export declare function blockingIssues(report: ConformReport): readonly {
|
package/dist/audio-layout.js
CHANGED
|
@@ -314,6 +314,8 @@ function findLayoutBox(bytes, start, end) {
|
|
|
314
314
|
if (box.type === "stsd") {
|
|
315
315
|
// Skip the full-box header and entry count.
|
|
316
316
|
for (const entry of boxes(bytes, box.payload + 8, box.end)) {
|
|
317
|
+
if (entry.payload + 10 > entry.end)
|
|
318
|
+
continue;
|
|
317
319
|
const view = new DataView(bytes.buffer, bytes.byteOffset);
|
|
318
320
|
const version = view.getUint16(entry.payload + 8);
|
|
319
321
|
// QuickTime sound descriptions grow by 16 (v1) or 36 (v2) bytes; ISO v1 does not, so try
|
|
@@ -334,9 +336,10 @@ function trackId(bytes, trak) {
|
|
|
334
336
|
for (const box of boxes(bytes, trak.payload, trak.end)) {
|
|
335
337
|
if (box.type !== "tkhd")
|
|
336
338
|
continue;
|
|
337
|
-
const
|
|
338
|
-
|
|
339
|
-
|
|
339
|
+
const at = box.payload + (bytes[box.payload] === 1 ? 20 : 12);
|
|
340
|
+
if (at + 4 > box.end)
|
|
341
|
+
return null;
|
|
342
|
+
return new DataView(bytes.buffer, bytes.byteOffset).getUint32(at);
|
|
340
343
|
}
|
|
341
344
|
return null;
|
|
342
345
|
}
|
|
@@ -115,6 +115,8 @@ class Alpha2Processor extends AudioWorkletProcessor {
|
|
|
115
115
|
#sourcePointer = 0;
|
|
116
116
|
#sourceFrames = 0;
|
|
117
117
|
#sourceViews;
|
|
118
|
+
/** Why the module stopped; once set, nothing reaches the module again. */
|
|
119
|
+
#failure;
|
|
118
120
|
constructor() {
|
|
119
121
|
super();
|
|
120
122
|
this.port.onmessage = (event) => {
|
|
@@ -131,13 +133,14 @@ class Alpha2Processor extends AudioWorkletProcessor {
|
|
|
131
133
|
else if (message.type === "alpha2-ring" ||
|
|
132
134
|
message.type === "alpha2-config" ||
|
|
133
135
|
message.type === "alpha2-reset") {
|
|
134
|
-
let error;
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
136
|
+
let error = this.#failure;
|
|
137
|
+
if (error === undefined)
|
|
138
|
+
try {
|
|
139
|
+
error = this.#apply(message);
|
|
140
|
+
}
|
|
141
|
+
catch (thrown) {
|
|
142
|
+
error = thrown instanceof Error ? thrown.message : String(thrown);
|
|
143
|
+
}
|
|
141
144
|
// Posted after any `alpha2-latency` the request caused. Without an id, a refusal is an
|
|
142
145
|
// error.
|
|
143
146
|
if (message.id !== undefined)
|
|
@@ -379,19 +382,10 @@ class Alpha2Processor extends AudioWorkletProcessor {
|
|
|
379
382
|
status = exports.alpha2_worklet_process(this.#handle, length, this.#channels);
|
|
380
383
|
}
|
|
381
384
|
catch (error) {
|
|
382
|
-
this
|
|
383
|
-
type: "alpha2-error",
|
|
384
|
-
message: `AudioWorklet DSP module trapped (${this.#panicMessage(exports) ?? String(error)}); the node has stopped`,
|
|
385
|
-
});
|
|
386
|
-
return false;
|
|
387
|
-
}
|
|
388
|
-
if (status !== 0) {
|
|
389
|
-
this.port.postMessage({
|
|
390
|
-
type: "alpha2-error",
|
|
391
|
-
message: `AudioWorklet processing failed (${status}); the node has stopped`,
|
|
392
|
-
});
|
|
393
|
-
return false;
|
|
385
|
+
return this.#fail(`AudioWorklet DSP module trapped (${this.#panicMessage(exports) ?? String(error)}); the node has stopped`);
|
|
394
386
|
}
|
|
387
|
+
if (status !== 0)
|
|
388
|
+
return this.#fail(`AudioWorklet processing failed (${status}); the node has stopped`);
|
|
395
389
|
const views = this.#viewsFor(exports, length);
|
|
396
390
|
const produced = this.#transparent ? views.input : views.output;
|
|
397
391
|
for (let channel = 0; channel < this.#channels; channel += 1) {
|
|
@@ -402,8 +396,17 @@ class Alpha2Processor extends AudioWorkletProcessor {
|
|
|
402
396
|
}
|
|
403
397
|
return true;
|
|
404
398
|
}
|
|
399
|
+
/**
|
|
400
|
+
* Records a module failure and reports it once. A node with a connected input keeps being
|
|
401
|
+
* called after it returns false, so later calls stop before the module.
|
|
402
|
+
*/
|
|
403
|
+
#fail(message) {
|
|
404
|
+
this.#failure = message;
|
|
405
|
+
this.port.postMessage({ type: "alpha2-error", message });
|
|
406
|
+
return false;
|
|
407
|
+
}
|
|
405
408
|
process(inputs, outputs) {
|
|
406
|
-
if (this.#disposed)
|
|
409
|
+
if (this.#disposed || this.#failure !== undefined)
|
|
407
410
|
return false;
|
|
408
411
|
const exports = this.#exports;
|
|
409
412
|
const output = outputs[0];
|
|
@@ -439,20 +442,11 @@ class Alpha2Processor extends AudioWorkletProcessor {
|
|
|
439
442
|
}
|
|
440
443
|
catch (error) {
|
|
441
444
|
// A Rust panic traps, and the trap carries no message of its own.
|
|
442
|
-
this
|
|
443
|
-
type: "alpha2-error",
|
|
444
|
-
message: `AudioWorklet DSP module trapped (${this.#panicMessage(exports) ?? String(error)}); the node has stopped`,
|
|
445
|
-
});
|
|
446
|
-
return false;
|
|
447
|
-
}
|
|
448
|
-
if (status !== 0) {
|
|
449
|
-
// Returning false retires the node; this message is the host's only signal.
|
|
450
|
-
this.port.postMessage({
|
|
451
|
-
type: "alpha2-error",
|
|
452
|
-
message: `AudioWorklet processing failed (${status}); the node has stopped`,
|
|
453
|
-
});
|
|
454
|
-
return false;
|
|
445
|
+
return this.#fail(`AudioWorklet DSP module trapped (${this.#panicMessage(exports) ?? String(error)}); the node has stopped`);
|
|
455
446
|
}
|
|
447
|
+
// Returning false retires the node; this message is the host's only signal.
|
|
448
|
+
if (status !== 0)
|
|
449
|
+
return this.#fail(`AudioWorklet processing failed (${status}); the node has stopped`);
|
|
456
450
|
// Recheck: processing may have grown memory and detached the views.
|
|
457
451
|
const produced = this.#viewsFor(exports, length).output;
|
|
458
452
|
for (let channel = 0; channel < this.#channels; channel += 1) {
|
package/dist/audio.d.ts
CHANGED
|
@@ -9,8 +9,8 @@ export interface BrowserAudioBlockSink {
|
|
|
9
9
|
/** Called once after the last block was written. */
|
|
10
10
|
finish(): Promise<void>;
|
|
11
11
|
/**
|
|
12
|
-
* Called once instead of `finish` when the render fails or is
|
|
13
|
-
* render rejects with.
|
|
12
|
+
* Called once instead of `finish`, or while `finish` is pending, when the render fails or is
|
|
13
|
+
* aborted; `reason` is the error the render rejects with.
|
|
14
14
|
*/
|
|
15
15
|
abort(reason: Error): Promise<void> | void;
|
|
16
16
|
}
|
|
@@ -24,8 +24,9 @@ export type OfflineAudioRenderer = (startSample: bigint, frameCount: number) =>
|
|
|
24
24
|
* sizes cycling through `blockSizes`.
|
|
25
25
|
*
|
|
26
26
|
* On success the sink's `finish` is awaited. On any failure, including `signal` aborting before
|
|
27
|
-
*
|
|
28
|
-
* (`signal.reason` or an `AbortError` for an abort). An
|
|
27
|
+
* `finish` resolves, the sink's `abort` is awaited and the promise rejects with the error
|
|
28
|
+
* (`signal.reason` or an `AbortError` for an abort). An abort after `finish` resolved is ignored.
|
|
29
|
+
* An error thrown by `abort` does not replace it.
|
|
29
30
|
*
|
|
30
31
|
* @throws RangeError When `totalFrames` is negative, `blockSizes` is empty or holds a size that is
|
|
31
32
|
* not a positive safe integer (checked before the sink is touched), or `render` returns a block
|