@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/{chunk-R3QHQ7LF.mjs → chunk-JB2NMDKX.mjs} +2 -2
- package/dist/chunk-JB2NMDKX.mjs.map +1 -0
- package/dist/{chunk-ZHXUMAPK.mjs → chunk-RHE5IMXC.mjs} +9 -2
- package/dist/chunk-RHE5IMXC.mjs.map +1 -0
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/model.mjs +1 -1
- package/dist/studio.mjs +33 -6
- package/dist/studio.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-R3QHQ7LF.mjs.map +0 -1
- package/dist/chunk-ZHXUMAPK.mjs.map +0 -1
package/dist/index.mjs
CHANGED
package/dist/model.mjs
CHANGED
package/dist/studio.mjs
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
getExportImageDimensions,
|
|
17
17
|
injectExportStyles,
|
|
18
18
|
memoNode
|
|
19
|
-
} from "./chunk-
|
|
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-
|
|
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
|
|
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
|
-
|
|
2452
|
-
|
|
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)],
|