alpha2 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 (119) hide show
  1. package/README.md +5 -4
  2. package/THIRD_PARTY_NOTICES.md +4 -0
  3. package/dist/abort.d.ts +12 -0
  4. package/dist/abort.js +48 -0
  5. package/dist/active-clock.d.ts +35 -0
  6. package/dist/active-clock.js +99 -0
  7. package/dist/assets.d.ts +28 -22
  8. package/dist/assets.js +8 -12
  9. package/dist/audio-layout.d.ts +52 -74
  10. package/dist/audio-layout.js +114 -148
  11. package/dist/audio-timeline.d.ts +89 -117
  12. package/dist/audio-timeline.js +102 -118
  13. package/dist/audio-worker.d.ts +12 -21
  14. package/dist/audio-worker.js +8 -13
  15. package/dist/audio-worklet-processor.js +45 -58
  16. package/dist/audio-worklet.d.ts +45 -76
  17. package/dist/audio-worklet.js +44 -79
  18. package/dist/audio.d.ts +15 -23
  19. package/dist/audio.js +9 -13
  20. package/dist/builder.d.ts +45 -63
  21. package/dist/builder.js +49 -45
  22. package/dist/capabilities.d.ts +99 -16
  23. package/dist/capabilities.js +2 -2
  24. package/dist/captions.d.ts +45 -22
  25. package/dist/captions.js +60 -15
  26. package/dist/chroma-siting.d.ts +24 -41
  27. package/dist/chroma-siting.js +38 -71
  28. package/dist/containers.d.ts +41 -30
  29. package/dist/containers.js +59 -27
  30. package/dist/decoder-fallback.d.ts +13 -0
  31. package/dist/decoder-fallback.js +38 -0
  32. package/dist/decoder-order.d.ts +24 -39
  33. package/dist/decoder-order.js +28 -42
  34. package/dist/edit.d.ts +77 -154
  35. package/dist/edit.js +98 -180
  36. package/dist/effects.d.ts +108 -177
  37. package/dist/effects.js +7 -9
  38. package/dist/export-destination.d.ts +25 -41
  39. package/dist/export-destination.js +20 -32
  40. package/dist/export-failure.d.ts +34 -59
  41. package/dist/export-failure.js +54 -48
  42. package/dist/export-metrics.d.ts +116 -0
  43. package/dist/export-metrics.js +74 -0
  44. package/dist/export-retry.d.ts +46 -29
  45. package/dist/export-retry.js +86 -51
  46. package/dist/exporter.d.ts +67 -116
  47. package/dist/exporter.js +133 -133
  48. package/dist/extensions.d.ts +69 -115
  49. package/dist/extensions.js +55 -82
  50. package/dist/frame-intake.d.ts +92 -0
  51. package/dist/frame-intake.js +114 -0
  52. package/dist/frame-supply.d.ts +96 -162
  53. package/dist/frame-supply.js +181 -171
  54. package/dist/generated/project-schema.d.ts +701 -485
  55. package/dist/generated/project-schema.js +55 -2
  56. package/dist/generated/project-shape.js +261 -16
  57. package/dist/geometry.d.ts +28 -34
  58. package/dist/geometry.js +18 -23
  59. package/dist/gpu-recovery.d.ts +92 -0
  60. package/dist/gpu-recovery.js +135 -0
  61. package/dist/hdr-frames.d.ts +82 -67
  62. package/dist/hdr-frames.js +112 -49
  63. package/dist/index.d.ts +4 -0
  64. package/dist/index.js +4 -0
  65. package/dist/json-text.d.ts +13 -23
  66. package/dist/json-text.js +10 -20
  67. package/dist/layout-values.d.ts +14 -22
  68. package/dist/layout-values.js +18 -21
  69. package/dist/layout.d.ts +48 -63
  70. package/dist/layout.js +37 -37
  71. package/dist/loudness.d.ts +27 -32
  72. package/dist/loudness.js +19 -23
  73. package/dist/media.d.ts +85 -237
  74. package/dist/media.js +133 -287
  75. package/dist/mediabunny.d.ts +166 -245
  76. package/dist/mediabunny.js +741 -580
  77. package/dist/physical-frames.d.ts +5 -17
  78. package/dist/physical-frames.js +4 -11
  79. package/dist/player.d.ts +56 -47
  80. package/dist/player.js +155 -40
  81. package/dist/presented-frames.d.ts +2 -7
  82. package/dist/presented-frames.js +3 -8
  83. package/dist/project.d.ts +73 -117
  84. package/dist/project.js +384 -445
  85. package/dist/rate-control.d.ts +9 -23
  86. package/dist/rate-control.js +7 -18
  87. package/dist/renderer-choice.d.ts +41 -0
  88. package/dist/renderer-choice.js +82 -0
  89. package/dist/repacked-bytes.d.ts +0 -2
  90. package/dist/repacked-bytes.js +2 -5
  91. package/dist/robustness.d.ts +25 -37
  92. package/dist/robustness.js +71 -54
  93. package/dist/sha256.d.ts +5 -13
  94. package/dist/sha256.js +9 -24
  95. package/dist/text.d.ts +97 -71
  96. package/dist/text.js +33 -70
  97. package/dist/video-frames.d.ts +7 -25
  98. package/dist/video-frames.js +12 -29
  99. package/dist/waveform.d.ts +5 -11
  100. package/dist/waveform.js +4 -9
  101. package/dist/worker-error.d.ts +5 -20
  102. package/dist/worker-error.js +8 -25
  103. package/dist/worker.d.ts +82 -95
  104. package/dist/worker.js +235 -143
  105. package/package.json +26 -2
  106. package/wasm/alpha2_audio_worklet.wasm +0 -0
  107. package/wasm/alpha2_extensions.d.ts +26 -47
  108. package/wasm/alpha2_extensions.js +26 -47
  109. package/wasm/alpha2_extensions_bg.wasm +0 -0
  110. package/wasm/alpha2_wasm.d.ts +460 -567
  111. package/wasm/alpha2_wasm.js +594 -594
  112. package/wasm/alpha2_wasm_bg.wasm +0 -0
  113. package/wasm/alpha2_wasm_bg.wasm.d.ts +15 -8
  114. package/wasm/rust-crate-licenses.md +2 -2
  115. package/wasm/snippets/{alpha2-wasm-c62e60c964e88a52 → alpha2-wasm-1313375d424845c0}/inline1.js +1 -0
  116. package/wasm/snippets/alpha2-wasm-1313375d424845c0/inline2.js +82 -0
  117. package/wasm/snippets/alpha2-wasm-c62e60c964e88a52/inline2.js +0 -52
  118. /package/wasm/snippets/{alpha2-wasm-c62e60c964e88a52 → alpha2-wasm-1313375d424845c0}/inline0.js +0 -0
  119. /package/wasm/snippets/{alpha2-wasm-c62e60c964e88a52 → alpha2-wasm-1313375d424845c0}/inline3.js +0 -0
