rerender-lens 0.4.0 → 0.7.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 (68) hide show
  1. package/CHANGELOG.md +127 -0
  2. package/README.md +208 -359
  3. package/dist/{budget-LkNjGtRc.d.ts → budget-CA1MS7lB.d.cts} +20 -10
  4. package/dist/{budget-COBu7jBU.d.cts → budget-ok1VDJ4t.d.ts} +20 -10
  5. package/dist/cli.cjs +322 -53
  6. package/dist/cli.cjs.map +1 -1
  7. package/dist/cli.js +322 -53
  8. package/dist/cli.js.map +1 -1
  9. package/dist/{devtools-BkCct3cJ.d.cts → devtools-Cl5n_52v.d.ts} +17 -2
  10. package/dist/{devtools-CZebzpF6.d.ts → devtools-UwQx2VYS.d.cts} +17 -2
  11. package/dist/index.cjs +537 -49
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.cts +137 -8
  14. package/dist/index.d.ts +137 -8
  15. package/dist/index.js +521 -50
  16. package/dist/index.js.map +1 -1
  17. package/dist/jest-setup.cjs +1690 -0
  18. package/dist/jest-setup.cjs.map +1 -0
  19. package/dist/jest-setup.d.cts +8 -0
  20. package/dist/jest-setup.d.ts +8 -0
  21. package/dist/jest-setup.js +1688 -0
  22. package/dist/jest-setup.js.map +1 -0
  23. package/dist/jest.cjs +1777 -0
  24. package/dist/jest.cjs.map +1 -0
  25. package/dist/jest.d.cts +23 -0
  26. package/dist/jest.d.ts +23 -0
  27. package/dist/jest.js +1768 -0
  28. package/dist/jest.js.map +1 -0
  29. package/dist/{notifiers-BjjGSHpp.d.ts → notifiers-B5poAEvE.d.cts} +8 -4
  30. package/dist/{notifiers-BGQtWKfX.d.cts → notifiers-CqQW0Eum.d.ts} +8 -4
  31. package/dist/playwright.cjs +230 -28
  32. package/dist/playwright.cjs.map +1 -1
  33. package/dist/playwright.d.cts +4 -4
  34. package/dist/playwright.d.ts +4 -4
  35. package/dist/playwright.js +230 -28
  36. package/dist/playwright.js.map +1 -1
  37. package/dist/relay.cjs +71 -19
  38. package/dist/relay.cjs.map +1 -1
  39. package/dist/relay.d.cts +25 -3
  40. package/dist/relay.d.ts +25 -3
  41. package/dist/relay.js +71 -19
  42. package/dist/relay.js.map +1 -1
  43. package/dist/rerender-lens.iife.js +457 -62
  44. package/dist/runner-report-Bvqoe89M.d.ts +46 -0
  45. package/dist/runner-report-CvpDg2zt.d.cts +46 -0
  46. package/dist/setup.cjs +209 -35
  47. package/dist/setup.cjs.map +1 -1
  48. package/dist/setup.js +209 -35
  49. package/dist/setup.js.map +1 -1
  50. package/dist/{types-BzUEVkxJ.d.cts → types-DwNN5cWe.d.cts} +82 -2
  51. package/dist/{types-BzUEVkxJ.d.ts → types-DwNN5cWe.d.ts} +82 -2
  52. package/dist/vite.d.cts +1 -1
  53. package/dist/vite.d.ts +1 -1
  54. package/dist/vitest-setup.cjs +357 -44
  55. package/dist/vitest-setup.cjs.map +1 -1
  56. package/dist/vitest-setup.d.cts +4 -4
  57. package/dist/vitest-setup.d.ts +4 -4
  58. package/dist/vitest-setup.js +357 -44
  59. package/dist/vitest-setup.js.map +1 -1
  60. package/dist/vitest.cjs +420 -80
  61. package/dist/vitest.cjs.map +1 -1
  62. package/dist/vitest.d.cts +21 -39
  63. package/dist/vitest.d.ts +21 -39
  64. package/dist/vitest.js +421 -81
  65. package/dist/vitest.js.map +1 -1
  66. package/package.json +41 -4
  67. package/panel/panel.css +49 -0
  68. package/panel/panel.js +871 -353
