Summary:
This PR adds the missing test coverage for the standalone Fusebox debugger shell in `StandaloneFuseboxShell-test`.
First, I added some missing expectation for the success case (`enableStandaloneFuseboxShell=true` and no errors) already present:
- the assertion that `unstable_prepareFuseboxShell` is called just one time during middleware initialization
- the assertion that `launchDebuggerAppWindow` is never called when the standalone shell is available
Then, I added the missing test for the case when `unstable_prepareFuseboxShell` returns one of the error code like eg. `platform_not_supported` (as reported also in the TODO that I removed).
In this way now the test is verifying the full behaviour for the new standalone mode for debugger/dev tools.
## Changelog:
[GENERAL] [CHANGED] - Added missing tests for Standalone fusebox shell
Pull Request resolved: https://github.com/facebook/react-native/pull/55460
Test Plan:
- Ran `StandaloneFuseboxShell-test` and verify all tests cases passed
- Ran the full React Native test suite to ensure all tests pass.
- Verified test correctness by intentionally breaking production code:
- removing the calls to the `DefaultBrowserLauncher` in `openDebuggerMiddleware` to verify that the tests were correctly failing
Reviewed By: Abbondanzo
Differential Revision: D93157076
Pulled By: huntie
fbshipit-source-id: 51c12ad67dd929035f779b53add9163a6619cf41
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55728
Fixes unwanted side effect launches of the debugger shell in tests (likely introduced in D88161573!).
Also adds error guard on `DefaultAppLauncher` to ensure that the implementation is always mocked.
Changelog: [Internal]
Reviewed By: vzaidman
Differential Revision: D94230761
fbshipit-source-id: 966f6f09c38aa55594091bd7d34a5c78dc6eee93
Summary:
Renames the **"BrowserLauncher"** concept (`unstable_browserLauncher`) to **"DevToolLauncher"** (`unstable_toolLauncher`), since the scope is now widened to open the desktop debugger shell by default.
Also rename and remove `unstable_` prefixes for `launchDebuggerShell` and `prepareDebuggerShell` methods (APIs remain unstable on the root option key).
**Why not `DebuggerLauncher`?**
This naming remains wide enough to cover other host process delegation in future (e.g. opening other secondary tools, or opening a generic URL in the browser). Debugger launching methods remain specifically named to match their intent.
Changelog: [Internal]
Reviewed By: vzaidman
Differential Revision: D94218654
fbshipit-source-id: e59d5465f200666cd0f1a189414f2223f5e46f69
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55549
**Context**
Clean up the legacy `rn_inspector.html` entry point. React Native DevTools has been the default since 0.76, and we have now removed all internal dependencies at Meta.
**This diff**
- Remove `prefersFuseboxFrontend` metadata from `unstable_eventReporter` API.
Changelog: [Internal]
Reviewed By: vzaidman
Differential Revision: D93247602
fbshipit-source-id: 278f847433259c98deb121562e34a12ff59058a2
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55548
**Context**
Clean up the legacy `rn_inspector.html` entry point. React Native DevTools has been the default since 0.76, and we have now removed all internal dependencies at Meta.
We've verified that Reanimated (`react-native-worklets`) also do not depend on this workflow, and documents `chrome://inspect` instead.
**This diff**
- Launching the debugger will no longer check for the `prefersFuseboxFrontend` capability flag (internal contract with the debugger server).
- The modern `rn_fusebox.html` entry point will always be used.
Changelog: [Internal]
Reviewed By: vzaidman
Differential Revision: D93247604
fbshipit-source-id: 1c7b6838d9105c9206ffc0030374dc1ee559a6dd
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55285
Changelog: [GENERAL] [CHANGED] - `createDevMiddleware` now accepts `string | URL` for `serverBaseUrl`
Replaces the serverBaseUrl string type with a native URL object across the Metro CLI and Gateway packages.
This change improves type safety and makes URL manipulation more robust by leveraging the built-in URL API instead of string concatenation.
The public createDevMiddleware API has been updated to accept either a string or URL for the serverBaseUrl option.
Internally within the dev-middleware package, the internal APIs (InspectorProxy, openDebuggerMiddleware, getDevToolsFrontendUrl) use URL objects instead of strings.
https://www.npmjs.com/package/react-native/dev-middleware
Reviewed By: vzaidman
Differential Revision: D90987090
fbshipit-source-id: ec5b8faa4ed5c24b489c3d63f7b6030073be5403
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55237
Adds multi-session support to the Node side of the inspector-proxy protocol implementation. The protocol now has an explicit `sessionId` property in all relevant messages.
Multi-session support is fully backwards compatible:
* An app that does not report itself as multi-session capable will get the old proxy behaviour.
* If the `enableStandaloneFuseboxShell` experiment flag is disabled by the integrator/framework, we automatically disable multi-session support, too. This is to guarantee that we continue to have at most one active RNDT window/tab open per app. (The standalone shell guarantees this independently of the proxy, while the old browser-based flow requires the proxy to keep enforcing the single-session UX.)
Changelog: [General][Added] Support multiple CDP connections to one React Native Host (diff 2 of 2)
Reviewed By: robhogan
Differential Revision: D90174643
fbshipit-source-id: b277cf2777d2018c44252dc4eae7b197e51cfb79
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55238
Adds multi-session support to the inspector-proxy protocol, specifically to the C++ `InspectorPackagerConnection` class that implements the "device" side of the protocol.
Changelog: [General][Added] Support multiple CDP connections to one React Native Host (diff 1 of 2)
Reviewed By: hoxyq
Differential Revision: D90174642
fbshipit-source-id: b22946aaa5a6f3d2d4a81cbfe81d371ea2bc0632
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55268
Allow WS debugger connection to origin from debugger url.
Also notify the user on Metro if a connection is rejected.
Changelog: [General][Fixed] - Reaching Metro from Debugger on urls other than localhost:8081 and 127.0.0.1:8081.
Reviewed By: robhogan, yungsters
Differential Revision: D91130956
fbshipit-source-id: 107dbc78aa60b888325f5c6dca68cc28f4e6af52
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55235
Use of Node's `url.parse` is deprecated and emits a runtime warning (when used in 1P code) from Node 24.
This wouldn't directly affect RN users, but does create noise running from monorepo source.
Changelog: [Internal]
Reviewed By: GijsWeterings
Differential Revision: D90992431
fbshipit-source-id: d53e2837cd13bba3fbb24302c5916038ae0e5a50
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55075
It's been >1y since we introduced this notice (and introduced the `--client-logs` flag) — clean up.
Changelog:
[General][Changed] - Remove "JavaScript logs have moved!" notice from dev server CLI
Reviewed By: hoxyq
Differential Revision: D90247471
fbshipit-source-id: dc13c90476c65c301bdb3a51db91f0e5fe0b326b
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55008
Changelog: [Internal] removed an unstable function briefly added in #54447
This was previously added in https://github.com/facebook/react-native/pull/54447, but not needed anymore as we found a different way to get this information without exposing a special API for that.
Reviewed By: robhogan
Differential Revision: D89962175
fbshipit-source-id: 3636ef8815678781ee39ef8211f00bde69b5ce63
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54528
Changelog: [Internal]
Currently, `DefaultBrowserLauncher.js` holds arguments configuring how the debugger shell is launched. Instead, move some of them downstream, and make `DefaultBrowserLauncher.js` use the defaults.
Reviewed By: motiz88
Differential Revision: D86772692
fbshipit-source-id: 826bb6236dc3cba3c4b0d455aebf3f81c4e8ed6f
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54447
Changelog: [Internal]
Expose `unstable_hasConnectedDevices` and `unstable_addHasConnectedDevicesListener` from both `InspectorProxy` and `DevMiddleware` that tells the user if any devices are connected to `devMiddleware` and allows to listen to whenever this state changes.
Reviewed By: motiz88
Differential Revision: D86319965
fbshipit-source-id: 18a30138b16a41821dc17a63e9d9cada04888f34
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54754
Enables the standalone app shell for React Native DevTools by default.
We preserve + document this flag as an opt-out (allowing Frameworks to override this behaviour if needed).
Changelog: [Internal]
Reviewed By: motiz88
Differential Revision: D88161573
fbshipit-source-id: 64ee191dcead4e639bb3067bc9e715b1c8cdf80d
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53923
Motivated by feedback on D83070252. This prevents us from including decodable information about debug targets in these values.
Changelog: [Internal]
Reviewed By: motiz88
Differential Revision: D83139401
fbshipit-source-id: 01b01d23e4dfb06e400729b8cedf1fe2e098b209
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53921
Changelog: [Internal] `devMiddleware` removed the unused option `projectRoot`
This option was used only in a dead branch of the code inside `InspectorProxy`.
The scenario where it appeared was enabling resolving script sources (`Debugger.getScriptSource`) starting with `file://` which were coming from the file system. However, we don't seem to ever point scripts at the filesystem this way.
Reviewed By: huntie
Differential Revision: D82739662
fbshipit-source-id: 9a130eaa83cb94ae0e36a5a1102c56ff8a36cffc
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53884
Changelog: [Internal]
Now that there's a clear display for when HMR is disconnected, we don't want to show messages regardless devices connection and disconnection to the DevServer because they are too partial.
Reviewed By: huntie
Differential Revision: D82727105
fbshipit-source-id: 32dd077f85d2044f89ae2d8d60a37c0ec6cccbbf
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53510
Changelog: [Internal]
Electron imposes a [strange undocumented limitation](https://github.com/electron/electron/pull/13039) on the format of command-line arguments, which for some reason only affects Windows. Basically, the command line is truncated after the first argument that looks like a URL.
Electron's recommendation for avoiding this is to prefix the argument list with `--`, but I prefer switching to a different arg format (`--x=y` instead of `--x y`) that will prevent us from ever running into this issue.
NOTE: I will follow up with a diff to harden arg parsing in our Electron code so that it only accepts the `--x=y` format.
Reviewed By: huntie
Differential Revision: D81237713
fbshipit-source-id: a255dc63b6486b96d9f7ccf780d1b09bc4ddf7e0
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53464
Changelog: [Internal]
Minor followup from D78351937 - the Fusebox console notice still mentions that RNDT requires Chrome or Edge. Let's remove this mention for users opted into the standalone shell experiment.
Reviewed By: huntie
Differential Revision: D81040965
fbshipit-source-id: a290d3164261f8a1087229edfe3f69a2a9b49960
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53435
Changelog: [Internal] Support setting `enableStandaloneFuseboxShell: true` in OSS with no custom `BrowserLauncher`
Makes it possible for frameworks to enable the React Native DevTools standalone shell in open source by passing `unstable_experiments: {enableStandaloneFuseboxShell: true}` to `createDevMiddleware()`.
When this experiment is enabled:
* The RNDT shell binary will be prefetched in the background as soon as the dev server starts (into a local cache managed by [DotSlash](https://dotslash-cli.com/)).
* If prefetching is successful, then "Open DevTools" actions will be handled by launching the RNDT frontend in the standalone shell, instead of in Chrome/Edge.
* If prefetching is not successful, then we'll notify the user about the error, and "Open DevTools" will continue to be handled by Chrome/Edge, as before.
* If the user attempts to open DevTools more than once for the same app, the standalone shell will reuse the existing window (as opposed to the current behaviour of always creating a new Chrome/Edge window).
* The appropriate DevTools window will automatically foreground itself upon pausing on a breakpoint.
Reviewed By: huntie
Differential Revision: D78351937
fbshipit-source-id: 6d5baa8fa866760f1d527108cd3c42bcab68cf57
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53437
Changelog: [Internal]
The React Native DevTools standalone shell is distributed as a DotSlash file that downloads the required binaries lazily. This diff adds support in dev-middleware for a new `BrowserLauncher.unstable_prepareFuseboxShell` method that integrations can use to kick off the download early. Integrations are expected to implement this by calling the `unstable_prepareDebuggerShell` function (added to the `debugger-shell` package in D78413091).
If `BrowserLauncher.unstable_prepareFuseboxShell` returns an error, dev-middleware will fall back to the browser-based launch flow, even for users opted into the `enableStandaloneFuseboxShell` experiment.
Reviewed By: huntie
Differential Revision: D78413092
fbshipit-source-id: 6868bf07e16353fcd83337ae54c87c5a641a0f99
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53468
# Changelog: [Internal]
I've just discovered today that Chrome DevTools has a native support for `panel` query parameter, we don't need a custom one.
Reviewed By: alanleedev
Differential Revision: D81052828
fbshipit-source-id: 6f8ef5b576dbff70cabd6ab792bc0f6e615928e7
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52947
Wires up a `landingView` parameter to be passed to rn_fusebox.html that we can use to focus an arbitrary view on launch. Used from the new perf analyze scenario to open devtools on the performance panel.
Changelog:
[Android][Added] - Adds a landing view parameter to opening RNDT, enabling arbitrary view focus on launch.
Reviewed By: hoxyq
Differential Revision: D79329081
fbshipit-source-id: b1513a803f4add803100cebd08f53e59a08e64d4
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52704
Stack traces for console calls are passed to the debugger when they are relative to device. (e.g. 10.0.2.2 for Android emulator)
Changelog: [android][fixed] fix stack trace linkifying failing when using Android emulator and other situations where the device and debugger have different bundle urls
Reviewed By: motiz88
Differential Revision: D78553183
fbshipit-source-id: 91d7e7ccc99d12ec7d06f4201237ecf557a46c4f
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52473
Shared utils that were located in the root of `scripts/` are now colocated closer to their dependencies or moved to `scripts/shared/` — simplifying the root directory layout.
Changelog: [Internal]
Reviewed By: robhogan
Differential Revision: D77873875
fbshipit-source-id: e04dba41a1ef811d32793931033fdfa93afad0cd
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52289
The old `devtools://devtools/...` URL is **unsupported** with our modern debugger backend.
This reference was something we'd been intentionally leaving in place to preserve the old experience in Flipper — we can now remove.
Changelog: [Internal]
Reviewed By: motiz88
Differential Revision: D77368319
fbshipit-source-id: 400183e9bc477a887d66d79b412277971cf425e5
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51788
Adds `flow` to the remaining files that are lacking it in the `packages/rn-tester` directory.
This also adds any necessary type annotations and fixes lint warnings.
Changelog:
[Internal]
Reviewed By: SamChou19815
Differential Revision: D75899307
fbshipit-source-id: 27a74ed0007b3b754446a45931c2c148312d5e3a
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51687
Changelog: [Internal]
# Context
This is the first of several commits that aim to implement a **standalone shell for React Native DevTools**. This will be a lightweight desktop app designed to host the debugger frontend, in much the same way as we currently use Chrome or Edge. The launch flow will otherwise remain **very similar** to the one that exists today.
## What's changing for users?
1. With this commit, nothing; we're merely setting up an experiment flag (for stage 1 - Meta-internal testing) and will make separate plans for open source rollout, coordinated with our framework maintainer partners.
2. If the experiment is successful, we aim to *eventually* phase out the use of Chrome/Edge in React Native DevTools and ship the standalone shell as standard to all React Native developers. This is to enable further improvements that will rely on the standalone shell to work.
3. The first iteration of the standalone shell aims to solve some concrete pain points such as the "dead window problem" - the fact that opening DevTools multiple times for the same target will leave behind a now-dead window (that would ideally have been reused).
## This diff
We amend the `unstable_experiments` and `unstable_browserLauncher` APIs in `dev-middleware` to add basic support for launching a standalone shell based on a frontend URL and a *window key* - the latter being an opaque string that the shell process can match against previous launches in order to reuse and foreground existing windows.
We leave it up to `BrowserLauncher` implementers ( = frameworks) to provide a working implementation of `unstable_showFuseboxShell`, and do not provide one with `DefaultBrowserLauncher`. This will effectively allow us to dependency-inject the actual shell implementation at stage 1 so we don't increase the download size of React Native unnecessarily.
Reviewed By: rickhanlonii, robhogan
Differential Revision: D74904547
fbshipit-source-id: fbc6eac97923062bda8892bc130b39051845ea82
Summary:
Running with
```
DEBUG=Metro:InspectorProxy DEV=1 js1 run --no-tty-print
```
When a message larger than 100kb is send over the cdp, log it.
Changelog: [Internal]
Reviewed By: huntie
Differential Revision: D75000887
fbshipit-source-id: 6f426ed4db7ac1996c4f26461a6e0d13c096e5cd