comfy-ts 2.16.0 → 2.17.1
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 +23 -0
- package/dist/{run-serve-C78hD7t9.js → ServeApp-qXcQfdgT.js} +18 -445
- package/dist/ServeApp-qXcQfdgT.js.map +1 -0
- package/dist/cli.js +72 -9
- package/dist/cli.js.map +1 -1
- package/dist/exampleAssets-BfWzygoM.js +38 -0
- package/dist/exampleAssets-BfWzygoM.js.map +1 -0
- package/dist/{LogsSt-Ct7Le0S_.js → findDefinedWorkflow-0lG-VTEd.js} +201 -201
- package/dist/findDefinedWorkflow-0lG-VTEd.js.map +1 -0
- package/dist/index.cjs +182 -69
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +61 -8
- package/dist/index.d.ts +61 -8
- package/dist/index.js +182 -69
- package/dist/index.js.map +1 -1
- package/dist/run-run-tg82jUIk.js +450 -0
- package/dist/run-run-tg82jUIk.js.map +1 -0
- package/dist/run-serve-DaXzoVTS.js +464 -0
- package/dist/run-serve-DaXzoVTS.js.map +1 -0
- package/dist/{run-tui-nPETFRmk.js → run-tui-Bw7BA75d.js} +7 -38
- package/dist/run-tui-Bw7BA75d.js.map +1 -0
- package/dist/{schemaDrift-wb5XkrHV.js → schemaDrift-CbsABBuk.js} +3 -2
- package/dist/{schemaDrift-wb5XkrHV.js.map → schemaDrift-CbsABBuk.js.map} +1 -1
- package/dist/serve-web.js +56 -48
- package/dist/{state-BMW57_M0.js → state-zTow5ucI.js} +182 -70
- package/dist/state-zTow5ucI.js.map +1 -0
- package/dist/web.d.ts +61 -8
- package/dist/web.js +182 -69
- package/dist/web.js.map +1 -1
- package/examples/README.md +1 -0
- package/examples/rvion/15-tts-voice-clone.cflow.ts +8 -8
- package/examples/rvion/16-tts-voice-design.cflow.ts +71 -0
- package/guide-for-agents.md +3 -0
- package/package.json +2 -2
- package/src/cli/bunHop.ts +49 -0
- package/src/cli/comfy-ts-cli.ts +18 -5
- package/src/cli/run/findModules.ts +36 -0
- package/src/cli/run/flagValue.ts +61 -0
- package/src/cli/run/outputPaths.ts +41 -0
- package/src/cli/run/pickModule.ts +41 -0
- package/src/cli/run/run-run.ts +250 -0
- package/src/cli/run/runArgs.ts +61 -0
- package/src/cli/run/sidecar.ts +27 -0
- package/src/cli/serve/ServeApp.ts +13 -39
- package/src/cli/serve/run-serve.ts +51 -13
- package/src/cli/serve/web/components/App.tsx +2 -0
- package/src/cli/serve/web/components/DialogLayer.tsx +55 -0
- package/src/cli/serve/web/components/DraftTabs.tsx +16 -5
- package/src/cli/serve/web/components/PromptEnhancer.tsx +15 -9
- package/src/cli/serve/web/components/SideMenu.tsx +16 -8
- package/src/cli/serve/web/state/WebSt.ts +10 -1
- package/src/cli/serve/web/state/dialog.ts +59 -0
- package/src/cli/serve/web/state/draftTabs.ts +12 -0
- package/src/cli/serve/web/state/keptLines.ts +1 -1
- package/src/cli/serve/web/state/shortcutCatalog.ts +1 -0
- package/src/cli/serve/web/styles.ts +8 -0
- package/src/coreExports.ts +2 -0
- package/src/host/ComfyHost.ts +73 -40
- package/src/host/previewMethod.ts +29 -0
- package/src/litegraph/convertFlowToLiteGraphJSON.ts +38 -20
- package/src/promptEnhancers.ts +1 -1
- package/src/runner/ComfyExecution.ts +45 -1
- package/src/runner/ComfyWorkflow.ts +6 -1
- package/src/runner/ComfyWsApi.ts +1 -1
- package/src/runner/wsBinaryFrame.ts +48 -25
- package/src/vars/ComfyVars.ts +3 -0
- package/src/vars/DefinedWorkflow.ts +1 -0
- package/dist/LogsSt-Ct7Le0S_.js.map +0 -1
- package/dist/run-serve-C78hD7t9.js.map +0 -1
- package/dist/run-tui-nPETFRmk.js.map +0 -1
- package/dist/state-BMW57_M0.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { X as ansi, a as DefinedWorkflow, at as extractErrorMessage, ct as getComfyStorage, dt as logError, ft as logInfo, ht as sha1HexOfString, it as hashArrayBuffer, lt as resolveComfyStorage, mt as statelessRegex, n as diffSchemas, nt as isVideoFilename, ot as isRecord$1, pt as logSuccess, rt as mediaMime, st as bang, t as MODEL_LISTS, ut as isQuiet } from "./schemaDrift-
|
|
1
|
+
import { X as ansi, a as DefinedWorkflow, at as extractErrorMessage, ct as getComfyStorage, dt as logError, ft as logInfo, ht as sha1HexOfString, it as hashArrayBuffer, lt as resolveComfyStorage, mt as statelessRegex, n as diffSchemas, nt as isVideoFilename, ot as isRecord$1, pt as logSuccess, rt as mediaMime, st as bang, t as MODEL_LISTS, ut as isQuiet } from "./schemaDrift-CbsABBuk.js";
|
|
2
2
|
import { basename, join } from "pathe";
|
|
3
3
|
import { scope, type } from "arktype";
|
|
4
4
|
import { nanoid } from "nanoid";
|
|
@@ -850,7 +850,7 @@ var ComfySchema = class {
|
|
|
850
850
|
};
|
|
851
851
|
//#endregion
|
|
852
852
|
//#region package.json
|
|
853
|
-
var version = "2.
|
|
853
|
+
var version = "2.17.1";
|
|
854
854
|
//#endregion
|
|
855
855
|
//#region src/litegraph/LiteGraphLinkID.ts
|
|
856
856
|
const asLiteGraphLinkID = (id) => id;
|
|
@@ -1390,21 +1390,41 @@ const normalizeGroup = (g) => {
|
|
|
1390
1390
|
};
|
|
1391
1391
|
};
|
|
1392
1392
|
//#endregion
|
|
1393
|
-
//#region src/
|
|
1394
|
-
function
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1393
|
+
//#region src/host/previewMethod.ts
|
|
1394
|
+
function isPreviewMethod(x) {
|
|
1395
|
+
return x === "none" || x === "auto" || x === "latent2rgb" || x === "taesd";
|
|
1396
|
+
}
|
|
1397
|
+
/** the preview method a host was launched with, from its /system_stats payload. `'none'` when
|
|
1398
|
+
* the flag is absent (ComfyUI's default), null when the payload carries no argv to read (a cloud
|
|
1399
|
+
* host) or the flag holds a value this parser does not know */
|
|
1400
|
+
function previewMethodFromSystemStats(stats) {
|
|
1401
|
+
if (stats == null || typeof stats !== "object" || !("system" in stats)) return null;
|
|
1402
|
+
const system = stats.system;
|
|
1403
|
+
if (system == null || typeof system !== "object" || !("argv" in system)) return null;
|
|
1404
|
+
const argv = system.argv;
|
|
1405
|
+
if (!Array.isArray(argv)) return null;
|
|
1406
|
+
for (let i = 0; i < argv.length; i++) {
|
|
1407
|
+
const arg = argv[i];
|
|
1408
|
+
if (typeof arg !== "string") continue;
|
|
1409
|
+
const value = arg === "--preview-method" ? argv[i + 1] : arg.startsWith("--preview-method=") ? arg.slice(17) : void 0;
|
|
1410
|
+
if (value === void 0) continue;
|
|
1411
|
+
return isPreviewMethod(value) ? value : null;
|
|
1405
1412
|
}
|
|
1413
|
+
return "none";
|
|
1414
|
+
}
|
|
1415
|
+
/** the frame's event type, read in place: deciding whether anyone wants a frame costs no copy */
|
|
1416
|
+
function binaryFrameType(data) {
|
|
1417
|
+
if (data.byteLength < 4) return -1;
|
|
1418
|
+
return new DataView(data).getUint32(0);
|
|
1419
|
+
}
|
|
1420
|
+
function isPreviewFrameType(eventType) {
|
|
1421
|
+
return eventType === 1 || eventType === 4;
|
|
1422
|
+
}
|
|
1423
|
+
function parseBinaryWsFrame(data) {
|
|
1424
|
+
const eventType = binaryFrameType(data);
|
|
1425
|
+
if (isPreviewFrameType(eventType)) return parsePreviewFrame(data);
|
|
1406
1426
|
if (eventType === 3) {
|
|
1407
|
-
const nodeIdLen =
|
|
1427
|
+
const nodeIdLen = new DataView(data).getUint32(4);
|
|
1408
1428
|
const decoder = new TextDecoder();
|
|
1409
1429
|
return {
|
|
1410
1430
|
kind: "text",
|
|
@@ -1412,25 +1432,41 @@ function parseBinaryWsFrame(data) {
|
|
|
1412
1432
|
text: decoder.decode(data.slice(8 + nodeIdLen))
|
|
1413
1433
|
};
|
|
1414
1434
|
}
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1435
|
+
return {
|
|
1436
|
+
kind: "unknown",
|
|
1437
|
+
eventType
|
|
1438
|
+
};
|
|
1439
|
+
}
|
|
1440
|
+
/** a type 1 or type 4 frame; the caller checked the type with `isPreviewFrameType` */
|
|
1441
|
+
function parsePreviewFrame(data) {
|
|
1442
|
+
const view = new DataView(data);
|
|
1443
|
+
if (view.getUint32(0) === 1) {
|
|
1444
|
+
const imageType = view.getUint32(4);
|
|
1422
1445
|
return {
|
|
1423
1446
|
kind: "preview",
|
|
1424
|
-
bytes,
|
|
1425
|
-
mime:
|
|
1426
|
-
metadata
|
|
1447
|
+
bytes: new Uint8Array(data.slice(8)),
|
|
1448
|
+
mime: imageType === 2 ? "image/png" : "image/jpeg",
|
|
1449
|
+
metadata: null
|
|
1427
1450
|
};
|
|
1428
1451
|
}
|
|
1452
|
+
const metadataLen = view.getUint32(4);
|
|
1453
|
+
let metadata = null;
|
|
1454
|
+
try {
|
|
1455
|
+
metadata = JSON.parse(new TextDecoder().decode(data.slice(8, 8 + metadataLen)));
|
|
1456
|
+
} catch {}
|
|
1457
|
+
const bytes = new Uint8Array(data.slice(8 + metadataLen));
|
|
1429
1458
|
return {
|
|
1430
|
-
kind: "
|
|
1431
|
-
|
|
1459
|
+
kind: "preview",
|
|
1460
|
+
bytes,
|
|
1461
|
+
mime: bytes[0] === 137 && bytes[1] === 80 ? "image/png" : "image/jpeg",
|
|
1462
|
+
metadata
|
|
1432
1463
|
};
|
|
1433
1464
|
}
|
|
1465
|
+
/** the node a type 4 frame names (`node_id` in its metadata), null when absent or malformed */
|
|
1466
|
+
function previewMetadataNodeId(metadata) {
|
|
1467
|
+
if (metadata == null || typeof metadata !== "object" || !("node_id" in metadata)) return null;
|
|
1468
|
+
return typeof metadata.node_id === "string" && metadata.node_id !== "" ? metadata.node_id : null;
|
|
1469
|
+
}
|
|
1434
1470
|
//#endregion
|
|
1435
1471
|
//#region src/sdk-generator/litegraphToApiRequestPayload.ts
|
|
1436
1472
|
/** a canonical workflow the converter cannot turn into a prompt — the code NAMES the feature that failed */
|
|
@@ -2168,20 +2204,40 @@ const convertFlowToLiteGraphJSON = (graph) => {
|
|
|
2168
2204
|
const convertNodeToLiteGraphNode = (ctx, node) => {
|
|
2169
2205
|
const inputs = [];
|
|
2170
2206
|
const widgets_values = [];
|
|
2207
|
+
const pushLinked = (name, type, link, shape) => {
|
|
2208
|
+
const nodeUidNumber = bang(ctx.graph.nodes.find((n) => n.uid === link[0])?.uidNumber, `link target node "${link[0]}" not found in graph`);
|
|
2209
|
+
const linkId = ctx.allocateLink(nodeUidNumber, link[1], node.uidNumber, asLiteGraphSlotIndex(inputs.length), type);
|
|
2210
|
+
inputs.push(shape == null ? {
|
|
2211
|
+
name,
|
|
2212
|
+
type,
|
|
2213
|
+
link: linkId
|
|
2214
|
+
} : {
|
|
2215
|
+
name,
|
|
2216
|
+
type,
|
|
2217
|
+
shape,
|
|
2218
|
+
link: linkId
|
|
2219
|
+
});
|
|
2220
|
+
};
|
|
2171
2221
|
for (const ipt of node.$schema.inputs) {
|
|
2172
|
-
const raw = node.serializeValue(ipt.nameInComfy, node.json.inputs[ipt.nameInComfy]);
|
|
2173
2222
|
const kind = classifySchemaInput(ipt);
|
|
2174
|
-
if (
|
|
2175
|
-
const
|
|
2176
|
-
|
|
2177
|
-
name
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2223
|
+
if (kind.kind === "dynamic-container") {
|
|
2224
|
+
const type = containerInstanceSlotType(ipt.opts) ?? "*";
|
|
2225
|
+
for (const instance of kind.instanceNames) {
|
|
2226
|
+
const name = `${ipt.nameInComfy}.${instance}`;
|
|
2227
|
+
const value = node.json.inputs[name];
|
|
2228
|
+
if (value == null) continue;
|
|
2229
|
+
const raw = node.serializeValue(name, value);
|
|
2230
|
+
if (!_isLink(raw)) throw new Error(`🔴 [toWorkflowJson] ${node.$schema.nameInComfy}#${node.uid} "${name}" holds a literal; an autogrow instance is a link slot in the editor`);
|
|
2231
|
+
pushLinked(name, type, raw, 7);
|
|
2232
|
+
}
|
|
2233
|
+
continue;
|
|
2234
|
+
}
|
|
2235
|
+
const raw = node.serializeValue(ipt.nameInComfy, node.json.inputs[ipt.nameInComfy]);
|
|
2236
|
+
if (_isLink(raw)) pushLinked(ipt.nameInComfy, ipt.typeName, raw);
|
|
2237
|
+
else if (kind.kind === "widget") {
|
|
2182
2238
|
widgets_values.push(...kind.prefixValues, raw);
|
|
2183
2239
|
const phantoms = kind.consumes - 1 - kind.prefixValues.length;
|
|
2184
|
-
for (let i = 0; i < phantoms; i++) widgets_values.push(
|
|
2240
|
+
for (let i = 0; i < phantoms; i++) widgets_values.push(controlMode(ipt.opts));
|
|
2185
2241
|
} else inputs.push({
|
|
2186
2242
|
name: ipt.nameInComfy,
|
|
2187
2243
|
type: ipt.typeName,
|
|
@@ -2204,6 +2260,12 @@ const convertNodeToLiteGraphNode = (ctx, node) => {
|
|
|
2204
2260
|
widgets_values
|
|
2205
2261
|
};
|
|
2206
2262
|
};
|
|
2263
|
+
/** the editor's control widget is a combo (fixed, increment, decrement, randomize):
|
|
2264
|
+
* a config naming a mode keeps it, anything else is `fixed`, the seed the code pinned */
|
|
2265
|
+
const controlMode = (opts) => {
|
|
2266
|
+
const mode = typeof opts === "object" && opts != null ? Reflect.get(opts, "control_after_generate") : null;
|
|
2267
|
+
return typeof mode === "string" ? mode : "fixed";
|
|
2268
|
+
};
|
|
2207
2269
|
const _isLink = (v) => {
|
|
2208
2270
|
return Array.isArray(v) && v.length === 2 && typeof v[0] === "string" && typeof v[1] === "number";
|
|
2209
2271
|
};
|
|
@@ -2674,6 +2736,7 @@ var ComfyExecution = class {
|
|
|
2674
2736
|
this.ephemeral = false;
|
|
2675
2737
|
this.snapshot = null;
|
|
2676
2738
|
this.onProgress = null;
|
|
2739
|
+
this.onPreview = null;
|
|
2677
2740
|
this.logProgress = false;
|
|
2678
2741
|
this.startedAt = Date.now();
|
|
2679
2742
|
this._lastLoggedLine = "";
|
|
@@ -2687,6 +2750,7 @@ var ComfyExecution = class {
|
|
|
2687
2750
|
bytes: msg.bytes,
|
|
2688
2751
|
mime: msg.mime
|
|
2689
2752
|
});
|
|
2753
|
+
else this.onPreviewFrame(msg);
|
|
2690
2754
|
return;
|
|
2691
2755
|
}
|
|
2692
2756
|
if (msg.type === "execution_start") return;
|
|
@@ -2933,6 +2997,7 @@ var ComfyExecution = class {
|
|
|
2933
2997
|
this.scrubHistory = init.scrubHistory ?? false;
|
|
2934
2998
|
this.ephemeral = init.ephemeral ?? false;
|
|
2935
2999
|
this.onProgress = init.onProgress ?? null;
|
|
3000
|
+
this.onPreview = init.onPreview ?? null;
|
|
2936
3001
|
this.logProgress = init.logProgress ?? false;
|
|
2937
3002
|
this.host.executions.set(data.id, this);
|
|
2938
3003
|
this.onCreate();
|
|
@@ -3013,6 +3078,28 @@ var ComfyExecution = class {
|
|
|
3013
3078
|
if (uid == null) return false;
|
|
3014
3079
|
return (this.snapshot?.apiJson ?? this.workflow.apiJson)[uid]?.class_type === "SaveImageWebsocket";
|
|
3015
3080
|
}
|
|
3081
|
+
/** @internal a live preview frame of this run; never an output (the host routes ws saver frames
|
|
3082
|
+
* to onWsImageOutput before they get here) */
|
|
3083
|
+
onPreviewFrame(p) {
|
|
3084
|
+
const listener = this.onPreview;
|
|
3085
|
+
if (listener == null) return;
|
|
3086
|
+
const current = this.workflow.currentExecutingNode;
|
|
3087
|
+
const nodeId = previewMetadataNodeId(p.metadata) ?? current?.uid ?? null;
|
|
3088
|
+
const apiJson = this.snapshot?.apiJson ?? this.workflow.apiJson;
|
|
3089
|
+
const counter = current != null && current.uid === nodeId ? current.progress : null;
|
|
3090
|
+
listener({
|
|
3091
|
+
promptId: this.data.id,
|
|
3092
|
+
bytes: p.bytes,
|
|
3093
|
+
mime: p.mime,
|
|
3094
|
+
nodeId,
|
|
3095
|
+
nodeName: nodeId != null ? apiJson[nodeId]?.class_type ?? null : null,
|
|
3096
|
+
step: counter != null ? {
|
|
3097
|
+
value: counter.value,
|
|
3098
|
+
max: counter.max
|
|
3099
|
+
} : null,
|
|
3100
|
+
metadata: p.metadata
|
|
3101
|
+
});
|
|
3102
|
+
}
|
|
3016
3103
|
/** @internal a live-text frame for one node */
|
|
3017
3104
|
onProgressText(p) {
|
|
3018
3105
|
this.progressTexts.set(p.nodeId, p.text);
|
|
@@ -3321,6 +3408,7 @@ var ComfyWorkflow = class {
|
|
|
3321
3408
|
ephemeral: p.ephemeral ?? false,
|
|
3322
3409
|
scrubHistory: p.scrubHistory ?? p.ephemeral ?? false,
|
|
3323
3410
|
onProgress: p.onProgress,
|
|
3411
|
+
onPreview: p.onPreview,
|
|
3324
3412
|
logProgress: p.log ?? false
|
|
3325
3413
|
});
|
|
3326
3414
|
};
|
|
@@ -4131,6 +4219,11 @@ var ComfyHost = class {
|
|
|
4131
4219
|
this.clearHistory = () => {
|
|
4132
4220
|
return this.postJSON_("/history", { clear: true });
|
|
4133
4221
|
};
|
|
4222
|
+
this.fetchPreviewMethod = async () => {
|
|
4223
|
+
const res = await this.fetch("/system_stats", {});
|
|
4224
|
+
if (!res.ok) throw new Error(`GET /system_stats failed: ${res.status}`);
|
|
4225
|
+
return previewMethodFromSystemStats(await res.json());
|
|
4226
|
+
};
|
|
4134
4227
|
this.fetchRawLogs = async () => {
|
|
4135
4228
|
const res = await this.fetch("/internal/logs/raw", {}, { apiPrefix: false });
|
|
4136
4229
|
if (!res.ok) throw new Error(`GET /internal/logs/raw failed: ${res.status}`);
|
|
@@ -4207,7 +4300,8 @@ var ComfyHost = class {
|
|
|
4207
4300
|
this.executions = /* @__PURE__ */ new Map();
|
|
4208
4301
|
this._pendingMsgs = /* @__PURE__ */ new Map();
|
|
4209
4302
|
this.activePromptID = null;
|
|
4210
|
-
this.
|
|
4303
|
+
this._latentFrame = null;
|
|
4304
|
+
this._latentPreview = null;
|
|
4211
4305
|
this.onLatentPreview = null;
|
|
4212
4306
|
this.onProgressText = null;
|
|
4213
4307
|
this.onStatus = null;
|
|
@@ -4384,42 +4478,60 @@ var ComfyHost = class {
|
|
|
4384
4478
|
}
|
|
4385
4479
|
prompt.onPromptRelatedMessage(msg);
|
|
4386
4480
|
}
|
|
4481
|
+
/** the latent image beeing generated, in case you want to display it. Built on read: a
|
|
4482
|
+
* session that never reads it never decodes a frame nor holds an object url */
|
|
4483
|
+
get latentPreview() {
|
|
4484
|
+
if (this._latentPreview != null || this._latentFrame == null) return this._latentPreview;
|
|
4485
|
+
const frame = parsePreviewFrame(this._latentFrame.data);
|
|
4486
|
+
const blob = new Blob([frame.bytes], { type: frame.mime });
|
|
4487
|
+
this._latentPreview = {
|
|
4488
|
+
blob,
|
|
4489
|
+
url: URL.createObjectURL(blob),
|
|
4490
|
+
receivedAt: this._latentFrame.receivedAt,
|
|
4491
|
+
promptID: this._latentFrame.promptID
|
|
4492
|
+
};
|
|
4493
|
+
return this._latentPreview;
|
|
4494
|
+
}
|
|
4495
|
+
/** a type 1 or 4 frame. Parsed only when someone wants it, in this order (architecture.md,
|
|
4496
|
+
* Live previews): the ws saver's output, the pre-registration buffer, the run's onPreview,
|
|
4497
|
+
* the host hook. Nobody listening = the frame is kept by reference and never copied */
|
|
4498
|
+
onPreviewFrame(data) {
|
|
4499
|
+
let parsed = null;
|
|
4500
|
+
const frame = () => parsed ??= parsePreviewFrame(data);
|
|
4501
|
+
const promptID = this.activePromptID;
|
|
4502
|
+
const activeExec = promptID != null ? this.executions.get(promptID) : null;
|
|
4503
|
+
if (activeExec?.wsOutputNodeExecuting) return activeExec.onWsImageOutput({
|
|
4504
|
+
bytes: frame().bytes,
|
|
4505
|
+
mime: frame().mime
|
|
4506
|
+
});
|
|
4507
|
+
const pending = promptID != null ? this._pendingMsgs.get(promptID) : void 0;
|
|
4508
|
+
if (pending != null) pending.push({
|
|
4509
|
+
type: "binary_preview_frame",
|
|
4510
|
+
bytes: frame().bytes,
|
|
4511
|
+
mime: frame().mime,
|
|
4512
|
+
metadata: frame().metadata
|
|
4513
|
+
});
|
|
4514
|
+
if (this._latentPreview != null) URL.revokeObjectURL(this._latentPreview.url);
|
|
4515
|
+
this._latentPreview = null;
|
|
4516
|
+
this._latentFrame = {
|
|
4517
|
+
data,
|
|
4518
|
+
promptID,
|
|
4519
|
+
receivedAt: Date.now()
|
|
4520
|
+
};
|
|
4521
|
+
if (activeExec?.onPreview != null) activeExec.onPreviewFrame(frame());
|
|
4522
|
+
if (this.onLatentPreview != null) this.onLatentPreview({
|
|
4523
|
+
bytes: frame().bytes,
|
|
4524
|
+
mime: frame().mime,
|
|
4525
|
+
promptID
|
|
4526
|
+
});
|
|
4527
|
+
}
|
|
4387
4528
|
onMessage(e) {
|
|
4388
4529
|
this.lastWsMessageAt = Date.now();
|
|
4389
4530
|
if (this.data.onWsMessageAny) this.data.onWsMessageAny(e);
|
|
4390
4531
|
if (e.data instanceof ArrayBuffer) {
|
|
4532
|
+
if (isPreviewFrameType(binaryFrameType(e.data))) return this.onPreviewFrame(e.data);
|
|
4391
4533
|
const frame = parseBinaryWsFrame(e.data);
|
|
4392
|
-
if (frame.kind === "
|
|
4393
|
-
const activeExec = this.activePromptID != null ? this.executions.get(this.activePromptID) : null;
|
|
4394
|
-
if (activeExec?.wsOutputNodeExecuting) {
|
|
4395
|
-
activeExec.onWsImageOutput({
|
|
4396
|
-
bytes: frame.bytes,
|
|
4397
|
-
mime: frame.mime
|
|
4398
|
-
});
|
|
4399
|
-
return;
|
|
4400
|
-
}
|
|
4401
|
-
if (this.activePromptID != null) {
|
|
4402
|
-
const pending = this._pendingMsgs.get(this.activePromptID);
|
|
4403
|
-
if (pending != null) pending.push({
|
|
4404
|
-
type: "binary_preview_frame",
|
|
4405
|
-
bytes: frame.bytes,
|
|
4406
|
-
mime: frame.mime
|
|
4407
|
-
});
|
|
4408
|
-
}
|
|
4409
|
-
if (this.latentPreview != null) URL.revokeObjectURL(this.latentPreview.url);
|
|
4410
|
-
const imageBlob = new Blob([frame.bytes], { type: frame.mime });
|
|
4411
|
-
this.latentPreview = {
|
|
4412
|
-
blob: imageBlob,
|
|
4413
|
-
url: URL.createObjectURL(imageBlob),
|
|
4414
|
-
receivedAt: Date.now(),
|
|
4415
|
-
promptID: this.activePromptID
|
|
4416
|
-
};
|
|
4417
|
-
this.onLatentPreview?.({
|
|
4418
|
-
bytes: frame.bytes,
|
|
4419
|
-
mime: frame.mime,
|
|
4420
|
-
promptID: this.activePromptID
|
|
4421
|
-
});
|
|
4422
|
-
} else if (frame.kind === "unknown" && !this._unknownBinaryFrameTypes.has(frame.eventType)) {
|
|
4534
|
+
if (frame.kind === "unknown" && !this._unknownBinaryFrameTypes.has(frame.eventType)) {
|
|
4423
4535
|
this._unknownBinaryFrameTypes.add(frame.eventType);
|
|
4424
4536
|
console.error(`🔴 unknown binary ws frame type ${frame.eventType} from host ${this.data.id} — ignored`);
|
|
4425
4537
|
}
|
|
@@ -5138,4 +5250,4 @@ var ComfyTS = class ComfyTS {
|
|
|
5138
5250
|
//#endregion
|
|
5139
5251
|
export { ComfySchema as a, importSharp as i, settingsPathFor as n, readableStringify as r, ComfyTS as t };
|
|
5140
5252
|
|
|
5141
|
-
//# sourceMappingURL=state-
|
|
5253
|
+
//# sourceMappingURL=state-zTow5ucI.js.map
|