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
|
@@ -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;
|
|
@@ -690,11 +694,13 @@ var ResultHistory = class {
|
|
|
690
694
|
});
|
|
691
695
|
this.used += b.bytes.byteLength;
|
|
692
696
|
}
|
|
693
|
-
|
|
697
|
+
const kept = {
|
|
694
698
|
record: p.record,
|
|
695
699
|
imageKeys: p.imageKeys,
|
|
696
|
-
audioKeys: p.audioKeys
|
|
697
|
-
|
|
700
|
+
audioKeys: p.audioKeys,
|
|
701
|
+
videoKeys: p.videoKeys ?? []
|
|
702
|
+
};
|
|
703
|
+
this.runs = [kept, ...this.runs];
|
|
698
704
|
for (const dropped of this.runs.slice(50)) this.freeRun(dropped);
|
|
699
705
|
this.runs = this.runs.slice(0, 50);
|
|
700
706
|
this.evict();
|
|
@@ -707,7 +713,8 @@ var ResultHistory = class {
|
|
|
707
713
|
return this.runs.map((k) => ({
|
|
708
714
|
...k.record,
|
|
709
715
|
images: k.record.images.map((img, ix) => this.withLiveUrl(img, k.imageKeys[ix])),
|
|
710
|
-
audios: k.record.audios.map((a, ix) => this.withLiveUrl(a, k.audioKeys[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]))
|
|
711
718
|
}));
|
|
712
719
|
}
|
|
713
720
|
remove(promptId) {
|
|
@@ -741,7 +748,11 @@ var ResultHistory = class {
|
|
|
741
748
|
};
|
|
742
749
|
}
|
|
743
750
|
freeRun(k) {
|
|
744
|
-
for (const key of [
|
|
751
|
+
for (const key of [
|
|
752
|
+
...k.imageKeys,
|
|
753
|
+
...k.audioKeys,
|
|
754
|
+
...k.videoKeys
|
|
755
|
+
]) {
|
|
745
756
|
if (key == null) continue;
|
|
746
757
|
const b = this.blobs.get(key);
|
|
747
758
|
if (b == null) continue;
|
|
@@ -761,8 +772,8 @@ var ResultHistory = class {
|
|
|
761
772
|
this.runs = this.runs.filter((k) => {
|
|
762
773
|
const live = (keys) => keys.some((key) => key == null || this.blobs.has(key));
|
|
763
774
|
const hasText = k.record.texts.length > 0;
|
|
764
|
-
const hasNothing = k.record.images.length === 0 && k.record.audios.length === 0;
|
|
765
|
-
return hasText || hasNothing || live(k.imageKeys) || live(k.audioKeys);
|
|
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);
|
|
766
777
|
});
|
|
767
778
|
}
|
|
768
779
|
};
|
|
@@ -887,27 +898,31 @@ function readTabs(raw, modules) {
|
|
|
887
898
|
}
|
|
888
899
|
//#endregion
|
|
889
900
|
//#region src/cli/serve/ServeApp.ts
|
|
890
|
-
/** what serve will read off the disk and upload. Wider than the picker
|
|
891
|
-
* LoadImage takes bmp and tiff too, and a var declaring one of those must not be refused */
|
|
892
|
-
const
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
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
|
+
};
|
|
899
914
|
/** the first bytes say what a file IS; the name only says what it claims. Cheap, and it stops
|
|
900
915
|
* a .png that holds a key or a script from being read and uploaded to the host.
|
|
901
916
|
* HONEST LIMIT: this is checked before the run, and the file is read again when the graph
|
|
902
917
|
* builds, so a local writer who can swap the path in between still wins. Closing that needs
|
|
903
918
|
* the upload to hold an fd, which is a bigger change than this gate. */
|
|
904
|
-
function
|
|
919
|
+
function looksLikeMedia(kind, path) {
|
|
905
920
|
let fd = null;
|
|
906
921
|
try {
|
|
907
922
|
fd = openSync(path, "r");
|
|
908
923
|
const head = /* @__PURE__ */ new Uint8Array(16);
|
|
909
924
|
const n = readSync(fd, head, 0, 16, 0);
|
|
910
|
-
return
|
|
925
|
+
return isMediaMagic(kind, head.subarray(0, n));
|
|
911
926
|
} catch {
|
|
912
927
|
return false;
|
|
913
928
|
} finally {
|
|
@@ -919,10 +934,11 @@ function looksLikeImage(path) {
|
|
|
919
934
|
* the gate: a workflow author narrowing (or emptying) it for listing reasons must not be able
|
|
920
935
|
* to widen what an unauthenticated request can make the server read. The var may narrow this
|
|
921
936
|
* floor, never leave it. */
|
|
922
|
-
function
|
|
937
|
+
function serveAcceptsMediaExt(kind, declared, ext) {
|
|
938
|
+
const floor = SERVE_MEDIA_FLOOR[kind];
|
|
923
939
|
if (ext === "") return false;
|
|
924
|
-
if (!
|
|
925
|
-
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));
|
|
926
942
|
return narrowed.length === 0 || narrowed.includes(ext);
|
|
927
943
|
}
|
|
928
944
|
/** an image var pointing at a url downloads it: capped, because the inbound BODY cap does not
|
|
@@ -993,6 +1009,11 @@ const CONTENT_TYPES = {
|
|
|
993
1009
|
".gif": "image/gif",
|
|
994
1010
|
".mp4": "video/mp4",
|
|
995
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",
|
|
996
1017
|
".flac": "audio/flac",
|
|
997
1018
|
".mp3": "audio/mpeg",
|
|
998
1019
|
".opus": "audio/ogg",
|
|
@@ -1023,6 +1044,31 @@ function isImageMagic(b) {
|
|
|
1023
1044
|
if (at(4, 102, 116, 121, 112)) return true;
|
|
1024
1045
|
return false;
|
|
1025
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
|
+
}
|
|
1026
1072
|
function json(status, payload) {
|
|
1027
1073
|
return {
|
|
1028
1074
|
status,
|
|
@@ -1040,7 +1086,8 @@ const USAGE = [
|
|
|
1040
1086
|
"PUT /drafts/<module>/<draft> with { ...vars } — save (or duplicate to a new name) a draft",
|
|
1041
1087
|
"DELETE /drafts/<module>/<draft> — delete that draft file",
|
|
1042
1088
|
"GET /run/<module> — live run status · /run/<module>/preview — latent preview bytes",
|
|
1043
|
-
"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)",
|
|
1044
1091
|
"GET /tags/<module>/<var>?q=<text>&limit=<n> — tag completion from the list a prompt var declares (`tags`)",
|
|
1045
1092
|
"GET /hosts/<hostId>/drift[?full=1] — what changed on the host since the schema was loaded (model files; node types with full=1)",
|
|
1046
1093
|
"GET /lora-info/<hostId>/<lora> — display name + trigger words (local mirror)",
|
|
@@ -1166,6 +1213,7 @@ var ServeApp = class {
|
|
|
1166
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"));
|
|
1167
1214
|
if (segs[0] === "images" && segs.length === 3 && segs[1] != null && segs[2] != null) return this.replyMemoryImage(`${segs[1]}/${segs[2]}`);
|
|
1168
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]}`);
|
|
1169
1217
|
if (segs[0] === "results" && segs.length === 1) return json(200, {
|
|
1170
1218
|
runs: this.kept.list(),
|
|
1171
1219
|
memory: this.kept.usage()
|
|
@@ -1451,7 +1499,7 @@ var ServeApp = class {
|
|
|
1451
1499
|
headers: NO_STORE
|
|
1452
1500
|
};
|
|
1453
1501
|
}
|
|
1454
|
-
/** browser file → local file
|
|
1502
|
+
/** browser file → local file a media var can point at (downloadInput family) */
|
|
1455
1503
|
replyUpload(req) {
|
|
1456
1504
|
let parsed;
|
|
1457
1505
|
try {
|
|
@@ -2239,6 +2287,8 @@ var ServeApp = class {
|
|
|
2239
2287
|
const produced = [`${execution.images.length} image(s)`];
|
|
2240
2288
|
const audios = execution.audios ?? [];
|
|
2241
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)`);
|
|
2242
2292
|
if ((execution.texts ?? []).length > 0) produced.push(`${(execution.texts ?? []).length} text(s)`);
|
|
2243
2293
|
console.log(`[serve] 🟢 ${mod.key}/${draft} done in ${(durationMs / 1e3).toFixed(1)}s · ${produced.join(" · ")}`);
|
|
2244
2294
|
const blobs = [];
|
|
@@ -2254,7 +2304,13 @@ var ServeApp = class {
|
|
|
2254
2304
|
blobs.push(this.memoryBlob(key, a.bytes, a.filename));
|
|
2255
2305
|
return key;
|
|
2256
2306
|
});
|
|
2257
|
-
const
|
|
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("/")}`;
|
|
2258
2314
|
const record = {
|
|
2259
2315
|
ok: true,
|
|
2260
2316
|
module: mod.key,
|
|
@@ -2284,12 +2340,22 @@ var ServeApp = class {
|
|
|
2284
2340
|
url: a.absPath != null ? this.outputUrl(a.absPath) : key != null ? memoryUrl("audio", key) : null,
|
|
2285
2341
|
absPath: a.absPath
|
|
2286
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
|
+
};
|
|
2287
2352
|
})
|
|
2288
2353
|
};
|
|
2289
2354
|
this.kept.add({
|
|
2290
2355
|
record,
|
|
2291
2356
|
imageKeys,
|
|
2292
2357
|
audioKeys,
|
|
2358
|
+
videoKeys,
|
|
2293
2359
|
blobs
|
|
2294
2360
|
});
|
|
2295
2361
|
const first = execution.images[0];
|
|
@@ -2335,7 +2401,7 @@ var ServeApp = class {
|
|
|
2335
2401
|
error: `unknown var '${k}' — vars: ${[...varMap.keys()].join(", ")}`
|
|
2336
2402
|
};
|
|
2337
2403
|
let value = rawValue;
|
|
2338
|
-
if (varDef.kind
|
|
2404
|
+
if (isMediaKind(varDef.kind) && typeof rawValue === "string" && /^https?:\/\//.test(rawValue)) try {
|
|
2339
2405
|
value = await this.downloadInput(rawValue);
|
|
2340
2406
|
} catch (e) {
|
|
2341
2407
|
return {
|
|
@@ -2354,13 +2420,14 @@ var ServeApp = class {
|
|
|
2354
2420
|
};
|
|
2355
2421
|
}
|
|
2356
2422
|
for (const [k, varDef] of varMap) {
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2423
|
+
const kind = varDef.kind;
|
|
2424
|
+
if (!isMediaKind(kind)) continue;
|
|
2425
|
+
const media = varDef;
|
|
2426
|
+
if (!media.isSet()) continue;
|
|
2427
|
+
const abs = media.absPath();
|
|
2361
2428
|
const refuse = {
|
|
2362
2429
|
status: 400,
|
|
2363
|
-
error:
|
|
2430
|
+
error: `${kind} var '${k}': not a usable ${kind} file`
|
|
2364
2431
|
};
|
|
2365
2432
|
if (!existsSync(abs)) return refuse;
|
|
2366
2433
|
let real;
|
|
@@ -2374,8 +2441,8 @@ var ServeApp = class {
|
|
|
2374
2441
|
} catch {
|
|
2375
2442
|
return refuse;
|
|
2376
2443
|
}
|
|
2377
|
-
if (!
|
|
2378
|
-
if (!
|
|
2444
|
+
if (!serveAcceptsMediaExt(kind, media.extensions, extname(real).toLowerCase().replace(/^\./, ""))) return refuse;
|
|
2445
|
+
if (!looksLikeMedia(kind, real)) return refuse;
|
|
2379
2446
|
}
|
|
2380
2447
|
for (const [k, varDef] of varMap) {
|
|
2381
2448
|
if (varDef.kind !== "seed") continue;
|
|
@@ -2410,7 +2477,7 @@ var ServeApp = class {
|
|
|
2410
2477
|
host: runHost ?? void 0
|
|
2411
2478
|
}) };
|
|
2412
2479
|
} catch (e) {
|
|
2413
|
-
if (e instanceof Error && e.name === "ImageVarEmptyError") return {
|
|
2480
|
+
if (e instanceof Error && (e.name === "MediaVarEmptyError" || e.name === "ImageVarEmptyError")) return {
|
|
2414
2481
|
status: 400,
|
|
2415
2482
|
error: e.message
|
|
2416
2483
|
};
|
|
@@ -2687,6 +2754,8 @@ async function loadOrBuildWebJs() {
|
|
|
2687
2754
|
//#region src/cli/serve/run-serve.ts
|
|
2688
2755
|
const DEFAULT_PORT = 8288;
|
|
2689
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;
|
|
2690
2759
|
function parseArgs(args) {
|
|
2691
2760
|
let target;
|
|
2692
2761
|
let port = DEFAULT_PORT;
|
|
@@ -2726,6 +2795,7 @@ function makeRequestListener(app) {
|
|
|
2726
2795
|
"access-control-allow-headers": "content-type, accept"
|
|
2727
2796
|
};
|
|
2728
2797
|
return (req, res) => {
|
|
2798
|
+
const cap = req.method === "POST" && (req.url ?? "").split("?")[0] === "/upload" ? UPLOAD_BODY_CAP : BODY_CAP;
|
|
2729
2799
|
const chunks = [];
|
|
2730
2800
|
let size = 0;
|
|
2731
2801
|
let overflow = false;
|
|
@@ -2733,7 +2803,7 @@ function makeRequestListener(app) {
|
|
|
2733
2803
|
req.on("data", (c) => {
|
|
2734
2804
|
if (overflow) return;
|
|
2735
2805
|
size += c.length;
|
|
2736
|
-
if (size >
|
|
2806
|
+
if (size > cap) {
|
|
2737
2807
|
overflow = true;
|
|
2738
2808
|
res.writeHead(413, {
|
|
2739
2809
|
"content-type": "application/json",
|
|
@@ -2865,4 +2935,4 @@ function printStartup(app, bind, port) {
|
|
|
2865
2935
|
//#endregion
|
|
2866
2936
|
export { runServe };
|
|
2867
2937
|
|
|
2868
|
-
//# sourceMappingURL=run-serve-
|
|
2938
|
+
//# sourceMappingURL=run-serve-B5PfIuhK.js.map
|