react-native-mcp-kit 3.0.1 → 4.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 +22 -10
- package/dist/bin/ios-hid +0 -0
- package/dist/client/contexts/McpContext/McpProvider.d.ts.map +1 -1
- package/dist/client/contexts/McpContext/McpProvider.js +5 -5
- package/dist/client/contexts/McpContext/McpProvider.js.map +1 -1
- package/dist/client/core/McpClient.d.ts.map +1 -1
- package/dist/client/core/McpClient.js +26 -32
- package/dist/client/core/McpClient.js.map +1 -1
- package/dist/modules/alert/alert.d.ts.map +1 -1
- package/dist/modules/alert/alert.js +2 -5
- package/dist/modules/alert/alert.js.map +1 -1
- package/dist/modules/console/console.d.ts.map +1 -1
- package/dist/modules/console/console.js +32 -107
- package/dist/modules/console/console.js.map +1 -1
- package/dist/modules/console/types.d.ts +1 -0
- package/dist/modules/console/types.d.ts.map +1 -1
- package/dist/modules/device/device.d.ts.map +1 -1
- package/dist/modules/device/device.js +224 -133
- package/dist/modules/device/device.js.map +1 -1
- package/dist/modules/errors/errors.d.ts.map +1 -1
- package/dist/modules/errors/errors.js +19 -36
- package/dist/modules/errors/errors.js.map +1 -1
- package/dist/modules/fiberTree/children.d.ts +49 -0
- package/dist/modules/fiberTree/children.d.ts.map +1 -0
- package/dist/modules/fiberTree/children.js +182 -0
- package/dist/modules/fiberTree/children.js.map +1 -0
- package/dist/modules/fiberTree/constants.d.ts +13 -0
- package/dist/modules/fiberTree/constants.d.ts.map +1 -0
- package/dist/modules/fiberTree/constants.js +24 -0
- package/dist/modules/fiberTree/constants.js.map +1 -0
- package/dist/modules/fiberTree/fiberTree.d.ts +3 -6
- package/dist/modules/fiberTree/fiberTree.d.ts.map +1 -1
- package/dist/modules/fiberTree/fiberTree.js +219 -1080
- package/dist/modules/fiberTree/fiberTree.js.map +1 -1
- package/dist/modules/fiberTree/finder.d.ts +60 -0
- package/dist/modules/fiberTree/finder.d.ts.map +1 -0
- package/dist/modules/fiberTree/finder.js +107 -0
- package/dist/modules/fiberTree/finder.js.map +1 -0
- package/dist/modules/fiberTree/hooks.d.ts +103 -0
- package/dist/modules/fiberTree/hooks.d.ts.map +1 -0
- package/dist/modules/fiberTree/hooks.js +532 -0
- package/dist/modules/fiberTree/hooks.js.map +1 -0
- package/dist/modules/fiberTree/projection.d.ts +49 -0
- package/dist/modules/fiberTree/projection.d.ts.map +1 -0
- package/dist/modules/fiberTree/projection.js +82 -0
- package/dist/modules/fiberTree/projection.js.map +1 -0
- package/dist/modules/fiberTree/query.d.ts +56 -0
- package/dist/modules/fiberTree/query.d.ts.map +1 -0
- package/dist/modules/fiberTree/query.js +151 -0
- package/dist/modules/fiberTree/query.js.map +1 -0
- package/dist/modules/fiberTree/redact.d.ts +24 -0
- package/dist/modules/fiberTree/redact.d.ts.map +1 -0
- package/dist/modules/fiberTree/redact.js +51 -0
- package/dist/modules/fiberTree/redact.js.map +1 -0
- package/dist/modules/fiberTree/types.d.ts +7 -0
- package/dist/modules/fiberTree/types.d.ts.map +1 -1
- package/dist/modules/fiberTree/utils.d.ts +8 -2
- package/dist/modules/fiberTree/utils.d.ts.map +1 -1
- package/dist/modules/fiberTree/utils.js +79 -78
- package/dist/modules/fiberTree/utils.js.map +1 -1
- package/dist/modules/fiberTree/viewport.d.ts +28 -0
- package/dist/modules/fiberTree/viewport.d.ts.map +1 -0
- package/dist/modules/fiberTree/viewport.js +50 -0
- package/dist/modules/fiberTree/viewport.js.map +1 -0
- package/dist/modules/fiberTree/waitFor.d.ts +52 -0
- package/dist/modules/fiberTree/waitFor.d.ts.map +1 -0
- package/dist/modules/fiberTree/waitFor.js +98 -0
- package/dist/modules/fiberTree/waitFor.js.map +1 -0
- package/dist/modules/logBox/logBox.d.ts.map +1 -1
- package/dist/modules/logBox/logBox.js +59 -66
- package/dist/modules/logBox/logBox.js.map +1 -1
- package/dist/modules/navigation/navigation.d.ts.map +1 -1
- package/dist/modules/navigation/navigation.js +115 -114
- package/dist/modules/navigation/navigation.js.map +1 -1
- package/dist/modules/network/network.d.ts.map +1 -1
- package/dist/modules/network/network.js +78 -197
- package/dist/modules/network/network.js.map +1 -1
- package/dist/modules/network/types.d.ts +23 -27
- package/dist/modules/network/types.d.ts.map +1 -1
- package/dist/modules/reactQuery/reactQuery.d.ts.map +1 -1
- package/dist/modules/reactQuery/reactQuery.js +46 -52
- package/dist/modules/reactQuery/reactQuery.js.map +1 -1
- package/dist/modules/storage/storage.d.ts.map +1 -1
- package/dist/modules/storage/storage.js +20 -3
- package/dist/modules/storage/storage.js.map +1 -1
- package/dist/server/host/tools/input.js +2 -2
- package/dist/server/host/tools/input.js.map +1 -1
- package/dist/server/mcpServer.d.ts.map +1 -1
- package/dist/server/mcpServer.js +43 -3
- package/dist/server/mcpServer.js.map +1 -1
- package/dist/server/metro/eventCapture.d.ts +0 -2
- package/dist/server/metro/eventCapture.d.ts.map +1 -1
- package/dist/server/metro/eventCapture.js +1 -2
- package/dist/server/metro/eventCapture.js.map +1 -1
- package/dist/server/metro/tools/events.d.ts.map +1 -1
- package/dist/server/metro/tools/events.js +11 -11
- package/dist/server/metro/tools/events.js.map +1 -1
- package/dist/shared/projection/projectValue.d.ts +90 -0
- package/dist/shared/projection/projectValue.d.ts.map +1 -0
- package/dist/shared/projection/projectValue.js +322 -0
- package/dist/shared/projection/projectValue.js.map +1 -0
- package/dist/shared/projection/redact.d.ts +31 -0
- package/dist/shared/projection/redact.d.ts.map +1 -0
- package/dist/shared/projection/redact.js +78 -0
- package/dist/shared/projection/redact.js.map +1 -0
- package/dist/shared/projection/resolvePath.d.ts +45 -0
- package/dist/shared/projection/resolvePath.d.ts.map +1 -0
- package/dist/shared/projection/resolvePath.js +211 -0
- package/dist/shared/projection/resolvePath.js.map +1 -0
- package/dist/shared/rn/core.d.ts +48 -0
- package/dist/shared/rn/core.d.ts.map +1 -0
- package/dist/shared/rn/core.js +100 -0
- package/dist/shared/rn/core.js.map +1 -0
- package/dist/shared/rn/deviceInfo.d.ts +40 -0
- package/dist/shared/rn/deviceInfo.d.ts.map +1 -0
- package/dist/shared/rn/deviceInfo.js +78 -0
- package/dist/shared/rn/deviceInfo.js.map +1 -0
- package/package.json +2 -2
- package/dist/client/hooks/useMcpState.d.ts +0 -3
- package/dist/client/hooks/useMcpState.d.ts.map +0 -1
- package/dist/client/hooks/useMcpState.js +0 -20
- package/dist/client/hooks/useMcpState.js.map +0 -1
- package/dist/server/canonicalize.d.ts +0 -8
- package/dist/server/canonicalize.d.ts.map +0 -1
- package/dist/server/canonicalize.js +0 -23
- package/dist/server/canonicalize.js.map +0 -1
- package/dist/server/host/modules/screenshot.d.ts +0 -4
- package/dist/server/host/modules/screenshot.d.ts.map +0 -1
- package/dist/server/host/modules/screenshot.js +0 -615
- package/dist/server/host/modules/screenshot.js.map +0 -1
- package/dist/server/host/tools/connectionStatus.d.ts +0 -9
- package/dist/server/host/tools/connectionStatus.d.ts.map +0 -1
- package/dist/server/host/tools/connectionStatus.js +0 -39
- package/dist/server/host/tools/connectionStatus.js.map +0 -1
- package/dist/server/host/tools/symbolicate.d.ts +0 -3
- package/dist/server/host/tools/symbolicate.d.ts.map +0 -1
- package/dist/server/host/tools/symbolicate.js +0 -209
- package/dist/server/host/tools/symbolicate.js.map +0 -1
- package/dist/server/host/wda.d.ts +0 -15
- package/dist/server/host/wda.d.ts.map +0 -1
- package/dist/server/host/wda.js +0 -100
- package/dist/server/host/wda.js.map +0 -1
- package/dist/server/inputSchemaToZod.d.ts +0 -19
- package/dist/server/inputSchemaToZod.d.ts.map +0 -1
- package/dist/server/inputSchemaToZod.js +0 -89
- package/dist/server/inputSchemaToZod.js.map +0 -1
- package/dist/server/metro/tools/openUrl.d.ts +0 -3
- package/dist/server/metro/tools/openUrl.d.ts.map +0 -1
- package/dist/server/metro/tools/openUrl.js +0 -71
- package/dist/server/metro/tools/openUrl.js.map +0 -1
- package/dist/shared/slice.d.ts +0 -16
- package/dist/shared/slice.d.ts.map +0 -1
- package/dist/shared/slice.js +0 -29
- package/dist/shared/slice.js.map +0 -1
|
@@ -1,172 +1,263 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deviceModule = void 0;
|
|
4
|
+
const core_1 = require("../../shared/rn/core");
|
|
5
|
+
const deviceInfo_1 = require("../../shared/rn/deviceInfo");
|
|
6
|
+
// All fields the unified `info` tool can return. The handler reads from RN
|
|
7
|
+
// core modules (Platform, Dimensions, Appearance, AppState,
|
|
8
|
+
// AccessibilityInfo, Keyboard, Linking) plus — when installed — selected
|
|
9
|
+
// helpers from `react-native-device-info`. Pass `select` to filter; omit
|
|
10
|
+
// for the full payload.
|
|
11
|
+
//
|
|
12
|
+
// Fields backed by react-native-device-info (identity / app / battery /
|
|
13
|
+
// memoryStorage) return `{ unavailable: true, reason }` when the package
|
|
14
|
+
// isn't installed. Fields already surfaced in the handshake (appName,
|
|
15
|
+
// appVersion, bundleId, deviceId, label) are not duplicated here.
|
|
16
|
+
const INFO_FIELDS = [
|
|
17
|
+
// RN core
|
|
18
|
+
'platform', // { os, version, constants } from Platform
|
|
19
|
+
'dimensions', // { screen, window, screenPixels, windowPixels, pixelRatio }
|
|
20
|
+
'pixelRatio', // { pixelRatio, fontScale }
|
|
21
|
+
'appearance', // { colorScheme: 'light' | 'dark' | null }
|
|
22
|
+
'appState', // { state: 'active' | 'background' | 'inactive' }
|
|
23
|
+
'accessibility', // { isScreenReaderEnabled, isReduceMotionEnabled }
|
|
24
|
+
'keyboard', // { isVisible, metrics }
|
|
25
|
+
'initialUrl', // { url }
|
|
26
|
+
'dev', // { dev: boolean }
|
|
27
|
+
// react-native-device-info (optional)
|
|
28
|
+
'identity', // { model, manufacturer, deviceType, isTablet, hasNotch, hasDynamicIsland, systemName, systemVersion }
|
|
29
|
+
'app', // { buildNumber, readableVersion, firstInstallTime, lastUpdateTime, installerPackageName }
|
|
30
|
+
'battery', // { batteryLevel, isCharging, isLowBatteryLevel, powerState }
|
|
31
|
+
'memoryStorage', // { totalMemory, usedMemory, maxMemory, totalDiskCapacity, freeDiskStorage }
|
|
32
|
+
];
|
|
33
|
+
// react-native-device-info-backed fields share a single graceful-degradation
|
|
34
|
+
// payload when the package isn't installed.
|
|
35
|
+
const DI_FIELDS = new Set(['identity', 'app', 'battery', 'memoryStorage']);
|
|
4
36
|
const deviceModule = () => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
//
|
|
8
|
-
|
|
37
|
+
const buildInfoField = async (field) => {
|
|
38
|
+
// react-native-device-info-backed fields go first so we can short-circuit
|
|
39
|
+
// when the package is missing without poking at RN.
|
|
40
|
+
if (DI_FIELDS.has(field)) {
|
|
41
|
+
const DI = (0, deviceInfo_1.loadDeviceInfo)();
|
|
42
|
+
if (!DI)
|
|
43
|
+
return deviceInfo_1.DEVICE_INFO_UNAVAILABLE;
|
|
44
|
+
switch (field) {
|
|
45
|
+
case 'identity':
|
|
46
|
+
// Identity excludes handshake-duplicated fields (deviceId, label,
|
|
47
|
+
// appName/appVersion/bundleId).
|
|
48
|
+
return {
|
|
49
|
+
deviceType: (0, deviceInfo_1.callDI)(DI.getDeviceType),
|
|
50
|
+
hasDynamicIsland: (0, deviceInfo_1.callDI)(DI.hasDynamicIsland),
|
|
51
|
+
hasNotch: (0, deviceInfo_1.callDI)(DI.hasNotch),
|
|
52
|
+
isTablet: (0, deviceInfo_1.callDI)(DI.isTablet),
|
|
53
|
+
manufacturer: (0, deviceInfo_1.callDI)(DI.getManufacturerSync ?? DI.getBrand),
|
|
54
|
+
model: (0, deviceInfo_1.callDI)(DI.getModel),
|
|
55
|
+
systemName: (0, deviceInfo_1.callDI)(DI.getSystemName),
|
|
56
|
+
systemVersion: (0, deviceInfo_1.callDI)(DI.getSystemVersion),
|
|
57
|
+
};
|
|
58
|
+
case 'app': {
|
|
59
|
+
// App excludes bundleId / version / appName already in handshake.
|
|
60
|
+
const [firstInstallTime, lastUpdateTime, installerPackageName] = await Promise.all([
|
|
61
|
+
(0, deviceInfo_1.callDIAsync)(DI.getFirstInstallTime),
|
|
62
|
+
(0, deviceInfo_1.callDIAsync)(DI.getLastUpdateTime),
|
|
63
|
+
(0, deviceInfo_1.callDIAsync)(DI.getInstallerPackageName),
|
|
64
|
+
]);
|
|
65
|
+
return {
|
|
66
|
+
buildNumber: (0, deviceInfo_1.callDI)(DI.getBuildNumber),
|
|
67
|
+
firstInstallTime,
|
|
68
|
+
installerPackageName,
|
|
69
|
+
lastUpdateTime,
|
|
70
|
+
readableVersion: (0, deviceInfo_1.callDI)(DI.getReadableVersion),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
case 'battery': {
|
|
74
|
+
const [batteryLevel, isCharging, powerState] = await Promise.all([
|
|
75
|
+
(0, deviceInfo_1.callDIAsync)(DI.getBatteryLevel),
|
|
76
|
+
(0, deviceInfo_1.callDIAsync)(DI.isBatteryCharging),
|
|
77
|
+
(0, deviceInfo_1.callDIAsync)(DI.getPowerState),
|
|
78
|
+
]);
|
|
79
|
+
return {
|
|
80
|
+
batteryLevel,
|
|
81
|
+
isCharging,
|
|
82
|
+
isLowBatteryLevel: typeof batteryLevel === 'number' ? batteryLevel < 0.2 : null,
|
|
83
|
+
powerState,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
case 'memoryStorage': {
|
|
87
|
+
const [totalMemory, usedMemory, maxMemory, totalDiskCapacity, freeDiskStorage] = await Promise.all([
|
|
88
|
+
(0, deviceInfo_1.callDIAsync)(DI.getTotalMemory),
|
|
89
|
+
(0, deviceInfo_1.callDIAsync)(DI.getUsedMemory),
|
|
90
|
+
(0, deviceInfo_1.callDIAsync)(DI.getMaxMemory),
|
|
91
|
+
(0, deviceInfo_1.callDIAsync)(DI.getTotalDiskCapacity),
|
|
92
|
+
(0, deviceInfo_1.callDIAsync)(DI.getFreeDiskStorage),
|
|
93
|
+
]);
|
|
94
|
+
return {
|
|
95
|
+
freeDiskStorage,
|
|
96
|
+
maxMemory,
|
|
97
|
+
totalDiskCapacity,
|
|
98
|
+
totalMemory,
|
|
99
|
+
usedMemory,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const RN = (0, core_1.getRN)();
|
|
105
|
+
switch (field) {
|
|
106
|
+
case 'platform':
|
|
107
|
+
return {
|
|
108
|
+
constants: RN.Platform.constants,
|
|
109
|
+
os: RN.Platform.OS,
|
|
110
|
+
version: RN.Platform.Version,
|
|
111
|
+
};
|
|
112
|
+
case 'dimensions': {
|
|
113
|
+
const ratio = RN.PixelRatio.get();
|
|
114
|
+
const screen = RN.Dimensions.get('screen');
|
|
115
|
+
const window = RN.Dimensions.get('window');
|
|
116
|
+
return {
|
|
117
|
+
pixelRatio: ratio,
|
|
118
|
+
screen,
|
|
119
|
+
screenPixels: {
|
|
120
|
+
height: Math.round(screen.height * ratio),
|
|
121
|
+
width: Math.round(screen.width * ratio),
|
|
122
|
+
},
|
|
123
|
+
window,
|
|
124
|
+
windowPixels: {
|
|
125
|
+
height: Math.round(window.height * ratio),
|
|
126
|
+
width: Math.round(window.width * ratio),
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
case 'pixelRatio':
|
|
131
|
+
return {
|
|
132
|
+
fontScale: RN.PixelRatio.getFontScale(),
|
|
133
|
+
pixelRatio: RN.PixelRatio.get(),
|
|
134
|
+
};
|
|
135
|
+
case 'appearance':
|
|
136
|
+
return { colorScheme: RN.Appearance.getColorScheme() };
|
|
137
|
+
case 'appState':
|
|
138
|
+
return { state: RN.AppState.currentState };
|
|
139
|
+
case 'accessibility': {
|
|
140
|
+
const [isScreenReaderEnabled, isReduceMotionEnabled] = await Promise.all([
|
|
141
|
+
RN.AccessibilityInfo.isScreenReaderEnabled(),
|
|
142
|
+
RN.AccessibilityInfo.isReduceMotionEnabled(),
|
|
143
|
+
]);
|
|
144
|
+
return { isReduceMotionEnabled, isScreenReaderEnabled };
|
|
145
|
+
}
|
|
146
|
+
case 'keyboard':
|
|
147
|
+
return {
|
|
148
|
+
isVisible: RN.Keyboard.isVisible(),
|
|
149
|
+
metrics: RN.Keyboard.metrics(),
|
|
150
|
+
};
|
|
151
|
+
case 'initialUrl': {
|
|
152
|
+
const url = await RN.Linking.getInitialURL();
|
|
153
|
+
return { url };
|
|
154
|
+
}
|
|
155
|
+
case 'dev':
|
|
156
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
157
|
+
return { dev: Boolean(globalThis.__DEV__) };
|
|
158
|
+
default:
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
9
161
|
};
|
|
10
162
|
return {
|
|
11
163
|
description: `Device + platform introspection, plus a few imperative actions (open URL, dismiss keyboard, reload, vibrate).
|
|
12
164
|
|
|
13
165
|
Dimension helpers return values in both logical DP and physical pixels —
|
|
14
|
-
physical pixel helpers (screenPixels / windowPixels
|
|
15
|
-
match what host__tap / adb input tap consume
|
|
166
|
+
physical pixel helpers (screenPixels / windowPixels under \`dimensions\`)
|
|
167
|
+
match what host__tap / adb input tap consume.
|
|
168
|
+
|
|
169
|
+
READS
|
|
170
|
+
info({ select? }) — one aggregate read. Returns any subset of:
|
|
171
|
+
RN core: platform, dimensions, pixelRatio, appearance, appState,
|
|
172
|
+
accessibility, keyboard, initialUrl, dev
|
|
173
|
+
react-native-device-info (optional dep): identity, app, battery,
|
|
174
|
+
memoryStorage
|
|
175
|
+
Pass \`select: ['battery','keyboard']\` to limit fields; omit for the full
|
|
176
|
+
payload. DI-backed fields gracefully return
|
|
177
|
+
\`{ unavailable: true, reason }\` when the package isn't installed. Fields
|
|
178
|
+
already in the handshake (appName / appVersion / bundleId / deviceId /
|
|
179
|
+
label) are not duplicated.
|
|
180
|
+
|
|
181
|
+
ACTIONS
|
|
182
|
+
open_url({ url, dryRun? }) — opens the URL via Linking. \`dryRun: true\`
|
|
183
|
+
only checks Linking.canOpenURL without launching anything (returns
|
|
184
|
+
{ canOpen, url }).
|
|
185
|
+
open_settings — open the app settings page.
|
|
186
|
+
dismiss_keyboard — Keyboard.dismiss().
|
|
187
|
+
reload — DevSettings.reload() (dev only).
|
|
188
|
+
vibrate({ duration? }) — Vibration.vibrate(duration|400).`,
|
|
16
189
|
name: 'device',
|
|
17
190
|
tools: {
|
|
18
|
-
can_open_url: {
|
|
19
|
-
description: 'Check if a URL can be opened by an installed app.',
|
|
20
|
-
handler: async (args) => {
|
|
21
|
-
const { Linking } = getRN();
|
|
22
|
-
const canOpen = await Linking.canOpenURL(args.url);
|
|
23
|
-
return { canOpen, url: args.url };
|
|
24
|
-
},
|
|
25
|
-
inputSchema: {
|
|
26
|
-
url: { description: 'URL to check.', type: 'string' },
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
191
|
dismiss_keyboard: {
|
|
30
192
|
description: 'Dismiss the currently visible keyboard.',
|
|
31
193
|
handler: () => {
|
|
32
|
-
const { Keyboard } = getRN();
|
|
194
|
+
const { Keyboard } = (0, core_1.getRN)();
|
|
33
195
|
Keyboard.dismiss();
|
|
34
196
|
return { success: true };
|
|
35
197
|
},
|
|
36
198
|
},
|
|
37
|
-
|
|
38
|
-
description: '
|
|
39
|
-
handler: async () => {
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
get_appearance: {
|
|
59
|
-
description: 'Current color scheme: light / dark / null.',
|
|
60
|
-
handler: () => {
|
|
61
|
-
const { Appearance } = getRN();
|
|
62
|
-
return { colorScheme: Appearance.getColorScheme() };
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
get_device_info: {
|
|
66
|
-
description: 'Platform, OS version, dimensions, pixel ratio, appearance, dev flag.',
|
|
67
|
-
handler: () => {
|
|
68
|
-
const { Appearance, Dimensions, PixelRatio, Platform } = getRN();
|
|
69
|
-
return {
|
|
70
|
-
appearance: Appearance.getColorScheme(),
|
|
71
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
72
|
-
dev: Boolean(globalThis.__DEV__),
|
|
73
|
-
dimensions: {
|
|
74
|
-
screen: Dimensions.get('screen'),
|
|
75
|
-
window: Dimensions.get('window'),
|
|
76
|
-
},
|
|
77
|
-
pixelRatio: PixelRatio.get(),
|
|
78
|
-
platform: {
|
|
79
|
-
constants: Platform.constants,
|
|
80
|
-
os: Platform.OS,
|
|
81
|
-
version: Platform.Version,
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
get_dimensions: {
|
|
87
|
-
description: 'Screen + window dimensions in both DP (raw RN) and physical pixels.',
|
|
88
|
-
handler: () => {
|
|
89
|
-
const { Dimensions, PixelRatio } = getRN();
|
|
90
|
-
const ratio = PixelRatio.get();
|
|
91
|
-
const screen = Dimensions.get('screen');
|
|
92
|
-
const window = Dimensions.get('window');
|
|
93
|
-
return {
|
|
94
|
-
pixelRatio: ratio,
|
|
95
|
-
screen,
|
|
96
|
-
screenPixels: {
|
|
97
|
-
height: Math.round(screen.height * ratio),
|
|
98
|
-
width: Math.round(screen.width * ratio),
|
|
99
|
-
},
|
|
100
|
-
window,
|
|
101
|
-
windowPixels: {
|
|
102
|
-
height: Math.round(window.height * ratio),
|
|
103
|
-
width: Math.round(window.width * ratio),
|
|
104
|
-
},
|
|
105
|
-
};
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
get_initial_url: {
|
|
109
|
-
description: 'Deep link that launched the app, if any.',
|
|
110
|
-
handler: async () => {
|
|
111
|
-
const { Linking } = getRN();
|
|
112
|
-
const url = await Linking.getInitialURL();
|
|
113
|
-
return { url };
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
get_keyboard_state: {
|
|
117
|
-
description: 'Keyboard visibility + metrics.',
|
|
118
|
-
handler: () => {
|
|
119
|
-
const { Keyboard } = getRN();
|
|
120
|
-
return {
|
|
121
|
-
isVisible: Keyboard.isVisible(),
|
|
122
|
-
metrics: Keyboard.metrics(),
|
|
123
|
-
};
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
get_pixel_ratio: {
|
|
127
|
-
description: 'Pixel density + font scale.',
|
|
128
|
-
handler: () => {
|
|
129
|
-
const { PixelRatio } = getRN();
|
|
130
|
-
return {
|
|
131
|
-
fontScale: PixelRatio.getFontScale(),
|
|
132
|
-
pixelRatio: PixelRatio.get(),
|
|
133
|
-
};
|
|
199
|
+
info: {
|
|
200
|
+
description: `Aggregate device / platform introspection. Returns any subset of: ${INFO_FIELDS.join(' / ')}. Pass \`select: ['battery','keyboard']\` to limit to specific fields; omit for the full payload. Fields backed by react-native-device-info (identity / app / battery / memoryStorage) return \`{ unavailable: true, reason }\` when the package isn't installed.`,
|
|
201
|
+
handler: async (args) => {
|
|
202
|
+
const requested = Array.isArray(args.select)
|
|
203
|
+
? args.select.filter((f) => {
|
|
204
|
+
return INFO_FIELDS.includes(f);
|
|
205
|
+
})
|
|
206
|
+
: INFO_FIELDS;
|
|
207
|
+
if (Array.isArray(args.select) && requested.length === 0) {
|
|
208
|
+
return {
|
|
209
|
+
availableFields: INFO_FIELDS,
|
|
210
|
+
error: `select must contain at least one known field. Got ${JSON.stringify(args.select)}.`,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
const entries = await Promise.all(requested.map(async (field) => {
|
|
214
|
+
return [field, await buildInfoField(field)];
|
|
215
|
+
}));
|
|
216
|
+
const out = {};
|
|
217
|
+
for (const [key, value] of entries)
|
|
218
|
+
out[key] = value;
|
|
219
|
+
return out;
|
|
134
220
|
},
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
constants: Platform.constants,
|
|
142
|
-
os: Platform.OS,
|
|
143
|
-
version: Platform.Version,
|
|
144
|
-
};
|
|
221
|
+
inputSchema: {
|
|
222
|
+
select: {
|
|
223
|
+
description: `Optional list of fields to return. Default = all. Known fields: ${INFO_FIELDS.join(' / ')}. identity / app / battery / memoryStorage require react-native-device-info; they return { unavailable: true, reason } when the package isn't installed.`,
|
|
224
|
+
examples: [['battery'], ['identity', 'app'], ['platform', 'dimensions']],
|
|
225
|
+
type: 'array',
|
|
226
|
+
},
|
|
145
227
|
},
|
|
146
228
|
},
|
|
147
229
|
open_settings: {
|
|
148
230
|
description: 'Open the app settings page in device settings.',
|
|
149
231
|
handler: async () => {
|
|
150
|
-
const { Linking } = getRN();
|
|
232
|
+
const { Linking } = (0, core_1.getRN)();
|
|
151
233
|
await Linking.openSettings();
|
|
152
234
|
return { success: true };
|
|
153
235
|
},
|
|
154
236
|
},
|
|
155
237
|
open_url: {
|
|
156
|
-
description: 'Open a URL with the appropriate installed app.',
|
|
238
|
+
description: 'Open a URL with the appropriate installed app. Pass `dryRun: true` to only check whether an app can handle it (returns `{ canOpen, url }`) without launching.',
|
|
157
239
|
handler: async (args) => {
|
|
158
|
-
const { Linking } = getRN();
|
|
159
|
-
|
|
160
|
-
|
|
240
|
+
const { Linking } = (0, core_1.getRN)();
|
|
241
|
+
const url = args.url;
|
|
242
|
+
if (args.dryRun === true) {
|
|
243
|
+
const canOpen = await Linking.canOpenURL(url);
|
|
244
|
+
return { canOpen, url };
|
|
245
|
+
}
|
|
246
|
+
await Linking.openURL(url);
|
|
247
|
+
return { success: true, url };
|
|
161
248
|
},
|
|
162
249
|
inputSchema: {
|
|
163
|
-
|
|
250
|
+
dryRun: {
|
|
251
|
+
description: 'When true, only check Linking.canOpenURL and return `{ canOpen, url }` without opening. Default false.',
|
|
252
|
+
type: 'boolean',
|
|
253
|
+
},
|
|
254
|
+
url: { description: 'URL to open (or check, when dryRun:true).', type: 'string' },
|
|
164
255
|
},
|
|
165
256
|
},
|
|
166
257
|
reload: {
|
|
167
258
|
description: 'Reload the app (dev mode only — like pressing R in Metro).',
|
|
168
259
|
handler: () => {
|
|
169
|
-
const { DevSettings } = getRN();
|
|
260
|
+
const { DevSettings } = (0, core_1.getRN)();
|
|
170
261
|
DevSettings.reload();
|
|
171
262
|
return { success: true };
|
|
172
263
|
},
|
|
@@ -174,7 +265,7 @@ match what host__tap / adb input tap consume.`,
|
|
|
174
265
|
vibrate: {
|
|
175
266
|
description: 'Vibrate the device.',
|
|
176
267
|
handler: (args) => {
|
|
177
|
-
const { Vibration } = getRN();
|
|
268
|
+
const { Vibration } = (0, core_1.getRN)();
|
|
178
269
|
const duration = args.duration || 400;
|
|
179
270
|
Vibration.vibrate(duration);
|
|
180
271
|
return { success: true };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device.js","sourceRoot":"","sources":["../../../src/modules/device/device.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"device.js","sourceRoot":"","sources":["../../../src/modules/device/device.ts"],"names":[],"mappings":";;;AACA,2CAAyC;AACzC,uDAKgC;AAEhC,2EAA2E;AAC3E,4DAA4D;AAC5D,yEAAyE;AACzE,yEAAyE;AACzE,wBAAwB;AACxB,EAAE;AACF,wEAAwE;AACxE,yEAAyE;AACzE,sEAAsE;AACtE,kEAAkE;AAClE,MAAM,WAAW,GAAG;IAClB,UAAU;IACV,UAAU,EAAE,2CAA2C;IACvD,YAAY,EAAE,6DAA6D;IAC3E,YAAY,EAAE,4BAA4B;IAC1C,YAAY,EAAE,2CAA2C;IACzD,UAAU,EAAE,kDAAkD;IAC9D,eAAe,EAAE,mDAAmD;IACpE,UAAU,EAAE,yBAAyB;IACrC,YAAY,EAAE,UAAU;IACxB,KAAK,EAAE,mBAAmB;IAC1B,sCAAsC;IACtC,UAAU,EAAE,uGAAuG;IACnH,KAAK,EAAE,2FAA2F;IAClG,SAAS,EAAE,8DAA8D;IACzE,eAAe,EAAE,6EAA6E;CACtF,CAAC;AAIX,6EAA6E;AAC7E,4CAA4C;AAC5C,MAAM,SAAS,GAAG,IAAI,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M,EAAE;gBACN,WAAW,EAAE,4DAA4D;gBACzE,OAAO,EAAE,GAAG,EAAE;oBACZ,MAAM,EAAE,WAAW,EAAE,GAAG,IAAA,YAAK,GAAE,CAAC;oBAChC,WAAW,CAAC,MAAM,EAAE,CAAC;oBACrB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gBAC3B,CAAC;aACF;YACD,OAAO,EAAE;gBACP,WAAW,EAAE,qBAAqB;gBAClC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;oBAChB,MAAM,EAAE,SAAS,EAAE,GAAG,IAAA,YAAK,GAAE,CAAC;oBAC9B,MAAM,QAAQ,GAAI,IAAI,CAAC,QAAmB,IAAI,GAAG,CAAC;oBAClD,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;oBAC5B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gBAC3B,CAAC;gBACD,WAAW,EAAE;oBACX,QAAQ,EAAE,EAAE,WAAW,EAAE,gCAAgC,EAAE,IAAI,EAAE,QAAQ,EAAE;iBAC5E;aACF;SACF;KACF,CAAC;AACJ,CAAC,CAAC;AAxPW,QAAA,YAAY,gBAwPvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/modules/errors/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/modules/errors/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAQvD,OAAO,EAGL,KAAK,mBAAmB,EAEzB,MAAM,SAAS,CAAC;AA8HjB,eAAO,MAAM,YAAY,aAAc,mBAAmB,KAAG,SAoG5D,CAAC"}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.errorsModule = void 0;
|
|
4
|
-
const
|
|
4
|
+
const projectValue_1 = require("../../shared/projection/projectValue");
|
|
5
5
|
const DEFAULT_MAX_ENTRIES = 50;
|
|
6
|
+
// Default depth 4 — top is array of entries, level 2 expands each entry
|
|
7
|
+
// (id/isFatal/message/source/timestamp inline, stack/stackFrames still
|
|
8
|
+
// markers), level 3 opens stackFrames (each frame as `${obj}` marker),
|
|
9
|
+
// level 4 opens each frame (file/line/method/column inline). Long `stack`
|
|
10
|
+
// string auto-wraps in `${str}` regardless. Drill deeper via path.
|
|
11
|
+
const ERRORS_DEFAULT_DEPTH = 4;
|
|
12
|
+
const PROJECTION_SCHEMA = (0, projectValue_1.makeProjectionSchema)(ERRORS_DEFAULT_DEPTH);
|
|
6
13
|
// Match both the V8 ` at method (file:line:col)` and Hermes / JSC
|
|
7
14
|
// `method@file:line:col` stack formats. Keep parsing lightweight — full
|
|
8
15
|
// symbolication lives in metro__symbolicate so the agent can resolve frames
|
|
@@ -103,6 +110,9 @@ const installPatches = () => {
|
|
|
103
110
|
};
|
|
104
111
|
};
|
|
105
112
|
installPatches();
|
|
113
|
+
const project = (entries, args) => {
|
|
114
|
+
return (0, projectValue_1.applyProjection)(entries, args, projectValue_1.projectAsValue, ERRORS_DEFAULT_DEPTH);
|
|
115
|
+
};
|
|
106
116
|
const errorsModule = (options) => {
|
|
107
117
|
if (typeof options?.maxEntries === 'number') {
|
|
108
118
|
maxEntries = options.maxEntries;
|
|
@@ -115,8 +125,11 @@ const errorsModule = (options) => {
|
|
|
115
125
|
|
|
116
126
|
Captures via ErrorUtils.setGlobalHandler + console.error sniffing.
|
|
117
127
|
Deduplicates within a 100ms window. Capture starts at module-import
|
|
118
|
-
time
|
|
119
|
-
|
|
128
|
+
time so early fatal crashes are visible. Each entry carries a monotonic
|
|
129
|
+
numeric \`id\`, parsed \`stackFrames\` (V8 + Hermes formats, ready for
|
|
130
|
+
metro__symbolicate), and the raw \`stack\` string. Listing tools accept
|
|
131
|
+
path / depth / maxBytes (default depth ${ERRORS_DEFAULT_DEPTH}). Buffer size configurable via
|
|
132
|
+
errorsModule options.`,
|
|
120
133
|
name: 'errors',
|
|
121
134
|
tools: {
|
|
122
135
|
clear_errors: {
|
|
@@ -127,7 +140,7 @@ agent. Buffer size configurable via errorsModule options.`,
|
|
|
127
140
|
},
|
|
128
141
|
},
|
|
129
142
|
get_errors: {
|
|
130
|
-
description: 'Captured errors; filterable by source / fatal / time range.
|
|
143
|
+
description: 'Captured errors; filterable by source / fatal / time range. Use `metro__symbolicate` on stackFrames to resolve bundled paths back to source.',
|
|
131
144
|
handler: (args) => {
|
|
132
145
|
let result = [...buffer];
|
|
133
146
|
if (args.source) {
|
|
@@ -156,31 +169,16 @@ agent. Buffer size configurable via errorsModule options.`,
|
|
|
156
169
|
});
|
|
157
170
|
}
|
|
158
171
|
}
|
|
159
|
-
|
|
160
|
-
const includeStack = args.includeStack === true;
|
|
161
|
-
return result.map((entry) => {
|
|
162
|
-
if (includeStack)
|
|
163
|
-
return entry;
|
|
164
|
-
const { stack, ...rest } = entry;
|
|
165
|
-
return { ...rest, hasRawStack: typeof stack === 'string' };
|
|
166
|
-
});
|
|
172
|
+
return project(result, args);
|
|
167
173
|
},
|
|
168
174
|
inputSchema: {
|
|
175
|
+
...PROJECTION_SCHEMA,
|
|
169
176
|
fatal: { description: 'Filter by fatal flag.', type: 'boolean' },
|
|
170
|
-
includeStack: {
|
|
171
|
-
description: 'Include the raw `stack` string alongside parsed `stackFrames`. Default false — stackFrames already carries the structured form for metro__symbolicate.',
|
|
172
|
-
type: 'boolean',
|
|
173
|
-
},
|
|
174
177
|
since: {
|
|
175
178
|
description: 'ISO timestamp — only entries at or after this point.',
|
|
176
179
|
examples: ['2026-04-19T22:00:00.000Z'],
|
|
177
180
|
type: 'string',
|
|
178
181
|
},
|
|
179
|
-
slice: {
|
|
180
|
-
description: (0, slice_1.sliceSchemaDescription)('Default omitted → every matching entry is returned.'),
|
|
181
|
-
examples: [[-10], [-20, -10], [0, 50]],
|
|
182
|
-
type: 'array',
|
|
183
|
-
},
|
|
184
182
|
source: {
|
|
185
183
|
description: 'Filter by source.',
|
|
186
184
|
examples: ['global', 'promise'],
|
|
@@ -192,21 +190,6 @@ agent. Buffer size configurable via errorsModule options.`,
|
|
|
192
190
|
},
|
|
193
191
|
},
|
|
194
192
|
},
|
|
195
|
-
get_fatal: {
|
|
196
|
-
description: 'Fatal errors only.',
|
|
197
|
-
handler: (args) => {
|
|
198
|
-
const result = buffer.filter((e) => {
|
|
199
|
-
return e.isFatal;
|
|
200
|
-
});
|
|
201
|
-
return (0, slice_1.applySlice)(result, (0, slice_1.parseSliceArg)(args.slice));
|
|
202
|
-
},
|
|
203
|
-
inputSchema: {
|
|
204
|
-
slice: {
|
|
205
|
-
description: (0, slice_1.sliceSchemaDescription)('Default omitted → every fatal entry is returned.'),
|
|
206
|
-
type: 'array',
|
|
207
|
-
},
|
|
208
|
-
},
|
|
209
|
-
},
|
|
210
193
|
get_stats: {
|
|
211
194
|
description: 'Error counts — total, by source, fatal.',
|
|
212
195
|
handler: () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/modules/errors/errors.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/modules/errors/errors.ts"],"names":[],"mappings":";;;AACA,mEAK0C;AAS1C,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAE/B,wEAAwE;AACxE,uEAAuE;AACvE,uEAAuE;AACvE,0EAA0E;AAC1E,mEAAmE;AACnE,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAE/B,MAAM,iBAAiB,GAAG,IAAA,mCAAoB,EAAC,oBAAoB,CAAC,CAAC;AAErE,qEAAqE;AACrE,wEAAwE;AACxE,4EAA4E;AAC5E,6DAA6D;AAC7D,MAAM,UAAU,GAAG,CAAC,KAAyB,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