comfy-ts 2.13.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-DlRBv_Nk.js → run-serve-B5PfIuhK.js} +310 -88
- package/dist/run-serve-B5PfIuhK.js.map +1 -0
- package/dist/{run-tui-B5uxm2_l.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 +160 -71
- package/dist/{state-CUp2J1Zy.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 +189 -110
- package/src/cli/serve/applyVarPayload.ts +5 -3
- package/src/cli/serve/describeVar.ts +5 -3
- package/src/cli/serve/resultHistory.ts +141 -0
- package/src/cli/serve/run-serve.ts +4 -1
- package/src/cli/serve/runError.ts +23 -0
- package/src/cli/serve/serveSettings.ts +17 -1
- package/src/cli/serve/web/api.ts +33 -2
- package/src/cli/serve/web/components/App.tsx +6 -4
- package/src/cli/serve/web/components/Gallery.tsx +116 -11
- package/src/cli/serve/web/components/Icon.tsx +4 -0
- package/src/cli/serve/web/components/MemoryBudget.tsx +98 -0
- package/src/cli/serve/web/components/RunError.tsx +19 -0
- package/src/cli/serve/web/components/ShortcutsModal.tsx +54 -0
- package/src/cli/serve/web/components/SideMenu.tsx +14 -0
- package/src/cli/serve/web/components/VarsForm.tsx +75 -55
- package/src/cli/serve/web/components/controls/BasicControls.tsx +8 -1
- package/src/cli/serve/web/components/controls/LorasControl.tsx +6 -3
- package/src/cli/serve/web/components/controls/MediaControl.tsx +111 -0
- package/src/cli/serve/web/promptEditor/promptExtensions.ts +3 -1
- package/src/cli/serve/web/state/FormSt.ts +70 -2
- package/src/cli/serve/web/state/RunSt.ts +61 -3
- package/src/cli/serve/web/state/WebSt.ts +26 -2
- package/src/cli/serve/web/state/formRows.ts +9 -0
- package/src/cli/serve/web/state/host.ts +2 -0
- package/src/cli/serve/web/state/keptResults.ts +26 -0
- package/src/cli/serve/web/state/lightbox.ts +17 -0
- package/src/cli/serve/web/state/mediaDrop.ts +76 -0
- package/src/cli/serve/web/state/shortcutCatalog.ts +100 -0
- package/src/cli/serve/web/state/shortcuts.ts +10 -0
- package/src/cli/serve/web/styles.ts +112 -24
- 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-DlRBv_Nk.js.map +0 -1
- package/dist/run-tui-B5uxm2_l.js.map +0 -1
- package/dist/schemaDrift-E95iTF7E.js.map +0 -1
- package/dist/state-CUp2J1Zy.js.map +0 -1
- package/src/cli/serve/web/components/controls/ImageControl.tsx +0 -72
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { a as draftsDirForFile, c as isDraftMetaKey, f as findDefinedWorkflow, i as draftKeyForFile, m as scanCflowFiles, n as assembleLogChunks, o as listDraftsForFile, s as ENHANCE_KEY } from "./LogsSt-
|
|
1
|
+
import { $ as DEFAULT_MEDIA_EXTENSIONS, A as reloadLoraInfoCache, B as lmFileSize, C as getLoraTriggers, E as lorasMissingFromMirror, F as fetchLoraList, G as lmTags, I as fetchLoraPreviewBytes, J as loraKey, L as lmBaseModel, M as fetchLoraCivitai, N as fetchLoraDescription, O as recordCivitaiMiss, P as fetchLoraExampleImages, Q as stripAnsi, R as lmCivitai, S as getLoraTriggerWords, T as loraMirrorEntries, U as lmNotes, V as lmFolder, W as lmSha256, X as ansi, Y as loraPreviewMapFrom, Z as colorsAvailable, _ as buildLoraMirror, at as extractErrorMessage, b as getLoraInfo, c as isLoraLanes, d as isLoraStrength, et as MEDIA_KINDS, ht as sha1HexOfString, i as summarizeDrift, j as writeLoraMirror, k as refreshLoraInfoCacheIfChanged, l as isLorasInput, mt as statelessRegex, p as getLoraKeyword, r as driftChanged, st as bang, u as isPromptInput, v as getLoraAddedAt, x as getLoraPreviewUrl, y as getLoraDisplayName, z as lmFilePath } from "./schemaDrift-BkN8rLiZ.js";
|
|
2
|
+
import { a as draftsDirForFile, c as isDraftMetaKey, f as findDefinedWorkflow, i as draftKeyForFile, m as scanCflowFiles, n as assembleLogChunks, o as listDraftsForFile, s as ENHANCE_KEY } from "./LogsSt-C3UIWR-o.js";
|
|
3
3
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
4
|
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { basename, dirname, extname, isAbsolute, join, resolve } from "pathe";
|
|
@@ -107,7 +107,9 @@ function describeVar(varDef) {
|
|
|
107
107
|
starredPresets: [...v.starred]
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
|
-
case "image":
|
|
110
|
+
case "image":
|
|
111
|
+
case "audio":
|
|
112
|
+
case "video": {
|
|
111
113
|
const v = varDef;
|
|
112
114
|
return {
|
|
113
115
|
...base,
|
|
@@ -255,6 +257,8 @@ function applyVarPayload(varDef, raw, opts = {}) {
|
|
|
255
257
|
return `var '${name}' expects {"width":W,"height":H}, "WxH", or a preset label`;
|
|
256
258
|
}
|
|
257
259
|
case "image":
|
|
260
|
+
case "audio":
|
|
261
|
+
case "video":
|
|
258
262
|
if (typeof raw !== "string") return `var '${name}' expects a file path or http(s) url string`;
|
|
259
263
|
varDef.set(raw);
|
|
260
264
|
return null;
|
|
@@ -674,13 +678,119 @@ function stringMap(raw) {
|
|
|
674
678
|
}
|
|
675
679
|
return out;
|
|
676
680
|
}
|
|
681
|
+
var ResultHistory = class {
|
|
682
|
+
constructor(budgetBytes) {
|
|
683
|
+
this.budgetBytes = budgetBytes;
|
|
684
|
+
this.runs = [];
|
|
685
|
+
this.blobs = /* @__PURE__ */ new Map();
|
|
686
|
+
this.used = 0;
|
|
687
|
+
}
|
|
688
|
+
add(p) {
|
|
689
|
+
this.remove(p.record.promptId);
|
|
690
|
+
for (const b of p.blobs) {
|
|
691
|
+
this.blobs.set(b.key, {
|
|
692
|
+
bytes: b.bytes,
|
|
693
|
+
contentType: b.contentType
|
|
694
|
+
});
|
|
695
|
+
this.used += b.bytes.byteLength;
|
|
696
|
+
}
|
|
697
|
+
const kept = {
|
|
698
|
+
record: p.record,
|
|
699
|
+
imageKeys: p.imageKeys,
|
|
700
|
+
audioKeys: p.audioKeys,
|
|
701
|
+
videoKeys: p.videoKeys ?? []
|
|
702
|
+
};
|
|
703
|
+
this.runs = [kept, ...this.runs];
|
|
704
|
+
for (const dropped of this.runs.slice(50)) this.freeRun(dropped);
|
|
705
|
+
this.runs = this.runs.slice(0, 50);
|
|
706
|
+
this.evict();
|
|
707
|
+
}
|
|
708
|
+
blob(key) {
|
|
709
|
+
return this.blobs.get(key) ?? null;
|
|
710
|
+
}
|
|
711
|
+
/** an output whose bytes were evicted lists with url null: the panel says it is gone */
|
|
712
|
+
list() {
|
|
713
|
+
return this.runs.map((k) => ({
|
|
714
|
+
...k.record,
|
|
715
|
+
images: k.record.images.map((img, ix) => this.withLiveUrl(img, k.imageKeys[ix])),
|
|
716
|
+
audios: k.record.audios.map((a, ix) => this.withLiveUrl(a, k.audioKeys[ix])),
|
|
717
|
+
videos: (k.record.videos ?? []).map((a, ix) => this.withLiveUrl(a, k.videoKeys[ix]))
|
|
718
|
+
}));
|
|
719
|
+
}
|
|
720
|
+
remove(promptId) {
|
|
721
|
+
const hit = this.runs.find((k) => k.record.promptId === promptId);
|
|
722
|
+
if (hit == null) return;
|
|
723
|
+
this.freeRun(hit);
|
|
724
|
+
this.runs = this.runs.filter((k) => k !== hit);
|
|
725
|
+
}
|
|
726
|
+
clear() {
|
|
727
|
+
this.runs = [];
|
|
728
|
+
this.blobs.clear();
|
|
729
|
+
this.used = 0;
|
|
730
|
+
}
|
|
731
|
+
setBudget(bytes) {
|
|
732
|
+
this.budgetBytes = bytes;
|
|
733
|
+
this.evict();
|
|
734
|
+
}
|
|
735
|
+
usage() {
|
|
736
|
+
return {
|
|
737
|
+
usedBytes: this.used,
|
|
738
|
+
budgetBytes: this.budgetBytes,
|
|
739
|
+
outputs: this.blobs.size,
|
|
740
|
+
runs: this.runs.length
|
|
741
|
+
};
|
|
742
|
+
}
|
|
743
|
+
withLiveUrl(out, key) {
|
|
744
|
+
if (key == null || this.blobs.has(key)) return out;
|
|
745
|
+
return {
|
|
746
|
+
...out,
|
|
747
|
+
url: null
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
freeRun(k) {
|
|
751
|
+
for (const key of [
|
|
752
|
+
...k.imageKeys,
|
|
753
|
+
...k.audioKeys,
|
|
754
|
+
...k.videoKeys
|
|
755
|
+
]) {
|
|
756
|
+
if (key == null) continue;
|
|
757
|
+
const b = this.blobs.get(key);
|
|
758
|
+
if (b == null) continue;
|
|
759
|
+
this.used -= b.bytes.byteLength;
|
|
760
|
+
this.blobs.delete(key);
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
/** the NEWEST output always stays, even alone over budget: the run that just finished must
|
|
764
|
+
* not reply with a url that already 404s */
|
|
765
|
+
evict() {
|
|
766
|
+
while (this.used > this.budgetBytes && this.blobs.size > 1) {
|
|
767
|
+
const oldest = this.blobs.entries().next();
|
|
768
|
+
if (oldest.done === true) break;
|
|
769
|
+
this.used -= oldest.value[1].bytes.byteLength;
|
|
770
|
+
this.blobs.delete(oldest.value[0]);
|
|
771
|
+
}
|
|
772
|
+
this.runs = this.runs.filter((k) => {
|
|
773
|
+
const live = (keys) => keys.some((key) => key == null || this.blobs.has(key));
|
|
774
|
+
const hasText = k.record.texts.length > 0;
|
|
775
|
+
const hasNothing = k.record.images.length === 0 && k.record.audios.length === 0 && (k.record.videos ?? []).length === 0;
|
|
776
|
+
return hasText || hasNothing || live(k.imageKeys) || live(k.audioKeys) || live(k.videoKeys);
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
};
|
|
677
780
|
//#endregion
|
|
678
781
|
//#region src/cli/serve/serveSettings.ts
|
|
679
782
|
const DEFAULT_SERVE_SETTINGS = {
|
|
680
783
|
saveToDisk: true,
|
|
681
784
|
hostOverride: {},
|
|
682
|
-
savePrefix: {}
|
|
785
|
+
savePrefix: {},
|
|
786
|
+
memoryBudgetMb: 100
|
|
683
787
|
};
|
|
788
|
+
/** null = not a budget. A hand-written file goes through the same gate as PUT /settings */
|
|
789
|
+
function validMemoryBudgetMb(raw) {
|
|
790
|
+
if (typeof raw !== "number" || !Number.isFinite(raw)) return null;
|
|
791
|
+
if (raw < 1 || raw > 1e5) return null;
|
|
792
|
+
return Math.round(raw);
|
|
793
|
+
}
|
|
684
794
|
/** null when no comfyts is registered yet: a ServeApp can be constructed before the global
|
|
685
795
|
* exists (tests do), and reading a setting must degrade to defaults, never throw */
|
|
686
796
|
function settingsPath() {
|
|
@@ -729,7 +839,8 @@ function readServeSettings() {
|
|
|
729
839
|
return {
|
|
730
840
|
saveToDisk: typeof o.saveToDisk === "boolean" ? o.saveToDisk : DEFAULT_SERVE_SETTINGS.saveToDisk,
|
|
731
841
|
hostOverride: stringMap(o.hostOverride),
|
|
732
|
-
savePrefix: cleanValues(stringMap(o.savePrefix), validSavePrefix)
|
|
842
|
+
savePrefix: cleanValues(stringMap(o.savePrefix), validSavePrefix),
|
|
843
|
+
memoryBudgetMb: validMemoryBudgetMb(o.memoryBudgetMb) ?? DEFAULT_SERVE_SETTINGS.memoryBudgetMb
|
|
733
844
|
};
|
|
734
845
|
}
|
|
735
846
|
function writeServeSettings(next) {
|
|
@@ -744,6 +855,25 @@ function writeServeSettings(next) {
|
|
|
744
855
|
}, null, 2));
|
|
745
856
|
}
|
|
746
857
|
//#endregion
|
|
858
|
+
//#region src/cli/serve/runError.ts
|
|
859
|
+
function describeRunError(error) {
|
|
860
|
+
if (error == null) return "execution failed";
|
|
861
|
+
if (typeof error === "string") return error;
|
|
862
|
+
if (error instanceof Error) return error.message;
|
|
863
|
+
if (typeof error === "object") {
|
|
864
|
+
const data = error.data;
|
|
865
|
+
if (typeof data === "object" && data !== null) {
|
|
866
|
+
const d = data;
|
|
867
|
+
if (typeof d.exception_message === "string") return `${typeof d.node_type === "string" ? `${d.node_type} (node ${String(d.node_id)}): ` : ""}${typeof d.exception_type === "string" && d.exception_type !== "" ? `${d.exception_type}: ` : ""}${d.exception_message.trim()}`;
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
try {
|
|
871
|
+
return JSON.stringify(error);
|
|
872
|
+
} catch {
|
|
873
|
+
return String(error);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
//#endregion
|
|
747
877
|
//#region src/cli/serve/web/state/draftTabs.ts
|
|
748
878
|
/** where the serve process keeps them, under .comfy-ts/: draft names are private, so this file
|
|
749
879
|
* must stay gitignored (tests/serve-tabs.test.ts runs git check-ignore on it) */
|
|
@@ -768,27 +898,31 @@ function readTabs(raw, modules) {
|
|
|
768
898
|
}
|
|
769
899
|
//#endregion
|
|
770
900
|
//#region src/cli/serve/ServeApp.ts
|
|
771
|
-
/** what serve will read off the disk and upload. Wider than the picker
|
|
772
|
-
* LoadImage takes bmp and tiff too, and a var declaring one of those must not be refused */
|
|
773
|
-
const
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
901
|
+
/** what serve will read off the disk and upload, per medium. Wider than the picker defaults:
|
|
902
|
+
* ComfyUI's LoadImage takes bmp and tiff too, and a var declaring one of those must not be refused */
|
|
903
|
+
const SERVE_MEDIA_FLOOR = {
|
|
904
|
+
image: /* @__PURE__ */ new Set([
|
|
905
|
+
...DEFAULT_MEDIA_EXTENSIONS.image,
|
|
906
|
+
"bmp",
|
|
907
|
+
"tif",
|
|
908
|
+
"tiff",
|
|
909
|
+
"avif"
|
|
910
|
+
]),
|
|
911
|
+
audio: /* @__PURE__ */ new Set([...DEFAULT_MEDIA_EXTENSIONS.audio, "aac"]),
|
|
912
|
+
video: /* @__PURE__ */ new Set([...DEFAULT_MEDIA_EXTENSIONS.video, "avi"])
|
|
913
|
+
};
|
|
780
914
|
/** the first bytes say what a file IS; the name only says what it claims. Cheap, and it stops
|
|
781
915
|
* a .png that holds a key or a script from being read and uploaded to the host.
|
|
782
916
|
* HONEST LIMIT: this is checked before the run, and the file is read again when the graph
|
|
783
917
|
* builds, so a local writer who can swap the path in between still wins. Closing that needs
|
|
784
918
|
* the upload to hold an fd, which is a bigger change than this gate. */
|
|
785
|
-
function
|
|
919
|
+
function looksLikeMedia(kind, path) {
|
|
786
920
|
let fd = null;
|
|
787
921
|
try {
|
|
788
922
|
fd = openSync(path, "r");
|
|
789
923
|
const head = /* @__PURE__ */ new Uint8Array(16);
|
|
790
924
|
const n = readSync(fd, head, 0, 16, 0);
|
|
791
|
-
return
|
|
925
|
+
return isMediaMagic(kind, head.subarray(0, n));
|
|
792
926
|
} catch {
|
|
793
927
|
return false;
|
|
794
928
|
} finally {
|
|
@@ -800,10 +934,11 @@ function looksLikeImage(path) {
|
|
|
800
934
|
* the gate: a workflow author narrowing (or emptying) it for listing reasons must not be able
|
|
801
935
|
* to widen what an unauthenticated request can make the server read. The var may narrow this
|
|
802
936
|
* floor, never leave it. */
|
|
803
|
-
function
|
|
937
|
+
function serveAcceptsMediaExt(kind, declared, ext) {
|
|
938
|
+
const floor = SERVE_MEDIA_FLOOR[kind];
|
|
804
939
|
if (ext === "") return false;
|
|
805
|
-
if (!
|
|
806
|
-
const narrowed = declared.map((e) => e.toLowerCase().replace(/^\./, "")).filter((e) =>
|
|
940
|
+
if (!floor.has(ext)) return false;
|
|
941
|
+
const narrowed = declared.map((e) => e.toLowerCase().replace(/^\./, "")).filter((e) => floor.has(e));
|
|
807
942
|
return narrowed.length === 0 || narrowed.includes(ext);
|
|
808
943
|
}
|
|
809
944
|
/** an image var pointing at a url downloads it: capped, because the inbound BODY cap does not
|
|
@@ -819,6 +954,7 @@ const INPUT_DOWNLOAD_TIMEOUT_MS = 6e4;
|
|
|
819
954
|
/** the danbooru list is ~3.5 MB; ten times that is still a tag list, beyond is a wrong url */
|
|
820
955
|
const TAG_LIST_CAP = 4e7;
|
|
821
956
|
const TAG_LIST_TIMEOUT_MS = 12e4;
|
|
957
|
+
const MB = 1024 * 1024;
|
|
822
958
|
/** read a reply STREAMING, aborting the moment it passes the cap. `arrayBuffer()` buffers the
|
|
823
959
|
* whole body first, so a chunked reply with no content-length could exhaust the process before
|
|
824
960
|
* anything checked its size, the cap then reported a number nobody survived to read. */
|
|
@@ -873,6 +1009,11 @@ const CONTENT_TYPES = {
|
|
|
873
1009
|
".gif": "image/gif",
|
|
874
1010
|
".mp4": "video/mp4",
|
|
875
1011
|
".webm": "video/webm",
|
|
1012
|
+
".m4v": "video/mp4",
|
|
1013
|
+
".mov": "video/quicktime",
|
|
1014
|
+
".mkv": "video/x-matroska",
|
|
1015
|
+
".avi": "video/x-msvideo",
|
|
1016
|
+
".aac": "audio/aac",
|
|
876
1017
|
".flac": "audio/flac",
|
|
877
1018
|
".mp3": "audio/mpeg",
|
|
878
1019
|
".opus": "audio/ogg",
|
|
@@ -903,6 +1044,31 @@ function isImageMagic(b) {
|
|
|
903
1044
|
if (at(4, 102, 116, 121, 112)) return true;
|
|
904
1045
|
return false;
|
|
905
1046
|
}
|
|
1047
|
+
/** the same full-signature sniff for every medium: a var of one kind never reads a file of
|
|
1048
|
+
* another. mp4, mov and m4a share the isobmff `ftyp` box, the extension floor tells them apart */
|
|
1049
|
+
function isMediaMagic(kind, b) {
|
|
1050
|
+
const at = (i, ...want) => want.every((w, k) => b[i + k] === w);
|
|
1051
|
+
const isobmff = at(4, 102, 116, 121, 112);
|
|
1052
|
+
if (kind === "image") return isImageMagic(b);
|
|
1053
|
+
if (kind === "audio") {
|
|
1054
|
+
if (at(0, 82, 73, 70, 70) && at(8, 87, 65, 86, 69)) return true;
|
|
1055
|
+
if (at(0, 102, 76, 97, 67)) return true;
|
|
1056
|
+
if (at(0, 79, 103, 103, 83)) return true;
|
|
1057
|
+
if (at(0, 73, 68, 51)) return true;
|
|
1058
|
+
const b0 = b[0];
|
|
1059
|
+
const b1 = b[1];
|
|
1060
|
+
const b2 = b[2];
|
|
1061
|
+
if (b0 === 255 && b1 != null && b1 !== 254 && b2 != null && (b1 & 224) === 224 && (b1 & 24) !== 8 && (b1 & 6) !== 0 && b2 >> 4 !== 15 && (b2 >> 2 & 3) !== 3) return true;
|
|
1062
|
+
if (b0 === 255 && b1 != null && (b1 & 246) === 240) return true;
|
|
1063
|
+
return isobmff;
|
|
1064
|
+
}
|
|
1065
|
+
if (at(0, 26, 69, 223, 163)) return true;
|
|
1066
|
+
if (at(0, 82, 73, 70, 70) && at(8, 65, 86, 73, 32)) return true;
|
|
1067
|
+
return isobmff;
|
|
1068
|
+
}
|
|
1069
|
+
function isMediaKind(kind) {
|
|
1070
|
+
return MEDIA_KINDS.includes(kind);
|
|
1071
|
+
}
|
|
906
1072
|
function json(status, payload) {
|
|
907
1073
|
return {
|
|
908
1074
|
status,
|
|
@@ -920,7 +1086,8 @@ const USAGE = [
|
|
|
920
1086
|
"PUT /drafts/<module>/<draft> with { ...vars } — save (or duplicate to a new name) a draft",
|
|
921
1087
|
"DELETE /drafts/<module>/<draft> — delete that draft file",
|
|
922
1088
|
"GET /run/<module> — live run status · /run/<module>/preview — latent preview bytes",
|
|
923
|
-
"POST /upload with {\"name\",\"dataBase64\"} — store a browser file for an image var",
|
|
1089
|
+
"POST /upload with {\"name\",\"dataBase64\"} — store a browser file for an image, audio or video var",
|
|
1090
|
+
"GET /images|audio|video/<promptId>/<ix> — an output kept in memory (saving off)",
|
|
924
1091
|
"GET /tags/<module>/<var>?q=<text>&limit=<n> — tag completion from the list a prompt var declares (`tags`)",
|
|
925
1092
|
"GET /hosts/<hostId>/drift[?full=1] — what changed on the host since the schema was loaded (model files; node types with full=1)",
|
|
926
1093
|
"GET /lora-info/<hostId>/<lora> — display name + trigger words (local mirror)",
|
|
@@ -931,13 +1098,14 @@ const USAGE = [
|
|
|
931
1098
|
"PUT /prompt-enhancers/<name> with {\"text\"} — write one · DELETE /prompt-enhancers/<name> — remove it",
|
|
932
1099
|
"GET /llm-configs — the enhancer LLM configs (.comfy-ts/llm-configs/*.json)",
|
|
933
1100
|
"PUT /llm-configs/<name> with {provider, baseUrl, model, effort, thinkingOnly} · DELETE /llm-configs/<name>",
|
|
934
|
-
"GET /settings — { saveToDisk } · PUT /settings with {\"saveToDisk\"} — write outputs to disk, or keep them in memory",
|
|
1101
|
+
"GET /settings — { saveToDisk, memoryBudgetMb } · PUT /settings with {\"saveToDisk\"} — write outputs to disk, or keep them in memory; {\"memoryBudgetMb\"} caps what memory keeps",
|
|
935
1102
|
"GET /hosts — every host this process knows · PUT /hosts/<module> with {\"host\"} — run that workflow elsewhere",
|
|
936
1103
|
"POST /hosts/<hostId>/<interrupt|clear-queue|restart|refresh-loras|refresh-schema> — act on a ComfyUI host",
|
|
937
1104
|
"GET /hosts/<hostId>/ping — is that host answering right now (restart watch)",
|
|
938
1105
|
"GET /hosts/<hostId>/logs — the last lines of that host console",
|
|
939
1106
|
"GET /images/<promptId>/<ix> — an in-memory output (saving off), while the process lives",
|
|
940
1107
|
"GET /audio/<promptId>/<ix> — the same for an in-memory audio output",
|
|
1108
|
+
"GET /results — the last runs this process kept, for a reload · DELETE /results[/<promptId>] — forget them, freeing their memory",
|
|
941
1109
|
"GET /outputs/<path> — generated files"
|
|
942
1110
|
];
|
|
943
1111
|
/** content hash of the bundle, so the script URL CHANGES whenever the code does. no-store
|
|
@@ -972,15 +1140,18 @@ var ServeApp = class {
|
|
|
972
1140
|
set settings(next) {
|
|
973
1141
|
this.settingsCache = next;
|
|
974
1142
|
}
|
|
1143
|
+
get kept() {
|
|
1144
|
+
this.keptCache ??= new ResultHistory(this.settings.memoryBudgetMb * MB);
|
|
1145
|
+
return this.keptCache;
|
|
1146
|
+
}
|
|
975
1147
|
constructor(modules, opts = {}) {
|
|
976
1148
|
this.modules = modules;
|
|
977
1149
|
this.opts = opts;
|
|
978
1150
|
this.seedState = /* @__PURE__ */ new Map();
|
|
979
1151
|
this.chains = /* @__PURE__ */ new Map();
|
|
980
1152
|
this.settingsCache = null;
|
|
981
|
-
this.
|
|
1153
|
+
this.keptCache = null;
|
|
982
1154
|
this.tagsByModule = /* @__PURE__ */ new Map();
|
|
983
|
-
this.MEMORY_IMAGE_CAP = 60;
|
|
984
1155
|
this.tabs = null;
|
|
985
1156
|
this.tagSources = new TagSources({
|
|
986
1157
|
cacheDir: () => join(comfyts.baseFolder, "cache", "tags"),
|
|
@@ -1042,6 +1213,11 @@ var ServeApp = class {
|
|
|
1042
1213
|
if (segs[0] === "hosts" && segs.length === 3 && segs[1] != null && segs[2] === "drift") return await this.replyHostDrift(segs[1], req.url.includes("full=1"));
|
|
1043
1214
|
if (segs[0] === "images" && segs.length === 3 && segs[1] != null && segs[2] != null) return this.replyMemoryImage(`${segs[1]}/${segs[2]}`);
|
|
1044
1215
|
if (segs[0] === "audio" && segs.length === 3 && segs[1] != null && segs[2] != null) return this.replyMemoryImage(`audio/${segs[1]}/${segs[2]}`);
|
|
1216
|
+
if (segs[0] === "video" && segs.length === 3 && segs[1] != null && segs[2] != null) return this.replyMemoryImage(`video/${segs[1]}/${segs[2]}`);
|
|
1217
|
+
if (segs[0] === "results" && segs.length === 1) return json(200, {
|
|
1218
|
+
runs: this.kept.list(),
|
|
1219
|
+
memory: this.kept.usage()
|
|
1220
|
+
});
|
|
1045
1221
|
if (segs[0] === "outputs") return this.replyOutput(segs.slice(1));
|
|
1046
1222
|
return json(404, {
|
|
1047
1223
|
error: `no route: GET ${path}`,
|
|
@@ -1058,6 +1234,11 @@ var ServeApp = class {
|
|
|
1058
1234
|
if (req.method === "PUT" && segs[0] === "drafts" && segs.length === 3 && segs[1] != null && segs[2] != null) return await this.replySaveDraft(segs[1], segs[2], req);
|
|
1059
1235
|
if (req.method === "DELETE" && segs[0] === "drafts" && segs.length === 3 && segs[1] != null && segs[2] != null) return await this.replyDeleteDraft(segs[1], segs[2]);
|
|
1060
1236
|
if (req.method === "PUT" && segs[0] === "settings" && segs.length === 1) return this.replySaveSettings(req);
|
|
1237
|
+
if (req.method === "DELETE" && segs[0] === "results" && segs.length <= 2) {
|
|
1238
|
+
if (segs[1] == null) this.kept.clear();
|
|
1239
|
+
else this.kept.remove(segs[1]);
|
|
1240
|
+
return json(200, { memory: this.kept.usage() });
|
|
1241
|
+
}
|
|
1061
1242
|
if (req.method === "PUT" && segs[0] === "tabs" && segs.length === 1) return this.replySaveTabs(req);
|
|
1062
1243
|
if (req.method === "PUT" && segs[0] === "hosts" && segs.length === 2 && segs[1] != null) return this.replySetHost(segs[1], req);
|
|
1063
1244
|
if (req.method === "POST" && segs[0] === "hosts" && segs.length === 3 && segs[1] != null && segs[2] != null) return await this.replyHostAction(segs[1], segs[2]);
|
|
@@ -1318,7 +1499,7 @@ var ServeApp = class {
|
|
|
1318
1499
|
headers: NO_STORE
|
|
1319
1500
|
};
|
|
1320
1501
|
}
|
|
1321
|
-
/** browser file → local file
|
|
1502
|
+
/** browser file → local file a media var can point at (downloadInput family) */
|
|
1322
1503
|
replyUpload(req) {
|
|
1323
1504
|
let parsed;
|
|
1324
1505
|
try {
|
|
@@ -1689,21 +1870,16 @@ var ServeApp = class {
|
|
|
1689
1870
|
overrides: this.settings.hostOverride
|
|
1690
1871
|
});
|
|
1691
1872
|
}
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1873
|
+
memoryBlob(key, bytes, filename) {
|
|
1874
|
+
return {
|
|
1875
|
+
key,
|
|
1695
1876
|
bytes,
|
|
1696
|
-
contentType
|
|
1697
|
-
}
|
|
1698
|
-
while (this.memoryImages.size > this.MEMORY_IMAGE_CAP) {
|
|
1699
|
-
const oldest = this.memoryImages.keys().next();
|
|
1700
|
-
if (oldest.done === true) break;
|
|
1701
|
-
this.memoryImages.delete(oldest.value);
|
|
1702
|
-
}
|
|
1877
|
+
contentType: CONTENT_TYPES[extname(filename).toLowerCase()] ?? sniffImageContentType(bytes)
|
|
1878
|
+
};
|
|
1703
1879
|
}
|
|
1704
1880
|
replyMemoryImage(key) {
|
|
1705
|
-
const hit = this.
|
|
1706
|
-
if (hit == null) return json(404, { error: `no in-memory output '${key}' — it
|
|
1881
|
+
const hit = this.kept.blob(key);
|
|
1882
|
+
if (hit == null) return json(404, { error: `no in-memory output '${key}' — it was deleted, dropped past the ${this.settings.memoryBudgetMb} MB memory budget, or the server restarted. Turn saving on to keep outputs.` });
|
|
1707
1883
|
return {
|
|
1708
1884
|
status: 200,
|
|
1709
1885
|
contentType: hit.contentType,
|
|
@@ -1723,7 +1899,7 @@ var ServeApp = class {
|
|
|
1723
1899
|
} catch (e) {
|
|
1724
1900
|
return json(400, { error: `body is not valid json: ${extractErrorMessage(e)}` });
|
|
1725
1901
|
}
|
|
1726
|
-
if (parsed == null || typeof parsed !== "object" || Array.isArray(parsed)) return json(400, { error: "body must be { \"saveToDisk\"?: true | false, \"savePrefix\"?: { \"<module>\": \"path\" } }" });
|
|
1902
|
+
if (parsed == null || typeof parsed !== "object" || Array.isArray(parsed)) return json(400, { error: "body must be { \"saveToDisk\"?: true | false, \"savePrefix\"?: { \"<module>\": \"path\" }, \"memoryBudgetMb\"?: number }" });
|
|
1727
1903
|
const wanted = parsed;
|
|
1728
1904
|
let next = this.settings;
|
|
1729
1905
|
if (wanted.saveToDisk != null) {
|
|
@@ -1749,8 +1925,17 @@ var ServeApp = class {
|
|
|
1749
1925
|
savePrefix: prefixes
|
|
1750
1926
|
};
|
|
1751
1927
|
}
|
|
1928
|
+
if (wanted.memoryBudgetMb != null) {
|
|
1929
|
+
const mb = validMemoryBudgetMb(wanted.memoryBudgetMb);
|
|
1930
|
+
if (mb == null) return json(400, { error: "\"memoryBudgetMb\" must be a number of MB, 1 to 100000" });
|
|
1931
|
+
next = {
|
|
1932
|
+
...next,
|
|
1933
|
+
memoryBudgetMb: mb
|
|
1934
|
+
};
|
|
1935
|
+
}
|
|
1752
1936
|
const saveToDisk = next.saveToDisk;
|
|
1753
1937
|
this.settings = next;
|
|
1938
|
+
this.kept.setBudget(next.memoryBudgetMb * MB);
|
|
1754
1939
|
try {
|
|
1755
1940
|
writeServeSettings(this.settings);
|
|
1756
1941
|
} catch (e) {
|
|
@@ -2088,35 +2273,91 @@ var ServeApp = class {
|
|
|
2088
2273
|
}
|
|
2089
2274
|
const durationMs = Date.now() - t0;
|
|
2090
2275
|
if (execution.status === "Failure") {
|
|
2091
|
-
|
|
2276
|
+
const error = describeRunError(execution.data.error);
|
|
2277
|
+
console.error(`[serve] 🔴 ${mod.key}/${draft} failed after ${durationMs}ms: ${error}`);
|
|
2092
2278
|
return json(500, {
|
|
2093
2279
|
ok: false,
|
|
2094
2280
|
module: mod.key,
|
|
2095
2281
|
draft,
|
|
2096
2282
|
promptId: execution.data.id,
|
|
2097
2283
|
durationMs,
|
|
2098
|
-
error
|
|
2284
|
+
error
|
|
2099
2285
|
});
|
|
2100
2286
|
}
|
|
2101
2287
|
const produced = [`${execution.images.length} image(s)`];
|
|
2102
2288
|
const audios = execution.audios ?? [];
|
|
2103
2289
|
if (audios.length > 0) produced.push(`${audios.length} audio(s)`);
|
|
2290
|
+
const videos = execution.videos ?? [];
|
|
2291
|
+
if (videos.length > 0) produced.push(`${videos.length} video(s)`);
|
|
2104
2292
|
if ((execution.texts ?? []).length > 0) produced.push(`${(execution.texts ?? []).length} text(s)`);
|
|
2105
2293
|
console.log(`[serve] 🟢 ${mod.key}/${draft} done in ${(durationMs / 1e3).toFixed(1)}s · ${produced.join(" · ")}`);
|
|
2106
|
-
const
|
|
2107
|
-
|
|
2108
|
-
if (img.absPath != null || img.buffer == null)
|
|
2109
|
-
const key = `${execution.data.id}/${ix}`;
|
|
2110
|
-
this.rememberMemoryImage(key, img.buffer, img.filename);
|
|
2111
|
-
memoryKeys.set(ix, key);
|
|
2112
|
-
}
|
|
2113
|
-
const audioKeys = /* @__PURE__ */ new Map();
|
|
2114
|
-
for (const [ix, a] of audios.entries()) {
|
|
2115
|
-
if (a.absPath != null) continue;
|
|
2294
|
+
const blobs = [];
|
|
2295
|
+
const imageKeys = execution.images.map((img, ix) => {
|
|
2296
|
+
if (img.absPath != null || img.buffer == null) return null;
|
|
2116
2297
|
const key = `${execution.data.id}/${ix}`;
|
|
2117
|
-
this.
|
|
2118
|
-
|
|
2119
|
-
}
|
|
2298
|
+
blobs.push(this.memoryBlob(key, img.buffer, img.filename));
|
|
2299
|
+
return key;
|
|
2300
|
+
});
|
|
2301
|
+
const audioKeys = audios.map((a, ix) => {
|
|
2302
|
+
if (a.absPath != null) return null;
|
|
2303
|
+
const key = `audio/${execution.data.id}/${ix}`;
|
|
2304
|
+
blobs.push(this.memoryBlob(key, a.bytes, a.filename));
|
|
2305
|
+
return key;
|
|
2306
|
+
});
|
|
2307
|
+
const videoKeys = videos.map((a, ix) => {
|
|
2308
|
+
if (a.absPath != null) return null;
|
|
2309
|
+
const key = `video/${execution.data.id}/${ix}`;
|
|
2310
|
+
blobs.push(this.memoryBlob(key, a.bytes, a.filename));
|
|
2311
|
+
return key;
|
|
2312
|
+
});
|
|
2313
|
+
const memoryUrl = (route, key) => `/${route}/${key.split("/").slice(route === "images" ? 0 : 1).map((seg) => encodeURIComponent(seg)).join("/")}`;
|
|
2314
|
+
const record = {
|
|
2315
|
+
ok: true,
|
|
2316
|
+
module: mod.key,
|
|
2317
|
+
draft,
|
|
2318
|
+
promptId: execution.data.id,
|
|
2319
|
+
durationMs,
|
|
2320
|
+
finishedAt: Date.now(),
|
|
2321
|
+
seeds,
|
|
2322
|
+
savedToDisk: this.settings.saveToDisk,
|
|
2323
|
+
texts: (execution.texts ?? []).map((t) => ({
|
|
2324
|
+
nodeKey: t.nodeKey,
|
|
2325
|
+
text: t.text
|
|
2326
|
+
})),
|
|
2327
|
+
images: execution.images.map((img, ix) => {
|
|
2328
|
+
const key = imageKeys[ix];
|
|
2329
|
+
return {
|
|
2330
|
+
filename: img.filename,
|
|
2331
|
+
url: img.absPath != null ? this.outputUrl(img.absPath) : key != null ? memoryUrl("images", key) : null,
|
|
2332
|
+
absPath: img.absPath
|
|
2333
|
+
};
|
|
2334
|
+
}),
|
|
2335
|
+
audios: audios.map((a, ix) => {
|
|
2336
|
+
const key = audioKeys[ix];
|
|
2337
|
+
return {
|
|
2338
|
+
filename: a.filename,
|
|
2339
|
+
mime: a.mime,
|
|
2340
|
+
url: a.absPath != null ? this.outputUrl(a.absPath) : key != null ? memoryUrl("audio", key) : null,
|
|
2341
|
+
absPath: a.absPath
|
|
2342
|
+
};
|
|
2343
|
+
}),
|
|
2344
|
+
videos: videos.map((a, ix) => {
|
|
2345
|
+
const key = videoKeys[ix];
|
|
2346
|
+
return {
|
|
2347
|
+
filename: a.filename,
|
|
2348
|
+
mime: a.mime,
|
|
2349
|
+
url: a.absPath != null ? this.outputUrl(a.absPath) : key != null ? memoryUrl("video", key) : null,
|
|
2350
|
+
absPath: a.absPath
|
|
2351
|
+
};
|
|
2352
|
+
})
|
|
2353
|
+
};
|
|
2354
|
+
this.kept.add({
|
|
2355
|
+
record,
|
|
2356
|
+
imageKeys,
|
|
2357
|
+
audioKeys,
|
|
2358
|
+
videoKeys,
|
|
2359
|
+
blobs
|
|
2360
|
+
});
|
|
2120
2361
|
const first = execution.images[0];
|
|
2121
2362
|
if (req.accept?.includes("image/") && first != null) {
|
|
2122
2363
|
if (first.absPath != null) return {
|
|
@@ -2124,37 +2365,14 @@ var ServeApp = class {
|
|
|
2124
2365
|
contentType: CONTENT_TYPES[extname(first.absPath).toLowerCase()] ?? "application/octet-stream",
|
|
2125
2366
|
body: new Uint8Array(readFileSync(first.absPath))
|
|
2126
2367
|
};
|
|
2127
|
-
const inMemory = this.
|
|
2368
|
+
const inMemory = this.kept.blob(imageKeys[0] ?? "");
|
|
2128
2369
|
if (inMemory != null) return {
|
|
2129
2370
|
status: 200,
|
|
2130
2371
|
contentType: inMemory.contentType,
|
|
2131
2372
|
body: inMemory.bytes
|
|
2132
2373
|
};
|
|
2133
2374
|
}
|
|
2134
|
-
return json(200,
|
|
2135
|
-
ok: true,
|
|
2136
|
-
module: mod.key,
|
|
2137
|
-
draft,
|
|
2138
|
-
promptId: execution.data.id,
|
|
2139
|
-
durationMs,
|
|
2140
|
-
seeds,
|
|
2141
|
-
savedToDisk: this.settings.saveToDisk,
|
|
2142
|
-
texts: (execution.texts ?? []).map((t) => ({
|
|
2143
|
-
nodeKey: t.nodeKey,
|
|
2144
|
-
text: t.text
|
|
2145
|
-
})),
|
|
2146
|
-
images: execution.images.map((img, ix) => ({
|
|
2147
|
-
filename: img.filename,
|
|
2148
|
-
url: img.absPath != null ? this.outputUrl(img.absPath) : memoryKeys.has(ix) ? `/images/${(memoryKeys.get(ix) ?? "").split("/").map((seg) => encodeURIComponent(seg)).join("/")}` : null,
|
|
2149
|
-
absPath: img.absPath
|
|
2150
|
-
})),
|
|
2151
|
-
audios: audios.map((a, ix) => ({
|
|
2152
|
-
filename: a.filename,
|
|
2153
|
-
mime: a.mime,
|
|
2154
|
-
url: a.absPath != null ? this.outputUrl(a.absPath) : audioKeys.has(ix) ? `/audio/${(audioKeys.get(ix) ?? "").split("/").map((seg) => encodeURIComponent(seg)).join("/")}` : null,
|
|
2155
|
-
absPath: a.absPath
|
|
2156
|
-
}))
|
|
2157
|
-
});
|
|
2375
|
+
return json(200, record);
|
|
2158
2376
|
}
|
|
2159
2377
|
/** everything that touches the module's SHARED vars, under the module mutex */
|
|
2160
2378
|
async prepareAndStart(mod, draft, payload, seeds) {
|
|
@@ -2183,7 +2401,7 @@ var ServeApp = class {
|
|
|
2183
2401
|
error: `unknown var '${k}' — vars: ${[...varMap.keys()].join(", ")}`
|
|
2184
2402
|
};
|
|
2185
2403
|
let value = rawValue;
|
|
2186
|
-
if (varDef.kind
|
|
2404
|
+
if (isMediaKind(varDef.kind) && typeof rawValue === "string" && /^https?:\/\//.test(rawValue)) try {
|
|
2187
2405
|
value = await this.downloadInput(rawValue);
|
|
2188
2406
|
} catch (e) {
|
|
2189
2407
|
return {
|
|
@@ -2202,13 +2420,14 @@ var ServeApp = class {
|
|
|
2202
2420
|
};
|
|
2203
2421
|
}
|
|
2204
2422
|
for (const [k, varDef] of varMap) {
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2423
|
+
const kind = varDef.kind;
|
|
2424
|
+
if (!isMediaKind(kind)) continue;
|
|
2425
|
+
const media = varDef;
|
|
2426
|
+
if (!media.isSet()) continue;
|
|
2427
|
+
const abs = media.absPath();
|
|
2209
2428
|
const refuse = {
|
|
2210
2429
|
status: 400,
|
|
2211
|
-
error:
|
|
2430
|
+
error: `${kind} var '${k}': not a usable ${kind} file`
|
|
2212
2431
|
};
|
|
2213
2432
|
if (!existsSync(abs)) return refuse;
|
|
2214
2433
|
let real;
|
|
@@ -2222,8 +2441,8 @@ var ServeApp = class {
|
|
|
2222
2441
|
} catch {
|
|
2223
2442
|
return refuse;
|
|
2224
2443
|
}
|
|
2225
|
-
if (!
|
|
2226
|
-
if (!
|
|
2444
|
+
if (!serveAcceptsMediaExt(kind, media.extensions, extname(real).toLowerCase().replace(/^\./, ""))) return refuse;
|
|
2445
|
+
if (!looksLikeMedia(kind, real)) return refuse;
|
|
2227
2446
|
}
|
|
2228
2447
|
for (const [k, varDef] of varMap) {
|
|
2229
2448
|
if (varDef.kind !== "seed") continue;
|
|
@@ -2258,7 +2477,7 @@ var ServeApp = class {
|
|
|
2258
2477
|
host: runHost ?? void 0
|
|
2259
2478
|
}) };
|
|
2260
2479
|
} catch (e) {
|
|
2261
|
-
if (e instanceof Error && e.name === "ImageVarEmptyError") return {
|
|
2480
|
+
if (e instanceof Error && (e.name === "MediaVarEmptyError" || e.name === "ImageVarEmptyError")) return {
|
|
2262
2481
|
status: 400,
|
|
2263
2482
|
error: e.message
|
|
2264
2483
|
};
|
|
@@ -2535,6 +2754,8 @@ async function loadOrBuildWebJs() {
|
|
|
2535
2754
|
//#region src/cli/serve/run-serve.ts
|
|
2536
2755
|
const DEFAULT_PORT = 8288;
|
|
2537
2756
|
const BODY_CAP = 1e7;
|
|
2757
|
+
/** a video dropped on a media var rides POST /upload as base64 json: ~200 MB of file */
|
|
2758
|
+
const UPLOAD_BODY_CAP = 28e7;
|
|
2538
2759
|
function parseArgs(args) {
|
|
2539
2760
|
let target;
|
|
2540
2761
|
let port = DEFAULT_PORT;
|
|
@@ -2574,6 +2795,7 @@ function makeRequestListener(app) {
|
|
|
2574
2795
|
"access-control-allow-headers": "content-type, accept"
|
|
2575
2796
|
};
|
|
2576
2797
|
return (req, res) => {
|
|
2798
|
+
const cap = req.method === "POST" && (req.url ?? "").split("?")[0] === "/upload" ? UPLOAD_BODY_CAP : BODY_CAP;
|
|
2577
2799
|
const chunks = [];
|
|
2578
2800
|
let size = 0;
|
|
2579
2801
|
let overflow = false;
|
|
@@ -2581,7 +2803,7 @@ function makeRequestListener(app) {
|
|
|
2581
2803
|
req.on("data", (c) => {
|
|
2582
2804
|
if (overflow) return;
|
|
2583
2805
|
size += c.length;
|
|
2584
|
-
if (size >
|
|
2806
|
+
if (size > cap) {
|
|
2585
2807
|
overflow = true;
|
|
2586
2808
|
res.writeHead(413, {
|
|
2587
2809
|
"content-type": "application/json",
|
|
@@ -2713,4 +2935,4 @@ function printStartup(app, bind, port) {
|
|
|
2713
2935
|
//#endregion
|
|
2714
2936
|
export { runServe };
|
|
2715
2937
|
|
|
2716
|
-
//# sourceMappingURL=run-serve-
|
|
2938
|
+
//# sourceMappingURL=run-serve-B5PfIuhK.js.map
|