@eventcatalog/visualiser 5.1.0 → 5.1.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.
package/dist/index.mjs CHANGED
@@ -80,7 +80,7 @@ import {
80
80
  nodeConfigs,
81
81
  normalizeOwners,
82
82
  pauseEdgeAnimations
83
- } from "./chunk-ZHXUMAPK.mjs";
83
+ } from "./chunk-RHE5IMXC.mjs";
84
84
  import {
85
85
  ACTOR,
86
86
  AGENT,
package/dist/model.mjs CHANGED
@@ -22,7 +22,7 @@ import {
22
22
  Tour,
23
23
  validateModel,
24
24
  validateTour
25
- } from "./chunk-R3QHQ7LF.mjs";
25
+ } from "./chunk-JB2NMDKX.mjs";
26
26
  export {
27
27
  CONTAINER_TYPES,
28
28
  CommentAuthor,
package/dist/studio.mjs CHANGED
@@ -16,7 +16,7 @@ import {
16
16
  getExportImageDimensions,
17
17
  injectExportStyles,
18
18
  memoNode
19
- } from "./chunk-ZHXUMAPK.mjs";
19
+ } from "./chunk-RHE5IMXC.mjs";
20
20
  import "./chunk-STJQWGKW.mjs";
21
21
  import {
22
22
  getMessagesLabel,
@@ -28,7 +28,7 @@ import {
28
28
  MESSAGE_TYPES,
29
29
  Model,
30
30
  validateModel
31
- } from "./chunk-R3QHQ7LF.mjs";
31
+ } from "./chunk-JB2NMDKX.mjs";
32
32
 
33
33
  // src/studio/canvas-doc.ts
34
34
  import * as Y from "yjs";
@@ -2426,7 +2426,15 @@ async function modelToCanvas(model, seed) {
2426
2426
  })
2427
2427
  );
2428
2428
  const edges = edgesFor(model, byId2);
2429
- const unplaced = nodes.filter((node) => !saved[node.id]).map((node) => node.id);
2429
+ const lookup = new Map(nodes.map((node) => [node.id, node]));
2430
+ const misplaced = (node) => {
2431
+ const parent = node.parentId ? lookup.get(node.parentId) : void 0;
2432
+ if (!parent || !saved[node.id]) return false;
2433
+ const { x, y } = node.position;
2434
+ const slack = 20;
2435
+ return x < -slack || y < -slack || parent.width !== void 0 && x > parent.width || parent.height !== void 0 && y > parent.height;
2436
+ };
2437
+ const unplaced = nodes.filter((node) => !saved[node.id] || misplaced(node)).map((node) => node.id);
2430
2438
  const seeded = unplaced.length === nodes.length && seed ? placesFromSeed(seed.nodes, nodes) : void 0;
2431
2439
  if (seeded) {
2432
2440
  nodes = nodes.map(
@@ -2448,9 +2456,28 @@ async function modelToCanvas(model, seed) {
2448
2456
  target
2449
2457
  }));
2450
2458
  const places = placeNodes(nodes, unplaced, links);
2451
- nodes = nodes.map(
2452
- (node) => places.has(node.id) ? { ...node, position: places.get(node.id) } : node
2453
- );
2459
+ const byNodeId = new Map(nodes.map((node) => [node.id, node]));
2460
+ const canvasAt = (node) => {
2461
+ const placed = places.get(node.id);
2462
+ if (placed) return placed;
2463
+ const parent = node.parentId ? byNodeId.get(node.parentId) : void 0;
2464
+ if (!parent) return node.position;
2465
+ const parentAt = canvasAt(parent);
2466
+ return {
2467
+ x: parentAt.x + node.position.x,
2468
+ y: parentAt.y + node.position.y
2469
+ };
2470
+ };
2471
+ nodes = nodes.map((node) => {
2472
+ const placed = places.get(node.id);
2473
+ if (!placed) return node;
2474
+ const parent = node.parentId ? byNodeId.get(node.parentId) : void 0;
2475
+ const parentAt = parent ? canvasAt(parent) : { x: 0, y: 0 };
2476
+ return {
2477
+ ...node,
2478
+ position: { x: placed.x - parentAt.x, y: placed.y - parentAt.y }
2479
+ };
2480
+ });
2454
2481
  }
2455
2482
  return {
2456
2483
  nodes: [...nodes, ...notesToNodes(model.notes ?? [], nodes)],