react-native-ai-debugger 1.8.0 → 1.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.
Files changed (197) hide show
  1. package/README.md +73 -66
  2. package/build/__tests__/integration/auto-reconnect.test.d.ts +2 -0
  3. package/build/__tests__/integration/auto-reconnect.test.d.ts.map +1 -0
  4. package/build/__tests__/integration/auto-reconnect.test.js +118 -0
  5. package/build/__tests__/integration/auto-reconnect.test.js.map +1 -0
  6. package/build/__tests__/integration/per-call-timeout.test.d.ts +2 -0
  7. package/build/__tests__/integration/per-call-timeout.test.d.ts.map +1 -0
  8. package/build/__tests__/integration/per-call-timeout.test.js +103 -0
  9. package/build/__tests__/integration/per-call-timeout.test.js.map +1 -0
  10. package/build/__tests__/setup.js +3 -5
  11. package/build/__tests__/setup.js.map +1 -1
  12. package/build/__tests__/unit/debugGlobals.test.d.ts +2 -0
  13. package/build/__tests__/unit/debugGlobals.test.d.ts.map +1 -0
  14. package/build/__tests__/unit/debugGlobals.test.js +14 -0
  15. package/build/__tests__/unit/debugGlobals.test.js.map +1 -0
  16. package/build/__tests__/unit/escapeNonAscii.test.d.ts +2 -0
  17. package/build/__tests__/unit/escapeNonAscii.test.d.ts.map +1 -0
  18. package/build/__tests__/unit/escapeNonAscii.test.js +76 -0
  19. package/build/__tests__/unit/escapeNonAscii.test.js.map +1 -0
  20. package/build/__tests__/unit/executor.test.js +59 -7
  21. package/build/__tests__/unit/executor.test.js.map +1 -1
  22. package/build/__tests__/unit/fastRefreshRecorder.test.d.ts +2 -0
  23. package/build/__tests__/unit/fastRefreshRecorder.test.d.ts.map +1 -0
  24. package/build/__tests__/unit/fastRefreshRecorder.test.js +68 -0
  25. package/build/__tests__/unit/fastRefreshRecorder.test.js.map +1 -0
  26. package/build/__tests__/unit/fastRefreshTools.test.d.ts +2 -0
  27. package/build/__tests__/unit/fastRefreshTools.test.d.ts.map +1 -0
  28. package/build/__tests__/unit/fastRefreshTools.test.js +112 -0
  29. package/build/__tests__/unit/fastRefreshTools.test.js.map +1 -0
  30. package/build/__tests__/unit/fingerprint.test.js +10 -0
  31. package/build/__tests__/unit/fingerprint.test.js.map +1 -1
  32. package/build/__tests__/unit/measureComponent.test.d.ts +2 -0
  33. package/build/__tests__/unit/measureComponent.test.d.ts.map +1 -0
  34. package/build/__tests__/unit/measureComponent.test.js +66 -0
  35. package/build/__tests__/unit/measureComponent.test.js.map +1 -0
  36. package/build/__tests__/unit/measureComponentTools.test.d.ts +2 -0
  37. package/build/__tests__/unit/measureComponentTools.test.d.ts.map +1 -0
  38. package/build/__tests__/unit/measureComponentTools.test.js +94 -0
  39. package/build/__tests__/unit/measureComponentTools.test.js.map +1 -0
  40. package/build/__tests__/unit/rnGlobalsBootstrap.test.d.ts +2 -0
  41. package/build/__tests__/unit/rnGlobalsBootstrap.test.d.ts.map +1 -0
  42. package/build/__tests__/unit/rnGlobalsBootstrap.test.js +29 -0
  43. package/build/__tests__/unit/rnGlobalsBootstrap.test.js.map +1 -0
  44. package/build/__tests__/unit/timeoutClamp.test.d.ts +2 -0
  45. package/build/__tests__/unit/timeoutClamp.test.d.ts.map +1 -0
  46. package/build/__tests__/unit/timeoutClamp.test.js +17 -0
  47. package/build/__tests__/unit/timeoutClamp.test.js.map +1 -0
  48. package/build/__tests__/unit/transportClassify.test.d.ts +2 -0
  49. package/build/__tests__/unit/transportClassify.test.d.ts.map +1 -0
  50. package/build/__tests__/unit/transportClassify.test.js +60 -0
  51. package/build/__tests__/unit/transportClassify.test.js.map +1 -0
  52. package/build/core/appDetection.d.ts +7 -0
  53. package/build/core/appDetection.d.ts.map +1 -1
  54. package/build/core/appDetection.js +38 -17
  55. package/build/core/appDetection.js.map +1 -1
  56. package/build/core/bundle.d.ts +1 -1
  57. package/build/core/bundle.d.ts.map +1 -1
  58. package/build/core/bundle.js +6 -10
  59. package/build/core/bundle.js.map +1 -1
  60. package/build/core/componentSearch.d.ts +41 -0
  61. package/build/core/componentSearch.d.ts.map +1 -0
  62. package/build/core/componentSearch.js +484 -0
  63. package/build/core/componentSearch.js.map +1 -0
  64. package/build/core/componentTree.d.ts +13 -0
  65. package/build/core/componentTree.d.ts.map +1 -0
  66. package/build/core/componentTree.js +275 -0
  67. package/build/core/componentTree.js.map +1 -0
  68. package/build/core/connection.d.ts +1 -0
  69. package/build/core/connection.d.ts.map +1 -1
  70. package/build/core/connection.js +97 -88
  71. package/build/core/connection.js.map +1 -1
  72. package/build/core/debugGlobals.d.ts +6 -0
  73. package/build/core/debugGlobals.d.ts.map +1 -0
  74. package/build/core/debugGlobals.js +336 -0
  75. package/build/core/debugGlobals.js.map +1 -0
  76. package/build/core/escapeNonAscii.d.ts +18 -0
  77. package/build/core/escapeNonAscii.d.ts.map +1 -0
  78. package/build/core/escapeNonAscii.js +352 -0
  79. package/build/core/escapeNonAscii.js.map +1 -0
  80. package/build/core/executor.d.ts +7 -206
  81. package/build/core/executor.d.ts.map +1 -1
  82. package/build/core/executor.js +10 -4333
  83. package/build/core/executor.js.map +1 -1
  84. package/build/core/fastRefreshRecorder.d.ts +23 -0
  85. package/build/core/fastRefreshRecorder.d.ts.map +1 -0
  86. package/build/core/fastRefreshRecorder.js +83 -0
  87. package/build/core/fastRefreshRecorder.js.map +1 -0
  88. package/build/core/fastRefreshTools.d.ts +19 -0
  89. package/build/core/fastRefreshTools.d.ts.map +1 -0
  90. package/build/core/fastRefreshTools.js +71 -0
  91. package/build/core/fastRefreshTools.js.map +1 -0
  92. package/build/core/guides.d.ts.map +1 -1
  93. package/build/core/guides.js +2 -1
  94. package/build/core/guides.js.map +1 -1
  95. package/build/core/index.d.ts +5 -2
  96. package/build/core/index.d.ts.map +1 -1
  97. package/build/core/index.js +5 -2
  98. package/build/core/index.js.map +1 -1
  99. package/build/core/inspector.d.ts +50 -0
  100. package/build/core/inspector.d.ts.map +1 -0
  101. package/build/core/inspector.js +604 -0
  102. package/build/core/inspector.js.map +1 -0
  103. package/build/core/jsExecute.d.ts +61 -0
  104. package/build/core/jsExecute.d.ts.map +1 -0
  105. package/build/core/jsExecute.js +679 -0
  106. package/build/core/jsExecute.js.map +1 -0
  107. package/build/core/measureComponent.d.ts +19 -0
  108. package/build/core/measureComponent.d.ts.map +1 -0
  109. package/build/core/measureComponent.js +94 -0
  110. package/build/core/measureComponent.js.map +1 -0
  111. package/build/core/measureComponentTools.d.ts +6 -0
  112. package/build/core/measureComponentTools.d.ts.map +1 -0
  113. package/build/core/measureComponentTools.js +43 -0
  114. package/build/core/measureComponentTools.js.map +1 -0
  115. package/build/core/pressables.d.ts +44 -0
  116. package/build/core/pressables.d.ts.map +1 -0
  117. package/build/core/pressables.js +1480 -0
  118. package/build/core/pressables.js.map +1 -0
  119. package/build/core/register.d.ts +8 -0
  120. package/build/core/register.d.ts.map +1 -0
  121. package/build/core/register.js +216 -0
  122. package/build/core/register.js.map +1 -0
  123. package/build/core/rnGlobalsBootstrap.d.ts +16 -0
  124. package/build/core/rnGlobalsBootstrap.d.ts.map +1 -0
  125. package/build/core/rnGlobalsBootstrap.js +101 -0
  126. package/build/core/rnGlobalsBootstrap.js.map +1 -0
  127. package/build/core/screenLayout.d.ts +53 -0
  128. package/build/core/screenLayout.d.ts.map +1 -0
  129. package/build/core/screenLayout.js +828 -0
  130. package/build/core/screenLayout.js.map +1 -0
  131. package/build/core/state.d.ts +2 -2
  132. package/build/core/state.d.ts.map +1 -1
  133. package/build/core/state.js +10 -5
  134. package/build/core/state.js.map +1 -1
  135. package/build/core/telemetry.d.ts +23 -0
  136. package/build/core/telemetry.d.ts.map +1 -1
  137. package/build/core/telemetry.js +67 -0
  138. package/build/core/telemetry.js.map +1 -1
  139. package/build/core/toolHelpers.d.ts +24 -0
  140. package/build/core/toolHelpers.d.ts.map +1 -0
  141. package/build/core/toolHelpers.js +118 -0
  142. package/build/core/toolHelpers.js.map +1 -0
  143. package/build/core/types.d.ts +18 -6
  144. package/build/core/types.d.ts.map +1 -1
  145. package/build/index.d.ts +2 -4
  146. package/build/index.d.ts.map +1 -1
  147. package/build/index.js +37 -4440
  148. package/build/index.js.map +1 -1
  149. package/build/tools/accountTools.d.ts +2 -0
  150. package/build/tools/accountTools.d.ts.map +1 -1
  151. package/build/tools/accountTools.js +5 -0
  152. package/build/tools/accountTools.js.map +1 -1
  153. package/build/tools/bundleTools.d.ts +3 -0
  154. package/build/tools/bundleTools.d.ts.map +1 -0
  155. package/build/tools/bundleTools.js +368 -0
  156. package/build/tools/bundleTools.js.map +1 -0
  157. package/build/tools/componentTools.d.ts +3 -0
  158. package/build/tools/componentTools.d.ts.map +1 -0
  159. package/build/tools/componentTools.js +704 -0
  160. package/build/tools/componentTools.js.map +1 -0
  161. package/build/tools/connectionTools.d.ts +3 -0
  162. package/build/tools/connectionTools.d.ts.map +1 -0
  163. package/build/tools/connectionTools.js +564 -0
  164. package/build/tools/connectionTools.js.map +1 -0
  165. package/build/tools/deviceTools.d.ts +3 -0
  166. package/build/tools/deviceTools.d.ts.map +1 -0
  167. package/build/tools/deviceTools.js +296 -0
  168. package/build/tools/deviceTools.js.map +1 -0
  169. package/build/tools/executionTools.d.ts +3 -0
  170. package/build/tools/executionTools.d.ts.map +1 -0
  171. package/build/tools/executionTools.js +245 -0
  172. package/build/tools/executionTools.js.map +1 -0
  173. package/build/tools/interactionTools.d.ts +3 -0
  174. package/build/tools/interactionTools.d.ts.map +1 -0
  175. package/build/tools/interactionTools.js +558 -0
  176. package/build/tools/interactionTools.js.map +1 -0
  177. package/build/tools/logTools.d.ts +3 -0
  178. package/build/tools/logTools.d.ts.map +1 -0
  179. package/build/tools/logTools.js +371 -0
  180. package/build/tools/logTools.js.map +1 -0
  181. package/build/tools/metaTools.d.ts +7 -0
  182. package/build/tools/metaTools.d.ts.map +1 -0
  183. package/build/tools/metaTools.js +205 -0
  184. package/build/tools/metaTools.js.map +1 -0
  185. package/build/tools/networkTools.d.ts +3 -0
  186. package/build/tools/networkTools.d.ts.map +1 -0
  187. package/build/tools/networkTools.js +478 -0
  188. package/build/tools/networkTools.js.map +1 -0
  189. package/build/tools/reduxTools.d.ts +3 -0
  190. package/build/tools/reduxTools.d.ts.map +1 -0
  191. package/build/tools/reduxTools.js +83 -0
  192. package/build/tools/reduxTools.js.map +1 -0
  193. package/build/tools/screenshotTools.d.ts +3 -0
  194. package/build/tools/screenshotTools.d.ts.map +1 -0
  195. package/build/tools/screenshotTools.js +606 -0
  196. package/build/tools/screenshotTools.js.map +1 -0
  197. package/package.json +1 -1