@@ -1,9 +1,9 @@
1
- import { R as RenderReport } from './types-BzUEVkxJ.js';
1
+ import { b as ReportLike, R as RenderReport } from './types-DwNN5cWe.cjs';
2
2
 
3
3
  /**
4
4
  * Concrete fixes derived from reports, ranked by how many avoidable re-renders each one removes.
5
- * The same logic drives the extension's Fixes view; here it is typed on `RenderReport` for tests,
6
- * CI budgets and the CLI. Pure.
5
+ * One implementation for the library (tests, CI budgets, the CLI, typed on `RenderReport`) and the
6
+ * DevTools panel (serialized reports): everything here reads only `ReportLike`. Pure.
7
7
  */
8
8
 
9
9
  type FixKind = 'memo' | 'useCallback' | 'useMemo' | 'useMemoElement' | 'children' | 'contextValue' | 'splitContext' | 'storeSnapshot' | 'bailout';
@@ -16,19 +16,29 @@ interface Fix {
16
16
  prop: string | null;
17
17
  label: string;
18
18
  detail: string;
19
+ /** Code sketch of the fix, `// <owner>` on the first line. */
20
+ snippet: string;
19
21
  }
20
- interface RankedFix extends Fix {
22
+ interface RankedFix<R extends ReportLike = RenderReport> extends Fix {
21
23
  key: string;
22
24
  /** Avoidable re-renders this fix removes. */
23
25
  count: number;
24
26
  components: Record<string, number>;
27
+ /** The first (at most 50) reports the fix applies to. */
28
+ reports: R[];
25
29
  }
26
- declare function fixesFor(r: RenderReport): Fix[];
30
+ /** `JSON.stringify` cut to `max` characters, for snippets and markdown; never throws. */
31
+ declare function shortValue(v: unknown, max?: number): string;
32
+ /** The concrete fixes one report suggests, each attributed to the component (file) that must change. */
33
+ declare function fixesFor(r: ReportLike): Fix[];
27
34
  declare const fixKey: (f: Fix) => string;
28
- /** Every fix across `reports`, most re-renders removed first. */
29
- declare function rankFixes(reports: RenderReport[]): RankedFix[];
30
- /** Multi-line text for a test failure or a CI log. */
31
- declare function formatFixes(reports: RenderReport[], limit?: number): string;
35
+ /** Every fix across `reports`, most avoidable re-renders removed first. */
36
+ declare function rankFixes<R extends ReportLike>(reports: readonly R[]): RankedFix<R>[];
37
+ /**
38
+ * Multi-line text for a test failure or a CI log: the ranked fixes, then (when the reports carry
39
+ * `commitId`) a "Root causes" section naming the components whose own changes started the cascades.
40
+ */
41
+ declare function formatFixes(reports: readonly ReportLike[], limit?: number): string;
32
42
 
33
43
  /**
34
44
  * Re-render budgets for CI: a JSON baseline of allowed avoidable re-renders per component, checked
@@ -61,4 +71,4 @@ declare function toBudget(reports: RenderReport[]): Budget;
61
71
  /** Throws with the violations and the ranked fixes; use it from a test. */
62
72
  declare function assertWithinBudget(reports: RenderReport[], budget: Budget | number): BudgetResult;
63
73
 
64
- export { type Budget as B, type Fix as F, type RankedFix as R, type BudgetResult as a, type BudgetViolation as b, checkBudget as c, type FixKind as d, assertWithinBudget as e, formatFixes as f, avoidableCounts as g, fixKey as h, fixesFor as i, rankFixes as r, toBudget as t };
74
+ export { type Budget as B, type Fix as F, type RankedFix as R, type BudgetResult as a, type BudgetViolation as b, checkBudget as c, type FixKind as d, assertWithinBudget as e, formatFixes as f, avoidableCounts as g, fixKey as h, fixesFor as i, rankFixes as r, shortValue as s, toBudget as t };
@@ -1,9 +1,9 @@
1
- import { R as RenderReport } from './types-BzUEVkxJ.cjs';
1
+ import { b as ReportLike, R as RenderReport } from './types-DwNN5cWe.js';
2
2
 
3
3
  /**
4
4
  * Concrete fixes derived from reports, ranked by how many avoidable re-renders each one removes.
5
- * The same logic drives the extension's Fixes view; here it is typed on `RenderReport` for tests,
6
- * CI budgets and the CLI. Pure.
5
+ * One implementation for the library (tests, CI budgets, the CLI, typed on `RenderReport`) and the
6
+ * DevTools panel (serialized reports): everything here reads only `ReportLike`. Pure.
7
7
  */
8
8
 
9
9
  type FixKind = 'memo' | 'useCallback' | 'useMemo' | 'useMemoElement' | 'children' | 'contextValue' | 'splitContext' | 'storeSnapshot' | 'bailout';
@@ -16,19 +16,29 @@ interface Fix {
16
16
  prop: string | null;
17
17
  label: string;
18
18
  detail: string;
19
+ /** Code sketch of the fix, `// <owner>` on the first line. */
20
+ snippet: string;
19
21
  }
20
- interface RankedFix extends Fix {
22
+ interface RankedFix<R extends ReportLike = RenderReport> extends Fix {
21
23
  key: string;
22
24
  /** Avoidable re-renders this fix removes. */
23
25
  count: number;
24
26
  components: Record<string, number>;
27
+ /** The first (at most 50) reports the fix applies to. */
28
+ reports: R[];
25
29
  }
26
- declare function fixesFor(r: RenderReport): Fix[];
30
+ /** `JSON.stringify` cut to `max` characters, for snippets and markdown; never throws. */
31
+ declare function shortValue(v: unknown, max?: number): string;
32
+ /** The concrete fixes one report suggests, each attributed to the component (file) that must change. */
33
+ declare function fixesFor(r: ReportLike): Fix[];
27
34
  declare const fixKey: (f: Fix) => string;
28
- /** Every fix across `reports`, most re-renders removed first. */
29
- declare function rankFixes(reports: RenderReport[]): RankedFix[];
30
- /** Multi-line text for a test failure or a CI log. */
31
- declare function formatFixes(reports: RenderReport[], limit?: number): string;
35
+ /** Every fix across `reports`, most avoidable re-renders removed first. */
36
+ declare function rankFixes<R extends ReportLike>(reports: readonly R[]): RankedFix<R>[];
37
+ /**
38
+ * Multi-line text for a test failure or a CI log: the ranked fixes, then (when the reports carry
39
+ * `commitId`) a "Root causes" section naming the components whose own changes started the cascades.
40
+ */
41
+ declare function formatFixes(reports: readonly ReportLike[], limit?: number): string;
32
42
 
33
43
  /**
34
44
  * Re-render budgets for CI: a JSON baseline of allowed avoidable re-renders per component, checked
@@ -61,4 +71,4 @@ declare function toBudget(reports: RenderReport[]): Budget;
61
71
  /** Throws with the violations and the ranked fixes; use it from a test. */
62
72
  declare function assertWithinBudget(reports: RenderReport[], budget: Budget | number): BudgetResult;
63
73
 
64
- export { type Budget as B, type Fix as F, type RankedFix as R, type BudgetResult as a, type BudgetViolation as b, checkBudget as c, type FixKind as d, assertWithinBudget as e, formatFixes as f, avoidableCounts as g, fixKey as h, fixesFor as i, rankFixes as r, toBudget as t };
74
+ export { type Budget as B, type Fix as F, type RankedFix as R, type BudgetResult as a, type BudgetViolation as b, checkBudget as c, type FixKind as d, assertWithinBudget as e, formatFixes as f, avoidableCounts as g, fixKey as h, fixesFor as i, rankFixes as r, shortValue as s, toBudget as t };