@react-native/dev-middleware 0.77.0-nightly-20241122-e4d8c9678 → 0.77.0-nightly-20241124-d4d1eb9bb
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 +63 -53
- package/package.json +2 -2
|
@@ -39,11 +39,6 @@ function _interopRequireDefault(e) {
|
|
|
39
39
|
}
|
|
40
40
|
const debug = require("debug")("Metro:InspectorProxy");
|
|
41
41
|
const PAGES_POLLING_INTERVAL = 1000;
|
|
42
|
-
const REWRITE_HOSTS_TO_LOCALHOST = new Set([
|
|
43
|
-
"127.0.0.1",
|
|
44
|
-
"10.0.2.2",
|
|
45
|
-
"10.0.3.2",
|
|
46
|
-
]);
|
|
47
42
|
const FILE_PREFIX = "file://";
|
|
48
43
|
const REACT_NATIVE_RELOADABLE_PAGE_ID = "-1";
|
|
49
44
|
class Device {
|
|
@@ -500,6 +495,39 @@ class Device {
|
|
|
500
495
|
});
|
|
501
496
|
}
|
|
502
497
|
}
|
|
498
|
+
#debuggerRelativeToDeviceRelativeUrl(
|
|
499
|
+
debuggerRelativeUrl,
|
|
500
|
+
{ debuggerRelativeBaseUrl }
|
|
501
|
+
) {
|
|
502
|
+
const deviceRelativeUrl = new URL(debuggerRelativeUrl.href);
|
|
503
|
+
if (debuggerRelativeUrl.origin === debuggerRelativeBaseUrl.origin) {
|
|
504
|
+
deviceRelativeUrl.hostname = this.#deviceRelativeBaseUrl.hostname;
|
|
505
|
+
deviceRelativeUrl.port = this.#deviceRelativeBaseUrl.port;
|
|
506
|
+
deviceRelativeUrl.protocol = this.#deviceRelativeBaseUrl.protocol;
|
|
507
|
+
}
|
|
508
|
+
return deviceRelativeUrl;
|
|
509
|
+
}
|
|
510
|
+
#deviceRelativeUrlToDebuggerRelativeUrl(
|
|
511
|
+
deviceRelativeUrl,
|
|
512
|
+
{ debuggerRelativeBaseUrl }
|
|
513
|
+
) {
|
|
514
|
+
const debuggerRelativeUrl = new URL(deviceRelativeUrl.href);
|
|
515
|
+
if (deviceRelativeUrl.origin === this.#deviceRelativeBaseUrl.origin) {
|
|
516
|
+
debuggerRelativeUrl.hostname = debuggerRelativeBaseUrl.hostname;
|
|
517
|
+
debuggerRelativeUrl.port = debuggerRelativeBaseUrl.port;
|
|
518
|
+
debuggerRelativeUrl.protocol = debuggerRelativeUrl.protocol;
|
|
519
|
+
}
|
|
520
|
+
return debuggerRelativeUrl;
|
|
521
|
+
}
|
|
522
|
+
#deviceRelativeUrlToServerRelativeUrl(deviceRelativeUrl) {
|
|
523
|
+
const debuggerRelativeUrl = new URL(deviceRelativeUrl.href);
|
|
524
|
+
if (deviceRelativeUrl.origin === this.#deviceRelativeBaseUrl.origin) {
|
|
525
|
+
debuggerRelativeUrl.hostname = this.#serverRelativeBaseUrl.hostname;
|
|
526
|
+
debuggerRelativeUrl.port = this.#serverRelativeBaseUrl.port;
|
|
527
|
+
debuggerRelativeUrl.protocol = this.#serverRelativeBaseUrl.protocol;
|
|
528
|
+
}
|
|
529
|
+
return debuggerRelativeUrl;
|
|
530
|
+
}
|
|
503
531
|
async #processMessageFromDeviceLegacy(payload, debuggerInfo, pageId) {
|
|
504
532
|
const page = pageId != null ? this.#pages.get(pageId) : null;
|
|
505
533
|
if (
|
|
@@ -511,24 +539,15 @@ class Device {
|
|
|
511
539
|
if ("sourceMapURL" in params) {
|
|
512
540
|
const sourceMapURL = this.#tryParseHTTPURL(params.sourceMapURL);
|
|
513
541
|
if (sourceMapURL) {
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
const debuggerRelativeURL = new URL(sourceMapURL.href);
|
|
520
|
-
debuggerRelativeURL.host =
|
|
521
|
-
debuggerInfo.debuggerRelativeBaseUrl.host;
|
|
522
|
-
debuggerRelativeURL.protocol =
|
|
523
|
-
debuggerInfo.debuggerRelativeBaseUrl.protocol;
|
|
524
|
-
serverRelativeUrl.host = this.#serverRelativeBaseUrl.host;
|
|
525
|
-
serverRelativeUrl.protocol = this.#serverRelativeBaseUrl.protocol;
|
|
526
|
-
debuggerInfo.originalSourceURLOrigin =
|
|
527
|
-
this.#deviceRelativeBaseUrl.origin;
|
|
528
|
-
payload.params.sourceMapURL = debuggerRelativeURL.href;
|
|
529
|
-
}
|
|
542
|
+
payload.params.sourceMapURL =
|
|
543
|
+
this.#deviceRelativeUrlToDebuggerRelativeUrl(
|
|
544
|
+
sourceMapURL,
|
|
545
|
+
debuggerInfo
|
|
546
|
+
).href;
|
|
530
547
|
try {
|
|
531
|
-
const sourceMap = await this.#fetchText(
|
|
548
|
+
const sourceMap = await this.#fetchText(
|
|
549
|
+
this.#deviceRelativeUrlToServerRelativeUrl(sourceMapURL)
|
|
550
|
+
);
|
|
532
551
|
payload.params.sourceMapURL =
|
|
533
552
|
"data:application/json;charset=utf-8;base64," +
|
|
534
553
|
Buffer.from(sourceMap).toString("base64");
|
|
@@ -542,19 +561,13 @@ class Device {
|
|
|
542
561
|
if ("url" in params) {
|
|
543
562
|
let serverRelativeUrl = params.url;
|
|
544
563
|
const parsedUrl = this.#tryParseHTTPURL(params.url);
|
|
545
|
-
if (
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
payload.params.url = parsedUrl.href;
|
|
553
|
-
debuggerInfo.originalSourceURLOrigin =
|
|
554
|
-
this.#deviceRelativeBaseUrl.origin;
|
|
555
|
-
parsedUrl.host = this.#serverRelativeBaseUrl.host;
|
|
556
|
-
parsedUrl.protocol = this.#serverRelativeBaseUrl.protocol;
|
|
557
|
-
serverRelativeUrl = parsedUrl.href;
|
|
564
|
+
if (parsedUrl) {
|
|
565
|
+
payload.params.url = this.#deviceRelativeUrlToDebuggerRelativeUrl(
|
|
566
|
+
parsedUrl,
|
|
567
|
+
debuggerInfo
|
|
568
|
+
).href;
|
|
569
|
+
serverRelativeUrl =
|
|
570
|
+
this.#deviceRelativeUrlToServerRelativeUrl(parsedUrl).href;
|
|
558
571
|
}
|
|
559
572
|
if (payload.params.url.match(/^[0-9a-z]+$/)) {
|
|
560
573
|
payload.params.url = FILE_PREFIX + payload.params.url;
|
|
@@ -629,35 +642,32 @@ class Device {
|
|
|
629
642
|
}
|
|
630
643
|
}
|
|
631
644
|
#processDebuggerSetBreakpointByUrl(req, debuggerInfo) {
|
|
632
|
-
const {
|
|
633
|
-
debuggerRelativeBaseUrl,
|
|
634
|
-
originalSourceURLOrigin,
|
|
635
|
-
prependedFilePrefix,
|
|
636
|
-
} = debuggerInfo;
|
|
645
|
+
const { debuggerRelativeBaseUrl, prependedFilePrefix } = debuggerInfo;
|
|
637
646
|
const processedReq = {
|
|
638
647
|
...req,
|
|
639
648
|
params: {
|
|
640
649
|
...req.params,
|
|
641
650
|
},
|
|
642
651
|
};
|
|
643
|
-
if (
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
652
|
+
if (processedReq.params.url != null) {
|
|
653
|
+
const originalUrlParam = processedReq.params.url;
|
|
654
|
+
const httpUrl = this.#tryParseHTTPURL(originalUrlParam);
|
|
655
|
+
if (httpUrl) {
|
|
656
|
+
processedReq.params.url = this.#debuggerRelativeToDeviceRelativeUrl(
|
|
657
|
+
httpUrl,
|
|
658
|
+
debuggerInfo
|
|
659
|
+
).href;
|
|
660
|
+
} else if (
|
|
661
|
+
originalUrlParam.startsWith(FILE_PREFIX) &&
|
|
651
662
|
prependedFilePrefix
|
|
652
663
|
) {
|
|
653
|
-
processedReq.params.url =
|
|
654
|
-
FILE_PREFIX.length
|
|
655
|
-
);
|
|
664
|
+
processedReq.params.url = originalUrlParam.slice(FILE_PREFIX.length);
|
|
656
665
|
}
|
|
657
666
|
}
|
|
658
667
|
if (
|
|
659
|
-
|
|
660
|
-
|
|
668
|
+
new Set(["10.0.2.2", "10.0.3.2"]).has(
|
|
669
|
+
this.#deviceRelativeBaseUrl.hostname
|
|
670
|
+
) &&
|
|
661
671
|
debuggerRelativeBaseUrl.hostname === "localhost" &&
|
|
662
672
|
processedReq.params.urlRegex != null
|
|
663
673
|
) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native/dev-middleware",
|
|
3
|
-
"version": "0.77.0-nightly-
|
|
3
|
+
"version": "0.77.0-nightly-20241124-d4d1eb9bb",
|
|
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.77.0-nightly-
|
|
26
|
+
"@react-native/debugger-frontend": "0.77.0-nightly-20241124-d4d1eb9bb",
|
|
27
27
|
"chrome-launcher": "^0.15.2",
|
|
28
28
|
"chromium-edge-launcher": "^0.2.0",
|
|
29
29
|
"connect": "^3.6.5",
|