@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.
- package/dist/{chunk-IVXSNW2B.cjs → chunk-2D5LQFV4.cjs} +18 -332
- package/dist/chunk-2D5LQFV4.cjs.map +1 -0
- package/dist/{chunk-XUJC6GHE.cjs → chunk-2HZGDZZN.cjs} +6 -6
- package/dist/{chunk-XUJC6GHE.cjs.map → chunk-2HZGDZZN.cjs.map} +1 -1
- package/dist/{chunk-43TGSZRJ.js → chunk-2QKF7M2Z.js} +3 -3
- package/dist/{chunk-43TGSZRJ.js.map → chunk-2QKF7M2Z.js.map} +1 -1
- package/dist/{chunk-7ARKVJTN.cjs → chunk-2W745U4A.cjs} +228 -355
- package/dist/chunk-2W745U4A.cjs.map +1 -0
- package/dist/{chunk-673E4KYC.js → chunk-3OYO3XCC.js} +70 -6
- package/dist/chunk-3OYO3XCC.js.map +1 -0
- package/dist/{chunk-FMXFHJWX.cjs → chunk-4ZEFP2FQ.cjs} +4 -4
- package/dist/{chunk-FMXFHJWX.cjs.map → chunk-4ZEFP2FQ.cjs.map} +1 -1
- package/dist/{chunk-A3FHTSLB.js → chunk-5YYN5X57.js} +302 -27
- package/dist/chunk-5YYN5X57.js.map +1 -0
- package/dist/{chunk-4KYLNTR7.cjs → chunk-6CSXMWL4.cjs} +4 -4
- package/dist/{chunk-4KYLNTR7.cjs.map → chunk-6CSXMWL4.cjs.map} +1 -1
- package/dist/{chunk-M3SXUUWC.cjs → chunk-6FQBKI2A.cjs} +4 -11
- package/dist/chunk-6FQBKI2A.cjs.map +1 -0
- package/dist/{chunk-G4XWVWRI.js → chunk-6G7NN4S4.js} +5 -4
- package/dist/chunk-6G7NN4S4.js.map +1 -0
- package/dist/{chunk-ZFJN23V4.cjs → chunk-A2PX5IRC.cjs} +4 -4
- package/dist/{chunk-ZFJN23V4.cjs.map → chunk-A2PX5IRC.cjs.map} +1 -1
- package/dist/{chunk-JHTT2V4A.cjs → chunk-AFYTX4AI.cjs} +52 -43
- package/dist/chunk-AFYTX4AI.cjs.map +1 -0
- package/dist/chunk-ALRXY4QH.cjs +13 -0
- package/dist/chunk-ALRXY4QH.cjs.map +1 -0
- package/dist/chunk-AOJ6B7K4.cjs +351 -0
- package/dist/chunk-AOJ6B7K4.cjs.map +1 -0
- package/dist/{chunk-ZDBPQBAA.js → chunk-C7POAYFE.js} +3 -3
- package/dist/{chunk-ZDBPQBAA.js.map → chunk-C7POAYFE.js.map} +1 -1
- package/dist/{chunk-B6BG3LV2.js → chunk-CC4V2B7S.js} +3 -3
- package/dist/{chunk-B6BG3LV2.js.map → chunk-CC4V2B7S.js.map} +1 -1
- package/dist/{chunk-XZKFZMRT.cjs → chunk-CIPPPT7E.cjs} +6 -6
- package/dist/{chunk-XZKFZMRT.cjs.map → chunk-CIPPPT7E.cjs.map} +1 -1
- package/dist/{chunk-6XVHYD5R.js → chunk-CLAKSLXF.js} +4 -9
- package/dist/chunk-CLAKSLXF.js.map +1 -0
- package/dist/chunk-CTANEPMY.js +61 -0
- package/dist/chunk-CTANEPMY.js.map +1 -0
- package/dist/{chunk-WGKAOUEQ.cjs → chunk-D34K455O.cjs} +3 -2
- package/dist/chunk-D34K455O.cjs.map +1 -0
- package/dist/chunk-E2HZTGYX.js +331 -0
- package/dist/chunk-E2HZTGYX.js.map +1 -0
- package/dist/{chunk-RQ4F3AJH.cjs → chunk-G3KVK7OU.cjs} +21 -21
- package/dist/{chunk-RQ4F3AJH.cjs.map → chunk-G3KVK7OU.cjs.map} +1 -1
- package/dist/chunk-G4U3HW6W.js +453 -0
- package/dist/chunk-G4U3HW6W.js.map +1 -0
- package/dist/{chunk-IRQ3SPX7.js → chunk-GSFB537T.js} +3 -3
- package/dist/{chunk-IRQ3SPX7.js.map → chunk-GSFB537T.js.map} +1 -1
- package/dist/chunk-HRY7KGAE.cjs +506 -0
- package/dist/chunk-HRY7KGAE.cjs.map +1 -0
- package/dist/{chunk-VOWJCUMR.js → chunk-I2RQB7VG.js} +3 -3
- package/dist/{chunk-VOWJCUMR.js.map → chunk-I2RQB7VG.js.map} +1 -1
- package/dist/chunk-IDTKF5EX.cjs +48 -0
- package/dist/chunk-IDTKF5EX.cjs.map +1 -0
- package/dist/{chunk-5XRRENHD.cjs → chunk-IWWVPR3W.cjs} +88 -11
- package/dist/chunk-IWWVPR3W.cjs.map +1 -0
- package/dist/{chunk-SCMTN57Y.js → chunk-JJNNM23P.js} +3 -3
- package/dist/{chunk-SCMTN57Y.js.map → chunk-JJNNM23P.js.map} +1 -1
- package/dist/{chunk-ZZGQRRN7.js → chunk-JZGZ26YB.js} +6 -306
- package/dist/chunk-JZGZ26YB.js.map +1 -0
- package/dist/{chunk-XROE3CAS.cjs → chunk-KHH54GRP.cjs} +120 -79
- package/dist/chunk-KHH54GRP.cjs.map +1 -0
- package/dist/{chunk-NJVOJXBS.cjs → chunk-KJSRPHJ2.cjs} +48 -47
- package/dist/chunk-KJSRPHJ2.cjs.map +1 -0
- package/dist/{chunk-FVVD6XY2.js → chunk-KL6GAYTT.js} +13 -4
- package/dist/chunk-KL6GAYTT.js.map +1 -0
- package/dist/{chunk-AFQFGZN7.cjs → chunk-KYMHFVAZ.cjs} +8 -6
- package/dist/chunk-KYMHFVAZ.cjs.map +1 -0
- package/dist/{chunk-F5YEMSNK.cjs → chunk-MYJQELFN.cjs} +320 -26
- package/dist/chunk-MYJQELFN.cjs.map +1 -0
- package/dist/chunk-N5HH46JF.cjs +68 -0
- package/dist/chunk-N5HH46JF.cjs.map +1 -0
- package/dist/{chunk-MQZRQ5LM.cjs → chunk-N7OUQK7E.cjs} +8 -8
- package/dist/{chunk-MQZRQ5LM.cjs.map → chunk-N7OUQK7E.cjs.map} +1 -1
- package/dist/{chunk-UARGJ5IZ.js → chunk-NGKKNSK6.js} +30 -7
- package/dist/chunk-NGKKNSK6.js.map +1 -0
- package/dist/{chunk-SWVGHAYO.js → chunk-O7RZRUMZ.js} +110 -74
- package/dist/chunk-O7RZRUMZ.js.map +1 -0
- package/dist/{chunk-C77F4ZTL.js → chunk-PTD6EDUU.js} +3 -3
- package/dist/{chunk-C77F4ZTL.js.map → chunk-PTD6EDUU.js.map} +1 -1
- package/dist/{chunk-ZNM2LW3D.cjs → chunk-QWYFHQYK.cjs} +78 -53
- package/dist/chunk-QWYFHQYK.cjs.map +1 -0
- package/dist/{chunk-VB2ARGQ6.js → chunk-RGNHHIMN.js} +3 -3
- package/dist/chunk-RGNHHIMN.js.map +1 -0
- package/dist/{chunk-MOMFX32D.js → chunk-S24ZBUB4.js} +194 -299
- package/dist/chunk-S24ZBUB4.js.map +1 -0
- package/dist/{chunk-EWS2VFO4.js → chunk-S5TMRJMX.js} +4 -4
- package/dist/{chunk-EWS2VFO4.js.map → chunk-S5TMRJMX.js.map} +1 -1
- package/dist/chunk-SMOO5FAH.js +10 -0
- package/dist/chunk-SMOO5FAH.js.map +1 -0
- package/dist/{chunk-RUHKBEFF.js → chunk-SYWR5G3T.js} +16 -7
- package/dist/chunk-SYWR5G3T.js.map +1 -0
- package/dist/{chunk-FQXRYPCX.cjs → chunk-TRVWMKNE.cjs} +337 -52
- package/dist/chunk-TRVWMKNE.cjs.map +1 -0
- package/dist/{chunk-LLOIAGFB.js → chunk-UDDVDQMF.js} +292 -35
- package/dist/chunk-UDDVDQMF.js.map +1 -0
- package/dist/{chunk-PONP5J5E.cjs → chunk-V24EPI5N.cjs} +13 -3
- package/dist/chunk-V24EPI5N.cjs.map +1 -0
- package/dist/{chunk-5I4T4QR5.cjs → chunk-VACPZPUA.cjs} +5 -5
- package/dist/{chunk-5I4T4QR5.cjs.map → chunk-VACPZPUA.cjs.map} +1 -1
- package/dist/{chunk-HGI2VKIV.js → chunk-Y6X7UJSD.js} +10 -9
- package/dist/chunk-Y6X7UJSD.js.map +1 -0
- package/dist/chunk-YCXRSWCQ.js +42 -0
- package/dist/chunk-YCXRSWCQ.js.map +1 -0
- package/dist/entries/apps.cjs +44 -44
- package/dist/entries/apps.js +9 -9
- package/dist/entries/credits.cjs +217 -152
- package/dist/entries/credits.d.cts +105 -3
- package/dist/entries/credits.d.ts +105 -3
- package/dist/entries/credits.js +13 -8
- package/dist/entries/entities.cjs +188 -143
- package/dist/entries/entities.d.cts +122 -1
- package/dist/entries/entities.d.ts +122 -1
- package/dist/entries/entities.js +2 -1
- package/dist/entries/llm-models.d.cts +2 -1
- package/dist/entries/llm-models.d.ts +2 -1
- package/dist/entries/media.cjs +92 -87
- package/dist/entries/media.d.cts +11 -1
- package/dist/entries/media.d.ts +11 -1
- package/dist/entries/media.js +3 -2
- package/dist/entries/model-catalog.cjs +195 -103
- package/dist/entries/model-catalog.d.cts +90 -4
- package/dist/entries/model-catalog.d.ts +90 -4
- package/dist/entries/model-catalog.js +5 -5
- package/dist/entries/models.cjs +407 -294
- package/dist/entries/models.d.cts +4 -3
- package/dist/entries/models.d.ts +4 -3
- package/dist/entries/models.js +6 -5
- package/dist/entries/nodes.cjs +241 -233
- package/dist/entries/nodes.d.cts +15 -2
- package/dist/entries/nodes.d.ts +15 -2
- package/dist/entries/nodes.js +10 -10
- package/dist/entries/pipeline.cjs +152 -152
- package/dist/entries/pipeline.d.cts +2 -1
- package/dist/entries/pipeline.d.ts +2 -1
- package/dist/entries/pipeline.js +3 -3
- package/dist/entries/ugc.cjs +71 -71
- package/dist/entries/ugc.js +4 -4
- package/dist/entries/video.cjs +308 -204
- package/dist/entries/video.d.cts +480 -98
- package/dist/entries/video.d.ts +480 -98
- package/dist/entries/video.js +8 -4
- package/dist/entries/workflow.cjs +102 -102
- package/dist/entries/workflow.d.cts +5 -4
- package/dist/entries/workflow.d.ts +5 -4
- package/dist/entries/workflow.js +2 -2
- package/dist/{gpt-image-2-6-BeZdT-pW.d.cts → gpt-image-2-6-jIRQBRag.d.cts} +6 -0
- package/dist/{gpt-image-2-6-BeZdT-pW.d.ts → gpt-image-2-6-jIRQBRag.d.ts} +6 -0
- package/dist/index.cjs +2309 -1886
- package/dist/index.d.cts +9 -9
- package/dist/index.d.ts +9 -9
- package/dist/index.js +26 -23
- package/dist/{model-catalog-BgSvskgY.d.cts → model-catalog-CCEcv08q.d.cts} +128 -14
- package/dist/{model-catalog-BgSvskgY.d.ts → model-catalog-CCEcv08q.d.ts} +128 -14
- package/dist/{model-constants-DHd9jwQ7.d.ts → model-constants-B88p6XR0.d.ts} +299 -19
- package/dist/{model-constants-DHd9jwQ7.d.cts → model-constants-Cf3zaITt.d.cts} +299 -19
- package/package.json +1 -1
- package/src/__tests__/extend-providers.test.ts +114 -0
- package/src/__tests__/fixtures/mask-composite-quote-parity.json +118 -0
- package/src/__tests__/fixtures/root-exports.baseline.json +68 -0
- package/src/__tests__/gpt-image-2-6-formats.test.ts +4 -1
- package/src/__tests__/grok-video-15-catalog.test.ts +189 -0
- package/src/__tests__/gvp-supported-providers.test.ts +5 -2
- package/src/__tests__/minimax-h3-image.test.ts +140 -0
- package/src/__tests__/model-makers.test.ts +49 -11
- package/src/__tests__/model-tree.test.ts +13 -0
- package/src/__tests__/retired-video-provider.test.ts +15 -5
- package/src/__tests__/seedance-25-catalog-modes.test.ts +1 -1
- package/src/__tests__/seedance-task-type.test.ts +178 -0
- package/src/__tests__/seedream-5-5.test.ts +117 -0
- package/src/__tests__/unit-contract-compose.test.ts +27 -1
- package/src/__tests__/unit-contracts.test.ts +20 -6
- package/src/__tests__/upscale-factors.test.ts +107 -0
- package/src/__tests__/video-character-refs.test.ts +20 -2
- package/src/__tests__/video-collapse-parity.test.ts +19 -0
- package/src/__tests__/video-overlay-geometry.test.ts +68 -0
- package/src/__tests__/video-overlay-layer-plan.test.ts +3 -4
- package/src/__tests__/video-overlay-layouts.test.ts +529 -0
- package/src/__tests__/video-overlay-pricing.test.ts +61 -0
- package/src/__tests__/video-overlay-validate.test.ts +128 -0
- package/src/__tests__/video-overlay-wired-kind.test.ts +207 -0
- package/src/__tests__/video-overlay.test.ts +280 -194
- package/src/__tests__/video-ref-limits.test.ts +2 -1
- package/src/__tests__/video-reference-only.test.ts +6 -2
- package/src/__tests__/video-start-frame-only.test.ts +98 -0
- package/src/__tests__/wired-character-names.test.ts +220 -0
- package/src/credit-estimators/index.ts +8 -0
- package/src/credit-estimators/video-overlay.ts +70 -0
- package/src/credit-identifiers.ts +94 -1
- package/src/entity-image-url.ts +21 -0
- package/src/entries/credits.ts +14 -0
- package/src/entries/entities.ts +14 -0
- package/src/entries/model-catalog.ts +35 -1
- package/src/entries/models.ts +34 -0
- package/src/entries/nodes.ts +2 -0
- package/src/entries/video.ts +6 -0
- package/src/generated/unit-contracts.ts +8 -1
- package/src/gpt-image-2-6.ts +6 -0
- package/src/input-image-pricing.ts +76 -0
- package/src/mask-composite.ts +11 -0
- package/src/minimax-h3-image.ts +61 -0
- package/src/model-catalog.ts +355 -37
- package/src/model-constants.ts +590 -32
- package/src/node-default-mappings.ts +12 -2
- package/src/node-execution-state.ts +4 -3
- package/src/producer-types.ts +23 -1
- package/src/seedance-task-type.ts +37 -0
- package/src/seedream-5-5.ts +45 -0
- package/src/unit-contract-compose.ts +4 -1
- package/src/upscale-factors.ts +111 -0
- package/src/video-character-refs.ts +7 -4
- package/src/video-overlay-geometry.ts +99 -0
- package/src/video-overlay-input.ts +25 -0
- package/src/video-overlay-layout-ids.ts +48 -0
- package/src/video-overlay-layouts.ts +315 -0
- package/src/video-overlay-validate.ts +223 -0
- package/src/video-overlay-video-layers.ts +304 -0
- package/src/video-overlay.ts +165 -297
- package/src/video-ui-defaults.ts +8 -6
- package/src/wired-character-names.ts +202 -0
- package/dist/chunk-5XRRENHD.cjs.map +0 -1
- package/dist/chunk-673E4KYC.js.map +0 -1
- package/dist/chunk-6XVHYD5R.js.map +0 -1
- package/dist/chunk-7ARKVJTN.cjs.map +0 -1
- package/dist/chunk-7WGKP3EU.js +0 -23
- package/dist/chunk-7WGKP3EU.js.map +0 -1
- package/dist/chunk-A3FHTSLB.js.map +0 -1
- package/dist/chunk-AFQFGZN7.cjs.map +0 -1
- package/dist/chunk-F5YEMSNK.cjs.map +0 -1
- package/dist/chunk-FQXRYPCX.cjs.map +0 -1
- package/dist/chunk-FVVD6XY2.js.map +0 -1
- package/dist/chunk-G4XWVWRI.js.map +0 -1
- package/dist/chunk-HGI2VKIV.js.map +0 -1
- package/dist/chunk-IVXSNW2B.cjs.map +0 -1
- package/dist/chunk-JHTT2V4A.cjs.map +0 -1
- package/dist/chunk-KHZAQGRP.js +0 -17
- package/dist/chunk-KHZAQGRP.js.map +0 -1
- package/dist/chunk-LLOIAGFB.js.map +0 -1
- package/dist/chunk-M3SXUUWC.cjs.map +0 -1
- package/dist/chunk-MOMFX32D.js.map +0 -1
- package/dist/chunk-NCOGGRRP.cjs +0 -27
- package/dist/chunk-NCOGGRRP.cjs.map +0 -1
- package/dist/chunk-NJVOJXBS.cjs.map +0 -1
- package/dist/chunk-PONP5J5E.cjs.map +0 -1
- package/dist/chunk-RUHKBEFF.js.map +0 -1
- package/dist/chunk-SWVGHAYO.js.map +0 -1
- package/dist/chunk-UARGJ5IZ.js.map +0 -1
- package/dist/chunk-VB2ARGQ6.js.map +0 -1
- package/dist/chunk-WGKAOUEQ.cjs.map +0 -1
- package/dist/chunk-XROE3CAS.cjs.map +0 -1
- package/dist/chunk-ZLDFPVVI.cjs +0 -19
- package/dist/chunk-ZLDFPVVI.cjs.map +0 -1
- package/dist/chunk-ZNM2LW3D.cjs.map +0 -1
- package/dist/chunk-ZZGQRRN7.js.map +0 -1
|
@@ -17,6 +17,7 @@ type Rows = {
|
|
|
17
17
|
UNIT_REVIEW_HOLDS?: readonly string[]
|
|
18
18
|
UNIT_PRESENTS?: ReadonlyArray<readonly [string, string]>
|
|
19
19
|
UNIT_FAN_OUT_EACH?: ReadonlyArray<readonly [string, { each: readonly string[]; primary: string }]>
|
|
20
|
+
UNIT_LIST_PIPS?: ReadonlyArray<readonly [string, readonly string[]]>
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
function withRows(rows: Rows): void {
|
|
@@ -29,6 +30,7 @@ function withRows(rows: Rows): void {
|
|
|
29
30
|
UNIT_REVIEW_HOLDS: [],
|
|
30
31
|
UNIT_PRESENTS: [],
|
|
31
32
|
UNIT_FAN_OUT_EACH: [],
|
|
33
|
+
UNIT_LIST_PIPS: [],
|
|
32
34
|
...rows,
|
|
33
35
|
}))
|
|
34
36
|
}
|
|
@@ -85,10 +87,27 @@ describe("a node unit's contract rows join the published tables", () => {
|
|
|
85
87
|
expect(listResultsServeHandle("fixture-case", "json")).toBe(false)
|
|
86
88
|
})
|
|
87
89
|
|
|
90
|
+
it("a list pip's edges run the next node once per item by default; the unit's other pips and an edge naming none keep Selected", async () => {
|
|
91
|
+
withRows({ UNIT_LIST_PIPS: [["fixture-layers", ["layers"]]] })
|
|
92
|
+
const { LIST_OUTPUT_HANDLES, defaultEdgeOutputMode, isListOutputHandle } = await import("../producer-types.js")
|
|
93
|
+
expect(LIST_OUTPUT_HANDLES).toEqual({ "fixture-layers": ["layers"] })
|
|
94
|
+
expect(isListOutputHandle("fixture-layers", "layers")).toBe(true)
|
|
95
|
+
expect(isListOutputHandle("fixture-layers", "base")).toBe(false)
|
|
96
|
+
expect(isListOutputHandle("fixture-layers", undefined)).toBe(false)
|
|
97
|
+
expect(isListOutputHandle("constructor", "layers")).toBe(false)
|
|
98
|
+
expect(defaultEdgeOutputMode("fixture-layers", "layers")).toBe("each")
|
|
99
|
+
expect(defaultEdgeOutputMode("fixture-layers", "base")).toBe("last")
|
|
100
|
+
expect(defaultEdgeOutputMode("fixture-layers", undefined)).toBe("last")
|
|
101
|
+
// A legacy node's default is untouched.
|
|
102
|
+
expect(defaultEdgeOutputMode("split-text", undefined)).toBe("each")
|
|
103
|
+
expect(defaultEdgeOutputMode("generate-image", "image")).toBe("last")
|
|
104
|
+
})
|
|
105
|
+
|
|
88
106
|
it("with no rows every table is exactly its hand-written entries", async () => {
|
|
89
107
|
withRows({})
|
|
90
|
-
const { FAN_OUT_EACH_HANDLES } = await import("../producer-types.js")
|
|
108
|
+
const { FAN_OUT_EACH_HANDLES, LIST_OUTPUT_HANDLES } = await import("../producer-types.js")
|
|
91
109
|
expect(Object.keys(FAN_OUT_EACH_HANDLES)).toEqual(["camera-switch", "ugc-clips"])
|
|
110
|
+
expect(LIST_OUTPUT_HANDLES).toEqual({})
|
|
92
111
|
const { NON_PROMPT_TEXT_LANES } = await import("../fan-out-rows.js")
|
|
93
112
|
const { REVIEW_HOLDING_USE_CASE_TYPES } = await import("../preview-gate.js")
|
|
94
113
|
expect(NON_PROMPT_TEXT_LANES.music).toBeUndefined()
|
|
@@ -114,6 +133,13 @@ describe("a type that is hand-written and a node unit refuses to load", () => {
|
|
|
114
133
|
}
|
|
115
134
|
})
|
|
116
135
|
|
|
136
|
+
describe("a node unit with two list-pip rows refuses to load", () => {
|
|
137
|
+
it("../producer-types.js", async () => {
|
|
138
|
+
withRows({ UNIT_LIST_PIPS: [["fixture-layers", ["layers"]], ["fixture-layers", ["frames"]]] })
|
|
139
|
+
await expect(import("../producer-types.js")).rejects.toThrow(/LIST_OUTPUT_HANDLES: node unit fixture-layers has more than one row/)
|
|
140
|
+
})
|
|
141
|
+
})
|
|
142
|
+
|
|
117
143
|
describe("a node unit with two fan-out rows refuses to load", () => {
|
|
118
144
|
it("../producer-types.js", async () => {
|
|
119
145
|
withRows({ UNIT_FAN_OUT_EACH: [["fixture-case", { each: ["media"], primary: "media" }], ["fixture-case", { each: ["json"], primary: "json" }]] })
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
import { readFileSync } from "node:fs"
|
|
3
3
|
import path from "node:path"
|
|
4
4
|
import { describe, expect, it } from "vitest"
|
|
5
|
-
import { UNIT_CONTRACTS, UNIT_FAN_OUT_EACH, UNIT_JSON_PIPS, UNIT_NON_PROMPT_INPUTS, UNIT_PRESENTS, UNIT_REVIEW_HOLDS, UNIT_USE_CASE_TYPES } from "../generated/unit-contracts.js"
|
|
5
|
+
import { UNIT_CONTRACTS, UNIT_FAN_OUT_EACH, UNIT_JSON_PIPS, UNIT_LIST_PIPS, UNIT_NON_PROMPT_INPUTS, UNIT_PRESENTS, UNIT_REVIEW_HOLDS, UNIT_USE_CASE_TYPES } from "../generated/unit-contracts.js"
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* What the node units may put in @nodaro/shared (decided 2026-10-16, widened
|
|
9
9
|
* 2026-10-18): node type ids with closed vocabularies — the producer kind, the
|
|
10
10
|
* use-case types, what a JSON pip carries, the non-prompt input pips, the
|
|
11
|
-
* review holds, how a published app presents the result
|
|
12
|
-
* fan out item by item. Each feeds a published table beside its hand-written
|
|
11
|
+
* review holds, how a published app presents the result, which output pips
|
|
12
|
+
* fan out item by item and which carry a list. Each feeds a published table beside its hand-written
|
|
13
13
|
* rows. Never a price, a credit id, a number, prompt or
|
|
14
14
|
* doctrine text: every published version of this package is an irrevocable
|
|
15
15
|
* Apache grant, and those live in backend/ (prices, ee/) and @nodaro/prompts
|
|
@@ -22,7 +22,7 @@ const GOLDEN = readFileSync(path.resolve(__dirname, "../../../../tools/units/__f
|
|
|
22
22
|
const TYPE = "[a-z][a-z0-9-]*"
|
|
23
23
|
const ROW_END = `, \\/\\/ unit:${TYPE}$`
|
|
24
24
|
const PIP = `"[a-zA-Z][\\w-]*"`
|
|
25
|
-
/** The
|
|
25
|
+
/** The eight declarations, in order, each with the one row shape its block may hold, and how the block ends. */
|
|
26
26
|
const DECLARATIONS: ReadonlyArray<{ readonly head: RegExp; readonly row: RegExp; readonly end: string }> = [
|
|
27
27
|
{
|
|
28
28
|
head: /^export const UNIT_CONTRACTS: ReadonlyArray<readonly \[type: string, producer: "audio" \| "video" \| "image" \| "dynamic"\]> = \[$/,
|
|
@@ -51,11 +51,16 @@ const DECLARATIONS: ReadonlyArray<{ readonly head: RegExp; readonly row: RegExp;
|
|
|
51
51
|
row: new RegExp(`^ {2}\\["${TYPE}", \\{ "each": \\[${PIP}(?:, ${PIP})*\\], "primary": ${PIP} \\}\\]${ROW_END}`),
|
|
52
52
|
end: "]",
|
|
53
53
|
},
|
|
54
|
+
{
|
|
55
|
+
head: /^export const UNIT_LIST_PIPS: ReadonlyArray<readonly \[type: string, pips: ReadonlyArray<string>\]> = \[$/,
|
|
56
|
+
row: new RegExp(`^ {2}\\["${TYPE}", \\[${PIP}(?:, ${PIP})*\\]\\]${ROW_END}`),
|
|
57
|
+
end: "]",
|
|
58
|
+
},
|
|
54
59
|
]
|
|
55
60
|
|
|
56
61
|
/**
|
|
57
62
|
* Problems with a contracts file's code lines (`//` comments and blanks aside —
|
|
58
|
-
* a `/** … *\/` line is code, and refused); [] when it holds exactly the
|
|
63
|
+
* a `/** … *\/` line is code, and refused); [] when it holds exactly the eight
|
|
59
64
|
* declarations, in order, each followed only by its own rows and its end line.
|
|
60
65
|
*/
|
|
61
66
|
function contractProblems(source: string): string[] {
|
|
@@ -98,9 +103,15 @@ describe("generated/unit-contracts.ts carries only type ids with closed vocabula
|
|
|
98
103
|
expect(h.each.length).toBeGreaterThan(0)
|
|
99
104
|
for (const pip of [...h.each, h.primary]) expect(pip).toMatch(PIP_ID)
|
|
100
105
|
}
|
|
106
|
+
// A list-pip row is a type id and pip ids only.
|
|
107
|
+
for (const [t, pips] of UNIT_LIST_PIPS) {
|
|
108
|
+
expect(t).toMatch(KEBAB)
|
|
109
|
+
expect(pips.length).toBeGreaterThan(0)
|
|
110
|
+
for (const pip of pips) expect(pip).toMatch(PIP_ID)
|
|
111
|
+
}
|
|
101
112
|
})
|
|
102
113
|
|
|
103
|
-
it("the file holds nothing else: the
|
|
114
|
+
it("the file holds nothing else: the eight declarations and their rows", () => {
|
|
104
115
|
expect(contractProblems(SOURCE)).toEqual([])
|
|
105
116
|
})
|
|
106
117
|
|
|
@@ -110,6 +121,7 @@ describe("generated/unit-contracts.ts carries only type ids with closed vocabula
|
|
|
110
121
|
const full = GOLDEN
|
|
111
122
|
.replace("ReadonlyArray<string>]> = [\n", 'ReadonlyArray<string>]> = [\n ["fixture-case", ["media"]], // unit:fixture-case\n')
|
|
112
123
|
.replace("UNIT_REVIEW_HOLDS: ReadonlyArray<string> = [\n", 'UNIT_REVIEW_HOLDS: ReadonlyArray<string> = [\n "fixture-case", // unit:fixture-case\n')
|
|
124
|
+
.replace("pips: ReadonlyArray<string>]> = [\n", 'pips: ReadonlyArray<string>]> = [\n ["fixture-echo", ["layers"]], // unit:fixture-echo\n')
|
|
113
125
|
expect(full).not.toBe(GOLDEN)
|
|
114
126
|
expect(contractProblems(full)).toEqual([])
|
|
115
127
|
const refused = [
|
|
@@ -125,6 +137,8 @@ describe("generated/unit-contracts.ts carries only type ids with closed vocabula
|
|
|
125
137
|
GOLDEN.replace('{ "each": ["text"], "primary": "text" }', '{ "each": ["text", 10], "primary": "text" }'),
|
|
126
138
|
GOLDEN.replace('{ "each": ["text"], "primary": "text" }', '{ "each": ["text"], "primary": "text", "fee": "x" }'),
|
|
127
139
|
GOLDEN.replace('{ "each": ["text"], "primary": "text" }', '{ "each": ["Make it cinematic"], "primary": "text" }'),
|
|
140
|
+
full.replace('["fixture-echo", ["layers"]]', '["fixture-echo", ["layers", 10]]'),
|
|
141
|
+
full.replace('["fixture-echo", ["layers"]]', '["fixture-echo", ["Split it nicely"]]'),
|
|
128
142
|
]
|
|
129
143
|
for (const [i, src] of refused.entries()) {
|
|
130
144
|
expect(src, `case ${i} changed the golden`).not.toBe(GOLDEN)
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest"
|
|
2
|
+
import {
|
|
3
|
+
NODARO_IMAGE_UPSCALE_DEFAULT_FACTOR,
|
|
4
|
+
NODARO_IMAGE_UPSCALE_FACTORS,
|
|
5
|
+
UPSCALE_FACTORS,
|
|
6
|
+
resolveNodaroImageUpscaleFactor,
|
|
7
|
+
resolveTopazUpscale,
|
|
8
|
+
resolveUpscaleFactor,
|
|
9
|
+
snappedUpscaleFactor,
|
|
10
|
+
TOPAZ_UPSCALE_FACTORS,
|
|
11
|
+
upscaleFactorsFor,
|
|
12
|
+
} from "../entries/credits.js"
|
|
13
|
+
import { HOUSE_ONLY_UPSCALE_FACTORS } from "../upscale-factors.js"
|
|
14
|
+
import { buildCreditModelIdentifier } from "../credit-identifiers.js"
|
|
15
|
+
import { MODEL_CATALOG } from "../model-catalog.js"
|
|
16
|
+
import { IMAGE_EDIT_PROVIDERS, UPSCALE_IMAGE_PROVIDERS } from "../model-constants.js"
|
|
17
|
+
|
|
18
|
+
describe("the factors each upscaler takes", () => {
|
|
19
|
+
it("Nodaro Image Upscale takes 1 / 2 / 4 / 8, default 2; Topaz keeps 1 / 2 / 4; Recraft takes none", () => {
|
|
20
|
+
expect(NODARO_IMAGE_UPSCALE_FACTORS).toEqual(["1", "2", "4", "8"])
|
|
21
|
+
expect(NODARO_IMAGE_UPSCALE_DEFAULT_FACTOR).toBe("2")
|
|
22
|
+
expect(upscaleFactorsFor("nodaro-image-upscale")).toEqual(["1", "2", "4", "8"])
|
|
23
|
+
expect(upscaleFactorsFor("topaz-image-upscale")).toEqual(TOPAZ_UPSCALE_FACTORS)
|
|
24
|
+
expect(TOPAZ_UPSCALE_FACTORS).toEqual(["1", "2", "4"])
|
|
25
|
+
expect(upscaleFactorsFor("recraft-upscale")).toBeUndefined()
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it("UPSCALE_FACTORS is every factor any upscaler takes", () => {
|
|
29
|
+
const union = new Set(UPSCALE_IMAGE_PROVIDERS.flatMap((p) => upscaleFactorsFor(p) ?? []))
|
|
30
|
+
expect([...UPSCALE_FACTORS].sort()).toEqual([...union].sort())
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
describe("resolveNodaroImageUpscaleFactor / resolveUpscaleFactor", () => {
|
|
35
|
+
it("a listed factor is rendered as given; anything else at 2", () => {
|
|
36
|
+
for (const f of ["1", "2", "4", "8"]) expect(resolveNodaroImageUpscaleFactor(f)).toBe(f)
|
|
37
|
+
expect(resolveNodaroImageUpscaleFactor(" 8 ")).toBe("8")
|
|
38
|
+
expect(resolveNodaroImageUpscaleFactor(4)).toBe("4")
|
|
39
|
+
for (const f of [undefined, null, "", "3", "16", "8K", 0]) expect(resolveNodaroImageUpscaleFactor(f)).toBe("2")
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it("Topaz resolves exactly as resolveTopazUpscale (8 still renders at 2, a legacy tier still maps)", () => {
|
|
43
|
+
for (const upscaleFactor of [undefined, "1", "2", "4", "8"]) {
|
|
44
|
+
for (const targetResolution of [undefined, "2K", "4K", "8K"]) {
|
|
45
|
+
expect(resolveUpscaleFactor("topaz-image-upscale", { upscaleFactor, targetResolution })).toBe(
|
|
46
|
+
resolveTopazUpscale({ upscaleFactor, targetResolution }).upscaleFactor,
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it("Nodaro Image Upscale never reads a stored tier; a model with no factor list is sent its value as before, never an 8", () => {
|
|
53
|
+
expect(resolveUpscaleFactor("nodaro-image-upscale", { targetResolution: "4K" })).toBe("2")
|
|
54
|
+
// As it always was: a stored or mapped 1/2/4 is passed on.
|
|
55
|
+
expect(resolveUpscaleFactor("recraft-upscale", { upscaleFactor: "4" })).toBe("4")
|
|
56
|
+
expect(resolveUpscaleFactor("nano-banana-edit", { upscaleFactor: "2" })).toBe("2")
|
|
57
|
+
expect(resolveUpscaleFactor("grok-2-edit", { upscaleFactor: "1" })).toBe("1")
|
|
58
|
+
expect(resolveUpscaleFactor("recraft-upscale", {})).toBeUndefined()
|
|
59
|
+
// Only the house model takes 8: a node kept from it never sends it elsewhere.
|
|
60
|
+
expect(resolveUpscaleFactor("recraft-upscale", { upscaleFactor: "8" })).toBeUndefined()
|
|
61
|
+
expect(resolveUpscaleFactor(undefined, { upscaleFactor: "8" })).toBeUndefined()
|
|
62
|
+
expect(HOUSE_ONLY_UPSCALE_FACTORS).toEqual(["8"])
|
|
63
|
+
})
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
describe("snappedUpscaleFactor (the editor's fail-safe on a model switch)", () => {
|
|
67
|
+
it("a Nodaro Image Upscale 8x switched to Topaz runs, and is stored, at 2x", () => {
|
|
68
|
+
expect(snappedUpscaleFactor("topaz-image-upscale", { upscaleFactor: "8" })).toBe("2")
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
it("a Nodaro Image Upscale 8x switched to Recraft (or to no model, which runs as Recraft) keeps no factor", () => {
|
|
72
|
+
expect(snappedUpscaleFactor("recraft-upscale", { upscaleFactor: "8" })).toBeNull()
|
|
73
|
+
expect(snappedUpscaleFactor(undefined, { upscaleFactor: "8" })).toBeNull()
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
it("a saved Recraft node's own 1/2/4 stands, as it always did", () => {
|
|
77
|
+
for (const f of ["1", "2", "4"]) expect(snappedUpscaleFactor("recraft-upscale", { upscaleFactor: f }), f).toBeUndefined()
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it("a factor the new model takes, or no factor stored: nothing to change", () => {
|
|
81
|
+
expect(snappedUpscaleFactor("nodaro-image-upscale", { upscaleFactor: "4" })).toBeUndefined()
|
|
82
|
+
expect(snappedUpscaleFactor("topaz-image-upscale", { upscaleFactor: "4" })).toBeUndefined()
|
|
83
|
+
expect(snappedUpscaleFactor("topaz-image-upscale", {})).toBeUndefined()
|
|
84
|
+
expect(snappedUpscaleFactor("recraft-upscale", {})).toBeUndefined()
|
|
85
|
+
expect(snappedUpscaleFactor("nodaro-image-upscale", { upscaleFactor: "3" })).toBe("2")
|
|
86
|
+
})
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
describe("the catalog and the provider lists", () => {
|
|
90
|
+
it("Nodaro Image Upscale is an own-label image upscaler, priced by output tier with a hold", () => {
|
|
91
|
+
const entry = MODEL_CATALOG["nodaro-image-upscale"]!
|
|
92
|
+
expect(entry).toMatchObject({ kind: "image", modes: ["upscale"], ownLabel: true, family: "Nodaro Upscale", series: "Nodaro Upscale", label: "Nodaro Image Upscale" })
|
|
93
|
+
expect(entry).not.toHaveProperty("maker")
|
|
94
|
+
expect(entry.pricing.map((p) => [p.identifier, p.credits])).toEqual([
|
|
95
|
+
["nodaro-image-upscale:2K", 4],
|
|
96
|
+
["nodaro-image-upscale:4K", 10],
|
|
97
|
+
["nodaro-image-upscale:8K", 30],
|
|
98
|
+
["nodaro-image-upscale", 30],
|
|
99
|
+
])
|
|
100
|
+
expect(IMAGE_EDIT_PROVIDERS).toContain("nodaro-image-upscale")
|
|
101
|
+
expect(UPSCALE_IMAGE_PROVIDERS).toContain("nodaro-image-upscale")
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
it("the shared builder prices it at the hold — the size-aware id is built from the image's size, never a stored tier", () => {
|
|
105
|
+
expect(buildCreditModelIdentifier("nodaro-image-upscale", undefined, undefined, undefined, "4K")).toBe("nodaro-image-upscale")
|
|
106
|
+
})
|
|
107
|
+
})
|
|
@@ -22,15 +22,21 @@ const portrait = (over: Partial<VideoCharacterReference> = {}): VideoCharacterRe
|
|
|
22
22
|
})
|
|
23
23
|
|
|
24
24
|
describe("character reference capability (data-driven)", () => {
|
|
25
|
-
it("both Gemini Omni SKUs declare a 3-character cap, Kling 4.0 a 7-subject cap; nothing else does", () => {
|
|
25
|
+
it("both Gemini Omni SKUs declare a 3-character cap, Kling 4.0 and Kling 4.0 Flash a 7-subject cap; nothing else does", () => {
|
|
26
26
|
expect(VIDEO_REF_LIMITS_BY_PROVIDER["gemini-omni-video"]?.characters).toBe(3)
|
|
27
27
|
expect(VIDEO_REF_LIMITS_BY_PROVIDER["gemini-omni-flash"]?.characters).toBe(3)
|
|
28
28
|
expect(VIDEO_REF_LIMITS_BY_PROVIDER["kling-4"]?.characters).toBe(7)
|
|
29
|
+
expect(VIDEO_REF_LIMITS_BY_PROVIDER["kling-4-flash"]?.characters).toBe(7)
|
|
29
30
|
const others = Object.entries(VIDEO_REF_LIMITS_BY_PROVIDER)
|
|
30
|
-
.filter(([id, l]) => !id.startsWith("gemini-omni") && id !== "kling-4" && (l?.characters ?? 0) > 0)
|
|
31
|
+
.filter(([id, l]) => !id.startsWith("gemini-omni") && id !== "kling-4" && id !== "kling-4-flash" && (l?.characters ?? 0) > 0)
|
|
31
32
|
expect(others).toEqual([])
|
|
32
33
|
})
|
|
33
34
|
|
|
35
|
+
it("only Kling 4.0 Flash binds its audio to the characters", () => {
|
|
36
|
+
const binders = Object.entries(VIDEO_REF_LIMITS_BY_PROVIDER).filter(([, l]) => l?.audioBindsToCharacters).map(([id]) => id)
|
|
37
|
+
expect(binders).toEqual(["kling-4-flash"])
|
|
38
|
+
})
|
|
39
|
+
|
|
34
40
|
it("the wire ceiling is the widest declared cap", () => {
|
|
35
41
|
const widest = Math.max(...Object.values(VIDEO_REF_LIMITS_BY_PROVIDER).map((l) => l?.characters ?? 0))
|
|
36
42
|
expect(VIDEO_CHARACTER_REFS_WIRE_MAX).toBe(widest)
|
|
@@ -115,6 +121,18 @@ describe("videoCharacterRefProblem", () => {
|
|
|
115
121
|
expect(videoCharacterRefProblem({ ...base, imageCount: 4, characterReferences: [withBody, withBody] })?.code)
|
|
116
122
|
.toBe("character_references_quota")
|
|
117
123
|
})
|
|
124
|
+
|
|
125
|
+
it("Kling 4.0 counts voice clips in its 15 materials; Flash's clips ride the characters and take no seat", () => {
|
|
126
|
+
const two = [portrait(), portrait()]
|
|
127
|
+
// 10 images + 1 start frame + 2 videos + 2 characters = 15.
|
|
128
|
+
const shape = { imageCount: 10, videoCount: 2, hasStartFrame: true, characterReferences: two }
|
|
129
|
+
expect(videoCharacterRefProblem({ ...shape, provider: "kling-4", audioCount: 0 })).toBeNull()
|
|
130
|
+
expect(videoCharacterRefProblem({ ...shape, provider: "kling-4", audioCount: 1 })?.code).toBe("character_references_quota")
|
|
131
|
+
expect(videoCharacterRefProblem({ ...shape, provider: "kling-4-flash", audioCount: 2 })).toBeNull()
|
|
132
|
+
const over = videoCharacterRefProblem({ ...shape, provider: "kling-4-flash", imageCount: 11, audioCount: 2 })
|
|
133
|
+
expect(over?.code).toBe("character_references_quota")
|
|
134
|
+
expect(over?.message).not.toContain("voices")
|
|
135
|
+
})
|
|
118
136
|
})
|
|
119
137
|
|
|
120
138
|
describe("Gemini Omni voice presets (data)", () => {
|
|
@@ -4,6 +4,8 @@ import {
|
|
|
4
4
|
normalizeMinimaxH3Resolution,
|
|
5
5
|
normalizeWan3Resolution,
|
|
6
6
|
normalizeViduQ4Resolution,
|
|
7
|
+
normalizeGrokVideo15Resolution,
|
|
8
|
+
KLING_4_FLASH_RESOLUTION,
|
|
7
9
|
VIDEO_GEN_PROVIDERS,
|
|
8
10
|
} from "../model-constants.js"
|
|
9
11
|
|
|
@@ -59,6 +61,23 @@ describe("unlistedResolutionRendersAs matches the provider's own collapse rule",
|
|
|
59
61
|
}
|
|
60
62
|
})
|
|
61
63
|
|
|
64
|
+
it("grok-imagine-video-1.5 declares what normalizeGrokVideo15Resolution collapses to", () => {
|
|
65
|
+
const declared = MODEL_CATALOG["grok-imagine-video-1.5"]!.unlistedResolutionRendersAs
|
|
66
|
+
expect(declared).toBe("480p")
|
|
67
|
+
for (const off of ["360p", "2k", "4k", "nonsense"]) {
|
|
68
|
+
expect(normalizeGrokVideo15Resolution(off), `grok renders ${off} as`).toBe(declared)
|
|
69
|
+
expect(normalizeVideoRequestParams("grok-imagine-video-1.5", { resolution: off }).resolution).toBe(declared)
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
it("kling-4-flash declares the one band it renders — the runner sends 720p for anything", () => {
|
|
74
|
+
const declared = MODEL_CATALOG["kling-4-flash"]!.unlistedResolutionRendersAs
|
|
75
|
+
expect(declared).toBe(KLING_4_FLASH_RESOLUTION)
|
|
76
|
+
for (const off of ["480p", "1080p", "4k", "nonsense"]) {
|
|
77
|
+
expect(normalizeVideoRequestParams("kling-4-flash", { resolution: off }).resolution).toBe(declared)
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
|
|
62
81
|
it("a declared collapse target is always one of the model's own bands", () => {
|
|
63
82
|
for (const provider of VIDEO_GEN_PROVIDERS) {
|
|
64
83
|
const entry = MODEL_CATALOG[provider]
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest"
|
|
2
|
+
import { VIDEO_OVERLAY_PRESETS } from "../video-overlay.js"
|
|
3
|
+
import { resolveVideoOverlayGeometry, videoOverlayCanvas } from "../video-overlay-geometry.js"
|
|
4
|
+
|
|
5
|
+
describe("resolveVideoOverlayGeometry (§3.4 — shared by the preview and the worker)", () => {
|
|
6
|
+
it("the card preset on 1080×1920 (the spec's worked example)", () => {
|
|
7
|
+
expect(resolveVideoOverlayGeometry({ w: 1080, h: 1920 }, VIDEO_OVERLAY_PRESETS.card, 1080 / 2160)).toEqual({
|
|
8
|
+
box: { left: 119, top: 307, width: 842, height: 1152 },
|
|
9
|
+
drawn: { left: 252, top: 307, width: 576, height: 1152 },
|
|
10
|
+
})
|
|
11
|
+
})
|
|
12
|
+
it("full-frame on a 9:16 canvas is the whole canvas — no edge shrink", () => {
|
|
13
|
+
expect(resolveVideoOverlayGeometry({ w: 1080, h: 1920 }, VIDEO_OVERLAY_PRESETS["full-frame"], 16 / 9).drawn).toEqual({ left: 0, top: 0, width: 1080, height: 1920 })
|
|
14
|
+
})
|
|
15
|
+
it("a corner badge on 16:9", () => {
|
|
16
|
+
expect(resolveVideoOverlayGeometry({ w: 1920, h: 1080 }, VIDEO_OVERLAY_PRESETS["corner-badge"]["bottom-right"], 1).drawn).toEqual({ left: 1497, top: 691, width: 346, height: 346 })
|
|
17
|
+
})
|
|
18
|
+
it("an odd drawn size is rounded DOWN to even (libx264 yuv420p)", () => {
|
|
19
|
+
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 })
|
|
20
|
+
})
|
|
21
|
+
it("a very tall image at width 60 % with no height is fitted inside the canvas (the clamp): 192 × 1920", () => {
|
|
22
|
+
expect(resolveVideoOverlayGeometry({ w: 1080, h: 1920 }, { anchor: "center", x: 0, y: 0, width: 60, fit: "contain" }, 400 / 4000)).toEqual({
|
|
23
|
+
box: { left: 444, top: 0, width: 192, height: 1920 },
|
|
24
|
+
drawn: { left: 444, top: 0, width: 192, height: 1920 },
|
|
25
|
+
})
|
|
26
|
+
})
|
|
27
|
+
it("…and with height 60 % set: box 648 × 1152, contain → 114 × 1152, no clamp", () => {
|
|
28
|
+
const g = resolveVideoOverlayGeometry({ w: 1080, h: 1920 }, { anchor: "center", x: 0, y: 0, width: 60, height: 60, fit: "contain" }, 400 / 4000)
|
|
29
|
+
expect(g.box).toEqual({ left: 216, top: 384, width: 648, height: 1152 })
|
|
30
|
+
expect(g.drawn).toEqual({ left: 483, top: 384, width: 114, height: 1152 })
|
|
31
|
+
})
|
|
32
|
+
it("a drawn size that would round below 2 px is floored at 2 × 2 (Review Focus 4)", () => {
|
|
33
|
+
expect(resolveVideoOverlayGeometry({ w: 100, h: 100 }, { anchor: "top-left", x: 0, y: 0, width: 1, fit: "contain" }, 1).drawn).toMatchObject({ width: 2, height: 2 })
|
|
34
|
+
})
|
|
35
|
+
it("property: drawn is even, ≥ 2 and never larger than the canvas", () => {
|
|
36
|
+
const canvases = [{ w: 1080, h: 1920 }, { w: 1920, h: 1080 }, { w: 100, h: 100 }, { w: 640, h: 360 }]
|
|
37
|
+
for (const canvas of canvases) {
|
|
38
|
+
for (let width = 1; width <= 100; width += 7) {
|
|
39
|
+
for (const height of [undefined, 1, 14, 60, 100]) {
|
|
40
|
+
for (const aspect of [0.05, 0.5, 1, 2, 20]) {
|
|
41
|
+
for (const fit of ["contain", "cover"] as const) {
|
|
42
|
+
const { drawn } = resolveVideoOverlayGeometry(canvas, { anchor: "center", x: 0, y: 0, width, height, fit }, aspect)
|
|
43
|
+
expect(drawn.width % 2).toBe(0)
|
|
44
|
+
expect(drawn.height % 2).toBe(0)
|
|
45
|
+
expect(drawn.width).toBeGreaterThanOrEqual(2)
|
|
46
|
+
expect(drawn.width).toBeLessThanOrEqual(canvas.w)
|
|
47
|
+
expect(drawn.height).toBeLessThanOrEqual(canvas.h)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
describe("videoOverlayCanvas", () => {
|
|
57
|
+
it("is the display size: SAR resolved, even-rounded", () => {
|
|
58
|
+
expect(videoOverlayCanvas({ width: 540, height: 1920, sar: 2 })).toEqual({ w: 1080, h: 1920 })
|
|
59
|
+
expect(videoOverlayCanvas({ width: 1079, height: 1919 })).toEqual({ w: 1078, h: 1918 })
|
|
60
|
+
})
|
|
61
|
+
it("a target aspect wins", () => {
|
|
62
|
+
expect(videoOverlayCanvas({ width: 1920, height: 1080 }, "9:16")).toEqual({ w: 1080, h: 1920 })
|
|
63
|
+
expect(videoOverlayCanvas(null, "4:5")).toEqual({ w: 1080, h: 1350 })
|
|
64
|
+
})
|
|
65
|
+
it("unknown size and no aspect → null", () => {
|
|
66
|
+
expect(videoOverlayCanvas(null)).toBeNull()
|
|
67
|
+
})
|
|
68
|
+
})
|
|
@@ -2,13 +2,12 @@ import { describe, expect, it } from "vitest"
|
|
|
2
2
|
import {
|
|
3
3
|
VIDEO_OVERLAY_MAX_LAYERS,
|
|
4
4
|
assembleVideoOverlayRequest,
|
|
5
|
-
formatVideoOverlayError,
|
|
6
5
|
parseVideoOverlayLayerPlan,
|
|
7
|
-
validateVideoOverlayRequest,
|
|
8
6
|
videoOverlayCompositionKey,
|
|
9
7
|
videoOverlayRenderOrder,
|
|
10
8
|
videoOverlaySlotSources,
|
|
11
9
|
} from "../video-overlay.js"
|
|
10
|
+
import { formatVideoOverlayError, validateVideoOverlayRequest } from "../video-overlay-validate.js"
|
|
12
11
|
|
|
13
12
|
const box = { anchor: "top", x: 0, y: 12, width: 78, height: 52, fit: "contain" } as const
|
|
14
13
|
const plan = [
|
|
@@ -47,13 +46,13 @@ describe("the layerPlan input (SP2 D6, spec §6.1)", () => {
|
|
|
47
46
|
expect(verdict.ok).toBe(false)
|
|
48
47
|
if (!verdict.ok) {
|
|
49
48
|
expect(verdict.code).toBe("layer_without_image")
|
|
50
|
-
expect(formatVideoOverlayError(verdict)).toBe("Plan layer 1: no image — set imageUrl on this layer in the plan.")
|
|
49
|
+
expect(formatVideoOverlayError(verdict)).toBe("Plan layer 1: no image or video — set imageUrl or videoUrl on this layer in the plan.")
|
|
51
50
|
}
|
|
52
51
|
})
|
|
53
52
|
it("a handle layer without an image keeps the handle wording", () => {
|
|
54
53
|
const verdict = validateVideoOverlayRequest({ layers: [{ start: 0, slot: 2 }] })
|
|
55
54
|
expect(verdict.ok).toBe(false)
|
|
56
|
-
if (!verdict.ok) expect(formatVideoOverlayError(verdict)).toBe("Layer 2: no image — connect one to the layer's handle or set imageUrl")
|
|
55
|
+
if (!verdict.ok) expect(formatVideoOverlayError(verdict)).toBe("Layer 2: no image or video — connect one to the layer's handle or set imageUrl or videoUrl")
|
|
57
56
|
})
|
|
58
57
|
it("reports an unparseable plan as invalid_layer_plan", () => {
|
|
59
58
|
const req = assembleVideoOverlayRequest({ videoUrl: "https://cdn.example/v.mp4", data: { layers: [] }, wiredImageUrls: [], planLayers: "not json" })
|