alpha2 0.3.1 → 0.4.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 CHANGED
@@ -88,6 +88,7 @@ For preview, `alpha2/audio-timeline` moves the mixed blocks to the audio thread
88
88
  | `alpha2/edit` | Editing operations on a project: split, trim, ripple, roll, slip, slide, retime, insert, overwrite, append, move. |
89
89
  | `alpha2/captions` | SRT and WebVTT import into caption tracks. |
90
90
  | `alpha2/geometry` | Shape geometry for editors, from the engine's own code: item bounds, hit tests, nearest points, path lengths, trims, resampling, convert to path, motion paths. |
91
+ | `alpha2/layout` | Layout generators: `measureLayout` (where every box lies and what overflows, laid out with the engine's fonts, pixels those of the project canvas) and a builder from CSS-like props, flexbox and grid. See [docs/layout.md](https://github.com/alpha2-sh/alpha2/blob/main/docs/layout.md). |
91
92
  | `alpha2/effects` | Effect definitions and the built-in catalog's types; `RuntimeEffectRegistry`, a typed wrapper for registering WGSL effects and effect resources at run time. |
92
93
  | `alpha2/extensions`, `alpha2/extensions-wasm` | SVG, animated image, Lottie, OpenEXR and image sequence sources, from their own WebAssembly module (`loadExtensions`). |
93
94
  | `alpha2/text` | Text rasterizers: `WasmTextRasterizer` (the engine's, the same pixels as a native export) and `OffscreenTextRasterizer` (the browser's). |
@@ -56,12 +56,24 @@ export declare const MAX_FRAME_INLINED_NODES = 65536;
56
56
  export declare const MAX_GAIN = 16;
57
57
  /** Mirrors `alpha2_model::MAX_GRADIENT_STOPS`. */
58
58
  export declare const MAX_GRADIENT_STOPS = 8;
59
+ /** Mirrors `alpha2_model::MAX_GRID_TRACKS`. */
60
+ export declare const MAX_GRID_TRACKS = 64;
59
61
  /** Mirrors `alpha2_model::MAX_GROUP_INPUTS`. */
60
62
  export declare const MAX_GROUP_INPUTS = 16;
61
63
  /** Mirrors `alpha2_model::MAX_HDR_PEAK_NITS`. */
62
64
  export declare const MAX_HDR_PEAK_NITS = 10000;
63
65
  /** Mirrors `alpha2_model::MAX_INLINED_NODES`. */
64
66
  export declare const MAX_INLINED_NODES = 65536;
67
+ /** Mirrors `alpha2_model::MAX_LAYOUT_DEPTH`. */
68
+ export declare const MAX_LAYOUT_DEPTH = 16;
69
+ /** Mirrors `alpha2_model::MAX_LAYOUT_FONT_SIZE`. */
70
+ export declare const MAX_LAYOUT_FONT_SIZE = 1;
71
+ /** Mirrors `alpha2_model::MAX_LAYOUT_ISOLATED`. */
72
+ export declare const MAX_LAYOUT_ISOLATED = 16;
73
+ /** Mirrors `alpha2_model::MAX_LAYOUT_NODES`. */
74
+ export declare const MAX_LAYOUT_NODES = 256;
75
+ /** Mirrors `alpha2_model::MAX_LAYOUT_TEXTS`. */
76
+ export declare const MAX_LAYOUT_TEXTS = 64;
65
77
  /** Mirrors `alpha2_model::MAX_LINE_HEIGHT`. */
66
78
  export declare const MAX_LINE_HEIGHT = 3;
67
79
  /** Mirrors `alpha2_model::MAX_LOOKAHEAD_MS`. */
@@ -120,6 +132,10 @@ export declare const MIN_SAMPLE_RATE = 8000;
120
132
  export declare const REVERB_DELAY_MS = 160;
121
133
  /** Mirrors `alpha2_model::TICKS_PER_SECOND`. */
122
134
  export declare const TICKS_PER_SECOND = 120000;
135
+ /** Every {@link AlignContent}, in the model's order. */
136
+ export declare const ALIGN_CONTENT_VALUES: readonly AlignContent[];
137
+ /** Every {@link AlignItems}, in the model's order. */
138
+ export declare const ALIGN_ITEMS_VALUES: readonly AlignItems[];
123
139
  /** Every {@link BlendSpace}, in the model's order. */
124
140
  export declare const BLEND_SPACE_VALUES: readonly BlendSpace[];
125
141
  /** Every {@link CacheIntent}, in the model's order. */
@@ -132,6 +148,8 @@ export declare const COLOR_MATRIX_VALUES: readonly ColorMatrix[];
132
148
  export declare const COLOR_PRIMARIES_VALUES: readonly ColorPrimaries[];
133
149
  /** Every {@link ColorRange}, in the model's order. */
134
150
  export declare const COLOR_RANGE_VALUES: readonly ColorRange[];
151
+ /** Every {@link Display}, in the model's order. */
152
+ export declare const DISPLAY_VALUES: readonly Display[];
135
153
  /** Every {@link DynamicRange}, in the model's order. */
136
154
  export declare const DYNAMIC_RANGE_VALUES: readonly DynamicRange[];
137
155
  /** Every {@link EffectResourceKind}, in the model's order. */
@@ -142,8 +160,16 @@ export declare const EQ_BAND_KIND_VALUES: readonly EqBandKind[];
142
160
  export declare const FADE_SHAPE_VALUES: readonly FadeShape[];
143
161
  /** Every {@link FillRule}, in the model's order. */
144
162
  export declare const FILL_RULE_VALUES: readonly FillRule[];
163
+ /** Every {@link FlexDirection}, in the model's order. */
164
+ export declare const FLEX_DIRECTION_VALUES: readonly FlexDirection[];
165
+ /** Every {@link FlexWrap}, in the model's order. */
166
+ export declare const FLEX_WRAP_VALUES: readonly FlexWrap[];
167
+ /** Every {@link GridAutoFlow}, in the model's order. */
168
+ export declare const GRID_AUTO_FLOW_VALUES: readonly GridAutoFlow[];
145
169
  /** Every {@link HdrSources}, in the model's order. */
146
170
  export declare const HDR_SOURCES_VALUES: readonly HdrSources[];
171
+ /** Every {@link JustifyContent}, in the model's order. */
172
+ export declare const JUSTIFY_CONTENT_VALUES: readonly JustifyContent[];
147
173
  /** Every {@link LineCap}, in the model's order. */
148
174
  export declare const LINE_CAP_VALUES: readonly LineCap[];
149
175
  /** Every {@link LineJoin}, in the model's order. */
@@ -160,8 +186,12 @@ export declare const MATTE_MODE_VALUES: readonly MatteMode[];
160
186
  export declare const MEDIA_KIND_VALUES: readonly MediaKind[];
161
187
  /** Every {@link MissingFrames}, in the model's order. */
162
188
  export declare const MISSING_FRAMES_VALUES: readonly MissingFrames[];
189
+ /** Every {@link Overflow}, in the model's order. */
190
+ export declare const OVERFLOW_VALUES: readonly Overflow[];
163
191
  /** Every {@link PolystarKind}, in the model's order. */
164
192
  export declare const POLYSTAR_KIND_VALUES: readonly PolystarKind[];
193
+ /** Every {@link Position}, in the model's order. */
194
+ export declare const POSITION_VALUES: readonly Position[];
165
195
  /** Every {@link Spread}, in the model's order. */
166
196
  export declare const SPREAD_VALUES: readonly Spread[];
167
197
  /** Every {@link TextAlign}, in the model's order. */
@@ -222,6 +252,16 @@ export interface Project {
222
252
  */
223
253
  readonly timeline: Timeline;
224
254
  }
255
+ /**
256
+ * Where the lines of a wrapping flex container, or a grid's rows, lie
257
+ * across the container.
258
+ */
259
+ export type AlignContent = "start" | "center" | "end" | "space_between" | "space_around" | "space_evenly" | "stretch";
260
+ /**
261
+ * Where children lie across a flex container's main axis, or in their grid
262
+ * areas.
263
+ */
264
+ export type AlignItems = "start" | "center" | "end" | "stretch";
225
265
  /**
226
266
  * A value that is either constant or controlled by sorted keyframes.
227
267
  */
@@ -762,6 +802,10 @@ export interface Dash {
762
802
  */
763
803
  readonly pattern: readonly Animated<number>[];
764
804
  }
805
+ /**
806
+ * How a box lays its children out.
807
+ */
808
+ export type Display = "flex" | "grid";
765
809
  /**
766
810
  * Sidechain ducking authored on the track that is attenuated.
767
811
  */
@@ -928,6 +972,14 @@ export type FadeShape = "linear" | "equal_power";
928
972
  * Which regions of a path are inside it.
929
973
  */
930
974
  export type FillRule = "nonzero" | "evenodd";
975
+ /**
976
+ * The main axis of a flex container.
977
+ */
978
+ export type FlexDirection = "row" | "column" | "row_reverse" | "column_reverse";
979
+ /**
980
+ * Whether a flex container's children wrap.
981
+ */
982
+ export type FlexWrap = "nowrap" | "wrap";
931
983
  /**
932
984
  * A positive rational frame rate in reduced form, at most one frame per tick
933
985
  * (120 000 frames per second).
@@ -950,7 +1002,7 @@ export interface FrameRate {
950
1002
  * top-left to `(1, 1)` bottom-right; lengths (radii, stroke widths) are
951
1003
  * fractions of its shorter side, so the picture is the same at any render
952
1004
  * resolution. A fill or text does not change over time (a clip animates it
953
- * with its transform, effects, and masks); shapes may.
1005
+ * with its transform, effects, and masks); shapes and layouts may.
954
1006
  */
955
1007
  export type Generator = {
956
1008
  /**
@@ -991,6 +1043,18 @@ export type Generator = {
991
1043
  * the fonts its host registered.
992
1044
  */
993
1045
  readonly type: "text";
1046
+ } | {
1047
+ /**
1048
+ * The root box: the whole picture.
1049
+ */
1050
+ readonly root: LayoutNode;
1051
+ /**
1052
+ * Boxes laid out by CSS flexbox around their text and shapes. Its
1053
+ * picture changes over time when any value in the tree is keyframed,
1054
+ * in the picture's time. The engine lays it out with the fonts it
1055
+ * draws with. See `LayoutNode`.
1056
+ */
1057
+ readonly type: "layout";
994
1058
  };
995
1059
  /**
996
1060
  * One color of a gradient.
@@ -1005,10 +1069,27 @@ export interface GradientStop {
1005
1069
  */
1006
1070
  readonly offset: number;
1007
1071
  }
