Release V3.8X2 package 3.8.3
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
import { app } from "../../scripts/app.js";
|
||||
|
||||
const NODE_CLASS = "H3DecodeCacheHelper";
|
||||
const MAX_TOKEN = 2147483647;
|
||||
const BUTTON_NAME = "キャッシュをクリア";
|
||||
const TOOLTIP = "次回QueueでこのHelperのキャッシュを破棄します。次回は通常Decodeとなります。普段は操作不要です。";
|
||||
|
||||
// Keep the backend widget in its original position. Only its presentation is
|
||||
// hidden; Core still serializes and sends reset_token as an INT.
|
||||
function hideToken(widget) {
|
||||
widget.hidden = true;
|
||||
widget.options ||= {};
|
||||
widget.options.hidden = true;
|
||||
widget.type = "converted-widget";
|
||||
widget.computeSize = () => [0, -4];
|
||||
}
|
||||
|
||||
function withoutButton(node, button, operation) {
|
||||
const index = node.widgets?.indexOf(button) ?? -1;
|
||||
if (index >= 0) node.widgets.splice(index, 1);
|
||||
try {
|
||||
return operation();
|
||||
} finally {
|
||||
if (index >= 0) node.widgets.splice(index, 0, button);
|
||||
}
|
||||
}
|
||||
|
||||
export function configureDecodeCacheHelper(node) {
|
||||
if (node?.comfyClass !== NODE_CLASS && node?.type !== NODE_CLASS) return;
|
||||
const token = node.widgets?.find((widget) => widget.name === "reset_token");
|
||||
if (!token || typeof node.addWidget !== "function") return;
|
||||
if (!node.__h3DecodeCacheClearButton) {
|
||||
// Create the control before hiding the numeric widget, so a failed
|
||||
// control installation leaves the traditional input available.
|
||||
const button = node.addWidget("button", BUTTON_NAME, null, () => {
|
||||
const current = node.widgets?.find((widget) => widget.name === "reset_token");
|
||||
if (!current) return;
|
||||
const value = Number(current.value);
|
||||
if (!Number.isInteger(value) || value < 0 || value > MAX_TOKEN) return;
|
||||
// Wrap only at the backend's INT limit; never submit an invalid INT.
|
||||
current.value = value === MAX_TOKEN ? 0 : value + 1;
|
||||
node.setDirtyCanvas?.(true, true);
|
||||
}, { serialize: false });
|
||||
button.serialize = false;
|
||||
button.options ||= {};
|
||||
button.options.serialize = false;
|
||||
button.tooltip = TOOLTIP;
|
||||
node.__h3DecodeCacheClearButton = button;
|
||||
|
||||
// Some frontend versions assign widgets_values by index even for
|
||||
// non-serialized controls. Exclude the button from both operations.
|
||||
const serialize = node.serialize;
|
||||
if (typeof serialize === "function") {
|
||||
node.serialize = function (...args) {
|
||||
return withoutButton(this, button, () => serialize.apply(this, args));
|
||||
};
|
||||
}
|
||||
const configure = node.configure;
|
||||
if (typeof configure === "function") {
|
||||
node.configure = function (...args) {
|
||||
const result = withoutButton(this, button, () => configure.apply(this, args));
|
||||
configureDecodeCacheHelper(this);
|
||||
return result;
|
||||
};
|
||||
}
|
||||
}
|
||||
hideToken(token);
|
||||
node.setDirtyCanvas?.(true, true);
|
||||
}
|
||||
|
||||
app.registerExtension({
|
||||
name: "H3Continuum.DecodeCacheHelper.ClearButton",
|
||||
nodeCreated: configureDecodeCacheHelper,
|
||||
loadedGraphNode: configureDecodeCacheHelper,
|
||||
afterConfigureGraph() {
|
||||
for (const node of app.graph?._nodes || []) configureDecodeCacheHelper(node);
|
||||
},
|
||||
});
|
||||
+26
-7
@@ -1,6 +1,7 @@
|
||||
import { app } from "../../scripts/app.js";
|
||||
import { api } from "../../scripts/api.js";
|
||||
import { normalizeReferenceAudioLabels } from "./reference_audio_ui.js";
|
||||
import { migrateReferenceImageInputs } from "./reference_image_ui.js";
|
||||
|
||||
const PRODUCTION_NODE_CLASS = "H3ContinuumSamplerProduction";
|
||||
const TIMELINE_NODE_CLASS = "H3ContinuumSamplerTimelineVideo";
|
||||
@@ -341,6 +342,13 @@ function linkedInput(node, names) {
|
||||
return node.inputs?.some((input) => names.includes(input.name) && input.link != null) ?? false;
|
||||
}
|
||||
|
||||
function removeUnusedLegacyInputs(node) {
|
||||
if (node.comfyClass !== V38_NODE_CLASS) return;
|
||||
for (const name of ["guide", "reference_audio_1", "reference_audio_vae"]) {
|
||||
if (!linkedInput(node, [name])) removeUnusedInput(node, name);
|
||||
}
|
||||
}
|
||||
|
||||
function activeLinkedInput(node, names) {
|
||||
const inputs = node.inputs?.filter(
|
||||
(item) => names.includes(item.name) && item.link != null,
|
||||
@@ -351,6 +359,11 @@ function activeLinkedInput(node, names) {
|
||||
const source = app.graph?.getNodeById?.(link.origin_id);
|
||||
if (!source) return true;
|
||||
if ([2, 4].includes(Number(source.mode))) return false;
|
||||
if (source.comfyClass === "H3ContinuumReferenceImages") {
|
||||
return activeLinkedInput(source, source.inputs.filter(
|
||||
(item) => /^reference_image_[4-9]$/.test(item.name),
|
||||
).map((item) => item.name));
|
||||
}
|
||||
const enableWidget = source.widgets?.find((widget) => (
|
||||
[
|
||||
"Enable Image",
|
||||
@@ -1214,7 +1227,7 @@ function configureIntuitiveV38Ux(node) {
|
||||
);
|
||||
const referenceConnected = activeLinkedInput(
|
||||
node,
|
||||
["reference_image_1", "reference_image_2", "reference_image_3"],
|
||||
["reference_image_1", "reference_image_2", "reference_image_3", "reference_image_4", "reference_image_5", "image_references"],
|
||||
);
|
||||
const videoConnected = activeLinkedInput(node, ["reference_video_1"]);
|
||||
const storageEnabled = findWidget(node, RUN_STORAGE_WIDGET)?.value === "Save + Auto Resume";
|
||||
@@ -2683,6 +2696,7 @@ function configureConditionalWidgets(node) {
|
||||
regenerateWidget.__h3ContinuumManualIntentCallback = true;
|
||||
}
|
||||
const refresh = () => {
|
||||
removeUnusedLegacyInputs(node);
|
||||
const productionView = true;
|
||||
const storageEnabled = node.comfyClass === V38_NODE_CLASS
|
||||
? storageWidget?.value === "Save + Auto Resume"
|
||||
@@ -2696,7 +2710,7 @@ function configureConditionalWidgets(node) {
|
||||
setWidgetVisible(
|
||||
findWidget(node, REFERENCE_SIZE_WIDGET),
|
||||
productionView
|
||||
&& linkedInput(node, ["reference_image_1", "reference_image_2", "reference_image_3"]),
|
||||
&& activeLinkedInput(node, ["reference_image_1", "reference_image_2", "reference_image_3", "reference_image_4", "reference_image_5", "image_references"]),
|
||||
);
|
||||
setWidgetVisible(
|
||||
findWidget(node, TIMELINE_SIZE_WIDGET),
|
||||
@@ -3052,7 +3066,10 @@ function configureNode(node) {
|
||||
const isV37 = node.comfyClass === V37_NODE_CLASS;
|
||||
const isV38 = node.comfyClass === V38_NODE_CLASS;
|
||||
if (!isProduction && !isTimeline && !isV34 && !isV35 && !isV36 && !isV37 && !isV38) {
|
||||
configureAssembler(node);
|
||||
if (node.comfyClass === "H3ContinuumReferenceAudios") {
|
||||
normalizeReferenceAudioLabels(node);
|
||||
}
|
||||
configureAssembler(node);
|
||||
return null;
|
||||
}
|
||||
const projectWidget = findWidget(node, PROJECT_WIDGET);
|
||||
@@ -3066,7 +3083,8 @@ function configureNode(node) {
|
||||
if (isV35 || isV36 || isV37 || isV38) {
|
||||
normalizeReferenceAudioLabels(node);
|
||||
}
|
||||
hidePersistentWidget(findWidget(node, "diagnostics"));
|
||||
removeUnusedLegacyInputs(node);
|
||||
hidePersistentWidget(findWidget(node, "diagnostics"));
|
||||
hidePersistentWidget(findWidget(node, "strict_compatibility"));
|
||||
hidePersistentWidget(findWidget(node, "debug"));
|
||||
hidePersistentWidget(findWidget(node, "show_preview"));
|
||||
@@ -3146,9 +3164,10 @@ app.registerExtension({
|
||||
configureNodeAfterSetup(node);
|
||||
},
|
||||
|
||||
afterConfigureGraph() {
|
||||
for (const node of app.graph?._nodes || []) {
|
||||
configureNodeAfterSetup(node);
|
||||
afterConfigureGraph() {
|
||||
for (const node of [...(app.graph?._nodes || [])]) {
|
||||
migrateReferenceImageInputs(node);
|
||||
configureNodeAfterSetup(node);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -2,14 +2,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)",
|
||||
audio_references: "Reference Audios (Optional)",
|
||||
reference_audio_1: "Reference Audio (Legacy)",
|
||||
reference_audio_vae: "Reference Audio VAE (Legacy)",
|
||||
};
|
||||
|
||||
export function normalizeReferenceAudioLabels(node) {
|
||||
if (!node) {
|
||||
return false;
|
||||
}
|
||||
if (!node) {
|
||||
return false;
|
||||
}
|
||||
if (node.comfyClass === "H3ContinuumReferenceAudios") {
|
||||
const output = node.outputs?.find((item) => item.name === "audio_references");
|
||||
if (output) output.label = "Reference Audios";
|
||||
return true;
|
||||
}
|
||||
for (const input of node.inputs || []) {
|
||||
const label = NORMALIZED_INPUT_LABELS[input.name];
|
||||
if (label) {
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
import { app } from "../../scripts/app.js";
|
||||
|
||||
const BUNDLE_NODE = "H3ContinuumReferenceImages";
|
||||
const BUNDLE_INPUT = "image_references";
|
||||
const BUNDLE_TYPE = "H3_CONTINUUM_IMAGE_REFERENCES";
|
||||
|
||||
export function migrateReferenceImageInputs(node) {
|
||||
if (node.comfyClass !== "H3ContinuumSamplerV38") return;
|
||||
const graph = node.graph || app.graph;
|
||||
const legacy = (node.inputs || []).filter(
|
||||
(input) => ["reference_image_4", "reference_image_5"].includes(input.name),
|
||||
);
|
||||
if (!node.inputs?.some((input) => input.name === BUNDLE_INPUT)) {
|
||||
node.addInput(BUNDLE_INPUT, BUNDLE_TYPE, { label: "Reference Images (Optional)" });
|
||||
}
|
||||
if (!legacy.length) return;
|
||||
|
||||
const connected = legacy.filter((input) => input.link != null);
|
||||
const bundleSlot = node.inputs.findIndex((input) => input.name === BUNDLE_INPUT);
|
||||
const bundleLink = graph.links[node.inputs[bundleSlot].link];
|
||||
let bundle = bundleLink && graph.getNodeById(bundleLink.origin_id);
|
||||
if (connected.length) {
|
||||
const sources = connected.map((input) => {
|
||||
const link = graph.links[input.link];
|
||||
const source = link && graph.getNodeById(link.origin_id);
|
||||
return { input, link, source };
|
||||
});
|
||||
if (sources.some(({ source }) => !source)
|
||||
|| (bundleLink && bundle?.comfyClass !== BUNDLE_NODE)) {
|
||||
console.warn("H3 Continuum: legacy Reference Image links retained; their source or bundle cannot be migrated.");
|
||||
return;
|
||||
}
|
||||
if (bundle && connected.some((input) => {
|
||||
const slot = bundle.inputs.find((item) => item.name === input.name);
|
||||
return !slot || slot.link != null;
|
||||
})) {
|
||||
console.warn("H3 Continuum: legacy Reference Image links retained; the matching bundle slots are occupied.");
|
||||
return;
|
||||
}
|
||||
if (!bundle) {
|
||||
bundle = globalThis.LiteGraph?.createNode(BUNDLE_NODE);
|
||||
if (!bundle) {
|
||||
console.warn("H3 Continuum: legacy Reference Image links retained; the Reference Images node is unavailable.");
|
||||
return;
|
||||
}
|
||||
bundle.pos = [node.pos[0] - 360, node.pos[1] + 220];
|
||||
graph.add(bundle);
|
||||
bundle.connect(0, node, bundleSlot);
|
||||
if (node.inputs[bundleSlot].link == null) {
|
||||
graph.remove(bundle);
|
||||
console.warn("H3 Continuum: legacy Reference Image links retained; bundle connection failed.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (const { input, link, source } of sources) {
|
||||
const slot = bundle.inputs.findIndex((item) => item.name === input.name);
|
||||
source.connect(link.origin_slot, bundle, slot);
|
||||
const moved = graph.links[bundle.inputs[slot].link];
|
||||
if (!moved || moved.origin_id !== link.origin_id || moved.origin_slot !== link.origin_slot) {
|
||||
console.warn("H3 Continuum: legacy Reference Image link retained; image connection failed.");
|
||||
continue;
|
||||
}
|
||||
node.removeInput(node.inputs.indexOf(input));
|
||||
}
|
||||
}
|
||||
for (const input of legacy) {
|
||||
const slot = node.inputs.indexOf(input);
|
||||
if (slot >= 0 && input.link == null) node.removeInput(slot);
|
||||
}
|
||||
node.setDirtyCanvas?.(true, true);
|
||||
}
|
||||
Reference in New Issue
Block a user