@reticlehq/react 2.3.0 → 2.4.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.js +25 -6
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import { registerAdapter } from '@reticlehq/browser';
|
|
2
|
-
import { ComponentStateReason, DATA_RETICLE_SOURCE_ATTR, } from '@reticlehq/core';
|
|
2
|
+
import { ComponentStateReason, DATA_RETICLE_SOURCE_ATTR, RETICLE_ROOT_GLOBAL, } from '@reticlehq/core';
|
|
3
|
+
/**
|
|
4
|
+
* React's `_debugSource.fileName` is ABSOLUTE; the babel stamp is repo-relative. Both surface to the
|
|
5
|
+
* agent as `source`, so the same product emitted two path shapes depending on which React version an
|
|
6
|
+
* app was on — and `/Users/someone/tmp/wt/apps/x/src/A.tsx` is noise in a report, not a pointer.
|
|
7
|
+
* The build plugins define the root; without one we return the path unchanged rather than guessing.
|
|
8
|
+
*/
|
|
9
|
+
function relativeToRoot(file) {
|
|
10
|
+
const root = globalThis[RETICLE_ROOT_GLOBAL];
|
|
11
|
+
if (typeof root !== 'string' || root.length === 0)
|
|
12
|
+
return file;
|
|
13
|
+
const prefix = root.endsWith('/') ? root : `${root}/`;
|
|
14
|
+
return file.startsWith(prefix) ? file.slice(prefix.length) : file;
|
|
15
|
+
}
|
|
3
16
|
const FIBER_PREFIXES = ['__reactFiber$', '__reactInternalInstance$'];
|
|
4
17
|
const MAX_DEPTH = 200;
|
|
5
18
|
const MAX_HOOKS = 100;
|
|
@@ -56,11 +69,17 @@ export function identify(el) {
|
|
|
56
69
|
if (!isFrameworkNoise(name) && stack[stack.length - 1] !== name)
|
|
57
70
|
stack.push(name);
|
|
58
71
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
72
|
+
// `identify()` is on the ACT path as well as the inspect path, so one null fiber anywhere in
|
|
73
|
+
// this walk used to take out reticle_act / reticle_act_and_wait / reticle_inspect for the whole
|
|
74
|
+
// app: the read-only tools kept working, so the agent could see the app perfectly and could not
|
|
75
|
+
// touch it. The throw also pre-empted the React 19 attribute fallback below, which would have
|
|
76
|
+
// produced the source anyway.
|
|
77
|
+
const debugSource = fiber._debugSource;
|
|
78
|
+
if (source === undefined && debugSource !== undefined && debugSource !== null) {
|
|
79
|
+
source = { file: relativeToRoot(debugSource.fileName), line: debugSource.lineNumber };
|
|
80
|
+
const column = debugSource.columnNumber;
|
|
81
|
+
if (column !== undefined && column !== null)
|
|
82
|
+
source.column = column;
|
|
64
83
|
}
|
|
65
84
|
fiber = fiber.return;
|
|
66
85
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reticlehq/react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.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",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@reticlehq/browser": "2.
|
|
20
|
-
"@reticlehq/core": "2.
|
|
19
|
+
"@reticlehq/browser": "2.4.0",
|
|
20
|
+
"@reticlehq/core": "2.4.0"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"react": ">=18"
|