react-native-ai-devtools 1.1.4
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/LICENSE +32 -0
- package/README.md +1250 -0
- package/build/__tests__/helpers/fake-cdp-server.d.ts +56 -0
- package/build/__tests__/helpers/fake-cdp-server.d.ts.map +1 -0
- package/build/__tests__/helpers/fake-cdp-server.js +108 -0
- package/build/__tests__/helpers/fake-cdp-server.js.map +1 -0
- package/build/__tests__/integration/connection-health.test.d.ts +2 -0
- package/build/__tests__/integration/connection-health.test.d.ts.map +1 -0
- package/build/__tests__/integration/connection-health.test.js +151 -0
- package/build/__tests__/integration/connection-health.test.js.map +1 -0
- package/build/__tests__/integration/execute-in-app.test.d.ts +2 -0
- package/build/__tests__/integration/execute-in-app.test.d.ts.map +1 -0
- package/build/__tests__/integration/execute-in-app.test.js +115 -0
- package/build/__tests__/integration/execute-in-app.test.js.map +1 -0
- package/build/__tests__/integration/tools.test.d.ts +2 -0
- package/build/__tests__/integration/tools.test.d.ts.map +1 -0
- package/build/__tests__/integration/tools.test.js +228 -0
- package/build/__tests__/integration/tools.test.js.map +1 -0
- package/build/__tests__/setup.d.ts +2 -0
- package/build/__tests__/setup.d.ts.map +1 -0
- package/build/__tests__/setup.js +11 -0
- package/build/__tests__/setup.js.map +1 -0
- package/build/__tests__/unit/bundle.test.d.ts +2 -0
- package/build/__tests__/unit/bundle.test.d.ts.map +1 -0
- package/build/__tests__/unit/bundle.test.js +53 -0
- package/build/__tests__/unit/bundle.test.js.map +1 -0
- package/build/__tests__/unit/connection-health.test.d.ts +2 -0
- package/build/__tests__/unit/connection-health.test.d.ts.map +1 -0
- package/build/__tests__/unit/connection-health.test.js +28 -0
- package/build/__tests__/unit/connection-health.test.js.map +1 -0
- package/build/__tests__/unit/executor.test.d.ts +2 -0
- package/build/__tests__/unit/executor.test.d.ts.map +1 -0
- package/build/__tests__/unit/executor.test.js +79 -0
- package/build/__tests__/unit/executor.test.js.map +1 -0
- package/build/__tests__/unit/logs.test.d.ts +2 -0
- package/build/__tests__/unit/logs.test.d.ts.map +1 -0
- package/build/__tests__/unit/logs.test.js +81 -0
- package/build/__tests__/unit/logs.test.js.map +1 -0
- package/build/__tests__/unit/metro.test.d.ts +2 -0
- package/build/__tests__/unit/metro.test.d.ts.map +1 -0
- package/build/__tests__/unit/metro.test.js +61 -0
- package/build/__tests__/unit/metro.test.js.map +1 -0
- package/build/__tests__/unit/network.test.d.ts +2 -0
- package/build/__tests__/unit/network.test.d.ts.map +1 -0
- package/build/__tests__/unit/network.test.js +102 -0
- package/build/__tests__/unit/network.test.js.map +1 -0
- package/build/__tests__/unit/tap.test.d.ts +2 -0
- package/build/__tests__/unit/tap.test.d.ts.map +1 -0
- package/build/__tests__/unit/tap.test.js +157 -0
- package/build/__tests__/unit/tap.test.js.map +1 -0
- package/build/core/android.d.ts +265 -0
- package/build/core/android.d.ts.map +1 -0
- package/build/core/android.js +1413 -0
- package/build/core/android.js.map +1 -0
- package/build/core/bundle.d.ts +49 -0
- package/build/core/bundle.d.ts.map +1 -0
- package/build/core/bundle.js +368 -0
- package/build/core/bundle.js.map +1 -0
- package/build/core/connection.d.ts +43 -0
- package/build/core/connection.d.ts.map +1 -0
- package/build/core/connection.js +963 -0
- package/build/core/connection.js.map +1 -0
- package/build/core/connectionState.d.ts +108 -0
- package/build/core/connectionState.d.ts.map +1 -0
- package/build/core/connectionState.js +284 -0
- package/build/core/connectionState.js.map +1 -0
- package/build/core/errorScreenParser.d.ts +30 -0
- package/build/core/errorScreenParser.d.ts.map +1 -0
- package/build/core/errorScreenParser.js +198 -0
- package/build/core/errorScreenParser.js.map +1 -0
- package/build/core/executor.d.ts +113 -0
- package/build/core/executor.d.ts.map +1 -0
- package/build/core/executor.js +1877 -0
- package/build/core/executor.js.map +1 -0
- package/build/core/format.d.ts +8 -0
- package/build/core/format.d.ts.map +1 -0
- package/build/core/format.js +34 -0
- package/build/core/format.js.map +1 -0
- package/build/core/guides.d.ts +14 -0
- package/build/core/guides.d.ts.map +1 -0
- package/build/core/guides.js +261 -0
- package/build/core/guides.js.map +1 -0
- package/build/core/httpServer.d.ts +14 -0
- package/build/core/httpServer.d.ts.map +1 -0
- package/build/core/httpServer.js +2459 -0
- package/build/core/httpServer.js.map +1 -0
- package/build/core/httpServerProcess.d.ts +25 -0
- package/build/core/httpServerProcess.d.ts.map +1 -0
- package/build/core/httpServerProcess.js +153 -0
- package/build/core/httpServerProcess.js.map +1 -0
- package/build/core/index.d.ts +25 -0
- package/build/core/index.d.ts.map +1 -0
- package/build/core/index.js +53 -0
- package/build/core/index.js.map +1 -0
- package/build/core/ios.d.ts +214 -0
- package/build/core/ios.d.ts.map +1 -0
- package/build/core/ios.js +1232 -0
- package/build/core/ios.js.map +1 -0
- package/build/core/logs.d.ts +43 -0
- package/build/core/logs.d.ts.map +1 -0
- package/build/core/logs.js +144 -0
- package/build/core/logs.js.map +1 -0
- package/build/core/metro.d.ts +23 -0
- package/build/core/metro.d.ts.map +1 -0
- package/build/core/metro.js +96 -0
- package/build/core/metro.js.map +1 -0
- package/build/core/network.d.ts +43 -0
- package/build/core/network.d.ts.map +1 -0
- package/build/core/network.js +217 -0
- package/build/core/network.js.map +1 -0
- package/build/core/networkInterceptor.d.ts +3 -0
- package/build/core/networkInterceptor.d.ts.map +1 -0
- package/build/core/networkInterceptor.js +203 -0
- package/build/core/networkInterceptor.js.map +1 -0
- package/build/core/ocr.d.ts +69 -0
- package/build/core/ocr.d.ts.map +1 -0
- package/build/core/ocr.js +212 -0
- package/build/core/ocr.js.map +1 -0
- package/build/core/state.d.ts +17 -0
- package/build/core/state.d.ts.map +1 -0
- package/build/core/state.js +50 -0
- package/build/core/state.js.map +1 -0
- package/build/core/tap.d.ts +91 -0
- package/build/core/tap.d.ts.map +1 -0
- package/build/core/tap.js +542 -0
- package/build/core/tap.js.map +1 -0
- package/build/core/telemetry.d.ts +4 -0
- package/build/core/telemetry.d.ts.map +1 -0
- package/build/core/telemetry.js +289 -0
- package/build/core/telemetry.js.map +1 -0
- package/build/core/types.d.ts +134 -0
- package/build/core/types.d.ts.map +1 -0
- package/build/core/types.js +2 -0
- package/build/core/types.js.map +1 -0
- package/build/httpServerStandalone.d.ts +7 -0
- package/build/httpServerStandalone.d.ts.map +1 -0
- package/build/httpServerStandalone.js +31 -0
- package/build/httpServerStandalone.js.map +1 -0
- package/build/index.d.ts +3 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +3012 -0
- package/build/index.js.map +1 -0
- package/build/pro/tap.d.ts +91 -0
- package/build/pro/tap.d.ts.map +1 -0
- package/build/pro/tap.js +542 -0
- package/build/pro/tap.js.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error Screen Parser
|
|
3
|
+
*
|
|
4
|
+
* Parses React Native error screens from OCR text to extract structured error information.
|
|
5
|
+
* Used as fallback when CDP connection cannot be established due to bundle errors.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Parse OCR text from a React Native error screen (red screen of death)
|
|
9
|
+
*
|
|
10
|
+
* Common error formats:
|
|
11
|
+
* - "Unable to resolve \"@/module\" from \"path/to/file.ts\""
|
|
12
|
+
* - "SyntaxError: ..."
|
|
13
|
+
* - "TransformError: ..."
|
|
14
|
+
* - "Error: ..."
|
|
15
|
+
*/
|
|
16
|
+
export function parseErrorScreenText(ocrText) {
|
|
17
|
+
if (!ocrText || ocrText.trim().length === 0) {
|
|
18
|
+
return { found: false };
|
|
19
|
+
}
|
|
20
|
+
const normalizedText = normalizeOcrText(ocrText);
|
|
21
|
+
// Check if this looks like an error screen
|
|
22
|
+
if (!looksLikeErrorScreen(normalizedText)) {
|
|
23
|
+
return { found: false, rawText: ocrText };
|
|
24
|
+
}
|
|
25
|
+
const error = {
|
|
26
|
+
timestamp: new Date(),
|
|
27
|
+
type: "other",
|
|
28
|
+
message: ""
|
|
29
|
+
};
|
|
30
|
+
// Try to parse different error types
|
|
31
|
+
// 1. Module resolution errors: "Unable to resolve \"module\" from \"file\""
|
|
32
|
+
const resolutionMatch = normalizedText.match(/unable\s+to\s+resolve\s+["']([^"']+)["']\s+from\s+["']([^"']+)["']/i);
|
|
33
|
+
if (resolutionMatch) {
|
|
34
|
+
error.type = "resolution";
|
|
35
|
+
error.message = `Unable to resolve "${resolutionMatch[1]}"`;
|
|
36
|
+
error.file = resolutionMatch[2];
|
|
37
|
+
// Try to extract import stack
|
|
38
|
+
error.importStack = extractImportStack(normalizedText);
|
|
39
|
+
return { found: true, error, rawText: ocrText };
|
|
40
|
+
}
|
|
41
|
+
// 2. Syntax errors
|
|
42
|
+
const syntaxMatch = normalizedText.match(/syntax\s*error[:\s]+(.+?)(?:\n|$)/i);
|
|
43
|
+
if (syntaxMatch) {
|
|
44
|
+
error.type = "syntax";
|
|
45
|
+
error.message = `SyntaxError: ${syntaxMatch[1].trim()}`;
|
|
46
|
+
// Try to extract file location
|
|
47
|
+
const locationInfo = extractFileLocation(normalizedText);
|
|
48
|
+
if (locationInfo) {
|
|
49
|
+
error.file = locationInfo.file;
|
|
50
|
+
error.line = locationInfo.line;
|
|
51
|
+
error.column = locationInfo.column;
|
|
52
|
+
}
|
|
53
|
+
return { found: true, error, rawText: ocrText };
|
|
54
|
+
}
|
|
55
|
+
// 3. Transform errors (Babel/Metro transforms)
|
|
56
|
+
const transformMatch = normalizedText.match(/transform\s*error[:\s]+(.+?)(?:\n|$)/i);
|
|
57
|
+
if (transformMatch) {
|
|
58
|
+
error.type = "transform";
|
|
59
|
+
error.message = `TransformError: ${transformMatch[1].trim()}`;
|
|
60
|
+
const locationInfo = extractFileLocation(normalizedText);
|
|
61
|
+
if (locationInfo) {
|
|
62
|
+
error.file = locationInfo.file;
|
|
63
|
+
error.line = locationInfo.line;
|
|
64
|
+
error.column = locationInfo.column;
|
|
65
|
+
}
|
|
66
|
+
return { found: true, error, rawText: ocrText };
|
|
67
|
+
}
|
|
68
|
+
// 4. Generic error pattern: "Error: message"
|
|
69
|
+
const errorMatch = normalizedText.match(/error[:\s]+(.+?)(?:\n|$)/i);
|
|
70
|
+
if (errorMatch) {
|
|
71
|
+
error.message = errorMatch[1].trim();
|
|
72
|
+
const locationInfo = extractFileLocation(normalizedText);
|
|
73
|
+
if (locationInfo) {
|
|
74
|
+
error.file = locationInfo.file;
|
|
75
|
+
error.line = locationInfo.line;
|
|
76
|
+
error.column = locationInfo.column;
|
|
77
|
+
}
|
|
78
|
+
return { found: true, error, rawText: ocrText };
|
|
79
|
+
}
|
|
80
|
+
// 5. Fallback: use the entire text as the error message
|
|
81
|
+
// Truncate if too long
|
|
82
|
+
const maxLength = 500;
|
|
83
|
+
error.message = normalizedText.length > maxLength
|
|
84
|
+
? normalizedText.substring(0, maxLength) + "..."
|
|
85
|
+
: normalizedText;
|
|
86
|
+
return { found: true, error, rawText: ocrText };
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Normalize OCR text by fixing common OCR errors and standardizing whitespace
|
|
90
|
+
*/
|
|
91
|
+
function normalizeOcrText(text) {
|
|
92
|
+
return text
|
|
93
|
+
// Replace multiple whitespace with single space
|
|
94
|
+
.replace(/\s+/g, " ")
|
|
95
|
+
// Fix common OCR misreadings
|
|
96
|
+
.replace(/[|l]mport/gi, "import")
|
|
97
|
+
.replace(/reso[|l]ve/gi, "resolve")
|
|
98
|
+
.replace(/unab[|l]e/gi, "unable")
|
|
99
|
+
.replace(/modu[|l]e/gi, "module")
|
|
100
|
+
// Normalize quotes
|
|
101
|
+
.replace(/[""'']/g, '"')
|
|
102
|
+
.trim();
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Check if OCR text looks like a React Native error screen
|
|
106
|
+
*/
|
|
107
|
+
function looksLikeErrorScreen(text) {
|
|
108
|
+
const lowerText = text.toLowerCase();
|
|
109
|
+
const errorIndicators = [
|
|
110
|
+
"error",
|
|
111
|
+
"unable to resolve",
|
|
112
|
+
"syntax error",
|
|
113
|
+
"transform error",
|
|
114
|
+
"bundling failed",
|
|
115
|
+
"metro has encountered an error",
|
|
116
|
+
"failed to construct",
|
|
117
|
+
"unexpected token",
|
|
118
|
+
"module not found",
|
|
119
|
+
"cannot find module",
|
|
120
|
+
"import stack",
|
|
121
|
+
".tsx",
|
|
122
|
+
".ts",
|
|
123
|
+
".js",
|
|
124
|
+
".jsx"
|
|
125
|
+
];
|
|
126
|
+
return errorIndicators.some(indicator => lowerText.includes(indicator));
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Extract file location (file:line:column) from text
|
|
130
|
+
*/
|
|
131
|
+
function extractFileLocation(text) {
|
|
132
|
+
// Pattern: /path/to/file.tsx:123:45 or /path/to/file.tsx:123
|
|
133
|
+
const locationMatch = text.match(/([a-zA-Z0-9_\-./\\@]+\.(tsx?|jsx?|mjs|cjs)):(\d+)(?::(\d+))?/i);
|
|
134
|
+
if (locationMatch) {
|
|
135
|
+
return {
|
|
136
|
+
file: locationMatch[1],
|
|
137
|
+
line: parseInt(locationMatch[3], 10),
|
|
138
|
+
column: locationMatch[4] ? parseInt(locationMatch[4], 10) : undefined
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
// Try to find just a file path
|
|
142
|
+
const fileMatch = text.match(/([a-zA-Z0-9_\-./\\@]+\.(tsx?|jsx?|mjs|cjs))/i);
|
|
143
|
+
if (fileMatch) {
|
|
144
|
+
return { file: fileMatch[1] };
|
|
145
|
+
}
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Extract import stack from error text
|
|
150
|
+
*/
|
|
151
|
+
function extractImportStack(text) {
|
|
152
|
+
const stack = [];
|
|
153
|
+
// Look for patterns like:
|
|
154
|
+
// - "import from file.tsx"
|
|
155
|
+
// - "app/hooks/useAuth.ts"
|
|
156
|
+
// - file references in the text
|
|
157
|
+
const filePattern = /([a-zA-Z0-9_\-./\\@]+\.(tsx?|jsx?|mjs|cjs))/gi;
|
|
158
|
+
let match;
|
|
159
|
+
while ((match = filePattern.exec(text)) !== null) {
|
|
160
|
+
const file = match[1];
|
|
161
|
+
// Avoid duplicates
|
|
162
|
+
if (!stack.includes(file)) {
|
|
163
|
+
stack.push(file);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return stack.length > 0 ? stack : undefined;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Format parsed error for display
|
|
170
|
+
*/
|
|
171
|
+
export function formatParsedError(parsed) {
|
|
172
|
+
if (!parsed.found || !parsed.error) {
|
|
173
|
+
return "No error detected in screenshot.";
|
|
174
|
+
}
|
|
175
|
+
const { error } = parsed;
|
|
176
|
+
const lines = [];
|
|
177
|
+
lines.push(`[Screenshot OCR] ${error.type.toUpperCase()} ERROR`);
|
|
178
|
+
lines.push(`Message: ${error.message}`);
|
|
179
|
+
if (error.file) {
|
|
180
|
+
let location = `File: ${error.file}`;
|
|
181
|
+
if (error.line) {
|
|
182
|
+
location += `:${error.line}`;
|
|
183
|
+
if (error.column) {
|
|
184
|
+
location += `:${error.column}`;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
lines.push(location);
|
|
188
|
+
}
|
|
189
|
+
if (error.importStack && error.importStack.length > 0) {
|
|
190
|
+
lines.push("\nImport Stack:");
|
|
191
|
+
error.importStack.forEach(imp => {
|
|
192
|
+
lines.push(` - ${imp}`);
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
lines.push("\n(Captured via screenshot OCR fallback)");
|
|
196
|
+
return lines.join("\n");
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=errorScreenParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorScreenParser.js","sourceRoot":"","sources":["../../src/core/errorScreenParser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAaH;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAe;IAChD,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,C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B,KAAK,CAAC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;IACP,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,0CAA0C,CAAC,CAAC;IAEvD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
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
|
+
*/
|
|
11
|
+
export declare function containsProblematicUnicode(str: string): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Strip leading comments from an expression
|
|
14
|
+
* Users often start with // comments which break the (return expr) wrapping
|
|
15
|
+
*/
|
|
16
|
+
export declare function stripLeadingComments(expression: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Validate and preprocess an expression before execution
|
|
19
|
+
* Returns cleaned expression or error with helpful message
|
|
20
|
+
*/
|
|
21
|
+
export declare function validateAndPreprocessExpression(expression: string): ExpressionValidation;
|
|
22
|
+
export declare function executeInApp(expression: string, awaitPromise?: boolean, options?: ExecuteOptions): Promise<ExecutionResult>;
|
|
23
|
+
export declare function listDebugGlobals(): Promise<ExecutionResult>;
|
|
24
|
+
export declare function inspectGlobal(objectName: string): Promise<ExecutionResult>;
|
|
25
|
+
export declare function reloadApp(): Promise<ExecutionResult>;
|
|
26
|
+
/**
|
|
27
|
+
* Get the React component tree from the running app.
|
|
28
|
+
* This traverses the fiber tree to extract component hierarchy with names.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getComponentTree(options?: {
|
|
31
|
+
maxDepth?: number;
|
|
32
|
+
includeProps?: boolean;
|
|
33
|
+
includeStyles?: boolean;
|
|
34
|
+
hideInternals?: boolean;
|
|
35
|
+
format?: "json" | "tonl";
|
|
36
|
+
structureOnly?: boolean;
|
|
37
|
+
focusedOnly?: boolean;
|
|
38
|
+
}): Promise<ExecutionResult>;
|
|
39
|
+
/**
|
|
40
|
+
* Get layout styles for all components on the current screen.
|
|
41
|
+
* Useful for verifying layout without screenshots.
|
|
42
|
+
*/
|
|
43
|
+
export declare function getScreenLayout(options?: {
|
|
44
|
+
maxDepth?: number;
|
|
45
|
+
componentsOnly?: boolean;
|
|
46
|
+
shortPath?: boolean;
|
|
47
|
+
summary?: boolean;
|
|
48
|
+
format?: "json" | "tonl";
|
|
49
|
+
}): Promise<ExecutionResult>;
|
|
50
|
+
/**
|
|
51
|
+
* Inspect a specific component by name, returning its props, state, and layout.
|
|
52
|
+
*/
|
|
53
|
+
export declare function inspectComponent(componentName: string, options?: {
|
|
54
|
+
index?: number;
|
|
55
|
+
includeState?: boolean;
|
|
56
|
+
includeChildren?: boolean;
|
|
57
|
+
childrenDepth?: number;
|
|
58
|
+
shortPath?: boolean;
|
|
59
|
+
simplifyHooks?: boolean;
|
|
60
|
+
}): Promise<ExecutionResult>;
|
|
61
|
+
/**
|
|
62
|
+
* Find all components matching a name pattern and return summary info.
|
|
63
|
+
*/
|
|
64
|
+
export declare function findComponents(pattern: string, options?: {
|
|
65
|
+
maxResults?: number;
|
|
66
|
+
includeLayout?: boolean;
|
|
67
|
+
shortPath?: boolean;
|
|
68
|
+
summary?: boolean;
|
|
69
|
+
format?: "json" | "tonl";
|
|
70
|
+
}): Promise<ExecutionResult>;
|
|
71
|
+
/**
|
|
72
|
+
* Find a pressable element in the React fiber tree and invoke its onPress handler.
|
|
73
|
+
* Matches by text content, testID, or component name.
|
|
74
|
+
*/
|
|
75
|
+
export declare function pressElement(options: {
|
|
76
|
+
text?: string;
|
|
77
|
+
testID?: string;
|
|
78
|
+
component?: string;
|
|
79
|
+
index?: number;
|
|
80
|
+
maxTraversalDepth?: number;
|
|
81
|
+
}): Promise<ExecutionResult>;
|
|
82
|
+
/**
|
|
83
|
+
* Toggle the Element Inspector via DevSettings native module.
|
|
84
|
+
* This enables the inspector overlay programmatically.
|
|
85
|
+
*/
|
|
86
|
+
export declare function toggleElementInspector(): Promise<ExecutionResult>;
|
|
87
|
+
/**
|
|
88
|
+
* Check if the Element Inspector overlay is currently active.
|
|
89
|
+
*/
|
|
90
|
+
export declare function isInspectorActive(): Promise<boolean>;
|
|
91
|
+
/**
|
|
92
|
+
* Get the currently selected element from the Element Inspector overlay.
|
|
93
|
+
* This reads the InspectorPanel component's props to get the hierarchy, frame, and style.
|
|
94
|
+
* Requires the Element Inspector to be enabled and an element to be selected.
|
|
95
|
+
*/
|
|
96
|
+
export declare function getInspectorSelection(): Promise<ExecutionResult>;
|
|
97
|
+
/**
|
|
98
|
+
* Inspect the React component at a specific (x, y) coordinate.
|
|
99
|
+
*
|
|
100
|
+
* Works on both Paper and Fabric (New Architecture). Uses a two-step approach
|
|
101
|
+
* because measureInWindow callbacks fire in a future native event loop tick
|
|
102
|
+
* (not microtasks), so awaitPromise cannot be used to collect them:
|
|
103
|
+
*
|
|
104
|
+
* Step 1 — dispatch: walk the fiber tree, call measureInWindow on each host
|
|
105
|
+
* component, store fiber refs and results in app globals.
|
|
106
|
+
* Step 2 — resolve (after 300ms): read the globals, hit-test against target
|
|
107
|
+
* coordinates, return the innermost matching React component.
|
|
108
|
+
*/
|
|
109
|
+
export declare function inspectAtPoint(x: number, y: number, options?: {
|
|
110
|
+
includeProps?: boolean;
|
|
111
|
+
includeFrame?: boolean;
|
|
112
|
+
}): Promise<ExecutionResult>;
|
|
113
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/core/executor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAc7D,MAAM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