comfy-ts 2.20.2 → 2.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -1
- package/dist/{ServeApp-B469W26E.js → ServeApp-DuxYdaZZ.js} +142 -7
- package/dist/ServeApp-DuxYdaZZ.js.map +1 -0
- package/dist/cli.js +5 -5
- package/dist/{exampleAssets-yBLaKXLq.js → exampleAssets-1NHndnNB.js} +59 -17
- package/dist/exampleAssets-1NHndnNB.js.map +1 -0
- package/dist/{findDefinedWorkflow-B90-xFxX.js → findDefinedWorkflow-CRsBTTJK.js} +2 -2
- package/dist/{findDefinedWorkflow-B90-xFxX.js.map → findDefinedWorkflow-CRsBTTJK.js.map} +1 -1
- package/dist/index.cjs +118 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +90 -9
- package/dist/index.d.ts +90 -9
- package/dist/index.js +117 -20
- package/dist/index.js.map +1 -1
- package/dist/{run-run-C-dDD9Dc.js → run-run-Y5ZI48vV.js} +5 -5
- package/dist/{run-run-C-dDD9Dc.js.map → run-run-Y5ZI48vV.js.map} +1 -1
- package/dist/{run-serve-CsEYPGm9.js → run-serve-CICU_wTL.js} +4 -4
- package/dist/{run-serve-CsEYPGm9.js.map → run-serve-CICU_wTL.js.map} +1 -1
- package/dist/{run-tui-bsmja4hi.js → run-tui-CViJXsHL.js} +4 -4
- package/dist/{run-tui-bsmja4hi.js.map → run-tui-CViJXsHL.js.map} +1 -1
- package/dist/{schemaDrift-DaWsE-mt.js → schemaDrift-CzjaIwZX.js} +53 -20
- package/dist/schemaDrift-CzjaIwZX.js.map +1 -0
- package/dist/serve-web.js +204 -47
- package/dist/web.d.ts +90 -9
- package/dist/web.js +117 -20
- package/dist/web.js.map +1 -1
- package/examples/README.md +2 -0
- package/examples/depth-explorer/models.ts +722 -0
- package/examples/depth-explorer/serve.ts +140 -0
- package/examples/depth-explorer/thumbs/bae.webp +0 -0
- package/examples/depth-explorer/thumbs/da3-mono-large.webp +0 -0
- package/examples/depth-explorer/thumbs/dav1-vitl.webp +0 -0
- package/examples/depth-explorer/thumbs/dav2-vitl.webp +0 -0
- package/examples/depth-explorer/thumbs/dsine.webp +0 -0
- package/examples/depth-explorer/thumbs/iid-albedo.webp +0 -0
- package/examples/depth-explorer/thumbs/iid-metalness.webp +0 -0
- package/examples/depth-explorer/thumbs/iid-roughness.webp +0 -0
- package/examples/depth-explorer/thumbs/iid-shading.webp +0 -0
- package/examples/depth-explorer/thumbs/iid-specular.webp +0 -0
- package/examples/depth-explorer/thumbs/leres.webp +0 -0
- package/examples/depth-explorer/thumbs/lotus-depth.webp +0 -0
- package/examples/depth-explorer/thumbs/marigold2-albedo.webp +0 -0
- package/examples/depth-explorer/thumbs/marigold2-depth.webp +0 -0
- package/examples/depth-explorer/thumbs/marigold2-normal.webp +0 -0
- package/examples/depth-explorer/thumbs/metric3d-depth.webp +0 -0
- package/examples/depth-explorer/thumbs/metric3d-normal.webp +0 -0
- package/examples/depth-explorer/thumbs/midas-normal.webp +0 -0
- package/examples/depth-explorer/thumbs/midas.webp +0 -0
- package/examples/depth-explorer/thumbs/moge2-depth.webp +0 -0
- package/examples/depth-explorer/thumbs/moge2-normal.webp +0 -0
- package/examples/depth-explorer/thumbs/zoe-da.webp +0 -0
- package/examples/depth-explorer/thumbs/zoe.webp +0 -0
- package/examples/depth-explorer/web/App.tsx +457 -0
- package/examples/depth-explorer/web/gl.ts +202 -0
- package/examples/depth-explorer/web/index.html +14 -0
- package/examples/depth-explorer/web/main.tsx +19 -0
- package/examples/depth-explorer/web/pixels.ts +86 -0
- package/examples/depth-explorer/web/state.ts +329 -0
- package/examples/depth-explorer/web/styles.css +366 -0
- package/examples/depth-explorer/web/tsconfig.json +16 -0
- package/examples/rvion/17-relight.cflow.ts +110 -0
- package/package.json +3 -2
- package/src/cli/serve/ServeApp.ts +79 -4
- package/src/cli/serve/describeVar.ts +12 -1
- package/src/cli/serve/resultHistory.ts +6 -1
- package/src/cli/serve/thumbs.ts +66 -0
- package/src/cli/serve/web/api.ts +5 -1
- package/src/cli/serve/web/components/Gallery.tsx +2 -0
- package/src/cli/serve/web/components/controls/BasicControls.tsx +14 -17
- package/src/cli/serve/web/components/controls/MediaControl.tsx +62 -9
- package/src/cli/serve/web/components/controls/RichSelect.tsx +262 -0
- package/src/cli/serve/web/state/RunSt.poll.test.ts +4 -1
- package/src/cli/serve/web/state/choiceButtons.ts +26 -2
- package/src/cli/serve/web/styles.ts +39 -0
- package/src/cli/serve/web/widgets/OutputWidgets.tsx +19 -0
- package/src/cli/serve/web/widgets/RelightSt.ts +113 -0
- package/src/cli/serve/web/widgets/RelightWidget.tsx +305 -0
- package/src/cli/serve/web/widgets/relightGl.ts +305 -0
- package/src/cli/serve/web/widgets/widgetStyles.ts +19 -0
- package/src/coreExports.ts +9 -0
- package/src/host/ComfyHost.ts +21 -0
- package/src/host/leastBusy.ts +37 -0
- package/src/state.ts +6 -0
- package/src/vars/ComfyVars.ts +32 -2
- package/src/vars/DefinedWorkflow.ts +42 -21
- package/src/vars/outputWidgets.ts +47 -0
- package/dist/ServeApp-B469W26E.js.map +0 -1
- package/dist/exampleAssets-yBLaKXLq.js.map +0 -1
- package/dist/schemaDrift-DaWsE-mt.js.map +0 -1
package/dist/web.d.ts
CHANGED
|
@@ -16925,6 +16925,41 @@ type LoraLanes<T extends string = string> = {
|
|
|
16925
16925
|
* lanes object can never be mistaken for each other */
|
|
16926
16926
|
type LorasInput<T extends string = string> = LoraRecord<T> | LoraLanes<T>;
|
|
16927
16927
|
//#endregion
|
|
16928
|
+
//#region src/vars/outputWidgets.d.ts
|
|
16929
|
+
/** the maps a relight widget reads, each the tag of one output image */
|
|
16930
|
+
type RelightRoles = {
|
|
16931
|
+
/** the photo itself; the base colour when no albedo is given */
|
|
16932
|
+
image: string;
|
|
16933
|
+
/** near = white; places each pixel in 3D and casts the shadows */
|
|
16934
|
+
depth?: string;
|
|
16935
|
+
/** OpenGL convention (green up) */
|
|
16936
|
+
normal?: string;
|
|
16937
|
+
albedo?: string;
|
|
16938
|
+
/** white = rough */
|
|
16939
|
+
roughness?: string;
|
|
16940
|
+
/** white = metal */
|
|
16941
|
+
metalness?: string;
|
|
16942
|
+
/** the non diffuse part of the light (reflections, highlights) */
|
|
16943
|
+
specular?: string;
|
|
16944
|
+
};
|
|
16945
|
+
type RelightWidget = {
|
|
16946
|
+
kind: 'relight';
|
|
16947
|
+
title?: string;
|
|
16948
|
+
roles: RelightRoles;
|
|
16949
|
+
};
|
|
16950
|
+
type OutputWidget = RelightWidget;
|
|
16951
|
+
type OutputWidgetKind = OutputWidget['kind'];
|
|
16952
|
+
declare const widget: {
|
|
16953
|
+
/** a point light moved over the image in 3D: left/right, up/down, nearer/farther */
|
|
16954
|
+
relight(roles: RelightRoles, opts?: {
|
|
16955
|
+
title?: string;
|
|
16956
|
+
}): RelightWidget;
|
|
16957
|
+
};
|
|
16958
|
+
/** the roles of a widget whose tag one of the images carries, as role → index in `images` */
|
|
16959
|
+
declare function resolveWidgetRoles(w: OutputWidget, images: {
|
|
16960
|
+
tags?: string[];
|
|
16961
|
+
}[]): Map<string, number>;
|
|
16962
|
+
//#endregion
|
|
16928
16963
|
//#region src/vars/presets.d.ts
|
|
16929
16964
|
type VarPreset = {
|
|
16930
16965
|
label: string;
|
|
@@ -16957,6 +16992,27 @@ type VarKind = 'text' | 'prompt' | 'int' | 'float' | 'seed' | 'toggle' | 'choice
|
|
|
16957
16992
|
*/
|
|
16958
16993
|
/** how a var LOOKS in the panel, set by the workflow: `v.int(8).ui({ icon, color, description })`.
|
|
16959
16994
|
* Every slot is optional, a color is any css color */
|
|
16995
|
+
/** how one option of a choice var looks in the panel. Every field is optional: a bare option
|
|
16996
|
+
* shows its value */
|
|
16997
|
+
type ChoiceOptionLook = {
|
|
16998
|
+
/** a 24×24 svg path drawn in the color, or a whole `<svg …>` string */
|
|
16999
|
+
icon?: string;
|
|
17000
|
+
color?: string;
|
|
17001
|
+
/** the name shown instead of the raw value (the value stays the payload) */
|
|
17002
|
+
label?: string;
|
|
17003
|
+
description?: string;
|
|
17004
|
+
/** a picture: an http(s) url, or a local path relative to the workflow file */
|
|
17005
|
+
thumb?: string;
|
|
17006
|
+
/** when it came out: `2025`, `2025-11` */
|
|
17007
|
+
date?: string;
|
|
17008
|
+
/** what it weighs on disk: `1.3 GB` */
|
|
17009
|
+
size?: string;
|
|
17010
|
+
/** 1 (rough) to 5 (the best of its kind) */
|
|
17011
|
+
quality?: number;
|
|
17012
|
+
/** how long it takes: `0.9 s`, `30 s` */
|
|
17013
|
+
speed?: string;
|
|
17014
|
+
tags?: string[];
|
|
17015
|
+
};
|
|
16960
17016
|
type VarUi = {
|
|
16961
17017
|
/** shown as a (?) after the label, the text is its tooltip */
|
|
16962
17018
|
description?: string;
|
|
@@ -16973,11 +17029,8 @@ type VarUi = {
|
|
|
16973
17029
|
groupColor?: string;
|
|
16974
17030
|
border?: string;
|
|
16975
17031
|
/** choice vars: a look per option, keyed by the option value. The lit option is filled
|
|
16976
|
-
* with its own color */
|
|
16977
|
-
options?: Record<string,
|
|
16978
|
-
icon?: string;
|
|
16979
|
-
color?: string;
|
|
16980
|
-
}>;
|
|
17032
|
+
* with its own color; a dropdown row shows the rest (ChoiceOptionLook) */
|
|
17033
|
+
options?: Record<string, ChoiceOptionLook>;
|
|
16981
17034
|
/** the field is shown but disabled unless every named var holds one of the listed values:
|
|
16982
17035
|
* `{ model: ['aesthetic', 'base'] }`. Checked against the var names when the workflow loads.
|
|
16983
17036
|
* Display only: a disabled var's value still reaches the build */
|
|
@@ -17380,6 +17433,10 @@ type MediaVarOpts = {
|
|
|
17380
17433
|
/** the text var a file's `<name>.txt` sidecar fills, when a driver sets this var from a file
|
|
17381
17434
|
* and leaves that one unset: a voice clip's transcript (`comfy-ts run`) */
|
|
17382
17435
|
sidecarText?: TextVar;
|
|
17436
|
+
/** one-click starting files: `{ 'a lioness': exampleImagePath(…), 'a ruin': 'https://…' }`.
|
|
17437
|
+
* A local path that is not on this machine is shown disabled, a url is fetched when a run
|
|
17438
|
+
* uses it. Key order is display order */
|
|
17439
|
+
presets?: Record<string, string>;
|
|
17383
17440
|
};
|
|
17384
17441
|
type ImageVarOpts = MediaVarOpts;
|
|
17385
17442
|
type AudioVarOpts = MediaVarOpts;
|
|
@@ -17411,6 +17468,11 @@ declare abstract class MediaVar extends ComfyVar<string> {
|
|
|
17411
17468
|
constructor(defaultValue: string, opts?: MediaVarOpts);
|
|
17412
17469
|
/** what the picker lists (lowercase, no dots) */
|
|
17413
17470
|
get extensions(): readonly string[];
|
|
17471
|
+
/** the one-click starting files, `~/` expanded, in their declared order */
|
|
17472
|
+
get presets(): {
|
|
17473
|
+
label: string;
|
|
17474
|
+
value: string;
|
|
17475
|
+
}[];
|
|
17414
17476
|
set(value: string): this;
|
|
17415
17477
|
parse(raw: string): boolean;
|
|
17416
17478
|
isSet(): boolean;
|
|
@@ -17559,6 +17621,9 @@ type DefineWorkflowSpec<ID extends string, V extends VarsSpec> = {
|
|
|
17559
17621
|
/** free search tags for the serve omnibox, added to the ones read from the graph
|
|
17560
17622
|
* (`image`, `audio`, `video`, `text`, `llm`, `edit`) */
|
|
17561
17623
|
tags?: string[];
|
|
17624
|
+
/** built-in web panel widgets drawn over a run's outputs (`widget.relight(...)`), each role
|
|
17625
|
+
* naming the `tag` of a save node. The CLI and the TUI ignore them */
|
|
17626
|
+
widgets?: OutputWidget[];
|
|
17562
17627
|
};
|
|
17563
17628
|
/**
|
|
17564
17629
|
* a re-runnable workflow definition: `build` re-executes per run with the
|
|
@@ -17588,17 +17653,22 @@ declare class DefinedWorkflow<ID extends string = string, V extends VarsSpec = V
|
|
|
17588
17653
|
* the graph is built against (TUI host override): node/model availability
|
|
17589
17654
|
* there surfaces as workflow.problems / server validation, by design.
|
|
17590
17655
|
* `p.dry` builds a graph only to read it: nothing is uploaded, lastWorkflow is left alone.
|
|
17656
|
+
* `p.values` builds from a snapshot taken earlier (run() takes it at the call).
|
|
17591
17657
|
*/
|
|
17592
17658
|
build(p?: {
|
|
17593
17659
|
advance?: boolean;
|
|
17594
|
-
host?: ComfyHost
|
|
17660
|
+
host?: ComfyHost;
|
|
17595
17661
|
dry?: boolean;
|
|
17662
|
+
values?: VarValues<V>;
|
|
17596
17663
|
}): Promise<ComfyWorkflow<ID>>;
|
|
17597
|
-
/**
|
|
17664
|
+
/** the current var values; `advance` then moves each var to its next run (the seed) */
|
|
17665
|
+
private snapshot;
|
|
17666
|
+
/** build a fresh graph from the var values AT THE CALL, send it, wait for outputs:
|
|
17667
|
+
* set a var, call run(), set it again, and each run keeps its own values.
|
|
17598
17668
|
* connects first (idempotent) — modules can import offline from the schema cache.
|
|
17599
17669
|
* `settings.host` runs against THAT host instead of the defining one. */
|
|
17600
17670
|
run(settings?: RunSettings & {
|
|
17601
|
-
host?: ComfyHost
|
|
17671
|
+
host?: ComfyHost;
|
|
17602
17672
|
}): Promise<ComfyExecution>;
|
|
17603
17673
|
}
|
|
17604
17674
|
//#endregion
|
|
@@ -17847,6 +17917,13 @@ declare class ComfyHost<ID extends string = string> {
|
|
|
17847
17917
|
* `'none'` (ComfyUI's default) means no live preview frame will ever arrive; null = the host
|
|
17848
17918
|
* does not publish its launch flags (a cloud host), so only a run can tell */
|
|
17849
17919
|
fetchPreviewMethod: () => Promise<PreviewMethod | null>;
|
|
17920
|
+
/** jobs waiting or running on this host, every client counted (`GET /prompt`) */
|
|
17921
|
+
fetchQueueSize: (p?: {
|
|
17922
|
+
timeoutMs?: number;
|
|
17923
|
+
}) => Promise<number>;
|
|
17924
|
+
/** runs started through DefinedWorkflow.run() and not finished yet: counted from the call,
|
|
17925
|
+
* before the prompt reaches the server queue, so runs started together spread out */
|
|
17926
|
+
runsInFlight: number;
|
|
17850
17927
|
/** the server's recent console buffer (entries are write CHUNKS, not lines) */
|
|
17851
17928
|
fetchRawLogs: () => Promise<{
|
|
17852
17929
|
entries: LogEntry[];
|
|
@@ -18488,6 +18565,10 @@ declare class ComfyTS {
|
|
|
18488
18565
|
host<const ID extends string>(data: ComfyHostData & {
|
|
18489
18566
|
id: ID;
|
|
18490
18567
|
}): ComfyHost<ID>;
|
|
18568
|
+
/** the host with the shortest queue, for `wf.run({ host: await comfy.leastBusy([a, b]) })` */
|
|
18569
|
+
leastBusy<H extends ComfyHost<string>>(hosts: readonly H[], p?: {
|
|
18570
|
+
timeoutMs?: number;
|
|
18571
|
+
}): Promise<H>;
|
|
18491
18572
|
/**
|
|
18492
18573
|
* A ComfyRegistry instance that provides access to all
|
|
18493
18574
|
* known Comfy nodes, models, plugins, ...
|
|
@@ -18929,5 +19010,5 @@ type HostToPanel = {
|
|
|
18929
19010
|
comfyTs: 'get-state';
|
|
18930
19011
|
};
|
|
18931
19012
|
//#endregion
|
|
18932
|
-
export { AbsolutePath, type ActiveLora, type ActiveLoraSource, type AnyChoiceVar, type AnyVar, AudioVar, type AudioVarOpts, BaseNode, BaseNodeFactory, BaseNodeInputs, BaseNodeOutputs, type BoundVars, Branded, type CanonicalGroup, type CanonicalInput, type CanonicalLink, type CanonicalNode, type CanonicalOutput, type CanonicalWidgetValues, type CanonicalWorkflow, type ChoiceSelect, ChoiceVar, type CodegenOptions, type ComfyApiJson, type ComfyApiNodeJson, type ComfyAudioOutput, 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 ComfyTextOutput, type ComfyUnionValue, type ComfyUploadImageResult, ComfyUploader, ComfyVar, ComfyVarBase, type ComfyVideoOutput, ComfyWorkflow, ComfyWorkflowBuilder, type ComfyWorkflowData, type ComfyWorkflowID, type ConnectOptions, ConvertibleImageFormat, DEFAULT_AUDIO_EXTENSIONS, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, DEFAULT_STARRED_SIZES, DEFAULT_VIDEO_EXTENSIONS, type DefineWorkflowSpec, DefinedWorkflow, Either, EmptyRecord, type ExecutionPreview, type ExecutionProgress, type ExecutionSnapshot, Flavor, FloatVar, HTMLContent, type HostSlotSource, type HostToPanel, ImageVar, ImageVarEmptyError, type ImageVarOpts, IntVar, InvalidPromptError, IsEqual, type LiteGraphJSON, type LmLoraItem, type LoraEntry, type LoraLane, type LoraLanes, type LoraMirror, type LoraNameOf, type LoraRecord, type LoraStrength, type LoraSweep, type LorasHost, type LorasInput, LorasVar, MDContent, Maybe, MediaImage, type MediaImageData, MediaVar, MediaVarEmptyError, type MediaVarOpts, type ModelVarOpts, MultiChoiceVar, type NodeMode, NodeOf, OptionalChoiceVar, type PanelError, type PanelHostAction, type PanelRequest, type PanelResultAction, type PanelState, type PanelToHost, type ParsedHostBase, PartialOmit, type PluginInstallStatus, type PluginSuggestion, type PreviewMethod, type ProgressReport, type PromptID, type PromptInput, type PromptLane, type PromptLanes, type PromptRelated_WsMsg, type PromptTagsOpts, type PromptValue, PromptVar, type PromptVarOpts, type QualifiedNodeKey, RelativePath, type Requirements, ResilientWebSocketClient, Result, ResultFailure, type RunSettings, SD15_SIZE_PRESETS, SaveOptions, SdkForHost, SeedVar, type SizePreset, type SizeValue, SizeVar, type SlotNameOf, type SlotValueOf, Tagged, TextVar, type TextVarOpts, ToggleVar, type VarKind, type VarPreset, type VarPresetSpec, type VarUi, type VarValues, type VarsSpec, VideoVar, type VideoVarOpts, WorkflowConvertError, WorkflowNormalizeError, type WsLike, type WsMessageEvent, type WsMsg, __FAIL, __OK, activeLoras, activePresetLabel, 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, sizePresetsFor, toPresetList, v };
|
|
19013
|
+
export { AbsolutePath, type ActiveLora, type ActiveLoraSource, type AnyChoiceVar, type AnyVar, AudioVar, type AudioVarOpts, BaseNode, BaseNodeFactory, BaseNodeInputs, BaseNodeOutputs, type BoundVars, Branded, type CanonicalGroup, type CanonicalInput, type CanonicalLink, type CanonicalNode, type CanonicalOutput, type CanonicalWidgetValues, type CanonicalWorkflow, type ChoiceOptionLook, type ChoiceSelect, ChoiceVar, type CodegenOptions, type ComfyApiJson, type ComfyApiNodeJson, type ComfyAudioOutput, 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 ComfyTextOutput, type ComfyUnionValue, type ComfyUploadImageResult, ComfyUploader, ComfyVar, ComfyVarBase, type ComfyVideoOutput, ComfyWorkflow, ComfyWorkflowBuilder, type ComfyWorkflowData, type ComfyWorkflowID, type ConnectOptions, ConvertibleImageFormat, DEFAULT_AUDIO_EXTENSIONS, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, DEFAULT_STARRED_SIZES, DEFAULT_VIDEO_EXTENSIONS, type DefineWorkflowSpec, DefinedWorkflow, Either, EmptyRecord, type ExecutionPreview, type ExecutionProgress, type ExecutionSnapshot, Flavor, FloatVar, HTMLContent, type HostSlotSource, type HostToPanel, ImageVar, ImageVarEmptyError, type ImageVarOpts, IntVar, InvalidPromptError, IsEqual, type LiteGraphJSON, type LmLoraItem, type LoraEntry, type LoraLane, type LoraLanes, type LoraMirror, type LoraNameOf, type LoraRecord, type LoraStrength, type LoraSweep, type LorasHost, type LorasInput, LorasVar, MDContent, Maybe, MediaImage, type MediaImageData, MediaVar, MediaVarEmptyError, type MediaVarOpts, type ModelVarOpts, MultiChoiceVar, type NodeMode, NodeOf, OptionalChoiceVar, type OutputWidget, type OutputWidgetKind, type PanelError, type PanelHostAction, type PanelRequest, type PanelResultAction, type PanelState, type PanelToHost, type ParsedHostBase, PartialOmit, type PluginInstallStatus, type PluginSuggestion, type PreviewMethod, type ProgressReport, type PromptID, type PromptInput, type PromptLane, type PromptLanes, type PromptRelated_WsMsg, type PromptTagsOpts, type PromptValue, PromptVar, type PromptVarOpts, type QualifiedNodeKey, RelativePath, type RelightRoles, type RelightWidget, type Requirements, ResilientWebSocketClient, Result, ResultFailure, type RunSettings, SD15_SIZE_PRESETS, SaveOptions, SdkForHost, SeedVar, type SizePreset, type SizeValue, SizeVar, type SlotNameOf, type SlotValueOf, Tagged, TextVar, type TextVarOpts, ToggleVar, type VarKind, type VarPreset, type VarPresetSpec, type VarUi, type VarValues, type VarsSpec, VideoVar, type VideoVarOpts, WorkflowConvertError, WorkflowNormalizeError, type WsLike, type WsMessageEvent, type WsMsg, __FAIL, __OK, activeLoras, activePresetLabel, 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, resolveWidgetRoles, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, sizePresetsFor, toPresetList, v, widget };
|
|
18933
19014
|
//# 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.
|
|
104
|
+
var version = "2.22.0";
|
|
105
105
|
//#endregion
|
|
106
106
|
//#region src/litegraph/LiteGraphLinkID.ts
|
|
107
107
|
const asLiteGraphLinkID = (id) => id;
|
|
@@ -6522,6 +6522,13 @@ var MediaVar = class extends ComfyVar {
|
|
|
6522
6522
|
get extensions() {
|
|
6523
6523
|
return this.opts.extensions ?? DEFAULT_MEDIA_EXTENSIONS[this.kind];
|
|
6524
6524
|
}
|
|
6525
|
+
/** the one-click starting files, `~/` expanded, in their declared order */
|
|
6526
|
+
get presets() {
|
|
6527
|
+
return Object.entries(this.opts.presets ?? {}).map(([label, value]) => ({
|
|
6528
|
+
label,
|
|
6529
|
+
value: expandUserPath(value)
|
|
6530
|
+
}));
|
|
6531
|
+
}
|
|
6525
6532
|
set(value) {
|
|
6526
6533
|
return super.set(expandUserPath(value));
|
|
6527
6534
|
}
|
|
@@ -6684,37 +6691,50 @@ var DefinedWorkflow = class {
|
|
|
6684
6691
|
* the graph is built against (TUI host override): node/model availability
|
|
6685
6692
|
* there surfaces as workflow.problems / server validation, by design.
|
|
6686
6693
|
* `p.dry` builds a graph only to read it: nothing is uploaded, lastWorkflow is left alone.
|
|
6694
|
+
* `p.values` builds from a snapshot taken earlier (run() takes it at the call).
|
|
6687
6695
|
*/
|
|
6688
6696
|
async build(p = {}) {
|
|
6689
6697
|
const wf = (p.host ?? this.host).workflow({ id: this.spec.id });
|
|
6690
6698
|
wf.dry = p.dry === true;
|
|
6691
|
-
const values =
|
|
6692
|
-
if (p.advance) for (const varDef of Object.values(this.vars)) varDef.afterRun();
|
|
6699
|
+
const values = p.values ?? this.snapshot({ advance: p.advance === true });
|
|
6693
6700
|
await this.spec.build(wf.builder, values, wf);
|
|
6694
6701
|
if (wf.dry) return wf;
|
|
6695
6702
|
this.lastWorkflow = wf;
|
|
6696
6703
|
return wf;
|
|
6697
6704
|
}
|
|
6698
|
-
/**
|
|
6705
|
+
/** the current var values; `advance` then moves each var to its next run (the seed) */
|
|
6706
|
+
snapshot(p) {
|
|
6707
|
+
const values = varValues(this.vars);
|
|
6708
|
+
if (p.advance) for (const varDef of Object.values(this.vars)) varDef.afterRun();
|
|
6709
|
+
return values;
|
|
6710
|
+
}
|
|
6711
|
+
/** build a fresh graph from the var values AT THE CALL, send it, wait for outputs:
|
|
6712
|
+
* set a var, call run(), set it again, and each run keeps its own values.
|
|
6699
6713
|
* connects first (idempotent) — modules can import offline from the schema cache.
|
|
6700
6714
|
* `settings.host` runs against THAT host instead of the defining one. */
|
|
6701
6715
|
async run(settings = {}) {
|
|
6702
6716
|
const host = settings.host ?? this.host;
|
|
6703
|
-
|
|
6704
|
-
|
|
6705
|
-
|
|
6706
|
-
host
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
|
|
6713
|
-
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6717
|
+
const values = this.snapshot({ advance: true });
|
|
6718
|
+
host.runsInFlight++;
|
|
6719
|
+
try {
|
|
6720
|
+
await host.connect();
|
|
6721
|
+
const execution = await (await this.build({
|
|
6722
|
+
host,
|
|
6723
|
+
values
|
|
6724
|
+
})).run({
|
|
6725
|
+
save: settings.save,
|
|
6726
|
+
ephemeral: settings.ephemeral,
|
|
6727
|
+
scrubHistory: settings.scrubHistory,
|
|
6728
|
+
idMode: settings.idMode,
|
|
6729
|
+
log: settings.log,
|
|
6730
|
+
onProgress: settings.onProgress,
|
|
6731
|
+
onPreview: settings.onPreview
|
|
6732
|
+
});
|
|
6733
|
+
this.lastExecution = execution;
|
|
6734
|
+
return execution;
|
|
6735
|
+
} finally {
|
|
6736
|
+
host.runsInFlight--;
|
|
6737
|
+
}
|
|
6718
6738
|
}
|
|
6719
6739
|
};
|
|
6720
6740
|
//#endregion
|
|
@@ -7026,6 +7046,14 @@ var ComfyHost = class {
|
|
|
7026
7046
|
if (!res.ok) throw new Error(`GET /system_stats failed: ${res.status}`);
|
|
7027
7047
|
return previewMethodFromSystemStats(await res.json());
|
|
7028
7048
|
};
|
|
7049
|
+
this.fetchQueueSize = async (p = {}) => {
|
|
7050
|
+
const res = await this.fetch("/prompt", { signal: AbortSignal.timeout(p.timeoutMs ?? 3e3) });
|
|
7051
|
+
if (!res.ok) throw new Error(`GET /prompt failed: ${res.status}`);
|
|
7052
|
+
const size = queueRemainingOf(await res.json());
|
|
7053
|
+
if (size == null) throw new Error(`GET /prompt: no exec_info.queue_remaining in the reply`);
|
|
7054
|
+
return size;
|
|
7055
|
+
};
|
|
7056
|
+
this.runsInFlight = 0;
|
|
7029
7057
|
this.fetchRawLogs = async () => {
|
|
7030
7058
|
const res = await this.fetch("/internal/logs/raw", {}, { apiPrefix: false });
|
|
7031
7059
|
if (!res.ok) throw new Error(`GET /internal/logs/raw failed: ${res.status}`);
|
|
@@ -7424,6 +7452,49 @@ var ComfyHost = class {
|
|
|
7424
7452
|
}
|
|
7425
7453
|
}
|
|
7426
7454
|
};
|
|
7455
|
+
/** `exec_info.queue_remaining` of a `GET /prompt` reply, null when the shape is not there */
|
|
7456
|
+
function queueRemainingOf(json) {
|
|
7457
|
+
if (typeof json !== "object" || json == null || !("exec_info" in json)) return null;
|
|
7458
|
+
const info = json.exec_info;
|
|
7459
|
+
if (typeof info !== "object" || info == null || !("queue_remaining" in info)) return null;
|
|
7460
|
+
return typeof info.queue_remaining === "number" ? info.queue_remaining : null;
|
|
7461
|
+
}
|
|
7462
|
+
//#endregion
|
|
7463
|
+
//#region src/host/leastBusy.ts
|
|
7464
|
+
/**
|
|
7465
|
+
* the host with the shortest queue. Score = max(server queue, our runs in flight there):
|
|
7466
|
+
* the server counts every client, the local count sees runs not posted yet.
|
|
7467
|
+
* Ties go to the first host listed; a host that does not answer is skipped, all down throws.
|
|
7468
|
+
*/
|
|
7469
|
+
async function leastBusy(hosts, p = {}) {
|
|
7470
|
+
if (hosts.length === 0) throw new Error("leastBusy: no host given");
|
|
7471
|
+
const probes = await Promise.all(hosts.map(async (host) => {
|
|
7472
|
+
try {
|
|
7473
|
+
const queue = await host.fetchQueueSize({ timeoutMs: p.timeoutMs });
|
|
7474
|
+
return {
|
|
7475
|
+
host,
|
|
7476
|
+
score: Math.max(queue, host.runsInFlight),
|
|
7477
|
+
error: null
|
|
7478
|
+
};
|
|
7479
|
+
} catch (err) {
|
|
7480
|
+
return {
|
|
7481
|
+
host,
|
|
7482
|
+
score: Infinity,
|
|
7483
|
+
error: extractErrorMessage(err)
|
|
7484
|
+
};
|
|
7485
|
+
}
|
|
7486
|
+
}));
|
|
7487
|
+
let best = null;
|
|
7488
|
+
for (const probe of probes) {
|
|
7489
|
+
if (probe.error != null) {
|
|
7490
|
+
console.warn(`🟡 leastBusy: host '${probe.host.data.id}' skipped: ${probe.error}`);
|
|
7491
|
+
continue;
|
|
7492
|
+
}
|
|
7493
|
+
if (best == null || probe.score < best.score) best = probe;
|
|
7494
|
+
}
|
|
7495
|
+
if (best == null) throw new Error(`🔴 leastBusy: no host answered (${probes.map((x) => `'${x.host.data.id}': ${x.error}`).join(", ")})`);
|
|
7496
|
+
return best.host;
|
|
7497
|
+
}
|
|
7427
7498
|
//#endregion
|
|
7428
7499
|
//#region src/utils/downloadFile.ts
|
|
7429
7500
|
async function downloadFile(url, outputPath, logPrefix = " - ") {
|
|
@@ -8040,6 +8111,10 @@ var ComfyTS = class ComfyTS {
|
|
|
8040
8111
|
this.hosts.set(data.id, created);
|
|
8041
8112
|
return created;
|
|
8042
8113
|
}
|
|
8114
|
+
/** the host with the shortest queue, for `wf.run({ host: await comfy.leastBusy([a, b]) })` */
|
|
8115
|
+
leastBusy(hosts, p = {}) {
|
|
8116
|
+
return leastBusy(hosts, p);
|
|
8117
|
+
}
|
|
8043
8118
|
get registry() {
|
|
8044
8119
|
if (this._registry == null) this._registry = new ComfyRegistry({
|
|
8045
8120
|
check: false,
|
|
@@ -8082,6 +8157,28 @@ var ComfyTS = class ComfyTS {
|
|
|
8082
8157
|
}
|
|
8083
8158
|
};
|
|
8084
8159
|
//#endregion
|
|
8160
|
+
//#region src/vars/outputWidgets.ts
|
|
8161
|
+
const widget = {
|
|
8162
|
+
/** a point light moved over the image in 3D: left/right, up/down, nearer/farther */
|
|
8163
|
+
relight(roles, opts = {}) {
|
|
8164
|
+
if (roles.depth == null && roles.normal == null) throw new Error("widget.relight needs a `depth` or a `normal` role: without either there is no surface to light");
|
|
8165
|
+
return {
|
|
8166
|
+
kind: "relight",
|
|
8167
|
+
roles,
|
|
8168
|
+
...opts.title != null ? { title: opts.title } : {}
|
|
8169
|
+
};
|
|
8170
|
+
} };
|
|
8171
|
+
/** the roles of a widget whose tag one of the images carries, as role → index in `images` */
|
|
8172
|
+
function resolveWidgetRoles(w, images) {
|
|
8173
|
+
const out = /* @__PURE__ */ new Map();
|
|
8174
|
+
for (const [role, tag] of Object.entries(w.roles)) {
|
|
8175
|
+
if (typeof tag !== "string") continue;
|
|
8176
|
+
const ix = images.findIndex((img) => img.tags?.includes(tag) === true);
|
|
8177
|
+
if (ix >= 0) out.set(role, ix);
|
|
8178
|
+
}
|
|
8179
|
+
return out;
|
|
8180
|
+
}
|
|
8181
|
+
//#endregion
|
|
8085
8182
|
//#region src/utils/loraTag.ts
|
|
8086
8183
|
/**
|
|
8087
8184
|
* build a LoraManager-style lora tag: `<lora:name:strength>` or
|
|
@@ -8105,6 +8202,6 @@ function loraTag(name, strength = 1, clipStrength) {
|
|
|
8105
8202
|
*/
|
|
8106
8203
|
setDefaultComfyStorage(createMemoryStorage());
|
|
8107
8204
|
//#endregion
|
|
8108
|
-
export { AudioVar, ChoiceVar, ComfyExecution, ComfyHost, ComfyHostAuthError, ComfyHostUnreachableError, ComfyManager, ComfyNode, ComfyNodeOutput, ComfySchema, ComfyTS, ComfyUploader, ComfyVar, ComfyVarBase, ComfyWorkflow, ComfyWorkflowBuilder, DEFAULT_AUDIO_EXTENSIONS, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, DEFAULT_STARRED_SIZES, DEFAULT_VIDEO_EXTENSIONS, DefinedWorkflow, FloatVar, ImageVar, ImageVarEmptyError, IntVar, InvalidPromptError, LorasVar, MediaImage, MediaVar, MediaVarEmptyError, MultiChoiceVar, OptionalChoiceVar, PromptVar, ResilientWebSocketClient, SD15_SIZE_PRESETS, SeedVar, SizeVar, TextVar, ToggleVar, VideoVar, WorkflowConvertError, WorkflowNormalizeError, __FAIL, __OK, activeLoras, activePresetLabel, 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, sizePresetsFor, toPresetList, v };
|
|
8205
|
+
export { AudioVar, ChoiceVar, ComfyExecution, ComfyHost, ComfyHostAuthError, ComfyHostUnreachableError, ComfyManager, ComfyNode, ComfyNodeOutput, ComfySchema, ComfyTS, ComfyUploader, ComfyVar, ComfyVarBase, ComfyWorkflow, ComfyWorkflowBuilder, DEFAULT_AUDIO_EXTENSIONS, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, DEFAULT_STARRED_SIZES, DEFAULT_VIDEO_EXTENSIONS, DefinedWorkflow, FloatVar, ImageVar, ImageVarEmptyError, IntVar, InvalidPromptError, LorasVar, MediaImage, MediaVar, MediaVarEmptyError, MultiChoiceVar, OptionalChoiceVar, PromptVar, ResilientWebSocketClient, SD15_SIZE_PRESETS, SeedVar, SizeVar, TextVar, ToggleVar, VideoVar, WorkflowConvertError, WorkflowNormalizeError, __FAIL, __OK, activeLoras, activePresetLabel, 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, resolveWidgetRoles, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, sizePresetsFor, toPresetList, v, widget };
|
|
8109
8206
|
|
|
8110
8207
|
//# sourceMappingURL=web.js.map
|