diff --git a/src/LGraph.ts b/src/LGraph.ts index c164a6900..8bfc7ab15 100644 --- a/src/LGraph.ts +++ b/src/LGraph.ts @@ -30,12 +30,6 @@ import { stringOrEmpty } from "./strings" import { LGraphEventMode } from "./types/globalEnums" import { getAllNestedItems } from "./utils/collections" -interface IGraphInput { - name: string - type: string - value?: unknown -} - export interface LGraphState { lastGroupId: number lastNodeId: number @@ -125,8 +119,6 @@ export class LGraph implements LinkNetwork, Serialisable { nodes_actioning: (string | boolean)[] = [] nodes_executedAction: string[] = [] extra: Record = {} - inputs: Dictionary = {} - outputs: Dictionary = {} /** @deprecated Deserialising a workflow sets this unused property. */ version?: number @@ -298,9 +290,6 @@ export class LGraph implements LinkNetwork, Serialisable { this.nodes_actioning = [] this.nodes_executedAction = [] - this.inputs = {} - this.outputs = {} - // notify canvas to redraw this.change() @@ -1134,178 +1123,6 @@ export class LGraph implements LinkNetwork, Serialisable { this.onTrigger?.(action, param) } - /** - * Tell this graph it has a global graph input of this type - */ - addInput(name: string, type: string, value?: unknown): void { - const input = this.inputs[name] - // already exist - if (input) return - - this.beforeChange() - this.inputs[name] = { name: name, type: type, value: value } - this._version++ - this.afterChange() - - this.onInputAdded?.(name, type) - this.onInputsOutputsChange?.() - } - - /** - * Assign a data to the global graph input - */ - setInputData(name: string, data: unknown): void { - const input = this.inputs[name] - if (!input) return - input.value = data - } - - /** - * Returns the current value of a global graph input - */ - getInputData(name: string): unknown { - const input = this.inputs[name] - return input - ? input.value - : null - } - - /** - * Changes the name of a global graph input - */ - renameInput(old_name: string, name: string): boolean | undefined { - if (name == old_name) return - - if (!this.inputs[old_name]) return false - - if (this.inputs[name]) { - console.error("there is already one input with that name") - return false - } - - this.inputs[name] = this.inputs[old_name] - delete this.inputs[old_name] - this._version++ - - this.onInputRenamed?.(old_name, name) - this.onInputsOutputsChange?.() - } - - /** - * Changes the type of a global graph input - */ - changeInputType(name: string, type: string): boolean | undefined { - if (!this.inputs[name]) return false - - if ( - this.inputs[name].type && - String(this.inputs[name].type).toLowerCase() == String(type).toLowerCase() - ) { - return - } - - this.inputs[name].type = type - this._version++ - this.onInputTypeChanged?.(name, type) - } - - /** - * Removes a global graph input - */ - removeInput(name: string): boolean { - if (!this.inputs[name]) return false - - delete this.inputs[name] - this._version++ - - this.onInputRemoved?.(name) - this.onInputsOutputsChange?.() - return true - } - - /** - * Creates a global graph output - */ - addOutput(name: string, type: string, value: unknown): void { - this.outputs[name] = { name: name, type: type, value: value } - this._version++ - - this.onOutputAdded?.(name, type) - - this.onInputsOutputsChange?.() - } - - /** - * Assign a data to the global output - */ - setOutputData(name: string, value: unknown): void { - const output = this.outputs[name] - if (!output) return - output.value = value - } - - /** - * Returns the current value of a global graph output - */ - getOutputData(name: string): unknown { - const output = this.outputs[name] - if (!output) return null - return output.value - } - - /** - * Renames a global graph output - */ - renameOutput(old_name: string, name: string): boolean | undefined { - if (!this.outputs[old_name]) return false - - if (this.outputs[name]) { - console.error("there is already one output with that name") - return false - } - - this.outputs[name] = this.outputs[old_name] - delete this.outputs[old_name] - this._version++ - - this.onOutputRenamed?.(old_name, name) - - this.onInputsOutputsChange?.() - } - - /** - * Changes the type of a global graph output - */ - changeOutputType(name: string, type: string): boolean | undefined { - if (!this.outputs[name]) return false - - if ( - this.outputs[name].type && - String(this.outputs[name].type).toLowerCase() == String(type).toLowerCase() - ) { - return - } - - this.outputs[name].type = type - this._version++ - this.onOutputTypeChanged?.(name, type) - } - - /** - * Removes a global graph output - */ - removeOutput(name: string): boolean { - if (!this.outputs[name]) return false - - delete this.outputs[name] - this._version++ - - this.onOutputRemoved?.(name) - - this.onInputsOutputsChange?.() - return true - } - /** @todo Clean up - never implemented. */ triggerInput(name: string, value: any): void { const nodes = this.findNodesByTitle(name) diff --git a/test/__snapshots__/ConfigureGraph.test.ts.snap b/test/__snapshots__/ConfigureGraph.test.ts.snap index 91d5ecf47..79244720d 100644 --- a/test/__snapshots__/ConfigureGraph.test.ts.snap +++ b/test/__snapshots__/ConfigureGraph.test.ts.snap @@ -241,7 +241,6 @@ LGraph { "fixedtime_lapse": 0.01, "globaltime": 0, "id": "ca9da7d8-fddd-4707-ad32-67be9be13140", - "inputs": {}, "iteration": 0, "last_update_time": 0, "links": Map {}, @@ -249,7 +248,6 @@ LGraph { "nodes_actioning": [], "nodes_executedAction": [], "nodes_executing": [], - "outputs": {}, "revision": 0, "runningtime": 0, "starttime": 0, @@ -288,7 +286,6 @@ LGraph { "fixedtime_lapse": 0.01, "globaltime": 0, "id": "d175890f-716a-4ece-ba33-1d17a513b7be", - "inputs": {}, "iteration": 0, "last_update_time": 0, "links": Map {}, @@ -296,7 +293,6 @@ LGraph { "nodes_actioning": [], "nodes_executedAction": [], "nodes_executing": [], - "outputs": {}, "revision": 0, "runningtime": 0, "starttime": 0, diff --git a/test/__snapshots__/LGraph.test.ts.snap b/test/__snapshots__/LGraph.test.ts.snap index 200fdf69a..6bf93da10 100644 --- a/test/__snapshots__/LGraph.test.ts.snap +++ b/test/__snapshots__/LGraph.test.ts.snap @@ -247,7 +247,6 @@ LGraph { "fixedtime_lapse": 0.01, "globaltime": 0, "id": "b4e984f1-b421-4d24-b8b4-ff895793af13", - "inputs": {}, "iteration": 0, "last_update_time": 0, "links": Map {}, @@ -255,7 +254,6 @@ LGraph { "nodes_actioning": [], "nodes_executedAction": [], "nodes_executing": [], - "outputs": {}, "revision": 0, "runningtime": 0, "starttime": 0, diff --git a/test/__snapshots__/LGraph_constructor.test.ts.snap b/test/__snapshots__/LGraph_constructor.test.ts.snap index d71d797f6..09cdf4524 100644 --- a/test/__snapshots__/LGraph_constructor.test.ts.snap +++ b/test/__snapshots__/LGraph_constructor.test.ts.snap @@ -241,7 +241,6 @@ LGraph { "fixedtime_lapse": 0.01, "globaltime": 0, "id": "ca9da7d8-fddd-4707-ad32-67be9be13140", - "inputs": {}, "iteration": 0, "last_update_time": 0, "links": Map {}, @@ -249,7 +248,6 @@ LGraph { "nodes_actioning": [], "nodes_executedAction": [], "nodes_executing": [], - "outputs": {}, "revision": 0, "runningtime": 0, "starttime": 0, @@ -288,7 +286,6 @@ LGraph { "fixedtime_lapse": 0.01, "globaltime": 0, "id": "d175890f-716a-4ece-ba33-1d17a513b7be", - "inputs": {}, "iteration": 0, "last_update_time": 0, "links": Map {}, @@ -296,7 +293,6 @@ LGraph { "nodes_actioning": [], "nodes_executedAction": [], "nodes_executing": [], - "outputs": {}, "revision": 0, "runningtime": 0, "starttime": 0,