rerender-lens 0.2.0 → 0.3.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 +69 -0
- package/README.md +146 -5
- package/dist/budget-COBu7jBU.d.cts +64 -0
- package/dist/budget-LkNjGtRc.d.ts +64 -0
- package/dist/cli.cjs +458 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +4 -0
- package/dist/cli.d.ts +4 -0
- package/dist/cli.js +452 -0
- package/dist/cli.js.map +1 -0
- package/dist/devtools-BHGUUo-p.d.ts +244 -0
- package/dist/devtools-DmhWiWcN.d.cts +244 -0
- package/dist/index.cjs +652 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +40 -336
- package/dist/index.d.ts +40 -336
- package/dist/index.js +636 -24
- package/dist/index.js.map +1 -1
- package/dist/notifiers-BGQtWKfX.d.cts +90 -0
- package/dist/notifiers-BjjGSHpp.d.ts +90 -0
- package/dist/playwright.cjs +196 -0
- package/dist/playwright.cjs.map +1 -0
- package/dist/playwright.d.cts +35 -0
- package/dist/playwright.d.ts +35 -0
- package/dist/playwright.js +184 -0
- package/dist/playwright.js.map +1 -0
- package/dist/relay.cjs +166 -0
- package/dist/relay.cjs.map +1 -0
- package/dist/relay.d.cts +41 -0
- package/dist/relay.d.ts +41 -0
- package/dist/relay.js +161 -0
- package/dist/relay.js.map +1 -0
- package/dist/rerender-lens.iife.js +1717 -0
- package/dist/setup.cjs +1510 -0
- package/dist/setup.cjs.map +1 -0
- package/dist/setup.d.cts +2 -0
- package/dist/setup.d.ts +2 -0
- package/dist/setup.js +1508 -0
- package/dist/setup.js.map +1 -0
- package/dist/types-BzUEVkxJ.d.cts +177 -0
- package/dist/types-BzUEVkxJ.d.ts +177 -0
- package/dist/vite.cjs +113 -0
- package/dist/vite.cjs.map +1 -0
- package/dist/vite.d.cts +84 -0
- package/dist/vite.d.ts +84 -0
- package/dist/vite.js +103 -0
- package/dist/vite.js.map +1 -0
- package/dist/vitest-setup.cjs +1299 -0
- package/dist/vitest-setup.cjs.map +1 -0
- package/dist/vitest-setup.d.cts +8 -0
- package/dist/vitest-setup.d.ts +8 -0
- package/dist/vitest-setup.js +1297 -0
- package/dist/vitest-setup.js.map +1 -0
- package/dist/vitest.cjs +1360 -0
- package/dist/vitest.cjs.map +1 -0
- package/dist/vitest.d.cts +52 -0
- package/dist/vitest.d.ts +52 -0
- package/dist/vitest.js +1351 -0
- package/dist/vitest.js.map +1 -0
- package/package.json +84 -4
- package/panel/panel.css +418 -0
- package/panel/panel.html +12 -0
- package/panel/panel.js +3325 -0
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { N as Notifier, O as Options } from './types-BzUEVkxJ.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Fiber-tree inspection. Runs after every React commit via the DevTools global
|
|
5
|
+
* hook, exactly like React DevTools itself. Element types are never touched, so
|
|
6
|
+
* Fast Refresh, memo comparators and component identity all stay intact.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
interface ContextDependency {
|
|
10
|
+
context: {
|
|
11
|
+
displayName?: string;
|
|
12
|
+
_currentValue?: unknown;
|
|
13
|
+
};
|
|
14
|
+
memoizedValue: unknown;
|
|
15
|
+
next: ContextDependency | null;
|
|
16
|
+
}
|
|
17
|
+
interface Fiber {
|
|
18
|
+
tag: number;
|
|
19
|
+
key: unknown;
|
|
20
|
+
type: unknown;
|
|
21
|
+
elementType: unknown;
|
|
22
|
+
stateNode: unknown;
|
|
23
|
+
memoizedProps: Record<string, unknown> | null;
|
|
24
|
+
memoizedState: unknown;
|
|
25
|
+
alternate: Fiber | null;
|
|
26
|
+
child: Fiber | null;
|
|
27
|
+
sibling: Fiber | null;
|
|
28
|
+
return: Fiber | null;
|
|
29
|
+
flags?: number;
|
|
30
|
+
/** React 16 name for `flags`. */
|
|
31
|
+
effectTag?: number;
|
|
32
|
+
dependencies?: {
|
|
33
|
+
firstContext: ContextDependency | null;
|
|
34
|
+
} | null;
|
|
35
|
+
_debugOwner?: {
|
|
36
|
+
type?: unknown;
|
|
37
|
+
name?: string;
|
|
38
|
+
} | null;
|
|
39
|
+
_debugHookTypes?: string[] | null;
|
|
40
|
+
/** React <= 18 with the JSX dev transform. */
|
|
41
|
+
_debugSource?: {
|
|
42
|
+
fileName?: string;
|
|
43
|
+
lineNumber?: number;
|
|
44
|
+
columnNumber?: number;
|
|
45
|
+
} | null;
|
|
46
|
+
/** React 19: an Error captured where the element was created. */
|
|
47
|
+
_debugStack?: {
|
|
48
|
+
stack?: string;
|
|
49
|
+
} | string | null;
|
|
50
|
+
actualDuration?: number;
|
|
51
|
+
}
|
|
52
|
+
interface FiberRoot {
|
|
53
|
+
current: Fiber;
|
|
54
|
+
/** Dev builds with a DevTools hook present: fibers that scheduled the update being committed. */
|
|
55
|
+
memoizedUpdaters?: Set<Fiber>;
|
|
56
|
+
}
|
|
57
|
+
/** What `react-dom` passes to `hook.inject`. */
|
|
58
|
+
interface RendererInfo {
|
|
59
|
+
version?: string;
|
|
60
|
+
/** 1 = development build, 0 = production build. */
|
|
61
|
+
bundleType?: number;
|
|
62
|
+
rendererPackageName?: string;
|
|
63
|
+
}
|
|
64
|
+
interface DevtoolsHook {
|
|
65
|
+
renderers: Map<number, unknown>;
|
|
66
|
+
supportsFiber: boolean;
|
|
67
|
+
inject(renderer: unknown): number;
|
|
68
|
+
onCommitFiberRoot?: (id: number, root: FiberRoot, priority?: unknown, didError?: boolean) => void;
|
|
69
|
+
onCommitFiberUnmount?: (id: number, fiber: Fiber) => void;
|
|
70
|
+
onScheduleFiberRoot?: (id: number, root: FiberRoot, children: unknown) => void;
|
|
71
|
+
onPostCommitFiberRoot?: (id: number, root: FiberRoot) => void;
|
|
72
|
+
isDisabled?: boolean;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Make sure `window.__REACT_DEVTOOLS_GLOBAL_HOOK__` exists. React DOM only looks
|
|
76
|
+
* for it once, when the `react-dom` module is evaluated, so this must run before
|
|
77
|
+
* that unless the React DevTools extension or Fast Refresh already created it.
|
|
78
|
+
*/
|
|
79
|
+
declare function ensureDevtoolsHook(): DevtoolsHook;
|
|
80
|
+
/** The renderers React registered on the hook (version and dev/prod bundle type). */
|
|
81
|
+
declare function getRenderers(): RendererInfo[];
|
|
82
|
+
/** True when every registered React renderer is a production build (names minified, no hook labels). */
|
|
83
|
+
declare function isProductionReact(): boolean;
|
|
84
|
+
|
|
85
|
+
declare const DEVTOOLS_MARKER: "__rerenderLens";
|
|
86
|
+
/** Bumped when the message shape or bridge API changes in a way the panel must know about. */
|
|
87
|
+
declare const PROTOCOL_VERSION = 2;
|
|
88
|
+
interface DevtoolsMessage {
|
|
89
|
+
[DEVTOOLS_MARKER]: true;
|
|
90
|
+
version: number;
|
|
91
|
+
type: 'report' | 'clear' | 'hello';
|
|
92
|
+
payload?: unknown;
|
|
93
|
+
}
|
|
94
|
+
/** Payload of a `hello` message. */
|
|
95
|
+
interface HelloPayload {
|
|
96
|
+
/** Buffered reports available for `replay()` / `pull()`. */
|
|
97
|
+
count: number;
|
|
98
|
+
/** Library version. */
|
|
99
|
+
library: string;
|
|
100
|
+
protocol: number;
|
|
101
|
+
react: RendererInfo[];
|
|
102
|
+
/** True when every React renderer on the page is a production build. */
|
|
103
|
+
production: boolean;
|
|
104
|
+
enabled: boolean;
|
|
105
|
+
options: SerializableOptions;
|
|
106
|
+
/** Who created this bridge: the page's own `init` call, or the extension's injected copy. */
|
|
107
|
+
source: 'page' | 'extension';
|
|
108
|
+
/** True when the extension injected a copy of the library into this page (whether or not it is the active one). */
|
|
109
|
+
injected: boolean;
|
|
110
|
+
/** Roots React scheduled (dev builds) and commits observed since `init`; the gap is work that never committed. */
|
|
111
|
+
scheduled: number;
|
|
112
|
+
commits: number;
|
|
113
|
+
/** The library's own cost: total and worst-case time spent inspecting commits, in ms. */
|
|
114
|
+
overhead: {
|
|
115
|
+
totalMs: number;
|
|
116
|
+
maxCommitMs: number;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/** Command sent by a panel over the BroadcastChannel; answered with a `ChannelReply` of the same id. */
|
|
120
|
+
interface ChannelCommand {
|
|
121
|
+
__rerenderLensCmd: true;
|
|
122
|
+
id: string;
|
|
123
|
+
cmd: 'info' | 'pull' | 'replay' | 'clear' | 'configure' | 'highlight' | 'flash';
|
|
124
|
+
arg?: unknown;
|
|
125
|
+
}
|
|
126
|
+
interface ChannelReply {
|
|
127
|
+
__rerenderLensReply: true;
|
|
128
|
+
id: string;
|
|
129
|
+
result?: unknown;
|
|
130
|
+
error?: string;
|
|
131
|
+
}
|
|
132
|
+
/** Default channel name for `createDevtoolsNotifier({ channel: true })` and the panel served by the Vite plugin. */
|
|
133
|
+
declare const DEFAULT_CHANNEL = "rerender-lens";
|
|
134
|
+
declare global {
|
|
135
|
+
interface Window {
|
|
136
|
+
/** Set by the extension's inject script: version of the injected library. */
|
|
137
|
+
__RERENDER_LENS_INJECTED__?: string;
|
|
138
|
+
/** Relay URL (`npx rerender-lens panel`) picked up by `createDevtoolsNotifier` when no `relay` option is given. */
|
|
139
|
+
__RERENDER_LENS_RELAY__?: string;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/** `Options` with matchers as strings (`"Name"` or `"/regex/flags"`) and no functions. */
|
|
143
|
+
interface SerializableOptions {
|
|
144
|
+
trackAllMemoized?: boolean;
|
|
145
|
+
trackAllComponents?: boolean;
|
|
146
|
+
include?: string[];
|
|
147
|
+
exclude?: string[];
|
|
148
|
+
trackHooks?: boolean;
|
|
149
|
+
includeState?: boolean;
|
|
150
|
+
resolveHookNames?: boolean;
|
|
151
|
+
logAll?: boolean;
|
|
152
|
+
silent?: boolean;
|
|
153
|
+
collapse?: boolean;
|
|
154
|
+
ignoreHotReload?: boolean;
|
|
155
|
+
maxReportsPerComponent?: number;
|
|
156
|
+
}
|
|
157
|
+
interface DevtoolsNotifierOptions {
|
|
158
|
+
/** How many reports to keep for `replay()`. Default 300. */
|
|
159
|
+
bufferSize?: number;
|
|
160
|
+
/** Where to post. Default `window`. */
|
|
161
|
+
target?: Pick<Window, 'postMessage'>;
|
|
162
|
+
/** Max serialization depth. Default 6. */
|
|
163
|
+
maxDepth?: number;
|
|
164
|
+
/** Flash the DOM of components that re-rendered avoidably. Default false; toggle later with `flashAvoidable`. */
|
|
165
|
+
flashAvoidable?: boolean;
|
|
166
|
+
/** Reported in `info()`. The extension's inject script passes `'extension'`. Default `'page'`. */
|
|
167
|
+
source?: 'page' | 'extension';
|
|
168
|
+
/**
|
|
169
|
+
* Also publish on a `BroadcastChannel`, so a panel in another same-origin tab (the one the Vite plugin
|
|
170
|
+
* serves at `/__rerender-lens/`) receives reports and can send commands. `true` uses `DEFAULT_CHANNEL`.
|
|
171
|
+
* Off by default.
|
|
172
|
+
*/
|
|
173
|
+
channel?: boolean | string;
|
|
174
|
+
/**
|
|
175
|
+
* Forward everything to a relay started with `npx rerender-lens panel` (its URL), so the panel works for
|
|
176
|
+
* any app on any origin. Also read from `window.__RERENDER_LENS_RELAY__` when set before the app loads.
|
|
177
|
+
*/
|
|
178
|
+
relay?: string;
|
|
179
|
+
/** `EventSource` implementation for the relay (tests, Node). Default: the global one. */
|
|
180
|
+
eventSource?: EventSourceCtor;
|
|
181
|
+
}
|
|
182
|
+
/** The subset of `EventSource` the relay client needs. */
|
|
183
|
+
interface EventSourceLike {
|
|
184
|
+
onmessage: ((event: {
|
|
185
|
+
data: string;
|
|
186
|
+
}) => void) | null;
|
|
187
|
+
onerror: ((event: unknown) => void) | null;
|
|
188
|
+
close(): void;
|
|
189
|
+
}
|
|
190
|
+
type EventSourceCtor = new (url: string) => EventSourceLike;
|
|
191
|
+
interface InspectResult {
|
|
192
|
+
component: string;
|
|
193
|
+
instanceId: number | null;
|
|
194
|
+
tracked: boolean;
|
|
195
|
+
path: string[];
|
|
196
|
+
/** Serialized reports for this instance, oldest first. */
|
|
197
|
+
reports: unknown[];
|
|
198
|
+
}
|
|
199
|
+
interface PullResult {
|
|
200
|
+
/** Sequence number of the newest report included; pass it back as `since`. */
|
|
201
|
+
seq: number;
|
|
202
|
+
reports: unknown[];
|
|
203
|
+
/** True when the caller missed reports that fell out of the buffer. */
|
|
204
|
+
dropped: boolean;
|
|
205
|
+
}
|
|
206
|
+
interface DevtoolsBridge {
|
|
207
|
+
/** Re-post every buffered report (a panel that opened late calls this). */
|
|
208
|
+
replay(): void;
|
|
209
|
+
clear(): void;
|
|
210
|
+
readonly size: number;
|
|
211
|
+
readonly version: number;
|
|
212
|
+
/** Library version. */
|
|
213
|
+
readonly library: string;
|
|
214
|
+
/** Everything the panel shows in its status line. */
|
|
215
|
+
info(): HelloPayload;
|
|
216
|
+
/** Reports newer than `since`. Lets a panel poll without any content script. */
|
|
217
|
+
pull(since?: number): PullResult;
|
|
218
|
+
/** Merge options at runtime; matchers are strings (`"/^Grid/"` becomes a RegExp). */
|
|
219
|
+
configure(options: SerializableOptions): SerializableOptions;
|
|
220
|
+
getOptions(): SerializableOptions;
|
|
221
|
+
/** Outline the DOM of an instance in the page; `null` clears. */
|
|
222
|
+
highlight(instanceId: number | null): boolean;
|
|
223
|
+
/** Turn the avoidable-render flash on or off. */
|
|
224
|
+
flashAvoidable(on: boolean): void;
|
|
225
|
+
/** Re-render details for a DOM node (DevTools' `$0`). */
|
|
226
|
+
inspect(node: unknown): InspectResult | null;
|
|
227
|
+
}
|
|
228
|
+
declare global {
|
|
229
|
+
interface Window {
|
|
230
|
+
__RERENDER_LENS_DEVTOOLS__?: DevtoolsBridge;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/** Convert a report into a structured-clone-safe value (functions, elements, cycles removed). */
|
|
234
|
+
declare function serialize(value: unknown, maxDepth?: number, seen?: WeakSet<object>, depth?: number): unknown;
|
|
235
|
+
/** The current options in a JSON-safe form (function matchers and custom consoles are dropped). */
|
|
236
|
+
declare function serializeOptions(o: Options): SerializableOptions;
|
|
237
|
+
declare function deserializeOptions(o: SerializableOptions): Options;
|
|
238
|
+
/**
|
|
239
|
+
* A notifier that posts every report on `window` for a DevTools extension to pick up.
|
|
240
|
+
* Also installs `window.__RERENDER_LENS_DEVTOOLS__` with `replay()` / `clear()` / `pull()` and friends.
|
|
241
|
+
*/
|
|
242
|
+
declare function createDevtoolsNotifier(options?: DevtoolsNotifierOptions): Notifier;
|
|
243
|
+
|
|
244
|
+
export { type ChannelCommand as C, DEFAULT_CHANNEL as D, type Fiber as F, type HelloPayload as H, type InspectResult as I, PROTOCOL_VERSION as P, type RendererInfo as R, type SerializableOptions as S, type ChannelReply as a, DEVTOOLS_MARKER as b, type DevtoolsBridge as c, type DevtoolsMessage as d, type DevtoolsNotifierOptions as e, type PullResult as f, createDevtoolsNotifier as g, deserializeOptions as h, ensureDevtoolsHook as i, getRenderers as j, isProductionReact as k, serializeOptions as l, serialize as s };
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { N as Notifier, O as Options } from './types-BzUEVkxJ.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Fiber-tree inspection. Runs after every React commit via the DevTools global
|
|
5
|
+
* hook, exactly like React DevTools itself. Element types are never touched, so
|
|
6
|
+
* Fast Refresh, memo comparators and component identity all stay intact.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
interface ContextDependency {
|
|
10
|
+
context: {
|
|
11
|
+
displayName?: string;
|
|
12
|
+
_currentValue?: unknown;
|
|
13
|
+
};
|
|
14
|
+
memoizedValue: unknown;
|
|
15
|
+
next: ContextDependency | null;
|
|
16
|
+
}
|
|
17
|
+
interface Fiber {
|
|
18
|
+
tag: number;
|
|
19
|
+
key: unknown;
|
|
20
|
+
type: unknown;
|
|
21
|
+
elementType: unknown;
|
|
22
|
+
stateNode: unknown;
|
|
23
|
+
memoizedProps: Record<string, unknown> | null;
|
|
24
|
+
memoizedState: unknown;
|
|
25
|
+
alternate: Fiber | null;
|
|
26
|
+
child: Fiber | null;
|
|
27
|
+
sibling: Fiber | null;
|
|
28
|
+
return: Fiber | null;
|
|
29
|
+
flags?: number;
|
|
30
|
+
/** React 16 name for `flags`. */
|
|
31
|
+
effectTag?: number;
|
|
32
|
+
dependencies?: {
|
|
33
|
+
firstContext: ContextDependency | null;
|
|
34
|
+
} | null;
|
|
35
|
+
_debugOwner?: {
|
|
36
|
+
type?: unknown;
|
|
37
|
+
name?: string;
|
|
38
|
+
} | null;
|
|
39
|
+
_debugHookTypes?: string[] | null;
|
|
40
|
+
/** React <= 18 with the JSX dev transform. */
|
|
41
|
+
_debugSource?: {
|
|
42
|
+
fileName?: string;
|
|
43
|
+
lineNumber?: number;
|
|
44
|
+
columnNumber?: number;
|
|
45
|
+
} | null;
|
|
46
|
+
/** React 19: an Error captured where the element was created. */
|
|
47
|
+
_debugStack?: {
|
|
48
|
+
stack?: string;
|
|
49
|
+
} | string | null;
|
|
50
|
+
actualDuration?: number;
|
|
51
|
+
}
|
|
52
|
+
interface FiberRoot {
|
|
53
|
+
current: Fiber;
|
|
54
|
+
/** Dev builds with a DevTools hook present: fibers that scheduled the update being committed. */
|
|
55
|
+
memoizedUpdaters?: Set<Fiber>;
|
|
56
|
+
}
|
|
57
|
+
/** What `react-dom` passes to `hook.inject`. */
|
|
58
|
+
interface RendererInfo {
|
|
59
|
+
version?: string;
|
|
60
|
+
/** 1 = development build, 0 = production build. */
|
|
61
|
+
bundleType?: number;
|
|
62
|
+
rendererPackageName?: string;
|
|
63
|
+
}
|
|
64
|
+
interface DevtoolsHook {
|
|
65
|
+
renderers: Map<number, unknown>;
|
|
66
|
+
supportsFiber: boolean;
|
|
67
|
+
inject(renderer: unknown): number;
|
|
68
|
+
onCommitFiberRoot?: (id: number, root: FiberRoot, priority?: unknown, didError?: boolean) => void;
|
|
69
|
+
onCommitFiberUnmount?: (id: number, fiber: Fiber) => void;
|
|
70
|
+
onScheduleFiberRoot?: (id: number, root: FiberRoot, children: unknown) => void;
|
|
71
|
+
onPostCommitFiberRoot?: (id: number, root: FiberRoot) => void;
|
|
72
|
+
isDisabled?: boolean;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Make sure `window.__REACT_DEVTOOLS_GLOBAL_HOOK__` exists. React DOM only looks
|
|
76
|
+
* for it once, when the `react-dom` module is evaluated, so this must run before
|
|
77
|
+
* that unless the React DevTools extension or Fast Refresh already created it.
|
|
78
|
+
*/
|
|
79
|
+
declare function ensureDevtoolsHook(): DevtoolsHook;
|
|
80
|
+
/** The renderers React registered on the hook (version and dev/prod bundle type). */
|
|
81
|
+
declare function getRenderers(): RendererInfo[];
|
|
82
|
+
/** True when every registered React renderer is a production build (names minified, no hook labels). */
|
|
83
|
+
declare function isProductionReact(): boolean;
|
|
84
|
+
|
|
85
|
+
declare const DEVTOOLS_MARKER: "__rerenderLens";
|
|
86
|
+
/** Bumped when the message shape or bridge API changes in a way the panel must know about. */
|
|
87
|
+
declare const PROTOCOL_VERSION = 2;
|
|
88
|
+
interface DevtoolsMessage {
|
|
89
|
+
[DEVTOOLS_MARKER]: true;
|
|
90
|
+
version: number;
|
|
91
|
+
type: 'report' | 'clear' | 'hello';
|
|
92
|
+
payload?: unknown;
|
|
93
|
+
}
|
|
94
|
+
/** Payload of a `hello` message. */
|
|
95
|
+
interface HelloPayload {
|
|
96
|
+
/** Buffered reports available for `replay()` / `pull()`. */
|
|
97
|
+
count: number;
|
|
98
|
+
/** Library version. */
|
|
99
|
+
library: string;
|
|
100
|
+
protocol: number;
|
|
101
|
+
react: RendererInfo[];
|
|
102
|
+
/** True when every React renderer on the page is a production build. */
|
|
103
|
+
production: boolean;
|
|
104
|
+
enabled: boolean;
|
|
105
|
+
options: SerializableOptions;
|
|
106
|
+
/** Who created this bridge: the page's own `init` call, or the extension's injected copy. */
|
|
107
|
+
source: 'page' | 'extension';
|
|
108
|
+
/** True when the extension injected a copy of the library into this page (whether or not it is the active one). */
|
|
109
|
+
injected: boolean;
|
|
110
|
+
/** Roots React scheduled (dev builds) and commits observed since `init`; the gap is work that never committed. */
|
|
111
|
+
scheduled: number;
|
|
112
|
+
commits: number;
|
|
113
|
+
/** The library's own cost: total and worst-case time spent inspecting commits, in ms. */
|
|
114
|
+
overhead: {
|
|
115
|
+
totalMs: number;
|
|
116
|
+
maxCommitMs: number;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/** Command sent by a panel over the BroadcastChannel; answered with a `ChannelReply` of the same id. */
|
|
120
|
+
interface ChannelCommand {
|
|
121
|
+
__rerenderLensCmd: true;
|
|
122
|
+
id: string;
|
|
123
|
+
cmd: 'info' | 'pull' | 'replay' | 'clear' | 'configure' | 'highlight' | 'flash';
|
|
124
|
+
arg?: unknown;
|
|
125
|
+
}
|
|
126
|
+
interface ChannelReply {
|
|
127
|
+
__rerenderLensReply: true;
|
|
128
|
+
id: string;
|
|
129
|
+
result?: unknown;
|
|
130
|
+
error?: string;
|
|
131
|
+
}
|
|
132
|
+
/** Default channel name for `createDevtoolsNotifier({ channel: true })` and the panel served by the Vite plugin. */
|
|
133
|
+
declare const DEFAULT_CHANNEL = "rerender-lens";
|
|
134
|
+
declare global {
|
|
135
|
+
interface Window {
|
|
136
|
+
/** Set by the extension's inject script: version of the injected library. */
|
|
137
|
+
__RERENDER_LENS_INJECTED__?: string;
|
|
138
|
+
/** Relay URL (`npx rerender-lens panel`) picked up by `createDevtoolsNotifier` when no `relay` option is given. */
|
|
139
|
+
__RERENDER_LENS_RELAY__?: string;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/** `Options` with matchers as strings (`"Name"` or `"/regex/flags"`) and no functions. */
|
|
143
|
+
interface SerializableOptions {
|
|
144
|
+
trackAllMemoized?: boolean;
|
|
145
|
+
trackAllComponents?: boolean;
|
|
146
|
+
include?: string[];
|
|
147
|
+
exclude?: string[];
|
|
148
|
+
trackHooks?: boolean;
|
|
149
|
+
includeState?: boolean;
|
|
150
|
+
resolveHookNames?: boolean;
|
|
151
|
+
logAll?: boolean;
|
|
152
|
+
silent?: boolean;
|
|
153
|
+
collapse?: boolean;
|
|
154
|
+
ignoreHotReload?: boolean;
|
|
155
|
+
maxReportsPerComponent?: number;
|
|
156
|
+
}
|
|
157
|
+
interface DevtoolsNotifierOptions {
|
|
158
|
+
/** How many reports to keep for `replay()`. Default 300. */
|
|
159
|
+
bufferSize?: number;
|
|
160
|
+
/** Where to post. Default `window`. */
|
|
161
|
+
target?: Pick<Window, 'postMessage'>;
|
|
162
|
+
/** Max serialization depth. Default 6. */
|
|
163
|
+
maxDepth?: number;
|
|
164
|
+
/** Flash the DOM of components that re-rendered avoidably. Default false; toggle later with `flashAvoidable`. */
|
|
165
|
+
flashAvoidable?: boolean;
|
|
166
|
+
/** Reported in `info()`. The extension's inject script passes `'extension'`. Default `'page'`. */
|
|
167
|
+
source?: 'page' | 'extension';
|
|
168
|
+
/**
|
|
169
|
+
* Also publish on a `BroadcastChannel`, so a panel in another same-origin tab (the one the Vite plugin
|
|
170
|
+
* serves at `/__rerender-lens/`) receives reports and can send commands. `true` uses `DEFAULT_CHANNEL`.
|
|
171
|
+
* Off by default.
|
|
172
|
+
*/
|
|
173
|
+
channel?: boolean | string;
|
|
174
|
+
/**
|
|
175
|
+
* Forward everything to a relay started with `npx rerender-lens panel` (its URL), so the panel works for
|
|
176
|
+
* any app on any origin. Also read from `window.__RERENDER_LENS_RELAY__` when set before the app loads.
|
|
177
|
+
*/
|
|
178
|
+
relay?: string;
|
|
179
|
+
/** `EventSource` implementation for the relay (tests, Node). Default: the global one. */
|
|
180
|
+
eventSource?: EventSourceCtor;
|
|
181
|
+
}
|
|
182
|
+
/** The subset of `EventSource` the relay client needs. */
|
|
183
|
+
interface EventSourceLike {
|
|
184
|
+
onmessage: ((event: {
|
|
185
|
+
data: string;
|
|
186
|
+
}) => void) | null;
|
|
187
|
+
onerror: ((event: unknown) => void) | null;
|
|
188
|
+
close(): void;
|
|
189
|
+
}
|
|
190
|
+
type EventSourceCtor = new (url: string) => EventSourceLike;
|
|
191
|
+
interface InspectResult {
|
|
192
|
+
component: string;
|
|
193
|
+
instanceId: number | null;
|
|
194
|
+
tracked: boolean;
|
|
195
|
+
path: string[];
|
|
196
|
+
/** Serialized reports for this instance, oldest first. */
|
|
197
|
+
reports: unknown[];
|
|
198
|
+
}
|
|
199
|
+
interface PullResult {
|
|
200
|
+
/** Sequence number of the newest report included; pass it back as `since`. */
|
|
201
|
+
seq: number;
|
|
202
|
+
reports: unknown[];
|
|
203
|
+
/** True when the caller missed reports that fell out of the buffer. */
|
|
204
|
+
dropped: boolean;
|
|
205
|
+
}
|
|
206
|
+
interface DevtoolsBridge {
|
|
207
|
+
/** Re-post every buffered report (a panel that opened late calls this). */
|
|
208
|
+
replay(): void;
|
|
209
|
+
clear(): void;
|
|
210
|
+
readonly size: number;
|
|
211
|
+
readonly version: number;
|
|
212
|
+
/** Library version. */
|
|
213
|
+
readonly library: string;
|
|
214
|
+
/** Everything the panel shows in its status line. */
|
|
215
|
+
info(): HelloPayload;
|
|
216
|
+
/** Reports newer than `since`. Lets a panel poll without any content script. */
|
|
217
|
+
pull(since?: number): PullResult;
|
|
218
|
+
/** Merge options at runtime; matchers are strings (`"/^Grid/"` becomes a RegExp). */
|
|
219
|
+
configure(options: SerializableOptions): SerializableOptions;
|
|
220
|
+
getOptions(): SerializableOptions;
|
|
221
|
+
/** Outline the DOM of an instance in the page; `null` clears. */
|
|
222
|
+
highlight(instanceId: number | null): boolean;
|
|
223
|
+
/** Turn the avoidable-render flash on or off. */
|
|
224
|
+
flashAvoidable(on: boolean): void;
|
|
225
|
+
/** Re-render details for a DOM node (DevTools' `$0`). */
|
|
226
|
+
inspect(node: unknown): InspectResult | null;
|
|
227
|
+
}
|
|
228
|
+
declare global {
|
|
229
|
+
interface Window {
|
|
230
|
+
__RERENDER_LENS_DEVTOOLS__?: DevtoolsBridge;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/** Convert a report into a structured-clone-safe value (functions, elements, cycles removed). */
|
|
234
|
+
declare function serialize(value: unknown, maxDepth?: number, seen?: WeakSet<object>, depth?: number): unknown;
|
|
235
|
+
/** The current options in a JSON-safe form (function matchers and custom consoles are dropped). */
|
|
236
|
+
declare function serializeOptions(o: Options): SerializableOptions;
|
|
237
|
+
declare function deserializeOptions(o: SerializableOptions): Options;
|
|
238
|
+
/**
|
|
239
|
+
* A notifier that posts every report on `window` for a DevTools extension to pick up.
|
|
240
|
+
* Also installs `window.__RERENDER_LENS_DEVTOOLS__` with `replay()` / `clear()` / `pull()` and friends.
|
|
241
|
+
*/
|
|
242
|
+
declare function createDevtoolsNotifier(options?: DevtoolsNotifierOptions): Notifier;
|
|
243
|
+
|
|
244
|
+
export { type ChannelCommand as C, DEFAULT_CHANNEL as D, type Fiber as F, type HelloPayload as H, type InspectResult as I, PROTOCOL_VERSION as P, type RendererInfo as R, type SerializableOptions as S, type ChannelReply as a, DEVTOOLS_MARKER as b, type DevtoolsBridge as c, type DevtoolsMessage as d, type DevtoolsNotifierOptions as e, type PullResult as f, createDevtoolsNotifier as g, deserializeOptions as h, ensureDevtoolsHook as i, getRenderers as j, isProductionReact as k, serializeOptions as l, serialize as s };
|