comfy-ts 2.14.0 → 2.16.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 +1 -0
- package/dist/{LogsSt-CUeo843w.js → LogsSt-Ct7Le0S_.js} +2 -2
- package/dist/{LogsSt-CUeo843w.js.map → LogsSt-Ct7Le0S_.js.map} +1 -1
- package/dist/cli.js +4 -4
- package/dist/index.cjs +268 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +176 -26
- package/dist/index.d.ts +176 -26
- package/dist/index.js +262 -56
- package/dist/index.js.map +1 -1
- package/dist/{run-serve-DUqcn0h3.js → run-serve-C78hD7t9.js} +119 -40
- package/dist/run-serve-C78hD7t9.js.map +1 -0
- package/dist/{run-tui-D-LaSqgB.js → run-tui-nPETFRmk.js} +15 -9
- package/dist/run-tui-nPETFRmk.js.map +1 -0
- package/dist/{schemaDrift-E95iTF7E.js → schemaDrift-wb5XkrHV.js} +218 -27
- package/dist/schemaDrift-wb5XkrHV.js.map +1 -0
- package/dist/serve-web.js +64 -50
- package/dist/{state-BytbdZ8s.js → state-BMW57_M0.js} +45 -35
- package/dist/state-BMW57_M0.js.map +1 -0
- package/dist/web.d.ts +173 -26
- package/dist/web.js +251 -53
- package/dist/web.js.map +1 -1
- package/examples/README.md +1 -0
- package/examples/media/README.md +9 -0
- package/examples/media/sine_440hz_3s.flac +0 -0
- package/examples/media/testsrc_256x256_3s.mp4 +0 -0
- package/examples/media/voice_en_6s.flac +0 -0
- package/examples/rvion/04-krea2-turbo-t2i.cflow.ts +9 -1
- package/examples/rvion/10-anima-t2i.cflow.ts +8 -1
- package/examples/rvion/14-video-soundtrack.cflow.ts +47 -0
- package/examples/rvion/15-tts-voice-clone.cflow.ts +111 -0
- package/guide-for-agents.md +3 -1
- package/package.json +2 -2
- package/src/cli/serve/ServeApp.ts +115 -32
- package/src/cli/serve/applyVarPayload.ts +5 -3
- package/src/cli/serve/describeVar.ts +5 -3
- package/src/cli/serve/resultHistory.ts +22 -6
- package/src/cli/serve/run-serve.ts +4 -1
- package/src/cli/serve/web/api.ts +4 -0
- package/src/cli/serve/web/components/DraftTabs.tsx +2 -1
- package/src/cli/serve/web/components/Gallery.tsx +86 -5
- package/src/cli/serve/web/components/HistoryPicker.tsx +5 -3
- package/src/cli/serve/web/components/MenuButton.tsx +2 -4
- package/src/cli/serve/web/components/Omnibox.tsx +2 -1
- package/src/cli/serve/web/components/PromptEnhancer.tsx +4 -3
- package/src/cli/serve/web/components/ShortcutsModal.tsx +2 -1
- package/src/cli/serve/web/components/SideMenu.tsx +2 -1
- package/src/cli/serve/web/components/VarsForm.tsx +5 -3
- package/src/cli/serve/web/components/controls/LorasControl.tsx +4 -3
- package/src/cli/serve/web/components/controls/MediaControl.tsx +111 -0
- package/src/cli/serve/web/components/controls/PresetPicker.tsx +2 -1
- package/src/cli/serve/web/components/controls/PromptControl.tsx +2 -1
- package/src/cli/serve/web/components/controls/SizeControl.tsx +2 -1
- package/src/cli/serve/web/state/FormSt.ts +70 -2
- package/src/cli/serve/web/state/escape.ts +16 -0
- package/src/cli/serve/web/state/host.ts +2 -0
- package/src/cli/serve/web/state/mediaDrop.ts +76 -0
- package/src/cli/serve/web/styles.ts +16 -2
- package/src/cli/tui/imagePicker/ImagePickerOverlay.tsx +4 -1
- package/src/cli/tui/imagePicker/ImagePickerSt.ts +15 -6
- package/src/cli/tui/state/TuiSt.ts +1 -1
- package/src/coreExports.ts +20 -1
- package/src/exampleAssets.ts +13 -3
- package/src/host/ComfyUploader.ts +34 -27
- package/src/index.ts +1 -1
- package/src/runner/ComfyExecution.ts +38 -20
- package/src/runner/ComfyWsApi.ts +3 -0
- package/src/runner/mediaKinds.ts +51 -0
- package/src/vars/ComfyVars.ts +178 -34
- package/src/vars/DefinedWorkflow.ts +35 -2
- package/dist/run-serve-DUqcn0h3.js.map +0 -1
- package/dist/run-tui-D-LaSqgB.js.map +0 -1
- package/dist/schemaDrift-E95iTF7E.js.map +0 -1
- package/dist/state-BytbdZ8s.js.map +0 -1
- package/src/cli/serve/web/components/controls/ImageControl.tsx +0 -72
package/examples/README.md
CHANGED
|
@@ -9,6 +9,7 @@ Every `*.cflow.ts` file here is a runnable workflow module: run it directly with
|
|
|
9
9
|
- `rvion/06-qwen-image-edit.cflow.ts` — image editing (qwen image edit 2511) against the same local host.
|
|
10
10
|
- `rvion/07-local-llm-text-gen.cflow.ts` — a local LLM, no image: core's `TextGenerate` runs a chat model loaded through `CLIPLoader`, and the text comes back in `execution.text`. `--sweep` reports which text encoders on your host actually generate.
|
|
11
11
|
- `rvion/08-qwen-image-21-t2i.cflow.ts` / `rvion/09-qwen-image-21-edit.cflow.ts` — Qwen Image 2.1 (ComfyUI ≥ 0.37) against the same local host: text to image, and instruction editing of one reference image (its `remove background` preset is the official background-removal template).
|
|
12
|
+
- `rvion/15-tts-voice-clone.cflow.ts` — text to speech in a cloned voice (needs the [TTS-Audio-Suite](https://github.com/diodiogod/TTS-Audio-Suite) custom node pack on the host): pick an engine (Chatterbox Multilingual v3 by default, Qwen3-TTS, Fish Audio S2 Pro, CosyVoice3, OmniVoice) and a language, drop a voice clip and write its transcript, and the text comes back as audio in `execution.audios`.
|
|
12
13
|
- `comfy-cloud/<family>-<mode>.cflow.ts` — the model zoo: one clean example per model family × mode (`t2i`, `i2i`, `t2v`, `i2v`, `t2a`), each mirroring an official ComfyUI template (flux, qwen-image, z-image, wan, hidream, ace-step, …). All share `comfy-cloud/cloudHost.ts`.
|
|
13
14
|
|
|
14
15
|
## Cloud API key
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Bundled example media
|
|
2
|
+
|
|
3
|
+
Default inputs for the examples that take an audio or a video file. They ship in the npm tarball, so these examples run out of the box. All are synthetic (ffmpeg test sources, or a voice invented by a TTS model), so no license question applies.
|
|
4
|
+
|
|
5
|
+
| file | what | made with |
|
|
6
|
+
| ------------------------ | --------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
7
|
+
| `testsrc_256x256_3s.mp4` | 3 s, 256×256, 12 fps, h264, no audio track | `ffmpeg -f lavfi -i "testsrc2=size=256x256:rate=12:duration=3" -c:v libx264 -pix_fmt yuv420p -crf 30 -movflags +faststart` |
|
|
8
|
+
| `sine_440hz_3s.flac` | 3 s, 440 Hz sine at 30% volume, 22.05 kHz | `ffmpeg -f lavfi -i "sine=frequency=440:duration=3:sample_rate=22050" -af "volume=0.3" -c:a flac` |
|
|
9
|
+
| `voice_en_6s.flac` | 6.4 s of English speech, 24 kHz mono, the default voice of example 15 | Qwen3-TTS 1.7B VoiceDesign (Apache 2.0), instruction « a calm, warm adult narrator in his thirties, clear diction, neutral American English accent, steady medium pace », text « This is a short sample of my voice. Clone it, and I can read any text you give me, in many languages. », seed 7 |
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -45,6 +45,14 @@ export const t2i = host.defineWorkflow({
|
|
|
45
45
|
// number still says exactly which one you are on
|
|
46
46
|
seed: v.seed(517, { mode: '+' }),
|
|
47
47
|
steps: v.int(8, { min: 1, max: 40 }),
|
|
48
|
+
// the base model: every krea file the box has, read live from the host (serve's
|
|
49
|
+
// "refresh schema" picks up a new download). A finetune is chosen in the draft,
|
|
50
|
+
// so its file name never has to be written here
|
|
51
|
+
checkpoint: v.model('UNETLoader.unet_name', {
|
|
52
|
+
filter: /krea/i,
|
|
53
|
+
default: 'krea2_turbo_fp8_scaled.safetensors',
|
|
54
|
+
label: 'checkpoint',
|
|
55
|
+
}),
|
|
48
56
|
size: v.size({ width: 1024, height: 1024 }),
|
|
49
57
|
removeBg: v.toggle(true, 'remove bg'),
|
|
50
58
|
loras,
|
|
@@ -52,7 +60,7 @@ export const t2i = host.defineWorkflow({
|
|
|
52
60
|
},
|
|
53
61
|
build: (b, vars) => {
|
|
54
62
|
// models
|
|
55
|
-
const unet = b.UNETLoader({ unet_name:
|
|
63
|
+
const unet = b.UNETLoader({ unet_name: vars.checkpoint, weight_dtype: 'default' })
|
|
56
64
|
const clipLoader = b.CLIPLoader({
|
|
57
65
|
clip_name: 'qwen3vl_4b_fp8_scaled.safetensors',
|
|
58
66
|
type: 'krea2',
|
|
@@ -151,6 +151,13 @@ export const animaT2i = host.defineWorkflow({
|
|
|
151
151
|
groupColor: 'rgba(122, 162, 247, 0.08)',
|
|
152
152
|
description: 'turbo and base+turbo: 8 steps at turbo cfg. aesthetic and base: the steps and cfg below',
|
|
153
153
|
}),
|
|
154
|
+
// a finetune in place of the model's own file, read live from the host. The model
|
|
155
|
+
// choice above still decides the sampling (turbo or not), so pick the one it matches
|
|
156
|
+
checkpoint: v.model('UNETLoader.unet_name', { filter: /anima/i, default: null, label: 'checkpoint' }).ui({
|
|
157
|
+
group: 'sampling',
|
|
158
|
+
description:
|
|
159
|
+
"none = the model choice's own file. Any other file replaces it and keeps that choice's sampling",
|
|
160
|
+
}),
|
|
154
161
|
// auto = er_sde on aesthetic and base, euler on the distilled ones
|
|
155
162
|
sampler: v.choice(['auto', 'er_sde', 'euler', 'euler_ancestral'], 'auto', 'sampler').ui({ group: 'sampling' }),
|
|
156
163
|
// the distilled models ignore these: 8 steps at cfg 1 is what they were distilled for
|
|
@@ -187,7 +194,7 @@ export const animaT2i = host.defineWorkflow({
|
|
|
187
194
|
device: 'default',
|
|
188
195
|
})
|
|
189
196
|
const spec = MODELS[vars.model]
|
|
190
|
-
let model = b.UNETLoader({ unet_name: spec.unet, weight_dtype: 'default' })._MODEL
|
|
197
|
+
let model = b.UNETLoader({ unet_name: vars.checkpoint ?? spec.unet, weight_dtype: 'default' })._MODEL
|
|
191
198
|
let clip = clipLoader._CLIP
|
|
192
199
|
if (spec.turboLora) model = b.LoraLoaderModelOnly({ model, lora_name: TURBO_LORA, strength_model: 1 })._MODEL
|
|
193
200
|
for (const l of activeLoras(vars.loras)) {
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// a new soundtrack on a video, on windows-1: the frames of one file, the audio of another, muxed
|
|
2
|
+
// back into one video at the fps you pick (lower = slower). Core nodes only, no model
|
|
3
|
+
// shows the media vars: v.video and v.audio load through LoadVideo and LoadAudio, and the result
|
|
4
|
+
// comes back as a VIDEO output (execution.videos). In the serve panel, drop a file on either var,
|
|
5
|
+
// or drag a generated video or audio from the results onto it
|
|
6
|
+
// run directly: bun examples/rvion/14-video-soundtrack.cflow.ts [video.mp4] [audio.flac]
|
|
7
|
+
import { ComfyTS, exampleMediaPath, v } from 'comfy-ts'
|
|
8
|
+
|
|
9
|
+
const comfy = ComfyTS.create()
|
|
10
|
+
const host = comfy.host({ id: 'windows-1', host: 'desktop-im18794', port: 8085 })
|
|
11
|
+
await host.loadSchemaFromCache() // offline import; run() connects lazily
|
|
12
|
+
|
|
13
|
+
// bundled defaults (examples/media/, ship in the tarball)
|
|
14
|
+
const video = v.video(exampleMediaPath('testsrc_256x256_3s.mp4'))
|
|
15
|
+
const soundtrack = v.audio(exampleMediaPath('sine_440hz_3s.flac'))
|
|
16
|
+
|
|
17
|
+
export const videoSoundtrack = host.defineWorkflow({
|
|
18
|
+
id: 'video-soundtrack',
|
|
19
|
+
tags: ['soundtrack', 'mux'],
|
|
20
|
+
vars: {
|
|
21
|
+
video,
|
|
22
|
+
soundtrack,
|
|
23
|
+
fps: v.float(12, { min: 1, max: 60 }),
|
|
24
|
+
},
|
|
25
|
+
// async build: both files are uploaded (hash-named, deduped) per run
|
|
26
|
+
build: async (b, vars, wf) => {
|
|
27
|
+
const frames = b.GetVideoComponents({ video: await video.loadInWorkflow(wf) })
|
|
28
|
+
b.SaveVideo({
|
|
29
|
+
video: b.CreateVideo({ images: frames._IMAGE, fps: vars.fps, audio: await soundtrack.loadInWorkflow(wf) }),
|
|
30
|
+
filename_prefix: 'comfy-ts-example/video-soundtrack',
|
|
31
|
+
format: 'mp4',
|
|
32
|
+
codec: 'h264',
|
|
33
|
+
})
|
|
34
|
+
},
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
export default videoSoundtrack
|
|
38
|
+
|
|
39
|
+
// standalone run (skipped when another driver — e.g. the TUI — imports this module)
|
|
40
|
+
if (import.meta.main) {
|
|
41
|
+
if (process.argv[2]) videoSoundtrack.vars.video.set(process.argv[2])
|
|
42
|
+
if (process.argv[3]) videoSoundtrack.vars.soundtrack.set(process.argv[3])
|
|
43
|
+
|
|
44
|
+
const execution = await videoSoundtrack.run({ log: true, save: { prefix: 'comfy-ts-example/video-soundtrack' } })
|
|
45
|
+
for (const clip of execution.videos) console.log(`🟢 ${clip.absPath}`)
|
|
46
|
+
host.disconnect()
|
|
47
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// text to speech in a cloned voice, on windows-1: one reference clip and its transcript become the
|
|
2
|
+
// voice, and the engine you pick reads your text with it, in the language you pick
|
|
3
|
+
// engines: chatterbox (Chatterbox Multilingual v3, 0.5B, fast), qwen3 (Qwen3-TTS 1.7B Base),
|
|
4
|
+
// fishs2 (Fish Audio S2 Pro, fp8), cosyvoice3 (Fun-CosyVoice3 0.5B), omnivoice (OmniVoice)
|
|
5
|
+
// box inventory: custom node pack TTS-Audio-Suite (github.com/diodiogod/TTS-Audio-Suite); every
|
|
6
|
+
// engine downloads its weights on first use, which takes minutes. The bundled voice is synthetic
|
|
7
|
+
// (examples/media/README.md); drop your own clip on `voice` and write what it says in `transcript`
|
|
8
|
+
// run directly: bun examples/rvion/15-tts-voice-clone.cflow.ts ["text"] [engine] [language]
|
|
9
|
+
import { ComfyTS, exampleMediaPath, v } from 'comfy-ts'
|
|
10
|
+
|
|
11
|
+
const comfy = ComfyTS.create()
|
|
12
|
+
const host = comfy.host({ id: 'windows-1', host: 'desktop-im18794', port: 8085 })
|
|
13
|
+
await host.loadSchemaFromCache() // offline import; run() connects lazily
|
|
14
|
+
|
|
15
|
+
const ENGINES = ['chatterbox', 'qwen3', 'fishs2', 'cosyvoice3', 'omnivoice'] as const
|
|
16
|
+
// the languages every engine here names the same way
|
|
17
|
+
const LANGUAGES = [
|
|
18
|
+
'English',
|
|
19
|
+
'French',
|
|
20
|
+
'German',
|
|
21
|
+
'Spanish',
|
|
22
|
+
'Italian',
|
|
23
|
+
'Portuguese',
|
|
24
|
+
'Russian',
|
|
25
|
+
'Japanese',
|
|
26
|
+
'Korean',
|
|
27
|
+
'Chinese',
|
|
28
|
+
] as const
|
|
29
|
+
|
|
30
|
+
// bundled default (examples/media/, ships in the tarball)
|
|
31
|
+
const voice = v.audio(exampleMediaPath('voice_en_6s.flac'))
|
|
32
|
+
|
|
33
|
+
export const ttsVoiceClone = host.defineWorkflow({
|
|
34
|
+
id: 'tts-voice-clone',
|
|
35
|
+
tags: ['tts', 'voice'],
|
|
36
|
+
vars: {
|
|
37
|
+
prompt: v.prompt(
|
|
38
|
+
'Welcome back, traveler. The road ahead is long, but the view from the top is worth every step.',
|
|
39
|
+
),
|
|
40
|
+
seed: v.seed(1),
|
|
41
|
+
engine: v.choice(ENGINES, 'chatterbox', 'engine'),
|
|
42
|
+
language: v.choice(LANGUAGES, 'English', 'language'),
|
|
43
|
+
voice,
|
|
44
|
+
transcript: v.text(
|
|
45
|
+
'This is a short sample of my voice. Clone it, and I can read any text you give me, in many languages.',
|
|
46
|
+
{
|
|
47
|
+
label: 'transcript of the voice clip',
|
|
48
|
+
},
|
|
49
|
+
),
|
|
50
|
+
},
|
|
51
|
+
// async build: the voice clip is uploaded (hash-named, deduped) per run
|
|
52
|
+
build: async (b, vars, wf) => {
|
|
53
|
+
const S = 'TTS-Audio-Suite'
|
|
54
|
+
const engine = (() => {
|
|
55
|
+
switch (vars.engine) {
|
|
56
|
+
case 'chatterbox':
|
|
57
|
+
return b[`${S}.ChatterBoxOfficial23LangEngineNode`]({
|
|
58
|
+
model_version: 'v3',
|
|
59
|
+
language: vars.language,
|
|
60
|
+
device: 'auto',
|
|
61
|
+
})
|
|
62
|
+
case 'qwen3':
|
|
63
|
+
return b[`${S}.Qwen3TTSEngineNode`]({
|
|
64
|
+
model_variant: 'TTS - Base 1.7B (Voice Clone)',
|
|
65
|
+
device: 'auto',
|
|
66
|
+
voice_preset: 'None (Zero-shot / Custom)',
|
|
67
|
+
language: vars.language,
|
|
68
|
+
instruct: '',
|
|
69
|
+
})
|
|
70
|
+
case 'fishs2':
|
|
71
|
+
return b[`${S}.FishAudioS2EngineNode`]({ model: 's2-pro-fp8', device: 'auto' })
|
|
72
|
+
case 'cosyvoice3':
|
|
73
|
+
return b[`${S}.CosyVoiceEngineNode`]({ model_path: 'Fun-CosyVoice3-0.5B-RL', device: 'auto' })
|
|
74
|
+
case 'omnivoice':
|
|
75
|
+
return b[`${S}.OmniVoiceEngineNode`]({
|
|
76
|
+
model_variant: 'OmniVoice',
|
|
77
|
+
device: 'auto',
|
|
78
|
+
language: vars.language,
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
})()
|
|
82
|
+
const narrator = b[`${S}.CharacterVoicesNode`]({
|
|
83
|
+
voice_name: 'none',
|
|
84
|
+
reference_text: vars.transcript,
|
|
85
|
+
opt_audio_input: await voice.loadInWorkflow(wf),
|
|
86
|
+
})
|
|
87
|
+
const speech = b[`${S}.UnifiedTTSTextNode`]({
|
|
88
|
+
TTS_engine: engine.outputs.TTS_engine,
|
|
89
|
+
text: vars.prompt.positive,
|
|
90
|
+
narrator_voice: 'none',
|
|
91
|
+
opt_narrator: narrator.outputs.opt_narrator,
|
|
92
|
+
seed: vars.seed,
|
|
93
|
+
enable_chunking: false,
|
|
94
|
+
enable_audio_cache: false,
|
|
95
|
+
})
|
|
96
|
+
b.PreviewAudio({ audio: speech.outputs.audio })
|
|
97
|
+
},
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
export default ttsVoiceClone
|
|
101
|
+
|
|
102
|
+
// standalone run (skipped when another driver — e.g. the TUI — imports this module)
|
|
103
|
+
if (import.meta.main) {
|
|
104
|
+
if (process.argv[2]) ttsVoiceClone.vars.prompt.set(process.argv[2])
|
|
105
|
+
if (process.argv[3]) ttsVoiceClone.vars.engine.set(process.argv[3] as (typeof ENGINES)[number])
|
|
106
|
+
if (process.argv[4]) ttsVoiceClone.vars.language.set(process.argv[4] as (typeof LANGUAGES)[number])
|
|
107
|
+
|
|
108
|
+
const execution = await ttsVoiceClone.run({ log: true, save: { prefix: 'comfy-ts-example/tts-voice-clone' } })
|
|
109
|
+
for (const clip of execution.audios) console.log(`🟢 ${clip.absPath}`)
|
|
110
|
+
host.disconnect()
|
|
111
|
+
}
|
package/guide-for-agents.md
CHANGED
|
@@ -71,11 +71,13 @@ if (import.meta.main) {
|
|
|
71
71
|
}
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
-
Var kinds: `v.text`, `v.int`, `v.float`, `v.seed`, `v.toggle`, `v.choice`, `v.size`, `v.loras`, `v.prompt`, `v.image`. Notes:
|
|
74
|
+
Var kinds: `v.text`, `v.int`, `v.float`, `v.seed`, `v.toggle`, `v.choice`, `v.size`, `v.loras`, `v.prompt`, `v.model`, `v.image`, `v.audio`, `v.video`. Notes:
|
|
75
75
|
|
|
76
76
|
- `v.loras(/regex/)` resolves against the host's real lora list; `activeLoras(vars.loras)` returns `{ lora_name, strength_model, strength_clip }[]` for a standard `LoraLoader` chain.
|
|
77
77
|
- `v.prompt` is structured: `//` lines are comments (stripped), `- ` lines go to the negative prompt, `{ loraKeywordsFrom: lorasVar }` prefixes lora trigger keywords. The value is `{ positive, negative }`.
|
|
78
78
|
- `v.image` holds a local image path as a plain string; an empty value throws at build time instead of running a silent placeholder. Capture the var in a const and call `image.absPath()` in `build`. Default it to a bundled sample with `exampleImagePath('bear_1024x1024.jpg')` (ships in the package). In the TUI it opens an image picker (browse, favorite folders, recents, preview).
|
|
79
|
+
- `v.model('UNETLoader.unet_name', { default, filter })` (in a `vars: (v) => …` lambda) is a choice over the host's file list for that loader input; use it instead of writing a model file name into the workflow.
|
|
80
|
+
- `v.audio` and `v.video` work the same way for audio and video files. In `build`, `await myVar.loadInWorkflow(wf)` uploads the file and returns the loader node (`LoadImage`, `LoadAudio`, `LoadVideo`). Default them with `exampleMediaPath('sine_440hz_3s.flac')` or `exampleMediaPath('testsrc_256x256_3s.mp4')`. Video results land in `execution.videos`.
|
|
79
81
|
- `vars` may be a lambda `(v) => ({ ... })` so vars can reference each other.
|
|
80
82
|
- `build` may be async, for uploads: the third param `wf` feeds `MediaImage` helpers (`new MediaImage({ path }).loadInWorkflow_viaLoadImageNode(wf)`). Uploads are hash-named and deduped, nothing is re-sent.
|
|
81
83
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "comfy-ts",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.16.0",
|
|
4
4
|
"description": "The complete TypeScript toolkit for ComfyUI and generative AI. Fully type-safe SDK with autocomplete on every node, companion CLI, TUI, agentic docs, and 50+ examples. Design, run and deploy creative pipelines for image, video, audio, 3d and text on any ComfyUI, local, cloud or hosted.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"comfyui",
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
"oxfmt": "^0.60.0",
|
|
141
141
|
"oxlint": "^1.75.0",
|
|
142
142
|
"oxlint-tsgolint": "^7.0.2001",
|
|
143
|
-
"rvlib-shipkit": "^1.
|
|
143
|
+
"rvlib-shipkit": "^1.7.0",
|
|
144
144
|
"rvlib-ts-tools": "^0.3.3",
|
|
145
145
|
"tsdown": "^0.22.14",
|
|
146
146
|
"typescript": "^7.0.2"
|
|
@@ -73,8 +73,8 @@ import {
|
|
|
73
73
|
} from 'src/host/loraManagerApi.ts'
|
|
74
74
|
import { getLoraKeyword } from 'src/vars/loraKeywords.ts'
|
|
75
75
|
import type { ComfyHost } from 'src/host/ComfyHost.ts'
|
|
76
|
-
import {
|
|
77
|
-
import type {
|
|
76
|
+
import { DEFAULT_MEDIA_EXTENSIONS, MEDIA_KINDS, type MediaKind } from 'src/runner/mediaKinds.ts'
|
|
77
|
+
import type { ChoiceVar, LorasVar, MediaVar, OptionalChoiceVar, PromptVar, SeedVar } from 'src/vars/ComfyVars.ts'
|
|
78
78
|
import type { DefinedWorkflow } from 'src/vars/DefinedWorkflow.ts'
|
|
79
79
|
import { bang } from 'src/utils/bang.ts'
|
|
80
80
|
import { extractErrorMessage } from 'src/utils/extractErrorMessage.ts'
|
|
@@ -94,6 +94,8 @@ export type ServeExecution = {
|
|
|
94
94
|
texts?: { nodeId: string; nodeKey: string | null; text: string }[]
|
|
95
95
|
/** audio files (SaveAudio*, PreviewAudio). absPath null = saving off, bytes the only copy */
|
|
96
96
|
audios?: { absPath: string | null; filename: string; mime: string; bytes: Uint8Array }[]
|
|
97
|
+
/** video files (SaveVideo, SaveWEBM, VHS_VideoCombine), same shape as audios */
|
|
98
|
+
videos?: { absPath: string | null; filename: string; mime: string; bytes: Uint8Array }[]
|
|
97
99
|
data: { id: string; error?: unknown }
|
|
98
100
|
/** live global progress (ComfyExecution has it; fakes may omit) — the /run/<module> poll reads it */
|
|
99
101
|
progressGlobal?: { percent: number }
|
|
@@ -121,28 +123,26 @@ export type ServeReply = {
|
|
|
121
123
|
headers?: Record<string, string>
|
|
122
124
|
}
|
|
123
125
|
|
|
124
|
-
/** what serve will read off the disk and upload. Wider than the picker
|
|
125
|
-
* LoadImage takes bmp and tiff too, and a var declaring one of those must not be refused */
|
|
126
|
-
const
|
|
127
|
-
...
|
|
128
|
-
'
|
|
129
|
-
'
|
|
130
|
-
|
|
131
|
-
'avif',
|
|
132
|
-
])
|
|
126
|
+
/** what serve will read off the disk and upload, per medium. Wider than the picker defaults:
|
|
127
|
+
* ComfyUI's LoadImage takes bmp and tiff too, and a var declaring one of those must not be refused */
|
|
128
|
+
const SERVE_MEDIA_FLOOR: Record<MediaKind, Set<string>> = {
|
|
129
|
+
image: new Set([...DEFAULT_MEDIA_EXTENSIONS.image, 'bmp', 'tif', 'tiff', 'avif']),
|
|
130
|
+
audio: new Set([...DEFAULT_MEDIA_EXTENSIONS.audio, 'aac']),
|
|
131
|
+
video: new Set([...DEFAULT_MEDIA_EXTENSIONS.video, 'avi']),
|
|
132
|
+
}
|
|
133
133
|
|
|
134
134
|
/** the first bytes say what a file IS; the name only says what it claims. Cheap, and it stops
|
|
135
135
|
* a .png that holds a key or a script from being read and uploaded to the host.
|
|
136
136
|
* HONEST LIMIT: this is checked before the run, and the file is read again when the graph
|
|
137
137
|
* builds, so a local writer who can swap the path in between still wins. Closing that needs
|
|
138
138
|
* the upload to hold an fd, which is a bigger change than this gate. */
|
|
139
|
-
function
|
|
139
|
+
function looksLikeMedia(kind: MediaKind, path: string): boolean {
|
|
140
140
|
let fd: number | null = null
|
|
141
141
|
try {
|
|
142
142
|
fd = openSync(path, 'r')
|
|
143
143
|
const head = new Uint8Array(16)
|
|
144
144
|
const n = readSync(fd, head, 0, 16, 0)
|
|
145
|
-
return
|
|
145
|
+
return isMediaMagic(kind, head.subarray(0, n))
|
|
146
146
|
} catch {
|
|
147
147
|
return false
|
|
148
148
|
} finally {
|
|
@@ -155,14 +155,15 @@ function looksLikeImage(path: string): boolean {
|
|
|
155
155
|
* the gate: a workflow author narrowing (or emptying) it for listing reasons must not be able
|
|
156
156
|
* to widen what an unauthenticated request can make the server read. The var may narrow this
|
|
157
157
|
* floor, never leave it. */
|
|
158
|
-
function
|
|
158
|
+
function serveAcceptsMediaExt(kind: MediaKind, declared: readonly string[], ext: string): boolean {
|
|
159
|
+
const floor = SERVE_MEDIA_FLOOR[kind]
|
|
159
160
|
if (ext === '') return false
|
|
160
|
-
if (!
|
|
161
|
+
if (!floor.has(ext)) return false
|
|
161
162
|
// a declared list NARROWS the floor by its intersection. When that intersection is empty
|
|
162
163
|
// the declaration says nothing this bridge can honour (a picker filter for a format serve
|
|
163
164
|
// does not read), so the floor stands: narrowing to NOTHING would refuse every image,
|
|
164
165
|
// including the ones the var was declared for
|
|
165
|
-
const narrowed = declared.map((e) => e.toLowerCase().replace(/^\./, '')).filter((e) =>
|
|
166
|
+
const narrowed = declared.map((e) => e.toLowerCase().replace(/^\./, '')).filter((e) => floor.has(e))
|
|
166
167
|
return narrowed.length === 0 || narrowed.includes(ext)
|
|
167
168
|
}
|
|
168
169
|
|
|
@@ -241,6 +242,11 @@ const CONTENT_TYPES: Record<string, string> = {
|
|
|
241
242
|
'.gif': 'image/gif',
|
|
242
243
|
'.mp4': 'video/mp4',
|
|
243
244
|
'.webm': 'video/webm',
|
|
245
|
+
'.m4v': 'video/mp4',
|
|
246
|
+
'.mov': 'video/quicktime',
|
|
247
|
+
'.mkv': 'video/x-matroska',
|
|
248
|
+
'.avi': 'video/x-msvideo',
|
|
249
|
+
'.aac': 'audio/aac',
|
|
244
250
|
'.flac': 'audio/flac',
|
|
245
251
|
'.mp3': 'audio/mpeg',
|
|
246
252
|
'.opus': 'audio/ogg',
|
|
@@ -274,6 +280,47 @@ export function isImageMagic(b: Uint8Array): boolean {
|
|
|
274
280
|
return false
|
|
275
281
|
}
|
|
276
282
|
|
|
283
|
+
/** the same full-signature sniff for every medium: a var of one kind never reads a file of
|
|
284
|
+
* another. mp4, mov and m4a share the isobmff `ftyp` box, the extension floor tells them apart */
|
|
285
|
+
export function isMediaMagic(kind: MediaKind, b: Uint8Array): boolean {
|
|
286
|
+
const at = (i: number, ...want: number[]): boolean => want.every((w, k) => b[i + k] === w)
|
|
287
|
+
const isobmff = at(4, 0x66, 0x74, 0x79, 0x70)
|
|
288
|
+
if (kind === 'image') return isImageMagic(b)
|
|
289
|
+
if (kind === 'audio') {
|
|
290
|
+
if (at(0, 0x52, 0x49, 0x46, 0x46) && at(8, 0x57, 0x41, 0x56, 0x45)) return true // riff....wave
|
|
291
|
+
if (at(0, 0x66, 0x4c, 0x61, 0x43)) return true // flac
|
|
292
|
+
if (at(0, 0x4f, 0x67, 0x67, 0x53)) return true // ogg (vorbis, opus)
|
|
293
|
+
if (at(0, 0x49, 0x44, 0x33)) return true // mp3 with an id3 tag
|
|
294
|
+
// an mpeg frame sync: 11 set bits, a version and a layer that are not reserved, then a
|
|
295
|
+
// bitrate and a sample rate that are not the invalid 1111 and 11. FF FE is refused whole:
|
|
296
|
+
// it is the utf-16le BOM, and a layer I header is never what a real file starts with
|
|
297
|
+
const b0 = b[0]
|
|
298
|
+
const b1 = b[1]
|
|
299
|
+
const b2 = b[2]
|
|
300
|
+
if (
|
|
301
|
+
b0 === 0xff &&
|
|
302
|
+
b1 != null &&
|
|
303
|
+
b1 !== 0xfe &&
|
|
304
|
+
b2 != null &&
|
|
305
|
+
(b1 & 0xe0) === 0xe0 &&
|
|
306
|
+
(b1 & 0x18) !== 0x08 &&
|
|
307
|
+
(b1 & 0x06) !== 0 &&
|
|
308
|
+
b2 >> 4 !== 0xf &&
|
|
309
|
+
((b2 >> 2) & 3) !== 3
|
|
310
|
+
)
|
|
311
|
+
return true
|
|
312
|
+
if (b0 === 0xff && b1 != null && (b1 & 0xf6) === 0xf0) return true // aac adts
|
|
313
|
+
return isobmff // m4a
|
|
314
|
+
}
|
|
315
|
+
if (at(0, 0x1a, 0x45, 0xdf, 0xa3)) return true // ebml: webm, mkv
|
|
316
|
+
if (at(0, 0x52, 0x49, 0x46, 0x46) && at(8, 0x41, 0x56, 0x49, 0x20)) return true // riff....avi
|
|
317
|
+
return isobmff // mp4, mov, m4v
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function isMediaKind(kind: string): kind is MediaKind {
|
|
321
|
+
return (MEDIA_KINDS as readonly string[]).includes(kind)
|
|
322
|
+
}
|
|
323
|
+
|
|
277
324
|
function json(status: number, payload: unknown): ServeReply {
|
|
278
325
|
return { status, contentType: 'application/json', body: JSON.stringify(payload, null, 2) }
|
|
279
326
|
}
|
|
@@ -288,7 +335,8 @@ const USAGE = [
|
|
|
288
335
|
'PUT /drafts/<module>/<draft> with { ...vars } — save (or duplicate to a new name) a draft',
|
|
289
336
|
'DELETE /drafts/<module>/<draft> — delete that draft file',
|
|
290
337
|
'GET /run/<module> — live run status · /run/<module>/preview — latent preview bytes',
|
|
291
|
-
'POST /upload with {"name","dataBase64"} — store a browser file for an image var',
|
|
338
|
+
'POST /upload with {"name","dataBase64"} — store a browser file for an image, audio or video var',
|
|
339
|
+
'GET /images|audio|video/<promptId>/<ix> — an output kept in memory (saving off)',
|
|
292
340
|
'GET /tags/<module>/<var>?q=<text>&limit=<n> — tag completion from the list a prompt var declares (`tags`)',
|
|
293
341
|
'GET /hosts/<hostId>/drift[?full=1] — what changed on the host since the schema was loaded (model files; node types with full=1)',
|
|
294
342
|
'GET /lora-info/<hostId>/<lora> — display name + trigger words (local mirror)',
|
|
@@ -443,6 +491,8 @@ export class ServeApp {
|
|
|
443
491
|
return this.replyMemoryImage(`${segs[1]}/${segs[2]}`)
|
|
444
492
|
if (segs[0] === 'audio' && segs.length === 3 && segs[1] != null && segs[2] != null)
|
|
445
493
|
return this.replyMemoryImage(`audio/${segs[1]}/${segs[2]}`)
|
|
494
|
+
if (segs[0] === 'video' && segs.length === 3 && segs[1] != null && segs[2] != null)
|
|
495
|
+
return this.replyMemoryImage(`video/${segs[1]}/${segs[2]}`)
|
|
446
496
|
if (segs[0] === 'results' && segs.length === 1)
|
|
447
497
|
return json(200, { runs: this.kept.list(), memory: this.kept.usage() })
|
|
448
498
|
if (segs[0] === 'outputs') return this.replyOutput(segs.slice(1))
|
|
@@ -756,7 +806,7 @@ export class ServeApp {
|
|
|
756
806
|
return { status: 200, contentType: 'text/javascript; charset=utf-8', body: js, headers: NO_STORE }
|
|
757
807
|
}
|
|
758
808
|
|
|
759
|
-
/** browser file → local file
|
|
809
|
+
/** browser file → local file a media var can point at (downloadInput family) */
|
|
760
810
|
private replyUpload(req: ServeRequest): ServeReply {
|
|
761
811
|
let parsed: unknown
|
|
762
812
|
try {
|
|
@@ -900,13 +950,13 @@ export class ServeApp {
|
|
|
900
950
|
const dropped =
|
|
901
951
|
rebound.stale.length === 0
|
|
902
952
|
? ''
|
|
903
|
-
: `.
|
|
953
|
+
: `. ${rebound.stale.length} selection(s) this host no longer lists (a lora is dropped, a model stays picked)`
|
|
904
954
|
return json(200, {
|
|
905
955
|
ok: true,
|
|
906
956
|
host: hostId,
|
|
907
957
|
action,
|
|
908
958
|
stale: rebound.stale,
|
|
909
|
-
note: `schema refetched: ${nodes} node types, ${loras} loras, ${rebound.widened} lora var(s) changed${dropped}${lorasNote}`,
|
|
959
|
+
note: `schema refetched: ${nodes} node types, ${loras} loras, ${rebound.widened} lora or model var(s) changed${dropped}${lorasNote}`,
|
|
910
960
|
})
|
|
911
961
|
}
|
|
912
962
|
if (action === 'restart') {
|
|
@@ -943,6 +993,18 @@ export class ServeApp {
|
|
|
943
993
|
if (mod.dw.host.data.id !== hostId) continue
|
|
944
994
|
await this.exclusive(mod.key, () => {
|
|
945
995
|
for (const [name, varDef] of mod.dw.entries()) {
|
|
996
|
+
if (varDef.kind === 'choice') {
|
|
997
|
+
const choice = varDef as ChoiceVar<string> | OptionalChoiceVar<string>
|
|
998
|
+
if (choice.hostSlot == null) continue
|
|
999
|
+
const before = choice.choices.length
|
|
1000
|
+
choice.bindHost(host)
|
|
1001
|
+
if (choice.choices.length !== before) widened++
|
|
1002
|
+
// a model the box no longer lists stays picked: the run then fails on the host,
|
|
1003
|
+
// naming the file, instead of silently running another model
|
|
1004
|
+
if (choice.value != null && !choice.choices.includes(choice.value))
|
|
1005
|
+
stale.push(`${mod.key}/${name}: ${choice.value}`)
|
|
1006
|
+
continue
|
|
1007
|
+
}
|
|
946
1008
|
if (varDef.kind !== 'loras') continue
|
|
947
1009
|
const lorasVar = varDef as LorasVar<string>
|
|
948
1010
|
if (lorasVar.optionsFilter == null) continue // a plain array never re-resolves
|
|
@@ -1591,6 +1653,8 @@ export class ServeApp {
|
|
|
1591
1653
|
const produced = [`${execution.images.length} image(s)`]
|
|
1592
1654
|
const audios = execution.audios ?? []
|
|
1593
1655
|
if (audios.length > 0) produced.push(`${audios.length} audio(s)`)
|
|
1656
|
+
const videos = execution.videos ?? []
|
|
1657
|
+
if (videos.length > 0) produced.push(`${videos.length} video(s)`)
|
|
1594
1658
|
if ((execution.texts ?? []).length > 0) produced.push(`${(execution.texts ?? []).length} text(s)`)
|
|
1595
1659
|
console.log(`[serve] 🟢 ${mod.key}/${draft} done in ${(durationMs / 1000).toFixed(1)}s · ${produced.join(' · ')}`)
|
|
1596
1660
|
|
|
@@ -1610,12 +1674,18 @@ export class ServeApp {
|
|
|
1610
1674
|
blobs.push(this.memoryBlob(key, a.bytes, a.filename))
|
|
1611
1675
|
return key
|
|
1612
1676
|
})
|
|
1677
|
+
const videoKeys = videos.map((a, ix) => {
|
|
1678
|
+
if (a.absPath != null) return null
|
|
1679
|
+
const key = `video/${execution.data.id}/${ix}`
|
|
1680
|
+
blobs.push(this.memoryBlob(key, a.bytes, a.filename))
|
|
1681
|
+
return key
|
|
1682
|
+
})
|
|
1613
1683
|
// the KEY is raw (`<promptId>/<ix>`); the url encodes each segment, and handle() decodes
|
|
1614
1684
|
// per segment, so the lookup gets the raw key back
|
|
1615
1685
|
const memoryUrl = (route: string, key: string): string =>
|
|
1616
1686
|
`/${route}/${key
|
|
1617
1687
|
.split('/')
|
|
1618
|
-
.slice(route === '
|
|
1688
|
+
.slice(route === 'images' ? 0 : 1)
|
|
1619
1689
|
.map((seg) => encodeURIComponent(seg))
|
|
1620
1690
|
.join('/')}`
|
|
1621
1691
|
const record: RunRecord = {
|
|
@@ -1645,8 +1715,17 @@ export class ServeApp {
|
|
|
1645
1715
|
absPath: a.absPath,
|
|
1646
1716
|
}
|
|
1647
1717
|
}),
|
|
1718
|
+
videos: videos.map((a, ix) => {
|
|
1719
|
+
const key = videoKeys[ix]
|
|
1720
|
+
return {
|
|
1721
|
+
filename: a.filename,
|
|
1722
|
+
mime: a.mime,
|
|
1723
|
+
url: a.absPath != null ? this.outputUrl(a.absPath) : key != null ? memoryUrl('video', key) : null,
|
|
1724
|
+
absPath: a.absPath,
|
|
1725
|
+
}
|
|
1726
|
+
}),
|
|
1648
1727
|
}
|
|
1649
|
-
this.kept.add({ record, imageKeys, audioKeys, blobs })
|
|
1728
|
+
this.kept.add({ record, imageKeys, audioKeys, videoKeys, blobs })
|
|
1650
1729
|
|
|
1651
1730
|
// Accept: image/* → first image's bytes directly (curl -o, <img src>)
|
|
1652
1731
|
const first = execution.images[0]
|
|
@@ -1697,7 +1776,7 @@ export class ServeApp {
|
|
|
1697
1776
|
let value = rawValue
|
|
1698
1777
|
// kind, never instanceof: consumer and cli hold different class copies (VarKind
|
|
1699
1778
|
// owns the WHY); casts are the kind-narrowing family, agent/coding.md whitelist 6
|
|
1700
|
-
if (varDef.kind
|
|
1779
|
+
if (isMediaKind(varDef.kind) && typeof rawValue === 'string' && /^https?:\/\//.test(rawValue)) {
|
|
1701
1780
|
try {
|
|
1702
1781
|
value = await this.downloadInput(rawValue)
|
|
1703
1782
|
} catch (e) {
|
|
@@ -1723,18 +1802,19 @@ export class ServeApp {
|
|
|
1723
1802
|
if (err != null) return { status: 400, error: err }
|
|
1724
1803
|
}
|
|
1725
1804
|
|
|
1726
|
-
// 3.
|
|
1805
|
+
// 3. media vars must point at a real FILE of a declared type BEFORE anything is queued.
|
|
1727
1806
|
// the path a request hands us is read off this box and uploaded to the ComfyUI host, so
|
|
1728
1807
|
// the extension list the descriptor advertises is enforced here, not merely advertised:
|
|
1729
1808
|
// a var that accepts .png must not be talked into reading a key or a config file
|
|
1730
1809
|
for (const [k, varDef] of varMap) {
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1810
|
+
const kind = varDef.kind
|
|
1811
|
+
if (!isMediaKind(kind)) continue
|
|
1812
|
+
const media = varDef as MediaVar
|
|
1813
|
+
if (!media.isSet()) continue
|
|
1814
|
+
const abs = media.absPath()
|
|
1735
1815
|
// ONE message for every rejection below: distinct ones told an unauthenticated caller
|
|
1736
1816
|
// whether any path exists, is a file, and what type it is
|
|
1737
|
-
const refuse = { status: 400, error:
|
|
1817
|
+
const refuse = { status: 400, error: `${kind} var '${k}': not a usable ${kind} file` }
|
|
1738
1818
|
if (!existsSync(abs)) return refuse
|
|
1739
1819
|
// the REAL path: statSync follows symlinks, so `pic.png -> id_rsa` passed a check made
|
|
1740
1820
|
// on the link's name. Resolving first means the gate judges the file being read
|
|
@@ -1749,8 +1829,9 @@ export class ServeApp {
|
|
|
1749
1829
|
} catch {
|
|
1750
1830
|
return refuse
|
|
1751
1831
|
}
|
|
1752
|
-
if (!
|
|
1753
|
-
|
|
1832
|
+
if (!serveAcceptsMediaExt(kind, media.extensions, extname(real).toLowerCase().replace(/^\./, '')))
|
|
1833
|
+
return refuse
|
|
1834
|
+
if (!looksLikeMedia(kind, real)) return refuse
|
|
1754
1835
|
}
|
|
1755
1836
|
|
|
1756
1837
|
// 4. seed policy (architecture item 12): payload wins; '?' rerolls;
|
|
@@ -1795,7 +1876,9 @@ export class ServeApp {
|
|
|
1795
1876
|
}
|
|
1796
1877
|
} catch (e) {
|
|
1797
1878
|
// name, not instanceof: same two-copies problem as the var classes
|
|
1798
|
-
|
|
1879
|
+
// both names: a project on an older comfy-ts still throws the image-only one
|
|
1880
|
+
if (e instanceof Error && (e.name === 'MediaVarEmptyError' || e.name === 'ImageVarEmptyError'))
|
|
1881
|
+
return { status: 400, error: e.message }
|
|
1799
1882
|
// the ComfyUI host is upstream of this bridge: 502, not "serve crashed".
|
|
1800
1883
|
// The connect deadline (ConnectOptions.timeoutMs) is what makes this
|
|
1801
1884
|
// this runs inside the module mutex: a url that never answers would hold it
|
|
@@ -11,7 +11,7 @@ import type {
|
|
|
11
11
|
AnyVar,
|
|
12
12
|
AnyChoiceVar,
|
|
13
13
|
FloatVar,
|
|
14
|
-
|
|
14
|
+
MediaVar,
|
|
15
15
|
IntVar,
|
|
16
16
|
LorasVar,
|
|
17
17
|
PromptVar,
|
|
@@ -158,9 +158,11 @@ export function applyVarPayload(
|
|
|
158
158
|
return `var '${name}' expects {"width":W,"height":H}, "WxH", or a preset label`
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
case 'image':
|
|
161
|
+
case 'image':
|
|
162
|
+
case 'audio':
|
|
163
|
+
case 'video': {
|
|
162
164
|
if (typeof raw !== 'string') return `var '${name}' expects a file path or http(s) url string`
|
|
163
|
-
;(varDef as
|
|
165
|
+
;(varDef as MediaVar).set(raw)
|
|
164
166
|
return null
|
|
165
167
|
}
|
|
166
168
|
|
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
AnyChoiceVar,
|
|
7
7
|
ChoiceSelect,
|
|
8
8
|
FloatVar,
|
|
9
|
-
|
|
9
|
+
MediaVar,
|
|
10
10
|
IntVar,
|
|
11
11
|
LorasVar,
|
|
12
12
|
PromptVar,
|
|
@@ -162,8 +162,10 @@ export function describeVar(varDef: AnyVar): VarDescriptor {
|
|
|
162
162
|
starredPresets: [...v.starred],
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
|
-
case 'image':
|
|
166
|
-
|
|
165
|
+
case 'image':
|
|
166
|
+
case 'audio':
|
|
167
|
+
case 'video': {
|
|
168
|
+
const v = varDef as MediaVar
|
|
167
169
|
return { ...base, payload: 'local file path or http(s) url', extensions: v.extensions }
|
|
168
170
|
}
|
|
169
171
|
default: {
|