@stencil/core 4.43.2 → 4.43.3

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.
Files changed (38) hide show
  1. package/cli/index.cjs +379 -154
  2. package/cli/index.js +379 -154
  3. package/cli/package.json +1 -1
  4. package/compiler/package.json +1 -1
  5. package/compiler/stencil.js +2276 -2065
  6. package/dev-server/client/index.js +1 -1
  7. package/dev-server/client/package.json +1 -1
  8. package/dev-server/connector.html +2 -2
  9. package/dev-server/index.js +1 -1
  10. package/dev-server/package.json +1 -1
  11. package/dev-server/server-process.js +346 -137
  12. package/internal/app-data/package.json +1 -1
  13. package/internal/app-globals/package.json +1 -1
  14. package/internal/client/index.js +1 -1
  15. package/internal/client/package.json +1 -1
  16. package/internal/client/patch-browser.js +1 -1
  17. package/internal/hydrate/index.js +423 -214
  18. package/internal/hydrate/package.json +1 -1
  19. package/internal/hydrate/runner.js +396 -189
  20. package/internal/package.json +1 -1
  21. package/internal/stencil-private.d.ts +1 -1
  22. package/internal/stencil-public-compiler.d.ts +61 -6
  23. package/internal/testing/index.js +410 -201
  24. package/internal/testing/package.json +1 -1
  25. package/mock-doc/index.cjs +2 -4
  26. package/mock-doc/index.d.ts +1 -1
  27. package/mock-doc/index.js +2 -4
  28. package/mock-doc/package.json +1 -1
  29. package/package.json +2 -2
  30. package/screenshot/index.js +341 -132
  31. package/screenshot/package.json +1 -1
  32. package/screenshot/pixel-match.js +1 -1
  33. package/sys/node/glob.js +1 -1
  34. package/sys/node/index.js +44 -46
  35. package/sys/node/package.json +1 -1
  36. package/sys/node/worker.js +1 -1
  37. package/testing/index.js +420 -211
  38. package/testing/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /*
2
- Stencil Screenshot v4.43.2 | MIT Licensed | https://stenciljs.com
2
+ Stencil Screenshot v4.43.3 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  "use strict";
5
5
  var __create = Object.create;
@@ -904,8 +904,35 @@ var unescape = (s, { windowsPathsNoEscape = false } = {}) => {
904
904
  };
905
905
 
906
906
  // node_modules/minimatch/dist/esm/ast.js
907
+ var _a;
907
908
  var types = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]);
908
909
  var isExtglobType = (c) => types.has(c);
910
+ var isExtglobAST = (c) => isExtglobType(c.type);
911
+ var adoptionMap = /* @__PURE__ */ new Map([
912
+ ["!", ["@"]],
913
+ ["?", ["?", "@"]],
914
+ ["@", ["@"]],
915
+ ["*", ["*", "+", "?", "@"]],
916
+ ["+", ["+", "@"]]
917
+ ]);
918
+ var adoptionWithSpaceMap = /* @__PURE__ */ new Map([
919
+ ["!", ["?"]],
920
+ ["@", ["?"]],
921
+ ["+", ["?", "*"]]
922
+ ]);
923
+ var adoptionAnyMap = /* @__PURE__ */ new Map([
924
+ ["!", ["?", "@"]],
925
+ ["?", ["?", "@"]],
926
+ ["@", ["?", "@"]],
927
+ ["*", ["*", "+", "?", "@"]],
928
+ ["+", ["+", "@", "?", "*"]]
929
+ ]);
930
+ var usurpMap = /* @__PURE__ */ new Map([
931
+ ["!", /* @__PURE__ */ new Map([["!", "@"]])],
932
+ ["?", /* @__PURE__ */ new Map([["*", "*"], ["+", "*"]])],
933
+ ["@", /* @__PURE__ */ new Map([["!", "!"], ["?", "?"], ["@", "@"], ["*", "*"], ["+", "+"]])],
934
+ ["+", /* @__PURE__ */ new Map([["?", "*"], ["*", "*"]])]
935
+ ]);
909
936
  var startNoTraversal = "(?!(?:^|/)\\.\\.?(?:$|/))";
910
937
  var startNoDot = "(?!\\.)";
911
938
  var addPatternStart = /* @__PURE__ */ new Set(["[", "."]);
@@ -915,8 +942,8 @@ var regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
915
942
  var qmark = "[^/]";
916
943
  var star = qmark + "*?";
917
944
  var starNoEmpty = qmark + "+?";
