-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add --experimental-debugger-frontend flag, restore 0.72 flow as base (#…
…40766) Summary: Pull Request resolved: #40766 This changeset allows users to opt into the new debugger frontend experience by passing `--experimental-debugger` to `react-native start`. **We are defaulting this option to `true`** for now, but will continue to evaluate this feature before 0.73 ships. It restores Flipper (via `flipper://`) as the default handling for `/open-debugger` (matching 0.72 behaviour) when this flag is not enabled. Detailed changes: - Replaces `enableCustomDebuggerFrontend` experiment in `dev-middleware` with `enableNewDebugger`. The latter now hard-swaps between the Flipper and new launch flows. - Removes now-unused switching of `devtoolsFrontendUrl`. - Implements `deprecated_openFlipperMiddleware` (matching previous RN CLI implementation). - Disables "`j` to debug" key handler by default. - Marks "`j` to debug" and `/open-debugger` console logs as experimental. Changelog: [Changed][General] Gate new debugger frontend behind `--experimental-debugger` flag, restore Flipper as base launch flow Reviewed By: motiz88 Differential Revision: D50084590 fbshipit-source-id: 5234634f20110cb7933b1787bd2c86f645411fff
- Loading branch information
1 parent
4dcd5f1
commit 9e068ac
Showing
11 changed files
with
152 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow strict | ||
* @format | ||
* @oncall react_native | ||
*/ | ||
|
||
declare module 'open' { | ||
import type {ChildProcess} from 'child_process'; | ||
|
||
declare export type Options = $ReadOnly<{ | ||
wait?: boolean, | ||
background?: boolean, | ||
newInstance?: boolean, | ||
allowNonzeroExitCode?: boolean, | ||
... | ||
}>; | ||
|
||
declare type open = ( | ||
target: string, | ||
options?: Options, | ||
) => Promise<ChildProcess>; | ||
|
||
declare module.exports: open; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
packages/dev-middleware/src/middleware/deprecated_openFlipperMiddleware.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow strict-local | ||
* @format | ||
* @oncall react_native | ||
*/ | ||
|
||
import type {NextHandleFunction} from 'connect'; | ||
import type {IncomingMessage, ServerResponse} from 'http'; | ||
import type {Logger} from '../types/Logger'; | ||
|
||
import open from 'open'; | ||
|
||
const FLIPPER_SELF_CONNECT_URL = | ||
'flipper://null/Hermesdebuggerrn?device=React%20Native'; | ||
|
||
type Options = $ReadOnly<{ | ||
logger?: Logger, | ||
}>; | ||
|
||
/** | ||
* Open the legacy Flipper debugger (Hermes). | ||
* | ||
* @deprecated This replicates the pre-0.73 workflow of opening Flipper via the | ||
* `flipper://` URL scheme, failing if Flipper is not installed locally. This | ||
* flow will be removed in a future version. | ||
*/ | ||
export default function deprecated_openFlipperMiddleware({ | ||
logger, | ||
}: Options): NextHandleFunction { | ||
return async ( | ||
req: IncomingMessage, | ||
res: ServerResponse, | ||
next: (err?: Error) => void, | ||
) => { | ||
if (req.method === 'POST') { | ||
logger?.info('Launching JS debugger...'); | ||
|
||
try { | ||
logger?.warn( | ||
'Attempting to debug JS in Flipper (deprecated). This requires ' + | ||
'Flipper to be installed on your system to handle the ' + | ||
"'flipper://' URL scheme.", | ||
); | ||
await open(FLIPPER_SELF_CONNECT_URL); | ||
res.end(); | ||
} catch (e) { | ||
logger?.error( | ||
'Error launching Flipper: ' + e.message ?? 'Unknown error', | ||
); | ||
res.writeHead(500); | ||
res.end(); | ||
} | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters