@nodaro/shared 3.61.0 → 3.62.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 (254) hide show
  1. package/dist/{chunk-IVXSNW2B.cjs → chunk-2D5LQFV4.cjs} +18 -332
  2. package/dist/chunk-2D5LQFV4.cjs.map +1 -0
  3. package/dist/{chunk-XUJC6GHE.cjs → chunk-2HZGDZZN.cjs} +6 -6
  4. package/dist/{chunk-XUJC6GHE.cjs.map → chunk-2HZGDZZN.cjs.map} +1 -1
  5. package/dist/{chunk-43TGSZRJ.js → chunk-2QKF7M2Z.js} +3 -3
  6. package/dist/{chunk-43TGSZRJ.js.map → chunk-2QKF7M2Z.js.map} +1 -1
  7. package/dist/{chunk-7ARKVJTN.cjs → chunk-2W745U4A.cjs} +228 -355
  8. package/dist/chunk-2W745U4A.cjs.map +1 -0
  9. package/dist/{chunk-673E4KYC.js → chunk-3OYO3XCC.js} +70 -6
  10. package/dist/chunk-3OYO3XCC.js.map +1 -0
  11. package/dist/{chunk-FMXFHJWX.cjs → chunk-4ZEFP2FQ.cjs} +4 -4
  12. package/dist/{chunk-FMXFHJWX.cjs.map → chunk-4ZEFP2FQ.cjs.map} +1 -1
  13. package/dist/{chunk-A3FHTSLB.js → chunk-5YYN5X57.js} +302 -27
  14. package/dist/chunk-5YYN5X57.js.map +1 -0
  15. package/dist/{chunk-4KYLNTR7.cjs → chunk-6CSXMWL4.cjs} +4 -4
  16. package/dist/{chunk-4KYLNTR7.cjs.map → chunk-6CSXMWL4.cjs.map} +1 -1
  17. package/dist/{chunk-M3SXUUWC.cjs → chunk-6FQBKI2A.cjs} +4 -11
  18. package/dist/chunk-6FQBKI2A.cjs.map +1 -0
  19. package/dist/{chunk-G4XWVWRI.js → chunk-6G7NN4S4.js} +5 -4
  20. package/dist/chunk-6G7NN4S4.js.map +1 -0
  21. package/dist/{chunk-ZFJN23V4.cjs → chunk-A2PX5IRC.cjs} +4 -4
  22. package/dist/{chunk-ZFJN23V4.cjs.map → chunk-A2PX5IRC.cjs.map} +1 -1
  23. package/dist/{chunk-JHTT2V4A.cjs → chunk-AFYTX4AI.cjs} +52 -43
  24. package/dist/chunk-AFYTX4AI.cjs.map +1 -0
  25. package/dist/chunk-ALRXY4QH.cjs +13 -0
  26. package/dist/chunk-ALRXY4QH.cjs.map +1 -0
  27. package/dist/chunk-AOJ6B7K4.cjs +351 -0
  28. package/dist/chunk-AOJ6B7K4.cjs.map +1 -0
  29. package/dist/{chunk-ZDBPQBAA.js → chunk-C7POAYFE.js} +3 -3
  30. package/dist/{chunk-ZDBPQBAA.js.map → chunk-C7POAYFE.js.map} +1 -1
  31. package/dist/{chunk-B6BG3LV2.js → chunk-CC4V2B7S.js} +3 -3
  32. package/dist/{chunk-B6BG3LV2.js.map → chunk-CC4V2B7S.js.map} +1 -1
  33. package/dist/{chunk-XZKFZMRT.cjs → chunk-CIPPPT7E.cjs} +6 -6
  34. package/dist/{chunk-XZKFZMRT.cjs.map → chunk-CIPPPT7E.cjs.map} +1 -1
  35. package/dist/{chunk-6XVHYD5R.js → chunk-CLAKSLXF.js} +4 -9
  36. package/dist/chunk-CLAKSLXF.js.map +1 -0
  37. package/dist/chunk-CTANEPMY.js +61 -0
  38. package/dist/chunk-CTANEPMY.js.map +1 -0
  39. package/dist/{chunk-WGKAOUEQ.cjs → chunk-D34K455O.cjs} +3 -2
  40. package/dist/chunk-D34K455O.cjs.map +1 -0
  41. package/dist/chunk-E2HZTGYX.js +331 -0
  42. package/dist/chunk-E2HZTGYX.js.map +1 -0
  43. package/dist/{chunk-RQ4F3AJH.cjs → chunk-G3KVK7OU.cjs} +21 -21
  44. package/dist/{chunk-RQ4F3AJH.cjs.map → chunk-G3KVK7OU.cjs.map} +1 -1
  45. package/dist/chunk-G4U3HW6W.js +453 -0
  46. package/dist/chunk-G4U3HW6W.js.map +1 -0
  47. package/dist/{chunk-IRQ3SPX7.js → chunk-GSFB537T.js} +3 -3
  48. package/dist/{chunk-IRQ3SPX7.js.map → chunk-GSFB537T.js.map} +1 -1
  49. package/dist/chunk-HRY7KGAE.cjs +506 -0
  50. package/dist/chunk-HRY7KGAE.cjs.map +1 -0
  51. package/dist/{chunk-VOWJCUMR.js → chunk-I2RQB7VG.js} +3 -3
  52. package/dist/{chunk-VOWJCUMR.js.map → chunk-I2RQB7VG.js.map} +1 -1
  53. package/dist/chunk-IDTKF5EX.cjs +48 -0
  54. package/dist/chunk-IDTKF5EX.cjs.map +1 -0
  55. package/dist/{chunk-5XRRENHD.cjs → chunk-IWWVPR3W.cjs} +88 -11
  56. package/dist/chunk-IWWVPR3W.cjs.map +1 -0
  57. package/dist/{chunk-SCMTN57Y.js → chunk-JJNNM23P.js} +3 -3
  58. package/dist/{chunk-SCMTN57Y.js.map → chunk-JJNNM23P.js.map} +1 -1
  59. package/dist/{chunk-ZZGQRRN7.js → chunk-JZGZ26YB.js} +6 -306
  60. package/dist/chunk-JZGZ26YB.js.map +1 -0
  61. package/dist/{chunk-XROE3CAS.cjs → chunk-KHH54GRP.cjs} +120 -79
  62. package/dist/chunk-KHH54GRP.cjs.map +1 -0
  63. package/dist/{chunk-NJVOJXBS.cjs → chunk-KJSRPHJ2.cjs} +48 -47
  64. package/dist/chunk-KJSRPHJ2.cjs.map +1 -0
  65. package/dist/{chunk-FVVD6XY2.js → chunk-KL6GAYTT.js} +13 -4
  66. package/dist/chunk-KL6GAYTT.js.map +1 -0
  67. package/dist/{chunk-AFQFGZN7.cjs → chunk-KYMHFVAZ.cjs} +8 -6
  68. package/dist/chunk-KYMHFVAZ.cjs.map +1 -0
  69. package/dist/{chunk-F5YEMSNK.cjs → chunk-MYJQELFN.cjs} +320 -26
  70. package/dist/chunk-MYJQELFN.cjs.map +1 -0
  71. package/dist/chunk-N5HH46JF.cjs +68 -0
  72. package/dist/chunk-N5HH46JF.cjs.map +1 -0
  73. package/dist/{chunk-MQZRQ5LM.cjs → chunk-N7OUQK7E.cjs} +8 -8
  74. package/dist/{chunk-MQZRQ5LM.cjs.map → chunk-N7OUQK7E.cjs.map} +1 -1
  75. package/dist/{chunk-UARGJ5IZ.js → chunk-NGKKNSK6.js} +30 -7
  76. package/dist/chunk-NGKKNSK6.js.map +1 -0
  77. package/dist/{chunk-SWVGHAYO.js → chunk-O7RZRUMZ.js} +110 -74
  78. package/dist/chunk-O7RZRUMZ.js.map +1 -0
  79. package/dist/{chunk-C77F4ZTL.js → chunk-PTD6EDUU.js} +3 -3
  80. package/dist/{chunk-C77F4ZTL.js.map → chunk-PTD6EDUU.js.map} +1 -1
  81. package/dist/{chunk-ZNM2LW3D.cjs → chunk-QWYFHQYK.cjs} +78 -53
  82. package/dist/chunk-QWYFHQYK.cjs.map +1 -0
  83. package/dist/{chunk-VB2ARGQ6.js → chunk-RGNHHIMN.js} +3 -3
  84. package/dist/chunk-RGNHHIMN.js.map +1 -0
  85. package/dist/{chunk-MOMFX32D.js → chunk-S24ZBUB4.js} +194 -299
  86. package/dist/chunk-S24ZBUB4.js.map +1 -0
  87. package/dist/{chunk-EWS2VFO4.js → chunk-S5TMRJMX.js} +4 -4
  88. package/dist/{chunk-EWS2VFO4.js.map → chunk-S5TMRJMX.js.map} +1 -1
  89. package/dist/chunk-SMOO5FAH.js +10 -0
  90. package/dist/chunk-SMOO5FAH.js.map +1 -0
  91. package/dist/{chunk-RUHKBEFF.js → chunk-SYWR5G3T.js} +16 -7
  92. package/dist/chunk-SYWR5G3T.js.map +1 -0
  93. package/dist/{chunk-FQXRYPCX.cjs → chunk-TRVWMKNE.cjs} +337 -52
  94. package/dist/chunk-TRVWMKNE.cjs.map +1 -0
  95. package/dist/{chunk-LLOIAGFB.js → chunk-UDDVDQMF.js} +292 -35
  96. package/dist/chunk-UDDVDQMF.js.map +1 -0
  97. package/dist/{chunk-PONP5J5E.cjs → chunk-V24EPI5N.cjs} +13 -3
  98. package/dist/chunk-V24EPI5N.cjs.map +1 -0
  99. package/dist/{chunk-5I4T4QR5.cjs → chunk-VACPZPUA.cjs} +5 -5
  100. package/dist/{chunk-5I4T4QR5.cjs.map → chunk-VACPZPUA.cjs.map} +1 -1
  101. package/dist/{chunk-HGI2VKIV.js → chunk-Y6X7UJSD.js} +10 -9
  102. package/dist/chunk-Y6X7UJSD.js.map +1 -0
  103. package/dist/chunk-YCXRSWCQ.js +42 -0
  104. package/dist/chunk-YCXRSWCQ.js.map +1 -0
  105. package/dist/entries/apps.cjs +44 -44
  106. package/dist/entries/apps.js +9 -9
  107. package/dist/entries/credits.cjs +217 -152
  108. package/dist/entries/credits.d.cts +105 -3
  109. package/dist/entries/credits.d.ts +105 -3
  110. package/dist/entries/credits.js +13 -8
  111. package/dist/entries/entities.cjs +188 -143
  112. package/dist/entries/entities.d.cts +122 -1
  113. package/dist/entries/entities.d.ts +122 -1
  114. package/dist/entries/entities.js +2 -1
  115. package/dist/entries/llm-models.d.cts +2 -1
  116. package/dist/entries/llm-models.d.ts +2 -1
  117. package/dist/entries/media.cjs +92 -87
  118. package/dist/entries/media.d.cts +11 -1
  119. package/dist/entries/media.d.ts +11 -1
  120. package/dist/entries/media.js +3 -2
  121. package/dist/entries/model-catalog.cjs +195 -103
  122. package/dist/entries/model-catalog.d.cts +90 -4
  123. package/dist/entries/model-catalog.d.ts +90 -4
  124. package/dist/entries/model-catalog.js +5 -5
  125. package/dist/entries/models.cjs +407 -294
  126. package/dist/entries/models.d.cts +4 -3
  127. package/dist/entries/models.d.ts +4 -3
  128. package/dist/entries/models.js +6 -5
  129. package/dist/entries/nodes.cjs +241 -233
  130. package/dist/entries/nodes.d.cts +15 -2
  131. package/dist/entries/nodes.d.ts +15 -2
  132. package/dist/entries/nodes.js +10 -10
  133. package/dist/entries/pipeline.cjs +152 -152
  134. package/dist/entries/pipeline.d.cts +2 -1
  135. package/dist/entries/pipeline.d.ts +2 -1
  136. package/dist/entries/pipeline.js +3 -3
  137. package/dist/entries/ugc.cjs +71 -71
  138. package/dist/entries/ugc.js +4 -4
  139. package/dist/entries/video.cjs +308 -204
  140. package/dist/entries/video.d.cts +480 -98
  141. package/dist/entries/video.d.ts +480 -98
  142. package/dist/entries/video.js +8 -4
  143. package/dist/entries/workflow.cjs +102 -102
  144. package/dist/entries/workflow.d.cts +5 -4
  145. package/dist/entries/workflow.d.ts +5 -4
  146. package/dist/entries/workflow.js +2 -2
  147. package/dist/{gpt-image-2-6-BeZdT-pW.d.cts → gpt-image-2-6-jIRQBRag.d.cts} +6 -0
  148. package/dist/{gpt-image-2-6-BeZdT-pW.d.ts → gpt-image-2-6-jIRQBRag.d.ts} +6 -0
  149. package/dist/index.cjs +2309 -1886
  150. package/dist/index.d.cts +9 -9
  151. package/dist/index.d.ts +9 -9
  152. package/dist/index.js +26 -23
  153. package/dist/{model-catalog-BgSvskgY.d.cts → model-catalog-CCEcv08q.d.cts} +128 -14
  154. package/dist/{model-catalog-BgSvskgY.d.ts → model-catalog-CCEcv08q.d.ts} +128 -14
  155. package/dist/{model-constants-DHd9jwQ7.d.ts → model-constants-B88p6XR0.d.ts} +299 -19
  156. package/dist/{model-constants-DHd9jwQ7.d.cts → model-constants-Cf3zaITt.d.cts} +299 -19
  157. package/package.json +1 -1
  158. package/src/__tests__/extend-providers.test.ts +114 -0
  159. package/src/__tests__/fixtures/mask-composite-quote-parity.json +118 -0
  160. package/src/__tests__/fixtures/root-exports.baseline.json +68 -0
  161. package/src/__tests__/gpt-image-2-6-formats.test.ts +4 -1
  162. package/src/__tests__/grok-video-15-catalog.test.ts +189 -0
  163. package/src/__tests__/gvp-supported-providers.test.ts +5 -2
  164. package/src/__tests__/minimax-h3-image.test.ts +140 -0
  165. package/src/__tests__/model-makers.test.ts +49 -11
  166. package/src/__tests__/model-tree.test.ts +13 -0
  167. package/src/__tests__/retired-video-provider.test.ts +15 -5
  168. package/src/__tests__/seedance-25-catalog-modes.test.ts +1 -1
  169. package/src/__tests__/seedance-task-type.test.ts +178 -0
  170. package/src/__tests__/seedream-5-5.test.ts +117 -0
  171. package/src/__tests__/unit-contract-compose.test.ts +27 -1
  172. package/src/__tests__/unit-contracts.test.ts +20 -6
  173. package/src/__tests__/upscale-factors.test.ts +107 -0
  174. package/src/__tests__/video-character-refs.test.ts +20 -2
  175. package/src/__tests__/video-collapse-parity.test.ts +19 -0
  176. package/src/__tests__/video-overlay-geometry.test.ts +68 -0
  177. package/src/__tests__/video-overlay-layer-plan.test.ts +3 -4
  178. package/src/__tests__/video-overlay-layouts.test.ts +529 -0
  179. package/src/__tests__/video-overlay-pricing.test.ts +61 -0
  180. package/src/__tests__/video-overlay-validate.test.ts +128 -0
  181. package/src/__tests__/video-overlay-wired-kind.test.ts +207 -0
  182. package/src/__tests__/video-overlay.test.ts +280 -194
  183. package/src/__tests__/video-ref-limits.test.ts +2 -1
  184. package/src/__tests__/video-reference-only.test.ts +6 -2
  185. package/src/__tests__/video-start-frame-only.test.ts +98 -0
  186. package/src/__tests__/wired-character-names.test.ts +220 -0
  187. package/src/credit-estimators/index.ts +8 -0
  188. package/src/credit-estimators/video-overlay.ts +70 -0
  189. package/src/credit-identifiers.ts +94 -1
  190. package/src/entity-image-url.ts +21 -0
  191. package/src/entries/credits.ts +14 -0
  192. package/src/entries/entities.ts +14 -0
  193. package/src/entries/model-catalog.ts +35 -1
  194. package/src/entries/models.ts +34 -0
  195. package/src/entries/nodes.ts +2 -0
  196. package/src/entries/video.ts +6 -0
  197. package/src/generated/unit-contracts.ts +8 -1
  198. package/src/gpt-image-2-6.ts +6 -0
  199. package/src/input-image-pricing.ts +76 -0
  200. package/src/mask-composite.ts +11 -0
  201. package/src/minimax-h3-image.ts +61 -0
  202. package/src/model-catalog.ts +355 -37
  203. package/src/model-constants.ts +590 -32
  204. package/src/node-default-mappings.ts +12 -2
  205. package/src/node-execution-state.ts +4 -3
  206. package/src/producer-types.ts +23 -1
  207. package/src/seedance-task-type.ts +37 -0
  208. package/src/seedream-5-5.ts +45 -0
  209. package/src/unit-contract-compose.ts +4 -1
  210. package/src/upscale-factors.ts +111 -0
  211. package/src/video-character-refs.ts +7 -4
  212. package/src/video-overlay-geometry.ts +99 -0
  213. package/src/video-overlay-input.ts +25 -0
  214. package/src/video-overlay-layout-ids.ts +48 -0
  215. package/src/video-overlay-layouts.ts +315 -0
  216. package/src/video-overlay-validate.ts +223 -0
  217. package/src/video-overlay-video-layers.ts +304 -0
  218. package/src/video-overlay.ts +165 -297
  219. package/src/video-ui-defaults.ts +8 -6
  220. package/src/wired-character-names.ts +202 -0
  221. package/dist/chunk-5XRRENHD.cjs.map +0 -1
  222. package/dist/chunk-673E4KYC.js.map +0 -1
  223. package/dist/chunk-6XVHYD5R.js.map +0 -1
  224. package/dist/chunk-7ARKVJTN.cjs.map +0 -1
  225. package/dist/chunk-7WGKP3EU.js +0 -23
  226. package/dist/chunk-7WGKP3EU.js.map +0 -1
  227. package/dist/chunk-A3FHTSLB.js.map +0 -1
  228. package/dist/chunk-AFQFGZN7.cjs.map +0 -1
  229. package/dist/chunk-F5YEMSNK.cjs.map +0 -1
  230. package/dist/chunk-FQXRYPCX.cjs.map +0 -1
  231. package/dist/chunk-FVVD6XY2.js.map +0 -1
  232. package/dist/chunk-G4XWVWRI.js.map +0 -1
  233. package/dist/chunk-HGI2VKIV.js.map +0 -1
  234. package/dist/chunk-IVXSNW2B.cjs.map +0 -1
  235. package/dist/chunk-JHTT2V4A.cjs.map +0 -1
  236. package/dist/chunk-KHZAQGRP.js +0 -17
  237. package/dist/chunk-KHZAQGRP.js.map +0 -1
  238. package/dist/chunk-LLOIAGFB.js.map +0 -1
  239. package/dist/chunk-M3SXUUWC.cjs.map +0 -1
  240. package/dist/chunk-MOMFX32D.js.map +0 -1
  241. package/dist/chunk-NCOGGRRP.cjs +0 -27
  242. package/dist/chunk-NCOGGRRP.cjs.map +0 -1
  243. package/dist/chunk-NJVOJXBS.cjs.map +0 -1
  244. package/dist/chunk-PONP5J5E.cjs.map +0 -1
  245. package/dist/chunk-RUHKBEFF.js.map +0 -1
  246. package/dist/chunk-SWVGHAYO.js.map +0 -1
  247. package/dist/chunk-UARGJ5IZ.js.map +0 -1
  248. package/dist/chunk-VB2ARGQ6.js.map +0 -1
  249. package/dist/chunk-WGKAOUEQ.cjs.map +0 -1
  250. package/dist/chunk-XROE3CAS.cjs.map +0 -1
  251. package/dist/chunk-ZLDFPVVI.cjs +0 -19
  252. package/dist/chunk-ZLDFPVVI.cjs.map +0 -1
  253. package/dist/chunk-ZNM2LW3D.cjs.map +0 -1
  254. package/dist/chunk-ZZGQRRN7.js.map +0 -1
