@metronforge/concept-map 0.1.1 → 0.2.0
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/README.md +124 -93
- package/css/concept-map.css +31 -21
- package/dist/dom/badgeDom.d.ts +3 -0
- package/dist/dom/badgeDom.d.ts.map +1 -0
- package/dist/dom/badgeDom.js +23 -0
- package/dist/dom/badgeDom.js.map +1 -0
- package/dist/dom/geometry.d.ts.map +1 -1
- package/dist/dom/geometry.js +12 -2
- package/dist/dom/geometry.js.map +1 -1
- package/dist/dom/index.d.ts +6 -0
- package/dist/dom/index.d.ts.map +1 -0
- package/dist/dom/index.js +3 -0
- package/dist/dom/index.js.map +1 -0
- package/dist/dom/measureLabel.d.ts +4 -0
- package/dist/dom/measureLabel.d.ts.map +1 -0
- package/dist/dom/measureLabel.js +29 -0
- package/dist/dom/measureLabel.js.map +1 -0
- package/dist/dom/mount.d.ts +7 -0
- package/dist/dom/mount.d.ts.map +1 -0
- package/dist/dom/mount.js +37 -0
- package/dist/dom/mount.js.map +1 -0
- package/dist/dom/player.d.ts.map +1 -1
- package/dist/dom/player.js +3 -3
- package/dist/dom/player.js.map +1 -1
- package/dist/element/element.d.ts +26 -0
- package/dist/element/element.d.ts.map +1 -0
- package/dist/element/element.js +115 -0
- package/dist/element/element.js.map +1 -0
- package/dist/element/input.d.ts +7 -0
- package/dist/element/input.d.ts.map +1 -0
- package/dist/element/input.js +40 -0
- package/dist/element/input.js.map +1 -0
- package/dist/element/layout.d.ts +4 -0
- package/dist/element/layout.d.ts.map +1 -0
- package/dist/element/layout.js +14 -0
- package/dist/element/layout.js.map +1 -0
- package/dist/element.d.ts +9 -0
- package/dist/element.d.ts.map +1 -0
- package/dist/element.js +5 -0
- package/dist/element.js.map +1 -0
- package/dist/index.d.ts +4 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/layout/badges.d.ts +4 -0
- package/dist/layout/badges.d.ts.map +1 -0
- package/dist/layout/badges.js +45 -0
- package/dist/layout/badges.js.map +1 -0
- package/dist/layout/check.d.ts +5 -0
- package/dist/layout/check.d.ts.map +1 -0
- package/dist/layout/check.js +61 -0
- package/dist/layout/check.js.map +1 -0
- package/dist/layout/dagre.d.ts +4 -0
- package/dist/layout/dagre.d.ts.map +1 -0
- package/dist/layout/dagre.js +62 -0
- package/dist/layout/dagre.js.map +1 -0
- package/dist/layout/elk.d.ts +4 -0
- package/dist/layout/elk.d.ts.map +1 -0
- package/dist/layout/elk.js +98 -0
- package/dist/layout/elk.js.map +1 -0
- package/dist/layout/font-metrics.d.ts +3 -0
- package/dist/layout/font-metrics.d.ts.map +1 -0
- package/dist/layout/font-metrics.js +128 -0
- package/dist/layout/font-metrics.js.map +1 -0
- package/dist/layout/geometry.d.ts +7 -0
- package/dist/layout/geometry.d.ts.map +1 -0
- package/dist/layout/geometry.js +56 -0
- package/dist/layout/geometry.js.map +1 -0
- package/dist/layout/graph.d.ts +6 -0
- package/dist/layout/graph.d.ts.map +1 -0
- package/dist/layout/graph.js +57 -0
- package/dist/layout/graph.js.map +1 -0
- package/dist/layout/index.d.ts +8 -0
- package/dist/layout/index.d.ts.map +1 -0
- package/dist/layout/index.js +21 -0
- package/dist/layout/index.js.map +1 -0
- package/dist/layout/lanes.d.ts +8 -0
- package/dist/layout/lanes.d.ts.map +1 -0
- package/dist/layout/lanes.js +78 -0
- package/dist/layout/lanes.js.map +1 -0
- package/dist/layout/measure.d.ts +4 -0
- package/dist/layout/measure.d.ts.map +1 -0
- package/dist/layout/measure.js +24 -0
- package/dist/layout/measure.js.map +1 -0
- package/dist/layout/resolve.d.ts +4 -0
- package/dist/layout/resolve.d.ts.map +1 -0
- package/dist/layout/resolve.js +114 -0
- package/dist/layout/resolve.js.map +1 -0
- package/dist/layout/self-route.d.ts +6 -0
- package/dist/layout/self-route.d.ts.map +1 -0
- package/dist/layout/self-route.js +110 -0
- package/dist/layout/self-route.js.map +1 -0
- package/dist/layout/types.d.ts +53 -0
- package/dist/layout/types.d.ts.map +1 -0
- package/dist/layout/types.js +2 -0
- package/dist/layout/types.js.map +1 -0
- package/dist/model/badge-placement.d.ts +10 -0
- package/dist/model/badge-placement.d.ts.map +1 -0
- package/dist/model/badge-placement.js +27 -0
- package/dist/model/badge-placement.js.map +1 -0
- package/dist/model/frame.d.ts +1 -1
- package/dist/model/frame.js +1 -1
- package/dist/model/input.d.ts +20 -0
- package/dist/model/input.d.ts.map +1 -0
- package/dist/model/input.js +15 -0
- package/dist/model/input.js.map +1 -0
- package/dist/model/labels.d.ts +1 -0
- package/dist/model/labels.d.ts.map +1 -1
- package/dist/model/labels.js +2 -0
- package/dist/model/labels.js.map +1 -1
- package/dist/render/concepts.d.ts.map +1 -1
- package/dist/render/concepts.js +6 -5
- package/dist/render/concepts.js.map +1 -1
- package/dist/render/data.d.ts +3 -0
- package/dist/render/data.d.ts.map +1 -0
- package/dist/render/data.js +7 -0
- package/dist/render/data.js.map +1 -0
- package/dist/render/figure.d.ts +10 -0
- package/dist/render/figure.d.ts.map +1 -0
- package/dist/render/figure.js +22 -0
- package/dist/render/figure.js.map +1 -0
- package/dist/render/hydration.d.ts +3 -0
- package/dist/render/hydration.d.ts.map +1 -0
- package/dist/render/hydration.js +13 -0
- package/dist/render/hydration.js.map +1 -0
- package/dist/render/panel.d.ts.map +1 -1
- package/dist/render/panel.js +7 -6
- package/dist/render/panel.js.map +1 -1
- package/dist/render/svg.d.ts.map +1 -1
- package/dist/render/svg.js +5 -4
- package/dist/render/svg.js.map +1 -1
- package/dist/schema/content.d.ts +90 -0
- package/dist/schema/content.d.ts.map +1 -0
- package/dist/schema/content.js +60 -0
- package/dist/schema/content.js.map +1 -0
- package/dist/schema/layout.d.ts +10 -0
- package/dist/schema/layout.d.ts.map +1 -0
- package/dist/schema/layout.js +8 -0
- package/dist/schema/layout.js.map +1 -0
- package/dist/schema/level.d.ts +3 -0
- package/dist/schema/level.d.ts.map +1 -0
- package/dist/schema/level.js +7 -0
- package/dist/schema/level.js.map +1 -0
- package/dist/schema/primitives.d.ts +61 -0
- package/dist/schema/primitives.d.ts.map +1 -0
- package/dist/schema/primitives.js +46 -0
- package/dist/schema/primitives.js.map +1 -0
- package/dist/schema/references.d.ts +6 -0
- package/dist/schema/references.d.ts.map +1 -0
- package/dist/schema/references.js +81 -0
- package/dist/schema/references.js.map +1 -0
- package/dist/schema.d.ts +357 -192
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +51 -119
- package/dist/schema.js.map +1 -1
- package/package.json +53 -9
- package/resolved-map.schema.json +184 -212
- package/source-map.schema.json +606 -0
- package/src/dom/badgeDom.ts +32 -0
- package/src/dom/geometry.ts +24 -2
- package/src/dom/index.ts +5 -0
- package/src/dom/measureLabel.ts +28 -0
- package/src/dom/mount.ts +46 -0
- package/src/dom/player.ts +3 -3
- package/src/element/element.ts +128 -0
- package/src/element/input.ts +60 -0
- package/src/element/layout.ts +18 -0
- package/src/element.ts +11 -0
- package/src/index.ts +10 -5
- package/src/layout/FONT-LICENSE.txt +78 -0
- package/src/layout/badges.ts +71 -0
- package/src/layout/check.ts +81 -0
- package/src/layout/dagre.ts +81 -0
- package/src/layout/elk.ts +113 -0
- package/src/layout/font-metrics.ts +127 -0
- package/src/layout/geometry.ts +72 -0
- package/src/layout/graph.ts +88 -0
- package/src/layout/index.ts +29 -0
- package/src/layout/lanes.ts +114 -0
- package/src/layout/measure.ts +25 -0
- package/src/layout/resolve.ts +155 -0
- package/src/layout/self-route.ts +168 -0
- package/src/layout/types.ts +50 -0
- package/src/model/badge-placement.ts +43 -0
- package/src/model/frame.ts +2 -2
- package/src/model/input.ts +26 -0
- package/src/model/labels.ts +3 -0
- package/src/render/concepts.ts +7 -5
- package/src/render/data.ts +10 -0
- package/src/render/figure.ts +35 -0
- package/src/render/hydration.ts +11 -0
- package/src/render/panel.ts +7 -6
- package/src/render/svg.ts +5 -4
- package/src/schema/content.ts +91 -0
- package/src/schema/layout.ts +10 -0
- package/src/schema/level.ts +6 -0
- package/src/schema/primitives.ts +55 -0
- package/src/schema/references.ts +106 -0
- package/src/schema.ts +73 -134
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { ResolvedMapSchema } from "../schema.js";
|
|
2
|
+
import { bounds, midpoint } from "./geometry.js";
|
|
3
|
+
import { badgePositions } from "./badges.js";
|
|
4
|
+
import { measured } from "./graph.js";
|
|
5
|
+
function frameBoxes(map, result, measure) {
|
|
6
|
+
return Object.fromEntries(Object.entries(map.frames).map(([id, f]) => {
|
|
7
|
+
const b = bounds(f.showWith.map((n) => result.nodes[n]));
|
|
8
|
+
const label = measured(measure, f.label, {
|
|
9
|
+
fontSize: 10.5,
|
|
10
|
+
mono: true,
|
|
11
|
+
letterSpacing: 0.63,
|
|
12
|
+
});
|
|
13
|
+
return [
|
|
14
|
+
id,
|
|
15
|
+
[
|
|
16
|
+
b[0] - 12,
|
|
17
|
+
b[1] - 28,
|
|
18
|
+
Math.max(b[2] + 24, label.width + 24),
|
|
19
|
+
b[3] + 40,
|
|
20
|
+
],
|
|
21
|
+
];
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
function viewport(graph, result, frames, badges) {
|
|
25
|
+
const boxes = [
|
|
26
|
+
...Object.values(result.nodes),
|
|
27
|
+
...Object.values(result.lanes),
|
|
28
|
+
...Object.values(frames),
|
|
29
|
+
...Object.values(badges).map(([x, y]) => [x - 8, y - 8, 16, 16]),
|
|
30
|
+
];
|
|
31
|
+
for (const e of graph.edges) {
|
|
32
|
+
const r = result.edges[e.id];
|
|
33
|
+
boxes.push(...r.points.map(([x, y]) => [x, y, 0, 0]));
|
|
34
|
+
if (e.label) {
|
|
35
|
+
const p = r.label ?? midpoint(r.points);
|
|
36
|
+
boxes.push([
|
|
37
|
+
p[0] - e.label.width / 2,
|
|
38
|
+
p[1] - e.label.height / 2,
|
|
39
|
+
e.label.width,
|
|
40
|
+
e.label.height,
|
|
41
|
+
]);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return bounds(boxes);
|
|
45
|
+
}
|
|
46
|
+
function edgeGeometry(map, graph, result, move, badges) {
|
|
47
|
+
return Object.fromEntries(graph.edges.map((e) => {
|
|
48
|
+
const source = map.edges[e.id], r = result.edges[e.id];
|
|
49
|
+
const points = r.points.map(move), badge = move(badges[e.id]);
|
|
50
|
+
const label = move(r.label ?? midpoint(r.points));
|
|
51
|
+
return [
|
|
52
|
+
e.id,
|
|
53
|
+
{
|
|
54
|
+
...source,
|
|
55
|
+
path: points
|
|
56
|
+
.map(([x, y], i) => `${i ? "L" : "M"}${x},${y}`)
|
|
57
|
+
.join(" "),
|
|
58
|
+
badge,
|
|
59
|
+
...(e.label
|
|
60
|
+
? {
|
|
61
|
+
label: {
|
|
62
|
+
text: source.label,
|
|
63
|
+
at: [
|
|
64
|
+
label[0] - e.label.width / 2,
|
|
65
|
+
label[1] + e.label.height / 3,
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
}
|
|
69
|
+
: {}),
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
function resolvedScenarios(map, badge) {
|
|
75
|
+
return map.scenarios.map((s) => ({
|
|
76
|
+
...s,
|
|
77
|
+
...(s.repeatBadges
|
|
78
|
+
? {
|
|
79
|
+
repeatBadges: s.repeatBadges.map((r) => ({
|
|
80
|
+
...r,
|
|
81
|
+
at: badge(r.edge),
|
|
82
|
+
})),
|
|
83
|
+
}
|
|
84
|
+
: {}),
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
export function resolveGeometry(map, graph, result, measure) {
|
|
88
|
+
const frames = frameBoxes(map, result, measure), badges = badgePositions(graph, result), b = viewport(graph, result, frames, badges);
|
|
89
|
+
const move = ([x, y]) => [
|
|
90
|
+
x - b[0] + 16,
|
|
91
|
+
y - b[1] + 16,
|
|
92
|
+
];
|
|
93
|
+
const box = ([x, y, w, h]) => [...move([x, y]), w, h];
|
|
94
|
+
const edges = edgeGeometry(map, graph, result, move, badges);
|
|
95
|
+
return ResolvedMapSchema.parse({
|
|
96
|
+
...map,
|
|
97
|
+
viewBox: [b[2] + 32, b[3] + 32],
|
|
98
|
+
nodes: Object.fromEntries(Object.entries(map.nodes).map(([id, n]) => [
|
|
99
|
+
id,
|
|
100
|
+
{ ...n, box: box(result.nodes[id]) },
|
|
101
|
+
])),
|
|
102
|
+
lanes: Object.fromEntries(Object.entries(map.lanes).map(([id, l]) => {
|
|
103
|
+
const [x, y, w, h] = box(result.lanes[id]);
|
|
104
|
+
return [id, { ...l, x, y, w, h }];
|
|
105
|
+
})),
|
|
106
|
+
frames: Object.fromEntries(Object.entries(map.frames).map(([id, f]) => [
|
|
107
|
+
id,
|
|
108
|
+
{ ...f, box: box(frames[id]) },
|
|
109
|
+
])),
|
|
110
|
+
edges,
|
|
111
|
+
scenarios: resolvedScenarios(map, (id) => edges[id].badge),
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=resolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/layout/resolve.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAQjD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,SAAS,UAAU,CACjB,GAAc,EACd,MAAoB,EACpB,OAAsB;IAEtB,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE;QACzC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC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G,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE;YACxC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;YAC3C,OAAO,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACpC,CAAC,CAAC,CACH;QACD,MAAM,EAAE,MAAM,CAAC,WAAW,CACxB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;YAC1C,EAAE;YACF,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE;SAC/B,CAAC,CACH;QACD,KAAK;QACL,SAAS,EAAE,iBAAiB,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC;KAC3D,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { LayoutBox, LayoutPoint, LayoutGraph, LayoutResult, LayoutRoute, LabelSize } from "./types.js";
|
|
2
|
+
/** Compact side loops use final node positions, including relocated partitions. */
|
|
3
|
+
export declare function routeSelfEdges(graph: LayoutGraph, result: LayoutResult): LayoutResult;
|
|
4
|
+
/** Dagre 3 returns a folded path for self-edges; use its reserved label lane. */
|
|
5
|
+
export declare function reservedSelfRoute(box: LayoutBox, center: LayoutPoint, label: LabelSize | undefined, right: boolean): LayoutRoute;
|
|
6
|
+
//# sourceMappingURL=self-route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"self-route.d.ts","sourceRoot":"","sources":["../../src/layout/self-route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,WAAW,EACX,WAAW,EACX,YAAY,EACZ,WAAW,EACX,SAAS,EACV,MAAM,YAAY,CAAC;AAGpB,mFAAmF;AACnF,wBAAgB,cAAc,CAC5B,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,YAAY,GACnB,YAAY,CAuBd;AA6FD,iFAAiF;AACjF,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,SAAS,EACd,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,SAAS,GAAG,SAAS,EAC5B,KAAK,EAAE,OAAO,GACb,WAAW,CA+Bb"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { bounds } from "./geometry.js";
|
|
2
|
+
/** Compact side loops use final node positions, including relocated partitions. */
|
|
3
|
+
export function routeSelfEdges(graph, result) {
|
|
4
|
+
const reserved = [];
|
|
5
|
+
const edges = { ...result.edges };
|
|
6
|
+
for (const edge of graph.edges) {
|
|
7
|
+
if (edge.from !== edge.to)
|
|
8
|
+
continue;
|
|
9
|
+
const box = result.nodes[edge.from];
|
|
10
|
+
const neighbors = Object.entries(result.nodes)
|
|
11
|
+
.filter(([id]) => id !== edge.from)
|
|
12
|
+
.map(([, b]) => b)
|
|
13
|
+
.concat(reserved);
|
|
14
|
+
const candidates = [
|
|
15
|
+
...[1, -1].map((side) => selfRoute(box, edge.label, side)),
|
|
16
|
+
...[-1, 1].map((side) => verticalRoute(box, edge.label, side)),
|
|
17
|
+
];
|
|
18
|
+
const selected = candidates.find((route) => interference(route, edge.label, neighbors) === 0);
|
|
19
|
+
if (!selected)
|
|
20
|
+
return originalRoutes(graph, result);
|
|
21
|
+
edges[edge.id] = selected;
|
|
22
|
+
reserved.push(routeBounds(selected, edge.label));
|
|
23
|
+
}
|
|
24
|
+
result.edges = edges;
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
/** A crowded graph keeps its engine routing, rather than receiving known collisions. */
|
|
28
|
+
function originalRoutes(graph, result) {
|
|
29
|
+
for (const edge of graph.edges)
|
|
30
|
+
if (!result.edges[edge.id])
|
|
31
|
+
throw new Error(`Self-edge “${edge.id}”: no clear compact route and no original engine route`);
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
function selfRoute(box, label, side, reach = 24) {
|
|
35
|
+
const [x, y, w, h] = box;
|
|
36
|
+
const start = x + (side > 0 ? w : 0);
|
|
37
|
+
const outside = start + side * reach;
|
|
38
|
+
return {
|
|
39
|
+
points: [
|
|
40
|
+
[start, y + h / 4],
|
|
41
|
+
[outside, y + h / 4],
|
|
42
|
+
[outside, y + (3 * h) / 4],
|
|
43
|
+
[start, y + (3 * h) / 4],
|
|
44
|
+
],
|
|
45
|
+
...(label
|
|
46
|
+
? {
|
|
47
|
+
label: [outside + side * (12 + label.width / 2), y + h / 2],
|
|
48
|
+
}
|
|
49
|
+
: {}),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/** Swap the route axes while keeping measured label dimensions unrotated. */
|
|
53
|
+
function verticalRoute(box, label, side) {
|
|
54
|
+
const [x, y, w, h] = box;
|
|
55
|
+
const route = selfRoute([y, x, h, w], label ? { width: label.height, height: label.width } : undefined, side, Math.min(24, h));
|
|
56
|
+
return {
|
|
57
|
+
points: route.points.map(([px, py]) => [py, px]),
|
|
58
|
+
...(route.label
|
|
59
|
+
? { label: [route.label[1], route.label[0]] }
|
|
60
|
+
: {}),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function routeBounds(route, label) {
|
|
64
|
+
const boxes = route.points.map(([x, y]) => [x, y, 0, 0]);
|
|
65
|
+
if (route.label && label)
|
|
66
|
+
boxes.push([
|
|
67
|
+
route.label[0] - label.width / 2,
|
|
68
|
+
route.label[1] - label.height / 2,
|
|
69
|
+
label.width,
|
|
70
|
+
label.height,
|
|
71
|
+
]);
|
|
72
|
+
return bounds(boxes);
|
|
73
|
+
}
|
|
74
|
+
function interference(route, label, neighbors) {
|
|
75
|
+
const [x, y, w, h] = routeBounds(route, label);
|
|
76
|
+
return neighbors.reduce((area, [nx, ny, nw, nh]) => area +
|
|
77
|
+
Math.max(0, Math.min(x + w + 12, nx + nw) - Math.max(x - 12, nx)) *
|
|
78
|
+
Math.max(0, Math.min(y + h + 12, ny + nh) - Math.max(y - 12, ny)), 0);
|
|
79
|
+
}
|
|
80
|
+
/** Dagre 3 returns a folded path for self-edges; use its reserved label lane. */
|
|
81
|
+
export function reservedSelfRoute(box, center, label, right) {
|
|
82
|
+
const [x, y, w, h] = box;
|
|
83
|
+
if (right) {
|
|
84
|
+
const bottom = Math.max(y + h + 24, center[1] - (label?.height ?? 0) / 2 - 12);
|
|
85
|
+
return {
|
|
86
|
+
points: [
|
|
87
|
+
[x + w / 3, y + h],
|
|
88
|
+
[x + w / 3, bottom],
|
|
89
|
+
[x + (w * 2) / 3, bottom],
|
|
90
|
+
[x + (w * 2) / 3, y + h],
|
|
91
|
+
],
|
|
92
|
+
...(label
|
|
93
|
+
? { label: [center[0], bottom + 12 + label.height / 2] }
|
|
94
|
+
: {}),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
const side = Math.max(x + w + 24, center[0] - (label?.width ?? 0) / 2 - 12);
|
|
98
|
+
return {
|
|
99
|
+
points: [
|
|
100
|
+
[x + w, y + h / 3],
|
|
101
|
+
[side, y + h / 3],
|
|
102
|
+
[side, y + (h * 2) / 3],
|
|
103
|
+
[x + w, y + (h * 2) / 3],
|
|
104
|
+
],
|
|
105
|
+
...(label
|
|
106
|
+
? { label: [side + 12 + label.width / 2, center[1]] }
|
|
107
|
+
: {}),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=self-route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"self-route.js","sourceRoot":"","sources":["../../src/layout/self-route.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,MAAM,EAAE,MAAM,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AAG,CAAC,CAAC;YACjB,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;YACvB,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;SACzB;QACD,GAAG,CAAC,KAAK;YACP,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,GAAG,EAAE,GAAG,KAAK,CAAC,KAAK,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAgB,EAAE;YACpE,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** Coordinates in SVG user units, relative to the graph origin. */
|
|
2
|
+
export type LayoutPoint = [number, number];
|
|
3
|
+
export type LayoutBox = [number, number, number, number];
|
|
4
|
+
export interface LabelSize {
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
}
|
|
8
|
+
export interface LabelStyle {
|
|
9
|
+
fontSize: number;
|
|
10
|
+
mono: boolean;
|
|
11
|
+
letterSpacing?: number;
|
|
12
|
+
}
|
|
13
|
+
export type LabelMeasurer = (text: string, style: LabelStyle) => LabelSize;
|
|
14
|
+
export interface LayoutNode extends LabelSize {
|
|
15
|
+
id: string;
|
|
16
|
+
lane?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface LayoutEdge {
|
|
19
|
+
id: string;
|
|
20
|
+
from: string;
|
|
21
|
+
to: string;
|
|
22
|
+
label?: LabelSize & {
|
|
23
|
+
text?: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/** Lanes follow the layout direction. Unassigned nodes follow the last lane. */
|
|
27
|
+
export interface LayoutLane {
|
|
28
|
+
id: string;
|
|
29
|
+
label: LabelSize;
|
|
30
|
+
}
|
|
31
|
+
export interface LayoutGraph {
|
|
32
|
+
direction?: "down" | "right";
|
|
33
|
+
nodes: readonly LayoutNode[];
|
|
34
|
+
edges: readonly LayoutEdge[];
|
|
35
|
+
lanes: readonly LayoutLane[];
|
|
36
|
+
}
|
|
37
|
+
export interface LayoutRoute {
|
|
38
|
+
points: LayoutPoint[];
|
|
39
|
+
label?: LayoutPoint;
|
|
40
|
+
}
|
|
41
|
+
/** Every graph id must have exactly one geometry entry; label points are centres. */
|
|
42
|
+
export interface LayoutResult {
|
|
43
|
+
nodes: Record<string, LayoutBox>;
|
|
44
|
+
edges: Record<string, LayoutRoute>;
|
|
45
|
+
lanes: Record<string, LayoutBox>;
|
|
46
|
+
}
|
|
47
|
+
export interface LayoutEngine {
|
|
48
|
+
layout(graph: LayoutGraph): Promise<LayoutResult>;
|
|
49
|
+
}
|
|
50
|
+
export interface LayoutOptions {
|
|
51
|
+
measureLabel?: LabelMeasurer;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/layout/types.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,MAAM,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC3C,MAAM,MAAM,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AACzD,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AACD,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AACD,MAAM,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,KAAK,SAAS,CAAC;AAC3E,MAAM,WAAW,UAAW,SAAQ,SAAS;IAC3C,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AACD,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,SAAS,GAAG;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACvC;AACD,gFAAgF;AAChF,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,SAAS,CAAC;CAClB;AACD,MAAM,WAAW,WAAW;IAC1B,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7B,KAAK,EAAE,SAAS,UAAU,EAAE,CAAC;IAC7B,KAAK,EAAE,SAAS,UAAU,EAAE,CAAC;IAC7B,KAAK,EAAE,SAAS,UAAU,EAAE,CAAC;CAC9B;AACD,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB;AACD,qFAAqF;AACrF,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACjC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACnC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CAClC;AACD,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CACnD;AACD,MAAM,WAAW,aAAa;IAC5B,YAAY,CAAC,EAAE,aAAa,CAAC;CAC9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/layout/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Point } from "./path.js";
|
|
2
|
+
export interface BadgeObstacle {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
}
|
|
8
|
+
/** Keep intentional node/edge attachments unless actual label text overlaps. */
|
|
9
|
+
export declare function placeBadge(origin: Point, radius: number, labels: BadgeObstacle[], bounds: BadgeObstacle, obstacles?: BadgeObstacle[]): Point;
|
|
10
|
+
//# sourceMappingURL=badge-placement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"badge-placement.d.ts","sourceRoot":"","sources":["../../src/model/badge-placement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACvC,MAAM,WAAW,aAAa;IAC5B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAUD,gFAAgF;AAChF,wBAAgB,UAAU,CACxB,MAAM,EAAE,KAAK,EACb,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,aAAa,EAAE,EACvB,MAAM,EAAE,aAAa,EACrB,SAAS,GAAE,aAAa,EAAO,GAC9B,KAAK,CAmBP"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
function clearOf([x, y], radius, box) {
|
|
2
|
+
return (Math.hypot(Math.max(box.x - x, 0, x - box.x - box.width), Math.max(box.y - y, 0, y - box.y - box.height)) >=
|
|
3
|
+
radius + 3);
|
|
4
|
+
}
|
|
5
|
+
/** Keep intentional node/edge attachments unless actual label text overlaps. */
|
|
6
|
+
export function placeBadge(origin, radius, labels, bounds, obstacles = []) {
|
|
7
|
+
if (labels.every((box) => clearOf(origin, radius, box)))
|
|
8
|
+
return origin;
|
|
9
|
+
const clear = ([x, y]) => x - radius >= bounds.x &&
|
|
10
|
+
y - radius >= bounds.y &&
|
|
11
|
+
x + radius <= bounds.x + bounds.width &&
|
|
12
|
+
y + radius <= bounds.y + bounds.height &&
|
|
13
|
+
[...labels, ...obstacles].every((box) => clearOf([x, y], radius, box));
|
|
14
|
+
const limit = Math.hypot(bounds.width, bounds.height);
|
|
15
|
+
for (let distance = 4; distance <= limit; distance += 4)
|
|
16
|
+
for (let angle = 0; angle < 16; angle++) {
|
|
17
|
+
const radians = (angle * Math.PI) / 8;
|
|
18
|
+
const candidate = [
|
|
19
|
+
origin[0] + Math.cos(radians) * distance,
|
|
20
|
+
origin[1] + Math.sin(radians) * distance,
|
|
21
|
+
];
|
|
22
|
+
if (clear(candidate))
|
|
23
|
+
return candidate;
|
|
24
|
+
}
|
|
25
|
+
return origin;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=badge-placement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"badge-placement.js","sourceRoot":"","sources":["../../src/model/badge-placement.ts"],"names":[],"mappings":"AAOA,SAAS,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAQ,EAAE,MAAc,EAAE,GAAkB;IAChE,OAAO,CACL,IAAI,CAAC,KAAK,CACR,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,EAC7C,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAC/C;QACD,MAAM,GAAG,CAAC,CACX,CAAC;AACJ,CAAC;AACD,gFAAgF;AAChF,MAAM,UAAU,UAAU,CACxB,MAAa,EACb,MAAc,EACd,MAAuB,EACvB,MAAqB,EACrB,YAA6B,EAAE;IAE/B,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;QAAE,OAAO,MAAM,CA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|
@@ -89,7 +89,7 @@ export function derive(map, state) {
|
|
|
89
89
|
kind: "step",
|
|
90
90
|
count: `${s.display.counterLabel ? s.label + " · " : ""}Step ${state.step + 1} of ${steps.length}`,
|
|
91
91
|
title: t.title,
|
|
92
|
-
|
|
92
|
+
text: t.text,
|
|
93
93
|
log: [
|
|
94
94
|
...before.map((text) => ({ text, kind: "old" })),
|
|
95
95
|
...(t.log ?? []).map((text) => ({
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface MapInputs {
|
|
2
|
+
assigned?: unknown;
|
|
3
|
+
src?: string | null;
|
|
4
|
+
direct?: string;
|
|
5
|
+
inline?: unknown;
|
|
6
|
+
server?: string;
|
|
7
|
+
}
|
|
8
|
+
export type SelectedMapInput = {
|
|
9
|
+
kind: "value";
|
|
10
|
+
value: unknown;
|
|
11
|
+
} | {
|
|
12
|
+
kind: "url";
|
|
13
|
+
url: string;
|
|
14
|
+
} | {
|
|
15
|
+
kind: "json";
|
|
16
|
+
text: string;
|
|
17
|
+
};
|
|
18
|
+
/** Choose before parsing, so invalid preferred data never falls back. */
|
|
19
|
+
export declare function selectMapInput(inputs: MapInputs): SelectedMapInput | undefined;
|
|
20
|
+
//# sourceMappingURL=input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/model/input.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AACD,MAAM,MAAM,gBAAgB,GACxB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAC5B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnC,yEAAyE;AACzE,wBAAgB,cAAc,CAC5B,MAAM,EAAE,SAAS,GAChB,gBAAgB,GAAG,SAAS,CAU9B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Choose before parsing, so invalid preferred data never falls back. */
|
|
2
|
+
export function selectMapInput(inputs) {
|
|
3
|
+
if (inputs.assigned !== undefined)
|
|
4
|
+
return { kind: "value", value: inputs.assigned };
|
|
5
|
+
if (inputs.src !== undefined && inputs.src !== null)
|
|
6
|
+
return { kind: "url", url: inputs.src };
|
|
7
|
+
if (inputs.direct !== undefined)
|
|
8
|
+
return { kind: "json", text: inputs.direct };
|
|
9
|
+
if (inputs.inline !== undefined)
|
|
10
|
+
return { kind: "value", value: inputs.inline };
|
|
11
|
+
if (inputs.server !== undefined)
|
|
12
|
+
return { kind: "json", text: inputs.server };
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../src/model/input.ts"],"names":[],"mappings":"AAYA,yEAAyE;AACzE,MAAM,UAAU,cAAc,CAC5B,MAAiB;IAEjB,IAAI,MAAM,CAAC,QAAQ,KAAK,SAAS;QAC/B,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC;IACnD,IAAI,MAAM,CAAC,GAAG,KAAK,SAAS,IAAI,MAAM,CAAC,GAAG,KAAK,IAAI;QACjD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC;IAC1C,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS;QAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;IAC9E,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS;QAC7B,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;IACjD,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS;QAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;IAC9E,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/model/labels.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Point } from "./path.js";
|
|
2
|
+
export declare const naturalMapWidth: (viewBoxWidth: number, fontSize?: number) => number;
|
|
2
3
|
export declare const labelMinimum: (viewBoxWidth: number, renderedWidth: number) => number;
|
|
3
4
|
export declare function fitNodeLabels([, y, , h]: number[], main: {
|
|
4
5
|
y: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"labels.d.ts","sourceRoot":"","sources":["../../src/model/labels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"labels.d.ts","sourceRoot":"","sources":["../../src/model/labels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEvC,eAAO,MAAM,eAAe,GAAI,cAAc,MAAM,EAAE,iBAAa,WACjC,CAAC;AACnC,eAAO,MAAM,YAAY,GAAI,cAAc,MAAM,EAAE,eAAe,MAAM,WAChC,CAAC;AACzC,wBAAgB,aAAa,CAC3B,CAAC,EAAE,CAAC,EAAE,AAAD,EAAG,CAAC,CAAC,EAAE,MAAM,EAAE,EACpB,IAAI,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EACnC,GAAG,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE;;;EAenC;AACD,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EACb,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,GACf;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,GAAG,IAAI,CAQjD"}
|
package/dist/model/labels.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Layout measures edge labels at 10.5 units; scale the drawing to page text.
|
|
2
|
+
export const naturalMapWidth = (viewBoxWidth, fontSize = 16) => (viewBoxWidth * fontSize) / 10.5;
|
|
1
3
|
export const labelMinimum = (viewBoxWidth, renderedWidth) => (10.55 * viewBoxWidth) / renderedWidth;
|
|
2
4
|
export function fitNodeLabels([, y, , h], main, tag) {
|
|
3
5
|
const baseline = { main: y + 17, tag: y + 32 };
|
package/dist/model/labels.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"labels.js","sourceRoot":"","sources":["../../src/model/labels.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,YAAoB,EAAE,aAAqB,EAAE,EAAE,CAC1E,CAAC,KAAK,GAAG,YAAY,CAAC,GAAG,aAAa,CAAC;AACzC,MAAM,UAAU,aAAa,CAC3B,CAAC,EAAE,CAAC,EAAE,AAAD,EAAG,CAAC,CAAW,EACpB,IAAmC,EACnC,GAAkC;IAElC,MAAM,QAAQ,GAAG,EAAE,IAAI,EAAE,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC;IAC/C,IACE,IAAI,CAAC,CAAC,IAAI,CAAC;QACX,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,IAAI,G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AAI,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC;QAClC,GAAG,EAAE,QAAQ,CAAC,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;KACpD,CAAC;AACJ,CAAC;AACD,MAAM,UAAU,YAAY,CAC1B,IAAY,EACZ,CAAC,CAAC,EAAE,CAAC,CAAQ,EACb,YAAoB,EACpB,aAAqB,EACrB,QAAgB;IAEhB,IAAI,aAAa,IAAI,YAAY,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAC9E,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9B,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QACjC,IAAI,EAAE,IAAI,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAClD,CAAC;QACD,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ;KACnD,CAAC,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"concepts.d.ts","sourceRoot":"","sources":["../../src/render/concepts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,wBAAgB,cAAc,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"concepts.d.ts","sourceRoot":"","sources":["../../src/render/concepts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,wBAAgB,cAAc,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,CAiBvD;AACD,wBAAgB,YAAY,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,CAErD"}
|
package/dist/render/concepts.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { escapeHtml as esc } from "./inline.js";
|
|
1
|
+
import { escapeHtml as esc, renderInline } from "./inline.js";
|
|
2
2
|
export function renderConcepts(map) {
|
|
3
3
|
return `<div class="concepts">${map.concepts
|
|
4
|
-
.map((g) => `<section class="cgroup" style="--c:var(--
|
|
4
|
+
.map((g) => `<section class="cgroup" style="--c:var(--cmap-layer-${esc(g.layer)},var(--cmap-layer))"><h3><span class="dot" aria-hidden="true"></span>${esc(g.label)}</h3><ul>${g.items
|
|
5
5
|
.map((c) => {
|
|
6
|
-
const scenario = map.scenarios.find((s) => s.id ===
|
|
6
|
+
const scenario = map.scenarios.find((s) => s.id ===
|
|
7
|
+
(c.step.scenario ?? map.conceptScenario ?? map.scenarios[0].id));
|
|
7
8
|
const index = scenario.steps.findIndex((s) => s.id === c.step.step);
|
|
8
|
-
return `<li data-nodes="${esc(c.nodes.join(" "))}"><span class="term">${esc(map.definitions[c.definition].term)}</span><span class="def">${c.short}</span><span class="meta"
|
|
9
|
+
return `<li data-nodes="${esc(c.nodes.join(" "))}"><span class="term">${esc(map.definitions[c.definition].term)}</span><span class="def">${renderInline(c.short)}</span><span class="meta">${c.source ? `<a href="${esc(c.source.url)}" title="${esc(c.source.label)}">Source ↗</a>` : ""}<button type="button" data-step="${index}"${c.step.scenario ? ` data-concept-scenario="${esc(c.step.scenario)}"` : ""}>Step ${index + 1}</button></span></li>`;
|
|
9
10
|
})
|
|
10
11
|
.join("")}</ul></section>`)
|
|
11
12
|
.join("")}</div>`;
|
|
12
13
|
}
|
|
13
14
|
export function renderDeeper(map) {
|
|
14
|
-
return `<ul class="deeper">${map.deeper.map((d) => `<li><a href="${esc(d.href)}">${esc(d.title)}</a><span>${d.why}</span></li>`).join("")}</ul>`;
|
|
15
|
+
return `<ul class="deeper">${map.deeper.map((d) => `<li><a href="${esc(d.href)}">${esc(d.title)}</a><span>${renderInline(d.why)}</span></li>`).join("")}</ul>`;
|
|
15
16
|
}
|
|
16
17
|
//# sourceMappingURL=concepts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"concepts.js","sourceRoot":"","sources":["../../src/render/concepts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,IAAI,GAAG,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"concepts.js","sourceRoot":"","sources":["../../src/render/concepts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,IAAI,GAAG,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC9D,MAAM,UAAU,cAAc,CAAC,GAAgB;IAC7C,OAAO,yBAAyB,GAAG,CAAC,QAAQ;SACzC,GAAG,CACF,CAAC,CAAC,EAAE,EAAE,CACJ,uDAAuD,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,wEAAwE,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,KAAK;SACvK,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACT,MAAM,QAAQ,GAAG,GAAG,CAAC,SAAS,CAAC,IAAI,CACjC,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,IAAI,GAAG,CAAC,eAAe,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CACjE,CAAC;QACH,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpE,OAAO,mBAAmB,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,wBAAwB,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,4BAA4B,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,oCAAoC,KAAK,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,2BAA2B,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,SAAS,KAAK,GAAG,CAAC,uBAAuB,CAAC;IAC3b,CAAC,CAAC;SACD,IAAI,CAAC,EAAE,CAAC,iBAAiB,CAC/B;SACA,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC;AACtB,CAAC;AACD,MAAM,UAAU,YAAY,CAAC,GAAgB;IAC3C,OAAO,sBAAsB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,gBAAgB,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,aAAa,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC;AACjK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../src/render/data.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAQ9C"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Stable JSON lets server and browser compare map data independent of key order. */
|
|
2
|
+
export function mapData(value) {
|
|
3
|
+
return JSON.stringify(value, (_, item) => item && typeof item === "object" && !Array.isArray(item)
|
|
4
|
+
? Object.fromEntries(Object.entries(item).sort(([a], [b]) => a.localeCompare(b)))
|
|
5
|
+
: item).replaceAll("<", "\\u003c");
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.js","sourceRoot":"","sources":["../../src/render/data.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,MAAM,UAAU,OAAO,CAAC,KAAc;IACpC,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,CACvC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QACtD,CAAC,CAAC,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAC5D;QACH,CAAC,CAAC,IAAI,CACT,CAAC,UAAU,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ResolvedMap } from "../schema.js";
|
|
2
|
+
import { type UiStrings } from "./panel.js";
|
|
3
|
+
export interface FigureOptions {
|
|
4
|
+
/** Unique document id, also used for the server-rendered SVG marker. */
|
|
5
|
+
id?: string;
|
|
6
|
+
strings?: Partial<UiStrings>;
|
|
7
|
+
}
|
|
8
|
+
/** Complete light-DOM figure, including the data needed to hydrate it. */
|
|
9
|
+
export declare function renderFigure(map: ResolvedMap, options?: FigureOptions): string;
|
|
10
|
+
//# sourceMappingURL=figure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"figure.d.ts","sourceRoot":"","sources":["../../src/render/figure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAIhD,OAAO,EAAgC,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAI1E,MAAM,WAAW,aAAa;IAC5B,wEAAwE;IACxE,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;CAC9B;AAED,0EAA0E;AAC1E,wBAAgB,YAAY,CAC1B,GAAG,EAAE,WAAW,EAChB,OAAO,GAAE,aAAkB,GAC1B,MAAM,CAgBR"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { derive } from "../model/frame.js";
|
|
2
|
+
import { initialState } from "../model/state.js";
|
|
3
|
+
import { renderSvg } from "./svg.js";
|
|
4
|
+
import { renderPanelParts, statusText } from "./panel.js";
|
|
5
|
+
import { renderConcepts, renderDeeper } from "./concepts.js";
|
|
6
|
+
import { escapeHtml as esc } from "./inline.js";
|
|
7
|
+
/** Complete light-DOM figure, including the data needed to hydrate it. */
|
|
8
|
+
export function renderFigure(map, options = {}) {
|
|
9
|
+
const frame = derive(map, initialState);
|
|
10
|
+
const panel = renderPanelParts(map, frame, options.strings);
|
|
11
|
+
const id = options.id ? ` id="${esc(options.id)}"` : "";
|
|
12
|
+
const scenarios = map.scenarios
|
|
13
|
+
.map((s, i) => `<button type="button" data-scenario="${esc(s.id)}" aria-pressed="${i === 0}">${esc(s.label)}</button>`)
|
|
14
|
+
.join("");
|
|
15
|
+
const svg = renderSvg(map, {
|
|
16
|
+
frame,
|
|
17
|
+
markerId: options.id ? `${options.id}-arrow` : undefined,
|
|
18
|
+
});
|
|
19
|
+
const data = JSON.stringify(map).replaceAll("<", "\\u003c");
|
|
20
|
+
return `<figure class="map-figure map-ui"${id} data-figure="map" data-map-id="${esc(map.id)}" tabindex="0" aria-label="${esc(map.title)}"><section aria-label="Concept map"><div class="bar"><div class="seg scenarios" role="group" aria-label="Scenario" data-role="scenarios">${scenarios}</div><div class="seg" role="group" aria-label="View"><button type="button" data-mode="step" aria-pressed="true">Step by step</button><button type="button" data-mode="all" aria-pressed="false">Whole map</button></div></div><div class="map">${svg}</div></section><p class="map-status" role="status" data-map-status>${esc(statusText(frame))}</p><div class="panel head" data-role="panel">${panel.head}</div><div class="panel more" data-role="more">${panel.more}</div><div data-map-concepts>${renderConcepts(map)}</div>${renderDeeper(map)}<script type="application/json" data-map-data>${data}</script></figure>`;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=figure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"figure.js","sourceRoot":"","sources":["../../src/render/figure.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAkB,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,UAAU,IAAI,GAAG,EAAE,MAAM,aAAa,CAAC;AAQhD,0EAA0E;AAC1E,MAAM,UAAU,YAAY,CAC1B,GAAgB,EAChB,UAAyB,EAAE;IAE3B,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IACxC,MAAM,KAAK,GAAG,gBAAgB,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5D,MAAM,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACxD,MAAM,SAAS,GAAG,GAAG,CAAC,SAAS;SAC5B,GAAG,CACF,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACP,wCAAwC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,mBAAmB,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAC1G;SACA,IAAI,CAAC,EAAE,CAAC,CAAC;IACZ,MAAM,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE;QACzB,KAAK;QACL,QAAQ,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS;KACzD,CAAC,CAAC;IACH,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAC5D,OAAO,oCAAoC,EAAE,mCAAmC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,8BAA8B,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,4IAA4I,SAAS,mPAAmP,GAAG,uEAAuE,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,iDAAiD,KAAK,CAAC,IAAI,kDAAkD,KAAK,CAAC,IAAI,gCAAgC,cAAc,CAAC,GAAG,CAAC,SAAS,YAAY,CAAC,GAAG,CAAC,iDAAiD,IAAI,oBAAoB,CAAC;AAC/3B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hydration.d.ts","sourceRoot":"","sources":["../../src/render/hydration.ts"],"names":[],"mappings":"AAEA,4EAA4E;AAC5E,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAO1E"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { mapData } from "./data.js";
|
|
2
|
+
/** Reuse a figure only when its embedded data matches the requested map. */
|
|
3
|
+
export function canHydrate(data, map) {
|
|
4
|
+
if (data === undefined)
|
|
5
|
+
return false;
|
|
6
|
+
try {
|
|
7
|
+
return mapData(JSON.parse(data)) === mapData(map);
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=hydration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hydration.js","sourceRoot":"","sources":["../../src/render/hydration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,4EAA4E;AAC5E,MAAM,UAAU,UAAU,CAAC,IAAwB,EAAE,GAAY;IAC/D,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACrC,IAAI,CAAC;QACH,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACpD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panel.d.ts","sourceRoot":"","sources":["../../src/render/panel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C,eAAO,MAAM,cAAc;;;;;;;;;;;;;;CAc1B,CAAC;AACF,MAAM,MAAM,SAAS,GAAG,OAAO,cAAc,CAAC;AAC9C;4EAC4E;AAC5E,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAE/C;
|
|
1
|
+
{"version":3,"file":"panel.d.ts","sourceRoot":"","sources":["../../src/render/panel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C,eAAO,MAAM,cAAc;;;;;;;;;;;;;;CAc1B,CAAC;AACF,MAAM,MAAM,SAAS,GAAG,OAAO,cAAc,CAAC;AAC9C;4EAC4E;AAC5E,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAE/C;AA+BD,wBAAgB,WAAW,CACzB,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,KAAK,EACZ,OAAO,GAAE,OAAO,CAAC,SAAS,CAAM,GAC/B,MAAM,CAGR;AACD,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,KAAK,EACZ,OAAO,GAAE,OAAO,CAAC,SAAS,CAAM;;;EAIjC"}
|