comfy-ts 2.24.0 → 2.25.1

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 (321) hide show
  1. package/dist/chunk-6mgjbrp6.js +579 -0
  2. package/dist/chunk-6mgjbrp6.js.map +17 -0
  3. package/dist/chunk-6tsg7fm5.js +1876 -0
  4. package/dist/chunk-6tsg7fm5.js.map +31 -0
  5. package/dist/chunk-dvxjvwe7.js +2593 -0
  6. package/dist/chunk-dvxjvwe7.js.map +29 -0
  7. package/dist/chunk-dw0t1nye.js +457 -0
  8. package/dist/chunk-dw0t1nye.js.map +16 -0
  9. package/dist/chunk-he70ewwx.js +444 -0
  10. package/dist/chunk-he70ewwx.js.map +13 -0
  11. package/dist/chunk-n22qz0j1.js +6663 -0
  12. package/dist/chunk-n22qz0j1.js.map +95 -0
  13. package/dist/chunk-n35nffm8.js +4777 -0
  14. package/dist/chunk-n35nffm8.js.map +51 -0
  15. package/dist/cli/serve/hostProtocol.d.cts +74 -0
  16. package/dist/cli/serve/hostProtocol.d.ts +74 -0
  17. package/dist/cli/tui-env.d.cts +2 -0
  18. package/dist/cli/tui-env.d.ts +2 -0
  19. package/dist/cli.js +494 -485
  20. package/dist/cli.js.map +16 -1
  21. package/dist/coreExports.d.cts +45 -0
  22. package/dist/coreExports.d.ts +45 -0
  23. package/dist/errors/InvalidPromptError.d.cts +10 -0
  24. package/dist/errors/InvalidPromptError.d.ts +10 -0
  25. package/dist/exampleAssets.d.cts +24 -0
  26. package/dist/exampleAssets.d.ts +24 -0
  27. package/dist/graph/ComfyNode.d.cts +109 -0
  28. package/dist/graph/ComfyNode.d.ts +109 -0
  29. package/dist/graph/ComfyNodeID.d.cts +15 -0
  30. package/dist/graph/ComfyNodeID.d.ts +15 -0
  31. package/dist/graph/ComfyNodeOutput.d.cts +21 -0
  32. package/dist/graph/ComfyNodeOutput.d.ts +21 -0
  33. package/dist/graph/NodeSlotSize.d.cts +4 -0
  34. package/dist/graph/NodeSlotSize.d.ts +4 -0
  35. package/dist/graph/autoValue.d.cts +16 -0
  36. package/dist/graph/autoValue.d.ts +16 -0
  37. package/dist/host/ComfyHost.d.cts +383 -0
  38. package/dist/host/ComfyHost.d.ts +383 -0
  39. package/dist/host/ComfyInstallType.d.cts +11 -0
  40. package/dist/host/ComfyInstallType.d.ts +11 -0
  41. package/dist/host/ComfyManager.d.cts +152 -0
  42. package/dist/host/ComfyManager.d.ts +152 -0
  43. package/dist/host/ComfyUploader.d.cts +42 -0
  44. package/dist/host/ComfyUploader.d.ts +42 -0
  45. package/dist/host/ComfyWorkflowBuilder.d.cts +19 -0
  46. package/dist/host/ComfyWorkflowBuilder.d.ts +19 -0
  47. package/dist/host/Requirements.d.cts +43 -0
  48. package/dist/host/Requirements.d.ts +43 -0
  49. package/dist/host/ResilientWebsocket.d.cts +122 -0
  50. package/dist/host/ResilientWebsocket.d.ts +122 -0
  51. package/dist/host/hostFile.d.cts +23 -0
  52. package/dist/host/hostFile.d.ts +23 -0
  53. package/dist/host/hostUrl.d.cts +22 -0
  54. package/dist/host/hostUrl.d.ts +22 -0
  55. package/dist/host/leastBusy.d.cts +9 -0
  56. package/dist/host/leastBusy.d.ts +9 -0
  57. package/dist/host/loraInfoCache.d.cts +110 -0
  58. package/dist/host/loraInfoCache.d.ts +110 -0
  59. package/dist/host/loraManagerApi.d.cts +106 -0
  60. package/dist/host/loraManagerApi.d.ts +106 -0
  61. package/dist/host/previewMethod.d.cts +5 -0
  62. package/dist/host/previewMethod.d.ts +5 -0
  63. package/dist/host/schemaDrift.d.cts +54 -0
  64. package/dist/host/schemaDrift.d.ts +54 -0
  65. package/dist/image-utils/_getPngMetadata.d.cts +5 -0
  66. package/dist/image-utils/_getPngMetadata.d.ts +5 -0
  67. package/dist/index.cjs +8197 -8509
  68. package/dist/index.cjs.map +124 -1
  69. package/dist/index.d.cts +4 -19116
  70. package/dist/index.d.ts +4 -19116
  71. package/dist/index.js +8129 -8390
  72. package/dist/index.js.map +124 -1
  73. package/dist/litegraph/CanonicalWorkflow.d.cts +75 -0
  74. package/dist/litegraph/CanonicalWorkflow.d.ts +75 -0
  75. package/dist/litegraph/LiteGraphGroup.d.cts +17 -0
  76. package/dist/litegraph/LiteGraphGroup.d.ts +17 -0
  77. package/dist/litegraph/LiteGraphJSON.d.cts +242 -0
  78. package/dist/litegraph/LiteGraphJSON.d.ts +242 -0
  79. package/dist/litegraph/LiteGraphLink.d.cts +48 -0
  80. package/dist/litegraph/LiteGraphLink.d.ts +48 -0
  81. package/dist/litegraph/LiteGraphLinkID.d.cts +6 -0
  82. package/dist/litegraph/LiteGraphLinkID.d.ts +6 -0
  83. package/dist/litegraph/LiteGraphNode.d.cts +76 -0
  84. package/dist/litegraph/LiteGraphNode.d.ts +76 -0
  85. package/dist/litegraph/LiteGraphNodeInput.d.cts +25 -0
  86. package/dist/litegraph/LiteGraphNodeInput.d.ts +25 -0
  87. package/dist/litegraph/LiteGraphNodeOutput.d.cts +20 -0
  88. package/dist/litegraph/LiteGraphNodeOutput.d.ts +20 -0
  89. package/dist/litegraph/LiteGraphSlotIndex.d.cts +6 -0
  90. package/dist/litegraph/LiteGraphSlotIndex.d.ts +6 -0
  91. package/dist/litegraph/LiteGraphSubgraphDef.d.cts +174 -0
  92. package/dist/litegraph/LiteGraphSubgraphDef.d.ts +174 -0
  93. package/dist/litegraph/convertFlowToLiteGraphJSON.d.cts +12 -0
  94. package/dist/litegraph/convertFlowToLiteGraphJSON.d.ts +12 -0
  95. package/dist/litegraph/expandSubgraphs.d.cts +27 -0
  96. package/dist/litegraph/expandSubgraphs.d.ts +27 -0
  97. package/dist/litegraph/normalizeWorkflow.d.cts +21 -0
  98. package/dist/litegraph/normalizeWorkflow.d.ts +21 -0
  99. package/dist/manager/ComfyRegistry.d.cts +54 -0
  100. package/dist/manager/ComfyRegistry.d.ts +54 -0
  101. package/dist/manager/generated/KnownComfyCustomNodeName.d.cts +1 -0
  102. package/dist/manager/generated/KnownComfyCustomNodeName.d.ts +1 -0
  103. package/dist/manager/generated/KnownComfyPluginTitle.d.cts +12109 -0
  104. package/dist/manager/generated/KnownComfyPluginTitle.d.ts +12109 -0
  105. package/dist/manager/generated/KnownComfyPluginURL.d.cts +1 -0
  106. package/dist/manager/generated/KnownComfyPluginURL.d.ts +1 -0
  107. package/dist/manager/generated/KnownModel_Base.d.cts +2 -0
  108. package/dist/manager/generated/KnownModel_Base.d.ts +2 -0
  109. package/dist/manager/generated/KnownModel_Name.d.cts +2842 -0
  110. package/dist/manager/generated/KnownModel_Name.d.ts +2842 -0
  111. package/dist/manager/generated/KnownModel_SavePath.d.cts +2 -0
  112. package/dist/manager/generated/KnownModel_SavePath.d.ts +2 -0
  113. package/dist/manager/generated/KnownModel_Type.d.cts +2 -0
  114. package/dist/manager/generated/KnownModel_Type.d.ts +2 -0
  115. package/dist/manager/installedView.d.cts +65 -0
  116. package/dist/manager/installedView.d.ts +65 -0
  117. package/dist/manager/json/custom-node-list.extra.d.cts +2 -0
  118. package/dist/manager/json/custom-node-list.extra.d.ts +2 -0
  119. package/dist/manager/json/model-list.extra.d.cts +2 -0
  120. package/dist/manager/json/model-list.extra.d.ts +2 -0
  121. package/dist/manager/loaders/parseReport.d.cts +24 -0
  122. package/dist/manager/loaders/parseReport.d.ts +24 -0
  123. package/dist/manager/loaders/step1_downloadComfyManagerJSONs.d.cts +1 -0
  124. package/dist/manager/loaders/step1_downloadComfyManagerJSONs.d.ts +1 -0
  125. package/dist/manager/loaders/step2_custom-node-list-loader.d.cts +2 -0
  126. package/dist/manager/loaders/step2_custom-node-list-loader.d.ts +2 -0
  127. package/dist/manager/loaders/step3_extension-node-map-loader.d.cts +2 -0
  128. package/dist/manager/loaders/step3_extension-node-map-loader.d.ts +2 -0
  129. package/dist/manager/loaders/step4_model-list-loader.d.cts +2 -0
  130. package/dist/manager/loaders/step4_model-list-loader.d.ts +2 -0
  131. package/dist/manager/loaders/step5_alter-list-loader.d.cts +2 -0
  132. package/dist/manager/loaders/step5_alter-list-loader.d.ts +2 -0
  133. package/dist/manager/loaders/step6_github-stats-loader.d.cts +2 -0
  134. package/dist/manager/loaders/step6_github-stats-loader.d.ts +2 -0
  135. package/dist/manager/types/ComfyManagerAPIFetchPolicy.d.cts +7 -0
  136. package/dist/manager/types/ComfyManagerAPIFetchPolicy.d.ts +7 -0
  137. package/dist/manager/types/ComfyManagerAPIModelList.d.cts +10 -0
  138. package/dist/manager/types/ComfyManagerAPIModelList.d.ts +10 -0
  139. package/dist/manager/types/ComfyManagerAPIPluginList.d.cts +33 -0
  140. package/dist/manager/types/ComfyManagerAPIPluginList.d.ts +33 -0
  141. package/dist/manager/types/ComfyManagerAlterInfo.d.cts +12 -0
  142. package/dist/manager/types/ComfyManagerAlterInfo.d.ts +12 -0
  143. package/dist/manager/types/ComfyManagerFileModelInfo.d.cts +10 -0
  144. package/dist/manager/types/ComfyManagerFileModelInfo.d.ts +10 -0
  145. package/dist/manager/types/ComfyManagerFilePluginContent.d.cts +11 -0
  146. package/dist/manager/types/ComfyManagerFilePluginContent.d.ts +11 -0
  147. package/dist/manager/types/ComfyManagerFilePluginList.d.cts +5 -0
  148. package/dist/manager/types/ComfyManagerFilePluginList.d.ts +5 -0
  149. package/dist/manager/types/ComfyManagerGithubStats.d.cts +7 -0
  150. package/dist/manager/types/ComfyManagerGithubStats.d.ts +7 -0
  151. package/dist/manager/types/ComfyManagerModelInfo.d.cts +12 -0
  152. package/dist/manager/types/ComfyManagerModelInfo.d.ts +12 -0
  153. package/dist/manager/types/ComfyManagerPluginContentMetadata.d.cts +10 -0
  154. package/dist/manager/types/ComfyManagerPluginContentMetadata.d.ts +10 -0
  155. package/dist/manager/types/ComfyManagerPluginEnums.d.cts +5 -0
  156. package/dist/manager/types/ComfyManagerPluginEnums.d.ts +5 -0
  157. package/dist/manager/types/ComfyManagerPluginInfo.d.cts +54 -0
  158. package/dist/manager/types/ComfyManagerPluginInfo.d.ts +54 -0
  159. package/dist/promptEnhancers.d.cts +22 -0
  160. package/dist/promptEnhancers.d.ts +22 -0
  161. package/dist/runner/ComfyExecution.d.cts +230 -0
  162. package/dist/runner/ComfyExecution.d.ts +230 -0
  163. package/dist/runner/ComfyExecutionStatus.d.cts +1 -0
  164. package/dist/runner/ComfyExecutionStatus.d.ts +1 -0
  165. package/dist/runner/ComfyWorkflow.d.cts +141 -0
  166. package/dist/runner/ComfyWorkflow.d.ts +141 -0
  167. package/dist/runner/ComfyWorkflowLayout.d.cts +17 -0
  168. package/dist/runner/ComfyWorkflowLayout.d.ts +17 -0
  169. package/dist/runner/ComfyWsApi.d.cts +2174 -0
  170. package/dist/runner/ComfyWsApi.d.ts +2174 -0
  171. package/dist/runner/MediaImage.d.cts +127 -0
  172. package/dist/runner/MediaImage.d.ts +127 -0
  173. package/dist/runner/comfyOrgApiKey.d.cts +21 -0
  174. package/dist/runner/comfyOrgApiKey.d.ts +21 -0
  175. package/dist/runner/describePromptRejection.d.cts +1 -0
  176. package/dist/runner/describePromptRejection.d.ts +1 -0
  177. package/dist/runner/ephemeral.d.cts +10 -0
  178. package/dist/runner/ephemeral.d.ts +10 -0
  179. package/dist/runner/historyReplay.d.cts +13 -0
  180. package/dist/runner/historyReplay.d.ts +13 -0
  181. package/dist/runner/mediaKinds.d.cts +7 -0
  182. package/dist/runner/mediaKinds.d.ts +7 -0
  183. package/dist/runner/outputPath.d.cts +40 -0
  184. package/dist/runner/outputPath.d.ts +40 -0
  185. package/dist/runner/outputs3d.d.cts +3 -0
  186. package/dist/runner/outputs3d.d.ts +3 -0
  187. package/dist/runner/wsBinaryFrame.d.cts +25 -0
  188. package/dist/runner/wsBinaryFrame.d.ts +25 -0
  189. package/dist/sdk-generator/ComfyNodeSchema.d.cts +25 -0
  190. package/dist/sdk-generator/ComfyNodeSchema.d.ts +25 -0
  191. package/dist/sdk-generator/ComfySchema.d.cts +74 -0
  192. package/dist/sdk-generator/ComfySchema.d.ts +74 -0
  193. package/dist/sdk-generator/ComfyUIObjectInfoTypes.d.cts +3072 -0
  194. package/dist/sdk-generator/ComfyUIObjectInfoTypes.d.ts +3072 -0
  195. package/dist/sdk-generator/Primitives.d.cts +12 -0
  196. package/dist/sdk-generator/Primitives.d.ts +12 -0
  197. package/dist/sdk-generator/_getUnionNameBasedOnFirstFoundEnumName.d.cts +2 -0
  198. package/dist/sdk-generator/_getUnionNameBasedOnFirstFoundEnumName.d.ts +2 -0
  199. package/dist/sdk-generator/_pythonModuleToNamespace.d.cts +1 -0
  200. package/dist/sdk-generator/_pythonModuleToNamespace.d.ts +1 -0
  201. package/dist/sdk-generator/_toQualifiedNodeKey.d.cts +1 -0
  202. package/dist/sdk-generator/_toQualifiedNodeKey.d.ts +1 -0
  203. package/dist/sdk-generator/comfy-api-json.d.cts +16 -0
  204. package/dist/sdk-generator/comfy-api-json.d.ts +16 -0
  205. package/dist/sdk-generator/comfyui-sdk-codegen.d.cts +23 -0
  206. package/dist/sdk-generator/comfyui-sdk-codegen.d.ts +23 -0
  207. package/dist/sdk-generator/comfyui-types.d.cts +55 -0
  208. package/dist/sdk-generator/comfyui-types.d.ts +55 -0
  209. package/dist/sdk-generator/inputWidgetKind.d.cts +80 -0
  210. package/dist/sdk-generator/inputWidgetKind.d.ts +80 -0
  211. package/dist/sdk-generator/litegraphToApiRequestPayload.d.cts +41 -0
  212. package/dist/sdk-generator/litegraphToApiRequestPayload.d.ts +41 -0
  213. package/dist/serve-web.js +51 -51
  214. package/dist/ssh-host-manager/ssh-config-manager.d.cts +17 -0
  215. package/dist/ssh-host-manager/ssh-config-manager.d.ts +17 -0
  216. package/dist/state.d.cts +80 -0
  217. package/dist/state.d.ts +80 -0
  218. package/dist/storage/ComfyStorage.d.cts +55 -0
  219. package/dist/storage/ComfyStorage.d.ts +55 -0
  220. package/dist/storage/nodeStorage.d.cts +2 -0
  221. package/dist/storage/nodeStorage.d.ts +2 -0
  222. package/dist/types/comfy-sdk.d.cts +85 -0
  223. package/dist/types/comfy-sdk.d.ts +85 -0
  224. package/dist/types/index.d.cts +65 -0
  225. package/dist/types/index.d.ts +65 -0
  226. package/dist/utils/CodeBuffer.d.cts +20 -0
  227. package/dist/utils/CodeBuffer.d.ts +20 -0
  228. package/dist/utils/ComfyColors.d.cts +14 -0
  229. package/dist/utils/ComfyColors.d.ts +14 -0
  230. package/dist/utils/ansi.d.cts +22 -0
  231. package/dist/utils/ansi.d.ts +22 -0
  232. package/dist/utils/bang.d.cts +9 -0
  233. package/dist/utils/bang.d.ts +9 -0
  234. package/dist/utils/deepCopyNaive.d.cts +1 -0
  235. package/dist/utils/deepCopyNaive.d.ts +1 -0
  236. package/dist/utils/downloadFile.d.cts +2 -0
  237. package/dist/utils/downloadFile.d.ts +2 -0
  238. package/dist/utils/escapeJSKey.d.cts +2 -0
  239. package/dist/utils/escapeJSKey.d.ts +2 -0
  240. package/dist/utils/exhaust.d.cts +1 -0
  241. package/dist/utils/exhaust.d.ts +1 -0
  242. package/dist/utils/extractErrorMessage.d.cts +2 -0
  243. package/dist/utils/extractErrorMessage.d.ts +2 -0
  244. package/dist/utils/githubRegexes.d.cts +2 -0
  245. package/dist/utils/githubRegexes.d.ts +2 -0
  246. package/dist/utils/hashArrayBuffer.d.cts +1 -0
  247. package/dist/utils/hashArrayBuffer.d.ts +1 -0
  248. package/dist/utils/isRecord.d.cts +2 -0
  249. package/dist/utils/isRecord.d.ts +2 -0
  250. package/dist/utils/lazySharp.d.cts +3 -0
  251. package/dist/utils/lazySharp.d.ts +3 -0
  252. package/dist/utils/log.d.cts +4 -0
  253. package/dist/utils/log.d.ts +4 -0
  254. package/dist/utils/loraTag.d.cts +8 -0
  255. package/dist/utils/loraTag.d.ts +8 -0
  256. package/dist/utils/matchesRegex.d.cts +2 -0
  257. package/dist/utils/matchesRegex.d.ts +2 -0
  258. package/dist/utils/printArkResultInConsole.d.cts +2 -0
  259. package/dist/utils/printArkResultInConsole.d.ts +2 -0
  260. package/dist/utils/safeName.d.cts +6 -0
  261. package/dist/utils/safeName.d.ts +6 -0
  262. package/dist/utils/sha1.d.cts +2 -0
  263. package/dist/utils/sha1.d.ts +2 -0
  264. package/dist/utils/softValidate.d.cts +2 -0
  265. package/dist/utils/softValidate.d.ts +2 -0
  266. package/dist/utils/stringifyReadable.d.cts +1 -0
  267. package/dist/utils/stringifyReadable.d.ts +1 -0
  268. package/dist/utils/toposort.d.cts +3 -0
  269. package/dist/utils/toposort.d.ts +3 -0
  270. package/dist/vars/ComfyVars.d.cts +607 -0
  271. package/dist/vars/ComfyVars.d.ts +607 -0
  272. package/dist/vars/DefinedWorkflow.d.cts +104 -0
  273. package/dist/vars/DefinedWorkflow.d.ts +104 -0
  274. package/dist/vars/lanes.d.cts +81 -0
  275. package/dist/vars/lanes.d.ts +81 -0
  276. package/dist/vars/loraEntry.d.cts +26 -0
  277. package/dist/vars/loraEntry.d.ts +26 -0
  278. package/dist/vars/loraKeywords.d.cts +19 -0
  279. package/dist/vars/loraKeywords.d.ts +19 -0
  280. package/dist/vars/outputWidgets.d.cts +33 -0
  281. package/dist/vars/outputWidgets.d.ts +33 -0
  282. package/dist/vars/presets.d.cts +9 -0
  283. package/dist/vars/presets.d.ts +9 -0
  284. package/dist/vars/promptSyntax.d.cts +98 -0
  285. package/dist/vars/promptSyntax.d.ts +98 -0
  286. package/dist/web.d.cts +2 -0
  287. package/dist/web.d.ts +2 -19160
  288. package/dist/web.js +8040 -8292
  289. package/dist/web.js.map +119 -1
  290. package/examples/depth-explorer/web/tsconfig.json +1 -2
  291. package/examples/upscale-explorer/web/tsconfig.json +1 -2
  292. package/examples/web/tsconfig.json +1 -4
  293. package/examples/world-explorer/web/tsconfig.json +1 -2
  294. package/package.json +27 -32
  295. package/src/cli/serve/web/components/SideMenu.tsx +1 -1
  296. package/src/cli/serve/web/components/controls/LorasControl.tsx +2 -0
  297. package/src/cli/serve/web/components/controls/RichSelect.tsx +1 -0
  298. package/src/cli/serve/web/state/RunSt.poll.test.ts +2 -1
  299. package/src/cli/serve/web/tsconfig.json +1 -2
  300. package/src/cli/serve/web/widgets/RelightWidget.tsx +1 -0
  301. package/src/cli/tui/state/HostSt.ts +1 -1
  302. package/src/host/loraManagerApi.ts +8 -3
  303. package/src/runner/ComfyExecution.ts +3 -1
  304. package/src/runner/ComfyWsApi.ts +2 -1
  305. package/src/storage/ComfyStorage.ts +5 -4
  306. package/src/types/comfy-sdk.ts +1 -0
  307. package/src/utils/ansi.ts +1 -0
  308. package/dist/ServeApp-fsHtW5zG.js +0 -2689
  309. package/dist/ServeApp-fsHtW5zG.js.map +0 -1
  310. package/dist/exampleAssets-DZynSkZm.js +0 -6674
  311. package/dist/exampleAssets-DZynSkZm.js.map +0 -1
  312. package/dist/findDefinedWorkflow-qyqFea7q.js +0 -625
  313. package/dist/findDefinedWorkflow-qyqFea7q.js.map +0 -1
  314. package/dist/run-run-Cn2JzKlE.js +0 -449
  315. package/dist/run-run-Cn2JzKlE.js.map +0 -1
  316. package/dist/run-serve-BhGegaCI.js +0 -464
  317. package/dist/run-serve-BhGegaCI.js.map +0 -1
  318. package/dist/run-tui-CrM4ijkH.js +0 -4569
  319. package/dist/run-tui-CrM4ijkH.js.map +0 -1
  320. package/dist/schemaDrift-BGYJZGMD.js +0 -2225
  321. package/dist/schemaDrift-BGYJZGMD.js.map +0 -1
