execbro 1.11.1 → 2.0.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/README.md +4 -4
- package/build/__tests__/unit/appContext.test.d.ts +2 -0
- package/build/__tests__/unit/appContext.test.d.ts.map +1 -0
- package/build/__tests__/unit/appContext.test.js +70 -0
- package/build/__tests__/unit/appContext.test.js.map +1 -0
- package/build/__tests__/unit/appRequest.test.d.ts +2 -0
- package/build/__tests__/unit/appRequest.test.d.ts.map +1 -0
- package/build/__tests__/unit/appRequest.test.js +179 -0
- package/build/__tests__/unit/appRequest.test.js.map +1 -0
- package/build/__tests__/unit/contextWiring.test.d.ts +2 -0
- package/build/__tests__/unit/contextWiring.test.d.ts.map +1 -0
- package/build/__tests__/unit/contextWiring.test.js +28 -0
- package/build/__tests__/unit/contextWiring.test.js.map +1 -0
- package/build/__tests__/unit/epochRender.test.d.ts +2 -0
- package/build/__tests__/unit/epochRender.test.d.ts.map +1 -0
- package/build/__tests__/unit/epochRender.test.js +60 -0
- package/build/__tests__/unit/epochRender.test.js.map +1 -0
- package/build/__tests__/unit/executeBudget.test.d.ts +2 -0
- package/build/__tests__/unit/executeBudget.test.d.ts.map +1 -0
- package/build/__tests__/unit/executeBudget.test.js +27 -0
- package/build/__tests__/unit/executeBudget.test.js.map +1 -0
- package/build/__tests__/unit/executor.test.js +48 -6
- package/build/__tests__/unit/executor.test.js.map +1 -1
- package/build/__tests__/unit/getLogsEmptyContract.test.js +4 -3
- package/build/__tests__/unit/getLogsEmptyContract.test.js.map +1 -1
- package/build/__tests__/unit/getLogsNativeSource.test.js +7 -8
- package/build/__tests__/unit/getLogsNativeSource.test.js.map +1 -1
- package/build/__tests__/unit/inspectorHarvest.test.js +1 -21
- package/build/__tests__/unit/inspectorHarvest.test.js.map +1 -1
- package/build/__tests__/unit/inspectorSource.test.js +1 -38
- package/build/__tests__/unit/inspectorSource.test.js.map +1 -1
- package/build/__tests__/unit/jsLogEvents.test.js +1 -0
- package/build/__tests__/unit/jsLogEvents.test.js.map +1 -1
- package/build/__tests__/unit/logBufferEpoch.test.d.ts +2 -0
- package/build/__tests__/unit/logBufferEpoch.test.d.ts.map +1 -0
- package/build/__tests__/unit/logBufferEpoch.test.js +63 -0
- package/build/__tests__/unit/logBufferEpoch.test.js.map +1 -0
- package/build/__tests__/unit/metro.test.js +18 -1
- package/build/__tests__/unit/metro.test.js.map +1 -1
- package/build/__tests__/unit/moduleRegistry.test.d.ts +2 -0
- package/build/__tests__/unit/moduleRegistry.test.d.ts.map +1 -0
- package/build/__tests__/unit/moduleRegistry.test.js +62 -0
- package/build/__tests__/unit/moduleRegistry.test.js.map +1 -0
- package/build/__tests__/unit/navigateVerify.test.d.ts +2 -0
- package/build/__tests__/unit/navigateVerify.test.d.ts.map +1 -0
- package/build/__tests__/unit/navigateVerify.test.js +30 -0
- package/build/__tests__/unit/navigateVerify.test.js.map +1 -0
- package/build/__tests__/unit/navigation.test.d.ts +2 -0
- package/build/__tests__/unit/navigation.test.d.ts.map +1 -0
- package/build/__tests__/unit/navigation.test.js +254 -0
- package/build/__tests__/unit/navigation.test.js.map +1 -0
- package/build/__tests__/unit/network.test.js +1 -0
- package/build/__tests__/unit/network.test.js.map +1 -1
- package/build/__tests__/unit/networkBufferEpoch.test.d.ts +2 -0
- package/build/__tests__/unit/networkBufferEpoch.test.d.ts.map +1 -0
- package/build/__tests__/unit/networkBufferEpoch.test.js +52 -0
- package/build/__tests__/unit/networkBufferEpoch.test.js.map +1 -0
- package/build/__tests__/unit/networkInterceptor.test.js +7 -7
- package/build/__tests__/unit/networkInterceptor.test.js.map +1 -1
- package/build/__tests__/unit/promiseHandles.test.d.ts +2 -0
- package/build/__tests__/unit/promiseHandles.test.d.ts.map +1 -0
- package/build/__tests__/unit/promiseHandles.test.js +61 -0
- package/build/__tests__/unit/promiseHandles.test.js.map +1 -0
- package/build/__tests__/unit/resolveBufferOffline.test.d.ts +2 -0
- package/build/__tests__/unit/resolveBufferOffline.test.d.ts.map +1 -0
- package/build/__tests__/unit/resolveBufferOffline.test.js +25 -0
- package/build/__tests__/unit/resolveBufferOffline.test.js.map +1 -0
- package/build/__tests__/unit/sdkMirrorPoller.test.d.ts +2 -0
- package/build/__tests__/unit/sdkMirrorPoller.test.d.ts.map +1 -0
- package/build/__tests__/unit/sdkMirrorPoller.test.js +118 -0
- package/build/__tests__/unit/sdkMirrorPoller.test.js.map +1 -0
- package/build/__tests__/unit/sessionEpoch.test.d.ts +2 -0
- package/build/__tests__/unit/sessionEpoch.test.d.ts.map +1 -0
- package/build/__tests__/unit/sessionEpoch.test.js +41 -0
- package/build/__tests__/unit/sessionEpoch.test.js.map +1 -0
- package/build/__tests__/unit/truncate.test.d.ts +2 -0
- package/build/__tests__/unit/truncate.test.d.ts.map +1 -0
- package/build/__tests__/unit/truncate.test.js +58 -0
- package/build/__tests__/unit/truncate.test.js.map +1 -0
- package/build/core/appContext.d.ts +53 -0
- package/build/core/appContext.d.ts.map +1 -0
- package/build/core/appContext.js +172 -0
- package/build/core/appContext.js.map +1 -0
- package/build/core/appRequest.d.ts +21 -0
- package/build/core/appRequest.d.ts.map +1 -0
- package/build/core/appRequest.js +95 -0
- package/build/core/appRequest.js.map +1 -0
- package/build/core/bufferConfig.d.ts +5 -0
- package/build/core/bufferConfig.d.ts.map +1 -0
- package/build/core/bufferConfig.js +20 -0
- package/build/core/bufferConfig.js.map +1 -0
- package/build/core/connection.d.ts.map +1 -1
- package/build/core/connection.js +29 -9
- package/build/core/connection.js.map +1 -1
- package/build/core/debugGlobals.d.ts.map +1 -1
- package/build/core/debugGlobals.js +13 -0
- package/build/core/debugGlobals.js.map +1 -1
- package/build/core/epochRender.d.ts +19 -0
- package/build/core/epochRender.d.ts.map +1 -0
- package/build/core/epochRender.js +38 -0
- package/build/core/epochRender.js.map +1 -0
- package/build/core/guides.d.ts.map +1 -1
- package/build/core/guides.js +36 -91
- package/build/core/guides.js.map +1 -1
- package/build/core/index.d.ts +2 -3
- package/build/core/index.d.ts.map +1 -1
- package/build/core/index.js +4 -4
- package/build/core/index.js.map +1 -1
- package/build/core/inspector.d.ts +0 -39
- package/build/core/inspector.d.ts.map +1 -1
- package/build/core/inspector.js +1 -358
- package/build/core/inspector.js.map +1 -1
- package/build/core/ios.js +2 -2
- package/build/core/ios.js.map +1 -1
- package/build/core/jsExecute.d.ts +15 -0
- package/build/core/jsExecute.d.ts.map +1 -1
- package/build/core/jsExecute.js +136 -29
- package/build/core/jsExecute.js.map +1 -1
- package/build/core/logs.d.ts +12 -3
- package/build/core/logs.d.ts.map +1 -1
- package/build/core/logs.js +28 -5
- package/build/core/logs.js.map +1 -1
- package/build/core/metro.d.ts +2 -0
- package/build/core/metro.d.ts.map +1 -1
- package/build/core/metro.js +16 -8
- package/build/core/metro.js.map +1 -1
- package/build/core/moduleRegistry.d.ts +19 -0
- package/build/core/moduleRegistry.d.ts.map +1 -0
- package/build/core/moduleRegistry.js +67 -0
- package/build/core/moduleRegistry.js.map +1 -0
- package/build/core/nativeOnlyHints.d.ts.map +1 -1
- package/build/core/nativeOnlyHints.js +0 -2
- package/build/core/nativeOnlyHints.js.map +1 -1
- package/build/core/navigate.d.ts +46 -0
- package/build/core/navigate.d.ts.map +1 -0
- package/build/core/navigate.js +119 -0
- package/build/core/navigate.js.map +1 -0
- package/build/core/navigation.d.ts +66 -0
- package/build/core/navigation.d.ts.map +1 -0
- package/build/core/navigation.js +269 -0
- package/build/core/navigation.js.map +1 -0
- package/build/core/network.d.ts +12 -2
- package/build/core/network.d.ts.map +1 -1
- package/build/core/network.js +52 -12
- package/build/core/network.js.map +1 -1
- package/build/core/networkInterceptor.d.ts +1 -1
- package/build/core/networkInterceptor.d.ts.map +1 -1
- package/build/core/networkInterceptor.js +3 -2
- package/build/core/networkInterceptor.js.map +1 -1
- package/build/core/promiseHandles.d.ts +19 -0
- package/build/core/promiseHandles.d.ts.map +1 -0
- package/build/core/promiseHandles.js +58 -0
- package/build/core/promiseHandles.js.map +1 -0
- package/build/core/register.d.ts.map +1 -1
- package/build/core/register.js +1 -4
- package/build/core/register.js.map +1 -1
- package/build/core/sdkMirrorPoller.d.ts +31 -0
- package/build/core/sdkMirrorPoller.d.ts.map +1 -0
- package/build/core/sdkMirrorPoller.js +210 -0
- package/build/core/sdkMirrorPoller.js.map +1 -0
- package/build/core/state.d.ts +14 -0
- package/build/core/state.d.ts.map +1 -1
- package/build/core/state.js +48 -2
- package/build/core/state.js.map +1 -1
- package/build/core/toolHelpers.d.ts.map +1 -1
- package/build/core/toolHelpers.js +42 -10
- package/build/core/toolHelpers.js.map +1 -1
- package/build/core/truncate.d.ts +42 -0
- package/build/core/truncate.d.ts.map +1 -0
- package/build/core/truncate.js +169 -0
- package/build/core/truncate.js.map +1 -0
- package/build/core/types.d.ts +3 -0
- package/build/core/types.d.ts.map +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4 -2
- package/build/index.js.map +1 -1
- package/build/tools/_deviceArg.d.ts +17 -1
- package/build/tools/_deviceArg.d.ts.map +1 -1
- package/build/tools/_deviceArg.js +17 -1
- package/build/tools/_deviceArg.js.map +1 -1
- package/build/tools/bundleTools.d.ts.map +1 -1
- package/build/tools/bundleTools.js +20 -33
- package/build/tools/bundleTools.js.map +1 -1
- package/build/tools/componentTools.d.ts.map +1 -1
- package/build/tools/componentTools.js +41 -219
- package/build/tools/componentTools.js.map +1 -1
- package/build/tools/connectionTools.d.ts.map +1 -1
- package/build/tools/connectionTools.js +17 -22
- package/build/tools/connectionTools.js.map +1 -1
- package/build/tools/deviceTools.d.ts.map +1 -1
- package/build/tools/deviceTools.js +13 -167
- package/build/tools/deviceTools.js.map +1 -1
- package/build/tools/executionTools.d.ts.map +1 -1
- package/build/tools/executionTools.js +63 -18
- package/build/tools/executionTools.js.map +1 -1
- package/build/tools/interactionTools.d.ts.map +1 -1
- package/build/tools/interactionTools.js +13 -45
- package/build/tools/interactionTools.js.map +1 -1
- package/build/tools/logTools.d.ts.map +1 -1
- package/build/tools/logTools.js +61 -80
- package/build/tools/logTools.js.map +1 -1
- package/build/tools/metaTools.js +1 -1
- package/build/tools/metaTools.js.map +1 -1
- package/build/tools/navigationTools.d.ts +3 -0
- package/build/tools/navigationTools.d.ts.map +1 -0
- package/build/tools/navigationTools.js +60 -0
- package/build/tools/navigationTools.js.map +1 -0
- package/build/tools/networkTools.d.ts.map +1 -1
- package/build/tools/networkTools.js +44 -202
- package/build/tools/networkTools.js.map +1 -1
- package/build/tools/reduxTools.d.ts.map +1 -1
- package/build/tools/reduxTools.js +3 -2
- package/build/tools/reduxTools.js.map +1 -1
- package/build/tools/requestTools.d.ts +3 -0
- package/build/tools/requestTools.d.ts.map +1 -0
- package/build/tools/requestTools.js +79 -0
- package/build/tools/requestTools.js.map +1 -0
- package/build/tools/screenshotTools.d.ts.map +1 -1
- package/build/tools/screenshotTools.js +9 -13
- package/build/tools/screenshotTools.js.map +1 -1
- package/package.json +1 -1
- package/tools.json +22 -78
- package/build/__tests__/unit/flowpoints.test.d.ts +0 -2
- package/build/__tests__/unit/flowpoints.test.d.ts.map +0 -1
- package/build/__tests__/unit/flowpoints.test.js +0 -126
- package/build/__tests__/unit/flowpoints.test.js.map +0 -1
- package/build/__tests__/unit/flowpointsQuery.test.d.ts +0 -2
- package/build/__tests__/unit/flowpointsQuery.test.d.ts.map +0 -1
- package/build/__tests__/unit/flowpointsQuery.test.js +0 -91
- package/build/__tests__/unit/flowpointsQuery.test.js.map +0 -1
- package/build/__tests__/unit/selectionPoller.test.d.ts +0 -2
- package/build/__tests__/unit/selectionPoller.test.d.ts.map +0 -1
- package/build/__tests__/unit/selectionPoller.test.js +0 -109
- package/build/__tests__/unit/selectionPoller.test.js.map +0 -1
- package/build/__tests__/unit/verifyFlow.test.d.ts +0 -2
- package/build/__tests__/unit/verifyFlow.test.d.ts.map +0 -1
- package/build/__tests__/unit/verifyFlow.test.js +0 -45
- package/build/__tests__/unit/verifyFlow.test.js.map +0 -1
- package/build/core/selectionPoller.d.ts +0 -13
- package/build/core/selectionPoller.d.ts.map +0 -1
- package/build/core/selectionPoller.js +0 -102
- package/build/core/selectionPoller.js.map +0 -1
- package/build/pro/flowpointTools.d.ts +0 -4
- package/build/pro/flowpointTools.d.ts.map +0 -1
- package/build/pro/flowpointTools.js +0 -266
- package/build/pro/flowpointTools.js.map +0 -1
- package/build/pro/flowpoints.d.ts +0 -86
- package/build/pro/flowpoints.d.ts.map +0 -1
- package/build/pro/flowpoints.js +0 -283
- package/build/pro/flowpoints.js.map +0 -1
package/build/core/inspector.js
CHANGED
|
@@ -1,34 +1,8 @@
|
|
|
1
1
|
import { executeInApp } from "./jsExecute.js";
|
|
2
2
|
import { resolveStacksToSource, buildDebugStackHarvestExpression } from "./componentSource.js";
|
|
3
|
-
import { selectionBuffer } from "./selectionBuffer.js";
|
|
4
3
|
// ============================================================================
|
|
5
4
|
// Coordinate-Based Element Inspection (via DevTools Inspector API)
|
|
6
5
|
// ============================================================================
|
|
7
|
-
/**
|
|
8
|
-
* Toggle the Element Inspector via DevSettings native module.
|
|
9
|
-
* This enables the inspector overlay programmatically.
|
|
10
|
-
*/
|
|
11
|
-
export async function toggleElementInspector(device) {
|
|
12
|
-
const expression = `
|
|
13
|
-
(function() {
|
|
14
|
-
const ds = globalThis.nativeModuleProxy?.DevSettings;
|
|
15
|
-
if (!ds) return { error: 'DevSettings not available' };
|
|
16
|
-
|
|
17
|
-
const proto = Object.getPrototypeOf(ds);
|
|
18
|
-
if (!proto || typeof proto.toggleElementInspector !== 'function') {
|
|
19
|
-
return { error: 'toggleElementInspector not found' };
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
try {
|
|
23
|
-
proto.toggleElementInspector.call(ds);
|
|
24
|
-
return { success: true, message: 'Element Inspector toggled' };
|
|
25
|
-
} catch (e) {
|
|
26
|
-
return { error: 'Failed to toggle: ' + e.message };
|
|
27
|
-
}
|
|
28
|
-
})()
|
|
29
|
-
`;
|
|
30
|
-
return executeInApp(expression, false, { originatingToolName: "toggle_element_inspector" }, device);
|
|
31
|
-
}
|
|
32
6
|
/**
|
|
33
7
|
* Check if the Element Inspector overlay is currently active.
|
|
34
8
|
*/
|
|
@@ -69,314 +43,6 @@ export async function isInspectorActive(device) {
|
|
|
69
43
|
}
|
|
70
44
|
return false;
|
|
71
45
|
}
|
|
72
|
-
/**
|
|
73
|
-
* Get the currently selected element from the Element Inspector overlay.
|
|
74
|
-
* This reads the InspectorPanel component's props to get the hierarchy, frame, and style.
|
|
75
|
-
* Requires the Element Inspector to be enabled and an element to be selected.
|
|
76
|
-
*/
|
|
77
|
-
export async function getInspectorSelection(device) {
|
|
78
|
-
const expression = `
|
|
79
|
-
(function() {
|
|
80
|
-
const hook = globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__;
|
|
81
|
-
if (!hook) return { error: 'React DevTools hook not available.' };
|
|
82
|
-
|
|
83
|
-
// Find fiber roots
|
|
84
|
-
let roots = [...(hook.getFiberRoots?.(1) || [])];
|
|
85
|
-
if (roots.length === 0) {
|
|
86
|
-
for (const [id] of (hook.renderers || [])) {
|
|
87
|
-
roots = [...(hook.getFiberRoots?.(id) || [])];
|
|
88
|
-
if (roots.length > 0) break;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
if (roots.length === 0) return { error: 'No fiber roots found.' };
|
|
92
|
-
|
|
93
|
-
// Find all InspectorPanel instances (apps with modals may have multiple)
|
|
94
|
-
function findAllPanels(fiber, targetName, depth, results) {
|
|
95
|
-
if (!fiber || depth > 5000) return;
|
|
96
|
-
const name = fiber.type?.displayName || fiber.type?.name;
|
|
97
|
-
if (name === targetName) results.push(fiber);
|
|
98
|
-
let child = fiber.child;
|
|
99
|
-
while (child) {
|
|
100
|
-
findAllPanels(child, targetName, depth + 1, results);
|
|
101
|
-
child = child.sibling;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const panels = [];
|
|
106
|
-
findAllPanels(roots[0].current, 'InspectorPanel', 0, panels);
|
|
107
|
-
if (panels.length === 0) {
|
|
108
|
-
return {
|
|
109
|
-
error: 'Element Inspector is not active.',
|
|
110
|
-
hint: 'Use toggle_element_inspector to enable the inspector, then tap an element to select it.'
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// Prefer the panel that has an active selection
|
|
115
|
-
const panelFiber = panels.find(p => p.memoizedProps.hierarchy?.length > 0) || panels[0];
|
|
116
|
-
const props = panelFiber.memoizedProps;
|
|
117
|
-
if (!props.hierarchy || props.hierarchy.length === 0) {
|
|
118
|
-
return {
|
|
119
|
-
error: 'No element selected.',
|
|
120
|
-
hint: 'Tap on an element in the app to select it for inspection.'
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// Build the path from hierarchy
|
|
125
|
-
const path = props.hierarchy.map(h => h.name).join(' > ');
|
|
126
|
-
const element = props.hierarchy[props.hierarchy.length - 1]?.name || 'Unknown';
|
|
127
|
-
|
|
128
|
-
// Extract style info
|
|
129
|
-
let style = {};
|
|
130
|
-
if (props.inspected?.style) {
|
|
131
|
-
const styles = Array.isArray(props.inspected.style)
|
|
132
|
-
? props.inspected.style
|
|
133
|
-
: [props.inspected.style];
|
|
134
|
-
for (const s of styles) {
|
|
135
|
-
if (s && typeof s === 'object') {
|
|
136
|
-
Object.assign(style, s);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return {
|
|
142
|
-
element,
|
|
143
|
-
path,
|
|
144
|
-
frame: props.inspected?.frame || null,
|
|
145
|
-
style: Object.keys(style).length > 0 ? style : null,
|
|
146
|
-
selection: props.selection,
|
|
147
|
-
hierarchyLength: props.hierarchy.length
|
|
148
|
-
};
|
|
149
|
-
})()
|
|
150
|
-
`;
|
|
151
|
-
return executeInApp(expression, false, { originatingToolName: "get_inspector_selection" }, device);
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Resolve the component at (x, y) using RN's built-in Element Inspector.
|
|
155
|
-
*
|
|
156
|
-
* Strategy: programmatically toggle the inspector overlay on (if needed),
|
|
157
|
-
* then call InspectorOverlay.props.onTouchPoint(x, y) directly — bypassing
|
|
158
|
-
* the broken adb-tap → PanResponder route on Bridgeless / new-arch RN.
|
|
159
|
-
* This populates InspectorPanel with RN's full curated hierarchy, the
|
|
160
|
-
* inspected element's frame, and per-component style data (margin, padding,
|
|
161
|
-
* border, layout) — exactly what the on-device overlay shows.
|
|
162
|
-
*
|
|
163
|
-
* Returns the rich hierarchy with style merged from each entry's
|
|
164
|
-
* getInspectorData(...).props.style, plus the inspected frame and style.
|
|
165
|
-
*
|
|
166
|
-
* Auto-hides the overlay after capture so subsequent screenshots stay clean.
|
|
167
|
-
*/
|
|
168
|
-
export async function getInspectorSelectionAtPoint(x, y, device) {
|
|
169
|
-
// Step 1: ensure the inspector overlay is mounted (toggle on if currently off).
|
|
170
|
-
const setupExpression = `
|
|
171
|
-
(function() {
|
|
172
|
-
var ds = globalThis.nativeModuleProxy && globalThis.nativeModuleProxy.DevSettings;
|
|
173
|
-
if (!ds) return { error: 'DevSettings native module not available.' };
|
|
174
|
-
var hook = globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__;
|
|
175
|
-
if (!hook) return { error: 'React DevTools hook not available. Make sure you are running a development build.' };
|
|
176
|
-
|
|
177
|
-
function findOverlays() {
|
|
178
|
-
var roots = [];
|
|
179
|
-
if (hook.renderers) {
|
|
180
|
-
for (var entry of hook.renderers) {
|
|
181
|
-
try { roots = roots.concat(Array.from(hook.getFiberRoots(entry[0]) || [])); } catch(e) {}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
var overlays = [];
|
|
185
|
-
function walk(f, d) {
|
|
186
|
-
if (!f || d > 800) return;
|
|
187
|
-
if (f.type && typeof f.type !== 'string' &&
|
|
188
|
-
(f.type.displayName || f.type.name) === 'InspectorOverlay') {
|
|
189
|
-
overlays.push(f);
|
|
190
|
-
}
|
|
191
|
-
var c = f.child;
|
|
192
|
-
while (c) { walk(c, d + 1); c = c.sibling; }
|
|
193
|
-
}
|
|
194
|
-
for (var r of roots) { walk(r.current, 0); }
|
|
195
|
-
return overlays;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
var overlays = findOverlays();
|
|
199
|
-
// Two overlays expected when active: one per fiber root (LogBox + app).
|
|
200
|
-
var wasActive = overlays.length >= 2;
|
|
201
|
-
if (!wasActive) {
|
|
202
|
-
var proto = Object.getPrototypeOf(ds);
|
|
203
|
-
if (typeof proto.toggleElementInspector !== 'function') {
|
|
204
|
-
return { error: 'toggleElementInspector not found on DevSettings.' };
|
|
205
|
-
}
|
|
206
|
-
proto.toggleElementInspector.call(ds);
|
|
207
|
-
}
|
|
208
|
-
return { wasActive: wasActive };
|
|
209
|
-
})()
|
|
210
|
-
`;
|
|
211
|
-
const setup = await executeInApp(setupExpression, false, { originatingToolName: "inspect_at_point" }, device);
|
|
212
|
-
if (!setup.success)
|
|
213
|
-
return setup;
|
|
214
|
-
try {
|
|
215
|
-
const parsed = JSON.parse(setup.result || "{}");
|
|
216
|
-
if (parsed.error)
|
|
217
|
-
return { success: false, error: parsed.error };
|
|
218
|
-
}
|
|
219
|
-
catch {
|
|
220
|
-
/* ignore */
|
|
221
|
-
}
|
|
222
|
-
// Allow the inspector overlay to mount.
|
|
223
|
-
await new Promise((resolve) => setTimeout(resolve, 350));
|
|
224
|
-
// Step 2: locate the app InspectorOverlay (skip LogBox at index 0) and dispatch onTouchPoint.
|
|
225
|
-
const tapExpression = `
|
|
226
|
-
(function() {
|
|
227
|
-
var hook = globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__;
|
|
228
|
-
var roots = [];
|
|
229
|
-
for (var entry of hook.renderers) {
|
|
230
|
-
try { roots = roots.concat(Array.from(hook.getFiberRoots(entry[0]) || [])); } catch(e) {}
|
|
231
|
-
}
|
|
232
|
-
var overlays = [];
|
|
233
|
-
function walk(f, d) {
|
|
234
|
-
if (!f || d > 800) return;
|
|
235
|
-
if (f.type && typeof f.type !== 'string' &&
|
|
236
|
-
(f.type.displayName || f.type.name) === 'InspectorOverlay') {
|
|
237
|
-
overlays.push(f);
|
|
238
|
-
}
|
|
239
|
-
var c = f.child;
|
|
240
|
-
while (c) { walk(c, d + 1); c = c.sibling; }
|
|
241
|
-
}
|
|
242
|
-
for (var r of roots) { walk(r.current, 0); }
|
|
243
|
-
|
|
244
|
-
// The LogBox renderer's overlay is mounted first; the app overlay is the last one.
|
|
245
|
-
var overlay = overlays[overlays.length - 1];
|
|
246
|
-
if (!overlay || !overlay.memoizedProps || typeof overlay.memoizedProps.onTouchPoint !== 'function') {
|
|
247
|
-
return { error: 'InspectorOverlay.onTouchPoint unavailable. Inspector may not be mounted.' };
|
|
248
|
-
}
|
|
249
|
-
try {
|
|
250
|
-
overlay.memoizedProps.onTouchPoint(${x}, ${y});
|
|
251
|
-
} catch (e) {
|
|
252
|
-
return { error: 'onTouchPoint failed: ' + (e && e.message || String(e)) };
|
|
253
|
-
}
|
|
254
|
-
return { ok: true };
|
|
255
|
-
})()
|
|
256
|
-
`;
|
|
257
|
-
const tap = await executeInApp(tapExpression, false, { originatingToolName: "inspect_at_point" }, device);
|
|
258
|
-
if (!tap.success)
|
|
259
|
-
return tap;
|
|
260
|
-
try {
|
|
261
|
-
const parsed = JSON.parse(tap.result || "{}");
|
|
262
|
-
if (parsed.error)
|
|
263
|
-
return { success: false, error: parsed.error };
|
|
264
|
-
}
|
|
265
|
-
catch {
|
|
266
|
-
/* ignore */
|
|
267
|
-
}
|
|
268
|
-
// Allow setState/render to propagate before reading panel props.
|
|
269
|
-
await new Promise((resolve) => setTimeout(resolve, 250));
|
|
270
|
-
// Step 3: read the populated InspectorPanel and shape the response.
|
|
271
|
-
const readExpression = `
|
|
272
|
-
(function() {
|
|
273
|
-
var hook = globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__;
|
|
274
|
-
var roots = [];
|
|
275
|
-
for (var entry of hook.renderers) {
|
|
276
|
-
try { roots = roots.concat(Array.from(hook.getFiberRoots(entry[0]) || [])); } catch(e) {}
|
|
277
|
-
}
|
|
278
|
-
var panels = [];
|
|
279
|
-
function walk(f, d) {
|
|
280
|
-
if (!f || d > 800) return;
|
|
281
|
-
if (f.type && typeof f.type !== 'string' &&
|
|
282
|
-
(f.type.displayName || f.type.name) === 'InspectorPanel') {
|
|
283
|
-
panels.push(f);
|
|
284
|
-
}
|
|
285
|
-
var c = f.child;
|
|
286
|
-
while (c) { walk(c, d + 1); c = c.sibling; }
|
|
287
|
-
}
|
|
288
|
-
for (var r of roots) { walk(r.current, 0); }
|
|
289
|
-
|
|
290
|
-
var withSel = panels.filter(function(p) {
|
|
291
|
-
return p.memoizedProps && p.memoizedProps.hierarchy && p.memoizedProps.hierarchy.length > 0;
|
|
292
|
-
});
|
|
293
|
-
if (withSel.length === 0) {
|
|
294
|
-
return { error: 'Inspector did not select an element at (${x}, ${y}). Coordinates may be outside the app bounds.' };
|
|
295
|
-
}
|
|
296
|
-
var props = withSel[withSel.length - 1].memoizedProps;
|
|
297
|
-
|
|
298
|
-
function flattenStyle(raw) {
|
|
299
|
-
if (!raw) return null;
|
|
300
|
-
var arr = Array.isArray(raw) ? raw : [raw];
|
|
301
|
-
var merged = {};
|
|
302
|
-
for (var i = 0; i < arr.length; i++) {
|
|
303
|
-
var v = arr[i];
|
|
304
|
-
if (v && typeof v === 'object') {
|
|
305
|
-
var keys = Object.keys(v);
|
|
306
|
-
for (var k = 0; k < keys.length; k++) merged[keys[k]] = v[keys[k]];
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
return Object.keys(merged).length > 0 ? merged : null;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
var idFn = function(x) { return x; };
|
|
313
|
-
// Build hierarchy with style + source per entry; dedupe consecutive duplicates.
|
|
314
|
-
var hierarchy = [];
|
|
315
|
-
var prevName = null;
|
|
316
|
-
for (var i = 0; i < props.hierarchy.length; i++) {
|
|
317
|
-
var h = props.hierarchy[i];
|
|
318
|
-
var name = h.name;
|
|
319
|
-
if (!name || name === prevName) continue;
|
|
320
|
-
prevName = name;
|
|
321
|
-
var data = h.getInspectorData ? h.getInspectorData(idFn) : null;
|
|
322
|
-
var style = data && data.props ? flattenStyle(data.props.style) : null;
|
|
323
|
-
var entry = { name: name };
|
|
324
|
-
if (style) entry.style = style;
|
|
325
|
-
if (data && data.source && data.source.fileName) {
|
|
326
|
-
entry.source = data.source.fileName + (data.source.lineNumber ? (':' + data.source.lineNumber) : '');
|
|
327
|
-
}
|
|
328
|
-
hierarchy.push(entry);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
var element = hierarchy.length > 0 ? hierarchy[hierarchy.length - 1].name : 'Unknown';
|
|
332
|
-
var path = hierarchy.map(function(e) { return e.name; }).join(' > ') || element;
|
|
333
|
-
|
|
334
|
-
return {
|
|
335
|
-
element: element,
|
|
336
|
-
path: path,
|
|
337
|
-
frame: props.inspected ? props.inspected.frame : null,
|
|
338
|
-
style: props.inspected ? flattenStyle(props.inspected.style) : null,
|
|
339
|
-
hierarchy: hierarchy,
|
|
340
|
-
selection: props.selection
|
|
341
|
-
};
|
|
342
|
-
})()
|
|
343
|
-
`;
|
|
344
|
-
const readResult = await executeInApp(readExpression, false, { originatingToolName: "inspect_at_point" }, device);
|
|
345
|
-
// Step 4: hide the overlay so it doesn't pollute subsequent screenshots.
|
|
346
|
-
// We always hide after a successful capture — agents don't manually toggle.
|
|
347
|
-
const teardownExpression = `
|
|
348
|
-
(function() {
|
|
349
|
-
var ds = globalThis.nativeModuleProxy && globalThis.nativeModuleProxy.DevSettings;
|
|
350
|
-
if (!ds) return { skipped: true };
|
|
351
|
-
var hook = globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__;
|
|
352
|
-
if (!hook) return { skipped: true };
|
|
353
|
-
var roots = [];
|
|
354
|
-
for (var entry of hook.renderers) {
|
|
355
|
-
try { roots = roots.concat(Array.from(hook.getFiberRoots(entry[0]) || [])); } catch(e) {}
|
|
356
|
-
}
|
|
357
|
-
var overlays = 0;
|
|
358
|
-
function walk(f, d) {
|
|
359
|
-
if (!f || d > 800) return;
|
|
360
|
-
if (f.type && typeof f.type !== 'string' &&
|
|
361
|
-
(f.type.displayName || f.type.name) === 'InspectorOverlay') overlays++;
|
|
362
|
-
var c = f.child;
|
|
363
|
-
while (c) { walk(c, d + 1); c = c.sibling; }
|
|
364
|
-
}
|
|
365
|
-
for (var r of roots) { walk(r.current, 0); }
|
|
366
|
-
if (overlays >= 2) {
|
|
367
|
-
try { Object.getPrototypeOf(ds).toggleElementInspector.call(ds); } catch(e) {}
|
|
368
|
-
}
|
|
369
|
-
return { ok: true };
|
|
370
|
-
})()
|
|
371
|
-
`;
|
|
372
|
-
try {
|
|
373
|
-
await executeInApp(teardownExpression, false, { originatingToolName: "inspect_at_point" }, device);
|
|
374
|
-
}
|
|
375
|
-
catch {
|
|
376
|
-
/* best-effort hide; don't fail the call */
|
|
377
|
-
}
|
|
378
|
-
return readResult;
|
|
379
|
-
}
|
|
380
46
|
/**
|
|
381
47
|
* Inspect the React component at a specific (x, y) coordinate.
|
|
382
48
|
*
|
|
@@ -609,7 +275,7 @@ export async function inspectAtPoint(x, y, options = {}) {
|
|
|
609
275
|
*/
|
|
610
276
|
export async function harvestStacksAtPoint(x, y, device) {
|
|
611
277
|
try {
|
|
612
|
-
const res = await executeInApp(buildDebugStackHarvestExpression(x, y), true, { timeoutMs: 5000, originatingToolName: "
|
|
278
|
+
const res = await executeInApp(buildDebugStackHarvestExpression(x, y), true, { timeoutMs: 5000, originatingToolName: "inspect_at_point" }, device);
|
|
613
279
|
if (!res.success || !res.result)
|
|
614
280
|
return [];
|
|
615
281
|
const parsed = JSON.parse(res.result);
|
|
@@ -619,17 +285,6 @@ export async function harvestStacksAtPoint(x, y, device) {
|
|
|
619
285
|
return [];
|
|
620
286
|
}
|
|
621
287
|
}
|
|
622
|
-
/** Same, but derives the point from an inspected element's frame. */
|
|
623
|
-
export async function harvestStacksAtFrame(frame, device) {
|
|
624
|
-
if (!frame ||
|
|
625
|
-
frame.left === undefined ||
|
|
626
|
-
frame.top === undefined ||
|
|
627
|
-
frame.width === undefined ||
|
|
628
|
-
frame.height === undefined) {
|
|
629
|
-
return [];
|
|
630
|
-
}
|
|
631
|
-
return harvestStacksAtPoint(frame.left + frame.width / 2, frame.top + frame.height / 2, device);
|
|
632
|
-
}
|
|
633
288
|
/**
|
|
634
289
|
* Attaches source location to an inspector payload. Never throws and never
|
|
635
290
|
* removes existing fields - a failure adds only a `sourceUnavailable` reason.
|
|
@@ -646,16 +301,4 @@ export async function enrichWithSource(payload, stacks) {
|
|
|
646
301
|
return { ...payload, sourceUnavailable: "resolution-failed" };
|
|
647
302
|
}
|
|
648
303
|
}
|
|
649
|
-
/** Buffered selections, newest first, each with source resolved lazily on read. */
|
|
650
|
-
export async function getSelectionHistory(options) {
|
|
651
|
-
const entries = selectionBuffer.list({ device: options.device, limit: options.limit ?? 10 });
|
|
652
|
-
return Promise.all(entries.map(async (entry) => enrichWithSource({
|
|
653
|
-
element: entry.element,
|
|
654
|
-
path: entry.path,
|
|
655
|
-
frame: entry.frame,
|
|
656
|
-
style: entry.style,
|
|
657
|
-
device: entry.device,
|
|
658
|
-
timestamp: entry.timestamp,
|
|
659
|
-
}, entry.stacks)));
|
|
660
|
-
}
|
|
661
304
|
//# sourceMappingURL=inspector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspector.js","sourceRoot":"","sources":["../../src/core/inspector.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"inspector.js","sourceRoot":"","sources":["../../src/core/inspector.ts"],"names":[],"mappings":"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"}
|
package/build/core/ios.js
CHANGED
|
@@ -343,7 +343,7 @@ export async function buildNoSimulatorError() {
|
|
|
343
343
|
if (shutdown.length === 0)
|
|
344
344
|
return base;
|
|
345
345
|
const top = shutdown.slice(0, 6).map((d) => ` - ${d.name} (${d.udid})`).join("\n");
|
|
346
|
-
const more = shutdown.length > 6 ? `\n ...and ${shutdown.length - 6} more (run
|
|
346
|
+
const more = shutdown.length > 6 ? `\n ...and ${shutdown.length - 6} more (run list_devices)` : "";
|
|
347
347
|
return `${base}\n\nAvailable simulators (shutdown):\n${top}${more}`;
|
|
348
348
|
}
|
|
349
349
|
catch {
|
|
@@ -568,7 +568,7 @@ export async function iosLaunchApp(bundleId, udid) {
|
|
|
568
568
|
let hint = "";
|
|
569
569
|
if (msg.includes("FBSOpenApplicationErrorDomain")) {
|
|
570
570
|
hint =
|
|
571
|
-
"\n\nCommon causes:\n- App is not installed on this simulator (install it
|
|
571
|
+
"\n\nCommon causes:\n- App is not installed on this simulator (install it with `xcrun simctl install booted <path.app>`, or run your project's iOS build)\n- Bundle ID is incorrect (check with: xcrun simctl listapps booted)";
|
|
572
572
|
}
|
|
573
573
|
return {
|
|
574
574
|
success: false,
|