@alpha2-sh/editor 0.4.6 → 0.5.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.
Files changed (81) hide show
  1. package/dist/browser/bridge.d.ts +15 -16
  2. package/dist/browser/bridge.js +396 -312
  3. package/dist/browser/extensions-worker.d.ts +12 -16
  4. package/dist/browser/extensions-worker.js +17 -24
  5. package/dist/browser/hash-worker.d.ts +4 -5
  6. package/dist/browser/hash-worker.js +7 -8
  7. package/dist/browser/jobs.d.ts +17 -19
  8. package/dist/browser/jobs.js +41 -28
  9. package/dist/browser/resources.d.ts +6 -11
  10. package/dist/browser/resources.js +5 -9
  11. package/dist/browser/runtime/assets.d.ts +47 -28
  12. package/dist/browser/runtime/assets.js +129 -45
  13. package/dist/browser/runtime/audio.d.ts +16 -11
  14. package/dist/browser/runtime/audio.js +58 -31
  15. package/dist/browser/runtime/budget.d.ts +4 -5
  16. package/dist/browser/runtime/budget.js +4 -5
  17. package/dist/browser/runtime/caption-fonts.d.ts +3 -7
  18. package/dist/browser/runtime/caption-fonts.js +4 -8
  19. package/dist/browser/runtime/engine.d.ts +39 -44
  20. package/dist/browser/runtime/engine.js +78 -64
  21. package/dist/browser/runtime/export-audio.d.ts +6 -6
  22. package/dist/browser/runtime/export-audio.js +8 -9
  23. package/dist/browser/runtime/exporter.d.ts +33 -66
  24. package/dist/browser/runtime/exporter.js +111 -137
  25. package/dist/browser/runtime/extension-import.d.ts +28 -35
  26. package/dist/browser/runtime/extension-import.js +36 -46
  27. package/dist/browser/runtime/fingerprint.d.ts +11 -14
  28. package/dist/browser/runtime/fingerprint.js +20 -24
  29. package/dist/browser/runtime/generators.d.ts +2 -3
  30. package/dist/browser/runtime/generators.js +5 -7
  31. package/dist/browser/runtime/locks.d.ts +5 -7
  32. package/dist/browser/runtime/locks.js +5 -7
  33. package/dist/browser/runtime/output.d.ts +7 -9
  34. package/dist/browser/runtime/output.js +17 -21
  35. package/dist/browser/runtime/preview-utils.js +10 -6
  36. package/dist/browser/runtime/proxies.d.ts +10 -17
  37. package/dist/browser/runtime/proxies.js +33 -45
  38. package/dist/browser/runtime/proxy-storage.d.ts +15 -19
  39. package/dist/browser/runtime/proxy-storage.js +20 -24
  40. package/dist/browser/runtime/sources.d.ts +23 -31
  41. package/dist/browser/runtime/sources.js +85 -103
  42. package/dist/browser/runtime/staging.d.ts +2 -6
  43. package/dist/browser/runtime/staging.js +7 -11
  44. package/dist/browser/runtime/still.d.ts +2 -6
  45. package/dist/browser/runtime/still.js +6 -12
  46. package/dist/browser/runtime/text.d.ts +14 -0
  47. package/dist/browser/runtime/text.js +27 -0
  48. package/dist/browser/runtime/wasm.d.ts +4 -5
  49. package/dist/browser/runtime/wasm.js +4 -5
  50. package/dist/browser/types.d.ts +233 -238
  51. package/dist/browser/worker.d.ts +8 -9
  52. package/dist/browser/worker.js +50 -21
  53. package/dist/core/captions.d.ts +8 -10
  54. package/dist/core/captions.js +10 -18
  55. package/dist/core/clip-time.d.ts +8 -10
  56. package/dist/core/clip-time.js +12 -15
  57. package/dist/core/commands.d.ts +46 -46
  58. package/dist/core/commands.js +38 -36
  59. package/dist/core/compositions.d.ts +78 -112
  60. package/dist/core/compositions.js +66 -94
  61. package/dist/core/document.d.ts +59 -92
  62. package/dist/core/document.js +64 -90
  63. package/dist/core/keyframes.d.ts +11 -12
  64. package/dist/core/keyframes.js +11 -13
  65. package/dist/core/presets.d.ts +14 -20
  66. package/dist/core/presets.js +12 -18
  67. package/dist/core/session.d.ts +26 -38
  68. package/dist/core/session.js +38 -53
  69. package/dist/core/text.d.ts +2 -3
  70. package/dist/core/text.js +2 -3
  71. package/dist/core/timeline-index.d.ts +2 -3
  72. package/dist/core/timeline-index.js +11 -7
  73. package/dist/core/transitions.js +4 -5
  74. package/dist/core/validated.d.ts +6 -7
  75. package/dist/core/validated.js +8 -11
  76. package/dist/native-client/index.d.ts +31 -32
  77. package/dist/native-client/index.js +40 -41
  78. package/dist/ports/index.d.ts +19 -20
  79. package/dist/react/index.d.ts +5 -6
  80. package/dist/react/index.js +5 -6
  81. package/package.json +4 -4
@@ -1,14 +1,10 @@
1
- /**
2
- * Whether the start of a file could be an SVG, a GIF, an animated WebP, an APNG, a Lottie or
3
- * dotLottie, or an OpenEXR image.
4
- */
1
+ /** Whether a file's start could be SVG, GIF, animated WebP, APNG, Lottie, dotLottie or OpenEXR. */
5
2
  export function mayBeExtension(head: any): boolean;
