ui-router-devtools 0.0.1-alpha.0 → 0.1.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/LICENSE +9 -0
- package/README.md +161 -0
- package/dist/console.d.ts +5 -0
- package/dist/console.d.ts.map +1 -0
- package/dist/console.js +47 -0
- package/dist/console.js.map +1 -0
- package/dist/define.d.ts +8 -0
- package/dist/define.d.ts.map +1 -0
- package/dist/define.js +4 -0
- package/dist/define.js.map +1 -0
- package/dist/edges.d.ts +25 -0
- package/dist/edges.d.ts.map +1 -0
- package/dist/edges.js +28 -0
- package/dist/edges.js.map +1 -0
- package/dist/element/chips.d.ts +17 -0
- package/dist/element/chips.d.ts.map +1 -0
- package/dist/element/chips.js +134 -0
- package/dist/element/chips.js.map +1 -0
- package/dist/element/glyphs.d.ts +34 -0
- package/dist/element/glyphs.d.ts.map +1 -0
- package/dist/element/glyphs.js +107 -0
- package/dist/element/glyphs.js.map +1 -0
- package/dist/element/inspector.d.ts +7 -0
- package/dist/element/inspector.d.ts.map +1 -0
- package/dist/element/inspector.js +183 -0
- package/dist/element/inspector.js.map +1 -0
- package/dist/element/links.d.ts +4 -0
- package/dist/element/links.d.ts.map +1 -0
- package/dist/element/links.js +87 -0
- package/dist/element/links.js.map +1 -0
- package/dist/element/log.d.ts +12 -0
- package/dist/element/log.d.ts.map +1 -0
- package/dist/element/log.js +272 -0
- package/dist/element/log.js.map +1 -0
- package/dist/element/map.d.ts +5 -0
- package/dist/element/map.d.ts.map +1 -0
- package/dist/element/map.js +5 -0
- package/dist/element/map.js.map +1 -0
- package/dist/element/mapview.d.ts +17 -0
- package/dist/element/mapview.d.ts.map +1 -0
- package/dist/element/mapview.js +158 -0
- package/dist/element/mapview.js.map +1 -0
- package/dist/element/measure.d.ts +3 -0
- package/dist/element/measure.d.ts.map +1 -0
- package/dist/element/measure.js +9 -0
- package/dist/element/measure.js.map +1 -0
- package/dist/element/nested.d.ts +45 -0
- package/dist/element/nested.d.ts.map +1 -0
- package/dist/element/nested.js +686 -0
- package/dist/element/nested.js.map +1 -0
- package/dist/element/pack.d.ts +75 -0
- package/dist/element/pack.d.ts.map +1 -0
- package/dist/element/pack.js +281 -0
- package/dist/element/pack.js.map +1 -0
- package/dist/element/panel.d.ts +159 -0
- package/dist/element/panel.d.ts.map +1 -0
- package/dist/element/panel.js +1542 -0
- package/dist/element/panel.js.map +1 -0
- package/dist/element/popover.d.ts +12 -0
- package/dist/element/popover.d.ts.map +1 -0
- package/dist/element/popover.js +38 -0
- package/dist/element/popover.js.map +1 -0
- package/dist/element/route.d.ts +75 -0
- package/dist/element/route.d.ts.map +1 -0
- package/dist/element/route.js +883 -0
- package/dist/element/route.js.map +1 -0
- package/dist/element/scrubber.d.ts +4 -0
- package/dist/element/scrubber.d.ts.map +1 -0
- package/dist/element/scrubber.js +67 -0
- package/dist/element/scrubber.js.map +1 -0
- package/dist/element/styles.d.ts +3 -0
- package/dist/element/styles.d.ts.map +1 -0
- package/dist/element/styles.js +2084 -0
- package/dist/element/styles.js.map +1 -0
- package/dist/element/timeline-styles.d.ts +3 -0
- package/dist/element/timeline-styles.d.ts.map +1 -0
- package/dist/element/timeline-styles.js +286 -0
- package/dist/element/timeline-styles.js.map +1 -0
- package/dist/element/timeline.d.ts +9 -0
- package/dist/element/timeline.d.ts.map +1 -0
- package/dist/element/timeline.js +225 -0
- package/dist/element/timeline.js.map +1 -0
- package/dist/element/tree.d.ts +24 -0
- package/dist/element/tree.d.ts.map +1 -0
- package/dist/element/tree.js +149 -0
- package/dist/element/tree.js.map +1 -0
- package/dist/element/viewmap-styles.d.ts +3 -0
- package/dist/element/viewmap-styles.d.ts.map +1 -0
- package/dist/element/viewmap-styles.js +282 -0
- package/dist/element/viewmap-styles.js.map +1 -0
- package/dist/element/viewmap.d.ts +39 -0
- package/dist/element/viewmap.d.ts.map +1 -0
- package/dist/element/viewmap.js +406 -0
- package/dist/element/viewmap.js.map +1 -0
- package/dist/element/viewport.d.ts +31 -0
- package/dist/element/viewport.d.ts.map +1 -0
- package/dist/element/viewport.js +37 -0
- package/dist/element/viewport.js.map +1 -0
- package/dist/element/waterfall.d.ts +85 -0
- package/dist/element/waterfall.d.ts.map +1 -0
- package/dist/element/waterfall.js +284 -0
- package/dist/element/waterfall.js.map +1 -0
- package/dist/fold.d.ts +27 -0
- package/dist/fold.d.ts.map +1 -0
- package/dist/fold.js +104 -0
- package/dist/fold.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/lit-ui-router.d.ts +24 -0
- package/dist/lit-ui-router.d.ts.map +1 -0
- package/dist/lit-ui-router.js +102 -0
- package/dist/lit-ui-router.js.map +1 -0
- package/dist/notation.d.ts +28 -0
- package/dist/notation.d.ts.map +1 -0
- package/dist/notation.js +105 -0
- package/dist/notation.js.map +1 -0
- package/dist/performance.d.ts +5 -0
- package/dist/performance.d.ts.map +1 -0
- package/dist/performance.js +66 -0
- package/dist/performance.js.map +1 -0
- package/dist/plugin.d.ts +32 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +21 -0
- package/dist/plugin.js.map +1 -0
- package/dist/recorder.d.ts +30 -0
- package/dist/recorder.d.ts.map +1 -0
- package/dist/recorder.js +117 -0
- package/dist/recorder.js.map +1 -0
- package/dist/schema.d.ts +2 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +2 -0
- package/dist/schema.js.map +1 -0
- package/dist/session-schema.d.ts +31 -0
- package/dist/session-schema.d.ts.map +1 -0
- package/dist/session-schema.js +314 -0
- package/dist/session-schema.js.map +1 -0
- package/dist/session.schema.json +1172 -0
- package/dist/shared/event-schema.d.ts +225 -0
- package/dist/shared/event-schema.d.ts.map +1 -0
- package/dist/shared/event-schema.js +2 -0
- package/dist/shared/event-schema.js.map +1 -0
- package/dist/shared/redaction.d.ts +19 -0
- package/dist/shared/redaction.d.ts.map +1 -0
- package/dist/shared/redaction.js +56 -0
- package/dist/shared/redaction.js.map +1 -0
- package/dist/shared/resolve-timing.d.ts +6 -0
- package/dist/shared/resolve-timing.d.ts.map +1 -0
- package/dist/shared/resolve-timing.js +61 -0
- package/dist/shared/resolve-timing.js.map +1 -0
- package/dist/shared/router-events.d.ts +10 -0
- package/dist/shared/router-events.d.ts.map +1 -0
- package/dist/shared/router-events.js +296 -0
- package/dist/shared/router-events.js.map +1 -0
- package/dist/shared/thrown.d.ts +5 -0
- package/dist/shared/thrown.d.ts.map +1 -0
- package/dist/shared/thrown.js +12 -0
- package/dist/shared/thrown.js.map +1 -0
- package/dist/shared/transition-source.d.ts +4 -0
- package/dist/shared/transition-source.d.ts.map +1 -0
- package/dist/shared/transition-source.js +2 -0
- package/dist/shared/transition-source.js.map +1 -0
- package/dist/shared/views.d.ts +10 -0
- package/dist/shared/views.d.ts.map +1 -0
- package/dist/shared/views.js +67 -0
- package/dist/shared/views.js.map +1 -0
- package/dist/spans.d.ts +15 -0
- package/dist/spans.d.ts.map +1 -0
- package/dist/spans.js +24 -0
- package/dist/spans.js.map +1 -0
- package/dist/testing.d.ts +32 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +28 -0
- package/dist/testing.js.map +1 -0
- package/dist/ui-router-devtools.d.ts +36 -0
- package/dist/ui-router-devtools.d.ts.map +1 -0
- package/dist/ui-router-devtools.js +3 -0
- package/dist/ui-router-devtools.js.map +1 -0
- package/dist/views.d.ts +44 -0
- package/dist/views.d.ts.map +1 -0
- package/dist/views.js +43 -0
- package/dist/views.js.map +1 -0
- package/package.json +112 -2
- package/src/console.ts +104 -0
- package/src/define.ts +12 -0
- package/src/edges.ts +64 -0
- package/src/element/chips.ts +187 -0
- package/src/element/glyphs.ts +218 -0
- package/src/element/inspector.ts +315 -0
- package/src/element/links.ts +136 -0
- package/src/element/log.ts +410 -0
- package/src/element/map.ts +22 -0
- package/src/element/mapview.ts +224 -0
- package/src/element/measure.ts +13 -0
- package/src/element/nested.ts +1124 -0
- package/src/element/pack.ts +526 -0
- package/src/element/panel.ts +2378 -0
- package/src/element/popover.ts +64 -0
- package/src/element/route.ts +1481 -0
- package/src/element/scrubber.ts +103 -0
- package/src/element/styles.ts +2084 -0
- package/src/element/timeline-styles.ts +287 -0
- package/src/element/timeline.ts +392 -0
- package/src/element/tree.ts +271 -0
- package/src/element/viewmap-styles.ts +283 -0
- package/src/element/viewmap.ts +733 -0
- package/src/element/viewport.ts +112 -0
- package/src/element/waterfall.ts +585 -0
- package/src/fold.ts +151 -0
- package/src/index.ts +40 -0
- package/src/lit-ui-router.ts +194 -0
- package/src/notation.ts +181 -0
- package/src/performance.ts +142 -0
- package/src/plugin.ts +57 -0
- package/src/recorder.ts +228 -0
- package/src/schema.ts +32 -0
- package/src/session-schema.ts +362 -0
- package/src/spans.ts +53 -0
- package/src/testing.ts +74 -0
- package/src/types/import-meta-env.d.ts +9 -0
- package/src/ui-router-devtools.ts +39 -0
- package/src/views.ts +116 -0
|
@@ -0,0 +1,686 @@
|
|
|
1
|
+
import { html, nothing, svg } from "lit";
|
|
2
|
+
import { repeat } from "lit/directives/repeat.js";
|
|
3
|
+
import { ancestorsOf, bareName } from "../fold.js";
|
|
4
|
+
import { edgesOf, edgeWeight } from "../edges.js";
|
|
5
|
+
import { segment, truncateMiddle } from "../notation.js";
|
|
6
|
+
import { depthClass, foldGlyph, markGlyph, markLabel, stateMarks } from "./glyphs.js";
|
|
7
|
+
import { chooseRung, drawnIn, fits, LARGE_METRICS, METRICS, pack, ROOMY_METRICS, SMALL_METRICS } from "./pack.js";
|
|
8
|
+
import { renderMinimap, viewKey } from "./mapview.js";
|
|
9
|
+
import { textWidth } from "./measure.js";
|
|
10
|
+
import { route, visibleEnd } from "./route.js";
|
|
11
|
+
import { placeChips } from "./chips.js";
|
|
12
|
+
import { facts, label, onTreeKey, words } from "./tree.js";
|
|
13
|
+
const LEAD = 20;
|
|
14
|
+
const SETTLE = 200;
|
|
15
|
+
const WITHDRAW = 160;
|
|
16
|
+
const OPEN = {
|
|
17
|
+
collapse: false,
|
|
18
|
+
merge: false,
|
|
19
|
+
truncate: false
|
|
20
|
+
};
|
|
21
|
+
const SHUT = {
|
|
22
|
+
collapse: true,
|
|
23
|
+
merge: true,
|
|
24
|
+
truncate: true
|
|
25
|
+
};
|
|
26
|
+
const OPTIONS = {
|
|
27
|
+
large: {
|
|
28
|
+
...OPEN,
|
|
29
|
+
metrics: LARGE_METRICS
|
|
30
|
+
},
|
|
31
|
+
roomy: {
|
|
32
|
+
...OPEN,
|
|
33
|
+
metrics: ROOMY_METRICS
|
|
34
|
+
},
|
|
35
|
+
expanded: {
|
|
36
|
+
...OPEN,
|
|
37
|
+
metrics: METRICS
|
|
38
|
+
},
|
|
39
|
+
collapsed: {
|
|
40
|
+
...OPEN,
|
|
41
|
+
collapse: true,
|
|
42
|
+
metrics: METRICS
|
|
43
|
+
},
|
|
44
|
+
merged: {
|
|
45
|
+
...SHUT,
|
|
46
|
+
truncate: false,
|
|
47
|
+
metrics: METRICS
|
|
48
|
+
},
|
|
49
|
+
truncated: {
|
|
50
|
+
...SHUT,
|
|
51
|
+
metrics: METRICS
|
|
52
|
+
},
|
|
53
|
+
small: {
|
|
54
|
+
...SHUT,
|
|
55
|
+
metrics: SMALL_METRICS
|
|
56
|
+
},
|
|
57
|
+
pan: {
|
|
58
|
+
...SHUT,
|
|
59
|
+
truncate: false,
|
|
60
|
+
metrics: METRICS
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
export const ZOOMS = [
|
|
64
|
+
SMALL_METRICS,
|
|
65
|
+
METRICS,
|
|
66
|
+
ROOMY_METRICS,
|
|
67
|
+
LARGE_METRICS
|
|
68
|
+
];
|
|
69
|
+
const REPACK_RATIO = 1.25;
|
|
70
|
+
const STEP = new Map([
|
|
71
|
+
[LARGE_METRICS, "large"],
|
|
72
|
+
[ROOMY_METRICS, "roomy"],
|
|
73
|
+
[SMALL_METRICS, "small"]
|
|
74
|
+
]);
|
|
75
|
+
export const scaleOf = (metrics) => Math.max(1, metrics.type / METRICS.type);
|
|
76
|
+
const isOpen = ({ host, keep, options }, name) => host._mapOpen.get(name) ?? (!options.collapse || keep.has(name));
|
|
77
|
+
const countUnder = (build, name) => (build.children.get(name) ?? []).reduce((total, child) => total + 1 + countUnder(build, child.name), 0);
|
|
78
|
+
const nameOf = (state, options) => options.truncate ? truncateMiddle(segment(state.name)) : segment(state.name);
|
|
79
|
+
const labelWidth = (build, state, collapsed, merging) => {
|
|
80
|
+
const { host, options, family } = build;
|
|
81
|
+
const size = options.metrics.type;
|
|
82
|
+
const scale = scaleOf(options.metrics);
|
|
83
|
+
const weight = state.name === host._model.current.name ? 700 : 400;
|
|
84
|
+
const marks = stateMarks(state, host._model.states).length;
|
|
85
|
+
const font = (w) => `${w} ${size}px ${family}`;
|
|
86
|
+
const count = collapsed ? 8 * scale + textWidth(String(countUnder(build, state.name)), font(400)) : 0;
|
|
87
|
+
const name = textWidth(nameOf(state, options), font(weight));
|
|
88
|
+
if (merging) return Math.ceil(44 * scale + name);
|
|
89
|
+
const fixed = 36 + (marks ? 4 + marks * 16 : 0) + (state.future ? 40 : 0) + ((build.children.get(state.name) ?? []).length ? 20 : 0);
|
|
90
|
+
return Math.ceil(fixed * scale + name + count);
|
|
91
|
+
};
|
|
92
|
+
const buildBox = (build, state) => {
|
|
93
|
+
const kids = build.children.get(state.name) ?? [];
|
|
94
|
+
const open = kids.length > 0 && isOpen(build, state.name);
|
|
95
|
+
const children = open ? kids.map((kid) => buildBox(build, kid)) : [];
|
|
96
|
+
const merge = build.options.merge && children.length === 1 && children[0].children.length > 0;
|
|
97
|
+
for (const child of children) if (!merge && state.redirectTo === bareName(child.name)) child.lead = LEAD;
|
|
98
|
+
return {
|
|
99
|
+
name: state.name,
|
|
100
|
+
label: labelWidth(build, state, kids.length > 0 && !open, merge),
|
|
101
|
+
merge,
|
|
102
|
+
children
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
const keepOpen = (host) => {
|
|
106
|
+
const { states, current } = host._model;
|
|
107
|
+
const tx = host._inspect === "tx" ? host._tx(host._selectedTx) : undefined;
|
|
108
|
+
const origin = tx && host._origin(tx);
|
|
109
|
+
const names = [
|
|
110
|
+
current.name,
|
|
111
|
+
tx?.from,
|
|
112
|
+
tx?.to,
|
|
113
|
+
origin?.from,
|
|
114
|
+
origin?.to
|
|
115
|
+
];
|
|
116
|
+
const keep = new Set();
|
|
117
|
+
for (const name of names) {
|
|
118
|
+
if (!name) continue;
|
|
119
|
+
keep.add(name);
|
|
120
|
+
ancestorsOf(states, name).forEach((ancestor) => keep.add(ancestor));
|
|
121
|
+
}
|
|
122
|
+
if (host._selectedState) ancestorsOf(states, host._selectedState).forEach((a) => keep.add(a));
|
|
123
|
+
return keep;
|
|
124
|
+
};
|
|
125
|
+
const rowsOf = (boxes, states, children, depth = 1) => boxes.flatMap((box, index) => [{
|
|
126
|
+
state: states.get(box.name),
|
|
127
|
+
depth,
|
|
128
|
+
hasChildren: (children.get(box.name) ?? []).length > 0,
|
|
129
|
+
setsize: boxes.length,
|
|
130
|
+
posinset: index + 1
|
|
131
|
+
}, ...rowsOf(box.children, states, children, depth + 1)]);
|
|
132
|
+
const openOf = (boxes) => boxes.flatMap((box) => box.children.length ? [box.name, ...openOf(box.children)] : []);
|
|
133
|
+
const cache = new WeakMap();
|
|
134
|
+
const sameAspect = (a, b) => {
|
|
135
|
+
const ratio = a.width * b.height / Math.max(1, a.height * b.width);
|
|
136
|
+
return ratio < REPACK_RATIO && ratio > 1 / REPACK_RATIO;
|
|
137
|
+
};
|
|
138
|
+
const rectsOf = (placed, metrics, origin, into = new Map()) => {
|
|
139
|
+
for (const item of drawnIn(placed, metrics)) {
|
|
140
|
+
const at = {
|
|
141
|
+
x: origin.x + item.x,
|
|
142
|
+
y: origin.y + item.y
|
|
143
|
+
};
|
|
144
|
+
into.set(item.box.name, {
|
|
145
|
+
...at,
|
|
146
|
+
width: item.width,
|
|
147
|
+
height: item.height
|
|
148
|
+
});
|
|
149
|
+
rectsOf(item.placed, metrics, at, into);
|
|
150
|
+
}
|
|
151
|
+
return into;
|
|
152
|
+
};
|
|
153
|
+
const allRects = (placed, metrics, rtl) => {
|
|
154
|
+
const rects = new Map();
|
|
155
|
+
const origin = {
|
|
156
|
+
x: 0,
|
|
157
|
+
y: 0
|
|
158
|
+
};
|
|
159
|
+
if (placed.box) rects.set(placed.box.name, {
|
|
160
|
+
...origin,
|
|
161
|
+
width: placed.width,
|
|
162
|
+
height: placed.height
|
|
163
|
+
});
|
|
164
|
+
rectsOf(placed, metrics, origin, rects);
|
|
165
|
+
if (rtl) for (const [name, rect] of rects) rects.set(name, {
|
|
166
|
+
...rect,
|
|
167
|
+
x: placed.width - rect.x - rect.width
|
|
168
|
+
});
|
|
169
|
+
return rects;
|
|
170
|
+
};
|
|
171
|
+
export const layoutNested = (host) => {
|
|
172
|
+
const { states, current } = host._model;
|
|
173
|
+
const keep = keepOpen(host);
|
|
174
|
+
const style = getComputedStyle(host);
|
|
175
|
+
const family = style.getPropertyValue("--uird-font-mono");
|
|
176
|
+
const rtl = style.direction === "rtl";
|
|
177
|
+
const viewport = host._mapSize;
|
|
178
|
+
const children = host._children();
|
|
179
|
+
const opened = [...keep].filter((name) => children.get(name)?.length && !host._mapOpen.has(name));
|
|
180
|
+
const content = JSON.stringify([
|
|
181
|
+
states,
|
|
182
|
+
current.name,
|
|
183
|
+
opened,
|
|
184
|
+
[...host._mapOpen],
|
|
185
|
+
family,
|
|
186
|
+
rtl,
|
|
187
|
+
host._max,
|
|
188
|
+
host._mapZoom
|
|
189
|
+
]);
|
|
190
|
+
const key = content + JSON.stringify(viewport);
|
|
191
|
+
const cached = cache.get(host);
|
|
192
|
+
if (cached?.key === key) return cached.layout;
|
|
193
|
+
const boxesWith = (options) => {
|
|
194
|
+
const build = {
|
|
195
|
+
host,
|
|
196
|
+
children,
|
|
197
|
+
keep,
|
|
198
|
+
options,
|
|
199
|
+
family
|
|
200
|
+
};
|
|
201
|
+
return (children.get(null) ?? []).map((state) => buildBox(build, state));
|
|
202
|
+
};
|
|
203
|
+
const sizeAt = (rung, room) => pack(boxesWith(OPTIONS[rung]), room, OPTIONS[rung].metrics);
|
|
204
|
+
const same = cached?.content === content ? cached : undefined;
|
|
205
|
+
const rung = chooseRung(sizeAt, viewport, same && host._rung, host._max);
|
|
206
|
+
const zoom = host._mapZoom === null ? undefined : ZOOMS[host._mapZoom];
|
|
207
|
+
host._rung = rung;
|
|
208
|
+
if (same?.layout.rung === rung && sameAspect(same.room, viewport) && (zoom || rung === "pan" || fits(same.layout.placed, viewport))) {
|
|
209
|
+
cache.set(host, {
|
|
210
|
+
...same,
|
|
211
|
+
key
|
|
212
|
+
});
|
|
213
|
+
return same.layout;
|
|
214
|
+
}
|
|
215
|
+
const options = zoom ? {
|
|
216
|
+
...OPTIONS[rung],
|
|
217
|
+
metrics: zoom
|
|
218
|
+
} : OPTIONS[rung];
|
|
219
|
+
const scale = options.metrics.type / OPTIONS[rung].metrics.type;
|
|
220
|
+
const boxes = boxesWith(options);
|
|
221
|
+
const placed = pack(boxes, {
|
|
222
|
+
width: viewport.width * scale,
|
|
223
|
+
height: viewport.height * scale
|
|
224
|
+
}, options.metrics);
|
|
225
|
+
const byName = new Map(states.map((state) => [state.name, state]));
|
|
226
|
+
const layout = {
|
|
227
|
+
rung,
|
|
228
|
+
options,
|
|
229
|
+
metrics: options.metrics,
|
|
230
|
+
placed,
|
|
231
|
+
rects: allRects(placed, options.metrics, rtl),
|
|
232
|
+
rows: rowsOf(boxes, byName, children),
|
|
233
|
+
open: new Set(openOf(boxes)),
|
|
234
|
+
family,
|
|
235
|
+
rtl,
|
|
236
|
+
step: ZOOMS.indexOf(options.metrics)
|
|
237
|
+
};
|
|
238
|
+
cache.set(host, {
|
|
239
|
+
content,
|
|
240
|
+
key,
|
|
241
|
+
layout,
|
|
242
|
+
room: viewport
|
|
243
|
+
});
|
|
244
|
+
return layout;
|
|
245
|
+
};
|
|
246
|
+
const styleOf = (tx) => {
|
|
247
|
+
const outcome = tx.result?.outcome;
|
|
248
|
+
if (outcome === "error" || outcome === "invalid") return "fault";
|
|
249
|
+
return outcome === "redirected" ? "redirect" : "ok";
|
|
250
|
+
};
|
|
251
|
+
const txEdges = (host, tx) => {
|
|
252
|
+
const origin = host._origin(tx);
|
|
253
|
+
return [...origin ? [{
|
|
254
|
+
from: origin.from,
|
|
255
|
+
to: origin.to,
|
|
256
|
+
style: "redirect"
|
|
257
|
+
}] : [], {
|
|
258
|
+
from: tx.from,
|
|
259
|
+
to: tx.to,
|
|
260
|
+
style: styleOf(tx),
|
|
261
|
+
running: !tx.result
|
|
262
|
+
}];
|
|
263
|
+
};
|
|
264
|
+
const stateEdges = (host, name) => edgesOf(host._model).flatMap((edge) => {
|
|
265
|
+
const count = edge.outcomes.success ?? 0;
|
|
266
|
+
return count && (edge.from === name || edge.to === name) ? [{
|
|
267
|
+
from: edge.from,
|
|
268
|
+
to: edge.to,
|
|
269
|
+
style: "ok",
|
|
270
|
+
count
|
|
271
|
+
}] : [];
|
|
272
|
+
});
|
|
273
|
+
const wantedEdges = (host) => {
|
|
274
|
+
const tx = host._inspect === "tx" ? host._tx(host._selectedTx) : undefined;
|
|
275
|
+
if (tx) return txEdges(host, tx);
|
|
276
|
+
return host._inspect === "state" && host._selectedState ? stateEdges(host, host._selectedState) : [];
|
|
277
|
+
};
|
|
278
|
+
const mapEdges = (host, drawn) => {
|
|
279
|
+
const parents = new Map(host._model.states.map((s) => [s.name, s.parent]));
|
|
280
|
+
const end = (name) => visibleEnd(name, (at) => parents.get(at), (at) => drawn.has(at));
|
|
281
|
+
const edges = new Map();
|
|
282
|
+
for (const wanted of wantedEdges(host)) {
|
|
283
|
+
const from = end(wanted.from);
|
|
284
|
+
const to = end(wanted.to);
|
|
285
|
+
if (!from || !to) continue;
|
|
286
|
+
const id = JSON.stringify([
|
|
287
|
+
from.id,
|
|
288
|
+
to.id,
|
|
289
|
+
wanted.style
|
|
290
|
+
]);
|
|
291
|
+
const edge = edges.get(id);
|
|
292
|
+
edges.set(id, {
|
|
293
|
+
id,
|
|
294
|
+
from: from.id,
|
|
295
|
+
to: to.id,
|
|
296
|
+
style: wanted.style,
|
|
297
|
+
count: (edge?.count ?? 0) + (wanted.count ?? 0),
|
|
298
|
+
back: 0,
|
|
299
|
+
running: wanted.running,
|
|
300
|
+
fromStub: edge?.fromStub || from.stub,
|
|
301
|
+
toStub: edge?.toStub || to.stub
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
const nested = (a, b) => ancestorsOf(host._model.states, a).includes(b) || ancestorsOf(host._model.states, b).includes(a);
|
|
305
|
+
return twoWay([...edges.values()], nested).map((edge) => ({
|
|
306
|
+
...edge,
|
|
307
|
+
width: edge.count ? edgeWeight(Math.max(edge.count, edge.back)) : 2
|
|
308
|
+
}));
|
|
309
|
+
};
|
|
310
|
+
const twoWay = (edges, nested) => {
|
|
311
|
+
const byId = new Map(edges.map((edge) => [edge.id, edge]));
|
|
312
|
+
return edges.flatMap((edge) => {
|
|
313
|
+
const reverse = byId.get(JSON.stringify([
|
|
314
|
+
edge.to,
|
|
315
|
+
edge.from,
|
|
316
|
+
edge.style
|
|
317
|
+
]));
|
|
318
|
+
if (!reverse || reverse === edge || nested(edge.from, edge.to)) return [edge];
|
|
319
|
+
return edge.from > edge.to ? [] : [{
|
|
320
|
+
...edge,
|
|
321
|
+
both: true,
|
|
322
|
+
back: reverse.count,
|
|
323
|
+
fromStub: edge.fromStub || reverse.toStub,
|
|
324
|
+
toStub: edge.toStub || reverse.fromStub
|
|
325
|
+
}];
|
|
326
|
+
});
|
|
327
|
+
};
|
|
328
|
+
const routes = new WeakMap();
|
|
329
|
+
const CHIP = {
|
|
330
|
+
height: 12,
|
|
331
|
+
pad: 3,
|
|
332
|
+
arrow: 6,
|
|
333
|
+
gap: 4
|
|
334
|
+
};
|
|
335
|
+
const CHIP_FONT = "500 11px";
|
|
336
|
+
const chipCounts = ({ count, back, both }, dir) => {
|
|
337
|
+
if (Math.max(count, back) < 2) return [];
|
|
338
|
+
if (!both) return [{ text: `×${count}` }];
|
|
339
|
+
const forward = {
|
|
340
|
+
text: String(count),
|
|
341
|
+
dir
|
|
342
|
+
};
|
|
343
|
+
const against = {
|
|
344
|
+
text: String(back),
|
|
345
|
+
dir: (dir + 2) % 4
|
|
346
|
+
};
|
|
347
|
+
return dir >= 2 ? [forward, against] : [against, forward];
|
|
348
|
+
};
|
|
349
|
+
const chipParts = (edge, dir, family) => {
|
|
350
|
+
let x = CHIP.pad - CHIP.gap;
|
|
351
|
+
const parts = chipCounts(edge, dir).map((part) => {
|
|
352
|
+
const start = x + CHIP.gap;
|
|
353
|
+
x = start + (part.dir === undefined ? 0 : CHIP.arrow) + textWidth(part.text, `${CHIP_FONT} ${family}`);
|
|
354
|
+
return {
|
|
355
|
+
...part,
|
|
356
|
+
x: start
|
|
357
|
+
};
|
|
358
|
+
});
|
|
359
|
+
return {
|
|
360
|
+
parts,
|
|
361
|
+
width: Math.ceil(x + CHIP.pad)
|
|
362
|
+
};
|
|
363
|
+
};
|
|
364
|
+
const countChips = (routed, boxes, family) => {
|
|
365
|
+
const byId = new Map(routed.map((r) => [r.id, r.edge]));
|
|
366
|
+
const wants = routed.flatMap(({ id, edge }) => {
|
|
367
|
+
const { parts, width } = chipParts(edge, 0, family);
|
|
368
|
+
return parts.length ? [{
|
|
369
|
+
id,
|
|
370
|
+
width,
|
|
371
|
+
height: CHIP.height
|
|
372
|
+
}] : [];
|
|
373
|
+
});
|
|
374
|
+
return placeChips(routed, boxes, wants).map((chip) => ({
|
|
375
|
+
...chip,
|
|
376
|
+
parts: chipParts(byId.get(chip.id), chip.dir, family).parts
|
|
377
|
+
}));
|
|
378
|
+
};
|
|
379
|
+
const routeEdges = (host, layout) => {
|
|
380
|
+
const { rects } = layout;
|
|
381
|
+
const edges = mapEdges(host, new Set(rects.keys()));
|
|
382
|
+
const key = JSON.stringify(edges);
|
|
383
|
+
const cached = routes.get(host);
|
|
384
|
+
if (cached?.key === key && cached.layout === layout) return cached;
|
|
385
|
+
const parents = new Map(host._model.states.map((s) => [s.name, s.parent]));
|
|
386
|
+
const boxes = [...rects].map(([id, rect]) => ({
|
|
387
|
+
id,
|
|
388
|
+
parent: parents.get(id) ?? null,
|
|
389
|
+
rect,
|
|
390
|
+
head: Math.min(layout.metrics.head, rect.height)
|
|
391
|
+
}));
|
|
392
|
+
const byId = new Map(edges.map((edge) => [edge.id, edge]));
|
|
393
|
+
const routed = route(boxes, edges, { dpr: globalThis.devicePixelRatio || 1 }).map((r) => ({
|
|
394
|
+
...r,
|
|
395
|
+
edge: byId.get(r.id)
|
|
396
|
+
}));
|
|
397
|
+
const drawn = {
|
|
398
|
+
routed,
|
|
399
|
+
chips: countChips(routed, boxes, layout.family)
|
|
400
|
+
};
|
|
401
|
+
routes.set(host, {
|
|
402
|
+
key,
|
|
403
|
+
layout,
|
|
404
|
+
...drawn
|
|
405
|
+
});
|
|
406
|
+
return drawn;
|
|
407
|
+
};
|
|
408
|
+
const shown = new WeakMap();
|
|
409
|
+
const edgesToDraw = (host, layout) => {
|
|
410
|
+
const { routed, chips } = routeEdges(host, layout);
|
|
411
|
+
const before = shown.get(host);
|
|
412
|
+
const moved = before !== undefined && before.layout !== layout;
|
|
413
|
+
const now = performance.now();
|
|
414
|
+
const ids = new Set(routed.map((r) => r.id));
|
|
415
|
+
const leaving = !before || moved ? [] : [...before.leaving.filter((r) => r.until > now), ...before.routed.filter((r) => !before.leaving.some((gone) => gone.id === r.id)).map((r) => ({
|
|
416
|
+
...r,
|
|
417
|
+
until: now + WITHDRAW
|
|
418
|
+
}))].filter((r) => !ids.has(r.id));
|
|
419
|
+
const pass = (before?.pass ?? 0) + (moved ? 1 : 0);
|
|
420
|
+
clearTimeout(before?.timer);
|
|
421
|
+
shown.set(host, {
|
|
422
|
+
layout,
|
|
423
|
+
routed,
|
|
424
|
+
chips,
|
|
425
|
+
leaving,
|
|
426
|
+
pass,
|
|
427
|
+
timer: leaving.length ? setTimeout(() => host.requestUpdate(), WITHDRAW) : undefined
|
|
428
|
+
});
|
|
429
|
+
return {
|
|
430
|
+
routed,
|
|
431
|
+
chips,
|
|
432
|
+
leaving,
|
|
433
|
+
moved,
|
|
434
|
+
pass
|
|
435
|
+
};
|
|
436
|
+
};
|
|
437
|
+
export const anchorRect = (host, layout) => {
|
|
438
|
+
const parents = new Map(host._model.states.map((s) => [s.name, s.parent]));
|
|
439
|
+
const name = host._anchorState;
|
|
440
|
+
const end = name === null ? undefined : visibleEnd(name, (at) => parents.get(at), (at) => layout.rects.has(at));
|
|
441
|
+
return end && layout.rects.get(end.id);
|
|
442
|
+
};
|
|
443
|
+
export const keepClear = (host, layout) => {
|
|
444
|
+
const pad = 6;
|
|
445
|
+
const drawn = routeEdges(host, layout).routed.flatMap(({ edge, points }) => [...[edge.from, edge.to].flatMap((id) => layout.rects.get(id) ?? []), ...points.slice(1).map((point, index) => {
|
|
446
|
+
const prev = points[index];
|
|
447
|
+
return {
|
|
448
|
+
x: Math.min(prev.x, point.x) - pad,
|
|
449
|
+
y: Math.min(prev.y, point.y) - pad,
|
|
450
|
+
width: Math.abs(point.x - prev.x) + pad * 2,
|
|
451
|
+
height: Math.abs(point.y - prev.y) + pad * 2
|
|
452
|
+
};
|
|
453
|
+
})]);
|
|
454
|
+
const pills = [...layout.rects].flatMap(([name, rect]) => layout.open.has(name) ? [] : [rect]);
|
|
455
|
+
return [...drawn.map((rect) => ({
|
|
456
|
+
...rect,
|
|
457
|
+
weight: 20
|
|
458
|
+
})), ...pills.map((rect) => ({
|
|
459
|
+
...rect,
|
|
460
|
+
weight: 1
|
|
461
|
+
}))];
|
|
462
|
+
};
|
|
463
|
+
const renderEdge = ({ edge, kind, d, points, head, tail, caps }, index, leaving, frame) => {
|
|
464
|
+
const id = `uird-edge-${leaving ? "out" : "in"}-${index}`;
|
|
465
|
+
const reveal = `M${points.map((point) => `${point.x} ${point.y}`).join("L")}`;
|
|
466
|
+
const tip = edge.style === "redirect" ? "M-6.5 -3.5L0 0L-6.5 3.5" : "M0 0L-7 -3.5V3.5z";
|
|
467
|
+
return svg`<g class="nedge edge-${edge.style} w${edge.width ?? 1} ${kind === "fallback" ? "fallback" : ""} ${edge.running ? "running" : ""} ${leaving ? "leaving" : ""}">
|
|
468
|
+
<mask id=${id} maskUnits="userSpaceOnUse" x="-24" y="-24" width=${frame.width + 48} height=${frame.height + 48}>
|
|
469
|
+
<path class="reveal" pathLength="1" d=${reveal} />
|
|
470
|
+
</mask>
|
|
471
|
+
<g mask="url(#${id})">
|
|
472
|
+
<path class="halo" d=${d} /><path class="line" d=${d} />
|
|
473
|
+
${[head, ...tail ? [tail] : []].map((at) => svg`<path class="head" transform="translate(${at.x} ${at.y}) rotate(${at.angle})" d=${tip} />`)}
|
|
474
|
+
${caps.map((cap) => svg`<path class="cap" d=${cap.upright ? `M${cap.x} ${cap.y - 4}v8` : `M${cap.x - 4} ${cap.y}h8`} />`)}
|
|
475
|
+
</g>
|
|
476
|
+
</g>`;
|
|
477
|
+
};
|
|
478
|
+
const renderChip = ({ x, y, width, height, parts }) => svg`<g class="chip" transform="translate(${x} ${y})">
|
|
479
|
+
<rect width=${width} height=${height} rx="2" />
|
|
480
|
+
${parts.map((part) => svg`${part.dir === undefined ? nothing : svg`<path transform="translate(${part.x + 2.5} ${height / 2}) rotate(${part.dir * 90})" d="M-2 -3L2 0L-2 3z" />`}<text x=${part.x + (part.dir === undefined ? 0 : CHIP.arrow)} y=${height / 2}>${part.text}</text>`)}
|
|
481
|
+
</g>`;
|
|
482
|
+
const initialMark = svg`<svg class="initial" viewBox="0 0 20 12" width="20" height="12" aria-hidden="true">
|
|
483
|
+
<circle cx="4" cy="6" r="3" /><path d="M4 6H13" /><path class="tip" d="M20 6l-8 -4v8z" />
|
|
484
|
+
</svg>`;
|
|
485
|
+
const renderMarks = (marks) => marks.length ? html`<span class="marks" aria-hidden="true"
|
|
486
|
+
>${marks.map((mark) => html`<span class="mark" title=${markLabel(mark)}
|
|
487
|
+
>${markGlyph(mark.mark)}</span
|
|
488
|
+
>`)}</span
|
|
489
|
+
>` : nothing;
|
|
490
|
+
const renderFold = (view, box, kind, chain) => {
|
|
491
|
+
if (kind === "leaf" || box.merge) return nothing;
|
|
492
|
+
const open = kind === "open";
|
|
493
|
+
const target = chain ?? box.name;
|
|
494
|
+
return html`<button
|
|
495
|
+
class="fold"
|
|
496
|
+
tabindex="-1"
|
|
497
|
+
aria-label="${open ? "Collapse" : "Expand"} ${segment(target)}"
|
|
498
|
+
title=${open ? "Collapse" : "Expand"}
|
|
499
|
+
@click=${(event) => {
|
|
500
|
+
if (event.detail > 1 && view.host._pressed) return;
|
|
501
|
+
event.stopPropagation();
|
|
502
|
+
view.host._pressed = null;
|
|
503
|
+
nestedKeys(view.host, view.layout).toggle(target, open);
|
|
504
|
+
}}
|
|
505
|
+
>
|
|
506
|
+
${foldGlyph(open)}
|
|
507
|
+
</button>`;
|
|
508
|
+
};
|
|
509
|
+
const renderHead = (view, box, state, kind, chain) => {
|
|
510
|
+
const { host, layout, build } = view;
|
|
511
|
+
const role = host._role(state);
|
|
512
|
+
const isPivot = role === "retained" && state.name === view.pivot;
|
|
513
|
+
const marks = stateMarks(state, host._model.states);
|
|
514
|
+
const name = nameOf(state, layout.options);
|
|
515
|
+
const full = segment(state.name);
|
|
516
|
+
const current = state.name === host._model.current.name;
|
|
517
|
+
const id = view.ids.get(box.name) ?? 0;
|
|
518
|
+
const described = words(state, role, isPivot, marks);
|
|
519
|
+
const hidden = countUnder(build, state.name);
|
|
520
|
+
const labelled = kind === "collapsed" ? `${full} ${hidden}` : full;
|
|
521
|
+
const unlabelled = kind === "leaf" && name === full;
|
|
522
|
+
const tie = view.linked.get(box.name);
|
|
523
|
+
const description = [
|
|
524
|
+
described,
|
|
525
|
+
...kind === "collapsed" ? [`${hidden} states inside`] : [],
|
|
526
|
+
...tie ? [tie] : []
|
|
527
|
+
].join(", ");
|
|
528
|
+
return html`<div
|
|
529
|
+
class="head"
|
|
530
|
+
role="treeitem"
|
|
531
|
+
title=${state.name}
|
|
532
|
+
tabindex=${box.name === view.focus ? 0 : -1}
|
|
533
|
+
aria-label=${unlabelled ? nothing : labelled}
|
|
534
|
+
aria-owns=${kind === "open" ? `kids-${id}` : nothing}
|
|
535
|
+
aria-expanded=${kind === "leaf" ? nothing : kind === "open" ? "true" : "false"}
|
|
536
|
+
aria-current=${current ? "true" : nothing}
|
|
537
|
+
aria-selected=${host._selectedState === box.name}
|
|
538
|
+
aria-description=${description}
|
|
539
|
+
>
|
|
540
|
+
${label(state, role, isPivot, [], name, false)}${kind === "collapsed" ? html` <span class="count num">${hidden}</span>` : nothing}${renderMarks(marks)}${renderFold(view, box, kind, chain)}
|
|
541
|
+
</div>`;
|
|
542
|
+
};
|
|
543
|
+
const boxClasses = (view, item, kind) => {
|
|
544
|
+
const { box, placed } = item;
|
|
545
|
+
const state = view.states.get(box.name);
|
|
546
|
+
return [
|
|
547
|
+
`role-${view.host._role(state)}`,
|
|
548
|
+
depthClass(view.depths.get(box.name) ?? 1),
|
|
549
|
+
facts(state, view.host._model.current.name),
|
|
550
|
+
kind,
|
|
551
|
+
view.host._selectedState === box.name && "selected",
|
|
552
|
+
view.linked.has(box.name) && "linked",
|
|
553
|
+
box.merge && "merging",
|
|
554
|
+
placed.indent > 0 && "merged",
|
|
555
|
+
box.lead && "led"
|
|
556
|
+
].filter(Boolean).join(" ");
|
|
557
|
+
};
|
|
558
|
+
const kindOf = (view, box) => {
|
|
559
|
+
if (view.layout.open.has(box.name)) return "open";
|
|
560
|
+
return (view.build.children.get(box.name) ?? []).length ? "collapsed" : "leaf";
|
|
561
|
+
};
|
|
562
|
+
const renderBoxes = (view, placed, chain) => repeat(drawnIn(placed, view.layout.metrics), (item) => item.box.name, (item) => renderBox(view, item, chain));
|
|
563
|
+
const renderBox = (view, item, chain) => {
|
|
564
|
+
const { box, placed } = item;
|
|
565
|
+
const state = view.states.get(box.name);
|
|
566
|
+
const kind = kindOf(view, box);
|
|
567
|
+
return html`<div
|
|
568
|
+
role="none"
|
|
569
|
+
class="box ${boxClasses(view, item, kind)}"
|
|
570
|
+
data-name=${box.name}
|
|
571
|
+
style="inset-inline-start:${item.x}px;inset-block-start:${item.y}px;inline-size:${item.width}px;block-size:${item.height}px;--indent:${placed.indent}px"
|
|
572
|
+
>
|
|
573
|
+
${box.lead ? initialMark : nothing}${renderHead(view, box, state, kind, chain)}${kind === "open" ? html`<div
|
|
574
|
+
class="kids"
|
|
575
|
+
role="group"
|
|
576
|
+
id="kids-${view.ids.get(box.name) ?? 0}"
|
|
577
|
+
>
|
|
578
|
+
${renderBoxes(view, placed, box.merge ? chain ?? box.name : undefined)}
|
|
579
|
+
</div>` : nothing}
|
|
580
|
+
</div>`;
|
|
581
|
+
};
|
|
582
|
+
const boxName = (event) => event.target.closest(".box")?.dataset.name;
|
|
583
|
+
const nestedKeys = (host, layout) => ({
|
|
584
|
+
expanded: (row) => layout.open.has(row.state.name),
|
|
585
|
+
toggle: (name, collapse) => {
|
|
586
|
+
host._mapOpen = new Map([...host._mapOpen, [name, !collapse]]);
|
|
587
|
+
}
|
|
588
|
+
});
|
|
589
|
+
const linkedBoxes = (host, layout) => {
|
|
590
|
+
const linked = new Map();
|
|
591
|
+
for (const [name, tie] of host._linkedStates()) {
|
|
592
|
+
const drawn = [name, ...ancestorsOf(host._model.states, name)].filter((each) => layout.rects.has(each));
|
|
593
|
+
for (const each of drawn.slice(0, 1)) linked.set(each, tie);
|
|
594
|
+
}
|
|
595
|
+
return linked;
|
|
596
|
+
};
|
|
597
|
+
export const renderNested = (host, layout) => {
|
|
598
|
+
const { states, current } = host._model;
|
|
599
|
+
const { rows, placed, options } = layout;
|
|
600
|
+
const drawn = new Set(rows.map((row) => row.state.name));
|
|
601
|
+
const { routed, chips, leaving, moved, pass } = edgesToDraw(host, layout);
|
|
602
|
+
const frame = {
|
|
603
|
+
width: placed.width,
|
|
604
|
+
height: placed.height
|
|
605
|
+
};
|
|
606
|
+
const top = placed.box ? [{
|
|
607
|
+
box: placed.box,
|
|
608
|
+
placed,
|
|
609
|
+
x: 0,
|
|
610
|
+
y: 0,
|
|
611
|
+
...frame
|
|
612
|
+
}] : [];
|
|
613
|
+
const focus = host._focusState && drawn.has(host._focusState) ? host._focusState : (rows.find((r) => r.state.name === current.name) ?? rows[0])?.state.name;
|
|
614
|
+
const view = {
|
|
615
|
+
host,
|
|
616
|
+
layout,
|
|
617
|
+
states: new Map(states.map((state) => [state.name, state])),
|
|
618
|
+
ids: new Map(states.map((state, index) => [state.name, index])),
|
|
619
|
+
build: {
|
|
620
|
+
host,
|
|
621
|
+
children: host._children(),
|
|
622
|
+
keep: new Set(),
|
|
623
|
+
options,
|
|
624
|
+
family: ""
|
|
625
|
+
},
|
|
626
|
+
depths: new Map(rows.map((row) => [row.state.name, row.depth])),
|
|
627
|
+
focus,
|
|
628
|
+
pivot: host._focusTx?.retained.at(-1),
|
|
629
|
+
linked: linkedBoxes(host, layout)
|
|
630
|
+
};
|
|
631
|
+
const onKey = (event) => {
|
|
632
|
+
if (event.key === "Escape" && host._inspect !== "none") {
|
|
633
|
+
host._clearSelection();
|
|
634
|
+
event.preventDefault();
|
|
635
|
+
return;
|
|
636
|
+
}
|
|
637
|
+
if (viewKey(host, layout, event)) {
|
|
638
|
+
event.preventDefault();
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
onTreeKey(host, event, rows, focus, nestedKeys(host, layout));
|
|
642
|
+
};
|
|
643
|
+
const select = (event) => {
|
|
644
|
+
if (event.detail > 1) {
|
|
645
|
+
if (host._pressed) host._selectState(host._pressed, true);
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
host._pressed = boxName(event) ?? null;
|
|
649
|
+
if (host._pressed) host._selectState(host._pressed);
|
|
650
|
+
};
|
|
651
|
+
const go = () => {
|
|
652
|
+
if (host._pressed) host._goState(host._pressed);
|
|
653
|
+
};
|
|
654
|
+
const focusIn = (event) => {
|
|
655
|
+
const name = boxName(event);
|
|
656
|
+
if (!name) return;
|
|
657
|
+
host._focusState = name;
|
|
658
|
+
if (event.target.matches(":focus-visible")) host._reveal(layout, name);
|
|
659
|
+
};
|
|
660
|
+
const room = host._room(layout);
|
|
661
|
+
const at = host._viewOf(layout);
|
|
662
|
+
const from = layout.rtl ? room.width - placed.width : 0;
|
|
663
|
+
return html`<div
|
|
664
|
+
class="nested ${STEP.get(options.metrics) ?? ""}"
|
|
665
|
+
role="tree"
|
|
666
|
+
aria-label="State map"
|
|
667
|
+
style="inline-size:${placed.width}px;block-size:${placed.height}px;translate:${at.x - from}px ${at.y}px"
|
|
668
|
+
@keydown=${onKey}
|
|
669
|
+
@click=${select}
|
|
670
|
+
@dblclick=${go}
|
|
671
|
+
@focusin=${focusIn}
|
|
672
|
+
>
|
|
673
|
+
${top.length ? renderBox(view, top[0]) : renderBoxes(view, placed)}
|
|
674
|
+
<svg
|
|
675
|
+
class="nedges"
|
|
676
|
+
aria-hidden="true"
|
|
677
|
+
style="--uird-edge-delay:${moved ? SETTLE : 0}ms"
|
|
678
|
+
>
|
|
679
|
+
${repeat(routed, (r) => `${pass} ${r.id}`, (r, index) => renderEdge(r, index, false, frame))}
|
|
680
|
+
${leaving.map((r, index) => renderEdge(r, index, true, frame))}
|
|
681
|
+
${repeat(chips, (chip) => `${pass} ${chip.id}`, (chip) => renderChip(chip))}
|
|
682
|
+
</svg>
|
|
683
|
+
</div>
|
|
684
|
+
${renderMinimap(host, layout, at, room)}`;
|
|
685
|
+
};
|
|
686
|
+
//# sourceMappingURL=nested.js.map
|