@diagrammo/dgmo 0.47.0 → 0.48.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/advanced.js +11 -11
- package/dist/auto.js +16 -16
- package/dist/auto.mjs +41 -12
- package/dist/block.js +4 -4
- package/dist/{chunk-FNB3PNGF.js → chunk-7DTWEFUE.js} +3 -3
- package/dist/{chunk-2DXMZRWJ.js → chunk-B65G5DNL.js} +8 -1
- package/dist/{chunk-RZCF2VVM.js → chunk-B7JUCQUA.js} +3 -1
- package/dist/{chunk-DU7W62N5.js → chunk-FANX6UJR.js} +3 -3
- package/dist/{chunk-6FZYCKXB.js → chunk-HSH73DP6.js} +2 -2
- package/dist/{chunk-P4RH4OSP.js → chunk-ILKORZ3H.js} +2 -2
- package/dist/{chunk-Y5QGVTVC.js → chunk-JTSMEYIZ.js} +7 -3
- package/dist/{chunk-RCERWOJR.js → chunk-ODZVHU3R.js} +1 -2
- package/dist/{chunk-DZAQBW35.js → chunk-SGZYXELT.js} +3 -7
- package/dist/{chunk-CUVHQHZ7.js → chunk-THXCFRTU.js} +3 -3
- package/dist/{chunk-IH6ZMVQ5.js → chunk-UC7TFHUM.js} +29 -11
- package/dist/{chunk-EMS2SK26.js → chunk-ZBWMSD5N.js} +3 -1
- package/dist/cli.cjs +15 -15
- package/dist/{dgmo-router-DZCIDUO5.js → dgmo-router-X35VLZLM.js} +3 -3
- package/dist/element.js +16 -16
- package/dist/element.mjs +41 -12
- package/dist/{flowchart-renderer-ZAEOL4DX.js → flowchart-renderer-SNDSII4D.js} +2 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -4
- package/dist/{parser-FUSKFGZN.js → parser-2EWECDSA.js} +2 -2
- package/dist/{renderer-UWA5XS74.js → renderer-4JHRUBE6.js} +3 -3
- package/dist/{renderer-WZRREQ2P.js → renderer-5MYBMBYO.js} +2 -2
- package/dist/{renderer-TOCOVLHS.js → renderer-B2OMQIQG.js} +3 -3
- package/dist/{renderer-2XQQQ6QR.js → renderer-N43WR5GV.js} +3 -3
- package/dist/{renderer-T7YKC5VP.js → renderer-ZRNG54CW.js} +3 -3
- package/dist/{state-renderer-RFYHSP4K.js → state-renderer-B4DQBM6M.js} +2 -2
- package/package.json +23 -71
- package/dist/advanced.cjs +0 -71648
- package/dist/advanced.d.cts +0 -5719
- package/dist/auto.cjs +0 -70648
- package/dist/auto.d.cts +0 -54
- package/dist/block.cjs +0 -70208
- package/dist/block.d.cts +0 -115
- package/dist/editor.cjs +0 -526
- package/dist/editor.d.cts +0 -26
- package/dist/element.cjs +0 -70530
- package/dist/element.d.cts +0 -62
- package/dist/highlight.cjs +0 -852
- package/dist/highlight.d.cts +0 -49
- package/dist/index.cjs +0 -70491
- package/dist/index.d.cts +0 -160
- package/dist/pert.cjs +0 -325
- package/dist/pert.d.cts +0 -559
- package/dist/themes-1-CuKpeH.d.cts +0 -908
- package/src/advanced.ts +0 -873
- package/src/arc/parser.ts +0 -15
- package/src/arc/renderer.ts +0 -633
- package/src/auto/index.ts +0 -621
- package/src/auto/shared.ts +0 -370
- package/src/auto/styles.ts +0 -73
- package/src/block/layout.ts +0 -198
- package/src/block/parser.ts +0 -427
- package/src/block/renderer.ts +0 -484
- package/src/block/types.ts +0 -67
- package/src/boxes-and-lines/collapse.ts +0 -96
- package/src/boxes-and-lines/focus.ts +0 -257
- package/src/boxes-and-lines/label-placement.ts +0 -339
- package/src/boxes-and-lines/layout-grouped.ts +0 -912
- package/src/boxes-and-lines/layout-layered.ts +0 -722
- package/src/boxes-and-lines/layout-search.ts +0 -1678
- package/src/boxes-and-lines/layout.ts +0 -398
- package/src/boxes-and-lines/parser.ts +0 -1181
- package/src/boxes-and-lines/renderer.ts +0 -1465
- package/src/boxes-and-lines/types.ts +0 -66
- package/src/c4/layout.ts +0 -2441
- package/src/c4/parser.ts +0 -1158
- package/src/c4/renderer.ts +0 -2008
- package/src/c4/types.ts +0 -89
- package/src/chart-type-registry.ts +0 -529
- package/src/chart-types.ts +0 -225
- package/src/chart.ts +0 -685
- package/src/charts-d3/bar.ts +0 -338
- package/src/charts-d3/chord.ts +0 -140
- package/src/charts-d3/function.ts +0 -147
- package/src/charts-d3/funnel.ts +0 -104
- package/src/charts-d3/heatmap.ts +0 -145
- package/src/charts-d3/index.ts +0 -337
- package/src/charts-d3/interactions.ts +0 -477
- package/src/charts-d3/line.ts +0 -344
- package/src/charts-d3/mount.ts +0 -151
- package/src/charts-d3/pie.ts +0 -117
- package/src/charts-d3/polar.ts +0 -89
- package/src/charts-d3/radar.ts +0 -0
- package/src/charts-d3/sankey.ts +0 -0
- package/src/charts-d3/scatter.ts +0 -185
- package/src/charts-d3/shared.ts +0 -208
- package/src/class/layout.ts +0 -326
- package/src/class/parser.ts +0 -635
- package/src/class/renderer.ts +0 -793
- package/src/class/types.ts +0 -58
- package/src/cli-banner.ts +0 -106
- package/src/cli.ts +0 -1080
- package/src/colors-diagnostics.ts +0 -35
- package/src/colors.ts +0 -379
- package/src/completion-types.ts +0 -27
- package/src/completion.ts +0 -2668
- package/src/cycle/layout.ts +0 -1026
- package/src/cycle/parser.ts +0 -387
- package/src/cycle/renderer.ts +0 -653
- package/src/cycle/types.ts +0 -101
- package/src/d3.ts +0 -1434
- package/src/data-chart-parser.ts +0 -1007
- package/src/dgmo-router.ts +0 -296
- package/src/diagnostics-registry.ts +0 -108
- package/src/diagnostics.ts +0 -0
- package/src/dimensions.ts +0 -20
- package/src/directives-registry.ts +0 -396
- package/src/editor/dgmo.grammar +0 -76
- package/src/editor/dgmo.grammar.d.ts +0 -2
- package/src/editor/dgmo.grammar.js +0 -18
- package/src/editor/dgmo.grammar.terms.d.ts +0 -5
- package/src/editor/dgmo.grammar.terms.js +0 -35
- package/src/editor/highlight-api.ts +0 -596
- package/src/editor/highlight.ts +0 -36
- package/src/editor/index.ts +0 -27
- package/src/editor/keywords.ts +0 -128
- package/src/editor/tokens.ts +0 -30
- package/src/element/index.ts +0 -432
- package/src/embed/css.ts +0 -312
- package/src/embed/escape.ts +0 -15
- package/src/embed/index.ts +0 -280
- package/src/er/classify.ts +0 -228
- package/src/er/layout.ts +0 -530
- package/src/er/parser.ts +0 -750
- package/src/er/renderer.ts +0 -725
- package/src/er/types.ts +0 -52
- package/src/error-card.ts +0 -269
- package/src/event-line/diagnostics.ts +0 -117
- package/src/event-line/parser.ts +0 -643
- package/src/event-line/renderer.ts +0 -1742
- package/src/event-line/types.ts +0 -74
- package/src/fonts.ts +0 -3
- package/src/gantt/calculator.ts +0 -979
- package/src/gantt/parser.ts +0 -1641
- package/src/gantt/renderer.ts +0 -3787
- package/src/gantt/resolver.ts +0 -172
- package/src/gantt/types.ts +0 -206
- package/src/graph/diagnostics.ts +0 -64
- package/src/graph/edge-spline.ts +0 -29
- package/src/graph/flowchart-parser.ts +0 -759
- package/src/graph/flowchart-renderer.ts +0 -817
- package/src/graph/layout.ts +0 -472
- package/src/graph/notes.ts +0 -21
- package/src/graph/state-collapse.ts +0 -78
- package/src/graph/state-parser.ts +0 -574
- package/src/graph/state-renderer.ts +0 -653
- package/src/graph/types.ts +0 -65
- package/src/index.ts +0 -261
- package/src/infra/compute.ts +0 -1385
- package/src/infra/layout.ts +0 -888
- package/src/infra/parser.ts +0 -1234
- package/src/infra/renderer.ts +0 -2534
- package/src/infra/roles.ts +0 -75
- package/src/infra/types.ts +0 -216
- package/src/infra/validation.ts +0 -201
- package/src/journey-map/layout.ts +0 -490
- package/src/journey-map/parser.ts +0 -557
- package/src/journey-map/renderer.ts +0 -1580
- package/src/journey-map/types.ts +0 -47
- package/src/kanban/mutations.ts +0 -175
- package/src/kanban/parser.ts +0 -509
- package/src/kanban/renderer.ts +0 -1449
- package/src/kanban/types.ts +0 -39
- package/src/label-layout.ts +0 -368
- package/src/map/colorize.ts +0 -54
- package/src/map/completion.ts +0 -316
- package/src/map/context-labels.ts +0 -609
- package/src/map/data/PROVENANCE.json +0 -1
- package/src/map/data/README.md +0 -40
- package/src/map/data/airport-collisions.json +0 -1
- package/src/map/data/airports.json +0 -1
- package/src/map/data/gazetteer.json +0 -1
- package/src/map/data/lakes.json +0 -1
- package/src/map/data/mountain-ranges.json +0 -1
- package/src/map/data/na-lakes.json +0 -1
- package/src/map/data/na-land.json +0 -1
- package/src/map/data/region-names.json +0 -1
- package/src/map/data/rivers.json +0 -1
- package/src/map/data/types.ts +0 -121
- package/src/map/data/us-states.json +0 -1
- package/src/map/data/water-bodies.json +0 -1
- package/src/map/data/world-coarse.json +0 -1
- package/src/map/data/world-detail.json +0 -1
- package/src/map/diagnostics.ts +0 -134
- package/src/map/dimensions.ts +0 -150
- package/src/map/geo-query.ts +0 -295
- package/src/map/geo.ts +0 -438
- package/src/map/invert.ts +0 -111
- package/src/map/layout.ts +0 -5069
- package/src/map/legend-band.ts +0 -127
- package/src/map/load-data.ts +0 -186
- package/src/map/parser.ts +0 -783
- package/src/map/renderer.ts +0 -1445
- package/src/map/resolved-types.ts +0 -160
- package/src/map/resolver.ts +0 -1146
- package/src/map/types.ts +0 -194
- package/src/mindmap/collapse.ts +0 -67
- package/src/mindmap/layout.ts +0 -649
- package/src/mindmap/parser.ts +0 -430
- package/src/mindmap/renderer.ts +0 -637
- package/src/mindmap/text-wrap.ts +0 -218
- package/src/mindmap/types.ts +0 -56
- package/src/org/collapse.ts +0 -151
- package/src/org/layout.ts +0 -1262
- package/src/org/parser.ts +0 -519
- package/src/org/renderer.ts +0 -866
- package/src/org/resolver.ts +0 -636
- package/src/palettes/atlas.ts +0 -77
- package/src/palettes/blueprint.ts +0 -73
- package/src/palettes/catppuccin.ts +0 -84
- package/src/palettes/color-utils.ts +0 -443
- package/src/palettes/index.ts +0 -67
- package/src/palettes/nord.ts +0 -67
- package/src/palettes/registry.ts +0 -114
- package/src/palettes/slate.ts +0 -73
- package/src/palettes/tidewater.ts +0 -73
- package/src/palettes/tokyo-night.ts +0 -86
- package/src/palettes/types.ts +0 -88
- package/src/pert/analyzer.ts +0 -1183
- package/src/pert/diagnostics.ts +0 -110
- package/src/pert/index.ts +0 -43
- package/src/pert/internal.ts +0 -252
- package/src/pert/layout.ts +0 -971
- package/src/pert/monte-carlo.ts +0 -446
- package/src/pert/parser.ts +0 -1606
- package/src/pert/renderer.ts +0 -4009
- package/src/pert/share-normalize.ts +0 -62
- package/src/pert/types.ts +0 -604
- package/src/pyramid/parser.ts +0 -185
- package/src/pyramid/renderer.ts +0 -768
- package/src/pyramid/types.ts +0 -28
- package/src/quadrant/parser.ts +0 -18
- package/src/quadrant/renderer.ts +0 -638
- package/src/raci/diagnostics.ts +0 -213
- package/src/raci/index.ts +0 -23
- package/src/raci/mutations.ts +0 -321
- package/src/raci/parser.ts +0 -699
- package/src/raci/renderer.ts +0 -1627
- package/src/raci/types.ts +0 -82
- package/src/raci/variants.ts +0 -320
- package/src/render.ts +0 -268
- package/src/ring/parser.ts +0 -212
- package/src/ring/renderer.ts +0 -490
- package/src/ring/types.ts +0 -27
- package/src/sequence/collapse.ts +0 -174
- package/src/sequence/parser.ts +0 -1596
- package/src/sequence/participant-inference.ts +0 -152
- package/src/sequence/renderer.ts +0 -3168
- package/src/sequence/tag-resolution.ts +0 -164
- package/src/sharing.ts +0 -211
- package/src/sitemap/collapse.ts +0 -100
- package/src/sitemap/layout.ts +0 -925
- package/src/sitemap/parser.ts +0 -755
- package/src/sitemap/renderer.ts +0 -828
- package/src/sitemap/types.ts +0 -42
- package/src/slope/parser.ts +0 -18
- package/src/slope/renderer.ts +0 -378
- package/src/swimlane/diagnostics.ts +0 -94
- package/src/swimlane/layout.ts +0 -597
- package/src/swimlane/parser.ts +0 -613
- package/src/swimlane/renderer.ts +0 -681
- package/src/swimlane/types.ts +0 -151
- package/src/tech-radar/interactive.ts +0 -1129
- package/src/tech-radar/layout.ts +0 -197
- package/src/tech-radar/parser.ts +0 -436
- package/src/tech-radar/renderer.ts +0 -1239
- package/src/tech-radar/shared.ts +0 -151
- package/src/tech-radar/types.ts +0 -86
- package/src/themes.ts +0 -22
- package/src/timeline/parser.ts +0 -472
- package/src/timeline/renderer.ts +0 -3024
- package/src/timeline/types.ts +0 -33
- package/src/timeline/viz-parser.ts +0 -21
- package/src/treemap/diagnostics.ts +0 -62
- package/src/treemap/layout-radial.ts +0 -233
- package/src/treemap/layout.ts +0 -189
- package/src/treemap/parser.ts +0 -463
- package/src/treemap/renderer-radial.ts +0 -438
- package/src/treemap/renderer.ts +0 -572
- package/src/treemap/treemap-shared.ts +0 -309
- package/src/treemap/types.ts +0 -60
- package/src/utils/arrow-markers.ts +0 -51
- package/src/utils/arrows-diagnostics.ts +0 -62
- package/src/utils/arrows.ts +0 -227
- package/src/utils/brand.ts +0 -61
- package/src/utils/card.ts +0 -183
- package/src/utils/collapse-engine/tree-edges.ts +0 -115
- package/src/utils/collapse-engine/tree.ts +0 -117
- package/src/utils/d3-helpers.ts +0 -219
- package/src/utils/d3-types.ts +0 -9
- package/src/utils/description-helpers.ts +0 -38
- package/src/utils/duration.ts +0 -312
- package/src/utils/export-container.ts +0 -41
- package/src/utils/expr-eval.ts +0 -27
- package/src/utils/fit-canvas.ts +0 -64
- package/src/utils/hover-styles.ts +0 -673
- package/src/utils/inline-markdown.ts +0 -96
- package/src/utils/legend-constants.ts +0 -48
- package/src/utils/legend-d3.ts +0 -618
- package/src/utils/legend-integration.ts +0 -107
- package/src/utils/legend-layout.ts +0 -776
- package/src/utils/legend-svg.ts +0 -214
- package/src/utils/legend-types.ts +0 -272
- package/src/utils/name-normalize.ts +0 -163
- package/src/utils/note-box/constants.ts +0 -25
- package/src/utils/note-box/index.ts +0 -11
- package/src/utils/note-box/metrics.ts +0 -90
- package/src/utils/note-box/svg.ts +0 -331
- package/src/utils/notes/bounds.ts +0 -30
- package/src/utils/notes/build.ts +0 -131
- package/src/utils/notes/index.ts +0 -18
- package/src/utils/notes/model.ts +0 -19
- package/src/utils/notes/parse.ts +0 -131
- package/src/utils/notes/place.ts +0 -177
- package/src/utils/notes/resolve.ts +0 -88
- package/src/utils/number-format.ts +0 -36
- package/src/utils/parsing.ts +0 -953
- package/src/utils/reserved-key-registry.ts +0 -239
- package/src/utils/safe-href.ts +0 -38
- package/src/utils/scaling.ts +0 -97
- package/src/utils/svg-embed.ts +0 -251
- package/src/utils/tag-groups.ts +0 -607
- package/src/utils/text-measure.ts +0 -122
- package/src/utils/time-ticks.ts +0 -253
- package/src/utils/title-constants.ts +0 -24
- package/src/utils/visual-conventions.ts +0 -61
- package/src/utils/wrapped-desc.ts +0 -87
- package/src/venn/parser.ts +0 -18
- package/src/venn/renderer.ts +0 -1047
- package/src/version-control/diagnostics.ts +0 -67
- package/src/version-control/parser.ts +0 -544
- package/src/version-control/renderer.ts +0 -724
- package/src/version-control/types.ts +0 -100
- package/src/visualizations/parse.ts +0 -1560
- package/src/visualizations/types.ts +0 -262
- package/src/wireframe/layout.ts +0 -479
- package/src/wireframe/parser.ts +0 -1114
- package/src/wireframe/renderer.ts +0 -1318
- package/src/wireframe/types.ts +0 -110
- package/src/wordcloud/parser.ts +0 -18
- package/src/wordcloud/renderer.ts +0 -357
package/src/sitemap/renderer.ts
DELETED
|
@@ -1,828 +0,0 @@
|
|
|
1
|
-
// ============================================================
|
|
2
|
-
// Sitemap Diagram SVG Renderer
|
|
3
|
-
// ============================================================
|
|
4
|
-
|
|
5
|
-
import { tagAttrKey } from '../utils/tag-groups';
|
|
6
|
-
import * as d3Selection from 'd3-selection';
|
|
7
|
-
import * as d3Shape from 'd3-shape';
|
|
8
|
-
import { FONT_FAMILY } from '../fonts';
|
|
9
|
-
import type { PaletteColors } from '../palettes';
|
|
10
|
-
import {
|
|
11
|
-
contrastText,
|
|
12
|
-
mix,
|
|
13
|
-
shapeFill,
|
|
14
|
-
themeBaseBg,
|
|
15
|
-
} from '../palettes/color-utils';
|
|
16
|
-
import type { ParsedSitemap } from './types';
|
|
17
|
-
import type { SitemapLayoutResult, SitemapLegendGroup } from './layout';
|
|
18
|
-
import { renderInlineText } from '../utils/inline-markdown';
|
|
19
|
-
import { preprocessDescriptionLine } from '../utils/description-helpers';
|
|
20
|
-
import { measureText } from '../utils/text-measure';
|
|
21
|
-
import {
|
|
22
|
-
LEGEND_HEIGHT,
|
|
23
|
-
LEGEND_GROUP_GAP,
|
|
24
|
-
LEGEND_EYE_SIZE,
|
|
25
|
-
LEGEND_EYE_GAP,
|
|
26
|
-
EYE_OPEN_PATH,
|
|
27
|
-
EYE_CLOSED_PATH,
|
|
28
|
-
} from '../utils/legend-constants';
|
|
29
|
-
import { renderIntegratedLegend } from '../utils/legend-integration';
|
|
30
|
-
import { getMaxLegendReservedHeight } from '../utils/legend-layout';
|
|
31
|
-
import { ScaleContext } from '../utils/scaling';
|
|
32
|
-
import { renderNodeCard } from '../utils/card';
|
|
33
|
-
|
|
34
|
-
// ============================================================
|
|
35
|
-
// Constants
|
|
36
|
-
// ============================================================
|
|
37
|
-
|
|
38
|
-
const DIAGRAM_PADDING = 20;
|
|
39
|
-
const MAX_SCALE = 3;
|
|
40
|
-
import { TITLE_FONT_SIZE, TITLE_FONT_WEIGHT } from '../utils/title-constants';
|
|
41
|
-
const TITLE_HEIGHT = 30;
|
|
42
|
-
// Shared card / group / collapse constants (Story 111.1). sitemap matches every
|
|
43
|
-
// convention default, so it imports the full set.
|
|
44
|
-
import {
|
|
45
|
-
LABEL_FONT_SIZE,
|
|
46
|
-
META_FONT_SIZE,
|
|
47
|
-
META_LINE_HEIGHT,
|
|
48
|
-
HEADER_HEIGHT,
|
|
49
|
-
SEPARATOR_GAP,
|
|
50
|
-
EDGE_STROKE_WIDTH,
|
|
51
|
-
NODE_STROKE_WIDTH,
|
|
52
|
-
CARD_RADIUS,
|
|
53
|
-
CONTAINER_RADIUS,
|
|
54
|
-
CONTAINER_LABEL_FONT_SIZE,
|
|
55
|
-
CONTAINER_META_FONT_SIZE,
|
|
56
|
-
CONTAINER_META_LINE_HEIGHT,
|
|
57
|
-
CONTAINER_HEADER_HEIGHT,
|
|
58
|
-
COLLAPSE_BAR_HEIGHT,
|
|
59
|
-
} from '../utils/visual-conventions';
|
|
60
|
-
const ARROWHEAD_W = 10;
|
|
61
|
-
const ARROWHEAD_H = 7;
|
|
62
|
-
const EDGE_LABEL_FONT_SIZE = 11;
|
|
63
|
-
|
|
64
|
-
const LEGEND_FIXED_GAP = 8; // gap between fixed legend and scaled diagram — local, not shared
|
|
65
|
-
|
|
66
|
-
// ============================================================
|
|
67
|
-
// Color helpers
|
|
68
|
-
// ============================================================
|
|
69
|
-
|
|
70
|
-
function nodeFill(
|
|
71
|
-
palette: PaletteColors,
|
|
72
|
-
isDark: boolean,
|
|
73
|
-
nodeColor?: string,
|
|
74
|
-
solid?: boolean
|
|
75
|
-
): string {
|
|
76
|
-
const color = nodeColor ?? palette.primary;
|
|
77
|
-
return shapeFill(palette, color, isDark, {
|
|
78
|
-
...(solid !== undefined && { solid }),
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function nodeStroke(_palette: PaletteColors, nodeColor?: string): string {
|
|
83
|
-
return nodeColor ?? _palette.primary;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function containerFill(
|
|
87
|
-
palette: PaletteColors,
|
|
88
|
-
isDark: boolean,
|
|
89
|
-
nodeColor?: string
|
|
90
|
-
): string {
|
|
91
|
-
if (nodeColor) {
|
|
92
|
-
return mix(nodeColor, themeBaseBg(palette, isDark), 10);
|
|
93
|
-
}
|
|
94
|
-
return mix(palette.surface, palette.bg, 40);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function containerStroke(palette: PaletteColors, nodeColor?: string): string {
|
|
98
|
-
return nodeColor ?? palette.textMuted;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// ============================================================
|
|
102
|
-
// Curve generator
|
|
103
|
-
// ============================================================
|
|
104
|
-
|
|
105
|
-
const lineGenerator = d3Shape
|
|
106
|
-
.line<{ x: number; y: number }>()
|
|
107
|
-
.x((d) => d.x)
|
|
108
|
-
.y((d) => d.y)
|
|
109
|
-
.curve(d3Shape.curveBasis);
|
|
110
|
-
|
|
111
|
-
const lineGeneratorLinear = d3Shape
|
|
112
|
-
.line<{ x: number; y: number }>()
|
|
113
|
-
.x((d) => d.x)
|
|
114
|
-
.y((d) => d.y)
|
|
115
|
-
.curve(d3Shape.curveLinear);
|
|
116
|
-
|
|
117
|
-
// ============================================================
|
|
118
|
-
// Main Renderer
|
|
119
|
-
// ============================================================
|
|
120
|
-
|
|
121
|
-
type GSelection = d3Selection.Selection<SVGGElement, unknown, null, undefined>;
|
|
122
|
-
|
|
123
|
-
export function renderSitemap(
|
|
124
|
-
container: HTMLDivElement,
|
|
125
|
-
parsed: ParsedSitemap,
|
|
126
|
-
layout: SitemapLayoutResult,
|
|
127
|
-
palette: PaletteColors,
|
|
128
|
-
isDark: boolean,
|
|
129
|
-
onClickItem?: (lineNumber: number) => void,
|
|
130
|
-
exportDims?: { width?: number; height?: number },
|
|
131
|
-
activeTagGroup?: string | null,
|
|
132
|
-
hiddenAttributes?: Set<string>,
|
|
133
|
-
exportMode?: boolean
|
|
134
|
-
): void {
|
|
135
|
-
// Clear existing content
|
|
136
|
-
d3Selection.select(container).selectAll(':not([data-d3-tooltip])').remove();
|
|
137
|
-
|
|
138
|
-
const width = exportDims?.width ?? container.clientWidth;
|
|
139
|
-
const height = exportDims?.height ?? container.clientHeight;
|
|
140
|
-
if (width <= 0 || height <= 0) return;
|
|
141
|
-
|
|
142
|
-
const ctx = ScaleContext.identity();
|
|
143
|
-
|
|
144
|
-
const sDiagramPadding = ctx.aesthetic(DIAGRAM_PADDING);
|
|
145
|
-
const sLabelFontSize = ctx.text(LABEL_FONT_SIZE);
|
|
146
|
-
const sMetaFontSize = ctx.text(META_FONT_SIZE);
|
|
147
|
-
const sMetaLineHeight = ctx.structural(META_LINE_HEIGHT);
|
|
148
|
-
const sHeaderHeight = ctx.structural(HEADER_HEIGHT);
|
|
149
|
-
const sSeparatorGap = ctx.structural(SEPARATOR_GAP);
|
|
150
|
-
const sEdgeStrokeWidth = ctx.structural(EDGE_STROKE_WIDTH);
|
|
151
|
-
const sNodeStrokeWidth = ctx.structural(NODE_STROKE_WIDTH);
|
|
152
|
-
const sEdgeLabelFontSize = ctx.text(EDGE_LABEL_FONT_SIZE);
|
|
153
|
-
const sContainerLabelFontSize = ctx.text(CONTAINER_LABEL_FONT_SIZE);
|
|
154
|
-
const sContainerMetaFontSize = ctx.text(CONTAINER_META_FONT_SIZE);
|
|
155
|
-
const sContainerMetaLineHeight = ctx.structural(CONTAINER_META_LINE_HEIGHT);
|
|
156
|
-
const sContainerHeaderHeight = ctx.structural(CONTAINER_HEADER_HEIGHT);
|
|
157
|
-
const sTitleFontSize = ctx.text(TITLE_FONT_SIZE);
|
|
158
|
-
const sTitleHeight = ctx.structural(TITLE_HEIGHT);
|
|
159
|
-
const sCollapseBarHeight = ctx.structural(COLLAPSE_BAR_HEIGHT);
|
|
160
|
-
const sLegendFixedGap = ctx.aesthetic(LEGEND_FIXED_GAP);
|
|
161
|
-
|
|
162
|
-
const hasLegend = layout.legend.length > 0;
|
|
163
|
-
|
|
164
|
-
const layoutLegendShift = LEGEND_HEIGHT + LEGEND_GROUP_GAP;
|
|
165
|
-
const showTitle = !!parsed.title && parsed.options['no-title'] !== 'on';
|
|
166
|
-
const fixedLegend = !exportDims && hasLegend;
|
|
167
|
-
const fixedTitle = fixedLegend && showTitle;
|
|
168
|
-
const fixedTitleH = fixedTitle ? sTitleHeight : 0;
|
|
169
|
-
const sLegendHeight = ctx.structural(
|
|
170
|
-
fixedLegend
|
|
171
|
-
? getMaxLegendReservedHeight(
|
|
172
|
-
{
|
|
173
|
-
groups: parsed.tagGroups,
|
|
174
|
-
position: {
|
|
175
|
-
placement: 'top-center',
|
|
176
|
-
titleRelation: 'below-title',
|
|
177
|
-
},
|
|
178
|
-
mode: 'preview',
|
|
179
|
-
capsulePillAddonWidth: LEGEND_EYE_SIZE + LEGEND_EYE_GAP,
|
|
180
|
-
},
|
|
181
|
-
width
|
|
182
|
-
)
|
|
183
|
-
: LEGEND_HEIGHT
|
|
184
|
-
);
|
|
185
|
-
const legendReserveH = fixedLegend ? sLegendHeight + sLegendFixedGap : 0;
|
|
186
|
-
const fixedReserveTop = fixedTitleH + legendReserveH;
|
|
187
|
-
const fixedReserveBottom = 0;
|
|
188
|
-
const titleOffset = !fixedTitle && showTitle ? sTitleHeight : 0;
|
|
189
|
-
|
|
190
|
-
const diagramW = layout.width;
|
|
191
|
-
let diagramH = layout.height + titleOffset;
|
|
192
|
-
if (fixedLegend) {
|
|
193
|
-
diagramH -= layoutLegendShift;
|
|
194
|
-
}
|
|
195
|
-
const availH =
|
|
196
|
-
height - sDiagramPadding * 2 - fixedReserveTop - fixedReserveBottom;
|
|
197
|
-
const scaleX = (width - sDiagramPadding * 2) / diagramW;
|
|
198
|
-
const scaleY = availH / diagramH;
|
|
199
|
-
const scale = Math.min(MAX_SCALE, scaleX, scaleY);
|
|
200
|
-
|
|
201
|
-
const scaledW = diagramW * scale;
|
|
202
|
-
const offsetX = (width - scaledW) / 2;
|
|
203
|
-
const offsetY = sDiagramPadding + fixedReserveTop;
|
|
204
|
-
|
|
205
|
-
const svg = d3Selection
|
|
206
|
-
.select(container)
|
|
207
|
-
.append('svg')
|
|
208
|
-
.attr('width', width)
|
|
209
|
-
.attr('height', height)
|
|
210
|
-
.attr('viewBox', `0 0 ${width} ${height}`)
|
|
211
|
-
.attr('preserveAspectRatio', 'xMidYMin meet')
|
|
212
|
-
.style('font-family', FONT_FAMILY);
|
|
213
|
-
|
|
214
|
-
if (ctx.isBelowFloor) {
|
|
215
|
-
svg.attr('width', '100%');
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// Defs: arrowhead markers
|
|
219
|
-
const defs = svg.append('defs');
|
|
220
|
-
|
|
221
|
-
// Default arrowhead
|
|
222
|
-
defs
|
|
223
|
-
.append('marker')
|
|
224
|
-
.attr('id', 'sm-arrow')
|
|
225
|
-
.attr('viewBox', `0 0 ${ARROWHEAD_W} ${ARROWHEAD_H}`)
|
|
226
|
-
.attr('refX', ARROWHEAD_W)
|
|
227
|
-
.attr('refY', ARROWHEAD_H / 2)
|
|
228
|
-
.attr('markerWidth', ARROWHEAD_W)
|
|
229
|
-
.attr('markerHeight', ARROWHEAD_H)
|
|
230
|
-
.attr('orient', 'auto')
|
|
231
|
-
.append('polygon')
|
|
232
|
-
.attr('points', `0,0 ${ARROWHEAD_W},${ARROWHEAD_H / 2} 0,${ARROWHEAD_H}`)
|
|
233
|
-
.attr('fill', palette.textMuted);
|
|
234
|
-
|
|
235
|
-
// Edges have no color slot (spec §1.7); keep empty set so the marker-setup
|
|
236
|
-
// loop is a no-op but the symbol stays available for future color sources.
|
|
237
|
-
const edgeColors = new Set<string>();
|
|
238
|
-
for (const color of edgeColors) {
|
|
239
|
-
const id = `sm-arrow-${color.replace('#', '')}`;
|
|
240
|
-
defs
|
|
241
|
-
.append('marker')
|
|
242
|
-
.attr('id', id)
|
|
243
|
-
.attr('viewBox', `0 0 ${ARROWHEAD_W} ${ARROWHEAD_H}`)
|
|
244
|
-
.attr('refX', ARROWHEAD_W)
|
|
245
|
-
.attr('refY', ARROWHEAD_H / 2)
|
|
246
|
-
.attr('markerWidth', ARROWHEAD_W)
|
|
247
|
-
.attr('markerHeight', ARROWHEAD_H)
|
|
248
|
-
.attr('orient', 'auto')
|
|
249
|
-
.append('polygon')
|
|
250
|
-
.attr('points', `0,0 ${ARROWHEAD_W},${ARROWHEAD_H / 2} 0,${ARROWHEAD_H}`)
|
|
251
|
-
.attr('fill', color);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// Main content group with scale/translate
|
|
255
|
-
const mainG = svg
|
|
256
|
-
.append('g')
|
|
257
|
-
.attr('transform', `translate(${offsetX}, ${offsetY}) scale(${scale})`);
|
|
258
|
-
|
|
259
|
-
if (!fixedTitle && showTitle) {
|
|
260
|
-
const titleEl = mainG
|
|
261
|
-
.append('text')
|
|
262
|
-
.attr('x', diagramW / 2)
|
|
263
|
-
.attr('y', sTitleFontSize)
|
|
264
|
-
.attr('text-anchor', 'middle')
|
|
265
|
-
.attr('fill', palette.text)
|
|
266
|
-
.attr('font-size', sTitleFontSize)
|
|
267
|
-
.attr('font-weight', TITLE_FONT_WEIGHT)
|
|
268
|
-
.attr('class', 'sitemap-title chart-title');
|
|
269
|
-
|
|
270
|
-
if (parsed.titleLineNumber) {
|
|
271
|
-
titleEl.attr('data-line-number', parsed.titleLineNumber);
|
|
272
|
-
if (onClickItem) {
|
|
273
|
-
titleEl
|
|
274
|
-
.style('cursor', 'pointer')
|
|
275
|
-
.on('click', () => onClickItem(parsed.titleLineNumber!));
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
titleEl.text(parsed.title);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
// Content group (offset by title; pull up by legendShift when legend is fixed)
|
|
283
|
-
const contentShift = fixedLegend ? -layoutLegendShift : 0;
|
|
284
|
-
const contentG = mainG
|
|
285
|
-
.append('g')
|
|
286
|
-
.attr('transform', `translate(0, ${titleOffset + contentShift})`);
|
|
287
|
-
|
|
288
|
-
// Build display name map + tag color lookup from tag groups
|
|
289
|
-
const displayNames = new Map<string, string>();
|
|
290
|
-
// tagColors: "groupkey:valueLower" → hex color
|
|
291
|
-
const tagColors = new Map<string, string>();
|
|
292
|
-
for (const group of parsed.tagGroups) {
|
|
293
|
-
displayNames.set(tagAttrKey(group.name), group.name);
|
|
294
|
-
for (const entry of group.entries) {
|
|
295
|
-
tagColors.set(
|
|
296
|
-
`${tagAttrKey(group.name)}:${entry.value.toLowerCase()}`,
|
|
297
|
-
entry.color
|
|
298
|
-
);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
// --- Render containers (bottom layer) ---
|
|
303
|
-
for (const c of layout.containers) {
|
|
304
|
-
const cG = contentG
|
|
305
|
-
.append('g')
|
|
306
|
-
.attr('transform', `translate(${c.x}, ${c.y})`)
|
|
307
|
-
.attr('class', 'sitemap-container')
|
|
308
|
-
.attr('data-line-number', String(c.lineNumber)) as GSelection;
|
|
309
|
-
|
|
310
|
-
if (c.hasChildren) {
|
|
311
|
-
cG.attr('data-node-toggle', c.nodeId)
|
|
312
|
-
.attr('tabindex', '0')
|
|
313
|
-
.attr('role', 'button')
|
|
314
|
-
.attr('aria-expanded', String(!c.hiddenCount))
|
|
315
|
-
.attr('aria-label', c.label);
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
if (onClickItem) {
|
|
319
|
-
cG.style('cursor', 'pointer').on('click', () =>
|
|
320
|
-
onClickItem(c.lineNumber)
|
|
321
|
-
);
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
// Tag metadata for legend hover dimming
|
|
325
|
-
if (activeTagGroup) {
|
|
326
|
-
const tagKey = tagAttrKey(activeTagGroup);
|
|
327
|
-
const tagVal = c.tagMetadata[tagKey];
|
|
328
|
-
if (tagVal) cG.attr(`data-tag-${tagKey}`, tagVal.toLowerCase());
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
const fill = containerFill(palette, isDark, c.color);
|
|
332
|
-
const stroke = containerStroke(palette, c.color);
|
|
333
|
-
|
|
334
|
-
cG.append('rect')
|
|
335
|
-
.attr('x', 0)
|
|
336
|
-
.attr('y', 0)
|
|
337
|
-
.attr('width', c.width)
|
|
338
|
-
.attr('height', c.height)
|
|
339
|
-
.attr('rx', CONTAINER_RADIUS)
|
|
340
|
-
.attr('fill', fill)
|
|
341
|
-
.attr('stroke', stroke)
|
|
342
|
-
.attr('stroke-opacity', 0.35)
|
|
343
|
-
.attr('stroke-width', sNodeStrokeWidth);
|
|
344
|
-
|
|
345
|
-
cG.append('text')
|
|
346
|
-
.attr('x', c.width / 2)
|
|
347
|
-
.attr('y', sContainerHeaderHeight / 2 + sContainerLabelFontSize / 2 - 2)
|
|
348
|
-
.attr('text-anchor', 'middle')
|
|
349
|
-
.attr('fill', palette.text)
|
|
350
|
-
.attr('font-size', sContainerLabelFontSize)
|
|
351
|
-
.attr('font-weight', 'bold')
|
|
352
|
-
.text(c.label);
|
|
353
|
-
|
|
354
|
-
const metaEntries = Object.entries(c.metadata);
|
|
355
|
-
if (metaEntries.length > 0) {
|
|
356
|
-
const metaDisplayKeys = metaEntries.map(
|
|
357
|
-
([k]) => displayNames.get(k) ?? k
|
|
358
|
-
);
|
|
359
|
-
const maxKeyWidth = Math.max(
|
|
360
|
-
...metaDisplayKeys.map((k) =>
|
|
361
|
-
measureText(`${k}: `, sContainerMetaFontSize)
|
|
362
|
-
)
|
|
363
|
-
);
|
|
364
|
-
const valueX = 10 + maxKeyWidth;
|
|
365
|
-
const metaStartY = sContainerHeaderHeight + sContainerMetaFontSize - 2;
|
|
366
|
-
|
|
367
|
-
for (let i = 0; i < metaEntries.length; i++) {
|
|
368
|
-
// In-bounds by loop guard.
|
|
369
|
-
const [key, value] = metaEntries[i]!;
|
|
370
|
-
const displayKey = metaDisplayKeys[i];
|
|
371
|
-
const rowY = metaStartY + i * sContainerMetaLineHeight;
|
|
372
|
-
const valColor =
|
|
373
|
-
tagColors.get(`${key}:${value.toLowerCase()}`) ?? palette.text;
|
|
374
|
-
|
|
375
|
-
cG.append('text')
|
|
376
|
-
.attr('x', 10)
|
|
377
|
-
.attr('y', rowY)
|
|
378
|
-
.attr('fill', palette.textMuted)
|
|
379
|
-
.attr('font-size', sContainerMetaFontSize)
|
|
380
|
-
.text(`${displayKey}: `);
|
|
381
|
-
|
|
382
|
-
cG.append('text')
|
|
383
|
-
.attr('x', valueX)
|
|
384
|
-
.attr('y', rowY)
|
|
385
|
-
.attr('fill', valColor)
|
|
386
|
-
.attr('font-size', sContainerMetaFontSize)
|
|
387
|
-
.text(value);
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
if (!exportDims && c.hiddenCount && c.hiddenCount > 0) {
|
|
392
|
-
const clipId = `clip-${c.nodeId}`;
|
|
393
|
-
cG.append('clipPath')
|
|
394
|
-
.attr('id', clipId)
|
|
395
|
-
.append('rect')
|
|
396
|
-
.attr('width', c.width)
|
|
397
|
-
.attr('height', c.height)
|
|
398
|
-
.attr('rx', CONTAINER_RADIUS);
|
|
399
|
-
cG.append('rect')
|
|
400
|
-
.attr('y', c.height - sCollapseBarHeight)
|
|
401
|
-
.attr('width', c.width)
|
|
402
|
-
.attr('height', sCollapseBarHeight)
|
|
403
|
-
.attr('fill', stroke)
|
|
404
|
-
.attr('clip-path', `url(#${clipId})`)
|
|
405
|
-
.attr('class', 'sitemap-collapse-bar');
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
// --- Render edges (middle layer) ---
|
|
410
|
-
for (const edge of layout.edges) {
|
|
411
|
-
if (edge.points.length < 2) continue;
|
|
412
|
-
|
|
413
|
-
const edgeG = contentG
|
|
414
|
-
.append('g')
|
|
415
|
-
.attr('class', 'sitemap-edge-group')
|
|
416
|
-
.attr('data-line-number', String(edge.lineNumber))
|
|
417
|
-
// Endpoint node ids for baked-CSS connection-highlight (hover-styles.ts).
|
|
418
|
-
.attr('data-from', edge.sourceId)
|
|
419
|
-
.attr('data-to', edge.targetId);
|
|
420
|
-
|
|
421
|
-
const edgeColor = palette.textMuted;
|
|
422
|
-
const markerId = 'sm-arrow';
|
|
423
|
-
|
|
424
|
-
const gen = edge.deferred ? lineGeneratorLinear : lineGenerator;
|
|
425
|
-
const pathD = gen(edge.points);
|
|
426
|
-
if (pathD) {
|
|
427
|
-
edgeG
|
|
428
|
-
.append('path')
|
|
429
|
-
.attr('d', pathD)
|
|
430
|
-
.attr('fill', 'none')
|
|
431
|
-
.attr('stroke', edgeColor)
|
|
432
|
-
.attr('stroke-width', sEdgeStrokeWidth)
|
|
433
|
-
.attr('marker-end', `url(#${markerId})`)
|
|
434
|
-
.attr('class', 'sitemap-edge');
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
// Edge label with background badge
|
|
438
|
-
if (edge.label && edge.points.length >= 2) {
|
|
439
|
-
const mid = edge.points[Math.floor(edge.points.length / 2)]!;
|
|
440
|
-
const labelW = measureText(edge.label, sEdgeLabelFontSize) + 10;
|
|
441
|
-
const labelH = sEdgeLabelFontSize + 6;
|
|
442
|
-
|
|
443
|
-
edgeG
|
|
444
|
-
.append('rect')
|
|
445
|
-
.attr('x', mid.x - labelW / 2)
|
|
446
|
-
.attr('y', mid.y - labelH / 2 - 1)
|
|
447
|
-
.attr('width', labelW)
|
|
448
|
-
.attr('height', labelH)
|
|
449
|
-
.attr('rx', 3)
|
|
450
|
-
.attr('fill', palette.bg)
|
|
451
|
-
.attr('opacity', 0.85)
|
|
452
|
-
.attr('class', 'sitemap-edge-label-bg');
|
|
453
|
-
|
|
454
|
-
edgeG
|
|
455
|
-
.append('text')
|
|
456
|
-
.attr('x', mid.x)
|
|
457
|
-
.attr('y', mid.y + 4)
|
|
458
|
-
.attr('text-anchor', 'middle')
|
|
459
|
-
.attr('fill', edgeColor)
|
|
460
|
-
.attr('font-size', sEdgeLabelFontSize)
|
|
461
|
-
.attr('class', 'sitemap-edge-label')
|
|
462
|
-
.text(edge.label);
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
// --- Render page cards (top layer) ---
|
|
467
|
-
for (const node of layout.nodes) {
|
|
468
|
-
const nodeG = contentG
|
|
469
|
-
.append('g')
|
|
470
|
-
.attr('transform', `translate(${node.x - node.width / 2}, ${node.y})`)
|
|
471
|
-
.attr('class', 'sitemap-node')
|
|
472
|
-
.attr('data-line-number', String(node.lineNumber))
|
|
473
|
-
.attr('data-node-id', node.id) as GSelection;
|
|
474
|
-
|
|
475
|
-
if (node.hasChildren) {
|
|
476
|
-
nodeG
|
|
477
|
-
.attr('data-node-toggle', node.id)
|
|
478
|
-
.attr('tabindex', '0')
|
|
479
|
-
.attr('role', 'button')
|
|
480
|
-
.attr('aria-expanded', String(!node.hiddenCount));
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
if (onClickItem) {
|
|
484
|
-
nodeG
|
|
485
|
-
.style('cursor', 'pointer')
|
|
486
|
-
.on('click', () => onClickItem(node.lineNumber));
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
// Tag metadata for legend hover dimming
|
|
490
|
-
if (activeTagGroup) {
|
|
491
|
-
const tagKey = tagAttrKey(activeTagGroup);
|
|
492
|
-
const tagVal = node.tagMetadata[tagKey];
|
|
493
|
-
if (tagVal) nodeG.attr(`data-tag-${tagKey}`, tagVal.toLowerCase());
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
const solid = parsed.options['solid-fill'] === 'on';
|
|
497
|
-
const fill = nodeFill(palette, isDark, node.color, solid);
|
|
498
|
-
const stroke = nodeStroke(palette, node.color);
|
|
499
|
-
|
|
500
|
-
// Card background + label via the shared card door (Story 111.1). sitemap's
|
|
501
|
-
// metadata, description lines, and collapse bar diverge from the convention
|
|
502
|
-
// (different meta baseline; semi-transparent collapse bar + "+N" badge), so
|
|
503
|
-
// they stay inline below — see conventions §1/§3 deviations log.
|
|
504
|
-
const labelColor = contrastText(
|
|
505
|
-
fill,
|
|
506
|
-
palette.textOnFillLight,
|
|
507
|
-
palette.textOnFillDark
|
|
508
|
-
);
|
|
509
|
-
renderNodeCard(nodeG, {
|
|
510
|
-
width: node.width,
|
|
511
|
-
height: node.height,
|
|
512
|
-
rx: CARD_RADIUS,
|
|
513
|
-
fill,
|
|
514
|
-
stroke,
|
|
515
|
-
strokeWidth: sNodeStrokeWidth,
|
|
516
|
-
label: node.label,
|
|
517
|
-
labelColor,
|
|
518
|
-
labelFontSize: sLabelFontSize,
|
|
519
|
-
headerHeight: sHeaderHeight,
|
|
520
|
-
});
|
|
521
|
-
|
|
522
|
-
const metaEntries = Object.entries(node.metadata);
|
|
523
|
-
if (metaEntries.length > 0) {
|
|
524
|
-
nodeG
|
|
525
|
-
.append('line')
|
|
526
|
-
.attr('x1', 0)
|
|
527
|
-
.attr('y1', sHeaderHeight)
|
|
528
|
-
.attr('x2', node.width)
|
|
529
|
-
.attr('y2', sHeaderHeight)
|
|
530
|
-
.attr('stroke', solid ? labelColor : stroke)
|
|
531
|
-
.attr('stroke-opacity', 0.3);
|
|
532
|
-
|
|
533
|
-
const metaDisplayKeys = metaEntries.map(
|
|
534
|
-
([k]) => displayNames.get(k) ?? k
|
|
535
|
-
);
|
|
536
|
-
const maxKeyWidth = Math.max(
|
|
537
|
-
...metaDisplayKeys.map((k) => measureText(`${k}: `, sMetaFontSize))
|
|
538
|
-
);
|
|
539
|
-
const valueX = 10 + maxKeyWidth;
|
|
540
|
-
|
|
541
|
-
for (let i = 0; i < metaEntries.length; i++) {
|
|
542
|
-
// In-bounds by loop guard.
|
|
543
|
-
const [key, value] = metaEntries[i]!;
|
|
544
|
-
const displayKey = metaDisplayKeys[i];
|
|
545
|
-
const rowY =
|
|
546
|
-
sHeaderHeight + sSeparatorGap + (i + 1) * sMetaLineHeight - 4;
|
|
547
|
-
const tagColor = tagColors.get(`${key}:${value.toLowerCase()}`);
|
|
548
|
-
const valColor = solid ? labelColor : (tagColor ?? labelColor);
|
|
549
|
-
|
|
550
|
-
nodeG
|
|
551
|
-
.append('text')
|
|
552
|
-
.attr('x', 10)
|
|
553
|
-
.attr('y', rowY)
|
|
554
|
-
.attr('fill', labelColor)
|
|
555
|
-
.attr('font-size', sMetaFontSize)
|
|
556
|
-
.text(`${displayKey}:`);
|
|
557
|
-
|
|
558
|
-
nodeG
|
|
559
|
-
.append('text')
|
|
560
|
-
.attr('x', valueX)
|
|
561
|
-
.attr('y', rowY)
|
|
562
|
-
.attr('fill', valColor)
|
|
563
|
-
.attr('font-size', sMetaFontSize)
|
|
564
|
-
.text(value);
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
// Description lines (after metadata)
|
|
569
|
-
if (node.description && node.description.length > 0) {
|
|
570
|
-
const metaCount = Object.keys(node.metadata).length;
|
|
571
|
-
const sepY =
|
|
572
|
-
metaCount > 0
|
|
573
|
-
? sHeaderHeight + sSeparatorGap + metaCount * sMetaLineHeight
|
|
574
|
-
: sHeaderHeight;
|
|
575
|
-
nodeG
|
|
576
|
-
.append('line')
|
|
577
|
-
.attr('x1', 0)
|
|
578
|
-
.attr('y1', sepY)
|
|
579
|
-
.attr('x2', node.width)
|
|
580
|
-
.attr('y2', sepY)
|
|
581
|
-
.attr('stroke', solid ? labelColor : stroke)
|
|
582
|
-
.attr('stroke-opacity', 0.3);
|
|
583
|
-
|
|
584
|
-
const descStartY =
|
|
585
|
-
sHeaderHeight + sSeparatorGap + metaCount * sMetaLineHeight;
|
|
586
|
-
for (let di = 0; di < node.description.length; di++) {
|
|
587
|
-
const processed = preprocessDescriptionLine(node.description[di]!);
|
|
588
|
-
const rowY = descStartY + (di + 1) * sMetaLineHeight - 4;
|
|
589
|
-
const textEl = nodeG
|
|
590
|
-
.append('text')
|
|
591
|
-
.attr('x', 10)
|
|
592
|
-
.attr('y', rowY)
|
|
593
|
-
.attr('fill', labelColor)
|
|
594
|
-
.attr('font-size', sMetaFontSize);
|
|
595
|
-
renderInlineText(textEl, processed, palette, sMetaFontSize);
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
if (!exportDims && node.hiddenCount && node.hiddenCount > 0) {
|
|
600
|
-
const clipId = `clip-${node.id}`;
|
|
601
|
-
nodeG
|
|
602
|
-
.append('clipPath')
|
|
603
|
-
.attr('id', clipId)
|
|
604
|
-
.append('rect')
|
|
605
|
-
.attr('width', node.width)
|
|
606
|
-
.attr('height', node.height)
|
|
607
|
-
.attr('rx', CARD_RADIUS);
|
|
608
|
-
nodeG
|
|
609
|
-
.append('rect')
|
|
610
|
-
.attr('y', node.height - sCollapseBarHeight)
|
|
611
|
-
.attr('width', node.width)
|
|
612
|
-
.attr('height', sCollapseBarHeight)
|
|
613
|
-
.attr('fill', solid ? labelColor : (node.color ?? palette.primary))
|
|
614
|
-
.attr('opacity', 0.5)
|
|
615
|
-
.attr('clip-path', `url(#${clipId})`);
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
// --- Render legend ---
|
|
620
|
-
if (exportDims && hasLegend) {
|
|
621
|
-
// Export mode: render inside the scaled content group
|
|
622
|
-
renderLegend(
|
|
623
|
-
contentG,
|
|
624
|
-
layout.legend,
|
|
625
|
-
palette,
|
|
626
|
-
isDark,
|
|
627
|
-
activeTagGroup,
|
|
628
|
-
undefined,
|
|
629
|
-
hiddenAttributes,
|
|
630
|
-
exportMode
|
|
631
|
-
);
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
// --- Fixed title + legend (appended AFTER mainG so they paint on top
|
|
635
|
-
// and receive pointer events without being blocked by scaled content) ---
|
|
636
|
-
if (fixedTitle) {
|
|
637
|
-
const titleEl = svg
|
|
638
|
-
.append('text')
|
|
639
|
-
.attr('x', width / 2)
|
|
640
|
-
.attr('y', sDiagramPadding + sTitleFontSize)
|
|
641
|
-
.attr('text-anchor', 'middle')
|
|
642
|
-
.attr('fill', palette.text)
|
|
643
|
-
.attr('font-size', sTitleFontSize)
|
|
644
|
-
.attr('font-weight', TITLE_FONT_WEIGHT)
|
|
645
|
-
.attr('class', 'sitemap-title chart-title')
|
|
646
|
-
.style('font-family', FONT_FAMILY);
|
|
647
|
-
|
|
648
|
-
if (parsed.titleLineNumber) {
|
|
649
|
-
titleEl.attr('data-line-number', parsed.titleLineNumber);
|
|
650
|
-
if (onClickItem) {
|
|
651
|
-
titleEl
|
|
652
|
-
.style('cursor', 'pointer')
|
|
653
|
-
.on('click', () => onClickItem(parsed.titleLineNumber!));
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
titleEl.text(parsed.title!);
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
if (fixedLegend) {
|
|
661
|
-
const legendParent = svg
|
|
662
|
-
.append('g')
|
|
663
|
-
.attr('class', 'sitemap-legend-fixed')
|
|
664
|
-
.attr('transform', `translate(0, ${sDiagramPadding + fixedTitleH})`);
|
|
665
|
-
if (activeTagGroup) {
|
|
666
|
-
legendParent.attr('data-legend-active', tagAttrKey(activeTagGroup));
|
|
667
|
-
}
|
|
668
|
-
renderLegend(
|
|
669
|
-
legendParent,
|
|
670
|
-
layout.legend,
|
|
671
|
-
palette,
|
|
672
|
-
isDark,
|
|
673
|
-
activeTagGroup,
|
|
674
|
-
width,
|
|
675
|
-
hiddenAttributes,
|
|
676
|
-
exportMode
|
|
677
|
-
);
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
// ============================================================
|
|
682
|
-
// Legend rendering
|
|
683
|
-
// ============================================================
|
|
684
|
-
|
|
685
|
-
function renderLegend(
|
|
686
|
-
parent: d3Selection.Selection<SVGGElement, unknown, null, undefined>,
|
|
687
|
-
legendGroups: readonly SitemapLegendGroup[],
|
|
688
|
-
palette: PaletteColors,
|
|
689
|
-
isDark: boolean,
|
|
690
|
-
activeTagGroup?: string | null,
|
|
691
|
-
fixedWidth?: number,
|
|
692
|
-
hiddenAttributes?: Set<string>,
|
|
693
|
-
exportMode?: boolean
|
|
694
|
-
): void {
|
|
695
|
-
if (legendGroups.length === 0) return;
|
|
696
|
-
|
|
697
|
-
const groups = legendGroups.map((g) => ({
|
|
698
|
-
name: g.name,
|
|
699
|
-
entries: g.entries.map((e) => ({ value: e.value, color: e.color })),
|
|
700
|
-
}));
|
|
701
|
-
|
|
702
|
-
const isFixedMode = fixedWidth != null;
|
|
703
|
-
const eyeAddonWidth = isFixedMode ? LEGEND_EYE_SIZE + LEGEND_EYE_GAP : 0;
|
|
704
|
-
|
|
705
|
-
const containerWidth =
|
|
706
|
-
// In-bounds by length === 0 early return at top of function.
|
|
707
|
-
fixedWidth ?? legendGroups[0]!.x + (legendGroups[0]!.width ?? 200);
|
|
708
|
-
|
|
709
|
-
const legendHandle = renderIntegratedLegend(parent, {
|
|
710
|
-
groups,
|
|
711
|
-
activeGroup: activeTagGroup ?? null,
|
|
712
|
-
mode: exportMode ? 'export' : 'preview',
|
|
713
|
-
capsulePillAddonWidth: eyeAddonWidth,
|
|
714
|
-
palette,
|
|
715
|
-
isDark,
|
|
716
|
-
width: containerWidth,
|
|
717
|
-
});
|
|
718
|
-
|
|
719
|
-
parent.selectAll('[data-legend-group]').classed('sitemap-legend-group', true);
|
|
720
|
-
|
|
721
|
-
// Inject eye icons into active group capsules (fixed/app mode only)
|
|
722
|
-
if (isFixedMode) {
|
|
723
|
-
const computedLayout = legendHandle.getLayout();
|
|
724
|
-
if (computedLayout.activeCapsule?.addonX != null) {
|
|
725
|
-
const capsule = computedLayout.activeCapsule;
|
|
726
|
-
const groupKey = tagAttrKey(capsule.groupName);
|
|
727
|
-
const isHidden = hiddenAttributes?.has(groupKey) ?? false;
|
|
728
|
-
|
|
729
|
-
const activeGroupEl = parent.select(`[data-legend-group="${groupKey}"]`);
|
|
730
|
-
if (!activeGroupEl.empty()) {
|
|
731
|
-
const eyeX = capsule.addonX!;
|
|
732
|
-
const eyeY = (LEGEND_HEIGHT - LEGEND_EYE_SIZE) / 2;
|
|
733
|
-
const hitPad = 6;
|
|
734
|
-
|
|
735
|
-
const eyeG = activeGroupEl
|
|
736
|
-
.append('g')
|
|
737
|
-
.attr('class', 'sitemap-legend-eye')
|
|
738
|
-
.attr('data-legend-visibility', groupKey)
|
|
739
|
-
.style('cursor', 'pointer')
|
|
740
|
-
.attr('opacity', isHidden ? 0.4 : 0.7);
|
|
741
|
-
|
|
742
|
-
eyeG
|
|
743
|
-
.append('rect')
|
|
744
|
-
.attr('x', eyeX - hitPad)
|
|
745
|
-
.attr('y', eyeY - hitPad)
|
|
746
|
-
.attr('width', LEGEND_EYE_SIZE + hitPad * 2)
|
|
747
|
-
.attr('height', LEGEND_EYE_SIZE + hitPad * 2)
|
|
748
|
-
.attr('fill', 'transparent')
|
|
749
|
-
.attr('pointer-events', 'all');
|
|
750
|
-
|
|
751
|
-
eyeG
|
|
752
|
-
.append('path')
|
|
753
|
-
.attr('d', isHidden ? EYE_CLOSED_PATH : EYE_OPEN_PATH)
|
|
754
|
-
.attr('transform', `translate(${eyeX}, ${eyeY})`)
|
|
755
|
-
.attr('fill', 'none')
|
|
756
|
-
.attr('stroke', palette.textMuted)
|
|
757
|
-
.attr('stroke-width', 1.2)
|
|
758
|
-
.attr('stroke-linecap', 'round')
|
|
759
|
-
.attr('stroke-linejoin', 'round');
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
// ============================================================
|
|
766
|
-
// Export convenience function
|
|
767
|
-
// ============================================================
|
|
768
|
-
|
|
769
|
-
export async function renderSitemapForExport(
|
|
770
|
-
content: string,
|
|
771
|
-
theme: 'light' | 'dark' | 'transparent',
|
|
772
|
-
palette?: PaletteColors
|
|
773
|
-
): Promise<string> {
|
|
774
|
-
const { parseSitemap } = await import('./parser');
|
|
775
|
-
const { layoutSitemap } = await import('./layout');
|
|
776
|
-
const { getPalette } = await import('../palettes');
|
|
777
|
-
const isDark = theme === 'dark';
|
|
778
|
-
const effectivePalette =
|
|
779
|
-
palette ?? (isDark ? getPalette('nord').dark : getPalette('nord').light);
|
|
780
|
-
|
|
781
|
-
const parsed = parseSitemap(content, effectivePalette);
|
|
782
|
-
if (parsed.error || parsed.roots.length === 0) return '';
|
|
783
|
-
|
|
784
|
-
const sitemapLayout = layoutSitemap(parsed, undefined, null, undefined, true);
|
|
785
|
-
|
|
786
|
-
const PADDING = 20;
|
|
787
|
-
const titleOffset = parsed.title ? 30 : 0;
|
|
788
|
-
const exportWidth = sitemapLayout.width + PADDING * 2;
|
|
789
|
-
const exportHeight = sitemapLayout.height + PADDING * 2 + titleOffset;
|
|
790
|
-
|
|
791
|
-
const container = document.createElement('div');
|
|
792
|
-
container.style.width = `${exportWidth}px`;
|
|
793
|
-
container.style.height = `${exportHeight}px`;
|
|
794
|
-
container.style.position = 'absolute';
|
|
795
|
-
container.style.left = '-9999px';
|
|
796
|
-
document.body.appendChild(container);
|
|
797
|
-
|
|
798
|
-
renderSitemap(
|
|
799
|
-
container,
|
|
800
|
-
parsed,
|
|
801
|
-
sitemapLayout,
|
|
802
|
-
effectivePalette,
|
|
803
|
-
isDark,
|
|
804
|
-
undefined,
|
|
805
|
-
{
|
|
806
|
-
width: exportWidth,
|
|
807
|
-
height: exportHeight,
|
|
808
|
-
}
|
|
809
|
-
);
|
|
810
|
-
|
|
811
|
-
const svgEl = container.querySelector('svg');
|
|
812
|
-
if (!svgEl) {
|
|
813
|
-
document.body.removeChild(container);
|
|
814
|
-
return '';
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
if (theme === 'transparent') {
|
|
818
|
-
svgEl.style.background = 'none';
|
|
819
|
-
} else if (!svgEl.style.background) {
|
|
820
|
-
svgEl.style.background = effectivePalette.bg;
|
|
821
|
-
}
|
|
822
|
-
svgEl.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
|
|
823
|
-
svgEl.style.fontFamily = FONT_FAMILY;
|
|
824
|
-
|
|
825
|
-
const svgHtml = svgEl.outerHTML;
|
|
826
|
-
document.body.removeChild(container);
|
|
827
|
-
return svgHtml;
|
|
828
|
-
}
|