918
- var _root, _hasMagic, _uflag, _parts, _parent, _parentIndex, _negs, _filledNegs, _options, _toString, _emptyExt, _AST_instances, fillNegs_fn, _AST_static, parseAST_fn, partsToRegExp_fn, parseGlob_fn;
919
- var _AST = class _AST {
945
+ var _root, _hasMagic, _uflag, _parts, _parent, _parentIndex, _negs, _filledNegs, _options, _toString, _emptyExt, _AST_instances, fillNegs_fn, _AST_static, parseAST_fn, canAdoptWithSpace_fn, canAdopt_fn, canAdoptType_fn, adoptWithSpace_fn, adopt_fn, canUsurpType_fn, canUsurp_fn, usurp_fn, flatten_fn, partsToRegExp_fn, parseGlob_fn;
946
+ var AST = class {
920
947
  constructor(type, parent, options = {}) {
921
948
  __privateAdd(this, _AST_instances);
922
949
  __publicField(this, "type");
@@ -969,44 +996,44 @@ var _AST = class _AST {
969
996
  for (const p of parts) {
970
997
  if (p === "")
971
998
  continue;
972
- if (typeof p !== "string" && !(p instanceof _AST && __privateGet(p, _parent) === this)) {
999
+ if (typeof p !== "string" && !(p instanceof _a && __privateGet(p, _parent) === this)) {
973
1000
  throw new Error("invalid part: " + p);
974
1001
  }
975
1002
  __privateGet(this, _parts).push(p);
976
1003
  }
977
1004
  }
978
1005
  toJSON() {
979
- var _a;
1006
+ var _a2;
980
1007
  const ret = this.type === null ? __privateGet(this, _parts).slice().map((p) => typeof p === "string" ? p : p.toJSON()) : [this.type, ...__privateGet(this, _parts).map((p) => p.toJSON())];
981
1008
  if (this.isStart() && !this.type)
982
1009
  ret.unshift([]);
983
- if (this.isEnd() && (this === __privateGet(this, _root) || __privateGet(__privateGet(this, _root), _filledNegs) && ((_a = __privateGet(this, _parent)) == null ? void 0 : _a.type) === "!")) {
1010
+ if (this.isEnd() && (this === __privateGet(this, _root) || __privateGet(__privateGet(this, _root), _filledNegs) && ((_a2 = __privateGet(this, _parent)) == null ? void 0 : _a2.type) === "!")) {
984
1011
  ret.push({});
985
1012
  }
986
1013
  return ret;
987
1014
  }
988
1015
  isStart() {
989
- var _a;
1016
+ var _a2;
990
1017
  if (__privateGet(this, _root) === this)
991
1018
  return true;
992
- if (!((_a = __privateGet(this, _parent)) == null ? void 0 : _a.isStart()))
1019
+ if (!((_a2 = __privateGet(this, _parent)) == null ? void 0 : _a2.isStart()))
993
1020
  return false;
994
1021
  if (__privateGet(this, _parentIndex) === 0)
995
1022
  return true;
996
1023
  const p = __privateGet(this, _parent);
997
1024
  for (let i = 0; i < __privateGet(this, _parentIndex); i++) {
998
1025
  const pp = __privateGet(p, _parts)[i];
999
- if (!(pp instanceof _AST && pp.type === "!")) {
1026
+ if (!(pp instanceof _a && pp.type === "!")) {
1000
1027
  return false;
1001
1028
  }
1002
1029
  }
1003
1030
  return true;
1004
1031
  }
1005
1032
  isEnd() {
1006
- var _a, _b, _c;
1033
+ var _a2, _b, _c;
1007
1034
  if (__privateGet(this, _root) === this)
1008
1035
  return true;
1009
- if (((_a = __privateGet(this, _parent)) == null ? void 0 : _a.type) === "!")
1036
+ if (((_a2 = __privateGet(this, _parent)) == null ? void 0 : _a2.type) === "!")
1010
1037
  return true;
1011
1038
  if (!((_b = __privateGet(this, _parent)) == null ? void 0 : _b.isEnd()))
1012
1039
  return false;
@@ -1022,16 +1049,16 @@ var _AST = class _AST {
1022
1049
  this.push(part.clone(this));
1023
1050
  }
1024
1051
  clone(parent) {
1025
- const c = new _AST(this.type, parent);
1052
+ const c = new _a(this.type, parent);
1026
1053
  for (const p of __privateGet(this, _parts)) {
1027
1054
  c.copyIn(p);
1028
1055
  }
1029
1056
  return c;
1030
1057
  }
1031
1058
  static fromGlob(pattern, options = {}) {
1032
- var _a;
1033
- const ast = new _AST(null, void 0, options);
1034
- __privateMethod(_a = _AST, _AST_static, parseAST_fn).call(_a, pattern, ast, 0, options);
1059
+ var _a2;
1060
+ const ast = new _a(null, void 0, options);
1061
+ __privateMethod(_a2 = _a, _AST_static, parseAST_fn).call(_a2, pattern, ast, 0, options, 0);
1035
1062
  return ast;
1036
1063
  }
1037
1064
  // returns the regular expression if there's magic, or the unescaped
@@ -1124,15 +1151,17 @@ var _AST = class _AST {
1124
1151
  // is ^(?!\.), we can just prepend (?!\.) to the pattern (either root
1125
1152
  // or start or whatever) and prepend ^ or / at the Regexp construction.
1126
1153
  toRegExpSource(allowDot) {
1127
- var _a;
1154
+ var _a2;
1128
1155
  const dot = allowDot != null ? allowDot : !!__privateGet(this, _options).dot;
1129
- if (__privateGet(this, _root) === this)
1156
+ if (__privateGet(this, _root) === this) {
1157
+ __privateMethod(this, _AST_instances, flatten_fn).call(this);
1130
1158
  __privateMethod(this, _AST_instances, fillNegs_fn).call(this);
1131
- if (!this.type) {
1159
+ }
1160
+ if (!isExtglobAST(this)) {
1132
1161
  const noEmpty = this.isStart() && this.isEnd();
1133
1162
  const src = __privateGet(this, _parts).map((p) => {
1134
- var _a2;
1135
- const [re, _, hasMagic, uflag] = typeof p === "string" ? __privateMethod(_a2 = _AST, _AST_static, parseGlob_fn).call(_a2, p, __privateGet(this, _hasMagic), noEmpty) : p.toRegExpSource(allowDot);
1163
+ var _a3;
1164
+ const [re, _, hasMagic, uflag] = typeof p === "string" ? __privateMethod(_a3 = _a, _AST_static, parseGlob_fn).call(_a3, p, __privateGet(this, _hasMagic), noEmpty) : p.toRegExpSource(allowDot);
1136
1165
  __privateSet(this, _hasMagic, __privateGet(this, _hasMagic) || hasMagic);
1137
1166
  __privateSet(this, _uflag, __privateGet(this, _uflag) || uflag);
1138
1167
  return re;
@@ -1155,7 +1184,7 @@ var _AST = class _AST {
1155
1184
  }
1156
1185
  }
1157
1186
  let end = "";
1158
- if (this.isEnd() && __privateGet(__privateGet(this, _root), _filledNegs) && ((_a = __privateGet(this, _parent)) == null ? void 0 : _a.type) === "!") {
1187
+ if (this.isEnd() && __privateGet(__privateGet(this, _root), _filledNegs) && ((_a2 = __privateGet(this, _parent)) == null ? void 0 : _a2.type) === "!") {
1159
1188
  end = "(?:$|\\/)";
1160
1189
  }
1161
1190
  const final2 = start2 + src + end;
@@ -1171,9 +1200,10 @@ var _AST = class _AST {
1171
1200
  let body = __privateMethod(this, _AST_instances, partsToRegExp_fn).call(this, dot);
1172
1201
  if (this.isStart() && this.isEnd() && !body && this.type !== "!") {
1173
1202
  const s = this.toString();
1174
- __privateSet(this, _parts, [s]);
1175
- this.type = null;
1176
- __privateSet(this, _hasMagic, void 0);
1203
+ const me = this;
1204
+ __privateSet(me, _parts, [s]);
1205
+ me.type = null;
1206
+ __privateSet(me, _hasMagic, void 0);
1177
1207
  return [s, unescape(this.toString()), false, false];
1178
1208
  }
1179
1209
  let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot ? "" : __privateMethod(this, _AST_instances, partsToRegExp_fn).call(this, true);
@@ -1242,8 +1272,9 @@ fillNegs_fn = function() {
1242
1272
  return this;
1243
1273
  };
1244
1274
  _AST_static = new WeakSet();
1245
- parseAST_fn = function(str, ast, pos, opt) {
1246
- var _a, _b;
1275
+ parseAST_fn = function(str, ast, pos, opt, extDepth) {
1276
+ var _a2, _b, _c, _d, _e;
1277
+ const maxDepth = (_a2 = opt.maxExtglobRecursion) != null ? _a2 : 2;
1247
1278
  let escaping = false;
1248
1279
  let inBrace = false;
1249
1280
  let braceStart = -1;
@@ -1275,11 +1306,12 @@ parseAST_fn = function(str, ast, pos, opt) {
1275
1306
  acc2 += c;
1276
1307
  continue;
1277
1308
  }
1278
- if (!opt.noext && isExtglobType(c) && str.charAt(i2) === "(") {
1309
+ const doRecurse = !opt.noext && isExtglobType(c) && str.charAt(i2) === "(" && extDepth <= maxDepth;
1310
+ if (doRecurse) {
1279
1311
  ast.push(acc2);
1280
1312
  acc2 = "";
1281
- const ext2 = new _AST(c, ast);
1282
- i2 = __privateMethod(_a = _AST, _AST_static, parseAST_fn).call(_a, str, ext2, i2, opt);
1313
+ const ext2 = new _a(c, ast);
1314
+ i2 = __privateMethod(_b = _a, _AST_static, parseAST_fn).call(_b, str, ext2, i2, opt, extDepth + 1);
1283
1315
  ast.push(ext2);
1284
1316
  continue;
1285
1317
  }
@@ -1289,7 +1321,7 @@ parseAST_fn = function(str, ast, pos, opt) {
1289
1321
  return i2;
1290
1322
  }
1291
1323
  let i = pos + 1;
1292
- let part = new _AST(null, ast);
1324
+ let part = new _a(null, ast);
1293
1325
  const parts = [];
1294
1326
  let acc = "";
1295
1327
  while (i < str.length) {
@@ -1316,19 +1348,22 @@ parseAST_fn = function(str, ast, pos, opt) {
1316
1348
  acc += c;
1317
1349
  continue;
1318
1350
  }
1319
- if (isExtglobType(c) && str.charAt(i) === "(") {
1351
+ const doRecurse = isExtglobType(c) && str.charAt(i) === "(" && /* c8 ignore start - the maxDepth is sufficient here */
1352
+ (extDepth <= maxDepth || ast && __privateMethod(_c = ast, _AST_instances, canAdoptType_fn).call(_c, c));
1353
+ if (doRecurse) {
1354
+ const depthAdd = ast && __privateMethod(_d = ast, _AST_instances, canAdoptType_fn).call(_d, c) ? 0 : 1;
1320
1355
  part.push(acc);
1321
1356
  acc = "";
1322
- const ext2 = new _AST(c, part);
1357
+ const ext2 = new _a(c, part);
1323
1358
  part.push(ext2);
1324
- i = __privateMethod(_b = _AST, _AST_static, parseAST_fn).call(_b, str, ext2, i, opt);
1359
+ i = __privateMethod(_e = _a, _AST_static, parseAST_fn).call(_e, str, ext2, i, opt, extDepth + depthAdd);
1325
1360
  continue;
1326
1361
  }
1327
1362
  if (c === "|") {
1328
1363
  part.push(acc);
1329
1364
  acc = "";
1330
1365
  parts.push(part);
1331
- part = new _AST(null, ast);
1366
+ part = new _a(null, ast);
1332
1367
  continue;
1333
1368
  }
1334
1369
  if (c === ")") {
@@ -1347,6 +1382,100 @@ parseAST_fn = function(str, ast, pos, opt) {
1347
1382
  __privateSet(ast, _parts, [str.substring(pos - 1)]);
1348
1383
  return i;
1349
1384
  };
1385
+ canAdoptWithSpace_fn = function(child) {
1386
+ return __privateMethod(this, _AST_instances, canAdopt_fn).call(this, child, adoptionWithSpaceMap);
1387
+ };
1388
+ canAdopt_fn = function(child, map2 = adoptionMap) {
1389
+ if (!child || typeof child !== "object" || child.type !== null || __privateGet(child, _parts).length !== 1 || this.type === null) {
1390
+ return false;
1391
+ }
1392
+ const gc = __privateGet(child, _parts)[0];
1393
+ if (!gc || typeof gc !== "object" || gc.type === null) {
1394
+ return false;
1395
+ }
1396
+ return __privateMethod(this, _AST_instances, canAdoptType_fn).call(this, gc.type, map2);
1397
+ };
1398
+ canAdoptType_fn = function(c, map2 = adoptionAnyMap) {
1399
+ var _a2;
1400
+ return !!((_a2 = map2.get(this.type)) == null ? void 0 : _a2.includes(c));
1401
+ };
1402
+ adoptWithSpace_fn = function(child, index) {
1403
+ const gc = __privateGet(child, _parts)[0];
1404
+ const blank = new _a(null, gc, this.options);
1405
+ __privateGet(blank, _parts).push("");
1406
+ gc.push(blank);
1407
+ __privateMethod(this, _AST_instances, adopt_fn).call(this, child, index);
1408
+ };
1409
+ adopt_fn = function(child, index) {
1410
+ const gc = __privateGet(child, _parts)[0];
1411
+ __privateGet(this, _parts).splice(index, 1, ...__privateGet(gc, _parts));
1412
+ for (const p of __privateGet(gc, _parts)) {
1413
+ if (typeof p === "object")
1414
+ __privateSet(p, _parent, this);
1415
+ }
1416
+ __privateSet(this, _toString, void 0);
1417
+ };
1418
+ canUsurpType_fn = function(c) {
1419
+ const m = usurpMap.get(this.type);
1420
+ return !!(m == null ? void 0 : m.has(c));
1421
+ };
1422
+ canUsurp_fn = function(child) {
1423
+ if (!child || typeof child !== "object" || child.type !== null || __privateGet(child, _parts).length !== 1 || this.type === null || __privateGet(this, _parts).length !== 1) {
1424
+ return false;
1425
+ }
1426
+ const gc = __privateGet(child, _parts)[0];
1427
+ if (!gc || typeof gc !== "object" || gc.type === null) {
1428
+ return false;
1429
+ }
1430
+ return __privateMethod(this, _AST_instances, canUsurpType_fn).call(this, gc.type);
1431
+ };
1432
+ usurp_fn = function(child) {
1433
+ const m = usurpMap.get(this.type);
1434
+ const gc = __privateGet(child, _parts)[0];
1435
+ const nt = m == null ? void 0 : m.get(gc.type);
1436
+ if (!nt)
1437
+ return false;
1438
+ __privateSet(this, _parts, __privateGet(gc, _parts));
1439
+ for (const p of __privateGet(this, _parts)) {
1440
+ if (typeof p === "object")
1441
+ __privateSet(p, _parent, this);
1442
+ }
1443
+ this.type = nt;
1444
+ __privateSet(this, _toString, void 0);
1445
+ __privateSet(this, _emptyExt, false);
1446
+ };
1447
+ flatten_fn = function() {
1448
+ var _a2, _b;
1449
+ if (!isExtglobAST(this)) {
1450
+ for (const p of __privateGet(this, _parts)) {
1451
+ if (typeof p === "object")
1452
+ __privateMethod(_a2 = p, _AST_instances, flatten_fn).call(_a2);
1453
+ }
1454
+ } else {
1455
+ let iterations = 0;
1456
+ let done = false;
1457
+ do {
1458
+ done = true;
1459
+ for (let i = 0; i < __privateGet(this, _parts).length; i++) {
1460
+ const c = __privateGet(this, _parts)[i];
1461
+ if (typeof c === "object") {
1462
+ __privateMethod(_b = c, _AST_instances, flatten_fn).call(_b);
1463
+ if (__privateMethod(this, _AST_instances, canAdopt_fn).call(this, c)) {
1464
+ done = false;
1465
+ __privateMethod(this, _AST_instances, adopt_fn).call(this, c, i);
1466
+ } else if (__privateMethod(this, _AST_instances, canAdoptWithSpace_fn).call(this, c)) {
1467
+ done = false;
1468
+ __privateMethod(this, _AST_instances, adoptWithSpace_fn).call(this, c, i);
1469
+ } else if (__privateMethod(this, _AST_instances, canUsurp_fn).call(this, c)) {
1470
+ done = false;
1471
+ __privateMethod(this, _AST_instances, usurp_fn).call(this, c);
1472
+ }
1473
+ }
1474
+ }
1475
+ } while (!done && ++iterations < 10);
1476
+ }
1477
+ __privateSet(this, _toString, void 0);
1478
+ };
1350
1479
  partsToRegExp_fn = function(dot) {
1351
1480
  return __privateGet(this, _parts).map((p) => {
1352
1481
  if (typeof p === "string") {
@@ -1361,11 +1490,13 @@ parseGlob_fn = function(glob, hasMagic, noEmpty = false) {
1361
1490
  let escaping = false;
1362
1491
  let re = "";
1363
1492
  let uflag = false;
1493
+ let inStar = false;
1364
1494
  for (let i = 0; i < glob.length; i++) {
1365
1495
  const c = glob.charAt(i);
1366
1496
  if (escaping) {
1367
1497
  escaping = false;
1368
1498
  re += (reSpecials.has(c) ? "\\" : "") + c;
1499
+ inStar = false;
1369
1500
  continue;
1370
1501
  }
1371
1502
  if (c === "\\") {
@@ -1383,16 +1514,19 @@ parseGlob_fn = function(glob, hasMagic, noEmpty = false) {
1383
1514
  uflag = uflag || needUflag;
1384
1515
  i += consumed - 1;
1385
1516
  hasMagic = hasMagic || magic;
1517
+ inStar = false;
1386
1518
  continue;
1387
1519
  }
1388
1520
  }
1389
1521
  if (c === "*") {
1390
- if (noEmpty && glob === "*")
1391
- re += starNoEmpty;
1392
- else
1393
- re += star;
1522
+ if (inStar)
1523
+ continue;
1524
+ inStar = true;
1525
+ re += noEmpty && /^[*]+$/.test(glob) ? starNoEmpty : star;
1394
1526
  hasMagic = true;
1395
1527
  continue;
1528
+ } else {
1529
+ inStar = false;
1396
1530
  }
1397
1531
  if (c === "?") {
1398
1532
  re += qmark;
@@ -1403,8 +1537,8 @@ parseGlob_fn = function(glob, hasMagic, noEmpty = false) {
1403
1537
  }
1404
1538
  return [re, unescape(glob), !!hasMagic, uflag];
1405
1539
  };
1406
- __privateAdd(_AST, _AST_static);
1407
- var AST = _AST;
1540
+ __privateAdd(AST, _AST_static);
1541
+ _a = AST;
1408
1542
 
1409
1543
  // node_modules/minimatch/dist/esm/escape.js
1410
1544
  var escape = (s, { windowsPathsNoEscape = false } = {}) => {
@@ -1543,28 +1677,33 @@ var match = (list, pattern, options = {}) => {
1543
1677
  minimatch.match = match;
1544
1678
  var globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
1545
1679
  var regExpEscape2 = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
1680
+ var _Minimatch_instances, matchGlobstar_fn, matchGlobStarBodySections_fn, matchOne_fn;
1546
1681
  var Minimatch = class {
1547
- options;
1548
- set;
1549
- pattern;
1550
- windowsPathsNoEscape;
1551
- nonegate;
1552
- negate;
1553
- comment;
1554
- empty;
1555
- preserveMultipleSlashes;
1556
- partial;
1557
- globSet;
1558
- globParts;
1559
- nocase;
1560
- isWindows;
1561
- platform;
1562
- windowsNoMagicRoot;
1563
- regexp;
1564
1682
  constructor(pattern, options = {}) {
1683
+ __privateAdd(this, _Minimatch_instances);
1684
+ __publicField(this, "options");
1685
+ __publicField(this, "set");
1686
+ __publicField(this, "pattern");
1687
+ __publicField(this, "windowsPathsNoEscape");
1688
+ __publicField(this, "nonegate");
1689
+ __publicField(this, "negate");
1690
+ __publicField(this, "comment");
1691
+ __publicField(this, "empty");
1692
+ __publicField(this, "preserveMultipleSlashes");
1693
+ __publicField(this, "partial");
1694
+ __publicField(this, "globSet");
1695
+ __publicField(this, "globParts");
1696
+ __publicField(this, "nocase");
1697
+ __publicField(this, "isWindows");
1698
+ __publicField(this, "platform");
1699
+ __publicField(this, "windowsNoMagicRoot");
1700
+ __publicField(this, "maxGlobstarRecursion");
1701
+ __publicField(this, "regexp");
1702
+ var _a2;
1565
1703
  assertValidPattern(pattern);
1566
1704
  options = options || {};
1567
1705
  this.options = options;
1706
+ this.maxGlobstarRecursion = (_a2 = options.maxGlobstarRecursion) != null ? _a2 : 200;
1568
1707
  this.pattern = pattern;
1569
1708
  this.platform = options.platform || defaultPlatform;
1570
1709
  this.isWindows = this.platform === "win32";
@@ -1832,10 +1971,11 @@ var Minimatch = class {
1832
1971
  for (let i = 0; i < globParts.length - 1; i++) {
1833
1972
  for (let j = i + 1; j < globParts.length; j++) {
1834
1973
  const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
1835
- if (!matched)
1836
- continue;
1837
- globParts[i] = matched;
1838
- globParts[j] = [];
1974
+ if (matched) {
1975
+ globParts[i] = [];
1976
+ globParts[j] = matched;
1977
+ break;
1978
+ }
1839
1979
  }
1840
1980
  }
1841
1981
  return globParts.filter((gs) => gs.length);
@@ -1896,7 +2036,8 @@ var Minimatch = class {
1896
2036
  // out of pattern, then that's fine, as long as all
1897
2037
  // the parts match.
1898
2038
  matchOne(file, pattern, partial = false) {
1899
- const options = this.options;
2039
+ let fileStartIndex = 0;
2040
+ let patternStartIndex = 0;
1900
2041
  if (this.isWindows) {
1901
2042
  const fileDrive = typeof file[0] === "string" && /^[a-z]:$/i.test(file[0]);
1902
2043
  const fileUNC = !fileDrive && file[0] === "" && file[1] === "" && file[2] === "?" && /^[a-z]:$/i.test(file[3]);
@@ -1905,14 +2046,14 @@ var Minimatch = class {
1905
2046
  const fdi = fileUNC ? 3 : fileDrive ? 0 : void 0;
1906
2047
  const pdi = patternUNC ? 3 : patternDrive ? 0 : void 0;
1907
2048
  if (typeof fdi === "number" && typeof pdi === "number") {
1908
- const [fd, pd] = [file[fdi], pattern[pdi]];
2049
+ const [fd, pd] = [
2050
+ file[fdi],
2051
+ pattern[pdi]
2052
+ ];
1909
2053
  if (fd.toLowerCase() === pd.toLowerCase()) {
1910
2054
  pattern[pdi] = fd;
1911
- if (pdi > fdi) {
1912
- pattern = pattern.slice(pdi);
1913
- } else if (fdi > pdi) {
1914
- file = file.slice(fdi);
1915
- }
2055
+ patternStartIndex = pdi;
2056
+ fileStartIndex = fdi;
1916
2057
  }
1917
2058
  }
1918
2059
  }
@@ -1920,71 +2061,10 @@ var Minimatch = class {
1920
2061
  if (optimizationLevel >= 2) {
1921
2062
  file = this.levelTwoFileOptimize(file);
1922
2063
  }
1923
- this.debug("matchOne", this, { file, pattern });
1924
- this.debug("matchOne", file.length, pattern.length);
1925
- for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
1926
- this.debug("matchOne loop");
1927
- var p = pattern[pi];
1928
- var f = file[fi];
1929
- this.debug(pattern, p, f);
1930
- if (p === false) {
1931
- return false;
1932
- }
1933
- if (p === GLOBSTAR) {
1934
- this.debug("GLOBSTAR", [pattern, p, f]);
1935
- var fr = fi;
1936
- var pr = pi + 1;
1937
- if (pr === pl) {
1938
- this.debug("** at the end");
1939
- for (; fi < fl; fi++) {
1940
- if (file[fi] === "." || file[fi] === ".." || !options.dot && file[fi].charAt(0) === ".")
1941
- return false;
1942
- }
1943
- return true;
1944
- }
1945
- while (fr < fl) {
1946
- var swallowee = file[fr];
1947
- this.debug("\nglobstar while", file, fr, pattern, pr, swallowee);
1948
- if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
1949
- this.debug("globstar found match!", fr, fl, swallowee);
1950
- return true;
1951
- } else {
1952
- if (swallowee === "." || swallowee === ".." || !options.dot && swallowee.charAt(0) === ".") {
1953
- this.debug("dot detected!", file, fr, pattern, pr);
1954
- break;
1955
- }
1956
- this.debug("globstar swallow a segment, and continue");
1957
- fr++;
1958
- }
1959
- }
1960
- if (partial) {
1961
- this.debug("\n>>> no match, partial?", file, fr, pattern, pr);
1962
- if (fr === fl) {
1963
- return true;
1964
- }
1965
- }
1966
- return false;
1967
- }
1968
- let hit;
1969
- if (typeof p === "string") {
1970
- hit = f === p;
1971
- this.debug("string match", p, f, hit);
1972
- } else {
1973
- hit = p.test(f);
1974
- this.debug("pattern match", p, f, hit);
1975
- }
1976
- if (!hit)
1977
- return false;
1978
- }
1979
- if (fi === fl && pi === pl) {
1980
- return true;
1981
- } else if (fi === fl) {
1982
- return partial;
1983
- } else if (pi === pl) {
1984
- return fi === fl - 1 && file[fi] === "";
1985
- } else {
1986
- throw new Error("wtf?");
2064
+ if (pattern.includes(GLOBSTAR)) {
2065
+ return __privateMethod(this, _Minimatch_instances, matchGlobstar_fn).call(this, file, pattern, partial, fileStartIndex, patternStartIndex);
1987
2066
  }
2067
+ return __privateMethod(this, _Minimatch_instances, matchOne_fn).call(this, file, pattern, partial, fileStartIndex, patternStartIndex);
1988
2068
  }
1989
2069
  braceExpand() {
1990
2070
  return braceExpand(this.pattern, this.options);
@@ -2123,6 +2203,135 @@ var Minimatch = class {
2123
2203
  return minimatch.defaults(def).Minimatch;
2124
2204
  }
2125
2205
  };
2206
+ _Minimatch_instances = new WeakSet();
2207
+ matchGlobstar_fn = function(file, pattern, partial, fileIndex, patternIndex) {
2208
+ const firstgs = pattern.indexOf(GLOBSTAR, patternIndex);
2209
+ const lastgs = pattern.lastIndexOf(GLOBSTAR);
2210
+ const [head, body, tail] = partial ? [
2211
+ pattern.slice(patternIndex, firstgs),
2212
+ pattern.slice(firstgs + 1),
2213
+ []
2214
+ ] : [
2215
+ pattern.slice(patternIndex, firstgs),
2216
+ pattern.slice(firstgs + 1, lastgs),
2217
+ pattern.slice(lastgs + 1)
2218
+ ];
2219
+ if (head.length) {
2220
+ const fileHead = file.slice(fileIndex, fileIndex + head.length);
2221
+ if (!__privateMethod(this, _Minimatch_instances, matchOne_fn).call(this, fileHead, head, partial, 0, 0))
2222
+ return false;
2223
+ fileIndex += head.length;
2224
+ }
2225
+ let fileTailMatch = 0;
2226
+ if (tail.length) {
2227
+ if (tail.length + fileIndex > file.length)
2228
+ return false;
2229
+ let tailStart = file.length - tail.length;
2230
+ if (__privateMethod(this, _Minimatch_instances, matchOne_fn).call(this, file, tail, partial, tailStart, 0)) {
2231
+ fileTailMatch = tail.length;
2232
+ } else {
2233
+ if (file[file.length - 1] !== "" || fileIndex + tail.length === file.length) {
2234
+ return false;
2235
+ }
2236
+ tailStart--;
2237
+ if (!__privateMethod(this, _Minimatch_instances, matchOne_fn).call(this, file, tail, partial, tailStart, 0))
2238
+ return false;
2239
+ fileTailMatch = tail.length + 1;
2240
+ }
2241
+ }
2242
+ if (!body.length) {
2243
+ let sawSome = !!fileTailMatch;
2244
+ for (let i2 = fileIndex; i2 < file.length - fileTailMatch; i2++) {
2245
+ const f = String(file[i2]);
2246
+ sawSome = true;
2247
+ if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) {
2248
+ return false;
2249
+ }
2250
+ }
2251
+ return partial || sawSome;
2252
+ }
2253
+ const bodySegments = [[[], 0]];
2254
+ let currentBody = bodySegments[0];
2255
+ let nonGsParts = 0;
2256
+ const nonGsPartsSums = [0];
2257
+ for (const b of body) {
2258
+ if (b === GLOBSTAR) {
2259
+ nonGsPartsSums.push(nonGsParts);
2260
+ currentBody = [[], 0];
2261
+ bodySegments.push(currentBody);
2262
+ } else {
2263
+ currentBody[0].push(b);
2264
+ nonGsParts++;
2265
+ }
2266
+ }
2267
+ let i = bodySegments.length - 1;
2268
+ const fileLength = file.length - fileTailMatch;
2269
+ for (const b of bodySegments) {
2270
+ b[1] = fileLength - (nonGsPartsSums[i--] + b[0].length);
2271
+ }
2272
+ return !!__privateMethod(this, _Minimatch_instances, matchGlobStarBodySections_fn).call(this, file, bodySegments, fileIndex, 0, partial, 0, !!fileTailMatch);
2273
+ };
2274
+ matchGlobStarBodySections_fn = function(file, bodySegments, fileIndex, bodyIndex, partial, globStarDepth, sawTail) {
2275
+ const bs = bodySegments[bodyIndex];
2276
+ if (!bs) {
2277
+ for (let i = fileIndex; i < file.length; i++) {
2278
+ sawTail = true;
2279
+ const f = file[i];
2280
+ if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) {
2281
+ return false;
2282
+ }
2283
+ }
2284
+ return sawTail;
2285
+ }
2286
+ const [body, after] = bs;
2287
+ while (fileIndex <= after) {
2288
+ const m = __privateMethod(this, _Minimatch_instances, matchOne_fn).call(this, file.slice(0, fileIndex + body.length), body, partial, fileIndex, 0);
2289
+ if (m && globStarDepth < this.maxGlobstarRecursion) {
2290
+ const sub = __privateMethod(this, _Minimatch_instances, matchGlobStarBodySections_fn).call(this, file, bodySegments, fileIndex + body.length, bodyIndex + 1, partial, globStarDepth + 1, sawTail);
2291
+ if (sub !== false)
2292
+ return sub;
2293
+ }
2294
+ const f = file[fileIndex];
2295
+ if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) {
2296
+ return false;
2297
+ }
2298
+ fileIndex++;
2299
+ }
2300
+ return partial || null;
2301
+ };
2302
+ matchOne_fn = function(file, pattern, partial, fileIndex, patternIndex) {
2303
+ let fi;
2304
+ let pi;
2305
+ let pl;
2306
+ let fl;
2307
+ for (fi = fileIndex, pi = patternIndex, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
2308
+ this.debug("matchOne loop");
2309
+ let p = pattern[pi];
2310
+ let f = file[fi];
2311
+ this.debug(pattern, p, f);
2312
+ if (p === false || p === GLOBSTAR)
2313
+ return false;
2314
+ let hit;
2315
+ if (typeof p === "string") {
2316
+ hit = f === p;
2317
+ this.debug("string match", p, f, hit);
2318
+ } else {
2319
+ hit = p.test(f);
2320
+ this.debug("pattern match", p, f, hit);
2321
+ }
2322
+ if (!hit)
2323
+ return false;
2324
+ }
2325
+ if (fi === fl && pi === pl) {
2326
+ return true;
2327
+ } else if (fi === fl) {
2328
+ return partial;
2329
+ } else if (pi === pl) {
2330
+ return fi === fl - 1 && file[fi] === "";
2331
+ } else {
2332
+ throw new Error("wtf?");
2333
+ }
2334
+ };
2126
2335
  minimatch.AST = AST;
2127
2336
  minimatch.Minimatch = Minimatch;
2128
2337
  minimatch.escape = escape;