1072
+ /**
1073
+ * How a grid places items that have no placement of their own.
1074
+ */
1075
+ export type GridAutoFlow = "row" | "column" | "row_dense" | "column_dense";
1076
+ /**
1077
+ * Where a grid item lies on one axis, as CSS writes it: 2, "1 / 3", "span 2", "2 / span 3", "auto". Lines count from 1, or from -1 at the end.
1078
+ */
1079
+ export type GridPlacement = number | string;
1008
1080
  /**
1009
1081
  * What a project does with HDR sources.
1010
1082
  */
1011
1083
  export type HdrSources = "tone_map" | "reject";
1084
+ /**
1085
+ * A length on each side of a box: one length for every side, the CSS shorthand of one to four lengths ("8px 16px": top first, clockwise), or the sides object, missing sides 0.
1086
+ */
1087
+ export type Insets = number | string | {
1088
+ readonly bottom?: LayoutSize;
1089
+ readonly left?: LayoutSize;
1090
+ readonly right?: LayoutSize;
1091
+ readonly top?: LayoutSize;
1092
+ };
1012
1093
  /**
1013
1094
  * Interpolation from one keyframe to the next.
1014
1095
  *
@@ -1048,6 +1129,11 @@ export type Interpolation = {
1048
1129
  */
1049
1130
  readonly y2: number;
