alpha2 0.5.3 → 0.6.1

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 (82) hide show
  1. package/README.md +68 -3
  2. package/THIRD_PARTY_NOTICES.md +7 -3
  3. package/dist/apply-edit.d.ts +124 -0
  4. package/dist/apply-edit.js +15 -0
  5. package/dist/assets.d.ts +12 -0
  6. package/dist/audio-layout.js +6 -3
  7. package/dist/audio-worklet-processor.js +27 -33
  8. package/dist/audio.d.ts +5 -4
  9. package/dist/audio.js +8 -6
  10. package/dist/compose.d.ts +105 -0
  11. package/dist/compose.js +63 -0
  12. package/dist/decoder-fallback.d.ts +3 -2
  13. package/dist/decoder-fallback.js +11 -3
  14. package/dist/decoder-stall.d.ts +15 -0
  15. package/dist/decoder-stall.js +52 -0
  16. package/dist/edit-data.d.ts +24 -0
  17. package/dist/edit-data.js +224 -0
  18. package/dist/edit-keys.d.ts +16 -0
  19. package/dist/edit-keys.js +233 -0
  20. package/dist/edit.d.ts +41 -8
  21. package/dist/edit.js +123 -30
  22. package/dist/export-failure.d.ts +10 -2
  23. package/dist/export-failure.js +55 -4
  24. package/dist/export-retry.d.ts +6 -1
  25. package/dist/export-retry.js +12 -1
  26. package/dist/exporter.d.ts +11 -7
  27. package/dist/exporter.js +10 -9
  28. package/dist/extract.d.ts +65 -0
  29. package/dist/extract.js +291 -0
  30. package/dist/extractor.d.ts +151 -0
  31. package/dist/extractor.js +141 -0
  32. package/dist/float32.d.ts +2 -0
  33. package/dist/float32.js +10 -0
  34. package/dist/frame-intake.d.ts +5 -0
  35. package/dist/frame-intake.js +10 -3
  36. package/dist/generated/builtin-effects.d.ts +3 -0
  37. package/dist/generated/builtin-effects.js +1804 -0
  38. package/dist/generated/project-schema.d.ts +636 -37
  39. package/dist/generated/project-schema.js +55 -0
  40. package/dist/generated/project-shape.js +950 -381
  41. package/dist/index.d.ts +1 -0
  42. package/dist/index.js +1 -0
  43. package/dist/json-text.js +14 -2
  44. package/dist/layout-values.js +7 -1
  45. package/dist/layout.d.ts +12 -4
  46. package/dist/media.d.ts +43 -10
  47. package/dist/media.js +255 -66
  48. package/dist/mediabunny.d.ts +32 -12
  49. package/dist/mediabunny.js +276 -90
  50. package/dist/player.d.ts +9 -3
  51. package/dist/player.js +114 -18
  52. package/dist/plugins.d.ts +62 -0
  53. package/dist/plugins.js +506 -0
  54. package/dist/project-data.d.ts +56 -0
  55. package/dist/project-data.js +765 -0
  56. package/dist/project.d.ts +24 -1
  57. package/dist/project.js +456 -38
  58. package/dist/robustness.d.ts +6 -33
  59. package/dist/robustness.js +2 -63
  60. package/dist/sha256.d.ts +3 -2
  61. package/dist/sha256.js +14 -6
  62. package/dist/worker-error.d.ts +3 -2
  63. package/dist/worker-error.js +3 -1
  64. package/dist/worker.d.ts +13 -3
  65. package/dist/worker.js +36 -9
  66. package/package.json +26 -1
  67. package/wasm/alpha2_compose.d.ts +92 -0
  68. package/wasm/alpha2_compose.js +445 -0
  69. package/wasm/alpha2_compose_bg.wasm +0 -0
  70. package/wasm/alpha2_compose_bg.wasm.d.ts +17 -0
  71. package/wasm/alpha2_extensions_bg.wasm +0 -0
  72. package/wasm/alpha2_extensions_pdf_bg.wasm +0 -0
  73. package/wasm/alpha2_wasm.d.ts +151 -18
  74. package/wasm/alpha2_wasm.js +403 -59
  75. package/wasm/alpha2_wasm_bg.wasm +0 -0
  76. package/wasm/alpha2_wasm_bg.wasm.d.ts +21 -6
  77. package/wasm/rust-crate-licenses.md +5 -61
  78. package/wasm/snippets/alpha2-wasm-6749ed8b34a74067/inline3.js +7 -0
  79. /package/wasm/snippets/{alpha2-wasm-a6265983c9769e80/inline1.js → alpha2-wasm-6749ed8b34a74067/inline0.js} +0 -0
  80. /package/wasm/snippets/{alpha2-wasm-a6265983c9769e80/inline2.js → alpha2-wasm-6749ed8b34a74067/inline1.js} +0 -0
  81. /package/wasm/snippets/{alpha2-wasm-a6265983c9769e80/inline3.js → alpha2-wasm-6749ed8b34a74067/inline2.js} +0 -0
  82. /package/wasm/snippets/{alpha2-wasm-a6265983c9769e80/inline0.js → alpha2-wasm-6749ed8b34a74067/inline4.js} +0 -0
package/dist/project.js CHANGED
@@ -7,8 +7,12 @@
7
7
  *
8
8
  * Timeline values are integer ticks at {@link TICKS_PER_SECOND}. Ranges are half-open.
9
9
  */
10
+ import { BUILTIN_EFFECT_RULES } from "./generated/builtin-effects.js";
11
+ import { dataProblems } from "./project-data.js";
12
+ import { shortestFloat32 } from "./float32.js";
13
+ export { dataReferences, describeDataReference, } from "./project-data.js";
10
14
  import { parseHex, parseInsets, parseLength, parseOffset, parsePlacement, parseSize, parseTrackList, } from "./layout-values.js";
