rerender-lens 0.4.0 → 0.5.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 (66) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/README.md +192 -362
  3. package/dist/{budget-COBu7jBU.d.cts → budget-BnJlYwrV.d.ts} +20 -10
  4. package/dist/{budget-LkNjGtRc.d.ts → budget-CRswn-nC.d.cts} +20 -10
  5. package/dist/cli.cjs +248 -31
  6. package/dist/cli.cjs.map +1 -1
  7. package/dist/cli.js +248 -31
  8. package/dist/cli.js.map +1 -1
  9. package/dist/{devtools-CZebzpF6.d.ts → devtools-BYWat7nQ.d.ts} +7 -1
  10. package/dist/{devtools-BkCct3cJ.d.cts → devtools-DJi_6AfJ.d.cts} +7 -1
  11. package/dist/index.cjs +439 -41
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.cts +131 -8
  14. package/dist/index.d.ts +131 -8
  15. package/dist/index.js +424 -42
  16. package/dist/index.js.map +1 -1
  17. package/dist/jest-setup.cjs +1673 -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 +1671 -0
  22. package/dist/jest-setup.js.map +1 -0
  23. package/dist/jest.cjs +1760 -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 +1751 -0
  28. package/dist/jest.js.map +1 -0
  29. package/dist/{notifiers-BjjGSHpp.d.ts → notifiers-DwKlvv4H.d.cts} +8 -4
  30. package/dist/{notifiers-BGQtWKfX.d.cts → notifiers-FNzKHs0a.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 +10 -2
  38. package/dist/relay.cjs.map +1 -1
  39. package/dist/relay.js +10 -2
  40. package/dist/relay.js.map +1 -1
  41. package/dist/rerender-lens.iife.js +356 -54
  42. package/dist/runner-report-B8Sc3FZO.d.cts +46 -0
  43. package/dist/runner-report-CW8X5RwK.d.ts +46 -0
  44. package/dist/setup.cjs +112 -27
  45. package/dist/setup.cjs.map +1 -1
  46. package/dist/setup.js +112 -27
  47. package/dist/setup.js.map +1 -1
  48. package/dist/{types-BzUEVkxJ.d.cts → types-DW5-N2XH.d.cts} +55 -2
  49. package/dist/{types-BzUEVkxJ.d.ts → types-DW5-N2XH.d.ts} +55 -2
  50. package/dist/vite.d.cts +1 -1
  51. package/dist/vite.d.ts +1 -1
  52. package/dist/vitest-setup.cjs +337 -41
  53. package/dist/vitest-setup.cjs.map +1 -1
  54. package/dist/vitest-setup.d.cts +4 -4
  55. package/dist/vitest-setup.d.ts +4 -4
  56. package/dist/vitest-setup.js +337 -41
  57. package/dist/vitest-setup.js.map +1 -1
  58. package/dist/vitest.cjs +400 -77
  59. package/dist/vitest.cjs.map +1 -1
  60. package/dist/vitest.d.cts +21 -39
  61. package/dist/vitest.d.ts +21 -39
  62. package/dist/vitest.js +401 -78
  63. package/dist/vitest.js.map +1 -1
  64. package/package.json +40 -4
  65. package/panel/panel.css +1 -0
  66. package/panel/panel.js +499 -309
package/dist/vitest.d.cts CHANGED
@@ -1,44 +1,28 @@
1
- import { O as Options, R as RenderReport } from './types-BzUEVkxJ.cjs';
2
- import { C as Collector } from './notifiers-BGQtWKfX.cjs';
3
- export { c as checkBudget, f as formatFixes } from './budget-COBu7jBU.cjs';
1
+ import { R as ReporterOptions } from './runner-report-B8Sc3FZO.cjs';
2
+ export { L as LensSetup, O as OUT_ENV, a as RunResult, S as SetupHooks, b as SetupOptions, r as readRun, s as setupRerenderLens } from './runner-report-B8Sc3FZO.cjs';
3
+ export { c as checkBudget, f as formatFixes } from './budget-CRswn-nC.cjs';
4
+ import './types-DW5-N2XH.cjs';
5
+ import './notifiers-DwKlvv4H.cjs';
4
6
 
5
- declare const OUT_ENV = "RERENDER_LENS_OUT";
6
- interface SetupOptions extends Omit<Options, 'notifier'> {
7
- /** Also fail each test file that recorded avoidable re-renders (default false: the reporter decides). */
8
- failFast?: boolean;
9
- }
10
- /** How the setup ties into the test runner (`{ afterAll }` from 'vitest'; `rerender-lens/vitest/setup` does this). */
11
- interface SetupHooks {
12
- afterAll?: (fn: () => void) => void;
13
- /** Path of the current test file, for the reporter's output. */
14
- testPath?: () => string | undefined;
15
- }
16
- interface LensSetup {
17
- collector: Collector;
18
- /** Append this file's reports to the shared output and clear the collector; registered with `afterAll` when given. */
19
- flush(): void;
20
- }
21
7
  /**
22
- * Call from a `setupFiles` entry. Creates the DevTools hook before react-dom loads, starts the
23
- * library with a collector, and appends this file's reports to the shared output when it ends.
24
- * The collector is returned for per-test assertions (`assertNoAvoidable`, `assertWithinBudget`).
8
+ * Vitest integration: one `setupFiles` line collects every avoidable re-render across the run,
9
+ * and a reporter prints the ranked fixes (and enforces a budget file) when the run ends.
10
+ *
11
+ * // vitest.config.ts
12
+ * test: {
13
+ * setupFiles: ['rerender-lens/vitest/setup'],
14
+ * reporters: ['default', ['rerender-lens/vitest', { budget: 'rerender-budget.json' }]],
15
+ * }
16
+ *
17
+ * Custom options: write your own setup file and call `setupRerenderLens(options, { afterAll })`.
18
+ *
19
+ * Everything that is not Vitest-specific lives in `src/runner-report.ts`, shared with
20
+ * `rerender-lens/jest`.
25
21
  */
26
- declare function setupRerenderLens(options?: SetupOptions, hooks?: SetupHooks): LensSetup;
27
- interface ReporterOptions {
28
- /** Path to a budget JSON (`{ "*": 0, "Row": 2 }`). When set, the run fails on violations. */
29
- budget?: string;
30
- /** Print at most this many fixes. Default 10. */
31
- limit?: number;
32
- /** Also write the collected reports here as a panel-compatible export (`Sessions > Import`). */
33
- exportTo?: string;
34
- /** Where the lines go. Default `process.stdout`. */
35
- write?: (line: string) => void;
36
- }
22
+
37
23
  /** Vitest reporter (`reporters: [['rerender-lens/vitest', { budget }]]`). */
38
24
  declare class RerenderLensReporter {
39
- private options;
40
- private file;
41
- private done;
25
+ private core;
42
26
  constructor(options?: ReporterOptions);
43
27
  onInit(): void;
44
28
  onTestRunEnd(): void;
@@ -46,7 +30,5 @@ declare class RerenderLensReporter {
46
30
  onFinished(): void;
47
31
  private finish;
48
32
  }
49
- /** Reports from every worker of a run. */
50
- declare function readRun(file: string): RenderReport[];
51
33
 
52
- export { type LensSetup, OUT_ENV, type ReporterOptions, type SetupHooks, type SetupOptions, RerenderLensReporter as default, readRun, setupRerenderLens };
34
+ export { ReporterOptions, RerenderLensReporter as default };
package/dist/vitest.d.ts CHANGED
@@ -1,44 +1,28 @@
1
- import { O as Options, R as RenderReport } from './types-BzUEVkxJ.js';
2
- import { C as Collector } from './notifiers-BjjGSHpp.js';
3
- export { c as checkBudget, f as formatFixes } from './budget-LkNjGtRc.js';
1
+ import { R as ReporterOptions } from './runner-report-CW8X5RwK.js';
2
+ export { L as LensSetup, O as OUT_ENV, a as RunResult, S as SetupHooks, b as SetupOptions, r as readRun, s as setupRerenderLens } from './runner-report-CW8X5RwK.js';
3
+ export { c as checkBudget, f as formatFixes } from './budget-BnJlYwrV.js';
4
+ import './types-DW5-N2XH.js';
5
+ import './notifiers-FNzKHs0a.js';
4
6
 
5
- declare const OUT_ENV = "RERENDER_LENS_OUT";
6
- interface SetupOptions extends Omit<Options, 'notifier'> {
7
- /** Also fail each test file that recorded avoidable re-renders (default false: the reporter decides). */
8
- failFast?: boolean;
9
- }
10
- /** How the setup ties into the test runner (`{ afterAll }` from 'vitest'; `rerender-lens/vitest/setup` does this). */
11
- interface SetupHooks {
12
- afterAll?: (fn: () => void) => void;
13
- /** Path of the current test file, for the reporter's output. */
14
- testPath?: () => string | undefined;
15
- }
16
- interface LensSetup {
17
- collector: Collector;
18
- /** Append this file's reports to the shared output and clear the collector; registered with `afterAll` when given. */
19
- flush(): void;
20
- }
21
7
  /**
22
- * Call from a `setupFiles` entry. Creates the DevTools hook before react-dom loads, starts the
23
- * library with a collector, and appends this file's reports to the shared output when it ends.
24
- * The collector is returned for per-test assertions (`assertNoAvoidable`, `assertWithinBudget`).
8
+ * Vitest integration: one `setupFiles` line collects every avoidable re-render across the run,
9
+ * and a reporter prints the ranked fixes (and enforces a budget file) when the run ends.
10
+ *
11
+ * // vitest.config.ts
12
+ * test: {
13
+ * setupFiles: ['rerender-lens/vitest/setup'],
14
+ * reporters: ['default', ['rerender-lens/vitest', { budget: 'rerender-budget.json' }]],
15
+ * }
16
+ *
17
+ * Custom options: write your own setup file and call `setupRerenderLens(options, { afterAll })`.
18
+ *
19
+ * Everything that is not Vitest-specific lives in `src/runner-report.ts`, shared with
20
+ * `rerender-lens/jest`.
25
21
  */
26
- declare function setupRerenderLens(options?: SetupOptions, hooks?: SetupHooks): LensSetup;
27
- interface ReporterOptions {
28
- /** Path to a budget JSON (`{ "*": 0, "Row": 2 }`). When set, the run fails on violations. */
29
- budget?: string;
30
- /** Print at most this many fixes. Default 10. */
31
- limit?: number;
32
- /** Also write the collected reports here as a panel-compatible export (`Sessions > Import`). */
33
- exportTo?: string;
34
- /** Where the lines go. Default `process.stdout`. */
35
- write?: (line: string) => void;
36
- }
22
+
37
23
  /** Vitest reporter (`reporters: [['rerender-lens/vitest', { budget }]]`). */
38
24
  declare class RerenderLensReporter {
39
- private options;
40
- private file;
41
- private done;
25
+ private core;
42
26
  constructor(options?: ReporterOptions);
43
27
  onInit(): void;
44
28
  onTestRunEnd(): void;
@@ -46,7 +30,5 @@ declare class RerenderLensReporter {
46
30
  onFinished(): void;
47
31
  private finish;
48
32
  }
49
- /** Reports from every worker of a run. */
50
- declare function readRun(file: string): RenderReport[];
51
33
 
52
- export { type LensSetup, OUT_ENV, type ReporterOptions, type SetupHooks, type SetupOptions, RerenderLensReporter as default, readRun, setupRerenderLens };
34
+ export { ReporterOptions, RerenderLensReporter as default };