comfy-ts 1.2.0 → 1.3.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 +40 -0
- package/dist/DefinedWorkflow-gpknV-5f.js +686 -0
- package/dist/DefinedWorkflow-gpknV-5f.js.map +1 -0
- package/dist/DraftsSt-DmA0jWGl.js +434 -0
- package/dist/DraftsSt-DmA0jWGl.js.map +1 -0
- package/dist/cli.js +15 -5
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +132 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +23 -18
- package/dist/index.js +132 -21
- package/dist/index.js.map +1 -1
- package/dist/run-serve-Bn6yIJB0.js +638 -0
- package/dist/run-serve-Bn6yIJB0.js.map +1 -0
- package/dist/{run-tui-BAdizWsO.js → run-tui-BtjaOXRh.js} +244 -440
- package/dist/run-tui-BtjaOXRh.js.map +1 -0
- package/dist/{state-BYbxDgfr.js → state-DKCPy105.js} +130 -698
- package/dist/state-DKCPy105.js.map +1 -0
- package/package.json +3 -2
- package/src/cli/comfy-ts-cli.ts +15 -5
- package/src/cli/serve/ServeApp.ts +378 -0
- package/src/cli/serve/applyVarPayload.ts +119 -0
- package/src/cli/serve/describeVar.ts +74 -0
- package/src/cli/serve/run-serve.ts +169 -0
- package/src/cli/tui/components/StatusBar.tsx +1 -0
- package/src/cli/tui/components/TreePanel.tsx +17 -3
- package/src/cli/tui/components/TuiApp.tsx +7 -2
- package/src/cli/tui/components/VarsPanel.tsx +67 -34
- package/src/cli/tui/imageClipboard.ts +39 -0
- package/src/cli/tui/listWindow.ts +36 -0
- package/src/cli/tui/state/ExecSt.ts +48 -0
- package/src/cli/tui/state/TreeSt.ts +25 -0
- package/src/cli/tui/state/TuiSt.ts +34 -0
- package/src/litegraph/convertFlowToLiteGraphJSON.ts +11 -7
- package/src/runner/ComfyExecution.ts +21 -4
- package/src/runner/outputPath.ts +75 -0
- package/src/sdk-generator/inputWidgetKind.ts +50 -11
- package/src/sdk-generator/litegraphToApiRequestPayload.ts +14 -7
- package/src/vars/ComfyVars.ts +8 -0
- package/dist/run-tui-BAdizWsO.js.map +0 -1
- package/dist/state-BYbxDgfr.js.map +0 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as stripAnsi, n as settingsPathFor } from "./state-DKCPy105.js";
|
|
2
|
+
import { _ as logError, c as PromptVar, h as extractErrorMessage, m as setLoraKeyword, p as getLoraKeyword, s as LorasVar } from "./DefinedWorkflow-gpknV-5f.js";
|
|
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-DmA0jWGl.js";
|
|
2
4
|
import { spawn } from "node:child_process";
|
|
3
5
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
|
-
import {
|
|
6
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, statSync, writeFileSync } from "node:fs";
|
|
5
7
|
import { basename, dirname, join, resolve } from "pathe";
|
|
6
8
|
import { createHash } from "node:crypto";
|
|
7
9
|
import { type } from "arktype";
|
|
@@ -9,44 +11,13 @@ import sharp from "sharp";
|
|
|
9
11
|
import { imageMeta } from "image-meta";
|
|
10
12
|
import { homedir } from "node:os";
|
|
11
13
|
import { makeAutoObservable, observable, reaction, runInAction } from "mobx";
|
|
12
|
-
import { Box, Text, render, useApp, useInput, useStdin } from "ink";
|
|
14
|
+
import { Box, Text, measureElement, render, useApp, useInput, useStdin } from "ink";
|
|
13
15
|
import { observer } from "mobx-react-lite";
|
|
14
16
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
17
|
+
import { useEffect, useRef } from "react";
|
|
15
18
|
//#region src/cli/tui-env.ts
|
|
16
19
|
const COMFY_TS_TUI_ENV = "COMFY_TS_TUI";
|
|
17
20
|
//#endregion
|
|
18
|
-
//#region src/cli/tui/discoverWorkflows.ts
|
|
19
|
-
/**
|
|
20
|
-
* recursive scan for the workflow-module naming convention. Entries BELOW a
|
|
21
|
-
* node_modules segment are skipped: packaged examples arrive via
|
|
22
|
-
* bundledExamplesDir (src/exampleAssets.ts — symlinked layouts like pnpm would
|
|
23
|
-
* otherwise list them twice, un-deduped, as the user's own files), and
|
|
24
|
-
* third-party packages shipping *.cflow.ts are not this project's workflows. A
|
|
25
|
-
* scan root that is ITSELF inside node_modules still works (the filter is
|
|
26
|
-
* relative to the root).
|
|
27
|
-
*/
|
|
28
|
-
function scanCflowFiles(dir) {
|
|
29
|
-
return readdirSync(dir, { recursive: true }).map((f) => String(f)).filter((f) => !f.split("/").includes("node_modules")).map((f) => join(dir, f)).filter((f) => f.endsWith(".cflow.ts") || f.endsWith(".cflow.tsx")).sort();
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* PURE merge of the scan with the packaged examples (headless-tested). An
|
|
33
|
-
* explicit target keeps its scope only. Bundled files ALWAYS group under the
|
|
34
|
-
* bundled section, also when the scan already found them (repo dev: ./examples
|
|
35
|
-
* is under cwd) — dedupe relies on the caller passing realpath-normalized
|
|
36
|
-
* strings on both sides.
|
|
37
|
-
*/
|
|
38
|
-
function mergeWorkflowSources(p) {
|
|
39
|
-
if (p.explicitTarget) return {
|
|
40
|
-
files: p.scanned,
|
|
41
|
-
bundled: /* @__PURE__ */ new Set()
|
|
42
|
-
};
|
|
43
|
-
const bundled = new Set(p.bundledFiles);
|
|
44
|
-
return {
|
|
45
|
-
files: [...p.scanned.filter((f) => !bundled.has(f)), ...p.bundledFiles],
|
|
46
|
-
bundled
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
//#endregion
|
|
50
21
|
//#region src/exampleAssets.ts
|
|
51
22
|
/**
|
|
52
23
|
* the examples/ folder shipped in the npm tarball, resolved from THIS module's
|
|
@@ -79,16 +50,6 @@ function bundledExamplesDir(moduleUrl = import.meta.url) {
|
|
|
79
50
|
throw new Error(`[comfy-ts] no package.json found walking up from ${fileURLToPath(moduleUrl)}`);
|
|
80
51
|
}
|
|
81
52
|
//#endregion
|
|
82
|
-
//#region src/cli/tui/findDefinedWorkflow.ts
|
|
83
|
-
/**
|
|
84
|
-
* instanceof first; duck-type fallback covers a second copy of the library in
|
|
85
|
-
* the module graph (linked dev setups, npm dedupe misses)
|
|
86
|
-
*/
|
|
87
|
-
function findDefinedWorkflow(mod) {
|
|
88
|
-
const isDefined = (x) => x instanceof DefinedWorkflow || typeof x === "object" && x != null && "spec" in x && typeof x.run === "function" && typeof x.entries === "function";
|
|
89
|
-
return [mod.default, ...Object.values(mod)].find(isDefined) ?? null;
|
|
90
|
-
}
|
|
91
|
-
//#endregion
|
|
92
53
|
//#region src/utils/ansiImage.ts
|
|
93
54
|
/**
|
|
94
55
|
* render an image as truecolor half-block ANSI: each char cell is 1px wide and
|
|
@@ -646,6 +607,7 @@ const KeyBar = observer((p) => {
|
|
|
646
607
|
...s.mode === "nav" ? [["e", "rename draft"]] : [],
|
|
647
608
|
...s.preview.show || s.mode === "preview" ? [] : [["p", "preview (off)"]],
|
|
648
609
|
["o", "open image"],
|
|
610
|
+
["i", "copy image"],
|
|
649
611
|
...s.mode === "tree" || s.mode === "preview" ? [] : [["c/C", "copy wf/api"]],
|
|
650
612
|
["q", "quit"]
|
|
651
613
|
] : [["⌃R", "run"], ["esc", "back"]];
|
|
@@ -1737,18 +1699,27 @@ const TextOverlay = observer((p) => {
|
|
|
1737
1699
|
//#endregion
|
|
1738
1700
|
//#region src/cli/tui/components/TreePanel.tsx
|
|
1739
1701
|
/** persistent left panel: directory hierarchy + workflows with their drafts
|
|
1740
|
-
* nested; `t` (or ← from vars) focuses it, `/` filters it
|
|
1702
|
+
* nested; `t` (or ← from vars) focuses it, `/` filters it. The Box is
|
|
1703
|
+
* measured (keybar wraps, chrome height is width-dependent — arithmetic
|
|
1704
|
+
* lies) and the row list windows to the measured budget; overflow hidden
|
|
1705
|
+
* is the backstop for the one pre-measure frame. */
|
|
1741
1706
|
const TreePanel = observer((p) => {
|
|
1742
1707
|
const s = p.st;
|
|
1743
1708
|
const tree = s.tree;
|
|
1744
1709
|
const focused = s.mode === "tree";
|
|
1710
|
+
const boxRef = useRef(null);
|
|
1711
|
+
useEffect(() => {
|
|
1712
|
+
if (boxRef.current != null) tree.setViewH(measureElement(boxRef.current).height);
|
|
1713
|
+
});
|
|
1745
1714
|
return /* @__PURE__ */ jsxs(Box, {
|
|
1715
|
+
ref: boxRef,
|
|
1746
1716
|
borderStyle: "round",
|
|
1747
1717
|
borderColor: focused ? "cyan" : "gray",
|
|
1748
1718
|
flexDirection: "column",
|
|
1749
1719
|
flexShrink: 0,
|
|
1750
1720
|
width: s.treeWidth,
|
|
1751
1721
|
paddingX: 1,
|
|
1722
|
+
overflow: "hidden",
|
|
1752
1723
|
children: [
|
|
1753
1724
|
/* @__PURE__ */ jsx(Box, {
|
|
1754
1725
|
marginTop: -1,
|
|
@@ -1767,7 +1738,12 @@ const TreePanel = observer((p) => {
|
|
|
1767
1738
|
tree.filtering ? "▌" : ""
|
|
1768
1739
|
]
|
|
1769
1740
|
}),
|
|
1770
|
-
tree.
|
|
1741
|
+
tree.window.moreAbove && /* @__PURE__ */ jsx(Text, {
|
|
1742
|
+
color: "gray",
|
|
1743
|
+
children: "…"
|
|
1744
|
+
}),
|
|
1745
|
+
tree.rows.slice(tree.window.start, tree.window.end).map((row, sliceIx) => {
|
|
1746
|
+
const ix = tree.window.start + sliceIx;
|
|
1771
1747
|
const sel = focused && ix === tree.ix;
|
|
1772
1748
|
const indent = " ".repeat(row.depth * 2);
|
|
1773
1749
|
if (row.kind === "dir") return /* @__PURE__ */ jsxs(Text, {
|
|
@@ -1812,6 +1788,10 @@ const TreePanel = observer((p) => {
|
|
|
1812
1788
|
]
|
|
1813
1789
|
}, `${row.file}·${row.draft}`);
|
|
1814
1790
|
}),
|
|
1791
|
+
tree.window.moreBelow && /* @__PURE__ */ jsx(Text, {
|
|
1792
|
+
color: "gray",
|
|
1793
|
+
children: "…"
|
|
1794
|
+
}),
|
|
1815
1795
|
s.workflows.loading ? /* @__PURE__ */ jsx(Text, {
|
|
1816
1796
|
color: "yellow",
|
|
1817
1797
|
children: "loading…"
|
|
@@ -1849,6 +1829,7 @@ const VarRow = observer((p) => {
|
|
|
1849
1829
|
const label = p.varDef.label ?? p.name;
|
|
1850
1830
|
const raw = p.varDef.display();
|
|
1851
1831
|
const value = raw.length > VALUE_CAP ? `${raw.slice(0, VALUE_CAP)}…` : raw;
|
|
1832
|
+
const oneLine = p.compact && !p.selected;
|
|
1852
1833
|
return /* @__PURE__ */ jsxs(Box, {
|
|
1853
1834
|
flexDirection: "row",
|
|
1854
1835
|
children: [
|
|
@@ -1874,7 +1855,11 @@ const VarRow = observer((p) => {
|
|
|
1874
1855
|
}),
|
|
1875
1856
|
/* @__PURE__ */ jsx(Box, {
|
|
1876
1857
|
flexGrow: 1,
|
|
1877
|
-
children: editing ? /* @__PURE__ */ jsx(EditField, { st: p.st }) :
|
|
1858
|
+
children: editing ? /* @__PURE__ */ jsx(EditField, { st: p.st }) : oneLine ? /* @__PURE__ */ jsx(Text, {
|
|
1859
|
+
color: "cyan",
|
|
1860
|
+
wrap: "truncate",
|
|
1861
|
+
children: value.replaceAll("\n", " ")
|
|
1862
|
+
}) : p.varDef instanceof PromptVar ? /* @__PURE__ */ jsx(PromptCell, {
|
|
1878
1863
|
varDef: p.varDef,
|
|
1879
1864
|
value
|
|
1880
1865
|
}) : /* @__PURE__ */ jsx(Text, {
|
|
@@ -1890,25 +1875,44 @@ const VarsPanel = observer((p) => {
|
|
|
1890
1875
|
const s = p.st;
|
|
1891
1876
|
const labelW = Math.max(6, ...s.entries.map(([name, v]) => (v.label ?? name).length)) + 3;
|
|
1892
1877
|
const focused = s.mode === "nav" || s.mode === "edit";
|
|
1878
|
+
const boxRef = useRef(null);
|
|
1879
|
+
useEffect(() => {
|
|
1880
|
+
if (boxRef.current != null) s.setVarsViewH(measureElement(boxRef.current).height);
|
|
1881
|
+
});
|
|
1882
|
+
const w = s.varsWindow;
|
|
1893
1883
|
return /* @__PURE__ */ jsxs(Box, {
|
|
1884
|
+
ref: boxRef,
|
|
1894
1885
|
borderStyle: "round",
|
|
1895
1886
|
borderColor: focused ? "cyan" : "gray",
|
|
1896
1887
|
paddingX: 1,
|
|
1897
1888
|
flexDirection: "column",
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1889
|
+
overflow: "hidden",
|
|
1890
|
+
children: [
|
|
1891
|
+
/* @__PURE__ */ jsx(Box, {
|
|
1892
|
+
marginTop: -1,
|
|
1893
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
1894
|
+
color: focused ? "cyan" : "gray",
|
|
1895
|
+
bold: focused,
|
|
1896
|
+
children: "(v)ars"
|
|
1897
|
+
})
|
|
1898
|
+
}),
|
|
1899
|
+
w.moreAbove && /* @__PURE__ */ jsx(Text, {
|
|
1900
|
+
color: "gray",
|
|
1901
|
+
children: "…"
|
|
1902
|
+
}),
|
|
1903
|
+
s.entries.slice(w.start, w.end).map(([name, varDef], sliceIx) => /* @__PURE__ */ jsx(VarRow, {
|
|
1904
|
+
name,
|
|
1905
|
+
varDef,
|
|
1906
|
+
selected: w.start + sliceIx === s.selIx,
|
|
1907
|
+
labelW,
|
|
1908
|
+
st: s,
|
|
1909
|
+
compact: s.varsCompact
|
|
1910
|
+
}, name)),
|
|
1911
|
+
w.moreBelow && /* @__PURE__ */ jsx(Text, {
|
|
1912
|
+
color: "gray",
|
|
1913
|
+
children: "…"
|
|
1904
1914
|
})
|
|
1905
|
-
|
|
1906
|
-
name,
|
|
1907
|
-
varDef,
|
|
1908
|
-
selected: ix === s.selIx,
|
|
1909
|
-
labelW,
|
|
1910
|
-
st: s
|
|
1911
|
-
}, name))]
|
|
1915
|
+
]
|
|
1912
1916
|
});
|
|
1913
1917
|
});
|
|
1914
1918
|
//#endregion
|
|
@@ -2053,6 +2057,7 @@ const TuiApp = observer((p) => {
|
|
|
2053
2057
|
if (input === "a") return s.host.begin();
|
|
2054
2058
|
if (input === "p") return s.preview.beginMenu();
|
|
2055
2059
|
if (input === "o") return s.exec.openLastOutput();
|
|
2060
|
+
if (input === "i") return void s.exec.copyLastImage();
|
|
2056
2061
|
if (input === "q") {
|
|
2057
2062
|
s.onExit();
|
|
2058
2063
|
return app.exit();
|
|
@@ -2097,6 +2102,7 @@ const TuiApp = observer((p) => {
|
|
|
2097
2102
|
if (input === "h") return s.host.beginPicker();
|
|
2098
2103
|
if (input === "a") return s.host.begin();
|
|
2099
2104
|
if (input === "o") return s.exec.openLastOutput();
|
|
2105
|
+
if (input === "i") return void s.exec.copyLastImage();
|
|
2100
2106
|
if (input === "q") {
|
|
2101
2107
|
s.onExit();
|
|
2102
2108
|
return app.exit();
|
|
@@ -2140,17 +2146,20 @@ const TuiApp = observer((p) => {
|
|
|
2140
2146
|
if (input === "d") return s.drafts.begin();
|
|
2141
2147
|
if (input === "p") return s.preview.beginMenu();
|
|
2142
2148
|
if (input === "o") return s.exec.openLastOutput();
|
|
2149
|
+
if (input === "i") return void s.exec.copyLastImage();
|
|
2143
2150
|
if (input === "c") return void s.exec.copyWorkflowJson();
|
|
2144
2151
|
if (input === "C") return void s.exec.copyApiJson();
|
|
2145
2152
|
}, { isActive: useStdin().isRawModeSupported === true });
|
|
2146
2153
|
return /* @__PURE__ */ jsxs(Box, {
|
|
2147
2154
|
flexDirection: "column",
|
|
2148
|
-
|
|
2155
|
+
height: s.termRows - 1,
|
|
2149
2156
|
children: [
|
|
2150
2157
|
/* @__PURE__ */ jsx(Header, { st: s }),
|
|
2151
2158
|
/* @__PURE__ */ jsxs(Box, {
|
|
2152
2159
|
flexDirection: "row",
|
|
2153
2160
|
flexGrow: 1,
|
|
2161
|
+
flexShrink: 1,
|
|
2162
|
+
overflow: "hidden",
|
|
2154
2163
|
children: [
|
|
2155
2164
|
/* @__PURE__ */ jsx(TreePanel, { st: s }),
|
|
2156
2165
|
/* @__PURE__ */ jsxs(Box, {
|
|
@@ -2190,389 +2199,59 @@ const TuiApp = observer((p) => {
|
|
|
2190
2199
|
});
|
|
2191
2200
|
});
|
|
2192
2201
|
//#endregion
|
|
2193
|
-
//#region src/cli/tui/
|
|
2194
|
-
/** module display name — also the drafts folder key (DraftsSt delegates here) */
|
|
2195
|
-
function moduleName(file) {
|
|
2196
|
-
return basename(file).replace(/\.cflow\.tsx?$/, "");
|
|
2197
|
-
}
|
|
2198
|
-
/** the color word: everything before the first `-` (`flux1-i2i` → `flux1`) */
|
|
2199
|
-
function familyOf(name) {
|
|
2200
|
-
const dash = name.indexOf("-");
|
|
2201
|
-
return dash === -1 ? name : name.slice(0, dash);
|
|
2202
|
-
}
|
|
2203
|
-
/** hue-spread so CONSECUTIVE families land on clearly distinct colors */
|
|
2204
|
-
const FAMILY_PALETTE = [
|
|
2205
|
-
"#61afef",
|
|
2206
|
-
"#e5c07b",
|
|
2207
|
-
"#c678dd",
|
|
2208
|
-
"#98c379",
|
|
2209
|
-
"#e06c75",
|
|
2210
|
-
"#56b6c2",
|
|
2211
|
-
"#d19a66",
|
|
2212
|
-
"#a5b4fc",
|
|
2213
|
-
"#a5e075",
|
|
2214
|
-
"#f28fad"
|
|
2215
|
-
];
|
|
2216
|
-
/** family → color, palette cycled in first-appearance order over the FULL
|
|
2217
|
-
* (unfiltered) file list — stable while filtering/folding */
|
|
2218
|
-
function assignFamilyColors(files) {
|
|
2219
|
-
const colors = /* @__PURE__ */ new Map();
|
|
2220
|
-
for (const file of files) {
|
|
2221
|
-
const family = familyOf(moduleName(file));
|
|
2222
|
-
if (colors.has(family)) continue;
|
|
2223
|
-
colors.set(family, FAMILY_PALETTE[colors.size % FAMILY_PALETTE.length] ?? "#61afef");
|
|
2224
|
-
}
|
|
2225
|
-
return colors;
|
|
2226
|
-
}
|
|
2227
|
-
function commonDir(files) {
|
|
2228
|
-
const first = files[0];
|
|
2229
|
-
if (first == null) return "";
|
|
2230
|
-
let prefix = dirname(first).split("/");
|
|
2231
|
-
for (const f of files.slice(1)) {
|
|
2232
|
-
const segs = dirname(f).split("/");
|
|
2233
|
-
let i = 0;
|
|
2234
|
-
while (i < prefix.length && i < segs.length && prefix[i] === segs[i]) i++;
|
|
2235
|
-
prefix = prefix.slice(0, i);
|
|
2236
|
-
}
|
|
2237
|
-
return prefix.join("/");
|
|
2238
|
-
}
|
|
2239
|
-
function insert(root, rootDir, file) {
|
|
2240
|
-
const rel = dirname(file).slice(rootDir.length).replace(/^\//, "");
|
|
2241
|
-
const segs = rel === "" ? [] : rel.split("/");
|
|
2242
|
-
let node = root;
|
|
2243
|
-
for (const seg of segs) {
|
|
2244
|
-
let child = node.dirs.get(seg);
|
|
2245
|
-
if (child == null) {
|
|
2246
|
-
child = {
|
|
2247
|
-
path: `${node.path}/${seg}`,
|
|
2248
|
-
label: seg,
|
|
2249
|
-
files: [],
|
|
2250
|
-
dirs: /* @__PURE__ */ new Map()
|
|
2251
|
-
};
|
|
2252
|
-
node.dirs.set(seg, child);
|
|
2253
|
-
}
|
|
2254
|
-
node = child;
|
|
2255
|
-
}
|
|
2256
|
-
node.files.push(file);
|
|
2257
|
-
}
|
|
2258
|
-
/** a dir holding NOTHING but one subdir shows as one `a/b` row */
|
|
2259
|
-
function mergeChains(node) {
|
|
2260
|
-
const entries = [...node.dirs];
|
|
2261
|
-
for (const [key, child] of entries) {
|
|
2262
|
-
mergeChains(child);
|
|
2263
|
-
if (child.files.length === 0 && child.dirs.size === 1) {
|
|
2264
|
-
const only = [...child.dirs.values()][0];
|
|
2265
|
-
const label = `${child.label}/${only.label}`;
|
|
2266
|
-
node.dirs.delete(key);
|
|
2267
|
-
node.dirs.set(label, {
|
|
2268
|
-
...only,
|
|
2269
|
-
label
|
|
2270
|
-
});
|
|
2271
|
-
}
|
|
2272
|
-
}
|
|
2273
|
-
}
|
|
2274
|
-
function matches(file, rootDir, filter) {
|
|
2275
|
-
if (filter === "") return true;
|
|
2276
|
-
return `${dirname(file).slice(rootDir.length)}/${moduleName(file)}`.toLowerCase().includes(filter.toLowerCase());
|
|
2277
|
-
}
|
|
2278
|
-
function emit(p) {
|
|
2279
|
-
for (const file of p.node.files) {
|
|
2280
|
-
if (!matches(file, p.rootDir, p.filter)) continue;
|
|
2281
|
-
p.out.push({
|
|
2282
|
-
kind: "file",
|
|
2283
|
-
file,
|
|
2284
|
-
name: moduleName(file),
|
|
2285
|
-
depth: p.depth
|
|
2286
|
-
});
|
|
2287
|
-
}
|
|
2288
|
-
for (const dir of [...p.node.dirs.values()].sort((a, b) => a.label.localeCompare(b.label))) {
|
|
2289
|
-
const kept = [];
|
|
2290
|
-
const expanded = p.filter !== "" || !p.collapsedDirs.has(dir.path);
|
|
2291
|
-
emit({
|
|
2292
|
-
...p,
|
|
2293
|
-
node: dir,
|
|
2294
|
-
depth: p.depth + 1,
|
|
2295
|
-
out: kept
|
|
2296
|
-
});
|
|
2297
|
-
if (p.filter !== "" && kept.length === 0) continue;
|
|
2298
|
-
p.out.push({
|
|
2299
|
-
kind: "dir",
|
|
2300
|
-
path: dir.path,
|
|
2301
|
-
label: dir.label,
|
|
2302
|
-
depth: p.depth,
|
|
2303
|
-
expanded
|
|
2304
|
-
});
|
|
2305
|
-
if (expanded) p.out.push(...kept);
|
|
2306
|
-
}
|
|
2307
|
-
}
|
|
2202
|
+
//#region src/cli/tui/listWindow.ts
|
|
2308
2203
|
/**
|
|
2309
|
-
*
|
|
2310
|
-
*
|
|
2204
|
+
* window a list around the selection so that
|
|
2205
|
+
* (moreAbove ? 1 : 0) + (end - start) + (moreBelow ? 1 : 0) <= budget,
|
|
2206
|
+
* with the selection always inside [start, end). Degenerate budgets (<= 2)
|
|
2207
|
+
* drop the markers and show a bare slice at the selection.
|
|
2311
2208
|
*/
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
dirs: /* @__PURE__ */ new Map()
|
|
2209
|
+
const listWindow = (p) => {
|
|
2210
|
+
if (p.count === 0 || p.budget <= 0) {
|
|
2211
|
+
const at = Math.max(0, Math.min(p.selected, p.count));
|
|
2212
|
+
return {
|
|
2213
|
+
start: at,
|
|
2214
|
+
end: at,
|
|
2215
|
+
moreAbove: false,
|
|
2216
|
+
moreBelow: false
|
|
2321
2217
|
};
|
|
2322
|
-
for (const f of p.userFiles) insert(root, rootDir, f);
|
|
2323
|
-
mergeChains(root);
|
|
2324
|
-
emit({
|
|
2325
|
-
node: root,
|
|
2326
|
-
depth: 0,
|
|
2327
|
-
rootDir,
|
|
2328
|
-
collapsedDirs: p.collapsedDirs,
|
|
2329
|
-
filter: p.filter,
|
|
2330
|
-
out
|
|
2331
|
-
});
|
|
2332
2218
|
}
|
|
2333
|
-
if (p.
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2219
|
+
if (p.count <= p.budget) return {
|
|
2220
|
+
start: 0,
|
|
2221
|
+
end: p.count,
|
|
2222
|
+
moreAbove: false,
|
|
2223
|
+
moreBelow: false
|
|
2224
|
+
};
|
|
2225
|
+
const sel = Math.max(0, Math.min(p.selected, p.count - 1));
|
|
2226
|
+
if (p.budget <= 2) {
|
|
2227
|
+
const start = Math.min(sel, p.count - p.budget);
|
|
2228
|
+
return {
|
|
2229
|
+
start,
|
|
2230
|
+
end: start + p.budget,
|
|
2231
|
+
moreAbove: false,
|
|
2232
|
+
moreBelow: false
|
|
2340
2233
|
};
|
|
2341
|
-
for (const f of p.bundledFiles) insert(root, rootDir, f);
|
|
2342
|
-
mergeChains(root);
|
|
2343
|
-
const kept = [];
|
|
2344
|
-
const expanded = p.filter !== "" || !p.collapsedDirs.has(rootDir);
|
|
2345
|
-
emit({
|
|
2346
|
-
node: root,
|
|
2347
|
-
depth: 1,
|
|
2348
|
-
rootDir,
|
|
2349
|
-
collapsedDirs: p.collapsedDirs,
|
|
2350
|
-
filter: p.filter,
|
|
2351
|
-
out: kept
|
|
2352
|
-
});
|
|
2353
|
-
if (p.filter !== "" && kept.length === 0) return out;
|
|
2354
|
-
out.push({
|
|
2355
|
-
kind: "dir",
|
|
2356
|
-
path: rootDir,
|
|
2357
|
-
label: root.label,
|
|
2358
|
-
depth: 0,
|
|
2359
|
-
expanded
|
|
2360
|
-
});
|
|
2361
|
-
if (expanded) out.push(...kept);
|
|
2362
|
-
}
|
|
2363
|
-
return out;
|
|
2364
|
-
}
|
|
2365
|
-
//#endregion
|
|
2366
|
-
//#region src/cli/tui/state/DraftsSt.ts
|
|
2367
|
-
/** module basename (`01-txt2img`) keys the draft folder — knowable for EVERY tree file without importing it */
|
|
2368
|
-
function draftKeyForFile(file) {
|
|
2369
|
-
return moduleName(file);
|
|
2370
|
-
}
|
|
2371
|
-
function draftsDirForFile(file) {
|
|
2372
|
-
return comfyts.resolveFromDrafts(draftKeyForFile(file));
|
|
2373
|
-
}
|
|
2374
|
-
function listDraftsInDir(dir) {
|
|
2375
|
-
if (!existsSync(dir)) return [];
|
|
2376
|
-
return readdirSync(dir).filter((f) => f.endsWith(".json")).map((f) => f.slice(0, -5)).sort();
|
|
2377
|
-
}
|
|
2378
|
-
/** draft names stored for a workflow module (fs read — pair with DraftsSt.version for reactivity) */
|
|
2379
|
-
function listDraftsForFile(file) {
|
|
2380
|
-
return listDraftsInDir(draftsDirForFile(file));
|
|
2381
|
-
}
|
|
2382
|
-
/**
|
|
2383
|
-
* named var-value snapshots at `.comfy-ts/drafts/<module-basename>/<name>.json`
|
|
2384
|
-
* (LOCAL state, gitignored). The active draft autosaves debounced; the TUI is
|
|
2385
|
-
* ALWAYS in a draft (`default` unless another one is activated).
|
|
2386
|
-
*/
|
|
2387
|
-
var DraftsSt = class {
|
|
2388
|
-
constructor(st) {
|
|
2389
|
-
this.st = st;
|
|
2390
|
-
this.active = null;
|
|
2391
|
-
this.list = [];
|
|
2392
|
-
this.ix = 0;
|
|
2393
|
-
this.version = 0;
|
|
2394
|
-
makeAutoObservable(this, { st: false });
|
|
2395
|
-
this.st.disposers.push(reaction(() => this.active == null ? null : JSON.stringify(this.snapshot()), (json) => {
|
|
2396
|
-
if (json != null && this.active != null) this.write(this.active, json);
|
|
2397
|
-
}, { delay: 300 }));
|
|
2398
|
-
}
|
|
2399
|
-
get dir() {
|
|
2400
|
-
const cur = this.st.workflows.currentPath;
|
|
2401
|
-
return cur != null ? draftsDirForFile(cur) : comfyts.resolveFromDrafts(this.st.wf.spec.id ?? "workflow");
|
|
2402
|
-
}
|
|
2403
|
-
snapshot() {
|
|
2404
|
-
return Object.fromEntries(this.st.entries.map(([k, varDef]) => [k, varDef.toJSON()]));
|
|
2405
|
-
}
|
|
2406
|
-
write(name, json) {
|
|
2407
|
-
const path = join(this.dir, `${name}.json`);
|
|
2408
|
-
mkdirSync(dirname(path), { recursive: true });
|
|
2409
|
-
writeFileSync(path, json);
|
|
2410
|
-
this.version++;
|
|
2411
|
-
}
|
|
2412
|
-
/** module key of the currently loaded workflow (settings.lastDraft is keyed by it) */
|
|
2413
|
-
get moduleKey() {
|
|
2414
|
-
const cur = this.st.workflows.currentPath;
|
|
2415
|
-
return cur != null ? draftKeyForFile(cur) : this.st.wf.spec.id ?? "workflow";
|
|
2416
|
-
}
|
|
2417
|
-
/** switch to a draft: load its stored values when the file exists, else it starts from current values */
|
|
2418
|
-
activate(name) {
|
|
2419
|
-
this.active = null;
|
|
2420
|
-
const path = join(this.dir, `${name}.json`);
|
|
2421
|
-
if (existsSync(path)) try {
|
|
2422
|
-
const values = JSON.parse(readFileSync(path, "utf8"));
|
|
2423
|
-
for (const [k, varDef] of this.st.entries) if (k in values) varDef.loadJSON(values[k]);
|
|
2424
|
-
} catch (e) {
|
|
2425
|
-
this.st.exec.error = extractErrorMessage(e);
|
|
2426
|
-
}
|
|
2427
|
-
this.active = name;
|
|
2428
|
-
this.st.settings.rememberDraft(this.moduleKey, name);
|
|
2429
|
-
}
|
|
2430
|
-
/** open the draft this workflow was last in (settings), else 'default' */
|
|
2431
|
-
activateRemembered() {
|
|
2432
|
-
const remembered = this.st.settings.lastDraft[this.moduleKey];
|
|
2433
|
-
if (remembered != null && remembered !== "default" && existsSync(join(this.dir, `${remembered}.json`))) this.activate(remembered);
|
|
2434
|
-
else this.activate("default");
|
|
2435
|
-
}
|
|
2436
|
-
/** every workflow starts in a draft; kept for callers that want 'default' explicitly */
|
|
2437
|
-
activateDefault() {
|
|
2438
|
-
this.activate("default");
|
|
2439
|
-
}
|
|
2440
|
-
dirFor(file) {
|
|
2441
|
-
return file != null ? draftsDirForFile(file) : this.dir;
|
|
2442
|
-
}
|
|
2443
|
-
/** true when ops on `file` touch the ACTIVE draft bookkeeping */
|
|
2444
|
-
isCurrent(file) {
|
|
2445
|
-
return file == null || file === this.st.workflows.currentPath;
|
|
2446
|
-
}
|
|
2447
|
-
validName(rawName) {
|
|
2448
|
-
const name = rawName.trim();
|
|
2449
|
-
if (/^[\w][\w .-]*$/.test(name)) return name;
|
|
2450
|
-
this.st.exec.notice = `invalid draft name: '${rawName}'`;
|
|
2451
|
-
return null;
|
|
2452
|
-
}
|
|
2453
|
-
/** create a NEW draft from the current var values (current workflow only) */
|
|
2454
|
-
createNamed(rawName) {
|
|
2455
|
-
const name = this.validName(rawName);
|
|
2456
|
-
if (name == null) return false;
|
|
2457
|
-
if (existsSync(join(this.dir, `${name}.json`))) {
|
|
2458
|
-
this.st.exec.notice = `draft '${name}' already exists`;
|
|
2459
|
-
return false;
|
|
2460
|
-
}
|
|
2461
|
-
this.write(name, JSON.stringify(this.snapshot(), null, 2));
|
|
2462
|
-
this.active = name;
|
|
2463
|
-
this.st.settings.rememberDraft(this.moduleKey, name);
|
|
2464
|
-
this.st.exec.notice = `new draft: ${name} (autosaves)`;
|
|
2465
|
-
return true;
|
|
2466
|
-
}
|
|
2467
|
-
rename(oldName, rawName, file) {
|
|
2468
|
-
const newName = this.validName(rawName);
|
|
2469
|
-
if (newName == null) return false;
|
|
2470
|
-
if (newName === oldName) return true;
|
|
2471
|
-
const dir = this.dirFor(file);
|
|
2472
|
-
const to = join(dir, `${newName}.json`);
|
|
2473
|
-
if (existsSync(to)) {
|
|
2474
|
-
this.st.exec.notice = `draft '${newName}' already exists`;
|
|
2475
|
-
return false;
|
|
2476
|
-
}
|
|
2477
|
-
const from = join(dir, `${oldName}.json`);
|
|
2478
|
-
if (existsSync(from)) renameSync(from, to);
|
|
2479
|
-
else if (this.isCurrent(file)) this.write(newName, JSON.stringify(this.snapshot(), null, 2));
|
|
2480
|
-
if (this.isCurrent(file) && this.active === oldName) {
|
|
2481
|
-
this.active = newName;
|
|
2482
|
-
this.st.settings.rememberDraft(this.moduleKey, newName);
|
|
2483
|
-
}
|
|
2484
|
-
this.version++;
|
|
2485
|
-
this.st.exec.notice = `draft renamed: ${oldName} → ${newName}`;
|
|
2486
|
-
return true;
|
|
2487
|
-
}
|
|
2488
|
-
duplicate(name, rawName, file) {
|
|
2489
|
-
const newName = this.validName(rawName);
|
|
2490
|
-
if (newName == null) return false;
|
|
2491
|
-
const dir = this.dirFor(file);
|
|
2492
|
-
const from = join(dir, `${name}.json`);
|
|
2493
|
-
const to = join(dir, `${newName}.json`);
|
|
2494
|
-
if (!existsSync(from)) {
|
|
2495
|
-
this.st.exec.notice = `draft '${name}' has no file yet (edit a var first)`;
|
|
2496
|
-
return false;
|
|
2497
|
-
}
|
|
2498
|
-
if (existsSync(to)) {
|
|
2499
|
-
this.st.exec.notice = `draft '${newName}' already exists`;
|
|
2500
|
-
return false;
|
|
2501
|
-
}
|
|
2502
|
-
copyFileSync(from, to);
|
|
2503
|
-
this.version++;
|
|
2504
|
-
this.st.exec.notice = `draft duplicated: ${name} → ${newName}`;
|
|
2505
|
-
return true;
|
|
2506
|
-
}
|
|
2507
|
-
deleteDraft(name, file) {
|
|
2508
|
-
const path = join(this.dirFor(file), `${name}.json`);
|
|
2509
|
-
if (existsSync(path)) rmSync(path);
|
|
2510
|
-
this.version++;
|
|
2511
|
-
if (this.isCurrent(file) && this.active === name) this.activateDefault();
|
|
2512
|
-
this.st.exec.notice = `draft deleted: ${name}`;
|
|
2513
|
-
}
|
|
2514
|
-
promptNew(returnMode = "nav") {
|
|
2515
|
-
this.st.editor.beginCustom({
|
|
2516
|
-
title: "new draft (from current values)",
|
|
2517
|
-
initial: "",
|
|
2518
|
-
onCommit: (raw) => {
|
|
2519
|
-
const ok = this.createNamed(raw);
|
|
2520
|
-
if (ok && returnMode === "overlay-drafts") this.begin();
|
|
2521
|
-
return ok;
|
|
2522
|
-
},
|
|
2523
|
-
returnMode
|
|
2524
|
-
});
|
|
2525
|
-
}
|
|
2526
|
-
promptRename(name, file, returnMode = "nav") {
|
|
2527
|
-
this.st.editor.beginCustom({
|
|
2528
|
-
title: `rename draft '${name}'`,
|
|
2529
|
-
initial: name,
|
|
2530
|
-
onCommit: (raw) => {
|
|
2531
|
-
const ok = this.rename(name, raw, file);
|
|
2532
|
-
if (ok && returnMode === "overlay-drafts") this.begin();
|
|
2533
|
-
return ok;
|
|
2534
|
-
},
|
|
2535
|
-
returnMode
|
|
2536
|
-
});
|
|
2537
|
-
}
|
|
2538
|
-
promptDuplicate(name, file, returnMode = "nav") {
|
|
2539
|
-
this.st.editor.beginCustom({
|
|
2540
|
-
title: `duplicate draft '${name}'`,
|
|
2541
|
-
initial: `${name}-copy`,
|
|
2542
|
-
onCommit: (raw) => {
|
|
2543
|
-
const ok = this.duplicate(name, raw, file);
|
|
2544
|
-
if (ok && returnMode === "overlay-drafts") this.begin();
|
|
2545
|
-
return ok;
|
|
2546
|
-
},
|
|
2547
|
-
returnMode
|
|
2548
|
-
});
|
|
2549
|
-
}
|
|
2550
|
-
/** f2 in nav: rename the ACTIVE draft */
|
|
2551
|
-
beginRename() {
|
|
2552
|
-
this.promptRename(this.active ?? "default");
|
|
2553
|
-
}
|
|
2554
|
-
begin() {
|
|
2555
|
-
this.list = listDraftsInDir(this.dir);
|
|
2556
|
-
this.st.mode = "overlay-drafts";
|
|
2557
|
-
const ix = this.active == null ? -1 : this.list.indexOf(this.active);
|
|
2558
|
-
this.ix = ix === -1 ? 0 : ix + 1;
|
|
2559
|
-
}
|
|
2560
|
-
move(delta) {
|
|
2561
|
-
const len = this.list.length + 1;
|
|
2562
|
-
this.ix = (this.ix + delta + len) % len;
|
|
2563
|
-
}
|
|
2564
|
-
/** draft name under the overlay cursor (row 0 is 'new') */
|
|
2565
|
-
get selectedName() {
|
|
2566
|
-
return this.ix === 0 ? null : this.list[this.ix - 1] ?? null;
|
|
2567
|
-
}
|
|
2568
|
-
commit() {
|
|
2569
|
-
if (this.ix === 0) return this.promptNew("overlay-drafts");
|
|
2570
|
-
const name = this.selectedName;
|
|
2571
|
-
if (name == null) return;
|
|
2572
|
-
this.activate(name);
|
|
2573
|
-
this.st.exec.notice = `draft: ${name} (autosaves)`;
|
|
2574
|
-
this.st.mode = "nav";
|
|
2575
2234
|
}
|
|
2235
|
+
if (sel < p.budget - 1) return {
|
|
2236
|
+
start: 0,
|
|
2237
|
+
end: p.budget - 1,
|
|
2238
|
+
moreAbove: false,
|
|
2239
|
+
moreBelow: true
|
|
2240
|
+
};
|
|
2241
|
+
if (sel >= p.count - (p.budget - 1)) return {
|
|
2242
|
+
start: p.count - (p.budget - 1),
|
|
2243
|
+
end: p.count,
|
|
2244
|
+
moreAbove: true,
|
|
2245
|
+
moreBelow: false
|
|
2246
|
+
};
|
|
2247
|
+
const visible = p.budget - 2;
|
|
2248
|
+
const start = Math.max(1, Math.min(sel - Math.floor(visible / 2), p.count - visible - 1));
|
|
2249
|
+
return {
|
|
2250
|
+
start,
|
|
2251
|
+
end: start + visible,
|
|
2252
|
+
moreAbove: true,
|
|
2253
|
+
moreBelow: true
|
|
2254
|
+
};
|
|
2576
2255
|
};
|
|
2577
2256
|
//#endregion
|
|
2578
2257
|
//#region src/cli/tui/state/EditorSt.ts
|
|
@@ -2829,6 +2508,43 @@ var EditorSt = class EditorSt {
|
|
|
2829
2508
|
}
|
|
2830
2509
|
};
|
|
2831
2510
|
//#endregion
|
|
2511
|
+
//#region src/cli/tui/imageClipboard.ts
|
|
2512
|
+
const extOf = (path) => {
|
|
2513
|
+
const dot = path.lastIndexOf(".");
|
|
2514
|
+
return dot === -1 ? "" : path.slice(dot + 1).toLowerCase();
|
|
2515
|
+
};
|
|
2516
|
+
const imageClipboardCommand = (platform, path) => {
|
|
2517
|
+
const ext = extOf(path);
|
|
2518
|
+
if (platform === "darwin") {
|
|
2519
|
+
if (ext !== "png" && ext !== "jpg" && ext !== "jpeg") return null;
|
|
2520
|
+
const cls = ext === "png" ? "«class PNGf»" : "JPEG picture";
|
|
2521
|
+
return {
|
|
2522
|
+
cmd: "osascript",
|
|
2523
|
+
args: ["-e", `set the clipboard to (read (POSIX file ${JSON.stringify(path)}) as ${cls})`]
|
|
2524
|
+
};
|
|
2525
|
+
}
|
|
2526
|
+
if (platform === "win32") return {
|
|
2527
|
+
cmd: "powershell",
|
|
2528
|
+
args: [
|
|
2529
|
+
"-NoProfile",
|
|
2530
|
+
"-Sta",
|
|
2531
|
+
"-Command",
|
|
2532
|
+
`Add-Type -AssemblyName System.Windows.Forms,System.Drawing; $img=[System.Drawing.Image]::FromFile(${`'${path.replaceAll("'", "''")}'`}); [System.Windows.Forms.Clipboard]::SetImage($img); $img.Dispose()`
|
|
2533
|
+
]
|
|
2534
|
+
};
|
|
2535
|
+
return {
|
|
2536
|
+
cmd: "xclip",
|
|
2537
|
+
args: [
|
|
2538
|
+
"-selection",
|
|
2539
|
+
"clipboard",
|
|
2540
|
+
"-t",
|
|
2541
|
+
ext === "jpg" || ext === "jpeg" ? "image/jpeg" : ext === "webp" ? "image/webp" : "image/png",
|
|
2542
|
+
"-i",
|
|
2543
|
+
path
|
|
2544
|
+
]
|
|
2545
|
+
};
|
|
2546
|
+
};
|
|
2547
|
+
//#endregion
|
|
2832
2548
|
//#region src/cli/tui/state/ExecSt.ts
|
|
2833
2549
|
/** popup body: summary + the head of the copied json (proof of WHAT is in the clipboard) */
|
|
2834
2550
|
function jsonHead(text, maxLines) {
|
|
@@ -2961,6 +2677,44 @@ var ExecSt = class {
|
|
|
2961
2677
|
};
|
|
2962
2678
|
this.st.mode = "overlay-copy";
|
|
2963
2679
|
}
|
|
2680
|
+
/** 'i': the LAST generated image's pixels → clipboard (paste anywhere) */
|
|
2681
|
+
async copyLastImage() {
|
|
2682
|
+
const last = this.outputs[this.outputs.length - 1];
|
|
2683
|
+
if (last == null) {
|
|
2684
|
+
this.showCopyPopup("image → clipboard", false, ["no output image yet — r runs the workflow first"]);
|
|
2685
|
+
return;
|
|
2686
|
+
}
|
|
2687
|
+
let file = last;
|
|
2688
|
+
let command = imageClipboardCommand(process.platform, file);
|
|
2689
|
+
if (command == null && process.platform === "darwin") try {
|
|
2690
|
+
const { default: sharp } = await import("sharp");
|
|
2691
|
+
const { tmpdir } = await import("node:os");
|
|
2692
|
+
const { join } = await import("pathe");
|
|
2693
|
+
file = join(tmpdir(), `comfy-ts-clip-${Date.now()}.png`);
|
|
2694
|
+
await sharp(last).png().toFile(file);
|
|
2695
|
+
command = imageClipboardCommand(process.platform, file);
|
|
2696
|
+
} catch (e) {
|
|
2697
|
+
this.showCopyPopup("image → clipboard", false, [`COPY FAILED for ${basename(last)}`, `png transcode failed: ${extractErrorMessage(e)}`]);
|
|
2698
|
+
return;
|
|
2699
|
+
}
|
|
2700
|
+
if (command == null) {
|
|
2701
|
+
this.showCopyPopup("image → clipboard", false, [`no clipboard image tool for ${process.platform}`]);
|
|
2702
|
+
return;
|
|
2703
|
+
}
|
|
2704
|
+
const cmd = command;
|
|
2705
|
+
const ok = await new Promise((resolve) => {
|
|
2706
|
+
const proc = spawn(cmd.cmd, cmd.args, { stdio: "ignore" });
|
|
2707
|
+
proc.on("error", () => resolve(false));
|
|
2708
|
+
proc.on("close", (code) => resolve(code === 0));
|
|
2709
|
+
});
|
|
2710
|
+
runInAction(() => {
|
|
2711
|
+
this.showCopyPopup("image → clipboard", ok, ok ? [
|
|
2712
|
+
`${basename(last)} — paste the pixels anywhere`,
|
|
2713
|
+
"",
|
|
2714
|
+
last
|
|
2715
|
+
] : [`COPY FAILED for ${basename(last)}`, `could not run ${cmd.cmd} — is it installed and allowed ?`]);
|
|
2716
|
+
});
|
|
2717
|
+
}
|
|
2964
2718
|
toClipboard(text) {
|
|
2965
2719
|
const [cmd, ...args] = process.platform === "darwin" ? ["pbcopy"] : process.platform === "win32" ? ["clip"] : [
|
|
2966
2720
|
"xclip",
|
|
@@ -3975,6 +3729,7 @@ var TreeSt = class {
|
|
|
3975
3729
|
this.expandedFiles = /* @__PURE__ */ new Set();
|
|
3976
3730
|
this.filter = "";
|
|
3977
3731
|
this.filtering = false;
|
|
3732
|
+
this.viewH = 0;
|
|
3978
3733
|
this.collapsedDirs = new Set(st.settings.collapsedDirs);
|
|
3979
3734
|
makeAutoObservable(this, { st: false });
|
|
3980
3735
|
}
|
|
@@ -4053,6 +3808,27 @@ var TreeSt = class {
|
|
|
4053
3808
|
const ix = draftIx === -1 ? rows.findIndex((r) => r.kind === "workflow" && r.current) : draftIx;
|
|
4054
3809
|
this.ix = ix === -1 ? 0 : ix;
|
|
4055
3810
|
}
|
|
3811
|
+
setViewH(h) {
|
|
3812
|
+
this.viewH = h;
|
|
3813
|
+
}
|
|
3814
|
+
/** rows available for tree content: measured panel height minus the panel's
|
|
3815
|
+
* own chrome (2 border rows, the filter line when visible, the loading
|
|
3816
|
+
* line). Pre-measure fallback: termRows minus the header+keybar estimate —
|
|
3817
|
+
* one frame only, the measurement replaces it. */
|
|
3818
|
+
get viewBudget() {
|
|
3819
|
+
const h = this.viewH > 0 ? this.viewH : Math.max(5, this.st.termRows - 5);
|
|
3820
|
+
const filterLine = this.filtering || this.filter !== "" ? 1 : 0;
|
|
3821
|
+
const loadingLine = this.st.workflows.loading ? 1 : 0;
|
|
3822
|
+
return Math.max(1, h - 2 - filterLine - loadingLine);
|
|
3823
|
+
}
|
|
3824
|
+
/** the visible slice, selection always inside, markers within the budget */
|
|
3825
|
+
get window() {
|
|
3826
|
+
return listWindow({
|
|
3827
|
+
count: this.rows.length,
|
|
3828
|
+
selected: this.ix,
|
|
3829
|
+
budget: this.viewBudget
|
|
3830
|
+
});
|
|
3831
|
+
}
|
|
4056
3832
|
/** esc/t inside the tree, → on a draft row, `v` anywhere: back to the vars list */
|
|
4057
3833
|
blur() {
|
|
4058
3834
|
this.filtering = false;
|
|
@@ -4279,6 +4055,7 @@ var TuiSt = class {
|
|
|
4279
4055
|
this.onExit = () => {};
|
|
4280
4056
|
this.termCols = process.stdout.columns ?? 80;
|
|
4281
4057
|
this.termRows = (process.stdout.rows ?? 24) - 1;
|
|
4058
|
+
this.varsViewH = 0;
|
|
4282
4059
|
this.wf = wf;
|
|
4283
4060
|
makeAutoObservable(this, {
|
|
4284
4061
|
wf: observable.ref,
|
|
@@ -4351,6 +4128,33 @@ var TuiSt = class {
|
|
|
4351
4128
|
if (len === 0) return;
|
|
4352
4129
|
this.selIx = (this.selIx + delta + len) % len;
|
|
4353
4130
|
}
|
|
4131
|
+
setVarsViewH(h) {
|
|
4132
|
+
this.varsViewH = h;
|
|
4133
|
+
}
|
|
4134
|
+
/** row budget: measured height minus the 2 border rows; pre-measure fallback estimate */
|
|
4135
|
+
get varsBudget() {
|
|
4136
|
+
const h = this.varsViewH > 0 ? this.varsViewH : Math.max(5, this.termRows - 5);
|
|
4137
|
+
return Math.max(1, h - 2);
|
|
4138
|
+
}
|
|
4139
|
+
get varsWindow() {
|
|
4140
|
+
return listWindow({
|
|
4141
|
+
count: this.entries.length,
|
|
4142
|
+
selected: this.selIx,
|
|
4143
|
+
budget: this.varsBudget
|
|
4144
|
+
});
|
|
4145
|
+
}
|
|
4146
|
+
/**
|
|
4147
|
+
* while the list cannot fit, NON-selected rows collapse to one truncated
|
|
4148
|
+
* line (prompt values wrap tall) — rows above the selection then cost one
|
|
4149
|
+
* line each, so the selection can never be pushed off-screen. Reads only
|
|
4150
|
+
* entry count + measured height, never its own rendering: no oscillation.
|
|
4151
|
+
*/
|
|
4152
|
+
get varsCompact() {
|
|
4153
|
+
const w = this.varsWindow;
|
|
4154
|
+
if (w.moreAbove || w.moreBelow) return true;
|
|
4155
|
+
const h = this.varsViewH > 0 ? this.varsViewH : Math.max(5, this.termRows - 5);
|
|
4156
|
+
return this.entries.length + 2 > h;
|
|
4157
|
+
}
|
|
4354
4158
|
/** enter/space on a var: toggle, open an overlay, or inline-edit */
|
|
4355
4159
|
activate() {
|
|
4356
4160
|
const sel = this.selected?.[1];
|
|
@@ -4459,4 +4263,4 @@ async function runTui(args) {
|
|
|
4459
4263
|
//#endregion
|
|
4460
4264
|
export { runTui };
|
|
4461
4265
|
|
|
4462
|
-
//# sourceMappingURL=run-tui-
|
|
4266
|
+
//# sourceMappingURL=run-tui-BtjaOXRh.js.map
|