11
- import { AUDIO_EFFECT_STATE_MARGIN_MS, MAX_CANVAS_DIMENSION, MAX_CANVAS_PIXELS, MAX_TEXT_CONTENT_BYTES, MAX_FONT_FAMILY_BYTES, MAX_COMPOSITIONS, MAX_COMPOSITION_NODES, MAX_COMPOSITION_CONTROLS, MAX_COMPOSITION_DEPTH, MAX_GROUP_INPUTS, MAX_EFFECT_INPUTS, MAX_FRAME_INLINED_NODES, MAX_INLINED_NODES, MAX_MERGE_LAYERS, MAX_CLIP_MASKS, MAX_DASH_ENTRIES, MAX_GRADIENT_STOPS, MAX_PATH_SUBPATHS, MAX_PATH_VERTICES, MAX_POLYSTAR_POINTS, MAX_SHAPE_DEPTH, MAX_SHAPE_ITEMS, MAX_LAYOUT_DEPTH, MAX_LAYOUT_FONT_SIZE, MAX_LAYOUT_ISOLATED, MAX_LAYOUT_NODES, MAX_LAYOUT_TEXTS, MAX_GRID_TRACKS, MIN_POLYSTAR_POINTS, MAX_CLIPS, MAX_CLIPS_PER_TRACK, MAX_AUDIO_DELAY_MS, MAX_AUDIO_EFFECTS, MAX_CAPTION_FONT_SIZE, MAX_CAPTION_NAME_BYTES, MAX_CAPTION_STYLES, MAX_TEXT_GENERATOR_FONT_SIZE, MAX_FONT_WEIGHT, MAX_LETTER_SPACING, MAX_LINE_HEIGHT, MAX_TEXT_PADDING, MAX_ANIMATOR_SCALE, MAX_CLASS_NAME_BYTES, MAX_RANGE_INDEX, MAX_RANGE_PERCENT, MAX_RUN_CLASSES, MAX_TEXT_ANIMATORS, MAX_TEXT_RUNS, MIN_RANGE_PERCENT, MAX_TEXT_SHADOW_BLUR, MAX_TEXT_SHADOW_OFFSET, MAX_TEXT_SHADOWS, MAX_TEXT_STROKE_EXTENT, MAX_TEXT_STROKES, MAX_CHAIN_EFFECTS, MAX_COMPRESSOR_RATIO, MAX_ENVELOPE_MS, MAX_EQ_BANDS, MAX_LOOKAHEAD_MS, MIN_FONT_WEIGHT, MIN_LETTER_SPACING, MIN_LINE_HEIGHT, MIN_LEVEL_DB, MAX_EQ_FREQUENCY_HZ, MAX_EQ_GAIN_DB, MAX_EQ_Q, MAX_GAIN, MAX_PROJECT_JSON_BYTES, MAX_SAMPLE_RATE, MAX_TRACKS, MAX_TRANSITIONS_PER_TRACK, MIN_EQ_FREQUENCY_HZ, MIN_EQ_Q, MIN_SAMPLE_RATE, MIN_HDR_PEAK_NITS, MAX_HDR_PEAK_NITS, MAX_SEQUENCE_FRAMES, MAX_SELECTED_CHANNELS, MAX_AUDIO_CHANNELS, MAX_LATEX_BYTES, MAX_LATEX_FONT_SIZE, MAX_PDF_PAGES, REVERB_DELAY_MS, TICKS_PER_SECOND, } from "./generated/project-schema.js";
15
+ import { AUDIO_EFFECT_STATE_MARGIN_MS, MAX_CANVAS_DIMENSION, MAX_CANVAS_PIXELS, MAX_TEXT_CONTENT_BYTES, MAX_FONT_FAMILY_BYTES, MAX_COMPOSITIONS, MAX_COMPOSITION_NODES, MAX_COMPOSITION_CONTROLS, MAX_COMPOSITION_DEPTH, MAX_GROUP_INPUTS, MAX_EFFECT_INPUTS, MAX_FRAME_INLINED_NODES, MAX_INLINED_NODES, MAX_MERGE_LAYERS, MAX_CLIP_MASKS, MAX_DASH_ENTRIES, MAX_GRADIENT_STOPS, MAX_PATH_SUBPATHS, MAX_PATH_VERTICES, MAX_POLYSTAR_POINTS, MAX_SHAPE_DEPTH, MAX_SHAPE_ITEMS, MAX_LAYOUT_DEPTH, MAX_LAYOUT_FONT_SIZE, MAX_LAYOUT_ISOLATED, MAX_LAYOUT_NODES, MAX_LAYOUT_TEXTS, MAX_GRID_TRACKS, MIN_POLYSTAR_POINTS, MAX_CLIPS, MAX_CLIPS_PER_TRACK, MAX_AUDIO_DELAY_MS, MAX_AUDIO_EFFECTS, MAX_CAPTION_FONT_SIZE, MAX_CAPTION_NAME_BYTES, MAX_CAPTION_STYLES, MAX_TEXT_GENERATOR_FONT_SIZE, MAX_FONT_WEIGHT, MAX_LETTER_SPACING, MAX_LINE_HEIGHT, MAX_TEXT_PADDING, MAX_ANIMATOR_SCALE, MAX_CLASS_NAME_BYTES, MAX_RANGE_INDEX, MAX_RANGE_PERCENT, MAX_RUN_CLASSES, MAX_TEXT_ANIMATORS, MAX_TEXT_RUNS, MAX_LOOP_PASSES, MAX_ANIMATOR_OFFSET, MAX_ASPECT_RATIO, MAX_FLEX_FACTOR, MAX_LAYOUT_FRACTION, MAX_LAYOUT_PERCENT, MAX_LAYOUT_PX, MAX_TEXT_POSITION, MIN_ASPECT_RATIO, MIN_RANGE_PERCENT, MAX_TEXT_SHADOW_BLUR, MAX_TEXT_SHADOW_OFFSET, MAX_TEXT_SHADOWS, MAX_TEXT_STROKE_EXTENT, MAX_TEXT_STROKES, MAX_CHAIN_EFFECTS, MAX_COMPRESSOR_RATIO, MAX_ENVELOPE_MS, MAX_EQ_BANDS, MAX_LOOKAHEAD_MS, MIN_FONT_WEIGHT, MIN_LETTER_SPACING, MIN_LINE_HEIGHT, MIN_LEVEL_DB, MAX_EQ_FREQUENCY_HZ, MAX_EQ_GAIN_DB, MAX_EQ_Q, MAX_GAIN, MAX_PROJECT_JSON_BYTES, MAX_SAMPLE_RATE, MAX_TRACKS, MAX_TRANSITIONS_PER_TRACK, MIN_EQ_FREQUENCY_HZ, MIN_EQ_Q, MIN_SAMPLE_RATE, MIN_HDR_PEAK_NITS, MAX_HDR_PEAK_NITS, MAX_SEQUENCE_FRAMES, MAX_SELECTED_CHANNELS, MAX_AUDIO_CHANNELS, MAX_LATEX_BYTES, MAX_LATEX_FONT_SIZE, MAX_PDF_PAGES, REVERB_DELAY_MS, TICKS_PER_SECOND, } from "./generated/project-schema.js";
12
16
  import { PROJECT_SHAPE } from "./generated/project-shape.js";
