comfy-ts 2.14.0 → 2.15.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 +1 -0
- package/dist/{LogsSt-CUeo843w.js → LogsSt-C3UIWR-o.js} +2 -2
- package/dist/{LogsSt-CUeo843w.js.map → LogsSt-C3UIWR-o.js.map} +1 -1
- package/dist/cli.js +4 -4
- package/dist/index.cjs +213 -53
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +123 -21
- package/dist/index.d.ts +123 -21
- package/dist/index.js +207 -54
- package/dist/index.js.map +1 -1
- package/dist/{run-serve-DUqcn0h3.js → run-serve-B5PfIuhK.js} +108 -38
- package/dist/run-serve-B5PfIuhK.js.map +1 -0
- package/dist/{run-tui-D-LaSqgB.js → run-tui-D-N4_yyX.js} +15 -9
- package/dist/run-tui-D-N4_yyX.js.map +1 -0
- package/dist/{schemaDrift-E95iTF7E.js → schemaDrift-BkN8rLiZ.js} +163 -25
- package/dist/schemaDrift-BkN8rLiZ.js.map +1 -0
- package/dist/serve-web.js +62 -48
- package/dist/{state-BytbdZ8s.js → state-CZsYJqB6.js} +45 -35
- package/dist/state-CZsYJqB6.js.map +1 -0
- package/dist/web.d.ts +120 -21
- package/dist/web.js +196 -51
- package/dist/web.js.map +1 -1
- package/examples/media/README.md +8 -0
- package/examples/media/sine_440hz_3s.flac +0 -0
- package/examples/media/testsrc_256x256_3s.mp4 +0 -0
- package/examples/rvion/14-video-soundtrack.cflow.ts +47 -0
- package/guide-for-agents.md +2 -1
- package/package.json +2 -2
- package/src/cli/serve/ServeApp.ts +101 -30
- package/src/cli/serve/applyVarPayload.ts +5 -3
- package/src/cli/serve/describeVar.ts +5 -3
- package/src/cli/serve/resultHistory.ts +22 -6
- package/src/cli/serve/run-serve.ts +4 -1
- package/src/cli/serve/web/api.ts +4 -0
- package/src/cli/serve/web/components/Gallery.tsx +84 -4
- package/src/cli/serve/web/components/VarsForm.tsx +5 -3
- package/src/cli/serve/web/components/controls/MediaControl.tsx +111 -0
- package/src/cli/serve/web/state/FormSt.ts +70 -2
- package/src/cli/serve/web/state/host.ts +2 -0
- package/src/cli/serve/web/state/mediaDrop.ts +76 -0
- package/src/cli/serve/web/styles.ts +16 -2
- package/src/cli/tui/imagePicker/ImagePickerOverlay.tsx +4 -1
- package/src/cli/tui/imagePicker/ImagePickerSt.ts +15 -6
- package/src/cli/tui/state/TuiSt.ts +1 -1
- package/src/coreExports.ts +10 -0
- package/src/exampleAssets.ts +13 -3
- package/src/host/ComfyUploader.ts +34 -27
- package/src/index.ts +1 -1
- package/src/runner/ComfyExecution.ts +38 -20
- package/src/runner/ComfyWsApi.ts +3 -0
- package/src/runner/mediaKinds.ts +51 -0
- package/src/vars/ComfyVars.ts +96 -22
- package/dist/run-serve-DUqcn0h3.js.map +0 -1
- package/dist/run-tui-D-LaSqgB.js.map +0 -1
- package/dist/schemaDrift-E95iTF7E.js.map +0 -1
- package/dist/state-BytbdZ8s.js.map +0 -1
- package/src/cli/serve/web/components/controls/ImageControl.tsx +0 -72
|
@@ -168,6 +168,83 @@ const extractErrorMessage = (error) => {
|
|
|
168
168
|
return String(error);
|
|
169
169
|
};
|
|
170
170
|
//#endregion
|
|
171
|
+
//#region src/utils/hashArrayBuffer.ts
|
|
172
|
+
const hashArrayBuffer = (buffer) => {
|
|
173
|
+
return sha1Hex(buffer);
|
|
174
|
+
};
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region src/runner/mediaKinds.ts
|
|
177
|
+
const MEDIA_KINDS = [
|
|
178
|
+
"image",
|
|
179
|
+
"audio",
|
|
180
|
+
"video"
|
|
181
|
+
];
|
|
182
|
+
/** picker defaults per kind, lowercase without dots */
|
|
183
|
+
const DEFAULT_MEDIA_EXTENSIONS = {
|
|
184
|
+
image: [
|
|
185
|
+
"png",
|
|
186
|
+
"jpg",
|
|
187
|
+
"jpeg",
|
|
188
|
+
"webp",
|
|
189
|
+
"gif"
|
|
190
|
+
],
|
|
191
|
+
audio: [
|
|
192
|
+
"wav",
|
|
193
|
+
"flac",
|
|
194
|
+
"mp3",
|
|
195
|
+
"ogg",
|
|
196
|
+
"opus",
|
|
197
|
+
"m4a"
|
|
198
|
+
],
|
|
199
|
+
video: [
|
|
200
|
+
"mp4",
|
|
201
|
+
"webm",
|
|
202
|
+
"mov",
|
|
203
|
+
"mkv",
|
|
204
|
+
"m4v"
|
|
205
|
+
]
|
|
206
|
+
};
|
|
207
|
+
const MIMES = {
|
|
208
|
+
png: "image/png",
|
|
209
|
+
jpg: "image/jpeg",
|
|
210
|
+
jpeg: "image/jpeg",
|
|
211
|
+
webp: "image/webp",
|
|
212
|
+
gif: "image/gif",
|
|
213
|
+
flac: "audio/flac",
|
|
214
|
+
mp3: "audio/mpeg",
|
|
215
|
+
opus: "audio/ogg",
|
|
216
|
+
ogg: "audio/ogg",
|
|
217
|
+
wav: "audio/wav",
|
|
218
|
+
m4a: "audio/mp4",
|
|
219
|
+
aac: "audio/aac",
|
|
220
|
+
mp4: "video/mp4",
|
|
221
|
+
m4v: "video/mp4",
|
|
222
|
+
webm: "video/webm",
|
|
223
|
+
mov: "video/quicktime",
|
|
224
|
+
mkv: "video/x-matroska",
|
|
225
|
+
avi: "video/x-msvideo"
|
|
226
|
+
};
|
|
227
|
+
/** video containers an output node can name. An animated webp or gif is an IMAGE: the
|
|
228
|
+
* extension decides, never the `animated` flag */
|
|
229
|
+
const VIDEO_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
230
|
+
"mp4",
|
|
231
|
+
"m4v",
|
|
232
|
+
"webm",
|
|
233
|
+
"mov",
|
|
234
|
+
"mkv",
|
|
235
|
+
"avi"
|
|
236
|
+
]);
|
|
237
|
+
function extensionOf(filename) {
|
|
238
|
+
const dot = filename.lastIndexOf(".");
|
|
239
|
+
return dot < 0 ? "" : filename.slice(dot + 1).toLowerCase();
|
|
240
|
+
}
|
|
241
|
+
function isVideoFilename(filename) {
|
|
242
|
+
return VIDEO_EXTENSIONS.has(extensionOf(filename));
|
|
243
|
+
}
|
|
244
|
+
function mediaMime(filename) {
|
|
245
|
+
return MIMES[extensionOf(filename)] ?? "application/octet-stream";
|
|
246
|
+
}
|
|
247
|
+
//#endregion
|
|
171
248
|
//#region src/utils/ansi.ts
|
|
172
249
|
const codes = {
|
|
173
250
|
bold: [1, 22],
|
|
@@ -1700,42 +1777,53 @@ var SizeVar = class extends ComfyVar {
|
|
|
1700
1777
|
return `${width}×${height}${hit ? ` (${hit.label})` : ""}`;
|
|
1701
1778
|
}
|
|
1702
1779
|
};
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
"
|
|
1709
|
-
|
|
1710
|
-
/** empty image var consumed at build time — typed so drivers surface it apart from real crashes */
|
|
1711
|
-
var ImageVarEmptyError = class extends Error {
|
|
1712
|
-
constructor(varName) {
|
|
1713
|
-
super(`image var '${varName}' is empty — pick a file (TUI: activate the var; script: .set('/path/to/image.png'))`);
|
|
1780
|
+
DEFAULT_MEDIA_EXTENSIONS.image;
|
|
1781
|
+
DEFAULT_MEDIA_EXTENSIONS.audio;
|
|
1782
|
+
DEFAULT_MEDIA_EXTENSIONS.video;
|
|
1783
|
+
/** empty media var consumed at build time — typed so drivers surface it apart from real crashes */
|
|
1784
|
+
var MediaVarEmptyError = class extends Error {
|
|
1785
|
+
constructor(varName, media = "image") {
|
|
1786
|
+
super(`${media} var '${varName}' is empty — pick a file (TUI: activate the var; script: .set('/path/to/file'))`);
|
|
1714
1787
|
this.varName = varName;
|
|
1715
|
-
this.
|
|
1788
|
+
this.media = media;
|
|
1789
|
+
this.name = "MediaVarEmptyError";
|
|
1716
1790
|
}
|
|
1717
1791
|
};
|
|
1718
|
-
/** trim + expand a leading `~/` — every
|
|
1792
|
+
/** trim + expand a leading `~/` — every media var write funnels through this */
|
|
1719
1793
|
function expandUserPath(raw) {
|
|
1720
1794
|
const trimmed = raw.trim();
|
|
1721
1795
|
return trimmed.startsWith("~/") ? join(getComfyStorage().homedir(), trimmed.slice(2)) : trimmed;
|
|
1722
1796
|
}
|
|
1797
|
+
/** the loader node each medium goes through, and its file input */
|
|
1798
|
+
const MEDIA_LOADERS = {
|
|
1799
|
+
image: {
|
|
1800
|
+
node: "LoadImage",
|
|
1801
|
+
input: "image"
|
|
1802
|
+
},
|
|
1803
|
+
audio: {
|
|
1804
|
+
node: "LoadAudio",
|
|
1805
|
+
input: "audio"
|
|
1806
|
+
},
|
|
1807
|
+
video: {
|
|
1808
|
+
node: "LoadVideo",
|
|
1809
|
+
input: "file"
|
|
1810
|
+
}
|
|
1811
|
+
};
|
|
1723
1812
|
/**
|
|
1724
|
-
* a local
|
|
1813
|
+
* a local media file path. The VALUE is a PLAIN PATH STRING — text-encodable,
|
|
1725
1814
|
* drafts persist it verbatim (toJSON = the string), hand-editable in the
|
|
1726
|
-
* draft json. Empty = unset: outValue()/absPath() throw
|
|
1727
|
-
* so a build never runs on a silent placeholder. The TUI opens the
|
|
1728
|
-
* picker overlay for kind
|
|
1815
|
+
* draft json. Empty = unset: outValue()/absPath() throw MediaVarEmptyError,
|
|
1816
|
+
* so a build never runs on a silent placeholder. The TUI opens the file
|
|
1817
|
+
* picker overlay for every media kind.
|
|
1729
1818
|
*/
|
|
1730
|
-
var
|
|
1819
|
+
var MediaVar = class extends ComfyVar {
|
|
1731
1820
|
constructor(defaultValue, opts = {}) {
|
|
1732
1821
|
super(expandUserPath(defaultValue), opts.label);
|
|
1733
1822
|
this.opts = opts;
|
|
1734
|
-
this.kind = "image";
|
|
1735
1823
|
}
|
|
1736
1824
|
/** what the picker lists (lowercase, no dots) */
|
|
1737
1825
|
get extensions() {
|
|
1738
|
-
return this.opts.extensions ??
|
|
1826
|
+
return this.opts.extensions ?? DEFAULT_MEDIA_EXTENSIONS[this.kind];
|
|
1739
1827
|
}
|
|
1740
1828
|
set(value) {
|
|
1741
1829
|
return super.set(expandUserPath(value));
|
|
@@ -1748,7 +1836,7 @@ var ImageVar = class extends ComfyVar {
|
|
|
1748
1836
|
return this.value !== "";
|
|
1749
1837
|
}
|
|
1750
1838
|
emptyError() {
|
|
1751
|
-
return new
|
|
1839
|
+
return new MediaVarEmptyError(this.name ?? this.label ?? this.kind, this.kind);
|
|
1752
1840
|
}
|
|
1753
1841
|
/** the ONE resolution helper: absolute kept as-is, relative resolved against opts.folder, else cwd */
|
|
1754
1842
|
absPath() {
|
|
@@ -1766,8 +1854,56 @@ var ImageVar = class extends ComfyVar {
|
|
|
1766
1854
|
const home = getComfyStorage().homedir();
|
|
1767
1855
|
return this.value.startsWith(`${home}/`) ? `~${this.value.slice(home.length)}` : this.value;
|
|
1768
1856
|
}
|
|
1857
|
+
/** upload the file hash-named (reruns dedupe) and add this medium's loader node. A dry
|
|
1858
|
+
* build names the file by its hash and uploads nothing */
|
|
1859
|
+
async loadVia(wf) {
|
|
1860
|
+
const loader = MEDIA_LOADERS[this.kind];
|
|
1861
|
+
const factory = wf.builderBase[loader.node];
|
|
1862
|
+
if (factory == null) throw new Error(`host '${wf.host.data.id}' has no ${loader.node} node: ${this.kind} var '${this.name ?? "?"}' cannot load`);
|
|
1863
|
+
const abs = this.absPath();
|
|
1864
|
+
const bytes = getComfyStorage().readBytes(abs);
|
|
1865
|
+
const ext = extensionOf(abs);
|
|
1866
|
+
const name = `${hashArrayBuffer(bytes)}${ext === "" ? "" : `.${ext}`}`;
|
|
1867
|
+
const onHost = wf.dry ? name : await wf.host.uploader.uploadInput({
|
|
1868
|
+
blob: new Blob([bytes], { type: mediaMime(abs) }),
|
|
1869
|
+
name,
|
|
1870
|
+
slot: `${loader.node}.${loader.input}`,
|
|
1871
|
+
type: "input"
|
|
1872
|
+
});
|
|
1873
|
+
return factory({ [loader.input]: onHost });
|
|
1874
|
+
}
|
|
1875
|
+
};
|
|
1876
|
+
/** a local image path, loaded through LoadImage */
|
|
1877
|
+
var ImageVar = class extends MediaVar {
|
|
1878
|
+
constructor(..._args2) {
|
|
1879
|
+
super(..._args2);
|
|
1880
|
+
this.kind = "image";
|
|
1881
|
+
}
|
|
1882
|
+
async loadInWorkflow(wf) {
|
|
1883
|
+
return await this.loadVia(wf);
|
|
1884
|
+
}
|
|
1885
|
+
};
|
|
1886
|
+
/** a local audio path, loaded through LoadAudio */
|
|
1887
|
+
var AudioVar = class extends MediaVar {
|
|
1888
|
+
constructor(..._args3) {
|
|
1889
|
+
super(..._args3);
|
|
1890
|
+
this.kind = "audio";
|
|
1891
|
+
}
|
|
1892
|
+
async loadInWorkflow(wf) {
|
|
1893
|
+
return await this.loadVia(wf);
|
|
1894
|
+
}
|
|
1895
|
+
};
|
|
1896
|
+
/** a local video path, loaded through LoadVideo */
|
|
1897
|
+
var VideoVar = class extends MediaVar {
|
|
1898
|
+
constructor(..._args4) {
|
|
1899
|
+
super(..._args4);
|
|
1900
|
+
this.kind = "video";
|
|
1901
|
+
}
|
|
1902
|
+
async loadInWorkflow(wf) {
|
|
1903
|
+
return await this.loadVia(wf);
|
|
1904
|
+
}
|
|
1769
1905
|
};
|
|
1770
|
-
/** the var constructors: v.text / v.prompt / v.int / v.float / v.seed / v.toggle / v.choice / v.loras / v.size / v.image */
|
|
1906
|
+
/** the var constructors: v.text / v.prompt / v.int / v.float / v.seed / v.toggle / v.choice / v.loras / v.size / v.image / v.audio / v.video */
|
|
1771
1907
|
const v = {
|
|
1772
1908
|
text: (defaultValue, opts = {}) => new TextVar(defaultValue, typeof opts === "string" ? { label: opts } : opts),
|
|
1773
1909
|
prompt: (defaultValue, opts = {}) => new PromptVar(defaultValue, opts),
|
|
@@ -1782,7 +1918,9 @@ const v = {
|
|
|
1782
1918
|
choice,
|
|
1783
1919
|
loras: (options, initial = {}, label) => new LorasVar(options, initial, label),
|
|
1784
1920
|
size: (defaultValue, opts = {}) => new SizeVar(defaultValue, opts.presets ?? sizePresetsFor(defaultValue), opts.label, opts.image, opts.starred),
|
|
1785
|
-
image: (defaultValue, opts = {}) => new ImageVar(defaultValue, opts)
|
|
1921
|
+
image: (defaultValue, opts = {}) => new ImageVar(defaultValue, opts),
|
|
1922
|
+
audio: (defaultValue, opts = {}) => new AudioVar(defaultValue, opts),
|
|
1923
|
+
video: (defaultValue, opts = {}) => new VideoVar(defaultValue, opts)
|
|
1786
1924
|
};
|
|
1787
1925
|
function varValues(vars) {
|
|
1788
1926
|
const out = {};
|
|
@@ -1980,6 +2118,6 @@ function summarizeDrift(d) {
|
|
|
1980
2118
|
return parts.join(", ");
|
|
1981
2119
|
}
|
|
1982
2120
|
//#endregion
|
|
1983
|
-
export {
|
|
2121
|
+
export { DEFAULT_MEDIA_EXTENSIONS as $, reloadLoraInfoCache as A, lmFileSize as B, getLoraTriggers as C, readLoraMirror as D, lorasMissingFromMirror as E, fetchLoraList as F, lmTags as G, lmModelName as H, fetchLoraPreviewBytes as I, loraKey as J, lmTrainedWords as K, lmBaseModel as L, fetchLoraCivitai as M, fetchLoraDescription as N, recordCivitaiMiss as O, fetchLoraExampleImages as P, stripAnsi as Q, lmCivitai as R, getLoraTriggerWords as S, loraMirrorEntries as T, lmNotes as U, lmFolder as V, lmSha256 as W, ansi as X, loraPreviewMapFrom as Y, colorsAvailable as Z, buildLoraMirror as _, DefinedWorkflow as a, extractErrorMessage as at, getLoraInfo as b, isLoraLanes as c, getComfyStorage as ct, isLoraStrength as d, logError as dt, MEDIA_KINDS as et, clearLoraKeywordOverride as f, logInfo as ft, setLoraKeyword as g, loraKeywordFromMirror as h, sha1HexOfString as ht, summarizeDrift as i, hashArrayBuffer as it, writeLoraMirror as j, refreshLoraInfoCacheIfChanged as k, isLorasInput as l, resolveComfyStorage as lt, isLoraKeywordFromMirror as m, statelessRegex as mt, diffSchemas as n, isVideoFilename as nt, LorasVar as o, isRecord as ot, getLoraKeyword as p, logSuccess as pt, loraBasename as q, driftChanged as r, mediaMime as rt, PromptVar as s, bang as st, MODEL_LISTS as t, extensionOf as tt, isPromptInput as u, isQuiet as ut, getLoraAddedAt as v, loraMatchesFilter as w, getLoraPreviewUrl as x, getLoraDisplayName as y, lmFilePath as z };
|
|
1984
2122
|
|
|
1985
|
-
//# sourceMappingURL=schemaDrift-
|
|
2123
|
+
//# sourceMappingURL=schemaDrift-BkN8rLiZ.js.map
|