@statelyai/flow-dom 3.4.5 → 3.4.6

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.
Files changed (2) hide show
  1. package/dist/esm/index.js +13 -4
  2. package/package.json +2 -2
package/dist/esm/index.js CHANGED
@@ -414,13 +414,22 @@ function createEntityGeometryObserver(store, options = {}) {
414
414
  });
415
415
  },
416
416
  observeEdge(element, target) {
417
+ const inferredSegments = /* @__PURE__ */ new WeakMap();
417
418
  return observe(target.id, () => {
418
419
  const pathData = target.getPathData();
419
420
  if (!pathData) return;
420
- element.querySelectorAll("[data-flow-edge-segment]").forEach((path) => {
421
- const index = Number(path.dataset.flowEdgeSegment);
422
- const segment = pathData.segments[index];
423
- if (segment) path.setAttribute("d", pathToSVG(segment));
421
+ const svgSegments = pathData.segments.map(pathToSVG);
422
+ element.querySelectorAll("path").forEach((path) => {
423
+ const explicitIndex = path.dataset.flowEdgeSegment;
424
+ let index = explicitIndex === void 0 ? inferredSegments.get(path) : Number(explicitIndex);
425
+ if (index === void 0) {
426
+ const matchedIndex = svgSegments.indexOf(path.getAttribute("d") ?? "");
427
+ if (matchedIndex < 0) return;
428
+ index = matchedIndex;
429
+ inferredSegments.set(path, index);
430
+ }
431
+ const segment = svgSegments[index];
432
+ if (segment !== void 0) path.setAttribute("d", segment);
424
433
  });
425
434
  const first = pathData.segments[0]?.points[0];
426
435
  const last = pathData.segments.at(-1)?.points.at(-1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statelyai/flow-dom",
3
- "version": "3.4.5",
3
+ "version": "3.4.6",
4
4
  "description": "DOM-specific helpers for @statelyai/flow with core re-exports.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "license": "MIT",
29
29
  "dependencies": {
30
- "@statelyai/flow": "0.10.0"
30
+ "@statelyai/flow": "0.11.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@vitest/coverage-v8": "^4.1.0",