package/dist/layout.d.ts CHANGED
@@ -1,83 +1,69 @@
1
1
  /**
2
- * Layout generators for authors: boxes laid out by CSS flexbox or grid around their text and
3
- * shapes, as a project's `{ "type": "layout" }` generator holds them.
2
+ * Builders and measurement for `{ "type": "layout" }` generators (CSS flexbox and grid boxes).
4
3
  *
5
- * {@link measureLayout} answers, in wasm and with the fonts the engine draws with, where every box
6
- * of a layout lies on a picture and whether anything overflows, before anything is rendered. The
7
- * builder ({@link box}, {@link text}, {@link shape}, {@link layout}) writes the document from
8
- * CSS-like props: a value that is not animated becomes a constant, a `[top, right, bottom, left]`
9
- * tuple the sides object, an `[x, y]` tuple a vector. Lengths are written as the document writes
10
- * them: a number is a fraction of the picture's shorter side, `"12px"` pixels of the project
11
- * canvas, `"50%"` a percent of the parent's content box. Text style (`font_family`, `font_size`,
12
- * `font_weight`, `color`, `line_height`, `letter_spacing`, `text_align`, `outline`) may be set on
13
- * any box and is inherited. Its
14
- * output is a plain document that `validateProject` accepts; a CSS value string it cannot read
15
- * throws, with the parser's message.
4
+ * {@link measureLayout} computes every box's position and overflow in wasm with the engine's fonts.
5
+ * The builders ({@link box}, {@link text}, {@link shape}, {@link layout}) take CSS-like props:
6
+ * plain values become constants, and tuples expand to sides objects or vectors. A number length is
7
+ * a fraction of the picture's shorter side, `"12px"` is project canvas pixels, and `"50%"` is a
8
+ * percent of the parent's content box. Text style props may be set on any box and are inherited.
9
+ * The output is a plain document; an unreadable CSS value string throws the parser's message.
16
10
  */
17
11
  import type { PictureSize } from "./geometry.js";
18
- import type { AlignContent, AlignItems, Animated, Display, FlexDirection, FlexWrap, Generator, GridAutoFlow, JustifyContent, LayoutNode, Overflow, Paint, Position, Rgba, ShapeItem, TextAlign, TextOutline, Ticks, Vec2 } from "./project.js";
19
- /** The part of `alpha2/wasm`'s `WasmTextMeasurer` {@link measureLayout} uses. */
12
+ import type { AlignContent, AlignItems, Animated, Display, FlexDirection, FlexWrap, Generator, GridAutoFlow, JustifyContent, LayoutNode, Overflow, Paint, Position, Rgba, ShapeItem, TextAlign, TextShadow, TextStroke, Ticks, Vec2 } from "./project.js";
13
+ /** The `WasmTextMeasurer` method {@link measureLayout} uses. */
20
14
  export interface LayoutBinding {
21
15
  measureLayout(generatorJson: string, width: number, height: number, time: number, canvasWidth?: number, canvasHeight?: number): string;
22
16
  }
