@reticlehq/react 3.8.1 → 3.9.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/dist/index.d.ts +23 -1
- package/dist/index.js +2 -2
- package/dist/render-meter.d.ts +11 -1
- package/dist/render-meter.js +13 -2
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,28 @@ export declare function readState(el: Element): ComponentStateResult;
|
|
|
28
28
|
* Fail soft: an unexpected fiber shape returns false.
|
|
29
29
|
*/
|
|
30
30
|
export declare function hasHoverHandlers(el: Element): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Options for {@link install}.
|
|
33
|
+
*/
|
|
34
|
+
export interface InstallOptions {
|
|
35
|
+
/**
|
|
36
|
+
* When `true` (the default), `install` automatically registers stores it finds in the React
|
|
37
|
+
* fiber tree — Redux `Provider`, TanStack `QueryClientProvider`, and similar context providers.
|
|
38
|
+
* The discovery runs over the first ten React commits so that late-mounting providers
|
|
39
|
+
* (lazy routes, effects) are also found.
|
|
40
|
+
*
|
|
41
|
+
* Set to `false` to skip auto-discovery entirely. Use this when your app holds more than one
|
|
42
|
+
* context provider and you want to expose only the stores you name explicitly with
|
|
43
|
+
* `registerStore`. The render meter still runs with this option set to `false`.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* install({ discoverStores: false });
|
|
48
|
+
* registerStore('safe', safeStore);
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
discoverStores?: boolean;
|
|
52
|
+
}
|
|
31
53
|
/**
|
|
32
54
|
* Wire up React support: the adapter for `reticle.inspect`, and the render meter.
|
|
33
55
|
*
|
|
@@ -37,7 +59,7 @@ export declare function hasHoverHandlers(el: Element): boolean;
|
|
|
37
59
|
* for a documented capability is how a feature ships dead — an agent asking for render counts gets
|
|
38
60
|
* silence, indistinguishable from an idle page.
|
|
39
61
|
*/
|
|
40
|
-
export declare function install(): void;
|
|
62
|
+
export declare function install(options?: InstallOptions): void;
|
|
41
63
|
export { installRenderMeter, resetRenderMeter, getRenderStats, type RenderStats, } from './render-meter.js';
|
|
42
64
|
export { HYDRATION_COMPLETE_SIGNAL, createHydrationTracker, type HydrationTracker, } from './hydration.js';
|
|
43
65
|
export { buildErrorBoundaryData, reticleOnCaughtError, type ErrorBoundaryData, } from './error-boundary.js';
|
package/dist/index.js
CHANGED
|
@@ -288,12 +288,12 @@ let installed = false;
|
|
|
288
288
|
* for a documented capability is how a feature ships dead — an agent asking for render counts gets
|
|
289
289
|
* silence, indistinguishable from an idle page.
|
|
290
290
|
*/
|
|
291
|
-
export function install() {
|
|
291
|
+
export function install(options) {
|
|
292
292
|
if (installed)
|
|
293
293
|
return;
|
|
294
294
|
installed = true;
|
|
295
295
|
registerAdapter({ name: 'react', identify, readState, hasHoverHandlers });
|
|
296
|
-
installRenderMeter();
|
|
296
|
+
installRenderMeter({ discoverStores: false !== options?.discoverStores });
|
|
297
297
|
}
|
|
298
298
|
export { installRenderMeter, resetRenderMeter, getRenderStats, } from './render-meter.js';
|
|
299
299
|
export { HYDRATION_COMPLETE_SIGNAL, createHydrationTracker, } from './hydration.js';
|
package/dist/render-meter.d.ts
CHANGED
|
@@ -6,8 +6,18 @@ export interface RenderStats {
|
|
|
6
6
|
export declare function getRenderStats(): RenderStats;
|
|
7
7
|
/** Reset the commit counter — call before a measured window so the count is window-scoped. */
|
|
8
8
|
export declare function resetRenderMeter(): void;
|
|
9
|
+
/** Options for {@link installRenderMeter}. */
|
|
10
|
+
export interface RenderMeterOptions {
|
|
11
|
+
/**
|
|
12
|
+
* When true (default), walk the React fiber tree after early commits and auto-register
|
|
13
|
+
* discovered stores. When false, skip auto-discovery entirely.
|
|
14
|
+
*/
|
|
15
|
+
discoverStores?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** Reset internal state for test isolation. */
|
|
18
|
+
export declare function resetRenderMeterForTest(): void;
|
|
9
19
|
/**
|
|
10
20
|
* Install (or augment) the React commit hook + register the `__reticle_renders` store. Idempotent and
|
|
11
21
|
* never throws. Call BEFORE react-dom loads.
|
|
12
22
|
*/
|
|
13
|
-
export declare function installRenderMeter(): void;
|
|
23
|
+
export declare function installRenderMeter(options?: RenderMeterOptions): void;
|
package/dist/render-meter.js
CHANGED
|
@@ -62,12 +62,13 @@ const DISCOVERY_COMMITS = 10;
|
|
|
62
62
|
* ran would have got none at all.
|
|
63
63
|
*/
|
|
64
64
|
let discoveryAttempts = 0;
|
|
65
|
+
let shouldDiscover = true;
|
|
65
66
|
/** One React commit: bump the counter, fire hydration on the first, and feed the throttled stream. */
|
|
66
67
|
function onReactCommit() {
|
|
67
68
|
commits += 1;
|
|
68
69
|
hydration.onCommit();
|
|
69
70
|
commitStream.onCommit();
|
|
70
|
-
if (discoveryAttempts < DISCOVERY_COMMITS && 'undefined' !== typeof document) {
|
|
71
|
+
if (shouldDiscover && discoveryAttempts < DISCOVERY_COMMITS && 'undefined' !== typeof document) {
|
|
71
72
|
discoveryAttempts += 1;
|
|
72
73
|
// Never allowed to break a render: this runs inside React's own commit callback.
|
|
73
74
|
try {
|
|
@@ -101,14 +102,24 @@ export function getRenderStats() {
|
|
|
101
102
|
export function resetRenderMeter() {
|
|
102
103
|
commits = 0;
|
|
103
104
|
}
|
|
105
|
+
/** Reset internal state for test isolation. */
|
|
106
|
+
export function resetRenderMeterForTest() {
|
|
107
|
+
installed = false;
|
|
108
|
+
shouldDiscover = true;
|
|
109
|
+
discoveryAttempts = 0;
|
|
110
|
+
commits = 0;
|
|
111
|
+
}
|
|
104
112
|
/**
|
|
105
113
|
* Install (or augment) the React commit hook + register the `__reticle_renders` store. Idempotent and
|
|
106
114
|
* never throws. Call BEFORE react-dom loads.
|
|
107
115
|
*/
|
|
108
|
-
export function installRenderMeter() {
|
|
116
|
+
export function installRenderMeter(options) {
|
|
109
117
|
if (installed)
|
|
110
118
|
return;
|
|
111
119
|
installed = true;
|
|
120
|
+
if (false === options?.discoverStores) {
|
|
121
|
+
shouldDiscover = false;
|
|
122
|
+
}
|
|
112
123
|
try {
|
|
113
124
|
const root = globalThis;
|
|
114
125
|
// Adopt the pre-hook if the Vite plugin installed one.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reticlehq/react",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0",
|
|
4
4
|
"description": "Reticle React adapter — maps a DOM ref to its component stack and source file via the fiber tree.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"./package.json": "./package.json"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@reticlehq/browser": "3.
|
|
21
|
-
"@reticlehq/core": "3.
|
|
20
|
+
"@reticlehq/browser": "3.9.0",
|
|
21
|
+
"@reticlehq/core": "3.9.0"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"react": ">=18"
|