From f13b7c8818106318361cadbc8d41a86a5adf55fa Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Wed, 25 Sep 2024 18:03:41 +1000 Subject: [PATCH] Split LLink out to TS file --- src/LGraph.ts | 3 ++- src/LLink.ts | 43 +++++++++++++++++++++++++++++++++++++++++++ src/litegraph.js | 45 ++------------------------------------------- 3 files changed, 47 insertions(+), 44 deletions(-) create mode 100644 src/LLink.ts diff --git a/src/LGraph.ts b/src/LGraph.ts index 498255a47..50438d7cc 100644 --- a/src/LGraph.ts +++ b/src/LGraph.ts @@ -1,5 +1,6 @@ // @ts-nocheck -import { LiteGraph, LGraphCanvas, LGraphGroup, LLink, LGraphNode } from "./litegraph"; +import { LiteGraph, LGraphCanvas, LGraphGroup, LGraphNode } from "./litegraph"; +import { LLink } from "./LLink"; //********************************************************************************* // LGraph CLASS diff --git a/src/LLink.ts b/src/LLink.ts new file mode 100644 index 000000000..adb1ba40e --- /dev/null +++ b/src/LLink.ts @@ -0,0 +1,43 @@ +// @ts-nocheck +//this is the class in charge of storing link information + +export class LLink { + constructor(id, type, origin_id, origin_slot, target_id, target_slot) { + this.id = id; + this.type = type; + this.origin_id = origin_id; + this.origin_slot = origin_slot; + this.target_id = target_id; + this.target_slot = target_slot; + + this._data = null; + this._pos = new Float32Array(2); //center + } + configure(o) { + if (o.constructor === Array) { + this.id = o[0]; + this.origin_id = o[1]; + this.origin_slot = o[2]; + this.target_id = o[3]; + this.target_slot = o[4]; + this.type = o[5]; + } else { + this.id = o.id; + this.type = o.type; + this.origin_id = o.origin_id; + this.origin_slot = o.origin_slot; + this.target_id = o.target_id; + this.target_slot = o.target_slot; + } + } + serialize() { + return [ + this.id, + this.origin_id, + this.origin_slot, + this.target_id, + this.target_slot, + this.type + ]; + } +} diff --git a/src/litegraph.js b/src/litegraph.js index fd1fde9ff..6d9f4d70a 100755 --- a/src/litegraph.js +++ b/src/litegraph.js @@ -3,55 +3,14 @@ import { drawSlot, SlotShape, SlotDirection, SlotType, LabelPosition } from "./d import { LiteGraphGlobal, distance, isInsideRectangle, overlapBounding } from "./LiteGraphGlobal"; import { LGraph } from "./LGraph" +import { LLink } from "./LLink" -export { LGraph } +export { LGraph, LLink } export const LiteGraph = new LiteGraphGlobal() LiteGraph.LGraph = LGraph - //this is the class in charge of storing link information - export class LLink { - constructor(id, type, origin_id, origin_slot, target_id, target_slot) { - this.id = id; - this.type = type; - this.origin_id = origin_id; - this.origin_slot = origin_slot; - this.target_id = target_id; - this.target_slot = target_slot; - - this._data = null; - this._pos = new Float32Array(2); //center - } - configure(o) { - if (o.constructor === Array) { - this.id = o[0]; - this.origin_id = o[1]; - this.origin_slot = o[2]; - this.target_id = o[3]; - this.target_slot = o[4]; - this.type = o[5]; - } else { - this.id = o.id; - this.type = o.type; - this.origin_id = o.origin_id; - this.origin_slot = o.origin_slot; - this.target_id = o.target_id; - this.target_slot = o.target_slot; - } - } - serialize() { - return [ - this.id, - this.origin_id, - this.origin_slot, - this.target_id, - this.target_slot, - this.type - ]; - } - } - LiteGraph.LLink = LLink; // *************************************************************