@@ -8,22 +8,26 @@ import {
8
8
  clearWiredVideoOverlayImageUrls,
9
9
  expandVideoOverlayLayer,
10
10
  expandVideoOverlayPresets,
11
- formatVideoOverlayError,
12
- hasDrawableVideoOverlayBox,
13
11
  normalizeVideoOverlayNodes,
14
- resolveVideoOverlayGeometry,
15
12
  toCustomVideoOverlayLayer,
16
- validateVideoOverlayRequest,
17
- videoOverlayCanvas,
18
13
  VIDEO_OVERLAY_MAX_COMPOSITION_KEY_LENGTH,
19
14
  VIDEO_OVERLAY_MAX_LAYERS,
20
15
  videoOverlayCompositionKey,
21
16
  videoOverlayRenderOrder,
22
17
  videoOverlaySlotOfHandle,
23
18
  videoOverlaySlotSources,
24
- type VideoOverlayIssue,
19
+ VIDEO_OVERLAY_ERROR_CODES,
20
+ VIDEO_OVERLAY_MAX_LAYER_VIDEO_BYTES,
21
+ VIDEO_OVERLAY_MAX_VIDEO_LAYERS,
22
+ VIDEO_OVERLAY_VIDEO_MAX_BASE_SEC,
23
+ VIDEO_OVERLAY_VOLUME_BOUNDS,
24
+ VIDEO_OVERLAY_WARNING_CODES,
25
25
  type VideoOverlayLayerInput,
26
+ type VideoOverlayLayerSpec,
26
27
  } from "../video-overlay.js"
