@react-native/dev-middleware
Advanced tools
Comparing version 0.75.0-nightly-20240225-12f2c3cd2 to 0.75.0-nightly-20240226-fcabb2ad2
@@ -116,4 +116,6 @@ "use strict"; | ||
target.webSocketDebuggerUrl, | ||
// Use a relative URL. | ||
"" | ||
serverBaseUrl, | ||
{ | ||
relative: true, | ||
} | ||
), | ||
@@ -120,0 +122,0 @@ }); |
@@ -19,4 +19,5 @@ /** | ||
webSocketDebuggerUrl: string, | ||
devServerUrl: string | ||
devServerUrl: string, | ||
options?: Readonly<{ relative?: boolean }> | ||
): string; | ||
export default getDevToolsFrontendUrl; |
@@ -24,11 +24,14 @@ "use strict"; | ||
webSocketDebuggerUrl, | ||
devServerUrl | ||
devServerUrl, | ||
options | ||
) { | ||
const scheme = new URL(webSocketDebuggerUrl).protocol.slice(0, -1); | ||
const webSocketUrlWithoutProtocol = webSocketDebuggerUrl.replace( | ||
/^wss?:\/\//, | ||
"" | ||
); | ||
const wsParam = getWsParam({ | ||
webSocketDebuggerUrl, | ||
devServerUrl, | ||
}); | ||
const appUrl = | ||
(options?.relative === true ? "" : devServerUrl) + | ||
"/debugger-frontend/rn_inspector.html"; | ||
const searchParams = new URLSearchParams([ | ||
[scheme, webSocketUrlWithoutProtocol], | ||
[wsParam.key, wsParam.value], | ||
["sources.hide_add_folder", "true"], | ||
@@ -39,7 +42,21 @@ ]); | ||
} | ||
return ( | ||
`${devServerUrl}/debugger-frontend/rn_inspector.html` + | ||
"?" + | ||
searchParams.toString() | ||
); | ||
return appUrl + "?" + searchParams.toString(); | ||
} | ||
function getWsParam({ webSocketDebuggerUrl, devServerUrl }) { | ||
const wsUrl = new URL(webSocketDebuggerUrl); | ||
const serverHost = new URL(devServerUrl).host; | ||
let value; | ||
if (wsUrl.host === serverHost) { | ||
// Use a path-absolute (host-relative) URL | ||
// Depends on https://github.com/facebookexperimental/rn-chrome-devtools-frontend/pull/4 | ||
value = wsUrl.pathname + wsUrl.search + wsUrl.hash; | ||
} else { | ||
// Standard URL format accepted by the DevTools frontend | ||
value = wsUrl.host + wsUrl.pathname + wsUrl.search + wsUrl.hash; | ||
} | ||
const key = wsUrl.protocol.slice(0, -1); | ||
return { | ||
key, | ||
value, | ||
}; | ||
} |
{ | ||
"name": "@react-native/dev-middleware", | ||
"version": "0.75.0-nightly-20240225-12f2c3cd2", | ||
"version": "0.75.0-nightly-20240226-fcabb2ad2", | ||
"description": "Dev server middleware for React Native", | ||
@@ -26,3 +26,3 @@ "keywords": [ | ||
"@isaacs/ttlcache": "^1.4.1", | ||
"@react-native/debugger-frontend": "0.75.0-nightly-20240225-12f2c3cd2", | ||
"@react-native/debugger-frontend": "0.75.0-nightly-20240226-fcabb2ad2", | ||
"@rnx-kit/chromium-edge-launcher": "^1.0.0", | ||
@@ -29,0 +29,0 @@ "chrome-launcher": "^0.15.2", |
Sorry, the diff of this file is not supported yet
99152
2263