13
17
  import { MAX_JSON_DEPTH, hasLoneSurrogate, readJsonText, } from "./json-text.js";
14
18
  export * from "./generated/project-schema.js";
@@ -129,6 +133,8 @@ function invariantProblems(value) {
129
133
  }
130
134
  for (const problem of matteProblems(tracks))
131
135
  problems.push(problem);
136
+ for (const problem of projectDataProblems(project))
137
+ problems.push(problem);
132
138
  if (catalog.inlined !== undefined) {
133
139
  const frame = frameNodesOver(tracks.map((track) => frameEdges(track, catalog.sources, catalog.inlined)));
134
140
  if (frame !== undefined)
@@ -140,6 +146,9 @@ function invariantProblems(value) {
140
146
  problems.push(problem);
141
147
  return problems;
142
148
  }
149
+ function projectDataProblems(project) {
150
+ return dataProblems(project, (id, name) => builtinParamRule(id, name)?.type, validFingerprint, sealed);
151
+ }
143
152
  function headerProblems(project) {
144
153
  const problems = [];
145
154
  if (text(project.id).length === 0)
@@ -297,8 +306,17 @@ function catalogOf(sourceList, resourceList, compositionList, canvas) {
297
306
  }
298
307
  return names;
299
308
  };
309
+ const builtinControls = new Map();
310
+ const builtinControlsOf = (target) => {
311
+ let found = builtinControls.get(target);
312
+ if (found === undefined) {
313
+ found = builtinControlTargets(target);
314
+ builtinControls.set(target, found);
315
+ }
316
+ return found;
317
+ };
300
318
  for (const composition of compositionList) {
301
- const found = compositionProblems(composition, sources, effectResources, compositionsById, controlNamesOf, canvas);
319
+ const found = compositionProblems(composition, sources, effectResources, compositionsById, controlNamesOf, builtinControlsOf, canvas);
302
320
  for (const problem of found)
303
321
  problems.push(problem);
304
322
  }
@@ -403,6 +421,10 @@ function clipProblems(clip, trackKind, catalog) {
403
421
  if (!freezesInside(clip.time_map, clip.source_range)) {
404
422
  problems.push(`clip ${clipId} freezes outside its source range`);
405
423
  }
424
+ const passes = loopPasses(clip);
425
+ if (passes > BigInt(MAX_LOOP_PASSES)) {
426
+ problems.push(`clip ${clipId} loops ${passes} times; the maximum is ${MAX_LOOP_PASSES}`);
427
+ }
406
428
  const sourceId = text(clip.source_id);
407
429
  const source = catalog.sources.get(sourceId);
408
430
  if (source === undefined || !isRecord(source)) {
@@ -609,6 +631,7 @@ function invariantsHold(value) {
609
631
  }
610
632
  return (clipIdsUnique(summaries) &&
611
633
  mattesHold(summaries) &&
634
+ projectDataProblems(project).length === 0 &&
612
635
  frameNodesOver(summaries.map((summary) => summary.frames)) === undefined &&
613
636
  audioEffectProblems(project.audio, summaries.map((summary) => summary.audio)).length === 0 &&
614
637
  duckingProblems(tracks, trackIds).length === 0);
@@ -738,7 +761,7 @@ export function validateProjectJson(json) {
738
761
  }
739
762
  const read = readJsonText(json);
740
763
  if (read === undefined) {
741
- return [`project JSON nests deeper than ${MAX_JSON_DEPTH} levels`];
764
+ return [TOO_DEEP];
742
765
  }
743
766
  return projectProblems(read.value, read.spelling);
744
767
  }
@@ -775,13 +798,34 @@ function shapeProblems(value, spelling, reuse) {
775
798
  reusingShapes = reuse;
776
799
  try {
777
800
  const read = checkShape(shapeRoot, value, "project", problems, spelling);
778
- return { problems, read };
801
+ return { problems: tooDeep ? [TOO_DEEP] : problems, read };
779
802
  }
780
803
  finally {
781
804
  reusingShapes = false;
805
+ shapeDepth = 0;
806
+ tooDeep = false;
782
807
  }
783
808
  }
784
809
  let reusingShapes = false;
810
+ // Arrays and objects the shape walk is inside; past `MAX_JSON_DEPTH` it stops descending.
811
+ let shapeDepth = 0;
812
+ let tooDeep = false;
813
+ const TOO_DEEP = `project JSON nests deeper than ${MAX_JSON_DEPTH} levels`;
814
+ /** Runs `walk` one container deeper, or reports the depth problem without running it. */
815
+ function nested(value, problems, walk) {
816
+ if (shapeDepth >= MAX_JSON_DEPTH) {
817
+ tooDeep = true;
818
+ problems.push(TOO_DEEP);
819
+ return value;
820
+ }
821
+ shapeDepth += 1;
822
+ try {
823
+ return walk();
824
+ }
825
+ finally {
826
+ shapeDepth -= 1;
827
+ }
828
+ }
785
829
  // Cross-field rules the schema cannot state but the engine's parser enforces.
786
830
  const FRAME_RATE_SHAPE = shapeRoot.$defs
787
831
  .FrameRate;
@@ -934,16 +978,6 @@ const SHAPE_READERS = new Map([
934
978
  },
935
979
  ],
936
980
  ]);
937
- // The shortest decimal that reads back as the same 32-bit float, as the engine writes it.
938
- function shortestFloat32(value) {
939
- const target = Math.fround(value);
940
- for (let digits = 1; digits < 9; digits++) {
941
- const short = Number(target.toPrecision(digits));
942
- if (Math.fround(short) === target)
943
- return short;
944
- }
945
- return Number(target.toPrecision(9));
946
- }
947
981
  /** The whole text of a caption cue or text generator, with runs joined. */
948
982
  export function textOf(content) {
949
983
  return typeof content === "string"
@@ -1175,6 +1209,129 @@ function canonicalWalk(node, value) {
1175
1209
  }
1176
1210
  return read === undefined ? value : { ...value, ...read };
1177
1211
  }
