- web/lib/: the shared rgthree-derived layer (mxd_* utils, dialogs, api, runtime) + its CSS, moved as a unit. - web/nodes/: one extension file per node/feature, _mxd suffix dropped. - web/vendor/zip_loader/: vendored zip import addon. - index.js explicitly imports every module; loraloader_mxd_entry.js folded into it and deleted. Power Lora Loader merge: new web/nodes/power_lora_base.js holds the shared node machinery, header row, and single-strength lora row widget. power_lora_loader.js (dual model/clip strengths) and ltx2_power_lora_loader.js (per-layer strength rows) are now thin subclasses (~450 duplicated lines removed). Serialization formats, widget names, extension names, and node targets unchanged. better_combos.js scoped to MXD latent loaders only: removed the pysssss CheckpointLoader/LoraLoader patching (already disabled behind ENABLE_PYSSSS_NODE_ENHANCEMENTS=false, so provably inert), the dead ' MXD' alias config entries, and the no-op refreshComboInNodes wrapper. scripts/check_web.py clean; node schema unchanged (68 identical). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
98 lines
3.0 KiB
JavaScript
98 lines
3.0 KiB
JavaScript
import { app } from "../../../scripts/app.js";
|
|
|
|
class LogSession {
|
|
constructor(name) {
|
|
this.name = name || "[mxd]";
|
|
}
|
|
|
|
logParts(level, message, ...args) {
|
|
const method = level === "error" ? "error" : level === "warn" ? "warn" : "log";
|
|
return [method, [`${this.name} ${message}`, ...args]];
|
|
}
|
|
|
|
errorParts(message, ...args) {
|
|
return this.logParts("error", message, ...args);
|
|
}
|
|
}
|
|
|
|
class MxdRuntime {
|
|
constructor() {
|
|
this.loadingApiJson = null;
|
|
this.lastCanvasMouseEvent = null;
|
|
this.canvasCurrentlyCopyingToClipboard = false;
|
|
this.canvasCurrentlyCopyingToClipboardWithMultipleNodes = false;
|
|
this.canvasCurrentlyPastingFromClipboard = false;
|
|
this.initializeHooks();
|
|
}
|
|
|
|
initializeHooks() {
|
|
const runtime = this;
|
|
|
|
const loadApiJson = app.loadApiJson;
|
|
app.loadApiJson = async function (apiData, fileName) {
|
|
runtime.loadingApiJson = apiData;
|
|
try {
|
|
return await loadApiJson.apply(app, [...arguments]);
|
|
} finally {
|
|
runtime.loadingApiJson = null;
|
|
}
|
|
};
|
|
|
|
const adjustMouseEvent = LGraphCanvas.prototype.adjustMouseEvent;
|
|
LGraphCanvas.prototype.adjustMouseEvent = function (e) {
|
|
adjustMouseEvent.apply(this, [...arguments]);
|
|
runtime.lastCanvasMouseEvent = e;
|
|
};
|
|
|
|
const copyToClipboard = LGraphCanvas.prototype.copyToClipboard;
|
|
LGraphCanvas.prototype.copyToClipboard = function (items) {
|
|
runtime.canvasCurrentlyCopyingToClipboard = true;
|
|
runtime.canvasCurrentlyCopyingToClipboardWithMultipleNodes =
|
|
Object.values(items || this.selected_nodes || {}).length > 1;
|
|
try {
|
|
return copyToClipboard.apply(this, [...arguments]);
|
|
} finally {
|
|
runtime.canvasCurrentlyCopyingToClipboard = false;
|
|
runtime.canvasCurrentlyCopyingToClipboardWithMultipleNodes = false;
|
|
}
|
|
};
|
|
|
|
const pasteFromClipboard = LGraphCanvas.prototype.pasteFromClipboard;
|
|
LGraphCanvas.prototype.pasteFromClipboard = function () {
|
|
runtime.canvasCurrentlyPastingFromClipboard = true;
|
|
try {
|
|
return pasteFromClipboard.apply(this, [...arguments]);
|
|
} finally {
|
|
runtime.canvasCurrentlyPastingFromClipboard = false;
|
|
}
|
|
};
|
|
}
|
|
|
|
newLogSession(name) {
|
|
return new LogSession(name);
|
|
}
|
|
|
|
showMessage({ id, type, message, timeout }) {
|
|
const msgId = id || `mxd-${Date.now()}`;
|
|
let container = document.querySelector(".mxd-top-messages-container");
|
|
if (!container) {
|
|
container = document.createElement("div");
|
|
container.className = "mxd-top-messages-container";
|
|
document.body.appendChild(container);
|
|
}
|
|
const node = document.createElement("div");
|
|
node.className = `mxd-top-message ${type || "info"}`;
|
|
node.setAttribute("msg-id", msgId);
|
|
node.textContent = message || "";
|
|
container.appendChild(node);
|
|
setTimeout(() => node.remove(), timeout || 3000);
|
|
}
|
|
|
|
isDevMode() {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
export const mxdRuntime = new MxdRuntime();
|
|
window.mxdRuntime = mxdRuntime;
|