23
- /** A rectangle as fractions of the picture, `(0, 0)` top-left to `(1, 1)` bottom-right. */
17
+ /** Rectangle in picture fractions, `(0, 0)` top-left to `(1, 1)` bottom-right. */
24
18
  export interface LayoutRect {
25
19
  readonly left: number;
26
20
  readonly top: number;
27
21
  readonly right: number;
28
22
  readonly bottom: number;
29
23
  }
30
- /** Where one node lies: its layout boxes, before its clip's transform and node visuals. */
24
+ /** A node's layout boxes, before the clip transform and node visuals. */
31
25
  export interface NodeBounds {
32
- /** Its path from the root, like `root.children[1]`. */
26
+ /** Path from the root, like `root.children[1]`. */
33
27
  readonly at: string;
34
- /** The border box. */
35
28
  readonly border: LayoutRect;
36
- /** The content box. */
37
29
  readonly content: LayoutRect;
38
30
  /**
39
- * Whether it overflows: its text is taller than its content box or splits a word, or an
40
- * in-flow child reaches past its padding box. Rendering draws it anyway.
31
+ * Text is taller than the content box or splits a word, or an in-flow child reaches past the
32
+ * padding box. Rendering draws it anyway.
41
33
  */
42
34
  readonly overflow: boolean;
43
- /** A text node's line count; `null` for other nodes. */
35
+ /** `null` for non-text nodes. */
44
36
  readonly lineCount: number | null;
45
- /**
46
- * A text node's first and last lines' alphabetic baselines, as fractions of the picture's height:
47
- * its content box's top plus its text's baselines. `null` for other nodes and empty text.
48
- */
37
+ /** `null` for non-text nodes and empty text. */
49
38
  readonly baselines: Baselines | null;
50
39
  }
51
- /** Where a text's first and last lines' alphabetic baselines lie, y as a fraction of the height. */
40
+ /** First and last alphabetic baselines, as fractions of the picture height. */
52
41
  export interface Baselines {
53
42
  readonly first: number;
54
43
  readonly last: number;
55
44
  }
56
- /** Where every node of a layout lies, the root first, in document order. */
45
+ /** Every node's bounds, root first, in document order. */
57
46
  export interface LayoutBounds {
58
47
  readonly nodes: readonly NodeBounds[];
59
48
  }
60
49
  /**
61
- * Where every node of `generator` (a layout generator, or its root) lies on `picture` at picture
62
- * time `time`, laid out with `binding`'s fonts as a frame lays it out. Measure at the size the
63
- * picture is drawn at: at another size, lines can break elsewhere. The layout's `"<n>px"` lengths
64
- * are pixels of `canvas`, the project canvas: `picture` itself by default, so a preview measured
65
- * at half size passes the project's own size here.
50
+ * Lays out `generator` (or a bare root node) on `picture` at `time` with `binding`'s fonts. Measure
51
+ * at the drawn size, since lines can break differently at other sizes. `"<n>px"` lengths are pixels
52
+ * of `canvas`, which defaults to `picture`; pass the project size when measuring a scaled preview.
66
53
  *
67
- * @throws An `INVALID_INPUT` error for a layout the model rejects (on that canvas), a picture or
68
- * canvas outside 1 to 16384 pixels a side, or a time that is not whole ticks; a text error for a
69
- * measurer without fonts when the layout has text.
54
+ * @throws An `INVALID_INPUT` error for a layout the model rejects, a picture or canvas outside 1 to
55
+ * 16384 pixels a side, or a non-integer tick time; a text error when the layout has text and the
56
+ * measurer has no fonts.
70
57
  */
71
58
  export declare function measureLayout(binding: LayoutBinding, generator: Generator | LayoutNode, picture: PictureSize, time?: Ticks, canvas?: PictureSize): LayoutBounds;
72
- /** A value, or the document's animated form of it. */
73
59
  export type Value<T> = T | Animated<T>;
74
- /** A length that may not be a percent: a fraction of the picture's shorter side, or `"12px"`. */
60
+ /** A fraction of the picture's shorter side, or `"12px"`. No percent. */
75
61
  export type Size = number | `${number}px`;
76
- /** A size or inset: a {@link Size}, or `"50%"` of the parent's content box. */
62
+ /** A {@link Size}, or a percent of the parent's content box. */
77
63
  export type Length = Size | `${number}%`;
78
64
  /**
79
- * The sides of a box: one size for all, the CSS shorthand (`"8px 16px"`), a
80
- * `[top, right, bottom, left]` tuple, or the sides object (missing sides 0).
65
+ * One size for all sides, a CSS shorthand (`"8px 16px"`), a `[top, right, bottom, left]` tuple, or
66
+ * a sides object (missing sides are 0).
81
67
  */
