comfy-ts 2.4.1 → 2.5.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 (33) hide show
  1. package/dist/{DefinedWorkflow-QrhT6V66.js → DefinedWorkflow-CnzmQrBh.js} +45 -13
  2. package/dist/DefinedWorkflow-CnzmQrBh.js.map +1 -0
  3. package/dist/{DraftsSt-D9Fhk4qR.js → DraftsSt-C1MbWnEp.js} +2 -2
  4. package/dist/{DraftsSt-D9Fhk4qR.js.map → DraftsSt-C1MbWnEp.js.map} +1 -1
  5. package/dist/cli.js +18 -11
  6. package/dist/cli.js.map +1 -1
  7. package/dist/index.cjs +30 -14
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.cts +27 -23
  10. package/dist/index.d.ts +27 -23
  11. package/dist/index.js +30 -15
  12. package/dist/index.js.map +1 -1
  13. package/dist/{run-serve-C9E8dyLP.js → run-serve-D47Zas-a.js} +3 -3
  14. package/dist/{run-serve-C9E8dyLP.js.map → run-serve-D47Zas-a.js.map} +1 -1
  15. package/dist/{run-tui-8si-rVW0.js → run-tui-t2TRBN0H.js} +24 -15
  16. package/dist/run-tui-t2TRBN0H.js.map +1 -0
  17. package/dist/{state-C0ARiFFM.js → state-DY3Mp9Cl.js} +3 -3
  18. package/dist/{state-C0ARiFFM.js.map → state-DY3Mp9Cl.js.map} +1 -1
  19. package/dist/web.d.ts +27 -23
  20. package/dist/web.js +30 -15
  21. package/dist/web.js.map +1 -1
  22. package/package.json +3 -3
  23. package/src/cli/loras.ts +20 -9
  24. package/src/cli/tui/components/TuiApp.tsx +1 -1
  25. package/src/cli/tui/protocolImagePainter.ts +1 -1
  26. package/src/cli/tui/state/ExecSt.ts +3 -3
  27. package/src/cli/tui/state/LorasSt.ts +19 -5
  28. package/src/cli/tui/state/TuiSt.ts +4 -4
  29. package/src/coreExports.ts +1 -0
  30. package/src/host/loraInfoCache.ts +34 -13
  31. package/src/host/loraManagerApi.ts +25 -4
  32. package/dist/DefinedWorkflow-QrhT6V66.js.map +0 -1
  33. package/dist/run-tui-8si-rVW0.js.map +0 -1
package/dist/web.d.ts CHANGED
@@ -11900,27 +11900,27 @@ declare const types$1: import("arktype").Module<{
11900
11900
  };
11901
11901
  PromptID: PromptID;
