comfy-ts 1.0.0 → 1.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 +42 -6
- package/dist/{DefinedWorkflow-O3ynII3Y.js → DefinedWorkflow-BYyu5dK9.js} +76 -5
- package/dist/DefinedWorkflow-BYyu5dK9.js.map +1 -0
- package/dist/cli.js +421 -308
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +394 -162
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7426 -353
- package/dist/index.d.ts +7408 -335
- package/dist/index.js +393 -162
- package/dist/index.js.map +1 -1
- package/dist/{run-tui-BFhba_oG.js → run-tui-DZ22HDHI.js} +529 -78
- package/dist/run-tui-DZ22HDHI.js.map +1 -0
- package/examples/02-img2img-upload.cflow.ts +6 -17
- package/examples/05-comfy-cloud.cflow.ts +19 -35
- package/examples/README.md +30 -0
- package/examples/comfy-cloud/ace-step-t2a.cflow.ts +79 -0
- package/examples/comfy-cloud/anima-t2i.cflow.ts +57 -0
- package/examples/comfy-cloud/boogu-i2i.cflow.ts +76 -0
- package/examples/comfy-cloud/capybara-i2i.cflow.ts +85 -0
- package/examples/comfy-cloud/capybara-i2v.cflow.ts +90 -0
- package/examples/comfy-cloud/capybara-t2i.cflow.ts +67 -0
- package/examples/comfy-cloud/chatterbox-t2a.cflow.ts +79 -0
- package/examples/comfy-cloud/chroma-t2i.cflow.ts +62 -0
- package/examples/comfy-cloud/cloudHost.ts +41 -0
- package/examples/comfy-cloud/ernie-t2i.cflow.ts +59 -0
- package/examples/comfy-cloud/firered-i2i.cflow.ts +74 -0
- package/examples/comfy-cloud/flux1-i2i.cflow.ts +76 -0
- package/examples/comfy-cloud/flux1-t2i.cflow.ts +63 -0
- package/examples/comfy-cloud/flux2-i2i.cflow.ts +80 -0
- package/examples/comfy-cloud/flux2-t2i.cflow.ts +57 -0
- package/examples/comfy-cloud/hidream-i2i.cflow.ts +89 -0
- package/examples/comfy-cloud/hidream-t2i.cflow.ts +65 -0
- package/examples/comfy-cloud/hunyuan-video-i2v.cflow.ts +93 -0
- package/examples/comfy-cloud/hunyuan-video-t2v.cflow.ts +74 -0
- package/examples/comfy-cloud/ideogram4-t2i.cflow.ts +80 -0
- package/examples/comfy-cloud/kandinsky5-i2v.cflow.ts +95 -0
- package/examples/comfy-cloud/kandinsky5-t2i.cflow.ts +60 -0
- package/examples/comfy-cloud/kandinsky5-t2v.cflow.ts +78 -0
- package/examples/comfy-cloud/krea2-t2i.cflow.ts +59 -0
- package/examples/comfy-cloud/lens-t2i.cflow.ts +62 -0
- package/examples/comfy-cloud/longcat-i2i.cflow.ts +74 -0
- package/examples/comfy-cloud/longcat-t2i.cflow.ts +65 -0
- package/examples/comfy-cloud/ltxv-i2v.cflow.ts +92 -0
- package/examples/comfy-cloud/ltxv-t2v.cflow.ts +78 -0
- package/examples/comfy-cloud/newbie-t2i.cflow.ts +67 -0
- package/examples/comfy-cloud/omnigen2-i2i.cflow.ts +86 -0
- package/examples/comfy-cloud/omnigen2-t2i.cflow.ts +62 -0
- package/examples/comfy-cloud/ovis-t2i.cflow.ts +56 -0
- package/examples/comfy-cloud/pixeldit-t2i.cflow.ts +63 -0
- package/examples/comfy-cloud/qwen-image-i2i.cflow.ts +69 -0
- package/examples/comfy-cloud/qwen-image-t2i.cflow.ts +55 -0
- package/examples/comfy-cloud/sd35-t2i.cflow.ts +48 -0
- package/examples/comfy-cloud/sdk.d.ts +445 -57
- package/examples/comfy-cloud/sdxl-t2i.cflow.ts +69 -0
- package/examples/comfy-cloud/stable-audio-t2a.cflow.ts +53 -0
- package/examples/comfy-cloud/svd-i2v.cflow.ts +75 -0
- package/examples/comfy-cloud/wan21-i2v.cflow.ts +83 -0
- package/examples/comfy-cloud/wan21-t2v.cflow.ts +64 -0
- package/examples/comfy-cloud/wan22-5b-t2v.cflow.ts +69 -0
- package/examples/comfy-cloud/wan22-i2v.cflow.ts +107 -0
- package/examples/comfy-cloud/wan22-t2v.cflow.ts +98 -0
- package/examples/comfy-cloud/z-image-t2i.cflow.ts +62 -0
- package/examples/images/README.md +18 -0
- package/examples/images/bear_1024x1024.jpg +0 -0
- package/examples/images/deer_768x1344.jpg +0 -0
- package/examples/images/dog_512x512.jpg +0 -0
- package/examples/images/lioness_768x768.jpg +0 -0
- package/examples/images/pug_200x300.jpg +0 -0
- package/examples/images/walrus_1344x768.jpg +0 -0
- package/guide-for-agents.md +7 -1
- package/package.json +15 -4
- package/src/cli/tui/components/PreviewPanel.tsx +9 -8
- package/src/cli/tui/components/StatusBar.tsx +11 -0
- package/src/cli/tui/components/TuiApp.tsx +18 -0
- package/src/cli/tui/discoverWorkflows.ts +7 -41
- package/src/cli/tui/imagePicker/ImagePickerOverlay.tsx +72 -0
- package/src/cli/tui/imagePicker/ImagePickerSt.ts +288 -0
- package/src/cli/tui/imagePicker/fsListing.ts +46 -0
- package/src/cli/tui/imagePicker/pickerPrefs.ts +78 -0
- package/src/cli/tui/run-tui.tsx +2 -1
- package/src/cli/tui/state/LorasSt.ts +14 -36
- package/src/cli/tui/state/PreviewSt.ts +28 -2
- package/src/cli/tui/state/TuiSt.ts +6 -0
- package/src/exampleAssets.ts +56 -0
- package/src/graph/ComfyNode.ts +4 -1
- package/src/index.ts +7 -0
- package/src/manager/ComfyRegistry.ts +37 -9
- package/src/manager/generated/KnownComfyCustomNodeName.ts +23852 -1926
- package/src/manager/generated/KnownComfyPluginTitle.ts +6854 -236
- package/src/manager/generated/KnownComfyPluginURL.ts +3425 -111
- package/src/manager/generated/KnownModel_Base.ts +23 -7
- package/src/manager/generated/KnownModel_FileName.ts +421 -0
- package/src/manager/generated/KnownModel_Name.ts +421 -0
- package/src/manager/generated/KnownModel_SavePath.ts +34 -8
- package/src/manager/generated/KnownModel_Type.ts +18 -14
- package/src/manager/json/alter-list.json +221 -221
- package/src/manager/json/custom-node-list.json +61020 -21946
- package/src/manager/json/extension-node-map.json +81077 -31176
- package/src/manager/json/github-stats.json +29321 -12601
- package/src/manager/json/model-list.json +5935 -4997
- package/src/manager/loaders/parseReport.ts +55 -0
- package/src/manager/loaders/step1_downloadComfyManagerJSONs.ts +15 -49
- package/src/manager/loaders/step2_custom-node-list-loader.ts +38 -83
- package/src/manager/loaders/step3_extension-node-map-loader.ts +36 -142
- package/src/manager/loaders/step4_model-list-loader.ts +25 -36
- package/src/manager/loaders/step5_alter-list-loader.ts +29 -0
- package/src/manager/loaders/step6_github-stats-loader.ts +23 -0
- package/src/manager/script-update-manager.bun.ts +9 -1
- package/src/manager/types/ComfyManagerAlterInfo.ts +13 -0
- package/src/manager/types/ComfyManagerFileModelInfo.ts +7 -3
- package/src/manager/types/ComfyManagerFilePluginContent.ts +6 -9
- package/src/manager/types/ComfyManagerFilePluginList.ts +3 -3
- package/src/manager/types/ComfyManagerGithubStats.ts +9 -0
- package/src/manager/types/ComfyManagerPluginContentMetadata.ts +2 -3
- package/src/manager/types/ComfyManagerPluginInfo.ts +48 -34
- package/src/sdk-generator/ComfySchema.ts +14 -1
- package/src/sdk-generator/comfyui-sdk-codegen.ts +15 -0
- package/src/sdk-generator/inputWidgetKind.ts +17 -0
- package/src/vars/ComfyVars.ts +82 -2
- package/src/vars/DefinedWorkflow.ts +7 -2
- package/dist/DefinedWorkflow-O3ynII3Y.js.map +0 -1
- package/dist/run-tui-BFhba_oG.js.map +0 -1
- package/src/utils/tryExtracting.ts +0 -41
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as setLoraKeyword, c as stripAnsi, i as getLoraKeyword, n as LorasVar, o as extractErrorMessage, r as PromptVar, t as DefinedWorkflow, u as logError } from "./DefinedWorkflow-
|
|
1
|
+
import { a as setLoraKeyword, c as stripAnsi, i as getLoraKeyword, n as LorasVar, o as extractErrorMessage, r as PromptVar, t as DefinedWorkflow, u as logError } from "./DefinedWorkflow-BYyu5dK9.js";
|
|
2
2
|
import { spawn } from "node:child_process";
|
|
3
3
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
4
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
@@ -7,6 +7,7 @@ import { createHash } from "node:crypto";
|
|
|
7
7
|
import { type } from "arktype";
|
|
8
8
|
import sharp from "sharp";
|
|
9
9
|
import { imageMeta } from "image-meta";
|
|
10
|
+
import { homedir } from "node:os";
|
|
10
11
|
import { makeAutoObservable, observable, reaction, runInAction } from "mobx";
|
|
11
12
|
import { Box, Text, render, useApp, useInput, useStdin } from "ink";
|
|
12
13
|
import { observer } from "mobx-react-lite";
|
|
@@ -18,22 +19,43 @@ const COMFY_TS_TUI_ENV = "COMFY_TS_TUI";
|
|
|
18
19
|
/**
|
|
19
20
|
* recursive scan for the workflow-module naming convention. Entries BELOW a
|
|
20
21
|
* node_modules segment are skipped: packaged examples arrive via
|
|
21
|
-
* bundledExamplesDir (symlinked layouts like pnpm would
|
|
22
|
-
* twice, un-deduped, as the user's own files), and
|
|
23
|
-
* shipping *.cflow.ts are not this project's workflows. A
|
|
24
|
-
* ITSELF inside node_modules still works (the filter is
|
|
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).
|
|
25
27
|
*/
|
|
26
28
|
function scanCflowFiles(dir) {
|
|
27
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();
|
|
28
30
|
}
|
|
29
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
|
+
//#region src/exampleAssets.ts
|
|
51
|
+
/**
|
|
30
52
|
* the examples/ folder shipped in the npm tarball, resolved from THIS module's
|
|
31
53
|
* own location (NEVER cwd): walking up to the nearest NAMED package.json finds
|
|
32
|
-
* <pkg>/examples both from a consumer's node_modules/comfy-ts/dist/
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
54
|
+
* <pkg>/examples both from a consumer's node_modules/comfy-ts/dist/ and from
|
|
55
|
+
* this repo's src/. Returns null when the examples are absent (a consumer may
|
|
56
|
+
* prune the folder) or when the nearest named package is not comfy-ts (the lib
|
|
57
|
+
* was inlined into someone else's bundle — its examples are not on disk); no
|
|
58
|
+
* package.json all the way up is a broken install and throws.
|
|
37
59
|
*/
|
|
38
60
|
function bundledExamplesDir(moduleUrl = import.meta.url) {
|
|
39
61
|
let dir = dirname(fileURLToPath(moduleUrl));
|
|
@@ -54,25 +76,7 @@ function bundledExamplesDir(moduleUrl = import.meta.url) {
|
|
|
54
76
|
prev = dir;
|
|
55
77
|
dir = dirname(dir);
|
|
56
78
|
}
|
|
57
|
-
throw new Error(`[comfy-ts
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* PURE merge of the scan with the packaged examples (headless-tested). An
|
|
61
|
-
* explicit target keeps its scope only. Bundled files ALWAYS group under the
|
|
62
|
-
* bundled section, also when the scan already found them (repo dev: ./examples
|
|
63
|
-
* is under cwd) — dedupe relies on the caller passing realpath-normalized
|
|
64
|
-
* strings on both sides.
|
|
65
|
-
*/
|
|
66
|
-
function mergeWorkflowSources(p) {
|
|
67
|
-
if (p.explicitTarget) return {
|
|
68
|
-
files: p.scanned,
|
|
69
|
-
bundled: /* @__PURE__ */ new Set()
|
|
70
|
-
};
|
|
71
|
-
const bundled = new Set(p.bundledFiles);
|
|
72
|
-
return {
|
|
73
|
-
files: [...p.scanned.filter((f) => !bundled.has(f)), ...p.bundledFiles],
|
|
74
|
-
bundled
|
|
75
|
-
};
|
|
79
|
+
throw new Error(`[comfy-ts] no package.json found walking up from ${fileURLToPath(moduleUrl)}`);
|
|
76
80
|
}
|
|
77
81
|
//#endregion
|
|
78
82
|
//#region src/cli/tui/findDefinedWorkflow.ts
|
|
@@ -146,6 +150,7 @@ var PreviewSt = class {
|
|
|
146
150
|
this.latentDims = null;
|
|
147
151
|
this.latentSeenThisRun = false;
|
|
148
152
|
this.lastOutputPath = null;
|
|
153
|
+
this.overlay = null;
|
|
149
154
|
this.menuIx = 0;
|
|
150
155
|
this._busy = false;
|
|
151
156
|
makeAutoObservable(this, { st: false });
|
|
@@ -165,6 +170,15 @@ var PreviewSt = class {
|
|
|
165
170
|
get menuOpen() {
|
|
166
171
|
return this.st.mode === "preview";
|
|
167
172
|
}
|
|
173
|
+
get overlayActive() {
|
|
174
|
+
return this.st.mode === "overlay-loras" || this.st.mode === "overlay-image";
|
|
175
|
+
}
|
|
176
|
+
setOverlayImage(p) {
|
|
177
|
+
this.overlay = p;
|
|
178
|
+
}
|
|
179
|
+
clearOverlayImage() {
|
|
180
|
+
this.overlay = null;
|
|
181
|
+
}
|
|
168
182
|
/** running + latents wanted + sampling well underway + none arrived = server
|
|
169
183
|
* sends none. The ≥20% gate keeps healthy runs from red-flashing: the first
|
|
170
184
|
* progress tick lands a beat before the first preview frame */
|
|
@@ -244,7 +258,7 @@ var PreviewSt = class {
|
|
|
244
258
|
/** what the painter should show RIGHT NOW (native renderer only; mirrors the panel's source) */
|
|
245
259
|
get protocolImage() {
|
|
246
260
|
if (!this.useNative || !this.show || this.menuOpen) return null;
|
|
247
|
-
if (this.
|
|
261
|
+
if (this.overlayActive) return this.overlay?.bytes ?? null;
|
|
248
262
|
if (this.st.exec.running) {
|
|
249
263
|
if (this.duringRun === "latent") return this.latentBytes ?? this.outputBytes;
|
|
250
264
|
return this.outputBytes;
|
|
@@ -254,7 +268,7 @@ var PreviewSt = class {
|
|
|
254
268
|
/** small latent painted over the panel's top-right corner (native + 'latent small' only) */
|
|
255
269
|
get protocolImageCorner() {
|
|
256
270
|
if (!this.useNative || !this.show || this.menuOpen) return null;
|
|
257
|
-
if (this.
|
|
271
|
+
if (this.overlayActive) return null;
|
|
258
272
|
if (this.st.exec.running && this.duringRun === "latent-small") return this.latentBytes;
|
|
259
273
|
return null;
|
|
260
274
|
}
|
|
@@ -545,7 +559,8 @@ const KIND_KEYS = {
|
|
|
545
559
|
toggle: [["⏎/→", "flip"]],
|
|
546
560
|
choice: [["⏎/→", "pick"]],
|
|
547
561
|
size: [["⏎/→", "pick"]],
|
|
548
|
-
loras: [["⏎/→", "select"]]
|
|
562
|
+
loras: [["⏎/→", "select"]],
|
|
563
|
+
image: [["⏎/→", "browse"]]
|
|
549
564
|
};
|
|
550
565
|
/** shown INSIDE the text editor box (TextOverlay footer), not in the keybar */
|
|
551
566
|
const TEXT_EDIT_HINTS = [
|
|
@@ -596,6 +611,16 @@ const MODE_KEYS = {
|
|
|
596
611
|
["⌃N", "none"],
|
|
597
612
|
["esc", "done"]
|
|
598
613
|
],
|
|
614
|
+
"overlay-image": [
|
|
615
|
+
["⏎", "pick / enter dir"],
|
|
616
|
+
["←", "parent"],
|
|
617
|
+
["→", "enter dir"],
|
|
618
|
+
["tab", "pane"],
|
|
619
|
+
["↑↓", "move"],
|
|
620
|
+
["type", "filter"],
|
|
621
|
+
["⌃F", "fav folder"],
|
|
622
|
+
["esc", "cancel"]
|
|
623
|
+
],
|
|
599
624
|
"overlay-drafts": [
|
|
600
625
|
["⏎", "load / new"],
|
|
601
626
|
...DRAFT_OP_HINTS,
|
|
@@ -998,12 +1023,12 @@ const PreviewPanel = observer((p) => {
|
|
|
998
1023
|
})
|
|
999
1024
|
]
|
|
1000
1025
|
});
|
|
1001
|
-
const
|
|
1026
|
+
const overlayMode = pv.overlayActive;
|
|
1002
1027
|
const wantLatent = s.exec.running && pv.duringRun !== "last-output";
|
|
1003
|
-
const showLatent = !
|
|
1004
|
-
const label =
|
|
1005
|
-
const placeholder =
|
|
1006
|
-
const content = pv.useNative ? null :
|
|
1028
|
+
const showLatent = !overlayMode && wantLatent && (pv.latentAnsi != null || pv.latentBytes != null);
|
|
1029
|
+
const label = overlayMode ? pv.overlay?.name ?? (s.mode === "overlay-loras" ? "lora" : "image") : showLatent ? pv.duringRun === "latent-small" ? "latent small" : "latent" : "output";
|
|
1030
|
+
const placeholder = overlayMode ? pv.overlay?.note ?? (s.mode === "overlay-loras" ? "(pick a lora)" : "(pick an image)") : pv.latentsMissing ? "(no latents from the server — launch comfy with --preview-method auto)" : "(no image yet)";
|
|
1031
|
+
const content = pv.useNative ? null : overlayMode ? pv.overlay?.ansi ?? null : showLatent ? pv.latentAnsi ?? pv.outputAnsi : pv.outputAnsi;
|
|
1007
1032
|
const reserveRect = pv.useNative && (pv.protocolImage != null || pv.protocolImageCorner != null);
|
|
1008
1033
|
return /* @__PURE__ */ jsxs(Box, {
|
|
1009
1034
|
borderStyle: "round",
|
|
@@ -1081,6 +1106,430 @@ const PromptOverlay = observer((p) => {
|
|
|
1081
1106
|
});
|
|
1082
1107
|
});
|
|
1083
1108
|
//#endregion
|
|
1109
|
+
//#region src/cli/tui/imagePicker/fsListing.ts
|
|
1110
|
+
/** `name.PNG` matches extensions `['png']` — extensions are lowercase, no dots */
|
|
1111
|
+
function hasImageExtension(name, extensions) {
|
|
1112
|
+
const dot = name.lastIndexOf(".");
|
|
1113
|
+
if (dot <= 0) return false;
|
|
1114
|
+
return extensions.includes(name.slice(dot + 1).toLowerCase());
|
|
1115
|
+
}
|
|
1116
|
+
/**
|
|
1117
|
+
* ONE folder for the picker: dirs first then images, both alphabetical,
|
|
1118
|
+
* dotfiles skipped, images filtered by extension. Symlinks are followed
|
|
1119
|
+
* (a dangling one is skipped). Pure over fs — an unreadable dir THROWS,
|
|
1120
|
+
* the caller surfaces it (never a silent empty listing).
|
|
1121
|
+
*/
|
|
1122
|
+
function listImageDir(dir, extensions) {
|
|
1123
|
+
const dirs = [];
|
|
1124
|
+
const images = [];
|
|
1125
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
1126
|
+
if (entry.name.startsWith(".")) continue;
|
|
1127
|
+
let isDir = entry.isDirectory();
|
|
1128
|
+
let isFile = entry.isFile();
|
|
1129
|
+
if (entry.isSymbolicLink()) try {
|
|
1130
|
+
const target = statSync(join(dir, entry.name));
|
|
1131
|
+
isDir = target.isDirectory();
|
|
1132
|
+
isFile = target.isFile();
|
|
1133
|
+
} catch {
|
|
1134
|
+
continue;
|
|
1135
|
+
}
|
|
1136
|
+
if (isDir) dirs.push(entry.name);
|
|
1137
|
+
else if (isFile && hasImageExtension(entry.name, extensions)) images.push(entry.name);
|
|
1138
|
+
}
|
|
1139
|
+
dirs.sort((a, b) => a.localeCompare(b));
|
|
1140
|
+
images.sort((a, b) => a.localeCompare(b));
|
|
1141
|
+
return {
|
|
1142
|
+
dirs,
|
|
1143
|
+
images
|
|
1144
|
+
};
|
|
1145
|
+
}
|
|
1146
|
+
/** parent for `←` navigation — the fs root is its own parent (never ascends past it) */
|
|
1147
|
+
function parentDir(dir) {
|
|
1148
|
+
return dirname(dir);
|
|
1149
|
+
}
|
|
1150
|
+
/**
|
|
1151
|
+
* image-picker favorites + recents + lastFolder — loraKeywords pattern:
|
|
1152
|
+
* observable, loaded once, written through on every mutation. Human-editable
|
|
1153
|
+
* json at `.comfy-ts/image-picker.json` (hand-tuned data, NOT under cache/ —
|
|
1154
|
+
* survives a cache wipe):
|
|
1155
|
+
* { "favorites": ["/abs/dir"], "recents": ["/abs/img.png"], "lastFolder": "/abs/dir" }
|
|
1156
|
+
* A corrupt file logs loud and starts fresh, never blocks the TUI. The class
|
|
1157
|
+
* takes its file path explicitly so tests round-trip it headless; the TUI
|
|
1158
|
+
* uses the ONE lazy module singleton below.
|
|
1159
|
+
*/
|
|
1160
|
+
var PickerPrefs = class {
|
|
1161
|
+
constructor(path) {
|
|
1162
|
+
this.path = path;
|
|
1163
|
+
this.favorites = [];
|
|
1164
|
+
this.recents = [];
|
|
1165
|
+
this.lastFolder = null;
|
|
1166
|
+
this.load();
|
|
1167
|
+
makeAutoObservable(this);
|
|
1168
|
+
}
|
|
1169
|
+
load() {
|
|
1170
|
+
if (!existsSync(this.path)) return;
|
|
1171
|
+
try {
|
|
1172
|
+
const raw = JSON.parse(readFileSync(this.path, "utf8"));
|
|
1173
|
+
if (raw == null || typeof raw !== "object") throw new Error("not a json object");
|
|
1174
|
+
const o = raw;
|
|
1175
|
+
if (Array.isArray(o.favorites)) this.favorites = o.favorites.filter((f) => typeof f === "string");
|
|
1176
|
+
if (Array.isArray(o.recents)) this.recents = o.recents.filter((r) => typeof r === "string").slice(0, 20);
|
|
1177
|
+
if (typeof o.lastFolder === "string") this.lastFolder = o.lastFolder;
|
|
1178
|
+
} catch (e) {
|
|
1179
|
+
logError(`[imagePicker] unreadable ${this.path} — starting fresh: ${String(e)}`);
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
write() {
|
|
1183
|
+
try {
|
|
1184
|
+
mkdirSync(dirname(this.path), { recursive: true });
|
|
1185
|
+
const json = {
|
|
1186
|
+
favorites: this.favorites,
|
|
1187
|
+
recents: this.recents,
|
|
1188
|
+
lastFolder: this.lastFolder
|
|
1189
|
+
};
|
|
1190
|
+
writeFileSync(this.path, `${JSON.stringify(json, null, 2)}\n`);
|
|
1191
|
+
} catch (e) {
|
|
1192
|
+
logError(`[imagePicker] write failed ${this.path}: ${String(e)}`);
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
isFavorite(dir) {
|
|
1196
|
+
return this.favorites.includes(dir);
|
|
1197
|
+
}
|
|
1198
|
+
toggleFavorite(dir) {
|
|
1199
|
+
this.favorites = this.favorites.includes(dir) ? this.favorites.filter((f) => f !== dir) : [...this.favorites, dir];
|
|
1200
|
+
this.write();
|
|
1201
|
+
}
|
|
1202
|
+
/** a pick records the image (newest first, deduped, capped) AND remembers its folder */
|
|
1203
|
+
recordPick(imagePath) {
|
|
1204
|
+
this.recents = [imagePath, ...this.recents.filter((r) => r !== imagePath)].slice(0, 20);
|
|
1205
|
+
this.lastFolder = dirname(imagePath);
|
|
1206
|
+
this.write();
|
|
1207
|
+
}
|
|
1208
|
+
};
|
|
1209
|
+
let _prefs = null;
|
|
1210
|
+
/** the TUI's store, bound lazily to `.comfy-ts/image-picker.json` (gitignored) */
|
|
1211
|
+
function pickerPrefs() {
|
|
1212
|
+
if (_prefs == null) _prefs = new PickerPrefs(join(comfyts.baseFolder, "image-picker.json"));
|
|
1213
|
+
return _prefs;
|
|
1214
|
+
}
|
|
1215
|
+
//#endregion
|
|
1216
|
+
//#region src/utils/fuzzyMatch.ts
|
|
1217
|
+
/** case-insensitive subsequence match: 'wide' hits '16:9 (Widescreen)' */
|
|
1218
|
+
function fuzzyMatch(needle, hay) {
|
|
1219
|
+
const n = needle.toLowerCase();
|
|
1220
|
+
const h = hay.toLowerCase();
|
|
1221
|
+
let i = 0;
|
|
1222
|
+
for (const ch of h) if (ch === n[i]) i++;
|
|
1223
|
+
return i >= n.length;
|
|
1224
|
+
}
|
|
1225
|
+
//#endregion
|
|
1226
|
+
//#region src/cli/tui/imagePicker/ImagePickerSt.ts
|
|
1227
|
+
const PICKER_PANES = [
|
|
1228
|
+
"browse",
|
|
1229
|
+
"favorites",
|
|
1230
|
+
"recents"
|
|
1231
|
+
];
|
|
1232
|
+
/** `~`-contract $HOME for display (ImageVar.display's convention) */
|
|
1233
|
+
function contractHome(path) {
|
|
1234
|
+
const home = homedir();
|
|
1235
|
+
return path.startsWith(`${home}/`) ? `~${path.slice(home.length)}` : path;
|
|
1236
|
+
}
|
|
1237
|
+
/**
|
|
1238
|
+
* image-picker overlay (mode 'overlay-image'): browse the disk for an image
|
|
1239
|
+
* var, three panes (browse / favorites / recents), filter-as-you-type, the
|
|
1240
|
+
* highlighted image previews into the panel via PreviewSt's overlay slot.
|
|
1241
|
+
*/
|
|
1242
|
+
var ImagePickerSt = class {
|
|
1243
|
+
constructor(st) {
|
|
1244
|
+
this.st = st;
|
|
1245
|
+
this.pane = "browse";
|
|
1246
|
+
this.folder = process.cwd();
|
|
1247
|
+
this.ix = 0;
|
|
1248
|
+
this.filter = "";
|
|
1249
|
+
this._busy = false;
|
|
1250
|
+
makeAutoObservable(this, { st: false });
|
|
1251
|
+
this.st.disposers.push(reaction(() => this.st.mode === "overlay-image" ? this.highlightedImage : null, () => void this.refreshPreview(), { delay: 120 }));
|
|
1252
|
+
}
|
|
1253
|
+
/** kind-narrowing cast sanctioned (agent/coding.md), `kind` is the tag */
|
|
1254
|
+
get selectedVar() {
|
|
1255
|
+
const sel = this.st.selected?.[1];
|
|
1256
|
+
return sel?.kind === "image" ? sel : null;
|
|
1257
|
+
}
|
|
1258
|
+
get folderDisplay() {
|
|
1259
|
+
return contractHome(this.folder);
|
|
1260
|
+
}
|
|
1261
|
+
/** begin() open order: dirname(value) → persisted lastFolder → opts.folder → cwd */
|
|
1262
|
+
initialFolder(iv) {
|
|
1263
|
+
const candidates = [
|
|
1264
|
+
iv.isSet() ? dirname(iv.absPath()) : null,
|
|
1265
|
+
pickerPrefs().lastFolder,
|
|
1266
|
+
iv.opts.folder != null ? resolve(iv.opts.folder) : null
|
|
1267
|
+
];
|
|
1268
|
+
for (const c of candidates) try {
|
|
1269
|
+
if (c != null && statSync(c).isDirectory()) return c;
|
|
1270
|
+
} catch {}
|
|
1271
|
+
return process.cwd();
|
|
1272
|
+
}
|
|
1273
|
+
begin() {
|
|
1274
|
+
const iv = this.selectedVar;
|
|
1275
|
+
if (iv == null) return;
|
|
1276
|
+
this.st.mode = "overlay-image";
|
|
1277
|
+
this.pane = "browse";
|
|
1278
|
+
this.filter = "";
|
|
1279
|
+
this.ix = 0;
|
|
1280
|
+
this.folder = this.initialFolder(iv);
|
|
1281
|
+
this.st.preview.clearOverlayImage();
|
|
1282
|
+
}
|
|
1283
|
+
cancel() {
|
|
1284
|
+
this.st.mode = "nav";
|
|
1285
|
+
}
|
|
1286
|
+
/** every row of the active pane BEFORE the filter, plus the browse-pane
|
|
1287
|
+
* read error (unreadable folder: shown IN the overlay, browsing elsewhere
|
|
1288
|
+
* stays possible). Computed with NO side effects — mobx forbids them. */
|
|
1289
|
+
get paneListing() {
|
|
1290
|
+
if (this.pane === "favorites") return {
|
|
1291
|
+
rows: pickerPrefs().favorites.map((dir) => ({
|
|
1292
|
+
kind: "dir",
|
|
1293
|
+
name: contractHome(dir),
|
|
1294
|
+
path: dir
|
|
1295
|
+
})),
|
|
1296
|
+
error: null
|
|
1297
|
+
};
|
|
1298
|
+
if (this.pane === "recents") return {
|
|
1299
|
+
rows: pickerPrefs().recents.map((img) => ({
|
|
1300
|
+
kind: "image",
|
|
1301
|
+
name: contractHome(img),
|
|
1302
|
+
path: img,
|
|
1303
|
+
missing: !existsSync(img)
|
|
1304
|
+
})),
|
|
1305
|
+
error: null
|
|
1306
|
+
};
|
|
1307
|
+
const iv = this.selectedVar;
|
|
1308
|
+
if (iv == null) return {
|
|
1309
|
+
rows: [],
|
|
1310
|
+
error: null
|
|
1311
|
+
};
|
|
1312
|
+
try {
|
|
1313
|
+
const listing = listImageDir(this.folder, iv.extensions);
|
|
1314
|
+
return {
|
|
1315
|
+
rows: [...listing.dirs.map((d) => ({
|
|
1316
|
+
kind: "dir",
|
|
1317
|
+
name: d,
|
|
1318
|
+
path: resolve(this.folder, d)
|
|
1319
|
+
})), ...listing.images.map((f) => ({
|
|
1320
|
+
kind: "image",
|
|
1321
|
+
name: f,
|
|
1322
|
+
path: resolve(this.folder, f),
|
|
1323
|
+
missing: false
|
|
1324
|
+
}))],
|
|
1325
|
+
error: null
|
|
1326
|
+
};
|
|
1327
|
+
} catch (e) {
|
|
1328
|
+
return {
|
|
1329
|
+
rows: [],
|
|
1330
|
+
error: extractErrorMessage(e)
|
|
1331
|
+
};
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
get listingError() {
|
|
1335
|
+
return this.paneListing.error;
|
|
1336
|
+
}
|
|
1337
|
+
/** what the overlay renders: pane rows surviving the filter */
|
|
1338
|
+
get rows() {
|
|
1339
|
+
const all = this.paneListing.rows;
|
|
1340
|
+
if (this.filter === "") return all;
|
|
1341
|
+
return all.filter((r) => fuzzyMatch(this.filter, r.name));
|
|
1342
|
+
}
|
|
1343
|
+
get current() {
|
|
1344
|
+
return this.rows[this.ix] ?? null;
|
|
1345
|
+
}
|
|
1346
|
+
/** feeds the preview reaction: only a real, present image highlights */
|
|
1347
|
+
get highlightedImage() {
|
|
1348
|
+
const row = this.current;
|
|
1349
|
+
return row?.kind === "image" && !row.missing ? row.path : null;
|
|
1350
|
+
}
|
|
1351
|
+
move(delta) {
|
|
1352
|
+
const len = this.rows.length;
|
|
1353
|
+
if (len === 0) return;
|
|
1354
|
+
this.ix = (this.ix + delta + len) % len;
|
|
1355
|
+
}
|
|
1356
|
+
cyclePane() {
|
|
1357
|
+
const ix = PICKER_PANES.indexOf(this.pane);
|
|
1358
|
+
this.pane = PICKER_PANES[(ix + 1) % PICKER_PANES.length] ?? "browse";
|
|
1359
|
+
this.ix = 0;
|
|
1360
|
+
this.filter = "";
|
|
1361
|
+
}
|
|
1362
|
+
goto(dir) {
|
|
1363
|
+
this.pane = "browse";
|
|
1364
|
+
this.folder = dir;
|
|
1365
|
+
this.ix = 0;
|
|
1366
|
+
this.filter = "";
|
|
1367
|
+
}
|
|
1368
|
+
/** `→`: enter the highlighted dir (browse pane; images select via ⏎ only) */
|
|
1369
|
+
enter() {
|
|
1370
|
+
const row = this.current;
|
|
1371
|
+
if (this.pane === "browse" && row?.kind === "dir") this.goto(row.path);
|
|
1372
|
+
}
|
|
1373
|
+
/** `←`: parent dir (browse pane; the fs root is its own parent) */
|
|
1374
|
+
goParent() {
|
|
1375
|
+
if (this.pane !== "browse") return;
|
|
1376
|
+
const parent = parentDir(this.folder);
|
|
1377
|
+
if (parent !== this.folder) this.goto(parent);
|
|
1378
|
+
}
|
|
1379
|
+
/** ⏎: enter a dir (a favorite jumps browse into it), select an image */
|
|
1380
|
+
commit() {
|
|
1381
|
+
const row = this.current;
|
|
1382
|
+
if (row == null) return;
|
|
1383
|
+
if (row.kind === "dir") return this.goto(row.path);
|
|
1384
|
+
if (row.missing) return;
|
|
1385
|
+
this.select(row.path);
|
|
1386
|
+
}
|
|
1387
|
+
/** the pick: absolute path into the var, recents + lastFolder recorded */
|
|
1388
|
+
select(absPath) {
|
|
1389
|
+
const iv = this.selectedVar;
|
|
1390
|
+
if (iv == null) return;
|
|
1391
|
+
iv.set(absPath);
|
|
1392
|
+
pickerPrefs().recordPick(absPath);
|
|
1393
|
+
this.st.mode = "nav";
|
|
1394
|
+
}
|
|
1395
|
+
/** ⌃F: favorite FOLDERS only — a dir row favorites it, an image row favorites the current folder */
|
|
1396
|
+
toggleFavorite() {
|
|
1397
|
+
const row = this.current;
|
|
1398
|
+
const dir = row == null ? this.pane === "browse" ? this.folder : null : row.kind === "dir" ? row.path : this.pane === "browse" ? this.folder : dirname(row.path);
|
|
1399
|
+
if (dir == null) return;
|
|
1400
|
+
pickerPrefs().toggleFavorite(dir);
|
|
1401
|
+
this.ix = Math.max(0, Math.min(this.ix, this.rows.length - 1));
|
|
1402
|
+
}
|
|
1403
|
+
isFavorite(dir) {
|
|
1404
|
+
return pickerPrefs().isFavorite(dir);
|
|
1405
|
+
}
|
|
1406
|
+
filterInput(chunk) {
|
|
1407
|
+
this.filter += chunk;
|
|
1408
|
+
this.ix = 0;
|
|
1409
|
+
}
|
|
1410
|
+
filterBackspace() {
|
|
1411
|
+
this.filter = this.filter.slice(0, -1);
|
|
1412
|
+
this.ix = 0;
|
|
1413
|
+
}
|
|
1414
|
+
/** ⌥⌫ / ⌃W: drop the last word of the filter */
|
|
1415
|
+
filterDeleteWord() {
|
|
1416
|
+
this.filter = this.filter.replace(/\s*\S+\s*$/, "");
|
|
1417
|
+
this.ix = 0;
|
|
1418
|
+
}
|
|
1419
|
+
async refreshPreview() {
|
|
1420
|
+
if (this.st.mode !== "overlay-image") {
|
|
1421
|
+
if (!this.st.preview.overlayActive) this.st.preview.clearOverlayImage();
|
|
1422
|
+
return;
|
|
1423
|
+
}
|
|
1424
|
+
const path = this.highlightedImage;
|
|
1425
|
+
if (path == null) {
|
|
1426
|
+
this.st.preview.clearOverlayImage();
|
|
1427
|
+
return;
|
|
1428
|
+
}
|
|
1429
|
+
if (this._busy) return;
|
|
1430
|
+
this._busy = true;
|
|
1431
|
+
try {
|
|
1432
|
+
const bytes = new Uint8Array(readFileSync(path));
|
|
1433
|
+
if (this.st.preview.useNative) this.st.preview.setOverlayImage({
|
|
1434
|
+
bytes,
|
|
1435
|
+
ansi: null,
|
|
1436
|
+
name: basename(path),
|
|
1437
|
+
note: null
|
|
1438
|
+
});
|
|
1439
|
+
else {
|
|
1440
|
+
const ansi = await imageBufferToAnsi(bytes, {
|
|
1441
|
+
width: this.st.preview.width,
|
|
1442
|
+
height: this.st.preview.height
|
|
1443
|
+
});
|
|
1444
|
+
this.st.preview.setOverlayImage({
|
|
1445
|
+
bytes: null,
|
|
1446
|
+
ansi,
|
|
1447
|
+
name: basename(path),
|
|
1448
|
+
note: null
|
|
1449
|
+
});
|
|
1450
|
+
}
|
|
1451
|
+
} catch (e) {
|
|
1452
|
+
this.st.preview.setOverlayImage({
|
|
1453
|
+
bytes: null,
|
|
1454
|
+
ansi: null,
|
|
1455
|
+
name: basename(path),
|
|
1456
|
+
note: extractErrorMessage(e)
|
|
1457
|
+
});
|
|
1458
|
+
} finally {
|
|
1459
|
+
this._busy = false;
|
|
1460
|
+
if (this.st.mode === "overlay-image" && this.highlightedImage !== path) this.refreshPreview();
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1463
|
+
};
|
|
1464
|
+
//#endregion
|
|
1465
|
+
//#region src/cli/tui/imagePicker/ImagePickerOverlay.tsx
|
|
1466
|
+
/** modal image browser: three panes (tab), dirs enter, ⏎ picks, ★ = favorite folder */
|
|
1467
|
+
const ImagePickerOverlay = observer((p) => {
|
|
1468
|
+
const s = p.st;
|
|
1469
|
+
const ip = s.imagePicker;
|
|
1470
|
+
const iv = ip.selectedVar;
|
|
1471
|
+
if (iv == null) return null;
|
|
1472
|
+
const rows = ip.rows;
|
|
1473
|
+
return /* @__PURE__ */ jsx(OverlayList, {
|
|
1474
|
+
title: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1475
|
+
s.selected?.[1].label ?? s.selected?.[0],
|
|
1476
|
+
" ",
|
|
1477
|
+
/* @__PURE__ */ jsx(Text, {
|
|
1478
|
+
color: "gray",
|
|
1479
|
+
children: iv.display()
|
|
1480
|
+
})
|
|
1481
|
+
] }),
|
|
1482
|
+
extraHeader: /* @__PURE__ */ jsxs(Box, {
|
|
1483
|
+
flexDirection: "column",
|
|
1484
|
+
children: [/* @__PURE__ */ jsxs(Text, { children: [PICKER_PANES.map((pane, ix) => /* @__PURE__ */ jsxs(Text, { children: [ix > 0 ? /* @__PURE__ */ jsx(Text, {
|
|
1485
|
+
color: "gray",
|
|
1486
|
+
children: " · "
|
|
1487
|
+
}) : null, /* @__PURE__ */ jsx(Text, {
|
|
1488
|
+
color: pane === ip.pane ? "cyan" : "gray",
|
|
1489
|
+
bold: pane === ip.pane,
|
|
1490
|
+
underline: pane === ip.pane,
|
|
1491
|
+
children: pane
|
|
1492
|
+
})] }, pane)), ip.pane === "browse" ? /* @__PURE__ */ jsxs(Text, {
|
|
1493
|
+
color: "gray",
|
|
1494
|
+
children: [" ", ip.folderDisplay]
|
|
1495
|
+
}) : null] }), /* @__PURE__ */ jsxs(Text, {
|
|
1496
|
+
color: "yellow",
|
|
1497
|
+
children: [
|
|
1498
|
+
"filter: ",
|
|
1499
|
+
ip.filter,
|
|
1500
|
+
"▌"
|
|
1501
|
+
]
|
|
1502
|
+
})]
|
|
1503
|
+
}),
|
|
1504
|
+
selectedIx: ip.ix,
|
|
1505
|
+
lines: s.overlayLines,
|
|
1506
|
+
rows: rows.map((row, ix) => {
|
|
1507
|
+
const sel = ix === ip.ix;
|
|
1508
|
+
const fav = row.kind === "dir" && ip.isFavorite(row.path);
|
|
1509
|
+
const missing = row.kind === "image" && row.missing;
|
|
1510
|
+
return {
|
|
1511
|
+
key: `${row.kind}:${row.path}`,
|
|
1512
|
+
node: /* @__PURE__ */ jsxs(Text, {
|
|
1513
|
+
inverse: sel,
|
|
1514
|
+
color: row.kind === "dir" ? "blue" : missing ? "gray" : void 0,
|
|
1515
|
+
dimColor: missing,
|
|
1516
|
+
children: [
|
|
1517
|
+
sel ? "▸ " : " ",
|
|
1518
|
+
fav ? "★ " : " ",
|
|
1519
|
+
row.name,
|
|
1520
|
+
row.kind === "dir" ? "/" : "",
|
|
1521
|
+
missing ? " (missing)" : ""
|
|
1522
|
+
]
|
|
1523
|
+
}, `${row.kind}:${row.path}`)
|
|
1524
|
+
};
|
|
1525
|
+
}),
|
|
1526
|
+
footer: rows.length === 0 ? /* @__PURE__ */ jsx(Text, {
|
|
1527
|
+
color: "red",
|
|
1528
|
+
children: ip.listingError ?? (ip.filter !== "" ? "no match" : "no images here")
|
|
1529
|
+
}) : void 0
|
|
1530
|
+
});
|
|
1531
|
+
});
|
|
1532
|
+
//#endregion
|
|
1084
1533
|
//#region src/cli/tui/components/LogsPanel.tsx
|
|
1085
1534
|
const ERROR_RE = /error|exception|traceback|failed/i;
|
|
1086
1535
|
/** last server console lines (LogsSt), below the vars panel */
|
|
@@ -1456,6 +1905,21 @@ const TuiApp = observer((p) => {
|
|
|
1456
1905
|
if (input && !key.ctrl && !key.meta) return lo.filterInput(input);
|
|
1457
1906
|
return;
|
|
1458
1907
|
}
|
|
1908
|
+
if (s.mode === "overlay-image") {
|
|
1909
|
+
const ip = s.imagePicker;
|
|
1910
|
+
if (key.escape) return ip.cancel();
|
|
1911
|
+
if (key.tab || input === " ") return ip.cyclePane();
|
|
1912
|
+
if (key.ctrl && input === "f") return ip.toggleFavorite();
|
|
1913
|
+
if (key.return) return ip.commit();
|
|
1914
|
+
if (key.upArrow) return ip.move(-1);
|
|
1915
|
+
if (key.downArrow) return ip.move(1);
|
|
1916
|
+
if (key.leftArrow) return ip.goParent();
|
|
1917
|
+
if (key.rightArrow) return ip.enter();
|
|
1918
|
+
if (key.meta && (key.backspace || key.delete) || key.ctrl && input === "w") return ip.filterDeleteWord();
|
|
1919
|
+
if (key.backspace || key.delete) return ip.filterBackspace();
|
|
1920
|
+
if (input && !key.ctrl && !key.meta) return ip.filterInput(input);
|
|
1921
|
+
return;
|
|
1922
|
+
}
|
|
1459
1923
|
if (s.mode === "tree") {
|
|
1460
1924
|
const tr = s.tree;
|
|
1461
1925
|
if (key.escape || input === "t") return tr.blur();
|
|
@@ -1560,7 +2024,7 @@ const TuiApp = observer((p) => {
|
|
|
1560
2024
|
flexDirection: "column",
|
|
1561
2025
|
flexGrow: 1,
|
|
1562
2026
|
children: [
|
|
1563
|
-
s.mode === "edit" && s.editor.isCustom ? /* @__PURE__ */ jsx(PromptOverlay, { st: s }) : s.mode === "host" ? /* @__PURE__ */ jsx(HostPanel, { st: s }) : s.mode === "overlay-text" ? /* @__PURE__ */ jsx(TextOverlay, { st: s }) : s.mode === "overlay-choice" ? /* @__PURE__ */ jsx(ChoiceOverlay, { st: s }) : s.mode === "overlay-size" ? /* @__PURE__ */ jsx(SizeOverlay, { st: s }) : s.mode === "overlay-loras" ? /* @__PURE__ */ jsx(LorasOverlay, { st: s }) : s.mode === "overlay-drafts" ? /* @__PURE__ */ jsx(DraftsOverlay, { st: s }) : /* @__PURE__ */ jsx(VarsPanel, { st: s }),
|
|
2027
|
+
s.mode === "edit" && s.editor.isCustom ? /* @__PURE__ */ jsx(PromptOverlay, { st: s }) : s.mode === "host" ? /* @__PURE__ */ jsx(HostPanel, { st: s }) : s.mode === "overlay-text" ? /* @__PURE__ */ jsx(TextOverlay, { st: s }) : s.mode === "overlay-choice" ? /* @__PURE__ */ jsx(ChoiceOverlay, { st: s }) : s.mode === "overlay-size" ? /* @__PURE__ */ jsx(SizeOverlay, { st: s }) : s.mode === "overlay-loras" ? /* @__PURE__ */ jsx(LorasOverlay, { st: s }) : s.mode === "overlay-image" ? /* @__PURE__ */ jsx(ImagePickerOverlay, { st: s }) : s.mode === "overlay-drafts" ? /* @__PURE__ */ jsx(DraftsOverlay, { st: s }) : /* @__PURE__ */ jsx(VarsPanel, { st: s }),
|
|
1564
2028
|
/* @__PURE__ */ jsx(Box, {
|
|
1565
2029
|
paddingX: 1,
|
|
1566
2030
|
children: /* @__PURE__ */ jsx(ProgressLine, { st: s })
|
|
@@ -2673,16 +3137,6 @@ async function fetchLoraPreviewBytes(host, previewUrl) {
|
|
|
2673
3137
|
}
|
|
2674
3138
|
}
|
|
2675
3139
|
//#endregion
|
|
2676
|
-
//#region src/utils/fuzzyMatch.ts
|
|
2677
|
-
/** case-insensitive subsequence match: 'wide' hits '16:9 (Widescreen)' */
|
|
2678
|
-
function fuzzyMatch(needle, hay) {
|
|
2679
|
-
const n = needle.toLowerCase();
|
|
2680
|
-
const h = hay.toLowerCase();
|
|
2681
|
-
let i = 0;
|
|
2682
|
-
for (const ch of h) if (ch === n[i]) i++;
|
|
2683
|
-
return i >= n.length;
|
|
2684
|
-
}
|
|
2685
|
-
//#endregion
|
|
2686
3140
|
//#region src/cli/tui/state/LorasSt.ts
|
|
2687
3141
|
/** loras overlay: fuzzy filter + tick/untick + strengths + bulk ops + lora-manager preview */
|
|
2688
3142
|
var LorasSt = class {
|
|
@@ -2690,10 +3144,6 @@ var LorasSt = class {
|
|
|
2690
3144
|
this.st = st;
|
|
2691
3145
|
this.ix = 0;
|
|
2692
3146
|
this.filter = "";
|
|
2693
|
-
this.previewAnsi = null;
|
|
2694
|
-
this.previewBytes = null;
|
|
2695
|
-
this.previewName = null;
|
|
2696
|
-
this.previewNote = null;
|
|
2697
3147
|
this.previewMap = void 0;
|
|
2698
3148
|
this.previewMapHostId = null;
|
|
2699
3149
|
this._busy = false;
|
|
@@ -2717,6 +3167,7 @@ var LorasSt = class {
|
|
|
2717
3167
|
this.st.mode = "overlay-loras";
|
|
2718
3168
|
this.ix = 0;
|
|
2719
3169
|
this.filter = "";
|
|
3170
|
+
this.st.preview.clearOverlayImage();
|
|
2720
3171
|
}
|
|
2721
3172
|
move(delta) {
|
|
2722
3173
|
const len = this.filteredNames.length;
|
|
@@ -2769,14 +3220,10 @@ var LorasSt = class {
|
|
|
2769
3220
|
get selectedName() {
|
|
2770
3221
|
return this.filteredNames[this.ix] ?? null;
|
|
2771
3222
|
}
|
|
3223
|
+
/** preview goes through PreviewSt's shared overlay slot (one code path with the image picker) */
|
|
2772
3224
|
async refreshPreview() {
|
|
2773
3225
|
if (this.st.mode !== "overlay-loras") {
|
|
2774
|
-
|
|
2775
|
-
this.previewAnsi = null;
|
|
2776
|
-
this.previewBytes = null;
|
|
2777
|
-
this.previewName = null;
|
|
2778
|
-
this.previewNote = null;
|
|
2779
|
-
});
|
|
3226
|
+
if (!this.st.preview.overlayActive) this.st.preview.clearOverlayImage();
|
|
2780
3227
|
return;
|
|
2781
3228
|
}
|
|
2782
3229
|
const name = this.selectedName;
|
|
@@ -2792,22 +3239,22 @@ var LorasSt = class {
|
|
|
2792
3239
|
const url = map?.get(loraPreviewKey(name));
|
|
2793
3240
|
const note = map == null ? "lora-manager extension not detected" : url == null ? "no preview available" : null;
|
|
2794
3241
|
if (url == null) {
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
3242
|
+
this.st.preview.setOverlayImage({
|
|
3243
|
+
bytes: null,
|
|
3244
|
+
ansi: null,
|
|
3245
|
+
name: `lora ${name}`,
|
|
3246
|
+
note
|
|
2800
3247
|
});
|
|
2801
3248
|
return;
|
|
2802
3249
|
}
|
|
2803
3250
|
const bytes = await fetchLoraPreviewBytes(host, url);
|
|
2804
3251
|
if (bytes == null) throw new Error("no image preview on the server");
|
|
2805
3252
|
if (this.st.preview.useNative) {
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
3253
|
+
this.st.preview.setOverlayImage({
|
|
3254
|
+
bytes,
|
|
3255
|
+
ansi: null,
|
|
3256
|
+
name: `lora ${name}`,
|
|
3257
|
+
note: null
|
|
2811
3258
|
});
|
|
2812
3259
|
return;
|
|
2813
3260
|
}
|
|
@@ -2815,17 +3262,18 @@ var LorasSt = class {
|
|
|
2815
3262
|
width: this.st.preview.width,
|
|
2816
3263
|
height: this.st.preview.height
|
|
2817
3264
|
});
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
3265
|
+
this.st.preview.setOverlayImage({
|
|
3266
|
+
bytes: null,
|
|
3267
|
+
ansi,
|
|
3268
|
+
name: `lora ${name}`,
|
|
3269
|
+
note: null
|
|
2822
3270
|
});
|
|
2823
3271
|
} catch (e) {
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
3272
|
+
this.st.preview.setOverlayImage({
|
|
3273
|
+
bytes: null,
|
|
3274
|
+
ansi: null,
|
|
3275
|
+
name: `lora ${name}`,
|
|
3276
|
+
note: extractErrorMessage(e)
|
|
2829
3277
|
});
|
|
2830
3278
|
} finally {
|
|
2831
3279
|
this._busy = false;
|
|
@@ -3268,6 +3716,7 @@ var TuiSt = class {
|
|
|
3268
3716
|
editor: false,
|
|
3269
3717
|
picker: false,
|
|
3270
3718
|
loras: false,
|
|
3719
|
+
imagePicker: false,
|
|
3271
3720
|
workflows: false,
|
|
3272
3721
|
tree: false,
|
|
3273
3722
|
drafts: false,
|
|
@@ -3282,6 +3731,7 @@ var TuiSt = class {
|
|
|
3282
3731
|
this.editor = new EditorSt(this);
|
|
3283
3732
|
this.picker = new PickerSt(this);
|
|
3284
3733
|
this.loras = new LorasSt(this);
|
|
3734
|
+
this.imagePicker = new ImagePickerSt(this);
|
|
3285
3735
|
this.workflows = new WorkflowsSt(this, opts.workflowFiles ?? [], opts.currentFile ?? null, opts.bundledFiles, opts.loadErrors);
|
|
3286
3736
|
this.tree = new TreeSt(this);
|
|
3287
3737
|
this.drafts = new DraftsSt(this);
|
|
@@ -3334,6 +3784,7 @@ var TuiSt = class {
|
|
|
3334
3784
|
else if (sel.kind === "choice") this.picker.beginChoice();
|
|
3335
3785
|
else if (sel.kind === "size") this.picker.beginSize();
|
|
3336
3786
|
else if (sel.kind === "loras") this.loras.begin();
|
|
3787
|
+
else if (sel.kind === "image") this.imagePicker.begin();
|
|
3337
3788
|
else this.editor.beginInline();
|
|
3338
3789
|
}
|
|
3339
3790
|
/** kind-specific nav keys (documented in the keybar): seed `+`/`-`/`=`/`?` mode, `*` reroll */
|
|
@@ -3416,4 +3867,4 @@ async function runTui(args) {
|
|
|
3416
3867
|
//#endregion
|
|
3417
3868
|
export { runTui };
|
|
3418
3869
|
|
|
3419
|
-
//# sourceMappingURL=run-tui-
|
|
3870
|
+
//# sourceMappingURL=run-tui-DZ22HDHI.js.map
|