From ad55fd5b6004138b18d9238d5e1f7704bbf323ed Mon Sep 17 00:00:00 2001 From: space-nuko <24979496+space-nuko@users.noreply.github.com> Date: Wed, 23 Aug 2023 12:44:23 -0500 Subject: [PATCH] fix --- web/extensions/core/rerouteNode.js | 2 +- web/lib/litegraph.core.js | 3256 ++++++++++++++-------------- 2 files changed, 1638 insertions(+), 1620 deletions(-) diff --git a/web/extensions/core/rerouteNode.js b/web/extensions/core/rerouteNode.js index afc3a69b2..9c7ef2252 100644 --- a/web/extensions/core/rerouteNode.js +++ b/web/extensions/core/rerouteNode.js @@ -26,7 +26,7 @@ app.registerExtension({ this.applyOrientation(); // Prevent multiple connections to different types when we have no input - if (connected && type === LiteGraph.OUTPUT) { + if (connected && type === LConnectionKind.OUTPUT) { // Ignore wildcard nodes as these will be updated to real types const types = new Set(this.outputs[0].links.map((l) => app.graph.links[l].type).filter((t) => t !== "*")); if (types.size > 1) { diff --git a/web/lib/litegraph.core.js b/web/lib/litegraph.core.js index 1bf617e22..a99335f67 100644 --- a/web/lib/litegraph.core.js +++ b/web/lib/litegraph.core.js @@ -1,77 +1,77 @@ -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 || {}); +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 || {}); const re = ["Always", "On Event", "Never", "On Trigger"], Oe = ["#666", "#422", "#333", "#224", "#626"]; -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 || {}); +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 || {}); const Ie = ["default", "box", "round", "circle", "card", "arrow", "square"]; -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 || {}); +var W = /* @__PURE__ */ ((e) => (e[e.INPUT = 0] = "INPUT", e[e.OUTPUT = 1] = "OUTPUT", e))(W || {}), 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 || {}); const Xe = ["Straight", "Linear", "Spline"]; -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 || {}); +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 || {}); const Ae = ["*", "array", "object", "number", "string", "enum", "boolean", "table"]; -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; +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; } -function ve(t, e) { - return t.reduce((i, n) => { - const s = e(n); +function ve(e, t) { + return e.reduce((i, n) => { + const s = t(n); return i[s] = n, i; }, {}); } -function Ce(t, e) { - return e in t ? t[e] : null; +function Ce(e, t) { + return t in e ? e[t] : null; } -function ye(t, e) { - return e in t.constructor ? t.constructor[e] : null; +function ye(e, t) { + return t in e.constructor ? e.constructor[t] : null; } -function Ge(t, e) { - if (t.target !== e) +function Ge(e, t) { + if (e.target !== t) return; - let i = t.clientX - parseInt(window.getComputedStyle(e).left), n = t.clientY - parseInt(window.getComputedStyle(e).top); + let i = e.clientX - parseInt(window.getComputedStyle(t).left), n = e.clientY - parseInt(window.getComputedStyle(t).top); const s = (o) => { if (o.buttons === 0) { r(); return; } - e.style.top = o.clientY - n + "px", e.style.left = o.clientX - i + "px"; + t.style.top = o.clientY - n + "px", t.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(t) { - return t.addEventListener("mousedown", (e) => Ge(e, t)), t.classList.add("draggable"), t; +function Ee(e) { + return e.addEventListener("mousedown", (t) => Ge(t, e)), e.classList.add("draggable"), e; } -function J(t) { - return t === I.EVENT ? "Event" : t === I.ACTION ? "Action" : t === I.DEFAULT ? "Default" : t; +function J(e) { + return e === I.EVENT ? "Event" : e === I.ACTION ? "Action" : e === I.DEFAULT ? "Default" : e; } -function Se(t) { - return t === I.EVENT || t === I.ACTION || t === I.DEFAULT || typeof t == "string"; +function Se(e) { + return e === I.EVENT || e === I.ACTION || e === I.DEFAULT || typeof e == "string"; } const S = class { /** Register a node class so it can be listed when the user wants to create a new one */ - static registerNodeType(t) { - S.debug && console.log("Node registered: " + t.type); - const e = t.name, i = t.type; + static registerNodeType(e) { + S.debug && console.log("Node registered: " + e.type); + const t = e.name, i = e.type; if (!i) - throw console.error(t), new Error("Config has no type: " + t); - if (S.debug && console.debug(e, i), t.category == null || t.category === "") { + throw console.error(e), new Error("Config has no type: " + e); + if (S.debug && console.debug(t, i), e.category == null || e.category === "") { const s = i.lastIndexOf("/"); - t.category = i.substring(0, s); + e.category = i.substring(0, s); } - t.title || (t.title = e); + e.title || (e.title = t); const n = S.registered_node_types[i]; - 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); + 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); } - 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); + 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); } /** removes a node type from the system */ - 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]; + 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]; } /** * 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(t, e, i = !1) { + static registerNodeAndSlotType(e, t, i = !1) { let n; - if (typeof t == "string" ? n = S.registered_node_types[t] : "type" in t ? n = S.registered_node_types[t.type] : n = t, !n) - throw new Error("Node not registered!" + t); + if (typeof e == "string" ? n = S.registered_node_types[e] : "type" in e ? n = S.registered_node_types[e.type] : n = e, !n) + throw new Error("Node not registered!" + e); var s = n.class.__litegraph_type__; - if (typeof e == "string") - var r = e.split(","); - else if (e == I.EVENT || e == I.ACTION) + if (typeof t == "string") + var r = t.split(","); + else if (t == I.EVENT || t == 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(t, e, i = {}) { + static createNode(e, t, i = {}) { let n = null, s; - if (typeof t == "string") - s = t; - else if (s = t.__LITEGRAPH_TYPE__, !s) - throw console.error(t), "Node was not registered yet!"; + if (typeof e == "string") + s = e; + else if (s = e.__LITEGRAPH_TYPE__, !s) + throw console.error(e), "Node was not registered yet!"; if (n = S.registered_node_types[s], !n) return console.warn( - 'GraphNode type "' + t + '" not registered.' + 'GraphNode type "' + e + '" not registered.' ), null; - e = e || n.title || s; + t = t || n.title || s; var r = null; const o = i.constructorArgs || []; if (S.catch_exceptions) try { - r = new n.class(e, ...o); + r = new n.class(t, ...o); } catch (p) { return console.error("Error creating node!", p), null; } else - 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) + 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) 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(t) { - return S.registered_node_types[t]; + static getNodeType(e) { + return S.registered_node_types[e]; } /** * 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(t, e) { + static getNodeTypesInCategory(e, t) { var i = []; for (var n in S.registered_node_types) { var s = S.registered_node_types[n]; - s.filter == e && (t == "" ? s.category == null && i.push(s) : s.category == t && i.push(s)); + s.filter == t && (e == "" ? s.category == null && i.push(s) : s.category == e && 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(t) { - var e = { "": 1 }; + static getNodeTypesCategories(e) { + var t = { "": 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 != t) + if (n.filter != e) continue; - e[n.category] = 1; + t[n.category] = 1; } } var s = []; - for (var i in e) + for (var i in t) 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(t) { - for (var e = document.getElementsByTagName("script"), i = [], n = 0; n < e.length; n++) - i.push(e[n]); + static reloadNodes(e) { + for (var t = document.getElementsByTagName("script"), i = [], n = 0; n < t.length; n++) + i.push(t[n]); var s = document.getElementsByTagName("head")[0]; - t = document.location.href + t; + e = document.location.href + e; for (var n = 0; n < i.length; n++) { var r = i[n].src; - if (!(!r || r.substr(0, t.length) != t)) + if (!(!r || r.substr(0, e.length) != e)) 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(t, e) { - if (t == null) + static cloneObject(e, t) { + if (e == null) return null; - var i = JSON.parse(JSON.stringify(t)); - if (!e) + var i = JSON.parse(JSON.stringify(e)); + if (!t) return i; for (var n in i) - e[n] = i[n]; - return e; + t[n] = i[n]; + return t; } /** * 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(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) + 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) return !0; - 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) + 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) 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(t, e) { - for (var i in t) - if (t[i] != e[i]) + static compareObjects(e, t) { + for (var i in e) + if (e[i] != t[i]) return !1; return !0; } - static distance(t, e) { + static distance(e, t) { return Math.sqrt( - (e[0] - t[0]) * (e[0] - t[0]) + (e[1] - t[1]) * (e[1] - t[1]) + (t[0] - e[0]) * (t[0] - e[0]) + (t[1] - e[1]) * (t[1] - e[1]) ); } - 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 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 isInsideRectangle(t, e, i, n, s, r) { - return i < t && i + s > t && n < e && n + r > e; + static isInsideRectangle(e, t, i, n, s, r) { + return i < e && i + s > e && n < t && n + r > t; } // [minx,miny,maxx,maxy] - 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 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 isInsideBounding(t, e) { - return !(t[0] < e[0][0] || t[1] < e[0][1] || t[0] > e[1][0] || t[1] > e[1][1]); + 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]); } // bounding overlap, format: [ startx, starty, width, height ] - 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]); + 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]); } // 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(t) { - t.charAt(0) == "#" && (t = t.slice(1)), t = t.toUpperCase(); - var e = "0123456789ABCDEF"; + static hex2num(e) { + e.charAt(0) == "#" && (e = e.slice(1)), e = e.toUpperCase(); + var t = "0123456789ABCDEF"; let i; for (var n = 0, s, r, o = 0; o < 6; o += 2) - s = e.indexOf(t.charAt(o)), r = e.indexOf(t.charAt(o + 1)), i[n] = s * 16 + r, n++; + s = t.indexOf(e.charAt(o)), r = t.indexOf(e.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(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); + 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); 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(t, e, i, n = !1) { - if (!(!t || !t.addEventListener || !e || typeof i != "function")) { - var s = S.pointerevents_method, r = e; + static pointerListenerAdd(e, t, i, n = !1) { + if (!(!e || !e.addEventListener || !t || typeof i != "function")) { + var s = S.pointerevents_method, r = t; 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": - t.addEventListener(s + r, i, n); + e.addEventListener(s + r, i, n); case "leave": case "cancel": case "gotpointercapture": case "lostpointercapture": if (s != "mouse") - return t.addEventListener(s + r, i, n); + return e.addEventListener(s + r, i, n); default: - return t.addEventListener(r, i, n); + return e.addEventListener(r, i, n); } } } - static pointerListenerRemove(t, e, i, n = !1) { - if (!(!t || !t.removeEventListener || !e || typeof i != "function")) - switch (e) { + static pointerListenerRemove(e, t, i, n = !1) { + if (!(!e || !e.removeEventListener || !t || typeof i != "function")) + switch (t) { case "down": case "up": case "move": case "over": case "out": case "enter": - (S.pointerevents_method == "pointer" || S.pointerevents_method == "mouse") && t.removeEventListener(S.pointerevents_method + e, i, n); + (S.pointerevents_method == "pointer" || S.pointerevents_method == "mouse") && e.removeEventListener(S.pointerevents_method + t, i, n); case "leave": case "cancel": case "gotpointercapture": case "lostpointercapture": if (S.pointerevents_method == "pointer") - return t.removeEventListener(S.pointerevents_method + e, i, n); + return e.removeEventListener(S.pointerevents_method + t, i, n); default: - return t.removeEventListener(e, i, n); + return e.removeEventListener(t, 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(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)); + 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)); } - 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( + 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( "mousewheel", this._binded_mouse_callback, !1 - ), e.addEventListener("wheel", this._binded_mouse_callback, !1); + ), t.addEventListener("wheel", this._binded_mouse_callback, !1); } - computeVisibleArea(e) { + computeVisibleArea(t) { 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]; - e && (s += e[0] / this.scale, r += e[1] / this.scale, i = e[2], n = e[3]); + t && (s += t[0] / this.scale, r += t[1] / this.scale, i = t[2], n = t[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(e) { + onMouse(t) { if (!this.enabled) return; var i = this.element, n = i.getBoundingClientRect(); - let s = e; + let s = t; 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(e) { - e.scale(this.scale, this.scale), e.translate(this.offset[0], this.offset[1]); + toCanvasContext(t) { + t.scale(this.scale, this.scale), t.translate(this.offset[0], this.offset[1]); } - convertOffsetToCanvas(e) { + convertOffsetToCanvas(t) { return [ - (e[0] + this.offset[0]) * this.scale, - (e[1] + this.offset[1]) * this.scale + (t[0] + this.offset[0]) * this.scale, + (t[1] + this.offset[1]) * this.scale ]; } - 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; + 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; } - mouseDrag(e, i) { - this.offset[0] += e / this.scale, this.offset[1] += i / this.scale, this.onredraw && this.onredraw(this); + mouseDrag(t, i) { + this.offset[0] += t / this.scale, this.offset[1] += i / this.scale, this.onredraw && this.onredraw(this); } - 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) { + 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) { 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 = e, Math.abs(this.scale - 1) < 0.01 && (this.scale = 1); + this.scale = t, 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(e, i) { - this.changeScale(this.scale * e, i); + changeDeltaScale(t, i) { + this.changeScale(this.scale * t, i); } reset() { this.scale = 1, this.offset[0] = 0, this.offset[1] = 0; } } class ge { - processMouseDown(e) { + processMouseDown(t) { if (this.set_canvas_dirty_on_mouse_event && (this.dirty_canvas = !0), !this.graph) return; - let i = e; + let i = t; this.adjustMouseEvent(i); var n = this.getCanvasWindow(); n.document, N.active_canvas = this; @@ -740,8 +740,8 @@ class ge { } } } - processMouseMove(e) { - let i = e; + processMouseMove(t) { + let i = t; 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); @@ -847,8 +847,8 @@ class ge { } return r && !this.selected_group_resizing && !this.selected_group_moving && (this.selected_group = r), i.preventDefault(), !1; } - processMouseUp(e) { - let i = e; + processMouseUp(t) { + let i = t; 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(e) { - let i = e; + processMouseWheel(t) { + let i = t; 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(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); + 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); } /** brings a node to front (above all other nodes) */ - bringToFront(t) { - var e = this.graph._nodes.indexOf(t); - e != -1 && (this.graph._nodes.splice(e, 1), this.graph._nodes.push(t)); + bringToFront(e) { + var t = this.graph._nodes.indexOf(e); + t != -1 && (this.graph._nodes.splice(t, 1), this.graph._nodes.push(e)); } /** sends a node to the back (below all other nodes) */ - sendToBack(t) { - var e = this.graph._nodes.indexOf(t); - e != -1 && (this.graph._nodes.splice(e, 1), this.graph._nodes.unshift(t)); + sendToBack(e) { + var t = this.graph._nodes.indexOf(e); + t != -1 && (this.graph._nodes.splice(t, 1), this.graph._nodes.unshift(e)); } /** checks which nodes are visible (inside the camera area) */ - 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]; + 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]; 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(t = !1, e = !1) { + draw(e = !1, t = !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 || 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; + 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; } } /** draws the front canvas (the one containing all the nodes) */ drawFrontCanvas() { this.dirty_canvas = !1, this.ctx || (this.ctx = this.canvas.getContext("2d")); - 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); + 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); for (var n = this.computeVisibleNodes( null, this.visible_nodes ), s = 0; s < n.length; ++s) { var r = n[s]; - t.save(), t.translate(r.pos[0], r.pos[1]), this.drawNode(r, t), t.restore(); + e.save(), e.translate(r.pos[0], r.pos[1]), this.drawNode(r, e), e.restore(); } - 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; + 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; 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( - t, + e, this.connecting_pos, [this.graph_mouse[0], this.graph_mouse[1]], null, @@ -1019,85 +1019,85 @@ const ie = class { o, h, w.CENTER - ), t.beginPath(), p === k.BOX_SHAPE ? (t.rect( + ), e.beginPath(), p === k.BOX_SHAPE ? (e.rect( this.connecting_pos[0] - 6 + 0.5, this.connecting_pos[1] - 5 + 0.5, 14, 10 - ), t.fill(), t.beginPath(), t.rect( + ), e.fill(), e.beginPath(), e.rect( this.graph_mouse[0] - 6 + 0.5, this.graph_mouse[1] - 5 + 0.5, 14, 10 - )) : 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( + )) : 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( this.connecting_pos[0], this.connecting_pos[1], 4, 0, Math.PI * 2 - ), t.fill(), t.beginPath(), t.arc( + ), e.fill(), e.beginPath(), e.arc( this.graph_mouse[0], this.graph_mouse[1], 4, 0, Math.PI * 2 - )), t.fill(), t.fillStyle = "#ffcc00", this._highlight_input) { - t.beginPath(); + )), e.fill(), e.fillStyle = "#ffcc00", this._highlight_input) { + e.beginPath(); var f = this._highlight_input_slot.shape; - 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( + 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( this._highlight_input[0], this._highlight_input[1], 6, 0, Math.PI * 2 - ), t.fill(); + ), e.fill(); } - 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 && (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[0], this._highlight_output[1], 6, 0, Math.PI * 2 - ), t.fill()); + ), e.fill()); } - this.dragging_rectangle && (t.strokeStyle = "#FFF", t.strokeRect( + this.dragging_rectangle && (e.strokeStyle = "#FFF", e.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(t, this.over_link_center) : this.onDrawLinkTooltip && this.onDrawLinkTooltip(t, null, this), this.onDrawForeground && this.onDrawForeground(t, this.visible_area), t.restore(); + )), 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._graph_stack && this._graph_stack.length && this.render_subgraph_panels && this.drawSubgraphPanel(t), this.onDrawOverlay && this.onDrawOverlay(t), i && t.restore(); + this._graph_stack && this._graph_stack.length && this.render_subgraph_panels && this.drawSubgraphPanel(e), this.onDrawOverlay && this.onDrawOverlay(e), i && e.restore(); } } /** * draws the panel in the corner that shows subgraph properties * @method drawSubgraphPanel **/ - drawSubgraphPanel(t) { - var e = this.graph, i = e._subgraph_node; + drawSubgraphPanel(e) { + var t = this.graph, i = t._subgraph_node; if (!i) { console.warn("subgraph without subnode"); return; } - this.drawSubgraphPanelLeft(e, i, t), this.drawSubgraphPanelRight(e, i, t); + this.drawSubgraphPanelLeft(t, i, e), this.drawSubgraphPanelRight(t, i, e); } - drawSubgraphPanelLeft(t, e, i) { - var n = e.inputs ? e.inputs.length : 0, s = 200, r = Math.floor(u.NODE_SLOT_HEIGHT * 1.6); + drawSubgraphPanelLeft(e, t, i) { + var n = t.inputs ? t.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", e.inputs) - for (var a = 0; a < e.inputs.length; ++a) { - var l = e.inputs[a]; + if (i.font = "14px Arial", t.inputs) + for (var a = 0; a < t.inputs.length; ++a) { + var l = t.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(e); + this.drawButton(20, o + 2, s - 20, r - 2, "+", "#151515", "#222") && this.showSubgraphPropertiesDialog(t); } - 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); + 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); 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", e.outputs) - for (var p = 0; p < e.outputs.length; ++p) { - var f = e.outputs[p]; + if (i.font = "14px Arial", t.outputs) + for (var p = 0; p < t.outputs.length; ++p) { + var f = t.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(e); + this.drawButton(s - r, h + 2, r - 20, o - 2, "+", "#151515", "#222") && this.showSubgraphPropertiesDialogRight(t); } //Draws a button into the canvas overlay and computes if it was clicked using the immediate gui paradigm - drawButton(t, e, i, n, s, r = u.NODE_DEFAULT_COLOR, o = "#555", a = u.NODE_TEXT_COLOR, l = !1) { + drawButton(e, t, 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], t, e, i, n); + var p = this.ctx, f = this.offset_mouse, c = h && u.isInsideRectangle(f[0], f[1], e, t, i, n); f = this.last_click_position_offset; - 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 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 g = v && h; return v && this.blockClick(), g; } /** draws every group area in the background */ - drawGroups(t, e) { + drawGroups(e, t) { if (this.graph) { var i = this.graph._groups; - e.save(), e.globalAlpha = 0.5 * this.editor_alpha; + t.save(), t.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)) { - e.fillStyle = s.color || "#335", e.strokeStyle = s.color || "#335"; + t.fillStyle = s.color || "#335", t.strokeStyle = s.color || "#335"; var r = s._pos, o = s._size; - 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(); + 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(); var a = s.font_size || u.DEFAULT_GROUP_FONT_SIZE; - e.font = a + "px Arial", e.textAlign = "left", e.fillText(s.title, r[0] + 4, r[1] + a); + t.font = a + "px Arial", t.textAlign = "left", t.fillText(s.title, r[0] + 4, r[1] + a); } } - e.restore(); + t.restore(); } } /** draws some useful stats in the corner of the canvas */ - 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(); + 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(); } /** draws the back canvas (the one containing the background and the connections) */ drawBackCanvas() { - 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(); + 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(); const o = this._graph_stack[this._graph_stack.length - 1].graph, a = this.graph._subgraph_node; - 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"; + 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"; let l = ""; for (let h = 1; h < this._graph_stack.length; ++h) l += o._subgraph_node.getTitle() + " >> "; - e.fillText( + t.fillText( l + a.getTitle(), - t.width * 0.5, + e.width * 0.5, 40 - ), e.restore(); + ), t.restore(); } let n = !1; - 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( + 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( 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 ? 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.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.draw(!0, !0); }); var s = null; - 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._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.visible_area[0], this.visible_area[1], this.visible_area[2], this.visible_area[3] - ), e.fillStyle = "transparent"), e.globalAlpha = 1, e.imageSmoothingEnabled = e.imageSmoothingEnabled = !0; + ), t.fillStyle = "transparent"), t.globalAlpha = 1, t.imageSmoothingEnabled = t.imageSmoothingEnabled = !0; } - 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.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.dirty_bgcanvas = !1, this.dirty_canvas = !0; } /** draws the given node inside the canvas */ - 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; + 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; var s = this.ds.scale < 0.6; if (this.live_mode) { - t.flags.collapsed || (e.shadowColor = "transparent", t.onDrawForeground && t.onDrawForeground(e, this, this.canvas)); + e.flags.collapsed || (t.shadowColor = "transparent", e.onDrawForeground && e.onDrawForeground(t, this, this.canvas)); return; } var r = this.editor_alpha; - 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); + 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); } - 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( + 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( a[0] * 0.5, a[1] * 0.5, a[0] * 0.5, 0, Math.PI * 2 - ), e.clip()), t.has_errors && (n = "red"), this.drawNodeShape( - t, + ), t.clip()), e.has_errors && (n = "red"), this.drawNodeShape( e, + t, [a[0], a[1]], i, n, - 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; + 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; var p = !s, f = this.connecting_output, c = this.connecting_input; - e.lineWidth = 1; + t.lineWidth = 1; var v = 0, g = [0, 0]; - if (t.flags.collapsed) { + if (e.flags.collapsed) { if (this.render_collapsed_slots) { var A = null, M = null; - if (t.inputs) - for (let G = 0; G < t.inputs.length; G++) { - let z = t.inputs[G]; + if (e.inputs) + for (let G = 0; G < e.inputs.length; G++) { + let z = e.inputs[G]; if (z.link != null) { A = z; break; } } - if (t.outputs) - for (let G = 0; G < t.outputs.length; G++) { - let z = t.outputs[G]; + if (e.outputs) + for (let G = 0; G < e.outputs.length; G++) { + let z = e.outputs[G]; !z.links || !z.links.length || (M = z); } if (A) { var L = 0, B = u.NODE_TITLE_HEIGHT * -0.5; - 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(); + 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(); } if (M) { - 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(); + 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(); } } } else { - 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(); + 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(); var E = !0; - if (_.shape === k.BOX_SHAPE ? l ? e.rect( + if (_.shape === k.BOX_SHAPE ? l ? t.rect( m[0] - 5 + 0.5, m[1] - 8 + 0.5, 10, 14 - ) : e.rect( + ) : t.rect( m[0] - 6 + 0.5, m[1] - 5 + 0.5, 14, 10 - ) : 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) { + ) : 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) { var T = _.label != null ? _.label : _.name; - 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)); + 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)); } } - 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]; + 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]; var y = z.type, b = z.shape; - 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(); + 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(); var E = !0; - if (b === k.BOX_SHAPE ? l ? e.rect( + if (b === k.BOX_SHAPE ? l ? t.rect( m[0] - 5 + 0.5, m[1] - 8 + 0.5, 10, 14 - ) : e.rect( + ) : t.rect( m[0] - 6 + 0.5, m[1] - 5 + 0.5, 14, 10 - ) : 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) { + ) : 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) { var T = z.label != null ? z.label : z.name; - 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)); + 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)); } } - if (e.textAlign = "left", e.globalAlpha = 1, t.widgets) { + if (t.textAlign = "left", t.globalAlpha = 1, e.widgets) { var O = v; - (l || t.widgets_up) && (O = 2), t.widgets_start_y != null && (O = t.widgets_start_y), this.drawNodeWidgets( - t, - O, + (l || e.widgets_up) && (O = 2), e.widgets_start_y != null && (O = e.widgets_start_y), this.drawNodeWidgets( e, - this.node_widget && this.node_widget[0] == t ? this.node_widget[1] : null + O, + t, + this.node_widget && this.node_widget[0] == e ? this.node_widget[1] : null ); } } - t.clip_area && e.restore(), e.globalAlpha = 1; + e.clip_area && t.restore(), t.globalAlpha = 1; } } /** used by this.over_link_center */ - 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; + 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; 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), 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); + 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); } } } /** draws the shape of the given node in the canvas */ - 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; + 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; c[0] = 0, c[1] = f ? -a : 0, c[2] = i[0] + 1, c[3] = f ? i[1] + a : i[1]; - 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( + 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( 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 && e.arc( + ) : h == k.CIRCLE_SHAPE && t.arc( i[0] * 0.5, i[1] * 0.5, i[0] * 0.5, 0, Math.PI * 2 - ), 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) { + ), 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) { var d = N.gradients[g]; - d || (d = N.gradients[g] = e.createLinearGradient(0, 0, 400, 0), d.addColorStop(0, g), d.addColorStop(1, "#000")), e.fillStyle = d; + d || (d = N.gradients[g] = t.createLinearGradient(0, 0, 400, 0), d.addColorStop(0, g), d.addColorStop(1, "#000")), t.fillStyle = d; } else - 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( + 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( 0, -a, i[0] + 1, a, - t.flags.collapsed ? [this.round_radius] : [this.round_radius, this.round_radius, 0, 0] - ), e.fill(), e.shadowColor = "transparent"; + e.flags.collapsed ? [this.round_radius] : [this.round_radius, this.round_radius, 0, 0] + ), t.fill(), t.shadowColor = "transparent"; } var _ = null; - 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" : _); + 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" : _); var y = 10; - 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( + 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( a * 0.5, a * -0.5, y * 0.5 + 1, 0, Math.PI * 2 - ), 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( + ), 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( a * 0.5, a * -0.5, y * 0.5, 0, Math.PI * 2 - ), e.fill())) : (l && (e.fillStyle = "black", e.fillRect( + ), t.fill())) : (l && (t.fillStyle = "black", t.fillRect( (a - y) * 0.5 - 1, (a + y) * -0.5 - 1, y + 2, y + 2 - )), e.fillStyle = t.boxcolor || _ || u.NODE_DEFAULT_BOXCOLOR, e.fillRect( + )), t.fillStyle = e.boxcolor || _ || u.NODE_DEFAULT_BOXCOLOR, t.fillRect( (a - y) * 0.5, (a + y) * -0.5, y, y - )), e.globalAlpha = v, t.onDrawTitleText && t.onDrawTitleText( - e, + )), t.globalAlpha = v, e.onDrawTitleText && e.onDrawTitleText( + t, this, a, i, @@ -1393,56 +1393,56 @@ const ie = class { this.title_text_font, r ), !l) { - 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( + 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( b.substr(0, 20), //avoid urls too long a, // + measure.width * 0.5, u.NODE_TITLE_TEXT_Y - a - ), e.textAlign = "left") : (e.textAlign = "left", e.fillText( + ), t.textAlign = "left") : (t.textAlign = "left", t.fillText( b, a, u.NODE_TITLE_TEXT_Y - a ))); } - 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(); + 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(); } - t.onDrawTitle && t.onDrawTitle(e, this); + e.onDrawTitle && e.onDrawTitle(t, this); } - 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( + 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( -6 + c[0], -6 + c[1], 12 + c[2], 12 + c[3] - ) : h == k.ROUND_SHAPE || h == k.CARD_SHAPE && t.flags.collapsed ? e.roundRect( + ) : h == k.ROUND_SHAPE || h == k.CARD_SHAPE && e.flags.collapsed ? t.roundRect( -6 + c[0], -6 + c[1], 12 + c[2], 12 + c[3], [this.round_radius * 2] - ) : h == k.CARD_SHAPE ? e.roundRect( + ) : h == k.CARD_SHAPE ? t.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 && e.arc( + ) : h == k.CIRCLE_SHAPE && t.arc( i[0] * 0.5, i[1] * 0.5, i[0] * 0.5 + 6, 0, Math.PI * 2 - ), 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--; + ), 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--; } /** draws every connection visible in the canvas */ - drawConnections(t) { - var e = u.getTime(), i = this.visible_area; + drawConnections(e) { + var t = 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, t.lineWidth = this.connections_width, t.fillStyle = "#AAA", t.strokeStyle = "#AAA", t.globalAlpha = this.editor_alpha; + 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; 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( - t, + e, g, d, f, @@ -1481,10 +1481,10 @@ const ie = class { null, b, m - ), 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, + ), 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, g, d, f, @@ -1493,13 +1493,13 @@ const ie = class { "white", b, m - ), t.globalAlpha = T; + ), e.globalAlpha = T; } } } } } - t.globalAlpha = 1; + e.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(t, e, i, n, s, r, o, a, l, h) { + renderLink(e, t, 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(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(); + 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(); for (var f = 0; f < h; f += 1) { var c = (f - (h - 1) * 0.5) * 5; if (this.links_render_mode == de.SPLINE_LINK) { - t.moveTo(e[0], e[1] + c); + e.moveTo(t[0], t[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; } - t.bezierCurveTo( - e[0] + v, - e[1] + g + c, + e.bezierCurveTo( + t[0] + v, + t[1] + g + c, i[0] + d, i[1] + _ + c, i[0], i[1] + c ); } else if (this.links_render_mode == de.LINEAR_LINK) { - t.moveTo(e[0], e[1] + c); + e.moveTo(t[0], t[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; - t.lineTo( - e[0] + v * y, - e[1] + g * y + c - ), t.lineTo( + e.lineTo( + t[0] + v * y, + t[1] + g * y + c + ), e.lineTo( i[0] + d * y, i[1] + _ * y + c - ), t.lineTo(i[0], i[1] + c); + ), e.lineTo(i[0], i[1] + c); } else if (this.links_render_mode == de.STRAIGHT_LINK) { - 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]); + 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]); } else return; } - 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); + 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); 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( - e, + t, i, 0.25, a, l ), M = this.computeConnectionPoint( - e, + t, i, 0.26, a, l ), L = this.computeConnectionPoint( - e, + t, i, 0.75, a, l ), B = this.computeConnectionPoint( - e, + t, 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] > 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(); + 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(); } - t.beginPath(), t.arc(O[0], O[1], 5, 0, Math.PI * 2), t.fill(); + e.beginPath(), e.arc(O[0], O[1], 5, 0, Math.PI * 2), e.fill(); } if (r) { - t.fillStyle = o; + e.fillStyle = o; for (var f = 0; f < 5; ++f) { var pe = (u.getTime() * 1e-3 + f * 0.2) % 1, O = this.computeConnectionPoint( - e, + t, i, pe, a, l ); - t.beginPath(), t.arc(O[0], O[1], 5, 0, 2 * Math.PI), t.fill(); + e.beginPath(), e.arc(O[0], O[1], 5, 0, 2 * Math.PI), e.fill(); } } } - 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; + 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; 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(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( + 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( 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 && t.strokeRect( + ), n.order == 0 && e.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 - ), t.fillStyle = "#FFF", t.fillText( + ), e.fillStyle = "#FFF", e.fillText( "" + n.order, n.pos[0] + u.NODE_TITLE_HEIGHT * -0.5, n.pos[1] - 6 ); } - t.globalAlpha = 1; + e.globalAlpha = 1; } /** draws the widgets stored inside a node */ - drawNodeWidgets(t, e, i, n) { - if (!(!t.widgets || !t.widgets.length)) { - var s = t.size[0], r = t.widgets; - e += 2; + drawNodeWidgets(e, t, i, n) { + if (!(!e.widgets || !e.widgets.length)) { + var s = e.size[0], r = e.widgets; + t += 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 = e; + var d = t; 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, t, _, d, o); + g.draw && g.draw(i, e, _, d, o); break; } - e += (g.computeSize ? g.computeSize(_)[1] : o) + 4, i.globalAlpha = this.editor_alpha; + t += (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(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); + 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); } get bounding() { return this._bounding; @@ -1800,62 +1800,62 @@ class me { get pos() { return [this._pos[0], this._pos[1]]; } - set pos(e) { - !e || e.length < 2 || (this._pos[0] = e[0], this._pos[1] = e[1]); + set pos(t) { + !t || t.length < 2 || (this._pos[0] = t[0], this._pos[1] = t[1]); } get size() { return [this._size[0], this._size[1]]; } - set size(e) { - !e || e.length < 2 || (this._size[0] = Math.max(140, e[0]), this._size[1] = Math.max(80, e[1])); + set size(t) { + !t || t.length < 2 || (this._size[0] = Math.max(140, t[0]), this._size[1] = Math.max(80, t[1])); } - configure(e) { - e.bounding, this.title = e.title, this._bounding.set(e.bounding), this.color = e.color, this.font = e.font; + configure(t) { + t.bounding, this.title = t.title, this._bounding.set(t.bounding), this.color = t.color, this.font = t.font; } serialize() { - const e = this._bounding; + const t = this._bounding; return { title: this.title, bounding: [ - Math.round(e[0]), - Math.round(e[1]), - Math.round(e[2]), - Math.round(e[3]) + Math.round(t[0]), + Math.round(t[1]), + Math.round(t[2]), + Math.round(t[3]) ], color: this.color, font: this.font }; } - move(e, i, n) { - if (this._pos[0] += e, this._pos[1] += i, !n) + move(t, i, n) { + if (this._pos[0] += t, this._pos[1] += i, !n) for (var s = 0; s < this._nodes.length; ++s) { var r = this._nodes[s]; - r.pos[0] += e, r.pos[1] += i; + r.pos[0] += t, r.pos[1] += i; } } recomputeInsideNodes() { this._nodes.length = 0; - for (var e = this.graph._nodes, i = new Float32Array(4), n = 0; n < e.length; ++n) { - var s = e[n]; + for (var t = this.graph._nodes, i = new Float32Array(4), n = 0; n < t.length; ++n) { + var s = t[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(e, i, n = 0, s = !1) { + isPointInside(t, 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 < e && this.pos[0] + this.size[0] + 4 + n > e && this.pos[1] - r - n < i && this.pos[1] + this.size[1] + n > i; + 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; } /** Forces to redraw or the main canvas (LGraphNode) or the bg canvas (links) */ - setDirtyCanvas(e, i = !1) { - this.graph && this.graph.sendActionToCanvas("setDirty", [e, i]); + setDirtyCanvas(t, i = !1) { + this.graph && this.graph.sendActionToCanvas("setDirty", [t, i]); } } class he { - 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; + 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; } - 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); + 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); } serialize() { return [ @@ -1876,47 +1876,47 @@ function Fe() { return _e(He); } const K = []; -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(); +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(); } const ze = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), ke = { randomUUID: ze }; -function oe(t, e, i) { - if (ke.randomUUID && !e && !t) +function oe(e, t, i) { + if (ke.randomUUID && !t && !e) return ke.randomUUID(); - t = t || {}; - const n = t.random || (t.rng || Fe)(); - if (n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, e) { + e = e || {}; + const n = e.random || (e.rng || Fe)(); + if (n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, t) { i = i || 0; for (let s = 0; s < 16; ++s) - e[i + s] = n[s]; - return e; + t[i + s] = n[s]; + return t; } return Ue(n); } const Ne = class { - 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 = {}; + 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 = {}; } get slotLayout() { return "slotLayout" in this.constructor ? this.constructor.slotLayout : null; } /** configure a node from an object containing the serialized info */ - configure(t) { + configure(e) { this.graph && this.graph._version++; - 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]); + 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]); continue; } - 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[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.title || (this.title = ye(this, "title") || this.title); - const n = t.bgColor; + e.title || (this.title = ye(this, "title") || this.title); + const n = e.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; @@ -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 (t.widgets_values) - for (var s = 0; s < t.widgets_values.length; ++s) - this.widgets[s] && (this.widgets[s].value = t.widgets_values[s]); + 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]); } - this.onConfigure && this.onConfigure(t); + this.onConfigure && this.onConfigure(e); } /** serialize the content */ serialize() { - let t = { + let e = { 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 && (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.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.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; + 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; } - 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; + 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; } /** Creates a clone of this node */ - clone(t = { forNode: {} }) { - var e = u.createNode(this.type); - if (!e) + clone(e = { forNode: {} }) { + var t = u.createNode(this.type); + if (!t) 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()), e.configure(i), e; + return delete i.id, u.use_uuids && (i.id = oe()), t.configure(i), t; } /** serialize and stringify */ toString() { @@ -1992,97 +1992,97 @@ const Ne = class { return this.title || this.constructor.title; } getRootGraph() { - 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; + 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; } *iterateParentSubgraphNodes() { - var e; - let t = this.graph._subgraph_node; - for (; t; ) - yield t, t = (e = t.graph) == null ? void 0 : e._subgraph_node; + var t; + let e = this.graph._subgraph_node; + for (; e; ) + yield e, e = (t = e.graph) == null ? void 0 : t._subgraph_node; } /** sets the value of a property */ - setProperty(t, e) { + setProperty(e, t) { var r; - 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) + 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) for (var n = 0; n < this.widgets.length; ++n) { var s = this.widgets[n]; - if (s && ((r = s.options) == null ? void 0 : r.property) == t) { - s.value = e; + if (s && ((r = s.options) == null ? void 0 : r.property) == e) { + s.value = t; break; } } } } - getInputSlotProperty(t, e) { - if (!(!this.inputs || !this.graph) && !(t == -1 || t >= this.inputs.length)) { - var i = this.inputs[t]; + getInputSlotProperty(e, t) { + if (!(!this.inputs || !this.graph) && !(e == -1 || e >= this.inputs.length)) { + var i = this.inputs[e]; if (i) - return i.properties || (i.properties = {}), i.properties[e]; + return i.properties || (i.properties = {}), i.properties[t]; } } - getOutputSlotProperty(t, e) { - if (!(!this.outputs || !this.graph) && !(t == -1 || t >= this.outputs.length)) { - var i = this.outputs[t]; + getOutputSlotProperty(e, t) { + if (!(!this.outputs || !this.graph) && !(e == -1 || e >= this.outputs.length)) { + var i = this.outputs[e]; if (i) - return i.properties || (i.properties = {}), i.properties[e]; + return i.properties || (i.properties = {}), i.properties[t]; } } - 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); + 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(W.INPUT, 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); + 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(W.OUTPUT, e, n, t, i, s) === !1 && (n.properties[t] = s); } } } /** sets the output data */ - 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); + 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); } } } /** sets the output data */ - 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]; + 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]; if (r) { - r.type = e; + r.type = t; const o = this.graph.getNodeById(r.target_id); if (o) { const a = o.getInputInfo(r.target_slot); - a && !u.isValidConnection(e, a.type) && o.disconnectInput(r.target_slot); + a && !u.isValidConnection(t, a.type) && o.disconnectInput(r.target_slot); } } } } } *iterateInputInfo() { - for (let t = 0; t < this.inputs.length; t++) - yield this.inputs[t]; + for (let e = 0; e < this.inputs.length; e++) + yield this.inputs[e]; } /** * Retrieves the input data (data traveling through the connection) from one slot @@ -2090,12 +2090,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(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]; + 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]; if (!n) - return u.debug && console.error(`Link not found in slot ${t}!`, this, this.inputs[t], i), null; - if (!e) + return u.debug && console.error(`Link not found in slot ${e}!`, this, this.inputs[e], i), null; + if (!t) 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; @@ -2106,12 +2106,12 @@ const Ne = class { * @param slot * @return datatype in string format */ - getInputDataType(t) { - if (!this.inputs || t >= this.inputs.length || this.inputs[t].link == null) + getInputDataType(e) { + if (!this.inputs || e >= this.inputs.length || this.inputs[e].link == null) return null; - var e = this.inputs[t].link, i = this.graph.links[e]; + var t = this.inputs[e].link, i = this.graph.links[t]; if (!i) - return u.debug && console.error(`Link not found in slot ${t}!`, this, this.inputs[t], e), null; + return u.debug && console.error(`Link not found in slot ${e}!`, this, this.inputs[e], t), null; var n = this.graph.getNodeById(i.origin_id); if (!n) return i.type; @@ -2124,71 +2124,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(t, e) { - var i = this.findInputSlotIndexByName(t); - return i == -1 ? null : this.getInputData(i, e); + getInputDataByName(e, t) { + var i = this.findInputSlotIndexByName(e); + return i == -1 ? null : this.getInputData(i, t); } /** tells you if there is a connection in one input slot */ - isInputConnected(t) { - return this.inputs ? t < this.inputs.length && this.inputs[t].link != null : !1; + isInputConnected(e) { + return this.inputs ? e < this.inputs.length && this.inputs[e].link != null : !1; } /** tells you info about an input connection (which node, type, etc) */ - getInputInfo(t) { - return this.inputs && t < this.inputs.length ? this.inputs[t] : null; + getInputInfo(e) { + return this.inputs && e < this.inputs.length ? this.inputs[e] : null; } /** * Returns the link info in the connection of an input slot * @param {number} slot * @return {LLink} object or null */ - getInputLink(t) { + getInputLink(e) { if (!this.inputs || !this.graph) return null; - if (t < this.inputs.length) { - var e = this.inputs[t]; - return this.graph.links[e.link]; + if (e < this.inputs.length) { + var t = this.inputs[e]; + return this.graph.links[t.link]; } return null; } /** returns the node connected in the input slot */ - getInputNode(t) { + getInputNode(e) { if (!this.inputs || !this.graph) return null; - if (t < this.inputs.length) { - const i = this.inputs[t].link, n = this.graph.links[i]; + if (e < this.inputs.length) { + const i = this.inputs[e].link, n = this.graph.links[i]; if (!n) - 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 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 null; } /** returns the value of an input with this name, otherwise checks if there is a property with that name */ - getInputOrProperty(t) { + getInputOrProperty(e) { if (!this.inputs || !this.inputs.length || !this.graph) - 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) { + 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) { var s = this.graph.links[n.link]; if (s) return s.data; } } - return this.properties[t]; + return this.properties[e]; } /** sets the input data type */ - 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)) { + 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)) { const n = i.link, s = this.graph.links[n]; - s.type = e; + s.type = t; const r = this.graph.getNodeById(s.origin_id); if (r) { const o = r.getOutputInfo(s.origin_slot); - o && !u.isValidConnection(o.type, e) && r.disconnectOutput(s.origin_slot); + o && !u.isValidConnection(o.type, t) && r.disconnectOutput(s.origin_slot); } } } @@ -2198,42 +2198,42 @@ const Ne = class { * @param {number} slot * @return {LLink} object or null */ - getOutputSlotConnectedTo(t) { + getOutputSlotConnectedTo(e) { if (!this.outputs || !this.graph) return null; - if (t >= 0 && t < this.outputs.length) { - var e = this.inputs[t]; - if (e.link) { - const i = this.graph.links[e.link]; + if (e >= 0 && e < this.outputs.length) { + var t = this.inputs[e]; + if (t.link) { + const i = this.graph.links[t.link]; return this.graph.getNodeById(i.origin_id).outputs[i.origin_slot]; } } return null; } *iterateOutputInfo() { - for (let t = 0; t < this.outputs.length; t++) - yield this.outputs[t]; + for (let e = 0; e < this.outputs.length; e++) + yield this.outputs[e]; } /** tells you the last output data that went in that slot */ - getOutputData(t) { - if (!this.outputs || !this.graph || t >= this.outputs.length) + getOutputData(e) { + if (!this.outputs || !this.graph || e >= this.outputs.length) return null; - var e = this.outputs[t]; - return e._data; + var t = this.outputs[e]; + return t._data; } /** * Returns the link info in the connection of an output slot * @param {number} slot * @return {LLink} object or null */ - getOutputLinks(t) { + getOutputLinks(e) { if (!this.outputs || !this.graph) return []; - if (t >= 0 && t < this.outputs.length) { - var e = this.outputs[t]; - if (e.links) { + if (e >= 0 && e < this.outputs.length) { + var t = this.outputs[e]; + if (t.links) { var i = []; - for (const n of e.links) + for (const n of t.links) i.push(this.graph.links[n]); return i; } @@ -2245,14 +2245,14 @@ const Ne = class { * @param {number} slot * @return {LLink} object or null */ - getInputSlotsConnectedTo(t) { + getInputSlotsConnectedTo(e) { if (!this.outputs || !this.graph) return []; - if (t >= 0 && t < this.outputs.length) { - var e = this.outputs[t]; - if (e.links) { + if (e >= 0 && e < this.outputs.length) { + var t = this.outputs[e]; + if (t.links) { var i = []; - for (const n of e.links) { + for (const n of t.links) { const s = this.graph.links[n], r = this.graph.getNodeById(s.target_id); i.push(r.inputs[s.target_slot]); } @@ -2262,31 +2262,31 @@ const Ne = class { return []; } /** tells you info about an output connection (which node, type, etc) */ - getOutputInfo(t) { - return this.outputs && t < this.outputs.length ? this.outputs[t] : null; + getOutputInfo(e) { + return this.outputs && e < this.outputs.length ? this.outputs[e] : null; } /** tells you if there is a connection in one output slot */ - isOutputConnected(t) { - return !this.outputs || !this.graph ? !1 : t < this.outputs.length && this.outputs[t].links && this.outputs[t].links.length > 0; + isOutputConnected(e) { + return !this.outputs || !this.graph ? !1 : e < this.outputs.length && this.outputs[e].links && this.outputs[e].links.length > 0; } /** tells you if there is any connection in the output slots */ isAnyOutputConnected() { if (!this.outputs || !this.graph) return !1; - for (var t = 0; t < this.outputs.length; ++t) - if (this.outputs[t].links && this.outputs[t].links.length) + for (var e = 0; e < this.outputs.length; ++e) + if (this.outputs[e].links && this.outputs[e].links.length) return !0; return !1; } /** retrieves all the nodes connected to this output slot */ - getOutputNodes(t) { - if (!this.outputs || this.outputs.length == 0 || !this.graph || t >= this.outputs.length) + getOutputNodes(e) { + if (!this.outputs || this.outputs.length == 0 || !this.graph || e >= this.outputs.length) return null; - var e = this.outputs[t]; - if (!e.links || e.links.length == 0) + var t = this.outputs[e]; + if (!t.links || t.links.length == 0) return null; - for (var i = [], n = 0; n < e.links.length; n++) { - var s = e.links[n], r = this.graph.links[s]; + for (var i = [], n = 0; n < t.links.length; n++) { + var s = t.links[n], r = this.graph.links[s]; if (r) { var o = this.graph.getNodeById(r.target_id); o && i.push(o); @@ -2296,41 +2296,41 @@ const Ne = class { } *iterateAllLinks() { if (this.graph) { - for (const t of this.iterateInputInfo()) - if (t.link) { - const e = this.graph.links[t.link]; - e && (yield e); + for (const e of this.iterateInputInfo()) + if (e.link) { + const t = this.graph.links[e.link]; + t && (yield t); } - for (const t of this.iterateOutputInfo()) - if (t.links != null) - for (const e of t.links) { - const i = this.graph.links[e]; + for (const e of this.iterateOutputInfo()) + if (e.links != null) + for (const t of e.links) { + const i = this.graph.links[t]; i && (yield i); } } } addOnTriggerInput() { - var t = this.findInputSlotIndexByName("onTrigger"); - if (t == -1) { + var e = this.findInputSlotIndexByName("onTrigger"); + if (e == -1) { //!trigS || return this.addInput("onTrigger", I.EVENT, { optional: !0, nameLocked: !0 }), this.findInputSlotIndexByName("onTrigger"); } - return t; + return e; } addOnExecutedOutput() { - var t = this.findOutputSlotIndexByName("onExecuted"); - if (t == -1) { + var e = this.findOutputSlotIndexByName("onExecuted"); + if (e == -1) { //!trigS || return this.addOutput("onExecuted", I.ACTION, { optional: !0, nameLocked: !0 }), this.findOutputSlotIndexByName("onExecuted"); } - return t; + return e; } - onAfterExecuteNode(t, e) { + onAfterExecuteNode(e, t) { var i = this.findOutputSlotIndexByName("onExecuted"); - i != -1 && this.triggerSlot(i, t, null, e); + i != -1 && this.triggerSlot(i, e, null, t); } - changeMode(t) { - switch (t) { + changeMode(e) { + switch (e) { case Z.ON_EVENT: break; case Z.ON_TRIGGER: @@ -2345,10 +2345,10 @@ const Ne = class { default: return !1; } - return this.mode = t, !0; + return this.mode = e, !0; } - 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); + 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); } /** * Triggers an action, wrapped by logics to control execution flow @@ -2356,16 +2356,16 @@ const Ne = class { * @param {String} action name * @param {*} param */ - 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); + 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); } /** Triggers an event in this node, this will trigger any output with the same name */ - trigger(t, e, i) { + trigger(e, t, 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 || t && s.name != t || this.triggerSlot(n, e, null, i); + !s || s.type !== I.EVENT || e && s.name != e || this.triggerSlot(n, t, null, i); } } } @@ -2375,14 +2375,14 @@ const Ne = class { * @param param * @param link_id in case you want to trigger and specific output link in a slot */ - triggerSlot(t, e, i, n = {}) { + triggerSlot(e, t, i, n = {}) { if (this.outputs) { - if (t == null) { + if (e == null) { console.error("slot must be a number"); return; } - 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]; + 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]; if (s) { var r = s.links; if (!(!r || !r.length)) { @@ -2396,11 +2396,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(e, n); + n.action_call || (n.action_call = this.id + "_trigg_" + Math.floor(Math.random() * 9999)), h.onExecute && h.doExecute(t, 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, e, n); + h.actionDo(p.name, t, n); } } } @@ -2415,15 +2415,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(t, e) { + clearTriggeredSlot(e, t) { if (this.outputs) { - var i = this.outputs[t]; + var i = this.outputs[e]; if (i) { var n = i.links; if (!(!n || !n.length)) for (var s = 0; s < n.length; ++s) { var r = n[s]; - if (!(e != null && e != r)) { + if (!(t != null && t != r)) { var o = this.graph.links[n[s]]; o && (o._last_time = 0); } @@ -2436,8 +2436,8 @@ const Ne = class { * @method setSize * @param {vec2} size */ - setSize(t) { - this.size = t, this.onResize && this.onResize(this.size); + setSize(e) { + this.size = e, this.onResize && this.onResize(this.size); } /** * add a new property to this node @@ -2446,15 +2446,15 @@ 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(t, e, i, n) { - var s = { name: t, type: i, default_value: e }; + addProperty(e, t, i, n) { + var s = { name: e, type: i, default_value: t }; 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[t] = e, s; + return this.properties_info || (this.properties_info = []), this.properties_info.push(s), this.properties || (this.properties = {}), this.properties[e] = t, s; } - hasProperty(t) { - return this.properties != null && t in this.properties; + hasProperty(e) { + return this.properties != null && e in this.properties; } /** * add a new output slot to use in this node @@ -2462,41 +2462,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(t, e = I.DEFAULT, i) { - var n = { name: t, type: e, links: [], properties: {} }; + addOutput(e, t = I.DEFAULT, i) { + var n = { name: e, type: t, links: [], properties: {} }; if (i) for (var s in i) n[s] = i[s]; - 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; + 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; } /** remove an existing output slot */ - removeOutput(t) { - const e = this.outputs[t]; - this.disconnectOutput(t), this.outputs.splice(t, 1); - for (var i = t; i < this.outputs.length; ++i) + removeOutput(e) { + const t = this.outputs[e]; + this.disconnectOutput(e), this.outputs.splice(e, 1); + for (var i = e; 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(t, e), this.setDirtyCanvas(!0, !0); + this.setSize(this.computeSize()), this.onOutputRemoved && this.onOutputRemoved(e, t), this.setDirtyCanvas(!0, !0); } - moveOutput(t, e) { - const i = this.outputs[t]; - if (i == null || e < 0 || e > this.outputs.length - 1) + moveOutput(e, t) { + const i = this.outputs[e]; + if (i == null || t < 0 || t > this.outputs.length - 1) return; - const n = this.outputs[e]; + const n = this.outputs[t]; if (i.links) for (const s of i.links) { const r = this.graph.links[s]; - r.origin_slot = e; + r.origin_slot = t; } if (n.links) for (const s of n.links) { const r = this.graph.links[s]; - r.origin_slot = t; + r.origin_slot = e; } - this.outputs[e] = i, this.outputs[t] = n; + this.outputs[t] = i, this.outputs[e] = n; } /** * add a new input slot to use in this node @@ -2504,37 +2504,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(t, e = I.DEFAULT, i) { - var n = { name: t, type: e, link: null, properties: {} }; + addInput(e, t = I.DEFAULT, i) { + var n = { name: e, type: t, link: null, properties: {} }; if (i) for (var s in i) n[s] = i[s]; - 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; + 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; } /** remove an existing input slot */ - removeInput(t) { - this.disconnectInput(t); - for (var e = this.inputs.splice(t, 1), i = t; i < this.inputs.length; ++i) + removeInput(e) { + this.disconnectInput(e); + for (var t = this.inputs.splice(e, 1), i = e; 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(t, e[0]), this.setDirtyCanvas(!0, !0); + this.setSize(this.computeSize()), this.onInputRemoved && this.onInputRemoved(e, t[0]), this.setDirtyCanvas(!0, !0); } - moveInput(t, e) { - const i = this.inputs[t]; - if (i == null || e < 0 || e > this.inputs.length - 1) + moveInput(e, t) { + const i = this.inputs[e]; + if (i == null || t < 0 || t > this.inputs.length - 1) return; - const n = this.inputs[e]; + const n = this.inputs[t]; if (i.link != null) { const s = this.graph.links[i.link]; - s.target_slot = e; + s.target_slot = t; } if (n.link != null) { const s = this.graph.links[n.link]; - s.target_slot = t; + s.target_slot = e; } - this.inputs[e] = i, this.inputs[t] = n; + this.inputs[t] = i, this.inputs[e] = n; } /** * add an special connection to this node (used for special kinds of graphs) @@ -2543,10 +2543,10 @@ const Ne = class { * @param pos position of the connection inside the node * @param direction if is input or output */ - addConnection(t, e, i, n) { + addConnection(e, t, i, n) { let s = { - name: t, - type: e, + name: e, + type: t, pos: i, direction: n, links: null @@ -2554,14 +2554,14 @@ const Ne = class { return this.connections.push(s), s; } /** computes the size of a node according to its inputs and output slots */ - computeSize(t = [0, 0]) { - const e = ye(this, "overrideSize"); - if (e) - return e.concat(); + computeSize(e = [0, 0]) { + const t = ye(this, "overrideSize"); + if (t) + return t.concat(); var i = Math.max( this.inputs ? this.inputs.length : 1, this.outputs ? this.outputs.length : 1 - ), n = t; + ), n = e; i = Math.max(i, 1); var s = u.NODE_TEXT_SIZE, r = d(this.title), o = 0, a = 0; if (this.inputs) @@ -2599,73 +2599,73 @@ const Ne = class { * @param {String} property name of the property * @return {Object} the object with all the available info */ - getPropertyInfo(t) { - var e = null; + getPropertyInfo(e) { + var t = null; if (this.properties_info) { for (var i = 0; i < this.properties_info.length; ++i) - if (this.properties_info[i].name == t) { - e = this.properties_info[i]; + if (this.properties_info[i].name == e) { + t = this.properties_info[i]; break; } } - 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; + 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; } /** * https://github.com/jagenjo/litegraph.js/blob/master/guides/README.md#node-widgets * @return created widget */ - addWidget(t, e, i, n, s) { + addWidget(e, t, 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: t.toLowerCase(), - name: e, + type: e.toLowerCase(), + name: t, 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"), t == "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"), e == "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(t) { - return this.widgets || (this.widgets = []), this.widgets.push(t), this.setSize(this.computeSize()), t; + addCustomWidget(e) { + return this.widgets || (this.widgets = []), this.widgets.push(e), this.setSize(this.computeSize()), e; } - setWidgetHidden(t, e) { - t.hidden = e, this.setSize(this.computeSize()); + setWidgetHidden(e, t) { + e.hidden = t, this.setSize(this.computeSize()); } /** * returns the bounding of the object, used for rendering purposes * @return [x, y, width, height] */ - 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; + 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; } /** checks if a point is inside the shape of a node */ - isPointInside(t, e, i = 0, n = !1) { + isPointInside(e, t, 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( - t, e, + t, 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 < t && this.pos[0] + this.size[0] + 4 + i > t && this.pos[1] - s - i < e && this.pos[1] + this.size[1] + i > e) + } 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) return !0; return !1; } /** checks if a point is inside a node slot, and returns info about which slot */ - getSlotInPosition(t, e) { + getSlotInPosition(e, t) { 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( - t, e, + t, i[0] - 10, i[1] - 5, 20, @@ -2677,8 +2677,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( - t, e, + t, i[0] - 10, i[1] - 5, 20, @@ -2688,28 +2688,46 @@ const Ne = class { } return null; } - is(t) { - const e = t.__LITEGRAPH_TYPE__; - return e != null && this.type === e; + is(e) { + const t = e.__LITEGRAPH_TYPE__; + return t != null && this.type === t; + } + /** + * returns the input slot with a given name (used for dynamic slots), -1 if not found + * for compatibility purposes only, please prefer `findInputSlotIndexByName` + * @param name the name of the slot + * @return the slot (-1 if not found) + */ + findInputSlot(e) { + return this.findInputSlotIndexByName(e); + } + /** + * returns the output slot with a given name (used for dynamic slots), -1 if not found + * for compatibility purposes only, please prefer `findOutputSlotIndexByName` + * @param name the name of the slot + * @return the slot (-1 if not found) + */ + findOutputSlot(e) { + return this.findOutputSlotIndexByName(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(t, e = !1, i) { + findInputSlotIndexByName(e, t = !1, i) { if (!this.inputs) return -1; for (var n = 0, s = this.inputs.length; n < s; ++n) - if (!(e && this.inputs[n].link && this.inputs[n].link != null) && !(i && i.includes(this.inputs[n].type)) && (!t || t == this.inputs[n].name)) + if (!(t && this.inputs[n].link && this.inputs[n].link != null) && !(i && i.includes(this.inputs[n].type)) && (!e || e == this.inputs[n].name)) return n; return -1; } - findInputSlotByName(t, e = !1, i) { + findInputSlotByName(e, t = !1, i) { if (!this.inputs) return null; for (var n = 0, s = this.inputs.length; n < s; ++n) - if (!(e && this.inputs[n].link && this.inputs[n].link != null) && !(i && i.includes(this.inputs[n].type)) && (!t || t == this.inputs[n].name)) + if (!(t && this.inputs[n].link && this.inputs[n].link != null) && !(i && i.includes(this.inputs[n].type)) && (!e || e == this.inputs[n].name)) return this.inputs[n]; return null; } @@ -2718,45 +2736,45 @@ const Ne = class { * @param name the name of the slot * @return the slot (-1 if not found) */ - findOutputSlotIndexByName(t, e = !1, i) { + findOutputSlotIndexByName(e, t = !1, i) { if (!this.outputs) return -1; for (var n = 0, s = this.outputs.length; n < s; ++n) - if (!(e && this.outputs[n].links && this.outputs[n].links != null) && !(i && i.includes(this.outputs[n].type)) && (!t || t == this.outputs[n].name)) + if (!(t && this.outputs[n].links && this.outputs[n].links != null) && !(i && i.includes(this.outputs[n].type)) && (!e || e == this.outputs[n].name)) return n; return -1; } - findOutputSlotByName(t, e = !1, i) { + findOutputSlotByName(e, t = !1, i) { if (!this.outputs) return null; for (var n = 0, s = this.outputs.length; n < s; ++n) - if (!(e && this.outputs[n].links && this.outputs[n].links != null) && !(i && i.includes(this.outputs[n].type)) && (!t || t == this.outputs[n].name)) + if (!(t && this.outputs[n].links && this.outputs[n].links != null) && !(i && i.includes(this.outputs[n].type)) && (!e || e == this.outputs[n].name)) return this.outputs[n]; return null; } /** * findSlotByType for INPUTS */ - findInputSlotIndexByType(t, e = !1, i = !1) { - return this.findSlotByType(!0, t, !1, e, i); + findInputSlotIndexByType(e, t = !1, i = !1) { + return this.findSlotByType(!0, e, !1, t, i); } /** * findSlotByType for OUTPUTS */ - findOutputSlotIndexByType(t, e = !1, i = !1) { - return this.findSlotByType(!1, t, !1, e, i); + findOutputSlotIndexByType(e, t = !1, i = !1) { + return this.findSlotByType(!1, e, !1, t, i); } /** * findSlotByType for INPUTS */ - findInputSlotByType(t, e = !1, i = !1) { - return this.findSlotByType(!0, t, !1, e, i); + findInputSlotByType(e, t = !1, i = !1) { + return this.findSlotByType(!0, e, !1, t, i); } /** * findSlotByType for OUTPUTS */ - findOutputSlotByType(t, e = !1, i = !1) { - return this.findSlotByType(!1, t, !1, e, i); + findOutputSlotByType(e, t = !1, i = !1) { + return this.findSlotByType(!1, e, !1, t, i); } /** * returns the output (or input) slot with a given type, -1 if not found @@ -2766,14 +2784,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(t, e, i, n = !1, s = !1) { + findSlotByType(e, t, i, n = !1, s = !1) { n = n || !1, s = s || !1; - var r = t ? this.inputs : this.outputs; + var r = e ? this.inputs : this.outputs; if (!r) return i ? null : -1; - (e == "" || e == "*") && (e = 0); + (t == "" || t == "*") && (t = 0); for (var o = 0, a = r.length; o < a; ++o) { - var l = (e + "").toLowerCase().split(","), h = r[o].type == "0" || r[o].type == "*" ? "0" : r[o].type; + var l = (t + "").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++) @@ -2786,7 +2804,7 @@ const Ne = class { } if (n && !s) for (var o = 0, a = r.length; o < a; ++o) { - var l = (e + "").toLowerCase().split(","), h = r[o].type == "0" || r[o].type == "*" ? "0" : r[o].type; + var l = (t + "").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; _++) @@ -2803,31 +2821,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(t, e, i, n = {}) { + connectByTypeInput(e, t, i, n = {}) { var s = { createEventInCase: !0, firstFreeIfOutputGeneralInCase: !0, generalTypeInCase: !0 }, r = Object.assign(s, n); - e && e.constructor === Number && (e = this.graph.getNodeById(e)); + t && t.constructor === Number && (t = this.graph.getNodeById(t)); let o = i; i === I.EVENT ? o = I.ACTION : i === I.ACTION && (o = I.EVENT); - let a = e.findInputSlotIndexByType(o, !0); + let a = t.findInputSlotIndexByType(o, !0); if (a >= 0 && a !== null) - return u.debug && console.debug("CONNbyTYPE type " + i + " for " + a), this.connect(t, e, a); + return u.debug && console.debug("CONNbyTYPE type " + i + " for " + a), this.connect(e, t, 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 " + e), this.connect(t, e, -1); + return u.debug && console.debug("connect WILL CREATE THE onTrigger " + i + " to " + t), this.connect(e, t, -1); if (r.generalTypeInCase) { - 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); + 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); } if (r.firstFreeIfOutputGeneralInCase && (i == 0 || i == "*" || i == "")) { - 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); + 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); } - return u.debug && console.error("no way to connect type: ", i, " to targetNODE ", e), null; + return u.debug && console.error("no way to connect type: ", i, " to targetNODE ", t), null; } /** * connect this node input to the output of another node BY TYPE @@ -2837,31 +2855,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(t, e, i, n = {}) { + connectByTypeOutput(e, t, i, n = {}) { var s = { createEventInCase: !0, firstFreeIfInputGeneralInCase: !0, generalTypeInCase: !0 }, r = Object.assign(s, n); - e && e.constructor === Number && (e = this.graph.getNodeById(e)); + t && t.constructor === Number && (t = this.graph.getNodeById(t)); let o = i; - 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 (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 (r.generalTypeInCase) { - var a = e.findOutputSlotIndexByType(0, !0, !0); + var a = t.findOutputSlotIndexByType(0, !0, !0); if (a >= 0) - return e.connect(a, this, t); + return t.connect(a, this, e); } if ((r.createEventInCase && i == I.EVENT || i == I.ACTION) && u.do_add_triggers_slots) { - var a = e.addOnExecutedOutput(); - return e.connect(a, this, t); + var a = t.addOnExecutedOutput(); + return t.connect(a, this, e); } if (r.firstFreeIfInputGeneralInCase && (i == 0 || i == "*" || i == "")) { - let l = e.findOutputSlotIndexByName(null, !0, [I.EVENT, I.ACTION]); + let l = t.findOutputSlotIndexByName(null, !0, [I.EVENT, I.ACTION]); if (l >= 0) - return e.connect(l, this, t); + return t.connect(l, this, e); } - return console.error("no way to connect byOUT type: ", i, " to sourceNODE ", e), console.error("type OUT! " + i + " not found or not free?"), null; + return console.error("no way to connect byOUT type: ", i, " to sourceNODE ", t), console.error("type OUT! " + i + " not found or not free?"), null; } /** * connect this node output to the input of another node @@ -2870,45 +2888,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(t, e, i) { + connect(e, t, 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 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) + 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) return u.debug && console.error("Connect: Error, slot number not found"), null; - if (e && e.constructor === Number && (e = this.graph.getNodeById(e)), !e) + if (t && t.constructor === Number && (t = this.graph.getNodeById(t)), !t) throw "target node is null"; - if (e == this) + if (t == this) return u.debug && console.error("Connect: Error, can't connect node to itself!"), null; - if (!e.graph) + if (!t.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 = e.findInputSlotIndexByName(i), i == -1) + if (i = t.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) - e.changeMode(Z.ON_TRIGGER), i = e.findInputSlotIndexByName("onTrigger"); + t.changeMode(Z.ON_TRIGGER), i = t.findInputSlotIndexByName("onTrigger"); else return u.debug && console.error("Connect: Error, can't connect event target slot"), null; - else if (!e.inputs || i >= e.inputs.length) + else if (!t.inputs || i >= t.inputs.length) return u.debug && console.error("Connect: Error, slot number not found"), null; - 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)) + 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)) 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), e.onConnectInput && e.onConnectInput(i, o.type, o, this, t) === !1) + if (u.debug && console.debug("valid connection", o.type, s.type), t.onConnectInput && t.onConnectInput(i, o.type, o, this, e) === !1) return u.debug && console.debug("onConnectInput blocked", o.type, s.type), null; - if (this.onConnectOutput && this.onConnectOutput(t, s.type, s, e, i) === !1) + if (this.onConnectOutput && this.onConnectOutput(e, s.type, s, t, i) === !1) return u.debug && console.debug("onConnectOutput blocked", o.type, s.type), null; - 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) + 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) switch (o.type) { case I.EVENT: - u.allow_multi_output_for_events || (this.graph.beforeChange(), this.disconnectOutput(t, null, { doProcessChange: !1 }), n = !0); + u.allow_multi_output_for_events || (this.graph.beforeChange(), this.disconnectOutput(e, null, { doProcessChange: !1 }), n = !0); break; } let a; @@ -2916,16 +2934,16 @@ const Ne = class { a, s.type || o.type, this.id, - t, - e.id, + e, + t.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), e.inputs[i].link = r.id, this.graph && this.graph._version++, this.onConnectionsChange && this.onConnectionsChange( + ), 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( W.OUTPUT, - t, + e, !0, r, o - ), e.onConnectionsChange && e.onConnectionsChange( + ), t.onConnectionsChange && t.onConnectionsChange( W.INPUT, i, !0, @@ -2933,15 +2951,15 @@ const Ne = class { s ), this.graph && this.graph.onNodeConnectionChange && (this.graph.onNodeConnectionChange( W.INPUT, - e, + t, i, this, - t + e ), this.graph.onNodeConnectionChange( W.OUTPUT, this, - t, e, + t, i )), this.setDirtyCanvas(!1, !0), this.graph.afterChange(), this.graph.connectionChange(this, r), r; } @@ -2951,24 +2969,24 @@ 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(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) + 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) return u.debug && console.error("Connect: Error, slot number not found"), !1; - var n = this.outputs[t]; + var n = this.outputs[e]; if (!n || !n.links || n.links.length == 0) return !1; - if (e) { - if (e.constructor === Number && (e = this.graph.getNodeById(e)), !e) + if (t) { + if (t.constructor === Number && (t = this.graph.getNodeById(t)), !t) 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 == e.id) { + if (a.target_id == t.id) { n.links.splice(s, 1); - var l = e.inputs[a.target_slot]; - l.link = null, delete this.graph.links[o], this.graph && this.graph._version++, e.onConnectionsChange && e.onConnectionsChange( + var l = t.inputs[a.target_slot]; + l.link = null, delete this.graph.links[o], this.graph && this.graph._version++, t.onConnectionsChange && t.onConnectionsChange( W.INPUT, a.target_slot, !1, @@ -2976,21 +2994,21 @@ const Ne = class { l ), this.onConnectionsChange && this.onConnectionsChange( W.OUTPUT, - t, + e, !1, a, n ), this.graph && this.graph.onNodeConnectionChange && this.graph.onNodeConnectionChange( W.OUTPUT, this, - t + e ), this.graph && this.graph.onNodeConnectionChange && (this.graph.onNodeConnectionChange( W.OUTPUT, this, - t + e ), this.graph.onNodeConnectionChange( W.INPUT, - e, + t, a.target_slot )); break; @@ -3000,8 +3018,8 @@ 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 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( + 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( W.INPUT, a.target_slot, !1, @@ -3009,21 +3027,21 @@ const Ne = class { l ), this.graph && this.graph.onNodeConnectionChange && this.graph.onNodeConnectionChange( W.INPUT, - e, + t, a.target_slot )), delete this.graph.links[o], this.onConnectionsChange && this.onConnectionsChange( W.OUTPUT, - t, + e, !1, a, n ), this.graph && this.graph.onNodeConnectionChange && (this.graph.onNodeConnectionChange( W.OUTPUT, this, - t + e ), this.graph.onNodeConnectionChange( W.INPUT, - e, + t, a.target_slot )); } @@ -3037,18 +3055,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(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) + 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) return u.debug && console.error("Connect: Error, slot number not found"), !1; - var i = this.inputs[t]; + var i = this.inputs[e]; if (!i) return !1; - var n = this.inputs[t].link; + var n = this.inputs[e].link; if (n != null) { - this.inputs[t].link = null; + this.inputs[e].link = null; var s = this.graph.links[n]; if (s) { var r = this.graph.getNodeById(s.origin_id); @@ -3064,7 +3082,7 @@ const Ne = class { } delete this.graph.links[n], this.graph && this.graph._version++, this.onConnectionsChange && this.onConnectionsChange( W.INPUT, - t, + e, !1, s, i @@ -3078,7 +3096,7 @@ const Ne = class { W.OUTPUT, r, a - ), this.graph.onNodeConnectionChange(W.INPUT, this, t)); + ), this.graph.onNodeConnectionChange(W.INPUT, this, e)); } } return this.setDirtyCanvas(!1, !0), this.graph && this.graph.connectionChange(this), !0; @@ -3090,59 +3108,59 @@ const Ne = class { * @param out a place to store the output, to free garbage * @return the position **/ - getConnectionPos(t, e, i = [0, 0], n = !1) { + getConnectionPos(e, t, i = [0, 0], n = !1) { var s = 0; - t && this.inputs && (s = this.inputs.length), !t && this.outputs && (s = this.outputs.length); + e && this.inputs && (s = this.inputs.length), !e && 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, 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 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 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); + 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); } /** 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(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); + 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); } /** Forces to redraw or the main canvas (LGraphNode) or the bg canvas (links) */ - setDirtyCanvas(t, e = !1) { - this.graph && this.graph.sendActionToCanvas("setDirty", [t, e]); + setDirtyCanvas(e, t = !1) { + this.graph && this.graph.sendActionToCanvas("setDirty", [e, t]); } - loadImage(t) { - var e = new Image(); - e.src = u.node_images_path + t; + loadImage(e) { + var t = new Image(); + t.src = u.node_images_path + e; var i = this; - return e.onload = function() { + return t.onload = function() { i.setDirtyCanvas(!0); - }, e; + }, t; } /** Allows to get onMouseMove and onMouseUp events even if the mouse is out of focus */ - captureInput(t) { + captureInput(e) { if (!(!this.graph || !this.graph.list_of_graphcanvas)) - 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); + 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); } } - isShowingTitle(t) { - return this.titleMode == se.TRANSPARENT_TITLE || this.titleMode == se.NO_TITLE ? !1 : (this.titleMode == se.AUTOHIDE_TITLE && t, !0); + isShowingTitle(e) { + return this.titleMode == se.TRANSPARENT_TITLE || this.titleMode == se.NO_TITLE ? !1 : (this.titleMode == se.AUTOHIDE_TITLE && e, !0); } /** Collapse the node to make it smaller on the canvas */ - 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)); + 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)); } /** Forces the node to do not move or realign on Z */ - pin(t) { - this.graph._version++, t === void 0 ? this.flags.pinned = !this.flags.pinned : this.flags.pinned = t; + pin(e) { + this.graph._version++, e === void 0 ? this.flags.pinned = !this.flags.pinned : this.flags.pinned = e; } - localToScreen(t, e, i) { + localToScreen(e, t, i) { return [ - (t + this.pos[0]) * i.ds.scale + i.ds.offset[0], - (e + this.pos[1]) * i.ds.scale + i.ds.offset[1] + (e + this.pos[0]) * i.ds.scale + i.ds.offset[0], + (t + this.pos[1]) * i.ds.scale + i.ds.offset[1] ]; } getOptionalSlots() { @@ -3152,15 +3170,15 @@ const Ne = class { let ae = Ne; ae.MAX_CONSOLE = 100; function we() { - let t = []; - return t = t.concat(Ae), t = t.concat([I.ACTION]), t = t.concat(u.slot_types_in.map((e) => e.toUpperCase())), t; + let e = []; + return e = e.concat(Ae), e = e.concat([I.ACTION]), e = e.concat(u.slot_types_in.map((t) => t.toUpperCase())), e; } function We() { return we().map(J); } class $ extends ae { - constructor(e) { - super(e), this.properties = { + constructor(t) { + super(t), this.properties = { name: "", type: "number", value: 0, @@ -3192,48 +3210,48 @@ class $ extends ae { } ), this.widgets_up = !0; } - setName(e) { - if (e == null || e === this.properties.name) + setName(t) { + if (t == null || t === this.properties.name) return; const i = this.getParentSubgraph(); - i && (e = i.getValidGraphInputName(e), this.setProperty("name", e)); + i && (t = i.getValidGraphInputName(t), this.setProperty("name", t)); } - 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); + 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); } onConfigure() { this.updateType(); } getParentSubgraph() { - var e, i; - return (i = (e = this.graph._subgraph_node) == null ? void 0 : e.graph) == null ? void 0 : i.getNodeById(this.properties.subgraphID); + var t, i; + return (i = (t = this.graph._subgraph_node) == null ? void 0 : t.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 e = this.properties.type; - this.typeWidget.value = J(e); + var t = this.properties.type; + this.typeWidget.value = J(t); const i = this.outputs[0]; - 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); + 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); } /** this is executed AFTER the property has changed */ - onPropertyChanged(e, i) { - if (e == "name") { + onPropertyChanged(t, i) { + if (t == "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 - e == "type" && this.updateType(); + t == "type" && this.updateType(); } getTitle() { return this.flags.collapsed ? this.properties.name : this.title; } - onAction(e, i) { + onAction(t, i) { this.properties.type == I.EVENT && this.triggerSlot(0, i); } onExecute() { - var e = this.properties.name, i = this.graph.inputs[e]; + var t = this.properties.name, i = this.graph.inputs[t]; if (!i) { this.setOutputData(0, this.properties.value); return; @@ -3258,15 +3276,15 @@ u.registerNodeType({ hide_in_node_lists: !0 }); function Le() { - let t = []; - return t = t.concat(Ae), t = t.concat([I.EVENT]), t = t.concat(u.slot_types_out), t; + let e = []; + return e = e.concat(Ae), e = e.concat([I.EVENT]), e = e.concat(u.slot_types_out), e; } function Ye() { return Le().map(J); } class Q extends ae { - constructor(e) { - super(e), this.properties = { + constructor(t) { + super(t), this.properties = { name: "", type: "number", subgraphID: null @@ -3288,42 +3306,42 @@ class Q extends ae { this.setType.bind(this) ), this.widgets_up = !0; } - setName(e) { - if (e == null || e === this.properties.name) + setName(t) { + if (t == null || t === this.properties.name) return; const i = this.getParentSubgraph(); - i && (e = i.getValidGraphOutputName(e), this.setProperty("name", e)); + i && (t = i.getValidGraphOutputName(t), this.setProperty("name", t)); } - 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); + 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); } onConfigure() { this.updateType(); } getParentSubgraph() { - var e, i; - return (i = (e = this.graph._subgraph_node) == null ? void 0 : e.graph) == null ? void 0 : i.getNodeById(this.properties.subgraphID); + var t, i; + return (i = (t = this.graph._subgraph_node) == null ? void 0 : t.graph) == null ? void 0 : i.getNodeById(this.properties.subgraphID); } updateType() { - var e = this.properties.type; + var t = this.properties.type; const i = this.inputs[0]; - 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.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 is executed AFTER the property has changed */ - onPropertyChanged(e, i) { - if (e == "name") { + onPropertyChanged(t, i) { + if (t == "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!", e, 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!", t, i), this.nameWidget.value = i, this.nameInGraph = i; } else - e == "type" && this.updateType(); + t == "type" && this.updateType(); } getTitle() { return this.flags.collapsed ? this.properties.name : this.title; } - onAction(e, i, n) { + onAction(t, i, n) { const s = this.getParentSubgraph(); if (!s) return; @@ -3331,8 +3349,8 @@ class Q extends ae { r == null || s.outputs[r] == null || s.triggerSlot(r, i); } onExecute() { - const e = this.getInputData(0); - this.graph.setOutputData(this.properties.name, e); + const t = this.getInputData(0); + this.graph.setOutputData(this.properties.name, t); } onRemoved() { this.nameInGraph && this.graph.removeOutput(this.nameInGraph); @@ -3351,10 +3369,10 @@ u.registerNodeType({ type: "graph/output", hide_in_node_lists: !0 }); -var xe = /* @__PURE__ */ ((t) => (t[t.STATUS_STOPPED = 1] = "STATUS_STOPPED", t[t.STATUS_RUNNING = 2] = "STATUS_RUNNING", t))(xe || {}); +var xe = /* @__PURE__ */ ((e) => (e[e.STATUS_STOPPED = 1] = "STATUS_STOPPED", e[e.STATUS_RUNNING = 2] = "STATUS_RUNNING", e))(xe || {}); const De = class { - 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); + 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); } getSupportedTypes() { return this.supported_types || De.DEFAULT_SUPPORTED_TYPES; @@ -3363,54 +3381,54 @@ const De = class { * Gets the root graph above any subgraphs. */ getRootGraph() { - const t = Array.from(this.iterateParentGraphs()), e = t[t.length - 1]; - return e._is_subgraph ? null : e; + const e = Array.from(this.iterateParentGraphs()), t = e[e.length - 1]; + return t._is_subgraph ? null : t; } *iterateParentGraphs() { - var e; - let t = this; - for (; t; ) - yield t, t = (e = t._subgraph_node) == null ? void 0 : e.graph; + var t; + let e = this; + for (; e; ) + yield e, e = (t = e._subgraph_node) == null ? void 0 : t.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 t = 0; t < this._nodes.length; ++t) { - var e = this._nodes[t]; - e.onRemoved && e.onRemoved(); + for (var e = 0; e < this._nodes.length; ++e) { + var t = this._nodes[e]; + t.onRemoved && t.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(t) { - if (!(t instanceof N)) + attachCanvas(e) { + if (!(e instanceof N)) throw "attachCanvas expects a LGraphCanvas instance"; - 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); + 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); } /** Detach Canvas to this graph */ - detachCanvas(t) { + detachCanvas(e) { if (this.list_of_graphcanvas) { - var e = this.list_of_graphcanvas.indexOf(t); - e != -1 && (t.graph = null, this.list_of_graphcanvas.splice(e, 1)); + var t = this.list_of_graphcanvas.indexOf(e); + t != -1 && (e.graph = null, this.list_of_graphcanvas.splice(t, 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(t) { + start(e) { if (this.status != 2) { - 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) { + 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) { let i = function() { - e.execution_timer_id == -1 && (window.requestAnimationFrame(i), e.onBeforeStep && e.onBeforeStep(), e.runStep(1, !e.catch_errors), e.onAfterStep && e.onAfterStep()); + t.execution_timer_id == -1 && (window.requestAnimationFrame(i), t.onBeforeStep && t.onBeforeStep(), t.runStep(1, !t.catch_errors), t.onAfterStep && t.onAfterStep()); }; this.execution_timer_id = -1, i(); } else this.execution_timer_id = setInterval(function() { - e.onBeforeStep && e.onBeforeStep(), e.runStep(1, !e.catch_errors), e.onAfterStep && e.onAfterStep(); - }, t); + t.onBeforeStep && t.onBeforeStep(), t.runStep(1, !t.catch_errors), t.onAfterStep && t.onAfterStep(); + }, e); } } /** Stops the execution loop of the graph */ @@ -3422,13 +3440,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(t = 1, e = !1, i) { + runStep(e = 1, t = !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, e) { - for (var r = 0; r < t; r++) { + if (i = i || s.length, t) { + for (var r = 0; r < e; r++) { for (var o = 0; o < i; ++o) { var a = s[o]; a.mode == Z.ALWAYS && a.onExecute && a.doExecute(); @@ -3438,7 +3456,7 @@ const De = class { this.onAfterExecute && this.onAfterExecute(); } else try { - for (var r = 0; r < t; r++) { + for (var r = 0; r < e; r++) { for (var o = 0; o < i; ++o) { var a = s[o]; a.mode == Z.ALWAYS && a.onExecute && a.onExecute(null, {}); @@ -3461,29 +3479,29 @@ const De = class { */ updateExecutionOrder() { this._nodes_in_order = this.computeExecutionOrder(!1), this._nodes_executable = []; - 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); + 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); } } - *computeExecutionOrderRecursive(t = !1, e) { - for (const i of this.computeExecutionOrder(t, e)) + *computeExecutionOrderRecursive(e = !1, t) { + for (const i of this.computeExecutionOrder(e, t)) if (yield i, i.is(ne)) - for (const n of i.subgraph.computeExecutionOrderRecursive(t, e)) + for (const n of i.subgraph.computeExecutionOrderRecursive(e, t)) yield n; } /** This is more internal, it computes the executable nodes in order and returns it */ - computeExecutionOrder(t = !1, e) { + computeExecutionOrder(e = !1, t) { for (var i = [], n = [], s = {}, r = {}, o = {}, a = 0, _ = this._nodes.length; a < _; ++a) { var l = this._nodes[a]; - if (!(t && !l.onExecute)) { + if (!(e && !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), e && (l._level = 1)) : (e && (l._level = 0), o[l.id] = h); + h == 0 ? (n.push(l), t && (l._level = 1)) : (t && (l._level = 0), o[l.id] = h); } } for (; n.length != 0; ) { @@ -3500,7 +3518,7 @@ const De = class { r[g.id] = !0; continue; } - 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); + 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); } } } @@ -3523,45 +3541,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(t) { - for (var e = [], i = [t], n = {}; i.length; ) { + getAncestors(e) { + for (var t = [], i = [e], n = {}; i.length; ) { var s = i.shift(); if (s.inputs) { - !n[s.id] && s != t && (n[s.id] = !0, e.push(s)); + !n[s.id] && s != e && (n[s.id] = !0, t.push(s)); for (var r = 0; r < s.inputs.length; ++r) { var o = s.getInputNode(r); - o && e.indexOf(o) == -1 && i.push(o); + o && t.indexOf(o) == -1 && i.push(o); } } } - return e.sort(function(a, l) { + return t.sort(function(a, l) { return a.order - l.order; - }), e; + }), t; } /** * Positions every node in a more readable manner */ - arrange(t = 100, e = ue.HORIZONTAL_LAYOUT) { + arrange(e = 100, t = 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 = t; + let s = e; for (let r = 0; r < n.length; ++r) { const o = n[r]; if (!o) continue; - let a = 100, l = t + u.NODE_TITLE_HEIGHT; + let a = 100, l = e + u.NODE_TITLE_HEIGHT; for (let h = 0; h < o.length; ++h) { const p = o[h]; - 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.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.size[f] > a && (a = p.size[f]); - const c = e == ue.VERTICAL_LAYOUT ? 0 : 1; - l += p.size[c] + t + u.NODE_TITLE_HEIGHT; + const c = t == ue.VERTICAL_LAYOUT ? 0 : 1; + l += p.size[c] + e + u.NODE_TITLE_HEIGHT; } - s += a + t; + s += a + e; } this.setDirtyCanvas(!0, !0); } @@ -3591,123 +3609,123 @@ const De = class { * Iterates all nodes in this graph *excluding* subgraphs. */ *iterateNodesInOrder() { - const t = this._nodes_in_order ? this._nodes_in_order : this._nodes || []; - for (const e of t) - yield e; + const e = this._nodes_in_order ? this._nodes_in_order : this._nodes || []; + for (const t of e) + yield t; } /** * Iterates all nodes in this graph and subgraphs. */ *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()) + 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()) yield i; } /** * Iterates all nodes in this graph *excluding* subgraphs. */ - *iterateNodesOfClass(t) { - const e = t.__LITEGRAPH_TYPE__; - if (e != null) + *iterateNodesOfClass(e) { + const t = e.__LITEGRAPH_TYPE__; + if (t != null) for (const i of this.iterateNodesInOrder()) - i.type === e && (yield i); + i.type === t && (yield i); } /** * Iterates all nodes in this graph *excluding* subgraphs. */ - *iterateNodesOfClassRecursive(t) { - const e = t.__LITEGRAPH_TYPE__; - if (e != null) + *iterateNodesOfClassRecursive(e) { + const t = e.__LITEGRAPH_TYPE__; + if (t != null) for (const i of this.iterateNodesInOrderRecursive()) - i.type === e && (yield i); + i.type === t && (yield i); } /** * Iterates all nodes in this graph *excluding* subgraphs. */ - *iterateNodesOfTypeRecursive(t) { - for (const e of this.iterateNodesInOrderRecursive()) - e.type === t && (yield e); + *iterateNodesOfTypeRecursive(e) { + for (const t of this.iterateNodesInOrderRecursive()) + t.type === e && (yield t); } /** * 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(t, e = [], i = Z.ALWAYS) { + sendEventToAllNodes(e, t = [], 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" && t != "onExecute") { - s.mode == i && s.sendEventToAllNodes(t, e, i); + if (s.type === "basic/subgraph" && e != "onExecute") { + s.mode == i && s.sendEventToAllNodes(e, t, i); continue; } - !s[t] || s.mode != i || (e === void 0 ? s[t]() : e && e.constructor === Array ? s[t].apply(s, e) : s[t](e)); + !s[e] || s.mode != i || (t === void 0 ? s[e]() : t && t.constructor === Array ? s[e].apply(s, t) : s[e](t)); } } - sendActionToCanvas(t, e = []) { + sendActionToCanvas(e, t = []) { if (this.list_of_graphcanvas) for (var i = 0; i < this.list_of_graphcanvas.length; ++i) { var n = this.list_of_graphcanvas[i]; - n[t] && n[t].apply(n, e); + n[e] && n[e].apply(n, t); } } - addGroup(t) { - return this._groups.push(t), this.setDirtyCanvas(!0), this.change(), t.graph = this, this._version++, t; + addGroup(e) { + return this._groups.push(e), this.setDirtyCanvas(!0), this.change(), e.graph = this, this._version++, e; } /** * Adds a new node instance to this graph * @param node the instance of the node */ - add(t, e = {}) { - if (t.id != -1 && this._nodes_by_id[t.id] != null && (console.warn( + add(e, t = {}) { + if (e.id != -1 && this._nodes_by_id[e.id] != null && (console.warn( "LiteGraph: there is already a node with this ID, changing it", - t.id - ), u.use_uuids ? t.id = oe() : t.id = ++this.last_node_id), e.pos && (isNaN(e.pos[0]) || isNaN(e.pos[1]))) + e.id + ), u.use_uuids ? e.id = oe() : e.id = ++this.last_node_id), t.pos && (isNaN(t.pos[0]) || isNaN(t.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 ? 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; + 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; } /** Removes a node from the graph */ - 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(); + 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(); return; } - 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 (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 (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.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.onRemoved && t.onRemoved(e), t.graph = null, this._version++, this.list_of_graphcanvas) + if (e.onRemoved && e.onRemoved(t), e.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[t.id] && delete r.selected_nodes[t.id], r.node_dragged == t && (r.node_dragged = null); + r.selected_nodes[e.id] && delete r.selected_nodes[e.id], r.node_dragged == e && (r.node_dragged = null); } - 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(); + 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(); } } /** Returns a node by its id. */ - getNodeById(t) { - return t == null ? null : this._nodes_by_id[t]; + getNodeById(e) { + return e == null ? null : this._nodes_by_id[e]; } /** Returns a node by its id. */ - getNodeByIdRecursive(t) { - const e = this.getNodeById(t); - if (e != null) - return e; + getNodeByIdRecursive(e) { + const t = this.getNodeById(e); + if (t != null) + return t; for (const i of this.iterateNodesOfClass(ne)) { - const n = i.subgraph.getNodeByIdRecursive(t); + const n = i.subgraph.getNodeByIdRecursive(e); if (n) return n; } @@ -3718,56 +3736,56 @@ const De = class { * @param classObject the class itself (not an string) * @return a list with all the nodes of this type */ - findNodesByClass(t, e = []) { - e.length = 0; - for (const i of this.iterateNodesOfClass(t)) - e.push(i); - return e; + findNodesByClass(e, t = []) { + t.length = 0; + for (const i of this.iterateNodesOfClass(e)) + t.push(i); + return t; } /** * 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, e = []) { + findNodesByType(i, t = []) { var i = i.toLowerCase(); - e.length = 0; + t.length = 0; for (var n = 0, s = this._nodes.length; n < s; ++n) - this._nodes[n].type.toLowerCase() == i && e.push(this._nodes[n]); - return e; + this._nodes[n].type.toLowerCase() == i && t.push(this._nodes[n]); + return t; } /** * 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(t, e = []) { - e.length = 0; - for (const i of this.iterateNodesOfClassRecursive(t)) - e.push(i); - return e; + findNodesByClassRecursive(e, t = []) { + t.length = 0; + for (const i of this.iterateNodesOfClassRecursive(e)) + t.push(i); + return t; } /** * 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, e = []) { + findNodesByTypeRecursive(i, t = []) { var i = i.toLowerCase(); - e.length = 0; + t.length = 0; for (const n of this.iterateNodesOfTypeRecursive(i)) - e.push(n); - return e; + t.push(n); + return t; } /** * 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(t) { - for (var e = 0, i = this._nodes.length; e < i; ++e) - if (this._nodes[e].title == t) - return this._nodes[e]; + findNodeByTitle(e) { + for (var t = 0, i = this._nodes.length; t < i; ++t) + if (this._nodes[t].title == e) + return this._nodes[t]; return null; } /** @@ -3775,10 +3793,10 @@ const De = class { * @param title the name of the node to search * @return a list with all the nodes with this name */ - 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; + 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; } /** * Returns the top-most node in this position of the canvas @@ -3787,11 +3805,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(t, e, i, n) { + getNodeOnPos(e, t, 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(t, e, n, a)) + if (o.isPointInside(e, t, n, a)) return o; } return s; @@ -3802,10 +3820,10 @@ const De = class { * @param y the y coordinate in canvas space * @return the group or null */ - getGroupOnPos(t, e) { + getGroupOnPos(e, t) { for (var i = this._groups.length - 1; i >= 0; i--) { var n = this._groups[i]; - if (n.isPointInside(t, e, 2, !0)) + if (n.isPointInside(e, t, 2, !0)) return n; } return null; @@ -3816,93 +3834,93 @@ const De = class { * @method checkNodeTypes */ checkNodeTypes() { - for (var t = !1, e = 0; e < this._nodes.length; e++) { - var i = this._nodes[e], n = u.registered_node_types[i.type]; + for (var e = !1, t = 0; t < this._nodes.length; t++) { + var i = this._nodes[t], 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); - 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()); + 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()); } } - return this.updateExecutionOrder(), t; + return this.updateExecutionOrder(), e; } // ********** GLOBALS ***************** - onAction(t, e, i = {}) { + onAction(e, t, i = {}) { for (const n of this.iterateNodesOfClass($)) - if (n.properties.name == t) { - n.actionDo(t, e, i); + if (n.properties.name == e) { + n.actionDo(e, t, i); break; } } - trigger(t, e) { - this.onTrigger && this.onTrigger(t, e); + trigger(e, t) { + this.onTrigger && this.onTrigger(e, t); } - triggerSlot(t, e) { - this.onTrigger && this.onTrigger(t, e); + triggerSlot(e, t) { + this.onTrigger && this.onTrigger(e, t); } /** Tell this graph it has a global graph input of this type */ - 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()); + 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()); } /** Assign a data to the global graph input */ - setInputData(t, e) { - var i = this.inputs[t]; - i && (i.value = e); + setInputData(e, t) { + var i = this.inputs[e]; + i && (i.value = t); } /** Returns the current value of a global graph input */ - getInputData(t) { - var e = this.inputs[t]; - return e ? e.value : null; + getInputData(e) { + var t = this.inputs[e]; + return t ? t.value : null; } /** Changes the name of a global graph input */ - 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; + 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; } /** Changes the type of a global graph input */ - changeInputType(t, e) { - if (!this.inputs[t]) + changeInputType(e, t) { + if (!this.inputs[e]) return !1; - if (this.inputs[t].type && String(this.inputs[t].type).toLowerCase() == String(e).toLowerCase()) + if (this.inputs[e].type && String(this.inputs[e].type).toLowerCase() == String(t).toLowerCase()) return; - const i = this.inputs[t].type; - return this.inputs[t].type = e, this._version++, this.onInputTypeChanged && this.onInputTypeChanged(t, i, e), !0; + const i = this.inputs[e].type; + return this.inputs[e].type = t, this._version++, this.onInputTypeChanged && this.onInputTypeChanged(e, i, t), !0; } /** Removes a global graph input */ - removeInput(t) { - return this.inputs[t] ? (delete this.inputs[t], this._version++, this.onInputRemoved && this.onInputRemoved(t), this.onInputsOutputsChange && this.onInputsOutputsChange(), !0) : !1; + removeInput(e) { + return this.inputs[e] ? (delete this.inputs[e], this._version++, this.onInputRemoved && this.onInputRemoved(e), this.onInputsOutputsChange && this.onInputsOutputsChange(), !0) : !1; } /** Creates a global graph output */ - 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(); + 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(); } /** Assign a data to the global output */ - setOutputData(t, e) { - var i = this.outputs[t]; - i && (i.value = e); + setOutputData(e, t) { + var i = this.outputs[e]; + i && (i.value = t); } /** Returns the current value of a global graph output */ - getOutputData(t) { - var e = this.outputs[t]; - return e ? e.value : null; + getOutputData(e) { + var t = this.outputs[e]; + return t ? t.value : null; } /** Renames a global graph output */ - 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; + 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; } /** Changes the type of a global graph output */ - changeOutputType(t, e) { - if (!this.outputs[t]) + changeOutputType(e, t) { + if (!this.outputs[e]) return !1; - if (this.outputs[t].type && String(this.outputs[t].type).toLowerCase() == String(e).toLowerCase()) + if (this.outputs[e].type && String(this.outputs[e].type).toLowerCase() == String(t).toLowerCase()) return; - const i = this.outputs[t].type; - return this.outputs[t].type = e, this._version++, this.onOutputTypeChanged && this.onOutputTypeChanged(t, i, e), !0; + const i = this.outputs[e].type; + return this.outputs[e].type = t, this._version++, this.onOutputTypeChanged && this.onOutputTypeChanged(e, i, t), !0; } /** Removes a global graph output */ - removeOutput(t) { - return this.outputs[t] ? (delete this.outputs[t], this._version++, this.onOutputRemoved && this.onOutputRemoved(t), this.onInputsOutputsChange && this.onInputsOutputsChange(), !0) : !1; + removeOutput(e) { + return this.outputs[e] ? (delete this.outputs[e], this._version++, this.onOutputRemoved && this.onOutputRemoved(e), this.onInputsOutputsChange && this.onInputsOutputsChange(), !0) : !1; } /* TODO implement triggerInput(name: string, value: any): void { @@ -3920,53 +3938,53 @@ const De = class { } */ /** used for undo, called before any change is made to the graph */ - beforeChange(t) { - this.onBeforeChange && this.onBeforeChange(this, t), this.sendActionToCanvas("onBeforeChange", [this]); + beforeChange(e) { + this.onBeforeChange && this.onBeforeChange(this, e), this.sendActionToCanvas("onBeforeChange", [this]); } /** used to resend actions, called after any change is made to the graph */ - afterChange(t) { - this.onAfterChange && this.onAfterChange(this, t), this.sendActionToCanvas("onAfterChange", [this]); + afterChange(e) { + this.onAfterChange && this.onAfterChange(this, e), this.sendActionToCanvas("onAfterChange", [this]); } - connectionChange(t, e) { - this.updateExecutionOrder(), this.onConnectionChange && this.onConnectionChange(t), this._version++, this.sendActionToCanvas("onConnectionChange"); + connectionChange(e, t) { + this.updateExecutionOrder(), this.onConnectionChange && this.onConnectionChange(e), this._version++, this.sendActionToCanvas("onConnectionChange"); } /** returns if the graph is in live mode */ isLive() { if (!this.list_of_graphcanvas) return !1; - for (var t = 0; t < this.list_of_graphcanvas.length; ++t) { - var e = this.list_of_graphcanvas[t]; - if (e.live_mode) + for (var e = 0; e < this.list_of_graphcanvas.length; ++e) { + var t = this.list_of_graphcanvas[e]; + if (t.live_mode) return !0; } return !1; } /** clears the triggered slot animation in all links (stop visual animation) */ clearTriggeredSlots() { - for (var t in this.links) { - var e = this.links[t]; - e && e._last_time && (e._last_time = 0); + for (var e in this.links) { + var t = this.links[e]; + t && t._last_time && (t._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(t = !1, e = !1) { - this.sendActionToCanvas("setDirty", [t, e]); + setDirtyCanvas(e = !1, t = !1) { + this.sendActionToCanvas("setDirty", [e, t]); } /** Destroys a link */ - removeLink(t) { - var e = this.links[t]; - if (e) { - var i = this.getNodeById(e.target_id); - i && i.disconnectInput(e.target_slot); + removeLink(e) { + var t = this.links[e]; + if (t) { + var i = this.getNodeById(t.target_id); + i && i.disconnectInput(t.target_slot); } } /** Creates a Object containing all the info about this graph, it can be serialized */ serialize() { - for (var t = [], e = 0, i = this._nodes.length; e < i; ++e) - t.push(this._nodes[e].serialize()); + for (var e = [], t = 0, i = this._nodes.length; t < i; ++t) + e.push(this._nodes[t].serialize()); var n = []; for (const h in this.links) { var s = this.links[h]; @@ -3982,12 +4000,12 @@ const De = class { } n.push(s.serialize()); } - for (var a = [], e = 0; e < this._groups.length; ++e) - a.push(this._groups[e].serialize()); + for (var a = [], t = 0; t < this._groups.length; ++t) + a.push(this._groups[t].serialize()); var l = { last_node_id: this.last_node_id, last_link_id: this.last_link_id, - nodes: t, + nodes: e, links: n, groups: a, config: this.config, @@ -4001,13 +4019,13 @@ const De = class { * @param data configure a graph from a JSON string * @returns if there was any error parsing */ - 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]; + 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]; if (!r) { console.warn("serialized graph link data contains errors, skipping."); continue; @@ -4015,10 +4033,10 @@ const De = class { var o = he.configure(r); n[o.id] = o; } - t.links = n; + e.links = n; } - for (const c in t) - c == "nodes" || c == "groups" || (this[c] = t[c]); + for (const c in e) + c == "nodes" || c == "groups" || (this[c] = e[c]); var a = !1; if (this._nodes = [], i) { for (var s = 0, l = i.length; s < l; ++s) { @@ -4032,32 +4050,32 @@ const De = class { p && p.configure(h); } } - if (this._groups.length = 0, t.groups) - for (var s = 0; s < t.groups.length; ++s) { + if (this._groups.length = 0, e.groups) + for (var s = 0; s < e.groups.length; ++s) { var f = new me(); - f.configure(t.groups[s]), this.addGroup(f); + f.configure(e.groups[s]), this.addGroup(f); } - return this.updateExecutionOrder(), this.extra = t.extra || {}, this.onConfigure && this.onConfigure(t), this._version++, this.setDirtyCanvas(!0, !0), a; + return this.updateExecutionOrder(), this.extra = e.extra || {}, this.onConfigure && this.onConfigure(e), this._version++, this.setDirtyCanvas(!0, !0), a; } } - load(t, e) { + load(e, t) { var i = this; - if (t.constructor === File || t.constructor === Blob) { + if (e.constructor === File || e.constructor === Blob) { var n = new FileReader(); n.addEventListener("load", function(r) { var o = JSON.parse(n.result); - i.configure(o), e && e(o); - }), n.readAsText(t); + i.configure(o), t && t(o); + }), n.readAsText(e); return; } var s = new XMLHttpRequest(); - s.open("GET", t, !0), s.send(null), s.onload = function(r) { + s.open("GET", e, !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), e && e(o); + i.configure(o), t && t(o); }, s.onerror = function(r) { console.error("Error loading graph:", r); }; @@ -4065,54 +4083,54 @@ const De = class { }; let Pe = De; Pe.DEFAULT_SUPPORTED_TYPES = ["number", "string", "boolean"]; -function Re(t) { - const e = { nodeIDs: {}, linkIDs: {} }; - for (const i of t.nodes) { +function Re(e) { + const t = { nodeIDs: {}, linkIDs: {} }; + for (const i of e.nodes) { const n = i.id, s = oe(); - if (i.id = s, e.nodeIDs[n] || e.nodeIDs[s]) + if (i.id = s, t.nodeIDs[n] || t.nodeIDs[s]) throw new Error( `New/old node UUID wasn't unique in changed map! ${n} ${s}` ); - e.nodeIDs[n] = s, e.nodeIDs[s] = n; + t.nodeIDs[n] = s, t.nodeIDs[s] = n; } - for (const i of t.links) { + for (const i of e.links) { const n = i[0], s = oe(); - if (i[0] = s, e.linkIDs[n] || e.linkIDs[s]) + if (i[0] = s, t.linkIDs[n] || t.linkIDs[s]) throw new Error( `New/old link UUID wasn't unique in changed map! ${n} ${s}` ); - e.linkIDs[n] = s, e.linkIDs[s] = n; + t.linkIDs[n] = s, t.linkIDs[s] = n; const r = i[1], o = i[3]; - if (!e.nodeIDs[r]) + if (!t.nodeIDs[r]) throw new Error(`Old node UUID not found in mapping! ${r}`); - if (i[1] = e.nodeIDs[r], !e.nodeIDs[o]) + if (i[1] = t.nodeIDs[r], !t.nodeIDs[o]) throw new Error(`Old node UUID not found in mapping! ${o}`); - i[3] = e.nodeIDs[o]; + i[3] = t.nodeIDs[o]; } - for (const i of t.nodes) { + for (const i of e.nodes) { for (const n of i.inputs) - n.link && (n.link = e.linkIDs[n.link]); + n.link && (n.link = t.linkIDs[n.link]); for (const n of i.outputs) - n.links && (n.links = n.links.map((s) => e.linkIDs[s])); + n.links && (n.links = n.links.map((s) => t.linkIDs[s])); } - for (const i of t.nodes) + for (const i of e.nodes) if (i.type === "graph/subgraph") { const n = Re( i.subgraph ); - e.nodeIDs = { ...e.nodeIDs, ...n.nodeIDs }, e.linkIDs = { ...e.linkIDs, ...n.linkIDs }; + t.nodeIDs = { ...t.nodeIDs, ...n.nodeIDs }, t.linkIDs = { ...t.linkIDs, ...n.linkIDs }; } - return e; + return t; } -function Ve(t, e) { - for (const i of t.iterateNodesInOrderRecursive()) - i.onReassignID && i.onReassignID(e); +function Ve(e, t) { + for (const i of e.iterateNodesInOrderRecursive()) + i.onReassignID && i.onReassignID(t); } const Me = class extends ae { - constructor(t, e) { - super(t), this.properties = { + constructor(e, t) { + super(e), this.properties = { enabled: !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; + }, this.size = [140, 80], this.enabled = !0, this.subgraph = (t || 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) { @@ -4163,42 +4181,42 @@ const Me = class extends ae { // return graph; // } *iterateParentGraphs() { - var e; - let t = this.graph; - for (; t; ) - yield t, t = (e = t._subgraph_node) == null ? void 0 : e.graph; + var t; + let e = this.graph; + for (; e; ) + yield e, e = (t = e._subgraph_node) == null ? void 0 : t.graph; } - onDblClick(t, e, i) { + onDblClick(e, t, i) { var n = this; setTimeout(function() { i.openSubgraph(n.subgraph); }, 10); } - onAction(t, e, i) { + onAction(e, t, i) { const { originNode: n, link: s } = i; if (!n || !s) return; const r = s.target_slot; - this.getInnerGraphInputByIndex(r).triggerSlot(0, e); + this.getInnerGraphInputByIndex(r).triggerSlot(0, t); } onExecute() { if (this.enabled = this.getInputOrProperty("enabled"), !!this.enabled) { if (this.inputs) - for (var t = 0; t < this.inputs.length; t++) { - var e = this.inputs[t], i = this.getInputData(t); - this.subgraph.setInputData(e.name, i); + for (var e = 0; e < this.inputs.length; e++) { + var t = this.inputs[e], i = this.getInputData(e); + this.subgraph.setInputData(t.name, i); } if (this.subgraph.runStep(), this.outputs) - for (var t = 0; t < this.outputs.length; t++) { - var n = this.outputs[t], i = this.subgraph.getOutputData(n.name); - this.setOutputData(t, i); + for (var e = 0; e < this.outputs.length; e++) { + var n = this.outputs[e], i = this.subgraph.getOutputData(n.name); + this.setOutputData(e, i); } } } - sendEventToAllNodes(t, e, i) { - this.enabled && this.subgraph.sendEventToAllNodes(t, e, i); + sendEventToAllNodes(e, t, i) { + this.enabled && this.subgraph.sendEventToAllNodes(e, t, i); } - onDrawBackground(t, e, i, n) { + onDrawBackground(e, t, i, n) { } // override onMouseDown(e, localpos, graphcanvas) // { @@ -4223,123 +4241,123 @@ const Me = class extends ae { // return false; // } computeSize() { - var t = this.inputs ? this.inputs.length : 0, e = this.outputs ? this.outputs.length : 0; + var e = this.inputs ? this.inputs.length : 0, t = this.outputs ? this.outputs.length : 0; return [ 200, - Math.max(t, e) * u.NODE_SLOT_HEIGHT + u.NODE_SLOT_HEIGHT * 0.5 + Math.max(e, t) * u.NODE_SLOT_HEIGHT + u.NODE_SLOT_HEIGHT * 0.5 ]; } //**** INPUTS *********************************** - onSubgraphTrigger(t, e) { + onSubgraphTrigger(e, t) { } - onSubgraphNodeAdded(t, e) { + onSubgraphNodeAdded(e, t) { var i, n; - (i = this.graph) != null && i.onNodeAdded && (e.subgraphs || (e.subgraphs = []), e.subgraphs.push(this), (n = this.graph) == null || n.onNodeAdded(t, e)); + (i = this.graph) != null && i.onNodeAdded && (t.subgraphs || (t.subgraphs = []), t.subgraphs.push(this), (n = this.graph) == null || n.onNodeAdded(e, t)); } - onSubgraphNodeRemoved(t, e) { + onSubgraphNodeRemoved(e, t) { var i, n; - (i = this.graph) != null && i.onNodeRemoved && (e.subgraphs || (e.subgraphs = []), e.subgraphs.push(this), (n = this.graph) == null || n.onNodeRemoved(t, e)); + (i = this.graph) != null && i.onNodeRemoved && (t.subgraphs || (t.subgraphs = []), t.subgraphs.push(this), (n = this.graph) == null || n.onNodeRemoved(e, t)); } - onSubgraphNewInput(t, e) { - var i = this.findInputSlotIndexByName(t); - i == -1 && this.addInput(t, e); + onSubgraphNewInput(e, t) { + var i = this.findInputSlotIndexByName(e); + i == -1 && this.addInput(e, t); } - onSubgraphRenamedInput(t, e) { - var i = this.findInputSlotIndexByName(t); + onSubgraphRenamedInput(e, t) { + var i = this.findInputSlotIndexByName(e); if (i != -1) { var n = this.getInputInfo(i); - n.name = e; + n.name = t; } } - onSubgraphTypeChangeInput(t, e, i) { - var n = this.findInputSlotIndexByName(t); + onSubgraphTypeChangeInput(e, t, i) { + var n = this.findInputSlotIndexByName(e); if (n != -1) { var s = this.getInputInfo(n); s.type = i; } } - onSubgraphRemovedInput(t) { - var e = this.findInputSlotIndexByName(t); - e != -1 && this.removeInput(e); + onSubgraphRemovedInput(e) { + var t = this.findInputSlotIndexByName(e); + t != -1 && this.removeInput(t); } //**** OUTPUTS *********************************** - onSubgraphNewOutput(t, e) { - var i = this.findOutputSlotIndexByName(t); - i == -1 && this.addOutput(t, e); + onSubgraphNewOutput(e, t) { + var i = this.findOutputSlotIndexByName(e); + i == -1 && this.addOutput(e, t); } - onSubgraphRenamedOutput(t, e) { - var i = this.findOutputSlotIndexByName(t); + onSubgraphRenamedOutput(e, t) { + var i = this.findOutputSlotIndexByName(e); if (i != -1) { var n = this.getOutputInfo(i); - n.name = e; + n.name = t; } } - onSubgraphTypeChangeOutput(t, e, i) { - var n = this.findOutputSlotIndexByName(t); + onSubgraphTypeChangeOutput(e, t, i) { + var n = this.findOutputSlotIndexByName(e); if (n != -1) { var s = this.getOutputInfo(n); s.type = i; } } - onSubgraphRemovedOutput(t) { - var e = this.findOutputSlotIndexByName(t); - e != -1 && this.removeOutput(e); + onSubgraphRemovedOutput(e) { + var t = this.findOutputSlotIndexByName(e); + t != -1 && this.removeOutput(t); } // ***************************************************** - getExtraMenuOptions(t, e) { + getExtraMenuOptions(e, t) { var i = this; return [ { content: "Open", callback: function() { - t.openSubgraph(i.subgraph); + e.openSubgraph(i.subgraph); } } ]; } - onResize(t) { + onResize(e) { console.error("TEST subgraph resize"); } serialize() { - var t = ae.prototype.serialize.call(this); - return t.subgraph = this.subgraph.serialize(), t; + var e = ae.prototype.serialize.call(this); + return e.subgraph = this.subgraph.serialize(), e; } //no need to define node.configure, the default method detects node.subgraph and passes the object to node.subgraph.configure() - 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); - } - onReassignID() { + 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); } - clone(t = { forNode: {} }) { + onReassignID() { + for (const e of this.subgraph.iterateNodesInOrder()) + (e.is($) || e.is(Q)) && (e.properties.subgraphID = this.id); + } + clone(e = { forNode: {} }) { var s, r, o, a; - var e = u.createNode(this.type), i = this.serialize(); + var t = 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, 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; + 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; } - buildFromNodes(t) { + buildFromNodes(e) { var _, y; - if (t = t.filter((b) => !b.is($) && !b.is(Q)), t.length === 0) + if (e = e.filter((b) => !b.is($) && !b.is(Q)), e.length === 0) return; - const e = {}, i = {}, n = {}, s = t.reduce((b, m) => (b[m.id] = m, b), {}); + const t = {}, i = {}, n = {}, s = e.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(t)) + for (const b of Object.values(e)) 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 t) { + for (const b of e) { 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] : e[E.id] = [E, T, O.name]; + A && (h[A.id] = A), s[E.origin_id] != null ? n[E.id] = [E, T] : t[E.id] = [E, T, O.name]; } } for (let m = 0; m < b.outputs.length; m++) { @@ -4350,10 +4368,10 @@ const Me = class extends ae { } } } - 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 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 c = {}, v = {}; - for (const b of t) { + for (const b of e) { 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", @@ -4400,108 +4418,108 @@ const Me = class extends ae { ); } } - addGraphInput(t, e, i) { - t = this.getValidGraphInputName(t); + addGraphInput(e, t, i) { + e = this.getValidGraphInputName(e); const n = u.createNode($); if (n == null) return null; - 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); + 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); const r = n.computeSize(); i && (n.pos = [ i[0] - r[0] * 0.5, i[1] - r[1] * 0.5 - ]), this.subgraph.addInput(t, s, null); + ]), this.subgraph.addInput(e, s, null); const o = this.inputs.length - 1, a = this.inputs[o]; return { innerNode: n, outerInput: a, outerInputIndex: o }; } - addGraphOutput(t, e, i) { - t = this.getValidGraphOutputName(t); + addGraphOutput(e, t, i) { + e = this.getValidGraphOutputName(e); const n = u.createNode(Q); if (n == null) return null; - 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); + 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); const r = n.computeSize(); - i && (n.pos = [i[0], i[1] - r[1] * 0.5]), this.subgraph.addOutput(t, s, null); + i && (n.pos = [i[0], i[1] - r[1] * 0.5]), this.subgraph.addOutput(e, s, null); const o = this.outputs.length - 1, a = this.outputs[o]; return { innerNode: n, outerOutput: a, outerOutputIndex: o }; } - removeGraphInput(t) { - if (this.findInputSlotIndexByName(t) == null) { - console.error("[Subgraph] No input in slot!", t); + removeGraphInput(e) { + if (this.findInputSlotIndexByName(e) == null) { + console.error("[Subgraph] No input in slot!", e); return; } - const i = this.subgraph.findNodesByClass($).filter((n) => n.properties.name === t); + const i = this.subgraph.findNodesByClass($).filter((n) => n.properties.name === e); if (i.length > 0) for (const n of i) this.subgraph.remove(n); else { console.warn( "[Subgraph] No GraphInputs found on input removal", - t + e ); - const n = this.findInputSlotIndexByName(t); + const n = this.findInputSlotIndexByName(e); n !== -1 && this.removeInput(n); } } - removeGraphOutput(t) { - if (this.findOutputSlotIndexByName(t) == null) { - console.error("[Subgraph] No output in slot!", t); + removeGraphOutput(e) { + if (this.findOutputSlotIndexByName(e) == null) { + console.error("[Subgraph] No output in slot!", e); return; } - const i = this.subgraph.findNodesByClass(Q).filter((n) => n.properties.name === t); + const i = this.subgraph.findNodesByClass(Q).filter((n) => n.properties.name === e); if (i.length > 0) for (const n of i) this.subgraph.remove(n); else { console.warn( "[Subgraph] No GraphOutputs found on output removal", - t + e ); - const n = this.findOutputSlotIndexByName(t); + const n = this.findOutputSlotIndexByName(e); n !== -1 && this.removeOutput(n); } } - getValidGraphInputName(t) { - t || (t = "newInput"); - let e = t, i = this.getInnerGraphInput(e), n = 1; + getValidGraphInputName(e) { + e || (e = "newInput"); + let t = e, i = this.getInnerGraphInput(t), n = 1; for (; i != null; ) - e = `${t}_${n++}`, i = this.getInnerGraphInput(e); - return e; + t = `${e}_${n++}`, i = this.getInnerGraphInput(t); + return t; } - getValidGraphOutputName(t) { - t || (t = "newOutput"); - let e = t, i = this.getInnerGraphOutput(e), n = 1; + getValidGraphOutputName(e) { + e || (e = "newOutput"); + let t = e, i = this.getInnerGraphOutput(t), n = 1; for (; i != null; ) - e = `${t}_${n++}`, i = this.getInnerGraphOutput(e); - return e; + t = `${e}_${n++}`, i = this.getInnerGraphOutput(t); + return t; } - getInnerGraphOutput(t) { - return this.subgraph._nodes.find((i) => i.is(Q) && i.properties.name === t) || null; + getInnerGraphOutput(e) { + return this.subgraph._nodes.find((i) => i.is(Q) && i.properties.name === e) || null; } - getInnerGraphInput(t) { - return this.subgraph._nodes.find((i) => i.is($) && i.properties.name === t) || null; + getInnerGraphInput(e) { + return this.subgraph._nodes.find((i) => i.is($) && i.properties.name === e) || null; } - getInnerGraphOutputByIndex(t) { - const e = this.getOutputInfo(t); - return e ? this.getInnerGraphOutput(e.name) : null; + getInnerGraphOutputByIndex(e) { + const t = this.getOutputInfo(e); + return t ? this.getInnerGraphOutput(t.name) : null; } - getInnerGraphInputByIndex(t) { - const e = this.getInputInfo(t); - return e ? this.getInnerGraphInput(e.name) : null; + getInnerGraphInputByIndex(e) { + const t = this.getInputInfo(e); + return t ? this.getInnerGraphInput(t.name) : null; } - moveNodesToParentGraph(t) { - if (t = t.filter((g) => !g.is($) && !g.is(Q)), t.length === 0) + moveNodesToParentGraph(e) { + if (e = e.filter((g) => !g.is($) && !g.is(Q)), e.length === 0) return; - const e = this, i = e.graph; + const t = this, i = t.graph; let n = Number.MAX_SAFE_INTEGER, s = 0, r = Number.MAX_SAFE_INTEGER, o = 0; - for (const g of Object.values(t)) + for (const g of Object.values(e)) 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 = 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()) + 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()) c[d.id] = d; - for (const g of t) + for (const g of e) for (const d of g.iterateAllLinks()) { const _ = d.target_id === g.id, y = g.getConnectionPos( _, @@ -4510,7 +4528,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 t.entries()) { + for (const [g, d] of e.entries()) { const _ = [ d.pos[0] - n + h, d.pos[1] - r + p @@ -4523,18 +4541,18 @@ const Me = class extends ae { } return v; } - convertNodesToSubgraphInputs(t) { + convertNodesToSubgraphInputs(e) { var a; - if (t = t.filter((l) => !l.is($) && !l.is(Q)), t.length === 0) + if (e = e.filter((l) => !l.is($) && !l.is(Q)), e.length === 0) return; - const e = ve(t, (l) => l.id), i = [], n = {}, s = this.subgraph; - for (const l of t) + const t = ve(e, (l) => l.id), i = [], n = {}, s = this.subgraph; + for (const l of e) for (const h of l.iterateAllLinks()) { - if (e[h.origin_id] == null) + if (t[h.origin_id] == null) throw new Error( "Can't convert to input with an origin link outward" ); - if (e[h.target_id] == null) { + if (t[h.target_id] == null) { i.push(h); const p = [0, 0]; l.getConnectionPos(!1, h.target_slot, p), n[l.id] = [ @@ -4543,7 +4561,7 @@ const Me = class extends ae { ]; } } - const r = this.moveNodesToParentGraph(t), o = {}; + const r = this.moveNodesToParentGraph(e), 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] = {}); @@ -4574,25 +4592,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(t) { + convertNodesToSubgraphOutputs(e) { var a; - if (t = t.filter((l) => !l.is($) && !l.is(Q)), t.length === 0) + if (e = e.filter((l) => !l.is($) && !l.is(Q)), e.length === 0) return; - const e = ve(t, (l) => l.id), i = [], n = {}, s = this.subgraph; - for (const l of t) + const t = ve(e, (l) => l.id), i = [], n = {}, s = this.subgraph; + for (const l of e) for (const h of l.iterateAllLinks()) - if (e[h.origin_id] == null) { + if (t[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 (e[h.target_id] == null) + } else if (t[h.target_id] == null) throw new Error( "Can't convert to input with an origin link outward" ); - const r = this.moveNodesToParentGraph(t), o = {}; + const r = this.moveNodesToParentGraph(e), 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] = {}); @@ -4639,7 +4657,7 @@ class C { static onMenuNodeEdit() { } // refactor: there are different dialogs, some uses createDialog some dont - prompt(e = "", i, n, s, r = !1, o = null) { + prompt(t = "", 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; @@ -4677,7 +4695,7 @@ class C { }); }), a.prompt_box && a.prompt_box.close(), a.prompt_box = l; var g = l.querySelector(".name"); - g.innerText = e; + g.innerText = t; let d = l.querySelector(".value"); d.value = i; var _ = d; @@ -4701,7 +4719,7 @@ class C { _.focus(); }, 10), Ee(l), l; } - showSearchBox(e, i = {}) { + showSearchBox(t, i = {}) { var n = { slotFrom: null, node_from: null, @@ -4717,7 +4735,7 @@ class C { }; i = Object.assign(n, i); var s = this, r = N.active_canvas, o = r.canvas, a = o.ownerDocument || document; - let l = e; + let l = t; 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; @@ -4937,9 +4955,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(e) { + showShowNodePanel(t) { this.closePanels(); - var i = this.getCanvasWindow(), n = this, s = this.createPanel(e.title || "", { + var i = this.getCanvasWindow(), n = this, s = this.createPanel(t.title || "", { closable: !0, window: i, onOpen: function() { @@ -4948,38 +4966,38 @@ class C { n.node_panel = null; } }); - n.node_panel = s, s.id = "node-panel", s.node = e, s.classList.add("settings"); + n.node_panel = s, s.id = "node-panel", s.node = t, s.classList.add("settings"); function r() { - s.content.innerHTML = "", s.addHTML("" + e.type + "" + (e.constructor.desc || "") + ""), s.addHTML("