Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@react-native/dev-middleware

Package Overview
Dependencies
Maintainers
0
Versions
440
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-native/dev-middleware - npm Package Compare versions

Comparing version 0.77.0-nightly-20241122-e4d8c9678 to 0.77.0-nightly-20241123-1fed2cfde

116

dist/inspector-proxy/Device.js

@@ -42,7 +42,2 @@ "use strict";

const PAGES_POLLING_INTERVAL = 1000;
const REWRITE_HOSTS_TO_LOCALHOST = new Set([
"127.0.0.1",
"10.0.2.2",
"10.0.3.2",
]);
const FILE_PREFIX = "file://";

@@ -504,2 +499,35 @@ const REACT_NATIVE_RELOADABLE_PAGE_ID = "-1";

}
#debuggerRelativeToDeviceRelativeUrl(
debuggerRelativeUrl,
{ debuggerRelativeBaseUrl }
) {
const deviceRelativeUrl = new URL(debuggerRelativeUrl.href);
if (debuggerRelativeUrl.origin === debuggerRelativeBaseUrl.origin) {
deviceRelativeUrl.hostname = this.#deviceRelativeBaseUrl.hostname;
deviceRelativeUrl.port = this.#deviceRelativeBaseUrl.port;
deviceRelativeUrl.protocol = this.#deviceRelativeBaseUrl.protocol;
}
return deviceRelativeUrl;
}
#deviceRelativeUrlToDebuggerRelativeUrl(
deviceRelativeUrl,
{ debuggerRelativeBaseUrl }
) {
const debuggerRelativeUrl = new URL(deviceRelativeUrl.href);
if (deviceRelativeUrl.origin === this.#deviceRelativeBaseUrl.origin) {
debuggerRelativeUrl.hostname = debuggerRelativeBaseUrl.hostname;
debuggerRelativeUrl.port = debuggerRelativeBaseUrl.port;
debuggerRelativeUrl.protocol = debuggerRelativeUrl.protocol;
}
return debuggerRelativeUrl;
}
#deviceRelativeUrlToServerRelativeUrl(deviceRelativeUrl) {
const debuggerRelativeUrl = new URL(deviceRelativeUrl.href);
if (deviceRelativeUrl.origin === this.#deviceRelativeBaseUrl.origin) {
debuggerRelativeUrl.hostname = this.#serverRelativeBaseUrl.hostname;
debuggerRelativeUrl.port = this.#serverRelativeBaseUrl.port;
debuggerRelativeUrl.protocol = this.#serverRelativeBaseUrl.protocol;
}
return debuggerRelativeUrl;
}
async #processMessageFromDeviceLegacy(payload, debuggerInfo, pageId) {

@@ -516,20 +544,11 @@ const page = pageId != null ? this.#pages.get(pageId) : null;

