Files
1hew-ComfyUI-1hewNodes/web/js/core/runtime.js
T
1hew f492675b25 v3.10.0 chore(release): 添加 Image Alpha Join 并修复媒体预览
补充 Image Solid 256x256 预设,并修复 Load Image / Load Video / Load Video to Image 的预览显示、交互与旧工作流兼容问题。
2026-04-16 02:55:21 +08:00

43 lines
981 B
JavaScript

export function registerExtensionOnce(windowKey, register) {
if (window[windowKey]) {
return false;
}
window[windowKey] = true;
register();
return true;
}
export function chainOnRemoved(node, cleanup) {
const originalOnRemoved = node.onRemoved;
node.onRemoved = function () {
try {
cleanup?.call(this);
} catch {}
if (typeof originalOnRemoved === "function") {
return originalOnRemoved.apply(this, arguments);
}
};
}
export function createDisposer() {
const cleanups = [];
return {
add(cleanup) {
if (typeof cleanup === "function") {
cleanups.push(cleanup);
}
return cleanup;
},
dispose() {
while (cleanups.length > 0) {
const cleanup = cleanups.pop();
try {
cleanup?.();
} catch {}
}
},
};
}