@cnvx/nodal 0.5.0 → 0.5.1

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.
@@ -2,6 +2,22 @@ import { mount } from "svelte";
2
2
  import { SvelteMap } from "svelte/reactivity";
3
3
  import { writable } from "svelte/store";
4
4
  import Surface from "./Surface.svelte";
5
+ let elementIdCounter = 0;
6
+ function getElementId(el) {
7
+ if (el.id)
8
+ return `#${el.id}`;
9
+ if (!el.dataset.nodalUid) {
10
+ el.dataset.nodalUid = `nodal-${elementIdCounter++}`;
11
+ }
12
+ return `[data-nodal-uid="${el.dataset.nodalUid}"]`;
13
+ }
14
+ function getEdgeEndpointKey(endpoint) {
15
+ if (typeof endpoint === "string")
16
+ return endpoint;
17
+ if (endpoint instanceof HTMLElement)
18
+ return getElementId(endpoint);
19
+ return endpoint.map(e => typeof e === "string" ? e : getElementId(e)).join(",");
20
+ }
5
21
  function drawCall(surface) {
6
22
  // console.debug("Drawing nodal surface edges...");
7
23
  const connections = surface.querySelectorAll("[data-nodal-connected='true']");
@@ -28,7 +44,9 @@ function drawCall(surface) {
28
44
  ...edge,
29
45
  };
30
46
  }
31
- surface._nodalSurface.internals.edges.set(`${edgeDef.source}->${edgeDef.target}`, edgeDef);
47
+ const sourceKey = getEdgeEndpointKey(edgeDef.source);
48
+ const targetKey = getEdgeEndpointKey(edgeDef.target);
49
+ surface._nodalSurface.internals.edges.set(`${sourceKey}->${targetKey}`, edgeDef);
32
50
  });
33
51
  });
34
52
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@cnvx/nodal",
3
3
  "private": false,
4
4
  "license": "MIT",
5
- "version": "0.5.0",
5
+ "version": "0.5.1",
6
6
  "scripts": {
7
7
  "dev": "vite dev",
8
8
  "dev-lib": "svelte-package -w",