vite 2.8.0-beta.4 → 2.8.0-beta.5

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.

Potentially problematic release.


This version of vite might be problematic. Click here for more details.

@@ -10,7 +10,7 @@ var require$$0$5 = require('url');
10
10
  var require$$1$3 = require('http');
11
11
  var require$$0$8 = require('stream');
12
12
  var require$$1 = require('os');
13
- var resolve$3 = require('resolve');
13
+ var resolve$4 = require('resolve');
14
14
  var require$$0$6 = require('module');
15
15
  var perf_hooks = require('perf_hooks');
16
16
  var require$$1$4 = require('https');
@@ -50,7 +50,7 @@ var require$$0__default$5 = /*#__PURE__*/_interopDefaultLegacy(require$$0$5);
50
50
  var require$$1__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$1$3);
51
51
  var require$$0__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$0$8);
52
52
  var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
53
- var resolve__default = /*#__PURE__*/_interopDefaultLegacy(resolve$3);
53
+ var resolve__default = /*#__PURE__*/_interopDefaultLegacy(resolve$4);
54
54
  var require$$0__default$4 = /*#__PURE__*/_interopDefaultLegacy(require$$0$6);
55
55
  var require$$1__default$4 = /*#__PURE__*/_interopDefaultLegacy(require$$1$4);
56
56
  var require$$0__default$6 = /*#__PURE__*/_interopDefaultLegacy(require$$0$7);
