Release V3.8 source, illustrated manual and Spectrum workflow
This commit is contained in:
@@ -0,0 +1,204 @@
|
||||
// Shared native-Bypass control for Easy workflow loader nodes.
|
||||
|
||||
// ComfyUI Frontend 1.49.6 defines LGraphEventMode.ALWAYS=0 and BYPASS=4.
|
||||
// Prefer exported LiteGraph constants when available and keep the audited
|
||||
// numeric values only as compatibility fallbacks.
|
||||
const NODE_MODE_ALWAYS =
|
||||
typeof LiteGraph !== "undefined" && Number.isInteger(LiteGraph.ALWAYS)
|
||||
? LiteGraph.ALWAYS
|
||||
: 0;
|
||||
const NODE_MODE_BYPASS =
|
||||
typeof LiteGraph !== "undefined" && Number.isInteger(LiteGraph.BYPASS)
|
||||
? LiteGraph.BYPASS
|
||||
: 4;
|
||||
|
||||
function isConfiguredNode(node, nodeClass) {
|
||||
return node?.comfyClass === nodeClass || node?.type === nodeClass;
|
||||
}
|
||||
|
||||
export function findEasyBypassWidget(node) {
|
||||
const name = node.__h3EasyBypassToggle?.widgetName;
|
||||
return name ? node.widgets?.find((widget) => widget.name === name) : undefined;
|
||||
}
|
||||
|
||||
function syncWidgetFromMode(node) {
|
||||
const widget = findEasyBypassWidget(node);
|
||||
if (!widget) return;
|
||||
widget.value = node.mode === NODE_MODE_ALWAYS;
|
||||
}
|
||||
|
||||
function installModeSourceOfTruth(node) {
|
||||
if (node.__h3EasyBypassModeObserved) return true;
|
||||
const descriptor = Object.getOwnPropertyDescriptor(node, "mode");
|
||||
if (descriptor && descriptor.configurable === false) return false;
|
||||
|
||||
let currentMode = Number(node.mode ?? NODE_MODE_ALWAYS);
|
||||
Object.defineProperty(node, "mode", {
|
||||
configurable: true,
|
||||
enumerable: descriptor?.enumerable ?? true,
|
||||
get() {
|
||||
return descriptor?.get ? descriptor.get.call(this) : currentMode;
|
||||
},
|
||||
set(value) {
|
||||
if (descriptor?.set) {
|
||||
descriptor.set.call(this, value);
|
||||
} else {
|
||||
currentMode = Number(value);
|
||||
}
|
||||
syncWidgetFromMode(this);
|
||||
},
|
||||
});
|
||||
node.__h3EasyBypassModeObserved = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
function installWidgetSerializationGuard(node, widget) {
|
||||
if (node.__h3EasyBypassSerializationGuard) return;
|
||||
|
||||
const originalSerialize = node.serialize;
|
||||
if (typeof originalSerialize === "function") {
|
||||
node.serialize = function (...args) {
|
||||
const index = this.widgets?.indexOf(widget) ?? -1;
|
||||
if (index >= 0) this.widgets.splice(index, 1);
|
||||
try {
|
||||
return originalSerialize.apply(this, args);
|
||||
} finally {
|
||||
if (index >= 0) this.widgets.splice(index, 0, widget);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const originalConfigure = node.configure;
|
||||
if (typeof originalConfigure === "function") {
|
||||
node.configure = function (...args) {
|
||||
const index = this.widgets?.indexOf(widget) ?? -1;
|
||||
if (index >= 0) this.widgets.splice(index, 1);
|
||||
try {
|
||||
return originalConfigure.apply(this, args);
|
||||
} finally {
|
||||
if (index >= 0) this.widgets.splice(index, 0, widget);
|
||||
syncWidgetFromMode(this);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
node.__h3EasyBypassSerializationGuard = true;
|
||||
}
|
||||
|
||||
function installBypassToggleForeground(node) {
|
||||
if (node.__h3EasyBypassForegroundInstalled) return;
|
||||
const originalDrawWidgets = node.drawWidgets;
|
||||
if (typeof originalDrawWidgets !== "function") return;
|
||||
|
||||
node.drawWidgets = function (ctx, options = {}) {
|
||||
const result = originalDrawWidgets.call(this, ctx, options);
|
||||
if (this.mode !== NODE_MODE_BYPASS) return result;
|
||||
|
||||
const widget = findEasyBypassWidget(this);
|
||||
const widgets = this.widgets;
|
||||
if (!widget || widget.hidden || !Array.isArray(widgets)) return result;
|
||||
if (!widgets.includes(widget)) return result;
|
||||
|
||||
// ComfyUI draws every widget at the node's Bypass alpha. Redraw only
|
||||
// the Enable row afterwards at full opacity so it remains readable and
|
||||
// uses the unchanged native widget hit area/click handling.
|
||||
this.widgets = [widget];
|
||||
try {
|
||||
originalDrawWidgets.call(this, ctx, {
|
||||
...(options ?? {}),
|
||||
editorAlpha: 1,
|
||||
});
|
||||
} finally {
|
||||
this.widgets = widgets;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
node.__h3EasyBypassForegroundInstalled = true;
|
||||
}
|
||||
|
||||
function setModeFromToggle(node, enabled) {
|
||||
node.mode = enabled ? NODE_MODE_ALWAYS : NODE_MODE_BYPASS;
|
||||
syncWidgetFromMode(node);
|
||||
node.setDirtyCanvas?.(true, true);
|
||||
}
|
||||
|
||||
export function configureEasyBypassToggleNode(
|
||||
node,
|
||||
{ nodeClass, widgetName, tooltip },
|
||||
) {
|
||||
if (!isConfiguredNode(node, nodeClass)) return;
|
||||
node.__h3EasyBypassToggle = { nodeClass, widgetName };
|
||||
|
||||
let widget = findEasyBypassWidget(node);
|
||||
if (!widget) {
|
||||
widget = node.addWidget(
|
||||
"toggle",
|
||||
widgetName,
|
||||
node.mode === NODE_MODE_ALWAYS,
|
||||
(value) => setModeFromToggle(node, Boolean(value)),
|
||||
{
|
||||
on: "ON",
|
||||
off: "OFF",
|
||||
serialize: false,
|
||||
},
|
||||
);
|
||||
widget.serialize = false;
|
||||
widget.options ||= {};
|
||||
widget.options.serialize = false;
|
||||
widget.tooltip = tooltip;
|
||||
const currentIndex = node.widgets?.indexOf(widget) ?? -1;
|
||||
if (currentIndex > 0) {
|
||||
node.widgets.splice(currentIndex, 1);
|
||||
node.widgets.unshift(widget);
|
||||
}
|
||||
installWidgetSerializationGuard(node, widget);
|
||||
}
|
||||
|
||||
if (!installModeSourceOfTruth(node)) {
|
||||
console.warn(
|
||||
`${nodeClass} could not observe node.mode; external Bypass changes may require a workflow reload.`,
|
||||
);
|
||||
}
|
||||
installBypassToggleForeground(node);
|
||||
syncWidgetFromMode(node);
|
||||
node.setDirtyCanvas?.(true, true);
|
||||
}
|
||||
|
||||
export function configureExistingEasyBypassWidgetNode(
|
||||
node,
|
||||
{ nodeClass, widgetNames },
|
||||
) {
|
||||
if (!isConfiguredNode(node, nodeClass)) return;
|
||||
const names = Array.isArray(widgetNames) ? widgetNames : [widgetNames];
|
||||
const widget = node.widgets?.find((item) => names.includes(item.name));
|
||||
if (!widget) return;
|
||||
|
||||
node.__h3EasyBypassToggle = {
|
||||
nodeClass,
|
||||
widgetName: widget.name,
|
||||
};
|
||||
|
||||
if (!widget.__h3EasyBypassCallbackObserved) {
|
||||
const originalCallback = widget.callback;
|
||||
widget.callback = function (value, ...args) {
|
||||
const result = originalCallback?.call(this, value, ...args);
|
||||
setModeFromToggle(node, Boolean(value));
|
||||
return result;
|
||||
};
|
||||
widget.__h3EasyBypassCallbackObserved = true;
|
||||
}
|
||||
|
||||
if (!installModeSourceOfTruth(node)) {
|
||||
console.warn(
|
||||
`${nodeClass} could not observe node.mode; external Bypass changes may require a workflow reload.`,
|
||||
);
|
||||
}
|
||||
installBypassToggleForeground(node);
|
||||
|
||||
if (node.mode === NODE_MODE_BYPASS) {
|
||||
syncWidgetFromMode(node);
|
||||
} else {
|
||||
setModeFromToggle(node, Boolean(widget.value));
|
||||
}
|
||||
node.setDirtyCanvas?.(true, true);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
import { app } from "../../scripts/app.js";
|
||||
import { configureEasyBypassToggleNode } from "./easy_bypass_toggle.js";
|
||||
|
||||
const EASY_LOAD_AUDIO_CLASS = "H3EasyLoadAudio";
|
||||
|
||||
function configureEasyLoadAudioNode(node) {
|
||||
if (
|
||||
node?.comfyClass !== EASY_LOAD_AUDIO_CLASS &&
|
||||
node?.type !== EASY_LOAD_AUDIO_CLASS
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
// A frontend-only convenience control must never make the Core loader
|
||||
// itself unplaceable. Some ComfyUI frontend paths initialize upload
|
||||
// widgets later than nodeCreated; fail open and keep the native node.
|
||||
try {
|
||||
configureEasyBypassToggleNode(node, {
|
||||
nodeClass: EASY_LOAD_AUDIO_CLASS,
|
||||
widgetName: "Enable Audio",
|
||||
tooltip:
|
||||
"ON runs Core Load Audio. OFF uses ComfyUI native Bypass and behaves like an unconnected optional audio input.",
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
"H3 Easy Load Audio bypass control was skipped; the Core audio loader remains available.",
|
||||
error,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
app.registerExtension({
|
||||
name: "H3Continuum.EasyLoadAudio",
|
||||
|
||||
beforeRegisterNodeDef(nodeType, nodeData) {
|
||||
if (
|
||||
nodeType?.prototype?.comfyClass !== EASY_LOAD_AUDIO_CLASS &&
|
||||
nodeData?.name !== EASY_LOAD_AUDIO_CLASS
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const required = nodeData?.input?.required;
|
||||
if (!required?.audio?.[1]?.audio_upload || required.audioUI) return;
|
||||
|
||||
// ComfyUI Frontend 1.49.x adds AUDIOUPLOAD to every audio_upload
|
||||
// schema, but adds its required AUDIO_UI preview only to a hard-coded
|
||||
// list containing Core LoadAudio. Insert the same Core preview widget
|
||||
// before AUDIOUPLOAD so the upload callback always receives it.
|
||||
const { upload, ...inputs } = required;
|
||||
nodeData.input.required = {
|
||||
...inputs,
|
||||
audioUI: ["AUDIO_UI", {}],
|
||||
...(upload ? { upload } : {}),
|
||||
};
|
||||
},
|
||||
|
||||
nodeCreated(node) {
|
||||
configureEasyLoadAudioNode(node);
|
||||
},
|
||||
|
||||
loadedGraphNode(node) {
|
||||
configureEasyLoadAudioNode(node);
|
||||
},
|
||||
|
||||
afterConfigureGraph() {
|
||||
for (const node of app.graph?._nodes || []) configureEasyLoadAudioNode(node);
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
import { app } from "../../scripts/app.js";
|
||||
import { configureEasyBypassToggleNode } from "./easy_bypass_toggle.js";
|
||||
|
||||
const EASY_LOAD_IMAGE_CLASS = "H3EasyLoadImage";
|
||||
|
||||
function configureEasyLoadImageNode(node) {
|
||||
configureEasyBypassToggleNode(node, {
|
||||
nodeClass: EASY_LOAD_IMAGE_CLASS,
|
||||
widgetName: "Enable Image",
|
||||
tooltip:
|
||||
"ON runs Core Load Image. OFF uses ComfyUI native Bypass and behaves like an unconnected optional image input.",
|
||||
});
|
||||
}
|
||||
|
||||
app.registerExtension({
|
||||
name: "H3Continuum.EasyLoadImage",
|
||||
|
||||
nodeCreated(node) {
|
||||
configureEasyLoadImageNode(node);
|
||||
},
|
||||
|
||||
loadedGraphNode(node) {
|
||||
configureEasyLoadImageNode(node);
|
||||
},
|
||||
|
||||
afterConfigureGraph() {
|
||||
for (const node of app.graph?._nodes || []) configureEasyLoadImageNode(node);
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,41 @@
|
||||
import { app } from "../../scripts/app.js";
|
||||
import { configureExistingEasyBypassWidgetNode } from "./easy_bypass_toggle.js";
|
||||
|
||||
const EASY_LOAD_VIDEO_CLASS = "H3ContinuumLoadVideo";
|
||||
|
||||
function configureEasyLoadVideoNode(node) {
|
||||
if (
|
||||
node?.comfyClass !== EASY_LOAD_VIDEO_CLASS &&
|
||||
node?.type !== EASY_LOAD_VIDEO_CLASS
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
configureExistingEasyBypassWidgetNode(node, {
|
||||
nodeClass: EASY_LOAD_VIDEO_CLASS,
|
||||
widgetNames: ["enable_video", "Enable Video"],
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
"H3 Continuum Load Video bypass appearance synchronization was skipped; backend blocking remains available.",
|
||||
error,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
app.registerExtension({
|
||||
name: "H3Continuum.EasyLoadVideo",
|
||||
|
||||
nodeCreated(node) {
|
||||
configureEasyLoadVideoNode(node);
|
||||
},
|
||||
|
||||
loadedGraphNode(node) {
|
||||
configureEasyLoadVideoNode(node);
|
||||
},
|
||||
|
||||
afterConfigureGraph() {
|
||||
for (const node of app.graph?._nodes || []) configureEasyLoadVideoNode(node);
|
||||
},
|
||||
});
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
import { app } from "../../scripts/app.js";
|
||||
|
||||
const EASY_NODE_CLASS = "H3ContinuumEasyV38";
|
||||
const CUSTOM_PRESET = "Custom";
|
||||
const STORAGE_ENABLED = "Save + Auto Resume";
|
||||
|
||||
function findWidget(node, name) {
|
||||
return node.widgets?.find((widget) => widget.name === name);
|
||||
}
|
||||
|
||||
function setWidgetVisible(widget, visible) {
|
||||
if (!widget) return;
|
||||
if (!widget.__h3EasyOriginal) {
|
||||
widget.__h3EasyOriginal = {
|
||||
type: widget.type,
|
||||
computeSize: widget.computeSize,
|
||||
hidden: widget.hidden,
|
||||
optionsHidden: widget.options?.hidden,
|
||||
};
|
||||
}
|
||||
widget.options ||= {};
|
||||
if (visible) {
|
||||
const original = widget.__h3EasyOriginal;
|
||||
widget.type = original.type;
|
||||
widget.computeSize = original.computeSize;
|
||||
widget.hidden = original.hidden;
|
||||
if (original.optionsHidden === undefined) {
|
||||
delete widget.options.hidden;
|
||||
} else {
|
||||
widget.options.hidden = original.optionsHidden;
|
||||
}
|
||||
return;
|
||||
}
|
||||
widget.hidden = true;
|
||||
widget.type = "converted-widget";
|
||||
widget.options.hidden = true;
|
||||
widget.computeSize = () => [0, -4];
|
||||
}
|
||||
|
||||
function attachRefresh(widget, key, refresh) {
|
||||
if (!widget || widget[key]) return;
|
||||
const previous = widget.callback;
|
||||
widget.callback = function(value, ...args) {
|
||||
const result = previous?.call(this, value, ...args);
|
||||
refresh();
|
||||
return result;
|
||||
};
|
||||
widget[key] = true;
|
||||
}
|
||||
|
||||
function createProjectId() {
|
||||
if (globalThis.crypto?.randomUUID) return globalThis.crypto.randomUUID();
|
||||
const bytes = new Uint8Array(16);
|
||||
globalThis.crypto.getRandomValues(bytes);
|
||||
bytes[6] = (bytes[6] & 0x0f) | 0x40;
|
||||
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
||||
const hex = Array.from(bytes, (value) => value.toString(16).padStart(2, "0")).join("");
|
||||
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
||||
}
|
||||
|
||||
function seedControlWidget(node) {
|
||||
return node.widgets?.find((widget) => (
|
||||
widget.name === "control_after_generate"
|
||||
|| widget.name === "seed_control_after_generate"
|
||||
));
|
||||
}
|
||||
|
||||
function configureEasyNode(node) {
|
||||
if (node.comfyClass !== EASY_NODE_CLASS) return null;
|
||||
const projectWidget = findWidget(node, "project_id");
|
||||
const presetWidget = findWidget(node, "preset");
|
||||
const customWidget = findWidget(node, "custom_mp");
|
||||
const storageWidget = findWidget(node, "run_storage");
|
||||
const runNameWidget = findWidget(node, "run_name");
|
||||
const seedModeWidget = findWidget(node, "seed_mode");
|
||||
const controlWidget = seedControlWidget(node);
|
||||
|
||||
if (projectWidget && !String(projectWidget.value || "").trim()) {
|
||||
projectWidget.value = createProjectId();
|
||||
}
|
||||
const refresh = () => {
|
||||
setWidgetVisible(customWidget, presetWidget?.value === CUSTOM_PRESET);
|
||||
setWidgetVisible(runNameWidget, storageWidget?.value === STORAGE_ENABLED);
|
||||
if (controlWidget) {
|
||||
controlWidget.value = seedModeWidget?.value === "Fixed" ? "fixed" : "randomize";
|
||||
controlWidget.callback?.(controlWidget.value);
|
||||
}
|
||||
setWidgetVisible(controlWidget, false);
|
||||
setWidgetVisible(projectWidget, false);
|
||||
node.setDirtyCanvas?.(true, true);
|
||||
};
|
||||
attachRefresh(presetWidget, "__h3EasyPresetCallback", refresh);
|
||||
attachRefresh(storageWidget, "__h3EasyStorageCallback", refresh);
|
||||
attachRefresh(seedModeWidget, "__h3EasySeedModeCallback", refresh);
|
||||
refresh();
|
||||
return projectWidget;
|
||||
}
|
||||
|
||||
function configureEasyNodeAfterSetup(node) {
|
||||
configureEasyNode(node);
|
||||
setTimeout(() => configureEasyNode(node), 0);
|
||||
setTimeout(() => configureEasyNode(node), 100);
|
||||
}
|
||||
|
||||
app.registerExtension({
|
||||
name: "H3Continuum.EasyV38",
|
||||
|
||||
nodeCreated(node) {
|
||||
configureEasyNodeAfterSetup(node);
|
||||
},
|
||||
|
||||
loadedGraphNode(node) {
|
||||
configureEasyNodeAfterSetup(node);
|
||||
},
|
||||
|
||||
afterConfigureGraph() {
|
||||
for (const node of app.graph?._nodes || []) configureEasyNodeAfterSetup(node);
|
||||
},
|
||||
|
||||
async beforeQueuePrompt(prompt) {
|
||||
const seen = new Set();
|
||||
for (const node of app.graph?._nodes || []) {
|
||||
const projectWidget = configureEasyNode(node);
|
||||
if (!projectWidget) continue;
|
||||
let projectId = String(projectWidget.value || "").trim();
|
||||
if (!projectId || seen.has(projectId)) {
|
||||
projectId = createProjectId();
|
||||
projectWidget.value = projectId;
|
||||
}
|
||||
seen.add(projectId);
|
||||
const apiNode = prompt.output?.[String(node.id)];
|
||||
if (apiNode?.inputs) apiNode.inputs.project_id = projectId;
|
||||
}
|
||||
},
|
||||
});
|
||||
+2573
-294
File diff suppressed because it is too large
Load Diff
+20
-20
@@ -1,20 +1,20 @@
|
||||
const NORMALIZED_INPUT_LABELS = {
|
||||
reference_video_1: "Video Guide Frames",
|
||||
driving_audio: "Driving Audio",
|
||||
audio_vae: "Driving Audio VAE",
|
||||
reference_audio_1: "Reference Audio (Optional)",
|
||||
reference_audio_vae: "Reference Audio VAE (Optional)",
|
||||
};
|
||||
|
||||
export function normalizeReferenceAudioLabels(node) {
|
||||
if (!node) {
|
||||
return false;
|
||||
}
|
||||
for (const input of node.inputs || []) {
|
||||
const label = NORMALIZED_INPUT_LABELS[input.name];
|
||||
if (label) {
|
||||
input.label = label;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
const NORMALIZED_INPUT_LABELS = {
|
||||
reference_video_1: "Video Guide Frames",
|
||||
driving_audio: "Driving Audio",
|
||||
audio_vae: "Driving Audio VAE",
|
||||
reference_audio_1: "Reference Audio (Optional)",
|
||||
reference_audio_vae: "Reference Audio VAE (Optional)",
|
||||
};
|
||||
|
||||
export function normalizeReferenceAudioLabels(node) {
|
||||
if (!node) {
|
||||
return false;
|
||||
}
|
||||
for (const input of node.inputs || []) {
|
||||
const label = NORMALIZED_INPUT_LABELS[input.name];
|
||||
if (label) {
|
||||
input.label = label;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user