@@ -1,625 +0,0 @@
1
- import { Q as stripAnsi, a as DefinedWorkflow, vt as extractErrorMessage } from "./schemaDrift-BGYJZGMD.js";
2
- import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
3
- import { basename, dirname, join } from "pathe";
4
- import { makeAutoObservable, reaction, runInAction } from "mobx";
5
- //#region src/cli/tui/treeRows.ts
6
- /** module display name — also the drafts folder key (DraftsSt delegates here) */
7
- function moduleName(file) {
8
- return basename(file).replace(/\.cflow\.tsx?$/, "");
9
- }
10
- /** the color word: everything before the first `-` (`flux1-i2i` → `flux1`) */
11
- function familyOf(name) {
12
- const dash = name.indexOf("-");
13
- return dash === -1 ? name : name.slice(0, dash);
14
- }
15
- /** hue-spread so CONSECUTIVE families land on clearly distinct colors */
16
- const FAMILY_PALETTE = [
17
- "#61afef",
18
- "#e5c07b",
19
- "#c678dd",
20
- "#98c379",
21
- "#e06c75",
22
- "#56b6c2",
23
- "#d19a66",
24
- "#a5b4fc",
25
- "#a5e075",
26
- "#f28fad"
27
- ];
28
- /** family → color, palette cycled in first-appearance order over the FULL
29
- * (unfiltered) file list — stable while filtering/folding */
30
- function assignFamilyColors(files) {
31
- const colors = /* @__PURE__ */ new Map();
32
- for (const file of files) {
33
- const family = familyOf(moduleName(file));
34
- if (colors.has(family)) continue;
35
- colors.set(family, FAMILY_PALETTE[colors.size % FAMILY_PALETTE.length] ?? "#61afef");
36
- }
37
- return colors;
38
- }
39
- function commonDir(files) {
40
- const first = files[0];
41
- if (first == null) return "";
42
- let prefix = dirname(first).split("/");
43
- for (const f of files.slice(1)) {
44
- const segs = dirname(f).split("/");
45
- let i = 0;
46
- while (i < prefix.length && i < segs.length && prefix[i] === segs[i]) i++;
47
- prefix = prefix.slice(0, i);
48
- }
49
- return prefix.join("/");
50
- }
51
- function insert(root, rootDir, file) {
52
- const rel = dirname(file).slice(rootDir.length).replace(/^\//, "");
53
- const segs = rel === "" ? [] : rel.split("/");
54
- let node = root;
55
- for (const seg of segs) {
56
- let child = node.dirs.get(seg);
57
- if (child == null) {
58
- child = {
59
- path: `${node.path}/${seg}`,
60
- label: seg,
61
- files: [],
62
- dirs: /* @__PURE__ */ new Map()
63
- };
64
- node.dirs.set(seg, child);
65
- }
66
- node = child;
67
- }
68
- node.files.push(file);
69
- }
70
- /** a dir holding NOTHING but one subdir shows as one `a/b` row */
71
- function mergeChains(node) {
72
- const entries = [...node.dirs];
73
- for (const [key, child] of entries) {
74
- mergeChains(child);
75
- if (child.files.length === 0 && child.dirs.size === 1) {
76
- const only = [...child.dirs.values()][0];
77
- const label = `${child.label}/${only.label}`;
78
- node.dirs.delete(key);
79
- node.dirs.set(label, {
80
- ...only,
81
- label
82
- });
83
- }
84
- }
85
- }
86
- function matches(file, rootDir, filter) {
87
- if (filter === "") return true;
88
- return `${dirname(file).slice(rootDir.length)}/${moduleName(file)}`.toLowerCase().includes(filter.toLowerCase());
89
- }
90
- function emit(p) {
91
- for (const file of p.node.files) {
92
- if (!matches(file, p.rootDir, p.filter)) continue;
93
- p.out.push({
94
- kind: "file",
95
- file,
96
- name: moduleName(file),
97
- depth: p.depth
98
- });
99
- }
100
- for (const dir of [...p.node.dirs.values()].sort((a, b) => a.label.localeCompare(b.label))) {
101
- const kept = [];
102
- const expanded = p.filter !== "" || !p.collapsedDirs.has(dir.path);
103
- emit({
104
- ...p,
105
- node: dir,
106
- depth: p.depth + 1,
107
- out: kept
108
- });
109
- if (p.filter !== "" && kept.length === 0) continue;
110
- p.out.push({
111
- kind: "dir",
112
- path: dir.path,
113
- label: dir.label,
114
- depth: p.depth,
115
- expanded
116
- });
117
- if (expanded) p.out.push(...kept);
118
- }
119
- }
120
- /**
121
- * hierarchy rows over the discovered files: user files under their common
122
- * root, packaged examples LAST under one foldable 'comfy-ts examples' node.
123
- */
124
- function buildFileRows(p) {
125
- const out = [];
126
- if (p.userFiles.length > 0) {
127
- const rootDir = commonDir(p.userFiles);
128
- const root = {
129
- path: rootDir,
130
- label: "",
131
- files: [],
132
- dirs: /* @__PURE__ */ new Map()
133
- };
134
- for (const f of p.userFiles) insert(root, rootDir, f);
135
- mergeChains(root);
136
- emit({
137
- node: root,
138
- depth: 0,
139
- rootDir,
140
- collapsedDirs: p.collapsedDirs,
141
- filter: p.filter,
142
- out
143
- });
144
- }
145
- if (p.bundledFiles.length > 0) {
146
- const rootDir = commonDir(p.bundledFiles);
147
- const root = {
148
- path: rootDir,
149
- label: "comfy-ts examples",
150
- files: [],
151
- dirs: /* @__PURE__ */ new Map()
152
- };
153
- for (const f of p.bundledFiles) insert(root, rootDir, f);
154
- mergeChains(root);
155
- const kept = [];
156
- const expanded = p.filter !== "" || !p.collapsedDirs.has(rootDir);
157
- emit({
158
- node: root,
159
- depth: 1,
160
- rootDir,
161
- collapsedDirs: p.collapsedDirs,
162
- filter: p.filter,
163
- out: kept
164
- });
165
- if (p.filter !== "" && kept.length === 0) return out;
166
- out.push({
167
- kind: "dir",
168
- path: rootDir,
169
- label: root.label,
170
- depth: 0,
171
- expanded
172
- });
173
- if (expanded) out.push(...kept);
174
- }
175
- return out;
176
- }
177
- //#endregion
178
- //#region src/cli/draftMeta.ts
179
- const ENHANCE_KEY = "$enhance";
180
- /** a parsed draft file: a json object, never an array or a scalar */
181
- function isDraftRecord(raw) {
182
- return raw != null && typeof raw === "object" && !Array.isArray(raw);
183
- }
184
- function isDraftMetaKey(key) {
185
- return key === ENHANCE_KEY;
186
- }
187
- /** a writer that knows only the var values keeps what the file already carried beside them */
188
- function preserveDraftMeta(previous, next) {
189
- if (previous == null) return next;
190
- const out = { ...next };
191
- for (const [k, v] of Object.entries(previous)) if (isDraftMetaKey(k) && !(k in out)) out[k] = v;
192
- return out;
193
- }
194
- //#endregion
195
- //#region src/utils/mojibake.ts
196
- const CP1252_REVERSE = {
197
- "€": 128,
198
- "‚": 130,
199
- ƒ: 131,
200
- "„": 132,
201
- "…": 133,
202
- "†": 134,
203
- "‡": 135,
204
- ˆ: 136,
205
- "‰": 137,
206
- Š: 138,
207
- "‹": 139,
208
- Œ: 140,
209
- Ž: 142,
210
- "‘": 145,
211
- "’": 146,
212
- "“": 147,
213
- "”": 148,
214
- "•": 149,
215
- "–": 150,
216
- "—": 151,
217
- "˜": 152,
218
- "™": 153,
219
- š: 154,
220
- "›": 155,
221
- œ: 156,
222
- ž: 158,
223
- Ÿ: 159
224
- };
225
- /**
226
- * repair UTF-8 that was decoded as cp1252 (a Windows server re-reading its own
227
- * output: `█` E2 96 88 arrives as `â–ˆ`). Reverses the cp1252 map back to
228
- * bytes and re-decodes as UTF-8; any unmappable char or invalid byte sequence
229
- * means the text was NOT mojibake — the original is returned untouched.
230
- */
231
- function repairMojibake(s) {
232
- let suspicious = false;
233
- for (let i = 0; i < s.length; i++) if (s.charCodeAt(i) > 127) {
234
- suspicious = true;
235
- break;
236
- }
237
- if (!suspicious) return s;
238
- const bytes = new Uint8Array(s.length);
239
- for (let i = 0; i < s.length; i++) {
240
- const code = s.charCodeAt(i);
241
- if (code <= 255) {
242
- bytes[i] = code;
243
- continue;
244
- }
245
- const mapped = CP1252_REVERSE[s[i] ?? ""];
246
- if (mapped == null) return s;
247
- bytes[i] = mapped;
248
- }
249
- const decoded = Buffer.from(bytes).toString("utf8");
250
- return decoded.includes("�") ? s : decoded;
251
- }
252
- //#endregion
253
- //#region src/cli/tui/state/LogsSt.ts
254
- const MAX_LINES = 400;
255
- /** fold write chunks into p.lines (mutated), returns the new partial tail.
256
- * `\n` commits a line, `\r` resets the partial (tqdm redraws collapse to
257
- * their last state), ANSI stripped, blank lines dropped. */
258
- function assembleLogChunks(p) {
259
- let partial = p.partial;
260
- for (const entry of p.entries) for (const piece of stripAnsi(repairMojibake(entry.m)).split(/(\r\n|\n|\r)/)) if (piece === "\n" || piece === "\r\n") {
261
- if (partial.trim() !== "") p.lines.push(partial);
262
- partial = "";
263
- } else if (piece === "\r") partial = "";
264
- else if (piece !== "") partial += piece;
265
- return partial;
266
- }
267
- /** server console mirror: /internal/logs/raw backfill + ws 'logs' stream.
268
- * Entries are write CHUNKS, not lines — assembled here (`\n` commits,
269
- * `\r` resets the partial, so tqdm redraws collapse to their last state). */
270
- var LogsSt = class {
271
- constructor(st) {
272
- this.st = st;
273
- this.lines = [];
274
- this.partial = "";
275
- this.attached = null;
276
- makeAutoObservable(this, { st: false });
277
- this.attach(this.st.wf.host);
278
- this.st.disposers.push(() => {
279
- if (this.attached != null) {
280
- this.attached.onLogs = null;
281
- this.attached.onSession = null;
282
- }
283
- });
284
- }
285
- /** follow the CURRENT workflow's host (re-called on workflow switch) */
286
- attach(host) {
287
- if (this.attached === host) return;
288
- if (this.attached != null) {
289
- this.attached.onLogs = null;
290
- this.attached.onSession = null;
291
- if (this.attached.isConnected && this.attached.comfySessionId !== "temp") this.attached.subscribeLogs({
292
- enabled: false,
293
- clientId: this.attached.comfySessionId
294
- }).catch(() => {});
295
- }
296
- this.attached = host;
297
- this.lines = [];
298
- this.partial = "";
299
- host.onLogs = (p) => this.feed(p.entries);
300
- host.onSession = (sid) => void this.hydrate(host, sid);
301
- if (host.isConnected && host.comfySessionId !== "temp") this.hydrate(host, host.comfySessionId);
302
- }
303
- /** backfill BEFORE subscribe: entries emitted in the gap are lost, which is
304
- * the right trade — the reverse order would clobber streamed entries at the
305
- * reset, and the backfill re-covers the recent past anyway */
306
- async hydrate(host, sid) {
307
- try {
308
- const raw = await host.fetchRawLogs();
309
- if (this.attached !== host || host.comfySessionId !== sid) return;
310
- runInAction(() => {
311
- this.lines = [];
312
- this.partial = "";
313
- });
314
- this.feed(raw.entries);
315
- await host.subscribeLogs({
316
- enabled: true,
317
- clientId: sid
318
- });
319
- } catch (e) {
320
- if (this.attached !== host) return;
321
- this.feed([{
322
- t: "",
323
- m: `[comfy-ts] server log stream unavailable: ${extractErrorMessage(e)}\n`
324
- }]);
325
- }
326
- }
327
- feed(entries) {
328
- runInAction(() => {
329
- this.partial = assembleLogChunks({
330
- lines: this.lines,
331
- partial: this.partial,
332
- entries
333
- });
334
- if (this.lines.length > MAX_LINES) this.lines.splice(0, this.lines.length - MAX_LINES);
335
- });
336
- }
337
- /** last rows to render, live partial included */
338
- tail(n) {
339
- return (this.partial.trim() !== "" ? [...this.lines, this.partial] : this.lines).slice(-n);
340
- }
341
- };
342
- //#endregion
343
- //#region src/utils/copyName.ts
344
- /** the default name of a duplicate: a trailing number is incremented (`shot 007` → `shot 008`,
345
- * zero padding kept), anything else gets `-2`. Never returns a name in `taken` */
346
- function copyName(name, taken) {
347
- const m = /^(.*?)(\d+)$/.exec(name);
348
- if (m == null) return copyName(`${name}-1`, taken);
349
- const prefix = m[1] ?? "";
350
- const digits = m[2] ?? "";
351
- for (let n = Number(digits) + 1;; n++) {
352
- const candidate = `${prefix}${String(n).padStart(digits.length, "0")}`;
353
- if (!taken.includes(candidate)) return candidate;
354
- }
355
- }
356
- //#endregion
357
- //#region src/cli/tui/state/DraftsSt.ts
358
- /** module basename (`01-txt2img`) keys the draft folder — knowable for EVERY tree file without importing it */
359
- function draftKeyForFile(file) {
360
- return moduleName(file);
361
- }
362
- function draftsDirForFile(file) {
363
- return comfyts.resolveFromDrafts(draftKeyForFile(file));
364
- }
365
- function listDraftsInDir(dir) {
366
- if (!existsSync(dir)) return [];
367
- return readdirSync(dir).filter((f) => f.endsWith(".json")).map((f) => f.slice(0, -5)).sort((a, b) => a.localeCompare(b, "en", { numeric: true }));
368
- }
369
- /** draft names stored for a workflow module (fs read — pair with DraftsSt.version for reactivity) */
370
- function listDraftsForFile(file) {
371
- return listDraftsInDir(draftsDirForFile(file));
372
- }
373
- /**
374
- * named var-value snapshots at `.comfy-ts/drafts/<module-basename>/<name>.json`
375
- * (LOCAL state, gitignored). The active draft autosaves debounced; the TUI is
376
- * ALWAYS in a draft (`default` unless another one is activated).
377
- */
378
- var DraftsSt = class {
379
- constructor(st) {
380
- this.st = st;
381
- this.active = null;
382
- this.list = [];
383
- this.ix = 0;
384
- this.version = 0;
385
- makeAutoObservable(this, { st: false });
386
- this.st.disposers.push(reaction(() => this.active == null ? null : JSON.stringify(this.snapshot()), (json) => {
387
- if (json != null && this.active != null) this.write(this.active, json);
388
- }, { delay: this.st.timing.autosaveMs }));
389
- }
390
- get dir() {
391
- const cur = this.st.workflows.currentPath;
392
- return cur != null ? draftsDirForFile(cur) : comfyts.resolveFromDrafts(this.st.wf.spec.id ?? "workflow");
393
- }
394
- snapshot() {
395
- return Object.fromEntries(this.st.entries.map(([k, varDef]) => [k, varDef.toJSON()]));
396
- }
397
- write(name, json) {
398
- const path = join(this.dir, `${name}.json`);
399
- mkdirSync(dirname(path), { recursive: true });
400
- writeFileSync(path, keepDraftMeta(path, json));
401
- this.version++;
402
- }
403
- /** module key of the currently loaded workflow (settings.lastDraft is keyed by it) */
404
- get moduleKey() {
405
- return this.st.moduleKey;
406
- }
407
- /** switch to a draft: load its stored values when the file exists, else it starts from current values */
408
- activate(name) {
409
- this.active = null;
410
- const path = join(this.dir, `${name}.json`);
411
- if (existsSync(path)) try {
412
- const values = JSON.parse(readFileSync(path, "utf8"));
413
- for (const [k, varDef] of this.st.entries) if (k in values) varDef.loadJSON(values[k]);
414
- } catch (e) {
415
- this.st.exec.error = extractErrorMessage(e);
416
- }
417
- this.active = name;
418
- this.st.settings.rememberDraft(this.moduleKey, name);
419
- }
420
- /** open the draft this workflow was last in (settings), else 'default' */
421
- activateRemembered() {
422
- const remembered = this.st.settings.lastDraft[this.moduleKey];
423
- if (remembered != null && remembered !== "default" && existsSync(join(this.dir, `${remembered}.json`))) this.activate(remembered);
424
- else this.activate("default");
425
- }
426
- /** every workflow starts in a draft; kept for callers that want 'default' explicitly */
427
- activateDefault() {
428
- this.activate("default");
429
- }
430
- dirFor(file) {
431
- return file != null ? draftsDirForFile(file) : this.dir;
432
- }
433
- /** true when ops on `file` touch the ACTIVE draft bookkeeping */
434
- isCurrent(file) {
435
- return file == null || file === this.st.workflows.currentPath;
436
- }
437
- validName(rawName) {
438
- const name = rawName.trim();
439
- if (/^[\w][\w .-]*$/.test(name)) return name;
440
- this.st.exec.notice = `invalid draft name: '${rawName}'`;
441
- return null;
442
- }
443
- /** create a NEW draft from the current var values (current workflow only) */
444
- createNamed(rawName) {
445
- const name = this.validName(rawName);
446
- if (name == null) return false;
447
- if (existsSync(join(this.dir, `${name}.json`))) {
448
- this.st.exec.notice = `draft '${name}' already exists`;
449
- return false;
450
- }
451
- this.write(name, JSON.stringify(this.snapshot(), null, 2));
452
- this.active = name;
453
- this.st.settings.rememberDraft(this.moduleKey, name);
454
- this.st.exec.notice = `new draft: ${name} (autosaves)`;
455
- return true;
456
- }
457
- rename(oldName, rawName, file) {
458
- const newName = this.validName(rawName);
459
- if (newName == null) return false;
460
- if (newName === oldName) return true;
461
- const dir = this.dirFor(file);
462
- const to = join(dir, `${newName}.json`);
463
- if (existsSync(to)) {
464
- this.st.exec.notice = `draft '${newName}' already exists`;
465
- return false;
466
- }
467
- const from = join(dir, `${oldName}.json`);
468
- if (existsSync(from)) renameSync(from, to);
469
- else if (this.isCurrent(file)) this.write(newName, JSON.stringify(this.snapshot(), null, 2));
470
- if (this.isCurrent(file) && this.active === oldName) {
471
- this.active = newName;
472
- this.st.settings.rememberDraft(this.moduleKey, newName);
473
- }
474
- this.version++;
475
- this.st.exec.notice = `draft renamed: ${oldName} → ${newName}`;
476
- return true;
477
- }
478
- duplicate(name, rawName, file) {
479
- const newName = this.validName(rawName);
480
- if (newName == null) return false;
481
- const dir = this.dirFor(file);
482
- const from = join(dir, `${name}.json`);
483
- const to = join(dir, `${newName}.json`);
484
- if (!existsSync(from)) {
485
- this.st.exec.notice = `draft '${name}' has no file yet (edit a var first)`;
486
- return false;
487
- }
488
- if (existsSync(to)) {
489
- this.st.exec.notice = `draft '${newName}' already exists`;
490
- return false;
491
- }
492
- copyFileSync(from, to);
493
- this.version++;
494
- this.st.exec.notice = `draft duplicated: ${name} → ${newName}`;
495
- return true;
496
- }
497
- deleteDraft(name, file) {
498
- const path = join(this.dirFor(file), `${name}.json`);
499
- if (existsSync(path)) rmSync(path);
500
- this.version++;
501
- if (this.isCurrent(file) && this.active === name) this.activateDefault();
502
- this.st.exec.notice = `draft deleted: ${name}`;
503
- }
504
- promptNew(returnMode = "nav") {
505
- this.st.editor.beginCustom({
506
- title: "new draft (from current values)",
507
- initial: "",
508
- onCommit: (raw) => {
509
- const ok = this.createNamed(raw);
510
- if (ok && returnMode === "overlay-drafts") this.begin();
511
- return ok;
512
- },
513
- returnMode
514
- });
515
- }
516
- promptRename(name, file, returnMode = "nav") {
517
- this.st.editor.beginCustom({
518
- title: `rename draft '${name}'`,
519
- initial: name,
520
- onCommit: (raw) => {
521
- const ok = this.rename(name, raw, file);
522
- if (ok && returnMode === "overlay-drafts") this.begin();
523
- return ok;
524
- },
525
- returnMode
526
- });
527
- }
528
- promptDuplicate(name, file, returnMode = "nav") {
529
- this.st.editor.beginCustom({
530
- title: `duplicate draft '${name}'`,
531
- initial: copyName(name, listDraftsInDir(this.dirFor(file))),
532
- onCommit: (raw) => {
533
- const ok = this.duplicate(name, raw, file);
534
- if (ok && returnMode === "overlay-drafts") this.begin();
535
- return ok;
536
- },
537
- returnMode
538
- });
539
- }
540
- /** f2 in nav: rename the ACTIVE draft */
541
- beginRename() {
542
- this.promptRename(this.active ?? "default");
543
- }
544
- begin() {
545
- this.list = listDraftsInDir(this.dir);
546
- this.st.mode = "overlay-drafts";
547
- const ix = this.active == null ? -1 : this.list.indexOf(this.active);
548
- this.ix = ix === -1 ? 0 : ix + 1;
549
- }
550
- move(delta) {
551
- const len = this.list.length + 1;
552
- this.ix = (this.ix + delta + len) % len;
553
- }
554
- /** draft name under the overlay cursor (row 0 is 'new') */
555
- get selectedName() {
556
- return this.ix === 0 ? null : this.list[this.ix - 1] ?? null;
557
- }
558
- commit() {
559
- if (this.ix === 0) return this.promptNew("overlay-drafts");
560
- const name = this.selectedName;
561
- if (name == null) return;
562
- this.activate(name);
563
- this.st.exec.notice = `draft: ${name} (autosaves)`;
564
- this.st.mode = "nav";
565
- }
566
- };
567
- /** the new json, plus the `$` keys the file on disk already carried (src/cli/draftMeta.ts) */
568
- function keepDraftMeta(path, json) {
569
- if (!existsSync(path)) return json;
570
- let previous;
571
- try {
572
- previous = JSON.parse(readFileSync(path, "utf8"));
573
- } catch {
574
- return json;
575
- }
576
- const next = JSON.parse(json);
577
- if (!isDraftRecord(previous) || !isDraftRecord(next)) return json;
578
- return JSON.stringify(preserveDraftMeta(previous, next), null, 2);
579
- }
580
- //#endregion
581
- //#region src/cli/tui/discoverWorkflows.ts
582
- /**
583
- * recursive scan for the workflow-module naming convention. Entries BELOW a
584
- * node_modules segment are skipped: packaged examples arrive via
585
- * bundledExamplesDir (src/exampleAssets.ts — symlinked layouts like pnpm would
586
- * otherwise list them twice, un-deduped, as the user's own files), and
587
- * third-party packages shipping *.cflow.ts are not this project's workflows. A
588
- * scan root that is ITSELF inside node_modules still works (the filter is
589
- * relative to the root).
590
- */
591
- function scanCflowFiles(dir) {
592
- return readdirSync(dir, { recursive: true }).map((f) => String(f)).filter((f) => !f.split("/").includes("node_modules")).map((f) => join(dir, f)).filter((f) => f.endsWith(".cflow.ts") || f.endsWith(".cflow.tsx")).sort();
593
- }
594
- /**
595
- * PURE merge of the scan with the packaged examples (headless-tested). An
596
- * explicit target keeps its scope only. Bundled files ALWAYS group under the
597
- * bundled section, also when the scan already found them (repo dev: ./examples
598
- * is under cwd) — dedupe relies on the caller passing realpath-normalized
599
- * strings on both sides.
600
- */
601
- function mergeWorkflowSources(p) {
602
- if (p.explicitTarget) return {
603
- files: p.scanned,
604
- bundled: /* @__PURE__ */ new Set()
605
- };
606
- const bundled = new Set(p.bundledFiles);
607
- return {
608
- files: [...p.scanned.filter((f) => !bundled.has(f)), ...p.bundledFiles],
609
- bundled
610
- };
611
- }
612
- //#endregion
613
- //#region src/cli/tui/findDefinedWorkflow.ts
614
- /**
615
- * instanceof first; duck-type fallback covers a second copy of the library in
616
- * the module graph (linked dev setups, npm dedupe misses)
617
- */
618
- function findDefinedWorkflow(mod) {
619
- const isDefined = (x) => x instanceof DefinedWorkflow || typeof x === "object" && x != null && "spec" in x && typeof x.run === "function" && typeof x.entries === "function";
620
- return [mod.default, ...Object.values(mod)].find(isDefined) ?? null;
621
- }
622
- //#endregion
623
- export { draftKeyForFile as a, LogsSt as c, isDraftMetaKey as d, assignFamilyColors as f, moduleName as h, DraftsSt as i, assembleLogChunks as l, familyOf as m, mergeWorkflowSources as n, draftsDirForFile as o, buildFileRows as p, scanCflowFiles as r, listDraftsForFile as s, findDefinedWorkflow as t, ENHANCE_KEY as u };
624
-
625
- //# sourceMappingURL=findDefinedWorkflow-qyqFea7q.js.map