@markdy/renderer-dom 1.3.0 → 1.3.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.
- package/dist/index.js +68 -19
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -887,8 +887,8 @@ function computeEdgeLabelColor(edgeColor, isDark) {
|
|
|
887
887
|
}
|
|
888
888
|
function createEdgeRuntime(svg, from, to, kind, label, theme, sceneId, routeObstacles, labelObstacles, bounds, lane, existingPaths = []) {
|
|
889
889
|
ensureDefs(svg, theme, sceneId);
|
|
890
|
-
const color = theme.edges[kind];
|
|
891
|
-
const style = EDGE_STYLES[kind];
|
|
890
|
+
const color = theme.edges[kind] ?? theme.edges.request ?? theme.accent;
|
|
891
|
+
const style = EDGE_STYLES[kind] ?? EDGE_STYLES.request;
|
|
892
892
|
const isSelfLoop = from.id === to.id;
|
|
893
893
|
const points = isSelfLoop ? dedupePoints(selfLoopPath(from, bounds)) : dedupePoints(routeEdgePoints(from, to, routeObstacles, bounds, lane));
|
|
894
894
|
const d = toPathD(points, 14, existingPaths);
|
|
@@ -1246,7 +1246,7 @@ function buildCueAnimations(cues, nodeEls, nodes, theme, scene, titleEl, bounds,
|
|
|
1246
1246
|
anims.push(
|
|
1247
1247
|
el.animate(
|
|
1248
1248
|
[{ opacity: 0, transform: "translateY(10px) scale(0.98)" }, { opacity: 1, transform: "translateY(0) scale(1)" }],
|
|
1249
|
-
{ duration: durMs, delay, fill: "
|
|
1249
|
+
{ duration: durMs, delay, fill: "both", easing: "cubic-bezier(0.16, 1, 0.3, 1)" }
|
|
1250
1250
|
)
|
|
1251
1251
|
);
|
|
1252
1252
|
} else {
|
|
@@ -1376,18 +1376,29 @@ function buildCueAnimations(cues, nodeEls, nodes, theme, scene, titleEl, bounds,
|
|
|
1376
1376
|
if (edgeId) edgeRuntimes.set(edgeId, runtime);
|
|
1377
1377
|
}
|
|
1378
1378
|
anims.push(...animateEdgeReveal(runtime, startMs, durMs));
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1379
|
+
if (!shownNodeSet.has(seg.from)) {
|
|
1380
|
+
shownNodeSet.add(seg.from);
|
|
1381
|
+
const fromEl = nodeEls.get(seg.from);
|
|
1382
|
+
if (fromEl) {
|
|
1383
|
+
anims.push(
|
|
1384
|
+
fromEl.animate(
|
|
1385
|
+
[{ opacity: 0, transform: "translateY(8px) scale(0.98)" }, { opacity: 1, transform: "translateY(0) scale(1)" }],
|
|
1386
|
+
{ duration: 320, delay: startMs, fill: "both", easing: "cubic-bezier(0.16, 1, 0.3, 1)" }
|
|
1387
|
+
)
|
|
1388
|
+
);
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
if (!shownNodeSet.has(seg.to)) {
|
|
1392
|
+
shownNodeSet.add(seg.to);
|
|
1393
|
+
const toEl2 = nodeEls.get(seg.to);
|
|
1394
|
+
if (toEl2) {
|
|
1395
|
+
const arrivalDelay = startMs + Math.min(240, durMs * 0.65);
|
|
1396
|
+
anims.push(
|
|
1397
|
+
toEl2.animate(
|
|
1398
|
+
[{ opacity: 0, transform: "translateY(8px) scale(0.98)" }, { opacity: 1, transform: "translateY(0) scale(1)" }],
|
|
1399
|
+
{ duration: 300, delay: arrivalDelay, fill: "both", easing: "cubic-bezier(0.16, 1, 0.3, 1)" }
|
|
1400
|
+
)
|
|
1401
|
+
);
|
|
1391
1402
|
}
|
|
1392
1403
|
}
|
|
1393
1404
|
const toEl = nodeEls.get(seg.to);
|
|
@@ -1408,7 +1419,7 @@ function buildCueAnimations(cues, nodeEls, nodes, theme, scene, titleEl, bounds,
|
|
|
1408
1419
|
for (const a of anims) a.pause();
|
|
1409
1420
|
return anims;
|
|
1410
1421
|
}
|
|
1411
|
-
function buildStructuralEdgeAnimations(edges, nodes, theme, scene, bounds, edgeRuntimes = /* @__PURE__ */ new Map(), sceneId = createEdgeSceneId(), diagramType = "architecture") {
|
|
1422
|
+
function buildStructuralEdgeAnimations(edges, nodes, theme, scene, bounds, edgeRuntimes = /* @__PURE__ */ new Map(), sceneId = createEdgeSceneId(), diagramType = "architecture", cues = []) {
|
|
1412
1423
|
const structural = edges.filter(
|
|
1413
1424
|
(e) => e.structural && diagramType !== "sequence" && !(diagramType === "tree" && !e.label)
|
|
1414
1425
|
);
|
|
@@ -1420,6 +1431,30 @@ function buildStructuralEdgeAnimations(edges, nodes, theme, scene, bounds, edgeR
|
|
|
1420
1431
|
const placedPaths = [];
|
|
1421
1432
|
const laneByPair = /* @__PURE__ */ new Map();
|
|
1422
1433
|
const svg = ensureEdgeLayer(scene);
|
|
1434
|
+
const anims = [];
|
|
1435
|
+
const nodeRevealTime = /* @__PURE__ */ new Map();
|
|
1436
|
+
for (const cue of cues) {
|
|
1437
|
+
const cueStartMs = cue.start * 1e3;
|
|
1438
|
+
const durMs = cue.duration * 1e3;
|
|
1439
|
+
if (cue.kind === "show") {
|
|
1440
|
+
cue.targets.forEach((id, idx) => {
|
|
1441
|
+
const stagger = typeof cue.params?.stagger === "number" ? cue.params.stagger * 1e3 * idx : 0;
|
|
1442
|
+
const reveal = cueStartMs + stagger;
|
|
1443
|
+
if (!nodeRevealTime.has(id) || reveal < nodeRevealTime.get(id)) {
|
|
1444
|
+
nodeRevealTime.set(id, reveal);
|
|
1445
|
+
}
|
|
1446
|
+
});
|
|
1447
|
+
} else if (cue.kind === "flow" && cue.segments?.[0] && diagramType !== "sequence") {
|
|
1448
|
+
const seg = cue.segments[0];
|
|
1449
|
+
if (!nodeRevealTime.has(seg.from) || cueStartMs < nodeRevealTime.get(seg.from)) {
|
|
1450
|
+
nodeRevealTime.set(seg.from, cueStartMs);
|
|
1451
|
+
}
|
|
1452
|
+
const arrival = cueStartMs + Math.min(240, durMs * 0.65);
|
|
1453
|
+
if (!nodeRevealTime.has(seg.to) || arrival < nodeRevealTime.get(seg.to)) {
|
|
1454
|
+
nodeRevealTime.set(seg.to, arrival);
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1423
1458
|
for (const edge of structural) {
|
|
1424
1459
|
const from = nodeById.get(edge.from);
|
|
1425
1460
|
const to = nodeById.get(edge.to);
|
|
@@ -1443,10 +1478,23 @@ function buildStructuralEdgeAnimations(edges, nodes, theme, scene, bounds, edgeR
|
|
|
1443
1478
|
);
|
|
1444
1479
|
placedPaths.push(runtime.points);
|
|
1445
1480
|
if (runtime.labelRect) placedLabels.push(runtime.labelRect);
|
|
1446
|
-
setEdgeVisible(runtime, true);
|
|
1447
1481
|
edgeRuntimes.set(edge.id, runtime);
|
|
1482
|
+
const hasCues = cues.length > 0;
|
|
1483
|
+
const tFrom = nodeRevealTime.get(edge.from) ?? 0;
|
|
1484
|
+
const tTo = nodeRevealTime.get(edge.to) ?? 0;
|
|
1485
|
+
const revealDelay = Math.max(tFrom, tTo);
|
|
1486
|
+
if (hasCues) {
|
|
1487
|
+
anims.push(
|
|
1488
|
+
runtime.group.animate(
|
|
1489
|
+
[{ opacity: 0 }, { opacity: 1 }],
|
|
1490
|
+
{ duration: 240, delay: revealDelay, fill: "both", easing: "cubic-bezier(0.16, 1, 0.3, 1)" }
|
|
1491
|
+
)
|
|
1492
|
+
);
|
|
1493
|
+
} else {
|
|
1494
|
+
setEdgeVisible(runtime, true);
|
|
1495
|
+
}
|
|
1448
1496
|
}
|
|
1449
|
-
return
|
|
1497
|
+
return anims;
|
|
1450
1498
|
}
|
|
1451
1499
|
|
|
1452
1500
|
// src/annotations.ts
|
|
@@ -6001,7 +6049,8 @@ function createDiagram(opts) {
|
|
|
6001
6049
|
{ width: plan.meta.width, height: plan.meta.height },
|
|
6002
6050
|
edgeRuntimes,
|
|
6003
6051
|
edgeSceneId,
|
|
6004
|
-
plan.diagramType
|
|
6052
|
+
plan.diagramType,
|
|
6053
|
+
plan.cues
|
|
6005
6054
|
),
|
|
6006
6055
|
...buildCueAnimations(plan.cues, nodeEls, plan.nodes, plan.theme, cameraLayer, titleEl, {
|
|
6007
6056
|
width: plan.meta.width,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markdy/renderer-dom",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Browser renderer for diagram-native animated MarkdyScript architecture diagrams, built on the Web Animations API.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"html2canvas": "^1.4.1",
|
|
49
|
-
"@markdy/core": "1.3.
|
|
49
|
+
"@markdy/core": "1.3.1"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"jsdom": "^29.1.1",
|
|
53
53
|
"tsup": "^8.5.1",
|
|
54
54
|
"typescript": "^5.9.3",
|
|
55
55
|
"vitest": "^4.1.7",
|
|
56
|
-
"@markdy/stdlib-systems": "1.3.
|
|
56
|
+
"@markdy/stdlib-systems": "1.3.1"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "tsup",
|