1212
+ /**
1213
+ * `next` with every part that equals the matching part of `previous` replaced by that part, so
1214
+ * a project an engine edit wrote keeps the objects of the project it was computed from wherever
1215
+ * the edit changed nothing. A field one side omits counts as its schema default, as the engine
1216
+ * reads it; arrays match items by string `id` when they have one, else by position. Both projects
1217
+ * must be valid. The result reads as `next` does, though parts taken from `previous` keep its
1218
+ * spelling of defaults.
1219
+ */
1220
+ export function shareUnchangedParts(previous, next) {
1221
+ return shareAt(shapeRoot, previous, next);
1222
+ }
1223
+ const idOfItem = (item) => isRecord(item) ? item.id : undefined;
1224
+ /** Whether `value` can be an instance of variant `node`, judged by its constant fields. */
1225
+ function fitsVariant(node, value) {
1226
+ const schema = resolveShape(node);
1227
+ if ("const" in schema)
1228
+ return value === schema.const;
1229
+ if (schema.type === "null")
1230
+ return value === null;
1231
+ if (schema.type === "array")
1232
+ return Array.isArray(value);
1233
+ if (schema.type === "object" || schema.properties !== undefined) {
1234
+ if (!isRecord(value))
1235
+ return false;
1236
+ const properties = (schema.properties ?? {});
1237
+ return Object.entries(properties).every(([key, field]) => {
1238
+ const constant = resolveShape(field);
1239
+ return !("const" in constant) || value[key] === constant.const;
1240
+ });
1241
+ }
1242
+ if (schema.type === "string")
1243
+ return typeof value === "string";
1244
+ if (schema.type === "number" || schema.type === "integer")
1245
+ return typeof value === "number";
1246
+ if (schema.type === "boolean")
1247
+ return typeof value === "boolean";
1248
+ return true;
1249
+ }
1250
+ /** Whether `value` is the default of `field`, or `field` has none and `value` is absent. */
1251
+ function isFieldDefault(field, value) {
1252
+ if (typeof field !== "object" || field.default === undefined)
1253
+ return value === undefined;
1254
+ return (value === undefined ||
1255
+ shareAt(field, field.default, value) === field.default);
1256
+ }
1257
+ function shareAt(node, previous, next) {
1258
+ if (previous === next)
1259
+ return previous;
1260
+ if (typeof node !== "object")
1261
+ return next;
1262
+ const schema = resolveShape(node);
1263
+ const variants = (schema.oneOf ?? schema.anyOf);
1264
+ if (variants !== undefined) {
1265
+ const variant = variants.find((candidate) => fitsVariant(candidate, next));
1266
+ return variant === undefined || !fitsVariant(variant, previous)
1267
+ ? next
1268
+ : shareAt(variant, previous, next);
1269
+ }
1270
+ if (typeof next !== "object" ||
1271
+ next === null ||
1272
+ typeof previous !== "object" ||
1273
+ previous === null)
1274
+ return next;
1275
+ if (Array.isArray(next)) {
1276
+ if (!Array.isArray(previous))
1277
+ return next;
1278
+ let same = next.length === previous.length;
1279
+ let nested = false;
1280
+ for (let index = 0; same && index < next.length; index++) {
1281
+ const item = next[index];
1282
+ if (typeof item === "object" && item !== null)
1283
+ nested = true;
1284
+ else if (item !== previous[index])
1285
+ same = false;
1286
+ }
1287
+ if (same && !nested)
1288
+ return previous;
1289
+ const prefix = schema.prefixItems;
1290
+ const rest = (schema.items ?? true);
1291
+ let byId;
1292
+ const items = next.map((item, index) => {
1293
+ const id = idOfItem(item);
1294
+ let counterpart = previous[index];
1295
+ if (typeof id === "string" && idOfItem(counterpart) !== id) {
1296
+ byId ??= new Map(previous.map((other) => [idOfItem(other), other]));
1297
+ counterpart = byId.get(id);
1298
+ }
1299
+ const field = prefix !== undefined && index < prefix.length ? prefix[index] : rest;
1300
+ const shared = counterpart === undefined ? item : shareAt(field, counterpart, item);
1301
+ if (shared !== previous[index])
1302
+ same = false;
1303
+ return shared;
1304
+ });
1305
+ return same ? previous : items;
1306
+ }
1307
+ if (Array.isArray(previous) || !isRecord(next) || !isRecord(previous))
1308
+ return next;
1309
+ const properties = (schema.properties ?? {});
1310
+ const extra = (schema.additionalProperties ?? true);
1311
+ const fieldOf = (key) => Object.hasOwn(properties, key) ? properties[key] : extra;
1312
+ let same = true;
1313
+ const read = {};
1314
+ for (const key of Object.keys(next)) {
1315
+ const value = next[key];
1316
+ if (value === undefined)
1317
+ continue;
1318
+ const before = previous[key];
1319
+ if (before === undefined) {
1320
+ if (!isFieldDefault(fieldOf(key), value))
1321
+ same = false;
1322
+ read[key] = value;
1323
+ continue;
1324
+ }
1325
+ const shared = shareAt(fieldOf(key), before, value);
1326
+ if (shared !== before)
1327
+ same = false;
1328
+ read[key] = shared;
1329
+ }
1330
+ for (const key of Object.keys(previous))
1331
+ if (next[key] === undefined && !isFieldDefault(fieldOf(key), previous[key]))
1332
+ same = false;
1333
+ return same ? previous : read;
1334
+ }
1178
1335
  function walkShape(node, value, path, problems, spelling, texts) {
1179
1336
  const schema = resolveShape(node);
1180
1337
  const reader = SHAPE_READERS.get(schema);
@@ -1227,11 +1384,11 @@ function walkShape(node, value, path, problems, spelling, texts) {
1227
1384
  }
1228
1385
  }
1229
1386
  else if (Array.isArray(value)) {
1230
- return checkArrayShape(schema, value, path, problems, spelling);
1387
+ return nested(value, problems, () => checkArrayShape(schema, value, path, problems, spelling));
1231
1388
  }
