rn-inspector 0.3.1 → 0.3.3

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 (36) hide show
  1. package/README.md +221 -216
  2. package/dist/config/Index.d.ts +23 -0
  3. package/dist/config/Index.d.ts.map +1 -1
  4. package/dist/config/Index.js +35 -7
  5. package/dist/config/Index.js.map +1 -1
  6. package/dist/devtools/bridge.d.ts +3 -0
  7. package/dist/devtools/bridge.d.ts.map +1 -0
  8. package/dist/devtools/bridge.js +451 -0
  9. package/dist/devtools/bridge.js.map +1 -0
  10. package/dist/devtools/discovery.d.ts +3 -0
  11. package/dist/devtools/discovery.d.ts.map +1 -0
  12. package/dist/devtools/discovery.js +141 -0
  13. package/dist/devtools/discovery.js.map +1 -0
  14. package/dist/devtools/handlers.d.ts +14 -0
  15. package/dist/devtools/handlers.d.ts.map +1 -0
  16. package/dist/devtools/handlers.js +633 -0
  17. package/dist/devtools/handlers.js.map +1 -0
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +249 -1171
  20. package/dist/index.js.map +1 -1
  21. package/dist/index.old.d.ts +3 -0
  22. package/dist/index.old.d.ts.map +1 -0
  23. package/dist/index.old.js +1665 -0
  24. package/dist/index.old.js.map +1 -0
  25. package/dist/snippets/INJECT_INSPECTOR_SNIPPET.js +181 -181
  26. package/dist/snippets/INJECT_NETWORK_SNIPPET.js +994 -994
  27. package/dist/snippets/INJECT_STORAGE_SNIPPET.d.ts +1 -1
  28. package/dist/snippets/INJECT_STORAGE_SNIPPET.d.ts.map +1 -1
  29. package/dist/snippets/INJECT_STORAGE_SNIPPET.js +308 -122
  30. package/dist/snippets/INJECT_STORAGE_SNIPPET.js.map +1 -1
  31. package/dist/types/Index.d.ts +11 -1
  32. package/dist/types/Index.d.ts.map +1 -1
  33. package/package.json +53 -52
  34. package/ui/assets/index-J3NQW5OE.js +239 -0
  35. package/ui/index.html +13 -13
  36. package/ui/assets/index-DQmlFNcZ.js +0 -166
