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
@@ -0,0 +1,579 @@
1
+ import {
2
+ extractErrorMessage,
3
+ stripAnsi,
4
+ DefinedWorkflow
5
+ } from "./chunk-6tsg7fm5.js";
6
+
7
+ // src/cli/tui/treeRows.ts
8
+ import { basename, dirname } from "pathe";
9
+ function moduleName(file) {
10
+ return basename(file).replace(/\.cflow\.tsx?$/, "");
11
+ }
12
+ function familyOf(name) {
13
+ const dash = name.indexOf("-");
14
+ return dash === -1 ? name : name.slice(0, dash);
15
+ }
16
+ var FAMILY_PALETTE = [
17
+ "#61afef",
18
+ "#e5c07b",
19
+ "#c678dd",
20
+ "#98c379",
21
+ "#e06c75",
22
+ "#56b6c2",
23
+ "#d19a66",
24
+ "#a5b4fc",
25
+ "#a5e075",
26
+ "#f28fad"
27
+ ];
28
+ function assignFamilyColors(files) {
29
+ const colors = new Map;
30
+ for (const file of files) {
31
+ const family = familyOf(moduleName(file));
32
+ if (colors.has(family))
33
+ continue;
34
+ colors.set(family, FAMILY_PALETTE[colors.size % FAMILY_PALETTE.length] ?? "#61afef");
35
+ }
36
+ return colors;
37
+ }
38
+ function commonDir(files) {
39
+ const first = files[0];
40
+ if (first == null)
41
+ 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])
47
+ i++;
48
+ prefix = prefix.slice(0, i);
49
+ }
50
+ return prefix.join("/");
51
+ }
52
+ function insert(root, rootDir, file) {
53
+ const rel = dirname(file).slice(rootDir.length).replace(/^\//, "");
54
+ const segs = rel === "" ? [] : rel.split("/");
55
+ let node = root;
56
+ for (const seg of segs) {
57
+ let child = node.dirs.get(seg);
58
+ if (child == null) {
59
+ child = { path: `${node.path}/${seg}`, label: seg, files: [], dirs: new Map };
60
+ node.dirs.set(seg, child);
61
+ }
62
+ node = child;
63
+ }
64
+ node.files.push(file);
65
+ }
66
+ function mergeChains(node) {
67
+ const entries = [...node.dirs];
68
+ for (const [key, child] of entries) {
69
+ mergeChains(child);
70
+ if (child.files.length === 0 && child.dirs.size === 1) {
71
+ const only = [...child.dirs.values()][0];
72
+ const label = `${child.label}/${only.label}`;
73
+ node.dirs.delete(key);
74
+ node.dirs.set(label, { ...only, label });
75
+ }
76
+ }
77
+ }
78
+ function matches(file, rootDir, filter) {
79
+ if (filter === "")
80
+ return true;
81
+ const haystack = `${dirname(file).slice(rootDir.length)}/${moduleName(file)}`.toLowerCase();
82
+ return haystack.includes(filter.toLowerCase());
83
+ }
84
+ function emit(p) {
85
+ for (const file of p.node.files) {
86
+ if (!matches(file, p.rootDir, p.filter))
87
+ continue;
88
+ p.out.push({ kind: "file", file, name: moduleName(file), depth: p.depth });
89
+ }
90
+ for (const dir of [...p.node.dirs.values()].sort((a, b) => a.label.localeCompare(b.label))) {
91
+ const kept = [];
92
+ const expanded = p.filter !== "" || !p.collapsedDirs.has(dir.path);
93
+ emit({ ...p, node: dir, depth: p.depth + 1, out: kept });
94
+ if (p.filter !== "" && kept.length === 0)
95
+ continue;
96
+ p.out.push({ kind: "dir", path: dir.path, label: dir.label, depth: p.depth, expanded });
97
+ if (expanded)
98
+ p.out.push(...kept);
99
+ }
100
+ }
101
+ function buildFileRows(p) {
102
+ const out = [];
103
+ if (p.userFiles.length > 0) {
104
+ const rootDir = commonDir(p.userFiles);
105
+ const root = { path: rootDir, label: "", files: [], dirs: new Map };
106
+ for (const f of p.userFiles)
107
+ insert(root, rootDir, f);
108
+ mergeChains(root);
109
+ emit({ node: root, depth: 0, rootDir, collapsedDirs: p.collapsedDirs, filter: p.filter, out });
110
+ }
111
+ if (p.bundledFiles.length > 0) {
112
+ const rootDir = commonDir(p.bundledFiles);
113
+ const root = { path: rootDir, label: "comfy-ts examples", files: [], dirs: new Map };
114
+ for (const f of p.bundledFiles)
115
+ insert(root, rootDir, f);
116
+ mergeChains(root);
117
+ const kept = [];
118
+ const expanded = p.filter !== "" || !p.collapsedDirs.has(rootDir);
119
+ emit({ node: root, depth: 1, rootDir, collapsedDirs: p.collapsedDirs, filter: p.filter, out: kept });
120
+ if (p.filter !== "" && kept.length === 0)
121
+ return out;
122
+ out.push({ kind: "dir", path: rootDir, label: root.label, depth: 0, expanded });
123
+ if (expanded)
124
+ out.push(...kept);
125
+ }
126
+ return out;
127
+ }
128
+
129
+ // src/cli/draftMeta.ts
130
+ var ENHANCE_KEY = "$enhance";
131
+ function isDraftRecord(raw) {
132
+ return raw != null && typeof raw === "object" && !Array.isArray(raw);
133
+ }
134
+ function isDraftMetaKey(key) {
135
+ return key === ENHANCE_KEY;
136
+ }
137
+ function preserveDraftMeta(previous, next) {
138
+ if (previous == null)
139
+ return next;
140
+ const out = { ...next };
141
+ for (const [k, v] of Object.entries(previous))
142
+ if (isDraftMetaKey(k) && !(k in out))
143
+ out[k] = v;
144
+ return out;
145
+ }
146
+
147
+ // src/cli/tui/state/LogsSt.ts
148
+ import { makeAutoObservable, runInAction } from "mobx";
149
+
150
+ // src/utils/mojibake.ts
151
+ var CP1252_REVERSE = {
152
+ "€": 128,
153
+ "‚": 130,
154
+ ƒ: 131,
155
+ "„": 132,
156
+ "…": 133,
157
+ "†": 134,
158
+ "‡": 135,
159
+ ˆ: 136,
160
+ "‰": 137,
161
+ Š: 138,
162
+ "‹": 139,
163
+ Œ: 140,
164
+ Ž: 142,
165
+ "‘": 145,
166
+ "’": 146,
167
+ "“": 147,
168
+ "”": 148,
169
+ "•": 149,
170
+ "–": 150,
171
+ "—": 151,
172
+ "˜": 152,
173
+ "™": 153,
174
+ š: 154,
175
+ "›": 155,
176
+ œ: 156,
177
+ ž: 158,
178
+ Ÿ: 159
179
+ };
180
+ function repairMojibake(s) {
181
+ let suspicious = false;
182
+ for (let i = 0;i < s.length; i++) {
183
+ if (s.charCodeAt(i) > 127) {
184
+ suspicious = true;
185
+ break;
186
+ }
187
+ }
188
+ if (!suspicious)
189
+ return s;
190
+ const bytes = new Uint8Array(s.length);
191
+ for (let i = 0;i < s.length; i++) {
192
+ const code = s.charCodeAt(i);
193
+ if (code <= 255) {
194
+ bytes[i] = code;
195
+ continue;
196
+ }
197
+ const mapped = CP1252_REVERSE[s[i] ?? ""];
198
+ if (mapped == null)
199
+ return s;
200
+ bytes[i] = mapped;
201
+ }
202
+ const decoded = Buffer.from(bytes).toString("utf8");
203
+ return decoded.includes("�") ? s : decoded;
204
+ }
205
+
206
+ // src/cli/tui/state/LogsSt.ts
207
+ var MAX_LINES = 400;
208
+ function assembleLogChunks(p) {
209
+ let partial = p.partial;
210
+ for (const entry of p.entries) {
211
+ for (const piece of stripAnsi(repairMojibake(entry.m)).split(/(\r\n|\n|\r)/)) {
212
+ if (piece === `
213
+ ` || piece === `\r
214
+ `) {
215
+ if (partial.trim() !== "")
216
+ p.lines.push(partial);
217
+ partial = "";
218
+ } else if (piece === "\r") {
219
+ partial = "";
220
+ } else if (piece !== "") {
221
+ partial += piece;
222
+ }
223
+ }
224
+ }
225
+ return partial;
226
+ }
227
+
228
+ class LogsSt {
229
+ st;
230
+ constructor(st) {
231
+ this.st = st;
232
+ makeAutoObservable(this, { st: false });
233
+ this.attach(this.st.wf.host);
234
+ this.st.disposers.push(() => {
235
+ if (this.attached != null) {
236
+ this.attached.onLogs = null;
237
+ this.attached.onSession = null;
238
+ }
239
+ });
240
+ }
241
+ lines = [];
242
+ partial = "";
243
+ attached = null;
244
+ attach(host) {
245
+ if (this.attached === host)
246
+ return;
247
+ if (this.attached != null) {
248
+ this.attached.onLogs = null;
249
+ this.attached.onSession = null;
250
+ if (this.attached.isConnected && this.attached.comfySessionId !== "temp") {
251
+ this.attached.subscribeLogs({ enabled: false, clientId: this.attached.comfySessionId }).catch(() => {});
252
+ }
253
+ }
254
+ this.attached = host;
255
+ this.lines = [];
256
+ this.partial = "";
257
+ host.onLogs = (p) => this.feed(p.entries);
258
+ host.onSession = (sid) => void this.hydrate(host, sid);
259
+ if (host.isConnected && host.comfySessionId !== "temp")
260
+ this.hydrate(host, host.comfySessionId);
261
+ }
262
+ async hydrate(host, sid) {
263
+ try {
264
+ const raw = await host.fetchRawLogs();
265
+ if (this.attached !== host || host.comfySessionId !== sid)
266
+ return;
267
+ runInAction(() => {
268
+ this.lines = [];
269
+ this.partial = "";
270
+ });
271
+ this.feed(raw.entries);
272
+ await host.subscribeLogs({ enabled: true, clientId: sid });
273
+ } catch (e) {
274
+ if (this.attached !== host)
275
+ return;
276
+ this.feed([{ t: "", m: `[comfy-ts] server log stream unavailable: ${extractErrorMessage(e)}
277
+ ` }]);
278
+ }
279
+ }
280
+ feed(entries) {
281
+ runInAction(() => {
282
+ this.partial = assembleLogChunks({ lines: this.lines, partial: this.partial, entries });
283
+ if (this.lines.length > MAX_LINES)
284
+ this.lines.splice(0, this.lines.length - MAX_LINES);
285
+ });
286
+ }
287
+ tail(n) {
288
+ const rows = this.partial.trim() !== "" ? [...this.lines, this.partial] : this.lines;
289
+ return rows.slice(-n);
290
+ }
291
+ }
292
+
293
+ // src/cli/tui/state/DraftsSt.ts
294
+ import {
295
+ copyFileSync,
296
+ existsSync,
297
+ mkdirSync,
298
+ readdirSync,
299
+ readFileSync,
300
+ renameSync,
301
+ rmSync,
302
+ writeFileSync
303
+ } from "node:fs";
304
+ import { makeAutoObservable as makeAutoObservable2, reaction } from "mobx";
305
+ import { dirname as dirname2, join } from "pathe";
306
+
307
+ // src/utils/copyName.ts
308
+ function copyName(name, taken) {
309
+ const m = /^(.*?)(\d+)$/.exec(name);
310
+ if (m == null)
311
+ return copyName(`${name}-1`, taken);
312
+ const prefix = m[1] ?? "";
313
+ const digits = m[2] ?? "";
314
+ for (let n = Number(digits) + 1;; n++) {
315
+ const candidate = `${prefix}${String(n).padStart(digits.length, "0")}`;
316
+ if (!taken.includes(candidate))
317
+ return candidate;
318
+ }
319
+ }
320
+
321
+ // src/cli/tui/state/DraftsSt.ts
322
+ function draftKeyForFile(file) {
323
+ return moduleName(file);
324
+ }
325
+ function draftsDirForFile(file) {
326
+ return comfyts.resolveFromDrafts(draftKeyForFile(file));
327
+ }
328
+ function listDraftsInDir(dir) {
329
+ if (!existsSync(dir))
330
+ return [];
331
+ return readdirSync(dir).filter((f) => f.endsWith(".json")).map((f) => f.slice(0, -".json".length)).sort((a, b) => a.localeCompare(b, "en", { numeric: true }));
332
+ }
333
+ function listDraftsForFile(file) {
334
+ return listDraftsInDir(draftsDirForFile(file));
335
+ }
336
+
337
+ class DraftsSt {
338
+ st;
339
+ constructor(st) {
340
+ this.st = st;
341
+ makeAutoObservable2(this, { st: false });
342
+ this.st.disposers.push(reaction(() => this.active == null ? null : JSON.stringify(this.snapshot()), (json) => {
343
+ if (json != null && this.active != null)
344
+ this.write(this.active, json);
345
+ }, { delay: this.st.timing.autosaveMs }));
346
+ }
347
+ active = null;
348
+ list = [];
349
+ ix = 0;
350
+ version = 0;
351
+ get dir() {
352
+ const cur = this.st.workflows.currentPath;
353
+ return cur != null ? draftsDirForFile(cur) : comfyts.resolveFromDrafts(this.st.wf.spec.id ?? "workflow");
354
+ }
355
+ snapshot() {
356
+ return Object.fromEntries(this.st.entries.map(([k, varDef]) => [k, varDef.toJSON()]));
357
+ }
358
+ write(name, json) {
359
+ const path = join(this.dir, `${name}.json`);
360
+ mkdirSync(dirname2(path), { recursive: true });
361
+ writeFileSync(path, keepDraftMeta(path, json));
362
+ this.version++;
363
+ }
364
+ get moduleKey() {
365
+ return this.st.moduleKey;
366
+ }
367
+ activate(name) {
368
+ this.active = null;
369
+ const path = join(this.dir, `${name}.json`);
370
+ if (existsSync(path)) {
371
+ try {
372
+ const values = JSON.parse(readFileSync(path, "utf8"));
373
+ for (const [k, varDef] of this.st.entries)
374
+ if (k in values)
375
+ varDef.loadJSON(values[k]);
376
+ } catch (e) {
377
+ this.st.exec.error = extractErrorMessage(e);
378
+ }
379
+ }
380
+ this.active = name;
381
+ this.st.settings.rememberDraft(this.moduleKey, name);
382
+ }
383
+ activateRemembered() {
384
+ const remembered = this.st.settings.lastDraft[this.moduleKey];
385
+ if (remembered != null && remembered !== "default" && existsSync(join(this.dir, `${remembered}.json`)))
386
+ this.activate(remembered);
387
+ else
388
+ this.activate("default");
389
+ }
390
+ activateDefault() {
391
+ this.activate("default");
392
+ }
393
+ dirFor(file) {
394
+ return file != null ? draftsDirForFile(file) : this.dir;
395
+ }
396
+ isCurrent(file) {
397
+ return file == null || file === this.st.workflows.currentPath;
398
+ }
399
+ validName(rawName) {
400
+ const name = rawName.trim();
401
+ if (/^[\w][\w .-]*$/.test(name))
402
+ return name;
403
+ this.st.exec.notice = `invalid draft name: '${rawName}'`;
404
+ return null;
405
+ }
406
+ createNamed(rawName) {
407
+ const name = this.validName(rawName);
408
+ if (name == null)
409
+ return false;
410
+ if (existsSync(join(this.dir, `${name}.json`))) {
411
+ this.st.exec.notice = `draft '${name}' already exists`;
412
+ return false;
413
+ }
414
+ this.write(name, JSON.stringify(this.snapshot(), null, 2));
415
+ this.active = name;
416
+ this.st.settings.rememberDraft(this.moduleKey, name);
417
+ this.st.exec.notice = `new draft: ${name} (autosaves)`;
418
+ return true;
419
+ }
420
+ rename(oldName, rawName, file) {
421
+ const newName = this.validName(rawName);
422
+ if (newName == null)
423
+ return false;
424
+ if (newName === oldName)
425
+ return true;
426
+ const dir = this.dirFor(file);
427
+ const to = join(dir, `${newName}.json`);
428
+ if (existsSync(to)) {
429
+ this.st.exec.notice = `draft '${newName}' already exists`;
430
+ return false;
431
+ }
432
+ const from = join(dir, `${oldName}.json`);
433
+ if (existsSync(from))
434
+ renameSync(from, to);
435
+ else if (this.isCurrent(file))
436
+ this.write(newName, JSON.stringify(this.snapshot(), null, 2));
437
+ if (this.isCurrent(file) && this.active === oldName) {
438
+ this.active = newName;
439
+ this.st.settings.rememberDraft(this.moduleKey, newName);
440
+ }
441
+ this.version++;
442
+ this.st.exec.notice = `draft renamed: ${oldName} → ${newName}`;
443
+ return true;
444
+ }
445
+ duplicate(name, rawName, file) {
446
+ const newName = this.validName(rawName);
447
+ if (newName == null)
448
+ return false;
449
+ const dir = this.dirFor(file);
450
+ const from = join(dir, `${name}.json`);
451
+ const to = join(dir, `${newName}.json`);
452
+ if (!existsSync(from)) {
453
+ this.st.exec.notice = `draft '${name}' has no file yet (edit a var first)`;
454
+ return false;
455
+ }
456
+ if (existsSync(to)) {
457
+ this.st.exec.notice = `draft '${newName}' already exists`;
458
+ return false;
459
+ }
460
+ copyFileSync(from, to);
461
+ this.version++;
462
+ this.st.exec.notice = `draft duplicated: ${name} → ${newName}`;
463
+ return true;
464
+ }
465
+ deleteDraft(name, file) {
466
+ const path = join(this.dirFor(file), `${name}.json`);
467
+ if (existsSync(path))
468
+ rmSync(path);
469
+ this.version++;
470
+ if (this.isCurrent(file) && this.active === name)
471
+ this.activateDefault();
472
+ this.st.exec.notice = `draft deleted: ${name}`;
473
+ }
474
+ promptNew(returnMode = "nav") {
475
+ this.st.editor.beginCustom({
476
+ title: "new draft (from current values)",
477
+ initial: "",
478
+ onCommit: (raw) => {
479
+ const ok = this.createNamed(raw);
480
+ if (ok && returnMode === "overlay-drafts")
481
+ this.begin();
482
+ return ok;
483
+ },
484
+ returnMode
485
+ });
486
+ }
487
+ promptRename(name, file, returnMode = "nav") {
488
+ this.st.editor.beginCustom({
489
+ title: `rename draft '${name}'`,
490
+ initial: name,
491
+ onCommit: (raw) => {
492
+ const ok = this.rename(name, raw, file);
493
+ if (ok && returnMode === "overlay-drafts")
494
+ this.begin();
495
+ return ok;
496
+ },
497
+ returnMode
498
+ });
499
+ }
500
+ promptDuplicate(name, file, returnMode = "nav") {
501
+ this.st.editor.beginCustom({
502
+ title: `duplicate draft '${name}'`,
503
+ initial: copyName(name, listDraftsInDir(this.dirFor(file))),
504
+ onCommit: (raw) => {
505
+ const ok = this.duplicate(name, raw, file);
506
+ if (ok && returnMode === "overlay-drafts")
507
+ this.begin();
508
+ return ok;
509
+ },
510
+ returnMode
511
+ });
512
+ }
513
+ beginRename() {
514
+ this.promptRename(this.active ?? "default");
515
+ }
516
+ begin() {
517
+ this.list = listDraftsInDir(this.dir);
518
+ this.st.mode = "overlay-drafts";
519
+ const ix = this.active == null ? -1 : this.list.indexOf(this.active);
520
+ this.ix = ix === -1 ? 0 : ix + 1;
521
+ }
522
+ move(delta) {
523
+ const len = this.list.length + 1;
524
+ this.ix = (this.ix + delta + len) % len;
525
+ }
526
+ get selectedName() {
527
+ return this.ix === 0 ? null : this.list[this.ix - 1] ?? null;
528
+ }
529
+ commit() {
530
+ if (this.ix === 0)
531
+ return this.promptNew("overlay-drafts");
532
+ const name = this.selectedName;
533
+ if (name == null)
534
+ return;
535
+ this.activate(name);
536
+ this.st.exec.notice = `draft: ${name} (autosaves)`;
537
+ this.st.mode = "nav";
538
+ }
539
+ }
540
+ function keepDraftMeta(path, json) {
541
+ if (!existsSync(path))
542
+ return json;
543
+ let previous;
544
+ try {
545
+ previous = JSON.parse(readFileSync(path, "utf8"));
546
+ } catch {
547
+ return json;
548
+ }
549
+ const next = JSON.parse(json);
550
+ if (!isDraftRecord(previous) || !isDraftRecord(next))
551
+ return json;
552
+ return JSON.stringify(preserveDraftMeta(previous, next), null, 2);
553
+ }
554
+
555
+ // src/cli/tui/discoverWorkflows.ts
556
+ import { readdirSync as readdirSync2 } from "node:fs";
557
+ import { join as join2 } from "pathe";
558
+ function scanCflowFiles(dir) {
559
+ const hits = readdirSync2(dir, { recursive: true }).map((f) => String(f)).filter((f) => !f.split("/").includes("node_modules")).map((f) => join2(dir, f)).filter((f) => f.endsWith(".cflow.ts") || f.endsWith(".cflow.tsx"));
560
+ return hits.sort();
561
+ }
562
+ function mergeWorkflowSources(p) {
563
+ if (p.explicitTarget)
564
+ return { files: p.scanned, bundled: new Set };
565
+ const bundled = new Set(p.bundledFiles);
566
+ const userFiles = p.scanned.filter((f) => !bundled.has(f));
567
+ return { files: [...userFiles, ...p.bundledFiles], bundled };
568
+ }
569
+
570
+ // src/cli/tui/findDefinedWorkflow.ts
571
+ function findDefinedWorkflow(mod) {
572
+ const isDefined = (x) => x instanceof DefinedWorkflow || typeof x === "object" && x != null && ("spec" in x) && typeof x.run === "function" && typeof x.entries === "function";
573
+ return [mod.default, ...Object.values(mod)].find(isDefined) ?? null;
574
+ }
575
+
576
+ export { moduleName, familyOf, assignFamilyColors, buildFileRows, ENHANCE_KEY, isDraftMetaKey, assembleLogChunks, LogsSt, draftKeyForFile, draftsDirForFile, listDraftsForFile, DraftsSt, scanCflowFiles, mergeWorkflowSources, findDefinedWorkflow };
577
+
578
+ //# debugId=C9A6EC268910514364756E2164756E21
579
+ //# sourceMappingURL=chunk-6mgjbrp6.js.map