1232
1389
  else if (isRecord(value)) {
1233
1390
  const before = problems.length;
1234
- const read = checkObjectShape(schema, value, path, problems, spelling);
1391
+ const read = nested(value, problems, () => checkObjectShape(schema, value, path, problems, spelling));
1235
1392
  if (schema === FRAME_RATE_SHAPE &&
1236
1393
  problems.length === before &&
1237
1394
  !validFrameRate(value)) {
@@ -1377,20 +1534,84 @@ function checkArrayShape(schema, value, path, problems, spelling) {
1377
1534
  problems.push(`${path} must have at most ${schema.maxItems} items`);
1378
1535
  }
1379
1536
  const prefix = (schema.prefixItems ?? []);
1537
+ const scalar = prefix.length === 0 && schema.items !== undefined
1538
+ ? plainScalar(schema.items)
1539
+ : undefined;
1380
1540
  let changed = false;
1381
- const read = value.map((item, index) => {
1541
+ // By index rather than `map`, so a hole is read as `undefined` and fails its item shape.
1542
+ const read = [];
1543
+ for (let index = 0; index < value.length; index += 1) {
1544
+ const item = value[index];
1545
+ // Valid numbers of a plain number schema need no path or generic walk.
1546
+ const quick = scalar?.(item, numbers?.get(index));
1547
+ if (quick !== undefined) {
1548
+ if (quick !== item)
1549
+ changed = true;
1550
+ read.push(quick);
1551
+ continue;
1552
+ }
1382
1553
  const itemSchema = prefix[index] ?? schema.items;
1383
- if (itemSchema === undefined)
1384
- return item;
1554
+ if (itemSchema === undefined) {
1555
+ read.push(item);
1556
+ continue;
1557
+ }
1385
1558
  const itemRead = checkShape(itemSchema, item, `${path}[${index}]`, problems, spelling, numbers?.get(index));
1386
1559
  if (itemRead !== item)
1387
1560
  changed = true;
1388
- return itemRead;
1389
- });
1561
+ read.push(itemRead);
1562
+ }
1390
1563
  return !changed && reusingShapes && sealed(value)
1391
1564
  ? value
1392
1565
  : read;
1393
1566
  }
1567
+ /**
1568
+ * For an item schema that is only a number, integer or null type, a reader that returns a valid
1569
+ * item as the generic walk reads it, and `undefined` for anything it leaves to that walk.
1570
+ */
1571
+ function plainScalar(node) {
1572
+ const known = plainScalars.get(node);
1573
+ if (known !== undefined || plainScalars.has(node))
1574
+ return known ?? undefined;
1575
+ const schema = resolveShape(node);
1576
+ const types = Array.isArray(schema.type) ? schema.type : [schema.type];
1577
+ const plain = !SHAPE_READERS.has(schema) &&
1578
+ schema.oneOf === undefined &&
1579
+ schema.anyOf === undefined &&
1580
+ !("const" in schema) &&
1581
+ schema.enum === undefined &&
1582
+ schema.minimum === undefined &&
1583
+ schema.maximum === undefined &&
1584
+ types.every((type) => type === "number" || type === "integer" || type === "null") &&
1585
+ !(types.includes("number") && types.includes("integer"));
1586
+ let reader;
1587
+ if (plain) {
1588
+ const nullable = types.includes("null");
1589
+ const float = schema.format === "float";
1590
+ const { min, max } = types.includes("integer")
1591
+ ? integerBounds(schema)
1592
+ : { min: undefined, max: undefined };
1593
+ const low = min === undefined ? -Infinity : Number(min);
1594
+ const high = max === undefined ? Infinity : Number(max);
1595
+ reader = types.includes("integer")
1596
+ ? (item, texts) => (nullable && item === null) ||
1597
+ (texts === undefined &&
1598
+ Number.isSafeInteger(item) &&
1599
+ item >= low &&
1600
+ item <= high)
1601
+ ? item
1602
+ : undefined
1603
+ : (item) => nullable && item === null
1604
+ ? item
1605
+ : typeof item === "number" && Number.isFinite(item)
1606
+ ? float
1607
+ ? Math.fround(item)
1608
+ : item
1609
+ : undefined;
1610
+ }
1611
+ plainScalars.set(node, reader);
1612
+ return reader;
1613
+ }
1614
+ const plainScalars = new Map();
1394
1615
  function checkObjectShape(schema, value, path, problems, spelling) {
1395
1616
  const properties = (schema.properties ?? {});
1396
1617
  // A map (`additionalProperties`) keeps the last repeated key, as `JSON.parse` does.
@@ -1405,6 +1626,12 @@ function checkObjectShape(schema, value, path, problems, spelling) {
1405
1626
  if (value[name] === undefined)
1406
1627
  problems.push(`${path}.${name} is required`);
1407
1628
  }
1629
+ if (typeof schema.maxProperties === "number") {
1630
+ const present = Object.values(value).filter((item) => item !== undefined);
1631
+ if (present.length > schema.maxProperties) {
1632
+ problems.push(`${path} must have at most ${schema.maxProperties} properties`);
1633
+ }
1634
+ }
1408
1635
  const extra = schema.additionalProperties;
1409
1636
  const read = {};
1410
1637
  // Assigning `__proto__` would replace the copy's prototype instead of adding the key.
@@ -1609,6 +1836,20 @@ function freezesInside(timeMap, sourceRange) {
1609
1836
  instant >= sourceRange.start &&
1610
1837
  instant < sourceRange.end);
1611
1838
  }
1839
+ /** Passes of a valid looping clip, rounded up, as `loop_passes`; else 0. */
1840
+ function loopPasses(clip) {
1841
+ const map = clip.time_map;
1842
+ if (!isRecord(map) || map.type !== "loop")
1843
+ return 0n;
1844
+ if (!validRange(clip.timeline_range) || !validRange(clip.source_range))
1845
+ return 0n;
1846
+ const length = (range) => {
1847
+ const { start, end } = range;
1848
+ return BigInt(end) - BigInt(start);
1849
+ };
1850
+ const source = length(clip.source_range);
1851
+ return (length(clip.timeline_range) + source - 1n) / source;
1852
+ }
1612
1853
  function rangeStart(range) {
1613
1854
  return isRecord(range) && finiteNumber(range.start) ? range.start : 0;
1614
1855
  }
@@ -1617,6 +1858,9 @@ function animationValues(animation) {
1617
1858
  return undefined;
1618
1859
  if (animation.mode === "constant")
1619
1860
  return [animation.value];
1861
+ // A binding holds no authored value; `dataProblems` checks it.
1862
+ if (animation.mode === "data")
1863
+ return [];
1620
1864
  if (animation.mode !== "keyframes" || !Array.isArray(animation.keyframes)) {
1621
1865
  return undefined;
1622
1866
  }
@@ -1657,6 +1901,12 @@ function validRgb(value) {
1657
1901
  return (isRecord(value) &&
1658
1902
  [value.red, value.green, value.blue].every((component) => finiteNumber(component) && component >= 0 && component <= 1));
1659
1903
  }
1904
+ /** Mirrors the `position` and `anchor` check of `TextStyle::is_valid`. */
1905
+ function textPosition(value) {
1906
+ return (validVec2(value) &&
1907
+ Math.abs(value.x) <= MAX_TEXT_POSITION &&
1908
+ Math.abs(value.y) <= MAX_TEXT_POSITION);
1909
+ }
1660
1910
  function validVec2(value) {
1661
1911
  return isRecord(value) && finiteNumber(value.x) && finiteNumber(value.y);
1662
1912
  }
@@ -1705,6 +1955,8 @@ function validEffectValue(value) {
1705
1955
  }
1706
1956
  // All values share one type, and `enum` and `bool` keyframes must hold.
1707
1957
  function validEffectParam(param) {
1958
+ if (isRecord(param) && param.mode === "data")
1959
+ return true;
1708
1960
  const values = animationValues(param);
1709
1961
  if (values === undefined || !values.every(validEffectValue))
1710
1962
  return false;
@@ -1736,6 +1988,118 @@ function validClipEffect(effect) {
1736
1988
  Object.entries(params ?? {}).every(([name, value]) => EFFECT_BINDING_NAME.test(name) && validEffectParam(value)) &&
1737
1989
  Object.entries(resources ?? {}).every(([name, id]) => EFFECT_BINDING_NAME.test(name) && text(id).length > 0));
1738
1990
  }
1991
+ /** Ids under this prefix must name a built-in. Mirrors `alpha2_model::BUILTIN_EFFECT_PREFIX`. */
1992
+ const BUILTIN_EFFECT_PREFIX = "alpha2.";
1993
+ function builtinRules(id) {
1994
+ return Object.hasOwn(BUILTIN_EFFECT_RULES, id)
1995
+ ? BUILTIN_EFFECT_RULES[id]
1996
+ : undefined;
1997
+ }
1998
+ /** Each control of `composition` that sets a built-in parameter, by name; the first of a name. */
1999
+ function builtinControlTargets(composition) {
2000
+ const nodes = new Map();
2001
+ for (const node of Array.isArray(composition.nodes)
2002
+ ? composition.nodes
2003
+ : []) {
2004
+ if (isRecord(node) && !nodes.has(text(node.id))) {
2005
+ nodes.set(text(node.id), node);
2006
+ }
2007
+ }
2008
+ const found = new Map();
2009
+ const seen = new Set();
2010
+ for (const control of Array.isArray(composition.controls)
2011
+ ? composition.controls
2012
+ : []) {
2013
+ if (!isRecord(control) || seen.has(text(control.name)))
2014
+ continue;
2015
+ seen.add(text(control.name));
2016
+ const node = nodes.get(text(control.node));
2017
+ const effect = isRecord(node) && isRecord(node.op) ? node.op.effect : undefined;
2018
+ if (!isRecord(effect))
2019
+ continue;
2020
+ const param = text(control.param);
2021
+ const rule = builtinParamRule(text(effect.id), param);
2022
+ if (rule)
2023
+ found.set(text(control.name), { effect: text(effect.id), param, rule });
2024
+ }
2025
+ return found;
2026
+ }
2027
+ function builtinParamRule(id, name) {
2028
+ const rules = builtinRules(id);
2029
+ return rules && Object.hasOwn(rules.params, name)
2030
+ ? rules.params[name]
2031
+ : undefined;
2032
+ }
2033
+ function acceptsBuiltinParam(param, animation) {
2034
+ if (isRecord(animation) && animation.mode === "data") {
2035
+ return param.type === "float" || param.type === "vec2";
2036
+ }
2037
+ const values = animationValues(animation) ?? [];
2038
+ const scalar = (value) => finiteNumber(value) &&
2039
+ (param.min === undefined || Math.fround(value) >= param.min) &&
2040
+ (param.max === undefined || Math.fround(value) <= param.max);
2041
+ return values.every((held) => {
2042
+ if (!isRecord(held) || held.type !== param.type)
2043
+ return false;
2044
+ const value = held.value;
2045
+ switch (param.type) {
2046
+ case "float":
2047
+ return scalar(value);
2048
+ case "vec2":
2049
+ case "vec4":
2050
+ return Array.isArray(value) && value.every(scalar);
2051
+ case "color":
2052
+ return (Array.isArray(value) &&
2053
+ value.every((part) => finiteNumber(part) &&
2054
+ Math.fround(part) >= 0 &&
2055
+ Math.fround(part) <= 1));
2056
+ case "enum":
2057
+ return (Number.isInteger(value) &&
2058
+ value >= 0 &&
2059
+ value < (param.choices ?? 0));
2060
+ default:
2061
+ return true;
2062
+ }
2063
+ });
2064
+ }
2065
+ /** How `effect`, used as `kind`, fails its built-in definition, worded as the model words it. */
2066
+ function builtinEffectProblem(effect, kind, inputs) {
2067
+ if (!isRecord(effect))
2068
+ return undefined;
2069
+ const id = text(effect.id);
2070
+ if (!id.startsWith(BUILTIN_EFFECT_PREFIX))
2071
+ return undefined;
2072
+ const rules = builtinRules(id);
2073
+ if (rules === undefined)
2074
+ return "is not a built-in";
2075
+ if (effect.version !== rules.version)
2076
+ return `needs version ${rules.version}`;
2077
+ if (rules.kind !== kind)
2078
+ return "is used as the wrong kind";
2079
+ const params = isRecord(effect.params) ? effect.params : {};
2080
+ // The model reads parameters in name order.
2081
+ for (const name of Object.keys(params).sort()) {
2082
+ const param = Object.hasOwn(rules.params, name)
2083
+ ? rules.params[name]
2084
+ : undefined;
2085
+ if (param === undefined)
2086
+ return `has no parameter ${name}`;
2087
+ if (!acceptsBuiltinParam(param, params[name])) {
2088
+ return `has a parameter ${name} of the wrong type or out of range`;
2089
+ }
2090
+ }
2091
+ const declared = (names, used) => {
2092
+ const keys = Object.keys(isRecord(used) ? used : {});
2093
+ return (keys.length === names.length && keys.every((key) => names.includes(key)));
2094
+ };
2095
+ if (!declared(rules.inputs, inputs)) {
2096
+ return "does not get exactly its declared inputs";
2097
+ }
2098
+ if (!declared(rules.resources, effect.resources)) {
2099
+ return "does not get exactly its declared resources";
2100
+ }
2101
+ return undefined;
2102
+ }
1739
2103
  function validEffectInputs(inputs) {
1740
2104
  if (inputs === undefined)
1741
2105
  return true;
@@ -1981,6 +2345,10 @@ function transitionProblems(trackId, trackKind, clips, transitions) {
1981
2345
  problems.push(`track ${trackId} has an invalid clip transition`);
1982
2346
  continue;
1983
2347
  }
2348
+ const builtin = builtinEffectProblem(transition.effect, "transition", undefined);
2349
+ if (builtin !== undefined) {
2350
+ problems.push(`effect ${text(transition.effect.id)} in the transition from ${text(transition.from_clip)} to ${text(transition.to_clip)} on track ${trackId} ${builtin}`);
2351
+ }
1984
2352
  // At most one transition per pair of clips, in either direction.
1985
2353
  const ends = [text(transition.from_clip), text(transition.to_clip)].sort();
1986
2354
  const pair = JSON.stringify(ends);
@@ -2000,13 +2368,14 @@ function captionsProblem(track, clips, transitions, trackId) {
2000
2368
  if (!isRecord(captions) || clips.length > 0 || transitions.length > 0) {
2001
2369
  return invalid;
2002
2370
  }
2003
- const cues = captions.cues;
2371
+ const cues = captions.cues ?? [];
2004
2372
  const styles = captions.styles ?? {};
2005
2373
  const encoder = new TextEncoder();
2006
2374
  const name = (value) => typeof value === "string" &&
2007
2375
  value.length > 0 &&
2008
2376
  encoder.encode(value).length <= MAX_CAPTION_NAME_BYTES;
2009
2377
  if (!Array.isArray(cues) ||
2378
+ (captions.from_words != null && cues.length > 0) ||
2010
2379
  !validTextStyle(captions.style ?? {}, MAX_CAPTION_FONT_SIZE) ||
2011
2380
  !isRecord(styles) ||
2012
2381
  Object.keys(styles).length > MAX_CAPTION_STYLES ||
@@ -2091,8 +2460,8 @@ function validTextStyle(style, maxFontSize) {
2091
2460
  within(style.letter_spacing ?? 0, MIN_LETTER_SPACING, MAX_LETTER_SPACING) &&
2092
2461
  validFontWeight(style.font_weight ?? 400) &&
2093
2462
  within(style.max_width ?? 0.9, 0, 1, true) &&
2094
- (style.position === undefined || validVec2(style.position)) &&
2095
- (style.anchor === undefined || validVec2(style.anchor)) &&
2463
+ (style.position === undefined || textPosition(style.position)) &&
2464
+ (style.anchor === undefined || textPosition(style.anchor)) &&
2096
2465
  (style.strokes === undefined || validTextStrokes(style.strokes)) &&
2097
2466
  (style.shadows === undefined || validTextShadows(style.shadows)) &&
2098
2467
  (style.animators === undefined ||
@@ -2191,7 +2560,7 @@ function validAnimatorProperties(properties) {
2191
2560
  const values = animationValues(animation);
2192
2561
  return values !== undefined && values.every(validRgba);
2193
2562
  };
2194
- return (vec2(properties.offset, -Infinity, Infinity) &&
2563
+ return (vec2(properties.offset, -MAX_ANIMATOR_OFFSET, MAX_ANIMATOR_OFFSET) &&
2195
2564
  vec2(properties.scale, 0, MAX_ANIMATOR_SCALE) &&
2196
2565
  validScalarAnimation(properties.rotation_degrees) &&
2197
2566
  validScalarAnimation(properties.opacity, 0, 1) &&
@@ -2584,19 +2953,26 @@ function layoutAnimatedIssue(animation, at, check) {
2584
2953
  function layoutScalarIssue(animation, at, check) {
2585
2954
  return layoutAnimatedIssue(animation, at, (value) => finiteNumber(value) && check(value));
2586
2955
  }
2956
+ /** Mirrors `LayoutLength::in_bounds`: finite and within its unit's bound. */
2957
+ function lengthInBounds(length) {
2958
+ const bound = length.unit === "px"
2959
+ ? MAX_LAYOUT_PX
2960
+ : length.unit === "percent"
2961
+ ? MAX_LAYOUT_PERCENT
2962
+ : MAX_LAYOUT_FRACTION;
2963
+ return finiteNumber(length.value) && Math.abs(length.value) <= bound;
2964
+ }
2587
2965
  function layoutSizeIssue(animation, at, check) {
2588
2966
  return layoutAnimatedIssue(animation, at, (value) => {
2589
2967
  const length = lengthOf(value);
2590
- return (length !== undefined && finiteNumber(length.value) && check(length.value));
2968
+ return (length !== undefined && lengthInBounds(length) && check(length.value));
2591
2969
  });
2592
2970
  }
2593
2971
  function layoutInsetsIssue(animation, at, check) {
2594
2972
  return layoutAnimatedIssue(animation, at, (value) => isRecord(value) &&
2595
2973
  ["top", "right", "bottom", "left"].every((side) => {
2596
2974
  const length = lengthOf(value[side]);
2597
- return (length !== undefined &&
2598
- finiteNumber(length.value) &&
2599
- check(length.value));
2975
+ return (length !== undefined && lengthInBounds(length) && check(length.value));
2600
2976
  }));
2601
2977
  }
2602
2978
  // Checks values, then that keyframes are all percents or all lengths.
@@ -2645,12 +3021,14 @@ function layoutFieldsIssue(node, at) {
2645
3021
  return issue;
2646
3022
  }
2647
3023
  if (present(node.aspect_ratio) &&
2648
- !(finiteNumber(node.aspect_ratio) && node.aspect_ratio > 0)) {
3024
+ !(finiteNumber(node.aspect_ratio) &&
3025
+ node.aspect_ratio >= MIN_ASPECT_RATIO &&
3026
+ node.aspect_ratio <= MAX_ASPECT_RATIO)) {
2649
3027
  return { at: field("aspect_ratio"), problem: LAYOUT_PROBLEM.outOfRange };
2650
3028
  }
2651
3029
  const item = layoutInsetsIssue(node.margin, field("margin"), anyValue) ??
2652
- layoutScalarIssue(node.flex_grow, field("flex_grow"), nonNegativeValue) ??
2653
- layoutScalarIssue(node.flex_shrink, field("flex_shrink"), nonNegativeValue) ??
3030
+ layoutScalarIssue(node.flex_grow, field("flex_grow"), flexFactor) ??
3031
+ layoutScalarIssue(node.flex_shrink, field("flex_shrink"), flexFactor) ??
2654
3032
  layoutLengthIssue(node.flex_basis, field("flex_basis"), nonNegativeValue);
2655
3033
  if (item)
2656
3034
  return item;
@@ -2662,9 +3040,15 @@ function layoutFieldsIssue(node, at) {
2662
3040
  }
2663
3041
  }
2664
3042
  return (layoutScalarIssue(node.opacity, field("opacity"), unitValue) ??
2665
- layoutAnimatedIssue(node.translate, field("translate"), (value) => isRecord(value) &&
2666
- finiteNumber(lengthOf(value.x)?.value) &&
2667
- finiteNumber(lengthOf(value.y)?.value)) ??
3043
+ layoutAnimatedIssue(node.translate, field("translate"), (value) => {
3044
+ if (!isRecord(value))
3045
+ return false;
3046
+ const [x, y] = [lengthOf(value.x), lengthOf(value.y)];
3047
+ return (x !== undefined &&
3048
+ y !== undefined &&
3049
+ lengthInBounds(x) &&
3050
+ lengthInBounds(y));
3051
+ }) ??
2668
3052
  layoutAnimatedIssue(node.scale, field("scale"), validVec2) ??
2669
3053
  layoutScalarIssue(node.rotation_degrees, field("rotation_degrees"), anyValue));
2670
3054
  }
@@ -2693,7 +3077,7 @@ function fixedTrack(size) {
2693
3077
  function trackProblem(tracks, explicit) {
2694
3078
  const sizes = tracks.flatMap((component) => component.kind === "single" ? [component.size] : component.tracks);
2695
3079
  const parts = sizes.map(trackParts);
2696
- if (!parts.every(({ lengths, share }) => lengths.every((length) => Number.isFinite(length.value) && length.value >= 0) &&
3080
+ if (!parts.every(({ lengths, share }) => lengths.every((length) => lengthInBounds(length) && length.value >= 0) &&
2697
3081
  (share === undefined || (Number.isFinite(share) && share > 0)))) {
2698
3082
  return LAYOUT_PROBLEM.outOfRange;
2699
3083
  }
@@ -2869,6 +3253,7 @@ function shapeItemIssue(item, at, depth, counted) {
2869
3253
  }
2870
3254
  const unitValue = (value) => value >= 0 && value <= 1;
2871
3255
  const nonNegativeValue = (value) => value >= 0;
3256
+ const flexFactor = (value) => value >= 0 && value <= MAX_FLEX_FACTOR;
2872
3257
  const anyValue = () => true;
2873
3258
  // Keyframe problems first, then values. A missing value takes its (valid) default.
2874
3259
  function shapeScalarIssue(animation, at, check) {
@@ -3280,7 +3665,7 @@ function frameNodesOver(tracks) {
3280
3665
  }
3281
3666
  return undefined;
3282
3667
  }
3283
- function compositionProblems(composition, sources, effectResources, compositions, controlNamesOf, canvas) {
3668
+ function compositionProblems(composition, sources, effectResources, compositions, controlNamesOf, builtinControlsOf, canvas) {
3284
3669
  if (!isRecord(composition))
3285
3670
  return ["each composition must be an object"];
3286
3671
  const id = text(composition.id);
@@ -3329,6 +3714,19 @@ function compositionProblems(composition, sources, effectResources, compositions
3329
3714
  controls.length > MAX_COMPOSITION_CONTROLS ||
3330
3715
  !controlsValid)
3331
3716
  problems.push(`composition ${id} has invalid group inputs or controls`);
3717
+ else {
3718
+ for (const control of controls.filter(isRecord)) {
3719
+ const target = byId.get(text(control.node));
3720
+ const effect = isRecord(target) && isRecord(target.op) ? target.op.effect : undefined;
3721
+ const param = text(control.param);
3722
+ if (isRecord(effect) &&
3723
+ builtinRules(text(effect.id)) !== undefined &&
3724
+ builtinParamRule(text(effect.id), param) === undefined) {
3725
+ problems.push(`effect ${text(effect.id)} in composition ${id} node ${text(control.node)} has no parameter ${param}`);
3726
+ break;
3727
+ }
3728
+ }
3729
+ }
3332
3730
  for (const node of nodes) {
3333
3731
  if (!isRecord(node) || !isRecord(node.op))
3334
3732
  continue;
@@ -3337,6 +3735,12 @@ function compositionProblems(composition, sources, effectResources, compositions
3337
3735
  const invalid = () => {
3338
3736
  problems.push(`node ${nodeId} of composition ${id} has an invalid setting`);
3339
3737
  };
3738
+ const builtinProblem = (effect, kind, effectInputs) => {
3739
+ const problem = builtinEffectProblem(effect, kind, effectInputs);
3740
+ if (problem !== undefined && isRecord(effect)) {
3741
+ problems.push(`effect ${text(effect.id)} in composition ${id} node ${nodeId} ${problem}`);
3742
+ }
3743
+ };
3340
3744
  const inputs = nodeInputs(op);
3341
3745
  if (node.bypass === true &&
3342
3746
  (["clip", "media", "generator", "group_input"].includes(text(op.type)) ||
@@ -3373,10 +3777,15 @@ function compositionProblems(composition, sources, effectResources, compositions
3373
3777
  if (!validClipEffect(op.effect) || !validEffectInputs(op.inputs)) {
3374
3778
  invalid();
3375
3779
  }
3780
+ else {
3781
+ builtinProblem(op.effect, "effect", op.inputs);
3782
+ }
3376
3783
  break;
3377
3784
  case "transition":
3378
3785
  if (!validClipEffect(op.effect) || !unit(op.progress))
3379
3786
  invalid();
3787
+ else
3788
+ builtinProblem(op.effect, "transition", undefined);
3380
3789
  break;
3381
3790
  case "transform":
3382
3791
  if (!validVisual(op.transform))
@@ -3412,8 +3821,17 @@ function compositionProblems(composition, sources, effectResources, compositions
3412
3821
  if (!Array.isArray(op.inputs ?? []) ||
3413
3822
  inputs.length !== targetPorts.length ||
3414
3823
  !isRecord(values) ||
3415
- !Object.entries(values).every(([name, value]) => targetControls.has(name) && validEffectParam(value)))
3824
+ !Object.entries(values).every(([name, value]) => targetControls.has(name) && validEffectParam(value))) {
3416
3825
  invalid();
3826
+ break;
3827
+ }
3828
+ for (const [name, value] of Object.entries(values)) {
3829
+ const control = builtinControlsOf(target).get(name);
3830
+ if (control && !acceptsBuiltinParam(control.rule, value)) {
3831
+ problems.push(`effect ${control.effect} in composition ${id} node ${nodeId} has a parameter ${control.param} of the wrong type or out of range`);
3832
+ break;
3833
+ }
3834
+ }
3417
3835
  break;
3418
3836
  }
3419
3837
  case "group_input":