comfy-ts 2.0.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/dist/{DraftsSt-Da4DZUP7.js → DraftsSt-C-gBk9v7.js} +2 -3
- package/dist/DraftsSt-C-gBk9v7.js.map +1 -0
- package/dist/cli.js +3 -3
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{run-serve-BqeXtf8P.js → run-serve-CnlN_RFH.js} +2 -2
- package/dist/{run-serve-BqeXtf8P.js.map → run-serve-CnlN_RFH.js.map} +1 -1
- package/dist/{run-tui-CiB7TbYv.js → run-tui-DXI_Jufu.js} +257 -61
- package/dist/run-tui-DXI_Jufu.js.map +1 -0
- package/dist/{state-C1g_B8zR.js → state-DC5BcG6d.js} +2 -2
- package/dist/{state-C1g_B8zR.js.map → state-DC5BcG6d.js.map} +1 -1
- package/dist/web.js +1 -1
- package/package.json +1 -1
- 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 -52
- 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/dist/DraftsSt-Da4DZUP7.js.map +0 -1
- package/dist/run-tui-CiB7TbYv.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as stripAnsi, n as settingsPathFor, o as sha1HexOfString } from "./state-
|
|
1
|
+
import { i as stripAnsi, n as settingsPathFor, o as sha1HexOfString } from "./state-DC5BcG6d.js";
|
|
2
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-
|
|
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;
|
|
@@ -2572,19 +2664,40 @@ var ExecSt = class {
|
|
|
2572
2664
|
get running() {
|
|
2573
2665
|
return this.inFlight > 0;
|
|
2574
2666
|
}
|
|
2575
|
-
/** local save dir for this module's outputs (same key the drafts use) */
|
|
2576
|
-
get saveDirPrefix() {
|
|
2577
|
-
const cur = this.st.workflows.currentPath;
|
|
2578
|
-
return cur != null ? draftKeyForFile(cur) : this.st.wf.spec.id ?? "workflow";
|
|
2579
|
-
}
|
|
2580
2667
|
/** workflow switch: wipe run artifacts, keep a hello notice */
|
|
2581
2668
|
resetForWorkflow(notice) {
|
|
2582
|
-
this.
|
|
2669
|
+
this.outputImages = [];
|
|
2583
2670
|
this.error = null;
|
|
2584
2671
|
this.notice = notice;
|
|
2585
2672
|
this.runCount = 0;
|
|
2586
2673
|
this.lastStatus = null;
|
|
2587
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
|
+
}
|
|
2588
2701
|
/** every run takes THIS path, queued ones included: same progress, outputs, previews */
|
|
2589
2702
|
async run() {
|
|
2590
2703
|
const queued = this.running;
|
|
@@ -2605,16 +2718,16 @@ var ExecSt = class {
|
|
|
2605
2718
|
try {
|
|
2606
2719
|
const execution = await this.st.wf.run({
|
|
2607
2720
|
host: this.st.hostOverride ?? void 0,
|
|
2608
|
-
save: { prefix: this.
|
|
2721
|
+
save: this.st.settings.saveToDisk ? { prefix: this.st.savePrefix } : false,
|
|
2609
2722
|
onProgress: (p) => runInAction(() => this.onProgress(p))
|
|
2610
2723
|
});
|
|
2611
2724
|
runInAction(() => {
|
|
2612
|
-
this.
|
|
2725
|
+
this.outputImages = execution.images.slice();
|
|
2613
2726
|
this.lastStatus = execution.status;
|
|
2614
2727
|
this.runCount++;
|
|
2615
2728
|
});
|
|
2616
2729
|
const lastImage = execution.images[execution.images.length - 1];
|
|
2617
|
-
if (lastImage
|
|
2730
|
+
if (lastImage != null) this.st.preview.renderOutput(lastImage.absPath ?? lastImage.buffer);
|
|
2618
2731
|
} catch (e) {
|
|
2619
2732
|
runInAction(() => {
|
|
2620
2733
|
this.error = extractErrorMessage(e);
|
|
@@ -2647,11 +2760,18 @@ var ExecSt = class {
|
|
|
2647
2760
|
}
|
|
2648
2761
|
/** 'o': real pixels in the OS viewer — the in-terminal ceiling is half-blocks */
|
|
2649
2762
|
openLastOutput() {
|
|
2650
|
-
const
|
|
2651
|
-
if (
|
|
2763
|
+
const lastImg = this.outputImages[this.outputImages.length - 1];
|
|
2764
|
+
if (lastImg == null) {
|
|
2652
2765
|
this.notice = "no output image yet";
|
|
2653
2766
|
return;
|
|
2654
2767
|
}
|
|
2768
|
+
let last;
|
|
2769
|
+
try {
|
|
2770
|
+
last = this.materialize(lastImg);
|
|
2771
|
+
} catch (e) {
|
|
2772
|
+
this.notice = `open failed: ${extractErrorMessage(e)}`;
|
|
2773
|
+
return;
|
|
2774
|
+
}
|
|
2655
2775
|
const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
|
|
2656
2776
|
const proc = spawn(cmd, [last], {
|
|
2657
2777
|
stdio: "ignore",
|
|
@@ -2663,7 +2783,7 @@ var ExecSt = class {
|
|
|
2663
2783
|
});
|
|
2664
2784
|
});
|
|
2665
2785
|
proc.unref();
|
|
2666
|
-
this.notice = `opened ${basename(last)}`;
|
|
2786
|
+
this.notice = `opened ${basename(last)}${lastImg.absPath == null ? ` (memory image via ${last})` : ""}`;
|
|
2667
2787
|
}
|
|
2668
2788
|
closeCopyPopup() {
|
|
2669
2789
|
this.copyPopup = null;
|
|
@@ -2682,42 +2802,69 @@ var ExecSt = class {
|
|
|
2682
2802
|
};
|
|
2683
2803
|
this.st.mode = "overlay-copy";
|
|
2684
2804
|
}
|
|
2685
|
-
/** '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. */
|
|
2686
2809
|
async copyLastImage() {
|
|
2687
|
-
const
|
|
2688
|
-
if (
|
|
2810
|
+
const lastImg = this.outputImages[this.outputImages.length - 1];
|
|
2811
|
+
if (lastImg == null) {
|
|
2689
2812
|
this.showCopyPopup("image → clipboard", false, ["no output image yet — r runs the workflow first"]);
|
|
2690
2813
|
return;
|
|
2691
2814
|
}
|
|
2692
|
-
let
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
const { default: sharp } = await import("sharp");
|
|
2696
|
-
const { tmpdir } = await import("node:os");
|
|
2697
|
-
const { join } = await import("pathe");
|
|
2698
|
-
file = join(tmpdir(), `comfy-ts-clip-${Date.now()}.png`);
|
|
2699
|
-
await sharp(last).png().toFile(file);
|
|
2700
|
-
command = imageClipboardCommand(process.platform, file);
|
|
2815
|
+
let pngBytes;
|
|
2816
|
+
try {
|
|
2817
|
+
pngBytes = lastImg.metadata.type === "png" ? lastImg.buffer : await this.toPngBytes(lastImg.buffer);
|
|
2701
2818
|
} catch (e) {
|
|
2702
|
-
this.showCopyPopup("image → clipboard", false, [`COPY FAILED for ${
|
|
2819
|
+
this.showCopyPopup("image → clipboard", false, [`COPY FAILED for ${lastImg.filename}`, `png transcode failed: ${extractErrorMessage(e)}`]);
|
|
2703
2820
|
return;
|
|
2704
2821
|
}
|
|
2705
|
-
|
|
2706
|
-
|
|
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
|
+
]);
|
|
2707
2829
|
return;
|
|
2708
2830
|
}
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
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)}`]);
|
|
2836
|
+
return;
|
|
2837
|
+
}
|
|
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" });
|
|
2712
2841
|
proc.on("error", () => resolve(false));
|
|
2713
2842
|
proc.on("close", (code) => resolve(code === 0));
|
|
2714
2843
|
});
|
|
2715
2844
|
runInAction(() => {
|
|
2716
2845
|
this.showCopyPopup("image → clipboard", ok, ok ? [
|
|
2717
|
-
`${basename(
|
|
2846
|
+
`${basename(file)} — paste the pixels anywhere`,
|
|
2718
2847
|
"",
|
|
2719
|
-
|
|
2720
|
-
] : [`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();
|
|
2721
2868
|
});
|
|
2722
2869
|
}
|
|
2723
2870
|
toClipboard(text) {
|
|
@@ -3671,6 +3818,8 @@ var SettingsSt = class {
|
|
|
3671
3818
|
this.lastWorkflow = null;
|
|
3672
3819
|
this.hostOverrideId = null;
|
|
3673
3820
|
this.collapsedDirs = [];
|
|
3821
|
+
this.saveToDisk = true;
|
|
3822
|
+
this.savePrefix = {};
|
|
3674
3823
|
this.load();
|
|
3675
3824
|
if (this.previewRenderer === "native" && !protocolCapable()) this.previewRenderer = "pixel";
|
|
3676
3825
|
makeAutoObservable(this, { st: false });
|
|
@@ -3685,7 +3834,9 @@ var SettingsSt = class {
|
|
|
3685
3834
|
lastDraft: this.lastDraft,
|
|
3686
3835
|
lastWorkflow: this.lastWorkflow,
|
|
3687
3836
|
hostOverrideId: this.hostOverrideId,
|
|
3688
|
-
collapsedDirs: this.collapsedDirs
|
|
3837
|
+
collapsedDirs: this.collapsedDirs,
|
|
3838
|
+
saveToDisk: this.saveToDisk,
|
|
3839
|
+
savePrefix: this.savePrefix
|
|
3689
3840
|
});
|
|
3690
3841
|
}
|
|
3691
3842
|
rememberDraft(moduleKey, draft) {
|
|
@@ -3710,6 +3861,8 @@ var SettingsSt = class {
|
|
|
3710
3861
|
if (typeof o.lastWorkflow === "string") this.lastWorkflow = o.lastWorkflow;
|
|
3711
3862
|
if (typeof o.hostOverrideId === "string") this.hostOverrideId = o.hostOverrideId;
|
|
3712
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"));
|
|
3713
3866
|
} catch {}
|
|
3714
3867
|
}
|
|
3715
3868
|
write(json) {
|
|
@@ -4128,9 +4281,37 @@ var TuiSt = class {
|
|
|
4128
4281
|
get selected() {
|
|
4129
4282
|
return this.entries[this.selIx];
|
|
4130
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
|
+
}
|
|
4131
4313
|
moveSel(delta) {
|
|
4132
|
-
const len = this.
|
|
4133
|
-
if (len === 0) return;
|
|
4314
|
+
const len = this.varRowCount;
|
|
4134
4315
|
this.selIx = (this.selIx + delta + len) % len;
|
|
4135
4316
|
}
|
|
4136
4317
|
setVarsViewH(h) {
|
|
@@ -4143,7 +4324,7 @@ var TuiSt = class {
|
|
|
4143
4324
|
}
|
|
4144
4325
|
get varsWindow() {
|
|
4145
4326
|
return listWindow({
|
|
4146
|
-
count: this.
|
|
4327
|
+
count: this.varRowCount,
|
|
4147
4328
|
selected: this.selIx,
|
|
4148
4329
|
budget: this.varsBudget
|
|
4149
4330
|
});
|
|
@@ -4158,10 +4339,25 @@ var TuiSt = class {
|
|
|
4158
4339
|
const w = this.varsWindow;
|
|
4159
4340
|
if (w.moreAbove || w.moreBelow) return true;
|
|
4160
4341
|
const h = this.varsViewH > 0 ? this.varsViewH : Math.max(5, this.termRows - 5);
|
|
4161
|
-
return this.
|
|
4342
|
+
return this.varRowCount + 2 > h;
|
|
4162
4343
|
}
|
|
4163
4344
|
/** enter/space on a var: toggle, open an overlay, or inline-edit */
|
|
4164
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
|
+
}
|
|
4165
4361
|
const sel = this.selected?.[1];
|
|
4166
4362
|
if (sel == null) return;
|
|
4167
4363
|
if (sel.kind === "toggle") sel.toggle();
|
|
@@ -4268,4 +4464,4 @@ async function runTui(args) {
|
|
|
4268
4464
|
//#endregion
|
|
4269
4465
|
export { runTui };
|
|
4270
4466
|
|
|
4271
|
-
//# sourceMappingURL=run-tui-
|
|
4467
|
+
//# sourceMappingURL=run-tui-DXI_Jufu.js.map
|