package/README.md CHANGED
@@ -1,216 +1,221 @@
1
- # rn-inspector CLI
2
-
3
- [![npm version](https://img.shields.io/npm/v/rn-inspector.svg?label=rn-inspector)](https://www.npmjs.com/package/rn-inspector)
4
- [![npm downloads](https://img.shields.io/npm/dm/rn-inspector.svg)](https://www.npmjs.com/package/rn-inspector)
5
-
6
- `rn-inspector` is a focused CLI + Web UI that helps you debug **React Native** apps by:
7
-
8
- - Proxying **Metro** messages.
9
- - Attaching to **DevTools** targets (single or multiple devices/emulators).
10
- - Streaming **console logs**, **network requests**, and selected **storage state** into a modern, glassy web UI.
11
-
12
- This package is the **CLI entry point** you install globally.
13
-
14
- ---
15
-
16
- ## Installation
17
-
18
- Install globally from npm:
19
-
20
- ```bash
21
- npm install -g rn-inspector
22
- ```
23
-
24
- After installing, the `rn-inspector` command is available in your shell.
25
-
26
- ---
27
-
28
- ## Quick start
29
-
30
- 1. Start your React Native app as usual (Metro running, app open in simulator or device).
31
- 2. In another terminal, run:
32
-
33
- ```bash
34
- rn-inspector
35
- ```
36
-
37
- 3. By default this will:
38
-
39
- - Connect to **Metro** on port `8081`.
40
- - Start a **WebSocket proxy** for the UI at `ws://localhost:9230/inspector`.
41
- - Serve the **UI** at `http://localhost:4173`.
42
- - Auto-discover any available **DevTools targets** (for connected devices/emulators).
43
-
44
- 4. Open the UI in your browser (or use the `o` keyboard shortcut), pick a device from the header, and start inspecting **Console** and **Network** events.
45
-
46
- ---
47
-
48
- ## CLI usage
49
-
50
- ```bash
51
- rn-inspector \
52
- [--port 8081 | --port=8081] \
53
- [--ui-port 4173 | --ui-port=4173] \
54
- [--ui-ws-port 9230 | --ui-ws-port=9230] \
55
- [--devtools-url ws://...] \
56
- [--version]
57
- ```
58
-
59
- ### Options
60
-
61
- - `--port <number>` / `--port=<number>`
62
- - Metro port to connect to.
63
- - Default: `8081`.
64
- - This is also affected by the `METRO_PORT` environment variable (see below).
65
-
66
- - `--ui-port <number>` / `--ui-port=<number>`
67
- - HTTP port where the Web UI is served.
68
- - Default: `4173`.
69
- - The UI will be available at `http://localhost:<ui-port>`.
70
-
71
- - `--ui-ws-port <number>` / `--ui-ws-port=<number>`
72
- - WebSocket port used between the CLI proxy and the Web UI.
73
- - Default: `9230`.
74
- - The UI connects to `ws://localhost:<ui-ws-port>/inspector`.
75
-
76
- - `--devtools-url <ws-url>` / `--devtools-url=<ws-url>`
77
- - Explicit DevTools websocket URL to attach to (for advanced usage).
78
- - If omitted, `rn-inspector` will **auto-discover** DevTools targets via `http://<host>:<port>/json` on a range of ports (starting around the Metro port) and attach to all matching targets.
79
-
80
- - `--version`
81
- - Print the `rn-inspector` CLI version and exit.
82
-
83
- ### Environment variables
84
-
85
- - `METRO_PORT`
86
- - If set, this overrides the default Metro port.
87
- - Equivalent to passing `--port=<METRO_PORT>`.
88
-
89
- - `RN_INSPECTOR_DEVTOOLS_URL`
90
- - Default DevTools websocket URL if `--devtools-url` is not provided.
91
- - Example: `ws://localhost:9229/devtools/page/XXXX-YYYY`.
92
-
93
- ---
94
-
95
- ## Multi-device DevTools support
96
-
97
- `rn-inspector` is designed to work with **multiple React Native targets** at once:
98
-
99
- - The CLI scans a set of ports (around the Metro port and some common DevTools ports) for `/json` endpoints.
100
- - For each DevTools target it finds, it:
101
- - Opens a WebSocket connection.
102
- - Tags all console and network events with a `deviceId`.
103
- - The CLI periodically sends a **meta `devices` event** over the UI WebSocket with a list of currently attached devices.
104
- - The Web UI:
105
- - Shows a **global device selector** in the header.
106
- - Filters **Console** and **Network** events by the selected device while still showing Metro-only events.
107
-
108
- If you prefer to control the DevTools connection manually, you can pass a `--devtools-url` instead of relying on auto-discovery.
109
-
110
- ---
111
-
112
- ## Web UI overview
113
-
114
- When `rn-inspector` is running, the UI is served from:
115
-
116
- ```text
117
- http://localhost:<ui-port>
118
- ```
119
-
120
- By default this is `http://localhost:4173`.
121
-
122
- The UI includes:
123
-
124
- - **Console** page
125
- - Live console logs from Metro and DevTools.
126
- - Level filters (log/info/warn/error).
127
- - Detail drawer with copy-to-clipboard and timestamps.
128
-
129
- - **Network** page
130
- - HTTP requests captured via an injected fetch wrapper / DevTools Network domain.
131
- - Detail drawer with headers, payload, and response preview (including text, JSON, images, and some binary types).
132
-
133
- - **Header controls**
134
- - Global **device selector** (backed by the `deviceId` tagging in the CLI).
135
- - Global **capture toggles** for Console and Network streams.
136
- - Global **proxy WS status chip** (shows connection status and basic stats; click to reconnect when disconnected).
137
- - Global **DevTools status chip** (shows connected/closed/error and lets you request a DevTools reconnect from the UI).
138
-
139
- ---
140
-
141
- ## Storage & Redux inspection
142
-
143
- The **Storage** page lets you inspect:
144
-
145
- - **AsyncStorage** key/value pairs.
146
- - **Redux** state (if you are using Redux).
147
-
148
- To keep the CLI simple and avoid depending on your bundler setup, you need to expose these on the global object in your app:
149
-
150
- ### AsyncStorage
151
-
152
- In your React Native app (for example in `App.tsx`):
153
-
154
- ```ts
155
- import AsyncStorage from '@react-native-async-storage/async-storage';
156
-
157
- // Make AsyncStorage visible to rn-inspector storage helper
158
- (global as any).AsyncStorage = AsyncStorage;
159
- ```
160
-
161
- Once this is set and the app is running with DevTools debugging enabled, the Storage page's **AsyncStorage** panel will show your keys and values.
162
-
163
- ### Redux store
164
-
165
- If you use Redux, expose your store after you create it (anywhere in your app setup):
166
-
167
- ```ts
168
- import { createStore } from 'redux';
169
-
170
- const store = createStore(reducer);
171
-
172
- // Expose Redux store for rn-inspector
173
- (global as any).__RN_INSPECTOR_REDUX_STORE__ = store;
174
- ```
175
-
176
- The Storage page's **Redux State** panel will then show `store.getState()` and update as your state changes.
177
-
178
- If you do not expose these globals, the Storage page will show a helpful message explaining what to add in your app.
179
-
180
- ---
181
-
182
- ## Keyboard shortcuts (CLI)
183
-
184
- While `rn-inspector` is running in a TTY, the CLI listens for a few simple shortcuts:
185
-
186
- - `o` / `O`
187
- - Open the Web UI in your default browser (using `start` on Windows, `open` on macOS, or `xdg-open` on Linux).
188
-
189
- - `r` / `R`
190
- - Print a hint on how to fully reload the CLI:
191
- - Press `Ctrl+C` to stop the process, then run `rn-inspector` again.
192
-
193
- - `Ctrl+C`
194
- - Quit `rn-inspector`.
195
-
196
- If the terminal does not support raw mode (no TTY), these shortcuts are safely disabled.
197
-
198
- ---
199
-
200
- ## Error handling & reconnection
201
-
202
- - If the **Metro websocket** closes or errors, the CLI logs a message and sends a small `meta` event to the UI so you can see the status.
203
- - For **DevTools websockets** (one per device):
204
- - The CLI emits `devtools` **status meta events** (`open`, `closed`, `error`) but does **not** auto-retry reconnecting.
205
- - The Web UI header exposes a **DevTools status chip**; clicking it sends a control message to the CLI to re-run DevTools discovery and attach again.
206
- - When DevTools auto-discovery finds no `/json` targets, the CLI logs a message *and* emits a warning `meta` event so the UI can surface a toast like “DevTools auto-discovery found no /json targets (falling back to Metro-only mode)”.
207
-
208
- ---
209
-
210
- ## Repository
211
-
212
- This CLI is part of the **RN Inspector Monorepo**:
213
-
214
- - GitHub: <https://github.com/afzaal-28/rn-inspector>
215
-
216
- Please open issues or pull requests in that repository for bugs, feature requests, or contributions.
1
+ # rn-inspector CLI
2
+
3
+ [![npm version](https://img.shields.io/npm/v/rn-inspector.svg?label=rn-inspector)](https://www.npmjs.com/package/rn-inspector)
4
+ [![npm downloads](https://img.shields.io/npm/dm/rn-inspector.svg)](https://www.npmjs.com/package/rn-inspector)
5
+
6
+ `rn-inspector` is a focused CLI + Web UI that helps you debug **React Native** apps by:
7
+
8
+ - Proxying **Metro** messages.
9
+ - Attaching to **DevTools** targets (single or multiple devices/emulators).
10
+ - Streaming **console logs**, **network requests**, and selected **storage state** into a modern, glassy web UI.
11
+
12
+ This package is the **CLI entry point** you install globally.
13
+
14
+ ---
15
+
16
+ ## Installation
17
+
18
+ Install globally from npm:
19
+
20
+ ```bash
21
+ npm install -g rn-inspector
22
+ ```
23
+
24
+ After installing, the `rn-inspector` command is available in your shell.
25
+
26
+ ---
27
+
28
+ ## Quick start
29
+
30
+ 1. Start your React Native app as usual (Metro running, app open in simulator or device).
31
+ 2. In another terminal, run:
32
+
33
+ ```bash
34
+ rn-inspector
35
+ ```
36
+
37
+ 3. By default this will:
38
+ - Connect to **Metro** on port `8081`.
39
+ - Start a **WebSocket proxy** for the UI at `ws://localhost:9230/inspector`.
40
+ - Serve the **UI** at `http://localhost:4173`.
41
+ - Auto-discover any available **DevTools targets** (for connected devices/emulators).
42
+
43
+ 4. Open the UI in your browser (or use the `o` keyboard shortcut), pick a device from the header, and start inspecting **Console** and **Network** events.
44
+
45
+ ---
46
+
47
+ ## CLI usage
48
+
49
+ ```bash
50
+ rn-inspector \
51
+ [--port 8081 | --port=8081] \
52
+ [--ui-port 4173 | --ui-port=4173] \
53
+ [--ui-ws-port 9230 | --ui-ws-port=9230] \
54
+ [--devtools-url ws://...] \
55
+ [--version]
56
+ ```
57
+
58
+ ### Options
59
+
60
+ - `--port <number>` / `--port=<number>`
61
+ - Metro port to connect to.
62
+ - Default: `8081`.
63
+ - This is also affected by the `METRO_PORT` environment variable (see below).
64
+
65
+ - `--ui-port <number>` / `--ui-port=<number>`
66
+ - HTTP port where the Web UI is served.
67
+ - Default: `4173`.
68
+ - The UI will be available at `http://localhost:<ui-port>`.
69
+
70
+ - `--ui-ws-port <number>` / `--ui-ws-port=<number>`
71
+ - WebSocket port used between the CLI proxy and the Web UI.
72
+ - Default: `9230`.
73
+ - The UI connects to `ws://localhost:<ui-ws-port>/inspector`.
74
+
75
+ - `--devtools-url <ws-url>` / `--devtools-url=<ws-url>`
76
+ - Explicit DevTools websocket URL to attach to (for advanced usage).
77
+ - If omitted, `rn-inspector` will **auto-discover** DevTools targets via `http://<host>:<port>/json` on a range of ports (starting around the Metro port) and attach to all matching targets.
78
+
79
+ - `--version`
80
+ - Print the `rn-inspector` CLI version and exit.
81
+
82
+ ### Environment variables
83
+
84
+ - `METRO_PORT`
85
+ - If set, this overrides the default Metro port.
86
+ - Equivalent to passing `--port=<METRO_PORT>`.
87
+
88
+ - `RN_INSPECTOR_DEVTOOLS_URL`
89
+ - Default DevTools websocket URL if `--devtools-url` is not provided.
90
+ - Example: `ws://localhost:9229/devtools/page/XXXX-YYYY`.
91
+
92
+ ---
93
+
94
+ ## Multi-device DevTools support
95
+
96
+ `rn-inspector` is designed to work with **multiple React Native targets** at once:
97
+
98
+ - The CLI scans a set of ports (around the Metro port and some common DevTools ports) for `/json` endpoints.
99
+ - For each DevTools target it finds, it:
100
+ - Opens a WebSocket connection.
101
+ - Tags all console and network events with a `deviceId`.
102
+ - The CLI periodically sends a **meta `devices` event** over the UI WebSocket with a list of currently attached devices.
103
+ - The Web UI:
104
+ - Shows a **global device selector** in the header.
105
+ - Filters **Console** and **Network** events by the selected device while still showing Metro-only events.
106
+
107
+ If you prefer to control the DevTools connection manually, you can pass a `--devtools-url` instead of relying on auto-discovery.
108
+
109
+ ---
110
+
111
+ ## Web UI overview
112
+
113
+ When `rn-inspector` is running, the UI is served from:
114
+
115
+ ```text
116
+ http://localhost:<ui-port>
117
+ ```
118
+
119
+ By default this is `http://localhost:4173`.
120
+
121
+ The UI includes:
122
+
123
+ - **Console** page
124
+ - Live console logs from Metro and DevTools.
125
+ - Level filters (log/info/warn/error).
126
+ - Detail drawer with copy-to-clipboard and timestamps.
127
+
128
+ - **Network** page
129
+ - HTTP requests captured via an injected fetch wrapper / DevTools Network domain.
130
+ - Detail drawer with headers, payload, and response preview (including text, JSON, images, and some binary types).
131
+
132
+ - **Header controls**
133
+ - Global **device selector** (backed by the `deviceId` tagging in the CLI).
134
+ - Global **capture toggles** for Console and Network streams.
135
+ - Global **proxy WS status chip** (shows connection status and basic stats; click to reconnect when disconnected).
136
+ - Global **DevTools status chip** (shows connected/closed/error and lets you request a DevTools reconnect from the UI).
137
+
138
+ ---
139
+
140
+ ## Storage & Redux inspection
141
+
142
+ The **Storage** page lets you inspect:
143
+
144
+ - **AsyncStorage** key/value pairs.
145
+ - **Redux** state (if you are using Redux).
146
+
147
+ To keep the CLI simple and avoid depending on your bundler setup, you need to expose these on the global object in your app:
148
+
149
+ ### AsyncStorage
150
+
151
+ In your React Native app (for example in `App.tsx`):
152
+
153
+ ```ts
154
+ import AsyncStorage from "@react-native-async-storage/async-storage";
155
+
156
+ // Make AsyncStorage visible to rn-inspector storage helper
157
+ global.__RN_INSPECTOR_ASYNC_STORAGE__ = AsyncStorage;
158
+ ```
159
+
160
+ Once this is set and the app is running with DevTools debugging enabled, the Storage page's **AsyncStorage** panel will show your keys and values.
161
+
162
+ ### Redux store
163
+
164
+ If you use Redux, expose your store after you create it (anywhere in your app setup):
165
+
166
+ ```ts
167
+ import { createStore } from "redux";
168
+
169
+ const store = createStore(reducer);
170
+
171
+ // Expose Redux store for rn-inspector
172
+ (global as any).__RN_INSPECTOR_REDUX_STORE__ = store;
173
+ ```
174
+
175
+ The Storage page's **Redux State** panel will then show `store.getState()` and update as your state changes.
176
+
177
+ If you do not expose these globals, the Storage page will show a helpful message explaining what to add in your app.
178
+
179
+ ---
180
+
181
+ ## Keyboard shortcuts (CLI)
182
+
183
+ While `rn-inspector` is running in a TTY, the CLI listens for a few simple shortcuts:
184
+
185
+ - `o` / `O`
186
+ - Open the Web UI in your default browser (using `start` on Windows, `open` on macOS, or `xdg-open` on Linux).
187
+
188
+ - `r` / `R`
189
+ - Print a hint on how to fully reload the CLI:
190
+ - Press `Ctrl+C` to stop the process, then run `rn-inspector` again.
191
+
192
+ - `Ctrl+C`
193
+ - Quit `rn-inspector`.
194
+
195
+ If the terminal does not support raw mode (no TTY), these shortcuts are safely disabled.
196
+
197
+ ---
198
+
199
+ ## Error handling & reconnection
200
+
201
+ - If the **Metro websocket** closes or errors, the CLI logs a message and sends a small `meta` event to the UI so you can see the status.
202
+ - For **DevTools websockets** (one per device):
203
+ - The CLI emits `devtools` **status meta events** (`open`, `closed`, `error`) but does **not** auto-retry reconnecting.
204
+ - The Web UI header exposes a **DevTools status chip**; clicking it sends a control message to the CLI to re-run DevTools discovery and attach again.
205
+ - When DevTools auto-discovery finds no `/json` targets, the CLI logs a message _and_ emits a warning `meta` event so the UI can surface a toast like “DevTools auto-discovery found no /json targets (falling back to Metro-only mode)”.
206
+
207
+ ---
208
+
209
+ ## Repository
210
+
211
+ This CLI is part of the **RN Inspector Monorepo**:
212
+
213
+ - GitHub: <https://github.com/afzaal-28/rn-inspector>
214
+
215
+ Please open issues or pull requests in that repository for bugs, feature requests, or contributions.
216
+
217
+ ---
218
+
219
+ ## License
220
+
221
+ Licensed under the [MIT License](../../LICENSE).
@@ -1,7 +1,30 @@
1
1
  export declare const DEFAULT_METRO_PORT = 8081;
2
2
  export declare const DEFAULT_UI_WS_PORT = 9230;
3
3
  export declare const DEFAULT_UI_STATIC_PORT = 4173;
4
+ export declare const DEFAULT_HOST = "127.0.0.1";
5
+ export declare const DEVTOOLS_PORT_OFFSETS: number[];
6
+ export declare const DEVTOOLS_EXTRA_PORTS: number[];
7
+ export declare const DEFAULT_DISCOVERY_TIMEOUT_MS = 750;
8
+ export declare const DEVTOOLS_DISCOVERY_PATH = "/json";
9
+ export declare const METRO_WS_PATH = "/message";
10
+ export declare const UI_WS_PATH = "/inspector";
11
+ export declare const UI_STATIC_INDEX = "index.html";
12
+ export declare const ENV_DEVTOOLS_URL = "RN_INSPECTOR_DEVTOOLS_URL";
13
+ export declare const ENV_METRO_PORT = "METRO_PORT";
14
+ export declare const CONTROL_MSG_TYPE = "control";
15
+ export declare const CONTROL_CMD_RECONNECT = "reconnect-devtools";
16
+ export declare const CONTROL_CMD_FETCH_STORAGE = "fetch-storage";
17
+ export declare const CONTROL_CMD_FETCH_UI = "fetch-ui";
18
+ export declare const CONTROL_CMD_MUTATE_STORAGE = "mutate-storage";
19
+ export declare const CONTROL_CMD_START_MIRROR = "start-mirror";
20
+ export declare const CONTROL_CMD_STOP_MIRROR = "stop-mirror";
21
+ export declare const DEVICE_ID_EXPLICIT = "devtools-explicit";
22
+ export declare const DEVICE_ID_ALL = "all";
23
+ export declare const DEVICE_LABEL_EXPLICIT = "DevTools (explicit URL)";
24
+ export declare const META_KIND_DEVICES = "devices";
25
+ export declare const META_MSG_TYPE = "meta";
4
26
  export declare const baseDir: string;
27
+ export declare function getUiStaticDir(): string;
5
28
  export declare function getCliVersion(): string;
6
29
  export declare function getMetroPort(envPort?: string | undefined): number;
7
30
  //# sourceMappingURL=Index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Index.d.ts","sourceRoot":"","sources":["../../src/config/Index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB,OAAO,CAAC;AACvC,eAAO,MAAM,kBAAkB,OAAO,CAAC;AACvC,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAG3C,eAAO,MAAM,OAAO,EAAE,MAA8E,CAAC;AAErG,wBAAgB,aAAa,IAAI,MAAM,CAStC;AAED,wBAAgB,YAAY,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAOjE"}
1
+ {"version":3,"file":"Index.d.ts","sourceRoot":"","sources":["../../src/config/Index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB,OAAO,CAAC;AACvC,eAAO,MAAM,kBAAkB,OAAO,CAAC;AACvC,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAC3C,eAAO,MAAM,YAAY,cAAc,CAAC;AACxC,eAAO,MAAM,qBAAqB,EAAE,MAAM,EAGzC,CAAC;AACF,eAAO,MAAM,oBAAoB,UAAqB,CAAC;AACvD,eAAO,MAAM,4BAA4B,MAAM,CAAC;AAChD,eAAO,MAAM,uBAAuB,UAAU,CAAC;AAC/C,eAAO,MAAM,aAAa,aAAa,CAAC;AACxC,eAAO,MAAM,UAAU,eAAe,CAAC;AACvC,eAAO,MAAM,eAAe,eAAe,CAAC;AAC5C,eAAO,MAAM,gBAAgB,8BAA8B,CAAC;AAC5D,eAAO,MAAM,cAAc,eAAe,CAAC;AAC3C,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAC1C,eAAO,MAAM,qBAAqB,uBAAuB,CAAC;AAC1D,eAAO,MAAM,yBAAyB,kBAAkB,CAAC;AACzD,eAAO,MAAM,oBAAoB,aAAa,CAAC;AAC/C,eAAO,MAAM,0BAA0B,mBAAmB,CAAC;AAC3D,eAAO,MAAM,wBAAwB,iBAAiB,CAAC;AACvD,eAAO,MAAM,uBAAuB,gBAAgB,CAAC;AACrD,eAAO,MAAM,kBAAkB,sBAAsB,CAAC;AACtD,eAAO,MAAM,aAAa,QAAQ,CAAC;AACnC,eAAO,MAAM,qBAAqB,4BAA4B,CAAC;AAC/D,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAC3C,eAAO,MAAM,aAAa,SAAS,CAAC;AAMpC,eAAO,MAAM,OAAO,EAAE,MACiD,CAAC;AAExE,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,wBAAgB,aAAa,IAAI,MAAM,CAStC;AAED,wBAAgB,YAAY,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CASjE"}
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.baseDir = exports.DEFAULT_UI_STATIC_PORT = exports.DEFAULT_UI_WS_PORT = exports.DEFAULT_METRO_PORT = void 0;
6
+ exports.baseDir = exports.META_MSG_TYPE = exports.META_KIND_DEVICES = exports.DEVICE_LABEL_EXPLICIT = exports.DEVICE_ID_ALL = exports.DEVICE_ID_EXPLICIT = exports.CONTROL_CMD_STOP_MIRROR = exports.CONTROL_CMD_START_MIRROR = exports.CONTROL_CMD_MUTATE_STORAGE = exports.CONTROL_CMD_FETCH_UI = exports.CONTROL_CMD_FETCH_STORAGE = exports.CONTROL_CMD_RECONNECT = exports.CONTROL_MSG_TYPE = exports.ENV_METRO_PORT = exports.ENV_DEVTOOLS_URL = exports.UI_STATIC_INDEX = exports.UI_WS_PATH = exports.METRO_WS_PATH = exports.DEVTOOLS_DISCOVERY_PATH = exports.DEFAULT_DISCOVERY_TIMEOUT_MS = exports.DEVTOOLS_EXTRA_PORTS = exports.DEVTOOLS_PORT_OFFSETS = exports.DEFAULT_HOST = exports.DEFAULT_UI_STATIC_PORT = exports.DEFAULT_UI_WS_PORT = exports.DEFAULT_METRO_PORT = void 0;
7
+ exports.getUiStaticDir = getUiStaticDir;
7
8
  exports.getCliVersion = getCliVersion;
8
9
  exports.getMetroPort = getMetroPort;
9
10
  const path_1 = __importDefault(require("path"));
@@ -11,17 +12,44 @@ const fs_1 = __importDefault(require("fs"));
11
12
  exports.DEFAULT_METRO_PORT = 8081;
12
13
  exports.DEFAULT_UI_WS_PORT = 9230;
13
14
  exports.DEFAULT_UI_STATIC_PORT = 4173;
14
- const baseFile = typeof __filename !== 'undefined' ? __filename : path_1.default.resolve(process.argv[1] ?? '');
15
- exports.baseDir = typeof __dirname !== 'undefined' ? __dirname : path_1.default.dirname(baseFile);
15
+ exports.DEFAULT_HOST = "127.0.0.1";
16
+ exports.DEVTOOLS_PORT_OFFSETS = Array.from({ length: 10 }, (_v, i) => i + 1);
17
+ exports.DEVTOOLS_EXTRA_PORTS = [9222, 9229, 9230];
18
+ exports.DEFAULT_DISCOVERY_TIMEOUT_MS = 750;
19
+ exports.DEVTOOLS_DISCOVERY_PATH = "/json";
20
+ exports.METRO_WS_PATH = "/message";
21
+ exports.UI_WS_PATH = "/inspector";
22
+ exports.UI_STATIC_INDEX = "index.html";
23
+ exports.ENV_DEVTOOLS_URL = "RN_INSPECTOR_DEVTOOLS_URL";
24
+ exports.ENV_METRO_PORT = "METRO_PORT";
25
+ exports.CONTROL_MSG_TYPE = "control";
26
+ exports.CONTROL_CMD_RECONNECT = "reconnect-devtools";
27
+ exports.CONTROL_CMD_FETCH_STORAGE = "fetch-storage";
28
+ exports.CONTROL_CMD_FETCH_UI = "fetch-ui";
29
+ exports.CONTROL_CMD_MUTATE_STORAGE = "mutate-storage";
30
+ exports.CONTROL_CMD_START_MIRROR = "start-mirror";
31
+ exports.CONTROL_CMD_STOP_MIRROR = "stop-mirror";
32
+ exports.DEVICE_ID_EXPLICIT = "devtools-explicit";
33
+ exports.DEVICE_ID_ALL = "all";
34
+ exports.DEVICE_LABEL_EXPLICIT = "DevTools (explicit URL)";
35
+ exports.META_KIND_DEVICES = "devices";
36
+ exports.META_MSG_TYPE = "meta";
37
+ const baseFile = typeof __filename !== "undefined"
38
+ ? __filename
39
+ : path_1.default.resolve(process.argv[1] ?? "");
40
+ exports.baseDir = typeof __dirname !== "undefined" ? __dirname : path_1.default.dirname(baseFile);
41
+ function getUiStaticDir() {
42
+ return path_1.default.resolve(exports.baseDir, "../../ui");
43
+ }
16
44
  function getCliVersion() {
17
45
  try {
18
- const pkgPath = path_1.default.resolve(exports.baseDir, '../../package.json');
19
- const raw = fs_1.default.readFileSync(pkgPath, 'utf8');
46
+ const pkgPath = path_1.default.resolve(exports.baseDir, "../../package.json");
47
+ const raw = fs_1.default.readFileSync(pkgPath, "utf8");
20
48
  const pkg = JSON.parse(raw);
21
- return pkg.version ?? 'unknown';
49
+ return pkg.version ?? "unknown";
22
50
  }
23
51
  catch {
24
- return 'unknown';
52
+ return "unknown";
25
53
  }
26
54
  }
27
55
  function getMetroPort(envPort) {
@@ -1 +1 @@
1
- {"version":3,"file":"Index.js","sourceRoot":"","sources":["../../src/config/Index.ts"],"names":[],"mappings":";;;;;;AAUA,sCASC;AAED,oCAOC;AA5BD,gDAAwB;AACxB,4CAAoB;AAEP,QAAA,kBAAkB,GAAG,IAAI,CAAC;AAC1B,QAAA,kBAAkB,GAAG,IAAI,CAAC;AAC1B,QAAA,sBAAsB,GAAG,IAAI,CAAC;AAE3C,MAAM,QAAQ,GAAW,OAAO,UAAU,KAAK,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AACjG,QAAA,OAAO,GAAW,OAAO,SAAS,KAAK,WAAW,CAAC,CAAC,CAA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AAO,CAAC,eAAO,EAAE,UAAU,CAAC,CAAC;AAC3C,CAAC;AAED,SAAgB,aAAa;IAC3B,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,cAAI,CAAC,OAAO,CAAC,eAAO,EAAE,oBAAoB,CAAC,CAAC;QAC5D,MAAM,GAAG,GAAG,YAAE,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC7C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAyB,CAAC;QACpD,OAAO,GAAG,CAAC,OAAO,IAAI,SAAS,CAAC;IAClC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAgB,YAAY,CAAC,OAA4B;IACvD,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;QAC/B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,IAAI,MAAM,GAAG,KAAK;YAAE,OAAO,MAAM,CAAC;QACzE,OAAO,CAAC,IAAI,CACV,+CAA+C,OAAO,sBAAsB,0BAAkB,EAAE,CACjG,CAAC;IACJ,CAAC;IACD,OAAO,0BAAkB,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { DevtoolsBridge } from "../types/Index";
2
+ export declare function attachDevtoolsBridge(devtoolsWsUrl: string, broadcast: (message: unknown) => void, deviceId: string, devtoolsBridges: Map<string, DevtoolsBridge>): DevtoolsBridge;
3
+ //# sourceMappingURL=bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../src/devtools/bridge.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAiB,MAAM,gBAAgB,CAAC;AAWpE,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,EACrC,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,GAC3C,cAAc,CAsgBhB"}