fix: update version to 1.1.6 and enhance getSavedPaths function for improved file retrieval
This commit is contained in:
+32
-12
@@ -25,11 +25,27 @@ function openUrl(url) {
|
||||
}
|
||||
|
||||
function getSavedPaths(message) {
|
||||
const files = message?.imagemetahub?.files;
|
||||
if (!Array.isArray(files)) {
|
||||
return [];
|
||||
const candidates = [
|
||||
message?.imagemetahub?.files,
|
||||
message?.ui?.imagemetahub?.files,
|
||||
];
|
||||
|
||||
for (const files of candidates) {
|
||||
if (Array.isArray(files)) {
|
||||
return files.filter(
|
||||
(filePath) => typeof filePath === "string" && filePath.trim()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
function captureLastSavedPath(node, message) {
|
||||
const savedPaths = getSavedPaths(message);
|
||||
if (savedPaths.length > 0) {
|
||||
node.__imageMetaHubLastSavedPath = savedPaths[savedPaths.length - 1];
|
||||
}
|
||||
return files.filter((filePath) => typeof filePath === "string" && filePath.trim());
|
||||
}
|
||||
|
||||
function addMetaHubCTA(node) {
|
||||
@@ -42,14 +58,6 @@ function addMetaHubCTA(node) {
|
||||
}
|
||||
|
||||
node.__imageMetaHubCTAAdded = true;
|
||||
const originalOnExecuted = node.onExecuted;
|
||||
node.onExecuted = function (message) {
|
||||
originalOnExecuted?.apply(this, arguments);
|
||||
const savedPaths = getSavedPaths(message);
|
||||
if (savedPaths.length > 0) {
|
||||
this.__imageMetaHubLastSavedPath = savedPaths[savedPaths.length - 1];
|
||||
}
|
||||
};
|
||||
|
||||
node.addWidget(
|
||||
"button",
|
||||
@@ -75,6 +83,18 @@ function addMetaHubCTA(node) {
|
||||
app.registerExtension({
|
||||
name: "ImageMetaHub.SaveNodeCTA",
|
||||
|
||||
async beforeRegisterNodeDef(nodeType, nodeData) {
|
||||
if (!METAHUB_SAVE_NODE_CLASSES.has(nodeData.name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const originalOnExecuted = nodeType.prototype.onExecuted;
|
||||
nodeType.prototype.onExecuted = function (message) {
|
||||
originalOnExecuted?.apply(this, arguments);
|
||||
captureLastSavedPath(this, message);
|
||||
};
|
||||
},
|
||||
|
||||
async nodeCreated(node) {
|
||||
addMetaHubCTA(node);
|
||||
},
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@ Compatibility shim for MetaHub Save Node metadata helpers.
|
||||
|
||||
The implementation is kept in metadata_utils_impl.py; this module exposes the
|
||||
same public API expected by the save nodes while pinning the published node
|
||||
version to 1.1.5.
|
||||
version to 1.1.6.
|
||||
"""
|
||||
|
||||
try:
|
||||
@@ -11,7 +11,7 @@ try:
|
||||
except ImportError:
|
||||
import metadata_utils_impl as _impl
|
||||
|
||||
METAHUB_SAVE_NODE_VERSION = "1.1.5"
|
||||
METAHUB_SAVE_NODE_VERSION = "1.1.6"
|
||||
_impl.METAHUB_SAVE_NODE_VERSION = METAHUB_SAVE_NODE_VERSION
|
||||
|
||||
for _name in dir(_impl):
|
||||
|
||||
@@ -14,7 +14,7 @@ from xml.sax.saxutils import escape as xml_escape
|
||||
import numpy as np
|
||||
from PIL import Image, PngImagePlugin
|
||||
|
||||
METAHUB_SAVE_NODE_VERSION = "1.1.5"
|
||||
METAHUB_SAVE_NODE_VERSION = "1.1.6"
|
||||
|
||||
try:
|
||||
import piexif
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
[project]
|
||||
name = "imagemetahub-comfyui-save"
|
||||
description = "Official companion node for Image MetaHub. Saves A1111/Civitai-compatible parameters plus extended Image MetaHub metadata (workflow JSON, SHA256 model hashes, VRAM peak/total, GPU device, generation time, and steps/sec) for reproducibility and benchmarking."
|
||||
version = "1.1.5"
|
||||
version = "1.1.6"
|
||||
license = {file = "LICENSE"}
|
||||
# classifiers = [
|
||||
# # For OS-independent nodes (works on all operating systems)
|
||||
|
||||
@@ -334,7 +334,7 @@ def test_extract_workflow_attribution_from_node_properties():
|
||||
|
||||
assert attribution["token"] == "imhcrt_br_creator_workflow_v1_random"
|
||||
assert attribution["source"] == "metahub_save_node"
|
||||
assert attribution["node_version"] == "1.1.5"
|
||||
assert attribution["node_version"] == "1.1.6"
|
||||
|
||||
|
||||
def test_build_imh_metadata_includes_attribution_without_a1111_parameters():
|
||||
|
||||
Reference in New Issue
Block a user