@react-native/dev-middleware 0.74.0-nightly-20231009-ec1de6194 → 0.74.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 +4 -0
- package/dist/createDevMiddleware.js +16 -11
- package/dist/middleware/deprecated_openFlipperMiddleware.d.ts +25 -0
- package/dist/middleware/deprecated_openFlipperMiddleware.js +52 -0
- package/dist/middleware/deprecated_openFlipperMiddleware.js.flow +28 -0
- package/dist/middleware/openDebuggerMiddleware.js +3 -5
- package/dist/types/Experiments.d.ts +4 -3
- package/dist/types/Experiments.js.flow +4 -3
- package/dist/utils/getDevToolsFrontendUrl.d.ts +2 -4
- package/dist/utils/getDevToolsFrontendUrl.js +5 -26
- package/dist/utils/getDevToolsFrontendUrl.js.flow +2 -5
- package/package.json +7 -16
package/README.md
CHANGED
|
@@ -58,6 +58,10 @@ Returns the list of available WebSocket targets for all connected React Native a
|
|
|
58
58
|
|
|
59
59
|
Returns version metadata used by Chrome DevTools.
|
|
60
60
|
|
|
61
|
+
#### GET `/debugger-frontend`
|
|
62
|
+
|
|
63
|
+
Subpaths of this endpoint are reserved to serve the JavaScript debugger frontend.
|
|
64
|
+
|
|
61
65
|
#### POST `/open-debugger`
|
|
62
66
|
|
|
63
67
|
Open the JavaScript debugger for a given CDP target (direct Hermes debugging).
|
|
@@ -10,6 +10,9 @@ var _debuggerFrontend = _interopRequireDefault(
|
|
|
10
10
|
var _connect = _interopRequireDefault(require("connect"));
|
|
11
11
|
var _path = _interopRequireDefault(require("path"));
|
|
12
12
|
var _serveStatic = _interopRequireDefault(require("serve-static"));
|
|
13
|
+
var _deprecated_openFlipperMiddleware = _interopRequireDefault(
|
|
14
|
+
require("./middleware/deprecated_openFlipperMiddleware")
|
|
15
|
+
);
|
|
13
16
|
var _openDebuggerMiddleware = _interopRequireDefault(
|
|
14
17
|
require("./middleware/openDebuggerMiddleware")
|
|
15
18
|
);
|
|
@@ -33,8 +36,6 @@ function _interopRequireDefault(obj) {
|
|
|
33
36
|
* @oncall react_native
|
|
34
37
|
*/
|
|
35
38
|
|
|
36
|
-
// $FlowFixMe[untyped-import] TODO: type serve-static
|
|
37
|
-
|
|
38
39
|
function createDevMiddleware({
|
|
39
40
|
projectRoot,
|
|
40
41
|
serverBaseUrl,
|
|
@@ -53,14 +54,18 @@ function createDevMiddleware({
|
|
|
53
54
|
const middleware = (0, _connect.default)()
|
|
54
55
|
.use(
|
|
55
56
|
"/open-debugger",
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
experiments.enableNewDebugger
|
|
58
|
+
? (0, _openDebuggerMiddleware.default)({
|
|
59
|
+
serverBaseUrl,
|
|
60
|
+
inspectorProxy,
|
|
61
|
+
browserLauncher: unstable_browserLauncher,
|
|
62
|
+
eventReporter: unstable_eventReporter,
|
|
63
|
+
experiments,
|
|
64
|
+
logger,
|
|
65
|
+
})
|
|
66
|
+
: (0, _deprecated_openFlipperMiddleware.default)({
|
|
67
|
+
logger,
|
|
68
|
+
})
|
|
64
69
|
)
|
|
65
70
|
.use(
|
|
66
71
|
"/debugger-frontend",
|
|
@@ -76,7 +81,7 @@ function createDevMiddleware({
|
|
|
76
81
|
}
|
|
77
82
|
function getExperiments(config) {
|
|
78
83
|
return {
|
|
79
|
-
|
|
84
|
+
enableNewDebugger: config.enableNewDebugger ?? false,
|
|
80
85
|
enableOpenDebuggerRedirect: config.enableOpenDebuggerRedirect ?? false,
|
|
81
86
|
};
|
|
82
87
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* @format
|
|
9
|
+
* @oncall react_native
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { NextHandleFunction } from "connect";
|
|
13
|
+
import type { Logger } from "../types/Logger";
|
|
14
|
+
type Options = Readonly<{ logger?: Logger }>;
|
|
15
|
+
/**
|
|
16
|
+
* Open the legacy Flipper debugger (Hermes).
|
|
17
|
+
*
|
|
18
|
+
* @deprecated This replicates the pre-0.73 workflow of opening Flipper via the
|
|
19
|
+
* `flipper://` URL scheme, failing if Flipper is not installed locally. This
|
|
20
|
+
* flow will be removed in a future version.
|
|
21
|
+
*/
|
|
22
|
+
declare function deprecated_openFlipperMiddleware(
|
|
23
|
+
$$PARAM_0$$: Options
|
|
24
|
+
): NextHandleFunction;
|
|
25
|
+
export default deprecated_openFlipperMiddleware;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.default = deprecated_openFlipperMiddleware;
|
|
7
|
+
var _open = _interopRequireDefault(require("open"));
|
|
8
|
+
function _interopRequireDefault(obj) {
|
|
9
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the MIT license found in the
|
|
15
|
+
* LICENSE file in the root directory of this source tree.
|
|
16
|
+
*
|
|
17
|
+
*
|
|
18
|
+
* @format
|
|
19
|
+
* @oncall react_native
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
const FLIPPER_SELF_CONNECT_URL =
|
|
23
|
+
"flipper://null/Hermesdebuggerrn?device=React%20Native";
|
|
24
|
+
/**
|
|
25
|
+
* Open the legacy Flipper debugger (Hermes).
|
|
26
|
+
*
|
|
27
|
+
* @deprecated This replicates the pre-0.73 workflow of opening Flipper via the
|
|
28
|
+
* `flipper://` URL scheme, failing if Flipper is not installed locally. This
|
|
29
|
+
* flow will be removed in a future version.
|
|
30
|
+
*/
|
|
31
|
+
function deprecated_openFlipperMiddleware({ logger }) {
|
|
32
|
+
return async (req, res, next) => {
|
|
33
|
+
if (req.method === "POST") {
|
|
34
|
+
logger?.info("Launching JS debugger...");
|
|
35
|
+
try {
|
|
36
|
+
logger?.warn(
|
|
37
|
+
"Attempting to debug JS in Flipper (deprecated). This requires " +
|
|
38
|
+
"Flipper to be installed on your system to handle the " +
|
|
39
|
+
"'flipper://' URL scheme."
|
|
40
|
+
);
|
|
41
|
+
await (0, _open.default)(FLIPPER_SELF_CONNECT_URL);
|
|
42
|
+
res.end();
|
|
43
|
+
} catch (e) {
|
|
44
|
+
logger?.error(
|
|
45
|
+
"Error launching Flipper: " + e.message ?? "Unknown error"
|
|
46
|
+
);
|
|
47
|
+
res.writeHead(500);
|
|
48
|
+
res.end();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
|
+
* @oncall react_native
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { NextHandleFunction } from "connect";
|
|
13
|
+
import type { Logger } from "../types/Logger";
|
|
14
|
+
|
|
15
|
+
type Options = $ReadOnly<{
|
|
16
|
+
logger?: Logger,
|
|
17
|
+
}>;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Open the legacy Flipper debugger (Hermes).
|
|
21
|
+
*
|
|
22
|
+
* @deprecated This replicates the pre-0.73 workflow of opening Flipper via the
|
|
23
|
+
* `flipper://` URL scheme, failing if Flipper is not installed locally. This
|
|
24
|
+
* flow will be removed in a future version.
|
|
25
|
+
*/
|
|
26
|
+
declare export default function deprecated_openFlipperMiddleware(
|
|
27
|
+
Options
|
|
28
|
+
): NextHandleFunction;
|
|
@@ -56,7 +56,7 @@ function openDebuggerMiddleware({
|
|
|
56
56
|
if (typeof appId === "string") {
|
|
57
57
|
logger?.info(
|
|
58
58
|
(launchType === "launch" ? "Launching" : "Redirecting to") +
|
|
59
|
-
" JS debugger..."
|
|
59
|
+
" JS debugger (experimental)..."
|
|
60
60
|
);
|
|
61
61
|
target = targets.find((_target) => _target.description === appId);
|
|
62
62
|
} else {
|
|
@@ -89,8 +89,7 @@ function openDebuggerMiddleware({
|
|
|
89
89
|
await browserLauncher.launchDebuggerAppWindow(
|
|
90
90
|
(0, _getDevToolsFrontendUrl.default)(
|
|
91
91
|
target.webSocketDebuggerUrl,
|
|
92
|
-
serverBaseUrl
|
|
93
|
-
experiments
|
|
92
|
+
serverBaseUrl
|
|
94
93
|
)
|
|
95
94
|
)
|
|
96
95
|
);
|
|
@@ -101,8 +100,7 @@ function openDebuggerMiddleware({
|
|
|
101
100
|
Location: (0, _getDevToolsFrontendUrl.default)(
|
|
102
101
|
target.webSocketDebuggerUrl,
|
|
103
102
|
// Use a relative URL.
|
|
104
|
-
""
|
|
105
|
-
experiments
|
|
103
|
+
""
|
|
106
104
|
),
|
|
107
105
|
});
|
|
108
106
|
res.end();
|
|
@@ -10,10 +10,11 @@
|
|
|
10
10
|
|
|
11
11
|
export type Experiments = Readonly<{
|
|
12
12
|
/**
|
|
13
|
-
* Enables the
|
|
14
|
-
*
|
|
13
|
+
* Enables the new JS debugger launch flow and custom debugger frontend
|
|
14
|
+
* (@react-native/debugger-frontend). When disabled, /open-debugger will
|
|
15
|
+
* trigger the legacy Flipper connection flow.
|
|
15
16
|
*/
|
|
16
|
-
|
|
17
|
+
enableNewDebugger: boolean;
|
|
17
18
|
/**
|
|
18
19
|
* Enables the handling of GET requests in the /open-debugger endpoint,
|
|
19
20
|
* in addition to POST requests. GET requests respond by redirecting to
|
|
@@ -10,10 +10,11 @@
|
|
|
10
10
|
|
|
11
11
|
export type Experiments = $ReadOnly<{
|
|
12
12
|
/**
|
|
13
|
-
* Enables the
|
|
14
|
-
*
|
|
13
|
+
* Enables the new JS debugger launch flow and custom debugger frontend
|
|
14
|
+
* (@react-native/debugger-frontend). When disabled, /open-debugger will
|
|
15
|
+
* trigger the legacy Flipper connection flow.
|
|
15
16
|
*/
|
|
16
|
-
|
|
17
|
+
enableNewDebugger: boolean,
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* Enables the handling of GET requests in the /open-debugger endpoint,
|
|
@@ -9,13 +9,11 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import type { Experiments } from "../types/Experiments";
|
|
13
12
|
/**
|
|
14
|
-
*
|
|
13
|
+
* Get the DevTools frontend URL to debug a given React Native CDP target.
|
|
15
14
|
*/
|
|
16
15
|
declare function getDevToolsFrontendUrl(
|
|
17
16
|
webSocketDebuggerUrl: string,
|
|
18
|
-
devServerUrl: string
|
|
19
|
-
experiments: Experiments
|
|
17
|
+
devServerUrl: string
|
|
20
18
|
): string;
|
|
21
19
|
export default getDevToolsFrontendUrl;
|
|
@@ -16,33 +16,12 @@ exports.default = getDevToolsFrontendUrl;
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
* latest version known to be compatible with Hermes.
|
|
21
|
-
*
|
|
22
|
-
* Revision should be the full identifier from:
|
|
23
|
-
* https://chromium.googlesource.com/chromium/src.git
|
|
24
|
-
*/
|
|
25
|
-
const DEVTOOLS_FRONTEND_REV = "d9568d04d7dd79269c5a655d7ada69650c5a8336"; // Chrome 100.0.4896.75
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Construct the URL to Chrome DevTools connected to a given debugger target.
|
|
19
|
+
* Get the DevTools frontend URL to debug a given React Native CDP target.
|
|
29
20
|
*/
|
|
30
|
-
function getDevToolsFrontendUrl(
|
|
31
|
-
webSocketDebuggerUrl,
|
|
32
|
-
devServerUrl,
|
|
33
|
-
experiments
|
|
34
|
-
) {
|
|
21
|
+
function getDevToolsFrontendUrl(webSocketDebuggerUrl, devServerUrl) {
|
|
35
22
|
const scheme = new URL(webSocketDebuggerUrl).protocol.slice(0, -1);
|
|
36
|
-
const webSocketUrlWithoutProtocol =
|
|
37
|
-
/^wss?:\/\//,
|
|
38
|
-
""
|
|
23
|
+
const webSocketUrlWithoutProtocol = encodeURIComponent(
|
|
24
|
+
webSocketDebuggerUrl.replace(/^wss?:\/\//, "")
|
|
39
25
|
);
|
|
40
|
-
|
|
41
|
-
return `${`${devServerUrl}/debugger-frontend/rn_inspector.html`}?${scheme}=${encodeURIComponent(
|
|
42
|
-
webSocketUrlWithoutProtocol
|
|
43
|
-
)}&sources.hide_add_folder=true`;
|
|
44
|
-
}
|
|
45
|
-
return `${`https://chrome-devtools-frontend.appspot.com/serve_rev/@${DEVTOOLS_FRONTEND_REV}/devtools_app.html`}?panel=console&${scheme}=${encodeURIComponent(
|
|
46
|
-
webSocketUrlWithoutProtocol
|
|
47
|
-
)}`;
|
|
26
|
+
return `${`${devServerUrl}/debugger-frontend/rn_inspector.html`}?${scheme}=${webSocketUrlWithoutProtocol}&sources.hide_add_folder=true`;
|
|
48
27
|
}
|
|
@@ -9,13 +9,10 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import type { Experiments } from "../types/Experiments";
|
|
13
|
-
|
|
14
12
|
/**
|
|
15
|
-
*
|
|
13
|
+
* Get the DevTools frontend URL to debug a given React Native CDP target.
|
|
16
14
|
*/
|
|
17
15
|
declare export default function getDevToolsFrontendUrl(
|
|
18
16
|
webSocketDebuggerUrl: string,
|
|
19
|
-
devServerUrl: string
|
|
20
|
-
experiments: Experiments
|
|
17
|
+
devServerUrl: string
|
|
21
18
|
): string;
|
package/package.json
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native/dev-middleware",
|
|
3
|
-
"version": "0.74.0
|
|
3
|
+
"version": "0.74.0",
|
|
4
4
|
"description": "Dev server middleware for React Native",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"react-native",
|
|
7
|
-
"tools"
|
|
8
|
-
],
|
|
5
|
+
"keywords": ["react-native", "tools"],
|
|
9
6
|
"homepage": "https://github.com/facebook/react-native/tree/HEAD/packages/dev-middleware#readme",
|
|
10
7
|
"bugs": "https://github.com/facebook/react-native/issues",
|
|
11
8
|
"repository": {
|
|
@@ -14,25 +11,19 @@
|
|
|
14
11
|
"directory": "packages/dev-middleware"
|
|
15
12
|
},
|
|
16
13
|
"license": "MIT",
|
|
17
|
-
"exports": {
|
|
18
|
-
|
|
19
|
-
"./package.json": "./package.json"
|
|
20
|
-
},
|
|
21
|
-
"files": [
|
|
22
|
-
"dist"
|
|
23
|
-
],
|
|
14
|
+
"exports": { ".": "./dist/index.js", "./package.json": "./package.json" },
|
|
15
|
+
"files": ["dist"],
|
|
24
16
|
"dependencies": {
|
|
25
17
|
"@isaacs/ttlcache": "^1.4.1",
|
|
26
|
-
"@react-native/debugger-frontend": "0.74.0
|
|
18
|
+
"@react-native/debugger-frontend": "^0.74.0",
|
|
27
19
|
"chrome-launcher": "^0.15.2",
|
|
28
20
|
"chromium-edge-launcher": "^1.0.0",
|
|
29
21
|
"connect": "^3.6.5",
|
|
30
22
|
"debug": "^2.2.0",
|
|
31
23
|
"node-fetch": "^2.2.0",
|
|
24
|
+
"open": "^7.0.3",
|
|
32
25
|
"serve-static": "^1.13.1",
|
|
33
26
|
"temp-dir": "^2.0.0"
|
|
34
27
|
},
|
|
35
|
-
"engines": {
|
|
36
|
-
"node": ">=18"
|
|
37
|
-
}
|
|
28
|
+
"engines": { "node": ">=18" }
|
|
38
29
|
}
|