@buoy-gg/image-overlay 7.0.17 → 7.0.19
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/lib/commonjs/imageOverlay/components/ImageOverlayModal.js +379 -332
- package/lib/commonjs/imageOverlay/utils/ImageOverlayController.js +2 -1
- package/lib/commonjs/imageOverlay/utils/devtoolsHook.js +36 -0
- package/lib/commonjs/imageOverlay/utils/fiberScanner.js +7 -6
- package/lib/commonjs/index.js +14 -1
- package/lib/module/imageOverlay/components/ImageOverlayModal.js +378 -332
- package/lib/module/imageOverlay/utils/ImageOverlayController.js +2 -1
- package/lib/module/imageOverlay/utils/devtoolsHook.js +31 -0
- package/lib/module/imageOverlay/utils/fiberScanner.js +7 -6
- package/lib/module/index.js +2 -1
- package/lib/typescript/imageOverlay/components/ImageOverlayModal.d.ts +12 -1
- package/lib/typescript/imageOverlay/components/ImageOverlayModal.d.ts.map +1 -1
- package/lib/typescript/imageOverlay/types/index.d.ts +4 -0
- package/lib/typescript/imageOverlay/types/index.d.ts.map +1 -1
- package/lib/typescript/imageOverlay/utils/ImageOverlayController.d.ts.map +1 -1
- package/lib/typescript/imageOverlay/utils/devtoolsHook.d.ts +21 -0
- package/lib/typescript/imageOverlay/utils/devtoolsHook.d.ts.map +1 -0
- package/lib/typescript/imageOverlay/utils/fiberScanner.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +2 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +8 -3
|
@@ -7,6 +7,7 @@ exports.ImageOverlayController = void 0;
|
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
8
|
var _componentMeasurement = require("./componentMeasurement");
|
|
9
9
|
var _fiberScanner = require("./fiberScanner");
|
|
10
|
+
var _devtoolsHook = require("./devtoolsHook");
|
|
10
11
|
/**
|
|
11
12
|
* Singleton state manager for the image overlay tool.
|
|
12
13
|
* Bridges the modal (controls) and standalone overlay (rendering).
|
|
@@ -89,7 +90,7 @@ async function measureWithFallback(instance, label) {
|
|
|
89
90
|
function startTraceTracking() {
|
|
90
91
|
if (traceUnsubscribe) return; // already tracking
|
|
91
92
|
|
|
92
|
-
const hook =
|
|
93
|
+
const hook = (0, _devtoolsHook.getDevToolsHook)();
|
|
93
94
|
if (!hook) return;
|
|
94
95
|
|
|
95
96
|
// Enable trace updates on all renderers (same as highlight-updates)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getDevToolsHook = getDevToolsHook;
|
|
7
|
+
exports.setDevToolsHookOverride = setDevToolsHookOverride;
|
|
8
|
+
/**
|
|
9
|
+
* Single accessor for the React DevTools global hook.
|
|
10
|
+
*
|
|
11
|
+
* Both the fiber scanner (target discovery) and the controller (auto-track via
|
|
12
|
+
* traceUpdates) reach for `__REACT_DEVTOOLS_GLOBAL_HOOK__`. Routing both through
|
|
13
|
+
* here gives embedded hosts — the docs-site live demo, and any future desktop
|
|
14
|
+
* port — one place to substitute their own hook, so the tool never instruments
|
|
15
|
+
* the host page's React renderer just because someone flipped Auto Track.
|
|
16
|
+
*
|
|
17
|
+
* On device nothing calls setDevToolsHookOverride, so this stays a plain
|
|
18
|
+
* passthrough to the global.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
let hookOverride = null;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Substitute the hook the tool reads. Pass null to fall back to the global.
|
|
25
|
+
* The override only needs the parts the tool actually uses:
|
|
26
|
+
* `getFiberRoots(rendererId)`, and optionally `sub("traceUpdates", fn)` plus
|
|
27
|
+
* `rendererInterfaces` for auto-track.
|
|
28
|
+
*/
|
|
29
|
+
function setDevToolsHookOverride(hook) {
|
|
30
|
+
hookOverride = hook ?? null;
|
|
31
|
+
}
|
|
32
|
+
function getDevToolsHook() {
|
|
33
|
+
if (hookOverride) return hookOverride;
|
|
34
|
+
if (typeof global === "undefined") return null;
|
|
35
|
+
return global.__REACT_DEVTOOLS_GLOBAL_HOOK__ ?? null;
|
|
36
|
+
}
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.scanForImageTargets = scanForImageTargets;
|
|
7
|
+
var _devtoolsHook = require("./devtoolsHook");
|
|
7
8
|
/**
|
|
8
9
|
* Fiber tree scanner for discovering image-overlay targets.
|
|
9
10
|
* Finds components tagged with testID="image-target:LabelName".
|
|
@@ -16,12 +17,8 @@ const IMAGE_TARGET_PREFIX = "image-target:";
|
|
|
16
17
|
// Fiber tag constants (from React internals)
|
|
17
18
|
const HostComponent = 5;
|
|
18
19
|
const OffscreenComponent = 22;
|
|
19
|
-
function getReactDevToolsHook() {
|
|
20
|
-
if (typeof global === "undefined") return null;
|
|
21
|
-
return global.__REACT_DEVTOOLS_GLOBAL_HOOK__ ?? null;
|
|
22
|
-
}
|
|
23
20
|
function getFiberRoots() {
|
|
24
|
-
const hook =
|
|
21
|
+
const hook = (0, _devtoolsHook.getDevToolsHook)();
|
|
25
22
|
if (!hook?.getFiberRoots) return [];
|
|
26
23
|
try {
|
|
27
24
|
const rootsSet = hook.getFiberRoots(1);
|
|
@@ -84,7 +81,11 @@ function scanForImageTargets() {
|
|
|
84
81
|
for (const root of roots) {
|
|
85
82
|
traverseFiberTree(root.current, fiber => {
|
|
86
83
|
if (fiber.tag !== HostComponent) return;
|
|
87
|
-
|
|
84
|
+
|
|
85
|
+
// react-native-web rewrites testID to data-testid before it reaches the
|
|
86
|
+
// host fiber, so read both — otherwise the scanner finds nothing in any
|
|
87
|
+
// RNW-rendered tree (example-web, the docs-site live demo).
|
|
88
|
+
const testID = fiber.memoizedProps?.testID ?? fiber.pendingProps?.testID ?? fiber.memoizedProps?.["data-testid"] ?? fiber.pendingProps?.["data-testid"];
|
|
88
89
|
if (!testID || !testID.startsWith(IMAGE_TARGET_PREFIX)) return;
|
|
89
90
|
const label = testID.slice(IMAGE_TARGET_PREFIX.length);
|
|
90
91
|
if (!label) return;
|
package/lib/commonjs/index.js
CHANGED
|
@@ -21,6 +21,12 @@ Object.defineProperty(exports, "ImageOverlayStandalone", {
|
|
|
21
21
|
return _ImageOverlayStandalone.ImageOverlayStandalone;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
+
Object.defineProperty(exports, "ImageOverlayToolView", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _ImageOverlayModal.ImageOverlayToolView;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
24
30
|
Object.defineProperty(exports, "createImageOverlayTool", {
|
|
25
31
|
enumerable: true,
|
|
26
32
|
get: function () {
|
|
@@ -39,8 +45,15 @@ Object.defineProperty(exports, "scanForImageTargets", {
|
|
|
39
45
|
return _fiberScanner.scanForImageTargets;
|
|
40
46
|
}
|
|
41
47
|
});
|
|
48
|
+
Object.defineProperty(exports, "setDevToolsHookOverride", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () {
|
|
51
|
+
return _devtoolsHook.setDevToolsHookOverride;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
42
54
|
var _preset = require("./preset");
|
|
43
55
|
var _ImageOverlayModal = require("./imageOverlay/components/ImageOverlayModal");
|
|
44
56
|
var _ImageOverlayStandalone = require("./imageOverlay/components/ImageOverlayStandalone");
|
|
45
57
|
var _ImageOverlayController = require("./imageOverlay/utils/ImageOverlayController");
|
|
46
|
-
var _fiberScanner = require("./imageOverlay/utils/fiberScanner");
|
|
58
|
+
var _fiberScanner = require("./imageOverlay/utils/fiberScanner");
|
|
59
|
+
var _devtoolsHook = require("./imageOverlay/utils/devtoolsHook");
|