@webpieces/nx-webpieces-rules 0.4.577 → 0.4.579
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/package.json +6 -6
- package/src/lib/graph-responsibilities.d.ts +1 -1
- package/src/lib/graph-responsibilities.js +1 -1
- package/src/lib/graph-responsibilities.js.map +1 -1
- package/src/lib/graph-visualizer.client.d.ts +55 -0
- package/src/lib/graph-visualizer.client.js +209 -116
- package/src/lib/graph-visualizer.client.js.map +1 -0
- package/src/lib/graph-visualizer.d.ts +28 -5
- package/src/lib/graph-visualizer.js +41 -8
- package/src/lib/graph-visualizer.js.map +1 -1
- package/src/lib/runtime-visualizer.client.d.ts +51 -0
- package/src/lib/runtime-visualizer.client.js +139 -102
- package/src/lib/runtime-visualizer.client.js.map +1 -0
- package/src/lib/runtime-visualizer.js +4 -3
- package/src/lib/runtime-visualizer.js.map +1 -1
- package/src/lib/runtime-viz-theme.d.ts +1 -1
- package/src/lib/runtime-viz-theme.js +2 -2
- package/src/lib/runtime-viz-theme.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpieces/nx-webpieces-rules",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.579",
|
|
4
4
|
"description": "Nx-specific webpieces validation rules and graph tooling. Bundles all @webpieces rule packages with Nx graph validators and an inference plugin.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
"README.md"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@webpieces/ai-hook-rules": "0.4.
|
|
22
|
-
"@webpieces/code-rules": "0.4.
|
|
23
|
-
"@webpieces/eslint-rules": "0.4.
|
|
24
|
-
"@webpieces/pr-gate": "0.4.
|
|
25
|
-
"@webpieces/rules-config": "0.4.
|
|
21
|
+
"@webpieces/ai-hook-rules": "0.4.579",
|
|
22
|
+
"@webpieces/code-rules": "0.4.579",
|
|
23
|
+
"@webpieces/eslint-rules": "0.4.579",
|
|
24
|
+
"@webpieces/pr-gate": "0.4.579",
|
|
25
|
+
"@webpieces/rules-config": "0.4.579",
|
|
26
26
|
"madge": "8.0.0"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Each card carries `data-node="<shortName>"` matching the graph box's title, so
|
|
10
10
|
* the page script can filter the list to just the locked box's chain (see
|
|
11
|
-
* graph-visualizer.client.
|
|
11
|
+
* graph-visualizer.client.ts). The summary paragraph is the `shortDescription`
|
|
12
12
|
* already on each graph entry; the expanded body is the rendered markdown file.
|
|
13
13
|
*/
|
|
14
14
|
import type { EnhancedGraph } from './graph-sorter';
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Each card carries `data-node="<shortName>"` matching the graph box's title, so
|
|
11
11
|
* the page script can filter the list to just the locked box's chain (see
|
|
12
|
-
* graph-visualizer.client.
|
|
12
|
+
* graph-visualizer.client.ts). The summary paragraph is the `shortDescription`
|
|
13
13
|
* already on each graph entry; the expanded body is the rendered markdown file.
|
|
14
14
|
*/
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-responsibilities.js","sourceRoot":"","sources":["../../../../../../packages/tooling/nx-webpieces-rules/src/lib/graph-responsibilities.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;;AAEH,+CAAyB;AACzB,mDAA6B;AAE7B,+CAA2C;AAE3C;;;;GAIG;AACH,MAAM,iBAAiB;IACnB,MAAM,GAAG,KAAK,CAAC;CAClB;AAED,MAAa,wBAAwB;IAChB,KAAK,GAAG,IAAI,wBAAU,EAAE,CAAC;IAE1C;;;;OAIG;IACH,eAAe,CAAC,KAAoB,EAAE,aAAqB;QACvD,MAAM,QA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G,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAAC,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC;QAAC,CAAC;QAC9D,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;IACnE,CAAC;IAED;;;OAGG;IACK,YAAY,CAAC,OAAe;QAChC,OAAO,OAAO;aACT,OAAO,CAAC,YAAY,EAAE,iBAAiB,CAAC;aACxC,OAAO,CAAC,kBAAkB,EAAE,qBAAqB,CAAC;aAClD,OAAO,CAAC,sBAAsB,EAAE,eAAe,CAAC,CAAC;IAC1D,CAAC;IAED;;OAEG;IACK,UAAU,CAAC,IAAY;QAC3B,OAAO,IAAI;aACN,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;aACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;aACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;aACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACjC,CAAC;CACJ;AA1HD,4DA0HC","sourcesContent":["/**\n * Responsibilities Section\n *\n * Renders every module's full `responsibilities.md` as a collapsible card below\n * the dependency graph in architecture/dependencies.html. Cards are ordered by\n * dependency level HIGH → LOW (top-level apps first, deepest libs last) so a\n * reader scrolls from the runnable servers/clients down into the libraries.\n *\n * Each card carries `data-node=\"<shortName>\"` matching the graph box's title, so\n * the page script can filter the list to just the locked box's chain (see\n * graph-visualizer.client.js). The summary paragraph is the `shortDescription`\n * already on each graph entry; the expanded body is the rendered markdown file.\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport type { EnhancedGraph, GraphEntry } from './graph-sorter';\nimport { GraphNames } from './graph-names';\n\n/**\n * Mutable cursor state threaded through the markdown line renderer: whether we\n * are currently inside an open `<ul>` (so the next blank line / heading / non-\n * bullet closes it).\n */\nclass MarkdownListState {\n inList = false;\n}\n\nexport class ResponsibilitiesRenderer {\n private readonly names = new GraphNames();\n\n /**\n * Build the responsibilities section HTML: one collapsible card per module,\n * sorted by level descending (tie-break by name ascending). Returned as a\n * <section> that GraphVisualizer injects below the graph.\n */\n generateSection(graph: EnhancedGraph, workspaceRoot: string): string {\n const projects = Object.keys(graph);\n projects.sort((a: string, b: string): number => {\n const levelDiff = graph[b].level - graph[a].level;\n if (levelDiff !== 0) return levelDiff;\n return a.localeCompare(b);\n });\n\n const cards: string[] = [];\n for (const project of projects) {\n // Hidden projects (drawOnGraph:false) are omitted from the graph, so\n // they get no responsibilities card either.\n if (graph[project].drawOnGraph === false) continue;\n cards.push(this.renderCard(project, graph[project], workspaceRoot));\n }\n\n return (\n `<section id=\"wp-responsibilities\">` +\n `<h2>Responsibilities (level high → low)</h2>` +\n `<p class=\"hint\">Lock a box above to narrow this list to just that box's dependency chain.</p>` +\n cards.join('\\n') +\n `</section>`\n );\n }\n\n private renderCard(project: string, entry: GraphEntry, workspaceRoot: string): string {\n const shortName = this.names.getShortName(project);\n const summary = entry.shortDescription ?? '';\n const summaryHtml = summary ? ` — ${this.escapeHtml(summary)}` : '';\n const body = this.readBody(entry, workspaceRoot);\n return (\n `<details class=\"wp-resp-card\" data-node=\"${this.escapeHtml(shortName)}\">` +\n `<summary><span class=\"wp-resp-level\">L${entry.level}</span> ` +\n `<strong>${this.escapeHtml(shortName)}</strong>${summaryHtml}</summary>` +\n `<div class=\"wp-resp-body\">${body}</div>` +\n `</details>`\n );\n }\n\n /**\n * Read a module's responsibilities.md body. Generation already guarantees the\n * file exists (metadata validation throws otherwise); a fallback line guards\n * the edge case where the graph JSON is stale relative to disk.\n */\n private readBody(entry: GraphEntry, workspaceRoot: string): string {\n const file = entry.responsibilitiesFile;\n if (!file) return '<p><em>No responsibilities.md recorded for this module.</em></p>';\n const absolutePath = path.join(workspaceRoot, file);\n if (!fs.existsSync(absolutePath)) {\n return `<p><em>Missing ${this.escapeHtml(file)}.</em></p>`;\n }\n return this.renderMarkdown(fs.readFileSync(absolutePath, 'utf-8'));\n }\n\n /**\n * Minimal markdown → HTML for a responsibilities.md body. Handles ATX headings\n * (`#`..`######`), `-`/`*` bullet lists, and blank-line-separated paragraphs.\n * Everything is HTML-escaped first; only a small inline set is re-marked. This\n * is deliberately tiny — responsibilities.md files are short and structured,\n * and the repo has no markdown dependency.\n */\n private renderMarkdown(markdown: string): string {\n const out: string[] = [];\n const state = new MarkdownListState();\n for (const rawLine of markdown.split('\\n')) {\n this.renderLine(rawLine.trim(), out, state);\n }\n if (state.inList) out.push('</ul>');\n return out.join('\\n');\n }\n\n private renderLine(line: string, out: string[], state: MarkdownListState): void {\n const heading = /^(#{1,6})\\s+(.*)$/.exec(line);\n const bullet = /^[-*]\\s+(.*)$/.exec(line);\n if (line.length === 0) {\n if (state.inList) { out.push('</ul>'); state.inList = false; }\n return;\n }\n if (heading) {\n if (state.inList) { out.push('</ul>'); state.inList = false; }\n const level = Math.min(heading[1].length + 3, 6); // # → h4, ## → h5, deeper → h6\n out.push(`<h${level}>${this.renderInline(this.escapeHtml(heading[2]))}</h${level}>`);\n return;\n }\n if (bullet) {\n if (!state.inList) { out.push('<ul>'); state.inList = true; }\n out.push(`<li>${this.renderInline(this.escapeHtml(bullet[1]))}</li>`);\n return;\n }\n if (state.inList) { out.push('</ul>'); state.inList = false; }\n out.push(`<p>${this.renderInline(this.escapeHtml(line))}</p>`);\n }\n\n /**\n * Render inline markdown spans within an already HTML-escaped line: `code` →\n * <code>, **bold** → <strong>, *italic* → <em>.\n */\n private renderInline(escaped: string): string {\n return escaped\n .replace(/`([^`]+)`/g, '<code>$1</code>')\n .replace(/\\*\\*([^*]+)\\*\\*/g, '<strong>$1</strong>')\n .replace(/(^|[^*])\\*([^*]+)\\*/g, '$1<em>$2</em>');\n }\n\n /**\n * Escape a string for safe embedding in HTML text/attributes.\n */\n private escapeHtml(text: string): string {\n return text\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"');\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"graph-responsibilities.js","sourceRoot":"","sources":["../../../../../../packages/tooling/nx-webpieces-rules/src/lib/graph-responsibilities.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;;AAEH,+CAAyB;AACzB,mDAA6B;AAE7B,+CAA2C;AAE3C;;;;GAIG;AACH,MAAM,iBAAiB;IACnB,MAAM,GAAG,KAAK,CAAC;CAClB;AAED,MAAa,wBAAwB;IAChB,KAAK,GAAG,IAAI,wBAAU,EAAE,CAAC;IAE1C;;;;OAIG;IACH,eAAe,CAAC,KAAoB,EAAE,aAAqB;QACvD,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE;YAC3C,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;YAClD,IAAI,SAAS,KAAK,CAAC;gBAAE,OAAO,SAAS,CAAC;YACtC,OAAO,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;QAC9B,CAAC,CAAC,CAAC;QAEH,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC7B,qEAAqE;YACrE,4CAA4C;YAC5C,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,WAAW,KAAK,KAAK;gBAAE,SAAS;YACnD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC;QACxE,CAAC;QAED,OAAO,CACH,oCAAoC;YACpC,8CAA8C;YAC9C,+FAA+F;YAC/F,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;YAChB,YAAY,CACf,CAAC;IACN,CAAC;IAEO,UA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QACX,CAAC;QACD,IAAI,MAAM,EAAE,CAAC;YACT,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;gBAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC;YAAC,CAAC;YAC7D,GAAG,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;YACtE,OAAO;QACX,CAAC;QACD,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;YAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAAC,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC;QAAC,CAAC;QAC9D,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;IACnE,CAAC;IAED;;;OAGG;IACK,YAAY,CAAC,OAAe;QAChC,OAAO,OAAO;aACT,OAAO,CAAC,YAAY,EAAE,iBAAiB,CAAC;aACxC,OAAO,CAAC,kBAAkB,EAAE,qBAAqB,CAAC;aAClD,OAAO,CAAC,sBAAsB,EAAE,eAAe,CAAC,CAAC;IAC1D,CAAC;IAED;;OAEG;IACK,UAAU,CAAC,IAAY;QAC3B,OAAO,IAAI;aACN,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;aACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;aACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;aACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACjC,CAAC;CACJ;AA1HD,4DA0HC","sourcesContent":["/**\n * Responsibilities Section\n *\n * Renders every module's full `responsibilities.md` as a collapsible card below\n * the dependency graph in architecture/dependencies.html. Cards are ordered by\n * dependency level HIGH → LOW (top-level apps first, deepest libs last) so a\n * reader scrolls from the runnable servers/clients down into the libraries.\n *\n * Each card carries `data-node=\"<shortName>\"` matching the graph box's title, so\n * the page script can filter the list to just the locked box's chain (see\n * graph-visualizer.client.ts). The summary paragraph is the `shortDescription`\n * already on each graph entry; the expanded body is the rendered markdown file.\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport type { EnhancedGraph, GraphEntry } from './graph-sorter';\nimport { GraphNames } from './graph-names';\n\n/**\n * Mutable cursor state threaded through the markdown line renderer: whether we\n * are currently inside an open `<ul>` (so the next blank line / heading / non-\n * bullet closes it).\n */\nclass MarkdownListState {\n inList = false;\n}\n\nexport class ResponsibilitiesRenderer {\n private readonly names = new GraphNames();\n\n /**\n * Build the responsibilities section HTML: one collapsible card per module,\n * sorted by level descending (tie-break by name ascending). Returned as a\n * <section> that GraphVisualizer injects below the graph.\n */\n generateSection(graph: EnhancedGraph, workspaceRoot: string): string {\n const projects = Object.keys(graph);\n projects.sort((a: string, b: string): number => {\n const levelDiff = graph[b].level - graph[a].level;\n if (levelDiff !== 0) return levelDiff;\n return a.localeCompare(b);\n });\n\n const cards: string[] = [];\n for (const project of projects) {\n // Hidden projects (drawOnGraph:false) are omitted from the graph, so\n // they get no responsibilities card either.\n if (graph[project].drawOnGraph === false) continue;\n cards.push(this.renderCard(project, graph[project], workspaceRoot));\n }\n\n return (\n `<section id=\"wp-responsibilities\">` +\n `<h2>Responsibilities (level high → low)</h2>` +\n `<p class=\"hint\">Lock a box above to narrow this list to just that box's dependency chain.</p>` +\n cards.join('\\n') +\n `</section>`\n );\n }\n\n private renderCard(project: string, entry: GraphEntry, workspaceRoot: string): string {\n const shortName = this.names.getShortName(project);\n const summary = entry.shortDescription ?? '';\n const summaryHtml = summary ? ` — ${this.escapeHtml(summary)}` : '';\n const body = this.readBody(entry, workspaceRoot);\n return (\n `<details class=\"wp-resp-card\" data-node=\"${this.escapeHtml(shortName)}\">` +\n `<summary><span class=\"wp-resp-level\">L${entry.level}</span> ` +\n `<strong>${this.escapeHtml(shortName)}</strong>${summaryHtml}</summary>` +\n `<div class=\"wp-resp-body\">${body}</div>` +\n `</details>`\n );\n }\n\n /**\n * Read a module's responsibilities.md body. Generation already guarantees the\n * file exists (metadata validation throws otherwise); a fallback line guards\n * the edge case where the graph JSON is stale relative to disk.\n */\n private readBody(entry: GraphEntry, workspaceRoot: string): string {\n const file = entry.responsibilitiesFile;\n if (!file) return '<p><em>No responsibilities.md recorded for this module.</em></p>';\n const absolutePath = path.join(workspaceRoot, file);\n if (!fs.existsSync(absolutePath)) {\n return `<p><em>Missing ${this.escapeHtml(file)}.</em></p>`;\n }\n return this.renderMarkdown(fs.readFileSync(absolutePath, 'utf-8'));\n }\n\n /**\n * Minimal markdown → HTML for a responsibilities.md body. Handles ATX headings\n * (`#`..`######`), `-`/`*` bullet lists, and blank-line-separated paragraphs.\n * Everything is HTML-escaped first; only a small inline set is re-marked. This\n * is deliberately tiny — responsibilities.md files are short and structured,\n * and the repo has no markdown dependency.\n */\n private renderMarkdown(markdown: string): string {\n const out: string[] = [];\n const state = new MarkdownListState();\n for (const rawLine of markdown.split('\\n')) {\n this.renderLine(rawLine.trim(), out, state);\n }\n if (state.inList) out.push('</ul>');\n return out.join('\\n');\n }\n\n private renderLine(line: string, out: string[], state: MarkdownListState): void {\n const heading = /^(#{1,6})\\s+(.*)$/.exec(line);\n const bullet = /^[-*]\\s+(.*)$/.exec(line);\n if (line.length === 0) {\n if (state.inList) { out.push('</ul>'); state.inList = false; }\n return;\n }\n if (heading) {\n if (state.inList) { out.push('</ul>'); state.inList = false; }\n const level = Math.min(heading[1].length + 3, 6); // # → h4, ## → h5, deeper → h6\n out.push(`<h${level}>${this.renderInline(this.escapeHtml(heading[2]))}</h${level}>`);\n return;\n }\n if (bullet) {\n if (!state.inList) { out.push('<ul>'); state.inList = true; }\n out.push(`<li>${this.renderInline(this.escapeHtml(bullet[1]))}</li>`);\n return;\n }\n if (state.inList) { out.push('</ul>'); state.inList = false; }\n out.push(`<p>${this.renderInline(this.escapeHtml(line))}</p>`);\n }\n\n /**\n * Render inline markdown spans within an already HTML-escaped line: `code` →\n * <code>, **bold** → <strong>, *italic* → <em>.\n */\n private renderInline(escaped: string): string {\n return escaped\n .replace(/`([^`]+)`/g, '<code>$1</code>')\n .replace(/\\*\\*([^*]+)\\*\\*/g, '<strong>$1</strong>')\n .replace(/(^|[^*])\\*([^*]+)\\*/g, '$1<em>$2</em>');\n }\n\n /**\n * Escape a string for safe embedding in HTML text/attributes.\n */\n private escapeHtml(text: string): string {\n return text\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"');\n }\n}\n"]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** One traversal direction: the edges to light, and the nodes to walk on to. */
|
|
2
|
+
declare class Direction {
|
|
3
|
+
readonly nodes: Map<string, Set<string>>;
|
|
4
|
+
readonly edges: Map<string, Set<Element>>;
|
|
5
|
+
constructor(nodes: Map<string, Set<string>>, edges: Map<string, Set<Element>>);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Indexes the rendered SVG and drives the dim/highlight/lock interaction.
|
|
9
|
+
*
|
|
10
|
+
* The adjacency is DIRECTED and kept as two maps per axis: `in*` is what points AT a node (ancestors,
|
|
11
|
+
* walked upward) and `out*` is what it points to (dependencies, walked downward). Highlighting walks
|
|
12
|
+
* both, so a hovered box lights its entire chain in both directions rather than just its neighbours.
|
|
13
|
+
*/
|
|
14
|
+
declare class GraphHighlighter {
|
|
15
|
+
private readonly svg;
|
|
16
|
+
private readonly nodeByName;
|
|
17
|
+
private readonly inEdges;
|
|
18
|
+
private readonly outEdges;
|
|
19
|
+
private readonly inNodes;
|
|
20
|
+
private readonly outNodes;
|
|
21
|
+
/**
|
|
22
|
+
* The box the dropdown pinned, or null. Hover still works on top of a lock — leaving a box
|
|
23
|
+
* restores the LOCKED view instead of clearing, so the pinned subgraph stays visible while you
|
|
24
|
+
* scroll down to its responsibility cards.
|
|
25
|
+
*/
|
|
26
|
+
private locked;
|
|
27
|
+
constructor(svg: SVGSVGElement);
|
|
28
|
+
/** Index the SVG, then wire hover and the lock dropdown. */
|
|
29
|
+
wire(): void;
|
|
30
|
+
private indexNodes;
|
|
31
|
+
private indexEdges;
|
|
32
|
+
private ensureEdges;
|
|
33
|
+
private ensureNodes;
|
|
34
|
+
private clear;
|
|
35
|
+
/**
|
|
36
|
+
* Dim everything, then transitively light ancestors and descendants of `name`: edges reached get
|
|
37
|
+
* `wp-hl`, boxes get `wp-neighbor`. The `visited` set is what makes a cyclic graph terminate.
|
|
38
|
+
*/
|
|
39
|
+
private highlight;
|
|
40
|
+
private walk;
|
|
41
|
+
/** Leaving a box restores the locked view rather than clearing it outright. */
|
|
42
|
+
private relight;
|
|
43
|
+
private wireHover;
|
|
44
|
+
private wireLock;
|
|
45
|
+
/**
|
|
46
|
+
* Filter the responsibility cards to the locked box's chain by READING BACK the
|
|
47
|
+
* `.wp-focus`/`.wp-neighbor` classes highlight() just set — so there is no second graph walk and
|
|
48
|
+
* the cards can never disagree with the picture.
|
|
49
|
+
*/
|
|
50
|
+
private filterCards;
|
|
51
|
+
}
|
|
52
|
+
/** Renders the DOT and hands the SVG to the highlighter. Reports a failure into the page, not just the console. */
|
|
53
|
+
declare class GraphPage {
|
|
54
|
+
render(): void;
|
|
55
|
+
}
|
|
@@ -1,130 +1,223 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/*
|
|
2
|
-
* Browser-side script for architecture/dependencies.html
|
|
3
|
-
* tag by graph-visualizer.ts, which replaces the __DOT__ placeholder with the
|
|
4
|
-
* JSON-encoded Graphviz DOT). Kept as a plain .js asset — NOT a TypeScript
|
|
5
|
-
* template literal — so the dim/highlight/lock logic can define ordinary browser
|
|
6
|
-
* functions without tripping the TypeScript lint rules that scan .ts template
|
|
7
|
-
* strings. Copied into dist by the build's assets glob and read via readFileSync.
|
|
3
|
+
* Browser-side script for architecture/dependencies.html.
|
|
8
4
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
5
|
+
* graph-visualizer.ts reads this file's COMPILED output with readFileSync, substitutes the DOT
|
|
6
|
+
* placeholder (see viz-client-globals.d.ts) with the JSON-encoded Graphviz DOT, and inlines the result into a <script> tag. So it
|
|
7
|
+
* runs in a browser, never in node — but it is ordinary TypeScript, compiled in place by tsc exactly
|
|
8
|
+
* like the package's bin entry points, and linted like every other file here.
|
|
9
|
+
*
|
|
10
|
+
* IT USED TO BE A COMMITTED .js ASSET, exempted from `no-js-files`, and its own header said why: so the
|
|
11
|
+
* dim/highlight/lock logic "can define ordinary browser functions without tripping the TypeScript lint
|
|
12
|
+
* rules". That is a file existing to dodge the rules — the same anti-pattern as the bin shims this repo
|
|
13
|
+
* deleted, and the same cure applies. The logic is a CLASS now, which is what `no-function-outside-class`
|
|
14
|
+
* was asking for all along; nothing needed a disable.
|
|
15
|
+
*
|
|
16
|
+
* Behaviour, unchanged: after Viz renders the SVG, hovering a box dims the rest and lights its full
|
|
17
|
+
* ancestor+descendant chain; the #wp-lock dropdown PINS one box's chain (the dim survives mouse-leave)
|
|
18
|
+
* and filters the responsibilities cards below the graph to just that chain. "All" clears the lock.
|
|
14
19
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
// The DOT placeholder and the `Viz` global are declared once in viz-client-globals.d.ts — both
|
|
21
|
+
// scripts share a global scope, so they cannot each declare them. Do NOT spell the placeholder token
|
|
22
|
+
// in a comment: the inliner is a blind split/join, so every literal occurrence gets the whole DOT.
|
|
23
|
+
/** One traversal direction: the edges to light, and the nodes to walk on to. */
|
|
24
|
+
class Direction {
|
|
25
|
+
nodes;
|
|
26
|
+
edges;
|
|
27
|
+
constructor(nodes, edges) {
|
|
28
|
+
this.nodes = nodes;
|
|
29
|
+
this.edges = edges;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Indexes the rendered SVG and drives the dim/highlight/lock interaction.
|
|
34
|
+
*
|
|
35
|
+
* The adjacency is DIRECTED and kept as two maps per axis: `in*` is what points AT a node (ancestors,
|
|
36
|
+
* walked upward) and `out*` is what it points to (dependencies, walked downward). Highlighting walks
|
|
37
|
+
* both, so a hovered box lights its entire chain in both directions rather than just its neighbours.
|
|
38
|
+
*/
|
|
39
|
+
class GraphHighlighter {
|
|
40
|
+
svg;
|
|
41
|
+
nodeByName = new Map();
|
|
42
|
+
inEdges = new Map();
|
|
43
|
+
outEdges = new Map();
|
|
44
|
+
inNodes = new Map();
|
|
45
|
+
outNodes = new Map();
|
|
46
|
+
/**
|
|
47
|
+
* The box the dropdown pinned, or null. Hover still works on top of a lock — leaving a box
|
|
48
|
+
* restores the LOCKED view instead of clearing, so the pinned subgraph stays visible while you
|
|
49
|
+
* scroll down to its responsibility cards.
|
|
50
|
+
*/
|
|
51
|
+
locked = null;
|
|
52
|
+
constructor(svg) {
|
|
53
|
+
this.svg = svg;
|
|
54
|
+
}
|
|
55
|
+
/** Index the SVG, then wire hover and the lock dropdown. */
|
|
56
|
+
wire() {
|
|
57
|
+
this.indexNodes();
|
|
58
|
+
this.indexEdges();
|
|
59
|
+
this.wireHover();
|
|
60
|
+
this.wireLock();
|
|
61
|
+
}
|
|
62
|
+
indexNodes() {
|
|
63
|
+
this.svg.querySelectorAll('g.node').forEach((g) => {
|
|
64
|
+
const title = g.querySelector('title');
|
|
65
|
+
if (title !== null && title.textContent !== null) {
|
|
66
|
+
this.nodeByName.set(title.textContent.trim(), g);
|
|
67
|
+
}
|
|
29
68
|
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (
|
|
69
|
+
}
|
|
70
|
+
indexEdges() {
|
|
71
|
+
this.svg.querySelectorAll('g.edge').forEach((edge) => {
|
|
72
|
+
const title = edge.querySelector('title');
|
|
73
|
+
const text = title === null ? null : title.textContent;
|
|
74
|
+
if (text === null)
|
|
75
|
+
return;
|
|
76
|
+
const idx = text.indexOf('->');
|
|
77
|
+
if (idx < 0)
|
|
78
|
+
return;
|
|
79
|
+
const from = text.slice(0, idx).trim();
|
|
80
|
+
const to = text.slice(idx + 2).trim();
|
|
81
|
+
this.ensureEdges(this.outEdges, from).add(edge);
|
|
82
|
+
this.ensureEdges(this.inEdges, to).add(edge);
|
|
83
|
+
this.ensureNodes(this.outNodes, from).add(to);
|
|
84
|
+
this.ensureNodes(this.inNodes, to).add(from);
|
|
36
85
|
});
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
86
|
+
}
|
|
87
|
+
ensureEdges(map, key) {
|
|
88
|
+
const existing = map.get(key);
|
|
89
|
+
if (existing !== undefined)
|
|
90
|
+
return existing;
|
|
91
|
+
const created = new Set();
|
|
92
|
+
map.set(key, created);
|
|
93
|
+
return created;
|
|
94
|
+
}
|
|
95
|
+
ensureNodes(map, key) {
|
|
96
|
+
const existing = map.get(key);
|
|
97
|
+
if (existing !== undefined)
|
|
98
|
+
return existing;
|
|
99
|
+
const created = new Set();
|
|
100
|
+
map.set(key, created);
|
|
101
|
+
return created;
|
|
102
|
+
}
|
|
103
|
+
clear() {
|
|
104
|
+
this.svg.classList.remove('wp-dim');
|
|
105
|
+
this.svg.querySelectorAll('.wp-focus, .wp-neighbor, .wp-hl').forEach((el) => {
|
|
106
|
+
el.classList.remove('wp-focus', 'wp-neighbor', 'wp-hl');
|
|
55
107
|
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Dim everything, then transitively light ancestors and descendants of `name`: edges reached get
|
|
111
|
+
* `wp-hl`, boxes get `wp-neighbor`. The `visited` set is what makes a cyclic graph terminate.
|
|
112
|
+
*/
|
|
113
|
+
highlight(name, focusEl) {
|
|
114
|
+
this.clear();
|
|
115
|
+
this.svg.classList.add('wp-dim');
|
|
116
|
+
focusEl.classList.add('wp-focus');
|
|
117
|
+
const directions = [
|
|
118
|
+
new Direction(this.inNodes, this.inEdges),
|
|
119
|
+
new Direction(this.outNodes, this.outEdges),
|
|
120
|
+
];
|
|
121
|
+
for (const dir of directions)
|
|
122
|
+
this.walk(name, dir);
|
|
123
|
+
}
|
|
124
|
+
walk(start, dir) {
|
|
125
|
+
const visited = new Set();
|
|
126
|
+
const stack = [start];
|
|
127
|
+
while (stack.length > 0) {
|
|
128
|
+
const cur = stack.pop();
|
|
129
|
+
const edges = dir.edges.get(cur);
|
|
130
|
+
if (edges !== undefined) {
|
|
131
|
+
edges.forEach((e) => { e.classList.add('wp-hl'); });
|
|
132
|
+
}
|
|
133
|
+
const next = dir.nodes.get(cur);
|
|
134
|
+
if (next === undefined)
|
|
135
|
+
continue;
|
|
136
|
+
next.forEach((name) => {
|
|
137
|
+
if (visited.has(name))
|
|
138
|
+
return;
|
|
139
|
+
visited.add(name);
|
|
140
|
+
stack.push(name);
|
|
141
|
+
const g = this.nodeByName.get(name);
|
|
142
|
+
if (g !== undefined)
|
|
143
|
+
g.classList.add('wp-neighbor');
|
|
82
144
|
});
|
|
83
145
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
var lg = nodeByName.get(locked);
|
|
91
|
-
if (lg) highlight(locked, lg);
|
|
92
|
-
} else {
|
|
93
|
-
clear();
|
|
94
|
-
}
|
|
146
|
+
}
|
|
147
|
+
/** Leaving a box restores the locked view rather than clearing it outright. */
|
|
148
|
+
relight() {
|
|
149
|
+
if (this.locked === null) {
|
|
150
|
+
this.clear();
|
|
151
|
+
return;
|
|
95
152
|
}
|
|
96
|
-
nodeByName.
|
|
97
|
-
|
|
98
|
-
|
|
153
|
+
const g = this.nodeByName.get(this.locked);
|
|
154
|
+
if (g !== undefined)
|
|
155
|
+
this.highlight(this.locked, g);
|
|
156
|
+
}
|
|
157
|
+
wireHover() {
|
|
158
|
+
this.nodeByName.forEach((g, name) => {
|
|
159
|
+
g.addEventListener('mouseenter', () => { this.highlight(name, g); });
|
|
160
|
+
g.addEventListener('mouseleave', () => { this.relight(); });
|
|
99
161
|
});
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
if (t) lit.add(t.textContent.trim());
|
|
110
|
-
});
|
|
162
|
+
}
|
|
163
|
+
wireLock() {
|
|
164
|
+
const lockSelect = document.getElementById('wp-lock');
|
|
165
|
+
if (lockSelect === null)
|
|
166
|
+
return;
|
|
167
|
+
lockSelect.addEventListener('change', () => {
|
|
168
|
+
this.locked = lockSelect.value === '' ? null : lockSelect.value;
|
|
169
|
+
if (this.locked === null) {
|
|
170
|
+
this.clear();
|
|
111
171
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
172
|
+
else {
|
|
173
|
+
const g = this.nodeByName.get(this.locked);
|
|
174
|
+
if (g !== undefined)
|
|
175
|
+
this.highlight(this.locked, g);
|
|
176
|
+
}
|
|
177
|
+
this.filterCards();
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Filter the responsibility cards to the locked box's chain by READING BACK the
|
|
182
|
+
* `.wp-focus`/`.wp-neighbor` classes highlight() just set — so there is no second graph walk and
|
|
183
|
+
* the cards can never disagree with the picture.
|
|
184
|
+
*/
|
|
185
|
+
filterCards() {
|
|
186
|
+
const lit = new Set();
|
|
187
|
+
if (this.locked !== null) {
|
|
188
|
+
this.svg.querySelectorAll('.wp-focus, .wp-neighbor').forEach((el) => {
|
|
189
|
+
const title = el.querySelector('title');
|
|
190
|
+
if (title !== null && title.textContent !== null)
|
|
191
|
+
lit.add(title.textContent.trim());
|
|
127
192
|
});
|
|
128
193
|
}
|
|
194
|
+
document.querySelectorAll('.wp-resp-card').forEach((card) => {
|
|
195
|
+
const name = card.getAttribute('data-node');
|
|
196
|
+
const visible = this.locked === null || (name !== null && lit.has(name));
|
|
197
|
+
card.classList.toggle('wp-hidden', !visible);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/** Renders the DOT and hands the SVG to the highlighter. Reports a failure into the page, not just the console. */
|
|
202
|
+
class GraphPage {
|
|
203
|
+
render() {
|
|
204
|
+
Viz.instance()
|
|
205
|
+
.then((viz) => {
|
|
206
|
+
const element = viz.renderSVGElement(__DOT__);
|
|
207
|
+
const host = document.getElementById('graph');
|
|
208
|
+
if (host === null)
|
|
209
|
+
return;
|
|
210
|
+
host.appendChild(element);
|
|
211
|
+
new GraphHighlighter(element).wire();
|
|
212
|
+
})
|
|
213
|
+
// webpieces-disable no-any-unknown -- a promise rejection reason is untyped BY THE LANGUAGE (any value can be thrown), and this browser script cannot import the repo's toError helper; it is stringified, never dereferenced
|
|
214
|
+
.catch((err) => {
|
|
215
|
+
console.error(err);
|
|
216
|
+
const host = document.getElementById('graph');
|
|
217
|
+
if (host !== null)
|
|
218
|
+
host.innerHTML = '<pre>' + String(err) + '</pre>';
|
|
219
|
+
});
|
|
129
220
|
}
|
|
130
|
-
}
|
|
221
|
+
}
|
|
222
|
+
new GraphPage().render();
|
|
223
|
+
//# sourceMappingURL=graph-visualizer.client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph-visualizer.client.js","sourceRoot":"","sources":["../../../../../../packages/tooling/nx-webpieces-rules/src/lib/graph-visualizer.client.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,+FAA+F;AAC/F,qGAAqG;AACrG,mGAAmG;AAEnG,gFAAgF;AAChF,MAAM,SAAS;IAEE;IACA;IAFb,YACa,KAA+B,EAC/B,KAAgC;QADhC,UAAK,GAAL,KAAK,CAA0B;QAC/B,UAAK,GAAL,KAAK,CAA2B;IAC1C,CAAC;CACP;AAED;;;;;;GAMG;AACH,MAAM,gBAAgB;IAcW;IAbZ,UAAU,GAAG,IAAI,GAAG,EAAuB,CAAC;IAC5C,OAAO,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC1C,QAAQ,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC3C,OAAO,GAAG,IAAI,GAAG,EAAuB,CAAC;IACzC,QAAQ,GAAG,IAAI,GAAG,EAAuB,CAAC;IAE3D;;;;OAIG;IACK,MAAM,GAAkB,IAAI,CAAC;IAErC,YAA6B,GAAkB;QAAlB,QAAG,GAAH,GAAG,CAAe;IAAG,CAAC;IAEnD,4DAA4D;IAC5D,IAAI;QACA,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,SAAS,EAAE,CAAC;QACjB,IAAI,CAAC,QAAQ,EAAE,CAAC;IACpB,CAAC;IAEO,UAAU;QACd,IAAI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CAAC,CAAC,CAAC;YACzE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,mHAAmH;AACnH,MAAM,SAAS;IACX,MAAM;QACF,GAAG,CAAC,QAAQ,EAAE;aACT,IAAI,CAAC,CAAC,GAAgB,EAAQ,EAAE;YAC7B,MAAM,OAAO,GAAG,GAAG,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;YAC9C,MAAM,IAAI,GAAG,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;YAC9C,IAAI,IAAI,KAAK,IAAI;gBAAE,OAAO;YAC1B,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YAC1B,IAAI,gBAAgB,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;QACzC,CAAC,CAAC;YACF,8NAA8N;aAC7N,KAAK,CAAC,CAAC,GAAY,EAAQ,EAAE;YAC1B,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnB,MAAM,IAAI,GAAG,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;YAC9C,IAAI,IAAI,KAAK,IAAI;gBAAE,IAAI,CAAC,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;QACzE,CAAC,CAAC,CAAC;IACX,CAAC;CACJ;AAED,IAAI,SAAS,EAAE,CAAC,MAAM,EAAE,CAAC","sourcesContent":["/*\n * Browser-side script for architecture/dependencies.html.\n *\n * graph-visualizer.ts reads this file's COMPILED output with readFileSync, substitutes the DOT\n * placeholder (see viz-client-globals.d.ts) with the JSON-encoded Graphviz DOT, and inlines the result into a <script> tag. So it\n * runs in a browser, never in node — but it is ordinary TypeScript, compiled in place by tsc exactly\n * like the package's bin entry points, and linted like every other file here.\n *\n * IT USED TO BE A COMMITTED .js ASSET, exempted from `no-js-files`, and its own header said why: so the\n * dim/highlight/lock logic \"can define ordinary browser functions without tripping the TypeScript lint\n * rules\". That is a file existing to dodge the rules — the same anti-pattern as the bin shims this repo\n * deleted, and the same cure applies. The logic is a CLASS now, which is what `no-function-outside-class`\n * was asking for all along; nothing needed a disable.\n *\n * Behaviour, unchanged: after Viz renders the SVG, hovering a box dims the rest and lights its full\n * ancestor+descendant chain; the #wp-lock dropdown PINS one box's chain (the dim survives mouse-leave)\n * and filters the responsibilities cards below the graph to just that chain. \"All\" clears the lock.\n */\n\n// The DOT placeholder and the `Viz` global are declared once in viz-client-globals.d.ts — both\n// scripts share a global scope, so they cannot each declare them. Do NOT spell the placeholder token\n// in a comment: the inliner is a blind split/join, so every literal occurrence gets the whole DOT.\n\n/** One traversal direction: the edges to light, and the nodes to walk on to. */\nclass Direction {\n constructor(\n readonly nodes: Map<string, Set<string>>,\n readonly edges: Map<string, Set<Element>>,\n ) {}\n}\n\n/**\n * Indexes the rendered SVG and drives the dim/highlight/lock interaction.\n *\n * The adjacency is DIRECTED and kept as two maps per axis: `in*` is what points AT a node (ancestors,\n * walked upward) and `out*` is what it points to (dependencies, walked downward). Highlighting walks\n * both, so a hovered box lights its entire chain in both directions rather than just its neighbours.\n */\nclass GraphHighlighter {\n private readonly nodeByName = new Map<string, SVGGElement>();\n private readonly inEdges = new Map<string, Set<Element>>();\n private readonly outEdges = new Map<string, Set<Element>>();\n private readonly inNodes = new Map<string, Set<string>>();\n private readonly outNodes = new Map<string, Set<string>>();\n\n /**\n * The box the dropdown pinned, or null. Hover still works on top of a lock — leaving a box\n * restores the LOCKED view instead of clearing, so the pinned subgraph stays visible while you\n * scroll down to its responsibility cards.\n */\n private locked: string | null = null;\n\n constructor(private readonly svg: SVGSVGElement) {}\n\n /** Index the SVG, then wire hover and the lock dropdown. */\n wire(): void {\n this.indexNodes();\n this.indexEdges();\n this.wireHover();\n this.wireLock();\n }\n\n private indexNodes(): void {\n this.svg.querySelectorAll('g.node').forEach((g: Element): void => {\n const title = g.querySelector('title');\n if (title !== null && title.textContent !== null) {\n this.nodeByName.set(title.textContent.trim(), g as SVGGElement);\n }\n });\n }\n\n private indexEdges(): void {\n this.svg.querySelectorAll('g.edge').forEach((edge: Element): void => {\n const title = edge.querySelector('title');\n const text = title === null ? null : title.textContent;\n if (text === null) return;\n const idx = text.indexOf('->');\n if (idx < 0) return;\n const from = text.slice(0, idx).trim();\n const to = text.slice(idx + 2).trim();\n this.ensureEdges(this.outEdges, from).add(edge);\n this.ensureEdges(this.inEdges, to).add(edge);\n this.ensureNodes(this.outNodes, from).add(to);\n this.ensureNodes(this.inNodes, to).add(from);\n });\n }\n\n private ensureEdges(map: Map<string, Set<Element>>, key: string): Set<Element> {\n const existing = map.get(key);\n if (existing !== undefined) return existing;\n const created = new Set<Element>();\n map.set(key, created);\n return created;\n }\n\n private ensureNodes(map: Map<string, Set<string>>, key: string): Set<string> {\n const existing = map.get(key);\n if (existing !== undefined) return existing;\n const created = new Set<string>();\n map.set(key, created);\n return created;\n }\n\n private clear(): void {\n this.svg.classList.remove('wp-dim');\n this.svg.querySelectorAll('.wp-focus, .wp-neighbor, .wp-hl').forEach((el: Element): void => {\n el.classList.remove('wp-focus', 'wp-neighbor', 'wp-hl');\n });\n }\n\n /**\n * Dim everything, then transitively light ancestors and descendants of `name`: edges reached get\n * `wp-hl`, boxes get `wp-neighbor`. The `visited` set is what makes a cyclic graph terminate.\n */\n private highlight(name: string, focusEl: SVGGElement): void {\n this.clear();\n this.svg.classList.add('wp-dim');\n focusEl.classList.add('wp-focus');\n const directions = [\n new Direction(this.inNodes, this.inEdges),\n new Direction(this.outNodes, this.outEdges),\n ];\n for (const dir of directions) this.walk(name, dir);\n }\n\n private walk(start: string, dir: Direction): void {\n const visited = new Set<string>();\n const stack = [start];\n while (stack.length > 0) {\n const cur = stack.pop() as string;\n const edges = dir.edges.get(cur);\n if (edges !== undefined) {\n edges.forEach((e: Element): void => { e.classList.add('wp-hl'); });\n }\n const next = dir.nodes.get(cur);\n if (next === undefined) continue;\n next.forEach((name: string): void => {\n if (visited.has(name)) return;\n visited.add(name);\n stack.push(name);\n const g = this.nodeByName.get(name);\n if (g !== undefined) g.classList.add('wp-neighbor');\n });\n }\n }\n\n /** Leaving a box restores the locked view rather than clearing it outright. */\n private relight(): void {\n if (this.locked === null) {\n this.clear();\n return;\n }\n const g = this.nodeByName.get(this.locked);\n if (g !== undefined) this.highlight(this.locked, g);\n }\n\n private wireHover(): void {\n this.nodeByName.forEach((g: SVGGElement, name: string): void => {\n g.addEventListener('mouseenter', (): void => { this.highlight(name, g); });\n g.addEventListener('mouseleave', (): void => { this.relight(); });\n });\n }\n\n private wireLock(): void {\n const lockSelect = document.getElementById('wp-lock') as HTMLSelectElement | null;\n if (lockSelect === null) return;\n lockSelect.addEventListener('change', (): void => {\n this.locked = lockSelect.value === '' ? null : lockSelect.value;\n if (this.locked === null) {\n this.clear();\n } else {\n const g = this.nodeByName.get(this.locked);\n if (g !== undefined) this.highlight(this.locked, g);\n }\n this.filterCards();\n });\n }\n\n /**\n * Filter the responsibility cards to the locked box's chain by READING BACK the\n * `.wp-focus`/`.wp-neighbor` classes highlight() just set — so there is no second graph walk and\n * the cards can never disagree with the picture.\n */\n private filterCards(): void {\n const lit = new Set<string>();\n if (this.locked !== null) {\n this.svg.querySelectorAll('.wp-focus, .wp-neighbor').forEach((el: Element): void => {\n const title = el.querySelector('title');\n if (title !== null && title.textContent !== null) lit.add(title.textContent.trim());\n });\n }\n document.querySelectorAll('.wp-resp-card').forEach((card: Element): void => {\n const name = card.getAttribute('data-node');\n const visible = this.locked === null || (name !== null && lit.has(name));\n card.classList.toggle('wp-hidden', !visible);\n });\n }\n}\n\n/** Renders the DOT and hands the SVG to the highlighter. Reports a failure into the page, not just the console. */\nclass GraphPage {\n render(): void {\n Viz.instance()\n .then((viz: VizInstance): void => {\n const element = viz.renderSVGElement(__DOT__);\n const host = document.getElementById('graph');\n if (host === null) return;\n host.appendChild(element);\n new GraphHighlighter(element).wire();\n })\n // webpieces-disable no-any-unknown -- a promise rejection reason is untyped BY THE LANGUAGE (any value can be thrown), and this browser script cannot import the repo's toError helper; it is stringified, never dereferenced\n .catch((err: unknown): void => {\n console.error(err);\n const host = document.getElementById('graph');\n if (host !== null) host.innerHTML = '<pre>' + String(err) + '</pre>';\n });\n }\n}\n\nnew GraphPage().render();\n"]}
|
|
@@ -14,9 +14,31 @@ export declare class VisualizationPaths {
|
|
|
14
14
|
htmlPath: string;
|
|
15
15
|
constructor(htmlPath: string);
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* The token the client scripts carry where the DOT belongs. It must appear EXACTLY ONCE in a compiled
|
|
19
|
+
* client — the inliner is a blind split/join, so a second occurrence (in a comment, say) would be
|
|
20
|
+
* replaced by the entire DOT too, bloating every generated page.
|
|
21
|
+
*/
|
|
22
|
+
export declare const CLIENT_DOT_PLACEHOLDER: string;
|
|
23
|
+
/**
|
|
24
|
+
* Read a compiled browser client sitting beside this file.
|
|
25
|
+
*
|
|
26
|
+
* It is generated from the matching `.client.ts` by tsc, so it exists in `dist` and in the published
|
|
27
|
+
* tarball but NOT in a source checkout. The error says that outright rather than surfacing a bare
|
|
28
|
+
* ENOENT, because "the build has not run" and "the file is missing" look identical otherwise.
|
|
29
|
+
*/
|
|
30
|
+
export declare function readCompiledClient(name: string): string;
|
|
17
31
|
export declare class GraphVisualizer {
|
|
32
|
+
private readonly clientJs;
|
|
18
33
|
private readonly names;
|
|
19
34
|
private readonly responsibilities;
|
|
35
|
+
/**
|
|
36
|
+
* How to obtain the browser client's text. Injected so HTML generation does not depend on BUILD
|
|
37
|
+
* ORDER: the default reads the compiled sibling, which exists in the tarball and in dist but NOT in
|
|
38
|
+
* a source checkout (the source there is .client.ts). A unit test running from source supplies the
|
|
39
|
+
* text itself rather than requiring the package to have been built first.
|
|
40
|
+
*/
|
|
41
|
+
constructor(clientJs?: () => string);
|
|
20
42
|
/**
|
|
21
43
|
* A project tagged `drawOnGraph:false` is hidden from the rendered graph —
|
|
22
44
|
* its node, its rank placement, its dropdown option, its responsibilities
|
|
@@ -100,11 +122,12 @@ export declare class GraphVisualizer {
|
|
|
100
122
|
private borderItems;
|
|
101
123
|
private edgeItems;
|
|
102
124
|
/**
|
|
103
|
-
* The page script. The browser code lives in graph-visualizer.client.
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
125
|
+
* The page script. The browser code lives in graph-visualizer.client.ts — real, linted TypeScript
|
|
126
|
+
* that tsc compiles in place, so what this inlines is its COMPILED .js sitting beside this file.
|
|
127
|
+
*
|
|
128
|
+
* The substitution is a blind split/join, which is why the placeholder token must appear EXACTLY
|
|
129
|
+
* ONCE in the client (never in one of its comments): every literal occurrence would otherwise be
|
|
130
|
+
* replaced by the whole DOT.
|
|
108
131
|
*/
|
|
109
132
|
private script;
|
|
110
133
|
/**
|