comfy-ts 2.15.0 → 2.17.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 +23 -0
- package/dist/{run-serve-B5PfIuhK.js → ServeApp-BSA5yzxZ.js} +28 -446
- package/dist/ServeApp-BSA5yzxZ.js.map +1 -0
- package/dist/cli.js +18 -5
- package/dist/cli.js.map +1 -1
- package/dist/exampleAssets-BfWzygoM.js +38 -0
- package/dist/exampleAssets-BfWzygoM.js.map +1 -0
- package/dist/{LogsSt-C3UIWR-o.js → findDefinedWorkflow-0lG-VTEd.js} +201 -201
- package/dist/findDefinedWorkflow-0lG-VTEd.js.map +1 -0
- package/dist/index.cjs +202 -62
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +115 -14
- package/dist/index.d.ts +115 -14
- package/dist/index.js +202 -62
- package/dist/index.js.map +1 -1
- package/dist/run-run-DnaMLCFn.js +450 -0
- package/dist/run-run-DnaMLCFn.js.map +1 -0
- package/dist/run-serve-CbKxIu6i.js +418 -0
- package/dist/run-serve-CbKxIu6i.js.map +1 -0
- package/dist/{run-tui-D-N4_yyX.js → run-tui-B0AQWbad.js} +6 -37
- package/dist/run-tui-B0AQWbad.js.map +1 -0
- package/dist/{schemaDrift-BkN8rLiZ.js → schemaDrift-CbsABBuk.js} +59 -5
- package/dist/schemaDrift-CbsABBuk.js.map +1 -0
- package/dist/serve-web.js +48 -48
- package/dist/{state-CZsYJqB6.js → state-C2oDiQ26.js} +146 -60
- package/dist/state-C2oDiQ26.js.map +1 -0
- package/dist/web.d.ts +115 -14
- package/dist/web.js +202 -62
- package/dist/web.js.map +1 -1
- package/examples/README.md +2 -0
- package/examples/media/README.md +6 -5
- package/examples/media/voice_en_6s.flac +0 -0
- package/examples/rvion/04-krea2-turbo-t2i.cflow.ts +9 -1
- package/examples/rvion/10-anima-t2i.cflow.ts +8 -1
- package/examples/rvion/15-tts-voice-clone.cflow.ts +111 -0
- package/examples/rvion/16-tts-voice-design.cflow.ts +71 -0
- package/guide-for-agents.md +5 -1
- package/package.json +2 -2
- package/src/cli/comfy-ts-cli.ts +14 -1
- package/src/cli/run/findModules.ts +36 -0
- package/src/cli/run/flagValue.ts +61 -0
- package/src/cli/run/outputPaths.ts +41 -0
- package/src/cli/run/pickModule.ts +41 -0
- package/src/cli/run/run-run.ts +250 -0
- package/src/cli/run/runArgs.ts +61 -0
- package/src/cli/run/sidecar.ts +27 -0
- package/src/cli/serve/ServeApp.ts +28 -42
- package/src/cli/serve/web/components/DraftTabs.tsx +10 -3
- package/src/cli/serve/web/components/Gallery.tsx +2 -1
- package/src/cli/serve/web/components/HistoryPicker.tsx +5 -3
- package/src/cli/serve/web/components/MenuButton.tsx +2 -4
- package/src/cli/serve/web/components/Omnibox.tsx +2 -1
- package/src/cli/serve/web/components/PromptEnhancer.tsx +4 -3
- package/src/cli/serve/web/components/ShortcutsModal.tsx +2 -1
- package/src/cli/serve/web/components/SideMenu.tsx +2 -1
- package/src/cli/serve/web/components/controls/LorasControl.tsx +4 -3
- package/src/cli/serve/web/components/controls/PresetPicker.tsx +2 -1
- package/src/cli/serve/web/components/controls/PromptControl.tsx +2 -1
- package/src/cli/serve/web/components/controls/SizeControl.tsx +2 -1
- package/src/cli/serve/web/state/draftTabs.ts +12 -0
- package/src/cli/serve/web/state/escape.ts +16 -0
- package/src/cli/serve/web/state/shortcutCatalog.ts +1 -0
- package/src/coreExports.ts +12 -1
- package/src/host/ComfyHost.ts +73 -40
- package/src/host/previewMethod.ts +29 -0
- package/src/runner/ComfyExecution.ts +45 -1
- package/src/runner/ComfyWorkflow.ts +6 -1
- package/src/runner/ComfyWsApi.ts +1 -1
- package/src/runner/wsBinaryFrame.ts +48 -25
- package/src/vars/ComfyVars.ts +86 -13
- package/src/vars/DefinedWorkflow.ts +36 -2
- package/dist/LogsSt-C3UIWR-o.js.map +0 -1
- package/dist/run-serve-B5PfIuhK.js.map +0 -1
- package/dist/run-tui-D-N4_yyX.js.map +0 -1
- package/dist/schemaDrift-BkN8rLiZ.js.map +0 -1
- package/dist/state-CZsYJqB6.js.map +0 -1
package/dist/web.d.ts
CHANGED
|
@@ -12283,6 +12283,7 @@ type PendingBinaryFrame = {
|
|
|
12283
12283
|
type: 'binary_preview_frame';
|
|
12284
12284
|
bytes: Uint8Array;
|
|
12285
12285
|
mime: string;
|
|
12286
|
+
metadata: unknown;
|
|
12286
12287
|
};
|
|
12287
12288
|
type PendingWsItem = PromptRelated_WsMsg | PendingBinaryFrame;
|
|
12288
12289
|
type WsMsg = typeof types$1.WsMsg.infer;
|
|
@@ -12759,6 +12760,25 @@ type ExecutionProgress = ProgressReport & {
|
|
|
12759
12760
|
* puts its partial answer here every few tokens */
|
|
12760
12761
|
progressText: string | null;
|
|
12761
12762
|
};
|
|
12763
|
+
/** one live preview frame of a run: the image a sampler is forming, once per step */
|
|
12764
|
+
type ExecutionPreview = {
|
|
12765
|
+
promptId: PromptID;
|
|
12766
|
+
/** the image as ComfyUI encoded it, jpeg or png */
|
|
12767
|
+
bytes: Uint8Array;
|
|
12768
|
+
mime: string;
|
|
12769
|
+
/** the node that sent the frame: the frame's own metadata when it names one (type 4 frames),
|
|
12770
|
+
* else the node executing when it arrived. Null when neither is known */
|
|
12771
|
+
nodeId: ComfyNodeId | null;
|
|
12772
|
+
/** that node's class name in the sent prompt (`KSampler`), null when unknown */
|
|
12773
|
+
nodeName: string | null;
|
|
12774
|
+
/** that node's own counter when the frame arrived (sampler step of total), null when unknown */
|
|
12775
|
+
step: {
|
|
12776
|
+
value: number;
|
|
12777
|
+
max: number;
|
|
12778
|
+
} | null;
|
|
12779
|
+
/** the raw metadata json of a type 4 frame (`node_id`, `prompt_id`, …), null on a type 1 frame */
|
|
12780
|
+
metadata: unknown;
|
|
12781
|
+
};
|
|
12762
12782
|
declare class ComfyExecution {
|
|
12763
12783
|
workflow: ComfyWorkflow;
|
|
12764
12784
|
data: ComfyExecutionData;
|
|
@@ -12769,6 +12789,7 @@ declare class ComfyExecution {
|
|
|
12769
12789
|
scrubHistory?: boolean;
|
|
12770
12790
|
ephemeral?: boolean;
|
|
12771
12791
|
onProgress?: Maybe<(p: ExecutionProgress) => void>;
|
|
12792
|
+
onPreview?: Maybe<(p: ExecutionPreview) => void>;
|
|
12772
12793
|
logProgress?: boolean;
|
|
12773
12794
|
});
|
|
12774
12795
|
/** local disk saving, OPT-IN (architecture.md item 14); null = outputs stay in memory */
|
|
@@ -12781,6 +12802,8 @@ declare class ComfyExecution {
|
|
|
12781
12802
|
snapshot: Maybe<ExecutionSnapshot>;
|
|
12782
12803
|
/** called on every progress-relevant websocket message */
|
|
12783
12804
|
onProgress: Maybe<(p: ExecutionProgress) => void>;
|
|
12805
|
+
/** called on every live preview frame of this run. Null = frames are never decoded for it */
|
|
12806
|
+
onPreview: Maybe<(p: ExecutionPreview) => void>;
|
|
12784
12807
|
/** render a live single-line progress report to the console */
|
|
12785
12808
|
logProgress: boolean;
|
|
12786
12809
|
readonly startedAt: number;
|
|
@@ -12834,6 +12857,13 @@ declare class ComfyExecution {
|
|
|
12834
12857
|
* SENT snapshot (the ephemeral rewrite only touches the snapshot, so the
|
|
12835
12858
|
* live graph may still say SaveImage) — binary frames are then OUTPUTS */
|
|
12836
12859
|
get wsOutputNodeExecuting(): boolean;
|
|
12860
|
+
/** @internal a live preview frame of this run; never an output (the host routes ws saver frames
|
|
12861
|
+
* to onWsImageOutput before they get here) */
|
|
12862
|
+
onPreviewFrame(p: {
|
|
12863
|
+
bytes: Uint8Array;
|
|
12864
|
+
mime: string;
|
|
12865
|
+
metadata: unknown;
|
|
12866
|
+
}): void;
|
|
12837
12867
|
/** one binary ws frame = one output image of the executing SaveImageWebsocket
|
|
12838
12868
|
* node (architecture.md item 14 — the zero-server-disk path) */
|
|
12839
12869
|
onWsImageOutput: (p: {
|
|
@@ -12863,6 +12893,9 @@ declare class ComfyExecution {
|
|
|
12863
12893
|
private _finish;
|
|
12864
12894
|
}
|
|
12865
12895
|
//#endregion
|
|
12896
|
+
//#region src/host/previewMethod.d.ts
|
|
12897
|
+
type PreviewMethod = 'none' | 'auto' | 'latent2rgb' | 'taesd';
|
|
12898
|
+
//#endregion
|
|
12866
12899
|
//#region src/sdk-generator/comfyui-sdk-codegen.d.ts
|
|
12867
12900
|
/**
|
|
12868
12901
|
* convert a host id to the namespace name it gets inside the global `Comfy` namespace
|
|
@@ -16385,20 +16418,33 @@ declare class ToggleVar extends ComfyVar<boolean> {
|
|
|
16385
16418
|
}
|
|
16386
16419
|
/** how many options a choice holds: exactly one (the default), one or none, or any number */
|
|
16387
16420
|
type ChoiceSelect = 'one' | 'zero-or-one' | 'many';
|
|
16421
|
+
/** where a host-bound choice reads its options: one loader input of the host's live schema,
|
|
16422
|
+
* optionally narrowed (`v.model`) */
|
|
16423
|
+
type HostSlotSource = {
|
|
16424
|
+
slot: string;
|
|
16425
|
+
filter?: RegExp;
|
|
16426
|
+
};
|
|
16388
16427
|
declare class ChoiceVar<T extends string> extends ComfyVar<T> {
|
|
16389
|
-
readonly choices: readonly T[];
|
|
16390
16428
|
readonly kind: 'choice';
|
|
16391
16429
|
readonly select: 'one';
|
|
16392
|
-
|
|
16430
|
+
private list;
|
|
16431
|
+
constructor(choices: readonly T[] | HostSlotSource, defaultValue: T, label?: string);
|
|
16432
|
+
get choices(): readonly T[];
|
|
16433
|
+
/** set for `v.model`: the loader input this choice lists */
|
|
16434
|
+
get hostSlot(): HostSlotSource | null;
|
|
16435
|
+
bindHost(host: LorasHost): void;
|
|
16393
16436
|
next(delta?: number): this;
|
|
16394
16437
|
parse(raw: string): boolean;
|
|
16395
16438
|
}
|
|
16396
16439
|
/** one option or none: `null` is "nothing picked", clicking the lit option clears it */
|
|
16397
16440
|
declare class OptionalChoiceVar<T extends string> extends ComfyVar<T | null> {
|
|
16398
|
-
readonly choices: readonly T[];
|
|
16399
16441
|
readonly kind: 'choice';
|
|
16400
16442
|
readonly select: 'zero-or-one';
|
|
16401
|
-
|
|
16443
|
+
private list;
|
|
16444
|
+
constructor(choices: readonly T[] | HostSlotSource, defaultValue: T | null, label?: string);
|
|
16445
|
+
get choices(): readonly T[];
|
|
16446
|
+
get hostSlot(): HostSlotSource | null;
|
|
16447
|
+
bindHost(host: LorasHost): void;
|
|
16402
16448
|
/** pick `c`, or clear it when it is already the one picked */
|
|
16403
16449
|
toggle(c: T): this;
|
|
16404
16450
|
/** the TUI text form: a choice, or an empty line for none */
|
|
@@ -16435,6 +16481,22 @@ declare function choice<const T extends string>(choices: readonly T[], defaultVa
|
|
|
16435
16481
|
}): ChoiceVar<T>;
|
|
16436
16482
|
declare function choice<const T extends string>(choices: readonly T[], defaultValue: T | null, opts: ChoiceOpts<'zero-or-one'>): OptionalChoiceVar<T>;
|
|
16437
16483
|
declare function choice<const T extends string>(choices: readonly T[], defaultValue: readonly T[], opts: ChoiceOpts<'many'>): MultiChoiceVar<T>;
|
|
16484
|
+
type ModelVarOpts<T extends string> = {
|
|
16485
|
+
/** narrows the host's list: `/krea/i` */
|
|
16486
|
+
filter?: RegExp;
|
|
16487
|
+
label?: string;
|
|
16488
|
+
/** a file name, or null for "the workflow decides" (the build then reads null) */
|
|
16489
|
+
default: T | null;
|
|
16490
|
+
};
|
|
16491
|
+
/** a choice over the host's LIVE file list for one loader input (`'UNETLoader.unet_name'`),
|
|
16492
|
+
* resolved at define time and rebound by serve's refresh-schema: a downloaded model is picked
|
|
16493
|
+
* in the draft, never written into the workflow file */
|
|
16494
|
+
declare function model<T extends string>(slot: string, opts: ModelVarOpts<T> & {
|
|
16495
|
+
default: T;
|
|
16496
|
+
}): ChoiceVar<T>;
|
|
16497
|
+
declare function model<T extends string>(slot: string, opts: ModelVarOpts<T> & {
|
|
16498
|
+
default: null;
|
|
16499
|
+
}): OptionalChoiceVar<T>;
|
|
16438
16500
|
type ActiveLora<T extends string> = {
|
|
16439
16501
|
lora_name: T;
|
|
16440
16502
|
strength_model: number;
|
|
@@ -16449,6 +16511,7 @@ type LorasHost = {
|
|
|
16449
16511
|
};
|
|
16450
16512
|
schema: {
|
|
16451
16513
|
getLoras(filter?: RegExp): string[];
|
|
16514
|
+
stringValues(slot: string): string[];
|
|
16452
16515
|
};
|
|
16453
16516
|
};
|
|
16454
16517
|
/**
|
|
@@ -16556,6 +16619,9 @@ type MediaVarOpts = {
|
|
|
16556
16619
|
* not what the api accepts) */
|
|
16557
16620
|
extensions?: readonly string[];
|
|
16558
16621
|
label?: string;
|
|
16622
|
+
/** the text var a file's `<name>.txt` sidecar fills, when a driver sets this var from a file
|
|
16623
|
+
* and leaves that one unset: a voice clip's transcript (`comfy-ts run`) */
|
|
16624
|
+
sidecarText?: TextVar;
|
|
16559
16625
|
};
|
|
16560
16626
|
type ImageVarOpts = MediaVarOpts;
|
|
16561
16627
|
type AudioVarOpts = MediaVarOpts;
|
|
@@ -16615,7 +16681,7 @@ declare class VideoVar extends MediaVar {
|
|
|
16615
16681
|
readonly kind: 'video';
|
|
16616
16682
|
loadInWorkflow<WID extends string>(wf: ComfyWorkflow<WID>): Promise<NodeOf<WID, 'LoadVideo'>>;
|
|
16617
16683
|
}
|
|
16618
|
-
/** the var constructors: v.text / v.prompt / v.int / v.float / v.seed / v.toggle / v.choice / v.loras / v.size / v.image / v.audio / v.video */
|
|
16684
|
+
/** the var constructors: v.text / v.prompt / v.int / v.float / v.seed / v.toggle / v.choice / v.model / v.loras / v.size / v.image / v.audio / v.video */
|
|
16619
16685
|
declare const v: {
|
|
16620
16686
|
text: (defaultValue: string, opts?: TextVarOpts | string) => TextVar;
|
|
16621
16687
|
prompt: (
|
|
@@ -16650,6 +16716,8 @@ declare const v: {
|
|
|
16650
16716
|
label?: string;
|
|
16651
16717
|
image?: ImageVar;
|
|
16652
16718
|
}) => SizeVar;
|
|
16719
|
+
/** host-bound: only inside defineWorkflow({ vars: (v) => … }), typed per slot there */
|
|
16720
|
+
model: typeof model;
|
|
16653
16721
|
image: (defaultValue: string, opts?: MediaVarOpts) => ImageVar;
|
|
16654
16722
|
audio: (defaultValue: string, opts?: MediaVarOpts) => AudioVar;
|
|
16655
16723
|
video: (defaultValue: string, opts?: MediaVarOpts) => VideoVar;
|
|
@@ -16692,10 +16760,26 @@ type LoraNameOf<ID extends string> = 'E_LoraName' extends keyof SdkForHost<ID>['
|
|
|
16692
16760
|
* the `v` handed to a vars LAMBDA: the global factory, host-typed —
|
|
16693
16761
|
* `v.loras(regex)` yields the host's lora-name union (resolved via bindHost)
|
|
16694
16762
|
*/
|
|
16695
|
-
type BoundVars<ID extends string> = Omit<typeof v, 'loras'> & {
|
|
16763
|
+
type BoundVars<ID extends string> = Omit<typeof v, 'loras' | 'model'> & {
|
|
16696
16764
|
loras(options: RegExp, initial?: LorasInput<LoraNameOf<ID>>, label?: string): LorasVar<LoraNameOf<ID>>;
|
|
16697
16765
|
loras<T extends string>(options: readonly T[], initial?: LorasInput<T>, label?: string): LorasVar<T>;
|
|
16766
|
+
/** the host's file list for one loader input: the slot autocompletes, the value is its union */
|
|
16767
|
+
model: ModelFactory<SdkForHost<ID>['Slots']>;
|
|
16698
16768
|
};
|
|
16769
|
+
/** `v.model` typed by a host's slot table S (`Slots`): its own interface, so the host id's
|
|
16770
|
+
* variance stays measurable (inlined into BoundVars, ComfyHost<ID> stopped being a ComfyHost<string>) */
|
|
16771
|
+
interface ModelFactory<S> {
|
|
16772
|
+
<K extends keyof S & string>(slot: K, opts: ModelVarOpts<S[K] & string> & {
|
|
16773
|
+
default: S[K] & string;
|
|
16774
|
+
}): ChoiceVar<S[K] & string>;
|
|
16775
|
+
<K extends keyof S & string>(slot: K, opts: ModelVarOpts<S[K] & string> & {
|
|
16776
|
+
default: null;
|
|
16777
|
+
}): OptionalChoiceVar<S[K] & string>;
|
|
16778
|
+
}
|
|
16779
|
+
/** every `Node.input` slot of the host's generated sdk (any string without one) */
|
|
16780
|
+
type SlotNameOf<ID extends string> = keyof SdkForHost<ID>['Slots'] & string;
|
|
16781
|
+
/** the value union of one slot, strings only (a loader file list) */
|
|
16782
|
+
type SlotValueOf<ID extends string, K extends string> = K extends keyof SdkForHost<ID>['Slots'] ? SdkForHost<ID>['Slots'][K] & string : string;
|
|
16699
16783
|
type DefineWorkflowSpec<ID extends string, V extends VarsSpec> = {
|
|
16700
16784
|
/** short id; also names the workflow instances */
|
|
16701
16785
|
id?: string;
|
|
@@ -16839,6 +16923,12 @@ declare class ComfyHostAuthError extends Error {
|
|
|
16839
16923
|
hostId: string;
|
|
16840
16924
|
constructor(code: 401 | 402 | 429, hostId: string, message: string);
|
|
16841
16925
|
}
|
|
16926
|
+
type LatentPreview = {
|
|
16927
|
+
promptID: Maybe<PromptID>;
|
|
16928
|
+
receivedAt: number_Timestamp;
|
|
16929
|
+
blob: Blob;
|
|
16930
|
+
url: string;
|
|
16931
|
+
};
|
|
16842
16932
|
declare class ComfyHost<ID extends string = string> {
|
|
16843
16933
|
data: ComfyHostData & {
|
|
16844
16934
|
id: ID;
|
|
@@ -16980,6 +17070,10 @@ declare class ComfyHost<ID extends string = string> {
|
|
|
16980
17070
|
deleteHistory: (promptId: string) => Promise<void>;
|
|
16981
17071
|
/** wipe the server's WHOLE prompt history (every user of that server) */
|
|
16982
17072
|
clearHistory: () => Promise<void>;
|
|
17073
|
+
/** the `--preview-method` this host was launched with, read from `GET /system_stats`.
|
|
17074
|
+
* `'none'` (ComfyUI's default) means no live preview frame will ever arrive; null = the host
|
|
17075
|
+
* does not publish its launch flags (a cloud host), so only a run can tell */
|
|
17076
|
+
fetchPreviewMethod: () => Promise<PreviewMethod | null>;
|
|
16983
17077
|
/** the server's recent console buffer (entries are write CHUNKS, not lines) */
|
|
16984
17078
|
fetchRawLogs: () => Promise<{
|
|
16985
17079
|
entries: LogEntry[];
|
|
@@ -17008,13 +17102,12 @@ declare class ComfyHost<ID extends string = string> {
|
|
|
17008
17102
|
private activePromptID;
|
|
17009
17103
|
/** method to either execute or buffer the incoming message */
|
|
17010
17104
|
routeOrBuffer(prompt_id: PromptID, msg: PromptRelated_WsMsg): void;
|
|
17011
|
-
/** the
|
|
17012
|
-
|
|
17013
|
-
|
|
17014
|
-
|
|
17015
|
-
|
|
17016
|
-
|
|
17017
|
-
}>;
|
|
17105
|
+
/** the last raw preview frame; `latentPreview` decodes it only when read */
|
|
17106
|
+
private _latentFrame;
|
|
17107
|
+
private _latentPreview;
|
|
17108
|
+
/** the latent image beeing generated, in case you want to display it. Built on read: a
|
|
17109
|
+
* session that never reads it never decodes a frame nor holds an object url */
|
|
17110
|
+
get latentPreview(): Maybe<LatentPreview>;
|
|
17018
17111
|
/** byte-level latent-preview hook (e.g. TUI live preview panel) */
|
|
17019
17112
|
onLatentPreview: Maybe<(p: {
|
|
17020
17113
|
bytes: Uint8Array;
|
|
@@ -17049,6 +17142,10 @@ declare class ComfyHost<ID extends string = string> {
|
|
|
17049
17142
|
* sockets keep streaming (a half-open socket receives nothing, so this
|
|
17050
17143
|
* never revives one) */
|
|
17051
17144
|
lastWsMessageAt: number | null;
|
|
17145
|
+
/** a type 1 or 4 frame. Parsed only when someone wants it, in this order (architecture.md,
|
|
17146
|
+
* Live previews): the ws saver's output, the pre-registration buffer, the run's onPreview,
|
|
17147
|
+
* the host hook. Nobody listening = the frame is kept by reference and never copied */
|
|
17148
|
+
private onPreviewFrame;
|
|
17052
17149
|
onMessage(e: WsMessageEvent): void;
|
|
17053
17150
|
}
|
|
17054
17151
|
//#endregion
|
|
@@ -17246,6 +17343,10 @@ type RunSettings = {
|
|
|
17246
17343
|
log?: boolean;
|
|
17247
17344
|
/** called on every progress-relevant websocket message */
|
|
17248
17345
|
onProgress?: (p: ExecutionProgress) => void;
|
|
17346
|
+
/** called on every live preview frame of this run (the image a sampler is forming). Opt in:
|
|
17347
|
+
* without it no frame is decoded for the run. ComfyUI sends frames only when launched with
|
|
17348
|
+
* `--preview-method`, see `host.fetchPreviewMethod()` */
|
|
17349
|
+
onPreview?: (p: ExecutionPreview) => void;
|
|
17249
17350
|
};
|
|
17250
17351
|
/** exactly what was sent to the host for one execution, frozen at send time */
|
|
17251
17352
|
type ExecutionSnapshot = {
|
|
@@ -18043,5 +18144,5 @@ type HostToPanel = {
|
|
|
18043
18144
|
comfyTs: 'get-state';
|
|
18044
18145
|
};
|
|
18045
18146
|
//#endregion
|
|
18046
|
-
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 ExecutionProgress, type ExecutionSnapshot, Flavor, FloatVar, HTMLContent, 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, 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 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, 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 };
|
|
18147
|
+
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 };
|
|
18047
18148
|
//# 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.17.0";
|
|
105
105
|
//#endregion
|
|
106
106
|
//#region src/litegraph/LiteGraphLinkID.ts
|
|
107
107
|
const asLiteGraphLinkID = (id) => id;
|
|
@@ -651,21 +651,41 @@ const normalizeGroup = (g) => {
|
|
|
651
651
|
};
|
|
652
652
|
};
|
|
653
653
|
//#endregion
|
|
654
|
-
//#region src/
|
|
655
|
-
function
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
654
|
+
//#region src/host/previewMethod.ts
|
|
655
|
+
function isPreviewMethod(x) {
|
|
656
|
+
return x === "none" || x === "auto" || x === "latent2rgb" || x === "taesd";
|
|
657
|
+
}
|
|
658
|
+
/** the preview method a host was launched with, from its /system_stats payload. `'none'` when
|
|
659
|
+
* the flag is absent (ComfyUI's default), null when the payload carries no argv to read (a cloud
|
|
660
|
+
* host) or the flag holds a value this parser does not know */
|
|
661
|
+
function previewMethodFromSystemStats(stats) {
|
|
662
|
+
if (stats == null || typeof stats !== "object" || !("system" in stats)) return null;
|
|
663
|
+
const system = stats.system;
|
|
664
|
+
if (system == null || typeof system !== "object" || !("argv" in system)) return null;
|
|
665
|
+
const argv = system.argv;
|
|
666
|
+
if (!Array.isArray(argv)) return null;
|
|
667
|
+
for (let i = 0; i < argv.length; i++) {
|
|
668
|
+
const arg = argv[i];
|
|
669
|
+
if (typeof arg !== "string") continue;
|
|
670
|
+
const value = arg === "--preview-method" ? argv[i + 1] : arg.startsWith("--preview-method=") ? arg.slice(17) : void 0;
|
|
671
|
+
if (value === void 0) continue;
|
|
672
|
+
return isPreviewMethod(value) ? value : null;
|
|
666
673
|
}
|
|
674
|
+
return "none";
|
|
675
|
+
}
|
|
676
|
+
/** the frame's event type, read in place: deciding whether anyone wants a frame costs no copy */
|
|
677
|
+
function binaryFrameType(data) {
|
|
678
|
+
if (data.byteLength < 4) return -1;
|
|
679
|
+
return new DataView(data).getUint32(0);
|
|
680
|
+
}
|
|
681
|
+
function isPreviewFrameType(eventType) {
|
|
682
|
+
return eventType === 1 || eventType === 4;
|
|
683
|
+
}
|
|
684
|
+
function parseBinaryWsFrame(data) {
|
|
685
|
+
const eventType = binaryFrameType(data);
|
|
686
|
+
if (isPreviewFrameType(eventType)) return parsePreviewFrame(data);
|
|
667
687
|
if (eventType === 3) {
|
|
668
|
-
const nodeIdLen =
|
|
688
|
+
const nodeIdLen = new DataView(data).getUint32(4);
|
|
669
689
|
const decoder = new TextDecoder();
|
|
670
690
|
return {
|
|
671
691
|
kind: "text",
|
|
@@ -673,25 +693,41 @@ function parseBinaryWsFrame(data) {
|
|
|
673
693
|
text: decoder.decode(data.slice(8 + nodeIdLen))
|
|
674
694
|
};
|
|
675
695
|
}
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
696
|
+
return {
|
|
697
|
+
kind: "unknown",
|
|
698
|
+
eventType
|
|
699
|
+
};
|
|
700
|
+
}
|
|
701
|
+
/** a type 1 or type 4 frame; the caller checked the type with `isPreviewFrameType` */
|
|
702
|
+
function parsePreviewFrame(data) {
|
|
703
|
+
const view = new DataView(data);
|
|
704
|
+
if (view.getUint32(0) === 1) {
|
|
705
|
+
const imageType = view.getUint32(4);
|
|
683
706
|
return {
|
|
684
707
|
kind: "preview",
|
|
685
|
-
bytes,
|
|
686
|
-
mime:
|
|
687
|
-
metadata
|
|
708
|
+
bytes: new Uint8Array(data.slice(8)),
|
|
709
|
+
mime: imageType === 2 ? "image/png" : "image/jpeg",
|
|
710
|
+
metadata: null
|
|
688
711
|
};
|
|
689
712
|
}
|
|
713
|
+
const metadataLen = view.getUint32(4);
|
|
714
|
+
let metadata = null;
|
|
715
|
+
try {
|
|
716
|
+
metadata = JSON.parse(new TextDecoder().decode(data.slice(8, 8 + metadataLen)));
|
|
717
|
+
} catch {}
|
|
718
|
+
const bytes = new Uint8Array(data.slice(8 + metadataLen));
|
|
690
719
|
return {
|
|
691
|
-
kind: "
|
|
692
|
-
|
|
720
|
+
kind: "preview",
|
|
721
|
+
bytes,
|
|
722
|
+
mime: bytes[0] === 137 && bytes[1] === 80 ? "image/png" : "image/jpeg",
|
|
723
|
+
metadata
|
|
693
724
|
};
|
|
694
725
|
}
|
|
726
|
+
/** the node a type 4 frame names (`node_id` in its metadata), null when absent or malformed */
|
|
727
|
+
function previewMetadataNodeId(metadata) {
|
|
728
|
+
if (metadata == null || typeof metadata !== "object" || !("node_id" in metadata)) return null;
|
|
729
|
+
return typeof metadata.node_id === "string" && metadata.node_id !== "" ? metadata.node_id : null;
|
|
730
|
+
}
|
|
695
731
|
//#endregion
|
|
696
732
|
//#region src/sdk-generator/Primitives.ts
|
|
697
733
|
const ComfyPrimitiveMapping = {
|
|
@@ -2341,6 +2377,7 @@ var ComfyExecution = class {
|
|
|
2341
2377
|
this.ephemeral = false;
|
|
2342
2378
|
this.snapshot = null;
|
|
2343
2379
|
this.onProgress = null;
|
|
2380
|
+
this.onPreview = null;
|
|
2344
2381
|
this.logProgress = false;
|
|
2345
2382
|
this.startedAt = Date.now();
|
|
2346
2383
|
this._lastLoggedLine = "";
|
|
@@ -2354,6 +2391,7 @@ var ComfyExecution = class {
|
|
|
2354
2391
|
bytes: msg.bytes,
|
|
2355
2392
|
mime: msg.mime
|
|
2356
2393
|
});
|
|
2394
|
+
else this.onPreviewFrame(msg);
|
|
2357
2395
|
return;
|
|
2358
2396
|
}
|
|
2359
2397
|
if (msg.type === "execution_start") return;
|
|
@@ -2600,6 +2638,7 @@ var ComfyExecution = class {
|
|
|
2600
2638
|
this.scrubHistory = init.scrubHistory ?? false;
|
|
2601
2639
|
this.ephemeral = init.ephemeral ?? false;
|
|
2602
2640
|
this.onProgress = init.onProgress ?? null;
|
|
2641
|
+
this.onPreview = init.onPreview ?? null;
|
|
2603
2642
|
this.logProgress = init.logProgress ?? false;
|
|
2604
2643
|
this.host.executions.set(data.id, this);
|
|
2605
2644
|
this.onCreate();
|
|
@@ -2680,6 +2719,28 @@ var ComfyExecution = class {
|
|
|
2680
2719
|
if (uid == null) return false;
|
|
2681
2720
|
return (this.snapshot?.apiJson ?? this.workflow.apiJson)[uid]?.class_type === "SaveImageWebsocket";
|
|
2682
2721
|
}
|
|
2722
|
+
/** @internal a live preview frame of this run; never an output (the host routes ws saver frames
|
|
2723
|
+
* to onWsImageOutput before they get here) */
|
|
2724
|
+
onPreviewFrame(p) {
|
|
2725
|
+
const listener = this.onPreview;
|
|
2726
|
+
if (listener == null) return;
|
|
2727
|
+
const current = this.workflow.currentExecutingNode;
|
|
2728
|
+
const nodeId = previewMetadataNodeId(p.metadata) ?? current?.uid ?? null;
|
|
2729
|
+
const apiJson = this.snapshot?.apiJson ?? this.workflow.apiJson;
|
|
2730
|
+
const counter = current != null && current.uid === nodeId ? current.progress : null;
|
|
2731
|
+
listener({
|
|
2732
|
+
promptId: this.data.id,
|
|
2733
|
+
bytes: p.bytes,
|
|
2734
|
+
mime: p.mime,
|
|
2735
|
+
nodeId,
|
|
2736
|
+
nodeName: nodeId != null ? apiJson[nodeId]?.class_type ?? null : null,
|
|
2737
|
+
step: counter != null ? {
|
|
2738
|
+
value: counter.value,
|
|
2739
|
+
max: counter.max
|
|
2740
|
+
} : null,
|
|
2741
|
+
metadata: p.metadata
|
|
2742
|
+
});
|
|
2743
|
+
}
|
|
2683
2744
|
/** @internal a live-text frame for one node */
|
|
2684
2745
|
onProgressText(p) {
|
|
2685
2746
|
this.progressTexts.set(p.nodeId, p.text);
|
|
@@ -3019,6 +3080,7 @@ var ComfyWorkflow = class {
|
|
|
3019
3080
|
ephemeral: p.ephemeral ?? false,
|
|
3020
3081
|
scrubHistory: p.scrubHistory ?? p.ephemeral ?? false,
|
|
3021
3082
|
onProgress: p.onProgress,
|
|
3083
|
+
onPreview: p.onPreview,
|
|
3022
3084
|
logProgress: p.log ?? false
|
|
3023
3085
|
});
|
|
3024
3086
|
};
|
|
@@ -5013,12 +5075,46 @@ var ToggleVar = class extends ComfyVar {
|
|
|
5013
5075
|
return this.value ? "ON" : "OFF";
|
|
5014
5076
|
}
|
|
5015
5077
|
};
|
|
5078
|
+
/** a fixed list, or the host's list for one slot once bindHost ran */
|
|
5079
|
+
var ChoiceList = class {
|
|
5080
|
+
constructor(source) {
|
|
5081
|
+
this.source = source;
|
|
5082
|
+
this.resolved = null;
|
|
5083
|
+
}
|
|
5084
|
+
get slot() {
|
|
5085
|
+
return isChoiceList(this.source) ? null : this.source;
|
|
5086
|
+
}
|
|
5087
|
+
get choices() {
|
|
5088
|
+
if (isChoiceList(this.source)) return this.source;
|
|
5089
|
+
if (this.resolved == null) throw new Error(`v.model('${this.source.slot}') is host-bound — it only works inside defineWorkflow({ vars }) (pass a name list to v.choice otherwise)`);
|
|
5090
|
+
return this.resolved;
|
|
5091
|
+
}
|
|
5092
|
+
/** cast: whitelist family 1 (agent/coding.md) — stringValues() returns the runtime values of
|
|
5093
|
+
* the SAME object_info enum the generated slot union comes from */
|
|
5094
|
+
bind(host) {
|
|
5095
|
+
const src = this.slot;
|
|
5096
|
+
if (src == null) return;
|
|
5097
|
+
const all = host.schema.stringValues(src.slot);
|
|
5098
|
+
const filter = src.filter == null ? null : statelessRegex(src.filter);
|
|
5099
|
+
this.resolved = filter == null ? all : all.filter((n) => filter.test(n));
|
|
5100
|
+
}
|
|
5101
|
+
};
|
|
5016
5102
|
var ChoiceVar = class extends ComfyVar {
|
|
5017
5103
|
constructor(choices, defaultValue, label) {
|
|
5018
5104
|
super(defaultValue, label);
|
|
5019
|
-
this.choices = choices;
|
|
5020
5105
|
this.kind = "choice";
|
|
5021
5106
|
this.select = "one";
|
|
5107
|
+
this.list = new ChoiceList(choices);
|
|
5108
|
+
}
|
|
5109
|
+
get choices() {
|
|
5110
|
+
return this.list.choices;
|
|
5111
|
+
}
|
|
5112
|
+
/** set for `v.model`: the loader input this choice lists */
|
|
5113
|
+
get hostSlot() {
|
|
5114
|
+
return this.list.slot;
|
|
5115
|
+
}
|
|
5116
|
+
bindHost(host) {
|
|
5117
|
+
this.list.bind(host);
|
|
5022
5118
|
}
|
|
5023
5119
|
next(delta = 1) {
|
|
5024
5120
|
const nextIx = (this.choices.indexOf(this.value) + delta + this.choices.length) % this.choices.length;
|
|
@@ -5035,9 +5131,18 @@ var ChoiceVar = class extends ComfyVar {
|
|
|
5035
5131
|
var OptionalChoiceVar = class extends ComfyVar {
|
|
5036
5132
|
constructor(choices, defaultValue, label) {
|
|
5037
5133
|
super(defaultValue, label);
|
|
5038
|
-
this.choices = choices;
|
|
5039
5134
|
this.kind = "choice";
|
|
5040
5135
|
this.select = "zero-or-one";
|
|
5136
|
+
this.list = new ChoiceList(choices);
|
|
5137
|
+
}
|
|
5138
|
+
get choices() {
|
|
5139
|
+
return this.list.choices;
|
|
5140
|
+
}
|
|
5141
|
+
get hostSlot() {
|
|
5142
|
+
return this.list.slot;
|
|
5143
|
+
}
|
|
5144
|
+
bindHost(host) {
|
|
5145
|
+
this.list.bind(host);
|
|
5041
5146
|
}
|
|
5042
5147
|
/** pick `c`, or clear it when it is already the one picked */
|
|
5043
5148
|
toggle(c) {
|
|
@@ -5115,6 +5220,14 @@ function choice(choices, defaultValue, opts) {
|
|
|
5115
5220
|
if (defaultValue == null) throw new Error("a 'one' choice needs a default: use { select: 'zero-or-one' } for none");
|
|
5116
5221
|
return new ChoiceVar(choices, defaultValue, o.label);
|
|
5117
5222
|
}
|
|
5223
|
+
function model(slot, opts) {
|
|
5224
|
+
const source = {
|
|
5225
|
+
slot,
|
|
5226
|
+
filter: opts.filter
|
|
5227
|
+
};
|
|
5228
|
+
if (opts.default == null) return new OptionalChoiceVar(source, null, opts.label);
|
|
5229
|
+
return new ChoiceVar(source, opts.default, opts.label);
|
|
5230
|
+
}
|
|
5118
5231
|
/** normalize a loras record into what a standard LoraLoader chain consumes */
|
|
5119
5232
|
function activeLoras(loras) {
|
|
5120
5233
|
const out = [];
|
|
@@ -5529,7 +5642,7 @@ var VideoVar = class extends MediaVar {
|
|
|
5529
5642
|
return await this.loadVia(wf);
|
|
5530
5643
|
}
|
|
5531
5644
|
};
|
|
5532
|
-
/** the var constructors: v.text / v.prompt / v.int / v.float / v.seed / v.toggle / v.choice / v.loras / v.size / v.image / v.audio / v.video */
|
|
5645
|
+
/** the var constructors: v.text / v.prompt / v.int / v.float / v.seed / v.toggle / v.choice / v.model / v.loras / v.size / v.image / v.audio / v.video */
|
|
5533
5646
|
const v = {
|
|
5534
5647
|
text: (defaultValue, opts = {}) => new TextVar(defaultValue, typeof opts === "string" ? { label: opts } : opts),
|
|
5535
5648
|
prompt: (defaultValue, opts = {}) => new PromptVar(defaultValue, opts),
|
|
@@ -5544,6 +5657,8 @@ const v = {
|
|
|
5544
5657
|
choice,
|
|
5545
5658
|
loras: (options, initial = {}, label) => new LorasVar(options, initial, label),
|
|
5546
5659
|
size: (defaultValue, opts = {}) => new SizeVar(defaultValue, opts.presets ?? sizePresetsFor(defaultValue), opts.label, opts.image, opts.starred),
|
|
5660
|
+
/** host-bound: only inside defineWorkflow({ vars: (v) => … }), typed per slot there */
|
|
5661
|
+
model,
|
|
5547
5662
|
image: (defaultValue, opts = {}) => new ImageVar(defaultValue, opts),
|
|
5548
5663
|
audio: (defaultValue, opts = {}) => new AudioVar(defaultValue, opts),
|
|
5549
5664
|
video: (defaultValue, opts = {}) => new VideoVar(defaultValue, opts)
|
|
@@ -5637,7 +5752,8 @@ var DefinedWorkflow = class {
|
|
|
5637
5752
|
scrubHistory: settings.scrubHistory,
|
|
5638
5753
|
idMode: settings.idMode,
|
|
5639
5754
|
log: settings.log,
|
|
5640
|
-
onProgress: settings.onProgress
|
|
5755
|
+
onProgress: settings.onProgress,
|
|
5756
|
+
onPreview: settings.onPreview
|
|
5641
5757
|
});
|
|
5642
5758
|
this.lastExecution = execution;
|
|
5643
5759
|
return execution;
|
|
@@ -5942,6 +6058,11 @@ var ComfyHost = class {
|
|
|
5942
6058
|
this.clearHistory = () => {
|
|
5943
6059
|
return this.postJSON_("/history", { clear: true });
|
|
5944
6060
|
};
|
|
6061
|
+
this.fetchPreviewMethod = async () => {
|
|
6062
|
+
const res = await this.fetch("/system_stats", {});
|
|
6063
|
+
if (!res.ok) throw new Error(`GET /system_stats failed: ${res.status}`);
|
|
6064
|
+
return previewMethodFromSystemStats(await res.json());
|
|
6065
|
+
};
|
|
5945
6066
|
this.fetchRawLogs = async () => {
|
|
5946
6067
|
const res = await this.fetch("/internal/logs/raw", {}, { apiPrefix: false });
|
|
5947
6068
|
if (!res.ok) throw new Error(`GET /internal/logs/raw failed: ${res.status}`);
|
|
@@ -6018,7 +6139,8 @@ var ComfyHost = class {
|
|
|
6018
6139
|
this.executions = /* @__PURE__ */ new Map();
|
|
6019
6140
|
this._pendingMsgs = /* @__PURE__ */ new Map();
|
|
6020
6141
|
this.activePromptID = null;
|
|
6021
|
-
this.
|
|
6142
|
+
this._latentFrame = null;
|
|
6143
|
+
this._latentPreview = null;
|
|
6022
6144
|
this.onLatentPreview = null;
|
|
6023
6145
|
this.onProgressText = null;
|
|
6024
6146
|
this.onStatus = null;
|
|
@@ -6195,42 +6317,60 @@ var ComfyHost = class {
|
|
|
6195
6317
|
}
|
|
6196
6318
|
prompt.onPromptRelatedMessage(msg);
|
|
6197
6319
|
}
|
|
6320
|
+
/** the latent image beeing generated, in case you want to display it. Built on read: a
|
|
6321
|
+
* session that never reads it never decodes a frame nor holds an object url */
|
|
6322
|
+
get latentPreview() {
|
|
6323
|
+
if (this._latentPreview != null || this._latentFrame == null) return this._latentPreview;
|
|
6324
|
+
const frame = parsePreviewFrame(this._latentFrame.data);
|
|
6325
|
+
const blob = new Blob([frame.bytes], { type: frame.mime });
|
|
6326
|
+
this._latentPreview = {
|
|
6327
|
+
blob,
|
|
6328
|
+
url: URL.createObjectURL(blob),
|
|
6329
|
+
receivedAt: this._latentFrame.receivedAt,
|
|
6330
|
+
promptID: this._latentFrame.promptID
|
|
6331
|
+
};
|
|
6332
|
+
return this._latentPreview;
|
|
6333
|
+
}
|
|
6334
|
+
/** a type 1 or 4 frame. Parsed only when someone wants it, in this order (architecture.md,
|
|
6335
|
+
* Live previews): the ws saver's output, the pre-registration buffer, the run's onPreview,
|
|
6336
|
+
* the host hook. Nobody listening = the frame is kept by reference and never copied */
|
|
6337
|
+
onPreviewFrame(data) {
|
|
6338
|
+
let parsed = null;
|
|
6339
|
+
const frame = () => parsed ??= parsePreviewFrame(data);
|
|
6340
|
+
const promptID = this.activePromptID;
|
|
6341
|
+
const activeExec = promptID != null ? this.executions.get(promptID) : null;
|
|
6342
|
+
if (activeExec?.wsOutputNodeExecuting) return activeExec.onWsImageOutput({
|
|
6343
|
+
bytes: frame().bytes,
|
|
6344
|
+
mime: frame().mime
|
|
6345
|
+
});
|
|
6346
|
+
const pending = promptID != null ? this._pendingMsgs.get(promptID) : void 0;
|
|
6347
|
+
if (pending != null) pending.push({
|
|
6348
|
+
type: "binary_preview_frame",
|
|
6349
|
+
bytes: frame().bytes,
|
|
6350
|
+
mime: frame().mime,
|
|
6351
|
+
metadata: frame().metadata
|
|
6352
|
+
});
|
|
6353
|
+
if (this._latentPreview != null) URL.revokeObjectURL(this._latentPreview.url);
|
|
6354
|
+
this._latentPreview = null;
|
|
6355
|
+
this._latentFrame = {
|
|
6356
|
+
data,
|
|
6357
|
+
promptID,
|
|
6358
|
+
receivedAt: Date.now()
|
|
6359
|
+
};
|
|
6360
|
+
if (activeExec?.onPreview != null) activeExec.onPreviewFrame(frame());
|
|
6361
|
+
if (this.onLatentPreview != null) this.onLatentPreview({
|
|
6362
|
+
bytes: frame().bytes,
|
|
6363
|
+
mime: frame().mime,
|
|
6364
|
+
promptID
|
|
6365
|
+
});
|
|
6366
|
+
}
|
|
6198
6367
|
onMessage(e) {
|
|
6199
6368
|
this.lastWsMessageAt = Date.now();
|
|
6200
6369
|
if (this.data.onWsMessageAny) this.data.onWsMessageAny(e);
|
|
6201
6370
|
if (e.data instanceof ArrayBuffer) {
|
|
6371
|
+
if (isPreviewFrameType(binaryFrameType(e.data))) return this.onPreviewFrame(e.data);
|
|
6202
6372
|
const frame = parseBinaryWsFrame(e.data);
|
|
6203
|
-
if (frame.kind === "
|
|
6204
|
-
const activeExec = this.activePromptID != null ? this.executions.get(this.activePromptID) : null;
|
|
6205
|
-
if (activeExec?.wsOutputNodeExecuting) {
|
|
6206
|
-
activeExec.onWsImageOutput({
|
|
6207
|
-
bytes: frame.bytes,
|
|
6208
|
-
mime: frame.mime
|
|
6209
|
-
});
|
|
6210
|
-
return;
|
|
6211
|
-
}
|
|
6212
|
-
if (this.activePromptID != null) {
|
|
6213
|
-
const pending = this._pendingMsgs.get(this.activePromptID);
|
|
6214
|
-
if (pending != null) pending.push({
|
|
6215
|
-
type: "binary_preview_frame",
|
|
6216
|
-
bytes: frame.bytes,
|
|
6217
|
-
mime: frame.mime
|
|
6218
|
-
});
|
|
6219
|
-
}
|
|
6220
|
-
if (this.latentPreview != null) URL.revokeObjectURL(this.latentPreview.url);
|
|
6221
|
-
const imageBlob = new Blob([frame.bytes], { type: frame.mime });
|
|
6222
|
-
this.latentPreview = {
|
|
6223
|
-
blob: imageBlob,
|
|
6224
|
-
url: URL.createObjectURL(imageBlob),
|
|
6225
|
-
receivedAt: Date.now(),
|
|
6226
|
-
promptID: this.activePromptID
|
|
6227
|
-
};
|
|
6228
|
-
this.onLatentPreview?.({
|
|
6229
|
-
bytes: frame.bytes,
|
|
6230
|
-
mime: frame.mime,
|
|
6231
|
-
promptID: this.activePromptID
|
|
6232
|
-
});
|
|
6233
|
-
} else if (frame.kind === "unknown" && !this._unknownBinaryFrameTypes.has(frame.eventType)) {
|
|
6373
|
+
if (frame.kind === "unknown" && !this._unknownBinaryFrameTypes.has(frame.eventType)) {
|
|
6234
6374
|
this._unknownBinaryFrameTypes.add(frame.eventType);
|
|
6235
6375
|
console.error(`🔴 unknown binary ws frame type ${frame.eventType} from host ${this.data.id} — ignored`);
|
|
6236
6376
|
}
|