browser-requirements 0.0.0-stage → 0.1.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 (106) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +248 -2
  3. package/dist/analysis/analyze.d.ts +14 -0
  4. package/dist/analysis/analyze.js +67 -0
  5. package/dist/analysis/analyze.js.map +1 -0
  6. package/dist/analysis/ast.d.ts +12 -0
  7. package/dist/analysis/ast.js +21 -0
  8. package/dist/analysis/ast.js.map +1 -0
  9. package/dist/analysis/context.d.ts +17 -0
  10. package/dist/analysis/context.js +2 -0
  11. package/dist/analysis/context.js.map +1 -0
  12. package/dist/analysis/detectors/builtins.d.ts +8 -0
  13. package/dist/analysis/detectors/builtins.js +68 -0
  14. package/dist/analysis/detectors/builtins.js.map +1 -0
  15. package/dist/analysis/detectors/syntax.d.ts +6 -0
  16. package/dist/analysis/detectors/syntax.js +79 -0
  17. package/dist/analysis/detectors/syntax.js.map +1 -0
  18. package/dist/analysis/detectors/web-apis.d.ts +12 -0
  19. package/dist/analysis/detectors/web-apis.js +30 -0
  20. package/dist/analysis/detectors/web-apis.js.map +1 -0
  21. package/dist/analysis/files.d.ts +9 -0
  22. package/dist/analysis/files.js +60 -0
  23. package/dist/analysis/files.js.map +1 -0
  24. package/dist/analysis/guards.d.ts +9 -0
  25. package/dist/analysis/guards.js +41 -0
  26. package/dist/analysis/guards.js.map +1 -0
  27. package/dist/analysis/parse.d.ts +21 -0
  28. package/dist/analysis/parse.js +43 -0
  29. package/dist/analysis/parse.js.map +1 -0
  30. package/dist/analysis/scope.d.ts +11 -0
  31. package/dist/analysis/scope.js +31 -0
  32. package/dist/analysis/scope.js.map +1 -0
  33. package/dist/analysis/walk.d.ts +9 -0
  34. package/dist/analysis/walk.js +168 -0
  35. package/dist/analysis/walk.js.map +1 -0
  36. package/dist/analysis/writes.d.ts +6 -0
  37. package/dist/analysis/writes.js +16 -0
  38. package/dist/analysis/writes.js.map +1 -0
  39. package/dist/bin/cli.d.ts +2 -0
  40. package/dist/bin/cli.js +114 -0
  41. package/dist/bin/cli.js.map +1 -0
  42. package/dist/config/load.d.ts +14 -0
  43. package/dist/config/load.js +95 -0
  44. package/dist/config/load.js.map +1 -0
  45. package/dist/config/suppressions.d.ts +16 -0
  46. package/dist/config/suppressions.js +60 -0
  47. package/dist/config/suppressions.js.map +1 -0
  48. package/dist/data/browsers.d.ts +8 -0
  49. package/dist/data/browsers.js +49 -0
  50. package/dist/data/browsers.js.map +1 -0
  51. package/dist/data/features.d.ts +14 -0
  52. package/dist/data/features.js +46 -0
  53. package/dist/data/features.js.map +1 -0
  54. package/dist/data/generated/features.json +1 -0
  55. package/dist/data/globals.d.ts +5 -0
  56. package/dist/data/globals.js +22 -0
  57. package/dist/data/globals.js.map +1 -0
  58. package/dist/data/syntax-map.d.ts +10 -0
  59. package/dist/data/syntax-map.js +34 -0
  60. package/dist/data/syntax-map.js.map +1 -0
  61. package/dist/index.d.ts +8 -0
  62. package/dist/index.js +8 -0
  63. package/dist/index.js.map +1 -0
  64. package/dist/model/baseline.d.ts +7 -0
  65. package/dist/model/baseline.js +15 -0
  66. package/dist/model/baseline.js.map +1 -0
  67. package/dist/model/compare.d.ts +5 -0
  68. package/dist/model/compare.js +61 -0
  69. package/dist/model/compare.js.map +1 -0
  70. package/dist/model/minimums.d.ts +5 -0
  71. package/dist/model/minimums.js +45 -0
  72. package/dist/model/minimums.js.map +1 -0
  73. package/dist/model/targets.d.ts +12 -0
  74. package/dist/model/targets.js +89 -0
  75. package/dist/model/targets.js.map +1 -0
  76. package/dist/model/types.d.ts +165 -0
  77. package/dist/model/types.js +2 -0
  78. package/dist/model/types.js.map +1 -0
  79. package/dist/model/version.d.ts +9 -0
  80. package/dist/model/version.js +39 -0
  81. package/dist/model/version.js.map +1 -0
  82. package/dist/output/comparison.d.ts +2 -0
  83. package/dist/output/comparison.js +7 -0
  84. package/dist/output/comparison.js.map +1 -0
  85. package/dist/output/index.d.ts +3 -0
  86. package/dist/output/index.js +6 -0
  87. package/dist/output/index.js.map +1 -0
  88. package/dist/output/json.d.ts +3 -0
  89. package/dist/output/json.js +5 -0
  90. package/dist/output/json.js.map +1 -0
  91. package/dist/output/markdown.d.ts +9 -0
  92. package/dist/output/markdown.js +59 -0
  93. package/dist/output/markdown.js.map +1 -0
  94. package/dist/output/style.d.ts +5 -0
  95. package/dist/output/style.js +14 -0
  96. package/dist/output/style.js.map +1 -0
  97. package/dist/output/text.d.ts +9 -0
  98. package/dist/output/text.js +115 -0
  99. package/dist/output/text.js.map +1 -0
  100. package/dist/version.d.ts +2 -0
  101. package/dist/version.js +5 -0
  102. package/dist/version.js.map +1 -0
  103. package/package.json +78 -4
  104. package/schemas/comparison-1.json +44 -0
  105. package/schemas/config-1.json +24 -0
  106. package/schemas/report-1.json +114 -0
