comfy-ts 2.13.0 → 2.15.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-C3UIWR-o.js} +2 -2
- package/dist/{LogsSt-CUeo843w.js.map → LogsSt-C3UIWR-o.js.map} +1 -1
- package/dist/cli.js +4 -4
- package/dist/index.cjs +213 -53
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +123 -21
- package/dist/index.d.ts +123 -21
- package/dist/index.js +207 -54
- package/dist/index.js.map +1 -1
- package/dist/{run-serve-DlRBv_Nk.js → run-serve-B5PfIuhK.js} +310 -88
- package/dist/run-serve-B5PfIuhK.js.map +1 -0
- package/dist/{run-tui-B5uxm2_l.js → run-tui-D-N4_yyX.js} +15 -9
- package/dist/run-tui-D-N4_yyX.js.map +1 -0
- package/dist/{schemaDrift-E95iTF7E.js → schemaDrift-BkN8rLiZ.js} +163 -25
- package/dist/schemaDrift-BkN8rLiZ.js.map +1 -0
- package/dist/serve-web.js +160 -71
- package/dist/{state-CUp2J1Zy.js → state-CZsYJqB6.js} +45 -35
- package/dist/state-CZsYJqB6.js.map +1 -0
- package/dist/web.d.ts +120 -21
- package/dist/web.js +196 -51
- package/dist/web.js.map +1 -1
- package/examples/media/README.md +8 -0
- package/examples/media/sine_440hz_3s.flac +0 -0
- package/examples/media/testsrc_256x256_3s.mp4 +0 -0
- package/examples/rvion/14-video-soundtrack.cflow.ts +47 -0
- package/guide-for-agents.md +2 -1
- package/package.json +2 -2
- package/src/cli/serve/ServeApp.ts +189 -110
- package/src/cli/serve/applyVarPayload.ts +5 -3
- package/src/cli/serve/describeVar.ts +5 -3
- package/src/cli/serve/resultHistory.ts +141 -0
- package/src/cli/serve/run-serve.ts +4 -1
- package/src/cli/serve/runError.ts +23 -0
- package/src/cli/serve/serveSettings.ts +17 -1
- package/src/cli/serve/web/api.ts +33 -2
- package/src/cli/serve/web/components/App.tsx +6 -4
- package/src/cli/serve/web/components/Gallery.tsx +116 -11
- package/src/cli/serve/web/components/Icon.tsx +4 -0
- package/src/cli/serve/web/components/MemoryBudget.tsx +98 -0
- package/src/cli/serve/web/components/RunError.tsx +19 -0
- package/src/cli/serve/web/components/ShortcutsModal.tsx +54 -0
- package/src/cli/serve/web/components/SideMenu.tsx +14 -0
- package/src/cli/serve/web/components/VarsForm.tsx +75 -55
- package/src/cli/serve/web/components/controls/BasicControls.tsx +8 -1
- package/src/cli/serve/web/components/controls/LorasControl.tsx +6 -3
- package/src/cli/serve/web/components/controls/MediaControl.tsx +111 -0
- package/src/cli/serve/web/promptEditor/promptExtensions.ts +3 -1
- package/src/cli/serve/web/state/FormSt.ts +70 -2
- package/src/cli/serve/web/state/RunSt.ts +61 -3
- package/src/cli/serve/web/state/WebSt.ts +26 -2
- package/src/cli/serve/web/state/formRows.ts +9 -0
- package/src/cli/serve/web/state/host.ts +2 -0
- package/src/cli/serve/web/state/keptResults.ts +26 -0
- package/src/cli/serve/web/state/lightbox.ts +17 -0
- package/src/cli/serve/web/state/mediaDrop.ts +76 -0
- package/src/cli/serve/web/state/shortcutCatalog.ts +100 -0
- package/src/cli/serve/web/state/shortcuts.ts +10 -0
- package/src/cli/serve/web/styles.ts +112 -24
- 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 +10 -0
- 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 +96 -22
- package/dist/run-serve-DlRBv_Nk.js.map +0 -1
- package/dist/run-tui-B5uxm2_l.js.map +0 -1
- package/dist/schemaDrift-E95iTF7E.js.map +0 -1
- package/dist/state-CUp2J1Zy.js.map +0 -1
- package/src/cli/serve/web/components/controls/ImageControl.tsx +0 -72
package/dist/index.cjs
CHANGED
|
@@ -134,7 +134,7 @@ function createNodeStorage() {
|
|
|
134
134
|
}
|
|
135
135
|
//#endregion
|
|
136
136
|
//#region package.json
|
|
137
|
-
var version = "2.
|
|
137
|
+
var version = "2.15.0";
|
|
138
138
|
//#endregion
|
|
139
139
|
//#region src/litegraph/LiteGraphLinkID.ts
|
|
140
140
|
const asLiteGraphLinkID = (id) => id;
|
|
@@ -2044,6 +2044,8 @@ const types$1 = (0, arktype.scope)({
|
|
|
2044
2044
|
"previews?": [{ filepath: "string" }, "[]"],
|
|
2045
2045
|
"images?": "ComfyImageInfo[]",
|
|
2046
2046
|
"audio?": "ComfyImageInfo[]",
|
|
2047
|
+
"video?": "ComfyImageInfo[]",
|
|
2048
|
+
"gifs?": "ComfyImageInfo[]",
|
|
2047
2049
|
"text?": "unknown[]"
|
|
2048
2050
|
},
|
|
2049
2051
|
prompt_id: "PromptID"
|
|
@@ -2290,24 +2292,79 @@ var MediaImage = class MediaImage {
|
|
|
2290
2292
|
}
|
|
2291
2293
|
};
|
|
2292
2294
|
//#endregion
|
|
2293
|
-
//#region src/runner/
|
|
2294
|
-
/**
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2295
|
+
//#region src/runner/mediaKinds.ts
|
|
2296
|
+
/** picker defaults per kind, lowercase without dots */
|
|
2297
|
+
const DEFAULT_MEDIA_EXTENSIONS = {
|
|
2298
|
+
image: [
|
|
2299
|
+
"png",
|
|
2300
|
+
"jpg",
|
|
2301
|
+
"jpeg",
|
|
2302
|
+
"webp",
|
|
2303
|
+
"gif"
|
|
2304
|
+
],
|
|
2305
|
+
audio: [
|
|
2306
|
+
"wav",
|
|
2307
|
+
"flac",
|
|
2308
|
+
"mp3",
|
|
2309
|
+
"ogg",
|
|
2310
|
+
"opus",
|
|
2311
|
+
"m4a"
|
|
2312
|
+
],
|
|
2313
|
+
video: [
|
|
2314
|
+
"mp4",
|
|
2315
|
+
"webm",
|
|
2316
|
+
"mov",
|
|
2317
|
+
"mkv",
|
|
2318
|
+
"m4v"
|
|
2319
|
+
]
|
|
2320
|
+
};
|
|
2321
|
+
const MIMES = {
|
|
2322
|
+
png: "image/png",
|
|
2323
|
+
jpg: "image/jpeg",
|
|
2324
|
+
jpeg: "image/jpeg",
|
|
2325
|
+
webp: "image/webp",
|
|
2326
|
+
gif: "image/gif",
|
|
2300
2327
|
flac: "audio/flac",
|
|
2301
2328
|
mp3: "audio/mpeg",
|
|
2302
2329
|
opus: "audio/ogg",
|
|
2303
2330
|
ogg: "audio/ogg",
|
|
2304
2331
|
wav: "audio/wav",
|
|
2305
|
-
m4a: "audio/mp4"
|
|
2332
|
+
m4a: "audio/mp4",
|
|
2333
|
+
aac: "audio/aac",
|
|
2334
|
+
mp4: "video/mp4",
|
|
2335
|
+
m4v: "video/mp4",
|
|
2336
|
+
webm: "video/webm",
|
|
2337
|
+
mov: "video/quicktime",
|
|
2338
|
+
mkv: "video/x-matroska",
|
|
2339
|
+
avi: "video/x-msvideo"
|
|
2306
2340
|
};
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2341
|
+
/** video containers an output node can name. An animated webp or gif is an IMAGE: the
|
|
2342
|
+
* extension decides, never the `animated` flag */
|
|
2343
|
+
const VIDEO_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
2344
|
+
"mp4",
|
|
2345
|
+
"m4v",
|
|
2346
|
+
"webm",
|
|
2347
|
+
"mov",
|
|
2348
|
+
"mkv",
|
|
2349
|
+
"avi"
|
|
2350
|
+
]);
|
|
2351
|
+
function extensionOf(filename) {
|
|
2352
|
+
const dot = filename.lastIndexOf(".");
|
|
2353
|
+
return dot < 0 ? "" : filename.slice(dot + 1).toLowerCase();
|
|
2354
|
+
}
|
|
2355
|
+
function isVideoFilename(filename) {
|
|
2356
|
+
return VIDEO_EXTENSIONS.has(extensionOf(filename));
|
|
2310
2357
|
}
|
|
2358
|
+
function mediaMime(filename) {
|
|
2359
|
+
return MIMES[extensionOf(filename)] ?? "application/octet-stream";
|
|
2360
|
+
}
|
|
2361
|
+
//#endregion
|
|
2362
|
+
//#region src/runner/ComfyExecution.ts
|
|
2363
|
+
/** paths claimed by in-flight retrievals: two same-second runs on a
|
|
2364
|
+
* counter-resetting cloud host compute the same name before either writes.
|
|
2365
|
+
* A claim is released as soon as the write lands (the file itself then holds
|
|
2366
|
+
* the name) or fails (the name is free again) — the set never accumulates */
|
|
2367
|
+
const CLAIMED_OUTPUT_PATHS = /* @__PURE__ */ new Set();
|
|
2311
2368
|
var ComfyExecution = class {
|
|
2312
2369
|
get host() {
|
|
2313
2370
|
return this.workflow.host;
|
|
@@ -2374,15 +2431,28 @@ var ComfyExecution = class {
|
|
|
2374
2431
|
text: entry
|
|
2375
2432
|
});
|
|
2376
2433
|
}
|
|
2377
|
-
const
|
|
2378
|
-
|
|
2434
|
+
const out = msg.data.output;
|
|
2435
|
+
const listed = [
|
|
2436
|
+
...out?.images ?? [],
|
|
2437
|
+
...out?.video ?? [],
|
|
2438
|
+
...out?.gifs ?? []
|
|
2439
|
+
].filter((f) => f.type !== "input");
|
|
2440
|
+
for (const video of listed.filter((f) => isVideoFilename(f.filename))) this.pendingPromises.push(this.retrieveFile("video", video, promptNodeID).catch((e) => {
|
|
2441
|
+
console.error(`🔴 failed to retrieve ${video.filename}:`, e);
|
|
2442
|
+
this.videoErrors.push({
|
|
2443
|
+
video,
|
|
2444
|
+
error: e
|
|
2445
|
+
});
|
|
2446
|
+
}));
|
|
2447
|
+
const images = listed.filter((f) => !isVideoFilename(f.filename));
|
|
2448
|
+
if (images.length > 0) for (const img of images) this.pendingPromises.push(this.retrieveImage(img, promptNodeID).catch((e) => {
|
|
2379
2449
|
console.error(`🔴 failed to retrieve ${img.filename}:`, e);
|
|
2380
2450
|
this.imageErrors.push({
|
|
2381
2451
|
image: img,
|
|
2382
2452
|
error: e
|
|
2383
2453
|
});
|
|
2384
2454
|
}));
|
|
2385
|
-
for (const audio of msg.data.output?.audio ?? []) this.pendingPromises.push(this.
|
|
2455
|
+
for (const audio of msg.data.output?.audio ?? []) this.pendingPromises.push(this.retrieveFile("audio", audio, promptNodeID).catch((e) => {
|
|
2386
2456
|
console.error(`🔴 failed to retrieve ${audio.filename}:`, e);
|
|
2387
2457
|
this.audioErrors.push({
|
|
2388
2458
|
audio,
|
|
@@ -2393,13 +2463,16 @@ var ComfyExecution = class {
|
|
|
2393
2463
|
this.pendingPromises = [];
|
|
2394
2464
|
this.audioErrors = [];
|
|
2395
2465
|
this.audios = [];
|
|
2396
|
-
this.
|
|
2466
|
+
this.videoErrors = [];
|
|
2467
|
+
this.videos = [];
|
|
2468
|
+
this.retrieveFile = async (kind, info, promptNodeID) => {
|
|
2397
2469
|
const response = await this.host.fetchFile("/view?" + new URLSearchParams(info).toString());
|
|
2398
2470
|
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
2399
|
-
const mime =
|
|
2471
|
+
const mime = mediaMime(info.filename);
|
|
2472
|
+
const list = kind === "audio" ? this.audios : this.videos;
|
|
2400
2473
|
const sf = this.save;
|
|
2401
2474
|
if (sf == null) {
|
|
2402
|
-
|
|
2475
|
+
list.push({
|
|
2403
2476
|
nodeId: promptNodeID,
|
|
2404
2477
|
filename: info.filename,
|
|
2405
2478
|
mime,
|
|
@@ -2419,7 +2492,7 @@ var ComfyExecution = class {
|
|
|
2419
2492
|
subfolder: info.subfolder,
|
|
2420
2493
|
filename: info.filename
|
|
2421
2494
|
});
|
|
2422
|
-
|
|
2495
|
+
list.push({
|
|
2423
2496
|
nodeId: promptNodeID,
|
|
2424
2497
|
filename: info.filename,
|
|
2425
2498
|
mime,
|
|
@@ -2599,6 +2672,7 @@ var ComfyExecution = class {
|
|
|
2599
2672
|
const p = this.progress;
|
|
2600
2673
|
const outputs = [`${this.images.length} image(s)`];
|
|
2601
2674
|
if (this.audios.length > 0) outputs.push(`${this.audios.length} audio(s)`);
|
|
2675
|
+
if (this.videos.length > 0) outputs.push(`${this.videos.length} video(s)`);
|
|
2602
2676
|
if (this.texts.length > 0) outputs.push(`${this.texts.length} text(s)`);
|
|
2603
2677
|
const line = `${this.status === "Failure" ? "🔴" : "🟢"} ${this.status.toLowerCase()} in ${(p.elapsedMs / 1e3).toFixed(1)}s · ${outputs.join(" · ")}`;
|
|
2604
2678
|
if (globalThis.process?.stdout?.isTTY) process.stdout.write(`\r\x1b[2K${line}\n`);
|
|
@@ -3948,15 +4022,23 @@ const ComfyUploadImageResult_ark = (0, arktype.type)({
|
|
|
3948
4022
|
var ComfyUploader = class {
|
|
3949
4023
|
constructor(host) {
|
|
3950
4024
|
this.host = host;
|
|
4025
|
+
this.uploaded = /* @__PURE__ */ new Set();
|
|
3951
4026
|
this.uploadImage = async (img, p) => {
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
4027
|
+
return await this.uploadInput({
|
|
4028
|
+
blob: img.getAsBlob(),
|
|
4029
|
+
name: img.enumName,
|
|
4030
|
+
...p,
|
|
4031
|
+
slot: "LoadImage.image"
|
|
4032
|
+
});
|
|
4033
|
+
};
|
|
4034
|
+
this.uploadInput = async (p) => {
|
|
4035
|
+
const expectedFinalName = p.subfolder ? `${p.subfolder}/${p.name}` : p.name;
|
|
4036
|
+
if (this.uploaded.has(expectedFinalName) || this.host.schema.stringValues(p.slot).includes(expectedFinalName)) {
|
|
4037
|
+
console.log(`[🌁] UPLOAD: 🩶 "${expectedFinalName}" already exists on current ComfyUI instance`);
|
|
3956
4038
|
return expectedFinalName;
|
|
3957
4039
|
}
|
|
3958
4040
|
const form = new FormData();
|
|
3959
|
-
form.set("image",
|
|
4041
|
+
form.set("image", p.blob, p.name);
|
|
3960
4042
|
if (p.type) form.set("type", p.type);
|
|
3961
4043
|
if (p.override ?? true) form.set("override", "true");
|
|
3962
4044
|
if (p.subfolder) form.set("subfolder", p.subfolder);
|
|
@@ -3966,11 +4048,11 @@ var ComfyUploader = class {
|
|
|
3966
4048
|
});
|
|
3967
4049
|
const result = softValidate(ComfyUploadImageResult_ark, await resp.json());
|
|
3968
4050
|
console.log("[🌁] UPLOAD: ✅ got", result);
|
|
3969
|
-
if (result.name == null) throw new Error(
|
|
4051
|
+
if (result.name == null) throw new Error(`upload of '${p.name}' failed: the host answered no name`);
|
|
3970
4052
|
const finalName = result.subfolder ? `${result.subfolder}/${result.name}` : result.name;
|
|
3971
4053
|
if (finalName !== expectedFinalName) console.warn(`[🌁] UPLOAD: ⚠️ expected "${expectedFinalName}" but got "${finalName}"`);
|
|
3972
|
-
|
|
3973
|
-
this.
|
|
4054
|
+
if (p.slot === "LoadImage.image") this.host.schema.unsafely_addImageInSchemaWithoutReloading(finalName);
|
|
4055
|
+
this.uploaded.add(finalName);
|
|
3974
4056
|
return finalName;
|
|
3975
4057
|
};
|
|
3976
4058
|
}
|
|
@@ -5355,42 +5437,55 @@ var SizeVar = class extends ComfyVar {
|
|
|
5355
5437
|
return `${width}×${height}${hit ? ` (${hit.label})` : ""}`;
|
|
5356
5438
|
}
|
|
5357
5439
|
};
|
|
5358
|
-
const DEFAULT_IMAGE_EXTENSIONS =
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
"
|
|
5364
|
-
|
|
5365
|
-
/** empty image var consumed at build time — typed so drivers surface it apart from real crashes */
|
|
5366
|
-
var ImageVarEmptyError = class extends Error {
|
|
5367
|
-
constructor(varName) {
|
|
5368
|
-
super(`image var '${varName}' is empty — pick a file (TUI: activate the var; script: .set('/path/to/image.png'))`);
|
|
5440
|
+
const DEFAULT_IMAGE_EXTENSIONS = DEFAULT_MEDIA_EXTENSIONS.image;
|
|
5441
|
+
const DEFAULT_AUDIO_EXTENSIONS = DEFAULT_MEDIA_EXTENSIONS.audio;
|
|
5442
|
+
const DEFAULT_VIDEO_EXTENSIONS = DEFAULT_MEDIA_EXTENSIONS.video;
|
|
5443
|
+
/** empty media var consumed at build time — typed so drivers surface it apart from real crashes */
|
|
5444
|
+
var MediaVarEmptyError = class extends Error {
|
|
5445
|
+
constructor(varName, media = "image") {
|
|
5446
|
+
super(`${media} var '${varName}' is empty — pick a file (TUI: activate the var; script: .set('/path/to/file'))`);
|
|
5369
5447
|
this.varName = varName;
|
|
5370
|
-
this.
|
|
5448
|
+
this.media = media;
|
|
5449
|
+
this.name = "MediaVarEmptyError";
|
|
5371
5450
|
}
|
|
5372
5451
|
};
|
|
5373
|
-
/**
|
|
5452
|
+
/** the image-only name this error had first; the same class */
|
|
5453
|
+
const ImageVarEmptyError = MediaVarEmptyError;
|
|
5454
|
+
/** trim + expand a leading `~/` — every media var write funnels through this */
|
|
5374
5455
|
function expandUserPath(raw) {
|
|
5375
5456
|
const trimmed = raw.trim();
|
|
5376
5457
|
return trimmed.startsWith("~/") ? (0, pathe.join)(getComfyStorage().homedir(), trimmed.slice(2)) : trimmed;
|
|
5377
5458
|
}
|
|
5459
|
+
/** the loader node each medium goes through, and its file input */
|
|
5460
|
+
const MEDIA_LOADERS = {
|
|
5461
|
+
image: {
|
|
5462
|
+
node: "LoadImage",
|
|
5463
|
+
input: "image"
|
|
5464
|
+
},
|
|
5465
|
+
audio: {
|
|
5466
|
+
node: "LoadAudio",
|
|
5467
|
+
input: "audio"
|
|
5468
|
+
},
|
|
5469
|
+
video: {
|
|
5470
|
+
node: "LoadVideo",
|
|
5471
|
+
input: "file"
|
|
5472
|
+
}
|
|
5473
|
+
};
|
|
5378
5474
|
/**
|
|
5379
|
-
* a local
|
|
5475
|
+
* a local media file path. The VALUE is a PLAIN PATH STRING — text-encodable,
|
|
5380
5476
|
* drafts persist it verbatim (toJSON = the string), hand-editable in the
|
|
5381
|
-
* draft json. Empty = unset: outValue()/absPath() throw
|
|
5382
|
-
* so a build never runs on a silent placeholder. The TUI opens the
|
|
5383
|
-
* picker overlay for kind
|
|
5477
|
+
* draft json. Empty = unset: outValue()/absPath() throw MediaVarEmptyError,
|
|
5478
|
+
* so a build never runs on a silent placeholder. The TUI opens the file
|
|
5479
|
+
* picker overlay for every media kind.
|
|
5384
5480
|
*/
|
|
5385
|
-
var
|
|
5481
|
+
var MediaVar = class extends ComfyVar {
|
|
5386
5482
|
constructor(defaultValue, opts = {}) {
|
|
5387
5483
|
super(expandUserPath(defaultValue), opts.label);
|
|
5388
5484
|
this.opts = opts;
|
|
5389
|
-
this.kind = "image";
|
|
5390
5485
|
}
|
|
5391
5486
|
/** what the picker lists (lowercase, no dots) */
|
|
5392
5487
|
get extensions() {
|
|
5393
|
-
return this.opts.extensions ??
|
|
5488
|
+
return this.opts.extensions ?? DEFAULT_MEDIA_EXTENSIONS[this.kind];
|
|
5394
5489
|
}
|
|
5395
5490
|
set(value) {
|
|
5396
5491
|
return super.set(expandUserPath(value));
|
|
@@ -5403,7 +5498,7 @@ var ImageVar = class extends ComfyVar {
|
|
|
5403
5498
|
return this.value !== "";
|
|
5404
5499
|
}
|
|
5405
5500
|
emptyError() {
|
|
5406
|
-
return new
|
|
5501
|
+
return new MediaVarEmptyError(this.name ?? this.label ?? this.kind, this.kind);
|
|
5407
5502
|
}
|
|
5408
5503
|
/** the ONE resolution helper: absolute kept as-is, relative resolved against opts.folder, else cwd */
|
|
5409
5504
|
absPath() {
|
|
@@ -5421,8 +5516,56 @@ var ImageVar = class extends ComfyVar {
|
|
|
5421
5516
|
const home = getComfyStorage().homedir();
|
|
5422
5517
|
return this.value.startsWith(`${home}/`) ? `~${this.value.slice(home.length)}` : this.value;
|
|
5423
5518
|
}
|
|
5519
|
+
/** upload the file hash-named (reruns dedupe) and add this medium's loader node. A dry
|
|
5520
|
+
* build names the file by its hash and uploads nothing */
|
|
5521
|
+
async loadVia(wf) {
|
|
5522
|
+
const loader = MEDIA_LOADERS[this.kind];
|
|
5523
|
+
const factory = wf.builderBase[loader.node];
|
|
5524
|
+
if (factory == null) throw new Error(`host '${wf.host.data.id}' has no ${loader.node} node: ${this.kind} var '${this.name ?? "?"}' cannot load`);
|
|
5525
|
+
const abs = this.absPath();
|
|
5526
|
+
const bytes = getComfyStorage().readBytes(abs);
|
|
5527
|
+
const ext = extensionOf(abs);
|
|
5528
|
+
const name = `${hashArrayBuffer(bytes)}${ext === "" ? "" : `.${ext}`}`;
|
|
5529
|
+
const onHost = wf.dry ? name : await wf.host.uploader.uploadInput({
|
|
5530
|
+
blob: new Blob([bytes], { type: mediaMime(abs) }),
|
|
5531
|
+
name,
|
|
5532
|
+
slot: `${loader.node}.${loader.input}`,
|
|
5533
|
+
type: "input"
|
|
5534
|
+
});
|
|
5535
|
+
return factory({ [loader.input]: onHost });
|
|
5536
|
+
}
|
|
5424
5537
|
};
|
|
5425
|
-
/**
|
|
5538
|
+
/** a local image path, loaded through LoadImage */
|
|
5539
|
+
var ImageVar = class extends MediaVar {
|
|
5540
|
+
constructor(..._args2) {
|
|
5541
|
+
super(..._args2);
|
|
5542
|
+
this.kind = "image";
|
|
5543
|
+
}
|
|
5544
|
+
async loadInWorkflow(wf) {
|
|
5545
|
+
return await this.loadVia(wf);
|
|
5546
|
+
}
|
|
5547
|
+
};
|
|
5548
|
+
/** a local audio path, loaded through LoadAudio */
|
|
5549
|
+
var AudioVar = class extends MediaVar {
|
|
5550
|
+
constructor(..._args3) {
|
|
5551
|
+
super(..._args3);
|
|
5552
|
+
this.kind = "audio";
|
|
5553
|
+
}
|
|
5554
|
+
async loadInWorkflow(wf) {
|
|
5555
|
+
return await this.loadVia(wf);
|
|
5556
|
+
}
|
|
5557
|
+
};
|
|
5558
|
+
/** a local video path, loaded through LoadVideo */
|
|
5559
|
+
var VideoVar = class extends MediaVar {
|
|
5560
|
+
constructor(..._args4) {
|
|
5561
|
+
super(..._args4);
|
|
5562
|
+
this.kind = "video";
|
|
5563
|
+
}
|
|
5564
|
+
async loadInWorkflow(wf) {
|
|
5565
|
+
return await this.loadVia(wf);
|
|
5566
|
+
}
|
|
5567
|
+
};
|
|
5568
|
+
/** the var constructors: v.text / v.prompt / v.int / v.float / v.seed / v.toggle / v.choice / v.loras / v.size / v.image / v.audio / v.video */
|
|
5426
5569
|
const v = {
|
|
5427
5570
|
text: (defaultValue, opts = {}) => new TextVar(defaultValue, typeof opts === "string" ? { label: opts } : opts),
|
|
5428
5571
|
prompt: (defaultValue, opts = {}) => new PromptVar(defaultValue, opts),
|
|
@@ -5437,7 +5580,9 @@ const v = {
|
|
|
5437
5580
|
choice,
|
|
5438
5581
|
loras: (options, initial = {}, label) => new LorasVar(options, initial, label),
|
|
5439
5582
|
size: (defaultValue, opts = {}) => new SizeVar(defaultValue, opts.presets ?? sizePresetsFor(defaultValue), opts.label, opts.image, opts.starred),
|
|
5440
|
-
image: (defaultValue, opts = {}) => new ImageVar(defaultValue, opts)
|
|
5583
|
+
image: (defaultValue, opts = {}) => new ImageVar(defaultValue, opts),
|
|
5584
|
+
audio: (defaultValue, opts = {}) => new AudioVar(defaultValue, opts),
|
|
5585
|
+
video: (defaultValue, opts = {}) => new VideoVar(defaultValue, opts)
|
|
5441
5586
|
};
|
|
5442
5587
|
function varValues(vars) {
|
|
5443
5588
|
const out = {};
|
|
@@ -6889,10 +7034,18 @@ function bundledExamplesDir(moduleUrl = require("url").pathToFileURL(__filename)
|
|
|
6889
7034
|
* or the package's examples/ folder was pruned.
|
|
6890
7035
|
*/
|
|
6891
7036
|
function exampleImagePath(name) {
|
|
7037
|
+
return bundledExampleFile("images", name);
|
|
7038
|
+
}
|
|
7039
|
+
/** the same for a bundled `examples/media/` audio or video file, e.g.
|
|
7040
|
+
* `exampleMediaPath('sine_440hz_3s.flac')` — the default of audio and video example vars */
|
|
7041
|
+
function exampleMediaPath(name) {
|
|
7042
|
+
return bundledExampleFile("media", name);
|
|
7043
|
+
}
|
|
7044
|
+
function bundledExampleFile(folder, name) {
|
|
6892
7045
|
const examples = bundledExamplesDir();
|
|
6893
|
-
if (examples == null) throw new Error(`[comfy-ts] cannot resolve bundled example
|
|
6894
|
-
const abs = (0, pathe.join)(examples,
|
|
6895
|
-
if (!(0, node_fs.existsSync)(abs)) throw new Error(`[comfy-ts] bundled example
|
|
7046
|
+
if (examples == null) throw new Error(`[comfy-ts] cannot resolve bundled example file '${name}': the package's examples/ folder is not on disk`);
|
|
7047
|
+
const abs = (0, pathe.join)(examples, folder, name);
|
|
7048
|
+
if (!(0, node_fs.existsSync)(abs)) throw new Error(`[comfy-ts] bundled example file not found: ${abs}`);
|
|
6896
7049
|
return abs;
|
|
6897
7050
|
}
|
|
6898
7051
|
//#endregion
|
|
@@ -6955,6 +7108,7 @@ function isTuiActive() {
|
|
|
6955
7108
|
*/
|
|
6956
7109
|
setDefaultComfyStorage(createNodeStorage());
|
|
6957
7110
|
//#endregion
|
|
7111
|
+
exports.AudioVar = AudioVar;
|
|
6958
7112
|
exports.ChoiceVar = ChoiceVar;
|
|
6959
7113
|
exports.ComfyExecution = ComfyExecution;
|
|
6960
7114
|
exports.ComfyHost = ComfyHost;
|
|
@@ -6970,9 +7124,11 @@ exports.ComfyVar = ComfyVar;
|
|
|
6970
7124
|
exports.ComfyVarBase = ComfyVarBase;
|
|
6971
7125
|
exports.ComfyWorkflow = ComfyWorkflow;
|
|
6972
7126
|
exports.ComfyWorkflowBuilder = ComfyWorkflowBuilder;
|
|
7127
|
+
exports.DEFAULT_AUDIO_EXTENSIONS = DEFAULT_AUDIO_EXTENSIONS;
|
|
6973
7128
|
exports.DEFAULT_IMAGE_EXTENSIONS = DEFAULT_IMAGE_EXTENSIONS;
|
|
6974
7129
|
exports.DEFAULT_SIZE_PRESETS = DEFAULT_SIZE_PRESETS;
|
|
6975
7130
|
exports.DEFAULT_STARRED_SIZES = DEFAULT_STARRED_SIZES;
|
|
7131
|
+
exports.DEFAULT_VIDEO_EXTENSIONS = DEFAULT_VIDEO_EXTENSIONS;
|
|
6976
7132
|
exports.DefinedWorkflow = DefinedWorkflow;
|
|
6977
7133
|
exports.FloatVar = FloatVar;
|
|
6978
7134
|
exports.ImageVar = ImageVar;
|
|
@@ -6981,6 +7137,8 @@ exports.IntVar = IntVar;
|
|
|
6981
7137
|
exports.InvalidPromptError = InvalidPromptError;
|
|
6982
7138
|
exports.LorasVar = LorasVar;
|
|
6983
7139
|
exports.MediaImage = MediaImage;
|
|
7140
|
+
exports.MediaVar = MediaVar;
|
|
7141
|
+
exports.MediaVarEmptyError = MediaVarEmptyError;
|
|
6984
7142
|
exports.MultiChoiceVar = MultiChoiceVar;
|
|
6985
7143
|
exports.OptionalChoiceVar = OptionalChoiceVar;
|
|
6986
7144
|
exports.PromptVar = PromptVar;
|
|
@@ -6990,6 +7148,7 @@ exports.SeedVar = SeedVar;
|
|
|
6990
7148
|
exports.SizeVar = SizeVar;
|
|
6991
7149
|
exports.TextVar = TextVar;
|
|
6992
7150
|
exports.ToggleVar = ToggleVar;
|
|
7151
|
+
exports.VideoVar = VideoVar;
|
|
6993
7152
|
exports.WorkflowConvertError = WorkflowConvertError;
|
|
6994
7153
|
exports.WorkflowNormalizeError = WorkflowNormalizeError;
|
|
6995
7154
|
exports.__FAIL = __FAIL;
|
|
@@ -7008,6 +7167,7 @@ exports.convertFlowToLiteGraphJSON = convertFlowToLiteGraphJSON;
|
|
|
7008
7167
|
exports.convertLiteGraphToPrompt = convertLiteGraphToPrompt;
|
|
7009
7168
|
exports.createMemoryStorage = createMemoryStorage;
|
|
7010
7169
|
exports.exampleImagePath = exampleImagePath;
|
|
7170
|
+
exports.exampleMediaPath = exampleMediaPath;
|
|
7011
7171
|
exports.getComfyStorage = getComfyStorage;
|
|
7012
7172
|
exports.getLoraDisplayName = getLoraDisplayName;
|
|
7013
7173
|
exports.getLoraInfo = getLoraInfo;
|