feat: refactor Lora handling by introducing chainCallback for improved node initialization and widget management. Fixes #176

This commit is contained in:
Will Miao
2025-06-24 16:36:15 +08:00
parent d0ed1213d8
commit ceee482ecc
3 changed files with 126 additions and 107 deletions

View File

@@ -1,5 +1,23 @@
export const CONVERTED_TYPE = 'converted-widget';
export function chainCallback(object, property, callback) {
if (object == undefined) {
//This should not happen.
console.error("Tried to add callback to non-existant object")
return;
}
if (property in object) {
const callback_orig = object[property]
object[property] = function () {
const r = callback_orig.apply(this, arguments);
callback.apply(this, arguments);
return r
};
} else {
object[property] = callback;
}
}
export function getComfyUIFrontendVersion() {
return window['__COMFYUI_FRONTEND_VERSION__'] || "0.0.0";
}