82
68
  export type Sides = number | string | readonly [Size, Size, Size, Size] | {
83
69
  readonly top?: Size;
@@ -85,34 +71,37 @@ export type Sides = number | string | readonly [Size, Size, Size, Size] | {
85
71
  readonly bottom?: Size;
86
72
  readonly left?: Size;
87
73
  };
88
- /** A color: the components object, or CSS hex (`"#1e2230"`) as `Rgba` allows. */
74
+ /** A components object or CSS hex string (`"#1e2230"`). */
89
75
  export type Color = Rgba;
90
- /** A paint, or a color painted solid. */
91
76
  export type Fill = Paint | Color;
92
- /** An offset: the CSS `translate` string (`"10px 20px"`), an `[x, y]` tuple, or `{ x, y }`. */
77
+ /** A CSS `translate` string (`"10px 20px"`), an `[x, y]` tuple, or `{ x, y }`. */
93
78
  export type Offset = string | readonly [Size, Size] | {
94
79
  readonly x: Size;
95
80
  readonly y: Size;
96
81
  };
97
- /** The style a box gives its text and the boxes in it, inherited as CSS inherits it. */
82
+ /** Text style, inherited by descendant boxes as in CSS. */
98
83
  export interface TextStyleProps {
99
84
  readonly font_family?: string;
100
85
  readonly font_size?: Value<Size>;
101
- /** The weight the family's faces are matched by, in `[1, 1000]`. Not animated. */
86
+ /** In `[1, 1000]`. Not animated. */
102
87
  readonly font_weight?: number;
103
- readonly color?: Color;
88
+ /** A color, or a gradient over the text's layout box. Not animated. */
89
+ readonly fill?: Fill;
104
90
  readonly line_height?: number;
105
- /** Space after each character, as a fraction of the font size, in `[-0.5, 1]`. Not animated. */
91
+ /** Space after each character as a fraction of the font size, in `[-0.5, 1]`. Not animated. */
106
92
  readonly letter_spacing?: number;
107
93
  readonly text_align?: TextAlign;
108
- readonly outline?: TextOutline;
94
+ /** Innermost first; widths are fractions of the font size. */
95
+ readonly strokes?: readonly TextStroke[];
96
+ /** First on top; lengths are fractions of the font size. */
97
+ readonly shadows?: readonly TextShadow[];
109
98
  }
110
- /** A box's CSS fields, with shorthands. */
99
+ /** A box's CSS fields, with shorthand forms accepted. */
111
100
  export interface BoxProps extends TextStyleProps {
112
101
  readonly display?: Display;
113
102
  readonly flex_direction?: FlexDirection;
114
103
  readonly flex_wrap?: FlexWrap;
115
- /** A grid's columns, as CSS writes them: `"1fr 2fr"`, `"repeat(3, minmax(100px, 1fr))"`. */
104
+ /** CSS syntax, such as `"1fr 2fr"` or `"repeat(3, minmax(100px, 1fr))"`. */
116
105
  readonly grid_template_columns?: string;
117
106
  readonly grid_template_rows?: string;
118
107
  readonly grid_auto_columns?: string;
@@ -146,7 +135,7 @@ export interface BoxProps extends TextStyleProps {
146
135
  readonly flex_basis?: Value<Length>;
147
136
  readonly align_self?: AlignItems;
148
137
  readonly justify_self?: AlignItems;
149
- /** The box's grid columns, as CSS writes them: `2`, `"1 / 3"`, `"span 2"`. */
138
+ /** CSS syntax, such as `2`, `"1 / 3"` or `"span 2"`. */
150
139
  readonly grid_column?: number | string;
151
140
  readonly grid_row?: number | string;
152
141
  readonly position?: Position;
@@ -162,21 +151,17 @@ export interface BoxProps extends TextStyleProps {
162
151
  readonly scale?: Value<Vec2> | number | readonly [number, number];
163
152
  readonly rotation_degrees?: Value<number>;
164
153
  }
165
- /** A layout generator whose root is `root`: the whole picture. */
154
+ /** A layout generator whose root covers the whole picture. */
166
155
  export declare function layout(root: LayoutNode): Generator;
167
- /** A box: a container holding `children`, or empty without them. */
156
+ /** A box, optionally holding `children`. */
168
157
  export declare function box(props?: BoxProps, ...children: LayoutNode[]): LayoutNode;
169
- /**
170
- * A box holding one paragraph of text, wrapped at its content width and drawn in the style it
171
- * sets or inherits.
172
- */
158
+ /** A box holding one paragraph of text, wrapped at its content width. */
173
159
  export declare function text(content: Value<string>, props?: Omit<BoxProps, ContainerField>): LayoutNode;
174
160
  /**
175
- * A box holding shapes, drawn on a picture the size of its content box: positions normalized to
176
- * it, lengths fractions of its shorter side. It has no size of its own: give it `width` and
177
- * `height`, an `aspect_ratio`, or `flex_grow`.
161
+ * A box holding shapes, with positions normalized to its content box and lengths as fractions of
162
+ * its shorter side. It has no intrinsic size, so give it `width` and `height`, an `aspect_ratio`,
163
+ * or `flex_grow`.
178
164
  */
179
165
  export declare function shape(items: readonly ShapeItem[], props?: Omit<BoxProps, ContainerField>): LayoutNode;
180
- /** The container fields a text or shape node may not take. */
181
166
  type ContainerField = "display" | "flex_direction" | "flex_wrap" | "grid_template_columns" | "grid_template_rows" | "grid_auto_columns" | "grid_auto_rows" | "grid_auto_flow" | "gap" | "row_gap" | "column_gap" | "justify_content" | "align_items" | "align_content" | "justify_items";
182
167
  export {};
package/dist/layout.js CHANGED
@@ -1,30 +1,22 @@
1
1
  /**
2
- * Layout generators for authors: boxes laid out by CSS flexbox or grid around their text and
3
- * shapes, as a project's `{ "type": "layout" }` generator holds them.
2
+ * Builders and measurement for `{ "type": "layout" }` generators (CSS flexbox and grid boxes).
4
3
  *
5
- * {@link measureLayout} answers, in wasm and with the fonts the engine draws with, where every box
6
- * of a layout lies on a picture and whether anything overflows, before anything is rendered. The
7
- * builder ({@link box}, {@link text}, {@link shape}, {@link layout}) writes the document from
8
- * CSS-like props: a value that is not animated becomes a constant, a `[top, right, bottom, left]`
9
- * tuple the sides object, an `[x, y]` tuple a vector. Lengths are written as the document writes
10
- * them: a number is a fraction of the picture's shorter side, `"12px"` pixels of the project
11
- * canvas, `"50%"` a percent of the parent's content box. Text style (`font_family`, `font_size`,
12
- * `font_weight`, `color`, `line_height`, `letter_spacing`, `text_align`, `outline`) may be set on
13
- * any box and is inherited. Its
14
- * output is a plain document that `validateProject` accepts; a CSS value string it cannot read
15
- * throws, with the parser's message.
4
+ * {@link measureLayout} computes every box's position and overflow in wasm with the engine's fonts.
5
+ * The builders ({@link box}, {@link text}, {@link shape}, {@link layout}) take CSS-like props:
6
+ * plain values become constants, and tuples expand to sides objects or vectors. A number length is
7
+ * a fraction of the picture's shorter side, `"12px"` is project canvas pixels, and `"50%"` is a
8
+ * percent of the parent's content box. Text style props may be set on any box and are inherited.
9
+ * The output is a plain document; an unreadable CSS value string throws the parser's message.
16
10
  */
17
11
  import { parseHex, parseInsets, parseLength, parseOffset, parsePlacement, parseSize, parseTrackList, } from "./layout-values.js";
18
12
  /**
19
- * Where every node of `generator` (a layout generator, or its root) lies on `picture` at picture
20
- * time `time`, laid out with `binding`'s fonts as a frame lays it out. Measure at the size the
21
- * picture is drawn at: at another size, lines can break elsewhere. The layout's `"<n>px"` lengths
22
- * are pixels of `canvas`, the project canvas: `picture` itself by default, so a preview measured
23
- * at half size passes the project's own size here.
13
+ * Lays out `generator` (or a bare root node) on `picture` at `time` with `binding`'s fonts. Measure
14
+ * at the drawn size, since lines can break differently at other sizes. `"<n>px"` lengths are pixels
15
+ * of `canvas`, which defaults to `picture`; pass the project size when measuring a scaled preview.
24
16
  *
25
- * @throws An `INVALID_INPUT` error for a layout the model rejects (on that canvas), a picture or
26
- * canvas outside 1 to 16384 pixels a side, or a time that is not whole ticks; a text error for a
27
- * measurer without fonts when the layout has text.
17
+ * @throws An `INVALID_INPUT` error for a layout the model rejects, a picture or canvas outside 1 to
18
+ * 16384 pixels a side, or a non-integer tick time; a text error when the layout has text and the
19
+ * measurer has no fonts.
28
20
  */
29
21
  export function measureLayout(binding, generator, picture, time = 0, canvas = picture) {
30
22
  const document = "type" in generator && generator.type === "layout"
@@ -32,27 +24,24 @@ export function measureLayout(binding, generator, picture, time = 0, canvas = pi
32
24
  : layout(generator);
33
25
  return JSON.parse(binding.measureLayout(JSON.stringify(document), picture.width, picture.height, time, canvas.width, canvas.height));
34
26
  }
35
- /** A layout generator whose root is `root`: the whole picture. */
27
+ /** A layout generator whose root covers the whole picture. */
36
28
  export function layout(root) {
37
29
  return { type: "layout", root };
38
30
  }
39
- /** A box: a container holding `children`, or empty without them. */
31
+ /** A box, optionally holding `children`. */
40
32
  export function box(props = {}, ...children) {
41
33
  return children.length > 0
42
34
  ? { ...boxFields(props), children }
43
35
  : boxFields(props);
44
36
  }
45
- /**
46
- * A box holding one paragraph of text, wrapped at its content width and drawn in the style it
47
- * sets or inherits.
48
- */
37
+ /** A box holding one paragraph of text, wrapped at its content width. */
49
38
  export function text(content, props = {}) {
50
39
  return { ...boxFields(props), text: animated(content) };
51
40
  }
52
41
  /**
53
- * A box holding shapes, drawn on a picture the size of its content box: positions normalized to
54
- * it, lengths fractions of its shorter side. It has no size of its own: give it `width` and
55
- * `height`, an `aspect_ratio`, or `flex_grow`.
42
+ * A box holding shapes, with positions normalized to its content box and lengths as fractions of
43
+ * its shorter side. It has no intrinsic size, so give it `width` and `height`, an `aspect_ratio`,
44
+ * or `flex_grow`.
56
45
  */
57
46
  export function shape(items, props = {}) {
58
47
  return { ...boxFields(props), shape: { items } };
@@ -66,13 +55,13 @@ function isAnimated(value) {
66
55
  function animated(value) {
67
56
  return isAnimated(value) ? value : { mode: "constant", value };
68
57
  }
69
- /** `value` when `parse` reads it; otherwise the parser's message, thrown. */
58
+ /** Returns `value`, or throws the parser's message. */
70
59
  function checked(value, parsed) {
71
60
  if (!parsed.ok)
72
61
  throw new TypeError(parsed.error);
73
62
  return value;
74
63
  }
75
- /** A length's or size's string checked as the engine reads it; numbers as they are. */
64
+ /** Validates string lengths; numbers pass through. */
76
65
  function lengthValue(value, percent) {
77
66
  if (typeof value !== "string")
78
67
  return value;
@@ -105,7 +94,7 @@ function offsetValue(value) {
105
94
  const { x, y } = value;
106
95
  return { x: lengthValue(x, false), y: lengthValue(y, false) };
107
96
  }
108
- /** `value` as an animated field, each of its values mapped by `map` when it is not animated. */
97
+ /** Wraps a plain value as a constant after `map`; animated values pass through unchanged. */
109
98
  function field(value, map) {
110
99
  return isAnimated(value) ? value : { mode: "constant", value: map(value) };
111
100
  }
@@ -119,7 +108,7 @@ function scaleField(value) {
119
108
  }
120
109
  return animated(value);
121
110
  }
122
- /** `props` as the document's fields, each shorthand written out; absent fields stay absent. */
111
+ /** Expands shorthands in `props` to document fields. */
123
112
  function boxFields(props) {
124
113
  const fields = {};
125
114
  for (const [name, value] of Object.entries(props)) {
@@ -181,9 +170,21 @@ function boxFields(props) {
181
170
  case "grid_row":
182
171
  fields[name] = checked(value, parsePlacement(value));
183
172
  break;
184
- case "color":
173
+ case "fill":
185
174
  fields[name] = fillValue(value);
186
175
  break;
176
+ case "strokes":
177
+ fields[name] = value.map((stroke) => ({
178
+ ...stroke,
179
+ color: fillValue(stroke.color),
180
+ }));
181
+ break;
182
+ case "shadows":
183
+ fields[name] = value.map((shadow) => ({
184
+ ...shadow,
185
+ color: fillValue(shadow.color),
186
+ }));
187
+ break;
187
188
  case "translate":
188
189
  fields[name] = field(value, offsetValue);
189
190
  break;
@@ -191,8 +192,7 @@ function boxFields(props) {
191
192
  fields[name] = scaleField(value);
192
193
  break;
193
194
  default:
194
- // CSS keywords, the aspect ratio and the plain style values are written as they are;
195
- // anything else the model refuses by name.
195
+ // Written as is; the model rejects unknown fields by name.
196
196
  fields[name] = value;
197
197
  }
198
198
  }
@@ -1,18 +1,15 @@
1
1
  /**
2
- * Loudness measurement and normalization (ITU-R BS.1770-4, EBU R128),
3
- * computed by the engine with the same code a native host uses.
2
+ * Loudness measurement and normalization (ITU-R BS.1770-4, EBU R128), computed by the engine.
4
3
  *
5
- * Measure decoded audio with {@link measureLoudness}. To export at a target
6
- * loudness, measure the export's mix before the master limiter first: turn
7
- * `setLoudnessMetering(true)` on the engine, render the export's audio once
8
- * with `renderAudio`, parse its report with `JSON.parse(engine.loudnessReport())`,
9
- * plan the gain with {@link planLoudnessNormalization}, and render the export with
10
- * `setNormalizationGainDb(plan.gainDb)`. The engine's report states the master
11
- * limiter's threshold, and the plan keeps the mix under it, so the limiter
12
- * leaves the export at the planned loudness. Turning metering on removes the
13
- * gain, so the cycle can run again; set zero for audio that is not normalized.
4
+ * To export at a target loudness:
5
+ * 1. call `setLoudnessMetering(true)` on the engine and render the audio once with `renderAudio`;
6
+ * 2. pass `JSON.parse(engine.loudnessReport())` to {@link planLoudnessNormalization};
7
+ * 3. render the export with `setNormalizationGainDb(plan.gainDb)`.
8
+ *
9
+ * The plan keeps the mix under the master limiter's threshold, so the limiter does not change the
10
+ * planned loudness. Enabling metering resets the gain to zero.
14
11
  */
15
- /** What a loudness measurement found. `null` where nothing was measurable. */
12
+ /** Loudness measurement. A field is `null` when nothing was measurable. */
16
13
  export interface LoudnessReport {
17
14
  /** Gated integrated loudness, LUFS; `null` for audio below -70 LUFS. */
18
15
  readonly integratedLufs: number | null;
@@ -29,13 +26,12 @@ export interface LoudnessReport {
29
26
  /** Samples measured per channel. */
30
27
  readonly frames: number;
31
28
  /**
32
- * The linear threshold of the master limiter the mix was measured in front of: `null` for a mix
33
- * without one, absent from a {@link measureLoudness} measurement. The engine's
34
- * `loudnessReport()` states it, and a plan keeps the mix's sample peak under it.
29
+ * Linear threshold of the master limiter after the metering point; `null` without a limiter and
30
+ * absent from {@link measureLoudness} results.
35
31
  */
36
32
  readonly limiterThreshold?: number | null;
37
33
  }
38
- /** A static gain that brings a mix to a loudness target. */
34
+ /** Static gain that brings a mix to a loudness target. */
39
35
  export interface LoudnessNormalization {
40
36
  /** Gain to apply before the master limiter, dB. */
41
37
  readonly gainDb: number;
@@ -44,17 +40,17 @@ export interface LoudnessNormalization {
44
40
  /** True peak after the gain, dBTP. */
45
41
  readonly truePeakDbtp: number;
46
42
  /**
47
- * Whether a peak bound set the gain, leaving the result quieter than the target: the true-peak
48
- * ceiling, or the master limiter (`limiterLimited`).
43
+ * Whether the true-peak ceiling or the master limiter capped the gain, leaving the result quieter
44
+ * than the target.
49
45
  */
50
46
  readonly peakLimited: boolean;
51
47
  /**
52
- * Whether the master limiter's threshold set the gain, below what the ceiling allows: the mix's
53
- * sample peak is kept 0.01 dB under it, so the limiter does not act.
48
+ * Whether the limiter threshold capped the gain; the sample peak is kept 0.01 dB under it so the
49
+ * limiter does not act.
54
50
  */
55
51
  readonly limiterLimited: boolean;
56
52
  }
57
- /** The parts of `alpha2/wasm` loudness uses. */
53
+ /** The `alpha2/wasm` items loudness uses. */
58
54
  export interface LoudnessBinding {
59
55
  readonly LoudnessMeter: new (sampleRate: number, channels: number) => {
60
56
  push(planar: Float32Array): void;
@@ -64,21 +60,20 @@ export interface LoudnessBinding {
64
60
  planLoudnessNormalization(reportJson: string, targetLufs: number, ceilingDbtp: number): string;
65
61
  }
66
62
  /**
67
- * Measures planar audio: one `Float32Array` per channel, all one length. A NaN
68
- * or infinite sample measures as silence. `blockFrames` is how many frames are
69
- * copied into wasm per call.
63
+ * Measures planar audio, one equal-length `Float32Array` per channel. Non-finite samples count as
64
+ * silence. `blockFrames` is the number of frames copied into wasm per call.
70
65
  *
71
- * @throws RangeError When there are no planes, their lengths differ, or
72
- * `blockFrames` is not a positive integer.
73
- * @throws When the engine refuses the sample rate (outside 8 to 96 kHz).
66
+ * @throws RangeError When there are no planes, their lengths differ, or `blockFrames` is not a
67
+ * positive integer.
68
+ * @throws When the sample rate is outside 8 to 96 kHz.
74
69
  */
75
70
  export declare function measureLoudness(binding: LoudnessBinding, planes: readonly Float32Array[], sampleRate: number, blockFrames?: number): LoudnessReport;
76
71
  /**
77
- * The gain that brings `report` to `targetLufs` without its true peak passing `ceilingDbtp`
78
- * (default -1 dBTP), or its sample peak reaching the master limiter `report.limiterThreshold`
79
- * states; `null` for audio silent below the absolute gate.
72
+ * Plans the gain that brings `report` to `targetLufs` without the true peak exceeding
73
+ * `ceilingDbtp` or the sample peak reaching `report.limiterThreshold`. Returns `null` for audio
74
+ * below the absolute gate.
80
75
  *
81
- * @throws TypeError When `report` is not an object: the engine's `loudnessReport()` returns JSON
82
- * text, which is parsed first, and `null` while metering is off, which measured nothing.
76
+ * @throws TypeError When `report` is not an object (for example the unparsed JSON string from
77
+ * `loudnessReport()`, or its `null` while metering is off).
83
78
  */
84
79
  export declare function planLoudnessNormalization(binding: LoudnessBinding, report: LoudnessReport, targetLufs: number, ceilingDbtp?: number): LoudnessNormalization | null;
package/dist/loudness.js CHANGED
@@ -1,25 +1,21 @@
1
1
  /**
2
- * Loudness measurement and normalization (ITU-R BS.1770-4, EBU R128),
3
- * computed by the engine with the same code a native host uses.
2
+ * Loudness measurement and normalization (ITU-R BS.1770-4, EBU R128), computed by the engine.
4
3
  *
5
- * Measure decoded audio with {@link measureLoudness}. To export at a target
6
- * loudness, measure the export's mix before the master limiter first: turn
7
- * `setLoudnessMetering(true)` on the engine, render the export's audio once
8
- * with `renderAudio`, parse its report with `JSON.parse(engine.loudnessReport())`,
9
- * plan the gain with {@link planLoudnessNormalization}, and render the export with
10
- * `setNormalizationGainDb(plan.gainDb)`. The engine's report states the master
11
- * limiter's threshold, and the plan keeps the mix under it, so the limiter
12
- * leaves the export at the planned loudness. Turning metering on removes the
13
- * gain, so the cycle can run again; set zero for audio that is not normalized.
4
+ * To export at a target loudness:
5
+ * 1. call `setLoudnessMetering(true)` on the engine and render the audio once with `renderAudio`;
6
+ * 2. pass `JSON.parse(engine.loudnessReport())` to {@link planLoudnessNormalization};
7
+ * 3. render the export with `setNormalizationGainDb(plan.gainDb)`.
8
+ *
9
+ * The plan keeps the mix under the master limiter's threshold, so the limiter does not change the
10
+ * planned loudness. Enabling metering resets the gain to zero.
14
11
  */
15
12
  /**
16
- * Measures planar audio: one `Float32Array` per channel, all one length. A NaN
17
- * or infinite sample measures as silence. `blockFrames` is how many frames are
18
- * copied into wasm per call.
13
+ * Measures planar audio, one equal-length `Float32Array` per channel. Non-finite samples count as
14
+ * silence. `blockFrames` is the number of frames copied into wasm per call.
19
15
  *
20
- * @throws RangeError When there are no planes, their lengths differ, or
21
- * `blockFrames` is not a positive integer.
22
- * @throws When the engine refuses the sample rate (outside 8 to 96 kHz).
16
+ * @throws RangeError When there are no planes, their lengths differ, or `blockFrames` is not a
17
+ * positive integer.
18
+ * @throws When the sample rate is outside 8 to 96 kHz.
23
19
  */
24
20
  export function measureLoudness(binding, planes, sampleRate, blockFrames = 65_536) {
25
21
  const channels = planes.length;
@@ -45,15 +41,15 @@ export function measureLoudness(binding, planes, sampleRate, blockFrames = 65_53
45
41
  }
46
42
  }
47
43
  /**
48
- * The gain that brings `report` to `targetLufs` without its true peak passing `ceilingDbtp`
49
- * (default -1 dBTP), or its sample peak reaching the master limiter `report.limiterThreshold`
50
- * states; `null` for audio silent below the absolute gate.
44
+ * Plans the gain that brings `report` to `targetLufs` without the true peak exceeding
45
+ * `ceilingDbtp` or the sample peak reaching `report.limiterThreshold`. Returns `null` for audio
46
+ * below the absolute gate.
51
47
  *
52
- * @throws TypeError When `report` is not an object: the engine's `loudnessReport()` returns JSON
53
- * text, which is parsed first, and `null` while metering is off, which measured nothing.
48
+ * @throws TypeError When `report` is not an object (for example the unparsed JSON string from
49
+ * `loudnessReport()`, or its `null` while metering is off).
54
50
  */
55
51
  export function planLoudnessNormalization(binding, report, targetLufs, ceilingDbtp = -1) {
56
- // An unchecked string or null would plan as silence, the same answer as quiet audio.
52
+ // Without this check a string or null would silently plan as silence.
57
53
  if (typeof report !== "object" || report === null)
58
54
  throw new TypeError("planLoudnessNormalization takes a report object: parse loudnessReport() with JSON.parse, " +
59
55
  "and measure with metering on");