@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.
- package/CHANGELOG.md +17 -0
- package/LICENSE +202 -0
- package/README.md +21 -3
- package/dist/config.d.ts +50 -0
- package/dist/config.js +402 -0
- package/dist/constants.d.ts +55 -0
- package/dist/constants.js +86 -0
- package/dist/decision-maker.d.ts +39 -0
- package/dist/decision-maker.js +119 -0
- package/dist/filter/child-element.d.ts +3 -0
- package/dist/filter/child-element.js +17 -0
- package/dist/filter/missing-component.d.ts +10 -0
- package/dist/filter/missing-component.js +96 -0
- package/dist/filter/no-structure.d.ts +3 -0
- package/dist/filter/no-structure.js +16 -0
- package/dist/filter/usages.d.ts +3 -0
- package/dist/filter/usages.js +14 -0
- package/dist/index.d.ts +105 -0
- package/dist/index.js +244 -0
- package/dist/lib-registry.d.ts +4 -0
- package/dist/lib-registry.js +376 -0
- package/dist/logger.d.ts +7 -0
- package/dist/logger.js +70 -0
- package/dist/main.d.ts +25 -0
- package/dist/main.js +666 -0
- package/dist/matcher/a11y.d.ts +19 -0
- package/dist/matcher/a11y.js +311 -0
- package/dist/matcher/behavior.d.ts +10 -0
- package/dist/matcher/behavior.js +32 -0
- package/dist/matcher/css-matching.d.ts +18 -0
- package/dist/matcher/css-matching.js +159 -0
- package/dist/matcher/framework/index.d.ts +2 -0
- package/dist/matcher/framework/index.js +37 -0
- package/dist/matcher/framework/react.d.ts +12 -0
- package/dist/matcher/framework/react.js +70 -0
- package/dist/matcher/index.d.ts +64 -0
- package/dist/matcher/index.js +38 -0
- package/dist/matcher/name.d.ts +15 -0
- package/dist/matcher/name.js +154 -0
- package/dist/matcher/structure.d.ts +22 -0
- package/dist/matcher/structure.js +329 -0
- package/dist/matcher/styles.d.ts +20 -0
- package/dist/matcher/styles.js +49 -0
- package/dist/normalize/candidate.d.ts +3 -0
- package/dist/normalize/candidate.js +21 -0
- package/dist/normalize/dom.d.ts +22 -0
- package/dist/normalize/dom.js +180 -0
- package/dist/normalize/external-html.d.ts +5 -0
- package/dist/normalize/external-html.js +40 -0
- package/dist/normalize/framework.d.ts +20 -0
- package/dist/normalize/framework.js +130 -0
- package/dist/normalize/resolver.d.ts +7 -0
- package/dist/normalize/resolver.js +28 -0
- package/dist/normalize/style-resolver.d.ts +7 -0
- package/dist/normalize/style-resolver.js +28 -0
- package/dist/normalize/style.d.ts +15 -0
- package/dist/normalize/style.js +174 -0
- package/dist/normalize/words.d.ts +3 -0
- package/dist/normalize/words.js +40 -0
- package/dist/package.json +88 -0
- package/dist/playgrounds/angular.d.ts +7 -0
- package/dist/playgrounds/angular.js +9 -0
- package/dist/playgrounds/framework-entrypoint.d.ts +10 -0
- package/dist/playgrounds/framework-entrypoint.js +102 -0
- package/dist/playgrounds/framework.d.ts +10 -0
- package/dist/playgrounds/framework.js +102 -0
- package/dist/playgrounds/react.d.ts +14 -0
- package/dist/playgrounds/react.js +1288 -0
- package/dist/playgrounds/scss.d.ts +6 -0
- package/dist/playgrounds/scss.js +9 -0
- package/dist/playgrounds/style-entrypoint.d.ts +13 -0
- package/dist/playgrounds/style-entrypoint.js +82 -0
- package/dist/playgrounds/style.d.ts +13 -0
- package/dist/playgrounds/style.js +82 -0
- package/dist/playgrounds/styled-components.d.ts +7 -0
- package/dist/playgrounds/styled-components.js +190 -0
- package/dist/playgrounds/tailwind.d.ts +15 -0
- package/dist/playgrounds/tailwind.js +256 -0
- package/dist/playgrounds/vue.d.ts +7 -0
- package/dist/playgrounds/vue.js +9 -0
- package/dist/report/asks.d.ts +27 -0
- package/dist/report/asks.js +28 -0
- package/dist/report/cli-report.d.ts +7 -0
- package/dist/report/cli-report.js +187 -0
- package/dist/report/codes/index.d.ts +37 -0
- package/dist/report/codes/index.js +31 -0
- package/dist/report/errorTypes/index.d.ts +92 -0
- package/dist/report/errorTypes/index.js +186 -0
- package/dist/report/evidence.d.ts +2 -0
- package/dist/report/evidence.js +8 -0
- package/dist/report/explain.d.ts +27 -0
- package/dist/report/explain.js +76 -0
- package/dist/report/index.d.ts +2 -0
- package/dist/report/index.js +24 -0
- package/dist/report/matchers/a11y/model.d.ts +20 -0
- package/dist/report/matchers/a11y/model.js +14 -0
- package/dist/report/matchers/a11y/text.d.ts +2 -0
- package/dist/report/matchers/a11y/text.js +22 -0
- package/dist/report/matchers/behavior/model.d.ts +20 -0
- package/dist/report/matchers/behavior/model.js +12 -0
- package/dist/report/matchers/behavior/text.d.ts +2 -0
- package/dist/report/matchers/behavior/text.js +22 -0
- package/dist/report/matchers/framework/model.d.ts +10 -0
- package/dist/report/matchers/framework/model.js +39 -0
- package/dist/report/matchers/framework/text.d.ts +2 -0
- package/dist/report/matchers/framework/text.js +26 -0
- package/dist/report/matchers/index.d.ts +5 -0
- package/dist/report/matchers/index.js +97 -0
- package/dist/report/matchers/name/model.d.ts +20 -0
- package/dist/report/matchers/name/model.js +30 -0
- package/dist/report/matchers/name/text.d.ts +2 -0
- package/dist/report/matchers/name/text.js +17 -0
- package/dist/report/matchers/set-model.d.ts +31 -0
- package/dist/report/matchers/set-model.js +42 -0
- package/dist/report/matchers/structure/model.d.ts +10 -0
- package/dist/report/matchers/structure/model.js +58 -0
- package/dist/report/matchers/structure/text.d.ts +2 -0
- package/dist/report/matchers/structure/text.js +40 -0
- package/dist/report/matchers/styles/model.d.ts +11 -0
- package/dist/report/matchers/styles/model.js +36 -0
- package/dist/report/matchers/styles/text.d.ts +2 -0
- package/dist/report/matchers/styles/text.js +40 -0
- package/dist/report/user-report/build/bundle.d.ts +3 -0
- package/dist/report/user-report/build/bundle.js +185 -0
- package/dist/report/user-report/build/bundle.prebuilt.js +955 -0
- package/dist/report/user-report/data/collect.d.ts +68 -0
- package/dist/report/user-report/data/collect.js +150 -0
- package/dist/report/user-report/data/folders.d.ts +3 -0
- package/dist/report/user-report/data/folders.js +73 -0
- package/dist/report/user-report/data/groups.d.ts +13 -0
- package/dist/report/user-report/data/groups.js +76 -0
- package/dist/report/user-report/data/links.d.ts +39 -0
- package/dist/report/user-report/data/links.js +222 -0
- package/dist/report/user-report/data/snapshot.d.ts +9 -0
- package/dist/report/user-report/data/snapshot.js +180 -0
- package/dist/report/user-report/data/source.d.ts +13 -0
- package/dist/report/user-report/data/source.js +58 -0
- package/dist/report/user-report/data/word.d.ts +3 -0
- package/dist/report/user-report/data/word.js +32 -0
- package/dist/report/user-report/html/shell.d.ts +2 -0
- package/dist/report/user-report/html/shell.js +27 -0
- package/dist/report/user-report/index.d.ts +7 -0
- package/dist/report/user-report/index.js +47 -0
- package/dist/report/vocabulary/evidence.d.ts +48 -0
- package/dist/report/vocabulary/evidence.js +66 -0
- package/dist/report/vocabulary/format.d.ts +4 -0
- package/dist/report/vocabulary/format.js +20 -0
- package/dist/report/vocabulary/labels.d.ts +134 -0
- package/dist/report/vocabulary/labels.js +87 -0
- package/dist/report/vocabulary/phrases.d.ts +20 -0
- package/dist/report/vocabulary/phrases.js +34 -0
- package/dist/self-catalog.d.ts +4 -0
- package/dist/self-catalog.js +179 -0
- package/dist/utils.d.ts +6 -0
- package/dist/utils.js +125 -0
- package/package.json +86 -60
- package/config.js +0 -362
- package/decision-maker.js +0 -109
- package/filter/drop-child-element.js +0 -13
- package/filter/drop-usages.js +0 -13
- package/filter/missing-component.js +0 -68
- package/index.js +0 -184
- package/logger.js +0 -44
- package/main.js +0 -539
- package/matcher/a11y.js +0 -65
- package/matcher/behavior.js +0 -31
- package/matcher/framework/index.js +0 -15
- package/matcher/framework/react.js +0 -25
- package/matcher/index.js +0 -36
- package/matcher/name.js +0 -132
- package/matcher/structure.js +0 -208
- package/normalize/candidate.js +0 -22
- package/normalize/dom.js +0 -167
- package/normalize/framework.js +0 -129
- package/normalize/style-resolver.js +0 -24
- package/normalize/style.js +0 -175
- package/normalize/words.js +0 -40
- package/playgrounds/angular.js +0 -11
- package/playgrounds/framework-entrypoint.js +0 -90
- package/playgrounds/react.js +0 -997
- package/playgrounds/scss.js +0 -7
- package/playgrounds/style-entrypoint.js +0 -78
- package/playgrounds/styled-components.js +0 -138
- package/playgrounds/tailwind.js +0 -186
- package/playgrounds/vue.js +0 -11
- package/plugin.js +0 -3
- package/report.js +0 -159
- package/utils.js +0 -92
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.explain = void 0;
|
|
4
|
+
// One explanation per pair, in the SAME shape the entities report uses, so the
|
|
5
|
+
// DecisionPanel, the signal pills and the CLI verdict rows read it unchanged.
|
|
6
|
+
//
|
|
7
|
+
// `decision` is what the component `decide()` returned: it carries `signals`
|
|
8
|
+
// (score + evidence per group), `weights` and `thresholds`. This module only
|
|
9
|
+
// turns those numbers into the reader's words — it never re-decides.
|
|
10
|
+
const labels_1 = require("./vocabulary/labels");
|
|
11
|
+
const phrases_1 = require("./vocabulary/phrases");
|
|
12
|
+
const format_1 = require("./vocabulary/format");
|
|
13
|
+
const evidence_1 = require("./vocabulary/evidence");
|
|
14
|
+
const constants_1 = require("../constants");
|
|
15
|
+
const chips = (evidence) => Object.entries(evidence ?? {})
|
|
16
|
+
.filter(([, value]) => value !== undefined && value !== null)
|
|
17
|
+
.map(([key, value]) => ({ key, label: (0, evidence_1.labelOfEvidence)(key), value: (0, format_1.showValue)(value) }));
|
|
18
|
+
// The share of the verdict each signal produced: weight × score over the total.
|
|
19
|
+
const contributionOf = (decision, key, totalWeight) => {
|
|
20
|
+
const score = decision.signals?.[key]?.score ?? 0;
|
|
21
|
+
const weight = decision.weights?.[key] ?? 0;
|
|
22
|
+
return (weight * score) / (totalWeight || 1);
|
|
23
|
+
};
|
|
24
|
+
const explain = (decision) => {
|
|
25
|
+
const totalWeight = labels_1.SIGNALS.reduce((sum, s) => sum + (decision.weights?.[s.key] ?? 0), 0) || 1;
|
|
26
|
+
const rows = labels_1.SIGNALS.map((signal) => {
|
|
27
|
+
const sig = decision.signals?.[signal.key] ?? {};
|
|
28
|
+
const score = sig.score ?? 0;
|
|
29
|
+
const weight = decision.weights?.[signal.key] ?? 0;
|
|
30
|
+
// A signal whose weight was zeroed (no evidence / not applicable) is OFF:
|
|
31
|
+
// it neither supports nor refutes the verdict.
|
|
32
|
+
const applied = weight > 0;
|
|
33
|
+
const contribution = contributionOf(decision, signal.key, totalWeight);
|
|
34
|
+
return {
|
|
35
|
+
key: signal.key,
|
|
36
|
+
label: signal.label,
|
|
37
|
+
short: signal.short,
|
|
38
|
+
color: signal.color,
|
|
39
|
+
what: signal.what,
|
|
40
|
+
score,
|
|
41
|
+
weight,
|
|
42
|
+
contribution,
|
|
43
|
+
applied,
|
|
44
|
+
evidence: chips(sig.evidence),
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
const why = [];
|
|
48
|
+
for (const row of [...rows].sort((a, b) => b.contribution - a.contribution)) {
|
|
49
|
+
if (!row.applied) {
|
|
50
|
+
why.push({ tone: constants_1.TONE.Off, signal: row.key, text: (0, phrases_1.fill)(phrases_1.PHRASES.signalOff, { label: row.label }) });
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const template = row.score >= 0.6 ? phrases_1.PHRASES.signal : phrases_1.PHRASES.signalDisagrees;
|
|
54
|
+
why.push({
|
|
55
|
+
tone: row.score >= 0.6 ? constants_1.TONE.Agree : constants_1.TONE.Disagree,
|
|
56
|
+
signal: row.key,
|
|
57
|
+
text: (0, phrases_1.fill)(template, { label: row.label, score: (0, format_1.num)(row.score), weight: (0, format_1.pct)(row.weight), what: row.what }),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
const verdict = decision.tier === constants_1.TIER.Duplicate ? constants_1.KIND.Duplicate : decision.tier === constants_1.TIER.Similar ? constants_1.KIND.Similar : "none";
|
|
61
|
+
return {
|
|
62
|
+
confidence: decision.confidence ?? 0,
|
|
63
|
+
tier: decision.tier,
|
|
64
|
+
verdict,
|
|
65
|
+
thresholds: decision.thresholds ?? {},
|
|
66
|
+
weights: decision.weights ?? {},
|
|
67
|
+
vetoes: [],
|
|
68
|
+
signals: rows,
|
|
69
|
+
why,
|
|
70
|
+
headline: (() => {
|
|
71
|
+
const top = [...rows].sort((a, b) => b.contribution - a.contribution)[0];
|
|
72
|
+
return (0, phrases_1.fill)(phrases_1.PHRASES.headline, { confidence: (0, format_1.num)(decision.confidence), top: top ? top.label : "—", share: (0, format_1.pct)(top ? top.contribution : 0) });
|
|
73
|
+
})(),
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
exports.explain = explain;
|
|
@@ -0,0 +1,24 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.TIER_ORDER = void 0;
|
|
18
|
+
// The report folder's public surface. `require("./report")` and the published
|
|
19
|
+
// `./report` subpath both resolve here, so the folder exposes ONE barrel named
|
|
20
|
+
// `index` instead of a root-level `report.ts` shim beside it. `TIER_ORDER` is
|
|
21
|
+
// the extra export the old shim carried for its consumers.
|
|
22
|
+
__exportStar(require("./cli-report"), exports);
|
|
23
|
+
var constants_1 = require("../constants");
|
|
24
|
+
Object.defineProperty(exports, "TIER_ORDER", { enumerable: true, get: function () { return constants_1.TIER_ORDER; } });
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare const build: (left: any, right: any, signal: any) => {
|
|
2
|
+
rows: {
|
|
3
|
+
name: unknown;
|
|
4
|
+
left: {
|
|
5
|
+
name: unknown;
|
|
6
|
+
};
|
|
7
|
+
right: {
|
|
8
|
+
name: unknown;
|
|
9
|
+
};
|
|
10
|
+
shared: boolean;
|
|
11
|
+
same: boolean;
|
|
12
|
+
}[];
|
|
13
|
+
sharedCount: number;
|
|
14
|
+
leftCount: number;
|
|
15
|
+
rightCount: number;
|
|
16
|
+
score: any;
|
|
17
|
+
hasEvidence: boolean;
|
|
18
|
+
evidence: any;
|
|
19
|
+
};
|
|
20
|
+
export { build };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.build = void 0;
|
|
4
|
+
// The A11Y model: the ARIA roles/attributes and test ids each component carries.
|
|
5
|
+
const set_model_1 = require("../set-model");
|
|
6
|
+
const build = (left, right, signal) => {
|
|
7
|
+
if (!left || !right)
|
|
8
|
+
return null;
|
|
9
|
+
const ev = signal?.evidence ?? {};
|
|
10
|
+
const leftTokens = [...(ev.candidateA11y ?? []), ...(ev.candidateTestId ?? [])];
|
|
11
|
+
const rightTokens = [...(ev.canonicalA11y ?? []), ...(ev.canonicalTestId ?? [])];
|
|
12
|
+
return (0, set_model_1.buildSet)(signal, leftTokens, rightTokens);
|
|
13
|
+
};
|
|
14
|
+
exports.build = build;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.text = void 0;
|
|
4
|
+
// The A11Y CLI text: the score, then the shared ARIA / test-id tokens.
|
|
5
|
+
const pct = (n) => `${Math.round((n ?? 0) * 100)}%`;
|
|
6
|
+
const text = (model) => {
|
|
7
|
+
if (!model || !model.hasEvidence)
|
|
8
|
+
return [];
|
|
9
|
+
const shared = model.rows.filter((r) => r.shared).map((r) => r.name);
|
|
10
|
+
const head = `${pct(model.score)} ${shared.length} shared a11y token(s) (${model.leftCount}↔${model.rightCount})`;
|
|
11
|
+
const lines = [head];
|
|
12
|
+
if (shared.length > 0)
|
|
13
|
+
lines.push(`shared ${shared.join(", ")}`);
|
|
14
|
+
const onlyA = model.rows.filter((r) => r.left && !r.right).map((r) => r.name);
|
|
15
|
+
const onlyB = model.rows.filter((r) => r.right && !r.left).map((r) => r.name);
|
|
16
|
+
if (onlyA.length > 0)
|
|
17
|
+
lines.push(`only local ${onlyA.join(", ")}`);
|
|
18
|
+
if (onlyB.length > 0)
|
|
19
|
+
lines.push(`only canonical ${onlyB.join(", ")}`);
|
|
20
|
+
return lines;
|
|
21
|
+
};
|
|
22
|
+
exports.text = text;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare const build: (left: any, right: any, signal: any) => {
|
|
2
|
+
rows: {
|
|
3
|
+
name: unknown;
|
|
4
|
+
left: {
|
|
5
|
+
name: unknown;
|
|
6
|
+
};
|
|
7
|
+
right: {
|
|
8
|
+
name: unknown;
|
|
9
|
+
};
|
|
10
|
+
shared: boolean;
|
|
11
|
+
same: boolean;
|
|
12
|
+
}[];
|
|
13
|
+
sharedCount: number;
|
|
14
|
+
leftCount: number;
|
|
15
|
+
rightCount: number;
|
|
16
|
+
score: any;
|
|
17
|
+
hasEvidence: boolean;
|
|
18
|
+
evidence: any;
|
|
19
|
+
};
|
|
20
|
+
export { build };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.build = void 0;
|
|
4
|
+
// The BEHAVIOR model: the events each component handles, side by side.
|
|
5
|
+
const set_model_1 = require("../set-model");
|
|
6
|
+
const build = (left, right, signal) => {
|
|
7
|
+
if (!left || !right)
|
|
8
|
+
return null;
|
|
9
|
+
const ev = signal?.evidence ?? {};
|
|
10
|
+
return (0, set_model_1.buildSet)(signal, ev.candidateEvents ?? left.framework?.events, ev.canonicalEvents ?? right.framework?.events);
|
|
11
|
+
};
|
|
12
|
+
exports.build = build;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.text = void 0;
|
|
4
|
+
// The BEHAVIOR CLI text: the score, then the shared events and the surplus.
|
|
5
|
+
const pct = (n) => `${Math.round((n ?? 0) * 100)}%`;
|
|
6
|
+
const text = (model) => {
|
|
7
|
+
if (!model || !model.hasEvidence)
|
|
8
|
+
return [];
|
|
9
|
+
const shared = model.rows.filter((r) => r.shared).map((r) => r.name);
|
|
10
|
+
const head = `${pct(model.score)} ${shared.length} shared event(s) (${model.leftCount}↔${model.rightCount})`;
|
|
11
|
+
const lines = [head];
|
|
12
|
+
if (shared.length > 0)
|
|
13
|
+
lines.push(`shared ${shared.join(", ")}`);
|
|
14
|
+
const onlyA = model.rows.filter((r) => r.left && !r.right).map((r) => r.name);
|
|
15
|
+
const onlyB = model.rows.filter((r) => r.right && !r.left).map((r) => r.name);
|
|
16
|
+
if (onlyA.length > 0)
|
|
17
|
+
lines.push(`only local ${onlyA.join(", ")}`);
|
|
18
|
+
if (onlyB.length > 0)
|
|
19
|
+
lines.push(`only canonical ${onlyB.join(", ")}`);
|
|
20
|
+
return lines;
|
|
21
|
+
};
|
|
22
|
+
exports.text = text;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.build = void 0;
|
|
4
|
+
// The FRAMEWORK model: the components each side USES and the props it PASSES,
|
|
5
|
+
// side by side. One row per matched component usage; the shared passed props are
|
|
6
|
+
// the correspondence. Accepted parameter props are never compared here.
|
|
7
|
+
const build = (left, right, signal) => {
|
|
8
|
+
if (!left || !right)
|
|
9
|
+
return null;
|
|
10
|
+
const ev = signal?.evidence ?? {};
|
|
11
|
+
const pairs = ev.pairs ?? [];
|
|
12
|
+
const rows = pairs.map((pair) => ({
|
|
13
|
+
name: pair.name,
|
|
14
|
+
left: { name: pair.name, line: pair.leftLine },
|
|
15
|
+
right: { name: pair.name, line: pair.rightLine },
|
|
16
|
+
shared: true,
|
|
17
|
+
same: (pair.sharedProps ?? []).length > 0 || (pair.leftProps ?? []).length === 0,
|
|
18
|
+
sharedProps: pair.sharedProps ?? [],
|
|
19
|
+
leftProps: pair.leftProps ?? [],
|
|
20
|
+
rightProps: pair.rightProps ?? [],
|
|
21
|
+
}));
|
|
22
|
+
// Usages present on one side only: surplus rows, not correspondences.
|
|
23
|
+
const leftOnly = (ev.candidateUsages ?? []).filter((n) => !(ev.sharedComponents ?? []).includes(n));
|
|
24
|
+
const rightOnly = (ev.canonicalUsages ?? []).filter((n) => !(ev.sharedComponents ?? []).includes(n));
|
|
25
|
+
for (const name of leftOnly)
|
|
26
|
+
rows.push({ name, left: { name }, right: null, shared: false, same: false });
|
|
27
|
+
for (const name of rightOnly)
|
|
28
|
+
rows.push({ name, left: null, right: { name }, shared: false, same: false });
|
|
29
|
+
return {
|
|
30
|
+
rows,
|
|
31
|
+
sharedCount: rows.filter((r) => r.shared).length,
|
|
32
|
+
leftCount: (ev.candidateUsages ?? []).length,
|
|
33
|
+
rightCount: (ev.canonicalUsages ?? []).length,
|
|
34
|
+
score: signal?.score ?? 0,
|
|
35
|
+
hasEvidence: rows.length > 0,
|
|
36
|
+
evidence: ev,
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
exports.build = build;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.text = void 0;
|
|
4
|
+
// The FRAMEWORK CLI text: the score, then the shared component usages and the
|
|
5
|
+
// props passed to them. Usage against usage — never accepted parameter props.
|
|
6
|
+
const pct = (n) => `${Math.round((n ?? 0) * 100)}%`;
|
|
7
|
+
const text = (model) => {
|
|
8
|
+
if (!model || !model.hasEvidence)
|
|
9
|
+
return [];
|
|
10
|
+
const shared = model.rows.filter((r) => r.shared).map((r) => r.name);
|
|
11
|
+
const head = `${pct(model.score)} ${shared.length} shared component usage(s) (${model.leftCount}↔${model.rightCount})`;
|
|
12
|
+
const lines = [head];
|
|
13
|
+
if (shared.length > 0)
|
|
14
|
+
lines.push(`shared ${shared.join(", ")}`);
|
|
15
|
+
const withProps = model.rows.filter((r) => r.shared && (r.sharedProps ?? []).length > 0);
|
|
16
|
+
if (withProps.length > 0)
|
|
17
|
+
lines.push(`passed props ${withProps.map((r) => `${r.name}: ${r.sharedProps.join(", ")}`).join(" · ")}`);
|
|
18
|
+
const onlyA = model.rows.filter((r) => r.left && !r.right).map((r) => r.name);
|
|
19
|
+
const onlyB = model.rows.filter((r) => r.right && !r.left).map((r) => r.name);
|
|
20
|
+
if (onlyA.length > 0)
|
|
21
|
+
lines.push(`only local ${onlyA.join(", ")}`);
|
|
22
|
+
if (onlyB.length > 0)
|
|
23
|
+
lines.push(`only canonical ${onlyB.join(", ")}`);
|
|
24
|
+
return lines;
|
|
25
|
+
};
|
|
26
|
+
exports.text = text;
|
|
@@ -0,0 +1,97 @@
|
|
|
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.describe = exports.analyze = exports.MATCHERS = exports.matcherOf = void 0;
|
|
27
|
+
// ── MATCHERS · the one registry ─────────────────────────────────────────────
|
|
28
|
+
//
|
|
29
|
+
// The five comparison groups each live in their own folder with their own MODEL
|
|
30
|
+
// and their own CLI TEXT:
|
|
31
|
+
//
|
|
32
|
+
// matchers/structure/ { model.js, text.js }
|
|
33
|
+
// matchers/behavior/
|
|
34
|
+
// matchers/a11y/
|
|
35
|
+
// matchers/framework/
|
|
36
|
+
// matchers/name/
|
|
37
|
+
//
|
|
38
|
+
// This registry binds them by the SIGNAL key the engine uses, so the page, the
|
|
39
|
+
// markdown report and the decision can never disagree about which group is which.
|
|
40
|
+
//
|
|
41
|
+
// The component engine already scored every pair: `decision.signals[key]` carries
|
|
42
|
+
// {score, evidence}. `analyze(left, right, decision)` arranges those facts into
|
|
43
|
+
// one model per signal; `describe` produces the CLI lines. No re-deciding here.
|
|
44
|
+
const constants_1 = require("../../constants");
|
|
45
|
+
const structureModel = __importStar(require("./structure/model"));
|
|
46
|
+
const structureText = __importStar(require("./structure/text"));
|
|
47
|
+
const stylesModel = __importStar(require("./styles/model"));
|
|
48
|
+
const stylesText = __importStar(require("./styles/text"));
|
|
49
|
+
const behaviorModel = __importStar(require("./behavior/model"));
|
|
50
|
+
const behaviorText = __importStar(require("./behavior/text"));
|
|
51
|
+
const a11yModel = __importStar(require("./a11y/model"));
|
|
52
|
+
const a11yText = __importStar(require("./a11y/text"));
|
|
53
|
+
const frameworkModel = __importStar(require("./framework/model"));
|
|
54
|
+
const frameworkText = __importStar(require("./framework/text"));
|
|
55
|
+
const nameModel = __importStar(require("./name/model"));
|
|
56
|
+
const nameText = __importStar(require("./name/text"));
|
|
57
|
+
const structure = { key: constants_1.SIGNAL.Structure, model: structureModel, text: structureText };
|
|
58
|
+
const styles = { key: constants_1.SIGNAL.Styles, model: stylesModel, text: stylesText };
|
|
59
|
+
const behavior = { key: constants_1.SIGNAL.Behavior, model: behaviorModel, text: behaviorText };
|
|
60
|
+
const a11y = { key: constants_1.SIGNAL.A11y, model: a11yModel, text: a11yText };
|
|
61
|
+
const framework = { key: constants_1.SIGNAL.Framework, model: frameworkModel, text: frameworkText };
|
|
62
|
+
const name = { key: constants_1.SIGNAL.Name, model: nameModel, text: nameText };
|
|
63
|
+
const BY_KEY = new Map([
|
|
64
|
+
[structure.key, structure],
|
|
65
|
+
[styles.key, styles],
|
|
66
|
+
[behavior.key, behavior],
|
|
67
|
+
[a11y.key, a11y],
|
|
68
|
+
[framework.key, framework],
|
|
69
|
+
[name.key, name],
|
|
70
|
+
]);
|
|
71
|
+
const MATCHERS = constants_1.SIGNAL_ORDER.map((key) => BY_KEY.get(key)).filter(Boolean);
|
|
72
|
+
exports.MATCHERS = MATCHERS;
|
|
73
|
+
// Every model for one pair, keyed by SIGNAL: `{ structure: model, … }`.
|
|
74
|
+
const analyze = (left, right, decision) => {
|
|
75
|
+
const out = {};
|
|
76
|
+
for (const matcher of MATCHERS) {
|
|
77
|
+
out[matcher.key] = matcher.model.build(left, right, decision?.signals?.[matcher.key] ?? null);
|
|
78
|
+
}
|
|
79
|
+
return out;
|
|
80
|
+
};
|
|
81
|
+
exports.analyze = analyze;
|
|
82
|
+
// The text lines for one pair, in the same order — used by the CLI report.
|
|
83
|
+
const describe = (left, right, decision) => {
|
|
84
|
+
const out = [];
|
|
85
|
+
for (const matcher of MATCHERS) {
|
|
86
|
+
const model = matcher.model.build(left, right, decision?.signals?.[matcher.key] ?? null);
|
|
87
|
+
if (!model)
|
|
88
|
+
continue;
|
|
89
|
+
const lines = matcher.text.text(model);
|
|
90
|
+
if (lines.length > 0)
|
|
91
|
+
out.push({ key: matcher.key, lines });
|
|
92
|
+
}
|
|
93
|
+
return out;
|
|
94
|
+
};
|
|
95
|
+
exports.describe = describe;
|
|
96
|
+
const matcherOf = (key) => BY_KEY.get(key) ?? null;
|
|
97
|
+
exports.matcherOf = matcherOf;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare const build: (left: any, right: any, signal: any) => {
|
|
2
|
+
rows: {
|
|
3
|
+
name: string;
|
|
4
|
+
left: {
|
|
5
|
+
name: any;
|
|
6
|
+
};
|
|
7
|
+
right: {
|
|
8
|
+
name: any;
|
|
9
|
+
};
|
|
10
|
+
shared: boolean;
|
|
11
|
+
same: boolean;
|
|
12
|
+
}[];
|
|
13
|
+
sharedCount: number;
|
|
14
|
+
leftCount: number;
|
|
15
|
+
rightCount: number;
|
|
16
|
+
score: any;
|
|
17
|
+
hasEvidence: boolean;
|
|
18
|
+
evidence: any;
|
|
19
|
+
};
|
|
20
|
+
export { build };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.build = void 0;
|
|
4
|
+
// The NAME model: the two component names side by side. A name is one row; the
|
|
5
|
+
// engine's name signal already decided exact / basename / fuzzy / word-overlap.
|
|
6
|
+
const build = (left, right, signal) => {
|
|
7
|
+
if (!left || !right || !signal)
|
|
8
|
+
return null;
|
|
9
|
+
const ev = signal.evidence ?? {};
|
|
10
|
+
const same = !!ev.exactName || (signal.score ?? 0) >= 1;
|
|
11
|
+
const rows = [
|
|
12
|
+
{
|
|
13
|
+
name: "name",
|
|
14
|
+
left: { name: left.name },
|
|
15
|
+
right: { name: right.name },
|
|
16
|
+
shared: true,
|
|
17
|
+
same,
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
return {
|
|
21
|
+
rows,
|
|
22
|
+
sharedCount: 1,
|
|
23
|
+
leftCount: 1,
|
|
24
|
+
rightCount: 1,
|
|
25
|
+
score: signal.score ?? 0,
|
|
26
|
+
hasEvidence: (signal.score ?? 0) > 0,
|
|
27
|
+
evidence: ev,
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
exports.build = build;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.text = void 0;
|
|
4
|
+
// The NAME CLI text: the score and how the names matched.
|
|
5
|
+
const pct = (n) => `${Math.round((n ?? 0) * 100)}%`;
|
|
6
|
+
const text = (model) => {
|
|
7
|
+
if (!model || !model.hasEvidence)
|
|
8
|
+
return [];
|
|
9
|
+
const ev = model.evidence ?? {};
|
|
10
|
+
const row = model.rows[0];
|
|
11
|
+
const head = `${pct(model.score)} ${row.left.name} ↔ ${row.right.name}`;
|
|
12
|
+
const lines = [head];
|
|
13
|
+
if (ev.matchType)
|
|
14
|
+
lines.push(`match ${ev.matchType}${ev.wordSim != null ? ` · word overlap ${pct(ev.wordSim)}` : ""}`);
|
|
15
|
+
return lines;
|
|
16
|
+
};
|
|
17
|
+
exports.text = text;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
declare const rowsOf: (leftTokens: any, rightTokens: any) => {
|
|
2
|
+
name: unknown;
|
|
3
|
+
left: {
|
|
4
|
+
name: unknown;
|
|
5
|
+
};
|
|
6
|
+
right: {
|
|
7
|
+
name: unknown;
|
|
8
|
+
};
|
|
9
|
+
shared: boolean;
|
|
10
|
+
same: boolean;
|
|
11
|
+
}[];
|
|
12
|
+
declare const buildSet: (signal: any, leftTokens: any, rightTokens: any) => {
|
|
13
|
+
rows: {
|
|
14
|
+
name: unknown;
|
|
15
|
+
left: {
|
|
16
|
+
name: unknown;
|
|
17
|
+
};
|
|
18
|
+
right: {
|
|
19
|
+
name: unknown;
|
|
20
|
+
};
|
|
21
|
+
shared: boolean;
|
|
22
|
+
same: boolean;
|
|
23
|
+
}[];
|
|
24
|
+
sharedCount: number;
|
|
25
|
+
leftCount: number;
|
|
26
|
+
rightCount: number;
|
|
27
|
+
score: any;
|
|
28
|
+
hasEvidence: boolean;
|
|
29
|
+
evidence: any;
|
|
30
|
+
};
|
|
31
|
+
export { rowsOf, buildSet };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildSet = exports.rowsOf = void 0;
|
|
4
|
+
// A set-comparison model: the two sides carry lists of tokens (events, ARIA
|
|
5
|
+
// attributes, props, child-component names). A token present on both sides is a
|
|
6
|
+
// shared row; a token on one side only is a surplus row. This is the comparison
|
|
7
|
+
// material the board draws for the behavior / a11y / framework signals.
|
|
8
|
+
//
|
|
9
|
+
// The engine already scored the pair; `signal` carries {score, evidence}. This
|
|
10
|
+
// only arranges the token lists into rows — it never re-decides.
|
|
11
|
+
const rowsOf = (leftTokens, rightTokens) => {
|
|
12
|
+
const A = new Set(leftTokens ?? []);
|
|
13
|
+
const B = new Set(rightTokens ?? []);
|
|
14
|
+
const names = [...new Set([...A, ...B])];
|
|
15
|
+
return names.map((name) => {
|
|
16
|
+
const shared = A.has(name) && B.has(name);
|
|
17
|
+
return {
|
|
18
|
+
name,
|
|
19
|
+
left: A.has(name) ? { name } : null,
|
|
20
|
+
right: B.has(name) ? { name } : null,
|
|
21
|
+
shared,
|
|
22
|
+
same: shared,
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
exports.rowsOf = rowsOf;
|
|
27
|
+
const buildSet = (signal, leftTokens, rightTokens) => {
|
|
28
|
+
if (!signal)
|
|
29
|
+
return null;
|
|
30
|
+
const rows = rowsOf(leftTokens, rightTokens);
|
|
31
|
+
const shared = rows.filter((r) => r.shared);
|
|
32
|
+
return {
|
|
33
|
+
rows,
|
|
34
|
+
sharedCount: shared.length,
|
|
35
|
+
leftCount: new Set(leftTokens ?? []).size,
|
|
36
|
+
rightCount: new Set(rightTokens ?? []).size,
|
|
37
|
+
score: signal.score ?? 0,
|
|
38
|
+
hasEvidence: (signal.score ?? 0) > 0 || shared.length > 0 || rows.length > 0,
|
|
39
|
+
evidence: signal.evidence ?? {},
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
exports.buildSet = buildSet;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.build = void 0;
|
|
4
|
+
// The STRUCTURE model: the DOM-chain comparison the engine already scored.
|
|
5
|
+
//
|
|
6
|
+
// The component engine's structure matcher reports a best-matching chain of DOM
|
|
7
|
+
// nodes (tag + CSS + text) between the two trees. The model surfaces that chain's
|
|
8
|
+
// facts as rows the board can draw: the root tags on each side, and the chain
|
|
9
|
+
// quality / size. It does NOT recompute the chain — the engine's evidence is the
|
|
10
|
+
// source of truth; this only arranges it for the report.
|
|
11
|
+
const rootTagOf = (candidate) => {
|
|
12
|
+
const tree = candidate?.dom?.tree ?? candidate?.tree;
|
|
13
|
+
if (!tree)
|
|
14
|
+
return null;
|
|
15
|
+
const firstReal = (n) => {
|
|
16
|
+
if (!n)
|
|
17
|
+
return null;
|
|
18
|
+
if (n.tag === "fragment" || n.tag === "children" || n.tag === "text") {
|
|
19
|
+
for (const child of n.children || []) {
|
|
20
|
+
const found = firstReal(child);
|
|
21
|
+
if (found)
|
|
22
|
+
return found;
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
return n;
|
|
27
|
+
};
|
|
28
|
+
const root = firstReal(tree);
|
|
29
|
+
return root ? root.tag : null;
|
|
30
|
+
};
|
|
31
|
+
// `signal` is the engine's structure signal {score, applicable, evidence}.
|
|
32
|
+
const build = (left, right, signal) => {
|
|
33
|
+
if (!left || !right || !signal)
|
|
34
|
+
return null;
|
|
35
|
+
const ev = signal.evidence ?? {};
|
|
36
|
+
const leftTag = rootTagOf(left);
|
|
37
|
+
const rightTag = rootTagOf(right);
|
|
38
|
+
const rows = [];
|
|
39
|
+
if (leftTag || rightTag) {
|
|
40
|
+
rows.push({
|
|
41
|
+
name: "root",
|
|
42
|
+
left: leftTag ? { name: leftTag } : null,
|
|
43
|
+
right: rightTag ? { name: rightTag } : null,
|
|
44
|
+
shared: !!leftTag && !!rightTag,
|
|
45
|
+
same: !!leftTag && leftTag === rightTag,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
rows,
|
|
50
|
+
sharedCount: rows.filter((r) => r.shared).length,
|
|
51
|
+
leftCount: leftTag ? 1 : 0,
|
|
52
|
+
rightCount: rightTag ? 1 : 0,
|
|
53
|
+
score: signal.score ?? 0,
|
|
54
|
+
hasEvidence: signal.applicable !== false && (ev.chainSize > 0 || ev.rootSim > 0 || rows.length > 0),
|
|
55
|
+
evidence: ev,
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
exports.build = build;
|