@@ -1222,10 +1222,10 @@ const KNOWN_ASSET_TYPES = [
1222
1222
  const DEFAULT_ASSETS_RE = new RegExp(`\\.(` + KNOWN_ASSET_TYPES.join('|') + `)(\\?.*)?$`);
1223
1223
  const DEP_VERSION_RE = /[\?&](v=[\w\.-]+)\b/;
1224
1224
 
1225
- var charToInteger$1 = {};
1226
- var chars$2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
1227
- for (var i$3 = 0; i$3 < chars$2.length; i$3++) {
1228
- charToInteger$1[chars$2.charCodeAt(i$3)] = i$3;
1225
+ var charToInteger = {};
1226
+ var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
1227
+ for (var i$2 = 0; i$2 < chars$1.length; i$2++) {
1228
+ charToInteger[chars$1.charCodeAt(i$2)] = i$2;
1229
1229
  }
1230
1230
  function decode(mappings) {
1231
1231
  var decoded = [];
@@ -1252,7 +1252,7 @@ function decode(mappings) {
1252
1252
  segment[0] = 0;
1253
1253
  }
1254
1254
  else {
1255
- var integer = charToInteger$1[c];
1255
+ var integer = charToInteger[c];
1256
1256
  if (integer === undefined) {
1257
1257
  throw new Error('Invalid character (' + String.fromCharCode(c) + ')');
1258
1258
  }
@@ -1293,7 +1293,7 @@ function segmentify(line, segment, j) {
1293
1293
  else if (j === 1)
1294
1294
  line.push([segment[0]]);
1295
1295
  }
1296
- function encode$1(decoded) {
1296
+ function encode(decoded) {
1297
1297
  var sourceFileIndex = 0; // second field
1298
1298
  var sourceCodeLine = 0; // third field
1299
1299
  var sourceCodeColumn = 0; // fourth field
@@ -1309,19 +1309,19 @@ function encode$1(decoded) {
1309
1309
  var lineMappings = [];
1310
1310
  for (var _i = 0, line_1 = line; _i < line_1.length; _i++) {
1311
1311
  var segment = line_1[_i];
1312
- var segmentMappings = encodeInteger$1(segment[0] - generatedCodeColumn);
1312
+ var segmentMappings = encodeInteger(segment[0] - generatedCodeColumn);
1313
1313
  generatedCodeColumn = segment[0];
1314
1314
  if (segment.length > 1) {
1315
1315
  segmentMappings +=
1316
- encodeInteger$1(segment[1] - sourceFileIndex) +
1317
- encodeInteger$1(segment[2] - sourceCodeLine) +
1318
- encodeInteger$1(segment[3] - sourceCodeColumn);
1316
+ encodeInteger(segment[1] - sourceFileIndex) +
1317
+ encodeInteger(segment[2] - sourceCodeLine) +
1318
+ encodeInteger(segment[3] - sourceCodeColumn);
1319
1319
  sourceFileIndex = segment[1];
1320
1320
  sourceCodeLine = segment[2];
1321
1321
  sourceCodeColumn = segment[3];
1322
1322
  }
1323
1323
  if (segment.length === 5) {
1324
- segmentMappings += encodeInteger$1(segment[4] - nameIndex);
1324
+ segmentMappings += encodeInteger(segment[4] - nameIndex);
1325
1325
  nameIndex = segment[4];
1326
1326
  }
1327
1327
  lineMappings.push(segmentMappings);
@@ -1330,7 +1330,7 @@ function encode$1(decoded) {
1330
1330
  }
1331
1331
  return mappings;
1332
1332
  }
1333
- function encodeInteger$1(num) {
1333
+ function encodeInteger(num) {
1334
1334
  var result = '';
1335
1335
  num = num < 0 ? (-num << 1) | 1 : num << 1;
1336
1336
  do {
@@ -1339,11 +1339,186 @@ function encodeInteger$1(num) {
1339
1339
  if (num > 0) {
1340
1340
  clamped |= 32;
1341
1341
  }
1342
- result += chars$2[clamped];
1342
+ result += chars$1[clamped];
1343
1343
  } while (num > 0);
1344
1344
  return result;
1345
1345
  }
1346
1346
 
1347
+ // Matches the scheme of a URL, eg "http://"
1348
+ const schemeRegex = /^[\w+.-]+:\/\//;
1349
+ /**
1350
+ * Matches the parts of a URL:
1351
+ * 1. Scheme, including ":", guaranteed.
1352
+ * 2. User/password, including "@", optional.
1353
+ * 3. Host, guaranteed.
1354
+ * 4. Port, including ":", optional.
1355
+ * 5. Path, including "/", optional.
1356
+ */
1357
+ const urlRegex = /^([\w+.-]+:)\/\/([^@]*@)?([^:/]*)(:\d+)?(\/[^#?]*)?/;
1358
+ function isAbsoluteUrl(input) {
1359
+ return schemeRegex.test(input);
1360
+ }
1361
+ function isSchemeRelativeUrl(input) {
1362
+ return input.startsWith('//');
1363
+ }
1364
+ function isAbsolutePath(input) {
1365
+ return input.startsWith('/');
1366
+ }
1367
+ function parseAbsoluteUrl(input) {
1368
+ const match = urlRegex.exec(input);
1369
+ return {
1370
+ scheme: match[1],
1371
+ user: match[2] || '',
1372
+ host: match[3],
1373
+ port: match[4] || '',
1374
+ path: match[5] || '/',
1375
+ relativePath: false,
1376
+ };
1377
+ }
1378
+ function parseUrl$2(input) {
1379
+ if (isSchemeRelativeUrl(input)) {
1380
+ const url = parseAbsoluteUrl('http:' + input);
1381
+ url.scheme = '';
1382
+ return url;
1383
+ }
1384
+ if (isAbsolutePath(input)) {
1385
+ const url = parseAbsoluteUrl('http://foo.com' + input);
1386
+ url.scheme = '';
1387
+ url.host = '';
1388
+ return url;
1389
+ }
1390
+ if (!isAbsoluteUrl(input)) {
1391
+ const url = parseAbsoluteUrl('http://foo.com/' + input);
1392
+ url.scheme = '';
1393
+ url.host = '';
1394
+ url.relativePath = true;
1395
+ return url;
1396
+ }
1397
+ return parseAbsoluteUrl(input);
1398
+ }
1399
+ function stripPathFilename(path) {
1400
+ // If a path ends with a parent directory "..", then it's a relative path with excess parent
1401
+ // paths. It's not a file, so we can't strip it.
1402
+ if (path.endsWith('/..'))
1403
+ return path;
1404
+ const index = path.lastIndexOf('/');
1405
+ return path.slice(0, index + 1);
1406
+ }
1407
+ function mergePaths(url, base) {
1408
+ // If we're not a relative path, then we're an absolute path, and it doesn't matter what base is.
1409
+ if (!url.relativePath)
1410
+ return;
1411
+ normalizePath$5(base);
1412
+ // If the path is just a "/", then it was an empty path to begin with (remember, we're a relative
1413
+ // path).
1414
+ if (url.path === '/') {
1415
+ url.path = base.path;
1416
+ }
1417
+ else {
1418
+ // Resolution happens relative to the base path's directory, not the file.
1419
+ url.path = stripPathFilename(base.path) + url.path;
1420
+ }
1421
+ // If the base path is absolute, then our path is now absolute too.
1422
+ url.relativePath = base.relativePath;
1423
+ }
1424
+ /**
1425
+ * The path can have empty directories "//", unneeded parents "foo/..", or current directory
1426
+ * "foo/.". We need to normalize to a standard representation.
1427
+ */
1428
+ function normalizePath$5(url) {
1429
+ const { relativePath } = url;
1430
+ const pieces = url.path.split('/');
1431
+ // We need to preserve the first piece always, so that we output a leading slash. The item at
1432
+ // pieces[0] is an empty string.
1433
+ let pointer = 1;
1434
+ // Positive is the number of real directories we've output, used for popping a parent directory.
1435
+ // Eg, "foo/bar/.." will have a positive 2, and we can decrement to be left with just "foo".
1436
+ let positive = 0;
1437
+ // We need to keep a trailing slash if we encounter an empty directory (eg, splitting "foo/" will
1438
+ // generate `["foo", ""]` pieces). And, if we pop a parent directory. But once we encounter a
1439
+ // real directory, we won't need to append, unless the other conditions happen again.
1440
+ let addTrailingSlash = false;
1441
+ for (let i = 1; i < pieces.length; i++) {
1442
+ const piece = pieces[i];
1443
+ // An empty directory, could be a trailing slash, or just a double "//" in the path.
1444
+ if (!piece) {
1445
+ addTrailingSlash = true;
1446
+ continue;
1447
+ }
1448
+ // If we encounter a real directory, then we don't need to append anymore.
1449
+ addTrailingSlash = false;
1450
+ // A current directory, which we can always drop.
1451
+ if (piece === '.')
1452
+ continue;
1453
+ // A parent directory, we need to see if there are any real directories we can pop. Else, we
1454
+ // have an excess of parents, and we'll need to keep the "..".
1455
+ if (piece === '..') {
1456
+ if (positive) {
1457
+ addTrailingSlash = true;
1458
+ positive--;
1459
+ pointer--;
1460
+ }
1461
+ else if (relativePath) {
1462
+ // If we're in a relativePath, then we need to keep the excess parents. Else, in an absolute
1463
+ // URL, protocol relative URL, or an absolute path, we don't need to keep excess.
1464
+ pieces[pointer++] = piece;
1465
+ }
1466
+ continue;
1467
+ }
1468
+ // We've encountered a real directory. Move it to the next insertion pointer, which accounts for
1469
+ // any popped or dropped directories.
1470
+ pieces[pointer++] = piece;
1471
+ positive++;
1472
+ }
1473
+ let path = '';
1474
+ for (let i = 1; i < pointer; i++) {
1475
+ path += '/' + pieces[i];
1476
+ }
1477
+ if (!path || (addTrailingSlash && !path.endsWith('/..'))) {
1478
+ path += '/';
1479
+ }
1480
+ url.path = path;
1481
+ }
1482
+ /**
1483
+ * Attempts to resolve `input` URL/path relative to `base`.
1484
+ */
1485
+ function resolve$3(input, base) {
1486
+ if (!input && !base)
1487
+ return '';
1488
+ const url = parseUrl$2(input);
1489
+ // If we have a base, and the input isn't already an absolute URL, then we need to merge.
1490
+ if (base && !url.scheme) {
1491
+ const baseUrl = parseUrl$2(base);
1492
+ url.scheme = baseUrl.scheme;
1493
+ // If there's no host, then we were just a path.
1494
+ if (!url.host || baseUrl.scheme === 'file:') {
1495
+ // The host, user, and port are joined, you can't copy one without the others.
1496
+ url.user = baseUrl.user;
1497
+ url.host = baseUrl.host;
1498
+ url.port = baseUrl.port;
1499
+ }
1500
+ mergePaths(url, baseUrl);
1501
+ }
1502
+ normalizePath$5(url);
1503
+ // If the input (and base, if there was one) are both relative, then we need to output a relative.
1504
+ if (url.relativePath) {
1505
+ // The first char is always a "/".
1506
+ const path = url.path.slice(1);
1507
+ if (!path)
1508
+ return '.';
1509
+ // If base started with a leading ".", or there is no base and input started with a ".", then we
1510
+ // need to ensure that the relative path starts with a ".". We don't know if relative starts
1511
+ // with a "..", though, so check before prepending.
1512
+ const keepRelative = (base || input).startsWith('.');
1513
+ return !keepRelative || path.startsWith('.') ? path : './' + path;
1514
+ }
1515
+ // If there's no host (and no scheme/user/port), then we need to output an absolute path.
1516
+ if (!url.scheme && !url.host)
1517
+ return url.path;
1518
+ // We're outputting either an absolute URL, or a protocol relative one.
1519
+ return `${url.scheme}//${url.user}${url.host}${url.port}${url.path}`;
1520
+ }
1521
+
1347
1522
  /**
1348
1523
  * Copyright 2019 The AMP HTML Authors. All Rights Reserved.
1349
1524
  *
@@ -1468,150 +1643,6 @@ class OriginalSource {
1468
1643
  }
1469
1644
  }
1470
1645
 
1471
- /* istanbul ignore next */
1472
- const Url$1 = (typeof URL !== 'undefined' ? URL : require('url').URL);
1473
- // Matches "..", which must be preceeded by "/" or the start of the string, and
1474
- // must be followed by a "/". We do not eat the following "/", so that the next
1475
- // iteration can match on it.
1476
- const parentRegex = /(^|\/)\.\.(?=\/|$)/g;
1477
- function isAbsoluteUrl(url) {
1478
- try {
1479
- return !!new Url$1(url);
1480
- }
1481
- catch (e) {
1482
- return false;
1483
- }
1484
- }
1485
- /**
1486
- * Creates a directory name that is guaranteed to not be in `str`.
1487
- */
1488
- function uniqInStr(str) {
1489
- let uniq = String(Math.random()).slice(2);
1490
- while (str.indexOf(uniq) > -1) {
1491
- /* istanbul ignore next */
1492
- uniq += uniq;
1493
- }
1494
- return uniq;
1495
- }
1496
- /**
1497
- * Removes the filename from the path (everything trailing the last "/"). This
1498
- * is only safe to call on a path, never call with an absolute or protocol
1499
- * relative URL.
1500
- */
1501
- function stripPathFilename(path) {
1502
- path = normalizePath$5(path);
1503
- const index = path.lastIndexOf('/');
1504
- return path.slice(0, index + 1);
1505
- }
1506
- /**
1507
- * Normalizes a protocol-relative URL, but keeps it protocol relative by
1508
- * stripping out the protocl before returning it.
1509
- */
1510
- function normalizeProtocolRelative(input, absoluteBase) {
1511
- const { href, protocol } = new Url$1(input, absoluteBase);
1512
- return href.slice(protocol.length);
1513
- }
1514
- /**
1515
- * Normalizes a simple path (one that has no ".."s, or is absolute so ".."s can
1516
- * be normalized absolutely).
1517
- */
1518
- function normalizeSimplePath(input) {
1519
- const { href } = new Url$1(input, 'https://foo.com/');
1520
- return href.slice('https://foo.com/'.length);
1521
- }
1522
- /**
1523
- * Normalizes a path, ensuring that excess ".."s are preserved for relative
1524
- * paths in the output.
1525
- *
1526
- * If the input is absolute, this will return an absolutey normalized path, but
1527
- * it will not have a leading "/".
1528
- *
1529
- * If the input has a leading "..", the output will have a leading "..".
1530
- *
1531
- * If the input has a leading ".", the output will not have a leading "."
1532
- * unless there are too many ".."s, in which case there will be a leading "..".
1533
- */
1534
- function normalizePath$5(input) {
1535
- // If there are no ".."s, we can treat this as if it were an absolute path.
1536
- // The return won't be an absolute path, so it's easy.
1537
- if (!parentRegex.test(input))
1538
- return normalizeSimplePath(input);
1539
- // We already found one "..". Let's see how many there are.
1540
- let total = 1;
1541
- while (parentRegex.test(input))
1542
- total++;
1543
- // If there are ".."s, we need to prefix the the path with the same number of
1544
- // unique directories. This is to ensure that we "remember" how many parent
1545
- // directories we are accessing. Eg, "../../.." must keep 3, and "foo/../.."
1546
- // must keep 1.
1547
- const uniqDirectory = `z${uniqInStr(input)}/`;
1548
- // uniqDirectory is just a "z", followed by numbers, followed by a "/". So
1549
- // generating a runtime regex from it is safe. We'll use this search regex to
1550
- // strip out our uniq directory names and insert any needed ".."s.
1551
- const search = new RegExp(`^(?:${uniqDirectory})*`);
1552
- // Now we can resolve the total path. If there are excess ".."s, they will
1553
- // eliminate one or more of the unique directories we prefix with.
1554
- const relative = normalizeSimplePath(uniqDirectory.repeat(total) + input);
1555
- // We can now count the number of unique directories that were eliminated. If
1556
- // there were 3, and 1 was eliminated, we know we only need to add 1 "..". If
1557
- // 2 were eliminated, we need to insert 2 ".."s. If all 3 were eliminated,
1558
- // then we need 3, etc. This replace is guranteed to match (it may match 0 or
1559
- // more times), and we can count the total match to see how many were eliminated.
1560
- return relative.replace(search, (all) => {
1561
- const leftover = all.length / uniqDirectory.length;
1562
- return '../'.repeat(total - leftover);
1563
- });
1564
- }
1565
- /**
1566
- * Attempts to resolve `input` URL relative to `base`.
1567
- */
1568
- function resolve$2(input, base) {
1569
- if (!base)
1570
- base = '';
1571
- // Absolute URLs are very easy to resolve right.
1572
- if (isAbsoluteUrl(input))
1573
- return new Url$1(input).href;
1574
- if (base) {
1575
- // Absolute URLs are easy...
1576
- if (isAbsoluteUrl(base))
1577
- return new Url$1(input, base).href;
1578
- // If base is protocol relative, we'll resolve with it but keep the result
1579
- // protocol relative.
1580
- if (base.startsWith('//'))
1581
- return normalizeProtocolRelative(input, `https:${base}`);
1582
- }
1583
- // Normalize input, but keep it protocol relative. We know base doesn't supply
1584
- // a protocol, because that would have been handled above.
1585
- if (input.startsWith('//'))
1586
- return normalizeProtocolRelative(input, 'https://foo.com/');
1587
- // We now know that base (if there is one) and input are paths. We've handled
1588
- // both absolute and protocol-relative variations above.
1589
- // Absolute paths don't need any special handling, because they cannot have
1590
- // extra "." or ".."s. That'll all be stripped away. Input takes priority here,
1591
- // because if input is an absolute path, base path won't affect it in any way.
1592
- if (input.startsWith('/'))
1593
- return '/' + normalizeSimplePath(input);
1594
- // Since input and base are paths, we need to join them to do any further
1595
- // processing. Paths are joined at the directory level, so we need to remove
1596
- // the base's filename before joining. We also know that input does not have a
1597
- // leading slash, and that the stripped base will have a trailing slash if
1598
- // there are any directories (or it'll be empty).
1599
- const joined = stripPathFilename(base) + input;
1600
- // If base is an absolute path, then input will be relative to it.
1601
- if (base.startsWith('/'))
1602
- return '/' + normalizeSimplePath(joined);
1603
- // We now know both base (if there is one) and input are relative paths.
1604
- const relative = normalizePath$5(joined);
1605
- // If base started with a leading ".", or there is no base and input started
1606
- // with a ".", then we need to ensure that the relative path starts with a
1607
- // ".". We don't know if relative starts with a "..", though, so check before
1608
- // prepending.
1609
- if ((base || input).startsWith('.') && !relative.startsWith('.')) {
1610
- return './' + relative;
1611
- }
1612
- return relative;
1613
- }
1614
-
1615
1646
  /**
1616
1647
  * Copyright 2019 The AMP HTML Authors. All Rights Reserved.
1617
1648
  *
@@ -1627,13 +1658,13 @@ function resolve$2(input, base) {
1627
1658
  * See the License for the specific language governing permissions and
1628
1659
  * limitations under the License.
1629
1660
  */
1630
- function resolve$1$1(input, base) {
1661
+ function resolve$2(input, base) {
1631
1662
  // The base is always treated as a directory, if it's not empty.
1632
1663
  // https://github.com/mozilla/source-map/blob/8cb3ee57/lib/util.js#L327
1633
1664
  // https://github.com/chromium/chromium/blob/da4adbb3/third_party/blink/renderer/devtools/front_end/sdk/SourceMap.js#L400-L401
1634
1665
  if (base && !base.endsWith('/'))
1635
1666
  base += '/';
1636
- return resolve$2(input, base);
1667
+ return resolve$3(input, base);
1637
1668
  }
1638
1669
 
1639
1670
  /**
@@ -1952,7 +1983,7 @@ function buildSourceMapTree(input, loader, relativeRoot) {
1952
1983
  const children = sources.map((sourceFile, i) => {
1953
1984
  // Each source file is loaded relative to the sourcemap's own sourceRoot,
1954
1985
  // which is itself relative to the sourcemap's parent.
1955
- const uri = resolve$1$1(sourceFile || '', resolve$1$1(sourceRoot || '', stripFilename(relativeRoot)));
1986
+ const uri = resolve$2(sourceFile || '', resolve$2(sourceRoot || '', stripFilename(relativeRoot)));
1956
1987
  // Use the provided loader callback to retrieve the file's sourcemap.
1957
1988
  // TODO: We should eventually support async loading of sourcemap files.
1958
1989
  const sourceMap = loader(uri);
@@ -1999,7 +2030,7 @@ class SourceMap$1 {
1999
2030
  this.version = 3; // SourceMap spec says this should be first.
2000
2031
  if ('file' in map)
2001
2032
  this.file = map.file;
2002
- this.mappings = options.decodedMappings ? map.mappings : encode$1(map.mappings);
2033
+ this.mappings = options.decodedMappings ? map.mappings : encode(map.mappings);
2003
2034
  this.names = map.names;
2004
2035
  // TODO: We first need to make all source URIs relative to the sourceRoot
2005
2036
  // before we can support a sourceRoot.
@@ -2059,7 +2090,7 @@ function unwrapId$1(id) {
2059
2090
  return id.startsWith(VALID_ID_PREFIX) ? id.slice(VALID_ID_PREFIX.length) : id;
2060
2091
  }
2061
2092
  const flattenId = (id) => id.replace(/(\s*>\s*)/g, '__').replace(/[\/\.]/g, '_');
2062
- const normalizeId$1 = (id) => id.replace(/(\s*>\s*)/g, ' > ');
2093
+ const normalizeId = (id) => id.replace(/(\s*>\s*)/g, ' > ');
2063
2094
  //TODO: revisit later to see if the edge case that "compiling using node v12 code to be run in node v16 in the server" is what we intend to support.
2064
2095
  const builtins$2 = new Set([
2065
2096
  ...require$$0$6.builtinModules,
@@ -2827,62 +2858,6 @@ function throttle(fn) {
2827
2858
  };
2828
2859
  }
2829
2860
 
2830
- var charToInteger = {};
2831
- var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
2832
- for (var i$2 = 0; i$2 < chars$1.length; i$2++) {
2833
- charToInteger[chars$1.charCodeAt(i$2)] = i$2;
2834
- }
2835
- function encode(decoded) {
2836
- var sourceFileIndex = 0; // second field
2837
- var sourceCodeLine = 0; // third field
2838
- var sourceCodeColumn = 0; // fourth field
2839
- var nameIndex = 0; // fifth field
2840
- var mappings = '';
2841
- for (var i = 0; i < decoded.length; i++) {
2842
- var line = decoded[i];
2843
- if (i > 0)
2844
- mappings += ';';
2845
- if (line.length === 0)
2846
- continue;
2847
- var generatedCodeColumn = 0; // first field
2848
- var lineMappings = [];
2849
- for (var _i = 0, line_1 = line; _i < line_1.length; _i++) {
2850
- var segment = line_1[_i];
2851
- var segmentMappings = encodeInteger(segment[0] - generatedCodeColumn);
2852
- generatedCodeColumn = segment[0];
2853
- if (segment.length > 1) {
2854
- segmentMappings +=
2855
- encodeInteger(segment[1] - sourceFileIndex) +
2856
- encodeInteger(segment[2] - sourceCodeLine) +
2857
- encodeInteger(segment[3] - sourceCodeColumn);
2858
- sourceFileIndex = segment[1];
2859
- sourceCodeLine = segment[2];
2860
- sourceCodeColumn = segment[3];
2861
- }
2862
- if (segment.length === 5) {
2863
- segmentMappings += encodeInteger(segment[4] - nameIndex);
2864
- nameIndex = segment[4];
2865
- }
2866
- lineMappings.push(segmentMappings);
2867
- }
2868
- mappings += lineMappings.join(',');
2869
- }
2870
- return mappings;
2871
- }
2872
- function encodeInteger(num) {
2873
- var result = '';
2874
- num = num < 0 ? (-num << 1) | 1 : num << 1;
2875
- do {
2876
- var clamped = num & 31;
2877
- num >>>= 5;
2878
- if (num > 0) {
2879
- clamped |= 32;
2880
- }
2881
- result += chars$1[clamped];
2882
- } while (num > 0);
2883
- return result;
2884
- }
2885
-
2886
2861
  var BitSet = function BitSet(arg) {
2887
2862
  this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
2888
2863
  };
@@ -5363,7 +5338,7 @@ const toRegexRange = toRegexRange_1;
5363
5338
 
5364
5339
  const isObject$1 = val => val !== null && typeof val === 'object' && !Array.isArray(val);
5365
5340
 
5366
- const transform = toNumber => {
5341
+ const transform$1 = toNumber => {
5367
5342
  return value => toNumber === true ? Number(value) : String(value);
5368
5343
  };
5369
5344
 
@@ -5500,7 +5475,7 @@ const fillNumbers = (start, end, step = 1, options = {}) => {
5500
5475
  let padded = zeros(startString) || zeros(endString) || zeros(stepString);
5501
5476
  let maxLen = padded ? Math.max(startString.length, endString.length, stepString.length) : 0;
5502
5477
  let toNumber = padded === false && stringify$7(start, end, options) === false;
5503
- let format = options.transform || transform(toNumber);
5478
+ let format = options.transform || transform$1(toNumber);
5504
5479
 
5505
5480
  if (options.toRegex && step === 1) {
5506
5481
  return toRange(toMaxLen(start, maxLen), toMaxLen(end, maxLen), true, options);
@@ -5685,7 +5660,7 @@ const append$1 = (queue = '', stash = '', enclose = false) => {
5685
5660
  return utils$g.flatten(result);
5686
5661
  };
5687
5662
 
5688
- const expand$3 = (ast, options = {}) => {
5663
+ const expand$4 = (ast, options = {}) => {
5689
5664
  let rangeLimit = options.rangeLimit === void 0 ? 1000 : options.rangeLimit;
5690
5665
 
5691
5666
  let walk = (node, parent = {}) => {
@@ -5765,7 +5740,7 @@ const expand$3 = (ast, options = {}) => {
5765
5740
  return utils$g.flatten(walk(ast));
5766
5741
  };
5767
5742
 
5768
- var expand_1 = expand$3;
5743
+ var expand_1$1 = expand$4;
5769
5744
 
5770
5745
  var constants$6 = {
5771
5746
  MAX_LENGTH: 1024 * 64,
@@ -6154,7 +6129,7 @@ var parse_1$2 = parse$m;
6154
6129
 
6155
6130
  const stringify$4 = stringify$8;
6156
6131
  const compile = compile_1;
6157
- const expand$2 = expand_1;
6132
+ const expand$3 = expand_1$1;
6158
6133
  const parse$l = parse_1$2;
6159
6134
 
6160
6135
  /**
@@ -6274,7 +6249,7 @@ braces$2.expand = (input, options = {}) => {
6274
6249
  input = braces$2.parse(input, options);
6275
6250
  }
6276
6251
 
6277
- let result = expand$2(input, options);
6252
+ let result = expand$3(input, options);
6278
6253
 
6279
6254
  // filter out empty strings if specified
6280
6255
  if (options.noempty === true) {
@@ -8850,10 +8825,10 @@ const micromatch = micromatch_1;
8850
8825
  const GLOBSTAR$2 = '**';
8851
8826
  const ESCAPE_SYMBOL = '\\';
8852
8827
  const COMMON_GLOB_SYMBOLS_RE = /[*?]|^!/;
8853
- const REGEX_CHARACTER_CLASS_SYMBOLS_RE = /\[.*]/;
8854
- const REGEX_GROUP_SYMBOLS_RE = /(?:^|[^!*+?@])\(.*\|.*\)/;
8855
- const GLOB_EXTENSION_SYMBOLS_RE = /[!*+?@]\(.*\)/;
8856
- const BRACE_EXPANSIONS_SYMBOLS_RE = /{.*(?:,|\.\.).*}/;
8828
+ const REGEX_CHARACTER_CLASS_SYMBOLS_RE = /\[[^[]*]/;
8829
+ const REGEX_GROUP_SYMBOLS_RE = /(?:^|[^!*+?@])\([^(]*\|[^|]*\)/;
8830
+ const GLOB_EXTENSION_SYMBOLS_RE = /[!*+?@]\([^(]*\)/;
8831
+ const BRACE_EXPANSION_SEPARATORS_RE = /,|\.\./;
8857
8832
  function isStaticPattern(pattern, options = {}) {
8858
8833
  return !isDynamicPattern(pattern, options);
8859
8834
  }
@@ -8880,12 +8855,24 @@ function isDynamicPattern(pattern, options = {}) {
8880
8855
  if (options.extglob !== false && GLOB_EXTENSION_SYMBOLS_RE.test(pattern)) {
8881
8856
  return true;
8882
8857
  }
8883
- if (options.braceExpansion !== false && BRACE_EXPANSIONS_SYMBOLS_RE.test(pattern)) {
8858
+ if (options.braceExpansion !== false && hasBraceExpansion(pattern)) {
8884
8859
  return true;
8885
8860
  }
8886
8861
  return false;
8887
8862
  }
8888
8863
  pattern$1.isDynamicPattern = isDynamicPattern;
8864
+ function hasBraceExpansion(pattern) {
8865
+ const openingBraceIndex = pattern.indexOf('{');
8866
+ if (openingBraceIndex === -1) {
8867
+ return false;
8868
+ }
8869
+ const closingBraceIndex = pattern.indexOf('}', openingBraceIndex + 1);
8870
+ if (closingBraceIndex === -1) {
8871
+ return false;
8872
+ }
8873
+ const braceContent = pattern.slice(openingBraceIndex, closingBraceIndex);
8874
+ return BRACE_EXPANSION_SEPARATORS_RE.test(braceContent);
8875
+ }
8889
8876
  function convertToPositivePattern(pattern) {
8890
8877
  return isNegativePattern(pattern) ? pattern.slice(1) : pattern;
8891
8878
  }
@@ -9272,6 +9259,29 @@ function convertPatternGroupToTask(base, positive, negative, dynamic) {
9272
9259
  }
9273
9260
  tasks.convertPatternGroupToTask = convertPatternGroupToTask;
9274
9261
 
9262
+ var patterns = {};
9263
+
9264
+ Object.defineProperty(patterns, "__esModule", { value: true });
9265
+ patterns.removeDuplicateSlashes = patterns.transform = void 0;
9266
+ /**
9267
+ * Matches a sequence of two or more consecutive slashes, excluding the first two slashes at the beginning of the string.
9268
+ * The latter is due to the presence of the device path at the beginning of the UNC path.
9269
+ * @todo rewrite to negative lookbehind with the next major release.
9270
+ */
9271
+ const DOUBLE_SLASH_RE$1 = /(?!^)\/{2,}/g;
9272
+ function transform(patterns) {
9273
+ return patterns.map((pattern) => removeDuplicateSlashes(pattern));
9274
+ }
9275
+ patterns.transform = transform;
9276
+ /**
9277
+ * This package only works with forward slashes as a path separator.
9278
+ * Because of this, we cannot use the standard `path.normalize` method, because on Windows platform it will use of backslashes.
9279
+ */
9280
+ function removeDuplicateSlashes(pattern) {
9281
+ return pattern.replace(DOUBLE_SLASH_RE$1, '/');
9282
+ }
9283
+ patterns.removeDuplicateSlashes = removeDuplicateSlashes;
9284
+
9275
9285
  var async$6 = {};
9276
9286
 
9277
9287
  var stream$2 = {};
@@ -9834,8 +9844,8 @@ function fastqueue (context, worker, concurrency) {
9834
9844
 
9835
9845
  var self = {
9836
9846
  push: push,
9837
- drain: noop$3,
9838
- saturated: noop$3,
9847
+ drain: noop$2,
9848
+ saturated: noop$2,
9839
9849
  pause: pause,
9840
9850
  paused: false,
9841
9851
  concurrency: concurrency,
@@ -9845,7 +9855,7 @@ function fastqueue (context, worker, concurrency) {
9845
9855
  length: length,
9846
9856
  getQueue: getQueue,
9847
9857
  unshift: unshift,
9848
- empty: noop$3,
9858
+ empty: noop$2,
9849
9859
  kill: kill,
9850
9860
  killAndDrain: killAndDrain,
9851
9861
  error: error
@@ -9904,7 +9914,7 @@ function fastqueue (context, worker, concurrency) {
9904
9914
  current.context = context;
9905
9915
  current.release = release;
9906
9916
  current.value = value;
9907
- current.callback = done || noop$3;
9917
+ current.callback = done || noop$2;
9908
9918
  current.errorHandler = errorHandler;
9909
9919
 
9910
9920
  if (_running === self.concurrency || self.paused) {
@@ -9928,7 +9938,7 @@ function fastqueue (context, worker, concurrency) {
9928
9938
  current.context = context;
9929
9939
  current.release = release;
9930
9940
  current.value = value;
9931
- current.callback = done || noop$3;
9941
+ current.callback = done || noop$2;
9932
9942
 
9933
9943
  if (_running === self.concurrency || self.paused) {
9934
9944
  if (queueHead) {
@@ -9972,14 +9982,14 @@ function fastqueue (context, worker, concurrency) {
9972
9982
  function kill () {
9973
9983
  queueHead = null;
9974
9984
  queueTail = null;
9975
- self.drain = noop$3;
9985
+ self.drain = noop$2;
9976
9986
  }
9977
9987
 
9978
9988
  function killAndDrain () {
9979
9989
  queueHead = null;
9980
9990
  queueTail = null;
9981
9991
  self.drain();
9982
- self.drain = noop$3;
9992
+ self.drain = noop$2;
9983
9993
  }
9984
9994
 
9985
9995
  function error (handler) {
@@ -9987,13 +9997,13 @@ function fastqueue (context, worker, concurrency) {
9987
9997
  }
9988
9998
  }
9989
9999
 
9990
- function noop$3 () {}
10000
+ function noop$2 () {}
9991
10001
 
9992
10002
  function Task () {
9993
10003
  this.value = null;
9994
- this.callback = noop$3;
10004
+ this.callback = noop$2;
9995
10005
  this.next = null;
9996
- this.release = noop$3;
10006
+ this.release = noop$2;
9997
10007
  this.context = null;
9998
10008
  this.errorHandler = null;
9999
10009
 
@@ -10004,7 +10014,7 @@ function Task () {
10004
10014
  var errorHandler = self.errorHandler;
10005
10015
  var val = self.value;
10006
10016
  self.value = null;
10007
- self.callback = noop$3;
10017
+ self.callback = noop$2;
10008
10018
  if (self.errorHandler) {
10009
10019
  errorHandler(err, val);
10010
10020
  }
@@ -10052,7 +10062,7 @@ function queueAsPromised (context, worker, concurrency) {
10052
10062
  // Let's fork the promise chain to
10053
10063
  // make the error bubble up to the user but
10054
10064
  // not lead to a unhandledRejection
10055
- p.catch(noop$3);
10065
+ p.catch(noop$2);
10056
10066
 
10057
10067
  return p
10058
10068
  }
@@ -10071,7 +10081,7 @@ function queueAsPromised (context, worker, concurrency) {
10071
10081
  // Let's fork the promise chain to
10072
10082
  // make the error bubble up to the user but
10073
10083
  // not lead to a unhandledRejection
10074
- p.catch(noop$3);
10084
+ p.catch(noop$2);
10075
10085
 
10076
10086
  return p
10077
10087
  }
@@ -10740,9 +10750,13 @@ class EntryFilter {
10740
10750
  const fullpath = utils$3.path.makeAbsolute(this._settings.cwd, entryPath);
10741
10751
  return utils$3.pattern.matchAny(fullpath, patternsRe);
10742
10752
  }
10753
+ /**
10754
+ * First, just trying to apply patterns to the path.
10755
+ * Second, trying to apply patterns to the path with final slash.
10756
+ */
10743
10757
  _isMatchToPatterns(entryPath, patternsRe) {
10744
10758
  const filepath = utils$3.path.removeLeadingDotSegment(entryPath);
10745
- return utils$3.pattern.matchAny(filepath, patternsRe);
10759
+ return utils$3.pattern.matchAny(filepath, patternsRe) || utils$3.pattern.matchAny(filepath + '/', patternsRe);
10746
10760
  }
10747
10761
  }
10748
10762
  entry$1.default = EntryFilter;
@@ -11033,6 +11047,7 @@ exports.default = Settings;
11033
11047
  }(settings));
11034
11048
 
11035
11049
  const taskManager = tasks;
11050
+ const patternManager = patterns;
11036
11051
  const async_1 = async$6;
11037
11052
  const stream_1 = stream;
11038
11053
  const sync_1 = sync$5;
@@ -11066,7 +11081,7 @@ async function FastGlob(source, options) {
11066
11081
  FastGlob.stream = stream;
11067
11082
  function generateTasks(source, options) {
11068
11083
  assertPatternsInput(source);
11069
- const patterns = [].concat(source);
11084
+ const patterns = patternManager.transform([].concat(source));
11070
11085
  const settings = new settings_1.default(options);
11071
11086
  return taskManager.generate(patterns, settings);
11072
11087
  }
@@ -11084,7 +11099,7 @@ async function FastGlob(source, options) {
11084
11099
  FastGlob.escapePath = escapePath;
11085
11100
  })(FastGlob || (FastGlob = {}));
11086
11101
  function getWorks(source, _Provider, options) {
11087
- const patterns = [].concat(source);
11102
+ const patterns = patternManager.transform([].concat(source));
11088
11103
  const settings = new settings_1.default(options);
11089
11104
  const tasks = taskManager.generate(patterns, settings);
11090
11105
  const provider = new _Provider(settings);
@@ -18857,7 +18872,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
18857
18872
  replacer: urlReplacer
18858
18873
  }));
18859
18874
  if (isModule) {
18860
- postcssPlugins.unshift((await Promise.resolve().then(function () { return require('./dep-4ef300ce.js'); }).then(function (n) { return n.index; })).default({
18875
+ postcssPlugins.unshift((await Promise.resolve().then(function () { return require('./dep-ae5bfd1c.js'); }).then(function (n) { return n.index; })).default({
18861
18876
  ...modulesOptions,
18862
18877
  getJSON(cssFileName, _modules, outputFileName) {
18863
18878
  modules = _modules;
@@ -21280,7 +21295,7 @@ const assetAttrsConfig = {
21280
21295
  const isAsyncScriptMap = new WeakMap();
21281
21296
  async function traverseHtml(html, filePath, visitor) {
21282
21297
  // lazy load compiler
21283
- const { parse, transform } = await Promise.resolve().then(function () { return require('./dep-2451c479.js'); }).then(function (n) { return n.compilerDom_cjs; });
21298
+ const { parse, transform } = await Promise.resolve().then(function () { return require('./dep-ba706304.js'); }).then(function (n) { return n.compilerDom_cjs; });
21284
21299
  // @vue/compiler-core doesn't like lowercase doctypes
21285
21300
  html = html.replace(/<!doctype\s/i, '<!DOCTYPE ');
21286
21301
  try {
@@ -21348,30 +21363,11 @@ function buildHtmlPlugin(config) {
21348
21363
  checkPublicFile(url, config);
21349
21364
  // Same reason with `htmlInlineProxyPlugin`
21350
21365
  isAsyncScriptMap.set(config, new Map());
21351
- const inputFiles = new Set();
21352
21366
  return {
21353
21367
  name: 'vite:build-html',
21354
- buildStart({ input }) {
21355
- isAsyncScriptMap.set(config, new Map());
21356
- let allInputs;
21357
- if (typeof input === 'string') {
21358
- allInputs = [input];
21359
- }
21360
- else if (Array.isArray(input)) {
21361
- allInputs = input;
21362
- }
21363
- else {
21364
- allInputs = Object.values(input);
21365
- }
21366
- for (const filename of allInputs) {
21367
- if (filename.endsWith('.html')) {
21368
- inputFiles.add(normalizePath$4(filename));
21369
- }
21370
- }
21371
- },
21372
21368
  async transform(html, id) {
21373
21369
  var _a, _b;
21374
- if (inputFiles.has(id)) {
21370
+ if (id.endsWith('.html')) {
21375
21371
  const publicPath = `/${slash$1(path__default.relative(config.root, id))}`;
21376
21372
  // pre-transform
21377
21373
  html = await applyHtmlTransforms(html, preHooks, {
@@ -22018,14 +22014,13 @@ function stripBom(string) {
22018
22014
  }
22019
22015
  var POSIX_SEP_RE = new RegExp("\\" + path__default.posix.sep, "g");
22020
22016
  var NATIVE_SEP_RE = new RegExp("\\" + path__default.sep, "g");
22021
- var PATTERN_REGEX_CACHE = new Map();
22017
+ var PATTERN_REGEX_CACHE = /* @__PURE__ */ new Map();
22022
22018
  var GLOB_ALL_PATTERN = `**/*`;
22023
22019
  var DEFAULT_EXTENSIONS = [".ts", ".tsx", ".mts", ".cts"];
22024
22020
  var DEFAULT_EXTENSIONS_RE_GROUP = `\\.(?:${DEFAULT_EXTENSIONS.map((ext) => ext.substring(1)).join("|")})`;
22025
22021
  new Function("path", "return import(path).then(m => m.default)");
22026
22022
  async function resolveTSConfig(filename) {
22027
- const basename = path__default.basename(filename);
22028
- if (basename !== "tsconfig.json") {
22023
+ if (path__default.extname(filename) !== ".json") {
22029
22024
  return;
22030
22025
  }
22031
22026
  const tsconfig = path__default.resolve(filename);
@@ -23687,7 +23682,7 @@ function expandTop(str) {
23687
23682
  str = '\\{\\}' + str.substr(2);
23688
23683
  }
23689
23684
 
23690
- return expand$1(escapeBraces(str), true).map(unescapeBraces);
23685
+ return expand$2(escapeBraces(str), true).map(unescapeBraces);
23691
23686
  }
23692
23687
 
23693
23688
  function embrace(str) {
@@ -23704,7 +23699,7 @@ function gte(i, y) {
23704
23699
  return i >= y;
23705
23700
  }
23706
23701
 
23707
- function expand$1(str, isTop) {
23702
+ function expand$2(str, isTop) {
23708
23703
  var expansions = [];
23709
23704
 
23710
23705
  var m = balanced('{', '}', str);
@@ -23718,7 +23713,7 @@ function expand$1(str, isTop) {
23718
23713
  // {a},b}
23719
23714
  if (m.post.match(/,.*\}/)) {
23720
23715
  str = m.pre + '{' + m.body + escClose + m.post;
23721
- return expand$1(str);
23716
+ return expand$2(str);
23722
23717
  }
23723
23718
  return [str];
23724
23719
  }
@@ -23730,10 +23725,10 @@ function expand$1(str, isTop) {
23730
23725
  n = parseCommaParts(m.body);
23731
23726
  if (n.length === 1) {
23732
23727
  // x{{a,b}}y ==> x{a}y x{b}y
23733
- n = expand$1(n[0], false).map(embrace);
23728
+ n = expand$2(n[0], false).map(embrace);
23734
23729
  if (n.length === 1) {
23735
23730
  var post = m.post.length
23736
- ? expand$1(m.post, false)
23731
+ ? expand$2(m.post, false)
23737
23732
  : [''];
23738
23733
  return post.map(function(p) {
23739
23734
  return m.pre + n[0] + p;
@@ -23748,7 +23743,7 @@ function expand$1(str, isTop) {
23748
23743
  // no need to expand pre, since it is guaranteed to be free of brace-sets
23749
23744
  var pre = m.pre;
23750
23745
  var post = m.post.length
23751
- ? expand$1(m.post, false)
23746
+ ? expand$2(m.post, false)
23752
23747
  : [''];
23753
23748
 
23754
23749
  var N;
@@ -23792,7 +23787,7 @@ function expand$1(str, isTop) {
23792
23787
  N.push(c);
23793
23788
  }
23794
23789
  } else {
23795
- N = concatMap(n, function(el) { return expand$1(el, false) });
23790
+ N = concatMap(n, function(el) { return expand$2(el, false) });
23796
23791
  }
23797
23792
 
23798
23793
  for (var j = 0; j < N.length; j++) {
@@ -23815,7 +23810,7 @@ try {
23815
23810
  } catch (er) {}
23816
23811
 
23817
23812
  var GLOBSTAR$1 = minimatch$3.GLOBSTAR = Minimatch$1.GLOBSTAR = {};
23818
- var expand = braceExpansion;
23813
+ var expand$1 = braceExpansion;
23819
23814
 
23820
23815
  var plTypes = {
23821
23816
  '!': { open: '(?:(?!(?:', close: '))[^/]*?)'},
@@ -24060,7 +24055,7 @@ function braceExpand (pattern, options) {
24060
24055
  return [pattern]
24061
24056
  }
24062
24057
 
24063
- return expand(pattern)
24058
+ return expand$1(pattern)
24064
24059
  }
24065
24060
 
24066
24061
  // parse a component of the expanded set.
@@ -27681,7 +27676,7 @@ function getRequireStringArg(node) {
27681
27676
  function hasDynamicModuleForPath(source, id, dynamicRequireModuleSet) {
27682
27677
  if (!/^(?:\.{0,2}[/\\]|[A-Za-z]:[/\\])/.test(source)) {
27683
27678
  try {
27684
- const resolvedPath = normalizePathSlashes(resolve$3.sync(source, { basedir: path$r.dirname(id) }));
27679
+ const resolvedPath = normalizePathSlashes(resolve$4.sync(source, { basedir: path$r.dirname(id) }));
27685
27680
  if (dynamicRequireModuleSet.has(resolvedPath)) {
27686
27681
  return true;
27687
27682
  }
@@ -43254,7 +43249,15 @@ async _handleSymlink(entry, directory, path, item) {
43254
43249
  if (!this.fsw.options.followSymlinks) {
43255
43250
  // watch symlink directly (don't follow) and detect changes
43256
43251
  this.fsw._incrReadyCount();
43257
- const linkPath = await fsrealpath(path);
43252
+
43253
+ let linkPath;
43254
+ try {
43255
+ linkPath = await fsrealpath(path);
43256
+ } catch (e) {
43257
+ this.fsw._emitReady();
43258
+ return true;
43259
+ }
43260
+
43258
43261
  if (this.fsw.closed) return;
43259
43262
  if (dir.has(item)) {
43260
43263
  if (this.fsw._symlinkPaths.get(full) !== linkPath) {
@@ -45037,7 +45040,7 @@ async function getCertificate(cacheDir) {
45037
45040
  return content;
45038
45041
  }
45039
45042
  catch {
45040
- const content = (await Promise.resolve().then(function () { return require('./dep-778bed46.js'); })).createCertificate();
45043
+ const content = (await Promise.resolve().then(function () { return require('./dep-6c133e83.js'); })).createCertificate();
45041
45044
  fs$n.promises
45042
45045
  .mkdir(cacheDir, { recursive: true })
45043
45046
  .then(() => fs$n.promises.writeFile(cachePath, content))
@@ -45577,7 +45580,7 @@ class PerMessageDeflate$4 {
45577
45580
  /**
45578
45581
  * Compress data. Concurrency limited.
45579
45582
  *
45580
- * @param {Buffer} data Data to compress
45583
+ * @param {(Buffer|String)} data Data to compress
45581
45584
  * @param {Boolean} fin Specifies whether or not this is the last fragment
45582
45585
  * @param {Function} callback Callback
45583
45586
  * @public
@@ -45659,7 +45662,7 @@ class PerMessageDeflate$4 {
45659
45662
  /**
45660
45663
  * Compress data.
45661
45664
  *
45662
- * @param {Buffer} data Data to compress
45665
+ * @param {(Buffer|String)} data Data to compress
45663
45666
  * @param {Boolean} fin Specifies whether or not this is the last fragment
45664
45667
  * @param {Function} callback Callback
45665
45668
  * @private
@@ -46524,6 +46527,7 @@ const { EMPTY_BUFFER: EMPTY_BUFFER$1 } = constants;
46524
46527
  const { isValidStatusCode } = validation.exports;
46525
46528
  const { mask: applyMask, toBuffer: toBuffer$2 } = bufferUtil$1.exports;
46526
46529
 
46530
+ const kByteLength = Symbol('kByteLength');
46527
46531
  const maskBuffer = Buffer.alloc(4);
46528
46532
 
46529
46533
  /**
@@ -46559,7 +46563,7 @@ class Sender$1 {
46559
46563
  /**
46560
46564
  * Frames a piece of data according to the HyBi WebSocket protocol.
46561
46565
  *
46562
- * @param {Buffer} data The data to frame
46566
+ * @param {(Buffer|String)} data The data to frame
46563
46567
  * @param {Object} options Options object
46564
46568
  * @param {Boolean} [options.fin=false] Specifies whether or not to set the
46565
46569
  * FIN bit
@@ -46574,7 +46578,7 @@ class Sender$1 {
46574
46578
  * modified
46575
46579
  * @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
46576
46580
  * RSV1 bit
46577
- * @return {Buffer[]} The framed data as a list of `Buffer` instances
46581
+ * @return {(Buffer|String)[]} The framed data
46578
46582
  * @public
46579
46583
  */
46580
46584
  static frame(data, options) {
@@ -46593,22 +46597,37 @@ class Sender$1 {
46593
46597
  }
46594
46598
 
46595
46599
  skipMasking = (mask[0] | mask[1] | mask[2] | mask[3]) === 0;
46596
- if (options.readOnly && !skipMasking) merge = true;
46597
-
46598
46600
  offset = 6;
46599
46601
  }
46600
46602
 
46601
- let payloadLength = data.length;
46603
+ let dataLength;
46602
46604
 
46603
- if (data.length >= 65536) {
46605
+ if (typeof data === 'string') {
46606
+ if (
46607
+ (!options.mask || skipMasking) &&
46608
+ options[kByteLength] !== undefined
46609
+ ) {
46610
+ dataLength = options[kByteLength];
46611
+ } else {
46612
+ data = Buffer.from(data);
46613
+ dataLength = data.length;
46614
+ }
46615
+ } else {
46616
+ dataLength = data.length;
46617
+ merge = options.mask && options.readOnly && !skipMasking;
46618
+ }
46619
+
46620
+ let payloadLength = dataLength;
46621
+
46622
+ if (dataLength >= 65536) {
46604
46623
  offset += 8;
46605
46624
  payloadLength = 127;
46606
- } else if (data.length > 125) {
46625
+ } else if (dataLength > 125) {
46607
46626
  offset += 2;
46608
46627
  payloadLength = 126;
46609
46628
  }
46610
46629
 
46611
- const target = Buffer.allocUnsafe(merge ? data.length + offset : offset);
46630
+ const target = Buffer.allocUnsafe(merge ? dataLength + offset : offset);
46612
46631
 
46613
46632
  target[0] = options.fin ? options.opcode | 0x80 : options.opcode;
46614
46633
  if (options.rsv1) target[0] |= 0x40;
@@ -46616,10 +46635,10 @@ class Sender$1 {
46616
46635
  target[1] = payloadLength;
46617
46636
 
46618
46637
  if (payloadLength === 126) {
46619
- target.writeUInt16BE(data.length, 2);
46638
+ target.writeUInt16BE(dataLength, 2);
46620
46639
  } else if (payloadLength === 127) {
46621
46640
  target[2] = target[3] = 0;
46622
- target.writeUIntBE(data.length, 4, 6);
46641
+ target.writeUIntBE(dataLength, 4, 6);
46623
46642
  }
46624
46643
 
46625
46644
  if (!options.mask) return [target, data];
@@ -46633,11 +46652,11 @@ class Sender$1 {
46633
46652
  if (skipMasking) return [target, data];
46634
46653
 
46635
46654
  if (merge) {
46636
- applyMask(data, mask, target, offset, data.length);
46655
+ applyMask(data, mask, target, offset, dataLength);
46637
46656
  return [target];
46638
46657
  }
46639
46658
 
46640
- applyMask(data, mask, data, 0, data.length);
46659
+ applyMask(data, mask, data, 0, dataLength);
46641
46660
  return [target, data];
46642
46661
  }
46643
46662
 
@@ -46677,36 +46696,24 @@ class Sender$1 {
46677
46696
  }
46678
46697
  }
46679
46698
 
46699
+ const options = {
46700
+ [kByteLength]: buf.length,
46701
+ fin: true,
46702
+ generateMask: this._generateMask,
46703
+ mask,
46704
+ maskBuffer: this._maskBuffer,
46705
+ opcode: 0x08,
46706
+ readOnly: false,
46707
+ rsv1: false
46708
+ };
46709
+
46680
46710
  if (this._deflating) {
46681
- this.enqueue([this.doClose, buf, mask, cb]);
46711
+ this.enqueue([this.dispatch, buf, false, options, cb]);
46682
46712
  } else {
46683
- this.doClose(buf, mask, cb);
46713
+ this.sendFrame(Sender$1.frame(buf, options), cb);
46684
46714
  }
46685
46715
  }
46686
46716
 
46687
- /**
46688
- * Frames and sends a close message.
46689
- *
46690
- * @param {Buffer} data The message to send
46691
- * @param {Boolean} [mask=false] Specifies whether or not to mask `data`
46692
- * @param {Function} [cb] Callback
46693
- * @private
46694
- */
46695
- doClose(data, mask, cb) {
46696
- this.sendFrame(
46697
- Sender$1.frame(data, {
46698
- fin: true,
46699
- rsv1: false,
46700
- opcode: 0x08,
46701
- mask,
46702
- maskBuffer: this._maskBuffer,
46703
- generateMask: this._generateMask,
46704
- readOnly: false
46705
- }),
46706
- cb
46707
- );
46708
- }
46709
-
46710
46717
  /**
46711
46718
  * Sends a ping message to the other peer.
46712
46719
  *
@@ -46716,43 +46723,40 @@ class Sender$1 {
46716
46723
  * @public
46717
46724
  */
46718
46725
  ping(data, mask, cb) {
46719
- const buf = toBuffer$2(data);
46726
+ let byteLength;
46727
+ let readOnly;
46728
+
46729
+ if (typeof data === 'string') {
46730
+ byteLength = Buffer.byteLength(data);
46731
+ readOnly = false;
46732
+ } else {
46733
+ data = toBuffer$2(data);
46734
+ byteLength = data.length;
46735
+ readOnly = toBuffer$2.readOnly;
46736
+ }
46720
46737
 
46721
- if (buf.length > 125) {
46738
+ if (byteLength > 125) {
46722
46739
  throw new RangeError('The data size must not be greater than 125 bytes');
46723
46740
  }
46724
46741
 
46742
+ const options = {
46743
+ [kByteLength]: byteLength,
46744
+ fin: true,
46745
+ generateMask: this._generateMask,
46746
+ mask,
46747
+ maskBuffer: this._maskBuffer,
46748
+ opcode: 0x09,
46749
+ readOnly,
46750
+ rsv1: false
46751
+ };
46752
+
46725
46753
  if (this._deflating) {
46726
- this.enqueue([this.doPing, buf, mask, toBuffer$2.readOnly, cb]);
46754
+ this.enqueue([this.dispatch, data, false, options, cb]);
46727
46755
  } else {
46728
- this.doPing(buf, mask, toBuffer$2.readOnly, cb);
46756
+ this.sendFrame(Sender$1.frame(data, options), cb);
46729
46757
  }
46730
46758
  }
46731
46759
 
46732
- /**
46733
- * Frames and sends a ping message.
46734
- *
46735
- * @param {Buffer} data The message to send
46736
- * @param {Boolean} [mask=false] Specifies whether or not to mask `data`
46737
- * @param {Boolean} [readOnly=false] Specifies whether `data` can be modified
46738
- * @param {Function} [cb] Callback
46739
- * @private
46740
- */
46741
- doPing(data, mask, readOnly, cb) {
46742
- this.sendFrame(
46743
- Sender$1.frame(data, {
46744
- fin: true,
46745
- rsv1: false,
46746
- opcode: 0x09,
46747
- mask,
46748
- maskBuffer: this._maskBuffer,
46749
- generateMask: this._generateMask,
46750
- readOnly
46751
- }),
46752
- cb
46753
- );
46754
- }
46755
-
46756
46760
  /**
46757
46761
  * Sends a pong message to the other peer.
46758
46762
  *
@@ -46762,43 +46766,40 @@ class Sender$1 {
46762
46766
  * @public
46763
46767
  */
46764
46768
  pong(data, mask, cb) {
46765
- const buf = toBuffer$2(data);
46769
+ let byteLength;
46770
+ let readOnly;
46766
46771
 
46767
- if (buf.length > 125) {
46772
+ if (typeof data === 'string') {
46773
+ byteLength = Buffer.byteLength(data);
46774
+ readOnly = false;
46775
+ } else {
46776
+ data = toBuffer$2(data);
46777
+ byteLength = data.length;
46778
+ readOnly = toBuffer$2.readOnly;
46779
+ }
46780
+
46781
+ if (byteLength > 125) {
46768
46782
  throw new RangeError('The data size must not be greater than 125 bytes');
46769
46783
  }
46770
46784
 
46785
+ const options = {
46786
+ [kByteLength]: byteLength,
46787
+ fin: true,
46788
+ generateMask: this._generateMask,
46789
+ mask,
46790
+ maskBuffer: this._maskBuffer,
46791
+ opcode: 0x0a,
46792
+ readOnly,
46793
+ rsv1: false
46794
+ };
46795
+
46771
46796
  if (this._deflating) {
46772
- this.enqueue([this.doPong, buf, mask, toBuffer$2.readOnly, cb]);
46797
+ this.enqueue([this.dispatch, data, false, options, cb]);
46773
46798
  } else {
46774
- this.doPong(buf, mask, toBuffer$2.readOnly, cb);
46799
+ this.sendFrame(Sender$1.frame(data, options), cb);
46775
46800
  }
46776
46801
  }
46777
46802
 
46778
- /**
46779
- * Frames and sends a pong message.
46780
- *
46781
- * @param {Buffer} data The message to send
46782
- * @param {Boolean} [mask=false] Specifies whether or not to mask `data`
46783
- * @param {Boolean} [readOnly=false] Specifies whether `data` can be modified
46784
- * @param {Function} [cb] Callback
46785
- * @private
46786
- */
46787
- doPong(data, mask, readOnly, cb) {
46788
- this.sendFrame(
46789
- Sender$1.frame(data, {
46790
- fin: true,
46791
- rsv1: false,
46792
- opcode: 0x0a,
46793
- mask,
46794
- maskBuffer: this._maskBuffer,
46795
- generateMask: this._generateMask,
46796
- readOnly
46797
- }),
46798
- cb
46799
- );
46800
- }
46801
-
46802
46803
  /**
46803
46804
  * Sends a data message to the other peer.
46804
46805
  *
@@ -46816,11 +46817,22 @@ class Sender$1 {
46816
46817
  * @public
46817
46818
  */
46818
46819
  send(data, options, cb) {
46819
- const buf = toBuffer$2(data);
46820
46820
  const perMessageDeflate = this._extensions[PerMessageDeflate$2.extensionName];
46821
46821
  let opcode = options.binary ? 2 : 1;
46822
46822
  let rsv1 = options.compress;
46823
46823
 
46824
+ let byteLength;
46825
+ let readOnly;
46826
+
46827
+ if (typeof data === 'string') {
46828
+ byteLength = Buffer.byteLength(data);
46829
+ readOnly = false;
46830
+ } else {
46831
+ data = toBuffer$2(data);
46832
+ byteLength = data.length;
46833
+ readOnly = toBuffer$2.readOnly;
46834
+ }
46835
+
46824
46836
  if (this._firstFragment) {
46825
46837
  this._firstFragment = false;
46826
46838
  if (
@@ -46832,7 +46844,7 @@ class Sender$1 {
46832
46844
  : 'client_no_context_takeover'
46833
46845
  ]
46834
46846
  ) {
46835
- rsv1 = buf.length >= perMessageDeflate._threshold;
46847
+ rsv1 = byteLength >= perMessageDeflate._threshold;
46836
46848
  }
46837
46849
  this._compress = rsv1;
46838
46850
  } else {
@@ -46844,30 +46856,32 @@ class Sender$1 {
46844
46856
 
46845
46857
  if (perMessageDeflate) {
46846
46858
  const opts = {
46859
+ [kByteLength]: byteLength,
46847
46860
  fin: options.fin,
46848
- rsv1,
46849
- opcode,
46861
+ generateMask: this._generateMask,
46850
46862
  mask: options.mask,
46851
46863
  maskBuffer: this._maskBuffer,
46852
- generateMask: this._generateMask,
46853
- readOnly: toBuffer$2.readOnly
46864
+ opcode,
46865
+ readOnly,
46866
+ rsv1
46854
46867
  };
46855
46868
 
46856
46869
  if (this._deflating) {
46857
- this.enqueue([this.dispatch, buf, this._compress, opts, cb]);
46870
+ this.enqueue([this.dispatch, data, this._compress, opts, cb]);
46858
46871
  } else {
46859
- this.dispatch(buf, this._compress, opts, cb);
46872
+ this.dispatch(data, this._compress, opts, cb);
46860
46873
  }
46861
46874
  } else {
46862
46875
  this.sendFrame(
46863
- Sender$1.frame(buf, {
46876
+ Sender$1.frame(data, {
46877
+ [kByteLength]: byteLength,
46864
46878
  fin: options.fin,
46865
- rsv1: false,
46866
- opcode,
46879
+ generateMask: this._generateMask,
46867
46880
  mask: options.mask,
46868
46881
  maskBuffer: this._maskBuffer,
46869
- generateMask: this._generateMask,
46870
- readOnly: toBuffer$2.readOnly
46882
+ opcode,
46883
+ readOnly,
46884
+ rsv1: false
46871
46885
  }),
46872
46886
  cb
46873
46887
  );
@@ -46875,13 +46889,12 @@ class Sender$1 {
46875
46889
  }
46876
46890
 
46877
46891
  /**
46878
- * Dispatches a data message.
46892
+ * Dispatches a message.
46879
46893
  *
46880
- * @param {Buffer} data The message to send
46894
+ * @param {(Buffer|String)} data The message to send
46881
46895
  * @param {Boolean} [compress=false] Specifies whether or not to compress
46882
46896
  * `data`
46883
46897
  * @param {Object} options Options object
46884
- * @param {Number} options.opcode The opcode
46885
46898
  * @param {Boolean} [options.fin=false] Specifies whether or not to set the
46886
46899
  * FIN bit
46887
46900
  * @param {Function} [options.generateMask] The function used to generate the
@@ -46890,6 +46903,7 @@ class Sender$1 {
46890
46903
  * `data`
46891
46904
  * @param {Buffer} [options.maskBuffer] The buffer used to store the masking
46892
46905
  * key
46906
+ * @param {Number} options.opcode The opcode
46893
46907
  * @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
46894
46908
  * modified
46895
46909
  * @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
@@ -46905,7 +46919,7 @@ class Sender$1 {
46905
46919
 
46906
46920
  const perMessageDeflate = this._extensions[PerMessageDeflate$2.extensionName];
46907
46921
 
46908
- this._bufferedBytes += data.length;
46922
+ this._bufferedBytes += options[kByteLength];
46909
46923
  this._deflating = true;
46910
46924
  perMessageDeflate.compress(data, options.fin, (_, buf) => {
46911
46925
  if (this._socket.destroyed) {
@@ -46916,7 +46930,8 @@ class Sender$1 {
46916
46930
  if (typeof cb === 'function') cb(err);
46917
46931
 
46918
46932
  for (let i = 0; i < this._queue.length; i++) {
46919
- const callback = this._queue[i][4];
46933
+ const params = this._queue[i];
46934
+ const callback = params[params.length - 1];
46920
46935
 
46921
46936
  if (typeof callback === 'function') callback(err);
46922
46937
  }
@@ -46924,7 +46939,7 @@ class Sender$1 {
46924
46939
  return;
46925
46940
  }
46926
46941
 
46927
- this._bufferedBytes -= data.length;
46942
+ this._bufferedBytes -= options[kByteLength];
46928
46943
  this._deflating = false;
46929
46944
  options.readOnly = false;
46930
46945
  this.sendFrame(Sender$1.frame(buf, options), cb);
@@ -46941,7 +46956,7 @@ class Sender$1 {
46941
46956
  while (!this._deflating && this._queue.length) {
46942
46957
  const params = this._queue.shift();
46943
46958
 
46944
- this._bufferedBytes -= params[1].length;
46959
+ this._bufferedBytes -= params[3][kByteLength];
46945
46960
  Reflect.apply(params[0], this, params.slice(1));
46946
46961
  }
46947
46962
  }
@@ -46953,7 +46968,7 @@ class Sender$1 {
46953
46968
  * @private
46954
46969
  */
46955
46970
  enqueue(params) {
46956
- this._bufferedBytes += params[1].length;
46971
+ this._bufferedBytes += params[3][kByteLength];
46957
46972
  this._queue.push(params);
46958
46973
  }
46959
46974
 
@@ -47453,7 +47468,7 @@ const http$3 = require$$1__default$2;
47453
47468
  const net = require$$3__default;
47454
47469
  const tls = require$$4__default;
47455
47470
  const { randomBytes, createHash: createHash$1 } = require$$1__default$3;
47456
- const { URL: URL$2 } = require$$0__default$5;
47471
+ const { URL: URL$1 } = require$$0__default$5;
47457
47472
 
47458
47473
  const PerMessageDeflate$1 = permessageDeflate;
47459
47474
  const Receiver = receiver;
@@ -48106,12 +48121,12 @@ function initAsClient(websocket, address, protocols, options) {
48106
48121
 
48107
48122
  let parsedUrl;
48108
48123
 
48109
- if (address instanceof URL$2) {
48124
+ if (address instanceof URL$1) {
48110
48125
  parsedUrl = address;
48111
48126
  websocket._url = address.href;
48112
48127
  } else {
48113
48128
  try {
48114
- parsedUrl = new URL$2(address);
48129
+ parsedUrl = new URL$1(address);
48115
48130
  } catch (e) {
48116
48131
  throw new SyntaxError(`Invalid URL: ${address}`);
48117
48132
  }
@@ -48245,7 +48260,7 @@ function initAsClient(websocket, address, protocols, options) {
48245
48260
  let addr;
48246
48261
 
48247
48262
  try {
48248
- addr = new URL$2(location, address);
48263
+ addr = new URL$1(location, address);
48249
48264
  } catch (e) {
48250
48265
  const err = new SyntaxError(`Invalid URL: ${location}`);
48251
48266
  emitErrorAndClose(websocket, err);
@@ -50155,7 +50170,7 @@ var debug_1 = function () {
50155
50170
  };
50156
50171
 
50157
50172
  var url$1 = require$$0__default$5;
50158
- var URL$1 = url$1.URL;
50173
+ var URL = url$1.URL;
50159
50174
  var http$1 = require$$1__default$2;
50160
50175
  var https$1 = require$$1__default$4;
50161
50176
  var Writable = require$$0__default$2.Writable;
@@ -50606,14 +50621,14 @@ function wrap(protocols) {
50606
50621
  if (typeof input === "string") {
50607
50622
  var urlStr = input;
50608
50623
  try {
50609
- input = urlToOptions(new URL$1(urlStr));
50624
+ input = urlToOptions(new URL(urlStr));
50610
50625
  }
50611
50626
  catch (err) {
50612
50627
  /* istanbul ignore next */
50613
50628
  input = url$1.parse(urlStr);
50614
50629
  }
50615
50630
  }
50616
- else if (URL$1 && (input instanceof URL$1)) {
50631
+ else if (URL && (input instanceof URL)) {
50617
50632
  input = urlToOptions(input);
50618
50633
  }
50619
50634
  else {
@@ -50655,7 +50670,7 @@ function wrap(protocols) {
50655
50670
  }
50656
50671
 
50657
50672
  /* istanbul ignore next */
50658
- function noop$2() { /* empty */ }
50673
+ function noop$1() { /* empty */ }
50659
50674
 
50660
50675
  // from https://github.com/nodejs/node/blob/master/lib/internal/url.js
50661
50676
  function urlToOptions(urlObject) {
@@ -50711,7 +50726,7 @@ function abortRequest(request) {
50711
50726
  for (var e = 0; e < events.length; e++) {
50712
50727
  request.removeListener(events[e], eventHandlers[events[e]]);
50713
50728
  }
50714
- request.on("error", noop$2);
50729
+ request.on("error", noop$1);
50715
50730
  request.abort();
50716
50731
  }
50717
50732
 
@@ -52508,7 +52523,7 @@ function parse$5(req) {
52508
52523
  return req._parsedUrl = { pathname, search, query, raw };
52509
52524
  }
52510
52525
 
52511
- const noop$1 = () => {};
52526
+ const noop = () => {};
52512
52527
 
52513
52528
  function isMatch(uri, arr) {
52514
52529
  for (let i=0; i < arr.length; i++) {
@@ -52619,7 +52634,7 @@ function sirv (dir, opts={}) {
52619
52634
  dir = path$r.resolve(dir || '.');
52620
52635
 
52621
52636
  let isNotFound = opts.onNoMatch || is404;
52622
- let setHeaders = opts.setHeaders || noop$1;
52637
+ let setHeaders = opts.setHeaders || noop;
52623
52638
 
52624
52639
  let extensions = opts.extensions || ['html', 'htm'];
52625
52640
  let gzips = opts.gzip && extensions.map(x => `${x}.gz`).concat('gz');
@@ -55690,7 +55705,7 @@ ssr) {
55690
55705
  for (const id of include) {
55691
55706
  // normalize 'foo >bar` as 'foo > bar' to prevent same id being added
55692
55707
  // and for pretty printing
55693
- const normalizedId = normalizeId$1(id);
55708
+ const normalizedId = normalizeId(id);
55694
55709
  if (!deps[normalizedId]) {
55695
55710
  const entry = await resolve(id);
55696
55711
  if (entry) {
@@ -69474,7 +69489,6 @@ async function preview(inlineConfig) {
69474
69489
  };
69475
69490
  }
69476
69491
 
69477
- const noop = () => null;
69478
69492
  function matches(pattern, importee) {
69479
69493
  if (pattern instanceof RegExp) {
69480
69494
  return pattern.test(importee);
@@ -69485,36 +69499,35 @@ function matches(pattern, importee) {
69485
69499
  if (importee === pattern) {
69486
69500
  return true;
69487
69501
  }
69488
- const importeeStartsWithKey = importee.indexOf(pattern) === 0;
69489
- const importeeHasSlashAfterKey = importee.substring(pattern.length)[0] === '/';
69490
- return importeeStartsWithKey && importeeHasSlashAfterKey;
69502
+ // eslint-disable-next-line prefer-template
69503
+ return importee.startsWith(pattern + '/');
69491
69504
  }
69492
- function normalizeId(id) {
69493
- return id;
69494
- }
69495
- function getEntries({ entries }) {
69505
+ function getEntries({ entries, customResolver }) {
69496
69506
  if (!entries) {
69497
69507
  return [];
69498
69508
  }
69509
+ const resolverFunctionFromOptions = resolveCustomResolver(customResolver);
69499
69510
  if (Array.isArray(entries)) {
69500
- return entries;
69511
+ return entries.map((entry) => {
69512
+ return {
69513
+ find: entry.find,
69514
+ replacement: entry.replacement,
69515
+ resolverFunction: resolveCustomResolver(entry.customResolver) || resolverFunctionFromOptions
69516
+ };
69517
+ });
69501
69518
  }
69502
69519
  return Object.entries(entries).map(([key, value]) => {
69503
- return { find: key, replacement: value };
69520
+ return { find: key, replacement: value, resolverFunction: resolverFunctionFromOptions };
69504
69521
  });
69505
69522
  }
69506
- function getCustomResolver({ customResolver }, options) {
69507
- if (typeof customResolver === 'function') {
69508
- return customResolver;
69509
- }
69510
- if (customResolver && typeof customResolver.resolveId === 'function') {
69511
- return customResolver.resolveId;
69512
- }
69513
- if (typeof options.customResolver === 'function') {
69514
- return options.customResolver;
69515
- }
69516
- if (options.customResolver && typeof options.customResolver.resolveId === 'function') {
69517
- return options.customResolver.resolveId;
69523
+ function resolveCustomResolver(customResolver) {
69524
+ if (customResolver) {
69525
+ if (typeof customResolver === 'function') {
69526
+ return customResolver;
69527
+ }
69528
+ if (typeof customResolver.resolveId === 'function') {
69529
+ return customResolver.resolveId;
69530
+ }
69518
69531
  }
69519
69532
  return null;
69520
69533
  }
@@ -69523,39 +69536,31 @@ function alias(options = {}) {
69523
69536
  if (entries.length === 0) {
69524
69537
  return {
69525
69538
  name: 'alias',
69526
- resolveId: noop
69539
+ resolveId: () => null
69527
69540
  };
69528
69541
  }
69529
69542
  return {
69530
69543
  name: 'alias',
69531
- buildStart(inputOptions) {
69532
- return Promise.all([...entries, options].map(({ customResolver }) => customResolver &&
69544
+ async buildStart(inputOptions) {
69545
+ await Promise.all([...(Array.isArray(options.entries) ? options.entries : []), options].map(({ customResolver }) => customResolver &&
69533
69546
  typeof customResolver === 'object' &&
69534
69547
  typeof customResolver.buildStart === 'function' &&
69535
- customResolver.buildStart.call(this, inputOptions))).then(() => {
69536
- // enforce void return value
69537
- });
69548
+ customResolver.buildStart.call(this, inputOptions)));
69538
69549
  },
69539
69550
  resolveId(importee, importer, resolveOptions) {
69540
- const importeeId = normalizeId(importee);
69541
- const importerId = normalizeId(importer);
69551
+ if (!importer) {
69552
+ return null;
69553
+ }
69542
69554
  // First match is supposed to be the correct one
69543
- const matchedEntry = entries.find((entry) => matches(entry.find, importeeId));
69544
- if (!matchedEntry || !importerId) {
69555
+ const matchedEntry = entries.find((entry) => matches(entry.find, importee));
69556
+ if (!matchedEntry) {
69545
69557
  return null;
69546
69558
  }
69547
- const updatedId = normalizeId(importeeId.replace(matchedEntry.find, matchedEntry.replacement));
69548
- const customResolver = getCustomResolver(matchedEntry, options);
69549
- if (customResolver) {
69550
- return customResolver.call(this, updatedId, importerId, resolveOptions);
69559
+ const updatedId = importee.replace(matchedEntry.find, matchedEntry.replacement);
69560
+ if (matchedEntry.resolverFunction) {
69561
+ return matchedEntry.resolverFunction.call(this, updatedId, importer, resolveOptions);
69551
69562
  }
69552
- return this.resolve(updatedId, importer, Object.assign({ skipSelf: true }, resolveOptions)).then((resolved) => {
69553
- let finalResult = resolved;
69554
- if (!finalResult) {
69555
- finalResult = { id: updatedId };
69556
- }
69557
- return finalResult;
69558
- });
69563
+ return this.resolve(updatedId, importer, Object.assign({ skipSelf: true }, resolveOptions)).then((resolved) => resolved || { id: updatedId });
69559
69564
  }
69560
69565
  };
69561
69566
  }
@@ -70559,7 +70564,7 @@ async function resolvePlugins(config, prePlugins, normalPlugins, postPlugins) {
70559
70564
  ].filter(Boolean);
70560
70565
  }
70561
70566
 
70562
- var main$1 = {exports: {}};
70567
+ var main = {exports: {}};
70563
70568
 
70564
70569
  const fs = fs__default;
70565
70570
  const path = path__default;
@@ -70700,56 +70705,70 @@ const DotenvModule = {
70700
70705
  parse
70701
70706
  };
70702
70707
 
70703
- main$1.exports.config = DotenvModule.config;
70704
- main$1.exports.parse = DotenvModule.parse;
70705
- main$1.exports = DotenvModule;
70708
+ main.exports.config = DotenvModule.config;
70709
+ main.exports.parse = DotenvModule.parse;
70710
+ main.exports = DotenvModule;
70706
70711
 
70707
- var dotenv = main$1.exports;
70712
+ var dotenv = main.exports;
70708
70713
 
70709
- var dotenvExpand = function (config) {
70710
- // if ignoring process.env, use a blank object
70711
- var environment = config.ignoreProcessEnv ? {} : process.env;
70712
-
70713
- var interpolate = function (envValue) {
70714
- var matches = envValue.match(/(.?\${?(?:[a-zA-Z0-9_]+)?}?)/g) || [];
70714
+ function _interpolate (envValue, environment, config) {
70715
+ const matches = envValue.match(/(.?\${*[\w]*(?::-)?[\w]*}*)/g) || [];
70715
70716
 
70716
- return matches.reduce(function (newEnv, match) {
70717
- var parts = /(.?)\${?([a-zA-Z0-9_]+)?}?/g.exec(match);
70718
- var prefix = parts[1];
70717
+ return matches.reduce(function (newEnv, match, index) {
70718
+ const parts = /(.?)\${*([\w]*(?::-)?[\w]*)?}*/g.exec(match);
70719
+ if (!parts || parts.length === 0) {
70720
+ return newEnv
70721
+ }
70719
70722
 
70720
- var value, replacePart;
70723
+ const prefix = parts[1];
70721
70724
 
70722
- if (prefix === '\\') {
70723
- replacePart = parts[0];
70724
- value = replacePart.replace('\\$', '$');
70725
- } else {
70726
- var key = parts[2];
70727
- replacePart = parts[0].substring(prefix.length);
70728
- // process.env value 'wins' over .env file's value
70729
- value = environment.hasOwnProperty(key) ? environment[key] : (config.parsed[key] || '');
70725
+ let value, replacePart;
70730
70726
 
70731
- // Resolve recursive interpolations
70732
- value = interpolate(value);
70727
+ if (prefix === '\\') {
70728
+ replacePart = parts[0];
70729
+ value = replacePart.replace('\\$', '$');
70730
+ } else {
70731
+ const keyParts = parts[2].split(':-');
70732
+ const key = keyParts[0];
70733
+ replacePart = parts[0].substring(prefix.length);
70734
+ // process.env value 'wins' over .env file's value
70735
+ value = Object.prototype.hasOwnProperty.call(environment, key)
70736
+ ? environment[key]
70737
+ : (config.parsed[key] || keyParts[1] || '');
70738
+
70739
+ // If the value is found, remove nested expansions.
70740
+ if (keyParts.length > 1 && value) {
70741
+ const replaceNested = matches[index + 1];
70742
+ matches[index + 1] = '';
70743
+
70744
+ newEnv = newEnv.replace(replaceNested, '');
70733
70745
  }
70746
+ // Resolve recursive interpolations
70747
+ value = _interpolate(value, environment, config);
70748
+ }
70734
70749
 
70735
- return newEnv.replace(replacePart, value)
70736
- }, envValue)
70737
- };
70750
+ return newEnv.replace(replacePart, value)
70751
+ }, envValue)
70752
+ }
70738
70753
 
70739
- for (var configKey in config.parsed) {
70740
- var value = environment.hasOwnProperty(configKey) ? environment[configKey] : config.parsed[configKey];
70754
+ function expand (config) {
70755
+ // if ignoring process.env, use a blank object
70756
+ const environment = config.ignoreProcessEnv ? {} : process.env;
70757
+
70758
+ for (const configKey in config.parsed) {
70759
+ const value = Object.prototype.hasOwnProperty.call(environment, configKey) ? environment[configKey] : config.parsed[configKey];
70741
70760
 
70742
- config.parsed[configKey] = interpolate(value);
70761
+ config.parsed[configKey] = _interpolate(value, environment, config);
70743
70762
  }
70744
70763
 
70745
- for (var processKey in config.parsed) {
70764
+ for (const processKey in config.parsed) {
70746
70765
  environment[processKey] = config.parsed[processKey];
70747
70766
  }
70748
70767
 
70749
70768
  return config
70750
- };
70769
+ }
70751
70770
 
70752
- var main = dotenvExpand;
70771
+ var expand_1 = expand;
70753
70772
 
70754
70773
  const debug = createDebugger('vite:config');
70755
70774
  /**
@@ -71363,7 +71382,7 @@ function loadEnv(mode, envDir, prefixes = 'VITE_') {
71363
71382
  debug: ((_a = process.env.DEBUG) === null || _a === void 0 ? void 0 : _a.includes('vite:dotenv')) || undefined
71364
71383
  });
71365
71384
  // let environment variables use each other
71366
- main({
71385
+ expand_1({
71367
71386
  parsed,
71368
71387
  // prevent process.env mutation
71369
71388
  ignoreProcessEnv: true