glassbrain 0.2.0-alpha.7 → 0.2.0-alpha.8
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 +6 -7
- package/dist/chunks/{chunk-GZSWZSSE.js → chunk-3CNHFYHG.js} +1317 -1650
- package/dist/chunks/chunk-7PWRJEZT.js +35 -0
- package/dist/chunks/chunk-CHOCJIOD.js +1340 -0
- package/dist/chunks/chunk-DHYIMBHU.js +960 -0
- package/dist/chunks/{chunk-FNTYI7VP.js → chunk-NDUF3CBQ.js} +340 -996
- package/dist/cli/glassbrain.js +338 -142
- package/dist/cli/viewer.js +218 -213
- package/dist/core.d.ts +1 -0
- package/dist/core.js +50 -30
- package/dist/diff.d.ts +9 -1
- package/dist/edit.d.ts +10 -0
- package/dist/index.js +57 -37
- package/dist/internal.d.ts +1 -0
- package/dist/internal.js +98 -76
- package/dist/layers.d.ts +3 -1
- package/dist/lint-report.d.ts +70 -0
- package/dist/profile.d.ts +10 -2
- package/dist/react/DetailPanel.d.ts +31 -1
- package/dist/react/DetailPanel.js +8 -4
- package/dist/react/EdgeMark.d.ts +22 -0
- package/dist/react/EditPanel.d.ts +6 -6
- package/dist/react/GraphCanvas.d.ts +17 -6
- package/dist/react/GraphCanvas.js +4 -4
- package/dist/react/Inspector.d.ts +72 -0
- package/dist/react/ObjectRef.d.ts +12 -0
- package/dist/react/Toolbar.d.ts +10 -3
- package/dist/react/ZoomBoundary.d.ts +4 -0
- package/dist/react/camera.d.ts +7 -0
- package/dist/react/i18n.d.ts +2 -2
- package/dist/react/icons.d.ts +7 -3
- package/dist/react/input.d.ts +5 -3
- package/dist/react/useSubgraph.d.ts +15 -0
- package/dist/shell.d.ts +1 -0
- package/dist/strings.d.ts +23 -2
- package/dist/style.d.ts +2 -0
- package/dist/subgraph.d.ts +13 -0
- package/dist/tree.d.ts +1 -0
- package/dist/view.d.ts +3 -1
- package/package.json +1 -1
- package/dist/chunks/chunk-3KUNYSJE.js +0 -246
- package/dist/chunks/chunk-LK77SYCN.js +0 -100
- package/dist/chunks/chunk-Q35ZKWKF.js +0 -99
- package/dist/react/GlassPlanes.d.ts +0 -11
|
@@ -1,70 +1,86 @@
|
|
|
1
1
|
import {
|
|
2
|
-
DIFF_COLORS,
|
|
3
|
-
DIFF_INK,
|
|
4
|
-
EDGE_W,
|
|
5
2
|
FADE_BASE,
|
|
6
3
|
FADE_NAMES,
|
|
7
4
|
FULL_VIEW,
|
|
8
|
-
GK_CSS,
|
|
9
|
-
LABEL_MAX_EM,
|
|
10
|
-
LIGHT_THEME,
|
|
11
|
-
NODE_BASE,
|
|
12
|
-
PAST_KINDS,
|
|
13
|
-
PLANE_HUES,
|
|
14
5
|
SKIN_SIZE_PROPS,
|
|
15
|
-
STEP_FLAG,
|
|
16
|
-
VIRTUAL_ROOT,
|
|
17
6
|
anchorOf,
|
|
18
|
-
buildElements,
|
|
19
|
-
checkEdit,
|
|
20
|
-
chromeStyle,
|
|
21
|
-
cls,
|
|
22
|
-
defaultNodeColor,
|
|
23
7
|
defaultProfile,
|
|
24
|
-
|
|
8
|
+
deriveLayers,
|
|
25
9
|
diffSkinStyle,
|
|
26
10
|
edgeFade,
|
|
27
|
-
edgeKindClass,
|
|
28
11
|
edgeTraffic,
|
|
29
|
-
edgesOf,
|
|
30
|
-
graphStyle,
|
|
31
|
-
indexModel,
|
|
32
12
|
isFiltering,
|
|
33
|
-
isNarrowing,
|
|
34
13
|
kindTable,
|
|
35
|
-
|
|
36
|
-
nodeWeight,
|
|
37
|
-
originView,
|
|
38
|
-
originsOf,
|
|
14
|
+
layerView,
|
|
39
15
|
planSkins,
|
|
40
16
|
planTransition,
|
|
41
17
|
planeView,
|
|
42
|
-
|
|
18
|
+
projectSubgraph,
|
|
43
19
|
queryMarker,
|
|
44
20
|
resolveSpec,
|
|
45
21
|
resolveView,
|
|
46
22
|
sampleSkinStyle,
|
|
47
23
|
sampleTransition,
|
|
48
24
|
searchNodes,
|
|
49
|
-
shareT,
|
|
50
|
-
skeletonColor,
|
|
51
25
|
solveDiffLayout,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
untheme,
|
|
56
|
-
validateModel
|
|
57
|
-
} from "./chunk-FNTYI7VP.js";
|
|
26
|
+
subgraphFloors,
|
|
27
|
+
validateModelBySource
|
|
28
|
+
} from "./chunk-DHYIMBHU.js";
|
|
58
29
|
import {
|
|
59
|
-
|
|
30
|
+
EdgeMark,
|
|
31
|
+
EdgeMarks,
|
|
60
32
|
I,
|
|
61
33
|
Icon,
|
|
34
|
+
Inspector,
|
|
35
|
+
InspectorField,
|
|
36
|
+
NodeDot,
|
|
37
|
+
NodeRef,
|
|
38
|
+
NodeRelations,
|
|
39
|
+
ObjectDetails,
|
|
40
|
+
ObjectRef,
|
|
62
41
|
StringsContext,
|
|
42
|
+
ZoomBoundary,
|
|
43
|
+
childrenOf,
|
|
44
|
+
edgeKindHidden,
|
|
45
|
+
edgeMarksFor,
|
|
46
|
+
inspect,
|
|
47
|
+
installPainter,
|
|
48
|
+
renderMarkdown,
|
|
49
|
+
shapeOf,
|
|
63
50
|
useStrings
|
|
64
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-CHOCJIOD.js";
|
|
65
52
|
import {
|
|
66
|
-
|
|
67
|
-
|
|
53
|
+
DIFF_COLORS,
|
|
54
|
+
DIFF_INK,
|
|
55
|
+
EN,
|
|
56
|
+
GK_CSS,
|
|
57
|
+
LABEL_MAX_EM,
|
|
58
|
+
LIGHT_THEME,
|
|
59
|
+
PAST_KINDS,
|
|
60
|
+
PLANE_HUES,
|
|
61
|
+
STEP_FLAG,
|
|
62
|
+
VIRTUAL_ROOT,
|
|
63
|
+
buildElements,
|
|
64
|
+
checkEdit,
|
|
65
|
+
chromeStyle,
|
|
66
|
+
cls,
|
|
67
|
+
defaultNodeColor,
|
|
68
|
+
diffModels,
|
|
69
|
+
edgeKey,
|
|
70
|
+
edgesOf,
|
|
71
|
+
graphStyle,
|
|
72
|
+
indexModel,
|
|
73
|
+
mixHex,
|
|
74
|
+
nodeWeight,
|
|
75
|
+
originsOf,
|
|
76
|
+
plateColors,
|
|
77
|
+
sameEdge,
|
|
78
|
+
skeletonColor,
|
|
79
|
+
stepUnion,
|
|
80
|
+
themeColor,
|
|
81
|
+
unionSides,
|
|
82
|
+
untheme
|
|
83
|
+
} from "./chunk-NDUF3CBQ.js";
|
|
68
84
|
import {
|
|
69
85
|
LAYOUTS,
|
|
70
86
|
inlinePool
|
|
@@ -76,698 +92,6 @@ import {
|
|
|
76
92
|
// src/react/GraphCanvas.tsx
|
|
77
93
|
import { useCallback as useCallback2, useEffect as useEffect4, useMemo as useMemo5, useRef as useRef4, useState as useState5 } from "react";
|
|
78
94
|
|
|
79
|
-
// src/paint.ts
|
|
80
|
-
var MIN_DOT = 2;
|
|
81
|
-
var MIN_LINE = 1;
|
|
82
|
-
var HOLD_LEAF = 4;
|
|
83
|
-
var NODE_SLACK = 4;
|
|
84
|
-
var SKEL_FLOOR = 4;
|
|
85
|
-
var SKEL_CURVE = 1.2;
|
|
86
|
-
var SEM_W = 1;
|
|
87
|
-
var SEM_INK = 0.05;
|
|
88
|
-
var SEM_BOOST = 2;
|
|
89
|
-
var FOCUS_INK = 16;
|
|
90
|
-
var focusAlphaOf = (n, ink = FOCUS_INK) => Math.min(1, Math.sqrt(ink / Math.max(1, n)));
|
|
91
|
-
var DETAIL_LEAF = 6;
|
|
92
|
-
var GAP = [3, 9];
|
|
93
|
-
var GAP_MAX = 1.5;
|
|
94
|
-
var HAZE_R = 1.4;
|
|
95
|
-
var HAZE_MAX = 0.32;
|
|
96
|
-
var HOVER_DIM = 0.4;
|
|
97
|
-
var HOVER_FADE_MS = 160;
|
|
98
|
-
var MUTE_FADE_MS = 240;
|
|
99
|
-
var clamp01 = (v) => Math.max(0, Math.min(1, v));
|
|
100
|
-
var ramp = (v, [a, b]) => clamp01((v - a) / (b - a));
|
|
101
|
-
var dotOf = (d, z, w = 0, leafPx = Infinity, hold = HOLD_LEAF) => {
|
|
102
|
-
const s = d * z * Math.max(1, w * hold / leafPx);
|
|
103
|
-
return s >= MIN_DOT ? [s, 1] : [MIN_DOT, (s / MIN_DOT) ** 2];
|
|
104
|
-
};
|
|
105
|
-
var gapOf = (px) => GAP_MAX * ramp(px, GAP);
|
|
106
|
-
var skeletonLineOf = (w, z, t) => {
|
|
107
|
-
const s = Math.max(w * z, SKEL_FLOOR * t ** SKEL_CURVE);
|
|
108
|
-
return s >= MIN_LINE ? [s, 1] : [MIN_LINE, s / MIN_LINE];
|
|
109
|
-
};
|
|
110
|
-
var semanticAlphaOf = (opacity, cover) => Math.min(1, opacity * Math.min(SEM_BOOST, Math.sqrt(SEM_INK / Math.max(cover, 1e-9))));
|
|
111
|
-
var clippedLength = (ax, ay, bx, by, W, H) => {
|
|
112
|
-
let t0 = 0, t1 = 1;
|
|
113
|
-
const dx = bx - ax, dy = by - ay;
|
|
114
|
-
for (const [p, q2] of [[-dx, ax], [dx, W - ax], [-dy, ay], [dy, H - ay]]) {
|
|
115
|
-
if (p === 0) {
|
|
116
|
-
if (q2 < 0) return 0;
|
|
117
|
-
continue;
|
|
118
|
-
}
|
|
119
|
-
const r = q2 / p;
|
|
120
|
-
if (p < 0) {
|
|
121
|
-
if (r > t1) return 0;
|
|
122
|
-
if (r > t0) t0 = r;
|
|
123
|
-
} else {
|
|
124
|
-
if (r < t0) return 0;
|
|
125
|
-
if (r < t1) t1 = r;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return Math.hypot(dx, dy) * (t1 - t0);
|
|
129
|
-
};
|
|
130
|
-
var hazeOf = (leafPx) => HAZE_MAX * (1 - ramp(leafPx, GAP));
|
|
131
|
-
var EDGE_REACH = 0.5;
|
|
132
|
-
var reachOf = (vis, lineW, touch = false, base = EDGE_REACH) => (base * (touch ? 2.4 : 1) + lineW / 2) * vis;
|
|
133
|
-
var hittable = (reach) => reach * 2 >= 1;
|
|
134
|
-
var detailed = (leafPx) => leafPx >= DETAIL_LEAF;
|
|
135
|
-
var edgeKindHidden = (skeleton, kind, hidden) => !skeleton && hidden.has(kind);
|
|
136
|
-
var shapeOf = (name) => /hexagon|octagon|pentagon|heptagon/.test(name) ? "hexagon" : /diamond/.test(name) ? "diamond" : /rectangle|square|barrel|tag/.test(name) ? "rect" : "circle";
|
|
137
|
-
var arrowOf = (name) => name === "none" ? "none" : name === "tee" ? "tee" : "triangle";
|
|
138
|
-
function installPainter(cy, opts) {
|
|
139
|
-
const r = cy.renderer();
|
|
140
|
-
const baseRender = r.render;
|
|
141
|
-
const baseFind = r.findNearestElements;
|
|
142
|
-
let nodes = [], parents = [], edges = [];
|
|
143
|
-
let byId = /* @__PURE__ */ new Map();
|
|
144
|
-
let stale = true;
|
|
145
|
-
const dirty = /* @__PURE__ */ new Set();
|
|
146
|
-
let needs = true;
|
|
147
|
-
const readNode = (rec) => {
|
|
148
|
-
const e = rec.ele;
|
|
149
|
-
rec.vis = e.visible();
|
|
150
|
-
rec.op = e.effectiveOpacity();
|
|
151
|
-
rec.fill = e.pstyle("background-color").strValue;
|
|
152
|
-
rec.border = e.pstyle("border-color").strValue;
|
|
153
|
-
rec.bw = e.pstyle("border-width").pfValue;
|
|
154
|
-
rec.d = rec.parent ? 0 : e.width();
|
|
155
|
-
rec.shape = rec.parent ? "rect" : shapeOf(e.pstyle("shape").value);
|
|
156
|
-
rec.bgOp = e.pstyle("background-opacity").value;
|
|
157
|
-
rec.events = e.pstyle("events").value !== "no";
|
|
158
|
-
};
|
|
159
|
-
const readEdge = (rec) => {
|
|
160
|
-
const e = rec.ele;
|
|
161
|
-
rec.vis = e.pstyle("display").value !== "none" && e.pstyle("visibility").value === "visible";
|
|
162
|
-
rec.op = e.effectiveOpacity() * e.pstyle("line-opacity").value;
|
|
163
|
-
rec.color = e.pstyle("line-color").strValue;
|
|
164
|
-
rec.w = e.pstyle("width").pfValue;
|
|
165
|
-
rec.dash = e.pstyle("line-style").value;
|
|
166
|
-
rec.head = arrowOf(e.pstyle("target-arrow-shape").value);
|
|
167
|
-
rec.tail = arrowOf(e.pstyle("source-arrow-shape").value);
|
|
168
|
-
rec.z = e.pstyle("z-index").value;
|
|
169
|
-
const curve = e.pstyle("curve-style").value;
|
|
170
|
-
rec.bend = curve === "unbundled-bezier" ? e.pstyle("control-point-distances").pfValue?.[0] ?? 0 : 0;
|
|
171
|
-
rec.events = e.pstyle("events").value !== "no";
|
|
172
|
-
};
|
|
173
|
-
const rebuild = () => {
|
|
174
|
-
nodes = [];
|
|
175
|
-
parents = [];
|
|
176
|
-
edges = [];
|
|
177
|
-
byId = /* @__PURE__ */ new Map();
|
|
178
|
-
cy.nodes().forEach((ele) => {
|
|
179
|
-
const rec = {
|
|
180
|
-
ele,
|
|
181
|
-
id: ele.id(),
|
|
182
|
-
parent: ele.isParent(),
|
|
183
|
-
t: shareT(ele.data("share") ?? 0),
|
|
184
|
-
w: nodeWeight(ele.data("leaves") ?? 0),
|
|
185
|
-
depth: ele.ancestors().length,
|
|
186
|
-
x: 0,
|
|
187
|
-
y: 0,
|
|
188
|
-
s: 0,
|
|
189
|
-
a: 1
|
|
190
|
-
};
|
|
191
|
-
readNode(rec);
|
|
192
|
-
(rec.parent ? parents : nodes).push(rec);
|
|
193
|
-
byId.set(rec.id, rec);
|
|
194
|
-
});
|
|
195
|
-
parents.sort((a, b) => a.depth - b.depth);
|
|
196
|
-
cy.edges().forEach((ele) => {
|
|
197
|
-
const src = byId.get(ele.source().id()), tgt = byId.get(ele.target().id());
|
|
198
|
-
if (!src || !tgt) return;
|
|
199
|
-
const rec = { ele, id: ele.id(), src, tgt, skeleton: ele.hasClass("contains"), t: shareT(ele.data("share") ?? 0) };
|
|
200
|
-
readEdge(rec);
|
|
201
|
-
edges.push(rec);
|
|
202
|
-
byId.set(rec.id, rec);
|
|
203
|
-
});
|
|
204
|
-
edges = byZ(edges);
|
|
205
|
-
stale = false;
|
|
206
|
-
dirty.clear();
|
|
207
|
-
remute();
|
|
208
|
-
repin();
|
|
209
|
-
};
|
|
210
|
-
const refresh = () => {
|
|
211
|
-
if (stale) {
|
|
212
|
-
rebuild();
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
if (!dirty.size) return;
|
|
216
|
-
let reorder = false;
|
|
217
|
-
for (const ele of dirty) {
|
|
218
|
-
if (ele.removed()) continue;
|
|
219
|
-
const rec = byId.get(ele.id());
|
|
220
|
-
if (!rec) {
|
|
221
|
-
stale = true;
|
|
222
|
-
break;
|
|
223
|
-
}
|
|
224
|
-
if ("src" in rec) {
|
|
225
|
-
const z = rec.z;
|
|
226
|
-
readEdge(rec);
|
|
227
|
-
if (rec.z !== z) reorder = true;
|
|
228
|
-
} else readNode(rec);
|
|
229
|
-
}
|
|
230
|
-
dirty.clear();
|
|
231
|
-
if (stale) rebuild();
|
|
232
|
-
else if (reorder) edges = byZ(edges);
|
|
233
|
-
};
|
|
234
|
-
const onStyle = (e) => {
|
|
235
|
-
const t = e.target;
|
|
236
|
-
dirty.add(t);
|
|
237
|
-
if (t.isNode() && t.isParent()) t.descendants().forEach((d) => dirty.add(d));
|
|
238
|
-
needs = true;
|
|
239
|
-
};
|
|
240
|
-
const onStructure = () => {
|
|
241
|
-
stale = true;
|
|
242
|
-
needs = true;
|
|
243
|
-
};
|
|
244
|
-
const onMove = () => {
|
|
245
|
-
needs = true;
|
|
246
|
-
};
|
|
247
|
-
cy.on("style", onStyle);
|
|
248
|
-
cy.on("add remove data move", onStructure);
|
|
249
|
-
cy.on("position viewport", onMove);
|
|
250
|
-
let focusIds = /* @__PURE__ */ new Set();
|
|
251
|
-
let lifted = /* @__PURE__ */ new Set();
|
|
252
|
-
let semCover = 0;
|
|
253
|
-
let hovered = null;
|
|
254
|
-
let hoverT = 0, hoverFrom = 0, hoverTo = 0;
|
|
255
|
-
let target = null;
|
|
256
|
-
let spot = null;
|
|
257
|
-
let muteKinds = { nodes: /* @__PURE__ */ new Set(), edges: /* @__PURE__ */ new Set() };
|
|
258
|
-
let mutedIds = /* @__PURE__ */ new Set();
|
|
259
|
-
let pinned = /* @__PURE__ */ new Set();
|
|
260
|
-
let mutedFrom = /* @__PURE__ */ new Set();
|
|
261
|
-
let muteT = 1, muteStart = 0;
|
|
262
|
-
const mutedNow = () => {
|
|
263
|
-
const out = /* @__PURE__ */ new Set();
|
|
264
|
-
if (!muteKinds.nodes.size && !muteKinds.edges.size) return out;
|
|
265
|
-
for (const n of [...nodes, ...parents]) if (muteKinds.nodes.has(n.ele.data("kind"))) out.add(n.id);
|
|
266
|
-
for (const e of edges) {
|
|
267
|
-
if (edgeKindHidden(e.skeleton, e.ele.data("kind"), muteKinds.edges) || out.has(e.src.id) || out.has(e.tgt.id)) out.add(e.id);
|
|
268
|
-
}
|
|
269
|
-
return out;
|
|
270
|
-
};
|
|
271
|
-
const remute = () => {
|
|
272
|
-
mutedIds = mutedFrom = mutedNow();
|
|
273
|
-
muteT = 1;
|
|
274
|
-
};
|
|
275
|
-
const repin = () => {
|
|
276
|
-
const sel = cy.$(":selected");
|
|
277
|
-
pinned = new Set(sel.nonempty() ? sel.closedNeighborhood().map((x) => x.id()) : []);
|
|
278
|
-
};
|
|
279
|
-
const shownIn2 = (set, id) => !set.has(id) || pinned.has(id) ? 1 : focusIds.has(id) ? smooth(hoverT) : 0;
|
|
280
|
-
const muteOf = (id) => {
|
|
281
|
-
const to = shownIn2(mutedIds, id);
|
|
282
|
-
if (muteT >= 1) return to;
|
|
283
|
-
const from = shownIn2(mutedFrom, id);
|
|
284
|
-
return from + (to - from) * smooth(muteT);
|
|
285
|
-
};
|
|
286
|
-
const settleFocus = (instant) => {
|
|
287
|
-
const live = target && !target.removed() ? target : spot?.size ? cy.collection([...spot].map((id) => cy.$id(id)).filter((x) => x.nonempty())) : null;
|
|
288
|
-
if (live && live.nonempty()) {
|
|
289
|
-
const one = live === target;
|
|
290
|
-
const focus = !one ? live : target.isNode() ? target.closedNeighborhood() : target.union(target.connectedNodes());
|
|
291
|
-
focusIds = new Set(focus.map((x) => x.id()));
|
|
292
|
-
lifted = /* @__PURE__ */ new Set([...focusIds, ...focus.nodes().ancestors().map((x) => x.id())]);
|
|
293
|
-
hovered = one ? target.id() : null;
|
|
294
|
-
if (hoverTo !== 1) {
|
|
295
|
-
hoverFrom = performance.now() - hoverT * HOVER_FADE_MS;
|
|
296
|
-
hoverTo = 1;
|
|
297
|
-
}
|
|
298
|
-
} else {
|
|
299
|
-
if (instant) {
|
|
300
|
-
hoverT = 0;
|
|
301
|
-
focusIds = /* @__PURE__ */ new Set();
|
|
302
|
-
lifted = /* @__PURE__ */ new Set();
|
|
303
|
-
hovered = null;
|
|
304
|
-
}
|
|
305
|
-
if (hoverTo !== 0) {
|
|
306
|
-
hoverFrom = performance.now() - (1 - hoverT) * HOVER_FADE_MS;
|
|
307
|
-
hoverTo = 0;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
needs = true;
|
|
311
|
-
r.redraw();
|
|
312
|
-
};
|
|
313
|
-
const hover = (t, instant = false) => {
|
|
314
|
-
target = t;
|
|
315
|
-
settleFocus(instant);
|
|
316
|
-
};
|
|
317
|
-
const mute = (nodeKinds, edgeKinds) => {
|
|
318
|
-
const same = (a, b) => a.size === b.length && b.every((k) => a.has(k));
|
|
319
|
-
if (same(muteKinds.nodes, nodeKinds) && same(muteKinds.edges, edgeKinds)) return;
|
|
320
|
-
muteKinds = { nodes: new Set(nodeKinds), edges: new Set(edgeKinds) };
|
|
321
|
-
if (!stale) {
|
|
322
|
-
const next = mutedNow();
|
|
323
|
-
const back = muteT < 1 && next.size === mutedFrom.size && [...next].every((id) => mutedFrom.has(id));
|
|
324
|
-
const t = back ? 1 - muteT : 0;
|
|
325
|
-
mutedFrom = mutedIds;
|
|
326
|
-
mutedIds = next;
|
|
327
|
-
muteT = t;
|
|
328
|
-
muteStart = performance.now() - t * MUTE_FADE_MS;
|
|
329
|
-
}
|
|
330
|
-
needs = true;
|
|
331
|
-
r.redraw();
|
|
332
|
-
};
|
|
333
|
-
const onSelect = () => {
|
|
334
|
-
repin();
|
|
335
|
-
needs = true;
|
|
336
|
-
r.redraw();
|
|
337
|
-
};
|
|
338
|
-
cy.on("select unselect", onSelect);
|
|
339
|
-
const spotlight = (ids2) => {
|
|
340
|
-
spot = ids2?.size ? ids2 : null;
|
|
341
|
-
settleFocus(false);
|
|
342
|
-
};
|
|
343
|
-
const stepHover = (now) => {
|
|
344
|
-
if (hoverT === hoverTo) return false;
|
|
345
|
-
const k = Math.min(1, (now - hoverFrom) / HOVER_FADE_MS);
|
|
346
|
-
hoverT = hoverTo ? k : 1 - k;
|
|
347
|
-
if (k >= 1) {
|
|
348
|
-
hoverT = hoverTo;
|
|
349
|
-
if (!hoverTo) {
|
|
350
|
-
focusIds = /* @__PURE__ */ new Set();
|
|
351
|
-
lifted = /* @__PURE__ */ new Set();
|
|
352
|
-
hovered = null;
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
return true;
|
|
356
|
-
};
|
|
357
|
-
const stepMute = (now) => {
|
|
358
|
-
if (muteT >= 1) return false;
|
|
359
|
-
muteT = Math.min(1, (now - muteStart) / MUTE_FADE_MS);
|
|
360
|
-
if (muteT >= 1) mutedFrom = mutedIds;
|
|
361
|
-
return true;
|
|
362
|
-
};
|
|
363
|
-
const dimNow = () => 1 - (1 - HOVER_DIM) * smooth(hoverT);
|
|
364
|
-
let wasActive = false;
|
|
365
|
-
let lastSize = "";
|
|
366
|
-
const ids = [/* @__PURE__ */ new Map(), /* @__PURE__ */ new Map(), /* @__PURE__ */ new Map()];
|
|
367
|
-
const idOf = (m) => (c) => m.get(c) ?? m.set(c, m.size).get(c);
|
|
368
|
-
const fillId = idOf(ids[0]), borderId = idOf(ids[1]), lineId = idOf(ids[2]);
|
|
369
|
-
const paint = () => {
|
|
370
|
-
const pr = r.getPixelRatio();
|
|
371
|
-
if (r.prevPxRatio !== pr) {
|
|
372
|
-
r.invalidateContainerClientCoordsCache();
|
|
373
|
-
r.matchCanvasSize(r.container);
|
|
374
|
-
}
|
|
375
|
-
r.prevPxRatio = pr;
|
|
376
|
-
const size = `${r.canvasWidth}x${r.canvasHeight}`;
|
|
377
|
-
const now = performance.now();
|
|
378
|
-
const hovering = stepHover(now), muting = stepMute(now);
|
|
379
|
-
const animating = hovering || muting;
|
|
380
|
-
if (r.hoverData?.selecting || r.touchData?.selecting) needs = true;
|
|
381
|
-
if (!needs && !animating && size === lastSize) return;
|
|
382
|
-
needs = false;
|
|
383
|
-
lastSize = size;
|
|
384
|
-
refresh();
|
|
385
|
-
for (const m of ids) m.clear();
|
|
386
|
-
const ctx = r.data.contexts[r.NODE];
|
|
387
|
-
for (const c of r.data.contexts) {
|
|
388
|
-
c.setTransform(1, 0, 0, 1, 0, 0);
|
|
389
|
-
c.clearRect(0, 0, r.canvasWidth, r.canvasHeight);
|
|
390
|
-
}
|
|
391
|
-
ctx.setTransform(pr, 0, 0, pr, 0, 0);
|
|
392
|
-
const W = r.canvasWidth / pr, H = r.canvasHeight / pr;
|
|
393
|
-
const z = cy.zoom(), pan = cy.pan();
|
|
394
|
-
const leafPx = NODE_BASE * opts.nodeScale() * z;
|
|
395
|
-
const dim = dimNow();
|
|
396
|
-
const mulOf = (id) => (hoverT > 0 && !lifted.has(id) ? dim : 1) * muteOf(id);
|
|
397
|
-
const PAD3 = 40;
|
|
398
|
-
const onScreen = (x, y, rad) => x + rad > -PAD3 && x - rad < W + PAD3 && y + rad > -PAD3 && y - rad < H + PAD3;
|
|
399
|
-
const hold = HOLD_LEAF;
|
|
400
|
-
for (const n of nodes) {
|
|
401
|
-
if (!n.vis) continue;
|
|
402
|
-
const p = n.ele.position();
|
|
403
|
-
n.x = p.x * z + pan.x;
|
|
404
|
-
n.y = p.y * z + pan.y;
|
|
405
|
-
[n.s, n.a] = dotOf(n.d, z, n.w, leafPx, hold);
|
|
406
|
-
}
|
|
407
|
-
for (const n of parents) {
|
|
408
|
-
if (!n.vis) continue;
|
|
409
|
-
const bb = n.ele.boundingBox({ includeLabels: false, includeOverlays: false, includeUnderlays: false });
|
|
410
|
-
n.box = [bb.x1 * z + pan.x, bb.y1 * z + pan.y, bb.w * z, bb.h * z];
|
|
411
|
-
n.x = n.box[0] + n.box[2] / 2;
|
|
412
|
-
n.y = n.box[1] + n.box[3] / 2;
|
|
413
|
-
n.s = 0;
|
|
414
|
-
n.a = 1;
|
|
415
|
-
}
|
|
416
|
-
ctx.lineJoin = "round";
|
|
417
|
-
drawBoxes(ctx, z, mulOf);
|
|
418
|
-
const haze = hazeOf(leafPx);
|
|
419
|
-
if (haze > 5e-3) drawHaze(ctx, z, haze, mulOf, onScreen);
|
|
420
|
-
let ink = 0;
|
|
421
|
-
for (const e of edges) {
|
|
422
|
-
if (e.skeleton || !e.vis || !e.src.vis || !e.tgt.vis) continue;
|
|
423
|
-
ink += clippedLength(e.src.x, e.src.y, e.tgt.x, e.tgt.y, W, H) * (SEM_W * e.w / EDGE_W) * e.op;
|
|
424
|
-
}
|
|
425
|
-
semCover = ink / (W * H);
|
|
426
|
-
drawEdges(ctx, edges, z, leafPx, mulOf, W, H, false);
|
|
427
|
-
drawNodes(ctx, nodes, mulOf, onScreen);
|
|
428
|
-
if (hoverT > 0 && focusIds.size) {
|
|
429
|
-
drawEdges(ctx, edges.filter((e) => focusIds.has(e.id)), z, leafPx, () => 1, W, H, true);
|
|
430
|
-
drawNodes(ctx, nodes.filter((n) => focusIds.has(n.id)), () => 1, onScreen);
|
|
431
|
-
const h = hovered ? byId.get(hovered) : null;
|
|
432
|
-
if (h && !("src" in h) && !h.parent && h.vis) {
|
|
433
|
-
ctx.globalAlpha = 0.5 * smooth(hoverT);
|
|
434
|
-
ctx.strokeStyle = opts.theme().halo;
|
|
435
|
-
ctx.lineWidth = 2;
|
|
436
|
-
ctx.beginPath();
|
|
437
|
-
ctx.arc(h.x, h.y, h.s / 2 + gapOf(h.s) + 3, 0, Math.PI * 2);
|
|
438
|
-
ctx.stroke();
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
drawSelectionBox(ctx, z, pan);
|
|
442
|
-
ctx.globalAlpha = 1;
|
|
443
|
-
if (animating) queueMicrotask(() => r.redraw());
|
|
444
|
-
};
|
|
445
|
-
const drawBoxes = (ctx, z, mulOf) => {
|
|
446
|
-
for (const n of parents) {
|
|
447
|
-
if (!n.vis || !n.box) continue;
|
|
448
|
-
const m = n.op * mulOf(n.id);
|
|
449
|
-
if (m < 0.01) continue;
|
|
450
|
-
const [x, y, w, h] = n.box;
|
|
451
|
-
const rad = Math.min(10, w / 4, h / 4);
|
|
452
|
-
ctx.beginPath();
|
|
453
|
-
ctx.roundRect(x, y, w, h, rad);
|
|
454
|
-
ctx.globalAlpha = n.bgOp * m;
|
|
455
|
-
ctx.fillStyle = n.fill;
|
|
456
|
-
ctx.fill();
|
|
457
|
-
const [lw, la] = skeletonLineOf(n.bw, z, n.t);
|
|
458
|
-
ctx.globalAlpha = la * m;
|
|
459
|
-
ctx.strokeStyle = n.border;
|
|
460
|
-
ctx.lineWidth = lw;
|
|
461
|
-
ctx.stroke();
|
|
462
|
-
}
|
|
463
|
-
};
|
|
464
|
-
const drawHaze = (ctx, z, haze, mulOf, onScreen) => {
|
|
465
|
-
const groups = /* @__PURE__ */ new Map();
|
|
466
|
-
for (const n of nodes) {
|
|
467
|
-
if (!n.vis) continue;
|
|
468
|
-
const rad = n.d * HAZE_R * z;
|
|
469
|
-
if (!onScreen(n.x, n.y, rad)) continue;
|
|
470
|
-
const a = q(haze * n.op * mulOf(n.id), 0.02);
|
|
471
|
-
if (a < 0.01) continue;
|
|
472
|
-
const key = fillId(n.fill) * 64 + Math.round(a * 50);
|
|
473
|
-
let g = groups.get(key);
|
|
474
|
-
if (!g) groups.set(key, g = { c: n.fill, a, list: [] });
|
|
475
|
-
g.list.push(n);
|
|
476
|
-
}
|
|
477
|
-
for (const g of groups.values()) {
|
|
478
|
-
ctx.globalAlpha = g.a;
|
|
479
|
-
ctx.fillStyle = g.c;
|
|
480
|
-
ctx.beginPath();
|
|
481
|
-
for (const n of g.list) {
|
|
482
|
-
const rad = n.d * HAZE_R * z;
|
|
483
|
-
ctx.moveTo(n.x + rad, n.y);
|
|
484
|
-
ctx.arc(n.x, n.y, rad, 0, Math.PI * 2);
|
|
485
|
-
}
|
|
486
|
-
ctx.fill();
|
|
487
|
-
}
|
|
488
|
-
};
|
|
489
|
-
const drawEdges = (ctx, list, z, leafPx, mulOf, W, H, focus) => {
|
|
490
|
-
const near = detailed(leafPx);
|
|
491
|
-
const semA = semanticAlphaOf(opts.semanticOpacity(), semCover);
|
|
492
|
-
const focusA = focus ? focusAlphaOf(list.reduce((k, e) => k + (e.skeleton ? 0 : 1), 0)) : 0;
|
|
493
|
-
let layer = null;
|
|
494
|
-
let groups = /* @__PURE__ */ new Map();
|
|
495
|
-
const flush = () => {
|
|
496
|
-
for (const g of groups.values()) strokeGroup(ctx, g, z, near);
|
|
497
|
-
groups = /* @__PURE__ */ new Map();
|
|
498
|
-
};
|
|
499
|
-
for (const e of list) {
|
|
500
|
-
if (!e.vis || !e.src.vis || !e.tgt.vis) continue;
|
|
501
|
-
const a = e.src, b = e.tgt;
|
|
502
|
-
if (Math.max(a.x, b.x) < -40 || Math.min(a.x, b.x) > W + 40 || Math.max(a.y, b.y) < -40 || Math.min(a.y, b.y) > H + 40) continue;
|
|
503
|
-
if (e.z !== layer) {
|
|
504
|
-
flush();
|
|
505
|
-
layer = e.z;
|
|
506
|
-
}
|
|
507
|
-
let w, al;
|
|
508
|
-
if (e.skeleton) [w, al] = skeletonLineOf(e.w, z, e.t);
|
|
509
|
-
else [w, al] = [SEM_W * e.w / EDGE_W, focus ? focusA : semA];
|
|
510
|
-
al *= e.op * mulOf(e.id);
|
|
511
|
-
if (al < 0.01) continue;
|
|
512
|
-
const wq = q(w, 0.25) || 0.25, aq = q(al, 0.05) || 0.05;
|
|
513
|
-
const dash = e.dash === "solid" || !near ? 0 : e.dash === "dashed" ? 1 : 2;
|
|
514
|
-
const key = ((lineId(e.color) * 4096 + Math.round(wq * 4)) * 32 + Math.round(aq * 20)) * 3 + dash;
|
|
515
|
-
let g = groups.get(key);
|
|
516
|
-
if (!g) groups.set(key, g = { c: e.color, w: wq, a: aq, dash, list: [] });
|
|
517
|
-
g.list.push(e);
|
|
518
|
-
}
|
|
519
|
-
flush();
|
|
520
|
-
ctx.setLineDash([]);
|
|
521
|
-
};
|
|
522
|
-
const drawNodes = (ctx, list, mulOf, onScreen) => {
|
|
523
|
-
const groups = /* @__PURE__ */ new Map();
|
|
524
|
-
const marked = [];
|
|
525
|
-
for (const n of list) {
|
|
526
|
-
if (!n.vis || !onScreen(n.x, n.y, n.s)) continue;
|
|
527
|
-
const a = q(n.a * n.op * mulOf(n.id), 0.05);
|
|
528
|
-
if (a < 0.01) continue;
|
|
529
|
-
const gap = q(gapOf(n.s), 0.25);
|
|
530
|
-
const shapeK = n.shape === "circle" ? 0 : n.shape === "hexagon" ? 1 : n.shape === "diamond" ? 2 : 3;
|
|
531
|
-
const key = (((fillId(n.fill) * 65536 + borderId(n.border)) * 32 + Math.round(a * 20)) * 8 + gap * 4) * 4 + shapeK;
|
|
532
|
-
let g = groups.get(key);
|
|
533
|
-
if (!g) groups.set(key, g = { c: n.fill, border: n.border, a, gap, shape: n.shape, list: [] });
|
|
534
|
-
g.list.push(n);
|
|
535
|
-
if (n.bw > 1.5) marked.push(n);
|
|
536
|
-
}
|
|
537
|
-
for (const g of groups.values()) {
|
|
538
|
-
ctx.globalAlpha = g.a;
|
|
539
|
-
ctx.beginPath();
|
|
540
|
-
for (const n of g.list) tracePoint(ctx, g.shape, n.x, n.y, n.s / 2);
|
|
541
|
-
if (g.gap > 0) {
|
|
542
|
-
ctx.strokeStyle = g.border;
|
|
543
|
-
ctx.lineWidth = g.gap * 2;
|
|
544
|
-
ctx.stroke();
|
|
545
|
-
}
|
|
546
|
-
ctx.fillStyle = g.c;
|
|
547
|
-
ctx.fill();
|
|
548
|
-
}
|
|
549
|
-
for (const n of marked) {
|
|
550
|
-
ctx.globalAlpha = n.op * mulOf(n.id);
|
|
551
|
-
ctx.strokeStyle = n.border;
|
|
552
|
-
ctx.lineWidth = 2;
|
|
553
|
-
ctx.beginPath();
|
|
554
|
-
tracePoint(ctx, n.shape, n.x, n.y, n.s / 2 + gapOf(n.s) + 1.5);
|
|
555
|
-
ctx.stroke();
|
|
556
|
-
}
|
|
557
|
-
};
|
|
558
|
-
const drawSelectionBox = (ctx, z, pan) => {
|
|
559
|
-
const sel = r.selection;
|
|
560
|
-
if (!sel || sel[4] !== 1 || !(r.hoverData?.selecting || r.touchData?.selecting)) return;
|
|
561
|
-
const t = opts.theme();
|
|
562
|
-
const x = sel[0] * z + pan.x, y = sel[1] * z + pan.y, w = (sel[2] - sel[0]) * z, h = (sel[3] - sel[1]) * z;
|
|
563
|
-
ctx.globalAlpha = 0.15;
|
|
564
|
-
ctx.fillStyle = t.selected;
|
|
565
|
-
ctx.fillRect(x, y, w, h);
|
|
566
|
-
ctx.globalAlpha = 0.6;
|
|
567
|
-
ctx.strokeStyle = t.selected;
|
|
568
|
-
ctx.lineWidth = 1;
|
|
569
|
-
ctx.strokeRect(x, y, w, h);
|
|
570
|
-
};
|
|
571
|
-
const find = (mx, my, interactiveOnly, isTouch) => {
|
|
572
|
-
refresh();
|
|
573
|
-
const z = cy.zoom(), pan = cy.pan();
|
|
574
|
-
const sx = mx * z + pan.x, sy = my * z + pan.y;
|
|
575
|
-
const slack = isTouch ? 10 : NODE_SLACK;
|
|
576
|
-
const leafPx = NODE_BASE * opts.nodeScale() * z;
|
|
577
|
-
const usable = (x) => x.vis && x.op > 0.05 && (!interactiveOnly || x.events) && muteOf(x.id) > 0.5;
|
|
578
|
-
let best = null, bestD = Infinity;
|
|
579
|
-
for (const n of nodes) {
|
|
580
|
-
if (!usable(n)) continue;
|
|
581
|
-
const p = n.ele.position();
|
|
582
|
-
const x = p.x * z + pan.x, y = p.y * z + pan.y;
|
|
583
|
-
const rad = dotOf(n.d, z, n.w, leafPx)[0] / 2 + slack;
|
|
584
|
-
const d = Math.hypot(sx - x, sy - y);
|
|
585
|
-
if (d <= rad && d - rad < bestD) {
|
|
586
|
-
best = n.ele;
|
|
587
|
-
bestD = d - rad;
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
if (best) return [best];
|
|
591
|
-
const semReach = reachOf(semanticAlphaOf(1, semCover), SEM_W, isTouch);
|
|
592
|
-
for (const e of edges) {
|
|
593
|
-
if (!usable(e) || !e.src.vis || !e.tgt.vis) continue;
|
|
594
|
-
let reach = semReach * Math.max(1, e.w / EDGE_W);
|
|
595
|
-
if (e.skeleton) {
|
|
596
|
-
const [lw, la] = skeletonLineOf(e.w, z, e.t);
|
|
597
|
-
reach = reachOf(la, lw, isTouch);
|
|
598
|
-
}
|
|
599
|
-
const a = e.src.ele.position(), b = e.tgt.ele.position();
|
|
600
|
-
const d = distToEdge(sx, sy, a.x * z + pan.x, a.y * z + pan.y, b.x * z + pan.x, b.y * z + pan.y, e.bend * z);
|
|
601
|
-
if (hittable(reach) && d <= reach && d - reach < bestD) {
|
|
602
|
-
best = e.ele;
|
|
603
|
-
bestD = d - reach;
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
if (best) return [best];
|
|
607
|
-
for (let i = parents.length - 1; i >= 0; i--) {
|
|
608
|
-
const n = parents[i];
|
|
609
|
-
if (!usable(n)) continue;
|
|
610
|
-
const bb = n.ele.boundingBox({ includeLabels: false, includeOverlays: false, includeUnderlays: false });
|
|
611
|
-
if (mx >= bb.x1 && mx <= bb.x2 && my >= bb.y1 && my <= bb.y2) return [n.ele];
|
|
612
|
-
}
|
|
613
|
-
return [];
|
|
614
|
-
};
|
|
615
|
-
r.render = function render(options) {
|
|
616
|
-
const active = opts.active() && !options?.forcedContext;
|
|
617
|
-
if (active !== wasActive) {
|
|
618
|
-
wasActive = active;
|
|
619
|
-
needs = true;
|
|
620
|
-
if (!active) {
|
|
621
|
-
r.redrawHint("eles", true);
|
|
622
|
-
r.redrawHint("drag", true);
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
if (!active) return baseRender.call(r, options);
|
|
626
|
-
paint();
|
|
627
|
-
cy.emit("render");
|
|
628
|
-
};
|
|
629
|
-
r.findNearestElements = function findNearestElements(x, y, interactiveOnly, isTouch) {
|
|
630
|
-
if (!opts.active()) return baseFind.call(r, x, y, interactiveOnly, isTouch);
|
|
631
|
-
return find(x, y, interactiveOnly, isTouch);
|
|
632
|
-
};
|
|
633
|
-
r.redraw();
|
|
634
|
-
return {
|
|
635
|
-
hover,
|
|
636
|
-
spotlight,
|
|
637
|
-
focused: (id) => hoverTo === 1 && focusIds.has(id),
|
|
638
|
-
hoveredId: () => hoverTo === 1 ? hovered : null,
|
|
639
|
-
dimOf: (id) => (hoverT > 0 && !lifted.has(id) ? dimNow() : 1) * muteOf(id),
|
|
640
|
-
mute,
|
|
641
|
-
// Reads the hover **target**, not how far the fade has gone: when hover changes, the text layer must lay out the brought-out set at once.
|
|
642
|
-
hidden: (id) => mutedIds.has(id) && !pinned.has(id) && !(hoverTo === 1 && focusIds.has(id)),
|
|
643
|
-
radiusOf: (id) => {
|
|
644
|
-
if (!opts.active()) return null;
|
|
645
|
-
refresh();
|
|
646
|
-
const n = byId.get(id);
|
|
647
|
-
if (!n || "src" in n || n.parent) return null;
|
|
648
|
-
const z = cy.zoom();
|
|
649
|
-
return dotOf(n.d, z, n.w, NODE_BASE * opts.nodeScale() * z)[0] / 2;
|
|
650
|
-
},
|
|
651
|
-
repaint: () => {
|
|
652
|
-
needs = true;
|
|
653
|
-
r.redraw();
|
|
654
|
-
},
|
|
655
|
-
dispose: () => {
|
|
656
|
-
cy.off("style", onStyle);
|
|
657
|
-
cy.off("add remove data move", onStructure);
|
|
658
|
-
cy.off("position viewport", onMove);
|
|
659
|
-
cy.off("select unselect", onSelect);
|
|
660
|
-
if (!cy.destroyed()) {
|
|
661
|
-
r.render = baseRender;
|
|
662
|
-
r.findNearestElements = baseFind;
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
};
|
|
666
|
-
}
|
|
667
|
-
var q = (v, step) => Math.round(v / step) * step;
|
|
668
|
-
var byZ = (list) => list.map((e, i) => [e, i]).sort((a, b) => a[0].z - b[0].z || a[1] - b[1]).map(([e]) => e);
|
|
669
|
-
var smooth = (x) => x * x * (3 - 2 * x);
|
|
670
|
-
var controlOf = (ax, ay, bx, by, bend) => {
|
|
671
|
-
const dx = bx - ax, dy = by - ay, L = Math.hypot(dx, dy) || 1;
|
|
672
|
-
return [(ax + bx) / 2 - dy / L * bend, (ay + by) / 2 + dx / L * bend];
|
|
673
|
-
};
|
|
674
|
-
function strokeGroup(ctx, g, z, near) {
|
|
675
|
-
ctx.globalAlpha = Math.min(1, g.a);
|
|
676
|
-
ctx.strokeStyle = g.c;
|
|
677
|
-
ctx.lineWidth = g.w;
|
|
678
|
-
ctx.lineCap = "round";
|
|
679
|
-
ctx.setLineDash(g.dash === 1 ? [4, 3] : g.dash === 2 ? [1, 3] : []);
|
|
680
|
-
ctx.beginPath();
|
|
681
|
-
const heads = [];
|
|
682
|
-
for (const e of g.list) {
|
|
683
|
-
const ax = e.src.x, ay = e.src.y, bx = e.tgt.x, by = e.tgt.y;
|
|
684
|
-
ctx.moveTo(ax, ay);
|
|
685
|
-
let hx = bx - ax, hy = by - ay, tx = ax - bx, ty = ay - by;
|
|
686
|
-
if (e.bend) {
|
|
687
|
-
const [cx, cy] = controlOf(ax, ay, bx, by, e.bend * z);
|
|
688
|
-
ctx.quadraticCurveTo(cx, cy, bx, by);
|
|
689
|
-
hx = bx - cx;
|
|
690
|
-
hy = by - cy;
|
|
691
|
-
tx = ax - cx;
|
|
692
|
-
ty = ay - cy;
|
|
693
|
-
} else ctx.lineTo(bx, by);
|
|
694
|
-
const show = e.skeleton ? g.w >= 1.5 : near && Math.hypot(bx - ax, by - ay) > 40;
|
|
695
|
-
if (!show) continue;
|
|
696
|
-
if (e.head !== "none") heads.push([e, bx, by, hx, hy, true]);
|
|
697
|
-
if (e.tail !== "none") heads.push([e, ax, ay, tx, ty, false]);
|
|
698
|
-
}
|
|
699
|
-
ctx.stroke();
|
|
700
|
-
if (!heads.length) return;
|
|
701
|
-
ctx.setLineDash([]);
|
|
702
|
-
ctx.fillStyle = g.c;
|
|
703
|
-
ctx.beginPath();
|
|
704
|
-
const tees = [];
|
|
705
|
-
for (const [e, px, py, ux0, uy0, atHead] of heads) {
|
|
706
|
-
const L = Math.hypot(ux0, uy0) || 1, ux = ux0 / L, uy = uy0 / L;
|
|
707
|
-
const n = atHead ? e.tgt : e.src;
|
|
708
|
-
const rad = n.parent ? 0 : n.s / 2 + gapOf(n.s);
|
|
709
|
-
const tipX = px - ux * rad, tipY = py - uy * rad;
|
|
710
|
-
const len = e.skeleton ? g.w * 2.6 : 3 + g.w * 2.5, half = len * 0.55;
|
|
711
|
-
if ((atHead ? e.head : e.tail) === "tee") {
|
|
712
|
-
tees.push([tipX, tipY, ux, uy, half]);
|
|
713
|
-
continue;
|
|
714
|
-
}
|
|
715
|
-
ctx.moveTo(tipX, tipY);
|
|
716
|
-
ctx.lineTo(tipX - ux * len - uy * half, tipY - uy * len + ux * half);
|
|
717
|
-
ctx.lineTo(tipX - ux * len + uy * half, tipY - uy * len - ux * half);
|
|
718
|
-
ctx.closePath();
|
|
719
|
-
}
|
|
720
|
-
ctx.fill();
|
|
721
|
-
if (tees.length) {
|
|
722
|
-
ctx.beginPath();
|
|
723
|
-
for (const [x, y, ux, uy, half] of tees) {
|
|
724
|
-
const cx = x - ux * 2, cy = y - uy * 2;
|
|
725
|
-
ctx.moveTo(cx - uy * half, cy + ux * half);
|
|
726
|
-
ctx.lineTo(cx + uy * half, cy - ux * half);
|
|
727
|
-
}
|
|
728
|
-
ctx.lineWidth = Math.max(1.5, g.w);
|
|
729
|
-
ctx.stroke();
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
function tracePoint(ctx, shape, x, y, rad) {
|
|
733
|
-
if (shape === "circle") {
|
|
734
|
-
ctx.moveTo(x + rad, y);
|
|
735
|
-
ctx.arc(x, y, rad, 0, Math.PI * 2);
|
|
736
|
-
return;
|
|
737
|
-
}
|
|
738
|
-
if (shape === "rect") {
|
|
739
|
-
ctx.rect(x - rad, y - rad, rad * 2, rad * 2);
|
|
740
|
-
return;
|
|
741
|
-
}
|
|
742
|
-
const n = shape === "hexagon" ? 6 : 4;
|
|
743
|
-
const off = shape === "diamond" ? -Math.PI / 2 : 0;
|
|
744
|
-
for (let i = 0; i < n; i++) {
|
|
745
|
-
const t = off + i * 2 * Math.PI / n;
|
|
746
|
-
const px = x + rad * Math.cos(t), py = y + rad * Math.sin(t);
|
|
747
|
-
if (i === 0) ctx.moveTo(px, py);
|
|
748
|
-
else ctx.lineTo(px, py);
|
|
749
|
-
}
|
|
750
|
-
ctx.closePath();
|
|
751
|
-
}
|
|
752
|
-
function distToEdge(px, py, ax, ay, bx, by, bend) {
|
|
753
|
-
if (!bend) return distToSeg(px, py, ax, ay, bx, by);
|
|
754
|
-
const [cx, cy] = controlOf(ax, ay, bx, by, bend);
|
|
755
|
-
let best = Infinity, lx = ax, ly = ay;
|
|
756
|
-
for (let i = 1; i <= 8; i++) {
|
|
757
|
-
const t = i / 8, u = 1 - t;
|
|
758
|
-
const x = u * u * ax + 2 * u * t * cx + t * t * bx, y = u * u * ay + 2 * u * t * cy + t * t * by;
|
|
759
|
-
best = Math.min(best, distToSeg(px, py, lx, ly, x, y));
|
|
760
|
-
lx = x;
|
|
761
|
-
ly = y;
|
|
762
|
-
}
|
|
763
|
-
return best;
|
|
764
|
-
}
|
|
765
|
-
function distToSeg(px, py, ax, ay, bx, by) {
|
|
766
|
-
const dx = bx - ax, dy = by - ay, L2 = dx * dx + dy * dy;
|
|
767
|
-
const t = L2 ? Math.max(0, Math.min(1, ((px - ax) * dx + (py - ay) * dy) / L2)) : 0;
|
|
768
|
-
return Math.hypot(px - (ax + t * dx), py - (ay + t * dy));
|
|
769
|
-
}
|
|
770
|
-
|
|
771
95
|
// src/layout/divide.ts
|
|
772
96
|
var isEdge = (el) => !!el.data.source;
|
|
773
97
|
var isAttached = (el) => el.data._struct === false;
|
|
@@ -941,12 +265,12 @@ function readOrder(elements) {
|
|
|
941
265
|
}
|
|
942
266
|
const orderedKids = /* @__PURE__ */ new Map();
|
|
943
267
|
let any = false;
|
|
944
|
-
for (const [parent,
|
|
945
|
-
if (
|
|
946
|
-
const sorted = [...
|
|
268
|
+
for (const [parent, list2] of kids) {
|
|
269
|
+
if (list2.length < 2 || list2.some((k) => k.order === null)) continue;
|
|
270
|
+
const sorted = [...list2].sort((a, b) => a.order - b.order).map((k) => k.id);
|
|
947
271
|
const seen = /* @__PURE__ */ new Set();
|
|
948
272
|
let unique = true;
|
|
949
|
-
for (const k of
|
|
273
|
+
for (const k of list2) {
|
|
950
274
|
if (seen.has(k.order)) {
|
|
951
275
|
unique = false;
|
|
952
276
|
break;
|
|
@@ -977,8 +301,8 @@ function orderSeed(elements, info, dims = {}, random = Math.random) {
|
|
|
977
301
|
const gap = LAYOUTS["cose-bilkent"].opts.idealEdgeLength;
|
|
978
302
|
const children = /* @__PURE__ */ new Map();
|
|
979
303
|
for (const [id, parent] of info.parentOf) {
|
|
980
|
-
const
|
|
981
|
-
|
|
304
|
+
const list2 = children.get(parent);
|
|
305
|
+
list2 ? list2.push(id) : children.set(parent, [id]);
|
|
982
306
|
}
|
|
983
307
|
const diameter = (id) => {
|
|
984
308
|
const d = dims[id];
|
|
@@ -1001,10 +325,10 @@ function orderSeed(elements, info, dims = {}, random = Math.random) {
|
|
|
1001
325
|
};
|
|
1002
326
|
const out = {};
|
|
1003
327
|
const placeChildren = (parent, ids, parentRadius, sector) => {
|
|
1004
|
-
const
|
|
1005
|
-
if (!
|
|
1006
|
-
const span = sector ? (sector.to - sector.from) /
|
|
1007
|
-
|
|
328
|
+
const list2 = info.orderedKids.get(parent ?? VIRTUAL_PARENT) ?? shuffled(ids, random);
|
|
329
|
+
if (!list2.length) return;
|
|
330
|
+
const span = sector ? (sector.to - sector.from) / list2.length : TAU / (list2.length + 1);
|
|
331
|
+
list2.forEach((id, i) => {
|
|
1008
332
|
const middle2 = sector ? sector.from + (i + 0.5) * span : -Math.PI / 2 + (i + 1) * span;
|
|
1009
333
|
const angle = middle2 + offset(span);
|
|
1010
334
|
const clearance = gap + (diameter(parent ?? VIRTUAL_PARENT) + diameter(id)) / 2;
|
|
@@ -1156,7 +480,7 @@ async function runDivide(req, aborted) {
|
|
|
1156
480
|
if (req.seed) {
|
|
1157
481
|
const seed2 = req.seed;
|
|
1158
482
|
const compByKey = new Map(comps.map((c) => [c.key, c]));
|
|
1159
|
-
const mid = (pts) => pts.length ? { x: pts.reduce((s,
|
|
483
|
+
const mid = (pts) => pts.length ? { x: pts.reduce((s, q) => s + q.x, 0) / pts.length, y: pts.reduce((s, q) => s + q.y, 0) / pts.length } : void 0;
|
|
1160
484
|
for (const el of coarseEls) {
|
|
1161
485
|
if (el.data.source) continue;
|
|
1162
486
|
const key = el.data.id;
|
|
@@ -1604,12 +928,254 @@ function idPhase(id) {
|
|
|
1604
928
|
return (h >>> 0) % 6283 / 1e3;
|
|
1605
929
|
}
|
|
1606
930
|
|
|
931
|
+
// src/react/useSubgraph.ts
|
|
932
|
+
import { useMemo } from "react";
|
|
933
|
+
function useSubgraph(props, view, force) {
|
|
934
|
+
const base = props.profile ?? defaultProfile;
|
|
935
|
+
const before = props.diff?.before ?? props.compareWith?.model;
|
|
936
|
+
const after = props.diff?.after ?? props.editModel ?? props.model;
|
|
937
|
+
const active = !!(view.subtree || view.origins?.length);
|
|
938
|
+
const priorRoot = useMemo(() => {
|
|
939
|
+
if (view.subtree && before && !before.index.has(view.subtree)) {
|
|
940
|
+
if (props.diff) {
|
|
941
|
+
for (const [old, now2] of props.diff.resolved) if (now2 === view.subtree) return old;
|
|
942
|
+
} else {
|
|
943
|
+
const key = props.compareWith?.options?.key;
|
|
944
|
+
const root = after.index.get(view.subtree);
|
|
945
|
+
if (key && root) {
|
|
946
|
+
const identity = key(root);
|
|
947
|
+
return before.nodes.find((n) => key(n) === identity)?.id ?? view.subtree;
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
return view.subtree;
|
|
952
|
+
}, [after, before, props.diff, props.compareWith, view.subtree]);
|
|
953
|
+
const current = useMemo(() => projectSubgraph(after, view), [after, view.subtree, view.origins]);
|
|
954
|
+
const previous = useMemo(
|
|
955
|
+
() => before && projectSubgraph(before, { subtree: priorRoot, origins: view.origins }),
|
|
956
|
+
[before, priorRoot, view.origins]
|
|
957
|
+
);
|
|
958
|
+
const colors = useMemo(() => base.layers.map((l) => l.color ?? ""), [base.layers]);
|
|
959
|
+
const localFloors = active && (base.structuralLayers ?? base.layers.length <= 1);
|
|
960
|
+
const now = useMemo(() => localFloors ? subgraphFloors(current, colors, force) : null, [current, localFloors, colors, force]);
|
|
961
|
+
const past = useMemo(() => localFloors && previous ? subgraphFloors(previous, colors, force) : null, [previous, localFloors, colors, force]);
|
|
962
|
+
const profile = useMemo(() => {
|
|
963
|
+
if (!now) return base;
|
|
964
|
+
const ids = new Set(now.layers.map((l) => l.id));
|
|
965
|
+
const layers = now.layers.concat((past?.layers ?? []).filter((l) => !ids.has(l.id)));
|
|
966
|
+
return { ...base, layers: layers.length ? layers : defaultProfile.layers };
|
|
967
|
+
}, [base, now, past]);
|
|
968
|
+
const delta = useMemo(() => {
|
|
969
|
+
if (!previous) return null;
|
|
970
|
+
if (!active && props.diff) return props.diff;
|
|
971
|
+
return diffModels(
|
|
972
|
+
past?.model ?? previous,
|
|
973
|
+
now?.model ?? current,
|
|
974
|
+
props.diff?.options ?? props.compareWith?.options ?? { labels: props.diff?.labels, ignore: props.diff?.ignore, key: props.matchKey }
|
|
975
|
+
);
|
|
976
|
+
}, [previous, active, props.diff, props.compareWith, props.matchKey, past, now, current]);
|
|
977
|
+
const model = useMemo(() => {
|
|
978
|
+
if (delta) return delta.model;
|
|
979
|
+
if (!now) return active ? current : props.model;
|
|
980
|
+
const { model: model2, anchor } = now;
|
|
981
|
+
return layerView(model2, view.planes === false ? void 0 : anchor);
|
|
982
|
+
}, [delta, props.model, active, current, now, view.planes]);
|
|
983
|
+
const canForce = useMemo(() => !!now && !now.layers.length && !force && deriveLayers(current, [], true).layers.length >= 2, [now, current, force]);
|
|
984
|
+
const origins = useMemo(() => [.../* @__PURE__ */ new Set([...props.sourceFiles ?? [], ...originsOf(after), ...before ? originsOf(before) : []])].sort(), [props.sourceFiles, after, before]);
|
|
985
|
+
return { active, before, after, current, model, delta, profile, origins, canForce };
|
|
986
|
+
}
|
|
987
|
+
|
|
1607
988
|
// src/react/Toolbar.tsx
|
|
1608
|
-
import { useEffect, useLayoutEffect as useLayoutEffect2,
|
|
989
|
+
import { useId, useEffect, useLayoutEffect as useLayoutEffect2, useRef, useState as useState2 } from "react";
|
|
990
|
+
|
|
991
|
+
// src/shell.ts
|
|
992
|
+
var shellArg = (s) => "'" + s.replace(/'/g, `'"'"'`) + "'";
|
|
993
|
+
|
|
994
|
+
// src/lint-report.ts
|
|
995
|
+
var headings = {
|
|
996
|
+
"bad-structure": "Sibling subtrees differ in shape or node kind.",
|
|
997
|
+
"wide-node": "These parent nodes have many direct children.",
|
|
998
|
+
"duplicate-edge": "Multiple edge records have the same source ID, kind and target ID.",
|
|
999
|
+
"dangling-edge": "An edge references a missing node ID. Add the node or correct the endpoint.",
|
|
1000
|
+
"field-conflict": "Choose one value for the conflicting node field.",
|
|
1001
|
+
"children-conflict": "Use the same ordered child IDs in each declaration, with each child listed once.",
|
|
1002
|
+
"parent-error": "Repair the parent\u2013child placement.",
|
|
1003
|
+
"duplicate-id": "Resolve conflicting definitions of a node ID.",
|
|
1004
|
+
"schema": "Check the named fields against the graph or profile format.",
|
|
1005
|
+
"kind-note": "Review kind names. Merge synonyms and keep distinct meanings.",
|
|
1006
|
+
"uncolored-kind": "Assign a distinct color to each listed node kind.",
|
|
1007
|
+
"coverage-note": "These leaf nodes have no `description`. Add a sentence explaining each one.",
|
|
1008
|
+
"color-note": "These node kinds have similar colors. Make one lighter or darker."
|
|
1009
|
+
};
|
|
1010
|
+
function delimiter(text, minimum) {
|
|
1011
|
+
let length = minimum;
|
|
1012
|
+
for (const run of text.matchAll(/`+/g)) length = Math.max(length, run[0].length + 1);
|
|
1013
|
+
return "`".repeat(length);
|
|
1014
|
+
}
|
|
1015
|
+
function codeBlock(text, indent, language = "") {
|
|
1016
|
+
const fence = delimiter(text, 3);
|
|
1017
|
+
return [indent + fence + language, ...text.split("\n").map((line) => indent + line), indent + fence];
|
|
1018
|
+
}
|
|
1019
|
+
function literal(value) {
|
|
1020
|
+
const text = /[\u0000-\u001f]|^\s|\s$|^$/.test(value) ? JSON.stringify(value) : value;
|
|
1021
|
+
const fence = delimiter(text, 1);
|
|
1022
|
+
const pad = text.startsWith("`") || text.endsWith("`") ? " " : "";
|
|
1023
|
+
return fence + pad + text + pad + fence;
|
|
1024
|
+
}
|
|
1025
|
+
function plain(value) {
|
|
1026
|
+
return value.replace(/[\\`*_\[\]<>#&~!|]/g, "\\$&").replace(/[\r\n]+/g, " ");
|
|
1027
|
+
}
|
|
1028
|
+
var list = (values) => values.map(literal).join(", ");
|
|
1029
|
+
function groupBy(items, keyOf) {
|
|
1030
|
+
const groups = /* @__PURE__ */ new Map();
|
|
1031
|
+
for (const item of items) {
|
|
1032
|
+
const key = keyOf(item);
|
|
1033
|
+
const group = groups.get(key);
|
|
1034
|
+
if (group) group.push(item);
|
|
1035
|
+
else groups.set(key, [item]);
|
|
1036
|
+
}
|
|
1037
|
+
return groups;
|
|
1038
|
+
}
|
|
1039
|
+
function duplicateLines(edges) {
|
|
1040
|
+
const lines = [];
|
|
1041
|
+
const batches = [...groupBy(edges, (e) => JSON.stringify([e.differing, e.count, e.files])).values()];
|
|
1042
|
+
for (const group of batches.sort((a, b) => Number(b[0].differing) - Number(a[0].differing))) {
|
|
1043
|
+
const { differing, count, files } = group[0];
|
|
1044
|
+
const redundant = group.length * (count - 1);
|
|
1045
|
+
const action = differing ? "Attributes differ. Decide which values to retain before merging." : `Remove ${redundant} identical ${redundant === 1 ? "copy" : "copies"}, leaving one record per edge.`;
|
|
1046
|
+
lines.push(` - ${group.length} ${group.length === 1 ? "edge" : "edges"}, ${count} copies each${files.length ? (files.length === 1 ? " in " : " across ") + list(files) : ""}. ${action}`);
|
|
1047
|
+
for (const [source, outgoing] of groupBy(group, (e) => e.source)) {
|
|
1048
|
+
const targets = [...groupBy(outgoing, (e) => JSON.stringify(e.kind ?? null)).values()].map((sameKind) => {
|
|
1049
|
+
const kind = sameKind[0].kind;
|
|
1050
|
+
return `${kind === void 0 ? "(no kind)" : literal(kind)} \u2192 ${list(sameKind.map((e) => e.target))}`;
|
|
1051
|
+
});
|
|
1052
|
+
lines.push(` - From node ID ${literal(source)}: ${targets.join(" | ")}`);
|
|
1053
|
+
for (const edge of outgoing) for (const diff of edge.differences ?? []) {
|
|
1054
|
+
const values = diff.copies.map((c) => (c.value === void 0 ? "(absent)" : literal(c.value)) + (c.file ? " in " + literal(c.file) : ""));
|
|
1055
|
+
lines.push(` - ${edge.kind ? "Kind " + literal(edge.kind) + ", " : ""}target ID ${literal(edge.target)}, field ${literal(diff.field)}: ${values.join(" / ")}.`);
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
return lines;
|
|
1060
|
+
}
|
|
1061
|
+
function ruleLines(rows, input) {
|
|
1062
|
+
const lines = [];
|
|
1063
|
+
const duplicates = [];
|
|
1064
|
+
const uneven = [];
|
|
1065
|
+
for (const f of rows) {
|
|
1066
|
+
const d = f.facts;
|
|
1067
|
+
const place = f.where && f.scope !== "graph" ? literal(f.where) : "";
|
|
1068
|
+
const location = place ? " in " + (f.scope === "version" ? "version " : "") + place : "";
|
|
1069
|
+
switch (d?.type) {
|
|
1070
|
+
case "duplicate":
|
|
1071
|
+
duplicates.push(d);
|
|
1072
|
+
break;
|
|
1073
|
+
case "uneven":
|
|
1074
|
+
uneven.push(f);
|
|
1075
|
+
break;
|
|
1076
|
+
case "wide":
|
|
1077
|
+
lines.push(` - Node ID ${literal(f.node)}: ${d.count} direct children${d.layers ? " (floors; check that each is a major section)" : ""}.`);
|
|
1078
|
+
break;
|
|
1079
|
+
case "dangling":
|
|
1080
|
+
lines.push(` - Source ID ${literal(d.source)} \u2192 target ID ${literal(d.target)}${d.kind ? ", edge kind " + literal(d.kind) : ""}${location}. Missing: ${list(d.missing)}.`);
|
|
1081
|
+
break;
|
|
1082
|
+
case "misplaced":
|
|
1083
|
+
lines.push(` - On node ID ${literal(f.node)}${location}, move ${list(d.fields)} out of \`data\` and beside \`id\`.`);
|
|
1084
|
+
break;
|
|
1085
|
+
case "palette":
|
|
1086
|
+
case "colors": {
|
|
1087
|
+
const target = d.target ?? { file: "_profile.json", field: "nodePalette" };
|
|
1088
|
+
lines.push(` - In ${literal(target.file)}, edit ${literal(target.field)} for node kinds: ${list(d.kinds)}`);
|
|
1089
|
+
break;
|
|
1090
|
+
}
|
|
1091
|
+
case "coverage":
|
|
1092
|
+
lines.push(" - Leaf node IDs: " + list(d.leaves));
|
|
1093
|
+
break;
|
|
1094
|
+
case "vocabulary":
|
|
1095
|
+
lines.push(` - ${d.space === "node" ? "Node" : "Edge"} kinds (${d.kinds.length}): ${list(d.kinds)}`);
|
|
1096
|
+
break;
|
|
1097
|
+
default:
|
|
1098
|
+
lines.push(" - " + (place ? (f.scope === "version" ? "Version " : "File ") + place + ": " : "") + plain(f.message));
|
|
1099
|
+
if (f.fix) {
|
|
1100
|
+
const [action, ...example] = f.fix.split("\n");
|
|
1101
|
+
lines.push(" - " + plain(action));
|
|
1102
|
+
if (example.length) lines.push(...codeBlock(example.join("\n"), " "));
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
if (uneven.length) {
|
|
1107
|
+
const example = uneven[0];
|
|
1108
|
+
lines.push(" - Parent node IDs: " + list(uneven.map((f) => f.node)));
|
|
1109
|
+
if (example.facts?.type === "uneven" && example.facts.closest) {
|
|
1110
|
+
const { a, b } = example.facts.closest;
|
|
1111
|
+
lines.push(` - Example: Under the node with ID ${literal(example.node)}, child nodes ${literal(a)} and ${literal(b)} have the most similar subtrees.`);
|
|
1112
|
+
}
|
|
1113
|
+
const commands = [
|
|
1114
|
+
"glassbrain tree " + shellArg(input) + " --path " + shellArg(example.node),
|
|
1115
|
+
"glassbrain restructure " + shellArg(input) + " --dry-run"
|
|
1116
|
+
].join("\n");
|
|
1117
|
+
lines.push(
|
|
1118
|
+
" - If two siblings share a subject, move both under a new group node. Inspect and preview:",
|
|
1119
|
+
...codeBlock(commands, " ", "sh")
|
|
1120
|
+
);
|
|
1121
|
+
const pairs = uneven.slice(1).flatMap((f) => f.facts?.type === "uneven" && f.facts.closest ? [`${literal(f.node)} \u2192 ${list([f.facts.closest.a, f.facts.closest.b])}`] : []);
|
|
1122
|
+
if (pairs.length) {
|
|
1123
|
+
lines.push(" - Other pairs to inspect (parent node ID \u2192 two child node IDs):");
|
|
1124
|
+
for (const pair of pairs) lines.push(" - " + pair);
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
if (rows.some((f) => f.facts?.type === "wide" && !f.facts.layers)) lines.push(" - Group children by subject where useful. Keep a natural collection together.");
|
|
1128
|
+
if (duplicates.length) {
|
|
1129
|
+
lines.push(" - Each source below lists edge kind \u2192 target node IDs.");
|
|
1130
|
+
for (const line of duplicateLines(duplicates)) lines.push(line);
|
|
1131
|
+
}
|
|
1132
|
+
return lines;
|
|
1133
|
+
}
|
|
1134
|
+
var severities = [["error", "Errors"], ["warn", "Warnings"], ["info", "Info"]];
|
|
1135
|
+
function reportText(found, input, versions = 1) {
|
|
1136
|
+
const lines = ["# Graph lint"];
|
|
1137
|
+
if (versions > 1) lines.push(`${versions} versions checked. Quality warnings apply to the latest version.`);
|
|
1138
|
+
for (const [level, heading] of severities) {
|
|
1139
|
+
const findings = found.filter((f) => f.level === level);
|
|
1140
|
+
const policy = { error: "Blocks export.", warn: "Fails lint with `--strict`.", info: "Advisory. Info alone passes lint, including with `--strict`." };
|
|
1141
|
+
lines.push(`## ${heading} (${findings.length})${findings.length ? " \u2014 " + policy[level] : ""}`);
|
|
1142
|
+
const groups = groupBy(findings, (f) => f.code);
|
|
1143
|
+
const codes = [...groups.keys()].sort((a, b) => Number(a === "duplicate-edge") - Number(b === "duplicate-edge"));
|
|
1144
|
+
for (const code of codes) {
|
|
1145
|
+
const rows = groups.get(code);
|
|
1146
|
+
lines.push(`- **${plain(code)}** (${rows.length})${Object.hasOwn(headings, code) ? " \u2014 " + headings[code] : ""}`);
|
|
1147
|
+
for (const line of ruleLines(rows, input)) lines.push(line);
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
return lines.join("\n") + "\n";
|
|
1151
|
+
}
|
|
1152
|
+
function checksText({ lint, review }, lintReport) {
|
|
1153
|
+
const graphLint = lintReport ?? reportText(lint.map((i) => ({ ...i, code: i.kind, node: i.nodeId })), "graph.json");
|
|
1154
|
+
if (!review) return graphLint;
|
|
1155
|
+
const lines = [`# Data review (${review.length})`];
|
|
1156
|
+
for (const [level, heading] of severities) {
|
|
1157
|
+
const rows = review.filter((i) => i.level === level);
|
|
1158
|
+
if (!rows.length) continue;
|
|
1159
|
+
lines.push(`## ${heading} (${rows.length})`);
|
|
1160
|
+
for (const [kind, issues] of groupBy(rows, (i) => i.kind)) {
|
|
1161
|
+
const label = issues[0].group;
|
|
1162
|
+
lines.push(`- **${plain(kind)}** (${issues.length})` + (label && label !== kind ? " \u2014 " + plain(label) : ""));
|
|
1163
|
+
for (const issue of issues) {
|
|
1164
|
+
const location = [];
|
|
1165
|
+
if (issue.nodeId !== void 0) location.push("Node ID " + literal(issue.nodeId));
|
|
1166
|
+
if (issue.edge) location.push("Edge " + literal(issue.edge.source) + " \u2192 " + literal(issue.edge.target));
|
|
1167
|
+
if (issue.where) location.push(literal(issue.where));
|
|
1168
|
+
lines.push(" - " + (location.length ? location.join(", ") + " \u2014 " : "") + plain(issue.message));
|
|
1169
|
+
if (issue.fix) lines.push(" - " + plain(issue.fix));
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
return lines.join("\n") + "\n\n" + graphLint;
|
|
1174
|
+
}
|
|
1609
1175
|
|
|
1610
1176
|
// src/react/placement.ts
|
|
1611
1177
|
import { useLayoutEffect, useState } from "react";
|
|
1612
|
-
var
|
|
1178
|
+
var GAP = 6;
|
|
1613
1179
|
var MARGIN = 8;
|
|
1614
1180
|
function placePanel(anchor, panel, boundary, prefer) {
|
|
1615
1181
|
const combos = [
|
|
@@ -1620,7 +1186,7 @@ function placePanel(anchor, panel, boundary, prefer) {
|
|
|
1620
1186
|
];
|
|
1621
1187
|
const at = (c) => ({
|
|
1622
1188
|
left: c.align === "start" ? anchor.left : anchor.right - panel.width,
|
|
1623
|
-
top: c.side === "bottom" ? anchor.bottom +
|
|
1189
|
+
top: c.side === "bottom" ? anchor.bottom + GAP : anchor.top - GAP - panel.height
|
|
1624
1190
|
});
|
|
1625
1191
|
const fits = (c) => {
|
|
1626
1192
|
const p2 = at(c);
|
|
@@ -1740,7 +1306,7 @@ function LayerPicker({ layers, view, setView, disabled, collapsed }) {
|
|
|
1740
1306
|
const next = layers.map((l) => l.id).filter((l) => l === id ? !on.has(l) : on.has(l));
|
|
1741
1307
|
setView({ layers: next });
|
|
1742
1308
|
};
|
|
1743
|
-
return /* @__PURE__ */ jsxs("div", { className: `gb-segm gb-layers${stacked ? " is-multi" : ""}${collapsed ? " is-collapsed" : ""}`, role: stacked ? "group" : "radiogroup", children: [
|
|
1309
|
+
return /* @__PURE__ */ jsxs("div", { className: `gb-segm gb-glass gb-raised gb-round gb-layers${stacked ? " is-multi" : ""}${collapsed ? " is-collapsed" : ""}`, role: stacked ? "group" : "radiogroup", children: [
|
|
1744
1310
|
/* @__PURE__ */ jsxs("div", { className: `gb-layer-track${edges.left ? " can-left" : ""}${edges.right ? " can-right" : ""}`, ref: box, "aria-hidden": collapsed, children: [
|
|
1745
1311
|
thumb && /* @__PURE__ */ jsx("i", { className: "gb-thumb", style: { transform: `translateX(${thumb.x}px)`, width: thumb.w } }),
|
|
1746
1312
|
layers.map((l) => {
|
|
@@ -1783,7 +1349,7 @@ function LayerUnavailable(p) {
|
|
|
1783
1349
|
/* @__PURE__ */ jsx(
|
|
1784
1350
|
"button",
|
|
1785
1351
|
{
|
|
1786
|
-
className: "gb-icon-btn",
|
|
1352
|
+
className: "gb-icon-btn gb-glass gb-raised gb-round",
|
|
1787
1353
|
style: { opacity: 0.45 },
|
|
1788
1354
|
"aria-label": t.layersOff,
|
|
1789
1355
|
title: t.layersOff,
|
|
@@ -1796,7 +1362,7 @@ function LayerUnavailable(p) {
|
|
|
1796
1362
|
"div",
|
|
1797
1363
|
{
|
|
1798
1364
|
ref: pop.panelRef,
|
|
1799
|
-
className: "gb-panel",
|
|
1365
|
+
className: "gb-panel gb-glass gb-raised gb-round",
|
|
1800
1366
|
role: "dialog",
|
|
1801
1367
|
"data-x": pop.placement?.align,
|
|
1802
1368
|
"data-y": pop.placement?.side,
|
|
@@ -1890,11 +1456,11 @@ function SearchBox(p) {
|
|
|
1890
1456
|
else e.target.blur();
|
|
1891
1457
|
}
|
|
1892
1458
|
};
|
|
1893
|
-
const
|
|
1894
|
-
const marker = queryMarker(
|
|
1459
|
+
const q = p.query.trim();
|
|
1460
|
+
const marker = queryMarker(q);
|
|
1895
1461
|
return /* @__PURE__ */ jsxs("div", { className: `gb-search${focused ? " is-focus" : ""}${open ? " is-open" : ""}`, children: [
|
|
1896
|
-
/* @__PURE__ */ jsxs("div", { className: "gb-field", children: [
|
|
1897
|
-
/* @__PURE__ */ jsx(Icon, { d: I.search }),
|
|
1462
|
+
/* @__PURE__ */ jsxs("div", { className: "gb-field gb-glass gb-raised gb-round", children: [
|
|
1463
|
+
p.prefix ?? /* @__PURE__ */ jsx(Icon, { d: I.search }),
|
|
1898
1464
|
/* @__PURE__ */ jsx(
|
|
1899
1465
|
"input",
|
|
1900
1466
|
{
|
|
@@ -1910,10 +1476,10 @@ function SearchBox(p) {
|
|
|
1910
1476
|
onKeyDown: onKey
|
|
1911
1477
|
}
|
|
1912
1478
|
),
|
|
1913
|
-
p.query ? /* @__PURE__ */ jsx("button", { className: "gb-clear", "aria-label": t.clearSearch, onMouseDown: (e) => e.preventDefault(), onClick: () => p.setQuery(""), children: /* @__PURE__ */ jsx(Icon, { d: I.
|
|
1479
|
+
p.query ? /* @__PURE__ */ jsx("button", { className: "gb-clear", "aria-label": t.clearSearch, onMouseDown: (e) => e.preventDefault(), onClick: () => p.setQuery(""), children: /* @__PURE__ */ jsx(Icon, { d: I.clear, size: 14 }) }) : !focused && /* @__PURE__ */ jsx("kbd", { children: "/" })
|
|
1914
1480
|
] }),
|
|
1915
1481
|
open && // Pressing the mouse in the list does not take focus: the dropdown closes as soon as the input blurs, and the click would miss.
|
|
1916
|
-
/* @__PURE__ */ jsxs("div", { className: "gb-drop", onMouseDown: (e) => e.preventDefault(), children: [
|
|
1482
|
+
/* @__PURE__ */ jsxs("div", { className: "gb-drop gb-glass gb-raised gb-round", onMouseDown: (e) => e.preventDefault(), children: [
|
|
1917
1483
|
results.length > 0 ? /* @__PURE__ */ jsx("ul", { role: "listbox", children: results.map((r, i) => /* @__PURE__ */ jsxs(
|
|
1918
1484
|
"li",
|
|
1919
1485
|
{
|
|
@@ -1927,16 +1493,12 @@ function SearchBox(p) {
|
|
|
1927
1493
|
p.inputRef.current?.blur();
|
|
1928
1494
|
},
|
|
1929
1495
|
children: [
|
|
1930
|
-
/* @__PURE__ */ jsx(
|
|
1931
|
-
/* @__PURE__ */ jsxs("span", { className: "gb-r-main", children: [
|
|
1932
|
-
/* @__PURE__ */ jsx("span", { className: "gb-r-label", children: /* @__PURE__ */ jsx(Hl, { text: r.label, re: marker }) }),
|
|
1933
|
-
r.path.length > 0 && /* @__PURE__ */ jsx("span", { className: "gb-r-path", children: r.path.join(" / ") })
|
|
1934
|
-
] }),
|
|
1496
|
+
/* @__PURE__ */ jsx(ObjectRef, { mark: /* @__PURE__ */ jsx(NodeDot, { color: p.colorOf(r.id) }), name: /* @__PURE__ */ jsx(Hl, { text: r.label, re: marker }), sub: r.path.join(" / ") }),
|
|
1935
1497
|
r.kind && /* @__PURE__ */ jsx("span", { className: "gb-r-kind", children: r.kind })
|
|
1936
1498
|
]
|
|
1937
1499
|
},
|
|
1938
1500
|
r.id
|
|
1939
|
-
)) }) : /* @__PURE__ */ jsx("div", { className: "gb-drop-empty", children: t.noMatch(
|
|
1501
|
+
)) }) : /* @__PURE__ */ jsx("div", { className: "gb-drop-empty", children: t.noMatch(q, !!p.search?.elsewhere.length) }),
|
|
1940
1502
|
p.search && p.search.total > results.length || p.search?.elsewhere.length ? /* @__PURE__ */ jsxs("div", { className: "gb-drop-foot", children: [
|
|
1941
1503
|
p.search && p.search.total > results.length && /* @__PURE__ */ jsx("span", { children: t.moreResults(p.search.total - results.length) }),
|
|
1942
1504
|
p.search?.elsewhere.map((e) => /* @__PURE__ */ jsxs("button", { onClick: () => p.onLayer(e.layer), children: [
|
|
@@ -1969,7 +1531,7 @@ function ViewMenu(p) {
|
|
|
1969
1531
|
/* @__PURE__ */ jsx(
|
|
1970
1532
|
"button",
|
|
1971
1533
|
{
|
|
1972
|
-
className: `gb-icon-btn${pop.open ? " on" : ""}`,
|
|
1534
|
+
className: `gb-icon-btn gb-glass gb-raised gb-round${pop.open ? " on" : ""}`,
|
|
1973
1535
|
"aria-label": t.more,
|
|
1974
1536
|
"aria-expanded": pop.open,
|
|
1975
1537
|
title: t.more,
|
|
@@ -1981,7 +1543,7 @@ function ViewMenu(p) {
|
|
|
1981
1543
|
"div",
|
|
1982
1544
|
{
|
|
1983
1545
|
ref: pop.panelRef,
|
|
1984
|
-
className: "gb-panel",
|
|
1546
|
+
className: "gb-panel gb-glass gb-raised gb-round",
|
|
1985
1547
|
role: "dialog",
|
|
1986
1548
|
"data-x": pop.placement?.align,
|
|
1987
1549
|
"data-y": pop.placement?.side,
|
|
@@ -2003,16 +1565,22 @@ function ViewMenu(p) {
|
|
|
2003
1565
|
function Toolbar(p) {
|
|
2004
1566
|
const { view, setView, controls } = p;
|
|
2005
1567
|
const t = useStrings();
|
|
2006
|
-
const shortOrigin = (o) => o.split("/").pop() ?? o;
|
|
2007
1568
|
const originPick = controls.origins && p.origins.length > 1;
|
|
1569
|
+
const token = p.scope.active && /* @__PURE__ */ jsxs("span", { className: "gb-token", title: p.scope.subtree ?? p.scope.origins?.join(", "), children: [
|
|
1570
|
+
/* @__PURE__ */ jsx(Icon, { d: p.scope.subtree ? I.tree : I.file, size: 13 }),
|
|
1571
|
+
/* @__PURE__ */ jsx("span", { children: p.scope.label }),
|
|
1572
|
+
/* @__PURE__ */ jsx("button", { type: "button", "aria-label": t.exitScope, title: t.exitScope, onClick: () => p.scope.change(null), children: /* @__PURE__ */ jsx(Icon, { d: I.x, size: 12 }) })
|
|
1573
|
+
] });
|
|
2008
1574
|
const multi = controls.layers && p.layers.length > 1;
|
|
2009
1575
|
const showLayer = (l) => setView(view.planes ? { layers: [...view.layers ?? [], l] } : { layers: [l] });
|
|
2010
1576
|
return /* @__PURE__ */ jsxs("div", { className: `gb-bar${multi && view.planes ? " has-layers" : ""}`, children: [
|
|
1577
|
+
!controls.search && token,
|
|
2011
1578
|
controls.search && /* @__PURE__ */ jsx(
|
|
2012
1579
|
SearchBox,
|
|
2013
1580
|
{
|
|
1581
|
+
prefix: token || void 0,
|
|
2014
1582
|
query: view.query ?? "",
|
|
2015
|
-
setQuery: (
|
|
1583
|
+
setQuery: (q) => setView({ query: q }),
|
|
2016
1584
|
search: p.search,
|
|
2017
1585
|
colorOf: p.colorOf,
|
|
2018
1586
|
onPreview: p.onPreview,
|
|
@@ -2023,12 +1591,6 @@ function Toolbar(p) {
|
|
|
2023
1591
|
),
|
|
2024
1592
|
multi && /* @__PURE__ */ jsx(LayerPicker, { layers: p.layers, view, setView, disabled: p.busy, collapsed: !view.planes }),
|
|
2025
1593
|
controls.layers && !multi && /* @__PURE__ */ jsx(LayerUnavailable, { reason: p.layerIssue ?? "", onForce: p.onForceLayers }),
|
|
2026
|
-
originPick && view.origins?.length === 1 && /* Filtering by source: the state is in plain sight, and one × returns to everything. */
|
|
2027
|
-
/* @__PURE__ */ jsxs("span", { className: "gb-chip", title: view.origins[0], children: [
|
|
2028
|
-
/* @__PURE__ */ jsx(Icon, { d: I.file, size: 13 }),
|
|
2029
|
-
/* @__PURE__ */ jsx("span", { children: shortOrigin(view.origins[0]) }),
|
|
2030
|
-
/* @__PURE__ */ jsx("button", { "aria-label": t.allOrigins, title: t.allOrigins, onClick: () => setView({ origins: null }), children: /* @__PURE__ */ jsx(Icon, { d: I.x, size: 12 }) })
|
|
2031
|
-
] }),
|
|
2032
1594
|
(originPick || p.onAdd || p.onRelayout || p.onRestructure) && /* @__PURE__ */ jsxs(ViewMenu, { foot: t.stats(p.stats.nodes, p.stats.edges), children: [
|
|
2033
1595
|
originPick && /* @__PURE__ */ jsxs("div", { className: "gb-panel-sec", children: [
|
|
2034
1596
|
/* @__PURE__ */ jsx("div", { className: "gb-panel-h", children: t.origins }),
|
|
@@ -2036,11 +1598,12 @@ function Toolbar(p) {
|
|
|
2036
1598
|
"select",
|
|
2037
1599
|
{
|
|
2038
1600
|
className: "gb-select",
|
|
2039
|
-
|
|
2040
|
-
|
|
1601
|
+
"aria-label": t.origins,
|
|
1602
|
+
value: p.scope.origins?.length === 1 ? p.scope.origins[0] : "",
|
|
1603
|
+
onChange: (e) => p.scope.change(null, e.target.value ? [e.target.value] : void 0),
|
|
2041
1604
|
children: [
|
|
2042
1605
|
/* @__PURE__ */ jsx("option", { value: "", children: t.allOrigins }),
|
|
2043
|
-
p.origins.map((o) => /* @__PURE__ */ jsx("option", { value: o, children:
|
|
1606
|
+
p.origins.map((o) => /* @__PURE__ */ jsx("option", { value: o, children: o }, o))
|
|
2044
1607
|
]
|
|
2045
1608
|
}
|
|
2046
1609
|
)
|
|
@@ -2051,90 +1614,79 @@ function Toolbar(p) {
|
|
|
2051
1614
|
] }),
|
|
2052
1615
|
(p.onRelayout || p.onRestructure) && /* @__PURE__ */ jsxs("div", { className: "gb-panel-sec gb-menu-list", children: [
|
|
2053
1616
|
p.onRelayout && /* @__PURE__ */ jsx("button", { className: "gb-menu-item", onClick: p.onRelayout, disabled: p.busy, children: t.relayout }),
|
|
2054
|
-
p.onRestructure && /* @__PURE__ */ jsx("button", { className: "gb-menu-item", "data-menu-keep-open": p.restructureContent ? true : void 0, onClick: p.onRestructure, disabled: p.busy, children: t.restructure }),
|
|
1617
|
+
p.onRestructure && /* @__PURE__ */ jsx("button", { className: "gb-menu-item", "data-menu-keep-open": p.restructureContent ? true : void 0, onClick: p.onRestructure, disabled: p.busy, children: p.scope.active ? t.restructureFull : t.restructure }),
|
|
2055
1618
|
p.restructureContent
|
|
2056
1619
|
] })
|
|
2057
1620
|
] })
|
|
2058
1621
|
] });
|
|
2059
1622
|
}
|
|
2060
|
-
function
|
|
1623
|
+
function MarkdownReport({ text }) {
|
|
1624
|
+
return /* @__PURE__ */ jsx("div", { onCopy: (event) => {
|
|
1625
|
+
const selection = event.currentTarget.ownerDocument.getSelection();
|
|
1626
|
+
if (!selection?.rangeCount || selection.isCollapsed) return;
|
|
1627
|
+
const range = selection.getRangeAt(0);
|
|
1628
|
+
if (!event.currentTarget.contains(range.commonAncestorContainer)) return;
|
|
1629
|
+
if (range.toString() === event.currentTarget.textContent) {
|
|
1630
|
+
event.clipboardData.setData("text/plain", text);
|
|
1631
|
+
event.preventDefault();
|
|
1632
|
+
}
|
|
1633
|
+
}, children: renderMarkdown(text) });
|
|
1634
|
+
}
|
|
1635
|
+
function Issues({ checks, report }) {
|
|
2061
1636
|
const t = useStrings();
|
|
1637
|
+
const panelId = useId();
|
|
2062
1638
|
const pop = usePopover(ISSUES_PLACE);
|
|
2063
|
-
const
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
const g = by.get(key) ?? by.set(key, { name, level: it.level, items: [] }).get(key);
|
|
2069
|
-
g.items.push(it);
|
|
2070
|
-
}
|
|
2071
|
-
const rank = { error: 0, warn: 1, info: 2 };
|
|
2072
|
-
return [...by.values()].sort((a, b) => rank[a.level] - rank[b.level]);
|
|
2073
|
-
}, [issues]);
|
|
1639
|
+
const countCategories = (rows) => new Set(rows.map((i) => i.level + ":" + i.kind)).size;
|
|
1640
|
+
const lintGroups = countCategories(checks.lint);
|
|
1641
|
+
const reviewGroups = checks.review && countCategories(checks.review);
|
|
1642
|
+
const groups = lintGroups + (reviewGroups ?? 0);
|
|
1643
|
+
const issues = checks.review ? checks.lint.concat(checks.review) : checks.lint;
|
|
2074
1644
|
const errors = issues.filter((i) => i.level === "error").length;
|
|
2075
1645
|
const warns = issues.filter((i) => i.level === "warn").length;
|
|
2076
|
-
const infos = issues.
|
|
2077
|
-
const
|
|
2078
|
-
const
|
|
1646
|
+
const infos = issues.length - errors - warns;
|
|
1647
|
+
const summary = [t.issuesTitle(errors, warns, infos, groups), t.issuesTip(errors, warns, infos)].filter(Boolean).join(" \xB7 ");
|
|
1648
|
+
const title = reviewGroups === void 0 ? summary : summary + "\n" + t.issuesBySource(reviewGroups, lintGroups);
|
|
2079
1649
|
return /* @__PURE__ */ jsxs("div", { className: "gb-menu", ref: pop.ref, children: [
|
|
2080
1650
|
/* @__PURE__ */ jsx(
|
|
2081
1651
|
"button",
|
|
2082
1652
|
{
|
|
2083
|
-
className: "gb-icon-btn gb-check-button",
|
|
1653
|
+
className: "gb-icon-btn gb-glass gb-raised gb-round gb-check-button",
|
|
2084
1654
|
onClick: () => pop.setOpen(!pop.open),
|
|
2085
1655
|
"aria-expanded": pop.open,
|
|
2086
|
-
|
|
2087
|
-
"aria-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
1656
|
+
"aria-haspopup": "dialog",
|
|
1657
|
+
"aria-controls": pop.open ? panelId : void 0,
|
|
1658
|
+
title,
|
|
1659
|
+
"aria-label": title,
|
|
1660
|
+
children: /* @__PURE__ */ jsxs("span", { className: "gb-check-stack", "aria-hidden": "true", children: [
|
|
1661
|
+
/* @__PURE__ */ jsx(Icon, { d: I.checks, size: 18 }),
|
|
1662
|
+
groups > 0 && /* @__PURE__ */ jsx("span", { className: "gb-check-badge", children: groups > 99 ? "99+" : groups })
|
|
2091
1663
|
] })
|
|
2092
1664
|
}
|
|
2093
1665
|
),
|
|
2094
|
-
pop.open && /* @__PURE__ */
|
|
1666
|
+
pop.open && /* @__PURE__ */ jsx(
|
|
2095
1667
|
"div",
|
|
2096
1668
|
{
|
|
2097
1669
|
ref: pop.panelRef,
|
|
2098
|
-
|
|
1670
|
+
id: panelId,
|
|
1671
|
+
className: "gb-panel gb-glass gb-raised gb-round gb-issues",
|
|
2099
1672
|
role: "dialog",
|
|
2100
|
-
"aria-label":
|
|
1673
|
+
"aria-label": title,
|
|
2101
1674
|
"data-x": pop.placement?.align,
|
|
2102
1675
|
"data-y": pop.placement?.side,
|
|
2103
1676
|
style: pop.placement ? { left: pop.placement.left, top: pop.placement.top, right: "auto", bottom: "auto" } : { visibility: "hidden" },
|
|
2104
|
-
children:
|
|
2105
|
-
/* @__PURE__ */ jsx("div", { className: "gb-panel-h", children: t.issuesTitle(errors, warns, infos) }),
|
|
2106
|
-
groups.map((g) => /* @__PURE__ */ jsxs("details", { open: g.level !== "info", children: [
|
|
2107
|
-
/* @__PURE__ */ jsxs("summary", { className: `gb-check-${g.level}`, children: [
|
|
2108
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
2109
|
-
g.level,
|
|
2110
|
-
" \xB7 ",
|
|
2111
|
-
g.name
|
|
2112
|
-
] }),
|
|
2113
|
-
/* @__PURE__ */ jsx("b", { children: g.items.length })
|
|
2114
|
-
] }),
|
|
2115
|
-
/* @__PURE__ */ jsx("ul", { children: g.items.map((it, i) => {
|
|
2116
|
-
const id = target(it);
|
|
2117
|
-
return /* @__PURE__ */ jsxs("li", { children: [
|
|
2118
|
-
id ? /* @__PURE__ */ jsx("button", { className: "gb-issue-target", onClick: () => {
|
|
2119
|
-
onPick(id);
|
|
2120
|
-
pop.setOpen(false);
|
|
2121
|
-
}, children: it.message }) : /* @__PURE__ */ jsx("div", { children: it.message }),
|
|
2122
|
-
it.where && /* @__PURE__ */ jsx("small", { className: "gb-issue-where", children: it.where }),
|
|
2123
|
-
it.fix && /* @__PURE__ */ jsx("div", { className: "gb-issue-fix", children: it.fix })
|
|
2124
|
-
] }, i);
|
|
2125
|
-
}) })
|
|
2126
|
-
] }, `${g.level}:${g.name}`))
|
|
2127
|
-
]
|
|
1677
|
+
children: /* @__PURE__ */ jsx(MarkdownReport, { text: checksText(checks, report) })
|
|
2128
1678
|
}
|
|
2129
1679
|
)
|
|
2130
1680
|
] });
|
|
2131
1681
|
}
|
|
2132
1682
|
function ZoomDock(p) {
|
|
2133
1683
|
const t = useStrings();
|
|
2134
|
-
|
|
1684
|
+
const checks = p.checks;
|
|
1685
|
+
const showChecks = checks && (checks.lint.length > 0 || checks.review !== void 0 || !!p.report);
|
|
1686
|
+
if (!p.zoom && !showChecks) return null;
|
|
2135
1687
|
return /* @__PURE__ */ jsxs("div", { className: "gb-dock", children: [
|
|
2136
|
-
|
|
2137
|
-
p.zoom && /* @__PURE__ */ jsxs("div", { className: "gb-group", title: t.cameraTip, children: [
|
|
1688
|
+
showChecks && /* @__PURE__ */ jsx(Issues, { checks, report: p.report }),
|
|
1689
|
+
p.zoom && /* @__PURE__ */ jsxs("div", { className: "gb-group gb-glass gb-raised gb-round", title: t.cameraTip, children: [
|
|
2138
1690
|
/* @__PURE__ */ jsx("button", { "aria-label": t.zoomOut, title: t.zoomOut, onClick: () => p.onZoom(-1), children: /* @__PURE__ */ jsx(Icon, { d: I.minus }) }),
|
|
2139
1691
|
/* @__PURE__ */ jsx("button", { "aria-label": t.zoomIn, title: t.zoomIn, onClick: () => p.onZoom(1), children: /* @__PURE__ */ jsx(Icon, { d: I.plus }) }),
|
|
2140
1692
|
/* @__PURE__ */ jsx("button", { "aria-label": t.fit, title: t.fit, onClick: p.onFit, children: /* @__PURE__ */ jsx(Icon, { d: I.fit }) })
|
|
@@ -2154,7 +1706,12 @@ function touchGestures(actions) {
|
|
|
2154
1706
|
let start = null;
|
|
2155
1707
|
let startedAt = 0;
|
|
2156
1708
|
let target = null;
|
|
2157
|
-
let
|
|
1709
|
+
let current = null;
|
|
1710
|
+
let beforeGesture = null;
|
|
1711
|
+
const preview = (hit) => {
|
|
1712
|
+
current = hit;
|
|
1713
|
+
actions.preview(hit?.value ?? null);
|
|
1714
|
+
};
|
|
2158
1715
|
let lastTap = null;
|
|
2159
1716
|
let pinch = null;
|
|
2160
1717
|
const anchor = () => {
|
|
@@ -2171,6 +1728,7 @@ function touchGestures(actions) {
|
|
|
2171
1728
|
pinch = null;
|
|
2172
1729
|
start = null;
|
|
2173
1730
|
target = null;
|
|
1731
|
+
beforeGesture = null;
|
|
2174
1732
|
navigation = moved = false;
|
|
2175
1733
|
};
|
|
2176
1734
|
return {
|
|
@@ -2178,9 +1736,9 @@ function touchGestures(actions) {
|
|
|
2178
1736
|
actions.interact();
|
|
2179
1737
|
fingers.set(id, point);
|
|
2180
1738
|
if (fingers.size > 1 || navigation) {
|
|
1739
|
+
if (current?.id !== beforeGesture?.id) preview(beforeGesture);
|
|
2181
1740
|
navigation = true;
|
|
2182
1741
|
lastTap = null;
|
|
2183
|
-
actions.preview(null);
|
|
2184
1742
|
anchor();
|
|
2185
1743
|
return;
|
|
2186
1744
|
}
|
|
@@ -2188,8 +1746,8 @@ function touchGestures(actions) {
|
|
|
2188
1746
|
startedAt = Date.now();
|
|
2189
1747
|
moved = false;
|
|
2190
1748
|
target = actions.hit(point);
|
|
2191
|
-
|
|
2192
|
-
|
|
1749
|
+
beforeGesture = current;
|
|
1750
|
+
if (target) preview(target);
|
|
2193
1751
|
},
|
|
2194
1752
|
move(id, point) {
|
|
2195
1753
|
if (!fingers.has(id)) return;
|
|
@@ -2217,10 +1775,7 @@ function touchGestures(actions) {
|
|
|
2217
1775
|
}
|
|
2218
1776
|
if (moved) {
|
|
2219
1777
|
const next = actions.hit(point);
|
|
2220
|
-
if (
|
|
2221
|
-
previewId = next?.id ?? null;
|
|
2222
|
-
actions.preview(next?.value ?? null);
|
|
2223
|
-
}
|
|
1778
|
+
if (next && next.id !== current?.id) preview(next);
|
|
2224
1779
|
}
|
|
2225
1780
|
},
|
|
2226
1781
|
up(id, point) {
|
|
@@ -2229,8 +1784,8 @@ function touchGestures(actions) {
|
|
|
2229
1784
|
if (!navigation && !moved && start && Date.now() - startedAt < TAP_MS && distance(start, point) <= SLOP) {
|
|
2230
1785
|
const hit = actions.hit(point);
|
|
2231
1786
|
if ((hit?.id ?? null) === (target?.id ?? null)) {
|
|
2232
|
-
actions.preview(hit?.value ?? null);
|
|
2233
1787
|
if (!hit) {
|
|
1788
|
+
preview(null);
|
|
2234
1789
|
actions.select(null);
|
|
2235
1790
|
lastTap = null;
|
|
2236
1791
|
} else if (hit.node) {
|
|
@@ -2248,7 +1803,7 @@ function touchGestures(actions) {
|
|
|
2248
1803
|
cancel() {
|
|
2249
1804
|
reset();
|
|
2250
1805
|
lastTap = null;
|
|
2251
|
-
|
|
1806
|
+
preview(null);
|
|
2252
1807
|
},
|
|
2253
1808
|
dispose() {
|
|
2254
1809
|
reset();
|
|
@@ -2263,20 +1818,43 @@ function installGraphInput(cy, el, actions) {
|
|
|
2263
1818
|
actions.interact();
|
|
2264
1819
|
actions.cancelFly();
|
|
2265
1820
|
};
|
|
2266
|
-
|
|
2267
|
-
const
|
|
2268
|
-
|
|
2269
|
-
|
|
1821
|
+
const pane = el.parentElement;
|
|
1822
|
+
const point = (e) => {
|
|
1823
|
+
const rect = pane.getBoundingClientRect();
|
|
1824
|
+
return { x: e.clientX - rect.left, y: e.clientY - rect.top };
|
|
1825
|
+
};
|
|
1826
|
+
const hit = (p, isTouch) => {
|
|
1827
|
+
let layerHit = null;
|
|
1828
|
+
if (pane.firstElementChild?.classList.contains("gb-planes")) {
|
|
1829
|
+
const rect = pane.getBoundingClientRect();
|
|
1830
|
+
const root = pane.getRootNode();
|
|
1831
|
+
const stack = root.elementsFromPoint(rect.left + p.x, rect.top + p.y);
|
|
1832
|
+
const shape = stack.find((item) => item.hasAttribute("data-gb-layer") && pane.contains(item));
|
|
1833
|
+
if (shape) {
|
|
1834
|
+
const layer = shape.getAttribute("data-gb-layer");
|
|
1835
|
+
layerHit = { id: "layer:" + layer, node: false, value: layer };
|
|
1836
|
+
if (shape.localName === "text") return layerHit;
|
|
1837
|
+
}
|
|
1838
|
+
}
|
|
1839
|
+
const z = cy.zoom(), pan = cy.pan();
|
|
1840
|
+
const element = cy.renderer().findNearestElements((p.x - pan.x) / z, (p.y - pan.y) / z, true, isTouch)[0];
|
|
1841
|
+
if (element && element.id() !== VIRTUAL_ROOT) {
|
|
1842
|
+
return { id: "graph:" + element.id(), node: element.isNode(), value: element };
|
|
1843
|
+
}
|
|
1844
|
+
return layerHit;
|
|
1845
|
+
};
|
|
1846
|
+
let mouseId;
|
|
1847
|
+
const mouseHover = (target) => {
|
|
1848
|
+
if (target?.id === mouseId) return;
|
|
1849
|
+
mouseId = target?.id;
|
|
1850
|
+
actions.interact();
|
|
1851
|
+
actions.hover?.(target?.value ?? null);
|
|
2270
1852
|
};
|
|
2271
1853
|
const touch = touchGestures({
|
|
2272
1854
|
interact,
|
|
2273
|
-
hit(p)
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
return !hit || hit.id() === VIRTUAL_ROOT ? null : { id: hit.id(), node: hit.isNode(), value: hit };
|
|
2277
|
-
},
|
|
2278
|
-
preview: previewTouch,
|
|
2279
|
-
select: actions.selectTouch,
|
|
1855
|
+
hit: (p) => hit(p, true),
|
|
1856
|
+
preview: actions.preview,
|
|
1857
|
+
select: actions.select,
|
|
2280
1858
|
viewport: () => ({ zoom: cy.zoom(), pan: { ...cy.pan() } }),
|
|
2281
1859
|
move: (view) => cy.viewport(view),
|
|
2282
1860
|
limits: () => ({ min: cy.minZoom(), max: cy.maxZoom() })
|
|
@@ -2295,43 +1873,69 @@ function installGraphInput(cy, el, actions) {
|
|
|
2295
1873
|
actions.select(id === VIRTUAL_ROOT ? null : e.target);
|
|
2296
1874
|
if (id !== VIRTUAL_ROOT && lastTap.id === id && time - lastTap.time < 350) actions.focus?.(id);
|
|
2297
1875
|
lastTap = { id, time };
|
|
2298
|
-
}
|
|
1876
|
+
} else if (e.target.isEdge() && !e.target.hasClass("contains")) actions.select(e.target);
|
|
2299
1877
|
});
|
|
2300
1878
|
onCy("tapstart", actions.cancelFly);
|
|
2301
|
-
if (actions.hover) {
|
|
2302
|
-
onCy("mouseover", (e) => {
|
|
2303
|
-
if (e.target !== cy) {
|
|
2304
|
-
actions.interact();
|
|
2305
|
-
actions.hover(e.target);
|
|
2306
|
-
}
|
|
2307
|
-
});
|
|
2308
|
-
onCy("mouseout", (e) => {
|
|
2309
|
-
if (e.target !== cy) actions.hover(null);
|
|
2310
|
-
});
|
|
2311
|
-
}
|
|
2312
1879
|
const on = (name, fn, capture = false) => {
|
|
2313
|
-
|
|
2314
|
-
bindings.push(() =>
|
|
1880
|
+
pane.addEventListener(name, fn, { capture, passive: false });
|
|
1881
|
+
bindings.push(() => pane.removeEventListener(name, fn, capture));
|
|
2315
1882
|
};
|
|
2316
|
-
const
|
|
2317
|
-
|
|
1883
|
+
const captured = /* @__PURE__ */ new Set();
|
|
1884
|
+
let mixedTouch = false;
|
|
1885
|
+
const boundary = pane.closest("[data-gb-zoom-boundary]:not([data-gb-zoom-boundary] *)");
|
|
1886
|
+
const checkOrigins = (e) => {
|
|
1887
|
+
if (captured.size && !mixedTouch && Array.from(e.touches).some((t) => !pane.contains(t.target))) {
|
|
1888
|
+
mixedTouch = true;
|
|
1889
|
+
touch.cancel();
|
|
1890
|
+
}
|
|
1891
|
+
};
|
|
1892
|
+
boundary?.addEventListener("touchstart", checkOrigins, { capture: true, passive: true });
|
|
1893
|
+
let gestureZoom;
|
|
1894
|
+
const gestureStart = (e) => {
|
|
1895
|
+
e.preventDefault();
|
|
1896
|
+
if (!captured.size) {
|
|
1897
|
+
interact();
|
|
1898
|
+
gestureZoom = cy.zoom();
|
|
1899
|
+
}
|
|
1900
|
+
};
|
|
1901
|
+
const gestureChange = (e) => {
|
|
1902
|
+
e.preventDefault();
|
|
1903
|
+
if (gestureZoom === void 0 || captured.size) return;
|
|
1904
|
+
const { scale, clientX, clientY } = e;
|
|
1905
|
+
if (!Number.isFinite(scale) || scale <= 0) return;
|
|
1906
|
+
const rect = el.getBoundingClientRect();
|
|
1907
|
+
cy.zoom({ level: gestureZoom * scale, renderedPosition: {
|
|
1908
|
+
x: Number.isFinite(clientX) ? clientX - rect.left : rect.width / 2,
|
|
1909
|
+
y: Number.isFinite(clientY) ? clientY - rect.top : rect.height / 2
|
|
1910
|
+
} });
|
|
1911
|
+
};
|
|
1912
|
+
const gestureEnd = () => {
|
|
1913
|
+
gestureZoom = void 0;
|
|
1914
|
+
};
|
|
1915
|
+
pane.addEventListener("gesturestart", gestureStart, { passive: false });
|
|
1916
|
+
pane.addEventListener("gesturechange", gestureChange, { passive: false });
|
|
1917
|
+
pane.addEventListener("gestureend", gestureEnd);
|
|
1918
|
+
on("wheel", (e) => {
|
|
2318
1919
|
e.preventDefault();
|
|
2319
1920
|
interact();
|
|
2320
1921
|
if (e.ctrlKey || e.metaKey) {
|
|
1922
|
+
if (gestureZoom !== void 0) return;
|
|
2321
1923
|
const rect = el.getBoundingClientRect();
|
|
2322
1924
|
cy.zoom({
|
|
2323
1925
|
level: cy.zoom() * Math.exp(-e.deltaY * 0.01),
|
|
2324
1926
|
renderedPosition: { x: e.clientX - rect.left, y: e.clientY - rect.top }
|
|
2325
1927
|
});
|
|
2326
1928
|
} else cy.panBy({ x: -e.deltaX, y: -e.deltaY });
|
|
2327
|
-
};
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
const
|
|
2333
|
-
|
|
2334
|
-
|
|
1929
|
+
});
|
|
1930
|
+
on("pointerleave", (e) => {
|
|
1931
|
+
if (e.pointerType !== "touch") mouseHover(null);
|
|
1932
|
+
});
|
|
1933
|
+
let usingTouch = false;
|
|
1934
|
+
const useMouse = () => {
|
|
1935
|
+
if (usingTouch) {
|
|
1936
|
+
touch.cancel();
|
|
1937
|
+
usingTouch = false;
|
|
1938
|
+
}
|
|
2335
1939
|
};
|
|
2336
1940
|
const stop = (e) => {
|
|
2337
1941
|
if (e.cancelable) e.preventDefault();
|
|
@@ -2339,17 +1943,23 @@ function installGraphInput(cy, el, actions) {
|
|
|
2339
1943
|
};
|
|
2340
1944
|
on("pointerdown", (e) => {
|
|
2341
1945
|
if (e.pointerType !== "touch") {
|
|
2342
|
-
|
|
1946
|
+
useMouse();
|
|
2343
1947
|
return;
|
|
2344
1948
|
}
|
|
1949
|
+
mouseHover(null);
|
|
1950
|
+
usingTouch = true;
|
|
2345
1951
|
stop(e);
|
|
2346
1952
|
lastTap = { id: "", time: 0 };
|
|
2347
1953
|
captured.add(e.pointerId);
|
|
2348
|
-
|
|
2349
|
-
touch.down(e.pointerId, point(e));
|
|
1954
|
+
pane.setPointerCapture(e.pointerId);
|
|
1955
|
+
if (!mixedTouch) touch.down(e.pointerId, point(e));
|
|
2350
1956
|
}, true);
|
|
2351
1957
|
on("pointermove", (e) => {
|
|
2352
|
-
if (e.pointerType !== "touch"
|
|
1958
|
+
if (e.pointerType !== "touch") {
|
|
1959
|
+
useMouse();
|
|
1960
|
+
if (actions.hover && !e.buttons) mouseHover(hit(point(e), false));
|
|
1961
|
+
return;
|
|
1962
|
+
}
|
|
2353
1963
|
if (!captured.has(e.pointerId)) return;
|
|
2354
1964
|
stop(e);
|
|
2355
1965
|
touch.move(e.pointerId, point(e));
|
|
@@ -2358,13 +1968,16 @@ function installGraphInput(cy, el, actions) {
|
|
|
2358
1968
|
if (!captured.delete(e.pointerId)) return;
|
|
2359
1969
|
stop(e);
|
|
2360
1970
|
touch.up(e.pointerId, point(e));
|
|
2361
|
-
if (
|
|
1971
|
+
if (!captured.size) mixedTouch = false;
|
|
1972
|
+
if (pane.hasPointerCapture(e.pointerId)) pane.releasePointerCapture(e.pointerId);
|
|
2362
1973
|
}, true);
|
|
2363
1974
|
const cancel = () => {
|
|
1975
|
+
gestureEnd();
|
|
1976
|
+
mixedTouch = false;
|
|
2364
1977
|
touch.cancel();
|
|
2365
1978
|
const ids = [...captured];
|
|
2366
1979
|
captured.clear();
|
|
2367
|
-
for (const id of ids) if (
|
|
1980
|
+
for (const id of ids) if (pane.hasPointerCapture(id)) pane.releasePointerCapture(id);
|
|
2368
1981
|
};
|
|
2369
1982
|
on("pointercancel", (e) => {
|
|
2370
1983
|
if (captured.has(e.pointerId)) {
|
|
@@ -2379,21 +1992,48 @@ function installGraphInput(cy, el, actions) {
|
|
|
2379
1992
|
on("contextmenu", (e) => {
|
|
2380
1993
|
if (captured.size || e.pointerType === "touch") stop(e);
|
|
2381
1994
|
}, true);
|
|
2382
|
-
const previousTouchAction =
|
|
2383
|
-
|
|
1995
|
+
const previousTouchAction = pane.style.touchAction;
|
|
1996
|
+
pane.style.touchAction = "none";
|
|
2384
1997
|
const win = el.ownerDocument.defaultView;
|
|
2385
1998
|
win?.addEventListener("blur", cancel);
|
|
2386
1999
|
return () => {
|
|
2387
2000
|
touch.dispose();
|
|
2001
|
+
boundary?.removeEventListener("touchstart", checkOrigins, true);
|
|
2002
|
+
pane.removeEventListener("gesturestart", gestureStart);
|
|
2003
|
+
pane.removeEventListener("gesturechange", gestureChange);
|
|
2004
|
+
pane.removeEventListener("gestureend", gestureEnd);
|
|
2388
2005
|
bindings.forEach((off) => off());
|
|
2389
2006
|
win?.removeEventListener("blur", cancel);
|
|
2390
|
-
for (const id of captured) if (
|
|
2007
|
+
for (const id of captured) if (pane.hasPointerCapture(id)) pane.releasePointerCapture(id);
|
|
2391
2008
|
captured.clear();
|
|
2392
|
-
|
|
2009
|
+
pane.style.touchAction = previousTouchAction;
|
|
2393
2010
|
};
|
|
2394
2011
|
}
|
|
2395
2012
|
|
|
2396
2013
|
// src/react/camera.ts
|
|
2014
|
+
function frameTranslation(before, after) {
|
|
2015
|
+
let x = 0, y = 0, count = 0;
|
|
2016
|
+
for (const [id, a2] of Object.entries(after)) {
|
|
2017
|
+
const b2 = before[id];
|
|
2018
|
+
if (!b2) continue;
|
|
2019
|
+
x += a2.x - b2.x;
|
|
2020
|
+
y += a2.y - b2.y;
|
|
2021
|
+
count++;
|
|
2022
|
+
}
|
|
2023
|
+
if (count) return { x: x / count, y: y / count };
|
|
2024
|
+
const center = (points) => {
|
|
2025
|
+
let x1 = Infinity, y1 = Infinity, x2 = -Infinity, y2 = -Infinity;
|
|
2026
|
+
for (const p of Object.values(points)) {
|
|
2027
|
+
x1 = Math.min(x1, p.x);
|
|
2028
|
+
y1 = Math.min(y1, p.y);
|
|
2029
|
+
x2 = Math.max(x2, p.x);
|
|
2030
|
+
y2 = Math.max(y2, p.y);
|
|
2031
|
+
}
|
|
2032
|
+
return x1 === Infinity ? null : { x: (x1 + x2) / 2, y: (y1 + y2) / 2 };
|
|
2033
|
+
};
|
|
2034
|
+
const a = center(after), b = center(before);
|
|
2035
|
+
return a && b ? { x: a.x - b.x, y: a.y - b.y } : { x: 0, y: 0 };
|
|
2036
|
+
}
|
|
2397
2037
|
var toRect = (v, W, H) => ({
|
|
2398
2038
|
cx: (W / 2 - v.pan.x) / v.zoom,
|
|
2399
2039
|
cy: (H / 2 - v.pan.y) / v.zoom,
|
|
@@ -2425,73 +2065,29 @@ function zoomPath(a, b) {
|
|
|
2425
2065
|
return {
|
|
2426
2066
|
S,
|
|
2427
2067
|
at: (k) => {
|
|
2428
|
-
const s = k * S, c0 = Math.cosh(r0);
|
|
2429
|
-
const u = w0 / (rho2 * d1) * (c0 * Math.tanh(rho * s + r0) - Math.sinh(r0));
|
|
2430
|
-
return { cx: a.cx + u * dx, cy: a.cy + u * dy, hw: w0 * c0 / Math.cosh(rho * s + r0) / 2 };
|
|
2431
|
-
}
|
|
2432
|
-
};
|
|
2433
|
-
}
|
|
2434
|
-
var easeInOut = (x) => x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2;
|
|
2435
|
-
|
|
2436
|
-
// src/react/GlassPlanes.tsx
|
|
2437
|
-
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
2438
|
-
function GlassPlanes({ plates, viewport, theme, alpha, hot }) {
|
|
2439
|
-
return /* @__PURE__ */ jsx2("div", { className: "gb-glass-planes", style: { opacity: alpha }, "aria-hidden": "true", children: plates.map((p) => {
|
|
2440
|
-
const points = p.points.map(([x, y]) => [x * viewport.zoom + viewport.pan.x, y * viewport.zoom + viewport.pan.y]);
|
|
2441
|
-
const left = Math.min(...points.map((p2) => p2[0])), top = Math.min(...points.map((p2) => p2[1]));
|
|
2442
|
-
const width = Math.max(...points.map((p2) => p2[0])) - left, height = Math.max(...points.map((p2) => p2[1])) - top;
|
|
2443
|
-
if (width <= 0 || height <= 0) return null;
|
|
2444
|
-
const local = points.map(([x, y]) => [x - left, y - top]);
|
|
2445
|
-
const clip = `polygon(${local.map(([x, y]) => `${100 * x / width}% ${100 * y / height}%`).join(",")})`;
|
|
2446
|
-
const c = plateColors(theme, p.color);
|
|
2447
|
-
const hue = mixHex(theme.canvas, p.color, 0.64);
|
|
2448
|
-
return /* @__PURE__ */ jsxs2(
|
|
2449
|
-
"div",
|
|
2450
|
-
{
|
|
2451
|
-
className: "gb-glass-plane",
|
|
2452
|
-
"data-layer": p.layer,
|
|
2453
|
-
style: { left, top, width, height, opacity: (p.alpha ?? 1) * (hot && hot !== p.layer ? 0.45 : 1) },
|
|
2454
|
-
children: [
|
|
2455
|
-
/* @__PURE__ */ jsx2("div", { className: "gb-glass-surface", style: {
|
|
2456
|
-
clipPath: clip,
|
|
2457
|
-
background: `linear-gradient(165deg, #ffffff26, #ffffff00 38%), linear-gradient(145deg, ${hue}6d, ${hue}${hot === p.layer ? "48" : "2d"} 55%, ${hue}5b)`
|
|
2458
|
-
} }),
|
|
2459
|
-
/* @__PURE__ */ jsxs2("svg", { width, height, className: "gb-glass-rim", children: [
|
|
2460
|
-
/* @__PURE__ */ jsx2("polygon", { points: local.map((p2) => p2.join(",")).join(" "), fill: "none", stroke: c.stroke, strokeOpacity: 0.8, strokeWidth: hot === p.layer ? 2.25 : 1.5 }),
|
|
2461
|
-
/* @__PURE__ */ jsx2("polyline", { points: local.slice(0, 3).map((p2) => p2.join(",")).join(" "), fill: "none", stroke: mixHex(p.color, "#ffffff", 0.72), strokeOpacity: 0.85, strokeWidth: 1.25 })
|
|
2462
|
-
] })
|
|
2463
|
-
]
|
|
2464
|
-
},
|
|
2465
|
-
p.layer
|
|
2466
|
-
);
|
|
2467
|
-
}) });
|
|
2068
|
+
const s = k * S, c0 = Math.cosh(r0);
|
|
2069
|
+
const u = w0 / (rho2 * d1) * (c0 * Math.tanh(rho * s + r0) - Math.sinh(r0));
|
|
2070
|
+
return { cx: a.cx + u * dx, cy: a.cy + u * dy, hw: w0 * c0 / Math.cosh(rho * s + r0) / 2 };
|
|
2071
|
+
}
|
|
2072
|
+
};
|
|
2468
2073
|
}
|
|
2074
|
+
var easeInOut = (x) => x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2;
|
|
2469
2075
|
|
|
2470
2076
|
// src/react/EditPanel.tsx
|
|
2471
|
-
import { useEffect as useEffect2, useId, useMemo as useMemo2, useRef as useRef2, useState as useState3 } from "react";
|
|
2472
|
-
import { Fragment as Fragment2, jsx as
|
|
2077
|
+
import { useEffect as useEffect2, useId as useId2, useMemo as useMemo2, useRef as useRef2, useState as useState3 } from "react";
|
|
2078
|
+
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
2473
2079
|
var PICK_MAX = 8;
|
|
2474
|
-
function NodeRef({ id, model, colorOf, sub }) {
|
|
2475
|
-
const n = model.index.get(id);
|
|
2476
|
-
return /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
2477
|
-
/* @__PURE__ */ jsx3("i", { className: "gb-dot", style: { background: colorOf(id) } }),
|
|
2478
|
-
/* @__PURE__ */ jsxs3("span", { className: "gb-ref-main", children: [
|
|
2479
|
-
/* @__PURE__ */ jsx3("span", { className: "gb-ref-label", children: n?.label ?? id }),
|
|
2480
|
-
sub && /* @__PURE__ */ jsx3("span", { className: "gb-ref-sub", children: sub })
|
|
2481
|
-
] })
|
|
2482
|
-
] });
|
|
2483
|
-
}
|
|
2484
2080
|
function NodePicker({ model, value, onChange, exclude, empty, autoFocus, label, colorOf, id: inputId }) {
|
|
2485
2081
|
const t = useStrings();
|
|
2486
|
-
const [
|
|
2082
|
+
const [q, setQ] = useState3("");
|
|
2487
2083
|
const [open, setOpen] = useState3(false);
|
|
2488
2084
|
const [active, setActive] = useState3(0);
|
|
2489
2085
|
const idx = useMemo2(() => indexModel(model), [model]);
|
|
2490
2086
|
const hits = useMemo2(
|
|
2491
|
-
() =>
|
|
2492
|
-
[model,
|
|
2087
|
+
() => q.trim() ? searchNodes(model, q).filter((id) => !exclude?.(id)).slice(0, PICK_MAX) : [],
|
|
2088
|
+
[model, q, exclude]
|
|
2493
2089
|
);
|
|
2494
|
-
useEffect2(() => setActive(0), [
|
|
2090
|
+
useEffect2(() => setActive(0), [q]);
|
|
2495
2091
|
const curRef = useRef2(null);
|
|
2496
2092
|
const refocus = useRef2(false);
|
|
2497
2093
|
const choose = (id) => {
|
|
@@ -2508,38 +2104,48 @@ function NodePicker({ model, value, onChange, exclude, empty, autoFocus, label,
|
|
|
2508
2104
|
}
|
|
2509
2105
|
});
|
|
2510
2106
|
const pathOf = (id) => idx.ancestorsOf(id).slice(0, 2).reverse().map((a) => model.index.get(a)?.label).filter(Boolean).join(" / ");
|
|
2511
|
-
return /* @__PURE__ */
|
|
2512
|
-
cur && !open ? /* @__PURE__ */
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
e.
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
/* @__PURE__ */
|
|
2530
|
-
|
|
2107
|
+
return /* @__PURE__ */ jsxs2("div", { className: `gb-pick${open ? " is-open" : ""}`, children: [
|
|
2108
|
+
cur && !open ? /* @__PURE__ */ jsxs2("span", { className: "gb-input gb-pick-selected", children: [
|
|
2109
|
+
/* @__PURE__ */ jsx2(
|
|
2110
|
+
"button",
|
|
2111
|
+
{
|
|
2112
|
+
ref: curRef,
|
|
2113
|
+
type: "button",
|
|
2114
|
+
id: inputId,
|
|
2115
|
+
className: "gb-pick-cur",
|
|
2116
|
+
"aria-label": `${label}: ${cur.label}`,
|
|
2117
|
+
onClick: () => setOpen(true),
|
|
2118
|
+
onKeyDown: (e) => {
|
|
2119
|
+
if (e.key === "Backspace" || e.key === "Delete") {
|
|
2120
|
+
e.preventDefault();
|
|
2121
|
+
choose(null);
|
|
2122
|
+
setOpen(true);
|
|
2123
|
+
}
|
|
2124
|
+
},
|
|
2125
|
+
children: /* @__PURE__ */ jsx2(NodeRef, { id: cur.id, model, colorOf, sub: cur.id === cur.label ? void 0 : cur.id })
|
|
2126
|
+
}
|
|
2127
|
+
),
|
|
2128
|
+
/* @__PURE__ */ jsx2(
|
|
2129
|
+
"button",
|
|
2130
|
+
{
|
|
2131
|
+
type: "button",
|
|
2132
|
+
className: "gb-ibtn gb-pick-x",
|
|
2133
|
+
"aria-label": t.clearField + " " + label,
|
|
2134
|
+
onClick: () => {
|
|
2531
2135
|
choose(null);
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2136
|
+
setOpen(true);
|
|
2137
|
+
},
|
|
2138
|
+
children: /* @__PURE__ */ jsx2(Icon, { d: I.clear, size: 15 })
|
|
2139
|
+
}
|
|
2140
|
+
)
|
|
2141
|
+
] }) : /* @__PURE__ */ jsxs2("span", { className: "gb-input gb-pick-field", children: [
|
|
2142
|
+
/* @__PURE__ */ jsx2(Icon, { d: I.search, size: 14 }),
|
|
2143
|
+
/* @__PURE__ */ jsx2(
|
|
2538
2144
|
"input",
|
|
2539
2145
|
{
|
|
2540
2146
|
id: inputId,
|
|
2541
2147
|
"aria-label": label,
|
|
2542
|
-
value:
|
|
2148
|
+
value: q,
|
|
2543
2149
|
spellCheck: false,
|
|
2544
2150
|
placeholder: value === null && empty ? empty : t.pick,
|
|
2545
2151
|
autoFocus: autoFocus || open,
|
|
@@ -2568,7 +2174,7 @@ function NodePicker({ model, value, onChange, exclude, empty, autoFocus, label,
|
|
|
2568
2174
|
}
|
|
2569
2175
|
)
|
|
2570
2176
|
] }),
|
|
2571
|
-
open && hits.length > 0 && /* @__PURE__ */
|
|
2177
|
+
open && hits.length > 0 && /* @__PURE__ */ jsx2("ul", { className: "gb-pick-list gb-glass gb-raised gb-round", role: "listbox", onMouseDown: (e) => e.preventDefault(), children: hits.map((id, i) => /* @__PURE__ */ jsx2(
|
|
2572
2178
|
"li",
|
|
2573
2179
|
{
|
|
2574
2180
|
role: "option",
|
|
@@ -2576,7 +2182,7 @@ function NodePicker({ model, value, onChange, exclude, empty, autoFocus, label,
|
|
|
2576
2182
|
className: i === active ? "on" : "",
|
|
2577
2183
|
onMouseEnter: () => setActive(i),
|
|
2578
2184
|
onClick: () => choose(id),
|
|
2579
|
-
children: /* @__PURE__ */
|
|
2185
|
+
children: /* @__PURE__ */ jsx2(NodeRef, { id, model, colorOf, sub: pathOf(id) || id })
|
|
2580
2186
|
},
|
|
2581
2187
|
id
|
|
2582
2188
|
)) })
|
|
@@ -2599,45 +2205,20 @@ function readContent(text) {
|
|
|
2599
2205
|
if (Object.keys(d).length) out.data = d;
|
|
2600
2206
|
return out;
|
|
2601
2207
|
}
|
|
2602
|
-
function
|
|
2603
|
-
|
|
2604
|
-
return /* @__PURE__ */ jsxs3(
|
|
2605
|
-
"form",
|
|
2606
|
-
{
|
|
2607
|
-
className: "gb-detail gb-edit",
|
|
2608
|
-
onSubmit: (e) => {
|
|
2609
|
-
e.preventDefault();
|
|
2610
|
-
onSubmit();
|
|
2611
|
-
},
|
|
2612
|
-
onKeyDown: (e) => {
|
|
2613
|
-
if (e.key === "Escape" && !e.defaultPrevented) onClose();
|
|
2614
|
-
},
|
|
2615
|
-
children: [
|
|
2616
|
-
/* @__PURE__ */ jsxs3("div", { className: "gb-dh", children: [
|
|
2617
|
-
/* @__PURE__ */ jsx3("span", { className: "gb-dh-title", children: title }),
|
|
2618
|
-
/* @__PURE__ */ jsx3("span", { className: "gb-dh-act", children: /* @__PURE__ */ jsx3("button", { type: "button", className: "gb-ibtn", onClick: onClose, "aria-label": t.close, title: t.close, children: /* @__PURE__ */ jsx3(Icon, { d: I.x, size: 15 }) }) })
|
|
2619
|
-
] }),
|
|
2620
|
-
/* @__PURE__ */ jsx3("div", { className: "gb-db gb-form", children }),
|
|
2621
|
-
error && /* @__PURE__ */ jsx3("div", { className: "gb-edit-err", role: "alert", children: error }),
|
|
2622
|
-
/* @__PURE__ */ jsx3("div", { className: "gb-df", children: foot })
|
|
2623
|
-
]
|
|
2624
|
-
}
|
|
2625
|
-
);
|
|
2626
|
-
}
|
|
2627
|
-
function EditPanel({ target, model, onSubmit, onCancel, onRetarget, renderEditor, colorOf = () => void 0 }) {
|
|
2628
|
-
return target.what === "node" ? /* @__PURE__ */ jsx3(
|
|
2208
|
+
function EditPanel({ target, model, onSubmit, onCancel, kindLabels, renderEditor, colorOf = () => void 0 }) {
|
|
2209
|
+
return target.what === "node" ? /* @__PURE__ */ jsx2(
|
|
2629
2210
|
NodeForm,
|
|
2630
2211
|
{
|
|
2631
2212
|
target,
|
|
2632
2213
|
model,
|
|
2633
2214
|
onSubmit,
|
|
2634
2215
|
onCancel,
|
|
2635
|
-
|
|
2216
|
+
kindLabels,
|
|
2636
2217
|
renderEditor,
|
|
2637
2218
|
colorOf
|
|
2638
2219
|
},
|
|
2639
2220
|
target.id ?? "+"
|
|
2640
|
-
) : /* @__PURE__ */
|
|
2221
|
+
) : /* @__PURE__ */ jsx2(EdgeForm, { targetSpec: target, model, onSubmit, onCancel, colorOf }, target.edge ? edgeKey(target.edge) : "+");
|
|
2641
2222
|
}
|
|
2642
2223
|
function useSubmit(onSubmit) {
|
|
2643
2224
|
const t = useStrings();
|
|
@@ -2649,9 +2230,16 @@ function useSubmit(onSubmit) {
|
|
|
2649
2230
|
};
|
|
2650
2231
|
return { error, setError, submit };
|
|
2651
2232
|
}
|
|
2652
|
-
function
|
|
2233
|
+
function SaveActions({ onCancel, label, disabled }) {
|
|
2234
|
+
const t = useStrings();
|
|
2235
|
+
return /* @__PURE__ */ jsxs2("span", { className: "gb-form-act", children: [
|
|
2236
|
+
/* @__PURE__ */ jsx2("button", { type: "button", className: "gb-btn", onClick: onCancel, children: t.cancel }),
|
|
2237
|
+
/* @__PURE__ */ jsx2("button", { type: "submit", className: "gb-btn gb-primary", disabled, children: label })
|
|
2238
|
+
] });
|
|
2239
|
+
}
|
|
2240
|
+
function NodeForm({ target, model, onSubmit, onCancel, kindLabels, renderEditor, colorOf }) {
|
|
2653
2241
|
const t = useStrings();
|
|
2654
|
-
const uid =
|
|
2242
|
+
const uid = useId2();
|
|
2655
2243
|
const { error, setError, submit } = useSubmit(onSubmit);
|
|
2656
2244
|
const node = target.id ? model.index.get(target.id) : void 0;
|
|
2657
2245
|
const creating = !node;
|
|
@@ -2663,27 +2251,19 @@ function NodeForm({ target, model, onSubmit, onCancel, onRetarget, renderEditor,
|
|
|
2663
2251
|
);
|
|
2664
2252
|
const [text, setText] = useState3(initial);
|
|
2665
2253
|
const initialBefore = useMemo2(() => {
|
|
2666
|
-
const
|
|
2667
|
-
return node ?
|
|
2254
|
+
const siblings2 = childrenOf(model, node?.parent ?? target.parent);
|
|
2255
|
+
return node ? siblings2[siblings2.findIndex((n) => n.id === node.id) + 1]?.id ?? null : null;
|
|
2668
2256
|
}, [model, node, target.parent]);
|
|
2669
2257
|
const [before, setBefore] = useState3(initialBefore);
|
|
2258
|
+
const [nested, setNested] = useState3(null);
|
|
2670
2259
|
const [confirming, setConfirming] = useState3(false);
|
|
2671
2260
|
const idErr = creating && id ? checkEdit(model, { op: "addNode", id, set: {} }) : null;
|
|
2672
2261
|
const below = useMemo2(() => {
|
|
2673
2262
|
if (!node) return null;
|
|
2674
|
-
|
|
2675
|
-
let grew = true;
|
|
2676
|
-
while (grew) {
|
|
2677
|
-
grew = false;
|
|
2678
|
-
for (const n of model.nodes) if (n.parent && out.has(n.parent) && !out.has(n.id)) {
|
|
2679
|
-
out.add(n.id);
|
|
2680
|
-
grew = true;
|
|
2681
|
-
}
|
|
2682
|
-
}
|
|
2683
|
-
return out;
|
|
2263
|
+
return indexModel(model).subtreeOf(node.id);
|
|
2684
2264
|
}, [model, node]);
|
|
2685
2265
|
const edges = node ? edgesOf(model, node.id) : [];
|
|
2686
|
-
const
|
|
2266
|
+
const children = node ? childrenOf(model, node.id) : [];
|
|
2687
2267
|
const save = () => {
|
|
2688
2268
|
const content = readContent(text);
|
|
2689
2269
|
if (!content) {
|
|
@@ -2706,185 +2286,192 @@ function NodeForm({ target, model, onSubmit, onCancel, onRetarget, renderEditor,
|
|
|
2706
2286
|
}
|
|
2707
2287
|
if (submit({ op: "updateNode", id: node.id, set })) onCancel();
|
|
2708
2288
|
};
|
|
2709
|
-
const foot = confirming && node ? /* @__PURE__ */
|
|
2710
|
-
/* @__PURE__ */
|
|
2711
|
-
/* @__PURE__ */
|
|
2712
|
-
/* @__PURE__ */
|
|
2713
|
-
/* @__PURE__ */
|
|
2289
|
+
const foot = confirming && node ? /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
2290
|
+
/* @__PURE__ */ jsx2("span", { className: "gb-confirm", children: t.confirmRemove(edges.length) }),
|
|
2291
|
+
/* @__PURE__ */ jsxs2("span", { className: "gb-form-act", children: [
|
|
2292
|
+
/* @__PURE__ */ jsx2("button", { type: "button", className: "gb-btn", onClick: () => setConfirming(false), children: t.cancel }),
|
|
2293
|
+
/* @__PURE__ */ jsxs2("button", { type: "button", className: "gb-btn gb-danger", onClick: () => {
|
|
2714
2294
|
if (submit({ op: "removeNode", id: node.id })) onCancel();
|
|
2715
|
-
}, children:
|
|
2295
|
+
}, children: [
|
|
2296
|
+
/* @__PURE__ */ jsx2(Icon, { d: I.trash, size: 15 }),
|
|
2297
|
+
t.remove
|
|
2298
|
+
] })
|
|
2716
2299
|
] })
|
|
2717
|
-
] }) : /* @__PURE__ */
|
|
2718
|
-
node ? /* @__PURE__ */
|
|
2300
|
+
] }) : /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
2301
|
+
node ? /* @__PURE__ */ jsxs2(
|
|
2719
2302
|
"button",
|
|
2720
2303
|
{
|
|
2721
2304
|
type: "button",
|
|
2722
2305
|
className: "gb-btn gb-danger-text",
|
|
2723
|
-
disabled:
|
|
2724
|
-
title:
|
|
2306
|
+
disabled: children.length > 0,
|
|
2307
|
+
title: children.length > 0 ? t.error["has-children"] : void 0,
|
|
2725
2308
|
onClick: () => setConfirming(true),
|
|
2726
|
-
children:
|
|
2309
|
+
children: [
|
|
2310
|
+
/* @__PURE__ */ jsx2(Icon, { d: I.trash, size: 15 }),
|
|
2311
|
+
t.remove
|
|
2312
|
+
]
|
|
2727
2313
|
}
|
|
2728
|
-
) : /* @__PURE__ */
|
|
2729
|
-
/* @__PURE__ */
|
|
2730
|
-
/* @__PURE__ */ jsx3("button", { type: "button", className: "gb-btn", onClick: onCancel, children: t.cancel }),
|
|
2731
|
-
/* @__PURE__ */ jsx3("button", { type: "submit", className: "gb-btn gb-primary", disabled: creating && (!id.trim() || !!idErr), children: creating ? t.create : t.save })
|
|
2732
|
-
] })
|
|
2314
|
+
) : /* @__PURE__ */ jsx2("span", {}),
|
|
2315
|
+
/* @__PURE__ */ jsx2(SaveActions, { onCancel, label: creating ? t.create : t.save, disabled: creating && (!id.trim() || !!idErr) })
|
|
2733
2316
|
] });
|
|
2734
|
-
return /* @__PURE__ */
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2317
|
+
if (nested) return /* @__PURE__ */ jsx2(EditPanel, { target: nested, ...{ model, onSubmit, renderEditor, colorOf, kindLabels }, onCancel: () => setNested(null) });
|
|
2318
|
+
const siblings = childrenOf(model, parent).filter((n) => n.id !== node?.id);
|
|
2319
|
+
const ordered = !parent || model.index.get(parent)?.data?.unordered !== true;
|
|
2320
|
+
return /* @__PURE__ */ jsxs2(
|
|
2321
|
+
Inspector,
|
|
2322
|
+
{
|
|
2323
|
+
title: node?.label ?? t.newNode,
|
|
2324
|
+
objectId: node?.id,
|
|
2325
|
+
mark: node && /* @__PURE__ */ jsx2(NodeDot, { color: colorOf(node.id) }),
|
|
2326
|
+
kind: node && (node.kind ? kindLabels?.[node.kind] ?? node.kind : t.node),
|
|
2327
|
+
onClose: onCancel,
|
|
2328
|
+
onSubmit: save,
|
|
2329
|
+
foot,
|
|
2330
|
+
error,
|
|
2331
|
+
children: [
|
|
2332
|
+
creating && /* @__PURE__ */ jsxs2(InspectorField, { label: t.id, htmlFor: `${uid}-id`, children: [
|
|
2333
|
+
/* @__PURE__ */ jsx2(
|
|
2334
|
+
"input",
|
|
2335
|
+
{
|
|
2336
|
+
id: `${uid}-id`,
|
|
2337
|
+
className: `gb-input${idErr ? " is-bad" : ""}`,
|
|
2338
|
+
value: id,
|
|
2339
|
+
autoFocus: true,
|
|
2340
|
+
spellCheck: false,
|
|
2341
|
+
onChange: (e) => setId(e.target.value)
|
|
2342
|
+
}
|
|
2343
|
+
),
|
|
2344
|
+
/* @__PURE__ */ jsx2("small", { className: idErr ? "is-bad" : "", children: idErr ? t.error[idErr] : t.idHint })
|
|
2345
|
+
] }),
|
|
2346
|
+
/* @__PURE__ */ jsxs2("div", { className: "gb-field-pair", children: [
|
|
2347
|
+
/* @__PURE__ */ jsx2(InspectorField, { label: t.parent, htmlFor: `${uid}-parent`, children: /* @__PURE__ */ jsx2(
|
|
2348
|
+
NodePicker,
|
|
2349
|
+
{
|
|
2350
|
+
id: `${uid}-parent`,
|
|
2351
|
+
model,
|
|
2352
|
+
value: parent,
|
|
2353
|
+
onChange: (id2) => {
|
|
2354
|
+
setParent(id2);
|
|
2355
|
+
setBefore(null);
|
|
2356
|
+
},
|
|
2357
|
+
empty: t.noParent,
|
|
2358
|
+
label: t.parent,
|
|
2359
|
+
exclude: below ? (x) => below.has(x) : void 0,
|
|
2360
|
+
colorOf
|
|
2361
|
+
}
|
|
2362
|
+
) }),
|
|
2363
|
+
ordered && /* @__PURE__ */ jsx2(InspectorField, { label: t.position, htmlFor: `${uid}-before`, children: /* @__PURE__ */ jsxs2("select", { id: `${uid}-before`, className: "gb-input", value: before ?? "", onChange: (e) => setBefore(e.target.value || null), children: [
|
|
2364
|
+
siblings.map((n, i) => /* @__PURE__ */ jsx2("option", { value: n.id, children: i + 1 }, n.id)),
|
|
2365
|
+
/* @__PURE__ */ jsx2("option", { value: "", children: siblings.length + 1 })
|
|
2366
|
+
] }) })
|
|
2367
|
+
] }),
|
|
2368
|
+
node && /* @__PURE__ */ jsx2(
|
|
2369
|
+
NodeRelations,
|
|
2740
2370
|
{
|
|
2741
|
-
id:
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
onChange: (e) => setId(e.target.value)
|
|
2371
|
+
id: node.id,
|
|
2372
|
+
current: { model, children, edges, colorOf },
|
|
2373
|
+
kindLabels,
|
|
2374
|
+
onAdd: (group) => setNested(group === "child" ? { what: "node", parent: node.id } : { what: "edge", ...group === "in" ? { target: node.id } : { source: node.id } }),
|
|
2375
|
+
onEditEdge: (edge) => setNested({ what: "edge", edge })
|
|
2747
2376
|
}
|
|
2748
2377
|
),
|
|
2749
|
-
/* @__PURE__ */
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
colorOf
|
|
2768
|
-
}
|
|
2769
|
-
)
|
|
2770
|
-
] }),
|
|
2771
|
-
/* @__PURE__ */ jsxs3("div", { className: "gb-fld", children: [
|
|
2772
|
-
/* @__PURE__ */ jsx3("label", { className: "gb-k", htmlFor: `${uid}-before`, children: "Before" }),
|
|
2773
|
-
/* @__PURE__ */ jsxs3("select", { id: `${uid}-before`, className: "gb-input", value: before ?? "", onChange: (e) => setBefore(e.target.value || null), children: [
|
|
2774
|
-
/* @__PURE__ */ jsx3("option", { value: "", children: "Last" }),
|
|
2775
|
-
model.nodes.filter((n) => n.id !== node?.id && (n.parent ?? null) === parent).sort((a, b) => (a.order ?? Infinity) - (b.order ?? Infinity)).map((n) => /* @__PURE__ */ jsx3("option", { value: n.id, children: n.label }, n.id))
|
|
2776
|
-
] })
|
|
2777
|
-
] }),
|
|
2778
|
-
/* @__PURE__ */ jsxs3("div", { className: "gb-fld gb-grow", children: [
|
|
2779
|
-
/* @__PURE__ */ jsxs3("label", { className: "gb-k", htmlFor: `${uid}-json`, children: [
|
|
2780
|
-
t.content,
|
|
2781
|
-
" ",
|
|
2782
|
-
/* @__PURE__ */ jsx3("em", { children: t.contentHint })
|
|
2783
|
-
] }),
|
|
2784
|
-
renderEditor ? renderEditor({ value: text, onChange: setText }) : /* @__PURE__ */ jsx3(
|
|
2785
|
-
"textarea",
|
|
2786
|
-
{
|
|
2787
|
-
id: `${uid}-json`,
|
|
2788
|
-
className: "gb-input gb-json",
|
|
2789
|
-
value: text,
|
|
2790
|
-
spellCheck: false,
|
|
2791
|
-
rows: 9,
|
|
2792
|
-
onChange: (e) => setText(e.target.value)
|
|
2793
|
-
}
|
|
2794
|
-
)
|
|
2795
|
-
] }),
|
|
2796
|
-
node && /* @__PURE__ */ jsxs3("div", { className: "gb-fld", children: [
|
|
2797
|
-
/* @__PURE__ */ jsxs3("span", { className: "gb-k", children: [
|
|
2798
|
-
t.relations,
|
|
2799
|
-
" ",
|
|
2800
|
-
/* @__PURE__ */ jsx3("em", { children: edges.length || "" })
|
|
2801
|
-
] }),
|
|
2802
|
-
/* @__PURE__ */ jsx3("ul", { className: "gb-rel", children: edges.map((e, i) => {
|
|
2803
|
-
const out = e.source === node.id;
|
|
2804
|
-
return /* @__PURE__ */ jsxs3("li", { children: [
|
|
2805
|
-
/* @__PURE__ */ jsx3("span", { className: "gb-rel-dir", "aria-hidden": true, children: out ? "\u2192" : "\u2190" }),
|
|
2806
|
-
/* @__PURE__ */ jsx3(NodeRef, { id: out ? e.target : e.source, model, colorOf }),
|
|
2807
|
-
e.kind && /* @__PURE__ */ jsx3("span", { className: "gb-r-kind", children: e.kind }),
|
|
2808
|
-
/* @__PURE__ */ jsx3(
|
|
2809
|
-
"button",
|
|
2810
|
-
{
|
|
2811
|
-
type: "button",
|
|
2812
|
-
className: "gb-ibtn",
|
|
2813
|
-
"aria-label": t.removeEdge,
|
|
2814
|
-
title: t.removeEdge,
|
|
2815
|
-
onClick: () => submit({ op: "removeEdge", edge: { source: e.source, target: e.target, kind: e.kind } }),
|
|
2816
|
-
children: /* @__PURE__ */ jsx3(Icon, { d: I.x, size: 13 })
|
|
2817
|
-
}
|
|
2818
|
-
)
|
|
2819
|
-
] }, i);
|
|
2820
|
-
}) }),
|
|
2821
|
-
/* @__PURE__ */ jsxs3("button", { type: "button", className: "gb-add", onClick: () => onRetarget({ what: "edge", source: node.id }), children: [
|
|
2822
|
-
/* @__PURE__ */ jsx3(Icon, { d: I.plus, size: 13 }),
|
|
2823
|
-
t.addEdge
|
|
2824
|
-
] })
|
|
2825
|
-
] })
|
|
2826
|
-
] });
|
|
2378
|
+
/* @__PURE__ */ jsx2(InspectorField, { htmlFor: `${uid}-json`, label: /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
2379
|
+
t.content,
|
|
2380
|
+
" ",
|
|
2381
|
+
/* @__PURE__ */ jsx2("em", { children: t.contentHint })
|
|
2382
|
+
] }), children: renderEditor ? renderEditor({ value: text, onChange: setText }) : /* @__PURE__ */ jsx2(
|
|
2383
|
+
"textarea",
|
|
2384
|
+
{
|
|
2385
|
+
id: `${uid}-json`,
|
|
2386
|
+
className: "gb-input gb-json",
|
|
2387
|
+
value: text,
|
|
2388
|
+
spellCheck: false,
|
|
2389
|
+
rows: 5,
|
|
2390
|
+
onChange: (e) => setText(e.target.value)
|
|
2391
|
+
}
|
|
2392
|
+
) })
|
|
2393
|
+
]
|
|
2394
|
+
}
|
|
2395
|
+
);
|
|
2827
2396
|
}
|
|
2828
|
-
function EdgeForm({
|
|
2397
|
+
function EdgeForm({ targetSpec, model, onSubmit, onCancel, colorOf }) {
|
|
2829
2398
|
const t = useStrings();
|
|
2830
|
-
const uid =
|
|
2399
|
+
const uid = useId2();
|
|
2831
2400
|
const { error, submit } = useSubmit(onSubmit);
|
|
2832
|
-
const
|
|
2833
|
-
const
|
|
2834
|
-
const [
|
|
2835
|
-
const [
|
|
2401
|
+
const original = targetSpec.edge && { source: targetSpec.edge.source, target: targetSpec.edge.target, kind: targetSpec.edge.kind };
|
|
2402
|
+
const existing = original && model.edges.find((e) => sameEdge(e, original));
|
|
2403
|
+
const [source, setSource] = useState3(original?.source ?? targetSpec.source ?? null);
|
|
2404
|
+
const [target, setTarget] = useState3(original?.target ?? targetSpec.target ?? null);
|
|
2405
|
+
const [kind, setKind] = useState3(existing?.kind ?? "");
|
|
2406
|
+
const [label, setLabel] = useState3(existing?.label ?? "");
|
|
2836
2407
|
const kinds = useMemo2(() => [...new Set(model.edges.map((e) => e.kind).filter(Boolean))].sort(), [model]);
|
|
2837
2408
|
const save = () => {
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2409
|
+
if (!source || !target) return;
|
|
2410
|
+
if (original) {
|
|
2411
|
+
const set = {};
|
|
2412
|
+
if (source !== original.source) set.source = source;
|
|
2413
|
+
if (target !== original.target) set.target = target;
|
|
2414
|
+
if (kind !== (existing?.kind ?? "")) set.kind = kind.trim();
|
|
2415
|
+
if (label !== (existing?.label ?? "")) set.label = label.trim();
|
|
2416
|
+
if (existing && !Object.keys(set).length) {
|
|
2417
|
+
onCancel();
|
|
2418
|
+
return;
|
|
2419
|
+
}
|
|
2420
|
+
if (submit({ op: "updateEdge", edge: original, set })) onCancel();
|
|
2421
|
+
} else if (submit({ op: "addEdge", edge: { source, target, ...kind.trim() && { kind: kind.trim() }, ...label.trim() && { label: label.trim() } } })) {
|
|
2422
|
+
onCancel();
|
|
2423
|
+
}
|
|
2843
2424
|
};
|
|
2844
|
-
const foot = /* @__PURE__ */
|
|
2845
|
-
/* @__PURE__ */
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
/* @__PURE__ */
|
|
2849
|
-
|
|
2850
|
-
] });
|
|
2851
|
-
return /* @__PURE__ */ jsxs3(Shell, { title: t.newEdge, onClose: onCancel, onSubmit: save, foot, error, children: [
|
|
2852
|
-
/* @__PURE__ */ jsxs3("div", { className: "gb-fld", children: [
|
|
2853
|
-
/* @__PURE__ */ jsx3("label", { className: "gb-k", htmlFor: `${uid}-s`, children: t.source }),
|
|
2854
|
-
/* @__PURE__ */ jsx3(NodePicker, { id: `${uid}-s`, model, value: source, onChange: setSource, autoFocus: !src, label: t.source, colorOf })
|
|
2425
|
+
const foot = /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
2426
|
+
original && /* @__PURE__ */ jsxs2("button", { type: "button", className: "gb-btn gb-danger-text", onClick: () => {
|
|
2427
|
+
if (submit({ op: "removeEdge", edge: original })) onCancel();
|
|
2428
|
+
}, children: [
|
|
2429
|
+
/* @__PURE__ */ jsx2(Icon, { d: I.trash, size: 15 }),
|
|
2430
|
+
t.remove
|
|
2855
2431
|
] }),
|
|
2856
|
-
/* @__PURE__ */
|
|
2857
|
-
|
|
2858
|
-
|
|
2432
|
+
/* @__PURE__ */ jsx2(SaveActions, { onCancel, label: original ? t.save : t.create, disabled: !source || !target })
|
|
2433
|
+
] });
|
|
2434
|
+
return /* @__PURE__ */ jsxs2(Inspector, { title: original ? t.editEdge : t.newEdge, onClose: onCancel, onSubmit: save, foot, error, children: [
|
|
2435
|
+
/* @__PURE__ */ jsxs2("div", { className: "gb-field-pair", children: [
|
|
2436
|
+
/* @__PURE__ */ jsx2(InspectorField, { label: t.source, htmlFor: `${uid}-s`, children: /* @__PURE__ */ jsx2(
|
|
2437
|
+
NodePicker,
|
|
2438
|
+
{
|
|
2439
|
+
id: `${uid}-s`,
|
|
2440
|
+
model,
|
|
2441
|
+
value: source,
|
|
2442
|
+
onChange: setSource,
|
|
2443
|
+
autoFocus: !original && !targetSpec.source,
|
|
2444
|
+
label: t.source,
|
|
2445
|
+
colorOf,
|
|
2446
|
+
exclude: target ? (x) => x === target : void 0
|
|
2447
|
+
}
|
|
2448
|
+
) }),
|
|
2449
|
+
/* @__PURE__ */ jsx2(InspectorField, { label: t.target, htmlFor: `${uid}-t`, children: /* @__PURE__ */ jsx2(
|
|
2859
2450
|
NodePicker,
|
|
2860
2451
|
{
|
|
2861
2452
|
id: `${uid}-t`,
|
|
2862
2453
|
model,
|
|
2863
2454
|
value: target,
|
|
2864
2455
|
onChange: setTarget,
|
|
2865
|
-
autoFocus: !!
|
|
2456
|
+
autoFocus: !original && !!targetSpec.source,
|
|
2866
2457
|
label: t.target,
|
|
2867
2458
|
colorOf,
|
|
2868
2459
|
exclude: source ? (x) => x === source : void 0
|
|
2869
2460
|
}
|
|
2870
|
-
)
|
|
2461
|
+
) })
|
|
2871
2462
|
] }),
|
|
2872
|
-
/* @__PURE__ */
|
|
2873
|
-
/* @__PURE__ */
|
|
2874
|
-
/* @__PURE__ */
|
|
2875
|
-
/* @__PURE__ */ jsx3("datalist", { id: `${uid}-kinds`, children: kinds.map((k) => /* @__PURE__ */ jsx3("option", { value: k }, k)) })
|
|
2463
|
+
/* @__PURE__ */ jsxs2(InspectorField, { label: t.kind, htmlFor: `${uid}-k`, children: [
|
|
2464
|
+
/* @__PURE__ */ jsx2("input", { id: `${uid}-k`, className: "gb-input", value: kind, list: `${uid}-kinds`, spellCheck: false, onChange: (e) => setKind(e.target.value) }),
|
|
2465
|
+
/* @__PURE__ */ jsx2("datalist", { id: `${uid}-kinds`, children: kinds.map((k) => /* @__PURE__ */ jsx2("option", { value: k }, k)) })
|
|
2876
2466
|
] }),
|
|
2877
|
-
/* @__PURE__ */
|
|
2878
|
-
/* @__PURE__ */ jsx3("label", { className: "gb-k", htmlFor: `${uid}-l`, children: t.edgeLabel }),
|
|
2879
|
-
/* @__PURE__ */ jsx3("input", { id: `${uid}-l`, className: "gb-input", value: label, spellCheck: false, onChange: (e) => setLabel(e.target.value) })
|
|
2880
|
-
] })
|
|
2467
|
+
/* @__PURE__ */ jsx2(InspectorField, { label: t.edgeLabel, htmlFor: `${uid}-l`, children: /* @__PURE__ */ jsx2("input", { id: `${uid}-l`, className: "gb-input", value: label, spellCheck: false, onChange: (e) => setLabel(e.target.value) }) })
|
|
2881
2468
|
] });
|
|
2882
2469
|
}
|
|
2883
2470
|
|
|
2884
2471
|
// src/react/Legend.tsx
|
|
2885
2472
|
import { useCallback, useEffect as useEffect3, useLayoutEffect as useLayoutEffect3, useMemo as useMemo3, useRef as useRef3, useState as useState4 } from "react";
|
|
2886
2473
|
import { createPortal } from "react-dom";
|
|
2887
|
-
import { jsx as
|
|
2474
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
2888
2475
|
function applyLook(profile, look) {
|
|
2889
2476
|
if (!look || !(look.nodePalette || look.edgePalette || look.nodeSize || look.edgeWidth)) return profile;
|
|
2890
2477
|
return {
|
|
@@ -2896,40 +2483,17 @@ function applyLook(profile, look) {
|
|
|
2896
2483
|
};
|
|
2897
2484
|
}
|
|
2898
2485
|
var isEmptyLook = (l) => !l.skeleton && ![l.nodePalette, l.edgePalette, l.nodeSize, l.edgeWidth].some((m) => m && Object.keys(m).length);
|
|
2899
|
-
function readMarks(c, cy, style, nodeKinds, edgeKinds) {
|
|
2900
|
-
if (c.cy !== cy || c.style !== style) {
|
|
2901
|
-
c.cy = cy;
|
|
2902
|
-
c.style = style;
|
|
2903
|
-
c.shapes.clear();
|
|
2904
|
-
c.strokes.clear();
|
|
2905
|
-
}
|
|
2906
|
-
const live = cy && !cy.destroyed();
|
|
2907
|
-
for (const k of nodeKinds) {
|
|
2908
|
-
if (c.shapes.has(k) || !live) continue;
|
|
2909
|
-
const n = cy.nodes(`.${cls(k)}`)[0];
|
|
2910
|
-
if (n) c.shapes.set(k, shapeOf(n.pstyle("shape").value));
|
|
2911
|
-
}
|
|
2912
|
-
for (const k of edgeKinds) {
|
|
2913
|
-
if (c.strokes.has(k) || !live) continue;
|
|
2914
|
-
const e = cy.edges(`.${edgeKindClass(k)}`)[0];
|
|
2915
|
-
if (e) c.strokes.set(k, { dash: e.pstyle("line-style").value, head: arrowOf(e.pstyle("target-arrow-shape").value), tail: arrowOf(e.pstyle("source-arrow-shape").value) });
|
|
2916
|
-
}
|
|
2917
|
-
return {
|
|
2918
|
-
shape: (k) => c.shapes.get(k) ?? "circle",
|
|
2919
|
-
stroke: (k) => c.strokes.get(k) ?? { dash: "solid", head: "none", tail: "none" }
|
|
2920
|
-
};
|
|
2921
|
-
}
|
|
2922
2486
|
function tally(model, profile) {
|
|
2923
2487
|
const nodes = /* @__PURE__ */ Object.create(null);
|
|
2924
2488
|
const edges = /* @__PURE__ */ Object.create(null);
|
|
2925
|
-
let
|
|
2489
|
+
let plain2 = 0;
|
|
2926
2490
|
for (const n of model.nodes) {
|
|
2927
2491
|
const hollow = !!n.flags?.some((f) => profile.placeholderFlags.includes(f));
|
|
2928
2492
|
if (!hollow && n.kind) nodes[n.kind] = (nodes[n.kind] ?? 0) + 1;
|
|
2929
|
-
else
|
|
2493
|
+
else plain2++;
|
|
2930
2494
|
}
|
|
2931
2495
|
for (const e of model.edges) if (e.kind && Object.hasOwn(profile.edgePalette, e.kind)) edges[e.kind] = (edges[e.kind] ?? 0) + 1;
|
|
2932
|
-
return { nodes, edges, plain };
|
|
2496
|
+
return { nodes, edges, plain: plain2 };
|
|
2933
2497
|
}
|
|
2934
2498
|
var SCALES = [0.5, 1, 2];
|
|
2935
2499
|
var OPEN_DELAY_MS = 120;
|
|
@@ -2959,7 +2523,7 @@ function Item(p) {
|
|
|
2959
2523
|
ctl.done(k, byKeyboard);
|
|
2960
2524
|
if (byKeyboard) btn.current?.focus({ preventScroll: true });
|
|
2961
2525
|
};
|
|
2962
|
-
return /* @__PURE__ */
|
|
2526
|
+
return /* @__PURE__ */ jsxs3(
|
|
2963
2527
|
"span",
|
|
2964
2528
|
{
|
|
2965
2529
|
ref: item,
|
|
@@ -2976,7 +2540,7 @@ function Item(p) {
|
|
|
2976
2540
|
if (!e.currentTarget.contains(e.relatedTarget) && !e.relatedTarget?.closest?.(".gb-lg-pop")) ctl.focus(k, false, false);
|
|
2977
2541
|
},
|
|
2978
2542
|
children: [
|
|
2979
|
-
/* @__PURE__ */
|
|
2543
|
+
/* @__PURE__ */ jsxs3(
|
|
2980
2544
|
"button",
|
|
2981
2545
|
{
|
|
2982
2546
|
ref: btn,
|
|
@@ -2990,16 +2554,16 @@ function Item(p) {
|
|
|
2990
2554
|
onFocus: (e) => ctl.focus(k, true, e.currentTarget.matches(":focus-visible")),
|
|
2991
2555
|
children: [
|
|
2992
2556
|
p.mark,
|
|
2993
|
-
p.label && /* @__PURE__ */
|
|
2994
|
-
p.count != null && /* @__PURE__ */
|
|
2557
|
+
p.label && /* @__PURE__ */ jsx3("span", { children: p.label }),
|
|
2558
|
+
p.count != null && /* @__PURE__ */ jsx3("b", { children: p.count })
|
|
2995
2559
|
]
|
|
2996
2560
|
}
|
|
2997
2561
|
),
|
|
2998
|
-
open && portalRoot && createPortal(/* @__PURE__ */
|
|
2562
|
+
open && portalRoot && createPortal(/* @__PURE__ */ jsxs3(
|
|
2999
2563
|
"div",
|
|
3000
2564
|
{
|
|
3001
2565
|
ref: panel,
|
|
3002
|
-
className: "gb-lg-pop",
|
|
2566
|
+
className: "gb-lg-pop gb-glass gb-raised gb-round",
|
|
3003
2567
|
role: "dialog",
|
|
3004
2568
|
"aria-label": p.title,
|
|
3005
2569
|
"data-side": placement?.side,
|
|
@@ -3013,7 +2577,7 @@ function Item(p) {
|
|
|
3013
2577
|
}
|
|
3014
2578
|
},
|
|
3015
2579
|
children: [
|
|
3016
|
-
p.onToggle && /* @__PURE__ */
|
|
2580
|
+
p.onToggle && /* @__PURE__ */ jsx3(
|
|
3017
2581
|
"button",
|
|
3018
2582
|
{
|
|
3019
2583
|
type: "button",
|
|
@@ -3025,12 +2589,12 @@ function Item(p) {
|
|
|
3025
2589
|
p.onToggle();
|
|
3026
2590
|
finish(e.detail === 0);
|
|
3027
2591
|
},
|
|
3028
|
-
children: /* @__PURE__ */
|
|
2592
|
+
children: /* @__PURE__ */ jsx3(Eye, { off: p.off })
|
|
3029
2593
|
}
|
|
3030
2594
|
),
|
|
3031
|
-
/* @__PURE__ */
|
|
3032
|
-
/* @__PURE__ */
|
|
3033
|
-
/* @__PURE__ */
|
|
2595
|
+
/* @__PURE__ */ jsxs3("label", { className: "gb-lg-well", title: `${t.legendColor} \xB7 ${p.color}`, children: [
|
|
2596
|
+
/* @__PURE__ */ jsx3("i", { style: { background: p.color } }),
|
|
2597
|
+
/* @__PURE__ */ jsx3(
|
|
3034
2598
|
"input",
|
|
3035
2599
|
{
|
|
3036
2600
|
ref: well,
|
|
@@ -3042,8 +2606,8 @@ function Item(p) {
|
|
|
3042
2606
|
}
|
|
3043
2607
|
)
|
|
3044
2608
|
] }),
|
|
3045
|
-
p.onScale && /* @__PURE__ */
|
|
3046
|
-
p.onScale && /* @__PURE__ */
|
|
2609
|
+
p.onScale && /* @__PURE__ */ jsx3("i", { className: "gb-lg-sep" }),
|
|
2610
|
+
p.onScale && /* @__PURE__ */ jsx3("span", { className: "gb-lg-segm", role: "group", "aria-label": t.legendSize, children: SCALES.map((s) => /* @__PURE__ */ jsx3(
|
|
3047
2611
|
"button",
|
|
3048
2612
|
{
|
|
3049
2613
|
type: "button",
|
|
@@ -3051,7 +2615,7 @@ function Item(p) {
|
|
|
3051
2615
|
"aria-pressed": s === (p.scale ?? 1),
|
|
3052
2616
|
title: `${s}\xD7`,
|
|
3053
2617
|
onClick: () => p.onScale(s),
|
|
3054
|
-
children: /* @__PURE__ */
|
|
2618
|
+
children: /* @__PURE__ */ jsx3("svg", { viewBox: "0 0 16 10", width: 16, height: 10, children: p.glyph === "line" ? /* @__PURE__ */ jsx3("line", { x1: 2, y1: 5, x2: 14, y2: 5, stroke: "currentColor", strokeWidth: s * 1.6, strokeLinecap: "round" }) : /* @__PURE__ */ jsx3("circle", { cx: 8, cy: 5, r: 1.6 + s * 1.4, fill: "currentColor" }) })
|
|
3055
2619
|
},
|
|
3056
2620
|
s
|
|
3057
2621
|
)) })
|
|
@@ -3063,7 +2627,7 @@ function Item(p) {
|
|
|
3063
2627
|
);
|
|
3064
2628
|
}
|
|
3065
2629
|
function Eye({ off }) {
|
|
3066
|
-
return /* @__PURE__ */
|
|
2630
|
+
return /* @__PURE__ */ jsxs3(
|
|
3067
2631
|
"svg",
|
|
3068
2632
|
{
|
|
3069
2633
|
viewBox: "0 0 16 16",
|
|
@@ -3075,9 +2639,9 @@ function Eye({ off }) {
|
|
|
3075
2639
|
strokeLinecap: "round",
|
|
3076
2640
|
strokeLinejoin: "round",
|
|
3077
2641
|
children: [
|
|
3078
|
-
/* @__PURE__ */
|
|
3079
|
-
/* @__PURE__ */
|
|
3080
|
-
off && /* @__PURE__ */
|
|
2642
|
+
/* @__PURE__ */ jsx3("path", { d: "M1.5 8s2.4-4.5 6.5-4.5S14.5 8 14.5 8 12.1 12.5 8 12.5 1.5 8 1.5 8Z" }),
|
|
2643
|
+
/* @__PURE__ */ jsx3("circle", { cx: 8, cy: 8, r: 2 }),
|
|
2644
|
+
off && /* @__PURE__ */ jsx3("path", { d: "M2.5 2.5l11 11" })
|
|
3081
2645
|
]
|
|
3082
2646
|
}
|
|
3083
2647
|
);
|
|
@@ -3085,40 +2649,16 @@ function Eye({ off }) {
|
|
|
3085
2649
|
function NodeMark({ color, shape = "circle", ring, off, scale = 1 }) {
|
|
3086
2650
|
const paint = off ? { fill: "none", stroke: color, strokeWidth: 1.4 } : { fill: color, stroke: ring, strokeWidth: 1.2 };
|
|
3087
2651
|
const r = (off ? 4.8 : 5.5) * (1 + 0.2 * Math.log2(scale));
|
|
3088
|
-
return /* @__PURE__ */
|
|
3089
|
-
}
|
|
3090
|
-
var DASH = { dashed: "4 2.5", dotted: "0.1 3" };
|
|
3091
|
-
function EdgeMark({ color, stroke, off, scale = 1 }) {
|
|
3092
|
-
const sw = 1.8 * (1 + 0.3 * Math.log2(scale));
|
|
3093
|
-
const x1 = stroke.tail === "triangle" ? 6 : 2, x2 = stroke.head === "triangle" ? 18 : 22;
|
|
3094
|
-
return /* @__PURE__ */ jsxs4("svg", { className: "gb-lg-mark", viewBox: "0 0 24 12", width: 24, height: 12, opacity: off ? 0.35 : 1, children: [
|
|
3095
|
-
/* @__PURE__ */ jsx4(
|
|
3096
|
-
"line",
|
|
3097
|
-
{
|
|
3098
|
-
x1,
|
|
3099
|
-
y1: 6,
|
|
3100
|
-
x2,
|
|
3101
|
-
y2: 6,
|
|
3102
|
-
stroke: color,
|
|
3103
|
-
strokeWidth: sw,
|
|
3104
|
-
strokeLinecap: stroke.dash === "dotted" ? "round" : void 0,
|
|
3105
|
-
strokeDasharray: DASH[stroke.dash]
|
|
3106
|
-
}
|
|
3107
|
-
),
|
|
3108
|
-
stroke.head === "triangle" && /* @__PURE__ */ jsx4("polygon", { points: "17,2.5 23,6 17,9.5", fill: color }),
|
|
3109
|
-
stroke.tail === "triangle" && /* @__PURE__ */ jsx4("polygon", { points: "7,2.5 1,6 7,9.5", fill: color }),
|
|
3110
|
-
stroke.head === "tee" && /* @__PURE__ */ jsx4("path", { d: "M22,2.5 V9.5", stroke: color, strokeWidth: 1.8 }),
|
|
3111
|
-
stroke.tail === "tee" && /* @__PURE__ */ jsx4("path", { d: "M2,2.5 V9.5", stroke: color, strokeWidth: 1.8 })
|
|
3112
|
-
] });
|
|
2652
|
+
return /* @__PURE__ */ jsx3("svg", { className: "gb-lg-mark", viewBox: "0 0 14 14", width: 14, height: 14, children: shape === "hexagon" ? /* @__PURE__ */ jsx3("polygon", { points: [0, 1, 2, 3, 4, 5].map((i) => `${7 + r * Math.sin(i * Math.PI / 3)},${7 - r * Math.cos(i * Math.PI / 3)}`).join(" "), ...paint }) : shape === "diamond" ? /* @__PURE__ */ jsx3("polygon", { points: `7,${7 - r} ${7 + r},7 7,${7 + r} ${7 - r},7`, ...paint }) : shape === "rect" ? /* @__PURE__ */ jsx3("rect", { x: 7 - r * 0.85, y: 7 - r * 0.85, width: r * 1.7, height: r * 1.7, rx: 1.5, ...paint }) : /* @__PURE__ */ jsx3("circle", { cx: 7, cy: 7, r, ...paint }) });
|
|
3113
2653
|
}
|
|
3114
2654
|
function SkeletonEdge({ theme }) {
|
|
3115
2655
|
const id = useMemo3(() => `gb-lg-contain-${Math.random().toString(36).slice(2)}`, []);
|
|
3116
|
-
return /* @__PURE__ */
|
|
3117
|
-
/* @__PURE__ */
|
|
3118
|
-
/* @__PURE__ */
|
|
3119
|
-
/* @__PURE__ */
|
|
2656
|
+
return /* @__PURE__ */ jsxs3("svg", { className: "gb-lg-mark", viewBox: "0 0 30 12", width: 30, height: 12, children: [
|
|
2657
|
+
/* @__PURE__ */ jsx3("defs", { children: /* @__PURE__ */ jsxs3("linearGradient", { id, children: [
|
|
2658
|
+
/* @__PURE__ */ jsx3("stop", { offset: "0", stopColor: skeletonColor(theme, 0) }),
|
|
2659
|
+
/* @__PURE__ */ jsx3("stop", { offset: "1", stopColor: skeletonColor(theme, 1) })
|
|
3120
2660
|
] }) }),
|
|
3121
|
-
/* @__PURE__ */
|
|
2661
|
+
/* @__PURE__ */ jsx3("polygon", { points: "1,5.25 29,3 29,9 1,6.75", fill: `url(#${id})` })
|
|
3122
2662
|
] });
|
|
3123
2663
|
}
|
|
3124
2664
|
function LegendFrame({ collapsed, children }) {
|
|
@@ -3132,7 +2672,7 @@ function LegendFrame({ collapsed, children }) {
|
|
|
3132
2672
|
if (!before || before.width === after.width && before.height === after.height || window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
|
|
3133
2673
|
const body = el.firstElementChild;
|
|
3134
2674
|
body.style.width = `${body.getBoundingClientRect().width}px`;
|
|
3135
|
-
const timing = { duration: 220, easing: "
|
|
2675
|
+
const timing = { duration: 220, easing: getComputedStyle(el).getPropertyValue("--gb-ease").trim() };
|
|
3136
2676
|
const motion = el.animate([
|
|
3137
2677
|
{ width: `${before.width}px`, height: `${before.height}px`, overflow: "clip" },
|
|
3138
2678
|
{ width: `${after.width}px`, height: `${after.height}px`, overflow: "clip" }
|
|
@@ -3157,7 +2697,7 @@ function LegendFrame({ collapsed, children }) {
|
|
|
3157
2697
|
ro.observe(el);
|
|
3158
2698
|
return () => ro.disconnect();
|
|
3159
2699
|
}, []);
|
|
3160
|
-
return /* @__PURE__ */
|
|
2700
|
+
return /* @__PURE__ */ jsx3("div", { className: "gb-legend gb-glass gb-raised gb-round", ref: root, children });
|
|
3161
2701
|
}
|
|
3162
2702
|
function Legend(p) {
|
|
3163
2703
|
const t = useStrings();
|
|
@@ -3236,8 +2776,15 @@ function Legend(p) {
|
|
|
3236
2776
|
const slot = (key) => ({ k: key, open: open === key, ctl });
|
|
3237
2777
|
const nodeKinds = Object.keys(count.nodes).sort((a, b) => count.nodes[b] - count.nodes[a] || a.localeCompare(b));
|
|
3238
2778
|
const edgeKinds = Object.keys(profile.edgePalette).filter((k) => count.edges[k]);
|
|
3239
|
-
const
|
|
3240
|
-
const
|
|
2779
|
+
const shapes = useMemo3(() => /* @__PURE__ */ new Map(), [p.cy, profile.style]);
|
|
2780
|
+
const shape = (k) => {
|
|
2781
|
+
const cy = p.cy;
|
|
2782
|
+
if (!shapes.has(k) && cy && !cy.destroyed()) {
|
|
2783
|
+
const node = cy.nodes(`.${cls(k)}`)[0];
|
|
2784
|
+
if (node) shapes.set(k, shapeOf(node.pstyle("shape").value));
|
|
2785
|
+
}
|
|
2786
|
+
return shapes.get(k);
|
|
2787
|
+
};
|
|
3241
2788
|
const spot = picking || p.collapsed ? null : open ?? focused;
|
|
3242
2789
|
const onEmphasis = p.onEmphasis;
|
|
3243
2790
|
useEffect3(() => {
|
|
@@ -3250,7 +2797,7 @@ function Legend(p) {
|
|
|
3250
2797
|
const name = (k) => profile.kindLabels[k] ?? k;
|
|
3251
2798
|
const colorOfKind = (k) => profile.nodePalette[k] ?? theme.skeleton;
|
|
3252
2799
|
const shown = (c) => themeColor(theme, c);
|
|
3253
|
-
const content = p.collapsed ? /* @__PURE__ */
|
|
2800
|
+
const content = p.collapsed ? /* @__PURE__ */ jsx3(
|
|
3254
2801
|
"button",
|
|
3255
2802
|
{
|
|
3256
2803
|
type: "button",
|
|
@@ -3259,20 +2806,20 @@ function Legend(p) {
|
|
|
3259
2806
|
"aria-label": t.legend,
|
|
3260
2807
|
title: t.legend,
|
|
3261
2808
|
onClick: () => p.onCollapsed(false),
|
|
3262
|
-
children: /* @__PURE__ */
|
|
2809
|
+
children: /* @__PURE__ */ jsx3(Icon, { d: I.legend })
|
|
3263
2810
|
}
|
|
3264
|
-
) : /* @__PURE__ */
|
|
3265
|
-
/* @__PURE__ */
|
|
3266
|
-
p.caption && /* @__PURE__ */
|
|
3267
|
-
/* @__PURE__ */
|
|
3268
|
-
count.plain > 0 && /* @__PURE__ */
|
|
2811
|
+
) : /* @__PURE__ */ jsxs3("div", { className: "gb-lg", ref: rootRef, children: [
|
|
2812
|
+
/* @__PURE__ */ jsxs3("div", { className: "gb-lg-body", children: [
|
|
2813
|
+
p.caption && /* @__PURE__ */ jsx3("div", { className: "gb-lg-cap", children: p.caption }),
|
|
2814
|
+
/* @__PURE__ */ jsxs3("div", { className: "gb-lg-row", children: [
|
|
2815
|
+
count.plain > 0 && /* @__PURE__ */ jsx3(
|
|
3269
2816
|
Item,
|
|
3270
2817
|
{
|
|
3271
2818
|
...slot("n:"),
|
|
3272
2819
|
color: theme.skeleton,
|
|
3273
2820
|
onPick: setSkeleton,
|
|
3274
2821
|
title: t.legendPlain,
|
|
3275
|
-
mark: /* @__PURE__ */
|
|
2822
|
+
mark: /* @__PURE__ */ jsx3(NodeMark, { color: defaultNodeColor(theme, 0.3), ring: theme.canvas }),
|
|
3276
2823
|
label: t.legendPlainName,
|
|
3277
2824
|
count: count.plain
|
|
3278
2825
|
}
|
|
@@ -3280,7 +2827,7 @@ function Legend(p) {
|
|
|
3280
2827
|
nodeKinds.map((k) => {
|
|
3281
2828
|
const off = p.hidden.nodes.includes(k);
|
|
3282
2829
|
const scale = profile.nodeSize[k] ?? 1;
|
|
3283
|
-
return /* @__PURE__ */
|
|
2830
|
+
return /* @__PURE__ */ jsx3(
|
|
3284
2831
|
Item,
|
|
3285
2832
|
{
|
|
3286
2833
|
...slot(`n:${k}`),
|
|
@@ -3292,7 +2839,7 @@ function Legend(p) {
|
|
|
3292
2839
|
scale,
|
|
3293
2840
|
glyph: "dot",
|
|
3294
2841
|
onScale: (s) => set("nodeSize", k, s),
|
|
3295
|
-
mark: /* @__PURE__ */
|
|
2842
|
+
mark: /* @__PURE__ */ jsx3(NodeMark, { color: shown(colorOfKind(k)), shape: shape(k), ring: theme.canvas, off, scale }),
|
|
3296
2843
|
label: name(k),
|
|
3297
2844
|
count: count.nodes[k]
|
|
3298
2845
|
},
|
|
@@ -3300,22 +2847,22 @@ function Legend(p) {
|
|
|
3300
2847
|
);
|
|
3301
2848
|
})
|
|
3302
2849
|
] }),
|
|
3303
|
-
/* @__PURE__ */
|
|
3304
|
-
/* @__PURE__ */
|
|
2850
|
+
/* @__PURE__ */ jsxs3("div", { className: "gb-lg-row", children: [
|
|
2851
|
+
/* @__PURE__ */ jsx3(
|
|
3305
2852
|
Item,
|
|
3306
2853
|
{
|
|
3307
2854
|
...slot("e:"),
|
|
3308
2855
|
color: theme.skeleton,
|
|
3309
2856
|
onPick: setSkeleton,
|
|
3310
2857
|
title: t.legendContains,
|
|
3311
|
-
mark: /* @__PURE__ */
|
|
2858
|
+
mark: /* @__PURE__ */ jsx3(SkeletonEdge, { theme }),
|
|
3312
2859
|
label: t.legendContainsName
|
|
3313
2860
|
}
|
|
3314
2861
|
),
|
|
3315
2862
|
edgeKinds.map((k) => {
|
|
3316
2863
|
const off = p.hidden.edges.includes(k);
|
|
3317
2864
|
const scale = profile.edgeWidth[k] ?? 1;
|
|
3318
|
-
return /* @__PURE__ */
|
|
2865
|
+
return /* @__PURE__ */ jsx3(
|
|
3319
2866
|
Item,
|
|
3320
2867
|
{
|
|
3321
2868
|
...slot(`e:${k}`),
|
|
@@ -3327,7 +2874,7 @@ function Legend(p) {
|
|
|
3327
2874
|
scale,
|
|
3328
2875
|
glyph: "line",
|
|
3329
2876
|
onScale: (s) => set("edgeWidth", k, s),
|
|
3330
|
-
mark: /* @__PURE__ */
|
|
2877
|
+
mark: /* @__PURE__ */ jsx3(EdgeMark, { kind: k, off }),
|
|
3331
2878
|
label: name(k),
|
|
3332
2879
|
count: count.edges[k]
|
|
3333
2880
|
},
|
|
@@ -3336,24 +2883,24 @@ function Legend(p) {
|
|
|
3336
2883
|
})
|
|
3337
2884
|
] }),
|
|
3338
2885
|
p.delta && /* Change legend: only a legend, not a filter. Marks match the text on the graph: strikethrough = removed, underline = added. */
|
|
3339
|
-
/* @__PURE__ */
|
|
3340
|
-
/* @__PURE__ */
|
|
3341
|
-
/* @__PURE__ */
|
|
3342
|
-
/* @__PURE__ */
|
|
2886
|
+
/* @__PURE__ */ jsx3("div", { className: "gb-lg-row gb-lg-diff", children: CHANGE_ORDER.filter((k) => p.delta.counts[k] > 0).map((k) => /* @__PURE__ */ jsxs3("span", { className: `gb-lg-chg${PAST_KINDS.has(k) ? " past" : ""}`, children: [
|
|
2887
|
+
/* @__PURE__ */ jsx3("i", { style: { boxShadow: `0 0 0 2px ${DIFF_COLORS[k]}b0, 0 0 0 5px ${DIFF_COLORS[k]}40` } }),
|
|
2888
|
+
/* @__PURE__ */ jsx3("span", { style: k === "added" ? { textDecoration: `underline 2px ${DIFF_COLORS[k]}`, textUnderlineOffset: 3 } : PAST_KINDS.has(k) ? { textDecoration: `line-through 2px ${DIFF_COLORS[k]}` } : void 0, children: t.change[k] }),
|
|
2889
|
+
/* @__PURE__ */ jsx3("b", { children: p.delta.counts[k] })
|
|
3343
2890
|
] }, k)) }),
|
|
3344
|
-
/* @__PURE__ */
|
|
2891
|
+
/* @__PURE__ */ jsx3("div", { className: "gb-lg-foot", children: isEmptyLook(look) && !p.hidden.nodes.length && !p.hidden.edges.length ? /* @__PURE__ */ jsx3("span", { children: t.legendHint }) : /* @__PURE__ */ jsx3("button", { type: "button", onClick: () => {
|
|
3345
2892
|
onLook({});
|
|
3346
2893
|
p.onShowAll();
|
|
3347
2894
|
}, children: t.legendReset }) })
|
|
3348
2895
|
] }),
|
|
3349
|
-
/* @__PURE__ */
|
|
2896
|
+
/* @__PURE__ */ jsx3("span", { className: "gb-lg-act", children: /* @__PURE__ */ jsx3("button", { type: "button", className: "gb-lg-btn", onClick: () => p.onCollapsed(true), "aria-expanded": true, "aria-label": t.legend, title: t.legend, children: /* @__PURE__ */ jsx3(Icon, { d: I.collapse, size: 13 }) }) })
|
|
3350
2897
|
] });
|
|
3351
|
-
return /* @__PURE__ */
|
|
2898
|
+
return /* @__PURE__ */ jsx3(LegendFrame, { collapsed: p.collapsed, children: content });
|
|
3352
2899
|
}
|
|
3353
2900
|
|
|
3354
2901
|
// src/react/DiffOverlay.tsx
|
|
3355
2902
|
import { useMemo as useMemo4 } from "react";
|
|
3356
|
-
import { Fragment as Fragment3, jsx as
|
|
2903
|
+
import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
3357
2904
|
var DEFAULT_MAX = 600;
|
|
3358
2905
|
var PAD2 = 4;
|
|
3359
2906
|
var GLOW_PASSES = [[26, 0.05], [15, 0.13], [6, 0.55]];
|
|
@@ -3394,12 +2941,12 @@ function DiffOverlay(p) {
|
|
|
3394
2941
|
const shown = (id) => (!only || only.has(id)) && (!visible || visible.has(id));
|
|
3395
2942
|
const table = MARK[side];
|
|
3396
2943
|
const rank = { merged: 0, moved: 1, removed: 2, added: 3, changed: 4 };
|
|
3397
|
-
const
|
|
3398
|
-
const truncated2 = Math.max(0,
|
|
2944
|
+
const list2 = [...delta.changes].filter((c) => table[c.kind] && shown(c.id)).sort((a, b) => rank[a.kind] - rank[b.kind]);
|
|
2945
|
+
const truncated2 = Math.max(0, list2.length - max);
|
|
3399
2946
|
const nodeGlow2 = LEVEL.map(emptyBuckets);
|
|
3400
2947
|
const edgeGlow2 = emptyBuckets();
|
|
3401
2948
|
const wire = [];
|
|
3402
|
-
for (const c of
|
|
2949
|
+
for (const c of list2.slice(0, max)) {
|
|
3403
2950
|
const box = geom.nodes[c.id];
|
|
3404
2951
|
if (!box) continue;
|
|
3405
2952
|
const ink = table[c.kind];
|
|
@@ -3430,11 +2977,11 @@ function DiffOverlay(p) {
|
|
|
3430
2977
|
const t = `translate(${viewport.pan.x},${viewport.pan.y}) scale(${viewport.zoom})`;
|
|
3431
2978
|
const inv = 1 / Math.max(viewport.zoom, 0.02);
|
|
3432
2979
|
const dash = { strokeDasharray: `${5 * inv} ${4 * inv}` };
|
|
3433
|
-
return /* @__PURE__ */
|
|
3434
|
-
/* @__PURE__ */
|
|
3435
|
-
INKS.map((ink) => /* @__PURE__ */
|
|
3436
|
-
edgeGlow[ink] && GLOW_EDGE_PASSES.map(([w, o]) => /* @__PURE__ */
|
|
3437
|
-
nodeGlow.map((lv, i) => lv[ink] && GLOW_PASSES.map(([w, o]) => /* @__PURE__ */
|
|
2980
|
+
return /* @__PURE__ */ jsxs4(Fragment3, { children: [
|
|
2981
|
+
/* @__PURE__ */ jsx4("svg", { className: "gb-diff-under", "aria-hidden": true, children: /* @__PURE__ */ jsxs4("g", { transform: t, children: [
|
|
2982
|
+
INKS.map((ink) => /* @__PURE__ */ jsxs4("g", { className: `gb-glow gb-glow-${ink}`, children: [
|
|
2983
|
+
edgeGlow[ink] && GLOW_EDGE_PASSES.map(([w, o]) => /* @__PURE__ */ jsx4("path", { d: edgeGlow[ink], strokeWidth: w * inv, strokeOpacity: o }, `e${w}`)),
|
|
2984
|
+
nodeGlow.map((lv, i) => lv[ink] && GLOW_PASSES.map(([w, o]) => /* @__PURE__ */ jsx4(
|
|
3438
2985
|
"path",
|
|
3439
2986
|
{
|
|
3440
2987
|
d: lv[ink],
|
|
@@ -3444,17 +2991,14 @@ function DiffOverlay(p) {
|
|
|
3444
2991
|
`n${i}-${w}`
|
|
3445
2992
|
)))
|
|
3446
2993
|
] }, ink)),
|
|
3447
|
-
wireD && /* @__PURE__ */
|
|
2994
|
+
wireD && /* @__PURE__ */ jsx4("path", { className: "gb-pastwire", d: wireD, strokeWidth: 2 * inv, style: dash })
|
|
3448
2995
|
] }) }),
|
|
3449
|
-
truncated > 0 && /* @__PURE__ */
|
|
2996
|
+
truncated > 0 && /* @__PURE__ */ jsx4("div", { className: "gb-diff-trunc gb-glass gb-raised gb-round", children: str.diffTruncated(truncated) })
|
|
3450
2997
|
] });
|
|
3451
2998
|
}
|
|
3452
2999
|
|
|
3453
3000
|
// src/react/GraphCanvas.tsx
|
|
3454
|
-
import { jsx as
|
|
3455
|
-
var TIGHTEN_MAX = 400;
|
|
3456
|
-
var NODE_PITCH = 150;
|
|
3457
|
-
var SEED_MAX = 60;
|
|
3001
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
3458
3002
|
var PLANE_MS = 720;
|
|
3459
3003
|
var FLY_ZOOM = 1;
|
|
3460
3004
|
var FLY_MS_PER_S = 380;
|
|
@@ -3465,7 +3009,6 @@ var FIT_MAX_ZOOM = 1.5;
|
|
|
3465
3009
|
var planeKey = (v) => `${v.planes ? 1 : 0}|${(v.layers ?? []).join(",")}`;
|
|
3466
3010
|
var litPlates = (plates, alphaOf) => plates.map((p) => ({ ...p, alpha: alphaOf(p.layer) })).filter((p) => p.alpha > 1e-3);
|
|
3467
3011
|
var shownIn = (v) => (layer) => !v.layers || v.layers.includes(layer) ? 1 : 0;
|
|
3468
|
-
var sightKey = (v) => `${planeKey(v)}|${(v.origins ?? []).join(",")}`;
|
|
3469
3012
|
var LABEL_FONT = { min: 12, max: 15 };
|
|
3470
3013
|
var labelFontOf = (leaves) => LABEL_FONT.min + (LABEL_FONT.max - LABEL_FONT.min) * nodeWeight(leaves);
|
|
3471
3014
|
var labelCss = (px, bold = false) => `${bold ? 600 : 400} ${px}px ui-sans-serif, system-ui, sans-serif`;
|
|
@@ -3490,7 +3033,7 @@ var BREATH_IDLE_MS = 4e3;
|
|
|
3490
3033
|
var BREATH_INTERVAL_MS = 2600;
|
|
3491
3034
|
var BREATH_AMPLITUDE = 0.08;
|
|
3492
3035
|
var smoothstep = (x) => x * x * (3 - 2 * x);
|
|
3493
|
-
var
|
|
3036
|
+
var clamp01 = (x) => Math.min(1, Math.max(0, x));
|
|
3494
3037
|
var SPRITE_MAX = 1500;
|
|
3495
3038
|
var sprites = /* @__PURE__ */ new Map();
|
|
3496
3039
|
var tintOf = ([r, g, b]) => `rgb(${[r, g, b].map((v) => Math.round(v / 8) * 8).join(",")})`;
|
|
@@ -3579,8 +3122,8 @@ function samePositions(a, b) {
|
|
|
3579
3122
|
const ka = Object.keys(a);
|
|
3580
3123
|
if (ka.length !== Object.keys(b).length) return false;
|
|
3581
3124
|
for (const k of ka) {
|
|
3582
|
-
const p = a[k],
|
|
3583
|
-
if (!
|
|
3125
|
+
const p = a[k], q = b[k];
|
|
3126
|
+
if (!q || p.x !== q.x || p.y !== q.y) return false;
|
|
3584
3127
|
}
|
|
3585
3128
|
return true;
|
|
3586
3129
|
}
|
|
@@ -3742,7 +3285,7 @@ function seatFromLastFrame(cy, prev, parentOf) {
|
|
|
3742
3285
|
y: vals.reduce((s, p) => s + p.y, 0) / vals.length
|
|
3743
3286
|
};
|
|
3744
3287
|
const seat = (id) => {
|
|
3745
|
-
const anc = anchorOf(id, (
|
|
3288
|
+
const anc = anchorOf(id, (q) => !!prev[q], parentOf);
|
|
3746
3289
|
return anc ? prev[anc] : mid;
|
|
3747
3290
|
};
|
|
3748
3291
|
cy.batch(() => {
|
|
@@ -3793,11 +3336,107 @@ function Drawer({ children }) {
|
|
|
3793
3336
|
}, [open]);
|
|
3794
3337
|
const content = children || (gone ? null : last.current);
|
|
3795
3338
|
if (!content) return null;
|
|
3796
|
-
return /* @__PURE__ */
|
|
3339
|
+
return /* @__PURE__ */ jsx5("div", { className: `gb-drawer gb-glass gb-raised gb-round${open ? "" : " is-closing"}`, children: content });
|
|
3797
3340
|
}
|
|
3798
3341
|
var DRAWER_MS = 200;
|
|
3342
|
+
function hasTarget(model, target) {
|
|
3343
|
+
return "node" in target ? model.index.has(target.node) : model.edges.some((e) => sameEdge(e, target.edge));
|
|
3344
|
+
}
|
|
3799
3345
|
function GraphCanvas(props) {
|
|
3346
|
+
const [innerView, setInnerView] = useState5({ ...FULL_VIEW, ...props.defaultView });
|
|
3347
|
+
const rawView = props.view ?? innerView;
|
|
3348
|
+
const patchView = useCallback2((patch) => {
|
|
3349
|
+
const next = { ...props.view ?? innerView, ...patch };
|
|
3350
|
+
if (!props.view) setInnerView(next);
|
|
3351
|
+
props.onViewChange?.(next);
|
|
3352
|
+
}, [props.view, props.onViewChange, innerView]);
|
|
3353
|
+
const [forcedScope, setForcedScope] = useState5("");
|
|
3354
|
+
const scopeKey = JSON.stringify(rawView.subtree ? ["node", rawView.subtree] : rawView.origins?.length ? ["files", ...rawView.origins] : []);
|
|
3355
|
+
const scoped = useSubgraph(props, rawView, forcedScope === scopeKey);
|
|
3356
|
+
const cy = useRef4(null);
|
|
3357
|
+
const destination = useRef4(null);
|
|
3358
|
+
const returnCamera = useRef4(null);
|
|
3359
|
+
const fullLayers = useRef4({ layers: null, planes: void 0 });
|
|
3360
|
+
const change = (subtree, origins, target) => {
|
|
3361
|
+
destination.current = target ?? null;
|
|
3362
|
+
if (!scoped.active) {
|
|
3363
|
+
fullLayers.current = { layers: rawView.layers, planes: rawView.planes };
|
|
3364
|
+
returnCamera.current = null;
|
|
3365
|
+
const graph = cy.current;
|
|
3366
|
+
if (graph && !graph.destroyed()) {
|
|
3367
|
+
const center = { x: graph.width() / 2, y: graph.height() / 2 };
|
|
3368
|
+
let nearest = Infinity;
|
|
3369
|
+
graph.nodes(":visible").forEach((n) => {
|
|
3370
|
+
if (n.id() === VIRTUAL_ROOT) return;
|
|
3371
|
+
const pos = n.renderedPosition(), dx = pos.x - center.x, dy = pos.y - center.y;
|
|
3372
|
+
const distance2 = dx * dx + dy * dy;
|
|
3373
|
+
if (distance2 < nearest) {
|
|
3374
|
+
nearest = distance2;
|
|
3375
|
+
returnCamera.current = { id: n.id(), dx, dy, zoom: graph.zoom() };
|
|
3376
|
+
}
|
|
3377
|
+
});
|
|
3378
|
+
}
|
|
3379
|
+
}
|
|
3380
|
+
setForcedScope("");
|
|
3381
|
+
const layers = subtree || origins?.length || target ? { layers: null, planes: false } : fullLayers.current;
|
|
3382
|
+
patchView({ subtree, origins: origins ?? null, query: "", ...layers });
|
|
3383
|
+
};
|
|
3384
|
+
const strings = props.strings;
|
|
3385
|
+
const lastRoot = useRef4(null);
|
|
3386
|
+
const root = rawView.subtree && (scoped.after.index.get(rawView.subtree) ?? scoped.before?.index.get(rawView.subtree));
|
|
3387
|
+
if (root) lastRoot.current = root;
|
|
3388
|
+
const label = rawView.subtree ? lastRoot.current?.id === rawView.subtree ? lastRoot.current.label : rawView.subtree : (rawView.origins ?? []).join(", ");
|
|
3389
|
+
const scope = {
|
|
3390
|
+
active: scoped.active,
|
|
3391
|
+
subtree: rawView.subtree,
|
|
3392
|
+
origins: rawView.subtree ? null : rawView.origins,
|
|
3393
|
+
label,
|
|
3394
|
+
files: scoped.origins,
|
|
3395
|
+
change,
|
|
3396
|
+
before: scoped.before,
|
|
3397
|
+
after: scoped.after,
|
|
3398
|
+
local: scoped.current,
|
|
3399
|
+
leaveFor: (target) => change(null, void 0, target),
|
|
3400
|
+
missing: rawView.subtree ? strings?.absentNode ?? EN.absentNode : strings?.absentSource ?? EN.absentSource
|
|
3401
|
+
};
|
|
3402
|
+
const localView = useMemo5(() => ({ ...rawView, subtree: null, origins: null }), [rawView]);
|
|
3403
|
+
const caption = typeof props.note === "function" ? props.note(scoped.current, scoped.delta) : props.note ?? (scoped.active ? (strings?.stats ?? EN.stats)(scoped.current.nodes.length, scoped.current.edges.length) : void 0);
|
|
3404
|
+
return /* @__PURE__ */ jsx5(
|
|
3405
|
+
CanvasScene,
|
|
3406
|
+
{
|
|
3407
|
+
...props,
|
|
3408
|
+
scopeKey,
|
|
3409
|
+
scope,
|
|
3410
|
+
sourceDiff: props.diff,
|
|
3411
|
+
world: props.profile ?? defaultProfile,
|
|
3412
|
+
restoreCamera: returnCamera,
|
|
3413
|
+
destination,
|
|
3414
|
+
note: caption,
|
|
3415
|
+
view: localView,
|
|
3416
|
+
setView: patchView,
|
|
3417
|
+
model: scoped.model,
|
|
3418
|
+
diff: scoped.delta,
|
|
3419
|
+
profile: scoped.profile,
|
|
3420
|
+
editModel: scoped.after,
|
|
3421
|
+
onReady: (instance) => {
|
|
3422
|
+
cy.current = instance;
|
|
3423
|
+
props.onReady?.(instance);
|
|
3424
|
+
},
|
|
3425
|
+
layout: scoped.active ? null : props.layout,
|
|
3426
|
+
onLayout: scoped.active ? void 0 : props.onLayout,
|
|
3427
|
+
layerIssue: scoped.active ? strings?.noLocalFloors ?? EN.noLocalFloors : props.layerIssue,
|
|
3428
|
+
onForceLayers: scoped.active ? scoped.canForce ? () => {
|
|
3429
|
+
setForcedScope(scopeKey);
|
|
3430
|
+
patchView({ planes: true });
|
|
3431
|
+
} : void 0 : props.onForceLayers
|
|
3432
|
+
}
|
|
3433
|
+
);
|
|
3434
|
+
}
|
|
3435
|
+
function CanvasScene(props) {
|
|
3800
3436
|
const {
|
|
3437
|
+
scope,
|
|
3438
|
+
view: rawView,
|
|
3439
|
+
setView,
|
|
3801
3440
|
model,
|
|
3802
3441
|
profile: baseProfile = defaultProfile,
|
|
3803
3442
|
theme: baseTheme = LIGHT_THEME,
|
|
@@ -3840,9 +3479,9 @@ function GraphCanvas(props) {
|
|
|
3840
3479
|
} = props;
|
|
3841
3480
|
const [innerLook, setInnerLook] = useState5(props.defaultLook ?? {});
|
|
3842
3481
|
const look = props.look ?? innerLook;
|
|
3843
|
-
const setLook = useCallback2((
|
|
3844
|
-
if (!props.look) setInnerLook(
|
|
3845
|
-
props.onLookChange?.(
|
|
3482
|
+
const setLook = useCallback2((next) => {
|
|
3483
|
+
if (!props.look) setInnerLook(next);
|
|
3484
|
+
props.onLookChange?.(next);
|
|
3846
3485
|
}, [props.look, props.onLookChange]);
|
|
3847
3486
|
const lookProfile = useMemo5(() => applyLook(baseProfile, look), [baseProfile, look]);
|
|
3848
3487
|
const theme = useMemo5(() => look.skeleton ? { ...baseTheme, skeleton: look.skeleton } : baseTheme, [baseTheme, look.skeleton]);
|
|
@@ -3855,33 +3494,31 @@ function GraphCanvas(props) {
|
|
|
3855
3494
|
if ((stageRef.current?.clientWidth ?? 1e3) < 640) setLegendCollapsed(true);
|
|
3856
3495
|
}, []);
|
|
3857
3496
|
const [liveCy, setLiveCy] = useState5(null);
|
|
3858
|
-
const
|
|
3497
|
+
const requestedProfile = useShapeOf(lookProfile);
|
|
3498
|
+
const [profile, setProfile] = useState5(requestedProfile);
|
|
3859
3499
|
const strings = useMemo5(() => ({ ...EN, ...props.strings, error: { ...EN.error, ...props.strings?.error } }), [props.strings]);
|
|
3860
|
-
const [innerView, setInnerView] = useState5({ ...FULL_VIEW, ...props.defaultView });
|
|
3861
|
-
const rawView = props.view ?? innerView;
|
|
3862
|
-
const setView = useCallback2((patch) => {
|
|
3863
|
-
const next = { ...props.view ?? innerView, ...patch };
|
|
3864
|
-
if (!props.view) setInnerView(next);
|
|
3865
|
-
props.onViewChange?.(next);
|
|
3866
|
-
}, [props.view, props.onViewChange, innerView]);
|
|
3867
3500
|
const containerRef = useRef4(null);
|
|
3868
3501
|
const [layoutOwner] = useState5(() => ({}));
|
|
3869
3502
|
const cyRef = useRef4(null);
|
|
3870
3503
|
const mirrorRef = useRef4(null);
|
|
3504
|
+
const edgeMarks = useMemo5(() => edgeMarksFor(lookProfile, theme, liveCy, () => mirrorRef.current), [lookProfile, theme, liveCy]);
|
|
3871
3505
|
const mirrorElRef = useRef4(null);
|
|
3872
3506
|
const syncingRef = useRef4(false);
|
|
3873
3507
|
const baseRef = useRef4({});
|
|
3874
|
-
const tightenedRef = useRef4(false);
|
|
3875
3508
|
const runRef = useRef4(0);
|
|
3876
3509
|
const platesRef = useRef4([]);
|
|
3877
3510
|
const dispRef = useRef4({});
|
|
3511
|
+
const visibleFrameRef = useRef4(/* @__PURE__ */ new Set());
|
|
3512
|
+
const framingRef = useRef4("");
|
|
3878
3513
|
const [renderModel, setRenderModel] = useState5(model);
|
|
3879
3514
|
const prevModelRef = useRef4(null);
|
|
3880
3515
|
const prevProfileRef = useRef4(null);
|
|
3881
3516
|
const [pastRenderModel, setPastRenderModel] = useState5(null);
|
|
3882
|
-
const
|
|
3883
|
-
|
|
3884
|
-
|
|
3517
|
+
const world = useShapeOf(props.world);
|
|
3518
|
+
const [renderWorld, setRenderWorld] = useState5(world);
|
|
3519
|
+
if (renderWorld !== world) {
|
|
3520
|
+
setRenderWorld(world);
|
|
3521
|
+
setProfile(requestedProfile);
|
|
3885
3522
|
setRenderModel(model);
|
|
3886
3523
|
setPastRenderModel(null);
|
|
3887
3524
|
}
|
|
@@ -3899,7 +3536,7 @@ function GraphCanvas(props) {
|
|
|
3899
3536
|
const dimsRef = useRef4({});
|
|
3900
3537
|
const labelsRef = useRef4(/* @__PURE__ */ new Map());
|
|
3901
3538
|
const labelRafRef = useRef4(null);
|
|
3902
|
-
const
|
|
3539
|
+
const hoverTimerRef = useRef4(null);
|
|
3903
3540
|
const painterRef = useRef4(null);
|
|
3904
3541
|
const ringsRef = useRef4(/* @__PURE__ */ new Map());
|
|
3905
3542
|
const ringRafRef = useRef4(null);
|
|
@@ -3924,16 +3561,21 @@ function GraphCanvas(props) {
|
|
|
3924
3561
|
const playPlanesRef = useRef4(null);
|
|
3925
3562
|
const sightRef = useRef4("");
|
|
3926
3563
|
const searchInputRef = useRef4(null);
|
|
3927
|
-
const [
|
|
3564
|
+
const [trail, setTrail] = useState5([]);
|
|
3565
|
+
const target = trail.at(-1);
|
|
3928
3566
|
const [editing, setEditing] = useState5(null);
|
|
3567
|
+
const [inspectedScope, setInspectedScope] = useState5(props.scopeKey);
|
|
3568
|
+
if (inspectedScope !== props.scopeKey) {
|
|
3569
|
+
setInspectedScope(props.scopeKey);
|
|
3570
|
+
setTrail([]);
|
|
3571
|
+
setEditing(null);
|
|
3572
|
+
}
|
|
3929
3573
|
const editingModel = props.editModel ?? model;
|
|
3930
|
-
const modelRef = useRef4(model);
|
|
3931
|
-
modelRef.current = model;
|
|
3932
3574
|
const editable = !!onEdit && !diff;
|
|
3933
3575
|
const onEditRef = useRef4(onEdit);
|
|
3934
3576
|
onEditRef.current = onEdit;
|
|
3935
3577
|
const pendingPickRef = useRef4(null);
|
|
3936
|
-
const keepSelRef = useRef4(
|
|
3578
|
+
const keepSelRef = useRef4(void 0);
|
|
3937
3579
|
const pickRef = useRef4(() => {
|
|
3938
3580
|
});
|
|
3939
3581
|
const [prog, setProg] = useState5(null);
|
|
@@ -3951,11 +3593,7 @@ function GraphCanvas(props) {
|
|
|
3951
3593
|
const has = new Set(model.nodes.map((n) => n.layer ?? profile.layers[0].id));
|
|
3952
3594
|
return profile.layers.filter((l) => has.has(l.id));
|
|
3953
3595
|
}, [model, profile.layers]);
|
|
3954
|
-
const
|
|
3955
|
-
const view = useMemo5(
|
|
3956
|
-
() => planeView(originView(rawView, origins), layersHere),
|
|
3957
|
-
[rawView, origins, layersHere]
|
|
3958
|
-
);
|
|
3596
|
+
const view = useMemo5(() => planeView(rawView, layersHere), [rawView, layersHere]);
|
|
3959
3597
|
const resolved = useMemo5(() => resolveView(renderModel, built.elements, view), [renderModel, built, view]);
|
|
3960
3598
|
const stats = useMemo5(() => {
|
|
3961
3599
|
const hn = new Set(view.hiddenNodeKinds ?? []), he = new Set(view.hiddenEdgeKinds ?? []);
|
|
@@ -3969,11 +3607,48 @@ function GraphCanvas(props) {
|
|
|
3969
3607
|
return { nodes, edges };
|
|
3970
3608
|
}, [model, resolved, view.hiddenNodeKinds, view.hiddenEdgeKinds]);
|
|
3971
3609
|
const diffSides = useMemo5(() => diff ? unionSides(diff) : null, [diff]);
|
|
3610
|
+
const oldIds = useMemo5(() => diff && new Map([...diff.resolved].map(([old, id]) => [id, old])), [diff]);
|
|
3611
|
+
const fullPast = useMemo5(() => {
|
|
3612
|
+
if (!scope.active || !scope.before) return diffSides?.before;
|
|
3613
|
+
const identity = props.sourceDiff ?? diff;
|
|
3614
|
+
if (!identity || ![...identity.resolved].some(([a, b]) => a !== b)) return scope.before;
|
|
3615
|
+
return unionSides({ ...identity, before: scope.before }).before;
|
|
3616
|
+
}, [scope.active, scope.before, diffSides, diff, props.sourceDiff]);
|
|
3617
|
+
const oldSubject = useMemo5(() => {
|
|
3618
|
+
if (!diff || !diffSides || !target || !fullPast) return void 0;
|
|
3619
|
+
const oldId = "node" in target && (oldIds?.get(target.node) ?? target.node);
|
|
3620
|
+
if (scope.active && !hasTarget(diffSides.before, target)) return void 0;
|
|
3621
|
+
return inspect(fullPast, target, oldId ? (scope.before ?? diff.before).index.get(oldId) : void 0);
|
|
3622
|
+
}, [diff, diffSides, fullPast, oldIds, target, scope.active, scope.before]);
|
|
3623
|
+
const currentSubject = useMemo5(() => {
|
|
3624
|
+
if (scope.active && target && !hasTarget(diff?.after ?? scope.local, target)) return void 0;
|
|
3625
|
+
return inspect(scope.active ? editingModel : diff?.after ?? editingModel, target);
|
|
3626
|
+
}, [scope.active, scope.local, diff, editingModel, target]);
|
|
3627
|
+
const selected = useMemo5(() => {
|
|
3628
|
+
const subject = target?.past ? oldSubject ?? currentSubject : currentSubject ?? oldSubject;
|
|
3629
|
+
const n = subject?.node;
|
|
3630
|
+
return n ? {
|
|
3631
|
+
id: n.id,
|
|
3632
|
+
label: n.label,
|
|
3633
|
+
kind: n.kind ?? "",
|
|
3634
|
+
layer: n.layer ?? profile.layers[0]?.id,
|
|
3635
|
+
parent: n.parent,
|
|
3636
|
+
order: n.order,
|
|
3637
|
+
origin: n.origin ?? null,
|
|
3638
|
+
container: !!subject.children.length,
|
|
3639
|
+
flags: [.../* @__PURE__ */ new Set([...n.flags ?? [], ...profile.nodeClass(subject.originalNode ?? n).split(/\s+/).filter(Boolean)])],
|
|
3640
|
+
detail: n.data ?? null
|
|
3641
|
+
} : null;
|
|
3642
|
+
}, [currentSubject, oldSubject, target, profile]);
|
|
3972
3643
|
const pastBuilt = useMemo5(
|
|
3973
3644
|
() => pastRenderModel ? buildElements(pastRenderModel, profile, { past: true }) : null,
|
|
3974
3645
|
[pastRenderModel, profile]
|
|
3975
3646
|
);
|
|
3976
|
-
const
|
|
3647
|
+
const checks = useMemo5(() => {
|
|
3648
|
+
if (props.checks) return props.checks;
|
|
3649
|
+
return props.issues ? { lint: props.issues } : validateModelBySource(editingModel, profile);
|
|
3650
|
+
}, [props.checks, props.issues, editingModel, profile]);
|
|
3651
|
+
const issues = useMemo5(() => checks.review ? checks.lint.concat(checks.review) : checks.lint, [checks]);
|
|
3977
3652
|
const onIssuesRef = useRef4(onIssues);
|
|
3978
3653
|
onIssuesRef.current = onIssues;
|
|
3979
3654
|
useEffect4(() => {
|
|
@@ -4051,6 +3726,7 @@ function GraphCanvas(props) {
|
|
|
4051
3726
|
if (v) painterRef.current?.hover(null, true);
|
|
4052
3727
|
onBusyRef.current?.(v);
|
|
4053
3728
|
}, []);
|
|
3729
|
+
useEffect4(() => () => markBusy(false), [markBusy]);
|
|
4054
3730
|
const carryLastFrame = useCallback2((resolved2) => {
|
|
4055
3731
|
if (!resolved2.size) return;
|
|
4056
3732
|
const carried = { ...dispRef.current };
|
|
@@ -4058,6 +3734,7 @@ function GraphCanvas(props) {
|
|
|
4058
3734
|
for (const [oldId, unionId] of resolved2) {
|
|
4059
3735
|
const p = dispRef.current[oldId];
|
|
4060
3736
|
if (p && !carried[unionId]) carried[unionId] = p;
|
|
3737
|
+
if (visibleFrameRef.current.has(oldId)) visibleFrameRef.current.add(unionId);
|
|
4061
3738
|
const s = book.get(oldId);
|
|
4062
3739
|
if (s && !book.has(unionId)) book.set(unionId, { ...s });
|
|
4063
3740
|
}
|
|
@@ -4069,10 +3746,11 @@ function GraphCanvas(props) {
|
|
|
4069
3746
|
return;
|
|
4070
3747
|
}
|
|
4071
3748
|
missedRef.current = false;
|
|
3749
|
+
setProfile(requestedProfile);
|
|
4072
3750
|
const prev = prevModelRef.current;
|
|
4073
3751
|
prevModelRef.current = model;
|
|
4074
|
-
const sameWorld = prevProfileRef.current ===
|
|
4075
|
-
prevProfileRef.current =
|
|
3752
|
+
const sameWorld = prevProfileRef.current === world;
|
|
3753
|
+
prevProfileRef.current = world;
|
|
4076
3754
|
const spec = resolveSpec(animateRef.current);
|
|
4077
3755
|
const sides = diffRef.current ? diffSidesRef.current ?? unionSides(diffRef.current) : null;
|
|
4078
3756
|
const settleNow = () => {
|
|
@@ -4085,9 +3763,13 @@ function GraphCanvas(props) {
|
|
|
4085
3763
|
prevPastRef.current = sides ? sides.before : null;
|
|
4086
3764
|
setPastRenderModel(sides ? sides.before : null);
|
|
4087
3765
|
};
|
|
4088
|
-
if (!sameWorld) {
|
|
3766
|
+
if (!sameWorld || !model.nodes.length || !prev?.nodes.length) {
|
|
4089
3767
|
dispRef.current = {};
|
|
3768
|
+
rawRef.current = {};
|
|
3769
|
+
visibleFrameRef.current.clear();
|
|
3770
|
+
framingRef.current = "";
|
|
4090
3771
|
labelsRef.current = /* @__PURE__ */ new Map();
|
|
3772
|
+
prevViewportRef.current = null;
|
|
4091
3773
|
}
|
|
4092
3774
|
if (!spec || !prev || prev === model || !sameWorld || !model.nodes.length || !prev.nodes.length) {
|
|
4093
3775
|
settleNow();
|
|
@@ -4107,7 +3789,7 @@ function GraphCanvas(props) {
|
|
|
4107
3789
|
pendingRef.current = step;
|
|
4108
3790
|
pendingPastRef.current = pastStep;
|
|
4109
3791
|
marksRef.current = STEP_MARKS;
|
|
4110
|
-
pendingSkinsRef.current = planSkins(step, prev, model,
|
|
3792
|
+
pendingSkinsRef.current = planSkins(step, prev, model, requestedProfile);
|
|
4111
3793
|
leftRef.current = /* @__PURE__ */ new Set();
|
|
4112
3794
|
leftPastRef.current = /* @__PURE__ */ new Set();
|
|
4113
3795
|
setDiffGeom(EMPTY_GEOM);
|
|
@@ -4127,11 +3809,11 @@ function GraphCanvas(props) {
|
|
|
4127
3809
|
}
|
|
4128
3810
|
carryLastFrame(delta.resolved);
|
|
4129
3811
|
pendingRef.current = delta;
|
|
4130
|
-
pendingSkinsRef.current = planSkins(delta, prev, model,
|
|
3812
|
+
pendingSkinsRef.current = planSkins(delta, prev, model, requestedProfile);
|
|
4131
3813
|
leftRef.current = /* @__PURE__ */ new Set();
|
|
4132
3814
|
markBusy(true);
|
|
4133
3815
|
setRenderModel(delta.model);
|
|
4134
|
-
}, [model, resume]);
|
|
3816
|
+
}, [model, requestedProfile, world, resume]);
|
|
4135
3817
|
const [diffGeom, setDiffGeom] = useState5(EMPTY_GEOM);
|
|
4136
3818
|
const [pastGeom, setPastGeom] = useState5(EMPTY_GEOM);
|
|
4137
3819
|
const visibleNodes = useCallback2((cy) => {
|
|
@@ -4139,17 +3821,19 @@ function GraphCanvas(props) {
|
|
|
4139
3821
|
const left = leftRef.current;
|
|
4140
3822
|
return cy.nodes().filter((n) => visible.has(n.id()) && !left.has(n.id()));
|
|
4141
3823
|
}, []);
|
|
4142
|
-
const
|
|
3824
|
+
const frameIds = useCallback2((visible) => {
|
|
3825
|
+
const ids = /* @__PURE__ */ new Set();
|
|
3826
|
+
const hidden = new Set(viewRef.current.hiddenNodeKinds);
|
|
3827
|
+
visible.forEach((n) => {
|
|
3828
|
+
if (n.id() !== VIRTUAL_ROOT && !n.isParent() && !hidden.has(n.data("kind")) && !(diffRef.current && (n.hasClass("gb-removed") || n.hasClass("gb-merged")))) ids.add(n.id());
|
|
3829
|
+
});
|
|
3830
|
+
return ids;
|
|
3831
|
+
}, []);
|
|
3832
|
+
const fitAll = useCallback2((cy, coll) => {
|
|
4143
3833
|
const vis = coll ?? visibleNodes(cy);
|
|
4144
3834
|
const go = (eles, padding) => {
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
if (cy.zoom() > FIT_MAX_ZOOM) cy.zoom({ level: FIT_MAX_ZOOM, renderedPosition: { x: cy.width() / 2, y: cy.height() / 2 } });
|
|
4148
|
-
};
|
|
4149
|
-
if (animate2) requestAnimationFrame(() => {
|
|
4150
|
-
if (!cy.destroyed()) fit2();
|
|
4151
|
-
});
|
|
4152
|
-
else fit2();
|
|
3835
|
+
cy.fit(eles, padding);
|
|
3836
|
+
if (cy.zoom() > FIT_MAX_ZOOM) cy.zoom({ level: FIT_MAX_ZOOM, renderedPosition: { x: cy.width() / 2, y: cy.height() / 2 } });
|
|
4153
3837
|
};
|
|
4154
3838
|
if (!viewRef.current.planes || platesRef.current.length === 0) {
|
|
4155
3839
|
if (vis.length) go(vis, compactRef.current ? 24 : FIT_PAD);
|
|
@@ -4197,18 +3881,26 @@ function GraphCanvas(props) {
|
|
|
4197
3881
|
const left = leftRef.current;
|
|
4198
3882
|
painterRef.current?.spotlight(ids.size ? new Set([...ids].filter((id) => !left.has(id))) : null);
|
|
4199
3883
|
}, []);
|
|
3884
|
+
const spotlightLayer = useCallback2((layer) => {
|
|
3885
|
+
if (hotLayerRef.current === layer) return;
|
|
3886
|
+
hotLayerRef.current = layer;
|
|
3887
|
+
setHotLayer(layer);
|
|
3888
|
+
respot();
|
|
3889
|
+
}, [respot]);
|
|
4200
3890
|
const projectAt = useCallback2((raw, t) => {
|
|
4201
3891
|
const layers = profileRef.current.layers;
|
|
4202
3892
|
if (layers.length < 2) return { positions: { ...raw }, plates: [] };
|
|
4203
|
-
|
|
4204
|
-
return projectPlanes(raw, layerOfRef.current, layers, {}, t, frame);
|
|
3893
|
+
return projectPlanes(raw, layerOfRef.current, layers, {}, t);
|
|
4205
3894
|
}, []);
|
|
4206
3895
|
const showPlates = useCallback2((plates2, alpha) => {
|
|
4207
3896
|
platesRef.current = plates2;
|
|
4208
3897
|
plateAlphaRef.current = alpha;
|
|
4209
3898
|
setPlates(plates2);
|
|
4210
3899
|
setPlateAlpha(alpha);
|
|
4211
|
-
|
|
3900
|
+
if (hotLayerRef.current && (alpha <= 0.01 || !plates2.some((p) => p.layer === hotLayerRef.current))) {
|
|
3901
|
+
spotlightLayer(null);
|
|
3902
|
+
}
|
|
3903
|
+
}, [spotlightLayer]);
|
|
4212
3904
|
const applyView = useCallback2((opts) => {
|
|
4213
3905
|
const cy = cyRef.current;
|
|
4214
3906
|
if (!cy) return;
|
|
@@ -4237,55 +3929,9 @@ function GraphCanvas(props) {
|
|
|
4237
3929
|
showPlates(litPlates(projectAt(rawRef.current, planeTRef.current).plates, shownIn(v)), plateAlphaRef.current);
|
|
4238
3930
|
}
|
|
4239
3931
|
const vis = visibleNodes(cy);
|
|
4240
|
-
|
|
4241
|
-
const wantTighten = isNarrowing(v) && !v.planes && vis.length > 1 && vis.length <= TIGHTEN_MAX && !diffRef.current;
|
|
4242
|
-
if (wantTighten) {
|
|
4243
|
-
try {
|
|
4244
|
-
const structureless = visEdges.length === 0 && vis.filter((n) => !n.isChildless()).length === 0;
|
|
4245
|
-
const seed = vis.length <= SEED_MAX;
|
|
4246
|
-
if (!structureless && seed) {
|
|
4247
|
-
const bb = vis.boundingBox();
|
|
4248
|
-
const want = Math.sqrt(vis.length) * NODE_PITCH;
|
|
4249
|
-
const k = want / Math.max(1, bb.w, bb.h);
|
|
4250
|
-
if (k < 1) {
|
|
4251
|
-
const mx = bb.x1 + bb.w / 2, my = bb.y1 + bb.h / 2;
|
|
4252
|
-
cy.batch(() => vis.forEach((n) => {
|
|
4253
|
-
const p = n.position();
|
|
4254
|
-
n.position({ x: mx + (p.x - mx) * k, y: my + (p.y - my) * k });
|
|
4255
|
-
}));
|
|
4256
|
-
}
|
|
4257
|
-
}
|
|
4258
|
-
vis.union(visEdges).layout(structureless ? { name: "grid", fit: false, animate: false, avoidOverlap: true, condense: true } : {
|
|
4259
|
-
name: "fcose",
|
|
4260
|
-
quality: "default",
|
|
4261
|
-
randomize: !seed,
|
|
4262
|
-
animate: false,
|
|
4263
|
-
fit: false,
|
|
4264
|
-
nodeSeparation: 45,
|
|
4265
|
-
idealEdgeLength: 60,
|
|
4266
|
-
nodeRepulsion: 8e3,
|
|
4267
|
-
packComponents: true,
|
|
4268
|
-
tile: true,
|
|
4269
|
-
tilingPaddingVertical: 8,
|
|
4270
|
-
tilingPaddingHorizontal: 8
|
|
4271
|
-
}).run();
|
|
4272
|
-
tightenedRef.current = true;
|
|
4273
|
-
if (opts?.fit !== false) fitAll(cy, vis, true);
|
|
4274
|
-
return;
|
|
4275
|
-
} catch {
|
|
4276
|
-
}
|
|
4277
|
-
}
|
|
4278
|
-
if (tightenedRef.current) {
|
|
4279
|
-
cy.batch(() => {
|
|
4280
|
-
cy.nodes(":childless").forEach((n) => {
|
|
4281
|
-
const p = baseRef.current[n.id()];
|
|
4282
|
-
if (p) n.position(p);
|
|
4283
|
-
});
|
|
4284
|
-
});
|
|
4285
|
-
tightenedRef.current = false;
|
|
4286
|
-
}
|
|
3932
|
+
if (!busyRef.current) visibleFrameRef.current = frameIds(vis);
|
|
4287
3933
|
if (opts?.fit !== false) fitAll(cy, vis);
|
|
4288
|
-
}, [fitAll, visibleNodes, respot, projectAt, showPlates]);
|
|
3934
|
+
}, [fitAll, visibleNodes, respot, projectAt, showPlates, frameIds]);
|
|
4289
3935
|
const touchInteraction = useCallback2(() => {
|
|
4290
3936
|
lastInteractionRef.current = Date.now();
|
|
4291
3937
|
}, []);
|
|
@@ -4398,6 +4044,8 @@ function GraphCanvas(props) {
|
|
|
4398
4044
|
ringRafRef.current = null;
|
|
4399
4045
|
if (cy.destroyed()) return;
|
|
4400
4046
|
drawLabels(cy);
|
|
4047
|
+
const mirror = mirrorRef.current;
|
|
4048
|
+
if (mirror && !mirror.destroyed()) drawLabels(mirror);
|
|
4401
4049
|
const now = performance.now();
|
|
4402
4050
|
if ([...ringsRef.current.values()].some((t0) => now - t0 < RING_IN_MS)) ringRafRef.current = requestAnimationFrame(step);
|
|
4403
4051
|
};
|
|
@@ -4506,10 +4154,10 @@ function GraphCanvas(props) {
|
|
|
4506
4154
|
if (cyRef.current === cy && !cy.destroyed()) scheduleReadability(cy);
|
|
4507
4155
|
}, LABEL_SETTLE_MS);
|
|
4508
4156
|
}, [scheduleReadability]);
|
|
4509
|
-
const applyHover = useCallback2((cy,
|
|
4157
|
+
const applyHover = useCallback2((cy, target2, fade = true) => {
|
|
4510
4158
|
const painter = painterRef.current;
|
|
4511
4159
|
if (cy.destroyed() || !painter) return;
|
|
4512
|
-
painter.hover(diffRef.current ? null :
|
|
4160
|
+
painter.hover(diffRef.current ? null : target2, !fade);
|
|
4513
4161
|
if (readableRef.current && !diffRef.current && !labelsFrozen()) replanLabels(cy);
|
|
4514
4162
|
}, [labelsFrozen, replanLabels]);
|
|
4515
4163
|
const emphasisKey = JSON.stringify(emphasis ?? null);
|
|
@@ -4519,50 +4167,40 @@ function GraphCanvas(props) {
|
|
|
4519
4167
|
respot();
|
|
4520
4168
|
if (readableRef.current && !labelsFrozen()) replanLabels(cy);
|
|
4521
4169
|
}, [emphasisKey, respot, labelsFrozen, replanLabels]);
|
|
4522
|
-
const
|
|
4523
|
-
if (
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
clearTimeout(hoverOutRef.current);
|
|
4550
|
-
hoverOutRef.current = null;
|
|
4551
|
-
}
|
|
4552
|
-
if (labelsFrozen()) target = null;
|
|
4553
|
-
cy.batch(() => {
|
|
4554
|
-
cy.$(".gb-preview, .gb-preview-hop").removeClass("gb-preview gb-preview-hop");
|
|
4555
|
-
if (diffRef.current || !readableRef.current) {
|
|
4556
|
-
target?.addClass("gb-preview");
|
|
4557
|
-
if (target) (target.isNode() ? target.closedNeighborhood() : target.connectedNodes()).addClass("gb-preview-hop");
|
|
4170
|
+
const cancelHoverTimer = useCallback2(() => {
|
|
4171
|
+
if (hoverTimerRef.current != null) clearTimeout(hoverTimerRef.current);
|
|
4172
|
+
hoverTimerRef.current = null;
|
|
4173
|
+
}, []);
|
|
4174
|
+
const highlight = useCallback2((cy, target2, touch) => {
|
|
4175
|
+
cancelHoverTimer();
|
|
4176
|
+
const apply = () => {
|
|
4177
|
+
hoverTimerRef.current = null;
|
|
4178
|
+
if (cy.destroyed()) return;
|
|
4179
|
+
const frozen = labelsFrozen();
|
|
4180
|
+
const hit = frozen ? null : target2;
|
|
4181
|
+
const layer = typeof hit === "string" && plateAlphaRef.current > 0.01 && platesRef.current.some((p) => p.layer === hit) ? hit : null;
|
|
4182
|
+
spotlightLayer(layer);
|
|
4183
|
+
const element = hit && typeof hit !== "string" && !hit.removed() ? hit : null;
|
|
4184
|
+
if (touch) {
|
|
4185
|
+
cy.batch(() => {
|
|
4186
|
+
cy.$(".gb-preview, .gb-preview-hop").removeClass("gb-preview gb-preview-hop");
|
|
4187
|
+
if (element && (diffRef.current || !readableRef.current)) {
|
|
4188
|
+
element.addClass("gb-preview");
|
|
4189
|
+
(element.isNode() ? element.closedNeighborhood() : element.connectedNodes()).addClass("gb-preview-hop");
|
|
4190
|
+
}
|
|
4191
|
+
});
|
|
4192
|
+
if (diffRef.current || !readableRef.current) {
|
|
4193
|
+
replanLabels(cy);
|
|
4194
|
+
drawLabels(cy);
|
|
4195
|
+
return;
|
|
4196
|
+
}
|
|
4558
4197
|
}
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
}, [labelsFrozen, applyHover, replanLabels, drawLabels]);
|
|
4198
|
+
applyHover(cy, element, !frozen);
|
|
4199
|
+
};
|
|
4200
|
+
const focused = hotLayerRef.current != null || painterRef.current?.hoveredId() != null;
|
|
4201
|
+
if (touch || labelsFrozen() || target2 != null && focused) apply();
|
|
4202
|
+
else hoverTimerRef.current = setTimeout(apply, target2 == null ? HOVER_OUT_MS : HOVER_IN_MS);
|
|
4203
|
+
}, [cancelHoverTimer, labelsFrozen, spotlightLayer, applyHover, replanLabels, drawLabels]);
|
|
4566
4204
|
const armBreath = useCallback2((cy) => {
|
|
4567
4205
|
if (!readableRef.current || breathTimerRef.current != null) return;
|
|
4568
4206
|
const tick = () => {
|
|
@@ -4660,30 +4298,28 @@ function GraphCanvas(props) {
|
|
|
4660
4298
|
if (!busyRef.current) setPastGeom(measureDiffGeom(m, leftPastRef.current));
|
|
4661
4299
|
}, []);
|
|
4662
4300
|
const selectEle = useCallback2((el) => {
|
|
4663
|
-
if (!el || el.empty?.())
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4301
|
+
if (!el || el.empty?.() || el.id() === VIRTUAL_ROOT) {
|
|
4302
|
+
setTrail([]);
|
|
4303
|
+
return;
|
|
4304
|
+
}
|
|
4305
|
+
const past = el.cy() === mirrorRef.current;
|
|
4306
|
+
if (el.isNode()) setTrail([{ node: el.id(), past }]);
|
|
4307
|
+
else if (!el.hasClass("contains")) setTrail([{ edge: { source: el.data("source"), target: el.data("target"), kind: el.data("kind") }, past }]);
|
|
4308
|
+
}, []);
|
|
4309
|
+
const syncSelection = useCallback2((cy, item) => {
|
|
4310
|
+
if (!cy || cy.destroyed()) return;
|
|
4311
|
+
const match = item && ("node" in item ? cy.$id(item.node) : cy.edges().filter((e) => !e.hasClass("contains") && sameEdge(e.data(), item.edge)));
|
|
4312
|
+
cy.batch(() => {
|
|
4313
|
+
cy.$(":selected").difference(match || cy.collection()).unselect();
|
|
4314
|
+
if (match?.length && match.visible()) match.select();
|
|
4677
4315
|
});
|
|
4678
4316
|
}, []);
|
|
4679
|
-
const
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
target
|
|
4684
|
-
|
|
4685
|
-
else setSelected(null);
|
|
4686
|
-
}, [selectEle]);
|
|
4317
|
+
const targetRef = useRef4(target);
|
|
4318
|
+
targetRef.current = target;
|
|
4319
|
+
useEffect4(() => {
|
|
4320
|
+
syncSelection(cyRef.current, target);
|
|
4321
|
+
syncSelection(mirrorRef.current, target);
|
|
4322
|
+
}, [target, liveCy, syncSelection]);
|
|
4687
4323
|
const cancelFrames = useCallback2(() => {
|
|
4688
4324
|
const tw = tweenRef.current;
|
|
4689
4325
|
if (tw) {
|
|
@@ -4732,12 +4368,12 @@ function GraphCanvas(props) {
|
|
|
4732
4368
|
});
|
|
4733
4369
|
if (settle && diffRef.current) setDiffGeom(measureDiffGeom(cy, leftRef.current));
|
|
4734
4370
|
}, []);
|
|
4735
|
-
const settleTo = useCallback2((cy,
|
|
4736
|
-
dispRef.current = { ...
|
|
4737
|
-
applyPositions(cy,
|
|
4371
|
+
const settleTo = useCallback2((cy, target2, after) => {
|
|
4372
|
+
dispRef.current = { ...target2 };
|
|
4373
|
+
applyPositions(cy, target2, true);
|
|
4738
4374
|
after?.();
|
|
4739
4375
|
}, [applyPositions]);
|
|
4740
|
-
const playTransition = useCallback2((cy, union, after) => {
|
|
4376
|
+
const playTransition = useCallback2((cy, union, after, returnView) => {
|
|
4741
4377
|
const spec = resolveSpec(animateRef.current);
|
|
4742
4378
|
const delta = pendingRef.current;
|
|
4743
4379
|
const pastDelta = pendingPastRef.current;
|
|
@@ -4776,10 +4412,12 @@ function GraphCanvas(props) {
|
|
|
4776
4412
|
// or exits: the marks on the union are left over, and planning by them would replay the previous batch.
|
|
4777
4413
|
presence: delta ? presenceOf(cy, marksRef.current) : void 0
|
|
4778
4414
|
};
|
|
4415
|
+
const framing = [cy.width(), cy.height(), !!diffRef.current, planeKey(viewRef.current)].join("|");
|
|
4416
|
+
const sameFraming = framingRef.current === framing;
|
|
4417
|
+
framingRef.current = framing;
|
|
4779
4418
|
const tooBig = !!spec && Object.keys(union).length > spec.maxNodes;
|
|
4780
|
-
const filtering2 = isNarrowing(viewRef.current);
|
|
4781
4419
|
const hidden = typeof document !== "undefined" && document.visibilityState === "hidden";
|
|
4782
|
-
if (!spec || tooBig ||
|
|
4420
|
+
if (!spec || tooBig || hidden) {
|
|
4783
4421
|
onTransitionRef.current?.({
|
|
4784
4422
|
...planTransition(delta, dispRef.current, union, planOpts).report,
|
|
4785
4423
|
layoutMs: layoutMsRef.current,
|
|
@@ -4788,7 +4426,10 @@ function GraphCanvas(props) {
|
|
|
4788
4426
|
collectLeft();
|
|
4789
4427
|
armed.disarm();
|
|
4790
4428
|
disarmMirror();
|
|
4791
|
-
settleTo(cy, union, () =>
|
|
4429
|
+
settleTo(cy, union, () => {
|
|
4430
|
+
if (returnView) cy.viewport(returnView);
|
|
4431
|
+
after(!!returnView);
|
|
4432
|
+
});
|
|
4792
4433
|
forgetLeft();
|
|
4793
4434
|
return;
|
|
4794
4435
|
}
|
|
@@ -4797,12 +4438,14 @@ function GraphCanvas(props) {
|
|
|
4797
4438
|
setPastGeom(EMPTY_GEOM);
|
|
4798
4439
|
};
|
|
4799
4440
|
const t = planTransition(delta, dispRef.current, union, planOpts);
|
|
4800
|
-
|
|
4801
|
-
|
|
4441
|
+
const movingCamera = returnView && (Math.abs(returnView.zoom - cy.zoom()) > 1e-6 || Math.hypot(returnView.pan.x - cy.pan().x, returnView.pan.y - cy.pan().y) > 0.5);
|
|
4442
|
+
const animated = t.worth || !!movingCamera;
|
|
4443
|
+
onTransitionRef.current?.({ ...t.report, layoutMs: layoutMsRef.current, animated });
|
|
4444
|
+
if (!animated) {
|
|
4802
4445
|
collectLeft();
|
|
4803
4446
|
armed.disarm();
|
|
4804
4447
|
disarmMirror();
|
|
4805
|
-
settleTo(cy, union, () => after
|
|
4448
|
+
settleTo(cy, union, () => after(sameFraming || !!returnView));
|
|
4806
4449
|
forgetLeft();
|
|
4807
4450
|
return;
|
|
4808
4451
|
}
|
|
@@ -4815,10 +4458,13 @@ function GraphCanvas(props) {
|
|
|
4815
4458
|
fitAll(cy);
|
|
4816
4459
|
const vU = cam();
|
|
4817
4460
|
leftRef.current = /* @__PURE__ */ new Set([...leftBefore, ...t.leaving]);
|
|
4818
|
-
fitAll(cy);
|
|
4819
|
-
const v1 = cam();
|
|
4461
|
+
if (!returnView) fitAll(cy);
|
|
4462
|
+
const v1 = returnView ?? cam();
|
|
4820
4463
|
leftRef.current = leftBefore;
|
|
4821
|
-
|
|
4464
|
+
const startPositions = sampleTransition(t, 0).pos;
|
|
4465
|
+
applyPositions(cy, startPositions, false);
|
|
4466
|
+
const mirror = mirrorNow();
|
|
4467
|
+
if (mirror) applyPositions(mirror.m, startPositions, false);
|
|
4822
4468
|
cy.viewport(v0);
|
|
4823
4469
|
const W = cy.width() || 1, H = cy.height() || 1;
|
|
4824
4470
|
const r0 = toRect(v0, W, H), r12 = toRect(v1, W, H);
|
|
@@ -4839,12 +4485,12 @@ function GraphCanvas(props) {
|
|
|
4839
4485
|
disarmMirror();
|
|
4840
4486
|
const settled = { ...union };
|
|
4841
4487
|
for (const id of t.leaving) {
|
|
4842
|
-
const
|
|
4843
|
-
if (
|
|
4488
|
+
const q = dispRef.current[id];
|
|
4489
|
+
if (q) settled[id] = q;
|
|
4844
4490
|
}
|
|
4845
4491
|
settleTo(cy, settled, () => {
|
|
4846
4492
|
cy.viewport(v1);
|
|
4847
|
-
after
|
|
4493
|
+
after(true);
|
|
4848
4494
|
});
|
|
4849
4495
|
forgetLeft();
|
|
4850
4496
|
};
|
|
@@ -4863,10 +4509,10 @@ function GraphCanvas(props) {
|
|
|
4863
4509
|
Object.assign(dispRef.current, pos);
|
|
4864
4510
|
cy.batch(() => {
|
|
4865
4511
|
leaves.forEach((n) => {
|
|
4866
|
-
const
|
|
4867
|
-
if (
|
|
4512
|
+
const q = pos[n.id()];
|
|
4513
|
+
if (q) n.position(q);
|
|
4868
4514
|
});
|
|
4869
|
-
for (const n of FADE_NAMES) groups[n].style("opacity",
|
|
4515
|
+
for (const n of FADE_NAMES) groups[n].style("opacity", clamp01(fade[n]));
|
|
4870
4516
|
for (const g of skinGroups) g.eles.style(sampleSkinStyle(g.tween, fade.in));
|
|
4871
4517
|
if (!present && fade.in > 0) {
|
|
4872
4518
|
present = true;
|
|
@@ -4877,10 +4523,10 @@ function GraphCanvas(props) {
|
|
|
4877
4523
|
if (mir) {
|
|
4878
4524
|
mir.m.batch(() => {
|
|
4879
4525
|
mir.leaves.forEach((n) => {
|
|
4880
|
-
const
|
|
4881
|
-
if (
|
|
4526
|
+
const q = pos[n.id()];
|
|
4527
|
+
if (q) n.position(q);
|
|
4882
4528
|
});
|
|
4883
|
-
if (mir.armed) for (const n of FADE_NAMES) mir.armed.groups[n].style("opacity",
|
|
4529
|
+
if (mir.armed) for (const n of FADE_NAMES) mir.armed.groups[n].style("opacity", clamp01(fade[n]));
|
|
4884
4530
|
});
|
|
4885
4531
|
}
|
|
4886
4532
|
cy.viewport(toView({
|
|
@@ -4920,7 +4566,10 @@ function GraphCanvas(props) {
|
|
|
4920
4566
|
const dims = {};
|
|
4921
4567
|
cy.nodes(":childless").forEach((n) => {
|
|
4922
4568
|
const d = n.layoutDimensions({ nodeDimensionsIncludeLabels: true });
|
|
4923
|
-
|
|
4569
|
+
const size = { w: Math.round(d.w * 64) / 64, h: Math.round(d.h * 64) / 64 };
|
|
4570
|
+
dims[n.id()] = size;
|
|
4571
|
+
const old = dimsRef.current[n.id()];
|
|
4572
|
+
if (!old || old.w !== size.w || old.h !== size.h) framingRef.current = "";
|
|
4924
4573
|
});
|
|
4925
4574
|
dimsRef.current = dims;
|
|
4926
4575
|
if (scaled) cy.style(sheetFor(false));
|
|
@@ -5019,20 +4668,44 @@ function GraphCanvas(props) {
|
|
|
5019
4668
|
layerOfRef.current = layerOf;
|
|
5020
4669
|
const t = viewRef.current.planes ? 1 : 0;
|
|
5021
4670
|
const placed = projectAt(positions, t);
|
|
4671
|
+
const previous = dispRef.current;
|
|
4672
|
+
const before = /* @__PURE__ */ Object.create(null), after = /* @__PURE__ */ Object.create(null);
|
|
4673
|
+
for (const id of visibleFrameRef.current) if (previous[id]) before[id] = previous[id];
|
|
4674
|
+
const target2 = diffSidesRef.current?.after ?? model;
|
|
4675
|
+
for (const id of frameIds(visibleNodes(cy))) {
|
|
4676
|
+
if (target2.index.has(id) && placed.positions[id]) after[id] = placed.positions[id];
|
|
4677
|
+
}
|
|
4678
|
+
const shift = frameTranslation(before, after);
|
|
4679
|
+
if (shift.x || shift.y) {
|
|
4680
|
+
for (const [id, p] of Object.entries(previous)) previous[id] = { x: p.x + shift.x, y: p.y + shift.y };
|
|
4681
|
+
cy.panBy({ x: -shift.x * cy.zoom(), y: -shift.y * cy.zoom() });
|
|
4682
|
+
}
|
|
5022
4683
|
for (const id of stay) placed.positions[id] = dispRef.current[id];
|
|
5023
4684
|
planeTRef.current = t;
|
|
5024
4685
|
planeKeyRef.current = planeKey(viewRef.current);
|
|
5025
4686
|
layerAlphaRef.current = /* @__PURE__ */ new Map();
|
|
5026
4687
|
baseRef.current = placed.positions;
|
|
5027
|
-
tightenedRef.current = false;
|
|
5028
4688
|
showPlates(litPlates(placed.plates, shownIn(viewRef.current)), t);
|
|
5029
4689
|
setProg(null);
|
|
4690
|
+
const bookmark = !scope.active && props.restoreCamera.current;
|
|
4691
|
+
const anchor = bookmark && after[bookmark.id];
|
|
4692
|
+
const returnView = anchor && bookmark ? { zoom: bookmark.zoom, pan: {
|
|
4693
|
+
x: cy.width() / 2 + bookmark.dx - anchor.x * bookmark.zoom,
|
|
4694
|
+
y: cy.height() / 2 + bookmark.dy - anchor.y * bookmark.zoom
|
|
4695
|
+
} } : null;
|
|
4696
|
+
if (bookmark) props.restoreCamera.current = null;
|
|
5030
4697
|
playTransition(cy, placed.positions, (cameraPlaced) => {
|
|
5031
4698
|
markBusy(false);
|
|
5032
4699
|
if (missedRef.current) setResume((v) => v + 1);
|
|
5033
4700
|
if (cyRef.current !== cy) return;
|
|
5034
4701
|
applyView({ fit: !cameraPlaced });
|
|
5035
|
-
|
|
4702
|
+
const destination = props.destination.current;
|
|
4703
|
+
if (destination && !scope.active) {
|
|
4704
|
+
props.destination.current = null;
|
|
4705
|
+
setTrail([destination]);
|
|
4706
|
+
if ("node" in destination) flyToRef.current(destination.node, false, true);
|
|
4707
|
+
}
|
|
4708
|
+
sightRef.current = planeKey(viewRef.current);
|
|
5036
4709
|
if (plateAlphaRef.current > 0 || diffRef.current) setViewport({ zoom: cy.zoom(), pan: { ...cy.pan() } });
|
|
5037
4710
|
syncMirror();
|
|
5038
4711
|
if (!missedRef.current && owedLayoutRef.current) {
|
|
@@ -5046,7 +4719,7 @@ function GraphCanvas(props) {
|
|
|
5046
4719
|
pendingPickRef.current = null;
|
|
5047
4720
|
pickRef.current(want);
|
|
5048
4721
|
}
|
|
5049
|
-
});
|
|
4722
|
+
}, returnView);
|
|
5050
4723
|
} catch (err) {
|
|
5051
4724
|
pendingRef.current = null;
|
|
5052
4725
|
markBusy(false);
|
|
@@ -5055,7 +4728,7 @@ function GraphCanvas(props) {
|
|
|
5055
4728
|
} finally {
|
|
5056
4729
|
if (runRef.current === run) setProg(null);
|
|
5057
4730
|
}
|
|
5058
|
-
}, [built, pool, profile, applyView, playTransition, markBusy, sheetFor, scheduleReadability, projectAt, showPlates]);
|
|
4731
|
+
}, [built, pool, profile, model, scope.active, applyView, playTransition, markBusy, sheetFor, scheduleReadability, projectAt, showPlates, frameIds, visibleNodes]);
|
|
5059
4732
|
const playPlanes = useCallback2((cy) => {
|
|
5060
4733
|
if (planeTweenRef.current != null) {
|
|
5061
4734
|
cancelAnimationFrame(planeTweenRef.current);
|
|
@@ -5065,7 +4738,7 @@ function GraphCanvas(props) {
|
|
|
5065
4738
|
const v = viewRef.current;
|
|
5066
4739
|
const prevKey = planeKeyRef.current;
|
|
5067
4740
|
planeKeyRef.current = planeKey(v);
|
|
5068
|
-
sightRef.current =
|
|
4741
|
+
sightRef.current = planeKey(v);
|
|
5069
4742
|
const raw = rawRef.current;
|
|
5070
4743
|
const t0 = planeTRef.current, t1 = v.planes ? 1 : 0;
|
|
5071
4744
|
const end = projectAt(raw, t1);
|
|
@@ -5114,8 +4787,8 @@ ${lt}`;
|
|
|
5114
4787
|
};
|
|
5115
4788
|
const place = (pos) => {
|
|
5116
4789
|
for (const g of groups) g.inst.batch(() => g.leaves.forEach((n) => {
|
|
5117
|
-
const
|
|
5118
|
-
if (
|
|
4790
|
+
const q = pos[n.id()];
|
|
4791
|
+
if (q) n.position(q);
|
|
5119
4792
|
}));
|
|
5120
4793
|
Object.assign(dispRef.current, pos);
|
|
5121
4794
|
};
|
|
@@ -5137,7 +4810,7 @@ ${lt}`;
|
|
|
5137
4810
|
};
|
|
5138
4811
|
const spec = resolveSpec(animateRef.current);
|
|
5139
4812
|
const hidden = typeof document !== "undefined" && document.visibilityState === "hidden";
|
|
5140
|
-
if (!spec || hidden ||
|
|
4813
|
+
if (!spec || hidden || !Object.keys(raw).length) {
|
|
5141
4814
|
finish();
|
|
5142
4815
|
applyView();
|
|
5143
4816
|
syncMirror();
|
|
@@ -5149,16 +4822,16 @@ ${lt}`;
|
|
|
5149
4822
|
const from = { ...dispRef.current };
|
|
5150
4823
|
const platesBefore = platesRef.current;
|
|
5151
4824
|
cy.batch(() => groups[0].leaves.forEach((n) => {
|
|
5152
|
-
const
|
|
5153
|
-
if (
|
|
4825
|
+
const q = end.positions[n.id()];
|
|
4826
|
+
if (q) n.position(q);
|
|
5154
4827
|
}));
|
|
5155
4828
|
platesRef.current = endPlates;
|
|
5156
4829
|
fitAll(cy);
|
|
5157
4830
|
const v1 = { zoom: cy.zoom(), pan: { ...cy.pan() } };
|
|
5158
4831
|
platesRef.current = platesBefore;
|
|
5159
4832
|
cy.batch(() => groups[0].leaves.forEach((n) => {
|
|
5160
|
-
const
|
|
5161
|
-
if (
|
|
4833
|
+
const q = from[n.id()];
|
|
4834
|
+
if (q) n.position(q);
|
|
5162
4835
|
}));
|
|
5163
4836
|
cy.viewport(v0);
|
|
5164
4837
|
const r0 = toRect(v0, W, H), r12 = toRect(v1, W, H);
|
|
@@ -5190,11 +4863,12 @@ ${lt}`;
|
|
|
5190
4863
|
planeTweenRef.current = requestAnimationFrame(frame);
|
|
5191
4864
|
}, [projectAt, showPlates, fitAll, applyView, syncMirror, scheduleReadability, cancelFly]);
|
|
5192
4865
|
playPlanesRef.current = playPlanes;
|
|
5193
|
-
const flyTo = useCallback2((id, around2 = false) => {
|
|
4866
|
+
const flyTo = useCallback2((id, around2 = false, allowPast = false) => {
|
|
5194
4867
|
const cy = cyRef.current;
|
|
5195
4868
|
if (!cy || cy.destroyed() || busyRef.current || planeTweenRef.current != null) return;
|
|
5196
|
-
const
|
|
5197
|
-
|
|
4869
|
+
const now = cy.$id(id);
|
|
4870
|
+
const n = allowPast && (!now.length || !now.visible()) ? mirrorRef.current?.$id(id) : now;
|
|
4871
|
+
if (!n || n.empty() || !n.visible()) return;
|
|
5198
4872
|
cancelFly();
|
|
5199
4873
|
const W = cy.width() || 1, H = cy.height() || 1;
|
|
5200
4874
|
const p = n.position();
|
|
@@ -5218,10 +4892,10 @@ ${lt}`;
|
|
|
5218
4892
|
const path = zoomPath(a, b);
|
|
5219
4893
|
const dur = Math.min(FLY_MS.max, Math.max(FLY_MS.min, path.S * FLY_MS_PER_S));
|
|
5220
4894
|
const start = performance.now();
|
|
5221
|
-
const frame = (
|
|
4895
|
+
const frame = (now2) => {
|
|
5222
4896
|
flyRef.current = null;
|
|
5223
4897
|
if (cyRef.current !== cy || cy.destroyed()) return;
|
|
5224
|
-
const k = Math.min(1, (
|
|
4898
|
+
const k = Math.min(1, (now2 - start) / dur);
|
|
5225
4899
|
cy.viewport(toView(path.at(easeInOut(k)), cy.width() || W, cy.height() || H));
|
|
5226
4900
|
if (k < 1) flyRef.current = requestAnimationFrame(frame);
|
|
5227
4901
|
};
|
|
@@ -5236,14 +4910,8 @@ ${lt}`;
|
|
|
5236
4910
|
let detach = null;
|
|
5237
4911
|
let cancelled = false;
|
|
5238
4912
|
(async () => {
|
|
5239
|
-
const
|
|
5240
|
-
import("cytoscape"),
|
|
5241
|
-
import("cytoscape-fcose"),
|
|
5242
|
-
import("cytoscape-cose-bilkent")
|
|
5243
|
-
]);
|
|
4913
|
+
const { default: cytoscape } = await import("cytoscape");
|
|
5244
4914
|
if (cancelled || !containerRef.current) return;
|
|
5245
|
-
cytoscape.use(fcose);
|
|
5246
|
-
cytoscape.use(coseBilkent);
|
|
5247
4915
|
cy = cytoscape({
|
|
5248
4916
|
container: containerRef.current,
|
|
5249
4917
|
elements: built.elements,
|
|
@@ -5256,8 +4924,9 @@ ${lt}`;
|
|
|
5256
4924
|
maxZoom: 4
|
|
5257
4925
|
});
|
|
5258
4926
|
const prevView = prevViewportRef.current;
|
|
4927
|
+
const restoringCamera = !scope.active && !!props.restoreCamera.current;
|
|
5259
4928
|
if (prevView) cy.viewport(prevView);
|
|
5260
|
-
seatFromLastFrame(cy, dispRef.current, (
|
|
4929
|
+
seatFromLastFrame(cy, dispRef.current, (q) => built.parentOf.get(q));
|
|
5261
4930
|
armedRef.current = null;
|
|
5262
4931
|
if (pendingRef.current && resolveSpec(animateRef.current)) armTransition(cy);
|
|
5263
4932
|
painterRef.current = installPainter(cy, {
|
|
@@ -5283,7 +4952,7 @@ ${lt}`;
|
|
|
5283
4952
|
const pan = cy.pan();
|
|
5284
4953
|
cy.resize();
|
|
5285
4954
|
if (first) {
|
|
5286
|
-
fitAll(cy);
|
|
4955
|
+
if (!prevView && !restoringCamera && !busyRef.current) fitAll(cy);
|
|
5287
4956
|
return;
|
|
5288
4957
|
}
|
|
5289
4958
|
const sel = cy.nodes(":selected").filter((n) => n.visible());
|
|
@@ -5307,10 +4976,9 @@ ${lt}`;
|
|
|
5307
4976
|
detach = installGraphInput(cy, containerRef.current, {
|
|
5308
4977
|
interact: touchInteraction,
|
|
5309
4978
|
cancelFly,
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
preview: (target) => previewTouch(cy, target),
|
|
4979
|
+
select: selectEle,
|
|
4980
|
+
hover: (target2) => highlight(cy, target2, false),
|
|
4981
|
+
preview: (target2) => highlight(cy, target2, true),
|
|
5314
4982
|
// The first click opens the inspector: let its new width settle before framing.
|
|
5315
4983
|
focus: (id) => requestAnimationFrame(() => requestAnimationFrame(() => {
|
|
5316
4984
|
if (!cy.destroyed()) flyToRef.current(id, true);
|
|
@@ -5329,9 +4997,9 @@ ${lt}`;
|
|
|
5329
4997
|
});
|
|
5330
4998
|
cyRef.current = cy;
|
|
5331
4999
|
const keep = keepSelRef.current;
|
|
5332
|
-
keepSelRef.current =
|
|
5333
|
-
if (keep
|
|
5334
|
-
else
|
|
5000
|
+
keepSelRef.current = void 0;
|
|
5001
|
+
if (keep) syncSelection(cy, keep);
|
|
5002
|
+
else setTrail([]);
|
|
5335
5003
|
setLiveCy(cy);
|
|
5336
5004
|
onReady?.(cy);
|
|
5337
5005
|
markBusy(true);
|
|
@@ -5354,10 +5022,7 @@ ${lt}`;
|
|
|
5354
5022
|
clearTimeout(breathTimerRef.current);
|
|
5355
5023
|
breathTimerRef.current = null;
|
|
5356
5024
|
}
|
|
5357
|
-
|
|
5358
|
-
clearTimeout(hoverOutRef.current);
|
|
5359
|
-
hoverOutRef.current = null;
|
|
5360
|
-
}
|
|
5025
|
+
cancelHoverTimer();
|
|
5361
5026
|
if (planeTweenRef.current != null) {
|
|
5362
5027
|
cancelAnimationFrame(planeTweenRef.current);
|
|
5363
5028
|
planeTweenRef.current = null;
|
|
@@ -5369,6 +5034,7 @@ ${lt}`;
|
|
|
5369
5034
|
detach?.();
|
|
5370
5035
|
cy?.destroy();
|
|
5371
5036
|
cyRef.current = null;
|
|
5037
|
+
spotlightLayer(null);
|
|
5372
5038
|
};
|
|
5373
5039
|
}, [built, profile, !!diff]);
|
|
5374
5040
|
useEffect4(() => {
|
|
@@ -5389,15 +5055,15 @@ ${lt}`;
|
|
|
5389
5055
|
minZoom: 0.02,
|
|
5390
5056
|
maxZoom: 4
|
|
5391
5057
|
});
|
|
5392
|
-
seatFromLastFrame(m, dispRef.current, (
|
|
5058
|
+
seatFromLastFrame(m, dispRef.current, (q) => pastBuilt.parentOf.get(q));
|
|
5393
5059
|
mirrorRef.current = m;
|
|
5060
|
+
syncSelection(m, targetRef.current);
|
|
5394
5061
|
m.$id(VIRTUAL_ROOT).unselectify();
|
|
5395
5062
|
detach = installGraphInput(m, mirrorElRef.current, {
|
|
5396
5063
|
interact: touchInteraction,
|
|
5397
5064
|
cancelFly,
|
|
5398
|
-
|
|
5399
|
-
|
|
5400
|
-
preview: (target) => previewTouch(m, target)
|
|
5065
|
+
select: selectEle,
|
|
5066
|
+
preview: (target2) => highlight(m, target2, true)
|
|
5401
5067
|
});
|
|
5402
5068
|
m.on("viewport", () => {
|
|
5403
5069
|
const cy2 = cyRef.current;
|
|
@@ -5439,7 +5105,7 @@ ${lt}`;
|
|
|
5439
5105
|
if (!busyRef.current) playPlanes(cy);
|
|
5440
5106
|
return;
|
|
5441
5107
|
}
|
|
5442
|
-
const sight =
|
|
5108
|
+
const sight = planeKey(view);
|
|
5443
5109
|
applyView({ fit: sight !== sightRef.current });
|
|
5444
5110
|
sightRef.current = sight;
|
|
5445
5111
|
if (cy && !cy.destroyed()) scheduleReadability(cy);
|
|
@@ -5530,32 +5196,31 @@ ${lt}`;
|
|
|
5530
5196
|
const query = view.query?.trim() ?? "";
|
|
5531
5197
|
const search = useMemo5(() => {
|
|
5532
5198
|
if (!query) return null;
|
|
5533
|
-
const idx = indexModel(
|
|
5534
|
-
const
|
|
5535
|
-
const hits = [...resolved.hits].filter((id) => !left.has(id));
|
|
5199
|
+
const idx = indexModel(model);
|
|
5200
|
+
const hits = [...resolved.hits].filter((id) => model.index.has(id));
|
|
5536
5201
|
const results = hits.slice(0, SEARCH_LIST).map((id) => {
|
|
5537
|
-
const n =
|
|
5538
|
-
const path = idx.ancestorsOf(id).slice(0, 2).reverse().map((a) =>
|
|
5202
|
+
const n = model.index.get(id);
|
|
5203
|
+
const path = idx.ancestorsOf(id).slice(0, 2).reverse().map((a) => model.index.get(a)?.label).filter((x) => !!x);
|
|
5539
5204
|
return { id, label: n.label, path, kind: n.kind ? profile.kindLabels[n.kind] ?? n.kind : void 0 };
|
|
5540
5205
|
});
|
|
5541
5206
|
const elsewhere = [];
|
|
5542
5207
|
if (layersHere.length > 1 && view.layers) {
|
|
5543
5208
|
const here = new Set(view.layers ?? []);
|
|
5544
5209
|
const count = /* @__PURE__ */ new Map();
|
|
5545
|
-
for (const id of searchNodes(
|
|
5546
|
-
|
|
5547
|
-
const l = renderModel.index.get(id)?.layer ?? profile.layers[0].id;
|
|
5210
|
+
for (const id of searchNodes(model, query)) {
|
|
5211
|
+
const l = model.index.get(id)?.layer ?? profile.layers[0].id;
|
|
5548
5212
|
if (!here.has(l)) count.set(l, (count.get(l) ?? 0) + 1);
|
|
5549
5213
|
}
|
|
5550
5214
|
for (const l of layersHere) if (count.get(l.id)) elsewhere.push({ layer: l.id, label: l.label, count: count.get(l.id) });
|
|
5551
5215
|
}
|
|
5552
5216
|
return { results, total: hits.length, elsewhere };
|
|
5553
|
-
}, [query, resolved,
|
|
5554
|
-
const colorOf = useCallback2((id) => {
|
|
5555
|
-
const cy
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5217
|
+
}, [query, resolved, model, profile, layersHere, view.planes, view.layers]);
|
|
5218
|
+
const colorOf = useCallback2((id, past = false) => {
|
|
5219
|
+
for (const cy of past ? [mirrorRef.current, cyRef.current] : [cyRef.current, mirrorRef.current]) {
|
|
5220
|
+
if (!cy || cy.destroyed()) continue;
|
|
5221
|
+
const n = cy.$id(id);
|
|
5222
|
+
if (n.nonempty()) return n.style("background-color");
|
|
5223
|
+
}
|
|
5559
5224
|
}, []);
|
|
5560
5225
|
const preview = useCallback2((id) => {
|
|
5561
5226
|
const cy = cyRef.current;
|
|
@@ -5564,79 +5229,59 @@ ${lt}`;
|
|
|
5564
5229
|
applyHover(cy, n && n.nonempty() ? n : null);
|
|
5565
5230
|
if (id) flyTo(id);
|
|
5566
5231
|
}, [applyHover, flyTo]);
|
|
5567
|
-
const hoverLayer = useCallback2((layer) => {
|
|
5568
|
-
hotLayerRef.current = layer;
|
|
5569
|
-
setHotLayer(layer);
|
|
5570
|
-
const cy = cyRef.current;
|
|
5571
|
-
if (!cy || cy.destroyed() || diffRef.current) return;
|
|
5572
|
-
respot();
|
|
5573
|
-
if (readableRef.current && !labelsFrozen()) replanLabels(cy);
|
|
5574
|
-
}, [respot, labelsFrozen, replanLabels]);
|
|
5575
5232
|
const pick = useCallback2((id) => {
|
|
5576
5233
|
const cy = cyRef.current;
|
|
5577
5234
|
if (!cy || cy.destroyed()) return;
|
|
5578
5235
|
const n = cy.$id(id);
|
|
5579
5236
|
if (n.empty()) return;
|
|
5580
5237
|
applyHover(cy, null);
|
|
5581
|
-
cy.$(":selected").unselect();
|
|
5582
|
-
n.select();
|
|
5583
5238
|
selectEle(n);
|
|
5584
5239
|
flyTo(id);
|
|
5585
5240
|
setView({ query: "" });
|
|
5586
5241
|
}, [applyHover, flyTo, selectEle, setView]);
|
|
5587
5242
|
pickRef.current = pick;
|
|
5588
|
-
const
|
|
5589
|
-
|
|
5590
|
-
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
|
|
5595
|
-
|
|
5596
|
-
if (!pendingIssue || !model.index.has(pendingIssue)) return;
|
|
5597
|
-
const frame = requestAnimationFrame(() => {
|
|
5598
|
-
pickRef.current(pendingIssue);
|
|
5599
|
-
setPendingIssue(null);
|
|
5600
|
-
});
|
|
5601
|
-
return () => cancelAnimationFrame(frame);
|
|
5602
|
-
}, [model, pendingIssue]);
|
|
5243
|
+
const navigate = useCallback2((next, back = false) => {
|
|
5244
|
+
if (scope.active && !hasTarget(next.past && diffSides ? diffSides.before : scope.local, next)) {
|
|
5245
|
+
scope.leaveFor(next);
|
|
5246
|
+
return;
|
|
5247
|
+
}
|
|
5248
|
+
setTrail((path) => back ? path.slice(0, -1) : [...path, next]);
|
|
5249
|
+
if ("node" in next) flyTo(next.node, false, true);
|
|
5250
|
+
}, [flyTo, scope, diffSides]);
|
|
5603
5251
|
useEffect4(() => {
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
const n = s && model.index.get(s.id);
|
|
5607
|
-
if (!s || !n) return null;
|
|
5608
|
-
return {
|
|
5609
|
-
...s,
|
|
5610
|
-
parent: n.parent,
|
|
5611
|
-
order: n.order,
|
|
5612
|
-
label: n.label,
|
|
5613
|
-
kind: n.kind ?? "",
|
|
5614
|
-
layer: n.layer,
|
|
5615
|
-
detail: n.data ?? null,
|
|
5616
|
-
flags: n.flags ?? [],
|
|
5617
|
-
container: model.nodes.some((x) => x.parent === n.id)
|
|
5618
|
-
};
|
|
5619
|
-
});
|
|
5620
|
-
setEditing((e) => e?.what === "node" && e.id && !model.index.has(e.id) ? null : e);
|
|
5621
|
-
}, [model]);
|
|
5252
|
+
setEditing((e) => e?.what === "node" && e.id && !editingModel.index.has(e.id) ? null : e);
|
|
5253
|
+
}, [editingModel]);
|
|
5622
5254
|
useEffect4(() => {
|
|
5623
5255
|
if (!editable) setEditing(null);
|
|
5624
5256
|
}, [editable]);
|
|
5625
5257
|
const submitEdit = useCallback2((input) => {
|
|
5626
|
-
const only =
|
|
5627
|
-
const op = input.op === "addNode" && only && !input.origin ? { ...input, origin: only } : input;
|
|
5258
|
+
const only = scope.origins?.length === 1 ? scope.origins[0] : void 0;
|
|
5259
|
+
const op = (input.op === "addNode" || input.op === "addEdge") && only && !input.origin ? { ...input, origin: only } : input;
|
|
5628
5260
|
const err = checkEdit(editingModel, op) ?? props.validateEdit?.(op);
|
|
5629
5261
|
if (err) return err;
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
|
|
5262
|
+
let path = trail;
|
|
5263
|
+
if (op.op === "addNode" && !(editing?.what === "node" && editing.id)) {
|
|
5264
|
+
pendingPickRef.current = op.id;
|
|
5265
|
+
path = [];
|
|
5266
|
+
} else if (op.op === "removeNode") {
|
|
5267
|
+
path = [];
|
|
5268
|
+
} else if (op.op === "updateEdge" || op.op === "removeEdge") {
|
|
5269
|
+
path = trail.flatMap((item) => {
|
|
5270
|
+
if (!("edge" in item) || !sameEdge(item.edge, op.edge)) return [item];
|
|
5271
|
+
if (op.op === "removeEdge") return [];
|
|
5272
|
+
const { source, target: target2, kind } = { ...op.edge, ...op.set };
|
|
5273
|
+
return [{ ...item, edge: { source, target: target2, kind } }];
|
|
5274
|
+
});
|
|
5275
|
+
}
|
|
5276
|
+
keepSelRef.current = path.at(-1);
|
|
5277
|
+
if (path !== trail) setTrail(path);
|
|
5633
5278
|
onEditRef.current?.(op);
|
|
5634
5279
|
return null;
|
|
5635
|
-
}, [editingModel,
|
|
5280
|
+
}, [editing, editingModel, trail, scope.origins, props.validateEdit]);
|
|
5636
5281
|
const startAdd = useCallback2((what) => {
|
|
5637
|
-
setEditing(what === "node" ? { what, parent: selected?.id ?? null } : { what, source: selected?.id });
|
|
5638
|
-
}, [selected]);
|
|
5639
|
-
const editPanel = editing && /* @__PURE__ */
|
|
5282
|
+
setEditing(what === "node" ? { what, parent: selected?.id ?? scope.subtree ?? null } : { what, source: selected?.id });
|
|
5283
|
+
}, [selected, scope.subtree]);
|
|
5284
|
+
const editPanel = editing && /* @__PURE__ */ jsx5(
|
|
5640
5285
|
EditPanel,
|
|
5641
5286
|
{
|
|
5642
5287
|
target: editing,
|
|
@@ -5645,9 +5290,56 @@ ${lt}`;
|
|
|
5645
5290
|
renderEditor,
|
|
5646
5291
|
colorOf,
|
|
5647
5292
|
onCancel: () => setEditing(null),
|
|
5648
|
-
|
|
5293
|
+
kindLabels: profile.kindLabels
|
|
5649
5294
|
}
|
|
5650
5295
|
);
|
|
5296
|
+
const details = useMemo5(() => detailPanel && (currentSubject || oldSubject) ? /* @__PURE__ */ jsx5(
|
|
5297
|
+
ObjectDetails,
|
|
5298
|
+
{
|
|
5299
|
+
before: oldSubject,
|
|
5300
|
+
after: currentSubject,
|
|
5301
|
+
delta: diff,
|
|
5302
|
+
nodeClass: profile.nodeClass,
|
|
5303
|
+
spec: profile.detail,
|
|
5304
|
+
kindLabels: profile.kindLabels,
|
|
5305
|
+
onClose: () => setTrail([]),
|
|
5306
|
+
onBack: trail.length > 1 ? () => navigate(trail[trail.length - 2], true) : void 0,
|
|
5307
|
+
scope: compact ? void 0 : scope,
|
|
5308
|
+
membership: scope.active && target && "node" in target && diff ? !currentSubject && scope.after.index.has(target.node) ? strings.leftScope : !oldSubject && fullPast?.index.has(target.node) ? strings.enteredScope : void 0 : void 0,
|
|
5309
|
+
onPick: navigate,
|
|
5310
|
+
renderText,
|
|
5311
|
+
colorOf,
|
|
5312
|
+
onEdit: editable && currentSubject && target ? () => setEditing("node" in target ? { what: "node", id: target.node } : { what: "edge", edge: target.edge }) : void 0,
|
|
5313
|
+
markdownFor: (side) => ({
|
|
5314
|
+
resolveUrl: resolveUrl && side.originalNode ? (u) => resolveUrl(u, side.originalNode) : void 0,
|
|
5315
|
+
onNodeLink: (id) => {
|
|
5316
|
+
const node = side === oldSubject ? diff?.resolved.get(id) ?? id : id;
|
|
5317
|
+
if (side.model.index.has(node)) navigate({ node, past: side === oldSubject });
|
|
5318
|
+
}
|
|
5319
|
+
})
|
|
5320
|
+
},
|
|
5321
|
+
target && ("node" in target ? "node:" + target.node : "edge:" + edgeKey(target.edge))
|
|
5322
|
+
) : null, [
|
|
5323
|
+
detailPanel,
|
|
5324
|
+
currentSubject,
|
|
5325
|
+
oldSubject,
|
|
5326
|
+
target,
|
|
5327
|
+
diff,
|
|
5328
|
+
profile,
|
|
5329
|
+
trail,
|
|
5330
|
+
navigate,
|
|
5331
|
+
renderText,
|
|
5332
|
+
colorOf,
|
|
5333
|
+
editable,
|
|
5334
|
+
resolveUrl,
|
|
5335
|
+
lookProfile,
|
|
5336
|
+
theme,
|
|
5337
|
+
liveCy,
|
|
5338
|
+
compact,
|
|
5339
|
+
scope,
|
|
5340
|
+
strings,
|
|
5341
|
+
fullPast
|
|
5342
|
+
]);
|
|
5651
5343
|
useEffect4(() => {
|
|
5652
5344
|
if (compact) return;
|
|
5653
5345
|
const onKey = (e) => {
|
|
@@ -5673,11 +5365,11 @@ ${lt}`;
|
|
|
5673
5365
|
window.addEventListener("keydown", onKey);
|
|
5674
5366
|
return () => window.removeEventListener("keydown", onKey);
|
|
5675
5367
|
}, [compact, zoomBy, fit]);
|
|
5676
|
-
if (model.nodes.length === 0 && model.errors.length === 0) {
|
|
5677
|
-
return /* @__PURE__ */
|
|
5678
|
-
/* @__PURE__ */
|
|
5679
|
-
/* @__PURE__ */
|
|
5680
|
-
editable && !editing && /* @__PURE__ */
|
|
5368
|
+
if (!scope.active && model.nodes.length === 0 && model.errors.length === 0) {
|
|
5369
|
+
return /* @__PURE__ */ jsx5(StringsContext.Provider, { value: strings, children: /* @__PURE__ */ jsxs5(ZoomBoundary, { className: `gb-root ${className ?? ""}`, style: rootStyle, children: [
|
|
5370
|
+
/* @__PURE__ */ jsxs5("div", { className: "gb-empty", children: [
|
|
5371
|
+
/* @__PURE__ */ jsx5("div", { children: emptyMessage ?? strings.empty }),
|
|
5372
|
+
editable && !editing && /* @__PURE__ */ jsx5("button", { className: "gb-link", onClick: () => startAdd("node"), children: strings.addNode })
|
|
5681
5373
|
] }),
|
|
5682
5374
|
editPanel
|
|
5683
5375
|
] }) });
|
|
@@ -5685,16 +5377,32 @@ ${lt}`;
|
|
|
5685
5377
|
const filtering = isFiltering(view);
|
|
5686
5378
|
const panes = !!diff;
|
|
5687
5379
|
const platesOn = !panes && plates.length > 0 && plateAlpha > 0.01;
|
|
5688
|
-
return /* @__PURE__ */
|
|
5689
|
-
/* @__PURE__ */
|
|
5690
|
-
/* @__PURE__ */
|
|
5691
|
-
platesOn && /* @__PURE__ */
|
|
5380
|
+
return /* @__PURE__ */ jsx5(StringsContext.Provider, { value: strings, children: /* @__PURE__ */ jsx5(EdgeMarks.Provider, { value: edgeMarks, children: /* @__PURE__ */ jsxs5(ZoomBoundary, { className: `gb-root ${className ?? ""}`, style: rootStyle, children: [
|
|
5381
|
+
/* @__PURE__ */ jsxs5("div", { className: "gb-stage", ref: stageRef, style: { background: theme.canvas }, children: [
|
|
5382
|
+
/* @__PURE__ */ jsxs5("div", { className: "gb-scene", children: [
|
|
5383
|
+
platesOn && /* @__PURE__ */ jsx5("svg", { className: "gb-planes", style: { opacity: plateAlpha }, children: /* @__PURE__ */ jsx5("g", { transform: `translate(${viewport.pan.x},${viewport.pan.y}) scale(${viewport.zoom})`, children: plates.map((p) => {
|
|
5384
|
+
const c = plateColors(theme, p.color);
|
|
5385
|
+
return /* @__PURE__ */ jsx5("g", { opacity: p.alpha, children: /* @__PURE__ */ jsx5(
|
|
5386
|
+
"polygon",
|
|
5387
|
+
{
|
|
5388
|
+
"data-gb-layer": p.layer,
|
|
5389
|
+
pointerEvents: "visiblePainted",
|
|
5390
|
+
opacity: hotLayer && hotLayer !== p.layer ? 0.45 : 1,
|
|
5391
|
+
points: p.points.map(([x, y]) => `${x},${y}`).join(" "),
|
|
5392
|
+
fill: p.color,
|
|
5393
|
+
fillOpacity: hotLayer === p.layer ? 0.16 : 0.07,
|
|
5394
|
+
stroke: c.stroke,
|
|
5395
|
+
strokeWidth: hotLayer === p.layer ? 3 : 2,
|
|
5396
|
+
vectorEffect: "non-scaling-stroke"
|
|
5397
|
+
}
|
|
5398
|
+
) }, p.layer);
|
|
5399
|
+
}) }) }),
|
|
5692
5400
|
panes ? (
|
|
5693
5401
|
/* Left = before, right = now, sharing one set of coordinates and one viewport: "unchanged things are the same
|
|
5694
5402
|
screen pixel in both columns" is the whole value of two columns. */
|
|
5695
|
-
/* @__PURE__ */
|
|
5696
|
-
/* @__PURE__ */
|
|
5697
|
-
!prog && /* @__PURE__ */
|
|
5403
|
+
/* @__PURE__ */ jsxs5("div", { className: "gb-panes", children: [
|
|
5404
|
+
/* @__PURE__ */ jsxs5("div", { className: "gb-pane", children: [
|
|
5405
|
+
!prog && /* @__PURE__ */ jsx5(
|
|
5698
5406
|
DiffOverlay,
|
|
5699
5407
|
{
|
|
5700
5408
|
delta: diff,
|
|
@@ -5705,16 +5413,17 @@ ${lt}`;
|
|
|
5705
5413
|
visible: filtering ? resolved.visible : null
|
|
5706
5414
|
}
|
|
5707
5415
|
),
|
|
5708
|
-
/* @__PURE__ */
|
|
5709
|
-
/* @__PURE__ */
|
|
5710
|
-
/* @__PURE__ */
|
|
5416
|
+
/* @__PURE__ */ jsx5("div", { ref: mirrorElRef, className: "gb-canvas" }),
|
|
5417
|
+
/* @__PURE__ */ jsx5("canvas", { ref: mirrorCanvasRef, className: "gb-labels" }),
|
|
5418
|
+
scope.active && !diff.before.nodes.length && /* @__PURE__ */ jsx5("div", { role: "status", className: "gb-absent", children: scope.missing }),
|
|
5419
|
+
/* @__PURE__ */ jsxs5("div", { className: "gb-pane-tag gb-glass gb-raised gb-round", children: [
|
|
5711
5420
|
diff.labels.before,
|
|
5712
5421
|
" \xB7 ",
|
|
5713
5422
|
strings.past
|
|
5714
5423
|
] })
|
|
5715
5424
|
] }),
|
|
5716
|
-
/* @__PURE__ */
|
|
5717
|
-
!prog && /* @__PURE__ */
|
|
5425
|
+
/* @__PURE__ */ jsxs5("div", { className: "gb-pane", children: [
|
|
5426
|
+
!prog && /* @__PURE__ */ jsx5(
|
|
5718
5427
|
DiffOverlay,
|
|
5719
5428
|
{
|
|
5720
5429
|
delta: diff,
|
|
@@ -5725,21 +5434,24 @@ ${lt}`;
|
|
|
5725
5434
|
visible: filtering ? resolved.visible : null
|
|
5726
5435
|
}
|
|
5727
5436
|
),
|
|
5728
|
-
/* @__PURE__ */
|
|
5729
|
-
/* @__PURE__ */
|
|
5730
|
-
/* @__PURE__ */
|
|
5437
|
+
/* @__PURE__ */ jsx5("div", { ref: containerRef, className: "gb-canvas" }),
|
|
5438
|
+
/* @__PURE__ */ jsx5("canvas", { ref: labelCanvasRef, className: "gb-labels" }),
|
|
5439
|
+
scope.active && !diff.after.nodes.length && /* @__PURE__ */ jsx5("div", { role: "status", className: "gb-absent", children: scope.missing }),
|
|
5440
|
+
/* @__PURE__ */ jsxs5("div", { className: "gb-pane-tag gb-glass gb-raised gb-round gb-pane-now", children: [
|
|
5731
5441
|
diff.labels.after,
|
|
5732
5442
|
" \xB7 ",
|
|
5733
5443
|
strings.now
|
|
5734
5444
|
] })
|
|
5735
5445
|
] }),
|
|
5736
|
-
/* @__PURE__ */
|
|
5446
|
+
/* @__PURE__ */ jsx5("div", { className: "gb-flow", "aria-hidden": true, children: /* @__PURE__ */ jsx5("svg", { viewBox: "-32 -25 64 50", children: /* @__PURE__ */ jsx5("path", { d: "M-31.84,-12.16 H7.52 V-24.32 L31.84,0 L7.52,24.32 V12.16 H-31.84 Z", fill: theme.canvas }) }) })
|
|
5737
5447
|
] }, "panes")
|
|
5738
|
-
) : /* @__PURE__ */
|
|
5739
|
-
!panes && /* @__PURE__ */
|
|
5740
|
-
|
|
5448
|
+
) : /* @__PURE__ */ jsx5("div", { ref: containerRef, className: "gb-canvas" }, "solo"),
|
|
5449
|
+
!panes && scope.active && !model.nodes.length && /* @__PURE__ */ jsx5("div", { role: "status", className: "gb-absent", children: scope.missing }),
|
|
5450
|
+
!panes && /* @__PURE__ */ jsx5("canvas", { ref: labelCanvasRef, className: "gb-labels" }),
|
|
5451
|
+
platesOn && /* @__PURE__ */ jsx5("svg", { className: "gb-plane-labels", style: { opacity: plateAlpha }, children: /* @__PURE__ */ jsx5("g", { transform: `translate(${viewport.pan.x},${viewport.pan.y}) scale(${viewport.zoom})`, children: plates.map((p) => /* @__PURE__ */ jsx5(
|
|
5741
5452
|
"text",
|
|
5742
5453
|
{
|
|
5454
|
+
"data-gb-layer": p.layer,
|
|
5743
5455
|
opacity: p.alpha ?? 1,
|
|
5744
5456
|
x: p.anchor[0],
|
|
5745
5457
|
y: p.anchor[1],
|
|
@@ -5750,20 +5462,19 @@ ${lt}`;
|
|
|
5750
5462
|
strokeWidth: 4 / viewport.zoom,
|
|
5751
5463
|
paintOrder: "stroke",
|
|
5752
5464
|
style: { userSelect: "none", pointerEvents: "auto", cursor: "default" },
|
|
5753
|
-
onMouseEnter: () => hoverLayer(p.layer),
|
|
5754
|
-
onMouseLeave: () => hoverLayer(null),
|
|
5755
5465
|
children: p.label
|
|
5756
5466
|
},
|
|
5757
5467
|
p.layer
|
|
5758
5468
|
)) }) })
|
|
5759
5469
|
] }),
|
|
5760
|
-
!compact && /* @__PURE__ */
|
|
5470
|
+
!compact && /* @__PURE__ */ jsx5(
|
|
5761
5471
|
Toolbar,
|
|
5762
5472
|
{
|
|
5763
5473
|
view,
|
|
5764
5474
|
setView,
|
|
5765
5475
|
layers: layersHere,
|
|
5766
|
-
origins,
|
|
5476
|
+
origins: scope.files,
|
|
5477
|
+
scope,
|
|
5767
5478
|
stats,
|
|
5768
5479
|
busy: !!prog,
|
|
5769
5480
|
controls,
|
|
@@ -5772,7 +5483,7 @@ ${lt}`;
|
|
|
5772
5483
|
onPreview: preview,
|
|
5773
5484
|
onPick: pick,
|
|
5774
5485
|
inputRef: searchInputRef,
|
|
5775
|
-
onAdd: editable ? startAdd : void 0,
|
|
5486
|
+
onAdd: editable && (!scope.active || model.nodes.length > 0) ? startAdd : void 0,
|
|
5776
5487
|
onRelayout: controls.relayout && !diff ? relayout : void 0,
|
|
5777
5488
|
onRestructure: controls.relayout && !diff ? onRestructure : void 0,
|
|
5778
5489
|
restructureContent: controls.relayout && !diff ? restructureContent : void 0,
|
|
@@ -5780,19 +5491,19 @@ ${lt}`;
|
|
|
5780
5491
|
onForceLayers
|
|
5781
5492
|
}
|
|
5782
5493
|
),
|
|
5783
|
-
/* @__PURE__ */
|
|
5494
|
+
/* @__PURE__ */ jsxs5("div", { className: "gb-footer", children: [
|
|
5784
5495
|
(note || model.errors.length > 0 || legend && !compact) && /* Bottom left: the host's caption (if any) on top, the legend below. Top left is tools, bottom right is the camera. */
|
|
5785
|
-
/* @__PURE__ */
|
|
5786
|
-
(note && !(legend && !compact) || model.errors.length > 0) && /* @__PURE__ */
|
|
5496
|
+
/* @__PURE__ */ jsxs5("div", { className: "gb-bl", children: [
|
|
5497
|
+
(note && !(legend && !compact) || model.errors.length > 0) && /* @__PURE__ */ jsxs5("div", { className: "gb-note gb-glass gb-raised gb-round", children: [
|
|
5787
5498
|
!(legend && !compact) && note,
|
|
5788
5499
|
model.errors.length > 0 && // The names must appear on this line. Reporting only a number, "16 sources could not be parsed" sends people back to
|
|
5789
5500
|
// try the files one by one, while locating them only takes printing the origin. The full list is in title.
|
|
5790
|
-
/* @__PURE__ */
|
|
5501
|
+
/* @__PURE__ */ jsx5("span", { className: "gb-warn", title: model.errors.map((e) => `${e.origin}: ${e.message}`).join("\n"), children: strings.parseErrors(
|
|
5791
5502
|
model.errors.length,
|
|
5792
5503
|
model.errors.slice(0, 2).map((e) => e.origin).join(", ") + (model.errors.length > 2 ? ", \u2026" : "")
|
|
5793
5504
|
) })
|
|
5794
5505
|
] }),
|
|
5795
|
-
legend && !compact && /* @__PURE__ */
|
|
5506
|
+
legend && !compact && /* @__PURE__ */ jsx5(
|
|
5796
5507
|
Legend,
|
|
5797
5508
|
{
|
|
5798
5509
|
model,
|
|
@@ -5816,44 +5527,25 @@ ${lt}`;
|
|
|
5816
5527
|
}
|
|
5817
5528
|
)
|
|
5818
5529
|
] }),
|
|
5819
|
-
!compact && /* @__PURE__ */
|
|
5530
|
+
!compact && /* @__PURE__ */ jsx5(
|
|
5820
5531
|
ZoomDock,
|
|
5821
5532
|
{
|
|
5822
5533
|
zoom: controls.zoom,
|
|
5823
5534
|
onZoom: zoomBy,
|
|
5824
5535
|
onFit: fit,
|
|
5825
|
-
|
|
5826
|
-
|
|
5536
|
+
checks: showIssues ? checks : void 0,
|
|
5537
|
+
report: showIssues ? props.issueReport : void 0
|
|
5827
5538
|
}
|
|
5828
5539
|
)
|
|
5829
5540
|
] }),
|
|
5830
|
-
prog && /* @__PURE__ */
|
|
5831
|
-
/* @__PURE__ */
|
|
5541
|
+
prog && /* @__PURE__ */ jsx5("div", { className: "gb-mask", children: /* @__PURE__ */ jsxs5("div", { className: "gb-glass gb-raised gb-round gb-loading", children: [
|
|
5542
|
+
/* @__PURE__ */ jsx5("span", { className: "gb-spin" }),
|
|
5832
5543
|
prog.total > 0 ? strings.layingOut(prog.done, prog.total) : strings.preparing
|
|
5833
5544
|
] }) }),
|
|
5834
|
-
compact && /* @__PURE__ */
|
|
5545
|
+
compact && /* @__PURE__ */ jsx5("div", { style: { position: "absolute", bottom: 4, left: 8, fontSize: 10.5, opacity: 0.6, pointerEvents: "none" }, children: strings.stats(stats.nodes, stats.edges) })
|
|
5835
5546
|
] }),
|
|
5836
|
-
/* @__PURE__ */
|
|
5837
|
-
|
|
5838
|
-
{
|
|
5839
|
-
node: selected,
|
|
5840
|
-
spec: profile.detail,
|
|
5841
|
-
kindLabels: profile.kindLabels,
|
|
5842
|
-
onClose: () => setSelected(null),
|
|
5843
|
-
renderText,
|
|
5844
|
-
onEdit: editable ? () => setEditing({ what: "node", id: selected.id }) : void 0,
|
|
5845
|
-
color: colorOf(selected.id),
|
|
5846
|
-
markdown: {
|
|
5847
|
-
resolveUrl: resolveUrl ? (u) => {
|
|
5848
|
-
const n = model.index.get(selected.id);
|
|
5849
|
-
return n ? resolveUrl(u, n) : null;
|
|
5850
|
-
} : void 0,
|
|
5851
|
-
onNodeLink: pick
|
|
5852
|
-
}
|
|
5853
|
-
},
|
|
5854
|
-
selected.id
|
|
5855
|
-
) : null) })
|
|
5856
|
-
] }) });
|
|
5547
|
+
/* @__PURE__ */ jsx5(Drawer, { children: editPanel || details }, props.scopeKey)
|
|
5548
|
+
] }) }) });
|
|
5857
5549
|
}
|
|
5858
5550
|
|
|
5859
5551
|
export {
|
|
@@ -5861,32 +5553,6 @@ export {
|
|
|
5861
5553
|
clearLayoutCache,
|
|
5862
5554
|
DEFAULT_PLANES,
|
|
5863
5555
|
projectPlanes,
|
|
5864
|
-
MIN_DOT,
|
|
5865
|
-
MIN_LINE,
|
|
5866
|
-
HOLD_LEAF,
|
|
5867
|
-
NODE_SLACK,
|
|
5868
|
-
SKEL_FLOOR,
|
|
5869
|
-
SEM_W,
|
|
5870
|
-
SEM_INK,
|
|
5871
|
-
SEM_BOOST,
|
|
5872
|
-
FOCUS_INK,
|
|
5873
|
-
focusAlphaOf,
|
|
5874
|
-
DETAIL_LEAF,
|
|
5875
|
-
GAP,
|
|
5876
|
-
HOVER_DIM,
|
|
5877
|
-
dotOf,
|
|
5878
|
-
gapOf,
|
|
5879
|
-
skeletonLineOf,
|
|
5880
|
-
semanticAlphaOf,
|
|
5881
|
-
clippedLength,
|
|
5882
|
-
hazeOf,
|
|
5883
|
-
EDGE_REACH,
|
|
5884
|
-
reachOf,
|
|
5885
|
-
hittable,
|
|
5886
|
-
detailed,
|
|
5887
|
-
edgeKindHidden,
|
|
5888
|
-
shapeOf,
|
|
5889
|
-
arrowOf,
|
|
5890
5556
|
relaxOverlaps,
|
|
5891
5557
|
relaxNodes,
|
|
5892
5558
|
labelBox,
|
|
@@ -5895,6 +5561,7 @@ export {
|
|
|
5895
5561
|
placePanel,
|
|
5896
5562
|
ALL_CONTROLS,
|
|
5897
5563
|
touchGestures,
|
|
5564
|
+
frameTranslation,
|
|
5898
5565
|
applyLook,
|
|
5899
5566
|
DiffOverlay,
|
|
5900
5567
|
GraphCanvas
|