alpha2 0.5.1 → 0.5.3
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 +3 -2
- package/THIRD_PARTY_NOTICES.md +186 -0
- package/dist/extensions.d.ts +86 -28
- package/dist/extensions.js +204 -61
- package/dist/generated/project-schema.d.ts +60 -4
- package/dist/generated/project-schema.js +12 -0
- package/dist/generated/project-shape.js +34 -0
- package/dist/media.d.ts +1 -1
- package/dist/media.js +1 -1
- package/dist/project.d.ts +12 -0
- package/dist/project.js +60 -5
- package/dist/wasm-module.d.ts +37 -0
- package/dist/wasm-module.js +47 -0
- package/package.json +11 -2
- 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.js +25 -25
- package/wasm/alpha2_wasm_bg.wasm +0 -0
- package/wasm/rust-crate-licenses.md +499 -4
- /package/wasm/snippets/{alpha2-wasm-070d94113471ef0a → alpha2-wasm-a6265983c9769e80}/inline0.js +0 -0
- /package/wasm/snippets/{alpha2-wasm-070d94113471ef0a → alpha2-wasm-a6265983c9769e80}/inline1.js +0 -0
- /package/wasm/snippets/{alpha2-wasm-070d94113471ef0a → alpha2-wasm-a6265983c9769e80}/inline2.js +0 -0
- /package/wasm/snippets/{alpha2-wasm-070d94113471ef0a → alpha2-wasm-a6265983c9769e80}/inline3.js +0 -0
package/dist/extensions.js
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
|
-
// Browser extension providers (SVG, animated images, Lottie, OpenEXR, image sequences
|
|
2
|
-
// native host's Rust code in
|
|
1
|
+
// Browser extension providers (SVG, animated images, Lottie, OpenEXR, image sequences, LaTeX,
|
|
2
|
+
// PDF), running the native host's Rust code in lazily loaded wasm modules.
|
|
3
|
+
import { WasmModule } from "./wasm-module.js";
|
|
3
4
|
/**
|
|
4
|
-
* The provider module aborted during this call (a panic or failed allocation)
|
|
5
|
-
*
|
|
5
|
+
* The provider module aborted during this call (a panic or failed allocation), or cannot be used.
|
|
6
|
+
* After an abort the module restarts; {@link Extensions.ready} resolves once later calls work. The
|
|
7
|
+
* source involved stays failed.
|
|
6
8
|
*/
|
|
7
9
|
export class ExtensionModuleError extends Error {
|
|
8
10
|
name = "ExtensionModuleError";
|
|
9
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* The provider module is restarting after an abort. Await {@link Extensions.ready} and call again.
|
|
14
|
+
*/
|
|
15
|
+
export class ExtensionModuleRestartingError extends ExtensionModuleError {
|
|
16
|
+
name = "ExtensionModuleRestartingError";
|
|
17
|
+
constructor() {
|
|
18
|
+
super("the extension module is restarting: await ready() and call again");
|
|
19
|
+
}
|
|
20
|
+
}
|
|
10
21
|
/**
|
|
11
22
|
* The source was opened before the provider module restarted. Re-register its resources and open
|
|
12
23
|
* it again.
|
|
@@ -24,35 +35,64 @@ export class StaleExtensionSourceError extends Error {
|
|
|
24
35
|
function isTrap(error) {
|
|
25
36
|
return (error instanceof WebAssembly.RuntimeError || error instanceof RangeError);
|
|
26
37
|
}
|
|
38
|
+
const PDF_HEADER = [0x25, 0x50, 0x44, 0x46, 0x2d];
|
|
39
|
+
const providerModules = [
|
|
40
|
+
{
|
|
41
|
+
name: "core",
|
|
42
|
+
loader: new WasmModule(() => import("alpha2/extensions-wasm")),
|
|
43
|
+
formats: null,
|
|
44
|
+
claims: () => true,
|
|
45
|
+
readsResources: true,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "pdf",
|
|
49
|
+
loader: new WasmModule(() => import("alpha2/extensions-pdf-wasm")),
|
|
50
|
+
formats: ["pdf"],
|
|
51
|
+
// `%PDF-` within the first 1024 bytes, as PDF readers accept.
|
|
52
|
+
claims: (head) => {
|
|
53
|
+
const end = Math.min(head.length, 1024) - PDF_HEADER.length;
|
|
54
|
+
for (let at = 0; at <= end; at++)
|
|
55
|
+
if (PDF_HEADER.every((byte, index) => head[at + index] === byte))
|
|
56
|
+
return true;
|
|
57
|
+
return false;
|
|
58
|
+
},
|
|
59
|
+
readsResources: false,
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
const CORE = providerModules[0];
|
|
63
|
+
function moduleFor(provider) {
|
|
64
|
+
return (providerModules.find((module) => module.formats?.includes(provider.format)) ?? CORE);
|
|
65
|
+
}
|
|
27
66
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* Providers parse untrusted files, and a panic aborts the wasm instance. The call that aborted it
|
|
31
|
-
* throws {@link ExtensionModuleError} and the module restarts with its fonts re-registered, but
|
|
32
|
-
* sources and resources are lost. Older sources throw {@link StaleExtensionSourceError} until
|
|
33
|
-
* reopened.
|
|
67
|
+
* One loaded provider module. A trap in a call restarts it asynchronously; until it is ready again
|
|
68
|
+
* every call throws {@link ExtensionModuleRestartingError}.
|
|
34
69
|
*/
|
|
35
|
-
|
|
36
|
-
|
|
70
|
+
class ModuleSession {
|
|
71
|
+
module;
|
|
72
|
+
#glue;
|
|
37
73
|
#wasm;
|
|
38
74
|
/** Restart count; sources from an earlier generation are stale. */
|
|
39
75
|
#generation = 0;
|
|
76
|
+
/** Settles when the current restart ends; `null` when none is running. */
|
|
77
|
+
#restarting = null;
|
|
40
78
|
/** Set when a restart failed. */
|
|
41
79
|
#broken = null;
|
|
42
80
|
#fonts = [];
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
this.#
|
|
47
|
-
this.#wasm = new
|
|
48
|
-
this
|
|
49
|
-
call: (call) => this
|
|
81
|
+
calls;
|
|
82
|
+
constructor(module, glue) {
|
|
83
|
+
this.module = module;
|
|
84
|
+
this.#glue = glue;
|
|
85
|
+
this.#wasm = new glue.ExtensionRegistry();
|
|
86
|
+
this.calls = {
|
|
87
|
+
call: (call) => this.call(call),
|
|
50
88
|
generation: () => this.#generation,
|
|
51
89
|
};
|
|
52
90
|
}
|
|
53
|
-
|
|
91
|
+
call(call) {
|
|
54
92
|
if (this.#broken !== null)
|
|
55
|
-
throw
|
|
93
|
+
throw this.#brokenError();
|
|
94
|
+
if (this.#restarting !== null)
|
|
95
|
+
throw new ExtensionModuleRestartingError();
|
|
56
96
|
try {
|
|
57
97
|
return call(this.#wasm);
|
|
58
98
|
}
|
|
@@ -60,60 +100,159 @@ export class Extensions {
|
|
|
60
100
|
if (!isTrap(error))
|
|
61
101
|
throw error;
|
|
62
102
|
this.#restart();
|
|
63
|
-
throw new ExtensionModuleError(`the extension module stopped (${error.message}) and
|
|
103
|
+
throw new ExtensionModuleError(`the ${this.module.name} extension module stopped (${error.message}) and is restarting`, { cause: error });
|
|
64
104
|
}
|
|
65
105
|
}
|
|
106
|
+
#brokenError() {
|
|
107
|
+
const broken = this.#broken;
|
|
108
|
+
return new ExtensionModuleError(`the ${this.module.name} extension module stopped and could not be restarted: ${broken.message}`, { cause: broken });
|
|
109
|
+
}
|
|
66
110
|
#restart() {
|
|
67
111
|
this.#generation += 1;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
112
|
+
// Reuses the compiled module; no fetch or compile.
|
|
113
|
+
this.#restarting = this.module.loader
|
|
114
|
+
.restart()
|
|
115
|
+
.then(() => {
|
|
116
|
+
const wasm = new this.#glue.ExtensionRegistry();
|
|
72
117
|
for (const font of this.#fonts)
|
|
73
118
|
wasm.registerFont(font);
|
|
74
119
|
this.#wasm = wasm;
|
|
120
|
+
})
|
|
121
|
+
.catch((error) => {
|
|
122
|
+
this.#broken =
|
|
123
|
+
error instanceof Error ? error : new Error(String(error));
|
|
124
|
+
})
|
|
125
|
+
.finally(() => {
|
|
126
|
+
this.#restarting = null;
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
async ready() {
|
|
130
|
+
await this.#restarting;
|
|
131
|
+
if (this.#broken !== null)
|
|
132
|
+
throw this.#brokenError();
|
|
133
|
+
}
|
|
134
|
+
setFonts(fonts) {
|
|
135
|
+
this.call((wasm) => {
|
|
136
|
+
wasm.clearFonts();
|
|
137
|
+
for (const font of fonts)
|
|
138
|
+
wasm.registerFont(font);
|
|
139
|
+
});
|
|
140
|
+
this.#fonts = fonts;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* The provider modules, shared by every source on the page. Load it with {@link loadExtensions},
|
|
145
|
+
* which loads the core module; others load when {@link probe} or {@link prepare} needs them.
|
|
146
|
+
*
|
|
147
|
+
* Providers parse untrusted files, and a panic aborts that module's wasm instance. The call that
|
|
148
|
+
* aborted it throws {@link ExtensionModuleError} and the module restarts asynchronously with its
|
|
149
|
+
* fonts re-registered, but its sources and resources are lost. Until {@link ready} resolves, every
|
|
150
|
+
* call to that module throws {@link ExtensionModuleRestartingError}. Older sources throw
|
|
151
|
+
* {@link StaleExtensionSourceError} until reopened.
|
|
152
|
+
*/
|
|
153
|
+
export class Extensions {
|
|
154
|
+
#urls;
|
|
155
|
+
#sessions = new Map();
|
|
156
|
+
#loading = new Map();
|
|
157
|
+
#fonts = [];
|
|
158
|
+
/** Use {@link loadExtensions}. */
|
|
159
|
+
constructor(urls, core) {
|
|
160
|
+
this.#urls = urls;
|
|
161
|
+
this.#sessions.set(core.module.name, core);
|
|
162
|
+
}
|
|
163
|
+
#session(module) {
|
|
164
|
+
const session = this.#sessions.get(module.name);
|
|
165
|
+
if (session === undefined)
|
|
166
|
+
throw new Error(`the ${module.name} extension module is not loaded: await prepare() first`);
|
|
167
|
+
return session;
|
|
168
|
+
}
|
|
169
|
+
#readers() {
|
|
170
|
+
return [...this.#sessions.values()].filter((session) => session.module.readsResources);
|
|
171
|
+
}
|
|
172
|
+
#load(module) {
|
|
173
|
+
const loaded = this.#sessions.get(module.name);
|
|
174
|
+
if (loaded !== undefined)
|
|
175
|
+
return Promise.resolve(loaded);
|
|
176
|
+
let loading = this.#loading.get(module.name);
|
|
177
|
+
if (loading === undefined) {
|
|
178
|
+
loading = loadSession(module, this.#urls[module.name])
|
|
179
|
+
.then((session) => {
|
|
180
|
+
if (module.readsResources && this.#fonts.length > 0)
|
|
181
|
+
session.setFonts(this.#fonts);
|
|
182
|
+
this.#sessions.set(module.name, session);
|
|
183
|
+
return session;
|
|
184
|
+
})
|
|
185
|
+
.finally(() => this.#loading.delete(module.name));
|
|
186
|
+
this.#loading.set(module.name, loading);
|
|
75
187
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
188
|
+
return loading;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Resolves when every loaded module takes calls, at once unless one is restarting.
|
|
192
|
+
*
|
|
193
|
+
* @throws {ExtensionModuleError} When a restart failed; every later call to that module throws.
|
|
194
|
+
*/
|
|
195
|
+
async ready() {
|
|
196
|
+
await Promise.all([...this.#sessions.values()].map((session) => session.ready()));
|
|
79
197
|
}
|
|
80
|
-
/**
|
|
198
|
+
/**
|
|
199
|
+
* Loads the module that opens `provider`, so {@link open} can open it, at once if it is loaded.
|
|
200
|
+
*
|
|
201
|
+
* @throws When the module cannot be fetched or instantiated.
|
|
202
|
+
*/
|
|
203
|
+
async prepare(provider) {
|
|
204
|
+
await this.#load(moduleFor(provider));
|
|
205
|
+
}
|
|
206
|
+
/** Built-in providers of the loaded modules, in priority order. */
|
|
81
207
|
get providers() {
|
|
82
|
-
|
|
208
|
+
const names = [...this.#sessions.values()].flatMap((session) => JSON.parse(session.call((wasm) => wasm.providers())));
|
|
209
|
+
return [...new Set(names)];
|
|
83
210
|
}
|
|
84
|
-
/** Whether the
|
|
211
|
+
/** Whether the package can open this provider source; its module need not be loaded yet. */
|
|
85
212
|
supports(provider) {
|
|
86
|
-
|
|
213
|
+
const session = this.#sessions.get(moduleFor(provider).name);
|
|
214
|
+
return (session === undefined ||
|
|
215
|
+
session.call((wasm) => wasm.supports(JSON.stringify(provider))));
|
|
87
216
|
}
|
|
88
217
|
/**
|
|
89
|
-
* Probes `bytes` with the first provider that claims them, or
|
|
90
|
-
* decoders can read them.
|
|
218
|
+
* Probes `bytes` with the first provider that claims them, or answers `null` so the host's own
|
|
219
|
+
* decoders can read them. Loads a module only when the bytes' start may be one of its formats.
|
|
91
220
|
*
|
|
92
|
-
* @throws When a provider claims the bytes and cannot read them.
|
|
221
|
+
* @throws When a provider claims the bytes and cannot read them, or a module cannot load.
|
|
93
222
|
*/
|
|
94
|
-
probe(bytes) {
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
223
|
+
async probe(bytes) {
|
|
224
|
+
for (const module of providerModules) {
|
|
225
|
+
if (!module.claims(bytes))
|
|
226
|
+
continue;
|
|
227
|
+
const session = await this.#load(module);
|
|
228
|
+
const found = session.call((wasm) => wasm.probe(bytes));
|
|
229
|
+
if (found !== undefined)
|
|
230
|
+
return JSON.parse(found);
|
|
231
|
+
}
|
|
232
|
+
return null;
|
|
99
233
|
}
|
|
100
234
|
/**
|
|
101
235
|
* Registers bytes under a locator, such as an image sequence frame or an image an SVG references.
|
|
102
236
|
* They stay until released or a module restart; {@link withResources} scopes them to one call.
|
|
103
237
|
*/
|
|
104
238
|
registerResource(locator, bytes) {
|
|
105
|
-
|
|
239
|
+
for (const session of this.#readers())
|
|
240
|
+
session.call((wasm) => wasm.registerResource(locator, bytes));
|
|
106
241
|
}
|
|
107
242
|
releaseResource(locator) {
|
|
108
|
-
|
|
243
|
+
for (const session of this.#readers())
|
|
244
|
+
session.call((wasm) => wasm.releaseResource(locator));
|
|
109
245
|
}
|
|
110
246
|
/** Total registered resource bytes. */
|
|
111
247
|
get resourceBytes() {
|
|
112
|
-
return this.#call((wasm) => wasm.resourceBytes());
|
|
248
|
+
return this.#readers().reduce((total, session) => total + session.call((wasm) => wasm.resourceBytes()), 0);
|
|
113
249
|
}
|
|
114
250
|
/** Locators of resources opening this source reads, such as an image sequence's first frame. */
|
|
115
251
|
openNeeds(provider) {
|
|
116
|
-
|
|
252
|
+
const module = moduleFor(provider);
|
|
253
|
+
if (!module.readsResources)
|
|
254
|
+
return [];
|
|
255
|
+
return JSON.parse(this.#session(module).call((wasm) => wasm.openNeeds(JSON.stringify(provider))));
|
|
117
256
|
}
|
|
118
257
|
/**
|
|
119
258
|
* Runs `call` with the resources `needs` names registered only for its duration. Each is
|
|
@@ -173,23 +312,22 @@ export class Extensions {
|
|
|
173
312
|
if (fonts.length === this.#fonts.length &&
|
|
174
313
|
fonts.every((font, index) => font === this.#fonts[index]))
|
|
175
314
|
return;
|
|
176
|
-
this.#
|
|
177
|
-
|
|
178
|
-
for (const font of fonts)
|
|
179
|
-
wasm.registerFont(font);
|
|
180
|
-
});
|
|
315
|
+
for (const session of this.#readers())
|
|
316
|
+
session.setFonts([...fonts]);
|
|
181
317
|
this.#fonts = [...fonts];
|
|
182
318
|
}
|
|
183
319
|
/**
|
|
184
|
-
* Opens a provider source. Image sequences take
|
|
185
|
-
* (see {@link openNeeds} and {@link withResources}).
|
|
320
|
+
* Opens a provider source. LaTeX takes no bytes. Image sequences take none either; their frames
|
|
321
|
+
* are registered resources (see {@link openNeeds} and {@link withResources}). The source's module
|
|
322
|
+
* must be loaded: {@link probe} loads it for the bytes it claims, {@link prepare} for a source.
|
|
186
323
|
*
|
|
187
324
|
* @throws When the source cannot be opened.
|
|
188
325
|
*/
|
|
189
326
|
open(provider, bytes) {
|
|
190
|
-
|
|
327
|
+
const session = this.#session(moduleFor(provider));
|
|
328
|
+
return session.call((wasm) => {
|
|
191
329
|
const handle = wasm.open(JSON.stringify(provider), bytes);
|
|
192
|
-
return new ExtensionSource(
|
|
330
|
+
return new ExtensionSource(session.calls, handle);
|
|
193
331
|
});
|
|
194
332
|
}
|
|
195
333
|
}
|
|
@@ -321,17 +459,22 @@ export class ExtensionSource {
|
|
|
321
459
|
this.#calls.call((wasm) => wasm.release(handle));
|
|
322
460
|
}
|
|
323
461
|
}
|
|
462
|
+
async function loadSession(module, wasmUrl) {
|
|
463
|
+
return new ModuleSession(module, await module.loader.load(wasmUrl));
|
|
464
|
+
}
|
|
324
465
|
let loading = null;
|
|
325
466
|
/**
|
|
326
|
-
* Loads the provider module once per page
|
|
327
|
-
*
|
|
467
|
+
* Loads the core provider module once per page; the others load when first needed. `wasmUrl`
|
|
468
|
+
* locates the core module's `alpha2_extensions_bg.wasm`, or each module's file by name, when a
|
|
469
|
+
* bundler moved them; it applies to the first call. A failed load is not cached.
|
|
328
470
|
*/
|
|
329
471
|
export function loadExtensions(wasmUrl) {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
472
|
+
const urls = typeof wasmUrl === "string" || wasmUrl instanceof URL
|
|
473
|
+
? { core: wasmUrl }
|
|
474
|
+
: (wasmUrl ?? {});
|
|
475
|
+
loading ??= loadSession(CORE, urls.core)
|
|
476
|
+
.then((core) => new Extensions(urls, core))
|
|
477
|
+
.catch((error) => {
|
|
335
478
|
loading = null;
|
|
336
479
|
throw error;
|
|
337
480
|
});
|
|
@@ -4,6 +4,8 @@ export declare const AUDIO_EFFECT_STATE_MARGIN_MS = 1100;
|
|
|
4
4
|
export declare const CURRENT_SCHEMA_VERSION = 1;
|
|
5
5
|
/** Mirrors `alpha2_model::MAX_ANIMATOR_SCALE`. */
|
|
6
6
|
export declare const MAX_ANIMATOR_SCALE = 10;
|
|
7
|
+
/** Mirrors `alpha2_model::MAX_AUDIO_CHANNELS`. */
|
|
8
|
+
export declare const MAX_AUDIO_CHANNELS = 24;
|
|
7
9
|
/** Mirrors `alpha2_model::MAX_AUDIO_DELAY_MS`. */
|
|
8
10
|
export declare const MAX_AUDIO_DELAY_MS = 120000;
|
|
9
11
|
/** Mirrors `alpha2_model::MAX_AUDIO_EFFECTS`. */
|
|
@@ -74,6 +76,10 @@ export declare const MAX_GROUP_INPUTS = 16;
|
|
|
74
76
|
export declare const MAX_HDR_PEAK_NITS = 10000;
|
|
75
77
|
/** Mirrors `alpha2_model::MAX_INLINED_NODES`. */
|
|
76
78
|
export declare const MAX_INLINED_NODES = 65536;
|
|
79
|
+
/** Mirrors `alpha2_model::MAX_LATEX_BYTES`. */
|
|
80
|
+
export declare const MAX_LATEX_BYTES = 4096;
|
|
81
|
+
/** Mirrors `alpha2_model::MAX_LATEX_FONT_SIZE`. */
|
|
82
|
+
export declare const MAX_LATEX_FONT_SIZE = 1024;
|
|
77
83
|
/** Mirrors `alpha2_model::MAX_LAYOUT_DEPTH`. */
|
|
78
84
|
export declare const MAX_LAYOUT_DEPTH = 16;
|
|
79
85
|
/** Mirrors `alpha2_model::MAX_LAYOUT_FONT_SIZE`. */
|
|
@@ -98,6 +104,10 @@ export declare const MAX_MERGE_LAYERS = 32;
|
|
|
98
104
|
export declare const MAX_PATH_SUBPATHS = 256;
|
|
99
105
|
/** Mirrors `alpha2_model::MAX_PATH_VERTICES`. */
|
|
100
106
|
export declare const MAX_PATH_VERTICES = 4096;
|
|
107
|
+
/** Mirrors `alpha2_model::MAX_PDF_DOCUMENT_BYTES`. */
|
|
108
|
+
export declare const MAX_PDF_DOCUMENT_BYTES = 268435456;
|
|
109
|
+
/** Mirrors `alpha2_model::MAX_PDF_PAGES`. */
|
|
110
|
+
export declare const MAX_PDF_PAGES = 10000;
|
|
101
111
|
/** Mirrors `alpha2_model::MAX_POLYSTAR_POINTS`. */
|
|
102
112
|
export declare const MAX_POLYSTAR_POINTS = 100;
|
|
103
113
|
/** Mirrors `alpha2_model::MAX_PROJECT_JSON_BYTES`. */
|
|
@@ -112,6 +122,8 @@ export declare const MAX_RANGE_PERCENT = 200;
|
|
|
112
122
|
export declare const MAX_RUN_CLASSES = 8;
|
|
113
123
|
/** Mirrors `alpha2_model::MAX_SAMPLE_RATE`. */
|
|
114
124
|
export declare const MAX_SAMPLE_RATE = 96000;
|
|
125
|
+
/** Mirrors `alpha2_model::MAX_SELECTED_CHANNELS`. */
|
|
126
|
+
export declare const MAX_SELECTED_CHANNELS = 2;
|
|
115
127
|
/** Mirrors `alpha2_model::MAX_SEQUENCE_FRAMES`. */
|
|
116
128
|
export declare const MAX_SEQUENCE_FRAMES = 100000;
|
|
117
129
|
/** Mirrors `alpha2_model::MAX_SHAPE_DEPTH`. */
|
|
@@ -2070,8 +2082,8 @@ export interface ProjectSettings {
|
|
|
2070
2082
|
*/
|
|
2071
2083
|
readonly frame_rate: FrameRate;
|
|
2072
2084
|
/**
|
|
2073
|
-
* Canvas height in output pixels, at most `MAX_CANVAS_DIMENSION`. The canvas
|
|
2074
|
-
*
|
|
2085
|
+
* Canvas height in output pixels, at most `MAX_CANVAS_DIMENSION`. The canvas is at most
|
|
2086
|
+
* `MAX_CANVAS_PIXELS` in area.
|
|
2075
2087
|
*/
|
|
2076
2088
|
readonly height: number;
|
|
2077
2089
|
/**
|
|
@@ -2084,8 +2096,7 @@ export interface ProjectSettings {
|
|
|
2084
2096
|
readonly width: number;
|
|
2085
2097
|
}
|
|
2086
2098
|
/**
|
|
2087
|
-
* A source whose media an extension provider supplies
|
|
2088
|
-
* decoders.
|
|
2099
|
+
* A source whose media an extension provider supplies, not the host's video and image decoders.
|
|
2089
2100
|
*
|
|
2090
2101
|
* A host picks the provider by probing the bytes at import, never by file name, and records
|
|
2091
2102
|
* it here so every host opens the source the same way. The engine does not read it.
|
|
@@ -2154,6 +2165,51 @@ export type ProviderSource = {
|
|
|
2154
2165
|
* file has none, as OpenEXR defines).
|
|
2155
2166
|
*/
|
|
2156
2167
|
readonly primaries?: LinearPrimaries | null;
|
|
2168
|
+
} | {
|
|
2169
|
+
/**
|
|
2170
|
+
* The ink where the formula sets no `\color` of its own. White when absent.
|
|
2171
|
+
*
|
|
2172
|
+
* @defaultValue `{"alpha":1,"blue":1,"green":1,"red":1}`
|
|
2173
|
+
*/
|
|
2174
|
+
readonly color?: Rgba;
|
|
2175
|
+
/**
|
|
2176
|
+
* Display style, with large operators and limits above and below, or text style when
|
|
2177
|
+
* `false`. Display when absent.
|
|
2178
|
+
*
|
|
2179
|
+
* @defaultValue `true`
|
|
2180
|
+
*/
|
|
2181
|
+
readonly display?: boolean;
|
|
2182
|
+
/**
|
|
2183
|
+
* Pixels per em, above `0` and at most `MAX_LATEX_FONT_SIZE`.
|
|
2184
|
+
*/
|
|
2185
|
+
readonly font_size: number;
|
|
2186
|
+
/**
|
|
2187
|
+
* A LaTeX math formula typeset with the bundled STIX Two Math font. The source's kind is
|
|
2188
|
+
* `image`, and it has no locator or fingerprint since it reads no file. A formula that uses
|
|
2189
|
+
* a character the font lacks, such as Hangul in `\text`, does not open.
|
|
2190
|
+
*/
|
|
2191
|
+
readonly format: "latex";
|
|
2192
|
+
/**
|
|
2193
|
+
* Math-mode LaTeX without `$` delimiters. Non-empty, at most `MAX_LATEX_BYTES` bytes.
|
|
2194
|
+
*/
|
|
2195
|
+
readonly latex: string;
|
|
2196
|
+
} | {
|
|
2197
|
+
/**
|
|
2198
|
+
* Painted under the page, which is itself transparent. White paper when absent.
|
|
2199
|
+
*
|
|
2200
|
+
* @defaultValue `{"alpha":1,"blue":1,"green":1,"red":1}`
|
|
2201
|
+
*/
|
|
2202
|
+
readonly background?: Rgba;
|
|
2203
|
+
/**
|
|
2204
|
+
* One page of a PDF document. The source's kind is `image`.
|
|
2205
|
+
*/
|
|
2206
|
+
readonly format: "pdf";
|
|
2207
|
+
/**
|
|
2208
|
+
* The page shown, counted from `1`, at most `MAX_PDF_PAGES`. The first when absent.
|
|
2209
|
+
*
|
|
2210
|
+
* @defaultValue `1`
|
|
2211
|
+
*/
|
|
2212
|
+
readonly page?: number;
|
|
2157
2213
|
};
|
|
2158
2214
|
/**
|
|
2159
2215
|
* How selection rises and falls across a Range selector's range.
|
|
@@ -7,6 +7,8 @@ export const AUDIO_EFFECT_STATE_MARGIN_MS = 1100;
|
|
|
7
7
|
export const CURRENT_SCHEMA_VERSION = 1;
|
|
8
8
|
/** Mirrors `alpha2_model::MAX_ANIMATOR_SCALE`. */
|
|
9
9
|
export const MAX_ANIMATOR_SCALE = 10;
|
|
10
|
+
/** Mirrors `alpha2_model::MAX_AUDIO_CHANNELS`. */
|
|
11
|
+
export const MAX_AUDIO_CHANNELS = 24;
|
|
10
12
|
/** Mirrors `alpha2_model::MAX_AUDIO_DELAY_MS`. */
|
|
11
13
|
export const MAX_AUDIO_DELAY_MS = 120000;
|
|
12
14
|
/** Mirrors `alpha2_model::MAX_AUDIO_EFFECTS`. */
|
|
@@ -77,6 +79,10 @@ export const MAX_GROUP_INPUTS = 16;
|
|
|
77
79
|
export const MAX_HDR_PEAK_NITS = 10000;
|
|
78
80
|
/** Mirrors `alpha2_model::MAX_INLINED_NODES`. */
|
|
79
81
|
export const MAX_INLINED_NODES = 65536;
|
|
82
|
+
/** Mirrors `alpha2_model::MAX_LATEX_BYTES`. */
|
|
83
|
+
export const MAX_LATEX_BYTES = 4096;
|
|
84
|
+
/** Mirrors `alpha2_model::MAX_LATEX_FONT_SIZE`. */
|
|
85
|
+
export const MAX_LATEX_FONT_SIZE = 1024;
|
|
80
86
|
/** Mirrors `alpha2_model::MAX_LAYOUT_DEPTH`. */
|
|
81
87
|
export const MAX_LAYOUT_DEPTH = 16;
|
|
82
88
|
/** Mirrors `alpha2_model::MAX_LAYOUT_FONT_SIZE`. */
|
|
@@ -101,6 +107,10 @@ export const MAX_MERGE_LAYERS = 32;
|
|
|
101
107
|
export const MAX_PATH_SUBPATHS = 256;
|
|
102
108
|
/** Mirrors `alpha2_model::MAX_PATH_VERTICES`. */
|
|
103
109
|
export const MAX_PATH_VERTICES = 4096;
|
|
110
|
+
/** Mirrors `alpha2_model::MAX_PDF_DOCUMENT_BYTES`. */
|
|
111
|
+
export const MAX_PDF_DOCUMENT_BYTES = 268435456;
|
|
112
|
+
/** Mirrors `alpha2_model::MAX_PDF_PAGES`. */
|
|
113
|
+
export const MAX_PDF_PAGES = 10000;
|
|
104
114
|
/** Mirrors `alpha2_model::MAX_POLYSTAR_POINTS`. */
|
|
105
115
|
export const MAX_POLYSTAR_POINTS = 100;
|
|
106
116
|
/** Mirrors `alpha2_model::MAX_PROJECT_JSON_BYTES`. */
|
|
@@ -115,6 +125,8 @@ export const MAX_RANGE_PERCENT = 200;
|
|
|
115
125
|
export const MAX_RUN_CLASSES = 8;
|
|
116
126
|
/** Mirrors `alpha2_model::MAX_SAMPLE_RATE`. */
|
|
117
127
|
export const MAX_SAMPLE_RATE = 96000;
|
|
128
|
+
/** Mirrors `alpha2_model::MAX_SELECTED_CHANNELS`. */
|
|
129
|
+
export const MAX_SELECTED_CHANNELS = 2;
|
|
118
130
|
/** Mirrors `alpha2_model::MAX_SEQUENCE_FRAMES`. */
|
|
119
131
|
export const MAX_SEQUENCE_FRAMES = 100000;
|
|
120
132
|
/** Mirrors `alpha2_model::MAX_SHAPE_DEPTH`. */
|
|
@@ -1880,6 +1880,40 @@ export const PROJECT_SHAPE = {
|
|
|
1880
1880
|
required: ["format"],
|
|
1881
1881
|
type: "object",
|
|
1882
1882
|
},
|
|
1883
|
+
{
|
|
1884
|
+
additionalProperties: false,
|
|
1885
|
+
properties: {
|
|
1886
|
+
color: {
|
|
1887
|
+
$ref: "#/$defs/Rgba",
|
|
1888
|
+
default: { alpha: 1, blue: 1, green: 1, red: 1 },
|
|
1889
|
+
},
|
|
1890
|
+
display: { default: true, type: "boolean" },
|
|
1891
|
+
font_size: { format: "float", type: "number" },
|
|
1892
|
+
format: { const: "latex", type: "string" },
|
|
1893
|
+
latex: { type: "string" },
|
|
1894
|
+
},
|
|
1895
|
+
required: ["format", "latex", "font_size"],
|
|
1896
|
+
type: "object",
|
|
1897
|
+
},
|
|
1898
|
+
{
|
|
1899
|
+
additionalProperties: false,
|
|
1900
|
+
properties: {
|
|
1901
|
+
background: {
|
|
1902
|
+
$ref: "#/$defs/Rgba",
|
|
1903
|
+
default: { alpha: 1, blue: 1, green: 1, red: 1 },
|
|
1904
|
+
},
|
|
1905
|
+
format: { const: "pdf", type: "string" },
|
|
1906
|
+
page: {
|
|
1907
|
+
default: 1,
|
|
1908
|
+
format: "uint32",
|
|
1909
|
+
maximum: 4294967295,
|
|
1910
|
+
minimum: 0,
|
|
1911
|
+
type: "integer",
|
|
1912
|
+
},
|
|
1913
|
+
},
|
|
1914
|
+
required: ["format"],
|
|
1915
|
+
type: "object",
|
|
1916
|
+
},
|
|
1883
1917
|
],
|
|
1884
1918
|
},
|
|
1885
1919
|
RangeShape: {
|
package/dist/media.d.ts
CHANGED
|
@@ -143,7 +143,7 @@ export interface BrowserVideoDecoderOptions {
|
|
|
143
143
|
/** Loudspeaker by `FFmpeg` channel name. `UNK` planes (unknown, ambisonic) are not mixed. */
|
|
144
144
|
export type AudioSpeaker = "FL" | "FR" | "FC" | "LFE" | "BL" | "BR" | "FLC" | "FRC" | "BC" | "SL" | "SR" | "TC" | "TFL" | "TFC" | "TFR" | "TBL" | "TBC" | "TBR" | "DL" | "DR" | "WL" | "WR" | "SDL" | "SDR" | "LFE2" | "TSL" | "TSR" | "BFC" | "BFL" | "BFR" | "SSL" | "SSR" | "TTL" | "TTR" | "BIL" | "BIR" | "UNK";
|
|
145
145
|
/** A 22.2 layout's 24; sources with more are refused. */
|
|
146
|
-
export
|
|
146
|
+
export { MAX_AUDIO_CHANNELS } from "./generated/project-schema.js";
|
|
147
147
|
/** Owned project-rate planar audio returned by browser adapters. */
|
|
148
148
|
export interface BrowserAudioBlock {
|
|
149
149
|
readonly sourceId: string;
|
package/dist/media.js
CHANGED
|
@@ -456,7 +456,7 @@ export async function readMatroskaCodecDelay(container, trackId) {
|
|
|
456
456
|
return 0;
|
|
457
457
|
}
|
|
458
458
|
/** A 22.2 layout's 24; sources with more are refused. */
|
|
459
|
-
export
|
|
459
|
+
export { MAX_AUDIO_CHANNELS } from "./generated/project-schema.js";
|
|
460
460
|
/** WebCodecs adapter for elementary chunks supplied by any demuxer. */
|
|
461
461
|
export class WebCodecsVideoDecoder {
|
|
462
462
|
#sourceId;
|
package/dist/project.d.ts
CHANGED
|
@@ -143,6 +143,18 @@ export declare function canonicalPaint(paint: Paint): CanonicalPaint;
|
|
|
143
143
|
* parts seen before are not walked again.
|
|
144
144
|
*/
|
|
145
145
|
export declare function canonicalProject(project: Project): CanonicalProject;
|
|
146
|
+
/**
|
|
147
|
+
* Whether a provider reads a file of the source's own. One that does not, such as LaTeX, holds its
|
|
148
|
+
* content in its settings, so its source has an empty locator and no fingerprint. Mirrors
|
|
149
|
+
* `ProviderSource::reads_file`.
|
|
150
|
+
*/
|
|
151
|
+
export declare function providerReadsFile(provider: {
|
|
152
|
+
readonly format: string;
|
|
153
|
+
}): boolean;
|
|
154
|
+
/** The kind of source a provider's media is. Mirrors `ProviderSource::kind`. */
|
|
155
|
+
export declare function providerKind(provider: {
|
|
156
|
+
readonly format: string;
|
|
157
|
+
}): "image" | "video";
|
|
146
158
|
/** What a {@link LintIssue} is about. */
|
|
147
159
|
export type LintOwner = {
|
|
148
160
|
readonly type: "clip";
|