@jsenv/core 40.5.3 → 40.6.1
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/build/build.js +163 -61
- package/dist/build/jsenv_core_packages.js +259 -259
- package/dist/start_build_server/jsenv_core_packages.js +29 -29
- package/dist/start_dev_server/jsenv_core_packages.js +312 -260
- package/dist/start_dev_server/start_dev_server.js +164 -62
- package/package.json +33 -30
- package/src/build/build.js +1 -1
- package/src/dev/start_dev_server.js +2 -2
- package/src/kitchen/errors.js +62 -43
- package/src/kitchen/kitchen.js +45 -3
- package/src/plugins/protocol_file/jsenv_plugin_protocol_file.js +3 -0
- package/src/plugins/resolution_node_esm/jsenv_plugin_node_esm_resolution.js +9 -4
- package/src/plugins/resolution_node_esm/node_esm_resolver.js +43 -10
|
@@ -5,6 +5,79 @@ import { extname } from "node:path";
|
|
|
5
5
|
import crypto, { createHash } from "node:crypto";
|
|
6
6
|
import { pathToFileURL, fileURLToPath } from "node:url";
|
|
7
7
|
|
|
8
|
+
const isFileSystemPath = (value) => {
|
|
9
|
+
if (typeof value !== "string") {
|
|
10
|
+
throw new TypeError(
|
|
11
|
+
`isFileSystemPath first arg must be a string, got ${value}`,
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
if (value[0] === "/") {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
return startsWithWindowsDriveLetter(value);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const startsWithWindowsDriveLetter = (string) => {
|
|
21
|
+
const firstChar = string[0];
|
|
22
|
+
if (!/[a-zA-Z]/.test(firstChar)) return false;
|
|
23
|
+
|
|
24
|
+
const secondChar = string[1];
|
|
25
|
+
if (secondChar !== ":") return false;
|
|
26
|
+
|
|
27
|
+
return true;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const fileSystemPathToUrl = (value) => {
|
|
31
|
+
if (!isFileSystemPath(value)) {
|
|
32
|
+
throw new Error(`value must be a filesystem path, got ${value}`);
|
|
33
|
+
}
|
|
34
|
+
return String(pathToFileURL(value));
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const getCallerPosition = () => {
|
|
38
|
+
const { prepareStackTrace } = Error;
|
|
39
|
+
Error.prepareStackTrace = (error, stack) => {
|
|
40
|
+
Error.prepareStackTrace = prepareStackTrace;
|
|
41
|
+
return stack;
|
|
42
|
+
};
|
|
43
|
+
const { stack } = new Error();
|
|
44
|
+
const callerCallsite = stack[2];
|
|
45
|
+
const fileName = callerCallsite.getFileName();
|
|
46
|
+
return {
|
|
47
|
+
url:
|
|
48
|
+
fileName && isFileSystemPath(fileName)
|
|
49
|
+
? fileSystemPathToUrl(fileName)
|
|
50
|
+
: fileName,
|
|
51
|
+
line: callerCallsite.getLineNumber(),
|
|
52
|
+
column: callerCallsite.getColumnNumber(),
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const urlToFileSystemPath = (url) => {
|
|
57
|
+
const urlObject = new URL(url);
|
|
58
|
+
let { origin, pathname, hash } = urlObject;
|
|
59
|
+
if (urlObject.protocol === "file:") {
|
|
60
|
+
origin = "file://";
|
|
61
|
+
}
|
|
62
|
+
pathname = pathname
|
|
63
|
+
.split("/")
|
|
64
|
+
.map((part) => {
|
|
65
|
+
return part.replace(/%(?![0-9A-F][0-9A-F])/g, "%25");
|
|
66
|
+
})
|
|
67
|
+
.join("/");
|
|
68
|
+
if (hash) {
|
|
69
|
+
pathname += `%23${encodeURIComponent(hash.slice(1))}`;
|
|
70
|
+
}
|
|
71
|
+
const urlString = `${origin}${pathname}`;
|
|
72
|
+
const fileSystemPath = fileURLToPath(urlString);
|
|
73
|
+
if (fileSystemPath[fileSystemPath.length - 1] === "/") {
|
|
74
|
+
// remove trailing / so that nodejs path becomes predictable otherwise it logs
|
|
75
|
+
// the trailing slash on linux but does not on windows
|
|
76
|
+
return fileSystemPath.slice(0, -1);
|
|
77
|
+
}
|
|
78
|
+
return fileSystemPath;
|
|
79
|
+
};
|
|
80
|
+
|
|
8
81
|
/*
|
|
9
82
|
* data:[<mediatype>][;base64],<data>
|
|
10
83
|
* https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs#syntax
|
|
@@ -637,6 +710,58 @@ const escapeHtml = (string) => {
|
|
|
637
710
|
.replace(/'/g, "'");
|
|
638
711
|
};
|
|
639
712
|
|
|
713
|
+
const formatError = (error) => {
|
|
714
|
+
let text = "";
|
|
715
|
+
text += error.stack;
|
|
716
|
+
const { cause } = error;
|
|
717
|
+
if (cause) {
|
|
718
|
+
const formatCause = (cause, depth) => {
|
|
719
|
+
let causeText = prefixFirstAndIndentRemainingLines({
|
|
720
|
+
prefix: " [cause]:",
|
|
721
|
+
indentation: " ".repeat(depth + 1),
|
|
722
|
+
text: cause.stack,
|
|
723
|
+
});
|
|
724
|
+
const nestedCause = cause.cause;
|
|
725
|
+
if (nestedCause) {
|
|
726
|
+
const nestedCauseText = formatCause(nestedCause, depth + 1);
|
|
727
|
+
causeText += `\n${nestedCauseText}`;
|
|
728
|
+
}
|
|
729
|
+
return causeText;
|
|
730
|
+
};
|
|
731
|
+
const causeText = formatCause(cause, 0);
|
|
732
|
+
text += `\n${causeText}`;
|
|
733
|
+
}
|
|
734
|
+
return text;
|
|
735
|
+
};
|
|
736
|
+
|
|
737
|
+
const prefixFirstAndIndentRemainingLines = ({
|
|
738
|
+
prefix,
|
|
739
|
+
indentation,
|
|
740
|
+
text,
|
|
741
|
+
trimLines,
|
|
742
|
+
trimLastLine,
|
|
743
|
+
}) => {
|
|
744
|
+
const lines = text.split(/\r?\n/);
|
|
745
|
+
const firstLine = lines.shift();
|
|
746
|
+
if (indentation === undefined) {
|
|
747
|
+
{
|
|
748
|
+
indentation = " "; // prefix + space
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
let result = `${prefix} ${firstLine}` ;
|
|
752
|
+
let i = 0;
|
|
753
|
+
while (i < lines.length) {
|
|
754
|
+
const line = trimLines ? lines[i].trim() : lines[i];
|
|
755
|
+
i++;
|
|
756
|
+
result += line.length
|
|
757
|
+
? `\n${indentation}${line}`
|
|
758
|
+
: trimLastLine && i === lines.length
|
|
759
|
+
? ""
|
|
760
|
+
: `\n`;
|
|
761
|
+
}
|
|
762
|
+
return result;
|
|
763
|
+
};
|
|
764
|
+
|
|
640
765
|
const LOG_LEVEL_OFF = "off";
|
|
641
766
|
|
|
642
767
|
const LOG_LEVEL_DEBUG = "debug";
|
|
@@ -1262,6 +1387,75 @@ const urlToOrigin$1 = (url) => {
|
|
|
1262
1387
|
return new URL(urlString).origin;
|
|
1263
1388
|
};
|
|
1264
1389
|
|
|
1390
|
+
const setUrlExtension = (url, extension) => {
|
|
1391
|
+
const origin = urlToOrigin$1(url);
|
|
1392
|
+
const currentExtension = urlToExtension$1(url);
|
|
1393
|
+
if (typeof extension === "function") {
|
|
1394
|
+
extension = extension(currentExtension);
|
|
1395
|
+
}
|
|
1396
|
+
const resource = urlToResource(url);
|
|
1397
|
+
const [pathname, search] = resource.split("?");
|
|
1398
|
+
const pathnameWithoutExtension = currentExtension
|
|
1399
|
+
? pathname.slice(0, -currentExtension.length)
|
|
1400
|
+
: pathname;
|
|
1401
|
+
let newPathname;
|
|
1402
|
+
if (pathnameWithoutExtension.endsWith("/")) {
|
|
1403
|
+
newPathname = pathnameWithoutExtension.slice(0, -1);
|
|
1404
|
+
newPathname += extension;
|
|
1405
|
+
newPathname += "/";
|
|
1406
|
+
} else {
|
|
1407
|
+
newPathname = pathnameWithoutExtension;
|
|
1408
|
+
newPathname += extension;
|
|
1409
|
+
}
|
|
1410
|
+
return `${origin}${newPathname}${search ? `?${search}` : ""}`;
|
|
1411
|
+
};
|
|
1412
|
+
|
|
1413
|
+
const setUrlFilename = (url, filename) => {
|
|
1414
|
+
const parentPathname = new URL("./", url).pathname;
|
|
1415
|
+
return transformUrlPathname(url, (pathname) => {
|
|
1416
|
+
if (typeof filename === "function") {
|
|
1417
|
+
filename = filename(pathnameToFilename(pathname));
|
|
1418
|
+
}
|
|
1419
|
+
return `${parentPathname}${filename}`;
|
|
1420
|
+
});
|
|
1421
|
+
};
|
|
1422
|
+
|
|
1423
|
+
const setUrlBasename = (url, basename) => {
|
|
1424
|
+
return setUrlFilename(url, (filename) => {
|
|
1425
|
+
if (typeof basename === "function") {
|
|
1426
|
+
basename = basename(filenameToBasename(filename));
|
|
1427
|
+
}
|
|
1428
|
+
return `${basename}${urlToExtension$1(url)}`;
|
|
1429
|
+
});
|
|
1430
|
+
};
|
|
1431
|
+
|
|
1432
|
+
const transformUrlPathname = (url, transformer) => {
|
|
1433
|
+
if (typeof url === "string") {
|
|
1434
|
+
const urlObject = new URL(url);
|
|
1435
|
+
const { pathname } = urlObject;
|
|
1436
|
+
const pathnameTransformed = transformer(pathname);
|
|
1437
|
+
if (pathnameTransformed === pathname) {
|
|
1438
|
+
return url;
|
|
1439
|
+
}
|
|
1440
|
+
let { origin } = urlObject;
|
|
1441
|
+
// origin is "null" for "file://" urls with Node.js
|
|
1442
|
+
if (origin === "null" && urlObject.href.startsWith("file:")) {
|
|
1443
|
+
origin = "file://";
|
|
1444
|
+
}
|
|
1445
|
+
const { search, hash } = urlObject;
|
|
1446
|
+
const urlWithPathnameTransformed = `${origin}${pathnameTransformed}${search}${hash}`;
|
|
1447
|
+
return urlWithPathnameTransformed;
|
|
1448
|
+
}
|
|
1449
|
+
const pathnameTransformed = transformer(url.pathname);
|
|
1450
|
+
url.pathname = pathnameTransformed;
|
|
1451
|
+
return url;
|
|
1452
|
+
};
|
|
1453
|
+
const ensurePathnameTrailingSlash = (url) => {
|
|
1454
|
+
return transformUrlPathname(url, (pathname) => {
|
|
1455
|
+
return pathname.endsWith("/") ? pathname : `${pathname}/`;
|
|
1456
|
+
});
|
|
1457
|
+
};
|
|
1458
|
+
|
|
1265
1459
|
const asUrlWithoutSearch = (url) => {
|
|
1266
1460
|
url = String(url);
|
|
1267
1461
|
if (url.includes("?")) {
|
|
@@ -1352,130 +1546,6 @@ const injectQueryParams = (url, params) => {
|
|
|
1352
1546
|
return normalizeUrl(calledWithString ? urlObject.href : urlObject);
|
|
1353
1547
|
};
|
|
1354
1548
|
|
|
1355
|
-
const setUrlExtension = (url, extension) => {
|
|
1356
|
-
const origin = urlToOrigin$1(url);
|
|
1357
|
-
const currentExtension = urlToExtension$1(url);
|
|
1358
|
-
if (typeof extension === "function") {
|
|
1359
|
-
extension = extension(currentExtension);
|
|
1360
|
-
}
|
|
1361
|
-
const resource = urlToResource(url);
|
|
1362
|
-
const [pathname, search] = resource.split("?");
|
|
1363
|
-
const pathnameWithoutExtension = currentExtension
|
|
1364
|
-
? pathname.slice(0, -currentExtension.length)
|
|
1365
|
-
: pathname;
|
|
1366
|
-
let newPathname;
|
|
1367
|
-
if (pathnameWithoutExtension.endsWith("/")) {
|
|
1368
|
-
newPathname = pathnameWithoutExtension.slice(0, -1);
|
|
1369
|
-
newPathname += extension;
|
|
1370
|
-
newPathname += "/";
|
|
1371
|
-
} else {
|
|
1372
|
-
newPathname = pathnameWithoutExtension;
|
|
1373
|
-
newPathname += extension;
|
|
1374
|
-
}
|
|
1375
|
-
return `${origin}${newPathname}${search ? `?${search}` : ""}`;
|
|
1376
|
-
};
|
|
1377
|
-
|
|
1378
|
-
const setUrlFilename = (url, filename) => {
|
|
1379
|
-
const parentPathname = new URL("./", url).pathname;
|
|
1380
|
-
return transformUrlPathname(url, (pathname) => {
|
|
1381
|
-
if (typeof filename === "function") {
|
|
1382
|
-
filename = filename(pathnameToFilename(pathname));
|
|
1383
|
-
}
|
|
1384
|
-
return `${parentPathname}${filename}`;
|
|
1385
|
-
});
|
|
1386
|
-
};
|
|
1387
|
-
|
|
1388
|
-
const setUrlBasename = (url, basename) => {
|
|
1389
|
-
return setUrlFilename(url, (filename) => {
|
|
1390
|
-
if (typeof basename === "function") {
|
|
1391
|
-
basename = basename(filenameToBasename(filename));
|
|
1392
|
-
}
|
|
1393
|
-
return `${basename}${urlToExtension$1(url)}`;
|
|
1394
|
-
});
|
|
1395
|
-
};
|
|
1396
|
-
|
|
1397
|
-
const transformUrlPathname = (url, transformer) => {
|
|
1398
|
-
if (typeof url === "string") {
|
|
1399
|
-
const urlObject = new URL(url);
|
|
1400
|
-
const { pathname } = urlObject;
|
|
1401
|
-
const pathnameTransformed = transformer(pathname);
|
|
1402
|
-
if (pathnameTransformed === pathname) {
|
|
1403
|
-
return url;
|
|
1404
|
-
}
|
|
1405
|
-
let { origin } = urlObject;
|
|
1406
|
-
// origin is "null" for "file://" urls with Node.js
|
|
1407
|
-
if (origin === "null" && urlObject.href.startsWith("file:")) {
|
|
1408
|
-
origin = "file://";
|
|
1409
|
-
}
|
|
1410
|
-
const { search, hash } = urlObject;
|
|
1411
|
-
const urlWithPathnameTransformed = `${origin}${pathnameTransformed}${search}${hash}`;
|
|
1412
|
-
return urlWithPathnameTransformed;
|
|
1413
|
-
}
|
|
1414
|
-
const pathnameTransformed = transformer(url.pathname);
|
|
1415
|
-
url.pathname = pathnameTransformed;
|
|
1416
|
-
return url;
|
|
1417
|
-
};
|
|
1418
|
-
const ensurePathnameTrailingSlash = (url) => {
|
|
1419
|
-
return transformUrlPathname(url, (pathname) => {
|
|
1420
|
-
return pathname.endsWith("/") ? pathname : `${pathname}/`;
|
|
1421
|
-
});
|
|
1422
|
-
};
|
|
1423
|
-
|
|
1424
|
-
const isFileSystemPath = (value) => {
|
|
1425
|
-
if (typeof value !== "string") {
|
|
1426
|
-
throw new TypeError(
|
|
1427
|
-
`isFileSystemPath first arg must be a string, got ${value}`,
|
|
1428
|
-
);
|
|
1429
|
-
}
|
|
1430
|
-
if (value[0] === "/") {
|
|
1431
|
-
return true;
|
|
1432
|
-
}
|
|
1433
|
-
return startsWithWindowsDriveLetter(value);
|
|
1434
|
-
};
|
|
1435
|
-
|
|
1436
|
-
const startsWithWindowsDriveLetter = (string) => {
|
|
1437
|
-
const firstChar = string[0];
|
|
1438
|
-
if (!/[a-zA-Z]/.test(firstChar)) return false;
|
|
1439
|
-
|
|
1440
|
-
const secondChar = string[1];
|
|
1441
|
-
if (secondChar !== ":") return false;
|
|
1442
|
-
|
|
1443
|
-
return true;
|
|
1444
|
-
};
|
|
1445
|
-
|
|
1446
|
-
const fileSystemPathToUrl = (value) => {
|
|
1447
|
-
if (!isFileSystemPath(value)) {
|
|
1448
|
-
throw new Error(`value must be a filesystem path, got ${value}`);
|
|
1449
|
-
}
|
|
1450
|
-
return String(pathToFileURL(value));
|
|
1451
|
-
};
|
|
1452
|
-
|
|
1453
|
-
const getCallerPosition = () => {
|
|
1454
|
-
const { prepareStackTrace } = Error;
|
|
1455
|
-
Error.prepareStackTrace = (error, stack) => {
|
|
1456
|
-
Error.prepareStackTrace = prepareStackTrace;
|
|
1457
|
-
return stack;
|
|
1458
|
-
};
|
|
1459
|
-
const { stack } = new Error();
|
|
1460
|
-
const callerCallsite = stack[2];
|
|
1461
|
-
const fileName = callerCallsite.getFileName();
|
|
1462
|
-
return {
|
|
1463
|
-
url:
|
|
1464
|
-
fileName && isFileSystemPath(fileName)
|
|
1465
|
-
? fileSystemPathToUrl(fileName)
|
|
1466
|
-
: fileName,
|
|
1467
|
-
line: callerCallsite.getLineNumber(),
|
|
1468
|
-
column: callerCallsite.getColumnNumber(),
|
|
1469
|
-
};
|
|
1470
|
-
};
|
|
1471
|
-
|
|
1472
|
-
const resolveUrl$1 = (specifier, baseUrl) => {
|
|
1473
|
-
if (typeof baseUrl === "undefined") {
|
|
1474
|
-
throw new TypeError(`baseUrl missing to resolve ${specifier}`);
|
|
1475
|
-
}
|
|
1476
|
-
return String(new URL(specifier, baseUrl));
|
|
1477
|
-
};
|
|
1478
|
-
|
|
1479
1549
|
const getCommonPathname = (pathname, otherPathname) => {
|
|
1480
1550
|
if (pathname === otherPathname) {
|
|
1481
1551
|
return pathname;
|
|
@@ -1585,6 +1655,13 @@ const moveUrl = ({ url, from, to, preferRelative }) => {
|
|
|
1585
1655
|
return absoluteUrl;
|
|
1586
1656
|
};
|
|
1587
1657
|
|
|
1658
|
+
const resolveUrl$1 = (specifier, baseUrl) => {
|
|
1659
|
+
if (typeof baseUrl === "undefined") {
|
|
1660
|
+
throw new TypeError(`baseUrl missing to resolve ${specifier}`);
|
|
1661
|
+
}
|
|
1662
|
+
return String(new URL(specifier, baseUrl));
|
|
1663
|
+
};
|
|
1664
|
+
|
|
1588
1665
|
const urlIsInsideOf = (url, otherUrl) => {
|
|
1589
1666
|
const urlObject = new URL(url);
|
|
1590
1667
|
const otherUrlObject = new URL(otherUrl);
|
|
@@ -1603,31 +1680,6 @@ const urlIsInsideOf = (url, otherUrl) => {
|
|
|
1603
1680
|
return isInside;
|
|
1604
1681
|
};
|
|
1605
1682
|
|
|
1606
|
-
const urlToFileSystemPath = (url) => {
|
|
1607
|
-
const urlObject = new URL(url);
|
|
1608
|
-
let { origin, pathname, hash } = urlObject;
|
|
1609
|
-
if (urlObject.protocol === "file:") {
|
|
1610
|
-
origin = "file://";
|
|
1611
|
-
}
|
|
1612
|
-
pathname = pathname
|
|
1613
|
-
.split("/")
|
|
1614
|
-
.map((part) => {
|
|
1615
|
-
return part.replace(/%(?![0-9A-F][0-9A-F])/g, "%25");
|
|
1616
|
-
})
|
|
1617
|
-
.join("/");
|
|
1618
|
-
if (hash) {
|
|
1619
|
-
pathname += `%23${encodeURIComponent(hash.slice(1))}`;
|
|
1620
|
-
}
|
|
1621
|
-
const urlString = `${origin}${pathname}`;
|
|
1622
|
-
const fileSystemPath = fileURLToPath(urlString);
|
|
1623
|
-
if (fileSystemPath[fileSystemPath.length - 1] === "/") {
|
|
1624
|
-
// remove trailing / so that nodejs path becomes predictable otherwise it logs
|
|
1625
|
-
// the trailing slash on linux but does not on windows
|
|
1626
|
-
return fileSystemPath.slice(0, -1);
|
|
1627
|
-
}
|
|
1628
|
-
return fileSystemPath;
|
|
1629
|
-
};
|
|
1630
|
-
|
|
1631
1683
|
const validateDirectoryUrl = (value) => {
|
|
1632
1684
|
let urlString;
|
|
1633
1685
|
|
|
@@ -5349,6 +5401,23 @@ const isResponseEligibleForIntegrityValidation = (response) => {
|
|
|
5349
5401
|
return ["basic", "cors", "default"].includes(response.type);
|
|
5350
5402
|
};
|
|
5351
5403
|
|
|
5404
|
+
const assertImportMap = (value) => {
|
|
5405
|
+
if (value === null) {
|
|
5406
|
+
throw new TypeError(`an importMap must be an object, got null`);
|
|
5407
|
+
}
|
|
5408
|
+
|
|
5409
|
+
const type = typeof value;
|
|
5410
|
+
if (type !== "object") {
|
|
5411
|
+
throw new TypeError(`an importMap must be an object, received ${value}`);
|
|
5412
|
+
}
|
|
5413
|
+
|
|
5414
|
+
if (Array.isArray(value)) {
|
|
5415
|
+
throw new TypeError(
|
|
5416
|
+
`an importMap must be an object, received array ${value}`,
|
|
5417
|
+
);
|
|
5418
|
+
}
|
|
5419
|
+
};
|
|
5420
|
+
|
|
5352
5421
|
// duplicated from @jsenv/log to avoid the dependency
|
|
5353
5422
|
const createDetailedMessage = (message, details = {}) => {
|
|
5354
5423
|
let string = `${message}`;
|
|
@@ -5365,89 +5434,72 @@ const createDetailedMessage = (message, details = {}) => {
|
|
|
5365
5434
|
}`;
|
|
5366
5435
|
});
|
|
5367
5436
|
|
|
5368
|
-
return string
|
|
5437
|
+
return string;
|
|
5369
5438
|
};
|
|
5370
5439
|
|
|
5371
|
-
const
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
}
|
|
5440
|
+
const hasScheme = (string) => {
|
|
5441
|
+
return /^[a-zA-Z]{2,}:/.test(string);
|
|
5442
|
+
};
|
|
5375
5443
|
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
|
|
5444
|
+
const pathnameToParentPathname = (pathname) => {
|
|
5445
|
+
const slashLastIndex = pathname.lastIndexOf("/");
|
|
5446
|
+
if (slashLastIndex === -1) {
|
|
5447
|
+
return "/";
|
|
5379
5448
|
}
|
|
5380
5449
|
|
|
5381
|
-
|
|
5382
|
-
throw new TypeError(
|
|
5383
|
-
`an importMap must be an object, received array ${value}`,
|
|
5384
|
-
)
|
|
5385
|
-
}
|
|
5386
|
-
};
|
|
5387
|
-
|
|
5388
|
-
const hasScheme = (string) => {
|
|
5389
|
-
return /^[a-zA-Z]{2,}:/.test(string)
|
|
5450
|
+
return pathname.slice(0, slashLastIndex + 1);
|
|
5390
5451
|
};
|
|
5391
5452
|
|
|
5392
5453
|
const urlToScheme = (urlString) => {
|
|
5393
5454
|
const colonIndex = urlString.indexOf(":");
|
|
5394
|
-
if (colonIndex === -1) return ""
|
|
5395
|
-
return urlString.slice(0, colonIndex)
|
|
5455
|
+
if (colonIndex === -1) return "";
|
|
5456
|
+
return urlString.slice(0, colonIndex);
|
|
5457
|
+
};
|
|
5458
|
+
|
|
5459
|
+
const urlToOrigin = (urlString) => {
|
|
5460
|
+
const scheme = urlToScheme(urlString);
|
|
5461
|
+
|
|
5462
|
+
if (scheme === "file") {
|
|
5463
|
+
return "file://";
|
|
5464
|
+
}
|
|
5465
|
+
|
|
5466
|
+
if (scheme === "http" || scheme === "https") {
|
|
5467
|
+
const secondProtocolSlashIndex = scheme.length + "://".length;
|
|
5468
|
+
const pathnameSlashIndex = urlString.indexOf("/", secondProtocolSlashIndex);
|
|
5469
|
+
|
|
5470
|
+
if (pathnameSlashIndex === -1) return urlString;
|
|
5471
|
+
return urlString.slice(0, pathnameSlashIndex);
|
|
5472
|
+
}
|
|
5473
|
+
|
|
5474
|
+
return urlString.slice(0, scheme.length + 1);
|
|
5396
5475
|
};
|
|
5397
5476
|
|
|
5398
5477
|
const urlToPathname = (urlString) => {
|
|
5399
|
-
return ressourceToPathname(urlToRessource(urlString))
|
|
5478
|
+
return ressourceToPathname(urlToRessource(urlString));
|
|
5400
5479
|
};
|
|
5401
5480
|
|
|
5402
5481
|
const urlToRessource = (urlString) => {
|
|
5403
5482
|
const scheme = urlToScheme(urlString);
|
|
5404
5483
|
|
|
5405
5484
|
if (scheme === "file") {
|
|
5406
|
-
return urlString.slice("file://".length)
|
|
5485
|
+
return urlString.slice("file://".length);
|
|
5407
5486
|
}
|
|
5408
5487
|
|
|
5409
5488
|
if (scheme === "https" || scheme === "http") {
|
|
5410
5489
|
// remove origin
|
|
5411
5490
|
const afterProtocol = urlString.slice(scheme.length + "://".length);
|
|
5412
5491
|
const pathnameSlashIndex = afterProtocol.indexOf("/", "://".length);
|
|
5413
|
-
return afterProtocol.slice(pathnameSlashIndex)
|
|
5492
|
+
return afterProtocol.slice(pathnameSlashIndex);
|
|
5414
5493
|
}
|
|
5415
5494
|
|
|
5416
|
-
return urlString.slice(scheme.length + 1)
|
|
5495
|
+
return urlString.slice(scheme.length + 1);
|
|
5417
5496
|
};
|
|
5418
5497
|
|
|
5419
5498
|
const ressourceToPathname = (ressource) => {
|
|
5420
5499
|
const searchSeparatorIndex = ressource.indexOf("?");
|
|
5421
5500
|
return searchSeparatorIndex === -1
|
|
5422
5501
|
? ressource
|
|
5423
|
-
: ressource.slice(0, searchSeparatorIndex)
|
|
5424
|
-
};
|
|
5425
|
-
|
|
5426
|
-
const urlToOrigin = (urlString) => {
|
|
5427
|
-
const scheme = urlToScheme(urlString);
|
|
5428
|
-
|
|
5429
|
-
if (scheme === "file") {
|
|
5430
|
-
return "file://"
|
|
5431
|
-
}
|
|
5432
|
-
|
|
5433
|
-
if (scheme === "http" || scheme === "https") {
|
|
5434
|
-
const secondProtocolSlashIndex = scheme.length + "://".length;
|
|
5435
|
-
const pathnameSlashIndex = urlString.indexOf("/", secondProtocolSlashIndex);
|
|
5436
|
-
|
|
5437
|
-
if (pathnameSlashIndex === -1) return urlString
|
|
5438
|
-
return urlString.slice(0, pathnameSlashIndex)
|
|
5439
|
-
}
|
|
5440
|
-
|
|
5441
|
-
return urlString.slice(0, scheme.length + 1)
|
|
5442
|
-
};
|
|
5443
|
-
|
|
5444
|
-
const pathnameToParentPathname = (pathname) => {
|
|
5445
|
-
const slashLastIndex = pathname.lastIndexOf("/");
|
|
5446
|
-
if (slashLastIndex === -1) {
|
|
5447
|
-
return "/"
|
|
5448
|
-
}
|
|
5449
|
-
|
|
5450
|
-
return pathname.slice(0, slashLastIndex + 1)
|
|
5502
|
+
: ressource.slice(0, searchSeparatorIndex);
|
|
5451
5503
|
};
|
|
5452
5504
|
|
|
5453
5505
|
// could be useful: https://url.spec.whatwg.org/#url-miscellaneous
|
|
@@ -5456,29 +5508,29 @@ const pathnameToParentPathname = (pathname) => {
|
|
|
5456
5508
|
const resolveUrl = (specifier, baseUrl) => {
|
|
5457
5509
|
if (baseUrl) {
|
|
5458
5510
|
if (typeof baseUrl !== "string") {
|
|
5459
|
-
throw new TypeError(writeBaseUrlMustBeAString({ baseUrl, specifier }))
|
|
5511
|
+
throw new TypeError(writeBaseUrlMustBeAString({ baseUrl, specifier }));
|
|
5460
5512
|
}
|
|
5461
5513
|
if (!hasScheme(baseUrl)) {
|
|
5462
|
-
throw new Error(writeBaseUrlMustBeAbsolute({ baseUrl, specifier }))
|
|
5514
|
+
throw new Error(writeBaseUrlMustBeAbsolute({ baseUrl, specifier }));
|
|
5463
5515
|
}
|
|
5464
5516
|
}
|
|
5465
5517
|
|
|
5466
5518
|
if (hasScheme(specifier)) {
|
|
5467
|
-
return specifier
|
|
5519
|
+
return specifier;
|
|
5468
5520
|
}
|
|
5469
5521
|
|
|
5470
5522
|
if (!baseUrl) {
|
|
5471
|
-
throw new Error(writeBaseUrlRequired({ baseUrl, specifier }))
|
|
5523
|
+
throw new Error(writeBaseUrlRequired({ baseUrl, specifier }));
|
|
5472
5524
|
}
|
|
5473
5525
|
|
|
5474
5526
|
// scheme relative
|
|
5475
5527
|
if (specifier.slice(0, 2) === "//") {
|
|
5476
|
-
return `${urlToScheme(baseUrl)}:${specifier}
|
|
5528
|
+
return `${urlToScheme(baseUrl)}:${specifier}`;
|
|
5477
5529
|
}
|
|
5478
5530
|
|
|
5479
5531
|
// origin relative
|
|
5480
5532
|
if (specifier[0] === "/") {
|
|
5481
|
-
return `${urlToOrigin(baseUrl)}${specifier}
|
|
5533
|
+
return `${urlToOrigin(baseUrl)}${specifier}`;
|
|
5482
5534
|
}
|
|
5483
5535
|
|
|
5484
5536
|
const baseOrigin = urlToOrigin(baseUrl);
|
|
@@ -5486,13 +5538,13 @@ const resolveUrl = (specifier, baseUrl) => {
|
|
|
5486
5538
|
|
|
5487
5539
|
if (specifier === ".") {
|
|
5488
5540
|
const baseDirectoryPathname = pathnameToParentPathname(basePathname);
|
|
5489
|
-
return `${baseOrigin}${baseDirectoryPathname}
|
|
5541
|
+
return `${baseOrigin}${baseDirectoryPathname}`;
|
|
5490
5542
|
}
|
|
5491
5543
|
|
|
5492
5544
|
// pathname relative inside
|
|
5493
5545
|
if (specifier.slice(0, 2) === "./") {
|
|
5494
5546
|
const baseDirectoryPathname = pathnameToParentPathname(basePathname);
|
|
5495
|
-
return `${baseOrigin}${baseDirectoryPathname}${specifier.slice(2)}
|
|
5547
|
+
return `${baseOrigin}${baseDirectoryPathname}${specifier.slice(2)}`;
|
|
5496
5548
|
}
|
|
5497
5549
|
|
|
5498
5550
|
// pathname relative outside
|
|
@@ -5513,17 +5565,17 @@ const resolveUrl = (specifier, baseUrl) => {
|
|
|
5513
5565
|
const resolvedPathname = `${importerFolders.join(
|
|
5514
5566
|
"/",
|
|
5515
5567
|
)}/${unresolvedPathname}`;
|
|
5516
|
-
return `${baseOrigin}${resolvedPathname}
|
|
5568
|
+
return `${baseOrigin}${resolvedPathname}`;
|
|
5517
5569
|
}
|
|
5518
5570
|
|
|
5519
5571
|
// bare
|
|
5520
5572
|
if (basePathname === "") {
|
|
5521
|
-
return `${baseOrigin}/${specifier}
|
|
5573
|
+
return `${baseOrigin}/${specifier}`;
|
|
5522
5574
|
}
|
|
5523
5575
|
if (basePathname[basePathname.length] === "/") {
|
|
5524
|
-
return `${baseOrigin}${basePathname}${specifier}
|
|
5576
|
+
return `${baseOrigin}${basePathname}${specifier}`;
|
|
5525
5577
|
}
|
|
5526
|
-
return `${baseOrigin}${pathnameToParentPathname(basePathname)}${specifier}
|
|
5578
|
+
return `${baseOrigin}${pathnameToParentPathname(basePathname)}${specifier}`;
|
|
5527
5579
|
};
|
|
5528
5580
|
|
|
5529
5581
|
const writeBaseUrlMustBeAString = ({
|
|
@@ -5555,7 +5607,7 @@ ${specifier}`;
|
|
|
5555
5607
|
|
|
5556
5608
|
const tryUrlResolution = (string, url) => {
|
|
5557
5609
|
const result = resolveUrl(string, url);
|
|
5558
|
-
return hasScheme(result) ? result : null
|
|
5610
|
+
return hasScheme(result) ? result : null;
|
|
5559
5611
|
};
|
|
5560
5612
|
|
|
5561
5613
|
const resolveSpecifier = (specifier, importer) => {
|
|
@@ -5565,14 +5617,14 @@ const resolveSpecifier = (specifier, importer) => {
|
|
|
5565
5617
|
specifier.startsWith("./") ||
|
|
5566
5618
|
specifier.startsWith("../")
|
|
5567
5619
|
) {
|
|
5568
|
-
return resolveUrl(specifier, importer)
|
|
5620
|
+
return resolveUrl(specifier, importer);
|
|
5569
5621
|
}
|
|
5570
5622
|
|
|
5571
5623
|
if (hasScheme(specifier)) {
|
|
5572
|
-
return specifier
|
|
5624
|
+
return specifier;
|
|
5573
5625
|
}
|
|
5574
5626
|
|
|
5575
|
-
return null
|
|
5627
|
+
return null;
|
|
5576
5628
|
};
|
|
5577
5629
|
|
|
5578
5630
|
const applyImportMap = ({
|
|
@@ -5585,7 +5637,7 @@ const applyImportMap = ({
|
|
|
5585
5637
|
specifier,
|
|
5586
5638
|
importer,
|
|
5587
5639
|
}),
|
|
5588
|
-
)
|
|
5640
|
+
);
|
|
5589
5641
|
},
|
|
5590
5642
|
onImportMapping = () => {},
|
|
5591
5643
|
}) => {
|
|
@@ -5596,7 +5648,7 @@ const applyImportMap = ({
|
|
|
5596
5648
|
specifier,
|
|
5597
5649
|
importer,
|
|
5598
5650
|
}),
|
|
5599
|
-
)
|
|
5651
|
+
);
|
|
5600
5652
|
}
|
|
5601
5653
|
if (importer) {
|
|
5602
5654
|
if (typeof importer !== "string") {
|
|
@@ -5605,7 +5657,7 @@ const applyImportMap = ({
|
|
|
5605
5657
|
importer,
|
|
5606
5658
|
specifier,
|
|
5607
5659
|
}),
|
|
5608
|
-
)
|
|
5660
|
+
);
|
|
5609
5661
|
}
|
|
5610
5662
|
if (!hasScheme(importer)) {
|
|
5611
5663
|
throw new Error(
|
|
@@ -5613,7 +5665,7 @@ const applyImportMap = ({
|
|
|
5613
5665
|
importer,
|
|
5614
5666
|
specifier,
|
|
5615
5667
|
}),
|
|
5616
|
-
)
|
|
5668
|
+
);
|
|
5617
5669
|
}
|
|
5618
5670
|
}
|
|
5619
5671
|
|
|
@@ -5627,7 +5679,7 @@ const applyImportMap = ({
|
|
|
5627
5679
|
return (
|
|
5628
5680
|
scopeSpecifier === importer ||
|
|
5629
5681
|
specifierIsPrefixOf(scopeSpecifier, importer)
|
|
5630
|
-
)
|
|
5682
|
+
);
|
|
5631
5683
|
},
|
|
5632
5684
|
);
|
|
5633
5685
|
if (scopeSpecifierMatching) {
|
|
@@ -5639,7 +5691,7 @@ const applyImportMap = ({
|
|
|
5639
5691
|
onImportMapping,
|
|
5640
5692
|
);
|
|
5641
5693
|
if (mappingFromScopes !== null) {
|
|
5642
|
-
return mappingFromScopes
|
|
5694
|
+
return mappingFromScopes;
|
|
5643
5695
|
}
|
|
5644
5696
|
}
|
|
5645
5697
|
}
|
|
@@ -5653,15 +5705,15 @@ const applyImportMap = ({
|
|
|
5653
5705
|
onImportMapping,
|
|
5654
5706
|
);
|
|
5655
5707
|
if (mappingFromImports !== null) {
|
|
5656
|
-
return mappingFromImports
|
|
5708
|
+
return mappingFromImports;
|
|
5657
5709
|
}
|
|
5658
5710
|
}
|
|
5659
5711
|
|
|
5660
5712
|
if (specifierUrl) {
|
|
5661
|
-
return specifierUrl
|
|
5713
|
+
return specifierUrl;
|
|
5662
5714
|
}
|
|
5663
5715
|
|
|
5664
|
-
throw createBareSpecifierError({ specifier, importer })
|
|
5716
|
+
throw createBareSpecifierError({ specifier, importer });
|
|
5665
5717
|
};
|
|
5666
5718
|
|
|
5667
5719
|
const applyMappings = (
|
|
@@ -5685,7 +5737,7 @@ const applyMappings = (
|
|
|
5685
5737
|
before: specifierNormalized,
|
|
5686
5738
|
after: address,
|
|
5687
5739
|
});
|
|
5688
|
-
return address
|
|
5740
|
+
return address;
|
|
5689
5741
|
}
|
|
5690
5742
|
if (specifierIsPrefixOf(specifierCandidate, specifierNormalized)) {
|
|
5691
5743
|
const address = mappings[specifierCandidate];
|
|
@@ -5700,18 +5752,18 @@ const applyMappings = (
|
|
|
5700
5752
|
before: specifierNormalized,
|
|
5701
5753
|
after: addressFinal,
|
|
5702
5754
|
});
|
|
5703
|
-
return addressFinal
|
|
5755
|
+
return addressFinal;
|
|
5704
5756
|
}
|
|
5705
5757
|
}
|
|
5706
5758
|
|
|
5707
|
-
return null
|
|
5759
|
+
return null;
|
|
5708
5760
|
};
|
|
5709
5761
|
|
|
5710
5762
|
const specifierIsPrefixOf = (specifierHref, href) => {
|
|
5711
5763
|
return (
|
|
5712
5764
|
specifierHref[specifierHref.length - 1] === "/" &&
|
|
5713
5765
|
href.startsWith(specifierHref)
|
|
5714
|
-
)
|
|
5766
|
+
);
|
|
5715
5767
|
};
|
|
5716
5768
|
|
|
5717
5769
|
// https://github.com/systemjs/systemjs/blob/89391f92dfeac33919b0223bbf834a1f4eea5750/src/common.js#L136
|
|
@@ -5750,7 +5802,7 @@ const composeTwoImportMaps = (leftImportMap, rightImportMap) => {
|
|
|
5750
5802
|
importMap.scopes = { ...rightScopes };
|
|
5751
5803
|
}
|
|
5752
5804
|
|
|
5753
|
-
return importMap
|
|
5805
|
+
return importMap;
|
|
5754
5806
|
};
|
|
5755
5807
|
|
|
5756
5808
|
const composeTwoMappings = (leftMappings, rightMappings) => {
|
|
@@ -5759,11 +5811,11 @@ const composeTwoMappings = (leftMappings, rightMappings) => {
|
|
|
5759
5811
|
Object.keys(leftMappings).forEach((leftSpecifier) => {
|
|
5760
5812
|
if (objectHasKey(rightMappings, leftSpecifier)) {
|
|
5761
5813
|
// will be overidden
|
|
5762
|
-
return
|
|
5814
|
+
return;
|
|
5763
5815
|
}
|
|
5764
5816
|
const leftAddress = leftMappings[leftSpecifier];
|
|
5765
5817
|
const rightSpecifier = Object.keys(rightMappings).find((rightSpecifier) => {
|
|
5766
|
-
return compareAddressAndSpecifier(leftAddress, rightSpecifier)
|
|
5818
|
+
return compareAddressAndSpecifier(leftAddress, rightSpecifier);
|
|
5767
5819
|
});
|
|
5768
5820
|
mappings[leftSpecifier] = rightSpecifier
|
|
5769
5821
|
? rightMappings[rightSpecifier]
|
|
@@ -5774,7 +5826,7 @@ const composeTwoMappings = (leftMappings, rightMappings) => {
|
|
|
5774
5826
|
mappings[rightSpecifier] = rightMappings[rightSpecifier];
|
|
5775
5827
|
});
|
|
5776
5828
|
|
|
5777
|
-
return mappings
|
|
5829
|
+
return mappings;
|
|
5778
5830
|
};
|
|
5779
5831
|
|
|
5780
5832
|
const objectHasKey = (object, key) =>
|
|
@@ -5783,7 +5835,7 @@ const objectHasKey = (object, key) =>
|
|
|
5783
5835
|
const compareAddressAndSpecifier = (address, specifier) => {
|
|
5784
5836
|
const addressUrl = resolveUrl(address, "file:///");
|
|
5785
5837
|
const specifierUrl = resolveUrl(specifier, "file:///");
|
|
5786
|
-
return addressUrl === specifierUrl
|
|
5838
|
+
return addressUrl === specifierUrl;
|
|
5787
5839
|
};
|
|
5788
5840
|
|
|
5789
5841
|
const composeTwoScopes = (leftScopes, rightScopes, imports) => {
|
|
@@ -5793,14 +5845,14 @@ const composeTwoScopes = (leftScopes, rightScopes, imports) => {
|
|
|
5793
5845
|
if (objectHasKey(rightScopes, leftScopeKey)) {
|
|
5794
5846
|
// will be merged
|
|
5795
5847
|
scopes[leftScopeKey] = leftScopes[leftScopeKey];
|
|
5796
|
-
return
|
|
5848
|
+
return;
|
|
5797
5849
|
}
|
|
5798
5850
|
const topLevelSpecifier = Object.keys(imports).find(
|
|
5799
5851
|
(topLevelSpecifierCandidate) => {
|
|
5800
5852
|
return compareAddressAndSpecifier(
|
|
5801
5853
|
leftScopeKey,
|
|
5802
5854
|
topLevelSpecifierCandidate,
|
|
5803
|
-
)
|
|
5855
|
+
);
|
|
5804
5856
|
},
|
|
5805
5857
|
);
|
|
5806
5858
|
if (topLevelSpecifier) {
|
|
@@ -5823,7 +5875,7 @@ const composeTwoScopes = (leftScopes, rightScopes, imports) => {
|
|
|
5823
5875
|
}
|
|
5824
5876
|
});
|
|
5825
5877
|
|
|
5826
|
-
return scopes
|
|
5878
|
+
return scopes;
|
|
5827
5879
|
};
|
|
5828
5880
|
|
|
5829
5881
|
const sortImports = (imports) => {
|
|
@@ -5835,7 +5887,7 @@ const sortImports = (imports) => {
|
|
|
5835
5887
|
mappingsSorted[name] = imports[name];
|
|
5836
5888
|
});
|
|
5837
5889
|
|
|
5838
|
-
return mappingsSorted
|
|
5890
|
+
return mappingsSorted;
|
|
5839
5891
|
};
|
|
5840
5892
|
|
|
5841
5893
|
const sortScopes = (scopes) => {
|
|
@@ -5847,18 +5899,18 @@ const sortScopes = (scopes) => {
|
|
|
5847
5899
|
scopesSorted[scopeSpecifier] = sortImports(scopes[scopeSpecifier]);
|
|
5848
5900
|
});
|
|
5849
5901
|
|
|
5850
|
-
return scopesSorted
|
|
5902
|
+
return scopesSorted;
|
|
5851
5903
|
};
|
|
5852
5904
|
|
|
5853
5905
|
const compareLengthOrLocaleCompare = (a, b) => {
|
|
5854
|
-
return b.length - a.length || a.localeCompare(b)
|
|
5906
|
+
return b.length - a.length || a.localeCompare(b);
|
|
5855
5907
|
};
|
|
5856
5908
|
|
|
5857
5909
|
const normalizeImportMap = (importMap, baseUrl) => {
|
|
5858
5910
|
assertImportMap(importMap);
|
|
5859
5911
|
|
|
5860
5912
|
if (!isStringOrUrl(baseUrl)) {
|
|
5861
|
-
throw new TypeError(formulateBaseUrlMustBeStringOrUrl({ baseUrl }))
|
|
5913
|
+
throw new TypeError(formulateBaseUrlMustBeStringOrUrl({ baseUrl }));
|
|
5862
5914
|
}
|
|
5863
5915
|
|
|
5864
5916
|
const { imports, scopes } = importMap;
|
|
@@ -5866,19 +5918,19 @@ const normalizeImportMap = (importMap, baseUrl) => {
|
|
|
5866
5918
|
return {
|
|
5867
5919
|
imports: imports ? normalizeMappings(imports, baseUrl) : undefined,
|
|
5868
5920
|
scopes: scopes ? normalizeScopes(scopes, baseUrl) : undefined,
|
|
5869
|
-
}
|
|
5921
|
+
};
|
|
5870
5922
|
};
|
|
5871
5923
|
|
|
5872
5924
|
const isStringOrUrl = (value) => {
|
|
5873
5925
|
if (typeof value === "string") {
|
|
5874
|
-
return true
|
|
5926
|
+
return true;
|
|
5875
5927
|
}
|
|
5876
5928
|
|
|
5877
5929
|
if (typeof URL === "function" && value instanceof URL) {
|
|
5878
|
-
return true
|
|
5930
|
+
return true;
|
|
5879
5931
|
}
|
|
5880
5932
|
|
|
5881
|
-
return false
|
|
5933
|
+
return false;
|
|
5882
5934
|
};
|
|
5883
5935
|
|
|
5884
5936
|
const normalizeMappings = (mappings, baseUrl) => {
|
|
@@ -5894,7 +5946,7 @@ const normalizeMappings = (mappings, baseUrl) => {
|
|
|
5894
5946
|
specifier,
|
|
5895
5947
|
}),
|
|
5896
5948
|
);
|
|
5897
|
-
return
|
|
5949
|
+
return;
|
|
5898
5950
|
}
|
|
5899
5951
|
|
|
5900
5952
|
const specifierResolved = resolveSpecifier(specifier, baseUrl) || specifier;
|
|
@@ -5908,7 +5960,7 @@ const normalizeMappings = (mappings, baseUrl) => {
|
|
|
5908
5960
|
specifier,
|
|
5909
5961
|
}),
|
|
5910
5962
|
);
|
|
5911
|
-
return
|
|
5963
|
+
return;
|
|
5912
5964
|
}
|
|
5913
5965
|
|
|
5914
5966
|
if (specifier.endsWith("/") && !addressUrl.endsWith("/")) {
|
|
@@ -5918,12 +5970,12 @@ const normalizeMappings = (mappings, baseUrl) => {
|
|
|
5918
5970
|
specifier,
|
|
5919
5971
|
}),
|
|
5920
5972
|
);
|
|
5921
|
-
return
|
|
5973
|
+
return;
|
|
5922
5974
|
}
|
|
5923
5975
|
mappingsNormalized[specifierResolved] = addressUrl;
|
|
5924
5976
|
});
|
|
5925
5977
|
|
|
5926
|
-
return sortImports(mappingsNormalized)
|
|
5978
|
+
return sortImports(mappingsNormalized);
|
|
5927
5979
|
};
|
|
5928
5980
|
|
|
5929
5981
|
const normalizeScopes = (scopes, baseUrl) => {
|
|
@@ -5939,13 +5991,13 @@ const normalizeScopes = (scopes, baseUrl) => {
|
|
|
5939
5991
|
baseUrl,
|
|
5940
5992
|
}),
|
|
5941
5993
|
);
|
|
5942
|
-
return
|
|
5994
|
+
return;
|
|
5943
5995
|
}
|
|
5944
5996
|
const scopeValueNormalized = normalizeMappings(scopeMappings, baseUrl);
|
|
5945
5997
|
scopesNormalized[scopeUrl] = scopeValueNormalized;
|
|
5946
5998
|
});
|
|
5947
5999
|
|
|
5948
|
-
return sortScopes(scopesNormalized)
|
|
6000
|
+
return sortScopes(scopesNormalized);
|
|
5949
6001
|
};
|
|
5950
6002
|
|
|
5951
6003
|
const formulateBaseUrlMustBeStringOrUrl = ({
|
|
@@ -6003,9 +6055,9 @@ const pathnameToExtension = (pathname) => {
|
|
|
6003
6055
|
}
|
|
6004
6056
|
|
|
6005
6057
|
const dotLastIndex = pathname.lastIndexOf(".");
|
|
6006
|
-
if (dotLastIndex === -1) return ""
|
|
6058
|
+
if (dotLastIndex === -1) return "";
|
|
6007
6059
|
// if (dotLastIndex === pathname.length - 1) return ""
|
|
6008
|
-
return pathname.slice(dotLastIndex)
|
|
6060
|
+
return pathname.slice(dotLastIndex);
|
|
6009
6061
|
};
|
|
6010
6062
|
|
|
6011
6063
|
const resolveImport = ({
|
|
@@ -6033,20 +6085,20 @@ const resolveImport = ({
|
|
|
6033
6085
|
url = applyDefaultExtension({ url, importer, defaultExtension });
|
|
6034
6086
|
}
|
|
6035
6087
|
|
|
6036
|
-
return url
|
|
6088
|
+
return url;
|
|
6037
6089
|
};
|
|
6038
6090
|
|
|
6039
6091
|
const applyDefaultExtension = ({ url, importer, defaultExtension }) => {
|
|
6040
6092
|
if (urlToPathname(url).endsWith("/")) {
|
|
6041
|
-
return url
|
|
6093
|
+
return url;
|
|
6042
6094
|
}
|
|
6043
6095
|
|
|
6044
6096
|
if (typeof defaultExtension === "string") {
|
|
6045
6097
|
const extension = pathnameToExtension(url);
|
|
6046
6098
|
if (extension === "") {
|
|
6047
|
-
return `${url}${defaultExtension}
|
|
6099
|
+
return `${url}${defaultExtension}`;
|
|
6048
6100
|
}
|
|
6049
|
-
return url
|
|
6101
|
+
return url;
|
|
6050
6102
|
}
|
|
6051
6103
|
|
|
6052
6104
|
if (defaultExtension === true) {
|
|
@@ -6054,11 +6106,11 @@ const applyDefaultExtension = ({ url, importer, defaultExtension }) => {
|
|
|
6054
6106
|
if (extension === "" && importer) {
|
|
6055
6107
|
const importerPathname = urlToPathname(importer);
|
|
6056
6108
|
const importerExtension = pathnameToExtension(importerPathname);
|
|
6057
|
-
return `${url}${importerExtension}
|
|
6109
|
+
return `${url}${importerExtension}`;
|
|
6058
6110
|
}
|
|
6059
6111
|
}
|
|
6060
6112
|
|
|
6061
|
-
return url
|
|
6113
|
+
return url;
|
|
6062
6114
|
};
|
|
6063
6115
|
|
|
6064
6116
|
const isEscaped = (i, string) => {
|
|
@@ -6205,4 +6257,4 @@ const memoizeByFirstArgument = (compute) => {
|
|
|
6205
6257
|
return fnWithMemoization;
|
|
6206
6258
|
};
|
|
6207
6259
|
|
|
6208
|
-
export { ANSI, CONTENT_TYPE, DATA_URL, JS_QUOTES, RUNTIME_COMPAT, URL_META, applyFileSystemMagicResolution, applyNodeEsmResolution, asSpecifierWithoutSearch, asUrlWithoutSearch, assertAndNormalizeDirectoryUrl, bufferToEtag, compareFileUrls, composeTwoImportMaps, createDetailedMessage$1 as createDetailedMessage, createLogger, createTaskLog, defaultLookupPackageScope, defaultReadPackageJson, ensurePathnameTrailingSlash, ensureWindowsDriveLetter, errorToHTML, generateContentFrame, getCallerPosition, getExtensionsToTry, injectQueryParamsIntoSpecifier, isFileSystemPath, isSpecifierForNodeBuiltin, lookupPackageDirectory, memoizeByFirstArgument, moveUrl, normalizeImportMap, normalizeUrl, readCustomConditionsFromProcessArgs, readEntryStatSync, readPackageAtOrNull, registerDirectoryLifecycle, resolveImport, setUrlBasename, setUrlExtension, setUrlFilename, stringifyUrlSite, urlIsInsideOf, urlToBasename, urlToExtension$1 as urlToExtension, urlToFileSystemPath, urlToFilename$1 as urlToFilename, urlToPathname$1 as urlToPathname, urlToRelativeUrl, validateResponseIntegrity, writeFileSync };
|
|
6260
|
+
export { ANSI, CONTENT_TYPE, DATA_URL, JS_QUOTES, RUNTIME_COMPAT, URL_META, applyFileSystemMagicResolution, applyNodeEsmResolution, asSpecifierWithoutSearch, asUrlWithoutSearch, assertAndNormalizeDirectoryUrl, bufferToEtag, compareFileUrls, composeTwoImportMaps, createDetailedMessage$1 as createDetailedMessage, createLogger, createTaskLog, defaultLookupPackageScope, defaultReadPackageJson, ensurePathnameTrailingSlash, ensureWindowsDriveLetter, errorToHTML, formatError, generateContentFrame, getCallerPosition, getExtensionsToTry, injectQueryParamsIntoSpecifier, isFileSystemPath, isSpecifierForNodeBuiltin, lookupPackageDirectory, memoizeByFirstArgument, moveUrl, normalizeImportMap, normalizeUrl, readCustomConditionsFromProcessArgs, readEntryStatSync, readPackageAtOrNull, registerDirectoryLifecycle, resolveImport, setUrlBasename, setUrlExtension, setUrlFilename, stringifyUrlSite, urlIsInsideOf, urlToBasename, urlToExtension$1 as urlToExtension, urlToFileSystemPath, urlToFilename$1 as urlToFilename, urlToPathname$1 as urlToPathname, urlToRelativeUrl, validateResponseIntegrity, writeFileSync };
|