@@ -0,0 +1,604 @@
1
+ import { executeInApp, delay } from "./jsExecute.js";
2
+ // ============================================================================
3
+ // Coordinate-Based Element Inspection (via DevTools Inspector API)
4
+ // ============================================================================
5
+ /**
6
+ * Toggle the Element Inspector via DevSettings native module.
7
+ * This enables the inspector overlay programmatically.
8
+ */
9
+ export async function toggleElementInspector(device) {
10
+ const expression = `
11
+ (function() {
12
+ const ds = globalThis.nativeModuleProxy?.DevSettings;
13
+ if (!ds) return { error: 'DevSettings not available' };
14
+
15
+ const proto = Object.getPrototypeOf(ds);
16
+ if (!proto || typeof proto.toggleElementInspector !== 'function') {
17
+ return { error: 'toggleElementInspector not found' };
18
+ }
19
+
20
+ try {
21
+ proto.toggleElementInspector.call(ds);
22
+ return { success: true, message: 'Element Inspector toggled' };
23
+ } catch (e) {
24
+ return { error: 'Failed to toggle: ' + e.message };
25
+ }
26
+ })()
27
+ `;
28
+ return executeInApp(expression, false, {}, device);
29
+ }
30
+ /**
31
+ * Check if the Element Inspector overlay is currently active.
32
+ */
33
+ export async function isInspectorActive(device) {
34
+ const expression = `
35
+ (function() {
36
+ const hook = globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__;
37
+ if (!hook) return false;
38
+
39
+ let roots = [...(hook.getFiberRoots?.(1) || [])];
40
+ if (roots.length === 0) {
41
+ for (const [id] of (hook.renderers || [])) {
42
+ roots = [...(hook.getFiberRoots?.(id) || [])];
43
+ if (roots.length > 0) break;
44
+ }
45
+ }
46
+ if (roots.length === 0) return false;
47
+
48
+ function findComponent(fiber, targetName, depth = 0) {
49
+ if (!fiber || depth > 5000) return null;
50
+ const name = fiber.type?.displayName || fiber.type?.name;
51
+ if (name === targetName) return fiber;
52
+ let child = fiber.child;
53
+ while (child) {
54
+ const found = findComponent(child, targetName, depth + 1);
55
+ if (found) return found;
56
+ child = child.sibling;
57
+ }
58
+ return null;
59
+ }
60
+
61
+ return !!findComponent(roots[0].current, 'InspectorPanel');
62
+ })()
63
+ `;
64
+ const result = await executeInApp(expression, false, {}, device);
65
+ if (result.success && result.result) {
66
+ return result.result === "true";
67
+ }
68
+ return false;
69
+ }
70
+ /**
71
+ * Get the currently selected element from the Element Inspector overlay.
72
+ * This reads the InspectorPanel component's props to get the hierarchy, frame, and style.
73
+ * Requires the Element Inspector to be enabled and an element to be selected.
74
+ */
75
+ export async function getInspectorSelection(device) {
76
+ const expression = `
77
+ (function() {
78
+ const hook = globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__;
79
+ if (!hook) return { error: 'React DevTools hook not available.' };
80
+
81
+ // Find fiber roots
82
+ let roots = [...(hook.getFiberRoots?.(1) || [])];
83
+ if (roots.length === 0) {
84
+ for (const [id] of (hook.renderers || [])) {
85
+ roots = [...(hook.getFiberRoots?.(id) || [])];
86
+ if (roots.length > 0) break;
87
+ }
88
+ }
89
+ if (roots.length === 0) return { error: 'No fiber roots found.' };
90
+
91
+ // Find all InspectorPanel instances (apps with modals may have multiple)
92
+ function findAllPanels(fiber, targetName, depth, results) {
93
+ if (!fiber || depth > 5000) return;
94
+ const name = fiber.type?.displayName || fiber.type?.name;
95
+ if (name === targetName) results.push(fiber);
96
+ let child = fiber.child;
97
+ while (child) {
98
+ findAllPanels(child, targetName, depth + 1, results);
99
+ child = child.sibling;
100
+ }
101
+ }
102
+
103
+ const panels = [];
104
+ findAllPanels(roots[0].current, 'InspectorPanel', 0, panels);
105
+ if (panels.length === 0) {
106
+ return {
107
+ error: 'Element Inspector is not active.',
108
+ hint: 'Use toggle_element_inspector to enable the inspector, then tap an element to select it.'
109
+ };
110
+ }
111
+
112
+ // Prefer the panel that has an active selection
113
+ const panelFiber = panels.find(p => p.memoizedProps.hierarchy?.length > 0) || panels[0];
114
+ const props = panelFiber.memoizedProps;
115
+ if (!props.hierarchy || props.hierarchy.length === 0) {
116
+ return {
117
+ error: 'No element selected.',
118
+ hint: 'Tap on an element in the app to select it for inspection.'
119
+ };
120
+ }
121
+
122
+ // Build the path from hierarchy
123
+ const path = props.hierarchy.map(h => h.name).join(' > ');
124
+ const element = props.hierarchy[props.hierarchy.length - 1]?.name || 'Unknown';
125
+
126
+ // Extract style info
127
+ let style = {};
128
+ if (props.inspected?.style) {
129
+ const styles = Array.isArray(props.inspected.style)
130
+ ? props.inspected.style
131
+ : [props.inspected.style];
132
+ for (const s of styles) {
133
+ if (s && typeof s === 'object') {
134
+ Object.assign(style, s);
135
+ }
136
+ }
137
+ }
138
+
139
+ return {
140
+ element,
141
+ path,
142
+ frame: props.inspected?.frame || null,
143
+ style: Object.keys(style).length > 0 ? style : null,
144
+ selection: props.selection,
145
+ hierarchyLength: props.hierarchy.length
146
+ };
147
+ })()
148
+ `;
149
+ return executeInApp(expression, false, {}, device);
150
+ }
151
+ /**
152
+ * Resolve the component at (x, y) using RN's built-in Element Inspector.
153
+ *
154
+ * Strategy: programmatically toggle the inspector overlay on (if needed),
155
+ * then call InspectorOverlay.props.onTouchPoint(x, y) directly — bypassing
156
+ * the broken adb-tap → PanResponder route on Bridgeless / new-arch RN.
157
+ * This populates InspectorPanel with RN's full curated hierarchy, the
158
+ * inspected element's frame, and per-component style data (margin, padding,
159
+ * border, layout) — exactly what the on-device overlay shows.
160
+ *
161
+ * Returns the rich hierarchy with style merged from each entry's
162
+ * getInspectorData(...).props.style, plus the inspected frame and style.
163
+ *
164
+ * Auto-hides the overlay after capture so subsequent screenshots stay clean.
165
+ */
166
+ export async function getInspectorSelectionAtPoint(x, y, device) {
167
+ // Step 1: ensure the inspector overlay is mounted (toggle on if currently off).
168
+ const setupExpression = `
169
+ (function() {
170
+ var ds = globalThis.nativeModuleProxy && globalThis.nativeModuleProxy.DevSettings;
171
+ if (!ds) return { error: 'DevSettings native module not available.' };
172
+ var hook = globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__;
173
+ if (!hook) return { error: 'React DevTools hook not available. Make sure you are running a development build.' };
174
+
175
+ function findOverlays() {
176
+ var roots = [];
177
+ if (hook.renderers) {
178
+ for (var entry of hook.renderers) {
179
+ try { roots = roots.concat(Array.from(hook.getFiberRoots(entry[0]) || [])); } catch(e) {}
180
+ }
181
+ }
182
+ var overlays = [];
183
+ function walk(f, d) {
184
+ if (!f || d > 800) return;
185
+ if (f.type && typeof f.type !== 'string' &&
186
+ (f.type.displayName || f.type.name) === 'InspectorOverlay') {
187
+ overlays.push(f);
188
+ }
189
+ var c = f.child;
190
+ while (c) { walk(c, d + 1); c = c.sibling; }
191
+ }
192
+ for (var r of roots) { walk(r.current, 0); }
193
+ return overlays;
194
+ }
195
+
196
+ var overlays = findOverlays();
197
+ // Two overlays expected when active: one per fiber root (LogBox + app).
198
+ var wasActive = overlays.length >= 2;
199
+ if (!wasActive) {
200
+ var proto = Object.getPrototypeOf(ds);
201
+ if (typeof proto.toggleElementInspector !== 'function') {
202
+ return { error: 'toggleElementInspector not found on DevSettings.' };
203
+ }
204
+ proto.toggleElementInspector.call(ds);
205
+ }
206
+ return { wasActive: wasActive };
207
+ })()
208
+ `;
209
+ const setup = await executeInApp(setupExpression, false, {}, device);
210
+ if (!setup.success)
211
+ return setup;
212
+ try {
213
+ const parsed = JSON.parse(setup.result || "{}");
214
+ if (parsed.error)
215
+ return { success: false, error: parsed.error };
216
+ }
217
+ catch {
218
+ /* ignore */
219
+ }
220
+ // Allow the inspector overlay to mount.
221
+ await new Promise((resolve) => setTimeout(resolve, 350));
222
+ // Step 2: locate the app InspectorOverlay (skip LogBox at index 0) and dispatch onTouchPoint.
223
+ const tapExpression = `
224
+ (function() {
225
+ var hook = globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__;
226
+ var roots = [];
227
+ for (var entry of hook.renderers) {
228
+ try { roots = roots.concat(Array.from(hook.getFiberRoots(entry[0]) || [])); } catch(e) {}
229
+ }
230
+ var overlays = [];
231
+ function walk(f, d) {
232
+ if (!f || d > 800) return;
233
+ if (f.type && typeof f.type !== 'string' &&
234
+ (f.type.displayName || f.type.name) === 'InspectorOverlay') {
235
+ overlays.push(f);
236
+ }
237
+ var c = f.child;
238
+ while (c) { walk(c, d + 1); c = c.sibling; }
239
+ }
240
+ for (var r of roots) { walk(r.current, 0); }
241
+
242
+ // The LogBox renderer's overlay is mounted first; the app overlay is the last one.
243
+ var overlay = overlays[overlays.length - 1];
244
+ if (!overlay || !overlay.memoizedProps || typeof overlay.memoizedProps.onTouchPoint !== 'function') {
245
+ return { error: 'InspectorOverlay.onTouchPoint unavailable. Inspector may not be mounted.' };
246
+ }
247
+ try {
248
+ overlay.memoizedProps.onTouchPoint(${x}, ${y});
249
+ } catch (e) {
250
+ return { error: 'onTouchPoint failed: ' + (e && e.message || String(e)) };
251
+ }
252
+ return { ok: true };
253
+ })()
254
+ `;
255
+ const tap = await executeInApp(tapExpression, false, {}, device);
256
+ if (!tap.success)
257
+ return tap;
258
+ try {
259
+ const parsed = JSON.parse(tap.result || "{}");
260
+ if (parsed.error)
261
+ return { success: false, error: parsed.error };
262
+ }
263
+ catch {
264
+ /* ignore */
265
+ }
266
+ // Allow setState/render to propagate before reading panel props.
267
+ await new Promise((resolve) => setTimeout(resolve, 250));
268
+ // Step 3: read the populated InspectorPanel and shape the response.
269
+ const readExpression = `
270
+ (function() {
271
+ var hook = globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__;
272
+ var roots = [];
273
+ for (var entry of hook.renderers) {
274
+ try { roots = roots.concat(Array.from(hook.getFiberRoots(entry[0]) || [])); } catch(e) {}
275
+ }
276
+ var panels = [];
277
+ function walk(f, d) {
278
+ if (!f || d > 800) return;
279
+ if (f.type && typeof f.type !== 'string' &&
280
+ (f.type.displayName || f.type.name) === 'InspectorPanel') {
281
+ panels.push(f);
282
+ }
283
+ var c = f.child;
284
+ while (c) { walk(c, d + 1); c = c.sibling; }
285
+ }
286
+ for (var r of roots) { walk(r.current, 0); }
287
+
288
+ var withSel = panels.filter(function(p) {
289
+ return p.memoizedProps && p.memoizedProps.hierarchy && p.memoizedProps.hierarchy.length > 0;
290
+ });
291
+ if (withSel.length === 0) {
292
+ return { error: 'Inspector did not select an element at (${x}, ${y}). Coordinates may be outside the app bounds.' };
293
+ }
294
+ var props = withSel[withSel.length - 1].memoizedProps;
295
+
296
+ function flattenStyle(raw) {
297
+ if (!raw) return null;
298
+ var arr = Array.isArray(raw) ? raw : [raw];
299
+ var merged = {};
300
+ for (var i = 0; i < arr.length; i++) {
301
+ var v = arr[i];
302
+ if (v && typeof v === 'object') {
303
+ var keys = Object.keys(v);
304
+ for (var k = 0; k < keys.length; k++) merged[keys[k]] = v[keys[k]];
305
+ }
306
+ }
307
+ return Object.keys(merged).length > 0 ? merged : null;
308
+ }
309
+
310
+ var idFn = function(x) { return x; };
311
+ // Build hierarchy with style + source per entry; dedupe consecutive duplicates.
312
+ var hierarchy = [];
313
+ var prevName = null;
314
+ for (var i = 0; i < props.hierarchy.length; i++) {
315
+ var h = props.hierarchy[i];
316
+ var name = h.name;
317
+ if (!name || name === prevName) continue;
318
+ prevName = name;
319
+ var data = h.getInspectorData ? h.getInspectorData(idFn) : null;
320
+ var style = data && data.props ? flattenStyle(data.props.style) : null;
321
+ var entry = { name: name };
322
+ if (style) entry.style = style;
323
+ if (data && data.source && data.source.fileName) {
324
+ entry.source = data.source.fileName + (data.source.lineNumber ? (':' + data.source.lineNumber) : '');
325
+ }
326
+ hierarchy.push(entry);
327
+ }
328
+
329
+ var element = hierarchy.length > 0 ? hierarchy[hierarchy.length - 1].name : 'Unknown';
330
+ var path = hierarchy.map(function(e) { return e.name; }).join(' > ') || element;
331
+
332
+ return {
333
+ element: element,
334
+ path: path,
335
+ frame: props.inspected ? props.inspected.frame : null,
336
+ style: props.inspected ? flattenStyle(props.inspected.style) : null,
337
+ hierarchy: hierarchy,
338
+ selection: props.selection
339
+ };
340
+ })()
341
+ `;
342
+ const readResult = await executeInApp(readExpression, false, {}, device);
343
+ // Step 4: hide the overlay so it doesn't pollute subsequent screenshots.
344
+ // We always hide after a successful capture — agents don't manually toggle.
345
+ const teardownExpression = `
346
+ (function() {
347
+ var ds = globalThis.nativeModuleProxy && globalThis.nativeModuleProxy.DevSettings;
348
+ if (!ds) return { skipped: true };
349
+ var hook = globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__;
350
+ if (!hook) return { skipped: true };
351
+ var roots = [];
352
+ for (var entry of hook.renderers) {
353
+ try { roots = roots.concat(Array.from(hook.getFiberRoots(entry[0]) || [])); } catch(e) {}
354
+ }
355
+ var overlays = 0;
356
+ function walk(f, d) {
357
+ if (!f || d > 800) return;
358
+ if (f.type && typeof f.type !== 'string' &&
359
+ (f.type.displayName || f.type.name) === 'InspectorOverlay') overlays++;
360
+ var c = f.child;
361
+ while (c) { walk(c, d + 1); c = c.sibling; }
362
+ }
363
+ for (var r of roots) { walk(r.current, 0); }
364
+ if (overlays >= 2) {
365
+ try { Object.getPrototypeOf(ds).toggleElementInspector.call(ds); } catch(e) {}
366
+ }
367
+ return { ok: true };
368
+ })()
369
+ `;
370
+ try {
371
+ await executeInApp(teardownExpression, false, {}, device);
372
+ }
373
+ catch {
374
+ /* best-effort hide; don't fail the call */
375
+ }
376
+ return readResult;
377
+ }
378
+ /**
379
+ * Inspect the React component at a specific (x, y) coordinate.
380
+ *
381
+ * Works on both Paper and Fabric (New Architecture). Uses a two-step approach
382
+ * because measureInWindow callbacks fire in a future native event loop tick
383
+ * (not microtasks), so awaitPromise cannot be used to collect them:
384
+ *
385
+ * Step 1 — dispatch: walk the fiber tree, call measureInWindow on each host
386
+ * component, store fiber refs and results in app globals.
387
+ * Step 2 — resolve (after 300ms): read the globals, hit-test against target
388
+ * coordinates, return the innermost matching React component.
389
+ */
390
+ export async function inspectAtPoint(x, y, options = {}) {
391
+ const { includeProps = true, includeFrame = true, device } = options;
392
+ // --- Step 1: walk fiber tree + dispatch measureInWindow calls ---
393
+ const dispatchExpression = `
394
+ (function() {
395
+ var hook = globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__;
396
+ if (!hook) return { error: 'React DevTools hook not available. Make sure you are running a development build.' };
397
+
398
+ var roots = [];
399
+ if (hook.getFiberRoots) {
400
+ try { roots = Array.from(hook.getFiberRoots(1) || []); } catch(e) {}
401
+ }
402
+ if (roots.length === 0 && hook.renderers) {
403
+ for (var entry of hook.renderers) {
404
+ try {
405
+ var r = Array.from(hook.getFiberRoots ? (hook.getFiberRoots(entry[0]) || []) : []);
406
+ if (r.length > 0) { roots = r; break; }
407
+ } catch(e) {}
408
+ }
409
+ }
410
+ if (roots.length === 0) return { error: 'No fiber roots found. The app may not have rendered yet.' };
411
+
412
+ // Paper: measureInWindow is on stateNode directly.
413
+ // Fabric: measureInWindow is on stateNode.canonical.publicInstance.
414
+ function getMeasurable(fiber) {
415
+ var sn = fiber.stateNode;
416
+ if (!sn) return null;
417
+ if (typeof sn.measureInWindow === 'function') return sn;
418
+ if (sn.canonical && sn.canonical.publicInstance &&
419
+ typeof sn.canonical.publicInstance.measureInWindow === 'function') {
420
+ return sn.canonical.publicInstance;
421
+ }
422
+ // Fabric leaf nodes like RCTText have no publicInstance. Measure via
423
+ // the native Fabric UIManager using the shadow node instead — needed
424
+ // for text bounds that are tight around the glyphs (not the scroll
425
+ // container the text happens to live inside).
426
+ if (sn.node && globalThis.nativeFabricUIManager &&
427
+ typeof globalThis.nativeFabricUIManager.measureInWindow === 'function') {
428
+ var node = sn.node;
429
+ return {
430
+ measureInWindow: function(cb) {
431
+ try { globalThis.nativeFabricUIManager.measureInWindow(node, cb); } catch(e) {}
432
+ }
433
+ };
434
+ }
435
+ return null;
436
+ }
437
+
438
+ var hostFibers = [];
439
+ function walkFibers(fiber, depth) {
440
+ var cur = fiber;
441
+ while (cur) {
442
+ if (hostFibers.length >= 500) return;
443
+ if (typeof cur.type === 'string' && getMeasurable(cur)) hostFibers.push(cur);
444
+ if (cur.child && depth < 250) walkFibers(cur.child, depth + 1);
445
+ cur = cur.sibling;
446
+ }
447
+ }
448
+ for (var root of roots) { walkFibers(root.current, 0); }
449
+
450
+ if (hostFibers.length === 0) return { error: 'No measurable host components found. App may not be fully rendered.' };
451
+
452
+ globalThis.__inspectFibers = hostFibers;
453
+ globalThis.__inspectMeasurements = new Array(hostFibers.length).fill(null);
454
+
455
+ hostFibers.forEach(function(fiber, i) {
456
+ try {
457
+ getMeasurable(fiber).measureInWindow(function(fx, fy, fw, fh) {
458
+ globalThis.__inspectMeasurements[i] = { x: fx, y: fy, width: fw, height: fh };
459
+ });
460
+ } catch(e) {}
461
+ });
462
+
463
+ return { count: hostFibers.length };
464
+ })()
465
+ `;
466
+ const dispatchResult = await executeInApp(dispatchExpression, false, {}, device);
467
+ if (!dispatchResult.success)
468
+ return dispatchResult;
469
+ try {
470
+ const parsed = JSON.parse(dispatchResult.result || "{}");
471
+ if (parsed.error)
472
+ return { success: false, error: parsed.error };
473
+ }
474
+ catch {
475
+ /* ignore parse errors */
476
+ }
477
+ // Wait for native measureInWindow callbacks to fire
478
+ await delay(300);
479
+ // --- Step 2: read measurements, hit-test, return result ---
480
+ const resolveExpression = `
481
+ (function() {
482
+ var fibers = globalThis.__inspectFibers;
483
+ var measurements = globalThis.__inspectMeasurements;
484
+ globalThis.__inspectFibers = null;
485
+ globalThis.__inspectMeasurements = null;
486
+
487
+ if (!fibers || !measurements) return { error: 'No measurement data available. Run inspect_at_point again.' };
488
+
489
+ var targetX = ${x};
490
+ var targetY = ${y};
491
+
492
+ var hits = [];
493
+ for (var i = 0; i < measurements.length; i++) {
494
+ var m = measurements[i];
495
+ if (m && m.width > 0 && m.height > 0 &&
496
+ targetX >= m.x && targetX <= m.x + m.width &&
497
+ targetY >= m.y && targetY <= m.y + m.height) {
498
+ hits.push({ fiber: fibers[i], x: m.x, y: m.y, width: m.width, height: m.height });
499
+ }
500
+ }
501
+
502
+ if (hits.length === 0) {
503
+ return { point: { x: targetX, y: targetY }, error: 'No component found at this point. Coordinates may be outside the app bounds or over a native-only element.' };
504
+ }
505
+
506
+ // Smallest area = innermost (most specific) component
507
+ hits.sort(function(a, b) { return (a.width * a.height) - (b.width * b.height); });
508
+ var best = hits[0];
509
+
510
+ // RN primitives and internal components to skip when surfacing the "element" name.
511
+ // We want the nearest *custom* component, not a library wrapper.
512
+ var RN_PRIMITIVES = /^(View|Text|Image|ScrollView|FlatList|SectionList|TextInput|TouchableOpacity|TouchableHighlight|TouchableNativeFeedback|TouchableWithoutFeedback|Pressable|Button|Switch|ActivityIndicator|SafeAreaView|KeyboardAvoidingView|Animated\\(.*|withAnimated.*|ForwardRef.*|memo\\(.*|Context\\.Consumer|Context\\.Provider|VirtualizedList.*|CellRenderer.*|FrameSizeProvider|MaybeScreenContainer|RCT.*|RNS.*|Navigation.*|Screen$|ScreenStack|ScreenContainer|ScreenContentWrapper|SceneView|DelayedFreeze|Freeze|Suspender|DebugContainer|StaticContainer|Expo.*|LinearGradient|ViewManagerAdapter_.*|Svg.*|Defs|Path|Rect|Circle|G|Line|Polygon|Polyline|Ellipse|ClipPath|GestureHandler.*|NativeViewGestureHandler|Reanimated.*|BottomTabNavigator|TabLayout|RouteNode|Route$|MaybeScreen|SafeAreaProvider.*|GestureDetector|PanGestureHandler|DropShadow|BlurView|MaskedView.*)$/;
513
+
514
+ function getNearestNamed(fiber, skipPrimitives) {
515
+ var cur = fiber;
516
+ var fallback = null;
517
+ while (cur) {
518
+ if (cur.type && typeof cur.type !== 'string') {
519
+ var name = cur.type.displayName || cur.type.name;
520
+ if (name) {
521
+ if (!fallback) fallback = { name: name, fiber: cur };
522
+ if (!skipPrimitives || !RN_PRIMITIVES.test(name)) {
523
+ return { name: name, fiber: cur };
524
+ }
525
+ }
526
+ }
527
+ cur = cur.return;
528
+ }
529
+ return fallback;
530
+ }
531
+
532
+ function buildPath(fiber) {
533
+ var path = [];
534
+ var cur = fiber;
535
+ while (cur) {
536
+ if (cur.type) {
537
+ var n = typeof cur.type === 'string'
538
+ ? cur.type
539
+ : (cur.type.displayName || cur.type.name);
540
+ if (n) path.unshift(n);
541
+ }
542
+ cur = cur.return;
543
+ }
544
+ return path.slice(-8).join(' > ');
545
+ }
546
+
547
+ // Find nearest custom component (skipping RN primitives) for the element name,
548
+ // but fall back to the nearest named component if nothing custom is found.
549
+ var named = getNearestNamed(best.fiber.return || best.fiber, true);
550
+ var result = {
551
+ point: { x: targetX, y: targetY },
552
+ element: named ? named.name : best.fiber.type,
553
+ nativeElement: best.fiber.type,
554
+ path: buildPath(best.fiber)
555
+ };
556
+
557
+ if (${includeFrame}) {
558
+ result.frame = { x: best.x, y: best.y, width: best.width, height: best.height };
559
+ }
560
+
561
+ if (${includeProps} && named && named.fiber.memoizedProps) {
562
+ var props = {};
563
+ var keys = Object.keys(named.fiber.memoizedProps);
564
+ for (var i = 0; i < keys.length; i++) {
565
+ var key = keys[i];
566
+ if (key === 'children') continue;
567
+ var val = named.fiber.memoizedProps[key];
568
+ if (typeof val === 'function') {
569
+ props[key] = '[Function]';
570
+ } else if (typeof val === 'object' && val !== null) {
571
+ try {
572
+ var str = JSON.stringify(val);
573
+ props[key] = str.length > 200
574
+ ? (Array.isArray(val) ? '[Array(' + val.length + ')]' : '[Object]')
575
+ : val;
576
+ } catch(e) {
577
+ props[key] = '[Object]';
578
+ }
579
+ } else {
580
+ props[key] = val;
581
+ }
582
+ }
583
+ if (Object.keys(props).length > 0) result.props = props;
584
+ }
585
+
586
+ // Hierarchy: custom-named component for each hit, deduped, innermost→outermost
587
+ var hierarchy = [];
588
+ for (var j = 0; j < Math.min(hits.length, 15); j++) {
589
+ var n2 = getNearestNamed(hits[j].fiber.return, true) || getNearestNamed(hits[j].fiber, true);
590
+ if (n2 && !hierarchy.some(function(h) { return h.name === n2.name; })) {
591
+ hierarchy.push({
592
+ name: n2.name,
593
+ frame: { x: hits[j].x, y: hits[j].y, width: hits[j].width, height: hits[j].height }
594
+ });
595
+ }
596
+ }
597
+ if (hierarchy.length > 1) result.hierarchy = hierarchy;
598
+
599
+ return result;
600
+ })()
601
+ `;
602
+ return executeInApp(resolveExpression, false, {}, device);
603
+ }
604
+ //# sourceMappingURL=inspector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inspector.js","sourceRoot":"","sources":["../../src/core/inspector.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAErD,+EAA+E;AAC/E,mEAAmE;AACnE,+EAA+E;AAE/E;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,MAAe;IACxD,MAAM,UAAU,GAAG;;;;;;;;;;;;;;;;;KAiBlB,CAAC;IAEF,OAAO,YAAY,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;AACvD,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,MAAe;IACnD,MAAM,UAAU,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA6BlB,CAAC;IAEF,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;IACjE,IAAI,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClC,OAAO,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC;IACpC,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,MAAe;IACvD,MAAM,UAAU,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAwElB,CAAC;IAEF,OAAO,YAAY,CAAC,UAAU,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;IACjF,IAAI,CAAC,cAAc,CAAC,OAAO;QAAE,OAAO,cAAc,CAAC;IAEnD,IAAI,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC;QACzD,IAAI,MAAM,CAAC,KAAK;YAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;IACrE,CAAC;IAAC,MAAM,CAAC;QACL,yBAAyB;IAC7B,CAAC;IAED,oDAAoD;IACpD,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IAEjB,6DAA6D;IAC7D,MAAM,iBAAiB,GAAG;;;;;;;;;4BASF,CAAC;4BACD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAmEX,YAAY;;;;kBAIZ,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAwCzB,CAAC;IAEF,OAAO,YAAY,CAAC,iBAAiB,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;AAC9D,CAAC"}
@@ -0,0 +1,61 @@
1
+ import { ExecutionResult, ExecuteOptions } from "./types.js";
2
+ export interface ExpressionValidation {
3
+ valid: boolean;
4
+ expression: string;
5
+ error?: string;
6
+ }
7
+ /**
8
+ * Check if a string contains emoji or other problematic Unicode characters
9
+ * Hermes has issues with certain UTF-16 surrogate pairs (like emoji)
10
+ * @deprecated retained for backward compatibility — escapeNonAsciiInStringLiterals handles this now.
11
+ */
12
+ export declare function containsProblematicUnicode(str: string): boolean;
13
+ /**
14
+ * Strip leading comments from an expression
15
+ * Users often start with // comments which break the (return expr) wrapping
16
+ */
17
+ export declare function stripLeadingComments(expression: string): string;
18
+ /**
19
+ * Validate and preprocess an expression before execution
20
+ * Returns cleaned expression or error with helpful message
21
+ */
22
+ export declare function validateAndPreprocessExpression(expression: string): ExpressionValidation;
23
+ export declare const TIMEOUT_HARD_CAP_MS = 120000;
24
+ export declare function clampTimeoutMs(input: number): {
25
+ value: number;
26
+ clampedFrom?: number;
27
+ };
28
+ export type TransportPattern = "no_apps" | "ws_closed" | "target_closed" | "cdp_eval_too_long";
29
+ export type TransportClassification = {
30
+ kind: "transport";
31
+ pattern: TransportPattern;
32
+ } | {
33
+ kind: "logical";
34
+ };
35
+ /**
36
+ * Classify an error message into transport-vs-logical for auto-reconnect routing.
37
+ *
38
+ * The `source` argument distinguishes the CDP-emitted "Expression took too long"
39
+ * (a stale-target signal we DO want to reconnect on) from the server-side
40
+ * `Promise.race` timer text (a logical "this took too long" we do NOT).
41
+ */
42
+ export declare function classifyTransportError(message: string, source: "cdp" | "server-timer" | "logical"): TransportClassification;
43
+ /**
44
+ * Simple delay helper
45
+ */
46
+ export declare function delay(ms: number): Promise<void>;
47
+ /**
48
+ * One-shot scan-and-retry wrapper on top of executeInAppInner.
49
+ *
50
+ * On first-failure, classifies the error as transport-vs-logical:
51
+ * - transport → call attemptQuickReconnect once, retry with autoReconnect:false
52
+ * to avoid recursion. Successful retries carry _meta.reconnected; surviving
53
+ * failures surface 'reconnected_but_still_failed'.
54
+ * - logical → propagate the original error unchanged.
55
+ *
56
+ * The server-side `timeoutMs` timer always classifies as logical (a too-long
57
+ * expression is not a transport drop), so timeoutMs hits never trigger
58
+ * reconnect.
59
+ */
60
+ export declare function executeInApp(expression: string, awaitPromise?: boolean, options?: ExecuteOptions, device?: string): Promise<ExecutionResult>;
61
+ //# sourceMappingURL=jsExecute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsExecute.d.ts","sourceRoot":"","sources":["../../src/core/jsExecute.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAiB7D,MAAM,WAAW,oBAAoB;IACjC,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,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