1050
1131
  };
1132
+ /**
1133
+ * Where children lie along a container's main axis, or a grid's columns in
1134
+ * it.
1135
+ */
1136
+ export type JustifyContent = "start" | "center" | "end" | "space_between" | "space_around" | "space_evenly";
1051
1137
  /**
1052
1138
  * One timestamped control value.
1053
1139
  */
@@ -1058,7 +1144,9 @@ export interface Keyframe<T> {
1058
1144
  readonly interpolation: Interpolation;
1059
1145
  /**
1060
1146
  * Timestamp of this value: timeline time, except in a composition
1061
- * node's settings, which are keyed in composition time.
1147
+ * node's settings, which are keyed in composition time, and in a
1148
+ * shapes or layout generator's tree, which is keyed in its picture's
1149
+ * time.
1062
1150
  */
1063
1151
  readonly time: MediaTime;
1064
1152
  /**
@@ -1066,6 +1154,314 @@ export interface Keyframe<T> {
1066
1154
  */
1067
1155
  readonly value: T;
1068
1156
  }
1157
+ /**
1158
+ * A border inside the border box, as wide on every side.
1159
+ */
1160
+ export interface LayoutBorder {
1161
+ /**
1162
+ * What covers the border. Positions are normalized to the border box.
1163
+ */
1164
+ readonly paint: Animated<Paint>;
1165
+ /**
1166
+ * Width. At least 0.
1167
+ */
1168
+ readonly width: Animated<LayoutSize>;
1169
+ }
1170
+ /**
1171
+ * Where an absolute box lies in its parent's padding box. A missing side is
1172
+ * auto: with neither `left` nor `right`, the box keeps its place in the
1173
+ * flow on that axis.
1174
+ */
1175
+ export interface LayoutInset {
1176
+ /**
1177
+ * Distance from the parent's bottom padding edge.
1178
+ */
1179
+ readonly bottom?: Animated<LayoutLength> | null;
1180
+ /**
1181
+ * Distance from the parent's left padding edge.
1182
+ */
1183
+ readonly left?: Animated<LayoutLength> | null;
1184
+ /**
1185
+ * Distance from the parent's right padding edge.
1186
+ */
1187
+ readonly right?: Animated<LayoutLength> | null;
1188
+ /**
1189
+ * Distance from the parent's top padding edge.
1190
+ */
1191
+ readonly top?: Animated<LayoutLength> | null;
1192
+ }
1193
+ /**
1194
+ * A length: a number is a fraction of the layout picture's shorter side, "<n>px" pixels of the project canvas, "<n>%" a percent of the parent's content box along the field's axis.
1195
+ */
1196
+ export type LayoutLength = number | string;
1197
+ /**
1198
+ * One box of a layout tree.
1199
+ *
1200
+ * A box lays its children out by flexbox (`display: flex`, the default) or
1201
+ * grid (`display: grid`). It is a container when it has children, a leaf
1202
+ * when it has text or shape content, and empty otherwise (a spacer or a
1203
+ * decoration). Per box, its background is drawn first, then its border,
1204
+ * then its content. Boxes are drawn in document order; a reversed
1205
+ * direction or a grid placement moves them, not their order.
1206
+ */
1207
+ export interface LayoutNode {
1208
+ /**
1209
+ * Where lines of a wrapping flex container, or a grid's rows, lie
1210
+ * across the container. Default `stretch`.
1211
+ */
1212
+ readonly align_content?: AlignContent | null;
1213
+ /**
1214
+ * Where children lie across the main axis, or in their grid areas'
1215
+ * rows. Default `stretch`.
1216
+ */
1217
+ readonly align_items?: AlignItems | null;
1218
+ /**
1219
+ * Where the box lies across its flex container's main axis, or in its
1220
+ * grid area's row. `None` follows the parent's `align_items`.
1221
+ */
1222
+ readonly align_self?: AlignItems | null;
1223
+ /**
1224
+ * Width over height. Positive.
1225
+ */
1226
+ readonly aspect_ratio?: number | null;
1227
+ /**
1228
+ * What covers the border box, rounded by `border_radius`. Positions
1229
+ * are normalized to the border box.
1230
+ */
1231
+ readonly background?: Animated<Paint> | null;
1232
+ /**
1233
+ * A border inside the border box.
1234
+ */
1235
+ readonly border?: LayoutBorder | null;
1236
+ /**
1237
+ * The corner radius of the border box. At least 0; default 0. A radius
1238
+ * past half the box's shorter side is capped.
1239
+ */
1240
+ readonly border_radius?: Animated<LayoutSize> | null;
1241
+ /**
1242
+ * Boxes laid out in this one, in document (and paint) order. Not with
1243
+ * `text` or `shape`.
1244
+ */
1245
+ readonly children?: readonly LayoutNode[];
1246
+ /**
1247
+ * Text color. Inherited; the root's is white.
1248
+ */
1249
+ readonly color?: Rgba | null;
1250
+ /**
1251
+ * Space between columns, in place of `gap`. At least 0.
1252
+ */
1253
+ readonly column_gap?: Animated<LayoutSize> | null;
1254
+ /**
1255
+ * How the box lays its children out. Default `flex`. Not on a box with
1256
+ * text or shape content, as every container field.
1257
+ */
1258
+ readonly display?: Display | null;
1259
+ /**
1260
+ * The main size before growing and shrinking. `None` is auto.
1261
+ */
1262
+ readonly flex_basis?: Animated<LayoutLength> | null;
1263
+ /**
1264
+ * The main axis of a flex container's children. Default `row`.
1265
+ */
1266
+ readonly flex_direction?: FlexDirection | null;
1267
+ /**
1268
+ * How much of a flex container's free space the box takes. At least
1269
+ * 0; default 0. Not in a grid, as every flex item field.
1270
+ */
1271
+ readonly flex_grow?: Animated<number> | null;
1272
+ /**
1273
+ * How much the box gives up when a flex container's space runs short.
1274
+ * At least 0; default 1.
1275
+ */
1276
+ readonly flex_shrink?: Animated<number> | null;
1277
+ /**
1278
+ * Whether a flex container's children wrap onto more lines. Default
1279
+ * `nowrap`.
1280
+ */
1281
+ readonly flex_wrap?: FlexWrap | null;
1282
+ /**
1283
+ * The family the box's text draws in, as a text style's
1284
+ * `font_family`. Inherited; the root's is the host's first font.
1285
+ */
1286
+ readonly font_family?: string | null;
1287
+ /**
1288
+ * Font size: positive, at most `MAX_LAYOUT_FONT_SIZE` of the
1289
+ * picture's shorter side. Inherited; the root's is 0.05.
1290
+ */
1291
+ readonly font_size?: Animated<LayoutSize> | null;
1292
+ /**
1293
+ * Space between children, on both axes. At least 0; default 0.
1294
+ */
1295
+ readonly gap?: Animated<LayoutSize> | null;
1296
+ /**
1297
+ * The size of a grid's implicit columns. Default `auto`.
1298
+ */
1299
+ readonly grid_auto_columns?: TrackList | null;
1300
+ /**
1301
+ * How a grid places items without a placement. Default `row`.
1302
+ */
1303
+ readonly grid_auto_flow?: GridAutoFlow | null;
1304
+ /**
1305
+ * The size of a grid's implicit rows. Default `auto`.
1306
+ */
1307
+ readonly grid_auto_rows?: TrackList | null;
1308
+ /**
1309
+ * The box's columns in its grid, as CSS writes them (`2`, `"1 / 3"`,
1310
+ * `"span 2"`). Default `auto`.
1311
+ */
1312
+ readonly grid_column?: GridPlacement | null;
1313
+ /**
1314
+ * The box's rows in its grid. Default `auto`.
1315
+ */
1316
+ readonly grid_row?: GridPlacement | null;
1317
+ /**
1318
+ * A grid's explicit columns, as CSS writes them (`"1fr 2fr"`,
1319
+ * `"repeat(3, minmax(100px, 1fr))"`). Default none.
1320
+ */
1321
+ readonly grid_template_columns?: TrackList | null;
1322
+ /**
1323
+ * A grid's explicit rows. Default none.
1324
+ */
1325
+ readonly grid_template_rows?: TrackList | null;
1326
+ /**
1327
+ * Border-box height. `None` is auto.
1328
+ */
1329
+ readonly height?: Animated<LayoutLength> | null;
1330
+ /**
1331
+ * Where an `absolute` box lies in its parent's padding box.
1332
+ */
1333
+ readonly inset?: LayoutInset | null;
1334
+ /**
1335
+ * Where children lie along the main (inline, for a grid) axis. Default
1336
+ * `start`.
1337
+ */
1338
+ readonly justify_content?: JustifyContent | null;
1339
+ /**
1340
+ * Where a grid's children lie in their grid areas' columns. Default
1341
+ * `stretch`.
1342
+ */
1343
+ readonly justify_items?: AlignItems | null;
1344
+ /**
1345
+ * Where the box lies in its grid area's column. `None` follows the
1346
+ * parent's `justify_items`. Not in a flex container, as every grid
1347
+ * item field.
1348
+ */
1349
+ readonly justify_self?: AlignItems | null;
1350
+ /**
1351
+ * Baseline-to-baseline distance in font sizes, in `[0.5, 3]`.
1352
+ * Inherited; the root's is 1.2.
1353
+ */
1354
+ readonly line_height?: number | null;
1355
+ /**
1356
+ * Space outside the border, written as `padding` is. Sides may be
1357
+ * negative; there is no `auto`.
1358
+ */
1359
+ readonly margin?: Animated<Insets> | null;
1360
+ /**
1361
+ * Largest height. `None` is none.
1362
+ */
1363
+ readonly max_height?: Animated<LayoutLength> | null;
1364
+ /**
1365
+ * Largest width. `None` is none.
1366
+ */
1367
+ readonly max_width?: Animated<LayoutLength> | null;
1368
+ /**
1369
+ * Smallest height. `None` is auto.
1370
+ */
1371
+ readonly min_height?: Animated<LayoutLength> | null;
1372
+ /**
1373
+ * Smallest width. `None` is auto, the CSS automatic minimum size.
1374
+ */
1375
+ readonly min_width?: Animated<LayoutLength> | null;
1376
+ /**
1377
+ * Opacity of the box and everything in it, as one group, in `0..=1`.
1378
+ * Drawn after layout; it never moves a box.
1379
+ */
1380
+ readonly opacity?: Animated<number> | null;
1381
+ /**
1382
+ * A band around the glyphs; its width a fraction of the font size.
1383
+ * Inherited; the root has none.
1384
+ */
1385
+ readonly outline?: TextOutline | null;
1386
+ /**
1387
+ * Whether content past the padding box is drawn. Default `visible`.
1388
+ */
1389
+ readonly overflow?: Overflow | null;
1390
+ /**
1391
+ * Space inside the border: a length, the CSS shorthand
1392
+ * (`"8px 16px"`), or the sides object. Sides at least 0; default 0.
1393
+ */
1394
+ readonly padding?: Animated<Insets> | null;
1395
+ /**
1396
+ * Whether the box is in its parent's flow. Default `relative`.
1397
+ */
1398
+ readonly position?: Position | null;
1399
+ /**
1400
+ * Clockwise rotation of the box and everything in it about its
1401
+ * border-box centre, in degrees, after layout.
1402
+ */
1403
+ readonly rotation_degrees?: Animated<number> | null;
1404
+ /**
1405
+ * Space between rows (between lines of a wrapping row flex
1406
+ * container), in place of `gap`. At least 0.
1407
+ */
1408
+ readonly row_gap?: Animated<LayoutSize> | null;
1409
+ /**
1410
+ * Per-axis scale of the box and everything in it about its border-box
1411
+ * centre, after layout.
1412
+ */
1413
+ readonly scale?: Animated<Vec2> | null;
1414
+ /**
1415
+ * Shapes drawn on a picture the size of the box's content box. Not with
1416
+ * `children` or `text`.
1417
+ */
1418
+ readonly shape?: LayoutShape | null;
1419
+ /**
1420
+ * The box's text, wrapped at its content width and drawn in the style
1421
+ * it inherits; `\n` starts a line. At most `MAX_TEXT_CONTENT_BYTES`
1422
+ * bytes per value; may be empty. Its keyframes all `hold`. Not with
1423
+ * `children` or `shape`.
1424
+ */
1425
+ readonly text?: Animated<string> | null;
1426
+ /**
1427
+ * How lines align within the content width. Inherited; the root's is
1428
+ * `start`.
1429
+ */
1430
+ readonly text_align?: TextAlign | null;
1431
+ /**
1432
+ * Offset of the box and everything in it, after layout: the object, or
1433
+ * one or two lengths as CSS `translate` writes them.
1434
+ */
1435
+ readonly translate?: Animated<LayoutOffset> | null;
1436
+ /**
1437
+ * Border-box width. `None` is auto. Not on the root, as every item
1438
+ * field.
1439
+ */
1440
+ readonly width?: Animated<LayoutLength> | null;
1441
+ }
1442
+ /**
1443
+ * An offset, x right and y down: one or two lengths as CSS translate writes them (y 0 when missing), or {x, y}.
1444
+ */
1445
+ export type LayoutOffset = string | {
1446
+ readonly x: LayoutSize;
1447
+ readonly y: LayoutSize;
1448
+ };
1449
+ /**
1450
+ * A box's shapes, drawn as a shapes generator draws its items on a picture
1451
+ * the size of the box's content box: positions normalized to that box,
1452
+ * lengths fractions of its shorter side. A shape box has no size of its
1453
+ * own.
1454
+ */
1455
+ export interface LayoutShape {
1456
+ /**
1457
+ * The content tree, front first.
1458
+ */
1459
+ readonly items: readonly ShapeItem[];
1460
+ }
1461
+ /**
1462
+ * A length that may not be a percent: a number is a fraction of the layout picture's shorter side, "<n>px" pixels of the project canvas.
1463
+ */
1464
+ export type LayoutSize = number | string;
1069
1465
  /**
1070
1466
  * Final peak limiter placed at the end of the master bus.
1071
1467
  */
