@react-native/dev-middleware 0.75.0-nightly-20240225-12f2c3cd2 → 0.75.0-nightly-20240227-8317325fb

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.
@@ -113,8 +113,10 @@ function openDebuggerMiddleware({
113
113
  Location: (0, _getDevToolsFrontendUrl.default)(
114
114
  experiments,
115
115
  target.webSocketDebuggerUrl,
116
- // Use a relative URL.
117
- ""
116
+ serverBaseUrl,
117
+ {
118
+ relative: true,
119
+ }
118
120
  ),
119
121
  });
120
122
  res.end();
@@ -16,6 +16,7 @@ import type { Experiments } from "../types/Experiments";
16
16
  declare function getDevToolsFrontendUrl(
17
17
  experiments: Experiments,
18
18
  webSocketDebuggerUrl: string,
19
- devServerUrl: string
19
+ devServerUrl: string,
20
+ options?: Readonly<{ relative?: boolean }>
20
21
  ): string;
21
22
  export default getDevToolsFrontendUrl;
@@ -21,23 +21,40 @@ exports.default = getDevToolsFrontendUrl;
21
21
  function getDevToolsFrontendUrl(
22
22
  experiments,
23
23
  webSocketDebuggerUrl,
24
- devServerUrl
24
+ devServerUrl,
25
+ options
25
26
  ) {
26
- const scheme = new URL(webSocketDebuggerUrl).protocol.slice(0, -1);
27
- const webSocketUrlWithoutProtocol = webSocketDebuggerUrl.replace(
28
- /^wss?:\/\//,
29
- ""
30
- );
27
+ const wsParam = getWsParam({
28
+ webSocketDebuggerUrl,
29
+ devServerUrl,
30
+ });
31
+ const appUrl =
32
+ (options?.relative === true ? "" : devServerUrl) +
33
+ "/debugger-frontend/rn_inspector.html";
31
34
  const searchParams = new URLSearchParams([
32
- [scheme, webSocketUrlWithoutProtocol],
35
+ [wsParam.key, wsParam.value],
33
36
  ["sources.hide_add_folder", "true"],
34
37
  ]);
35
38
  if (experiments.enableNetworkInspector) {
36
39
  searchParams.append("unstable_enableNetworkPanel", "true");
37
40
  }
38
- return (
39
- `${devServerUrl}/debugger-frontend/rn_inspector.html` +
40
- "?" +
41
- searchParams.toString()
42
- );
41
+ return appUrl + "?" + searchParams.toString();
42
+ }
43
+ function getWsParam({ webSocketDebuggerUrl, devServerUrl }) {
44
+ const wsUrl = new URL(webSocketDebuggerUrl);
45
+ const serverHost = new URL(devServerUrl).host;
46
+ let value;
47
+ if (wsUrl.host === serverHost) {
48
+ // Use a path-absolute (host-relative) URL
49
+ // Depends on https://github.com/facebookexperimental/rn-chrome-devtools-frontend/pull/4
50
+ value = wsUrl.pathname + wsUrl.search + wsUrl.hash;
51
+ } else {
52
+ // Standard URL format accepted by the DevTools frontend
53
+ value = wsUrl.host + wsUrl.pathname + wsUrl.search + wsUrl.hash;
54
+ }
55
+ const key = wsUrl.protocol.slice(0, -1);
56
+ return {
57
+ key,
58
+ value,
59
+ };
43
60
  }
@@ -17,5 +17,8 @@ import type { Experiments } from "../types/Experiments";
17
17
  declare export default function getDevToolsFrontendUrl(
18
18
  experiments: Experiments,
19
19
  webSocketDebuggerUrl: string,
20
- devServerUrl: string
20
+ devServerUrl: string,
21
+ options?: $ReadOnly<{
22
+ relative?: boolean,
23
+ }>
21
24
  ): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native/dev-middleware",
3
- "version": "0.75.0-nightly-20240225-12f2c3cd2",
3
+ "version": "0.75.0-nightly-20240227-8317325fb",
4
4
  "description": "Dev server middleware for React Native",
5
5
  "keywords": [
6
6
  "react-native",
@@ -23,7 +23,7 @@
23
23
  ],
24
24
  "dependencies": {
25
25
  "@isaacs/ttlcache": "^1.4.1",
26
- "@react-native/debugger-frontend": "0.75.0-nightly-20240225-12f2c3cd2",
26
+ "@react-native/debugger-frontend": "0.75.0-nightly-20240227-8317325fb",
27
27
  "@rnx-kit/chromium-edge-launcher": "^1.0.0",
28
28
  "chrome-launcher": "^0.15.2",
29
29
  "connect": "^3.6.5",