11902
11902
  PromptRelated_WsMsg: {
11903
- type: "execution_start";
11903
+ type: "progress";
11904
11904
  data: {
11905
- prompt_id: PromptID;
11905
+ value: number;
11906
+ max: number;
11906
11907
  };
11907
11908
  } | {
11908
- type: "execution_cached";
11909
+ type: "executing";
11909
11910
  data: {
11910
- nodes: ComfyNodeId[];
11911
11911
  prompt_id: PromptID;
11912
+ node?: ComfyNodeId | null | undefined;
11912
11913
  };
11913
11914
  } | {
11914
- type: "executing";
11915
+ type: "execution_start";
11915
11916
  data: {
11916
11917
  prompt_id: PromptID;
11917
- node?: ComfyNodeId | null | undefined;
11918
11918
  };
11919
11919
  } | {
11920
- type: "progress";
11920
+ type: "execution_cached";
11921
11921
  data: {
11922
- value: number;
11923
- max: number;
11922
+ nodes: ComfyNodeId[];
11923
+ prompt_id: PromptID;
11924
11924
  };
11925
11925
  } | {
11926
11926
  type: "progress_state";
@@ -11975,27 +11975,27 @@ declare const types$1: import("arktype").Module<{
11975
11975
  data: string;
11976
11976
  };
11977
11977
  WsMsg: {
11978
- type: "execution_start";
11978
+ type: "progress";
11979
11979
  data: {
11980
- prompt_id: PromptID;
11980
+ value: number;
11981
+ max: number;
11981
11982
  };
11982
11983
  } | {
11983
- type: "execution_cached";
11984
+ type: "executing";
11984
11985
  data: {
11985
- nodes: ComfyNodeId[];
11986
11986
  prompt_id: PromptID;
11987
+ node?: ComfyNodeId | null | undefined;
11987
11988
  };
11988
11989
  } | {
11989
- type: "executing";
11990
+ type: "execution_start";
11990
11991
  data: {
11991
11992
  prompt_id: PromptID;
11992
- node?: ComfyNodeId | null | undefined;
11993
11993
  };
11994
11994
  } | {
11995
- type: "progress";
11995
+ type: "execution_cached";
11996
11996
  data: {
11997
- value: number;
11998
- max: number;
11997
+ nodes: ComfyNodeId[];
11998
+ prompt_id: PromptID;
11999
11999
  };
12000
12000
  } | {
12001
12001
  type: "progress_state";
@@ -17453,10 +17453,14 @@ type LoraMirror = {
17453
17453
  loras: Record<string, LmLoraItem>;
17454
17454
  };
17455
17455
  /**
17456
- * forget everything loaded, so the next read picks up a fresh `comfy-ts loras`.
17457
- * A long-lived process (the TUI, `comfy-ts serve`) has no other way to see a
17458
- * re-sync that happened in another terminal.
17459
- */
17456
+ * re-read any mirror whose file changed (or appeared) since we loaded it.
17457
+ * `comfy-ts loras` in another terminal is the normal case, and without this a
17458
+ * TUI session kept the stale data — or kept knowing NOTHING, for a host whose
17459
+ * first sync happened while it was open. One stat per registered host, so this
17460
+ * belongs at user-initiated moments (opening the loras overlay), never in a render.
17461
+ */
17462
+ declare function refreshLoraInfoCacheIfChanged(): void;
17463
+ /** forget everything loaded, so the next read re-reads from disk (tests, and a hard refresh) */
17460
17464
  declare function reloadLoraInfoCache(): void;
17461
17465
  /**
17462
17466
  * the lm item for a raw lora name (`styles\x.safetensors`).
@@ -17497,5 +17501,5 @@ declare function loraMatchesFilter(name: string, filter: string, hostId?: string
17497
17501
  */
17498
17502
  declare function loraTag<N extends string = string>(name: N, strength?: number, clipStrength?: number): string;
17499
17503
  //#endregion
17500
- export { AbsolutePath, type ActiveLora, type ActiveLoraSource, type AnyVar, BaseNode, BaseNodeFactory, BaseNodeInputs, BaseNodeOutputs, type BoundVars, Branded, type CanonicalGroup, type CanonicalInput, type CanonicalLink, type CanonicalNode, type CanonicalOutput, type CanonicalWidgetValues, type CanonicalWorkflow, ChoiceVar, type CodegenOptions, type ComfyApiJson, type ComfyApiNodeJson, ComfyExecution, type ComfyExecutionData, type ComfyExecutionStatus, ComfyHost, ComfyHostAuthError, type ComfyHostData, type ComfyHostID, ComfyHostUnreachableError, type ComfyImageName, ComfyManager, ComfyNode, type ComfyNodeId, type ComfyNodeIdMode, type ComfyNodeMetadata, ComfyNodeOutput, type ComfyNodeSchemaJSON, ComfySchema, type ComfySchemaJSON, ComfySdkBase, ComfySdkShape, type ComfyStorage, ComfyTS, type ComfyUnionValue, type ComfyUploadImageResult, ComfyUploader, ComfyVar, ComfyVarBase, ComfyWorkflow, ComfyWorkflowBuilder, type ComfyWorkflowData, type ComfyWorkflowID, type ConnectOptions, ConvertibleImageFormat, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, type DefineWorkflowSpec, DefinedWorkflow, Either, EmptyRecord, type ExecutionProgress, type ExecutionSnapshot, Flavor, FloatVar, HTMLContent, ImageVar, ImageVarEmptyError, type ImageVarOpts, IntVar, InvalidPromptError, IsEqual, type LiteGraphJSON, type LmLoraItem, type LoraMirror, type LoraNameOf, type LoraStrength, type LoraSweep, type LorasHost, LorasVar, MDContent, Maybe, MediaImage, type MediaImageData, type NodeMode, NodeOf, type ParsedHostBase, PartialOmit, type PluginInstallStatus, type PluginSuggestion, type ProgressReport, type PromptID, type PromptRelated_WsMsg, type PromptValue, PromptVar, type QualifiedNodeKey, RelativePath, type Requirements, ResilientWebSocketClient, Result, ResultFailure, type RunSettings, SaveOptions, SdkForHost, SeedVar, type SizePreset, type SizeValue, SizeVar, Tagged, TextVar, ToggleVar, type VarKind, type VarValues, type VarsSpec, WorkflowConvertError, WorkflowNormalizeError, type WsLike, type WsMessageEvent, type WsMsg, __FAIL, __OK, activeLoras, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, clearLoraKeywordOverride, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, getComfyStorage, getLoraDisplayName, getLoraInfo, getLoraKeyword, getLoraPreviewUrl, getLoraTriggerWords, hostIdToNamespace, isLoraKeywordFromMirror, loraKey, loraKeywordFromMirror, loraMatchesFilter, loraSearchNames, loraSearchText, loraTag, normalizeWorkflow, number_Timestamp, parseHostBase, parseWorkflowJson, reloadLoraInfoCache, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, v };
17504
+ export { AbsolutePath, type ActiveLora, type ActiveLoraSource, type AnyVar, BaseNode, BaseNodeFactory, BaseNodeInputs, BaseNodeOutputs, type BoundVars, Branded, type CanonicalGroup, type CanonicalInput, type CanonicalLink, type CanonicalNode, type CanonicalOutput, type CanonicalWidgetValues, type CanonicalWorkflow, ChoiceVar, type CodegenOptions, type ComfyApiJson, type ComfyApiNodeJson, ComfyExecution, type ComfyExecutionData, type ComfyExecutionStatus, ComfyHost, ComfyHostAuthError, type ComfyHostData, type ComfyHostID, ComfyHostUnreachableError, type ComfyImageName, ComfyManager, ComfyNode, type ComfyNodeId, type ComfyNodeIdMode, type ComfyNodeMetadata, ComfyNodeOutput, type ComfyNodeSchemaJSON, ComfySchema, type ComfySchemaJSON, ComfySdkBase, ComfySdkShape, type ComfyStorage, ComfyTS, type ComfyUnionValue, type ComfyUploadImageResult, ComfyUploader, ComfyVar, ComfyVarBase, ComfyWorkflow, ComfyWorkflowBuilder, type ComfyWorkflowData, type ComfyWorkflowID, type ConnectOptions, ConvertibleImageFormat, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, type DefineWorkflowSpec, DefinedWorkflow, Either, EmptyRecord, type ExecutionProgress, type ExecutionSnapshot, Flavor, FloatVar, HTMLContent, ImageVar, ImageVarEmptyError, type ImageVarOpts, IntVar, InvalidPromptError, IsEqual, type LiteGraphJSON, type LmLoraItem, type LoraMirror, type LoraNameOf, type LoraStrength, type LoraSweep, type LorasHost, LorasVar, MDContent, Maybe, MediaImage, type MediaImageData, type NodeMode, NodeOf, type ParsedHostBase, PartialOmit, type PluginInstallStatus, type PluginSuggestion, type ProgressReport, type PromptID, type PromptRelated_WsMsg, type PromptValue, PromptVar, type QualifiedNodeKey, RelativePath, type Requirements, ResilientWebSocketClient, Result, ResultFailure, type RunSettings, SaveOptions, SdkForHost, SeedVar, type SizePreset, type SizeValue, SizeVar, Tagged, TextVar, ToggleVar, type VarKind, type VarValues, type VarsSpec, WorkflowConvertError, WorkflowNormalizeError, type WsLike, type WsMessageEvent, type WsMsg, __FAIL, __OK, activeLoras, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, clearLoraKeywordOverride, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, getComfyStorage, getLoraDisplayName, getLoraInfo, getLoraKeyword, getLoraPreviewUrl, getLoraTriggerWords, hostIdToNamespace, isLoraKeywordFromMirror, loraKey, loraKeywordFromMirror, loraMatchesFilter, loraSearchNames, loraSearchText, loraTag, normalizeWorkflow, number_Timestamp, parseHostBase, parseWorkflowJson, refreshLoraInfoCacheIfChanged, reloadLoraInfoCache, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, v };
17501
17505
  //# sourceMappingURL=web.d.ts.map
package/dist/web.js CHANGED
@@ -101,7 +101,7 @@ function getComfyStorage() {
101
101
  }
102
102
  //#endregion
103
103
  //#region package.json
104
- var version = "2.4.1";
104
+ var version = "2.5.0";
105
105
  //#endregion
106
106
  //#region src/litegraph/LiteGraphLinkID.ts
107
107
  const asLiteGraphLinkID = (id) => id;
@@ -3988,25 +3988,40 @@ function readLoraMirror(hostId) {
3988
3988
  * `comfyts.hosts` — exactly the hosts this process can be asked about.
3989
3989
  */
3990
3990
  const byHost = /* @__PURE__ */ new Map();
3991
- /** hosts already looked for, INCLUDING the ones with no mirror (see reloadLoraInfoCache) */
3992
- const loadedHostIds = /* @__PURE__ */ new Set();
3991
+ /** hosts already looked for, INCLUDING the ones with no mirror on disk → their mtime is null */
3992
+ const loadedMtimes = /* @__PURE__ */ new Map();
3993
+ /** cheap: no stat, no parse — this runs inside the overlay's render for every row */
3993
3994
  function ensureLoaded() {
3994
- for (const hostId of comfyts.hosts.keys()) {
3995
- if (loadedHostIds.has(hostId)) continue;
3996
- loadedHostIds.add(hostId);
3997
- const mirror = readLoraMirror(hostId);
3998
- if (mirror == null) continue;
3999
- byHost.set(hostId, new Map(Object.entries(mirror.loras)));
4000
- }
3995
+ for (const hostId of comfyts.hosts.keys()) if (!loadedMtimes.has(hostId)) loadHost(hostId);
3996
+ }
3997
+ function loadHost(hostId) {
3998
+ const storage = getComfyStorage();
3999
+ const path = loraMirrorPath(hostId);
4000
+ loadedMtimes.set(hostId, storage.mtimeMs(path));
4001
+ const mirror = readLoraMirror(hostId);
4002
+ if (mirror != null) byHost.set(hostId, new Map(Object.entries(mirror.loras)));
4003
+ else if (storage.exists(path)) byHost.set(hostId, /* @__PURE__ */ new Map());
4004
+ else byHost.delete(hostId);
4001
4005
  }
4002
4006
  /**
4003
- * forget everything loaded, so the next read picks up a fresh `comfy-ts loras`.
4004
- * A long-lived process (the TUI, `comfy-ts serve`) has no other way to see a
4005
- * re-sync that happened in another terminal.
4007
+ * re-read any mirror whose file changed (or appeared) since we loaded it.
4008
+ * `comfy-ts loras` in another terminal is the normal case, and without this a
4009
+ * TUI session kept the stale data — or kept knowing NOTHING, for a host whose
4010
+ * first sync happened while it was open. One stat per registered host, so this
4011
+ * belongs at user-initiated moments (opening the loras overlay), never in a render.
4006
4012
  */
4013
+ function refreshLoraInfoCacheIfChanged() {
4014
+ const storage = getComfyStorage();
4015
+ for (const hostId of comfyts.hosts.keys()) {
4016
+ const seen = loadedMtimes.get(hostId);
4017
+ const now = storage.mtimeMs(loraMirrorPath(hostId));
4018
+ if (!loadedMtimes.has(hostId) || seen !== now) loadHost(hostId);
4019
+ }
4020
+ }
4021
+ /** forget everything loaded, so the next read re-reads from disk (tests, and a hard refresh) */
4007
4022
  function reloadLoraInfoCache() {
4008
4023
  byHost.clear();
4009
- loadedHostIds.clear();
4024
+ loadedMtimes.clear();
4010
4025
  }
4011
4026
  /**
4012
4027
  * the lm item for a raw lora name (`styles\x.safetensors`).
@@ -5990,6 +6005,6 @@ function loraTag(name, strength = 1, clipStrength) {
5990
6005
  */
5991
6006
  setDefaultComfyStorage(createMemoryStorage());
5992
6007
  //#endregion
5993
- export { ChoiceVar, ComfyExecution, ComfyHost, ComfyHostAuthError, ComfyHostUnreachableError, ComfyManager, ComfyNode, ComfyNodeOutput, ComfySchema, ComfyTS, ComfyUploader, ComfyVar, ComfyVarBase, ComfyWorkflow, ComfyWorkflowBuilder, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, DefinedWorkflow, FloatVar, ImageVar, ImageVarEmptyError, IntVar, InvalidPromptError, LorasVar, MediaImage, PromptVar, ResilientWebSocketClient, SeedVar, SizeVar, TextVar, ToggleVar, WorkflowConvertError, WorkflowNormalizeError, __FAIL, __OK, activeLoras, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, clearLoraKeywordOverride, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, getComfyStorage, getLoraDisplayName, getLoraInfo, getLoraKeyword, getLoraPreviewUrl, getLoraTriggerWords, hostIdToNamespace, isLoraKeywordFromMirror, loraKey, loraKeywordFromMirror, loraMatchesFilter, loraSearchNames, loraSearchText, loraTag, normalizeWorkflow, parseHostBase, parseWorkflowJson, reloadLoraInfoCache, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, v };
6008
+ export { ChoiceVar, ComfyExecution, ComfyHost, ComfyHostAuthError, ComfyHostUnreachableError, ComfyManager, ComfyNode, ComfyNodeOutput, ComfySchema, ComfyTS, ComfyUploader, ComfyVar, ComfyVarBase, ComfyWorkflow, ComfyWorkflowBuilder, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, DefinedWorkflow, FloatVar, ImageVar, ImageVarEmptyError, IntVar, InvalidPromptError, LorasVar, MediaImage, PromptVar, ResilientWebSocketClient, SeedVar, SizeVar, TextVar, ToggleVar, WorkflowConvertError, WorkflowNormalizeError, __FAIL, __OK, activeLoras, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, clearLoraKeywordOverride, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, getComfyStorage, getLoraDisplayName, getLoraInfo, getLoraKeyword, getLoraPreviewUrl, getLoraTriggerWords, hostIdToNamespace, isLoraKeywordFromMirror, loraKey, loraKeywordFromMirror, loraMatchesFilter, loraSearchNames, loraSearchText, loraTag, normalizeWorkflow, parseHostBase, parseWorkflowJson, refreshLoraInfoCacheIfChanged, reloadLoraInfoCache, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, v };
5994
6009
 
5995
6010
  //# sourceMappingURL=web.js.map