comfy-ts 2.22.0 → 2.24.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.
Files changed (99) hide show
  1. package/dist/{ServeApp-DuxYdaZZ.js → ServeApp-fsHtW5zG.js} +51 -17
  2. package/dist/ServeApp-fsHtW5zG.js.map +1 -0
  3. package/dist/cli.js +5 -5
  4. package/dist/{exampleAssets-1NHndnNB.js → exampleAssets-DZynSkZm.js} +405 -39
  5. package/dist/exampleAssets-DZynSkZm.js.map +1 -0
  6. package/dist/{findDefinedWorkflow-CRsBTTJK.js → findDefinedWorkflow-qyqFea7q.js} +2 -2
  7. package/dist/{findDefinedWorkflow-CRsBTTJK.js.map → findDefinedWorkflow-qyqFea7q.js.map} +1 -1
  8. package/dist/index.cjs +428 -46
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.cts +147 -1
  11. package/dist/index.d.ts +147 -1
  12. package/dist/index.js +428 -47
  13. package/dist/index.js.map +1 -1
  14. package/dist/{run-run-Y5ZI48vV.js → run-run-Cn2JzKlE.js} +5 -5
  15. package/dist/{run-run-Y5ZI48vV.js.map → run-run-Cn2JzKlE.js.map} +1 -1
  16. package/dist/{run-serve-CICU_wTL.js → run-serve-BhGegaCI.js} +4 -4
  17. package/dist/{run-serve-CICU_wTL.js.map → run-serve-BhGegaCI.js.map} +1 -1
  18. package/dist/{run-tui-CViJXsHL.js → run-tui-CrM4ijkH.js} +4 -4
  19. package/dist/{run-tui-CViJXsHL.js.map → run-tui-CrM4ijkH.js.map} +1 -1
  20. package/dist/{schemaDrift-CzjaIwZX.js → schemaDrift-BGYJZGMD.js} +18 -3
  21. package/dist/{schemaDrift-CzjaIwZX.js.map → schemaDrift-BGYJZGMD.js.map} +1 -1
  22. package/dist/serve-web.js +46 -43
  23. package/dist/web.d.ts +147 -1
  24. package/dist/web.js +428 -47
  25. package/dist/web.js.map +1 -1
  26. package/examples/README.md +1 -0
  27. package/examples/comfy-cloud/sdk.d.ts +102 -1
  28. package/examples/depth-explorer/models.ts +6 -56
  29. package/examples/depth-explorer/serve.ts +12 -133
  30. package/examples/depth-explorer/web/App.tsx +20 -91
  31. package/examples/depth-explorer/web/index.html +1 -0
  32. package/examples/depth-explorer/web/state.ts +26 -109
  33. package/examples/depth-explorer/web/styles.css +1 -286
  34. package/examples/explorer-kit/catalog.ts +80 -0
  35. package/examples/explorer-kit/server.ts +167 -0
  36. package/examples/explorer-kit/web/base.css +289 -0
  37. package/examples/explorer-kit/web/runs.ts +160 -0
  38. package/examples/explorer-kit/web/ui.tsx +125 -0
  39. package/examples/rvion/17-relight.cflow.ts +2 -1
  40. package/examples/rvion/18-world.cflow.ts +101 -0
  41. package/examples/rvion/19-flythrough.cflow.ts +312 -0
  42. package/examples/rvion/20-grow-splat.cflow.ts +88 -0
  43. package/examples/rvion/21-photo-to-model.cflow.ts +191 -0
  44. package/examples/rvion/flythroughChain.ts +171 -0
  45. package/examples/rvion/flythroughColmap.ts +157 -0
  46. package/examples/rvion/flythroughFuse.ts +199 -0
  47. package/examples/rvion/flythroughGuide.ts +300 -0
  48. package/examples/rvion/flythroughPalette.ts +310 -0
  49. package/examples/rvion/flythroughPath.ts +177 -0
  50. package/examples/rvion/flythroughSplat.ts +73 -0
  51. package/examples/rvion/grow-splat/align.ts +114 -0
  52. package/examples/rvion/grow-splat/grow.ts +198 -0
  53. package/examples/rvion/grow-splat/ply.ts +166 -0
  54. package/examples/rvion/grow-splat/raster.ts +207 -0
  55. package/examples/rvion/grow-splat/sharp.ts +45 -0
  56. package/examples/rvion/splatDataset.ts +80 -0
  57. package/examples/rvion/splatEval.ts +380 -0
  58. package/examples/upscale-explorer/models.ts +341 -0
  59. package/examples/upscale-explorer/serve.ts +19 -0
  60. package/examples/upscale-explorer/web/App.tsx +250 -0
  61. package/examples/upscale-explorer/web/compare.tsx +285 -0
  62. package/examples/upscale-explorer/web/index.html +15 -0
  63. package/examples/upscale-explorer/web/main.tsx +12 -0
  64. package/examples/upscale-explorer/web/state.ts +279 -0
  65. package/examples/upscale-explorer/web/styles.css +241 -0
  66. package/examples/upscale-explorer/web/tsconfig.json +16 -0
  67. package/examples/upscale-explorer/web/viewport.tsx +130 -0
  68. package/examples/world-explorer/serve.ts +171 -0
  69. package/examples/world-explorer/web/index.html +14 -0
  70. package/examples/world-explorer/web/main.tsx +200 -0
  71. package/examples/world-explorer/web/state.ts +212 -0
  72. package/examples/world-explorer/web/styles.css +131 -0
  73. package/examples/world-explorer/web/thumb.ts +21 -0
  74. package/examples/world-explorer/web/tsconfig.json +11 -0
  75. package/examples/world-explorer/world-state.ts +40 -0
  76. package/package.json +7 -8
  77. package/src/cli/serve/ServeApp.ts +27 -2
  78. package/src/cli/serve/resultHistory.ts +22 -4
  79. package/src/cli/serve/thumbs.ts +19 -8
  80. package/src/cli/serve/web/api.ts +4 -0
  81. package/src/cli/serve/web/components/Gallery.tsx +24 -1
  82. package/src/cli/serve/web/styles.ts +3 -0
  83. package/src/coreExports.ts +6 -0
  84. package/src/graph/ComfyNode.ts +12 -2
  85. package/src/host/ComfyHost.ts +159 -2
  86. package/src/host/ResilientWebsocket.ts +10 -0
  87. package/src/manager/script-update-manager.bun.ts +0 -7
  88. package/src/runner/ComfyExecution.ts +185 -23
  89. package/src/runner/ComfyWorkflow.ts +22 -0
  90. package/src/runner/ComfyWsApi.ts +3 -1
  91. package/src/runner/comfyOrgApiKey.ts +44 -0
  92. package/src/runner/historyReplay.ts +53 -0
  93. package/src/runner/outputs3d.ts +18 -0
  94. package/src/sdk-generator/ComfyUIObjectInfoTypes.ts +2 -0
  95. package/src/sdk-generator/comfyui-sdk-codegen.ts +7 -2
  96. package/src/state.ts +2 -0
  97. package/src/vars/DefinedWorkflow.ts +1 -0
  98. package/dist/ServeApp-DuxYdaZZ.js.map +0 -1
  99. package/dist/exampleAssets-1NHndnNB.js.map +0 -1
