@md-code/component-uniqueness 0.1.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/LICENSE +202 -0
  3. package/README.md +21 -3
  4. package/dist/config.d.ts +50 -0
  5. package/dist/config.js +402 -0
  6. package/dist/constants.d.ts +55 -0
  7. package/dist/constants.js +86 -0
  8. package/dist/decision-maker.d.ts +39 -0
  9. package/dist/decision-maker.js +119 -0
  10. package/dist/filter/child-element.d.ts +3 -0
  11. package/dist/filter/child-element.js +17 -0
  12. package/dist/filter/missing-component.d.ts +10 -0
  13. package/dist/filter/missing-component.js +96 -0
  14. package/dist/filter/no-structure.d.ts +3 -0
  15. package/dist/filter/no-structure.js +16 -0
  16. package/dist/filter/usages.d.ts +3 -0
  17. package/dist/filter/usages.js +14 -0
  18. package/dist/index.d.ts +105 -0
  19. package/dist/index.js +244 -0
  20. package/dist/lib-registry.d.ts +4 -0
  21. package/dist/lib-registry.js +376 -0
  22. package/dist/logger.d.ts +7 -0
  23. package/dist/logger.js +70 -0
  24. package/dist/main.d.ts +25 -0
  25. package/dist/main.js +666 -0
  26. package/dist/matcher/a11y.d.ts +19 -0
  27. package/dist/matcher/a11y.js +311 -0
  28. package/dist/matcher/behavior.d.ts +10 -0
  29. package/dist/matcher/behavior.js +32 -0
  30. package/dist/matcher/css-matching.d.ts +18 -0
  31. package/dist/matcher/css-matching.js +159 -0
  32. package/dist/matcher/framework/index.d.ts +2 -0
  33. package/dist/matcher/framework/index.js +37 -0
  34. package/dist/matcher/framework/react.d.ts +12 -0
  35. package/dist/matcher/framework/react.js +70 -0
  36. package/dist/matcher/index.d.ts +64 -0
  37. package/dist/matcher/index.js +38 -0
  38. package/dist/matcher/name.d.ts +15 -0
  39. package/dist/matcher/name.js +154 -0
  40. package/dist/matcher/structure.d.ts +22 -0
  41. package/dist/matcher/structure.js +329 -0
  42. package/dist/matcher/styles.d.ts +20 -0
  43. package/dist/matcher/styles.js +49 -0
  44. package/dist/normalize/candidate.d.ts +3 -0
  45. package/dist/normalize/candidate.js +21 -0
  46. package/dist/normalize/dom.d.ts +22 -0
  47. package/dist/normalize/dom.js +180 -0
  48. package/dist/normalize/external-html.d.ts +5 -0
  49. package/dist/normalize/external-html.js +40 -0
  50. package/dist/normalize/framework.d.ts +20 -0
  51. package/dist/normalize/framework.js +130 -0
  52. package/dist/normalize/resolver.d.ts +7 -0
  53. package/dist/normalize/resolver.js +28 -0
  54. package/dist/normalize/style-resolver.d.ts +7 -0
  55. package/dist/normalize/style-resolver.js +28 -0
  56. package/dist/normalize/style.d.ts +15 -0
  57. package/dist/normalize/style.js +174 -0
  58. package/dist/normalize/words.d.ts +3 -0
  59. package/dist/normalize/words.js +40 -0
  60. package/dist/package.json +88 -0
  61. package/dist/playgrounds/angular.d.ts +7 -0
  62. package/dist/playgrounds/angular.js +9 -0
  63. package/dist/playgrounds/framework-entrypoint.d.ts +10 -0
  64. package/dist/playgrounds/framework-entrypoint.js +102 -0
  65. package/dist/playgrounds/framework.d.ts +10 -0
  66. package/dist/playgrounds/framework.js +102 -0
  67. package/dist/playgrounds/react.d.ts +14 -0
  68. package/dist/playgrounds/react.js +1288 -0
  69. package/dist/playgrounds/scss.d.ts +6 -0
  70. package/dist/playgrounds/scss.js +9 -0
  71. package/dist/playgrounds/style-entrypoint.d.ts +13 -0
  72. package/dist/playgrounds/style-entrypoint.js +82 -0
  73. package/dist/playgrounds/style.d.ts +13 -0
  74. package/dist/playgrounds/style.js +82 -0
  75. package/dist/playgrounds/styled-components.d.ts +7 -0
  76. package/dist/playgrounds/styled-components.js +190 -0
  77. package/dist/playgrounds/tailwind.d.ts +15 -0
  78. package/dist/playgrounds/tailwind.js +256 -0
  79. package/dist/playgrounds/vue.d.ts +7 -0
  80. package/dist/playgrounds/vue.js +9 -0
  81. package/dist/report/asks.d.ts +27 -0
  82. package/dist/report/asks.js +28 -0
  83. package/dist/report/cli-report.d.ts +7 -0
  84. package/dist/report/cli-report.js +187 -0
  85. package/dist/report/codes/index.d.ts +37 -0
  86. package/dist/report/codes/index.js +31 -0
  87. package/dist/report/errorTypes/index.d.ts +92 -0
  88. package/dist/report/errorTypes/index.js +186 -0
  89. package/dist/report/evidence.d.ts +2 -0
  90. package/dist/report/evidence.js +8 -0
  91. package/dist/report/explain.d.ts +27 -0
  92. package/dist/report/explain.js +76 -0
  93. package/dist/report/index.d.ts +2 -0
  94. package/dist/report/index.js +24 -0
  95. package/dist/report/matchers/a11y/model.d.ts +20 -0
  96. package/dist/report/matchers/a11y/model.js +14 -0
  97. package/dist/report/matchers/a11y/text.d.ts +2 -0
  98. package/dist/report/matchers/a11y/text.js +22 -0
  99. package/dist/report/matchers/behavior/model.d.ts +20 -0
  100. package/dist/report/matchers/behavior/model.js +12 -0
  101. package/dist/report/matchers/behavior/text.d.ts +2 -0
  102. package/dist/report/matchers/behavior/text.js +22 -0
  103. package/dist/report/matchers/framework/model.d.ts +10 -0
  104. package/dist/report/matchers/framework/model.js +39 -0
  105. package/dist/report/matchers/framework/text.d.ts +2 -0
  106. package/dist/report/matchers/framework/text.js +26 -0
  107. package/dist/report/matchers/index.d.ts +5 -0
  108. package/dist/report/matchers/index.js +97 -0
  109. package/dist/report/matchers/name/model.d.ts +20 -0
  110. package/dist/report/matchers/name/model.js +30 -0
  111. package/dist/report/matchers/name/text.d.ts +2 -0
  112. package/dist/report/matchers/name/text.js +17 -0
  113. package/dist/report/matchers/set-model.d.ts +31 -0
  114. package/dist/report/matchers/set-model.js +42 -0
  115. package/dist/report/matchers/structure/model.d.ts +10 -0
  116. package/dist/report/matchers/structure/model.js +58 -0
  117. package/dist/report/matchers/structure/text.d.ts +2 -0
  118. package/dist/report/matchers/structure/text.js +40 -0
  119. package/dist/report/matchers/styles/model.d.ts +11 -0
  120. package/dist/report/matchers/styles/model.js +36 -0
  121. package/dist/report/matchers/styles/text.d.ts +2 -0
  122. package/dist/report/matchers/styles/text.js +40 -0
  123. package/dist/report/user-report/build/bundle.d.ts +3 -0
  124. package/dist/report/user-report/build/bundle.js +185 -0
  125. package/dist/report/user-report/build/bundle.prebuilt.js +955 -0
  126. package/dist/report/user-report/data/collect.d.ts +68 -0
  127. package/dist/report/user-report/data/collect.js +150 -0
  128. package/dist/report/user-report/data/folders.d.ts +3 -0
  129. package/dist/report/user-report/data/folders.js +73 -0
  130. package/dist/report/user-report/data/groups.d.ts +13 -0
  131. package/dist/report/user-report/data/groups.js +76 -0
  132. package/dist/report/user-report/data/links.d.ts +39 -0
  133. package/dist/report/user-report/data/links.js +222 -0
  134. package/dist/report/user-report/data/snapshot.d.ts +9 -0
  135. package/dist/report/user-report/data/snapshot.js +180 -0
  136. package/dist/report/user-report/data/source.d.ts +13 -0
  137. package/dist/report/user-report/data/source.js +58 -0
  138. package/dist/report/user-report/data/word.d.ts +3 -0
  139. package/dist/report/user-report/data/word.js +32 -0
  140. package/dist/report/user-report/html/shell.d.ts +2 -0
  141. package/dist/report/user-report/html/shell.js +27 -0
  142. package/dist/report/user-report/index.d.ts +7 -0
  143. package/dist/report/user-report/index.js +47 -0
  144. package/dist/report/vocabulary/evidence.d.ts +48 -0
  145. package/dist/report/vocabulary/evidence.js +66 -0
  146. package/dist/report/vocabulary/format.d.ts +4 -0
  147. package/dist/report/vocabulary/format.js +20 -0
  148. package/dist/report/vocabulary/labels.d.ts +134 -0
  149. package/dist/report/vocabulary/labels.js +87 -0
  150. package/dist/report/vocabulary/phrases.d.ts +20 -0
  151. package/dist/report/vocabulary/phrases.js +34 -0
  152. package/dist/self-catalog.d.ts +4 -0
  153. package/dist/self-catalog.js +179 -0
  154. package/dist/utils.d.ts +6 -0
  155. package/dist/utils.js +125 -0
  156. package/package.json +86 -60
  157. package/config.js +0 -362
  158. package/decision-maker.js +0 -109
  159. package/filter/drop-child-element.js +0 -13
  160. package/filter/drop-usages.js +0 -13
  161. package/filter/missing-component.js +0 -68
  162. package/index.js +0 -184
  163. package/logger.js +0 -44
  164. package/main.js +0 -539
  165. package/matcher/a11y.js +0 -65
  166. package/matcher/behavior.js +0 -31
  167. package/matcher/framework/index.js +0 -15
  168. package/matcher/framework/react.js +0 -25
  169. package/matcher/index.js +0 -36
  170. package/matcher/name.js +0 -132
  171. package/matcher/structure.js +0 -208
  172. package/normalize/candidate.js +0 -22
  173. package/normalize/dom.js +0 -167
  174. package/normalize/framework.js +0 -129
  175. package/normalize/style-resolver.js +0 -24
  176. package/normalize/style.js +0 -175
  177. package/normalize/words.js +0 -40
  178. package/playgrounds/angular.js +0 -11
  179. package/playgrounds/framework-entrypoint.js +0 -90
  180. package/playgrounds/react.js +0 -997
  181. package/playgrounds/scss.js +0 -7
  182. package/playgrounds/style-entrypoint.js +0 -78
  183. package/playgrounds/styled-components.js +0 -138
  184. package/playgrounds/tailwind.js +0 -186
  185. package/playgrounds/vue.js +0 -11
  186. package/plugin.js +0 -3
  187. package/report.js +0 -159
  188. package/utils.js +0 -92
