ts-checker-rspack-plugin 1.8.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*! LICENSE: index.js.LICENSE.txt */
2
- var __webpack_modules__ = {
2
+ var __rspack_modules = {
3
3
  "./node_modules/.pnpm/is-extglob@2.1.1/node_modules/is-extglob/index.js" (module) {
4
4
  /*!
5
5
  * is-extglob <https://github.com/jonschlinkert/is-extglob>
@@ -16,13 +16,13 @@ var __webpack_modules__ = {
16
16
  return false;
17
17
  };
18
18
  },
19
- "./node_modules/.pnpm/is-glob@4.0.3/node_modules/is-glob/index.js" (module, __unused_rspack_exports, __webpack_require__) {
19
+ "./node_modules/.pnpm/is-glob@4.0.3/node_modules/is-glob/index.js" (module, __unused_rspack_exports, __rspack_context) {
20
20
  /*!
21
21
  * is-glob <https://github.com/jonschlinkert/is-glob>
22
22
  *
23
23
  * Copyright (c) 2014-2017, Jon Schlinkert.
24
24
  * Released under the MIT License.
25
- */ var isExtglob = __webpack_require__("./node_modules/.pnpm/is-extglob@2.1.1/node_modules/is-extglob/index.js");
25
+ */ var isExtglob = __rspack_context.r("./node_modules/.pnpm/is-extglob@2.1.1/node_modules/is-extglob/index.js");
26
26
  var chars = {
27
27
  '{': '}',
28
28
  '(': ')',
@@ -136,11 +136,11 @@ var __webpack_modules__ = {
136
136
  "use strict";
137
137
  module.exports = require("picocolors");
138
138
  },
139
- "./node_modules/.pnpm/@babel+code-frame@7.29.7/node_modules/@babel/code-frame/lib/index.js" (__unused_rspack_module, exports1, __webpack_require__) {
139
+ "./node_modules/.pnpm/@babel+code-frame@7.29.7/node_modules/@babel/code-frame/lib/index.js" (__unused_rspack_module, exports1, __rspack_context) {
140
140
  "use strict";
141
- var picocolors = __webpack_require__("picocolors");
142
- var jsTokens = __webpack_require__("./node_modules/.pnpm/js-tokens@4.0.0/node_modules/js-tokens/index.js");
143
- var helperValidatorIdentifier = __webpack_require__("./node_modules/.pnpm/@babel+helper-validator-identifier@7.29.7/node_modules/@babel/helper-validator-identifier/lib/index.js");
141
+ var picocolors = __rspack_context.r("picocolors");
142
+ var jsTokens = __rspack_context.r("./node_modules/.pnpm/js-tokens@4.0.0/node_modules/js-tokens/index.js");
143
+ var helperValidatorIdentifier = __rspack_context.r("./node_modules/.pnpm/@babel+helper-validator-identifier@7.29.7/node_modules/@babel/helper-validator-identifier/lib/index.js");
144
144
  function isColorSupported() {
145
145
  return "object" == typeof process && ("0" === process.env.FORCE_COLOR || "false" === process.env.FORCE_COLOR) ? false : picocolors.isColorSupported;
146
146
  }
@@ -1316,7 +1316,7 @@ var __webpack_modules__ = {
1316
1316
  return !isFirst;
1317
1317
  }
1318
1318
  },
1319
- "./node_modules/.pnpm/@babel+helper-validator-identifier@7.29.7/node_modules/@babel/helper-validator-identifier/lib/index.js" (__unused_rspack_module, exports1, __webpack_require__) {
1319
+ "./node_modules/.pnpm/@babel+helper-validator-identifier@7.29.7/node_modules/@babel/helper-validator-identifier/lib/index.js" (__unused_rspack_module, exports1, __rspack_context) {
1320
1320
  "use strict";
1321
1321
  Object.defineProperty(exports1, "__esModule", {
1322
1322
  value: true
@@ -1369,8 +1369,8 @@ var __webpack_modules__ = {
1369
1369
  return _keyword.isStrictReservedWord;
1370
1370
  }
1371
1371
  });
1372
- var _identifier = __webpack_require__("./node_modules/.pnpm/@babel+helper-validator-identifier@7.29.7/node_modules/@babel/helper-validator-identifier/lib/identifier.js");
1373
- var _keyword = __webpack_require__("./node_modules/.pnpm/@babel+helper-validator-identifier@7.29.7/node_modules/@babel/helper-validator-identifier/lib/keyword.js");
1372
+ var _identifier = __rspack_context.r("./node_modules/.pnpm/@babel+helper-validator-identifier@7.29.7/node_modules/@babel/helper-validator-identifier/lib/identifier.js");
1373
+ var _keyword = __rspack_context.r("./node_modules/.pnpm/@babel+helper-validator-identifier@7.29.7/node_modules/@babel/helper-validator-identifier/lib/keyword.js");
1374
1374
  },
1375
1375
  "./node_modules/.pnpm/@babel+helper-validator-identifier@7.29.7/node_modules/@babel/helper-validator-identifier/lib/keyword.js" (__unused_rspack_module, exports1) {
1376
1376
  "use strict";
@@ -1456,29 +1456,30 @@ var __webpack_modules__ = {
1456
1456
  }
1457
1457
  }
1458
1458
  };
1459
- var __webpack_module_cache__ = {};
1460
- function __webpack_require__(moduleId) {
1461
- var cachedModule = __webpack_module_cache__[moduleId];
1459
+ var __rspack_module_cache = {};
1460
+ var __rspack_context = {};
1461
+ function __rspack_require(moduleId) {
1462
+ var cachedModule = __rspack_module_cache[moduleId];
1462
1463
  if (void 0 !== cachedModule) return cachedModule.exports;
1463
- var module = __webpack_module_cache__[moduleId] = {
1464
+ var module = __rspack_module_cache[moduleId] = {
1464
1465
  exports: {}
1465
1466
  };
1466
- __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
1467
+ __rspack_modules[moduleId](module, module.exports, __rspack_context);
1467
1468
  return module.exports;
1468
1469
  }
1469
- (()=>{
1470
- __webpack_require__.n = (module)=>{
1470
+ __rspack_context.r = __rspack_require;
1471
+ (function() {
1472
+ var compatGetDefaultExport = (module)=>{
1471
1473
  var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
1472
- __webpack_require__.d(getter, {
1474
+ definePropertyGetters(getter, {
1473
1475
  a: getter
1474
1476
  });
1475
1477
  return getter;
1476
1478
  };
1477
- })();
1478
- (()=>{
1479
- __webpack_require__.d = (exports1, getters, values)=>{
1479
+ __rspack_context.n = compatGetDefaultExport;
1480
+ var definePropertyGetters = (exports1, getters, values)=>{
1480
1481
  var define = (defs, kind)=>{
1481
- for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
1482
+ for(var key in defs)if (hasOwnProperty(defs, key) && !hasOwnProperty(exports1, key)) Object.defineProperty(exports1, key, {
1482
1483
  enumerable: true,
1483
1484
  [kind]: defs[key]
1484
1485
  });
@@ -1486,29 +1487,29 @@ function __webpack_require__(moduleId) {
1486
1487
  define(getters, "get");
1487
1488
  define(values, "value");
1488
1489
  };
1489
- })();
1490
- (()=>{
1491
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
1492
- })();
1493
- (()=>{
1494
- __webpack_require__.r = (exports1)=>{
1495
- if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
1496
- value: 'Module'
1497
- });
1498
- Object.defineProperty(exports1, '__esModule', {
1499
- value: true
1490
+ __rspack_context.d = definePropertyGetters;
1491
+ var hasOwnProperty = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
1492
+ var makeNamespaceObject = (exports1)=>{
1493
+ Object.defineProperties(exports1, {
1494
+ [Symbol.toStringTag]: {
1495
+ value: 'Module'
1496
+ },
1497
+ __esModule: {
1498
+ value: true
1499
+ }
1500
1500
  });
1501
1501
  };
1502
+ __rspack_context.N = makeNamespaceObject;
1502
1503
  })();
1503
- var __webpack_exports__ = {};
1504
+ var __rspack_exports = {};
1504
1505
  (()=>{
1505
1506
  "use strict";
1506
- __webpack_require__.r(__webpack_exports__);
1507
- __webpack_require__.d(__webpack_exports__, {
1507
+ __rspack_context.N(__rspack_exports);
1508
+ __rspack_context.d(__rspack_exports, {
1508
1509
  TsCheckerRspackPlugin: ()=>TsCheckerRspackPlugin
1509
1510
  });
1510
1511
  const external_node_path_namespaceObject = require("node:path");
1511
- var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
1512
+ var external_node_path_default = /*#__PURE__*/ __rspack_context.n(external_node_path_namespaceObject);
1512
1513
  function getInfrastructureLogger(compiler) {
1513
1514
  const logger = compiler.getInfrastructureLogger('TsCheckerRspackPlugin');
1514
1515
  return {
@@ -1553,25 +1554,9 @@ var __webpack_exports__ = {};
1553
1554
  });
1554
1555
  }
1555
1556
  const external_node_fs_namespaceObject = require("node:fs");
1556
- var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
1557
+ var external_node_fs_default = /*#__PURE__*/ __rspack_context.n(external_node_fs_namespaceObject);
1557
1558
  const external_chokidar_namespaceObject = require("chokidar");
1558
- var external_chokidar_default = /*#__PURE__*/ __webpack_require__.n(external_chokidar_namespaceObject);
1559
- const balanced = (a, b, str)=>{
1560
- const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
1561
- const mb = b instanceof RegExp ? maybeMatch(b, str) : b;
1562
- const r = null !== ma && null != mb && range(ma, mb, str);
1563
- return r && {
1564
- start: r[0],
1565
- end: r[1],
1566
- pre: str.slice(0, r[0]),
1567
- body: str.slice(r[0] + ma.length, r[1]),
1568
- post: str.slice(r[1] + mb.length)
1569
- };
1570
- };
1571
- const maybeMatch = (reg, str)=>{
1572
- const m = str.match(reg);
1573
- return m ? m[0] : null;
1574
- };
1559
+ var external_chokidar_default = /*#__PURE__*/ __rspack_context.n(external_chokidar_namespaceObject);
1575
1560
  const range = (a, b, str)=>{
1576
1561
  let begs, beg, left, right, result;
1577
1562
  let ai = str.indexOf(a);
@@ -1611,11 +1596,11 @@ var __webpack_exports__ = {};
1611
1596
  }
1612
1597
  return result;
1613
1598
  };
1614
- const escSlash = '\0SLASH' + Math.random() + '\0';
1615
- const escOpen = '\0OPEN' + Math.random() + '\0';
1616
- const escClose = '\0CLOSE' + Math.random() + '\0';
1617
- const escComma = '\0COMMA' + Math.random() + '\0';
1618
- const escPeriod = '\0PERIOD' + Math.random() + '\0';
1599
+ const escSlash = '\0SLASH' + Math.random().toFixed(16) + '\0';
1600
+ const escOpen = '\0OPEN' + Math.random().toFixed(16) + '\0';
1601
+ const escClose = '\0CLOSE' + Math.random().toFixed(16) + '\0';
1602
+ const escComma = '\0COMMA' + Math.random().toFixed(16) + '\0';
1603
+ const escPeriod = '\0PERIOD' + Math.random().toFixed(16) + '\0';
1619
1604
  const escSlashPattern = new RegExp(escSlash, 'g');
1620
1605
  const escOpenPattern = new RegExp(escOpen, 'g');
1621
1606
  const escClosePattern = new RegExp(escClose, 'g');
@@ -1628,6 +1613,10 @@ var __webpack_exports__ = {};
1628
1613
  const periodPattern = /\\\./g;
1629
1614
  const EXPANSION_MAX = 100000;
1630
1615
  const EXPANSION_MAX_LENGTH = 4000000;
1616
+ const EXPANSION_MAX_DEPTH = 1000;
1617
+ const EXPANSION_MAX_REWRITES = 1000;
1618
+ const EXPANSION_MAX_STEPS = 20000000;
1619
+ const CALL_STEPS = 16;
1631
1620
  function numeric(str) {
1632
1621
  return isNaN(str) ? str.charCodeAt(0) : parseInt(str, 10);
1633
1622
  }
@@ -1637,29 +1626,91 @@ var __webpack_exports__ = {};
1637
1626
  function unescapeBraces(str) {
1638
1627
  return str.replace(escSlashPattern, '\\').replace(escOpenPattern, '{').replace(escClosePattern, '}').replace(escCommaPattern, ',').replace(escPeriodPattern, '.');
1639
1628
  }
1640
- function parseCommaParts(str) {
1641
- if (!str) return [
1642
- ''
1643
- ];
1629
+ function pushAll(target, items) {
1630
+ for(let i = 0; i < items.length; i++)target.push(items[i]);
1631
+ }
1632
+ function balancedWithBudget(str, masked, budget) {
1633
+ if (budget.remaining < 0) return;
1634
+ const r = range('{', '}', masked);
1635
+ const unmatched = void 0 !== r && masked.indexOf('{') < r[0];
1636
+ budget.remaining -= r && !unmatched ? r[1] + 1 : str.length;
1637
+ if (!r || budget.remaining < 0) return;
1638
+ return {
1639
+ end: r[1],
1640
+ pre: str.slice(0, r[0]),
1641
+ body: str.slice(r[0] + 1, r[1]),
1642
+ post: str.slice(r[1] + 1),
1643
+ unmatched
1644
+ };
1645
+ }
1646
+ function maskUnmatchedOpens(masked, budget) {
1647
+ budget.remaining -= masked.length;
1648
+ const open = [];
1649
+ for(let i = 0; i < masked.length; i++){
1650
+ const c = masked.charCodeAt(i);
1651
+ if (0x7b === c) open.push(i);
1652
+ else if (0x7d === c && open.length) open.pop();
1653
+ }
1654
+ let out = '';
1655
+ let last = 0;
1656
+ for(let i = 0; i < open.length; i++){
1657
+ const at = open[i];
1658
+ out += masked.slice(last, at) + '\0';
1659
+ last = at + 1;
1660
+ }
1661
+ return out + masked.slice(last);
1662
+ }
1663
+ function commaSetFollows(str, budget) {
1664
+ budget.remaining -= str.length;
1665
+ if (budget.remaining < 0) return false;
1666
+ let close = false;
1667
+ for(let i = str.length - 1; i >= 0; i--){
1668
+ const c = str.charCodeAt(i);
1669
+ if (0x7d === c) close = true;
1670
+ else if (0x0a === c || 0x0d === c || 0x2028 === c || 0x2029 === c) close = false;
1671
+ else if (0x2c === c && close && 0x2c !== str.charCodeAt(i + 1)) return true;
1672
+ }
1673
+ return false;
1674
+ }
1675
+ function parseCommaParts(str, budget) {
1644
1676
  const parts = [];
1645
- const m = balanced('{', '}', str);
1646
- if (!m) return str.split(',');
1647
- const { pre, body, post } = m;
1648
- const p = pre.split(',');
1649
- p[p.length - 1] += '{' + body + '}';
1650
- const postParts = parseCommaParts(post);
1651
- if (post.length) {
1652
- p[p.length - 1] += postParts.shift();
1653
- p.push.apply(p, postParts);
1654
- }
1655
- parts.push.apply(parts, p);
1656
- return parts;
1677
+ let carry = '';
1678
+ for(;;){
1679
+ const m = balancedWithBudget(str, str, budget);
1680
+ if (budget.remaining < 0) return;
1681
+ if (!m) {
1682
+ const tail = str.split(',');
1683
+ tail[0] = carry + tail[0];
1684
+ pushAll(parts, tail);
1685
+ return parts;
1686
+ }
1687
+ const { pre, body, post } = m;
1688
+ const p = pre.split(',');
1689
+ p[0] = carry + p[0];
1690
+ p[p.length - 1] += '{' + body + '}';
1691
+ if (!post.length) {
1692
+ pushAll(parts, p);
1693
+ return parts;
1694
+ }
1695
+ carry = p.pop();
1696
+ pushAll(parts, p);
1697
+ str = post;
1698
+ }
1699
+ }
1700
+ function bound(value, fallback) {
1701
+ return void 0 === value || isNaN(value) ? fallback : value;
1657
1702
  }
1658
1703
  function expand(str, options = {}) {
1659
1704
  if (!str) return [];
1660
- const { max = EXPANSION_MAX, maxLength = EXPANSION_MAX_LENGTH } = options;
1705
+ const max = bound(options.max, EXPANSION_MAX);
1706
+ const maxLength = bound(options.maxLength, EXPANSION_MAX_LENGTH);
1707
+ const maxDepth = bound(options.maxDepth, EXPANSION_MAX_DEPTH);
1708
+ const maxRewrites = bound(options.maxRewrites, EXPANSION_MAX_REWRITES);
1709
+ const maxSteps = bound(options.maxSteps, EXPANSION_MAX_STEPS);
1661
1710
  if ('{}' === str.slice(0, 2)) str = '\\{\\}' + str.slice(2);
1662
- return expand_(escapeBraces(str), max, maxLength, true).map(unescapeBraces);
1711
+ return expand_(escapeBraces(str), max, maxLength, maxDepth, 0, maxRewrites, {
1712
+ remaining: maxSteps
1713
+ }, true).map(unescapeBraces);
1663
1714
  }
1664
1715
  function embrace(str) {
1665
1716
  return '{' + str + '}';
@@ -1673,21 +1724,29 @@ var __webpack_exports__ = {};
1673
1724
  function gte(i, y) {
1674
1725
  return i >= y;
1675
1726
  }
1676
- function combine(acc, pre, values, max, maxLength, dropEmpties) {
1727
+ function combine(acc, pre, values, max, maxLength, dropEmpties, budget) {
1677
1728
  const out = [];
1678
1729
  let length = 0;
1679
- for(let a = 0; a < acc.length; a++)for(let v = 0; v < values.length; v++){
1680
- if (out.length >= max) return out;
1681
- const expansion = acc[a] + pre + values[v];
1682
- if (!dropEmpties || expansion) {
1683
- if (length + expansion.length > maxLength) return out;
1730
+ let nonEmpty;
1731
+ outer: for(let a = 0; a < acc.length; a++){
1732
+ const prefix = acc[a] + pre;
1733
+ let vs = values;
1734
+ if (dropEmpties && !prefix) {
1735
+ if (!nonEmpty) nonEmpty = values.filter((v)=>v);
1736
+ vs = nonEmpty;
1737
+ }
1738
+ for(let v = 0; v < vs.length; v++){
1739
+ if (out.length >= max) break outer;
1740
+ const expansion = prefix + vs[v];
1741
+ if (length + expansion.length > maxLength) break outer;
1684
1742
  out.push(expansion);
1685
1743
  length += expansion.length;
1686
1744
  }
1687
1745
  }
1746
+ budget.remaining -= out.length;
1688
1747
  return out;
1689
1748
  }
1690
- function expandSequence(body, isAlphaSequence, max, maxLength) {
1749
+ function expandSequence(body, isAlphaSequence, max, maxLength, budget) {
1691
1750
  const n = body.split(/\.\./);
1692
1751
  const N = [];
1693
1752
  if (void 0 === n[0] || void 0 === n[1]) return N;
@@ -1702,8 +1761,11 @@ var __webpack_exports__ = {};
1702
1761
  test = gte;
1703
1762
  }
1704
1763
  const pad = n.some(isPadded);
1764
+ const cost = pad ? width : 1;
1705
1765
  let length = 0;
1706
1766
  for(let i = x; test(i, y) && N.length < max; i += incr){
1767
+ budget.remaining -= cost;
1768
+ if (budget.remaining < 0) return;
1707
1769
  let c;
1708
1770
  if (isAlphaSequence) {
1709
1771
  c = String.fromCharCode(i);
@@ -1724,25 +1786,36 @@ var __webpack_exports__ = {};
1724
1786
  }
1725
1787
  return N;
1726
1788
  }
1727
- function expand_(str, max, maxLength, isTop) {
1789
+ function expand_(str, max, maxLength, maxDepth, depth, maxRewrites, budget, isTop) {
1790
+ budget.remaining -= CALL_STEPS;
1791
+ if (depth > maxDepth) return [
1792
+ str
1793
+ ];
1728
1794
  let acc = [
1729
1795
  ''
1730
1796
  ];
1797
+ let rewrites = 0;
1731
1798
  let dropEmpties = false;
1732
1799
  let firstGroup = true;
1800
+ let masked = str;
1733
1801
  for(;;){
1734
- const m = balanced('{', '}', str);
1802
+ const m = balancedWithBudget(str, masked, budget);
1735
1803
  if (!m) return combine(acc, str, [
1736
1804
  ''
1737
- ], max, maxLength, dropEmpties);
1805
+ ], max, maxLength, dropEmpties, budget);
1806
+ if (m.unmatched) masked = maskUnmatchedOpens(masked, budget);
1738
1807
  const pre = m.pre;
1808
+ const literal = ()=>combine(acc, pre + '{' + m.body + '}' + m.post, [
1809
+ ''
1810
+ ], max, maxLength, dropEmpties, budget);
1739
1811
  if (/\$$/.test(pre)) {
1740
1812
  acc = combine(acc, pre + '{' + m.body + '}', [
1741
1813
  ''
1742
- ], max, maxLength, dropEmpties && !m.post.length);
1814
+ ], max, maxLength, dropEmpties && !m.post.length, budget);
1743
1815
  firstGroup = false;
1744
1816
  if (!m.post.length) break;
1745
1817
  str = m.post;
1818
+ masked = masked.slice(m.end + 1);
1746
1819
  continue;
1747
1820
  }
1748
1821
  const isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
@@ -1750,31 +1823,38 @@ var __webpack_exports__ = {};
1750
1823
  const isSequence = isNumericSequence || isAlphaSequence;
1751
1824
  const isOptions = m.body.indexOf(',') >= 0;
1752
1825
  if (!isSequence && !isOptions) {
1753
- if (m.post.match(/,(?!,).*\}/)) {
1826
+ if (rewrites < maxRewrites && commaSetFollows(m.post, budget)) {
1827
+ rewrites++;
1754
1828
  str = m.pre + '{' + m.body + escClose + m.post;
1829
+ masked = masked.slice(0, m.end) + escClose + masked.slice(m.end + 1);
1755
1830
  isTop = true;
1756
1831
  continue;
1757
1832
  }
1758
- return combine(acc, pre + '{' + m.body + '}' + m.post, [
1759
- ''
1760
- ], max, maxLength, dropEmpties);
1833
+ return literal();
1761
1834
  }
1762
1835
  if (firstGroup) {
1763
1836
  dropEmpties = isTop && !isSequence;
1764
1837
  firstGroup = false;
1765
1838
  }
1766
1839
  let values;
1767
- if (isSequence) values = expandSequence(m.body, isAlphaSequence, max, maxLength);
1768
- else {
1769
- let n = parseCommaParts(m.body);
1840
+ if (isSequence) {
1841
+ values = expandSequence(m.body, isAlphaSequence, max, maxLength, budget);
1842
+ if (!values) return literal();
1843
+ } else {
1844
+ let n = parseCommaParts(m.body, budget);
1845
+ if (!n) return literal();
1770
1846
  if (1 === n.length && void 0 !== n[0]) {
1771
- n = expand_(n[0], max, maxLength, false).map(embrace);
1847
+ n = expand_(n[0], max, maxLength, maxDepth, depth + 1, maxRewrites, budget, false).map(embrace);
1848
+ if (budget.remaining < 0) return literal();
1772
1849
  if (1 === n.length) {
1773
- acc = combine(acc, pre + n[0], [
1850
+ const next = combine(acc, pre + n[0], [
1774
1851
  ''
1775
- ], max, maxLength, dropEmpties && !m.post.length);
1852
+ ], max, maxLength, dropEmpties && !m.post.length, budget);
1853
+ if (budget.remaining < 0) return literal();
1854
+ acc = next;
1776
1855
  if (!m.post.length) break;
1777
1856
  str = m.post;
1857
+ masked = masked.slice(m.end + 1);
1778
1858
  continue;
1779
1859
  }
1780
1860
  }
@@ -1783,7 +1863,8 @@ var __webpack_exports__ = {};
1783
1863
  values = [];
1784
1864
  let valuesLength = 0;
1785
1865
  outer: for(let j = 0; j < n.length; j++){
1786
- const expanded = expand_(n[j], max, maxLength, false);
1866
+ const expanded = expand_(n[j], max, maxLength, maxDepth, depth + 1, maxRewrites, budget, false);
1867
+ if (budget.remaining < 0) return literal();
1787
1868
  for(let k = 0; k < expanded.length; k++){
1788
1869
  const v = expanded[k];
1789
1870
  if (!dropsEmpties || v) {
@@ -1794,93 +1875,148 @@ var __webpack_exports__ = {};
1794
1875
  }
1795
1876
  }
1796
1877
  }
1797
- acc = combine(acc, pre, values, max, maxLength, dropEmpties && !m.post.length);
1878
+ const next = combine(acc, pre, values, max, maxLength, dropEmpties && !m.post.length, budget);
1879
+ if (budget.remaining < 0) return literal();
1880
+ acc = next;
1798
1881
  if (!m.post.length) break;
1799
1882
  str = m.post;
1883
+ masked = masked.slice(m.end + 1);
1800
1884
  }
1801
1885
  return acc;
1802
1886
  }
1803
- const MAX_PATTERN_LENGTH = 65536;
1804
- const assertValidPattern = (pattern)=>{
1805
- if ('string' != typeof pattern) throw new TypeError('invalid pattern');
1806
- if (pattern.length > MAX_PATTERN_LENGTH) throw new TypeError('pattern is too long');
1887
+ const digit = (a, b)=>a === b ? {
1888
+ t: 'lit',
1889
+ ch: String(a)
1890
+ } : {
1891
+ t: 'class',
1892
+ re: new RegExp(`^[${a}-${b}]$`)
1893
+ };
1894
+ const numeric_range_prefix = (d, alts)=>alts.map((s)=>[
1895
+ digit(d, d),
1896
+ ...s
1897
+ ]);
1898
+ const fixed = (a, b)=>{
1899
+ if (!a) return [
1900
+ []
1901
+ ];
1902
+ let lo = +a[0];
1903
+ let hi = +b[0];
1904
+ const ra = a.slice(1);
1905
+ const rb = b.slice(1);
1906
+ if (lo === hi) return numeric_range_prefix(lo, fixed(ra, rb));
1907
+ const zeros = '0'.repeat(ra.length);
1908
+ const nines = '9'.repeat(ra.length);
1909
+ const out = [];
1910
+ if (ra !== zeros) out.push(...numeric_range_prefix(lo++, fixed(ra, nines)));
1911
+ const last = rb === nines ? [] : numeric_range_prefix(hi--, fixed(zeros, rb));
1912
+ if (lo <= hi) out.push([
1913
+ digit(lo, hi),
1914
+ ...Array.from(ra, ()=>digit(0, 9))
1915
+ ]);
1916
+ out.push(...last);
1917
+ return out;
1918
+ };
1919
+ const nonneg = (a, b, width)=>{
1920
+ if (width) return fixed(String(a).padStart(width, '0'), String(b).padStart(width, '0'));
1921
+ const out = [];
1922
+ for(let len = String(a).length; len <= String(b).length; len++){
1923
+ const lo = Math.max(a, 1 === len ? 0 : 10 ** (len - 1));
1924
+ const hi = Math.min(b, 10 ** len - 1);
1925
+ out.push(...fixed(String(lo), String(hi)));
1926
+ }
1927
+ return out;
1928
+ };
1929
+ const numericRange = (loStr, hiStr)=>{
1930
+ let lo = Number(loStr);
1931
+ let hi = Number(hiStr);
1932
+ if (!Number.isSafeInteger(lo) || !Number.isSafeInteger(hi)) return;
1933
+ if (lo > hi) [lo, hi] = [
1934
+ hi,
1935
+ lo
1936
+ ];
1937
+ const padded = /^-?0\d/.test(loStr) || /^-?0\d/.test(hiStr);
1938
+ const width = padded ? Math.max(loStr.length, hiStr.length) : 0;
1939
+ const out = [];
1940
+ if (lo < 0) {
1941
+ const neg = nonneg(Math.max(-hi, 1), -lo, width && width - 1);
1942
+ out.push(...neg.map((s)=>[
1943
+ {
1944
+ t: 'lit',
1945
+ ch: '-'
1946
+ },
1947
+ ...s
1948
+ ]));
1949
+ }
1950
+ if (hi >= 0) out.push(...nonneg(Math.max(lo, 0), hi, width));
1951
+ return out;
1807
1952
  };
1808
1953
  const posixClasses = {
1809
1954
  '[:alnum:]': [
1810
- '\\p{L}\\p{Nl}\\p{Nd}',
1811
- true
1955
+ '\\p{L}\\p{Nl}\\p{Nd}'
1812
1956
  ],
1813
1957
  '[:alpha:]': [
1814
- '\\p{L}\\p{Nl}',
1815
- true
1958
+ '\\p{L}\\p{Nl}'
1816
1959
  ],
1817
1960
  '[:ascii:]': [
1818
- "\\x00-\\x7f",
1819
- false
1961
+ "\\x00-\\x7f"
1820
1962
  ],
1821
1963
  '[:blank:]': [
1822
- '\\p{Zs}\\t',
1823
- true
1964
+ '\\p{Zs}\\t'
1824
1965
  ],
1825
1966
  '[:cntrl:]': [
1826
- '\\p{Cc}',
1827
- true
1967
+ '\\p{Cc}'
1828
1968
  ],
1829
1969
  '[:digit:]': [
1830
- '\\p{Nd}',
1831
- true
1970
+ '\\p{Nd}'
1832
1971
  ],
1833
1972
  '[:graph:]': [
1834
1973
  '\\p{Z}\\p{C}',
1835
- true,
1836
1974
  true
1837
1975
  ],
1838
1976
  '[:lower:]': [
1839
- '\\p{Ll}',
1840
- true
1977
+ '\\p{Ll}'
1841
1978
  ],
1842
1979
  '[:print:]': [
1843
1980
  '\\p{C}',
1844
1981
  true
1845
1982
  ],
1846
1983
  '[:punct:]': [
1847
- '\\p{P}',
1848
- true
1984
+ '\\p{P}\\p{S}'
1849
1985
  ],
1850
1986
  '[:space:]': [
1851
- '\\p{Z}\\t\\r\\n\\v\\f',
1852
- true
1987
+ '\\p{Z}\\t\\r\\n\\v\\f'
1853
1988
  ],
1854
1989
  '[:upper:]': [
1855
- '\\p{Lu}',
1856
- true
1990
+ '\\p{Lu}'
1857
1991
  ],
1858
1992
  '[:word:]': [
1859
- '\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}',
1860
- true
1993
+ '\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}'
1861
1994
  ],
1862
1995
  '[:xdigit:]': [
1863
- 'A-Fa-f0-9',
1864
- false
1996
+ 'A-Fa-f0-9'
1865
1997
  ]
1866
1998
  };
1867
1999
  const braceEscape = (s)=>s.replace(/[[\]\\-]/g, '\\$&');
1868
- const regexpEscape = (s)=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
1869
- const rangesToString = (ranges)=>ranges.join('');
1870
- const parseClass = (glob, position)=>{
2000
+ const noMatch = /$./;
2001
+ const parseClass = (glob, position, nocase = false, form)=>{
2002
+ const norm = (c)=>{
2003
+ const n = form ? c.normalize(form) : c;
2004
+ return 1 === [
2005
+ ...n
2006
+ ].length ? n : c;
2007
+ };
1871
2008
  const pos = position;
1872
2009
  if ('[' !== glob.charAt(pos)) throw new Error('not in a brace expression');
1873
2010
  const ranges = [];
1874
2011
  const negs = [];
1875
2012
  let i = pos + 1;
1876
2013
  let sawStart = false;
1877
- let uflag = false;
1878
2014
  let escaping = false;
1879
2015
  let negate = false;
1880
2016
  let endPos = pos;
1881
2017
  let rangeStart = '';
1882
2018
  WHILE: while(i < glob.length){
1883
- const c = glob.charAt(i);
2019
+ const c = String.fromCodePoint(glob.codePointAt(i));
1884
2020
  if (('!' === c || '^' === c) && i === pos + 1) {
1885
2021
  negate = true;
1886
2022
  i++;
@@ -1899,762 +2035,844 @@ var __webpack_exports__ = {};
1899
2035
  }
1900
2036
  }
1901
2037
  if ('[' === c && !escaping) {
1902
- for (const [cls, [unip, u, neg]] of Object.entries(posixClasses))if (glob.startsWith(cls, i)) {
2038
+ for (const [cls, [unip, neg]] of Object.entries(posixClasses))if (glob.startsWith(cls, i)) {
1903
2039
  if (rangeStart) return [
1904
- '$.',
1905
- false,
1906
- glob.length - pos,
1907
- true
2040
+ noMatch,
2041
+ glob.length - pos
1908
2042
  ];
1909
2043
  i += cls.length;
1910
2044
  if (neg) negs.push(unip);
1911
2045
  else ranges.push(unip);
1912
- uflag = uflag || u;
1913
2046
  continue WHILE;
1914
2047
  }
1915
2048
  }
1916
2049
  escaping = false;
2050
+ const n = norm(c);
1917
2051
  if (rangeStart) {
1918
- if (c > rangeStart) ranges.push(braceEscape(rangeStart) + '-' + braceEscape(c));
1919
- else if (c === rangeStart) ranges.push(braceEscape(c));
2052
+ if (n.codePointAt(0) > rangeStart.codePointAt(0)) ranges.push(braceEscape(rangeStart) + '-' + braceEscape(n));
2053
+ else if (n === rangeStart) ranges.push(braceEscape(n));
1920
2054
  rangeStart = '';
1921
- i++;
2055
+ i += c.length;
1922
2056
  continue;
1923
2057
  }
1924
- if (glob.startsWith('-]', i + 1)) {
1925
- ranges.push(braceEscape(c + '-'));
1926
- i += 2;
2058
+ if (glob.startsWith('-]', i + c.length)) {
2059
+ ranges.push(braceEscape(n + '-'));
2060
+ i += c.length + 1;
1927
2061
  continue;
1928
2062
  }
1929
- if (glob.startsWith('-', i + 1)) {
1930
- rangeStart = c;
1931
- i += 2;
2063
+ if (glob.startsWith('-', i + c.length)) {
2064
+ rangeStart = n;
2065
+ i += c.length + 1;
1932
2066
  continue;
1933
2067
  }
1934
- ranges.push(braceEscape(c));
1935
- i++;
2068
+ ranges.push(braceEscape(n));
2069
+ i += c.length;
1936
2070
  }
1937
2071
  if (endPos < i) return [
1938
- '',
1939
- false,
1940
- 0,
1941
- false
2072
+ noMatch,
2073
+ 0
1942
2074
  ];
1943
2075
  if (!ranges.length && !negs.length) return [
1944
- '$.',
1945
- false,
1946
- glob.length - pos,
1947
- true
2076
+ noMatch,
2077
+ glob.length - pos
1948
2078
  ];
1949
- if (0 === negs.length && 1 === ranges.length && /^\\?.$/.test(ranges[0]) && !negate) {
1950
- const r = 2 === ranges[0].length ? ranges[0].slice(-1) : ranges[0];
1951
- return [
1952
- regexpEscape(r),
1953
- false,
1954
- endPos - pos,
1955
- false
1956
- ];
1957
- }
1958
- const sranges = '[' + (negate ? '^' : '') + rangesToString(ranges) + ']';
1959
- const snegs = '[' + (negate ? '' : '^') + rangesToString(negs) + ']';
1960
- const comb = ranges.length && negs.length ? '(' + sranges + '|' + snegs + ')' : ranges.length ? sranges : snegs;
2079
+ const sranges = '[' + (negate ? '^' : '') + ranges.join('') + ']';
2080
+ const snegs = '[' + (negate ? '' : '^') + negs.join('') + ']';
2081
+ const comb = '^' + (ranges.length && negs.length ? '(' + sranges + '|' + snegs + ')' : ranges.length ? sranges : snegs);
1961
2082
  return [
1962
- comb,
1963
- uflag,
1964
- endPos - pos,
1965
- true
2083
+ new RegExp(comb, nocase ? 'iu' : 'u'),
2084
+ endPos - pos
1966
2085
  ];
1967
2086
  };
1968
- const unescape_unescape = (s, { windowsPathsNoEscape = false, magicalBraces = true } = {})=>{
1969
- if (magicalBraces) return windowsPathsNoEscape ? s.replace(/\[([^/\\])\]/g, '$1') : s.replace(/((?!\\).|^)\[([^/\\])\]/g, '$1$2').replace(/\\([^/])/g, '$1');
1970
- return windowsPathsNoEscape ? s.replace(/\[([^/\\{}])\]/g, '$1') : s.replace(/((?!\\).|^)\[([^/\\{}])\]/g, '$1$2').replace(/\\([^/{}])/g, '$1');
2087
+ const MATCH = {
2088
+ t: 'match',
2089
+ id: 0
1971
2090
  };
1972
- var _a;
1973
- const types = new Set([
1974
- '!',
1975
- '?',
1976
- '+',
1977
- '*',
1978
- '@'
1979
- ]);
1980
- const isExtglobType = (c)=>types.has(c);
1981
- const isExtglobAST = (c)=>isExtglobType(c.type);
1982
- const adoptionMap = new Map([
1983
- [
1984
- '!',
1985
- [
1986
- '@'
1987
- ]
1988
- ],
1989
- [
1990
- '?',
1991
- [
1992
- '?',
1993
- '@'
1994
- ]
1995
- ],
1996
- [
1997
- '@',
1998
- [
1999
- '@'
2000
- ]
2001
- ],
2002
- [
2003
- '*',
2004
- [
2005
- '*',
2006
- '+',
2007
- '?',
2008
- '@'
2009
- ]
2010
- ],
2011
- [
2012
- '+',
2013
- [
2014
- '+',
2015
- '@'
2016
- ]
2017
- ]
2018
- ]);
2019
- const adoptionWithSpaceMap = new Map([
2020
- [
2021
- '!',
2022
- [
2023
- '?'
2024
- ]
2025
- ],
2026
- [
2027
- '@',
2028
- [
2029
- '?'
2030
- ]
2031
- ],
2032
- [
2033
- '+',
2034
- [
2035
- '?',
2036
- '*'
2037
- ]
2038
- ]
2039
- ]);
2040
- const adoptionAnyMap = new Map([
2041
- [
2042
- '!',
2043
- [
2044
- '?',
2045
- '@'
2046
- ]
2047
- ],
2048
- [
2049
- '?',
2050
- [
2051
- '?',
2052
- '@'
2053
- ]
2054
- ],
2055
- [
2056
- '@',
2057
- [
2058
- '?',
2059
- '@'
2060
- ]
2061
- ],
2062
- [
2063
- '*',
2064
- [
2065
- '*',
2066
- '+',
2067
- '?',
2068
- '@'
2069
- ]
2070
- ],
2071
- [
2072
- '+',
2073
- [
2074
- '+',
2075
- '@',
2076
- '?',
2077
- '*'
2078
- ]
2079
- ]
2080
- ]);
2081
- const usurpMap = new Map([
2082
- [
2083
- '!',
2084
- new Map([
2085
- [
2086
- '!',
2087
- '@'
2088
- ]
2089
- ])
2090
- ],
2091
- [
2092
- '?',
2093
- new Map([
2094
- [
2095
- '*',
2096
- '*'
2097
- ],
2098
- [
2099
- '+',
2100
- '*'
2101
- ]
2102
- ])
2103
- ],
2104
- [
2105
- '@',
2106
- new Map([
2107
- [
2108
- '!',
2109
- '!'
2110
- ],
2111
- [
2112
- '?',
2113
- '?'
2114
- ],
2115
- [
2116
- '@',
2117
- '@'
2118
- ],
2119
- [
2120
- '*',
2121
- '*'
2122
- ],
2123
- [
2124
- '+',
2125
- '+'
2126
- ]
2127
- ])
2128
- ],
2129
- [
2130
- '+',
2131
- new Map([
2132
- [
2133
- '?',
2134
- '*'
2135
- ],
2136
- [
2137
- '*',
2138
- '*'
2139
- ]
2140
- ])
2141
- ]
2142
- ]);
2143
- const startNoTraversal = '(?!(?:^|/)\\.\\.?(?:$|/))';
2144
- const startNoDot = '(?!\\.)';
2145
- const addPatternStart = new Set([
2146
- '[',
2147
- '.'
2148
- ]);
2149
- const justDots = new Set([
2150
- '..',
2151
- '.'
2152
- ]);
2153
- const reSpecials = new Set('().*{}+?[]^$\\!');
2154
- const regExpEscape = (s)=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
2155
- const qmark = '[^/]';
2156
- const star = qmark + '*?';
2157
- const starNoEmpty = qmark + '+?';
2158
- let ID = 0;
2159
- class ast_AST {
2160
- type;
2161
- #root;
2162
- #hasMagic;
2163
- #uflag = false;
2164
- #parts = [];
2165
- #parent;
2166
- #parentIndex;
2167
- #negs;
2168
- #filledNegs = false;
2169
- #options;
2170
- #toString;
2171
- #emptyExt = false;
2172
- id = ++ID;
2173
- get depth() {
2174
- return (this.#parent?.depth ?? -1) + 1;
2175
- }
2176
- [Symbol.for('nodejs.util.inspect.custom')]() {
2177
- return {
2178
- '@@type': 'AST',
2179
- id: this.id,
2180
- type: this.type,
2181
- root: this.#root.id,
2182
- parent: this.#parent?.id,
2183
- depth: this.depth,
2184
- partsLength: this.#parts.length,
2185
- parts: this.#parts
2186
- };
2187
- }
2188
- constructor(type, parent, options = {}){
2189
- this.type = type;
2190
- if (type) this.#hasMagic = true;
2191
- this.#parent = parent;
2192
- this.#root = this.#parent ? this.#parent.#root : this;
2193
- this.#options = this.#root === this ? options : this.#root.#options;
2194
- this.#negs = this.#root === this ? [] : this.#root.#negs;
2195
- if ('!' === type && !this.#root.#filledNegs) this.#negs.push(this);
2196
- this.#parentIndex = this.#parent ? this.#parent.#parts.length : 0;
2197
- }
2198
- get hasMagic() {
2199
- if (void 0 !== this.#hasMagic) return this.#hasMagic;
2200
- for (const p of this.#parts)if ('string' != typeof p) {
2201
- if (p.type || p.hasMagic) return this.#hasMagic = true;
2202
- }
2203
- return this.#hasMagic;
2204
- }
2205
- toString() {
2206
- return void 0 !== this.#toString ? this.#toString : this.type ? this.#toString = this.type + '(' + this.#parts.map((p)=>String(p)).join('|') + ')' : this.#toString = this.#parts.map((p)=>String(p)).join('');
2207
- }
2208
- #fillNegs() {
2209
- if (this !== this.#root) throw new Error('should only call on root');
2210
- if (this.#filledNegs) return this;
2211
- this.toString();
2212
- this.#filledNegs = true;
2213
- let n;
2214
- while(n = this.#negs.pop()){
2215
- if ('!' !== n.type) continue;
2216
- let p = n;
2217
- let pp = p.#parent;
2218
- while(pp){
2219
- for(let i = p.#parentIndex + 1; !pp.type && i < pp.#parts.length; i++)for (const part of n.#parts){
2220
- if ('string' == typeof part) throw new Error('string part in extglob AST??');
2221
- part.copyIn(pp.#parts[i]);
2091
+ const extTypes = '!?+*@';
2092
+ const esm_lit = (ch)=>({
2093
+ t: 'lit',
2094
+ ch
2095
+ });
2096
+ const reEscape = (s)=>s.replace(/[\\^$.*+?()[\]{}|/]/g, '\\$&');
2097
+ const newFoldRe = (s)=>new RegExp(`^${reEscape(s)}$`, 'iu');
2098
+ const foldCache = new Map();
2099
+ const foldRe = (ch)=>{
2100
+ let re = foldCache.get(ch);
2101
+ if (!re) {
2102
+ re = newFoldRe(ch);
2103
+ if (foldCache.size >= 1000) foldCache.clear();
2104
+ foldCache.set(ch, re);
2105
+ }
2106
+ return re;
2107
+ };
2108
+ const litMatch = (l, c)=>{
2109
+ if (c === l.ch) return true;
2110
+ if (!l.re) return false;
2111
+ const code = c.charCodeAt(0);
2112
+ if (code >= 128) return l.re.test(c);
2113
+ const ascii = l.ascii ??= new Uint8Array(128);
2114
+ ascii[code] ||= l.re.test(c) ? 1 : 2;
2115
+ return 1 === ascii[code];
2116
+ };
2117
+ const tokenize = (p, nocase, noext, form, mark)=>{
2118
+ const toks = [];
2119
+ for(let i = 0; i < p.length;){
2120
+ const c = String.fromCodePoint(p.codePointAt(i));
2121
+ if (mark) {
2122
+ const m = '\\' === c && p.startsWith(mark, i + 1) ? 1 : 0;
2123
+ if (m || c === mark) {
2124
+ const start = i + m + mark.length;
2125
+ const end = p.indexOf(mark, start);
2126
+ const r = /^(-?\d+)\.\.(-?\d+)$/.exec(p.slice(start, end));
2127
+ const alts = -1 !== end && r && numericRange(r[1], r[2]);
2128
+ if (alts) {
2129
+ toks.push({
2130
+ t: 'ext',
2131
+ type: '@',
2132
+ alts
2133
+ });
2134
+ i = end + mark.length;
2135
+ continue;
2222
2136
  }
2223
- p = pp;
2224
- pp = p.#parent;
2225
2137
  }
2226
2138
  }
2227
- return this;
2139
+ if ('\\' === c) {
2140
+ const e = p.codePointAt(i + 1);
2141
+ const ch = void 0 === e ? c : String.fromCodePoint(e);
2142
+ toks.push(esm_lit(ch));
2143
+ i += 1 + ch.length;
2144
+ continue;
2145
+ }
2146
+ if ('[' === c) {
2147
+ const [re, consumed] = parseClass(p, i, nocase, form);
2148
+ if (consumed) {
2149
+ toks.push({
2150
+ t: 'class',
2151
+ re
2152
+ });
2153
+ i += consumed;
2154
+ continue;
2155
+ }
2156
+ }
2157
+ if (!noext && extTypes.includes(c) && '(' === p[i + 1]) {
2158
+ toks.push({
2159
+ t: 'open',
2160
+ type: c
2161
+ });
2162
+ i += 2;
2163
+ continue;
2164
+ }
2165
+ toks.push(noext || '|' !== c ? noext || ')' !== c ? '*' === c ? {
2166
+ t: 'star'
2167
+ } : '?' === c ? {
2168
+ t: 'any'
2169
+ } : esm_lit(c) : {
2170
+ t: 'close'
2171
+ } : {
2172
+ t: 'bar'
2173
+ });
2174
+ i += c.length;
2228
2175
  }
2229
- push(...parts) {
2230
- for (const p of parts)if ('' !== p) {
2231
- if ('string' != typeof p && !(p instanceof _a && p.#parent === this)) throw new Error('invalid part: ' + p);
2232
- this.#parts.push(p);
2176
+ return toks;
2177
+ };
2178
+ const pair = (toks)=>{
2179
+ const pairs = new Map();
2180
+ const stack = [];
2181
+ toks.forEach((tok, i)=>{
2182
+ if ('open' === tok.t) stack.push(i);
2183
+ else if ('close' === tok.t && stack.length) pairs.set(stack.pop(), i);
2184
+ });
2185
+ return pairs;
2186
+ };
2187
+ const build = (toks, pairs, start, end, top)=>{
2188
+ let seq = [];
2189
+ const alts = [
2190
+ seq
2191
+ ];
2192
+ for(let i = start; i < end; i++){
2193
+ const tok = toks[i];
2194
+ const close = pairs.get(i);
2195
+ if ('open' === tok.t && void 0 !== close) {
2196
+ const sub = build(toks, pairs, i + 1, close, false);
2197
+ seq.push({
2198
+ t: 'ext',
2199
+ type: tok.type,
2200
+ alts: sub
2201
+ });
2202
+ i = close;
2203
+ } else if ('bar' !== tok.t || top) if ('open' === tok.t) seq.push(esm_lit(tok.type), esm_lit('('));
2204
+ else if ('bar' === tok.t) seq.push(esm_lit('|'));
2205
+ else if ('close' === tok.t) seq.push(esm_lit(')'));
2206
+ else seq.push(tok);
2207
+ else alts.push(seq = []);
2208
+ }
2209
+ return alts;
2210
+ };
2211
+ const esm_normalize = (items, form)=>{
2212
+ const out = [];
2213
+ let run = '';
2214
+ const flush = ()=>{
2215
+ for (const ch of run.normalize(form))out.push(esm_lit(ch));
2216
+ run = '';
2217
+ };
2218
+ for (const it of items){
2219
+ if ('lit' === it.t) {
2220
+ run += it.ch;
2221
+ continue;
2233
2222
  }
2223
+ flush();
2224
+ out.push('ext' === it.t ? {
2225
+ ...it,
2226
+ alts: it.alts.map((a)=>esm_normalize(a, form))
2227
+ } : it);
2234
2228
  }
2235
- toJSON() {
2236
- const ret = null === this.type ? this.#parts.slice().map((p)=>'string' == typeof p ? p : p.toJSON()) : [
2237
- this.type,
2238
- ...this.#parts.map((p)=>p.toJSON())
2239
- ];
2240
- if (this.isStart() && !this.type) ret.unshift([]);
2241
- if (this.isEnd() && (this === this.#root || this.#root.#filledNegs && this.#parent?.type === '!')) ret.push({});
2242
- return ret;
2243
- }
2244
- isStart() {
2245
- if (this.#root === this) return true;
2246
- if (!this.#parent?.isStart()) return false;
2247
- if (0 === this.#parentIndex) return true;
2248
- const p = this.#parent;
2249
- for(let i = 0; i < this.#parentIndex; i++){
2250
- const pp = p.#parts[i];
2251
- if (!(pp instanceof _a && '!' === pp.type)) return false;
2229
+ flush();
2230
+ return out;
2231
+ };
2232
+ const compile = (items, nocase)=>{
2233
+ let id = 1;
2234
+ const split = (out)=>({
2235
+ t: 'split',
2236
+ id: id++,
2237
+ out
2238
+ });
2239
+ const seq = (items, next)=>items.reduceRight((next, it)=>item(it, next), next);
2240
+ const item = (it, next)=>{
2241
+ switch(it.t){
2242
+ case 'lit':
2243
+ const re = nocase ? foldRe(it.ch) : void 0;
2244
+ return {
2245
+ t: 'lit',
2246
+ id: id++,
2247
+ ch: it.ch,
2248
+ re,
2249
+ next
2250
+ };
2251
+ case 'any':
2252
+ case 'star':
2253
+ return {
2254
+ t: it.t,
2255
+ id: id++,
2256
+ next
2257
+ };
2258
+ case 'class':
2259
+ return {
2260
+ t: 'class',
2261
+ id: id++,
2262
+ re: it.re,
2263
+ next
2264
+ };
2265
+ }
2266
+ const alts = (next)=>it.alts.map((a)=>seq(a, next));
2267
+ switch(it.type){
2268
+ case '@':
2269
+ return split(alts(next));
2270
+ case '?':
2271
+ return split([
2272
+ next,
2273
+ ...alts(next)
2274
+ ]);
2275
+ case '!':
2276
+ return {
2277
+ t: 'neg',
2278
+ id: id++,
2279
+ sub: split(alts(MATCH)),
2280
+ next
2281
+ };
2282
+ }
2283
+ const after = split([]);
2284
+ const entry = split(alts(after));
2285
+ after.out.push(next, entry);
2286
+ return '*' === it.type ? after : entry;
2287
+ };
2288
+ const start = seq(items, MATCH);
2289
+ return [
2290
+ start,
2291
+ id
2292
+ ];
2293
+ };
2294
+ const show = (start)=>{
2295
+ const lines = [];
2296
+ const seen = new Set();
2297
+ const ref = (n)=>'match' === n.t ? 'match' : String(n.id);
2298
+ const walk = (n, indent)=>{
2299
+ if ('match' === n.t || seen.has(n)) return;
2300
+ seen.add(n);
2301
+ const line = (desc)=>lines.push(`${indent}${n.id}: ${desc}`);
2302
+ switch(n.t){
2303
+ case 'split':
2304
+ line(`split -> ${n.out.map(ref).join(', ')}`);
2305
+ for (const o of n.out)walk(o, indent);
2306
+ return;
2307
+ case 'neg':
2308
+ line(`!(${ref(n.sub)}) -> ${ref(n.next)}`);
2309
+ walk(n.sub, indent + ' ');
2310
+ return walk(n.next, indent);
2311
+ case 'lit':
2312
+ line(`${JSON.stringify(n.ch)} -> ${ref(n.next)}`);
2313
+ break;
2314
+ case 'class':
2315
+ line(`${n.re} -> ${ref(n.next)}`);
2316
+ break;
2317
+ default:
2318
+ line(`${'any' === n.t ? '?' : '*'} -> ${ref(n.next)}`);
2252
2319
  }
2320
+ walk(n.next, indent);
2321
+ };
2322
+ walk(start, '');
2323
+ return [
2324
+ `start -> ${ref(start)}`,
2325
+ ...lines
2326
+ ].join('\n');
2327
+ };
2328
+ class State {
2329
+ gen;
2330
+ threads = [];
2331
+ match = false;
2332
+ runs = [];
2333
+ ids = [];
2334
+ constructor(gen){
2335
+ this.gen = gen;
2336
+ }
2337
+ get dead() {
2338
+ return !this.threads.length && !this.match && !this.runs.length;
2339
+ }
2340
+ }
2341
+ const sameState = (a, b)=>{
2342
+ if (a.ids.length !== b.ids.length) return false;
2343
+ if (a.runs.length !== b.runs.length) return false;
2344
+ if (a.ids.some((id, i)=>id !== b.ids[i])) return false;
2345
+ return a.runs.every((r)=>b.runs.some((o)=>o.neg === r.neg && sameState(o.state, r.state)));
2346
+ };
2347
+ const esm_marks = (size)=>({
2348
+ has: new Float64Array(size),
2349
+ seen: new Float64Array(size),
2350
+ gen: 0
2351
+ });
2352
+ class Sim {
2353
+ dots;
2354
+ dotStart;
2355
+ #marks;
2356
+ constructor(dots, dotStart, marks){
2357
+ this.dots = dots;
2358
+ this.dotStart = dotStart;
2359
+ this.#marks = marks;
2360
+ }
2361
+ state() {
2362
+ return new State(++this.#marks.gen);
2363
+ }
2364
+ done(state) {
2365
+ state.ids = state.threads.map((n)=>n.id).sort((a, b)=>a - b);
2366
+ if (state.match) state.ids.unshift(MATCH.id);
2367
+ return state;
2368
+ }
2369
+ #visit(state, node) {
2370
+ const { seen } = this.#marks;
2371
+ if (seen[node.id] === state.gen) return false;
2372
+ seen[node.id] = state.gen;
2253
2373
  return true;
2254
2374
  }
2255
- isEnd() {
2256
- if (this.#root === this) return true;
2257
- if (this.#parent?.type === '!') return true;
2258
- if (!this.#parent?.isEnd()) return false;
2259
- if (!this.type) return this.#parent?.isEnd();
2260
- const pl = this.#parent ? this.#parent.#parts.length : 0;
2261
- return this.#parentIndex === pl - 1;
2262
- }
2263
- copyIn(part) {
2264
- if ('string' == typeof part) this.push(part);
2265
- else this.push(part.clone(this));
2266
- }
2267
- clone(parent) {
2268
- const c = new _a(this.type, parent);
2269
- for (const p of this.#parts)c.copyIn(p);
2270
- return c;
2271
- }
2272
- static #parseAST(str, ast, pos, opt, extDepth) {
2273
- const maxDepth = opt.maxExtglobRecursion ?? 2;
2274
- let escaping = false;
2275
- let inBrace = false;
2276
- let braceStart = -1;
2277
- let braceNeg = false;
2278
- if (null === ast.type) {
2279
- let i = pos;
2280
- let acc = '';
2281
- while(i < str.length){
2282
- const c = str.charAt(i++);
2283
- if (escaping || '\\' === c) {
2284
- escaping = !escaping;
2285
- acc += c;
2286
- continue;
2287
- }
2288
- if (inBrace) {
2289
- if (i === braceStart + 1) {
2290
- if ('^' === c || '!' === c) braceNeg = true;
2291
- } else if (']' === c && !(i === braceStart + 2 && braceNeg)) inBrace = false;
2292
- acc += c;
2293
- continue;
2294
- } else if ('[' === c) {
2295
- inBrace = true;
2296
- braceStart = i;
2297
- braceNeg = false;
2298
- acc += c;
2299
- continue;
2300
- }
2301
- const doRecurse = !opt.noext && isExtglobType(c) && '(' === str.charAt(i) && extDepth <= maxDepth;
2302
- if (doRecurse) {
2303
- ast.push(acc);
2304
- acc = '';
2305
- const ext = new _a(c, ast);
2306
- i = _a.#parseAST(str, ext, i, opt, extDepth + 1);
2307
- ast.push(ext);
2308
- continue;
2309
- }
2310
- acc += c;
2311
- }
2312
- ast.push(acc);
2313
- return i;
2314
- }
2315
- let i = pos + 1;
2316
- let part = new _a(null, ast);
2317
- const parts = [];
2318
- let acc = '';
2319
- while(i < str.length){
2320
- const c = str.charAt(i++);
2321
- if (escaping || '\\' === c) {
2322
- escaping = !escaping;
2323
- acc += c;
2324
- continue;
2325
- }
2326
- if (inBrace) {
2327
- if (i === braceStart + 1) {
2328
- if ('^' === c || '!' === c) braceNeg = true;
2329
- } else if (']' === c && !(i === braceStart + 2 && braceNeg)) inBrace = false;
2330
- acc += c;
2331
- continue;
2332
- } else if ('[' === c) {
2333
- inBrace = true;
2334
- braceStart = i;
2335
- braceNeg = false;
2336
- acc += c;
2337
- continue;
2338
- }
2339
- const doRecurse = !opt.noext && isExtglobType(c) && '(' === str.charAt(i) && (extDepth <= maxDepth || ast && ast.#canAdoptType(c));
2340
- if (doRecurse) {
2341
- const depthAdd = ast && ast.#canAdoptType(c) ? 0 : 1;
2342
- part.push(acc);
2343
- acc = '';
2344
- const ext = new _a(c, part);
2345
- part.push(ext);
2346
- i = _a.#parseAST(str, ext, i, opt, extDepth + depthAdd);
2347
- continue;
2348
- }
2349
- if ('|' === c) {
2350
- part.push(acc);
2351
- acc = '';
2352
- parts.push(part);
2353
- part = new _a(null, ast);
2375
+ #addThread(state, node) {
2376
+ const { has } = this.#marks;
2377
+ if (has[node.id] === state.gen) return false;
2378
+ has[node.id] = state.gen;
2379
+ state.threads.push(node);
2380
+ return true;
2381
+ }
2382
+ restricted(i, top) {
2383
+ return top && (this.dots || this.dotStart && 0 === i);
2384
+ }
2385
+ add(state, node, i, top) {
2386
+ switch(node.t){
2387
+ case 'split':
2388
+ if (!this.#visit(state, node)) return;
2389
+ for (const o of node.out)this.add(state, o, i, top);
2390
+ return;
2391
+ case 'neg':
2392
+ if (!this.#visit(state, node)) return;
2393
+ const sub = this.state();
2394
+ this.add(sub, node.sub, i, false);
2395
+ this.done(sub);
2396
+ return this.addRun(state, {
2397
+ t: 'run',
2398
+ neg: node,
2399
+ state: sub
2400
+ }, i, top);
2401
+ case 'star':
2402
+ if (this.restricted(i, top)) return;
2403
+ if (this.#addThread(state, node)) this.add(state, node.next, i, top);
2404
+ return;
2405
+ case 'match':
2406
+ state.match = true;
2407
+ return;
2408
+ default:
2409
+ this.#addThread(state, node);
2410
+ }
2411
+ }
2412
+ addRun(state, run, i, top) {
2413
+ for (const r of state.runs)if (r.neg === run.neg && sameState(r.state, run.state)) return;
2414
+ state.runs.push(run);
2415
+ if (!run.state.match) this.add(state, run.neg.next, i, top);
2416
+ }
2417
+ step(state, c, i, top) {
2418
+ const next = this.state();
2419
+ for (const th of state.threads)switch(th.t){
2420
+ case 'lit':
2421
+ if (litMatch(th, c)) this.add(next, th.next, i + 1, top);
2422
+ break;
2423
+ case 'any':
2424
+ if (!this.restricted(i, top)) this.add(next, th.next, i + 1, top);
2425
+ break;
2426
+ case 'class':
2427
+ if (!this.restricted(i, top) && th.re.test(c)) this.add(next, th.next, i + 1, top);
2428
+ break;
2429
+ case 'star':
2430
+ if (!this.restricted(i, top)) this.add(next, th, i + 1, top);
2431
+ }
2432
+ if (!this.restricted(i, top)) for (const run of state.runs){
2433
+ if (run.state.dead) {
2434
+ this.addRun(next, run, i + 1, top);
2354
2435
  continue;
2355
2436
  }
2356
- if (')' === c) {
2357
- if ('' === acc && 0 === ast.#parts.length) ast.#emptyExt = true;
2358
- part.push(acc);
2359
- acc = '';
2360
- ast.push(...parts, part);
2361
- return i;
2362
- }
2363
- acc += c;
2437
+ const sub = this.step(run.state, c, i, false);
2438
+ this.addRun(next, {
2439
+ t: 'run',
2440
+ neg: run.neg,
2441
+ state: sub
2442
+ }, i + 1, top);
2364
2443
  }
2365
- ast.type = null;
2366
- ast.#hasMagic = void 0;
2367
- ast.#parts = [
2368
- str.substring(pos - 1)
2369
- ];
2370
- return i;
2371
- }
2372
- #canAdoptWithSpace(child) {
2373
- return this.#canAdopt(child, adoptionWithSpaceMap);
2374
- }
2375
- #canAdopt(child, map = adoptionMap) {
2376
- if (!child || 'object' != typeof child || null !== child.type || 1 !== child.#parts.length || null === this.type) return false;
2377
- const gc = child.#parts[0];
2378
- if (!gc || 'object' != typeof gc || null === gc.type) return false;
2379
- return this.#canAdoptType(gc.type, map);
2380
- }
2381
- #canAdoptType(c, map = adoptionAnyMap) {
2382
- return !!map.get(this.type)?.includes(c);
2383
- }
2384
- #adoptWithSpace(child, index) {
2385
- const gc = child.#parts[0];
2386
- const blank = new _a(null, gc, this.options);
2387
- blank.#parts.push('');
2388
- gc.push(blank);
2389
- this.#adopt(child, index);
2390
- }
2391
- #adopt(child, index) {
2392
- const gc = child.#parts[0];
2393
- this.#parts.splice(index, 1, ...gc.#parts);
2394
- for (const p of gc.#parts)if ('object' == typeof p) p.#parent = this;
2395
- this.#toString = void 0;
2396
- }
2397
- #canUsurpType(c) {
2398
- const m = usurpMap.get(this.type);
2399
- return !!m?.has(c);
2400
- }
2401
- #canUsurp(child) {
2402
- if (!child || 'object' != typeof child || null !== child.type || 1 !== child.#parts.length || null === this.type || 1 !== this.#parts.length) return false;
2403
- const gc = child.#parts[0];
2404
- if (!gc || 'object' != typeof gc || null === gc.type) return false;
2405
- return this.#canUsurpType(gc.type);
2406
- }
2407
- #usurp(child) {
2408
- const m = usurpMap.get(this.type);
2409
- const gc = child.#parts[0];
2410
- const nt = m?.get(gc.type);
2411
- if (!nt) return false;
2412
- this.#parts = gc.#parts;
2413
- for (const p of this.#parts)if ('object' == typeof p) p.#parent = this;
2414
- this.type = nt;
2415
- this.#toString = void 0;
2416
- this.#emptyExt = false;
2417
- }
2418
- static fromGlob(pattern, options = {}) {
2419
- const ast = new _a(null, void 0, options);
2420
- _a.#parseAST(pattern, ast, 0, options, 0);
2421
- return ast;
2422
- }
2423
- toMMPattern() {
2424
- if (this !== this.#root) return this.#root.toMMPattern();
2425
- const glob = this.toString();
2426
- const [re, body, hasMagic, uflag] = this.toRegExpSource();
2427
- const anyMagic = hasMagic || this.#hasMagic || this.#options.nocase && !this.#options.nocaseMagicOnly && glob.toUpperCase() !== glob.toLowerCase();
2428
- if (!anyMagic) return body;
2429
- const flags = (this.#options.nocase ? 'i' : '') + (uflag ? 'u' : '');
2430
- return Object.assign(new RegExp(`^${re}$`, flags), {
2431
- _src: re,
2432
- _glob: glob
2433
- });
2444
+ return this.done(next);
2434
2445
  }
2435
- get options() {
2436
- return this.#options;
2437
- }
2438
- toRegExpSource(allowDot) {
2439
- const dot = allowDot ?? !!this.#options.dot;
2440
- if (this.#root === this) {
2441
- this.#flatten();
2442
- this.#fillNegs();
2443
- }
2444
- if (!isExtglobAST(this)) {
2445
- const noEmpty = this.isStart() && this.isEnd() && !this.#parts.some((s)=>'string' != typeof s);
2446
- const src = this.#parts.map((p)=>{
2447
- const [re, _, hasMagic, uflag] = 'string' == typeof p ? _a.#parseGlob(p, this.#hasMagic, noEmpty) : p.toRegExpSource(allowDot);
2448
- this.#hasMagic = this.#hasMagic || hasMagic;
2449
- this.#uflag = this.#uflag || uflag;
2450
- return re;
2451
- }).join('');
2452
- let start = '';
2453
- if (this.isStart()) {
2454
- if ('string' == typeof this.#parts[0]) {
2455
- const dotTravAllowed = 1 === this.#parts.length && justDots.has(this.#parts[0]);
2456
- if (!dotTravAllowed) {
2457
- const aps = addPatternStart;
2458
- const needNoTrav = dot && aps.has(src.charAt(0)) || src.startsWith('\\.') && aps.has(src.charAt(2)) || src.startsWith('\\.\\.') && aps.has(src.charAt(4));
2459
- const needNoDot = !dot && !allowDot && aps.has(src.charAt(0));
2460
- start = needNoTrav ? startNoTraversal : needNoDot ? startNoDot : '';
2461
- }
2462
- }
2463
- }
2464
- let end = '';
2465
- if (this.isEnd() && this.#root.#filledNegs && this.#parent?.type === '!') end = '(?:$|\\/)';
2466
- const final = start + src + end;
2467
- return [
2468
- final,
2469
- unescape_unescape(src),
2470
- this.#hasMagic = !!this.#hasMagic,
2471
- this.#uflag
2472
- ];
2446
+ }
2447
+ const stateKey = (state)=>{
2448
+ const ids = state.ids.join();
2449
+ if (!state.runs.length) return ids;
2450
+ const runs = state.runs.map((r)=>`${r.neg.id}(${stateKey(r.state)})`);
2451
+ return `${ids}|${runs.sort().join('|')}`;
2452
+ };
2453
+ const DFA_BUDGET = 262144;
2454
+ class Dfa {
2455
+ #start;
2456
+ #states = new Map();
2457
+ #size = 0;
2458
+ #plain;
2459
+ #dotStart;
2460
+ #sim;
2461
+ #dotSim;
2462
+ constructor(start, marks){
2463
+ this.#start = start;
2464
+ this.#sim = new Sim(false, false, marks);
2465
+ this.#dotSim = new Sim(false, true, marks);
2466
+ }
2467
+ #make(state) {
2468
+ return {
2469
+ state,
2470
+ match: state.match,
2471
+ dead: state.dead,
2472
+ next: new Map()
2473
+ };
2474
+ }
2475
+ #intern(state) {
2476
+ const key = stateKey(state);
2477
+ const found = this.#states.get(key);
2478
+ if (found) return found;
2479
+ if (this.#size > DFA_BUDGET) this.#clear();
2480
+ const d = this.#make(state);
2481
+ this.#states.set(key, d);
2482
+ this.#size += key.length + 1;
2483
+ return d;
2484
+ }
2485
+ #clear() {
2486
+ this.#states.clear();
2487
+ this.#size = 0;
2488
+ this.#plain = void 0;
2489
+ this.#dotStart = void 0;
2490
+ }
2491
+ start(dotStart) {
2492
+ if (dotStart) {
2493
+ if (this.#dotStart) return this.#dotStart;
2494
+ const state = this.#dotSim.state();
2495
+ this.#dotSim.add(state, this.#start, 0, true);
2496
+ return this.#dotStart = this.#make(this.#dotSim.done(state));
2473
2497
  }
2474
- const repeated = '*' === this.type || '+' === this.type;
2475
- const start = '!' === this.type ? '(?:(?!(?:' : '(?:';
2476
- let body = this.#partsToRegExp(dot);
2477
- if (this.isStart() && this.isEnd() && !body && '!' !== this.type) {
2478
- const s = this.toString();
2479
- const me = this;
2480
- me.#parts = [
2481
- s
2482
- ];
2483
- me.type = null;
2484
- me.#hasMagic = void 0;
2485
- return [
2486
- s,
2487
- unescape_unescape(this.toString()),
2488
- false,
2489
- false
2490
- ];
2498
+ if (this.#plain) return this.#plain;
2499
+ const state = this.#sim.state();
2500
+ this.#sim.add(state, this.#start, 0, true);
2501
+ return this.#plain = this.#intern(this.#sim.done(state));
2502
+ }
2503
+ next(d, c) {
2504
+ const code = c.charCodeAt(0);
2505
+ const found = code < 128 ? void 0 : d.next.get(c);
2506
+ if (found) return found;
2507
+ const n = d === this.#dotStart ? this.#intern(this.#dotSim.step(d.state, c, 0, true)) : this.#intern(this.#sim.step(d.state, c, 1, true));
2508
+ if (code < 128) {
2509
+ if (!d.ascii) {
2510
+ d.ascii = new Array(128);
2511
+ this.#size += 128;
2512
+ }
2513
+ d.ascii[code] = n;
2514
+ } else d.next.set(c, n);
2515
+ this.#size++;
2516
+ return n;
2517
+ }
2518
+ }
2519
+ const linear = (start)=>{
2520
+ const nodes = [];
2521
+ for(let n = start; 'match' !== n.t; n = n.next){
2522
+ if ('split' === n.t || 'neg' === n.t) return;
2523
+ nodes.push(n);
2524
+ }
2525
+ return nodes;
2526
+ };
2527
+ const testLinear = (nodes, chars, start, end)=>{
2528
+ let ni = 0;
2529
+ let ci = start;
2530
+ let starNi = -1;
2531
+ let starCi = 0;
2532
+ while(ci < end){
2533
+ const n = nodes[ni];
2534
+ if (n?.t === 'star') {
2535
+ starNi = ni++;
2536
+ starCi = ci;
2537
+ continue;
2491
2538
  }
2492
- let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot ? '' : this.#partsToRegExp(true);
2493
- if (bodyDotAllowed === body) bodyDotAllowed = '';
2494
- if (bodyDotAllowed) body = `(?:${body})(?:${bodyDotAllowed})*?`;
2495
- let final = '';
2496
- if ('!' === this.type && this.#emptyExt) final = (this.isStart() && !dot ? startNoDot : '') + starNoEmpty;
2497
- else {
2498
- const close = '!' === this.type ? '))' + (!this.isStart() || dot || allowDot ? '' : startNoDot) + star + ')' : '@' === this.type ? ')' : '?' === this.type ? ')?' : '+' === this.type && bodyDotAllowed ? ')' : '*' === this.type && bodyDotAllowed ? ")?" : `)${this.type}`;
2499
- final = start + body + close;
2539
+ const c = chars[ci];
2540
+ if (n && ('any' === n.t || 'lit' === n.t && litMatch(n, c) || 'class' === n.t && n.re.test(c))) {
2541
+ ni++;
2542
+ ci++;
2543
+ continue;
2500
2544
  }
2501
- return [
2502
- final,
2503
- unescape_unescape(body),
2504
- this.#hasMagic = !!this.#hasMagic,
2505
- this.#uflag
2506
- ];
2545
+ if (-1 === starNi) return false;
2546
+ ni = starNi + 1;
2547
+ ci = ++starCi;
2507
2548
  }
2508
- #flatten() {
2509
- if (isExtglobAST(this)) {
2510
- let iterations = 0;
2511
- let done = false;
2512
- do {
2513
- done = true;
2514
- for(let i = 0; i < this.#parts.length; i++){
2515
- const c = this.#parts[i];
2516
- if ('object' == typeof c) {
2517
- c.#flatten();
2518
- if (this.#canAdopt(c)) {
2519
- done = false;
2520
- this.#adopt(c, i);
2521
- } else if (this.#canAdoptWithSpace(c)) {
2522
- done = false;
2523
- this.#adoptWithSpace(c, i);
2524
- } else if (this.#canUsurp(c)) {
2525
- done = false;
2526
- this.#usurp(c);
2527
- }
2528
- }
2529
- }
2530
- }while (!done && ++iterations < 10);
2531
- } else for (const p of this.#parts)if ('object' == typeof p) p.#flatten();
2532
- this.#toString = void 0;
2533
- }
2534
- #partsToRegExp(dot) {
2535
- return this.#parts.map((p)=>{
2536
- if ('string' == typeof p) throw new Error('string type in extglob ast??');
2537
- const [re, _, _hasMagic, uflag] = p.toRegExpSource(dot);
2538
- this.#uflag = this.#uflag || uflag;
2539
- return re;
2540
- }).filter((p)=>!(this.isStart() && this.isEnd()) || !!p).join('|');
2541
- }
2542
- static #parseGlob(glob, hasMagic, noEmpty = false) {
2543
- let escaping = false;
2544
- let re = '';
2545
- let uflag = false;
2546
- let inStar = false;
2547
- for(let i = 0; i < glob.length; i++){
2548
- const c = glob.charAt(i);
2549
- if (escaping) {
2550
- escaping = false;
2551
- re += (reSpecials.has(c) ? '\\' : '') + c;
2552
- continue;
2553
- }
2554
- if ('*' === c) {
2555
- if (inStar) continue;
2556
- inStar = true;
2557
- re += noEmpty && /^[*]+$/.test(glob) ? starNoEmpty : star;
2558
- hasMagic = true;
2559
- continue;
2560
- } else inStar = false;
2561
- if ('\\' === c) {
2562
- if (i === glob.length - 1) re += '\\\\';
2563
- else escaping = true;
2564
- continue;
2549
+ while(nodes[ni]?.t === 'star')ni++;
2550
+ return ni === nodes.length;
2551
+ };
2552
+ const lengths = (items)=>{
2553
+ let min = 0;
2554
+ let max = 0;
2555
+ for (const it of items){
2556
+ const [lo, hi] = itemLengths(it);
2557
+ min += lo;
2558
+ max += hi;
2559
+ }
2560
+ return [
2561
+ min,
2562
+ max
2563
+ ];
2564
+ };
2565
+ const itemLengths = (it)=>{
2566
+ if ('star' === it.t) return [
2567
+ 0,
2568
+ 1 / 0
2569
+ ];
2570
+ if ('ext' !== it.t) return [
2571
+ 1,
2572
+ 1
2573
+ ];
2574
+ if ('!' === it.type) return [
2575
+ 0,
2576
+ 1 / 0
2577
+ ];
2578
+ const alts = it.alts.map(lengths);
2579
+ const min = Math.min(...alts.map((a)=>a[0]));
2580
+ const max = Math.max(...alts.map((a)=>a[1]));
2581
+ const loop = 0 === max ? 0 : 1 / 0;
2582
+ return '@' === it.type ? [
2583
+ min,
2584
+ max
2585
+ ] : '?' === it.type ? [
2586
+ 0,
2587
+ max
2588
+ ] : '*' === it.type ? [
2589
+ 0,
2590
+ loop
2591
+ ] : [
2592
+ min,
2593
+ loop
2594
+ ];
2595
+ };
2596
+ const hasAffix = (lits, chars, start)=>{
2597
+ for(let j = 0; j < lits.length; j++)if (!litMatch(lits[j], chars[start + j])) return false;
2598
+ return true;
2599
+ };
2600
+ const slashOrSurrogate = /[/\ud800-\udfff]/;
2601
+ const surrogate = /[\ud800-\udfff]/;
2602
+ const codePoints = (s)=>surrogate.test(s) ? [
2603
+ ...s
2604
+ ] : s;
2605
+ const noSlash = (s)=>{
2606
+ if (s.includes('/')) throw new Error('can only match a single path portion, got: ' + s);
2607
+ };
2608
+ class Matcher {
2609
+ pattern;
2610
+ options;
2611
+ #start;
2612
+ #size;
2613
+ #marks;
2614
+ #dotsSim;
2615
+ #literal;
2616
+ #literalFold = false;
2617
+ #literalRe;
2618
+ #linear;
2619
+ #wild = false;
2620
+ #min = 0;
2621
+ #max = 1 / 0;
2622
+ #prefix = [];
2623
+ #suffix = [];
2624
+ #prefixStr;
2625
+ #suffixStr;
2626
+ #affix = false;
2627
+ #dfa;
2628
+ #form;
2629
+ constructor(pattern, options = {}){
2630
+ if (pattern.includes('/')) throw new Error('can only match a single path portion, got pattern: ' + pattern);
2631
+ this.pattern = pattern;
2632
+ this.options = options;
2633
+ const { nocase = false, noext = false, normalize: n } = options;
2634
+ this.#form = true === n ? 'NFC' : n || void 0;
2635
+ const literal = /^[?*+@]\(\)$/.test(pattern);
2636
+ const toks = tokenize(pattern, nocase, noext || literal, this.#form, options.rangeMark);
2637
+ let [items] = build(toks, pair(toks), 0, toks.length, true);
2638
+ if (this.#form) items = esm_normalize(items, this.#form);
2639
+ const [start, size] = compile(items, nocase);
2640
+ this.#start = start;
2641
+ this.#size = size;
2642
+ if (items.every((it)=>'lit' === it.t)) {
2643
+ this.#literal = items.map((it)=>it.ch).join('');
2644
+ this.#literalFold = nocase;
2645
+ } else {
2646
+ const lit = (it)=>'lit' !== it.t ? void 0 : nocase ? {
2647
+ ch: it.ch,
2648
+ re: foldRe(it.ch)
2649
+ } : {
2650
+ ch: it.ch
2651
+ };
2652
+ for (const it of items){
2653
+ const l = lit(it);
2654
+ if (!l) break;
2655
+ this.#prefix.push(l);
2565
2656
  }
2566
- if ('[' === c) {
2567
- const [src, needUflag, consumed, magic] = parseClass(glob, i);
2568
- if (consumed) {
2569
- re += src;
2570
- uflag = uflag || needUflag;
2571
- i += consumed - 1;
2572
- hasMagic = hasMagic || magic;
2573
- continue;
2574
- }
2657
+ for(let j = items.length - 1; j >= 0; j--){
2658
+ const l = lit(items[j]);
2659
+ if (!l) break;
2660
+ this.#suffix.unshift(l);
2575
2661
  }
2576
- if ('?' === c) {
2577
- re += qmark;
2578
- hasMagic = true;
2579
- continue;
2662
+ this.#affix = !!(this.#prefix.length || this.#suffix.length);
2663
+ if (!nocase) {
2664
+ this.#prefixStr = this.#prefix.map((l)=>l.ch).join('');
2665
+ this.#suffixStr = this.#suffix.map((l)=>l.ch).join('');
2580
2666
  }
2581
- re += regExpEscape(c);
2667
+ this.#linear = linear(this.#start)?.slice(this.#prefix.length, -this.#suffix.length || void 0);
2668
+ this.#wild = !!this.#linear?.every((n)=>'star' === n.t || 'any' === n.t);
2669
+ const [min, max] = lengths(items);
2670
+ this.#min = min;
2671
+ this.#max = max;
2582
2672
  }
2583
- return [
2584
- re,
2585
- unescape_unescape(glob),
2586
- !!hasMagic,
2587
- uflag
2588
- ];
2673
+ }
2674
+ test(s) {
2675
+ if (this.#form) {
2676
+ noSlash(s);
2677
+ return this.#test(s.normalize(this.#form));
2678
+ }
2679
+ if (slashOrSurrogate.test(s)) {
2680
+ noSlash(s);
2681
+ return this.#test(s, [
2682
+ ...s
2683
+ ]);
2684
+ }
2685
+ return this.#test(s, s);
2686
+ }
2687
+ testUnchecked(s) {
2688
+ return this.#test(this.#form ? s.normalize(this.#form) : s);
2689
+ }
2690
+ #test(s, chars) {
2691
+ if (void 0 !== this.#literal) return this.#literalFold ? (this.#literalRe ??= newFoldRe(this.#literal)).test(s) : s === this.#literal;
2692
+ const min = this.#min;
2693
+ const max = this.#max;
2694
+ if (void 0 === chars) {
2695
+ const most = s.length;
2696
+ const least = most + 1 >> 1;
2697
+ if (most < min || least > max) return false;
2698
+ if (least < min || most > max) chars = codePoints(s);
2699
+ }
2700
+ if (void 0 !== chars && (chars.length < min || chars.length > max)) return false;
2701
+ const prefix = this.#prefix.length;
2702
+ if (this.#affix) if (void 0 !== this.#prefixStr && void 0 !== this.#suffixStr) {
2703
+ if (!s.startsWith(this.#prefixStr) || !s.endsWith(this.#suffixStr)) return false;
2704
+ } else {
2705
+ chars ??= codePoints(s);
2706
+ const end = chars.length - this.#suffix.length;
2707
+ if (!hasAffix(this.#prefix, chars, 0) || !hasAffix(this.#suffix, chars, end)) return false;
2708
+ }
2709
+ const dotStart = !this.options.dot && s.startsWith('.');
2710
+ if (this.#linear) {
2711
+ if ('.' === s || '..' === s) return false;
2712
+ if (dotStart && !prefix) return false;
2713
+ if (this.#wild) return true;
2714
+ chars ??= codePoints(s);
2715
+ const end = chars.length - this.#suffix.length;
2716
+ return testLinear(this.#linear, chars, prefix, end);
2717
+ }
2718
+ chars ??= codePoints(s);
2719
+ if ('.' === s || '..' === s) {
2720
+ this.#marks ??= esm_marks(this.#size);
2721
+ const sim = this.#dotsSim ??= new Sim(true, false, this.#marks);
2722
+ const start = sim.state();
2723
+ sim.add(start, this.#start, 0, true);
2724
+ let state = sim.done(start);
2725
+ for(let i = 0; i < chars.length; i++)state = sim.step(state, chars[i], i, true);
2726
+ return state.match;
2727
+ }
2728
+ this.#marks ??= esm_marks(this.#size);
2729
+ const dfa = this.#dfa ??= new Dfa(this.#start, this.#marks);
2730
+ let d = dfa.start(dotStart);
2731
+ const str = chars === s;
2732
+ for(let i = 0; i < chars.length; i++){
2733
+ if (d.dead) return false;
2734
+ const code = str ? s.charCodeAt(i) : chars[i].charCodeAt(0);
2735
+ d = d.ascii?.[code] ?? dfa.next(d, chars[i]);
2736
+ }
2737
+ return d.match;
2738
+ }
2739
+ toString() {
2740
+ return show(this.#start);
2589
2741
  }
2590
2742
  }
2591
- _a = ast_AST;
2592
- const escape_escape = (s, { windowsPathsNoEscape = false, magicalBraces = false } = {})=>{
2593
- if (magicalBraces) return windowsPathsNoEscape ? s.replace(/[?*()[\]{}]/g, '[$&]') : s.replace(/[?*()[\]\\{}]/g, '\\$&');
2594
- return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, '[$&]') : s.replace(/[?*()[\]\\]/g, '\\$&');
2595
- };
2596
- const minimatch = (p, pattern, options = {})=>{
2597
- assertValidPattern(pattern);
2598
- if (!options.nocomment && '#' === pattern.charAt(0)) return false;
2599
- return new esm_Minimatch(pattern, options).match(p);
2600
- };
2601
- const starDotExtRE = /^\*+([^+@!?*[(]*)$/;
2602
- const starDotExtTest = (ext)=>(f)=>!f.startsWith('.') && f.endsWith(ext);
2603
- const starDotExtTestDot = (ext)=>(f)=>f.endsWith(ext);
2604
- const starDotExtTestNocase = (ext)=>{
2605
- ext = ext.toLowerCase();
2606
- return (f)=>!f.startsWith('.') && f.toLowerCase().endsWith(ext);
2743
+ const MAX_PATTERN_LENGTH = 65536;
2744
+ const assertValidPattern = (pattern)=>{
2745
+ if ('string' != typeof pattern) throw new TypeError('invalid pattern');
2746
+ if (pattern.length > MAX_PATTERN_LENGTH) throw new TypeError('pattern is too long');
2607
2747
  };
2608
- const starDotExtTestNocaseDot = (ext)=>{
2609
- ext = ext.toLowerCase();
2610
- return (f)=>f.toLowerCase().endsWith(ext);
2748
+ const escape_escape = (s, { windowsPathsNoEscape = false, magicalBraces = false } = {})=>{
2749
+ const e = magicalBraces ? windowsPathsNoEscape ? s.replace(/[?*()[\]{}]/g, '[$&]') : s.replace(/[?*()[\]\\{}]/g, '\\$&') : windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, '[$&]') : s.replace(/[?*()[\]\\]/g, '\\$&');
2750
+ const c = e.charAt(0);
2751
+ if ('#' === c) return (windowsPathsNoEscape ? '[#]' : '\\#') + e.slice(1);
2752
+ if ('!' === c) return (windowsPathsNoEscape ? '@(!)' : '\\!') + e.slice(1);
2753
+ return e;
2611
2754
  };
2612
- const starDotStarRE = /^\*+\.\*+$/;
2613
- const starDotStarTest = (f)=>!f.startsWith('.') && f.includes('.');
2614
- const starDotStarTestDot = (f)=>'.' !== f && '..' !== f && f.includes('.');
2615
- const dotStarRE = /^\.\*+$/;
2616
- const dotStarTest = (f)=>'.' !== f && '..' !== f && f.startsWith('.');
2617
- const starRE = /^\*+$/;
2618
- const starTest = (f)=>0 !== f.length && !f.startsWith('.');
2619
- const starTestDot = (f)=>0 !== f.length && '.' !== f && '..' !== f;
2620
- const qmarksRE = /^\?+([^+@!?*[(]*)?$/;
2621
- const qmarksTestNocase = ([$0, ext = ''])=>{
2622
- const noext = qmarksTestNoExt([
2623
- $0
2624
- ]);
2625
- if (!ext) return noext;
2626
- ext = ext.toLowerCase();
2627
- return (f)=>noext(f) && f.toLowerCase().endsWith(ext);
2755
+ const unescape_unescape = (s, { windowsPathsNoEscape = false, magicalBraces = true } = {})=>{
2756
+ if (windowsPathsNoEscape && s.startsWith('@(!)')) return '!' + unescape_unescape(s.slice(4), {
2757
+ windowsPathsNoEscape,
2758
+ magicalBraces
2759
+ });
2760
+ if (magicalBraces) return windowsPathsNoEscape ? s.replace(/\[([^/\\])\]/g, '$1') : s.replace(/((?!\\).|^)\[([^/\\])\]/g, '$1$2').replace(/\\([^/])/g, '$1');
2761
+ return windowsPathsNoEscape ? s.replace(/\[([^/\\{}])\]/g, '$1') : s.replace(/((?!\\).|^)\[([^/\\{}])\]/g, '$1$2').replace(/\\([^/{}])/g, '$1');
2628
2762
  };
2629
- const qmarksTestNocaseDot = ([$0, ext = ''])=>{
2630
- const noext = qmarksTestNoExtDot([
2631
- $0
2632
- ]);
2633
- if (!ext) return noext;
2634
- ext = ext.toLowerCase();
2635
- return (f)=>noext(f) && f.toLowerCase().endsWith(ext);
2763
+ const DEFAULT_BRACE_EXPAND_MAX = 100000;
2764
+ const DEFAULT_GLOB_STAR_RECURSION_MAX = 200;
2765
+ const AWE_KEY = "allowWindowsEscape";
2766
+ const minimatch = (p, pattern, options)=>{
2767
+ assertValidPattern(pattern);
2768
+ if (!options?.nocomment && '#' === pattern.charAt(0)) return false;
2769
+ return cachedMinimatch(pattern, options).match(p);
2636
2770
  };
2637
- const qmarksTestDot = ([$0, ext = ''])=>{
2638
- const noext = qmarksTestNoExtDot([
2639
- $0
2640
- ]);
2641
- return ext ? (f)=>noext(f) && f.endsWith(ext) : noext;
2771
+ let cache = new Map();
2772
+ let oldCache = new Map();
2773
+ let cacheSize = 0;
2774
+ let cacheTotalWeight = 0;
2775
+ const cacheMax = 256;
2776
+ const cacheMaxWeight = 32768;
2777
+ const cacheMaxEntryWeight = 4096;
2778
+ const cacheWeight = (mm)=>{
2779
+ let w = mm.pattern.length;
2780
+ for (const s of mm.globSet){
2781
+ w += s.length + 1;
2782
+ if (w > cacheMaxEntryWeight) break;
2783
+ }
2784
+ return w;
2642
2785
  };
2643
- const qmarksTest = ([$0, ext = ''])=>{
2644
- const noext = qmarksTestNoExt([
2645
- $0
2646
- ]);
2647
- return ext ? (f)=>noext(f) && f.endsWith(ext) : noext;
2786
+ const tri = (v)=>void 0 === v ? 0 : v ? 2 : 1;
2787
+ const booleanWeights = new Map(Object.keys({
2788
+ nobrace: 0,
2789
+ nocomment: 0,
2790
+ nonegate: 0,
2791
+ noglobstar: 0,
2792
+ noext: 0,
2793
+ nonull: 0,
2794
+ partial: 0,
2795
+ dot: 0,
2796
+ nocase: 0,
2797
+ nocaseMagicOnly: 0,
2798
+ magicalBraces: 0,
2799
+ matchBase: 0,
2800
+ flipNegate: 0,
2801
+ preserveMultipleSlashes: 0,
2802
+ windowsNoMagicRoot: 0
2803
+ }).map((k, i)=>[
2804
+ k,
2805
+ 24 * 3 ** i
2806
+ ]));
2807
+ const optionsKey = (o)=>{
2808
+ let n = 0;
2809
+ let wpe = false;
2810
+ for(const k in o){
2811
+ const v = o[k];
2812
+ switch(k){
2813
+ case 'windowsPathsNoEscape':
2814
+ if (v) wpe = true;
2815
+ break;
2816
+ case AWE_KEY:
2817
+ if (false === v) wpe = true;
2818
+ break;
2819
+ case 'platform':
2820
+ {
2821
+ const p = v || defaultPlatform;
2822
+ if (p === defaultPlatform) break;
2823
+ if ('darwin' === p) n += 3;
2824
+ else if ('win32' === p) n += 6;
2825
+ else {
2826
+ if ('linux' !== p) return JSON.stringify(o);
2827
+ n += 9;
2828
+ }
2829
+ break;
2830
+ }
2831
+ case 'optimizationLevel':
2832
+ if (void 0 === v) break;
2833
+ n += v >= 2 ? 1 : v >= 1 ? 0 : 2;
2834
+ break;
2835
+ case 'braceExpandMax':
2836
+ if (void 0 !== v && v !== DEFAULT_BRACE_EXPAND_MAX) return JSON.stringify(o);
2837
+ break;
2838
+ case 'maxGlobstarRecursion':
2839
+ if (void 0 !== v && v !== DEFAULT_GLOB_STAR_RECURSION_MAX) return JSON.stringify(o);
2840
+ break;
2841
+ case 'normalize':
2842
+ if (void 0 !== v) return JSON.stringify(o);
2843
+ break;
2844
+ default:
2845
+ n += (booleanWeights.get(k) ?? 0) * tri(v);
2846
+ }
2847
+ }
2848
+ return wpe ? n + 12 : n;
2648
2849
  };
2649
- const qmarksTestNoExt = ([$0])=>{
2650
- const len = $0.length;
2651
- return (f)=>f.length === len && !f.startsWith('.');
2850
+ const copyOptions = (o)=>{
2851
+ const copy = {};
2852
+ for(const k in o)copy[k] = o[k];
2853
+ return copy;
2652
2854
  };
2653
- const qmarksTestNoExtDot = ([$0])=>{
2654
- const len = $0.length;
2655
- return (f)=>f.length === len && '.' !== f && '..' !== f;
2855
+ const cachedMinimatch = (pattern, options)=>{
2856
+ const key = options ? optionsKey(options) : 0;
2857
+ let mm = cache.get(key)?.get(pattern);
2858
+ if (mm) return mm;
2859
+ mm = oldCache.get(key)?.get(pattern) ?? new esm_Minimatch(pattern, copyOptions(options));
2860
+ const weight = cacheWeight(mm);
2861
+ if (weight > cacheMaxEntryWeight) return mm;
2862
+ if (cacheSize >= cacheMax || cacheTotalWeight + weight > cacheMaxWeight) {
2863
+ oldCache = cache;
2864
+ cache = new Map();
2865
+ cacheSize = 0;
2866
+ cacheTotalWeight = 0;
2867
+ }
2868
+ let byPattern = cache.get(key);
2869
+ if (!byPattern) cache.set(key, byPattern = new Map());
2870
+ byPattern.set(pattern, mm);
2871
+ cacheSize++;
2872
+ cacheTotalWeight += weight;
2873
+ return mm;
2656
2874
  };
2657
- const defaultPlatform = 'object' == typeof process && process ? 'object' == typeof process.env && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : 'posix';
2875
+ const defaultPlatform = 'object' == typeof process && process ? process.env?.__MINIMATCH_TESTING_PLATFORM__ || process.platform : 'posix';
2658
2876
  const esm_path = {
2659
2877
  win32: {
2660
2878
  sep: '\\'
@@ -2663,45 +2881,35 @@ var __webpack_exports__ = {};
2663
2881
  sep: '/'
2664
2882
  }
2665
2883
  };
2666
- const sep = 'win32' === defaultPlatform ? esm_path.win32.sep : esm_path.posix.sep;
2667
- minimatch.sep = sep;
2884
+ const esm_sep = 'win32' === defaultPlatform ? esm_path.win32.sep : esm_path.posix.sep;
2885
+ minimatch.sep = esm_sep;
2668
2886
  const GLOBSTAR = Symbol('globstar **');
2669
2887
  minimatch.GLOBSTAR = GLOBSTAR;
2670
- const esm_qmark = '[^/]';
2671
- const esm_star = esm_qmark + '*?';
2672
- const twoStarDot = '(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?';
2673
- const twoStarNoDot = '(?:(?!(?:\\/|^)\\.).)*?';
2674
- const filter = (pattern, options = {})=>(p)=>minimatch(p, pattern, options);
2888
+ const filter = (pattern, options)=>{
2889
+ let mm;
2890
+ return (p)=>(mm ??= cachedMinimatch(pattern, options)).match(p);
2891
+ };
2675
2892
  minimatch.filter = filter;
2676
- const esm_ext = (a, b = {})=>Object.assign({}, a, b);
2893
+ const ext = (a, b = {})=>Object.assign({}, a, b);
2677
2894
  const defaults = (def)=>{
2678
2895
  if (!def || 'object' != typeof def || !Object.keys(def).length) return minimatch;
2679
2896
  const orig = minimatch;
2680
- const m = (p, pattern, options = {})=>orig(p, pattern, esm_ext(def, options));
2897
+ const m = (p, pattern, options = {})=>orig(p, pattern, ext(def, options));
2681
2898
  return Object.assign(m, {
2682
2899
  Minimatch: class extends orig.Minimatch {
2683
2900
  constructor(pattern, options = {}){
2684
- super(pattern, esm_ext(def, options));
2901
+ super(pattern, ext(def, options));
2685
2902
  }
2686
2903
  static defaults(options) {
2687
- return orig.defaults(esm_ext(def, options)).Minimatch;
2904
+ return orig.defaults(ext(def, options)).Minimatch;
2688
2905
  }
2689
2906
  },
2690
- AST: class extends orig.AST {
2691
- constructor(type, parent, options = {}){
2692
- super(type, parent, esm_ext(def, options));
2693
- }
2694
- static fromGlob(pattern, options = {}) {
2695
- return orig.AST.fromGlob(pattern, esm_ext(def, options));
2696
- }
2697
- },
2698
- unescape: (s, options = {})=>orig.unescape(s, esm_ext(def, options)),
2699
- escape: (s, options = {})=>orig.escape(s, esm_ext(def, options)),
2700
- filter: (pattern, options = {})=>orig.filter(pattern, esm_ext(def, options)),
2701
- defaults: (options)=>orig.defaults(esm_ext(def, options)),
2702
- makeRe: (pattern, options = {})=>orig.makeRe(pattern, esm_ext(def, options)),
2703
- braceExpand: (pattern, options = {})=>orig.braceExpand(pattern, esm_ext(def, options)),
2704
- match: (list, pattern, options = {})=>orig.match(list, pattern, esm_ext(def, options)),
2907
+ unescape: (s, options = {})=>orig.unescape(s, ext(def, options)),
2908
+ escape: (s, options = {})=>orig.escape(s, ext(def, options)),
2909
+ filter: (pattern, options = {})=>orig.filter(pattern, ext(def, options)),
2910
+ defaults: (options)=>orig.defaults(ext(def, options)),
2911
+ braceExpand: (pattern, options = {})=>orig.braceExpand(pattern, ext(def, options)),
2912
+ match: (list, pattern, options = {})=>orig.match(list, pattern, ext(def, options)),
2705
2913
  sep: orig.sep,
2706
2914
  GLOBSTAR: GLOBSTAR
2707
2915
  });
@@ -2712,13 +2920,29 @@ var __webpack_exports__ = {};
2712
2920
  if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) return [
2713
2921
  pattern
2714
2922
  ];
2715
- return expand(pattern, {
2923
+ let p = pattern.replace(/\\\\/g, '\\\\\\\\');
2924
+ if (options.windowsPathsNoEscape || false === options[AWE_KEY]) p = p.replace(/\[([{}])\]/g, '[\\$1]');
2925
+ return expand(p, {
2716
2926
  max: options.braceExpandMax
2717
2927
  });
2718
2928
  };
2719
2929
  minimatch.braceExpand = braceExpand;
2720
- const makeRe = (pattern, options = {})=>new esm_Minimatch(pattern, options).makeRe();
2721
- minimatch.makeRe = makeRe;
2930
+ const RANGE_MIN = 100;
2931
+ const rangeRe = /(?<![\\$])\{(-?\d+)\.\.(-?\d+)\}/g;
2932
+ const inRepeatOrNegExt = (portion, mark)=>{
2933
+ const stack = [];
2934
+ for(let i = 0; i < portion.length; i++){
2935
+ const c = portion.charAt(i);
2936
+ if ('\\' === c) i++;
2937
+ else if (c === mark) {
2938
+ if (stack.some((t)=>'@' !== t && '?' !== t)) return true;
2939
+ } else if ('(' === portion.charAt(i + 1) && '!?+*@'.includes(c)) {
2940
+ stack.push(c);
2941
+ i++;
2942
+ } else if (')' === c) stack.pop();
2943
+ }
2944
+ return false;
2945
+ };
2722
2946
  const esm_match = (list, pattern, options = {})=>{
2723
2947
  const mm = new esm_Minimatch(pattern, options);
2724
2948
  list = list.filter((f)=>mm.match(f));
@@ -2727,7 +2951,118 @@ var __webpack_exports__ = {};
2727
2951
  };
2728
2952
  minimatch.match = esm_match;
2729
2953
  const globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
2730
- const esm_regExpEscape = (s)=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
2954
+ const classEnd = (pattern, start)=>{
2955
+ let i = start + 1;
2956
+ if ('!' === pattern.charAt(i) || '^' === pattern.charAt(i)) i++;
2957
+ let sawStart = false;
2958
+ for(; i < pattern.length; i++){
2959
+ const c = pattern.charAt(i);
2960
+ if (']' === c && sawStart) return i;
2961
+ sawStart = true;
2962
+ if ('\\' === c) i++;
2963
+ }
2964
+ return -1;
2965
+ };
2966
+ const esm_literal = (pattern, noext)=>{
2967
+ if (!noext && ('+()' === pattern || '@()' === pattern)) return pattern;
2968
+ let lit = '';
2969
+ for(let i = 0; i < pattern.length; i++){
2970
+ const c = pattern.charAt(i);
2971
+ if ('\\' === c) lit += pattern.charAt(++i) || c;
2972
+ else if ('*' === c || '?' === c) return;
2973
+ else if ('[' === c) {
2974
+ const close = classEnd(pattern, i);
2975
+ if (-1 === close) {
2976
+ lit += c;
2977
+ continue;
2978
+ }
2979
+ let body = pattern.slice(i + 1, close);
2980
+ if (body.startsWith('\\')) body = body.slice(1);
2981
+ if (1 !== [
2982
+ ...body
2983
+ ].length || '!^'.includes(pattern.charAt(i + 1))) return;
2984
+ lit += body;
2985
+ i = close;
2986
+ } else {
2987
+ if (!noext && '+@!'.includes(c) && '(' === pattern.charAt(i + 1) && pattern.includes(')', i + 2)) return;
2988
+ lit += c;
2989
+ }
2990
+ }
2991
+ return lit;
2992
+ };
2993
+ const MAX_EXTGLOBS = 256;
2994
+ const extglobCount = (pattern)=>{
2995
+ let n = 0;
2996
+ for(let i = 0; i < pattern.length - 1; i++){
2997
+ const c = pattern.charAt(i);
2998
+ if ('\\' === c) i++;
2999
+ else if ('+@!?*'.includes(c) && '(' === pattern.charAt(i + 1)) {
3000
+ n++;
3001
+ i++;
3002
+ }
3003
+ }
3004
+ return n;
3005
+ };
3006
+ const assertValidExtglobs = (pattern)=>{
3007
+ if (extglobCount(pattern) > MAX_EXTGLOBS) throw new TypeError('pattern has too many extglobs');
3008
+ };
3009
+ const extSafe = (pattern)=>{
3010
+ if (/^[?*+@]\(\)$/.test(pattern) || pattern.includes('[:')) return false;
3011
+ let depth = 0;
3012
+ for(let i = 0; i < pattern.length; i++){
3013
+ const c = pattern.charAt(i);
3014
+ if ('\\' === c) {
3015
+ if (++i === pattern.length) return false;
3016
+ } else if ('[' === c) {
3017
+ const close = classEnd(pattern, i);
3018
+ if (-1 !== close) i = close;
3019
+ } else if ('+@!?*'.includes(c) && '(' === pattern.charAt(i + 1)) {
3020
+ depth++;
3021
+ i++;
3022
+ } else if (')' === c) {
3023
+ if (!depth--) return false;
3024
+ } else if ('|' === c && !depth) return false;
3025
+ }
3026
+ return !depth;
3027
+ };
3028
+ let lastSplit;
3029
+ let lastChecked;
3030
+ const portionMatch = (p, f)=>'string' == typeof p ? f === p : '' !== f && p.testUnchecked(f);
3031
+ const endIndex = (p, last, lastStart, prev, prevStart)=>portionMatch(p, last) ? lastStart : void 0 !== prev && portionMatch(p, prev) ? prevStart : -1;
3032
+ const isDots = (p)=>'.' === p || '..' === p;
3033
+ const esm_isDrive = (p)=>'string' == typeof p && /^[a-z]:$/i.test(p);
3034
+ const isLongUNC = (p)=>'string' == typeof p && /^unc$/i.test(p);
3035
+ const uncHost = (p)=>{
3036
+ if ('' !== p[0] || '' !== p[1]) return -1;
3037
+ const h = '?' !== p[2] ? 2 : isLongUNC(p[3]) ? 4 : -1;
3038
+ const host = p[h];
3039
+ const share = p[h + 1];
3040
+ return -1 !== h && void 0 !== host && '' !== host && host !== GLOBSTAR && void 0 !== share && '' !== share && share !== GLOBSTAR ? h : -1;
3041
+ };
3042
+ const walkable = (p, dot)=>!isDots(p) && (dot || !p.startsWith('.'));
3043
+ const dotPortion = (f, start, end, dot, sep)=>{
3044
+ for(let k = start; k < end;){
3045
+ if (46 === f.charCodeAt(k)) {
3046
+ if (!dot) return true;
3047
+ const n = 46 === f.charCodeAt(k + 1) ? k + 2 : k + 1;
3048
+ if (n >= end || isSep(f.charCodeAt(n), sep)) return true;
3049
+ }
3050
+ const s = nextSep(f, k, sep);
3051
+ if (-1 === s) break;
3052
+ k = s + 1;
3053
+ while(k < end && isSep(f.charCodeAt(k), sep))k++;
3054
+ }
3055
+ return false;
3056
+ };
3057
+ const isSep = (c, sep)=>'/' === sep ? 47 === c : '\\' === sep ? 92 === c : 47 === c || 92 === c;
3058
+ const nextSep = (f, from, sep)=>{
3059
+ if ('both' !== sep) return f.indexOf(sep, from);
3060
+ const s = f.indexOf('/', from);
3061
+ const b = f.indexOf('\\', from);
3062
+ return -1 === s ? b : -1 === b ? s : Math.min(s, b);
3063
+ };
3064
+ const lastSep = (f, from, sep)=>'both' !== sep ? f.lastIndexOf(sep, from) : Math.max(f.lastIndexOf('/', from), f.lastIndexOf('\\', from));
3065
+ const PENDING = {};
2731
3066
  class esm_Minimatch {
2732
3067
  options;
2733
3068
  set;
@@ -2746,20 +3081,28 @@ var __webpack_exports__ = {};
2746
3081
  platform;
2747
3082
  windowsNoMagicRoot;
2748
3083
  maxGlobstarRecursion;
2749
- regexp;
3084
+ #endCheck;
3085
+ #literalCheck;
3086
+ #level2;
3087
+ #form;
3088
+ #literals = [];
3089
+ #shapes = [];
3090
+ #endRows = [];
3091
+ #matchers = new Map();
3092
+ #pending = false;
3093
+ #rangeMark;
3094
+ #globstarParts = new WeakMap();
2750
3095
  constructor(pattern, options = {}){
2751
3096
  assertValidPattern(pattern);
2752
3097
  options = options || {};
2753
3098
  this.options = options;
2754
- this.maxGlobstarRecursion = options.maxGlobstarRecursion ?? 200;
3099
+ this.maxGlobstarRecursion = options.maxGlobstarRecursion ?? DEFAULT_GLOB_STAR_RECURSION_MAX;
2755
3100
  this.pattern = pattern;
2756
3101
  this.platform = options.platform || defaultPlatform;
2757
3102
  this.isWindows = 'win32' === this.platform;
2758
- const awe = "allowWindowsEscape";
2759
- this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || false === options[awe];
3103
+ this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || false === options[AWE_KEY];
2760
3104
  if (this.windowsPathsNoEscape) this.pattern = this.pattern.replace(/\\/g, '/');
2761
3105
  this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
2762
- this.regexp = null;
2763
3106
  this.negate = false;
2764
3107
  this.nonegate = !!options.nonegate;
2765
3108
  this.comment = false;
@@ -2770,14 +3113,48 @@ var __webpack_exports__ = {};
2770
3113
  this.globSet = [];
2771
3114
  this.globParts = [];
2772
3115
  this.set = [];
3116
+ this.#endCheck = !this.preserveMultipleSlashes;
3117
+ this.#level2 = (options.optimizationLevel ?? 1) >= 2;
3118
+ const n = options.normalize;
3119
+ this.#form = true === n ? 'NFC' : n || void 0;
2773
3120
  this.make();
3121
+ const drives = this.set.map((row)=>this.#rootIndex(row));
3122
+ this.#endRows = this.set.map((row, r)=>this.#endCheck && row.length - 1 > drives[r]);
3123
+ this.#literals = this.set.map((row, r)=>{
3124
+ const end = this.#endRows[r] ? row.length - 1 : row.length;
3125
+ const lits = row.slice(drives[r] + 1, end).filter((p)=>'string' == typeof p && !!p);
3126
+ return [
3127
+ ...new Set(lits)
3128
+ ];
3129
+ });
3130
+ this.#literalCheck = this.#literals.some((l)=>l.length);
3131
+ this.#shapes = this.set.map((row, r)=>{
3132
+ const [p0, p1, p2] = row;
3133
+ if (this.#endRows[r] && 2 === row.length) {
3134
+ if (p0 === GLOBSTAR && p1 !== GLOBSTAR) return 'tail';
3135
+ }
3136
+ if (this.#endRows[r] && options.matchBase && 1 === row.length && p0 !== GLOBSTAR && '' !== p0) return 'base';
3137
+ if (!this.#endCheck || -1 !== drives[r]) return;
3138
+ if (3 === row.length && p0 === GLOBSTAR && p2 === GLOBSTAR && p1 !== GLOBSTAR && '' !== p1 && this.maxGlobstarRecursion > 0) return 'mid';
3139
+ if (2 === row.length && p1 === GLOBSTAR && p0 !== GLOBSTAR && '' !== p0) return 'head';
3140
+ });
3141
+ }
3142
+ #norm(p) {
3143
+ return this.#form ? p.normalize(this.#form) : p;
3144
+ }
3145
+ #rootIndex(row) {
3146
+ if (!this.isWindows) return -1;
3147
+ if (esm_isDrive(row[0])) return 0;
3148
+ const uncDrive = '' === row[0] && '' === row[1] && '?' === row[2] && esm_isDrive(row[3]);
3149
+ if (uncDrive) return 3;
3150
+ const h = uncHost(row);
3151
+ return -1 === h ? -1 : h + 1;
2774
3152
  }
2775
3153
  hasMagic() {
2776
3154
  if (this.options.magicalBraces && this.set.length > 1) return true;
2777
3155
  for (const pattern of this.set)for (const part of pattern)if ('string' != typeof part) return true;
2778
3156
  return false;
2779
3157
  }
2780
- debug() {}
2781
3158
  make() {
2782
3159
  const pattern = this.pattern;
2783
3160
  const options = this.options;
@@ -2791,35 +3168,121 @@ var __webpack_exports__ = {};
2791
3168
  }
2792
3169
  this.parseNegate();
2793
3170
  this.globSet = [
2794
- ...new Set(this.braceExpand())
3171
+ ...new Set(this.#expandBraces())
2795
3172
  ];
2796
- if (options.debug) this.debug = (...args)=>console.error(...args);
2797
- this.debug(this.pattern, this.globSet);
2798
- const rawGlobParts = this.globSet.map((s)=>this.slashSplit(s));
3173
+ const rawGlobParts = this.globSet.map((s)=>this.#slashSplit(s));
2799
3174
  this.globParts = this.preprocess(rawGlobParts);
2800
- this.debug(this.pattern, this.globParts);
3175
+ this.#pending = true;
2801
3176
  let set = this.globParts.map((s, _, __)=>{
2802
3177
  if (this.isWindows && this.windowsNoMagicRoot) {
2803
- const isUNC = '' === s[0] && '' === s[1] && ('?' === s[2] || !globMagic.test(s[2])) && !globMagic.test(s[3]);
3178
+ const n = '?' === s[2] && isLongUNC(s[3]) ? 6 : 4;
3179
+ const isUNC = '' === s[0] && '' === s[1] && ('?' === s[2] || !globMagic.test(s[2])) && s.slice(3, n).every((p)=>!globMagic.test(p));
2804
3180
  const isDrive = /^[a-z]:/i.test(s[0]);
2805
3181
  if (isUNC) return [
2806
- ...s.slice(0, 4),
2807
- ...s.slice(4).map((ss)=>this.parse(ss))
3182
+ ...s.slice(0, n).map((p)=>this.#norm(p)),
3183
+ ...s.slice(n).map((ss)=>this.parse(ss))
2808
3184
  ];
2809
3185
  else if (isDrive) return [
2810
- s[0],
3186
+ this.#norm(s[0]),
2811
3187
  ...s.slice(1).map((ss)=>this.parse(ss))
2812
3188
  ];
2813
3189
  }
2814
3190
  return s.map((ss)=>this.parse(ss));
2815
3191
  });
2816
- this.debug(this.pattern, set);
2817
3192
  this.set = set.filter((s)=>-1 === s.indexOf(false));
2818
3193
  if (this.isWindows) for(let i = 0; i < this.set.length; i++){
2819
3194
  const p = this.set[i];
2820
- if ('' === p[0] && '' === p[1] && '?' === this.globParts[i][2] && 'string' == typeof p[3] && /^[a-z]:$/i.test(p[3])) p[2] = '?';
3195
+ if ('' === p[0] && '' === p[1] && '?' === this.globParts[i][2] && (esm_isDrive(p[3]) || isLongUNC(this.globParts[i][3]))) {
3196
+ if (isLongUNC(this.globParts[i][3])) p[3] = 'UNC';
3197
+ p[2] = '?';
3198
+ }
2821
3199
  }
2822
- this.debug(this.pattern, this.set);
3200
+ if (!options.noext) this.mergeRows();
3201
+ this.#pending = false;
3202
+ this.set.forEach((row, i)=>{
3203
+ for(let k = 0; k < row.length; k++)if (row[k] === PENDING) row[k] = this.parse(this.globParts[i][k]);
3204
+ });
3205
+ }
3206
+ mergeRows() {
3207
+ let merged = true;
3208
+ while(merged){
3209
+ merged = false;
3210
+ if (this.set.length < 2) return;
3211
+ let keys = this.#mergeKeys();
3212
+ const len = Math.max(0, ...this.set.map((r)=>r.length));
3213
+ for(let k = 0; k < len; k++){
3214
+ const groups = new Map();
3215
+ const R = this.set.length + 1;
3216
+ this.set.forEach((row, i)=>{
3217
+ if (!(row[k] instanceof Matcher || row[k] === PENDING) || !extSafe(this.globParts[i][k])) return;
3218
+ const { pre, suf } = keys[i];
3219
+ const key = pre[k] * R + suf[k + 1];
3220
+ const g = groups.get(key);
3221
+ if (g) g.push(i);
3222
+ else groups.set(key, [
3223
+ i
3224
+ ]);
3225
+ });
3226
+ const drop = new Set();
3227
+ for (const g of groups.values()){
3228
+ if (g.length < 2) continue;
3229
+ const [first, ...rest] = g;
3230
+ const alts = g.map((i)=>this.globParts[i][k]);
3231
+ const glob = `@(${alts.join('|')})`;
3232
+ if (!(extglobCount(glob) > MAX_EXTGLOBS)) {
3233
+ this.globParts[first][k] = glob;
3234
+ this.set[first][k] = this.parse(glob);
3235
+ for (const i of rest)drop.add(i);
3236
+ }
3237
+ }
3238
+ if (drop.size) {
3239
+ merged = true;
3240
+ this.set = this.set.filter((_, i)=>!drop.has(i));
3241
+ this.globParts = this.globParts.filter((_, i)=>!drop.has(i));
3242
+ if (this.set.length < 2) return;
3243
+ keys = this.#mergeKeys();
3244
+ }
3245
+ }
3246
+ }
3247
+ }
3248
+ #mergeKeys() {
3249
+ const partIds = new Map();
3250
+ const ids = this.globParts.map((parts)=>parts.map((s)=>{
3251
+ let id = partIds.get(s);
3252
+ if (void 0 === id) partIds.set(s, id = partIds.size);
3253
+ return id;
3254
+ }));
3255
+ const P = partIds.size;
3256
+ const len = Math.max(0, ...ids.map((r)=>r.length));
3257
+ const keys = ids.map((r)=>({
3258
+ pre: [
3259
+ 0
3260
+ ],
3261
+ suf: new Array(r.length + 1).fill(0)
3262
+ }));
3263
+ for(let k = 0; k < len; k++){
3264
+ const m = new Map();
3265
+ ids.forEach((r, i)=>{
3266
+ if (k >= r.length) return;
3267
+ const { pre } = keys[i];
3268
+ const key = pre[k] * P + r[k];
3269
+ let id = m.get(key);
3270
+ if (void 0 === id) m.set(key, id = m.size + 1);
3271
+ pre.push(id);
3272
+ });
3273
+ }
3274
+ for(let k = len - 1; k >= 0; k--){
3275
+ const m = new Map();
3276
+ ids.forEach((r, i)=>{
3277
+ if (k >= r.length) return;
3278
+ const { suf } = keys[i];
3279
+ const key = suf[k + 1] * P + r[k];
3280
+ let id = m.get(key);
3281
+ if (void 0 === id) m.set(key, id = m.size + 1);
3282
+ suf[k] = id;
3283
+ });
3284
+ }
3285
+ return keys;
2823
3286
  }
2824
3287
  preprocess(globParts) {
2825
3288
  if (this.options.noglobstar) {
@@ -2845,11 +3308,12 @@ var __webpack_exports__ = {};
2845
3308
  }
2846
3309
  levelOneOptimize(globParts) {
2847
3310
  return globParts.map((parts)=>{
3311
+ const root = this.#rootIndex(parts) + 1;
2848
3312
  parts = parts.reduce((set, part)=>{
2849
3313
  const prev = set[set.length - 1];
2850
3314
  if ('**' === part && '**' === prev) return set;
2851
3315
  if ('..' === part) {
2852
- if (prev && '..' !== prev && '.' !== prev && '**' !== prev) {
3316
+ if (set.length > root && prev && '..' !== prev && '.' !== prev && '**' !== prev) {
2853
3317
  set.pop();
2854
3318
  return set;
2855
3319
  }
@@ -2862,8 +3326,123 @@ var __webpack_exports__ = {};
2862
3326
  ] : parts;
2863
3327
  });
2864
3328
  }
2865
- levelTwoFileOptimize(parts) {
2866
- if (!Array.isArray(parts)) parts = this.slashSplit(parts);
3329
+ #canMatch(f) {
3330
+ const sep = this.isWindows && f.includes('\\') ? f.includes('/') ? 'both' : '\\' : '/';
3331
+ let ends = this.#endCheck ? 0 : -1;
3332
+ let last = '';
3333
+ let lastStart = 0;
3334
+ let prev;
3335
+ let prevStart = 0;
3336
+ const dot = !!this.options.dot;
3337
+ ROWS: for(let r = 0; r < this.set.length; r++){
3338
+ const row = this.set[r];
3339
+ const p = row[row.length - 1];
3340
+ let end = -1 !== ends && this.#endRows[r] && p !== GLOBSTAR;
3341
+ if (end && 0 === ends) {
3342
+ const i = lastSep(f, f.length, sep);
3343
+ lastStart = i + 1;
3344
+ last = f.slice(lastStart);
3345
+ if ('' === last && i >= 0) {
3346
+ let j = i;
3347
+ while(j > 0 && isSep(f.charCodeAt(j - 1), sep))j--;
3348
+ prevStart = 0 === j ? 0 : lastSep(f, j - 1, sep) + 1;
3349
+ prev = f.slice(prevStart, j);
3350
+ }
3351
+ const resolves = this.#level2 && (isDots(last) || '' === last && void 0 !== prev && isDots(prev));
3352
+ ends = resolves ? -1 : 1;
3353
+ end = !resolves;
3354
+ }
3355
+ let tailStart = -1;
3356
+ if (end && 'string' == typeof p) {
3357
+ tailStart = endIndex(p, last, lastStart, prev, prevStart);
3358
+ if (-1 === tailStart) continue;
3359
+ }
3360
+ if (this.#literalCheck) {
3361
+ for (const l of this.#literals[r])if (!f.includes(l)) continue ROWS;
3362
+ }
3363
+ if (end && 'object' == typeof p) {
3364
+ tailStart = endIndex(p, last, lastStart, prev, prevStart);
3365
+ if (-1 === tailStart) continue;
3366
+ }
3367
+ const shape = this.#shapes[r];
3368
+ if ('base' === shape && end) return 'yes';
3369
+ if ('tail' === shape && end) {
3370
+ if (this.#level2 && dotPortion(f, 0, tailStart, true, sep)) return 'maybe';
3371
+ if (!dotPortion(f, 0, tailStart, dot, sep)) return 'yes';
3372
+ continue;
3373
+ }
3374
+ if ('mid' === shape || 'head' === shape) {
3375
+ const m = this.#walk(f, row, 'head' === shape, dot, sep);
3376
+ if ('no' !== m) return m;
3377
+ continue;
3378
+ }
3379
+ return 'maybe';
3380
+ }
3381
+ return 'no';
3382
+ }
3383
+ #matchShape(file, row, shape) {
3384
+ const dot = !!this.options.dot;
3385
+ const n = file.length;
3386
+ if ('head' === shape) {
3387
+ if (n < 2 || !portionMatch(row[0], file[0])) return false;
3388
+ for(let i = 1; i < n; i++)if (!walkable(file[i], dot)) return false;
3389
+ return true;
3390
+ }
3391
+ const x = row[1];
3392
+ if ('tail' === shape) {
3393
+ let t = n - 1;
3394
+ if (!portionMatch(x, file[t])) {
3395
+ if ('' !== file[t] || 1 === n || !portionMatch(x, file[--t])) return false;
3396
+ }
3397
+ for(let i = 0; i < t; i++)if (!walkable(file[i], dot)) return false;
3398
+ return true;
3399
+ }
3400
+ for(let k = 0; k < n; k++){
3401
+ if (portionMatch(x, file[k]) && k + 1 < n) {
3402
+ let i = k + 1;
3403
+ while(i < n && walkable(file[i], dot))i++;
3404
+ if (i === n) return true;
3405
+ }
3406
+ if (!walkable(file[k], dot)) break;
3407
+ }
3408
+ return false;
3409
+ }
3410
+ #walk(f, row, head, dot, sep) {
3411
+ if (this.#level2 && dotPortion(f, 0, f.length, true, sep)) return 'maybe';
3412
+ const x = row[head ? 0 : 1];
3413
+ let s = 0;
3414
+ for(let e = nextSep(f, s, sep); -1 !== e; e = nextSep(f, s, sep)){
3415
+ let next = e + 1;
3416
+ while(next < f.length && isSep(f.charCodeAt(next), sep))next++;
3417
+ const hit = 'string' == typeof x ? e - s === x.length && f.startsWith(x, s) : e > s && x.testUnchecked(f.slice(s, e));
3418
+ if (hit && !dotPortion(f, next, f.length, dot, sep)) return 'yes';
3419
+ if (head || dotPortion(f, s, next, dot, sep)) break;
3420
+ s = next;
3421
+ }
3422
+ return 'no';
3423
+ }
3424
+ #cachedSplit(f) {
3425
+ const last = lastSplit;
3426
+ return last?.f === f && last.isWindows === this.isWindows && last.preserveMultipleSlashes === this.preserveMultipleSlashes && last.normalize === this.#form ? last : void 0;
3427
+ }
3428
+ #split(f) {
3429
+ const { isWindows, preserveMultipleSlashes } = this;
3430
+ let parts = this.#slashSplit(isWindows ? f.split('\\').join('/') : f);
3431
+ const normalize = this.#form;
3432
+ if (normalize) parts = parts.map((p)=>p.normalize(normalize));
3433
+ lastSplit = {
3434
+ f,
3435
+ isWindows,
3436
+ preserveMultipleSlashes,
3437
+ normalize,
3438
+ parts
3439
+ };
3440
+ return lastSplit;
3441
+ }
3442
+ #levelTwoFileOptimize(file) {
3443
+ const parts = [
3444
+ ...file
3445
+ ];
2867
3446
  let didSomething = false;
2868
3447
  do {
2869
3448
  didSomething = false;
@@ -2883,13 +3462,14 @@ var __webpack_exports__ = {};
2883
3462
  parts.pop();
2884
3463
  }
2885
3464
  }
2886
- let dd = 0;
3465
+ const root = this.#rootIndex(parts) + 1;
3466
+ let dd = root;
2887
3467
  while(-1 !== (dd = parts.indexOf('..', dd + 1))){
2888
3468
  const p = parts[dd - 1];
2889
- if (p && '.' !== p && '..' !== p && '**' !== p && !(this.isWindows && /^[a-z]:$/i.test(p))) {
3469
+ if (p && '.' !== p && '..' !== p && '**' !== p) {
2890
3470
  didSomething = true;
2891
3471
  parts.splice(dd - 1, 2);
2892
- dd -= 2;
3472
+ dd = Math.max(dd - 2, root);
2893
3473
  }
2894
3474
  }
2895
3475
  }while (didSomething);
@@ -2898,6 +3478,9 @@ var __webpack_exports__ = {};
2898
3478
  ] : parts;
2899
3479
  }
2900
3480
  firstPhasePreProcess(globParts) {
3481
+ const { braceExpandMax = DEFAULT_BRACE_EXPAND_MAX } = this.options;
3482
+ let splitCells = 0;
3483
+ const maxSplitCells = 1000000;
2901
3484
  let didSomething = false;
2902
3485
  do {
2903
3486
  didSomething = false;
@@ -2912,10 +3495,13 @@ var __webpack_exports__ = {};
2912
3495
  const p2 = parts[gs + 3];
2913
3496
  if ('..' !== next) continue;
2914
3497
  if (!p || '.' === p || '..' === p || !p2 || '.' === p2 || '..' === p2) continue;
3498
+ const addedCells = parts.length - 1;
3499
+ if (globParts.length >= braceExpandMax || splitCells + addedCells > maxSplitCells) throw new RangeError("optimizationLevel 2: too many patterns from '**/..'");
2915
3500
  didSomething = true;
2916
3501
  parts.splice(gs, 1);
2917
3502
  const other = parts.slice(0);
2918
3503
  other[gs] = '**';
3504
+ splitCells += addedCells;
2919
3505
  globParts.push(other);
2920
3506
  gs--;
2921
3507
  }
@@ -2935,7 +3521,8 @@ var __webpack_exports__ = {};
2935
3521
  parts.pop();
2936
3522
  }
2937
3523
  }
2938
- let dd = 0;
3524
+ const root = this.#rootIndex(parts) + 1;
3525
+ let dd = root;
2939
3526
  while(-1 !== (dd = parts.indexOf('..', dd + 1))){
2940
3527
  const p = parts[dd - 1];
2941
3528
  if (p && '.' !== p && '..' !== p && '**' !== p) {
@@ -2946,7 +3533,7 @@ var __webpack_exports__ = {};
2946
3533
  ] : [];
2947
3534
  parts.splice(dd - 1, 2, ...splin);
2948
3535
  if (0 === parts.length) parts.push('');
2949
- dd -= 2;
3536
+ dd = Math.max(dd - 2, root);
2950
3537
  }
2951
3538
  }
2952
3539
  }
@@ -2954,46 +3541,44 @@ var __webpack_exports__ = {};
2954
3541
  return globParts;
2955
3542
  }
2956
3543
  secondPhasePreProcess(globParts) {
2957
- for(let i = 0; i < globParts.length - 1; i++)for(let j = i + 1; j < globParts.length; j++){
2958
- const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
2959
- if (matched) {
2960
- globParts[i] = [];
2961
- globParts[j] = matched;
2962
- break;
2963
- }
2964
- }
2965
- return globParts.filter((gs)=>gs.length);
2966
- }
2967
- partsMatch(a, b, emptyGSMatch = false) {
2968
- let ai = 0;
2969
- let bi = 0;
2970
- let result = [];
2971
- let which = '';
2972
- while(ai < a.length && bi < b.length)if (a[ai] === b[bi]) {
2973
- result.push('b' === which ? b[bi] : a[ai]);
2974
- ai++;
2975
- bi++;
2976
- } else if (emptyGSMatch && '**' === a[ai] && b[bi] === a[ai + 1]) {
2977
- result.push(a[ai]);
2978
- ai++;
2979
- } else if (emptyGSMatch && '**' === b[bi] && a[ai] === b[bi + 1]) {
2980
- result.push(b[bi]);
2981
- bi++;
2982
- } else if ('*' === a[ai] && b[bi] && (this.options.dot || !b[bi].startsWith('.')) && '**' !== b[bi]) {
2983
- if ('b' === which) return false;
2984
- which = 'a';
2985
- result.push(a[ai]);
2986
- ai++;
2987
- bi++;
2988
- } else {
2989
- if ('*' !== b[bi] || !a[ai] || !this.options.dot && !!a[ai].startsWith('.') || '**' === a[ai]) return false;
2990
- if ('a' === which) return false;
2991
- which = 'b';
2992
- result.push(b[bi]);
2993
- ai++;
2994
- bi++;
3544
+ const keys = new Set();
3545
+ const rows = globParts.filter((parts)=>{
3546
+ const key = parts.join('/');
3547
+ if (keys.has(key)) return false;
3548
+ keys.add(key);
3549
+ return true;
3550
+ });
3551
+ const stars = new Map();
3552
+ for (const parts of rows){
3553
+ const s = [];
3554
+ for(let i = 0; i < parts.length; i++)if ('*' === parts[i]) s.push(i);
3555
+ if (s.length) stars.set(s.join(','), s);
2995
3556
  }
2996
- return a.length === b.length && result;
3557
+ if (!stars.size || rows.length * stars.size > 100000) return rows;
3558
+ const { dot } = this.options;
3559
+ return rows.filter((parts)=>{
3560
+ for (const s of stars.values()){
3561
+ if (s[s.length - 1] >= parts.length) continue;
3562
+ const c = [
3563
+ ...parts
3564
+ ];
3565
+ let ok = true;
3566
+ let changed = false;
3567
+ for (const i of s){
3568
+ const p = parts[i];
3569
+ if ('*' !== p) {
3570
+ if (!p || '**' === p || !dot && p.startsWith('.')) {
3571
+ ok = false;
3572
+ break;
3573
+ }
3574
+ c[i] = '*';
3575
+ changed = true;
3576
+ }
3577
+ }
3578
+ if (ok && changed && keys.has(c.join('/'))) return false;
3579
+ }
3580
+ return true;
3581
+ });
2997
3582
  }
2998
3583
  parseNegate() {
2999
3584
  if (this.nonegate) return;
@@ -3007,10 +3592,22 @@ var __webpack_exports__ = {};
3007
3592
  if (negateOffset) this.pattern = pattern.slice(negateOffset);
3008
3593
  this.negate = negate;
3009
3594
  }
3010
- matchOne(file, pattern, partial = false) {
3595
+ #matchRow(file, resolved, pattern, partial) {
3011
3596
  let fileStartIndex = 0;
3012
3597
  let patternStartIndex = 0;
3013
- if (this.isWindows) {
3598
+ const fh = this.isWindows ? uncHost(resolved) : -1;
3599
+ const ph = -1 === fh ? -1 : uncHost(pattern);
3600
+ if (-1 !== ph) {
3601
+ const host = pattern[ph];
3602
+ const share = pattern[ph + 1];
3603
+ if ('string' != typeof host || 'string' != typeof share) {
3604
+ fileStartIndex = fh;
3605
+ patternStartIndex = ph;
3606
+ } else if (resolved[fh].toLowerCase() === host.toLowerCase() && resolved[fh + 1].toLowerCase() === share.toLowerCase()) {
3607
+ fileStartIndex = fh + 2;
3608
+ patternStartIndex = ph + 2;
3609
+ }
3610
+ } else if (this.isWindows) {
3014
3611
  const fileDrive = 'string' == typeof file[0] && /^[a-z]:$/i.test(file[0]);
3015
3612
  const fileUNC = !fileDrive && '' === file[0] && '' === file[1] && '?' === file[2] && /^[a-z]:$/i.test(file[3]);
3016
3613
  const patternDrive = 'string' == typeof pattern[0] && /^[a-z]:$/i.test(pattern[0]);
@@ -3023,32 +3620,20 @@ var __webpack_exports__ = {};
3023
3620
  pattern[pdi]
3024
3621
  ];
3025
3622
  if (fd.toLowerCase() === pd.toLowerCase()) {
3026
- pattern[pdi] = fd;
3027
- patternStartIndex = pdi;
3028
- fileStartIndex = fdi;
3623
+ patternStartIndex = pdi + 1;
3624
+ fileStartIndex = fdi + 1;
3029
3625
  }
3030
3626
  }
3031
3627
  }
3032
- const { optimizationLevel = 1 } = this.options;
3033
- if (optimizationLevel >= 2) file = this.levelTwoFileOptimize(file);
3628
+ file = resolved;
3034
3629
  if (pattern.includes(GLOBSTAR)) return this.#matchGlobstar(file, pattern, partial, fileStartIndex, patternStartIndex);
3035
3630
  return this.#matchOne(file, pattern, partial, fileStartIndex, patternStartIndex);
3036
3631
  }
3037
3632
  #matchGlobstar(file, pattern, partial, fileIndex, patternIndex) {
3038
- const firstgs = pattern.indexOf(GLOBSTAR, patternIndex);
3039
- const lastgs = pattern.lastIndexOf(GLOBSTAR);
3040
- const [head, body, tail] = partial ? [
3041
- pattern.slice(patternIndex, firstgs),
3042
- pattern.slice(firstgs + 1),
3043
- []
3044
- ] : [
3045
- pattern.slice(patternIndex, firstgs),
3046
- pattern.slice(firstgs + 1, lastgs),
3047
- pattern.slice(lastgs + 1)
3048
- ];
3633
+ const { head, body, tail, segments } = this.#getGlobstarParts(pattern, partial, patternIndex);
3049
3634
  if (head.length) {
3050
- const fileHead = file.slice(fileIndex, fileIndex + head.length);
3051
- if (!this.#matchOne(fileHead, head, partial, 0, 0)) return false;
3635
+ const headEnd = fileIndex + head.length;
3636
+ if (!this.#matchOne(file, head, partial, fileIndex, 0, headEnd)) return false;
3052
3637
  fileIndex += head.length;
3053
3638
  patternIndex += head.length;
3054
3639
  }
@@ -3073,76 +3658,95 @@ var __webpack_exports__ = {};
3073
3658
  }
3074
3659
  return partial || sawSome;
3075
3660
  }
3076
- const bodySegments = [
3661
+ return !!this.#matchGlobStarBodySections(file, segments, file.length - fileTailMatch, fileIndex, 0, partial, 0, !!fileTailMatch, new Set());
3662
+ }
3663
+ #getGlobstarParts(pattern, partial, patternIndex) {
3664
+ let byStart = this.#globstarParts.get(pattern);
3665
+ if (!byStart) {
3666
+ byStart = [];
3667
+ this.#globstarParts.set(pattern, byStart);
3668
+ }
3669
+ const key = 2 * patternIndex + (partial ? 1 : 0);
3670
+ const found = byStart[key];
3671
+ if (found) return found;
3672
+ const firstgs = pattern.indexOf(GLOBSTAR, patternIndex);
3673
+ const lastgs = pattern.lastIndexOf(GLOBSTAR);
3674
+ const head = pattern.slice(patternIndex, firstgs);
3675
+ const body = pattern.slice(firstgs + 1, partial ? void 0 : lastgs);
3676
+ const tail = partial ? [] : pattern.slice(lastgs + 1);
3677
+ const segments = [
3077
3678
  [
3078
3679
  [],
3079
3680
  0
3080
3681
  ]
3081
3682
  ];
3082
- let currentBody = bodySegments[0];
3683
+ let current = segments[0];
3083
3684
  let nonGsParts = 0;
3084
3685
  const nonGsPartsSums = [
3085
3686
  0
3086
3687
  ];
3087
3688
  for (const b of body)if (b === GLOBSTAR) {
3088
3689
  nonGsPartsSums.push(nonGsParts);
3089
- currentBody = [
3690
+ current = [
3090
3691
  [],
3091
3692
  0
3092
3693
  ];
3093
- bodySegments.push(currentBody);
3694
+ segments.push(current);
3094
3695
  } else {
3095
- currentBody[0].push(b);
3696
+ current[0].push(b);
3096
3697
  nonGsParts++;
3097
3698
  }
3098
- let i = bodySegments.length - 1;
3099
- const fileLength = file.length - fileTailMatch;
3100
- for (const b of bodySegments)b[1] = fileLength - (nonGsPartsSums[i--] + b[0].length);
3101
- return !!this.#matchGlobStarBodySections(file, bodySegments, fileIndex, 0, partial, 0, !!fileTailMatch);
3699
+ segments.forEach((b, i)=>{
3700
+ b[1] = nonGsParts - nonGsPartsSums[i];
3701
+ });
3702
+ const parts = {
3703
+ head,
3704
+ body,
3705
+ tail,
3706
+ segments
3707
+ };
3708
+ byStart[key] = parts;
3709
+ return parts;
3102
3710
  }
3103
- #matchGlobStarBodySections(file, bodySegments, fileIndex, bodyIndex, partial, globStarDepth, sawTail) {
3711
+ #matchGlobStarBodySections(file, bodySegments, fileLength, fileIndex, bodyIndex, partial, globStarDepth, sawTail, tried) {
3104
3712
  const bs = bodySegments[bodyIndex];
3105
3713
  if (!bs) {
3106
- for(let i = fileIndex; i < file.length; i++){
3714
+ if (partial) return fileIndex >= fileLength || fileIndex === fileLength - 1 && '' === file[fileIndex];
3715
+ for(let i = fileIndex; i < fileLength; i++){
3107
3716
  sawTail = true;
3108
3717
  const f = file[i];
3109
3718
  if ('.' === f || '..' === f || !this.options.dot && f.startsWith('.')) return false;
3110
3719
  }
3111
3720
  return sawTail;
3112
3721
  }
3113
- const [body, after] = bs;
3722
+ const [body, need] = bs;
3723
+ const after = partial ? fileLength : fileLength - need;
3114
3724
  while(fileIndex <= after){
3115
- const m = this.#matchOne(file.slice(0, fileIndex + body.length), body, partial, fileIndex, 0);
3725
+ const key = bodyIndex * (file.length + 1) + fileIndex;
3726
+ if (tried.has(key)) return false;
3727
+ tried.add(key);
3728
+ const m = this.#matchOne(file, body, partial, fileIndex, 0, fileIndex + body.length);
3116
3729
  if (m && globStarDepth < this.maxGlobstarRecursion) {
3117
- const sub = this.#matchGlobStarBodySections(file, bodySegments, fileIndex + body.length, bodyIndex + 1, partial, globStarDepth + 1, sawTail);
3730
+ const sub = this.#matchGlobStarBodySections(file, bodySegments, fileLength, fileIndex + body.length, bodyIndex + 1, partial, globStarDepth + 1, sawTail, tried);
3118
3731
  if (false !== sub) return sub;
3119
3732
  }
3733
+ if (fileIndex === after) break;
3120
3734
  const f = file[fileIndex];
3121
3735
  if ('.' === f || '..' === f || !this.options.dot && f.startsWith('.')) return false;
3122
3736
  fileIndex++;
3123
3737
  }
3124
3738
  return partial || null;
3125
3739
  }
3126
- #matchOne(file, pattern, partial, fileIndex, patternIndex) {
3740
+ #matchOne(file, pattern, partial, fileIndex, patternIndex, fileEnd = file.length) {
3127
3741
  let fi;
3128
3742
  let pi;
3129
3743
  let pl;
3130
3744
  let fl;
3131
- for(fi = fileIndex, pi = patternIndex, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++){
3132
- this.debug('matchOne loop');
3745
+ for(fi = fileIndex, pi = patternIndex, fl = Math.min(fileEnd, file.length), pl = pattern.length; fi < fl && pi < pl; fi++, pi++){
3133
3746
  let p = pattern[pi];
3134
3747
  let f = file[fi];
3135
- this.debug(pattern, p, f);
3136
3748
  if (false === p || p === GLOBSTAR) return false;
3137
- let hit;
3138
- if ('string' == typeof p) {
3139
- hit = f === p;
3140
- this.debug('string match', p, f, hit);
3141
- } else {
3142
- hit = p.test(f);
3143
- this.debug('pattern match', p, f, hit);
3144
- }
3145
- if (!hit) return false;
3749
+ if (!portionMatch(p, f)) return false;
3146
3750
  }
3147
3751
  if (fi === fl && pi === pl) return true;
3148
3752
  else if (fi === fl) return partial;
@@ -3152,81 +3756,57 @@ var __webpack_exports__ = {};
3152
3756
  braceExpand() {
3153
3757
  return braceExpand(this.pattern, this.options);
3154
3758
  }
3759
+ #expandBraces() {
3760
+ const { pattern } = this;
3761
+ if (this.options.nobrace) return this.braceExpand();
3762
+ let code = 0xe000;
3763
+ while(pattern.includes(String.fromCharCode(code)))if (++code > 0xf8ff) return this.braceExpand();
3764
+ const mark = String.fromCharCode(code);
3765
+ let found = false;
3766
+ const marked = pattern.replace(rangeRe, (m, lo, hi)=>{
3767
+ const a = Number(lo);
3768
+ const b = Number(hi);
3769
+ if (!Number.isSafeInteger(a) || !Number.isSafeInteger(b) || Math.abs(a - b) + 1 < RANGE_MIN) return m;
3770
+ found = true;
3771
+ return `${mark}${lo}..${hi}${mark}`;
3772
+ });
3773
+ if (!found) return this.braceExpand();
3774
+ const set = braceExpand(marked, this.options);
3775
+ for (const p of set)for (const portion of p.split('/')){
3776
+ const c = portion.indexOf('[');
3777
+ if (-1 !== c && c < portion.lastIndexOf(mark)) return this.braceExpand();
3778
+ if (!this.options.noext && inRepeatOrNegExt(portion, mark)) return this.braceExpand();
3779
+ }
3780
+ this.#rangeMark = mark;
3781
+ return set;
3782
+ }
3155
3783
  parse(pattern) {
3156
3784
  assertValidPattern(pattern);
3157
3785
  const options = this.options;
3158
3786
  if ('**' === pattern) return GLOBSTAR;
3159
3787
  if ('' === pattern) return '';
3160
- let m;
3161
- let fastTest = null;
3162
- if (m = pattern.match(starRE)) fastTest = options.dot ? starTestDot : starTest;
3163
- else if (m = pattern.match(starDotExtRE)) fastTest = (options.nocase ? options.dot ? starDotExtTestNocaseDot : starDotExtTestNocase : options.dot ? starDotExtTestDot : starDotExtTest)(m[1]);
3164
- else if (m = pattern.match(qmarksRE)) fastTest = (options.nocase ? options.dot ? qmarksTestNocaseDot : qmarksTestNocase : options.dot ? qmarksTestDot : qmarksTest)(m);
3165
- else if (m = pattern.match(starDotStarRE)) fastTest = options.dot ? starDotStarTestDot : starDotStarTest;
3166
- else if (m = pattern.match(dotStarRE)) fastTest = dotStarTest;
3167
- const re = ast_AST.fromGlob(pattern, this.options).toMMPattern();
3168
- if (fastTest && 'object' == typeof re) Reflect.defineProperty(re, 'test', {
3169
- value: fastTest
3170
- });
3171
- return re;
3172
- }
3173
- makeRe() {
3174
- if (this.regexp || false === this.regexp) return this.regexp;
3175
- const set = this.set;
3176
- if (!set.length) {
3177
- this.regexp = false;
3178
- return this.regexp;
3179
- }
3180
- const options = this.options;
3181
- const twoStar = options.noglobstar ? esm_star : options.dot ? twoStarDot : twoStarNoDot;
3182
- const flags = new Set(options.nocase ? [
3183
- 'i'
3184
- ] : []);
3185
- let re = set.map((pattern)=>{
3186
- const pp = pattern.map((p)=>{
3187
- if (p instanceof RegExp) for (const f of p.flags.split(''))flags.add(f);
3188
- return 'string' == typeof p ? esm_regExpEscape(p) : p === GLOBSTAR ? GLOBSTAR : p._src;
3189
- });
3190
- pp.forEach((p, i)=>{
3191
- const next = pp[i + 1];
3192
- const prev = pp[i - 1];
3193
- if (p !== GLOBSTAR || prev === GLOBSTAR) return;
3194
- if (void 0 === prev) if (void 0 !== next && next !== GLOBSTAR) pp[i + 1] = '(?:\\/|' + twoStar + '\\/)?' + next;
3195
- else pp[i] = twoStar;
3196
- else if (void 0 === next) pp[i - 1] = prev + '(?:\\/|\\/' + twoStar + ')?';
3197
- else if (next !== GLOBSTAR) {
3198
- pp[i - 1] = prev + '(?:\\/|\\/' + twoStar + '\\/)' + next;
3199
- pp[i + 1] = GLOBSTAR;
3788
+ const { nocase, nocaseMagicOnly, noext = false, dot, normalize } = options;
3789
+ const rangeMark = this.#rangeMark;
3790
+ const lit = rangeMark && pattern.includes(rangeMark) ? void 0 : esm_literal(pattern, noext);
3791
+ if (void 0 !== lit && !(nocase && !nocaseMagicOnly && pattern.toUpperCase() !== pattern.toLowerCase())) return this.#norm(lit);
3792
+ if (this.#pending) return PENDING;
3793
+ let m = this.#matchers.get(pattern);
3794
+ if (!m) {
3795
+ if (!noext) assertValidExtglobs(pattern);
3796
+ m = new Matcher(pattern, {
3797
+ nocase,
3798
+ noext,
3799
+ dot,
3800
+ normalize,
3801
+ ...rangeMark && {
3802
+ rangeMark
3200
3803
  }
3201
3804
  });
3202
- const filtered = pp.filter((p)=>p !== GLOBSTAR);
3203
- if (this.partial && filtered.length >= 1) {
3204
- const prefixes = [];
3205
- for(let i = 1; i <= filtered.length; i++)prefixes.push(filtered.slice(0, i).join('/'));
3206
- return '(?:' + prefixes.join('|') + ')';
3207
- }
3208
- return filtered.join('/');
3209
- }).join('|');
3210
- const [open, close] = set.length > 1 ? [
3211
- '(?:',
3212
- ')'
3213
- ] : [
3214
- '',
3215
- ''
3216
- ];
3217
- re = '^' + open + re + close + '$';
3218
- if (this.partial) re = '^(?:\\/|' + open + re.slice(1, -1) + close + ')$';
3219
- if (this.negate) re = '^(?!' + re + ').+$';
3220
- try {
3221
- this.regexp = new RegExp(re, [
3222
- ...flags
3223
- ].join(''));
3224
- } catch {
3225
- this.regexp = false;
3805
+ this.#matchers.set(pattern, m);
3226
3806
  }
3227
- return this.regexp;
3807
+ return m;
3228
3808
  }
3229
- slashSplit(p) {
3809
+ #slashSplit(p) {
3230
3810
  if (this.preserveMultipleSlashes) return p.split('/');
3231
3811
  else if (this.isWindows && /^\/\/[^/]+/.test(p)) return [
3232
3812
  '',
@@ -3235,24 +3815,33 @@ var __webpack_exports__ = {};
3235
3815
  else return p.split(/\/+/);
3236
3816
  }
3237
3817
  match(f, partial = this.partial) {
3238
- this.debug('match', f, this.pattern);
3239
3818
  if (this.comment) return false;
3240
3819
  if (this.empty) return '' === f;
3241
3820
  if ('/' === f && partial) return true;
3242
3821
  const options = this.options;
3243
- if (this.isWindows) f = f.split('\\').join('/');
3244
- const ff = this.slashSplit(f);
3245
- this.debug(this.pattern, 'split', ff);
3822
+ let split = this.#cachedSplit(f);
3823
+ if (!split) {
3824
+ if (!partial && !this.#form && (this.#endCheck || this.#literalCheck) && lastChecked !== f) {
3825
+ lastChecked = f;
3826
+ const can = this.#canMatch(f);
3827
+ if ('no' === can) return options.flipNegate ? false : this.negate;
3828
+ if ('yes' === can) return options.flipNegate ? true : !this.negate;
3829
+ }
3830
+ split = this.#split(f);
3831
+ }
3832
+ const ff = split.parts;
3833
+ const resolved = this.#level2 ? split.resolved ??= this.#levelTwoFileOptimize(ff) : ff;
3246
3834
  const set = this.set;
3247
- this.debug(this.pattern, 'set', set);
3248
3835
  let filename = ff[ff.length - 1];
3249
3836
  if (!filename) for(let i = ff.length - 2; !filename && i >= 0; i--)filename = ff[i];
3250
- for (const pattern of set){
3251
- let file = ff;
3252
- if (options.matchBase && 1 === pattern.length) file = [
3837
+ for(let r = 0; r < set.length; r++){
3838
+ const pattern = set[r];
3839
+ const shape = partial ? void 0 : this.#shapes[r];
3840
+ const hit = 'base' === shape ? portionMatch(pattern[0], filename) : shape ? this.#matchShape(resolved, pattern, shape) : options.matchBase && 1 === pattern.length ? this.#matchRow([
3253
3841
  filename
3254
- ];
3255
- const hit = this.matchOne(file, pattern, partial);
3842
+ ], [
3843
+ filename
3844
+ ], pattern, partial) : this.#matchRow(ff, resolved, pattern, partial);
3256
3845
  if (hit) {
3257
3846
  if (options.flipNegate) return true;
3258
3847
  return !this.negate;
@@ -3265,12 +3854,11 @@ var __webpack_exports__ = {};
3265
3854
  return minimatch.defaults(def).Minimatch;
3266
3855
  }
3267
3856
  }
3268
- minimatch.AST = ast_AST;
3269
3857
  minimatch.Minimatch = esm_Minimatch;
3270
3858
  minimatch.escape = escape_escape;
3271
3859
  minimatch.unescape = unescape_unescape;
3272
- var is_glob = __webpack_require__("./node_modules/.pnpm/is-glob@4.0.3/node_modules/is-glob/index.js");
3273
- var is_glob_default = /*#__PURE__*/ __webpack_require__.n(is_glob);
3860
+ var is_glob = __rspack_context.r("./node_modules/.pnpm/is-glob@4.0.3/node_modules/is-glob/index.js");
3861
+ var is_glob_default = /*#__PURE__*/ __rspack_context.n(is_glob);
3274
3862
  const IGNORED_FILES = [
3275
3863
  'package.json'
3276
3864
  ];
@@ -3329,12 +3917,14 @@ var __webpack_exports__ = {};
3329
3917
  return true;
3330
3918
  }
3331
3919
  const external_node_child_process_namespaceObject = require("node:child_process");
3920
+ const external_node_module_namespaceObject = require("node:module");
3921
+ var external_node_module_default = /*#__PURE__*/ __rspack_context.n(external_node_module_namespaceObject);
3332
3922
  const external_node_url_namespaceObject = require("node:url");
3923
+ var external_node_url_default = /*#__PURE__*/ __rspack_context.n(external_node_url_namespaceObject);
3333
3924
  const external_node_util_namespaceObject = require("node:util");
3334
- const external_node_module_namespaceObject = require("node:module");
3335
3925
  const dist_A = (r)=>null !== r && "object" == typeof r, dist_a = (r, t)=>Object.assign(new Error(`[${r}]: ${t}`), {
3336
3926
  code: r
3337
- }), dist_ = "ERR_INVALID_PACKAGE_CONFIG", E = "ERR_INVALID_PACKAGE_TARGET", dist_I = "ERR_PACKAGE_PATH_NOT_EXPORTED", R = /^\d+$/, O = /^(\.{1,2}|node_modules)$/i, dist_w = /\/|\\/;
3927
+ }), dist_ = "ERR_INVALID_PACKAGE_CONFIG", E = "ERR_INVALID_PACKAGE_TARGET", dist_I = "ERR_PACKAGE_PATH_NOT_EXPORTED", dist_R = /^\d+$/, O = /^(\.{1,2}|node_modules)$/i, dist_w = /\/|\\/;
3338
3928
  var dist_h = ((r)=>(r.Export = "exports", r.Import = "imports", r))(dist_h || {});
3339
3929
  const dist_f = (r, t, e, o, c)=>{
3340
3930
  if (null == t) return [];
@@ -3348,7 +3938,7 @@ var __webpack_exports__ = {};
3348
3938
  if (Array.isArray(t)) return t.flatMap((n)=>dist_f(r, n, e, o, c));
3349
3939
  if (dist_A(t)) {
3350
3940
  for (const n of Object.keys(t)){
3351
- if (R.test(n)) throw dist_a(dist_, "Cannot contain numeric property keys");
3941
+ if (dist_R.test(n)) throw dist_a(dist_, "Cannot contain numeric property keys");
3352
3942
  if ("default" === n || o.includes(n)) return dist_f(r, t[n], e, o, c);
3353
3943
  }
3354
3944
  return [];
@@ -3447,12 +4037,12 @@ var __webpack_exports__ = {};
3447
4037
  function D() {
3448
4038
  let g = n;
3449
4039
  if (48 === e.charCodeAt(n)) n++;
3450
- else for(n++; n < e.length && dist_R(e.charCodeAt(n));)n++;
3451
- if (n < e.length && 46 === e.charCodeAt(n)) if (n++, !(n < e.length && dist_R(e.charCodeAt(n)))) return p = 3, e.substring(g, n);
3452
- else for(n++; n < e.length && dist_R(e.charCodeAt(n));)n++;
4040
+ else for(n++; n < e.length && get_tsconfig_dist_R(e.charCodeAt(n));)n++;
4041
+ if (n < e.length && 46 === e.charCodeAt(n)) if (n++, !(n < e.length && get_tsconfig_dist_R(e.charCodeAt(n)))) return p = 3, e.substring(g, n);
4042
+ else for(n++; n < e.length && get_tsconfig_dist_R(e.charCodeAt(n));)n++;
3453
4043
  let j = n;
3454
- if (n < e.length && (69 === e.charCodeAt(n) || 101 === e.charCodeAt(n))) if (n++, (n < e.length && 43 === e.charCodeAt(n) || 45 === e.charCodeAt(n)) && n++, n < e.length && dist_R(e.charCodeAt(n))) {
3455
- for(n++; n < e.length && dist_R(e.charCodeAt(n));)n++;
4044
+ if (n < e.length && (69 === e.charCodeAt(n) || 101 === e.charCodeAt(n))) if (n++, (n < e.length && 43 === e.charCodeAt(n) || 45 === e.charCodeAt(n)) && n++, n < e.length && get_tsconfig_dist_R(e.charCodeAt(n))) {
4045
+ for(n++; n < e.length && get_tsconfig_dist_R(e.charCodeAt(n));)n++;
3456
4046
  j = n;
3457
4047
  } else p = 3;
3458
4048
  return e.substring(g, j);
@@ -3567,7 +4157,7 @@ var __webpack_exports__ = {};
3567
4157
  }
3568
4158
  return s += String.fromCharCode(g), n++, o = 16;
3569
4159
  case 45:
3570
- if (s += String.fromCharCode(g), n++, n === l || !dist_R(e.charCodeAt(n))) return o = 16;
4160
+ if (s += String.fromCharCode(g), n++, n === l || !get_tsconfig_dist_R(e.charCodeAt(n))) return o = 16;
3571
4161
  case 48:
3572
4162
  case 49:
3573
4163
  case 50:
@@ -3640,10 +4230,10 @@ var __webpack_exports__ = {};
3640
4230
  return 10 === e || 13 === e;
3641
4231
  }
3642
4232
  dist_r(J, "isLineBreak");
3643
- function dist_R(e) {
4233
+ function get_tsconfig_dist_R(e) {
3644
4234
  return e >= 48 && e <= 57;
3645
4235
  }
3646
- dist_r(dist_R, "isDigit");
4236
+ dist_r(get_tsconfig_dist_R, "isDigit");
3647
4237
  var ge;
3648
4238
  (function(e) {
3649
4239
  e[e.lineFeed = 10] = "lineFeed", e[e.carriageReturn = 13] = "carriageReturn", e[e.space = 32] = "space", e[e._0 = 48] = "_0", e[e._1 = 49] = "_1", e[e._2 = 50] = "_2", e[e._3 = 51] = "_3", e[e._4 = 52] = "_4", e[e._5 = 53] = "_5", e[e._6 = 54] = "_6", e[e._7 = 55] = "_7", e[e._8 = 56] = "_8", e[e._9 = 57] = "_9", e[e.a = 97] = "a", e[e.b = 98] = "b", e[e.c = 99] = "c", e[e.d = 100] = "d", e[e.e = 101] = "e", e[e.f = 102] = "f", e[e.g = 103] = "g", e[e.h = 104] = "h", e[e.i = 105] = "i", e[e.j = 106] = "j", e[e.k = 107] = "k", e[e.l = 108] = "l", e[e.m = 109] = "m", e[e.n = 110] = "n", e[e.o = 111] = "o", e[e.p = 112] = "p", e[e.q = 113] = "q", e[e.r = 114] = "r", e[e.s = 115] = "s", e[e.t = 116] = "t", e[e.u = 117] = "u", e[e.v = 118] = "v", e[e.w = 119] = "w", e[e.x = 120] = "x", e[e.y = 121] = "y", e[e.z = 122] = "z", e[e.A = 65] = "A", e[e.B = 66] = "B", e[e.C = 67] = "C", e[e.D = 68] = "D", e[e.E = 69] = "E", e[e.F = 70] = "F", e[e.G = 71] = "G", e[e.H = 72] = "H", e[e.I = 73] = "I", e[e.J = 74] = "J", e[e.K = 75] = "K", e[e.L = 76] = "L", e[e.M = 77] = "M", e[e.N = 78] = "N", e[e.O = 79] = "O", e[e.P = 80] = "P", e[e.Q = 81] = "Q", e[e.R = 82] = "R", e[e.S = 83] = "S", e[e.T = 84] = "T", e[e.U = 85] = "U", e[e.V = 86] = "V", e[e.W = 87] = "W", e[e.X = 88] = "X", e[e.Y = 89] = "Y", e[e.Z = 90] = "Z", e[e.asterisk = 42] = "asterisk", e[e.backslash = 92] = "backslash", e[e.closeBrace = 125] = "closeBrace", e[e.closeBracket = 93] = "closeBracket", e[e.colon = 58] = "colon", e[e.comma = 44] = "comma", e[e.dot = 46] = "dot", e[e.doubleQuote = 34] = "doubleQuote", e[e.minus = 45] = "minus", e[e.openBrace = 123] = "openBrace", e[e.openBracket = 91] = "openBracket", e[e.plus = 43] = "plus", e[e.slash = 47] = "slash", e[e.formFeed = 12] = "formFeed", e[e.tab = 9] = "tab";
@@ -3869,10 +4459,10 @@ var __webpack_exports__ = {};
3869
4459
  (function(e) {
3870
4460
  e[e.None = 0] = "None", e[e.UnexpectedEndOfComment = 1] = "UnexpectedEndOfComment", e[e.UnexpectedEndOfString = 2] = "UnexpectedEndOfString", e[e.UnexpectedEndOfNumber = 3] = "UnexpectedEndOfNumber", e[e.InvalidUnicode = 4] = "InvalidUnicode", e[e.InvalidEscapeCharacter = 5] = "InvalidEscapeCharacter", e[e.InvalidCharacter = 6] = "InvalidCharacter";
3871
4461
  })(ke || (ke = {}));
3872
- var dist_me;
4462
+ var me;
3873
4463
  (function(e) {
3874
4464
  e[e.OpenBraceToken = 1] = "OpenBraceToken", e[e.CloseBraceToken = 2] = "CloseBraceToken", e[e.OpenBracketToken = 3] = "OpenBracketToken", e[e.CloseBracketToken = 4] = "CloseBracketToken", e[e.CommaToken = 5] = "CommaToken", e[e.ColonToken = 6] = "ColonToken", e[e.NullKeyword = 7] = "NullKeyword", e[e.TrueKeyword = 8] = "TrueKeyword", e[e.FalseKeyword = 9] = "FalseKeyword", e[e.StringLiteral = 10] = "StringLiteral", e[e.NumericLiteral = 11] = "NumericLiteral", e[e.LineCommentTrivia = 12] = "LineCommentTrivia", e[e.BlockCommentTrivia = 13] = "BlockCommentTrivia", e[e.LineBreakTrivia = 14] = "LineBreakTrivia", e[e.Trivia = 15] = "Trivia", e[e.Unknown = 16] = "Unknown", e[e.EOF = 17] = "EOF";
3875
- })(dist_me || (dist_me = {}));
4465
+ })(me || (me = {}));
3876
4466
  const Ve = Je;
3877
4467
  var de;
3878
4468
  (function(e) {
@@ -4348,11 +4938,16 @@ var __webpack_exports__ = {};
4348
4938
  }
4349
4939
  async function resolveTypeScriptGoNativeExecutablePath(packageJsonPath, packageName) {
4350
4940
  const getExePathPath = external_node_path_default().resolve(external_node_path_default().dirname(packageJsonPath), './lib/getExePath.js');
4351
- const getExePathUrl = (0, external_node_url_namespaceObject.pathToFileURL)(getExePathPath).href;
4941
+ const getExePathUrl = external_node_url_default().pathToFileURL(getExePathPath).href;
4352
4942
  const getExePathModule = await import(getExePathUrl);
4353
4943
  const getExePath = getExePathModule.default || getExePathModule.getExePath;
4354
4944
  if ('function' != typeof getExePath) throw new Error(`Cannot resolve the native TypeScript executable from "${packageName}".`);
4355
- const executablePath = getExePath();
4945
+ const executablePath = getExePath({
4946
+ fs: external_node_fs_default(),
4947
+ module: external_node_module_default(),
4948
+ path: external_node_path_default(),
4949
+ url: external_node_url_default()
4950
+ });
4356
4951
  if ('string' != typeof executablePath || !external_node_fs_default().existsSync(executablePath)) throw new Error('Executable not found');
4357
4952
  return executablePath;
4358
4953
  }
@@ -4832,8 +5427,8 @@ var __webpack_exports__ = {};
4832
5427
  } else debug('No watch file system found - plugin may not work correctly.');
4833
5428
  });
4834
5429
  }
4835
- var external_picocolors_ = __webpack_require__("picocolors");
4836
- var external_picocolors_default = /*#__PURE__*/ __webpack_require__.n(external_picocolors_);
5430
+ var external_picocolors_ = __rspack_context.r("picocolors");
5431
+ var external_picocolors_default = /*#__PURE__*/ __rspack_context.n(external_picocolors_);
4837
5432
  const lite_tapable_namespaceObject = require("@rspack/lite-tapable");
4838
5433
  const compilerHookMap = new WeakMap();
4839
5434
  function createPluginHooks() {
@@ -5014,7 +5609,7 @@ var __webpack_exports__ = {};
5014
5609
  });
5015
5610
  }
5016
5611
  const external_node_os_namespaceObject = require("node:os");
5017
- var external_node_os_default = /*#__PURE__*/ __webpack_require__.n(external_node_os_namespaceObject);
5612
+ var external_node_os_default = /*#__PURE__*/ __rspack_context.n(external_node_os_namespaceObject);
5018
5613
  function createPool(size) {
5019
5614
  let pendingPromises = [];
5020
5615
  const pool = {
@@ -5563,7 +6158,7 @@ var __webpack_exports__ = {};
5563
6158
  return external_picocolors_default().gray(issue.code + ': ') + issue.message;
5564
6159
  };
5565
6160
  }
5566
- var lib = __webpack_require__("./node_modules/.pnpm/@babel+code-frame@7.29.7/node_modules/@babel/code-frame/lib/index.js");
6161
+ var lib = __rspack_context.r("./node_modules/.pnpm/@babel+code-frame@7.29.7/node_modules/@babel/code-frame/lib/index.js");
5567
6162
  function createCodeFrameFormatter(options) {
5568
6163
  const basicFormatter = createBasicFormatter();
5569
6164
  return function(issue) {
@@ -5788,10 +6383,10 @@ var __webpack_exports__ = {};
5788
6383
  plugin_define_property(TsCheckerRspackPlugin, "dependenciesPool", dependenciesPool);
5789
6384
  plugin_define_property(TsCheckerRspackPlugin, "pool", issuesPool);
5790
6385
  })();
5791
- exports.TsCheckerRspackPlugin = __webpack_exports__.TsCheckerRspackPlugin;
5792
- for(var __rspack_i in __webpack_exports__)if (-1 === [
6386
+ exports.TsCheckerRspackPlugin = __rspack_exports.TsCheckerRspackPlugin;
6387
+ for(var __rspack_i in __rspack_exports)if (-1 === [
5793
6388
  "TsCheckerRspackPlugin"
5794
- ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
6389
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __rspack_exports[__rspack_i];
5795
6390
  Object.defineProperty(exports, '__esModule', {
5796
6391
  value: true
5797
6392
  });