diff --git a/src/lib/litegraph/src/LGraph.ts b/src/lib/litegraph/src/LGraph.ts index b4390736b3..2cc46f9273 100644 --- a/src/lib/litegraph/src/LGraph.ts +++ b/src/lib/litegraph/src/LGraph.ts @@ -1,3 +1,5 @@ +import { toString } from 'lodash' + import { SUBGRAPH_INPUT_ID, SUBGRAPH_OUTPUT_ID @@ -34,7 +36,6 @@ import { alignToContainer, createBounds } from './measure' -import { stringOrEmpty } from './strings' import { SubgraphInput } from './subgraph/SubgraphInput' import { SubgraphInputNode } from './subgraph/SubgraphInputNode' import { SubgraphOutput } from './subgraph/SubgraphOutput' @@ -2027,7 +2028,7 @@ export class LGraph if (url instanceof Blob || url instanceof File) { const reader = new FileReader() reader.addEventListener('load', (event) => { - const result = stringOrEmpty(event.target?.result) + const result = toString(event.target?.result) const data = JSON.parse(result) this.configure(data) callback?.() diff --git a/src/lib/litegraph/src/LGraphCanvas.ts b/src/lib/litegraph/src/LGraphCanvas.ts index 4a4b76243c..14aac3f243 100644 --- a/src/lib/litegraph/src/LGraphCanvas.ts +++ b/src/lib/litegraph/src/LGraphCanvas.ts @@ -1,3 +1,5 @@ +import { toString } from 'lodash' + import { LinkConnector } from '@/lib/litegraph/src/canvas/LinkConnector' import { CanvasPointer } from './CanvasPointer' @@ -55,7 +57,6 @@ import { snapPoint } from './measure' import { NodeInputSlot } from './node/NodeInputSlot' -import { stringOrEmpty } from './strings' import { Subgraph } from './subgraph/Subgraph' import { SubgraphIONodeBase } from './subgraph/SubgraphIONodeBase' import { SubgraphInputNode } from './subgraph/SubgraphInputNode' @@ -1244,7 +1245,7 @@ export class LGraphCanvas value = LGraphCanvas.getPropertyPrintableValue(value, info.values) // value could contain invalid html characters, clean that - value = LGraphCanvas.decodeHTML(stringOrEmpty(value)) + value = LGraphCanvas.decodeHTML(toString(value)) entries.push({ content: `${info.label || i}` + @@ -6065,7 +6066,7 @@ export class LGraphCanvas } ctx.fillStyle = '#FFF' ctx.fillText( - stringOrEmpty(node.order), + toString(node.order), node.pos[0] + LiteGraph.NODE_TITLE_HEIGHT * -0.5, node.pos[1] - 6 ) diff --git a/src/lib/litegraph/src/strings.ts b/src/lib/litegraph/src/strings.ts index d643cfb21d..78106e8f85 100644 --- a/src/lib/litegraph/src/strings.ts +++ b/src/lib/litegraph/src/strings.ts @@ -1,23 +1,5 @@ import type { ISlotType } from './litegraph' -/** - * Uses the standard String() function to coerce to string, unless the value is null or undefined - then null. - * @param value The value to convert - * @returns String(value) or null - */ -export function stringOrNull(value: unknown): string | null { - return value == null ? null : String(value) -} - -/** - * Uses the standard String() function to coerce to string, unless the value is null or undefined - then an empty string - * @param value The value to convert - * @returns String(value) or "" - */ -export function stringOrEmpty(value: unknown): string { - return value == null ? '' : String(value) -} - export function parseSlotTypes(type: ISlotType): string[] { return type == '' || type == '0' ? ['*']