@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.
@@ -516,6 +516,79 @@ const SIGINT_CALLBACK = {
516
516
  },
517
517
  };
518
518
 
519
+ const isFileSystemPath = (value) => {
520
+ if (typeof value !== "string") {
521
+ throw new TypeError(
522
+ `isFileSystemPath first arg must be a string, got ${value}`,
523
+ );
524
+ }
525
+ if (value[0] === "/") {
526
+ return true;
527
+ }
528
+ return startsWithWindowsDriveLetter(value);
529
+ };
530
+
531
+ const startsWithWindowsDriveLetter = (string) => {
532
+ const firstChar = string[0];
533
+ if (!/[a-zA-Z]/.test(firstChar)) return false;
534
+
535
+ const secondChar = string[1];
536
+ if (secondChar !== ":") return false;
537
+
538
+ return true;
539
+ };
540
+
541
+ const fileSystemPathToUrl = (value) => {
542
+ if (!isFileSystemPath(value)) {
543
+ throw new Error(`value must be a filesystem path, got ${value}`);
544
+ }
545
+ return String(pathToFileURL(value));
546
+ };
547
+
548
+ const getCallerPosition = () => {
549
+ const { prepareStackTrace } = Error;
550
+ Error.prepareStackTrace = (error, stack) => {
551
+ Error.prepareStackTrace = prepareStackTrace;
552
+ return stack;
553
+ };
554
+ const { stack } = new Error();
555
+ const callerCallsite = stack[2];
556
+ const fileName = callerCallsite.getFileName();
557
+ return {
558
+ url:
559
+ fileName && isFileSystemPath(fileName)
560
+ ? fileSystemPathToUrl(fileName)
561
+ : fileName,
562
+ line: callerCallsite.getLineNumber(),
563
+ column: callerCallsite.getColumnNumber(),
564
+ };
565
+ };
566
+
567
+ const urlToFileSystemPath = (url) => {
568
+ const urlObject = new URL(url);
569
+ let { origin, pathname, hash } = urlObject;
570
+ if (urlObject.protocol === "file:") {
571
+ origin = "file://";
572
+ }
573
+ pathname = pathname
574
+ .split("/")
575
+ .map((part) => {
576
+ return part.replace(/%(?![0-9A-F][0-9A-F])/g, "%25");
577
+ })
578
+ .join("/");
579
+ if (hash) {
580
+ pathname += `%23${encodeURIComponent(hash.slice(1))}`;
581
+ }
582
+ const urlString = `${origin}${pathname}`;
583
+ const fileSystemPath = fileURLToPath(urlString);
584
+ if (fileSystemPath[fileSystemPath.length - 1] === "/") {
585
+ // remove trailing / so that nodejs path becomes predictable otherwise it logs
586
+ // the trailing slash on linux but does not on windows
587
+ return fileSystemPath.slice(0, -1);
588
+ }
589
+ return fileSystemPath;
590
+ };
591
+
519
592
  /*
520
593
  * data:[<mediatype>][;base64],<data>
521
594
  * https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs#syntax
@@ -1947,6 +2020,75 @@ const urlToOrigin$1 = (url) => {
1947
2020
  return new URL(urlString).origin;
1948
2021
  };
1949
2022
 
2023
+ const setUrlExtension = (url, extension) => {
2024
+ const origin = urlToOrigin$1(url);
2025
+ const currentExtension = urlToExtension$1(url);
2026
+ if (typeof extension === "function") {
2027
+ extension = extension(currentExtension);
2028
+ }
2029
+ const resource = urlToResource(url);
2030
+ const [pathname, search] = resource.split("?");
2031
+ const pathnameWithoutExtension = currentExtension
2032
+ ? pathname.slice(0, -currentExtension.length)
2033
+ : pathname;
2034
+ let newPathname;
2035
+ if (pathnameWithoutExtension.endsWith("/")) {
2036
+ newPathname = pathnameWithoutExtension.slice(0, -1);
2037
+ newPathname += extension;
2038
+ newPathname += "/";
2039
+ } else {
2040
+ newPathname = pathnameWithoutExtension;
2041
+ newPathname += extension;
2042
+ }
2043
+ return `${origin}${newPathname}${search ? `?${search}` : ""}`;
2044
+ };
2045
+
2046
+ const setUrlFilename = (url, filename) => {
2047
+ const parentPathname = new URL("./", url).pathname;
2048
+ return transformUrlPathname(url, (pathname) => {
2049
+ if (typeof filename === "function") {
2050
+ filename = filename(pathnameToFilename(pathname));
2051
+ }
2052
+ return `${parentPathname}${filename}`;
2053
+ });
2054
+ };
2055
+
2056
+ const setUrlBasename = (url, basename) => {
2057
+ return setUrlFilename(url, (filename) => {
2058
+ if (typeof basename === "function") {
2059
+ basename = basename(filenameToBasename(filename));
2060
+ }
2061
+ return `${basename}${urlToExtension$1(url)}`;
2062
+ });
2063
+ };
2064
+
2065
+ const transformUrlPathname = (url, transformer) => {
2066
+ if (typeof url === "string") {
2067
+ const urlObject = new URL(url);
2068
+ const { pathname } = urlObject;
2069
+ const pathnameTransformed = transformer(pathname);
2070
+ if (pathnameTransformed === pathname) {
2071
+ return url;
2072
+ }
2073
+ let { origin } = urlObject;
2074
+ // origin is "null" for "file://" urls with Node.js
2075
+ if (origin === "null" && urlObject.href.startsWith("file:")) {
2076
+ origin = "file://";
2077
+ }
2078
+ const { search, hash } = urlObject;
2079
+ const urlWithPathnameTransformed = `${origin}${pathnameTransformed}${search}${hash}`;
2080
+ return urlWithPathnameTransformed;
2081
+ }
2082
+ const pathnameTransformed = transformer(url.pathname);
2083
+ url.pathname = pathnameTransformed;
2084
+ return url;
2085
+ };
2086
+ const ensurePathnameTrailingSlash = (url) => {
2087
+ return transformUrlPathname(url, (pathname) => {
2088
+ return pathname.endsWith("/") ? pathname : `${pathname}/`;
2089
+ });
2090
+ };
2091
+
1950
2092
  const asUrlWithoutSearch = (url) => {
1951
2093
  url = String(url);
1952
2094
  if (url.includes("?")) {
@@ -2099,130 +2241,6 @@ const renderUrlOrRelativeUrlFilename = (urlOrRelativeUrl, renderer) => {
2099
2241
  return `${beforeFilename}${newFilename}${afterQuestion}`;
2100
2242
  };
2101
2243
 
2102
- const setUrlExtension = (url, extension) => {
2103
- const origin = urlToOrigin$1(url);
2104
- const currentExtension = urlToExtension$1(url);
2105
- if (typeof extension === "function") {
2106
- extension = extension(currentExtension);
2107
- }
2108
- const resource = urlToResource(url);
2109
- const [pathname, search] = resource.split("?");
2110
- const pathnameWithoutExtension = currentExtension
2111
- ? pathname.slice(0, -currentExtension.length)
2112
- : pathname;
2113
- let newPathname;
2114
- if (pathnameWithoutExtension.endsWith("/")) {
2115
- newPathname = pathnameWithoutExtension.slice(0, -1);
2116
- newPathname += extension;
2117
- newPathname += "/";
2118
- } else {
2119
- newPathname = pathnameWithoutExtension;
2120
- newPathname += extension;
2121
- }
2122
- return `${origin}${newPathname}${search ? `?${search}` : ""}`;
2123
- };
2124
-
2125
- const setUrlFilename = (url, filename) => {
2126
- const parentPathname = new URL("./", url).pathname;
2127
- return transformUrlPathname(url, (pathname) => {
2128
- if (typeof filename === "function") {
2129
- filename = filename(pathnameToFilename(pathname));
2130
- }
2131
- return `${parentPathname}${filename}`;
2132
- });
2133
- };
2134
-
2135
- const setUrlBasename = (url, basename) => {
2136
- return setUrlFilename(url, (filename) => {
2137
- if (typeof basename === "function") {
2138
- basename = basename(filenameToBasename(filename));
2139
- }
2140
- return `${basename}${urlToExtension$1(url)}`;
2141
- });
2142
- };
2143
-
2144
- const transformUrlPathname = (url, transformer) => {
2145
- if (typeof url === "string") {
2146
- const urlObject = new URL(url);
2147
- const { pathname } = urlObject;
2148
- const pathnameTransformed = transformer(pathname);
2149
- if (pathnameTransformed === pathname) {
2150
- return url;
2151
- }
2152
- let { origin } = urlObject;
2153
- // origin is "null" for "file://" urls with Node.js
2154
- if (origin === "null" && urlObject.href.startsWith("file:")) {
2155
- origin = "file://";
2156
- }
2157
- const { search, hash } = urlObject;
2158
- const urlWithPathnameTransformed = `${origin}${pathnameTransformed}${search}${hash}`;
2159
- return urlWithPathnameTransformed;
2160
- }
2161
- const pathnameTransformed = transformer(url.pathname);
2162
- url.pathname = pathnameTransformed;
2163
- return url;
2164
- };
2165
- const ensurePathnameTrailingSlash = (url) => {
2166
- return transformUrlPathname(url, (pathname) => {
2167
- return pathname.endsWith("/") ? pathname : `${pathname}/`;
2168
- });
2169
- };
2170
-
2171
- const isFileSystemPath = (value) => {
2172
- if (typeof value !== "string") {
2173
- throw new TypeError(
2174
- `isFileSystemPath first arg must be a string, got ${value}`,
2175
- );
2176
- }
2177
- if (value[0] === "/") {
2178
- return true;
2179
- }
2180
- return startsWithWindowsDriveLetter(value);
2181
- };
2182
-
2183
- const startsWithWindowsDriveLetter = (string) => {
2184
- const firstChar = string[0];
2185
- if (!/[a-zA-Z]/.test(firstChar)) return false;
2186
-
2187
- const secondChar = string[1];
2188
- if (secondChar !== ":") return false;
2189
-
2190
- return true;
2191
- };
2192
-
2193
- const fileSystemPathToUrl = (value) => {
2194
- if (!isFileSystemPath(value)) {
2195
- throw new Error(`value must be a filesystem path, got ${value}`);
2196
- }
2197
- return String(pathToFileURL(value));
2198
- };
2199
-
2200
- const getCallerPosition = () => {
2201
- const { prepareStackTrace } = Error;
2202
- Error.prepareStackTrace = (error, stack) => {
2203
- Error.prepareStackTrace = prepareStackTrace;
2204
- return stack;
2205
- };
2206
- const { stack } = new Error();
2207
- const callerCallsite = stack[2];
2208
- const fileName = callerCallsite.getFileName();
2209
- return {
2210
- url:
2211
- fileName && isFileSystemPath(fileName)
2212
- ? fileSystemPathToUrl(fileName)
2213
- : fileName,
2214
- line: callerCallsite.getLineNumber(),
2215
- column: callerCallsite.getColumnNumber(),
2216
- };
2217
- };
2218
-
2219
- const resolveUrl$1 = (specifier, baseUrl) => {
2220
- if (typeof baseUrl === "undefined") {
2221
- throw new TypeError(`baseUrl missing to resolve ${specifier}`);
2222
- }
2223
- return String(new URL(specifier, baseUrl));
2224
- };
2225
-
2226
2244
  const getCommonPathname = (pathname, otherPathname) => {
2227
2245
  if (pathname === otherPathname) {
2228
2246
  return pathname;
@@ -2332,6 +2350,13 @@ const moveUrl = ({ url, from, to, preferRelative }) => {
2332
2350
  return absoluteUrl;
2333
2351
  };
2334
2352
 
2353
+ const resolveUrl$1 = (specifier, baseUrl) => {
2354
+ if (typeof baseUrl === "undefined") {
2355
+ throw new TypeError(`baseUrl missing to resolve ${specifier}`);
2356
+ }
2357
+ return String(new URL(specifier, baseUrl));
2358
+ };
2359
+
2335
2360
  const urlIsInsideOf = (url, otherUrl) => {
2336
2361
  const urlObject = new URL(url);
2337
2362
  const otherUrlObject = new URL(otherUrl);
@@ -2350,31 +2375,6 @@ const urlIsInsideOf = (url, otherUrl) => {
2350
2375
  return isInside;
2351
2376
  };
2352
2377
 
2353
- const urlToFileSystemPath = (url) => {
2354
- const urlObject = new URL(url);
2355
- let { origin, pathname, hash } = urlObject;
2356
- if (urlObject.protocol === "file:") {
2357
- origin = "file://";
2358
- }
2359
- pathname = pathname
2360
- .split("/")
2361
- .map((part) => {
2362
- return part.replace(/%(?![0-9A-F][0-9A-F])/g, "%25");
2363
- })
2364
- .join("/");
2365
- if (hash) {
2366
- pathname += `%23${encodeURIComponent(hash.slice(1))}`;
2367
- }
2368
- const urlString = `${origin}${pathname}`;
2369
- const fileSystemPath = fileURLToPath(urlString);
2370
- if (fileSystemPath[fileSystemPath.length - 1] === "/") {
2371
- // remove trailing / so that nodejs path becomes predictable otherwise it logs
2372
- // the trailing slash on linux but does not on windows
2373
- return fileSystemPath.slice(0, -1);
2374
- }
2375
- return fileSystemPath;
2376
- };
2377
-
2378
2378
  const validateDirectoryUrl = (value) => {
2379
2379
  let urlString;
2380
2380
 
@@ -7080,6 +7080,23 @@ const isResponseEligibleForIntegrityValidation = (response) => {
7080
7080
  return ["basic", "cors", "default"].includes(response.type);
7081
7081
  };
7082
7082
 
7083
+ const assertImportMap = (value) => {
7084
+ if (value === null) {
7085
+ throw new TypeError(`an importMap must be an object, got null`);
7086
+ }
7087
+
7088
+ const type = typeof value;
7089
+ if (type !== "object") {
7090
+ throw new TypeError(`an importMap must be an object, received ${value}`);
7091
+ }
7092
+
7093
+ if (Array.isArray(value)) {
7094
+ throw new TypeError(
7095
+ `an importMap must be an object, received array ${value}`,
7096
+ );
7097
+ }
7098
+ };
7099
+
7083
7100
  // duplicated from @jsenv/log to avoid the dependency
7084
7101
  const createDetailedMessage = (message, details = {}) => {
7085
7102
  let string = `${message}`;
@@ -7096,89 +7113,72 @@ const createDetailedMessage = (message, details = {}) => {
7096
7113
  }`;
7097
7114
  });
7098
7115
 
7099
- return string
7116
+ return string;
7100
7117
  };
7101
7118
 
7102
- const assertImportMap = (value) => {
7103
- if (value === null) {
7104
- throw new TypeError(`an importMap must be an object, got null`)
7105
- }
7106
-
7107
- const type = typeof value;
7108
- if (type !== "object") {
7109
- throw new TypeError(`an importMap must be an object, received ${value}`)
7110
- }
7119
+ const hasScheme = (string) => {
7120
+ return /^[a-zA-Z]{2,}:/.test(string);
7121
+ };
7111
7122
 
7112
- if (Array.isArray(value)) {
7113
- throw new TypeError(
7114
- `an importMap must be an object, received array ${value}`,
7115
- )
7123
+ const pathnameToParentPathname = (pathname) => {
7124
+ const slashLastIndex = pathname.lastIndexOf("/");
7125
+ if (slashLastIndex === -1) {
7126
+ return "/";
7116
7127
  }
7117
- };
7118
7128
 
7119
- const hasScheme = (string) => {
7120
- return /^[a-zA-Z]{2,}:/.test(string)
7129
+ return pathname.slice(0, slashLastIndex + 1);
7121
7130
  };
7122
7131
 
7123
7132
  const urlToScheme = (urlString) => {
7124
7133
  const colonIndex = urlString.indexOf(":");
7125
- if (colonIndex === -1) return ""
7126
- return urlString.slice(0, colonIndex)
7134
+ if (colonIndex === -1) return "";
7135
+ return urlString.slice(0, colonIndex);
7136
+ };
7137
+
7138
+ const urlToOrigin = (urlString) => {
7139
+ const scheme = urlToScheme(urlString);
7140
+
7141
+ if (scheme === "file") {
7142
+ return "file://";
7143
+ }
7144
+
7145
+ if (scheme === "http" || scheme === "https") {
7146
+ const secondProtocolSlashIndex = scheme.length + "://".length;
7147
+ const pathnameSlashIndex = urlString.indexOf("/", secondProtocolSlashIndex);
7148
+
7149
+ if (pathnameSlashIndex === -1) return urlString;
7150
+ return urlString.slice(0, pathnameSlashIndex);
7151
+ }
7152
+
7153
+ return urlString.slice(0, scheme.length + 1);
7127
7154
  };
7128
7155
 
7129
7156
  const urlToPathname = (urlString) => {
7130
- return ressourceToPathname(urlToRessource(urlString))
7157
+ return ressourceToPathname(urlToRessource(urlString));
7131
7158
  };
7132
7159
 
7133
7160
  const urlToRessource = (urlString) => {
7134
7161
  const scheme = urlToScheme(urlString);
7135
7162
 
7136
7163
  if (scheme === "file") {
7137
- return urlString.slice("file://".length)
7164
+ return urlString.slice("file://".length);
7138
7165
  }
7139
7166
 
7140
7167
  if (scheme === "https" || scheme === "http") {
7141
7168
  // remove origin
7142
7169
  const afterProtocol = urlString.slice(scheme.length + "://".length);
7143
7170
  const pathnameSlashIndex = afterProtocol.indexOf("/", "://".length);
7144
- return afterProtocol.slice(pathnameSlashIndex)
7171
+ return afterProtocol.slice(pathnameSlashIndex);
7145
7172
  }
7146
7173
 
7147
- return urlString.slice(scheme.length + 1)
7174
+ return urlString.slice(scheme.length + 1);
7148
7175
  };
7149
7176
 
7150
7177
  const ressourceToPathname = (ressource) => {
7151
7178
  const searchSeparatorIndex = ressource.indexOf("?");
7152
7179
  return searchSeparatorIndex === -1
7153
7180
  ? ressource
7154
- : ressource.slice(0, searchSeparatorIndex)
7155
- };
7156
-
7157
- const urlToOrigin = (urlString) => {
7158
- const scheme = urlToScheme(urlString);
7159
-
7160
- if (scheme === "file") {
7161
- return "file://"
7162
- }
7163
-
7164
- if (scheme === "http" || scheme === "https") {
7165
- const secondProtocolSlashIndex = scheme.length + "://".length;
7166
- const pathnameSlashIndex = urlString.indexOf("/", secondProtocolSlashIndex);
7167
-
7168
- if (pathnameSlashIndex === -1) return urlString
7169
- return urlString.slice(0, pathnameSlashIndex)
7170
- }
7171
-
7172
- return urlString.slice(0, scheme.length + 1)
7173
- };
7174
-
7175
- const pathnameToParentPathname = (pathname) => {
7176
- const slashLastIndex = pathname.lastIndexOf("/");
7177
- if (slashLastIndex === -1) {
7178
- return "/"
7179
- }
7180
-
7181
- return pathname.slice(0, slashLastIndex + 1)
7181
+ : ressource.slice(0, searchSeparatorIndex);
7182
7182
  };
7183
7183
 
7184
7184
  // could be useful: https://url.spec.whatwg.org/#url-miscellaneous
@@ -7187,29 +7187,29 @@ const pathnameToParentPathname = (pathname) => {
7187
7187
  const resolveUrl = (specifier, baseUrl) => {
7188
7188
  if (baseUrl) {
7189
7189
  if (typeof baseUrl !== "string") {
7190
- throw new TypeError(writeBaseUrlMustBeAString({ baseUrl, specifier }))
7190
+ throw new TypeError(writeBaseUrlMustBeAString({ baseUrl, specifier }));
7191
7191
  }
7192
7192
  if (!hasScheme(baseUrl)) {
7193
- throw new Error(writeBaseUrlMustBeAbsolute({ baseUrl, specifier }))
7193
+ throw new Error(writeBaseUrlMustBeAbsolute({ baseUrl, specifier }));
7194
7194
  }
7195
7195
  }
7196
7196
 
7197
7197
  if (hasScheme(specifier)) {
7198
- return specifier
7198
+ return specifier;
7199
7199
  }
7200
7200
 
7201
7201
  if (!baseUrl) {
7202
- throw new Error(writeBaseUrlRequired({ baseUrl, specifier }))
7202
+ throw new Error(writeBaseUrlRequired({ baseUrl, specifier }));
7203
7203
  }
7204
7204
 
7205
7205
  // scheme relative
7206
7206
  if (specifier.slice(0, 2) === "//") {
7207
- return `${urlToScheme(baseUrl)}:${specifier}`
7207
+ return `${urlToScheme(baseUrl)}:${specifier}`;
7208
7208
  }
7209
7209
 
7210
7210
  // origin relative
7211
7211
  if (specifier[0] === "/") {
7212
- return `${urlToOrigin(baseUrl)}${specifier}`
7212
+ return `${urlToOrigin(baseUrl)}${specifier}`;
7213
7213
  }
7214
7214
 
7215
7215
  const baseOrigin = urlToOrigin(baseUrl);
@@ -7217,13 +7217,13 @@ const resolveUrl = (specifier, baseUrl) => {
7217
7217
 
7218
7218
  if (specifier === ".") {
7219
7219
  const baseDirectoryPathname = pathnameToParentPathname(basePathname);
7220
- return `${baseOrigin}${baseDirectoryPathname}`
7220
+ return `${baseOrigin}${baseDirectoryPathname}`;
7221
7221
  }
7222
7222
 
7223
7223
  // pathname relative inside
7224
7224
  if (specifier.slice(0, 2) === "./") {
7225
7225
  const baseDirectoryPathname = pathnameToParentPathname(basePathname);
7226
- return `${baseOrigin}${baseDirectoryPathname}${specifier.slice(2)}`
7226
+ return `${baseOrigin}${baseDirectoryPathname}${specifier.slice(2)}`;
7227
7227
  }
7228
7228
 
7229
7229
  // pathname relative outside
@@ -7244,17 +7244,17 @@ const resolveUrl = (specifier, baseUrl) => {
7244
7244
  const resolvedPathname = `${importerFolders.join(
7245
7245
  "/",
7246
7246
  )}/${unresolvedPathname}`;
7247
- return `${baseOrigin}${resolvedPathname}`
7247
+ return `${baseOrigin}${resolvedPathname}`;
7248
7248
  }
7249
7249
 
7250
7250
  // bare
7251
7251
  if (basePathname === "") {
7252
- return `${baseOrigin}/${specifier}`
7252
+ return `${baseOrigin}/${specifier}`;
7253
7253
  }
7254
7254
  if (basePathname[basePathname.length] === "/") {
7255
- return `${baseOrigin}${basePathname}${specifier}`
7255
+ return `${baseOrigin}${basePathname}${specifier}`;
7256
7256
  }
7257
- return `${baseOrigin}${pathnameToParentPathname(basePathname)}${specifier}`
7257
+ return `${baseOrigin}${pathnameToParentPathname(basePathname)}${specifier}`;
7258
7258
  };
7259
7259
 
7260
7260
  const writeBaseUrlMustBeAString = ({
@@ -7286,7 +7286,7 @@ ${specifier}`;
7286
7286
 
7287
7287
  const tryUrlResolution = (string, url) => {
7288
7288
  const result = resolveUrl(string, url);
7289
- return hasScheme(result) ? result : null
7289
+ return hasScheme(result) ? result : null;
7290
7290
  };
7291
7291
 
7292
7292
  const resolveSpecifier = (specifier, importer) => {
@@ -7296,14 +7296,14 @@ const resolveSpecifier = (specifier, importer) => {
7296
7296
  specifier.startsWith("./") ||
7297
7297
  specifier.startsWith("../")
7298
7298
  ) {
7299
- return resolveUrl(specifier, importer)
7299
+ return resolveUrl(specifier, importer);
7300
7300
  }
7301
7301
 
7302
7302
  if (hasScheme(specifier)) {
7303
- return specifier
7303
+ return specifier;
7304
7304
  }
7305
7305
 
7306
- return null
7306
+ return null;
7307
7307
  };
7308
7308
 
7309
7309
  const applyImportMap = ({
@@ -7316,7 +7316,7 @@ const applyImportMap = ({
7316
7316
  specifier,
7317
7317
  importer,
7318
7318
  }),
7319
- )
7319
+ );
7320
7320
  },
7321
7321
  onImportMapping = () => {},
7322
7322
  }) => {
@@ -7327,7 +7327,7 @@ const applyImportMap = ({
7327
7327
  specifier,
7328
7328
  importer,
7329
7329
  }),
7330
- )
7330
+ );
7331
7331
  }
7332
7332
  if (importer) {
7333
7333
  if (typeof importer !== "string") {
@@ -7336,7 +7336,7 @@ const applyImportMap = ({
7336
7336
  importer,
7337
7337
  specifier,
7338
7338
  }),
7339
- )
7339
+ );
7340
7340
  }
7341
7341
  if (!hasScheme(importer)) {
7342
7342
  throw new Error(
@@ -7344,7 +7344,7 @@ const applyImportMap = ({
7344
7344
  importer,
7345
7345
  specifier,
7346
7346
  }),
7347
- )
7347
+ );
7348
7348
  }
7349
7349
  }
7350
7350
 
@@ -7358,7 +7358,7 @@ const applyImportMap = ({
7358
7358
  return (
7359
7359
  scopeSpecifier === importer ||
7360
7360
  specifierIsPrefixOf(scopeSpecifier, importer)
7361
- )
7361
+ );
7362
7362
  },
7363
7363
  );
7364
7364
  if (scopeSpecifierMatching) {
@@ -7370,7 +7370,7 @@ const applyImportMap = ({
7370
7370
  onImportMapping,
7371
7371
  );
7372
7372
  if (mappingFromScopes !== null) {
7373
- return mappingFromScopes
7373
+ return mappingFromScopes;
7374
7374
  }
7375
7375
  }
7376
7376
  }
@@ -7384,15 +7384,15 @@ const applyImportMap = ({
7384
7384
  onImportMapping,
7385
7385
  );
7386
7386
  if (mappingFromImports !== null) {
7387
- return mappingFromImports
7387
+ return mappingFromImports;
7388
7388
  }
7389
7389
  }
7390
7390
 
7391
7391
  if (specifierUrl) {
7392
- return specifierUrl
7392
+ return specifierUrl;
7393
7393
  }
7394
7394
 
7395
- throw createBareSpecifierError({ specifier, importer })
7395
+ throw createBareSpecifierError({ specifier, importer });
7396
7396
  };
7397
7397
 
7398
7398
  const applyMappings = (
@@ -7416,7 +7416,7 @@ const applyMappings = (
7416
7416
  before: specifierNormalized,
7417
7417
  after: address,
7418
7418
  });
7419
- return address
7419
+ return address;
7420
7420
  }
7421
7421
  if (specifierIsPrefixOf(specifierCandidate, specifierNormalized)) {
7422
7422
  const address = mappings[specifierCandidate];
@@ -7431,18 +7431,18 @@ const applyMappings = (
7431
7431
  before: specifierNormalized,
7432
7432
  after: addressFinal,
7433
7433
  });
7434
- return addressFinal
7434
+ return addressFinal;
7435
7435
  }
7436
7436
  }
7437
7437
 
7438
- return null
7438
+ return null;
7439
7439
  };
7440
7440
 
7441
7441
  const specifierIsPrefixOf = (specifierHref, href) => {
7442
7442
  return (
7443
7443
  specifierHref[specifierHref.length - 1] === "/" &&
7444
7444
  href.startsWith(specifierHref)
7445
- )
7445
+ );
7446
7446
  };
7447
7447
 
7448
7448
  // https://github.com/systemjs/systemjs/blob/89391f92dfeac33919b0223bbf834a1f4eea5750/src/common.js#L136
@@ -7481,7 +7481,7 @@ const composeTwoImportMaps = (leftImportMap, rightImportMap) => {
7481
7481
  importMap.scopes = { ...rightScopes };
7482
7482
  }
7483
7483
 
7484
- return importMap
7484
+ return importMap;
7485
7485
  };
7486
7486
 
7487
7487
  const composeTwoMappings = (leftMappings, rightMappings) => {
@@ -7490,11 +7490,11 @@ const composeTwoMappings = (leftMappings, rightMappings) => {
7490
7490
  Object.keys(leftMappings).forEach((leftSpecifier) => {
7491
7491
  if (objectHasKey(rightMappings, leftSpecifier)) {
7492
7492
  // will be overidden
7493
- return
7493
+ return;
7494
7494
  }
7495
7495
  const leftAddress = leftMappings[leftSpecifier];
7496
7496
  const rightSpecifier = Object.keys(rightMappings).find((rightSpecifier) => {
7497
- return compareAddressAndSpecifier(leftAddress, rightSpecifier)
7497
+ return compareAddressAndSpecifier(leftAddress, rightSpecifier);
7498
7498
  });
7499
7499
  mappings[leftSpecifier] = rightSpecifier
7500
7500
  ? rightMappings[rightSpecifier]
@@ -7505,7 +7505,7 @@ const composeTwoMappings = (leftMappings, rightMappings) => {
7505
7505
  mappings[rightSpecifier] = rightMappings[rightSpecifier];
7506
7506
  });
7507
7507
 
7508
- return mappings
7508
+ return mappings;
7509
7509
  };
7510
7510
 
7511
7511
  const objectHasKey = (object, key) =>
@@ -7514,7 +7514,7 @@ const objectHasKey = (object, key) =>
7514
7514
  const compareAddressAndSpecifier = (address, specifier) => {
7515
7515
  const addressUrl = resolveUrl(address, "file:///");
7516
7516
  const specifierUrl = resolveUrl(specifier, "file:///");
7517
- return addressUrl === specifierUrl
7517
+ return addressUrl === specifierUrl;
7518
7518
  };
7519
7519
 
7520
7520
  const composeTwoScopes = (leftScopes, rightScopes, imports) => {
@@ -7524,14 +7524,14 @@ const composeTwoScopes = (leftScopes, rightScopes, imports) => {
7524
7524
  if (objectHasKey(rightScopes, leftScopeKey)) {
7525
7525
  // will be merged
7526
7526
  scopes[leftScopeKey] = leftScopes[leftScopeKey];
7527
- return
7527
+ return;
7528
7528
  }
7529
7529
  const topLevelSpecifier = Object.keys(imports).find(
7530
7530
  (topLevelSpecifierCandidate) => {
7531
7531
  return compareAddressAndSpecifier(
7532
7532
  leftScopeKey,
7533
7533
  topLevelSpecifierCandidate,
7534
- )
7534
+ );
7535
7535
  },
7536
7536
  );
7537
7537
  if (topLevelSpecifier) {
@@ -7554,7 +7554,7 @@ const composeTwoScopes = (leftScopes, rightScopes, imports) => {
7554
7554
  }
7555
7555
  });
7556
7556
 
7557
- return scopes
7557
+ return scopes;
7558
7558
  };
7559
7559
 
7560
7560
  const sortImports = (imports) => {
@@ -7566,7 +7566,7 @@ const sortImports = (imports) => {
7566
7566
  mappingsSorted[name] = imports[name];
7567
7567
  });
7568
7568
 
7569
- return mappingsSorted
7569
+ return mappingsSorted;
7570
7570
  };
7571
7571
 
7572
7572
  const sortScopes = (scopes) => {
@@ -7578,18 +7578,18 @@ const sortScopes = (scopes) => {
7578
7578
  scopesSorted[scopeSpecifier] = sortImports(scopes[scopeSpecifier]);
7579
7579
  });
7580
7580
 
7581
- return scopesSorted
7581
+ return scopesSorted;
7582
7582
  };
7583
7583
 
7584
7584
  const compareLengthOrLocaleCompare = (a, b) => {
7585
- return b.length - a.length || a.localeCompare(b)
7585
+ return b.length - a.length || a.localeCompare(b);
7586
7586
  };
7587
7587
 
7588
7588
  const normalizeImportMap = (importMap, baseUrl) => {
7589
7589
  assertImportMap(importMap);
7590
7590
 
7591
7591
  if (!isStringOrUrl(baseUrl)) {
7592
- throw new TypeError(formulateBaseUrlMustBeStringOrUrl({ baseUrl }))
7592
+ throw new TypeError(formulateBaseUrlMustBeStringOrUrl({ baseUrl }));
7593
7593
  }
7594
7594
 
7595
7595
  const { imports, scopes } = importMap;
@@ -7597,19 +7597,19 @@ const normalizeImportMap = (importMap, baseUrl) => {
7597
7597
  return {
7598
7598
  imports: imports ? normalizeMappings(imports, baseUrl) : undefined,
7599
7599
  scopes: scopes ? normalizeScopes(scopes, baseUrl) : undefined,
7600
- }
7600
+ };
7601
7601
  };
7602
7602
 
7603
7603
  const isStringOrUrl = (value) => {
7604
7604
  if (typeof value === "string") {
7605
- return true
7605
+ return true;
7606
7606
  }
7607
7607
 
7608
7608
  if (typeof URL === "function" && value instanceof URL) {
7609
- return true
7609
+ return true;
7610
7610
  }
7611
7611
 
7612
- return false
7612
+ return false;
7613
7613
  };
7614
7614
 
7615
7615
  const normalizeMappings = (mappings, baseUrl) => {
@@ -7625,7 +7625,7 @@ const normalizeMappings = (mappings, baseUrl) => {
7625
7625
  specifier,
7626
7626
  }),
7627
7627
  );
7628
- return
7628
+ return;
7629
7629
  }
7630
7630
 
7631
7631
  const specifierResolved = resolveSpecifier(specifier, baseUrl) || specifier;
@@ -7639,7 +7639,7 @@ const normalizeMappings = (mappings, baseUrl) => {
7639
7639
  specifier,
7640
7640
  }),
7641
7641
  );
7642
- return
7642
+ return;
7643
7643
  }
7644
7644
 
7645
7645
  if (specifier.endsWith("/") && !addressUrl.endsWith("/")) {
@@ -7649,12 +7649,12 @@ const normalizeMappings = (mappings, baseUrl) => {
7649
7649
  specifier,
7650
7650
  }),
7651
7651
  );
7652
- return
7652
+ return;
7653
7653
  }
7654
7654
  mappingsNormalized[specifierResolved] = addressUrl;
7655
7655
  });
7656
7656
 
7657
- return sortImports(mappingsNormalized)
7657
+ return sortImports(mappingsNormalized);
7658
7658
  };
7659
7659
 
7660
7660
  const normalizeScopes = (scopes, baseUrl) => {
@@ -7670,13 +7670,13 @@ const normalizeScopes = (scopes, baseUrl) => {
7670
7670
  baseUrl,
7671
7671
  }),
7672
7672
  );
7673
- return
7673
+ return;
7674
7674
  }
7675
7675
  const scopeValueNormalized = normalizeMappings(scopeMappings, baseUrl);
7676
7676
  scopesNormalized[scopeUrl] = scopeValueNormalized;
7677
7677
  });
7678
7678
 
7679
- return sortScopes(scopesNormalized)
7679
+ return sortScopes(scopesNormalized);
7680
7680
  };
7681
7681
 
7682
7682
  const formulateBaseUrlMustBeStringOrUrl = ({
@@ -7734,9 +7734,9 @@ const pathnameToExtension = (pathname) => {
7734
7734
  }
7735
7735
 
7736
7736
  const dotLastIndex = pathname.lastIndexOf(".");
7737
- if (dotLastIndex === -1) return ""
7737
+ if (dotLastIndex === -1) return "";
7738
7738
  // if (dotLastIndex === pathname.length - 1) return ""
7739
- return pathname.slice(dotLastIndex)
7739
+ return pathname.slice(dotLastIndex);
7740
7740
  };
7741
7741
 
7742
7742
  const resolveImport = ({
@@ -7764,20 +7764,20 @@ const resolveImport = ({
7764
7764
  url = applyDefaultExtension({ url, importer, defaultExtension });
7765
7765
  }
7766
7766
 
7767
- return url
7767
+ return url;
7768
7768
  };
7769
7769
 
7770
7770
  const applyDefaultExtension = ({ url, importer, defaultExtension }) => {
7771
7771
  if (urlToPathname(url).endsWith("/")) {
7772
- return url
7772
+ return url;
7773
7773
  }
7774
7774
 
7775
7775
  if (typeof defaultExtension === "string") {
7776
7776
  const extension = pathnameToExtension(url);
7777
7777
  if (extension === "") {
7778
- return `${url}${defaultExtension}`
7778
+ return `${url}${defaultExtension}`;
7779
7779
  }
7780
- return url
7780
+ return url;
7781
7781
  }
7782
7782
 
7783
7783
  if (defaultExtension === true) {
@@ -7785,11 +7785,11 @@ const applyDefaultExtension = ({ url, importer, defaultExtension }) => {
7785
7785
  if (extension === "" && importer) {
7786
7786
  const importerPathname = urlToPathname(importer);
7787
7787
  const importerExtension = pathnameToExtension(importerPathname);
7788
- return `${url}${importerExtension}`
7788
+ return `${url}${importerExtension}`;
7789
7789
  }
7790
7790
  }
7791
7791
 
7792
- return url
7792
+ return url;
7793
7793
  };
7794
7794
 
7795
7795
  const isEscaped = (i, string) => {