28
+ import { formatVideoOverlayError, hasDrawableVideoOverlayBox, validateVideoOverlayRequest, type VideoOverlayIssue } from "../video-overlay-validate.js"
29
+ import { videoOverlayHasVideoLayer, videoOverlayWiredLayerKind } from "../video-overlay-video-layers.js"
30
+ import { DYNAMIC_PRODUCER_TYPES } from "../producer-types.js"
27
31
 
28
32
  const IMG = "https://cdn.example/a.png"
29
33
 
@@ -177,6 +181,24 @@ describe("normalizeVideoOverlayNodes (the JSON write-boundary pass)", () => {
177
181
  expect(layers[1]).toEqual(expandVideoOverlayLayer({ imageUrl: IMG, start: 1 }))
178
182
  expect(validateVideoOverlayRequest({ layers: layers as VideoOverlayLayerInput[] })).toMatchObject({ ok: false, code: "layer_without_image", layer: 0 })
179
183
  })
184
+ it("a wired slot's layer keeps only the fade setting it was written with: its default follows the wire's kind, read at the run", () => {
185
+ const [out] = normalizeVideoOverlayNodes([node([{ start: 1, preset: "card" }, { start: 2, animate: true }, { imageUrl: IMG, start: 3 }])], [
186
+ { target: "vo", targetHandle: "overlay" },
187
+ { target: "vo", targetHandle: "overlay2" },
188
+ ])
189
+ const layers = (out!.data as { layers: VideoOverlayLayerInput[] }).layers
190
+ expect(layers[0]).toMatchObject({ ...VIDEO_OVERLAY_PRESETS.card, start: 1, opacity: 1 })
191
+ expect(layers[0]).not.toHaveProperty("animate")
192
+ expect(layers[1]).toMatchObject({ start: 2, animate: true })
193
+ // An unwired slot's kind is its own source: expanded in full, as before.
194
+ expect(layers[2]).toEqual(expandVideoOverlayLayer({ imageUrl: IMG, start: 3 }))
195
+ // Idempotent, by reference.
196
+ const again = normalizeVideoOverlayNodes([out!], [{ target: "vo", targetHandle: "overlay" }, { target: "vo", targetHandle: "overlay2" }])
197
+ expect(again[0]).toBe(out)
198
+ // A video wired in later runs without a fade, as a video layer's default.
199
+ const run = assembleVideoOverlayRequest({ videoUrl: "v", data: { layers }, wiredImageUrls: ["https://x/clip"], wiredVideoSlots: new Set([1]) })
200
+ expect(run.layers[0]).toMatchObject({ videoUrl: "https://x/clip", animate: false })
201
+ })
180
202
  it("a null slot STAYS null — wired or not; only the engine assemblies and the stage synthesise the default (Review Focus 1)", () => {
181
203
  const [out] = normalizeVideoOverlayNodes([node([null, { imageUrl: IMG, start: 1 }, null])], [{ target: "vo", targetHandle: "overlay3" }])
182
204
  expect((out!.data as { layers: unknown[] }).layers).toEqual([null, expandVideoOverlayLayer({ imageUrl: IMG, start: 1 }), null])
@@ -185,71 +207,6 @@ describe("normalizeVideoOverlayNodes (the JSON write-boundary pass)", () => {
185
207
  })
186
208
  })
