From c906192ab1b8941ce4ef72e14375797f30256952 Mon Sep 17 00:00:00 2001 From: moklick Date: Tue, 3 Sep 2024 17:22:33 +0200 Subject: [PATCH] chore(getNodesBounds): only show warning in dev --- packages/react/src/types/instance.ts | 2 +- packages/system/src/utils/graph.ts | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/react/src/types/instance.ts b/packages/react/src/types/instance.ts index eac29b91..fdece4dd 100644 --- a/packages/react/src/types/instance.ts +++ b/packages/react/src/types/instance.ts @@ -180,7 +180,7 @@ export type GeneralHelpers Rect; + getNodesBounds: (nodes: (NodeType | InternalNode | string)[]) => Rect; /** * Gets all connections for a given handle belonging to a specific node. * diff --git a/packages/system/src/utils/graph.ts b/packages/system/src/utils/graph.ts index be391219..7efde2e3 100644 --- a/packages/system/src/utils/graph.ts +++ b/packages/system/src/utils/graph.ts @@ -132,9 +132,11 @@ export type GetNodesBoundsParams = { * @returns Bounding box enclosing all nodes */ export const getNodesBounds = (nodes: NodeBase[], params: GetNodesBoundsParams = { nodeOrigin: [0, 0] }): Rect => { - console.warn( - 'This function yields erronous results for subflows. Use getNodesBounds from useReactFlow/useSvelteFlow hook instead.' - ); + if (process.env.NODE_ENV === 'development') { + console.warn( + '[DEPRECATED] `getNodesBounds` is deprecated because it yields erronous results for subflows. Use `getNodesBounds` from useReactFlow/useSvelteFlow hook instead.' + ); + } if (nodes.length === 0) { return { x: 0, y: 0, width: 0, height: 0 };