@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
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
VOICE_DESIGN_MODELS,
|
|
12
12
|
} from "./model-constants.js"
|
|
13
13
|
import { LLM_MODEL_IDS } from "./llm-models.js"
|
|
14
|
+
import { SEEDREAM_5_5_DEFAULT_RESOLUTION } from "./seedream-5-5.js"
|
|
14
15
|
|
|
15
16
|
// ──────────────────────────────────────────────────────────────────────────
|
|
16
17
|
// Types
|
|
@@ -188,6 +189,13 @@ const QUALITY_MAP: Record<string, QualityMapping> = {
|
|
|
188
189
|
// Seedream 5 Flash's lever is size (sent as KIE `size`), flat-priced — resolution-style.
|
|
189
190
|
"seedream-5-flash": { field: "resolution", values: { low: "1K", mid: "2K", high: "2K" } },
|
|
190
191
|
"seedream-5-flash-i2i": { field: "resolution", values: { low: "1K", mid: "2K", high: "2K" } },
|
|
192
|
+
// MiniMax H3 Image: 1K and 2K cost the same, 2K is its default.
|
|
193
|
+
"minimax-h3-image": { field: "resolution", values: { low: "1K", mid: "2K", high: "4K" } },
|
|
194
|
+
"minimax-h3-image-i2i": { field: "resolution", values: { low: "1K", mid: "2K", high: "4K" } },
|
|
195
|
+
// Seedream 5.5's lever is its size too (KIE `size`): mid is its default, 2K;
|
|
196
|
+
// low the cheapest, 1K (1.5K costs the same, and is the panel's to pick).
|
|
197
|
+
"seedream-5-5": { field: "resolution", values: { low: "1K", mid: SEEDREAM_5_5_DEFAULT_RESOLUTION, high: "2K" } },
|
|
198
|
+
"seedream-5-5-i2i": { field: "resolution", values: { low: "1K", mid: SEEDREAM_5_5_DEFAULT_RESOLUTION, high: "2K" } },
|
|
191
199
|
// Video gen — resolution-style (720p/1080p)
|
|
192
200
|
"veo3": { field: "resolution", values: { low: "720p", mid: "1080p", high: "1080p" } },
|
|
193
201
|
"veo3.1": { field: "resolution", values: { low: "720p", mid: "1080p", high: "1080p" } },
|
|
@@ -209,6 +217,8 @@ const QUALITY_MAP: Record<string, QualityMapping> = {
|
|
|
209
217
|
// Kling 4.0 — two tiers on both endpoints.
|
|
210
218
|
"kling-4": { field: "resolution", values: { low: "720p", mid: "720p", high: "1080p" } },
|
|
211
219
|
"kling-4-keyframes": { field: "resolution", values: { low: "720p", mid: "720p", high: "1080p" } },
|
|
220
|
+
// Kling 4.0 Flash — 720p only, so every level lands on it.
|
|
221
|
+
"kling-4-flash": { field: "resolution", values: { low: "720p", mid: "720p", high: "720p" } },
|
|
212
222
|
"wan-2.7-i2v": { field: "resolution", values: { low: "720p", mid: "1080p", high: "1080p" } },
|
|
213
223
|
"wan-2.7-t2v": { field: "resolution", values: { low: "720p", mid: "1080p", high: "1080p" } },
|
|
214
224
|
"happyhorse": { field: "resolution", values: { low: "720p", mid: "1080p", high: "1080p" } },
|
|
@@ -224,8 +234,8 @@ const QUALITY_MAP: Record<string, QualityMapping> = {
|
|
|
224
234
|
"gemini-omni-video": { field: "resolution", values: { low: "720p", mid: "1080p", high: "4k" } },
|
|
225
235
|
"gemini-omni-flash": { field: "resolution", values: { low: "720p", mid: "1080p", high: "4k" } },
|
|
226
236
|
"gemini-omni-flash-1-2": { field: "resolution", values: { low: "720p", mid: "1080p", high: "4k" } },
|
|
227
|
-
// Grok Imagine Video 1.5 —
|
|
228
|
-
"grok-imagine-video-1.5": { field: "resolution", values: { low: "480p", mid: "720p", high: "
|
|
237
|
+
// Grok Imagine Video 1.5 — 480p / 720p / 1080p, each quality rung its own tier.
|
|
238
|
+
"grok-imagine-video-1.5": { field: "resolution", values: { low: "480p", mid: "720p", high: "1080p" } },
|
|
229
239
|
// Replicate Flux 2 family — MP-based resolution (matching IMAGE_RESOLUTION_OPTIONS["flux-2-*"]).
|
|
230
240
|
// `field: "resolution"` is mandatory — see Provider Enum Sync pitfall 4.
|
|
231
241
|
// mid = provider default: 1 MP for Klein, 2 MP for Pro/Max.
|
|
@@ -94,9 +94,10 @@ export interface NodeExecutionStateWire<TOutput = Record<string, unknown>> {
|
|
|
94
94
|
* `error_detail`), with links cut to their host and secrets removed; absent
|
|
95
95
|
* when the failure had no provider text (a platform refusal, a timeout).
|
|
96
96
|
* Display-only, beside `error`: branch on `errorCode` or the hint, never on
|
|
97
|
-
* these words.
|
|
98
|
-
*
|
|
99
|
-
* words for
|
|
97
|
+
* these words. Only a reader who can open the workflow the run executed
|
|
98
|
+
* receives it — never a published app's runner, nor a person running
|
|
99
|
+
* someone else's share link — and on a deployment that keeps these words for
|
|
100
|
+
* its administrators, no reader who is not one.
|
|
100
101
|
*/
|
|
101
102
|
errorDetail?: string | null
|
|
102
103
|
/**
|
package/src/producer-types.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* execution time (the prior drift bug, see issue 1 of the Task 4.1 review).
|
|
16
16
|
*/
|
|
17
17
|
import { UGC_PRIMARY_HANDLE } from "./ugc-node-wires.js"
|
|
18
|
-
import { composeUnitRecord, composeUnitSet, unitFanOutEach, unitProducers } from "./unit-contract-compose.js"
|
|
18
|
+
import { composeUnitRecord, composeUnitSet, unitFanOutEach, unitListPips, unitProducers } from "./unit-contract-compose.js"
|
|
19
19
|
|
|
20
20
|
// Each producer set below is its hand-written members ∪ the node units
|
|
21
21
|
// (tools/units/README.md) of that producer kind, from their generated contract
|
|
@@ -358,6 +358,27 @@ export function ownsItsList(nodeType: string | null | undefined): boolean {
|
|
|
358
358
|
return typeof nodeType === "string" && OWN_LIST_NODE_TYPES.has(nodeType)
|
|
359
359
|
}
|
|
360
360
|
|
|
361
|
+
/**
|
|
362
|
+
* The output pips that carry the LIST one run produced — several files on one
|
|
363
|
+
* pip (a node unit's `handles.outputs[].list`: each layer of a split image). An
|
|
364
|
+
* edge leaving one runs the next node once per item by default ("each"); a
|
|
365
|
+
* Bundle hands the whole list to a node that takes several. Unlike
|
|
366
|
+
* FAN_OUT_EACH_HANDLES, the list is what ONE run made on that pip, never the
|
|
367
|
+
* node's per-iteration results. An edge naming no pip reads the node's primary
|
|
368
|
+
* output, which is never a list pip (tools/units/json-output-rules.mjs).
|
|
369
|
+
* Node units only (generated/unit-contracts.ts UNIT_LIST_PIPS).
|
|
370
|
+
*/
|
|
371
|
+
export const LIST_OUTPUT_HANDLES: Readonly<Record<string, readonly string[]>> = composeUnitRecord("LIST_OUTPUT_HANDLES", {}, unitListPips())
|
|
372
|
+
|
|
373
|
+
/** Whether an edge leaving `sourceHandle` of a `sourceType` node carries a list one run produced (LIST_OUTPUT_HANDLES). */
|
|
374
|
+
export function isListOutputHandle(
|
|
375
|
+
sourceType: string | null | undefined,
|
|
376
|
+
sourceHandle: string | null | undefined,
|
|
377
|
+
): boolean {
|
|
378
|
+
if (typeof sourceType !== "string" || typeof sourceHandle !== "string" || !Object.hasOwn(LIST_OUTPUT_HANDLES, sourceType)) return false
|
|
379
|
+
return LIST_OUTPUT_HANDLES[sourceType]!.includes(sourceHandle)
|
|
380
|
+
}
|
|
381
|
+
|
|
361
382
|
/** The `outputMode` an edge has when none is set on it — the ONE rule both
|
|
362
383
|
* engines, the credit estimate and the editor read. */
|
|
363
384
|
export function defaultEdgeOutputMode(
|
|
@@ -366,6 +387,7 @@ export function defaultEdgeOutputMode(
|
|
|
366
387
|
): "each" | "last" {
|
|
367
388
|
if (typeof sourceType !== "string") return "last"
|
|
368
389
|
if (FAN_OUT_EACH_TYPES.has(sourceType)) return "each"
|
|
390
|
+
if (isListOutputHandle(sourceType, sourceHandle)) return "each"
|
|
369
391
|
const entry = FAN_OUT_EACH_HANDLES[sourceType]
|
|
370
392
|
if (!entry) return "last"
|
|
371
393
|
return entry.each.includes(sourceHandle || entry.primary) ? "each" : "last"
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seedance 2.5 reference task type — what a request's reference media is FOR.
|
|
3
|
+
*
|
|
4
|
+
* The provider takes an optional declaration of the job a run's references do:
|
|
5
|
+
* - `reference` — the media guides a new clip (look, subject, motion);
|
|
6
|
+
* - `edit` — the clip is an edit of the reference video, in its own shape
|
|
7
|
+
* and length;
|
|
8
|
+
* - `extend` — the clip continues the reference video.
|
|
9
|
+
* Without one the provider guesses from the prompt. `auto` is the platform's
|
|
10
|
+
* spelling of "declare nothing": the provider keeps guessing.
|
|
11
|
+
*
|
|
12
|
+
* Which models take the declaration is a catalog capability
|
|
13
|
+
* (`MODEL_CATALOG[id].referenceTaskTypes`), read through
|
|
14
|
+
* `supportsReferenceTaskType`; whether a given request declares one, and the
|
|
15
|
+
* aspect ratio and length that forces, is decided in one place by
|
|
16
|
+
* `resolveSeedanceTaskType` (both in `model-constants.ts`). Never hand-list the
|
|
17
|
+
* model.
|
|
18
|
+
*
|
|
19
|
+
* Import-free on purpose: the catalog (`model-catalog.ts`) and the constants
|
|
20
|
+
* module (`model-constants.ts`, which imports the catalog) both read it. The
|
|
21
|
+
* resolver itself lives in `model-constants.ts` because it needs
|
|
22
|
+
* `videoDefaultDurationSec` from there.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/** Every value a request may carry, `auto` (declare nothing) first. */
|
|
26
|
+
export const SEEDANCE_REFERENCE_TASK_TYPES = ["auto", "reference", "edit", "extend"] as const
|
|
27
|
+
export type SeedanceReferenceTaskType = typeof SEEDANCE_REFERENCE_TASK_TYPES[number]
|
|
28
|
+
|
|
29
|
+
/** A value that is actually sent to the provider. */
|
|
30
|
+
export type DeclaredSeedanceTaskType = Exclude<SeedanceReferenceTaskType, "auto">
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The reference-video length (seconds, inclusive) an `edit` declaration
|
|
34
|
+
* accepts. Every reference video must be measured and inside it; otherwise
|
|
35
|
+
* nothing is declared.
|
|
36
|
+
*/
|
|
37
|
+
export const SEEDANCE_EDIT_REF_VIDEO_SEC = { min: 4, max: 30 } as const
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What makes Seedream 5.5 price differently from the other Seedream models: its
|
|
3
|
+
* size (1K, 1.5K or 2K), and on an edit the number of input images as well.
|
|
4
|
+
*
|
|
5
|
+
* Only the ids and levers live in this published package. The rates and the
|
|
6
|
+
* formula are `backend/src/ee/billing/seedream-5-5-pricing.ts`.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export const SEEDREAM_5_5_T2I = "seedream-5-5"
|
|
10
|
+
export const SEEDREAM_5_5_I2I = "seedream-5-5-i2i"
|
|
11
|
+
export type Seedream55Model = typeof SEEDREAM_5_5_T2I | typeof SEEDREAM_5_5_I2I
|
|
12
|
+
|
|
13
|
+
/** The sizes it renders, smallest first; the provider names the field `size`. */
|
|
14
|
+
export const SEEDREAM_5_5_RESOLUTIONS = ["1K", "1.5K", "2K"] as const
|
|
15
|
+
export type Seedream55Resolution = (typeof SEEDREAM_5_5_RESOLUTIONS)[number]
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The size a run renders when it names none: the provider's own default, and
|
|
19
|
+
* the size an unset or unknown value is priced and sent at. Every place that
|
|
20
|
+
* fills an unset size for this model reads it from here.
|
|
21
|
+
*/
|
|
22
|
+
export const SEEDREAM_5_5_DEFAULT_RESOLUTION: Seedream55Resolution = "2K"
|
|
23
|
+
|
|
24
|
+
/** The most input images an edit takes, and is priced for (`REF_IMAGE_MAX_LIMITS`). */
|
|
25
|
+
export const SEEDREAM_5_5_MAX_INPUT_IMAGES = 10
|
|
26
|
+
|
|
27
|
+
/** The fewest characters a prompt may have: the provider refuses a shorter one. */
|
|
28
|
+
export const SEEDREAM_5_5_MIN_PROMPT_CHARS = 5
|
|
29
|
+
|
|
30
|
+
export function isSeedream55I2i(model: unknown): boolean {
|
|
31
|
+
return model === SEEDREAM_5_5_I2I
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function isSeedream55(model: unknown): model is Seedream55Model {
|
|
35
|
+
return model === SEEDREAM_5_5_T2I || model === SEEDREAM_5_5_I2I
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The size a Seedream 5.5 run is priced and sent at: the one asked for when it
|
|
40
|
+
* is one of its sizes (any case), else the default. Unset is the default.
|
|
41
|
+
*/
|
|
42
|
+
export function seedream55Resolution(resolution: unknown): Seedream55Resolution {
|
|
43
|
+
const asked = typeof resolution === "string" ? resolution.trim().toUpperCase() : ""
|
|
44
|
+
return SEEDREAM_5_5_RESOLUTIONS.find((r) => r === asked) ?? SEEDREAM_5_5_DEFAULT_RESOLUTION
|
|
45
|
+
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* the tables that compose its rows (producer-types, presentation-utils,
|
|
7
7
|
* json-kinds, fan-out-rows, preview-gate) are what consumers read.
|
|
8
8
|
*/
|
|
9
|
-
import { UNIT_CONTRACTS, UNIT_FAN_OUT_EACH, UNIT_JSON_PIPS, UNIT_NON_PROMPT_INPUTS, UNIT_PRESENTS, UNIT_REVIEW_HOLDS } from "./generated/unit-contracts.js"
|
|
9
|
+
import { UNIT_CONTRACTS, UNIT_FAN_OUT_EACH, UNIT_JSON_PIPS, UNIT_LIST_PIPS, UNIT_NON_PROMPT_INPUTS, UNIT_PRESENTS, UNIT_REVIEW_HOLDS } from "./generated/unit-contracts.js"
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* `legacy ∪ units` as a set, `legacy` first, refusing a type that is in both —
|
|
@@ -53,3 +53,6 @@ export const unitReviewHolds = (): readonly string[] => UNIT_REVIEW_HOLDS
|
|
|
53
53
|
|
|
54
54
|
/** Each node unit's fan-out "each" outputs and primary pip (`contract.fanOutEach`), in generated order. */
|
|
55
55
|
export const unitFanOutEach = (): ReadonlyArray<readonly [string, { readonly each: ReadonlyArray<string>; readonly primary: string }]> => UNIT_FAN_OUT_EACH
|
|
56
|
+
|
|
57
|
+
/** Each node unit's list outputs (`handles.outputs[].list`: one run's several files on one pip), in generated order. */
|
|
58
|
+
export const unitListPips = (): ReadonlyArray<readonly [string, ReadonlyArray<string>]> => UNIT_LIST_PIPS
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The upscale FACTOR of the image upscalers that take one — which factors each
|
|
3
|
+
* model accepts, and the factor a request renders at. One authority for the
|
|
4
|
+
* route's enum, the editor's dropdown and its fail-safe snap, the workflow
|
|
5
|
+
* payload, the worker, MCP and the SDK.
|
|
6
|
+
*
|
|
7
|
+
* Two models take a factor:
|
|
8
|
+
* - `topaz-image-upscale`: 1, 2 or 4 — resolved by `resolveTopazUpscale`,
|
|
9
|
+
* which also maps its legacy `targetResolution` (unchanged here).
|
|
10
|
+
* - `nodaro-image-upscale`: 1, 2, 4 or 8. A factor multiplies both sides; 1
|
|
11
|
+
* enhances the picture at its own size. Anything else is rendered at the
|
|
12
|
+
* default, 2. It has no `targetResolution`: its price follows the output's
|
|
13
|
+
* size (`@nodaro/render-rules` nodaro-image-upscale-pricing.ts), so a stored
|
|
14
|
+
* tier from another model is never read.
|
|
15
|
+
*
|
|
16
|
+
* Every other model (Recraft, and the edit models) declares no factor list,
|
|
17
|
+
* and a factor stored or mapped onto its node is passed on exactly as it
|
|
18
|
+
* always was — "1", "2" and "4" are the values the route takes for it — except
|
|
19
|
+
* a factor only the house model takes ({@link HOUSE_ONLY_UPSCALE_FACTORS}, "8"):
|
|
20
|
+
* no other model takes it, so it is never sent to one, and the editor clears
|
|
21
|
+
* it from a node switched away from Nodaro Image Upscale.
|
|
22
|
+
*/
|
|
23
|
+
import { resolveTopazUpscale, TOPAZ_UPSCALE_FACTORS } from "./topaz-upscale.js"
|
|
24
|
+
|
|
25
|
+
/** Nodaro Image Upscale's model id. */
|
|
26
|
+
export const NODARO_IMAGE_UPSCALE_MODEL_ID = "nodaro-image-upscale"
|
|
27
|
+
|
|
28
|
+
export type NodaroImageUpscaleFactor = "1" | "2" | "4" | "8"
|
|
29
|
+
|
|
30
|
+
/** The factors Nodaro Image Upscale renders at, smallest first. */
|
|
31
|
+
export const NODARO_IMAGE_UPSCALE_FACTORS: readonly NodaroImageUpscaleFactor[] = ["1", "2", "4", "8"]
|
|
32
|
+
|
|
33
|
+
/** The factor a Nodaro Image Upscale request without a valid one renders at. */
|
|
34
|
+
export const NODARO_IMAGE_UPSCALE_DEFAULT_FACTOR: NodaroImageUpscaleFactor = "2"
|
|
35
|
+
|
|
36
|
+
/** Every factor any image upscaler takes — the vocabulary the request enums carry. Each model's own list is {@link upscaleFactorsFor}. */
|
|
37
|
+
export const UPSCALE_FACTORS = ["1", "2", "4", "8"] as const
|
|
38
|
+
export type UpscaleFactor = (typeof UPSCALE_FACTORS)[number]
|
|
39
|
+
|
|
40
|
+
/** The factor Nodaro Image Upscale renders `raw` at: a listed factor as given (trimmed), anything else the default. */
|
|
41
|
+
export function resolveNodaroImageUpscaleFactor(raw: unknown): NodaroImageUpscaleFactor {
|
|
42
|
+
const trimmed = typeof raw === "string" ? raw.trim() : typeof raw === "number" ? String(raw) : ""
|
|
43
|
+
return (NODARO_IMAGE_UPSCALE_FACTORS as readonly string[]).includes(trimmed)
|
|
44
|
+
? (trimmed as NodaroImageUpscaleFactor)
|
|
45
|
+
: NODARO_IMAGE_UPSCALE_DEFAULT_FACTOR
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The factors only Nodaro Image Upscale takes: every other model's request
|
|
50
|
+
* refuses them (Topaz's list, and the 1/2/4 the route takes for a model with
|
|
51
|
+
* no list of its own), so none is ever sent to another model. "8".
|
|
52
|
+
*/
|
|
53
|
+
export const HOUSE_ONLY_UPSCALE_FACTORS: readonly UpscaleFactor[] = NODARO_IMAGE_UPSCALE_FACTORS.filter(
|
|
54
|
+
(f) => !(TOPAZ_UPSCALE_FACTORS as readonly string[]).includes(f),
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
/** True when `value` is a factor only Nodaro Image Upscale takes ({@link HOUSE_ONLY_UPSCALE_FACTORS}). */
|
|
58
|
+
function isHouseOnlyUpscaleFactor(value: string): boolean {
|
|
59
|
+
return (HOUSE_ONLY_UPSCALE_FACTORS as readonly string[]).includes(value.trim())
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** The factors `provider` accepts, or undefined for a model that declares no factor list. */
|
|
63
|
+
export function upscaleFactorsFor(provider: unknown): readonly UpscaleFactor[] | undefined {
|
|
64
|
+
if (provider === NODARO_IMAGE_UPSCALE_MODEL_ID) return NODARO_IMAGE_UPSCALE_FACTORS
|
|
65
|
+
if (provider === "topaz-image-upscale") return TOPAZ_UPSCALE_FACTORS
|
|
66
|
+
return undefined
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The factor a request to `provider` sends: Topaz's through `resolveTopazUpscale`
|
|
71
|
+
* (its legacy `targetResolution` included), Nodaro Image Upscale's through
|
|
72
|
+
* {@link resolveNodaroImageUpscaleFactor}, and any other model's value as
|
|
73
|
+
* given — except a factor only the house model takes ("8"), which is not
|
|
74
|
+
* sent. What the editor's panel snaps a stale value to, and what the editor's
|
|
75
|
+
* Run and the workflow payload send.
|
|
76
|
+
*/
|
|
77
|
+
export function resolveUpscaleFactor(
|
|
78
|
+
provider: unknown,
|
|
79
|
+
input: { upscaleFactor?: unknown; targetResolution?: unknown },
|
|
80
|
+
): string | undefined {
|
|
81
|
+
if (provider === NODARO_IMAGE_UPSCALE_MODEL_ID) return resolveNodaroImageUpscaleFactor(input.upscaleFactor)
|
|
82
|
+
if (provider === "topaz-image-upscale") {
|
|
83
|
+
return resolveTopazUpscale({
|
|
84
|
+
upscaleFactor: typeof input.upscaleFactor === "string" ? input.upscaleFactor : undefined,
|
|
85
|
+
targetResolution: typeof input.targetResolution === "string" ? input.targetResolution : undefined,
|
|
86
|
+
}).upscaleFactor
|
|
87
|
+
}
|
|
88
|
+
return typeof input.upscaleFactor === "string" && !isHouseOnlyUpscaleFactor(input.upscaleFactor) ? input.upscaleFactor : undefined
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The factor a node on `provider` must carry instead of its stored one — the
|
|
93
|
+
* one the run would render ({@link resolveUpscaleFactor}) — `null` when it
|
|
94
|
+
* must carry none, or undefined when the stored factor stands. What the editor
|
|
95
|
+
* writes when a stale factor meets a model that does not take it: a Nodaro
|
|
96
|
+
* Image Upscale 8x switched to Topaz runs, and is stored, at 2x; one switched
|
|
97
|
+
* to a model with no factor list (Recraft) keeps no factor. Any other factor
|
|
98
|
+
* on such a model stands exactly as it always did (a saved Recraft node's "4"
|
|
99
|
+
* is never rewritten), as does none stored, or one the model takes.
|
|
100
|
+
*/
|
|
101
|
+
export function snappedUpscaleFactor(
|
|
102
|
+
provider: unknown,
|
|
103
|
+
input: { upscaleFactor?: unknown; targetResolution?: unknown },
|
|
104
|
+
): string | null | undefined {
|
|
105
|
+
const stored = typeof input.upscaleFactor === "string" ? input.upscaleFactor : undefined
|
|
106
|
+
if (stored === undefined) return undefined
|
|
107
|
+
const factors = upscaleFactorsFor(provider)
|
|
108
|
+
if (!factors) return isHouseOnlyUpscaleFactor(stored) ? null : undefined
|
|
109
|
+
if ((factors as readonly string[]).includes(stored)) return undefined
|
|
110
|
+
return resolveUpscaleFactor(provider, input) ?? null
|
|
111
|
+
}
|
|
@@ -211,17 +211,20 @@ export function videoCharacterRefProblem(args: {
|
|
|
211
211
|
// A provider that counts every material against ONE budget (Kling 4.0: 15
|
|
212
212
|
// images + videos + subjects + voices) takes characters beside a start frame
|
|
213
213
|
// (the frame joins the reference images) — the Gemini Omni unit rules below
|
|
214
|
-
// do not apply to it.
|
|
215
|
-
|
|
214
|
+
// do not apply to it. Where audio rides on the characters as their voices
|
|
215
|
+
// (`audioBindsToCharacters`, Kling 4.0 Flash), a clip takes no seat.
|
|
216
|
+
const limits = VIDEO_REF_LIMITS_BY_PROVIDER[provider as string]
|
|
217
|
+
const materials = limits?.materials
|
|
216
218
|
if (materials !== undefined) {
|
|
219
|
+
const audioSeats = limits?.audioBindsToCharacters ? 0 : (args.audioCount ?? 0)
|
|
217
220
|
const used =
|
|
218
|
-
args.imageCount + (args.hasStartFrame ? 1 : 0) + args.videoCount + characterReferences.length +
|
|
221
|
+
args.imageCount + (args.hasStartFrame ? 1 : 0) + args.videoCount + characterReferences.length + audioSeats
|
|
219
222
|
if (used > materials) {
|
|
220
223
|
return {
|
|
221
224
|
code: "character_references_quota",
|
|
222
225
|
message:
|
|
223
226
|
`${provider} takes at most ${materials} materials in all — reference images (a start frame counts as one), ` +
|
|
224
|
-
`reference videos, characters and voices. This request uses ${used}. Remove some.`,
|
|
227
|
+
`reference videos, characters${limits?.audioBindsToCharacters ? "" : " and voices"}. This request uses ${used}. Remove some.`,
|
|
225
228
|
}
|
|
226
229
|
}
|
|
227
230
|
return videoCharacterVoiceProblem({ provider, characterReferences })
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Video Overlay — placement: the output canvas and where a layer's box lands
|
|
3
|
+
* on it. `resolveVideoOverlayGeometry` is the one placement function the
|
|
4
|
+
* canvas preview and the ffmpeg worker both call. A sibling of
|
|
5
|
+
* `video-overlay.ts`, which it imports from; nothing there imports this file.
|
|
6
|
+
* Wire contract only — no I/O.
|
|
7
|
+
*/
|
|
8
|
+
import type { OverlayAnchor } from "./image-overlay-layers.js"
|
|
9
|
+
import { ASPECT_RATIO_DIMENSIONS } from "./model-constants.js"
|
|
10
|
+
import { isVideoOverlayOutputAspect, type VideoOverlayLayer } from "./video-overlay.js"
|
|
11
|
+
|
|
12
|
+
export interface VideoOverlayRect {
|
|
13
|
+
readonly left: number
|
|
14
|
+
readonly top: number
|
|
15
|
+
readonly width: number
|
|
16
|
+
readonly height: number
|
|
17
|
+
}
|
|
18
|
+
export interface VideoOverlayCanvas {
|
|
19
|
+
readonly w: number
|
|
20
|
+
readonly h: number
|
|
21
|
+
}
|
|
22
|
+
export interface VideoOverlayGeometry {
|
|
23
|
+
readonly box: VideoOverlayRect
|
|
24
|
+
readonly drawn: VideoOverlayRect
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const evenFloor = (n: number): number => Math.max(2, Math.floor(n / 2) * 2)
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The output canvas: `ASPECT_RATIO_DIMENSIONS[outputAspect]` when a target
|
|
31
|
+
* aspect is set; otherwise the base's DISPLAY size (rotation already applied by
|
|
32
|
+
* the caller's probe) with the sample aspect ratio resolved and both sides
|
|
33
|
+
* rounded down to even — `trunc(iw*sar/2)*2 × trunc(ih/2)*2`, what the ffmpeg
|
|
34
|
+
* base chain produces. null when neither is known.
|
|
35
|
+
*/
|
|
36
|
+
export function videoOverlayCanvas(
|
|
37
|
+
display: { readonly width: number; readonly height: number; readonly sar?: number } | null | undefined,
|
|
38
|
+
outputAspect?: string | null,
|
|
39
|
+
): VideoOverlayCanvas | null {
|
|
40
|
+
if (isVideoOverlayOutputAspect(outputAspect)) {
|
|
41
|
+
const d = ASPECT_RATIO_DIMENSIONS[outputAspect]!
|
|
42
|
+
return { w: d.width, h: d.height }
|
|
43
|
+
}
|
|
44
|
+
if (!display || !(display.width > 0) || !(display.height > 0)) return null
|
|
45
|
+
const sar = typeof display.sar === "number" && Number.isFinite(display.sar) && display.sar > 0 ? display.sar : 1
|
|
46
|
+
return { w: evenFloor(display.width * sar), h: evenFloor(display.height) }
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function anchorFactors(anchor: OverlayAnchor): readonly [number, number] {
|
|
50
|
+
const h = anchor.endsWith("left") ? 0 : anchor.endsWith("right") ? 1 : 0.5
|
|
51
|
+
const v = anchor.startsWith("top") ? 0 : anchor.startsWith("bottom") ? 1 : 0.5
|
|
52
|
+
return [h, v]
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Spec §3.4. `width%` → px of the canvas width; height follows the image's
|
|
57
|
+
* aspect unless `height%` is set; nine anchors; x/y are additive offsets in %
|
|
58
|
+
* of the canvas. An aspect-following box taller than the canvas is fitted
|
|
59
|
+
* inside it (both sides scaled, aspect kept) — so `drawn` never exceeds the
|
|
60
|
+
* canvas, which is what bounds the sharp pre-fit at one canvas of RGBA. `fit`:
|
|
61
|
+
* contain → the image scaled inside the box, centred; cover → the box itself.
|
|
62
|
+
* The only post-processing is rounding `drawn` DOWN to even, floored at 2 × 2.
|
|
63
|
+
* Differences from Image Overlay's copies (on purpose): no 8192 edge shrink,
|
|
64
|
+
* the canvas clamp, the even rounding.
|
|
65
|
+
*/
|
|
66
|
+
export function resolveVideoOverlayGeometry(
|
|
67
|
+
canvas: VideoOverlayCanvas,
|
|
68
|
+
layer: Pick<VideoOverlayLayer, "anchor" | "x" | "y" | "width" | "height" | "fit">,
|
|
69
|
+
imageAspect: number,
|
|
70
|
+
): VideoOverlayGeometry {
|
|
71
|
+
const aspect = Number.isFinite(imageAspect) && imageAspect > 0 ? imageAspect : 1
|
|
72
|
+
let bw = Math.max(1, Math.round((layer.width / 100) * canvas.w))
|
|
73
|
+
let bh = layer.height !== undefined ? Math.max(1, Math.round((layer.height / 100) * canvas.h)) : Math.max(1, Math.round(bw / aspect))
|
|
74
|
+
if (layer.height === undefined && bh > canvas.h) {
|
|
75
|
+
bw = Math.max(1, Math.round(bw * (canvas.h / bh)))
|
|
76
|
+
bh = canvas.h
|
|
77
|
+
}
|
|
78
|
+
const [ax, ay] = anchorFactors(layer.anchor)
|
|
79
|
+
const left = Math.round(ax * (canvas.w - bw) + (layer.x / 100) * canvas.w)
|
|
80
|
+
const top = Math.round(ay * (canvas.h - bh) + (layer.y / 100) * canvas.h)
|
|
81
|
+
let dw: number
|
|
82
|
+
let dh: number
|
|
83
|
+
if (layer.fit === "cover") {
|
|
84
|
+
dw = bw
|
|
85
|
+
dh = bh
|
|
86
|
+
} else if (bw / bh > aspect) {
|
|
87
|
+
dh = bh
|
|
88
|
+
dw = bh * aspect
|
|
89
|
+
} else {
|
|
90
|
+
dw = bw
|
|
91
|
+
dh = bw / aspect
|
|
92
|
+
}
|
|
93
|
+
const width = evenFloor(dw)
|
|
94
|
+
const height = evenFloor(dh)
|
|
95
|
+
return {
|
|
96
|
+
box: { left, top, width: bw, height: bh },
|
|
97
|
+
drawn: { left: left + Math.floor((bw - width) / 2), top: top + Math.floor((bh - height) / 2), width, height },
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Video Overlay — internal readers of a value as a writer sent it, shared by
|
|
3
|
+
* `video-overlay.ts` and `video-overlay-validate.ts`. Not exported from any
|
|
4
|
+
* entry, so they add no public names; this file imports types only, so
|
|
5
|
+
* importing it creates no runtime cycle.
|
|
6
|
+
*/
|
|
7
|
+
import type { VideoOverlayFit, VideoOverlayLayerInput } from "./video-overlay.js"
|
|
8
|
+
|
|
9
|
+
export function isFit(v: unknown): v is VideoOverlayFit {
|
|
10
|
+
return v === "contain" || v === "cover"
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A `layers[]` entry as a layer, or null when it is not a plain object. Layer
|
|
15
|
+
* arrays reach this module from untrusted workflow JSON (the MCP write sites
|
|
16
|
+
* type nodes as `record<string, unknown>`), so a bare string / number / array
|
|
17
|
+
* entry is read as an ABSENT layer — never spread, never `in`-probed.
|
|
18
|
+
*/
|
|
19
|
+
export function asLayer(v: unknown): VideoOverlayLayerInput | null {
|
|
20
|
+
return v !== null && typeof v === "object" && !Array.isArray(v) ? (v as VideoOverlayLayerInput) : null
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const nonEmpty = (v: unknown): v is string => typeof v === "string" && v.length > 0
|
|
24
|
+
/** A stored `layout`, `""` read as absent like `null` (a cleared layout never refuses a run); anything else as stored, for the validator to judge. */
|
|
25
|
+
export const storedLayout = (v: string | null | undefined): string | undefined => (v == null || v === "" ? undefined : v)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Video Overlay layouts — the ids, and what each one needs. A layout is a
|
|
3
|
+
* named shortcut that writes the boxes (`expandVideoOverlayLayout` in
|
|
4
|
+
* `video-overlay-layouts.ts`); like a placement preset, it is a TAG and the
|
|
5
|
+
* boxes are the truth, except for the two stacks, whose boxes depend on the
|
|
6
|
+
* sources' shapes and are resolved where those are known.
|
|
7
|
+
*
|
|
8
|
+
* Dependency-free on purpose: the validator in `video-overlay-validate.ts`
|
|
9
|
+
* reads these, and `video-overlay-layouts.ts` imports the contract in
|
|
10
|
+
* `video-overlay.ts`, so they cannot live in either without a cycle. Wire contract only — no I/O.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* - `video-bottom` / `video-top`: the base whole, full width, against that edge.
|
|
15
|
+
* - `stack-whole`: the base directly above the first video layer, both whole,
|
|
16
|
+
* the same width, the pair centred.
|
|
17
|
+
* - `stack-filled`: the base fills the top half, the first video layer the
|
|
18
|
+
* bottom half, both cropped (`cover`).
|
|
19
|
+
* - `pip`: the base fills the frame, the first video layer sits in a corner.
|
|
20
|
+
*/
|
|
21
|
+
export const VIDEO_OVERLAY_LAYOUT_IDS = ["video-bottom", "video-top", "stack-whole", "stack-filled", "pip"] as const
|
|
22
|
+
export type VideoOverlayLayoutId = (typeof VIDEO_OVERLAY_LAYOUT_IDS)[number]
|
|
23
|
+
|
|
24
|
+
export function isVideoOverlayLayoutId(v: unknown): v is VideoOverlayLayoutId {
|
|
25
|
+
return typeof v === "string" && (VIDEO_OVERLAY_LAYOUT_IDS as readonly string[]).includes(v)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Layouts placed against the output canvas's edges or halves: every one but `pip`. */
|
|
29
|
+
const NEEDS_ASPECT: ReadonlySet<VideoOverlayLayoutId> = new Set(["video-bottom", "video-top", "stack-whole", "stack-filled"])
|
|
30
|
+
/** Layouts that place the first video layer. */
|
|
31
|
+
const NEEDS_VIDEO_LAYER: ReadonlySet<VideoOverlayLayoutId> = new Set(["stack-whole", "stack-filled", "pip"])
|
|
32
|
+
/** Layouts that place the base themselves, so take no `baseBox`. */
|
|
33
|
+
const PLACES_BASE: ReadonlySet<VideoOverlayLayoutId> = new Set(["stack-whole", "stack-filled"])
|
|
34
|
+
|
|
35
|
+
/** True when the layout is refused without an `outputAspect` (`layout_needs_aspect`). */
|
|
36
|
+
export function videoOverlayLayoutNeedsAspect(id: VideoOverlayLayoutId): boolean {
|
|
37
|
+
return NEEDS_ASPECT.has(id)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** True when the layout is refused without a video layer (`layout_needs_video_layer`). */
|
|
41
|
+
export function videoOverlayLayoutNeedsVideoLayer(id: VideoOverlayLayoutId): boolean {
|
|
42
|
+
return NEEDS_VIDEO_LAYER.has(id)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** True when the layout places the base itself and is refused with a `baseBox` (`layout_conflicts_base_box`): the two stacks. */
|
|
46
|
+
export function videoOverlayLayoutPlacesBase(id: VideoOverlayLayoutId): boolean {
|
|
47
|
+
return PLACES_BASE.has(id)
|
|
48
|
+
}
|