rerender-lens 0.5.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.
- package/CHANGELOG.md +50 -1
- package/README.md +23 -4
- package/dist/{budget-CRswn-nC.d.cts → budget-CA1MS7lB.d.cts} +1 -1
- package/dist/{budget-BnJlYwrV.d.ts → budget-ok1VDJ4t.d.ts} +1 -1
- package/dist/cli.cjs +78 -26
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +78 -26
- package/dist/cli.js.map +1 -1
- package/dist/{devtools-BYWat7nQ.d.ts → devtools-Cl5n_52v.d.ts} +11 -2
- package/dist/{devtools-DJi_6AfJ.d.cts → devtools-UwQx2VYS.d.cts} +11 -2
- package/dist/index.cjs +99 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -7
- package/dist/index.d.ts +13 -7
- package/dist/index.js +99 -10
- package/dist/index.js.map +1 -1
- package/dist/jest-setup.cjs +20 -3
- package/dist/jest-setup.cjs.map +1 -1
- package/dist/jest-setup.d.cts +4 -4
- package/dist/jest-setup.d.ts +4 -4
- package/dist/jest-setup.js +20 -3
- package/dist/jest-setup.js.map +1 -1
- package/dist/jest.cjs +20 -3
- package/dist/jest.cjs.map +1 -1
- package/dist/jest.d.cts +4 -4
- package/dist/jest.d.ts +4 -4
- package/dist/jest.js +20 -3
- package/dist/jest.js.map +1 -1
- package/dist/{notifiers-DwKlvv4H.d.cts → notifiers-B5poAEvE.d.cts} +2 -2
- package/dist/{notifiers-FNzKHs0a.d.ts → notifiers-CqQW0Eum.d.ts} +2 -2
- package/dist/playwright.d.cts +4 -4
- package/dist/playwright.d.ts +4 -4
- package/dist/relay.cjs +65 -21
- package/dist/relay.cjs.map +1 -1
- package/dist/relay.d.cts +25 -3
- package/dist/relay.d.ts +25 -3
- package/dist/relay.js +65 -21
- package/dist/relay.js.map +1 -1
- package/dist/rerender-lens.iife.js +105 -12
- package/dist/{runner-report-CW8X5RwK.d.ts → runner-report-Bvqoe89M.d.ts} +2 -2
- package/dist/{runner-report-B8Sc3FZO.d.cts → runner-report-CvpDg2zt.d.cts} +2 -2
- package/dist/setup.cjs +98 -9
- package/dist/setup.cjs.map +1 -1
- package/dist/setup.js +98 -9
- package/dist/setup.js.map +1 -1
- package/dist/{types-DW5-N2XH.d.cts → types-DwNN5cWe.d.cts} +28 -1
- package/dist/{types-DW5-N2XH.d.ts → types-DwNN5cWe.d.ts} +28 -1
- package/dist/vite.d.cts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vitest-setup.cjs +20 -3
- package/dist/vitest-setup.cjs.map +1 -1
- package/dist/vitest-setup.d.cts +4 -4
- package/dist/vitest-setup.d.ts +4 -4
- package/dist/vitest-setup.js +20 -3
- package/dist/vitest-setup.js.map +1 -1
- package/dist/vitest.cjs +20 -3
- package/dist/vitest.cjs.map +1 -1
- package/dist/vitest.d.cts +5 -5
- package/dist/vitest.d.ts +5 -5
- package/dist/vitest.js +20 -3
- package/dist/vitest.js.map +1 -1
- package/package.json +3 -2
- package/panel/panel.css +48 -0
- package/panel/panel.js +348 -20
|
@@ -224,7 +224,34 @@ interface Options {
|
|
|
224
224
|
/** Stop printing a component after this many reports (0 = unlimited). The notifier still receives them. Default 0. */
|
|
225
225
|
maxReportsPerComponent?: number;
|
|
226
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* Why one component type is or is not tracked under the current options, in words a user can act on.
|
|
229
|
+
* Produced by `explainTracking`; `tracked` always agrees with `shouldTrack`.
|
|
230
|
+
*/
|
|
231
|
+
interface TrackingVerdict {
|
|
232
|
+
tracked: boolean;
|
|
233
|
+
/** One sentence: the rule that decided it. */
|
|
234
|
+
reason: string;
|
|
235
|
+
/** What to change to track it, when it is not tracked and something can be changed. */
|
|
236
|
+
fix?: string;
|
|
237
|
+
/** Display name, or `Anonymous` when the type has none. */
|
|
238
|
+
name: string;
|
|
239
|
+
/** `React.memo` component or `PureComponent` class. */
|
|
240
|
+
memoized: boolean;
|
|
241
|
+
}
|
|
242
|
+
/** What the current options select, plus how much of the page they actually cover. In `info().tracking`. */
|
|
243
|
+
interface TrackingSummary {
|
|
244
|
+
/** `all` = every component, `memoized` = `React.memo`/`PureComponent` only, `marked` = only `track()` and `include`. */
|
|
245
|
+
mode: 'all' | 'memoized' | 'marked';
|
|
246
|
+
include: string[];
|
|
247
|
+
exclude: string[];
|
|
248
|
+
/** Distinct component names that rendered since `init`, and how many of those were tracked. */
|
|
249
|
+
renderedCount: number;
|
|
250
|
+
trackedCount: number;
|
|
251
|
+
/** True when more distinct names rendered than the counter keeps (`MAX_SEEN_COMPONENTS`); the counts are a floor. */
|
|
252
|
+
overflow: boolean;
|
|
253
|
+
}
|
|
227
254
|
/** Marker static: `MyComponent.rerenderLens = true` opts a component in. */
|
|
228
255
|
declare const MARKER: "rerenderLens";
|
|
229
256
|
|
|
230
|
-
export { type ChangeKind as C, type HookChange as H, MARKER as M, type Notifier as N, type Options as O, type ParentInfo as P, type RenderReport as R, type SourceLocation as S, type
|
|
257
|
+
export { type ChangeKind as C, type HookChange as H, MARKER as M, type Notifier as N, type Options as O, type ParentInfo as P, type RenderReport as R, type SourceLocation as S, type TrackingSummary as T, type TrackingVerdict as a, type ReportLike as b, type Change as c, type HookSnapshot as d, type CommitPriority as e, type CommitCause as f, type ChangeLike as g, type ComponentMatcher as h, type RenderTrigger as i };
|
|
@@ -224,7 +224,34 @@ interface Options {
|
|
|
224
224
|
/** Stop printing a component after this many reports (0 = unlimited). The notifier still receives them. Default 0. */
|
|
225
225
|
maxReportsPerComponent?: number;
|
|
226
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* Why one component type is or is not tracked under the current options, in words a user can act on.
|
|
229
|
+
* Produced by `explainTracking`; `tracked` always agrees with `shouldTrack`.
|
|
230
|
+
*/
|
|
231
|
+
interface TrackingVerdict {
|
|
232
|
+
tracked: boolean;
|
|
233
|
+
/** One sentence: the rule that decided it. */
|
|
234
|
+
reason: string;
|
|
235
|
+
/** What to change to track it, when it is not tracked and something can be changed. */
|
|
236
|
+
fix?: string;
|
|
237
|
+
/** Display name, or `Anonymous` when the type has none. */
|
|
238
|
+
name: string;
|
|
239
|
+
/** `React.memo` component or `PureComponent` class. */
|
|
240
|
+
memoized: boolean;
|
|
241
|
+
}
|
|
242
|
+
/** What the current options select, plus how much of the page they actually cover. In `info().tracking`. */
|
|
243
|
+
interface TrackingSummary {
|
|
244
|
+
/** `all` = every component, `memoized` = `React.memo`/`PureComponent` only, `marked` = only `track()` and `include`. */
|
|
245
|
+
mode: 'all' | 'memoized' | 'marked';
|
|
246
|
+
include: string[];
|
|
247
|
+
exclude: string[];
|
|
248
|
+
/** Distinct component names that rendered since `init`, and how many of those were tracked. */
|
|
249
|
+
renderedCount: number;
|
|
250
|
+
trackedCount: number;
|
|
251
|
+
/** True when more distinct names rendered than the counter keeps (`MAX_SEEN_COMPONENTS`); the counts are a floor. */
|
|
252
|
+
overflow: boolean;
|
|
253
|
+
}
|
|
227
254
|
/** Marker static: `MyComponent.rerenderLens = true` opts a component in. */
|
|
228
255
|
declare const MARKER: "rerenderLens";
|
|
229
256
|
|
|
230
|
-
export { type ChangeKind as C, type HookChange as H, MARKER as M, type Notifier as N, type Options as O, type ParentInfo as P, type RenderReport as R, type SourceLocation as S, type
|
|
257
|
+
export { type ChangeKind as C, type HookChange as H, MARKER as M, type Notifier as N, type Options as O, type ParentInfo as P, type RenderReport as R, type SourceLocation as S, type TrackingSummary as T, type TrackingVerdict as a, type ReportLike as b, type Change as c, type HookSnapshot as d, type CommitPriority as e, type CommitCause as f, type ChangeLike as g, type ComponentMatcher as h, type RenderTrigger as i };
|
package/dist/vite.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { O as Options } from './types-
|
|
1
|
+
import { O as Options } from './types-DwNN5cWe.cjs';
|
|
2
2
|
|
|
3
3
|
/** `Options` minus the parts that cannot be serialized into a module (functions). Matchers may be strings or RegExps. */
|
|
4
4
|
type VitePluginOptions = Omit<Options, 'notifier' | 'console' | 'include' | 'exclude'> & {
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { O as Options } from './types-
|
|
1
|
+
import { O as Options } from './types-DwNN5cWe.js';
|
|
2
2
|
|
|
3
3
|
/** `Options` minus the parts that cannot be serialized into a module (functions). Matchers may be strings or RegExps. */
|
|
4
4
|
type VitePluginOptions = Omit<Options, 'notifier' | 'console' | 'include' | 'exclude'> & {
|
package/dist/vitest-setup.cjs
CHANGED
|
@@ -388,16 +388,27 @@ function printReport(report, options) {
|
|
|
388
388
|
}
|
|
389
389
|
|
|
390
390
|
// src/state.ts
|
|
391
|
+
var MAX_SEEN_COMPONENTS = 500;
|
|
391
392
|
var KEY = /* @__PURE__ */ Symbol.for("rerender-lens.state");
|
|
392
393
|
function getState() {
|
|
393
394
|
const g = globalThis;
|
|
394
395
|
let s = g[KEY];
|
|
395
396
|
if (!s) {
|
|
396
|
-
s = { options: {}, enabled: false, printed: /* @__PURE__ */ new Map(), detach: null, nextInstanceId: 1, nextCommitId: 1, warnedOnce: /* @__PURE__ */ new Set(), scheduled: 0, commits: 0, overheadMs: 0, maxCommitMs: 0, truncated: 0 };
|
|
397
|
+
s = { options: {}, enabled: false, printed: /* @__PURE__ */ new Map(), detach: null, nextInstanceId: 1, nextCommitId: 1, warnedOnce: /* @__PURE__ */ new Set(), scheduled: 0, commits: 0, overheadMs: 0, maxCommitMs: 0, truncated: 0, seen: /* @__PURE__ */ new Set(), seenTracked: /* @__PURE__ */ new Set(), seenOverflow: false };
|
|
397
398
|
g[KEY] = s;
|
|
398
399
|
}
|
|
399
400
|
return s;
|
|
400
401
|
}
|
|
402
|
+
function noteRendered(s, name, tracked) {
|
|
403
|
+
if (!s.seen.has(name)) {
|
|
404
|
+
if (s.seen.size >= MAX_SEEN_COMPONENTS) {
|
|
405
|
+
s.seenOverflow = true;
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
s.seen.add(name);
|
|
409
|
+
}
|
|
410
|
+
if (tracked) s.seenTracked.add(name);
|
|
411
|
+
}
|
|
401
412
|
function warnOnce(key, message) {
|
|
402
413
|
const s = getState();
|
|
403
414
|
if (s.warnedOnce.has(key)) return;
|
|
@@ -475,6 +486,9 @@ function init(options = {}) {
|
|
|
475
486
|
const s = getState();
|
|
476
487
|
s.options = { ...options };
|
|
477
488
|
s.printed.clear();
|
|
489
|
+
s.seen.clear();
|
|
490
|
+
s.seenTracked.clear();
|
|
491
|
+
s.seenOverflow = false;
|
|
478
492
|
if (!s.enabled) {
|
|
479
493
|
s.detach = attach();
|
|
480
494
|
s.enabled = true;
|
|
@@ -1143,8 +1157,11 @@ function onCommit(root, commitPriority) {
|
|
|
1143
1157
|
const alt = fiber.alternate;
|
|
1144
1158
|
if (alt && isComponentTag(fiber.tag) && didRender(fiber)) {
|
|
1145
1159
|
if (isHotSwapped(fiber, alt)) hot = true;
|
|
1146
|
-
|
|
1147
|
-
|
|
1160
|
+
const name = fiberName(fiber);
|
|
1161
|
+
renderedNames.add(name);
|
|
1162
|
+
const tracked = shouldTrack(fiberType(fiber), o);
|
|
1163
|
+
noteRendered(s, name, tracked);
|
|
1164
|
+
if (tracked) rendered.push(fiber);
|
|
1148
1165
|
}
|
|
1149
1166
|
if (fiber.tag === SuspenseComponent && alt && alt.memoizedState !== null && fiber.memoizedState === null) (resolvedBoundaries ?? (resolvedBoundaries = [])).push(fiber);
|
|
1150
1167
|
if (!alt || fiber.child !== alt.child) {
|