@@ -1,5 +1,5 @@
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, R as lmCivitai, S as getLoraTriggerWords, T as loraMirrorEntries, U as lmNotes, V as lmFolder, W as lmSha256, X as ansi, Y as loraPreviewMapFrom, _ as buildLoraMirror, at as importSharp, b as getLoraInfo, c as isLoraLanes, d as isLoraStrength, et as MEDIA_KINDS, gt as extractErrorMessage, 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-CzjaIwZX.js";
2
- import { d as isDraftMetaKey, l as assembleLogChunks, o as draftsDirForFile, s as listDraftsForFile, u as ENHANCE_KEY } from "./findDefinedWorkflow-CRsBTTJK.js";
1
+ import { $ as MODEL_3D_MIMES, 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, R as lmCivitai, S as getLoraTriggerWords, T as loraMirrorEntries, U as lmNotes, V as lmFolder, W as lmSha256, X as ansi, Y as loraPreviewMapFrom, _ as buildLoraMirror, _t as sha1HexOfString, b as getLoraInfo, c as isLoraLanes, d as isLoraStrength, gt as statelessRegex, i as summarizeDrift, j as writeLoraMirror, k as refreshLoraInfoCacheIfChanged, l as isLorasInput, lt as bang, nt as MEDIA_KINDS, p as getLoraKeyword, r as driftChanged, st as importSharp, tt as DEFAULT_MEDIA_EXTENSIONS, u as isPromptInput, v as getLoraAddedAt, vt as extractErrorMessage, x as getLoraPreviewUrl, y as getLoraDisplayName, z as lmFilePath } from "./schemaDrift-BGYJZGMD.js";
2
+ import { d as isDraftMetaKey, l as assembleLogChunks, o as draftsDirForFile, s as listDraftsForFile, u as ENHANCE_KEY } from "./findDefinedWorkflow-qyqFea7q.js";
3
3
  import { homedir } from "node:os";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { closeSync, existsSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
@@ -150,6 +150,21 @@ const isHttpUrl = (s) => /^https?:\/\//i.test(s);
150
150
  function thumbUrl(abs, width = 160) {
151
151
  return `/thumb?src=${encodeURIComponent(abs)}&w=${width}`;
152
152
  }
153
+ /** Bun's own image pipeline when the server runs on Bun, sharp only under Node (the cli runs on
154
+ * both). Both read the EXIF orientation */
155
+ async function webpThumb(path, width) {
156
+ if (typeof Bun !== "undefined") return new Bun.Image(path).resize(width, width, {
157
+ fit: "inside",
158
+ withoutEnlargement: true
159
+ }).webp({ quality: 78 }).bytes();
160
+ const sharp = await importSharp("a thumbnail");
161
+ return new Uint8Array(await sharp(path).rotate().resize({
162
+ width,
163
+ height: width,
164
+ fit: "inside",
165
+ withoutEnlargement: true
166
+ }).webp({ quality: 78 }).toBuffer());
167
+ }
153
168
  const MAX_WIDTH = 640;
154
169
  const MAX_CACHED = 400;
155
170
  var ThumbStore = class {
@@ -182,13 +197,7 @@ var ThumbStore = class {
182
197
  const key = `${p}|${statSync(p).mtimeMs}|${w}`;
183
198
  const hit = this.cache.get(key);
184
199
  if (hit != null) return hit;
185
- const sharp = await importSharp("a thumbnail");
186
- const bytes = new Uint8Array(await sharp(p).rotate().resize({
187
- width: w,
188
- height: w,
189
- fit: "inside",
190
- withoutEnlargement: true
191
- }).webp({ quality: 78 }).toBuffer());
200
+ const bytes = await webpThumb(p, w);
192
201
  if (this.cache.size >= MAX_CACHED) {
193
202
  const oldest = this.cache.keys().next().value;
194
203
  if (oldest != null) this.cache.delete(oldest);
@@ -754,7 +763,8 @@ var ResultHistory = class {
754
763
  record: p.record,
755
764
  imageKeys: p.imageKeys,
756
765
  audioKeys: p.audioKeys,
757
- videoKeys: p.videoKeys ?? []
766
+ videoKeys: p.videoKeys ?? [],
767
+ model3dKeys: p.model3dKeys ?? []
758
768
  };
759
769
  this.runs = [kept, ...this.runs];
760
770
  for (const dropped of this.runs.slice(50)) this.freeRun(dropped);
@@ -770,7 +780,8 @@ var ResultHistory = class {
770
780
  ...k.record,
771
781
  images: k.record.images.map((img, ix) => this.withLiveUrl(img, k.imageKeys[ix])),
772
782
  audios: k.record.audios.map((a, ix) => this.withLiveUrl(a, k.audioKeys[ix])),
773
- videos: (k.record.videos ?? []).map((a, ix) => this.withLiveUrl(a, k.videoKeys[ix]))
783
+ videos: (k.record.videos ?? []).map((a, ix) => this.withLiveUrl(a, k.videoKeys[ix])),
784
+ models3d: (k.record.models3d ?? []).map((a, ix) => this.withLiveUrl(a, k.model3dKeys[ix]))
774
785
  }));
775
786
  }
776
787
  remove(promptId) {
@@ -807,7 +818,8 @@ var ResultHistory = class {
807
818
  for (const key of [
808
819
  ...k.imageKeys,
809
820
  ...k.audioKeys,
810
- ...k.videoKeys
821
+ ...k.videoKeys,
822
+ ...k.model3dKeys
811
823
  ]) {
812
824
  if (key == null) continue;
813
825
  const b = this.blobs.get(key);
@@ -828,8 +840,8 @@ var ResultHistory = class {
828
840
  this.runs = this.runs.filter((k) => {
829
841
  const live = (keys) => keys.some((key) => key == null || this.blobs.has(key));
830
842
  const hasText = k.record.texts.length > 0;
831
- const hasNothing = k.record.images.length === 0 && k.record.audios.length === 0 && (k.record.videos ?? []).length === 0;
832
- return hasText || hasNothing || live(k.imageKeys) || live(k.audioKeys) || live(k.videoKeys);
843
+ const hasNothing = k.record.images.length === 0 && k.record.audios.length === 0 && (k.record.videos ?? []).length === 0 && (k.record.models3d ?? []).length === 0;
844
+ return hasText || hasNothing || live(k.imageKeys) || live(k.audioKeys) || live(k.videoKeys) || live(k.model3dKeys);
833
845
  });
834
846
  }
835
847
  };
@@ -1080,7 +1092,8 @@ const CONTENT_TYPES = {
1080
1092
  ".wav": "audio/wav",
1081
1093
  ".m4a": "audio/mp4",
1082
1094
  ".json": "application/json",
1083
- ".txt": "text/plain"
1095
+ ".txt": "text/plain",
1096
+ ...Object.fromEntries(Object.entries(MODEL_3D_MIMES).map(([ext, mime]) => [`.${ext}`, mime]))
1084
1097
  };
1085
1098
  /** magic-byte sniff for the preview proxy — fetchLoraPreviewBytes already guarantees an image */
1086
1099
  function sniffImageContentType(bytes) {
@@ -1146,7 +1159,7 @@ const USAGE = [
1146
1159
  "DELETE /drafts/<module>/<draft> — delete that draft file",
1147
1160
  "GET /run/<module> — live run status · /run/<module>/preview — latent preview bytes",
1148
1161
  "POST /upload with {\"name\",\"dataBase64\"} — store a browser file for an image, audio or video var",
1149
- "GET /images|audio|video/<promptId>/<ix> — an output kept in memory (saving off)",
1162
+ "GET /images|audio|video|model3d/<promptId>/<ix> — an output kept in memory (saving off)",
1150
1163
  "GET /tags/<module>/<var>?q=<text>&limit=<n> — tag completion from the list a prompt var declares (`tags`)",
1151
1164
  "GET /hosts/<hostId>/drift[?full=1] — what changed on the host since the schema was loaded (model files; node types with full=1)",
1152
1165
  "GET /lora-info/<hostId>/<lora> — display name + trigger words (local mirror)",
@@ -1273,6 +1286,7 @@ var ServeApp = class {
1273
1286
  if (segs[0] === "images" && segs.length === 3 && segs[1] != null && segs[2] != null) return this.replyMemoryImage(`${segs[1]}/${segs[2]}`);
1274
1287
  if (segs[0] === "audio" && segs.length === 3 && segs[1] != null && segs[2] != null) return this.replyMemoryImage(`audio/${segs[1]}/${segs[2]}`);
1275
1288
  if (segs[0] === "video" && segs.length === 3 && segs[1] != null && segs[2] != null) return this.replyMemoryImage(`video/${segs[1]}/${segs[2]}`);
1289
+ if (segs[0] === "model3d" && segs.length === 3 && segs[1] != null && segs[2] != null) return this.replyMemoryImage(`model3d/${segs[1]}/${segs[2]}`);
1276
1290
  if (segs[0] === "results" && segs.length === 1) return json(200, {
1277
1291
  runs: this.kept.list(),
1278
1292
  memory: this.kept.usage()
@@ -2400,6 +2414,8 @@ var ServeApp = class {
2400
2414
  if (audios.length > 0) produced.push(`${audios.length} audio(s)`);
2401
2415
  const videos = execution.videos ?? [];
2402
2416
  if (videos.length > 0) produced.push(`${videos.length} video(s)`);
2417
+ const models3d = execution.models3d ?? [];
2418
+ if (models3d.length > 0) produced.push(`${models3d.length} 3d model(s)`);
2403
2419
  if ((execution.texts ?? []).length > 0) produced.push(`${(execution.texts ?? []).length} text(s)`);
2404
2420
  console.log(`[serve] 🟢 ${mod.key}/${draft} done in ${(durationMs / 1e3).toFixed(1)}s · ${produced.join(" · ")}`);
2405
2421
  const blobs = [];
@@ -2421,6 +2437,12 @@ var ServeApp = class {
2421
2437
  blobs.push(this.memoryBlob(key, a.bytes, a.filename));
2422
2438
  return key;
2423
2439
  });
2440
+ const model3dKeys = models3d.map((m, ix) => {
2441
+ if (m.absPath != null) return null;
2442
+ const key = `model3d/${execution.data.id}/${ix}`;
2443
+ blobs.push(this.memoryBlob(key, m.bytes, m.filename));
2444
+ return key;
2445
+ });
2424
2446
  const memoryUrl = (route, key) => `/${route}/${key.split("/").slice(route === "images" ? 0 : 1).map((seg) => encodeURIComponent(seg)).join("/")}`;
2425
2447
  const record = {
2426
2448
  ok: true,
@@ -2462,6 +2484,17 @@ var ServeApp = class {
2462
2484
  absPath: a.absPath
2463
2485
  };
2464
2486
  }),
2487
+ models3d: models3d.map((m, ix) => {
2488
+ const key = model3dKeys[ix];
2489
+ return {
2490
+ filename: m.filename,
2491
+ mime: m.mime,
2492
+ format: m.format,
2493
+ size: m.bytes.byteLength,
2494
+ url: m.absPath != null ? this.outputUrl(m.absPath) : key != null ? memoryUrl("model3d", key) : null,
2495
+ absPath: m.absPath
2496
+ };
2497
+ }),
2465
2498
  ...mod.dw.spec.widgets != null && mod.dw.spec.widgets.length > 0 ? { widgets: mod.dw.spec.widgets } : {}
2466
2499
  };
2467
2500
  this.kept.add({
@@ -2469,6 +2502,7 @@ var ServeApp = class {
2469
2502
  imageKeys,
2470
2503
  audioKeys,
2471
2504
  videoKeys,
2505
+ model3dKeys,
2472
2506
  blobs
2473
2507
  });
2474
2508
  const first = execution.images[0];
@@ -2652,4 +2686,4 @@ var ServeApp = class {
2652
2686
  //#endregion
2653
2687
  export { describeVar as n, renderDescriptorLine as r, ServeApp as t };
2654
2688
 
2655
- //# sourceMappingURL=ServeApp-DuxYdaZZ.js.map
2689
+ //# sourceMappingURL=ServeApp-fsHtW5zG.js.map