补充 Image Solid 256x256 预设,并修复 Load Image / Load Video / Load Video to Image 的预览显示、交互与旧工作流兼容问题。
43 lines
981 B
JavaScript
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 {}
|
|
}
|
|
},
|
|
};
|
|
}
|
|
|