6
3
  /**
7
- * The most bytes the engine reads of a file that could be one of the document formats a provider
8
- * parses whole, by its start, with what the file is called: a dotLottie package (a ZIP,
9
- * `MAX_PROVIDER_DOCUMENT_BYTES`), a Lottie animation (a JSON object, `MAX_LOTTIE_DOCUMENT_BYTES`)
10
- * or an SVG (XML, `MAX_SVG_DOCUMENT_BYTES`); `null` for any other file. A larger file is refused
11
- * before it is read.
4
+ * The byte limit for a file that could be a document format a provider parses whole, by its start:
5
+ * dotLottie (ZIP, `MAX_PROVIDER_DOCUMENT_BYTES`), Lottie (JSON, `MAX_LOTTIE_DOCUMENT_BYTES`) or
6
+ * SVG (XML, `MAX_SVG_DOCUMENT_BYTES`), with the format's name; `null` for other files. Larger
7
+ * files are refused unread.
12
8
  */
13
9
  export function providerDocumentLimit(head: any): {
14
10
  limit: number;
@@ -17,8 +13,8 @@ export function providerDocumentLimit(head: any): {
17
13
  /** The duration of a provider's timing in seconds, or 0 for a still. */
18
14
  export function timingSeconds(timing: any): number;
19
15
  /**
20
- * A small preview of a rendered frame (premultiplied, sRGB RGBA8 or linear half floats) as an image
21
- * URL, {@link THUMBNAIL_WIDTH} wide at most. Only one pixel per thumbnail pixel is converted.
16
+ * A small preview of a rendered frame (premultiplied sRGB RGBA8 or linear half floats) as an image
17
+ * URL at most {@link THUMBNAIL_WIDTH} wide. Only sampled pixels are converted.
22
18
  */
23
19
  export function thumbnailOf(frame: any): Promise<{
24
20
  dataUrl: any;
@@ -26,17 +22,15 @@ export function thumbnailOf(frame: any): Promise<{
26
22
  height: number;
27
23
  }>;
28
24
  /**
29
- * The provider a relinked file opens with: the defaults {@link stageProviderFile} staged it with,
30
- * carrying the choices the project `recorded` for that source where the new file still offers them.
31
- * A package's animation stays while the package has it; an OpenEXR still's primaries stay while the
32
- * file is one whose primaries can be chosen.
25
+ * The provider a relinked file opens with: the defaults {@link stageProviderFile} staged, plus the
26
+ * choices `recorded` for the source where the new file still offers them (a package's animation,
27
+ * an OpenEXR still's primaries).
33
28
  */
34
29
  export function keepProviderChoices(recorded: any, staged: any, report: any): any;
35
30
  /**
36
- * What import reads of a file with the provider module `extensions`: the provider that claims its
37
- * `bytes`, what probing found, and a thumbnail of its first frame; `null` when no provider claims
38
- * them. The source is opened as import records it, so a file that probes but does not open is
39
- * refused here.
31
+ * What import reads of `bytes` with provider module `extensions`: the claiming provider, the probe
32
+ * report and a first-frame thumbnail; `null` when no provider claims them. The source is opened as
33
+ * import records it, so a file that probes but does not open is refused here.
40
34
  *
41
35
  * @throws When a provider claims the bytes and cannot read them.
42
36
  */
@@ -55,13 +49,13 @@ export function readProviderFile(extensions: any, bytes: any): Promise<{
55
49
  };
56
50
  } | null>;
57
51
  /**
58
- * The diagnostics an SVG's report gives when it is opened with `fonts`, the stack its text draws
59
- * with: which of its text no font draws (`missing_font`).
52
+ * An SVG's diagnostics when opened with font stack `fonts`, listing text no font draws
53
+ * (`missing_font`).
60
54
  */
61
55
  export function svgDiagnostics(extensions: any, provider: any, bytes: any, fonts: any): any;
62
56
  /**
63
- * Stages a file a provider claimed, from what {@link readProviderFile} read of it: a still SVG is
64
- * an image source, an animation a video source of one cycle (repetition is the clip's).
57
+ * Stages a provider-claimed file from what {@link readProviderFile} read: a still SVG is an image
58
+ * source, an animation a video source of one cycle (repetition is the clip's).
65
59
  */
66
60
  export function stageProviderFile(file: any, { report, provider, thumbnail }: {
67
61
  report: any;
@@ -98,12 +92,11 @@ export function stageProviderFile(file: any, { report, provider, thumbnail }: {
98
92
  };
99
93
  };
100
94
  /**
101
- * How numbered files make one image sequence, from their names alone: the frame number each name
102
- * ends with, before its extension, fixes the order. Answers the first and last numbers, how many
103
- * frames the sequence has (every number between them), how many of those no file has, and the first
104
- * few of them; or, when the names cannot make a sequence, why: a name without a number, a number
105
- * listed twice, a number past 2^53 - 1 (a project document cannot hold it exactly), or more numbers
106
- * between the first and last than a sequence may have. Nothing here walks the numbers between them.
95
+ * How numbered files form one image sequence from their names alone: the frame number before each
96
+ * name's extension fixes the order. Answers the first and last numbers, the frame count (every
97
+ * number between them), how many have no file, and the first few gaps. Otherwise answers why not:
98
+ * a name without a number, a duplicate number, a number past 2^53 - 1 (a document cannot hold it
99
+ * exactly), or too many frames. Never walks the numbers in between.
107
100
  *
108
101
  * @param {readonly string[]} names
109
102
  * @returns {{ ok: true, first: number, last: number, frames: number, missing: number, gaps: number[] } | { ok: false, code: string, message: string }}
@@ -122,10 +115,10 @@ export function sequenceNumbering(names: readonly string[]): {
122
115
  };
123
116
  /**
124
117
  * Stages numbered PNGs or OpenEXR images as one image sequence at `frameRate`. The numbers fix the
125
- * order and the first frame; a gap is refused unless `missing` says to hold or blank it, and every
126
- * frame must be the first one's format and size. `openExr(file)` answers what the provider module
127
- * makes of an OpenEXR sequence's first frame (see {@link exrFirstFrame}): its thumbnail and report.
128
- * `id` names the source (a relink stages under the asset's own), a new one by default.
118
+ * order and first frame; a gap is refused unless `missing` holds or blanks it, and every frame must
119
+ * match the first one's format and size. `openExr(file)` returns the provider module's thumbnail
120
+ * and report for an OpenEXR first frame (see {@link exrFirstFrame}). `id` names the source (a
121
+ * relink uses the asset's own), new by default.
129
122
  */
130
123
  export function stageSequence(files: any, { frameRate, missing, openExr, id }: {
131
124
  frameRate: any;
@@ -183,8 +176,8 @@ export function stageSequence(files: any, { frameRate, missing, openExr, id }: {
183
176
  dispose(): void;
184
177
  }>;
185
178
  /**
186
- * An OpenEXR frame's thumbnail, sampled from the frame the provider module `extensions` renders at
187
- * its own size from `bytes`, and what the provider reports of it.
179
+ * An OpenEXR frame's thumbnail, sampled from the frame provider module `extensions` renders from
180
+ * `bytes` at its own size, with the provider's report.
188
181
  */
189
182
  export function exrFirstFrame(extensions: any, bytes: any): Promise<{
190
183
  thumbnail: {
@@ -1,12 +1,9 @@
1
- // Importing media an extension provider reads. The provider is chosen by probing the bytes, never
2
- // by file name; the extensions wasm module loads only when the bytes could be one of its formats.
1
+ // Importing media an extension provider reads. The provider is chosen by probing bytes, never by
2
+ // file name; the extensions wasm module loads only when the bytes could match one of its formats.
3
3
  import { MAX_LOTTIE_DOCUMENT_BYTES, MAX_PROVIDER_DOCUMENT_BYTES, MAX_SEQUENCE_FRAMES, MAX_SVG_DOCUMENT_BYTES, } from "alpha2/project";
4
4
  import { EditorError } from "../../core/document.js";
5
5
  const TICKS_PER_SECOND = 120_000;
6
- /**
7
- * Whether the start of a file could be an SVG, a GIF, an animated WebP, an APNG, a Lottie or
8
- * dotLottie, or an OpenEXR image.
9
- */
6
+ /** Whether a file's start could be SVG, GIF, animated WebP, APNG, Lottie, dotLottie or OpenEXR. */
10
7
  export function mayBeExtension(head) {
11
8
  const ascii = (at, text) => [...text].every((char, index) => head[at + index] === char.charCodeAt(0));
12
9
  if (ascii(0, "GIF8") || isExr(head))
@@ -20,15 +17,14 @@ export function mayBeExtension(head) {
20
17
  const text = new TextDecoder().decode(head);
21
18
  if (/^\s*\{/.test(text))
22
19
  return true;
23
- // An SVG root may follow a prolog longer than the head, so XML that starts with one is probed.
20
+ // An SVG root may follow a prolog longer than the head, so XML starting with one is probed.
24
21
  return /<svg[\s>/]/.test(text) || /^\s*<[?!]/.test(text);
25
22
  }
26
23
  /**
27
- * The most bytes the engine reads of a file that could be one of the document formats a provider
28
- * parses whole, by its start, with what the file is called: a dotLottie package (a ZIP,
29
- * `MAX_PROVIDER_DOCUMENT_BYTES`), a Lottie animation (a JSON object, `MAX_LOTTIE_DOCUMENT_BYTES`)
30
- * or an SVG (XML, `MAX_SVG_DOCUMENT_BYTES`); `null` for any other file. A larger file is refused
31
- * before it is read.
24
+ * The byte limit for a file that could be a document format a provider parses whole, by its start:
25
+ * dotLottie (ZIP, `MAX_PROVIDER_DOCUMENT_BYTES`), Lottie (JSON, `MAX_LOTTIE_DOCUMENT_BYTES`) or
26
+ * SVG (XML, `MAX_SVG_DOCUMENT_BYTES`), with the format's name; `null` for other files. Larger
27
+ * files are refused unread.
32
28
  */
33
29
  export function providerDocumentLimit(head) {
34
30
  if (head[0] === 0x50 &&
@@ -43,7 +39,6 @@ export function providerDocumentLimit(head) {
43
39
  return { limit: MAX_SVG_DOCUMENT_BYTES, what: "SVG document" };
44
40
  return null;
45
41
  }
46
- /** Whether bytes start as an OpenEXR file does. */
47
42
  function isExr(head) {
48
43
  return (head[0] === 0x76 && head[1] === 0x2f && head[2] === 0x31 && head[3] === 0x01);
49
44
  }
@@ -68,7 +63,6 @@ export function timingSeconds(timing) {
68
63
  return (timing.frames * timing.rate.den) / timing.rate.num;
69
64
  return 0;
70
65
  }
71
- /** A half float's value from its bits. */
72
66
  function halfValue(bits) {
73
67
  const exponent = (bits >> 10) & 0x1f;
74
68
  const fraction = bits & 0x3ff;
@@ -79,7 +73,7 @@ function halfValue(bits) {
79
73
  return fraction ? Number.NaN : sign * Infinity;
80
74
  return sign * (1 + fraction / 1024) * 2 ** (exponent - 15);
81
75
  }
82
- /** An sRGB code, 0 to 255, of a linear value, clipped to SDR as a picture shows it. */
76
+ /** The sRGB code (0 to 255) of a linear value, clipped to SDR. */
83
77
  function srgbCode(linear) {
84
78
  const value = Math.min(1, Math.max(0, linear));
85
79
  const encoded = value <= 0.0031308 ? 12.92 * value : 1.055 * value ** (1 / 2.4) - 0.055;
@@ -88,8 +82,8 @@ function srgbCode(linear) {
88
82
  /** A thumbnail's width, as an image sequence's PNG thumbnail has it. */
89
83
  const THUMBNAIL_WIDTH = 160;
90
84
  /**
91
- * A small preview of a rendered frame (premultiplied, sRGB RGBA8 or linear half floats) as an image
92
- * URL, {@link THUMBNAIL_WIDTH} wide at most. Only one pixel per thumbnail pixel is converted.
85
+ * A small preview of a rendered frame (premultiplied sRGB RGBA8 or linear half floats) as an image
86
+ * URL at most {@link THUMBNAIL_WIDTH} wide. Only sampled pixels are converted.
93
87
  */
94
88
  export async function thumbnailOf(frame) {
95
89
  const width = Math.min(THUMBNAIL_WIDTH, frame.width);
@@ -132,10 +126,9 @@ export async function thumbnailOf(frame) {
132
126
  return { dataUrl, width, height };
133
127
  }
134
128
  /**
135
- * The provider a relinked file opens with: the defaults {@link stageProviderFile} staged it with,
136
- * carrying the choices the project `recorded` for that source where the new file still offers them.
137
- * A package's animation stays while the package has it; an OpenEXR still's primaries stay while the
138
- * file is one whose primaries can be chosen.
129
+ * The provider a relinked file opens with: the defaults {@link stageProviderFile} staged, plus the
130
+ * choices `recorded` for the source where the new file still offers them (a package's animation,
131
+ * an OpenEXR still's primaries).
139
132
  */
140
133
  export function keepProviderChoices(recorded, staged, report) {
141
134
  if (!recorded || !staged || recorded.format !== staged.format)
@@ -150,7 +143,7 @@ export function keepProviderChoices(recorded, staged, report) {
150
143
  return { ...staged, primaries: recorded.primaries };
151
144
  return staged;
152
145
  }
153
- /** The provider source import records for what probing a file found. */
146
+ /** The provider source import records for a probed file. */
154
147
  function providerOf(report) {
155
148
  if (report.format === "svg" || report.format === "exr")
156
149
  return { format: report.format };
@@ -165,10 +158,9 @@ function providerOf(report) {
165
158
  return { format: "animated_image" };
166
159
  }
167
160
  /**
168
- * What import reads of a file with the provider module `extensions`: the provider that claims its
169
- * `bytes`, what probing found, and a thumbnail of its first frame; `null` when no provider claims
170
- * them. The source is opened as import records it, so a file that probes but does not open is
171
- * refused here.
161
+ * What import reads of `bytes` with provider module `extensions`: the claiming provider, the probe
162
+ * report and a first-frame thumbnail; `null` when no provider claims them. The source is opened as
163
+ * import records it, so a file that probes but does not open is refused here.
172
164
  *
173
165
  * @throws When a provider claims the bytes and cannot read them.
174
166
  */
@@ -190,8 +182,8 @@ export async function readProviderFile(extensions, bytes) {
190
182
  }
191
183
  }
192
184
  /**
193
- * The diagnostics an SVG's report gives when it is opened with `fonts`, the stack its text draws
194
- * with: which of its text no font draws (`missing_font`).
185
+ * An SVG's diagnostics when opened with font stack `fonts`, listing text no font draws
186
+ * (`missing_font`).
195
187
  */
196
188
  export function svgDiagnostics(extensions, provider, bytes, fonts) {
197
189
  extensions.setFonts(fonts);
@@ -204,8 +196,8 @@ export function svgDiagnostics(extensions, provider, bytes, fonts) {
204
196
  }
205
197
  }
206
198
  /**
207
- * Stages a file a provider claimed, from what {@link readProviderFile} read of it: a still SVG is
208
- * an image source, an animation a video source of one cycle (repetition is the clip's).
199
+ * Stages a provider-claimed file from what {@link readProviderFile} read: a still SVG is an image
200
+ * source, an animation a video source of one cycle (repetition is the clip's).
209
201
  */
210
202
  export function stageProviderFile(file, { report, provider, thumbnail }, fingerprint) {
211
203
  const kind = report.timing.kind === "static" ? "image" : "video";
@@ -262,12 +254,11 @@ function frameNumber(name) {
262
254
  /** Missing numbers a description of a sequence lists. */
263
255
  const LISTED_GAPS = 5;
264
256
  /**
265
- * How numbered files make one image sequence, from their names alone: the frame number each name
266
- * ends with, before its extension, fixes the order. Answers the first and last numbers, how many
267
- * frames the sequence has (every number between them), how many of those no file has, and the first
268
- * few of them; or, when the names cannot make a sequence, why: a name without a number, a number
269
- * listed twice, a number past 2^53 - 1 (a project document cannot hold it exactly), or more numbers
270
- * between the first and last than a sequence may have. Nothing here walks the numbers between them.
257
+ * How numbered files form one image sequence from their names alone: the frame number before each
258
+ * name's extension fixes the order. Answers the first and last numbers, the frame count (every
259
+ * number between them), how many have no file, and the first few gaps. Otherwise answers why not:
260
+ * a name without a number, a duplicate number, a number past 2^53 - 1 (a document cannot hold it
261
+ * exactly), or too many frames. Never walks the numbers in between.
271
262
  *
272
263
  * @param {readonly string[]} names
273
264
  * @returns {{ ok: true, first: number, last: number, frames: number, missing: number, gaps: number[] } | { ok: false, code: string, message: string }}
@@ -337,13 +328,12 @@ async function pngSize(file) {
337
328
  /** Header bytes read for an OpenEXR file's display window. */
338
329
  const EXR_HEADER_BYTES = 64 * 1024;
339
330
  /**
340
- * The most attributes read before the display window: OpenEXR writers put a few dozen; past this,
341
- * the header is no image's.
331
+ * Attributes read before the display window; writers use a few dozen, so more means not an image.
342
332
  */
343
333
  const EXR_MAX_ATTRIBUTES = 1024;
344
334
  /**
345
- * An OpenEXR image's display window size from its header; `null` when it is not an OpenEXR file.
346
- * The walk stops at an attribute that does not end past its start, so a crafted size cannot loop.
335
+ * An OpenEXR image's display window size from its header, or `null` when not OpenEXR. The walk
336
+ * stops at an attribute that does not end past its start, so a crafted size cannot loop.
347
337
  */
348
338
  async function exrSize(file) {
349
339
  const head = new Uint8Array(await file.slice(0, EXR_HEADER_BYTES).arrayBuffer());
@@ -392,10 +382,10 @@ async function frameShape(file) {
392
382
  }
393
383
  /**
394
384
  * Stages numbered PNGs or OpenEXR images as one image sequence at `frameRate`. The numbers fix the
395
- * order and the first frame; a gap is refused unless `missing` says to hold or blank it, and every
396
- * frame must be the first one's format and size. `openExr(file)` answers what the provider module
397
- * makes of an OpenEXR sequence's first frame (see {@link exrFirstFrame}): its thumbnail and report.
398
- * `id` names the source (a relink stages under the asset's own), a new one by default.
385
+ * order and first frame; a gap is refused unless `missing` holds or blanks it, and every frame must
386
+ * match the first one's format and size. `openExr(file)` returns the provider module's thumbnail
387
+ * and report for an OpenEXR first frame (see {@link exrFirstFrame}). `id` names the source (a
388
+ * relink uses the asset's own), new by default.
399
389
  */
400
390
  export async function stageSequence(files, { frameRate, missing = "reject", openExr, id = crypto.randomUUID() }) {
401
391
  const numbering = sequenceNumbering(files.map((file) => file.name));
@@ -504,8 +494,8 @@ async function pngThumbnail(file, size) {
504
494
  return { dataUrl, width: canvas.width, height: canvas.height };
505
495
  }
506
496
  /**
507
- * An OpenEXR frame's thumbnail, sampled from the frame the provider module `extensions` renders at
508
- * its own size from `bytes`, and what the provider reports of it.
497
+ * An OpenEXR frame's thumbnail, sampled from the frame provider module `extensions` renders from
498
+ * `bytes` at its own size, with the provider's report.
509
499
  */
510
500
  export async function exrFirstFrame(extensions, bytes) {
511
501
  const source = extensions.open({ format: "exr" }, bytes);
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * The fingerprint of `file` as media of `kind`. `size` is an image's decoded size; video and audio
3
- * are probed. `hash` makes the content hash, `sha256Blob` on this thread unless the caller hashes
4
- * elsewhere (`hashInWorker`).
3
+ * are probed. `hash` computes the content hash (`sha256Blob` on this thread by default).
5
4
  * @param {File} file
6
5
  * @param {string} kind
7
6
  * @param {{ signal?: AbortSignal, onProgress?: (bytes: number) => void, size?: { width: number, height: number }, hash?: (file: Blob, options: { signal?: AbortSignal, onProgress?: (bytes: number) => void }) => Promise<string> }} [options]
@@ -19,7 +18,7 @@ export function fingerprintFile(file: File, kind: string, options?: {
19
18
  onProgress?: (bytes: number) => void;
20
19
  }) => Promise<string>;
21
20
  }): Promise<import("alpha2/project").MediaFingerprint>;
22
- /** What the demuxer sees: the primary streams' shapes, the duration, and a declared color. */
21
+ /** What the demuxer sees: primary stream shapes, duration and declared color. */
23
22
  export function probeEvidence(file: any): Promise<{
24
23
  color?: import("alpha2/project").ColorMetadata | undefined;
25
24
  duration_ticks?: number | undefined;
@@ -31,12 +30,11 @@ export function probeEvidence(file: any): Promise<{
31
30
  } | undefined;
32
31
  }>;
33
32
  /**
34
- * The size a video track is shown at, in square pixels and turned as it is shown, as every host
35
- * finds it: the sample aspect ratio is the container's when it declares one that is not square,
36
- * else the one the H.264 or HEVC parameter sets signal (FFmpeg's `av_guess_sample_aspect_ratio`);
37
- * mediabunny reads only the container's. The stretch is the engine's
38
- * (`SampleAspectRatio::square_pixel_size`): the longer side of a sample grows, rounded to the
39
- * nearest pixel.
33
+ * A video track's displayed size in square pixels, rotated as shown, as every host computes it.
34
+ * The sample aspect ratio is the container's when it declares a non-square one, else the H.264 or
35
+ * HEVC parameter sets' (FFmpeg's `av_guess_sample_aspect_ratio`); mediabunny reads only the
36
+ * container's. The longer sample side grows, rounded to the nearest pixel, as in the engine's
37
+ * `SampleAspectRatio::square_pixel_size`.
40
38
  * @param {import("mediabunny").InputVideoTrack} track
41
39
  * @returns {Promise<{ width: number, height: number }>}
42
40
  */
@@ -45,11 +43,10 @@ export function displaySize(track: import("mediabunny").InputVideoTrack): Promis
45
43
  height: number;
46
44
  }>;
47
45
  /**
48
- * A measured frame rate as the rational a stream declares: the NTSC rates and whole rates exactly,
49
- * others to a thousandth (the engine's `alpha2_assets::rational_rate` is its twin). `null` when the
50
- * measure is no rate a project holds (so slow it rounds to no frames, or a frame shorter than a
51
- * tick, which only broken timestamps give): the fingerprint then records no rate rather than one
52
- * the engine refuses.
46
+ * A measured frame rate as a declared rational: NTSC and whole rates exactly, others to a
47
+ * thousandth (mirrors the engine's `alpha2_assets::rational_rate`). `null` when no project rate
48
+ * fits (too slow to round to a frame, or a frame shorter than a tick from broken timestamps), so
49
+ * the fingerprint records no rate rather than one the engine refuses.
53
50
  */
54
51
  export function rationalRate(rate: any): {
55
52
  num: number;
@@ -1,14 +1,12 @@
1
- // Evidence of an imported file's media, recorded in the project so any host can tell later whether
2
- // media it finds is the same: the bytes' hash, their length and date, and what the demuxer sees.
3
- // Whether two fingerprints match is the engine's decision (`alpha2/assets`), never made here.
1
+ // Evidence of an imported file's media, recorded in the project so any host can later tell whether
2
+ // media it finds is the same. Matching fingerprints is the engine's decision (`alpha2/assets`).
4
3
  import { sha256Blob } from "alpha2/assets";
5
4
  import { colorMetadataFromVideoColorSpace, sampleAspectForStream, } from "alpha2/hdr-frames";
6
5
  import { TICKS_PER_SECOND, validFrameRate } from "alpha2/project";
7
6
  import { ALL_FORMATS, BlobSource, EncodedPacketSink, Input } from "mediabunny";
8
7
  /**
9
8
  * The fingerprint of `file` as media of `kind`. `size` is an image's decoded size; video and audio
10
- * are probed. `hash` makes the content hash, `sha256Blob` on this thread unless the caller hashes
11
- * elsewhere (`hashInWorker`).
9
+ * are probed. `hash` computes the content hash (`sha256Blob` on this thread by default).
12
10
  * @param {File} file
13
11
  * @param {string} kind
14
12
  * @param {{ signal?: AbortSignal, onProgress?: (bytes: number) => void, size?: { width: number, height: number }, hash?: (file: Blob, options: { signal?: AbortSignal, onProgress?: (bytes: number) => void }) => Promise<string> }} [options]
@@ -35,7 +33,7 @@ export async function fingerprintFile(file, kind, options = {}) {
35
33
  return fingerprint;
36
34
  return { ...fingerprint, ...(await probeEvidence(file)) };
37
35
  }
38
- /** What the demuxer sees: the primary streams' shapes, the duration, and a declared color. */
36
+ /** What the demuxer sees: primary stream shapes, duration and declared color. */
39
37
  export async function probeEvidence(file) {
40
38
  const input = new Input({
41
39
  source: new BlobSource(file),
@@ -64,7 +62,7 @@ export async function probeEvidence(file) {
64
62
  channels: audio.numberOfChannels,
65
63
  sample_rate: audio.sampleRate,
66
64
  };
67
- // The latest end of any track: a stream starting at 1.4 s and lasting 2 s ends at 3.4 s.
65
+ // The latest end of any track (a stream starting at 1.4 s and lasting 2 s ends at 3.4 s).
68
66
  const seconds = await input.computeDuration().catch(() => null);
69
67
  return {
70
68
  ...(video || audio ? { streams } : {}),
@@ -79,12 +77,11 @@ export async function probeEvidence(file) {
79
77
  }
80
78
  }
81
79
  /**
82
- * The size a video track is shown at, in square pixels and turned as it is shown, as every host
83
- * finds it: the sample aspect ratio is the container's when it declares one that is not square,
84
- * else the one the H.264 or HEVC parameter sets signal (FFmpeg's `av_guess_sample_aspect_ratio`);
85
- * mediabunny reads only the container's. The stretch is the engine's
86
- * (`SampleAspectRatio::square_pixel_size`): the longer side of a sample grows, rounded to the
87
- * nearest pixel.
80
+ * A video track's displayed size in square pixels, rotated as shown, as every host computes it.
81
+ * The sample aspect ratio is the container's when it declares a non-square one, else the H.264 or
82
+ * HEVC parameter sets' (FFmpeg's `av_guess_sample_aspect_ratio`); mediabunny reads only the
83
+ * container's. The longer sample side grows, rounded to the nearest pixel, as in the engine's
84
+ * `SampleAspectRatio::square_pixel_size`.
88
85
  * @param {import("mediabunny").InputVideoTrack} track
89
86
  * @returns {Promise<{ width: number, height: number }>}
90
87
  */
@@ -109,14 +106,14 @@ export async function displaySize(track) {
109
106
  ? { width, height }
110
107
  : { width: height, height: width };
111
108
  }
112
- /** How many frames the rate is measured over, at least: about four seconds at 30 fps. */
109
+ /** Minimum frames the rate is measured over, about four seconds at 30 fps. */
113
110
  const RATE_FRAMES = 120;
114
111
  /**
115
- * The rate `track` presents its first frames at, from packet times alone (durations differ between
116
- * demuxers); past {@link RATE_FRAMES}, packets run up to the first presented after every one
117
- * taken, so reordered frames stay in the span. `null` with fewer than two frames or no span. Twin
118
- * of the engine's `alpha2_assets::FrameRateEvidence` (held equal by
119
- * `tests/cases/media-evidence-corpus.json`); a declared rate is no common ground across hosts.
112
+ * The rate `track` presents its first frames at, from packet times only (durations differ between
113
+ * demuxers). Past {@link RATE_FRAMES}, packets run up to the first presented after every one taken,
114
+ * so reordered frames stay in the span. `null` with fewer than two frames or no span. Mirrors the
115
+ * engine's `alpha2_assets::FrameRateEvidence` (checked by
116
+ * `tests/cases/media-evidence-corpus.json`); declared rates are not consistent across hosts.
120
117
  * @param {import("mediabunny").InputVideoTrack} track
121
118
  * @returns {Promise<number | null>}
122
119
  */
@@ -137,11 +134,10 @@ async function presentedRate(track) {
137
134
  return count >= 2 && last > first ? (count - 1) / (last - first) : null;
138
135
  }
139
136
  /**
140
- * A measured frame rate as the rational a stream declares: the NTSC rates and whole rates exactly,
141
- * others to a thousandth (the engine's `alpha2_assets::rational_rate` is its twin). `null` when the
142
- * measure is no rate a project holds (so slow it rounds to no frames, or a frame shorter than a
143
- * tick, which only broken timestamps give): the fingerprint then records no rate rather than one
144
- * the engine refuses.
137
+ * A measured frame rate as a declared rational: NTSC and whole rates exactly, others to a
138
+ * thousandth (mirrors the engine's `alpha2_assets::rational_rate`). `null` when no project rate
139
+ * fits (too slow to round to a frame, or a frame shorter than a tick from broken timestamps), so
140
+ * the fingerprint records no rate rather than one the engine refuses.
145
141
  */
146
142
  export function rationalRate(rate) {
147
143
  if (!Number.isFinite(rate) || rate <= 0)
@@ -151,9 +151,8 @@ export function encodeGenerator(generator: any): {
151
151
  paint?: undefined;
152
152
  };
153
153
  /**
154
- * Draws an approximation of the generator for a library thumbnail. Canvas gradients interpolate in
155
- * sRGB where the engine uses linear light, so the middle of a gradient is a little darker here than
156
- * in the preview.
154
+ * Draws an approximate library thumbnail of the generator. Canvas gradients interpolate in sRGB,
155
+ * not linear light, so gradient midpoints are slightly darker than in the preview.
157
156
  */
158
157
  export function drawGenerator(context: any, generator: any, width: any, height: any): void;
159
158
  /** Checks a generator read from a project file. */
@@ -1,6 +1,5 @@
1
- // Generated sources: pictures the engine draws itself (`kind: "generated"`). Positions are
2
- // normalized ((0, 0) top-left, (1, 1) bottom-right); radii and strokes are fractions of the shorter
3
- // side.
1
+ // Generated sources the engine draws itself (`kind: "generated"`). Positions are normalized ((0, 0)
2
+ // top-left, (1, 1) bottom-right); radii and strokes are fractions of the shorter side.
4
3
  import { rgba } from "./color.js";
5
4
  export const GENERATOR_KINDS = [
6
5
  { value: "solid", label: "Solid color" },
@@ -88,7 +87,7 @@ export function encodeGenerator(generator) {
88
87
  : {}),
89
88
  rotation_degrees: constant(generator.rotation),
90
89
  };
91
- // The stroke is listed first, so it is drawn over the fill.
90
+ // Listed first so the stroke draws over the fill.
92
91
  return {
93
92
  type: "shapes",
94
93
  items: [
@@ -119,9 +118,8 @@ export function encodeGenerator(generator) {
119
118
  }
120
119
  }
121
120
  /**
122
- * Draws an approximation of the generator for a library thumbnail. Canvas gradients interpolate in
123
- * sRGB where the engine uses linear light, so the middle of a gradient is a little darker here than
124
- * in the preview.
121
+ * Draws an approximate library thumbnail of the generator. Canvas gradients interpolate in sRGB,
122
+ * not linear light, so gradient midpoints are slightly darker than in the preview.
125
123
  */
126
124
  export function drawGenerator(context, generator, width, height) {
127
125
  const [first, second] = generator.colors;
@@ -1,7 +1,6 @@
1
1
  /**
2
- * Holds the shared lock `name` until `release()`. Resolves once held; where the browser has no Web
3
- * Locks, or refuses the lock, at once and holding nothing. `release()` returns a promise that
4
- * settles when the lock is let go.
2
+ * Holds the shared lock `name` until `release()`. Resolves once held; without Web Locks, or if
3
+ * refused, at once and holding nothing. `release()` settles when the lock is let go.
5
4
  * @param {string} name
6
5
  * @returns {Promise<{ release(): Promise<void> }>}
7
6
  */
@@ -17,10 +16,9 @@ export function holdShared(name: string): Promise<{
17
16
  */
18
17
  export function whenUnheld(name: string, remove: () => Promise<void>): Promise<boolean>;
19
18
  /**
20
- * Runs `body` holding the lock `name` exclusively, waiting for any page that holds it, and resolves
21
- * to what `body` resolves to; `body` is told whether it holds the lock. Where the browser has no
22
- * Web Locks, or refuses the lock, `body` runs at once, holding nothing. Rejects with
23
- * `signal.reason` once `signal` aborts while it waits.
19
+ * Runs `body` holding lock `name` exclusively, waiting for any holder, and resolves to its result.
20
+ * `body` is told whether it holds the lock; without Web Locks, or if refused, it runs at once
21
+ * holding nothing. Rejects with `signal.reason` if `signal` aborts while waiting.
24
22
  * @template T
25
23
  * @param {string} name
26
24
  * @param {{ signal?: AbortSignal }} options
@@ -2,9 +2,8 @@
2
2
  // only if unheld. Closed pages release their locks; without Web Locks nothing is held.
3
3
  const locks = () => globalThis.navigator?.locks ?? null;
4
4
  /**
5
- * Holds the shared lock `name` until `release()`. Resolves once held; where the browser has no Web
6
- * Locks, or refuses the lock, at once and holding nothing. `release()` returns a promise that
7
- * settles when the lock is let go.
5
+ * Holds the shared lock `name` until `release()`. Resolves once held; without Web Locks, or if
6
+ * refused, at once and holding nothing. `release()` settles when the lock is let go.
8
7
  * @param {string} name
9
8
  * @returns {Promise<{ release(): Promise<void> }>}
10
9
  */
@@ -55,10 +54,9 @@ export async function whenUnheld(name, remove) {
55
54
  });
56
55
  }
57
56
  /**
58
- * Runs `body` holding the lock `name` exclusively, waiting for any page that holds it, and resolves
59
- * to what `body` resolves to; `body` is told whether it holds the lock. Where the browser has no
60
- * Web Locks, or refuses the lock, `body` runs at once, holding nothing. Rejects with
61
- * `signal.reason` once `signal` aborts while it waits.
57
+ * Runs `body` holding lock `name` exclusively, waiting for any holder, and resolves to its result.
58
+ * `body` is told whether it holds the lock; without Web Locks, or if refused, it runs at once
59
+ * holding nothing. Rejects with `signal.reason` if `signal` aborts while waiting.
62
60
  * @template T
63
61
  * @param {string} name
64
62
  * @param {{ signal?: AbortSignal }} options
@@ -1,21 +1,19 @@
1
- /** Which storage APIs this page has, as an export's result reports them. */
1
+ /** Which storage APIs this page has, as an export result reports them. */
2
2
  export function storageSupport(): {
3
3
  opfs: boolean;
4
4
  savePicker: boolean;
5
5
  estimate: boolean;
6
6
  };
7
7
  /**
8
- * Opens where an export writes, refusing before anything renders only an in-memory output past its
9
- * limit.
8
+ * Opens where an export writes, refusing up front only an in-memory output past its limit.
10
9
  *
11
10
  * Storage is never refused ahead: `navigator.storage.estimate()` is a guess, and WebKit's usage
12
11
  * counts every write since its last disk scan, so `quota - usage` can be near zero on an empty
13
12
  * disk. A full disk fails at the write (`STORAGE_QUOTA_EXCEEDED`); the estimate is only reported.
14
13
  *
15
- * `container` (default `mp4`) gives the temporary file its extension and the artifact its MIME
16
- * type.
14
+ * `container` (default `mp4`) sets the temporary file's extension and the artifact's MIME type.
17
15
  * Returns `{ mode, destination, storageEstimate, abort, finish }`: `destination` is the sink's,
18
- * `abort` discards the file, and `finish(sinkOutput)` turns the finished output into the artifact's
16
+ * `abort` discards the file, and `finish(sinkOutput)` turns the finished output into artifact
19
17
  * fields.
20
18
  */
21
19
  export function openExportOutput({ jobId, name, container, target, durationSeconds, videoBitrate, audioBitrate, }: {
@@ -81,10 +79,10 @@ export function openExportOutput({ jobId, name, container, target, durationSecon
81
79
  }>;
82
80
  }>;
83
81
  /**
84
- * Deletes temporary export files left by pages that are gone: started over a day ago and held by
85
- * no page. Resolves to the names removed.
82
+ * Deletes temporary export files left by closed pages (started over a day ago, held by no page).
83
+ * Resolves to the names removed.
86
84
  * @returns {Promise<string[]>}
87
85
  */
88
86
  export function sweepStaleExports(now?: number): Promise<string[]>;
89
- /** The most an in-memory output may hold at its peak unless asked otherwise. */
87
+ /** Default peak size of an in-memory output. */
90
88
  export const DEFAULT_MEMORY_OUTPUT_LIMIT: number;