@jsenv/plugin-supervisor 1.5.26 → 1.5.27
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.
|
@@ -454,6 +454,38 @@ isBrowser ? () => {
|
|
|
454
454
|
throw new Error('`process.cwd()` only works in Node.js, not the browser.');
|
|
455
455
|
} : process$1.cwd;
|
|
456
456
|
|
|
457
|
+
// normalize url search params:
|
|
458
|
+
// Using URLSearchParams to alter the url search params
|
|
459
|
+
// can result into "file:///file.css?css_module"
|
|
460
|
+
// becoming "file:///file.css?css_module="
|
|
461
|
+
// we want to get rid of the "=" and consider it's the same url
|
|
462
|
+
const normalizeUrl = url => {
|
|
463
|
+
if (url.includes("?")) {
|
|
464
|
+
// disable on data urls (would mess up base64 encoding)
|
|
465
|
+
if (url.startsWith("data:")) {
|
|
466
|
+
return url;
|
|
467
|
+
}
|
|
468
|
+
return url.replace(/[=](?=&|$)/g, "");
|
|
469
|
+
}
|
|
470
|
+
return url;
|
|
471
|
+
};
|
|
472
|
+
const injectQueryParams = (url, params) => {
|
|
473
|
+
const urlObject = new URL(url);
|
|
474
|
+
const {
|
|
475
|
+
searchParams
|
|
476
|
+
} = urlObject;
|
|
477
|
+
Object.keys(params).forEach(key => {
|
|
478
|
+
const value = params[key];
|
|
479
|
+
if (value === undefined) {
|
|
480
|
+
searchParams.delete(key);
|
|
481
|
+
} else {
|
|
482
|
+
searchParams.set(key, value);
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
const urlWithParams = urlObject.href;
|
|
486
|
+
return normalizeUrl(urlWithParams);
|
|
487
|
+
};
|
|
488
|
+
|
|
457
489
|
const getCommonPathname = (pathname, otherPathname) => {
|
|
458
490
|
if (pathname === otherPathname) {
|
|
459
491
|
return pathname;
|
|
@@ -1199,7 +1231,9 @@ const jsenvPluginSupervisor = ({
|
|
|
1199
1231
|
const resolveUrlSite = urlWithLineAndColumn => {
|
|
1200
1232
|
const inlineUrlMatch = urlWithLineAndColumn.match(/@L([0-9]+)C([0-9]+)-L([0-9]+)C([0-9]+)\.\w+(:([0-9]+):([0-9]+))?$/);
|
|
1201
1233
|
if (inlineUrlMatch) {
|
|
1202
|
-
const htmlUrl = urlWithLineAndColumn.slice(0, inlineUrlMatch.index)
|
|
1234
|
+
const htmlUrl = injectQueryParams(urlWithLineAndColumn.slice(0, inlineUrlMatch.index), {
|
|
1235
|
+
hot: undefined
|
|
1236
|
+
});
|
|
1203
1237
|
const tagLineStart = parseInt(inlineUrlMatch[1]);
|
|
1204
1238
|
const tagColumnStart = parseInt(inlineUrlMatch[2]);
|
|
1205
1239
|
// const tagLineEnd = parseInt(inlineUrlMatch[3]);
|
|
@@ -1220,7 +1254,9 @@ const jsenvPluginSupervisor = ({
|
|
|
1220
1254
|
if (!match) {
|
|
1221
1255
|
return null;
|
|
1222
1256
|
}
|
|
1223
|
-
const file = urlWithLineAndColumn.slice(0, match.index)
|
|
1257
|
+
const file = injectQueryParams(urlWithLineAndColumn.slice(0, match.index), {
|
|
1258
|
+
hot: undefined
|
|
1259
|
+
});
|
|
1224
1260
|
let line = parseInt(match[1]);
|
|
1225
1261
|
let column = parseInt(match[2]);
|
|
1226
1262
|
return {
|
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { generateContentFrame } from "@jsenv/humanize";
|
|
7
7
|
import { getOriginalPosition } from "@jsenv/sourcemap";
|
|
8
|
+
import { injectQueryParams } from "@jsenv/urls";
|
|
8
9
|
import { createRequire } from "node:module";
|
|
9
10
|
import { fileURLToPath } from "node:url";
|
|
10
11
|
import {
|
|
@@ -24,7 +25,10 @@ export const jsenvPluginSupervisor = ({
|
|
|
24
25
|
/@L([0-9]+)C([0-9]+)-L([0-9]+)C([0-9]+)\.\w+(:([0-9]+):([0-9]+))?$/,
|
|
25
26
|
);
|
|
26
27
|
if (inlineUrlMatch) {
|
|
27
|
-
const htmlUrl =
|
|
28
|
+
const htmlUrl = injectQueryParams(
|
|
29
|
+
urlWithLineAndColumn.slice(0, inlineUrlMatch.index),
|
|
30
|
+
{ hot: undefined },
|
|
31
|
+
);
|
|
28
32
|
const tagLineStart = parseInt(inlineUrlMatch[1]);
|
|
29
33
|
const tagColumnStart = parseInt(inlineUrlMatch[2]);
|
|
30
34
|
// const tagLineEnd = parseInt(inlineUrlMatch[3]);
|
|
@@ -52,7 +56,9 @@ export const jsenvPluginSupervisor = ({
|
|
|
52
56
|
if (!match) {
|
|
53
57
|
return null;
|
|
54
58
|
}
|
|
55
|
-
const file = urlWithLineAndColumn.slice(0, match.index)
|
|
59
|
+
const file = injectQueryParams(urlWithLineAndColumn.slice(0, match.index), {
|
|
60
|
+
hot: undefined,
|
|
61
|
+
});
|
|
56
62
|
let line = parseInt(match[1]);
|
|
57
63
|
let column = parseInt(match[2]);
|
|
58
64
|
return {
|