glassbrain 0.2.0-alpha.6 → 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-LMYD4QHC.js → chunk-3CNHFYHG.js} +1329 -1610
- 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-3SAL4526.js → chunk-NDUF3CBQ.js} +349 -989
- package/dist/cli/glassbrain.js +441 -230
- package/dist/cli/viewer.js +228 -194
- package/dist/core.d.ts +2 -0
- package/dist/core.js +54 -26
- package/dist/diff.d.ts +9 -1
- package/dist/edit.d.ts +10 -0
- package/dist/index.js +63 -35
- package/dist/internal.d.ts +1 -0
- package/dist/internal.js +103 -73
- package/dist/kinds.d.ts +23 -0
- package/dist/layers.d.ts +3 -1
- package/dist/lint-report.d.ts +70 -0
- package/dist/profile.d.ts +15 -3
- 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 +18 -5
- 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 -1
- 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 +24 -3
- 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/schema/profile.schema.json +2 -2
- package/dist/chunks/chunk-3P34XHQ2.js +0 -244
- package/dist/chunks/chunk-5DEN6HXJ.js +0 -99
- package/dist/chunks/chunk-M3MAM2VD.js +0 -67
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/tree.ts
|
|
2
2
|
var object = (x) => !!x && typeof x === "object" && !Array.isArray(x);
|
|
3
3
|
var ref = (x) => typeof x === "string" || typeof x === "number" ? String(x) : void 0;
|
|
4
|
-
var
|
|
4
|
+
var stableJson = (x) => JSON.stringify(x, function(_key, value) {
|
|
5
5
|
return object(value) ? Object.fromEntries(Object.keys(value).sort().map((k) => [k, value[k]])) : value;
|
|
6
6
|
});
|
|
7
7
|
function treeDeclarations(raw, origin) {
|
|
@@ -67,12 +67,12 @@ function composeTrees(input) {
|
|
|
67
67
|
if (!r.origins.includes(slice.origin)) r.origins.push(slice.origin);
|
|
68
68
|
for (const [field, value] of [...Object.entries(d.fields), ...d.children === void 0 ? [] : [["children", d.children]]]) {
|
|
69
69
|
const previous = field === "children" ? r.children : r.fields[field];
|
|
70
|
-
if (r.locations.has(field) &&
|
|
70
|
+
if (r.locations.has(field) && stableJson(previous) !== stableJson(value)) {
|
|
71
71
|
errors.push({
|
|
72
72
|
origin: slice.origin,
|
|
73
73
|
node: d.id,
|
|
74
74
|
code: field === "children" ? "children-conflict" : "field-conflict",
|
|
75
|
-
message: `"${d.id}".${field}: ${r.locations.get(field)} = ${
|
|
75
|
+
message: `"${d.id}".${field}: ${r.locations.get(field)} = ${stableJson(previous)} conflicts with ${d.path} = ${stableJson(value)}.`
|
|
76
76
|
});
|
|
77
77
|
} else if (!r.locations.has(field)) {
|
|
78
78
|
if (field === "children") r.children = value;
|
|
@@ -264,125 +264,10 @@ function indexModel(model) {
|
|
|
264
264
|
function originsOf(model) {
|
|
265
265
|
const seen = /* @__PURE__ */ new Set();
|
|
266
266
|
for (const n of model.nodes) for (const o of originsOfNode(n)) seen.add(o);
|
|
267
|
+
for (const e of model.edges) if (e.origin) seen.add(e.origin);
|
|
267
268
|
return [...seen].sort();
|
|
268
269
|
}
|
|
269
270
|
|
|
270
|
-
// src/profile.ts
|
|
271
|
-
function parsePhysical(origin, text) {
|
|
272
|
-
let raw;
|
|
273
|
-
try {
|
|
274
|
-
raw = JSON.parse(text);
|
|
275
|
-
} catch (e) {
|
|
276
|
-
return { origin, title: origin, nodes: [], edges: [], error: e instanceof Error ? e.message : String(e) };
|
|
277
|
-
}
|
|
278
|
-
if (!raw || typeof raw !== "object" || !("nodes" in raw) && !("edges" in raw)) return null;
|
|
279
|
-
const edges = (Array.isArray(raw.edges) ? raw.edges : []).filter((e) => e && typeof e === "object").map((e) => ({
|
|
280
|
-
source: String(e.source ?? e.from),
|
|
281
|
-
target: String(e.target ?? e.to),
|
|
282
|
-
kind: typeof e.kind === "string" ? e.kind : void 0,
|
|
283
|
-
label: typeof e.label === "string" ? e.label : void 0,
|
|
284
|
-
weight: typeof e.weight === "number" ? e.weight : void 0,
|
|
285
|
-
// The whole record, like nodes' `data`: fields the library does not know survive a round trip (convert, toPhysical).
|
|
286
|
-
data: e
|
|
287
|
-
}));
|
|
288
|
-
const parsed = treeDeclarations(raw.nodes, origin);
|
|
289
|
-
return { origin, title: String(raw.name ?? raw.title ?? origin), nodes: treeNodes(parsed.declarations), edges, ...parsed };
|
|
290
|
-
}
|
|
291
|
-
function toPhysical(model) {
|
|
292
|
-
return serializeTree(model);
|
|
293
|
-
}
|
|
294
|
-
function toBundle(model, profile = null) {
|
|
295
|
-
const palette = Object.assign(/* @__PURE__ */ Object.create(null), profile?.nodePalette ?? {});
|
|
296
|
-
const wheel = ["#6366f1", "#f59e0b", "#10b981", "#ef4444", "#8b5cf6", "#06b6d4", "#ec4899", "#84cc16"];
|
|
297
|
-
const kinds = [...new Set(model.nodes.map((n) => n.kind).filter((k) => !!k))];
|
|
298
|
-
for (const [i, kind] of kinds.entries()) if (!Object.hasOwn(palette, kind)) palette[kind] = wheel[i % wheel.length];
|
|
299
|
-
return { profile: { ...profile, nodePalette: palette }, ...toPhysical(model) };
|
|
300
|
-
}
|
|
301
|
-
var DEFAULT_LAYER = { id: "default", label: "Graph", z: 0, structural: true };
|
|
302
|
-
function validateStructure(model) {
|
|
303
|
-
const out = model.errors.map((e) => ({ kind: e.code ?? "schema", group: "Invalid graph", level: "error", nodeId: e.node, message: `${e.origin}: ${e.message}` }));
|
|
304
|
-
const seen = /* @__PURE__ */ new Set();
|
|
305
|
-
const dup = /* @__PURE__ */ new Set();
|
|
306
|
-
for (const n of model.nodes) {
|
|
307
|
-
if (seen.has(n.id)) dup.add(n.id);
|
|
308
|
-
else seen.add(n.id);
|
|
309
|
-
}
|
|
310
|
-
for (const id of model.duplicateIds ?? []) dup.add(id);
|
|
311
|
-
for (const id of dup) out.push({ kind: "duplicate", group: "Duplicate id", level: "warn", nodeId: id, message: `Duplicate node id: ${id} (defined more than once; the first one is kept)` });
|
|
312
|
-
const seenEdge = /* @__PURE__ */ new Set();
|
|
313
|
-
const dupEdge = /* @__PURE__ */ new Map();
|
|
314
|
-
for (const e of model.edges) {
|
|
315
|
-
const key = `${e.source}\0${e.target}\0${e.kind ?? ""}`;
|
|
316
|
-
if (seenEdge.has(key)) dupEdge.set(key, e);
|
|
317
|
-
else seenEdge.add(key);
|
|
318
|
-
}
|
|
319
|
-
for (const e of dupEdge.values()) {
|
|
320
|
-
out.push({
|
|
321
|
-
kind: "duplicate-edge",
|
|
322
|
-
group: "Duplicate edge",
|
|
323
|
-
level: "warn",
|
|
324
|
-
edge: { source: e.source, target: e.target },
|
|
325
|
-
message: `Duplicate edge: ${e.source} \u2192 ${e.target}${e.kind ? ` (${e.kind})` : ""} is defined more than once`
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
for (const e of model.edges) {
|
|
329
|
-
const miss = [!seen.has(e.source) && e.source, !seen.has(e.target) && e.target].filter(Boolean).join(" / ");
|
|
330
|
-
if (miss) out.push({ kind: "dangling", group: "Dangling edge", level: "warn", edge: { source: e.source, target: e.target }, message: `Dangling edge: points to missing node ${miss}` });
|
|
331
|
-
}
|
|
332
|
-
return out;
|
|
333
|
-
}
|
|
334
|
-
function defineProfile(input) {
|
|
335
|
-
const layers = input.layers?.length ? input.layers : [DEFAULT_LAYER];
|
|
336
|
-
const fallbackLayer = layers[0].id;
|
|
337
|
-
return {
|
|
338
|
-
id: input.id,
|
|
339
|
-
parse: input.parse ?? parsePhysical,
|
|
340
|
-
merge: input.merge ?? mergeSlices,
|
|
341
|
-
layers,
|
|
342
|
-
layerOf: input.layerOf ?? ((n) => n.layer ?? fallbackLayer),
|
|
343
|
-
nodePalette: input.nodePalette ?? {},
|
|
344
|
-
edgePalette: input.edgePalette ?? {},
|
|
345
|
-
nodeSize: input.nodeSize ?? {},
|
|
346
|
-
edgeWidth: input.edgeWidth ?? {},
|
|
347
|
-
placeholderFlags: input.placeholderFlags ?? [],
|
|
348
|
-
style: input.style ?? [],
|
|
349
|
-
nodeClass: input.nodeClass ?? (() => ""),
|
|
350
|
-
edgeClass: input.edgeClass ?? ((e) => e.kind ?? ""),
|
|
351
|
-
kindLabels: input.kindLabels ?? {},
|
|
352
|
-
detail: input.detail ?? {},
|
|
353
|
-
validate: input.validate ?? (() => []),
|
|
354
|
-
layoutEdge: input.layoutEdge ?? (() => false),
|
|
355
|
-
singleRoot: input.singleRoot ?? true,
|
|
356
|
-
rootLabel: input.rootLabel ?? "Overview"
|
|
357
|
-
};
|
|
358
|
-
}
|
|
359
|
-
var defaultProfile = defineProfile({ id: "default" });
|
|
360
|
-
function parseSources(sources, profile = defaultProfile) {
|
|
361
|
-
const slices = [];
|
|
362
|
-
for (const { origin, text } of sources) {
|
|
363
|
-
const s = profile.parse(origin, text);
|
|
364
|
-
if (!s) continue;
|
|
365
|
-
slices.push({
|
|
366
|
-
...s,
|
|
367
|
-
origin,
|
|
368
|
-
nodes: s.nodes.map((n) => ({
|
|
369
|
-
...n,
|
|
370
|
-
origin: n.origin ?? origin,
|
|
371
|
-
origins: n.origins ?? [origin],
|
|
372
|
-
layer: n.layer ?? profile.layerOf(n)
|
|
373
|
-
})),
|
|
374
|
-
edges: s.edges.map((e) => ({ ...e, origin: e.origin ?? origin }))
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
const model = profile.merge(slices);
|
|
378
|
-
const nodes = model.nodes.map((n) => n.layer ? n : { ...n, layer: profile.layerOf(n) });
|
|
379
|
-
const out = buildModel(nodes, model.edges, model.errors);
|
|
380
|
-
return model.duplicateIds ? { ...out, duplicateIds: model.duplicateIds } : out;
|
|
381
|
-
}
|
|
382
|
-
function validateModel(model, profile) {
|
|
383
|
-
return [...validateStructure(model), ...profile.validate(model)];
|
|
384
|
-
}
|
|
385
|
-
|
|
386
271
|
// src/diff.ts
|
|
387
272
|
var DIFF_FLAG = {
|
|
388
273
|
added: "gb-added",
|
|
@@ -392,7 +277,7 @@ var DIFF_FLAG = {
|
|
|
392
277
|
merged: "gb-merged"
|
|
393
278
|
};
|
|
394
279
|
var KEPT_FLAG = "gb-kept";
|
|
395
|
-
var
|
|
280
|
+
var stable = (v, ignore) => {
|
|
396
281
|
const walk = (x) => {
|
|
397
282
|
if (Array.isArray(x)) return x.map(walk);
|
|
398
283
|
if (x && typeof x === "object") {
|
|
@@ -410,7 +295,7 @@ function changedFields(a, b, ignore) {
|
|
|
410
295
|
const ob = b ?? {};
|
|
411
296
|
const keys = new Set([...Object.keys(oa), ...Object.keys(ob)].filter((k) => !ignore.has(k)));
|
|
412
297
|
const out = [];
|
|
413
|
-
for (const k of keys) if (
|
|
298
|
+
for (const k of keys) if (stable(oa[k], ignore) !== stable(ob[k], ignore)) out.push(k);
|
|
414
299
|
return out.sort();
|
|
415
300
|
}
|
|
416
301
|
var EDIT_CAP = 512;
|
|
@@ -445,10 +330,17 @@ function editDistance(a, b) {
|
|
|
445
330
|
return prev[m] + over;
|
|
446
331
|
}
|
|
447
332
|
function changeAmount(a, b, fields, ignore) {
|
|
448
|
-
const pick = (n) => fields.map((k) =>
|
|
333
|
+
const pick = (n) => fields.map((k) => stable((n.data ?? {})[k], ignore)).join("\0");
|
|
449
334
|
return editDistance(pick(a), pick(b)) + editDistance(a.label ?? "", b.label ?? "");
|
|
450
335
|
}
|
|
451
|
-
var edgeKey = (e) =>
|
|
336
|
+
var edgeKey = (e) => JSON.stringify([e.source, e.target, e.kind ?? ""]);
|
|
337
|
+
function edgeContent(edge) {
|
|
338
|
+
const { source, target, from, to, kind, ...data } = edge.data ?? {};
|
|
339
|
+
return { ...data, label: edge.label ?? data.label, weight: edge.weight ?? data.weight };
|
|
340
|
+
}
|
|
341
|
+
function edgeContentChanged(before, after, ignore) {
|
|
342
|
+
return stable(edgeContent(before), ignore) !== stable(edgeContent(after), ignore);
|
|
343
|
+
}
|
|
452
344
|
var withFlag = (x, flag) => ({ ...x, flags: [...x.flags ?? [], flag] });
|
|
453
345
|
function diffModels(before, after, opts = {}) {
|
|
454
346
|
const ignore = new Set(opts.ignore ?? []);
|
|
@@ -562,7 +454,9 @@ function diffModels(before, after, opts = {}) {
|
|
|
562
454
|
);
|
|
563
455
|
const edges = [];
|
|
564
456
|
for (const [k, e] of afterEdges) {
|
|
565
|
-
|
|
457
|
+
const previous = beforeEdges.get(k);
|
|
458
|
+
const flag = !previous ? DIFF_FLAG.added : edgeContentChanged(previous, e, ignore) ? DIFF_FLAG.changed : KEPT_FLAG;
|
|
459
|
+
edges.push(withFlag(e, flag));
|
|
566
460
|
}
|
|
567
461
|
for (const [k, e] of beforeEdges) {
|
|
568
462
|
if (afterEdges.has(k)) continue;
|
|
@@ -585,7 +479,9 @@ function diffModels(before, after, opts = {}) {
|
|
|
585
479
|
prevData,
|
|
586
480
|
labels,
|
|
587
481
|
before,
|
|
588
|
-
after
|
|
482
|
+
after,
|
|
483
|
+
ignore: opts.ignore,
|
|
484
|
+
options: opts
|
|
589
485
|
};
|
|
590
486
|
}
|
|
591
487
|
function unionSides(d) {
|
|
@@ -670,19 +566,27 @@ function stepUnion(before, after, key = (n) => n.id) {
|
|
|
670
566
|
after
|
|
671
567
|
};
|
|
672
568
|
}
|
|
569
|
+
function changedEdge(e) {
|
|
570
|
+
return !!e.flags?.some((f) => f === DIFF_FLAG.added || f === DIFF_FLAG.removed || f === DIFF_FLAG.changed);
|
|
571
|
+
}
|
|
673
572
|
function hasChanges(d) {
|
|
674
|
-
return d.changes.length > 0;
|
|
573
|
+
return d.changes.length > 0 || d.model.edges.some(changedEdge);
|
|
675
574
|
}
|
|
676
575
|
function changedSubset(d) {
|
|
677
576
|
const keep = /* @__PURE__ */ new Set();
|
|
678
|
-
|
|
679
|
-
keep.
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
while (p && !keep.has(p)) {
|
|
683
|
-
keep.add(p);
|
|
684
|
-
p = d.model.index.get(p)?.parent;
|
|
577
|
+
const include = (id) => {
|
|
578
|
+
while (id && !keep.has(id)) {
|
|
579
|
+
keep.add(id);
|
|
580
|
+
id = d.model.index.get(id)?.parent;
|
|
685
581
|
}
|
|
582
|
+
};
|
|
583
|
+
for (const c of d.changes) {
|
|
584
|
+
include(c.id);
|
|
585
|
+
include(c.pairId);
|
|
586
|
+
}
|
|
587
|
+
for (const edge of d.model.edges) if (changedEdge(edge)) {
|
|
588
|
+
include(edge.source);
|
|
589
|
+
include(edge.target);
|
|
686
590
|
}
|
|
687
591
|
return keep;
|
|
688
592
|
}
|
|
@@ -870,130 +774,6 @@ function countByKind(model) {
|
|
|
870
774
|
return out;
|
|
871
775
|
}
|
|
872
776
|
|
|
873
|
-
// src/view.ts
|
|
874
|
-
var FULL_VIEW = {};
|
|
875
|
-
function planeView(v, layers) {
|
|
876
|
-
if (layers.length < 2) return v.planes || v.layers ? { ...v, planes: false, layers: null } : v;
|
|
877
|
-
const stacked = v.planes !== false;
|
|
878
|
-
const picked = layers.map((l) => l.id).filter((id) => v.layers?.includes(id));
|
|
879
|
-
const want = stacked ? picked.length && picked.length < layers.length ? picked : null : v.layers && picked.length === 1 ? picked : null;
|
|
880
|
-
const same = v.planes === stacked && (want === null ? v.layers === null : !!v.layers && want.length === v.layers.length && want.every((id, i) => id === v.layers[i]));
|
|
881
|
-
return same ? v : { ...v, planes: stacked, layers: want };
|
|
882
|
-
}
|
|
883
|
-
function isFiltering(v) {
|
|
884
|
-
return !!(v.origins && v.origins.length || v.layers && v.layers.length);
|
|
885
|
-
}
|
|
886
|
-
function isNarrowing(v) {
|
|
887
|
-
return !!(v.origins && v.origins.length);
|
|
888
|
-
}
|
|
889
|
-
function originView(v, available) {
|
|
890
|
-
if (!v.origins?.length) return v;
|
|
891
|
-
const have = new Set(available);
|
|
892
|
-
const kept = v.origins.filter((o) => have.has(o));
|
|
893
|
-
if (kept.length === v.origins.length) return v;
|
|
894
|
-
return { ...v, origins: kept.length ? kept : null };
|
|
895
|
-
}
|
|
896
|
-
var textOf = (data) => {
|
|
897
|
-
if (typeof data === "string") return data;
|
|
898
|
-
if (Array.isArray(data)) return data.map(textOf).join(" ");
|
|
899
|
-
if (data && typeof data === "object") return Object.values(data).map(textOf).join(" ");
|
|
900
|
-
return "";
|
|
901
|
-
};
|
|
902
|
-
function resolveView(model, elements, view) {
|
|
903
|
-
const present = /* @__PURE__ */ new Set();
|
|
904
|
-
for (const el of elements) if (!el.data.source) present.add(el.data.id);
|
|
905
|
-
const hitsIn = (scope) => new Set(searchNodes(model, view.query ?? "", scope));
|
|
906
|
-
if (!isFiltering(view)) {
|
|
907
|
-
return { visible: present, hits: hitsIn(present) };
|
|
908
|
-
}
|
|
909
|
-
const idx = indexModel(model);
|
|
910
|
-
const layers = view.layers?.length ? new Set(view.layers) : null;
|
|
911
|
-
const origins = view.origins?.length ? new Set(view.origins) : null;
|
|
912
|
-
const base = /* @__PURE__ */ new Set();
|
|
913
|
-
for (const n of model.nodes) {
|
|
914
|
-
if (!present.has(n.id)) continue;
|
|
915
|
-
if (layers && !layers.has(n.layer ?? "")) continue;
|
|
916
|
-
if (origins && !originsOfNode(n).some((o) => origins.has(o))) continue;
|
|
917
|
-
base.add(n.id);
|
|
918
|
-
}
|
|
919
|
-
const visible = new Set(base);
|
|
920
|
-
for (const id of base) for (const a of idx.ancestorsOf(id)) if (present.has(a)) visible.add(a);
|
|
921
|
-
if (present.has(VIRTUAL_ROOT)) {
|
|
922
|
-
let isCompoundRoot = false;
|
|
923
|
-
let topVisible = 0;
|
|
924
|
-
for (const el of elements) {
|
|
925
|
-
if (el.data.source) {
|
|
926
|
-
if (el.data.kind === "contains" && el.data.source === VIRTUAL_ROOT && visible.has(el.data.target)) topVisible++;
|
|
927
|
-
} else if (el.data.parent === VIRTUAL_ROOT) {
|
|
928
|
-
isCompoundRoot = true;
|
|
929
|
-
if (visible.has(el.data.id)) topVisible++;
|
|
930
|
-
}
|
|
931
|
-
}
|
|
932
|
-
if (isCompoundRoot || topVisible > 1) visible.add(VIRTUAL_ROOT);
|
|
933
|
-
}
|
|
934
|
-
return { visible, hits: hitsIn(base) };
|
|
935
|
-
}
|
|
936
|
-
function parseQuery(query) {
|
|
937
|
-
const raw = query.trim();
|
|
938
|
-
const m = /^\/(.+)\/$/.exec(raw);
|
|
939
|
-
if (m) {
|
|
940
|
-
try {
|
|
941
|
-
return { re: new RegExp(m[1], "i"), phrase: "", words: [] };
|
|
942
|
-
} catch {
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
const phrase = raw.toLowerCase();
|
|
946
|
-
return { re: null, phrase, words: phrase ? [...new Set(phrase.split(/\s+/))] : [] };
|
|
947
|
-
}
|
|
948
|
-
function queryMarker(query) {
|
|
949
|
-
const { re, phrase, words } = parseQuery(query);
|
|
950
|
-
if (re) return new RegExp(re.source, "gi");
|
|
951
|
-
if (!phrase) return null;
|
|
952
|
-
const esc = (w) => w.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
953
|
-
const alts = [phrase, ...words.filter((w) => w !== phrase)].sort((a, b) => b.length - a.length);
|
|
954
|
-
return new RegExp(alts.map(esc).join("|"), "gi");
|
|
955
|
-
}
|
|
956
|
-
function searchNodes(model, query, scope) {
|
|
957
|
-
const { re, phrase: q, words } = parseQuery(query);
|
|
958
|
-
if (!re && !q) return [];
|
|
959
|
-
const ids = scope ? scope : model.nodes.map((n) => n.id);
|
|
960
|
-
const ranked = [];
|
|
961
|
-
let best = 0;
|
|
962
|
-
for (const id of ids) {
|
|
963
|
-
if (id === VIRTUAL_ROOT) continue;
|
|
964
|
-
const n = model.index.get(id);
|
|
965
|
-
if (!n) continue;
|
|
966
|
-
let tier = -1;
|
|
967
|
-
let k = 1;
|
|
968
|
-
if (re) {
|
|
969
|
-
const m = re.exec(n.label);
|
|
970
|
-
tier = m ? m.index > 0 ? 2 : m[0].length === n.label.length ? 0 : 1 : re.test(n.id) ? 3 : re.test(textOf(n.data)) ? 4 : -1;
|
|
971
|
-
} else {
|
|
972
|
-
const label = n.label.toLowerCase();
|
|
973
|
-
tier = label === q ? 0 : label.startsWith(q) ? 1 : label.includes(q) ? 2 : n.id.toLowerCase().includes(q) ? 3 : -1;
|
|
974
|
-
let text = null;
|
|
975
|
-
const rest = () => text ?? (text = `${n.id} ${textOf(n.data)}`.toLowerCase());
|
|
976
|
-
if (tier < 0 && rest().includes(q)) tier = 4;
|
|
977
|
-
if (tier >= 0) k = words.length;
|
|
978
|
-
else if (words.length > 1) {
|
|
979
|
-
let inLabel = 0;
|
|
980
|
-
k = 0;
|
|
981
|
-
for (const w of words) {
|
|
982
|
-
if (label.includes(w)) {
|
|
983
|
-
k++;
|
|
984
|
-
inLabel++;
|
|
985
|
-
} else if (rest().includes(w)) k++;
|
|
986
|
-
}
|
|
987
|
-
if (k) tier = inLabel === k ? 5 : 6;
|
|
988
|
-
}
|
|
989
|
-
}
|
|
990
|
-
if (tier < 0) continue;
|
|
991
|
-
if (k > best) best = k;
|
|
992
|
-
ranked.push([k, tier, n.label.length, id]);
|
|
993
|
-
}
|
|
994
|
-
return ranked.filter((r) => r[0] === best).sort((a, b) => a[1] - b[1] || a[2] - b[2] || (a[3] < b[3] ? -1 : a[3] > b[3] ? 1 : 0)).map((r) => r[3]);
|
|
995
|
-
}
|
|
996
|
-
|
|
997
777
|
// src/style.ts
|
|
998
778
|
var PLANE_HUES = ["#64748b", "#6366f1", "#14b8a6", "#ef4444"];
|
|
999
779
|
var plateColors = (theme, hue) => ({
|
|
@@ -1295,6 +1075,8 @@ function chromeStyle(theme) {
|
|
|
1295
1075
|
border: "#1e293b",
|
|
1296
1076
|
panel: `${theme.canvas}e6`,
|
|
1297
1077
|
panel2: theme.canvas,
|
|
1078
|
+
surface: `color-mix(in srgb, ${theme.canvas} 94%, white)`,
|
|
1079
|
+
rim: "rgba(226,232,240,.16)",
|
|
1298
1080
|
tint: "#1e293b",
|
|
1299
1081
|
active: "#1e3a5f",
|
|
1300
1082
|
accent: "#38bdf8",
|
|
@@ -1313,11 +1095,14 @@ function chromeStyle(theme) {
|
|
|
1313
1095
|
...Object.fromEntries(Object.entries(colors).map(([key, value]) => [`--gb-default-${key}`, dark ? value : "initial"]))
|
|
1314
1096
|
};
|
|
1315
1097
|
}
|
|
1098
|
+
var HOVER_FADE_MS = 160;
|
|
1316
1099
|
var GK_CSS = `
|
|
1317
|
-
|
|
1100
|
+
/* Apply at scroll containers too: browsers resolve touch-action at gesture start. */
|
|
1101
|
+
:where([data-gb-zoom-boundary], [data-gb-zoom-boundary] *) { touch-action:pan-x pan-y; }
|
|
1102
|
+
.gb-root { --gb-ease:cubic-bezier(.2,.8,.3,1); --gb-ease-out:cubic-bezier(.4,0,.6,1); display:flex; height:100%; min-height:0; font-family: var(--gb-font, ui-sans-serif, system-ui, sans-serif);
|
|
1318
1103
|
color: var(--gb-text, var(--gb-default-text,#1f2937)); position:relative; container-type:inline-size; container-name:gk; }
|
|
1319
1104
|
.gb-stage { flex:1; min-width:0; position:relative; container-type:inline-size; container-name:gks; }
|
|
1320
|
-
.gb-canvas { position:absolute; inset:0; }
|
|
1105
|
+
.gb-scene, .gb-canvas { position:absolute; inset:0; }
|
|
1321
1106
|
/* The node text layer: cytoscape's canvases are z-index 1\u20133; this one sits above them and below the toolbar.
|
|
1322
1107
|
canvas is a replaced element; inset alone is not enough, it needs an explicit 100%. */
|
|
1323
1108
|
.gb-labels { position:absolute; left:0; top:0; pointer-events:none; z-index:4; }
|
|
@@ -1332,8 +1117,7 @@ var GK_CSS = `
|
|
|
1332
1117
|
* the seam is the only place empty in both columns, and left-then-right reads as "before \u2192 now". */
|
|
1333
1118
|
.gb-pane-tag { position:absolute; bottom:12px; right:12px; z-index:6; pointer-events:none;
|
|
1334
1119
|
font-size:11px; font-weight:600; letter-spacing:.02em; color: var(--gb-muted,var(--gb-default-muted,#64748b));
|
|
1335
|
-
|
|
1336
|
-
border-radius:var(--gb-r-face,10px); padding:3px 8px; }
|
|
1120
|
+
padding:3px 8px; }
|
|
1337
1121
|
.gb-pane-now { color: var(--gb-text,var(--gb-default-text,#1f2937)); right:auto; left:12px; }
|
|
1338
1122
|
/* The direction of time. **Purely indicative**: takes no events, no width (absolutely positioned, centered on the seam). A big hollow
|
|
1339
1123
|
* block arrow stamped on the seam, not a round button: nothing about it should invite a click. Filled with the canvas color
|
|
@@ -1346,6 +1130,9 @@ var GK_CSS = `
|
|
|
1346
1130
|
.gb-pane .gb-diff-trunc { top:auto; left:auto; bottom:44px; right:12px; }
|
|
1347
1131
|
.gb-planes, .gb-plane-labels { position:absolute; inset:0; width:100%; height:100%;
|
|
1348
1132
|
pointer-events:none; overflow:hidden; }
|
|
1133
|
+
/* The B\xE9zier has linear x and smoothstep y, matching the canvas painter. */
|
|
1134
|
+
.gb-planes polygon { transition-property:fill-opacity,stroke-width,opacity;
|
|
1135
|
+
transition-duration:${HOVER_FADE_MS}ms; transition-timing-function:cubic-bezier(.333333,0,.666667,1); }
|
|
1349
1136
|
/* svg is a replaced element: inset:0 alone falls back to its intrinsic 300x150, so it needs an explicit 100%. */
|
|
1350
1137
|
/* Plates are drawn **under** the graph (cytoscape's canvases are z-index 1\u20133); layer names **above**,
|
|
1351
1138
|
or nodes at the same spot would cover them. */
|
|
@@ -1360,23 +1147,24 @@ var GK_CSS = `
|
|
|
1360
1147
|
.gb-bar.has-layers { flex-wrap:nowrap; }
|
|
1361
1148
|
.gb-bar > * { pointer-events:auto; }
|
|
1362
1149
|
.gb-ico { display:block; flex:none; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
|
|
1363
|
-
/*
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
.gb-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
-
|
|
1150
|
+
/* Material, elevation and rounding compose independently. Only the outer face blurs. */
|
|
1151
|
+
.gb-glass { background:color-mix(in srgb, var(--gb-surface-fill,var(--gb-panel,var(--gb-default-panel,rgba(255,255,255,.86)))),
|
|
1152
|
+
transparent var(--gb-glass-transparency,25%));
|
|
1153
|
+
border:1px solid var(--gb-border,var(--gb-default-rim,#e2e8f0));
|
|
1154
|
+
-webkit-backdrop-filter:blur(var(--gb-blur,10px)); backdrop-filter:blur(var(--gb-blur,10px)); }
|
|
1155
|
+
.gb-raised { box-shadow:var(--gb-shadow,0 1px 2px rgba(15,23,42,.05), 0 6px 18px -6px rgba(15,23,42,.12)); }
|
|
1156
|
+
.gb-round { border-radius:var(--gb-radius,var(--gb-r-face,10px)); }
|
|
1157
|
+
.gb-drop,.gb-panel,.gb-lg-pop,.gb-pick-list,.gb-loading,.gb-drawer {
|
|
1158
|
+
--gb-surface-fill:color-mix(in srgb,var(--gb-panel2,var(--gb-default-surface,#fff)) 93%,transparent);
|
|
1159
|
+
--gb-radius:var(--gb-r-pop,12px);
|
|
1160
|
+
--gb-shadow:0 2px 6px rgba(0,0,0,.08),0 18px 40px -12px rgba(0,0,0,.24); }
|
|
1372
1161
|
.gb-bar button, .gb-dock button { font-family:inherit; cursor:pointer; }
|
|
1373
1162
|
.gb-bar button:focus-visible, .gb-dock button:focus-visible { outline:2px solid var(--gb-accent,var(--gb-default-accent,#0284c7)); outline-offset:1px; }
|
|
1374
1163
|
|
|
1375
|
-
/*
|
|
1376
|
-
|
|
1377
|
-
.gb-search { position:relative; width:260px; flex:0 1 260px; min-width:180px; max-width:100%; transition: width .22s cubic-bezier(.3,.7,.2,1); }
|
|
1164
|
+
/* Keep the search width stable on focus. */
|
|
1165
|
+
.gb-search { position:relative; width:260px; flex:0 1 260px; min-width:180px; max-width:100%; transition: width .22s var(--gb-ease); }
|
|
1378
1166
|
.gb-field { display:flex; align-items:center; gap:7px; height:36px; padding:0 8px 0 11px;
|
|
1379
|
-
color: var(--gb-muted,var(--gb-default-muted,#64748b)); transition: border-color .15s, box-shadow .15s; }
|
|
1167
|
+
color: var(--gb-muted,var(--gb-default-muted,#64748b)); transition: border-color .15s var(--gb-ease), box-shadow .15s var(--gb-ease); }
|
|
1380
1168
|
.gb-search.is-focus .gb-field { border-color: var(--gb-accent,var(--gb-default-accent,#0284c7));
|
|
1381
1169
|
box-shadow: 0 0 0 3px color-mix(in srgb, var(--gb-accent,var(--gb-default-accent,#0284c7)) 16%, transparent), 0 6px 18px -6px rgba(15,23,42,.14); }
|
|
1382
1170
|
.gb-field input { flex:1; min-width:0; height:100%; border:0; background:transparent; outline:none; padding:0;
|
|
@@ -1396,20 +1184,18 @@ var GK_CSS = `
|
|
|
1396
1184
|
.gb-token button:hover { background: rgba(127,127,127,.18); color: var(--gb-text,var(--gb-default-text,#1f2937)); }
|
|
1397
1185
|
|
|
1398
1186
|
.gb-drop, .gb-panel { position:absolute; top:calc(100% + 6px); left:0; z-index:12;
|
|
1399
|
-
|
|
1400
|
-
box-shadow: 0 2px 6px rgba(15,23,42,.06), 0 18px 40px -12px rgba(15,23,42,.24);
|
|
1401
|
-
padding:6px; transform-origin: top left; animation: gb-pop .14s cubic-bezier(.2,.8,.3,1); }
|
|
1187
|
+
padding:6px; transform-origin: top left; animation: gb-pop .14s var(--gb-ease); }
|
|
1402
1188
|
.gb-drop { width:max(100%, 360px); max-width:calc(100vw - 24px); }
|
|
1403
1189
|
.gb-drop ul { list-style:none; margin:0; padding:0; }
|
|
1404
1190
|
.gb-drop li { display:flex; align-items:center; gap:10px; padding:7px 9px; border-radius:var(--gb-r-in-pop,6px); cursor:pointer; }
|
|
1405
1191
|
.gb-drop li.on { background: var(--gb-tint,var(--gb-default-tint,#f1f5f9)); }
|
|
1406
1192
|
.gb-dot { width:9px; height:9px; border-radius:50%; flex:none; background: var(--gb-muted2,var(--gb-default-muted2,#94a3b8));
|
|
1407
1193
|
box-shadow: 0 0 0 2px var(--gb-panel2,var(--gb-default-panel2,#fff)), 0 0 0 3px var(--gb-border,var(--gb-default-border,#e2e8f0)); }
|
|
1408
|
-
.gb-
|
|
1409
|
-
.gb-
|
|
1410
|
-
.gb-
|
|
1194
|
+
.gb-drop .gb-ref { flex:1; gap:10px; }
|
|
1195
|
+
.gb-drop .gb-ref-main { gap:1px; }
|
|
1196
|
+
.gb-drop .gb-ref-label { font-size:13px; }
|
|
1197
|
+
.gb-drop mark { background:none; color:inherit; font-weight:650;
|
|
1411
1198
|
text-decoration: underline 2px color-mix(in srgb, var(--gb-accent,var(--gb-default-accent,#0284c7)) 45%, transparent); text-underline-offset:3px; }
|
|
1412
|
-
.gb-r-path { font-size:11px; color: var(--gb-muted2,var(--gb-default-muted2,#94a3b8)); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
|
|
1413
1199
|
.gb-r-kind { flex:none; font-size:10.5px; color: var(--gb-muted,var(--gb-default-muted,#64748b)); border:1px solid var(--gb-border,var(--gb-default-border,#e2e8f0));
|
|
1414
1200
|
border-radius:var(--gb-r-chip,5px); padding:1px 6px; }
|
|
1415
1201
|
.gb-drop-empty { padding:10px 9px; font-size:12.5px; color: var(--gb-muted,var(--gb-default-muted,#64748b)); }
|
|
@@ -1422,14 +1208,11 @@ var GK_CSS = `
|
|
|
1422
1208
|
.gb-drop-keys kbd { padding:1px 4px; }
|
|
1423
1209
|
.gb-drop-keys kbd + kbd { margin-left:-1px; }
|
|
1424
1210
|
|
|
1425
|
-
|
|
1426
|
-
.gb-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
.gb-chip button { display:grid; place-items:center; width:22px; height:22px; border:0; padding:0; border-radius:var(--gb-r-chip,5px);
|
|
1431
|
-
background:transparent; color: var(--gb-muted,var(--gb-default-muted,#64748b)); }
|
|
1432
|
-
.gb-chip button:hover { background: rgba(127,127,127,.18); color: var(--gb-text,var(--gb-default-text,#1f2937)); }
|
|
1211
|
+
.gb-field .gb-token { max-width:min(48%,140px); }
|
|
1212
|
+
.gb-token .gb-ico, .gb-token button { flex:none; }
|
|
1213
|
+
.gb-absent { position:absolute; inset:20% 8%; display:grid; place-content:center; text-align:center;
|
|
1214
|
+
pointer-events:none; color:var(--gb-muted,var(--gb-default-muted,#64748b)); }
|
|
1215
|
+
|
|
1433
1216
|
|
|
1434
1217
|
/* Segmented: a backing slides to the current item. The layer names live in a horizontal
|
|
1435
1218
|
* scroll track so a long list never pushes the toolbar wider than the canvas; the stack
|
|
@@ -1438,7 +1221,7 @@ var GK_CSS = `
|
|
|
1438
1221
|
min-width:0; max-width:100%; flex:0 1 auto; }
|
|
1439
1222
|
.gb-layer-track { position:relative; display:flex; flex:1 1 auto; min-width:0; height:28px;
|
|
1440
1223
|
overflow-x:auto; overflow-y:hidden; overscroll-behavior-x:contain; touch-action:pan-x;
|
|
1441
|
-
scrollbar-width:none; max-width:1000px; transition:max-width .26s ease, opacity .18s ease; }
|
|
1224
|
+
scrollbar-width:none; max-width:1000px; transition:max-width .26s var(--gb-ease), opacity .18s var(--gb-ease); }
|
|
1442
1225
|
/* Floors off: the list folds away; the switch beside it does not move (same element, same place, as the legend). */
|
|
1443
1226
|
.gb-layers.is-collapsed .gb-layer-track { max-width:0; opacity:0; pointer-events:none; }
|
|
1444
1227
|
.gb-layers.is-collapsed .gb-sep { opacity:0; margin:0; }
|
|
@@ -1450,15 +1233,15 @@ var GK_CSS = `
|
|
|
1450
1233
|
mask-image:linear-gradient(to right, transparent, #000 18px, #000 calc(100% - 18px), transparent); }
|
|
1451
1234
|
.gb-segm > button, .gb-layer-track > button { position:relative; z-index:1; height:28px; padding:0 12px; border:0; border-radius:var(--gb-r-in-face,7px);
|
|
1452
1235
|
background:transparent; font-size:12.5px; font-weight:500; color: var(--gb-muted,var(--gb-default-muted,#64748b)); white-space:nowrap;
|
|
1453
|
-
transition: color .2s, background-color .2s; flex:none; }
|
|
1236
|
+
transition: color .2s var(--gb-ease), background-color .2s var(--gb-ease); flex:none; }
|
|
1454
1237
|
.gb-segm > button:hover:not(.on):not(:disabled), .gb-layer-track > button:hover:not(.on):not(:disabled) { color: var(--gb-text,var(--gb-default-text,#1f2937)); }
|
|
1455
1238
|
.gb-segm > button.on, .gb-layer-track > button.on { color: var(--gb-text,var(--gb-default-text,#1f2937)); }
|
|
1456
1239
|
.gb-segm > button:disabled, .gb-layer-track > button:disabled { cursor:default; opacity:.5; }
|
|
1457
1240
|
.gb-thumb { position:absolute; top:0; left:0; z-index:0; height:28px; border-radius:var(--gb-r-in-face,7px); background: var(--gb-active,var(--gb-default-active,#e0f2fe));
|
|
1458
|
-
box-shadow: 0 1px 2px rgba(15,23,42,.08); transition: transform .3s
|
|
1241
|
+
box-shadow: 0 1px 2px rgba(15,23,42,.08); transition: transform .3s var(--gb-ease), width .3s var(--gb-ease); }
|
|
1459
1242
|
/* Stacked layers on: layer names are multi-select, each lit on its own; no slider. */
|
|
1460
1243
|
.gb-layers.is-multi .gb-layer-track > button[data-v].on { background: var(--gb-active,var(--gb-default-active,#e0f2fe)); box-shadow: 0 1px 2px rgba(15,23,42,.08); }
|
|
1461
|
-
.gb-sep { align-self:center; width:1px; height:18px; margin:0 3px; background: var(--gb-border,var(--gb-default-border,#e2e8f0)); flex:none; transition:opacity .18s ease, margin .26s ease; }
|
|
1244
|
+
.gb-sep { align-self:center; width:1px; height:18px; margin:0 3px; background: var(--gb-border,var(--gb-default-border,#e2e8f0)); flex:none; transition:opacity .18s var(--gb-ease), margin .26s var(--gb-ease); }
|
|
1462
1245
|
.gb-layer-track > button:focus-visible { outline-offset:-2px; }
|
|
1463
1246
|
.gb-segm > button.gb-stack { display:grid; place-items:center; width:30px; padding:0; color: var(--gb-muted2,var(--gb-default-muted2,#94a3b8)); }
|
|
1464
1247
|
.gb-segm > button.gb-stack:hover:not(:disabled) { color: var(--gb-text,var(--gb-default-text,#1f2937)); background: var(--gb-tint,var(--gb-default-tint,#f1f5f9)); }
|
|
@@ -1466,7 +1249,7 @@ var GK_CSS = `
|
|
|
1466
1249
|
|
|
1467
1250
|
.gb-menu { position:relative; }
|
|
1468
1251
|
.gb-icon-btn { display:grid; place-items:center; width:36px; height:36px; padding:0; color: var(--gb-muted,var(--gb-default-muted,#64748b));
|
|
1469
|
-
transition: color .15s, background-color .15s; }
|
|
1252
|
+
transition: color .15s var(--gb-ease), background-color .15s var(--gb-ease); }
|
|
1470
1253
|
.gb-icon-btn:hover, .gb-icon-btn.on { color: var(--gb-text,var(--gb-default-text,#1f2937)); }
|
|
1471
1254
|
.gb-icon-btn.on { background: var(--gb-active,var(--gb-default-active,#e0f2fe)); }
|
|
1472
1255
|
.gb-panel { min-width:228px; }
|
|
@@ -1483,31 +1266,33 @@ var GK_CSS = `
|
|
|
1483
1266
|
border-radius:var(--gb-r-in-pop,6px); background: var(--gb-panel2,var(--gb-default-panel2,#fff)); color: var(--gb-text,var(--gb-default-text,#1f2937)); font: inherit; font-size:12.5px; }
|
|
1484
1267
|
|
|
1485
1268
|
/* Bottom right: the camera. */
|
|
1486
|
-
.gb-
|
|
1269
|
+
.gb-footer { position:absolute; inset:12px; z-index:10; pointer-events:none;
|
|
1270
|
+
display:flex; align-items:flex-end; gap:8px; }
|
|
1271
|
+
.gb-dock { display:flex; align-items:flex-end; gap:8px; flex:none; margin-left:auto; }
|
|
1272
|
+
.gb-dock > * { pointer-events:auto; }
|
|
1487
1273
|
.gb-group { display:inline-flex; overflow:hidden; }
|
|
1488
1274
|
.gb-group > button { display:grid; place-items:center; width:34px; height:34px; padding:0; border:0; background:transparent;
|
|
1489
|
-
color: var(--gb-muted,var(--gb-default-muted,#64748b)); transition: color .15s, background-color .15s; }
|
|
1275
|
+
color: var(--gb-muted,var(--gb-default-muted,#64748b)); transition: color .15s var(--gb-ease), background-color .15s var(--gb-ease); }
|
|
1490
1276
|
.gb-group > button:hover { color: var(--gb-text,var(--gb-default-text,#1f2937)); background: var(--gb-tint,var(--gb-default-tint,#f1f5f9)); }
|
|
1491
1277
|
.gb-group > button:active { background: var(--gb-active,var(--gb-default-active,#e0f2fe)); }
|
|
1492
1278
|
.gb-group > button + button { border-left:1px solid var(--gb-border,var(--gb-default-border,#e2e8f0)); }
|
|
1493
|
-
.gb-
|
|
1494
|
-
.gb-issues {
|
|
1495
|
-
.gb-issues
|
|
1496
|
-
.gb-issues
|
|
1497
|
-
|
|
1498
|
-
.gb-issues
|
|
1499
|
-
.gb-issues
|
|
1500
|
-
|
|
1501
|
-
.gb-issues
|
|
1502
|
-
.gb-issues
|
|
1503
|
-
.gb-issues
|
|
1504
|
-
.gb-issues
|
|
1505
|
-
.gb-
|
|
1506
|
-
.gb-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
.gb-
|
|
1510
|
-
.gb-issues li.gb-more { font-style:italic; }
|
|
1279
|
+
.gb-issues { padding:0; width:min(700px, calc(100vw - 24px)); max-height:min(600px, 70vh); overflow:auto; }
|
|
1280
|
+
.gb-issues .gb-md { padding:10px 11px; font-size:13px; line-height:1.5; text-align:left; user-select:text; overflow-wrap:anywhere; }
|
|
1281
|
+
.gb-issues .gb-md-h { margin:14px 0 4px; }
|
|
1282
|
+
.gb-issues .gb-md-h:first-child { margin-top:0; }
|
|
1283
|
+
.gb-issues .gb-md > ul > li + li { margin-top:12px; }
|
|
1284
|
+
.gb-issues .gb-md li > ul, .gb-issues .gb-md li > pre { margin-top:4px; }
|
|
1285
|
+
.gb-issues .gb-md pre { white-space:pre-wrap; }
|
|
1286
|
+
.gb-check-button[aria-expanded="true"] { color:var(--gb-text,var(--gb-default-text,#1f2937)); background:var(--gb-active,var(--gb-default-active,#e0f2fe)); }
|
|
1287
|
+
.gb-issues .gb-md-h1 { font-size:15px; }
|
|
1288
|
+
.gb-issues .gb-md-h1:not(:first-child) { margin-top:16px; padding-top:12px; border-top:1px solid var(--gb-border,var(--gb-default-border,#e2e8f0)); }
|
|
1289
|
+
.gb-issues .gb-md-h2 { color:var(--gb-muted,var(--gb-default-muted,#64748b)); }
|
|
1290
|
+
.gb-issues .gb-md > .gb-md-h2, .gb-issues .gb-md > ul { margin-inline-start:8px; }
|
|
1291
|
+
.gb-check-stack { position:relative; display:block; }
|
|
1292
|
+
.gb-check-badge { position:absolute; top:-1px; right:-7px; min-width:12px; text-align:left;
|
|
1293
|
+
font:700 9px/9px ui-monospace, SFMono-Regular, Consolas, monospace;
|
|
1294
|
+
background:var(--gb-panel2,var(--gb-default-panel2,#fff)); border-radius:2px; }
|
|
1295
|
+
.gb-check-button[aria-expanded="true"] .gb-check-badge { background:var(--gb-active,var(--gb-default-active,#e0f2fe)); }
|
|
1511
1296
|
.gb-err { color: var(--gb-err,var(--gb-default-err,#dc2626)); border-color: var(--gb-err-border,var(--gb-default-err-border,#fca5a5)); background: var(--gb-err-bg,var(--gb-default-err-bg,#fef2f2)); }
|
|
1512
1297
|
.gb-hint { color: var(--gb-muted,var(--gb-default-muted,#64748b)); }
|
|
1513
1298
|
.gb-hint .gb-ico { color: var(--gb-warn,var(--gb-default-warn,#b45309)); }
|
|
@@ -1517,15 +1302,13 @@ var GK_CSS = `
|
|
|
1517
1302
|
.gb-search, .gb-thumb { transition:none; }
|
|
1518
1303
|
.gb-drop, .gb-panel { animation:none; }
|
|
1519
1304
|
}
|
|
1520
|
-
/*
|
|
1521
|
-
.gb-bl {
|
|
1522
|
-
display:flex; flex-direction:column; justify-content:flex-end; align-items:flex-start; gap:8px; pointer-events:none; }
|
|
1305
|
+
/* Share the available width with the dock. Stretch vertically to give the legend its height cap. */
|
|
1306
|
+
.gb-bl { min-width:0; align-self:stretch; display:flex; flex-direction:column; justify-content:flex-end; align-items:flex-start; gap:8px; }
|
|
1523
1307
|
.gb-bl > * { pointer-events:auto; }
|
|
1524
1308
|
.gb-note { font-size:11px; color: var(--gb-muted,var(--gb-default-muted,#64748b)); padding:4px 8px; display:flex; gap:8px; align-items:center; }
|
|
1525
1309
|
.gb-warn { color: var(--gb-warn,var(--gb-default-warn,#b45309)); border-color: var(--gb-warn-border,var(--gb-default-warn-border,#fcd34d)); background: var(--gb-warn-bg,var(--gb-default-warn-bg,#fffbeb)); }
|
|
1526
1310
|
.gb-mask { position:absolute; inset:0; z-index:20; display:grid; place-items:center; background: var(--gb-mask,var(--gb-default-mask,rgba(248,250,252,.6))); }
|
|
1527
|
-
.gb-
|
|
1528
|
-
border-radius:var(--gb-r-pop,12px); box-shadow: 0 2px 6px rgba(15,23,42,.06), 0 18px 40px -12px rgba(15,23,42,.24); background: var(--gb-panel,var(--gb-default-panel,#fff)); padding:10px 16px; font-size:12.5px; color: var(--gb-muted,var(--gb-default-muted,#64748b)); }
|
|
1311
|
+
.gb-loading { display:flex; align-items:center; gap:10px; padding:10px 16px; font-size:12.5px; color:var(--gb-muted,var(--gb-default-muted,#64748b)); }
|
|
1529
1312
|
.gb-spin { width:14px; height:14px; border-radius:50%; border:2px solid var(--gb-accent,var(--gb-default-accent,#0284c7));
|
|
1530
1313
|
border-top-color:transparent; animation: gb-spin 0.8s linear infinite; }
|
|
1531
1314
|
@keyframes gb-spin { to { transform: rotate(360deg); } }
|
|
@@ -1547,7 +1330,7 @@ var GK_CSS = `
|
|
|
1547
1330
|
.gb-lg-row { display:flex; flex-wrap:wrap; align-items:center; gap:1px 4px; }
|
|
1548
1331
|
.gb-lg-item { position:relative; display:inline-flex; color: var(--gb-muted,var(--gb-default-muted,#64748b)); }
|
|
1549
1332
|
.gb-lg-hit { display:inline-flex; align-items:center; gap:5px; height:24px; padding:0 6px; border:0; border-radius:var(--gb-r-in-pop,6px);
|
|
1550
|
-
background:none; font:inherit; color:inherit; cursor:pointer; transition: background-color .12s, color .12s; }
|
|
1333
|
+
background:none; font:inherit; color:inherit; cursor:pointer; transition: background-color .12s var(--gb-ease), color .12s var(--gb-ease); }
|
|
1551
1334
|
.gb-lg-hit:hover, .gb-lg-item.is-open .gb-lg-hit { background: var(--gb-tint,var(--gb-default-tint,#f1f5f9)); color: var(--gb-text,var(--gb-default-text,#1f2937)); }
|
|
1552
1335
|
.gb-lg-item b { font-weight:600; color: var(--gb-muted2,var(--gb-default-muted2,#94a3b8)); font-variant-numeric: tabular-nums; }
|
|
1553
1336
|
.gb-lg-item.off { color: var(--gb-muted2,var(--gb-default-muted2,#94a3b8)); }
|
|
@@ -1558,9 +1341,7 @@ var GK_CSS = `
|
|
|
1558
1341
|
outline:2px solid var(--gb-accent,var(--gb-default-accent,#0284c7)); outline-offset:1px; }
|
|
1559
1342
|
.gb-lg-pop { position:absolute; left:-6px; bottom:calc(100% + 6px); z-index:30;
|
|
1560
1343
|
display:flex; align-items:center; gap:4px; padding:6px; white-space:nowrap;
|
|
1561
|
-
|
|
1562
|
-
box-shadow: 0 2px 6px rgba(15,23,42,.06), 0 18px 40px -12px rgba(15,23,42,.24);
|
|
1563
|
-
animation: gb-pop-up .14s cubic-bezier(.2,.8,.3,1); }
|
|
1344
|
+
animation: gb-pop-up .14s var(--gb-ease); }
|
|
1564
1345
|
/* The gap between panel and entry counts as panel: moving the mouse up from the entry is not leaving. */
|
|
1565
1346
|
.gb-lg-pop::after { content:''; position:absolute; left:0; right:0; top:100%; height:8px; }
|
|
1566
1347
|
/* Portaled panel: opens above by default, flips below when the stage is too short. */
|
|
@@ -1602,43 +1383,75 @@ var GK_CSS = `
|
|
|
1602
1383
|
* inputs look like the search box, the node picker dropdown like the search dropdown, nodes carry their color on the graph. */
|
|
1603
1384
|
/* Drawer: opening and closing animate width, the canvas changes with it instead of jumping. Hosts use --gb-inspector-bg to match their own
|
|
1604
1385
|
* sidebar (symmetric on both sides, with the canvas in between). */
|
|
1605
|
-
.gb-drawer {
|
|
1606
|
-
|
|
1386
|
+
.gb-drawer { --gb-surface-fill:var(--gb-inspector-bg,var(--gb-panel2,var(--gb-default-surface,#fff)));
|
|
1387
|
+
--gb-radius:0; --gb-shadow:none; border-color:var(--gb-inspector-border,var(--gb-border,var(--gb-default-rim,#e2e8f0))); border-width:0 0 0 1px; flex:none; width:320px; overflow:hidden; display:flex; animation: gb-drawer-in .2s var(--gb-ease); }
|
|
1388
|
+
.gb-drawer.is-closing { animation: gb-drawer-out .2s var(--gb-ease-out) forwards; pointer-events:none; }
|
|
1607
1389
|
@keyframes gb-drawer-in { from { width:0; } }
|
|
1608
1390
|
@keyframes gb-drawer-out { to { width:0; } }
|
|
1609
|
-
.gb-detail { width:320px; flex-shrink:0; display:flex; flex-direction:column; min-height:0;
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
.gb-dh { flex:none; display:flex; align-items:
|
|
1613
|
-
height:
|
|
1614
|
-
.gb-dh-title {
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
.gb-
|
|
1391
|
+
.gb-detail { container:gb-inspector / inline-size; width:320px; flex-shrink:0; display:flex; flex-direction:column; min-height:0; }
|
|
1392
|
+
/* DetailPanel can also be mounted directly by a host. */
|
|
1393
|
+
:where(:not(.gb-drawer)) > .gb-detail { background:var(--gb-inspector-bg,var(--gb-panel2,var(--gb-default-panel2,#fff))); }
|
|
1394
|
+
.gb-dh { position:relative; flex:none; display:flex; align-items:flex-start; gap:6px;
|
|
1395
|
+
min-height:48px; box-sizing:border-box; padding:8px 44px 8px 16px; border-bottom:1px solid var(--gb-inspector-border, var(--gb-border,var(--gb-default-border,#e2e8f0))); }
|
|
1396
|
+
.gb-dh-title { flex:1; min-width:0; max-height:8rem; overflow:auto; overflow-wrap:anywhere; }
|
|
1397
|
+
.gb-dh-meta { display:flex; align-items:flex-start; flex-wrap:wrap; gap:2px 8px; font-size:11px; line-height:16px;
|
|
1398
|
+
color:var(--gb-muted,var(--gb-default-muted,#64748b)); }
|
|
1399
|
+
.gb-identity-field { display:grid; grid-template-columns:auto minmax(0,1fr); align-items:start; column-gap:4px; min-width:0; }
|
|
1400
|
+
.gb-identity-mark, .gb-ref-mark { display:grid; place-items:center; height:1lh; flex:none; }
|
|
1401
|
+
.gb-identity-mark { min-width:16px; }
|
|
1402
|
+
.gb-dh-controls { flex:none; display:flex; align-items:center; min-height:38px; gap:6px; }
|
|
1403
|
+
.gb-dh .gb-dh-close { position:absolute; top:3px; right:3px; width:36px; height:36px; }
|
|
1618
1404
|
.gb-ibtn { display:inline-flex; align-items:center; justify-content:center; gap:5px; min-width:28px; height:28px; padding:0 6px;
|
|
1619
1405
|
border:0; border-radius:var(--gb-r-in-face,7px); background:transparent; color: var(--gb-muted,var(--gb-default-muted,#64748b));
|
|
1620
|
-
font:inherit; font-size:12.5px; cursor:pointer; transition: color .15s, background-color .15s; }
|
|
1406
|
+
font:inherit; font-size:12.5px; cursor:pointer; transition: color .15s var(--gb-ease), background-color .15s var(--gb-ease); }
|
|
1621
1407
|
.gb-ibtn:hover { background: var(--gb-tint,var(--gb-default-tint,#f1f5f9)); color: var(--gb-text,var(--gb-default-text,#1f2937)); }
|
|
1622
|
-
.gb-ibtn:focus-visible, .gb-btn:focus-visible, .gb-
|
|
1408
|
+
.gb-ibtn:focus-visible, .gb-btn:focus-visible, .gb-link:focus-visible, .gb-ref-link:focus-visible, .gb-pick-cur:focus-visible {
|
|
1623
1409
|
outline:2px solid var(--gb-accent,var(--gb-default-accent,#0284c7)); outline-offset:1px; }
|
|
1624
1410
|
.gb-ibtn-text { padding:0 10px 0 8px; color: var(--gb-text,var(--gb-default-text,#1f2937)); border:1px solid var(--gb-border,var(--gb-default-border,#e2e8f0)); }
|
|
1625
|
-
|
|
1626
|
-
.gb-
|
|
1627
|
-
.gb-
|
|
1628
|
-
|
|
1411
|
+
@container gb-inspector (max-width:400px) {
|
|
1412
|
+
.gb-dh-controls .gb-ibtn-text { position:relative; width:28px; padding:0; }
|
|
1413
|
+
.gb-dh-controls .gb-ibtn-text::after { content:''; position:absolute; inset:-4px -3px; }
|
|
1414
|
+
.gb-dh-controls .gb-ibtn-text span { display:none; }
|
|
1415
|
+
}
|
|
1416
|
+
.gb-db { overscroll-behavior:contain; flex:1; min-height:0; overflow:auto; padding:16px; font-size:12.5px; line-height:1.55; }
|
|
1417
|
+
.gb-dt { font-size:15px; font-weight:600; line-height:1.35; margin:2px 0 0; overflow-wrap:anywhere; color: var(--gb-text,var(--gb-default-text,#1f2937)); }
|
|
1629
1418
|
.gb-dempty { color: var(--gb-muted2,var(--gb-default-muted2,#94a3b8)); }
|
|
1630
|
-
.gb-line { display:grid; grid-template-columns:
|
|
1631
|
-
.gb-k { font-size:10.5px; font-weight:600; letter-spacing:.05em; text-transform:uppercase; color: var(--gb-
|
|
1419
|
+
.gb-line { display:grid; grid-template-columns:minmax(64px,30%) minmax(0,1fr); gap:10px; padding:5px 0; overflow-wrap:anywhere; }
|
|
1420
|
+
.gb-k { font-size:10.5px; font-weight:600; letter-spacing:.05em; text-transform:uppercase; color: var(--gb-muted,var(--gb-default-muted,#64748b)); }
|
|
1632
1421
|
.gb-line .gb-k { padding-top:2px; }
|
|
1633
|
-
.gb-
|
|
1634
|
-
.gb-
|
|
1635
|
-
.gb-
|
|
1636
|
-
.gb-
|
|
1637
|
-
.gb-
|
|
1638
|
-
.gb-
|
|
1422
|
+
.gb-db:not(.gb-form) > .gb-core-field { margin:12px 0; }
|
|
1423
|
+
.gb-core-field .gb-value ul, .gb-core-field .gb-value-diff ul { margin:0; padding-left:16px; }
|
|
1424
|
+
.gb-core-field .gb-value li, .gb-core-field .gb-value-diff li { margin-bottom:3px; overflow-wrap:anywhere; }
|
|
1425
|
+
.gb-field-pair, .gb-children, .gb-edge-row, .gb-rel:not(.gb-children) > li { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); column-gap:12px; }
|
|
1426
|
+
.gb-field-pair { margin:8px 0 12px; }
|
|
1427
|
+
.gb-field-pair:first-child { margin-top:0; }
|
|
1428
|
+
.gb-core-field { min-width:0; display:grid; grid-template-columns:minmax(0,1fr); align-content:start; gap:3px; }
|
|
1429
|
+
.gb-rel-section { padding:8px 0; border-top:1px solid var(--gb-border,var(--gb-default-border,#e2e8f0)); }
|
|
1430
|
+
.gb-list-head { display:flex; align-items:center; gap:6px; min-height:22px; font-size:11px; font-variant-numeric:tabular-nums; color:var(--gb-muted,var(--gb-default-muted,#64748b)); }
|
|
1431
|
+
.gb-list-add { margin-inline-start:auto; }
|
|
1432
|
+
.gb-rel { list-style:none; margin:0; padding:0; }
|
|
1433
|
+
.gb-rel li { min-width:0; align-items:start; padding:2px 0; overflow-wrap:anywhere; }
|
|
1434
|
+
.gb-children > li, .gb-peer, .gb-ref { display:flex; align-items:flex-start; gap:6px; min-width:0; }
|
|
1435
|
+
.gb-peer { justify-content:space-between; }
|
|
1436
|
+
.gb-ref { align-items:center; max-width:100%; }
|
|
1437
|
+
.gb-ref-link { border:0; background:none; padding:2px 0; font:inherit; cursor:pointer; text-align:start; }
|
|
1438
|
+
.gb-ref-link:hover .gb-ref-label { text-decoration:underline; }
|
|
1439
|
+
:is(.gb-rel,.gb-value,.gb-value-diff) .gb-ref { align-items:flex-start; font-size:12.5px; line-height:1.4; }
|
|
1440
|
+
:is(.gb-rel,.gb-value,.gb-value-diff) .gb-ref-label { white-space:normal; overflow-wrap:anywhere; }
|
|
1441
|
+
.gb-rel .gb-ref { padding:2px 0; }
|
|
1442
|
+
|
|
1443
|
+
.gb-rel-section .gb-more { font-size:11.5px; padding:4px 0; }
|
|
1444
|
+
.gb-value { min-width:0; white-space:pre-wrap; overflow-wrap:anywhere; }
|
|
1445
|
+
.gb-value:has(.gb-md), .gb-value:has(ul) { white-space:normal; }
|
|
1446
|
+
.gb-value-diff { display:flex; flex-wrap:wrap; align-items:baseline; gap:3px 7px; min-width:0; overflow-wrap:anywhere; }
|
|
1447
|
+
.gb-value-diff.is-block { display:grid; }
|
|
1448
|
+
.gb-change { color:var(--gb-muted,var(--gb-default-muted,#64748b)); font-size:11px; }
|
|
1449
|
+
.gb-was, .gb-was .gb-ref-label { text-decoration:line-through; color:var(--gb-err,var(--gb-default-err,#b91c1c)); }
|
|
1450
|
+
.gb-now, .gb-now .gb-ref-label { text-decoration:underline; text-underline-offset:.15em; color:var(--gb-accent,var(--gb-default-accent,#0369a1)); }
|
|
1451
|
+
.gb-change { font-weight:600; padding-inline:5px; border-inline-start:1px solid currentColor; }
|
|
1639
1452
|
.gb-df { flex:none; display:flex; align-items:center; justify-content:space-between; gap:8px;
|
|
1640
1453
|
padding:10px 12px 10px 16px; border-top:1px solid var(--gb-inspector-border, var(--gb-border,var(--gb-default-border,#e2e8f0)));
|
|
1641
|
-
|
|
1454
|
+
}
|
|
1642
1455
|
|
|
1643
1456
|
/* markdown (long text in details): body font size, images span the column, code on a faint background. */
|
|
1644
1457
|
.gb-md > * + * { margin-top:8px; }
|
|
@@ -1663,13 +1476,15 @@ var GK_CSS = `
|
|
|
1663
1476
|
* opening the 320px inspector narrows the chrome too. */
|
|
1664
1477
|
@container gk (max-width: 640px) {
|
|
1665
1478
|
.gb-drawer { position:absolute; left:0; right:0; bottom:0; z-index:25; width:auto; max-height:62%;
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1479
|
+
--gb-radius:var(--gb-r-sheet,16px) var(--gb-r-sheet,16px) 0 0;
|
|
1480
|
+
--gb-surface-fill:color-mix(in srgb,var(--gb-inspector-bg,var(--gb-default-surface,#fff)) 93%,transparent);
|
|
1481
|
+
--gb-shadow:0 -10px 32px -12px rgba(0,0,0,.32); border-width:1px 0 0;
|
|
1482
|
+
animation: gb-sheet-in .24s var(--gb-ease); }
|
|
1483
|
+
.gb-drawer.is-closing { animation: gb-sheet-out .2s var(--gb-ease-out) forwards; }
|
|
1669
1484
|
.gb-drawer > .gb-detail { width:100%; border-left:0; }
|
|
1670
1485
|
.gb-dh::before { content:''; position:absolute; left:50%; top:6px; width:36px; height:4px; margin-left:-18px;
|
|
1671
|
-
border-radius:2px; background:
|
|
1672
|
-
.gb-dh {
|
|
1486
|
+
border-radius:2px; background:var(--gb-muted2,var(--gb-default-muted2,#94a3b8)); opacity:.4; }
|
|
1487
|
+
.gb-dh { padding-top:14px; }
|
|
1673
1488
|
}
|
|
1674
1489
|
@container gks (max-width: 640px) {
|
|
1675
1490
|
.gb-bar { right:12px; }
|
|
@@ -1679,10 +1494,9 @@ var GK_CSS = `
|
|
|
1679
1494
|
.gb-bar.has-layers .gb-search { flex:1 1 100%; width:auto; max-width:none; min-width:0; }
|
|
1680
1495
|
.gb-bar.has-layers .gb-segm { flex:1 1 0; }
|
|
1681
1496
|
.gb-bar.has-layers .gb-menu { flex:none; }
|
|
1682
|
-
/*
|
|
1683
|
-
.gb-bar:not(.has-layers) .gb-search { flex:1 1
|
|
1684
|
-
|
|
1685
|
-
.gb-bl { max-width:calc(100% - 60px); }
|
|
1497
|
+
/* Folded layers and settings take only their button widths; search fills the rest. */
|
|
1498
|
+
.gb-bar:not(.has-layers) .gb-search { flex:1 1 9rem; width:auto; min-width:min(9rem,100%); }
|
|
1499
|
+
.gb-layers.is-collapsed .gb-layer-track { display:none; }
|
|
1686
1500
|
.gb-dock { flex-direction:column; align-items:flex-end; }
|
|
1687
1501
|
.gb-dock .gb-group { flex-direction:column; }
|
|
1688
1502
|
.gb-dock .gb-group > button + button { border-left:0; border-top:1px solid var(--gb-border,var(--gb-default-border,#e2e8f0)); }
|
|
@@ -1690,7 +1504,8 @@ var GK_CSS = `
|
|
|
1690
1504
|
@keyframes gb-sheet-in { from { transform: translateY(100%); } }
|
|
1691
1505
|
@keyframes gb-sheet-out { to { transform: translateY(100%); } }
|
|
1692
1506
|
@media (prefers-reduced-motion: reduce) {
|
|
1693
|
-
.gb-
|
|
1507
|
+
.gb-root :is(.gb-drawer,.gb-glass,.gb-layer-track,.gb-sep,.gb-thumb,.gb-search) {
|
|
1508
|
+
animation-duration:.01ms; transition-duration:.01ms; }
|
|
1694
1509
|
}
|
|
1695
1510
|
|
|
1696
1511
|
/* What a node looks like: its color on the graph (.gb-dot, as in the search dropdown) + name (+ a grey line). */
|
|
@@ -1706,64 +1521,52 @@ var GK_CSS = `
|
|
|
1706
1521
|
.gb-menu-item:disabled { opacity:.5; cursor:default; }
|
|
1707
1522
|
.gb-link { border:0; background:none; padding:0; font:inherit; font-size:12.5px; color: var(--gb-accent,var(--gb-default-accent,#0284c7)); cursor:pointer; }
|
|
1708
1523
|
.gb-link:hover { text-decoration:underline; }
|
|
1709
|
-
.gb-form
|
|
1710
|
-
.gb-
|
|
1711
|
-
.gb-
|
|
1712
|
-
.gb-
|
|
1713
|
-
.gb-
|
|
1524
|
+
.gb-form > :is(.gb-core-field,.gb-rel-section) + .gb-core-field { margin-top:10px; }
|
|
1525
|
+
.gb-form > .gb-core-field { gap:7px; }
|
|
1526
|
+
.gb-core-field .gb-k em { font-style:normal; font-weight:500; letter-spacing:0; text-transform:none; margin-left:4px; opacity:.8; }
|
|
1527
|
+
.gb-core-field small { font-size:11px; color: var(--gb-muted2,var(--gb-default-muted2,#94a3b8)); }
|
|
1528
|
+
.gb-core-field small.is-bad { color: var(--gb-err,var(--gb-default-err,#dc2626)); }
|
|
1714
1529
|
/* Inputs: look like the search box: white background, thin border, a glow on focus. */
|
|
1715
1530
|
.gb-input { width:100%; box-sizing:border-box; height:36px; padding:0 11px; border:1px solid var(--gb-border,var(--gb-default-border,#e2e8f0));
|
|
1716
1531
|
border-radius:var(--gb-r-in-face,8px); background: var(--gb-panel2,var(--gb-default-panel2,#fff)); color: var(--gb-text,var(--gb-default-text,#1f2937));
|
|
1717
1532
|
font: inherit; font-size:13px; outline:none; box-shadow: 0 1px 2px rgba(15,23,42,.04);
|
|
1718
|
-
transition: border-color .15s, box-shadow .15s; }
|
|
1533
|
+
transition: border-color .15s var(--gb-ease), box-shadow .15s var(--gb-ease); }
|
|
1719
1534
|
.gb-input:focus, .gb-input:focus-within { border-color: var(--gb-accent,var(--gb-default-accent,#0284c7));
|
|
1720
1535
|
box-shadow: 0 0 0 3px color-mix(in srgb, var(--gb-accent,var(--gb-default-accent,#0284c7)) 16%, transparent); }
|
|
1536
|
+
.gb-input.gb-edge-row { grid-column:1 / -1; align-items:start; height:auto; min-height:36px; padding:6px 8px; text-align:start; cursor:pointer; }
|
|
1721
1537
|
.gb-input.is-bad { border-color: var(--gb-err,var(--gb-default-err,#dc2626)); }
|
|
1722
1538
|
.gb-input::placeholder, .gb-input input::placeholder { color: var(--gb-muted2,var(--gb-default-muted2,#94a3b8)); }
|
|
1723
|
-
.gb-json { height:auto; min-height:
|
|
1539
|
+
.gb-json { height:auto; min-height:96px; padding:10px 11px; resize:vertical; tab-size:2; white-space:pre;
|
|
1724
1540
|
font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--gb-tint,var(--gb-default-tint,#f8fafc)); }
|
|
1725
1541
|
.gb-json:focus { background: var(--gb-panel2,var(--gb-default-panel2,#fff)); }
|
|
1726
|
-
.gb-id { display:block; padding:8px 11px; border-radius:var(--gb-r-in-face,8px); background: var(--gb-tint,var(--gb-default-tint,#f8fafc));
|
|
1727
|
-
font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--gb-muted,var(--gb-default-muted,#64748b)); overflow-wrap:anywhere; }
|
|
1728
1542
|
/* Node picker: unselected it is a search box with a magnifier and a dropdown like search's; selected it is a colored tag. */
|
|
1729
1543
|
.gb-pick { position:relative; }
|
|
1730
1544
|
.gb-pick-field { display:flex; align-items:center; gap:8px; color: var(--gb-muted2,var(--gb-default-muted2,#94a3b8)); }
|
|
1731
1545
|
.gb-pick-field input { flex:1; min-width:0; height:100%; border:0; outline:none; background:transparent; padding:0;
|
|
1732
1546
|
font:inherit; font-size:13px; color: var(--gb-text,var(--gb-default-text,#1f2937)); }
|
|
1733
|
-
.gb-pick-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
.gb-pick-
|
|
1547
|
+
.gb-pick-selected { display:flex; align-items:center; gap:2px; padding:0 3px 0 8px; }
|
|
1548
|
+
.gb-pick-cur { flex:1; min-width:0; height:100%; display:flex; align-items:center; padding:0; border:0;
|
|
1549
|
+
text-align:start; color:inherit; background:transparent; font:inherit; cursor:pointer; }
|
|
1550
|
+
.gb-pick-selected:hover, .gb-edge-row:hover { border-color: color-mix(in srgb, var(--gb-accent,var(--gb-default-accent,#0284c7)) 45%, var(--gb-border,var(--gb-default-border,#e2e8f0))); }
|
|
1551
|
+
.gb-pick-cur > .gb-ref-static { flex:1; }
|
|
1737
1552
|
.gb-pick-x { display:grid; place-items:center; width:24px; height:24px; flex:none; border-radius:var(--gb-r-chip,5px);
|
|
1738
1553
|
color: var(--gb-muted2,var(--gb-default-muted2,#94a3b8)); }
|
|
1739
1554
|
.gb-pick-x:hover { background: var(--gb-tint,var(--gb-default-tint,#f1f5f9)); color: var(--gb-text,var(--gb-default-text,#1f2937)); }
|
|
1740
1555
|
.gb-pick-list { position:absolute; left:0; right:0; top:calc(100% + 6px); z-index:5; margin:0; padding:6px; list-style:none;
|
|
1741
|
-
|
|
1742
|
-
box-shadow: 0 2px 6px rgba(15,23,42,.06), 0 18px 40px -12px rgba(15,23,42,.24);
|
|
1743
|
-
animation: gb-pop .14s cubic-bezier(.2,.8,.3,1); }
|
|
1556
|
+
animation: gb-pop .14s var(--gb-ease); }
|
|
1744
1557
|
.gb-pick-list li { display:flex; align-items:center; gap:10px; padding:7px 9px; border-radius:var(--gb-r-in-pop,6px); cursor:pointer; }
|
|
1745
1558
|
.gb-pick-list li.on { background: var(--gb-tint,var(--gb-default-tint,#f1f5f9)); }
|
|
1746
|
-
/* Edge list: direction \xB7 other end \xB7 kind \xB7 \xD7. */
|
|
1747
|
-
.gb-rel { list-style:none; margin:0; padding:0; display:flex; flex-direction:column; }
|
|
1748
|
-
.gb-rel li { display:flex; align-items:center; gap:9px; min-height:34px; padding:0 2px 0 6px; border-radius:var(--gb-r-in-pop,6px); }
|
|
1749
|
-
.gb-rel li:hover { background: var(--gb-tint,var(--gb-default-tint,#f8fafc)); }
|
|
1750
|
-
.gb-rel-dir { width:12px; flex:none; color: var(--gb-muted2,var(--gb-default-muted2,#94a3b8)); font-size:12px; }
|
|
1751
|
-
.gb-rel .gb-ibtn { min-width:24px; height:24px; padding:0; opacity:0; }
|
|
1752
|
-
.gb-rel li:hover .gb-ibtn, .gb-rel .gb-ibtn:focus-visible { opacity:1; }
|
|
1753
|
-
.gb-add { align-self:flex-start; display:inline-flex; align-items:center; gap:6px; height:30px; padding:0 10px 0 8px;
|
|
1754
|
-
border:1px dashed var(--gb-border,var(--gb-default-border,#e2e8f0)); border-radius:var(--gb-r-in-face,7px); background:none;
|
|
1755
|
-
font:inherit; font-size:12px; color: var(--gb-muted,var(--gb-default-muted,#64748b)); cursor:pointer; }
|
|
1756
|
-
.gb-add:hover { color: var(--gb-accent,var(--gb-default-accent,#0284c7)); border-color: var(--gb-accent,var(--gb-default-accent,#0284c7)); }
|
|
1757
1559
|
/* Buttons: same height and radius as the canvas overlays. */
|
|
1758
|
-
.gb-form-act { display:flex; align-items:center; gap:8px; }
|
|
1560
|
+
.gb-form-act { margin-inline-start:auto; display:flex; align-items:center; gap:8px; }
|
|
1759
1561
|
.gb-btn { height:32px; padding:0 14px; border:1px solid var(--gb-border,var(--gb-default-border,#e2e8f0)); border-radius:var(--gb-r-in-face,7px);
|
|
1760
1562
|
background: var(--gb-panel2,var(--gb-default-panel2,#fff)); color: var(--gb-text,var(--gb-default-text,#1f2937)); font:inherit; font-size:12.5px; font-weight:500; cursor:pointer;
|
|
1761
|
-
transition: background-color .15s, border-color .15s, opacity .15s; }
|
|
1563
|
+
transition: background-color .15s var(--gb-ease), border-color .15s var(--gb-ease), opacity .15s var(--gb-ease); }
|
|
1762
1564
|
.gb-btn:hover:not(:disabled) { background: var(--gb-tint,var(--gb-default-tint,#f1f5f9)); }
|
|
1763
1565
|
.gb-btn:disabled { opacity:.45; cursor:default; }
|
|
1764
1566
|
.gb-primary { border-color:transparent; background: var(--gb-accent,var(--gb-default-accent,#0284c7)); color: var(--gb-on-accent,var(--gb-default-on-accent,#fff));
|
|
1765
1567
|
box-shadow: 0 1px 2px rgba(15,23,42,.12); }
|
|
1766
1568
|
.gb-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--gb-accent,var(--gb-default-accent,#0284c7)) 88%, #000); }
|
|
1569
|
+
.gb-df :is(.gb-danger,.gb-danger-text) { display:inline-flex; align-items:center; gap:5px; }
|
|
1767
1570
|
.gb-danger { border-color:transparent; background: var(--gb-err,var(--gb-default-err,#dc2626)); color:#fff; }
|
|
1768
1571
|
.gb-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--gb-err,var(--gb-default-err,#dc2626)) 88%, #000); }
|
|
1769
1572
|
.gb-danger-text { border-color:transparent; background:none; color: var(--gb-err,var(--gb-default-err,#dc2626)); padding:0 8px; }
|
|
@@ -1798,8 +1601,7 @@ var GK_CSS = `
|
|
|
1798
1601
|
.gb-pastwire { fill:none; stroke: var(--gb-diff-past, ${DIFF_INK.past}); stroke-linecap:round; }
|
|
1799
1602
|
.gb-diff-trunc { position:absolute; top:8px; left:8px; z-index:6; pointer-events:none;
|
|
1800
1603
|
font-size:11px; color: var(--gb-muted2,var(--gb-default-muted2,#94a3b8));
|
|
1801
|
-
|
|
1802
|
-
border-radius:var(--gb-r-face,10px); padding:3px 7px; }
|
|
1604
|
+
padding:3px 7px; }
|
|
1803
1605
|
`;
|
|
1804
1606
|
|
|
1805
1607
|
// src/edit.ts
|
|
@@ -1839,11 +1641,15 @@ function checkEdit(model, op) {
|
|
|
1839
1641
|
case "removeNode":
|
|
1840
1642
|
if (!has(op.id)) return "no-node";
|
|
1841
1643
|
return model.nodes.some((n) => n.parent === op.id) ? "has-children" : null;
|
|
1842
|
-
case "addEdge":
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
if (
|
|
1846
|
-
|
|
1644
|
+
case "addEdge":
|
|
1645
|
+
case "updateEdge": {
|
|
1646
|
+
const updating = op.op === "updateEdge";
|
|
1647
|
+
if (updating && !model.edges.some((e) => sameEdge(e, op.edge))) return "no-edge";
|
|
1648
|
+
const next = updating ? { ...op.edge, ...op.set } : op.edge;
|
|
1649
|
+
if (!has(next.source) || !has(next.target) || !next.source || !next.target) return "no-endpoint";
|
|
1650
|
+
if (next.source === next.target) return "self-loop";
|
|
1651
|
+
if (updating && sameEdge(next, op.edge)) return null;
|
|
1652
|
+
return model.edges.some((e) => sameEdge(e, next)) ? "edge-exists" : null;
|
|
1847
1653
|
}
|
|
1848
1654
|
case "removeEdge":
|
|
1849
1655
|
return model.edges.some((e) => sameEdge(e, op.edge)) ? null : "no-edge";
|
|
@@ -1909,7 +1715,7 @@ function apply(model, op, profile) {
|
|
|
1909
1715
|
);
|
|
1910
1716
|
case "addEdge": {
|
|
1911
1717
|
const { kind, label, weight, source, target } = op.edge;
|
|
1912
|
-
const origin = model.index.get(source)?.origin;
|
|
1718
|
+
const origin = op.origin ?? model.index.get(source)?.origin;
|
|
1913
1719
|
const edge = {
|
|
1914
1720
|
source,
|
|
1915
1721
|
target,
|
|
@@ -1920,6 +1726,23 @@ function apply(model, op, profile) {
|
|
|
1920
1726
|
};
|
|
1921
1727
|
return buildModel(model.nodes, [...model.edges, edge], model.errors);
|
|
1922
1728
|
}
|
|
1729
|
+
case "updateEdge":
|
|
1730
|
+
return buildModel(model.nodes, model.edges.map((e) => {
|
|
1731
|
+
if (!sameEdge(e, op.edge)) return e;
|
|
1732
|
+
const next = { ...e, ...op.set };
|
|
1733
|
+
if (!next.kind) delete next.kind;
|
|
1734
|
+
if (!next.label) delete next.label;
|
|
1735
|
+
if (e.data) {
|
|
1736
|
+
next.data = { ...e.data, source: next.source, target: next.target };
|
|
1737
|
+
if ("from" in next.data) next.data.from = next.source;
|
|
1738
|
+
if ("to" in next.data) next.data.to = next.target;
|
|
1739
|
+
for (const key of ["kind", "label"]) {
|
|
1740
|
+
if (next[key] !== void 0) next.data[key] = next[key];
|
|
1741
|
+
else delete next.data[key];
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
return next;
|
|
1745
|
+
}), model.errors);
|
|
1923
1746
|
case "removeEdge":
|
|
1924
1747
|
return buildModel(model.nodes, model.edges.filter((e) => !sameEdge(e, op.edge)), model.errors);
|
|
1925
1748
|
}
|
|
@@ -1936,558 +1759,133 @@ function applyEdits(model, ops, profile) {
|
|
|
1936
1759
|
}
|
|
1937
1760
|
var checkNativeEdit = checkEdit;
|
|
1938
1761
|
|
|
1939
|
-
// src/
|
|
1940
|
-
var
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
}
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
}
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
}
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1762
|
+
// src/strings.ts
|
|
1763
|
+
var EN = {
|
|
1764
|
+
empty: "No data yet",
|
|
1765
|
+
viewSubtree: "Scope",
|
|
1766
|
+
viewSubtreeTip: "View subtree",
|
|
1767
|
+
restructureFull: "Re-structure full graph",
|
|
1768
|
+
exitScopeLabel: "Exit scope",
|
|
1769
|
+
exitScope: "Return to full graph",
|
|
1770
|
+
absentNode: "This node is absent in this pass.",
|
|
1771
|
+
absentSource: "No graph content from this file in this pass.",
|
|
1772
|
+
enteredScope: "Moved into view",
|
|
1773
|
+
leftScope: "Moved out of view",
|
|
1774
|
+
noLocalFloors: "No layers in this subgraph.",
|
|
1775
|
+
stats: (n, e) => `${n} nodes \xB7 ${e} edges`,
|
|
1776
|
+
layingOut: (d, t) => `Laying out ${d}/${t}`,
|
|
1777
|
+
preparing: "Preparing layout\u2026",
|
|
1778
|
+
parseErrors: (c, names) => `\u26A0 ${c} source${c > 1 ? "s" : ""} could not be parsed: ${names}`,
|
|
1779
|
+
past: "past",
|
|
1780
|
+
now: "now",
|
|
1781
|
+
diffTruncated: (n) => `${n} more changes not marked (over the limit)`,
|
|
1782
|
+
change: { added: "Added", removed: "Removed", changed: "Changed", moved: "Moved", merged: "Merged" },
|
|
1783
|
+
search: "Search nodes",
|
|
1784
|
+
searchTip: "Several words: as many as possible; /\u2026/ is a regex",
|
|
1785
|
+
clearSearch: "Clear search",
|
|
1786
|
+
noMatch: (q, elsewhere) => `No \u201C${q}\u201D${elsewhere ? " in this layer" : ""}`,
|
|
1787
|
+
moreResults: (n) => `${n} more \u2014 keep typing to narrow down`,
|
|
1788
|
+
inLayer: (l, n) => `${n} in \u201C${l}\u201D`,
|
|
1789
|
+
keysBrowse: "browse",
|
|
1790
|
+
keysPick: "select",
|
|
1791
|
+
keysClear: "clear",
|
|
1792
|
+
viewLayer: (l) => `View \u201C${l}\u201D`,
|
|
1793
|
+
stackLayer: (l, on) => `${on ? "Hide" : "Stack"} \u201C${l}\u201D`,
|
|
1794
|
+
stack: "Stack layers",
|
|
1795
|
+
stackTip: (on) => on ? "Stacked (turn off to view one layer at a time)" : "Stack layers (2.5D)",
|
|
1796
|
+
layersOff: "Layers are off",
|
|
1797
|
+
forceLayers: "Open the floors anyway",
|
|
1798
|
+
ok: "OK",
|
|
1799
|
+
more: "More",
|
|
1800
|
+
origins: "Source",
|
|
1801
|
+
allOrigins: "All sources",
|
|
1802
|
+
issuesBySource: (review, lint) => {
|
|
1803
|
+
const count = (n) => `${n} ${n === 1 ? "category" : "categories"}`;
|
|
1804
|
+
return `Data review \xB7 ${count(review)} / Graph lint \xB7 ${count(lint)}`;
|
|
1805
|
+
},
|
|
1806
|
+
issuesTip: (e, w, i) => [e && `${e} error${e > 1 ? "s" : ""}`, w && `${w} warning${w > 1 ? "s" : ""}`, i && `${i} info`].filter(Boolean).join(" \xB7 "),
|
|
1807
|
+
issuesTitle: (e, w, i, groups) => {
|
|
1808
|
+
const count = groups ?? e + w + (i ?? 0);
|
|
1809
|
+
return count ? `Graph checks \xB7 ${count} ${count === 1 ? "category" : "categories"}` : "Graph checks \xB7 No findings";
|
|
1810
|
+
},
|
|
1811
|
+
moreItems: (n) => `${n} more`,
|
|
1812
|
+
cameraTip: "Scroll / two fingers to pan \xB7 \u2318 + scroll or pinch to zoom",
|
|
1813
|
+
zoomIn: "Zoom in (+)",
|
|
1814
|
+
zoomOut: "Zoom out (-)",
|
|
1815
|
+
fit: "Fit (0)",
|
|
1816
|
+
legend: "Legend",
|
|
1817
|
+
legendPlainName: "Default",
|
|
1818
|
+
noColor: "no colour set",
|
|
1819
|
+
legendPlain: "Nodes without a color of their own: containers and placeholders, shaded by how much hangs under them",
|
|
1820
|
+
legendContainsName: "Contains",
|
|
1821
|
+
legendHint: "Hover an item: color, hide, size",
|
|
1822
|
+
legendContains: "Containment: one shade from light to dark, trunk thick, leaves thin",
|
|
1823
|
+
legendShow: "Show",
|
|
1824
|
+
legendHide: "Hide",
|
|
1825
|
+
legendHideTip: "Hide in the overview \u2014 still shown on hover, selection and search",
|
|
1826
|
+
legendColor: "Color",
|
|
1827
|
+
legendSize: "Size",
|
|
1828
|
+
legendReset: "Reset",
|
|
1829
|
+
node: "Node",
|
|
1830
|
+
edge: "Edge",
|
|
1831
|
+
back: "Back",
|
|
1832
|
+
showLess: "Show less",
|
|
1833
|
+
position: "Position",
|
|
1834
|
+
beforeSibling: "Before",
|
|
1835
|
+
lastSibling: "Last",
|
|
1836
|
+
inEdges: "In-edges",
|
|
1837
|
+
outEdges: "Out-edges",
|
|
1838
|
+
noDetails: "No details yet",
|
|
1839
|
+
close: "Close",
|
|
1840
|
+
addNode: "Add node\u2026",
|
|
1841
|
+
addEdge: "Add edge\u2026",
|
|
1842
|
+
relayout: "Re-layout",
|
|
1843
|
+
restructure: "Re-structure",
|
|
1844
|
+
edit: "Edit",
|
|
1845
|
+
editNode: "Edit node",
|
|
1846
|
+
newNode: "New node",
|
|
1847
|
+
newEdge: "New edge",
|
|
1848
|
+
editEdge: "Edit edge",
|
|
1849
|
+
clearField: "Clear",
|
|
1850
|
+
id: "id",
|
|
1851
|
+
idHint: "Unique, cannot be changed later",
|
|
1852
|
+
parent: "Inside",
|
|
1853
|
+
noParent: "Top level",
|
|
1854
|
+
source: "From",
|
|
1855
|
+
target: "To",
|
|
1856
|
+
kind: "Kind",
|
|
1857
|
+
edgeLabel: "Label",
|
|
1858
|
+
content: "Content",
|
|
1859
|
+
contentHint: "JSON",
|
|
1860
|
+
badJson: "Not valid JSON (an object is expected)",
|
|
1861
|
+
relations: "Edges",
|
|
1862
|
+
removeEdge: "Remove this edge",
|
|
1863
|
+
pick: "Search a node\u2026",
|
|
1864
|
+
cancel: "Cancel",
|
|
1865
|
+
save: "Save",
|
|
1866
|
+
create: "Create",
|
|
1867
|
+
remove: "Delete",
|
|
1868
|
+
confirmRemove: (n) => n ? `Delete, with its ${n} edge${n > 1 ? "s" : ""}?` : "Delete?",
|
|
1869
|
+
error: {
|
|
1870
|
+
"id-empty": "id is required",
|
|
1871
|
+
"id-taken": "This id is already used",
|
|
1872
|
+
"no-node": "Node not found",
|
|
1873
|
+
"no-parent": "Parent not found",
|
|
1874
|
+
cycle: "Cannot be placed inside itself",
|
|
1875
|
+
"invalid-position": "Choose a different node in the same children list",
|
|
1876
|
+
"order-invalid": "Order must be positive and unique among siblings (blank = unordered)",
|
|
1877
|
+
"has-children": "Has children \u2014 delete or move them first",
|
|
1878
|
+
"no-endpoint": "Pick both ends",
|
|
1879
|
+
"self-loop": "Both ends are the same node",
|
|
1880
|
+
"edge-exists": "This edge already exists",
|
|
1881
|
+
"no-edge": "Edge not found"
|
|
1998
1882
|
}
|
|
1999
|
-
return null;
|
|
2000
|
-
}
|
|
2001
|
-
var FADE_BASE = {
|
|
2002
|
-
cut: ENVELOPES.cut.base,
|
|
2003
|
-
out: ENVELOPES.out.base,
|
|
2004
|
-
in: ENVELOPES.in.base,
|
|
2005
|
-
graft: ENVELOPES.graft.base
|
|
2006
|
-
};
|
|
2007
|
-
var fadeAt = (name, sc, t) => {
|
|
2008
|
-
const e = ENVELOPES[name];
|
|
2009
|
-
let v = e.base;
|
|
2010
|
-
for (const l of e.legs) v += l.d * trackLin(sc[l.track], t);
|
|
2011
|
-
return v;
|
|
2012
1883
|
};
|
|
2013
|
-
function makeScore(spec, active = {}) {
|
|
2014
|
-
const on = [];
|
|
2015
|
-
if (active.leaf) on.push("cut", "snap", "leaf");
|
|
2016
|
-
if (active.move) on.push("move");
|
|
2017
|
-
if (active.present) on.push("present", "sprout", "graft");
|
|
2018
|
-
const lead = on.length ? Math.min(...on.map((n) => BEATS[n][0])) : 0;
|
|
2019
|
-
const span = Math.max(1e-6, 1 - lead);
|
|
2020
|
-
const cut = (v) => clamp01((v - lead) / span);
|
|
2021
|
-
const ease = {
|
|
2022
|
-
cut: (t) => t,
|
|
2023
|
-
// a cut is an instant, not a stretch
|
|
2024
|
-
snap: easeOutCubic,
|
|
2025
|
-
// spring off: fastest at first, stops on arrival
|
|
2026
|
-
leaf: easeDrift,
|
|
2027
|
-
// then drift steadily to the end
|
|
2028
|
-
move: spec.easing,
|
|
2029
|
-
// sigmoid
|
|
2030
|
-
present: (t) => t,
|
|
2031
|
-
// envelopes take no curve
|
|
2032
|
-
sprout: easeOutBack(spec.bounce),
|
|
2033
|
-
graft: (t) => t,
|
|
2034
|
-
open: easeInOutCubic,
|
|
2035
|
-
close: easeInOutCubic
|
|
2036
|
-
};
|
|
2037
|
-
const out = { span };
|
|
2038
|
-
for (const n of TRACK_NAMES) {
|
|
2039
|
-
out[n] = { from: cut(BEATS[n][0]), to: cut(BEATS[n][1]), ease: ease[n] };
|
|
2040
|
-
}
|
|
2041
|
-
return out;
|
|
2042
|
-
}
|
|
2043
|
-
function edgeTraffic(delta) {
|
|
2044
|
-
let i = 0, o = 0;
|
|
2045
|
-
for (const e of delta.model.edges) {
|
|
2046
|
-
const f = e.flags;
|
|
2047
|
-
if (!f) continue;
|
|
2048
|
-
if (f.includes(DIFF_FLAG.added) || f.includes(STEP_FLAG.added)) i++;
|
|
2049
|
-
else if (f.includes(DIFF_FLAG.removed) || f.includes(STEP_FLAG.removed)) o++;
|
|
2050
|
-
}
|
|
2051
|
-
return { in: i, out: o };
|
|
2052
|
-
}
|
|
2053
|
-
var NOT_OURS = /^(display|visibility|opacity|z-|transition-|events|text-events|min-zoomed)/;
|
|
2054
|
-
var GEOMETRY = /^(padding|shape|font-|text-|label|source-arrow-shape|target-arrow-shape)/;
|
|
2055
|
-
var SKIN_SIZE_PROPS = ["width", "height"];
|
|
2056
|
-
var RGB = /^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:[,/\s]+([\d.]+))?\s*\)$/;
|
|
2057
|
-
function asColor(v) {
|
|
2058
|
-
const m = RGB.exec(String(v));
|
|
2059
|
-
return m ? [+m[1], +m[2], +m[3], m[4] === void 0 ? 1 : +m[4]] : null;
|
|
2060
|
-
}
|
|
2061
|
-
function asNumber(v) {
|
|
2062
|
-
if (typeof v === "number") return Number.isFinite(v) ? v : null;
|
|
2063
|
-
const m = /^(-?[\d.]+)(px)?$/.exec(String(v).trim());
|
|
2064
|
-
if (!m) return null;
|
|
2065
|
-
const n = Number(m[1]);
|
|
2066
|
-
return Number.isFinite(n) ? n : null;
|
|
2067
|
-
}
|
|
2068
|
-
function diffSkinStyle(past, now) {
|
|
2069
|
-
const tween = [];
|
|
2070
|
-
const steps = {};
|
|
2071
|
-
for (const prop of Object.keys(now)) {
|
|
2072
|
-
if (/[A-Z]/.test(prop) || NOT_OURS.test(prop) || GEOMETRY.test(prop)) continue;
|
|
2073
|
-
const a = past[prop], b = now[prop];
|
|
2074
|
-
if (a === void 0 || a === b || String(a) === String(b)) continue;
|
|
2075
|
-
const [ca, cb] = [asColor(a), asColor(b)];
|
|
2076
|
-
if (ca && cb) {
|
|
2077
|
-
tween.push({ prop, from: ca, to: cb, color: true });
|
|
2078
|
-
continue;
|
|
2079
|
-
}
|
|
2080
|
-
const [na, nb] = [asNumber(a), asNumber(b)];
|
|
2081
|
-
if (na !== null && nb !== null) {
|
|
2082
|
-
tween.push({ prop, from: [na], to: [nb], color: false });
|
|
2083
|
-
continue;
|
|
2084
|
-
}
|
|
2085
|
-
steps[prop] = a;
|
|
2086
|
-
}
|
|
2087
|
-
return { tween, steps };
|
|
2088
|
-
}
|
|
2089
|
-
function sampleSkinStyle(tween, p) {
|
|
2090
|
-
const out = {};
|
|
2091
|
-
for (const t of tween) {
|
|
2092
|
-
const v = t.from.map((f, i) => f + (t.to[i] - f) * p);
|
|
2093
|
-
out[t.prop] = t.color ? `rgba(${Math.round(v[0])},${Math.round(v[1])},${Math.round(v[2])},${v[3]})` : v[0];
|
|
2094
|
-
}
|
|
2095
|
-
return out;
|
|
2096
|
-
}
|
|
2097
|
-
var MOVED_EPS = 1.5;
|
|
2098
|
-
var SNAP_KICK = 0.3;
|
|
2099
|
-
function anchorOf(id, seen, parentOf) {
|
|
2100
|
-
const walked = /* @__PURE__ */ new Set([id]);
|
|
2101
|
-
let cur = parentOf(id);
|
|
2102
|
-
while (cur && !walked.has(cur)) {
|
|
2103
|
-
if (seen(cur)) return cur;
|
|
2104
|
-
walked.add(cur);
|
|
2105
|
-
cur = parentOf(cur);
|
|
2106
|
-
}
|
|
2107
|
-
return void 0;
|
|
2108
|
-
}
|
|
2109
|
-
function planTransition(delta, from, union, opts = {}) {
|
|
2110
|
-
const skins = opts.skins ?? [];
|
|
2111
|
-
const spec = opts.spec ?? DEFAULT_ANIMATE;
|
|
2112
|
-
const drift = spec.drift;
|
|
2113
|
-
const items = [];
|
|
2114
|
-
const leaving = /* @__PURE__ */ new Set();
|
|
2115
|
-
const report = {
|
|
2116
|
-
total: 0,
|
|
2117
|
-
moved: 0,
|
|
2118
|
-
movedMedian: 0,
|
|
2119
|
-
entering: 0,
|
|
2120
|
-
leaving: 0,
|
|
2121
|
-
relocated: 0,
|
|
2122
|
-
converging: 0,
|
|
2123
|
-
restyled: skins.length,
|
|
2124
|
-
pieces: 0,
|
|
2125
|
-
edgesIn: 0,
|
|
2126
|
-
edgesOut: 0
|
|
2127
|
-
};
|
|
2128
|
-
const dists = [];
|
|
2129
|
-
if (delta) ({ in: report.edgesIn, out: report.edgesOut } = edgeTraffic(delta));
|
|
2130
|
-
const at = (id) => from[id] ?? union[id];
|
|
2131
|
-
const ids = Object.keys(union);
|
|
2132
|
-
const kindOf = (id) => {
|
|
2133
|
-
const k = delta?.byId.get(id)?.kind;
|
|
2134
|
-
if (k) return k;
|
|
2135
|
-
const p = opts.presence?.get(id);
|
|
2136
|
-
return p === "gone" ? "removed" : p === "new" ? "added" : void 0;
|
|
2137
|
-
};
|
|
2138
|
-
const parentOf = opts.parentOf ?? (() => {
|
|
2139
|
-
const model = /* @__PURE__ */ new Map();
|
|
2140
|
-
for (const n of delta?.model.nodes ?? []) if (n.parent) model.set(n.id, n.parent);
|
|
2141
|
-
const root = union[VIRTUAL_ROOT] ? VIRTUAL_ROOT : void 0;
|
|
2142
|
-
return (id) => model.get(id) ?? (id === root ? void 0 : root);
|
|
2143
|
-
})();
|
|
2144
|
-
const hub = { x: 0, y: 0 };
|
|
2145
|
-
for (const id of ids) {
|
|
2146
|
-
hub.x += union[id].x / ids.length;
|
|
2147
|
-
hub.y += union[id].y / ids.length;
|
|
2148
|
-
}
|
|
2149
|
-
const jitter = (seed) => {
|
|
2150
|
-
let h = 2166136261;
|
|
2151
|
-
for (let i = 0; i < seed.length; i++) {
|
|
2152
|
-
h ^= seed.charCodeAt(i);
|
|
2153
|
-
h = Math.imul(h, 16777619);
|
|
2154
|
-
}
|
|
2155
|
-
return (h >>> 0) % 2048 / 2048;
|
|
2156
|
-
};
|
|
2157
|
-
const bb = { x1: Infinity, y1: Infinity, x2: -Infinity, y2: -Infinity };
|
|
2158
|
-
for (const id of ids) {
|
|
2159
|
-
const q = union[id];
|
|
2160
|
-
bb.x1 = Math.min(bb.x1, q.x);
|
|
2161
|
-
bb.x2 = Math.max(bb.x2, q.x);
|
|
2162
|
-
bb.y1 = Math.min(bb.y1, q.y);
|
|
2163
|
-
bb.y2 = Math.max(bb.y2, q.y);
|
|
2164
|
-
}
|
|
2165
|
-
const span = Math.max(bb.x2 - bb.x1, bb.y2 - bb.y1) || 0;
|
|
2166
|
-
const cutIds = /* @__PURE__ */ new Set();
|
|
2167
|
-
for (const id of ids) if (kindOf(id) === "removed") cutIds.add(id);
|
|
2168
|
-
const topOf = /* @__PURE__ */ new Map();
|
|
2169
|
-
const climb = (id) => {
|
|
2170
|
-
const path = [];
|
|
2171
|
-
let cur = id;
|
|
2172
|
-
for (; ; ) {
|
|
2173
|
-
const hit = topOf.get(cur);
|
|
2174
|
-
if (hit) {
|
|
2175
|
-
for (const q of path) topOf.set(q, hit);
|
|
2176
|
-
return hit;
|
|
2177
|
-
}
|
|
2178
|
-
const pa = parentOf(cur);
|
|
2179
|
-
if (!pa || !cutIds.has(pa) || path.includes(cur)) break;
|
|
2180
|
-
path.push(cur);
|
|
2181
|
-
cur = pa;
|
|
2182
|
-
}
|
|
2183
|
-
for (const q of path) topOf.set(q, cur);
|
|
2184
|
-
topOf.set(cur, cur);
|
|
2185
|
-
return cur;
|
|
2186
|
-
};
|
|
2187
|
-
const crew = /* @__PURE__ */ new Map();
|
|
2188
|
-
for (const id of cutIds) {
|
|
2189
|
-
const top = climb(id);
|
|
2190
|
-
const list = crew.get(top);
|
|
2191
|
-
if (list) list.push(id);
|
|
2192
|
-
else crew.set(top, [id]);
|
|
2193
|
-
}
|
|
2194
|
-
const piece = /* @__PURE__ */ new Map();
|
|
2195
|
-
for (const [top, mates] of crew) {
|
|
2196
|
-
const pa = parentOf(top);
|
|
2197
|
-
const anchor = pa && union[pa] ? at(pa) : hub;
|
|
2198
|
-
const legs = [];
|
|
2199
|
-
let cx = 0, cy = 0;
|
|
2200
|
-
for (const m of mates) {
|
|
2201
|
-
cx += at(m).x / mates.length;
|
|
2202
|
-
cy += at(m).y / mates.length;
|
|
2203
|
-
}
|
|
2204
|
-
const r = Math.hypot(cx - anchor.x, cy - anchor.y);
|
|
2205
|
-
const ang = jitter(`${top}@`) * Math.PI * 2;
|
|
2206
|
-
const ux = r > 1e-6 ? (cx - anchor.x) / r : Math.cos(ang);
|
|
2207
|
-
const uy = r > 1e-6 ? (cy - anchor.y) / r : Math.sin(ang);
|
|
2208
|
-
const len = drift * span * (0.7 + 0.6 * jitter(top));
|
|
2209
|
-
const side = 0.32 * (jitter(`${top}~`) * 2 - 1);
|
|
2210
|
-
const [dx, dy] = [(ux - uy * side) * len, (uy + ux * side) * len];
|
|
2211
|
-
if (len > 0) {
|
|
2212
|
-
legs.push({ track: "snap", dx: dx * SNAP_KICK, dy: dy * SNAP_KICK });
|
|
2213
|
-
legs.push({ track: "leaf", dx: dx * (1 - SNAP_KICK), dy: dy * (1 - SNAP_KICK) });
|
|
2214
|
-
}
|
|
2215
|
-
piece.set(top, legs);
|
|
2216
|
-
}
|
|
2217
|
-
report.pieces = crew.size;
|
|
2218
|
-
for (const id of ids) {
|
|
2219
|
-
const to = union[id];
|
|
2220
|
-
const c = delta?.byId.get(id);
|
|
2221
|
-
const kind = kindOf(id);
|
|
2222
|
-
report.total++;
|
|
2223
|
-
if (kind === "removed" || kind === "merged") {
|
|
2224
|
-
leaving.add(id);
|
|
2225
|
-
report.leaving++;
|
|
2226
|
-
const base = at(id);
|
|
2227
|
-
const pair = kind === "merged" && c.pairId ? c.pairId : void 0;
|
|
2228
|
-
if (pair && union[pair]) {
|
|
2229
|
-
report.converging++;
|
|
2230
|
-
const pf = at(pair);
|
|
2231
|
-
items.push({
|
|
2232
|
-
id,
|
|
2233
|
-
x: base.x,
|
|
2234
|
-
y: base.y,
|
|
2235
|
-
legs: [
|
|
2236
|
-
{ track: "move", dx: union[pair].x - pf.x, dy: union[pair].y - pf.y },
|
|
2237
|
-
{ track: "leaf", dx: pf.x - base.x, dy: pf.y - base.y }
|
|
2238
|
-
]
|
|
2239
|
-
});
|
|
2240
|
-
continue;
|
|
2241
|
-
}
|
|
2242
|
-
items.push({ id, x: base.x, y: base.y, legs: piece.get(topOf.get(id) ?? id) ?? [] });
|
|
2243
|
-
continue;
|
|
2244
|
-
}
|
|
2245
|
-
if (kind === "added") {
|
|
2246
|
-
report.entering++;
|
|
2247
|
-
const anc = anchorOf(id, (q) => !!from[q], parentOf);
|
|
2248
|
-
if (anc && union[anc]) {
|
|
2249
|
-
const pf = from[anc];
|
|
2250
|
-
items.push({
|
|
2251
|
-
id,
|
|
2252
|
-
x: pf.x,
|
|
2253
|
-
y: pf.y,
|
|
2254
|
-
legs: [
|
|
2255
|
-
{ track: "move", dx: union[anc].x - pf.x, dy: union[anc].y - pf.y },
|
|
2256
|
-
{ track: "sprout", dx: to.x - union[anc].x, dy: to.y - union[anc].y }
|
|
2257
|
-
]
|
|
2258
|
-
});
|
|
2259
|
-
} else {
|
|
2260
|
-
items.push({ id, x: to.x, y: to.y, legs: [] });
|
|
2261
|
-
}
|
|
2262
|
-
continue;
|
|
2263
|
-
}
|
|
2264
|
-
if (kind === "moved") {
|
|
2265
|
-
report.relocated++;
|
|
2266
|
-
const a0 = at(id);
|
|
2267
|
-
items.push({ id, x: a0.x, y: a0.y, legs: [{ track: "move", dx: to.x - a0.x, dy: to.y - a0.y }] });
|
|
2268
|
-
continue;
|
|
2269
|
-
}
|
|
2270
|
-
const a = at(id);
|
|
2271
|
-
const d = Math.hypot(a.x - to.x, a.y - to.y);
|
|
2272
|
-
if (d > MOVED_EPS) {
|
|
2273
|
-
report.moved++;
|
|
2274
|
-
dists.push(d);
|
|
2275
|
-
}
|
|
2276
|
-
items.push({ id, x: a.x, y: a.y, legs: [{ track: "move", dx: to.x - a.x, dy: to.y - a.y }] });
|
|
2277
|
-
}
|
|
2278
|
-
if (dists.length) {
|
|
2279
|
-
dists.sort((x, y) => x - y);
|
|
2280
|
-
report.movedMedian = Math.round(dists[dists.length >> 1]);
|
|
2281
|
-
}
|
|
2282
|
-
const worth = report.moved + report.entering + report.leaving + report.relocated + report.restyled + report.edgesIn + report.edgesOut > 0;
|
|
2283
|
-
const score = makeScore(spec, {
|
|
2284
|
-
// A branch move counts on both sides: it is **one containment edge gone + one containment edge come**, so both cut and graft
|
|
2285
|
-
// have content. Counting only node additions and removals would judge the step "motion only", then empty-beat trimming
|
|
2286
|
-
// squeezes cut to zero width, and the old link would not "break" but "vanish within a frame".
|
|
2287
|
-
leaf: report.leaving + report.edgesOut + report.relocated > 0,
|
|
2288
|
-
move: report.moved + report.relocated > 0,
|
|
2289
|
-
present: report.entering + report.edgesIn + report.restyled + report.relocated > 0
|
|
2290
|
-
});
|
|
2291
|
-
return { items, skins, score, leaving, worth, report };
|
|
2292
|
-
}
|
|
2293
|
-
function planSkins(delta, prev, next, profile) {
|
|
2294
|
-
if (!delta || !prev) return [];
|
|
2295
|
-
const kids = (m) => {
|
|
2296
|
-
const s = /* @__PURE__ */ new Set();
|
|
2297
|
-
for (const n of m.nodes) if (n.parent) s.add(n.parent);
|
|
2298
|
-
return s;
|
|
2299
|
-
};
|
|
2300
|
-
const [pKids, nKids] = [kids(prev), kids(next)];
|
|
2301
|
-
const skin = (n) => n.flags?.some((f) => f.startsWith("gb-")) ? { ...n, flags: n.flags.filter((f) => !f.startsWith("gb-")) } : n;
|
|
2302
|
-
const out = [];
|
|
2303
|
-
for (const [oldId, unionId] of delta.resolved) {
|
|
2304
|
-
const a = prev.index.get(oldId), b = next.index.get(unionId);
|
|
2305
|
-
if (!a || !b) continue;
|
|
2306
|
-
const past = nodeClasses(skin(a), profile, { container: pKids.has(oldId) });
|
|
2307
|
-
const now = nodeClasses(skin(b), profile, { container: nKids.has(unionId) });
|
|
2308
|
-
if (past !== now) out.push({ id: unionId, past, now });
|
|
2309
|
-
}
|
|
2310
|
-
return out;
|
|
2311
|
-
}
|
|
2312
|
-
function leavingOf(delta) {
|
|
2313
|
-
const out = /* @__PURE__ */ new Set();
|
|
2314
|
-
for (const c of delta?.changes ?? []) if (c.kind === "removed" || c.kind === "merged") out.add(c.id);
|
|
2315
|
-
return out;
|
|
2316
|
-
}
|
|
2317
|
-
function sampleTransition(t, time) {
|
|
2318
|
-
const sc = t.score;
|
|
2319
|
-
const s = {};
|
|
2320
|
-
for (const n of TRACK_NAMES) s[n] = trackAt(sc[n], time);
|
|
2321
|
-
const pos = {};
|
|
2322
|
-
for (const it of t.items) {
|
|
2323
|
-
let { x, y } = it;
|
|
2324
|
-
for (const l of it.legs) {
|
|
2325
|
-
const k = s[l.track];
|
|
2326
|
-
x += l.dx * k;
|
|
2327
|
-
y += l.dy * k;
|
|
2328
|
-
}
|
|
2329
|
-
pos[it.id] = { x, y };
|
|
2330
|
-
}
|
|
2331
|
-
const fade = {};
|
|
2332
|
-
for (const n of FADE_NAMES) fade[n] = fadeAt(n, sc, time);
|
|
2333
|
-
return { pos, fade, open: s.open, close: s.close };
|
|
2334
|
-
}
|
|
2335
|
-
|
|
2336
|
-
// src/layout/diff-layout.ts
|
|
2337
|
-
function repOf(model, pos) {
|
|
2338
|
-
const idx = indexModel(model);
|
|
2339
|
-
const memo = /* @__PURE__ */ new Map();
|
|
2340
|
-
const walk = (id) => {
|
|
2341
|
-
const hit = memo.get(id);
|
|
2342
|
-
if (hit !== void 0) return hit;
|
|
2343
|
-
memo.set(id, null);
|
|
2344
|
-
const own = pos[id];
|
|
2345
|
-
let out = own ? { x: own.x, y: own.y } : null;
|
|
2346
|
-
if (!out) {
|
|
2347
|
-
let sx = 0, sy = 0, n = 0;
|
|
2348
|
-
for (const c of idx.childrenOf.get(id) ?? []) {
|
|
2349
|
-
const p = walk(c);
|
|
2350
|
-
if (p) {
|
|
2351
|
-
sx += p.x;
|
|
2352
|
-
sy += p.y;
|
|
2353
|
-
n++;
|
|
2354
|
-
}
|
|
2355
|
-
}
|
|
2356
|
-
out = n ? { x: sx / n, y: sy / n } : null;
|
|
2357
|
-
}
|
|
2358
|
-
memo.set(id, out);
|
|
2359
|
-
return out;
|
|
2360
|
-
};
|
|
2361
|
-
return walk;
|
|
2362
|
-
}
|
|
2363
|
-
function adjacency(m) {
|
|
2364
|
-
const adj = /* @__PURE__ */ new Map();
|
|
2365
|
-
const link = (a, b) => {
|
|
2366
|
-
let s = adj.get(a);
|
|
2367
|
-
if (!s) adj.set(a, s = /* @__PURE__ */ new Set());
|
|
2368
|
-
s.add(b);
|
|
2369
|
-
};
|
|
2370
|
-
for (const n of m.nodes) if (n.parent) {
|
|
2371
|
-
link(n.id, n.parent);
|
|
2372
|
-
link(n.parent, n.id);
|
|
2373
|
-
}
|
|
2374
|
-
for (const e of m.edges) {
|
|
2375
|
-
link(e.source, e.target);
|
|
2376
|
-
link(e.target, e.source);
|
|
2377
|
-
}
|
|
2378
|
-
return adj;
|
|
2379
|
-
}
|
|
2380
|
-
function bboxOf(ids, pos) {
|
|
2381
|
-
let x1 = Infinity, y1 = Infinity, x2 = -Infinity, y2 = -Infinity, n = 0;
|
|
2382
|
-
for (const id of ids) {
|
|
2383
|
-
const p = pos[id];
|
|
2384
|
-
if (!p) continue;
|
|
2385
|
-
n++;
|
|
2386
|
-
x1 = Math.min(x1, p.x);
|
|
2387
|
-
y1 = Math.min(y1, p.y);
|
|
2388
|
-
x2 = Math.max(x2, p.x);
|
|
2389
|
-
y2 = Math.max(y2, p.y);
|
|
2390
|
-
}
|
|
2391
|
-
return n ? { x1, y1, x2, y2, w: x2 - x1, h: y2 - y1 } : null;
|
|
2392
|
-
}
|
|
2393
|
-
function diffPositions(sides, posBefore, posAfter) {
|
|
2394
|
-
const out = { ...posAfter };
|
|
2395
|
-
const alive = sides.after.index;
|
|
2396
|
-
const ghostSet = /* @__PURE__ */ new Set();
|
|
2397
|
-
for (const n of sides.before.nodes) if (!alive.has(n.id)) ghostSet.add(n.id);
|
|
2398
|
-
if (!ghostSet.size) return out;
|
|
2399
|
-
const adj = adjacency(sides.before);
|
|
2400
|
-
const repB = repOf(sides.before, posBefore);
|
|
2401
|
-
const repA = repOf(sides.after, posAfter);
|
|
2402
|
-
const seen = /* @__PURE__ */ new Set();
|
|
2403
|
-
const parked = [];
|
|
2404
|
-
for (const n of sides.before.nodes) {
|
|
2405
|
-
const start = n.id;
|
|
2406
|
-
if (!ghostSet.has(start) || seen.has(start)) continue;
|
|
2407
|
-
const comp = [];
|
|
2408
|
-
const anchors = /* @__PURE__ */ new Set();
|
|
2409
|
-
const stack = [start];
|
|
2410
|
-
seen.add(start);
|
|
2411
|
-
while (stack.length) {
|
|
2412
|
-
const id = stack.pop();
|
|
2413
|
-
comp.push(id);
|
|
2414
|
-
for (const nb of adj.get(id) ?? []) {
|
|
2415
|
-
if (ghostSet.has(nb)) {
|
|
2416
|
-
if (!seen.has(nb)) {
|
|
2417
|
-
seen.add(nb);
|
|
2418
|
-
stack.push(nb);
|
|
2419
|
-
}
|
|
2420
|
-
} else if (alive.has(nb)) anchors.add(nb);
|
|
2421
|
-
}
|
|
2422
|
-
}
|
|
2423
|
-
let dx = 0, dy = 0, k = 0;
|
|
2424
|
-
for (const a of anchors) {
|
|
2425
|
-
const b = repB(a), f = repA(a);
|
|
2426
|
-
if (b && f) {
|
|
2427
|
-
dx += f.x - b.x;
|
|
2428
|
-
dy += f.y - b.y;
|
|
2429
|
-
k++;
|
|
2430
|
-
}
|
|
2431
|
-
}
|
|
2432
|
-
if (!k) {
|
|
2433
|
-
parked.push(comp);
|
|
2434
|
-
continue;
|
|
2435
|
-
}
|
|
2436
|
-
dx /= k;
|
|
2437
|
-
dy /= k;
|
|
2438
|
-
for (const g of comp) {
|
|
2439
|
-
const p = posBefore[g];
|
|
2440
|
-
if (p) out[g] = { x: p.x + dx, y: p.y + dy };
|
|
2441
|
-
}
|
|
2442
|
-
}
|
|
2443
|
-
if (parked.length) {
|
|
2444
|
-
const main = bboxOf(Object.keys(posAfter), posAfter);
|
|
2445
|
-
const ids = parked.flat();
|
|
2446
|
-
const block = bboxOf(ids, posBefore);
|
|
2447
|
-
const dx = block && main ? (main.x1 + main.x2) / 2 - (block.x1 + block.x2) / 2 : 0;
|
|
2448
|
-
const dy = block && main ? (main.y1 + main.y2) / 2 - (block.y1 + block.y2) / 2 : 0;
|
|
2449
|
-
for (const id of ids) {
|
|
2450
|
-
const p = posBefore[id];
|
|
2451
|
-
if (p) out[id] = { x: p.x + dx, y: p.y + dy };
|
|
2452
|
-
}
|
|
2453
|
-
}
|
|
2454
|
-
return out;
|
|
2455
|
-
}
|
|
2456
|
-
var DEFAULT_DIFF_LAYOUT = { rounds: 1, iterations: 12, snap: true };
|
|
2457
|
-
var EMPTY = /* @__PURE__ */ new Set();
|
|
2458
|
-
function split(pos, shared) {
|
|
2459
|
-
const a = {}, b = {};
|
|
2460
|
-
for (const [id, p] of Object.entries(pos)) (shared.has(id) ? a : b)[id] = p;
|
|
2461
|
-
return { shared: a, own: b };
|
|
2462
|
-
}
|
|
2463
|
-
async function solveDiffLayout(sides, base, solve, spec = {}) {
|
|
2464
|
-
const rounds = Math.max(0, Math.floor(spec.rounds ?? DEFAULT_DIFF_LAYOUT.rounds));
|
|
2465
|
-
const snap = spec.snap !== false;
|
|
2466
|
-
const shared = /* @__PURE__ */ new Set();
|
|
2467
|
-
for (const n of sides.before.nodes) if (sides.after.index.has(n.id)) shared.add(n.id);
|
|
2468
|
-
const seeded = diffPositions(sides, base.before, base.after);
|
|
2469
|
-
let x = split(seeded, shared).shared;
|
|
2470
|
-
let ownA = split(seeded, shared).own;
|
|
2471
|
-
let ownB = split(base.after, shared).own;
|
|
2472
|
-
for (const id of Object.keys(ownA)) if (sides.after.index.has(id)) delete ownA[id];
|
|
2473
|
-
for (const id of Object.keys(ownB)) if (sides.before.index.has(id)) delete ownB[id];
|
|
2474
|
-
const steps = [];
|
|
2475
|
-
let iter = Math.max(0, Math.floor(spec.iterations ?? DEFAULT_DIFF_LAYOUT.iterations));
|
|
2476
|
-
for (let k = 0; k < rounds && iter > 0; k++) {
|
|
2477
|
-
const side = k % 2 === 0 ? "before" : "after";
|
|
2478
|
-
const seed = { ...x, ...side === "before" ? ownA : ownB };
|
|
2479
|
-
const got = await solve(side, seed, iter, snap ? shared : EMPTY);
|
|
2480
|
-
const parts = split(got, shared);
|
|
2481
|
-
if (side === "before") ownA = parts.own;
|
|
2482
|
-
else ownB = parts.own;
|
|
2483
|
-
if (!snap) x = parts.shared;
|
|
2484
|
-
steps.push({ side, iterations: iter });
|
|
2485
|
-
iter = Math.floor(iter / 2);
|
|
2486
|
-
}
|
|
2487
|
-
return { past: { ...x, ...ownA }, now: { ...x, ...ownB }, steps };
|
|
2488
|
-
}
|
|
2489
1884
|
|
|
2490
1885
|
export {
|
|
1886
|
+
treeDeclarations,
|
|
1887
|
+
treeNodes,
|
|
1888
|
+
serializeTree,
|
|
2491
1889
|
EMPTY_MODEL,
|
|
2492
1890
|
buildModel,
|
|
2493
1891
|
mergeSlices,
|
|
@@ -2495,16 +1893,12 @@ export {
|
|
|
2495
1893
|
originsOfNode,
|
|
2496
1894
|
indexModel,
|
|
2497
1895
|
originsOf,
|
|
2498
|
-
parsePhysical,
|
|
2499
|
-
toPhysical,
|
|
2500
|
-
toBundle,
|
|
2501
|
-
validateStructure,
|
|
2502
|
-
defineProfile,
|
|
2503
|
-
defaultProfile,
|
|
2504
|
-
parseSources,
|
|
2505
|
-
validateModel,
|
|
2506
1896
|
DIFF_FLAG,
|
|
2507
1897
|
KEPT_FLAG,
|
|
1898
|
+
stable,
|
|
1899
|
+
edgeKey,
|
|
1900
|
+
edgeContent,
|
|
1901
|
+
edgeContentChanged,
|
|
2508
1902
|
diffModels,
|
|
2509
1903
|
unionSides,
|
|
2510
1904
|
STEP_FLAG,
|
|
@@ -2520,15 +1914,6 @@ export {
|
|
|
2520
1914
|
buildElements,
|
|
2521
1915
|
isNodeEl,
|
|
2522
1916
|
countByKind,
|
|
2523
|
-
FULL_VIEW,
|
|
2524
|
-
planeView,
|
|
2525
|
-
isFiltering,
|
|
2526
|
-
isNarrowing,
|
|
2527
|
-
originView,
|
|
2528
|
-
resolveView,
|
|
2529
|
-
parseQuery,
|
|
2530
|
-
queryMarker,
|
|
2531
|
-
searchNodes,
|
|
2532
1917
|
PLANE_HUES,
|
|
2533
1918
|
plateColors,
|
|
2534
1919
|
LIGHT_THEME,
|
|
@@ -2553,38 +1938,13 @@ export {
|
|
|
2553
1938
|
DIFF_COLORS,
|
|
2554
1939
|
diffStyle,
|
|
2555
1940
|
chromeStyle,
|
|
1941
|
+
HOVER_FADE_MS,
|
|
2556
1942
|
GK_CSS,
|
|
1943
|
+
sameEdge,
|
|
2557
1944
|
checkEdit,
|
|
2558
1945
|
edgesOf,
|
|
2559
1946
|
applyEdit,
|
|
2560
1947
|
applyEdits,
|
|
2561
1948
|
checkNativeEdit,
|
|
2562
|
-
|
|
2563
|
-
easeInOutCubic,
|
|
2564
|
-
easeOutBack,
|
|
2565
|
-
easeDrift,
|
|
2566
|
-
DEFAULT_ANIMATE,
|
|
2567
|
-
resolveSpec,
|
|
2568
|
-
TRACK_NAMES,
|
|
2569
|
-
trackLin,
|
|
2570
|
-
trackAt,
|
|
2571
|
-
SNAP_DIM,
|
|
2572
|
-
FADE_NAMES,
|
|
2573
|
-
ENVELOPES,
|
|
2574
|
-
edgeFade,
|
|
2575
|
-
FADE_BASE,
|
|
2576
|
-
fadeAt,
|
|
2577
|
-
makeScore,
|
|
2578
|
-
edgeTraffic,
|
|
2579
|
-
SKIN_SIZE_PROPS,
|
|
2580
|
-
diffSkinStyle,
|
|
2581
|
-
sampleSkinStyle,
|
|
2582
|
-
anchorOf,
|
|
2583
|
-
planTransition,
|
|
2584
|
-
planSkins,
|
|
2585
|
-
leavingOf,
|
|
2586
|
-
sampleTransition,
|
|
2587
|
-
diffPositions,
|
|
2588
|
-
DEFAULT_DIFF_LAYOUT,
|
|
2589
|
-
solveDiffLayout
|
|
1949
|
+
EN
|
|
2590
1950
|
};
|