187
209
 
188
- describe("resolveVideoOverlayGeometry (§3.4 — shared by the preview and the worker)", () => {
189
- it("the card preset on 1080×1920 (the spec's worked example)", () => {
190
- expect(resolveVideoOverlayGeometry({ w: 1080, h: 1920 }, VIDEO_OVERLAY_PRESETS.card, 1080 / 2160)).toEqual({
191
- box: { left: 119, top: 307, width: 842, height: 1152 },
192
- drawn: { left: 252, top: 307, width: 576, height: 1152 },
193
- })
194
- })
195
- it("full-frame on a 9:16 canvas is the whole canvas — no edge shrink", () => {
196
- expect(resolveVideoOverlayGeometry({ w: 1080, h: 1920 }, VIDEO_OVERLAY_PRESETS["full-frame"], 16 / 9).drawn).toEqual({ left: 0, top: 0, width: 1080, height: 1920 })
197
- })
198
- it("a corner badge on 16:9", () => {
199
- expect(resolveVideoOverlayGeometry({ w: 1920, h: 1080 }, VIDEO_OVERLAY_PRESETS["corner-badge"]["bottom-right"], 1).drawn).toEqual({ left: 1497, top: 691, width: 346, height: 346 })
200
- })
201
- it("an odd drawn size is rounded DOWN to even (libx264 yuv420p)", () => {
202
- expect(resolveVideoOverlayGeometry({ w: 1000, h: 1000 }, { anchor: "top-left", x: 0, y: 0, width: 25, fit: "contain" }, 3).drawn).toEqual({ left: 1, top: 0, width: 248, height: 82 })
203
- })
204
- it("a very tall image at width 60 % with no height is fitted inside the canvas (the clamp): 192 × 1920", () => {
205
- expect(resolveVideoOverlayGeometry({ w: 1080, h: 1920 }, { anchor: "center", x: 0, y: 0, width: 60, fit: "contain" }, 400 / 4000)).toEqual({
206
- box: { left: 444, top: 0, width: 192, height: 1920 },
207
- drawn: { left: 444, top: 0, width: 192, height: 1920 },
208
- })
209
- })
210
- it("…and with height 60 % set: box 648 × 1152, contain → 114 × 1152, no clamp", () => {
211
- const g = resolveVideoOverlayGeometry({ w: 1080, h: 1920 }, { anchor: "center", x: 0, y: 0, width: 60, height: 60, fit: "contain" }, 400 / 4000)
212
- expect(g.box).toEqual({ left: 216, top: 384, width: 648, height: 1152 })
213
- expect(g.drawn).toEqual({ left: 483, top: 384, width: 114, height: 1152 })
214
- })
215
- it("a drawn size that would round below 2 px is floored at 2 × 2 (Review Focus 4)", () => {
216
- expect(resolveVideoOverlayGeometry({ w: 100, h: 100 }, { anchor: "top-left", x: 0, y: 0, width: 1, fit: "contain" }, 1).drawn).toMatchObject({ width: 2, height: 2 })
217
- })
218
- it("property: drawn is even, ≥ 2 and never larger than the canvas", () => {
219
- const canvases = [{ w: 1080, h: 1920 }, { w: 1920, h: 1080 }, { w: 100, h: 100 }, { w: 640, h: 360 }]
220
- for (const canvas of canvases) {
221
- for (let width = 1; width <= 100; width += 7) {
222
- for (const height of [undefined, 1, 14, 60, 100]) {
223
- for (const aspect of [0.05, 0.5, 1, 2, 20]) {
224
- for (const fit of ["contain", "cover"] as const) {
225
- const { drawn } = resolveVideoOverlayGeometry(canvas, { anchor: "center", x: 0, y: 0, width, height, fit }, aspect)
226
- expect(drawn.width % 2).toBe(0)
227
- expect(drawn.height % 2).toBe(0)
228
- expect(drawn.width).toBeGreaterThanOrEqual(2)
229
- expect(drawn.width).toBeLessThanOrEqual(canvas.w)
230
- expect(drawn.height).toBeLessThanOrEqual(canvas.h)
231
- }
232
- }
233
- }
234
- }
235
- }
236
- })
237
- })
238
-
239
- describe("videoOverlayCanvas", () => {
240
- it("is the display size: SAR resolved, even-rounded", () => {
241
- expect(videoOverlayCanvas({ width: 540, height: 1920, sar: 2 })).toEqual({ w: 1080, h: 1920 })
242
- expect(videoOverlayCanvas({ width: 1079, height: 1919 })).toEqual({ w: 1078, h: 1918 })
243
- })
244
- it("a target aspect wins", () => {
245
- expect(videoOverlayCanvas({ width: 1920, height: 1080 }, "9:16")).toEqual({ w: 1080, h: 1920 })
246
- expect(videoOverlayCanvas(null, "4:5")).toEqual({ w: 1080, h: 1350 })
247
- })
248
- it("unknown size and no aspect → null", () => {
249
- expect(videoOverlayCanvas(null)).toBeNull()
250
- })
251
- })
252
-
253
210
  describe("videoOverlayRenderOrder", () => {
254
211
  it("explicit zIndex wins, ties keep array order", () => {
255
212
  expect(videoOverlayRenderOrder([{ zIndex: 5 }, {}, { zIndex: 0 }])).toEqual([2, 1, 0])
@@ -294,129 +251,6 @@ describe("videoOverlayRenderOrder", () => {
294
251
  })
295
252
  })
296
253
 
297
- describe("hasDrawableVideoOverlayBox", () => {
298
- it("a complete (expanded) layer is drawable", () => {
299
- expect(hasDrawableVideoOverlayBox(expandVideoOverlayLayer({ imageUrl: IMG, start: 0 }))).toBe(true)
300
- expect(hasDrawableVideoOverlayBox(expandVideoOverlayLayer({ imageUrl: IMG, start: 0, preset: "card" }))).toBe(true)
301
- })
302
-
303
- it("a stored partial box is not — the expansion leaves it as written, the geometry would throw", () => {
304
- const noAnchor = { imageUrl: IMG, start: 0, width: 40 }
305
- const nullAnchor = { imageUrl: IMG, start: 0, anchor: null, width: 30 }
306
- expect(expandVideoOverlayLayer(noAnchor)).toBe(noAnchor)
307
- expect(hasDrawableVideoOverlayBox(noAnchor)).toBe(false)
308
- expect(hasDrawableVideoOverlayBox(nullAnchor)).toBe(false)
309
- expect(hasDrawableVideoOverlayBox({ imageUrl: IMG, start: 0, anchor: "center" })).toBe(false)
310
- })
311
-
312
- it("an unknown anchor, a non-finite width or an out-of-range field is not", () => {
313
- const ok = expandVideoOverlayLayer({ imageUrl: IMG, start: 0 })
314
- expect(hasDrawableVideoOverlayBox({ ...ok, anchor: "middle" })).toBe(false)
315
- expect(hasDrawableVideoOverlayBox({ ...ok, width: Number.NaN })).toBe(false)
316
- expect(hasDrawableVideoOverlayBox({ ...ok, width: "40" })).toBe(false)
317
- expect(hasDrawableVideoOverlayBox({ ...ok, x: 500 })).toBe(false)
318
- expect(hasDrawableVideoOverlayBox(null)).toBe(false)
319
- expect(hasDrawableVideoOverlayBox("layer")).toBe(false)
320
- })
321
-
322
- it("agrees with the validator: whatever it passes is drawable", () => {
323
- const layers = [
324
- expandVideoOverlayLayer({ imageUrl: IMG, start: 0, anchor: "top-left", width: 30 }),
325
- expandVideoOverlayLayer({ imageUrl: IMG, start: 0, preset: "full-frame" }),
326
- ]
327
- expect(validateVideoOverlayRequest({ layers }).ok).toBe(true)
328
- for (const l of layers) expect(hasDrawableVideoOverlayBox(l)).toBe(true)
329
- })
330
- })
331
-
332
- describe("validateVideoOverlayRequest (§3.5)", () => {
333
- const ok = { imageUrl: IMG, start: 0 }
334
- const fail = (body: Parameters<typeof validateVideoOverlayRequest>[0]) => validateVideoOverlayRequest(body) as VideoOverlayIssue
335
- it("returns a code, the 0-based layer, the slot when present, and params — never English", () => {
336
- const r = fail({ layers: [ok, ok, { imageUrl: IMG, start: 5, end: 4 }] })
337
- expect(r).toEqual({ ok: false, code: "end_before_start", layer: 2, params: { start: 5, end: 4 } })
338
- expect(formatVideoOverlayError(r)).toBe("layers[2]: end (4 s) must be after start (5 s)")
339
- const s = fail({ layers: [{ imageUrl: IMG, start: 5, end: 4, slot: 3 }] })
340
- expect(formatVideoOverlayError(s)).toBe("Layer 3: end (4 s) must be after start (5 s)")
341
- })
342
- it("layer count 1..20", () => {
343
- expect(fail({ layers: [] }).code).toBe("no_layers")
344
- const many = fail({ layers: Array.from({ length: 21 }, () => ok) })
345
- expect(many.code).toBe("too_many_layers")
346
- expect(formatVideoOverlayError(many)).toBe("At most 20 layers (got 21)")
347
- })
348
- it("times finite within 0..3600", () => {
349
- expect(fail({ layers: [{ imageUrl: IMG, start: -1 }] }).code).toBe("time_out_of_range")
350
- expect(fail({ layers: [{ imageUrl: IMG, start: 0, end: 3601 }] }).code).toBe("time_out_of_range")
351
- expect(fail({ layers: [{ imageUrl: IMG, start: Number.POSITIVE_INFINITY }] }).code).toBe("time_out_of_range")
352
- })
353
- it("a no-preset partial box is incomplete_box; no preset and no box is fine before AND after expansion (D8)", () => {
354
- const partial = fail({ layers: [{ start: 0, width: 40 }] })
355
- expect(partial.code).toBe("incomplete_box")
356
- expect(formatVideoOverlayError(partial)).toBe("layers[0]: anchor and width are required without a preset")
357
- expect(validateVideoOverlayRequest({ layers: [{ imageUrl: IMG, start: 0 }] })).toEqual({ ok: true })
358
- expect(validateVideoOverlayRequest({ layers: expandVideoOverlayPresets([{ imageUrl: IMG, start: 0 }]) })).toEqual({ ok: true })
359
- expect(validateVideoOverlayRequest({ layers: [{ imageUrl: IMG, start: 0, preset: "card", width: 50 }] })).toEqual({ ok: true })
360
- })
361
- it("a present box / look field outside VIDEO_OVERLAY_BOUNDS or its enum / type is field_out_of_bounds (spec §4.4, the DAG path's only check)", () => {
362
- const code = (extra: Record<string, unknown>) => {
363
- const r = validateVideoOverlayRequest({ layers: [ok, { imageUrl: IMG, start: 0, anchor: "center", width: 30, ...extra } as VideoOverlayLayerInput] })
364
- return r.ok ? "ok" : ([r.code, r.layer, r.params.field] as const)
365
- }
366
- expect(code({ width: 500, height: 100, fit: "cover" })).toEqual(["field_out_of_bounds", 1, "width"])
367
- expect(code({ width: 101 })).toEqual(["field_out_of_bounds", 1, "width"])
368
- expect(code({ width: "50" })).toEqual(["field_out_of_bounds", 1, "width"])
369
- expect(code({ x: -101 })).toEqual(["field_out_of_bounds", 1, "x"])
370
- expect(code({ height: 0 })).toEqual(["field_out_of_bounds", 1, "height"])
371
- expect(code({ y: Number.NaN })).toEqual(["field_out_of_bounds", 1, "y"])
372
- expect(code({ opacity: 5 })).toEqual(["field_out_of_bounds", 1, "opacity"])
373
- expect(code({ opacity: 9 })).toEqual(["field_out_of_bounds", 1, "opacity"])
374
- expect(code({ zIndex: 2.5 })).toEqual(["field_out_of_bounds", 1, "zIndex"])
375
- expect(code({ zIndex: -3 })).toEqual(["field_out_of_bounds", 1, "zIndex"])
376
- expect(code({ anchor: 7 })).toEqual(["field_out_of_bounds", 1, "anchor"])
377
- expect(code({ anchor: "middle" })).toEqual(["field_out_of_bounds", 1, "anchor"])
378
- expect(code({ fit: "stretch" })).toEqual(["field_out_of_bounds", 1, "fit"])
379
- expect(code({ animate: "yes" })).toEqual(["field_out_of_bounds", 1, "animate"])
380
- // null reads as absent; the bounds themselves are inclusive
381
- expect(code({ height: null, zIndex: null, opacity: null })).toBe("ok")
382
- expect(code({ x: -100, y: 100, width: 100, height: 1, opacity: 0, zIndex: 100, fit: "cover", animate: false })).toBe("ok")
383
- })
384
- it("field_out_of_bounds carries the slot, a symbolic range, and renders one English line", () => {
385
- const r = fail({ layers: [{ imageUrl: IMG, start: 0, anchor: "center", width: 30, zIndex: 2.5, slot: 4 }] })
386
- expect(r).toEqual({ ok: false, code: "field_out_of_bounds", layer: 0, slot: 4, params: { field: "zIndex", allowed: "integers 0..100" } })
387
- expect(formatVideoOverlayError(r)).toBe("Layer 4: zIndex is out of range (allowed: integers 0..100)")
388
- expect(fail({ layers: [{ imageUrl: IMG, start: 0, anchor: "center", width: 30, fit: "stretch" } as unknown as VideoOverlayLayerInput] }).params).toEqual({ field: "fit", allowed: "contain, cover" })
389
- })
390
- it("the bounds verdict is the same before and after the expansion (§3.5 order-independence)", () => {
391
- const bad = [{ imageUrl: IMG, start: 0, preset: "card" as const, width: 500 }]
392
- expect(fail({ layers: bad }).code).toBe("field_out_of_bounds")
393
- expect(fail({ layers: expandVideoOverlayPresets(bad) }).code).toBe("field_out_of_bounds")
394
- const good = [{ imageUrl: IMG, start: 0, preset: "card" as const }]
395
- expect(validateVideoOverlayRequest({ layers: good })).toEqual({ ok: true })
396
- expect(validateVideoOverlayRequest({ layers: expandVideoOverlayPresets(good) })).toEqual({ ok: true })
397
- const noBoxBadLook = [{ imageUrl: IMG, start: 0, opacity: 5 }]
398
- expect(fail({ layers: noBoxBadLook }).code).toBe("field_out_of_bounds")
399
- expect(fail({ layers: expandVideoOverlayPresets(noBoxBadLook) }).code).toBe("field_out_of_bounds")
400
- })
401
- it("an assembled JSON-written layer with an unbounded box is refused before it reaches the geometry (the DAG path)", () => {
402
- const req = assembleVideoOverlayRequest({
403
- videoUrl: "v",
404
- data: { layers: [{ anchor: "center", width: 100000, height: 100, fit: "cover", start: 0 } as VideoOverlayLayerInput] },
405
- wiredImageUrls: [IMG],
406
- })
407
- expect(validateVideoOverlayRequest(req)).toMatchObject({ ok: false, code: "field_out_of_bounds", slot: 1, params: { field: "width" } })
408
- const anchor = assembleVideoOverlayRequest({ videoUrl: "v", data: { layers: [{ anchor: 7, width: 30, start: 0 } as unknown as VideoOverlayLayerInput] }, wiredImageUrls: [IMG] })
409
- expect(validateVideoOverlayRequest(anchor)).toMatchObject({ ok: false, code: "field_out_of_bounds", params: { field: "anchor" } })
410
- })
411
- it("every layer needs an image", () => {
412
- expect(fail({ layers: [{ start: 0 }] }).code).toBe("layer_without_image")
413
- })
414
- it("baseFit / backgroundColor only with an outputAspect", () => {
415
- expect(fail({ layers: [ok], baseFit: "contain" }).code).toBe("fit_without_aspect")
416
- expect(validateVideoOverlayRequest({ layers: [ok], outputAspect: "9:16", baseFit: "contain", backgroundColor: "#ff0000" })).toEqual({ ok: true })
417
- })
418
- })
419
-
420
254
  describe("assembleVideoOverlayRequest (the ONE assembly both engines call)", () => {
421
255
  it("a wired slot with no settings runs as the default layer, slot stamped (D2)", () => {
422
256
  const r = assembleVideoOverlayRequest({ videoUrl: "v", data: { layers: [] }, wiredImageUrls: ["https://x/1.png"] })
@@ -570,3 +404,255 @@ describe("VIDEO_OVERLAY_MAX_COMPOSITION_KEY_LENGTH — the bound the REST route
570
404
  expect(key.length).toBeLessThan(VIDEO_OVERLAY_MAX_COMPOSITION_KEY_LENGTH)
571
405
  })
572
406
  })
407
+
408
+ describe("video layers — a layer carries an image or a video, never both", () => {
409
+ const I = "https://cdn.example/i.png"
410
+ const V = "https://cdn.example/v.mp4"
411
+ const B = "https://cdn.example/base.mp4"
412
+ const validate = (layers: VideoOverlayLayerInput[]) => validateVideoOverlayRequest({ layers })
413
+ const codeOf = (layers: VideoOverlayLayerInput[]) => {
414
+ const r = validate(layers)
415
+ return r.ok ? "ok" : r.code
416
+ }
417
+ const videoLayers = (n: number): VideoOverlayLayerInput[] => Array.from({ length: n }, (_, i) => ({ videoUrl: `https://cdn.example/v${i}.mp4`, start: 0 }))
418
+ const threeVideoLayers = videoLayers(3)
419
+
420
+ it("the contract's bounds, measured caps and codes", () => {
421
+ expect(VIDEO_OVERLAY_VOLUME_BOUNDS).toEqual([0, 1])
422
+ expect(VIDEO_OVERLAY_MAX_VIDEO_LAYERS).toBe(2)
423
+ expect(VIDEO_OVERLAY_VIDEO_MAX_BASE_SEC).toBe(60)
424
+ expect(VIDEO_OVERLAY_MAX_LAYER_VIDEO_BYTES).toBe(200 * 1024 * 1024)
425
+ expect(VIDEO_OVERLAY_ERROR_CODES).toEqual(expect.arrayContaining(["layer_two_sources", "too_many_video_layers", "sound_without_video"]))
426
+ expect(VIDEO_OVERLAY_WARNING_CODES).toContain("layer_no_audio")
427
+ })
428
+
429
+ it("a video layer defaults animate off; an image layer stays on", () => {
430
+ expect(expandVideoOverlayLayer({ videoUrl: V, start: 0, preset: "full-frame" }).animate).toBe(false)
431
+ expect(expandVideoOverlayLayer({ imageUrl: I, start: 0, preset: "full-frame" }).animate).toBe(true)
432
+ expect(expandVideoOverlayLayer({ videoUrl: V, start: 0, preset: "full-frame", animate: true }).animate).toBe(true)
433
+ })
434
+ it("a video layer with no box and no preset is the default corner badge with animate off — and stays put on a second pass", () => {
435
+ const l = expandVideoOverlayLayer({ videoUrl: V, start: 0 })
436
+ expect(l).toEqual({ ...DEFAULT_VIDEO_OVERLAY_LAYER, videoUrl: V, animate: false })
437
+ expect(expandVideoOverlayLayer(l)).toBe(l)
438
+ expect(expandVideoOverlayLayer({ videoUrl: V, start: 0, animate: true }).animate).toBe(true)
439
+ expect(expandVideoOverlayLayer({ videoUrl: V, start: 0, anchor: "top", width: 50 }).animate).toBe(false)
440
+ expect(expandVideoOverlayLayer({ imageUrl: I, start: 0 }).animate).toBe(true)
441
+ })
442
+
443
+ // A preset-tagged layer with no `start` (written as JSON): the default layer
444
+ // starts at 0, and a VIDEO layer tagged with a preset now does too. An image
445
+ // layer is left as it was — its request is refused today (time_out_of_range),
446
+ // and filling it would turn an existing image-only refusal into a run.
447
+ it("a video layer with a preset tag and no start starts at 0; an image layer stays as it was (refused)", () => {
448
+ const video = expandVideoOverlayLayer({ videoUrl: V, preset: "card" })
449
+ expect(video).toMatchObject({ videoUrl: V, start: 0, preset: "card", animate: false, anchor: "center", width: 78 })
450
+ expect(expandVideoOverlayLayer(video)).toBe(video)
451
+ expect(codeOf([video])).toBe("ok")
452
+ const image = expandVideoOverlayLayer({ imageUrl: I, preset: "card" })
453
+ expect(image).not.toHaveProperty("start")
454
+ expect(codeOf([image])).toBe("time_out_of_range")
455
+ // An explicit start is kept; a wired video slot tagged with a preset runs from 0.
456
+ expect(expandVideoOverlayLayer({ videoUrl: V, preset: "full-frame", start: 3 }).start).toBe(3)
457
+ const wired = assembleVideoOverlayRequest({ videoUrl: B, data: { layers: [{ preset: "corner-badge", corner: "top-left" }] }, wiredImageUrls: [V], wiredVideoSlots: new Set([1]) })
458
+ expect(wired.layers[0]).toMatchObject({ start: 0, videoUrl: V, slot: 1 })
459
+ expect(validateVideoOverlayRequest(wired)).toEqual({ ok: true })
460
+ })
461
+
462
+ it("refuses a layer with both sources", () => {
463
+ expect(codeOf([{ imageUrl: I, videoUrl: V, start: 0 }])).toBe("layer_two_sources")
464
+ expect(formatVideoOverlayError(validate([{ imageUrl: I, videoUrl: V, start: 0, slot: 2 }]) as VideoOverlayIssue)).toBe(
465
+ "Layer 2: has both an image and a video — keep one (imageUrl or videoUrl)",
466
+ )
467
+ })
468
+ it("a video-only layer is a complete layer; a layer with neither source names both", () => {
469
+ expect(codeOf([{ videoUrl: V, start: 0 }])).toBe("ok")
470
+ expect(codeOf([{ imageUrl: "", videoUrl: V, start: 0 }])).toBe("ok")
471
+ expect(formatVideoOverlayError(validate([{ start: 0, slot: 3 }]) as VideoOverlayIssue)).toBe(
472
+ "Layer 3: no image or video — connect one to the layer's handle or set imageUrl or videoUrl",
473
+ )
474
+ })
475
+
476
+ it("refuses a third video layer", () => {
477
+ expect(validate(threeVideoLayers)).toMatchObject({ code: "too_many_video_layers", params: { max: 2, count: 3 } })
478
+ expect(formatVideoOverlayError(validate(threeVideoLayers) as VideoOverlayIssue)).toBe("At most 2 video layers (got 3)")
479
+ expect(codeOf([...videoLayers(2), { imageUrl: I, start: 0 }, { imageUrl: I, start: 0 }])).toBe("ok")
480
+ })
481
+
482
+ it("refuses sound on an image layer", () => {
483
+ expect(codeOf([{ imageUrl: I, start: 0, sound: { volume: 1 } }])).toBe("sound_without_video")
484
+ expect(formatVideoOverlayError(validate([{ imageUrl: I, start: 0, sound: { volume: 1 } }]) as VideoOverlayIssue)).toBe(
485
+ "layers[0]: sound is only for a video layer — remove it or set videoUrl",
486
+ )
487
+ expect(codeOf([{ videoUrl: V, start: 0, sound: { volume: 0.8 } }])).toBe("ok")
488
+ expect(codeOf([{ imageUrl: I, start: 0, sound: null }])).toBe("ok")
489
+ })
490
+
491
+ it("bounds the volume", () => {
492
+ expect(codeOf([{ videoUrl: V, start: 0, sound: { volume: 1.5 } }])).toBe("field_out_of_bounds")
493
+ expect(validate([{ videoUrl: V, start: 0, sound: { volume: -0.1 } }])).toMatchObject({ params: { field: "sound.volume", allowed: "0..1" } })
494
+ for (const sound of [{ volume: Number.NaN }, { volume: "1" }, {}, "loud", 1]) {
495
+ expect(codeOf([{ videoUrl: V, start: 0, sound } as unknown as VideoOverlayLayerInput])).toBe("field_out_of_bounds")
496
+ }
497
+ expect(codeOf([{ videoUrl: V, start: 0, sound: { volume: 0 } }, { videoUrl: V, start: 0, sound: { volume: 1 } }])).toBe("ok")
498
+ })
499
+ it("a bad volume does not make the layer undrawable (the stage still places it)", () => {
500
+ expect(hasDrawableVideoOverlayBox({ ...expandVideoOverlayLayer({ videoUrl: V, start: 0 }), sound: { volume: 5 } })).toBe(true)
501
+ })
502
+
503
+ it("a wired video slot becomes videoUrl", () => {
504
+ const r = assembleVideoOverlayRequest({ videoUrl: B, data: {}, wiredImageUrls: [V], wiredVideoSlots: new Set([1]) })
505
+ expect(r.layers[0]).toMatchObject({ videoUrl: V, slot: 1, animate: false })
506
+ expect(r.layers[0].imageUrl).toBeUndefined()
507
+ })
508
+ it("a wire replaces whichever source the slot stored; an unwired slot keeps its own", () => {
509
+ const stored: VideoOverlayLayerInput[] = [{ videoUrl: "https://x/stored.mp4", start: 1 }, { imageUrl: "https://x/stored.png", start: 2 }, { videoUrl: V, start: 3 }]
510
+ const r = assembleVideoOverlayRequest({ videoUrl: B, data: { layers: stored }, wiredImageUrls: [I, V], wiredVideoSlots: new Set([2]) })
511
+ expect(r.layers.map((l) => [l.slot, l.imageUrl, l.videoUrl])).toEqual([[1, I, undefined], [2, undefined, V], [3, undefined, V]])
512
+ expect(r.layers.map((l) => l.start)).toEqual([1, 2, 3])
513
+ expect(validateVideoOverlayRequest(r)).toEqual({ ok: true })
514
+ })
515
+ it("an unwired slot stored with both sources reaches the validator as it is", () => {
516
+ const r = assembleVideoOverlayRequest({ videoUrl: B, data: { layers: [{ imageUrl: I, videoUrl: V, start: 0 }] }, wiredImageUrls: [] })
517
+ expect(validateVideoOverlayRequest(r)).toMatchObject({ ok: false, code: "layer_two_sources", slot: 1 })
518
+ })
519
+ it("an empty-string source is dropped, so the layer runs as the kind it has on both engines (the route refuses an empty URL)", () => {
520
+ const r = assembleVideoOverlayRequest({
521
+ videoUrl: B,
522
+ data: { layers: [{ imageUrl: I, videoUrl: "", start: 0 }, { imageUrl: "", videoUrl: V, start: 1 }] },
523
+ wiredImageUrls: [],
524
+ planLayers: [{ imageUrl: I, videoUrl: "", start: 2 }],
525
+ })
526
+ expect(r.layers.map((l) => [Object.hasOwn(l, "imageUrl"), Object.hasOwn(l, "videoUrl")])).toEqual([[true, false], [true, false], [false, true]])
527
+ expect(r.layers.map((l) => l.animate)).toEqual([true, true, false])
528
+ expect(validateVideoOverlayRequest(r)).toEqual({ ok: true })
529
+ // Both empty is no source at all: the slot is dropped, as before.
530
+ expect(assembleVideoOverlayRequest({ videoUrl: B, data: { layers: [{ imageUrl: "", videoUrl: "", start: 0 }] }, wiredImageUrls: [] }).layers).toEqual([])
531
+ })
532
+ it("an image-only assembly is unchanged without wiredVideoSlots", () => {
533
+ const r = assembleVideoOverlayRequest({ videoUrl: B, data: { layers: [{ imageUrl: "https://x/own.png", start: 2 }] }, wiredImageUrls: [I] })
534
+ expect(r.layers).toEqual([{ ...DEFAULT_VIDEO_OVERLAY_LAYER, imageUrl: I, start: 2, slot: 1 }])
535
+ })
536
+
537
+ // A WIRED slot's kind is its wire's, read at the run: a `sound` left on the
538
+ // slot from when its wire was a video is skipped when the wire is an image
539
+ // (the run goes ahead), and its fade default follows the image. A layer that
540
+ // carries its OWN image (the API, MCP, an unwired slot, a plan) is refused.
541
+ it("a wired image slot drops a stored sound and runs, its fade default on; wired to a video it keeps the sound, fade off", () => {
542
+ const layers: VideoOverlayLayerInput[] = [{ start: 1, sound: { volume: 0.4 } }]
543
+ const image = assembleVideoOverlayRequest({ videoUrl: B, data: { layers }, wiredImageUrls: [I] })
544
+ expect(image.layers).toEqual([{ ...DEFAULT_VIDEO_OVERLAY_LAYER, imageUrl: I, start: 1, slot: 1 }])
545
+ expect(validateVideoOverlayRequest(image)).toEqual({ ok: true })
546
+ const video = assembleVideoOverlayRequest({ videoUrl: B, data: { layers }, wiredImageUrls: [V], wiredVideoSlots: new Set([1]) })
547
+ expect(video.layers).toEqual([{ ...DEFAULT_VIDEO_OVERLAY_LAYER, animate: false, videoUrl: V, start: 1, sound: { volume: 0.4 }, slot: 1 }])
548
+ // Even a volume the validator would refuse: the sound is skipped, not judged.
549
+ const bad = assembleVideoOverlayRequest({ videoUrl: B, data: { layers: [{ start: 0, sound: { volume: 5 } }] }, wiredImageUrls: [I] })
550
+ expect(validateVideoOverlayRequest(bad)).toEqual({ ok: true })
551
+ })
552
+ it("a fade the wired slot was written with stays as written, whichever kind its wire is", () => {
553
+ const layers: VideoOverlayLayerInput[] = [{ start: 0, animate: true }, { start: 0, animate: false }]
554
+ const r = assembleVideoOverlayRequest({ videoUrl: B, data: { layers }, wiredImageUrls: [V, I], wiredVideoSlots: new Set([1]) })
555
+ expect(r.layers.map((l) => [l.slot, l.animate])).toEqual([[1, true], [2, false]])
556
+ })
557
+ it("sound on a layer with its own image is still refused: an unwired slot and a plan layer", () => {
558
+ const own = assembleVideoOverlayRequest({ videoUrl: B, data: { layers: [null, { imageUrl: I, start: 0, sound: { volume: 1 } }] }, wiredImageUrls: [] })
559
+ expect(validateVideoOverlayRequest(own)).toMatchObject({ ok: false, code: "sound_without_video", slot: 2 })
560
+ const plan = assembleVideoOverlayRequest({ videoUrl: B, data: {}, wiredImageUrls: [], planLayers: [{ imageUrl: I, start: 0, sound: { volume: 1 } }] })
561
+ expect(validateVideoOverlayRequest(plan)).toMatchObject({ ok: false, code: "sound_without_video", planLayer: 1 })
562
+ })
563
+
564
+ it("wiring clears both stored sources", () => {
565
+ expect(clearWiredVideoOverlayImageUrls([{ videoUrl: V, start: 0 }], new Set([1]))[0]).not.toHaveProperty("videoUrl")
566
+ expect(clearWiredVideoOverlayImageUrls([{ imageUrl: I, videoUrl: V, start: 0 }], new Set([1]))[0]).toEqual({ start: 0 })
567
+ const untouched = [{ start: 0 }]
568
+ expect(clearWiredVideoOverlayImageUrls(untouched, new Set([1]))).toBe(untouched)
569
+ const [out] = normalizeVideoOverlayNodes(
570
+ [{ id: "vo", type: "video-overlay", data: { layers: [{ videoUrl: V, start: 0 }] } }],
571
+ [{ target: "vo", targetHandle: "overlay" }],
572
+ )
573
+ expect((out!.data as { layers: VideoOverlayLayerInput[] }).layers[0]).not.toHaveProperty("videoUrl")
574
+ })
575
+
576
+ it("slot sources read a stored video", () => {
577
+ expect(videoOverlaySlotSources([{ videoUrl: V, start: 0 }], [])).toEqual([V])
578
+ expect(videoOverlaySlotSources([{ videoUrl: V, start: 0 }], [I])).toEqual([I])
579
+ })
580
+
581
+ it("kinds a wired source by producer, else by extension", () => {
582
+ expect(videoOverlayWiredLayerKind({ type: "generate-video" }, "https://x/a")).toBe("video")
583
+ expect(videoOverlayWiredLayerKind({ type: "generate-image" }, "https://x/a.mp4")).toBe("image")
584
+ const dynamic = [...DYNAMIC_PRODUCER_TYPES][0]
585
+ expect(videoOverlayWiredLayerKind({ type: dynamic }, "https://x/a.mp4?sig=1")).toBe("video")
586
+ expect(videoOverlayWiredLayerKind({ type: dynamic }, "https://x/a.png")).toBe("image")
587
+ })
588
+ it("the extension test reads the path only, case-insensitively, and defaults to image", () => {
589
+ for (const url of ["https://x/a.MOV", "https://x/a.webm#t=2", "https://x/a.m4v", "/uploads/a.mp4?x=1"]) {
590
+ expect(videoOverlayWiredLayerKind({}, url)).toBe("video")
591
+ }
592
+ for (const url of ["https://x/a.png?f=.mp4", "https://x/a.mp4.png", "https://x/mp4", "https://x/a.avi", "", "not a url"]) {
593
+ expect(videoOverlayWiredLayerKind({}, url)).toBe("image")
594
+ }
595
+ })
596
+
597
+ it("videoOverlayHasVideoLayer: any layer with a video", () => {
598
+ expect(videoOverlayHasVideoLayer([{ imageUrl: I, start: 0 }, null, { videoUrl: V, start: 0 }])).toBe(true)
599
+ expect(videoOverlayHasVideoLayer([{ imageUrl: I, start: 0 }, { videoUrl: "", start: 0 }, null])).toBe(false)
600
+ expect(videoOverlayHasVideoLayer([])).toBe(false)
601
+ expect(videoOverlayHasVideoLayer(null)).toBe(false)
602
+ expect(videoOverlayHasVideoLayer(["https://x/a.mp4"] as unknown as VideoOverlayLayerInput[])).toBe(false)
603
+ })
604
+
605
+ it("the wire type takes exactly one source", () => {
606
+ const image: VideoOverlayLayerSpec = { imageUrl: I, start: 0 }
607
+ const video: VideoOverlayLayerSpec = { videoUrl: V, start: 0, sound: { volume: 0.5 } }
608
+ // @ts-expect-error — both sources
609
+ const both: VideoOverlayLayerSpec = { imageUrl: I, videoUrl: V, start: 0 }
610
+ // @ts-expect-error — neither source
611
+ const neither: VideoOverlayLayerSpec = { start: 0 }
612
+ expect([image, video, both, neither]).toHaveLength(4)
613
+ })
614
+
615
+ // Captured by running videoOverlayCompositionKey on IMAGE_ONLY_FIXTURE before video layers existed.
616
+ const IMAGE_ONLY_FIXTURE = {
617
+ baseUrl: "https://x/base.mp4",
618
+ sources: ["https://x/wired.png", undefined, "https://x/own.png"],
619
+ data: {
620
+ layers: [
621
+ { start: 1, end: 4, preset: "card" as const },
622
+ null,
623
+ { imageUrl: "https://x/own.png", start: 0, anchor: "top-left" as const, x: 2, y: 3, width: 30, fit: "cover" as const, opacity: 0.5, animate: true, zIndex: 4 },
624
+ ],
625
+ outputAspect: "9:16",
626
+ baseFit: "contain",
627
+ backgroundColor: "#101010",
628
+ },
629
+ }
630
+ const KEY_CAPTURED_BEFORE_THIS_CHANGE = String.raw`["https://x/base.mp4",["https://x/wired.png",null,"https://x/own.png"],[{"end":4,"preset":"card","start":1},null,{"anchor":"top-left","animate":true,"fit":"cover","imageUrl":"https://x/own.png","opacity":0.5,"start":0,"width":30,"x":2,"y":3,"zIndex":4}],"9:16","contain","#101010"]`
631
+
632
+ it("an image-only composition keeps today's key", () => {
633
+ expect(videoOverlayCompositionKey(IMAGE_ONLY_FIXTURE)).toBe(KEY_CAPTURED_BEFORE_THIS_CHANGE)
634
+ })
635
+ it("a layer's video and its sound change the key", () => {
636
+ const withVideo = (layer: VideoOverlayLayerInput) => {
637
+ const layers = [layer]
638
+ return videoOverlayCompositionKey({ baseUrl: B, sources: videoOverlaySlotSources(layers, []), data: { layers } })
639
+ }
640
+ const k = withVideo({ videoUrl: V, start: 0 })
641
+ expect(withVideo({ videoUrl: "https://x/other.mp4", start: 0 })).not.toBe(k)
642
+ expect(withVideo({ videoUrl: V, start: 0, sound: { volume: 1 } })).not.toBe(k)
643
+ expect(withVideo({ videoUrl: V, start: 0, sound: { volume: 0.5 } })).not.toBe(withVideo({ videoUrl: V, start: 0, sound: { volume: 1 } }))
644
+ })
645
+ it("a wired slot's kind changes the key, even when its URL does not (videoSlots: 1-based, in any order)", () => {
646
+ const wired = { baseUrl: B, sources: ["https://x/signed/clip?sig=1", "https://x/b.png"], data: { layers: [] } }
647
+ const asImages = videoOverlayCompositionKey(wired)
648
+ const slot1Video = videoOverlayCompositionKey({ ...wired, videoSlots: [1] })
649
+ expect(slot1Video).not.toBe(asImages)
650
+ expect(videoOverlayCompositionKey({ ...wired, videoSlots: [2] })).not.toBe(slot1Video)
651
+ expect(videoOverlayCompositionKey({ ...wired, videoSlots: new Set([2, 1]) })).toBe(videoOverlayCompositionKey({ ...wired, videoSlots: [1, 2] }))
652
+ })
653
+ it("no wired video slot keeps the image-only key, whether absent, null or empty", () => {
654
+ expect(videoOverlayCompositionKey({ ...IMAGE_ONLY_FIXTURE, videoSlots: [] })).toBe(KEY_CAPTURED_BEFORE_THIS_CHANGE)
655
+ expect(videoOverlayCompositionKey({ ...IMAGE_ONLY_FIXTURE, videoSlots: new Set() })).toBe(KEY_CAPTURED_BEFORE_THIS_CHANGE)
656
+ expect(videoOverlayCompositionKey({ ...IMAGE_ONLY_FIXTURE, videoSlots: null })).toBe(KEY_CAPTURED_BEFORE_THIS_CHANGE)
657
+ })
658
+ })
@@ -23,7 +23,8 @@ describe("VIDEO_REF_LIMITS_BY_PROVIDER", () => {
23
23
  expect(VIDEO_REF_LIMITS_BY_PROVIDER["kling-turbo"]).toBeUndefined()
24
24
  // Not verified reference-forwarders (2026-06-28 audit) → deliberately absent.
25
25
  expect(VIDEO_REF_LIMITS_BY_PROVIDER["wan-i2v"]).toBeUndefined()
26
- expect(VIDEO_REF_LIMITS_BY_PROVIDER["grok-imagine-video-1.5"]).toBeUndefined()
26
+ // Its Image References are in-between frames (KIE `keyframes`, max 4).
27
+ expect(VIDEO_REF_LIMITS_BY_PROVIDER["grok-imagine-video-1.5"]).toEqual({ images: 4 })
27
28
  })
28
29
  })
29
30
 
@@ -10,6 +10,7 @@ import {
10
10
  resolveVideoProviderForMode,
11
11
  videoProviderRequiresImage,
12
12
  videoProviderRunsFromReferences,
13
+ videoProviderRefsReplaceStartFrame,
13
14
  } from "../model-constants.js"
14
15
 
15
16
  /**
@@ -34,6 +35,9 @@ const BLOCKED_WITHOUT_A_FRAME: Readonly<Record<string, string>> = {
34
35
  // No working dispatch at all (VIDEO_PROVIDERS_WITHOUT_DISPATCH): every run
35
36
  // fails at the router, so advertising a references-only run would be a lie.
36
37
  "kling-3-omni": "no dispatch path",
38
+ // Its Image References are in-between FRAMES (KIE `keyframes`) that need the
39
+ // start frame: the endpoint takes no run without one (decided 2026-11-11).
40
+ "grok-imagine-video-1.5": "in-between frames need the start frame",
37
41
  }
38
42
 
39
43
  const T2V = "text-to-video" as const
@@ -64,9 +68,9 @@ describe("reference-to-video capability (catalog)", () => {
64
68
  }
65
69
  })
66
70
 
67
- it("the blocked list is exactly the undispatchable ref-capable models", () => {
71
+ it("the blocked list is exactly the undispatchable ref-capable models and those whose references cannot replace the start frame", () => {
68
72
  expect(Object.keys(BLOCKED_WITHOUT_A_FRAME).sort()).toEqual(
69
- refCapable.filter((p) => VIDEO_PROVIDERS_WITHOUT_DISPATCH.has(p)).sort(),
73
+ refCapable.filter((p) => VIDEO_PROVIDERS_WITHOUT_DISPATCH.has(p) || !videoProviderRefsReplaceStartFrame(p)).sort(),
70
74
  )
71
75
  })
72
76
  })