@nodaro/shared 3.31.0 → 3.33.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/README.md +17 -0
- package/dist/chunk-23FJQTEA.js +1604 -0
- package/dist/chunk-23FJQTEA.js.map +1 -0
- package/dist/chunk-2NIQO2J3.cjs +54 -0
- package/dist/chunk-2NIQO2J3.cjs.map +1 -0
- package/dist/chunk-2NQLSLSN.cjs +19 -0
- package/dist/chunk-2NQLSLSN.cjs.map +1 -0
- package/dist/chunk-2OJIVO7R.cjs +32 -0
- package/dist/chunk-2OJIVO7R.cjs.map +1 -0
- package/dist/chunk-2RF4Z7KG.cjs +803 -0
- package/dist/chunk-2RF4Z7KG.cjs.map +1 -0
- package/dist/chunk-3RYKIUAE.js +86 -0
- package/dist/chunk-3RYKIUAE.js.map +1 -0
- package/dist/chunk-44I73CQS.cjs +194 -0
- package/dist/chunk-44I73CQS.cjs.map +1 -0
- package/dist/chunk-5PC6JBGJ.cjs +1419 -0
- package/dist/chunk-5PC6JBGJ.cjs.map +1 -0
- package/dist/chunk-5RU2HCW2.js +30 -0
- package/dist/chunk-5RU2HCW2.js.map +1 -0
- package/dist/chunk-5RYLK3MQ.js +267 -0
- package/dist/chunk-5RYLK3MQ.js.map +1 -0
- package/dist/chunk-5THUHJ3E.js +46 -0
- package/dist/chunk-5THUHJ3E.js.map +1 -0
- package/dist/chunk-6DAWSVX2.cjs +103 -0
- package/dist/chunk-6DAWSVX2.cjs.map +1 -0
- package/dist/chunk-6WZ2VN7V.js +920 -0
- package/dist/chunk-6WZ2VN7V.js.map +1 -0
- package/dist/chunk-7G7G42KS.js +86 -0
- package/dist/chunk-7G7G42KS.js.map +1 -0
- package/dist/chunk-7Z5LUTGU.js +1567 -0
- package/dist/chunk-7Z5LUTGU.js.map +1 -0
- package/dist/chunk-AINCI23X.js +2171 -0
- package/dist/chunk-AINCI23X.js.map +1 -0
- package/dist/chunk-BG5D5CZ6.js +1922 -0
- package/dist/chunk-BG5D5CZ6.js.map +1 -0
- package/dist/chunk-CK3GK34R.js +1381 -0
- package/dist/chunk-CK3GK34R.js.map +1 -0
- package/dist/chunk-CUH22J4D.js +17 -0
- package/dist/chunk-CUH22J4D.js.map +1 -0
- package/dist/chunk-D26ENTN2.cjs +1770 -0
- package/dist/chunk-D26ENTN2.cjs.map +1 -0
- package/dist/chunk-D6GNRSCV.cjs +2017 -0
- package/dist/chunk-D6GNRSCV.cjs.map +1 -0
- package/dist/chunk-FBV5DF6D.js +95 -0
- package/dist/chunk-FBV5DF6D.js.map +1 -0
- package/dist/chunk-FG4E7MTG.cjs +4 -0
- package/dist/chunk-FG4E7MTG.cjs.map +1 -0
- package/dist/chunk-FT5CF6IA.js +42 -0
- package/dist/chunk-FT5CF6IA.js.map +1 -0
- package/dist/chunk-G6IIVKMO.js +26 -0
- package/dist/chunk-G6IIVKMO.js.map +1 -0
- package/dist/chunk-HC7VKIV5.cjs +430 -0
- package/dist/chunk-HC7VKIV5.cjs.map +1 -0
- package/dist/chunk-HGC5JNVA.cjs +1503 -0
- package/dist/chunk-HGC5JNVA.cjs.map +1 -0
- package/dist/chunk-HKFMXNVQ.cjs +1273 -0
- package/dist/chunk-HKFMXNVQ.cjs.map +1 -0
- package/dist/chunk-HRXEZ3SX.cjs +526 -0
- package/dist/chunk-HRXEZ3SX.cjs.map +1 -0
- package/dist/chunk-HSHCCBIV.js +255 -0
- package/dist/chunk-HSHCCBIV.js.map +1 -0
- package/dist/chunk-HUR6ZJ7S.cjs +159 -0
- package/dist/chunk-HUR6ZJ7S.cjs.map +1 -0
- package/dist/chunk-J7BMO73N.cjs +114 -0
- package/dist/chunk-J7BMO73N.cjs.map +1 -0
- package/dist/chunk-JFS3NWZ5.cjs +1714 -0
- package/dist/chunk-JFS3NWZ5.cjs.map +1 -0
- package/dist/chunk-JL4C5VJ7.cjs +488 -0
- package/dist/chunk-JL4C5VJ7.cjs.map +1 -0
- package/dist/chunk-JSGIEF6Z.cjs +1087 -0
- package/dist/chunk-JSGIEF6Z.cjs.map +1 -0
- package/dist/chunk-JWA5SGCS.js +203 -0
- package/dist/chunk-JWA5SGCS.js.map +1 -0
- package/dist/chunk-K3LLGRK7.cjs +3545 -0
- package/dist/chunk-K3LLGRK7.cjs.map +1 -0
- package/dist/chunk-KU6S7IYV.cjs +210 -0
- package/dist/chunk-KU6S7IYV.cjs.map +1 -0
- package/dist/chunk-M36G6SRP.js +447 -0
- package/dist/chunk-M36G6SRP.js.map +1 -0
- package/dist/chunk-M7GQBRZU.cjs +1963 -0
- package/dist/chunk-M7GQBRZU.cjs.map +1 -0
- package/dist/chunk-MRXGWL42.cjs +4 -0
- package/dist/chunk-MRXGWL42.cjs.map +1 -0
- package/dist/chunk-NEJ2PV4C.cjs +211 -0
- package/dist/chunk-NEJ2PV4C.cjs.map +1 -0
- package/dist/chunk-OTATNBMD.js +141 -0
- package/dist/chunk-OTATNBMD.js.map +1 -0
- package/dist/chunk-OZSACQ2V.js +471 -0
- package/dist/chunk-OZSACQ2V.js.map +1 -0
- package/dist/chunk-PHZ23DP3.js +1782 -0
- package/dist/chunk-PHZ23DP3.js.map +1 -0
- package/dist/chunk-PQHS255G.js +1369 -0
- package/dist/chunk-PQHS255G.js.map +1 -0
- package/dist/chunk-PRYE7AZQ.cjs +1227 -0
- package/dist/chunk-PRYE7AZQ.cjs.map +1 -0
- package/dist/chunk-PVJBAPYJ.js +404 -0
- package/dist/chunk-PVJBAPYJ.js.map +1 -0
- package/dist/chunk-PXFQVLBX.js +776 -0
- package/dist/chunk-PXFQVLBX.js.map +1 -0
- package/dist/chunk-QA3MVQ32.js +21 -0
- package/dist/chunk-QA3MVQ32.js.map +1 -0
- package/dist/chunk-QJRP44ZO.js +769 -0
- package/dist/chunk-QJRP44ZO.js.map +1 -0
- package/dist/chunk-SAW5OK36.cjs +54 -0
- package/dist/chunk-SAW5OK36.cjs.map +1 -0
- package/dist/chunk-SES6GDBQ.cjs +624 -0
- package/dist/chunk-SES6GDBQ.cjs.map +1 -0
- package/dist/chunk-SFW3UB2P.js +31 -0
- package/dist/chunk-SFW3UB2P.js.map +1 -0
- package/dist/chunk-TNPDV7I4.cjs +2346 -0
- package/dist/chunk-TNPDV7I4.cjs.map +1 -0
- package/dist/chunk-TU33KYKW.cjs +25 -0
- package/dist/chunk-TU33KYKW.cjs.map +1 -0
- package/dist/chunk-TZBIY5C3.js +187 -0
- package/dist/chunk-TZBIY5C3.js.map +1 -0
- package/dist/chunk-TZE673G6.js +3 -0
- package/dist/chunk-TZE673G6.js.map +1 -0
- package/dist/chunk-UCFWI6D4.js +29 -0
- package/dist/chunk-UCFWI6D4.js.map +1 -0
- package/dist/chunk-UTQSSKSG.js +1164 -0
- package/dist/chunk-UTQSSKSG.js.map +1 -0
- package/dist/chunk-VA42637J.cjs +287 -0
- package/dist/chunk-VA42637J.cjs.map +1 -0
- package/dist/chunk-VNQRI2RO.cjs +1047 -0
- package/dist/chunk-VNQRI2RO.cjs.map +1 -0
- package/dist/chunk-VXPLKQWY.cjs +821 -0
- package/dist/chunk-VXPLKQWY.cjs.map +1 -0
- package/dist/chunk-WD6HJRBG.cjs +197 -0
- package/dist/chunk-WD6HJRBG.cjs.map +1 -0
- package/dist/chunk-WDIBOWAA.js +1054 -0
- package/dist/chunk-WDIBOWAA.js.map +1 -0
- package/dist/chunk-WKOIGLQX.cjs +38 -0
- package/dist/chunk-WKOIGLQX.cjs.map +1 -0
- package/dist/chunk-WNVQ3SMB.cjs +96 -0
- package/dist/chunk-WNVQ3SMB.cjs.map +1 -0
- package/dist/chunk-WRSWH7US.cjs +285 -0
- package/dist/chunk-WRSWH7US.cjs.map +1 -0
- package/dist/chunk-XGFTL5XY.js +181 -0
- package/dist/chunk-XGFTL5XY.js.map +1 -0
- package/dist/chunk-XNISPHTZ.js +1039 -0
- package/dist/chunk-XNISPHTZ.js.map +1 -0
- package/dist/chunk-Y2PM3FFL.js +3 -0
- package/dist/chunk-Y2PM3FFL.js.map +1 -0
- package/dist/chunk-YBPBK5KI.js +1030 -0
- package/dist/chunk-YBPBK5KI.js.map +1 -0
- package/dist/chunk-YWNYGYI7.cjs +31 -0
- package/dist/chunk-YWNYGYI7.cjs.map +1 -0
- package/dist/chunk-YYV35XOS.js +122 -0
- package/dist/chunk-YYV35XOS.js.map +1 -0
- package/dist/chunk-Z2OL5AJD.cjs +133 -0
- package/dist/chunk-Z2OL5AJD.cjs.map +1 -0
- package/dist/chunk-ZDFHA2EC.js +572 -0
- package/dist/chunk-ZDFHA2EC.js.map +1 -0
- package/dist/chunk-ZL7UM6PU.cjs +34 -0
- package/dist/chunk-ZL7UM6PU.cjs.map +1 -0
- package/dist/chunk-ZNZDQAXN.js +175 -0
- package/dist/chunk-ZNZDQAXN.js.map +1 -0
- package/dist/chunk-ZO5PBBFX.js +3497 -0
- package/dist/chunk-ZO5PBBFX.js.map +1 -0
- package/dist/chunk-ZRL2UFTH.cjs +1073 -0
- package/dist/chunk-ZRL2UFTH.cjs.map +1 -0
- package/dist/entries/apps.cjs +155 -0
- package/dist/entries/apps.cjs.map +1 -0
- package/dist/entries/apps.d.cts +292 -0
- package/dist/entries/apps.d.ts +292 -0
- package/dist/entries/apps.js +10 -0
- package/dist/entries/apps.js.map +1 -0
- package/dist/entries/captions.cjs +124 -0
- package/dist/entries/captions.cjs.map +1 -0
- package/dist/entries/captions.d.cts +354 -0
- package/dist/entries/captions.d.ts +354 -0
- package/dist/entries/captions.js +3 -0
- package/dist/entries/captions.js.map +1 -0
- package/dist/entries/catalogs.cjs +165 -0
- package/dist/entries/catalogs.cjs.map +1 -0
- package/dist/entries/catalogs.d.cts +385 -0
- package/dist/entries/catalogs.d.ts +385 -0
- package/dist/entries/catalogs.js +4 -0
- package/dist/entries/catalogs.js.map +1 -0
- package/dist/entries/credits.cjs +596 -0
- package/dist/entries/credits.cjs.map +1 -0
- package/dist/entries/credits.d.cts +1460 -0
- package/dist/entries/credits.d.ts +1460 -0
- package/dist/entries/credits.js +11 -0
- package/dist/entries/credits.js.map +1 -0
- package/dist/entries/edl.cjs +409 -0
- package/dist/entries/edl.cjs.map +1 -0
- package/dist/entries/edl.d.cts +1199 -0
- package/dist/entries/edl.d.ts +1199 -0
- package/dist/entries/edl.js +4 -0
- package/dist/entries/edl.js.map +1 -0
- package/dist/entries/entities.cjs +530 -0
- package/dist/entries/entities.cjs.map +1 -0
- package/dist/entries/entities.d.cts +1371 -0
- package/dist/entries/entities.d.ts +1371 -0
- package/dist/entries/entities.js +5 -0
- package/dist/entries/entities.js.map +1 -0
- package/dist/entries/i18n.cjs +48 -0
- package/dist/entries/i18n.cjs.map +1 -0
- package/dist/entries/i18n.d.cts +69 -0
- package/dist/entries/i18n.d.ts +69 -0
- package/dist/entries/i18n.js +3 -0
- package/dist/entries/i18n.js.map +1 -0
- package/dist/entries/llm-models.cjs +177 -0
- package/dist/entries/llm-models.cjs.map +1 -0
- package/dist/entries/llm-models.d.cts +435 -0
- package/dist/entries/llm-models.d.ts +435 -0
- package/dist/entries/llm-models.js +4 -0
- package/dist/entries/llm-models.js.map +1 -0
- package/dist/entries/media.cjs +335 -0
- package/dist/entries/media.cjs.map +1 -0
- package/dist/entries/media.d.cts +518 -0
- package/dist/entries/media.d.ts +518 -0
- package/dist/entries/media.js +6 -0
- package/dist/entries/media.js.map +1 -0
- package/dist/entries/model-catalog.cjs +259 -0
- package/dist/entries/model-catalog.cjs.map +1 -0
- package/dist/entries/model-catalog.d.cts +202 -0
- package/dist/entries/model-catalog.d.ts +202 -0
- package/dist/entries/model-catalog.js +6 -0
- package/dist/entries/model-catalog.js.map +1 -0
- package/dist/entries/models.cjs +833 -0
- package/dist/entries/models.cjs.map +1 -0
- package/dist/entries/models.d.cts +287 -0
- package/dist/entries/models.d.ts +287 -0
- package/dist/entries/models.js +8 -0
- package/dist/entries/models.js.map +1 -0
- package/dist/entries/nodes.cjs +789 -0
- package/dist/entries/nodes.cjs.map +1 -0
- package/dist/entries/nodes.d.cts +1600 -0
- package/dist/entries/nodes.d.ts +1600 -0
- package/dist/entries/nodes.js +16 -0
- package/dist/entries/nodes.js.map +1 -0
- package/dist/entries/organizations.cjs +80 -0
- package/dist/entries/organizations.cjs.map +1 -0
- package/dist/entries/organizations.d.cts +466 -0
- package/dist/entries/organizations.d.ts +466 -0
- package/dist/entries/organizations.js +3 -0
- package/dist/entries/organizations.js.map +1 -0
- package/dist/entries/pipeline.cjs +594 -0
- package/dist/entries/pipeline.cjs.map +1 -0
- package/dist/entries/pipeline.d.cts +2617 -0
- package/dist/entries/pipeline.d.ts +2617 -0
- package/dist/entries/pipeline.js +5 -0
- package/dist/entries/pipeline.js.map +1 -0
- package/dist/entries/scene3d.cjs +704 -0
- package/dist/entries/scene3d.cjs.map +1 -0
- package/dist/entries/scene3d.d.cts +4284 -0
- package/dist/entries/scene3d.d.ts +4284 -0
- package/dist/entries/scene3d.js +3 -0
- package/dist/entries/scene3d.js.map +1 -0
- package/dist/entries/social.cjs +714 -0
- package/dist/entries/social.cjs.map +1 -0
- package/dist/entries/social.d.cts +1366 -0
- package/dist/entries/social.d.ts +1366 -0
- package/dist/entries/social.js +5 -0
- package/dist/entries/social.js.map +1 -0
- package/dist/entries/types.cjs +13 -0
- package/dist/entries/types.cjs.map +1 -0
- package/dist/entries/types.d.cts +162 -0
- package/dist/entries/types.d.ts +162 -0
- package/dist/entries/types.js +4 -0
- package/dist/entries/types.js.map +1 -0
- package/dist/entries/ugc.cjs +279 -0
- package/dist/entries/ugc.cjs.map +1 -0
- package/dist/entries/ugc.d.cts +575 -0
- package/dist/entries/ugc.d.ts +575 -0
- package/dist/entries/ugc.js +6 -0
- package/dist/entries/ugc.js.map +1 -0
- package/dist/entries/video.cjs +549 -0
- package/dist/entries/video.cjs.map +1 -0
- package/dist/entries/video.d.cts +1791 -0
- package/dist/entries/video.d.ts +1791 -0
- package/dist/entries/video.js +8 -0
- package/dist/entries/video.js.map +1 -0
- package/dist/entries/workflow.cjs +574 -0
- package/dist/entries/workflow.cjs.map +1 -0
- package/dist/entries/workflow.d.cts +1743 -0
- package/dist/entries/workflow.d.ts +1743 -0
- package/dist/entries/workflow.js +5 -0
- package/dist/entries/workflow.js.map +1 -0
- package/dist/fan-out-meta-Bu6VyXcZ.d.cts +19 -0
- package/dist/fan-out-meta-Bu6VyXcZ.d.ts +19 -0
- package/dist/gemini-omni-voices-zeRXxSbZ.d.cts +174 -0
- package/dist/gemini-omni-voices-zeRXxSbZ.d.ts +174 -0
- package/dist/image-overlay-layers-CyBfRhxJ.d.cts +208 -0
- package/dist/image-overlay-layers-CyBfRhxJ.d.ts +208 -0
- package/dist/index.cjs +7747 -27084
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -24198
- package/dist/index.d.ts +32 -24198
- package/dist/index.js +40 -25220
- package/dist/index.js.map +1 -1
- package/dist/model-catalog-V-ZNzRSd.d.cts +651 -0
- package/dist/model-catalog-V-ZNzRSd.d.ts +651 -0
- package/dist/presentation-types-0ENOCjoj.d.cts +61 -0
- package/dist/presentation-types-0ENOCjoj.d.ts +61 -0
- package/dist/presentation-utils-D0kxsWf9.d.cts +92 -0
- package/dist/presentation-utils-pZwlEAzo.d.ts +92 -0
- package/dist/scene-node-types-C3kl_zyK.d.cts +1949 -0
- package/dist/scene-node-types-C3kl_zyK.d.ts +1949 -0
- package/dist/supported-fonts-CRoF1gOy.d.cts +16 -0
- package/dist/supported-fonts-CRoF1gOy.d.ts +16 -0
- package/dist/types-BRlFPEru.d.cts +511 -0
- package/dist/types-BRlFPEru.d.ts +511 -0
- package/dist/types-DffyGSy5.d.cts +67 -0
- package/dist/types-DffyGSy5.d.ts +67 -0
- package/package.json +102 -1
- package/src/__tests__/add-captions-plan.test.ts +6 -2
- package/src/__tests__/caption-edge-dash.test.ts +23 -0
- package/src/__tests__/fixtures/root-exports.baseline.json +4625 -0
- package/src/__tests__/input-field-extra-keys.test.ts +1 -0
- package/src/__tests__/model-makers.test.ts +76 -0
- package/src/__tests__/no-internal-imports.test.ts +1 -1
- package/src/__tests__/node-aspect-ratio.test.ts +25 -0
- package/src/__tests__/node-runtime-keys.test.ts +9 -0
- package/src/__tests__/package-entries.test.ts +50 -0
- package/src/__tests__/pitch-tempo-pricing.test.ts +21 -0
- package/src/__tests__/presentation-utils.test.ts +15 -0
- package/src/__tests__/preview-gate-use-case.test.ts +151 -0
- package/src/__tests__/private-host.test.ts +53 -0
- package/src/__tests__/run-continuation.test.ts +7 -1
- package/src/__tests__/site-capture-node.test.ts +58 -0
- package/src/__tests__/ugc-lane-wires.test.ts +228 -0
- package/src/__tests__/ugc-node-wires.test.ts +9 -3
- package/src/__tests__/ugc-run-state.test.ts +5 -4
- package/src/__tests__/video-analysis-catalog-sync.test.ts +1 -1
- package/src/__tests__/video-analysis-pricing.test.ts +6 -6
- package/src/__tests__/voice-changer-pro-quote.test.ts +79 -0
- package/src/add-captions-plan.ts +9 -3
- package/src/caption-edge-dash.ts +33 -0
- package/src/component-types.ts +9 -0
- package/src/credit-estimators/index.ts +22 -1
- package/src/credit-estimators/pitch-tempo.ts +15 -1
- package/src/credit-estimators/speech.ts +72 -4
- package/src/credit-estimators/unit-quote.ts +52 -0
- package/src/credit-estimators/video-sfx.ts +15 -0
- package/src/credit-estimators/voice-changer-pro-quote.ts +138 -0
- package/src/credit-identifiers.ts +62 -17
- package/src/entity-image-handle.ts +2 -0
- package/src/entries/apps.ts +63 -0
- package/src/entries/captions.ts +34 -0
- package/src/entries/catalogs.ts +65 -0
- package/src/entries/credits.ts +105 -0
- package/src/entries/edl.ts +42 -0
- package/src/entries/entities.ts +144 -0
- package/src/entries/i18n.ts +31 -0
- package/src/entries/llm-models.ts +63 -0
- package/src/entries/media.ts +36 -0
- package/src/entries/model-catalog.ts +95 -0
- package/src/entries/models.ts +266 -0
- package/src/entries/nodes.ts +245 -0
- package/src/entries/organizations.ts +9 -0
- package/src/entries/pipeline.ts +43 -0
- package/src/entries/scene3d.ts +27 -0
- package/src/entries/social.ts +297 -0
- package/src/entries/types.ts +26 -0
- package/src/entries/ugc.ts +14 -0
- package/src/entries/video.ts +59 -0
- package/src/entries/workflow.ts +172 -0
- package/src/fan-out-rows.ts +2 -0
- package/src/index.ts +25 -1845
- package/src/json-kinds.ts +4 -0
- package/src/model-catalog.ts +243 -34
- package/src/node-mappable-fields.ts +1 -0
- package/src/node-run-routes.ts +2 -0
- package/src/node-runtime-keys.ts +8 -0
- package/src/normalize-node-params.ts +30 -0
- package/src/presentation-utils.ts +12 -0
- package/src/preview-gate.ts +92 -14
- package/src/private-host.ts +89 -59
- package/src/producer-types.ts +16 -2
- package/src/run-continuation.ts +21 -0
- package/src/site-capture-node.ts +82 -0
- package/src/ugc-lane-wires.ts +246 -0
- package/src/ugc-node-wires.ts +37 -7
- package/src/ugc-run-state.ts +5 -3
- package/src/video-analysis-pricing.ts +31 -29
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var zod = require('zod');
|
|
4
|
+
|
|
5
|
+
// src/caption-styles.ts
|
|
6
|
+
var STATIC_CAPTION_STYLES = ["subtitle"];
|
|
7
|
+
var KINETIC_CAPTION_STYLES = [
|
|
8
|
+
"word-highlight",
|
|
9
|
+
"karaoke",
|
|
10
|
+
"tiktok-words",
|
|
11
|
+
"word-pop",
|
|
12
|
+
"bouncy"
|
|
13
|
+
];
|
|
14
|
+
var ALL_CAPTION_STYLES = [...STATIC_CAPTION_STYLES, ...KINETIC_CAPTION_STYLES];
|
|
15
|
+
var KINETIC_SET = new Set(KINETIC_CAPTION_STYLES);
|
|
16
|
+
function isKineticCaptionStyle(style) {
|
|
17
|
+
return style !== null && style !== void 0 && KINETIC_SET.has(style);
|
|
18
|
+
}
|
|
19
|
+
var CAPTION_LOOK_IDS = ["outline", "clean"];
|
|
20
|
+
var DEFAULT_CAPTION_LOOK = "outline";
|
|
21
|
+
var DEFAULT_SUBTITLE_LOOK = "clean";
|
|
22
|
+
var KINETIC_ONLY_CAPTION_LEVER_KEYS = [
|
|
23
|
+
"highlightColor",
|
|
24
|
+
"animate"
|
|
25
|
+
];
|
|
26
|
+
function captionRoutesToRemotion(input) {
|
|
27
|
+
if (input.segments && input.segments.length > 0) return true;
|
|
28
|
+
if (isKineticCaptionStyle(input.style)) return true;
|
|
29
|
+
const isSet = (v) => v !== void 0 && v !== null;
|
|
30
|
+
const hasStylingLever = isSet(input.look) || isSet(input.fontFamily) || isSet(input.fontWeight) || isSet(input.strokeColor) || isSet(input.strokeWidth) || isSet(input.uppercase) || isSet(input.positionY) || isSet(input.maxWordsPerLine);
|
|
31
|
+
if (hasStylingLever) return true;
|
|
32
|
+
if (input.transcript !== void 0 && input.transcript !== null) return true;
|
|
33
|
+
if (input.captions && input.captions.length > 0) return true;
|
|
34
|
+
if (!input.text) return true;
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
var CAPTION_MAX_WORDS_PER_LINE_MIN = 1;
|
|
38
|
+
var CAPTION_MAX_WORDS_PER_LINE_MAX = 20;
|
|
39
|
+
var CAPTION_LEVER_BOUNDS = {
|
|
40
|
+
fontSize: { min: 12, max: 200 },
|
|
41
|
+
strokeWidth: { min: 0, max: 40 },
|
|
42
|
+
positionY: { min: 0, max: 100 },
|
|
43
|
+
fontWeight: { min: 100, max: 900 },
|
|
44
|
+
maxWordsPerLine: { min: CAPTION_MAX_WORDS_PER_LINE_MIN, max: CAPTION_MAX_WORDS_PER_LINE_MAX }
|
|
45
|
+
};
|
|
46
|
+
var CAPTION_NUMERIC_LEVER_KEYS = Object.keys(CAPTION_LEVER_BOUNDS);
|
|
47
|
+
function normalizeCaptionNumericLevers(input) {
|
|
48
|
+
const out = { ...input };
|
|
49
|
+
for (const key of CAPTION_NUMERIC_LEVER_KEYS) {
|
|
50
|
+
if (!(key in out) || out[key] === void 0) continue;
|
|
51
|
+
if (out[key] === null) {
|
|
52
|
+
delete out[key];
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const raw = typeof out[key] === "string" && out[key].trim() !== "" ? Number(out[key]) : out[key];
|
|
56
|
+
if (typeof raw !== "number" || !Number.isFinite(raw)) {
|
|
57
|
+
delete out[key];
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const { min, max } = CAPTION_LEVER_BOUNDS[key];
|
|
61
|
+
const shaped = key === "fontWeight" ? Math.round(raw / 100) * 100 : key === "maxWordsPerLine" ? Math.round(raw) : raw;
|
|
62
|
+
out[key] = Math.min(max, Math.max(min, shaped));
|
|
63
|
+
}
|
|
64
|
+
return out;
|
|
65
|
+
}
|
|
66
|
+
function autoStrokeWidth(fontSize) {
|
|
67
|
+
return Math.max(2, Math.round(fontSize * 0.1));
|
|
68
|
+
}
|
|
69
|
+
var CAPTION_LOOKS = {
|
|
70
|
+
// The TikTok / CapCut read: heavy geometric sans, caps, white on a thick black
|
|
71
|
+
// outline, yellow spoken word.
|
|
72
|
+
outline: (fs) => ({
|
|
73
|
+
fontFamily: "Montserrat",
|
|
74
|
+
fontWeight: 900,
|
|
75
|
+
uppercase: true,
|
|
76
|
+
color: "#ffffff",
|
|
77
|
+
strokeColor: "#000000",
|
|
78
|
+
strokeWidth: autoStrokeWidth(fs),
|
|
79
|
+
highlightColor: "#FFE600"
|
|
80
|
+
}),
|
|
81
|
+
// The pre-look lever set with the face pinned (it never was): per-style weight,
|
|
82
|
+
// soft shadow only, no casing, no outline.
|
|
83
|
+
clean: () => ({ fontFamily: "Inter", color: "#ffffff" })
|
|
84
|
+
};
|
|
85
|
+
function resolveCaptionLook(look, explicit, fontSize) {
|
|
86
|
+
const preset = CAPTION_LOOKS[look ?? DEFAULT_CAPTION_LOOK] ?? CAPTION_LOOKS[DEFAULT_CAPTION_LOOK];
|
|
87
|
+
const out = { ...preset(fontSize) };
|
|
88
|
+
for (const k of Object.keys(explicit)) {
|
|
89
|
+
if (explicit[k] !== void 0) out[k] = explicit[k];
|
|
90
|
+
}
|
|
91
|
+
return out;
|
|
92
|
+
}
|
|
93
|
+
function resolveCaptionLevers(style, look, explicit, fontSize) {
|
|
94
|
+
const effective = look ?? (isKineticCaptionStyle(style) ? DEFAULT_CAPTION_LOOK : DEFAULT_SUBTITLE_LOOK);
|
|
95
|
+
return resolveCaptionLook(effective, explicit, fontSize);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// src/caption-plan.ts
|
|
99
|
+
var nonNegative = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0;
|
|
100
|
+
function parseCaptionPlan(raw) {
|
|
101
|
+
let value = raw;
|
|
102
|
+
if (typeof raw === "string") {
|
|
103
|
+
try {
|
|
104
|
+
value = JSON.parse(raw);
|
|
105
|
+
} catch {
|
|
106
|
+
return { error: "Caption plan: not valid JSON." };
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return { error: "Caption plan: not an object." };
|
|
110
|
+
const o = value;
|
|
111
|
+
if (o.v !== 1) return { error: "Caption plan: v must be 1." };
|
|
112
|
+
if (typeof o.hookText !== "string") return { error: "Caption plan: hookText must be text." };
|
|
113
|
+
for (const f of ["hookEndMs", "bodyEndMs"]) {
|
|
114
|
+
if (!nonNegative(o[f])) return { error: `Caption plan: ${f} must be a non-negative number.` };
|
|
115
|
+
}
|
|
116
|
+
if (o.videoDurationMs !== void 0 && !nonNegative(o.videoDurationMs)) {
|
|
117
|
+
return { error: "Caption plan: videoDurationMs must be a non-negative number." };
|
|
118
|
+
}
|
|
119
|
+
if (o.language !== void 0 && typeof o.language !== "string") return { error: "Caption plan: language must be text." };
|
|
120
|
+
if (!Array.isArray(o.captions)) return { error: "Caption plan: captions must be a list." };
|
|
121
|
+
const captions = [];
|
|
122
|
+
for (let i = 0; i < o.captions.length; i++) {
|
|
123
|
+
const c = o.captions[i];
|
|
124
|
+
if (!c || typeof c !== "object" || typeof c.text !== "string" || !nonNegative(c.startMs) || !nonNegative(c.endMs)) {
|
|
125
|
+
return { error: `Caption plan: captions[${i}] needs text, startMs and endMs.` };
|
|
126
|
+
}
|
|
127
|
+
if (c.endMs < c.startMs) return { error: `Caption plan: captions[${i}] ends before it starts.` };
|
|
128
|
+
captions.push({ text: c.text, startMs: c.startMs, endMs: c.endMs });
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
plan: {
|
|
132
|
+
v: 1,
|
|
133
|
+
hookText: o.hookText,
|
|
134
|
+
hookEndMs: o.hookEndMs,
|
|
135
|
+
bodyEndMs: o.bodyEndMs,
|
|
136
|
+
captions,
|
|
137
|
+
...o.videoDurationMs !== void 0 ? { videoDurationMs: o.videoDurationMs } : {},
|
|
138
|
+
...o.language !== void 0 ? { language: o.language } : {}
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// src/supported-fonts.ts
|
|
144
|
+
var SUPPORTED_FONT_NAMES = [
|
|
145
|
+
"Inter",
|
|
146
|
+
"Roboto",
|
|
147
|
+
"Open Sans",
|
|
148
|
+
"Montserrat",
|
|
149
|
+
"Poppins",
|
|
150
|
+
"Raleway",
|
|
151
|
+
"Nunito",
|
|
152
|
+
"Lato",
|
|
153
|
+
"Playfair Display",
|
|
154
|
+
"Merriweather",
|
|
155
|
+
"Lora",
|
|
156
|
+
"EB Garamond",
|
|
157
|
+
"Bebas Neue",
|
|
158
|
+
"Oswald",
|
|
159
|
+
"Anton",
|
|
160
|
+
"Dancing Script",
|
|
161
|
+
"Pacifico",
|
|
162
|
+
"Caveat",
|
|
163
|
+
"Roboto Mono",
|
|
164
|
+
"Fira Code",
|
|
165
|
+
"Rubik",
|
|
166
|
+
"Heebo",
|
|
167
|
+
"Cairo",
|
|
168
|
+
"Tajawal"
|
|
169
|
+
];
|
|
170
|
+
|
|
171
|
+
// src/caption-segment-schema.ts
|
|
172
|
+
var captionFontWeightSchema = zod.z.number().int().min(100).max(900).multipleOf(100);
|
|
173
|
+
var nonBlankCaptionText = zod.z.string().min(1).refine((t) => /\S/.test(t), { message: "text must contain a non-whitespace character" });
|
|
174
|
+
var captionInputSchema = zod.z.object({
|
|
175
|
+
text: zod.z.string(),
|
|
176
|
+
// startMs/endMs are the visibility window and drive the highlight; timestampMs
|
|
177
|
+
// is the word timestamp used by tiktok-words token timing; confidence is
|
|
178
|
+
// metadata, ignored by rendering. timestampMs/confidence default to null.
|
|
179
|
+
startMs: zod.z.number().min(0),
|
|
180
|
+
endMs: zod.z.number().min(0),
|
|
181
|
+
timestampMs: zod.z.number().min(0).nullable().default(null),
|
|
182
|
+
confidence: zod.z.number().min(0).max(1).nullable().default(null)
|
|
183
|
+
});
|
|
184
|
+
var captionSegmentInputSchema = zod.z.object({
|
|
185
|
+
startMs: zod.z.number().min(0),
|
|
186
|
+
endMs: zod.z.number().min(0),
|
|
187
|
+
style: zod.z.enum(ALL_CAPTION_STYLES).optional(),
|
|
188
|
+
position: zod.z.enum(["bottom", "top", "center"]).optional(),
|
|
189
|
+
fontSize: zod.z.number().min(12).max(200).optional(),
|
|
190
|
+
color: zod.z.string().optional(),
|
|
191
|
+
backgroundColor: zod.z.string().optional(),
|
|
192
|
+
// A named look preset (outline/clean); explicit levers below override it.
|
|
193
|
+
look: zod.z.enum(CAPTION_LOOK_IDS).optional(),
|
|
194
|
+
fontFamily: zod.z.enum(SUPPORTED_FONT_NAMES).optional(),
|
|
195
|
+
fontWeight: captionFontWeightSchema.optional(),
|
|
196
|
+
strokeColor: zod.z.string().optional(),
|
|
197
|
+
strokeWidth: zod.z.number().min(0).max(40).optional(),
|
|
198
|
+
highlightColor: zod.z.string().optional(),
|
|
199
|
+
uppercase: zod.z.boolean().optional(),
|
|
200
|
+
positionY: zod.z.number().min(0).max(100).optional(),
|
|
201
|
+
animate: zod.z.boolean().optional(),
|
|
202
|
+
maxWordsPerLine: zod.z.number().int().min(CAPTION_MAX_WORDS_PER_LINE_MIN).max(CAPTION_MAX_WORDS_PER_LINE_MAX).optional(),
|
|
203
|
+
text: nonBlankCaptionText.optional(),
|
|
204
|
+
captions: zod.z.array(captionInputSchema).optional()
|
|
205
|
+
}).refine((s) => s.endMs > s.startMs, { message: "segment endMs must be greater than startMs" });
|
|
206
|
+
var CAPTION_SEGMENT_SCHEMA_KEYS = Object.keys(captionSegmentInputSchema.shape);
|
|
207
|
+
function findSegmentOverlap(segments) {
|
|
208
|
+
const sorted = [...segments].sort((a, b) => a.startMs - b.startMs);
|
|
209
|
+
for (let i = 1; i < sorted.length; i++) {
|
|
210
|
+
if (sorted[i].startMs < sorted[i - 1].endMs) {
|
|
211
|
+
return `segments overlap: [${sorted[i - 1].startMs}, ${sorted[i - 1].endMs}) and [${sorted[i].startMs}, ${sorted[i].endMs})`;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// src/caption-edge-dash.ts
|
|
218
|
+
var BARE_DASH = /^[-‐-―−־﹘﹣-]+$/u;
|
|
219
|
+
function isBareDashToken(text) {
|
|
220
|
+
return BARE_DASH.test(text.trim());
|
|
221
|
+
}
|
|
222
|
+
function trimEdgeDashTokens(items, textOf) {
|
|
223
|
+
let start = 0;
|
|
224
|
+
let end = items.length;
|
|
225
|
+
while (start < end && isBareDashToken(textOf(items[start]))) start++;
|
|
226
|
+
while (end > start && isBareDashToken(textOf(items[end - 1]))) end--;
|
|
227
|
+
return items.slice(start, end);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// src/add-captions-plan.ts
|
|
231
|
+
function captionPlanBodyLevers(nodeData, leverKeys) {
|
|
232
|
+
const levers = {};
|
|
233
|
+
for (const k of leverKeys) {
|
|
234
|
+
const v = nodeData[k];
|
|
235
|
+
if (v !== void 0 && v !== null) levers[k] = v;
|
|
236
|
+
}
|
|
237
|
+
return Object.keys(levers).length > 0 ? levers : void 0;
|
|
238
|
+
}
|
|
239
|
+
function styleCaptionPlan(raw, nodeData, styler) {
|
|
240
|
+
const parsed = parseCaptionPlan(raw);
|
|
241
|
+
if ("error" in parsed) return { error: parsed.error };
|
|
242
|
+
const bodyLevers = captionPlanBodyLevers(nodeData, styler.leverKeys);
|
|
243
|
+
const styled = styler.segmentsFor(parsed.plan, bodyLevers ? { bodyLevers } : void 0).segments;
|
|
244
|
+
const segments = [];
|
|
245
|
+
for (let i = 0; i < styled.length; i++) {
|
|
246
|
+
const r = captionSegmentInputSchema.safeParse(styled[i]);
|
|
247
|
+
if (!r.success) return { error: `Caption plan: segment ${i + 1}: ${r.error.issues[0]?.message ?? "invalid"}.` };
|
|
248
|
+
segments.push(r.data);
|
|
249
|
+
}
|
|
250
|
+
const overlap = findSegmentOverlap(segments);
|
|
251
|
+
if (overlap) return { error: `Caption plan: ${overlap}.` };
|
|
252
|
+
return { segments };
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
exports.ALL_CAPTION_STYLES = ALL_CAPTION_STYLES;
|
|
256
|
+
exports.CAPTION_LEVER_BOUNDS = CAPTION_LEVER_BOUNDS;
|
|
257
|
+
exports.CAPTION_LOOKS = CAPTION_LOOKS;
|
|
258
|
+
exports.CAPTION_LOOK_IDS = CAPTION_LOOK_IDS;
|
|
259
|
+
exports.CAPTION_MAX_WORDS_PER_LINE_MAX = CAPTION_MAX_WORDS_PER_LINE_MAX;
|
|
260
|
+
exports.CAPTION_MAX_WORDS_PER_LINE_MIN = CAPTION_MAX_WORDS_PER_LINE_MIN;
|
|
261
|
+
exports.CAPTION_SEGMENT_SCHEMA_KEYS = CAPTION_SEGMENT_SCHEMA_KEYS;
|
|
262
|
+
exports.DEFAULT_CAPTION_LOOK = DEFAULT_CAPTION_LOOK;
|
|
263
|
+
exports.DEFAULT_SUBTITLE_LOOK = DEFAULT_SUBTITLE_LOOK;
|
|
264
|
+
exports.KINETIC_CAPTION_STYLES = KINETIC_CAPTION_STYLES;
|
|
265
|
+
exports.KINETIC_ONLY_CAPTION_LEVER_KEYS = KINETIC_ONLY_CAPTION_LEVER_KEYS;
|
|
266
|
+
exports.STATIC_CAPTION_STYLES = STATIC_CAPTION_STYLES;
|
|
267
|
+
exports.SUPPORTED_FONT_NAMES = SUPPORTED_FONT_NAMES;
|
|
268
|
+
exports.autoStrokeWidth = autoStrokeWidth;
|
|
269
|
+
exports.captionFontWeightSchema = captionFontWeightSchema;
|
|
270
|
+
exports.captionInputSchema = captionInputSchema;
|
|
271
|
+
exports.captionPlanBodyLevers = captionPlanBodyLevers;
|
|
272
|
+
exports.captionRoutesToRemotion = captionRoutesToRemotion;
|
|
273
|
+
exports.captionSegmentInputSchema = captionSegmentInputSchema;
|
|
274
|
+
exports.findSegmentOverlap = findSegmentOverlap;
|
|
275
|
+
exports.isBareDashToken = isBareDashToken;
|
|
276
|
+
exports.isKineticCaptionStyle = isKineticCaptionStyle;
|
|
277
|
+
exports.nonBlankCaptionText = nonBlankCaptionText;
|
|
278
|
+
exports.normalizeCaptionNumericLevers = normalizeCaptionNumericLevers;
|
|
279
|
+
exports.parseCaptionPlan = parseCaptionPlan;
|
|
280
|
+
exports.resolveCaptionLevers = resolveCaptionLevers;
|
|
281
|
+
exports.resolveCaptionLook = resolveCaptionLook;
|
|
282
|
+
exports.styleCaptionPlan = styleCaptionPlan;
|
|
283
|
+
exports.trimEdgeDashTokens = trimEdgeDashTokens;
|
|
284
|
+
//# sourceMappingURL=chunk-WRSWH7US.cjs.map
|
|
285
|
+
//# sourceMappingURL=chunk-WRSWH7US.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/caption-styles.ts","../src/caption-plan.ts","../src/supported-fonts.ts","../src/caption-segment-schema.ts","../src/caption-edge-dash.ts","../src/add-captions-plan.ts"],"names":["z"],"mappings":";;;;;AAcO,IAAM,qBAAA,GAAwB,CAAC,UAAU;AACzC,IAAM,sBAAA,GAAyB;AAAA,EACpC,gBAAA;AAAA,EACA,SAAA;AAAA,EACA,cAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF;AACO,IAAM,kBAAA,GAAqB,CAAC,GAAG,qBAAA,EAAuB,GAAG,sBAAsB;AAMtF,IAAM,WAAA,GAAc,IAAI,GAAA,CAAY,sBAAsB,CAAA;AAEnD,S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CAAA,CAAA,EAAI;AAC9G,IAAA,QAAA,CAAS,IAAA,CAAK,EAAE,IAAI,CAAA;AAAA,EACtB;AACA,EAAA,MAAM,OAAA,GAAU,mBAAmB,QAAgD,CAAA;AACnF,EAAA,IAAI,SAAS,OAAO,EAAE,KAAA,EAAO,CAAA,cAAA,EAAiB,OAAO,CAAA,CAAA,CAAA,EAAI;AACzD,EAAA,OAAO,EAAE,QAAA,EAAS;AACpB","file":"chunk-WRSWH7US.cjs","sourcesContent":["import type { SupportedFontName } from \"./supported-fonts.js\"\n\n/**\n * Caption styles for the add-captions node. Static path uses FFmpeg drawtext;\n * kinetic styles render via Remotion (BurnCaptions composition).\n *\n * Single source of truth — imported by:\n * - backend route Zod (add-captions.ts)\n * - backend worker handler (ffmpeg.ts)\n * - backend MCP tool (verbs-video.ts)\n * - backend plan schema (plan-schemas.ts)\n * - frontend node config + cost helper\n * - packages/remotion overlay dispatcher\n */\nexport const STATIC_CAPTION_STYLES = [\"subtitle\"] as const\nexport const KINETIC_CAPTION_STYLES = [\n \"word-highlight\",\n \"karaoke\",\n \"tiktok-words\",\n \"word-pop\",\n \"bouncy\",\n] as const\nexport const ALL_CAPTION_STYLES = [...STATIC_CAPTION_STYLES, ...KINETIC_CAPTION_STYLES] as const\n\nexport type StaticCaptionStyle = (typeof STATIC_CAPTION_STYLES)[number]\nexport type KineticCaptionStyle = (typeof KINETIC_CAPTION_STYLES)[number]\nexport type CaptionStyle = (typeof ALL_CAPTION_STYLES)[number]\n\nconst KINETIC_SET = new Set<string>(KINETIC_CAPTION_STYLES)\n\nexport function isKineticCaptionStyle(style: string | undefined | null): style is KineticCaptionStyle {\n return style !== null && style !== undefined && KINETIC_SET.has(style)\n}\n\n// ── Named \"looks\" ──────────────────────────────────────────────────────────\n// A look is a bundle of visual levers so a caption reads well with one field\n// instead of eight. Shared because the ids are wire contract (route Zod, MCP\n// schema, SDK type) and the value table is consumed by BOTH the worker (render)\n// and the canvas preview — deliberately given away, not creative doctrine.\nexport const CAPTION_LOOK_IDS = [\"outline\", \"clean\"] as const\nexport type CaptionLookId = (typeof CAPTION_LOOK_IDS)[number]\n\n/** What an unset `look` means on a KINETIC style. ONE-LINE FLIP: set to \"clean\"\n * to make an unset caption render as the pre-look-system lever set (face pinned)\n * instead. */\nexport const DEFAULT_CAPTION_LOOK: CaptionLookId = \"outline\"\n\n/** What an unset `look` means on the static `subtitle` style: the plain read —\n * a pinned neutral sans, no outline, no casing. A subtitle must never be left\n * with NO face: the Remotion render would fall back to headless Chrome's default\n * SERIF, so adding e.g. a stroke to a subtitle would silently flip its font away\n * from the sans the plain FFmpeg subtitle draws. */\nexport const DEFAULT_SUBTITLE_LOOK: CaptionLookId = \"clean\"\n\n/**\n * The lever field names that are MEANINGLESS on a `subtitle` render and so are\n * rejected on it: `highlightColor` (subtitle has no per-word spoken cursor to\n * colour) and `animate` (subtitle has no motion to switch off). The STYLING\n * levers (look/fontFamily/fontWeight/strokeColor/strokeWidth/uppercase/positionY)\n * are NOT here any more — a `subtitle` carrying any of them now routes to the\n * Remotion renderer (see `captionRoutesToRemotion`), which applies them exactly\n * as it does for the kinetic styles. Single source of truth for the route's\n * reject-on-subtitle guard and the frontend's \"don't send a stale lever\" strip.\n * `color`/`backgroundColor` are deliberately absent — FFmpeg subtitle honours\n * those too.\n */\nexport const KINETIC_ONLY_CAPTION_LEVER_KEYS = [\n \"highlightColor\",\n \"animate\",\n] as const\nexport type KineticOnlyCaptionLeverKey = (typeof KINETIC_ONLY_CAPTION_LEVER_KEYS)[number]\n\n/**\n * Does an add-captions request need the Remotion renderer, vs the cheap static\n * FFmpeg drawtext path? A caption routes to Remotion when it needs anything the\n * one-fixed-string drawtext pass cannot do:\n * - per-segment treatments (`segments`),\n * - a kinetic style,\n * - any STYLING lever (look/font/weight/stroke/uppercase/position_y/\n * max_words_per_line) — FFmpeg drawtext can't apply a webfont face, weight,\n * outline, casing, a free vertical position, or line grouping,\n * - TIMED captions (a wired `transcript` or an explicit `captions[]` array),\n * - auto-transcription, i.e. no `text` to burn as one static block.\n * Plain-`text` `subtitle` with no lever stays on FFmpeg (unchanged, cheap).\n *\n * SINGLE SOURCE for BOTH the worker dispatch (handleAddCaptions) AND the credit\n * id (buildAddCaptionsCreditId) so the renderer and the price never drift: a\n * Remotion render bills as `add-captions:kinetic`, a plain drawtext burn as\n * `add-captions`.\n */\nexport function captionRoutesToRemotion(input: {\n style?: string | null\n text?: string | null\n segments?: readonly unknown[] | null\n transcript?: unknown\n captions?: readonly unknown[] | null\n look?: unknown\n fontFamily?: unknown\n fontWeight?: unknown\n strokeColor?: unknown\n strokeWidth?: unknown\n uppercase?: unknown\n positionY?: unknown\n maxWordsPerLine?: unknown\n}): boolean {\n if (input.segments && input.segments.length > 0) return true\n if (isKineticCaptionStyle(input.style)) return true\n // From here the style is `subtitle` (or unset → the subtitle default).\n // `null` is \"not set\", exactly like `undefined`: stored node JSON (an agent's\n // write, an import, a cleared field) carries nulls, and a null lever that\n // counted as a lever would route a plain subtitle to Remotion — and its price\n // — for a lever nobody chose.\n const isSet = (v: unknown): boolean => v !== undefined && v !== null\n const hasStylingLever =\n isSet(input.look) ||\n isSet(input.fontFamily) ||\n isSet(input.fontWeight) ||\n isSet(input.strokeColor) ||\n isSet(input.strokeWidth) ||\n isSet(input.uppercase) ||\n isSet(input.positionY) ||\n isSet(input.maxWordsPerLine)\n if (hasStylingLever) return true\n if (input.transcript !== undefined && input.transcript !== null) return true\n if (input.captions && input.captions.length > 0) return true\n // No `text` to burn as one static block → the only caption source is\n // transcription, which produces TIMED captions the drawtext pass can't show.\n if (!input.text) return true\n return false\n}\n\n/**\n * `maxWordsPerLine` — caps how many words a caption LINE (or tiktok-words page)\n * may hold, on top of the frame-width budget, sentence ends and pauses that\n * already close a line. 1–2 gives the punchy CapCut read; unset = fit the width.\n * Applies to every line/page-grouped render (word-highlight, karaoke, bouncy,\n * tiktok-words, and a Remotion-rendered subtitle); inert on word-pop (always one\n * word). Bounds single-sourced here for the route Zod, the plan schema, the MCP\n * schema, the CLI and the canvas panel.\n */\nexport const CAPTION_MAX_WORDS_PER_LINE_MIN = 1\nexport const CAPTION_MAX_WORDS_PER_LINE_MAX = 20\n\n/**\n * Numeric caption levers and their wire bounds — the SAME limits the route Zod\n * and the render-plan schema enforce. Single-sourced so the coercion below and\n * those schemas cannot disagree (a guard test pins the route to these).\n */\nexport const CAPTION_LEVER_BOUNDS = {\n fontSize: { min: 12, max: 200 },\n strokeWidth: { min: 0, max: 40 },\n positionY: { min: 0, max: 100 },\n fontWeight: { min: 100, max: 900 },\n maxWordsPerLine: { min: CAPTION_MAX_WORDS_PER_LINE_MIN, max: CAPTION_MAX_WORDS_PER_LINE_MAX },\n} as const\n\ntype CaptionNumericLeverKey = keyof typeof CAPTION_LEVER_BOUNDS\nconst CAPTION_NUMERIC_LEVER_KEYS = Object.keys(CAPTION_LEVER_BOUNDS) as CaptionNumericLeverKey[]\n\n/**\n * COERCE, never reject: bring the numeric caption levers of node data that\n * never passed a Zod (a workflow written by an agent, an import, a template, a\n * FieldMapping) into the range the render plan accepts. Without this an\n * out-of-range value only surfaces when the plan schema throws — mid-run, after\n * credits are reserved. A `null` / non-finite / non-numeric value is DROPPED (the\n * render default applies); an out-of-range one is clamped; `fontWeight` snaps to the\n * nearest 100 and `maxWordsPerLine` to a whole number. Pure; returns a copy and\n * leaves every other field untouched. Applied by payload-builder to the node's\n * top level and to each `segments[]` entry.\n */\nexport function normalizeCaptionNumericLevers<T extends Record<string, unknown>>(input: T): T {\n const out: Record<string, unknown> = { ...input }\n for (const key of CAPTION_NUMERIC_LEVER_KEYS) {\n if (!(key in out) || out[key] === undefined) continue\n // `null` is \"not set\": drop it rather than carry it — the render plan's\n // numeric schema rejects a null, mid-run, after credits are reserved.\n if (out[key] === null) {\n delete out[key]\n continue\n }\n const raw = typeof out[key] === \"string\" && (out[key] as string).trim() !== \"\" ? Number(out[key]) : out[key]\n if (typeof raw !== \"number\" || !Number.isFinite(raw)) {\n delete out[key]\n continue\n }\n const { min, max } = CAPTION_LEVER_BOUNDS[key]\n const shaped = key === \"fontWeight\" ? Math.round(raw / 100) * 100 : key === \"maxWordsPerLine\" ? Math.round(raw) : raw\n out[key] = Math.min(max, Math.max(min, shaped))\n }\n return out as T\n}\n\n/** The concrete levers a look (and any explicit override) resolves to. */\nexport interface CaptionLookLevers {\n fontFamily?: SupportedFontName\n fontWeight?: number\n color?: string\n backgroundColor?: string\n strokeColor?: string\n strokeWidth?: number\n highlightColor?: string\n uppercase?: boolean\n}\n\n/** Outline width = 10% of font size (min 2px). `paint-order: stroke fill` puts\n * half the stroke OUTSIDE the glyph, so the visible rim is ~5% of font size. */\nexport function autoStrokeWidth(fontSize: number): number {\n return Math.max(2, Math.round(fontSize * 0.1))\n}\n\n/** Each look is a function of font size (so the outline tracks the text size). */\nexport const CAPTION_LOOKS: Record<CaptionLookId, (fontSize: number) => CaptionLookLevers> = {\n // The TikTok / CapCut read: heavy geometric sans, caps, white on a thick black\n // outline, yellow spoken word.\n outline: (fs) => ({\n fontFamily: \"Montserrat\",\n fontWeight: 900,\n uppercase: true,\n color: \"#ffffff\",\n strokeColor: \"#000000\",\n strokeWidth: autoStrokeWidth(fs),\n highlightColor: \"#FFE600\",\n }),\n // The pre-look lever set with the face pinned (it never was): per-style weight,\n // soft shadow only, no casing, no outline.\n clean: () => ({ fontFamily: \"Inter\", color: \"#ffffff\" }),\n}\n\n/**\n * Resolve a look + explicit overrides into concrete levers. An explicit lever\n * always wins over the look; `strokeWidth: 0` explicitly means \"no outline\".\n * The plan then carries concrete levers only — nothing to resolve at render.\n */\nexport function resolveCaptionLook(\n look: CaptionLookId | undefined,\n explicit: CaptionLookLevers,\n fontSize: number,\n): CaptionLookLevers {\n // COERCE, never throw. The route Zod rejects a bad `look`, but the orchestrator /\n // authored-JSON / import / Copilot paths write `look` straight onto node data with\n // no validation (payload-builder passes `look: data.look` verbatim — the CLAUDE.md\n // pitfall 5b class). An unknown id here would throw AFTER a paid transcription and\n // fail the whole run, so an out-of-vocabulary look falls back to the default preset.\n const preset = CAPTION_LOOKS[look ?? DEFAULT_CAPTION_LOOK] ?? CAPTION_LOOKS[DEFAULT_CAPTION_LOOK]\n const out: CaptionLookLevers = { ...preset(fontSize) }\n for (const k of Object.keys(explicit) as (keyof CaptionLookLevers)[]) {\n if (explicit[k] !== undefined) (out[k] as CaptionLookLevers[typeof k]) = explicit[k]\n }\n return out\n}\n\n/**\n * Resolve the concrete render levers for a caption, applying the DEFAULT look the\n * way each STYLE expects: an unset `look` means `outline` on a kinetic style (the\n * TikTok/CapCut read) and `clean` on the static `subtitle` (the plain read — a\n * pinned neutral sans, no outline, no casing). So a subtitle that routes to\n * Remotion never inherits the outline house-style unless asked, AND is never left\n * with no face at all (which renders as headless Chrome's default serif). A named\n * look always wins; explicit levers override either. SINGLE SOURCE for the worker\n * top-level levers, the per-segment resolver, and the frontend config/preview\n * mirror, so the per-style default can't drift between them.\n */\nexport function resolveCaptionLevers(\n style: string | undefined | null,\n look: CaptionLookId | undefined,\n explicit: CaptionLookLevers,\n fontSize: number,\n): CaptionLookLevers {\n const effective = look ?? (isKineticCaptionStyle(style) ? DEFAULT_CAPTION_LOOK : DEFAULT_SUBTITLE_LOOK)\n return resolveCaptionLook(effective, explicit, fontSize)\n}\n","export interface CaptionWordTiming {\n readonly text: string\n readonly startMs: number\n readonly endMs: number\n}\n\n/**\n * A caption plan: the opening line, where it ends, and the timed words that\n * follow it. Times and words only — no styling travels on a plan; whoever\n * renders it applies the look. Times are milliseconds from the video's start.\n */\n/** The opening line and the body's words, timed. No styling. */\nexport interface CaptionPlan {\n readonly v: 1\n /** The opening line as written; sent as is, never trimmed. */\n readonly hookText: string\n /** Where the opening line ends; the body starts here. */\n readonly hookEndMs: number\n /** Where the body captions end, any tail included (the producer decides it). */\n readonly bodyEndMs: number\n /** The body's words, in milliseconds. */\n readonly captions: readonly CaptionWordTiming[]\n /** When known, the opening line and the body are clamped to it. */\n readonly videoDurationMs?: number\n /** Primary language tag: \"en\", \"he\", … */\n readonly language?: string\n}\n\nconst nonNegative = (v: unknown): v is number => typeof v === \"number\" && Number.isFinite(v) && v >= 0\n\n/**\n * A wired caption plan (object or JSON string) → the plan, or the first problem\n * named as \"Caption plan: <issue>.\" Only the CaptionPlan fields are kept.\n */\nexport function parseCaptionPlan(raw: unknown): { plan: CaptionPlan } | { error: string } {\n let value: unknown = raw\n if (typeof raw === \"string\") {\n try { value = JSON.parse(raw) } catch { return { error: \"Caption plan: not valid JSON.\" } }\n }\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return { error: \"Caption plan: not an object.\" }\n const o = value as Record<string, unknown>\n if (o.v !== 1) return { error: \"Caption plan: v must be 1.\" }\n if (typeof o.hookText !== \"string\") return { error: \"Caption plan: hookText must be text.\" }\n for (const f of [\"hookEndMs\", \"bodyEndMs\"] as const) {\n if (!nonNegative(o[f])) return { error: `Caption plan: ${f} must be a non-negative number.` }\n }\n if (o.videoDurationMs !== undefined && !nonNegative(o.videoDurationMs)) {\n return { error: \"Caption plan: videoDurationMs must be a non-negative number.\" }\n }\n if (o.language !== undefined && typeof o.language !== \"string\") return { error: \"Caption plan: language must be text.\" }\n if (!Array.isArray(o.captions)) return { error: \"Caption plan: captions must be a list.\" }\n const captions: CaptionWordTiming[] = []\n for (let i = 0; i < o.captions.length; i++) {\n const c = o.captions[i] as Record<string, unknown> | null\n if (!c || typeof c !== \"object\" || typeof c.text !== \"string\" || !nonNegative(c.startMs) || !nonNegative(c.endMs)) {\n return { error: `Caption plan: captions[${i}] needs text, startMs and endMs.` }\n }\n if (c.endMs < c.startMs) return { error: `Caption plan: captions[${i}] ends before it starts.` }\n captions.push({ text: c.text, startMs: c.startMs, endMs: c.endMs })\n }\n return {\n plan: {\n v: 1,\n hookText: o.hookText,\n hookEndMs: o.hookEndMs as number,\n bodyEndMs: o.bodyEndMs as number,\n captions,\n ...(o.videoDurationMs !== undefined ? { videoDurationMs: o.videoDurationMs as number } : {}),\n ...(o.language !== undefined ? { language: o.language as string } : {}),\n },\n }\n}\n","/**\n * Canonical list of font display names supported by the Remotion renderer.\n *\n * Single source of truth shared by:\n * - the backend Zod schemas (`z.enum(SUPPORTED_FONT_NAMES)`), which CANNOT\n * import `@nodaro/remotion` (its font-registry pulls the render runtime +\n * `@remotion/google-fonts` side-effects into a validation path), and\n * - `packages/remotion/src/lib/font-registry.ts`, which loads each face and\n * is kept in lock-step with this tuple by a compile-time `satisfies` guard.\n *\n * Order/spelling MUST match the keys of the `fonts` object in font-registry.ts.\n */\nexport const SUPPORTED_FONT_NAMES = [\n \"Inter\",\n \"Roboto\",\n \"Open Sans\",\n \"Montserrat\",\n \"Poppins\",\n \"Raleway\",\n \"Nunito\",\n \"Lato\",\n \"Playfair Display\",\n \"Merriweather\",\n \"Lora\",\n \"EB Garamond\",\n \"Bebas Neue\",\n \"Oswald\",\n \"Anton\",\n \"Dancing Script\",\n \"Pacifico\",\n \"Caveat\",\n \"Roboto Mono\",\n \"Fira Code\",\n \"Rubik\",\n \"Heebo\",\n \"Cairo\",\n \"Tajawal\",\n] as const\n\nexport type SupportedFontName = (typeof SUPPORTED_FONT_NAMES)[number]\n","import { z } from \"zod\"\nimport {\n ALL_CAPTION_STYLES,\n CAPTION_LOOK_IDS,\n CAPTION_MAX_WORDS_PER_LINE_MAX,\n CAPTION_MAX_WORDS_PER_LINE_MIN,\n} from \"./caption-styles.js\"\nimport { SUPPORTED_FONT_NAMES } from \"./supported-fonts.js\"\n\n/**\n * The add-captions SEGMENT contract — one definition for the route's Zod, the\n * provider's overlap check and both workflow engines' pre-reservation check of a\n * caption plan's segments (a DAG payload never passes the route's validation).\n * Moved here from backend/src/routes/add-captions.ts so the copies can never differ.\n */\n\n/** Caption font weight: 100..900 on the 100 grid. */\nexport const captionFontWeightSchema = z.number().int().min(100).max(900).multipleOf(100)\n\n/** A text caption source must carry a visible glyph (whitespace synthesises to zero words). */\nexport const nonBlankCaptionText = z.string().min(1).refine((t) => /\\S/.test(t), { message: \"text must contain a non-whitespace character\" })\n\n/** One word-timed caption entry. */\nexport const captionInputSchema = z.object({\n text: z.string(),\n // startMs/endMs are the visibility window and drive the highlight; timestampMs\n // is the word timestamp used by tiktok-words token timing; confidence is\n // metadata, ignored by rendering. timestampMs/confidence default to null.\n startMs: z.number().min(0),\n endMs: z.number().min(0),\n timestampMs: z.number().min(0).nullable().default(null),\n confidence: z.number().min(0).max(1).nullable().default(null),\n})\n\n/**\n * One caption SEGMENT: a time range, optional levers (each inherits the top-level\n * value when omitted) and optional own words (`text` or `captions[]`; falls back\n * to the shared transcript filtered to the range). A segmented render is entirely\n * Remotion, so any `style` (incl. subtitle) and any look lever is valid on a segment.\n */\nexport const captionSegmentInputSchema = z.object({\n startMs: z.number().min(0),\n endMs: z.number().min(0),\n style: z.enum(ALL_CAPTION_STYLES).optional(),\n position: z.enum([\"bottom\", \"top\", \"center\"]).optional(),\n fontSize: z.number().min(12).max(200).optional(),\n color: z.string().optional(),\n backgroundColor: z.string().optional(),\n // A named look preset (outline/clean); explicit levers below override it.\n look: z.enum(CAPTION_LOOK_IDS).optional(),\n fontFamily: z.enum(SUPPORTED_FONT_NAMES).optional(),\n fontWeight: captionFontWeightSchema.optional(),\n strokeColor: z.string().optional(),\n strokeWidth: z.number().min(0).max(40).optional(),\n highlightColor: z.string().optional(),\n uppercase: z.boolean().optional(),\n positionY: z.number().min(0).max(100).optional(),\n animate: z.boolean().optional(),\n maxWordsPerLine: z.number().int().min(CAPTION_MAX_WORDS_PER_LINE_MIN).max(CAPTION_MAX_WORDS_PER_LINE_MAX).optional(),\n text: nonBlankCaptionText.optional(),\n captions: z.array(captionInputSchema).optional(),\n}).refine((s) => s.endMs > s.startMs, { message: \"segment endMs must be greater than startMs\" })\n\nexport type CaptionSegmentInput = z.infer<typeof captionSegmentInputSchema>\n\n/** Every field a segment may carry, in schema order. */\nexport const CAPTION_SEGMENT_SCHEMA_KEYS: readonly string[] = Object.keys(captionSegmentInputSchema.shape)\n\n/**\n * Segments must be sorted and non-overlapping. Returns the first offending pair\n * as the route's 400 text; null when none overlap (abutting is fine).\n * `startMs < endMs` per segment is enforced by the schema; this is the cross-segment rule.\n */\nexport function findSegmentOverlap(segments: readonly { startMs: number; endMs: number }[]): string | null {\n const sorted = [...segments].sort((a, b) => a.startMs - b.startMs)\n for (let i = 1; i < sorted.length; i++) {\n if (sorted[i]!.startMs < sorted[i - 1]!.endMs) {\n return `segments overlap: [${sorted[i - 1]!.startMs}, ${sorted[i - 1]!.endMs}) and [${sorted[i]!.startMs}, ${sorted[i]!.endMs})`\n }\n }\n return null\n}\n","/**\n * A caption line never starts or ends on a lone dash.\n *\n * A speech engine times a dash written between two spaces (\"Nodaro — every model\")\n * as a token of its own, and forced alignment keeps it. Inside a line the dash\n * reads as written; at a line's edge — the line breaks right after it, or the\n * next line opens with it — it reads as a stray mark. The display drops such a\n * token from the edge of the line it lands on; the words keep their own timings.\n *\n * One rule for every place that breaks captions into lines: the render's line\n * grouping (word-timed captions) and the wrap of a static text block.\n */\n\n/** Dash characters only: hyphen-minus, the Unicode hyphens and dashes (U+2010–U+2015), minus, the Hebrew maqaf, and their small/full-width forms. */\nconst BARE_DASH = /^[-‐-―−־﹘﹣-]+$/u\n\n/** True when the token, trimmed, is nothing but dash characters (\"—\", \"–\", \"-\"). A hyphenated word (\"ה-AI\", \"re-run\") is not. */\nexport function isBareDashToken(text: string): boolean {\n return BARE_DASH.test(text.trim())\n}\n\n/**\n * The items with every lone-dash token at either end removed (a copy; the input\n * is never mutated). A line holding nothing but dashes comes back empty — the\n * caller drops it rather than show it.\n */\nexport function trimEdgeDashTokens<T>(items: readonly T[], textOf: (item: T) => string): T[] {\n let start = 0\n let end = items.length\n while (start < end && isBareDashToken(textOf(items[start]!))) start++\n while (end > start && isBareDashToken(textOf(items[end - 1]!))) end--\n return items.slice(start, end)\n}\n","import { parseCaptionPlan, type CaptionPlan } from \"./caption-plan.js\"\nimport { captionSegmentInputSchema, findSegmentOverlap } from \"./caption-segment-schema.js\"\n\n/** The styling half, injected so this package never imports @nodaro/prompts (each engine passes hookPlateCaptionSegments). */\nexport interface CaptionPlanStyler {\n readonly segmentsFor: (\n plan: CaptionPlan,\n opts?: { bodyLevers?: Readonly<Record<string, unknown>> },\n ) => { segments: Record<string, unknown>[]; dropped: readonly string[] }\n readonly leverKeys: readonly string[]\n}\n\n/** The node's own caption levers (set, non-null) — the body's style. Undefined when it sets none (the helper then applies Body Captions). */\nexport function captionPlanBodyLevers(\n nodeData: Readonly<Record<string, unknown>>,\n leverKeys: readonly string[],\n): Record<string, unknown> | undefined {\n const levers: Record<string, unknown> = {}\n for (const k of leverKeys) {\n const v = nodeData[k]\n if (v !== undefined && v !== null) levers[k] = v\n }\n return Object.keys(levers).length > 0 ? levers : undefined\n}\n\n/**\n * A wired caption plan → the timed segments of ONE add-captions request, checked\n * with the route's own segment schema and overlap rule (a DAG payload never\n * passes the route, so both engines check here, before any reservation). The\n * plate is always Hook Plate plus the plan's language levers; the body is the\n * node's own style (the helper's rules, SP7 §4.6.3). `segments: []` = no\n * captions — the caller passes the video through.\n */\nexport function styleCaptionPlan(\n raw: unknown,\n nodeData: Readonly<Record<string, unknown>>,\n styler: CaptionPlanStyler,\n): { segments: Record<string, unknown>[] } | { error: string } {\n const parsed = parseCaptionPlan(raw)\n if (\"error\" in parsed) return { error: parsed.error }\n const bodyLevers = captionPlanBodyLevers(nodeData, styler.leverKeys)\n const styled = styler.segmentsFor(parsed.plan, bodyLevers ? { bodyLevers } : undefined).segments\n // The PARSED segments go on, never the helper's raw ones: the route's schema\n // fills each word entry's defaults (`timestampMs` / `confidence` → null), and a\n // DAG payload never passes the route, so returning the raw list sent a server\n // run word entries the add-captions route itself would have completed.\n const segments: Record<string, unknown>[] = []\n for (let i = 0; i < styled.length; i++) {\n const r = captionSegmentInputSchema.safeParse(styled[i])\n if (!r.success) return { error: `Caption plan: segment ${i + 1}: ${r.error.issues[0]?.message ?? \"invalid\"}.` }\n segments.push(r.data)\n }\n const overlap = findSegmentOverlap(segments as { startMs: number; endMs: number }[])\n if (overlap) return { error: `Caption plan: ${overlap}.` }\n return { segments }\n}\n"]}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { UGC_NEWER_APP_MESSAGE, ugcPlanLengthSec, UGC_SCRIPT_LANGUAGES, ugcPlanScreenshotCount, UGC_OVER_HOLD_MESSAGE, UGC_FINISH_NEEDS_CLIPS_MESSAGE, readUgcWire, UGC_NODE_MESSAGES, UGC_FINISH_NOT_READY_MESSAGE, UGC_NEEDS_FINISH_MESSAGE } from './chunk-OZSACQ2V.js';
|
|
2
|
+
|
|
3
|
+
// src/ugc-call-body.ts
|
|
4
|
+
var pick = (a, from, to) => a[from] !== void 0 && a[from] !== null ? { [to]: a[from] } : {};
|
|
5
|
+
function llmFields(a) {
|
|
6
|
+
return {
|
|
7
|
+
...pick(a, "llmModel", "llmModel"),
|
|
8
|
+
...pick(a, "reasoning_effort", "reasoningEffort"),
|
|
9
|
+
...a.advanced_mode === true ? { advancedMode: true } : {},
|
|
10
|
+
...pick(a, "temperature", "temperature"),
|
|
11
|
+
...pick(a, "max_tokens", "maxTokens")
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function ugcCallToRouteBody(call, opts = {}) {
|
|
15
|
+
const args = { ...call.args };
|
|
16
|
+
if (call.imageArg) {
|
|
17
|
+
if (!opts.image) return { error: `${call.tool} needs the previous step's image` };
|
|
18
|
+
args[call.imageArg] = opts.image;
|
|
19
|
+
}
|
|
20
|
+
switch (call.tool) {
|
|
21
|
+
case "generate_image":
|
|
22
|
+
return {
|
|
23
|
+
path: "/v1/generate-image",
|
|
24
|
+
body: {
|
|
25
|
+
...pick(args, "prompt", "prompt"),
|
|
26
|
+
...pick(args, "model", "provider"),
|
|
27
|
+
...pick(args, "aspect_ratio", "aspectRatio"),
|
|
28
|
+
...pick(args, "resolution", "resolution"),
|
|
29
|
+
...pick(args, "quality", "quality"),
|
|
30
|
+
...pick(args, "negative_prompt", "negativePrompt")
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
case "image_to_image":
|
|
34
|
+
return {
|
|
35
|
+
path: "/v1/image-to-image",
|
|
36
|
+
body: {
|
|
37
|
+
...pick(args, "image_url", "imageUrl"),
|
|
38
|
+
...pick(args, "prompt", "prompt"),
|
|
39
|
+
...pick(args, "model", "provider"),
|
|
40
|
+
...pick(args, "resolution", "resolution"),
|
|
41
|
+
...pick(args, "quality", "quality"),
|
|
42
|
+
...pick(args, "strength", "strength"),
|
|
43
|
+
...pick(args, "aspect_ratio", "aspectRatio"),
|
|
44
|
+
...pick(args, "negative_prompt", "negativePrompt"),
|
|
45
|
+
...pick(args, "seed", "seed")
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
case "image_to_text": {
|
|
49
|
+
const image = opts.image ?? (typeof args.image_url === "string" ? args.image_url : void 0);
|
|
50
|
+
if (!image) return { error: "image_to_text needs an image" };
|
|
51
|
+
return {
|
|
52
|
+
path: "/v1/image-to-text/describe",
|
|
53
|
+
body: {
|
|
54
|
+
imageUrl: image,
|
|
55
|
+
...pick(args, "detail_level", "detailLevel"),
|
|
56
|
+
...pick(args, "custom_prompt", "customPrompt"),
|
|
57
|
+
...llmFields(args)
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
default:
|
|
62
|
+
return void 0;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// src/ugc-lane-wires.ts
|
|
67
|
+
var isObject = (x) => !!x && typeof x === "object" && !Array.isArray(x);
|
|
68
|
+
var UGC_FINISH_CLIPS_TYPE = "ugc-finish-clips";
|
|
69
|
+
var UGC_PRELUDE_STEPS = ["speech", "alignment", "split"];
|
|
70
|
+
var UGC_PRELUDE_ROUTES = {
|
|
71
|
+
speech: { path: "/v1/text-to-speech", jobType: "text-to-speech" },
|
|
72
|
+
alignment: { path: "/v1/forced-alignment", jobType: "forced-alignment" },
|
|
73
|
+
split: { path: "/v1/ugc/segments", jobType: "ugc-segments" }
|
|
74
|
+
};
|
|
75
|
+
function ugcClipsPhase(answer) {
|
|
76
|
+
return answer.phase === 1 ? 1 : answer.phase === 2 ? 2 : null;
|
|
77
|
+
}
|
|
78
|
+
var callOf = (raw, tool) => {
|
|
79
|
+
if (!isObject(raw) || raw.tool !== tool || !isObject(raw.args)) return void 0;
|
|
80
|
+
return raw.args;
|
|
81
|
+
};
|
|
82
|
+
var pick2 = (a, from, to) => a[from] !== void 0 && a[from] !== null ? { [to]: a[from] } : {};
|
|
83
|
+
function ugcPrelude(answer) {
|
|
84
|
+
const speech = callOf(answer.speech, "generate_speech");
|
|
85
|
+
const align = callOf(answer.align, "forced_alignment");
|
|
86
|
+
const split = callOf(answer.split, "ugc_split_speech");
|
|
87
|
+
if (!speech || !align || !split || typeof speech.text !== "string" || !isObject(split.plan)) return { error: UGC_NEWER_APP_MESSAGE };
|
|
88
|
+
return {
|
|
89
|
+
speech: {
|
|
90
|
+
text: speech.text,
|
|
91
|
+
...pick2(speech, "voice_id", "voice"),
|
|
92
|
+
...pick2(speech, "voice_type", "voiceType"),
|
|
93
|
+
...pick2(speech, "model", "provider"),
|
|
94
|
+
...pick2(speech, "language_code", "languageCode")
|
|
95
|
+
},
|
|
96
|
+
alignment: (audioUrl) => ({ ...pick2(align, "transcript", "transcript"), audioUrl }),
|
|
97
|
+
split: (audioUrl, alignment) => ({ plan: split.plan, audioUrl, alignment })
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function ugcPreludeOutput(step, output) {
|
|
101
|
+
const value = step === "speech" ? output?.audioUrl : step === "alignment" ? output?.alignment : output?.segments;
|
|
102
|
+
const ok = step === "speech" ? typeof value === "string" && value !== "" : Array.isArray(value) && value.length > 0;
|
|
103
|
+
return ok ? { value } : { error: UGC_NEWER_APP_MESSAGE };
|
|
104
|
+
}
|
|
105
|
+
function ugcClipsPhase2Body(body, segments) {
|
|
106
|
+
return { ...body, segments: [...segments] };
|
|
107
|
+
}
|
|
108
|
+
function ugcRunEstimateInput(plan) {
|
|
109
|
+
const targetDurationSec = ugcPlanLengthSec(plan);
|
|
110
|
+
const language = planOf(plan)?.language;
|
|
111
|
+
if (targetDurationSec === void 0 || typeof language !== "string" || language === "en" || !UGC_SCRIPT_LANGUAGES.includes(language)) {
|
|
112
|
+
return { error: UGC_NEWER_APP_MESSAGE };
|
|
113
|
+
}
|
|
114
|
+
return { runEstimate: { targetDurationSec, screenshotCount: ugcPlanScreenshotCount(plan) ?? 0, source: "sampled", language } };
|
|
115
|
+
}
|
|
116
|
+
function ugcRenderHoldBody(input) {
|
|
117
|
+
if (!Array.isArray(input.tickets) || input.tickets.length === 0) return { error: UGC_NEWER_APP_MESSAGE };
|
|
118
|
+
return {
|
|
119
|
+
path: "/v1/ugc/quote",
|
|
120
|
+
body: {
|
|
121
|
+
tickets: [...input.tickets],
|
|
122
|
+
hasCards: input.hasCards,
|
|
123
|
+
...input.finishes ? { finishes: true } : {},
|
|
124
|
+
runEstimate: { ...input.runEstimate }
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function planOf(plan) {
|
|
129
|
+
if (typeof plan !== "string") return isObject(plan) ? plan : void 0;
|
|
130
|
+
try {
|
|
131
|
+
const parsed = JSON.parse(plan);
|
|
132
|
+
return isObject(parsed) ? parsed : void 0;
|
|
133
|
+
} catch {
|
|
134
|
+
return void 0;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
var isCredits = (x) => typeof x === "number" && Number.isFinite(x) && x >= 0;
|
|
138
|
+
function ugcRenderHoldVerdict(answer) {
|
|
139
|
+
if (!isObject(answer) || !isCredits(answer.ceiling) || !isCredits(answer.runHold)) return { error: UGC_NEWER_APP_MESSAGE };
|
|
140
|
+
return answer.ceiling > answer.runHold ? { error: UGC_OVER_HOLD_MESSAGE } : { ok: true };
|
|
141
|
+
}
|
|
142
|
+
function ugcFinishPlan(input) {
|
|
143
|
+
const clips = input.clipUrls.filter((u) => typeof u === "string" && u !== "");
|
|
144
|
+
if (clips.length === 0) return { error: UGC_FINISH_NEEDS_CLIPS_MESSAGE };
|
|
145
|
+
const read = readUgcWire(input.planOutWire, UGC_NODE_MESSAGES.needsPlanOut);
|
|
146
|
+
if ("error" in read) return read;
|
|
147
|
+
const finish = read.value.finish;
|
|
148
|
+
if (finish === void 0) return { kind: "pass", clips };
|
|
149
|
+
if (!isObject(finish) || !Array.isArray(finish.segments) || finish.segments.length === 0) return { error: UGC_NEWER_APP_MESSAGE };
|
|
150
|
+
if (finish.segments.length !== clips.length) return { error: UGC_NEWER_APP_MESSAGE };
|
|
151
|
+
return {
|
|
152
|
+
kind: "job",
|
|
153
|
+
path: "/v1/ugc/finish",
|
|
154
|
+
body: { segments: finish.segments, clips: clips.map((url, i) => ({ clip: i + 1, rolls: [url] })) }
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
function ugcFinishOutputs(output) {
|
|
158
|
+
if (!output) return { error: UGC_NEWER_APP_MESSAGE };
|
|
159
|
+
if (output.ready === false) return { error: UGC_FINISH_NOT_READY_MESSAGE };
|
|
160
|
+
if (output.ready !== true || !Array.isArray(output.clips) || output.clips.length === 0) return { error: UGC_NEWER_APP_MESSAGE };
|
|
161
|
+
const warnings = Array.isArray(output.warnings) ? output.warnings.flatMap((w) => isObject(w) && typeof w.code === "string" ? [w.code] : typeof w === "string" ? [w] : []) : [];
|
|
162
|
+
const rows = [...output.clips].filter(isObject).sort((a, b) => Number(a.clip) - Number(b.clip));
|
|
163
|
+
if (rows.length !== output.clips.length || rows.some((r, i) => r.clip !== i + 1 || typeof r.url !== "string" || r.url === "")) return { error: UGC_NEWER_APP_MESSAGE };
|
|
164
|
+
return {
|
|
165
|
+
clips: rows.map((r) => ({
|
|
166
|
+
url: r.url,
|
|
167
|
+
meta: { warnings, durationSec: typeof r.sec === "number" && Number.isFinite(r.sec) && r.sec > 0 ? r.sec : null }
|
|
168
|
+
}))
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
function ugcFinishWired(edges, nodes, clipsId) {
|
|
172
|
+
const finishIds = new Set(nodes.filter((n) => n.type === UGC_FINISH_CLIPS_TYPE && typeof n.id === "string").map((n) => n.id));
|
|
173
|
+
return edges.some((e) => e.source === clipsId && e.sourceHandle === "plan-out" && e.target !== void 0 && finishIds.has(e.target) && (e.targetHandle ?? "") === "plan");
|
|
174
|
+
}
|
|
175
|
+
function ugcLaneNeedsFinish(edges, nodes, clipsId) {
|
|
176
|
+
return ugcFinishWired(edges, nodes, clipsId) ? null : UGC_NEEDS_FINISH_MESSAGE;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export { UGC_FINISH_CLIPS_TYPE, UGC_PRELUDE_ROUTES, UGC_PRELUDE_STEPS, ugcCallToRouteBody, ugcClipsPhase, ugcClipsPhase2Body, ugcFinishOutputs, ugcFinishPlan, ugcFinishWired, ugcLaneNeedsFinish, ugcPrelude, ugcPreludeOutput, ugcRenderHoldBody, ugcRenderHoldVerdict, ugcRunEstimateInput };
|
|
180
|
+
//# sourceMappingURL=chunk-XGFTL5XY.js.map
|
|
181
|
+
//# sourceMappingURL=chunk-XGFTL5XY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ugc-call-body.ts","../src/ugc-lane-wires.ts"],"names":["pick"],"mappings":";;;AAkBA,IAAM,IAAA,GAAO,CAAC,CAAA,EAAsC,IAAA,EAAc,OAChE,CAAA,CAAE,IAAI,MAAM,MAAA,IAAa,CAAA,CAAE,IAAI,CAAA,KAAM,IAAA,GAAO,EAAE,CAAC,EAAE,GAAG,CAAA,CAAE,IAAI,CAAA,EAAE,GAAI,EAAC;AAGnE,SAAS,UAAU,CAAA,EAA+D;AAChF,EAAA,OAAO;AAAA,IACL,GAAG,IAAA,CAAK,CAAA,EAAG,UAAA,EAAY,UAAU,CAAA;AAAA,IACjC,GAAG,IAAA,CAAK,CAAA,EAAG,kBAAA,EAAoB,iBAAiB,CAAA;AAAA,IAChD,GAAI,EAAE,aAAA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AAM,CAAA,CAAE,EAAY,CAAC,CAAA;AACtI,EAAA,OAAO,KAAA,CAAM,KAAK,CAAC,CAAA,KAAM,EAAE,MAAA,KAAW,OAAA,IAAW,EAAE,YAAA,KAAiB,UAAA,IAAc,EAAE,MAAA,KAAW,MAAA,IAAa,UAAU,GAAA,CAAI,CAAA,CAAE,MAAM,CAAA,IAAA,CAAM,CAAA,CAAE,YAAA,IAAgB,EAAA,MAAQ,MAAM,CAAA;AAC1K;AAGO,SAAS,kBAAA,CACd,KAAA,EACA,KAAA,EACA,OAAA,EACe;AACf,EAAA,OAAO,cAAA,CAAe,KAAA,EAAO,KAAA,EAAO,OAAO,IAAI,IAAA,GAAO,wBAAA;AACxD","file":"chunk-XGFTL5XY.js","sourcesContent":["/**\n * A UGC builder call `{ tool, args }` (MCP argument names) → the REST body of\n * the public route that tool dispatches to. The builder sets every price lever;\n * this adds none — its one addition is the image of a call that needs the\n * previous step's image (`imageArg`, or the photo of `image_to_text`). A tool\n * it does not know → undefined, so an app older than the builder fails plainly\n * instead of guessing. Kept equal to the MCP verbs by ugc-call-body-parity.test.ts.\n */\nexport interface UgcToolCall {\n readonly tool: string\n readonly args: Readonly<Record<string, unknown>>\n readonly imageArg?: string\n}\nexport type UgcRouteBody = {\n readonly path: \"/v1/generate-image\" | \"/v1/image-to-image\" | \"/v1/image-to-text/describe\"\n readonly body: Record<string, unknown>\n}\n\nconst pick = (a: Readonly<Record<string, unknown>>, from: string, to: string): Record<string, unknown> =>\n a[from] !== undefined && a[from] !== null ? { [to]: a[from] } : {}\n\n/** The LLM levers image_to_text forwards (the verb's llmPayloadFields). */\nfunction llmFields(a: Readonly<Record<string, unknown>>): Record<string, unknown> {\n return {\n ...pick(a, \"llmModel\", \"llmModel\"),\n ...pick(a, \"reasoning_effort\", \"reasoningEffort\"),\n ...(a.advanced_mode === true ? { advancedMode: true } : {}),\n ...pick(a, \"temperature\", \"temperature\"),\n ...pick(a, \"max_tokens\", \"maxTokens\"),\n }\n}\n\nexport function ugcCallToRouteBody(\n call: UgcToolCall,\n opts: { readonly image?: string } = {},\n): UgcRouteBody | { readonly error: string } | undefined {\n const args: Record<string, unknown> = { ...call.args }\n if (call.imageArg) {\n if (!opts.image) return { error: `${call.tool} needs the previous step's image` }\n args[call.imageArg] = opts.image\n }\n switch (call.tool) {\n case \"generate_image\":\n return {\n path: \"/v1/generate-image\",\n body: {\n ...pick(args, \"prompt\", \"prompt\"),\n ...pick(args, \"model\", \"provider\"),\n ...pick(args, \"aspect_ratio\", \"aspectRatio\"),\n ...pick(args, \"resolution\", \"resolution\"),\n ...pick(args, \"quality\", \"quality\"),\n ...pick(args, \"negative_prompt\", \"negativePrompt\"),\n },\n }\n case \"image_to_image\":\n return {\n path: \"/v1/image-to-image\",\n body: {\n ...pick(args, \"image_url\", \"imageUrl\"),\n ...pick(args, \"prompt\", \"prompt\"),\n ...pick(args, \"model\", \"provider\"),\n ...pick(args, \"resolution\", \"resolution\"),\n ...pick(args, \"quality\", \"quality\"),\n ...pick(args, \"strength\", \"strength\"),\n ...pick(args, \"aspect_ratio\", \"aspectRatio\"),\n ...pick(args, \"negative_prompt\", \"negativePrompt\"),\n ...pick(args, \"seed\", \"seed\"),\n },\n }\n case \"image_to_text\": {\n const image = opts.image ?? (typeof args.image_url === \"string\" ? args.image_url : undefined)\n if (!image) return { error: \"image_to_text needs an image\" }\n return {\n path: \"/v1/image-to-text/describe\",\n body: {\n imageUrl: image,\n ...pick(args, \"detail_level\", \"detailLevel\"),\n ...pick(args, \"custom_prompt\", \"customPrompt\"),\n ...llmFields(args),\n },\n }\n }\n default:\n return undefined\n }\n}\n","/**\n * The UGC wires of a language whose clips are cut from one recorded speech (the\n * segmented lane): UGC Clips' prelude (record the speech, time its words, split\n * it at its pauses, then ask for the clips again with the segments) and UGC\n * Finish (lay the speech back over the rendered clips and trim the dead air,\n * as one job over all of them). One pure implementation both engines call, as\n * the rest of the UGC wires (`ugc-node-wires.ts`).\n *\n * Content-free: an answer is read only for `phase`, its three calls' `tool`\n * and `args` (argument names, never their meaning), the `finish` call's\n * `args`, and a finished job's clip list. Which language takes this lane, which\n * voice speaks and what the calls say are the builder's.\n */\nimport {\n UGC_FINISH_NEEDS_CLIPS_MESSAGE,\n UGC_FINISH_NOT_READY_MESSAGE,\n UGC_NEEDS_FINISH_MESSAGE,\n UGC_NEWER_APP_MESSAGE,\n UGC_NODE_MESSAGES,\n UGC_OVER_HOLD_MESSAGE,\n UGC_SCRIPT_LANGUAGES,\n readUgcWire,\n ugcPlanLengthSec,\n ugcPlanScreenshotCount,\n} from \"./ugc-node-wires.js\"\nimport type { FanOutItemMeta } from \"./fan-out-meta.js\"\n\ntype Obj = Record<string, unknown>\nconst isObject = (x: unknown): x is Obj => !!x && typeof x === \"object\" && !Array.isArray(x)\n\n/** UGC Finish's node type. Not the plugin job it runs (`ugc-finish`): a price, a dispatch or a reconcile keyed on a type never confuses the two. */\nexport const UGC_FINISH_CLIPS_TYPE = \"ugc-finish-clips\"\n\n/** The child steps of UGC Clips' prelude, in run order: each is a job of its own, keyed by its step. */\nexport const UGC_PRELUDE_STEPS = [\"speech\", \"alignment\", \"split\"] as const\nexport type UgcPreludeStep = (typeof UGC_PRELUDE_STEPS)[number]\n\n/** The public route each prelude step runs on, and the node type its job is read as. */\nexport const UGC_PRELUDE_ROUTES: Readonly<Record<UgcPreludeStep, { readonly path: string; readonly jobType: string }>> = {\n speech: { path: \"/v1/text-to-speech\", jobType: \"text-to-speech\" },\n alignment: { path: \"/v1/forced-alignment\", jobType: \"forced-alignment\" },\n split: { path: \"/v1/ugc/segments\", jobType: \"ugc-segments\" },\n}\n\n/** The `/v1/ugc/clips` answer's phase: 1 = the prelude must run first, 2 = the clips; null = an answer with no phase (one call, as English). */\nexport function ugcClipsPhase(answer: Readonly<Obj>): 1 | 2 | null {\n return answer.phase === 1 ? 1 : answer.phase === 2 ? 2 : null\n}\n\nconst callOf = (raw: unknown, tool: string): Obj | undefined => {\n if (!isObject(raw) || raw.tool !== tool || !isObject(raw.args)) return undefined\n return raw.args\n}\nconst pick = (a: Readonly<Obj>, from: string, to: string): Obj => (a[from] !== undefined && a[from] !== null ? { [to]: a[from] } : {})\n\n/** What the prelude runs: the speech's route body, and the two that need the step before them. */\nexport interface UgcPrelude {\n readonly speech: Obj\n readonly alignment: (audioUrl: string) => Obj\n readonly split: (audioUrl: string, alignment: unknown) => Obj\n}\n\n/**\n * A phase-1 answer's three calls (`speech`, `align`, `split`, MCP argument names) → the REST bodies of\n * the public routes their MCP tools dispatch to: `generate_speech` → `/v1/text-to-speech` (text, voice,\n * voice type, model as provider, language code, as the verb maps them), `forced_alignment` →\n * `/v1/forced-alignment` (the transcript, with the speech's audio), `ugc_split_speech` →\n * `/v1/ugc/segments` (the plan, with the speech's audio and its word timings). A call that is missing\n * or names another tool → the newer-app sentence: the app never guesses.\n */\nexport function ugcPrelude(answer: Readonly<Obj>): UgcPrelude | { readonly error: string } {\n const speech = callOf(answer.speech, \"generate_speech\")\n const align = callOf(answer.align, \"forced_alignment\")\n const split = callOf(answer.split, \"ugc_split_speech\")\n if (!speech || !align || !split || typeof speech.text !== \"string\" || !isObject(split.plan)) return { error: UGC_NEWER_APP_MESSAGE }\n return {\n speech: {\n text: speech.text,\n ...pick(speech, \"voice_id\", \"voice\"),\n ...pick(speech, \"voice_type\", \"voiceType\"),\n ...pick(speech, \"model\", \"provider\"),\n ...pick(speech, \"language_code\", \"languageCode\"),\n },\n alignment: (audioUrl) => ({ ...pick(align, \"transcript\", \"transcript\"), audioUrl }),\n split: (audioUrl, alignment) => ({ plan: split.plan, audioUrl, alignment }),\n }\n}\n\n/** The finished speech job's audio, its word timings and its segments, as their jobs write them. */\nexport function ugcPreludeOutput(step: UgcPreludeStep, output: Readonly<Obj> | undefined): { value: unknown } | { error: string } {\n const value = step === \"speech\" ? output?.audioUrl : step === \"alignment\" ? output?.alignment : output?.segments\n const ok = step === \"speech\" ? typeof value === \"string\" && value !== \"\" : Array.isArray(value) && value.length > 0\n return ok ? { value } : { error: UGC_NEWER_APP_MESSAGE }\n}\n\n/** The second `/v1/ugc/clips` call: the first call's body with the segments the split returned. */\nexport function ugcClipsPhase2Body(body: Readonly<Obj>, segments: readonly unknown[]): Obj {\n return { ...body, segments: [...segments] }\n}\n\n// ── The hold check once the speech is split ──────────────────────────────────\n\n/** The estimate input of a video cut from one recorded speech, as the hold check names it (`runEstimate`). */\nexport interface UgcRunEstimateInput {\n readonly targetDurationSec: number\n readonly screenshotCount: number\n readonly source: \"sampled\"\n readonly language: string\n}\n\n/**\n * The estimate input of the video a UGC Clips run belongs to, read from the plan the node was sent: its\n * length, its screenshot cards and its language — the reading a kept plan is priced with. Read on a\n * phase-1 answer, before the prelude spends anything, so a plan the check cannot read refuses the run\n * while nothing is paid. The creator's source prices no clip, so it is not read. A plan without a length,\n * or without a language this lane takes → the newer-app sentence: the check never guesses.\n */\nexport function ugcRunEstimateInput(plan: unknown): { runEstimate: UgcRunEstimateInput } | { error: string } {\n const targetDurationSec = ugcPlanLengthSec(plan)\n const language = planOf(plan)?.language\n if (targetDurationSec === undefined || typeof language !== \"string\" || language === \"en\" || !(UGC_SCRIPT_LANGUAGES as readonly unknown[]).includes(language)) {\n return { error: UGC_NEWER_APP_MESSAGE }\n }\n return { runEstimate: { targetDurationSec, screenshotCount: ugcPlanScreenshotCount(plan) ?? 0, source: \"sampled\", language } }\n}\n\n/**\n * The quote that checks a video cut from one recorded speech before any of its clips renders: the clips\n * the second `/v1/ugc/clips` call handed on, priced as the UGC Clips quote prices them (`tickets`,\n * `hasCards`, `finishes`), with `runEstimate` (`ugcRunEstimateInput`). The route then also answers\n * `runHold`, the most the video's estimate holds for the clips and the steps after them, which the run's\n * balance was checked against before it started (`ugcRenderHoldVerdict`). No clips → the newer-app sentence.\n */\nexport function ugcRenderHoldBody(input: { runEstimate: UgcRunEstimateInput; tickets: unknown; hasCards: boolean; finishes: boolean }): { path: \"/v1/ugc/quote\"; body: Obj } | { error: string } {\n if (!Array.isArray(input.tickets) || input.tickets.length === 0) return { error: UGC_NEWER_APP_MESSAGE }\n return {\n path: \"/v1/ugc/quote\",\n body: {\n tickets: [...input.tickets],\n hasCards: input.hasCards,\n ...(input.finishes ? { finishes: true } : {}),\n runEstimate: { ...input.runEstimate },\n },\n }\n}\n\n/** A plan, or its wire (a JSON string), as an object; undefined for anything else. */\nfunction planOf(plan: unknown): Obj | undefined {\n if (typeof plan !== \"string\") return isObject(plan) ? plan : undefined\n try {\n const parsed: unknown = JSON.parse(plan)\n return isObject(parsed) ? parsed : undefined\n } catch {\n return undefined\n }\n}\n\nconst isCredits = (x: unknown): x is number => typeof x === \"number\" && Number.isFinite(x) && x >= 0\n\n/**\n * The hold check's answer → go on, or stop before any clip renders: the clips and the steps after them\n * (`ceiling`, each clip at its hold) over what the run was checked for (`runHold`) → the over-hold\n * sentence. An answer without both figures stops too (the newer-app sentence): a clip never renders\n * on a figure nobody checked.\n */\nexport function ugcRenderHoldVerdict(answer: unknown): { readonly ok: true } | { readonly error: string } {\n if (!isObject(answer) || !isCredits(answer.ceiling) || !isCredits(answer.runHold)) return { error: UGC_NEWER_APP_MESSAGE }\n return answer.ceiling > answer.runHold ? { error: UGC_OVER_HOLD_MESSAGE } : { ok: true }\n}\n\n// ── UGC Finish ───────────────────────────────────────────────────────────────\n\n/** What UGC Finish does with the clips it was handed. */\nexport type UgcFinishPlan =\n /** No finish call on the plan (English): the clips go on as they came, no call, no job. */\n | { readonly kind: \"pass\"; readonly clips: readonly string[] }\n /** The finish job's body: the segments with their room, one roll per clip, in order. */\n | { readonly kind: \"job\"; readonly path: \"/v1/ugc/finish\"; readonly body: Obj }\n\n/**\n * UGC Finish's input → what it does. The `plan` input is UGC Clips' Script (sized) output; a plan\n * carrying `finish` (the segmented lane) asks for the finish job over the clips, in order; any other\n * plan passes the clips through. Clips are the fan-in list (`inputs.inputs`), in clip order.\n */\nexport function ugcFinishPlan(input: { planOutWire: unknown; clipUrls: readonly unknown[] }): UgcFinishPlan | { readonly error: string } {\n const clips = input.clipUrls.filter((u): u is string => typeof u === \"string\" && u !== \"\")\n if (clips.length === 0) return { error: UGC_FINISH_NEEDS_CLIPS_MESSAGE }\n const read = readUgcWire(input.planOutWire, UGC_NODE_MESSAGES.needsPlanOut)\n if (\"error\" in read) return read\n const finish = read.value.finish\n if (finish === undefined) return { kind: \"pass\", clips }\n if (!isObject(finish) || !Array.isArray(finish.segments) || finish.segments.length === 0) return { error: UGC_NEWER_APP_MESSAGE }\n if (finish.segments.length !== clips.length) return { error: UGC_NEWER_APP_MESSAGE }\n return {\n kind: \"job\",\n path: \"/v1/ugc/finish\",\n body: { segments: finish.segments, clips: clips.map((url, i) => ({ clip: i + 1, rolls: [url] })) },\n }\n}\n\n/** A finished clip, as UGC Finish hands it on: its URL and the notes its downstream nodes read. */\nexport interface UgcFinishedClip { readonly url: string; readonly meta: FanOutItemMeta }\n\n/**\n * A finished `ugc-finish` job → the finished clips in clip order, each with its real length. `ready: false`\n * (a clip that does not follow its speech) → the not-ready sentence: the node fails, never hands on a\n * partial list. A dry finish's warning rides every clip's notes.\n */\nexport function ugcFinishOutputs(output: Readonly<Obj> | undefined): { clips: UgcFinishedClip[] } | { error: string } {\n if (!output) return { error: UGC_NEWER_APP_MESSAGE }\n if (output.ready === false) return { error: UGC_FINISH_NOT_READY_MESSAGE }\n if (output.ready !== true || !Array.isArray(output.clips) || output.clips.length === 0) return { error: UGC_NEWER_APP_MESSAGE }\n const warnings = Array.isArray(output.warnings)\n ? output.warnings.flatMap((w) => (isObject(w) && typeof w.code === \"string\" ? [w.code] : typeof w === \"string\" ? [w] : []))\n : []\n const rows = [...output.clips].filter(isObject).sort((a, b) => Number(a.clip) - Number(b.clip))\n if (rows.length !== output.clips.length || rows.some((r, i) => r.clip !== i + 1 || typeof r.url !== \"string\" || r.url === \"\")) return { error: UGC_NEWER_APP_MESSAGE }\n return {\n clips: rows.map((r) => ({\n url: r.url as string,\n meta: { warnings, durationSec: typeof r.sec === \"number\" && Number.isFinite(r.sec) && r.sec > 0 ? r.sec : null },\n })),\n }\n}\n\n/**\n * Whether a UGC Finish reads this UGC Clips node's Script (sized) output: the graph can finish a video\n * whose clips are cut from one recorded speech. Read before the prelude spends anything.\n */\nexport function ugcFinishWired(\n edges: ReadonlyArray<{ readonly source?: string; readonly target?: string; readonly sourceHandle?: string | null; readonly targetHandle?: string | null }>,\n nodes: ReadonlyArray<{ readonly id?: string; readonly type?: string | null }>,\n clipsId: string,\n): boolean {\n const finishIds = new Set(nodes.filter((n) => n.type === UGC_FINISH_CLIPS_TYPE && typeof n.id === \"string\").map((n) => n.id as string))\n return edges.some((e) => e.source === clipsId && e.sourceHandle === \"plan-out\" && e.target !== undefined && finishIds.has(e.target) && (e.targetHandle ?? \"\") === \"plan\")\n}\n\n/** UGC Clips' refusal before its prelude: the sentence when no UGC Finish reads its Script (sized) output, else null. */\nexport function ugcLaneNeedsFinish(\n edges: Parameters<typeof ugcFinishWired>[0],\n nodes: Parameters<typeof ugcFinishWired>[1],\n clipsId: string,\n): string | null {\n return ugcFinishWired(edges, nodes, clipsId) ? null : UGC_NEEDS_FINISH_MESSAGE\n}\n"]}
|