alpha2 0.6.2 → 0.7.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 +3 -3
- package/dist/effects.d.ts +3 -2
- package/dist/export-failure.d.ts +6 -0
- package/dist/export-failure.js +18 -1
- package/dist/export-retry.d.ts +2 -1
- package/dist/export-retry.js +12 -5
- package/dist/extract.d.ts +0 -5
- package/dist/extract.js +5 -12
- package/dist/extractor.d.ts +16 -3
- package/dist/extractor.js +2 -1
- package/dist/generated/project-schema.d.ts +31 -1
- package/dist/generated/project-schema.js +5 -0
- package/dist/generated/project-shape.js +14 -1
- package/dist/gpu-recovery.d.ts +13 -5
- package/dist/gpu-recovery.js +19 -8
- package/dist/hdr-frames.js +2 -0
- package/dist/media-source.d.ts +3 -0
- package/dist/media-source.js +13 -0
- package/dist/media.d.ts +12 -1
- package/dist/media.js +15 -1
- package/dist/mediabunny.d.ts +4 -1
- package/dist/mediabunny.js +22 -23
- package/dist/player.js +2 -0
- package/dist/plugin-manifest.d.ts +119 -0
- package/dist/plugin-manifest.js +583 -0
- package/dist/plugin-supplied.d.ts +55 -0
- package/dist/plugin-supplied.js +221 -0
- package/dist/plugins.d.ts +87 -9
- package/dist/plugins.js +196 -47
- package/dist/project-data.d.ts +19 -0
- package/dist/project-data.js +210 -7
- package/dist/project.d.ts +1 -1
- package/dist/project.js +1 -1
- package/dist/sha256.d.ts +1 -1
- package/package.json +1 -1
- package/wasm/alpha2_compose_bg.wasm +0 -0
- package/wasm/alpha2_extensions_bg.wasm +0 -0
- package/wasm/alpha2_extensions_pdf_bg.wasm +0 -0
- package/wasm/alpha2_wasm.d.ts +14 -12
- package/wasm/alpha2_wasm.js +54 -52
- package/wasm/alpha2_wasm_bg.wasm +0 -0
- package/wasm/alpha2_wasm_bg.wasm.d.ts +6 -6
- /package/wasm/snippets/{alpha2-wasm-d984447de3610be7/inline4.js → alpha2-wasm-7cccf477e10e3d0d/inline0.js} +0 -0
- /package/wasm/snippets/{alpha2-wasm-d984447de3610be7/inline0.js → alpha2-wasm-7cccf477e10e3d0d/inline1.js} +0 -0
- /package/wasm/snippets/{alpha2-wasm-d984447de3610be7/inline1.js → alpha2-wasm-7cccf477e10e3d0d/inline2.js} +0 -0
- /package/wasm/snippets/{alpha2-wasm-d984447de3610be7/inline2.js → alpha2-wasm-7cccf477e10e3d0d/inline3.js} +0 -0
- /package/wasm/snippets/{alpha2-wasm-d984447de3610be7/inline3.js → alpha2-wasm-7cccf477e10e3d0d/inline4.js} +0 -0
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
// Files for a plugin's resource slots, resolved and read as host-core's `ResourceSet` does.
|
|
2
|
+
import { MAX_SUPPLIED_FILES, MAX_SUPPLIED_NAME_BYTES, } from "./generated/project-schema.js";
|
|
3
|
+
import { MAX_PLUGIN_RESOURCE_BYTES, PluginError, } from "./plugin-manifest.js";
|
|
4
|
+
import { Sha256 } from "./sha256.js";
|
|
5
|
+
/** Mirrors `alpha2_host_core::plugins::MAX_SLOT_DEPTH`: directories below a slot's own. */
|
|
6
|
+
export const MAX_SLOT_DEPTH = 8;
|
|
7
|
+
const encoder = new TextEncoder();
|
|
8
|
+
function byteOrder(a, b) {
|
|
9
|
+
const left = encoder.encode(a);
|
|
10
|
+
const right = encoder.encode(b);
|
|
11
|
+
for (let index = 0; index < Math.min(left.length, right.length); index++)
|
|
12
|
+
if (left[index] !== right[index])
|
|
13
|
+
return left[index] - right[index];
|
|
14
|
+
return left.length - right.length;
|
|
15
|
+
}
|
|
16
|
+
function invalid(slot, reason, message) {
|
|
17
|
+
return new PluginError("PLUGIN_RESOURCE_INVALID", message, {
|
|
18
|
+
details: { slot, reason },
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function fetchFailed(name, cause) {
|
|
22
|
+
return new PluginError("PLUGIN_FETCH_FAILED", `${name} could not be read: ${String(cause)}`, { cause });
|
|
23
|
+
}
|
|
24
|
+
const isDirectoryHandle = (value) => typeof value === "object" &&
|
|
25
|
+
value !== null &&
|
|
26
|
+
value.kind === "directory" &&
|
|
27
|
+
typeof value.entries === "function";
|
|
28
|
+
async function walkHandle(slot, handle, below, found) {
|
|
29
|
+
if (below.length > MAX_SLOT_DEPTH)
|
|
30
|
+
throw invalid(slot, "too_deep", `${[slot, ...below].join("/")} lies more than ${MAX_SLOT_DEPTH} directories below slot ${slot}`);
|
|
31
|
+
const entries = [];
|
|
32
|
+
try {
|
|
33
|
+
for await (const entry of handle.entries())
|
|
34
|
+
entries.push(entry);
|
|
35
|
+
}
|
|
36
|
+
catch (cause) {
|
|
37
|
+
throw fetchFailed([slot, ...below].join("/"), cause);
|
|
38
|
+
}
|
|
39
|
+
entries.sort(([a], [b]) => byteOrder(a, b));
|
|
40
|
+
for (const [name, entry] of entries) {
|
|
41
|
+
if (name.startsWith("."))
|
|
42
|
+
continue;
|
|
43
|
+
const path = [...below, name];
|
|
44
|
+
if (entry.kind === "directory")
|
|
45
|
+
await walkHandle(slot, entry, path, found);
|
|
46
|
+
else {
|
|
47
|
+
let file;
|
|
48
|
+
try {
|
|
49
|
+
file = await entry.getFile();
|
|
50
|
+
}
|
|
51
|
+
catch (cause) {
|
|
52
|
+
throw fetchFailed([slot, ...path].join("/"), cause);
|
|
53
|
+
}
|
|
54
|
+
found.push([path, file]);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function pickedFiles(slot, files) {
|
|
59
|
+
const found = [];
|
|
60
|
+
for (const file of files) {
|
|
61
|
+
const parts = (file.webkitRelativePath || file.name).split("/").slice(1);
|
|
62
|
+
if (parts.length === 0 || parts.some((part) => part === ""))
|
|
63
|
+
throw invalid(slot, "shape", `slot ${slot} takes a directory; ${file.name} has no path below a picked directory`);
|
|
64
|
+
if (parts.some((part) => part.startsWith(".")))
|
|
65
|
+
continue;
|
|
66
|
+
if (parts.length - 1 > MAX_SLOT_DEPTH)
|
|
67
|
+
throw invalid(slot, "too_deep", `${[slot, ...parts].join("/")} lies more than ${MAX_SLOT_DEPTH} directories below slot ${slot}`);
|
|
68
|
+
found.push([parts, file]);
|
|
69
|
+
}
|
|
70
|
+
return found;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Resolves the slots of `manifest` from `supplied`, refusing what host-core's loader refuses,
|
|
74
|
+
* with the same `details.reason`. Nothing is read; directory handles are walked.
|
|
75
|
+
*/
|
|
76
|
+
export async function resolveSupplied(manifest, supplied) {
|
|
77
|
+
const slots = (manifest.resources ?? []).filter((resource) => resource.supplied !== undefined);
|
|
78
|
+
const unknown = Object.keys(supplied).find((name) => !slots.some((slot) => slot.name === name));
|
|
79
|
+
if (unknown !== undefined)
|
|
80
|
+
throw invalid(unknown, "unknown_slot", `${manifest.id} declares no resource slot ${unknown}`);
|
|
81
|
+
const files = new Map();
|
|
82
|
+
const context = {};
|
|
83
|
+
for (const { name, supplied: slot } of [...slots].sort((a, b) => byteOrder(a.name, b.name))) {
|
|
84
|
+
const source = supplied[name];
|
|
85
|
+
if (source === undefined) {
|
|
86
|
+
if (slot.required !== false)
|
|
87
|
+
throw invalid(name, "missing", `${manifest.id} needs a file for its resource slot ${name}`);
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
const maxBytes = slot.max_bytes;
|
|
91
|
+
let offered;
|
|
92
|
+
if (slot.shape === "file") {
|
|
93
|
+
if (!(source instanceof Blob))
|
|
94
|
+
throw invalid(name, "shape", `slot ${name} takes a file; it was given a directory`);
|
|
95
|
+
const file = source;
|
|
96
|
+
if (maxBytes !== undefined && file.size > maxBytes)
|
|
97
|
+
throw invalid(name, "too_large", `${name} is ${file.size} bytes; slot ${name} takes at most ${maxBytes}`);
|
|
98
|
+
if (file.size > MAX_PLUGIN_RESOURCE_BYTES)
|
|
99
|
+
throw invalid(name, "too_large", `${name} is ${file.size} bytes; a wasm plugin reads at most ${MAX_PLUGIN_RESOURCE_BYTES}`);
|
|
100
|
+
offered = [[name, file]];
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
let found;
|
|
104
|
+
if (isDirectoryHandle(source)) {
|
|
105
|
+
found = [];
|
|
106
|
+
await walkHandle(name, source, [], found);
|
|
107
|
+
}
|
|
108
|
+
else if (Array.isArray(source))
|
|
109
|
+
found = pickedFiles(name, source);
|
|
110
|
+
else
|
|
111
|
+
throw invalid(name, "shape", `slot ${name} takes a directory; it was given a file`);
|
|
112
|
+
offered = found.map(([path, file]) => [
|
|
113
|
+
`${name}/${path.join("/")}`,
|
|
114
|
+
file,
|
|
115
|
+
]);
|
|
116
|
+
for (const [resource] of offered)
|
|
117
|
+
if (encoder.encode(resource).length > MAX_SUPPLIED_NAME_BYTES)
|
|
118
|
+
throw invalid(name, "name_too_long", `${resource} is longer than ${MAX_SUPPLIED_NAME_BYTES} bytes`);
|
|
119
|
+
offered.sort(([a], [b]) => byteOrder(a, b));
|
|
120
|
+
}
|
|
121
|
+
if (files.size + offered.length > MAX_SUPPLIED_FILES)
|
|
122
|
+
throw invalid(name, "too_many_files", `slot ${name} brings the run's supplied files past ${MAX_SUPPLIED_FILES}`);
|
|
123
|
+
for (const [resource, file] of offered)
|
|
124
|
+
files.set(resource, { slot: name, file, maxBytes });
|
|
125
|
+
context[name] = {
|
|
126
|
+
shape: slot.shape,
|
|
127
|
+
files: offered.map(([resource, file]) => ({
|
|
128
|
+
name: resource,
|
|
129
|
+
bytes: file.size,
|
|
130
|
+
})),
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
return { files, context };
|
|
134
|
+
}
|
|
135
|
+
const READ_STEP_BYTES = 8 * 1024 * 1024;
|
|
136
|
+
/**
|
|
137
|
+
* Serves one run's reads of supplied files synchronously, as wasm imports must: in a worker
|
|
138
|
+
* through `FileReaderSync`, step by step; on a page, from bytes read beforehand by
|
|
139
|
+
* {@link SuppliedReader.prepare}. Each file is hashed the first time it is read.
|
|
140
|
+
*/
|
|
141
|
+
export class SuppliedReader {
|
|
142
|
+
#set;
|
|
143
|
+
#read = new Map();
|
|
144
|
+
#held;
|
|
145
|
+
#sync;
|
|
146
|
+
constructor(set) {
|
|
147
|
+
this.#set = set;
|
|
148
|
+
}
|
|
149
|
+
/** Reads every offered file into memory where no synchronous file read exists. */
|
|
150
|
+
async prepare() {
|
|
151
|
+
const FileReaderSync = globalThis.FileReaderSync;
|
|
152
|
+
if (FileReaderSync !== undefined) {
|
|
153
|
+
this.#sync = new FileReaderSync();
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (this.#set.files.size === 0)
|
|
157
|
+
return;
|
|
158
|
+
const held = new Map();
|
|
159
|
+
for (const [name, { file }] of this.#set.files) {
|
|
160
|
+
try {
|
|
161
|
+
held.set(name, new Uint8Array(await file.arrayBuffer()));
|
|
162
|
+
}
|
|
163
|
+
catch (cause) {
|
|
164
|
+
throw fetchFailed(name, cause);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
this.#held = held;
|
|
168
|
+
}
|
|
169
|
+
/** The length of the supplied resource `name`, or `undefined` for another name. */
|
|
170
|
+
size(name) {
|
|
171
|
+
return this.#set.files.get(name)?.file.size;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Copies the supplied resource `name` into `target`, its length exactly. Throws the failure the
|
|
175
|
+
* call it happened in ends with: `PLUGIN_RESOURCE_INVALID` (`too_large`) past the slot's
|
|
176
|
+
* `max_bytes`, `PLUGIN_FETCH_FAILED` for a file that could not be read or changed.
|
|
177
|
+
*/
|
|
178
|
+
read(name, target) {
|
|
179
|
+
const offered = this.#set.files.get(name);
|
|
180
|
+
if (offered === undefined)
|
|
181
|
+
throw new Error(`no supplied resource ${name}`);
|
|
182
|
+
const { file, maxBytes, slot } = offered;
|
|
183
|
+
if (maxBytes !== undefined && file.size > maxBytes)
|
|
184
|
+
throw invalid(slot, "too_large", `${name} is ${file.size} bytes; slot ${slot} takes at most ${maxBytes}`);
|
|
185
|
+
const known = this.#read.get(name);
|
|
186
|
+
const hash = known === undefined ? new Sha256() : undefined;
|
|
187
|
+
const held = this.#held?.get(name);
|
|
188
|
+
if (held !== undefined) {
|
|
189
|
+
if (held.byteLength !== target.byteLength)
|
|
190
|
+
throw fetchFailed(name, "its length changed");
|
|
191
|
+
target.set(held);
|
|
192
|
+
hash?.update(held);
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
const reader = this.#sync;
|
|
196
|
+
if (reader === undefined)
|
|
197
|
+
throw new Error("the supplied files were not prepared");
|
|
198
|
+
for (let at = 0; at < target.byteLength; at += READ_STEP_BYTES) {
|
|
199
|
+
let step;
|
|
200
|
+
try {
|
|
201
|
+
step = new Uint8Array(reader.readAsArrayBuffer(file.slice(at, Math.min(at + READ_STEP_BYTES, target.byteLength))));
|
|
202
|
+
}
|
|
203
|
+
catch (cause) {
|
|
204
|
+
throw fetchFailed(name, cause);
|
|
205
|
+
}
|
|
206
|
+
if (step.byteLength !== Math.min(READ_STEP_BYTES, target.byteLength - at))
|
|
207
|
+
throw fetchFailed(name, "it changed while the plugin read it");
|
|
208
|
+
target.set(step, at);
|
|
209
|
+
hash?.update(step);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
if (hash !== undefined)
|
|
213
|
+
this.#read.set(name, { sha256: hash.hex(), bytes: target.byteLength });
|
|
214
|
+
}
|
|
215
|
+
/** The files read so far, as `made_by.plugin.supplied` records them. */
|
|
216
|
+
supplied() {
|
|
217
|
+
return [...this.#read]
|
|
218
|
+
.sort(([a], [b]) => byteOrder(a, b))
|
|
219
|
+
.map(([name, { sha256, bytes }]) => ({ name, sha256, bytes }));
|
|
220
|
+
}
|
|
221
|
+
}
|
package/dist/plugins.d.ts
CHANGED
|
@@ -1,12 +1,46 @@
|
|
|
1
|
-
import type { Extractor, ExtractorDescriptor } from "./
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { Extractor, ExtractorDescriptor } from "./extractor.js";
|
|
2
|
+
import { type SuppliedSet, type SuppliedSource } from "./plugin-supplied.js";
|
|
3
|
+
import { type PluginAbout, type PluginManifest } from "./plugin-manifest.js";
|
|
4
|
+
export { MAX_ABOUT_AUTHOR_CHARS, MAX_ABOUT_HOMEPAGE_CHARS, MAX_ABOUT_LICENSE_CHARS, MAX_ABOUT_NAME_CHARS, MAX_ABOUT_SUMMARY_CHARS, MAX_EXTRACTOR_OUTPUTS, MAX_MANIFEST_BYTES, MAX_OUTPUT_DESCRIPTION_CHARS, MAX_OUTPUT_LABEL_CHARS, MAX_PLUGIN_ARTIFACT_BYTES, MAX_PLUGIN_ARTIFACTS, MAX_PLUGIN_RESOURCE_BYTES, MAX_PLUGIN_RESOURCES, MAX_PLUGIN_RESOURCES_TOTAL_BYTES, MAX_PLUGIN_SLOTS, MAX_SLOT_ACCEPT, MAX_SLOT_ACCEPT_BYTES, MAX_SLOT_NAME_BYTES, PLUGIN_ABI, PluginError, parsePluginManifest, } from "./plugin-manifest.js";
|
|
5
|
+
export { MAX_SLOT_DEPTH, type SuppliedSource } from "./plugin-supplied.js";
|
|
6
|
+
export type { PinnedPluginResource, PluginAbout, PluginArtifact, PluginManifest, PluginResource, SuppliedPluginResource, } from "./plugin-manifest.js";
|
|
7
|
+
/** What a place that runs plugins can run, so an interface offers only the plugins it can. */
|
|
8
|
+
export interface PluginCapabilities {
|
|
9
|
+
/** The clocks each media is read on. */
|
|
10
|
+
readonly inputs: {
|
|
11
|
+
readonly video: readonly ("source" | "timeline")[];
|
|
12
|
+
readonly audio: readonly ("source" | "timeline")[];
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The artifacts that run: `wasm`, and `native` where native code is allowed, for the runner's
|
|
16
|
+
* own target, which a manifest alone does not show.
|
|
17
|
+
*/
|
|
18
|
+
readonly artifacts: readonly ("wasm" | "native")[];
|
|
19
|
+
/** Whether a run may fill resource slots. */
|
|
20
|
+
readonly slots: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** Why a plugin cannot run somewhere, by {@link pluginProblem}. */
|
|
23
|
+
export interface PluginProblem {
|
|
24
|
+
/**
|
|
25
|
+
* `artifact`: no artifact of a kind that runs there; `slots`: a required slot, where none is
|
|
26
|
+
* filled; `input`: none of the clocks it reads its media on.
|
|
27
|
+
*/
|
|
28
|
+
readonly reason: "artifact" | "slots" | "input";
|
|
29
|
+
readonly message: string;
|
|
30
|
+
}
|
|
31
|
+
/** Why `manifest`'s plugin cannot run where `capabilities` say, or `undefined` when it can. */
|
|
32
|
+
export declare function pluginProblem(manifest: PluginManifest, capabilities: PluginCapabilities): PluginProblem | undefined;
|
|
4
33
|
/** Linear memory a plugin may grow to when the caller sets no cap. */
|
|
5
34
|
export declare const DEFAULT_PLUGIN_MEMORY_BYTES: number;
|
|
6
|
-
/**
|
|
7
|
-
export
|
|
8
|
-
readonly
|
|
9
|
-
|
|
35
|
+
/** How far {@link loadPlugin} has read one of the files the manifest pins. */
|
|
36
|
+
export interface PluginLoadProgress {
|
|
37
|
+
readonly phase: "load";
|
|
38
|
+
/** The file's `url` as the manifest writes it. */
|
|
39
|
+
readonly file: string;
|
|
40
|
+
/** Bytes read so far. */
|
|
41
|
+
readonly loaded: number;
|
|
42
|
+
/** The length the manifest pins. */
|
|
43
|
+
readonly total: number;
|
|
10
44
|
}
|
|
11
45
|
/** Where {@link loadPlugin} reads a plugin from. */
|
|
12
46
|
export interface LoadPluginOptions {
|
|
@@ -15,6 +49,10 @@ export interface LoadPluginOptions {
|
|
|
15
49
|
/** Fetches the manifest's files; `globalThis.fetch` when left out. */
|
|
16
50
|
readonly fetch?: typeof fetch;
|
|
17
51
|
readonly signal?: AbortSignal;
|
|
52
|
+
/** Called as each artifact and resource arrives, after each chunk of its body. */
|
|
53
|
+
readonly onProgress?: (progress: PluginLoadProgress) => void;
|
|
54
|
+
/** What fills each resource slot, by the slot's name. */
|
|
55
|
+
readonly supplied?: Readonly<Record<string, SuppliedSource>>;
|
|
18
56
|
}
|
|
19
57
|
/** A loaded plugin: its manifest's identity and an extractor per run. */
|
|
20
58
|
export interface LoadedPlugin {
|
|
@@ -22,6 +60,10 @@ export interface LoadedPlugin {
|
|
|
22
60
|
readonly version: string;
|
|
23
61
|
/** SHA-256 of the artifact that runs, as `made_by.plugin` records it. */
|
|
24
62
|
readonly artifactSha256: string;
|
|
63
|
+
/** SHA-256 of the manifest's bytes in lowercase, as `made_by.plugin` records it. */
|
|
64
|
+
readonly manifestSha256: string;
|
|
65
|
+
/** What the manifest's `about` says for an interface, when it has one. */
|
|
66
|
+
readonly about?: PluginAbout;
|
|
25
67
|
readonly descriptor: ExtractorDescriptor;
|
|
26
68
|
/** An extractor that runs the module with `params`; each run instantiates it anew. */
|
|
27
69
|
extractor(params?: Readonly<Record<string, unknown>>): Extractor;
|
|
@@ -54,9 +96,45 @@ export declare function decodeRecords(batch: Uint8Array): PluginRecord[];
|
|
|
54
96
|
* whose bytes have SHA-256 `sha256`, with its wasm artifact and resources, each checked against
|
|
55
97
|
* the hash and length the manifest pins.
|
|
56
98
|
*
|
|
99
|
+
* `supplied` fills the manifest's resource slots as `docs/plugin-abi.md` describes, with the
|
|
100
|
+
* limits and refusals of the native loaders: a `File` for a `file` slot, a directory handle or a
|
|
101
|
+
* directory picker's `File`s for a `directory` slot. They are resolved before any file is fetched
|
|
102
|
+
* and read when the plugin asks for one, in a worker; on a page, where browsers read files only
|
|
103
|
+
* asynchronously, every file of the filled slots is read into memory as a run begins. A run records
|
|
104
|
+
* the files it read in `made_by.plugin.supplied`.
|
|
105
|
+
*
|
|
106
|
+
* The manifest is checked as {@link parsePluginManifest} checks it before any other file is
|
|
107
|
+
* fetched; a file is refused as soon as more bytes arrive than the manifest pins. `onProgress`
|
|
108
|
+
* reports each pinned file as it arrives.
|
|
109
|
+
*
|
|
57
110
|
* Rejects with a {@link PluginError} whose code is `PLUGIN_FETCH_FAILED`, `PLUGIN_HASH_MISMATCH`,
|
|
58
111
|
* `PLUGIN_ABI_UNSUPPORTED`, `PLUGIN_NO_ARTIFACT` (no wasm artifact), `PLUGIN_UNSUPPORTED_FEATURE`,
|
|
59
|
-
* `PLUGIN_LOAD_FAILED` or `
|
|
112
|
+
* `PLUGIN_LOAD_FAILED`, `PLUGIN_DESCRIPTOR_MISMATCH` or `PLUGIN_RESOURCE_INVALID` (a slot
|
|
113
|
+
* `supplied` does not fill as the manifest asks, `details` `{ slot, reason }`).
|
|
60
114
|
*/
|
|
61
115
|
export declare function loadPlugin(manifest: string | URL, sha256: string, options?: LoadPluginOptions): Promise<LoadedPlugin>;
|
|
62
|
-
|
|
116
|
+
/** What a loaded plugin is made of, every part of which `structuredClone` copies. */
|
|
117
|
+
export interface PluginParts {
|
|
118
|
+
readonly id: string;
|
|
119
|
+
readonly version: string;
|
|
120
|
+
readonly artifactSha256: string;
|
|
121
|
+
readonly manifestSha256: string;
|
|
122
|
+
readonly about?: PluginAbout;
|
|
123
|
+
readonly descriptor: ExtractorDescriptor;
|
|
124
|
+
readonly module: WebAssembly.Module;
|
|
125
|
+
readonly resources: ReadonlyMap<string, Uint8Array>;
|
|
126
|
+
readonly supplied: SuppliedSet;
|
|
127
|
+
readonly memoryBytes: number;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* A loaded plugin as a value `postMessage` copies to a worker of the same page: its compiled
|
|
131
|
+
* module, its checked resources and the files that fill its slots. {@link restorePlugin} makes it
|
|
132
|
+
* a plugin again there, without fetching or compiling anything.
|
|
133
|
+
*/
|
|
134
|
+
export interface TransferablePlugin {
|
|
135
|
+
readonly alpha2Plugin: PluginParts;
|
|
136
|
+
}
|
|
137
|
+
/** `plugin` as a value a worker can be posted; `plugin` is one {@link loadPlugin} gave. */
|
|
138
|
+
export declare function transferablePlugin(plugin: LoadedPlugin): TransferablePlugin;
|
|
139
|
+
/** The plugin {@link transferablePlugin} made `transferred` of, as it was loaded. */
|
|
140
|
+
export declare function restorePlugin(transferred: TransferablePlugin): LoadedPlugin;
|