@flowdrop/flowdrop 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,6 +13,7 @@
13
13
  * CSS positioning logic and stays automatically accurate.
14
14
  */
15
15
  import { SvelteMap } from "svelte/reactivity";
16
+ import { untrack } from "svelte";
16
17
  import { ProximityConnectHelper } from "../helpers/proximityConnect.js";
17
18
  /** Reactive state holding all port absolute coordinates, keyed by handleId */
18
19
  let coordinates = $state(new SvelteMap());
@@ -125,11 +126,21 @@ export function updateNodePortCoordinates(node, getInternalNode) {
125
126
  const internalNode = getInternalNode(node.id);
126
127
  if (!internalNode)
127
128
  return;
128
- // Remove old entries for this node
129
- for (const [key, coord] of coordinates) {
130
- if (coord.nodeId === node.id) {
131
- coordinates.delete(key);
129
+ // Remove old entries for this node.
130
+ // untrack prevents this read from creating a reactive dependency on `coordinates`
131
+ // inside any $effect that calls this function — otherwise the effect would re-run
132
+ // every time we mutate `coordinates`, creating an infinite reactive loop during drag.
133
+ const keysToDelete = untrack(() => {
134
+ const keys = [];
135
+ for (const [key, coord] of coordinates) {
136
+ if (coord.nodeId === node.id) {
137
+ keys.push(key);
138
+ }
132
139
  }
140
+ return keys;
141
+ });
142
+ for (const key of keysToDelete) {
143
+ coordinates.delete(key);
133
144
  }
134
145
  // Add new entries
135
146
  const coords = computeNodePortCoordinates(node, internalNode);
@@ -143,10 +154,17 @@ export function updateNodePortCoordinates(node, getInternalNode) {
143
154
  * @param nodeId - ID of the node to remove
144
155
  */
145
156
  export function removeNodePortCoordinates(nodeId) {
146
- for (const [key, coord] of coordinates) {
147
- if (coord.nodeId === nodeId) {
148
- coordinates.delete(key);
157
+ const keysToDelete = untrack(() => {
158
+ const keys = [];
159
+ for (const [key, coord] of coordinates) {
160
+ if (coord.nodeId === nodeId) {
161
+ keys.push(key);
162
+ }
149
163
  }
164
+ return keys;
165
+ });
166
+ for (const key of keysToDelete) {
167
+ coordinates.delete(key);
150
168
  }
151
169
  }
152
170
  /**
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "A drop-in visual workflow editor for any web application. You own the backend. You own the data. You own the orchestration.",
4
4
  "license": "MIT",
5
5
  "private": false,
6
- "version": "1.2.1",
6
+ "version": "1.2.2",
7
7
  "author": "Shibin Das (D34dMan)",
8
8
  "bugs": {
9
9
  "url": "https://github.com/flowdrop-io/flowdrop/issues"