comfy-ts 1.4.0 → 2.1.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 +80 -6
- package/dist/{DefinedWorkflow-C_QAxKr3.js → DefinedWorkflow-CqNE_kgR.js} +4 -2
- package/dist/{DefinedWorkflow-C_QAxKr3.js.map → DefinedWorkflow-CqNE_kgR.js.map} +1 -1
- package/dist/{DraftsSt-DcOTn0QR.js → DraftsSt-C-gBk9v7.js} +3 -4
- package/dist/DraftsSt-C-gBk9v7.js.map +1 -0
- package/dist/cli.js +3 -3
- package/dist/index.cjs +212 -66
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +72 -77
- package/dist/index.d.ts +72 -77
- package/dist/index.js +212 -66
- package/dist/index.js.map +1 -1
- package/dist/{run-serve-CN0DhrsA.js → run-serve-CnlN_RFH.js} +9 -7
- package/dist/run-serve-CnlN_RFH.js.map +1 -0
- package/dist/{run-tui-bN2hSD5i.js → run-tui-DXI_Jufu.js} +258 -56
- package/dist/run-tui-DXI_Jufu.js.map +1 -0
- package/dist/{state-COlKYipO.js → state-DC5BcG6d.js} +211 -67
- package/dist/state-DC5BcG6d.js.map +1 -0
- package/dist/web.d.ts +72 -77
- package/dist/web.js +212 -66
- package/dist/web.js.map +1 -1
- package/examples/comfy-cloud/ace-step-t2a.cflow.ts +1 -0
- package/examples/comfy-cloud/anima-t2i.cflow.ts +2 -3
- package/examples/comfy-cloud/boogu-i2i.cflow.ts +2 -5
- package/examples/comfy-cloud/capybara-i2i.cflow.ts +2 -2
- package/examples/comfy-cloud/capybara-i2v.cflow.ts +1 -0
- package/examples/comfy-cloud/capybara-t2i.cflow.ts +2 -2
- package/examples/comfy-cloud/chatterbox-t2a.cflow.ts +1 -0
- package/examples/comfy-cloud/chroma-t2i.cflow.ts +2 -5
- package/examples/comfy-cloud/ernie-t2i.cflow.ts +2 -3
- package/examples/comfy-cloud/firered-i2i.cflow.ts +2 -2
- package/examples/comfy-cloud/flux1-i2i.cflow.ts +2 -2
- package/examples/comfy-cloud/flux1-t2i.cflow.ts +2 -2
- package/examples/comfy-cloud/flux2-i2i.cflow.ts +2 -5
- package/examples/comfy-cloud/flux2-t2i.cflow.ts +2 -5
- package/examples/comfy-cloud/hidream-i2i.cflow.ts +2 -5
- package/examples/comfy-cloud/hidream-t2i.cflow.ts +2 -2
- package/examples/comfy-cloud/hunyuan-video-i2v.cflow.ts +1 -0
- package/examples/comfy-cloud/hunyuan-video-t2v.cflow.ts +1 -0
- package/examples/comfy-cloud/ideogram4-t2i.cflow.ts +2 -3
- package/examples/comfy-cloud/kandinsky5-i2v.cflow.ts +1 -0
- package/examples/comfy-cloud/kandinsky5-t2i.cflow.ts +2 -2
- package/examples/comfy-cloud/kandinsky5-t2v.cflow.ts +1 -0
- package/examples/comfy-cloud/krea2-t2i.cflow.ts +2 -3
- package/examples/comfy-cloud/lens-t2i.cflow.ts +2 -3
- package/examples/comfy-cloud/longcat-i2i.cflow.ts +2 -2
- package/examples/comfy-cloud/longcat-t2i.cflow.ts +2 -5
- package/examples/comfy-cloud/ltxv-i2v.cflow.ts +1 -0
- package/examples/comfy-cloud/ltxv-t2v.cflow.ts +1 -0
- package/examples/comfy-cloud/newbie-t2i.cflow.ts +2 -5
- package/examples/comfy-cloud/omnigen2-i2i.cflow.ts +2 -5
- package/examples/comfy-cloud/omnigen2-t2i.cflow.ts +2 -5
- package/examples/comfy-cloud/ovis-t2i.cflow.ts +2 -5
- package/examples/comfy-cloud/pixeldit-t2i.cflow.ts +2 -5
- package/examples/comfy-cloud/qwen-image-i2i.cflow.ts +2 -2
- package/examples/comfy-cloud/qwen-image-t2i.cflow.ts +2 -2
- package/examples/comfy-cloud/sd35-t2i.cflow.ts +2 -2
- package/examples/comfy-cloud/sdk.d.ts +13251 -11458
- package/examples/comfy-cloud/sdxl-t2i.cflow.ts +2 -2
- package/examples/comfy-cloud/stable-audio-t2a.cflow.ts +1 -0
- package/examples/comfy-cloud/svd-i2v.cflow.ts +1 -0
- package/examples/comfy-cloud/wan21-i2v.cflow.ts +1 -0
- package/examples/comfy-cloud/wan21-t2v.cflow.ts +1 -0
- package/examples/comfy-cloud/wan22-5b-t2v.cflow.ts +1 -0
- package/examples/comfy-cloud/wan22-i2v.cflow.ts +1 -0
- package/examples/comfy-cloud/wan22-t2v.cflow.ts +1 -0
- package/examples/comfy-cloud/z-image-t2i.cflow.ts +2 -5
- package/examples/rvion/01-txt2img.cflow.ts +5 -3
- package/examples/rvion/02-img2img-upload.cflow.ts +5 -4
- package/examples/rvion/04-krea2-turbo-t2i.cflow.ts +6 -7
- package/examples/rvion/05-comfy-cloud.cflow.ts +4 -2
- package/examples/rvion/06-qwen-image-edit.cflow.ts +2 -3
- package/examples/web/example.ts +8 -1
- package/package.json +1 -1
- package/src/cli/serve/ServeApp.ts +9 -6
- package/src/cli/tui/components/TuiApp.tsx +4 -5
- package/src/cli/tui/components/VarsPanel.tsx +40 -2
- package/src/cli/tui/imageClipboard.ts +40 -0
- package/src/cli/tui/state/DraftsSt.ts +1 -2
- package/src/cli/tui/state/ExecSt.ts +105 -40
- package/src/cli/tui/state/PreviewSt.ts +12 -11
- package/src/cli/tui/state/SettingsSt.ts +13 -0
- package/src/cli/tui/state/TuiSt.ts +54 -5
- package/src/host/ComfyHost.ts +33 -1
- package/src/runner/ComfyExecution.ts +162 -74
- package/src/runner/ComfyWorkflow.ts +25 -3
- package/src/runner/ComfyWsApi.ts +6 -0
- package/src/runner/MediaImage.ts +58 -11
- package/src/runner/ephemeral.ts +21 -0
- package/src/runner/outputPath.ts +2 -2
- package/src/sdk-generator/_pythonModuleToNamespace.ts +3 -0
- package/src/types/index.ts +6 -2
- package/src/vars/DefinedWorkflow.ts +3 -1
- package/dist/DraftsSt-DcOTn0QR.js.map +0 -1
- package/dist/run-serve-CN0DhrsA.js.map +0 -1
- package/dist/run-tui-bN2hSD5i.js.map +0 -1
- package/dist/state-COlKYipO.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as stripAnsi, n as settingsPathFor, o as sha1HexOfString } from "./state-
|
|
2
|
-
import { c as PromptVar, g as getComfyStorage, h as extractErrorMessage, m as setLoraKeyword, p as getLoraKeyword, s as LorasVar, y as logError } from "./DefinedWorkflow-
|
|
3
|
-
import { a as assignFamilyColors, c as findDefinedWorkflow, i as listDraftsForFile, l as mergeWorkflowSources, o as buildFileRows, s as familyOf, t as DraftsSt, u as scanCflowFiles } from "./DraftsSt-
|
|
1
|
+
import { i as stripAnsi, n as settingsPathFor, o as sha1HexOfString } from "./state-DC5BcG6d.js";
|
|
2
|
+
import { c as PromptVar, g as getComfyStorage, h as extractErrorMessage, m as setLoraKeyword, p as getLoraKeyword, s as LorasVar, y as logError } from "./DefinedWorkflow-CqNE_kgR.js";
|
|
3
|
+
import { a as assignFamilyColors, c as findDefinedWorkflow, i as listDraftsForFile, l as mergeWorkflowSources, n as draftKeyForFile, o as buildFileRows, s as familyOf, t as DraftsSt, u as scanCflowFiles } from "./DraftsSt-C-gBk9v7.js";
|
|
4
4
|
import { spawn } from "node:child_process";
|
|
5
5
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
6
|
import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, statSync, writeFileSync } from "node:fs";
|
|
@@ -12,7 +12,7 @@ import { Box, Text, measureElement, render, useApp, useInput, useStdin } from "i
|
|
|
12
12
|
import sharp from "sharp";
|
|
13
13
|
import { observer } from "mobx-react-lite";
|
|
14
14
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
-
import { homedir } from "node:os";
|
|
15
|
+
import { homedir, tmpdir } from "node:os";
|
|
16
16
|
import { useEffect, useRef } from "react";
|
|
17
17
|
//#region src/cli/tui-env.ts
|
|
18
18
|
const COMFY_TS_TUI_ENV = "COMFY_TS_TUI";
|
|
@@ -109,7 +109,7 @@ var PreviewSt = class {
|
|
|
109
109
|
this.latentBytes = null;
|
|
110
110
|
this.latentDims = null;
|
|
111
111
|
this.latentSeenThisRun = false;
|
|
112
|
-
this.
|
|
112
|
+
this.lastOutput = null;
|
|
113
113
|
this.overlay = null;
|
|
114
114
|
this.menuIx = 0;
|
|
115
115
|
this._busy = false;
|
|
@@ -200,7 +200,7 @@ var PreviewSt = class {
|
|
|
200
200
|
this.latentBytes = null;
|
|
201
201
|
this.latentDims = null;
|
|
202
202
|
this.latentSeenThisRun = false;
|
|
203
|
-
this.
|
|
203
|
+
this.lastOutput = null;
|
|
204
204
|
}
|
|
205
205
|
/** run boundary: drop the latents so the next run never shows the previous one's */
|
|
206
206
|
clearLatent() {
|
|
@@ -213,7 +213,7 @@ var PreviewSt = class {
|
|
|
213
213
|
onSettingsChanged() {
|
|
214
214
|
this.outputAnsi = null;
|
|
215
215
|
this.outputBytes = null;
|
|
216
|
-
if (this.show && this.
|
|
216
|
+
if (this.show && this.lastOutput != null) this.renderOutput(this.lastOutput);
|
|
217
217
|
}
|
|
218
218
|
/** what the painter should show RIGHT NOW (native renderer only; mirrors the panel's source) */
|
|
219
219
|
get protocolImage() {
|
|
@@ -260,12 +260,12 @@ var PreviewSt = class {
|
|
|
260
260
|
get height() {
|
|
261
261
|
return Math.max(10, this.st.termRows - 12);
|
|
262
262
|
}
|
|
263
|
-
async renderOutput(
|
|
264
|
-
this.
|
|
263
|
+
async renderOutput(src) {
|
|
264
|
+
this.lastOutput = src;
|
|
265
265
|
if (!this.show) return;
|
|
266
266
|
try {
|
|
267
267
|
if (this.useNative) {
|
|
268
|
-
const shrunk = await sharp(
|
|
268
|
+
const shrunk = await sharp(src).resize(896, 896, {
|
|
269
269
|
fit: "inside",
|
|
270
270
|
withoutEnlargement: true
|
|
271
271
|
}).png().toBuffer();
|
|
@@ -274,7 +274,7 @@ var PreviewSt = class {
|
|
|
274
274
|
});
|
|
275
275
|
return;
|
|
276
276
|
}
|
|
277
|
-
const rendered = await imageBufferToAnsi(
|
|
277
|
+
const rendered = await imageBufferToAnsi(src, {
|
|
278
278
|
width: this.width,
|
|
279
279
|
height: this.height
|
|
280
280
|
});
|
|
@@ -326,12 +326,12 @@ var PreviewSt = class {
|
|
|
326
326
|
const pxW = this.width;
|
|
327
327
|
const pxH = this.height * 2;
|
|
328
328
|
const thumb = await sharp(bytes).resize(Math.max(8, Math.floor(pxW * PIXEL_SMALL_FRACTION)), Math.max(8, Math.floor(pxH * PIXEL_SMALL_FRACTION)), { fit: "inside" }).png().toBuffer();
|
|
329
|
-
const
|
|
330
|
-
if (
|
|
329
|
+
const out = this.lastOutput;
|
|
330
|
+
if (out == null) return imageBufferToAnsi(thumb, {
|
|
331
331
|
width: this.width,
|
|
332
332
|
height: this.height
|
|
333
333
|
});
|
|
334
|
-
return imageBufferToAnsi(await sharp(await sharp(
|
|
334
|
+
return imageBufferToAnsi(await sharp(await sharp(out).resize(pxW, pxH, { fit: "inside" }).png().toBuffer()).composite([{
|
|
335
335
|
input: thumb,
|
|
336
336
|
gravity: "northeast"
|
|
337
337
|
}]).png().toBuffer(), {
|
|
@@ -1872,7 +1872,7 @@ const VarRow = observer((p) => {
|
|
|
1872
1872
|
});
|
|
1873
1873
|
const VarsPanel = observer((p) => {
|
|
1874
1874
|
const s = p.st;
|
|
1875
|
-
const labelW = Math.max(
|
|
1875
|
+
const labelW = Math.max(12, ...s.entries.map(([name, v]) => (v.label ?? name).length)) + 3;
|
|
1876
1876
|
const focused = s.mode === "nav" || s.mode === "edit";
|
|
1877
1877
|
const boxRef = useRef(null);
|
|
1878
1878
|
useEffect(() => {
|
|
@@ -1899,7 +1899,7 @@ const VarsPanel = observer((p) => {
|
|
|
1899
1899
|
color: "gray",
|
|
1900
1900
|
children: "…"
|
|
1901
1901
|
}),
|
|
1902
|
-
s.entries.slice(w.start, w.end).map(([name, varDef], sliceIx) => /* @__PURE__ */ jsx(VarRow, {
|
|
1902
|
+
s.entries.slice(w.start, Math.min(w.end, s.entries.length)).map(([name, varDef], sliceIx) => /* @__PURE__ */ jsx(VarRow, {
|
|
1903
1903
|
name,
|
|
1904
1904
|
varDef,
|
|
1905
1905
|
selected: w.start + sliceIx === s.selIx,
|
|
@@ -1907,6 +1907,68 @@ const VarsPanel = observer((p) => {
|
|
|
1907
1907
|
st: s,
|
|
1908
1908
|
compact: s.varsCompact
|
|
1909
1909
|
}, name)),
|
|
1910
|
+
w.end > s.entries.length && /* @__PURE__ */ jsxs(Box, {
|
|
1911
|
+
flexDirection: "row",
|
|
1912
|
+
children: [
|
|
1913
|
+
/* @__PURE__ */ jsx(Box, {
|
|
1914
|
+
width: labelW,
|
|
1915
|
+
flexShrink: 0,
|
|
1916
|
+
children: /* @__PURE__ */ jsxs(Text, {
|
|
1917
|
+
inverse: s.onSaveRow,
|
|
1918
|
+
children: [s.onSaveRow ? "▸ " : " ", "save to disk"]
|
|
1919
|
+
})
|
|
1920
|
+
}),
|
|
1921
|
+
/* @__PURE__ */ jsx(Box, {
|
|
1922
|
+
width: 9,
|
|
1923
|
+
flexShrink: 0,
|
|
1924
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
1925
|
+
color: "gray",
|
|
1926
|
+
children: "[tui]"
|
|
1927
|
+
})
|
|
1928
|
+
}),
|
|
1929
|
+
/* @__PURE__ */ jsx(Box, {
|
|
1930
|
+
flexGrow: 1,
|
|
1931
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
1932
|
+
color: s.settings.saveToDisk ? "cyan" : "yellow",
|
|
1933
|
+
wrap: "truncate",
|
|
1934
|
+
children: s.settings.saveToDisk ? "on" : "off — outputs stay in memory"
|
|
1935
|
+
})
|
|
1936
|
+
})
|
|
1937
|
+
]
|
|
1938
|
+
}),
|
|
1939
|
+
s.settings.saveToDisk && w.end > s.entries.length + 1 && /* @__PURE__ */ jsxs(Box, {
|
|
1940
|
+
flexDirection: "row",
|
|
1941
|
+
children: [
|
|
1942
|
+
/* @__PURE__ */ jsx(Box, {
|
|
1943
|
+
width: labelW,
|
|
1944
|
+
flexShrink: 0,
|
|
1945
|
+
children: /* @__PURE__ */ jsxs(Text, {
|
|
1946
|
+
inverse: s.onPrefixRow,
|
|
1947
|
+
children: [s.onPrefixRow ? "▸ " : " ", "save prefix"]
|
|
1948
|
+
})
|
|
1949
|
+
}),
|
|
1950
|
+
/* @__PURE__ */ jsx(Box, {
|
|
1951
|
+
width: 9,
|
|
1952
|
+
flexShrink: 0,
|
|
1953
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
1954
|
+
color: "gray",
|
|
1955
|
+
children: "[tui]"
|
|
1956
|
+
})
|
|
1957
|
+
}),
|
|
1958
|
+
/* @__PURE__ */ jsx(Box, {
|
|
1959
|
+
flexGrow: 1,
|
|
1960
|
+
children: /* @__PURE__ */ jsxs(Text, {
|
|
1961
|
+
color: "cyan",
|
|
1962
|
+
wrap: "truncate",
|
|
1963
|
+
children: [
|
|
1964
|
+
".comfy-ts/outputs/",
|
|
1965
|
+
s.savePrefix,
|
|
1966
|
+
"/"
|
|
1967
|
+
]
|
|
1968
|
+
})
|
|
1969
|
+
})
|
|
1970
|
+
]
|
|
1971
|
+
}),
|
|
1910
1972
|
w.moreBelow && /* @__PURE__ */ jsx(Text, {
|
|
1911
1973
|
color: "gray",
|
|
1912
1974
|
children: "…"
|
|
@@ -2170,22 +2232,22 @@ const TuiApp = observer((p) => {
|
|
|
2170
2232
|
paddingX: 1,
|
|
2171
2233
|
children: /* @__PURE__ */ jsx(ProgressLine, { st: s })
|
|
2172
2234
|
}),
|
|
2173
|
-
s.exec.
|
|
2235
|
+
s.exec.outputLabels.length > 0 && /* @__PURE__ */ jsx(Box, {
|
|
2174
2236
|
borderStyle: "round",
|
|
2175
2237
|
paddingX: 1,
|
|
2176
2238
|
flexDirection: "column",
|
|
2177
|
-
children: s.exec.
|
|
2178
|
-
color: "green",
|
|
2239
|
+
children: s.exec.outputLabels.map((o, ix) => /* @__PURE__ */ jsxs(Text, {
|
|
2240
|
+
color: o.memory ? "yellow" : "green",
|
|
2179
2241
|
wrap: "truncate",
|
|
2180
2242
|
children: [
|
|
2181
|
-
|
|
2243
|
+
o.name,
|
|
2182
2244
|
" ",
|
|
2183
2245
|
/* @__PURE__ */ jsx(Text, {
|
|
2184
2246
|
color: "gray",
|
|
2185
|
-
children: o
|
|
2247
|
+
children: o.detail
|
|
2186
2248
|
})
|
|
2187
2249
|
]
|
|
2188
|
-
}, o))
|
|
2250
|
+
}, `${ix}-${o.name}`))
|
|
2189
2251
|
}),
|
|
2190
2252
|
!s.mode.startsWith("overlay-") && !(s.mode === "edit" && s.editor.isCustom) && /* @__PURE__ */ jsx(LogsPanel, { st: s })
|
|
2191
2253
|
]
|
|
@@ -2512,6 +2574,36 @@ const extOf = (path) => {
|
|
|
2512
2574
|
const dot = path.lastIndexOf(".");
|
|
2513
2575
|
return dot === -1 ? "" : path.slice(dot + 1).toLowerCase();
|
|
2514
2576
|
};
|
|
2577
|
+
const imageClipboardStdinCommand = (platform, pngBytes) => {
|
|
2578
|
+
if (platform === "darwin") {
|
|
2579
|
+
const hex = Buffer.from(pngBytes).toString("hex").toUpperCase();
|
|
2580
|
+
return {
|
|
2581
|
+
cmd: "osascript",
|
|
2582
|
+
args: ["-"],
|
|
2583
|
+
stdin: new TextEncoder().encode(`set the clipboard to «data PNGf${hex}»`)
|
|
2584
|
+
};
|
|
2585
|
+
}
|
|
2586
|
+
if (platform === "win32") return {
|
|
2587
|
+
cmd: "powershell",
|
|
2588
|
+
args: [
|
|
2589
|
+
"-NoProfile",
|
|
2590
|
+
"-Sta",
|
|
2591
|
+
"-Command",
|
|
2592
|
+
"$b=[Convert]::FromBase64String([Console]::In.ReadToEnd()); $ms=New-Object System.IO.MemoryStream(,$b); Add-Type -AssemblyName System.Windows.Forms,System.Drawing; $img=[System.Drawing.Image]::FromStream($ms); [System.Windows.Forms.Clipboard]::SetImage($img); $img.Dispose()"
|
|
2593
|
+
],
|
|
2594
|
+
stdin: new TextEncoder().encode(Buffer.from(pngBytes).toString("base64"))
|
|
2595
|
+
};
|
|
2596
|
+
return {
|
|
2597
|
+
cmd: "xclip",
|
|
2598
|
+
args: [
|
|
2599
|
+
"-selection",
|
|
2600
|
+
"clipboard",
|
|
2601
|
+
"-t",
|
|
2602
|
+
"image/png"
|
|
2603
|
+
],
|
|
2604
|
+
stdin: pngBytes
|
|
2605
|
+
};
|
|
2606
|
+
};
|
|
2515
2607
|
const imageClipboardCommand = (platform, path) => {
|
|
2516
2608
|
const ext = extOf(path);
|
|
2517
2609
|
if (platform === "darwin") {
|
|
@@ -2558,7 +2650,7 @@ var ExecSt = class {
|
|
|
2558
2650
|
this.st = st;
|
|
2559
2651
|
this.inFlight = 0;
|
|
2560
2652
|
this.progress = null;
|
|
2561
|
-
this.
|
|
2653
|
+
this.outputImages = [];
|
|
2562
2654
|
this.runCount = 0;
|
|
2563
2655
|
this.lastStatus = null;
|
|
2564
2656
|
this.error = null;
|
|
@@ -2574,12 +2666,38 @@ var ExecSt = class {
|
|
|
2574
2666
|
}
|
|
2575
2667
|
/** workflow switch: wipe run artifacts, keep a hello notice */
|
|
2576
2668
|
resetForWorkflow(notice) {
|
|
2577
|
-
this.
|
|
2669
|
+
this.outputImages = [];
|
|
2578
2670
|
this.error = null;
|
|
2579
2671
|
this.notice = notice;
|
|
2580
2672
|
this.runCount = 0;
|
|
2581
2673
|
this.lastStatus = null;
|
|
2582
2674
|
}
|
|
2675
|
+
/** outputs box rows: path when saved, honest memory label otherwise */
|
|
2676
|
+
get outputLabels() {
|
|
2677
|
+
return this.outputImages.map((img) => {
|
|
2678
|
+
if (img.absPath != null) return {
|
|
2679
|
+
name: basename(img.absPath),
|
|
2680
|
+
detail: img.absPath,
|
|
2681
|
+
memory: false
|
|
2682
|
+
};
|
|
2683
|
+
const dims = img.width != null && img.height != null ? `${img.width}x${img.height}, ` : "";
|
|
2684
|
+
return {
|
|
2685
|
+
name: img.filename,
|
|
2686
|
+
detail: `(${dims}in memory — i copies, o opens)`,
|
|
2687
|
+
memory: true
|
|
2688
|
+
};
|
|
2689
|
+
});
|
|
2690
|
+
}
|
|
2691
|
+
/** a file path for viewer/clipboard: the saved file, or the bytes
|
|
2692
|
+
* materialized into os tmpdir (deliberate user action, never a silent
|
|
2693
|
+
* save — architecture item 14). The path derives from the content hash,
|
|
2694
|
+
* so re-materializing is a cheap existsSync, no retention needed. */
|
|
2695
|
+
materialize(img) {
|
|
2696
|
+
if (img.absPath != null) return img.absPath;
|
|
2697
|
+
const path = join(tmpdir(), `comfy-ts-mem-${img.hash.slice(0, 8)}${img.extension}`);
|
|
2698
|
+
if (!existsSync(path)) writeFileSync(path, img.buffer);
|
|
2699
|
+
return path;
|
|
2700
|
+
}
|
|
2583
2701
|
/** every run takes THIS path, queued ones included: same progress, outputs, previews */
|
|
2584
2702
|
async run() {
|
|
2585
2703
|
const queued = this.running;
|
|
@@ -2600,15 +2718,16 @@ var ExecSt = class {
|
|
|
2600
2718
|
try {
|
|
2601
2719
|
const execution = await this.st.wf.run({
|
|
2602
2720
|
host: this.st.hostOverride ?? void 0,
|
|
2721
|
+
save: this.st.settings.saveToDisk ? { prefix: this.st.savePrefix } : false,
|
|
2603
2722
|
onProgress: (p) => runInAction(() => this.onProgress(p))
|
|
2604
2723
|
});
|
|
2605
2724
|
runInAction(() => {
|
|
2606
|
-
this.
|
|
2725
|
+
this.outputImages = execution.images.slice();
|
|
2607
2726
|
this.lastStatus = execution.status;
|
|
2608
2727
|
this.runCount++;
|
|
2609
2728
|
});
|
|
2610
2729
|
const lastImage = execution.images[execution.images.length - 1];
|
|
2611
|
-
if (lastImage) this.st.preview.renderOutput(lastImage.absPath);
|
|
2730
|
+
if (lastImage != null) this.st.preview.renderOutput(lastImage.absPath ?? lastImage.buffer);
|
|
2612
2731
|
} catch (e) {
|
|
2613
2732
|
runInAction(() => {
|
|
2614
2733
|
this.error = extractErrorMessage(e);
|
|
@@ -2641,11 +2760,18 @@ var ExecSt = class {
|
|
|
2641
2760
|
}
|
|
2642
2761
|
/** 'o': real pixels in the OS viewer — the in-terminal ceiling is half-blocks */
|
|
2643
2762
|
openLastOutput() {
|
|
2644
|
-
const
|
|
2645
|
-
if (
|
|
2763
|
+
const lastImg = this.outputImages[this.outputImages.length - 1];
|
|
2764
|
+
if (lastImg == null) {
|
|
2646
2765
|
this.notice = "no output image yet";
|
|
2647
2766
|
return;
|
|
2648
2767
|
}
|
|
2768
|
+
let last;
|
|
2769
|
+
try {
|
|
2770
|
+
last = this.materialize(lastImg);
|
|
2771
|
+
} catch (e) {
|
|
2772
|
+
this.notice = `open failed: ${extractErrorMessage(e)}`;
|
|
2773
|
+
return;
|
|
2774
|
+
}
|
|
2649
2775
|
const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
|
|
2650
2776
|
const proc = spawn(cmd, [last], {
|
|
2651
2777
|
stdio: "ignore",
|
|
@@ -2657,7 +2783,7 @@ var ExecSt = class {
|
|
|
2657
2783
|
});
|
|
2658
2784
|
});
|
|
2659
2785
|
proc.unref();
|
|
2660
|
-
this.notice = `opened ${basename(last)}`;
|
|
2786
|
+
this.notice = `opened ${basename(last)}${lastImg.absPath == null ? ` (memory image via ${last})` : ""}`;
|
|
2661
2787
|
}
|
|
2662
2788
|
closeCopyPopup() {
|
|
2663
2789
|
this.copyPopup = null;
|
|
@@ -2676,42 +2802,69 @@ var ExecSt = class {
|
|
|
2676
2802
|
};
|
|
2677
2803
|
this.st.mode = "overlay-copy";
|
|
2678
2804
|
}
|
|
2679
|
-
/** 'i': the LAST generated image's pixels → clipboard (paste anywhere)
|
|
2805
|
+
/** 'i': the LAST generated image's pixels → clipboard (paste anywhere).
|
|
2806
|
+
* The primary route pipes png bytes over stdin — no disk write at all
|
|
2807
|
+
* (his ask 2026-07-31); only when that tool fails does it fall back to
|
|
2808
|
+
* the materialized-file command, and the popup says which route ran. */
|
|
2680
2809
|
async copyLastImage() {
|
|
2681
|
-
const
|
|
2682
|
-
if (
|
|
2810
|
+
const lastImg = this.outputImages[this.outputImages.length - 1];
|
|
2811
|
+
if (lastImg == null) {
|
|
2683
2812
|
this.showCopyPopup("image → clipboard", false, ["no output image yet — r runs the workflow first"]);
|
|
2684
2813
|
return;
|
|
2685
2814
|
}
|
|
2686
|
-
let
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
const { default: sharp } = await import("sharp");
|
|
2690
|
-
const { tmpdir } = await import("node:os");
|
|
2691
|
-
const { join } = await import("pathe");
|
|
2692
|
-
file = join(tmpdir(), `comfy-ts-clip-${Date.now()}.png`);
|
|
2693
|
-
await sharp(last).png().toFile(file);
|
|
2694
|
-
command = imageClipboardCommand(process.platform, file);
|
|
2815
|
+
let pngBytes;
|
|
2816
|
+
try {
|
|
2817
|
+
pngBytes = lastImg.metadata.type === "png" ? lastImg.buffer : await this.toPngBytes(lastImg.buffer);
|
|
2695
2818
|
} catch (e) {
|
|
2696
|
-
this.showCopyPopup("image → clipboard", false, [`COPY FAILED for ${
|
|
2819
|
+
this.showCopyPopup("image → clipboard", false, [`COPY FAILED for ${lastImg.filename}`, `png transcode failed: ${extractErrorMessage(e)}`]);
|
|
2697
2820
|
return;
|
|
2698
2821
|
}
|
|
2699
|
-
|
|
2700
|
-
|
|
2822
|
+
const piped = imageClipboardStdinCommand(process.platform, pngBytes);
|
|
2823
|
+
if (await this.runWithStdin(piped)) {
|
|
2824
|
+
this.showCopyPopup("image → clipboard", true, [
|
|
2825
|
+
`${lastImg.filename} — paste the pixels anywhere`,
|
|
2826
|
+
"",
|
|
2827
|
+
"nothing written to disk"
|
|
2828
|
+
]);
|
|
2829
|
+
return;
|
|
2830
|
+
}
|
|
2831
|
+
let file;
|
|
2832
|
+
try {
|
|
2833
|
+
file = this.materialize(lastImg);
|
|
2834
|
+
} catch (e) {
|
|
2835
|
+
this.showCopyPopup("image → clipboard", false, [`COPY FAILED for ${lastImg.filename}`, `piped ${piped.cmd} failed, and the tmp-file fallback could not write: ${extractErrorMessage(e)}`]);
|
|
2701
2836
|
return;
|
|
2702
2837
|
}
|
|
2703
|
-
const
|
|
2704
|
-
const ok = await new Promise((resolve) => {
|
|
2705
|
-
const proc = spawn(
|
|
2838
|
+
const command = imageClipboardCommand(process.platform, file);
|
|
2839
|
+
const ok = command != null && await new Promise((resolve) => {
|
|
2840
|
+
const proc = spawn(command.cmd, command.args, { stdio: "ignore" });
|
|
2706
2841
|
proc.on("error", () => resolve(false));
|
|
2707
2842
|
proc.on("close", (code) => resolve(code === 0));
|
|
2708
2843
|
});
|
|
2709
2844
|
runInAction(() => {
|
|
2710
2845
|
this.showCopyPopup("image → clipboard", ok, ok ? [
|
|
2711
|
-
`${basename(
|
|
2846
|
+
`${basename(file)} — paste the pixels anywhere`,
|
|
2712
2847
|
"",
|
|
2713
|
-
|
|
2714
|
-
] : [`COPY FAILED for ${
|
|
2848
|
+
`via fallback file ${file}`
|
|
2849
|
+
] : [`COPY FAILED for ${lastImg.filename}`, `could not run ${piped.cmd} — is it installed and allowed ?`]);
|
|
2850
|
+
});
|
|
2851
|
+
}
|
|
2852
|
+
async toPngBytes(bytes) {
|
|
2853
|
+
const { default: sharp } = await import("sharp");
|
|
2854
|
+
return new Uint8Array(await sharp(bytes).png().toBuffer());
|
|
2855
|
+
}
|
|
2856
|
+
runWithStdin(p) {
|
|
2857
|
+
return new Promise((resolve) => {
|
|
2858
|
+
const proc = spawn(p.cmd, p.args, { stdio: [
|
|
2859
|
+
"pipe",
|
|
2860
|
+
"ignore",
|
|
2861
|
+
"ignore"
|
|
2862
|
+
] });
|
|
2863
|
+
proc.on("error", () => resolve(false));
|
|
2864
|
+
proc.on("close", (code) => resolve(code === 0));
|
|
2865
|
+
proc.stdin.on("error", () => {});
|
|
2866
|
+
proc.stdin.write(p.stdin);
|
|
2867
|
+
proc.stdin.end();
|
|
2715
2868
|
});
|
|
2716
2869
|
}
|
|
2717
2870
|
toClipboard(text) {
|
|
@@ -3665,6 +3818,8 @@ var SettingsSt = class {
|
|
|
3665
3818
|
this.lastWorkflow = null;
|
|
3666
3819
|
this.hostOverrideId = null;
|
|
3667
3820
|
this.collapsedDirs = [];
|
|
3821
|
+
this.saveToDisk = true;
|
|
3822
|
+
this.savePrefix = {};
|
|
3668
3823
|
this.load();
|
|
3669
3824
|
if (this.previewRenderer === "native" && !protocolCapable()) this.previewRenderer = "pixel";
|
|
3670
3825
|
makeAutoObservable(this, { st: false });
|
|
@@ -3679,7 +3834,9 @@ var SettingsSt = class {
|
|
|
3679
3834
|
lastDraft: this.lastDraft,
|
|
3680
3835
|
lastWorkflow: this.lastWorkflow,
|
|
3681
3836
|
hostOverrideId: this.hostOverrideId,
|
|
3682
|
-
collapsedDirs: this.collapsedDirs
|
|
3837
|
+
collapsedDirs: this.collapsedDirs,
|
|
3838
|
+
saveToDisk: this.saveToDisk,
|
|
3839
|
+
savePrefix: this.savePrefix
|
|
3683
3840
|
});
|
|
3684
3841
|
}
|
|
3685
3842
|
rememberDraft(moduleKey, draft) {
|
|
@@ -3704,6 +3861,8 @@ var SettingsSt = class {
|
|
|
3704
3861
|
if (typeof o.lastWorkflow === "string") this.lastWorkflow = o.lastWorkflow;
|
|
3705
3862
|
if (typeof o.hostOverrideId === "string") this.hostOverrideId = o.hostOverrideId;
|
|
3706
3863
|
if (Array.isArray(o.collapsedDirs)) this.collapsedDirs = o.collapsedDirs.filter((d) => typeof d === "string");
|
|
3864
|
+
if (typeof o.saveToDisk === "boolean") this.saveToDisk = o.saveToDisk;
|
|
3865
|
+
if (o.savePrefix != null && typeof o.savePrefix === "object") this.savePrefix = Object.fromEntries(Object.entries(o.savePrefix).filter((kv) => typeof kv[1] === "string"));
|
|
3707
3866
|
} catch {}
|
|
3708
3867
|
}
|
|
3709
3868
|
write(json) {
|
|
@@ -4122,9 +4281,37 @@ var TuiSt = class {
|
|
|
4122
4281
|
get selected() {
|
|
4123
4282
|
return this.entries[this.selIx];
|
|
4124
4283
|
}
|
|
4284
|
+
/** module key of the loaded workflow (drafts + savePrefix are keyed by it) */
|
|
4285
|
+
get moduleKey() {
|
|
4286
|
+
const cur = this.workflows.currentPath;
|
|
4287
|
+
return cur != null ? draftKeyForFile(cur) : this.wf.spec.id ?? "workflow";
|
|
4288
|
+
}
|
|
4289
|
+
/** the local save dir under .comfy-ts/outputs/ — per-module override, else the module key */
|
|
4290
|
+
get savePrefix() {
|
|
4291
|
+
return this.settings.savePrefix[this.moduleKey] ?? this.moduleKey;
|
|
4292
|
+
}
|
|
4293
|
+
/** empty input resets to the module-key default */
|
|
4294
|
+
setSavePrefix(raw) {
|
|
4295
|
+
const trimmed = raw.trim().replace(/^\/+|\/+$/g, "");
|
|
4296
|
+
if (trimmed === "" || trimmed === this.moduleKey) delete this.settings.savePrefix[this.moduleKey];
|
|
4297
|
+
else this.settings.savePrefix[this.moduleKey] = trimmed;
|
|
4298
|
+
}
|
|
4299
|
+
/** the vars list carries the TUI-owned rows after the workflow vars: the
|
|
4300
|
+
* save-to-disk toggle, plus the save-prefix row while saving is on
|
|
4301
|
+
* (architecture item 14) */
|
|
4302
|
+
get varRowCount() {
|
|
4303
|
+
return this.entries.length + (this.settings.saveToDisk ? 2 : 1);
|
|
4304
|
+
}
|
|
4305
|
+
/** true while the selection sits on the save-to-disk pseudo-row */
|
|
4306
|
+
get onSaveRow() {
|
|
4307
|
+
return this.selIx === this.entries.length;
|
|
4308
|
+
}
|
|
4309
|
+
/** true while the selection sits on the save-prefix pseudo-row */
|
|
4310
|
+
get onPrefixRow() {
|
|
4311
|
+
return this.settings.saveToDisk && this.selIx === this.entries.length + 1;
|
|
4312
|
+
}
|
|
4125
4313
|
moveSel(delta) {
|
|
4126
|
-
const len = this.
|
|
4127
|
-
if (len === 0) return;
|
|
4314
|
+
const len = this.varRowCount;
|
|
4128
4315
|
this.selIx = (this.selIx + delta + len) % len;
|
|
4129
4316
|
}
|
|
4130
4317
|
setVarsViewH(h) {
|
|
@@ -4137,7 +4324,7 @@ var TuiSt = class {
|
|
|
4137
4324
|
}
|
|
4138
4325
|
get varsWindow() {
|
|
4139
4326
|
return listWindow({
|
|
4140
|
-
count: this.
|
|
4327
|
+
count: this.varRowCount,
|
|
4141
4328
|
selected: this.selIx,
|
|
4142
4329
|
budget: this.varsBudget
|
|
4143
4330
|
});
|
|
@@ -4152,10 +4339,25 @@ var TuiSt = class {
|
|
|
4152
4339
|
const w = this.varsWindow;
|
|
4153
4340
|
if (w.moreAbove || w.moreBelow) return true;
|
|
4154
4341
|
const h = this.varsViewH > 0 ? this.varsViewH : Math.max(5, this.termRows - 5);
|
|
4155
|
-
return this.
|
|
4342
|
+
return this.varRowCount + 2 > h;
|
|
4156
4343
|
}
|
|
4157
4344
|
/** enter/space on a var: toggle, open an overlay, or inline-edit */
|
|
4158
4345
|
activate() {
|
|
4346
|
+
if (this.onSaveRow) {
|
|
4347
|
+
this.settings.saveToDisk = !this.settings.saveToDisk;
|
|
4348
|
+
return;
|
|
4349
|
+
}
|
|
4350
|
+
if (this.onPrefixRow) {
|
|
4351
|
+
this.editor.beginCustom({
|
|
4352
|
+
title: `save prefix — dir under .comfy-ts/outputs/ (empty = ${this.moduleKey})`,
|
|
4353
|
+
initial: this.savePrefix,
|
|
4354
|
+
onCommit: (raw) => {
|
|
4355
|
+
this.setSavePrefix(raw);
|
|
4356
|
+
return true;
|
|
4357
|
+
}
|
|
4358
|
+
});
|
|
4359
|
+
return;
|
|
4360
|
+
}
|
|
4159
4361
|
const sel = this.selected?.[1];
|
|
4160
4362
|
if (sel == null) return;
|
|
4161
4363
|
if (sel.kind === "toggle") sel.toggle();
|
|
@@ -4262,4 +4464,4 @@ async function runTui(args) {
|
|
|
4262
4464
|
//#endregion
|
|
4263
4465
|
export { runTui };
|
|
4264
4466
|
|
|
4265
|
-
//# sourceMappingURL=run-tui-
|
|
4467
|
+
//# sourceMappingURL=run-tui-DXI_Jufu.js.map
|