@react-native/dev-middleware 0.73.3 → 0.73.4
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/dist/createDevMiddleware.js +16 -9
- package/dist/inspector-proxy/InspectorProxy.js +4 -3
- 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 +2 -1
|
@@ -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
|
);
|
|
@@ -53,14 +56,18 @@ function createDevMiddleware({
|
|
|
53
56
|
const middleware = (0, _connect.default)()
|
|
54
57
|
.use(
|
|
55
58
|
"/open-debugger",
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
experiments.enableNewDebugger
|
|
60
|
+
? (0, _openDebuggerMiddleware.default)({
|
|
61
|
+
serverBaseUrl,
|
|
62
|
+
inspectorProxy,
|
|
63
|
+
browserLauncher: unstable_browserLauncher,
|
|
64
|
+
eventReporter: unstable_eventReporter,
|
|
65
|
+
experiments,
|
|
66
|
+
logger,
|
|
67
|
+
})
|
|
68
|
+
: (0, _deprecated_openFlipperMiddleware.default)({
|
|
69
|
+
logger,
|
|
70
|
+
})
|
|
64
71
|
)
|
|
65
72
|
.use(
|
|
66
73
|
"/debugger-frontend",
|
|
@@ -76,7 +83,7 @@ function createDevMiddleware({
|
|
|
76
83
|
}
|
|
77
84
|
function getExperiments(config) {
|
|
78
85
|
return {
|
|
79
|
-
|
|
86
|
+
enableNewDebugger: config.enableNewDebugger ?? false,
|
|
80
87
|
enableOpenDebuggerRedirect: config.enableOpenDebuggerRedirect ?? false,
|
|
81
88
|
};
|
|
82
89
|
}
|
|
@@ -65,12 +65,13 @@ class InspectorProxy {
|
|
|
65
65
|
// 2. /json and /json/list returns list of page descriptions (list of inspectable apps).
|
|
66
66
|
// This list is combined from all the connected devices.
|
|
67
67
|
processRequest(request, response, next) {
|
|
68
|
+
const pathname = _url.default.parse(request.url).pathname;
|
|
68
69
|
if (
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
pathname === PAGES_LIST_JSON_URL ||
|
|
71
|
+
pathname === PAGES_LIST_JSON_URL_2
|
|
71
72
|
) {
|
|
72
73
|
this._sendJsonResponse(response, this.getPageDescriptions());
|
|
73
|
-
} else if (
|
|
74
|
+
} else if (pathname === PAGES_LIST_JSON_VERSION_URL) {
|
|
74
75
|
this._sendJsonResponse(response, {
|
|
75
76
|
Browser: "Mobile JavaScript",
|
|
76
77
|
"Protocol-Version": "1.1",
|
|
@@ -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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native/dev-middleware",
|
|
3
|
-
"version": "0.73.
|
|
3
|
+
"version": "0.73.4",
|
|
4
4
|
"description": "Dev server middleware for React Native",
|
|
5
5
|
"keywords": ["react-native", "tools"],
|
|
6
6
|
"homepage": "https://github.com/facebook/react-native/tree/HEAD/packages/dev-middleware#readme",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"connect": "^3.6.5",
|
|
22
22
|
"debug": "^2.2.0",
|
|
23
23
|
"node-fetch": "^2.2.0",
|
|
24
|
+
"open": "^7.0.3",
|
|
24
25
|
"serve-static": "^1.13.1",
|
|
25
26
|
"temp-dir": "^2.0.0"
|
|
26
27
|
},
|