@alpha2-sh/editor 0.0.0 → 0.1.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 (98) hide show
  1. package/README.md +107 -1
  2. package/dist/browser/bridge.d.ts +44 -0
  3. package/dist/browser/bridge.js +2176 -0
  4. package/dist/browser/extensions-worker-entry.js +3 -0
  5. package/dist/browser/extensions-worker.d.ts +46 -0
  6. package/dist/browser/extensions-worker.js +149 -0
  7. package/dist/browser/hash-worker-entry.d.ts +1 -0
  8. package/dist/browser/hash-worker-entry.js +3 -0
  9. package/dist/browser/hash-worker.d.ts +24 -0
  10. package/dist/browser/hash-worker.js +87 -0
  11. package/dist/browser/index.d.ts +11 -0
  12. package/dist/browser/index.js +9 -0
  13. package/dist/browser/jobs.d.ts +82 -0
  14. package/dist/browser/jobs.js +291 -0
  15. package/dist/browser/resources.d.ts +40 -0
  16. package/dist/browser/resources.js +83 -0
  17. package/dist/browser/runtime/assets.d.ts +233 -0
  18. package/dist/browser/runtime/assets.js +633 -0
  19. package/dist/browser/runtime/audio.d.ts +60 -0
  20. package/dist/browser/runtime/audio.js +549 -0
  21. package/dist/browser/runtime/budget.d.ts +11 -0
  22. package/dist/browser/runtime/budget.js +26 -0
  23. package/dist/browser/runtime/caption-fonts.d.ts +34 -0
  24. package/dist/browser/runtime/caption-fonts.js +69 -0
  25. package/dist/browser/runtime/color.d.ts +7 -0
  26. package/dist/browser/runtime/color.js +12 -0
  27. package/dist/browser/runtime/engine.d.ts +91 -0
  28. package/dist/browser/runtime/engine.js +352 -0
  29. package/dist/browser/runtime/export-audio.d.ts +23 -0
  30. package/dist/browser/runtime/export-audio.js +75 -0
  31. package/dist/browser/runtime/exporter.d.ts +140 -0
  32. package/dist/browser/runtime/exporter.js +751 -0
  33. package/dist/browser/runtime/extension-import.d.ts +196 -0
  34. package/dist/browser/runtime/extension-import.js +521 -0
  35. package/dist/browser/runtime/fingerprint.d.ts +57 -0
  36. package/dist/browser/runtime/fingerprint.js +157 -0
  37. package/dist/browser/runtime/generators.d.ts +188 -0
  38. package/dist/browser/runtime/generators.js +173 -0
  39. package/dist/browser/runtime/locks.d.ts +32 -0
  40. package/dist/browser/runtime/locks.js +86 -0
  41. package/dist/browser/runtime/output.d.ts +87 -0
  42. package/dist/browser/runtime/output.js +230 -0
  43. package/dist/browser/runtime/preview-utils.d.ts +3 -0
  44. package/dist/browser/runtime/preview-utils.js +49 -0
  45. package/dist/browser/runtime/proxies.d.ts +72 -0
  46. package/dist/browser/runtime/proxies.js +369 -0
  47. package/dist/browser/runtime/proxy-storage.d.ts +59 -0
  48. package/dist/browser/runtime/proxy-storage.js +119 -0
  49. package/dist/browser/runtime/sources.d.ts +82 -0
  50. package/dist/browser/runtime/sources.js +819 -0
  51. package/dist/browser/runtime/staging.d.ts +10 -0
  52. package/dist/browser/runtime/staging.js +32 -0
  53. package/dist/browser/runtime/still.d.ts +21 -0
  54. package/dist/browser/runtime/still.js +52 -0
  55. package/dist/browser/runtime/wasm.d.ts +9 -0
  56. package/dist/browser/runtime/wasm.js +20 -0
  57. package/dist/browser/types.d.ts +549 -0
  58. package/dist/browser/types.js +1 -0
  59. package/dist/browser/worker-entry.d.ts +1 -0
  60. package/dist/browser/worker-entry.js +2 -0
  61. package/dist/browser/worker.d.ts +24 -0
  62. package/dist/browser/worker.js +239 -0
  63. package/dist/core/captions.d.ts +34 -0
  64. package/dist/core/captions.js +108 -0
  65. package/dist/core/clip-time.d.ts +31 -0
  66. package/dist/core/clip-time.js +125 -0
  67. package/dist/core/commands.d.ts +413 -0
  68. package/dist/core/commands.js +1118 -0
  69. package/dist/core/compositions.d.ts +234 -0
  70. package/dist/core/compositions.js +851 -0
  71. package/dist/core/document.d.ts +245 -0
  72. package/dist/core/document.js +683 -0
  73. package/dist/core/keyframes.d.ts +82 -0
  74. package/dist/core/keyframes.js +153 -0
  75. package/dist/core/presets.d.ts +64 -0
  76. package/dist/core/presets.js +241 -0
  77. package/dist/core/session.d.ts +150 -0
  78. package/dist/core/session.js +541 -0
  79. package/dist/core/text.d.ts +17 -0
  80. package/dist/core/text.js +17 -0
  81. package/dist/core/time.d.ts +19 -0
  82. package/dist/core/time.js +39 -0
  83. package/dist/core/timeline-index.d.ts +44 -0
  84. package/dist/core/timeline-index.js +59 -0
  85. package/dist/core/transitions.d.ts +20 -0
  86. package/dist/core/transitions.js +118 -0
  87. package/dist/core/validated.d.ts +23 -0
  88. package/dist/core/validated.js +52 -0
  89. package/dist/index.d.ts +12 -0
  90. package/dist/index.js +11 -0
  91. package/dist/native-client/index.d.ts +131 -0
  92. package/dist/native-client/index.js +354 -0
  93. package/dist/ports/index.d.ts +146 -0
  94. package/dist/ports/index.js +1 -0
  95. package/dist/react/index.d.ts +37 -0
  96. package/dist/react/index.js +94 -0
  97. package/package.json +69 -8
  98. /package/{index.js → dist/browser/extensions-worker-entry.d.ts} +0 -0
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The bytes the engine's I420 readback of a `width`x`height` frame keeps staged: its planes and
3
+ * the renderer's 16-byte canary, what a readback ticket reports as `retainedBytes`.
4
+ */
5
+ export function estimatedStagingBytes(width: any, height: any): number;
6
+ /**
7
+ * The least an export of `width`x`height` frames can run with in flight: one frame's readback
8
+ * staged and the packed copy of one frame the encoder holds.
9
+ */
10
+ export function minimumExportWorkingSet(width: any, height: any): number;
@@ -0,0 +1,32 @@
1
+ // What an export frame holds in flight, computed without loading the runtime.
2
+ // `tests/cases/staging-bytes-corpus.json` holds these to the renderer's `yuv420p_staging_bytes`.
3
+ /** The canary the renderer stages after the planes, to prove the GPU wrote them. */
4
+ const CANARY_BYTES = 16;
5
+ /**
6
+ * The bytes of the planes of a `width`x`height` I420 readback: each plane's rows padded to the copy
7
+ * alignment (256), each plane starting on a 512-byte placement boundary, as the renderer lays them
8
+ * out. The packed frame the encoder takes is this long.
9
+ */
10
+ function planeBytes(width, height) {
11
+ const row = (bytes) => Math.ceil(bytes / 256) * 256;
12
+ const place = (offset) => Math.ceil(offset / 512) * 512;
13
+ const chromaRows = Math.floor(height / 2);
14
+ const chroma = row(Math.floor(width / 2)) * chromaRows;
15
+ const u = place(row(width) * height);
16
+ const v = place(u + chroma);
17
+ return v + chroma;
18
+ }
19
+ /**
20
+ * The bytes the engine's I420 readback of a `width`x`height` frame keeps staged: its planes and
21
+ * the renderer's 16-byte canary, what a readback ticket reports as `retainedBytes`.
22
+ */
23
+ export function estimatedStagingBytes(width, height) {
24
+ return planeBytes(width, height) + CANARY_BYTES;
25
+ }
26
+ /**
27
+ * The least an export of `width`x`height` frames can run with in flight: one frame's readback
28
+ * staged and the packed copy of one frame the encoder holds.
29
+ */
30
+ export function minimumExportWorkingSet(width, height) {
31
+ return estimatedStagingBytes(width, height) + planeBytes(width, height);
32
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Decodes an image file upright and without colour management. Rejects a picture larger than the
3
+ * engine takes, as native decoding refuses one.
4
+ */
5
+ export function decodeStill(file: any): Promise<ImageBitmap>;
6
+ /**
7
+ * A decoded still's pixels at its own size, in straight alpha as decoded, as a raster frame the
8
+ * engine presents into the output.
9
+ */
10
+ export function stillRaster(bitmap: any): {
11
+ kind: string;
12
+ width: any;
13
+ height: any;
14
+ pixels: Uint8Array<ArrayBuffer>;
15
+ alpha: string;
16
+ physicalTimeMicroseconds: number;
17
+ };
18
+ /** The longest side the engine decodes, renders, or composes (`MAX_FRAME_DIMENSION`). */
19
+ export const MAX_STILL_DIMENSION: 16384;
20
+ /** The largest area the engine decodes, renders, or composes (`MAX_FRAME_PIXELS`). */
21
+ export const MAX_STILL_PIXELS: 67108864;
@@ -0,0 +1,52 @@
1
+ // Reads a still image by the same rule as native decoding, so it shows alike in preview and in
2
+ // browser and native exports:
3
+ // - Upright per Exif `Orientation` (`imageOrientation: "from-image"`; Chrome reads `"none"` as it).
4
+ // - In stored sRGB code values: no ICC profile (`colorSpaceConversion: "none"`), since the engine
5
+ // treats SDR input as sRGB and native decoding has no colour management.
6
+ // - At its own size; the engine scales it into the output.
7
+ /** The longest side the engine decodes, renders, or composes (`MAX_FRAME_DIMENSION`). */
8
+ export const MAX_STILL_DIMENSION = 16_384;
9
+ /** The largest area the engine decodes, renders, or composes (`MAX_FRAME_PIXELS`). */
10
+ export const MAX_STILL_PIXELS = 67_108_864;
11
+ /**
12
+ * Decodes an image file upright and without colour management. Rejects a picture larger than the
13
+ * engine takes, as native decoding refuses one.
14
+ */
15
+ export async function decodeStill(file) {
16
+ const bitmap = await createImageBitmap(file, {
17
+ imageOrientation: "from-image",
18
+ colorSpaceConversion: "none",
19
+ });
20
+ const { width, height } = bitmap;
21
+ if (width > MAX_STILL_DIMENSION ||
22
+ height > MAX_STILL_DIMENSION ||
23
+ width * height > MAX_STILL_PIXELS) {
24
+ bitmap.close();
25
+ throw new RangeError(`the picture is ${width}x${height}, larger than the ${MAX_STILL_DIMENSION} pixels a side or ${MAX_STILL_PIXELS} pixels alpha2 decodes`);
26
+ }
27
+ return bitmap;
28
+ }
29
+ /**
30
+ * A decoded still's pixels at its own size, in straight alpha as decoded, as a raster frame the
31
+ * engine presents into the output.
32
+ */
33
+ export function stillRaster(bitmap) {
34
+ const { width, height } = bitmap;
35
+ const canvas = new OffscreenCanvas(width, height);
36
+ const context = canvas.getContext("2d", {
37
+ colorSpace: "srgb",
38
+ willReadFrequently: true,
39
+ });
40
+ context.drawImage(bitmap, 0, 0);
41
+ const { data } = context.getImageData(0, 0, width, height, {
42
+ colorSpace: "srgb",
43
+ });
44
+ return {
45
+ kind: "raster-frame",
46
+ width,
47
+ height,
48
+ pixels: new Uint8Array(data.buffer, data.byteOffset, data.byteLength),
49
+ alpha: "straight",
50
+ physicalTimeMicroseconds: 0,
51
+ };
52
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Instantiates `alpha2/wasm` once for this realm and resolves to its exports. wasm-bindgen's own
3
+ * init reuses an instance only after one has finished: two calls in flight instantiate twice, and
4
+ * the later instance replaces the module's memory under objects made from the first, whose next
5
+ * call reads out of bounds. Every caller goes through here. A failed load is retried by the next
6
+ * call.
7
+ * @param {string | URL | undefined} wasmUrl
8
+ */
9
+ export function loadEngineWasm(wasmUrl: string | URL | undefined): any;
@@ -0,0 +1,20 @@
1
+ import init from "alpha2/wasm";
2
+ import * as binding from "alpha2/wasm";
3
+ let loading = null;
4
+ /**
5
+ * Instantiates `alpha2/wasm` once for this realm and resolves to its exports. wasm-bindgen's own
6
+ * init reuses an instance only after one has finished: two calls in flight instantiate twice, and
7
+ * the later instance replaces the module's memory under objects made from the first, whose next
8
+ * call reads out of bounds. Every caller goes through here. A failed load is retried by the next
9
+ * call.
10
+ * @param {string | URL | undefined} wasmUrl
11
+ */
12
+ export function loadEngineWasm(wasmUrl) {
13
+ loading ??= init(wasmUrl ? { module_or_path: wasmUrl } : undefined)
14
+ .then(() => binding)
15
+ .catch((error) => {
16
+ loading = null;
17
+ throw error;
18
+ });
19
+ return loading;
20
+ }