@@ -0,0 +1,7 @@
1
+ import { comparisonToMarkdown, comparisonToText } from './markdown.js';
2
+ export function formatComparison(comparison, format) {
3
+ if (format === 'json')
4
+ return `${JSON.stringify(comparison, null, 2)}\n`;
5
+ return format === 'markdown' ? comparisonToMarkdown(comparison) : comparisonToText(comparison);
6
+ }
7
+ //# sourceMappingURL=comparison.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comparison.js","sourceRoot":"","sources":["../../src/output/comparison.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEvE,MAAM,UAAU,gBAAgB,CAAC,UAAsB,EAAE,MAAoC;IAC3F,IAAI,MAAM,KAAK,MAAM;QAAE,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;IACzE,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;AACjG,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Report } from '../model/types.js';
2
+ import { type TextOptions } from './text.js';
3
+ export declare function formatReport(report: Report, format: 'text' | 'json', options?: TextOptions): string;
@@ -0,0 +1,6 @@
1
+ import { reportToJson } from './json.js';
2
+ import { reportToText } from './text.js';
3
+ export function formatReport(report, format, options = {}) {
4
+ return format === 'json' ? reportToJson(report) : reportToText(report, options);
5
+ }
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/output/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,YAAY,EAAoB,MAAM,WAAW,CAAC;AAE3D,MAAM,UAAU,YAAY,CAAC,MAAc,EAAE,MAAuB,EAAE,OAAO,GAAgB,EAAE;IAC7F,OAAO,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAClF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Report } from '../model/types.js';
2
+ /** Deterministic JSON: fixed key order from construction, 2-space indent, trailing newline (FR-019). */
3
+ export declare function reportToJson(report: Report): string;
@@ -0,0 +1,5 @@
1
+ /** Deterministic JSON: fixed key order from construction, 2-space indent, trailing newline (FR-019). */
2
+ export function reportToJson(report) {
3
+ return `${JSON.stringify(report, null, 2)}\n`;
4
+ }
5
+ //# sourceMappingURL=json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.js","sourceRoot":"","sources":["../../src/output/json.ts"],"names":[],"mappings":"AAEA,wGAAwG;AACxG,MAAM,UAAU,YAAY,CAAC,MAAc;IACzC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;AAChD,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { Comparison, Support } from '../model/types.js';
2
+ export declare const COMPARISON_MARKER = "<!-- browser-requirements:comparison -->";
3
+ export declare const browserName: (id: string) => string;
4
+ export declare const formatSupport: (s: Support | null) => string;
5
+ export declare function causeText(cause: Comparison['browsers'][number]['cause'], code: (s: string) => string): string;
6
+ /** PR comment: marker, one row per raised or lowered browser; empty when nothing changed (FR-008). */
7
+ export declare function comparisonToMarkdown(c: Comparison): string;
8
+ /** Plain text comparison; empty when nothing changed. */
9
+ export declare function comparisonToText(c: Comparison): string;
@@ -0,0 +1,59 @@
1
+ import { BROWSER_NAMES } from '../data/browsers.js';
2
+ export const COMPARISON_MARKER = '<!-- browser-requirements:comparison -->';
3
+ const MAX_LOCATIONS = 3;
4
+ export const browserName = (id) => BROWSER_NAMES[id] ?? id;
5
+ export const formatSupport = (s) => (s === null ? 'any' : s === 'not-supported' ? 'not supported' : s);
6
+ export function causeText(cause, code) {
7
+ return cause
8
+ .map(({ feature, findings }) => {
9
+ const name = findings[0]?.name ?? feature;
10
+ const where = findings.slice(0, MAX_LOCATIONS).map((f) => code(`${f.location.file}:${f.location.line}`));
11
+ const more = findings.length > MAX_LOCATIONS ? ` +${findings.length - MAX_LOCATIONS} more` : '';
12
+ return where.length > 0 ? `${code(name)} at ${where.join(', ')}${more}` : code(name);
13
+ })
14
+ .join('; ');
15
+ }
16
+ function datasetNote(c) {
17
+ const b = c.datasets.base;
18
+ const h = c.datasets.head;
19
+ if (b['browser-compat-data'] === h['browser-compat-data'] && b['web-features'] === h['web-features'])
20
+ return null;
21
+ return `Note: the reports use different datasets (BCD ${b['browser-compat-data']} → ${h['browser-compat-data']}); some differences may come from the data.`;
22
+ }
23
+ /** PR comment: marker, one row per raised or lowered browser; empty when nothing changed (FR-008). */
24
+ export function comparisonToMarkdown(c) {
25
+ if (c.errors.length > 0) {
26
+ return `${COMPARISON_MARKER}\n### ⚠️ Browser requirements: comparison could not run\n\n${c.errors.map((e) => `- ${e}`).join('\n')}\n`;
27
+ }
28
+ if (!c.changed)
29
+ return '';
30
+ const code = (s) => `\`${s}\``;
31
+ const raised = c.browsers.filter((b) => b.direction === 'raised');
32
+ const lowered = c.browsers.filter((b) => b.direction === 'lowered');
33
+ const lines = [COMPARISON_MARKER, raised.length > 0 ? '### ⬆️ This change raises the minimum browser versions' : '### ⬇️ This change lowers the minimum browser versions', ''];
34
+ lines.push('| Browser | Before | After | Cause |', '| --- | --- | --- | --- |');
35
+ for (const b of [...raised, ...lowered]) {
36
+ const arrow = b.direction === 'raised' ? '⬆️' : '⬇️';
37
+ lines.push(`| ${browserName(b.browser)} | ${formatSupport(b.base)} | ${arrow} **${formatSupport(b.head)}** | ${b.direction === 'lowered' ? 'no longer uses ' : ''}${causeText(b.cause, code)} |`);
38
+ }
39
+ const note = datasetNote(c);
40
+ if (note)
41
+ lines.push('', `> ${note}`);
42
+ lines.push('', '<sub>Reported by browser-requirements. Lowered rows are improvements.</sub>');
43
+ return `${lines.join('\n')}\n`;
44
+ }
45
+ /** Plain text comparison; empty when nothing changed. */
46
+ export function comparisonToText(c) {
47
+ if (c.errors.length > 0)
48
+ return `Comparison could not run:\n${c.errors.map((e) => ` ${e}`).join('\n')}\n`;
49
+ if (!c.changed)
50
+ return '';
51
+ const lines = c.browsers
52
+ .filter((b) => b.direction !== 'unchanged')
53
+ .map((b) => `${browserName(b.browser)} ${formatSupport(b.base)} → ${formatSupport(b.head)} (${b.direction}${b.direction === 'lowered' ? ', no longer uses' : ' by'} ${causeText(b.cause, (s) => s)})`);
54
+ const note = datasetNote(c);
55
+ if (note)
56
+ lines.push(note);
57
+ return `${lines.join('\n')}\n`;
58
+ }
59
+ //# sourceMappingURL=markdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../src/output/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,MAAM,CAAC,MAAM,iBAAiB,GAAG,0CAA0C,CAAC;AAC5E,MAAM,aAAa,GAAG,CAAC,CA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AAC,QAAQ;SACrB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,WAAW,CAAC;SAC1C,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,KAAK,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACzM,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;IAC5B,IAAI,IAAI;QAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3B,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AACjC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export type Style = 'bold' | 'dim' | 'red' | 'green' | 'yellow' | 'cyan';
2
+ /** Returns a styling function; identity when colour is off (NO_COLOR, pipes). */
3
+ export declare function styler(color: boolean): (style: Style, text: string) => string;
4
+ /** Whether stdout should be coloured: a TTY, honouring NO_COLOR and FORCE_COLOR. */
5
+ export declare function shouldColor(stream?: NodeJS.WriteStream): boolean;
@@ -0,0 +1,14 @@
1
+ import { styleText } from 'node:util';
2
+ /** Returns a styling function; identity when colour is off (NO_COLOR, pipes). */
3
+ export function styler(color) {
4
+ return color ? (style, text) => styleText(style, text, { validateStream: false }) : (_style, text) => text;
5
+ }
6
+ /** Whether stdout should be coloured: a TTY, honouring NO_COLOR and FORCE_COLOR. */
7
+ export function shouldColor(stream = process.stdout) {
8
+ if (process.env.NO_COLOR)
9
+ return false;
10
+ if (process.env.FORCE_COLOR !== undefined)
11
+ return process.env.FORCE_COLOR !== '0';
12
+ return Boolean(stream.isTTY);
13
+ }
14
+ //# sourceMappingURL=style.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style.js","sourceRoot":"","sources":["../../src/output/style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAItC,iFAAiF;AACjF,MAAM,UAAU,MAAM,CAAC,KAAc;IACnC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;AAC7G,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,WAAW,CAAC,MAAM,GAAuB,OAAO,CAAC,MAAM;IACrE,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAC;IACvC,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,SAAS;QAAE,OAAO,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,GAAG,CAAC;IAClF,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { Report, TargetCheck, TargetSet } from '../model/types.js';
2
+ export interface TextOptions {
3
+ details?: boolean;
4
+ color?: boolean;
5
+ }
6
+ /** Human-readable report (contracts/cli.md). */
7
+ export declare function reportToText(report: Report, options?: TextOptions): string;
8
+ /** Target check section for `check` (FR-009). */
9
+ export declare function targetCheckToText(targets: TargetSet, check: TargetCheck, options?: TextOptions): string;
@@ -0,0 +1,115 @@
1
+ import Table from 'cli-table3';
2
+ import { BROWSER_NAMES } from '../data/browsers.js';
3
+ import { byId } from '../data/features.js';
4
+ import { counts } from '../model/minimums.js';
5
+ import { compareSupport } from '../model/version.js';
6
+ import { styler } from './style.js';
7
+ const PLAIN_TABLE = {
8
+ chars: {
9
+ top: '', 'top-mid': '', 'top-left': '', 'top-right': '', bottom: '', 'bottom-mid': '', 'bottom-left': '', 'bottom-right': '',
10
+ left: '', 'left-mid': '', mid: '', 'mid-mid': '', right: '', 'right-mid': '', middle: ' ',
11
+ },
12
+ style: { head: [], border: [], 'padding-left': 0, 'padding-right': 0 },
13
+ };
14
+ const browserName = (id) => BROWSER_NAMES[id] ?? id;
15
+ const formatSupport = (s) => (s === null ? 'any' : s === 'not-supported' ? 'not supported' : s);
16
+ const where = (f) => `${f.location.file}:${f.location.line}:${f.location.column}`;
17
+ const featureName = (id, findings) => findings.find((f) => f.feature === id)?.name ?? byId(id)?.name ?? id;
18
+ function limitingFindings(row, findings) {
19
+ const limiting = new Set(row.limitedBy);
20
+ return findings.filter((f) => limiting.has(f.feature) && counts(f));
21
+ }
22
+ /** Human-readable report (contracts/cli.md). */
23
+ export function reportToText(report, options = {}) {
24
+ const s = styler(options.color ?? false);
25
+ const { findings } = report;
26
+ const lines = [];
27
+ lines.push(s('bold', 'Minimum browser requirements') +
28
+ s('dim', ` (${report.analyzed.kind}, ${report.analyzed.files} file${report.analyzed.files === 1 ? '' : 's'}, BCD ${report.datasets['browser-compat-data']})`), '');
29
+ const table = new Table({ ...PLAIN_TABLE, head: ['Browser', 'Minimum', 'Limited by', 'Where'].map((h) => s('bold', h)) });
30
+ for (const row of report.browsers) {
31
+ const limiting = limitingFindings(row, findings);
32
+ const first = limiting[0];
33
+ const more = limiting.length > 1 ? s('dim', ` (+${limiting.length - 1} more)`) : '';
34
+ const minimum = row.minimum === 'not-supported' ? s('red', 'not supported') : formatSupport(row.minimum);
35
+ table.push([
36
+ browserName(row.browser),
37
+ row.partialSince ? `${minimum} ${s('dim', `(partial ${row.partialSince})`)}` : minimum,
38
+ row.limitedBy.map((id) => featureName(id, findings)).join(', ') || s('dim', '—'),
39
+ first ? where(first) + more : '',
40
+ ]);
41
+ }
42
+ lines.push(table.toString(), '');
43
+ const { status, year } = report.baseline;
44
+ lines.push(status === false ? 'Not Baseline' : `Baseline${year ? ` ${year}` : ''} (${status === 'high' ? 'widely available' : 'newly available'})`);
45
+ const rising = report.browsers.filter((b) => b.couldRiseTo);
46
+ if (rising.length > 0) {
47
+ const probableCount = findings.filter((f) => f.confidence === 'probable' && !f.guarded && !f.suppressed).length;
48
+ const targets = rising.map((b) => `${browserName(b.browser)} ${formatSupport(b.couldRiseTo.version)}`).join(', ');
49
+ lines.push(s('yellow', `Could rise to ${targets} if ${probableCount} probable finding${probableCount === 1 ? ' is' : 's are'} confirmed`) + (options.details ? '' : s('dim', ' (see --details)')));
50
+ }
51
+ const guarded = findings.filter((f) => f.guarded).length;
52
+ const suppressed = findings.filter((f) => f.suppressed).length;
53
+ lines.push(s('dim', `Guarded: ${guarded} · Suppressed: ${suppressed} · Skipped files: ${report.skipped.length}`));
54
+ // Suppressions are always visible with their reason (constitution IV).
55
+ for (const f of findings.filter((x) => x.suppressed)) {
56
+ lines.push(s('dim', ` suppressed ${f.name} at ${where(f)} (${f.suppressed.source}): ${f.suppressed.reason}`));
57
+ }
58
+ if (options.details)
59
+ lines.push('', ...details(report, s));
60
+ return `${lines.join('\n')}\n`;
61
+ }
62
+ function details(report, s) {
63
+ const out = [];
64
+ for (const row of report.browsers) {
65
+ if (row.next.length === 0 && !row.couldRiseTo)
66
+ continue;
67
+ out.push(s('bold', `${browserName(row.browser)}:`));
68
+ for (const n of row.next)
69
+ out.push(` next: ${featureName(n.feature, report.findings)} ${formatSupport(n.version)}`);
70
+ if (row.couldRiseTo)
71
+ out.push(s('yellow', ` could rise to ${formatSupport(row.couldRiseTo.version)} (${featureName(row.couldRiseTo.feature, report.findings)}, probable)`));
72
+ }
73
+ if (report.findings.length > 0) {
74
+ const table = new Table({ ...PLAIN_TABLE, head: ['Where', 'Feature', 'Confidence', 'Notes'].map((h) => s('bold', h)) });
75
+ for (const f of report.findings) {
76
+ const notes = [f.guarded ? 'guarded' : '', f.suppressed ? `suppressed: ${f.suppressed.reason}` : ''].filter(Boolean).join(', ');
77
+ table.push([where(f), f.name, f.confidence, notes]);
78
+ }
79
+ out.push('', s('bold', 'Findings'), table.toString());
80
+ }
81
+ for (const skip of report.skipped)
82
+ out.push(s('dim', `skipped ${skip.file}: ${skip.reason}`));
83
+ return out;
84
+ }
85
+ const TARGET_SOURCES = {
86
+ argument: 'from --targets',
87
+ config: 'from browser-requirements.config.json',
88
+ 'browserslist-config': 'from the project browserslist config',
89
+ default: 'no targets declared',
90
+ };
91
+ /** Target check section for `check` (FR-009). */
92
+ export function targetCheckToText(targets, check, options = {}) {
93
+ const s = styler(options.color ?? false);
94
+ const lines = [];
95
+ if (targets.source === 'default')
96
+ lines.push(s('yellow', 'No targets declared: using the browserslist "defaults" query.'));
97
+ lines.push(s('bold', `Targets: ${targets.query}`) + s('dim', ` (${TARGET_SOURCES[targets.source]})`));
98
+ for (const v of check.violations) {
99
+ lines.push(s('red', `✗ ${browserName(v.browser)} ${v.target}: needs ${formatSupport(v.minimum)}`));
100
+ const demand = (id) => byId(id)?.support[v.browser] ?? 'unknown';
101
+ const ordered = [...v.features].sort((a, b) => compareSupport(demand(b), demand(a)));
102
+ for (const id of ordered) {
103
+ const uses = v.findings.filter((f) => f.feature === id);
104
+ const support = byId(id)?.support[v.browser];
105
+ lines.push(` ${featureName(id, uses)}${support ? s('dim', ` (${browserName(v.browser)} ${formatSupport(support)})`) : ''}`);
106
+ for (const f of uses)
107
+ lines.push(s('dim', ` ${where(f)} ${f.snippet}`));
108
+ }
109
+ }
110
+ if (check.unknown.length > 0)
111
+ lines.push(s('yellow', `No data, not checked: ${check.unknown.join(', ')}`));
112
+ lines.push(check.met ? s('green', '✓ All targets met') : s('red', `${check.violations.length} target${check.violations.length === 1 ? '' : 's'} not met`));
113
+ return `${lines.join('\n')}\n`;
114
+ }
115
+ //# sourceMappingURL=text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"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AI,CAAC,CAAC,CAAC,KAAK,EAAE,SAAS,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAChF,CAAC;IACH,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,yBAAyB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3G,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK,CAAC,UAAU,CAAC,MAAM,UAAU,KAAK,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IAC3J,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AACjC,CAAC"}
@@ -0,0 +1,2 @@
1
+ /** Version from package.json (resolved relative to src/ or dist/). */
2
+ export declare const TOOL_VERSION: string;
@@ -0,0 +1,5 @@
1
+ import { createRequire } from 'node:module';
2
+ const require = createRequire(import.meta.url);
3
+ /** Version from package.json (resolved relative to src/ or dist/). */
4
+ export const TOOL_VERSION = require('../package.json').version;
5
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C,sEAAsE;AACtE,MAAM,CAAC,MAAM,YAAY,GAAY,OAAO,CAAC,iBAAiB,CAAyB,CAAC,OAAO,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,80 @@
1
1
  {
2
2
  "name": "browser-requirements",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "type": "module",
4
+ "version": "0.1.0",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "default": "./dist/index.js"
11
+ },
12
+ "./schemas/*": "./schemas/*",
13
+ "./package.json": "./package.json"
14
+ },
15
+ "bin": {
16
+ "browser-requirements": "./dist/bin/cli.js"
17
+ },
18
+ "scripts": {
19
+ "build": "tsc",
20
+ "typecheck": "tsc -p tsconfig.check.json",
21
+ "start": "node dist/bin/cli.js",
22
+ "dev": "tsx src/bin/cli.ts",
23
+ "test": "vitest run",
24
+ "test:watch": "vitest",
25
+ "generate:data": "tsx scripts/generate-data.ts",
26
+ "bench": "tsx scripts/bench.ts",
27
+ "prepack": "pnpm build"
28
+ },
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+https://github.com/n0ss4/browser-requirements.git"
32
+ },
33
+ "keywords": [
34
+ "browser",
35
+ "compatibility",
36
+ "browserslist",
37
+ "baseline",
38
+ "web-features",
39
+ "caniuse",
40
+ "mdn",
41
+ "minimum-requirements"
42
+ ],
43
+ "author": "",
44
+ "license": "ISC",
45
+ "bugs": {
46
+ "url": "https://github.com/n0ss4/browser-requirements/issues"
47
+ },
48
+ "homepage": "https://github.com/n0ss4/browser-requirements#readme",
49
+ "description": "Find the minimum browser versions your web app needs, and the code that sets them.",
50
+ "dependencies": {
51
+ "@typescript-eslint/scope-manager": "^8.74.0",
52
+ "@typescript-eslint/types": "^8.74.0",
53
+ "browserslist": "^4.29.6",
54
+ "cli-table3": "^0.6.5",
55
+ "commander": "^15.1.0",
56
+ "oxc-parser": "0.161.0"
57
+ },
58
+ "devDependencies": {
59
+ "@mdn/browser-compat-data": "8.1.12",
60
+ "@types/node": "^22.20.7",
61
+ "ajv": "^8.20.0",
62
+ "tsx": "^4.23.15",
63
+ "typescript": "^7.0.2",
64
+ "vitest": "^5.1.2",
65
+ "web-features": "3.49.0"
66
+ },
67
+ "engines": {
68
+ "node": ">=22.12.0"
69
+ },
70
+ "packageManager": "pnpm@10.32.1",
71
+ "pnpm": {
72
+ "onlyBuiltDependencies": [
73
+ "esbuild"
74
+ ]
75
+ },
76
+ "files": [
77
+ "dist",
78
+ "schemas"
79
+ ]
80
+ }
@@ -0,0 +1,44 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/n0ss4/browser-requirements/schemas/comparison-1.json",
4
+ "title": "browser-requirements comparison",
5
+ "type": "object",
6
+ "required": ["schemaVersion", "changed", "browsers", "datasets", "errors"],
7
+ "additionalProperties": false,
8
+ "properties": {
9
+ "schemaVersion": { "type": "string", "pattern": "^1\\.\\d+\\.\\d+$" },
10
+ "changed": { "type": "boolean" },
11
+ "browsers": {
12
+ "type": "array",
13
+ "items": {
14
+ "type": "object",
15
+ "required": ["browser", "base", "head", "direction", "cause"],
16
+ "additionalProperties": false,
17
+ "properties": {
18
+ "browser": { "type": "string" },
19
+ "base": { "$ref": "report-1.json#/$defs/browserMinimum/properties/minimum" },
20
+ "head": { "$ref": "report-1.json#/$defs/browserMinimum/properties/minimum" },
21
+ "direction": { "enum": ["raised", "lowered", "unchanged"] },
22
+ "cause": {
23
+ "type": "array",
24
+ "items": {
25
+ "type": "object", "required": ["feature", "findings"], "additionalProperties": false,
26
+ "properties": {
27
+ "feature": { "$ref": "report-1.json#/$defs/featureId" },
28
+ "findings": { "type": "array", "items": { "$ref": "report-1.json#/$defs/finding" } }
29
+ }
30
+ }
31
+ }
32
+ }
33
+ }
34
+ },
35
+ "datasets": {
36
+ "type": "object", "required": ["base", "head"], "additionalProperties": false,
37
+ "properties": {
38
+ "base": { "$ref": "report-1.json#/properties/datasets" },
39
+ "head": { "$ref": "report-1.json#/properties/datasets" }
40
+ }
41
+ },
42
+ "errors": { "type": "array", "items": { "type": "string" } }
43
+ }
44
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/n0ss4/browser-requirements/schemas/config-1.json",
4
+ "title": "browser-requirements.config.json",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "properties": {
8
+ "$schema": { "type": "string" },
9
+ "browsers": { "type": "array", "items": { "type": "string" }, "minItems": 1 },
10
+ "targets": { "type": "string", "description": "Browserslist query used by `check`" },
11
+ "ignore": { "type": "array", "items": { "type": "string" } },
12
+ "suppressions": {
13
+ "type": "array",
14
+ "items": {
15
+ "type": "object", "required": ["feature", "reason"], "additionalProperties": false,
16
+ "properties": {
17
+ "feature": { "type": "string", "pattern": "^(javascript|api)\\.[A-Za-z0-9_.$-]+$" },
18
+ "files": { "type": "array", "items": { "type": "string" } },
19
+ "reason": { "type": "string", "minLength": 1 }
20
+ }
21
+ }
22
+ }
23
+ }
24
+ }
@@ -0,0 +1,114 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/n0ss4/browser-requirements/schemas/report-1.json",
4
+ "title": "browser-requirements report",
5
+ "type": "object",
6
+ "required": ["schemaVersion", "tool", "analyzed", "datasets", "browsers", "baseline", "findings", "suppressions", "skipped"],
7
+ "additionalProperties": false,
8
+ "properties": {
9
+ "schemaVersion": { "type": "string", "pattern": "^1\\.\\d+\\.\\d+$" },
10
+ "tool": {
11
+ "type": "object", "required": ["name", "version"], "additionalProperties": false,
12
+ "properties": { "name": { "const": "browser-requirements" }, "version": { "type": "string" } }
13
+ },
14
+ "analyzed": {
15
+ "type": "object", "required": ["kind", "root", "files"], "additionalProperties": false,
16
+ "properties": {
17
+ "kind": { "enum": ["source", "output"] },
18
+ "root": { "type": "string", "description": "Always '.', locations are relative to the analysis root" },
19
+ "files": { "type": "integer", "minimum": 0 }
20
+ }
21
+ },
22
+ "datasets": {
23
+ "type": "object", "required": ["browser-compat-data", "web-features"],
24
+ "additionalProperties": { "type": "string" },
25
+ "properties": { "browser-compat-data": { "type": "string" }, "web-features": { "type": "string" } }
26
+ },
27
+ "browsers": { "type": "array", "items": { "$ref": "#/$defs/browserMinimum" } },
28
+ "baseline": {
29
+ "type": "object", "required": ["status"], "additionalProperties": false,
30
+ "properties": {
31
+ "status": { "enum": ["high", "low", false] },
32
+ "year": { "type": "integer" }
33
+ }
34
+ },
35
+ "findings": { "type": "array", "items": { "$ref": "#/$defs/finding" } },
36
+ "suppressions": {
37
+ "type": "array",
38
+ "items": {
39
+ "type": "object", "required": ["feature", "reason", "matched"], "additionalProperties": false,
40
+ "properties": {
41
+ "feature": { "$ref": "#/$defs/featureId" },
42
+ "files": { "type": "array", "items": { "type": "string" } },
43
+ "reason": { "type": "string", "minLength": 1 },
44
+ "matched": { "type": "integer", "minimum": 0 }
45
+ }
46
+ }
47
+ },
48
+ "skipped": {
49
+ "type": "array",
50
+ "items": {
51
+ "type": "object", "required": ["file", "reason"], "additionalProperties": false,
52
+ "properties": { "file": { "type": "string" }, "reason": { "type": "string" } }
53
+ }
54
+ }
55
+ },
56
+ "$defs": {
57
+ "featureId": { "type": "string", "pattern": "^(javascript|api)\\.[A-Za-z0-9_.$-]+$" },
58
+ "version": { "type": "string", "pattern": "^\\d+(\\.\\d+)*$" },
59
+ "support": {
60
+ "oneOf": [ { "$ref": "#/$defs/version" }, { "enum": ["not-supported", "unknown"] } ]
61
+ },
62
+ "location": {
63
+ "type": "object", "required": ["file", "line", "column"], "additionalProperties": false,
64
+ "properties": {
65
+ "file": { "type": "string" },
66
+ "line": { "type": "integer", "minimum": 1 },
67
+ "column": { "type": "integer", "minimum": 1 }
68
+ }
69
+ },
70
+ "finding": {
71
+ "type": "object",
72
+ "required": ["feature", "location", "confidence", "origin", "guarded", "snippet"],
73
+ "additionalProperties": false,
74
+ "properties": {
75
+ "feature": { "$ref": "#/$defs/featureId" },
76
+ "name": { "type": "string", "description": "Display name, e.g. Array.prototype.toSorted" },
77
+ "location": { "$ref": "#/$defs/location" },
78
+ "confidence": { "enum": ["certain", "probable"] },
79
+ "origin": {
80
+ "type": "object", "required": ["type"],
81
+ "properties": { "type": { "enum": ["project", "dependency"] }, "package": { "type": "string" } }
82
+ },
83
+ "guarded": { "type": "boolean" },
84
+ "suppressed": {
85
+ "type": "object", "required": ["reason", "source"], "additionalProperties": false,
86
+ "properties": { "reason": { "type": "string", "minLength": 1 }, "source": { "enum": ["config", "inline"] } }
87
+ },
88
+ "snippet": { "type": "string", "maxLength": 120 }
89
+ }
90
+ },
91
+ "browserMinimum": {
92
+ "type": "object",
93
+ "required": ["browser", "minimum", "limitedBy", "next"],
94
+ "additionalProperties": false,
95
+ "properties": {
96
+ "browser": { "type": "string" },
97
+ "minimum": { "oneOf": [ { "$ref": "#/$defs/support" }, { "type": "null", "description": "No counting findings: any version" } ] },
98
+ "limitedBy": { "type": "array", "items": { "$ref": "#/$defs/featureId" } },
99
+ "next": {
100
+ "type": "array", "maxItems": 5,
101
+ "items": {
102
+ "type": "object", "required": ["feature", "version"], "additionalProperties": false,
103
+ "properties": { "feature": { "$ref": "#/$defs/featureId" }, "version": { "$ref": "#/$defs/support" } }
104
+ }
105
+ },
106
+ "couldRiseTo": {
107
+ "type": "object", "required": ["version", "feature"], "additionalProperties": false,
108
+ "properties": { "version": { "$ref": "#/$defs/support" }, "feature": { "$ref": "#/$defs/featureId" } }
109
+ },
110
+ "partialSince": { "$ref": "#/$defs/version" }
111
+ }
112
+ }
113
+ }
114
+ }