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
package/dist/index.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import fs, { existsSync, mkdirSync, readFileSync, statSync, writeFile, writeFileSync } from "node:fs";
|
|
2
|
-
import { basename, dirname, join } from "pathe";
|
|
2
|
+
import { basename, dirname, isAbsolute, join, resolve } from "pathe";
|
|
3
3
|
import { scope, type } from "arktype";
|
|
4
4
|
import { nanoid } from "nanoid";
|
|
5
5
|
import sharp from "sharp";
|
|
6
6
|
import { imageMeta } from "image-meta";
|
|
7
7
|
import crypto from "node:crypto";
|
|
8
8
|
import WebSocket from "ws";
|
|
9
|
+
import { homedir } from "node:os";
|
|
9
10
|
import { action, makeObservable, observable, runInAction } from "mobx";
|
|
10
11
|
import https from "node:https";
|
|
11
12
|
import { stdout } from "node:process";
|
|
12
|
-
import {
|
|
13
|
+
import { fileURLToPath } from "node:url";
|
|
13
14
|
//#region package.json
|
|
14
|
-
var version = "1.
|
|
15
|
+
var version = "1.1.0";
|
|
15
16
|
//#endregion
|
|
16
17
|
//#region src/litegraph/LiteGraphLinkID.ts
|
|
17
18
|
const asLiteGraphLinkID = (id) => id;
|
|
@@ -710,6 +711,21 @@ const parseContainer = (template) => {
|
|
|
710
711
|
requiredCount: isRecord(input) && isRecord(input["required"]) && Object.keys(input["required"]).length > 0 ? Math.min(min, names.length) : 0
|
|
711
712
|
};
|
|
712
713
|
};
|
|
714
|
+
/**
|
|
715
|
+
* the single template sub-input's slot type of an autogrow container
|
|
716
|
+
* (`'IMAGE'` for TextEncodeBooguEdit.images). null when opts are not an
|
|
717
|
+
* autogrow template or the template has several sub-inputs (corpus-absent
|
|
718
|
+
* 2026-07-30, 27/27 single on the cloud catalog) — then codegen emits no
|
|
719
|
+
* typed instance keys and the container stays builderBase territory.
|
|
720
|
+
*/
|
|
721
|
+
const containerInstanceSlotType = (opts) => {
|
|
722
|
+
const template = (isRecord(opts) ? opts : null)?.["template"];
|
|
723
|
+
if (!isRecord(template) || !isRecord(template["input"])) return null;
|
|
724
|
+
const subs = flattenInputSections(template["input"]);
|
|
725
|
+
const first = subs[0];
|
|
726
|
+
if (subs.length !== 1 || first == null || typeof first.type !== "string") return null;
|
|
727
|
+
return first.type;
|
|
728
|
+
};
|
|
713
729
|
const classifyWidgetInput = (p) => {
|
|
714
730
|
const o = isRecord(p.opts) ? p.opts : null;
|
|
715
731
|
if (o?.["forceInput"] === true) return { kind: "slot" };
|
|
@@ -1222,7 +1238,7 @@ var ComfyNode = class ComfyNode {
|
|
|
1222
1238
|
for (const i of this.$schema.inputs) {
|
|
1223
1239
|
_done.add(i.nameInComfy);
|
|
1224
1240
|
const value = this.serializeValue(i.nameInComfy, promptExt.inputs[i.nameInComfy]);
|
|
1225
|
-
inputs[i.nameInComfy] = value;
|
|
1241
|
+
if (value !== void 0) inputs[i.nameInComfy] = value;
|
|
1226
1242
|
}
|
|
1227
1243
|
for (const [nameInComfy, rawVal] of Object.entries(promptExt.inputs)) {
|
|
1228
1244
|
if (_done.has(nameInComfy)) continue;
|
|
@@ -2596,6 +2612,15 @@ function codegenSDK(opts) {
|
|
|
2596
2612
|
for (const n of nodes) {
|
|
2597
2613
|
p(`${escapeJSKey(n.nodeKey)}: {`);
|
|
2598
2614
|
for (const i of n.inputs) {
|
|
2615
|
+
const kind = classifySchemaInput(i);
|
|
2616
|
+
if (kind.kind === "dynamic-container") {
|
|
2617
|
+
const instType = containerInstanceSlotType(i.opts);
|
|
2618
|
+
if (instType != null) kind.instanceNames.forEach((instName, ix) => {
|
|
2619
|
+
const opt = ix >= kind.requiredCount ? "?" : "";
|
|
2620
|
+
p(` ${escapeJSKey(`${i.nameInComfy}.${instName}`)}${opt}: Accepts[${JSON.stringify(instType)}]`);
|
|
2621
|
+
});
|
|
2622
|
+
continue;
|
|
2623
|
+
}
|
|
2599
2624
|
const opts_ = typeof i.opts === "string" ? null : i.opts;
|
|
2600
2625
|
let type = `Accepts[${JSON.stringify(i.typeName)}]`;
|
|
2601
2626
|
const comboOptions = i.typeName === "COMBO" && Array.isArray(opts_?.options) ? opts_.options.filter((o) => typeof o === "string" || typeof o === "number" || typeof o === "boolean") : [];
|
|
@@ -2915,9 +2940,18 @@ var ComfySchema = class {
|
|
|
2915
2940
|
comfyUnionDef: slotType
|
|
2916
2941
|
}).unionName);
|
|
2917
2942
|
else throw new Error(`invalid schema (${JSON.stringify(slotType)}) for input "${ipt.name}" in node "${nodeNameInComfy}" (type: ${typeof slotType}; expected: Array | string)`);
|
|
2943
|
+
const isAutogrowContainer = typeof slotType === "string" && classifyWidgetInput({
|
|
2944
|
+
name: ipt.name,
|
|
2945
|
+
type: slotType,
|
|
2946
|
+
opts: slotOpts
|
|
2947
|
+
}).kind === "dynamic-container";
|
|
2948
|
+
if (isAutogrowContainer) {
|
|
2949
|
+
const instType = containerInstanceSlotType(slotOpts);
|
|
2950
|
+
if (instType != null) this.knownSlotTypes.add(asComfyNodeSlotTypeName(instType));
|
|
2951
|
+
}
|
|
2918
2952
|
node.inputs.push({
|
|
2919
2953
|
slotName: inputSlotName,
|
|
2920
|
-
required: ipt.required,
|
|
2954
|
+
required: ipt.required && !isAutogrowContainer,
|
|
2921
2955
|
nameInComfy: inputNameInComfy,
|
|
2922
2956
|
nameInComfyEscaped: escapeJSKey(inputNameInComfy),
|
|
2923
2957
|
typeName: inputTypeName,
|
|
@@ -3917,7 +3951,73 @@ var SizeVar = class extends ComfyVar {
|
|
|
3917
3951
|
return `${width}×${height}${hit ? ` (${hit.label})` : ""}`;
|
|
3918
3952
|
}
|
|
3919
3953
|
};
|
|
3920
|
-
|
|
3954
|
+
const DEFAULT_IMAGE_EXTENSIONS = [
|
|
3955
|
+
"png",
|
|
3956
|
+
"jpg",
|
|
3957
|
+
"jpeg",
|
|
3958
|
+
"webp",
|
|
3959
|
+
"gif"
|
|
3960
|
+
];
|
|
3961
|
+
/** empty image var consumed at build time — typed so drivers surface it apart from real crashes */
|
|
3962
|
+
var ImageVarEmptyError = class extends Error {
|
|
3963
|
+
constructor(varName) {
|
|
3964
|
+
super(`image var '${varName}' is empty — pick a file (TUI: activate the var; script: .set('/path/to/image.png'))`);
|
|
3965
|
+
this.varName = varName;
|
|
3966
|
+
}
|
|
3967
|
+
};
|
|
3968
|
+
/** trim + expand a leading `~/` — every ImageVar write funnels through this */
|
|
3969
|
+
function expandUserPath(raw) {
|
|
3970
|
+
const trimmed = raw.trim();
|
|
3971
|
+
return trimmed.startsWith("~/") ? join(homedir(), trimmed.slice(2)) : trimmed;
|
|
3972
|
+
}
|
|
3973
|
+
/**
|
|
3974
|
+
* a local image path. The VALUE is a PLAIN PATH STRING — text-encodable,
|
|
3975
|
+
* drafts persist it verbatim (toJSON = the string), hand-editable in the
|
|
3976
|
+
* draft json. Empty = unset: outValue()/absPath() throw ImageVarEmptyError,
|
|
3977
|
+
* so a build never runs on a silent placeholder. The TUI opens the image
|
|
3978
|
+
* picker overlay for kind 'image'.
|
|
3979
|
+
*/
|
|
3980
|
+
var ImageVar = class extends ComfyVar {
|
|
3981
|
+
constructor(defaultValue, opts = {}) {
|
|
3982
|
+
super(expandUserPath(defaultValue), opts.label);
|
|
3983
|
+
this.opts = opts;
|
|
3984
|
+
this.kind = "image";
|
|
3985
|
+
}
|
|
3986
|
+
/** what the picker lists (lowercase, no dots) */
|
|
3987
|
+
get extensions() {
|
|
3988
|
+
return this.opts.extensions ?? DEFAULT_IMAGE_EXTENSIONS;
|
|
3989
|
+
}
|
|
3990
|
+
set(value) {
|
|
3991
|
+
return super.set(expandUserPath(value));
|
|
3992
|
+
}
|
|
3993
|
+
parse(raw) {
|
|
3994
|
+
this.set(raw);
|
|
3995
|
+
return true;
|
|
3996
|
+
}
|
|
3997
|
+
isSet() {
|
|
3998
|
+
return this.value !== "";
|
|
3999
|
+
}
|
|
4000
|
+
emptyError() {
|
|
4001
|
+
return new ImageVarEmptyError(this.name ?? this.label ?? "image");
|
|
4002
|
+
}
|
|
4003
|
+
/** the ONE resolution helper: absolute kept as-is, relative resolved against opts.folder, else cwd */
|
|
4004
|
+
absPath() {
|
|
4005
|
+
if (!this.isSet()) throw this.emptyError();
|
|
4006
|
+
if (isAbsolute(this.value)) return this.value;
|
|
4007
|
+
return resolve(this.opts.folder ?? process.cwd(), this.value);
|
|
4008
|
+
}
|
|
4009
|
+
/** empty = unset: the build fails LOUD here (varValues calls outValue) */
|
|
4010
|
+
outValue() {
|
|
4011
|
+
if (!this.isSet()) throw this.emptyError();
|
|
4012
|
+
return this.value;
|
|
4013
|
+
}
|
|
4014
|
+
display() {
|
|
4015
|
+
if (!this.isSet()) return "(unset) pick a file";
|
|
4016
|
+
const home = homedir();
|
|
4017
|
+
return this.value.startsWith(`${home}/`) ? `~${this.value.slice(home.length)}` : this.value;
|
|
4018
|
+
}
|
|
4019
|
+
};
|
|
4020
|
+
/** the var constructors: v.text / v.prompt / v.int / v.float / v.seed / v.toggle / v.choice / v.loras / v.size / v.image */
|
|
3921
4021
|
const v = {
|
|
3922
4022
|
text: (defaultValue, label) => new TextVar(defaultValue, label),
|
|
3923
4023
|
prompt: (defaultValue, opts = {}) => new PromptVar(defaultValue, opts),
|
|
@@ -3927,7 +4027,8 @@ const v = {
|
|
|
3927
4027
|
toggle: (defaultValue, label) => new ToggleVar(defaultValue, label),
|
|
3928
4028
|
choice: (choices, defaultValue, label) => new ChoiceVar(choices, defaultValue, label),
|
|
3929
4029
|
loras: (options, initial = {}, label) => new LorasVar(options, initial, label),
|
|
3930
|
-
size: (defaultValue, opts = {}) => new SizeVar(defaultValue, opts.presets, opts.label)
|
|
4030
|
+
size: (defaultValue, opts = {}) => new SizeVar(defaultValue, opts.presets, opts.label),
|
|
4031
|
+
image: (defaultValue, opts = {}) => new ImageVar(defaultValue, opts)
|
|
3931
4032
|
};
|
|
3932
4033
|
function varValues(vars) {
|
|
3933
4034
|
const out = {};
|
|
@@ -3951,7 +4052,10 @@ var DefinedWorkflow = class {
|
|
|
3951
4052
|
this.lastWorkflow = null;
|
|
3952
4053
|
this.lastExecution = null;
|
|
3953
4054
|
this.vars = isVarsThunk(spec.vars) ? spec.vars(v) : spec.vars;
|
|
3954
|
-
for (const [, varDef] of this.entries())
|
|
4055
|
+
for (const [key, varDef] of this.entries()) {
|
|
4056
|
+
varDef.name = key;
|
|
4057
|
+
varDef.bindHost?.(this.host);
|
|
4058
|
+
}
|
|
3955
4059
|
}
|
|
3956
4060
|
/** [name, var] pairs, for drivers that enumerate the knobs */
|
|
3957
4061
|
entries() {
|
|
@@ -4509,31 +4613,19 @@ function downloadFile(url, outputPath, logPrefix = " - ") {
|
|
|
4509
4613
|
}
|
|
4510
4614
|
//#endregion
|
|
4511
4615
|
//#region src/manager/loaders/step1_downloadComfyManagerJSONs.ts
|
|
4616
|
+
const MANAGER_RAW_BASE = "https://raw.githubusercontent.com/Comfy-Org/ComfyUI-Manager/main";
|
|
4617
|
+
const MANAGER_MIRROR_FILES = [
|
|
4618
|
+
"custom-node-list.json",
|
|
4619
|
+
"model-list.json",
|
|
4620
|
+
"extension-node-map.json",
|
|
4621
|
+
"alter-list.json",
|
|
4622
|
+
"github-stats.json"
|
|
4623
|
+
];
|
|
4512
4624
|
async function DownloadComfyManagerJSONs() {
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
await SYNC_githubStats();
|
|
4518
|
-
async function SYNC_modelList() {
|
|
4519
|
-
await downloadFile("https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/model-list.json", "src/manager/json/model-list.json", `- downloading ynchronizing model-list.json...`);
|
|
4520
|
-
console.log(` saved at ${ansi.blue("src/manager/json/model-list.json")}`);
|
|
4521
|
-
}
|
|
4522
|
-
async function SYNC_customNodeList() {
|
|
4523
|
-
await downloadFile("https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/custom-node-list.json", "src/manager/json/custom-node-list.json", `- downloading synchronizing custom-node-list.json...`);
|
|
4524
|
-
console.log(` saved at ${ansi.blue("src/manager/json/custom-node-list.json")}`);
|
|
4525
|
-
}
|
|
4526
|
-
async function SYNC_extensionNodeMap() {
|
|
4527
|
-
await downloadFile("https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/extension-node-map.json", "src/manager/json/extension-node-map.json", `- downloading synchronizing extension-node-map.json...`);
|
|
4528
|
-
console.log(` saved at ${ansi.blue("src/manager/json/extension-node-map.json")}`);
|
|
4529
|
-
}
|
|
4530
|
-
async function SYNC_alterList() {
|
|
4531
|
-
await downloadFile("https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/alter-list.json", "src/manager/json/alter-list.json", `- downloading synchronizing alter-list.json...`);
|
|
4532
|
-
console.log(` saved at ${ansi.blue("src/manager/json/alter-list.json")}`);
|
|
4533
|
-
}
|
|
4534
|
-
async function SYNC_githubStats() {
|
|
4535
|
-
await downloadFile("https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/refs/heads/main/github-stats.json", "src/manager/json/github-stats.json", `- downloading ynchronizing githubStats.json...`);
|
|
4536
|
-
console.log(` saved at ${ansi.blue("src/manager/json/github-stats.json")}`);
|
|
4625
|
+
for (const file of MANAGER_MIRROR_FILES) {
|
|
4626
|
+
const dest = `src/manager/json/${file}`;
|
|
4627
|
+
await downloadFile(`${MANAGER_RAW_BASE}/${file}`, dest, `- downloading ${file}...`);
|
|
4628
|
+
console.log(` saved at ${ansi.blue(dest)}`);
|
|
4537
4629
|
}
|
|
4538
4630
|
}
|
|
4539
4631
|
//#endregion
|
|
@@ -4541,24 +4633,6 @@ async function DownloadComfyManagerJSONs() {
|
|
|
4541
4633
|
const githubRegexpV1 = /https:\/\/github.com\/(.+?)\/(.+?)\/?/;
|
|
4542
4634
|
const githubRegexpV2 = /https:\/\/github.com\/(.+?)\/([a-zA-Z0-9-_]+)?/;
|
|
4543
4635
|
//#endregion
|
|
4544
|
-
//#region src/utils/tryExtracting.ts
|
|
4545
|
-
function tryRecovering({ verbose = 0, property, hacks, onFail, onSuccess }) {
|
|
4546
|
-
if (verbose >= 2) console.log(`[🔶] trying to find a suitable value for ${property}...`);
|
|
4547
|
-
for (const hack of hacks) {
|
|
4548
|
-
if (verbose >= 2) console.log(` > trying to use ${hack.attempt}...`);
|
|
4549
|
-
const value = hack.fn();
|
|
4550
|
-
if (value != null) {
|
|
4551
|
-
if (verbose >= (hack.level ?? 1)) {
|
|
4552
|
-
if (verbose) console.log(` 🔶 recovered ${property} using ${hack.attempt}.`);
|
|
4553
|
-
}
|
|
4554
|
-
onSuccess?.(property, value);
|
|
4555
|
-
return value;
|
|
4556
|
-
}
|
|
4557
|
-
}
|
|
4558
|
-
onFail?.(property);
|
|
4559
|
-
throw new Error(`[🔶] ${property} could not be recovered`);
|
|
4560
|
-
}
|
|
4561
|
-
//#endregion
|
|
4562
4636
|
//#region src/manager/json/custom-node-list.extra.ts
|
|
4563
4637
|
const ComfyPluginExtra = [{
|
|
4564
4638
|
id: "TEMP_ComfyUI-BRIA_AI-RMBG",
|
|
@@ -4570,43 +4644,111 @@ const ComfyPluginExtra = [{
|
|
|
4570
4644
|
description: "better rembg ?"
|
|
4571
4645
|
}];
|
|
4572
4646
|
//#endregion
|
|
4647
|
+
//#region src/manager/loaders/parseReport.ts
|
|
4648
|
+
/** root shape of a manager mirror file is broken: nothing to salvage, fail loud */
|
|
4649
|
+
var ManagerParseError = class extends Error {
|
|
4650
|
+
constructor(file, detail) {
|
|
4651
|
+
super(`🔴 [manager] ${file} root shape invalid: ${detail}`);
|
|
4652
|
+
this.file = file;
|
|
4653
|
+
this.detail = detail;
|
|
4654
|
+
this.name = "ManagerParseError";
|
|
4655
|
+
}
|
|
4656
|
+
};
|
|
4657
|
+
var FileParseCounter = class {
|
|
4658
|
+
constructor(file) {
|
|
4659
|
+
this.file = file;
|
|
4660
|
+
this.total = 0;
|
|
4661
|
+
this.accepted = 0;
|
|
4662
|
+
this.skipped = /* @__PURE__ */ new Map();
|
|
4663
|
+
}
|
|
4664
|
+
ok() {
|
|
4665
|
+
this.total++;
|
|
4666
|
+
this.accepted++;
|
|
4667
|
+
}
|
|
4668
|
+
skip(reason, firstError) {
|
|
4669
|
+
this.total++;
|
|
4670
|
+
const prev = this.skipped.get(reason);
|
|
4671
|
+
if (prev == null) this.skipped.set(reason, {
|
|
4672
|
+
count: 1,
|
|
4673
|
+
firstError
|
|
4674
|
+
});
|
|
4675
|
+
else prev.count++;
|
|
4676
|
+
}
|
|
4677
|
+
};
|
|
4678
|
+
/** per-file row accounting for the manager mirror parse; printed on every registry build so upstream drift stays visible */
|
|
4679
|
+
var ManagerParseReport = class {
|
|
4680
|
+
constructor() {
|
|
4681
|
+
this.counters = [];
|
|
4682
|
+
}
|
|
4683
|
+
file(name) {
|
|
4684
|
+
const counter = new FileParseCounter(name);
|
|
4685
|
+
this.counters.push(counter);
|
|
4686
|
+
return counter;
|
|
4687
|
+
}
|
|
4688
|
+
print() {
|
|
4689
|
+
console.log(ansi.bold(`[📘 registry] parse report:`));
|
|
4690
|
+
for (const c of this.counters) {
|
|
4691
|
+
const skippedTotal = [...c.skipped.values()].reduce((acc, cur) => acc + cur.count, 0);
|
|
4692
|
+
const headline = ` ${c.file}: ${c.total} rows, ${c.accepted} accepted, ${skippedTotal} skipped`;
|
|
4693
|
+
console.log(skippedTotal === 0 ? headline : ansi.red(headline));
|
|
4694
|
+
for (const [reason, info] of c.skipped) console.log(ansi.red(` - ${reason} x${info.count}, first: ${info.firstError}`));
|
|
4695
|
+
}
|
|
4696
|
+
}
|
|
4697
|
+
};
|
|
4698
|
+
//#endregion
|
|
4573
4699
|
//#region src/manager/types/ComfyManagerFilePluginList.ts
|
|
4574
|
-
const
|
|
4700
|
+
const ComfyManagerFilePluginListRoot_ark = type({ custom_nodes: "unknown[]" });
|
|
4701
|
+
//#endregion
|
|
4702
|
+
//#region src/manager/types/ComfyManagerPluginInfo.ts
|
|
4703
|
+
const ComfyManagerRawPluginInfo_ark = type({
|
|
4575
4704
|
author: "string",
|
|
4576
4705
|
title: type.string.as(),
|
|
4577
4706
|
reference: "string",
|
|
4578
4707
|
files: type.string.as().array(),
|
|
4579
4708
|
install_type: "string",
|
|
4580
4709
|
description: "string",
|
|
4581
|
-
id: type.string.as(),
|
|
4710
|
+
"id?": type.string.as(),
|
|
4582
4711
|
"preemptions?": "string[]",
|
|
4583
4712
|
"pip?": "string[]",
|
|
4584
4713
|
"nodename_pattern?": "string",
|
|
4585
4714
|
"apt_dependency?": "string[]",
|
|
4586
4715
|
"js_path?": "string",
|
|
4587
4716
|
"version?": "string",
|
|
4588
|
-
"tags?": "string[]"
|
|
4589
|
-
|
|
4717
|
+
"tags?": "string[]",
|
|
4718
|
+
"reference2?": "string",
|
|
4719
|
+
"category?": "string",
|
|
4720
|
+
"name?": "string",
|
|
4721
|
+
"license?": "string",
|
|
4722
|
+
"nickname?": "string",
|
|
4723
|
+
"stars?": "number",
|
|
4724
|
+
"last_update?": "string",
|
|
4725
|
+
"badges?": "string[]",
|
|
4726
|
+
"dependencies?": "string[]"
|
|
4727
|
+
});
|
|
4590
4728
|
//#endregion
|
|
4591
4729
|
//#region src/manager/loaders/step2_custom-node-list-loader.ts
|
|
4592
4730
|
const _getKnownPlugins = (DB) => {
|
|
4731
|
+
const counter = DB.report.file("custom-node-list.json");
|
|
4593
4732
|
let totalFileSeen = 0;
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
const
|
|
4597
|
-
for (const
|
|
4598
|
-
|
|
4599
|
-
plugin.title ??= tryRecoveringPluginTitle(plugin, 1);
|
|
4600
|
-
}
|
|
4601
|
-
const res = ComfyManagerFilePluginList_ark(knownPluginFile);
|
|
4602
|
-
if (DB.opts.check) {
|
|
4733
|
+
const root = ComfyManagerFilePluginListRoot_ark(JSON.parse(readFileSync("src/manager/json/custom-node-list.json", "utf8")));
|
|
4734
|
+
if (root instanceof type.errors) throw new ManagerParseError("custom-node-list.json", root.summary);
|
|
4735
|
+
const canonical = [];
|
|
4736
|
+
for (const row of root.custom_nodes) {
|
|
4737
|
+
const res = ComfyManagerRawPluginInfo_ark(row);
|
|
4603
4738
|
if (res instanceof type.errors) {
|
|
4604
|
-
|
|
4605
|
-
|
|
4739
|
+
counter.skip("schema", res.summary);
|
|
4740
|
+
continue;
|
|
4741
|
+
}
|
|
4742
|
+
const plugin = normalizePluginInfo(res);
|
|
4743
|
+
if (plugin == null) {
|
|
4744
|
+
counter.skip("id-unrecoverable", res.reference);
|
|
4745
|
+
continue;
|
|
4606
4746
|
}
|
|
4747
|
+
canonical.push(plugin);
|
|
4748
|
+
counter.ok();
|
|
4607
4749
|
}
|
|
4750
|
+
const knownPluginList = canonical.concat(ComfyPluginExtra);
|
|
4608
4751
|
for (const plugin of knownPluginList) {
|
|
4609
|
-
totalPluginSeen++;
|
|
4610
4752
|
if (DB.opts.check && DB.plugins_byTitle.has(plugin.title)) console.log(` ❌ plugin.title: "${plugin.title}" is duplicated`);
|
|
4611
4753
|
DB.plugins_byTitle.set(plugin.title, plugin);
|
|
4612
4754
|
for (const pluginURI of plugin.files) {
|
|
@@ -4617,7 +4759,7 @@ const _getKnownPlugins = (DB) => {
|
|
|
4617
4759
|
}
|
|
4618
4760
|
if (DB.opts.genTypes) {
|
|
4619
4761
|
let out1 = "";
|
|
4620
|
-
const allPluginsSortedByTitles = [...DB.plugins_byTitle.values()].sort((a, b) =>
|
|
4762
|
+
const allPluginsSortedByTitles = [...DB.plugins_byTitle.values()].sort((a, b) => a.title.toLowerCase().localeCompare(b.title.toLowerCase()));
|
|
4621
4763
|
out1 += "// prettier-ignore\n";
|
|
4622
4764
|
out1 += "export type KnownComfyPluginTitle =\n";
|
|
4623
4765
|
for (const plugin of allPluginsSortedByTitles) {
|
|
@@ -4626,7 +4768,7 @@ const _getKnownPlugins = (DB) => {
|
|
|
4626
4768
|
}
|
|
4627
4769
|
out1 += "\n";
|
|
4628
4770
|
const out1Path = "src/manager/generated/KnownComfyPluginTitle.ts";
|
|
4629
|
-
writeFileSync
|
|
4771
|
+
writeFileSync(out1Path, out1 + "\n", "utf-8");
|
|
4630
4772
|
console.log(` > generated: ${ansi.blue.underline(out1Path)}`);
|
|
4631
4773
|
let out2 = "";
|
|
4632
4774
|
const sortedFileNames = [...DB.plugins_byFile.keys()].sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
|
|
@@ -4634,47 +4776,33 @@ const _getKnownPlugins = (DB) => {
|
|
|
4634
4776
|
out2 += "export type KnownComfyPluginURL =\n";
|
|
4635
4777
|
for (const fileName of sortedFileNames) out2 += ` | ${JSON.stringify(fileName)}\n`;
|
|
4636
4778
|
const out2Path = "src/manager/generated/KnownComfyPluginURL.ts";
|
|
4637
|
-
writeFileSync
|
|
4779
|
+
writeFileSync(out2Path, out2, "utf-8");
|
|
4638
4780
|
console.log(` > generated: ${ansi.blue.underline(out2Path)}`);
|
|
4639
4781
|
}
|
|
4640
4782
|
if (DB.opts.check) {
|
|
4641
|
-
console.log(` - ${
|
|
4783
|
+
console.log(` - ${knownPluginList.length} CustomNodes in file`);
|
|
4642
4784
|
console.log(` - ${DB.plugins_byTitle.size} CustomNodes registered in map`);
|
|
4643
4785
|
console.log(` - ${totalFileSeen} CustomNodes-File Seen`);
|
|
4644
4786
|
console.log(` - ${DB.plugins_byFile.size} CustomNodes-File registered in map`);
|
|
4645
4787
|
}
|
|
4646
4788
|
};
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
}
|
|
4659
|
-
}
|
|
4660
|
-
function tryRecoveringPluginId(plugin, verbose = 0) {
|
|
4661
|
-
return tryRecovering({
|
|
4662
|
-
property: "plugin.id",
|
|
4663
|
-
verbose,
|
|
4664
|
-
hacks: [{
|
|
4665
|
-
level: 2,
|
|
4666
|
-
attempt: "title",
|
|
4667
|
-
fn: () => plugin.title
|
|
4668
|
-
}, {
|
|
4669
|
-
attempt: "github repo name",
|
|
4670
|
-
fn: () => plugin.reference.match(githubRegexpV1)?.[2]
|
|
4671
|
-
}]
|
|
4672
|
-
});
|
|
4789
|
+
/**
|
|
4790
|
+
* raw → canonical: recover the missing `id` (absent on ~76% of upstream rows)
|
|
4791
|
+
* from the title, else the github repo name. null = unrecoverable, caller
|
|
4792
|
+
* reports and skips the row.
|
|
4793
|
+
*/
|
|
4794
|
+
function normalizePluginInfo(p) {
|
|
4795
|
+
const id = p.id ?? p.title ?? p.reference.match(githubRegexpV1)?.[2];
|
|
4796
|
+
if (id == null) return null;
|
|
4797
|
+
return {
|
|
4798
|
+
...p,
|
|
4799
|
+
id
|
|
4800
|
+
};
|
|
4673
4801
|
}
|
|
4674
4802
|
//#endregion
|
|
4675
4803
|
//#region src/manager/types/ComfyManagerPluginContentMetadata.ts
|
|
4676
4804
|
const ComfyManagerPluginContentMetadata_ark = type({
|
|
4677
|
-
title_aux: type.string.or(type.null),
|
|
4805
|
+
"title_aux?": type.string.or(type.null),
|
|
4678
4806
|
"author?": "string",
|
|
4679
4807
|
"nickname?": "string",
|
|
4680
4808
|
"description?": "string",
|
|
@@ -4688,42 +4816,37 @@ const ComfyManagerPluginContentNodeName_ark = type.string.as();
|
|
|
4688
4816
|
type("string");
|
|
4689
4817
|
//#endregion
|
|
4690
4818
|
//#region src/manager/types/ComfyManagerFilePluginContent.ts
|
|
4691
|
-
const
|
|
4819
|
+
const ComfyManagerExtensionNodeMapEntry_ark = type([ComfyManagerPluginContentNodeName_ark.array(), ComfyManagerPluginContentMetadata_ark]);
|
|
4692
4820
|
//#endregion
|
|
4693
4821
|
//#region src/manager/loaders/step3_extension-node-map-loader.ts
|
|
4694
4822
|
const _getCustomNodeRegistry = (DB) => {
|
|
4823
|
+
const counter = DB.report.file("extension-node-map.json");
|
|
4695
4824
|
let totalCustomNodeSeen = 0;
|
|
4696
|
-
const
|
|
4697
|
-
const
|
|
4698
|
-
if (
|
|
4825
|
+
const raw = JSON.parse(readFileSync("src/manager/json/extension-node-map.json", "utf8"));
|
|
4826
|
+
const root = type("Record<string, unknown>")(raw);
|
|
4827
|
+
if (root instanceof type.errors) throw new ManagerParseError("extension-node-map.json", root.summary);
|
|
4828
|
+
for (const [url, value] of Object.entries(root)) {
|
|
4829
|
+
const res = ComfyManagerExtensionNodeMapEntry_ark(value);
|
|
4699
4830
|
if (res instanceof type.errors) {
|
|
4700
|
-
|
|
4701
|
-
|
|
4831
|
+
counter.skip("schema", `${url}: ${res.summary}`);
|
|
4832
|
+
continue;
|
|
4702
4833
|
}
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
meta,
|
|
4713
|
-
plugin: confyPlugin,
|
|
4714
|
-
pythonModule: reverseEngineerWhatComfyWillSendAsPythonModuleValueOnceInstalled(confyPlugin, url, meta)
|
|
4715
|
-
};
|
|
4716
|
-
});
|
|
4717
|
-
for (const enmEntry of enmEntries) {
|
|
4718
|
-
totalCustomNodeSeen += enmEntry.comfyNodeNames.length;
|
|
4719
|
-
const plugin = enmEntry.plugin;
|
|
4834
|
+
const plugin = DB.plugins_byFile.get(url);
|
|
4835
|
+
if (plugin == null) {
|
|
4836
|
+
counter.skip("unknown-plugin-url", url);
|
|
4837
|
+
continue;
|
|
4838
|
+
}
|
|
4839
|
+
counter.ok();
|
|
4840
|
+
const comfyNodeNames = res[0];
|
|
4841
|
+
totalCustomNodeSeen += comfyNodeNames.length;
|
|
4842
|
+
const pythonModule = reverseEngineerWhatComfyWillSendAsPythonModuleValueOnceInstalled(plugin);
|
|
4720
4843
|
const nodesInPlugin = DB.customNodes_byPluginName.get(plugin.title) ?? [];
|
|
4721
4844
|
DB.customNodes_byPluginName.set(plugin.title, nodesInPlugin);
|
|
4722
|
-
for (const nodeNameInComfy of
|
|
4723
|
-
const nodeKey = toQualifiedNodeKey(
|
|
4724
|
-
const
|
|
4725
|
-
if (
|
|
4726
|
-
else
|
|
4845
|
+
for (const nodeNameInComfy of comfyNodeNames) {
|
|
4846
|
+
const nodeKey = toQualifiedNodeKey(pythonModule, nodeNameInComfy);
|
|
4847
|
+
const prevEntry = DB.plugins_byNodeKey.get(nodeKey);
|
|
4848
|
+
if (prevEntry == null) DB.plugins_byNodeKey.set(nodeKey, [plugin]);
|
|
4849
|
+
else prevEntry.push(plugin);
|
|
4727
4850
|
nodesInPlugin.push(nodeKey);
|
|
4728
4851
|
}
|
|
4729
4852
|
}
|
|
@@ -4732,23 +4855,22 @@ const _getCustomNodeRegistry = (DB) => {
|
|
|
4732
4855
|
const sortedNodeKeys = [...DB.plugins_byNodeKey.keys()].sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
|
|
4733
4856
|
out += "// prettier-ignore\n";
|
|
4734
4857
|
out += "export type KnownComfyCustomNodeName =\n";
|
|
4735
|
-
for (const nodeName of sortedNodeKeys) {
|
|
4736
|
-
if (nodeName === "sd_perturbed_attention.PerturbedAttention") console.log(`[🤠] 🔴`, DB.plugins_byNodeKey.get(nodeName));
|
|
4737
|
-
out += ` | ${JSON.stringify(nodeName)}\n`;
|
|
4738
|
-
}
|
|
4858
|
+
for (const nodeName of sortedNodeKeys) out += ` | ${JSON.stringify(nodeName)}\n`;
|
|
4739
4859
|
out += "\n";
|
|
4740
4860
|
const outPath = "src/manager/generated/KnownComfyCustomNodeName.ts";
|
|
4741
4861
|
writeFileSync(outPath, out + "\n", "utf-8");
|
|
4742
4862
|
console.log(` > generated: ${ansi.blue.underline(outPath)}`);
|
|
4743
4863
|
}
|
|
4744
|
-
if (DB.opts.check)
|
|
4864
|
+
if (DB.opts.check) {
|
|
4865
|
+
console.log(` - ${totalCustomNodeSeen} CustomNodes names processed`);
|
|
4866
|
+
console.log(` - ${DB.plugins_byNodeKey.size} unique node keys registered in map`);
|
|
4867
|
+
}
|
|
4745
4868
|
};
|
|
4746
|
-
function reverseEngineerWhatComfyWillSendAsPythonModuleValueOnceInstalled(plugin
|
|
4869
|
+
function reverseEngineerWhatComfyWillSendAsPythonModuleValueOnceInstalled(plugin) {
|
|
4747
4870
|
if (plugin.id === "nodes" && plugin.reference === "https://github.com/comfyanonymous/ComfyUI") return "nodes";
|
|
4748
4871
|
const repoName = plugin.reference.match(githubRegexpV2)?.[2];
|
|
4749
4872
|
if (repoName) return `custom_nodes.${repoName}`;
|
|
4750
|
-
|
|
4751
|
-
return "🔴";
|
|
4873
|
+
return `custom_nodes.${plugin.id}`;
|
|
4752
4874
|
}
|
|
4753
4875
|
//#endregion
|
|
4754
4876
|
//#region src/manager/json/model-list.extra.ts
|
|
@@ -4772,6 +4894,9 @@ const extraModels = { models: [{
|
|
|
4772
4894
|
url: "https://huggingface.co/gemasai/4x_NMKD-Siax_200k/resolve/main/4xRealWebPhoto_v4_dat2.pth"
|
|
4773
4895
|
}] };
|
|
4774
4896
|
//#endregion
|
|
4897
|
+
//#region src/manager/types/ComfyManagerFileModelInfo.ts
|
|
4898
|
+
const ComfyManagerFileModelInfoRoot_ark = type({ models: "unknown[]" });
|
|
4899
|
+
//#endregion
|
|
4775
4900
|
//#region src/manager/types/ComfyManagerModelInfo.ts
|
|
4776
4901
|
const ComfyManagerModelInfo_ark = type({
|
|
4777
4902
|
name: type.string.as(),
|
|
@@ -4787,20 +4912,21 @@ const ComfyManagerModelInfo_ark = type({
|
|
|
4787
4912
|
//#endregion
|
|
4788
4913
|
//#region src/manager/loaders/step4_model-list-loader.ts
|
|
4789
4914
|
const _getKnownModels = (DB) => {
|
|
4790
|
-
const
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
printArkResultInConsole(errors);
|
|
4800
|
-
hasErrors = true;
|
|
4801
|
-
}
|
|
4915
|
+
const counter = DB.report.file("model-list.json");
|
|
4916
|
+
const root = ComfyManagerFileModelInfoRoot_ark(JSON.parse(readFileSync("src/manager/json/model-list.json", "utf8")));
|
|
4917
|
+
if (root instanceof type.errors) throw new ManagerParseError("model-list.json", root.summary);
|
|
4918
|
+
const canonical = [];
|
|
4919
|
+
for (const row of root.models) {
|
|
4920
|
+
const res = ComfyManagerModelInfo_ark(row);
|
|
4921
|
+
if (res instanceof type.errors) {
|
|
4922
|
+
counter.skip("schema", res.summary);
|
|
4923
|
+
continue;
|
|
4802
4924
|
}
|
|
4925
|
+
canonical.push(res);
|
|
4926
|
+
counter.ok();
|
|
4803
4927
|
}
|
|
4928
|
+
const knownModelList = canonical.concat(extraModels.models);
|
|
4929
|
+
for (const modelInfo of knownModelList) DB.knownModels.set(modelInfo.name, modelInfo);
|
|
4804
4930
|
if (DB.opts.genTypes) {
|
|
4805
4931
|
let out1 = "";
|
|
4806
4932
|
const uniqCategories = knownModelList.reduce((acc, cur) => {
|
|
@@ -4816,7 +4942,7 @@ const _getKnownModels = (DB) => {
|
|
|
4816
4942
|
for (const [cat, count] of Object.entries(uniqCategories)) out1 += ` ${JSON.stringify(cat).padEnd(20)}, // x ${count.toString().padStart(3)}\n`;
|
|
4817
4943
|
out1 += "]\n";
|
|
4818
4944
|
const out1Path = "src/manager/generated/KnownModel_Type.ts";
|
|
4819
|
-
writeFileSync
|
|
4945
|
+
writeFileSync(out1Path, out1 + "\n", "utf-8");
|
|
4820
4946
|
console.log(` > generated: ${ansi.blue.underline(out1Path)}`);
|
|
4821
4947
|
let out4 = "";
|
|
4822
4948
|
const uniqSavePath = knownModelList.reduce((acc, cur) => {
|
|
@@ -4832,7 +4958,7 @@ const _getKnownModels = (DB) => {
|
|
|
4832
4958
|
for (const [cat, count] of Object.entries(uniqSavePath)) out4 += ` ${JSON.stringify(cat).padEnd(50)}, // x ${count.toString().padStart(3)}\n`;
|
|
4833
4959
|
out4 += "]\n";
|
|
4834
4960
|
const out4Path = "src/manager/generated/KnownModel_SavePath.ts";
|
|
4835
|
-
writeFileSync
|
|
4961
|
+
writeFileSync(out4Path, out4 + "\n", "utf-8");
|
|
4836
4962
|
console.log(` > generated: ${ansi.blue.underline(out4Path)}`);
|
|
4837
4963
|
let out2 = "";
|
|
4838
4964
|
const uniqBases = knownModelList.reduce((acc, cur) => {
|
|
@@ -4849,7 +4975,7 @@ const _getKnownModels = (DB) => {
|
|
|
4849
4975
|
for (const [cat, count] of Object.entries(uniqBases)) out2 += ` ${JSON.stringify(cat).padEnd(20)}, // x ${count.toString().padStart(3)}\n`;
|
|
4850
4976
|
out2 += "]\n";
|
|
4851
4977
|
const out2Path = "src/manager/generated/KnownModel_Base.ts";
|
|
4852
|
-
writeFileSync
|
|
4978
|
+
writeFileSync(out2Path, out2 + "\n", "utf-8");
|
|
4853
4979
|
console.log(` > generated: ${ansi.blue.underline(out2Path)}`);
|
|
4854
4980
|
let out3 = "";
|
|
4855
4981
|
const sortedModels = knownModelList.sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase()));
|
|
@@ -4864,7 +4990,7 @@ const _getKnownModels = (DB) => {
|
|
|
4864
4990
|
}
|
|
4865
4991
|
out3 += "\n";
|
|
4866
4992
|
const out3Path = "src/manager/generated/KnownModel_Name.ts";
|
|
4867
|
-
writeFileSync
|
|
4993
|
+
writeFileSync(out3Path, out3 + "\n", "utf-8");
|
|
4868
4994
|
console.log(` > generated: ${ansi.blue.underline(out3Path)}`);
|
|
4869
4995
|
let out99 = "";
|
|
4870
4996
|
out99 += `// prettier-ignore\n`;
|
|
@@ -4878,20 +5004,78 @@ const _getKnownModels = (DB) => {
|
|
|
4878
5004
|
}
|
|
4879
5005
|
out99 += "\n";
|
|
4880
5006
|
const out99Path = "src/manager/generated/KnownModel_FileName.ts";
|
|
4881
|
-
writeFileSync
|
|
5007
|
+
writeFileSync(out99Path, out99 + "\n", "utf-8");
|
|
4882
5008
|
console.log(` > generated: ${ansi.blue.underline(out99Path)}`);
|
|
4883
5009
|
}
|
|
4884
5010
|
if (DB.opts.check) {
|
|
4885
5011
|
console.log(`${knownModelList.length} models found`);
|
|
4886
5012
|
console.log(`${DB.knownModels.size} models registered map`);
|
|
4887
5013
|
if (knownModelList.length !== DB.knownModels.size) console.log(`❌ some models are either duplicated or have overlapping indexing keys`);
|
|
4888
|
-
|
|
4889
|
-
|
|
5014
|
+
}
|
|
5015
|
+
};
|
|
5016
|
+
//#endregion
|
|
5017
|
+
//#region src/manager/types/ComfyManagerAlterInfo.ts
|
|
5018
|
+
const ComfyManagerAlterInfo_ark = type({
|
|
5019
|
+
id: "string",
|
|
5020
|
+
tags: "string",
|
|
5021
|
+
description: "string"
|
|
5022
|
+
});
|
|
5023
|
+
const ComfyManagerFileAlterListRoot_ark = type({ items: "unknown[]" });
|
|
5024
|
+
//#endregion
|
|
5025
|
+
//#region src/manager/loaders/step5_alter-list-loader.ts
|
|
5026
|
+
const _getAlterList = (DB) => {
|
|
5027
|
+
const counter = DB.report.file("alter-list.json");
|
|
5028
|
+
const root = ComfyManagerFileAlterListRoot_ark(JSON.parse(readFileSync("src/manager/json/alter-list.json", "utf8")));
|
|
5029
|
+
if (root instanceof type.errors) throw new ManagerParseError("alter-list.json", root.summary);
|
|
5030
|
+
const canonical = [];
|
|
5031
|
+
for (const row of root.items) {
|
|
5032
|
+
const res = ComfyManagerAlterInfo_ark(row);
|
|
5033
|
+
if (res instanceof type.errors) {
|
|
5034
|
+
counter.skip("schema", res.summary);
|
|
5035
|
+
continue;
|
|
5036
|
+
}
|
|
5037
|
+
canonical.push(res);
|
|
5038
|
+
counter.ok();
|
|
5039
|
+
}
|
|
5040
|
+
DB.alterations = canonical;
|
|
5041
|
+
};
|
|
5042
|
+
//#endregion
|
|
5043
|
+
//#region src/manager/types/ComfyManagerGithubStats.ts
|
|
5044
|
+
const ComfyManagerGithubStatEntry_ark = type({
|
|
5045
|
+
stars: "number",
|
|
5046
|
+
last_update: "string",
|
|
5047
|
+
author_account_age_days: "number"
|
|
5048
|
+
});
|
|
5049
|
+
//#endregion
|
|
5050
|
+
//#region src/manager/loaders/step6_github-stats-loader.ts
|
|
5051
|
+
const _getGithubStats = (DB) => {
|
|
5052
|
+
const counter = DB.report.file("github-stats.json");
|
|
5053
|
+
const raw = JSON.parse(readFileSync("src/manager/json/github-stats.json", "utf8"));
|
|
5054
|
+
const root = type("Record<string, unknown>")(raw);
|
|
5055
|
+
if (root instanceof type.errors) throw new ManagerParseError("github-stats.json", root.summary);
|
|
5056
|
+
for (const [url, value] of Object.entries(root)) {
|
|
5057
|
+
const res = ComfyManagerGithubStatEntry_ark(value);
|
|
5058
|
+
if (res instanceof type.errors) {
|
|
5059
|
+
counter.skip("schema", `${url}: ${res.summary}`);
|
|
5060
|
+
continue;
|
|
5061
|
+
}
|
|
5062
|
+
DB.githubStats.set(url, res);
|
|
5063
|
+
counter.ok();
|
|
4890
5064
|
}
|
|
4891
5065
|
};
|
|
4892
5066
|
//#endregion
|
|
4893
5067
|
//#region src/manager/ComfyRegistry.ts
|
|
4894
5068
|
const log = (...args) => console.log(`[📘 registry]`, ...args);
|
|
5069
|
+
const BUILTIN_URL = "https://github.com/comfyanonymous/ComfyUI";
|
|
5070
|
+
const BUILTIN_PLUGIN = {
|
|
5071
|
+
id: "nodes",
|
|
5072
|
+
author: "comfyanonymous",
|
|
5073
|
+
description: "built-in",
|
|
5074
|
+
title: "built-in",
|
|
5075
|
+
files: [BUILTIN_URL],
|
|
5076
|
+
reference: "https://github.com/comfyanonymous/ComfyUI",
|
|
5077
|
+
install_type: ""
|
|
5078
|
+
};
|
|
4895
5079
|
var ComfyRegistry = class ComfyRegistry {
|
|
4896
5080
|
static async DownloadAndUpdate(download) {
|
|
4897
5081
|
if (download) {
|
|
@@ -4911,6 +5095,9 @@ var ComfyRegistry = class ComfyRegistry {
|
|
|
4911
5095
|
this.plugins_byNodeKey = /* @__PURE__ */ new Map();
|
|
4912
5096
|
this.customNodes_byPluginName = /* @__PURE__ */ new Map();
|
|
4913
5097
|
this.knownModels = /* @__PURE__ */ new Map();
|
|
5098
|
+
this.alterations = [];
|
|
5099
|
+
this.githubStats = /* @__PURE__ */ new Map();
|
|
5100
|
+
this.report = new ManagerParseReport();
|
|
4914
5101
|
this.getKnownCheckpoints = () => {
|
|
4915
5102
|
return [...this.knownModels.values()].filter((i) => i.type === "checkpoint");
|
|
4916
5103
|
};
|
|
@@ -4950,21 +5137,19 @@ var ComfyRegistry = class ComfyRegistry {
|
|
|
4950
5137
|
nix: isUnderPrefix ? nixPath.slice(nixPrefix.length) : mi.filename
|
|
4951
5138
|
};
|
|
4952
5139
|
};
|
|
4953
|
-
this.
|
|
4954
|
-
|
|
4955
|
-
author: "comfyanonymous",
|
|
4956
|
-
description: "built-in",
|
|
4957
|
-
title: "built-in",
|
|
4958
|
-
files: [],
|
|
4959
|
-
reference: "https://github.com/comfyanonymous/ComfyUI",
|
|
4960
|
-
install_type: ""
|
|
4961
|
-
});
|
|
5140
|
+
this.plugins_byTitle.set(BUILTIN_PLUGIN.title, BUILTIN_PLUGIN);
|
|
5141
|
+
this.plugins_byFile.set(BUILTIN_URL, BUILTIN_PLUGIN);
|
|
4962
5142
|
log(`loading src/manager/json/${ansi.yellow("custom-node-list.json")}...`);
|
|
4963
5143
|
_getKnownPlugins(this);
|
|
4964
5144
|
log(`loading src/manager/json/${ansi.yellow("extension-node-map.json")}...`);
|
|
4965
5145
|
_getCustomNodeRegistry(this);
|
|
4966
5146
|
log(`loading src/manager/json/${ansi.yellow("model-list.json")}...`);
|
|
4967
5147
|
_getKnownModels(this);
|
|
5148
|
+
log(`loading src/manager/json/${ansi.yellow("alter-list.json")}...`);
|
|
5149
|
+
_getAlterList(this);
|
|
5150
|
+
log(`loading src/manager/json/${ansi.yellow("github-stats.json")}...`);
|
|
5151
|
+
_getGithubStats(this);
|
|
5152
|
+
this.report.print();
|
|
4968
5153
|
}
|
|
4969
5154
|
};
|
|
4970
5155
|
//#endregion
|
|
@@ -5056,6 +5241,52 @@ var ComfyTS = class ComfyTS {
|
|
|
5056
5241
|
}
|
|
5057
5242
|
};
|
|
5058
5243
|
//#endregion
|
|
5244
|
+
//#region src/exampleAssets.ts
|
|
5245
|
+
/**
|
|
5246
|
+
* the examples/ folder shipped in the npm tarball, resolved from THIS module's
|
|
5247
|
+
* own location (NEVER cwd): walking up to the nearest NAMED package.json finds
|
|
5248
|
+
* <pkg>/examples both from a consumer's node_modules/comfy-ts/dist/ and from
|
|
5249
|
+
* this repo's src/. Returns null when the examples are absent (a consumer may
|
|
5250
|
+
* prune the folder) or when the nearest named package is not comfy-ts (the lib
|
|
5251
|
+
* was inlined into someone else's bundle — its examples are not on disk); no
|
|
5252
|
+
* package.json all the way up is a broken install and throws.
|
|
5253
|
+
*/
|
|
5254
|
+
function bundledExamplesDir(moduleUrl = import.meta.url) {
|
|
5255
|
+
let dir = dirname(fileURLToPath(moduleUrl));
|
|
5256
|
+
let prev = "";
|
|
5257
|
+
while (dir !== prev) {
|
|
5258
|
+
const pkgPath = join(dir, "package.json");
|
|
5259
|
+
if (existsSync(pkgPath)) {
|
|
5260
|
+
let pkg = {};
|
|
5261
|
+
try {
|
|
5262
|
+
pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
5263
|
+
} catch {}
|
|
5264
|
+
if (pkg.name === "comfy-ts") {
|
|
5265
|
+
const examples = join(dir, "examples");
|
|
5266
|
+
return existsSync(examples) ? examples : null;
|
|
5267
|
+
}
|
|
5268
|
+
if (pkg.name != null) return null;
|
|
5269
|
+
}
|
|
5270
|
+
prev = dir;
|
|
5271
|
+
dir = dirname(dir);
|
|
5272
|
+
}
|
|
5273
|
+
throw new Error(`[comfy-ts] no package.json found walking up from ${fileURLToPath(moduleUrl)}`);
|
|
5274
|
+
}
|
|
5275
|
+
/**
|
|
5276
|
+
* absolute path of a bundled `examples/images/` input image, e.g.
|
|
5277
|
+
* `exampleImagePath('bear_1024x1024.jpg')` — the out-of-the-box default for
|
|
5278
|
+
* i2i/i2v example image vars, valid from this repo AND from a consumer's
|
|
5279
|
+
* node_modules/comfy-ts/. Loud throw naming the path when the file is missing
|
|
5280
|
+
* or the package's examples/ folder was pruned.
|
|
5281
|
+
*/
|
|
5282
|
+
function exampleImagePath(name) {
|
|
5283
|
+
const examples = bundledExamplesDir();
|
|
5284
|
+
if (examples == null) throw new Error(`[comfy-ts] cannot resolve bundled example image '${name}': the package's examples/ folder is not on disk`);
|
|
5285
|
+
const abs = join(examples, "images", name);
|
|
5286
|
+
if (!existsSync(abs)) throw new Error(`[comfy-ts] bundled example image not found: ${abs}`);
|
|
5287
|
+
return abs;
|
|
5288
|
+
}
|
|
5289
|
+
//#endregion
|
|
5059
5290
|
//#region src/cli/tui-env.ts
|
|
5060
5291
|
const COMFY_TS_TUI_ENV = "COMFY_TS_TUI";
|
|
5061
5292
|
function isTuiActive() {
|
|
@@ -5074,6 +5305,6 @@ function loraTag(name, strength = 1, clipStrength) {
|
|
|
5074
5305
|
return clipStrength == null ? `<lora:${name}:${strength}>` : `<lora:${name}:${strength}:${clipStrength}>`;
|
|
5075
5306
|
}
|
|
5076
5307
|
//#endregion
|
|
5077
|
-
export { ChoiceVar, ComfyExecution, ComfyHost, ComfyHostAuthError, ComfyManager, ComfyNode, ComfyNodeOutput, ComfySchema, ComfyTS, ComfyUploader, ComfyVar, ComfyVarBase, ComfyWorkflow, ComfyWorkflowBuilder, DEFAULT_SIZE_PRESETS, DefinedWorkflow, FloatVar, IntVar, InvalidPromptError, LorasVar, MediaImage, PromptVar, ResilientWebSocketClient, SeedVar, SizeVar, TextVar, ToggleVar, WorkflowConvertError, WorkflowNormalizeError, __FAIL, __OK, activeLoras, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, getLoraKeyword, hostIdToNamespace, isTuiActive, loraTag, normalizeWorkflow, parseHostBase, parseWorkflowJson, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setLoraKeyword, v };
|
|
5308
|
+
export { ChoiceVar, ComfyExecution, ComfyHost, ComfyHostAuthError, ComfyManager, ComfyNode, ComfyNodeOutput, ComfySchema, ComfyTS, ComfyUploader, ComfyVar, ComfyVarBase, ComfyWorkflow, ComfyWorkflowBuilder, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, DefinedWorkflow, FloatVar, ImageVar, ImageVarEmptyError, IntVar, InvalidPromptError, LorasVar, MediaImage, PromptVar, ResilientWebSocketClient, SeedVar, SizeVar, TextVar, ToggleVar, WorkflowConvertError, WorkflowNormalizeError, __FAIL, __OK, activeLoras, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, exampleImagePath, getLoraKeyword, hostIdToNamespace, isTuiActive, loraTag, normalizeWorkflow, parseHostBase, parseWorkflowJson, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setLoraKeyword, v };
|
|
5078
5309
|
|
|
5079
5310
|
//# sourceMappingURL=index.js.map
|