diff --git a/web/extensions/core/contextMenuFilter.js b/web/extensions/core/contextMenuFilter.js index d6fd98600..f7a73101e 100644 --- a/web/extensions/core/contextMenuFilter.js +++ b/web/extensions/core/contextMenuFilter.js @@ -1,18 +1,17 @@ import { app } from "../../scripts/app.js"; import { LiteGraph } from "../../lib/litegraph.core.js" +import { hook } from "../../scripts/utils.js"; // Adds filtering to combo context menus const ext = { name: "Comfy.ContextMenuFilter", init() { - const ctxMenu = LiteGraph.ContextMenu; - - LiteGraph.ContextMenu = function (values, options) { - const ctx = ctxMenu.call(this, values, options); + hook(LiteGraph, "onContextMenuCreated", (orig, contextMenu) => { + orig?.(contextMenu); // If we are a dark menu (only used for combo boxes) then add a filter input - if (options?.className === "dark" && values?.length > 10) { + if (contextMenu.options?.className === "dark" && contextMenu.values?.length > 10) { const filter = document.createElement("input"); filter.classList.add("comfy-context-menu-filter"); filter.placeholder = "Filter list"; @@ -30,7 +29,7 @@ const ext = { .find(w => w.options.values.every((v, i) => v === values[i])) ?.value; - let selectedIndex = clickedComboValue ? values.findIndex(v => v === clickedComboValue) : 0; + let selectedIndex = clickedComboValue ? contextMenu.values.findIndex(v => v === clickedComboValue) : 0; if (selectedIndex < 0) { selectedIndex = 0; } @@ -116,8 +115,8 @@ const ext = { updateSelected(); // If we have an event then we can try and position the list under the source - if (options.event) { - let top = options.event.clientY - 10; + if (contextMenu.options.event) { + let top = contextMenu.options.event.clientY - 10; const bodyRect = document.body.getBoundingClientRect(); const rootRect = this.root.getBoundingClientRect(); @@ -138,11 +137,7 @@ const ext = { }); }) } - - return ctx; - }; - - // LiteGraph.ContextMenu.prototype = ctxMenu.prototype; + }); }, } diff --git a/web/extensions/core/invertMenuScrolling.js b/web/extensions/core/invertMenuScrolling.js index 3b48efad0..0b24cd5a3 100644 --- a/web/extensions/core/invertMenuScrolling.js +++ b/web/extensions/core/invertMenuScrolling.js @@ -1,5 +1,6 @@ import { app } from "../../scripts/app.js"; import { LiteGraph } from "../../lib/litegraph.core.js" +import { hook } from "../../scripts/utils.js"; // Inverts the scrolling of context menus @@ -7,30 +8,18 @@ const id = "Comfy.InvertMenuScrolling"; app.registerExtension({ name: id, init() { - const ctxMenu = LiteGraph.ContextMenu; - const replace = () => { - LiteGraph.ContextMenu = function (values, options) { - options = options || {}; - if (options.scroll_speed) { - options.scroll_speed *= -1; - } else { - options.scroll_speed = -0.1; - } - return ctxMenu.call(this, values, options); - }; - LiteGraph.ContextMenu.prototype = ctxMenu.prototype; - }; + let invert = false; + hook(LiteGraph, "onContextMenuCreated", (orig, contextMenu) => { + orig?.(contextMenu); + contextMenu.invert_scrolling = invert; + }) app.ui.settings.addSetting({ id, name: "Invert Menu Scrolling", type: "boolean", defaultValue: false, onChange(value) { - if (value) { - replace(); - } else { - LiteGraph.ContextMenu = ctxMenu; - } + invert = value; }, }); }, diff --git a/web/lib/litegraph.core.js b/web/lib/litegraph.core.js index e74247d78..4021f2cdf 100644 --- a/web/lib/litegraph.core.js +++ b/web/lib/litegraph.core.js @@ -1,77 +1,77 @@ -var w = /* @__PURE__ */ ((e) => (e[e.UP = 1] = "UP", e[e.DOWN = 2] = "DOWN", e[e.LEFT = 3] = "LEFT", e[e.RIGHT = 4] = "RIGHT", e[e.CENTER = 5] = "CENTER", e))(w || {}), Z = /* @__PURE__ */ ((e) => (e[e.ALWAYS = 0] = "ALWAYS", e[e.ON_EVENT = 1] = "ON_EVENT", e[e.NEVER = 2] = "NEVER", e[e.ON_TRIGGER = 3] = "ON_TRIGGER", e[e.ON_REQUEST = 4] = "ON_REQUEST", e))(Z || {}); +var w = /* @__PURE__ */ ((t) => (t[t.UP = 1] = "UP", t[t.DOWN = 2] = "DOWN", t[t.LEFT = 3] = "LEFT", t[t.RIGHT = 4] = "RIGHT", t[t.CENTER = 5] = "CENTER", t))(w || {}), Z = /* @__PURE__ */ ((t) => (t[t.ALWAYS = 0] = "ALWAYS", t[t.ON_EVENT = 1] = "ON_EVENT", t[t.NEVER = 2] = "NEVER", t[t.ON_TRIGGER = 3] = "ON_TRIGGER", t[t.ON_REQUEST = 4] = "ON_REQUEST", t))(Z || {}); const re = ["Always", "On Event", "Never", "On Trigger"], Oe = ["#666", "#422", "#333", "#224", "#626"]; -var k = /* @__PURE__ */ ((e) => (e[e.DEFAULT = 0] = "DEFAULT", e[e.BOX_SHAPE = 1] = "BOX_SHAPE", e[e.ROUND_SHAPE = 2] = "ROUND_SHAPE", e[e.CIRCLE_SHAPE = 3] = "CIRCLE_SHAPE", e[e.CARD_SHAPE = 4] = "CARD_SHAPE", e[e.ARROW_SHAPE = 5] = "ARROW_SHAPE", e[e.GRID_SHAPE = 6] = "GRID_SHAPE", e))(k || {}); +var k = /* @__PURE__ */ ((t) => (t[t.DEFAULT = 0] = "DEFAULT", t[t.BOX_SHAPE = 1] = "BOX_SHAPE", t[t.ROUND_SHAPE = 2] = "ROUND_SHAPE", t[t.CIRCLE_SHAPE = 3] = "CIRCLE_SHAPE", t[t.CARD_SHAPE = 4] = "CARD_SHAPE", t[t.ARROW_SHAPE = 5] = "ARROW_SHAPE", t[t.GRID_SHAPE = 6] = "GRID_SHAPE", t))(k || {}); const Ie = ["default", "box", "round", "circle", "card", "arrow", "square"]; -var Y = /* @__PURE__ */ ((e) => (e[e.INPUT = 0] = "INPUT", e[e.OUTPUT = 1] = "OUTPUT", e))(Y || {}), de = /* @__PURE__ */ ((e) => (e[e.STRAIGHT_LINK = 0] = "STRAIGHT_LINK", e[e.LINEAR_LINK = 1] = "LINEAR_LINK", e[e.SPLINE_LINK = 2] = "SPLINE_LINK", e))(de || {}); +var W = /* @__PURE__ */ ((t) => (t[t.INPUT = 0] = "INPUT", t[t.OUTPUT = 1] = "OUTPUT", t))(W || {}), de = /* @__PURE__ */ ((t) => (t[t.STRAIGHT_LINK = 0] = "STRAIGHT_LINK", t[t.LINEAR_LINK = 1] = "LINEAR_LINK", t[t.SPLINE_LINK = 2] = "SPLINE_LINK", t))(de || {}); const Xe = ["Straight", "Linear", "Spline"]; -var se = /* @__PURE__ */ ((e) => (e[e.NORMAL_TITLE = 0] = "NORMAL_TITLE", e[e.NO_TITLE = 1] = "NO_TITLE", e[e.TRANSPARENT_TITLE = 2] = "TRANSPARENT_TITLE", e[e.AUTOHIDE_TITLE = 3] = "AUTOHIDE_TITLE", e))(se || {}), I = /* @__PURE__ */ ((e) => (e[e.EVENT = -2] = "EVENT", e[e.ACTION = -1] = "ACTION", e[e.DEFAULT = 0] = "DEFAULT", e))(I || {}); +var se = /* @__PURE__ */ ((t) => (t[t.NORMAL_TITLE = 0] = "NORMAL_TITLE", t[t.NO_TITLE = 1] = "NO_TITLE", t[t.TRANSPARENT_TITLE = 2] = "TRANSPARENT_TITLE", t[t.AUTOHIDE_TITLE = 3] = "AUTOHIDE_TITLE", t))(se || {}), I = /* @__PURE__ */ ((t) => (t[t.EVENT = -2] = "EVENT", t[t.ACTION = -1] = "ACTION", t[t.DEFAULT = 0] = "DEFAULT", t))(I || {}); const Ae = ["*", "array", "object", "number", "string", "enum", "boolean", "table"]; -var ue = /* @__PURE__ */ ((e) => (e.VERTICAL_LAYOUT = "vertical", e.HORIZONTAL_LAYOUT = "horizontal", e))(ue || {}); -function Te(e, t, i) { - return t > e ? t : i < e ? i : e; +var ue = /* @__PURE__ */ ((t) => (t.VERTICAL_LAYOUT = "vertical", t.HORIZONTAL_LAYOUT = "horizontal", t))(ue || {}); +function Te(t, e, i) { + return e > t ? e : i < t ? i : t; } -function ve(e, t) { - return e.reduce((i, n) => { - const s = t(n); +function ve(t, e) { + return t.reduce((i, n) => { + const s = e(n); return i[s] = n, i; }, {}); } -function Ce(e, t) { - return t in e ? e[t] : null; +function Ce(t, e) { + return e in t ? t[e] : null; } -function ye(e, t) { - return t in e.constructor ? e.constructor[t] : null; +function ye(t, e) { + return e in t.constructor ? t.constructor[e] : null; } -function Ge(e, t) { - if (e.target !== t) +function Ge(t, e) { + if (t.target !== e) return; - let i = e.clientX - parseInt(window.getComputedStyle(t).left), n = e.clientY - parseInt(window.getComputedStyle(t).top); + let i = t.clientX - parseInt(window.getComputedStyle(e).left), n = t.clientY - parseInt(window.getComputedStyle(e).top); const s = (o) => { if (o.buttons === 0) { r(); return; } - t.style.top = o.clientY - n + "px", t.style.left = o.clientX - i + "px"; + e.style.top = o.clientY - n + "px", e.style.left = o.clientX - i + "px"; }, r = () => { window.removeEventListener("mousemove", s), window.removeEventListener("mouseup", r); }; window.addEventListener("mousemove", s), window.addEventListener("mouseup", r); } -function Ee(e) { - return e.addEventListener("mousedown", (t) => Ge(t, e)), e.classList.add("draggable"), e; +function Ee(t) { + return t.addEventListener("mousedown", (e) => Ge(e, t)), t.classList.add("draggable"), t; } -function J(e) { - return e === I.EVENT ? "Event" : e === I.ACTION ? "Action" : e === I.DEFAULT ? "Default" : e; +function J(t) { + return t === I.EVENT ? "Event" : t === I.ACTION ? "Action" : t === I.DEFAULT ? "Default" : t; } -function Se(e) { - return e === I.EVENT || e === I.ACTION || e === I.DEFAULT || typeof e == "string"; +function Se(t) { + return t === I.EVENT || t === I.ACTION || t === I.DEFAULT || typeof t == "string"; } const S = class { /** Register a node class so it can be listed when the user wants to create a new one */ - static registerNodeType(e) { - S.debug && console.log("Node registered: " + e.type); - const t = e.name, i = e.type; + static registerNodeType(t) { + S.debug && console.log("Node registered: " + t.type); + const e = t.name, i = t.type; if (!i) - throw console.error(e), new Error("Config has no type: " + e); - if (S.debug && console.debug(t, i), e.category == null || e.category === "") { + throw console.error(t), new Error("Config has no type: " + t); + if (S.debug && console.debug(e, i), t.category == null || t.category === "") { const s = i.lastIndexOf("/"); - e.category = i.substring(0, s); + t.category = i.substring(0, s); } - e.title || (e.title = t); + t.title || (t.title = e); const n = S.registered_node_types[i]; - if (n && console.warn("replacing node type: " + i), e.supported_extensions) - for (let s in e.supported_extensions) { - const r = e.supported_extensions[s]; - r && r.constructor === String && (S.node_types_by_file_extension[r.toLowerCase()] = e); + if (n && console.warn("replacing node type: " + i), t.supported_extensions) + for (let s in t.supported_extensions) { + const r = t.supported_extensions[s]; + r && r.constructor === String && (S.node_types_by_file_extension[r.toLowerCase()] = t); } - e.class.__LITEGRAPH_TYPE__ = i, S.registered_node_types[i] = e, e.class.name && (S.Nodes[t] = e), S.onNodeTypeRegistered && S.onNodeTypeRegistered(i, e), n && S.onNodeTypeReplaced && S.onNodeTypeReplaced(i, e, n); + t.class.__LITEGRAPH_TYPE__ = i, S.registered_node_types[i] = t, t.class.name && (S.Nodes[e] = t), S.onNodeTypeRegistered && S.onNodeTypeRegistered(i, t), n && S.onNodeTypeReplaced && S.onNodeTypeReplaced(i, t, n); } /** removes a node type from the system */ - static unregisterNodeType(e) { - let t; - if (typeof e == "string" ? t = S.registered_node_types[e] : t = e, !t) - throw "node type not found: " + e; - delete S.registered_node_types[t.type], t.constructor.name && delete S.Nodes[t.constructor.name]; + static unregisterNodeType(t) { + let e; + if (typeof t == "string" ? e = S.registered_node_types[t] : e = t, !e) + throw "node type not found: " + t; + delete S.registered_node_types[e.type], e.constructor.name && delete S.Nodes[e.constructor.name]; } /** * Save a slot type and his node @@ -79,14 +79,14 @@ const S = class { * @param {String|Object} type name of the node or the node constructor itself * @param {String} slot_type name of the slot type (variable type), eg. string, number, array, boolean, .. */ - static registerNodeAndSlotType(e, t, i = !1) { + static registerNodeAndSlotType(t, e, i = !1) { let n; - if (typeof e == "string" ? n = S.registered_node_types[e] : "type" in e ? n = S.registered_node_types[e.type] : n = e, !n) - throw "Node not registered!" + e; + if (typeof t == "string" ? n = S.registered_node_types[t] : "type" in t ? n = S.registered_node_types[t.type] : n = t, !n) + throw "Node not registered!" + t; var s = n.class.__litegraph_type__; - if (typeof t == "string") - var r = t.split(","); - else if (t == I.EVENT || t == I.ACTION) + if (typeof e == "string") + var r = e.split(","); + else if (e == I.EVENT || e == I.ACTION) var r = ["_event_"]; else var r = ["*"]; @@ -170,28 +170,28 @@ const S = class { * @param name a name to distinguish from other nodes * @param options to set options */ - static createNode(e, t, i = {}) { + static createNode(t, e, i = {}) { let n = null, s; - if (typeof e == "string") - s = e; - else if (s = e.__LITEGRAPH_TYPE__, !s) - throw console.error(e), "Node was not registered yet!"; + if (typeof t == "string") + s = t; + else if (s = t.__LITEGRAPH_TYPE__, !s) + throw console.error(t), "Node was not registered yet!"; if (n = S.registered_node_types[s], !n) return console.warn( - 'GraphNode type "' + e + '" not registered.' + 'GraphNode type "' + t + '" not registered.' ), null; - t = t || n.title || s; + e = e || n.title || s; var r = null; const o = i.constructorArgs || []; if (S.catch_exceptions) try { - r = new n.class(t, ...o); + r = new n.class(e, ...o); } catch (p) { return console.error("Error creating node!", p), null; } else - r = new n.class(t, ...o); - if (r.class = n.class, r.type = s, !r.title && t && (r.title = t), r.properties || (r.properties = {}), r.properties_info || (r.properties_info = []), r.flags || (r.flags = {}), r.size || (r.size = r.computeSize()), r.pos || (r.pos = [S.DEFAULT_POSITION[0], S.DEFAULT_POSITION[1]]), r.mode || (r.mode = Z.ALWAYS), i.instanceProps) + r = new n.class(e, ...o); + if (r.class = n.class, r.type = s, !r.title && e && (r.title = e), r.properties || (r.properties = {}), r.properties_info || (r.properties_info = []), r.flags || (r.flags = {}), r.size || (r.size = r.computeSize()), r.pos || (r.pos = [S.DEFAULT_POSITION[0], S.DEFAULT_POSITION[1]]), r.mode || (r.mode = Z.ALWAYS), i.instanceProps) for (var a in i.instanceProps) r[a] = i.instanceProps[a]; const l = Ce(n.class, "propertyLayout"); @@ -221,8 +221,8 @@ const S = class { * Returns a registered node type with a given name * @param type full name of the node class. p.e. "math/sin" */ - static getNodeType(e) { - return S.registered_node_types[e]; + static getNodeType(t) { + return S.registered_node_types[t]; } /** * Returns a list of node types matching one category @@ -231,11 +231,11 @@ const S = class { * @param {String} filter only nodes with ctor.filter equal can be shown * @return {Array} array with all the node classes */ - static getNodeTypesInCategory(e, t) { + static getNodeTypesInCategory(t, e) { var i = []; for (var n in S.registered_node_types) { var s = S.registered_node_types[n]; - s.filter == t && (e == "" ? s.category == null && i.push(s) : s.category == e && i.push(s)); + s.filter == e && (t == "" ? s.category == null && i.push(s) : s.category == t && i.push(s)); } return S.auto_sort_node_types && i.sort(function(r, o) { return r.title.localeCompare(o.title); @@ -247,30 +247,30 @@ const S = class { * @param {String} filter only nodes with ctor.filter equal can be shown * @return {Array} array with all the names of the categories */ - static getNodeTypesCategories(e) { - var t = { "": 1 }; + static getNodeTypesCategories(t) { + var e = { "": 1 }; for (var i in S.registered_node_types) { var n = S.registered_node_types[i]; if (n.category && !n.hide_in_node_lists) { - if (n.filter != e) + if (n.filter != t) continue; - t[n.category] = 1; + e[n.category] = 1; } } var s = []; - for (var i in t) + for (var i in e) s.push(i); return S.auto_sort_node_types ? s.sort() : s; } /** debug purposes: reloads all the js scripts that matches a wildcard */ - static reloadNodes(e) { - for (var t = document.getElementsByTagName("script"), i = [], n = 0; n < t.length; n++) - i.push(t[n]); + static reloadNodes(t) { + for (var e = document.getElementsByTagName("script"), i = [], n = 0; n < e.length; n++) + i.push(e[n]); var s = document.getElementsByTagName("head")[0]; - e = document.location.href + e; + t = document.location.href + t; for (var n = 0; n < i.length; n++) { var r = i[n].src; - if (!(!r || r.substr(0, e.length) != e)) + if (!(!r || r.substr(0, t.length) != t)) try { S.debug && console.log("Reloading: " + r); var o = document.createElement("script"); @@ -285,15 +285,15 @@ const S = class { } // TODO move //separated just to improve if it doesn't work - static cloneObject(e, t) { - if (e == null) + static cloneObject(t, e) { + if (t == null) return null; - var i = JSON.parse(JSON.stringify(e)); - if (!t) + var i = JSON.parse(JSON.stringify(t)); + if (!e) return i; for (var n in i) - t[n] = i[n]; - return t; + e[n] = i[n]; + return e; } /** * Returns if the types of two slots are compatible (taking into account wildcards, etc) @@ -302,12 +302,12 @@ const S = class { * @param {String} type_b * @return {Boolean} true if they can be connected */ - static isValidConnection(e, t) { - if ((e == "" || e === "*") && (e = I.DEFAULT), (t == "" || t === "*") && (t = I.DEFAULT), !e || !t || e == t || e == I.EVENT && t == I.ACTION || e == I.ACTION && t == I.EVENT) + static isValidConnection(t, e) { + if ((t == "" || t === "*") && (t = I.DEFAULT), (e == "" || e === "*") && (e = I.DEFAULT), !t || !e || t == e || t == I.EVENT && e == I.ACTION || t == I.ACTION && e == I.EVENT) return !0; - if (e = String(e), t = String(t), e = e.toLowerCase(), t = t.toLowerCase(), e.indexOf(",") == -1 && t.indexOf(",") == -1) - return e == t; - for (var i = e.split(","), n = t.split(","), s = 0; s < i.length; ++s) + if (t = String(t), e = String(e), t = t.toLowerCase(), e = e.toLowerCase(), t.indexOf(",") == -1 && e.indexOf(",") == -1) + return t == e; + for (var i = t.split(","), n = e.split(","), s = 0; s < i.length; ++s) for (var r = 0; r < n.length; ++r) if (this.isValidConnection(i[s], n[r])) return !0; @@ -319,51 +319,51 @@ const S = class { // static LLink: typeof LLink; // static LGraph: typeof LGraph; // static DragAndScale: typeof DragAndScale; - static compareObjects(e, t) { - for (var i in e) - if (e[i] != t[i]) + static compareObjects(t, e) { + for (var i in t) + if (t[i] != e[i]) return !1; return !0; } - static distance(e, t) { + static distance(t, e) { return Math.sqrt( - (t[0] - e[0]) * (t[0] - e[0]) + (t[1] - e[1]) * (t[1] - e[1]) + (e[0] - t[0]) * (e[0] - t[0]) + (e[1] - t[1]) * (e[1] - t[1]) ); } - static colorToString(e) { - return "rgba(" + Math.round(e[0] * 255).toFixed() + "," + Math.round(e[1] * 255).toFixed() + "," + Math.round(e[2] * 255).toFixed() + "," + (e.length == 4 ? e[3].toFixed(2) : "1.0") + ")"; + static colorToString(t) { + return "rgba(" + Math.round(t[0] * 255).toFixed() + "," + Math.round(t[1] * 255).toFixed() + "," + Math.round(t[2] * 255).toFixed() + "," + (t.length == 4 ? t[3].toFixed(2) : "1.0") + ")"; } - static isInsideRectangle(e, t, i, n, s, r) { - return i < e && i + s > e && n < t && n + r > t; + static isInsideRectangle(t, e, i, n, s, r) { + return i < t && i + s > t && n < e && n + r > e; } // [minx,miny,maxx,maxy] - static growBounding(e, t, i) { - return t < e[0] ? e[0] = t : t > e[2] && (e[2] = t), i < e[1] ? e[1] = i : i > e[3] && (e[3] = i), e; + static growBounding(t, e, i) { + return e < t[0] ? t[0] = e : e > t[2] && (t[2] = e), i < t[1] ? t[1] = i : i > t[3] && (t[3] = i), t; } - static isInsideBounding(e, t) { - return !(e[0] < t[0][0] || e[1] < t[0][1] || e[0] > t[1][0] || e[1] > t[1][1]); + static isInsideBounding(t, e) { + return !(t[0] < e[0][0] || t[1] < e[0][1] || t[0] > e[1][0] || t[1] > e[1][1]); } // bounding overlap, format: [ startx, starty, width, height ] - static overlapBounding(e, t) { - var i = e[0] + e[2], n = e[1] + e[3], s = t[0] + t[2], r = t[1] + t[3]; - return !(e[0] > s || e[1] > r || i < t[0] || n < t[1]); + static overlapBounding(t, e) { + var i = t[0] + t[2], n = t[1] + t[3], s = e[0] + e[2], r = e[1] + e[3]; + return !(t[0] > s || t[1] > r || i < e[0] || n < e[1]); } // Convert a hex value to its decimal value - the inputted hex must be in the // format of a hex triplet - the kind we use for HTML colours. The function // will return an array with three values. - static hex2num(e) { - e.charAt(0) == "#" && (e = e.slice(1)), e = e.toUpperCase(); - var t = "0123456789ABCDEF"; + static hex2num(t) { + t.charAt(0) == "#" && (t = t.slice(1)), t = t.toUpperCase(); + var e = "0123456789ABCDEF"; let i; for (var n = 0, s, r, o = 0; o < 6; o += 2) - s = t.indexOf(e.charAt(o)), r = t.indexOf(e.charAt(o + 1)), i[n] = s * 16 + r, n++; + s = e.indexOf(t.charAt(o)), r = e.indexOf(t.charAt(o + 1)), i[n] = s * 16 + r, n++; return i; } //Give a array with three values as the argument and the function will return // the corresponding hex triplet. - static num2hex(e) { - for (var t = "0123456789ABCDEF", i = "#", n, s, r = 0; r < 3; r++) - n = e[r] / 16, s = e[r] % 16, i += t.charAt(n) + t.charAt(s); + static num2hex(t) { + for (var e = "0123456789ABCDEF", i = "#", n, s, r = 0; r < 3; r++) + n = t[r] / 16, s = t[r] % 16, i += e.charAt(n) + e.charAt(s); return i; } // ContextMenu: typeof ContextMenu; @@ -371,9 +371,9 @@ const S = class { // static getParameterNames(func: string | Function): string[]; /* helper for interaction: pointer, touch, mouse Listeners used by LGraphCanvas DragAndScale ContextMenu*/ - static pointerListenerAdd(e, t, i, n = !1) { - if (!(!e || !e.addEventListener || !t || typeof i != "function")) { - var s = S.pointerevents_method, r = t; + static pointerListenerAdd(t, e, i, n = !1) { + if (!(!t || !t.addEventListener || !e || typeof i != "function")) { + var s = S.pointerevents_method, r = e; if (s == "pointer" && !window.PointerEvent) switch (console.warn("sMethod=='pointer' && !window.PointerEvent"), console.log("Converting pointer[" + r + "] : down move up cancel enter TO touchstart touchmove touchend, etc .."), r) { case "down": { @@ -406,36 +406,36 @@ const S = class { case "over": case "out": case "enter": - e.addEventListener(s + r, i, n); + t.addEventListener(s + r, i, n); case "leave": case "cancel": case "gotpointercapture": case "lostpointercapture": if (s != "mouse") - return e.addEventListener(s + r, i, n); + return t.addEventListener(s + r, i, n); default: - return e.addEventListener(r, i, n); + return t.addEventListener(r, i, n); } } } - static pointerListenerRemove(e, t, i, n = !1) { - if (!(!e || !e.removeEventListener || !t || typeof i != "function")) - switch (t) { + static pointerListenerRemove(t, e, i, n = !1) { + if (!(!t || !t.removeEventListener || !e || typeof i != "function")) + switch (e) { case "down": case "up": case "move": case "over": case "out": case "enter": - (S.pointerevents_method == "pointer" || S.pointerevents_method == "mouse") && e.removeEventListener(S.pointerevents_method + t, i, n); + (S.pointerevents_method == "pointer" || S.pointerevents_method == "mouse") && t.removeEventListener(S.pointerevents_method + e, i, n); case "leave": case "cancel": case "gotpointercapture": case "lostpointercapture": if (S.pointerevents_method == "pointer") - return e.removeEventListener(S.pointerevents_method + t, i, n); + return t.removeEventListener(S.pointerevents_method + e, i, n); default: - return e.removeEventListener(t, i, n); + return t.removeEventListener(e, i, n); } } }; @@ -512,31 +512,31 @@ u.search_box_refresh_interval_ms = 250; u.graph_inputs_outputs_use_combo_widget = !1; u.serialize_slot_data = !1; class Be { - constructor(t, i = !1) { - this.offset = [0, 0], this.scale = 1, this.max_scale = 10, this.min_scale = 0.1, this.onredraw = null, this.enabled = !0, this.last_mouse = [0, 0], this.element = null, this.visible_area = new Float32Array([0, 0, 0, 0]), this.viewport = null, this.dragging = !1, this._binded_mouse_callback = null, t && (this.element = t, i || this.bindEvents(t)); + constructor(e, i = !1) { + this.offset = [0, 0], this.scale = 1, this.max_scale = 10, this.min_scale = 0.1, this.onredraw = null, this.enabled = !0, this.last_mouse = [0, 0], this.element = null, this.visible_area = new Float32Array([0, 0, 0, 0]), this.viewport = null, this.dragging = !1, this._binded_mouse_callback = null, e && (this.element = e, i || this.bindEvents(e)); } - bindEvents(t) { - this.last_mouse = [0, 0], this._binded_mouse_callback = this.onMouse.bind(this), u.pointerListenerAdd(t, "down", this._binded_mouse_callback), u.pointerListenerAdd(t, "move", this._binded_mouse_callback), u.pointerListenerAdd(t, "up", this._binded_mouse_callback), t.addEventListener( + bindEvents(e) { + this.last_mouse = [0, 0], this._binded_mouse_callback = this.onMouse.bind(this), u.pointerListenerAdd(e, "down", this._binded_mouse_callback), u.pointerListenerAdd(e, "move", this._binded_mouse_callback), u.pointerListenerAdd(e, "up", this._binded_mouse_callback), e.addEventListener( "mousewheel", this._binded_mouse_callback, !1 - ), t.addEventListener("wheel", this._binded_mouse_callback, !1); + ), e.addEventListener("wheel", this._binded_mouse_callback, !1); } - computeVisibleArea(t) { + computeVisibleArea(e) { if (!this.element) { this.visible_area[0] = this.visible_area[1] = this.visible_area[2] = this.visible_area[3] = 0; return; } var i = this.element.width, n = this.element.height, s = -this.offset[0], r = -this.offset[1]; - t && (s += t[0] / this.scale, r += t[1] / this.scale, i = t[2], n = t[3]); + e && (s += e[0] / this.scale, r += e[1] / this.scale, i = e[2], n = e[3]); var o = s + i / this.scale, a = r + n / this.scale; this.visible_area[0] = s, this.visible_area[1] = r, this.visible_area[2] = o - s, this.visible_area[3] = a - r; } - onMouse(t) { + onMouse(e) { if (!this.enabled) return; var i = this.element, n = i.getBoundingClientRect(); - let s = t; + let s = e; var r = s.clientX - n.left, o = s.clientY - n.top; s.canvasX = r, s.canvasX = o, s.dragging = this.dragging; var a = !this.viewport || this.viewport && r >= this.viewport[0] && r < this.viewport[0] + this.viewport[2] && o >= this.viewport[1] && o < this.viewport[1] + this.viewport[3]; @@ -550,23 +550,23 @@ class Be { if (this.last_mouse[0] = r, this.last_mouse[1] = o, a) return s.preventDefault(), s.stopPropagation(), !1; } - toCanvasContext(t) { - t.scale(this.scale, this.scale), t.translate(this.offset[0], this.offset[1]); + toCanvasContext(e) { + e.scale(this.scale, this.scale), e.translate(this.offset[0], this.offset[1]); } - convertOffsetToCanvas(t) { + convertOffsetToCanvas(e) { return [ - (t[0] + this.offset[0]) * this.scale, - (t[1] + this.offset[1]) * this.scale + (e[0] + this.offset[0]) * this.scale, + (e[1] + this.offset[1]) * this.scale ]; } - convertCanvasToOffset(t, i = [0, 0]) { - return i[0] = t[0] / this.scale - this.offset[0], i[1] = t[1] / this.scale - this.offset[1], i; + convertCanvasToOffset(e, i = [0, 0]) { + return i[0] = e[0] / this.scale - this.offset[0], i[1] = e[1] / this.scale - this.offset[1], i; } - mouseDrag(t, i) { - this.offset[0] += t / this.scale, this.offset[1] += i / this.scale, this.onredraw && this.onredraw(this); + mouseDrag(e, i) { + this.offset[0] += e / this.scale, this.offset[1] += i / this.scale, this.onredraw && this.onredraw(this); } - changeScale(t, i) { - if (t < this.min_scale ? t = this.min_scale : t > this.max_scale && (t = this.max_scale), t != this.scale && this.element) { + changeScale(e, i) { + if (e < this.min_scale ? e = this.min_scale : e > this.max_scale && (e = this.max_scale), e != this.scale && this.element) { var n = this.element.getBoundingClientRect(); if (n) { i = i || [ @@ -574,7 +574,7 @@ class Be { n.height * 0.5 ], i[0] -= n.left, i[1] -= n.top; var s = this.convertCanvasToOffset(i); - this.scale = t, Math.abs(this.scale - 1) < 0.01 && (this.scale = 1); + this.scale = e, Math.abs(this.scale - 1) < 0.01 && (this.scale = 1); var r = this.convertCanvasToOffset(i), o = [ r[0] - s[0], r[1] - s[1] @@ -583,18 +583,18 @@ class Be { } } } - changeDeltaScale(t, i) { - this.changeScale(this.scale * t, i); + changeDeltaScale(e, i) { + this.changeScale(this.scale * e, i); } reset() { this.scale = 1, this.offset[0] = 0, this.offset[1] = 0; } } class ge { - processMouseDown(t) { + processMouseDown(e) { if (this.set_canvas_dirty_on_mouse_event && (this.dirty_canvas = !0), !this.graph) return; - let i = t; + let i = e; this.adjustMouseEvent(i); var n = this.getCanvasWindow(); n.document, N.active_canvas = this; @@ -740,8 +740,8 @@ class ge { } } } - processMouseMove(t) { - let i = t; + processMouseMove(e) { + let i = e; if (this.autoresize && this.resize(), this.set_canvas_dirty_on_mouse_event && (this.dirty_canvas = !0), !this.graph) return; N.active_canvas = this, this.adjustMouseEvent(i); @@ -785,7 +785,7 @@ class ge { if (m.mouseOver && l != m) { m.mouseOver = !1, this.node_over && this.node_over.onMouseLeave && this.node_over.onMouseLeave(i, [i.canvasX - this.node_over.pos[0], i.canvasY - this.node_over.pos[1]], this); const E = this.node_over; - this.node_over = null, this.dirty_canvas = !0, E != this.node_over && this.onHoverChange && this.onHoverChange(this.node_over, E); + this.node_over = null, this.dirty_canvas = !0, this.onHoverChange && E != this.node_over && this.onHoverChange(this.node_over, E); } } if (l) { @@ -793,7 +793,7 @@ class ge { if (!l.mouseOver) { l.mouseOver = !0; const m = this.node_over; - this.node_over = l, this.dirty_canvas = !0, m != this.node_over && this.onHoverChange && this.onHoverChange(this.node_over, m), l.onMouseEnter && l.onMouseEnter(i, [i.canvasX - l.pos[0], i.canvasY - l.pos[1]], this); + this.node_over = l, this.dirty_canvas = !0, this.onHoverChange && m != this.node_over && this.onHoverChange(this.node_over, m), l.onMouseEnter && l.onMouseEnter(i, [i.canvasX - l.pos[0], i.canvasY - l.pos[1]], this); } if (l.onMouseMove && l.onMouseMove(i, [i.canvasX - l.pos[0], i.canvasY - l.pos[1]], this), this.connecting_node) { if (this.connecting_output) { @@ -847,8 +847,8 @@ class ge { } return r && !this.selected_group_resizing && !this.selected_group_moving && (this.selected_group = r), i.preventDefault(), !1; } - processMouseUp(t) { - let i = t; + processMouseUp(e) { + let i = e; var n = !(i instanceof PointerEvent) || !i.isPrimary; if (!n) return !1; @@ -937,8 +937,8 @@ class ge { return n && (this.pointer_is_down = !1, this.pointer_is_double = !1), this.graph.change(), i.stopPropagation(), i.preventDefault(), !1; } } - processMouseWheel(t) { - let i = t; + processMouseWheel(e) { + let i = e; if (!(!this.graph || !this.allow_dragcanvas)) { var n = i.wheelDeltaY != null ? i.wheelDeltaY : i.detail * -60; this.adjustMouseEvent(i); @@ -952,53 +952,53 @@ class ge { } const ie = class { /** changes the zoom level of the graph (default is 1), you can pass also a place used to pivot the zoom */ - setZoom(e, t) { - this.ds.changeScale(e, t), this.maxZoom && this.ds.scale > this.maxZoom ? this.scale = this.maxZoom : this.minZoom && this.ds.scale < this.minZoom && (this.scale = this.minZoom); + setZoom(t, e) { + this.ds.changeScale(t, e), this.maxZoom && this.ds.scale > this.maxZoom ? this.scale = this.maxZoom : this.minZoom && this.ds.scale < this.minZoom && (this.scale = this.minZoom); } /** brings a node to front (above all other nodes) */ - bringToFront(e) { - var t = this.graph._nodes.indexOf(e); - t != -1 && (this.graph._nodes.splice(t, 1), this.graph._nodes.push(e)); + bringToFront(t) { + var e = this.graph._nodes.indexOf(t); + e != -1 && (this.graph._nodes.splice(e, 1), this.graph._nodes.push(t)); } /** sends a node to the back (below all other nodes) */ - sendToBack(e) { - var t = this.graph._nodes.indexOf(e); - t != -1 && (this.graph._nodes.splice(t, 1), this.graph._nodes.unshift(e)); + sendToBack(t) { + var e = this.graph._nodes.indexOf(t); + e != -1 && (this.graph._nodes.splice(e, 1), this.graph._nodes.unshift(t)); } /** checks which nodes are visible (inside the camera area) */ - computeVisibleNodes(e, t = []) { - var i = t; - i.length = 0, e = e || this.graph._nodes; - for (var n = 0, s = e.length; n < s; ++n) { - var r = e[n]; + computeVisibleNodes(t, e = []) { + var i = e; + i.length = 0, t = t || this.graph._nodes; + for (var n = 0, s = t.length; n < s; ++n) { + var r = t[n]; this.live_mode && !r.onDrawBackground && !r.onDrawForeground || u.overlapBounding(this.visible_area, r.getBounding(ie.temp)) && i.push(r); } return i; } /** renders the whole canvas content, by rendering in two separated canvas, one containing the background grid and the connections, and one containing the nodes) */ - draw(e = !1, t = !1) { + draw(t = !1, e = !1) { if (!(!this.canvas || this.canvas.width == 0 || this.canvas.height == 0)) { var i = u.getTime(); - this.render_time = (i - this.last_draw_time) * 1e-3, this.last_draw_time = i, this.graph && this.ds.computeVisibleArea(this.viewport), (this.dirty_bgcanvas || t || this.always_render_background || this.graph && this.graph._last_trigger_time && i - this.graph._last_trigger_time < 1e3) && this.drawBackCanvas(), (this.dirty_canvas || e) && this.drawFrontCanvas(), this.fps = this.render_time ? 1 / this.render_time : 0, this.frame += 1; + this.render_time = (i - this.last_draw_time) * 1e-3, this.last_draw_time = i, this.graph && this.ds.computeVisibleArea(this.viewport), (this.dirty_bgcanvas || e || this.always_render_background || this.graph && this.graph._last_trigger_time && i - this.graph._last_trigger_time < 1e3) && this.drawBackCanvas(), (this.dirty_canvas || t) && this.drawFrontCanvas(), this.fps = this.render_time ? 1 / this.render_time : 0, this.frame += 1; } } /** draws the front canvas (the one containing all the nodes) */ drawFrontCanvas() { this.dirty_canvas = !1, this.ctx || (this.ctx = this.canvas.getContext("2d")); - var e = this.ctx; - if (e) { - var t = this.canvas, i = this.viewport || this.dirty_area; - if (i && (e.save(), e.beginPath(), e.rect(i[0], i[1], i[2], i[3]), e.clip()), this.clear_background && (i ? e.clearRect(i[0], i[1], i[2], i[3]) : e.clearRect(0, 0, t.width, t.height)), this.bgcanvas == this.canvas ? this.drawBackCanvas() : e.drawImage(this.bgcanvas, 0, 0), this.onRender && this.onRender(t, e), this.show_info && this.renderInfo(e, i ? i[0] : 0, i ? i[1] : 0), this.graph) { - e.save(), this.ds.toCanvasContext(e); + var t = this.ctx; + if (t) { + var e = this.canvas, i = this.viewport || this.dirty_area; + if (i && (t.save(), t.beginPath(), t.rect(i[0], i[1], i[2], i[3]), t.clip()), this.clear_background && (i ? t.clearRect(i[0], i[1], i[2], i[3]) : t.clearRect(0, 0, e.width, e.height)), this.bgcanvas == this.canvas ? this.drawBackCanvas() : t.drawImage(this.bgcanvas, 0, 0), this.onRender && this.onRender(e, t), this.show_info && this.renderInfo(t, i ? i[0] : 0, i ? i[1] : 0), this.graph) { + t.save(), this.ds.toCanvasContext(t); for (var n = this.computeVisibleNodes( null, this.visible_nodes ), s = 0; s < n.length; ++s) { var r = n[s]; - e.save(), e.translate(r.pos[0], r.pos[1]), this.drawNode(r, e), e.restore(); + t.save(), t.translate(r.pos[0], r.pos[1]), this.drawNode(r, t), t.restore(); } - if (this.render_execution_order && this.drawExecutionOrder(e), this.graph.config.links_ontop && (this.live_mode || this.drawConnections(e)), this.connecting_pos != null) { - e.lineWidth = this.connections_width; + if (this.render_execution_order && this.drawExecutionOrder(t), this.graph.config.links_ontop && (this.live_mode || this.drawConnections(t)), this.connecting_pos != null) { + t.lineWidth = this.connections_width; var o = null, a = this.connecting_output || this.connecting_input, l = a.type, h = a.dir; h == null && (this.connecting_output ? h = this.connecting_node.horizontal ? w.DOWN : w.RIGHT : h = this.connecting_node.horizontal ? w.UP : w.LEFT); var p = a.shape; @@ -1010,7 +1010,7 @@ const ie = class { o = u.CONNECTING_LINK_COLOR; } if (this.renderLink( - e, + t, this.connecting_pos, [this.graph_mouse[0], this.graph_mouse[1]], null, @@ -1019,85 +1019,85 @@ const ie = class { o, h, w.CENTER - ), e.beginPath(), p === k.BOX_SHAPE ? (e.rect( + ), t.beginPath(), p === k.BOX_SHAPE ? (t.rect( this.connecting_pos[0] - 6 + 0.5, this.connecting_pos[1] - 5 + 0.5, 14, 10 - ), e.fill(), e.beginPath(), e.rect( + ), t.fill(), t.beginPath(), t.rect( this.graph_mouse[0] - 6 + 0.5, this.graph_mouse[1] - 5 + 0.5, 14, 10 - )) : p === k.ARROW_SHAPE ? (e.moveTo(this.connecting_pos[0] + 8, this.connecting_pos[1] + 0.5), e.lineTo(this.connecting_pos[0] - 4, this.connecting_pos[1] + 6 + 0.5), e.lineTo(this.connecting_pos[0] - 4, this.connecting_pos[1] - 6 + 0.5), e.closePath()) : (e.arc( + )) : p === k.ARROW_SHAPE ? (t.moveTo(this.connecting_pos[0] + 8, this.connecting_pos[1] + 0.5), t.lineTo(this.connecting_pos[0] - 4, this.connecting_pos[1] + 6 + 0.5), t.lineTo(this.connecting_pos[0] - 4, this.connecting_pos[1] - 6 + 0.5), t.closePath()) : (t.arc( this.connecting_pos[0], this.connecting_pos[1], 4, 0, Math.PI * 2 - ), e.fill(), e.beginPath(), e.arc( + ), t.fill(), t.beginPath(), t.arc( this.graph_mouse[0], this.graph_mouse[1], 4, 0, Math.PI * 2 - )), e.fill(), e.fillStyle = "#ffcc00", this._highlight_input) { - e.beginPath(); + )), t.fill(), t.fillStyle = "#ffcc00", this._highlight_input) { + t.beginPath(); var f = this._highlight_input_slot.shape; - f === k.ARROW_SHAPE ? (e.moveTo(this._highlight_input[0] + 8, this._highlight_input[1] + 0.5), e.lineTo(this._highlight_input[0] - 4, this._highlight_input[1] + 6 + 0.5), e.lineTo(this._highlight_input[0] - 4, this._highlight_input[1] - 6 + 0.5), e.closePath()) : e.arc( + f === k.ARROW_SHAPE ? (t.moveTo(this._highlight_input[0] + 8, this._highlight_input[1] + 0.5), t.lineTo(this._highlight_input[0] - 4, this._highlight_input[1] + 6 + 0.5), t.lineTo(this._highlight_input[0] - 4, this._highlight_input[1] - 6 + 0.5), t.closePath()) : t.arc( this._highlight_input[0], this._highlight_input[1], 6, 0, Math.PI * 2 - ), e.fill(); + ), t.fill(); } - this._highlight_output && (e.beginPath(), f === k.ARROW_SHAPE ? (e.moveTo(this._highlight_output[0] + 8, this._highlight_output[1] + 0.5), e.lineTo(this._highlight_output[0] - 4, this._highlight_output[1] + 6 + 0.5), e.lineTo(this._highlight_output[0] - 4, this._highlight_output[1] - 6 + 0.5), e.closePath()) : e.arc( + this._highlight_output && (t.beginPath(), f === k.ARROW_SHAPE ? (t.moveTo(this._highlight_output[0] + 8, this._highlight_output[1] + 0.5), t.lineTo(this._highlight_output[0] - 4, this._highlight_output[1] + 6 + 0.5), t.lineTo(this._highlight_output[0] - 4, this._highlight_output[1] - 6 + 0.5), t.closePath()) : t.arc( this._highlight_output[0], this._highlight_output[1], 6, 0, Math.PI * 2 - ), e.fill()); + ), t.fill()); } - this.dragging_rectangle && (e.strokeStyle = "#FFF", e.strokeRect( + this.dragging_rectangle && (t.strokeStyle = "#FFF", t.strokeRect( this.dragging_rectangle[0], this.dragging_rectangle[1], this.dragging_rectangle[2], this.dragging_rectangle[3] - )), this.over_link_center && this.render_link_tooltip ? this.drawLinkTooltip(e, this.over_link_center) : this.onDrawLinkTooltip && this.onDrawLinkTooltip(e, null, this), this.onDrawForeground && this.onDrawForeground(e, this.visible_area), e.restore(); + )), this.over_link_center && this.render_link_tooltip ? this.drawLinkTooltip(t, this.over_link_center) : this.onDrawLinkTooltip && this.onDrawLinkTooltip(t, null, this), this.onDrawForeground && this.onDrawForeground(t, this.visible_area), t.restore(); } - this._graph_stack && this._graph_stack.length && this.render_subgraph_panels && this.drawSubgraphPanel(e), this.onDrawOverlay && this.onDrawOverlay(e), i && e.restore(); + this._graph_stack && this._graph_stack.length && this.render_subgraph_panels && this.drawSubgraphPanel(t), this.onDrawOverlay && this.onDrawOverlay(t), i && t.restore(); } } /** * draws the panel in the corner that shows subgraph properties * @method drawSubgraphPanel **/ - drawSubgraphPanel(e) { - var t = this.graph, i = t._subgraph_node; + drawSubgraphPanel(t) { + var e = this.graph, i = e._subgraph_node; if (!i) { console.warn("subgraph without subnode"); return; } - this.drawSubgraphPanelLeft(t, i, e), this.drawSubgraphPanelRight(t, i, e); + this.drawSubgraphPanelLeft(e, i, t), this.drawSubgraphPanelRight(e, i, t); } - drawSubgraphPanelLeft(e, t, i) { - var n = t.inputs ? t.inputs.length : 0, s = 200, r = Math.floor(u.NODE_SLOT_HEIGHT * 1.6); + drawSubgraphPanelLeft(t, e, i) { + var n = e.inputs ? e.inputs.length : 0, s = 200, r = Math.floor(u.NODE_SLOT_HEIGHT * 1.6); if (i.fillStyle = "#111", i.globalAlpha = 0.8, i.beginPath(), i.roundRect(10, 10, s, (n + 1) * r + 50, [8]), i.fill(), i.globalAlpha = 1, i.fillStyle = "#888", i.font = "14px Arial", i.textAlign = "left", i.fillText("Graph Inputs", 20, 34), this.drawButton(s - 20, 20, 20, 20, "X", "#151515", void 0, void 0, !0)) { this.closeSubgraph(); return; } var o = 50; - if (i.font = "14px Arial", t.inputs) - for (var a = 0; a < t.inputs.length; ++a) { - var l = t.inputs[a]; + if (i.font = "14px Arial", e.inputs) + for (var a = 0; a < e.inputs.length; ++a) { + var l = e.inputs[a]; l.not_subgraph_input || (i.fillStyle = "#9C9", i.beginPath(), i.arc(s - 16, o, 5, 0, 2 * Math.PI), i.fill(), i.fillStyle = "#AAA", i.fillText(l.name, 30, o + r * 0.75), i.fillStyle = "#777", i.fillText(J(l.type), 130, o + r * 0.75), o += r); } - this.drawButton(20, o + 2, s - 20, r - 2, "+", "#151515", "#222") && this.showSubgraphPropertiesDialog(t); + this.drawButton(20, o + 2, s - 20, r - 2, "+", "#151515", "#222") && this.showSubgraphPropertiesDialog(e); } - drawSubgraphPanelRight(e, t, i) { - var n = t.outputs ? t.outputs.length : 0, s = this.bgcanvas.width, r = 200, o = Math.floor(u.NODE_SLOT_HEIGHT * 1.6); + drawSubgraphPanelRight(t, e, i) { + var n = e.outputs ? e.outputs.length : 0, s = this.bgcanvas.width, r = 200, o = Math.floor(u.NODE_SLOT_HEIGHT * 1.6); i.fillStyle = "#111", i.globalAlpha = 0.8, i.beginPath(), i.roundRect(s - r - 10, 10, r, (n + 1) * o + 50, [8]), i.fill(), i.globalAlpha = 1, i.fillStyle = "#888", i.font = "14px Arial", i.textAlign = "left"; var a = "Graph Outputs", l = i.measureText(a).width; if (i.fillText(a, s - l - 20, 34), this.drawButton(s - r, 20, 20, 20, "X", "#151515", void 0, void 0, !0)) { @@ -1105,287 +1105,287 @@ const ie = class { return; } var h = 50; - if (i.font = "14px Arial", t.outputs) - for (var p = 0; p < t.outputs.length; ++p) { - var f = t.outputs[p]; + if (i.font = "14px Arial", e.outputs) + for (var p = 0; p < e.outputs.length; ++p) { + var f = e.outputs[p]; f.not_subgraph_output || (i.fillStyle = "#9C9", i.beginPath(), i.arc(s - r + 16, h, 5, 0, 2 * Math.PI), i.fill(), i.fillStyle = "#AAA", i.fillText(f.name, s - r + 30, h + o * 0.75), i.fillStyle = "#777", i.fillText(J(f.type), s - r + 130, h + o * 0.75), h += o); } - this.drawButton(s - r, h + 2, r - 20, o - 2, "+", "#151515", "#222") && this.showSubgraphPropertiesDialogRight(t); + this.drawButton(s - r, h + 2, r - 20, o - 2, "+", "#151515", "#222") && this.showSubgraphPropertiesDialogRight(e); } //Draws a button into the canvas overlay and computes if it was clicked using the immediate gui paradigm - drawButton(e, t, i, n, s, r = u.NODE_DEFAULT_COLOR, o = "#555", a = u.NODE_TEXT_COLOR, l = !1) { + drawButton(t, e, i, n, s, r = u.NODE_DEFAULT_COLOR, o = "#555", a = u.NODE_TEXT_COLOR, l = !1) { const h = !this.block_click && (l || this.allow_interaction && !this.read_only); - var p = this.ctx, f = this.offset_mouse, c = h && u.isInsideRectangle(f[0], f[1], e, t, i, n); + var p = this.ctx, f = this.offset_mouse, c = h && u.isInsideRectangle(f[0], f[1], t, e, i, n); f = this.last_click_position_offset; - var v = h && f && this.pointer_is_down && u.isInsideRectangle(f[0], f[1], e, t, i, n); - p.fillStyle = c ? o : r, v && (p.fillStyle = "#AAA"), p.beginPath(), p.roundRect(e, t, i, n, [4]), p.fill(), s != null && s.constructor == String && (p.fillStyle = a, p.textAlign = "center", p.font = (n * 0.65 | 0) + "px Arial", p.fillText(s, e + i * 0.5, t + n * 0.75), p.textAlign = "left"); + var v = h && f && this.pointer_is_down && u.isInsideRectangle(f[0], f[1], t, e, i, n); + p.fillStyle = c ? o : r, v && (p.fillStyle = "#AAA"), p.beginPath(), p.roundRect(t, e, i, n, [4]), p.fill(), s != null && s.constructor == String && (p.fillStyle = a, p.textAlign = "center", p.font = (n * 0.65 | 0) + "px Arial", p.fillText(s, t + i * 0.5, e + n * 0.75), p.textAlign = "left"); var g = v && h; return v && this.blockClick(), g; } /** draws every group area in the background */ - drawGroups(e, t) { + drawGroups(t, e) { if (this.graph) { var i = this.graph._groups; - t.save(), t.globalAlpha = 0.5 * this.editor_alpha; + e.save(), e.globalAlpha = 0.5 * this.editor_alpha; for (var n = 0; n < i.length; ++n) { var s = i[n]; if (u.overlapBounding(this.visible_area, s._bounding)) { - t.fillStyle = s.color || "#335", t.strokeStyle = s.color || "#335"; + e.fillStyle = s.color || "#335", e.strokeStyle = s.color || "#335"; var r = s._pos, o = s._size; - t.globalAlpha = 0.25 * this.editor_alpha, t.beginPath(), t.rect(r[0] + 0.5, r[1] + 0.5, o[0], o[1]), t.fill(), t.globalAlpha = this.editor_alpha, t.stroke(), t.beginPath(), t.moveTo(r[0] + o[0], r[1] + o[1]), t.lineTo(r[0] + o[0] - 10, r[1] + o[1]), t.lineTo(r[0] + o[0], r[1] + o[1] - 10), t.fill(); + e.globalAlpha = 0.25 * this.editor_alpha, e.beginPath(), e.rect(r[0] + 0.5, r[1] + 0.5, o[0], o[1]), e.fill(), e.globalAlpha = this.editor_alpha, e.stroke(), e.beginPath(), e.moveTo(r[0] + o[0], r[1] + o[1]), e.lineTo(r[0] + o[0] - 10, r[1] + o[1]), e.lineTo(r[0] + o[0], r[1] + o[1] - 10), e.fill(); var a = s.font_size || u.DEFAULT_GROUP_FONT_SIZE; - t.font = a + "px Arial", t.textAlign = "left", t.fillText(s.title, r[0] + 4, r[1] + a); + e.font = a + "px Arial", e.textAlign = "left", e.fillText(s.title, r[0] + 4, r[1] + a); } } - t.restore(); + e.restore(); } } /** draws some useful stats in the corner of the canvas */ - renderInfo(e, t = 10, i) { - i = i || this.canvas.height - 80, e.save(), e.translate(t, i), e.font = "10px Arial", e.fillStyle = "#888", e.textAlign = "left", this.graph ? (e.fillText("T: " + this.graph.globaltime.toFixed(2) + "s", 5, 13 * 1), e.fillText("I: " + this.graph.iteration, 5, 13 * 2), e.fillText("N: " + this.graph._nodes.length + " [" + this.visible_nodes.length + "]", 5, 13 * 3), e.fillText("V: " + this.graph._version, 5, 13 * 4), e.fillText("FPS:" + this.fps.toFixed(2), 5, 13 * 5)) : e.fillText("No graph selected", 5, 13 * 1), e.restore(); + renderInfo(t, e = 10, i) { + i = i || this.canvas.height - 80, t.save(), t.translate(e, i), t.font = "10px Arial", t.fillStyle = "#888", t.textAlign = "left", this.graph ? (t.fillText("T: " + this.graph.globaltime.toFixed(2) + "s", 5, 13 * 1), t.fillText("I: " + this.graph.iteration, 5, 13 * 2), t.fillText("N: " + this.graph._nodes.length + " [" + this.visible_nodes.length + "]", 5, 13 * 3), t.fillText("V: " + this.graph._version, 5, 13 * 4), t.fillText("FPS:" + this.fps.toFixed(2), 5, 13 * 5)) : t.fillText("No graph selected", 5, 13 * 1), t.restore(); } /** draws the back canvas (the one containing the background and the connections) */ drawBackCanvas() { - var e = this.bgcanvas; - (e.width != this.canvas.width || e.height != this.canvas.height) && (e.width = this.canvas.width, e.height = this.canvas.height), this.bgctx || (this.bgctx = this.bgcanvas.getContext("2d")); - var t = this.bgctx; - let i = this.viewport || [0, 0, t.canvas.width, t.canvas.height]; - if (this.clear_background && t.clearRect(i[0], i[1], i[2], i[3]), this._graph_stack && this._graph_stack.length && this.render_subgraph_stack_header) { - t.save(); + var t = this.bgcanvas; + (t.width != this.canvas.width || t.height != this.canvas.height) && (t.width = this.canvas.width, t.height = this.canvas.height), this.bgctx || (this.bgctx = this.bgcanvas.getContext("2d")); + var e = this.bgctx; + let i = this.viewport || [0, 0, e.canvas.width, e.canvas.height]; + if (this.clear_background && e.clearRect(i[0], i[1], i[2], i[3]), this._graph_stack && this._graph_stack.length && this.render_subgraph_stack_header) { + e.save(); const o = this._graph_stack[this._graph_stack.length - 1].graph, a = this.graph._subgraph_node; - t.strokeStyle = a.bgcolor, t.lineWidth = 10, t.strokeRect(1, 1, e.width - 2, e.height - 2), t.lineWidth = 1, t.font = "40px Arial", t.textAlign = "center", t.fillStyle = a.bgcolor || "#AAA"; + e.strokeStyle = a.bgcolor, e.lineWidth = 10, e.strokeRect(1, 1, t.width - 2, t.height - 2), e.lineWidth = 1, e.font = "40px Arial", e.textAlign = "center", e.fillStyle = a.bgcolor || "#AAA"; let l = ""; for (let h = 1; h < this._graph_stack.length; ++h) l += o._subgraph_node.getTitle() + " >> "; - t.fillText( + e.fillText( l + a.getTitle(), - e.width * 0.5, + t.width * 0.5, 40 - ), t.restore(); + ), e.restore(); } let n = !1; - if (this.onRenderBackground && this.onRenderBackground(e, t) && (n = !0), this.viewport || (t.restore(), t.setTransform(1, 0, 0, 1, 0, 0)), this.visible_links.length = 0, this.graph) { - if (t.save(), this.ds.toCanvasContext(t), this.ds.scale < 1.5 && !n && this.clear_background_color && (t.fillStyle = this.clear_background_color, t.fillRect( + if (this.onRenderBackground && this.onRenderBackground(t, e) && (n = !0), this.viewport || (e.restore(), e.setTransform(1, 0, 0, 1, 0, 0)), this.visible_links.length = 0, this.graph) { + if (e.save(), this.ds.toCanvasContext(e), this.ds.scale < 1.5 && !n && this.clear_background_color && (e.fillStyle = this.clear_background_color, e.fillRect( this.visible_area[0], this.visible_area[1], this.visible_area[2], this.visible_area[3] )), this.background_image && this.ds.scale > 0.5 && !n) { - this.zoom_modify_alpha ? t.globalAlpha = (1 - 0.5 / this.ds.scale) * this.editor_alpha : t.globalAlpha = this.editor_alpha, t.imageSmoothingEnabled = t.imageSmoothingEnabled = !1, (!this._bg_img || this._bg_img.name != this.background_image) && (this._bg_img = new Image(), this._bg_img.name = this.background_image, this._bg_img.src = this.background_image, this._bg_img.onload = () => { + this.zoom_modify_alpha ? e.globalAlpha = (1 - 0.5 / this.ds.scale) * this.editor_alpha : e.globalAlpha = this.editor_alpha, e.imageSmoothingEnabled = e.imageSmoothingEnabled = !1, (!this._bg_img || this._bg_img.name != this.background_image) && (this._bg_img = new Image(), this._bg_img.name = this.background_image, this._bg_img.src = this.background_image, this._bg_img.onload = () => { this.draw(!0, !0); }); var s = null; - this._pattern == null && this._bg_img.width > 0 ? (s = t.createPattern(this._bg_img, "repeat"), this._pattern_img = this._bg_img, this._pattern = s) : s = this._pattern, s && (t.fillStyle = s, t.fillRect( + this._pattern == null && this._bg_img.width > 0 ? (s = e.createPattern(this._bg_img, "repeat"), this._pattern_img = this._bg_img, this._pattern = s) : s = this._pattern, s && (e.fillStyle = s, e.fillRect( this.visible_area[0], this.visible_area[1], this.visible_area[2], this.visible_area[3] - ), t.fillStyle = "transparent"), t.globalAlpha = 1, t.imageSmoothingEnabled = t.imageSmoothingEnabled = !0; + ), e.fillStyle = "transparent"), e.globalAlpha = 1, e.imageSmoothingEnabled = e.imageSmoothingEnabled = !0; } - this.graph._groups.length && !this.live_mode && this.drawGroups(e, t), this.onDrawBackground && this.onDrawBackground(t, this.visible_area), u.debug && (t.fillStyle = "red", t.fillRect(this.visible_area[0] + 10, this.visible_area[1] + 10, this.visible_area[2] - 20, this.visible_area[3] - 20)), this.render_canvas_border && (t.strokeStyle = "#235", t.strokeRect(0, 0, e.width, e.height)), this.render_connections_shadows ? (t.shadowColor = "#000", t.shadowOffsetX = 0, t.shadowOffsetY = 0, t.shadowBlur = 6) : t.shadowColor = "rgba(0,0,0,0)", !this.live_mode && this.render_connections && this.drawConnections(t), t.shadowColor = "rgba(0,0,0,0)", t.restore(); + this.graph._groups.length && !this.live_mode && this.drawGroups(t, e), this.onDrawBackground && this.onDrawBackground(e, this.visible_area), u.debug && (e.fillStyle = "red", e.fillRect(this.visible_area[0] + 10, this.visible_area[1] + 10, this.visible_area[2] - 20, this.visible_area[3] - 20)), this.render_canvas_border && (e.strokeStyle = "#235", e.strokeRect(0, 0, t.width, t.height)), this.render_connections_shadows ? (e.shadowColor = "#000", e.shadowOffsetX = 0, e.shadowOffsetY = 0, e.shadowBlur = 6) : e.shadowColor = "rgba(0,0,0,0)", !this.live_mode && this.render_connections && this.drawConnections(e), e.shadowColor = "rgba(0,0,0,0)", e.restore(); } this.dirty_bgcanvas = !1, this.dirty_canvas = !0; } /** draws the given node inside the canvas */ - drawNode(e, t) { - this.current_node = e; - var i = e.color || e.constructor.color || u.NODE_DEFAULT_COLOR, n = e.bgcolor || e.constructor.bgcolor || u.NODE_DEFAULT_BGCOLOR; - e.mouseOver; + drawNode(t, e) { + this.current_node = t; + var i = t.color || t.constructor.color || u.NODE_DEFAULT_COLOR, n = t.bgcolor || t.constructor.bgcolor || u.NODE_DEFAULT_BGCOLOR; + t.mouseOver; var s = this.ds.scale < 0.6; if (this.live_mode) { - e.flags.collapsed || (t.shadowColor = "transparent", e.onDrawForeground && e.onDrawForeground(t, this, this.canvas)); + t.flags.collapsed || (e.shadowColor = "transparent", t.onDrawForeground && t.onDrawForeground(e, this, this.canvas)); return; } var r = this.editor_alpha; - if (t.globalAlpha = r, this.render_shadows && !s ? (t.shadowColor = u.DEFAULT_SHADOW_COLOR, t.shadowOffsetX = 2 * this.ds.scale, t.shadowOffsetY = 2 * this.ds.scale, t.shadowBlur = 3 * this.ds.scale) : t.shadowColor = "transparent", !(e.flags.collapsed && e.onDrawCollapsed && e.onDrawCollapsed(t, this) == !0)) { - var o = e.shape || k.BOX_SHAPE, a = ie.temp_vec2; - ie.temp_vec2.set(e.size); - var l = e.horizontal; - if (e.flags.collapsed) { - t.font = this.inner_text_font; - var h = e.getTitle ? e.getTitle() : e.title; - h != null && (e._collapsed_width = Math.min( - e.size[0], - t.measureText(h).width + u.NODE_TITLE_HEIGHT * 2 - ), a[0] = e._collapsed_width, a[1] = 0); + if (e.globalAlpha = r, this.render_shadows && !s ? (e.shadowColor = u.DEFAULT_SHADOW_COLOR, e.shadowOffsetX = 2 * this.ds.scale, e.shadowOffsetY = 2 * this.ds.scale, e.shadowBlur = 3 * this.ds.scale) : e.shadowColor = "transparent", !(t.flags.collapsed && t.onDrawCollapsed && t.onDrawCollapsed(e, this) == !0)) { + var o = t.shape || k.BOX_SHAPE, a = ie.temp_vec2; + ie.temp_vec2.set(t.size); + var l = t.horizontal; + if (t.flags.collapsed) { + e.font = this.inner_text_font; + var h = t.getTitle ? t.getTitle() : t.title; + h != null && (t._collapsed_width = Math.min( + t.size[0], + e.measureText(h).width + u.NODE_TITLE_HEIGHT * 2 + ), a[0] = t._collapsed_width, a[1] = 0); } - e.clip_area && (t.save(), t.beginPath(), o == k.BOX_SHAPE ? t.rect(0, 0, a[0], a[1]) : o == k.ROUND_SHAPE ? t.roundRect(0, 0, a[0], a[1], [10]) : o == k.CIRCLE_SHAPE && t.arc( + t.clip_area && (e.save(), e.beginPath(), o == k.BOX_SHAPE ? e.rect(0, 0, a[0], a[1]) : o == k.ROUND_SHAPE ? e.roundRect(0, 0, a[0], a[1], [10]) : o == k.CIRCLE_SHAPE && e.arc( a[0] * 0.5, a[1] * 0.5, a[0] * 0.5, 0, Math.PI * 2 - ), t.clip()), e.has_errors && (n = "red"), this.drawNodeShape( - e, + ), e.clip()), t.has_errors && (n = "red"), this.drawNodeShape( t, + e, [a[0], a[1]], i, n, - e.is_selected, - e.mouseOver - ), t.shadowColor = "transparent", e.onDrawForeground && e.onDrawForeground(t, this, this.canvas), t.textAlign = l ? "center" : "left", t.font = this.inner_text_font; + t.is_selected, + t.mouseOver + ), e.shadowColor = "transparent", t.onDrawForeground && t.onDrawForeground(e, this, this.canvas), e.textAlign = l ? "center" : "left", e.font = this.inner_text_font; var p = !s, f = this.connecting_output, c = this.connecting_input; - t.lineWidth = 1; + e.lineWidth = 1; var v = 0, g = [0, 0]; - if (e.flags.collapsed) { + if (t.flags.collapsed) { if (this.render_collapsed_slots) { var A = null, M = null; - if (e.inputs) - for (let G = 0; G < e.inputs.length; G++) { - let z = e.inputs[G]; + if (t.inputs) + for (let G = 0; G < t.inputs.length; G++) { + let z = t.inputs[G]; if (z.link != null) { A = z; break; } } - if (e.outputs) - for (let G = 0; G < e.outputs.length; G++) { - let z = e.outputs[G]; + if (t.outputs) + for (let G = 0; G < t.outputs.length; G++) { + let z = t.outputs[G]; !z.links || !z.links.length || (M = z); } if (A) { var L = 0, B = u.NODE_TITLE_HEIGHT * -0.5; - l && (L = e._collapsed_width * 0.5, B = -u.NODE_TITLE_HEIGHT), t.fillStyle = "#686", t.beginPath(), A.shape === k.BOX_SHAPE ? t.rect(L - 7 + 0.5, B - 4, 14, 8) : A.shape === k.ARROW_SHAPE ? (t.moveTo(L + 8, B), t.lineTo(L + -4, B - 4), t.lineTo(L + -4, B + 4), t.closePath()) : t.arc(L, B, 4, 0, Math.PI * 2), t.fill(); + l && (L = t._collapsed_width * 0.5, B = -u.NODE_TITLE_HEIGHT), e.fillStyle = "#686", e.beginPath(), A.shape === k.BOX_SHAPE ? e.rect(L - 7 + 0.5, B - 4, 14, 8) : A.shape === k.ARROW_SHAPE ? (e.moveTo(L + 8, B), e.lineTo(L + -4, B - 4), e.lineTo(L + -4, B + 4), e.closePath()) : e.arc(L, B, 4, 0, Math.PI * 2), e.fill(); } if (M) { - var L = e._collapsed_width, B = u.NODE_TITLE_HEIGHT * -0.5; - l && (L = e._collapsed_width * 0.5, B = 0), t.fillStyle = "#686", t.strokeStyle = "black", t.beginPath(), M.shape === k.BOX_SHAPE ? t.rect(L - 7 + 0.5, B - 4, 14, 8) : M.shape === k.ARROW_SHAPE ? (t.moveTo(L + 6, B), t.lineTo(L - 6, B - 4), t.lineTo(L - 6, B + 4), t.closePath()) : t.arc(L, B, 4, 0, Math.PI * 2), t.fill(); + var L = t._collapsed_width, B = u.NODE_TITLE_HEIGHT * -0.5; + l && (L = t._collapsed_width * 0.5, B = 0), e.fillStyle = "#686", e.strokeStyle = "black", e.beginPath(), M.shape === k.BOX_SHAPE ? e.rect(L - 7 + 0.5, B - 4, 14, 8) : M.shape === k.ARROW_SHAPE ? (e.moveTo(L + 6, B), e.lineTo(L - 6, B - 4), e.lineTo(L - 6, B + 4), e.closePath()) : e.arc(L, B, 4, 0, Math.PI * 2), e.fill(); } } } else { - if (e.inputs) - for (var d = 0; d < e.inputs.length; d++) { - var _ = e.inputs[d], y = _.type, b = _.shape; - t.globalAlpha = r, this.connecting_output && !u.isValidConnection(_.type, f.type) ? t.globalAlpha = 0.4 * r : t.globalAlpha = r, t.fillStyle = _.link != null ? _.color_on || N.DEFAULT_CONNECTION_COLORS_BY_TYPE[y] || N.DEFAULT_CONNECTION_COLORS.input_on : _.color_off || N.DEFAULT_CONNECTION_COLORS_BY_TYPE_OFF[y] || N.DEFAULT_CONNECTION_COLORS_BY_TYPE[y] || N.DEFAULT_CONNECTION_COLORS.input_off; - var m = e.getConnectionPos(!0, d, [g[0], g[1]]); - m[0] -= e.pos[0], m[1] -= e.pos[1], v < m[1] + u.NODE_SLOT_HEIGHT * 0.5 && (v = m[1] + u.NODE_SLOT_HEIGHT * 0.5), t.beginPath(); + if (t.inputs) + for (var d = 0; d < t.inputs.length; d++) { + var _ = t.inputs[d], y = _.type, b = _.shape; + e.globalAlpha = r, this.connecting_output && !u.isValidConnection(_.type, f.type) ? e.globalAlpha = 0.4 * r : e.globalAlpha = r, e.fillStyle = _.link != null ? _.color_on || N.DEFAULT_CONNECTION_COLORS_BY_TYPE[y] || N.DEFAULT_CONNECTION_COLORS.input_on : _.color_off || N.DEFAULT_CONNECTION_COLORS_BY_TYPE_OFF[y] || N.DEFAULT_CONNECTION_COLORS_BY_TYPE[y] || N.DEFAULT_CONNECTION_COLORS.input_off; + var m = t.getConnectionPos(!0, d, [g[0], g[1]]); + m[0] -= t.pos[0], m[1] -= t.pos[1], v < m[1] + u.NODE_SLOT_HEIGHT * 0.5 && (v = m[1] + u.NODE_SLOT_HEIGHT * 0.5), e.beginPath(); var E = !0; - if (_.shape === k.BOX_SHAPE ? l ? t.rect( + if (_.shape === k.BOX_SHAPE ? l ? e.rect( m[0] - 5 + 0.5, m[1] - 8 + 0.5, 10, 14 - ) : t.rect( + ) : e.rect( m[0] - 6 + 0.5, m[1] - 5 + 0.5, 14, 10 - ) : b === k.ARROW_SHAPE ? (t.moveTo(m[0] + 8, m[1] + 0.5), t.lineTo(m[0] - 4, m[1] + 6 + 0.5), t.lineTo(m[0] - 4, m[1] - 6 + 0.5), t.closePath()) : b === k.GRID_SHAPE ? (t.rect(m[0] - 4, m[1] - 4, 2, 2), t.rect(m[0] - 1, m[1] - 4, 2, 2), t.rect(m[0] + 2, m[1] - 4, 2, 2), t.rect(m[0] - 4, m[1] - 1, 2, 2), t.rect(m[0] - 1, m[1] - 1, 2, 2), t.rect(m[0] + 2, m[1] - 1, 2, 2), t.rect(m[0] - 4, m[1] + 2, 2, 2), t.rect(m[0] - 1, m[1] + 2, 2, 2), t.rect(m[0] + 2, m[1] + 2, 2, 2), E = !1) : s ? t.rect(m[0] - 4, m[1] - 4, 8, 8) : t.arc(m[0], m[1], 4, 0, Math.PI * 2), t.fill(), p) { + ) : b === k.ARROW_SHAPE ? (e.moveTo(m[0] + 8, m[1] + 0.5), e.lineTo(m[0] - 4, m[1] + 6 + 0.5), e.lineTo(m[0] - 4, m[1] - 6 + 0.5), e.closePath()) : b === k.GRID_SHAPE ? (e.rect(m[0] - 4, m[1] - 4, 2, 2), e.rect(m[0] - 1, m[1] - 4, 2, 2), e.rect(m[0] + 2, m[1] - 4, 2, 2), e.rect(m[0] - 4, m[1] - 1, 2, 2), e.rect(m[0] - 1, m[1] - 1, 2, 2), e.rect(m[0] + 2, m[1] - 1, 2, 2), e.rect(m[0] - 4, m[1] + 2, 2, 2), e.rect(m[0] - 1, m[1] + 2, 2, 2), e.rect(m[0] + 2, m[1] + 2, 2, 2), E = !1) : s ? e.rect(m[0] - 4, m[1] - 4, 8, 8) : e.arc(m[0], m[1], 4, 0, Math.PI * 2), e.fill(), p) { var T = _.label != null ? _.label : _.name; - T && (t.fillStyle = u.NODE_TEXT_COLOR, l || _.dir == w.UP ? t.fillText(T, m[0], m[1] - 10) : t.fillText(T, m[0] + 10, m[1] + 5)); + T && (e.fillStyle = u.NODE_TEXT_COLOR, l || _.dir == w.UP ? e.fillText(T, m[0], m[1] - 10) : e.fillText(T, m[0] + 10, m[1] + 5)); } } - if (t.textAlign = l ? "center" : "right", t.strokeStyle = "black", e.outputs) - for (let G = 0; G < e.outputs.length; G++) { - let z = e.outputs[G]; + if (e.textAlign = l ? "center" : "right", e.strokeStyle = "black", t.outputs) + for (let G = 0; G < t.outputs.length; G++) { + let z = t.outputs[G]; var y = z.type, b = z.shape; - this.connecting_input && !u.isValidConnection(c.type, y) ? t.globalAlpha = 0.4 * r : t.globalAlpha = r; - var m = e.getConnectionPos(!1, G, g); - m[0] -= e.pos[0], m[1] -= e.pos[1], v < m[1] + u.NODE_SLOT_HEIGHT * 0.5 && (v = m[1] + u.NODE_SLOT_HEIGHT * 0.5), t.fillStyle = z.links && z.links.length ? z.color_on || N.DEFAULT_CONNECTION_COLORS_BY_TYPE[y] || N.DEFAULT_CONNECTION_COLORS.output_on : z.color_off || N.DEFAULT_CONNECTION_COLORS_BY_TYPE_OFF[y] || N.DEFAULT_CONNECTION_COLORS_BY_TYPE[y] || N.DEFAULT_CONNECTION_COLORS.output_off, t.beginPath(); + this.connecting_input && !u.isValidConnection(c.type, y) ? e.globalAlpha = 0.4 * r : e.globalAlpha = r; + var m = t.getConnectionPos(!1, G, g); + m[0] -= t.pos[0], m[1] -= t.pos[1], v < m[1] + u.NODE_SLOT_HEIGHT * 0.5 && (v = m[1] + u.NODE_SLOT_HEIGHT * 0.5), e.fillStyle = z.links && z.links.length ? z.color_on || N.DEFAULT_CONNECTION_COLORS_BY_TYPE[y] || N.DEFAULT_CONNECTION_COLORS.output_on : z.color_off || N.DEFAULT_CONNECTION_COLORS_BY_TYPE_OFF[y] || N.DEFAULT_CONNECTION_COLORS_BY_TYPE[y] || N.DEFAULT_CONNECTION_COLORS.output_off, e.beginPath(); var E = !0; - if (b === k.BOX_SHAPE ? l ? t.rect( + if (b === k.BOX_SHAPE ? l ? e.rect( m[0] - 5 + 0.5, m[1] - 8 + 0.5, 10, 14 - ) : t.rect( + ) : e.rect( m[0] - 6 + 0.5, m[1] - 5 + 0.5, 14, 10 - ) : b === k.ARROW_SHAPE ? (t.moveTo(m[0] + 8, m[1] + 0.5), t.lineTo(m[0] - 4, m[1] + 6 + 0.5), t.lineTo(m[0] - 4, m[1] - 6 + 0.5), t.closePath()) : b === k.GRID_SHAPE ? (t.rect(m[0] - 4, m[1] - 4, 2, 2), t.rect(m[0] - 1, m[1] - 4, 2, 2), t.rect(m[0] + 2, m[1] - 4, 2, 2), t.rect(m[0] - 4, m[1] - 1, 2, 2), t.rect(m[0] - 1, m[1] - 1, 2, 2), t.rect(m[0] + 2, m[1] - 1, 2, 2), t.rect(m[0] - 4, m[1] + 2, 2, 2), t.rect(m[0] - 1, m[1] + 2, 2, 2), t.rect(m[0] + 2, m[1] + 2, 2, 2), E = !1) : s ? t.rect(m[0] - 4, m[1] - 4, 8, 8) : t.arc(m[0], m[1], 4, 0, Math.PI * 2), t.fill(), !s && E && t.stroke(), p) { + ) : b === k.ARROW_SHAPE ? (e.moveTo(m[0] + 8, m[1] + 0.5), e.lineTo(m[0] - 4, m[1] + 6 + 0.5), e.lineTo(m[0] - 4, m[1] - 6 + 0.5), e.closePath()) : b === k.GRID_SHAPE ? (e.rect(m[0] - 4, m[1] - 4, 2, 2), e.rect(m[0] - 1, m[1] - 4, 2, 2), e.rect(m[0] + 2, m[1] - 4, 2, 2), e.rect(m[0] - 4, m[1] - 1, 2, 2), e.rect(m[0] - 1, m[1] - 1, 2, 2), e.rect(m[0] + 2, m[1] - 1, 2, 2), e.rect(m[0] - 4, m[1] + 2, 2, 2), e.rect(m[0] - 1, m[1] + 2, 2, 2), e.rect(m[0] + 2, m[1] + 2, 2, 2), E = !1) : s ? e.rect(m[0] - 4, m[1] - 4, 8, 8) : e.arc(m[0], m[1], 4, 0, Math.PI * 2), e.fill(), !s && E && e.stroke(), p) { var T = z.label != null ? z.label : z.name; - T && (t.fillStyle = u.NODE_TEXT_COLOR, l || z.dir == w.DOWN ? t.fillText(T, m[0], m[1] - 8) : t.fillText(T, m[0] - 10, m[1] + 5)); + T && (e.fillStyle = u.NODE_TEXT_COLOR, l || z.dir == w.DOWN ? e.fillText(T, m[0], m[1] - 8) : e.fillText(T, m[0] - 10, m[1] + 5)); } } - if (t.textAlign = "left", t.globalAlpha = 1, e.widgets) { + if (e.textAlign = "left", e.globalAlpha = 1, t.widgets) { var O = v; - (l || e.widgets_up) && (O = 2), e.widgets_start_y != null && (O = e.widgets_start_y), this.drawNodeWidgets( - e, - O, + (l || t.widgets_up) && (O = 2), t.widgets_start_y != null && (O = t.widgets_start_y), this.drawNodeWidgets( t, - this.node_widget && this.node_widget[0] == e ? this.node_widget[1] : null + O, + e, + this.node_widget && this.node_widget[0] == t ? this.node_widget[1] : null ); } } - e.clip_area && t.restore(), t.globalAlpha = 1; + t.clip_area && e.restore(), e.globalAlpha = 1; } } /** used by this.over_link_center */ - drawLinkTooltip(e, t) { - var i = t._pos; - if (this.allow_interaction && !this.read_only && (e.fillStyle = "black", e.beginPath(), e.arc(i[0], i[1], 3, 0, Math.PI * 2), e.fill()), t.data != null && !(this.onDrawLinkTooltip && this.onDrawLinkTooltip(e, t, this) == !0)) { - var n = t.data, s = null; + drawLinkTooltip(t, e) { + var i = e._pos; + if (this.allow_interaction && !this.read_only && (t.fillStyle = "black", t.beginPath(), t.arc(i[0], i[1], 3, 0, Math.PI * 2), t.fill()), e.data != null && !(this.onDrawLinkTooltip && this.onDrawLinkTooltip(t, e, this) == !0)) { + var n = e.data, s = null; if (n.constructor === Number ? s = n.toFixed(2) : n.constructor === String ? s = '"' + n + '"' : n.constructor === Boolean ? s = String(n) : n.toToolTip ? s = n.toToolTip() : s = "[" + n.constructor.name + "]", s != null) { - s = s.substr(0, 30), e.font = "14px Courier New"; - var r = e.measureText(s), o = r.width + 20, a = 24; - e.shadowColor = "black", e.shadowOffsetX = 2, e.shadowOffsetY = 2, e.shadowBlur = 3, e.fillStyle = "#454", e.beginPath(), e.roundRect(i[0] - o * 0.5, i[1] - 15 - a, o, a, [3]), e.moveTo(i[0] - 10, i[1] - 15), e.lineTo(i[0] + 10, i[1] - 15), e.lineTo(i[0], i[1] - 5), e.fill(), e.shadowColor = "transparent", e.textAlign = "center", e.fillStyle = "#CEC", e.fillText(s, i[0], i[1] - 15 - a * 0.3); + s = s.substr(0, 30), t.font = "14px Courier New"; + var r = t.measureText(s), o = r.width + 20, a = 24; + t.shadowColor = "black", t.shadowOffsetX = 2, t.shadowOffsetY = 2, t.shadowBlur = 3, t.fillStyle = "#454", t.beginPath(), t.roundRect(i[0] - o * 0.5, i[1] - 15 - a, o, a, [3]), t.moveTo(i[0] - 10, i[1] - 15), t.lineTo(i[0] + 10, i[1] - 15), t.lineTo(i[0], i[1] - 5), t.fill(), t.shadowColor = "transparent", t.textAlign = "center", t.fillStyle = "#CEC", t.fillText(s, i[0], i[1] - 15 - a * 0.3); } } } /** draws the shape of the given node in the canvas */ - drawNodeShape(e, t, i, n, s, r, o) { - t.strokeStyle = n, t.fillStyle = s; - var a = u.NODE_TITLE_HEIGHT, l = this.ds.scale < 0.5, h = e.shape || e.constructor.shape || k.ROUND_SHAPE, p = e.titleMode, f = e.isShowingTitle(o), c = ie.tmp_area; + drawNodeShape(t, e, i, n, s, r, o) { + e.strokeStyle = n, e.fillStyle = s; + var a = u.NODE_TITLE_HEIGHT, l = this.ds.scale < 0.5, h = t.shape || t.constructor.shape || k.ROUND_SHAPE, p = t.titleMode, f = t.isShowingTitle(o), c = ie.tmp_area; c[0] = 0, c[1] = f ? -a : 0, c[2] = i[0] + 1, c[3] = f ? i[1] + a : i[1]; - var v = t.globalAlpha; - if (t.beginPath(), h == k.BOX_SHAPE || l ? t.fillRect(c[0], c[1], c[2], c[3]) : h == k.ROUND_SHAPE || h == k.CARD_SHAPE ? t.roundRect( + var v = e.globalAlpha; + if (e.beginPath(), h == k.BOX_SHAPE || l ? e.fillRect(c[0], c[1], c[2], c[3]) : h == k.ROUND_SHAPE || h == k.CARD_SHAPE ? e.roundRect( c[0], c[1], c[2], c[3], h == k.CARD_SHAPE ? [this.round_radius, this.round_radius, 0, 0] : [this.round_radius] - ) : h == k.CIRCLE_SHAPE && t.arc( + ) : h == k.CIRCLE_SHAPE && e.arc( i[0] * 0.5, i[1] * 0.5, i[0] * 0.5, 0, Math.PI * 2 - ), t.fill(), !e.flags.collapsed && f && (t.shadowColor = "transparent", t.fillStyle = "rgba(0,0,0,0.2)", t.fillRect(0, -1, c[2], 2)), t.shadowColor = "transparent", e.onDrawBackground && e.onDrawBackground(t, this, this.canvas, this.graph_mouse), f || p == se.TRANSPARENT_TITLE) { - if (e.onDrawTitleBar) - e.onDrawTitleBar(t, this, a, i, this.ds.scale, n); - else if (p != se.TRANSPARENT_TITLE && (e.constructor.title_color || this.render_title_colored)) { - var g = e.constructor.title_color || n; - if (e.flags.collapsed && (t.shadowColor = u.DEFAULT_SHADOW_COLOR), this.use_gradients) { + ), e.fill(), !t.flags.collapsed && f && (e.shadowColor = "transparent", e.fillStyle = "rgba(0,0,0,0.2)", e.fillRect(0, -1, c[2], 2)), e.shadowColor = "transparent", t.onDrawBackground && t.onDrawBackground(e, this, this.canvas, this.graph_mouse), f || p == se.TRANSPARENT_TITLE) { + if (t.onDrawTitleBar) + t.onDrawTitleBar(e, this, a, i, this.ds.scale, n); + else if (p != se.TRANSPARENT_TITLE && (t.constructor.title_color || this.render_title_colored)) { + var g = t.constructor.title_color || n; + if (t.flags.collapsed && (e.shadowColor = u.DEFAULT_SHADOW_COLOR), this.use_gradients) { var d = N.gradients[g]; - d || (d = N.gradients[g] = t.createLinearGradient(0, 0, 400, 0), d.addColorStop(0, g), d.addColorStop(1, "#000")), t.fillStyle = d; + d || (d = N.gradients[g] = e.createLinearGradient(0, 0, 400, 0), d.addColorStop(0, g), d.addColorStop(1, "#000")), e.fillStyle = d; } else - t.fillStyle = g; - t.beginPath(), h == k.BOX_SHAPE || l ? t.rect(0, -a, i[0] + 1, a) : (h == k.ROUND_SHAPE || h == k.CARD_SHAPE) && t.roundRect( + e.fillStyle = g; + e.beginPath(), h == k.BOX_SHAPE || l ? e.rect(0, -a, i[0] + 1, a) : (h == k.ROUND_SHAPE || h == k.CARD_SHAPE) && e.roundRect( 0, -a, i[0] + 1, a, - e.flags.collapsed ? [this.round_radius] : [this.round_radius, this.round_radius, 0, 0] - ), t.fill(), t.shadowColor = "transparent"; + t.flags.collapsed ? [this.round_radius] : [this.round_radius, this.round_radius, 0, 0] + ), e.fill(), e.shadowColor = "transparent"; } var _ = null; - u.node_box_coloured_by_mode && Oe[e.mode] && (_ = Oe[e.mode]), u.node_box_coloured_when_on && (_ = e.action_triggered ? "#FFF" : e.execute_triggered ? "#AAA" : _); + u.node_box_coloured_by_mode && Oe[t.mode] && (_ = Oe[t.mode]), u.node_box_coloured_when_on && (_ = t.action_triggered ? "#FFF" : t.execute_triggered ? "#AAA" : _); var y = 10; - if (e.onDrawTitleBox ? e.onDrawTitleBox(t, this, a, i, this.ds.scale) : h == k.ROUND_SHAPE || h == k.CIRCLE_SHAPE || h == k.CARD_SHAPE ? (l && (t.fillStyle = "black", t.beginPath(), t.arc( + if (t.onDrawTitleBox ? t.onDrawTitleBox(e, this, a, i, this.ds.scale) : h == k.ROUND_SHAPE || h == k.CIRCLE_SHAPE || h == k.CARD_SHAPE ? (l && (e.fillStyle = "black", e.beginPath(), e.arc( a * 0.5, a * -0.5, y * 0.5 + 1, 0, Math.PI * 2 - ), t.fill()), t.fillStyle = e.boxcolor || _ || u.NODE_DEFAULT_BOXCOLOR, l ? t.fillRect(a * 0.5 - y * 0.5, a * -0.5 - y * 0.5, y, y) : (t.beginPath(), t.arc( + ), e.fill()), e.fillStyle = t.boxcolor || _ || u.NODE_DEFAULT_BOXCOLOR, l ? e.fillRect(a * 0.5 - y * 0.5, a * -0.5 - y * 0.5, y, y) : (e.beginPath(), e.arc( a * 0.5, a * -0.5, y * 0.5, 0, Math.PI * 2 - ), t.fill())) : (l && (t.fillStyle = "black", t.fillRect( + ), e.fill())) : (l && (e.fillStyle = "black", e.fillRect( (a - y) * 0.5 - 1, (a + y) * -0.5 - 1, y + 2, y + 2 - )), t.fillStyle = e.boxcolor || _ || u.NODE_DEFAULT_BOXCOLOR, t.fillRect( + )), e.fillStyle = t.boxcolor || _ || u.NODE_DEFAULT_BOXCOLOR, e.fillRect( (a - y) * 0.5, (a + y) * -0.5, y, y - )), t.globalAlpha = v, e.onDrawTitleText && e.onDrawTitleText( - t, + )), e.globalAlpha = v, t.onDrawTitleText && t.onDrawTitleText( + e, this, a, i, @@ -1393,56 +1393,56 @@ const ie = class { this.title_text_font, r ), !l) { - t.font = this.title_text_font; - var b = String(e.getTitle()); - b && (r ? t.fillStyle = u.NODE_SELECTED_TITLE_COLOR : t.fillStyle = e.constructor.title_text_color || this.node_title_color, e.flags.collapsed ? (t.textAlign = "left", t.fillText( + e.font = this.title_text_font; + var b = String(t.getTitle()); + b && (r ? e.fillStyle = u.NODE_SELECTED_TITLE_COLOR : e.fillStyle = t.constructor.title_text_color || this.node_title_color, t.flags.collapsed ? (e.textAlign = "left", e.fillText( b.substr(0, 20), //avoid urls too long a, // + measure.width * 0.5, u.NODE_TITLE_TEXT_Y - a - ), t.textAlign = "left") : (t.textAlign = "left", t.fillText( + ), e.textAlign = "left") : (e.textAlign = "left", e.fillText( b, a, u.NODE_TITLE_TEXT_Y - a ))); } - if (!e.flags.collapsed && e.subgraph && !e.skip_subgraph_button) { - var m = u.NODE_TITLE_HEIGHT, E = e.size[0] - m, T = u.isInsideRectangle(this.graph_mouse[0] - e.pos[0], this.graph_mouse[1] - e.pos[1], E + 2, -m + 2, m - 4, m - 4); - t.fillStyle = T ? "#888" : "#555", h == k.BOX_SHAPE || l ? t.fillRect(E + 2, -m + 2, m - 4, m - 4) : (t.beginPath(), t.roundRect(E + 2, -m + 2, m - 4, m - 4, [4]), t.fill()), t.fillStyle = "#333", t.beginPath(), t.moveTo(E + m * 0.2, -m * 0.6), t.lineTo(E + m * 0.8, -m * 0.6), t.lineTo(E + m * 0.5, -m * 0.3), t.fill(); + if (!t.flags.collapsed && t.subgraph && !t.skip_subgraph_button) { + var m = u.NODE_TITLE_HEIGHT, E = t.size[0] - m, T = u.isInsideRectangle(this.graph_mouse[0] - t.pos[0], this.graph_mouse[1] - t.pos[1], E + 2, -m + 2, m - 4, m - 4); + e.fillStyle = T ? "#888" : "#555", h == k.BOX_SHAPE || l ? e.fillRect(E + 2, -m + 2, m - 4, m - 4) : (e.beginPath(), e.roundRect(E + 2, -m + 2, m - 4, m - 4, [4]), e.fill()), e.fillStyle = "#333", e.beginPath(), e.moveTo(E + m * 0.2, -m * 0.6), e.lineTo(E + m * 0.8, -m * 0.6), e.lineTo(E + m * 0.5, -m * 0.3), e.fill(); } - e.onDrawTitle && e.onDrawTitle(t, this); + t.onDrawTitle && t.onDrawTitle(e, this); } - r && (e.onBounding && e.onBounding(c), p == se.TRANSPARENT_TITLE && (c[1] -= a, c[3] += a), t.lineWidth = 1, t.globalAlpha = 0.8, t.beginPath(), h == k.BOX_SHAPE ? t.rect( + r && (t.onBounding && t.onBounding(c), p == se.TRANSPARENT_TITLE && (c[1] -= a, c[3] += a), e.lineWidth = 1, e.globalAlpha = 0.8, e.beginPath(), h == k.BOX_SHAPE ? e.rect( -6 + c[0], -6 + c[1], 12 + c[2], 12 + c[3] - ) : h == k.ROUND_SHAPE || h == k.CARD_SHAPE && e.flags.collapsed ? t.roundRect( + ) : h == k.ROUND_SHAPE || h == k.CARD_SHAPE && t.flags.collapsed ? e.roundRect( -6 + c[0], -6 + c[1], 12 + c[2], 12 + c[3], [this.round_radius * 2] - ) : h == k.CARD_SHAPE ? t.roundRect( + ) : h == k.CARD_SHAPE ? e.roundRect( -6 + c[0], -6 + c[1], 12 + c[2], 12 + c[3], [this.round_radius * 2, 2, this.round_radius * 2, 2] - ) : h == k.CIRCLE_SHAPE && t.arc( + ) : h == k.CIRCLE_SHAPE && e.arc( i[0] * 0.5, i[1] * 0.5, i[0] * 0.5 + 6, 0, Math.PI * 2 - ), t.strokeStyle = u.NODE_BOX_OUTLINE_COLOR, t.stroke(), t.strokeStyle = n, t.globalAlpha = 1), e.execute_triggered > 0 && e.execute_triggered--, e.action_triggered > 0 && e.action_triggered--; + ), e.strokeStyle = u.NODE_BOX_OUTLINE_COLOR, e.stroke(), e.strokeStyle = n, e.globalAlpha = 1), t.execute_triggered > 0 && t.execute_triggered--, t.action_triggered > 0 && t.action_triggered--; } /** draws every connection visible in the canvas */ - drawConnections(e) { - var t = u.getTime(), i = this.visible_area; + drawConnections(t) { + var e = u.getTime(), i = this.visible_area; let n = ie.margin_area; - n[0] = i[0] - 20, n[1] = i[1] - 20, n[2] = i[2] + 40, n[3] = i[3] + 40, e.lineWidth = this.connections_width, e.fillStyle = "#AAA", e.strokeStyle = "#AAA", e.globalAlpha = this.editor_alpha; + n[0] = i[0] - 20, n[1] = i[1] - 20, n[2] = i[2] + 40, n[3] = i[3] + 40, t.lineWidth = this.connections_width, t.fillStyle = "#AAA", t.strokeStyle = "#AAA", t.globalAlpha = this.editor_alpha; for (var s = this.graph._nodes, r = 0, o = s.length; r < o; ++r) { var a = s[r]; if (!(!a.inputs || !a.inputs.length)) @@ -1472,7 +1472,7 @@ const ie = class { if (!(!_ || !y)) { var b = _.dir || (c.horizontal ? w.DOWN : w.RIGHT), m = y.dir || (a.horizontal ? w.UP : w.LEFT); if (this.renderLink( - e, + t, g, d, f, @@ -1481,10 +1481,10 @@ const ie = class { null, b, m - ), f && f._last_time && t - f._last_time < 1e3) { - var E = 2 - (t - f._last_time) * 2e-3, T = e.globalAlpha; - e.globalAlpha = T * E, this.renderLink( - e, + ), f && f._last_time && e - f._last_time < 1e3) { + var E = 2 - (e - f._last_time) * 2e-3, T = t.globalAlpha; + t.globalAlpha = T * E, this.renderLink( + t, g, d, f, @@ -1493,13 +1493,13 @@ const ie = class { "white", b, m - ), e.globalAlpha = T; + ), t.globalAlpha = T; } } } } } - e.globalAlpha = 1; + t.globalAlpha = 1; } /** * draws a link between two points @@ -1513,14 +1513,14 @@ const ie = class { * @param endDir the direction enum * @param numSublines number of sublines (useful to represent vec3 or rgb) **/ - renderLink(e, t, i, n, s, r, o, a, l, h) { + renderLink(t, e, i, n, s, r, o, a, l, h) { n && this.visible_links.push(n), !o && n && (o = n.color || this.link_type_colors[n.type]), o || (o = this.default_link_color), n != null && this.highlighted_links[n.id] && (o = "#FFF"), a = a || w.RIGHT, l = l || w.LEFT; - var p = u.distance(t, i); - this.render_connections_border && this.ds.scale > 0.6 && (e.lineWidth = this.connections_width + 4), e.lineJoin = "round", h = h || 1, h > 1 && (e.lineWidth = 0.5), e.beginPath(); + var p = u.distance(e, i); + this.render_connections_border && this.ds.scale > 0.6 && (t.lineWidth = this.connections_width + 4), t.lineJoin = "round", h = h || 1, h > 1 && (t.lineWidth = 0.5), t.beginPath(); for (var f = 0; f < h; f += 1) { var c = (f - (h - 1) * 0.5) * 5; if (this.links_render_mode == de.SPLINE_LINK) { - e.moveTo(t[0], t[1] + c); + t.moveTo(e[0], e[1] + c); var v = 0, g = 0, d = 0, _ = 0; switch (a) { case w.LEFT: @@ -1550,16 +1550,16 @@ const ie = class { _ = p * 0.25; break; } - e.bezierCurveTo( - t[0] + v, - t[1] + g + c, + t.bezierCurveTo( + e[0] + v, + e[1] + g + c, i[0] + d, i[1] + _ + c, i[0], i[1] + c ); } else if (this.links_render_mode == de.LINEAR_LINK) { - e.moveTo(t[0], t[1] + c); + t.moveTo(e[0], e[1] + c); var v = 0, g = 0, d = 0, _ = 0; switch (a) { case w.LEFT: @@ -1590,69 +1590,69 @@ const ie = class { break; } var y = 15; - e.lineTo( - t[0] + v * y, - t[1] + g * y + c - ), e.lineTo( + t.lineTo( + e[0] + v * y, + e[1] + g * y + c + ), t.lineTo( i[0] + d * y, i[1] + _ * y + c - ), e.lineTo(i[0], i[1] + c); + ), t.lineTo(i[0], i[1] + c); } else if (this.links_render_mode == de.STRAIGHT_LINK) { - e.moveTo(t[0], t[1]); - var b = t[0], m = t[1], E = i[0], T = i[1]; - a == w.RIGHT ? b += 10 : m += 10, l == w.LEFT ? E -= 10 : T -= 10, e.lineTo(b, m), e.lineTo((b + E) * 0.5, m), e.lineTo((b + E) * 0.5, T), e.lineTo(E, T), e.lineTo(i[0], i[1]); + t.moveTo(e[0], e[1]); + var b = e[0], m = e[1], E = i[0], T = i[1]; + a == w.RIGHT ? b += 10 : m += 10, l == w.LEFT ? E -= 10 : T -= 10, t.lineTo(b, m), t.lineTo((b + E) * 0.5, m), t.lineTo((b + E) * 0.5, T), t.lineTo(E, T), t.lineTo(i[0], i[1]); } else return; } - this.render_connections_border && this.ds.scale > 0.6 && !s && (e.strokeStyle = "rgba(0,0,0,0.5)", e.stroke()), e.lineWidth = this.connections_width, e.fillStyle = e.strokeStyle = o, e.stroke(); - var O = this.computeConnectionPoint(t, i, 0.5, a, l); + this.render_connections_border && this.ds.scale > 0.6 && !s && (t.strokeStyle = "rgba(0,0,0,0.5)", t.stroke()), t.lineWidth = this.connections_width, t.fillStyle = t.strokeStyle = o, t.stroke(); + var O = this.computeConnectionPoint(e, i, 0.5, a, l); if (n && n._pos && (n._pos[0] = O[0], n._pos[1] = O[1]), this.ds.scale >= 0.6 && this.highquality_render && l != w.CENTER) { if (this.render_connection_arrows) { var A = this.computeConnectionPoint( - t, + e, i, 0.25, a, l ), M = this.computeConnectionPoint( - t, + e, i, 0.26, a, l ), L = this.computeConnectionPoint( - t, + e, i, 0.75, a, l ), B = this.computeConnectionPoint( - t, + e, i, 0.76, a, l ), G = 0, z = 0; - this.render_curved_connections ? (G = -Math.atan2(M[0] - A[0], M[1] - A[1]), z = -Math.atan2(B[0] - L[0], B[1] - L[1])) : z = G = i[1] > t[1] ? 0 : Math.PI, e.save(), e.translate(A[0], A[1]), e.rotate(G), e.beginPath(), e.moveTo(-5, -3), e.lineTo(0, 7), e.lineTo(5, -3), e.fill(), e.restore(), e.save(), e.translate(L[0], L[1]), e.rotate(z), e.beginPath(), e.moveTo(-5, -3), e.lineTo(0, 7), e.lineTo(5, -3), e.fill(), e.restore(); + this.render_curved_connections ? (G = -Math.atan2(M[0] - A[0], M[1] - A[1]), z = -Math.atan2(B[0] - L[0], B[1] - L[1])) : z = G = i[1] > e[1] ? 0 : Math.PI, t.save(), t.translate(A[0], A[1]), t.rotate(G), t.beginPath(), t.moveTo(-5, -3), t.lineTo(0, 7), t.lineTo(5, -3), t.fill(), t.restore(), t.save(), t.translate(L[0], L[1]), t.rotate(z), t.beginPath(), t.moveTo(-5, -3), t.lineTo(0, 7), t.lineTo(5, -3), t.fill(), t.restore(); } - e.beginPath(), e.arc(O[0], O[1], 5, 0, Math.PI * 2), e.fill(); + t.beginPath(), t.arc(O[0], O[1], 5, 0, Math.PI * 2), t.fill(); } if (r) { - e.fillStyle = o; + t.fillStyle = o; for (var f = 0; f < 5; ++f) { var pe = (u.getTime() * 1e-3 + f * 0.2) % 1, O = this.computeConnectionPoint( - t, + e, i, pe, a, l ); - e.beginPath(), e.arc(O[0], O[1], 5, 0, 2 * Math.PI), e.fill(); + t.beginPath(), t.arc(O[0], O[1], 5, 0, 2 * Math.PI), t.fill(); } } } - computeConnectionPoint(e, t, i, n = w.RIGHT, s = w.LEFT) { - var r = u.distance(e, t), o = e, a = [e[0], e[1]], l = [t[0], t[1]], h = t; + computeConnectionPoint(t, e, i, n = w.RIGHT, s = w.LEFT) { + var r = u.distance(t, e), o = t, a = [t[0], t[1]], l = [e[0], e[1]], h = e; switch (n) { case w.LEFT: a[0] += r * -0.25; @@ -1684,39 +1684,39 @@ const ie = class { var p = (1 - i) * (1 - i) * (1 - i), f = 3 * ((1 - i) * (1 - i)) * i, c = 3 * (1 - i) * (i * i), v = i * i * i, g = p * o[0] + f * a[0] + c * l[0] + v * h[0], d = p * o[1] + f * a[1] + c * l[1] + v * h[1]; return [g, d]; } - drawExecutionOrder(e) { - e.shadowColor = "transparent", e.globalAlpha = 0.25, e.textAlign = "center", e.strokeStyle = "white", e.globalAlpha = 0.75; - for (var t = this.visible_nodes, i = 0; i < t.length; ++i) { - var n = t[i]; - e.fillStyle = "black", e.fillRect( + drawExecutionOrder(t) { + t.shadowColor = "transparent", t.globalAlpha = 0.25, t.textAlign = "center", t.strokeStyle = "white", t.globalAlpha = 0.75; + for (var e = this.visible_nodes, i = 0; i < e.length; ++i) { + var n = e[i]; + t.fillStyle = "black", t.fillRect( n.pos[0] - u.NODE_TITLE_HEIGHT, n.pos[1] - u.NODE_TITLE_HEIGHT, u.NODE_TITLE_HEIGHT, u.NODE_TITLE_HEIGHT - ), n.order == 0 && e.strokeRect( + ), n.order == 0 && t.strokeRect( n.pos[0] - u.NODE_TITLE_HEIGHT + 0.5, n.pos[1] - u.NODE_TITLE_HEIGHT + 0.5, u.NODE_TITLE_HEIGHT, u.NODE_TITLE_HEIGHT - ), e.fillStyle = "#FFF", e.fillText( + ), t.fillStyle = "#FFF", t.fillText( "" + n.order, n.pos[0] + u.NODE_TITLE_HEIGHT * -0.5, n.pos[1] - 6 ); } - e.globalAlpha = 1; + t.globalAlpha = 1; } /** draws the widgets stored inside a node */ - drawNodeWidgets(e, t, i, n) { - if (!(!e.widgets || !e.widgets.length)) { - var s = e.size[0], r = e.widgets; - t += 2; + drawNodeWidgets(t, e, i, n) { + if (!(!t.widgets || !t.widgets.length)) { + var s = t.size[0], r = t.widgets; + e += 2; var o = u.NODE_WIDGET_HEIGHT, a = this.ds.scale > 0.5; i.save(), i.globalAlpha = this.editor_alpha; for (var l = u.WIDGET_OUTLINE_COLOR, h = u.WIDGET_BGCOLOR, p = u.WIDGET_TEXT_COLOR, f = u.WIDGET_SECONDARY_TEXT_COLOR, c = 15, v = 0; v < r.length; ++v) { var g = r[v]; if (!g.hidden) { - var d = t; + var d = e; g.y && (d = g.y), g.last_y = d, i.strokeStyle = l, i.fillStyle = "#222", i.textAlign = "left", g.disabled && (i.globalAlpha *= 0.5); var _ = g.width || s; switch (g.type) { @@ -1772,10 +1772,10 @@ const ie = class { i.textAlign = "left", i.strokeStyle = l, i.fillStyle = h, i.beginPath(), a ? i.roundRect(c, d, _ - c * 2, o, [o * 0.5]) : i.rect(c, d, _ - c * 2, o), i.fill(), a && (g.disabled || i.stroke(), i.save(), i.beginPath(), i.rect(c, d, _ - c * 2, o), i.clip(), i.fillStyle = f, g.name != null && i.fillText(g.name, c * 2, d + o * 0.7), i.fillStyle = p, i.textAlign = "right", i.fillText(String(g.value).substr(0, g.options.max_length || 30), _ - c * 2, d + o * 0.7), i.restore()); break; default: - g.draw && g.draw(i, e, _, d, o); + g.draw && g.draw(i, t, _, d, o); break; } - t += (g.computeSize ? g.computeSize(_)[1] : o) + 4, i.globalAlpha = this.editor_alpha; + e += (g.computeSize ? g.computeSize(_)[1] : o) + 4, i.globalAlpha = this.editor_alpha; } } i.restore(), i.textAlign = "left"; @@ -1791,8 +1791,8 @@ U.link_bounding = new Float32Array(4); U.tempA = [0, 0]; U.tempB = [0, 0]; class me { - constructor(t = "Group") { - this.fontSize = u.DEFAULT_GROUP_FONT_SIZE, this._nodes = [], this.graph = null, this._bounding = new Float32Array([10, 10, 140, 80]), this.title = t, this.color = N.node_colors.pale_blue ? N.node_colors.pale_blue.groupcolor : "#AAA", this._pos = this._bounding.subarray(0, 2), this._size = this._bounding.subarray(2, 4); + constructor(e = "Group") { + this.fontSize = u.DEFAULT_GROUP_FONT_SIZE, this._nodes = [], this.graph = null, this._bounding = new Float32Array([10, 10, 140, 80]), this.title = e, this.color = N.node_colors.pale_blue ? N.node_colors.pale_blue.groupcolor : "#AAA", this._pos = this._bounding.subarray(0, 2), this._size = this._bounding.subarray(2, 4); } get bounding() { return this._bounding; @@ -1800,62 +1800,62 @@ class me { get pos() { return [this._pos[0], this._pos[1]]; } - set pos(t) { - !t || t.length < 2 || (this._pos[0] = t[0], this._pos[1] = t[1]); + set pos(e) { + !e || e.length < 2 || (this._pos[0] = e[0], this._pos[1] = e[1]); } get size() { return [this._size[0], this._size[1]]; } - set size(t) { - !t || t.length < 2 || (this._size[0] = Math.max(140, t[0]), this._size[1] = Math.max(80, t[1])); + set size(e) { + !e || e.length < 2 || (this._size[0] = Math.max(140, e[0]), this._size[1] = Math.max(80, e[1])); } - configure(t) { - t.bounding, this.title = t.title, this._bounding.set(t.bounding), this.color = t.color, this.font = t.font; + configure(e) { + e.bounding, this.title = e.title, this._bounding.set(e.bounding), this.color = e.color, this.font = e.font; } serialize() { - const t = this._bounding; + const e = this._bounding; return { title: this.title, bounding: [ - Math.round(t[0]), - Math.round(t[1]), - Math.round(t[2]), - Math.round(t[3]) + Math.round(e[0]), + Math.round(e[1]), + Math.round(e[2]), + Math.round(e[3]) ], color: this.color, font: this.font }; } - move(t, i, n) { - if (this._pos[0] += t, this._pos[1] += i, !n) + move(e, i, n) { + if (this._pos[0] += e, this._pos[1] += i, !n) for (var s = 0; s < this._nodes.length; ++s) { var r = this._nodes[s]; - r.pos[0] += t, r.pos[1] += i; + r.pos[0] += e, r.pos[1] += i; } } recomputeInsideNodes() { this._nodes.length = 0; - for (var t = this.graph._nodes, i = new Float32Array(4), n = 0; n < t.length; ++n) { - var s = t[n]; + for (var e = this.graph._nodes, i = new Float32Array(4), n = 0; n < e.length; ++n) { + var s = e[n]; s.getBounding(i), u.overlapBounding(this._bounding, i) && this._nodes.push(s); } } /** checks if a point is inside the shape of a node */ - isPointInside(t, i, n = 0, s = !1) { + isPointInside(e, i, n = 0, s = !1) { var r = this.graph && this.graph.isLive() ? 0 : u.NODE_TITLE_HEIGHT; - return s && (r = 0), this.pos[0] - 4 - n < t && this.pos[0] + this.size[0] + 4 + n > t && this.pos[1] - r - n < i && this.pos[1] + this.size[1] + n > i; + return s && (r = 0), this.pos[0] - 4 - n < e && this.pos[0] + this.size[0] + 4 + n > e && this.pos[1] - r - n < i && this.pos[1] + this.size[1] + n > i; } /** Forces to redraw or the main canvas (LGraphNode) or the bg canvas (links) */ - setDirtyCanvas(t, i = !1) { - this.graph && this.graph.sendActionToCanvas("setDirty", [t, i]); + setDirtyCanvas(e, i = !1) { + this.graph && this.graph.sendActionToCanvas("setDirty", [e, i]); } } class he { - constructor(t, i, n, s, r, o) { - this.data = null, this._pos = [0, 0], this._last_time = 0, this.id = t, this.type = i, this.origin_id = n, this.origin_slot = s, this.target_id = r, this.target_slot = o; + constructor(e, i, n, s, r, o) { + this.data = null, this._pos = [0, 0], this._last_time = 0, this.id = e, this.type = i, this.origin_id = n, this.origin_slot = s, this.target_id = r, this.target_slot = o; } - static configure(t) { - return t instanceof Array ? new he(t[0], t[5], t[1], t[2], t[3], t[4]) : new he(t.id, t.type, t.origin_id, t.origin_slot, t.target_id, t.target_slot); + static configure(e) { + return e instanceof Array ? new he(e[0], e[5], e[1], e[2], e[3], e[4]) : new he(e.id, e.type, e.origin_id, e.origin_slot, e.target_id, e.target_slot); } serialize() { return [ @@ -1876,51 +1876,51 @@ function Fe() { return _e(He); } const K = []; -for (let e = 0; e < 256; ++e) - K.push((e + 256).toString(16).slice(1)); -function Ue(e, t = 0) { - return (K[e[t + 0]] + K[e[t + 1]] + K[e[t + 2]] + K[e[t + 3]] + "-" + K[e[t + 4]] + K[e[t + 5]] + "-" + K[e[t + 6]] + K[e[t + 7]] + "-" + K[e[t + 8]] + K[e[t + 9]] + "-" + K[e[t + 10]] + K[e[t + 11]] + K[e[t + 12]] + K[e[t + 13]] + K[e[t + 14]] + K[e[t + 15]]).toLowerCase(); +for (let t = 0; t < 256; ++t) + K.push((t + 256).toString(16).slice(1)); +function Ue(t, e = 0) { + return (K[t[e + 0]] + K[t[e + 1]] + K[t[e + 2]] + K[t[e + 3]] + "-" + K[t[e + 4]] + K[t[e + 5]] + "-" + K[t[e + 6]] + K[t[e + 7]] + "-" + K[t[e + 8]] + K[t[e + 9]] + "-" + K[t[e + 10]] + K[t[e + 11]] + K[t[e + 12]] + K[t[e + 13]] + K[t[e + 14]] + K[t[e + 15]]).toLowerCase(); } const ze = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), ke = { randomUUID: ze }; -function oe(e, t, i) { - if (ke.randomUUID && !t && !e) +function oe(t, e, i) { + if (ke.randomUUID && !e && !t) return ke.randomUUID(); - e = e || {}; - const n = e.random || (e.rng || Fe)(); - if (n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, t) { + t = t || {}; + const n = t.random || (t.rng || Fe)(); + if (n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, e) { i = i || 0; for (let s = 0; s < 16; ++s) - t[i + s] = n[s]; - return t; + e[i + s] = n[s]; + return e; } return Ue(n); } const Ne = class { - constructor(e) { - this.desc = "", this.pos = [0, 0], this.subgraph = null, this.skip_subgraph_button = !1, this.priority = 0, this.removable = !0, this.clonable = !0, this.collapsable = !0, this.titleMode = se.NORMAL_TITLE, this.serialize_widgets = !1, this.hide_in_node_lists = !1, this.block_delete = !1, this.ignore_remove = !1, this.last_serialization = null, this._relative_id = null, this.exec_version = 0, this.action_call = null, this.execute_triggered = 0, this.action_triggered = 0, this.console = [], this.title = e || "Unnamed", this.size = [u.NODE_WIDTH, 60], this.graph = null, this.pos = [10, 10], u.use_uuids ? this.id = oe() : this.id = -1, this.type = null, this.inputs = [], this.outputs = [], this.connections = [], this.properties = {}, this.properties_info = [], this.flags = {}; + constructor(t) { + this.desc = "", this.pos = [0, 0], this.subgraph = null, this.skip_subgraph_button = !1, this.priority = 0, this.removable = !0, this.clonable = !0, this.collapsable = !0, this.titleMode = se.NORMAL_TITLE, this.serialize_widgets = !1, this.hide_in_node_lists = !1, this.block_delete = !1, this.ignore_remove = !1, this.last_serialization = null, this._relative_id = null, this.exec_version = 0, this.action_call = null, this.execute_triggered = 0, this.action_triggered = 0, this.console = [], this.title = t || "Unnamed", this.size = [u.NODE_WIDTH, 60], this.graph = null, this.pos = [10, 10], u.use_uuids ? this.id = oe() : this.id = -1, this.type = null, this.inputs = [], this.outputs = [], this.connections = [], this.properties = {}, this.properties_info = [], this.flags = {}; } get slotLayout() { return "slotLayout" in this.constructor ? this.constructor.slotLayout : null; } /** configure a node from an object containing the serialized info */ - configure(e) { + configure(t) { this.graph && this.graph._version++; - for (var t in e) { - if (t == "properties") { - for (var i in e.properties) - this.properties[i] = e.properties[i], this.onPropertyChanged && this.onPropertyChanged(i, e.properties[i]); + for (var e in t) { + if (e == "properties") { + for (var i in t.properties) + this.properties[i] = t.properties[i], this.onPropertyChanged && this.onPropertyChanged(i, t.properties[i]); continue; } - e[t] != null && (typeof e[t] == "object" ? this[t] && this[t].configure ? this[t].configure(e[t]) : this[t] = u.cloneObject(e[t], this[t]) : this[t] = e[t]); + t[e] != null && (typeof t[e] == "object" ? this[e] && this[e].configure ? this[e].configure(t[e]) : this[e] = u.cloneObject(t[e], this[e]) : this[e] = t[e]); } - e.title || (this.title = ye(this, "title") || this.title); - const n = e.bgColor; + t.title || (this.title = ye(this, "title") || this.title); + const n = t.bgColor; if (n != null && (this.bgcolor || (this.bgcolor = n)), this.inputs) for (let o = 0; o < this.inputs.length; ++o) { let a = this.inputs[o], l = this.graph ? this.graph.links[a.link] : null; - a.properties || (a.properties = {}), this.onConnectionsChange && this.onConnectionsChange(Y.INPUT, o, !0, l, a), this.onInputAdded && this.onInputAdded(a); + a.properties || (a.properties = {}), this.onConnectionsChange && this.onConnectionsChange(W.INPUT, o, !0, l, a), this.onInputAdded && this.onInputAdded(a); } if (this.outputs) for (var s = 0; s < this.outputs.length; ++s) { @@ -1928,7 +1928,7 @@ const Ne = class { if (o.properties || (o.properties = {}), !!o.links) { for (let a = 0; a < o.links.length; ++a) { let l = this.graph ? this.graph.links[o.links[a]] : null; - this.onConnectionsChange && this.onConnectionsChange(Y.OUTPUT, s, !0, l, o); + this.onConnectionsChange && this.onConnectionsChange(W.OUTPUT, s, !0, l, o); } this.onOutputAdded && this.onOutputAdded(o); } @@ -1938,15 +1938,15 @@ const Ne = class { var r = this.widgets[s]; r && r.options && r.options.property && this.properties[r.options.property] && (r.value = JSON.parse(JSON.stringify(this.properties[r.options.property]))); } - if (e.widgets_values) - for (var s = 0; s < e.widgets_values.length; ++s) - this.widgets[s] && (this.widgets[s].value = e.widgets_values[s]); + if (t.widgets_values) + for (var s = 0; s < t.widgets_values.length; ++s) + this.widgets[s] && (this.widgets[s].value = t.widgets_values[s]); } - this.onConfigure && this.onConfigure(e); + this.onConfigure && this.onConfigure(t); } /** serialize the content */ serialize() { - let e = { + let t = { id: this.id, type: this.type, pos: this.pos, @@ -1957,22 +1957,22 @@ const Ne = class { }; if (this.constructor === Ne && this.last_serialization) return this.last_serialization; - if (this.inputs && (e.inputs = this.inputs), this.outputs) { - for (var t = 0; t < this.outputs.length; t++) - delete this.outputs[t]._data; - e.outputs = this.outputs; + if (this.inputs && (t.inputs = this.inputs), this.outputs) { + for (var e = 0; e < this.outputs.length; e++) + delete this.outputs[e]._data; + t.outputs = this.outputs; } - if (this.title && this.title != this.constructor.title && (e.title = this.title), this.properties && (e.properties = u.cloneObject(this.properties)), this.widgets && this.serialize_widgets) { - e.widgets_values = []; - for (var t = 0; t < this.widgets.length; ++t) - this.widgets[t] ? e.widgets_values[t] = this.widgets[t].value : e.widgets_values[t] = null; + if (this.title && this.title != this.constructor.title && (t.title = this.title), this.properties && (t.properties = u.cloneObject(this.properties)), this.widgets && this.serialize_widgets) { + t.widgets_values = []; + for (var e = 0; e < this.widgets.length; ++e) + this.widgets[e] ? t.widgets_values[e] = this.widgets[e].value : t.widgets_values[e] = null; } - return e.type || (e.type = this.constructor.type), this.color && (e.color = this.color), this.bgcolor && (e.bgcolor = this.bgcolor), this.boxcolor && (e.boxcolor = this.boxcolor), this.shape && (e.shape = this.shape), this.onSerialize && this.onSerialize(e), e; + return t.type || (t.type = this.constructor.type), this.color && (t.color = this.color), this.bgcolor && (t.bgcolor = this.bgcolor), this.boxcolor && (t.boxcolor = this.boxcolor), this.shape && (t.shape = this.shape), this.onSerialize && this.onSerialize(t), t; } /** Creates a clone of this node */ - clone(e = { forNode: {} }) { - var t = u.createNode(this.type); - if (!t) + clone(t = { forNode: {} }) { + var e = u.createNode(this.type); + if (!e) return null; var i = u.cloneObject(this.serialize()); if (i.inputs) @@ -1981,7 +1981,7 @@ const Ne = class { if (i.outputs) for (var n = 0; n < i.outputs.length; ++n) i.outputs[n].links && (i.outputs[n].links.length = 0); - return delete i.id, u.use_uuids && (i.id = oe()), t.configure(i), t; + return delete i.id, u.use_uuids && (i.id = oe()), e.configure(i), e; } /** serialize and stringify */ toString() { @@ -1992,96 +1992,96 @@ const Ne = class { return this.title || this.constructor.title; } getRootGraph() { - var t; - let e = this.graph; - for (; e && e._is_subgraph; ) - e = (t = e._subgraph_node) == null ? void 0 : t.graph; - return e == null || e._is_subgraph ? null : e; + var e; + let t = this.graph; + for (; t && t._is_subgraph; ) + t = (e = t._subgraph_node) == null ? void 0 : e.graph; + return t == null || t._is_subgraph ? null : t; } *iterateParentSubgraphNodes() { - var t; - let e = this.graph._subgraph_node; - for (; e; ) - yield e, e = (t = e.graph) == null ? void 0 : t._subgraph_node; + var e; + let t = this.graph._subgraph_node; + for (; t; ) + yield t, t = (e = t.graph) == null ? void 0 : e._subgraph_node; } /** sets the value of a property */ - setProperty(e, t) { - if (this.properties || (this.properties = {}), t !== this.properties[e]) { - var i = this.properties[e]; - if (this.properties[e] = t, this.graph && this.graph._version++, this.onPropertyChanged && this.onPropertyChanged(e, t, i) === !1 && (this.properties[e] = i), this.widgets) + setProperty(t, e) { + if (this.properties || (this.properties = {}), e !== this.properties[t]) { + var i = this.properties[t]; + if (this.properties[t] = e, this.graph && this.graph._version++, this.onPropertyChanged && this.onPropertyChanged(t, e, i) === !1 && (this.properties[t] = i), this.widgets) for (var n = 0; n < this.widgets.length; ++n) { var s = this.widgets[n]; - if (s && s.options.property == e) { - s.value = t; + if (s && s.options.property == t) { + s.value = e; break; } } } } - getInputSlotProperty(e, t) { - if (!(!this.inputs || !this.graph) && !(e == -1 || e >= this.inputs.length)) { - var i = this.inputs[e]; + getInputSlotProperty(t, e) { + if (!(!this.inputs || !this.graph) && !(t == -1 || t >= this.inputs.length)) { + var i = this.inputs[t]; if (i) - return i.properties || (i.properties = {}), i.properties[t]; + return i.properties || (i.properties = {}), i.properties[e]; } } - getOutputSlotProperty(e, t) { - if (!(!this.outputs || !this.graph) && !(e == -1 || e >= this.outputs.length)) { - var i = this.outputs[e]; + getOutputSlotProperty(t, e) { + if (!(!this.outputs || !this.graph) && !(t == -1 || t >= this.outputs.length)) { + var i = this.outputs[t]; if (i) - return i.properties || (i.properties = {}), i.properties[t]; + return i.properties || (i.properties = {}), i.properties[e]; } } - setInputSlotProperty(e, t, i) { - if (!(!this.inputs || !this.graph) && !(e == -1 || e >= this.inputs.length)) { - var n = this.inputs[e]; - if (n && (n.properties || (n.properties = {}), i !== n.properties[t])) { - var s = n.properties[t]; - n.properties[t] = i, this.graph && this.graph._version++, this.onSlotPropertyChanged && this.onSlotPropertyChanged(Y.INPUT, e, n, t, i, s) === !1 && (n.properties[t] = s); + setInputSlotProperty(t, e, i) { + if (!(!this.inputs || !this.graph) && !(t == -1 || t >= this.inputs.length)) { + var n = this.inputs[t]; + if (n && (n.properties || (n.properties = {}), i !== n.properties[e])) { + var s = n.properties[e]; + n.properties[e] = i, this.graph && this.graph._version++, this.onSlotPropertyChanged && this.onSlotPropertyChanged(W.INPUT, t, n, e, i, s) === !1 && (n.properties[e] = s); } } } - setOutputSlotProperty(e, t, i) { - if (!(!this.outputs || !this.graph) && !(e == -1 || e >= this.outputs.length)) { - var n = this.outputs[e]; - if (n && (n.properties || (n.properties = {}), i !== n.properties[t])) { - var s = n.properties[t]; - n.properties[t] = i, this.graph && this.graph._version++, this.onSlotPropertyChanged && this.onSlotPropertyChanged(Y.OUTPUT, e, n, t, i, s) === !1 && (n.properties[t] = s); + setOutputSlotProperty(t, e, i) { + if (!(!this.outputs || !this.graph) && !(t == -1 || t >= this.outputs.length)) { + var n = this.outputs[t]; + if (n && (n.properties || (n.properties = {}), i !== n.properties[e])) { + var s = n.properties[e]; + n.properties[e] = i, this.graph && this.graph._version++, this.onSlotPropertyChanged && this.onSlotPropertyChanged(W.OUTPUT, t, n, e, i, s) === !1 && (n.properties[e] = s); } } } /** sets the output data */ - setOutputData(e, t) { - if (!(!this.outputs || !this.graph) && !(e == -1 || e >= this.outputs.length)) { - var i = this.outputs[e]; - if (i && (u.serialize_slot_data ? i._data = t : i._data = void 0, this.outputs[e].links)) - for (var n = 0; n < this.outputs[e].links.length; n++) { - var s = this.outputs[e].links[n], r = this.graph.links[s]; - r && (r.data = t); + setOutputData(t, e) { + if (!(!this.outputs || !this.graph) && !(t == -1 || t >= this.outputs.length)) { + var i = this.outputs[t]; + if (i && (u.serialize_slot_data ? i._data = e : i._data = void 0, this.outputs[t].links)) + for (var n = 0; n < this.outputs[t].links.length; n++) { + var s = this.outputs[t].links[n], r = this.graph.links[s]; + r && (r.data = e); } } } /** sets the output data */ - setOutputDataType(e, t) { - if (this.outputs && !(e == -1 || e >= this.outputs.length)) { - var i = this.outputs[e]; - if (i && (i.type = t, this.outputs[e].links)) - for (let n = this.outputs[e].links.length - 1; n >= 0; n--) { - const s = this.outputs[e].links[n], r = this.graph.links[s]; + setOutputDataType(t, e) { + if (this.outputs && !(t == -1 || t >= this.outputs.length)) { + var i = this.outputs[t]; + if (i && (i.type = e, this.outputs[t].links)) + for (let n = this.outputs[t].links.length - 1; n >= 0; n--) { + const s = this.outputs[t].links[n], r = this.graph.links[s]; if (r) { - r.type = t; + r.type = e; const o = this.graph.getNodeById(r.target_id); if (o) { const a = o.getInputInfo(r.target_slot); - a && !u.isValidConnection(t, a.type) && o.disconnectInput(r.target_slot); + a && !u.isValidConnection(e, a.type) && o.disconnectInput(r.target_slot); } } } } } *iterateInputInfo() { - for (let e = 0; e < this.inputs.length; e++) - yield this.inputs[e]; + for (let t = 0; t < this.inputs.length; t++) + yield this.inputs[t]; } /** * Retrieves the input data (data traveling through the connection) from one slot @@ -2089,12 +2089,12 @@ const Ne = class { * @param force_update if set to true it will force the connected node of this slot to output data into this link * @return data or if it is not connected returns undefined */ - getInputData(e, t) { - if (!(!this.inputs || !this.graph) && !(e >= this.inputs.length || this.inputs[e].link == null)) { - var i = this.inputs[e].link, n = this.graph.links[i]; + getInputData(t, e) { + if (!(!this.inputs || !this.graph) && !(t >= this.inputs.length || this.inputs[t].link == null)) { + var i = this.inputs[t].link, n = this.graph.links[i]; if (!n) - return u.debug && console.error(`Link not found in slot ${e}!`, this, this.inputs[e], i), null; - if (!t) + return u.debug && console.error(`Link not found in slot ${t}!`, this, this.inputs[t], i), null; + if (!e) return n.data; var s = this.graph.getNodeById(n.origin_id); return s && (s.updateOutputData ? s.updateOutputData(n.origin_slot) : s.onExecute && s.onExecute(null, {})), n.data; @@ -2105,12 +2105,12 @@ const Ne = class { * @param slot * @return datatype in string format */ - getInputDataType(e) { - if (!this.inputs || e >= this.inputs.length || this.inputs[e].link == null) + getInputDataType(t) { + if (!this.inputs || t >= this.inputs.length || this.inputs[t].link == null) return null; - var t = this.inputs[e].link, i = this.graph.links[t]; + var e = this.inputs[t].link, i = this.graph.links[e]; if (!i) - return u.debug && console.error(`Link not found in slot ${e}!`, this, this.inputs[e], t), null; + return u.debug && console.error(`Link not found in slot ${t}!`, this, this.inputs[t], e), null; var n = this.graph.getNodeById(i.origin_id); if (!n) return i.type; @@ -2123,71 +2123,71 @@ const Ne = class { * @param force_update if set to true it will force the connected node of this slot to output data into this link * @return data or if it is not connected returns null */ - getInputDataByName(e, t) { - var i = this.findInputSlotIndexByName(e); - return i == -1 ? null : this.getInputData(i, t); + getInputDataByName(t, e) { + var i = this.findInputSlotIndexByName(t); + return i == -1 ? null : this.getInputData(i, e); } /** tells you if there is a connection in one input slot */ - isInputConnected(e) { - return this.inputs ? e < this.inputs.length && this.inputs[e].link != null : !1; + isInputConnected(t) { + return this.inputs ? t < this.inputs.length && this.inputs[t].link != null : !1; } /** tells you info about an input connection (which node, type, etc) */ - getInputInfo(e) { - return this.inputs && e < this.inputs.length ? this.inputs[e] : null; + getInputInfo(t) { + return this.inputs && t < this.inputs.length ? this.inputs[t] : null; } /** * Returns the link info in the connection of an input slot * @param {number} slot * @return {LLink} object or null */ - getInputLink(e) { + getInputLink(t) { if (!this.inputs || !this.graph) return null; - if (e < this.inputs.length) { - var t = this.inputs[e]; - return this.graph.links[t.link]; + if (t < this.inputs.length) { + var e = this.inputs[t]; + return this.graph.links[e.link]; } return null; } /** returns the node connected in the input slot */ - getInputNode(e) { + getInputNode(t) { if (!this.inputs || !this.graph) return null; - if (e < this.inputs.length) { - const i = this.inputs[e].link, n = this.graph.links[i]; + if (t < this.inputs.length) { + const i = this.inputs[t].link, n = this.graph.links[i]; if (!n) - return u.debug && console.error(`Link not found in slot ${e}!`, this, this.inputs[e], i), null; - var t = this.graph.getNodeById(n.origin_id); - if (t) - return t; + return u.debug && console.error(`Link not found in slot ${t}!`, this, this.inputs[t], i), null; + var e = this.graph.getNodeById(n.origin_id); + if (e) + return e; } return null; } /** returns the value of an input with this name, otherwise checks if there is a property with that name */ - getInputOrProperty(e) { + getInputOrProperty(t) { if (!this.inputs || !this.inputs.length || !this.graph) - return this.properties ? this.properties[e] : null; - for (var t = 0, i = this.inputs.length; t < i; ++t) { - var n = this.inputs[t]; - if (e == n.name && n.link != null) { + return this.properties ? this.properties[t] : null; + for (var e = 0, i = this.inputs.length; e < i; ++e) { + var n = this.inputs[e]; + if (t == n.name && n.link != null) { var s = this.graph.links[n.link]; if (s) return s.data; } } - return this.properties[e]; + return this.properties[t]; } /** sets the input data type */ - setInputDataType(e, t) { - if (!(!this.inputs || !this.graph) && !(e == -1 || e >= this.inputs.length)) { - var i = this.inputs[e]; - if (i && (i.type = t, i.link)) { + setInputDataType(t, e) { + if (!(!this.inputs || !this.graph) && !(t == -1 || t >= this.inputs.length)) { + var i = this.inputs[t]; + if (i && (i.type = e, i.link)) { const n = i.link, s = this.graph.links[n]; - s.type = t; + s.type = e; const r = this.graph.getNodeById(s.origin_id); if (r) { const o = r.getOutputInfo(s.origin_slot); - o && !u.isValidConnection(o.type, t) && r.disconnectOutput(s.origin_slot); + o && !u.isValidConnection(o.type, e) && r.disconnectOutput(s.origin_slot); } } } @@ -2197,42 +2197,42 @@ const Ne = class { * @param {number} slot * @return {LLink} object or null */ - getOutputSlotConnectedTo(e) { + getOutputSlotConnectedTo(t) { if (!this.outputs || !this.graph) return null; - if (e >= 0 && e < this.outputs.length) { - var t = this.inputs[e]; - if (t.link) { - const i = this.graph.links[t.link]; + if (t >= 0 && t < this.outputs.length) { + var e = this.inputs[t]; + if (e.link) { + const i = this.graph.links[e.link]; return this.graph.getNodeById(i.origin_id).outputs[i.origin_slot]; } } return null; } *iterateOutputInfo() { - for (let e = 0; e < this.outputs.length; e++) - yield this.outputs[e]; + for (let t = 0; t < this.outputs.length; t++) + yield this.outputs[t]; } /** tells you the last output data that went in that slot */ - getOutputData(e) { - if (!this.outputs || !this.graph || e >= this.outputs.length) + getOutputData(t) { + if (!this.outputs || !this.graph || t >= this.outputs.length) return null; - var t = this.outputs[e]; - return t._data; + var e = this.outputs[t]; + return e._data; } /** * Returns the link info in the connection of an output slot * @param {number} slot * @return {LLink} object or null */ - getOutputLinks(e) { + getOutputLinks(t) { if (!this.outputs || !this.graph) return []; - if (e >= 0 && e < this.outputs.length) { - var t = this.outputs[e]; - if (t.links) { + if (t >= 0 && t < this.outputs.length) { + var e = this.outputs[t]; + if (e.links) { var i = []; - for (const n of t.links) + for (const n of e.links) i.push(this.graph.links[n]); return i; } @@ -2244,14 +2244,14 @@ const Ne = class { * @param {number} slot * @return {LLink} object or null */ - getInputSlotsConnectedTo(e) { + getInputSlotsConnectedTo(t) { if (!this.outputs || !this.graph) return []; - if (e >= 0 && e < this.outputs.length) { - var t = this.outputs[e]; - if (t.links) { + if (t >= 0 && t < this.outputs.length) { + var e = this.outputs[t]; + if (e.links) { var i = []; - for (const n of t.links) { + for (const n of e.links) { const s = this.graph.links[n], r = this.graph.getNodeById(s.target_id); i.push(r.inputs[s.target_slot]); } @@ -2261,31 +2261,31 @@ const Ne = class { return []; } /** tells you info about an output connection (which node, type, etc) */ - getOutputInfo(e) { - return this.outputs && e < this.outputs.length ? this.outputs[e] : null; + getOutputInfo(t) { + return this.outputs && t < this.outputs.length ? this.outputs[t] : null; } /** tells you if there is a connection in one output slot */ - isOutputConnected(e) { - return !this.outputs || !this.graph ? !1 : e < this.outputs.length && this.outputs[e].links && this.outputs[e].links.length > 0; + isOutputConnected(t) { + return !this.outputs || !this.graph ? !1 : t < this.outputs.length && this.outputs[t].links && this.outputs[t].links.length > 0; } /** tells you if there is any connection in the output slots */ isAnyOutputConnected() { if (!this.outputs || !this.graph) return !1; - for (var e = 0; e < this.outputs.length; ++e) - if (this.outputs[e].links && this.outputs[e].links.length) + for (var t = 0; t < this.outputs.length; ++t) + if (this.outputs[t].links && this.outputs[t].links.length) return !0; return !1; } /** retrieves all the nodes connected to this output slot */ - getOutputNodes(e) { - if (!this.outputs || this.outputs.length == 0 || !this.graph || e >= this.outputs.length) + getOutputNodes(t) { + if (!this.outputs || this.outputs.length == 0 || !this.graph || t >= this.outputs.length) return null; - var t = this.outputs[e]; - if (!t.links || t.links.length == 0) + var e = this.outputs[t]; + if (!e.links || e.links.length == 0) return null; - for (var i = [], n = 0; n < t.links.length; n++) { - var s = t.links[n], r = this.graph.links[s]; + for (var i = [], n = 0; n < e.links.length; n++) { + var s = e.links[n], r = this.graph.links[s]; if (r) { var o = this.graph.getNodeById(r.target_id); o && i.push(o); @@ -2295,41 +2295,41 @@ const Ne = class { } *iterateAllLinks() { if (this.graph) { - for (const e of this.iterateInputInfo()) - if (e.link) { - const t = this.graph.links[e.link]; - t && (yield t); + for (const t of this.iterateInputInfo()) + if (t.link) { + const e = this.graph.links[t.link]; + e && (yield e); } - for (const e of this.iterateOutputInfo()) - if (e.links != null) - for (const t of e.links) { - const i = this.graph.links[t]; + for (const t of this.iterateOutputInfo()) + if (t.links != null) + for (const e of t.links) { + const i = this.graph.links[e]; i && (yield i); } } } addOnTriggerInput() { - var e = this.findInputSlotIndexByName("onTrigger"); - if (e == -1) { + var t = this.findInputSlotIndexByName("onTrigger"); + if (t == -1) { //!trigS || return this.addInput("onTrigger", I.EVENT, { optional: !0, nameLocked: !0 }), this.findInputSlotIndexByName("onTrigger"); } - return e; + return t; } addOnExecutedOutput() { - var e = this.findOutputSlotIndexByName("onExecuted"); - if (e == -1) { + var t = this.findOutputSlotIndexByName("onExecuted"); + if (t == -1) { //!trigS || return this.addOutput("onExecuted", I.ACTION, { optional: !0, nameLocked: !0 }), this.findOutputSlotIndexByName("onExecuted"); } - return e; + return t; } - onAfterExecuteNode(e, t) { + onAfterExecuteNode(t, e) { var i = this.findOutputSlotIndexByName("onExecuted"); - i != -1 && this.triggerSlot(i, e, null, t); + i != -1 && this.triggerSlot(i, t, null, e); } - changeMode(e) { - switch (e) { + changeMode(t) { + switch (t) { case Z.ON_EVENT: break; case Z.ON_TRIGGER: @@ -2344,10 +2344,10 @@ const Ne = class { default: return !1; } - return this.mode = e, !0; + return this.mode = t, !0; } - doExecute(e, t = {}) { - this.onExecute && (t.action_call || (t.action_call = this.id + "_exec_" + Math.floor(Math.random() * 9999)), this.graph.nodes_executing[this.id] = !0, this.onExecute(e, t), this.graph.nodes_executing[this.id] = !1, this.exec_version = this.graph.iteration, t && t.action_call && (this.action_call = t.action_call, this.graph.nodes_executedAction[this.id] = t.action_call)), this.execute_triggered = 2, this.onAfterExecuteNode && this.onAfterExecuteNode(e, t); + doExecute(t, e = {}) { + this.onExecute && (e.action_call || (e.action_call = this.id + "_exec_" + Math.floor(Math.random() * 9999)), this.graph.nodes_executing[this.id] = !0, this.onExecute(t, e), this.graph.nodes_executing[this.id] = !1, this.exec_version = this.graph.iteration, e && e.action_call && (this.action_call = e.action_call, this.graph.nodes_executedAction[this.id] = e.action_call)), this.execute_triggered = 2, this.onAfterExecuteNode && this.onAfterExecuteNode(t, e); } /** * Triggers an action, wrapped by logics to control execution flow @@ -2355,16 +2355,16 @@ const Ne = class { * @param {String} action name * @param {*} param */ - actionDo(e, t, i = {}) { - this.onAction && (i.action_call || (i.action_call = this.id + "_" + (e || "action") + "_" + Math.floor(Math.random() * 9999)), this.graph.nodes_actioning[this.id] = e || "actioning", this.onAction(e, t, i), this.graph.nodes_actioning[this.id] = !1, i && i.action_call && (this.action_call = i.action_call, this.graph.nodes_executedAction[this.id] = i.action_call)), this.action_triggered = 2, this.onAfterExecuteNode && this.onAfterExecuteNode(t, i); + actionDo(t, e, i = {}) { + this.onAction && (i.action_call || (i.action_call = this.id + "_" + (t || "action") + "_" + Math.floor(Math.random() * 9999)), this.graph.nodes_actioning[this.id] = t || "actioning", this.onAction(t, e, i), this.graph.nodes_actioning[this.id] = !1, i && i.action_call && (this.action_call = i.action_call, this.graph.nodes_executedAction[this.id] = i.action_call)), this.action_triggered = 2, this.onAfterExecuteNode && this.onAfterExecuteNode(e, i); } /** Triggers an event in this node, this will trigger any output with the same name */ - trigger(e, t, i) { + trigger(t, e, i) { if (!(!this.outputs || !this.outputs.length)) { this.graph && (this.graph._last_trigger_time = u.getTime()); for (var n = 0; n < this.outputs.length; ++n) { var s = this.outputs[n]; - !s || s.type !== I.EVENT || e && s.name != e || this.triggerSlot(n, t, null, i); + !s || s.type !== I.EVENT || t && s.name != t || this.triggerSlot(n, e, null, i); } } } @@ -2374,14 +2374,14 @@ const Ne = class { * @param param * @param link_id in case you want to trigger and specific output link in a slot */ - triggerSlot(e, t, i, n = {}) { + triggerSlot(t, e, i, n = {}) { if (this.outputs) { - if (e == null) { + if (t == null) { console.error("slot must be a number"); return; } - typeof e != "number" && console.warn("slot must be a number, use node.trigger('name') if you want to use a string"); - var s = this.outputs[e]; + typeof t != "number" && console.warn("slot must be a number, use node.trigger('name') if you want to use a string"); + var s = this.outputs[t]; if (s) { var r = s.links; if (!(!r || !r.length)) { @@ -2395,11 +2395,11 @@ const Ne = class { var h = this.graph.getNodeById(l.target_id); if (h) { if (h.inputs[l.target_slot], n.link = l, n.originNode = this, h.mode === Z.ON_TRIGGER) - n.action_call || (n.action_call = this.id + "_trigg_" + Math.floor(Math.random() * 9999)), h.onExecute && h.doExecute(t, n); + n.action_call || (n.action_call = this.id + "_trigg_" + Math.floor(Math.random() * 9999)), h.onExecute && h.doExecute(e, n); else if (h.onAction) { n.action_call || (n.action_call = this.id + "_act_" + Math.floor(Math.random() * 9999)); const p = h.inputs[l.target_slot]; - h.actionDo(p.name, t, n); + h.actionDo(p.name, e, n); } } } @@ -2414,15 +2414,15 @@ const Ne = class { * @param slot the index of the output slot * @param link_id in case you want to trigger and specific output link in a slot */ - clearTriggeredSlot(e, t) { + clearTriggeredSlot(t, e) { if (this.outputs) { - var i = this.outputs[e]; + var i = this.outputs[t]; if (i) { var n = i.links; if (!(!n || !n.length)) for (var s = 0; s < n.length; ++s) { var r = n[s]; - if (!(t != null && t != r)) { + if (!(e != null && e != r)) { var o = this.graph.links[n[s]]; o && (o._last_time = 0); } @@ -2435,8 +2435,8 @@ const Ne = class { * @method setSize * @param {vec2} size */ - setSize(e) { - this.size = e, this.onResize && this.onResize(this.size); + setSize(t) { + this.size = t, this.onResize && this.onResize(this.size); } /** * add a new property to this node @@ -2445,12 +2445,12 @@ const Ne = class { * @param type string defining the output type ("vec3","number",...) * @param extra_info this can be used to have special properties of the property (like values, etc) */ - addProperty(e, t, i, n) { - var s = { name: e, type: i, default_value: t }; + addProperty(t, e, i, n) { + var s = { name: t, type: i, default_value: e }; if (n) for (var r in n) s[r] = n[r]; - return this.properties_info || (this.properties_info = []), this.properties_info.push(s), this.properties || (this.properties = {}), this.properties[e] = t, s; + return this.properties_info || (this.properties_info = []), this.properties_info.push(s), this.properties || (this.properties = {}), this.properties[t] = e, s; } /** * add a new output slot to use in this node @@ -2458,41 +2458,41 @@ const Ne = class { * @param type string defining the output type ("vec3","number",...) * @param extra_info this can be used to have special properties of an output (label, special color, position, etc) */ - addOutput(e, t = I.DEFAULT, i) { - var n = { name: e, type: t, links: [], properties: {} }; + addOutput(t, e = I.DEFAULT, i) { + var n = { name: t, type: e, links: [], properties: {} }; if (i) for (var s in i) n[s] = i[s]; - return (n.shape == null || n.shape == k.DEFAULT) && (t == "array" ? n.shape = k.GRID_SHAPE : (t === I.EVENT || t === I.ACTION) && (n.shape = k.BOX_SHAPE)), (t === I.EVENT || t === I.ACTION) && (n.shape = k.BOX_SHAPE), this.outputs || (this.outputs = []), this.outputs.push(n), this.onOutputAdded && this.onOutputAdded(n), u.auto_load_slot_types && u.registerNodeAndSlotType(this, t, !0), this.setSize(this.computeSize()), this.setDirtyCanvas(!0, !0), n; + return (n.shape == null || n.shape == k.DEFAULT) && (e == "array" ? n.shape = k.GRID_SHAPE : (e === I.EVENT || e === I.ACTION) && (n.shape = k.BOX_SHAPE)), (e === I.EVENT || e === I.ACTION) && (n.shape = k.BOX_SHAPE), this.outputs || (this.outputs = []), this.outputs.push(n), this.onOutputAdded && this.onOutputAdded(n), u.auto_load_slot_types && u.registerNodeAndSlotType(this, e, !0), this.setSize(this.computeSize()), this.setDirtyCanvas(!0, !0), n; } /** remove an existing output slot */ - removeOutput(e) { - const t = this.outputs[e]; - this.disconnectOutput(e), this.outputs.splice(e, 1); - for (var i = e; i < this.outputs.length; ++i) + removeOutput(t) { + const e = this.outputs[t]; + this.disconnectOutput(t), this.outputs.splice(t, 1); + for (var i = t; i < this.outputs.length; ++i) if (!(!this.outputs[i] || !this.outputs[i].links)) for (var n = this.outputs[i].links, s = 0; s < n.length; ++s) { var r = this.graph.links[n[s]]; r && (r.origin_slot -= 1); } - this.setSize(this.computeSize()), this.onOutputRemoved && this.onOutputRemoved(e, t), this.setDirtyCanvas(!0, !0); + this.setSize(this.computeSize()), this.onOutputRemoved && this.onOutputRemoved(t, e), this.setDirtyCanvas(!0, !0); } - moveOutput(e, t) { - const i = this.outputs[e]; - if (i == null || t < 0 || t > this.outputs.length - 1) + moveOutput(t, e) { + const i = this.outputs[t]; + if (i == null || e < 0 || e > this.outputs.length - 1) return; - const n = this.outputs[t]; + const n = this.outputs[e]; if (i.links) for (const s of i.links) { const r = this.graph.links[s]; - r.origin_slot = t; + r.origin_slot = e; } if (n.links) for (const s of n.links) { const r = this.graph.links[s]; - r.origin_slot = e; + r.origin_slot = t; } - this.outputs[t] = i, this.outputs[e] = n; + this.outputs[e] = i, this.outputs[t] = n; } /** * add a new input slot to use in this node @@ -2500,37 +2500,37 @@ const Ne = class { * @param type string defining the input type ("vec3","number",...), it its a generic one use 0 * @param extra_info this can be used to have special properties of an input (label, color, position, etc) */ - addInput(e, t = I.DEFAULT, i) { - var n = { name: e, type: t, link: null, properties: {} }; + addInput(t, e = I.DEFAULT, i) { + var n = { name: t, type: e, link: null, properties: {} }; if (i) for (var s in i) n[s] = i[s]; - return (n.shape == null || n.shape == k.DEFAULT) && (t == "array" ? n.shape = k.GRID_SHAPE : (t === I.EVENT || t === I.ACTION) && (n.shape = k.BOX_SHAPE)), this.inputs || (this.inputs = []), this.inputs.push(n), this.setSize(this.computeSize()), this.onInputAdded && this.onInputAdded(n), u.registerNodeAndSlotType(this, t), this.setDirtyCanvas(!0, !0), n; + return (n.shape == null || n.shape == k.DEFAULT) && (e == "array" ? n.shape = k.GRID_SHAPE : (e === I.EVENT || e === I.ACTION) && (n.shape = k.BOX_SHAPE)), this.inputs || (this.inputs = []), this.inputs.push(n), this.setSize(this.computeSize()), this.onInputAdded && this.onInputAdded(n), u.registerNodeAndSlotType(this, e), this.setDirtyCanvas(!0, !0), n; } /** remove an existing input slot */ - removeInput(e) { - this.disconnectInput(e); - for (var t = this.inputs.splice(e, 1), i = e; i < this.inputs.length; ++i) + removeInput(t) { + this.disconnectInput(t); + for (var e = this.inputs.splice(t, 1), i = t; i < this.inputs.length; ++i) if (this.inputs[i]) { var n = this.graph.links[this.inputs[i].link]; n && (n.target_slot -= 1); } - this.setSize(this.computeSize()), this.onInputRemoved && this.onInputRemoved(e, t[0]), this.setDirtyCanvas(!0, !0); + this.setSize(this.computeSize()), this.onInputRemoved && this.onInputRemoved(t, e[0]), this.setDirtyCanvas(!0, !0); } - moveInput(e, t) { - const i = this.inputs[e]; - if (i == null || t < 0 || t > this.inputs.length - 1) + moveInput(t, e) { + const i = this.inputs[t]; + if (i == null || e < 0 || e > this.inputs.length - 1) return; - const n = this.inputs[t]; + const n = this.inputs[e]; if (i.link != null) { const s = this.graph.links[i.link]; - s.target_slot = t; + s.target_slot = e; } if (n.link != null) { const s = this.graph.links[n.link]; - s.target_slot = e; + s.target_slot = t; } - this.inputs[t] = i, this.inputs[e] = n; + this.inputs[e] = i, this.inputs[t] = n; } /** * add an special connection to this node (used for special kinds of graphs) @@ -2539,10 +2539,10 @@ const Ne = class { * @param pos position of the connection inside the node * @param direction if is input or output */ - addConnection(e, t, i, n) { + addConnection(t, e, i, n) { let s = { - name: e, - type: t, + name: t, + type: e, pos: i, direction: n, links: null @@ -2550,14 +2550,14 @@ const Ne = class { return this.connections.push(s), s; } /** computes the size of a node according to its inputs and output slots */ - computeSize(e = [0, 0]) { - const t = ye(this, "overrideSize"); - if (t) - return t.concat(); + computeSize(t = [0, 0]) { + const e = ye(this, "overrideSize"); + if (e) + return e.concat(); var i = Math.max( this.inputs ? this.inputs.length : 1, this.outputs ? this.outputs.length : 1 - ), n = e; + ), n = t; i = Math.max(i, 1); var s = u.NODE_TEXT_SIZE, r = d(this.title), o = 0, a = 0; if (this.inputs) @@ -2595,73 +2595,73 @@ const Ne = class { * @param {String} property name of the property * @return {Object} the object with all the available info */ - getPropertyInfo(e) { - var t = null; + getPropertyInfo(t) { + var e = null; if (this.properties_info) { for (var i = 0; i < this.properties_info.length; ++i) - if (this.properties_info[i].name == e) { - t = this.properties_info[i]; + if (this.properties_info[i].name == t) { + e = this.properties_info[i]; break; } } - return this.constructor["@" + e] && (t = this.constructor["@" + e]), this.constructor.widgets_info && this.constructor.widgets_info[e] && (t = this.constructor.widgets_info[e]), !t && this.onGetPropertyInfo && (t = this.onGetPropertyInfo(e)), t || (t = {}), t.type || (t.type = typeof this.properties[e]), t.widget == "combo" && (t.type = "enum"), t; + return this.constructor["@" + t] && (e = this.constructor["@" + t]), this.constructor.widgets_info && this.constructor.widgets_info[t] && (e = this.constructor.widgets_info[t]), !e && this.onGetPropertyInfo && (e = this.onGetPropertyInfo(t)), e || (e = {}), e.type || (e.type = typeof this.properties[t]), e.widget == "combo" && (e.type = "enum"), e; } /** * https://github.com/jagenjo/litegraph.js/blob/master/guides/README.md#node-widgets * @return created widget */ - addWidget(e, t, i, n, s) { + addWidget(t, e, i, n, s) { this.widgets || (this.widgets = []), !s && n && n.constructor === Object && (s = n, n = null), s && s.constructor === String && (s = { property: s }), n && n.constructor === String && (s || (s = {}), s.property = n, n = null), n && n.constructor !== Function && (console.warn("addWidget: callback must be a function"), n = null); var r = { - type: e.toLowerCase(), - name: t, + type: t.toLowerCase(), + name: e, value: i, callback: n, options: s || {} }; - if (r.options.y !== void 0 && (r.y = r.options.y), !n && !r.options.callback && !r.options.property && console.warn("LiteGraph addWidget(...) without a callback or property assigned"), e == "combo" && !r.options.values) + if (r.options.y !== void 0 && (r.y = r.options.y), !n && !r.options.callback && !r.options.property && console.warn("LiteGraph addWidget(...) without a callback or property assigned"), t == "combo" && !r.options.values) throw "LiteGraph addWidget('combo',...) requires to pass values in options: { values:['red','blue'] }"; return this.widgets.push(r), this.setSize(this.computeSize()), r; } - addCustomWidget(e) { - return this.widgets || (this.widgets = []), this.widgets.push(e), this.setSize(this.computeSize()), e; + addCustomWidget(t) { + return this.widgets || (this.widgets = []), this.widgets.push(t), this.setSize(this.computeSize()), t; } - setWidgetHidden(e, t) { - e.hidden = t, this.setSize(this.computeSize()); + setWidgetHidden(t, e) { + t.hidden = e, this.setSize(this.computeSize()); } /** * returns the bounding of the object, used for rendering purposes * @return [x, y, width, height] */ - getBounding(e) { - return e = e || new Float32Array(4), e[0] = this.pos[0] - 4, e[1] = this.pos[1] - u.NODE_TITLE_HEIGHT, e[2] = this.size[0] + 4, e[3] = this.flags.collapsed ? u.NODE_TITLE_HEIGHT : this.size[1] + u.NODE_TITLE_HEIGHT, this.onBounding && this.onBounding(e), e; + getBounding(t) { + return t = t || new Float32Array(4), t[0] = this.pos[0] - 4, t[1] = this.pos[1] - u.NODE_TITLE_HEIGHT, t[2] = this.size[0] + 4, t[3] = this.flags.collapsed ? u.NODE_TITLE_HEIGHT : this.size[1] + u.NODE_TITLE_HEIGHT, this.onBounding && this.onBounding(t), t; } /** checks if a point is inside the shape of a node */ - isPointInside(e, t, i = 0, n = !1) { + isPointInside(t, e, i = 0, n = !1) { var s = this.graph && this.graph.isLive() ? 0 : u.NODE_TITLE_HEIGHT; if (n && (s = 0), this.flags && this.flags.collapsed) { if (u.isInsideRectangle( - e, t, + e, this.pos[0] - i, this.pos[1] - u.NODE_TITLE_HEIGHT - i, (this._collapsed_width || u.NODE_COLLAPSED_WIDTH) + 2 * i, u.NODE_TITLE_HEIGHT + 2 * i )) return !0; - } else if (this.pos[0] - 4 - i < e && this.pos[0] + this.size[0] + 4 + i > e && this.pos[1] - s - i < t && this.pos[1] + this.size[1] + i > t) + } else if (this.pos[0] - 4 - i < t && this.pos[0] + this.size[0] + 4 + i > t && this.pos[1] - s - i < e && this.pos[1] + this.size[1] + i > e) return !0; return !1; } /** checks if a point is inside a node slot, and returns info about which slot */ - getSlotInPosition(e, t) { + getSlotInPosition(t, e) { var i = [0, 0]; if (this.inputs) for (var n = 0, s = this.inputs.length; n < s; ++n) { var r = this.inputs[n]; if (this.getConnectionPos(!0, n, i), u.isInsideRectangle( - e, t, + e, i[0] - 10, i[1] - 5, 20, @@ -2673,8 +2673,8 @@ const Ne = class { for (var n = 0, s = this.outputs.length; n < s; ++n) { var o = this.outputs[n]; if (this.getConnectionPos(!1, n, i), u.isInsideRectangle( - e, t, + e, i[0] - 10, i[1] - 5, 20, @@ -2684,28 +2684,28 @@ const Ne = class { } return null; } - is(e) { - const t = e.__LITEGRAPH_TYPE__; - return t != null && this.type === t; + is(t) { + const e = t.__LITEGRAPH_TYPE__; + return e != null && this.type === e; } /** * returns the input slot with a given name (used for dynamic slots), -1 if not found * @param name the name of the slot * @return the slot (-1 if not found) */ - findInputSlotIndexByName(e, t = !1, i) { + findInputSlotIndexByName(t, e = !1, i) { if (!this.inputs) return -1; for (var n = 0, s = this.inputs.length; n < s; ++n) - if (!(t && this.inputs[n].link && this.inputs[n].link != null) && !(i && i.includes(this.inputs[n].type)) && (!e || e == this.inputs[n].name)) + if (!(e && this.inputs[n].link && this.inputs[n].link != null) && !(i && i.includes(this.inputs[n].type)) && (!t || t == this.inputs[n].name)) return n; return -1; } - findInputSlotByName(e, t = !1, i) { + findInputSlotByName(t, e = !1, i) { if (!this.inputs) return null; for (var n = 0, s = this.inputs.length; n < s; ++n) - if (!(t && this.inputs[n].link && this.inputs[n].link != null) && !(i && i.includes(this.inputs[n].type)) && (!e || e == this.inputs[n].name)) + if (!(e && this.inputs[n].link && this.inputs[n].link != null) && !(i && i.includes(this.inputs[n].type)) && (!t || t == this.inputs[n].name)) return this.inputs[n]; return null; } @@ -2714,45 +2714,45 @@ const Ne = class { * @param name the name of the slot * @return the slot (-1 if not found) */ - findOutputSlotIndexByName(e, t = !1, i) { + findOutputSlotIndexByName(t, e = !1, i) { if (!this.outputs) return -1; for (var n = 0, s = this.outputs.length; n < s; ++n) - if (!(t && this.outputs[n].links && this.outputs[n].links != null) && !(i && i.includes(this.outputs[n].type)) && (!e || e == this.outputs[n].name)) + if (!(e && this.outputs[n].links && this.outputs[n].links != null) && !(i && i.includes(this.outputs[n].type)) && (!t || t == this.outputs[n].name)) return n; return -1; } - findOutputSlotByName(e, t = !1, i) { + findOutputSlotByName(t, e = !1, i) { if (!this.outputs) return null; for (var n = 0, s = this.outputs.length; n < s; ++n) - if (!(t && this.outputs[n].links && this.outputs[n].links != null) && !(i && i.includes(this.outputs[n].type)) && (!e || e == this.outputs[n].name)) + if (!(e && this.outputs[n].links && this.outputs[n].links != null) && !(i && i.includes(this.outputs[n].type)) && (!t || t == this.outputs[n].name)) return this.outputs[n]; return null; } /** * findSlotByType for INPUTS */ - findInputSlotIndexByType(e, t = !1, i = !1) { - return this.findSlotByType(!0, e, !1, t, i); + findInputSlotIndexByType(t, e = !1, i = !1) { + return this.findSlotByType(!0, t, !1, e, i); } /** * findSlotByType for OUTPUTS */ - findOutputSlotIndexByType(e, t = !1, i = !1) { - return this.findSlotByType(!1, e, !1, t, i); + findOutputSlotIndexByType(t, e = !1, i = !1) { + return this.findSlotByType(!1, t, !1, e, i); } /** * findSlotByType for INPUTS */ - findInputSlotByType(e, t = !1, i = !1) { - return this.findSlotByType(!0, e, !1, t, i); + findInputSlotByType(t, e = !1, i = !1) { + return this.findSlotByType(!0, t, !1, e, i); } /** * findSlotByType for OUTPUTS */ - findOutputSlotByType(e, t = !1, i = !1) { - return this.findSlotByType(!1, e, !1, t, i); + findOutputSlotByType(t, e = !1, i = !1) { + return this.findSlotByType(!1, t, !1, e, i); } /** * returns the output (or input) slot with a given type, -1 if not found @@ -2762,14 +2762,14 @@ const Ne = class { * @param {boolean} preferFreeSlot if we want a free slot (if not found, will return the first of the type anyway) * @return {number_or_object} the slot (-1 if not found) */ - findSlotByType(e, t, i, n = !1, s = !1) { + findSlotByType(t, e, i, n = !1, s = !1) { n = n || !1, s = s || !1; - var r = e ? this.inputs : this.outputs; + var r = t ? this.inputs : this.outputs; if (!r) return i ? null : -1; - (t == "" || t == "*") && (t = 0); + (e == "" || e == "*") && (e = 0); for (var o = 0, a = r.length; o < a; ++o) { - var l = (t + "").toLowerCase().split(","), h = r[o].type == "0" || r[o].type == "*" ? "0" : r[o].type; + var l = (e + "").toLowerCase().split(","), h = r[o].type == "0" || r[o].type == "*" ? "0" : r[o].type; let p = (h + "").toLowerCase().split(","); for (let f = 0; f < l.length; f++) for (let c = 0; c < p.length; c++) @@ -2782,7 +2782,7 @@ const Ne = class { } if (n && !s) for (var o = 0, a = r.length; o < a; ++o) { - var l = (t + "").toLowerCase().split(","), h = r[o].type == "0" || r[o].type == "*" ? "0" : r[o].type; + var l = (e + "").toLowerCase().split(","), h = r[o].type == "0" || r[o].type == "*" ? "0" : r[o].type; let g = (h + "").toLowerCase().split(","); for (let d = 0; d < l.length; d++) for (let _ = 0; _ < g.length; _++) @@ -2799,31 +2799,31 @@ const Ne = class { * @param {string} target_type the input slot type of the target node * @return {Object} the link_info is created, otherwise null */ - connectByTypeInput(e, t, i, n = {}) { + connectByTypeInput(t, e, i, n = {}) { var s = { createEventInCase: !0, firstFreeIfOutputGeneralInCase: !0, generalTypeInCase: !0 }, r = Object.assign(s, n); - t && t.constructor === Number && (t = this.graph.getNodeById(t)); + e && e.constructor === Number && (e = this.graph.getNodeById(e)); let o = i; i === I.EVENT ? o = I.ACTION : i === I.ACTION && (o = I.EVENT); - let a = t.findInputSlotIndexByType(o, !0); + let a = e.findInputSlotIndexByType(o, !0); if (a >= 0 && a !== null) - return u.debug && console.debug("CONNbyTYPE type " + i + " for " + a), this.connect(e, t, a); + return u.debug && console.debug("CONNbyTYPE type " + i + " for " + a), this.connect(t, e, a); if (u.debug && console.log("type " + i + " not found or not free?"), r.createEventInCase && i == I.EVENT) - return u.debug && console.debug("connect WILL CREATE THE onTrigger " + i + " to " + t), this.connect(e, t, -1); + return u.debug && console.debug("connect WILL CREATE THE onTrigger " + i + " to " + e), this.connect(t, e, -1); if (r.generalTypeInCase) { - let l = t.findInputSlotIndexByType(I.DEFAULT, !0, !0); - if (u.debug && console.debug("connect TO a general type (*, 0), if not found the specific type ", i, " to ", t, "RES_SLOT:", l), l >= 0) - return this.connect(e, t, l); + let l = e.findInputSlotIndexByType(I.DEFAULT, !0, !0); + if (u.debug && console.debug("connect TO a general type (*, 0), if not found the specific type ", i, " to ", e, "RES_SLOT:", l), l >= 0) + return this.connect(t, e, l); } if (r.firstFreeIfOutputGeneralInCase && (i == 0 || i == "*" || i == "")) { - let l = t.findInputSlotIndexByName(null, !0, [I.EVENT]); - if (u.debug && console.debug("connect TO TheFirstFREE ", i, " to ", t, "RES_SLOT:", l), l >= 0) - return this.connect(e, t, l); + let l = e.findInputSlotIndexByName(null, !0, [I.EVENT]); + if (u.debug && console.debug("connect TO TheFirstFREE ", i, " to ", e, "RES_SLOT:", l), l >= 0) + return this.connect(t, e, l); } - return u.debug && console.error("no way to connect type: ", i, " to targetNODE ", t), null; + return u.debug && console.error("no way to connect type: ", i, " to targetNODE ", e), null; } /** * connect this node input to the output of another node BY TYPE @@ -2833,31 +2833,31 @@ const Ne = class { * @param {string} target_type the output slot type of the target node * @return {Object} the link_info is created, otherwise null */ - connectByTypeOutput(e, t, i, n = {}) { + connectByTypeOutput(t, e, i, n = {}) { var s = { createEventInCase: !0, firstFreeIfInputGeneralInCase: !0, generalTypeInCase: !0 }, r = Object.assign(s, n); - t && t.constructor === Number && (t = this.graph.getNodeById(t)); + e && e.constructor === Number && (e = this.graph.getNodeById(e)); let o = i; - if (i === I.EVENT ? o = I.ACTION : i === I.ACTION && (o = I.EVENT), a = t.findOutputSlotIndexByType(o, !0), a >= 0 && a !== null) - return console.debug("CONNbyTYPE OUT! type " + i + " for " + a + " to " + o), t.connect(a, this, e); + if (i === I.EVENT ? o = I.ACTION : i === I.ACTION && (o = I.EVENT), a = e.findOutputSlotIndexByType(o, !0), a >= 0 && a !== null) + return console.debug("CONNbyTYPE OUT! type " + i + " for " + a + " to " + o), e.connect(a, this, t); if (r.generalTypeInCase) { - var a = t.findOutputSlotIndexByType(0, !0, !0); + var a = e.findOutputSlotIndexByType(0, !0, !0); if (a >= 0) - return t.connect(a, this, e); + return e.connect(a, this, t); } if ((r.createEventInCase && i == I.EVENT || i == I.ACTION) && u.do_add_triggers_slots) { - var a = t.addOnExecutedOutput(); - return t.connect(a, this, e); + var a = e.addOnExecutedOutput(); + return e.connect(a, this, t); } if (r.firstFreeIfInputGeneralInCase && (i == 0 || i == "*" || i == "")) { - let l = t.findOutputSlotIndexByName(null, !0, [I.EVENT, I.ACTION]); + let l = e.findOutputSlotIndexByName(null, !0, [I.EVENT, I.ACTION]); if (l >= 0) - return t.connect(l, this, e); + return e.connect(l, this, t); } - return console.error("no way to connect byOUT type: ", i, " to sourceNODE ", t), console.error("type OUT! " + i + " not found or not free?"), null; + return console.error("no way to connect byOUT type: ", i, " to sourceNODE ", e), console.error("type OUT! " + i + " not found or not free?"), null; } /** * connect this node output to the input of another node @@ -2866,45 +2866,45 @@ const Ne = class { * @param targetSlot the input slot of the target node (could be the number of the slot or the string with the name of the slot, or -1 to connect a trigger) * @return {Object} the linkInfo is created, otherwise null */ - connect(e, t, i) { + connect(t, e, i) { if (i = i || 0, !this.graph) throw new Error("Connect: Error, node doesn't belong to any graph. Nodes must be added first to a graph before connecting them."); - if (typeof e == "string") { - if (e = this.findOutputSlotIndexByName(e), e == -1) - return u.debug && console.error("Connect: Error, no slot of name " + e), null; - } else if (!this.outputs || e >= this.outputs.length) + if (typeof t == "string") { + if (t = this.findOutputSlotIndexByName(t), t == -1) + return u.debug && console.error("Connect: Error, no slot of name " + t), null; + } else if (!this.outputs || t >= this.outputs.length) return u.debug && console.error("Connect: Error, slot number not found"), null; - if (t && t.constructor === Number && (t = this.graph.getNodeById(t)), !t) + if (e && e.constructor === Number && (e = this.graph.getNodeById(e)), !e) throw "target node is null"; - if (t == this) + if (e == this) return u.debug && console.error("Connect: Error, can't connect node to itself!"), null; - if (!t.graph) + if (!e.graph) throw new Error("Connect: Error, target node doesn't belong to any graph. Nodes must be added first to a graph before connecting them."); if (typeof i == "string") { - if (i = t.findInputSlotIndexByName(i), i == -1) + if (i = e.findInputSlotIndexByName(i), i == -1) return u.debug && console.error( "Connect: Error, no slot of name " + i ), null; } else if (i === I.EVENT) if (u.do_add_triggers_slots) - t.changeMode(Z.ON_TRIGGER), i = t.findInputSlotIndexByName("onTrigger"); + e.changeMode(Z.ON_TRIGGER), i = e.findInputSlotIndexByName("onTrigger"); else return u.debug && console.error("Connect: Error, can't connect event target slot"), null; - else if (!t.inputs || i >= t.inputs.length) + else if (!e.inputs || i >= e.inputs.length) return u.debug && console.error("Connect: Error, slot number not found"), null; - var n = !1, s = t.inputs[i], r = null, o = this.outputs[e]; - if (!this.outputs[e]) - return u.debug && (console.warn("Connect: Invalid slot passed: " + e), console.warn(this.outputs)), null; - if (t.onBeforeConnectInput && (i = t.onBeforeConnectInput(i)), i === -1 || i === null || !u.isValidConnection(o.type, s.type)) + var n = !1, s = e.inputs[i], r = null, o = this.outputs[t]; + if (!this.outputs[t]) + return u.debug && (console.warn("Connect: Invalid slot passed: " + t), console.warn(this.outputs)), null; + if (e.onBeforeConnectInput && (i = e.onBeforeConnectInput(i)), i === -1 || i === null || !u.isValidConnection(o.type, s.type)) return this.setDirtyCanvas(!1, !0), n && this.graph.connectionChange(this, r), console.warn("Connect: Invalid connection: ", i, o.type, s.type), null; - if (u.debug && console.debug("valid connection", o.type, s.type), t.onConnectInput && t.onConnectInput(i, o.type, o, this, e) === !1) + if (u.debug && console.debug("valid connection", o.type, s.type), e.onConnectInput && e.onConnectInput(i, o.type, o, this, t) === !1) return u.debug && console.debug("onConnectInput blocked", o.type, s.type), null; - if (this.onConnectOutput && this.onConnectOutput(e, s.type, s, t, i) === !1) + if (this.onConnectOutput && this.onConnectOutput(t, s.type, s, e, i) === !1) return u.debug && console.debug("onConnectOutput blocked", o.type, s.type), null; - if (t.inputs[i] && t.inputs[i].link != null && (this.graph.beforeChange(), t.disconnectInput(i, { doProcessChange: !1 }), n = !0), o.links !== null && o.links.length) + if (e.inputs[i] && e.inputs[i].link != null && (this.graph.beforeChange(), e.disconnectInput(i, { doProcessChange: !1 }), n = !0), o.links !== null && o.links.length) switch (o.type) { case I.EVENT: - u.allow_multi_output_for_events || (this.graph.beforeChange(), this.disconnectOutput(e, null, { doProcessChange: !1 }), n = !0); + u.allow_multi_output_for_events || (this.graph.beforeChange(), this.disconnectOutput(t, null, { doProcessChange: !1 }), n = !0); break; } let a; @@ -2912,32 +2912,32 @@ const Ne = class { a, s.type || o.type, this.id, - e, - t.id, + t, + e.id, i - ), this.graph.links[r.id] && console.error("Link already exists in graph!", r.id, r, this.graph.links[r.id]), this.graph.links[r.id] = r, o.links == null && (o.links = []), o.links.push(r.id), t.inputs[i].link = r.id, this.graph && this.graph._version++, this.onConnectionsChange && this.onConnectionsChange( - Y.OUTPUT, - e, + ), this.graph.links[r.id] && console.error("Link already exists in graph!", r.id, r, this.graph.links[r.id]), this.graph.links[r.id] = r, o.links == null && (o.links = []), o.links.push(r.id), e.inputs[i].link = r.id, this.graph && this.graph._version++, this.onConnectionsChange && this.onConnectionsChange( + W.OUTPUT, + t, !0, r, o - ), t.onConnectionsChange && t.onConnectionsChange( - Y.INPUT, + ), e.onConnectionsChange && e.onConnectionsChange( + W.INPUT, i, !0, r, s ), this.graph && this.graph.onNodeConnectionChange && (this.graph.onNodeConnectionChange( - Y.INPUT, - t, + W.INPUT, + e, i, this, - e + t ), this.graph.onNodeConnectionChange( - Y.OUTPUT, + W.OUTPUT, this, - e, t, + e, i )), this.setDirtyCanvas(!1, !0), this.graph.afterChange(), this.graph.connectionChange(this, r), r; } @@ -2947,46 +2947,46 @@ const Ne = class { * @param targetNode the target node to which this slot is connected [Optional, if not targetNode is specified all nodes will be disconnected] * @return if it was disconnected successfully */ - disconnectOutput(e, t, i) { - if (typeof e == "string") { - if (e = this.findOutputSlotIndexByName(e), e == -1) - return u.debug && console.error("Connect: Error, no slot of name " + e), !1; - } else if (!this.outputs || e >= this.outputs.length) + disconnectOutput(t, e, i) { + if (typeof t == "string") { + if (t = this.findOutputSlotIndexByName(t), t == -1) + return u.debug && console.error("Connect: Error, no slot of name " + t), !1; + } else if (!this.outputs || t >= this.outputs.length) return u.debug && console.error("Connect: Error, slot number not found"), !1; - var n = this.outputs[e]; + var n = this.outputs[t]; if (!n || !n.links || n.links.length == 0) return !1; - if (t) { - if (t.constructor === Number && (t = this.graph.getNodeById(t)), !t) + if (e) { + if (e.constructor === Number && (e = this.graph.getNodeById(e)), !e) throw "Target Node not found"; for (var s = 0, r = n.links.length; s < r; s++) { var o = n.links[s], a = this.graph.links[o]; - if (a.target_id == t.id) { + if (a.target_id == e.id) { n.links.splice(s, 1); - var l = t.inputs[a.target_slot]; - l.link = null, delete this.graph.links[o], this.graph && this.graph._version++, t.onConnectionsChange && t.onConnectionsChange( - Y.INPUT, + var l = e.inputs[a.target_slot]; + l.link = null, delete this.graph.links[o], this.graph && this.graph._version++, e.onConnectionsChange && e.onConnectionsChange( + W.INPUT, a.target_slot, !1, a, l ), this.onConnectionsChange && this.onConnectionsChange( - Y.OUTPUT, - e, + W.OUTPUT, + t, !1, a, n ), this.graph && this.graph.onNodeConnectionChange && this.graph.onNodeConnectionChange( - Y.OUTPUT, + W.OUTPUT, this, - e + t ), this.graph && this.graph.onNodeConnectionChange && (this.graph.onNodeConnectionChange( - Y.OUTPUT, + W.OUTPUT, this, - e + t ), this.graph.onNodeConnectionChange( - Y.INPUT, - t, + W.INPUT, + e, a.target_slot )); break; @@ -2996,30 +2996,30 @@ const Ne = class { for (var s = 0, r = n.links.length; s < r; s++) { var o = n.links[s], a = this.graph.links[o]; if (a) { - var t = this.graph.getNodeById(a.target_id), l = null; - this.graph && this.graph._version++, t && (l = t.inputs[a.target_slot], l.link = null, t.onConnectionsChange && t.onConnectionsChange( - Y.INPUT, + var e = this.graph.getNodeById(a.target_id), l = null; + this.graph && this.graph._version++, e && (l = e.inputs[a.target_slot], l.link = null, e.onConnectionsChange && e.onConnectionsChange( + W.INPUT, a.target_slot, !1, a, l ), this.graph && this.graph.onNodeConnectionChange && this.graph.onNodeConnectionChange( - Y.INPUT, - t, + W.INPUT, + e, a.target_slot )), delete this.graph.links[o], this.onConnectionsChange && this.onConnectionsChange( - Y.OUTPUT, - e, + W.OUTPUT, + t, !1, a, n ), this.graph && this.graph.onNodeConnectionChange && (this.graph.onNodeConnectionChange( - Y.OUTPUT, + W.OUTPUT, this, - e + t ), this.graph.onNodeConnectionChange( - Y.INPUT, - t, + W.INPUT, + e, a.target_slot )); } @@ -3033,18 +3033,18 @@ const Ne = class { * @param slot (could be the number of the slot or the string with the name of the slot) * @return if it was disconnected successfully */ - disconnectInput(e, t = {}) { - if (typeof e == "string") { - if (e = this.findInputSlotIndexByName(e), e == -1) - return u.debug && console.error("Connect: Error, no slot of name " + e), !1; - } else if (!this.inputs || e >= this.inputs.length) + disconnectInput(t, e = {}) { + if (typeof t == "string") { + if (t = this.findInputSlotIndexByName(t), t == -1) + return u.debug && console.error("Connect: Error, no slot of name " + t), !1; + } else if (!this.inputs || t >= this.inputs.length) return u.debug && console.error("Connect: Error, slot number not found"), !1; - var i = this.inputs[e]; + var i = this.inputs[t]; if (!i) return !1; - var n = this.inputs[e].link; + var n = this.inputs[t].link; if (n != null) { - this.inputs[e].link = null; + this.inputs[t].link = null; var s = this.graph.links[n]; if (s) { var r = this.graph.getNodeById(s.origin_id); @@ -3059,22 +3059,22 @@ const Ne = class { break; } delete this.graph.links[n], this.graph && this.graph._version++, this.onConnectionsChange && this.onConnectionsChange( - Y.INPUT, - e, + W.INPUT, + t, !1, s, i ), r.onConnectionsChange && r.onConnectionsChange( - Y.OUTPUT, + W.OUTPUT, a, !1, s, o ), this.graph && this.graph.onNodeConnectionChange && (this.graph.onNodeConnectionChange( - Y.OUTPUT, + W.OUTPUT, r, a - ), this.graph.onNodeConnectionChange(Y.INPUT, this, e)); + ), this.graph.onNodeConnectionChange(W.INPUT, this, t)); } } return this.setDirtyCanvas(!1, !0), this.graph && this.graph.connectionChange(this), !0; @@ -3086,59 +3086,59 @@ const Ne = class { * @param out a place to store the output, to free garbage * @return the position **/ - getConnectionPos(e, t, i = [0, 0], n = !1) { + getConnectionPos(t, e, i = [0, 0], n = !1) { var s = 0; - e && this.inputs && (s = this.inputs.length), !e && this.outputs && (s = this.outputs.length); + t && this.inputs && (s = this.inputs.length), !t && this.outputs && (s = this.outputs.length); var r = u.NODE_SLOT_HEIGHT * 0.5; if (this.flags.collapsed && !n) { var o = this._collapsed_width || u.NODE_COLLAPSED_WIDTH; - return this.horizontal ? (i[0] = this.pos[0] + o * 0.5, e ? i[1] = this.pos[1] - u.NODE_TITLE_HEIGHT : i[1] = this.pos[1]) : (e ? i[0] = this.pos[0] : i[0] = this.pos[0] + o, i[1] = this.pos[1] - u.NODE_TITLE_HEIGHT * 0.5), i; + return this.horizontal ? (i[0] = this.pos[0] + o * 0.5, t ? i[1] = this.pos[1] - u.NODE_TITLE_HEIGHT : i[1] = this.pos[1]) : (t ? i[0] = this.pos[0] : i[0] = this.pos[0] + o, i[1] = this.pos[1] - u.NODE_TITLE_HEIGHT * 0.5), i; } - return e && t == -1 ? (i[0] = this.pos[0] + u.NODE_TITLE_HEIGHT * 0.5, i[1] = this.pos[1] + u.NODE_TITLE_HEIGHT * 0.5, i) : e && s > t && this.inputs[t].pos ? (i[0] = this.pos[0] + this.inputs[t].pos[0], i[1] = this.pos[1] + this.inputs[t].pos[1], i) : !e && s > t && this.outputs[t].pos ? (i[0] = this.pos[0] + this.outputs[t].pos[0], i[1] = this.pos[1] + this.outputs[t].pos[1], i) : this.horizontal ? (i[0] = this.pos[0] + (t + 0.5) * (this.size[0] / s), e ? i[1] = this.pos[1] - u.NODE_TITLE_HEIGHT : i[1] = this.pos[1] + this.size[1], i) : (e ? i[0] = this.pos[0] + r : i[0] = this.pos[0] + this.size[0] + 1 - r, i[1] = this.pos[1] + (t + 0.7) * u.NODE_SLOT_HEIGHT + (this.constructor.slot_start_y || 0), i); + return t && e == -1 ? (i[0] = this.pos[0] + u.NODE_TITLE_HEIGHT * 0.5, i[1] = this.pos[1] + u.NODE_TITLE_HEIGHT * 0.5, i) : t && s > e && this.inputs[e].pos ? (i[0] = this.pos[0] + this.inputs[e].pos[0], i[1] = this.pos[1] + this.inputs[e].pos[1], i) : !t && s > e && this.outputs[e].pos ? (i[0] = this.pos[0] + this.outputs[e].pos[0], i[1] = this.pos[1] + this.outputs[e].pos[1], i) : this.horizontal ? (i[0] = this.pos[0] + (e + 0.5) * (this.size[0] / s), t ? i[1] = this.pos[1] - u.NODE_TITLE_HEIGHT : i[1] = this.pos[1] + this.size[1], i) : (t ? i[0] = this.pos[0] + r : i[0] = this.pos[0] + this.size[0] + 1 - r, i[1] = this.pos[1] + (e + 0.7) * u.NODE_SLOT_HEIGHT + (this.constructor.slot_start_y || 0), i); } /** Force align to grid */ alignToGrid() { this.pos[0] = u.CANVAS_GRID_SIZE * Math.round(this.pos[0] / u.CANVAS_GRID_SIZE), this.pos[1] = u.CANVAS_GRID_SIZE * Math.round(this.pos[1] / u.CANVAS_GRID_SIZE); } /** Console output */ - trace(e) { - this.console || (this.console = []), this.console.push(e), this.console.length > Ne.MAX_CONSOLE && this.console.shift(), this.graph.onNodeTrace && this.graph.onNodeTrace(this, e); + trace(t) { + this.console || (this.console = []), this.console.push(t), this.console.length > Ne.MAX_CONSOLE && this.console.shift(), this.graph.onNodeTrace && this.graph.onNodeTrace(this, t); } /** Forces to redraw or the main canvas (LGraphNode) or the bg canvas (links) */ - setDirtyCanvas(e, t = !1) { - this.graph && this.graph.sendActionToCanvas("setDirty", [e, t]); + setDirtyCanvas(t, e = !1) { + this.graph && this.graph.sendActionToCanvas("setDirty", [t, e]); } - loadImage(e) { - var t = new Image(); - t.src = u.node_images_path + e; + loadImage(t) { + var e = new Image(); + e.src = u.node_images_path + t; var i = this; - return t.onload = function() { + return e.onload = function() { i.setDirtyCanvas(!0); - }, t; + }, e; } /** Allows to get onMouseMove and onMouseUp events even if the mouse is out of focus */ - captureInput(e) { + captureInput(t) { if (!(!this.graph || !this.graph.list_of_graphcanvas)) - for (var t = this.graph.list_of_graphcanvas, i = 0; i < t.length; ++i) { - var n = t[i]; - !e && n.node_capturing_input != this || (n.node_capturing_input = e ? this : null); + for (var e = this.graph.list_of_graphcanvas, i = 0; i < e.length; ++i) { + var n = e[i]; + !t && n.node_capturing_input != this || (n.node_capturing_input = t ? this : null); } } - isShowingTitle(e) { - return this.titleMode == se.TRANSPARENT_TITLE || this.titleMode == se.NO_TITLE ? !1 : (this.titleMode == se.AUTOHIDE_TITLE && e, !0); + isShowingTitle(t) { + return this.titleMode == se.TRANSPARENT_TITLE || this.titleMode == se.NO_TITLE ? !1 : (this.titleMode == se.AUTOHIDE_TITLE && t, !0); } /** Collapse the node to make it smaller on the canvas */ - collapse(e = !1) { - this.graph._version++, !(this.collapsable === !1 && !e) && (this.flags.collapsed ? this.flags.collapsed = !1 : this.flags.collapsed = !0, this.setDirtyCanvas(!0, !0)); + collapse(t = !1) { + this.graph._version++, !(this.collapsable === !1 && !t) && (this.flags.collapsed ? this.flags.collapsed = !1 : this.flags.collapsed = !0, this.setDirtyCanvas(!0, !0)); } /** Forces the node to do not move or realign on Z */ - pin(e) { - this.graph._version++, e === void 0 ? this.flags.pinned = !this.flags.pinned : this.flags.pinned = e; + pin(t) { + this.graph._version++, t === void 0 ? this.flags.pinned = !this.flags.pinned : this.flags.pinned = t; } - localToScreen(e, t, i) { + localToScreen(t, e, i) { return [ - (e + this.pos[0]) * i.ds.scale + i.ds.offset[0], - (t + this.pos[1]) * i.ds.scale + i.ds.offset[1] + (t + this.pos[0]) * i.ds.scale + i.ds.offset[0], + (e + this.pos[1]) * i.ds.scale + i.ds.offset[1] ]; } getOptionalSlots() { @@ -3148,15 +3148,15 @@ const Ne = class { let ae = Ne; ae.MAX_CONSOLE = 100; function we() { - let e = []; - return e = e.concat(Ae), e = e.concat([I.ACTION]), e = e.concat(u.slot_types_in.map((t) => t.toUpperCase())), e; + let t = []; + return t = t.concat(Ae), t = t.concat([I.ACTION]), t = t.concat(u.slot_types_in.map((e) => e.toUpperCase())), t; } -function Ye() { +function We() { return we().map(J); } class $ extends ae { - constructor(t) { - super(t), this.properties = { + constructor(e) { + super(e), this.properties = { name: "", type: "number", value: 0, @@ -3173,7 +3173,7 @@ class $ extends ae { "Type", J(this.properties.type), this.setType.bind(this), - { values: Ye } + { values: We } ) : this.typeWidget = this.addWidget( "text", "Type", @@ -3188,48 +3188,48 @@ class $ extends ae { } ), this.widgets_up = !0; } - setName(t) { - if (t == null || t === this.properties.name) + setName(e) { + if (e == null || e === this.properties.name) return; const i = this.getParentSubgraph(); - i && (t = i.getValidGraphInputName(t), this.setProperty("name", t)); + i && (e = i.getValidGraphInputName(e), this.setProperty("name", e)); } - setType(t) { - t || (t = "*"); - let i = t; - t === "-1" || t === "Action" ? i = I.ACTION : t === "-2" || t === "Event" ? i = I.EVENT : t === "0" && (i = "*"), this.setProperty("type", i); + setType(e) { + e || (e = "*"); + let i = e; + e === "-1" || e === "Action" ? i = I.ACTION : e === "-2" || e === "Event" ? i = I.EVENT : e === "0" && (i = "*"), this.setProperty("type", i); } onConfigure() { this.updateType(); } getParentSubgraph() { - var t, i; - return (i = (t = this.graph._subgraph_node) == null ? void 0 : t.graph) == null ? void 0 : i.getNodeById(this.properties.subgraphID); + var e, i; + return (i = (e = this.graph._subgraph_node) == null ? void 0 : e.graph) == null ? void 0 : i.getNodeById(this.properties.subgraphID); } /** ensures the type in the node output and the type in the associated graph input are the same */ updateType() { - var t = this.properties.type; - this.typeWidget.value = J(t); + var e = this.properties.type; + this.typeWidget.value = J(e); const i = this.outputs[0]; - i.type != t && (u.isValidConnection(i.type, t) || this.disconnectOutput(0), i.type = t), t == "array" ? i.shape = k.GRID_SHAPE : t === I.EVENT || t === I.ACTION ? i.shape = k.BOX_SHAPE : i.shape = k.DEFAULT, t == "number" ? (this.valueWidget.type = "number", this.valueWidget.value = 0) : t == "boolean" ? (this.valueWidget.type = "toggle", this.valueWidget.value = !0) : t == "string" ? (this.valueWidget.type = "text", this.valueWidget.value = "") : (this.valueWidget.type = null, this.valueWidget.value = null), this.properties.value = this.valueWidget.value, this.graph && this.nameInGraph && Se(t) ? (this.graph.changeInputType(this.nameInGraph, t), i.type !== t && this.setOutputDataType(0, t)) : console.error("[GraphInput] Can't change output to type", t, this.graph, this.nameInGraph); + i.type != e && (u.isValidConnection(i.type, e) || this.disconnectOutput(0), i.type = e), e == "array" ? i.shape = k.GRID_SHAPE : e === I.EVENT || e === I.ACTION ? i.shape = k.BOX_SHAPE : i.shape = k.DEFAULT, e == "number" ? (this.valueWidget.type = "number", this.valueWidget.value = 0) : e == "boolean" ? (this.valueWidget.type = "toggle", this.valueWidget.value = !0) : e == "string" ? (this.valueWidget.type = "text", this.valueWidget.value = "") : (this.valueWidget.type = null, this.valueWidget.value = null), this.properties.value = this.valueWidget.value, this.graph && this.nameInGraph && Se(e) ? (this.graph.changeInputType(this.nameInGraph, e), i.type !== e && this.setOutputDataType(0, e)) : console.error("[GraphInput] Can't change output to type", e, this.graph, this.nameInGraph); } /** this is executed AFTER the property has changed */ - onPropertyChanged(t, i) { - if (t == "name") { + onPropertyChanged(e, i) { + if (e == "name") { if (i == "" || i == this.nameInGraph || i == "enabled") return !1; this.graph && (this.nameInGraph ? this.graph.renameInput(this.nameInGraph, i) : this.graph.addInput(i, "" + this.properties.type, null)), this.nameWidget.value = i, this.nameInGraph = i; } else - t == "type" && this.updateType(); + e == "type" && this.updateType(); } getTitle() { return this.flags.collapsed ? this.properties.name : this.title; } - onAction(t, i) { + onAction(e, i) { this.properties.type == I.EVENT && this.triggerSlot(0, i); } onExecute() { - var t = this.properties.name, i = this.graph.inputs[t]; + var e = this.properties.name, i = this.graph.inputs[e]; if (!i) { this.setOutputData(0, this.properties.value); return; @@ -3254,15 +3254,15 @@ u.registerNodeType({ hide_in_node_lists: !0 }); function Le() { - let e = []; - return e = e.concat(Ae), e = e.concat([I.EVENT]), e = e.concat(u.slot_types_out), e; + let t = []; + return t = t.concat(Ae), t = t.concat([I.EVENT]), t = t.concat(u.slot_types_out), t; } -function We() { +function Ye() { return Le().map(J); } class Q extends ae { - constructor(t) { - super(t), this.properties = { + constructor(e) { + super(e), this.properties = { name: "", type: "number", subgraphID: null @@ -3276,7 +3276,7 @@ class Q extends ae { "Type", J(this.properties.type), this.setType.bind(this), - { values: We } + { values: Ye } ) : this.typeWidget = this.addWidget( "text", "Type", @@ -3284,42 +3284,42 @@ class Q extends ae { this.setType.bind(this) ), this.widgets_up = !0; } - setName(t) { - if (t == null || t === this.properties.name) + setName(e) { + if (e == null || e === this.properties.name) return; const i = this.getParentSubgraph(); - i && (t = i.getValidGraphOutputName(t), this.setProperty("name", t)); + i && (e = i.getValidGraphOutputName(e), this.setProperty("name", e)); } - setType(t) { - t || (t = "*"); - let i = t; - t === "-1" || t === "Action" ? i = I.ACTION : t === "-2" || t === "Event" ? i = I.EVENT : t === "0" && (i = "*"), this.setProperty("type", i); + setType(e) { + e || (e = "*"); + let i = e; + e === "-1" || e === "Action" ? i = I.ACTION : e === "-2" || e === "Event" ? i = I.EVENT : e === "0" && (i = "*"), this.setProperty("type", i); } onConfigure() { this.updateType(); } getParentSubgraph() { - var t, i; - return (i = (t = this.graph._subgraph_node) == null ? void 0 : t.graph) == null ? void 0 : i.getNodeById(this.properties.subgraphID); + var e, i; + return (i = (e = this.graph._subgraph_node) == null ? void 0 : e.graph) == null ? void 0 : i.getNodeById(this.properties.subgraphID); } updateType() { - var t = this.properties.type; + var e = this.properties.type; const i = this.inputs[0]; - this.typeWidget && (this.typeWidget.value = J(t)), t == "array" ? i.shape = k.GRID_SHAPE : t === I.EVENT || t === I.ACTION ? i.shape = k.BOX_SHAPE : i.shape = k.DEFAULT, i.type != t && ((t == "action" || t == "event") && (t = I.EVENT), u.isValidConnection(i.type, t) || this.disconnectInput(0), i.type = t), this.graph && this.nameInGraph && Se(t) ? (this.graph.changeOutputType(this.nameInGraph, t), i.type !== t && this.setInputDataType(0, t)) : console.error("Can't change GraphOutput to type", t, this.graph, this.nameInGraph); + this.typeWidget && (this.typeWidget.value = J(e)), e == "array" ? i.shape = k.GRID_SHAPE : e === I.EVENT || e === I.ACTION ? i.shape = k.BOX_SHAPE : i.shape = k.DEFAULT, i.type != e && ((e == "action" || e == "event") && (e = I.EVENT), u.isValidConnection(i.type, e) || this.disconnectInput(0), i.type = e), this.graph && this.nameInGraph && Se(e) ? (this.graph.changeOutputType(this.nameInGraph, e), i.type !== e && this.setInputDataType(0, e)) : console.error("Can't change GraphOutput to type", e, this.graph, this.nameInGraph); } /** this is executed AFTER the property has changed */ - onPropertyChanged(t, i) { - if (t == "name") { + onPropertyChanged(e, i) { + if (e == "name") { if (i == "" || i == this.nameInGraph || i == "enabled") return !1; - this.graph ? this.nameInGraph ? this.graph.renameOutput(this.nameInGraph, i) : this.graph.addOutput(i, "" + this.properties.type, null) : console.error("[GraphOutput] missing graph!", t, i), this.nameWidget.value = i, this.nameInGraph = i; + this.graph ? this.nameInGraph ? this.graph.renameOutput(this.nameInGraph, i) : this.graph.addOutput(i, "" + this.properties.type, null) : console.error("[GraphOutput] missing graph!", e, i), this.nameWidget.value = i, this.nameInGraph = i; } else - t == "type" && this.updateType(); + e == "type" && this.updateType(); } getTitle() { return this.flags.collapsed ? this.properties.name : this.title; } - onAction(t, i, n) { + onAction(e, i, n) { const s = this.getParentSubgraph(); if (!s) return; @@ -3327,8 +3327,8 @@ class Q extends ae { r == null || s.outputs[r] == null || s.triggerSlot(r, i); } onExecute() { - const t = this.getInputData(0); - this.graph.setOutputData(this.properties.name, t); + const e = this.getInputData(0); + this.graph.setOutputData(this.properties.name, e); } onRemoved() { this.nameInGraph && this.graph.removeOutput(this.nameInGraph); @@ -3347,10 +3347,10 @@ u.registerNodeType({ type: "graph/output", hide_in_node_lists: !0 }); -var xe = /* @__PURE__ */ ((e) => (e[e.STATUS_STOPPED = 1] = "STATUS_STOPPED", e[e.STATUS_RUNNING = 2] = "STATUS_RUNNING", e))(xe || {}); +var xe = /* @__PURE__ */ ((t) => (t[t.STATUS_STOPPED = 1] = "STATUS_STOPPED", t[t.STATUS_RUNNING = 2] = "STATUS_RUNNING", t))(xe || {}); const De = class { - constructor(e) { - this.supported_types = null, this.vars = {}, this.extra = {}, this.inputs = {}, this.outputs = {}, this.links = {}, this.list_of_graphcanvas = [], this._nodes = [], this._groups = [], this._nodes_by_id = {}, this._nodes_executable = null, this._nodes_in_order = [], this._version = -1, this._last_trigger_time = 0, this._is_subgraph = !1, this._subgraph_node = null, this.nodes_executing = [], this.nodes_actioning = [], this.nodes_executedAction = [], this.execution_timer_id = -1, this.execution_time = 0, this.errors_in_execution = !1, u.debug && console.log("Graph created"), this.list_of_graphcanvas = null, this.clear(), e && this.configure(e); + constructor(t) { + this.supported_types = null, this.vars = {}, this.extra = {}, this.inputs = {}, this.outputs = {}, this.links = {}, this.list_of_graphcanvas = [], this._nodes = [], this._groups = [], this._nodes_by_id = {}, this._nodes_executable = null, this._nodes_in_order = [], this._version = -1, this._last_trigger_time = 0, this._is_subgraph = !1, this._subgraph_node = null, this.nodes_executing = [], this.nodes_actioning = [], this.nodes_executedAction = [], this.execution_timer_id = -1, this.execution_time = 0, this.errors_in_execution = !1, u.debug && console.log("Graph created"), this.list_of_graphcanvas = null, this.clear(), t && this.configure(t); } getSupportedTypes() { return this.supported_types || De.DEFAULT_SUPPORTED_TYPES; @@ -3359,54 +3359,54 @@ const De = class { * Gets the root graph above any subgraphs. */ getRootGraph() { - const e = Array.from(this.iterateParentGraphs()), t = e[e.length - 1]; - return t._is_subgraph ? null : t; + const t = Array.from(this.iterateParentGraphs()), e = t[t.length - 1]; + return e._is_subgraph ? null : e; } *iterateParentGraphs() { - var t; - let e = this; - for (; e; ) - yield e, e = (t = e._subgraph_node) == null ? void 0 : t.graph; + var e; + let t = this; + for (; t; ) + yield t, t = (e = t._subgraph_node) == null ? void 0 : e.graph; } /** Removes all nodes from this graph */ clear() { if (this.stop(), this.status = 1, this.last_node_id = 0, this.last_link_id = 0, this._version = -1, this._nodes) - for (var e = 0; e < this._nodes.length; ++e) { - var t = this._nodes[e]; - t.onRemoved && t.onRemoved(); + for (var t = 0; t < this._nodes.length; ++t) { + var e = this._nodes[t]; + e.onRemoved && e.onRemoved(); } this._nodes = [], this._nodes_by_id = {}, this._nodes_in_order = [], this._nodes_executable = null, this._groups = [], this.links = {}, this.iteration = 0, this.config = {}, this.vars = {}, this.extra = {}, this.globaltime = 0, this.runningtime = 0, this.fixedtime = 0, this.fixedtime_lapse = 0.01, this.elapsed_time = 0.01, this.last_update_time = 0, this.starttime = 0, this.catch_errors = !0, this.nodes_executing = [], this.nodes_actioning = [], this.nodes_executedAction = [], this.inputs = {}, this.outputs = {}, this.change(), this.sendActionToCanvas("clear"); } /** Attach Canvas to this graph */ - attachCanvas(e) { - if (!(e instanceof N)) + attachCanvas(t) { + if (!(t instanceof N)) throw "attachCanvas expects a LGraphCanvas instance"; - e.graph && e.graph != this && e.graph.detachCanvas(e), e.graph = this, this.list_of_graphcanvas || (this.list_of_graphcanvas = []), this.list_of_graphcanvas.push(e); + t.graph && t.graph != this && t.graph.detachCanvas(t), t.graph = this, this.list_of_graphcanvas || (this.list_of_graphcanvas = []), this.list_of_graphcanvas.push(t); } /** Detach Canvas to this graph */ - detachCanvas(e) { + detachCanvas(t) { if (this.list_of_graphcanvas) { - var t = this.list_of_graphcanvas.indexOf(e); - t != -1 && (e.graph = null, this.list_of_graphcanvas.splice(t, 1)); + var e = this.list_of_graphcanvas.indexOf(t); + e != -1 && (t.graph = null, this.list_of_graphcanvas.splice(e, 1)); } } /** * Starts running this graph every interval milliseconds. * @param interval amount of milliseconds between executions, if 0 then it renders to the monitor refresh rate */ - start(e) { + start(t) { if (this.status != 2) { - this.status = 2, this.onPlayEvent && this.onPlayEvent(), this.sendEventToAllNodes("onStart"), this.starttime = u.getTime(), this.last_update_time = this.starttime, e = e || 0; - var t = this; - if (e == 0 && typeof window < "u" && window.requestAnimationFrame) { + this.status = 2, this.onPlayEvent && this.onPlayEvent(), this.sendEventToAllNodes("onStart"), this.starttime = u.getTime(), this.last_update_time = this.starttime, t = t || 0; + var e = this; + if (t == 0 && typeof window < "u" && window.requestAnimationFrame) { let i = function() { - t.execution_timer_id == -1 && (window.requestAnimationFrame(i), t.onBeforeStep && t.onBeforeStep(), t.runStep(1, !t.catch_errors), t.onAfterStep && t.onAfterStep()); + e.execution_timer_id == -1 && (window.requestAnimationFrame(i), e.onBeforeStep && e.onBeforeStep(), e.runStep(1, !e.catch_errors), e.onAfterStep && e.onAfterStep()); }; this.execution_timer_id = -1, i(); } else this.execution_timer_id = setInterval(function() { - t.onBeforeStep && t.onBeforeStep(), t.runStep(1, !t.catch_errors), t.onAfterStep && t.onAfterStep(); - }, e); + e.onBeforeStep && e.onBeforeStep(), e.runStep(1, !e.catch_errors), e.onAfterStep && e.onAfterStep(); + }, t); } } /** Stops the execution loop of the graph */ @@ -3418,13 +3418,13 @@ const De = class { * @param num number of steps to run, default is 1 * @param do_not_catch_errors if you want to try/catch errors */ - runStep(e = 1, t = !1, i) { + runStep(t = 1, e = !1, i) { var n = u.getTime(); this.globaltime = 1e-3 * (n - this.starttime); let s = this._nodes_executable ? this._nodes_executable : this._nodes; if (s) { - if (i = i || s.length, t) { - for (var r = 0; r < e; r++) { + if (i = i || s.length, e) { + for (var r = 0; r < t; r++) { for (var o = 0; o < i; ++o) { var a = s[o]; a.mode == Z.ALWAYS && a.onExecute && a.doExecute(); @@ -3434,7 +3434,7 @@ const De = class { this.onAfterExecute && this.onAfterExecute(); } else try { - for (var r = 0; r < e; r++) { + for (var r = 0; r < t; r++) { for (var o = 0; o < i; ++o) { var a = s[o]; a.mode == Z.ALWAYS && a.onExecute && a.onExecute(null, {}); @@ -3457,29 +3457,29 @@ const De = class { */ updateExecutionOrder() { this._nodes_in_order = this.computeExecutionOrder(!1), this._nodes_executable = []; - for (var e = 0; e < this._nodes_in_order.length; ++e) - if (this._nodes_in_order[e].onExecute) { - let t = this._nodes_in_order[e]; - this._nodes_executable.push(t); + for (var t = 0; t < this._nodes_in_order.length; ++t) + if (this._nodes_in_order[t].onExecute) { + let e = this._nodes_in_order[t]; + this._nodes_executable.push(e); } } - *computeExecutionOrderRecursive(e = !1, t) { - for (const i of this.computeExecutionOrder(e, t)) + *computeExecutionOrderRecursive(t = !1, e) { + for (const i of this.computeExecutionOrder(t, e)) if (yield i, i.is(ne)) - for (const n of i.subgraph.computeExecutionOrderRecursive(e, t)) + for (const n of i.subgraph.computeExecutionOrderRecursive(t, e)) yield n; } /** This is more internal, it computes the executable nodes in order and returns it */ - computeExecutionOrder(e = !1, t) { + computeExecutionOrder(t = !1, e) { for (var i = [], n = [], s = {}, r = {}, o = {}, a = 0, _ = this._nodes.length; a < _; ++a) { var l = this._nodes[a]; - if (!(e && !l.onExecute)) { + if (!(t && !l.onExecute)) { s[l.id] = l; var h = 0; if (l.inputs) for (var p = 0, f = l.inputs.length; p < f; p++) l.inputs[p] && l.inputs[p].link != null && (h += 1); - h == 0 ? (n.push(l), t && (l._level = 1)) : (t && (l._level = 0), o[l.id] = h); + h == 0 ? (n.push(l), e && (l._level = 1)) : (e && (l._level = 0), o[l.id] = h); } } for (; n.length != 0; ) { @@ -3496,7 +3496,7 @@ const De = class { r[g.id] = !0; continue; } - t && (!d._level || d._level <= y._level) && (d._level = y._level + 1), r[g.id] = !0, o[d.id] -= 1, o[d.id] == 0 && n.push(d); + e && (!d._level || d._level <= y._level) && (d._level = y._level + 1), r[g.id] = !0, o[d.id] -= 1, o[d.id] == 0 && n.push(d); } } } @@ -3519,45 +3519,45 @@ const De = class { * It doesn't include the node itself * @return an array with all the LGraphNodes that affect this node, in order of execution */ - getAncestors(e) { - for (var t = [], i = [e], n = {}; i.length; ) { + getAncestors(t) { + for (var e = [], i = [t], n = {}; i.length; ) { var s = i.shift(); if (s.inputs) { - !n[s.id] && s != e && (n[s.id] = !0, t.push(s)); + !n[s.id] && s != t && (n[s.id] = !0, e.push(s)); for (var r = 0; r < s.inputs.length; ++r) { var o = s.getInputNode(r); - o && t.indexOf(o) == -1 && i.push(o); + o && e.indexOf(o) == -1 && i.push(o); } } } - return t.sort(function(a, l) { + return e.sort(function(a, l) { return a.order - l.order; - }), t; + }), e; } /** * Positions every node in a more readable manner */ - arrange(e = 100, t = ue.HORIZONTAL_LAYOUT) { + arrange(t = 100, e = ue.HORIZONTAL_LAYOUT) { const i = this.computeExecutionOrder(!1, !0), n = []; for (let r = 0; r < i.length; ++r) { const o = i[r], a = o._level || 1; n[a] || (n[a] = []), n[a].push(o); } - let s = e; + let s = t; for (let r = 0; r < n.length; ++r) { const o = n[r]; if (!o) continue; - let a = 100, l = e + u.NODE_TITLE_HEIGHT; + let a = 100, l = t + u.NODE_TITLE_HEIGHT; for (let h = 0; h < o.length; ++h) { const p = o[h]; - p.pos[0] = t == ue.VERTICAL_LAYOUT ? l : s, p.pos[1] = t == ue.VERTICAL_LAYOUT ? s : l; - const f = t == ue.VERTICAL_LAYOUT ? 1 : 0; + p.pos[0] = e == ue.VERTICAL_LAYOUT ? l : s, p.pos[1] = e == ue.VERTICAL_LAYOUT ? s : l; + const f = e == ue.VERTICAL_LAYOUT ? 1 : 0; p.size[f] > a && (a = p.size[f]); - const c = t == ue.VERTICAL_LAYOUT ? 0 : 1; - l += p.size[c] + e + u.NODE_TITLE_HEIGHT; + const c = e == ue.VERTICAL_LAYOUT ? 0 : 1; + l += p.size[c] + t + u.NODE_TITLE_HEIGHT; } - s += a + e; + s += a + t; } this.setDirtyCanvas(!0, !0); } @@ -3587,123 +3587,123 @@ const De = class { * Iterates all nodes in this graph *excluding* subgraphs. */ *iterateNodesInOrder() { - const e = this._nodes_in_order ? this._nodes_in_order : this._nodes || []; - for (const t of e) - yield t; + const t = this._nodes_in_order ? this._nodes_in_order : this._nodes || []; + for (const e of t) + yield e; } /** * Iterates all nodes in this graph and subgraphs. */ *iterateNodesInOrderRecursive() { - const e = this._nodes_in_order ? this._nodes_in_order : this._nodes || []; - for (const t of e) - if (yield t, t.subgraph != null) - for (const i of t.subgraph.iterateNodesInOrderRecursive()) + const t = this._nodes_in_order ? this._nodes_in_order : this._nodes || []; + for (const e of t) + if (yield e, e.subgraph != null) + for (const i of e.subgraph.iterateNodesInOrderRecursive()) yield i; } /** * Iterates all nodes in this graph *excluding* subgraphs. */ - *iterateNodesOfClass(e) { - const t = e.__LITEGRAPH_TYPE__; - if (t != null) + *iterateNodesOfClass(t) { + const e = t.__LITEGRAPH_TYPE__; + if (e != null) for (const i of this.iterateNodesInOrder()) - i.type === t && (yield i); + i.type === e && (yield i); } /** * Iterates all nodes in this graph *excluding* subgraphs. */ - *iterateNodesOfClassRecursive(e) { - const t = e.__LITEGRAPH_TYPE__; - if (t != null) + *iterateNodesOfClassRecursive(t) { + const e = t.__LITEGRAPH_TYPE__; + if (e != null) for (const i of this.iterateNodesInOrderRecursive()) - i.type === t && (yield i); + i.type === e && (yield i); } /** * Iterates all nodes in this graph *excluding* subgraphs. */ - *iterateNodesOfTypeRecursive(e) { - for (const t of this.iterateNodesInOrderRecursive()) - t.type === e && (yield t); + *iterateNodesOfTypeRecursive(t) { + for (const e of this.iterateNodesInOrderRecursive()) + e.type === t && (yield e); } /** * Sends an event to all the nodes, useful to trigger stuff * @param eventName the name of the event (function to be called) * @param params parameters in array format */ - sendEventToAllNodes(e, t = [], i = Z.ALWAYS) { + sendEventToAllNodes(t, e = [], i = Z.ALWAYS) { var n = this._nodes_in_order ? this._nodes_in_order : this._nodes; if (n) for (const s of this.iterateNodesInOrder()) { - if (s.type === "basic/subgraph" && e != "onExecute") { - s.mode == i && s.sendEventToAllNodes(e, t, i); + if (s.type === "basic/subgraph" && t != "onExecute") { + s.mode == i && s.sendEventToAllNodes(t, e, i); continue; } - !s[e] || s.mode != i || (t === void 0 ? s[e]() : t && t.constructor === Array ? s[e].apply(s, t) : s[e](t)); + !s[t] || s.mode != i || (e === void 0 ? s[t]() : e && e.constructor === Array ? s[t].apply(s, e) : s[t](e)); } } - sendActionToCanvas(e, t = []) { + sendActionToCanvas(t, e = []) { if (this.list_of_graphcanvas) for (var i = 0; i < this.list_of_graphcanvas.length; ++i) { var n = this.list_of_graphcanvas[i]; - n[e] && n[e].apply(n, t); + n[t] && n[t].apply(n, e); } } - addGroup(e) { - return this._groups.push(e), this.setDirtyCanvas(!0), this.change(), e.graph = this, this._version++, e; + addGroup(t) { + return this._groups.push(t), this.setDirtyCanvas(!0), this.change(), t.graph = this, this._version++, t; } /** * Adds a new node instance to this graph * @param node the instance of the node */ - add(e, t = {}) { - if (e.id != -1 && this._nodes_by_id[e.id] != null && (console.warn( + add(t, e = {}) { + if (t.id != -1 && this._nodes_by_id[t.id] != null && (console.warn( "LiteGraph: there is already a node with this ID, changing it", - e.id - ), u.use_uuids ? e.id = oe() : e.id = ++this.last_node_id), t.pos && (isNaN(t.pos[0]) || isNaN(t.pos[1]))) + t.id + ), u.use_uuids ? t.id = oe() : t.id = ++this.last_node_id), e.pos && (isNaN(e.pos[0]) || isNaN(e.pos[1]))) throw "LiteGraph: Node position contained NaN(s)!"; if (this._nodes.length >= u.MAX_NUMBER_OF_NODES) throw "LiteGraph: max number of nodes in a graph reached"; - return u.use_uuids ? e.id || (e.id = oe()) : e.id == null || e.id == -1 ? e.id = ++this.last_node_id : this.last_node_id < e.id && (this.last_node_id = e.id), e.graph = this, this._version++, this._nodes.push(e), this._nodes_by_id[e.id] = e, t.pos && (e.pos = t.pos), e.onAdded && e.onAdded(this), this.config.align_to_grid && e.alignToGrid(), t.skipComputeOrder || this.updateExecutionOrder(), this.onNodeAdded && this.onNodeAdded(e, t), this.setDirtyCanvas(!0), this.change(), e; + return u.use_uuids ? t.id || (t.id = oe()) : t.id == null || t.id == -1 ? t.id = ++this.last_node_id : this.last_node_id < t.id && (this.last_node_id = t.id), t.graph = this, this._version++, this._nodes.push(t), this._nodes_by_id[t.id] = t, e.pos && (t.pos = e.pos), t.onAdded && t.onAdded(this), this.config.align_to_grid && t.alignToGrid(), e.skipComputeOrder || this.updateExecutionOrder(), this.onNodeAdded && this.onNodeAdded(t, e), this.setDirtyCanvas(!0), this.change(), t; } /** Removes a node from the graph */ - remove(e, t = {}) { - if (e instanceof me) { - var i = this._groups.indexOf(e); - i != -1 && this._groups.splice(i, 1), e.graph = null, this._version++, this.setDirtyCanvas(!0, !0), this.change(); + remove(t, e = {}) { + if (t instanceof me) { + var i = this._groups.indexOf(t); + i != -1 && this._groups.splice(i, 1), t.graph = null, this._version++, this.setDirtyCanvas(!0, !0), this.change(); return; } - if (this._nodes_by_id[e.id] != null && !e.ignore_remove) { - if (this.beforeChange(), e.inputs) - for (var n = 0; n < e.inputs.length; n++) { - var s = e.inputs[n]; - s.link != null && e.disconnectInput(n); + if (this._nodes_by_id[t.id] != null && !t.ignore_remove) { + if (this.beforeChange(), t.inputs) + for (var n = 0; n < t.inputs.length; n++) { + var s = t.inputs[n]; + s.link != null && t.disconnectInput(n); } - if (e.outputs) - for (var n = 0; n < e.outputs.length; n++) { - let l = e.outputs[n]; - l.links != null && l.links.length && e.disconnectOutput(n); + if (t.outputs) + for (var n = 0; n < t.outputs.length; n++) { + let l = t.outputs[n]; + l.links != null && l.links.length && t.disconnectOutput(n); } - if (e.onRemoved && e.onRemoved(t), e.graph = null, this._version++, this.list_of_graphcanvas) + if (t.onRemoved && t.onRemoved(e), t.graph = null, this._version++, this.list_of_graphcanvas) for (var n = 0; n < this.list_of_graphcanvas.length; ++n) { var r = this.list_of_graphcanvas[n]; - r.selected_nodes[e.id] && delete r.selected_nodes[e.id], r.node_dragged == e && (r.node_dragged = null); + r.selected_nodes[t.id] && delete r.selected_nodes[t.id], r.node_dragged == t && (r.node_dragged = null); } - var o = this._nodes.indexOf(e); - o != -1 && this._nodes.splice(o, 1), delete this._nodes_by_id[e.id], this.onNodeRemoved && this.onNodeRemoved(e, t), this.sendActionToCanvas("checkPanels"), this.setDirtyCanvas(!0, !0), this.afterChange(), this.change(), this.updateExecutionOrder(); + var o = this._nodes.indexOf(t); + o != -1 && this._nodes.splice(o, 1), delete this._nodes_by_id[t.id], this.onNodeRemoved && this.onNodeRemoved(t, e), this.sendActionToCanvas("checkPanels"), this.setDirtyCanvas(!0, !0), this.afterChange(), this.change(), this.updateExecutionOrder(); } } /** Returns a node by its id. */ - getNodeById(e) { - return e == null ? null : this._nodes_by_id[e]; + getNodeById(t) { + return t == null ? null : this._nodes_by_id[t]; } /** Returns a node by its id. */ - getNodeByIdRecursive(e) { - const t = this.getNodeById(e); - if (t != null) - return t; + getNodeByIdRecursive(t) { + const e = this.getNodeById(t); + if (e != null) + return e; for (const i of this.iterateNodesOfClass(ne)) { - const n = i.subgraph.getNodeByIdRecursive(e); + const n = i.subgraph.getNodeByIdRecursive(t); if (n) return n; } @@ -3714,56 +3714,56 @@ const De = class { * @param classObject the class itself (not an string) * @return a list with all the nodes of this type */ - findNodesByClass(e, t = []) { - t.length = 0; - for (const i of this.iterateNodesOfClass(e)) - t.push(i); - return t; + findNodesByClass(t, e = []) { + e.length = 0; + for (const i of this.iterateNodesOfClass(t)) + e.push(i); + return e; } /** * Returns a list of nodes that matches a type * @param type the name of the node type * @return a list with all the nodes of this type */ - findNodesByType(i, t = []) { + findNodesByType(i, e = []) { var i = i.toLowerCase(); - t.length = 0; + e.length = 0; for (var n = 0, s = this._nodes.length; n < s; ++n) - this._nodes[n].type.toLowerCase() == i && t.push(this._nodes[n]); - return t; + this._nodes[n].type.toLowerCase() == i && e.push(this._nodes[n]); + return e; } /** * Returns a list of nodes that matches a class * @param classObject the class itself (not an string) * @return a list with all the nodes of this type */ - findNodesByClassRecursive(e, t = []) { - t.length = 0; - for (const i of this.iterateNodesOfClassRecursive(e)) - t.push(i); - return t; + findNodesByClassRecursive(t, e = []) { + e.length = 0; + for (const i of this.iterateNodesOfClassRecursive(t)) + e.push(i); + return e; } /** * Returns a list of nodes that matches a type * @param type the name of the node type * @return a list with all the nodes of this type */ - findNodesByTypeRecursive(i, t = []) { + findNodesByTypeRecursive(i, e = []) { var i = i.toLowerCase(); - t.length = 0; + e.length = 0; for (const n of this.iterateNodesOfTypeRecursive(i)) - t.push(n); - return t; + e.push(n); + return e; } /** * Returns the first node that matches a name in its title * @param title the name of the node to search * @return the node or null */ - findNodeByTitle(e) { - for (var t = 0, i = this._nodes.length; t < i; ++t) - if (this._nodes[t].title == e) - return this._nodes[t]; + findNodeByTitle(t) { + for (var e = 0, i = this._nodes.length; e < i; ++e) + if (this._nodes[e].title == t) + return this._nodes[e]; return null; } /** @@ -3771,10 +3771,10 @@ const De = class { * @param title the name of the node to search * @return a list with all the nodes with this name */ - findNodesByTitle(e) { - for (var t = [], i = 0, n = this._nodes.length; i < n; ++i) - this._nodes[i].title == e && t.push(this._nodes[i]); - return t; + findNodesByTitle(t) { + for (var e = [], i = 0, n = this._nodes.length; i < n; ++i) + this._nodes[i].title == t && e.push(this._nodes[i]); + return e; } /** * Returns the top-most node in this position of the canvas @@ -3783,11 +3783,11 @@ const De = class { * @param nodesList a list with all the nodes to search from, by default is all the nodes in the graph * @return the node at this position or null */ - getNodeOnPos(e, t, i, n) { + getNodeOnPos(t, e, i, n) { i = i || this._nodes; for (var s = null, r = i.length - 1; r >= 0; r--) { var o = i[r], a = o.titleMode == se.NO_TITLE; - if (o.isPointInside(e, t, n, a)) + if (o.isPointInside(t, e, n, a)) return o; } return s; @@ -3798,10 +3798,10 @@ const De = class { * @param y the y coordinate in canvas space * @return the group or null */ - getGroupOnPos(e, t) { + getGroupOnPos(t, e) { for (var i = this._groups.length - 1; i >= 0; i--) { var n = this._groups[i]; - if (n.isPointInside(e, t, 2, !0)) + if (n.isPointInside(t, e, 2, !0)) return n; } return null; @@ -3812,93 +3812,93 @@ const De = class { * @method checkNodeTypes */ checkNodeTypes() { - for (var e = !1, t = 0; t < this._nodes.length; t++) { - var i = this._nodes[t], n = u.registered_node_types[i.type]; + for (var t = !1, e = 0; e < this._nodes.length; e++) { + var i = this._nodes[e], n = u.registered_node_types[i.type]; if (i.constructor != n.class) { console.log("node being replaced by newer version: " + i.type); var s = u.createNode(i.type); - e = !0, this._nodes[t] = s, s.configure(i.serialize()), s.graph = this, this._nodes_by_id[s.id] = s, i.inputs && (s.inputs = i.inputs.concat()), i.outputs && (s.outputs = i.outputs.concat()); + t = !0, this._nodes[e] = s, s.configure(i.serialize()), s.graph = this, this._nodes_by_id[s.id] = s, i.inputs && (s.inputs = i.inputs.concat()), i.outputs && (s.outputs = i.outputs.concat()); } } - return this.updateExecutionOrder(), e; + return this.updateExecutionOrder(), t; } // ********** GLOBALS ***************** - onAction(e, t, i = {}) { + onAction(t, e, i = {}) { for (const n of this.iterateNodesOfClass($)) - if (n.properties.name == e) { - n.actionDo(e, t, i); + if (n.properties.name == t) { + n.actionDo(t, e, i); break; } } - trigger(e, t) { - this.onTrigger && this.onTrigger(e, t); + trigger(t, e) { + this.onTrigger && this.onTrigger(t, e); } - triggerSlot(e, t) { - this.onTrigger && this.onTrigger(e, t); + triggerSlot(t, e) { + this.onTrigger && this.onTrigger(t, e); } /** Tell this graph it has a global graph input of this type */ - addInput(e, t, i) { - var n = this.inputs[e]; - n || (this.beforeChange(), this.inputs[e] = { name: e, type: t, value: i }, this._version++, this.afterChange(), this.onInputAdded && this.onInputAdded(e, t, i), this.onInputsOutputsChange && this.onInputsOutputsChange()); + addInput(t, e, i) { + var n = this.inputs[t]; + n || (this.beforeChange(), this.inputs[t] = { name: t, type: e, value: i }, this._version++, this.afterChange(), this.onInputAdded && this.onInputAdded(t, e, i), this.onInputsOutputsChange && this.onInputsOutputsChange()); } /** Assign a data to the global graph input */ - setInputData(e, t) { - var i = this.inputs[e]; - i && (i.value = t); + setInputData(t, e) { + var i = this.inputs[t]; + i && (i.value = e); } /** Returns the current value of a global graph input */ - getInputData(e) { - var t = this.inputs[e]; - return t ? t.value : null; + getInputData(t) { + var e = this.inputs[t]; + return e ? e.value : null; } /** Changes the name of a global graph input */ - renameInput(e, t) { - if (t != e) - return this.inputs[e] ? this.inputs[t] ? (console.error("there is already one input with that name"), !1) : (this.inputs[t] = this.inputs[e], delete this.inputs[e], this._version++, this.onInputRenamed && this.onInputRenamed(e, t), this.onInputsOutputsChange && this.onInputsOutputsChange(), !0) : !1; + renameInput(t, e) { + if (e != t) + return this.inputs[t] ? this.inputs[e] ? (console.error("there is already one input with that name"), !1) : (this.inputs[e] = this.inputs[t], delete this.inputs[t], this._version++, this.onInputRenamed && this.onInputRenamed(t, e), this.onInputsOutputsChange && this.onInputsOutputsChange(), !0) : !1; } /** Changes the type of a global graph input */ - changeInputType(e, t) { - if (!this.inputs[e]) + changeInputType(t, e) { + if (!this.inputs[t]) return !1; - if (this.inputs[e].type && String(this.inputs[e].type).toLowerCase() == String(t).toLowerCase()) + if (this.inputs[t].type && String(this.inputs[t].type).toLowerCase() == String(e).toLowerCase()) return; - const i = this.inputs[e].type; - return this.inputs[e].type = t, this._version++, this.onInputTypeChanged && this.onInputTypeChanged(e, i, t), !0; + const i = this.inputs[t].type; + return this.inputs[t].type = e, this._version++, this.onInputTypeChanged && this.onInputTypeChanged(t, i, e), !0; } /** Removes a global graph input */ - removeInput(e) { - return this.inputs[e] ? (delete this.inputs[e], this._version++, this.onInputRemoved && this.onInputRemoved(e), this.onInputsOutputsChange && this.onInputsOutputsChange(), !0) : !1; + removeInput(t) { + return this.inputs[t] ? (delete this.inputs[t], this._version++, this.onInputRemoved && this.onInputRemoved(t), this.onInputsOutputsChange && this.onInputsOutputsChange(), !0) : !1; } /** Creates a global graph output */ - addOutput(e, t, i) { - this.outputs[e] = { name: e, type: t, value: i }, this._version++, this.onOutputAdded && this.onOutputAdded(e, t, i), this.onInputsOutputsChange && this.onInputsOutputsChange(); + addOutput(t, e, i) { + this.outputs[t] = { name: t, type: e, value: i }, this._version++, this.onOutputAdded && this.onOutputAdded(t, e, i), this.onInputsOutputsChange && this.onInputsOutputsChange(); } /** Assign a data to the global output */ - setOutputData(e, t) { - var i = this.outputs[e]; - i && (i.value = t); + setOutputData(t, e) { + var i = this.outputs[t]; + i && (i.value = e); } /** Returns the current value of a global graph output */ - getOutputData(e) { - var t = this.outputs[e]; - return t ? t.value : null; + getOutputData(t) { + var e = this.outputs[t]; + return e ? e.value : null; } /** Renames a global graph output */ - renameOutput(e, t) { - return this.outputs[e] ? this.outputs[t] ? (console.error("there is already one output with that name"), !1) : (this.outputs[t] = this.outputs[e], delete this.outputs[e], this._version++, this.onOutputRenamed && this.onOutputRenamed(e, t), this.onInputsOutputsChange && this.onInputsOutputsChange(), !0) : !1; + renameOutput(t, e) { + return this.outputs[t] ? this.outputs[e] ? (console.error("there is already one output with that name"), !1) : (this.outputs[e] = this.outputs[t], delete this.outputs[t], this._version++, this.onOutputRenamed && this.onOutputRenamed(t, e), this.onInputsOutputsChange && this.onInputsOutputsChange(), !0) : !1; } /** Changes the type of a global graph output */ - changeOutputType(e, t) { - if (!this.outputs[e]) + changeOutputType(t, e) { + if (!this.outputs[t]) return !1; - if (this.outputs[e].type && String(this.outputs[e].type).toLowerCase() == String(t).toLowerCase()) + if (this.outputs[t].type && String(this.outputs[t].type).toLowerCase() == String(e).toLowerCase()) return; - const i = this.outputs[e].type; - return this.outputs[e].type = t, this._version++, this.onOutputTypeChanged && this.onOutputTypeChanged(e, i, t), !0; + const i = this.outputs[t].type; + return this.outputs[t].type = e, this._version++, this.onOutputTypeChanged && this.onOutputTypeChanged(t, i, e), !0; } /** Removes a global graph output */ - removeOutput(e) { - return this.outputs[e] ? (delete this.outputs[e], this._version++, this.onOutputRemoved && this.onOutputRemoved(e), this.onInputsOutputsChange && this.onInputsOutputsChange(), !0) : !1; + removeOutput(t) { + return this.outputs[t] ? (delete this.outputs[t], this._version++, this.onOutputRemoved && this.onOutputRemoved(t), this.onInputsOutputsChange && this.onInputsOutputsChange(), !0) : !1; } /* TODO implement triggerInput(name: string, value: any): void { @@ -3916,53 +3916,53 @@ const De = class { } */ /** used for undo, called before any change is made to the graph */ - beforeChange(e) { - this.onBeforeChange && this.onBeforeChange(this, e), this.sendActionToCanvas("onBeforeChange", [this]); + beforeChange(t) { + this.onBeforeChange && this.onBeforeChange(this, t), this.sendActionToCanvas("onBeforeChange", [this]); } /** used to resend actions, called after any change is made to the graph */ - afterChange(e) { - this.onAfterChange && this.onAfterChange(this, e), this.sendActionToCanvas("onAfterChange", [this]); + afterChange(t) { + this.onAfterChange && this.onAfterChange(this, t), this.sendActionToCanvas("onAfterChange", [this]); } - connectionChange(e, t) { - this.updateExecutionOrder(), this.onConnectionChange && this.onConnectionChange(e), this._version++, this.sendActionToCanvas("onConnectionChange"); + connectionChange(t, e) { + this.updateExecutionOrder(), this.onConnectionChange && this.onConnectionChange(t), this._version++, this.sendActionToCanvas("onConnectionChange"); } /** returns if the graph is in live mode */ isLive() { if (!this.list_of_graphcanvas) return !1; - for (var e = 0; e < this.list_of_graphcanvas.length; ++e) { - var t = this.list_of_graphcanvas[e]; - if (t.live_mode) + for (var t = 0; t < this.list_of_graphcanvas.length; ++t) { + var e = this.list_of_graphcanvas[t]; + if (e.live_mode) return !0; } return !1; } /** clears the triggered slot animation in all links (stop visual animation) */ clearTriggeredSlots() { - for (var e in this.links) { - var t = this.links[e]; - t && t._last_time && (t._last_time = 0); + for (var t in this.links) { + var e = this.links[t]; + e && e._last_time && (e._last_time = 0); } } /* Called when something visually changed (not the graph!) */ change() { u.debug && console.log("Graph changed"), this.sendActionToCanvas("setDirty", [!0, !0]), this.onChange && this.onChange(this); } - setDirtyCanvas(e = !1, t = !1) { - this.sendActionToCanvas("setDirty", [e, t]); + setDirtyCanvas(t = !1, e = !1) { + this.sendActionToCanvas("setDirty", [t, e]); } /** Destroys a link */ - removeLink(e) { - var t = this.links[e]; - if (t) { - var i = this.getNodeById(t.target_id); - i && i.disconnectInput(t.target_slot); + removeLink(t) { + var e = this.links[t]; + if (e) { + var i = this.getNodeById(e.target_id); + i && i.disconnectInput(e.target_slot); } } /** Creates a Object containing all the info about this graph, it can be serialized */ serialize() { - for (var e = [], t = 0, i = this._nodes.length; t < i; ++t) - e.push(this._nodes[t].serialize()); + for (var t = [], e = 0, i = this._nodes.length; e < i; ++e) + t.push(this._nodes[e].serialize()); var n = []; for (const h in this.links) { var s = this.links[h]; @@ -3978,12 +3978,12 @@ const De = class { } n.push(s.serialize()); } - for (var a = [], t = 0; t < this._groups.length; ++t) - a.push(this._groups[t].serialize()); + for (var a = [], e = 0; e < this._groups.length; ++e) + a.push(this._groups[e].serialize()); var l = { last_node_id: this.last_node_id, last_link_id: this.last_link_id, - nodes: e, + nodes: t, links: n, groups: a, config: this.config, @@ -3997,13 +3997,13 @@ const De = class { * @param data configure a graph from a JSON string * @returns if there was any error parsing */ - configure(e, t) { - if (e) { - t || this.clear(); - var i = e.nodes; - if (e.links && e.links.constructor === Array) { - for (var n = [], s = 0; s < e.links.length; ++s) { - var r = e.links[s]; + configure(t, e) { + if (t) { + e || this.clear(); + var i = t.nodes; + if (t.links && t.links.constructor === Array) { + for (var n = [], s = 0; s < t.links.length; ++s) { + var r = t.links[s]; if (!r) { console.warn("serialized graph link data contains errors, skipping."); continue; @@ -4011,10 +4011,10 @@ const De = class { var o = he.configure(r); n[o.id] = o; } - e.links = n; + t.links = n; } - for (const c in e) - c == "nodes" || c == "groups" || (this[c] = e[c]); + for (const c in t) + c == "nodes" || c == "groups" || (this[c] = t[c]); var a = !1; if (this._nodes = [], i) { for (var s = 0, l = i.length; s < l; ++s) { @@ -4028,32 +4028,32 @@ const De = class { p && p.configure(h); } } - if (this._groups.length = 0, e.groups) - for (var s = 0; s < e.groups.length; ++s) { + if (this._groups.length = 0, t.groups) + for (var s = 0; s < t.groups.length; ++s) { var f = new me(); - f.configure(e.groups[s]), this.addGroup(f); + f.configure(t.groups[s]), this.addGroup(f); } - return this.updateExecutionOrder(), this.extra = e.extra || {}, this.onConfigure && this.onConfigure(e), this._version++, this.setDirtyCanvas(!0, !0), a; + return this.updateExecutionOrder(), this.extra = t.extra || {}, this.onConfigure && this.onConfigure(t), this._version++, this.setDirtyCanvas(!0, !0), a; } } - load(e, t) { + load(t, e) { var i = this; - if (e.constructor === File || e.constructor === Blob) { + if (t.constructor === File || t.constructor === Blob) { var n = new FileReader(); n.addEventListener("load", function(r) { var o = JSON.parse(n.result); - i.configure(o), t && t(o); - }), n.readAsText(e); + i.configure(o), e && e(o); + }), n.readAsText(t); return; } var s = new XMLHttpRequest(); - s.open("GET", e, !0), s.send(null), s.onload = function(r) { + s.open("GET", t, !0), s.send(null), s.onload = function(r) { if (s.status !== 200) { console.error("Error loading graph:", s.status, s.response); return; } var o = JSON.parse(s.response); - i.configure(o), t && t(o); + i.configure(o), e && e(o); }, s.onerror = function(r) { console.error("Error loading graph:", r); }; @@ -4061,54 +4061,54 @@ const De = class { }; let Pe = De; Pe.DEFAULT_SUPPORTED_TYPES = ["number", "string", "boolean"]; -function Re(e) { - const t = { nodeIDs: {}, linkIDs: {} }; - for (const i of e.nodes) { +function Re(t) { + const e = { nodeIDs: {}, linkIDs: {} }; + for (const i of t.nodes) { const n = i.id, s = oe(); - if (i.id = s, t.nodeIDs[n] || t.nodeIDs[s]) + if (i.id = s, e.nodeIDs[n] || e.nodeIDs[s]) throw new Error( `New/old node UUID wasn't unique in changed map! ${n} ${s}` ); - t.nodeIDs[n] = s, t.nodeIDs[s] = n; + e.nodeIDs[n] = s, e.nodeIDs[s] = n; } - for (const i of e.links) { + for (const i of t.links) { const n = i[0], s = oe(); - if (i[0] = s, t.linkIDs[n] || t.linkIDs[s]) + if (i[0] = s, e.linkIDs[n] || e.linkIDs[s]) throw new Error( `New/old link UUID wasn't unique in changed map! ${n} ${s}` ); - t.linkIDs[n] = s, t.linkIDs[s] = n; + e.linkIDs[n] = s, e.linkIDs[s] = n; const r = i[1], o = i[3]; - if (!t.nodeIDs[r]) + if (!e.nodeIDs[r]) throw new Error(`Old node UUID not found in mapping! ${r}`); - if (i[1] = t.nodeIDs[r], !t.nodeIDs[o]) + if (i[1] = e.nodeIDs[r], !e.nodeIDs[o]) throw new Error(`Old node UUID not found in mapping! ${o}`); - i[3] = t.nodeIDs[o]; + i[3] = e.nodeIDs[o]; } - for (const i of e.nodes) { + for (const i of t.nodes) { for (const n of i.inputs) - n.link && (n.link = t.linkIDs[n.link]); + n.link && (n.link = e.linkIDs[n.link]); for (const n of i.outputs) - n.links && (n.links = n.links.map((s) => t.linkIDs[s])); + n.links && (n.links = n.links.map((s) => e.linkIDs[s])); } - for (const i of e.nodes) + for (const i of t.nodes) if (i.type === "graph/subgraph") { const n = Re( i.subgraph ); - t.nodeIDs = { ...t.nodeIDs, ...n.nodeIDs }, t.linkIDs = { ...t.linkIDs, ...n.linkIDs }; + e.nodeIDs = { ...e.nodeIDs, ...n.nodeIDs }, e.linkIDs = { ...e.linkIDs, ...n.linkIDs }; } - return t; + return e; } -function Ve(e, t) { - for (const i of e.iterateNodesInOrderRecursive()) - i.onReassignID && i.onReassignID(t); +function Ve(t, e) { + for (const i of t.iterateNodesInOrderRecursive()) + i.onReassignID && i.onReassignID(e); } const Me = class extends ae { - constructor(e, t) { - super(e), this.properties = { + constructor(t, e) { + super(t), this.properties = { enabled: !0 - }, this.size = [140, 80], this.enabled = !0, this.subgraph = (t || Me.default_lgraph_factory)(), this.subgraph._subgraph_node = this, this.subgraph._is_subgraph = !0; + }, this.size = [140, 80], this.enabled = !0, this.subgraph = (e || Me.default_lgraph_factory)(), this.subgraph._subgraph_node = this, this.subgraph._is_subgraph = !0; const i = (n, s) => { const r = s.bind(this); return function(...o) { @@ -4159,42 +4159,42 @@ const Me = class extends ae { // return graph; // } *iterateParentGraphs() { - var t; - let e = this.graph; - for (; e; ) - yield e, e = (t = e._subgraph_node) == null ? void 0 : t.graph; + var e; + let t = this.graph; + for (; t; ) + yield t, t = (e = t._subgraph_node) == null ? void 0 : e.graph; } - onDblClick(e, t, i) { + onDblClick(t, e, i) { var n = this; setTimeout(function() { i.openSubgraph(n.subgraph); }, 10); } - onAction(e, t, i) { + onAction(t, e, i) { const { originNode: n, link: s } = i; if (!n || !s) return; const r = s.target_slot; - this.getInnerGraphInputByIndex(r).triggerSlot(0, t); + this.getInnerGraphInputByIndex(r).triggerSlot(0, e); } onExecute() { if (this.enabled = this.getInputOrProperty("enabled"), !!this.enabled) { if (this.inputs) - for (var e = 0; e < this.inputs.length; e++) { - var t = this.inputs[e], i = this.getInputData(e); - this.subgraph.setInputData(t.name, i); + for (var t = 0; t < this.inputs.length; t++) { + var e = this.inputs[t], i = this.getInputData(t); + this.subgraph.setInputData(e.name, i); } if (this.subgraph.runStep(), this.outputs) - for (var e = 0; e < this.outputs.length; e++) { - var n = this.outputs[e], i = this.subgraph.getOutputData(n.name); - this.setOutputData(e, i); + for (var t = 0; t < this.outputs.length; t++) { + var n = this.outputs[t], i = this.subgraph.getOutputData(n.name); + this.setOutputData(t, i); } } } - sendEventToAllNodes(e, t, i) { - this.enabled && this.subgraph.sendEventToAllNodes(e, t, i); + sendEventToAllNodes(t, e, i) { + this.enabled && this.subgraph.sendEventToAllNodes(t, e, i); } - onDrawBackground(e, t, i, n) { + onDrawBackground(t, e, i, n) { } // override onMouseDown(e, localpos, graphcanvas) // { @@ -4219,123 +4219,123 @@ const Me = class extends ae { // return false; // } computeSize() { - var e = this.inputs ? this.inputs.length : 0, t = this.outputs ? this.outputs.length : 0; + var t = this.inputs ? this.inputs.length : 0, e = this.outputs ? this.outputs.length : 0; return [ 200, - Math.max(e, t) * u.NODE_SLOT_HEIGHT + u.NODE_SLOT_HEIGHT * 0.5 + Math.max(t, e) * u.NODE_SLOT_HEIGHT + u.NODE_SLOT_HEIGHT * 0.5 ]; } //**** INPUTS *********************************** - onSubgraphTrigger(e, t) { + onSubgraphTrigger(t, e) { } - onSubgraphNodeAdded(e, t) { + onSubgraphNodeAdded(t, e) { var i, n; - (i = this.graph) != null && i.onNodeAdded && (t.subgraphs || (t.subgraphs = []), t.subgraphs.push(this), (n = this.graph) == null || n.onNodeAdded(e, t)); + (i = this.graph) != null && i.onNodeAdded && (e.subgraphs || (e.subgraphs = []), e.subgraphs.push(this), (n = this.graph) == null || n.onNodeAdded(t, e)); } - onSubgraphNodeRemoved(e, t) { + onSubgraphNodeRemoved(t, e) { var i, n; - (i = this.graph) != null && i.onNodeRemoved && (t.subgraphs || (t.subgraphs = []), t.subgraphs.push(this), (n = this.graph) == null || n.onNodeRemoved(e, t)); + (i = this.graph) != null && i.onNodeRemoved && (e.subgraphs || (e.subgraphs = []), e.subgraphs.push(this), (n = this.graph) == null || n.onNodeRemoved(t, e)); } - onSubgraphNewInput(e, t) { - var i = this.findInputSlotIndexByName(e); - i == -1 && this.addInput(e, t); + onSubgraphNewInput(t, e) { + var i = this.findInputSlotIndexByName(t); + i == -1 && this.addInput(t, e); } - onSubgraphRenamedInput(e, t) { - var i = this.findInputSlotIndexByName(e); + onSubgraphRenamedInput(t, e) { + var i = this.findInputSlotIndexByName(t); if (i != -1) { var n = this.getInputInfo(i); - n.name = t; + n.name = e; } } - onSubgraphTypeChangeInput(e, t, i) { - var n = this.findInputSlotIndexByName(e); + onSubgraphTypeChangeInput(t, e, i) { + var n = this.findInputSlotIndexByName(t); if (n != -1) { var s = this.getInputInfo(n); s.type = i; } } - onSubgraphRemovedInput(e) { - var t = this.findInputSlotIndexByName(e); - t != -1 && this.removeInput(t); + onSubgraphRemovedInput(t) { + var e = this.findInputSlotIndexByName(t); + e != -1 && this.removeInput(e); } //**** OUTPUTS *********************************** - onSubgraphNewOutput(e, t) { - var i = this.findOutputSlotIndexByName(e); - i == -1 && this.addOutput(e, t); + onSubgraphNewOutput(t, e) { + var i = this.findOutputSlotIndexByName(t); + i == -1 && this.addOutput(t, e); } - onSubgraphRenamedOutput(e, t) { - var i = this.findOutputSlotIndexByName(e); + onSubgraphRenamedOutput(t, e) { + var i = this.findOutputSlotIndexByName(t); if (i != -1) { var n = this.getOutputInfo(i); - n.name = t; + n.name = e; } } - onSubgraphTypeChangeOutput(e, t, i) { - var n = this.findOutputSlotIndexByName(e); + onSubgraphTypeChangeOutput(t, e, i) { + var n = this.findOutputSlotIndexByName(t); if (n != -1) { var s = this.getOutputInfo(n); s.type = i; } } - onSubgraphRemovedOutput(e) { - var t = this.findOutputSlotIndexByName(e); - t != -1 && this.removeOutput(t); + onSubgraphRemovedOutput(t) { + var e = this.findOutputSlotIndexByName(t); + e != -1 && this.removeOutput(e); } // ***************************************************** - getExtraMenuOptions(e, t) { + getExtraMenuOptions(t, e) { var i = this; return [ { content: "Open", callback: function() { - e.openSubgraph(i.subgraph); + t.openSubgraph(i.subgraph); } } ]; } - onResize(e) { + onResize(t) { console.error("TEST subgraph resize"); } serialize() { - var e = ae.prototype.serialize.call(this); - return e.subgraph = this.subgraph.serialize(), e; + var t = ae.prototype.serialize.call(this); + return t.subgraph = this.subgraph.serialize(), t; } //no need to define node.configure, the default method detects node.subgraph and passes the object to node.subgraph.configure() - onConfigure(e) { - super.onConfigure && super.onConfigure(e), this.subgraph._is_subgraph = !0, this.subgraph._subgraph_node = this; - for (const t of this.subgraph.iterateNodesInOrder()) - (t.is($) || t.is(Q)) && (t.properties.subgraphID = this.id); - } - onReassignID() { + onConfigure(t) { + super.onConfigure && super.onConfigure(t), this.subgraph._is_subgraph = !0, this.subgraph._subgraph_node = this; for (const e of this.subgraph.iterateNodesInOrder()) (e.is($) || e.is(Q)) && (e.properties.subgraphID = this.id); } - clone(e = { forNode: {} }) { + onReassignID() { + for (const t of this.subgraph.iterateNodesInOrder()) + (t.is($) || t.is(Q)) && (t.properties.subgraphID = this.id); + } + clone(t = { forNode: {} }) { var s, r, o, a; - var t = u.createNode(this.type), i = this.serialize(); + var e = u.createNode(this.type), i = this.serialize(); let n = null; if (u.use_uuids) { const l = u.cloneObject(i.subgraph); n = Re(l), i.subgraph = l; } - return delete i.id, delete i.inputs, delete i.outputs, t.configure(i), u.use_uuids && Ve(t.subgraph, n), (s = e.forNode)[r = this.id] || (s[r] = {}), e.forNode[this.id].subgraphNewIDMapping = n, (o = e.forNode)[a = t.id] || (o[a] = {}), e.forNode[t.id].subgraphNewIDMapping = n, t; + return delete i.id, delete i.inputs, delete i.outputs, e.configure(i), u.use_uuids && Ve(e.subgraph, n), (s = t.forNode)[r = this.id] || (s[r] = {}), t.forNode[this.id].subgraphNewIDMapping = n, (o = t.forNode)[a = e.id] || (o[a] = {}), t.forNode[e.id].subgraphNewIDMapping = n, e; } - buildFromNodes(e) { + buildFromNodes(t) { var _, y; - if (e = e.filter((b) => !b.is($) && !b.is(Q)), e.length === 0) + if (t = t.filter((b) => !b.is($) && !b.is(Q)), t.length === 0) return; - const t = {}, i = {}, n = {}, s = e.reduce((b, m) => (b[m.id] = m, b), {}); + const e = {}, i = {}, n = {}, s = t.reduce((b, m) => (b[m.id] = m, b), {}); let r = Number.MAX_SAFE_INTEGER, o = 0, a = Number.MAX_SAFE_INTEGER, l = 0; - for (const b of Object.values(e)) + for (const b of Object.values(t)) r = Math.min(b.pos[0], r), o = Math.max(b.pos[0] + b.size[0], o), a = Math.min(b.pos[1], a), l = Math.max(b.pos[1] + b.size[1], l); const h = {}; - for (const b of e) { + for (const b of t) { h[b.id] = b; for (let m = 0; m < b.inputs.length; m++) { const E = b.getInputLink(m); if (E) { const T = b.getConnectionPos(!0, m), O = b.getInputInfo(m), A = b.getInputNode(m); - A && (h[A.id] = A), s[E.origin_id] != null ? n[E.id] = [E, T] : t[E.id] = [E, T, O.name]; + A && (h[A.id] = A), s[E.origin_id] != null ? n[E.id] = [E, T] : e[E.id] = [E, T, O.name]; } } for (let m = 0; m < b.outputs.length; m++) { @@ -4346,10 +4346,10 @@ const Me = class extends ae { } } } - const p = Object.values(t), f = Object.values(i); - p.sort((b, m) => b[1][1] - m[1][1]), f.sort((b, m) => b[1][1] - m[1][1]), u.debug && (console.debug("NODES", Object.keys(e)), console.debug("IN", Object.keys(t)), console.debug("OUT", Object.keys(i)), console.debug("INNER", Object.keys(n))); + const p = Object.values(e), f = Object.values(i); + p.sort((b, m) => b[1][1] - m[1][1]), f.sort((b, m) => b[1][1] - m[1][1]), u.debug && (console.debug("NODES", Object.keys(t)), console.debug("IN", Object.keys(e)), console.debug("OUT", Object.keys(i)), console.debug("INNER", Object.keys(n))); const c = {}, v = {}; - for (const b of e) { + for (const b of t) { const m = [b.pos[0] - r, b.pos[1] - a], E = b.id; b.graph.remove(b, { removedBy: "moveIntoSubgraph" }), this.subgraph.add(b, { addedBy: "moveIntoSubgraph", @@ -4396,108 +4396,108 @@ const Me = class extends ae { ); } } - addGraphInput(e, t, i) { - e = this.getValidGraphInputName(e); + addGraphInput(t, e, i) { + t = this.getValidGraphInputName(t); const n = u.createNode($); if (n == null) return null; - let s = t; - t === I.EVENT ? s = I.ACTION : t === I.ACTION && (t = I.EVENT), console.warn("[Subgraph] addGraphInput", e, t, s, i), n.setProperty("name", e), n.setProperty("type", t), n.properties.subgraphID = this.id, this.subgraph.add(n); + let s = e; + e === I.EVENT ? s = I.ACTION : e === I.ACTION && (e = I.EVENT), console.warn("[Subgraph] addGraphInput", t, e, s, i), n.setProperty("name", t), n.setProperty("type", e), n.properties.subgraphID = this.id, this.subgraph.add(n); const r = n.computeSize(); i && (n.pos = [ i[0] - r[0] * 0.5, i[1] - r[1] * 0.5 - ]), this.subgraph.addInput(e, s, null); + ]), this.subgraph.addInput(t, s, null); const o = this.inputs.length - 1, a = this.inputs[o]; return { innerNode: n, outerInput: a, outerInputIndex: o }; } - addGraphOutput(e, t, i) { - e = this.getValidGraphOutputName(e); + addGraphOutput(t, e, i) { + t = this.getValidGraphOutputName(t); const n = u.createNode(Q); if (n == null) return null; - let s = t; - t === I.EVENT ? t = I.ACTION : t === I.ACTION && (s = I.EVENT), console.warn("[Subgraph] addGraphOutput", e, t, s, i), n.setProperty("name", e), n.setProperty("type", t), n.properties.subgraphID = this.id, this.subgraph.add(n); + let s = e; + e === I.EVENT ? e = I.ACTION : e === I.ACTION && (s = I.EVENT), console.warn("[Subgraph] addGraphOutput", t, e, s, i), n.setProperty("name", t), n.setProperty("type", e), n.properties.subgraphID = this.id, this.subgraph.add(n); const r = n.computeSize(); - i && (n.pos = [i[0], i[1] - r[1] * 0.5]), this.subgraph.addOutput(e, s, null); + i && (n.pos = [i[0], i[1] - r[1] * 0.5]), this.subgraph.addOutput(t, s, null); const o = this.outputs.length - 1, a = this.outputs[o]; return { innerNode: n, outerOutput: a, outerOutputIndex: o }; } - removeGraphInput(e) { - if (this.findInputSlotIndexByName(e) == null) { - console.error("[Subgraph] No input in slot!", e); + removeGraphInput(t) { + if (this.findInputSlotIndexByName(t) == null) { + console.error("[Subgraph] No input in slot!", t); return; } - const i = this.subgraph.findNodesByClass($).filter((n) => n.properties.name === e); + const i = this.subgraph.findNodesByClass($).filter((n) => n.properties.name === t); if (i.length > 0) for (const n of i) this.subgraph.remove(n); else { console.warn( "[Subgraph] No GraphInputs found on input removal", - e + t ); - const n = this.findInputSlotIndexByName(e); + const n = this.findInputSlotIndexByName(t); n !== -1 && this.removeInput(n); } } - removeGraphOutput(e) { - if (this.findOutputSlotIndexByName(e) == null) { - console.error("[Subgraph] No output in slot!", e); + removeGraphOutput(t) { + if (this.findOutputSlotIndexByName(t) == null) { + console.error("[Subgraph] No output in slot!", t); return; } - const i = this.subgraph.findNodesByClass(Q).filter((n) => n.properties.name === e); + const i = this.subgraph.findNodesByClass(Q).filter((n) => n.properties.name === t); if (i.length > 0) for (const n of i) this.subgraph.remove(n); else { console.warn( "[Subgraph] No GraphOutputs found on output removal", - e + t ); - const n = this.findOutputSlotIndexByName(e); + const n = this.findOutputSlotIndexByName(t); n !== -1 && this.removeOutput(n); } } - getValidGraphInputName(e) { - e || (e = "newInput"); - let t = e, i = this.getInnerGraphInput(t), n = 1; + getValidGraphInputName(t) { + t || (t = "newInput"); + let e = t, i = this.getInnerGraphInput(e), n = 1; for (; i != null; ) - t = `${e}_${n++}`, i = this.getInnerGraphInput(t); - return t; + e = `${t}_${n++}`, i = this.getInnerGraphInput(e); + return e; } - getValidGraphOutputName(e) { - e || (e = "newOutput"); - let t = e, i = this.getInnerGraphOutput(t), n = 1; + getValidGraphOutputName(t) { + t || (t = "newOutput"); + let e = t, i = this.getInnerGraphOutput(e), n = 1; for (; i != null; ) - t = `${e}_${n++}`, i = this.getInnerGraphOutput(t); - return t; + e = `${t}_${n++}`, i = this.getInnerGraphOutput(e); + return e; } - getInnerGraphOutput(e) { - return this.subgraph._nodes.find((i) => i.is(Q) && i.properties.name === e) || null; + getInnerGraphOutput(t) { + return this.subgraph._nodes.find((i) => i.is(Q) && i.properties.name === t) || null; } - getInnerGraphInput(e) { - return this.subgraph._nodes.find((i) => i.is($) && i.properties.name === e) || null; + getInnerGraphInput(t) { + return this.subgraph._nodes.find((i) => i.is($) && i.properties.name === t) || null; } - getInnerGraphOutputByIndex(e) { - const t = this.getOutputInfo(e); - return t ? this.getInnerGraphOutput(t.name) : null; + getInnerGraphOutputByIndex(t) { + const e = this.getOutputInfo(t); + return e ? this.getInnerGraphOutput(e.name) : null; } - getInnerGraphInputByIndex(e) { - const t = this.getInputInfo(e); - return t ? this.getInnerGraphInput(t.name) : null; + getInnerGraphInputByIndex(t) { + const e = this.getInputInfo(t); + return e ? this.getInnerGraphInput(e.name) : null; } - moveNodesToParentGraph(e) { - if (e = e.filter((g) => !g.is($) && !g.is(Q)), e.length === 0) + moveNodesToParentGraph(t) { + if (t = t.filter((g) => !g.is($) && !g.is(Q)), t.length === 0) return; - const t = this, i = t.graph; + const e = this, i = e.graph; let n = Number.MAX_SAFE_INTEGER, s = 0, r = Number.MAX_SAFE_INTEGER, o = 0; - for (const g of Object.values(e)) + for (const g of Object.values(t)) n = Math.min(g.pos[0], n), s = Math.max(g.pos[0] + g.size[0], s), r = Math.min(g.pos[1], r), o = Math.max(g.pos[1] + g.size[1], o); - const a = s - n, l = o - r, h = t.pos[0] + t.size[0] / 2 - a / 2, p = t.pos[1] + t.size[1] / 2 - l / 2, f = {}, c = {}; - for (const [g, d] of e.entries()) + const a = s - n, l = o - r, h = e.pos[0] + e.size[0] / 2 - a / 2, p = e.pos[1] + e.size[1] / 2 - l / 2, f = {}, c = {}; + for (const [g, d] of t.entries()) c[d.id] = d; - for (const g of e) + for (const g of t) for (const d of g.iterateAllLinks()) { const _ = d.target_id === g.id, y = g.getConnectionPos( _, @@ -4506,7 +4506,7 @@ const Me = class extends ae { c[d.origin_id] != null && c[d.target_id] != null && (f[d.id] = [d, y]); } const v = {}; - for (const [g, d] of e.entries()) { + for (const [g, d] of t.entries()) { const _ = [ d.pos[0] - n + h, d.pos[1] - r + p @@ -4519,18 +4519,18 @@ const Me = class extends ae { } return v; } - convertNodesToSubgraphInputs(e) { + convertNodesToSubgraphInputs(t) { var a; - if (e = e.filter((l) => !l.is($) && !l.is(Q)), e.length === 0) + if (t = t.filter((l) => !l.is($) && !l.is(Q)), t.length === 0) return; - const t = ve(e, (l) => l.id), i = [], n = {}, s = this.subgraph; - for (const l of e) + const e = ve(t, (l) => l.id), i = [], n = {}, s = this.subgraph; + for (const l of t) for (const h of l.iterateAllLinks()) { - if (t[h.origin_id] == null) + if (e[h.origin_id] == null) throw new Error( "Can't convert to input with an origin link outward" ); - if (t[h.target_id] == null) { + if (e[h.target_id] == null) { i.push(h); const p = [0, 0]; l.getConnectionPos(!1, h.target_slot, p), n[l.id] = [ @@ -4539,7 +4539,7 @@ const Me = class extends ae { ]; } } - const r = this.moveNodesToParentGraph(e), o = {}; + const r = this.moveNodesToParentGraph(t), o = {}; for (const l of i) { const h = s.getNodeById(l.target_id), p = h.getInputInfo(l.target_slot); o[a = l.origin_id] || (o[a] = {}); @@ -4570,25 +4570,25 @@ const Me = class extends ae { r[l.origin_id].connect(l.origin_slot, this, f.outerInputIndex), f.innerNode.connect(0, h, l.target_slot); } } - convertNodesToSubgraphOutputs(e) { + convertNodesToSubgraphOutputs(t) { var a; - if (e = e.filter((l) => !l.is($) && !l.is(Q)), e.length === 0) + if (t = t.filter((l) => !l.is($) && !l.is(Q)), t.length === 0) return; - const t = ve(e, (l) => l.id), i = [], n = {}, s = this.subgraph; - for (const l of e) + const e = ve(t, (l) => l.id), i = [], n = {}, s = this.subgraph; + for (const l of t) for (const h of l.iterateAllLinks()) - if (t[h.origin_id] == null) { + if (e[h.origin_id] == null) { i.push(h); const p = [0, 0]; l.getConnectionPos(!0, h.origin_slot, p), n[l.id] = [ [l.pos[0], l.pos[1]], p ]; - } else if (t[h.target_id] == null) + } else if (e[h.target_id] == null) throw new Error( "Can't convert to input with an origin link outward" ); - const r = this.moveNodesToParentGraph(e), o = {}; + const r = this.moveNodesToParentGraph(t), o = {}; for (const l of i) { const h = s.getNodeById(l.origin_id), p = h.getOutputInfo(l.origin_slot); o[a = l.target_id] || (o[a] = {}); @@ -4635,7 +4635,7 @@ class C { static onMenuNodeEdit() { } // refactor: there are different dialogs, some uses createDialog some dont - prompt(t = "", i, n, s, r = !1, o = null) { + prompt(e = "", i, n, s, r = !1, o = null) { var a = this, l = document.createElement("div"); if (l.is_modified = !1, l.className = "graphdialog rounded", r) { let T = 5; @@ -4673,7 +4673,7 @@ class C { }); }), a.prompt_box && a.prompt_box.close(), a.prompt_box = l; var g = l.querySelector(".name"); - g.innerText = t; + g.innerText = e; let d = l.querySelector(".value"); d.value = i; var _ = d; @@ -4697,7 +4697,7 @@ class C { _.focus(); }, 10), Ee(l), l; } - showSearchBox(t, i = {}) { + showSearchBox(e, i = {}) { var n = { slotFrom: null, node_from: null, @@ -4713,7 +4713,7 @@ class C { }; i = Object.assign(n, i); var s = this, r = N.active_canvas, o = r.canvas, a = o.ownerDocument || document; - let l = t; + let l = e; var h = document.createElement("div"); h.className = "litegraph litesearchbox graphdialog rounded", h.innerHTML = "Search ", i.do_type_filter && (h.innerHTML += "", h.innerHTML += ""), h.innerHTML += "
", a.fullscreenElement ? a.fullscreenElement.appendChild(h) : (a.body.appendChild(h), a.body.style.overflow = "hidden"); let p = null, f = null; @@ -4823,15 +4823,15 @@ class C { if (fe.hide_in_node_lists || P && fe.filter != P || (!i.show_all_if_empty || F) && D.toLowerCase().indexOf(F) === -1) return !1; if (i.do_type_filter && !ee.skipFilter) { - const W = D; + const Y = D; let H = V == null ? void 0 : V.value; if (ee.inTypeOverride != null && (H = ee.inTypeOverride), V && H && u.registered_slot_in_types[H] && u.registered_slot_in_types[H].nodes) { - var te = u.registered_slot_in_types[H].nodes.includes(W); + var te = u.registered_slot_in_types[H].nodes.includes(Y); if (te === !1) return !1; } if (H = R == null ? void 0 : R.value, ee.outTypeOverride != null && (H = ee.outTypeOverride), R && H && u.registered_slot_out_types[H] && u.registered_slot_out_types[H].nodes) { - var te = u.registered_slot_out_types[H].nodes.includes(W); + var te = u.registered_slot_out_types[H].nodes.includes(Y); if (te === !1) return !1; } @@ -4851,44 +4851,44 @@ class C { var V = 0; D = D.toLowerCase(); var R = r.filter || r.graph.filter; - let W, H; - i.do_type_filter && s.search_box ? (W = s.search_box.querySelector(".slot_in_type_filter"), H = s.search_box.querySelector(".slot_out_type_filter")) : (W = null, H = null); + let Y, H; + i.do_type_filter && s.search_box ? (Y = s.search_box.querySelector(".slot_in_type_filter"), H = s.search_box.querySelector(".slot_out_type_filter")) : (Y = null, H = null); for (const x in u.searchbox_extras) { var le = u.searchbox_extras[x]; if (!((!i.show_all_if_empty || D) && le.desc.toLowerCase().indexOf(D) === -1)) { var be = u.registered_node_types[le.type]; - if (!(be && be.filter != R) && E(le.type, R, D, W, H) && (te(le.desc, "searchbox_extra"), N.search_limit !== -1 && V++ > N.search_limit)) + if (!(be && be.filter != R) && E(le.type, R, D, Y, H) && (te(le.desc, "searchbox_extra"), N.search_limit !== -1 && V++ > N.search_limit)) break; } } var ee = null; if (Array.prototype.filter) - var fe = Object.keys(u.registered_node_types), ee = fe.filter((q) => E(q, R, D, W, H)); + var fe = Object.keys(u.registered_node_types), ee = fe.filter((q) => E(q, R, D, Y, H)); else { ee = []; for (const x in u.registered_node_types) - E(x, R, D, W, H) && ee.push(x); + E(x, R, D, Y, H) && ee.push(x); } for (var F = 0; F < ee.length && (te(ee[F]), !(N.search_limit !== -1 && V++ > N.search_limit)); F++) ; - if (i.show_general_after_typefiltered && (W != null && W.value || H != null && H.value)) { + if (i.show_general_after_typefiltered && (Y != null && Y.value || H != null && H.value)) { let x = []; for (const q in u.registered_node_types) - E(q, R, D, W, H, { inTypeOverride: W && W.value ? "*" : null, outTypeOverride: H && H.value ? "*" : null }) && x.push(q); + E(q, R, D, Y, H, { inTypeOverride: Y && Y.value ? "*" : null, outTypeOverride: H && H.value ? "*" : null }) && x.push(q); for (let q = 0; q < x.length && (te(x[q], "generic_type"), !(N.search_limit !== -1 && V++ > N.search_limit)); q++) ; } - if ((W != null && W.value || H != null && H.value) && (g == null ? void 0 : g.childNodes.length) == 0 && i.show_general_if_none_on_typefilter) { + if ((Y != null && Y.value || H != null && H.value) && (g == null ? void 0 : g.childNodes.length) == 0 && i.show_general_if_none_on_typefilter) { let x = []; for (const q in u.registered_node_types) - E(q, R, D, W, H, { skipFilter: !0 }) && x.push(q); + E(q, R, D, Y, H, { skipFilter: !0 }) && x.push(q); for (let q = 0; q < x.length && (te(x[q], "not_in_filter"), !(N.search_limit !== -1 && V++ > N.search_limit)); q++) ; } } - function te(W, H) { + function te(Y, H) { var x = document.createElement("div"); - d || (d = W), x.innerText = W, x.dataset.type = escape(W), x.className = "litegraph lite-search-item", H && (x.className += " " + H), x.addEventListener("click", function(q) { + d || (d = Y), x.innerText = Y, x.dataset.type = escape(Y), x.className = "litegraph lite-search-item", H && (x.className += " " + H), x.addEventListener("click", function(q) { b(unescape(this.dataset.type)); }), g.appendChild(x); } @@ -4933,9 +4933,9 @@ class C { var G = o.getBoundingClientRect(), z = (l ? l.clientX : G.left + G.width * 0.5) - 80, pe = (l ? l.clientY : G.top + G.height * 0.5) - 20; return h.style.left = z + "px", h.style.top = pe + "px", l.layerY > G.height - 200 && (g.style.maxHeight = G.height - l.layerY - 20 + "px"), O.focus(), i.show_all_on_open && T(), h; } - showShowNodePanel(t) { + showShowNodePanel(e) { this.closePanels(); - var i = this.getCanvasWindow(), n = this, s = this.createPanel(t.title || "", { + var i = this.getCanvasWindow(), n = this, s = this.createPanel(e.title || "", { closable: !0, window: i, onOpen: function() { @@ -4944,38 +4944,38 @@ class C { n.node_panel = null; } }); - n.node_panel = s, s.id = "node-panel", s.node = t, s.classList.add("settings"); + n.node_panel = s, s.id = "node-panel", s.node = e, s.classList.add("settings"); function r() { - s.content.innerHTML = "", s.addHTML("" + t.type + "" + (t.constructor.desc || "") + ""), s.addHTML("

Properties

"); + s.content.innerHTML = "", s.addHTML("" + e.type + "" + (e.constructor.desc || "") + ""), s.addHTML("

Properties

"); var o = function(f, c) { - switch (n.graph.beforeChange(t), f) { + switch (n.graph.beforeChange(e), f) { case "Title": - t.title = c; + e.title = c; break; case "Mode": var v = Object.values(re).indexOf(c); - v >= Z.ALWAYS && re[v] ? t.changeMode(v) : console.warn("unexpected mode: " + c); + v >= Z.ALWAYS && re[v] ? e.changeMode(v) : console.warn("unexpected mode: " + c); break; case "Color": - N.node_colors[c] ? (t.color = N.node_colors[c].color, t.bgcolor = N.node_colors[c].bgcolor) : console.warn("unexpected color: " + c); + N.node_colors[c] ? (e.color = N.node_colors[c].color, e.bgcolor = N.node_colors[c].bgcolor) : console.warn("unexpected color: " + c); break; default: - t.setProperty(f, c); + e.setProperty(f, c); break; } n.graph.afterChange(), n.dirty_canvas = !0; }; - s.addWidget("string", "Title", t.title, {}, o), s.addWidget("combo", "Mode", re[t.mode], { values: re }, o); + s.addWidget("string", "Title", e.title, {}, o), s.addWidget("combo", "Mode", re[e.mode], { values: re }, o); var a = ""; - t.color !== void 0 && (a = Object.keys(N.node_colors).filter(function(f) { - return N.node_colors[f].color == t.color; + e.color !== void 0 && (a = Object.keys(N.node_colors).filter(function(f) { + return N.node_colors[f].color == e.color; })[0]), s.addWidget("combo", "Color", a, { values: Object.keys(N.node_colors) }, o); - for (var l in t.properties) { - var h = t.properties[l], p = t.getPropertyInfo(l); - p.type, !(t.onAddPropertyToPanel && t.onAddPropertyToPanel(l, s)) && s.addWidget(p.widget || p.type, l, h, p, o); + for (var l in e.properties) { + var h = e.properties[l], p = e.getPropertyInfo(l); + p.type, !(e.onAddPropertyToPanel && e.onAddPropertyToPanel(l, s)) && s.addWidget(p.widget || p.type, l, h, p, o); } - s.addSeparator(), t.onShowCustomPanelInfo && t.onShowCustomPanelInfo(s), s.footer.innerHTML = "", s.addButton("Delete", function() { - t.block_delete || (t.graph.remove(t), s.close()); + s.addSeparator(), e.onShowCustomPanelInfo && e.onShowCustomPanelInfo(s), s.footer.innerHTML = "", s.addButton("Delete", function() { + e.block_delete || (e.graph.remove(e), s.close()); }).classList.add("delete"); } s.inner_showCodePad = function(o) { @@ -4983,33 +4983,33 @@ class C { var a = s.alt_content.querySelector("textarea"), l = function() { s.toggleAltContent(!1), s.toggleFooterVisibility(!0), a.parentNode.removeChild(a), s.classList.add("settings"), s.classList.remove("centered"), r(); }; - a.value = t.properties[o], a.addEventListener("keydown", function(f) { - f.code == "Enter" && f.ctrlKey && (t.setProperty(o, a.value), l()); + a.value = e.properties[o], a.addEventListener("keydown", function(f) { + f.code == "Enter" && f.ctrlKey && (e.setProperty(o, a.value), l()); }), s.toggleAltContent(!0), s.toggleFooterVisibility(!1), a.style.height = "calc(100% - 40px)"; var h = s.addButton("Assign", function() { - t.setProperty(o, a.value), l(); + e.setProperty(o, a.value), l(); }); s.alt_content.appendChild(h); var p = s.addButton("Close", l); p.style.float = "right", s.alt_content.appendChild(p); }, r(), this.canvas.parentNode.appendChild(s); } - showSubgraphPropertiesDialog(t) { + showSubgraphPropertiesDialog(e) { console.log("showing subgraph properties dialog"); var i = this.canvas.parentNode.querySelector(".subgraph_dialog"); i && i.close(); var n = this.createPanel("Subgraph Inputs", { closable: !0, width: 500 }); - n.node = t, n.classList.add("subgraph_dialog"); - const s = t; + n.node = e, n.classList.add("subgraph_dialog"); + const s = e; var r = s.subgraph; if (!r) { console.warn("subnode without subgraph!"); return; } function o() { - if (n.clear(), t.inputs) - for (var d = 0; d < t.inputs.length; ++d) { - var _ = t.inputs[d]; + if (n.clear(), e.inputs) + for (var d = 0; d < e.inputs.length; ++d) { + var _ = e.inputs[d]; if (_.not_subgraph_input) continue; var y = ` @@ -5029,9 +5029,9 @@ class C { O < 0 || (s.moveInput(O, O - 1), o()); }); const E = b.querySelector(".move_down"); - E.disabled = d >= t.inputs.length - 1, E.addEventListener("click", function(T) { + E.disabled = d >= e.inputs.length - 1, E.addEventListener("click", function(T) { const O = +this.parentNode.dataset.slot; - O > t.inputs.length - 1 || (s.moveInput(O, O + 1), o()); + O > e.inputs.length - 1 || (s.moveInput(O, O + 1), o()); }); } } @@ -5050,26 +5050,26 @@ class C { const v = () => { const d = h.value; let _ = p.value; - _ === "-1" ? _ = I.ACTION : _ === "-2" && (_ = I.EVENT), !(!d || t.findInputSlotIndexByName(d) != -1) && (this.addGraphInputNode(t, d, _), h.value = "", p.value = "", o(), h.focus()); + _ === "-1" ? _ = I.ACTION : _ === "-2" && (_ = I.EVENT), !(!d || e.findInputSlotIndexByName(d) != -1) && (this.addGraphInputNode(e, d, _), h.value = "", p.value = "", o(), h.focus()); }, g = (d) => { d.keyCode == 13 ? (v(), d.preventDefault()) : d.keyCode == 27 && (n.close(), d.preventDefault()); }; return f.addEventListener("click", v), h.addEventListener("keydown", g), p.addEventListener("keydown", g), o(), this.canvas.parentNode.appendChild(n), h.focus(), n; } - showSubgraphPropertiesDialogRight(t) { + showSubgraphPropertiesDialogRight(e) { var i = this.canvas.parentNode.querySelector(".subgraph_dialog"); i && i.close(); var n = this.createPanel("Subgraph Outputs", { closable: !0, width: 500 }); - n.node = t, n.classList.add("subgraph_dialog"); - const s = t; + n.node = e, n.classList.add("subgraph_dialog"); + const s = e; if (!s.subgraph) { console.warn("subnode without subgraph!"); return; } function o() { - if (n.clear(), t.outputs) - for (var d = 0; d < t.outputs.length; ++d) { - var _ = t.outputs[d]; + if (n.clear(), e.outputs) + for (var d = 0; d < e.outputs.length; ++d) { + var _ = e.outputs[d]; if (_.not_subgraph_output) continue; var y = ` @@ -5089,9 +5089,9 @@ class C { O < 0 || (s.moveOutput(O, O - 1), o()); }); const E = b.querySelector(".move_down"); - E.disabled = d >= t.outputs.length - 1, E.addEventListener("click", function(T) { + E.disabled = d >= e.outputs.length - 1, E.addEventListener("click", function(T) { const O = +this.parentNode.dataset.slot; - O > t.outputs.length - 1 || (s.moveOutput(O, O + 1), o()); + O > e.outputs.length - 1 || (s.moveOutput(O, O + 1), o()); }); } } @@ -5110,18 +5110,18 @@ class C { const v = () => { const d = h.value; let _ = p.value; - _ === "-1" ? _ = I.ACTION : _ === "-2" && (_ = I.EVENT), !(!d || t.findOutputSlotIndexByName(d) != -1) && (this.addGraphOutputNode(t, d, _), h.value = "", p.value = "", o(), h.focus()); + _ === "-1" ? _ = I.ACTION : _ === "-2" && (_ = I.EVENT), !(!d || e.findOutputSlotIndexByName(d) != -1) && (this.addGraphOutputNode(e, d, _), h.value = "", p.value = "", o(), h.focus()); }, g = (d) => { d.keyCode == 13 ? (v(), d.preventDefault()) : d.keyCode == 27 && (n.close(), d.preventDefault()); }; return f.addEventListener("click", v), h.addEventListener("keydown", g), p.addEventListener("keydown", g), o(), this.canvas.parentNode.appendChild(n), h.focus(), n; } - showConnectionMenu(t = {}) { - var i = t.nodeFrom && t.slotFrom, n = !i && t.nodeTo && t.slotTo; + showConnectionMenu(e = {}) { + var i = e.nodeFrom && e.slotFrom, n = !i && e.nodeTo && e.slotTo; if (!i && !n) return console.warn("No data passed to showConnectionMenu"), !1; - var s = i ? t.nodeFrom : t.nodeTo; - const r = i ? t.slotFrom : t.slotTo; + var s = i ? e.nodeFrom : e.nodeTo; + const r = i ? e.slotFrom : e.slotTo; let o; var a = null; switch (typeof r) { @@ -5156,8 +5156,8 @@ class C { const m = s.graph._subgraph_node, E = [b.canvasX, b.canvasY], T = m.addGraphOutput(o.name, o.type, E); s.connect(a, T.innerNode, 0); }, d = (b) => { - const m = Object.assign(t, { - position: [t.e.canvasX, t.e.canvasY] + const m = Object.assign(e, { + position: [e.e.canvasX, e.e.canvasY] }); var E = this.createDefaultNodeForSlot(b, m); E ? console.log("node created", b) : console.error("node not in defaults", b); @@ -5165,7 +5165,7 @@ class C { switch (b.content) { case "Add Node": N.onMenuAdd(b, m, E, y, function(T) { - i ? t.nodeFrom.connectByTypeInput(a, T, h) : t.nodeTo.connectByTypeOutput(a, T, h); + i ? e.nodeFrom.connectByTypeInput(a, T, h) : e.nodeTo.connectByTypeOutput(a, T, h); }); break; case "Add Subgraph Input": @@ -5175,7 +5175,7 @@ class C { g(this.adjustMouseEvent(E)); break; case "Search": - i ? this.showSearchBox(E, { node_from: t.nodeFrom, slotFrom: o, type_filter_in: h }) : this.showSearchBox(E, { node_to: t.nodeTo, slotFrom: o, type_filter_out: h }); + i ? this.showSearchBox(E, { node_from: e.nodeFrom, slotFrom: o, type_filter_in: h }) : this.showSearchBox(E, { node_to: e.nodeTo, slotFrom: o, type_filter_out: h }); break; default: d(b.value); @@ -5183,24 +5183,24 @@ class C { } }; var y = new X(l, { - event: t.e, + event: e.e, title: (o && o.name != "" ? o.name + (h ? " | " : "") : "") + (o && h ? h : ""), callback: _ }); return !1; } - getLinkMenuOptions(t) { - const i = this.graph.getNodeById(t.origin_id), n = this.graph.getNodeById(t.target_id); + getLinkMenuOptions(e) { + const i = this.graph.getNodeById(e.origin_id), n = this.graph.getNodeById(e.target_id); let s = null; - i && i.outputs && i.outputs[t.origin_slot] && (s = i.outputs[t.origin_slot].type); + i && i.outputs && i.outputs[e.origin_slot] && (s = i.outputs[e.origin_slot].type); let r = null; - n && n.outputs && n.outputs[t.target_slot] && (r = n.inputs[t.target_slot].type); + n && n.outputs && n.outputs[e.target_slot] && (r = n.inputs[e.target_slot].type); const o = (p) => { - console.debug("node autoconnect"), !(!p.inputs || !p.inputs.length || !p.outputs || !p.outputs.length) && i.connectByTypeInput(t.origin_slot, p, s) && (p.connectByTypeInput(t.target_slot, n, r), p.pos[0] -= p.size[0] * 0.5); + console.debug("node autoconnect"), !(!p.inputs || !p.inputs.length || !p.outputs || !p.outputs.length) && i.connectByTypeInput(e.origin_slot, p, s) && (p.connectByTypeInput(e.target_slot, n, r), p.pos[0] -= p.size[0] * 0.5); }, a = (p, f, c, v, g) => { N.onMenuAdd(p, f, c, v, o); }, l = () => { - this.graph.removeLink(t.id); + this.graph.removeLink(e.id); }; let h = [ { @@ -5216,26 +5216,26 @@ class C { }, j.SEPARATOR ]; - return this.graph.onGetLinkMenuOptions && (h = this.graph.onGetLinkMenuOptions(h, t)), i.getExtraLinkOptions && (h = i.getExtraLinkOptions(this, t, Y.OUTPUT, h)), n.getExtraLinkOptions && (h = n.getExtraLinkOptions(this, t, Y.INPUT, h)), h; + return this.graph.onGetLinkMenuOptions && (h = this.graph.onGetLinkMenuOptions(h, e)), i.getExtraLinkOptions && (h = i.getExtraLinkOptions(this, e, W.OUTPUT, h)), n.getExtraLinkOptions && (h = n.getExtraLinkOptions(this, e, W.INPUT, h)), h; } - showLinkMenu(t, i) { - const n = this.getLinkMenuOptions(t); + showLinkMenu(e, i) { + const n = this.getLinkMenuOptions(e); return new X(n, { event: i, - title: t.data != null ? t.data.constructor.name : null, - extra: t + title: e.data != null ? e.data.constructor.name : null, + extra: e }), !1; } /* * Shows a popup for editing one of the LGraphNode.properties. */ - showEditPropertyValue(t, i, n = {}) { - if (!t || t.properties[i] === void 0 || u.ignore_all_widget_events) + showEditPropertyValue(e, i, n = {}) { + if (!e || e.properties[i] === void 0 || u.ignore_all_widget_events) return; - var s = t.getPropertyInfo(i), r = s.type, o = ""; + var s = e.getPropertyInfo(i), r = s.type, o = ""; if (r == "string" || r == "number" || r == "array" || r == "object") if (s.multiline) { - let d = t.properties[i], _ = 5; + let d = e.properties[i], _ = 5; if (r !== "string") { d = JSON.stringify(d, null, 2); const y = (d.match(/\n/g) || "").length + 1; @@ -5248,11 +5248,11 @@ class C { o = ""; } else if (r == "boolean" || r == "toggle") - o = ""; + o = ""; else { console.warn("unknown type: " + r); return; @@ -5273,7 +5273,7 @@ class C { p.addEventListener("blur", function(_) { this.focus(); }); - let d = t.properties[i] !== void 0 ? t.properties[i] : ""; + let d = e.properties[i] !== void 0 ? e.properties[i] : ""; if (r !== "string") { let _ = null; s.multiline && (_ = 2), d = JSON.stringify(d, null, _); @@ -5287,19 +5287,19 @@ class C { } p && p.focus(); const f = () => { - n.onclose && n.onclose(), h.close(), t.setDirtyCanvas(!0, !0); + n.onclose && n.onclose(), h.close(), e.setDirtyCanvas(!0, !0); }, c = () => { r != "boolean" && r != "toggle" ? v(p.value) : f(); }, v = (d) => { - s && s.values && s.values.constructor === Object && s.values[d] != null && (d = s.values[d]), typeof t.properties[i] == "number" && (d = Number(d)), (r == "array" || r == "object") && (d = JSON.parse(d)), t.setProperty(i, d), f(); + s && s.values && s.values.constructor === Object && s.values[d] != null && (d = s.values[d]), typeof e.properties[i] == "number" && (d = Number(d)), (r == "array" || r == "object") && (d = JSON.parse(d)), e.setProperty(i, d), f(); }; var g = h.querySelector("button"); return g.addEventListener("click", c), Ee(h), h; } // TODO refactor, theer are different dialog, some uses createDialog, some dont - createDialog(t, i = { checkForInput: !1, closeOnLeave: !0, closeOnLeave_checkModified: !0 }) { + createDialog(e, i = { checkForInput: !1, closeOnLeave: !0, closeOnLeave_checkModified: !0 }) { var n = document.createElement("div"); - n.className = "graphdialog", n.innerHTML = t, n.is_modified = !1; + n.className = "graphdialog", n.innerHTML = e, n.is_modified = !1; var s = this.canvas.getBoundingClientRect(), r = -20, o = -20; if (s && (r -= s.left, o -= s.top), i.position ? (r = i.position[0], o = i.position[1]) : i.event ? (r = i.event.clientX, o = i.event.clientY) : (r += this.canvas.width * 0.5, o += this.canvas.height * 0.5), n.style.left = r + "px", n.style.top = o + "px", this.canvas.parentNode.appendChild(n), i.checkForInput) { var a = n.querySelectorAll("input"), l = !1; @@ -5336,8 +5336,8 @@ class C { }), n; } getCanvasMenuOptions() { - var t = null; - if (this.getMenuOptions ? t = this.getMenuOptions(this) : (t = [ + var e = null; + if (this.getMenuOptions ? e = this.getMenuOptions(this) : (e = [ { content: "Add Node", has_submenu: !0, @@ -5346,18 +5346,18 @@ class C { { content: "Add Group", callback: N.onGroupAdd } //{ content: "Arrange", callback: that.graph.arrange }, //{content:"Collapse All", callback: LGraphCanvas.onMenuCollapseAll } - ], this._graph_stack && this._graph_stack.length > 0 && t.push(j.SEPARATOR, { + ], this._graph_stack && this._graph_stack.length > 0 && e.push(j.SEPARATOR, { content: "Close subgraph", callback: this.closeSubgraph.bind(this) })), this.getExtraMenuOptions) { - var i = this.getExtraMenuOptions(this, t); - i && (t = t.concat(i)); + var i = this.getExtraMenuOptions(this, e); + i && (e = e.concat(i)); } - return t; + return e; } - getNodeMenuOptions(t) { + getNodeMenuOptions(e) { let i = []; - t.getMenuOptions ? i = t.getMenuOptions(this) : (i = [ + e.getMenuOptions ? i = e.getMenuOptions(this) : (i = [ { content: "Inputs", has_submenu: !0, @@ -5388,7 +5388,7 @@ class C { has_submenu: !0, callback: N.onMenuNodeMode } - ], t.resizable !== !1 && i.push({ + ], e.resizable !== !1 && i.push({ content: "Resize", callback: N.onMenuResizeNode }), i.push( @@ -5409,12 +5409,12 @@ class C { }, j.SEPARATOR )); - const n = t.getOptionalSlots(); - if (n && (n.inputs && n.inputs.length > 0 && typeof i[0] == "object" && (i[0].disabled = !1), n.outputs && n.outputs.length && typeof i[1] == "object" && (i[1].disabled = !1)), t.getExtraMenuOptions) { - var s = t.getExtraMenuOptions(this, i); + const n = e.getOptionalSlots(); + if (n && (n.inputs && n.inputs.length > 0 && typeof i[0] == "object" && (i[0].disabled = !1), n.outputs && n.outputs.length && typeof i[1] == "object" && (i[1].disabled = !1)), e.getExtraMenuOptions) { + var s = e.getExtraMenuOptions(this, i); s && (s.push(j.SEPARATOR), i = s.concat(i)); } - t.clonable !== !1 && i.push({ + e.clonable !== !1 && i.push({ content: "Clone", callback: N.onMenuNodeClone }), i.push({ @@ -5422,11 +5422,11 @@ class C { callback: N.onMenuNodeToSubgraph }); let r = Object.values(this.selected_nodes || {}); - if (r.length || (r = [t]), r = r.filter((o) => !o.is($) && !o.is(Q)), i.push({ + if (r.length || (r = [e]), r = r.filter((o) => !o.is($) && !o.is(Q)), i.push({ content: "To Parent Graph", - disabled: !t.graph._is_subgraph || r.length === 0, + disabled: !e.graph._is_subgraph || r.length === 0, callback: N.onMenuNodeToParentGraph - }), t.graph._is_subgraph) { + }), e.graph._is_subgraph) { const o = (p) => { let f = 0; const c = ve(p, (v) => v.id); @@ -5462,11 +5462,11 @@ class C { } return i.push(j.SEPARATOR, { content: "Remove", - disabled: !(t.removable !== !1 && !t.block_delete), + disabled: !(e.removable !== !1 && !e.block_delete), callback: N.onMenuNodeRemove - }), t.graph && t.graph.onGetNodeMenuOptions && (i = t.graph.onGetNodeMenuOptions(i, t)), i; + }), e.graph && e.graph.onGetNodeMenuOptions && (i = e.graph.onGetNodeMenuOptions(i, e)), i; } - getGroupMenuOptions(t) { + getGroupMenuOptions(e) { var i = [ { content: "Title", @@ -5489,10 +5489,10 @@ class C { return i; } /** Called when mouse right click */ - processContextMenu(t, i) { + processContextMenu(e, i) { var n = N.active_canvas, s = n.getCanvasWindow(); let r = i, o = null, a = null, l = null; - t != null && (l = t.item, t.type === "node" && (o = t.item), t.type === "link" && (a = t.item)); + e != null && (l = e.item, e.type === "node" && (o = e.item), e.type === "link" && (a = e.item)); let h = null; var p = { event: r, @@ -5560,7 +5560,7 @@ class C { } h && new X(h, p, s); } - createPanel(t, i = {}) { + createPanel(e, i = {}) { var n = i.window || window, s = document.createElement("div"); if (s.className = "litegraph dialog", s.innerHTML = `
@@ -5572,7 +5572,7 @@ class C { s.close(); }), s.header.appendChild(r); } - return i.onOpen && (s.onOpen = i.onOpen), i.onClose && (s.onClose = i.onClose), s.title_element = s.querySelector(".dialog-title"), s.title_element.innerText = t, s.content = s.querySelector(".dialog-content"), s.alt_content = s.querySelector(".dialog-alt-content"), s.footer = s.querySelector(".dialog-footer"), s.close = function() { + return i.onOpen && (s.onOpen = i.onOpen), i.onClose && (s.onClose = i.onClose), s.title_element = s.querySelector(".dialog-title"), s.title_element.innerText = e, s.content = s.querySelector(".dialog-content"), s.alt_content = s.querySelector(".dialog-alt-content"), s.footer = s.querySelector(".dialog-footer"), s.close = function() { s.onClose && typeof s.onClose == "function" && s.onClose(), s.parentNode && s.parentNode.removeChild(s), this.parentNode && this.parentNode.removeChild(this); }, s.toggleAltContent = function(o = !1) { if (typeof o < "u") @@ -5651,8 +5651,8 @@ class C { } checkPanels() { if (this.canvas) - for (var t = this.canvas.parentNode.querySelectorAll(".litegraph.dialog"), i = 0; i < t.length; ++i) { - var n = t[i]; + for (var e = this.canvas.parentNode.querySelectorAll(".litegraph.dialog"), i = 0; i < e.length; ++i) { + var n = e[i]; if (n.node && (n.node.graph || n.close(), n.node.graph != this.graph)) { if (n.node.is(ne) && this.graph._is_subgraph && this.graph === n.node.subgraph) continue; @@ -5661,14 +5661,14 @@ class C { } } closePanels() { - var t = document.querySelector("#node-panel"); - t && t.close(); - var t = document.querySelector("#option-panel"); - t && t.close(); + var e = document.querySelector("#node-panel"); + e && e.close(); + var e = document.querySelector("#option-panel"); + e && e.close(); } } -C.onShowPropertyEditor = function(e, t, i, n, s) { - var r = e.value, o = r.name, a = s[o], l = document.createElement("div"); +C.onShowPropertyEditor = function(t, e, i, n, s) { + var r = t.value, o = r.name, a = s[o], l = document.createElement("div"); l.is_modified = !1, l.className = "graphdialog", l.innerHTML = "", l.close = function() { l.parentNode && l.parentNode.removeChild(l); }; @@ -5706,13 +5706,13 @@ C.onShowPropertyEditor = function(e, t, i, n, s) { u.dialog_close_on_mouse_leave && m && clearTimeout(m); }), Ee(l); }; -C.onGroupAdd = function(e, t, i, n) { +C.onGroupAdd = function(t, e, i, n) { var s = N.active_canvas; s.getCanvasWindow(); var r = new me(); r.pos = s.convertEventToCanvasOffset(i), s.graph.addGroup(r); }; -C.onMenuAdd = function(e, t, i, n, s) { +C.onMenuAdd = function(t, e, i, n, s) { var r = N.active_canvas, o = r.getCanvasWindow(), a = r.graph; if (!a) return; @@ -5759,7 +5759,7 @@ C.onMenuAdd = function(e, t, i, n, s) { } return l("", n), !1; }; -C.showMenuNodeOptionalInputs = function(e, t, i, n, s) { +C.showMenuNodeOptionalInputs = function(t, e, i, n, s) { if (!s) return; var r = this, o = N.active_canvas, a = o.getCanvasWindow(); @@ -5802,7 +5802,7 @@ C.showMenuNodeOptionalInputs = function(e, t, i, n, s) { } return !1; }; -C.showMenuNodeOptionalOutputs = function(e, t, i, n, s) { +C.showMenuNodeOptionalOutputs = function(t, e, i, n, s) { if (!s) return; var r = this, o = N.active_canvas, a = o.getCanvasWindow(), l = s.getOptionalSlots().outputs, h = []; @@ -5856,7 +5856,7 @@ C.showMenuNodeOptionalOutputs = function(e, t, i, n, s) { a ), !1; }; -C.onMenuResizeNode = function(e, t, i, n, s) { +C.onMenuResizeNode = function(t, e, i, n, s) { if (s) { var r = function(l) { l.size = l.computeSize(), l.onResize && l.onResize(l.size); @@ -5869,7 +5869,7 @@ C.onMenuResizeNode = function(e, t, i, n, s) { s.setDirtyCanvas(!0, !0); } }; -C.onShowMenuNodeProperties = function(e, t, i, n, s) { +C.onShowMenuNodeProperties = function(t, e, i, n, s) { if (!s || !s.properties) return; var r = N.active_canvas, o = r.getCanvasWindow(), a = []; @@ -5905,10 +5905,10 @@ C.onShowMenuNodeProperties = function(e, t, i, n, s) { } return !1; }; -C.onResizeNode = function(e, t, i, n, s) { +C.onResizeNode = function(t, e, i, n, s) { s && (s.size = s.computeSize(), s.setDirtyCanvas(!0, !0)); }; -C.onMenuNodeCollapse = function(e, t, i, n, s) { +C.onMenuNodeCollapse = function(t, e, i, n, s) { s.graph.beforeChange( /*?*/ ); @@ -5924,10 +5924,10 @@ C.onMenuNodeCollapse = function(e, t, i, n, s) { /*?*/ ); }; -C.onMenuNodePin = function(e, t, i, n, s) { +C.onMenuNodePin = function(t, e, i, n, s) { s.pin(); }; -C.onMenuNodeMode = function(e, t, i, n, s) { +C.onMenuNodeMode = function(t, e, i, n, s) { let r = Array.from(re).map((a) => ({ content: a })); new X( r, @@ -5947,7 +5947,7 @@ C.onMenuNodeMode = function(e, t, i, n, s) { } return !1; }; -C.onMenuNodeColors = function(e, t, i, n, s) { +C.onMenuNodeColors = function(t, e, i, n, s) { if (!s) throw "no node for color"; var r = []; @@ -5985,7 +5985,7 @@ C.onMenuNodeColors = function(e, t, i, n, s) { } return !1; }; -C.onMenuNodeShapes = function(e, t, i, n, s) { +C.onMenuNodeShapes = function(t, e, i, n, s) { if (!s) throw "no node passed"; const r = Array.from(Ie).map((a) => ({ content: a })); @@ -6015,7 +6015,7 @@ C.onMenuNodeShapes = function(e, t, i, n, s) { } return !1; }; -C.onMenuNodeRemove = function(e, t, i, n, s) { +C.onMenuNodeRemove = function(t, e, i, n, s) { if (!s) throw "no node passed"; var r = s.graph; @@ -6030,7 +6030,7 @@ C.onMenuNodeRemove = function(e, t, i, n, s) { o(a.selected_nodes[l]); r.afterChange(), s.setDirtyCanvas(!0, !0); }; -C.onMenuNodeToSubgraph = function(e, t, i, n, s) { +C.onMenuNodeToSubgraph = function(t, e, i, n, s) { var r = s.graph, o = N.active_canvas; if (o) { var a = Object.values(o.selected_nodes || {}); @@ -6039,7 +6039,7 @@ C.onMenuNodeToSubgraph = function(e, t, i, n, s) { l.pos = s.pos.concat(), r.add(l), l.buildFromNodes(a), o.deselectAllNodes(), s.setDirtyCanvas(!0, !0); } }; -C.onMenuNodeToSubgraphInputs = function(e, t, i, n, s) { +C.onMenuNodeToSubgraphInputs = function(t, e, i, n, s) { var r = N.active_canvas; if (!r) return; @@ -6051,7 +6051,7 @@ C.onMenuNodeToSubgraphInputs = function(e, t, i, n, s) { let a = Object.values(r.selected_nodes || {}); a.length || (a = [s]), o.convertNodesToSubgraphInputs(a), r.deselectAllNodes(), s.setDirtyCanvas(!0, !0); }; -C.onMenuNodeToSubgraphOutputs = function(e, t, i, n, s) { +C.onMenuNodeToSubgraphOutputs = function(t, e, i, n, s) { var r = N.active_canvas; if (!r) return; @@ -6063,7 +6063,7 @@ C.onMenuNodeToSubgraphOutputs = function(e, t, i, n, s) { let a = Object.values(r.selected_nodes || {}); a.length || (a = [s]), o.convertNodesToSubgraphOutputs(a), r.deselectAllNodes(), s.setDirtyCanvas(!0, !0); }; -C.onMenuNodeToParentGraph = function(e, t, i, n, s) { +C.onMenuNodeToParentGraph = function(t, e, i, n, s) { var r = N.active_canvas; if (!r) return; @@ -6075,77 +6075,77 @@ C.onMenuNodeToParentGraph = function(e, t, i, n, s) { let a = Object.values(r.selected_nodes || {}); a.length || (a = [s]), o.moveNodesToParentGraph(a), r.deselectAllNodes(), s.setDirtyCanvas(!0, !0); }; -C.onMenuNodeClone = function(e, t, i, n, s) { +C.onMenuNodeClone = function(t, e, i, n, s) { var r = N.active_canvas; (!r.selected_nodes || Object.keys(r.selected_nodes).length <= 1) && r.selectNode(s), r.cloneSelection(); }; const ce = class { - constructor(e, t, i = {}) { - this.link_type_colors = {}, this.node_panel = null, this.options_panel = null, this.render_time = 0, this.allow_dragcanvas = !0, this.allow_dragnodes = !0, this.allow_interaction = !0, this.allow_reconnect_links = !0, this.allow_searchbox = !0, this.always_render_background = !1, this.background_image = ce.DEFAULT_BACKGROUND_IMAGE, this.block_click = !1, this.clear_background = !0, this.clear_background_color = "#222", this.connecting_pos = null, this.connecting_slot = null, this.connecting_input = null, this.connecting_output = null, this.connections_width = 3, this.current_node = null, this.drag_mode = !1, this.dragging_rectangle = null, this.ds = new Be(), this.editor_alpha = 1, this.filter = null, this.highquality_render = !0, this.skip_events = !1, this.last_mouse_position = [0, 0], this.last_click_position = [0, 0], this.last_click_position_offset = [0, 0], this.last_mouse_dragging = !1, this.links_render_mode = de.SPLINE_LINK, this.live_mode = !1, this.mouse = [0, 0], this.offset_mouse = [0, 0], this.graph_mouse = [0, 0], this.node_widget = null, this.maxZoom = null, this.minZoom = null, this.multi_select = !1, this.over_link_center = null, this.pause_rendering = !1, this.read_only = !1, this.render_canvas_border = !0, this.render_collapsed_slots = !0, this.render_connection_arrows = !1, this.render_connections_border = !0, this.render_connections_shadows = !1, this.render_connections = !0, this.render_curved_connections = !1, this.render_execution_order = !1, this.render_link_tooltip = !0, this.render_only_selected = !0, this.render_shadows = !0, this.render_title_colored = !0, this.render_subgraph_panels = !0, this.render_subgraph_stack_header = !0, this.round_radius = 8, this.set_canvas_dirty_on_mouse_event = !0, this.show_info = !0, this.use_gradients = !1, this.visible_links = [], this.zoom_modify_alpha = !0, this.pointer_is_down = !1, this.pointer_is_double = !1, this._highlight_input = null, this._highlight_input_slot = null, this._highlight_output = null, this._graph_stack = [], this._bg_img = null, this._pattern = null, this._pattern_img = null, this.search_box = null, this.prompt_box = null, this._events_binded = !1, this.resizing_node = null, typeof e == "string" && (e = document.querySelector(e)), this.skip_events = i.skip_events || !1, this.title_text_font = "" + u.NODE_TEXT_SIZE + "px Arial", this.inner_text_font = "normal " + u.NODE_SUBTEXT_SIZE + "px Arial", this.node_title_color = u.NODE_TITLE_COLOR, this.default_link_color = u.LINK_COLOR, this.link_type_colors = u.cloneObject(ce.DEFAULT_LINK_TYPE_COLORS), this.canvas_mouse = this.graph_mouse, this.visible_area = this.ds.visible_area, this.viewport = i.viewport || null, t && t.attachCanvas(this), this.setCanvas(e, i.skip_events), this.clear(), i.skip_render || this.startRendering(), this.autoresize = i.autoresize; + constructor(t, e, i = {}) { + this.link_type_colors = {}, this.node_panel = null, this.options_panel = null, this.render_time = 0, this.allow_dragcanvas = !0, this.allow_dragnodes = !0, this.allow_interaction = !0, this.allow_reconnect_links = !0, this.allow_searchbox = !0, this.always_render_background = !1, this.background_image = ce.DEFAULT_BACKGROUND_IMAGE, this.block_click = !1, this.clear_background = !0, this.clear_background_color = "#222", this.connecting_pos = null, this.connecting_slot = null, this.connecting_input = null, this.connecting_output = null, this.connections_width = 3, this.current_node = null, this.drag_mode = !1, this.dragging_rectangle = null, this.ds = new Be(), this.editor_alpha = 1, this.filter = null, this.highquality_render = !0, this.skip_events = !1, this.last_mouse_position = [0, 0], this.last_click_position = [0, 0], this.last_click_position_offset = [0, 0], this.last_mouse_dragging = !1, this.links_render_mode = de.SPLINE_LINK, this.live_mode = !1, this.mouse = [0, 0], this.offset_mouse = [0, 0], this.graph_mouse = [0, 0], this.node_widget = null, this.maxZoom = null, this.minZoom = null, this.multi_select = !1, this.over_link_center = null, this.pause_rendering = !1, this.read_only = !1, this.render_canvas_border = !0, this.render_collapsed_slots = !0, this.render_connection_arrows = !1, this.render_connections_border = !0, this.render_connections_shadows = !1, this.render_connections = !0, this.render_curved_connections = !1, this.render_execution_order = !1, this.render_link_tooltip = !0, this.render_only_selected = !0, this.render_shadows = !0, this.render_title_colored = !0, this.render_subgraph_panels = !0, this.render_subgraph_stack_header = !0, this.round_radius = 8, this.set_canvas_dirty_on_mouse_event = !0, this.show_info = !0, this.use_gradients = !1, this.visible_links = [], this.zoom_modify_alpha = !0, this.pointer_is_down = !1, this.pointer_is_double = !1, this._highlight_input = null, this._highlight_input_slot = null, this._highlight_output = null, this._graph_stack = [], this._bg_img = null, this._pattern = null, this._pattern_img = null, this.search_box = null, this.prompt_box = null, this._events_binded = !1, this.resizing_node = null, typeof t == "string" && (t = document.querySelector(t)), this.skip_events = i.skip_events || !1, this.title_text_font = "" + u.NODE_TEXT_SIZE + "px Arial", this.inner_text_font = "normal " + u.NODE_SUBTEXT_SIZE + "px Arial", this.node_title_color = u.NODE_TITLE_COLOR, this.default_link_color = u.LINK_COLOR, this.link_type_colors = u.cloneObject(ce.DEFAULT_LINK_TYPE_COLORS), this.canvas_mouse = this.graph_mouse, this.visible_area = this.ds.visible_area, this.viewport = i.viewport || null, e && e.attachCanvas(this), this.setCanvas(t, i.skip_events), this.clear(), i.skip_render || this.startRendering(), this.autoresize = i.autoresize; } - static getFileExtension(e) { - var t = e.indexOf("?"); - t != -1 && (e = e.substr(0, t)); - var i = e.lastIndexOf("."); - return i == -1 ? "" : e.substr(i + 1).toLowerCase(); + static getFileExtension(t) { + var e = t.indexOf("?"); + e != -1 && (t = t.substr(0, e)); + var i = t.lastIndexOf("."); + return i == -1 ? "" : t.substr(i + 1).toLowerCase(); } - static decodeHTML(e) { - var t = document.createElement("div"); - return t.innerText = e, t.innerHTML; + static decodeHTML(t) { + var e = document.createElement("div"); + return e.innerText = t, e.innerHTML; } - static getPropertyPrintableValue(e, t) { - if (!t || t.constructor === Array) - return String(e); - if (t.constructor === Object) { + static getPropertyPrintableValue(t, e) { + if (!e || e.constructor === Array) + return String(t); + if (e.constructor === Object) { var i = ""; - for (var n in t) - if (t[n] == e) { + for (var n in e) + if (e[n] == t) { i = n; break; } - return String(e) + " (" + i + ")"; + return String(t) + " (" + i + ")"; } } get scale() { return this.ds.scale; } - set scale(e) { - this.ds.scale = e; + set scale(t) { + this.ds.scale = t; } /** clears all the data inside */ clear() { this.frame = 0, this.last_draw_time = 0, this.render_time = 0, this.fps = 0, this.dragging_rectangle = null, this.selected_nodes = {}, this.selected_group = null, this.visible_nodes = [], this.node_dragged = null, this.node_over = null, this.node_capturing_input = null, this.connecting_node = null, this.highlighted_links = {}, this.dragging_canvas = !1, this.dirty_canvas = !0, this.dirty_bgcanvas = !0, this.dirty_area = null, this.node_in_panel = null, this.node_widget = null, this.last_mouse = [0, 0], this.last_mouseclick = 0, this.pointer_is_down = !1, this.pointer_is_double = !1, this.onClear && this.onClear(); } /** assigns a graph, you can reassign graphs to the same canvas */ - setGraph(e, t = !1) { - if (this.graph != e) { - if (t || this.clear(), !e && this.graph) { + setGraph(t, e = !1) { + if (this.graph != t) { + if (e || this.clear(), !t && this.graph) { this.graph.detachCanvas(this); return; } - e.attachCanvas(this), this._graph_stack && (this._graph_stack = null), this.setDirty(!0, !0); + t.attachCanvas(this), this._graph_stack && (this._graph_stack = null), this.setDirty(!0, !0); } } /** opens a graph contained inside a node in the current graph */ - openSubgraph(e) { - if (!e) + openSubgraph(t) { + if (!t) throw "graph cannot be null"; - if (this.graph == e) + if (this.graph == t) throw "graph cannot be the same"; if (this.clear(), this.graph) { this._graph_stack || (this._graph_stack = []); const i = [this.ds.offset[0], this.ds.offset[1]]; this._graph_stack.push({ graph: this.graph, offset: i, scale: this.ds.scale }); } - u.debug && (console.warn("SubGraph opened", e), console.warn("Graph inputs", e.inputs), console.warn("Graph outputs", e.outputs)), e.attachCanvas(this); - const t = [0, 0]; - if (e._nodes.length > 0) { + u.debug && (console.warn("SubGraph opened", t), console.warn("Graph inputs", t.inputs), console.warn("Graph outputs", t.outputs)), t.attachCanvas(this); + const e = [0, 0]; + if (t._nodes.length > 0) { let i = Number.MAX_SAFE_INTEGER, n = 0, s = Number.MAX_SAFE_INTEGER, r = 0; - for (const o of e.iterateNodesInOrder()) + for (const o of t.iterateNodesInOrder()) i = Math.min(o.pos[0], i), n = Math.max(o.pos[0] + o.size[0], n), s = Math.min(o.pos[1], s), r = Math.max(o.pos[1] + o.size[1], r); - t[0] = -(i + (n - i) / 2) + this.canvas.width / 2, t[1] = -(s + (r - s) / 2) + this.canvas.height / 2; + e[0] = -(i + (n - i) / 2) + this.canvas.width / 2, e[1] = -(s + (r - s) / 2) + this.canvas.height / 2; } - this.ds.offset = t, this.ds.scale = 1, this.checkPanels(), this.setDirty(!0, !0); + this.ds.offset = e, this.ds.scale = 1, this.checkPanels(), this.setDirty(!0, !0); } closeAllSubgraphs() { for (; this._graph_stack && this._graph_stack.length > 0; ) @@ -6154,26 +6154,26 @@ const ce = class { /** closes a subgraph contained inside a node */ closeSubgraph() { if (!(!this._graph_stack || this._graph_stack.length == 0)) { - var e = this.graph._subgraph_node, { graph: t, offset: i, scale: n } = this._graph_stack.pop(); - this.selected_nodes = {}, this.highlighted_links = {}, t.attachCanvas(this), this.setDirty(!0, !0), e && (this.centerOnNode(e), this.selectNodes([e])), this.ds.offset = i, this.ds.scale = n; + var t = this.graph._subgraph_node, { graph: e, offset: i, scale: n } = this._graph_stack.pop(); + this.selected_nodes = {}, this.highlighted_links = {}, e.attachCanvas(this), this.setDirty(!0, !0), t && (this.centerOnNode(t), this.selectNodes([t])), this.ds.offset = i, this.ds.scale = n; } } /** assigns a canvas */ - setCanvas(e, t = !1) { - if (e && typeof e == "string" && (e = document.getElementById(e), !e)) + setCanvas(t, e = !1) { + if (t && typeof t == "string" && (t = document.getElementById(t), !t)) throw "Error creating LiteGraph canvas: Canvas not found"; - if (e = e, e !== this.canvas && (!e && this.canvas && (t || this.unbindEvents()), this.canvas = e, this.ds.element = e, !!e)) { - if (e.className += " lgraphcanvas", e.data = this, e.tabIndex = 1, this.bgcanvas = null, this.bgcanvas || (this.bgcanvas = document.createElement("canvas"), this.bgcanvas.width = this.canvas.width, this.bgcanvas.height = this.canvas.height), e.getContext == null) - throw e.localName != "canvas" ? "Element supplied for LGraphCanvas must be a element, you passed a " + e.localName : "This browser doesn't support Canvas"; - t || this.bindEvents(), this.adjustCanvasForHiDPI(); + if (t = t, t !== this.canvas && (!t && this.canvas && (e || this.unbindEvents()), this.canvas = t, this.ds.element = t, !!t)) { + if (t.className += " lgraphcanvas", t.data = this, t.tabIndex = 1, this.bgcanvas = null, this.bgcanvas || (this.bgcanvas = document.createElement("canvas"), this.bgcanvas.width = this.canvas.width, this.bgcanvas.height = this.canvas.height), t.getContext == null) + throw t.localName != "canvas" ? "Element supplied for LGraphCanvas must be a element, you passed a " + t.localName : "This browser doesn't support Canvas"; + e || this.bindEvents(), this.adjustCanvasForHiDPI(); } } //used in some events to capture them - _doNothing(e) { - return e.preventDefault(), !1; + _doNothing(t) { + return t.preventDefault(), !1; } - _doReturnTrue(e) { - return e.preventDefault(), !0; + _doReturnTrue(t) { + return t.preventDefault(), !0; } /** binds mouse, keyboard, touch and drag events to the canvas */ bindEvents() { @@ -6181,12 +6181,12 @@ const ce = class { console.warn("LGraphCanvas: events already binded"); return; } - var e = this.canvas, t = this.getCanvasWindow(), i = t.document; - this._mousedown_callback = this.processMouseDown.bind(this), this._mousewheel_callback = this.processMouseWheel.bind(this), this._mousemove_callback = this.processMouseMove.bind(this), this._mouseup_callback = this.processMouseUp.bind(this), u.pointerListenerAdd(e, "down", this._mousedown_callback, !0), e.addEventListener("mousewheel", this._mousewheel_callback, !1), u.pointerListenerAdd(e, "up", this._mouseup_callback, !0), u.pointerListenerAdd(e, "move", this._mousemove_callback), e.addEventListener("contextmenu", this._doNothing), e.addEventListener( + var t = this.canvas, e = this.getCanvasWindow(), i = e.document; + this._mousedown_callback = this.processMouseDown.bind(this), this._mousewheel_callback = this.processMouseWheel.bind(this), this._mousemove_callback = this.processMouseMove.bind(this), this._mouseup_callback = this.processMouseUp.bind(this), u.pointerListenerAdd(t, "down", this._mousedown_callback, !0), t.addEventListener("mousewheel", this._mousewheel_callback, !1), u.pointerListenerAdd(t, "up", this._mouseup_callback, !0), u.pointerListenerAdd(t, "move", this._mousemove_callback), t.addEventListener("contextmenu", this._doNothing), t.addEventListener( "DOMMouseScroll", this._mousewheel_callback, !1 - ), this._key_callback = this.processKey.bind(this), e.addEventListener("keydown", this._key_callback, !0), i.addEventListener("keyup", this._key_callback, !0), this._ondrop_callback = this.processDrop.bind(this), e.addEventListener("dragover", this._doNothing, !1), e.addEventListener("dragend", this._doNothing, !1), e.addEventListener("drop", this._ondrop_callback, !1), e.addEventListener("dragenter", this._doReturnTrue, !1), this._events_binded = !0; + ), this._key_callback = this.processKey.bind(this), t.addEventListener("keydown", this._key_callback, !0), i.addEventListener("keyup", this._key_callback, !0), this._ondrop_callback = this.processDrop.bind(this), t.addEventListener("dragover", this._doNothing, !1), t.addEventListener("dragend", this._doNothing, !1), t.addEventListener("drop", this._ondrop_callback, !1), t.addEventListener("dragenter", this._doReturnTrue, !1), this._events_binded = !0; } /** unbinds mouse events from the canvas */ unbindEvents() { @@ -6195,14 +6195,14 @@ const ce = class { return; } u.debug && console.log("pointerevents: unbindEvents"); - var e = this.getCanvasWindow(), t = e.document; + var t = this.getCanvasWindow(), e = t.document; u.pointerListenerRemove(this.canvas, "move", this._mousedown_callback), u.pointerListenerRemove(this.canvas, "up", this._mousedown_callback), u.pointerListenerRemove(this.canvas, "down", this._mousedown_callback), this.canvas.removeEventListener( "mousewheel", this._mousewheel_callback ), this.canvas.removeEventListener( "DOMMouseScroll", this._mousewheel_callback - ), this.canvas.removeEventListener("keydown", this._key_callback), t.removeEventListener("keyup", this._key_callback), this.canvas.removeEventListener("contextmenu", this._doNothing), this.canvas.removeEventListener("drop", this._ondrop_callback), this.canvas.removeEventListener("dragenter", this._doReturnTrue), this._mousedown_callback = null, this._mousewheel_callback = null, this._key_callback = null, this._ondrop_callback = null, this._events_binded = !1; + ), this.canvas.removeEventListener("keydown", this._key_callback), e.removeEventListener("keyup", this._key_callback), this.canvas.removeEventListener("contextmenu", this._doNothing), this.canvas.removeEventListener("drop", this._ondrop_callback), this.canvas.removeEventListener("dragenter", this._doReturnTrue), this._mousedown_callback = null, this._mousewheel_callback = null, this._key_callback = null, this._ondrop_callback = null, this._events_binded = !1; } /** * this function allows to render the canvas using WebGL instead of Canvas2D @@ -6215,8 +6215,8 @@ const ce = class { * @param fg if the foreground canvas is dirty (the one containing the nodes) * @param bg if the background canvas is dirty (the one containing the wires) */ - setDirty(e = !1, t = !1) { - e && (this.dirty_canvas = !0), t && (this.dirty_bgcanvas = !0); + setDirty(t = !1, e = !1) { + t && (this.dirty_canvas = !0), e && (this.dirty_bgcanvas = !0); } /** * Used to attach the canvas in a popup @@ -6225,24 +6225,24 @@ const ce = class { getCanvasWindow() { if (!this.canvas) return window; - var e = this.canvas.ownerDocument; - return e.defaultView; + var t = this.canvas.ownerDocument; + return t.defaultView; } - adjustCanvasForHiDPI(e) { - if (e || (e = window.devicePixelRatio), e == 1 || !this.canvas.parentNode) + adjustCanvasForHiDPI(t) { + if (t || (t = window.devicePixelRatio), t == 1 || !this.canvas.parentNode) return; - const t = this.canvas.parentNode.getBoundingClientRect(), { width: i, height: n } = t; - this.canvas.width = i * e, this.canvas.height = n * e, this.canvas.style.width = i + "px", this.canvas.style.height = n + "px", this.canvas.getContext("2d").scale(e, e); + const e = this.canvas.parentNode.getBoundingClientRect(), { width: i, height: n } = e; + this.canvas.width = i * t, this.canvas.height = n * t, this.canvas.style.width = i + "px", this.canvas.style.height = n + "px", this.canvas.getContext("2d").scale(t, t); } /** starts rendering the content of the canvas when needed */ startRendering() { if (this.is_rendering) return; - this.is_rendering = !0, e.call(this); - function e() { + this.is_rendering = !0, t.call(this); + function t() { this.pause_rendering || this.draw(); - var t = this.getCanvasWindow(); - this.is_rendering && t.requestAnimationFrame(e.bind(this)); + var e = this.getCanvasWindow(); + this.is_rendering && e.requestAnimationFrame(t.bind(this)); } } /** stops rendering the content of the canvas (to save resources) */ @@ -6253,17 +6253,17 @@ const ce = class { blockClick() { this.block_click = !0, this.last_mouseclick = 0; } - createDefaultNodeForSlot(e, t = {}) { - var i = this, n = t.nodeFrom && t.slotFrom !== null, s = !n && t.nodeTo && t.slotTo !== null; - if (t = { ...{ + createDefaultNodeForSlot(t, e = {}) { + var i = this, n = e.nodeFrom && e.slotFrom !== null, s = !n && e.nodeTo && e.slotTo !== null; + if (e = { ...{ position: [0, 0], posAdd: [0, 0], posSizeFix: [0, 0] - }, ...t }, !n && !s) - return console.warn("No data passed to createDefaultNodeForSlot " + t.nodeFrom + " " + t.slotFrom + " " + t.nodeTo + " " + t.slotTo), !1; - if (!e) + }, ...e }, !n && !s) + return console.warn("No data passed to createDefaultNodeForSlot " + e.nodeFrom + " " + e.slotFrom + " " + e.nodeTo + " " + e.slotTo), !1; + if (!t) return console.warn("No type to createDefaultNodeForSlot"), !1; - var o = n ? t.nodeFrom : t.nodeTo, a = n ? t.slotFrom : t.slotTo, l = null; + var o = n ? e.nodeFrom : e.nodeTo, a = n ? e.slotFrom : e.slotTo, l = null; switch (typeof a) { case "string": l = n ? o.findOutputSlotIndexByName(a) : o.findInputSlotIndexByName(a), a = n ? o.outputs[a] : o.inputs[a]; @@ -6286,8 +6286,8 @@ const ce = class { let _ = null; if (Array.isArray(f)) { for (var c in f) - if (e == p[h][c] || e == "AUTO") { - _ = p[h][c], u.debug && console.log("opts.nodeType == slotTypesDefault[fromSlotType][typeX] :: " + e); + if (t == p[h][c] || t == "AUTO") { + _ = p[h][c], u.debug && console.log("opts.nodeType == slotTypesDefault[fromSlotType][typeX] :: " + t); break; } } else @@ -6319,9 +6319,9 @@ const ce = class { } v.title && (g.title = v.title), v.json && g.configure(v.json); } - console.warn("PLACING", g.type, t); - const y = t.position[0] + t.posAdd[0] + (t.posSizeFix[0] ? t.posSizeFix[0] * g.size[0] : 0), b = t.position[1] + t.posAdd[1] + (t.posSizeFix[1] ? t.posSizeFix[1] * g.size[1] : 0), m = [y, b]; - return i.graph.add(g, { pos: m }), n ? t.nodeFrom.connectByTypeInput(l, g, h) : t.nodeTo.connectByTypeOutput(l, g, h), n && s && console.debug("connecting in between"), !0; + console.warn("PLACING", g.type, e); + const y = e.position[0] + e.posAdd[0] + (e.posSizeFix[0] ? e.posSizeFix[0] * g.size[0] : 0), b = e.position[1] + e.posAdd[1] + (e.posSizeFix[1] ? e.posSizeFix[1] * g.size[1] : 0), m = [y, b]; + return i.graph.add(g, { pos: m }), n ? e.nodeFrom.connectByTypeInput(l, g, h) : e.nodeTo.connectByTypeOutput(l, g, h), n && s && console.debug("connecting in between"), !0; } else console.log("failed creating " + _); } @@ -6329,31 +6329,31 @@ const ce = class { return !1; } /** returns true if a position (in graph space) is on top of a node little corner box */ - isOverNodeBox(e, t, i) { + isOverNodeBox(t, e, i) { var n = u.NODE_TITLE_HEIGHT; return !!u.isInsideRectangle( - t, + e, i, - e.pos[0] + 2, - e.pos[1] + 2 - n, + t.pos[0] + 2, + t.pos[1] + 2 - n, n - 4, n - 4 ); } /** returns slot index if a position (in graph space) is on top of a node input slot */ - isOverNodeInput(e, t, i, n) { - if (e.inputs) - for (var s = 0, r = e.inputs.length; s < r; ++s) { - var o = e.getConnectionPos(!0, s), a = !1; - if (e.horizontal ? a = u.isInsideRectangle( - t, + isOverNodeInput(t, e, i, n) { + if (t.inputs) + for (var s = 0, r = t.inputs.length; s < r; ++s) { + var o = t.getConnectionPos(!0, s), a = !1; + if (t.horizontal ? a = u.isInsideRectangle( + e, i, o[0] - 5, o[1] - 10, 10, 20 ) : a = u.isInsideRectangle( - t, + e, i, o[0] - 10, o[1] - 5, @@ -6368,20 +6368,20 @@ const ce = class { * returns the INDEX if a position (in graph space) is on top of a node output slot * @method isOverNodeOuput **/ - isOverNodeOutput(e, t, i, n) { - if (e.outputs) - for (var s = 0, r = e.outputs.length; s < r; ++s) { - e.outputs[s]; - var o = e.getConnectionPos(!1, s), a = !1; - if (e.horizontal ? a = u.isInsideRectangle( - t, + isOverNodeOutput(t, e, i, n) { + if (t.outputs) + for (var s = 0, r = t.outputs.length; s < r; ++s) { + t.outputs[s]; + var o = t.getConnectionPos(!1, s), a = !1; + if (t.horizontal ? a = u.isInsideRectangle( + e, i, o[0] - 5, o[1] - 10, 10, 20 ) : a = u.isInsideRectangle( - t, + e, i, o[0] - 10, o[1] - 5, @@ -6392,47 +6392,47 @@ const ce = class { } return -1; } - findLinkCenterAtPos(e, t) { + findLinkCenterAtPos(t, e) { for (let i = 0; i < this.visible_links.length; ++i) { const n = this.visible_links[i]; if (this.graph && this.graph.links[n.id] == null) continue; const s = n._pos; - if (!(!s || e < s[0] - 4 || e > s[0] + 4 || t < s[1] - 4 || t > s[1] + 4)) + if (!(!s || t < s[0] - 4 || t > s[0] + 4 || e < s[1] - 4 || e > s[1] + 4)) return n; } return null; } /** process a key event */ - processKey(e) { + processKey(t) { if (!this.graph) return; - var t = !1; - if (u.debug && console.log("processKey", e), e.target instanceof Element && e.target.localName == "input") + var e = !1; + if (u.debug && console.log("processKey", t), t.target instanceof Element && t.target.localName == "input") return; const i = this.allow_interaction && !this.read_only; - if (e.type == "keydown") { - if (e.keyCode == 32 && !(e.metaKey || e.ctrlKey || e.shiftKey) && (this.dragging_canvas = !0, t = !0), e.keyCode == 27 && !(e.metaKey || e.ctrlKey || e.shiftKey) && (this.node_panel && this.node_panel.close(), this.options_panel && this.options_panel.close(), t = !0), i && (e.keyCode == 65 && e.ctrlKey && (this.selectNodes(), t = !0), e.code == "KeyX" && (e.metaKey || e.ctrlKey) && !e.shiftKey && this.selected_nodes && (this.cutToClipboard(), t = !0), e.code == "KeyC" && (e.metaKey || e.ctrlKey) && !e.shiftKey && this.selected_nodes && (this.copyToClipboard(), t = !0), e.code == "KeyV" && (e.metaKey || e.ctrlKey) && !e.shiftKey && this.pasteFromClipboard(), e.code == "KeyD" && (e.metaKey || e.ctrlKey) && !e.shiftKey && (this.cloneSelection(), t = !0), (e.keyCode == 46 || e.keyCode == 8) && e.target instanceof Element && e.target.localName != "input" && e.target.localName != "textarea" && (this.deleteSelectedNodes(), t = !0), this.selected_nodes)) + if (t.type == "keydown") { + if (t.keyCode == 32 && !(t.metaKey || t.ctrlKey || t.shiftKey) && (this.dragging_canvas = !0, e = !0), t.keyCode == 27 && !(t.metaKey || t.ctrlKey || t.shiftKey) && (this.node_panel && this.node_panel.close(), this.options_panel && this.options_panel.close(), e = !0), i && (t.keyCode == 65 && t.ctrlKey && (this.selectNodes(), e = !0), t.code == "KeyX" && (t.metaKey || t.ctrlKey) && !t.shiftKey && this.selected_nodes && (this.cutToClipboard(), e = !0), t.code == "KeyC" && (t.metaKey || t.ctrlKey) && !t.shiftKey && this.selected_nodes && (this.copyToClipboard(), e = !0), t.code == "KeyV" && (t.metaKey || t.ctrlKey) && !t.shiftKey && this.pasteFromClipboard(), t.code == "KeyD" && (t.metaKey || t.ctrlKey) && !t.shiftKey && (this.cloneSelection(), e = !0), (t.keyCode == 46 || t.keyCode == 8) && t.target instanceof Element && t.target.localName != "input" && t.target.localName != "textarea" && (this.deleteSelectedNodes(), e = !0), this.selected_nodes)) for (var n in this.selected_nodes) - this.selected_nodes[n].onKeyDown && this.selected_nodes[n].onKeyDown(e); - } else if (e.type == "keyup" && (e.keyCode == 32 && (this.dragging_canvas = !1), i && this.selected_nodes)) + this.selected_nodes[n].onKeyDown && this.selected_nodes[n].onKeyDown(t); + } else if (t.type == "keyup" && (t.keyCode == 32 && (this.dragging_canvas = !1), i && this.selected_nodes)) for (var n in this.selected_nodes) - this.selected_nodes[n].onKeyUp && this.selected_nodes[n].onKeyUp(e); - if (this.graph.change(), t) - return e.preventDefault(), e.stopImmediatePropagation(), !1; + this.selected_nodes[n].onKeyUp && this.selected_nodes[n].onKeyUp(t); + if (this.graph.change(), e) + return t.preventDefault(), t.stopImmediatePropagation(), !1; } cutToClipboard() { this.copyToClipboard(), this.deleteSelectedNodes(); } copyToClipboard() { - var e = { + var t = { nodes: [], nodeCloneData: {}, links: [] - }, t = 0, i = []; + }, e = 0, i = []; for (var n in this.selected_nodes) { var s = this.selected_nodes[n]; - s._relative_id = t, i.push(s), t += 1; + s._relative_id = e, i.push(s), e += 1; } for (let h = 0; h < i.length; ++h) { let p = i[h]; @@ -6444,7 +6444,7 @@ const ce = class { console.warn("node type not found: " + p.type); continue; } - if (e.nodes.push(c.serialize()), e.nodeCloneData[c.id] = { + if (t.nodes.push(c.serialize()), t.nodeCloneData[c.id] = { prevNodeID: p.id, cloneData: f }, p.inputs && p.inputs.length) @@ -6456,7 +6456,7 @@ const ce = class { var l = this.graph.getNodeById( a.origin_id ); - !l || !this.selected_nodes[l.id] || !this.selected_nodes[l.id].clonable || e.links.push([ + !l || !this.selected_nodes[l.id] || !this.selected_nodes[l.id].clonable || t.links.push([ l._relative_id, a.origin_slot, //j, @@ -6469,25 +6469,25 @@ const ce = class { } localStorage.setItem( "litegrapheditor_clipboard", - JSON.stringify(e) + JSON.stringify(t) ); } pasteFromClipboard() { - var e = localStorage.getItem("litegrapheditor_clipboard"); - if (e) { + var t = localStorage.getItem("litegrapheditor_clipboard"); + if (t) { this.graph.beforeChange(); - for (var t = JSON.parse(e), i = null, n = null, s = 0; s < t.nodes.length; ++s) - i ? (i[0] > t.nodes[s].pos[0] && (i[0] = t.nodes[s].pos[0], n[0] = s), i[1] > t.nodes[s].pos[1] && (i[1] = t.nodes[s].pos[1], n[1] = s)) : (i = [t.nodes[s].pos[0], t.nodes[s].pos[1]], n = [s, s]); - for (var r = [], s = 0; s < t.nodes.length; ++s) { - var o = t.nodes[s], a = u.createNode(o.type); + for (var e = JSON.parse(t), i = null, n = null, s = 0; s < e.nodes.length; ++s) + i ? (i[0] > e.nodes[s].pos[0] && (i[0] = e.nodes[s].pos[0], n[0] = s), i[1] > e.nodes[s].pos[1] && (i[1] = e.nodes[s].pos[1], n[1] = s)) : (i = [e.nodes[s].pos[0], e.nodes[s].pos[1]], n = [s, s]); + for (var r = [], s = 0; s < e.nodes.length; ++s) { + var o = e.nodes[s], a = u.createNode(o.type); if (a) { a.configure(o), a.pos[0] += this.graph_mouse[0] - i[0], a.pos[1] += this.graph_mouse[1] - i[1]; - const { cloneData: c, prevNodeID: v } = t.nodeCloneData[a.id]; + const { cloneData: c, prevNodeID: v } = e.nodeCloneData[a.id]; this.graph.add(a, { doProcessChange: !1, addedBy: "paste", prevNodeID: v, cloneData: c }), r.push(a); } } - for (var s = 0; s < t.links.length; ++s) { - var l = t.links[s], h = r[l[0]], p = r[l[2]]; + for (var s = 0; s < e.links.length; ++s) { + var l = e.links[s], h = r[l[0]], p = r[l[2]]; h && p ? h.connect(l[1], p, l[3]) : console.warn("Warning, nodes missing on pasting"); } this.selectNodes(r), this.graph.afterChange(); @@ -6497,40 +6497,40 @@ const ce = class { if (!this.selected_nodes || Object.keys(this.selected_nodes).length === 0) return; this.graph.beforeChange(); - const e = {}, t = [], i = {}; + const t = {}, e = [], i = {}; for (const r of Object.values(this.selected_nodes)) for (const o of r.iterateAllLinks()) - this.selected_nodes[o.origin_id] && this.selected_nodes[o.target_id] && t.push(o); + this.selected_nodes[o.origin_id] && this.selected_nodes[o.target_id] && e.push(o); const n = function(r) { if (r.clonable == !1) return; const o = r.id, a = { forNode: {} }, l = r.clone(a); - l && (i[o] = l, l.pos = [r.pos[0] + 5, r.pos[1] + 5], r.graph.add(l, { addedBy: "cloneSelection", prevNodeID: o, prevNode: r, cloneData: a }), e[l.id] = l); + l && (i[o] = l, l.pos = [r.pos[0] + 5, r.pos[1] + 5], r.graph.add(l, { addedBy: "cloneSelection", prevNodeID: o, prevNode: r, cloneData: a }), t[l.id] = l); }; for (var s in this.selected_nodes) n(this.selected_nodes[s]); - for (const r of t) { + for (const r of e) { const o = i[r.origin_id], a = i[r.target_id]; o && a && o.connect(r.origin_slot, a, r.target_slot); } - Object.keys(e).length && this.selectNodes(Object.values(e)), this.graph.afterChange(), this.setDirty(!0, !0); + Object.keys(t).length && this.selectNodes(Object.values(t)), this.graph.afterChange(), this.setDirty(!0, !0); } - processDrop(e) { - let t = e; - t.preventDefault(), this.adjustMouseEvent(t); - var i = t.clientX, n = t.clientY, s = !this.viewport || this.viewport && i >= this.viewport[0] && i < this.viewport[0] + this.viewport[2] && n >= this.viewport[1] && n < this.viewport[1] + this.viewport[3]; + processDrop(t) { + let e = t; + e.preventDefault(), this.adjustMouseEvent(e); + var i = e.clientX, n = e.clientY, s = !this.viewport || this.viewport && i >= this.viewport[0] && i < this.viewport[0] + this.viewport[2] && n >= this.viewport[1] && n < this.viewport[1] + this.viewport[3]; if (s) { - var r = [t.canvasX, t.canvasY], o = this.graph ? this.graph.getNodeOnPos(r[0], r[1]) : null; + var r = [e.canvasX, e.canvasY], o = this.graph ? this.graph.getNodeOnPos(r[0], r[1]) : null; if (!o) { var a = null; - this.onDropItem && (a = this.onDropItem(t)), a || this.checkDropItem(t); + this.onDropItem && (a = this.onDropItem(e)), a || this.checkDropItem(e); return; } if (o.onDropFile || o.onDropData) { - var l = t.dataTransfer.files; + var l = e.dataTransfer.files; if (l && l.length) for (var h = 0; h < l.length; h++) { - var p = t.dataTransfer.files[0], f = p.name; + var p = e.dataTransfer.files[0], f = p.name; if (ce.getFileExtension(f), o.onDropFile && o.onDropFile(p), o.onDropData) { var c = new FileReader(); c.onload = function(g) { @@ -6542,35 +6542,35 @@ const ce = class { } } } - return !!(o.onDropItem && o.onDropItem(t) || this.onDropItem && this.onDropItem(t)); + return !!(o.onDropItem && o.onDropItem(e) || this.onDropItem && this.onDropItem(e)); } } - checkDropItem(e) { - let t = e; - if (t.dataTransfer.files.length) { - var i = t.dataTransfer.files[0], n = ce.getFileExtension(i.name).toLowerCase(), s = u.node_types_by_file_extension[n]; + checkDropItem(t) { + let e = t; + if (e.dataTransfer.files.length) { + var i = e.dataTransfer.files[0], n = ce.getFileExtension(i.name).toLowerCase(), s = u.node_types_by_file_extension[n]; if (s) { this.graph.beforeChange(); var r = u.createNode(s.type); - r.pos = [t.canvasX, t.canvasY], this.graph.add(r), r.onDropFile && r.onDropFile(i), this.graph.afterChange(); + r.pos = [e.canvasX, e.canvasY], this.graph.add(r), r.onDropFile && r.onDropFile(i), this.graph.afterChange(); } } } - processNodeDblClicked(e) { - this.onShowNodePanel ? this.onShowNodePanel(e) : this.showShowNodePanel(e), this.onNodeDblClicked && this.onNodeDblClicked(e), this.setDirty(!0); + processNodeDblClicked(t) { + this.onShowNodePanel ? this.onShowNodePanel(t) : this.showShowNodePanel(t), this.onNodeDblClicked && this.onNodeDblClicked(t), this.setDirty(!0); } - processNodeSelected(e, t) { - this.selectNode(e, t && (t.shiftKey || t.ctrlKey || this.multi_select)), this.onNodeSelected && this.onNodeSelected(e); + processNodeSelected(t, e) { + this.selectNode(t, e && (e.shiftKey || e.ctrlKey || this.multi_select)), this.onNodeSelected && this.onNodeSelected(t); } /** selects a given node (or adds it to the current selection) */ - selectNode(e, t = !1) { - e == null ? this.deselectAllNodes() : this.selectNodes([e], t); + selectNode(t, e = !1) { + t == null ? this.deselectAllNodes() : this.selectNodes([t], e); } /** selects several nodes (or adds them to the current selection) */ - selectNodes(e, t = !1) { - t || this.deselectAllNodes(), e = e || this.graph._nodes, typeof e == "string" && (e = [e]); - for (var i in e) { - var n = e[i]; + selectNodes(t, e = !1) { + e || this.deselectAllNodes(), t = t || this.graph._nodes, typeof t == "string" && (t = [t]); + for (var i in t) { + var n = t[i]; if (n.is_selected) { this.deselectNode(n); continue; @@ -6589,14 +6589,14 @@ const ce = class { this.onSelectionChange && this.onSelectionChange(this.selected_nodes), this.setDirty(!0); } /** removes a node from the current selection */ - deselectNode(e) { - if (e.is_selected) { - if (e.onDeselected && e.onDeselected(), e.is_selected = !1, this.onNodeDeselected && this.onNodeDeselected(e), e.inputs) - for (var t = 0; t < e.inputs.length; ++t) - delete this.highlighted_links[e.inputs[t].link]; - if (e.outputs) - for (var t = 0; t < e.outputs.length; ++t) { - var i = e.outputs[t]; + deselectNode(t) { + if (t.is_selected) { + if (t.onDeselected && t.onDeselected(), t.is_selected = !1, this.onNodeDeselected && this.onNodeDeselected(t), t.inputs) + for (var e = 0; e < t.inputs.length; ++e) + delete this.highlighted_links[t.inputs[e].link]; + if (t.outputs) + for (var e = 0; e < t.outputs.length; ++e) { + var i = t.outputs[e]; if (i.links) for (var n = 0; n < i.links.length; ++n) delete this.highlighted_links[i.links[n]]; @@ -6606,8 +6606,8 @@ const ce = class { /** removes all nodes from the current selection */ deselectAllNodes() { if (this.graph) { - for (var e = this.graph._nodes, t = 0, i = e.length; t < i; ++t) { - var n = e[t]; + for (var t = this.graph._nodes, e = 0, i = t.length; e < i; ++e) { + var n = t[e]; n.is_selected && (n.onDeselected && n.onDeselected(), n.is_selected = !1, this.onNodeDeselected && this.onNodeDeselected(n)); } this.selected_nodes = {}, this.current_node = null, this.highlighted_links = {}, this.onSelectionChange && this.onSelectionChange(this.selected_nodes), this.setDirty(!0); @@ -6616,42 +6616,42 @@ const ce = class { /** deletes all nodes in the current selection from the graph */ deleteSelectedNodes() { this.graph.beforeChange(); - for (var e in this.selected_nodes) { - var t = this.selected_nodes[e]; - if (!t.block_delete) { - if (t.inputs && t.inputs.length && t.outputs && t.outputs.length && u.isValidConnection(t.inputs[0].type, t.outputs[0].type) && t.inputs[0].link && t.outputs[0].links && t.outputs[0].links.length) { - var i = t.graph.links[t.inputs[0].link], n = t.graph.links[t.outputs[0].links[0]], s = t.getInputNode(0), r = t.getOutputNodes(0)[0]; + for (var t in this.selected_nodes) { + var e = this.selected_nodes[t]; + if (!e.block_delete) { + if (e.inputs && e.inputs.length && e.outputs && e.outputs.length && u.isValidConnection(e.inputs[0].type, e.outputs[0].type) && e.inputs[0].link && e.outputs[0].links && e.outputs[0].links.length) { + var i = e.graph.links[e.inputs[0].link], n = e.graph.links[e.outputs[0].links[0]], s = e.getInputNode(0), r = e.getOutputNodes(0)[0]; s && r && s.connect(i.origin_slot, r, n.target_slot); } - this.graph.remove(t), this.onNodeDeselected && this.onNodeDeselected(t); + this.graph.remove(e), this.onNodeDeselected && this.onNodeDeselected(e); } } this.selected_nodes = {}, this.current_node = null, this.highlighted_links = {}, this.setDirty(!0), this.graph.afterChange(); } /** centers the camera on a given node */ - centerOnNode(e) { - this.ds.offset[0] = -e.pos[0] - e.size[0] * 0.5 + this.canvas.width * 0.5 / this.ds.scale, this.ds.offset[1] = -e.pos[1] - e.size[1] * 0.5 + this.canvas.height * 0.5 / this.ds.scale, this.setDirty(!0, !0); + centerOnNode(t) { + this.ds.offset[0] = -t.pos[0] - t.size[0] * 0.5 + this.canvas.width * 0.5 / this.ds.scale, this.ds.offset[1] = -t.pos[1] - t.size[1] * 0.5 + this.canvas.height * 0.5 / this.ds.scale, this.setDirty(!0, !0); } /** * adds some useful properties to a mouse event, like the position in graph coordinates * @method adjustMouseEvent **/ - adjustMouseEvent(e) { - let t = e; + adjustMouseEvent(t) { + let e = t; var i = 0, n = 0; if (this.canvas) { var s = this.canvas.getBoundingClientRect(); - i = t.clientX - s.left, n = t.clientY - s.top; + i = e.clientX - s.left, n = e.clientY - s.top; } else - i = t.clientX, n = t.clientY; - return this.last_mouse_position[0] = i, this.last_mouse_position[1] = n, t.canvasX = i / this.ds.scale - this.ds.offset[0], t.canvasY = n / this.ds.scale - this.ds.offset[1], t; + i = e.clientX, n = e.clientY; + return this.last_mouse_position[0] = i, this.last_mouse_position[1] = n, e.canvasX = i / this.ds.scale - this.ds.offset[0], e.canvasY = n / this.ds.scale - this.ds.offset[1], e; } /** process an event on widgets */ - processNodeWidgets(e, t, i, n) { - if (!e.widgets || !e.widgets.length || u.ignore_all_widget_events) + processNodeWidgets(t, e, i, n) { + if (!t.widgets || !t.widgets.length || u.ignore_all_widget_events) return null; - for (var s = t[0] - e.pos[0], r = t[1] - e.pos[1], o = e.size[0], a = this, l = this.getCanvasWindow(), h = 0; h < e.widgets.length; ++h) { - var p = e.widgets[h]; + for (var s = e[0] - t.pos[0], r = e[1] - t.pos[1], o = t.size[0], a = this, l = this.getCanvasWindow(), h = 0; h < t.widgets.length; ++h) { + var p = t.widgets[h]; if (!(!p || p.disabled)) { var f = p.computeSize ? p.computeSize(o)[1] : u.NODE_WIDGET_HEIGHT, c = p.width || o; if (!(p != n && (s < 6 || s > c - 12 || r < p.last_y || r > p.last_y + f || p.last_y === void 0))) { @@ -6659,7 +6659,7 @@ const ce = class { switch (p.type) { case "button": i.type === u.pointerevents_method + "down" && (p.callback && setTimeout(function() { - p.callback(p, a, e, t, i); + p.callback(p, a, t, e, i); }, 20), p.clicked = !0, this.dirty_canvas = !0); break; case "slider": @@ -6678,7 +6678,7 @@ const ce = class { var d = p.options.values; if (d && typeof d == "function") { let O = p.options.values; - d = O(p, e); + d = O(p, t); } var _ = null; p.type != "number" && (_ = Array.isArray(d) ? d : Object.keys(d)); @@ -6743,72 +6743,72 @@ const ce = class { ); break; default: - p.mouse && (this.dirty_canvas = p.mouse(i, [s, r], e)); + p.mouse && (this.dirty_canvas = p.mouse(i, [s, r], t)); break; } - return v != p.value && (e.onWidgetChanged && e.onWidgetChanged(p, v), e.graph._version++), p; + return v != p.value && (t.onWidgetChanged && t.onWidgetChanged(p, v), t.graph._version++), p; } } } function E(T, O) { - T.value = O, T.options && T.options.property && e.properties[T.options.property] !== void 0 && e.setProperty(T.options.property, O), T.callback && T.callback(T.value, a, e, t, i); + T.value = O, T.options && T.options.property && t.properties[T.options.property] !== void 0 && t.setProperty(T.options.property, O), T.callback && T.callback(T.value, a, t, e, i); } return null; } adjustNodesSize() { - for (var e = this.graph._nodes, t = 0; t < e.length; ++t) - e[t].size = e[t].computeSize(); + for (var t = this.graph._nodes, e = 0; e < t.length; ++e) + t[e].size = t[e].computeSize(); this.setDirty(!0, !0); } /** resizes the canvas to a given size, if no size is passed, then it tries to fill the parentNode */ - resize(e, t) { - if (!e && !t) { + resize(t, e) { + if (!t && !e) { var i = this.canvas.parentNode; - e = i.offsetWidth, t = i.offsetHeight; + t = i.offsetWidth, e = i.offsetHeight; } - this.canvas.width == e && this.canvas.height == t || (this.canvas.width = e, this.canvas.height = t, this.bgcanvas.width = this.canvas.width, this.bgcanvas.height = this.canvas.height, this.adjustCanvasForHiDPI(), this.setDirty(!0, !0)); + this.canvas.width == t && this.canvas.height == e || (this.canvas.width = t, this.canvas.height = e, this.bgcanvas.width = this.canvas.width, this.bgcanvas.height = this.canvas.height, this.adjustCanvasForHiDPI(), this.setDirty(!0, !0)); } - isAreaClicked(e, t, i, n, s) { + isAreaClicked(t, e, i, n, s) { var r = this.offset_mouse; - u.isInsideRectangle(r[0], r[1], e, t, i, n), r = this.last_click_position; - var o = r && u.isInsideRectangle(r[0], r[1], e, t, i, n), a = o && !this.block_click; + u.isInsideRectangle(r[0], r[1], t, e, i, n), r = this.last_click_position; + var o = r && u.isInsideRectangle(r[0], r[1], t, e, i, n), a = o && !this.block_click; return o && s && this.blockClick(), a; } /** * switches to live mode (node shapes are not rendered, only the content) * this feature was designed when graphs where meant to create user interfaces **/ - switchLiveMode(e) { - if (!e) { + switchLiveMode(t) { + if (!t) { this.live_mode = !this.live_mode, this.dirty_canvas = !0, this.dirty_bgcanvas = !0; return; } - var t = this, i = this.live_mode ? 1.1 : 0.9; + var e = this, i = this.live_mode ? 1.1 : 0.9; this.live_mode && (this.live_mode = !1, this.editor_alpha = 0.1); var n = setInterval(function() { - t.editor_alpha *= i, t.dirty_canvas = !0, t.dirty_bgcanvas = !0, i < 1 && t.editor_alpha < 0.01 && (clearInterval(n), i < 1 && (t.live_mode = !0)), i > 1 && t.editor_alpha > 0.99 && (clearInterval(n), t.editor_alpha = 1); + e.editor_alpha *= i, e.dirty_canvas = !0, e.dirty_bgcanvas = !0, i < 1 && e.editor_alpha < 0.01 && (clearInterval(n), i < 1 && (e.live_mode = !0)), i > 1 && e.editor_alpha > 0.99 && (clearInterval(n), e.editor_alpha = 1); }, 1); } onNodeSelectionChange() { } - touchHandler(e) { + touchHandler(t) { } - convertOffsetToCanvas(e) { - return this.ds.convertOffsetToCanvas(e); + convertOffsetToCanvas(t) { + return this.ds.convertOffsetToCanvas(t); } - convertCanvasToOffset(e, t = [0, 0]) { - return this.ds.convertCanvasToOffset(e, t); + convertCanvasToOffset(t, e = [0, 0]) { + return this.ds.convertCanvasToOffset(t, e); } /** converts event coordinates from canvas2D to graph coordinates */ - convertEventToCanvasOffset(e) { - var t = this.canvas.getBoundingClientRect(); + convertEventToCanvasOffset(t) { + var e = this.canvas.getBoundingClientRect(); return this.convertCanvasToOffset([ - e.clientX - t.left, - e.clientY - t.top + t.clientX - e.left, + t.clientY - e.top ]); } - addGraphInputNode(e, t, i) { - const n = this.graph.findNodesByClass($).find((o) => o.properties.name === t); + addGraphInputNode(t, e, i) { + const n = this.graph.findNodesByClass($).find((o) => o.properties.name === e); if (n) { this.selectNodes([n]); return; @@ -6819,15 +6819,15 @@ const ce = class { this.canvas.height * 0.5 / this.ds.scale - this.ds.offset[1] ]; this.graph.beforeChange(); - const r = e.addGraphInput(t, i, s); + const r = t.addGraphInput(e, i, s); if (r) { const o = r.innerNode; this.selectNodes([o]), this.graph.afterChange(); } else console.error("graph input node not found:", i); } - addGraphOutputNode(e, t, i) { - const n = this.graph.findNodesByClass(Q).find((o) => o.properties.name === t); + addGraphOutputNode(t, e, i) { + const n = this.graph.findNodesByClass(Q).find((o) => o.properties.name === e); if (n) { this.selectNodes([n]); return; @@ -6838,7 +6838,7 @@ const ce = class { this.canvas.height * 0.5 / this.ds.scale - this.ds.offset[1] ]; this.graph.beforeChange(); - const r = e.addGraphOutput(t, i, s); + const r = t.addGraphOutput(e, i, s); if (r) { const o = r.innerNode; this.selectNodes([o]), this.graph.afterChange(); @@ -6848,13 +6848,13 @@ const ce = class { getCanvasMenuOptions() { return C.prototype.getCanvasMenuOptions.apply(this, arguments); } - getNodeMenuOptions(e) { + getNodeMenuOptions(t) { return C.prototype.getNodeMenuOptions.apply(this, arguments); } - getLinkMenuOptions(e) { + getLinkMenuOptions(t) { return C.prototype.getLinkMenuOptions.apply(this, arguments); } - getGroupMenuOptions(e) { + getGroupMenuOptions(t) { return C.prototype.getGroupMenuOptions.apply(this, arguments); } checkPanels() { @@ -6863,127 +6863,127 @@ const ce = class { closePanels() { C.prototype.closePanels.apply(this, arguments); } - createDialog(e, t) { + createDialog(t, e) { return C.prototype.createDialog.apply(this, arguments); } - createPanel(e, t = {}) { + createPanel(t, e = {}) { return C.prototype.createPanel.apply(this, arguments); } - showSearchBox(e, t = {}) { + showSearchBox(t, e = {}) { return C.prototype.showSearchBox.apply(this, arguments); } - prompt(e = "", t, i, n, s = !1, r = null) { + prompt(t = "", e, i, n, s = !1, r = null) { return C.prototype.prompt.apply(this, arguments); } - showConnectionMenu(e = {}) { + showConnectionMenu(t = {}) { return C.prototype.showConnectionMenu.apply(this, arguments); } - showLinkMenu(e, t) { + showLinkMenu(t, e) { return C.prototype.showLinkMenu.apply(this, arguments); } - showEditPropertyValue(e, t, i) { + showEditPropertyValue(t, e, i) { return C.prototype.showEditPropertyValue.apply(this, arguments); } - showShowNodePanel(e) { + showShowNodePanel(t) { C.prototype.showShowNodePanel.apply(this, arguments); } - showSubgraphPropertiesDialog(e) { + showSubgraphPropertiesDialog(t) { return C.prototype.showSubgraphPropertiesDialog.apply(this, arguments); } - showSubgraphPropertiesDialogRight(e) { + showSubgraphPropertiesDialogRight(t) { return C.prototype.showSubgraphPropertiesDialogRight.apply(this, arguments); } - processContextMenu(e, t) { + processContextMenu(t, e) { C.prototype.processContextMenu.apply(this, arguments); } /* * Events */ - processMouseMove(e) { + processMouseMove(t) { return ge.prototype.processMouseMove.apply(this, arguments); } - processMouseDown(e) { + processMouseDown(t) { return ge.prototype.processMouseDown.apply(this, arguments); } - processMouseUp(e) { + processMouseUp(t) { return ge.prototype.processMouseUp.apply(this, arguments); } - processMouseWheel(e) { + processMouseWheel(t) { return ge.prototype.processMouseWheel.apply(this, arguments); } /* * Rendering */ - setZoom(e, t) { + setZoom(t, e) { U.prototype.setZoom.apply(this, arguments); } - bringToFront(e) { + bringToFront(t) { U.prototype.bringToFront.apply(this, arguments); } - sendToBack(e) { + sendToBack(t) { U.prototype.sendToBack.apply(this, arguments); } - computeVisibleNodes(e, t = []) { + computeVisibleNodes(t, e = []) { return U.prototype.computeVisibleNodes.apply(this, arguments); } - draw(e = !1, t = !1) { + draw(t = !1, e = !1) { U.prototype.draw.apply(this, arguments); } drawFrontCanvas() { U.prototype.drawFrontCanvas.apply(this, arguments); } - drawSubgraphPanel(e) { + drawSubgraphPanel(t) { U.prototype.drawSubgraphPanel.apply(this, arguments); } - drawSubgraphPanelLeft(e, t, i) { + drawSubgraphPanelLeft(t, e, i) { U.prototype.drawSubgraphPanelLeft.apply(this, arguments); } - drawSubgraphPanelRight(e, t, i) { + drawSubgraphPanelRight(t, e, i) { U.prototype.drawSubgraphPanelRight.apply(this, arguments); } - drawButton(e, t, i, n, s, r = u.NODE_DEFAULT_COLOR, o = "#555", a = u.NODE_TEXT_COLOR, l = !0) { + drawButton(t, e, i, n, s, r = u.NODE_DEFAULT_COLOR, o = "#555", a = u.NODE_TEXT_COLOR, l = !0) { return U.prototype.drawButton.apply(this, arguments); } drawBackCanvas() { U.prototype.drawBackCanvas.apply(this, arguments); } - renderInfo(e, t = 10, i) { + renderInfo(t, e = 10, i) { U.prototype.renderInfo.apply(this, arguments); } - drawNode(e, t) { + drawNode(t, e) { U.prototype.drawNode.apply(this, arguments); } - drawLinkTooltip(e, t) { + drawLinkTooltip(t, e) { U.prototype.drawLinkTooltip.apply(this, arguments); } - drawNodeShape(e, t, i, n, s, r, o) { + drawNodeShape(t, e, i, n, s, r, o) { U.prototype.drawNodeShape.apply(this, arguments); } - drawConnections(e) { + drawConnections(t) { U.prototype.drawConnections.apply(this, arguments); } - renderLink(e, t, i, n, s, r, o, a, l, h) { + renderLink(t, e, i, n, s, r, o, a, l, h) { U.prototype.renderLink.apply(this, arguments); } - computeConnectionPoint(e, t, i, n = w.RIGHT, s = w.LEFT) { + computeConnectionPoint(t, e, i, n = w.RIGHT, s = w.LEFT) { return U.prototype.computeConnectionPoint.apply(this, arguments); } - drawExecutionOrder(e) { + drawExecutionOrder(t) { U.prototype.drawExecutionOrder.apply(this, arguments); } - drawNodeWidgets(e, t, i, n) { + drawNodeWidgets(t, e, i, n) { U.prototype.drawNodeWidgets.apply(this, arguments); } - drawGroups(e, t) { + drawGroups(t, e) { U.prototype.drawGroups.apply(this, arguments); } /* * ComfyUI Extension */ - updateBackground(e, t) { - this._bg_img = new Image(), this._bg_img.name = e, this._bg_img.src = e, this._bg_img.onload = () => { + updateBackground(t, e) { + this._bg_img = new Image(), this._bg_img.name = t, this._bg_img.src = t, this._bg_img.onload = () => { this.draw(!0, !0); - }, this.background_image = e, this.clear_background = !0, this.clear_background_color = t, this._pattern = null; + }, this.background_image = t, this.clear_background = !0, this.clear_background_color = e, this._pattern = null; } }; let N = ce; @@ -7046,26 +7046,27 @@ N.onMenuNodeToSubgraph = C.onMenuNodeToSubgraph; N.onMenuNodeToSubgraphInputs = C.onMenuNodeToSubgraphInputs; N.onMenuNodeToSubgraphOutputs = C.onMenuNodeToSubgraphOutputs; N.onMenuNodeToParentGraph = C.onMenuNodeToParentGraph; -var j = /* @__PURE__ */ ((e) => (e[e.SEPARATOR = 0] = "SEPARATOR", e))(j || {}); +var j = /* @__PURE__ */ ((t) => (t[t.SEPARATOR = 0] = "SEPARATOR", t))(j || {}); class X { - static trigger(t, i, n, s) { + static trigger(e, i, n, s) { var r = document.createEvent("CustomEvent"); - return r.initCustomEvent(i, !0, !0, n), r.target = s, t.dispatchEvent && t.dispatchEvent(r), r; + return r.initCustomEvent(i, !0, !0, n), r.target = s, e.dispatchEvent && e.dispatchEvent(r), r; } - static isCursorOverElement(t, i) { - var n = t.clientX, s = t.clientY, r = i.getBoundingClientRect(); + static isCursorOverElement(e, i) { + var n = e.clientX, s = e.clientY, r = i.getBoundingClientRect(); return r ? s > r.top && s < r.top + r.height && n > r.left && n < r.left + r.width : !1; } - static closeAllContextMenus(t) { - t = t || window; - var i = t.document.querySelectorAll(".litecontextmenu"); + static closeAllContextMenus(e) { + e = e || window; + var i = e.document.querySelectorAll(".litecontextmenu"); if (i.length) { var n = Array.from(i); for (const s of n) s.close(); } } - constructor(t, i = {}, n) { + constructor(e, i = {}, n) { + var g; this.options = i; var s = this; i.parentMenu && (i.parentMenu.constructor !== this.constructor ? (console.error( @@ -7076,7 +7077,7 @@ class X { "Event passed to ContextMenu is not of type MouseEvent or CustomEvent. Ignoring it. (" + r + ")" ), i.event = null); var o = document.createElement("div"); - o.className = "litegraph litecontextmenu litemenubar-panel", i.className && (o.className += " " + i.className), o.style.pointerEvents = "none", setTimeout(function() { + if (o.className = "litegraph litecontextmenu litemenubar-panel", i.className && (o.className += " " + i.className), o.style.pointerEvents = "none", setTimeout(function() { o.style.pointerEvents = "auto"; }, 100), u.pointerListenerAdd( o, @@ -7101,41 +7102,36 @@ class X { return s.close(), d.preventDefault(), !0; }, !0 - ); - function a(d) { - var _ = parseInt(o.style.top); - return o.style.top = (_ + d.deltaY * i.scroll_speed).toFixed() + "px", d.preventDefault(), !0; - } - if (i.scroll_speed || (i.scroll_speed = 0.1), o.addEventListener("wheel", a, !0), o.addEventListener("mousewheel", a, !0), this.root = o, i.title) { - var l = document.createElement("div"); - l.className = "litemenu-title", l.innerHTML = i.title, o.appendChild(l); + ), i.scroll_speed = i.scroll_speed || 0.1, i.invert_scrolling = i.invert_scrolling || !1, o.addEventListener("wheel", this.onMouseWheel.bind(this), !0), o.addEventListener("mousewheel", this.onMouseWheel.bind(this), !0), this.root = o, i.title) { + var a = document.createElement("div"); + a.className = "litemenu-title", a.innerHTML = i.title, o.appendChild(a); } this.values = []; - for (let d = 0; d < t.length; d++) { - let _ = t[d], y = ""; - _ === 0 ? y = "" : typeof _ == "string" ? y = _ : y = _.content, this.addItem(y, _, i); + for (let d = 0; d < e.length; d++) { + let _ = e[d], y = ""; + _ === 0 || _ == null ? y = "" : typeof _ == "string" ? y = _ : y = _.content, this.addItem(y, _, i); } u.pointerListenerAdd(o, "enter", function(d) { o.closing_timer && clearTimeout(o.closing_timer); }); - var h = document; - i.event && i.event.target instanceof Node && (h = i.event.target.ownerDocument), h || (h = document), h.fullscreenElement ? h.fullscreenElement.appendChild(o) : h.body.appendChild(o); - var p = i.left || 0, f = i.top || 0; + var l = document; + i.event && i.event.target instanceof Node && (l = i.event.target.ownerDocument), l || (l = document), l.fullscreenElement ? l.fullscreenElement.appendChild(o) : l.body.appendChild(o); + var h = i.left || 0, p = i.top || 0; if (i.event) { - if (p = i.event.clientX - 10, f = i.event.clientY - 10, i.title && (f -= 20), i.parentMenu) { - var c = i.parentMenu.root.getBoundingClientRect(); - p = c.left + c.width; + if (h = i.event.clientX - 10, p = i.event.clientY - 10, i.title && (p -= 20), i.parentMenu) { + var f = i.parentMenu.root.getBoundingClientRect(); + h = f.left + f.width; } - var v = document.body.getBoundingClientRect(), g = o.getBoundingClientRect(); - v.height == 0 && console.error("document.body height is 0. That is dangerous, set html,body { height: 100%; }"), v.width && p > v.width - g.width - 10 && (p = v.width - g.width - 10), v.height && f > v.height - g.height - 10 && (f = v.height - g.height - 10); + var c = document.body.getBoundingClientRect(), v = o.getBoundingClientRect(); + c.height == 0 && console.error("document.body height is 0. That is dangerous, set html,body { height: 100%; }"), c.width && h > c.width - v.width - 10 && (h = c.width - v.width - 10), c.height && p > c.height - v.height - 10 && (p = c.height - v.height - 10); } - o.style.left = p + "px", o.style.top = f + "px", i.scale && (o.style.transform = "scale(" + i.scale + ")"); + o.style.left = h + "px", o.style.top = p + "px", i.scale && (o.style.transform = "scale(" + i.scale + ")"), (g = u.onContextMenuCreated) == null || g.call(u, this); } - addItem(t, i, n = {}) { + addItem(e, i, n = {}) { var s = this, r = document.createElement("div"); r.className = "litemenu-entry submenu"; var o = !1; - typeof i == "string" && (i = { content: i }), i === 0 ? r.classList.add("separator") : (r.innerHTML = i.title ? i.title : t, i.disabled && (o = !0, r.classList.add("disabled")), (i.submenu || i.has_submenu) && r.classList.add("has_submenu"), typeof i == "function" ? r.dataset.value = t : r.dataset.value = "" + this.values.length, i.className && (r.className += " " + i.className)), this.values.push(i), this.root.appendChild(r), o || r.addEventListener("click", h), n.autoopen && u.pointerListenerAdd(r, "enter", l); + typeof i == "string" && (i = { content: i }), i === 0 || i == null ? r.classList.add("separator") : (r.innerHTML = i.title ? i.title : e, i.disabled && (o = !0, r.classList.add("disabled")), (i.submenu || i.has_submenu) && r.classList.add("has_submenu"), typeof i == "function" ? r.dataset.value = e : r.dataset.value = "" + this.values.length, i.className && (r.className += " " + i.className)), this.values.push(i), this.root.appendChild(r), o || r.addEventListener("click", h), n.autoopen && u.pointerListenerAdd(r, "enter", l); let a = this; function l(p) { var f = this.value; @@ -7191,8 +7187,8 @@ class X { } return r; } - close(t, i) { - this.root.parentNode && this.root.parentNode.removeChild(this.root), this.parentMenu && !i && (this.parentMenu.lock = !1, this.parentMenu.current_submenu = null, t === void 0 ? this.parentMenu.close() : t && !X.isCursorOverElement(t, this.parentMenu.root) && X.trigger(this.parentMenu.root, u.pointerevents_method + "leave", t)), this.current_submenu && this.current_submenu.close(t, !0), this.root.closing_timer && clearTimeout(this.root.closing_timer); + close(e, i) { + this.root.parentNode && this.root.parentNode.removeChild(this.root), this.parentMenu && !i && (this.parentMenu.lock = !1, this.parentMenu.current_submenu = null, e === void 0 ? this.parentMenu.close() : e && !X.isCursorOverElement(e, this.parentMenu.root) && X.trigger(this.parentMenu.root, u.pointerevents_method + "leave", e)), this.current_submenu && this.current_submenu.close(e, !0), this.root.closing_timer && clearTimeout(this.root.closing_timer); } getTopMenu() { return this.options.parentMenu ? this.options.parentMenu.getTopMenu() : this; @@ -7200,6 +7196,10 @@ class X { getFirstEvent() { return this.options.parentMenu ? this.options.parentMenu.getFirstEvent() : this.options.event; } + onMouseWheel(e) { + var i = parseInt(this.root.style.top); + return this.root.style.top = (i + e.deltaY * this.options.scroll_speed * (this.options.invert_scrolling ? -1 : 1)).toFixed() + "px", e.preventDefault(), !0; + } } export { Ae as BASE_SLOT_TYPES, @@ -7211,7 +7211,7 @@ export { Be as DragAndScale, $ as GraphInput, Q as GraphOutput, - Y as LConnectionKind, + W as LConnectionKind, Pe as LGraph, N as LGraphCanvas, ge as LGraphCanvas_Events, @@ -7234,9 +7234,9 @@ export { Te as clamp, J as getLitegraphTypeName, we as getSlotTypesIn, - Ye as getSlotTypesInFormatted, + We as getSlotTypesInFormatted, Le as getSlotTypesOut, - We as getSlotTypesOutFormatted, + Ye as getSlotTypesOutFormatted, Ce as getStaticProperty, ye as getStaticPropertyOnInstance, Se as isValidLitegraphType, diff --git a/web/scripts/graphNode.js b/web/scripts/graphNode.js index f966b31ab..47dfab70e 100644 --- a/web/scripts/graphNode.js +++ b/web/scripts/graphNode.js @@ -7,6 +7,7 @@ export class ComfyGraphNode extends LGraphNode { constructor(title, app) { super(title) this.app = app; + this.serialize_widgets = true; } getImageTop() { @@ -260,12 +261,6 @@ export class ComfyBackendNode extends ComfyGraphNode { this.comfyClass = comfyClass; this.isBackendNode = true; - const color = LGraphCanvas.node_colors["yellow"]; - if (this.color == null) - this.color = color.color - if (this.bgColor == null) - this.bgColor = color.bgColor - this.#setup(nodeDef) // if (nodeDef.output_node) { @@ -317,7 +312,6 @@ export class ComfyBackendNode extends ComfyGraphNode { this.addOutput(output.name, output.type, { shape: outputShape }); } - this.serialize_widgets = false; // app.#invokeExtensionsAsync("nodeCreated", this); } diff --git a/web/scripts/utils.js b/web/scripts/utils.js index fccaaff4b..85526a9be 100644 --- a/web/scripts/utils.js +++ b/web/scripts/utils.js @@ -1,3 +1,10 @@ export function range(size, startAt = 0) { return [...Array(size).keys()].map(i => i + startAt); } + +export function hook(klass, fnName, cb) { + const orig = location[fnName]; + location[fnName] = (...args) => { + cb(orig, ...args); + } +} diff --git a/web/scripts/widgets.js b/web/scripts/widgets.js index 63036a45a..8d61a4c34 100644 --- a/web/scripts/widgets.js +++ b/web/scripts/widgets.js @@ -9,7 +9,7 @@ function getNumberDefaults(inputData, defaultStep) { if (max == undefined) max = 2048; if (step == undefined) step = defaultStep; - return { val: defaultVal, config: { min, max, step: 10.0 * step } }; + return { val: defaultVal, config: { min, max, step: step } }; } export function addValueControlWidget(node, targetWidget, defaultValue = "randomize", values) { @@ -50,20 +50,20 @@ export function addValueControlWidget(node, targetWidget, defaultValue = "random // limit to something that javascript can handle max = Math.min(1125899906842624, max); min = Math.max(-1125899906842624, min); - let range = (max - min) / (targetWidget.options.step / 10); + let range = (max - min) / (targetWidget.options.step); //adjust values based on valueControl Behaviour switch (v) { case "fixed": break; case "increment": - targetWidget.value += targetWidget.options.step / 10; + targetWidget.value += targetWidget.options.step; break; case "decrement": - targetWidget.value -= targetWidget.options.step / 10; + targetWidget.value -= targetWidget.options.step; break; case "randomize": - targetWidget.value = Math.floor(Math.random() * range) * (targetWidget.options.step / 10) + min; + targetWidget.value = Math.floor(Math.random() * range) * (targetWidget.options.step) + min; default: break; } @@ -276,7 +276,7 @@ export const ComfyWidgets = { inputName, val, function (v) { - const s = this.options.step / 10; + const s = this.options.step; this.value = Math.round(v / s) * s; }, config