@nodaro/shared 3.60.1 → 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-5Y42RIGY.cjs → chunk-2D5LQFV4.cjs} +18 -332
- package/dist/chunk-2D5LQFV4.cjs.map +1 -0
- package/dist/{chunk-5G23AJBU.cjs → chunk-2HZGDZZN.cjs} +6 -6
- package/dist/{chunk-5G23AJBU.cjs.map → chunk-2HZGDZZN.cjs.map} +1 -1
- package/dist/{chunk-DS2TOM32.js → chunk-2QKF7M2Z.js} +28 -4
- package/dist/chunk-2QKF7M2Z.js.map +1 -0
- package/dist/{chunk-CIOXUPCJ.cjs → chunk-2W745U4A.cjs} +228 -355
- package/dist/chunk-2W745U4A.cjs.map +1 -0
- package/dist/{chunk-LN3EVFRS.js → chunk-3OYO3XCC.js} +70 -6
- package/dist/chunk-3OYO3XCC.js.map +1 -0
- package/dist/{chunk-5HK5Z5OB.cjs → chunk-4ZEFP2FQ.cjs} +4 -4
- package/dist/{chunk-5HK5Z5OB.cjs.map → chunk-4ZEFP2FQ.cjs.map} +1 -1
- package/dist/{chunk-KOLC7AF2.js → chunk-5YYN5X57.js} +398 -38
- package/dist/chunk-5YYN5X57.js.map +1 -0
- package/dist/{chunk-RRPPXZ36.cjs → chunk-6CSXMWL4.cjs} +4 -4
- package/dist/{chunk-RRPPXZ36.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-HOKWJXHA.cjs → chunk-A2PX5IRC.cjs} +31 -4
- package/dist/chunk-A2PX5IRC.cjs.map +1 -0
- package/dist/{chunk-W4M7TNXG.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-KJZVQIN4.js → chunk-C7POAYFE.js} +3 -3
- package/dist/{chunk-KJZVQIN4.js.map → chunk-C7POAYFE.js.map} +1 -1
- package/dist/{chunk-6Q6SI7AG.js → chunk-CC4V2B7S.js} +3 -3
- package/dist/{chunk-6Q6SI7AG.js.map → chunk-CC4V2B7S.js.map} +1 -1
- package/dist/{chunk-GNPJ2JLE.cjs → chunk-CIPPPT7E.cjs} +6 -6
- package/dist/{chunk-GNPJ2JLE.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-SKFJIFEV.cjs → chunk-G3KVK7OU.cjs} +21 -21
- package/dist/{chunk-SKFJIFEV.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-EN2YI5TV.js → chunk-GSFB537T.js} +3 -3
- package/dist/{chunk-EN2YI5TV.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-6AJOTEVC.js → chunk-I2RQB7VG.js} +3 -3
- package/dist/{chunk-6AJOTEVC.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-DQIJPDHC.cjs → chunk-IWWVPR3W.cjs} +88 -11
- package/dist/chunk-IWWVPR3W.cjs.map +1 -0
- package/dist/{chunk-URLDVK67.js → chunk-JJNNM23P.js} +3 -3
- package/dist/{chunk-URLDVK67.js.map → chunk-JJNNM23P.js.map} +1 -1
- package/dist/{chunk-YHVEZVAO.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-AXT7YNOR.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-A6HRY3WF.cjs → chunk-MYJQELFN.cjs} +420 -37
- 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-BXNPO3PL.cjs → chunk-N7OUQK7E.cjs} +8 -8
- package/dist/{chunk-BXNPO3PL.cjs.map → chunk-N7OUQK7E.cjs.map} +1 -1
- package/dist/{chunk-JKZVRKN3.js → chunk-NGKKNSK6.js} +31 -8
- 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-SCYBGTX6.js → chunk-PTD6EDUU.js} +3 -3
- package/dist/{chunk-SCYBGTX6.js.map → chunk-PTD6EDUU.js.map} +1 -1
- package/dist/{chunk-BDXXOEBZ.cjs → chunk-QWYFHQYK.cjs} +79 -54
- 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-AZGONXWV.js → chunk-S24ZBUB4.js} +194 -299
- package/dist/chunk-S24ZBUB4.js.map +1 -0
- package/dist/{chunk-IV6IDECY.js → chunk-S5TMRJMX.js} +4 -4
- package/dist/{chunk-IV6IDECY.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-HYBACFYW.js → chunk-SYWR5G3T.js} +16 -7
- package/dist/chunk-SYWR5G3T.js.map +1 -0
- package/dist/{chunk-GWBQ3GPO.cjs → chunk-TRVWMKNE.cjs} +343 -53
- package/dist/chunk-TRVWMKNE.cjs.map +1 -0
- package/dist/{chunk-G6GMY5BC.js → chunk-UDDVDQMF.js} +298 -36
- 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-HDHLZK7C.cjs → chunk-VACPZPUA.cjs} +5 -5
- package/dist/{chunk-HDHLZK7C.cjs.map → chunk-VACPZPUA.cjs.map} +1 -1
- package/dist/{chunk-ICDLYU4I.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 +112 -6
- package/dist/entries/credits.d.ts +112 -6
- 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 +207 -99
- 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 +111 -99
- package/dist/entries/workflow.d.cts +29 -2
- package/dist/entries/workflow.d.ts +29 -2
- 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 +2321 -1870
- package/dist/index.d.cts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.js +26 -23
- package/dist/{model-catalog-D6Es7VG-.d.cts → model-catalog-CCEcv08q.d.cts} +179 -14
- package/dist/{model-catalog-D6Es7VG-.d.ts → model-catalog-CCEcv08q.d.ts} +179 -14
- package/dist/{model-constants-22k3fjp1.d.cts → model-constants-B88p6XR0.d.ts} +305 -20
- package/dist/{model-constants-22k3fjp1.d.ts → model-constants-Cf3zaITt.d.cts} +305 -20
- 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__/gpt-image-2-6.test.ts +7 -0
- package/src/__tests__/grok-video-15-catalog.test.ts +189 -0
- package/src/__tests__/gvp-supported-providers.test.ts +5 -2
- package/src/__tests__/image-mask-mode.test.ts +34 -1
- package/src/__tests__/mask-edit-follows-source.test.ts +150 -0
- 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 +102 -5
- 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 +39 -1
- package/src/entries/models.ts +34 -0
- package/src/entries/nodes.ts +2 -0
- package/src/entries/video.ts +6 -0
- package/src/entries/workflow.ts +1 -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 +512 -48
- package/src/model-constants.ts +602 -34
- package/src/node-default-mappings.ts +12 -2
- package/src/node-execution-state.ts +4 -1
- 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/src/wired-image-size.ts +55 -0
- package/dist/chunk-5Y42RIGY.cjs.map +0 -1
- package/dist/chunk-6XVHYD5R.js.map +0 -1
- package/dist/chunk-A6HRY3WF.cjs.map +0 -1
- package/dist/chunk-AFQFGZN7.cjs.map +0 -1
- package/dist/chunk-AXT7YNOR.cjs.map +0 -1
- package/dist/chunk-AZGONXWV.js.map +0 -1
- package/dist/chunk-BDXXOEBZ.cjs.map +0 -1
- package/dist/chunk-CIOXUPCJ.cjs.map +0 -1
- package/dist/chunk-DQIJPDHC.cjs.map +0 -1
- package/dist/chunk-DS2TOM32.js.map +0 -1
- package/dist/chunk-FVVD6XY2.js.map +0 -1
- package/dist/chunk-G4XWVWRI.js.map +0 -1
- package/dist/chunk-G6GMY5BC.js.map +0 -1
- package/dist/chunk-G7ZYZQKO.cjs +0 -27
- package/dist/chunk-G7ZYZQKO.cjs.map +0 -1
- package/dist/chunk-GWBQ3GPO.cjs.map +0 -1
- package/dist/chunk-HNEF2N5C.cjs +0 -19
- package/dist/chunk-HNEF2N5C.cjs.map +0 -1
- package/dist/chunk-HOKWJXHA.cjs.map +0 -1
- package/dist/chunk-HYBACFYW.js.map +0 -1
- package/dist/chunk-ICDLYU4I.js.map +0 -1
- package/dist/chunk-JKZVRKN3.js.map +0 -1
- package/dist/chunk-KOLC7AF2.js.map +0 -1
- package/dist/chunk-LN3EVFRS.js.map +0 -1
- package/dist/chunk-M3SXUUWC.cjs.map +0 -1
- package/dist/chunk-MHY47BLL.js +0 -23
- package/dist/chunk-MHY47BLL.js.map +0 -1
- package/dist/chunk-PONP5J5E.cjs.map +0 -1
- package/dist/chunk-SWVGHAYO.js.map +0 -1
- package/dist/chunk-VB2ARGQ6.js.map +0 -1
- package/dist/chunk-VYQ25YQF.js +0 -17
- package/dist/chunk-VYQ25YQF.js.map +0 -1
- package/dist/chunk-W4M7TNXG.cjs.map +0 -1
- package/dist/chunk-WGKAOUEQ.cjs.map +0 -1
- package/dist/chunk-XROE3CAS.cjs.map +0 -1
- package/dist/chunk-YHVEZVAO.js.map +0 -1
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Video Overlay video layers — what makes a layer a video, and what kind of
|
|
3
|
+
* layer a wired source becomes. A sibling of `video-overlay.ts`, which imports
|
|
4
|
+
* from here at run time; this file imports from it for TYPES only, so the
|
|
5
|
+
* dependency stays one-way.
|
|
6
|
+
*
|
|
7
|
+
* A layer is a video layer when it carries a non-empty `videoUrl`: the
|
|
8
|
+
* validator's count, the `animate` default and `videoOverlayHasVideoLayer`
|
|
9
|
+
* all read it through `isVideoOverlayVideoLayer`, so they cannot disagree.
|
|
10
|
+
* Wire contract only — no I/O.
|
|
11
|
+
*/
|
|
12
|
+
import type { VideoOverlayLayerInput } from "./video-overlay.js"
|
|
13
|
+
import { DYNAMIC_PRODUCER_TYPES, IMAGE_PRODUCER_TYPES, VIDEO_PRODUCER_TYPES } from "./producer-types.js"
|
|
14
|
+
import { resolveEffectiveSourceType } from "./entity-image-handle.js"
|
|
15
|
+
|
|
16
|
+
/** File extensions a wired source from a node of no fixed kind is read as a video by. */
|
|
17
|
+
const LAYER_VIDEO_EXTENSIONS = [".mp4", ".mov", ".webm", ".m4v"] as const
|
|
18
|
+
/** File extensions it is read as an image by (a recognisable image stays an image, whatever a List column says). */
|
|
19
|
+
const LAYER_IMAGE_EXTENSIONS = [".png", ".jpg", ".jpeg", ".webp", ".gif", ".avif", ".bmp", ".tif", ".tiff", ".heic", ".heif", ".svg"] as const
|
|
20
|
+
|
|
21
|
+
/** True when the layer is a plain object with a non-empty `videoUrl`. */
|
|
22
|
+
export function isVideoOverlayVideoLayer(layer: unknown): boolean {
|
|
23
|
+
if (layer === null || typeof layer !== "object" || Array.isArray(layer)) return false
|
|
24
|
+
const url = (layer as VideoOverlayLayerInput).videoUrl
|
|
25
|
+
return typeof url === "string" && url.length > 0
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** True when any layer is a video layer. Non-array input and non-object entries read as none. */
|
|
29
|
+
export function videoOverlayHasVideoLayer(
|
|
30
|
+
layers: ReadonlyArray<VideoOverlayLayerInput | null | undefined> | null | undefined,
|
|
31
|
+
): boolean {
|
|
32
|
+
return Array.isArray(layers) && layers.some(isVideoOverlayVideoLayer)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The URL's path, lower-cased, without query or fragment; a relative or unparseable URL is cut at `?` / `#`. */
|
|
36
|
+
function lowerPath(url: string): string {
|
|
37
|
+
try {
|
|
38
|
+
return new URL(url).pathname.toLowerCase()
|
|
39
|
+
} catch {
|
|
40
|
+
return url.split(/[?#]/, 1)[0]!.toLowerCase()
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type VideoOverlayWiredLayerKind = "image" | "video"
|
|
45
|
+
|
|
46
|
+
/** The wire a layer handle receives, as both engines' resolvers know it. */
|
|
47
|
+
export interface VideoOverlayWiredSource {
|
|
48
|
+
/** The source node's type. */
|
|
49
|
+
readonly type?: string | null
|
|
50
|
+
/** The source handle the wire leaves (through any teleport). */
|
|
51
|
+
readonly handle?: string | null
|
|
52
|
+
/** The medium the source declares for that handle — a component's or sub-workflow's port (`declaredOutputMediaType`). */
|
|
53
|
+
readonly declaredMediaType?: string | null
|
|
54
|
+
/**
|
|
55
|
+
* The medium a List column's type declares for that handle
|
|
56
|
+
* (`listColumnMediaType`). It ranks BELOW the URL's extension: it only fills
|
|
57
|
+
* the gap for a link with no recognisable one.
|
|
58
|
+
*/
|
|
59
|
+
readonly columnMediaType?: string | null
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Pips whose medium the shared effective-type tables (`resolveEffectiveSourceType`)
|
|
64
|
+
* do not name, kept here so the layer rule reads them without changing how
|
|
65
|
+
* those tables route or validate a wire. 3D Render Pro sits in both producer
|
|
66
|
+
* sets: its `stills` pip carries one PNG per shot, its `video` pip the MP4.
|
|
67
|
+
* The dynamic producers hand on a video or an audio file by pip: their video
|
|
68
|
+
* pips are videos whatever their file's name. A frontend guard holds every
|
|
69
|
+
* image or video pip the editor draws, that a layer handle accepts, to its own
|
|
70
|
+
* medium with an extension-less URL.
|
|
71
|
+
*/
|
|
72
|
+
const LAYER_PIP_KINDS: Readonly<Record<string, Readonly<Record<string, VideoOverlayWiredLayerKind>>>> = {
|
|
73
|
+
"pro-3d-render": { stills: "image", video: "video" },
|
|
74
|
+
"adjust-volume": { "video-out": "video" },
|
|
75
|
+
"pitch-tempo": { "video-out": "video" },
|
|
76
|
+
"voice-changer": { video: "video" },
|
|
77
|
+
"voice-changer-pro": { video: "video" },
|
|
78
|
+
dubbing: { video: "video" },
|
|
79
|
+
"split-media": { video: "video" },
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Layer-plan pips whose plan carries layers of one medium only, so a run
|
|
84
|
+
* estimate can price the node they feed before the plan exists: UGC Cards'
|
|
85
|
+
* plan is its card images. On the `layerPlan` handle nothing else answers
|
|
86
|
+
* `image` before the run (`videoOverlayWireMediumBeforeRun`).
|
|
87
|
+
*/
|
|
88
|
+
const LAYER_PLAN_PIP_KINDS: Readonly<Record<string, Readonly<Record<string, VideoOverlayWiredLayerKind>>>> = {
|
|
89
|
+
"ugc-cards": { layerPlan: "image" },
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const ownKey = <T>(table: Readonly<Record<string, T>>, key: string): T | undefined => (Object.hasOwn(table, key) ? table[key] : undefined)
|
|
93
|
+
|
|
94
|
+
/** The kind of a single-medium producer: in exactly one of the image and video producer sets, and not dynamic. */
|
|
95
|
+
function producerKind(type: string): VideoOverlayWiredLayerKind | undefined {
|
|
96
|
+
if (DYNAMIC_PRODUCER_TYPES.has(type)) return undefined
|
|
97
|
+
const video = VIDEO_PRODUCER_TYPES.has(type)
|
|
98
|
+
if (video === IMAGE_PRODUCER_TYPES.has(type)) return undefined
|
|
99
|
+
return video ? "video" : "image"
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* What a source wired to a layer handle draws as — the ONE rule both engines
|
|
104
|
+
* call, in this order:
|
|
105
|
+
* 1. the medium the wire is known to carry: a pip row of its own
|
|
106
|
+
* (`LAYER_PIP_KINDS`), the medium a port declares (`declaredMediaType`:
|
|
107
|
+
* `image` or `video`), or the source's effective type for that handle
|
|
108
|
+
* (an aggregate lane, a scraper's typed pip, an entity's or an output's
|
|
109
|
+
* image pip — `resolveEffectiveSourceType`) when that is a single-medium producer;
|
|
110
|
+
* 2. the producer sets, for a single-medium producer only;
|
|
111
|
+
* 3. the URL path's extension, when it is a recognisable video or image one
|
|
112
|
+
* (a list, a sub-workflow, a producer in both sets);
|
|
113
|
+
* 4. a List column's declared type (`columnMediaType`: `image` or `video`),
|
|
114
|
+
* for a link with no recognisable extension — so a `.png` in a
|
|
115
|
+
* `video-url` column stays an image, as it was before video layers;
|
|
116
|
+
* 5. an image, as every layer was before video layers existed.
|
|
117
|
+
*/
|
|
118
|
+
export function videoOverlayWiredLayerKind(source: VideoOverlayWiredSource, url: string): VideoOverlayWiredLayerKind {
|
|
119
|
+
return kindOfSource(source) ?? kindOfFile(source, url)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Steps 3–5 of {@link videoOverlayWiredLayerKind}: what the file says, for a source that does not decide by itself. */
|
|
123
|
+
function kindOfFile(source: VideoOverlayWiredSource, url: string): VideoOverlayWiredLayerKind {
|
|
124
|
+
const column = source.columnMediaType === "image" || source.columnMediaType === "video" ? source.columnMediaType : undefined
|
|
125
|
+
return kindOfUrl(url) ?? column ?? "image"
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Steps 1–2 of {@link videoOverlayWiredLayerKind}: the kind the source decides by itself, or undefined when its file decides. */
|
|
129
|
+
function kindOfSource(source: VideoOverlayWiredSource): VideoOverlayWiredLayerKind | undefined {
|
|
130
|
+
const type = source.type ?? ""
|
|
131
|
+
const handle = source.handle ?? undefined
|
|
132
|
+
const pip = pipRowKind(LAYER_PIP_KINDS, source)
|
|
133
|
+
if (pip) return pip
|
|
134
|
+
if (source.declaredMediaType === "image" || source.declaredMediaType === "video") return source.declaredMediaType
|
|
135
|
+
const effective = resolveEffectiveSourceType(type, handle)
|
|
136
|
+
const carried = effective !== type ? producerKind(effective) : undefined
|
|
137
|
+
if (carried) return carried
|
|
138
|
+
return producerKind(type)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** Step 3: the URL path's recognisable extension, or undefined. */
|
|
142
|
+
function kindOfUrl(url: string): VideoOverlayWiredLayerKind | undefined {
|
|
143
|
+
const path = lowerPath(url)
|
|
144
|
+
if (LAYER_VIDEO_EXTENSIONS.some((ext) => path.endsWith(ext))) return "video"
|
|
145
|
+
if (LAYER_IMAGE_EXTENSIONS.some((ext) => path.endsWith(ext))) return "image"
|
|
146
|
+
return undefined
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** What a wire hands a Video Overlay before the run: an image, a video, or not known yet. */
|
|
150
|
+
export type VideoOverlayWireMedium = VideoOverlayWiredLayerKind | "unknown"
|
|
151
|
+
|
|
152
|
+
/** Where a wire lands on a Video Overlay: a layer handle, or the `layerPlan` handle. */
|
|
153
|
+
export interface VideoOverlayWireBeforeRun {
|
|
154
|
+
/** Default `layer`. */
|
|
155
|
+
readonly target?: "layer" | "plan"
|
|
156
|
+
/** A layer wire's files already known before the run (a List's own cells); none = not known. */
|
|
157
|
+
readonly knownUrls?: readonly string[]
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* What a source wired to a Video Overlay hands it, as far as it is known
|
|
162
|
+
* BEFORE the run: the ONE place a run estimate asks.
|
|
163
|
+
*
|
|
164
|
+
* On a layer handle, by the run's own rule ({@link videoOverlayWiredLayerKind}):
|
|
165
|
+
* a source that decides by itself (a pip row, a declared port, a single-medium
|
|
166
|
+
* producer) answers its kind; one whose kind follows its file answers by the
|
|
167
|
+
* files already known (`knownUrls`, read in the run's order: the extension,
|
|
168
|
+
* then a List column's type), and is `unknown` when none is.
|
|
169
|
+
*
|
|
170
|
+
* On the `layerPlan` handle, only a plan pip row answers `image`
|
|
171
|
+
* (`LAYER_PLAN_PIP_KINDS`: UGC Cards' plan is its card images): a declared
|
|
172
|
+
* port, a producer set or a List column says what a FILE is, not what a
|
|
173
|
+
* plan's layers are, so any other plan is `video` when its source is a video
|
|
174
|
+
* and `unknown` otherwise.
|
|
175
|
+
*
|
|
176
|
+
* A run estimate prices `unknown` as a video run, so a quote is never below
|
|
177
|
+
* what the run is charged; once a file is known, the answer is the run's.
|
|
178
|
+
*/
|
|
179
|
+
export function videoOverlayWireMediumBeforeRun(source: VideoOverlayWiredSource, wire: VideoOverlayWireBeforeRun = {}): VideoOverlayWireMedium {
|
|
180
|
+
if (wire.target === "plan") {
|
|
181
|
+
const row = pipRowKind(LAYER_PLAN_PIP_KINDS, source)
|
|
182
|
+
return row ?? (kindOfSource(source) === "video" ? "video" : "unknown")
|
|
183
|
+
}
|
|
184
|
+
const decided = kindOfSource(source)
|
|
185
|
+
if (decided) return decided
|
|
186
|
+
const known = wire.knownUrls ?? []
|
|
187
|
+
if (known.length === 0) return "unknown"
|
|
188
|
+
return known.some((url) => kindOfFile(source, url) === "video") ? "video" : "image"
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** The row of `table` naming the source's handle, or undefined. */
|
|
192
|
+
function pipRowKind(
|
|
193
|
+
table: Readonly<Record<string, Readonly<Record<string, VideoOverlayWiredLayerKind>>>>,
|
|
194
|
+
source: VideoOverlayWiredSource,
|
|
195
|
+
): VideoOverlayWiredLayerKind | undefined {
|
|
196
|
+
const pips = ownKey(table, source.type ?? "")
|
|
197
|
+
const handle = source.handle ?? undefined
|
|
198
|
+
return pips && handle !== undefined ? ownKey(pips, handle) : undefined
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** `list[i]` with `id === id`, its `key` when that is a string. */
|
|
202
|
+
function portMedium(list: unknown, id: string, key: "mediaType" | "type"): string | undefined {
|
|
203
|
+
if (!Array.isArray(list)) return undefined
|
|
204
|
+
const port = list.find((p) => p !== null && typeof p === "object" && (p as { id?: unknown }).id === id) as Record<string, unknown> | undefined
|
|
205
|
+
const value = port?.[key]
|
|
206
|
+
return typeof value === "string" ? value : undefined
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const field = (v: unknown, key: string): unknown => (v !== null && typeof v === "object" ? (v as Record<string, unknown>)[key] : undefined)
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* The medium a component or sub-workflow declares for the handle a wire
|
|
213
|
+
* leaves (`image`, `video`, `audio`, `text`, `any`), or undefined. A
|
|
214
|
+
* sub-workflow (and a component) names its output ports in
|
|
215
|
+
* `routeSnapshot.outputPorts`, its handles `out_<port>`; a component falls back
|
|
216
|
+
* to `componentMetadata.outputs[].type`; a sub-workflow input node names its
|
|
217
|
+
* ports in `ports`, by their own ids. The same fields both engines' input
|
|
218
|
+
* resolvers route these wires by. (A List's column type is not a port
|
|
219
|
+
* declaration: `listColumnMediaType` reads it, and it ranks below the URL's
|
|
220
|
+
* extension.) Untrusted node data: anything malformed declares nothing.
|
|
221
|
+
*/
|
|
222
|
+
export function declaredOutputMediaType(type: string | null | undefined, data: unknown, handle: string | null | undefined): string | undefined {
|
|
223
|
+
if (typeof handle !== "string" || data === null || typeof data !== "object") return undefined
|
|
224
|
+
if (type === "sub-workflow-input") return portMedium(field(data, "ports"), handle, "mediaType")
|
|
225
|
+
if (type !== "sub-workflow" && type !== "component") return undefined
|
|
226
|
+
const portId = handle.replace(/^out_/, "")
|
|
227
|
+
const fromSnapshot = portMedium(field(field(data, "routeSnapshot"), "outputPorts"), portId, "mediaType")
|
|
228
|
+
if (fromSnapshot !== undefined || type !== "component") return fromSnapshot
|
|
229
|
+
return portMedium(field(field(data, "componentMetadata"), "outputs"), portId, "type")
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/** A List column type → the medium its cells declare (its text and JSON columns declare none). */
|
|
233
|
+
const LIST_COLUMN_MEDIA: Readonly<Record<string, string>> = { "image-url": "image", "video-url": "video", "audio-url": "audio" }
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* The medium a List's column type declares for the pip a wire leaves
|
|
237
|
+
* (`image-url` → image, `video-url` → video, `audio-url` → audio): the column
|
|
238
|
+
* whose `handleId` the pip names, else its first column — the column a List's
|
|
239
|
+
* own `list` pip carries, as both engines' input resolvers route it. Undefined
|
|
240
|
+
* for any other source, a text or JSON column, or malformed data. Handed to the
|
|
241
|
+
* wired-kind rule as `columnMediaType`, where it ranks below the URL's extension.
|
|
242
|
+
*/
|
|
243
|
+
export function listColumnMediaType(type: string | null | undefined, data: unknown, handle: string | null | undefined): string | undefined {
|
|
244
|
+
if (type !== "list" || data === null || typeof data !== "object") return undefined
|
|
245
|
+
const columns = field(data, "columns")
|
|
246
|
+
if (!Array.isArray(columns)) return undefined
|
|
247
|
+
const isColumn = (c: unknown): c is Record<string, unknown> => c !== null && typeof c === "object"
|
|
248
|
+
const column = columns.find((c) => isColumn(c) && c.handleId === handle) ?? columns[0]
|
|
249
|
+
const columnType = isColumn(column) ? column.type : undefined
|
|
250
|
+
return typeof columnType === "string" && Object.hasOwn(LIST_COLUMN_MEDIA, columnType) ? LIST_COLUMN_MEDIA[columnType] : undefined
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* A WIRED slot's layer as it is stored: the expanded layer `expanded`, minus an
|
|
255
|
+
* `animate` its writer did not set (`written`: the stored layer and the edit
|
|
256
|
+
* applied to it). A wired slot's kind is its wire's, known only where the wire
|
|
257
|
+
* is read — the run's assembly and the canvas stage — and the expansion there
|
|
258
|
+
* fills the fade default by that kind (on for an image, off for a video); a
|
|
259
|
+
* default stored here would fix one kind's default on the other, so a video
|
|
260
|
+
* wired in later would fade. `written` itself when the result has the same
|
|
261
|
+
* fields (an idempotent write); `expanded` by reference when nothing is removed.
|
|
262
|
+
*/
|
|
263
|
+
export function withoutImpliedVideoOverlayAnimate(
|
|
264
|
+
expanded: VideoOverlayLayerInput,
|
|
265
|
+
written: VideoOverlayLayerInput | null | undefined,
|
|
266
|
+
): VideoOverlayLayerInput {
|
|
267
|
+
if (written?.animate != null || expanded.animate === undefined) return expanded
|
|
268
|
+
const { animate: _implied, ...rest } = expanded
|
|
269
|
+
const fields = rest as Readonly<Record<string, unknown>>
|
|
270
|
+
const keys = Object.keys(fields)
|
|
271
|
+
const same = written != null && keys.length === Object.keys(written).length && keys.every((k) => fields[k] === (written as Readonly<Record<string, unknown>>)[k])
|
|
272
|
+
return same ? written : rest
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* A WIRED slot's layer as the run reads it when its wire is an image: without
|
|
277
|
+
* a stored `sound`. A wired slot's kind is its wire's, read at the run, so a
|
|
278
|
+
* sound set while the wire was a video (or before a List column's type, a
|
|
279
|
+
* dynamic source's output or an upstream re-run changed it) is skipped rather
|
|
280
|
+
* than refused: the run goes ahead, silent, and its fade default follows the
|
|
281
|
+
* image. Only the assembly calls this, for wired slots; a layer that carries
|
|
282
|
+
* its OWN image (the API, MCP, an unwired slot, a plan) keeps its sound and
|
|
283
|
+
* the validator refuses it (`sound_without_video`). By reference when there is
|
|
284
|
+
* no sound.
|
|
285
|
+
*/
|
|
286
|
+
export function withoutVideoOverlaySound<T extends VideoOverlayLayerInput>(layer: T): T {
|
|
287
|
+
if (!Object.hasOwn(layer, "sound")) return layer
|
|
288
|
+
const { sound: _skipped, ...rest } = layer
|
|
289
|
+
return rest as T
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* A layer without an empty-string `imageUrl` / `videoUrl`: every reader treats
|
|
294
|
+
* one as absent, and the REST route's URL schema refuses it, so the assembly
|
|
295
|
+
* drops it and a stored `{ imageUrl, videoUrl: "" }` runs as an image layer on
|
|
296
|
+
* both engines. By reference when it has none.
|
|
297
|
+
*/
|
|
298
|
+
export function withoutEmptyVideoOverlaySources<T extends VideoOverlayLayerInput>(layer: T): T {
|
|
299
|
+
if (layer.imageUrl !== "" && layer.videoUrl !== "") return layer
|
|
300
|
+
const out: Record<string, unknown> = { ...layer }
|
|
301
|
+
if (out.imageUrl === "") delete out.imageUrl
|
|
302
|
+
if (out.videoUrl === "") delete out.videoUrl
|
|
303
|
+
return out as T
|
|
304
|
+
}
|