@nodaro/shared 3.67.0 → 3.68.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-JTYCJ5OL.cjs → chunk-4XR66IWF.cjs} +51 -13
- package/dist/chunk-4XR66IWF.cjs.map +1 -0
- package/dist/{chunk-6FQBKI2A.cjs → chunk-6JSYNKFL.cjs} +4 -4
- package/dist/{chunk-6FQBKI2A.cjs.map → chunk-6JSYNKFL.cjs.map} +1 -1
- package/dist/{chunk-23IKLMRL.cjs → chunk-BCY3A62O.cjs} +4 -4
- package/dist/{chunk-23IKLMRL.cjs.map → chunk-BCY3A62O.cjs.map} +1 -1
- package/dist/{chunk-RVQW623D.js → chunk-BHL7TAQO.js} +43 -12
- package/dist/chunk-BHL7TAQO.js.map +1 -0
- package/dist/{chunk-CLAKSLXF.js → chunk-E3PU7YC6.js} +3 -3
- package/dist/{chunk-CLAKSLXF.js.map → chunk-E3PU7YC6.js.map} +1 -1
- package/dist/{chunk-ALRXY4QH.cjs → chunk-N7ZJD4CK.cjs} +6 -2
- package/dist/chunk-N7ZJD4CK.cjs.map +1 -0
- package/dist/{chunk-O2QOBA6Q.js → chunk-NPGP6FMU.js} +43 -3
- package/dist/chunk-NPGP6FMU.js.map +1 -0
- package/dist/chunk-NWNRATS3.js +13 -0
- package/dist/chunk-NWNRATS3.js.map +1 -0
- package/dist/{chunk-ZQ2BHOFH.cjs → chunk-Q2LEJXLZ.cjs} +6 -6
- package/dist/{chunk-ZQ2BHOFH.cjs.map → chunk-Q2LEJXLZ.cjs.map} +1 -1
- package/dist/{chunk-O6TBB4IF.cjs → chunk-TZWXZDSX.cjs} +48 -2
- package/dist/chunk-TZWXZDSX.cjs.map +1 -0
- package/dist/{chunk-CFTXW3ZL.js → chunk-UVUHVY7F.js} +3 -3
- package/dist/{chunk-CFTXW3ZL.js.map → chunk-UVUHVY7F.js.map} +1 -1
- package/dist/{chunk-GTBW2KAY.js → chunk-XNJDAW3M.js} +3 -3
- package/dist/{chunk-GTBW2KAY.js.map → chunk-XNJDAW3M.js.map} +1 -1
- package/dist/entries/credits.cjs +192 -164
- package/dist/entries/credits.d.cts +82 -5
- package/dist/entries/credits.d.ts +82 -5
- package/dist/entries/credits.js +2 -2
- package/dist/entries/media.cjs +111 -107
- package/dist/entries/media.d.cts +17 -2
- package/dist/entries/media.d.ts +17 -2
- package/dist/entries/media.js +3 -3
- package/dist/entries/models.cjs +82 -82
- package/dist/entries/models.js +3 -3
- package/dist/entries/runtime-config.cjs +53 -29
- package/dist/entries/runtime-config.d.cts +53 -1
- package/dist/entries/runtime-config.d.ts +53 -1
- package/dist/entries/runtime-config.js +1 -1
- package/dist/entries/types.d.cts +12 -5
- package/dist/entries/types.d.ts +12 -5
- package/dist/index.cjs +435 -379
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +6 -6
- package/package.json +1 -1
- package/src/__tests__/add-captions-nemotron-pricing.test.ts +13 -1
- package/src/__tests__/fixtures/measured-input-quote-parity.json +1816 -1
- package/src/__tests__/fixtures/planned-length-quote-parity.json +55 -10
- package/src/__tests__/fixtures/video-utility-quote-parity.json +834 -38
- package/src/__tests__/nemotron-transcribe-pricing.test.ts +32 -0
- package/src/__tests__/runtime-config-lists.test.ts +92 -0
- package/src/catalog-projection.ts +12 -5
- package/src/credit-estimators/add-captions-nemotron.ts +11 -1
- package/src/credit-estimators/index.ts +6 -1
- package/src/credit-estimators/nemotron-transcribe.ts +35 -3
- package/src/credit-estimators/pitch-tempo.ts +14 -0
- package/src/credit-estimators/video-sfx.ts +15 -0
- package/src/credit-estimators/video-utils.ts +48 -12
- package/src/entries/credits.ts +1 -0
- package/src/entries/runtime-config.ts +10 -1
- package/src/lip-sync-pricing.ts +15 -0
- package/src/priced-clip-seconds.ts +19 -1
- package/src/runtime-config/lists.ts +87 -0
- package/src/runtime-config/worlds.ts +10 -0
- package/dist/chunk-ALRXY4QH.cjs.map +0 -1
- package/dist/chunk-JTYCJ5OL.cjs.map +0 -1
- package/dist/chunk-O2QOBA6Q.js.map +0 -1
- package/dist/chunk-O6TBB4IF.cjs.map +0 -1
- package/dist/chunk-RVQW623D.js.map +0 -1
- package/dist/chunk-SMOO5FAH.js +0 -10
- package/dist/chunk-SMOO5FAH.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkN7ZJD4CK_cjs = require('./chunk-N7ZJD4CK.cjs');
|
|
4
4
|
|
|
5
5
|
// src/video-depth.ts
|
|
6
6
|
var VIDEO_DEPTH_PROVIDERS = ["video-depth-anything", "depth-anything-frames"];
|
|
@@ -79,7 +79,7 @@ function videoDepthMaxSeconds(provider) {
|
|
|
79
79
|
function videoDepthCreditId(provider, durationSec) {
|
|
80
80
|
const maxSec = videoDepthMaxSeconds(provider);
|
|
81
81
|
const known = typeof durationSec === "number" && Number.isFinite(durationSec) && durationSec > 0 && durationSec <= maxSec;
|
|
82
|
-
return `${provider}:${known ?
|
|
82
|
+
return `${provider}:${known ? chunkN7ZJD4CK_cjs.pricedClipSeconds(durationSec) : maxSec}s`;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
exports.FAL_VIDEO_DEPTH_PROVIDERS = FAL_VIDEO_DEPTH_PROVIDERS;
|
|
@@ -98,5 +98,5 @@ exports.videoDepthColormaps = videoDepthColormaps;
|
|
|
98
98
|
exports.videoDepthCreditId = videoDepthCreditId;
|
|
99
99
|
exports.videoDepthLevers = videoDepthLevers;
|
|
100
100
|
exports.videoDepthNeedsGrayscalePass = videoDepthNeedsGrayscalePass;
|
|
101
|
-
//# sourceMappingURL=chunk-
|
|
102
|
-
//# sourceMappingURL=chunk-
|
|
101
|
+
//# sourceMappingURL=chunk-6JSYNKFL.cjs.map
|
|
102
|
+
//# sourceMappingURL=chunk-6JSYNKFL.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources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,CAAA,GAC/C,kBAAA,CAAmB,wBACnB,kBAAA,CAAmB,eAAA;AACzB;AAcO,SAAS,kBAAA,CAAmB,UAAkB,WAAA,EAAgD;AACnG,EAAA,MAAM,MAAA,GAAS,qBAAqB,QAAQ,CAAA;AAC5C,EAAA,MAAM,KAAA,GAAQ,OAAO,WAAA,KAAgB,QAAA,IAAY,MAAA,CAAO,SAAS,WAAW,CAAA,IAAK,WAAA,GAAc,CAAA,IAAK,WAAA,IAAe,MAAA;AACnH,EAAA,OAAO,GAAG,QAAQ,CAAA,CAAA,EAAI,QAAQA,mCAAA,CAAkB,WAAW,IAAI,MAAM,CAAA,CAAA,CAAA;AACvE","file":"chunk-6FQBKI2A.cjs","sourcesContent":["/**\n * Video Depth — the one contract every layer reads: which providers exist and\n * which lane serves each, which optional levers a provider honours, how long a\n * clip may be, and which price row a run is charged from.\n *\n * Colormaps: fal renders every `VIDEO_DEPTH_COLORMAPS` entry natively. The\n * Replicate model's native output is inferno-colorized, so it offers only\n * `inferno` (passed through as-is) and `grayscale`, which a worker ffmpeg pass\n * produces from the inferno output (`videoDepthNeedsGrayscalePass`).\n *\n * Price rows are `model_pricing` rows (`<provider>:<n>s`); the credit amounts\n * live there, never here. Both providers have one row per whole second of the\n * clip, up to the longest clip each accepts. Worked examples (repeated in\n * docs/nodes/processing-video/video-depth.md):\n * video-depth-anything: 0.4 s → `:1s`, 9 s → `:9s`, 9.2 s → `:10s`, 15.015 s → `:15s`, 15.06 s → `:16s`.\n * depth-anything-frames: 0.4 s → `:1s`, 4 s → `:4s`, 4.1 s → `:5s`, 15.015 s → `:15s`, 15.06 s → `:16s`, 80 s → `:80s`.\n */\n\nimport { pricedClipSeconds } from \"./priced-clip-seconds.js\"\n\nexport const VIDEO_DEPTH_PROVIDERS = [\"video-depth-anything\", \"depth-anything-frames\"] as const\nexport type VideoDepthProvider = (typeof VIDEO_DEPTH_PROVIDERS)[number]\n\nexport const FAL_VIDEO_DEPTH_PROVIDERS: ReadonlySet<string> = new Set([\"video-depth-anything\"])\nexport const REPLICATE_VIDEO_DEPTH_PROVIDERS: ReadonlySet<string> = new Set([\"depth-anything-frames\"])\n\n/**\n * The provider a run uses: `raw` when it is a Video Depth provider, else the\n * default (the first entry). Raw workflow JSON or a FieldMapping can carry any\n * value; the dispatch, the model deny and the price row all read this one\n * resolution, so an unknown id never reaches a price row or slips the deny.\n */\nexport function resolveVideoDepthProvider(raw: unknown): VideoDepthProvider {\n return typeof raw === \"string\" && (VIDEO_DEPTH_PROVIDERS as readonly string[]).includes(raw)\n ? (raw as VideoDepthProvider)\n : VIDEO_DEPTH_PROVIDERS[0]\n}\n\nexport const VIDEO_DEPTH_MODEL_SIZES = [\"small\", \"base\", \"large\"] as const\nexport type VideoDepthModelSize = (typeof VIDEO_DEPTH_MODEL_SIZES)[number]\n\n/** The model size a run uses: `raw` when it is one, else `large` (the providers index lookup tables with it). */\nexport function resolveVideoDepthModelSize(raw: unknown): VideoDepthModelSize {\n return typeof raw === \"string\" && (VIDEO_DEPTH_MODEL_SIZES as readonly string[]).includes(raw)\n ? (raw as VideoDepthModelSize)\n : \"large\"\n}\nexport const VIDEO_DEPTH_COLORMAPS = [\"grayscale\", \"turbo\", \"inferno\", \"magma\", \"viridis\"] as const\nexport type VideoDepthColormap = (typeof VIDEO_DEPTH_COLORMAPS)[number]\nexport const VIDEO_DEPTH_RESOLUTIONS = [\"auto\", \"360p\", \"480p\", \"720p\", \"1080p\"] as const\nexport type VideoDepthResolution = (typeof VIDEO_DEPTH_RESOLUTIONS)[number]\n\nexport type VideoDepthLever = \"colormap\" | \"resolution\" | \"sideBySide\"\nconst ALL_LEVERS: ReadonlySet<VideoDepthLever> = new Set([\"colormap\", \"resolution\", \"sideBySide\"])\nconst COLORMAP_ONLY: ReadonlySet<VideoDepthLever> = new Set([\"colormap\"])\nconst NO_LEVERS: ReadonlySet<VideoDepthLever> = new Set()\n\n/** The optional levers `provider` honours. A lever absent here is dropped, never sent. */\nexport function videoDepthLevers(provider: string): ReadonlySet<VideoDepthLever> {\n if (FAL_VIDEO_DEPTH_PROVIDERS.has(provider)) return ALL_LEVERS\n if (REPLICATE_VIDEO_DEPTH_PROVIDERS.has(provider)) return COLORMAP_ONLY\n return NO_LEVERS\n}\n\nconst REPLICATE_COLORMAPS: readonly VideoDepthColormap[] = [\"grayscale\", \"inferno\"]\n\n/** The colormaps `provider` can deliver, in display order; empty when it has no colormap lever. */\nexport function videoDepthColormaps(provider: string): readonly VideoDepthColormap[] {\n if (FAL_VIDEO_DEPTH_PROVIDERS.has(provider)) return VIDEO_DEPTH_COLORMAPS\n if (REPLICATE_VIDEO_DEPTH_PROVIDERS.has(provider)) return REPLICATE_COLORMAPS\n return []\n}\n\n/** The colormap a run uses: the requested one when `provider` offers it, else `grayscale`; `undefined` when the provider has no colormap lever. Coerces, never throws. */\nexport function resolveVideoDepthColormap(provider: string, requested: unknown): VideoDepthColormap | undefined {\n if (!videoDepthLevers(provider).has(\"colormap\")) return undefined\n const offered = videoDepthColormaps(provider)\n return typeof requested === \"string\" && (offered as readonly string[]).includes(requested)\n ? (requested as VideoDepthColormap)\n : \"grayscale\"\n}\n\n/** True when the worker must turn the Replicate model's native inferno output into grayscale with ffmpeg. */\nexport function videoDepthNeedsGrayscalePass(provider: string, colormap: VideoDepthColormap | undefined): boolean {\n return REPLICATE_VIDEO_DEPTH_PROVIDERS.has(provider) && resolveVideoDepthColormap(provider, colormap) === \"grayscale\"\n}\n\nexport const VIDEO_DEPTH_LIMITS = {\n /** fal `max_frames` ceiling. */\n FAL_MAX_FRAMES: 2400,\n /** Longest clip the fal lane accepts, whatever its frame rate: its top price row, `:300s` (a low-fps clip under the frame limit can otherwise run past every price row). */\n FAL_MAX_SECONDS: 300,\n /** Frame rate assumed when the clip reports none (variable-rate or missing). */\n ASSUMED_FPS: 30,\n /** Longest clip the Replicate lane accepts. */\n REPLICATE_MAX_SECONDS: 80,\n} as const\n\nconst fmt = (n: number): string => n.toLocaleString(\"en-US\")\n\n/** Refuse a clip the provider cannot take — run BEFORE any credit reservation. */\nexport function checkVideoDepthLength(\n provider: string,\n probe: { durationSec: number; fps?: number },\n): { ok: true } | { ok: false; message: string } {\n if (REPLICATE_VIDEO_DEPTH_PROVIDERS.has(provider)) {\n if (probe.durationSec <= VIDEO_DEPTH_LIMITS.REPLICATE_MAX_SECONDS) return { ok: true }\n return {\n ok: false,\n message: `Video is ${Math.ceil(probe.durationSec)} s. This provider accepts at most ${VIDEO_DEPTH_LIMITS.REPLICATE_MAX_SECONDS} s.`,\n }\n }\n if (probe.durationSec > VIDEO_DEPTH_LIMITS.FAL_MAX_SECONDS) {\n return {\n ok: false,\n message: `Video is ${Math.ceil(probe.durationSec)} s. This provider accepts at most ${VIDEO_DEPTH_LIMITS.FAL_MAX_SECONDS} s. Trim the clip and run again.`,\n }\n }\n const assumed = !(typeof probe.fps === \"number\" && probe.fps > 0)\n const fps = assumed ? VIDEO_DEPTH_LIMITS.ASSUMED_FPS : (probe.fps as number)\n const frames = Math.ceil(probe.durationSec * fps - 1e-9)\n if (frames <= VIDEO_DEPTH_LIMITS.FAL_MAX_FRAMES) return { ok: true }\n const maxSec = Math.floor(VIDEO_DEPTH_LIMITS.FAL_MAX_FRAMES / fps)\n return {\n ok: false,\n message:\n `Video is ${fmt(frames)} frames; the limit is ${fmt(VIDEO_DEPTH_LIMITS.FAL_MAX_FRAMES)} ` +\n `(about ${maxSec} s at ${Math.round(fps)} fps${assumed ? \", assumed 30 fps because the clip reports no frame rate\" : \"\"}). Trim the clip and run again.`,\n }\n}\n\n/**\n * The length buckets, in seconds, both providers were priced in before their\n * per-second rows. A row is no longer picked from these: a clip's whole seconds\n * name its row, so a `:15s` is the 15-second row and a `:120s` on Depth Anything\n * per frame is past its limit. Each per-second row took its admin switches from\n * the bucket that priced it (migrations 590 and 595).\n */\nexport const VIDEO_DEPTH_BUCKETS = [15, 30, 60, 120, 300] as const\n\n/** The longest clip `provider` accepts (`checkVideoDepthLength`); the fal limit for anything else. */\nfunction videoDepthMaxSeconds(provider: string): number {\n return REPLICATE_VIDEO_DEPTH_PROVIDERS.has(provider)\n ? VIDEO_DEPTH_LIMITS.REPLICATE_MAX_SECONDS\n : VIDEO_DEPTH_LIMITS.FAL_MAX_SECONDS\n}\n\n/**\n * The price row for a clip of `durationSec`.\n *\n * One row per whole second of the clip on both lanes: the clip's length rounded\n * UP (`pricedClipSeconds`: up to 0.05 s past a whole second is ignored first), so\n * a clip under one second is priced as one. `video-depth-anything:1s` … `:300s`\n * (decided 2026-11-03), `depth-anything-frames:1s` … `:80s` (decided 2026-11-04).\n *\n * Unknown, non-positive or longer than the provider accepts → the provider's\n * longest clip (fal `:300s`, Replicate `:80s`), its highest REACHABLE row — the\n * most a run on it can be charged, never a row a run could not reach.\n */\nexport function videoDepthCreditId(provider: string, durationSec: number | null | undefined): string {\n const maxSec = videoDepthMaxSeconds(provider)\n const known = typeof durationSec === \"number\" && Number.isFinite(durationSec) && durationSec > 0 && durationSec <= maxSec\n return `${provider}:${known ? pricedClipSeconds(durationSec) : maxSec}s`\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/video-depth.ts"],"names":["pricedClipSeconds"],"mappings":";;;;;AAoBO,IAAM,qBAAA,GAAwB,CAAC,sBAAA,EAAwB,uBAAuB;AAG9E,IAAM,yBAAA,mBAAiD,IAAI,GAAA,CAAI,CAAC,sBAAsB,CAAC;AACvF,IAAM,+BAAA,mBAAuD,IAAI,GAAA,CAAI,CAAC,uBAAuB,CAAC;AAQ9F,SAAS,0BAA0B,GAAA,EAAkC;AAC1E,EAAA,OAAO,OAAO,QAAQ,QAAA,IAAa,qBAAA,CAA4C,SAAS,GAAG,CAAA,GACtF,GAAA,GACD,qBAAA,CAAsB,CAAC,CAAA;AAC7B;AAEO,IAAM,uBAAA,GAA0B,CAAC,OAAA,EAAS,MAAA,EAAQ,OAAO;AAIzD,SAAS,2BAA2B,GAAA,EAAmC;AAC5E,EAAA,OAAO,OAAO,GAAA,KAAQ,QAAA,IAAa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AS,IAAA,CAAK,IAAA,CAAK,KAAA,CAAM,WAAA,GAAc,MAAM,IAAI,CAAA;AACvD,EAAA,IAAI,UAAU,kBAAA,CAAmB,cAAA,EAAgB,OAAO,EAAE,IAAI,IAAA,EAAK;AACnE,EAAA,MAAM,MAAA,GAAS,IAAA,CAAK,KAAA,CAAM,kBAAA,CAAmB,iBAAiB,GAAG,CAAA;AACjE,EAAA,OAAO;AAAA,IACL,EAAA,EAAI,KAAA;AAAA,IACJ,OAAA,EACE,YAAY,GAAA,CAAI,MAAM,CAAC,CAAA,sBAAA,EAAyB,GAAA,CAAI,mBAAmB,cAAc,CAAC,WAC5E,MAAM,CAAA,MAAA,EAAS,KAAK,KAAA,CAAM,GAAG,CAAC,CAAA,IAAA,EAAO,OAAA,GAAU,4DAA4D,EAAE,CAAA,+BAAA;AAAA,GAC3H;AACF;AASO,IAAM,sBAAsB,CAAC,EAAA,EAAI,EAAA,EAAI,EAAA,EAAI,KAAK,GAAG;AAGxD,SAAS,qBAAqB,QAAA,EAA0B;AACtD,EAAA,OAAO,gCAAgC,GAAA,CAAI,QAAQ,CAAA,GAC/C,kBAAA,CAAmB,wBACnB,kBAAA,CAAmB,eAAA;AACzB;AAcO,SAAS,kBAAA,CAAmB,UAAkB,WAAA,EAAgD;AACnG,EAAA,MAAM,MAAA,GAAS,qBAAqB,QAAQ,CAAA;AAC5C,EAAA,MAAM,KAAA,GAAQ,OAAO,WAAA,KAAgB,QAAA,IAAY,MAAA,CAAO,SAAS,WAAW,CAAA,IAAK,WAAA,GAAc,CAAA,IAAK,WAAA,IAAe,MAAA;AACnH,EAAA,OAAO,GAAG,QAAQ,CAAA,CAAA,EAAI,QAAQA,mCAAA,CAAkB,WAAW,IAAI,MAAM,CAAA,CAAA,CAAA;AACvE","file":"chunk-6JSYNKFL.cjs","sourcesContent":["/**\n * Video Depth — the one contract every layer reads: which providers exist and\n * which lane serves each, which optional levers a provider honours, how long a\n * clip may be, and which price row a run is charged from.\n *\n * Colormaps: fal renders every `VIDEO_DEPTH_COLORMAPS` entry natively. The\n * Replicate model's native output is inferno-colorized, so it offers only\n * `inferno` (passed through as-is) and `grayscale`, which a worker ffmpeg pass\n * produces from the inferno output (`videoDepthNeedsGrayscalePass`).\n *\n * Price rows are `model_pricing` rows (`<provider>:<n>s`); the credit amounts\n * live there, never here. Both providers have one row per whole second of the\n * clip, up to the longest clip each accepts. Worked examples (repeated in\n * docs/nodes/processing-video/video-depth.md):\n * video-depth-anything: 0.4 s → `:1s`, 9 s → `:9s`, 9.2 s → `:10s`, 15.015 s → `:15s`, 15.06 s → `:16s`.\n * depth-anything-frames: 0.4 s → `:1s`, 4 s → `:4s`, 4.1 s → `:5s`, 15.015 s → `:15s`, 15.06 s → `:16s`, 80 s → `:80s`.\n */\n\nimport { pricedClipSeconds } from \"./priced-clip-seconds.js\"\n\nexport const VIDEO_DEPTH_PROVIDERS = [\"video-depth-anything\", \"depth-anything-frames\"] as const\nexport type VideoDepthProvider = (typeof VIDEO_DEPTH_PROVIDERS)[number]\n\nexport const FAL_VIDEO_DEPTH_PROVIDERS: ReadonlySet<string> = new Set([\"video-depth-anything\"])\nexport const REPLICATE_VIDEO_DEPTH_PROVIDERS: ReadonlySet<string> = new Set([\"depth-anything-frames\"])\n\n/**\n * The provider a run uses: `raw` when it is a Video Depth provider, else the\n * default (the first entry). Raw workflow JSON or a FieldMapping can carry any\n * value; the dispatch, the model deny and the price row all read this one\n * resolution, so an unknown id never reaches a price row or slips the deny.\n */\nexport function resolveVideoDepthProvider(raw: unknown): VideoDepthProvider {\n return typeof raw === \"string\" && (VIDEO_DEPTH_PROVIDERS as readonly string[]).includes(raw)\n ? (raw as VideoDepthProvider)\n : VIDEO_DEPTH_PROVIDERS[0]\n}\n\nexport const VIDEO_DEPTH_MODEL_SIZES = [\"small\", \"base\", \"large\"] as const\nexport type VideoDepthModelSize = (typeof VIDEO_DEPTH_MODEL_SIZES)[number]\n\n/** The model size a run uses: `raw` when it is one, else `large` (the providers index lookup tables with it). */\nexport function resolveVideoDepthModelSize(raw: unknown): VideoDepthModelSize {\n return typeof raw === \"string\" && (VIDEO_DEPTH_MODEL_SIZES as readonly string[]).includes(raw)\n ? (raw as VideoDepthModelSize)\n : \"large\"\n}\nexport const VIDEO_DEPTH_COLORMAPS = [\"grayscale\", \"turbo\", \"inferno\", \"magma\", \"viridis\"] as const\nexport type VideoDepthColormap = (typeof VIDEO_DEPTH_COLORMAPS)[number]\nexport const VIDEO_DEPTH_RESOLUTIONS = [\"auto\", \"360p\", \"480p\", \"720p\", \"1080p\"] as const\nexport type VideoDepthResolution = (typeof VIDEO_DEPTH_RESOLUTIONS)[number]\n\nexport type VideoDepthLever = \"colormap\" | \"resolution\" | \"sideBySide\"\nconst ALL_LEVERS: ReadonlySet<VideoDepthLever> = new Set([\"colormap\", \"resolution\", \"sideBySide\"])\nconst COLORMAP_ONLY: ReadonlySet<VideoDepthLever> = new Set([\"colormap\"])\nconst NO_LEVERS: ReadonlySet<VideoDepthLever> = new Set()\n\n/** The optional levers `provider` honours. A lever absent here is dropped, never sent. */\nexport function videoDepthLevers(provider: string): ReadonlySet<VideoDepthLever> {\n if (FAL_VIDEO_DEPTH_PROVIDERS.has(provider)) return ALL_LEVERS\n if (REPLICATE_VIDEO_DEPTH_PROVIDERS.has(provider)) return COLORMAP_ONLY\n return NO_LEVERS\n}\n\nconst REPLICATE_COLORMAPS: readonly VideoDepthColormap[] = [\"grayscale\", \"inferno\"]\n\n/** The colormaps `provider` can deliver, in display order; empty when it has no colormap lever. */\nexport function videoDepthColormaps(provider: string): readonly VideoDepthColormap[] {\n if (FAL_VIDEO_DEPTH_PROVIDERS.has(provider)) return VIDEO_DEPTH_COLORMAPS\n if (REPLICATE_VIDEO_DEPTH_PROVIDERS.has(provider)) return REPLICATE_COLORMAPS\n return []\n}\n\n/** The colormap a run uses: the requested one when `provider` offers it, else `grayscale`; `undefined` when the provider has no colormap lever. Coerces, never throws. */\nexport function resolveVideoDepthColormap(provider: string, requested: unknown): VideoDepthColormap | undefined {\n if (!videoDepthLevers(provider).has(\"colormap\")) return undefined\n const offered = videoDepthColormaps(provider)\n return typeof requested === \"string\" && (offered as readonly string[]).includes(requested)\n ? (requested as VideoDepthColormap)\n : \"grayscale\"\n}\n\n/** True when the worker must turn the Replicate model's native inferno output into grayscale with ffmpeg. */\nexport function videoDepthNeedsGrayscalePass(provider: string, colormap: VideoDepthColormap | undefined): boolean {\n return REPLICATE_VIDEO_DEPTH_PROVIDERS.has(provider) && resolveVideoDepthColormap(provider, colormap) === \"grayscale\"\n}\n\nexport const VIDEO_DEPTH_LIMITS = {\n /** fal `max_frames` ceiling. */\n FAL_MAX_FRAMES: 2400,\n /** Longest clip the fal lane accepts, whatever its frame rate: its top price row, `:300s` (a low-fps clip under the frame limit can otherwise run past every price row). */\n FAL_MAX_SECONDS: 300,\n /** Frame rate assumed when the clip reports none (variable-rate or missing). */\n ASSUMED_FPS: 30,\n /** Longest clip the Replicate lane accepts. */\n REPLICATE_MAX_SECONDS: 80,\n} as const\n\nconst fmt = (n: number): string => n.toLocaleString(\"en-US\")\n\n/** Refuse a clip the provider cannot take — run BEFORE any credit reservation. */\nexport function checkVideoDepthLength(\n provider: string,\n probe: { durationSec: number; fps?: number },\n): { ok: true } | { ok: false; message: string } {\n if (REPLICATE_VIDEO_DEPTH_PROVIDERS.has(provider)) {\n if (probe.durationSec <= VIDEO_DEPTH_LIMITS.REPLICATE_MAX_SECONDS) return { ok: true }\n return {\n ok: false,\n message: `Video is ${Math.ceil(probe.durationSec)} s. This provider accepts at most ${VIDEO_DEPTH_LIMITS.REPLICATE_MAX_SECONDS} s.`,\n }\n }\n if (probe.durationSec > VIDEO_DEPTH_LIMITS.FAL_MAX_SECONDS) {\n return {\n ok: false,\n message: `Video is ${Math.ceil(probe.durationSec)} s. This provider accepts at most ${VIDEO_DEPTH_LIMITS.FAL_MAX_SECONDS} s. Trim the clip and run again.`,\n }\n }\n const assumed = !(typeof probe.fps === \"number\" && probe.fps > 0)\n const fps = assumed ? VIDEO_DEPTH_LIMITS.ASSUMED_FPS : (probe.fps as number)\n const frames = Math.ceil(probe.durationSec * fps - 1e-9)\n if (frames <= VIDEO_DEPTH_LIMITS.FAL_MAX_FRAMES) return { ok: true }\n const maxSec = Math.floor(VIDEO_DEPTH_LIMITS.FAL_MAX_FRAMES / fps)\n return {\n ok: false,\n message:\n `Video is ${fmt(frames)} frames; the limit is ${fmt(VIDEO_DEPTH_LIMITS.FAL_MAX_FRAMES)} ` +\n `(about ${maxSec} s at ${Math.round(fps)} fps${assumed ? \", assumed 30 fps because the clip reports no frame rate\" : \"\"}). Trim the clip and run again.`,\n }\n}\n\n/**\n * The length buckets, in seconds, both providers were priced in before their\n * per-second rows. A row is no longer picked from these: a clip's whole seconds\n * name its row, so a `:15s` is the 15-second row and a `:120s` on Depth Anything\n * per frame is past its limit. Each per-second row took its admin switches from\n * the bucket that priced it (migrations 590 and 595).\n */\nexport const VIDEO_DEPTH_BUCKETS = [15, 30, 60, 120, 300] as const\n\n/** The longest clip `provider` accepts (`checkVideoDepthLength`); the fal limit for anything else. */\nfunction videoDepthMaxSeconds(provider: string): number {\n return REPLICATE_VIDEO_DEPTH_PROVIDERS.has(provider)\n ? VIDEO_DEPTH_LIMITS.REPLICATE_MAX_SECONDS\n : VIDEO_DEPTH_LIMITS.FAL_MAX_SECONDS\n}\n\n/**\n * The price row for a clip of `durationSec`.\n *\n * One row per whole second of the clip on both lanes: the clip's length rounded\n * UP (`pricedClipSeconds`: up to 0.05 s past a whole second is ignored first), so\n * a clip under one second is priced as one. `video-depth-anything:1s` … `:300s`\n * (decided 2026-11-03), `depth-anything-frames:1s` … `:80s` (decided 2026-11-04).\n *\n * Unknown, non-positive or longer than the provider accepts → the provider's\n * longest clip (fal `:300s`, Replicate `:80s`), its highest REACHABLE row — the\n * most a run on it can be charged, never a row a run could not reach.\n */\nexport function videoDepthCreditId(provider: string, durationSec: number | null | undefined): string {\n const maxSec = videoDepthMaxSeconds(provider)\n const known = typeof durationSec === \"number\" && Number.isFinite(durationSec) && durationSec > 0 && durationSec <= maxSec\n return `${provider}:${known ? pricedClipSeconds(durationSec) : maxSec}s`\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk6JSYNKFL_cjs = require('./chunk-6JSYNKFL.cjs');
|
|
4
4
|
var chunk5NVGKXJV_cjs = require('./chunk-5NVGKXJV.cjs');
|
|
5
5
|
var chunkPJAJCFLP_cjs = require('./chunk-PJAJCFLP.cjs');
|
|
6
6
|
var chunkE62W5I6A_cjs = require('./chunk-E62W5I6A.cjs');
|
|
@@ -447,7 +447,7 @@ var ENUM_TARGETS = [
|
|
|
447
447
|
[chunkPJAJCFLP_cjs.TEXT_TO_VIDEO_PROVIDERS, "generate-video"],
|
|
448
448
|
[chunkPJAJCFLP_cjs.UPSCALE_IMAGE_PROVIDERS, "upscale-image"],
|
|
449
449
|
[chunkPJAJCFLP_cjs.VIDEO_UPSCALE_PROVIDERS, "video-upscale"],
|
|
450
|
-
[
|
|
450
|
+
[chunk6JSYNKFL_cjs.VIDEO_DEPTH_PROVIDERS, "video-depth"],
|
|
451
451
|
[chunkPJAJCFLP_cjs.MODIFY_IMAGE_PROVIDERS, "modify-image"],
|
|
452
452
|
[chunkPJAJCFLP_cjs.IMAGE_EDIT_PROVIDERS, "modify-image"],
|
|
453
453
|
[chunkPJAJCFLP_cjs.VIDEO_TO_VIDEO_PROVIDERS, "video-to-video"],
|
|
@@ -732,5 +732,5 @@ exports.topazVideoOutputSize = topazVideoOutputSize;
|
|
|
732
732
|
exports.topazVideoResolutionNearest = topazVideoResolutionNearest;
|
|
733
733
|
exports.validateProviderForNodeType = validateProviderForNodeType;
|
|
734
734
|
exports.withoutLipSyncLeversNotTaken = withoutLipSyncLeversNotTaken;
|
|
735
|
-
//# sourceMappingURL=chunk-
|
|
736
|
-
//# sourceMappingURL=chunk-
|
|
735
|
+
//# sourceMappingURL=chunk-BCY3A62O.cjs.map
|
|
736
|
+
//# sourceMappingURL=chunk-BCY3A62O.cjs.map
|