@react-devtools-plus/kit 0.3.2 → 0.5.0
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/index.cjs +34 -13
- package/dist/index.js +34 -13
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -820,7 +820,7 @@ function mergeClientRects(rects) {
|
|
|
820
820
|
}
|
|
821
821
|
function isInOverlay(node) {
|
|
822
822
|
var _overlayContainer$con;
|
|
823
|
-
if (!node) return false;
|
|
823
|
+
if (!node || !(node instanceof Node)) return false;
|
|
824
824
|
const overlayContainer = document.getElementById("react-devtools-overlay");
|
|
825
825
|
return (_overlayContainer$con = overlayContainer === null || overlayContainer === void 0 ? void 0 : overlayContainer.contains(node)) !== null && _overlayContainer$con !== void 0 ? _overlayContainer$con : false;
|
|
826
826
|
}
|
|
@@ -2360,22 +2360,43 @@ function tryOpenWithProtocol(fileName, line, column) {
|
|
|
2360
2360
|
return false;
|
|
2361
2361
|
}
|
|
2362
2362
|
}
|
|
2363
|
+
/**
|
|
2364
|
+
* Get the base path for DevTools API
|
|
2365
|
+
*/
|
|
2366
|
+
function getDevToolsBasePath() {
|
|
2367
|
+
const config = window.__REACT_DEVTOOLS_CONFIG__;
|
|
2368
|
+
if (config === null || config === void 0 ? void 0 : config.clientUrl) try {
|
|
2369
|
+
return new URL(config.clientUrl, window.location.origin).pathname.replace(/\/$/, "");
|
|
2370
|
+
} catch (_unused) {}
|
|
2371
|
+
const pathname = window.location.pathname;
|
|
2372
|
+
if (pathname.includes("/devtools")) {
|
|
2373
|
+
const match = pathname.match(/^(.*\/devtools)/);
|
|
2374
|
+
if (match) return match[1];
|
|
2375
|
+
}
|
|
2376
|
+
return "/__react_devtools__";
|
|
2377
|
+
}
|
|
2363
2378
|
function openInEditor(fileName, line, column) {
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
}
|
|
2371
|
-
}).catch(() => {
|
|
2372
|
-
console.warn("[React DevTools] Fetch failed, trying URL protocol fallback");
|
|
2379
|
+
const fileParam = encodeURIComponent(`${fileName}:${line}:${column}`);
|
|
2380
|
+
const basePath = getDevToolsBasePath();
|
|
2381
|
+
const endpoints = [`/__open-in-editor?file=${fileParam}`, `${basePath}/api/open-in-editor?file=${fileParam}`];
|
|
2382
|
+
async function tryEndpoints(index) {
|
|
2383
|
+
if (index >= endpoints.length) {
|
|
2384
|
+
console.warn("[React DevTools] All server endpoints failed, trying URL protocol fallback");
|
|
2373
2385
|
tryOpenWithProtocol(fileName, line, column);
|
|
2374
|
-
|
|
2375
|
-
|
|
2386
|
+
return;
|
|
2387
|
+
}
|
|
2388
|
+
const url = endpoints[index];
|
|
2389
|
+
try {
|
|
2390
|
+
if ((await fetch(url)).ok) return;
|
|
2391
|
+
await tryEndpoints(index + 1);
|
|
2392
|
+
} catch (_unused2) {
|
|
2393
|
+
await tryEndpoints(index + 1);
|
|
2394
|
+
}
|
|
2395
|
+
}
|
|
2396
|
+
tryEndpoints(0).catch((e) => {
|
|
2376
2397
|
console.error("[React DevTools] Failed to open in editor:", e);
|
|
2377
2398
|
tryOpenWithProtocol(fileName, line, column);
|
|
2378
|
-
}
|
|
2399
|
+
});
|
|
2379
2400
|
}
|
|
2380
2401
|
|
|
2381
2402
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -796,7 +796,7 @@ function mergeClientRects(rects) {
|
|
|
796
796
|
}
|
|
797
797
|
function isInOverlay(node) {
|
|
798
798
|
var _overlayContainer$con;
|
|
799
|
-
if (!node) return false;
|
|
799
|
+
if (!node || !(node instanceof Node)) return false;
|
|
800
800
|
const overlayContainer = document.getElementById("react-devtools-overlay");
|
|
801
801
|
return (_overlayContainer$con = overlayContainer === null || overlayContainer === void 0 ? void 0 : overlayContainer.contains(node)) !== null && _overlayContainer$con !== void 0 ? _overlayContainer$con : false;
|
|
802
802
|
}
|
|
@@ -2336,22 +2336,43 @@ function tryOpenWithProtocol(fileName, line, column) {
|
|
|
2336
2336
|
return false;
|
|
2337
2337
|
}
|
|
2338
2338
|
}
|
|
2339
|
+
/**
|
|
2340
|
+
* Get the base path for DevTools API
|
|
2341
|
+
*/
|
|
2342
|
+
function getDevToolsBasePath() {
|
|
2343
|
+
const config = window.__REACT_DEVTOOLS_CONFIG__;
|
|
2344
|
+
if (config === null || config === void 0 ? void 0 : config.clientUrl) try {
|
|
2345
|
+
return new URL(config.clientUrl, window.location.origin).pathname.replace(/\/$/, "");
|
|
2346
|
+
} catch (_unused) {}
|
|
2347
|
+
const pathname = window.location.pathname;
|
|
2348
|
+
if (pathname.includes("/devtools")) {
|
|
2349
|
+
const match = pathname.match(/^(.*\/devtools)/);
|
|
2350
|
+
if (match) return match[1];
|
|
2351
|
+
}
|
|
2352
|
+
return "/__react_devtools__";
|
|
2353
|
+
}
|
|
2339
2354
|
function openInEditor(fileName, line, column) {
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
}
|
|
2347
|
-
}).catch(() => {
|
|
2348
|
-
console.warn("[React DevTools] Fetch failed, trying URL protocol fallback");
|
|
2355
|
+
const fileParam = encodeURIComponent(`${fileName}:${line}:${column}`);
|
|
2356
|
+
const basePath = getDevToolsBasePath();
|
|
2357
|
+
const endpoints = [`/__open-in-editor?file=${fileParam}`, `${basePath}/api/open-in-editor?file=${fileParam}`];
|
|
2358
|
+
async function tryEndpoints(index) {
|
|
2359
|
+
if (index >= endpoints.length) {
|
|
2360
|
+
console.warn("[React DevTools] All server endpoints failed, trying URL protocol fallback");
|
|
2349
2361
|
tryOpenWithProtocol(fileName, line, column);
|
|
2350
|
-
|
|
2351
|
-
|
|
2362
|
+
return;
|
|
2363
|
+
}
|
|
2364
|
+
const url = endpoints[index];
|
|
2365
|
+
try {
|
|
2366
|
+
if ((await fetch(url)).ok) return;
|
|
2367
|
+
await tryEndpoints(index + 1);
|
|
2368
|
+
} catch (_unused2) {
|
|
2369
|
+
await tryEndpoints(index + 1);
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
2372
|
+
tryEndpoints(0).catch((e) => {
|
|
2352
2373
|
console.error("[React DevTools] Failed to open in editor:", e);
|
|
2353
2374
|
tryOpenWithProtocol(fileName, line, column);
|
|
2354
|
-
}
|
|
2375
|
+
});
|
|
2355
2376
|
}
|
|
2356
2377
|
|
|
2357
2378
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-devtools-plus/kit",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.5.0",
|
|
5
5
|
"author": "wzc520pyfm",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"mitt": "^3.0.1",
|
|
28
28
|
"perfect-debounce": "^2.0.0",
|
|
29
29
|
"superjson": "^2.2.2",
|
|
30
|
-
"@react-devtools-plus/shared": "^0.
|
|
30
|
+
"@react-devtools-plus/shared": "^0.5.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/node": "^24.7.2",
|