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
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.17.1";
|
|
138
138
|
//#endregion
|
|
139
139
|
//#region src/litegraph/LiteGraphLinkID.ts
|
|
140
140
|
const asLiteGraphLinkID = (id) => id;
|
|
@@ -684,21 +684,41 @@ const normalizeGroup = (g) => {
|
|
|
684
684
|
};
|
|
685
685
|
};
|
|
686
686
|
//#endregion
|
|
687
|
-
//#region src/
|
|
688
|
-
function
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
687
|
+
//#region src/host/previewMethod.ts
|
|
688
|
+
function isPreviewMethod(x) {
|
|
689
|
+
return x === "none" || x === "auto" || x === "latent2rgb" || x === "taesd";
|
|
690
|
+
}
|
|
691
|
+
/** the preview method a host was launched with, from its /system_stats payload. `'none'` when
|
|
692
|
+
* the flag is absent (ComfyUI's default), null when the payload carries no argv to read (a cloud
|
|
693
|
+
* host) or the flag holds a value this parser does not know */
|
|
694
|
+
function previewMethodFromSystemStats(stats) {
|
|
695
|
+
if (stats == null || typeof stats !== "object" || !("system" in stats)) return null;
|
|
696
|
+
const system = stats.system;
|
|
697
|
+
if (system == null || typeof system !== "object" || !("argv" in system)) return null;
|
|
698
|
+
const argv = system.argv;
|
|
699
|
+
if (!Array.isArray(argv)) return null;
|
|
700
|
+
for (let i = 0; i < argv.length; i++) {
|
|
701
|
+
const arg = argv[i];
|
|
702
|
+
if (typeof arg !== "string") continue;
|
|
703
|
+
const value = arg === "--preview-method" ? argv[i + 1] : arg.startsWith("--preview-method=") ? arg.slice(17) : void 0;
|
|
704
|
+
if (value === void 0) continue;
|
|
705
|
+
return isPreviewMethod(value) ? value : null;
|
|
699
706
|
}
|
|
707
|
+
return "none";
|
|
708
|
+
}
|
|
709
|
+
/** the frame's event type, read in place: deciding whether anyone wants a frame costs no copy */
|
|
710
|
+
function binaryFrameType(data) {
|
|
711
|
+
if (data.byteLength < 4) return -1;
|
|
712
|
+
return new DataView(data).getUint32(0);
|
|
713
|
+
}
|
|
714
|
+
function isPreviewFrameType(eventType) {
|
|
715
|
+
return eventType === 1 || eventType === 4;
|
|
716
|
+
}
|
|
717
|
+
function parseBinaryWsFrame(data) {
|
|
718
|
+
const eventType = binaryFrameType(data);
|
|
719
|
+
if (isPreviewFrameType(eventType)) return parsePreviewFrame(data);
|
|
700
720
|
if (eventType === 3) {
|
|
701
|
-
const nodeIdLen =
|
|
721
|
+
const nodeIdLen = new DataView(data).getUint32(4);
|
|
702
722
|
const decoder = new TextDecoder();
|
|
703
723
|
return {
|
|
704
724
|
kind: "text",
|
|
@@ -706,25 +726,41 @@ function parseBinaryWsFrame(data) {
|
|
|
706
726
|
text: decoder.decode(data.slice(8 + nodeIdLen))
|
|
707
727
|
};
|
|
708
728
|
}
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
729
|
+
return {
|
|
730
|
+
kind: "unknown",
|
|
731
|
+
eventType
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
/** a type 1 or type 4 frame; the caller checked the type with `isPreviewFrameType` */
|
|
735
|
+
function parsePreviewFrame(data) {
|
|
736
|
+
const view = new DataView(data);
|
|
737
|
+
if (view.getUint32(0) === 1) {
|
|
738
|
+
const imageType = view.getUint32(4);
|
|
716
739
|
return {
|
|
717
740
|
kind: "preview",
|
|
718
|
-
bytes,
|
|
719
|
-
mime:
|
|
720
|
-
metadata
|
|
741
|
+
bytes: new Uint8Array(data.slice(8)),
|
|
742
|
+
mime: imageType === 2 ? "image/png" : "image/jpeg",
|
|
743
|
+
metadata: null
|
|
721
744
|
};
|
|
722
745
|
}
|
|
746
|
+
const metadataLen = view.getUint32(4);
|
|
747
|
+
let metadata = null;
|
|
748
|
+
try {
|
|
749
|
+
metadata = JSON.parse(new TextDecoder().decode(data.slice(8, 8 + metadataLen)));
|
|
750
|
+
} catch {}
|
|
751
|
+
const bytes = new Uint8Array(data.slice(8 + metadataLen));
|
|
723
752
|
return {
|
|
724
|
-
kind: "
|
|
725
|
-
|
|
753
|
+
kind: "preview",
|
|
754
|
+
bytes,
|
|
755
|
+
mime: bytes[0] === 137 && bytes[1] === 80 ? "image/png" : "image/jpeg",
|
|
756
|
+
metadata
|
|
726
757
|
};
|
|
727
758
|
}
|
|
759
|
+
/** the node a type 4 frame names (`node_id` in its metadata), null when absent or malformed */
|
|
760
|
+
function previewMetadataNodeId(metadata) {
|
|
761
|
+
if (metadata == null || typeof metadata !== "object" || !("node_id" in metadata)) return null;
|
|
762
|
+
return typeof metadata.node_id === "string" && metadata.node_id !== "" ? metadata.node_id : null;
|
|
763
|
+
}
|
|
728
764
|
//#endregion
|
|
729
765
|
//#region src/sdk-generator/Primitives.ts
|
|
730
766
|
const ComfyPrimitiveMapping = {
|
|
@@ -1701,20 +1737,40 @@ const convertFlowToLiteGraphJSON = (graph) => {
|
|
|
1701
1737
|
const convertNodeToLiteGraphNode = (ctx, node) => {
|
|
1702
1738
|
const inputs = [];
|
|
1703
1739
|
const widgets_values = [];
|
|
1740
|
+
const pushLinked = (name, type, link, shape) => {
|
|
1741
|
+
const nodeUidNumber = bang(ctx.graph.nodes.find((n) => n.uid === link[0])?.uidNumber, `link target node "${link[0]}" not found in graph`);
|
|
1742
|
+
const linkId = ctx.allocateLink(nodeUidNumber, link[1], node.uidNumber, asLiteGraphSlotIndex(inputs.length), type);
|
|
1743
|
+
inputs.push(shape == null ? {
|
|
1744
|
+
name,
|
|
1745
|
+
type,
|
|
1746
|
+
link: linkId
|
|
1747
|
+
} : {
|
|
1748
|
+
name,
|
|
1749
|
+
type,
|
|
1750
|
+
shape,
|
|
1751
|
+
link: linkId
|
|
1752
|
+
});
|
|
1753
|
+
};
|
|
1704
1754
|
for (const ipt of node.$schema.inputs) {
|
|
1705
|
-
const raw = node.serializeValue(ipt.nameInComfy, node.json.inputs[ipt.nameInComfy]);
|
|
1706
1755
|
const kind = classifySchemaInput(ipt);
|
|
1707
|
-
if (
|
|
1708
|
-
const
|
|
1709
|
-
|
|
1710
|
-
name
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1756
|
+
if (kind.kind === "dynamic-container") {
|
|
1757
|
+
const type = containerInstanceSlotType(ipt.opts) ?? "*";
|
|
1758
|
+
for (const instance of kind.instanceNames) {
|
|
1759
|
+
const name = `${ipt.nameInComfy}.${instance}`;
|
|
1760
|
+
const value = node.json.inputs[name];
|
|
1761
|
+
if (value == null) continue;
|
|
1762
|
+
const raw = node.serializeValue(name, value);
|
|
1763
|
+
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`);
|
|
1764
|
+
pushLinked(name, type, raw, 7);
|
|
1765
|
+
}
|
|
1766
|
+
continue;
|
|
1767
|
+
}
|
|
1768
|
+
const raw = node.serializeValue(ipt.nameInComfy, node.json.inputs[ipt.nameInComfy]);
|
|
1769
|
+
if (_isLink(raw)) pushLinked(ipt.nameInComfy, ipt.typeName, raw);
|
|
1770
|
+
else if (kind.kind === "widget") {
|
|
1715
1771
|
widgets_values.push(...kind.prefixValues, raw);
|
|
1716
1772
|
const phantoms = kind.consumes - 1 - kind.prefixValues.length;
|
|
1717
|
-
for (let i = 0; i < phantoms; i++) widgets_values.push(
|
|
1773
|
+
for (let i = 0; i < phantoms; i++) widgets_values.push(controlMode(ipt.opts));
|
|
1718
1774
|
} else inputs.push({
|
|
1719
1775
|
name: ipt.nameInComfy,
|
|
1720
1776
|
type: ipt.typeName,
|
|
@@ -1737,6 +1793,12 @@ const convertNodeToLiteGraphNode = (ctx, node) => {
|
|
|
1737
1793
|
widgets_values
|
|
1738
1794
|
};
|
|
1739
1795
|
};
|
|
1796
|
+
/** the editor's control widget is a combo (fixed, increment, decrement, randomize):
|
|
1797
|
+
* a config naming a mode keeps it, anything else is `fixed`, the seed the code pinned */
|
|
1798
|
+
const controlMode = (opts) => {
|
|
1799
|
+
const mode = typeof opts === "object" && opts != null ? Reflect.get(opts, "control_after_generate") : null;
|
|
1800
|
+
return typeof mode === "string" ? mode : "fixed";
|
|
1801
|
+
};
|
|
1740
1802
|
const _isLink = (v) => {
|
|
1741
1803
|
return Array.isArray(v) && v.length === 2 && typeof v[0] === "string" && typeof v[1] === "number";
|
|
1742
1804
|
};
|
|
@@ -2377,6 +2439,7 @@ var ComfyExecution = class {
|
|
|
2377
2439
|
this.ephemeral = false;
|
|
2378
2440
|
this.snapshot = null;
|
|
2379
2441
|
this.onProgress = null;
|
|
2442
|
+
this.onPreview = null;
|
|
2380
2443
|
this.logProgress = false;
|
|
2381
2444
|
this.startedAt = Date.now();
|
|
2382
2445
|
this._lastLoggedLine = "";
|
|
@@ -2390,6 +2453,7 @@ var ComfyExecution = class {
|
|
|
2390
2453
|
bytes: msg.bytes,
|
|
2391
2454
|
mime: msg.mime
|
|
2392
2455
|
});
|
|
2456
|
+
else this.onPreviewFrame(msg);
|
|
2393
2457
|
return;
|
|
2394
2458
|
}
|
|
2395
2459
|
if (msg.type === "execution_start") return;
|
|
@@ -2636,6 +2700,7 @@ var ComfyExecution = class {
|
|
|
2636
2700
|
this.scrubHistory = init.scrubHistory ?? false;
|
|
2637
2701
|
this.ephemeral = init.ephemeral ?? false;
|
|
2638
2702
|
this.onProgress = init.onProgress ?? null;
|
|
2703
|
+
this.onPreview = init.onPreview ?? null;
|
|
2639
2704
|
this.logProgress = init.logProgress ?? false;
|
|
2640
2705
|
this.host.executions.set(data.id, this);
|
|
2641
2706
|
this.onCreate();
|
|
@@ -2716,6 +2781,28 @@ var ComfyExecution = class {
|
|
|
2716
2781
|
if (uid == null) return false;
|
|
2717
2782
|
return (this.snapshot?.apiJson ?? this.workflow.apiJson)[uid]?.class_type === "SaveImageWebsocket";
|
|
2718
2783
|
}
|
|
2784
|
+
/** @internal a live preview frame of this run; never an output (the host routes ws saver frames
|
|
2785
|
+
* to onWsImageOutput before they get here) */
|
|
2786
|
+
onPreviewFrame(p) {
|
|
2787
|
+
const listener = this.onPreview;
|
|
2788
|
+
if (listener == null) return;
|
|
2789
|
+
const current = this.workflow.currentExecutingNode;
|
|
2790
|
+
const nodeId = previewMetadataNodeId(p.metadata) ?? current?.uid ?? null;
|
|
2791
|
+
const apiJson = this.snapshot?.apiJson ?? this.workflow.apiJson;
|
|
2792
|
+
const counter = current != null && current.uid === nodeId ? current.progress : null;
|
|
2793
|
+
listener({
|
|
2794
|
+
promptId: this.data.id,
|
|
2795
|
+
bytes: p.bytes,
|
|
2796
|
+
mime: p.mime,
|
|
2797
|
+
nodeId,
|
|
2798
|
+
nodeName: nodeId != null ? apiJson[nodeId]?.class_type ?? null : null,
|
|
2799
|
+
step: counter != null ? {
|
|
2800
|
+
value: counter.value,
|
|
2801
|
+
max: counter.max
|
|
2802
|
+
} : null,
|
|
2803
|
+
metadata: p.metadata
|
|
2804
|
+
});
|
|
2805
|
+
}
|
|
2719
2806
|
/** @internal a live-text frame for one node */
|
|
2720
2807
|
onProgressText(p) {
|
|
2721
2808
|
this.progressTexts.set(p.nodeId, p.text);
|
|
@@ -3055,6 +3142,7 @@ var ComfyWorkflow = class {
|
|
|
3055
3142
|
ephemeral: p.ephemeral ?? false,
|
|
3056
3143
|
scrubHistory: p.scrubHistory ?? p.ephemeral ?? false,
|
|
3057
3144
|
onProgress: p.onProgress,
|
|
3145
|
+
onPreview: p.onPreview,
|
|
3058
3146
|
logProgress: p.log ?? false
|
|
3059
3147
|
});
|
|
3060
3148
|
};
|
|
@@ -5726,7 +5814,8 @@ var DefinedWorkflow = class {
|
|
|
5726
5814
|
scrubHistory: settings.scrubHistory,
|
|
5727
5815
|
idMode: settings.idMode,
|
|
5728
5816
|
log: settings.log,
|
|
5729
|
-
onProgress: settings.onProgress
|
|
5817
|
+
onProgress: settings.onProgress,
|
|
5818
|
+
onPreview: settings.onPreview
|
|
5730
5819
|
});
|
|
5731
5820
|
this.lastExecution = execution;
|
|
5732
5821
|
return execution;
|
|
@@ -6031,6 +6120,11 @@ var ComfyHost = class {
|
|
|
6031
6120
|
this.clearHistory = () => {
|
|
6032
6121
|
return this.postJSON_("/history", { clear: true });
|
|
6033
6122
|
};
|
|
6123
|
+
this.fetchPreviewMethod = async () => {
|
|
6124
|
+
const res = await this.fetch("/system_stats", {});
|
|
6125
|
+
if (!res.ok) throw new Error(`GET /system_stats failed: ${res.status}`);
|
|
6126
|
+
return previewMethodFromSystemStats(await res.json());
|
|
6127
|
+
};
|
|
6034
6128
|
this.fetchRawLogs = async () => {
|
|
6035
6129
|
const res = await this.fetch("/internal/logs/raw", {}, { apiPrefix: false });
|
|
6036
6130
|
if (!res.ok) throw new Error(`GET /internal/logs/raw failed: ${res.status}`);
|
|
@@ -6107,7 +6201,8 @@ var ComfyHost = class {
|
|
|
6107
6201
|
this.executions = /* @__PURE__ */ new Map();
|
|
6108
6202
|
this._pendingMsgs = /* @__PURE__ */ new Map();
|
|
6109
6203
|
this.activePromptID = null;
|
|
6110
|
-
this.
|
|
6204
|
+
this._latentFrame = null;
|
|
6205
|
+
this._latentPreview = null;
|
|
6111
6206
|
this.onLatentPreview = null;
|
|
6112
6207
|
this.onProgressText = null;
|
|
6113
6208
|
this.onStatus = null;
|
|
@@ -6284,42 +6379,60 @@ var ComfyHost = class {
|
|
|
6284
6379
|
}
|
|
6285
6380
|
prompt.onPromptRelatedMessage(msg);
|
|
6286
6381
|
}
|
|
6382
|
+
/** the latent image beeing generated, in case you want to display it. Built on read: a
|
|
6383
|
+
* session that never reads it never decodes a frame nor holds an object url */
|
|
6384
|
+
get latentPreview() {
|
|
6385
|
+
if (this._latentPreview != null || this._latentFrame == null) return this._latentPreview;
|
|
6386
|
+
const frame = parsePreviewFrame(this._latentFrame.data);
|
|
6387
|
+
const blob = new Blob([frame.bytes], { type: frame.mime });
|
|
6388
|
+
this._latentPreview = {
|
|
6389
|
+
blob,
|
|
6390
|
+
url: URL.createObjectURL(blob),
|
|
6391
|
+
receivedAt: this._latentFrame.receivedAt,
|
|
6392
|
+
promptID: this._latentFrame.promptID
|
|
6393
|
+
};
|
|
6394
|
+
return this._latentPreview;
|
|
6395
|
+
}
|
|
6396
|
+
/** a type 1 or 4 frame. Parsed only when someone wants it, in this order (architecture.md,
|
|
6397
|
+
* Live previews): the ws saver's output, the pre-registration buffer, the run's onPreview,
|
|
6398
|
+
* the host hook. Nobody listening = the frame is kept by reference and never copied */
|
|
6399
|
+
onPreviewFrame(data) {
|
|
6400
|
+
let parsed = null;
|
|
6401
|
+
const frame = () => parsed ??= parsePreviewFrame(data);
|
|
6402
|
+
const promptID = this.activePromptID;
|
|
6403
|
+
const activeExec = promptID != null ? this.executions.get(promptID) : null;
|
|
6404
|
+
if (activeExec?.wsOutputNodeExecuting) return activeExec.onWsImageOutput({
|
|
6405
|
+
bytes: frame().bytes,
|
|
6406
|
+
mime: frame().mime
|
|
6407
|
+
});
|
|
6408
|
+
const pending = promptID != null ? this._pendingMsgs.get(promptID) : void 0;
|
|
6409
|
+
if (pending != null) pending.push({
|
|
6410
|
+
type: "binary_preview_frame",
|
|
6411
|
+
bytes: frame().bytes,
|
|
6412
|
+
mime: frame().mime,
|
|
6413
|
+
metadata: frame().metadata
|
|
6414
|
+
});
|
|
6415
|
+
if (this._latentPreview != null) URL.revokeObjectURL(this._latentPreview.url);
|
|
6416
|
+
this._latentPreview = null;
|
|
6417
|
+
this._latentFrame = {
|
|
6418
|
+
data,
|
|
6419
|
+
promptID,
|
|
6420
|
+
receivedAt: Date.now()
|
|
6421
|
+
};
|
|
6422
|
+
if (activeExec?.onPreview != null) activeExec.onPreviewFrame(frame());
|
|
6423
|
+
if (this.onLatentPreview != null) this.onLatentPreview({
|
|
6424
|
+
bytes: frame().bytes,
|
|
6425
|
+
mime: frame().mime,
|
|
6426
|
+
promptID
|
|
6427
|
+
});
|
|
6428
|
+
}
|
|
6287
6429
|
onMessage(e) {
|
|
6288
6430
|
this.lastWsMessageAt = Date.now();
|
|
6289
6431
|
if (this.data.onWsMessageAny) this.data.onWsMessageAny(e);
|
|
6290
6432
|
if (e.data instanceof ArrayBuffer) {
|
|
6433
|
+
if (isPreviewFrameType(binaryFrameType(e.data))) return this.onPreviewFrame(e.data);
|
|
6291
6434
|
const frame = parseBinaryWsFrame(e.data);
|
|
6292
|
-
if (frame.kind === "
|
|
6293
|
-
const activeExec = this.activePromptID != null ? this.executions.get(this.activePromptID) : null;
|
|
6294
|
-
if (activeExec?.wsOutputNodeExecuting) {
|
|
6295
|
-
activeExec.onWsImageOutput({
|
|
6296
|
-
bytes: frame.bytes,
|
|
6297
|
-
mime: frame.mime
|
|
6298
|
-
});
|
|
6299
|
-
return;
|
|
6300
|
-
}
|
|
6301
|
-
if (this.activePromptID != null) {
|
|
6302
|
-
const pending = this._pendingMsgs.get(this.activePromptID);
|
|
6303
|
-
if (pending != null) pending.push({
|
|
6304
|
-
type: "binary_preview_frame",
|
|
6305
|
-
bytes: frame.bytes,
|
|
6306
|
-
mime: frame.mime
|
|
6307
|
-
});
|
|
6308
|
-
}
|
|
6309
|
-
if (this.latentPreview != null) URL.revokeObjectURL(this.latentPreview.url);
|
|
6310
|
-
const imageBlob = new Blob([frame.bytes], { type: frame.mime });
|
|
6311
|
-
this.latentPreview = {
|
|
6312
|
-
blob: imageBlob,
|
|
6313
|
-
url: URL.createObjectURL(imageBlob),
|
|
6314
|
-
receivedAt: Date.now(),
|
|
6315
|
-
promptID: this.activePromptID
|
|
6316
|
-
};
|
|
6317
|
-
this.onLatentPreview?.({
|
|
6318
|
-
bytes: frame.bytes,
|
|
6319
|
-
mime: frame.mime,
|
|
6320
|
-
promptID: this.activePromptID
|
|
6321
|
-
});
|
|
6322
|
-
} else if (frame.kind === "unknown" && !this._unknownBinaryFrameTypes.has(frame.eventType)) {
|
|
6435
|
+
if (frame.kind === "unknown" && !this._unknownBinaryFrameTypes.has(frame.eventType)) {
|
|
6323
6436
|
this._unknownBinaryFrameTypes.add(frame.eventType);
|
|
6324
6437
|
console.error(`🔴 unknown binary ws frame type ${frame.eventType} from host ${this.data.id} — ignored`);
|
|
6325
6438
|
}
|