@@ -1475,6 +1871,10 @@ export type NodeOp = {
1475
1871
  */
1476
1872
  readonly type: "group_input";
1477
1873
  };
1874
+ /**
1875
+ * Whether content past a box's padding box is drawn.
1876
+ */
1877
+ export type Overflow = "visible" | "hidden";
1478
1878
  /**
1479
1879
  * A color or gradient.
1480
1880
  *
@@ -1482,6 +1882,9 @@ export type NodeOp = {
1482
1882
  * engine's working space, so a gradient between two colors passes through
1483
1883
  * the physical mix of them, and a stop fading to transparent does not darken
1484
1884
  * its neighbour.
1885
+ *
1886
+ * A color (hex or object) is read as a solid paint of it; a paint is
1887
+ * written back tagged.
1485
1888
  */
1486
1889
  export type Paint = {
1487
1890
  /**
@@ -1558,7 +1961,7 @@ export type Paint = {
1558
1961
  * Colors around a point: offsets 0 to 1 are one clockwise turn.
1559
1962
  */
1560
1963
  readonly type: "conic_gradient";
1561
- };
1964
+ } | Rgba;
1562
1965
  /**
1563
1966
  * One or more subpaths.
1564
1967
  */
@@ -1624,6 +2027,10 @@ export interface PointKeyframe {
1624
2027
  * What kind of figure a polystar is.
1625
2028
  */
1626
2029
  export type PolystarKind = "star" | "polygon";
2030
+ /**
2031
+ * Whether a box is in its parent's flow.
2032
+ */
2033
+ export type Position = "relative" | "absolute";
1627
2034
  /**
1628
2035
  * A stable project identifier.
1629
2036
  */
@@ -1771,8 +2178,12 @@ export interface Rgb {
1771
2178
  /**
1772
2179
  * A straight (not premultiplied), sRGB-encoded color with alpha, each
1773
2180
  * component in `0..=1`.
2181
+ *
2182
+ * Written as the object, or as CSS hex: `"#rgb"`, `"#rgba"`, `"#rrggbb"` or
2183
+ * `"#rrggbbaa"`, any case, each digit pair a component times 255. It is
2184
+ * written back as the object: a component need not be a multiple of 1/255.
1774
2185
  */
1775
- export interface Rgba {
2186
+ export type Rgba = {
1776
2187
  /**
1777
2188
  * Coverage.
1778
2189
  */
@@ -1789,7 +2200,7 @@ export interface Rgba {
1789
2200
  * Red component.
1790
2201
  */
1791
2202
  readonly red: number;
1792
- }
2203
+ } | string;
1793
2204
  /**
1794
2205
  * A geometry alone, as a mask's outline is.
1795
2206
  */
@@ -2513,6 +2924,10 @@ export type TrackId = string;
2513
2924
  * The media domain accepted by a track.
2514
2925
  */
2515
2926
  export type TrackKind = "video" | "audio" | "caption";
2927
+ /**
2928
+ * A grid track list as CSS writes it: "1fr 2fr 120px", "repeat(3, minmax(100px, 1fr))", "repeat(auto-fill, 160px)", "auto min-content max-content", "fit-content(200px)". A bare number is a fraction of the picture's shorter side. Named lines are not supported.
2929
+ */
2930
+ export type TrackList = string;
2516
2931
  /**
2517
2932
  * Encoded transfer curve.
2518
2933
  */
@@ -59,12 +59,24 @@ export const MAX_FRAME_INLINED_NODES = 65536;
59
59
  export const MAX_GAIN = 16;
60
60
  /** Mirrors `alpha2_model::MAX_GRADIENT_STOPS`. */
61
61
  export const MAX_GRADIENT_STOPS = 8;
62
+ /** Mirrors `alpha2_model::MAX_GRID_TRACKS`. */
63
+ export const MAX_GRID_TRACKS = 64;
62
64
  /** Mirrors `alpha2_model::MAX_GROUP_INPUTS`. */
63
65
  export const MAX_GROUP_INPUTS = 16;
64
66
  /** Mirrors `alpha2_model::MAX_HDR_PEAK_NITS`. */
65
67
  export const MAX_HDR_PEAK_NITS = 10000;
66
68
  /** Mirrors `alpha2_model::MAX_INLINED_NODES`. */
67
69
  export const MAX_INLINED_NODES = 65536;
70
+ /** Mirrors `alpha2_model::MAX_LAYOUT_DEPTH`. */
71
+ export const MAX_LAYOUT_DEPTH = 16;
72
+ /** Mirrors `alpha2_model::MAX_LAYOUT_FONT_SIZE`. */
73
+ export const MAX_LAYOUT_FONT_SIZE = 1;
74
+ /** Mirrors `alpha2_model::MAX_LAYOUT_ISOLATED`. */
75
+ export const MAX_LAYOUT_ISOLATED = 16;
76
+ /** Mirrors `alpha2_model::MAX_LAYOUT_NODES`. */
77
+ export const MAX_LAYOUT_NODES = 256;
78
+ /** Mirrors `alpha2_model::MAX_LAYOUT_TEXTS`. */
79
+ export const MAX_LAYOUT_TEXTS = 64;
68
80
  /** Mirrors `alpha2_model::MAX_LINE_HEIGHT`. */
69
81
  export const MAX_LINE_HEIGHT = 3;
70
82
  /** Mirrors `alpha2_model::MAX_LOOKAHEAD_MS`. */
@@ -123,6 +135,23 @@ export const MIN_SAMPLE_RATE = 8000;
123
135
  export const REVERB_DELAY_MS = 160;
124
136
  /** Mirrors `alpha2_model::TICKS_PER_SECOND`. */
125
137
  export const TICKS_PER_SECOND = 120000;
138
+ /** Every {@link AlignContent}, in the model's order. */
139
+ export const ALIGN_CONTENT_VALUES = [
140
+ "start",
141
+ "center",
142
+ "end",
143
+ "space_between",
144
+ "space_around",
145
+ "space_evenly",
146
+ "stretch",
147
+ ];
148
+ /** Every {@link AlignItems}, in the model's order. */
149
+ export const ALIGN_ITEMS_VALUES = [
150
+ "start",
151
+ "center",
152
+ "end",
153
+ "stretch",
154
+ ];
126
155
  /** Every {@link BlendSpace}, in the model's order. */
127
156
  export const BLEND_SPACE_VALUES = [
128
157
  "linear_light",
@@ -168,6 +197,8 @@ export const COLOR_PRIMARIES_VALUES = [
168
197
  ];
169
198
  /** Every {@link ColorRange}, in the model's order. */
170
199
  export const COLOR_RANGE_VALUES = ["limited", "full"];
200
+ /** Every {@link Display}, in the model's order. */
201
+ export const DISPLAY_VALUES = ["flex", "grid"];
171
202
  /** Every {@link DynamicRange}, in the model's order. */
172
203
  export const DYNAMIC_RANGE_VALUES = ["sdr", "hdr"];
173
204
  /** Every {@link EffectResourceKind}, in the model's order. */
@@ -187,8 +218,33 @@ export const FADE_SHAPE_VALUES = [
187
218
  ];
188
219
  /** Every {@link FillRule}, in the model's order. */
189
220
  export const FILL_RULE_VALUES = ["nonzero", "evenodd"];
221
+ /** Every {@link FlexDirection}, in the model's order. */
222
+ export const FLEX_DIRECTION_VALUES = [
223
+ "row",
224
+ "column",
225
+ "row_reverse",
226
+ "column_reverse",
227
+ ];
228
+ /** Every {@link FlexWrap}, in the model's order. */
229
+ export const FLEX_WRAP_VALUES = ["nowrap", "wrap"];
230
+ /** Every {@link GridAutoFlow}, in the model's order. */
231
+ export const GRID_AUTO_FLOW_VALUES = [
232
+ "row",
233
+ "column",
234
+ "row_dense",
235
+ "column_dense",
236
+ ];
190
237
  /** Every {@link HdrSources}, in the model's order. */
191
238
  export const HDR_SOURCES_VALUES = ["tone_map", "reject"];
239
+ /** Every {@link JustifyContent}, in the model's order. */
240
+ export const JUSTIFY_CONTENT_VALUES = [
241
+ "start",
242
+ "center",
243
+ "end",
244
+ "space_between",
245
+ "space_around",
246
+ "space_evenly",
247
+ ];
192
248
  /** Every {@link LineCap}, in the model's order. */
193
249
  export const LINE_CAP_VALUES = ["butt", "round", "square"];
194
250
  /** Every {@link LineJoin}, in the model's order. */
@@ -234,11 +290,15 @@ export const MISSING_FRAMES_VALUES = [
234
290
  "hold",
235
291
  "blank",
236
292
  ];
293
+ /** Every {@link Overflow}, in the model's order. */
294
+ export const OVERFLOW_VALUES = ["visible", "hidden"];
237
295
  /** Every {@link PolystarKind}, in the model's order. */
238
296
  export const POLYSTAR_KIND_VALUES = [
239
297
  "star",
240
298
  "polygon",
241
299
  ];
300
+ /** Every {@link Position}, in the model's order. */
301
+ export const POSITION_VALUES = ["relative", "absolute"];
242
302
  /** Every {@link Spread}, in the model's order. */
243
303
  export const SPREAD_VALUES = ["pad", "repeat", "reflect"];
244
304
  /** Every {@link TextAlign}, in the model's order. */