@ceraph/react-native-mcp 0.2.1 → 0.3.1
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 +116 -15
- package/README.md +79 -77
- package/assets/default.png +0 -0
- package/dist/app-lifecycle.d.ts +50 -0
- package/dist/app-lifecycle.js +487 -0
- package/dist/camera-image-writer.d.ts +43 -0
- package/dist/camera-image-writer.js +280 -0
- package/dist/camera-registry-sync.d.ts +18 -0
- package/dist/camera-registry-sync.js +117 -0
- package/dist/cli.d.ts +0 -7
- package/dist/cli.js +41 -9
- package/dist/device-autonomy.d.ts +30 -0
- package/dist/device-autonomy.js +117 -0
- package/dist/error-parser.d.ts +6 -26
- package/dist/error-parser.js +4 -74
- package/dist/expo-manager.d.ts +2 -74
- package/dist/expo-manager.js +11 -125
- package/dist/index.d.ts +0 -7
- package/dist/index.js +1266 -56
- package/dist/init/ast-camera.d.ts +29 -0
- package/dist/init/ast-camera.js +267 -0
- package/dist/init/ast-layout.d.ts +15 -0
- package/dist/init/ast-layout.js +167 -0
- package/dist/init/claude-hook-constants.d.ts +9 -0
- package/dist/init/claude-hook-constants.js +91 -0
- package/dist/init/lan-ip.d.ts +11 -0
- package/dist/init/lan-ip.js +51 -0
- package/dist/init/monorepo.d.ts +13 -0
- package/dist/init/monorepo.js +185 -0
- package/dist/init/oauth.d.ts +52 -0
- package/dist/init/oauth.js +220 -0
- package/dist/init/package-manager.d.ts +11 -0
- package/dist/init/package-manager.js +60 -0
- package/dist/init/prompt.d.ts +12 -0
- package/dist/init/prompt.js +68 -0
- package/dist/init/shell-profile.d.ts +22 -0
- package/dist/init/shell-profile.js +85 -0
- package/dist/init/steps.d.ts +135 -0
- package/dist/init/steps.js +399 -0
- package/dist/init/url-scheme.d.ts +42 -0
- package/dist/init/url-scheme.js +187 -0
- package/dist/init/walkthrough.d.ts +76 -0
- package/dist/init/walkthrough.js +340 -0
- package/dist/init.d.ts +7 -7
- package/dist/init.js +280 -120
- package/dist/iproxy-manager.d.ts +32 -0
- package/dist/iproxy-manager.js +216 -0
- package/dist/mac-caffeinate.d.ts +10 -0
- package/dist/mac-caffeinate.js +56 -0
- package/dist/permission-interceptor.d.ts +29 -0
- package/dist/permission-interceptor.js +185 -0
- package/dist/prebuild-detector.d.ts +0 -30
- package/dist/prebuild-detector.js +1 -42
- package/dist/preflight.d.ts +34 -0
- package/dist/preflight.js +847 -0
- package/dist/screen.d.ts +132 -43
- package/dist/screen.js +668 -94
- package/dist/shim/boot.d.ts +41 -0
- package/dist/shim/boot.js +141 -0
- package/dist/shim/camera.d.ts +22 -0
- package/dist/shim/camera.js +62 -0
- package/dist/shim/config.d.ts +6 -0
- package/dist/shim/config.js +56 -0
- package/dist/shim/deep-link.d.ts +1 -0
- package/dist/shim/deep-link.js +25 -0
- package/dist/shim/dev-guard.d.ts +1 -0
- package/dist/shim/dev-guard.js +3 -0
- package/dist/shim/error-handler.d.ts +20 -0
- package/dist/shim/error-handler.js +66 -0
- package/dist/shim/fetch-interceptor.d.ts +13 -0
- package/dist/shim/fetch-interceptor.js +93 -0
- package/dist/shim/index.d.ts +6 -0
- package/dist/shim/index.js +6 -0
- package/dist/shim/keep-awake.d.ts +13 -0
- package/dist/shim/keep-awake.js +118 -0
- package/dist/shim/reload.d.ts +23 -0
- package/dist/shim/reload.js +76 -0
- package/dist/shim/signal-capture.d.ts +11 -0
- package/dist/shim/signal-capture.js +15 -0
- package/dist/shim/signal-transport.d.ts +17 -0
- package/dist/shim/signal-transport.js +43 -0
- package/dist/signal-listener.d.ts +27 -0
- package/dist/signal-listener.js +135 -0
- package/dist/simulator-boot.d.ts +52 -0
- package/dist/simulator-boot.js +227 -0
- package/dist/target.d.ts +48 -0
- package/dist/target.js +267 -0
- package/dist/uninstall/cli-runner.d.ts +32 -0
- package/dist/uninstall/cli-runner.js +223 -0
- package/dist/uninstall/footprint.d.ts +40 -0
- package/dist/uninstall/footprint.js +288 -0
- package/dist/uninstall/mcp-tools.d.ts +14 -0
- package/dist/uninstall/mcp-tools.js +175 -0
- package/dist/uninstall/revert-auth.d.ts +22 -0
- package/dist/uninstall/revert-auth.js +31 -0
- package/dist/uninstall/revert-boot.d.ts +24 -0
- package/dist/uninstall/revert-boot.js +242 -0
- package/dist/uninstall/revert-camera.d.ts +12 -0
- package/dist/uninstall/revert-camera.js +199 -0
- package/dist/uninstall/revert-ceraph-dir.d.ts +27 -0
- package/dist/uninstall/revert-ceraph-dir.js +38 -0
- package/dist/uninstall/revert-claude-hooks.d.ts +19 -0
- package/dist/uninstall/revert-claude-hooks.js +191 -0
- package/dist/uninstall/revert-gitignore.d.ts +17 -0
- package/dist/uninstall/revert-gitignore.js +43 -0
- package/dist/uninstall/revert-mcp-clients.d.ts +57 -0
- package/dist/uninstall/revert-mcp-clients.js +194 -0
- package/dist/uninstall/revert-package.d.ts +34 -0
- package/dist/uninstall/revert-package.js +98 -0
- package/dist/uninstall/revert-scheme.d.ts +36 -0
- package/dist/uninstall/revert-scheme.js +139 -0
- package/dist/uninstall/revert-signal-host-env.d.ts +31 -0
- package/dist/uninstall/revert-signal-host-env.js +61 -0
- package/dist/uninstall/walkthrough.d.ts +80 -0
- package/dist/uninstall/walkthrough.js +1244 -0
- package/dist/utils/atomic-write.d.ts +1 -0
- package/dist/utils/atomic-write.js +30 -0
- package/dist/wait-for-device.d.ts +68 -0
- package/dist/wait-for-device.js +368 -0
- package/dist/wda-manager.d.ts +38 -0
- package/dist/wda-manager.js +186 -0
- package/dist/wda-simulator.d.ts +28 -0
- package/dist/wda-simulator.js +257 -0
- package/package.json +38 -5
package/dist/error-parser.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parses Xcode build errors, Metro bundler errors, and runtime errors
|
|
3
|
-
* from raw process output.
|
|
4
|
-
*/
|
|
5
1
|
export interface BuildError {
|
|
6
2
|
file: string;
|
|
7
3
|
line: number;
|
|
@@ -10,10 +6,16 @@ export interface BuildError {
|
|
|
10
6
|
severity: "error" | "warning" | "note";
|
|
11
7
|
type: "build" | "link" | "pod";
|
|
12
8
|
}
|
|
9
|
+
export type RuntimeSignalKind = "metro-error" | "js-error" | "unhandled-rejection" | "network-error" | "network-4xx";
|
|
13
10
|
export interface RuntimeError {
|
|
14
11
|
message: string;
|
|
15
12
|
stack: string;
|
|
16
13
|
timestamp: string;
|
|
14
|
+
kind?: RuntimeSignalKind;
|
|
15
|
+
url?: string;
|
|
16
|
+
status?: number;
|
|
17
|
+
method?: string;
|
|
18
|
+
durationMs?: number;
|
|
17
19
|
}
|
|
18
20
|
export interface Warning {
|
|
19
21
|
message: string;
|
|
@@ -24,21 +26,11 @@ export interface AllErrors {
|
|
|
24
26
|
runtimeErrors: RuntimeError[];
|
|
25
27
|
warnings: Warning[];
|
|
26
28
|
}
|
|
27
|
-
/**
|
|
28
|
-
* Parse all build output lines and extract structured errors.
|
|
29
|
-
*/
|
|
30
29
|
export declare function parseBuildOutput(lines: string[]): {
|
|
31
30
|
errors: BuildError[];
|
|
32
31
|
warnings: Warning[];
|
|
33
32
|
buildFailed: boolean;
|
|
34
33
|
};
|
|
35
|
-
/**
|
|
36
|
-
* Stateful parser for Metro output. Multi-line errors (message + stack
|
|
37
|
-
* trace) arrive across multiple `onData` chunks, so the in-progress
|
|
38
|
-
* error must persist across calls. Use one instance per Metro session
|
|
39
|
-
* and call `parse(lines)` as chunks arrive; call `flush()` at the end
|
|
40
|
-
* (e.g. on process exit) to emit any error still being assembled.
|
|
41
|
-
*/
|
|
42
34
|
export declare class MetroErrorParser {
|
|
43
35
|
private currentStack;
|
|
44
36
|
private currentErrorMessage;
|
|
@@ -47,25 +39,13 @@ export declare class MetroErrorParser {
|
|
|
47
39
|
runtimeErrors: RuntimeError[];
|
|
48
40
|
warnings: Warning[];
|
|
49
41
|
};
|
|
50
|
-
/**
|
|
51
|
-
* Force-emit any error currently being assembled. Call on stream end.
|
|
52
|
-
*/
|
|
53
42
|
flush(): {
|
|
54
43
|
runtimeErrors: RuntimeError[];
|
|
55
44
|
warnings: Warning[];
|
|
56
45
|
};
|
|
57
46
|
}
|
|
58
|
-
/**
|
|
59
|
-
* Parse a complete Metro buffer in one shot. Suitable for batch use
|
|
60
|
-
* (e.g. `getErrors()` re-parsing the rolling buffer); for streaming use
|
|
61
|
-
* a `MetroErrorParser` instance instead so multi-line state survives
|
|
62
|
-
* across chunks.
|
|
63
|
-
*/
|
|
64
47
|
export declare function parseMetroOutput(lines: string[]): {
|
|
65
48
|
runtimeErrors: RuntimeError[];
|
|
66
49
|
warnings: Warning[];
|
|
67
50
|
};
|
|
68
|
-
/**
|
|
69
|
-
* Classify a log line by level.
|
|
70
|
-
*/
|
|
71
51
|
export declare function classifyLogLevel(line: string): "error" | "warn" | "log";
|
package/dist/error-parser.js
CHANGED
|
@@ -1,33 +1,20 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parses Xcode build errors, Metro bundler errors, and runtime errors
|
|
3
|
-
* from raw process output.
|
|
4
|
-
*/
|
|
5
|
-
// Xcode-style: /path/to/File.swift:12:5: error: something went wrong
|
|
6
1
|
const XCODE_ERROR_RE = /^(.+?):(\d+):(\d+):\s*(error|warning|note):\s*(.+)$/;
|
|
7
|
-
// Xcode build failure markers
|
|
8
2
|
const BUILD_FAILED_MARKERS = [
|
|
9
3
|
"Build Failed",
|
|
10
4
|
"** BUILD FAILED **",
|
|
11
5
|
"xcodebuild: error:",
|
|
12
6
|
"❌",
|
|
13
7
|
];
|
|
14
|
-
// Linker errors
|
|
15
8
|
const LINKER_ERROR_RE = /^(ld|clang):\s*(error|warning):\s*(.+)$/;
|
|
16
9
|
const UNDEFINED_SYMBOL_RE = /^Undefined symbols? for architecture .+:\s*"(.+)"/;
|
|
17
|
-
// CocoaPods errors
|
|
18
10
|
const POD_ERROR_RE = /^\[!\]\s*(.+)$/;
|
|
19
|
-
// Metro bundler errors
|
|
20
11
|
const METRO_ERROR_RE = /^(Error|TypeError|ReferenceError|SyntaxError|RangeError):\s*(.+)$/;
|
|
21
12
|
const METRO_MODULE_RE = /Unable to resolve module ['"](.+?)['"]/;
|
|
22
13
|
const METRO_ENCOUNTERED_RE = /Metro has encountered an error/;
|
|
23
|
-
// Runtime errors from console
|
|
24
14
|
const CONSOLE_ERROR_RE = /^(ERROR|console\.error)\s*(.+)$/i;
|
|
25
15
|
const INVARIANT_RE = /Invariant Violation:\s*(.+)/;
|
|
26
16
|
const UNHANDLED_JS_RE = /Unhandled JS Exception:\s*(.+)/;
|
|
27
17
|
const RED_SCREEN_RE = /ExceptionsManager\.js/;
|
|
28
|
-
/**
|
|
29
|
-
* Parse a single line for Xcode build errors/warnings.
|
|
30
|
-
*/
|
|
31
18
|
function parseXcodeLine(line) {
|
|
32
19
|
const match = line.match(XCODE_ERROR_RE);
|
|
33
20
|
if (match) {
|
|
@@ -42,9 +29,6 @@ function parseXcodeLine(line) {
|
|
|
42
29
|
}
|
|
43
30
|
return null;
|
|
44
31
|
}
|
|
45
|
-
/**
|
|
46
|
-
* Parse a single line for linker errors.
|
|
47
|
-
*/
|
|
48
32
|
function parseLinkerLine(line) {
|
|
49
33
|
const linkerMatch = line.match(LINKER_ERROR_RE);
|
|
50
34
|
if (linkerMatch) {
|
|
@@ -70,17 +54,6 @@ function parseLinkerLine(line) {
|
|
|
70
54
|
}
|
|
71
55
|
return null;
|
|
72
56
|
}
|
|
73
|
-
/**
|
|
74
|
-
* Parse a single line for CocoaPods notices.
|
|
75
|
-
*
|
|
76
|
-
* CocoaPods uses the `[!]` prefix for both errors and warnings. Default
|
|
77
|
-
* to `error` and only downgrade when the message matches a known-safe
|
|
78
|
-
* pattern (target overrides, deprecation hints, CDN/repo update notices,
|
|
79
|
-
* advisory "should" / "recommends" copy). This is closed under unknown
|
|
80
|
-
* failure modes — a new pod error vocabulary stays classified as an error
|
|
81
|
-
* rather than silently becoming a warning that lets a broken build
|
|
82
|
-
* resolve as success.
|
|
83
|
-
*/
|
|
84
57
|
const POD_SAFE_WARNING_RE = /\b(cdn|trunk|repo update|overrides the|setting defined in|deprecated|recommends|should)\b/i;
|
|
85
58
|
function parsePodLine(line) {
|
|
86
59
|
const match = line.match(POD_ERROR_RE);
|
|
@@ -97,16 +70,10 @@ function parsePodLine(line) {
|
|
|
97
70
|
type: "pod",
|
|
98
71
|
};
|
|
99
72
|
}
|
|
100
|
-
/**
|
|
101
|
-
* Parse all build output lines and extract structured errors.
|
|
102
|
-
*/
|
|
103
73
|
export function parseBuildOutput(lines) {
|
|
104
74
|
const errors = [];
|
|
105
75
|
const warnings = [];
|
|
106
76
|
let buildFailed = false;
|
|
107
|
-
// Track multi-line error context: sometimes Xcode emits the error
|
|
108
|
-
// on one line and the source context on the next few lines.
|
|
109
|
-
// We append context to the last error's message.
|
|
110
77
|
let lastError = null;
|
|
111
78
|
let contextLines = 0;
|
|
112
79
|
const MAX_CONTEXT = 3;
|
|
@@ -117,11 +84,9 @@ export function parseBuildOutput(lines) {
|
|
|
117
84
|
contextLines = 0;
|
|
118
85
|
continue;
|
|
119
86
|
}
|
|
120
|
-
// Check for build failure markers
|
|
121
87
|
if (BUILD_FAILED_MARKERS.some((m) => trimmed.includes(m))) {
|
|
122
88
|
buildFailed = true;
|
|
123
89
|
}
|
|
124
|
-
// Try Xcode error format
|
|
125
90
|
const xcodeError = parseXcodeLine(trimmed);
|
|
126
91
|
if (xcodeError) {
|
|
127
92
|
if (xcodeError.severity === "error") {
|
|
@@ -134,11 +99,9 @@ export function parseBuildOutput(lines) {
|
|
|
134
99
|
message: xcodeError.message,
|
|
135
100
|
source: `${xcodeError.file}:${xcodeError.line}:${xcodeError.column}`,
|
|
136
101
|
});
|
|
137
|
-
// Don't set lastError for warnings/notes
|
|
138
102
|
}
|
|
139
103
|
continue;
|
|
140
104
|
}
|
|
141
|
-
// Try linker error format
|
|
142
105
|
const linkerError = parseLinkerLine(trimmed);
|
|
143
106
|
if (linkerError) {
|
|
144
107
|
if (linkerError.severity === "warning") {
|
|
@@ -151,7 +114,6 @@ export function parseBuildOutput(lines) {
|
|
|
151
114
|
contextLines = 0;
|
|
152
115
|
continue;
|
|
153
116
|
}
|
|
154
|
-
// Try CocoaPods notice format (warning or error depending on message)
|
|
155
117
|
const podNotice = parsePodLine(trimmed);
|
|
156
118
|
if (podNotice) {
|
|
157
119
|
if (podNotice.severity === "warning") {
|
|
@@ -164,7 +126,6 @@ export function parseBuildOutput(lines) {
|
|
|
164
126
|
}
|
|
165
127
|
continue;
|
|
166
128
|
}
|
|
167
|
-
// Append context lines to last error for multi-line messages
|
|
168
129
|
if (lastError && contextLines < MAX_CONTEXT) {
|
|
169
130
|
lastError.message += `\n${trimmed}`;
|
|
170
131
|
contextLines++;
|
|
@@ -172,13 +133,6 @@ export function parseBuildOutput(lines) {
|
|
|
172
133
|
}
|
|
173
134
|
return { errors, warnings, buildFailed };
|
|
174
135
|
}
|
|
175
|
-
/**
|
|
176
|
-
* Stateful parser for Metro output. Multi-line errors (message + stack
|
|
177
|
-
* trace) arrive across multiple `onData` chunks, so the in-progress
|
|
178
|
-
* error must persist across calls. Use one instance per Metro session
|
|
179
|
-
* and call `parse(lines)` as chunks arrive; call `flush()` at the end
|
|
180
|
-
* (e.g. on process exit) to emit any error still being assembled.
|
|
181
|
-
*/
|
|
182
136
|
export class MetroErrorParser {
|
|
183
137
|
currentStack = [];
|
|
184
138
|
currentErrorMessage = "";
|
|
@@ -192,6 +146,7 @@ export class MetroErrorParser {
|
|
|
192
146
|
message: this.currentErrorMessage,
|
|
193
147
|
stack: this.currentStack.join("\n"),
|
|
194
148
|
timestamp: new Date().toISOString(),
|
|
149
|
+
kind: "metro-error",
|
|
195
150
|
});
|
|
196
151
|
this.currentErrorMessage = "";
|
|
197
152
|
this.currentStack = [];
|
|
@@ -200,7 +155,6 @@ export class MetroErrorParser {
|
|
|
200
155
|
};
|
|
201
156
|
for (const line of lines) {
|
|
202
157
|
const trimmed = line.trim();
|
|
203
|
-
// Metro module resolution errors — single-line, emit immediately.
|
|
204
158
|
const moduleMatch = trimmed.match(METRO_MODULE_RE);
|
|
205
159
|
if (moduleMatch) {
|
|
206
160
|
flushInto(runtimeErrors);
|
|
@@ -208,17 +162,16 @@ export class MetroErrorParser {
|
|
|
208
162
|
message: `Unable to resolve module '${moduleMatch[1]}'`,
|
|
209
163
|
stack: trimmed,
|
|
210
164
|
timestamp: new Date().toISOString(),
|
|
165
|
+
kind: "metro-error",
|
|
211
166
|
});
|
|
212
167
|
continue;
|
|
213
168
|
}
|
|
214
|
-
// Metro encountered an error
|
|
215
169
|
if (METRO_ENCOUNTERED_RE.test(trimmed)) {
|
|
216
170
|
flushInto(runtimeErrors);
|
|
217
171
|
this.currentErrorMessage = "Metro has encountered an error";
|
|
218
172
|
this.inStackTrace = true;
|
|
219
173
|
continue;
|
|
220
174
|
}
|
|
221
|
-
// Invariant Violation
|
|
222
175
|
const invariantMatch = trimmed.match(INVARIANT_RE);
|
|
223
176
|
if (invariantMatch) {
|
|
224
177
|
flushInto(runtimeErrors);
|
|
@@ -226,7 +179,6 @@ export class MetroErrorParser {
|
|
|
226
179
|
this.inStackTrace = true;
|
|
227
180
|
continue;
|
|
228
181
|
}
|
|
229
|
-
// Unhandled JS Exception
|
|
230
182
|
const unhandledMatch = trimmed.match(UNHANDLED_JS_RE);
|
|
231
183
|
if (unhandledMatch) {
|
|
232
184
|
flushInto(runtimeErrors);
|
|
@@ -234,7 +186,6 @@ export class MetroErrorParser {
|
|
|
234
186
|
this.inStackTrace = true;
|
|
235
187
|
continue;
|
|
236
188
|
}
|
|
237
|
-
// JS error types
|
|
238
189
|
const metroMatch = trimmed.match(METRO_ERROR_RE);
|
|
239
190
|
if (metroMatch) {
|
|
240
191
|
flushInto(runtimeErrors);
|
|
@@ -242,7 +193,6 @@ export class MetroErrorParser {
|
|
|
242
193
|
this.inStackTrace = true;
|
|
243
194
|
continue;
|
|
244
195
|
}
|
|
245
|
-
// Console errors
|
|
246
196
|
const consoleMatch = trimmed.match(CONSOLE_ERROR_RE);
|
|
247
197
|
if (consoleMatch) {
|
|
248
198
|
flushInto(runtimeErrors);
|
|
@@ -250,20 +200,17 @@ export class MetroErrorParser {
|
|
|
250
200
|
this.inStackTrace = true;
|
|
251
201
|
continue;
|
|
252
202
|
}
|
|
253
|
-
// Red screen detection
|
|
254
203
|
if (RED_SCREEN_RE.test(trimmed)) {
|
|
255
204
|
if (!this.currentErrorMessage) {
|
|
256
205
|
this.currentErrorMessage = "Red screen error detected";
|
|
257
206
|
}
|
|
258
207
|
this.inStackTrace = true;
|
|
259
208
|
}
|
|
260
|
-
// Stack trace lines (indented, or starting with "at ")
|
|
261
209
|
if (this.inStackTrace) {
|
|
262
210
|
if (trimmed.startsWith("at ") ||
|
|
263
211
|
trimmed.startsWith("in ") ||
|
|
264
212
|
/^\s+at\s/.test(line) ||
|
|
265
|
-
/^\d+\s*\|/.test(trimmed)
|
|
266
|
-
) {
|
|
213
|
+
/^\d+\s*\|/.test(trimmed)) {
|
|
267
214
|
this.currentStack.push(trimmed);
|
|
268
215
|
continue;
|
|
269
216
|
}
|
|
@@ -272,14 +219,10 @@ export class MetroErrorParser {
|
|
|
272
219
|
continue;
|
|
273
220
|
}
|
|
274
221
|
else {
|
|
275
|
-
// Continuation of the error message. Skip the warning check —
|
|
276
|
-
// a `warn ...` line interleaved with a stack trace would
|
|
277
|
-
// otherwise be double-counted as both stack and warning.
|
|
278
222
|
this.currentStack.push(trimmed);
|
|
279
223
|
continue;
|
|
280
224
|
}
|
|
281
225
|
}
|
|
282
|
-
// Warnings from Metro
|
|
283
226
|
if (/^warn\s/i.test(trimmed) || /\(WARN\)/.test(trimmed)) {
|
|
284
227
|
warnings.push({
|
|
285
228
|
message: trimmed.replace(/^warn\s*/i, "").replace(/\(WARN\)\s*/, ""),
|
|
@@ -287,13 +230,8 @@ export class MetroErrorParser {
|
|
|
287
230
|
});
|
|
288
231
|
}
|
|
289
232
|
}
|
|
290
|
-
// Do NOT flush at end of chunk — the in-progress error may continue
|
|
291
|
-
// in the next chunk. Caller must invoke `flush()` when the stream ends.
|
|
292
233
|
return { runtimeErrors, warnings };
|
|
293
234
|
}
|
|
294
|
-
/**
|
|
295
|
-
* Force-emit any error currently being assembled. Call on stream end.
|
|
296
|
-
*/
|
|
297
235
|
flush() {
|
|
298
236
|
const runtimeErrors = [];
|
|
299
237
|
if (this.currentErrorMessage) {
|
|
@@ -301,6 +239,7 @@ export class MetroErrorParser {
|
|
|
301
239
|
message: this.currentErrorMessage,
|
|
302
240
|
stack: this.currentStack.join("\n"),
|
|
303
241
|
timestamp: new Date().toISOString(),
|
|
242
|
+
kind: "metro-error",
|
|
304
243
|
});
|
|
305
244
|
this.currentErrorMessage = "";
|
|
306
245
|
this.currentStack = [];
|
|
@@ -309,12 +248,6 @@ export class MetroErrorParser {
|
|
|
309
248
|
return { runtimeErrors, warnings: [] };
|
|
310
249
|
}
|
|
311
250
|
}
|
|
312
|
-
/**
|
|
313
|
-
* Parse a complete Metro buffer in one shot. Suitable for batch use
|
|
314
|
-
* (e.g. `getErrors()` re-parsing the rolling buffer); for streaming use
|
|
315
|
-
* a `MetroErrorParser` instance instead so multi-line state survives
|
|
316
|
-
* across chunks.
|
|
317
|
-
*/
|
|
318
251
|
export function parseMetroOutput(lines) {
|
|
319
252
|
const parser = new MetroErrorParser();
|
|
320
253
|
const streamed = parser.parse(lines);
|
|
@@ -324,9 +257,6 @@ export function parseMetroOutput(lines) {
|
|
|
324
257
|
warnings: [...streamed.warnings, ...flushed.warnings],
|
|
325
258
|
};
|
|
326
259
|
}
|
|
327
|
-
/**
|
|
328
|
-
* Classify a log line by level.
|
|
329
|
-
*/
|
|
330
260
|
export function classifyLogLevel(line) {
|
|
331
261
|
const trimmed = line.trim().toLowerCase();
|
|
332
262
|
if (trimmed.startsWith("error") ||
|
package/dist/expo-manager.d.ts
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Manages React Native / Expo child processes (build and Metro dev server).
|
|
3
|
-
* Auto-detects whether the project uses Expo or bare React Native
|
|
4
|
-
* and runs the appropriate commands.
|
|
5
|
-
* Captures stdout/stderr into rolling buffers and parses errors.
|
|
6
|
-
*/
|
|
7
|
-
import { type Warning, type AllErrors } from "./error-parser.js";
|
|
1
|
+
import { type RuntimeError, type Warning, type AllErrors } from "./error-parser.js";
|
|
8
2
|
export interface BuildResult {
|
|
9
3
|
success: boolean;
|
|
10
4
|
errors: Array<{
|
|
@@ -43,92 +37,26 @@ export declare class RNManager {
|
|
|
43
37
|
private readonly MAX_BUILD_LINES;
|
|
44
38
|
private readonly MAX_METRO_LINES;
|
|
45
39
|
private readonly MAX_ERRORS;
|
|
46
|
-
/** The working directory for commands. */
|
|
47
40
|
private cwd;
|
|
48
|
-
/** Path to the error file that triggers the Claude Code hook. */
|
|
49
41
|
private errorFilePath;
|
|
50
42
|
constructor(cwd: string);
|
|
51
|
-
/**
|
|
52
|
-
* Detect whether this is an Expo or bare React Native project.
|
|
53
|
-
* Checks for app.json with expo config or expo package in dependencies.
|
|
54
|
-
*/
|
|
55
43
|
detectProjectType(): Promise<boolean>;
|
|
56
|
-
/**
|
|
57
|
-
* Write errors to .rn-errors.json so the Claude Code hook can detect them.
|
|
58
|
-
* Overwrites the file each time — the hook fires on any write.
|
|
59
|
-
*/
|
|
60
44
|
private writeErrorFile;
|
|
61
|
-
|
|
62
|
-
* Clear the error file (e.g., on successful build or process start).
|
|
63
|
-
*/
|
|
45
|
+
appendShimSignal(entry: RuntimeError): Promise<void>;
|
|
64
46
|
private clearErrorFile;
|
|
65
|
-
/**
|
|
66
|
-
* Append a line to a rolling buffer, evicting oldest entries when full.
|
|
67
|
-
*/
|
|
68
47
|
private pushLine;
|
|
69
|
-
/**
|
|
70
|
-
* Cap an error array at MAX_ERRORS, dropping oldest entries.
|
|
71
|
-
*/
|
|
72
48
|
private capErrors;
|
|
73
|
-
/**
|
|
74
|
-
* Kill a child process gracefully (SIGTERM, then SIGKILL after timeout).
|
|
75
|
-
*
|
|
76
|
-
* The promise resolves only when the process actually exits, not when
|
|
77
|
-
* SIGKILL is sent. Resolving on the SIGKILL timer was a race: callers
|
|
78
|
-
* (e.g. `runBuild`) would spawn a new build while the old Xcode process
|
|
79
|
-
* was still releasing DerivedData / build locks, causing cryptic
|
|
80
|
-
* SIGABRT or "file locked" errors on the new build.
|
|
81
|
-
*
|
|
82
|
-
* A hard upper-bound timer (2s after SIGKILL) guards against the
|
|
83
|
-
* pathological case where a process refuses to die at all, so callers
|
|
84
|
-
* never hang forever.
|
|
85
|
-
*/
|
|
86
49
|
private killProcess;
|
|
87
|
-
/**
|
|
88
|
-
* Run `npx expo prebuild --clean` synchronously (waits for exit).
|
|
89
|
-
*/
|
|
90
50
|
private runPrebuildClean;
|
|
91
|
-
/**
|
|
92
|
-
* Build and run the app on an iOS device or simulator.
|
|
93
|
-
* Auto-detects Expo vs bare React Native and uses the appropriate command:
|
|
94
|
-
* - Expo: `npx expo run:ios`
|
|
95
|
-
* - Bare RN: `npx react-native run-ios`
|
|
96
|
-
*
|
|
97
|
-
* Optionally runs `npx expo prebuild --clean` first (Expo only).
|
|
98
|
-
*/
|
|
99
51
|
runBuild(options?: RunBuildOptions): Promise<BuildResult>;
|
|
100
|
-
/**
|
|
101
|
-
* Start the Metro dev server.
|
|
102
|
-
* Auto-detects Expo vs bare React Native:
|
|
103
|
-
* - Expo: `npx expo start --dev-client`
|
|
104
|
-
* - Bare RN: `npx react-native start`
|
|
105
|
-
*
|
|
106
|
-
* Spawns Metro in the background and continuously captures output.
|
|
107
|
-
* Returns quickly once Metro shows signs of being ready (or after a timeout).
|
|
108
|
-
*/
|
|
109
52
|
startMetro(options?: StartMetroOptions): Promise<{
|
|
110
53
|
success: boolean;
|
|
111
54
|
message: string;
|
|
112
55
|
}>;
|
|
113
|
-
/**
|
|
114
|
-
* Return all captured errors from both build and runtime contexts.
|
|
115
|
-
*/
|
|
116
56
|
getErrors(): AllErrors;
|
|
117
|
-
/**
|
|
118
|
-
* Return recent console output from Metro, optionally filtered by level.
|
|
119
|
-
*/
|
|
120
57
|
getConsole(options?: ConsoleOptions): string[];
|
|
121
|
-
/**
|
|
122
|
-
* Stop all managed Expo processes.
|
|
123
|
-
*/
|
|
124
58
|
stopAll(): Promise<string[]>;
|
|
125
|
-
/**
|
|
126
|
-
* Get the raw build output buffer (for diagnostics).
|
|
127
|
-
*/
|
|
128
59
|
getBuildOutput(): string[];
|
|
129
|
-
/**
|
|
130
|
-
* Get the raw metro output buffer (for diagnostics).
|
|
131
|
-
*/
|
|
132
60
|
getMetroOutput(): string[];
|
|
133
61
|
}
|
|
134
62
|
export {};
|