@react-native/dev-middleware 0.75.0-nightly-20240415-e7154bdd9 → 0.75.0-nightly-20240417-fe9942a19
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/inspector-proxy/Device.js +23 -12
- package/package.json +2 -2
|
@@ -68,8 +68,21 @@ function _interopRequireDefault(obj) {
|
|
|
68
68
|
const debug = require("debug")("Metro:InspectorProxy");
|
|
69
69
|
const PAGES_POLLING_INTERVAL = 1000;
|
|
70
70
|
|
|
71
|
-
//
|
|
72
|
-
|
|
71
|
+
// Replace hosts appearing in the `url` and `sourceMapURL` fields of
|
|
72
|
+
// `Debugger.scriptParsed`, and back again in messages from the debugger,
|
|
73
|
+
// to account for device/debugger/proxy running on different networks.
|
|
74
|
+
const REWRITE_HOSTS_TO_LOCALHOST = [
|
|
75
|
+
// A device may retrieve a bundle through 127.0.0.1 via a (SSH) tunnel, but
|
|
76
|
+
// the (remote) Metro server may be on a host without an IPv4 loopback, so
|
|
77
|
+
// 127.0.0.1 may not be addressible locally for (e.g., for source map
|
|
78
|
+
// fetching). Replacing with the more general 'localhost' should always be
|
|
79
|
+
// safe while also more compatible with IPv6-only setups.
|
|
80
|
+
"127.0.0.1",
|
|
81
|
+
// Android's stock emulator and other emulators such as genymotion use a
|
|
82
|
+
// standard localhost alias.
|
|
83
|
+
"10.0.2.2",
|
|
84
|
+
"10.0.3.2",
|
|
85
|
+
];
|
|
73
86
|
|
|
74
87
|
// Prefix for script URLs that are alphanumeric IDs. See comment in #processMessageFromDeviceLegacy method for
|
|
75
88
|
// more details.
|
|
@@ -614,15 +627,14 @@ class Device {
|
|
|
614
627
|
) {
|
|
615
628
|
const params = payload.params;
|
|
616
629
|
if ("sourceMapURL" in params) {
|
|
617
|
-
for (
|
|
618
|
-
|
|
619
|
-
if (params.sourceMapURL.includes(address)) {
|
|
630
|
+
for (const hostToRewrite of REWRITE_HOSTS_TO_LOCALHOST) {
|
|
631
|
+
if (params.sourceMapURL.includes(hostToRewrite)) {
|
|
620
632
|
// $FlowFixMe[cannot-write]
|
|
621
633
|
payload.params.sourceMapURL = params.sourceMapURL.replace(
|
|
622
|
-
|
|
634
|
+
hostToRewrite,
|
|
623
635
|
"localhost"
|
|
624
636
|
);
|
|
625
|
-
debuggerInfo.originalSourceURLAddress =
|
|
637
|
+
debuggerInfo.originalSourceURLAddress = hostToRewrite;
|
|
626
638
|
}
|
|
627
639
|
}
|
|
628
640
|
const sourceMapURL = this.#tryParseHTTPURL(params.sourceMapURL);
|
|
@@ -646,12 +658,11 @@ class Device {
|
|
|
646
658
|
}
|
|
647
659
|
}
|
|
648
660
|
if ("url" in params) {
|
|
649
|
-
for (
|
|
650
|
-
|
|
651
|
-
if (params.url.indexOf(address) >= 0) {
|
|
661
|
+
for (const hostToRewrite of REWRITE_HOSTS_TO_LOCALHOST) {
|
|
662
|
+
if (params.url.includes(hostToRewrite)) {
|
|
652
663
|
// $FlowFixMe[cannot-write]
|
|
653
|
-
payload.params.url = params.url.replace(
|
|
654
|
-
debuggerInfo.originalSourceURLAddress =
|
|
664
|
+
payload.params.url = params.url.replace(hostToRewrite, "localhost");
|
|
665
|
+
debuggerInfo.originalSourceURLAddress = hostToRewrite;
|
|
655
666
|
}
|
|
656
667
|
}
|
|
657
668
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native/dev-middleware",
|
|
3
|
-
"version": "0.75.0-nightly-
|
|
3
|
+
"version": "0.75.0-nightly-20240417-fe9942a19",
|
|
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-
|
|
26
|
+
"@react-native/debugger-frontend": "0.75.0-nightly-20240417-fe9942a19",
|
|
27
27
|
"chrome-launcher": "^0.15.2",
|
|
28
28
|
"chromium-edge-launcher": "^0.2.0",
|
|
29
29
|
"connect": "^3.6.5",
|