pi-lens 4.4.7 → 4.4.8
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/CHANGELOG.md +149 -0
- package/README.md +12 -2
- package/config/markdownlint/run-no-fix.mjs +36 -0
- package/dist/{chunk-WME2OQST.js → chunk-2453RRJ2.js} +11 -6
- package/dist/{chunk-FZKFVUEC.js → chunk-2BKUFQKR.js} +276 -208
- package/dist/chunk-2TS4GLOJ.js +31 -0
- package/dist/{chunk-QHSNL7B2.js → chunk-2ZE3AUJQ.js} +12 -14
- package/dist/{chunk-MPKRJBPK.js → chunk-35WKJWO5.js} +28 -30
- package/dist/chunk-3JAHQBSY.js +27 -0
- package/dist/{chunk-4LM3VAZH.js → chunk-3O5EII3W.js} +2 -2
- package/dist/chunk-447YZL4S.js +25 -0
- package/dist/{chunk-H7OR7DFZ.js → chunk-4B2YFN4U.js} +25 -21
- package/dist/{chunk-OSTKYB55.js → chunk-4BKU7PV3.js} +1 -1
- package/dist/{chunk-RRV3FNNM.js → chunk-4LL2VRNY.js} +27 -28
- package/dist/{chunk-BZARLRJW.js → chunk-4NBWFYWW.js} +9 -9
- package/dist/{chunk-KKCK636N.js → chunk-4QG55RRC.js} +12 -12
- package/dist/{chunk-RQS4QQSD.js → chunk-4W52ZKZX.js} +2 -2
- package/dist/{chunk-Z2XAOKHK.js → chunk-565VRUP4.js} +2 -2
- package/dist/{chunk-HWDAVBFU.js → chunk-57X2CDRX.js} +23 -23
- package/dist/{chunk-MB6PXBUA.js → chunk-5F3XF3SX.js} +7 -15
- package/dist/{chunk-O4BJFESU.js → chunk-5RNB4HVK.js} +1 -1
- package/dist/{chunk-ZMAUPOMG.js → chunk-5T5A6YAJ.js} +35 -34
- package/dist/{chunk-4ZYJHQMB.js → chunk-6FIRFP6A.js} +12 -12
- package/dist/{chunk-4YHYPW2G.js → chunk-6GMGEKQN.js} +9 -5
- package/dist/{chunk-4LOE5R5P.js → chunk-6LJOJ6EO.js} +20 -15
- package/dist/{chunk-3YY7IXIL.js → chunk-6YUNI7B5.js} +3 -3
- package/dist/{chunk-PKES3ISE.js → chunk-7ANZ7XDD.js} +2 -2
- package/dist/{chunk-FB5SCCPT.js → chunk-7CGIDRIK.js} +16 -15
- package/dist/{chunk-L3CMBQMH.js → chunk-7MAD5ZAY.js} +16 -17
- package/dist/{chunk-WDBICWH3.js → chunk-7TNILKGY.js} +1 -1
- package/dist/{chunk-RORGS5II.js → chunk-A5GRLYPZ.js} +9 -9
- package/dist/{chunk-MNJIXFX4.js → chunk-AGGUWKRK.js} +1 -1
- package/dist/{chunk-ABPKUVA4.js → chunk-BBET6HD6.js} +1 -1
- package/dist/{chunk-L5JYIU47.js → chunk-BHWW6FAX.js} +14 -13
- package/dist/{chunk-URCQWAQ4.js → chunk-BOPDQ7AZ.js} +23 -21
- package/dist/{chunk-KDX35VXP.js → chunk-BQG2QFVO.js} +158 -133
- package/dist/{chunk-CB4WHS4H.js → chunk-BUZIQDFS.js} +3 -3
- package/dist/{chunk-2PHMIAKO.js → chunk-CM73PPGD.js} +4 -4
- package/dist/{chunk-DH5JPM3K.js → chunk-CUDD35TW.js} +10 -9
- package/dist/{chunk-AWDSEDER.js → chunk-CZL44WFN.js} +2 -2
- package/dist/{chunk-N5WSK2K7.js → chunk-DIWK3LBC.js} +12 -15
- package/dist/{chunk-24BILSZW.js → chunk-DYRZGUMA.js} +2 -2
- package/dist/{chunk-PR6PO3ES.js → chunk-FHEV6T4L.js} +22 -18
- package/dist/{chunk-DQZFQSR5.js → chunk-FRLAUP2B.js} +4 -4
- package/dist/{chunk-RZOXUSPC.js → chunk-G5GV2Q7K.js} +2 -2
- package/dist/{chunk-EKWX4WD3.js → chunk-G6JKM4O7.js} +7 -7
- package/dist/chunk-GGYOZWHW.js +27 -0
- package/dist/{chunk-XT2HTCJ5.js → chunk-GIRBSBGL.js} +6 -5
- package/dist/{chunk-PQJFG24Z.js → chunk-GMROJJRN.js} +1292 -946
- package/dist/{chunk-U6VN4NVL.js → chunk-HHR7WGCI.js} +3 -3
- package/dist/{chunk-TIQJPRDD.js → chunk-HKIL6DCL.js} +3 -2
- package/dist/{chunk-SNDXCFRS.js → chunk-HUAM7QG3.js} +11 -11
- package/dist/{chunk-QOE342SU.js → chunk-HXFUTMX2.js} +2 -2
- package/dist/{chunk-U7BD2QL7.js → chunk-I22THIHI.js} +12 -12
- package/dist/chunk-IE5D3RA5.js +58 -0
- package/dist/{chunk-DPGEAHZT.js → chunk-IYVYZQRL.js} +10 -16
- package/dist/{chunk-3F6BMY53.js → chunk-JBP7KESM.js} +1 -1
- package/dist/{chunk-U5HPROLA.js → chunk-JE6HKLC7.js} +2 -2
- package/dist/{chunk-ZE3KXHS7.js → chunk-JPRDTY5S.js} +85 -3
- package/dist/{chunk-HO6LWE2E.js → chunk-JYLOYTZD.js} +17 -1
- package/dist/{chunk-KW5JQPO5.js → chunk-JZRP4DGP.js} +2 -2
- package/dist/{chunk-CPSR3AVL.js → chunk-KZ4ALBCH.js} +2 -2
- package/dist/{chunk-6IR3ZYIB.js → chunk-L3CLUGDY.js} +3 -3
- package/dist/{chunk-LV4UMYVH.js → chunk-L4NEVZ4T.js} +28 -27
- package/dist/chunk-LPYTPNOJ.js +22 -0
- package/dist/{chunk-WGRJOXED.js → chunk-LSFXZLPW.js} +1016 -636
- package/dist/{chunk-LBLBAFG3.js → chunk-MC6VB2E5.js} +4 -4
- package/dist/{chunk-U2SDMG7C.js → chunk-NM2NWH55.js} +5 -5
- package/dist/{chunk-T7A2HK2B.js → chunk-NSPVR3FN.js} +19 -18
- package/dist/{chunk-ZGSJDWQU.js → chunk-O2ARHQKF.js} +2 -2
- package/dist/{chunk-OXOI55RU.js → chunk-O4N5BQ3T.js} +10 -10
- package/dist/{chunk-3FRLWYBG.js → chunk-OC7VWJBZ.js} +39 -40
- package/dist/chunk-OFNMHPBT.js +89 -0
- package/dist/{chunk-HR3OJ3TH.js → chunk-OWTG6UMO.js} +21 -21
- package/dist/{chunk-75GAYVNO.js → chunk-OY7WZI7Q.js} +6 -6
- package/dist/{chunk-ZJTT47IG.js → chunk-OZWXLJMX.js} +2 -2
- package/dist/{chunk-F6X3YJWD.js → chunk-PIQQM32Y.js} +2 -2
- package/dist/chunk-PKLB2XJL.js +8 -0
- package/dist/{chunk-EAOK7MIZ.js → chunk-PKSUMEPT.js} +17 -4
- package/dist/{chunk-YISME6ON.js → chunk-PPKECBPP.js} +1 -1
- package/dist/{chunk-4L36HG27.js → chunk-R2QQC33W.js} +14 -14
- package/dist/{chunk-LUBPZN36.js → chunk-R4QWJQ2H.js} +11 -11
- package/dist/{chunk-V63BC55Q.js → chunk-RGGH6M34.js} +1 -1
- package/dist/{chunk-Y7F7IEE3.js → chunk-RZG472YW.js} +65 -7
- package/dist/{chunk-PUZ3E2J4.js → chunk-SDFKOLSF.js} +6 -6
- package/dist/{chunk-YHC2O2WO.js → chunk-SFLHSL5R.js} +9 -9
- package/dist/{chunk-CCV2EU7T.js → chunk-SP4TFY5F.js} +14 -13
- package/dist/{chunk-J6JP25XU.js → chunk-SQC7K3SP.js} +4 -3
- package/dist/{chunk-3K2F6UDZ.js → chunk-T2S3FNNJ.js} +44 -42
- package/dist/{chunk-2TF6RXWB.js → chunk-TV6RXRYH.js} +10 -10
- package/dist/{chunk-GNSIWBAT.js → chunk-U3AS2FR6.js} +3 -3
- package/dist/{chunk-F7K5IBZG.js → chunk-UHHLR2VY.js} +40 -40
- package/dist/chunk-UYXV5NIS.js +20 -0
- package/dist/{chunk-VSFLRN5Y.js → chunk-VLQ7UKZH.js} +1 -1
- package/dist/{chunk-VUZWQ7UG.js → chunk-VN3L2JWZ.js} +46 -72
- package/dist/{chunk-NA7SEXHE.js → chunk-VOP4PJKA.js} +7 -7
- package/dist/{chunk-F5Z6URKM.js → chunk-VOXTCULR.js} +2 -2
- package/dist/{chunk-LLS45EWB.js → chunk-VPLBLWFO.js} +6 -8
- package/dist/chunk-W3BGKBBK.js +27 -0
- package/dist/{chunk-ZKXQKGWZ.js → chunk-WC6WRNQT.js} +4 -3
- package/dist/{chunk-YVHBNSME.js → chunk-WMDUT4KH.js} +1148 -1132
- package/dist/{chunk-KXF5R4UN.js → chunk-WQV6BI4Q.js} +1 -1
- package/dist/chunk-WXUDRAG6.js +24 -0
- package/dist/{chunk-KPPJTH44.js → chunk-X35S7HSB.js} +28 -10
- package/dist/{chunk-JMEKXFOL.js → chunk-X66YJ2SS.js} +40 -34
- package/dist/{chunk-CE6VMBCB.js → chunk-XOMGO63G.js} +22 -21
- package/dist/{chunk-LS3QJRUB.js → chunk-XWIME22V.js} +13 -13
- package/dist/{chunk-R5MOQM2H.js → chunk-XYLC35E4.js} +119 -87
- package/dist/{chunk-OE5ZBP7F.js → chunk-YHGYAEFH.js} +18 -18
- package/dist/{chunk-7E2563GA.js → chunk-ZFORSIED.js} +13 -13
- package/dist/{chunk-E7HJ56Y7.js → chunk-ZKLTNLAW.js} +64 -73
- package/dist/chunk-ZONZ6YY3.js +74 -0
- package/dist/chunk-ZSM35JF4.js +30 -0
- package/dist/{chunk-RC2Z6K47.js → chunk-ZZDIOAAJ.js} +15 -6
- package/dist/index.js +6993 -5396
- package/dist/mcp/analyze-cli.js +10 -10
- package/dist/mcp/cli.js +44 -42
- package/dist/mcp/server.js +1627 -504
- package/dist/mcp/worker.js +62 -61
- package/dist/probes/installer.js +20 -19
- package/docs/adr/0003-git-guard-latch-writer.md +11 -6
- package/docs/agent-tools.md +18 -8
- package/docs/alignment-families.md +29 -0
- package/docs/ast-grep_rules_catalog.md +6 -4
- package/docs/ci-bot-pr-checks.md +126 -0
- package/docs/configuration.md +99 -3
- package/docs/defect-shapes.md +55 -12
- package/docs/engineering-principles.md +27 -2
- package/docs/features.md +2 -2
- package/docs/invariants/git-guard-host.md +7 -3
- package/docs/invariants/language-config.md +15 -4
- package/docs/invariants/lsp-trust-exec.md +16 -2
- package/docs/invariants/paths-os.md +4 -2
- package/docs/lsp-capability-matrix.md +119 -39
- package/docs/merge-queue-rollout.md +1 -1
- package/docs/pi-lens-fixer.md +24 -17
- package/docs/pi-lens-merge-policy.md +20 -11
- package/docs/pi-lens-monitor.md +9 -0
- package/docs/pi-lens-orchestration.md +4 -1
- package/docs/pi-lens-reviewer.md +5 -5
- package/docs/pi-lens-subagent.md +6 -3
- package/docs/public-api-stability.md +18 -2
- package/docs/schema/pi-lens-config-v1.json +10 -0
- package/docs/settings.md +10 -6
- package/docs/word-index.md +17 -5
- package/package.json +5 -3
- package/rules/ast-grep-rules/rule-tests/no-accumulating-spread-js-test.yml +37 -0
- package/rules/ast-grep-rules/rule-tests/ts-redundant-filter-map-test.yml +12 -1
- package/rules/ast-grep-rules/rule-tests-disabled/filter-then-map-js-test.yml +12 -0
- package/rules/ast-grep-rules/rule-tests-disabled/filter-then-map-test.yml +25 -0
- package/rules/ast-grep-rules/rules/no-accumulating-spread-js.yml +49 -1
- package/rules/ast-grep-rules/rules/ts-redundant-filter-map.yml +9 -1
- package/rules/ast-grep-rules/rules-disabled/filter-then-map-js.yml +17 -0
- package/rules/ast-grep-rules/rules-disabled/filter-then-map.yml +36 -0
- package/rules/ast-grep-rules/self-scan-baseline.json +1 -1
- package/dist/chunk-46TNM7XZ.js +0 -88
- package/dist/chunk-72OKUXSD.js +0 -31
- package/dist/chunk-7GLOLOSH.js +0 -57
- package/dist/chunk-AKUUMGD5.js +0 -26
- package/dist/chunk-ASUXV767.js +0 -22
- package/dist/chunk-CTADOKYM.js +0 -25
- package/dist/chunk-JJ2RRESP.js +0 -58
- package/dist/chunk-LSC3VADM.js +0 -23
- package/dist/chunk-SHLDT3OI.js +0 -27
- package/dist/chunk-UF7RTZSO.js +0 -27
- package/dist/chunk-W4WP2ERB.js +0 -30
- package/dist/chunk-YES5CACN.js +0 -73
|
@@ -431,38 +431,30 @@ function expand_(str, max, maxLength, maxDepth, depth, maxRewrites, isTop) {
|
|
|
431
431
|
return acc;
|
|
432
432
|
}
|
|
433
433
|
|
|
434
|
-
// node_modules/
|
|
435
|
-
var MAX_PATTERN_LENGTH = 1024 * 64;
|
|
436
|
-
var assertValidPattern = (pattern) => {
|
|
437
|
-
if (typeof pattern !== "string") {
|
|
438
|
-
throw new TypeError("invalid pattern");
|
|
439
|
-
}
|
|
440
|
-
if (pattern.length > MAX_PATTERN_LENGTH) {
|
|
441
|
-
throw new TypeError("pattern is too long");
|
|
442
|
-
}
|
|
443
|
-
};
|
|
444
|
-
|
|
445
|
-
// node_modules/minimatch/dist/esm/brace-expressions.js
|
|
434
|
+
// node_modules/@isaacs/nonrecursive-glob-match/dist/esm/parse-class.js
|
|
446
435
|
var posixClasses = {
|
|
447
|
-
"[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}"
|
|
448
|
-
"[:alpha:]": ["\\p{L}\\p{Nl}"
|
|
449
|
-
"[:ascii:]": ["\\x00-\\x7f"
|
|
450
|
-
"[:blank:]": ["\\p{Zs}\\t"
|
|
451
|
-
"[:cntrl:]": ["\\p{Cc}"
|
|
452
|
-
"[:digit:]": ["\\p{Nd}"
|
|
453
|
-
"[:graph:]": ["\\p{Z}\\p{C}", true
|
|
454
|
-
"[:lower:]": ["\\p{Ll}"
|
|
436
|
+
"[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}"],
|
|
437
|
+
"[:alpha:]": ["\\p{L}\\p{Nl}"],
|
|
438
|
+
"[:ascii:]": ["\\x00-\\x7f"],
|
|
439
|
+
"[:blank:]": ["\\p{Zs}\\t"],
|
|
440
|
+
"[:cntrl:]": ["\\p{Cc}"],
|
|
441
|
+
"[:digit:]": ["\\p{Nd}"],
|
|
442
|
+
"[:graph:]": ["\\p{Z}\\p{C}", true],
|
|
443
|
+
"[:lower:]": ["\\p{Ll}"],
|
|
455
444
|
"[:print:]": ["\\p{C}", true],
|
|
456
|
-
"[:punct:]": ["\\p{P}"
|
|
457
|
-
"[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f"
|
|
458
|
-
"[:upper:]": ["\\p{Lu}"
|
|
459
|
-
"[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}"
|
|
460
|
-
"[:xdigit:]": ["A-Fa-f0-9"
|
|
445
|
+
"[:punct:]": ["\\p{P}\\p{S}"],
|
|
446
|
+
"[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f"],
|
|
447
|
+
"[:upper:]": ["\\p{Lu}"],
|
|
448
|
+
"[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}"],
|
|
449
|
+
"[:xdigit:]": ["A-Fa-f0-9"]
|
|
461
450
|
};
|
|
462
451
|
var braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&");
|
|
463
|
-
var
|
|
464
|
-
var
|
|
465
|
-
|
|
452
|
+
var noMatch = /$./;
|
|
453
|
+
var parseClass = (glob, position, nocase = false, form) => {
|
|
454
|
+
const norm = (c) => {
|
|
455
|
+
const n = form ? c.normalize(form) : c;
|
|
456
|
+
return [...n].length === 1 ? n : c;
|
|
457
|
+
};
|
|
466
458
|
const pos = position;
|
|
467
459
|
if (glob.charAt(pos) !== "[") {
|
|
468
460
|
throw new Error("not in a brace expression");
|
|
@@ -471,13 +463,12 @@ var parseClass = (glob, position) => {
|
|
|
471
463
|
const negs = [];
|
|
472
464
|
let i = pos + 1;
|
|
473
465
|
let sawStart = false;
|
|
474
|
-
let uflag = false;
|
|
475
466
|
let escaping = false;
|
|
476
467
|
let negate = false;
|
|
477
468
|
let endPos = pos;
|
|
478
469
|
let rangeStart = "";
|
|
479
470
|
WHILE: while (i < glob.length) {
|
|
480
|
-
const c = glob.
|
|
471
|
+
const c = String.fromCodePoint(glob.codePointAt(i));
|
|
481
472
|
if ((c === "!" || c === "^") && i === pos + 1) {
|
|
482
473
|
negate = true;
|
|
483
474
|
i++;
|
|
@@ -496,712 +487,727 @@ var parseClass = (glob, position) => {
|
|
|
496
487
|
}
|
|
497
488
|
}
|
|
498
489
|
if (c === "[" && !escaping) {
|
|
499
|
-
for (const [cls, [unip,
|
|
490
|
+
for (const [cls, [unip, neg]] of Object.entries(posixClasses)) {
|
|
500
491
|
if (glob.startsWith(cls, i)) {
|
|
501
492
|
if (rangeStart) {
|
|
502
|
-
return [
|
|
493
|
+
return [noMatch, glob.length - pos];
|
|
503
494
|
}
|
|
504
495
|
i += cls.length;
|
|
505
496
|
if (neg)
|
|
506
497
|
negs.push(unip);
|
|
507
498
|
else
|
|
508
499
|
ranges.push(unip);
|
|
509
|
-
uflag = uflag || u;
|
|
510
500
|
continue WHILE;
|
|
511
501
|
}
|
|
512
502
|
}
|
|
513
503
|
}
|
|
514
504
|
escaping = false;
|
|
505
|
+
const n = norm(c);
|
|
515
506
|
if (rangeStart) {
|
|
516
|
-
if (
|
|
517
|
-
ranges.push(braceEscape(rangeStart) + "-" + braceEscape(
|
|
518
|
-
} else if (
|
|
519
|
-
ranges.push(braceEscape(
|
|
507
|
+
if (n.codePointAt(0) > rangeStart.codePointAt(0)) {
|
|
508
|
+
ranges.push(braceEscape(rangeStart) + "-" + braceEscape(n));
|
|
509
|
+
} else if (n === rangeStart) {
|
|
510
|
+
ranges.push(braceEscape(n));
|
|
520
511
|
}
|
|
521
512
|
rangeStart = "";
|
|
522
|
-
i
|
|
513
|
+
i += c.length;
|
|
523
514
|
continue;
|
|
524
515
|
}
|
|
525
|
-
if (glob.startsWith("-]", i +
|
|
526
|
-
ranges.push(braceEscape(
|
|
527
|
-
i +=
|
|
516
|
+
if (glob.startsWith("-]", i + c.length)) {
|
|
517
|
+
ranges.push(braceEscape(n + "-"));
|
|
518
|
+
i += c.length + 1;
|
|
528
519
|
continue;
|
|
529
520
|
}
|
|
530
|
-
if (glob.startsWith("-", i +
|
|
531
|
-
rangeStart =
|
|
532
|
-
i +=
|
|
521
|
+
if (glob.startsWith("-", i + c.length)) {
|
|
522
|
+
rangeStart = n;
|
|
523
|
+
i += c.length + 1;
|
|
533
524
|
continue;
|
|
534
525
|
}
|
|
535
|
-
ranges.push(braceEscape(
|
|
536
|
-
i
|
|
526
|
+
ranges.push(braceEscape(n));
|
|
527
|
+
i += c.length;
|
|
537
528
|
}
|
|
538
529
|
if (endPos < i) {
|
|
539
|
-
return [
|
|
530
|
+
return [noMatch, 0];
|
|
540
531
|
}
|
|
541
532
|
if (!ranges.length && !negs.length) {
|
|
542
|
-
return [
|
|
543
|
-
}
|
|
544
|
-
if (negs.length === 0 && ranges.length === 1 && /^\\?.$/.test(ranges[0]) && !negate) {
|
|
545
|
-
const r = ranges[0].length === 2 ? ranges[0].slice(-1) : ranges[0];
|
|
546
|
-
return [regexpEscape(r), false, endPos - pos, false];
|
|
533
|
+
return [noMatch, glob.length - pos];
|
|
547
534
|
}
|
|
548
|
-
const sranges = "[" + (negate ? "^" : "") +
|
|
549
|
-
const snegs = "[" + (negate ? "" : "^") +
|
|
550
|
-
const comb = ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs;
|
|
551
|
-
return [comb,
|
|
535
|
+
const sranges = "[" + (negate ? "^" : "") + ranges.join("") + "]";
|
|
536
|
+
const snegs = "[" + (negate ? "" : "^") + negs.join("") + "]";
|
|
537
|
+
const comb = "^" + (ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs);
|
|
538
|
+
return [new RegExp(comb, nocase ? "iu" : "u"), endPos - pos];
|
|
552
539
|
};
|
|
553
540
|
|
|
554
|
-
// node_modules/
|
|
555
|
-
var
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
541
|
+
// node_modules/@isaacs/nonrecursive-glob-match/dist/esm/index.js
|
|
542
|
+
var MATCH = { t: "match", id: 0 };
|
|
543
|
+
var extTypes = "!?+*@";
|
|
544
|
+
var lit = (ch) => ({ t: "lit", ch });
|
|
545
|
+
var reEscape = (s) => s.replace(/[\\^$.*+?()[\]{}|/]/g, "\\$&");
|
|
546
|
+
var newFoldRe = (s) => new RegExp(`^${reEscape(s)}$`, "iu");
|
|
547
|
+
var foldCache = /* @__PURE__ */ new Map();
|
|
548
|
+
var foldRe = (ch) => {
|
|
549
|
+
let re = foldCache.get(ch);
|
|
550
|
+
if (!re) {
|
|
551
|
+
re = newFoldRe(ch);
|
|
552
|
+
if (foldCache.size >= 1e3)
|
|
553
|
+
foldCache.clear();
|
|
554
|
+
foldCache.set(ch, re);
|
|
555
|
+
}
|
|
556
|
+
return re;
|
|
560
557
|
};
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
[
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
["*", ["*", "+", "?", "@"]],
|
|
584
|
-
["+", ["+", "@", "?", "*"]]
|
|
585
|
-
]);
|
|
586
|
-
var usurpMap = /* @__PURE__ */ new Map([
|
|
587
|
-
["!", /* @__PURE__ */ new Map([["!", "@"]])],
|
|
588
|
-
[
|
|
589
|
-
"?",
|
|
590
|
-
/* @__PURE__ */ new Map([
|
|
591
|
-
["*", "*"],
|
|
592
|
-
["+", "*"]
|
|
593
|
-
])
|
|
594
|
-
],
|
|
595
|
-
[
|
|
596
|
-
"@",
|
|
597
|
-
/* @__PURE__ */ new Map([
|
|
598
|
-
["!", "!"],
|
|
599
|
-
["?", "?"],
|
|
600
|
-
["@", "@"],
|
|
601
|
-
["*", "*"],
|
|
602
|
-
["+", "+"]
|
|
603
|
-
])
|
|
604
|
-
],
|
|
605
|
-
[
|
|
606
|
-
"+",
|
|
607
|
-
/* @__PURE__ */ new Map([
|
|
608
|
-
["?", "*"],
|
|
609
|
-
["*", "*"]
|
|
610
|
-
])
|
|
611
|
-
]
|
|
612
|
-
]);
|
|
613
|
-
var startNoTraversal = "(?!(?:^|/)\\.\\.?(?:$|/))";
|
|
614
|
-
var startNoDot = "(?!\\.)";
|
|
615
|
-
var addPatternStart = /* @__PURE__ */ new Set(["[", "."]);
|
|
616
|
-
var justDots = /* @__PURE__ */ new Set(["..", "."]);
|
|
617
|
-
var reSpecials = new Set("().*{}+?[]^$\\!");
|
|
618
|
-
var regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
619
|
-
var qmark = "[^/]";
|
|
620
|
-
var star = qmark + "*?";
|
|
621
|
-
var starNoEmpty = qmark + "+?";
|
|
622
|
-
var ID = 0;
|
|
623
|
-
var AST = class {
|
|
624
|
-
type;
|
|
625
|
-
#root;
|
|
626
|
-
#hasMagic;
|
|
627
|
-
#uflag = false;
|
|
628
|
-
#parts = [];
|
|
629
|
-
#parent;
|
|
630
|
-
#parentIndex;
|
|
631
|
-
#negs;
|
|
632
|
-
#filledNegs = false;
|
|
633
|
-
#options;
|
|
634
|
-
#toString;
|
|
635
|
-
// set to true if it's an extglob with no children
|
|
636
|
-
// (which really means one child of '')
|
|
637
|
-
#emptyExt = false;
|
|
638
|
-
id = ++ID;
|
|
639
|
-
get depth() {
|
|
640
|
-
return (this.#parent?.depth ?? -1) + 1;
|
|
641
|
-
}
|
|
642
|
-
[/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")]() {
|
|
643
|
-
return {
|
|
644
|
-
"@@type": "AST",
|
|
645
|
-
id: this.id,
|
|
646
|
-
type: this.type,
|
|
647
|
-
root: this.#root.id,
|
|
648
|
-
parent: this.#parent?.id,
|
|
649
|
-
depth: this.depth,
|
|
650
|
-
partsLength: this.#parts.length,
|
|
651
|
-
parts: this.#parts
|
|
652
|
-
};
|
|
653
|
-
}
|
|
654
|
-
constructor(type, parent, options = {}) {
|
|
655
|
-
this.type = type;
|
|
656
|
-
if (type)
|
|
657
|
-
this.#hasMagic = true;
|
|
658
|
-
this.#parent = parent;
|
|
659
|
-
this.#root = this.#parent ? this.#parent.#root : this;
|
|
660
|
-
this.#options = this.#root === this ? options : this.#root.#options;
|
|
661
|
-
this.#negs = this.#root === this ? [] : this.#root.#negs;
|
|
662
|
-
if (type === "!" && !this.#root.#filledNegs)
|
|
663
|
-
this.#negs.push(this);
|
|
664
|
-
this.#parentIndex = this.#parent ? this.#parent.#parts.length : 0;
|
|
665
|
-
}
|
|
666
|
-
get hasMagic() {
|
|
667
|
-
if (this.#hasMagic !== void 0)
|
|
668
|
-
return this.#hasMagic;
|
|
669
|
-
for (const p of this.#parts) {
|
|
670
|
-
if (typeof p === "string")
|
|
671
|
-
continue;
|
|
672
|
-
if (p.type || p.hasMagic)
|
|
673
|
-
return this.#hasMagic = true;
|
|
558
|
+
var litMatch = (l, c) => {
|
|
559
|
+
if (c === l.ch)
|
|
560
|
+
return true;
|
|
561
|
+
if (!l.re)
|
|
562
|
+
return false;
|
|
563
|
+
const code = c.charCodeAt(0);
|
|
564
|
+
if (code >= 128)
|
|
565
|
+
return l.re.test(c);
|
|
566
|
+
const ascii = l.ascii ??= new Uint8Array(128);
|
|
567
|
+
ascii[code] ||= l.re.test(c) ? 1 : 2;
|
|
568
|
+
return ascii[code] === 1;
|
|
569
|
+
};
|
|
570
|
+
var tokenize = (p, nocase, noext, form) => {
|
|
571
|
+
const toks = [];
|
|
572
|
+
for (let i = 0; i < p.length; ) {
|
|
573
|
+
const c = String.fromCodePoint(p.codePointAt(i));
|
|
574
|
+
if (c === "\\") {
|
|
575
|
+
const e = p.codePointAt(i + 1);
|
|
576
|
+
const ch = e === void 0 ? c : String.fromCodePoint(e);
|
|
577
|
+
toks.push(lit(ch));
|
|
578
|
+
i += 1 + ch.length;
|
|
579
|
+
continue;
|
|
674
580
|
}
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
}
|
|
681
|
-
#fillNegs() {
|
|
682
|
-
if (this !== this.#root)
|
|
683
|
-
throw new Error("should only call on root");
|
|
684
|
-
if (this.#filledNegs)
|
|
685
|
-
return this;
|
|
686
|
-
this.toString();
|
|
687
|
-
this.#filledNegs = true;
|
|
688
|
-
let n;
|
|
689
|
-
while (n = this.#negs.pop()) {
|
|
690
|
-
if (n.type !== "!")
|
|
581
|
+
if (c === "[") {
|
|
582
|
+
const [re, consumed] = parseClass(p, i, nocase, form);
|
|
583
|
+
if (consumed) {
|
|
584
|
+
toks.push({ t: "class", re });
|
|
585
|
+
i += consumed;
|
|
691
586
|
continue;
|
|
692
|
-
let p = n;
|
|
693
|
-
let pp = p.#parent;
|
|
694
|
-
while (pp) {
|
|
695
|
-
for (let i = p.#parentIndex + 1; !pp.type && i < pp.#parts.length; i++) {
|
|
696
|
-
for (const part of n.#parts) {
|
|
697
|
-
if (typeof part === "string") {
|
|
698
|
-
throw new Error("string part in extglob AST??");
|
|
699
|
-
}
|
|
700
|
-
part.copyIn(pp.#parts[i]);
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
p = pp;
|
|
704
|
-
pp = p.#parent;
|
|
705
587
|
}
|
|
706
588
|
}
|
|
707
|
-
|
|
589
|
+
if (!noext && extTypes.includes(c) && p[i + 1] === "(") {
|
|
590
|
+
toks.push({ t: "open", type: c });
|
|
591
|
+
i += 2;
|
|
592
|
+
continue;
|
|
593
|
+
}
|
|
594
|
+
toks.push(!noext && c === "|" ? { t: "bar" } : !noext && c === ")" ? { t: "close" } : c === "*" ? { t: "star" } : c === "?" ? { t: "any" } : lit(c));
|
|
595
|
+
i += c.length;
|
|
708
596
|
}
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
597
|
+
return toks;
|
|
598
|
+
};
|
|
599
|
+
var pair = (toks) => {
|
|
600
|
+
const pairs = /* @__PURE__ */ new Map();
|
|
601
|
+
const stack = [];
|
|
602
|
+
toks.forEach((tok, i) => {
|
|
603
|
+
if (tok.t === "open")
|
|
604
|
+
stack.push(i);
|
|
605
|
+
else if (tok.t === "close" && stack.length)
|
|
606
|
+
pairs.set(stack.pop(), i);
|
|
607
|
+
});
|
|
608
|
+
return pairs;
|
|
609
|
+
};
|
|
610
|
+
var build = (toks, pairs, start, end, top) => {
|
|
611
|
+
let seq = [];
|
|
612
|
+
const alts = [seq];
|
|
613
|
+
for (let i = start; i < end; i++) {
|
|
614
|
+
const tok = toks[i];
|
|
615
|
+
const close = pairs.get(i);
|
|
616
|
+
if (tok.t === "open" && close !== void 0) {
|
|
617
|
+
const sub = build(toks, pairs, i + 1, close, false);
|
|
618
|
+
seq.push({ t: "ext", type: tok.type, alts: sub });
|
|
619
|
+
i = close;
|
|
620
|
+
} else if (tok.t === "bar" && !top) {
|
|
621
|
+
alts.push(seq = []);
|
|
622
|
+
} else if (tok.t === "open") {
|
|
623
|
+
seq.push(lit(tok.type), lit("("));
|
|
624
|
+
} else if (tok.t === "bar") {
|
|
625
|
+
seq.push(lit("|"));
|
|
626
|
+
} else if (tok.t === "close") {
|
|
627
|
+
seq.push(lit(")"));
|
|
628
|
+
} else {
|
|
629
|
+
seq.push(tok);
|
|
717
630
|
}
|
|
718
631
|
}
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
632
|
+
return alts;
|
|
633
|
+
};
|
|
634
|
+
var normalize = (items, form) => {
|
|
635
|
+
const out = [];
|
|
636
|
+
let run = "";
|
|
637
|
+
const flush = () => {
|
|
638
|
+
for (const ch of run.normalize(form))
|
|
639
|
+
out.push(lit(ch));
|
|
640
|
+
run = "";
|
|
641
|
+
};
|
|
642
|
+
for (const it of items) {
|
|
643
|
+
if (it.t === "lit") {
|
|
644
|
+
run += it.ch;
|
|
645
|
+
continue;
|
|
725
646
|
}
|
|
726
|
-
|
|
647
|
+
flush();
|
|
648
|
+
out.push(it.t === "ext" ? { ...it, alts: it.alts.map((a) => normalize(a, form)) } : it);
|
|
727
649
|
}
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
return
|
|
740
|
-
|
|
650
|
+
flush();
|
|
651
|
+
return out;
|
|
652
|
+
};
|
|
653
|
+
var compile = (items, nocase) => {
|
|
654
|
+
let id = 1;
|
|
655
|
+
const split = (out) => ({ t: "split", id: id++, out });
|
|
656
|
+
const seq = (items2, next) => items2.reduceRight((next2, it) => item(it, next2), next);
|
|
657
|
+
const item = (it, next) => {
|
|
658
|
+
switch (it.t) {
|
|
659
|
+
case "lit":
|
|
660
|
+
const re = nocase ? foldRe(it.ch) : void 0;
|
|
661
|
+
return { t: "lit", id: id++, ch: it.ch, re, next };
|
|
662
|
+
case "any":
|
|
663
|
+
case "star":
|
|
664
|
+
return { t: it.t, id: id++, next };
|
|
665
|
+
case "class":
|
|
666
|
+
return { t: "class", id: id++, re: it.re, next };
|
|
667
|
+
}
|
|
668
|
+
const alts = (next2) => it.alts.map((a) => seq(a, next2));
|
|
669
|
+
switch (it.type) {
|
|
670
|
+
case "@":
|
|
671
|
+
return split(alts(next));
|
|
672
|
+
case "?":
|
|
673
|
+
return split([next, ...alts(next)]);
|
|
674
|
+
case "!":
|
|
675
|
+
return { t: "neg", id: id++, sub: split(alts(MATCH)), next };
|
|
676
|
+
}
|
|
677
|
+
const after = split([]);
|
|
678
|
+
const entry = split(alts(after));
|
|
679
|
+
after.out.push(next, entry);
|
|
680
|
+
return it.type === "*" ? after : entry;
|
|
681
|
+
};
|
|
682
|
+
const start = seq(items, MATCH);
|
|
683
|
+
return [start, id];
|
|
684
|
+
};
|
|
685
|
+
var show = (start) => {
|
|
686
|
+
const lines = [];
|
|
687
|
+
const seen = /* @__PURE__ */ new Set();
|
|
688
|
+
const ref = (n) => n.t === "match" ? "match" : String(n.id);
|
|
689
|
+
const walk = (n, indent) => {
|
|
690
|
+
if (n.t === "match" || seen.has(n))
|
|
691
|
+
return;
|
|
692
|
+
seen.add(n);
|
|
693
|
+
const line = (desc) => lines.push(`${indent}${n.id}: ${desc}`);
|
|
694
|
+
switch (n.t) {
|
|
695
|
+
case "split":
|
|
696
|
+
line(`split -> ${n.out.map(ref).join(", ")}`);
|
|
697
|
+
for (const o of n.out)
|
|
698
|
+
walk(o, indent);
|
|
699
|
+
return;
|
|
700
|
+
case "neg":
|
|
701
|
+
line(`!(${ref(n.sub)}) -> ${ref(n.next)}`);
|
|
702
|
+
walk(n.sub, indent + " ");
|
|
703
|
+
return walk(n.next, indent);
|
|
704
|
+
case "lit":
|
|
705
|
+
line(`${JSON.stringify(n.ch)} -> ${ref(n.next)}`);
|
|
706
|
+
break;
|
|
707
|
+
case "class":
|
|
708
|
+
line(`${n.re} -> ${ref(n.next)}`);
|
|
709
|
+
break;
|
|
710
|
+
default:
|
|
711
|
+
line(`${n.t === "any" ? "?" : "*"} -> ${ref(n.next)}`);
|
|
741
712
|
}
|
|
713
|
+
walk(n.next, indent);
|
|
714
|
+
};
|
|
715
|
+
walk(start, "");
|
|
716
|
+
return [`start -> ${ref(start)}`, ...lines].join("\n");
|
|
717
|
+
};
|
|
718
|
+
var State = class {
|
|
719
|
+
// set by the Sim, to mark the nodes that this state has
|
|
720
|
+
gen;
|
|
721
|
+
threads = [];
|
|
722
|
+
match = false;
|
|
723
|
+
runs = [];
|
|
724
|
+
// the sorted ids of the threads, with 0 for a match, once the
|
|
725
|
+
// state is done
|
|
726
|
+
ids = [];
|
|
727
|
+
constructor(gen) {
|
|
728
|
+
this.gen = gen;
|
|
729
|
+
}
|
|
730
|
+
// no threads, so nothing more can match
|
|
731
|
+
get dead() {
|
|
732
|
+
return !this.threads.length && !this.match && !this.runs.length;
|
|
733
|
+
}
|
|
734
|
+
};
|
|
735
|
+
var sameState = (a, b) => {
|
|
736
|
+
if (a.ids.length !== b.ids.length)
|
|
737
|
+
return false;
|
|
738
|
+
if (a.runs.length !== b.runs.length)
|
|
739
|
+
return false;
|
|
740
|
+
if (a.ids.some((id, i) => id !== b.ids[i]))
|
|
741
|
+
return false;
|
|
742
|
+
return a.runs.every((r) => b.runs.some((o) => o.neg === r.neg && sameState(o.state, r.state)));
|
|
743
|
+
};
|
|
744
|
+
var marks = (size) => ({
|
|
745
|
+
has: new Float64Array(size),
|
|
746
|
+
seen: new Float64Array(size),
|
|
747
|
+
gen: 0
|
|
748
|
+
});
|
|
749
|
+
var Sim = class {
|
|
750
|
+
// `.` and `..` only match literal dots, even with `dot:true`
|
|
751
|
+
dots;
|
|
752
|
+
// the string starts with `.`, and `dot:true` is not set
|
|
753
|
+
dotStart;
|
|
754
|
+
#marks;
|
|
755
|
+
constructor(dots, dotStart, marks2) {
|
|
756
|
+
this.dots = dots;
|
|
757
|
+
this.dotStart = dotStart;
|
|
758
|
+
this.#marks = marks2;
|
|
759
|
+
}
|
|
760
|
+
state() {
|
|
761
|
+
return new State(++this.#marks.gen);
|
|
762
|
+
}
|
|
763
|
+
// sort the ids of a state, once it has all of its threads
|
|
764
|
+
done(state) {
|
|
765
|
+
state.ids = state.threads.map((n) => n.id).sort((a, b) => a - b);
|
|
766
|
+
if (state.match)
|
|
767
|
+
state.ids.unshift(MATCH.id);
|
|
768
|
+
return state;
|
|
769
|
+
}
|
|
770
|
+
// true the first time that the state walks through the node, so
|
|
771
|
+
// that loops in the graph stop
|
|
772
|
+
#visit(state, node) {
|
|
773
|
+
const { seen } = this.#marks;
|
|
774
|
+
if (seen[node.id] === state.gen)
|
|
775
|
+
return false;
|
|
776
|
+
seen[node.id] = state.gen;
|
|
742
777
|
return true;
|
|
743
778
|
}
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
if (this.#parent?.type === "!")
|
|
748
|
-
return true;
|
|
749
|
-
if (!this.#parent?.isEnd())
|
|
779
|
+
#addThread(state, node) {
|
|
780
|
+
const { has } = this.#marks;
|
|
781
|
+
if (has[node.id] === state.gen)
|
|
750
782
|
return false;
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
783
|
+
has[node.id] = state.gen;
|
|
784
|
+
state.threads.push(node);
|
|
785
|
+
return true;
|
|
786
|
+
}
|
|
787
|
+
// wildcards only match a leading dot if `dot:true`. In a negated
|
|
788
|
+
// sub-pattern, this does not apply, because the negation itself
|
|
789
|
+
// can not match a leading dot.
|
|
790
|
+
restricted(i, top) {
|
|
791
|
+
return top && (this.dots || this.dotStart && i === 0);
|
|
792
|
+
}
|
|
793
|
+
add(state, node, i, top) {
|
|
794
|
+
switch (node.t) {
|
|
795
|
+
case "split":
|
|
796
|
+
if (!this.#visit(state, node))
|
|
797
|
+
return;
|
|
798
|
+
for (const o of node.out)
|
|
799
|
+
this.add(state, o, i, top);
|
|
800
|
+
return;
|
|
801
|
+
case "neg":
|
|
802
|
+
if (!this.#visit(state, node))
|
|
803
|
+
return;
|
|
804
|
+
const sub = this.state();
|
|
805
|
+
this.add(sub, node.sub, i, false);
|
|
806
|
+
this.done(sub);
|
|
807
|
+
return this.addRun(state, { t: "run", neg: node, state: sub }, i, top);
|
|
808
|
+
case "star":
|
|
809
|
+
if (this.restricted(i, top))
|
|
810
|
+
return;
|
|
811
|
+
if (this.#addThread(state, node))
|
|
812
|
+
this.add(state, node.next, i, top);
|
|
813
|
+
return;
|
|
814
|
+
case "match":
|
|
815
|
+
state.match = true;
|
|
816
|
+
return;
|
|
817
|
+
default:
|
|
818
|
+
this.#addThread(state, node);
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
addRun(state, run, i, top) {
|
|
822
|
+
for (const r of state.runs) {
|
|
823
|
+
if (r.neg === run.neg && sameState(r.state, run.state))
|
|
824
|
+
return;
|
|
825
|
+
}
|
|
826
|
+
state.runs.push(run);
|
|
827
|
+
if (!run.state.match) {
|
|
828
|
+
this.add(state, run.neg.next, i, top);
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
// the threads after char `c`, at index `i`
|
|
832
|
+
step(state, c, i, top) {
|
|
833
|
+
const next = this.state();
|
|
834
|
+
for (const th of state.threads) {
|
|
835
|
+
switch (th.t) {
|
|
836
|
+
case "lit":
|
|
837
|
+
if (litMatch(th, c)) {
|
|
838
|
+
this.add(next, th.next, i + 1, top);
|
|
792
839
|
}
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
}
|
|
802
|
-
const doRecurse = !opt.noext && isExtglobType(c) && str.charAt(i2) === "(" && extDepth <= maxDepth;
|
|
803
|
-
if (doRecurse) {
|
|
804
|
-
ast.push(acc2);
|
|
805
|
-
acc2 = "";
|
|
806
|
-
const ext2 = new _a(c, ast);
|
|
807
|
-
i2 = _a.#parseAST(str, ext2, i2, opt, extDepth + 1);
|
|
808
|
-
ast.push(ext2);
|
|
809
|
-
continue;
|
|
810
|
-
}
|
|
811
|
-
acc2 += c;
|
|
812
|
-
}
|
|
813
|
-
ast.push(acc2);
|
|
814
|
-
return i2;
|
|
815
|
-
}
|
|
816
|
-
let i = pos + 1;
|
|
817
|
-
let part = new _a(null, ast);
|
|
818
|
-
const parts = [];
|
|
819
|
-
let acc = "";
|
|
820
|
-
while (i < str.length) {
|
|
821
|
-
const c = str.charAt(i++);
|
|
822
|
-
if (escaping || c === "\\") {
|
|
823
|
-
escaping = !escaping;
|
|
824
|
-
acc += c;
|
|
825
|
-
continue;
|
|
826
|
-
}
|
|
827
|
-
if (inBrace) {
|
|
828
|
-
if (i === braceStart + 1) {
|
|
829
|
-
if (c === "^" || c === "!") {
|
|
830
|
-
braceNeg = true;
|
|
840
|
+
break;
|
|
841
|
+
case "any":
|
|
842
|
+
if (!this.restricted(i, top))
|
|
843
|
+
this.add(next, th.next, i + 1, top);
|
|
844
|
+
break;
|
|
845
|
+
case "class":
|
|
846
|
+
if (!this.restricted(i, top) && th.re.test(c)) {
|
|
847
|
+
this.add(next, th.next, i + 1, top);
|
|
831
848
|
}
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
continue;
|
|
837
|
-
} else if (c === "[") {
|
|
838
|
-
inBrace = true;
|
|
839
|
-
braceStart = i;
|
|
840
|
-
braceNeg = false;
|
|
841
|
-
acc += c;
|
|
842
|
-
continue;
|
|
843
|
-
}
|
|
844
|
-
const doRecurse = !opt.noext && isExtglobType(c) && str.charAt(i) === "(" && /* c8 ignore start - the maxDepth is sufficient here */
|
|
845
|
-
(extDepth <= maxDepth || ast && ast.#canAdoptType(c));
|
|
846
|
-
if (doRecurse) {
|
|
847
|
-
const depthAdd = ast && ast.#canAdoptType(c) ? 0 : 1;
|
|
848
|
-
part.push(acc);
|
|
849
|
-
acc = "";
|
|
850
|
-
const ext2 = new _a(c, part);
|
|
851
|
-
part.push(ext2);
|
|
852
|
-
i = _a.#parseAST(str, ext2, i, opt, extDepth + depthAdd);
|
|
853
|
-
continue;
|
|
854
|
-
}
|
|
855
|
-
if (c === "|") {
|
|
856
|
-
part.push(acc);
|
|
857
|
-
acc = "";
|
|
858
|
-
parts.push(part);
|
|
859
|
-
part = new _a(null, ast);
|
|
860
|
-
continue;
|
|
849
|
+
break;
|
|
850
|
+
case "star":
|
|
851
|
+
if (!this.restricted(i, top))
|
|
852
|
+
this.add(next, th, i + 1, top);
|
|
861
853
|
}
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
854
|
+
}
|
|
855
|
+
if (!this.restricted(i, top)) {
|
|
856
|
+
for (const run of state.runs) {
|
|
857
|
+
if (run.state.dead) {
|
|
858
|
+
this.addRun(next, run, i + 1, top);
|
|
859
|
+
continue;
|
|
865
860
|
}
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
ast.push(...parts, part);
|
|
869
|
-
return i;
|
|
861
|
+
const sub = this.step(run.state, c, i, false);
|
|
862
|
+
this.addRun(next, { t: "run", neg: run.neg, state: sub }, i + 1, top);
|
|
870
863
|
}
|
|
871
|
-
acc += c;
|
|
872
864
|
}
|
|
873
|
-
|
|
874
|
-
ast.#hasMagic = void 0;
|
|
875
|
-
ast.#parts = [str.substring(pos - 1)];
|
|
876
|
-
return i;
|
|
865
|
+
return this.done(next);
|
|
877
866
|
}
|
|
878
|
-
|
|
879
|
-
|
|
867
|
+
};
|
|
868
|
+
var stateKey = (state) => {
|
|
869
|
+
const ids = state.ids.join();
|
|
870
|
+
if (!state.runs.length)
|
|
871
|
+
return ids;
|
|
872
|
+
const runs = state.runs.map((r) => `${r.neg.id}(${stateKey(r.state)})`);
|
|
873
|
+
return `${ids}|${runs.sort().join("|")}`;
|
|
874
|
+
};
|
|
875
|
+
var DFA_BUDGET = 1 << 18;
|
|
876
|
+
var Dfa = class {
|
|
877
|
+
#start;
|
|
878
|
+
#states = /* @__PURE__ */ new Map();
|
|
879
|
+
#size = 0;
|
|
880
|
+
#plain;
|
|
881
|
+
#dotStart;
|
|
882
|
+
#sim;
|
|
883
|
+
#dotSim;
|
|
884
|
+
constructor(start, marks2) {
|
|
885
|
+
this.#start = start;
|
|
886
|
+
this.#sim = new Sim(false, false, marks2);
|
|
887
|
+
this.#dotSim = new Sim(false, true, marks2);
|
|
888
|
+
}
|
|
889
|
+
#make(state) {
|
|
890
|
+
return {
|
|
891
|
+
state,
|
|
892
|
+
match: state.match,
|
|
893
|
+
dead: state.dead,
|
|
894
|
+
next: /* @__PURE__ */ new Map()
|
|
895
|
+
};
|
|
880
896
|
}
|
|
881
|
-
#
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
if (
|
|
887
|
-
|
|
897
|
+
#intern(state) {
|
|
898
|
+
const key = stateKey(state);
|
|
899
|
+
const found = this.#states.get(key);
|
|
900
|
+
if (found)
|
|
901
|
+
return found;
|
|
902
|
+
if (this.#size > DFA_BUDGET)
|
|
903
|
+
this.#clear();
|
|
904
|
+
const d = this.#make(state);
|
|
905
|
+
this.#states.set(key, d);
|
|
906
|
+
this.#size += key.length + 1;
|
|
907
|
+
return d;
|
|
908
|
+
}
|
|
909
|
+
#clear() {
|
|
910
|
+
this.#states.clear();
|
|
911
|
+
this.#size = 0;
|
|
912
|
+
this.#plain = void 0;
|
|
913
|
+
this.#dotStart = void 0;
|
|
914
|
+
}
|
|
915
|
+
start(dotStart) {
|
|
916
|
+
if (dotStart) {
|
|
917
|
+
if (this.#dotStart)
|
|
918
|
+
return this.#dotStart;
|
|
919
|
+
const state2 = this.#dotSim.state();
|
|
920
|
+
this.#dotSim.add(state2, this.#start, 0, true);
|
|
921
|
+
return this.#dotStart = this.#make(this.#dotSim.done(state2));
|
|
922
|
+
}
|
|
923
|
+
if (this.#plain)
|
|
924
|
+
return this.#plain;
|
|
925
|
+
const state = this.#sim.state();
|
|
926
|
+
this.#sim.add(state, this.#start, 0, true);
|
|
927
|
+
return this.#plain = this.#intern(this.#sim.done(state));
|
|
928
|
+
}
|
|
929
|
+
// the next state, after a miss in `d.ascii`
|
|
930
|
+
next(d, c) {
|
|
931
|
+
const code = c.charCodeAt(0);
|
|
932
|
+
const found = code < 128 ? void 0 : d.next.get(c);
|
|
933
|
+
if (found)
|
|
934
|
+
return found;
|
|
935
|
+
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));
|
|
936
|
+
if (code < 128) {
|
|
937
|
+
if (!d.ascii) {
|
|
938
|
+
d.ascii = new Array(128);
|
|
939
|
+
this.#size += 128;
|
|
940
|
+
}
|
|
941
|
+
d.ascii[code] = n;
|
|
942
|
+
} else {
|
|
943
|
+
d.next.set(c, n);
|
|
888
944
|
}
|
|
889
|
-
|
|
945
|
+
this.#size++;
|
|
946
|
+
return n;
|
|
890
947
|
}
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
948
|
+
};
|
|
949
|
+
var linear = (start) => {
|
|
950
|
+
const nodes = [];
|
|
951
|
+
for (let n = start; n.t !== "match"; n = n.next) {
|
|
952
|
+
if (n.t === "split" || n.t === "neg")
|
|
953
|
+
return void 0;
|
|
954
|
+
nodes.push(n);
|
|
955
|
+
}
|
|
956
|
+
return nodes;
|
|
957
|
+
};
|
|
958
|
+
var testLinear = (nodes, chars, start, end) => {
|
|
959
|
+
let ni = 0;
|
|
960
|
+
let ci = start;
|
|
961
|
+
let starNi = -1;
|
|
962
|
+
let starCi = 0;
|
|
963
|
+
while (ci < end) {
|
|
964
|
+
const n = nodes[ni];
|
|
965
|
+
if (n?.t === "star") {
|
|
966
|
+
starNi = ni++;
|
|
967
|
+
starCi = ci;
|
|
968
|
+
continue;
|
|
907
969
|
}
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
}
|
|
914
|
-
#canUsurp(child) {
|
|
915
|
-
if (!child || typeof child !== "object" || child.type !== null || child.#parts.length !== 1 || this.type === null || this.#parts.length !== 1) {
|
|
916
|
-
return false;
|
|
970
|
+
const c = chars[ci];
|
|
971
|
+
if (n && (n.t === "any" || n.t === "lit" && litMatch(n, c) || n.t === "class" && n.re.test(c))) {
|
|
972
|
+
ni++;
|
|
973
|
+
ci++;
|
|
974
|
+
continue;
|
|
917
975
|
}
|
|
918
|
-
|
|
919
|
-
if (!gc || typeof gc !== "object" || gc.type === null) {
|
|
976
|
+
if (starNi === -1)
|
|
920
977
|
return false;
|
|
921
|
-
|
|
922
|
-
|
|
978
|
+
ni = starNi + 1;
|
|
979
|
+
ci = ++starCi;
|
|
923
980
|
}
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
981
|
+
while (nodes[ni]?.t === "star")
|
|
982
|
+
ni++;
|
|
983
|
+
return ni === nodes.length;
|
|
984
|
+
};
|
|
985
|
+
var lengths = (items) => {
|
|
986
|
+
let min = 0;
|
|
987
|
+
let max = 0;
|
|
988
|
+
for (const it of items) {
|
|
989
|
+
const [lo, hi] = itemLengths(it);
|
|
990
|
+
min += lo;
|
|
991
|
+
max += hi;
|
|
992
|
+
}
|
|
993
|
+
return [min, max];
|
|
994
|
+
};
|
|
995
|
+
var itemLengths = (it) => {
|
|
996
|
+
if (it.t === "star")
|
|
997
|
+
return [0, Infinity];
|
|
998
|
+
if (it.t !== "ext")
|
|
999
|
+
return [1, 1];
|
|
1000
|
+
if (it.type === "!")
|
|
1001
|
+
return [0, Infinity];
|
|
1002
|
+
const alts = it.alts.map(lengths);
|
|
1003
|
+
const min = Math.min(...alts.map((a) => a[0]));
|
|
1004
|
+
const max = Math.max(...alts.map((a) => a[1]));
|
|
1005
|
+
const loop = max === 0 ? 0 : Infinity;
|
|
1006
|
+
return it.type === "@" ? [min, max] : it.type === "?" ? [0, max] : it.type === "*" ? [0, loop] : [min, loop];
|
|
1007
|
+
};
|
|
1008
|
+
var hasAffix = (lits, chars, start) => {
|
|
1009
|
+
for (let j = 0; j < lits.length; j++) {
|
|
1010
|
+
if (!litMatch(lits[j], chars[start + j]))
|
|
929
1011
|
return false;
|
|
930
|
-
this.#parts = gc.#parts;
|
|
931
|
-
for (const p of this.#parts) {
|
|
932
|
-
if (typeof p === "object") {
|
|
933
|
-
p.#parent = this;
|
|
934
|
-
}
|
|
935
|
-
}
|
|
936
|
-
this.type = nt;
|
|
937
|
-
this.#toString = void 0;
|
|
938
|
-
this.#emptyExt = false;
|
|
939
|
-
}
|
|
940
|
-
static fromGlob(pattern, options = {}) {
|
|
941
|
-
const ast = new _a(null, void 0, options);
|
|
942
|
-
_a.#parseAST(pattern, ast, 0, options, 0);
|
|
943
|
-
return ast;
|
|
944
|
-
}
|
|
945
|
-
// returns the regular expression if there's magic, or the unescaped
|
|
946
|
-
// string if not.
|
|
947
|
-
toMMPattern() {
|
|
948
|
-
if (this !== this.#root)
|
|
949
|
-
return this.#root.toMMPattern();
|
|
950
|
-
const glob = this.toString();
|
|
951
|
-
const [re, body, hasMagic, uflag] = this.toRegExpSource();
|
|
952
|
-
const anyMagic = hasMagic || this.#hasMagic || this.#options.nocase && !this.#options.nocaseMagicOnly && glob.toUpperCase() !== glob.toLowerCase();
|
|
953
|
-
if (!anyMagic) {
|
|
954
|
-
return body;
|
|
955
|
-
}
|
|
956
|
-
const flags = (this.#options.nocase ? "i" : "") + (uflag ? "u" : "");
|
|
957
|
-
return Object.assign(new RegExp(`^${re}$`, flags), {
|
|
958
|
-
_src: re,
|
|
959
|
-
_glob: glob
|
|
960
|
-
});
|
|
961
1012
|
}
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
//
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
//
|
|
980
|
-
|
|
981
|
-
//
|
|
982
|
-
//
|
|
983
|
-
//
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
//
|
|
988
|
-
//
|
|
989
|
-
|
|
990
|
-
//
|
|
991
|
-
//
|
|
992
|
-
|
|
993
|
-
//
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
//
|
|
997
|
-
// the
|
|
998
|
-
//
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
//
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
//
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
// AST, otherwise leave it to the child AST to handle it, and there,
|
|
1028
|
-
// use the (?:^|/) style of start binding.
|
|
1029
|
-
//
|
|
1030
|
-
// Even simplified further:
|
|
1031
|
-
// - Since the start for a join is eg /(?!\.) and the start for a part
|
|
1032
|
-
// is ^(?!\.), we can just prepend (?!\.) to the pattern (either root
|
|
1033
|
-
// or start or whatever) and prepend ^ or / at the Regexp construction.
|
|
1034
|
-
toRegExpSource(allowDot) {
|
|
1035
|
-
const dot = allowDot ?? !!this.#options.dot;
|
|
1036
|
-
if (this.#root === this) {
|
|
1037
|
-
this.#flatten();
|
|
1038
|
-
this.#fillNegs();
|
|
1039
|
-
}
|
|
1040
|
-
if (!isExtglobAST(this)) {
|
|
1041
|
-
const noEmpty = this.isStart() && this.isEnd() && !this.#parts.some((s) => typeof s !== "string");
|
|
1042
|
-
const src = this.#parts.map((p) => {
|
|
1043
|
-
const [re, _, hasMagic, uflag] = typeof p === "string" ? _a.#parseGlob(p, this.#hasMagic, noEmpty) : p.toRegExpSource(allowDot);
|
|
1044
|
-
this.#hasMagic = this.#hasMagic || hasMagic;
|
|
1045
|
-
this.#uflag = this.#uflag || uflag;
|
|
1046
|
-
return re;
|
|
1047
|
-
}).join("");
|
|
1048
|
-
let start2 = "";
|
|
1049
|
-
if (this.isStart()) {
|
|
1050
|
-
if (typeof this.#parts[0] === "string") {
|
|
1051
|
-
const dotTravAllowed = this.#parts.length === 1 && justDots.has(this.#parts[0]);
|
|
1052
|
-
if (!dotTravAllowed) {
|
|
1053
|
-
const aps = addPatternStart;
|
|
1054
|
-
const needNoTrav = (
|
|
1055
|
-
// dots are allowed, and the pattern starts with [ or .
|
|
1056
|
-
dot && aps.has(src.charAt(0)) || // the pattern starts with \., and then [ or .
|
|
1057
|
-
src.startsWith("\\.") && aps.has(src.charAt(2)) || // the pattern starts with \.\., and then [ or .
|
|
1058
|
-
src.startsWith("\\.\\.") && aps.has(src.charAt(4))
|
|
1059
|
-
);
|
|
1060
|
-
const needNoDot = !dot && !allowDot && aps.has(src.charAt(0));
|
|
1061
|
-
start2 = needNoTrav ? startNoTraversal : needNoDot ? startNoDot : "";
|
|
1062
|
-
}
|
|
1063
|
-
}
|
|
1064
|
-
}
|
|
1065
|
-
let end = "";
|
|
1066
|
-
if (this.isEnd() && this.#root.#filledNegs && this.#parent?.type === "!") {
|
|
1067
|
-
end = "(?:$|\\/)";
|
|
1068
|
-
}
|
|
1069
|
-
const final2 = start2 + src + end;
|
|
1070
|
-
return [
|
|
1071
|
-
final2,
|
|
1072
|
-
unescape(src),
|
|
1073
|
-
this.#hasMagic = !!this.#hasMagic,
|
|
1074
|
-
this.#uflag
|
|
1075
|
-
];
|
|
1076
|
-
}
|
|
1077
|
-
const repeated = this.type === "*" || this.type === "+";
|
|
1078
|
-
const start = this.type === "!" ? "(?:(?!(?:" : "(?:";
|
|
1079
|
-
let body = this.#partsToRegExp(dot);
|
|
1080
|
-
if (this.isStart() && this.isEnd() && !body && this.type !== "!") {
|
|
1081
|
-
const s = this.toString();
|
|
1082
|
-
const me = this;
|
|
1083
|
-
me.#parts = [s];
|
|
1084
|
-
me.type = null;
|
|
1085
|
-
me.#hasMagic = void 0;
|
|
1086
|
-
return [s, unescape(this.toString()), false, false];
|
|
1087
|
-
}
|
|
1088
|
-
let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot ? "" : this.#partsToRegExp(true);
|
|
1089
|
-
if (bodyDotAllowed === body) {
|
|
1090
|
-
bodyDotAllowed = "";
|
|
1091
|
-
}
|
|
1092
|
-
if (bodyDotAllowed) {
|
|
1093
|
-
body = `(?:${body})(?:${bodyDotAllowed})*?`;
|
|
1094
|
-
}
|
|
1095
|
-
let final = "";
|
|
1096
|
-
if (this.type === "!" && this.#emptyExt) {
|
|
1097
|
-
final = (this.isStart() && !dot ? startNoDot : "") + starNoEmpty;
|
|
1013
|
+
return true;
|
|
1014
|
+
};
|
|
1015
|
+
var slashOrSurrogate = /[/\ud800-\udfff]/;
|
|
1016
|
+
var surrogate = /[\ud800-\udfff]/;
|
|
1017
|
+
var codePoints = (s) => surrogate.test(s) ? [...s] : s;
|
|
1018
|
+
var noSlash = (s) => {
|
|
1019
|
+
if (s.includes("/")) {
|
|
1020
|
+
throw new Error("can only match a single path portion, got: " + s);
|
|
1021
|
+
}
|
|
1022
|
+
};
|
|
1023
|
+
var Matcher = class {
|
|
1024
|
+
pattern;
|
|
1025
|
+
options;
|
|
1026
|
+
#start;
|
|
1027
|
+
// the number of node ids
|
|
1028
|
+
#size;
|
|
1029
|
+
#marks;
|
|
1030
|
+
// the Sim for strings that are only `.` or `..`
|
|
1031
|
+
#dotsSim;
|
|
1032
|
+
// the string to compare, if the pattern has no magic. With
|
|
1033
|
+
// `nocase:true`, the RegExp that folds case is made when it is
|
|
1034
|
+
// first used.
|
|
1035
|
+
#literal;
|
|
1036
|
+
#literalFold = false;
|
|
1037
|
+
#literalRe;
|
|
1038
|
+
// the nodes between the prefix and suffix, if the graph is a
|
|
1039
|
+
// single chain
|
|
1040
|
+
#linear;
|
|
1041
|
+
// the linear nodes are only `*` and `?`, so the length bounds and
|
|
1042
|
+
// the prefix and suffix decide the match
|
|
1043
|
+
#wild = false;
|
|
1044
|
+
// the least and most chars that a match can have
|
|
1045
|
+
#min = 0;
|
|
1046
|
+
#max = Infinity;
|
|
1047
|
+
// the literals that a match must start and end with. Each one
|
|
1048
|
+
// matches exactly one char, and they are distinct items in the
|
|
1049
|
+
// pattern, so a string that does not have them can not match.
|
|
1050
|
+
#prefix = [];
|
|
1051
|
+
#suffix = [];
|
|
1052
|
+
// the prefix and suffix as strings, if they do not fold case
|
|
1053
|
+
#prefixStr;
|
|
1054
|
+
#suffixStr;
|
|
1055
|
+
// there is a prefix or suffix to check
|
|
1056
|
+
#affix = false;
|
|
1057
|
+
#dfa;
|
|
1058
|
+
#form;
|
|
1059
|
+
constructor(pattern, options = {}) {
|
|
1060
|
+
if (pattern.includes("/")) {
|
|
1061
|
+
throw new Error("can only match a single path portion, got pattern: " + pattern);
|
|
1062
|
+
}
|
|
1063
|
+
this.pattern = pattern;
|
|
1064
|
+
this.options = options;
|
|
1065
|
+
const { nocase = false, noext = false, normalize: n } = options;
|
|
1066
|
+
this.#form = n === true ? "NFC" : n || void 0;
|
|
1067
|
+
const literal2 = /^[?*+@]\(\)$/.test(pattern);
|
|
1068
|
+
const toks = tokenize(pattern, nocase, noext || literal2, this.#form);
|
|
1069
|
+
let [items] = build(toks, pair(toks), 0, toks.length, true);
|
|
1070
|
+
if (this.#form)
|
|
1071
|
+
items = normalize(items, this.#form);
|
|
1072
|
+
const [start, size] = compile(items, nocase);
|
|
1073
|
+
this.#start = start;
|
|
1074
|
+
this.#size = size;
|
|
1075
|
+
if (items.every((it) => it.t === "lit")) {
|
|
1076
|
+
this.#literal = items.map((it) => it.ch).join("");
|
|
1077
|
+
this.#literalFold = nocase;
|
|
1098
1078
|
} else {
|
|
1099
|
-
const
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
return [
|
|
1106
|
-
final,
|
|
1107
|
-
unescape(body),
|
|
1108
|
-
this.#hasMagic = !!this.#hasMagic,
|
|
1109
|
-
this.#uflag
|
|
1110
|
-
];
|
|
1111
|
-
}
|
|
1112
|
-
#flatten() {
|
|
1113
|
-
if (!isExtglobAST(this)) {
|
|
1114
|
-
for (const p of this.#parts) {
|
|
1115
|
-
if (typeof p === "object") {
|
|
1116
|
-
p.#flatten();
|
|
1117
|
-
}
|
|
1079
|
+
const lit2 = (it) => it.t !== "lit" ? void 0 : nocase ? { ch: it.ch, re: foldRe(it.ch) } : { ch: it.ch };
|
|
1080
|
+
for (const it of items) {
|
|
1081
|
+
const l = lit2(it);
|
|
1082
|
+
if (!l)
|
|
1083
|
+
break;
|
|
1084
|
+
this.#prefix.push(l);
|
|
1118
1085
|
}
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
for (let i = 0; i < this.#parts.length; i++) {
|
|
1125
|
-
const c = this.#parts[i];
|
|
1126
|
-
if (typeof c === "object") {
|
|
1127
|
-
c.#flatten();
|
|
1128
|
-
if (this.#canAdopt(c)) {
|
|
1129
|
-
done = false;
|
|
1130
|
-
this.#adopt(c, i);
|
|
1131
|
-
} else if (this.#canAdoptWithSpace(c)) {
|
|
1132
|
-
done = false;
|
|
1133
|
-
this.#adoptWithSpace(c, i);
|
|
1134
|
-
} else if (this.#canUsurp(c)) {
|
|
1135
|
-
done = false;
|
|
1136
|
-
this.#usurp(c);
|
|
1137
|
-
}
|
|
1138
|
-
}
|
|
1139
|
-
}
|
|
1140
|
-
} while (!done && ++iterations < 10);
|
|
1141
|
-
}
|
|
1142
|
-
this.#toString = void 0;
|
|
1143
|
-
}
|
|
1144
|
-
#partsToRegExp(dot) {
|
|
1145
|
-
return this.#parts.map((p) => {
|
|
1146
|
-
if (typeof p === "string") {
|
|
1147
|
-
throw new Error("string type in extglob ast??");
|
|
1148
|
-
}
|
|
1149
|
-
const [re, _, _hasMagic, uflag] = p.toRegExpSource(dot);
|
|
1150
|
-
this.#uflag = this.#uflag || uflag;
|
|
1151
|
-
return re;
|
|
1152
|
-
}).filter((p) => !(this.isStart() && this.isEnd()) || !!p).join("|");
|
|
1153
|
-
}
|
|
1154
|
-
static #parseGlob(glob, hasMagic, noEmpty = false) {
|
|
1155
|
-
let escaping = false;
|
|
1156
|
-
let re = "";
|
|
1157
|
-
let uflag = false;
|
|
1158
|
-
let inStar = false;
|
|
1159
|
-
for (let i = 0; i < glob.length; i++) {
|
|
1160
|
-
const c = glob.charAt(i);
|
|
1161
|
-
if (escaping) {
|
|
1162
|
-
escaping = false;
|
|
1163
|
-
re += (reSpecials.has(c) ? "\\" : "") + c;
|
|
1164
|
-
continue;
|
|
1086
|
+
for (let j = items.length - 1; j >= 0; j--) {
|
|
1087
|
+
const l = lit2(items[j]);
|
|
1088
|
+
if (!l)
|
|
1089
|
+
break;
|
|
1090
|
+
this.#suffix.unshift(l);
|
|
1165
1091
|
}
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
re += noEmpty && /^[*]+$/.test(glob) ? starNoEmpty : star;
|
|
1171
|
-
hasMagic = true;
|
|
1172
|
-
continue;
|
|
1173
|
-
} else {
|
|
1174
|
-
inStar = false;
|
|
1092
|
+
this.#affix = !!(this.#prefix.length || this.#suffix.length);
|
|
1093
|
+
if (!nocase) {
|
|
1094
|
+
this.#prefixStr = this.#prefix.map((l) => l.ch).join("");
|
|
1095
|
+
this.#suffixStr = this.#suffix.map((l) => l.ch).join("");
|
|
1175
1096
|
}
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1097
|
+
this.#linear = linear(this.#start)?.slice(this.#prefix.length, -this.#suffix.length || void 0);
|
|
1098
|
+
this.#wild = !!this.#linear?.every((n2) => n2.t === "star" || n2.t === "any");
|
|
1099
|
+
const [min, max] = lengths(items);
|
|
1100
|
+
this.#min = min;
|
|
1101
|
+
this.#max = max;
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
test(s) {
|
|
1105
|
+
if (this.#form) {
|
|
1106
|
+
noSlash(s);
|
|
1107
|
+
return this.#test(s.normalize(this.#form));
|
|
1108
|
+
}
|
|
1109
|
+
if (slashOrSurrogate.test(s)) {
|
|
1110
|
+
noSlash(s);
|
|
1111
|
+
return this.#test(s, [...s]);
|
|
1112
|
+
}
|
|
1113
|
+
return this.#test(s, s);
|
|
1114
|
+
}
|
|
1115
|
+
/**
|
|
1116
|
+
* The same as {@link Matcher#test}, but the string is not checked
|
|
1117
|
+
* for `/` chars, so the result for a string that has one is not
|
|
1118
|
+
* defined. Only use it for a string that is known to be one path
|
|
1119
|
+
* portion, such as a part of a path that was split on `/`. It can
|
|
1120
|
+
* be faster, because some patterns do not need to look at each char
|
|
1121
|
+
* of the string.
|
|
1122
|
+
*/
|
|
1123
|
+
testUnchecked(s) {
|
|
1124
|
+
return this.#test(this.#form ? s.normalize(this.#form) : s);
|
|
1125
|
+
}
|
|
1126
|
+
// Test a string that has no `/`. `chars` indexes it by code point.
|
|
1127
|
+
// If it is not given, it is only found if a step needs it.
|
|
1128
|
+
#test(s, chars) {
|
|
1129
|
+
if (this.#literal !== void 0) {
|
|
1130
|
+
return this.#literalFold ? (this.#literalRe ??= newFoldRe(this.#literal)).test(s) : s === this.#literal;
|
|
1131
|
+
}
|
|
1132
|
+
const min = this.#min;
|
|
1133
|
+
const max = this.#max;
|
|
1134
|
+
if (chars === void 0) {
|
|
1135
|
+
const most = s.length;
|
|
1136
|
+
const least = most + 1 >> 1;
|
|
1137
|
+
if (most < min || least > max)
|
|
1138
|
+
return false;
|
|
1139
|
+
if (least < min || most > max)
|
|
1140
|
+
chars = codePoints(s);
|
|
1141
|
+
}
|
|
1142
|
+
if (chars !== void 0 && (chars.length < min || chars.length > max)) {
|
|
1143
|
+
return false;
|
|
1144
|
+
}
|
|
1145
|
+
const prefix = this.#prefix.length;
|
|
1146
|
+
if (this.#affix) {
|
|
1147
|
+
if (this.#prefixStr !== void 0 && this.#suffixStr !== void 0) {
|
|
1148
|
+
if (!s.startsWith(this.#prefixStr) || !s.endsWith(this.#suffixStr)) {
|
|
1149
|
+
return false;
|
|
1181
1150
|
}
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
re += src;
|
|
1188
|
-
uflag = uflag || needUflag;
|
|
1189
|
-
i += consumed - 1;
|
|
1190
|
-
hasMagic = hasMagic || magic;
|
|
1191
|
-
continue;
|
|
1151
|
+
} else {
|
|
1152
|
+
chars ??= codePoints(s);
|
|
1153
|
+
const end = chars.length - this.#suffix.length;
|
|
1154
|
+
if (!hasAffix(this.#prefix, chars, 0) || !hasAffix(this.#suffix, chars, end)) {
|
|
1155
|
+
return false;
|
|
1192
1156
|
}
|
|
1193
1157
|
}
|
|
1194
|
-
if (c === "?") {
|
|
1195
|
-
re += qmark;
|
|
1196
|
-
hasMagic = true;
|
|
1197
|
-
continue;
|
|
1198
|
-
}
|
|
1199
|
-
re += regExpEscape(c);
|
|
1200
1158
|
}
|
|
1201
|
-
|
|
1159
|
+
const dotStart = !this.options.dot && s.startsWith(".");
|
|
1160
|
+
if (this.#linear) {
|
|
1161
|
+
if (s === "." || s === "..")
|
|
1162
|
+
return false;
|
|
1163
|
+
if (dotStart && !prefix)
|
|
1164
|
+
return false;
|
|
1165
|
+
if (this.#wild)
|
|
1166
|
+
return true;
|
|
1167
|
+
chars ??= codePoints(s);
|
|
1168
|
+
const end = chars.length - this.#suffix.length;
|
|
1169
|
+
return testLinear(this.#linear, chars, prefix, end);
|
|
1170
|
+
}
|
|
1171
|
+
chars ??= codePoints(s);
|
|
1172
|
+
if (s === "." || s === "..") {
|
|
1173
|
+
this.#marks ??= marks(this.#size);
|
|
1174
|
+
const sim = this.#dotsSim ??= new Sim(true, false, this.#marks);
|
|
1175
|
+
const start = sim.state();
|
|
1176
|
+
sim.add(start, this.#start, 0, true);
|
|
1177
|
+
let state = sim.done(start);
|
|
1178
|
+
for (let i = 0; i < chars.length; i++) {
|
|
1179
|
+
state = sim.step(state, chars[i], i, true);
|
|
1180
|
+
}
|
|
1181
|
+
return state.match;
|
|
1182
|
+
}
|
|
1183
|
+
this.#marks ??= marks(this.#size);
|
|
1184
|
+
const dfa = this.#dfa ??= new Dfa(this.#start, this.#marks);
|
|
1185
|
+
let d = dfa.start(dotStart);
|
|
1186
|
+
const str = chars === s;
|
|
1187
|
+
for (let i = 0; i < chars.length; i++) {
|
|
1188
|
+
if (d.dead)
|
|
1189
|
+
return false;
|
|
1190
|
+
const code = str ? s.charCodeAt(i) : chars[i].charCodeAt(0);
|
|
1191
|
+
d = d.ascii?.[code] ?? dfa.next(d, chars[i]);
|
|
1192
|
+
}
|
|
1193
|
+
return d.match;
|
|
1194
|
+
}
|
|
1195
|
+
/** a readable listing of the state machine */
|
|
1196
|
+
toString() {
|
|
1197
|
+
return show(this.#start);
|
|
1198
|
+
}
|
|
1199
|
+
};
|
|
1200
|
+
|
|
1201
|
+
// node_modules/minimatch/dist/esm/assert-valid-pattern.js
|
|
1202
|
+
var MAX_PATTERN_LENGTH = 1024 * 64;
|
|
1203
|
+
var assertValidPattern = (pattern) => {
|
|
1204
|
+
if (typeof pattern !== "string") {
|
|
1205
|
+
throw new TypeError("invalid pattern");
|
|
1206
|
+
}
|
|
1207
|
+
if (pattern.length > MAX_PATTERN_LENGTH) {
|
|
1208
|
+
throw new TypeError("pattern is too long");
|
|
1202
1209
|
}
|
|
1203
1210
|
};
|
|
1204
|
-
_a = AST;
|
|
1205
1211
|
|
|
1206
1212
|
// node_modules/minimatch/dist/esm/escape.js
|
|
1207
1213
|
var escape = (s, { windowsPathsNoEscape = false, magicalBraces = false } = {}) => {
|
|
@@ -1211,65 +1217,39 @@ var escape = (s, { windowsPathsNoEscape = false, magicalBraces = false } = {}) =
|
|
|
1211
1217
|
return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
|
|
1212
1218
|
};
|
|
1213
1219
|
|
|
1220
|
+
// node_modules/minimatch/dist/esm/unescape.js
|
|
1221
|
+
var unescape = (s, { windowsPathsNoEscape = false, magicalBraces = true } = {}) => {
|
|
1222
|
+
if (magicalBraces) {
|
|
1223
|
+
return windowsPathsNoEscape ? s.replace(/\[([^/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\])\]/g, "$1$2").replace(/\\([^/])/g, "$1");
|
|
1224
|
+
}
|
|
1225
|
+
return windowsPathsNoEscape ? s.replace(/\[([^/\\{}])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\{}])\]/g, "$1$2").replace(/\\([^/{}])/g, "$1");
|
|
1226
|
+
};
|
|
1227
|
+
|
|
1214
1228
|
// node_modules/minimatch/dist/esm/index.js
|
|
1215
1229
|
var minimatch = (p, pattern, options = {}) => {
|
|
1216
1230
|
assertValidPattern(pattern);
|
|
1217
1231
|
if (!options.nocomment && pattern.charAt(0) === "#") {
|
|
1218
1232
|
return false;
|
|
1219
1233
|
}
|
|
1220
|
-
return
|
|
1234
|
+
return cachedMinimatch(pattern, options).match(p);
|
|
1221
1235
|
};
|
|
1222
|
-
var
|
|
1223
|
-
var
|
|
1224
|
-
var
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1236
|
+
var cache = /* @__PURE__ */ new Map();
|
|
1237
|
+
var cacheMax = 256;
|
|
1238
|
+
var cachedMinimatch = (pattern, options) => {
|
|
1239
|
+
const key = pattern + "\0" + JSON.stringify(options);
|
|
1240
|
+
let mm = cache.get(key);
|
|
1241
|
+
if (mm) {
|
|
1242
|
+
cache.delete(key);
|
|
1243
|
+
} else {
|
|
1244
|
+
mm = new Minimatch(pattern, { ...options });
|
|
1245
|
+
if (cache.size >= cacheMax) {
|
|
1246
|
+
cache.delete(cache.keys().next().value);
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
cache.set(key, mm);
|
|
1250
|
+
return mm;
|
|
1228
1251
|
};
|
|
1229
|
-
var
|
|
1230
|
-
ext2 = ext2.toLowerCase();
|
|
1231
|
-
return (f) => f.toLowerCase().endsWith(ext2);
|
|
1232
|
-
};
|
|
1233
|
-
var starDotStarRE = /^\*+\.\*+$/;
|
|
1234
|
-
var starDotStarTest = (f) => !f.startsWith(".") && f.includes(".");
|
|
1235
|
-
var starDotStarTestDot = (f) => f !== "." && f !== ".." && f.includes(".");
|
|
1236
|
-
var dotStarRE = /^\.\*+$/;
|
|
1237
|
-
var dotStarTest = (f) => f !== "." && f !== ".." && f.startsWith(".");
|
|
1238
|
-
var starRE = /^\*+$/;
|
|
1239
|
-
var starTest = (f) => f.length !== 0 && !f.startsWith(".");
|
|
1240
|
-
var starTestDot = (f) => f.length !== 0 && f !== "." && f !== "..";
|
|
1241
|
-
var qmarksRE = /^\?+([^+@!?*[(]*)?$/;
|
|
1242
|
-
var qmarksTestNocase = ([$0, ext2 = ""]) => {
|
|
1243
|
-
const noext = qmarksTestNoExt([$0]);
|
|
1244
|
-
if (!ext2)
|
|
1245
|
-
return noext;
|
|
1246
|
-
ext2 = ext2.toLowerCase();
|
|
1247
|
-
return (f) => noext(f) && f.toLowerCase().endsWith(ext2);
|
|
1248
|
-
};
|
|
1249
|
-
var qmarksTestNocaseDot = ([$0, ext2 = ""]) => {
|
|
1250
|
-
const noext = qmarksTestNoExtDot([$0]);
|
|
1251
|
-
if (!ext2)
|
|
1252
|
-
return noext;
|
|
1253
|
-
ext2 = ext2.toLowerCase();
|
|
1254
|
-
return (f) => noext(f) && f.toLowerCase().endsWith(ext2);
|
|
1255
|
-
};
|
|
1256
|
-
var qmarksTestDot = ([$0, ext2 = ""]) => {
|
|
1257
|
-
const noext = qmarksTestNoExtDot([$0]);
|
|
1258
|
-
return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2);
|
|
1259
|
-
};
|
|
1260
|
-
var qmarksTest = ([$0, ext2 = ""]) => {
|
|
1261
|
-
const noext = qmarksTestNoExt([$0]);
|
|
1262
|
-
return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2);
|
|
1263
|
-
};
|
|
1264
|
-
var qmarksTestNoExt = ([$0]) => {
|
|
1265
|
-
const len = $0.length;
|
|
1266
|
-
return (f) => f.length === len && !f.startsWith(".");
|
|
1267
|
-
};
|
|
1268
|
-
var qmarksTestNoExtDot = ([$0]) => {
|
|
1269
|
-
const len = $0.length;
|
|
1270
|
-
return (f) => f.length === len && f !== "." && f !== "..";
|
|
1271
|
-
};
|
|
1272
|
-
var defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
|
1252
|
+
var defaultPlatform = typeof process === "object" && process ? process.env?.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
|
1273
1253
|
var path = {
|
|
1274
1254
|
win32: { sep: "\\" },
|
|
1275
1255
|
posix: { sep: "/" }
|
|
@@ -1278,10 +1258,6 @@ var sep = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
|
|
|
1278
1258
|
minimatch.sep = sep;
|
|
1279
1259
|
var GLOBSTAR = /* @__PURE__ */ Symbol("globstar **");
|
|
1280
1260
|
minimatch.GLOBSTAR = GLOBSTAR;
|
|
1281
|
-
var qmark2 = "[^/]";
|
|
1282
|
-
var star2 = qmark2 + "*?";
|
|
1283
|
-
var twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
|
|
1284
|
-
var twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?";
|
|
1285
1261
|
var filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options);
|
|
1286
1262
|
minimatch.filter = filter;
|
|
1287
1263
|
var ext = (a, b = {}) => Object.assign({}, a, b);
|
|
@@ -1300,21 +1276,10 @@ var defaults = (def) => {
|
|
|
1300
1276
|
return orig.defaults(ext(def, options)).Minimatch;
|
|
1301
1277
|
}
|
|
1302
1278
|
},
|
|
1303
|
-
AST: class AST extends orig.AST {
|
|
1304
|
-
/* c8 ignore start */
|
|
1305
|
-
constructor(type, parent, options = {}) {
|
|
1306
|
-
super(type, parent, ext(def, options));
|
|
1307
|
-
}
|
|
1308
|
-
/* c8 ignore stop */
|
|
1309
|
-
static fromGlob(pattern, options = {}) {
|
|
1310
|
-
return orig.AST.fromGlob(pattern, ext(def, options));
|
|
1311
|
-
}
|
|
1312
|
-
},
|
|
1313
1279
|
unescape: (s, options = {}) => orig.unescape(s, ext(def, options)),
|
|
1314
1280
|
escape: (s, options = {}) => orig.escape(s, ext(def, options)),
|
|
1315
1281
|
filter: (pattern, options = {}) => orig.filter(pattern, ext(def, options)),
|
|
1316
1282
|
defaults: (options) => orig.defaults(ext(def, options)),
|
|
1317
|
-
makeRe: (pattern, options = {}) => orig.makeRe(pattern, ext(def, options)),
|
|
1318
1283
|
braceExpand: (pattern, options = {}) => orig.braceExpand(pattern, ext(def, options)),
|
|
1319
1284
|
match: (list, pattern, options = {}) => orig.match(list, pattern, ext(def, options)),
|
|
1320
1285
|
sep: orig.sep,
|
|
@@ -1330,8 +1295,6 @@ var braceExpand = (pattern, options = {}) => {
|
|
|
1330
1295
|
return expand(pattern, { max: options.braceExpandMax });
|
|
1331
1296
|
};
|
|
1332
1297
|
minimatch.braceExpand = braceExpand;
|
|
1333
|
-
var makeRe = (pattern, options = {}) => new Minimatch(pattern, options).makeRe();
|
|
1334
|
-
minimatch.makeRe = makeRe;
|
|
1335
1298
|
var match = (list, pattern, options = {}) => {
|
|
1336
1299
|
const mm = new Minimatch(pattern, options);
|
|
1337
1300
|
list = list.filter((f) => mm.match(f));
|
|
@@ -1342,7 +1305,122 @@ var match = (list, pattern, options = {}) => {
|
|
|
1342
1305
|
};
|
|
1343
1306
|
minimatch.match = match;
|
|
1344
1307
|
var globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
|
|
1345
|
-
var
|
|
1308
|
+
var classEnd = (pattern, start) => {
|
|
1309
|
+
let i = start + 1;
|
|
1310
|
+
if (pattern.charAt(i) === "!" || pattern.charAt(i) === "^")
|
|
1311
|
+
i++;
|
|
1312
|
+
let sawStart = false;
|
|
1313
|
+
for (; i < pattern.length; i++) {
|
|
1314
|
+
const c = pattern.charAt(i);
|
|
1315
|
+
if (c === "]" && sawStart)
|
|
1316
|
+
return i;
|
|
1317
|
+
sawStart = true;
|
|
1318
|
+
if (c === "\\")
|
|
1319
|
+
i++;
|
|
1320
|
+
}
|
|
1321
|
+
return -1;
|
|
1322
|
+
};
|
|
1323
|
+
var literal = (pattern, noext) => {
|
|
1324
|
+
if (!noext && (pattern === "+()" || pattern === "@()"))
|
|
1325
|
+
return pattern;
|
|
1326
|
+
let lit2 = "";
|
|
1327
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
1328
|
+
const c = pattern.charAt(i);
|
|
1329
|
+
if (c === "\\") {
|
|
1330
|
+
lit2 += pattern.charAt(++i) || c;
|
|
1331
|
+
} else if (c === "*" || c === "?") {
|
|
1332
|
+
return void 0;
|
|
1333
|
+
} else if (c === "[") {
|
|
1334
|
+
const close = classEnd(pattern, i);
|
|
1335
|
+
if (close === -1) {
|
|
1336
|
+
lit2 += c;
|
|
1337
|
+
continue;
|
|
1338
|
+
}
|
|
1339
|
+
let body = pattern.slice(i + 1, close);
|
|
1340
|
+
if (body.startsWith("\\"))
|
|
1341
|
+
body = body.slice(1);
|
|
1342
|
+
if ([...body].length !== 1 || "!^".includes(pattern.charAt(i + 1))) {
|
|
1343
|
+
return void 0;
|
|
1344
|
+
}
|
|
1345
|
+
lit2 += body;
|
|
1346
|
+
i = close;
|
|
1347
|
+
} else if (!noext && "+@!".includes(c) && pattern.charAt(i + 1) === "(" && pattern.includes(")", i + 2)) {
|
|
1348
|
+
return void 0;
|
|
1349
|
+
} else {
|
|
1350
|
+
lit2 += c;
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
return lit2;
|
|
1354
|
+
};
|
|
1355
|
+
var extSafe = (pattern) => {
|
|
1356
|
+
if (/^[?*+@]\(\)$/.test(pattern) || pattern.includes("[:"))
|
|
1357
|
+
return false;
|
|
1358
|
+
let depth = 0;
|
|
1359
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
1360
|
+
const c = pattern.charAt(i);
|
|
1361
|
+
if (c === "\\") {
|
|
1362
|
+
if (++i === pattern.length)
|
|
1363
|
+
return false;
|
|
1364
|
+
} else if (c === "[") {
|
|
1365
|
+
const close = classEnd(pattern, i);
|
|
1366
|
+
if (close !== -1)
|
|
1367
|
+
i = close;
|
|
1368
|
+
} else if ("+@!?*".includes(c) && pattern.charAt(i + 1) === "(") {
|
|
1369
|
+
depth++;
|
|
1370
|
+
i++;
|
|
1371
|
+
} else if (c === ")") {
|
|
1372
|
+
if (!depth--)
|
|
1373
|
+
return false;
|
|
1374
|
+
} else if (c === "|" && !depth) {
|
|
1375
|
+
return false;
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
return !depth;
|
|
1379
|
+
};
|
|
1380
|
+
var lastSplit;
|
|
1381
|
+
var lastChecked;
|
|
1382
|
+
var portionMatch = (p, f) => typeof p === "string" ? f === p : f !== "" && p.testUnchecked(f);
|
|
1383
|
+
var endIndex = (p, last, lastStart, prev, prevStart) => portionMatch(p, last) ? lastStart : prev !== void 0 && portionMatch(p, prev) ? prevStart : -1;
|
|
1384
|
+
var isDots = (p) => p === "." || p === "..";
|
|
1385
|
+
var isDrive = (p) => typeof p === "string" && /^[a-z]:$/i.test(p);
|
|
1386
|
+
var isLongUNC = (p) => typeof p === "string" && /^unc$/i.test(p);
|
|
1387
|
+
var uncHost = (p) => {
|
|
1388
|
+
if (p[0] !== "" || p[1] !== "")
|
|
1389
|
+
return -1;
|
|
1390
|
+
const h = p[2] !== "?" ? 2 : isLongUNC(p[3]) ? 4 : -1;
|
|
1391
|
+
const host = p[h];
|
|
1392
|
+
const share = p[h + 1];
|
|
1393
|
+
return h !== -1 && host !== void 0 && host !== "" && host !== GLOBSTAR && share !== void 0 && share !== "" && share !== GLOBSTAR ? h : -1;
|
|
1394
|
+
};
|
|
1395
|
+
var walkable = (p, dot) => !isDots(p) && (dot || !p.startsWith("."));
|
|
1396
|
+
var dotPortion = (f, start, end, dot, sep2) => {
|
|
1397
|
+
for (let k = start; k < end; ) {
|
|
1398
|
+
if (f.charCodeAt(k) === 46) {
|
|
1399
|
+
if (!dot)
|
|
1400
|
+
return true;
|
|
1401
|
+
const n = f.charCodeAt(k + 1) === 46 ? k + 2 : k + 1;
|
|
1402
|
+
if (n >= end || isSep(f.charCodeAt(n), sep2))
|
|
1403
|
+
return true;
|
|
1404
|
+
}
|
|
1405
|
+
const s = nextSep(f, k, sep2);
|
|
1406
|
+
if (s === -1)
|
|
1407
|
+
return false;
|
|
1408
|
+
k = s + 1;
|
|
1409
|
+
while (k < end && isSep(f.charCodeAt(k), sep2))
|
|
1410
|
+
k++;
|
|
1411
|
+
}
|
|
1412
|
+
return false;
|
|
1413
|
+
};
|
|
1414
|
+
var isSep = (c, sep2) => sep2 === "/" ? c === 47 : sep2 === "\\" ? c === 92 : c === 47 || c === 92;
|
|
1415
|
+
var nextSep = (f, from, sep2) => {
|
|
1416
|
+
if (sep2 !== "both")
|
|
1417
|
+
return f.indexOf(sep2, from);
|
|
1418
|
+
const s = f.indexOf("/", from);
|
|
1419
|
+
const b = f.indexOf("\\", from);
|
|
1420
|
+
return s === -1 ? b : b === -1 ? s : Math.min(s, b);
|
|
1421
|
+
};
|
|
1422
|
+
var lastSep = (f, from, sep2) => sep2 !== "both" ? f.lastIndexOf(sep2, from) : Math.max(f.lastIndexOf("/", from), f.lastIndexOf("\\", from));
|
|
1423
|
+
var PENDING = {};
|
|
1346
1424
|
var Minimatch = class {
|
|
1347
1425
|
options;
|
|
1348
1426
|
set;
|
|
@@ -1361,7 +1439,27 @@ var Minimatch = class {
|
|
|
1361
1439
|
platform;
|
|
1362
1440
|
windowsNoMagicRoot;
|
|
1363
1441
|
maxGlobstarRecursion;
|
|
1364
|
-
|
|
1442
|
+
// the path can be checked against the last portion, and the string
|
|
1443
|
+
// portions, of each row before it is split. See #canMatch.
|
|
1444
|
+
#endCheck;
|
|
1445
|
+
#literalCheck;
|
|
1446
|
+
// level 2 resolves `.` and `..` portions in the path
|
|
1447
|
+
#level2;
|
|
1448
|
+
// the unicode normalization form, if any
|
|
1449
|
+
#form;
|
|
1450
|
+
// the string portions of each row in the set
|
|
1451
|
+
#literals = [];
|
|
1452
|
+
// the rows that #canMatch can match without splitting the path
|
|
1453
|
+
#shapes = [];
|
|
1454
|
+
// the rows whose last portion can be checked against the path's
|
|
1455
|
+
#endRows = [];
|
|
1456
|
+
// brace expansion can make the same portion in many rows, so they
|
|
1457
|
+
// share one Matcher, and the states that it caches
|
|
1458
|
+
#matchers = /* @__PURE__ */ new Map();
|
|
1459
|
+
// parse() returns PENDING in place of a Matcher
|
|
1460
|
+
#pending = false;
|
|
1461
|
+
// the GlobstarParts of each pattern row, by start index and partial
|
|
1462
|
+
#globstarParts = /* @__PURE__ */ new WeakMap();
|
|
1365
1463
|
constructor(pattern, options = {}) {
|
|
1366
1464
|
assertValidPattern(pattern);
|
|
1367
1465
|
options = options || {};
|
|
@@ -1376,7 +1474,6 @@ var Minimatch = class {
|
|
|
1376
1474
|
this.pattern = this.pattern.replace(/\\/g, "/");
|
|
1377
1475
|
}
|
|
1378
1476
|
this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
|
|
1379
|
-
this.regexp = null;
|
|
1380
1477
|
this.negate = false;
|
|
1381
1478
|
this.nonegate = !!options.nonegate;
|
|
1382
1479
|
this.comment = false;
|
|
@@ -1387,7 +1484,58 @@ var Minimatch = class {
|
|
|
1387
1484
|
this.globSet = [];
|
|
1388
1485
|
this.globParts = [];
|
|
1389
1486
|
this.set = [];
|
|
1487
|
+
this.#endCheck = !this.preserveMultipleSlashes;
|
|
1488
|
+
this.#level2 = (options.optimizationLevel ?? 1) >= 2;
|
|
1489
|
+
const n = options.normalize;
|
|
1490
|
+
this.#form = n === true ? "NFC" : n || void 0;
|
|
1390
1491
|
this.make();
|
|
1492
|
+
const drives = this.set.map((row) => this.#rootIndex(row));
|
|
1493
|
+
this.#endRows = this.set.map((row, r) => this.#endCheck && row.length - 1 > drives[r]);
|
|
1494
|
+
this.#literals = this.set.map((row, r) => {
|
|
1495
|
+
const end = this.#endRows[r] ? row.length - 1 : row.length;
|
|
1496
|
+
const lits = row.slice(drives[r] + 1, end).filter((p) => typeof p === "string" && !!p);
|
|
1497
|
+
return [...new Set(lits)];
|
|
1498
|
+
});
|
|
1499
|
+
this.#literalCheck = this.#literals.some((l) => l.length);
|
|
1500
|
+
this.#shapes = this.set.map((row, r) => {
|
|
1501
|
+
const [p0, p1, p2] = row;
|
|
1502
|
+
if (this.#endRows[r] && row.length === 2) {
|
|
1503
|
+
if (p0 === GLOBSTAR && p1 !== GLOBSTAR)
|
|
1504
|
+
return "tail";
|
|
1505
|
+
}
|
|
1506
|
+
if (this.#endRows[r] && options.matchBase && row.length === 1 && p0 !== GLOBSTAR && p0 !== "") {
|
|
1507
|
+
return "base";
|
|
1508
|
+
}
|
|
1509
|
+
if (!this.#endCheck || drives[r] !== -1)
|
|
1510
|
+
return void 0;
|
|
1511
|
+
if (row.length === 3 && p0 === GLOBSTAR && p2 === GLOBSTAR && p1 !== GLOBSTAR && p1 !== "" && // the portion between is only matched below this limit
|
|
1512
|
+
this.maxGlobstarRecursion > 0) {
|
|
1513
|
+
return "mid";
|
|
1514
|
+
}
|
|
1515
|
+
if (row.length === 2 && p1 === GLOBSTAR && p0 !== GLOBSTAR && p0 !== "") {
|
|
1516
|
+
return "head";
|
|
1517
|
+
}
|
|
1518
|
+
return void 0;
|
|
1519
|
+
});
|
|
1520
|
+
}
|
|
1521
|
+
// a string portion of a pattern, normalized if the option is set
|
|
1522
|
+
#norm(p) {
|
|
1523
|
+
return this.#form ? p.normalize(this.#form) : p;
|
|
1524
|
+
}
|
|
1525
|
+
// On Windows, the index of the last root portion of a row, as
|
|
1526
|
+
// #matchRow finds it: 0 for `c:/...`, 3 for `//?/c:/...` and
|
|
1527
|
+
// `//host/share/...`, and 5 for `//?/UNC/host/share/...`. Otherwise
|
|
1528
|
+
// -1.
|
|
1529
|
+
#rootIndex(row) {
|
|
1530
|
+
if (!this.isWindows)
|
|
1531
|
+
return -1;
|
|
1532
|
+
if (isDrive(row[0]))
|
|
1533
|
+
return 0;
|
|
1534
|
+
const uncDrive = row[0] === "" && row[1] === "" && row[2] === "?" && isDrive(row[3]);
|
|
1535
|
+
if (uncDrive)
|
|
1536
|
+
return 3;
|
|
1537
|
+
const h = uncHost(row);
|
|
1538
|
+
return h === -1 ? -1 : h + 1;
|
|
1391
1539
|
}
|
|
1392
1540
|
hasMagic() {
|
|
1393
1541
|
if (this.options.magicalBraces && this.set.length > 1) {
|
|
@@ -1401,8 +1549,6 @@ var Minimatch = class {
|
|
|
1401
1549
|
}
|
|
1402
1550
|
return false;
|
|
1403
1551
|
}
|
|
1404
|
-
debug(..._) {
|
|
1405
|
-
}
|
|
1406
1552
|
make() {
|
|
1407
1553
|
const pattern = this.pattern;
|
|
1408
1554
|
const options = this.options;
|
|
@@ -1416,39 +1562,93 @@ var Minimatch = class {
|
|
|
1416
1562
|
}
|
|
1417
1563
|
this.parseNegate();
|
|
1418
1564
|
this.globSet = [...new Set(this.braceExpand())];
|
|
1419
|
-
|
|
1420
|
-
this.debug = (...args) => console.error(...args);
|
|
1421
|
-
}
|
|
1422
|
-
this.debug(this.pattern, this.globSet);
|
|
1423
|
-
const rawGlobParts = this.globSet.map((s) => this.slashSplit(s));
|
|
1565
|
+
const rawGlobParts = this.globSet.map((s) => this.#slashSplit(s));
|
|
1424
1566
|
this.globParts = this.preprocess(rawGlobParts);
|
|
1425
|
-
this
|
|
1567
|
+
this.#pending = true;
|
|
1426
1568
|
let set = this.globParts.map((s, _, __) => {
|
|
1427
1569
|
if (this.isWindows && this.windowsNoMagicRoot) {
|
|
1428
|
-
const
|
|
1429
|
-
const
|
|
1570
|
+
const n = s[2] === "?" && isLongUNC(s[3]) ? 6 : 4;
|
|
1571
|
+
const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && s.slice(3, n).every((p) => !globMagic.test(p));
|
|
1572
|
+
const isDrive2 = /^[a-z]:/i.test(s[0]);
|
|
1430
1573
|
if (isUNC) {
|
|
1431
1574
|
return [
|
|
1432
|
-
...s.slice(0,
|
|
1433
|
-
...s.slice(
|
|
1575
|
+
...s.slice(0, n).map((p) => this.#norm(p)),
|
|
1576
|
+
...s.slice(n).map((ss) => this.parse(ss))
|
|
1577
|
+
];
|
|
1578
|
+
} else if (isDrive2) {
|
|
1579
|
+
return [
|
|
1580
|
+
this.#norm(s[0]),
|
|
1581
|
+
...s.slice(1).map((ss) => this.parse(ss))
|
|
1434
1582
|
];
|
|
1435
|
-
} else if (isDrive) {
|
|
1436
|
-
return [s[0], ...s.slice(1).map((ss) => this.parse(ss))];
|
|
1437
1583
|
}
|
|
1438
1584
|
}
|
|
1439
1585
|
return s.map((ss) => this.parse(ss));
|
|
1440
1586
|
});
|
|
1441
|
-
this.debug(this.pattern, set);
|
|
1442
1587
|
this.set = set.filter((s) => s.indexOf(false) === -1);
|
|
1443
1588
|
if (this.isWindows) {
|
|
1444
1589
|
for (let i = 0; i < this.set.length; i++) {
|
|
1445
1590
|
const p = this.set[i];
|
|
1446
|
-
if (p[0] === "" && p[1] === "" && this.globParts[i][2] === "?" &&
|
|
1591
|
+
if (p[0] === "" && p[1] === "" && this.globParts[i][2] === "?" && (isDrive(p[3]) || isLongUNC(this.globParts[i][3]))) {
|
|
1592
|
+
if (isLongUNC(this.globParts[i][3]))
|
|
1593
|
+
p[3] = "UNC";
|
|
1447
1594
|
p[2] = "?";
|
|
1448
1595
|
}
|
|
1449
1596
|
}
|
|
1450
1597
|
}
|
|
1451
|
-
|
|
1598
|
+
if (!options.noext)
|
|
1599
|
+
this.mergeRows();
|
|
1600
|
+
this.#pending = false;
|
|
1601
|
+
this.set.forEach((row, i) => {
|
|
1602
|
+
for (let k = 0; k < row.length; k++) {
|
|
1603
|
+
if (row[k] === PENDING) {
|
|
1604
|
+
row[k] = this.parse(this.globParts[i][k]);
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
});
|
|
1608
|
+
}
|
|
1609
|
+
// Merge rows that only differ in one portion, where each of them
|
|
1610
|
+
// is a Matcher, into one row that matches any of them with
|
|
1611
|
+
// `@(a|b|...)`. Then a path is only walked once for all of them,
|
|
1612
|
+
// for example with `**/*.{js,ts}`.
|
|
1613
|
+
mergeRows() {
|
|
1614
|
+
let merged = true;
|
|
1615
|
+
while (merged) {
|
|
1616
|
+
merged = false;
|
|
1617
|
+
const len = Math.max(0, ...this.set.map((r) => r.length));
|
|
1618
|
+
for (let k = 0; k < len; k++) {
|
|
1619
|
+
const groups = /* @__PURE__ */ new Map();
|
|
1620
|
+
this.set.forEach((row, i) => {
|
|
1621
|
+
if (!(row[k] instanceof Matcher || row[k] === PENDING) || !extSafe(this.globParts[i][k])) {
|
|
1622
|
+
return;
|
|
1623
|
+
}
|
|
1624
|
+
const parts = [...this.globParts[i]];
|
|
1625
|
+
parts[k] = "";
|
|
1626
|
+
const key = `${row.length}/${parts.join("/")}`;
|
|
1627
|
+
const g = groups.get(key);
|
|
1628
|
+
if (g)
|
|
1629
|
+
g.push(i);
|
|
1630
|
+
else
|
|
1631
|
+
groups.set(key, [i]);
|
|
1632
|
+
});
|
|
1633
|
+
const drop = /* @__PURE__ */ new Set();
|
|
1634
|
+
for (const g of groups.values()) {
|
|
1635
|
+
if (g.length < 2)
|
|
1636
|
+
continue;
|
|
1637
|
+
const [first, ...rest] = g;
|
|
1638
|
+
const alts = g.map((i) => this.globParts[i][k]);
|
|
1639
|
+
const glob = `@(${alts.join("|")})`;
|
|
1640
|
+
this.globParts[first][k] = glob;
|
|
1641
|
+
this.set[first][k] = this.parse(glob);
|
|
1642
|
+
for (const i of rest)
|
|
1643
|
+
drop.add(i);
|
|
1644
|
+
}
|
|
1645
|
+
if (drop.size) {
|
|
1646
|
+
merged = true;
|
|
1647
|
+
this.set = this.set.filter((_, i) => !drop.has(i));
|
|
1648
|
+
this.globParts = this.globParts.filter((_, i) => !drop.has(i));
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1452
1652
|
}
|
|
1453
1653
|
// various transforms to equivalent pattern sets that are
|
|
1454
1654
|
// faster to process in a filesystem walk. The goal is to
|
|
@@ -1495,13 +1695,14 @@ var Minimatch = class {
|
|
|
1495
1695
|
// get rid of adjascent ** and resolve .. portions
|
|
1496
1696
|
levelOneOptimize(globParts) {
|
|
1497
1697
|
return globParts.map((parts) => {
|
|
1698
|
+
const root = this.#rootIndex(parts) + 1;
|
|
1498
1699
|
parts = parts.reduce((set, part) => {
|
|
1499
1700
|
const prev = set[set.length - 1];
|
|
1500
1701
|
if (part === "**" && prev === "**") {
|
|
1501
1702
|
return set;
|
|
1502
1703
|
}
|
|
1503
1704
|
if (part === "..") {
|
|
1504
|
-
if (prev && prev !== ".." && prev !== "." && prev !== "**") {
|
|
1705
|
+
if (set.length > root && prev && prev !== ".." && prev !== "." && prev !== "**") {
|
|
1505
1706
|
set.pop();
|
|
1506
1707
|
return set;
|
|
1507
1708
|
}
|
|
@@ -1512,10 +1713,188 @@ var Minimatch = class {
|
|
|
1512
1713
|
return parts.length === 0 ? [""] : parts;
|
|
1513
1714
|
});
|
|
1514
1715
|
}
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1716
|
+
// Check the path against each row before it is split. 'no' if no
|
|
1717
|
+
// row can match, so it does not need to be split. 'yes' if a row of
|
|
1718
|
+
// `**` and one more portion matches. 'maybe' if it must be split to
|
|
1719
|
+
// know. None of this applies with partial, where the path can end
|
|
1720
|
+
// before the row does.
|
|
1721
|
+
//
|
|
1722
|
+
// On Windows, `\` is a separator in the path too, and the portions of
|
|
1723
|
+
// a row up to its drive letter or UNC share are not checked (see
|
|
1724
|
+
// #rootIndex).
|
|
1725
|
+
//
|
|
1726
|
+
// Each string portion of a row must be a portion of the path, so the
|
|
1727
|
+
// path must contain it. Level 2 can only take portions out of the
|
|
1728
|
+
// path, so this is still true then.
|
|
1729
|
+
//
|
|
1730
|
+
// The last portion of a row must match the last portion of the path,
|
|
1731
|
+
// or the one before a trailing `/` (as a/* and a/**/* match a/b/).
|
|
1732
|
+
// This does not apply to rows that end in **, rows that end in a
|
|
1733
|
+
// root, or preserveMultipleSlashes (which can leave more
|
|
1734
|
+
// than one '' at the end). At level 2, it does not apply if that
|
|
1735
|
+
// portion is `.` or `..`, which can be
|
|
1736
|
+
// resolved away. Level 2 only takes other portions out of the
|
|
1737
|
+
// middle of the path.
|
|
1738
|
+
//
|
|
1739
|
+
// A row of `**/x` then matches if the ** can walk the portions
|
|
1740
|
+
// before the one that x matches, the same as #matchGlobstar. At
|
|
1741
|
+
// level 2, this is only known if none of them are `.` or `..`, so
|
|
1742
|
+
// that the path does not change when it is resolved.
|
|
1743
|
+
#canMatch(f) {
|
|
1744
|
+
const sep2 = !this.isWindows || !f.includes("\\") ? "/" : f.includes("/") ? "both" : "\\";
|
|
1745
|
+
let ends = this.#endCheck ? 0 : -1;
|
|
1746
|
+
let last = "";
|
|
1747
|
+
let lastStart = 0;
|
|
1748
|
+
let prev;
|
|
1749
|
+
let prevStart = 0;
|
|
1750
|
+
const dot = !!this.options.dot;
|
|
1751
|
+
ROWS: for (let r = 0; r < this.set.length; r++) {
|
|
1752
|
+
const row = this.set[r];
|
|
1753
|
+
const p = row[row.length - 1];
|
|
1754
|
+
let end = ends !== -1 && this.#endRows[r] && p !== GLOBSTAR;
|
|
1755
|
+
if (end && ends === 0) {
|
|
1756
|
+
const i = lastSep(f, f.length, sep2);
|
|
1757
|
+
lastStart = i + 1;
|
|
1758
|
+
last = f.slice(lastStart);
|
|
1759
|
+
if (last === "" && i >= 0) {
|
|
1760
|
+
let j = i;
|
|
1761
|
+
while (j > 0 && isSep(f.charCodeAt(j - 1), sep2))
|
|
1762
|
+
j--;
|
|
1763
|
+
prevStart = j === 0 ? 0 : lastSep(f, j - 1, sep2) + 1;
|
|
1764
|
+
prev = f.slice(prevStart, j);
|
|
1765
|
+
}
|
|
1766
|
+
const resolves = this.#level2 && (isDots(last) || last === "" && prev !== void 0 && isDots(prev));
|
|
1767
|
+
ends = resolves ? -1 : 1;
|
|
1768
|
+
end = !resolves;
|
|
1769
|
+
}
|
|
1770
|
+
let tailStart = -1;
|
|
1771
|
+
if (end && typeof p === "string") {
|
|
1772
|
+
tailStart = endIndex(p, last, lastStart, prev, prevStart);
|
|
1773
|
+
if (tailStart === -1)
|
|
1774
|
+
continue;
|
|
1775
|
+
}
|
|
1776
|
+
if (this.#literalCheck) {
|
|
1777
|
+
for (const l of this.#literals[r]) {
|
|
1778
|
+
if (!f.includes(l))
|
|
1779
|
+
continue ROWS;
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
if (end && typeof p === "object") {
|
|
1783
|
+
tailStart = endIndex(p, last, lastStart, prev, prevStart);
|
|
1784
|
+
if (tailStart === -1)
|
|
1785
|
+
continue;
|
|
1786
|
+
}
|
|
1787
|
+
const shape = this.#shapes[r];
|
|
1788
|
+
if (shape === "base" && end)
|
|
1789
|
+
return "yes";
|
|
1790
|
+
if (shape === "tail" && end) {
|
|
1791
|
+
if (this.#level2 && dotPortion(f, 0, tailStart, true, sep2)) {
|
|
1792
|
+
return "maybe";
|
|
1793
|
+
}
|
|
1794
|
+
if (!dotPortion(f, 0, tailStart, dot, sep2))
|
|
1795
|
+
return "yes";
|
|
1796
|
+
continue;
|
|
1797
|
+
}
|
|
1798
|
+
if (shape === "mid" || shape === "head") {
|
|
1799
|
+
const m = this.#walk(f, row, shape === "head", dot, sep2);
|
|
1800
|
+
if (m !== "no")
|
|
1801
|
+
return m;
|
|
1802
|
+
continue;
|
|
1803
|
+
}
|
|
1804
|
+
return "maybe";
|
|
1805
|
+
}
|
|
1806
|
+
return "no";
|
|
1807
|
+
}
|
|
1808
|
+
// Match a row of a known shape against the split path, the same as
|
|
1809
|
+
// #matchGlobstar and #matchGlobStarBodySections do. None of these
|
|
1810
|
+
// rows have a drive letter, so they start at the first portion.
|
|
1811
|
+
#matchShape(file, row, shape) {
|
|
1812
|
+
const dot = !!this.options.dot;
|
|
1813
|
+
const n = file.length;
|
|
1814
|
+
if (shape === "head") {
|
|
1815
|
+
if (n < 2 || !portionMatch(row[0], file[0])) {
|
|
1816
|
+
return false;
|
|
1817
|
+
}
|
|
1818
|
+
for (let i = 1; i < n; i++)
|
|
1819
|
+
if (!walkable(file[i], dot))
|
|
1820
|
+
return false;
|
|
1821
|
+
return true;
|
|
1822
|
+
}
|
|
1823
|
+
const x = row[1];
|
|
1824
|
+
if (shape === "tail") {
|
|
1825
|
+
let t = n - 1;
|
|
1826
|
+
if (!portionMatch(x, file[t])) {
|
|
1827
|
+
if (file[t] !== "" || n === 1 || !portionMatch(x, file[--t])) {
|
|
1828
|
+
return false;
|
|
1829
|
+
}
|
|
1830
|
+
}
|
|
1831
|
+
for (let i = 0; i < t; i++)
|
|
1832
|
+
if (!walkable(file[i], dot))
|
|
1833
|
+
return false;
|
|
1834
|
+
return true;
|
|
1835
|
+
}
|
|
1836
|
+
for (let k = 0; k < n; k++) {
|
|
1837
|
+
if (portionMatch(x, file[k]) && k + 1 < n) {
|
|
1838
|
+
let i = k + 1;
|
|
1839
|
+
while (i < n && walkable(file[i], dot))
|
|
1840
|
+
i++;
|
|
1841
|
+
if (i === n)
|
|
1842
|
+
return true;
|
|
1843
|
+
}
|
|
1844
|
+
if (!walkable(file[k], dot))
|
|
1845
|
+
return false;
|
|
1518
1846
|
}
|
|
1847
|
+
return false;
|
|
1848
|
+
}
|
|
1849
|
+
// Match a row of `**/x/**` or `x/**` against the path, the same as
|
|
1850
|
+
// #matchGlobstar and #matchGlobStarBodySections do once it is split.
|
|
1851
|
+
// x must match a portion (the first one, for `x/**`), the ** before
|
|
1852
|
+
// it must be able to walk the portions before that one, and there
|
|
1853
|
+
// must be a portion after it, which the ** after it can walk. At
|
|
1854
|
+
// level 2, this is only known if no portion is `.` or `..`.
|
|
1855
|
+
#walk(f, row, head, dot, sep2) {
|
|
1856
|
+
if (this.#level2 && dotPortion(f, 0, f.length, true, sep2))
|
|
1857
|
+
return "maybe";
|
|
1858
|
+
const x = row[head ? 0 : 1];
|
|
1859
|
+
let s = 0;
|
|
1860
|
+
for (let e = nextSep(f, s, sep2); e !== -1; e = nextSep(f, s, sep2)) {
|
|
1861
|
+
let next = e + 1;
|
|
1862
|
+
while (next < f.length && isSep(f.charCodeAt(next), sep2))
|
|
1863
|
+
next++;
|
|
1864
|
+
const hit = typeof x === "string" ? e - s === x.length && f.startsWith(x, s) : e > s && x.testUnchecked(f.slice(s, e));
|
|
1865
|
+
if (hit && !dotPortion(f, next, f.length, dot, sep2))
|
|
1866
|
+
return "yes";
|
|
1867
|
+
if (head || dotPortion(f, s, next, dot, sep2))
|
|
1868
|
+
return "no";
|
|
1869
|
+
s = next;
|
|
1870
|
+
}
|
|
1871
|
+
return "no";
|
|
1872
|
+
}
|
|
1873
|
+
// the last split, if it was the same path with the same split
|
|
1874
|
+
// settings
|
|
1875
|
+
#cachedSplit(f) {
|
|
1876
|
+
const last = lastSplit;
|
|
1877
|
+
return last?.f === f && last.isWindows === this.isWindows && last.preserveMultipleSlashes === this.preserveMultipleSlashes && last.normalize === this.#form ? last : void 0;
|
|
1878
|
+
}
|
|
1879
|
+
// split a path for match(), and keep the parts for the next call
|
|
1880
|
+
#split(f) {
|
|
1881
|
+
const { isWindows, preserveMultipleSlashes } = this;
|
|
1882
|
+
let parts = this.#slashSplit(isWindows ? f.split("\\").join("/") : f);
|
|
1883
|
+
const normalize2 = this.#form;
|
|
1884
|
+
if (normalize2)
|
|
1885
|
+
parts = parts.map((p) => p.normalize(normalize2));
|
|
1886
|
+
lastSplit = {
|
|
1887
|
+
f,
|
|
1888
|
+
isWindows,
|
|
1889
|
+
preserveMultipleSlashes,
|
|
1890
|
+
normalize: normalize2,
|
|
1891
|
+
parts
|
|
1892
|
+
};
|
|
1893
|
+
return lastSplit;
|
|
1894
|
+
}
|
|
1895
|
+
// resolve `.` and `..` portions of a path, for level 2
|
|
1896
|
+
#levelTwoFileOptimize(file) {
|
|
1897
|
+
const parts = [...file];
|
|
1519
1898
|
let didSomething = false;
|
|
1520
1899
|
do {
|
|
1521
1900
|
didSomething = false;
|
|
@@ -1535,13 +1914,14 @@ var Minimatch = class {
|
|
|
1535
1914
|
parts.pop();
|
|
1536
1915
|
}
|
|
1537
1916
|
}
|
|
1538
|
-
|
|
1917
|
+
const root = this.#rootIndex(parts) + 1;
|
|
1918
|
+
let dd = root;
|
|
1539
1919
|
while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
|
|
1540
1920
|
const p = parts[dd - 1];
|
|
1541
|
-
if (p && p !== "." && p !== ".." && p !== "**"
|
|
1921
|
+
if (p && p !== "." && p !== ".." && p !== "**") {
|
|
1542
1922
|
didSomething = true;
|
|
1543
1923
|
parts.splice(dd - 1, 2);
|
|
1544
|
-
dd
|
|
1924
|
+
dd = Math.max(dd - 2, root);
|
|
1545
1925
|
}
|
|
1546
1926
|
}
|
|
1547
1927
|
} while (didSomething);
|
|
@@ -1566,6 +1946,7 @@ var Minimatch = class {
|
|
|
1566
1946
|
// **/*/<rest> -> */**/<rest> <== not valid because ** doesn't follow
|
|
1567
1947
|
// this WOULD be allowed if ** did follow symlinks, or * didn't
|
|
1568
1948
|
firstPhasePreProcess(globParts) {
|
|
1949
|
+
const { braceExpandMax = 1e5 } = this.options;
|
|
1569
1950
|
let didSomething = false;
|
|
1570
1951
|
do {
|
|
1571
1952
|
didSomething = false;
|
|
@@ -1584,7 +1965,7 @@ var Minimatch = class {
|
|
|
1584
1965
|
const p2 = parts[gs + 3];
|
|
1585
1966
|
if (next !== "..")
|
|
1586
1967
|
continue;
|
|
1587
|
-
if (!p || p === "." || p === ".." || !p2 || p2 === "." || p2 === "..") {
|
|
1968
|
+
if (!p || p === "." || p === ".." || !p2 || p2 === "." || p2 === ".." || globParts.length >= braceExpandMax) {
|
|
1588
1969
|
continue;
|
|
1589
1970
|
}
|
|
1590
1971
|
didSomething = true;
|
|
@@ -1610,7 +1991,8 @@ var Minimatch = class {
|
|
|
1610
1991
|
parts.pop();
|
|
1611
1992
|
}
|
|
1612
1993
|
}
|
|
1613
|
-
|
|
1994
|
+
const root = this.#rootIndex(parts) + 1;
|
|
1995
|
+
let dd = root;
|
|
1614
1996
|
while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
|
|
1615
1997
|
const p = parts[dd - 1];
|
|
1616
1998
|
if (p && p !== "." && p !== ".." && p !== "**") {
|
|
@@ -1620,7 +2002,7 @@ var Minimatch = class {
|
|
|
1620
2002
|
parts.splice(dd - 1, 2, ...splin);
|
|
1621
2003
|
if (parts.length === 0)
|
|
1622
2004
|
parts.push("");
|
|
1623
|
-
dd
|
|
2005
|
+
dd = Math.max(dd - 2, root);
|
|
1624
2006
|
}
|
|
1625
2007
|
}
|
|
1626
2008
|
}
|
|
@@ -1635,6 +2017,8 @@ var Minimatch = class {
|
|
|
1635
2017
|
// {<pre>/**/<rest>,<pre>/**/<p>/<rest>} -> <pre>/**/<rest>
|
|
1636
2018
|
// ^-- not valid because ** doens't follow symlinks
|
|
1637
2019
|
secondPhasePreProcess(globParts) {
|
|
2020
|
+
if (globParts.length > 1e3)
|
|
2021
|
+
return globParts;
|
|
1638
2022
|
for (let i = 0; i < globParts.length - 1; i++) {
|
|
1639
2023
|
for (let j = i + 1; j < globParts.length; j++) {
|
|
1640
2024
|
const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
|
|
@@ -1697,15 +2081,28 @@ var Minimatch = class {
|
|
|
1697
2081
|
this.pattern = pattern.slice(negateOffset);
|
|
1698
2082
|
this.negate = negate;
|
|
1699
2083
|
}
|
|
1700
|
-
//
|
|
1701
|
-
//
|
|
1702
|
-
//
|
|
1703
|
-
//
|
|
1704
|
-
//
|
|
1705
|
-
|
|
2084
|
+
// Match the parts of a path against one row of the set. `resolved`
|
|
2085
|
+
// is the parts after level 2 resolves `.` and `..` in them, or the
|
|
2086
|
+
// same parts below level 2. Set partial to true to test if, for
|
|
2087
|
+
// example, "/a/b" matches the start of "/*/b/*/d". Partial means, if
|
|
2088
|
+
// you run out of file before you run out of pattern, then that's
|
|
2089
|
+
// fine, as long as all the parts match.
|
|
2090
|
+
#matchRow(file, resolved, pattern, partial) {
|
|
1706
2091
|
let fileStartIndex = 0;
|
|
1707
2092
|
let patternStartIndex = 0;
|
|
1708
|
-
|
|
2093
|
+
const fh = this.isWindows ? uncHost(resolved) : -1;
|
|
2094
|
+
const ph = fh === -1 ? -1 : uncHost(pattern);
|
|
2095
|
+
if (ph !== -1) {
|
|
2096
|
+
const host = pattern[ph];
|
|
2097
|
+
const share = pattern[ph + 1];
|
|
2098
|
+
if (typeof host !== "string" || typeof share !== "string") {
|
|
2099
|
+
fileStartIndex = fh;
|
|
2100
|
+
patternStartIndex = ph;
|
|
2101
|
+
} else if (resolved[fh].toLowerCase() === host.toLowerCase() && resolved[fh + 1].toLowerCase() === share.toLowerCase()) {
|
|
2102
|
+
fileStartIndex = fh + 2;
|
|
2103
|
+
patternStartIndex = ph + 2;
|
|
2104
|
+
}
|
|
2105
|
+
} else if (this.isWindows) {
|
|
1709
2106
|
const fileDrive = typeof file[0] === "string" && /^[a-z]:$/i.test(file[0]);
|
|
1710
2107
|
const fileUNC = !fileDrive && file[0] === "" && file[1] === "" && file[2] === "?" && /^[a-z]:$/i.test(file[3]);
|
|
1711
2108
|
const patternDrive = typeof pattern[0] === "string" && /^[a-z]:$/i.test(pattern[0]);
|
|
@@ -1718,36 +2115,22 @@ var Minimatch = class {
|
|
|
1718
2115
|
pattern[pdi]
|
|
1719
2116
|
];
|
|
1720
2117
|
if (fd.toLowerCase() === pd.toLowerCase()) {
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
fileStartIndex = fdi;
|
|
2118
|
+
patternStartIndex = pdi + 1;
|
|
2119
|
+
fileStartIndex = fdi + 1;
|
|
1724
2120
|
}
|
|
1725
2121
|
}
|
|
1726
2122
|
}
|
|
1727
|
-
|
|
1728
|
-
if (optimizationLevel >= 2) {
|
|
1729
|
-
file = this.levelTwoFileOptimize(file);
|
|
1730
|
-
}
|
|
2123
|
+
file = resolved;
|
|
1731
2124
|
if (pattern.includes(GLOBSTAR)) {
|
|
1732
2125
|
return this.#matchGlobstar(file, pattern, partial, fileStartIndex, patternStartIndex);
|
|
1733
2126
|
}
|
|
1734
2127
|
return this.#matchOne(file, pattern, partial, fileStartIndex, patternStartIndex);
|
|
1735
2128
|
}
|
|
1736
2129
|
#matchGlobstar(file, pattern, partial, fileIndex, patternIndex) {
|
|
1737
|
-
const
|
|
1738
|
-
const lastgs = pattern.lastIndexOf(GLOBSTAR);
|
|
1739
|
-
const [head, body, tail] = partial ? [
|
|
1740
|
-
pattern.slice(patternIndex, firstgs),
|
|
1741
|
-
pattern.slice(firstgs + 1),
|
|
1742
|
-
[]
|
|
1743
|
-
] : [
|
|
1744
|
-
pattern.slice(patternIndex, firstgs),
|
|
1745
|
-
pattern.slice(firstgs + 1, lastgs),
|
|
1746
|
-
pattern.slice(lastgs + 1)
|
|
1747
|
-
];
|
|
2130
|
+
const { head, body, tail, segments } = this.#getGlobstarParts(pattern, partial, patternIndex);
|
|
1748
2131
|
if (head.length) {
|
|
1749
|
-
const
|
|
1750
|
-
if (!this.#matchOne(
|
|
2132
|
+
const headEnd = fileIndex + head.length;
|
|
2133
|
+
if (!this.#matchOne(file, head, partial, fileIndex, 0, headEnd)) {
|
|
1751
2134
|
return false;
|
|
1752
2135
|
}
|
|
1753
2136
|
fileIndex += head.length;
|
|
@@ -1773,8 +2156,8 @@ var Minimatch = class {
|
|
|
1773
2156
|
}
|
|
1774
2157
|
if (!body.length) {
|
|
1775
2158
|
let sawSome = !!fileTailMatch;
|
|
1776
|
-
for (let
|
|
1777
|
-
const f = String(file[
|
|
2159
|
+
for (let i = fileIndex; i < file.length - fileTailMatch; i++) {
|
|
2160
|
+
const f = String(file[i]);
|
|
1778
2161
|
sawSome = true;
|
|
1779
2162
|
if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) {
|
|
1780
2163
|
return false;
|
|
@@ -1782,33 +2165,57 @@ var Minimatch = class {
|
|
|
1782
2165
|
}
|
|
1783
2166
|
return partial || sawSome;
|
|
1784
2167
|
}
|
|
1785
|
-
|
|
1786
|
-
|
|
2168
|
+
return !!this.#matchGlobStarBodySections(file, segments, file.length - fileTailMatch, fileIndex, 0, partial, 0, !!fileTailMatch, /* @__PURE__ */ new Set());
|
|
2169
|
+
}
|
|
2170
|
+
// Split the pattern into head, tail, and middle of ** delimited
|
|
2171
|
+
// parts. The tail has to be at the end, and the others just have to
|
|
2172
|
+
// be found in order from the head. These only depend on the pattern
|
|
2173
|
+
// row, so they are kept for the next path.
|
|
2174
|
+
#getGlobstarParts(pattern, partial, patternIndex) {
|
|
2175
|
+
let byStart = this.#globstarParts.get(pattern);
|
|
2176
|
+
if (!byStart) {
|
|
2177
|
+
byStart = [];
|
|
2178
|
+
this.#globstarParts.set(pattern, byStart);
|
|
2179
|
+
}
|
|
2180
|
+
const key = patternIndex * 2 + (partial ? 1 : 0);
|
|
2181
|
+
const found = byStart[key];
|
|
2182
|
+
if (found)
|
|
2183
|
+
return found;
|
|
2184
|
+
const firstgs = pattern.indexOf(GLOBSTAR, patternIndex);
|
|
2185
|
+
const lastgs = pattern.lastIndexOf(GLOBSTAR);
|
|
2186
|
+
const head = pattern.slice(patternIndex, firstgs);
|
|
2187
|
+
const body = pattern.slice(firstgs + 1, partial ? void 0 : lastgs);
|
|
2188
|
+
const tail = partial ? [] : pattern.slice(lastgs + 1);
|
|
2189
|
+
const segments = [[[], 0]];
|
|
2190
|
+
let current = segments[0];
|
|
1787
2191
|
let nonGsParts = 0;
|
|
1788
2192
|
const nonGsPartsSums = [0];
|
|
1789
2193
|
for (const b of body) {
|
|
1790
2194
|
if (b === GLOBSTAR) {
|
|
1791
2195
|
nonGsPartsSums.push(nonGsParts);
|
|
1792
|
-
|
|
1793
|
-
|
|
2196
|
+
current = [[], 0];
|
|
2197
|
+
segments.push(current);
|
|
1794
2198
|
} else {
|
|
1795
|
-
|
|
2199
|
+
current[0].push(b);
|
|
1796
2200
|
nonGsParts++;
|
|
1797
2201
|
}
|
|
1798
2202
|
}
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
return
|
|
2203
|
+
segments.forEach((b, i) => {
|
|
2204
|
+
b[1] = nonGsParts - nonGsPartsSums[i];
|
|
2205
|
+
});
|
|
2206
|
+
const parts = { head, body, tail, segments };
|
|
2207
|
+
byStart[key] = parts;
|
|
2208
|
+
return parts;
|
|
1805
2209
|
}
|
|
1806
2210
|
// return false for "nope, not matching"
|
|
1807
2211
|
// return null for "not matching, cannot keep trying"
|
|
1808
|
-
#matchGlobStarBodySections(file, bodySegments, fileIndex, bodyIndex, partial, globStarDepth, sawTail) {
|
|
2212
|
+
#matchGlobStarBodySections(file, bodySegments, fileLength, fileIndex, bodyIndex, partial, globStarDepth, sawTail, tried) {
|
|
1809
2213
|
const bs = bodySegments[bodyIndex];
|
|
1810
2214
|
if (!bs) {
|
|
1811
|
-
|
|
2215
|
+
if (partial) {
|
|
2216
|
+
return fileIndex >= fileLength || fileIndex === fileLength - 1 && file[fileIndex] === "";
|
|
2217
|
+
}
|
|
2218
|
+
for (let i = fileIndex; i < fileLength; i++) {
|
|
1812
2219
|
sawTail = true;
|
|
1813
2220
|
const f = file[i];
|
|
1814
2221
|
if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) {
|
|
@@ -1817,15 +2224,22 @@ var Minimatch = class {
|
|
|
1817
2224
|
}
|
|
1818
2225
|
return sawTail;
|
|
1819
2226
|
}
|
|
1820
|
-
const [body,
|
|
2227
|
+
const [body, need] = bs;
|
|
2228
|
+
const after = partial ? fileLength : fileLength - need;
|
|
1821
2229
|
while (fileIndex <= after) {
|
|
1822
|
-
const
|
|
2230
|
+
const key = bodyIndex * (file.length + 1) + fileIndex;
|
|
2231
|
+
if (tried.has(key))
|
|
2232
|
+
return false;
|
|
2233
|
+
tried.add(key);
|
|
2234
|
+
const m = this.#matchOne(file, body, partial, fileIndex, 0, fileIndex + body.length);
|
|
1823
2235
|
if (m && globStarDepth < this.maxGlobstarRecursion) {
|
|
1824
|
-
const sub = this.#matchGlobStarBodySections(file, bodySegments, fileIndex + body.length, bodyIndex + 1, partial, globStarDepth + 1, sawTail);
|
|
2236
|
+
const sub = this.#matchGlobStarBodySections(file, bodySegments, fileLength, fileIndex + body.length, bodyIndex + 1, partial, globStarDepth + 1, sawTail, tried);
|
|
1825
2237
|
if (sub !== false) {
|
|
1826
2238
|
return sub;
|
|
1827
2239
|
}
|
|
1828
2240
|
}
|
|
2241
|
+
if (fileIndex === after)
|
|
2242
|
+
break;
|
|
1829
2243
|
const f = file[fileIndex];
|
|
1830
2244
|
if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) {
|
|
1831
2245
|
return false;
|
|
@@ -1834,28 +2248,18 @@ var Minimatch = class {
|
|
|
1834
2248
|
}
|
|
1835
2249
|
return partial || null;
|
|
1836
2250
|
}
|
|
1837
|
-
#matchOne(file, pattern, partial, fileIndex, patternIndex) {
|
|
2251
|
+
#matchOne(file, pattern, partial, fileIndex, patternIndex, fileEnd = file.length) {
|
|
1838
2252
|
let fi;
|
|
1839
2253
|
let pi;
|
|
1840
2254
|
let pl;
|
|
1841
2255
|
let fl;
|
|
1842
|
-
for (fi = fileIndex, pi = patternIndex, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
|
|
1843
|
-
this.debug("matchOne loop");
|
|
2256
|
+
for (fi = fileIndex, pi = patternIndex, fl = Math.min(fileEnd, file.length), pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
|
|
1844
2257
|
let p = pattern[pi];
|
|
1845
2258
|
let f = file[fi];
|
|
1846
|
-
this.debug(pattern, p, f);
|
|
1847
2259
|
if (p === false || p === GLOBSTAR) {
|
|
1848
2260
|
return false;
|
|
1849
2261
|
}
|
|
1850
|
-
|
|
1851
|
-
if (typeof p === "string") {
|
|
1852
|
-
hit = f === p;
|
|
1853
|
-
this.debug("string match", p, f, hit);
|
|
1854
|
-
} else {
|
|
1855
|
-
hit = p.test(f);
|
|
1856
|
-
this.debug("pattern match", p, f, hit);
|
|
1857
|
-
}
|
|
1858
|
-
if (!hit)
|
|
2262
|
+
if (!portionMatch(p, f))
|
|
1859
2263
|
return false;
|
|
1860
2264
|
}
|
|
1861
2265
|
if (fi === fl && pi === pl) {
|
|
@@ -1878,88 +2282,21 @@ var Minimatch = class {
|
|
|
1878
2282
|
return GLOBSTAR;
|
|
1879
2283
|
if (pattern === "")
|
|
1880
2284
|
return "";
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
if (
|
|
1884
|
-
|
|
1885
|
-
}
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
fastTest = dotStarTest;
|
|
1893
|
-
}
|
|
1894
|
-
const re = AST.fromGlob(pattern, this.options).toMMPattern();
|
|
1895
|
-
if (fastTest && typeof re === "object") {
|
|
1896
|
-
Reflect.defineProperty(re, "test", { value: fastTest });
|
|
1897
|
-
}
|
|
1898
|
-
return re;
|
|
1899
|
-
}
|
|
1900
|
-
makeRe() {
|
|
1901
|
-
if (this.regexp || this.regexp === false)
|
|
1902
|
-
return this.regexp;
|
|
1903
|
-
const set = this.set;
|
|
1904
|
-
if (!set.length) {
|
|
1905
|
-
this.regexp = false;
|
|
1906
|
-
return this.regexp;
|
|
1907
|
-
}
|
|
1908
|
-
const options = this.options;
|
|
1909
|
-
const twoStar = options.noglobstar ? star2 : options.dot ? twoStarDot : twoStarNoDot;
|
|
1910
|
-
const flags = new Set(options.nocase ? ["i"] : []);
|
|
1911
|
-
let re = set.map((pattern) => {
|
|
1912
|
-
const pp = pattern.map((p) => {
|
|
1913
|
-
if (p instanceof RegExp) {
|
|
1914
|
-
for (const f of p.flags.split(""))
|
|
1915
|
-
flags.add(f);
|
|
1916
|
-
}
|
|
1917
|
-
return typeof p === "string" ? regExpEscape2(p) : p === GLOBSTAR ? GLOBSTAR : p._src;
|
|
1918
|
-
});
|
|
1919
|
-
pp.forEach((p, i) => {
|
|
1920
|
-
const next = pp[i + 1];
|
|
1921
|
-
const prev = pp[i - 1];
|
|
1922
|
-
if (p !== GLOBSTAR || prev === GLOBSTAR) {
|
|
1923
|
-
return;
|
|
1924
|
-
}
|
|
1925
|
-
if (prev === void 0) {
|
|
1926
|
-
if (next !== void 0 && next !== GLOBSTAR) {
|
|
1927
|
-
pp[i + 1] = "(?:\\/|" + twoStar + "\\/)?" + next;
|
|
1928
|
-
} else {
|
|
1929
|
-
pp[i] = twoStar;
|
|
1930
|
-
}
|
|
1931
|
-
} else if (next === void 0) {
|
|
1932
|
-
pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + ")?";
|
|
1933
|
-
} else if (next !== GLOBSTAR) {
|
|
1934
|
-
pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + "\\/)" + next;
|
|
1935
|
-
pp[i + 1] = GLOBSTAR;
|
|
1936
|
-
}
|
|
1937
|
-
});
|
|
1938
|
-
const filtered = pp.filter((p) => p !== GLOBSTAR);
|
|
1939
|
-
if (this.partial && filtered.length >= 1) {
|
|
1940
|
-
const prefixes = [];
|
|
1941
|
-
for (let i = 1; i <= filtered.length; i++) {
|
|
1942
|
-
prefixes.push(filtered.slice(0, i).join("/"));
|
|
1943
|
-
}
|
|
1944
|
-
return "(?:" + prefixes.join("|") + ")";
|
|
1945
|
-
}
|
|
1946
|
-
return filtered.join("/");
|
|
1947
|
-
}).join("|");
|
|
1948
|
-
const [open, close] = set.length > 1 ? ["(?:", ")"] : ["", ""];
|
|
1949
|
-
re = "^" + open + re + close + "$";
|
|
1950
|
-
if (this.partial) {
|
|
1951
|
-
re = "^(?:\\/|" + open + re.slice(1, -1) + close + ")$";
|
|
1952
|
-
}
|
|
1953
|
-
if (this.negate)
|
|
1954
|
-
re = "^(?!" + re + ").+$";
|
|
1955
|
-
try {
|
|
1956
|
-
this.regexp = new RegExp(re, [...flags].join(""));
|
|
1957
|
-
} catch {
|
|
1958
|
-
this.regexp = false;
|
|
2285
|
+
const { nocase, nocaseMagicOnly, noext = false, dot, normalize: normalize2 } = options;
|
|
2286
|
+
const lit2 = literal(pattern, noext);
|
|
2287
|
+
if (lit2 !== void 0 && !(nocase && !nocaseMagicOnly && pattern.toUpperCase() !== pattern.toLowerCase())) {
|
|
2288
|
+
return this.#norm(lit2);
|
|
2289
|
+
}
|
|
2290
|
+
if (this.#pending)
|
|
2291
|
+
return PENDING;
|
|
2292
|
+
let m = this.#matchers.get(pattern);
|
|
2293
|
+
if (!m) {
|
|
2294
|
+
m = new Matcher(pattern, { nocase, noext, dot, normalize: normalize2 });
|
|
2295
|
+
this.#matchers.set(pattern, m);
|
|
1959
2296
|
}
|
|
1960
|
-
return
|
|
2297
|
+
return m;
|
|
1961
2298
|
}
|
|
1962
|
-
slashSplit(p) {
|
|
2299
|
+
#slashSplit(p) {
|
|
1963
2300
|
if (this.preserveMultipleSlashes) {
|
|
1964
2301
|
return p.split("/");
|
|
1965
2302
|
} else if (this.isWindows && /^\/\/[^/]+/.test(p)) {
|
|
@@ -1969,7 +2306,6 @@ var Minimatch = class {
|
|
|
1969
2306
|
}
|
|
1970
2307
|
}
|
|
1971
2308
|
match(f, partial = this.partial) {
|
|
1972
|
-
this.debug("match", f, this.pattern);
|
|
1973
2309
|
if (this.comment) {
|
|
1974
2310
|
return false;
|
|
1975
2311
|
}
|
|
@@ -1980,25 +2316,31 @@ var Minimatch = class {
|
|
|
1980
2316
|
return true;
|
|
1981
2317
|
}
|
|
1982
2318
|
const options = this.options;
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
2319
|
+
let split = this.#cachedSplit(f);
|
|
2320
|
+
if (!split) {
|
|
2321
|
+
if (!partial && !this.#form && (this.#endCheck || this.#literalCheck) && lastChecked !== f) {
|
|
2322
|
+
lastChecked = f;
|
|
2323
|
+
const can = this.#canMatch(f);
|
|
2324
|
+
if (can === "no")
|
|
2325
|
+
return options.flipNegate ? false : this.negate;
|
|
2326
|
+
if (can === "yes")
|
|
2327
|
+
return options.flipNegate ? true : !this.negate;
|
|
2328
|
+
}
|
|
2329
|
+
split = this.#split(f);
|
|
2330
|
+
}
|
|
2331
|
+
const ff = split.parts;
|
|
2332
|
+
const resolved = this.#level2 ? split.resolved ??= this.#levelTwoFileOptimize(ff) : ff;
|
|
1988
2333
|
const set = this.set;
|
|
1989
|
-
this.debug(this.pattern, "set", set);
|
|
1990
2334
|
let filename = ff[ff.length - 1];
|
|
1991
2335
|
if (!filename) {
|
|
1992
2336
|
for (let i = ff.length - 2; !filename && i >= 0; i--) {
|
|
1993
2337
|
filename = ff[i];
|
|
1994
2338
|
}
|
|
1995
2339
|
}
|
|
1996
|
-
for (
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
}
|
|
2001
|
-
const hit = this.matchOne(file, pattern, partial);
|
|
2340
|
+
for (let r = 0; r < set.length; r++) {
|
|
2341
|
+
const pattern = set[r];
|
|
2342
|
+
const shape = partial ? void 0 : this.#shapes[r];
|
|
2343
|
+
const hit = shape === "base" ? portionMatch(pattern[0], filename) : shape ? this.#matchShape(resolved, pattern, shape) : options.matchBase && pattern.length === 1 ? this.#matchRow([filename], [filename], pattern, partial) : this.#matchRow(ff, resolved, pattern, partial);
|
|
2002
2344
|
if (hit) {
|
|
2003
2345
|
if (options.flipNegate) {
|
|
2004
2346
|
return true;
|
|
@@ -2015,7 +2357,6 @@ var Minimatch = class {
|
|
|
2015
2357
|
return minimatch.defaults(def).Minimatch;
|
|
2016
2358
|
}
|
|
2017
2359
|
};
|
|
2018
|
-
minimatch.AST = AST;
|
|
2019
2360
|
minimatch.Minimatch = Minimatch;
|
|
2020
2361
|
minimatch.escape = escape;
|
|
2021
2362
|
minimatch.unescape = unescape;
|
|
@@ -2259,19 +2600,19 @@ function uriToDiskPath(uri) {
|
|
|
2259
2600
|
function normalizeMapKey(filePath) {
|
|
2260
2601
|
return normalizeFilePath(filePath);
|
|
2261
2602
|
}
|
|
2603
|
+
function relativeInside(root, file, pathImpl = path2) {
|
|
2604
|
+
const relative = pathImpl.relative(pathImpl.resolve(root), file);
|
|
2605
|
+
return relative !== ".." && !relative.startsWith(`..${pathImpl.sep}`) && !pathImpl.isAbsolute(relative) ? relative.replace(/\\/g, "/") : void 0;
|
|
2606
|
+
}
|
|
2262
2607
|
function toProjectRelativePath(filePath, projectRoot) {
|
|
2263
2608
|
const p = isWindowsPath(filePath) ? win32 : path2;
|
|
2264
2609
|
if (!p.isAbsolute(filePath))
|
|
2265
2610
|
return filePath.replace(/\\/g, "/");
|
|
2266
|
-
const
|
|
2267
|
-
|
|
2268
|
-
return relative && relative !== ".." && !relative.startsWith(`..${p.sep}`) && !p.isAbsolute(relative) ? relative.replace(/\\/g, "/") : void 0;
|
|
2269
|
-
};
|
|
2270
|
-
const direct = inside(projectRoot, filePath);
|
|
2271
|
-
if (direct !== void 0)
|
|
2611
|
+
const direct = relativeInside(projectRoot, filePath, p);
|
|
2612
|
+
if (direct)
|
|
2272
2613
|
return direct;
|
|
2273
|
-
const canonical =
|
|
2274
|
-
if (canonical
|
|
2614
|
+
const canonical = relativeInside(normalizeFilePath(projectRoot), normalizeFilePath(filePath), p);
|
|
2615
|
+
if (canonical)
|
|
2275
2616
|
return canonical;
|
|
2276
2617
|
return filePath.replace(/\\/g, "/");
|
|
2277
2618
|
}
|
|
@@ -2342,29 +2683,27 @@ function isRealGitMarker(markerPath, details) {
|
|
|
2342
2683
|
}
|
|
2343
2684
|
function findNearestMarkerRoot(startDir, markers, options = {}) {
|
|
2344
2685
|
const boundaries = options.boundaries ?? [];
|
|
2345
|
-
const homeDir = realpathOrResolve(options.homeDir ?? os.homedir());
|
|
2346
2686
|
const markerPredicate = options.markerPredicate ?? (() => true);
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2687
|
+
for (const current of walkUpDirs(startDir, {
|
|
2688
|
+
homeDir: options.homeDir ?? os.homedir(),
|
|
2689
|
+
maxDepth: 64
|
|
2690
|
+
})) {
|
|
2351
2691
|
if (markers.some((m) => existsSync(path2.join(current, m)) && markerPredicate(path2.join(current, m))))
|
|
2352
2692
|
return current;
|
|
2353
2693
|
if (boundaries.some((m) => existsSync(path2.join(current, m))))
|
|
2354
2694
|
return null;
|
|
2355
|
-
const parent = path2.dirname(current);
|
|
2356
|
-
if (parent === current)
|
|
2357
|
-
return null;
|
|
2358
|
-
current = parent;
|
|
2359
2695
|
}
|
|
2360
2696
|
return null;
|
|
2361
2697
|
}
|
|
2362
2698
|
function findNearestMarkerRootDetailed(startDir, markers, options) {
|
|
2363
|
-
|
|
2364
|
-
let
|
|
2365
|
-
for (
|
|
2366
|
-
|
|
2367
|
-
|
|
2699
|
+
let climbed = 0;
|
|
2700
|
+
let last;
|
|
2701
|
+
for (const current of walkUpDirs(startDir, {
|
|
2702
|
+
homeDir: options.homeDir ?? os.homedir(),
|
|
2703
|
+
maxDepth: 64
|
|
2704
|
+
})) {
|
|
2705
|
+
climbed += 1;
|
|
2706
|
+
last = current;
|
|
2368
2707
|
for (const marker of markers) {
|
|
2369
2708
|
const markerPath = path2.join(current, marker);
|
|
2370
2709
|
const checked = options.markerPredicate(markerPath);
|
|
@@ -2373,16 +2712,18 @@ function findNearestMarkerRootDetailed(startDir, markers, options) {
|
|
|
2373
2712
|
if (checked.kind === "valid")
|
|
2374
2713
|
return { kind: "found", root: current };
|
|
2375
2714
|
}
|
|
2376
|
-
const parent = path2.dirname(current);
|
|
2377
|
-
if (parent === current)
|
|
2378
|
-
return { kind: "not-found", reason: "root" };
|
|
2379
|
-
current = parent;
|
|
2380
2715
|
}
|
|
2381
|
-
|
|
2716
|
+
if (last === void 0)
|
|
2717
|
+
return { kind: "not-found", reason: "home-ceiling" };
|
|
2718
|
+
if (path2.dirname(last) === last)
|
|
2719
|
+
return { kind: "not-found", reason: "root" };
|
|
2720
|
+
return {
|
|
2721
|
+
kind: "not-found",
|
|
2722
|
+
reason: climbed >= 64 ? "depth-limit" : "home-ceiling"
|
|
2723
|
+
};
|
|
2382
2724
|
}
|
|
2383
2725
|
function isAtOrAboveHomeDir(dir, homeDir = os.homedir(), pathImpl = path2) {
|
|
2384
|
-
|
|
2385
|
-
return !rel.startsWith("..") && !pathImpl.isAbsolute(rel);
|
|
2726
|
+
return relativeInside(dir, pathImpl.resolve(homeDir), pathImpl) !== void 0;
|
|
2386
2727
|
}
|
|
2387
2728
|
function homeRelativePath(filePath, homeDir = os.homedir()) {
|
|
2388
2729
|
if (filePath.length === 0)
|
|
@@ -2405,6 +2746,9 @@ function isUnderDir(child, parent) {
|
|
|
2405
2746
|
return true;
|
|
2406
2747
|
if (process.platform === "win32")
|
|
2407
2748
|
return false;
|
|
2749
|
+
return isWithinIdentity(child, parent);
|
|
2750
|
+
}
|
|
2751
|
+
function isWithinIdentity(child, parent) {
|
|
2408
2752
|
return isWithinForm(normalizeFilePath(child), normalizeFilePath(parent));
|
|
2409
2753
|
}
|
|
2410
2754
|
function isWithinForm(child, parent) {
|
|
@@ -2651,6 +2995,7 @@ export {
|
|
|
2651
2995
|
uriToPath,
|
|
2652
2996
|
uriToDiskPath,
|
|
2653
2997
|
normalizeMapKey,
|
|
2998
|
+
relativeInside,
|
|
2654
2999
|
toProjectRelativePath,
|
|
2655
3000
|
normalizeEphemeralMapKey,
|
|
2656
3001
|
pathsEqual,
|
|
@@ -2663,6 +3008,7 @@ export {
|
|
|
2663
3008
|
isAtOrAboveHomeDir,
|
|
2664
3009
|
homeRelativePath,
|
|
2665
3010
|
isUnderDir,
|
|
3011
|
+
isWithinIdentity,
|
|
2666
3012
|
isWithinForm,
|
|
2667
3013
|
isVendorPath,
|
|
2668
3014
|
isExternalOrVendorFile,
|