@@ -0,0 +1,180 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.statesOf = exports.roleOf = exports.accessibleNameOf = exports.snapshotOf = void 0;
4
+ // ── THE SNAPSHOT: what the component BECOMES, and what a screen reader SEES ──
5
+ //
6
+ // The MODEL states facts only. A component is written as framework tags
7
+ // (`Button`, `Field`); the framework expands each into real HTML
8
+ // (`button > span + Icon`). This module flattens that expanded tree into rows the
9
+ // board can draw, and keeps two facts per row:
10
+ //
11
+ // • the HTML snapshot — the tag the framework rendered, indented by depth, with
12
+ // the component it came FROM (`via`) so the reader sees `Button → button`;
13
+ // • the screen-reader view — only what assistive technology announces: a role,
14
+ // an accessible name, a state. A `div` with no role and no name is silent.
15
+ //
16
+ // Every row carries the CODE LINE the parser reported for it (no text search, so
17
+ // a row never anchors on a comment or a parameter), the CSS the framework
18
+ // resolved, and what a screen reader announces. No character range is computed
19
+ // here — the view (code-diff) locates names and paints marks.
20
+ const isContainer = (tag) => tag === "fragment" || tag === "children";
21
+ const isText = (tag) => tag === "text";
22
+ // The accessible name a screen reader announces for one node: an explicit
23
+ // aria-label, the text it wraps, or the alt/title fallback. Empty = silent.
24
+ const accessibleNameOf = (node) => {
25
+ const attrs = node.attrs || {};
26
+ if (attrs["aria-label"])
27
+ return String(attrs["aria-label"]);
28
+ if (attrs["aria-labelledby"])
29
+ return `labelled by ${attrs["aria-labelledby"]}`;
30
+ if (attrs.alt)
31
+ return String(attrs.alt);
32
+ if (attrs.title)
33
+ return String(attrs.title);
34
+ const text = (node.children || [])
35
+ .filter((child) => isText(child.tag))
36
+ .map((child) => String(child.text || "").trim())
37
+ .filter(Boolean)
38
+ .join(" ");
39
+ return text || null;
40
+ };
41
+ exports.accessibleNameOf = accessibleNameOf;
42
+ // The ARIA states a screen reader reports (expanded / checked / disabled / …).
43
+ const STATE_ATTRS = ["aria-expanded", "aria-checked", "aria-selected", "aria-disabled", "aria-hidden", "aria-pressed", "aria-required", "aria-invalid"];
44
+ const statesOf = (node) => {
45
+ const attrs = node.attrs || {};
46
+ const out = [];
47
+ for (const name of STATE_ATTRS) {
48
+ if (attrs[name] !== undefined && attrs[name] !== null)
49
+ out.push(`${name}=${attrs[name]}`);
50
+ }
51
+ if (attrs.disabled === true || attrs.disabled === "true")
52
+ out.push("disabled");
53
+ return out;
54
+ };
55
+ exports.statesOf = statesOf;
56
+ // The implicit role of an HTML tag, when it has one a screen reader announces.
57
+ const IMPLICIT_ROLE = {
58
+ button: "button",
59
+ a: "link",
60
+ input: "textbox",
61
+ select: "combobox",
62
+ textarea: "textbox",
63
+ img: "img",
64
+ nav: "navigation",
65
+ main: "main",
66
+ header: "banner",
67
+ footer: "contentinfo",
68
+ aside: "complementary",
69
+ form: "form",
70
+ fieldset: "group",
71
+ label: "label",
72
+ h1: "heading",
73
+ h2: "heading",
74
+ h3: "heading",
75
+ h4: "heading",
76
+ h5: "heading",
77
+ h6: "heading",
78
+ ul: "list",
79
+ ol: "list",
80
+ li: "listitem",
81
+ table: "table",
82
+ dialog: "dialog",
83
+ };
84
+ const roleOf = (node) => {
85
+ const attrs = node.attrs || {};
86
+ if (attrs.role)
87
+ return String(attrs.role);
88
+ return IMPLICIT_ROLE[String(node.tag || "").toLowerCase()] ?? null;
89
+ };
90
+ exports.roleOf = roleOf;
91
+ // One snapshot of a component: the HTML rows and the screen-reader rows, each
92
+ // addressed by a stable id and pointing at the code line that produced it.
93
+ const snapshotOf = (candidate, span) => {
94
+ const tree = candidate?.tree ?? null;
95
+ if (!tree || !span)
96
+ return null;
97
+ const html = [];
98
+ const reader = [];
99
+ let at = 0;
100
+ // The resolved-CSS tree (dom.tree, same shape) in document order, so each HTML
101
+ // row can carry its computed styles.
102
+ const domQueue = [];
103
+ const collectDom = (n) => {
104
+ if (!n)
105
+ return;
106
+ if (isContainer(n.tag)) {
107
+ for (const c of n.children || [])
108
+ collectDom(c);
109
+ return;
110
+ }
111
+ if (isText(n.tag))
112
+ return;
113
+ domQueue.push(n);
114
+ for (const c of n.children || [])
115
+ collectDom(c);
116
+ };
117
+ collectDom(candidate?.dom?.tree ?? null);
118
+ let domAt = 0;
119
+ const walk = (node, depth, via) => {
120
+ if (!node)
121
+ return;
122
+ if (isContainer(node.tag)) {
123
+ for (const child of node.children || [])
124
+ walk(child, depth, via);
125
+ return;
126
+ }
127
+ if (isText(node.tag))
128
+ return;
129
+ const id = `s${at}`;
130
+ at += 1;
131
+ // The via CHAIN from the root usage down to the producer. The first name is the
132
+ // component the reader wrote in THIS file (`Button`); the rest is the internal
133
+ // expansion path (`Loader`). The code anchor is that root name on the usage line,
134
+ // so a ribbon always reaches a word the reader can see in the code column.
135
+ const chain = node.via && node.via.length > 0 ? node.via : (via || []);
136
+ const fromVia = chain.length > 0 ? chain[chain.length - 1] : null;
137
+ // The code anchor is the ROOT usage name the parser stamped (the component the
138
+ // reader wrote in THIS file), falling back to the chain head / the tag itself.
139
+ const codeName = node.codeName ?? (chain.length > 0 ? chain[0] : node.tag);
140
+ // The parser reported the exact source line of this element's usage. No text
141
+ // search: a row can never land on a comment or a destructured parameter.
142
+ const line = node.line != null ? String(node.line) : null;
143
+ const name = accessibleNameOf(node);
144
+ const role = roleOf(node);
145
+ const states = statesOf(node);
146
+ const testId = node.attrs?.["data-testid"] ?? node.attrs?.["data-test"] ?? null;
147
+ // Computed CSS from the parallel dom tree (same document order).
148
+ const domNode = domQueue[domAt] && domQueue[domAt].tag === node.tag ? domQueue[domAt] : null;
149
+ if (domNode)
150
+ domAt += 1;
151
+ const css = (domNode && domNode.css) || node.css || {};
152
+ // The HTML row: real tag, with the component the reader WROTE that produced it
153
+ // (the root usage), so `<img> ← Button` reads "this img comes from the Button on
154
+ // line 8" — and hovering lights that same word. The tree INDENT is drawn by the
155
+ // renderer from `depth` (one clear level per nest), not baked into the text, so
156
+ // a parent and its children read as a tree at a glance.
157
+ const viaLabel = codeName && codeName !== node.tag ? ` ← ${codeName}` : "";
158
+ html.push({ id, text: `<${node.tag}>${viaLabel}`, line, tag: node.tag, via: fromVia, viaChain: chain, codeName, codeLine: line, depth, css, role, name });
159
+ // The screen-reader row: only nodes that announce something. A silent
160
+ // container is skipped, but its children are still walked.
161
+ const announces = role || name || states.length > 0 || testId;
162
+ if (announces) {
163
+ const parts = [];
164
+ if (role)
165
+ parts.push(role);
166
+ if (name)
167
+ parts.push(`"${name}"`);
168
+ if (states.length > 0)
169
+ parts.push(states.join(" "));
170
+ if (testId)
171
+ parts.push(`testid=${testId}`);
172
+ reader.push({ id, text: parts.join(" · "), line, tag: node.tag, via: fromVia, viaChain: chain, codeName, codeLine: line, depth, role, name, states, testId });
173
+ }
174
+ for (const child of node.children || [])
175
+ walk(child, depth + 1, node.via || via);
176
+ };
177
+ walk(tree, 0, null);
178
+ return { html, reader, available: candidate?.dom?.available !== false };
179
+ };
180
+ exports.snapshotOf = snapshotOf;
@@ -0,0 +1,13 @@
1
+ declare const readLines: (absPath: any) => any;
2
+ declare const spanOf: (absPath: any, startLine: any, endLine: any) => {
3
+ startLine: any;
4
+ endLine: any;
5
+ lines: any[];
6
+ missing: boolean;
7
+ } | {
8
+ startLine: number;
9
+ endLine: number;
10
+ lines: any[];
11
+ missing: boolean;
12
+ };
13
+ export { readLines, spanOf };
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.spanOf = exports.readLines = void 0;
27
+ // Reading the two sides of a diff. A span is the real lines of the file at the
28
+ // numbers the parser reported, so the viewer shows the code AS THE FILE HAS IT.
29
+ // Files are read once per run and kept: a canonical component may be the
30
+ // right-hand side of twenty pairs.
31
+ const fs = __importStar(require("node:fs"));
32
+ const cache = new Map();
33
+ const readLines = (absPath) => {
34
+ if (cache.has(absPath))
35
+ return cache.get(absPath);
36
+ let lines = null;
37
+ try {
38
+ lines = fs.readFileSync(absPath, "utf8").split(/\r?\n/);
39
+ }
40
+ catch {
41
+ lines = null;
42
+ }
43
+ cache.set(absPath, lines);
44
+ return lines;
45
+ };
46
+ exports.readLines = readLines;
47
+ const spanOf = (absPath, startLine, endLine) => {
48
+ const all = readLines(absPath);
49
+ if (!all)
50
+ return { startLine: startLine ?? 1, endLine: endLine ?? startLine ?? 1, lines: [], missing: true };
51
+ const from = Math.max(1, Number(startLine ?? 1));
52
+ const to = Math.min(all.length, Number(endLine ?? from));
53
+ const lines = [];
54
+ for (let no = from; no <= to; no += 1)
55
+ lines.push({ no, text: all[no - 1] ?? "" });
56
+ return { startLine: from, endLine: to, lines, missing: false };
57
+ };
58
+ exports.spanOf = spanOf;
@@ -0,0 +1,3 @@
1
+ declare const singularOf: (phrase: any) => string;
2
+ declare const wordOf: (phrase: any, count: any) => string;
3
+ export { wordOf, singularOf };
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.singularOf = exports.wordOf = void 0;
4
+ // ── ONE WORD, THE RIGHT NUMBER ─────────────────────────────────────────────
5
+ // A caption says WHAT a lane is about, and the number it says it about is known.
6
+ // The singular is derived from the phrase itself — no table of cases.
7
+ const IRREGULAR = Object.freeze({
8
+ names: "name",
9
+ children: "child",
10
+ });
11
+ const singularWord = (word) => {
12
+ const known = IRREGULAR[word];
13
+ if (known !== undefined)
14
+ return known;
15
+ if (/ies$/.test(word))
16
+ return `${word.slice(0, -3)}y`;
17
+ if (/(ses|xes|ches|shes)$/.test(word))
18
+ return word.slice(0, -2);
19
+ if (/ss$/.test(word))
20
+ return word;
21
+ return /s$/.test(word) ? word.slice(0, -1) : word;
22
+ };
23
+ const singularOf = (phrase) => {
24
+ const words = String(phrase).split(" ");
25
+ if (words.length === 0)
26
+ return String(phrase);
27
+ words[words.length - 1] = singularWord(words[words.length - 1]);
28
+ return words.join(" ");
29
+ };
30
+ exports.singularOf = singularOf;
31
+ const wordOf = (phrase, count) => (count === 1 ? singularOf(phrase) : String(phrase));
32
+ exports.wordOf = wordOf;
@@ -0,0 +1,2 @@
1
+ declare const renderHtml: (data: any) => string;
2
+ export { renderHtml };
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderHtml = void 0;
4
+ // The HTML shell. It inlines the compiled React bundle and the JSON payload into
5
+ // ONE file, so the overview can be written anywhere and opened straight from
6
+ // disk — no server, no network, no sidecar files.
7
+ const bundle_1 = require("../build/bundle");
8
+ const escapeForScript = (text) => String(text).replace(/<\/script/gi, "<\\/script");
9
+ const renderHtml = (data) => {
10
+ const js = escapeForScript((0, bundle_1.getBundle)());
11
+ const payload = escapeForScript(JSON.stringify(data));
12
+ return `<!doctype html>
13
+ <html lang="en">
14
+ <head>
15
+ <meta charset="utf-8" />
16
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
17
+ <title>Component uniqueness — ${data.meta.repoName}</title>
18
+ </head>
19
+ <body>
20
+ <div id="root"></div>
21
+ <script type="application/json" id="utils-data">${payload}</script>
22
+ <script>${js}</script>
23
+ </body>
24
+ </html>
25
+ `;
26
+ };
27
+ exports.renderHtml = renderHtml;
@@ -0,0 +1,7 @@
1
+ import { collectOverviewData } from "./data/collect";
2
+ declare const renderOverview: (data: any) => string;
3
+ declare const writeOverview: (data: any, outPath: any) => {
4
+ path: string;
5
+ bytes: number;
6
+ };
7
+ export { collectOverviewData, renderOverview, writeOverview };
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.writeOverview = exports.renderOverview = exports.collectOverviewData = void 0;
27
+ // Public entry for the interactive overview (`--overview`).
28
+ //
29
+ // const { collectOverviewData, writeOverview } = require("./report/user-report");
30
+ // const written = writeOverview(collectOverviewData({ comp, repoRoot, config, candidates }), "reports/component-overview.html");
31
+ //
32
+ // The payload is plain JSON; the presentation is the React app in ./src,
33
+ // compiled on demand by ./build/bundle.js and inlined by ./html/shell.js.
34
+ const path = __importStar(require("node:path"));
35
+ const fs = __importStar(require("node:fs"));
36
+ const collect_1 = require("./data/collect");
37
+ Object.defineProperty(exports, "collectOverviewData", { enumerable: true, get: function () { return collect_1.collectOverviewData; } });
38
+ const shell_1 = require("./html/shell");
39
+ const renderOverview = (data) => (0, shell_1.renderHtml)(data);
40
+ exports.renderOverview = renderOverview;
41
+ const writeOverview = (data, outPath) => {
42
+ const abs = path.resolve(outPath);
43
+ fs.mkdirSync(path.dirname(abs), { recursive: true });
44
+ fs.writeFileSync(abs, renderOverview(data), "utf8");
45
+ return { path: abs, bytes: fs.statSync(abs).size };
46
+ };
47
+ exports.writeOverview = writeOverview;
@@ -0,0 +1,48 @@
1
+ declare const EVIDENCE_LABELS: Readonly<{
2
+ mode: "comparison mode";
3
+ similarity: "chain similarity";
4
+ quality: "chain quality";
5
+ minNodeSim: "weakest node match";
6
+ chainSize: "matched chain length";
7
+ refSize: "reference size";
8
+ conflicts: "CSS conflicts";
9
+ conflictRatio: "CSS conflict ratio";
10
+ agreement: "CSS agreement";
11
+ classesDiffer: "class names differ";
12
+ ceiling: "score ceiling";
13
+ sizeFactor: "size factor";
14
+ rootSim: "root similarity";
15
+ rejected: "rejected";
16
+ candidateEvents: "events (local)";
17
+ canonicalEvents: "events (canonical)";
18
+ sharedEvents: "shared events";
19
+ smallSetDiscount: "small-set discount";
20
+ candidateA11y: "ARIA (local)";
21
+ canonicalA11y: "ARIA (canonical)";
22
+ candidateTestId: "test ids (local)";
23
+ canonicalTestId: "test ids (canonical)";
24
+ a11ySimilarity: "ARIA overlap";
25
+ testIdSimilarity: "test-id overlap";
26
+ pairs: "matched node pairs";
27
+ properties: "relevant CSS properties";
28
+ agreeing: "agreeing properties";
29
+ candidateUsages: "component usages (local)";
30
+ canonicalUsages: "component usages (canonical)";
31
+ sharedComponents: "shared components";
32
+ nameSimilarity: "component overlap";
33
+ passedPropSimilarity: "passed-prop overlap";
34
+ candidateProps: "props (local)";
35
+ canonicalProps: "props (canonical)";
36
+ candidateNames: "child components (local)";
37
+ canonicalNames: "child components (canonical)";
38
+ propsSimilarity: "props overlap";
39
+ eventsSimilarity: "events overlap";
40
+ namesSimilarity: "child-component overlap";
41
+ exactName: "exact name";
42
+ exactBasename: "exact basename";
43
+ fuzzy: "fuzzy name hit";
44
+ wordSim: "name word overlap";
45
+ matchType: "name match type";
46
+ }>;
47
+ declare const labelOfEvidence: (key: any) => any;
48
+ export { EVIDENCE_LABELS, labelOfEvidence };
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.labelOfEvidence = exports.EVIDENCE_LABELS = void 0;
4
+ // The READER's names for the matchers' evidence keys. The matchers emit numbers
5
+ // under machine-ish keys because they are diagnostics, not prose. A person
6
+ // reading a finding needs the QUESTION the number answers, so the translation
7
+ // lives here with the rest of the wording — not in the decision engine.
8
+ //
9
+ // A key missing here falls back to its own name, so a new evidence field shows
10
+ // up (ugly but visible) instead of disappearing.
11
+ const EVIDENCE_LABELS = Object.freeze({
12
+ // structure
13
+ mode: "comparison mode",
14
+ similarity: "chain similarity",
15
+ quality: "chain quality",
16
+ minNodeSim: "weakest node match",
17
+ chainSize: "matched chain length",
18
+ refSize: "reference size",
19
+ conflicts: "CSS conflicts",
20
+ conflictRatio: "CSS conflict ratio",
21
+ agreement: "CSS agreement",
22
+ classesDiffer: "class names differ",
23
+ ceiling: "score ceiling",
24
+ sizeFactor: "size factor",
25
+ rootSim: "root similarity",
26
+ rejected: "rejected",
27
+ // behavior
28
+ candidateEvents: "events (local)",
29
+ canonicalEvents: "events (canonical)",
30
+ sharedEvents: "shared events",
31
+ smallSetDiscount: "small-set discount",
32
+ // a11y
33
+ candidateA11y: "ARIA (local)",
34
+ canonicalA11y: "ARIA (canonical)",
35
+ candidateTestId: "test ids (local)",
36
+ canonicalTestId: "test ids (canonical)",
37
+ a11ySimilarity: "ARIA overlap",
38
+ testIdSimilarity: "test-id overlap",
39
+ // styles
40
+ pairs: "matched node pairs",
41
+ properties: "relevant CSS properties",
42
+ agreeing: "agreeing properties",
43
+ // framework (usage-based: components USED and props PASSED, never accepted)
44
+ candidateUsages: "component usages (local)",
45
+ canonicalUsages: "component usages (canonical)",
46
+ sharedComponents: "shared components",
47
+ nameSimilarity: "component overlap",
48
+ passedPropSimilarity: "passed-prop overlap",
49
+ // framework (legacy prop keys, kept for older payloads)
50
+ candidateProps: "props (local)",
51
+ canonicalProps: "props (canonical)",
52
+ candidateNames: "child components (local)",
53
+ canonicalNames: "child components (canonical)",
54
+ propsSimilarity: "props overlap",
55
+ eventsSimilarity: "events overlap",
56
+ namesSimilarity: "child-component overlap",
57
+ // name
58
+ exactName: "exact name",
59
+ exactBasename: "exact basename",
60
+ fuzzy: "fuzzy name hit",
61
+ wordSim: "name word overlap",
62
+ matchType: "name match type",
63
+ });
64
+ exports.EVIDENCE_LABELS = EVIDENCE_LABELS;
65
+ const labelOfEvidence = (key) => EVIDENCE_LABELS[key] ?? key;
66
+ exports.labelOfEvidence = labelOfEvidence;
@@ -0,0 +1,4 @@
1
+ declare const num: (n: any) => string;
2
+ declare const pct: (n: any) => string;
3
+ declare const showValue: (value: any) => string;
4
+ export { num, pct, showValue };
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.showValue = exports.pct = exports.num = void 0;
4
+ // Small number/word formatters shared by every surface that prints a verdict.
5
+ // They only ever produce TEXT: the engine decides ("0.8666…"), the report speaks
6
+ // ("0.87", "87%", "yes").
7
+ const num = (n) => (typeof n === "number" && Number.isFinite(n) ? n.toFixed(2) : String(n));
8
+ exports.num = num;
9
+ const pct = (n) => `${Math.round((Number.isFinite(n) ? n : 0) * 100)}%`;
10
+ exports.pct = pct;
11
+ const showValue = (value) => {
12
+ if (typeof value === "boolean")
13
+ return value ? "yes" : "no";
14
+ if (Array.isArray(value))
15
+ return value.length === 0 ? "none" : value.join(", ");
16
+ if (typeof value === "number")
17
+ return Number.isInteger(value) ? String(value) : num(value);
18
+ return String(value);
19
+ };
20
+ exports.showValue = showValue;
@@ -0,0 +1,134 @@
1
+ declare const SIGNALS: ({
2
+ key: "structure";
3
+ label: string;
4
+ short: string;
5
+ color: string;
6
+ what: string;
7
+ } | {
8
+ key: "styles";
9
+ label: string;
10
+ short: string;
11
+ color: string;
12
+ what: string;
13
+ } | {
14
+ key: "behavior";
15
+ label: string;
16
+ short: string;
17
+ color: string;
18
+ what: string;
19
+ } | {
20
+ key: "a11y";
21
+ label: string;
22
+ short: string;
23
+ color: string;
24
+ what: string;
25
+ } | {
26
+ key: "framework";
27
+ label: string;
28
+ short: string;
29
+ color: string;
30
+ what: string;
31
+ } | {
32
+ key: "name";
33
+ label: string;
34
+ short: string;
35
+ color: string;
36
+ what: string;
37
+ })[];
38
+ declare const SIGNAL_KEYS: ("structure" | "styles" | "behavior" | "a11y" | "framework" | "name")[];
39
+ declare const signalOf: (key: any) => {
40
+ key: "structure";
41
+ label: string;
42
+ short: string;
43
+ color: string;
44
+ what: string;
45
+ } | {
46
+ key: "styles";
47
+ label: string;
48
+ short: string;
49
+ color: string;
50
+ what: string;
51
+ } | {
52
+ key: "behavior";
53
+ label: string;
54
+ short: string;
55
+ color: string;
56
+ what: string;
57
+ } | {
58
+ key: "a11y";
59
+ label: string;
60
+ short: string;
61
+ color: string;
62
+ what: string;
63
+ } | {
64
+ key: "framework";
65
+ label: string;
66
+ short: string;
67
+ color: string;
68
+ what: string;
69
+ } | {
70
+ key: "name";
71
+ label: string;
72
+ short: string;
73
+ color: string;
74
+ what: string;
75
+ };
76
+ declare const signalColor: (key: any) => string;
77
+ declare const KINDS: {
78
+ duplicate: {
79
+ label: string;
80
+ color: string;
81
+ action: string;
82
+ };
83
+ similar: {
84
+ label: string;
85
+ color: string;
86
+ action: string;
87
+ };
88
+ missing: {
89
+ label: string;
90
+ color: string;
91
+ action: string;
92
+ };
93
+ rawhtml: {
94
+ label: string;
95
+ color: string;
96
+ action: string;
97
+ };
98
+ part: {
99
+ label: string;
100
+ color: string;
101
+ action: string;
102
+ };
103
+ dropped: {
104
+ label: string;
105
+ color: string;
106
+ action: string;
107
+ };
108
+ };
109
+ declare const kindOf: (key: any) => any;
110
+ declare const KIND_TILES: readonly ({
111
+ key: "duplicate";
112
+ label: string;
113
+ } | {
114
+ key: "similar";
115
+ label: string;
116
+ } | {
117
+ key: "missing";
118
+ label: string;
119
+ } | {
120
+ key: "rawhtml";
121
+ label: string;
122
+ } | {
123
+ key: "part";
124
+ label: string;
125
+ } | {
126
+ key: "dropped";
127
+ label: string;
128
+ })[];
129
+ declare const TIER_LABEL: {
130
+ duplicate: string;
131
+ similar: string;
132
+ none: string;
133
+ };
134
+ export { SIGNALS, SIGNAL_KEYS, signalOf, signalColor, KINDS, kindOf, KIND_TILES, TIER_LABEL };