rerender-lens 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.
- package/CHANGELOG.md +15 -0
- package/LICENSE +21 -0
- package/README.md +232 -0
- package/dist/chunk-3YHI7BCU.js +544 -0
- package/dist/chunk-3YHI7BCU.js.map +1 -0
- package/dist/chunk-DOYB4MKH.cjs +562 -0
- package/dist/chunk-DOYB4MKH.cjs.map +1 -0
- package/dist/index.cjs +197 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +213 -0
- package/dist/index.d.ts +213 -0
- package/dist/index.js +134 -0
- package/dist/index.js.map +1 -0
- package/dist/jsx-dev-runtime.cjs +32 -0
- package/dist/jsx-dev-runtime.cjs.map +1 -0
- package/dist/jsx-dev-runtime.d.cts +8 -0
- package/dist/jsx-dev-runtime.d.ts +8 -0
- package/dist/jsx-dev-runtime.js +9 -0
- package/dist/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx-runtime.cjs +34 -0
- package/dist/jsx-runtime.cjs.map +1 -0
- package/dist/jsx-runtime.d.cts +9 -0
- package/dist/jsx-runtime.d.ts +9 -0
- package/dist/jsx-runtime.js +10 -0
- package/dist/jsx-runtime.js.map +1 -0
- package/package.json +101 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import * as ReactNS from 'react';
|
|
2
|
+
|
|
3
|
+
/** Why a single prop/state/hook value differs between two renders. */
|
|
4
|
+
type ChangeKind =
|
|
5
|
+
/** New reference, but deep-equal to the previous value. Avoidable. */
|
|
6
|
+
'deep-equal'
|
|
7
|
+
/** A new function with the same name/body shape. Almost always avoidable. */
|
|
8
|
+
| 'function'
|
|
9
|
+
/** A new React element that renders the same type with deep-equal props. Avoidable. */
|
|
10
|
+
| 'element'
|
|
11
|
+
/** The value genuinely changed. */
|
|
12
|
+
| 'different'
|
|
13
|
+
/** Key was added. */
|
|
14
|
+
| 'added'
|
|
15
|
+
/** Key was removed. */
|
|
16
|
+
| 'removed';
|
|
17
|
+
interface Change {
|
|
18
|
+
/** Dot path from the root, e.g. `style.color` or `items[2]`. */
|
|
19
|
+
path: string;
|
|
20
|
+
kind: ChangeKind;
|
|
21
|
+
prev: unknown;
|
|
22
|
+
next: unknown;
|
|
23
|
+
}
|
|
24
|
+
/** What caused a re-render. */
|
|
25
|
+
type RenderTrigger =
|
|
26
|
+
/** At least one prop genuinely changed. */
|
|
27
|
+
'props'
|
|
28
|
+
/** Props are equal by value, but the parent re-rendered. Wrap in React.memo. */
|
|
29
|
+
| 'parent'
|
|
30
|
+
/** Own state (useState/useReducer/this.setState) changed. */
|
|
31
|
+
| 'state'
|
|
32
|
+
/** A non-state hook value (useContext, useSyncExternalStore) changed. */
|
|
33
|
+
| 'hooks'
|
|
34
|
+
/** More than one of the above. */
|
|
35
|
+
| 'mixed';
|
|
36
|
+
interface HookChange extends Change {
|
|
37
|
+
/** `useState`, `useReducer`, `useContext`, ... */
|
|
38
|
+
hook: string;
|
|
39
|
+
/** Position of the hook in call order (0-based). */
|
|
40
|
+
index: number;
|
|
41
|
+
}
|
|
42
|
+
interface RenderReport {
|
|
43
|
+
/** Display name of the tracked component. */
|
|
44
|
+
component: string;
|
|
45
|
+
/** Monotonic per-component render count (1 = first update, mount is never reported). */
|
|
46
|
+
renderCount: number;
|
|
47
|
+
trigger: RenderTrigger;
|
|
48
|
+
/** True when the re-render produced no genuine change in props, state, or hooks. */
|
|
49
|
+
avoidable: boolean;
|
|
50
|
+
props: {
|
|
51
|
+
prev: Record<string, unknown>;
|
|
52
|
+
next: Record<string, unknown>;
|
|
53
|
+
};
|
|
54
|
+
propChanges: Change[];
|
|
55
|
+
/** Class components only. */
|
|
56
|
+
stateChanges: Change[];
|
|
57
|
+
/** Function components only, when `trackHooks` is on. */
|
|
58
|
+
hookChanges: HookChange[];
|
|
59
|
+
/** Human-readable explanations and suggested fixes. */
|
|
60
|
+
reasons: string[];
|
|
61
|
+
/** `performance.now()` (or `Date.now()`) when the report was produced. */
|
|
62
|
+
time: number;
|
|
63
|
+
}
|
|
64
|
+
type Notifier = (report: RenderReport) => void;
|
|
65
|
+
type ComponentMatcher = string | RegExp | ((displayName: string) => boolean);
|
|
66
|
+
interface Options {
|
|
67
|
+
/** Track every `React.memo`-wrapped component and every `PureComponent`. Default false. */
|
|
68
|
+
trackAllMemoized?: boolean;
|
|
69
|
+
/** Track every component, memoized or not. Noisy. Default false. */
|
|
70
|
+
trackAllComponents?: boolean;
|
|
71
|
+
/** Components to track by display name (string = exact match). */
|
|
72
|
+
include?: ComponentMatcher[];
|
|
73
|
+
/** Components never to track, even when marked. */
|
|
74
|
+
exclude?: ComponentMatcher[];
|
|
75
|
+
/** Capture `useState`/`useReducer`/`useContext` values and diff them. Default true. */
|
|
76
|
+
trackHooks?: boolean;
|
|
77
|
+
/** Report re-renders caused by genuine changes too, not only avoidable ones. Default false. */
|
|
78
|
+
logAll?: boolean;
|
|
79
|
+
/** Do not print to the console. Reports still reach `notifier`. Default false. */
|
|
80
|
+
silent?: boolean;
|
|
81
|
+
/** Receive every report. Combine several with `combineNotifiers`. */
|
|
82
|
+
notifier?: Notifier;
|
|
83
|
+
/** Use `console.groupCollapsed` instead of `console.group`. Default true. */
|
|
84
|
+
collapse?: boolean;
|
|
85
|
+
/** Console-like sink used for printing. Default `console`. */
|
|
86
|
+
console?: Pick<Console, 'log' | 'group' | 'groupCollapsed' | 'groupEnd' | 'warn'>;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The React object to patch. Structural so that both `import React from 'react'`
|
|
90
|
+
* and `import * as React from 'react'` type-check.
|
|
91
|
+
*/
|
|
92
|
+
type ReactLike = Pick<typeof ReactNS, 'createElement' | 'memo' | 'forwardRef' | 'useRef'> & Partial<Pick<typeof ReactNS, 'useState' | 'useReducer' | 'useContext' | 'useSyncExternalStore'>>;
|
|
93
|
+
/** Marker static: `MyComponent.rerenderLens = true` opts a component in. */
|
|
94
|
+
declare const MARKER: "rerenderLens";
|
|
95
|
+
|
|
96
|
+
type AnyType = any;
|
|
97
|
+
declare function getDisplayName(type: unknown): string;
|
|
98
|
+
/** Map an element type to its tracked wrapper (or return it unchanged). */
|
|
99
|
+
declare function resolveType(type: AnyType): AnyType;
|
|
100
|
+
/**
|
|
101
|
+
* Patch `React.createElement` (and the state hooks) so tracked components report
|
|
102
|
+
* their re-renders. Returns a function that undoes the patch.
|
|
103
|
+
*/
|
|
104
|
+
declare function init(R: ReactLike, options?: Options): () => void;
|
|
105
|
+
/** Update options at runtime. Include/exclude changes apply to elements created afterwards. */
|
|
106
|
+
declare function configure(options: Options): void;
|
|
107
|
+
/** Restore the original React functions. Already-created wrappers keep working but stop reporting. */
|
|
108
|
+
declare function disable(): void;
|
|
109
|
+
declare function isEnabled(): boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Opt a component in, with types preserved: `export default track(MyComponent)`.
|
|
112
|
+
* Pass `name` for anonymous arrow functions, which have no inferable name.
|
|
113
|
+
*/
|
|
114
|
+
declare function track<T>(component: T, name?: string): T;
|
|
115
|
+
|
|
116
|
+
type HookOptions = Pick<Options, 'notifier' | 'silent' | 'console' | 'collapse' | 'logAll'>;
|
|
117
|
+
/**
|
|
118
|
+
* Track one component from the inside, without patching React:
|
|
119
|
+
*
|
|
120
|
+
* ```ts
|
|
121
|
+
* function Row(props) {
|
|
122
|
+
* useWhyRerender('Row', props);
|
|
123
|
+
* ...
|
|
124
|
+
* }
|
|
125
|
+
* ```
|
|
126
|
+
*
|
|
127
|
+
* Pass any object of values you care about (props, selected state, context values).
|
|
128
|
+
* Reports go to the console and to the notifier configured via `init`, or to
|
|
129
|
+
* `options.notifier` when given.
|
|
130
|
+
*/
|
|
131
|
+
declare function useWhyRerender(name: string, values: Record<string, unknown>, options?: HookOptions): void;
|
|
132
|
+
|
|
133
|
+
type Seen = Map<object, Set<object>>;
|
|
134
|
+
/**
|
|
135
|
+
* Structural equality that understands Map, Set, Date, RegExp, typed arrays,
|
|
136
|
+
* React elements and cyclic references. Functions are equal only by reference.
|
|
137
|
+
*/
|
|
138
|
+
declare function deepEqual(a: unknown, b: unknown, seen?: Seen): boolean;
|
|
139
|
+
/** Classify why two values differ. Assumes `!Object.is(prev, next)`. */
|
|
140
|
+
declare function classify(prev: unknown, next: unknown): ChangeKind;
|
|
141
|
+
/**
|
|
142
|
+
* Shallow-diff two records. Every changed key produces exactly one Change;
|
|
143
|
+
* for `different` values that are plain objects/arrays, the nested path that
|
|
144
|
+
* actually differs is reported in `path` to make the console output actionable.
|
|
145
|
+
*/
|
|
146
|
+
declare function diffRecords(prev: Record<string, unknown> | undefined | null, next: Record<string, unknown> | undefined | null, basePath?: string): Change[];
|
|
147
|
+
|
|
148
|
+
interface BuildInput {
|
|
149
|
+
component: string;
|
|
150
|
+
renderCount: number;
|
|
151
|
+
prevProps: Record<string, unknown>;
|
|
152
|
+
nextProps: Record<string, unknown>;
|
|
153
|
+
propChanges: Change[];
|
|
154
|
+
stateChanges?: Change[];
|
|
155
|
+
hookChanges?: HookChange[];
|
|
156
|
+
}
|
|
157
|
+
declare function buildReport(input: BuildInput): RenderReport;
|
|
158
|
+
declare function summarize(report: RenderReport): string;
|
|
159
|
+
/** Default notifier: prints a console group per report. */
|
|
160
|
+
declare function printReport(report: RenderReport, options: Options): void;
|
|
161
|
+
|
|
162
|
+
interface Collector {
|
|
163
|
+
/** Every report received, in order. */
|
|
164
|
+
readonly reports: RenderReport[];
|
|
165
|
+
/** Reports where `avoidable` is true. */
|
|
166
|
+
readonly avoidable: RenderReport[];
|
|
167
|
+
/** Pass this to `init({ notifier })`. */
|
|
168
|
+
readonly notifier: Notifier;
|
|
169
|
+
clear(): void;
|
|
170
|
+
/** Throws with a readable message if any avoidable re-render was recorded. */
|
|
171
|
+
assertNoAvoidable(): void;
|
|
172
|
+
}
|
|
173
|
+
/** Collect reports in memory. Meant for tests. */
|
|
174
|
+
declare function createCollector(): Collector;
|
|
175
|
+
declare function combineNotifiers(...notifiers: Array<Notifier | undefined | null | false>): Notifier;
|
|
176
|
+
|
|
177
|
+
declare const DEVTOOLS_MARKER: "__rerenderLens";
|
|
178
|
+
declare const PROTOCOL_VERSION = 1;
|
|
179
|
+
interface DevtoolsMessage {
|
|
180
|
+
[DEVTOOLS_MARKER]: true;
|
|
181
|
+
version: number;
|
|
182
|
+
type: 'report' | 'clear' | 'hello';
|
|
183
|
+
payload?: unknown;
|
|
184
|
+
}
|
|
185
|
+
interface DevtoolsNotifierOptions {
|
|
186
|
+
/** How many reports to keep for `replay()`. Default 300. */
|
|
187
|
+
bufferSize?: number;
|
|
188
|
+
/** Where to post. Default `window`. */
|
|
189
|
+
target?: Pick<Window, 'postMessage'>;
|
|
190
|
+
/** Max serialization depth. Default 6. */
|
|
191
|
+
maxDepth?: number;
|
|
192
|
+
}
|
|
193
|
+
interface DevtoolsBridge {
|
|
194
|
+
/** Re-post every buffered report (a panel that opened late calls this). */
|
|
195
|
+
replay(): void;
|
|
196
|
+
clear(): void;
|
|
197
|
+
readonly size: number;
|
|
198
|
+
readonly version: number;
|
|
199
|
+
}
|
|
200
|
+
declare global {
|
|
201
|
+
interface Window {
|
|
202
|
+
__RERENDER_LENS_DEVTOOLS__?: DevtoolsBridge;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
/** Convert a report into a structured-clone-safe value (functions, elements, cycles removed). */
|
|
206
|
+
declare function serialize(value: unknown, maxDepth?: number, seen?: WeakSet<object>, depth?: number): unknown;
|
|
207
|
+
/**
|
|
208
|
+
* A notifier that posts every report on `window` for a DevTools extension to pick up.
|
|
209
|
+
* Also installs `window.__RERENDER_LENS_DEVTOOLS__` with `replay()` / `clear()`.
|
|
210
|
+
*/
|
|
211
|
+
declare function createDevtoolsNotifier(options?: DevtoolsNotifierOptions): Notifier;
|
|
212
|
+
|
|
213
|
+
export { type Change, type ChangeKind, type Collector, type ComponentMatcher, DEVTOOLS_MARKER, type DevtoolsBridge, type DevtoolsMessage, type DevtoolsNotifierOptions, type HookChange, MARKER, type Notifier, type Options, PROTOCOL_VERSION, type RenderReport, type RenderTrigger, buildReport, classify, combineNotifiers, configure, createCollector, createDevtoolsNotifier, deepEqual, diffRecords, disable, getDisplayName, init, isEnabled, printReport, resolveType, serialize, summarize, track, useWhyRerender };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { diffRecords, dispatch, buildReport, getState, isReactElement, getDisplayName } from './chunk-3YHI7BCU.js';
|
|
2
|
+
export { MARKER, buildReport, classify, configure, deepEqual, diffRecords, disable, getDisplayName, init, isEnabled, printReport, resolveType, summarize, track } from './chunk-3YHI7BCU.js';
|
|
3
|
+
import { useRef, useEffect } from 'react';
|
|
4
|
+
|
|
5
|
+
function useWhyRerender(name, values, options) {
|
|
6
|
+
const ref = useRef({
|
|
7
|
+
committed: null,
|
|
8
|
+
reported: false,
|
|
9
|
+
count: 0
|
|
10
|
+
});
|
|
11
|
+
const st = ref.current;
|
|
12
|
+
if (st.committed && !st.reported) {
|
|
13
|
+
st.reported = true;
|
|
14
|
+
st.count++;
|
|
15
|
+
const propChanges = diffRecords(st.committed, values);
|
|
16
|
+
dispatch(
|
|
17
|
+
buildReport({
|
|
18
|
+
component: name,
|
|
19
|
+
renderCount: st.count,
|
|
20
|
+
prevProps: st.committed,
|
|
21
|
+
nextProps: values,
|
|
22
|
+
propChanges
|
|
23
|
+
}),
|
|
24
|
+
options ? { ...getState().options, ...options } : void 0
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
st.committed = values;
|
|
29
|
+
st.reported = false;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// src/notifiers.ts
|
|
34
|
+
function createCollector() {
|
|
35
|
+
const reports = [];
|
|
36
|
+
return {
|
|
37
|
+
reports,
|
|
38
|
+
get avoidable() {
|
|
39
|
+
return reports.filter((r) => r.avoidable);
|
|
40
|
+
},
|
|
41
|
+
notifier: (r) => {
|
|
42
|
+
reports.push(r);
|
|
43
|
+
},
|
|
44
|
+
clear: () => {
|
|
45
|
+
reports.length = 0;
|
|
46
|
+
},
|
|
47
|
+
assertNoAvoidable() {
|
|
48
|
+
const bad = reports.filter((r) => r.avoidable);
|
|
49
|
+
if (bad.length === 0) return;
|
|
50
|
+
const lines = bad.map((r) => ` <${r.component}> render #${r.renderCount}:
|
|
51
|
+
${r.reasons.map((x) => ` - ${x}`).join("\n")}`);
|
|
52
|
+
throw new Error(`${bad.length} avoidable re-render${bad.length === 1 ? "" : "s"} detected:
|
|
53
|
+
${lines.join("\n")}`);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function combineNotifiers(...notifiers) {
|
|
58
|
+
const list = notifiers.filter((n) => typeof n === "function");
|
|
59
|
+
return (report) => {
|
|
60
|
+
for (const n of list) n(report);
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// src/devtools.ts
|
|
65
|
+
var DEVTOOLS_MARKER = "__rerenderLens";
|
|
66
|
+
var PROTOCOL_VERSION = 1;
|
|
67
|
+
function serialize(value, maxDepth = 6, seen = /* @__PURE__ */ new WeakSet(), depth = 0) {
|
|
68
|
+
if (value === null || value === void 0) return value;
|
|
69
|
+
const t = typeof value;
|
|
70
|
+
if (t === "string" || t === "boolean") return value;
|
|
71
|
+
if (t === "number") return Number.isFinite(value) ? value : String(value);
|
|
72
|
+
if (t === "bigint") return `${String(value)}n`;
|
|
73
|
+
if (t === "symbol") return String(value);
|
|
74
|
+
if (t === "function") return `\u0192 ${value.name || "anonymous"}`;
|
|
75
|
+
const obj = value;
|
|
76
|
+
if (seen.has(obj)) return "[Circular]";
|
|
77
|
+
if (depth >= maxDepth) return "[\u2026]";
|
|
78
|
+
seen.add(obj);
|
|
79
|
+
try {
|
|
80
|
+
if (isReactElement(obj)) return `<${getDisplayName(obj.type)}>`;
|
|
81
|
+
if (obj instanceof Date) return { $type: "Date", value: obj.toISOString() };
|
|
82
|
+
if (obj instanceof RegExp) return { $type: "RegExp", value: String(obj) };
|
|
83
|
+
if (obj instanceof Map) {
|
|
84
|
+
return { $type: "Map", entries: [...obj].map(([k, v]) => [serialize(k, maxDepth, seen, depth + 1), serialize(v, maxDepth, seen, depth + 1)]) };
|
|
85
|
+
}
|
|
86
|
+
if (obj instanceof Set) return { $type: "Set", values: [...obj].map((v) => serialize(v, maxDepth, seen, depth + 1)) };
|
|
87
|
+
if (Array.isArray(obj)) return obj.map((v) => serialize(v, maxDepth, seen, depth + 1));
|
|
88
|
+
if (typeof Element !== "undefined" && obj instanceof Element) return `<${obj.tagName.toLowerCase()}>`;
|
|
89
|
+
const out = {};
|
|
90
|
+
for (const k of Object.keys(obj)) out[k] = serialize(obj[k], maxDepth, seen, depth + 1);
|
|
91
|
+
const proto = Object.getPrototypeOf(obj);
|
|
92
|
+
if (proto && proto !== Object.prototype && proto.constructor?.name) out.$type = proto.constructor.name;
|
|
93
|
+
return out;
|
|
94
|
+
} finally {
|
|
95
|
+
seen.delete(obj);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function createDevtoolsNotifier(options = {}) {
|
|
99
|
+
const bufferSize = options.bufferSize ?? 300;
|
|
100
|
+
const maxDepth = options.maxDepth ?? 6;
|
|
101
|
+
const target = options.target ?? (typeof window !== "undefined" ? window : void 0);
|
|
102
|
+
const buffer = [];
|
|
103
|
+
const post = (type, payload) => {
|
|
104
|
+
if (!target) return;
|
|
105
|
+
const msg = { [DEVTOOLS_MARKER]: true, version: PROTOCOL_VERSION, type, payload };
|
|
106
|
+
target.postMessage(msg, "*");
|
|
107
|
+
};
|
|
108
|
+
const bridge = {
|
|
109
|
+
replay: () => {
|
|
110
|
+
post("hello", { count: buffer.length });
|
|
111
|
+
for (const p of buffer) post("report", p);
|
|
112
|
+
},
|
|
113
|
+
clear: () => {
|
|
114
|
+
buffer.length = 0;
|
|
115
|
+
post("clear");
|
|
116
|
+
},
|
|
117
|
+
get size() {
|
|
118
|
+
return buffer.length;
|
|
119
|
+
},
|
|
120
|
+
version: PROTOCOL_VERSION
|
|
121
|
+
};
|
|
122
|
+
if (typeof window !== "undefined") window.__RERENDER_LENS_DEVTOOLS__ = bridge;
|
|
123
|
+
post("hello", { count: 0 });
|
|
124
|
+
return (report) => {
|
|
125
|
+
const payload = serialize(report, maxDepth);
|
|
126
|
+
buffer.push(payload);
|
|
127
|
+
if (buffer.length > bufferSize) buffer.splice(0, buffer.length - bufferSize);
|
|
128
|
+
post("report", payload);
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export { DEVTOOLS_MARKER, PROTOCOL_VERSION, combineNotifiers, createCollector, createDevtoolsNotifier, serialize, useWhyRerender };
|
|
133
|
+
//# sourceMappingURL=index.js.map
|
|
134
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hook.ts","../src/notifiers.ts","../src/devtools.ts"],"names":[],"mappings":";;;;AAsBO,SAAS,cAAA,CAAe,IAAA,EAAc,MAAA,EAAiC,OAAA,EAA6B;AACzG,EAAA,MAAM,MAAM,MAAA,CAAwF;AAAA,IAClG,SAAA,EAAW,IAAA;AAAA,IACX,QAAA,EAAU,KAAA;AAAA,IACV,KAAA,EAAO;AAAA,GACR,CAAA;AACD,EAAA,MAAM,KAAK,GAAA,CAAI,OAAA;AAGf,EAAA,IAAI,EAAA,CAAG,SAAA,IAAa,CAAC,EAAA,CAAG,QAAA,EAAU;AAChC,IAAA,EAAA,CAAG,QAAA,GAAW,IAAA;AACd,IAAA,EAAA,CAAG,KAAA,EAAA;AACH,IAAA,MAAM,WAAA,GAAc,WAAA,CAAY,EAAA,CAAG,SAAA,EAAW,MAAM,CAAA;AACpD,IAAA,QAAA;AAAA,MACE,WAAA,CAAY;AAAA,QACV,SAAA,EAAW,IAAA;AAAA,QACX,aAAa,EAAA,CAAG,KAAA;AAAA,QAChB,WAAW,EAAA,CAAG,SAAA;AAAA,QACd,SAAA,EA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G,CAAA;AAAA,EAC7B,CAAA;AAEA,EAAA,MAAM,MAAA,GAAyB;AAAA,IAC7B,QAAQ,MAAM;AACZ,MAAA,IAAA,CAAK,OAAA,EAAS,EAAE,KAAA,EAAO,MAAA,CAAO,QAAQ,CAAA;AACtC,MAAA,KAAA,MAAW,CAAA,IAAK,MAAA,EAAQ,IAAA,CAAK,QAAA,EAAU,CAAC,CAAA;AAAA,IAC1C,CAAA;AAAA,IACA,OAAO,MAAM;AACX,MAAA,MAAA,CAAO,MAAA,GAAS,CAAA;AAChB,MAAA,IAAA,CAAK,OAAO,CAAA;AAAA,IACd,CAAA;AAAA,IACA,IAAI,IAAA,GAAO;AACT,MAAA,OAAO,MAAA,CAAO,MAAA;AAAA,IAChB,CAAA;AAAA,IACA,OAAA,EAAS;AAAA,GACX;AACA,EAAA,IAAI,OAAO,MAAA,KAAW,WAAA,EAAa,MAAA,CAAO,0BAAA,GAA6B,MAAA;AACvE,EAAA,IAAA,CAAK,OAAA,EAAS,EAAE,KAAA,EAAO,CAAA,EAAG,CAAA;AAE1B,EAAA,OAAO,CAAC,MAAA,KAAyB;AAC/B,IAAA,MAAM,OAAA,GAAU,SAAA,CAAU,MAAA,EAAQ,QAAQ,CAAA;AAC1C,IAAA,MAAA,CAAO,KAAK,OAAO,CAAA;AACnB,IAAA,IAAI,MAAA,CAAO,SAAS,UAAA,EAAY,MAAA,CAAO,OAAO,CAAA,EAAG,MAAA,CAAO,SAAS,UAAU,CAAA;AAC3E,IAAA,IAAA,CAAK,UAAU,OAAO,CAAA;AAAA,EACxB,CAAA;AACF","file":"index.js","sourcesContent":["import { useEffect, useRef } from 'react';\nimport type { Options } from './types';\nimport { diffRecords } from './diff';\nimport { buildReport } from './report';\nimport { dispatch, getState } from './state';\n\ntype HookOptions = Pick<Options, 'notifier' | 'silent' | 'console' | 'collapse' | 'logAll'>;\n\n/**\n * Track one component from the inside, without patching React:\n *\n * ```ts\n * function Row(props) {\n * useWhyRerender('Row', props);\n * ...\n * }\n * ```\n *\n * Pass any object of values you care about (props, selected state, context values).\n * Reports go to the console and to the notifier configured via `init`, or to\n * `options.notifier` when given.\n */\nexport function useWhyRerender(name: string, values: Record<string, unknown>, options?: HookOptions): void {\n const ref = useRef<{ committed: Record<string, unknown> | null; reported: boolean; count: number }>({\n committed: null,\n reported: false,\n count: 0,\n });\n const st = ref.current;\n // Compare against the last *committed* values. StrictMode renders twice before a\n // commit; `reported` makes sure the second pass does not produce a duplicate.\n if (st.committed && !st.reported) {\n st.reported = true;\n st.count++;\n const propChanges = diffRecords(st.committed, values);\n dispatch(\n buildReport({\n component: name,\n renderCount: st.count,\n prevProps: st.committed,\n nextProps: values,\n propChanges,\n }),\n options ? { ...getState().options, ...options } : undefined,\n );\n }\n useEffect(() => {\n st.committed = values;\n st.reported = false;\n });\n}\n","import type { Notifier, RenderReport } from './types';\n\nexport interface Collector {\n /** Every report received, in order. */\n readonly reports: RenderReport[];\n /** Reports where `avoidable` is true. */\n readonly avoidable: RenderReport[];\n /** Pass this to `init({ notifier })`. */\n readonly notifier: Notifier;\n clear(): void;\n /** Throws with a readable message if any avoidable re-render was recorded. */\n assertNoAvoidable(): void;\n}\n\n/** Collect reports in memory. Meant for tests. */\nexport function createCollector(): Collector {\n const reports: RenderReport[] = [];\n return {\n reports,\n get avoidable() {\n return reports.filter((r) => r.avoidable);\n },\n notifier: (r) => {\n reports.push(r);\n },\n clear: () => {\n reports.length = 0;\n },\n assertNoAvoidable() {\n const bad = reports.filter((r) => r.avoidable);\n if (bad.length === 0) return;\n const lines = bad.map((r) => ` <${r.component}> render #${r.renderCount}:\\n${r.reasons.map((x) => ` - ${x}`).join('\\n')}`);\n throw new Error(`${bad.length} avoidable re-render${bad.length === 1 ? '' : 's'} detected:\\n${lines.join('\\n')}`);\n },\n };\n}\n\nexport function combineNotifiers(...notifiers: Array<Notifier | undefined | null | false>): Notifier {\n const list = notifiers.filter((n): n is Notifier => typeof n === 'function');\n return (report) => {\n for (const n of list) n(report);\n };\n}\n","import type { Notifier, RenderReport } from './types';\nimport { isReactElement } from './diff';\nimport { getDisplayName } from './tracker';\n\nexport const DEVTOOLS_MARKER = '__rerenderLens' as const;\nexport const PROTOCOL_VERSION = 1;\n\nexport interface DevtoolsMessage {\n [DEVTOOLS_MARKER]: true;\n version: number;\n type: 'report' | 'clear' | 'hello';\n payload?: unknown;\n}\n\nexport interface DevtoolsNotifierOptions {\n /** How many reports to keep for `replay()`. Default 300. */\n bufferSize?: number;\n /** Where to post. Default `window`. */\n target?: Pick<Window, 'postMessage'>;\n /** Max serialization depth. Default 6. */\n maxDepth?: number;\n}\n\nexport interface DevtoolsBridge {\n /** Re-post every buffered report (a panel that opened late calls this). */\n replay(): void;\n clear(): void;\n readonly size: number;\n readonly version: number;\n}\n\ndeclare global {\n interface Window {\n __RERENDER_LENS_DEVTOOLS__?: DevtoolsBridge;\n }\n}\n\n/** Convert a report into a structured-clone-safe value (functions, elements, cycles removed). */\nexport function serialize(value: unknown, maxDepth = 6, seen: WeakSet<object> = new WeakSet(), depth = 0): unknown {\n if (value === null || value === undefined) return value;\n const t = typeof value;\n if (t === 'string' || t === 'boolean') return value;\n if (t === 'number') return Number.isFinite(value as number) ? value : String(value);\n if (t === 'bigint') return `${String(value)}n`;\n if (t === 'symbol') return String(value);\n if (t === 'function') return `ƒ ${(value as { name?: string }).name || 'anonymous'}`;\n const obj = value as object;\n if (seen.has(obj)) return '[Circular]';\n if (depth >= maxDepth) return '[…]';\n seen.add(obj);\n try {\n if (isReactElement(obj)) return `<${getDisplayName(obj.type)}>`;\n if (obj instanceof Date) return { $type: 'Date', value: obj.toISOString() };\n if (obj instanceof RegExp) return { $type: 'RegExp', value: String(obj) };\n if (obj instanceof Map) {\n return { $type: 'Map', entries: [...obj].map(([k, v]) => [serialize(k, maxDepth, seen, depth + 1), serialize(v, maxDepth, seen, depth + 1)]) };\n }\n if (obj instanceof Set) return { $type: 'Set', values: [...obj].map((v) => serialize(v, maxDepth, seen, depth + 1)) };\n if (Array.isArray(obj)) return obj.map((v) => serialize(v, maxDepth, seen, depth + 1));\n if (typeof Element !== 'undefined' && obj instanceof Element) return `<${obj.tagName.toLowerCase()}>`;\n const out: Record<string, unknown> = {};\n for (const k of Object.keys(obj)) out[k] = serialize((obj as Record<string, unknown>)[k], maxDepth, seen, depth + 1);\n const proto = Object.getPrototypeOf(obj) as { constructor?: { name?: string } } | null;\n if (proto && proto !== Object.prototype && proto.constructor?.name) out.$type = proto.constructor.name;\n return out;\n } finally {\n seen.delete(obj);\n }\n}\n\n/**\n * A notifier that posts every report on `window` for a DevTools extension to pick up.\n * Also installs `window.__RERENDER_LENS_DEVTOOLS__` with `replay()` / `clear()`.\n */\nexport function createDevtoolsNotifier(options: DevtoolsNotifierOptions = {}): Notifier {\n const bufferSize = options.bufferSize ?? 300;\n const maxDepth = options.maxDepth ?? 6;\n const target = options.target ?? (typeof window !== 'undefined' ? window : undefined);\n const buffer: unknown[] = [];\n\n const post = (type: DevtoolsMessage['type'], payload?: unknown): void => {\n if (!target) return;\n const msg: DevtoolsMessage = { [DEVTOOLS_MARKER]: true, version: PROTOCOL_VERSION, type, payload };\n target.postMessage(msg, '*');\n };\n\n const bridge: DevtoolsBridge = {\n replay: () => {\n post('hello', { count: buffer.length });\n for (const p of buffer) post('report', p);\n },\n clear: () => {\n buffer.length = 0;\n post('clear');\n },\n get size() {\n return buffer.length;\n },\n version: PROTOCOL_VERSION,\n };\n if (typeof window !== 'undefined') window.__RERENDER_LENS_DEVTOOLS__ = bridge;\n post('hello', { count: 0 });\n\n return (report: RenderReport) => {\n const payload = serialize(report, maxDepth);\n buffer.push(payload);\n if (buffer.length > bufferSize) buffer.splice(0, buffer.length - bufferSize);\n post('report', payload);\n };\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkDOYB4MKH_cjs = require('./chunk-DOYB4MKH.cjs');
|
|
4
|
+
var Runtime = require('react/jsx-dev-runtime');
|
|
5
|
+
|
|
6
|
+
function _interopNamespace(e) {
|
|
7
|
+
if (e && e.__esModule) return e;
|
|
8
|
+
var n = Object.create(null);
|
|
9
|
+
if (e) {
|
|
10
|
+
Object.keys(e).forEach(function (k) {
|
|
11
|
+
if (k !== 'default') {
|
|
12
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return e[k]; }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
n.default = e;
|
|
21
|
+
return Object.freeze(n);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var Runtime__namespace = /*#__PURE__*/_interopNamespace(Runtime);
|
|
25
|
+
|
|
26
|
+
var Fragment2 = Runtime__namespace.Fragment;
|
|
27
|
+
var jsxDEV2 = (type, props, key, isStatic, source, self) => Runtime__namespace.jsxDEV(chunkDOYB4MKH_cjs.resolveType(type), props, key, isStatic, source, self);
|
|
28
|
+
|
|
29
|
+
exports.Fragment = Fragment2;
|
|
30
|
+
exports.jsxDEV = jsxDEV2;
|
|
31
|
+
//# sourceMappingURL=jsx-dev-runtime.cjs.map
|
|
32
|
+
//# sourceMappingURL=jsx-dev-runtime.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/jsx-dev-runtime.ts"],"names":["Fragment","Runtime","jsxDEV","resolveType"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAIO,IAAMA,SAAAA,GAA4CC,kBAAA,CAAA;AAIlD,IAAMC,UAAmB,CAAC,IAAA,EAAM,KAAA,EAAO,GAAA,EAAK,UAAU,MAAA,EAAQ,IAAA,KAC3DD,kBAAA,CAAA,MAAA,CAAOE,6BAAA,CAAY,IAAI,CAAA,EAAG,KAAA,EAAO,GAAA,EAAK,QAAA,EAAU,QAAQ,IAAI","file":"jsx-dev-runtime.cjs","sourcesContent":["import * as Runtime from 'react/jsx-dev-runtime';\nimport { resolveType } from './tracker';\n\nexport type { JSX } from 'react/jsx-dev-runtime';\nexport const Fragment: typeof Runtime.Fragment = Runtime.Fragment;\n\ntype JsxDevFn = typeof Runtime.jsxDEV;\n\nexport const jsxDEV: JsxDevFn = (type, props, key, isStatic, source, self) =>\n Runtime.jsxDEV(resolveType(type), props, key, isStatic, source, self);\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { resolveType } from './chunk-3YHI7BCU.js';
|
|
2
|
+
import * as Runtime from 'react/jsx-dev-runtime';
|
|
3
|
+
|
|
4
|
+
var Fragment2 = Runtime.Fragment;
|
|
5
|
+
var jsxDEV2 = (type, props, key, isStatic, source, self) => Runtime.jsxDEV(resolveType(type), props, key, isStatic, source, self);
|
|
6
|
+
|
|
7
|
+
export { Fragment2 as Fragment, jsxDEV2 as jsxDEV };
|
|
8
|
+
//# sourceMappingURL=jsx-dev-runtime.js.map
|
|
9
|
+
//# sourceMappingURL=jsx-dev-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/jsx-dev-runtime.ts"],"names":["Fragment","jsxDEV"],"mappings":";;;AAIO,IAAMA,SAAAA,GAA4C,OAAA,CAAA;AAIlD,IAAMC,UAAmB,CAAC,IAAA,EAAM,KAAA,EAAO,GAAA,EAAK,UAAU,MAAA,EAAQ,IAAA,KAC3D,OAAA,CAAA,MAAA,CAAO,WAAA,CAAY,IAAI,CAAA,EAAG,KAAA,EAAO,GAAA,EAAK,QAAA,EAAU,QAAQ,IAAI","file":"jsx-dev-runtime.js","sourcesContent":["import * as Runtime from 'react/jsx-dev-runtime';\nimport { resolveType } from './tracker';\n\nexport type { JSX } from 'react/jsx-dev-runtime';\nexport const Fragment: typeof Runtime.Fragment = Runtime.Fragment;\n\ntype JsxDevFn = typeof Runtime.jsxDEV;\n\nexport const jsxDEV: JsxDevFn = (type, props, key, isStatic, source, self) =>\n Runtime.jsxDEV(resolveType(type), props, key, isStatic, source, self);\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkDOYB4MKH_cjs = require('./chunk-DOYB4MKH.cjs');
|
|
4
|
+
var Runtime = require('react/jsx-runtime');
|
|
5
|
+
|
|
6
|
+
function _interopNamespace(e) {
|
|
7
|
+
if (e && e.__esModule) return e;
|
|
8
|
+
var n = Object.create(null);
|
|
9
|
+
if (e) {
|
|
10
|
+
Object.keys(e).forEach(function (k) {
|
|
11
|
+
if (k !== 'default') {
|
|
12
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return e[k]; }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
n.default = e;
|
|
21
|
+
return Object.freeze(n);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var Runtime__namespace = /*#__PURE__*/_interopNamespace(Runtime);
|
|
25
|
+
|
|
26
|
+
var Fragment2 = Runtime__namespace.Fragment;
|
|
27
|
+
var jsx2 = (type, props, key) => Runtime__namespace.jsx(chunkDOYB4MKH_cjs.resolveType(type), props, key);
|
|
28
|
+
var jsxs2 = (type, props, key) => Runtime__namespace.jsxs(chunkDOYB4MKH_cjs.resolveType(type), props, key);
|
|
29
|
+
|
|
30
|
+
exports.Fragment = Fragment2;
|
|
31
|
+
exports.jsx = jsx2;
|
|
32
|
+
exports.jsxs = jsxs2;
|
|
33
|
+
//# sourceMappingURL=jsx-runtime.cjs.map
|
|
34
|
+
//# sourceMappingURL=jsx-runtime.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/jsx-runtime.ts"],"names":["Fragment","Runtime","jsx","resolveType","jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAIO,IAAMA,SAAAA,GAA4CC,kBAAA,CAAA;AAIlD,IAAMC,IAAAA,GAAa,CAAC,IAAA,EAAM,KAAA,EAAO,GAAA,KAAgBD,uBAAIE,6BAAA,CAAY,IAAI,CAAA,EAAG,KAAA,EAAO,GAAG;AAClF,IAAMC,KAAAA,GAAc,CAAC,IAAA,EAAM,KAAA,EAAO,GAAA,KAAgBH,wBAAKE,6BAAA,CAAY,IAAI,CAAA,EAAG,KAAA,EAAO,GAAG","file":"jsx-runtime.cjs","sourcesContent":["import * as Runtime from 'react/jsx-runtime';\nimport { resolveType } from './tracker';\n\nexport type { JSX } from 'react/jsx-runtime';\nexport const Fragment: typeof Runtime.Fragment = Runtime.Fragment;\n\ntype JsxFn = typeof Runtime.jsx;\n\nexport const jsx: JsxFn = (type, props, key) => Runtime.jsx(resolveType(type), props, key);\nexport const jsxs: JsxFn = (type, props, key) => Runtime.jsxs(resolveType(type), props, key);\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as Runtime from 'react/jsx-runtime';
|
|
2
|
+
export { JSX } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
declare const Fragment: typeof Runtime.Fragment;
|
|
5
|
+
type JsxFn = typeof Runtime.jsx;
|
|
6
|
+
declare const jsx: JsxFn;
|
|
7
|
+
declare const jsxs: JsxFn;
|
|
8
|
+
|
|
9
|
+
export { Fragment, jsx, jsxs };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as Runtime from 'react/jsx-runtime';
|
|
2
|
+
export { JSX } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
declare const Fragment: typeof Runtime.Fragment;
|
|
5
|
+
type JsxFn = typeof Runtime.jsx;
|
|
6
|
+
declare const jsx: JsxFn;
|
|
7
|
+
declare const jsxs: JsxFn;
|
|
8
|
+
|
|
9
|
+
export { Fragment, jsx, jsxs };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { resolveType } from './chunk-3YHI7BCU.js';
|
|
2
|
+
import * as Runtime from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
var Fragment2 = Runtime.Fragment;
|
|
5
|
+
var jsx2 = (type, props, key) => Runtime.jsx(resolveType(type), props, key);
|
|
6
|
+
var jsxs2 = (type, props, key) => Runtime.jsxs(resolveType(type), props, key);
|
|
7
|
+
|
|
8
|
+
export { Fragment2 as Fragment, jsx2 as jsx, jsxs2 as jsxs };
|
|
9
|
+
//# sourceMappingURL=jsx-runtime.js.map
|
|
10
|
+
//# sourceMappingURL=jsx-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/jsx-runtime.ts"],"names":["Fragment","jsx","jsxs"],"mappings":";;;AAIO,IAAMA,SAAAA,GAA4C,OAAA,CAAA;AAIlD,IAAMC,IAAAA,GAAa,CAAC,IAAA,EAAM,KAAA,EAAO,GAAA,KAAgB,YAAI,WAAA,CAAY,IAAI,CAAA,EAAG,KAAA,EAAO,GAAG;AAClF,IAAMC,KAAAA,GAAc,CAAC,IAAA,EAAM,KAAA,EAAO,GAAA,KAAgB,aAAK,WAAA,CAAY,IAAI,CAAA,EAAG,KAAA,EAAO,GAAG","file":"jsx-runtime.js","sourcesContent":["import * as Runtime from 'react/jsx-runtime';\nimport { resolveType } from './tracker';\n\nexport type { JSX } from 'react/jsx-runtime';\nexport const Fragment: typeof Runtime.Fragment = Runtime.Fragment;\n\ntype JsxFn = typeof Runtime.jsx;\n\nexport const jsx: JsxFn = (type, props, key) => Runtime.jsx(resolveType(type), props, key);\nexport const jsxs: JsxFn = (type, props, key) => Runtime.jsxs(resolveType(type), props, key);\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rerender-lens",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Find avoidable React re-renders. Structured reports, test assertions, and a hook. A modern alternative to why-did-you-render.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react",
|
|
7
|
+
"rerender",
|
|
8
|
+
"re-render",
|
|
9
|
+
"performance",
|
|
10
|
+
"why-did-you-render",
|
|
11
|
+
"memo",
|
|
12
|
+
"debug",
|
|
13
|
+
"devtools"
|
|
14
|
+
],
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"author": "Palanisamy Muthusamy",
|
|
17
|
+
"type": "module",
|
|
18
|
+
"sideEffects": false,
|
|
19
|
+
"main": "./dist/index.cjs",
|
|
20
|
+
"module": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"import": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"default": "./dist/index.js"
|
|
27
|
+
},
|
|
28
|
+
"require": {
|
|
29
|
+
"types": "./dist/index.d.cts",
|
|
30
|
+
"default": "./dist/index.cjs"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"./jsx-runtime": {
|
|
34
|
+
"import": {
|
|
35
|
+
"types": "./dist/jsx-runtime.d.ts",
|
|
36
|
+
"default": "./dist/jsx-runtime.js"
|
|
37
|
+
},
|
|
38
|
+
"require": {
|
|
39
|
+
"types": "./dist/jsx-runtime.d.cts",
|
|
40
|
+
"default": "./dist/jsx-runtime.cjs"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"./jsx-dev-runtime": {
|
|
44
|
+
"import": {
|
|
45
|
+
"types": "./dist/jsx-dev-runtime.d.ts",
|
|
46
|
+
"default": "./dist/jsx-dev-runtime.js"
|
|
47
|
+
},
|
|
48
|
+
"require": {
|
|
49
|
+
"types": "./dist/jsx-dev-runtime.d.cts",
|
|
50
|
+
"default": "./dist/jsx-dev-runtime.cjs"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"./package.json": "./package.json"
|
|
54
|
+
},
|
|
55
|
+
"files": [
|
|
56
|
+
"dist",
|
|
57
|
+
"README.md",
|
|
58
|
+
"LICENSE",
|
|
59
|
+
"CHANGELOG.md"
|
|
60
|
+
],
|
|
61
|
+
"scripts": {
|
|
62
|
+
"build": "tsup",
|
|
63
|
+
"typecheck": "tsc --noEmit",
|
|
64
|
+
"test": "vitest run",
|
|
65
|
+
"test:watch": "vitest",
|
|
66
|
+
"lint:pkg": "publint && attw --pack . --profile node16",
|
|
67
|
+
"check": "npm run typecheck && npm test && npm run build && npm run lint:pkg",
|
|
68
|
+
"prepublishOnly": "npm run check"
|
|
69
|
+
},
|
|
70
|
+
"peerDependencies": {
|
|
71
|
+
"react": ">=16.8.0"
|
|
72
|
+
},
|
|
73
|
+
"devDependencies": {
|
|
74
|
+
"@arethetypeswrong/cli": "^0.18.5",
|
|
75
|
+
"@types/node": "^26.4.1",
|
|
76
|
+
"@types/react": "^19.2.18",
|
|
77
|
+
"@types/react-dom": "^19.2.7",
|
|
78
|
+
"jsdom": "^29.1.1",
|
|
79
|
+
"publint": "^0.3.24",
|
|
80
|
+
"react": "^19.2.8",
|
|
81
|
+
"react-dom": "^19.2.8",
|
|
82
|
+
"tsup": "^8.5.1",
|
|
83
|
+
"typescript": "^5.9.3",
|
|
84
|
+
"vitest": "^5.0.0"
|
|
85
|
+
},
|
|
86
|
+
"engines": {
|
|
87
|
+
"node": ">=18"
|
|
88
|
+
},
|
|
89
|
+
"publishConfig": {
|
|
90
|
+
"access": "public",
|
|
91
|
+
"provenance": true
|
|
92
|
+
},
|
|
93
|
+
"repository": {
|
|
94
|
+
"type": "git",
|
|
95
|
+
"url": "git+https://github.com/NexaLeaf/rerender-lens.git"
|
|
96
|
+
},
|
|
97
|
+
"homepage": "https://github.com/NexaLeaf/rerender-lens#readme",
|
|
98
|
+
"bugs": {
|
|
99
|
+
"url": "https://github.com/NexaLeaf/rerender-lens/issues"
|
|
100
|
+
}
|
|
101
|
+
}
|