if (sourceMapURL) {
const serverRelativeUrl = new URL(sourceMapURL.href);
if (
sourceMapURL.origin === this.#deviceRelativeBaseUrl.origin &&
REWRITE_HOSTS_TO_LOCALHOST.has(this.#deviceRelativeBaseUrl.hostname)
) {
const debuggerRelativeURL = new URL(sourceMapURL.href);
debuggerRelativeURL.host =
debuggerInfo.debuggerRelativeBaseUrl.host;
debuggerRelativeURL.protocol =
debuggerInfo.debuggerRelativeBaseUrl.protocol;
serverRelativeUrl.host = this.#serverRelativeBaseUrl.host;
serverRelativeUrl.protocol = this.#serverRelativeBaseUrl.protocol;
debuggerInfo.originalSourceURLOrigin =
this.#deviceRelativeBaseUrl.origin;
payload.params.sourceMapURL = debuggerRelativeURL.href;
}
payload.params.sourceMapURL =
this.#deviceRelativeUrlToDebuggerRelativeUrl(
sourceMapURL,
debuggerInfo
).href;
try {
const sourceMap = await this.#fetchText(serverRelativeUrl);
const sourceMap = await this.#fetchText(
this.#deviceRelativeUrlToServerRelativeUrl(sourceMapURL)
);
payload.params.sourceMapURL =

@@ -548,15 +567,9 @@ "data:application/json;charset=utf-8;base64," +

const parsedUrl = this.#tryParseHTTPURL(params.url);
if (
parsedUrl &&
parsedUrl.origin === this.#deviceRelativeBaseUrl.origin &&
REWRITE_HOSTS_TO_LOCALHOST.has(this.#deviceRelativeBaseUrl.hostname)
) {
parsedUrl.host = debuggerInfo.debuggerRelativeBaseUrl.host;
parsedUrl.protocol = debuggerInfo.debuggerRelativeBaseUrl.protocol;
payload.params.url = parsedUrl.href;
debuggerInfo.originalSourceURLOrigin =
this.#deviceRelativeBaseUrl.origin;
parsedUrl.host = this.#serverRelativeBaseUrl.host;
parsedUrl.protocol = this.#serverRelativeBaseUrl.protocol;
serverRelativeUrl = parsedUrl.href;
if (parsedUrl) {
payload.params.url = this.#deviceRelativeUrlToDebuggerRelativeUrl(
parsedUrl,
debuggerInfo
).href;
serverRelativeUrl =
this.#deviceRelativeUrlToServerRelativeUrl(parsedUrl).href;
}

@@ -636,7 +649,3 @@ if (payload.params.url.match(/^[0-9a-z]+$/)) {

#processDebuggerSetBreakpointByUrl(req, debuggerInfo) {
const {
debuggerRelativeBaseUrl,
originalSourceURLOrigin,
prependedFilePrefix,
} = debuggerInfo;
const { debuggerRelativeBaseUrl, prependedFilePrefix } = debuggerInfo;
const processedReq = {

@@ -648,20 +657,21 @@ ...req,

};
if (originalSourceURLOrigin != null && processedReq.params.url != null) {
processedReq.params.url = processedReq.params.url.replace(
debuggerRelativeBaseUrl.origin,
originalSourceURLOrigin
);
if (
processedReq.params.url &&
processedReq.params.url.startsWith(FILE_PREFIX) &&
if (processedReq.params.url != null) {
const originalUrlParam = processedReq.params.url;
const httpUrl = this.#tryParseHTTPURL(originalUrlParam);
if (httpUrl) {
processedReq.params.url = this.#debuggerRelativeToDeviceRelativeUrl(
httpUrl,
debuggerInfo
).href;
} else if (
originalUrlParam.startsWith(FILE_PREFIX) &&
prependedFilePrefix
) {
processedReq.params.url = processedReq.params.url.slice(
FILE_PREFIX.length
);
processedReq.params.url = originalUrlParam.slice(FILE_PREFIX.length);
}
}
if (
REWRITE_HOSTS_TO_LOCALHOST.has(this.#deviceRelativeBaseUrl.hostname) &&
this.#deviceRelativeBaseUrl.port === debuggerRelativeBaseUrl.port &&
new Set(["10.0.2.2", "10.0.3.2"]).has(
this.#deviceRelativeBaseUrl.hostname
) &&
debuggerRelativeBaseUrl.hostname === "localhost" &&

@@ -668,0 +678,0 @@ processedReq.params.urlRegex != null

{
"name": "@react-native/dev-middleware",
"version": "0.77.0-nightly-20241122-e4d8c9678",
"version": "0.77.0-nightly-20241123-1fed2cfde",
"description": "Dev server middleware for React Native",

@@ -26,3 +26,3 @@ "keywords": [

"@isaacs/ttlcache": "^1.4.1",
"@react-native/debugger-frontend": "0.77.0-nightly-20241122-e4d8c9678",
"@react-native/debugger-frontend": "0.77.0-nightly-20241123-1fed2cfde",
"chrome-launcher": "^0.15.2",

@@ -29,0 +29,0 @@ "chromium-edge-launcher": "^0.2.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc