@dev.fast/whiteboard 0.5.2-preview.20261104.147 → 0.5.2-preview.20261109.149
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/dist/{account-alias-DXpd0Px8.js → account-alias-Cs5YqXRj.js} +4 -4
- package/dist/agent-cli-DdUAmdca.js +2 -0
- package/dist/{agent-cli-COrZtFks.js → agent-cli-a5J-juuu.js} +8 -8
- package/dist/{agent-client-BFtYm3Ng.js → agent-client-CgnEo6lf.js} +3 -3
- package/dist/{authoring-tools-D1avYp8-.js → authoring-tools-BgZvnbjN.js} +3 -3
- package/dist/{background-server-HOJozY99.js → background-server-D8SaPvuC.js} +1 -1
- package/dist/{background-server-BiRSqjxG.js → background-server-DHEcsFwH.js} +4 -4
- package/dist/build-info.json +1 -1
- package/dist/{cli-CSlwGRvH.js → cli-Bq5zVqlc.js} +1 -1
- package/dist/{cli-runner-CuffXA0Q.js → cli-runner-hL2efcxb.js} +21 -21
- package/dist/cli.js +1 -1
- package/dist/{fuzzy-match-DEo941za.js → fuzzy-match-DNyQDN3P.js} +2 -2
- package/dist/{headless-host-BCkXVVpU.js → headless-host-CGyfb5mS.js} +1 -1
- package/dist/{headless-host-CIuJJjmM.js → headless-host-bb09yVkX.js} +17 -15
- package/dist/{import-CjcW7EIQ.js → import-_XAsWqen.js} +24 -139
- package/dist/{local-data-B5PBZ0Ge.js → local-data-ZQIkF5k1.js} +81 -70
- package/dist/{mcp-Ba3WvhUh.js → mcp-B-J8P5xm.js} +4 -4
- package/dist/{package-paths-Dk7MOXxN.js → package-paths-wobHueCx.js} +1 -1
- package/dist/profile-Bi2SbpSI.js +2 -0
- package/dist/{profile-CNMhLUhf.js → profile-D-SbO3p9.js} +2 -2
- package/dist/{remote-attach-DkZoYBHV.js → remote-attach-DyIESbbf.js} +4 -4
- package/dist/{remote-extensions-BvV29_gk.js → remote-extensions-BHHFPyYW.js} +1 -1
- package/dist/{remote-extensions-L95HNwIH.js → remote-extensions-gTMcRBg-.js} +2 -2
- package/dist/{remote-language-server-l4ConTfj.js → remote-language-server-Pp261dqJ.js} +4 -4
- package/dist/{remote-uninstall-BAQM7cU8.js → remote-uninstall-D_hSuBik.js} +5 -5
- package/dist/{request-origin-DZexKlc4.js → request-origin-ENYd0Ymr.js} +1 -1
- package/dist/{review-app-launcher-B5F10y_4.js → review-app-launcher-DR5vYGEl.js} +1 -1
- package/dist/{review-home-paths-BmZX2qiz.js → review-home-paths-B8909D07.js} +19 -19
- package/dist/{review-telemetry-kQ7esDRE.js → review-telemetry-CxNvwdDS.js} +4 -4
- package/dist/server/desktop-host.js +74 -16
- package/dist/{server-discovery-DYY_xeG9.js → server-discovery-Fme7f3fb.js} +2 -2
- package/dist/sharing/index.d.ts +21 -21
- package/dist/sharing/index.js +1 -1
- package/dist/{src-DirPN_Qh.js → src-BPrngiWX.js} +1769 -1
- package/dist/{stored-document-migration-vg0NAzXG.js → stored-document-migration-BQcUyXO8.js} +4 -73
- package/dist/{tool-failure-BLBwcl3H.js → tool-failure-Cgjidoud.js} +5 -5
- package/package.json +5 -6
- package/src/review-api/comparison-coverage.ts +6 -20
- package/src/review-api/http.ts +20 -16
- package/src/review-api/review-progress.ts +38 -123
- package/src/review-api/store.ts +4 -6
- package/src/server/review-gateway-pushes.ts +5 -1
- package/src/server/review-gateway.ts +15 -1
- package/src/software-map-diff-counts.ts +4 -2
- package/src/viewed-coverage.ts +9 -252
- package/dist/agent-cli-x6-Eh1S-.js +0 -2
- package/dist/profile-BstQkIY0.js +0 -2
- package/src/review-api/file-lenses.ts +0 -125
- package/src/unified-diff.ts +0 -71
- package/dist/{s3-CsG2EWED.js → s3-d8RGPKwt.js} +1 -1
|
@@ -37,6 +37,33 @@ function unionIntervals(ranges) {
|
|
|
37
37
|
}
|
|
38
38
|
return result;
|
|
39
39
|
}
|
|
40
|
+
function intersectIntervals(left, right) {
|
|
41
|
+
const result = [];
|
|
42
|
+
const a = unionIntervals(left), b = unionIntervals(right);
|
|
43
|
+
let i = 0, j = 0;
|
|
44
|
+
while (i < a.length && j < b.length) {
|
|
45
|
+
const start = Math.max(a[i][0], b[j][0]), end = Math.min(a[i][1], b[j][1]);
|
|
46
|
+
if (start < end) result.push([start, end]);
|
|
47
|
+
if (a[i][1] < b[j][1]) i++;
|
|
48
|
+
else j++;
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
function subtractIntervals(from, remove) {
|
|
53
|
+
const result = [];
|
|
54
|
+
const removed = unionIntervals(remove);
|
|
55
|
+
for (const [start, end] of unionIntervals(from)) {
|
|
56
|
+
let cursor = start;
|
|
57
|
+
for (const [lower, upper] of removed) {
|
|
58
|
+
if (upper <= cursor) continue;
|
|
59
|
+
if (lower >= end) break;
|
|
60
|
+
if (lower > cursor) result.push([cursor, lower]);
|
|
61
|
+
cursor = Math.min(end, Math.max(cursor, upper));
|
|
62
|
+
}
|
|
63
|
+
if (cursor < end) result.push([cursor, end]);
|
|
64
|
+
}
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
40
67
|
//#endregion
|
|
41
68
|
//#region ../whiteboard-document/src/lens-selection.ts
|
|
42
69
|
const ANCHOR_FORMS = "\"head/path#L10-L24\" or \"base/path#L7\" (one side, lines 10–24 or line 7); across sides, GitHub diff style \"diff/path#L84-R90\" (L = base line, R = head line)";
|
|
@@ -376,6 +403,44 @@ const animation = {
|
|
|
376
403
|
}
|
|
377
404
|
};
|
|
378
405
|
//#endregion
|
|
406
|
+
//#region ../whiteboard-document/src/coverage.ts
|
|
407
|
+
const emptyCoverage = () => ({
|
|
408
|
+
base: [],
|
|
409
|
+
head: []
|
|
410
|
+
});
|
|
411
|
+
function updateCoverage(current, scope, viewed) {
|
|
412
|
+
const apply = (side) => viewed ? unionIntervals([...current[side], ...scope[side]]) : subtractIntervals(current[side], scope[side]);
|
|
413
|
+
return {
|
|
414
|
+
base: apply("base"),
|
|
415
|
+
head: apply("head")
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
function scopedCoverage(file, sources) {
|
|
419
|
+
if (!sources) return file.changed;
|
|
420
|
+
const side = (side) => intersectIntervals(file.changed[side], sources.flatMap((source) => source.side === side && source.file === (side === "base" ? file.previousPath ?? file.path : file.path) ? [[source.fromLine - 1, source.toLine]] : []));
|
|
421
|
+
return {
|
|
422
|
+
base: side("base"),
|
|
423
|
+
head: side("head")
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
/** Each file's own sources, grouped once. */
|
|
427
|
+
function sourcesForFile(sources) {
|
|
428
|
+
if (!sources) return () => void 0;
|
|
429
|
+
const byFile = Map.groupBy(sources, (source) => source.file);
|
|
430
|
+
return (file) => {
|
|
431
|
+
const base = byFile.get(file.previousPath ?? file.path) ?? [];
|
|
432
|
+
return file.previousPath && file.previousPath !== file.path ? [...base, ...byFile.get(file.path) ?? []] : base;
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
function coverageSources(file, coverage = file.viewed) {
|
|
436
|
+
return ["base", "head"].flatMap((side) => coverage[side].map(([start, end]) => ({
|
|
437
|
+
side,
|
|
438
|
+
file: side === "base" ? file.previousPath ?? file.path : file.path,
|
|
439
|
+
fromLine: start + 1,
|
|
440
|
+
toLine: end
|
|
441
|
+
})));
|
|
442
|
+
}
|
|
443
|
+
//#endregion
|
|
379
444
|
//#region ../whiteboard-document/src/blocks/flow_diagram.ts
|
|
380
445
|
/** Nodes and edges are the diagram's children: each is its own edit target,
|
|
381
446
|
* so an agent can draw a diagram one unit at a time. Edges still name nodes
|
|
@@ -2405,4 +2470,1707 @@ function written(element) {
|
|
|
2405
2470
|
return applied;
|
|
2406
2471
|
}
|
|
2407
2472
|
//#endregion
|
|
2408
|
-
|
|
2473
|
+
//#region ../../node_modules/balanced-match/dist/esm/index.js
|
|
2474
|
+
const balanced = (a, b, str) => {
|
|
2475
|
+
const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
|
|
2476
|
+
const mb = b instanceof RegExp ? maybeMatch(b, str) : b;
|
|
2477
|
+
const r = ma !== null && mb != null && range(ma, mb, str);
|
|
2478
|
+
return r && {
|
|
2479
|
+
start: r[0],
|
|
2480
|
+
end: r[1],
|
|
2481
|
+
pre: str.slice(0, r[0]),
|
|
2482
|
+
body: str.slice(r[0] + ma.length, r[1]),
|
|
2483
|
+
post: str.slice(r[1] + mb.length)
|
|
2484
|
+
};
|
|
2485
|
+
};
|
|
2486
|
+
const maybeMatch = (reg, str) => {
|
|
2487
|
+
const m = str.match(reg);
|
|
2488
|
+
return m ? m[0] : null;
|
|
2489
|
+
};
|
|
2490
|
+
const range = (a, b, str) => {
|
|
2491
|
+
let begs, beg, left, right = void 0, result;
|
|
2492
|
+
let ai = str.indexOf(a);
|
|
2493
|
+
let bi = str.indexOf(b, ai + 1);
|
|
2494
|
+
let i = ai;
|
|
2495
|
+
if (ai >= 0 && bi > 0) {
|
|
2496
|
+
if (a === b) return [ai, bi];
|
|
2497
|
+
begs = [];
|
|
2498
|
+
left = str.length;
|
|
2499
|
+
while (i >= 0 && !result) {
|
|
2500
|
+
if (i === ai) {
|
|
2501
|
+
begs.push(i);
|
|
2502
|
+
ai = str.indexOf(a, i + 1);
|
|
2503
|
+
} else if (begs.length === 1) {
|
|
2504
|
+
const r = begs.pop();
|
|
2505
|
+
if (r !== void 0) result = [r, bi];
|
|
2506
|
+
} else {
|
|
2507
|
+
beg = begs.pop();
|
|
2508
|
+
if (beg !== void 0 && beg < left) {
|
|
2509
|
+
left = beg;
|
|
2510
|
+
right = bi;
|
|
2511
|
+
}
|
|
2512
|
+
bi = str.indexOf(b, i + 1);
|
|
2513
|
+
}
|
|
2514
|
+
i = ai < bi && ai >= 0 ? ai : bi;
|
|
2515
|
+
}
|
|
2516
|
+
if (begs.length && right !== void 0) result = [left, right];
|
|
2517
|
+
}
|
|
2518
|
+
return result;
|
|
2519
|
+
};
|
|
2520
|
+
//#endregion
|
|
2521
|
+
//#region ../../node_modules/brace-expansion/dist/esm/index.js
|
|
2522
|
+
const escSlash = "\0SLASH" + Math.random() + "\0";
|
|
2523
|
+
const escOpen = "\0OPEN" + Math.random() + "\0";
|
|
2524
|
+
const escClose = "\0CLOSE" + Math.random() + "\0";
|
|
2525
|
+
const escComma = "\0COMMA" + Math.random() + "\0";
|
|
2526
|
+
const escPeriod = "\0PERIOD" + Math.random() + "\0";
|
|
2527
|
+
const escSlashPattern = new RegExp(escSlash, "g");
|
|
2528
|
+
const escOpenPattern = new RegExp(escOpen, "g");
|
|
2529
|
+
const escClosePattern = new RegExp(escClose, "g");
|
|
2530
|
+
const escCommaPattern = new RegExp(escComma, "g");
|
|
2531
|
+
const escPeriodPattern = new RegExp(escPeriod, "g");
|
|
2532
|
+
const slashPattern = /\\\\/g;
|
|
2533
|
+
const openPattern = /\\{/g;
|
|
2534
|
+
const closePattern = /\\}/g;
|
|
2535
|
+
const commaPattern = /\\,/g;
|
|
2536
|
+
const periodPattern = /\\\./g;
|
|
2537
|
+
const EXPANSION_MAX = 1e5;
|
|
2538
|
+
const EXPANSION_MAX_LENGTH = 4e6;
|
|
2539
|
+
const EXPANSION_MAX_DEPTH = 1e3;
|
|
2540
|
+
const EXPANSION_MAX_REWRITES = 1e3;
|
|
2541
|
+
function numeric(str) {
|
|
2542
|
+
return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
|
|
2543
|
+
}
|
|
2544
|
+
function escapeBraces(str) {
|
|
2545
|
+
return str.replace(slashPattern, escSlash).replace(openPattern, escOpen).replace(closePattern, escClose).replace(commaPattern, escComma).replace(periodPattern, escPeriod);
|
|
2546
|
+
}
|
|
2547
|
+
function unescapeBraces(str) {
|
|
2548
|
+
return str.replace(escSlashPattern, "\\").replace(escOpenPattern, "{").replace(escClosePattern, "}").replace(escCommaPattern, ",").replace(escPeriodPattern, ".");
|
|
2549
|
+
}
|
|
2550
|
+
function pushAll(target, items) {
|
|
2551
|
+
for (let i = 0; i < items.length; i++) target.push(items[i]);
|
|
2552
|
+
}
|
|
2553
|
+
/**
|
|
2554
|
+
* Basically just str.split(","), but handling cases
|
|
2555
|
+
* where we have nested braced sections, which should be
|
|
2556
|
+
* treated as individual members, like {a,{b,c},d}
|
|
2557
|
+
*/
|
|
2558
|
+
function parseCommaParts(str) {
|
|
2559
|
+
const parts = [];
|
|
2560
|
+
let carry = "";
|
|
2561
|
+
for (;;) {
|
|
2562
|
+
const m = balanced("{", "}", str);
|
|
2563
|
+
if (!m) {
|
|
2564
|
+
const tail = str.split(",");
|
|
2565
|
+
tail[0] = carry + tail[0];
|
|
2566
|
+
pushAll(parts, tail);
|
|
2567
|
+
return parts;
|
|
2568
|
+
}
|
|
2569
|
+
const { pre, body, post } = m;
|
|
2570
|
+
const p = pre.split(",");
|
|
2571
|
+
p[0] = carry + p[0];
|
|
2572
|
+
p[p.length - 1] += "{" + body + "}";
|
|
2573
|
+
if (!post.length) {
|
|
2574
|
+
pushAll(parts, p);
|
|
2575
|
+
return parts;
|
|
2576
|
+
}
|
|
2577
|
+
carry = p.pop();
|
|
2578
|
+
pushAll(parts, p);
|
|
2579
|
+
str = post;
|
|
2580
|
+
}
|
|
2581
|
+
}
|
|
2582
|
+
function expand(str, options = {}) {
|
|
2583
|
+
if (!str) return [];
|
|
2584
|
+
const { max = EXPANSION_MAX, maxLength = EXPANSION_MAX_LENGTH, maxDepth = EXPANSION_MAX_DEPTH, maxRewrites = EXPANSION_MAX_REWRITES } = options;
|
|
2585
|
+
if (str.slice(0, 2) === "{}") str = "\\{\\}" + str.slice(2);
|
|
2586
|
+
return expand_(escapeBraces(str), max, maxLength, maxDepth, 0, maxRewrites, true).map(unescapeBraces);
|
|
2587
|
+
}
|
|
2588
|
+
function embrace(str) {
|
|
2589
|
+
return "{" + str + "}";
|
|
2590
|
+
}
|
|
2591
|
+
function isPadded(el) {
|
|
2592
|
+
return /^-?0\d/.test(el);
|
|
2593
|
+
}
|
|
2594
|
+
function lte(i, y) {
|
|
2595
|
+
return i <= y;
|
|
2596
|
+
}
|
|
2597
|
+
function gte(i, y) {
|
|
2598
|
+
return i >= y;
|
|
2599
|
+
}
|
|
2600
|
+
function combine(acc, pre, values, max, maxLength, dropEmpties) {
|
|
2601
|
+
const out = [];
|
|
2602
|
+
let length = 0;
|
|
2603
|
+
for (let a = 0; a < acc.length; a++) for (let v = 0; v < values.length; v++) {
|
|
2604
|
+
if (out.length >= max) return out;
|
|
2605
|
+
const expansion = acc[a] + pre + values[v];
|
|
2606
|
+
if (dropEmpties && !expansion) continue;
|
|
2607
|
+
if (length + expansion.length > maxLength) return out;
|
|
2608
|
+
out.push(expansion);
|
|
2609
|
+
length += expansion.length;
|
|
2610
|
+
}
|
|
2611
|
+
return out;
|
|
2612
|
+
}
|
|
2613
|
+
function expandSequence(body, isAlphaSequence, max, maxLength) {
|
|
2614
|
+
const n = body.split(/\.\./);
|
|
2615
|
+
const N = [];
|
|
2616
|
+
/* c8 ignore start */
|
|
2617
|
+
if (n[0] === void 0 || n[1] === void 0) return N;
|
|
2618
|
+
/* c8 ignore stop */
|
|
2619
|
+
const x = numeric(n[0]);
|
|
2620
|
+
const y = numeric(n[1]);
|
|
2621
|
+
const width = Math.max(n[0].length, n[1].length);
|
|
2622
|
+
let incr = n.length === 3 && n[2] !== void 0 ? Math.max(Math.abs(numeric(n[2])), 1) : 1;
|
|
2623
|
+
let test = lte;
|
|
2624
|
+
if (y < x) {
|
|
2625
|
+
incr *= -1;
|
|
2626
|
+
test = gte;
|
|
2627
|
+
}
|
|
2628
|
+
const pad = n.some(isPadded);
|
|
2629
|
+
let length = 0;
|
|
2630
|
+
for (let i = x; test(i, y) && N.length < max; i += incr) {
|
|
2631
|
+
let c;
|
|
2632
|
+
if (isAlphaSequence) {
|
|
2633
|
+
c = String.fromCharCode(i);
|
|
2634
|
+
if (c === "\\") c = "";
|
|
2635
|
+
} else {
|
|
2636
|
+
c = String(i);
|
|
2637
|
+
if (pad) {
|
|
2638
|
+
const need = width - c.length;
|
|
2639
|
+
if (need > 0) {
|
|
2640
|
+
const z = new Array(need + 1).join("0");
|
|
2641
|
+
if (i < 0) c = "-" + z + c.slice(1);
|
|
2642
|
+
else c = z + c;
|
|
2643
|
+
}
|
|
2644
|
+
}
|
|
2645
|
+
}
|
|
2646
|
+
if (length + c.length > maxLength) break;
|
|
2647
|
+
N.push(c);
|
|
2648
|
+
length += c.length;
|
|
2649
|
+
}
|
|
2650
|
+
return N;
|
|
2651
|
+
}
|
|
2652
|
+
function expand_(str, max, maxLength, maxDepth, depth, maxRewrites, isTop) {
|
|
2653
|
+
if (depth > maxDepth) return [str];
|
|
2654
|
+
let acc = [""];
|
|
2655
|
+
let rewrites = 0;
|
|
2656
|
+
let dropEmpties = false;
|
|
2657
|
+
let firstGroup = true;
|
|
2658
|
+
for (;;) {
|
|
2659
|
+
const m = balanced("{", "}", str);
|
|
2660
|
+
if (!m) return combine(acc, str, [""], max, maxLength, dropEmpties);
|
|
2661
|
+
const pre = m.pre;
|
|
2662
|
+
if (/\$$/.test(pre)) {
|
|
2663
|
+
acc = combine(acc, pre + "{" + m.body + "}", [""], max, maxLength, dropEmpties && !m.post.length);
|
|
2664
|
+
firstGroup = false;
|
|
2665
|
+
if (!m.post.length) break;
|
|
2666
|
+
str = m.post;
|
|
2667
|
+
continue;
|
|
2668
|
+
}
|
|
2669
|
+
const isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
|
2670
|
+
const isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
|
2671
|
+
const isSequence = isNumericSequence || isAlphaSequence;
|
|
2672
|
+
const isOptions = m.body.indexOf(",") >= 0;
|
|
2673
|
+
if (!isSequence && !isOptions) {
|
|
2674
|
+
if (rewrites < maxRewrites && m.post.match(/,(?!,).*\}/)) {
|
|
2675
|
+
rewrites++;
|
|
2676
|
+
str = m.pre + "{" + m.body + escClose + m.post;
|
|
2677
|
+
isTop = true;
|
|
2678
|
+
continue;
|
|
2679
|
+
}
|
|
2680
|
+
return combine(acc, pre + "{" + m.body + "}" + m.post, [""], max, maxLength, dropEmpties);
|
|
2681
|
+
}
|
|
2682
|
+
if (firstGroup) {
|
|
2683
|
+
dropEmpties = isTop && !isSequence;
|
|
2684
|
+
firstGroup = false;
|
|
2685
|
+
}
|
|
2686
|
+
let values;
|
|
2687
|
+
if (isSequence) values = expandSequence(m.body, isAlphaSequence, max, maxLength);
|
|
2688
|
+
else {
|
|
2689
|
+
let n = parseCommaParts(m.body);
|
|
2690
|
+
if (n.length === 1 && n[0] !== void 0) {
|
|
2691
|
+
n = expand_(n[0], max, maxLength, maxDepth, depth + 1, maxRewrites, false).map(embrace);
|
|
2692
|
+
/* c8 ignore start */
|
|
2693
|
+
if (n.length === 1) {
|
|
2694
|
+
acc = combine(acc, pre + n[0], [""], max, maxLength, dropEmpties && !m.post.length);
|
|
2695
|
+
if (!m.post.length) break;
|
|
2696
|
+
str = m.post;
|
|
2697
|
+
continue;
|
|
2698
|
+
}
|
|
2699
|
+
}
|
|
2700
|
+
let dropsEmpties = dropEmpties && !m.post.length && !pre;
|
|
2701
|
+
for (let d = 0; dropsEmpties && d < acc.length; d++) if (acc[d]) dropsEmpties = false;
|
|
2702
|
+
values = [];
|
|
2703
|
+
let valuesLength = 0;
|
|
2704
|
+
outer: for (let j = 0; j < n.length; j++) {
|
|
2705
|
+
const expanded = expand_(n[j], max, maxLength, maxDepth, depth + 1, maxRewrites, false);
|
|
2706
|
+
for (let k = 0; k < expanded.length; k++) {
|
|
2707
|
+
const v = expanded[k];
|
|
2708
|
+
if (dropsEmpties && !v) continue;
|
|
2709
|
+
if (values.length >= max || valuesLength + v.length > maxLength) break outer;
|
|
2710
|
+
values.push(v);
|
|
2711
|
+
valuesLength += v.length;
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2714
|
+
}
|
|
2715
|
+
acc = combine(acc, pre, values, max, maxLength, dropEmpties && !m.post.length);
|
|
2716
|
+
if (!m.post.length) break;
|
|
2717
|
+
str = m.post;
|
|
2718
|
+
}
|
|
2719
|
+
return acc;
|
|
2720
|
+
}
|
|
2721
|
+
//#endregion
|
|
2722
|
+
//#region ../../node_modules/minimatch/dist/esm/assert-valid-pattern.js
|
|
2723
|
+
const MAX_PATTERN_LENGTH = 65536;
|
|
2724
|
+
const assertValidPattern = (pattern) => {
|
|
2725
|
+
if (typeof pattern !== "string") throw new TypeError("invalid pattern");
|
|
2726
|
+
if (pattern.length > MAX_PATTERN_LENGTH) throw new TypeError("pattern is too long");
|
|
2727
|
+
};
|
|
2728
|
+
//#endregion
|
|
2729
|
+
//#region ../../node_modules/minimatch/dist/esm/brace-expressions.js
|
|
2730
|
+
const posixClasses = {
|
|
2731
|
+
"[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true],
|
|
2732
|
+
"[:alpha:]": ["\\p{L}\\p{Nl}", true],
|
|
2733
|
+
"[:ascii:]": ["\\x00-\\x7f", false],
|
|
2734
|
+
"[:blank:]": ["\\p{Zs}\\t", true],
|
|
2735
|
+
"[:cntrl:]": ["\\p{Cc}", true],
|
|
2736
|
+
"[:digit:]": ["\\p{Nd}", true],
|
|
2737
|
+
"[:graph:]": [
|
|
2738
|
+
"\\p{Z}\\p{C}",
|
|
2739
|
+
true,
|
|
2740
|
+
true
|
|
2741
|
+
],
|
|
2742
|
+
"[:lower:]": ["\\p{Ll}", true],
|
|
2743
|
+
"[:print:]": ["\\p{C}", true],
|
|
2744
|
+
"[:punct:]": ["\\p{P}", true],
|
|
2745
|
+
"[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", true],
|
|
2746
|
+
"[:upper:]": ["\\p{Lu}", true],
|
|
2747
|
+
"[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", true],
|
|
2748
|
+
"[:xdigit:]": ["A-Fa-f0-9", false]
|
|
2749
|
+
};
|
|
2750
|
+
const braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&");
|
|
2751
|
+
const regexpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
2752
|
+
const rangesToString = (ranges) => ranges.join("");
|
|
2753
|
+
const parseClass = (glob, position) => {
|
|
2754
|
+
const pos = position;
|
|
2755
|
+
/* c8 ignore start */
|
|
2756
|
+
if (glob.charAt(pos) !== "[") throw new Error("not in a brace expression");
|
|
2757
|
+
/* c8 ignore stop */
|
|
2758
|
+
const ranges = [];
|
|
2759
|
+
const negs = [];
|
|
2760
|
+
let i = pos + 1;
|
|
2761
|
+
let sawStart = false;
|
|
2762
|
+
let uflag = false;
|
|
2763
|
+
let escaping = false;
|
|
2764
|
+
let negate = false;
|
|
2765
|
+
let endPos = pos;
|
|
2766
|
+
let rangeStart = "";
|
|
2767
|
+
WHILE: while (i < glob.length) {
|
|
2768
|
+
const c = glob.charAt(i);
|
|
2769
|
+
if ((c === "!" || c === "^") && i === pos + 1) {
|
|
2770
|
+
negate = true;
|
|
2771
|
+
i++;
|
|
2772
|
+
continue;
|
|
2773
|
+
}
|
|
2774
|
+
if (c === "]" && sawStart && !escaping) {
|
|
2775
|
+
endPos = i + 1;
|
|
2776
|
+
break;
|
|
2777
|
+
}
|
|
2778
|
+
sawStart = true;
|
|
2779
|
+
if (c === "\\") {
|
|
2780
|
+
if (!escaping) {
|
|
2781
|
+
escaping = true;
|
|
2782
|
+
i++;
|
|
2783
|
+
continue;
|
|
2784
|
+
}
|
|
2785
|
+
}
|
|
2786
|
+
if (c === "[" && !escaping) {
|
|
2787
|
+
for (const [cls, [unip, u, neg]] of Object.entries(posixClasses)) if (glob.startsWith(cls, i)) {
|
|
2788
|
+
if (rangeStart) return [
|
|
2789
|
+
"$.",
|
|
2790
|
+
false,
|
|
2791
|
+
glob.length - pos,
|
|
2792
|
+
true
|
|
2793
|
+
];
|
|
2794
|
+
i += cls.length;
|
|
2795
|
+
if (neg) negs.push(unip);
|
|
2796
|
+
else ranges.push(unip);
|
|
2797
|
+
uflag = uflag || u;
|
|
2798
|
+
continue WHILE;
|
|
2799
|
+
}
|
|
2800
|
+
}
|
|
2801
|
+
escaping = false;
|
|
2802
|
+
if (rangeStart) {
|
|
2803
|
+
if (c > rangeStart) ranges.push(braceEscape(rangeStart) + "-" + braceEscape(c));
|
|
2804
|
+
else if (c === rangeStart) ranges.push(braceEscape(c));
|
|
2805
|
+
rangeStart = "";
|
|
2806
|
+
i++;
|
|
2807
|
+
continue;
|
|
2808
|
+
}
|
|
2809
|
+
if (glob.startsWith("-]", i + 1)) {
|
|
2810
|
+
ranges.push(braceEscape(c + "-"));
|
|
2811
|
+
i += 2;
|
|
2812
|
+
continue;
|
|
2813
|
+
}
|
|
2814
|
+
if (glob.startsWith("-", i + 1)) {
|
|
2815
|
+
rangeStart = c;
|
|
2816
|
+
i += 2;
|
|
2817
|
+
continue;
|
|
2818
|
+
}
|
|
2819
|
+
ranges.push(braceEscape(c));
|
|
2820
|
+
i++;
|
|
2821
|
+
}
|
|
2822
|
+
if (endPos < i) return [
|
|
2823
|
+
"",
|
|
2824
|
+
false,
|
|
2825
|
+
0,
|
|
2826
|
+
false
|
|
2827
|
+
];
|
|
2828
|
+
if (!ranges.length && !negs.length) return [
|
|
2829
|
+
"$.",
|
|
2830
|
+
false,
|
|
2831
|
+
glob.length - pos,
|
|
2832
|
+
true
|
|
2833
|
+
];
|
|
2834
|
+
if (negs.length === 0 && ranges.length === 1 && /^\\?.$/.test(ranges[0]) && !negate) {
|
|
2835
|
+
const r = ranges[0].length === 2 ? ranges[0].slice(-1) : ranges[0];
|
|
2836
|
+
return [
|
|
2837
|
+
regexpEscape(r),
|
|
2838
|
+
false,
|
|
2839
|
+
endPos - pos,
|
|
2840
|
+
false
|
|
2841
|
+
];
|
|
2842
|
+
}
|
|
2843
|
+
const sranges = "[" + (negate ? "^" : "") + rangesToString(ranges) + "]";
|
|
2844
|
+
const snegs = "[" + (negate ? "" : "^") + rangesToString(negs) + "]";
|
|
2845
|
+
return [
|
|
2846
|
+
ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs,
|
|
2847
|
+
uflag,
|
|
2848
|
+
endPos - pos,
|
|
2849
|
+
true
|
|
2850
|
+
];
|
|
2851
|
+
};
|
|
2852
|
+
//#endregion
|
|
2853
|
+
//#region ../../node_modules/minimatch/dist/esm/unescape.js
|
|
2854
|
+
/**
|
|
2855
|
+
* Un-escape a string that has been escaped with {@link escape}.
|
|
2856
|
+
*
|
|
2857
|
+
* If the {@link MinimatchOptions.windowsPathsNoEscape} option is used, then
|
|
2858
|
+
* square-bracket escapes are removed, but not backslash escapes.
|
|
2859
|
+
*
|
|
2860
|
+
* For example, it will turn the string `'[*]'` into `*`, but it will not
|
|
2861
|
+
* turn `'\\*'` into `'*'`, because `\` is a path separator in
|
|
2862
|
+
* `windowsPathsNoEscape` mode.
|
|
2863
|
+
*
|
|
2864
|
+
* When `windowsPathsNoEscape` is not set, then both square-bracket escapes and
|
|
2865
|
+
* backslash escapes are removed.
|
|
2866
|
+
*
|
|
2867
|
+
* Slashes (and backslashes in `windowsPathsNoEscape` mode) cannot be escaped
|
|
2868
|
+
* or unescaped.
|
|
2869
|
+
*
|
|
2870
|
+
* When `magicalBraces` is not set, escapes of braces (`{` and `}`) will not be
|
|
2871
|
+
* unescaped.
|
|
2872
|
+
*/
|
|
2873
|
+
const unescape = (s, { windowsPathsNoEscape = false, magicalBraces = true } = {}) => {
|
|
2874
|
+
if (magicalBraces) return windowsPathsNoEscape ? s.replace(/\[([^/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\])\]/g, "$1$2").replace(/\\([^/])/g, "$1");
|
|
2875
|
+
return windowsPathsNoEscape ? s.replace(/\[([^/\\{}])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\{}])\]/g, "$1$2").replace(/\\([^/{}])/g, "$1");
|
|
2876
|
+
};
|
|
2877
|
+
//#endregion
|
|
2878
|
+
//#region ../../node_modules/minimatch/dist/esm/ast.js
|
|
2879
|
+
var _a;
|
|
2880
|
+
const types = /* @__PURE__ */ new Set([
|
|
2881
|
+
"!",
|
|
2882
|
+
"?",
|
|
2883
|
+
"+",
|
|
2884
|
+
"*",
|
|
2885
|
+
"@"
|
|
2886
|
+
]);
|
|
2887
|
+
const isExtglobType = (c) => types.has(c);
|
|
2888
|
+
const isExtglobAST = (c) => isExtglobType(c.type);
|
|
2889
|
+
const adoptionMap = /* @__PURE__ */ new Map([
|
|
2890
|
+
["!", ["@"]],
|
|
2891
|
+
["?", ["?", "@"]],
|
|
2892
|
+
["@", ["@"]],
|
|
2893
|
+
["*", [
|
|
2894
|
+
"*",
|
|
2895
|
+
"+",
|
|
2896
|
+
"?",
|
|
2897
|
+
"@"
|
|
2898
|
+
]],
|
|
2899
|
+
["+", ["+", "@"]]
|
|
2900
|
+
]);
|
|
2901
|
+
const adoptionWithSpaceMap = /* @__PURE__ */ new Map([
|
|
2902
|
+
["!", ["?"]],
|
|
2903
|
+
["@", ["?"]],
|
|
2904
|
+
["+", ["?", "*"]]
|
|
2905
|
+
]);
|
|
2906
|
+
const adoptionAnyMap = /* @__PURE__ */ new Map([
|
|
2907
|
+
["!", ["?", "@"]],
|
|
2908
|
+
["?", ["?", "@"]],
|
|
2909
|
+
["@", ["?", "@"]],
|
|
2910
|
+
["*", [
|
|
2911
|
+
"*",
|
|
2912
|
+
"+",
|
|
2913
|
+
"?",
|
|
2914
|
+
"@"
|
|
2915
|
+
]],
|
|
2916
|
+
["+", [
|
|
2917
|
+
"+",
|
|
2918
|
+
"@",
|
|
2919
|
+
"?",
|
|
2920
|
+
"*"
|
|
2921
|
+
]]
|
|
2922
|
+
]);
|
|
2923
|
+
const usurpMap = /* @__PURE__ */ new Map([
|
|
2924
|
+
["!", /* @__PURE__ */ new Map([["!", "@"]])],
|
|
2925
|
+
["?", /* @__PURE__ */ new Map([["*", "*"], ["+", "*"]])],
|
|
2926
|
+
["@", /* @__PURE__ */ new Map([
|
|
2927
|
+
["!", "!"],
|
|
2928
|
+
["?", "?"],
|
|
2929
|
+
["@", "@"],
|
|
2930
|
+
["*", "*"],
|
|
2931
|
+
["+", "+"]
|
|
2932
|
+
])],
|
|
2933
|
+
["+", /* @__PURE__ */ new Map([["?", "*"], ["*", "*"]])]
|
|
2934
|
+
]);
|
|
2935
|
+
const startNoTraversal = "(?!(?:^|/)\\.\\.?(?:$|/))";
|
|
2936
|
+
const startNoDot = "(?!\\.)";
|
|
2937
|
+
const addPatternStart = /* @__PURE__ */ new Set(["[", "."]);
|
|
2938
|
+
const justDots = /* @__PURE__ */ new Set(["..", "."]);
|
|
2939
|
+
const reSpecials = /* @__PURE__ */ new Set("().*{}+?[]^$\\!");
|
|
2940
|
+
const regExpEscape$1 = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
2941
|
+
const qmark = "[^/]";
|
|
2942
|
+
const star$1 = "[^/]*?";
|
|
2943
|
+
const starNoEmpty = "[^/]+?";
|
|
2944
|
+
let ID = 0;
|
|
2945
|
+
var AST = class {
|
|
2946
|
+
type;
|
|
2947
|
+
#root;
|
|
2948
|
+
#hasMagic;
|
|
2949
|
+
#uflag = false;
|
|
2950
|
+
#parts = [];
|
|
2951
|
+
#parent;
|
|
2952
|
+
#parentIndex;
|
|
2953
|
+
#negs;
|
|
2954
|
+
#filledNegs = false;
|
|
2955
|
+
#options;
|
|
2956
|
+
#toString;
|
|
2957
|
+
#emptyExt = false;
|
|
2958
|
+
id = ++ID;
|
|
2959
|
+
get depth() {
|
|
2960
|
+
return (this.#parent?.depth ?? -1) + 1;
|
|
2961
|
+
}
|
|
2962
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
2963
|
+
return {
|
|
2964
|
+
"@@type": "AST",
|
|
2965
|
+
id: this.id,
|
|
2966
|
+
type: this.type,
|
|
2967
|
+
root: this.#root.id,
|
|
2968
|
+
parent: this.#parent?.id,
|
|
2969
|
+
depth: this.depth,
|
|
2970
|
+
partsLength: this.#parts.length,
|
|
2971
|
+
parts: this.#parts
|
|
2972
|
+
};
|
|
2973
|
+
}
|
|
2974
|
+
constructor(type, parent, options = {}) {
|
|
2975
|
+
this.type = type;
|
|
2976
|
+
if (type) this.#hasMagic = true;
|
|
2977
|
+
this.#parent = parent;
|
|
2978
|
+
this.#root = this.#parent ? this.#parent.#root : this;
|
|
2979
|
+
this.#options = this.#root === this ? options : this.#root.#options;
|
|
2980
|
+
this.#negs = this.#root === this ? [] : this.#root.#negs;
|
|
2981
|
+
if (type === "!" && !this.#root.#filledNegs) this.#negs.push(this);
|
|
2982
|
+
this.#parentIndex = this.#parent ? this.#parent.#parts.length : 0;
|
|
2983
|
+
}
|
|
2984
|
+
get hasMagic() {
|
|
2985
|
+
/* c8 ignore start */
|
|
2986
|
+
if (this.#hasMagic !== void 0) return this.#hasMagic;
|
|
2987
|
+
/* c8 ignore stop */
|
|
2988
|
+
for (const p of this.#parts) {
|
|
2989
|
+
if (typeof p === "string") continue;
|
|
2990
|
+
if (p.type || p.hasMagic) return this.#hasMagic = true;
|
|
2991
|
+
}
|
|
2992
|
+
return this.#hasMagic;
|
|
2993
|
+
}
|
|
2994
|
+
toString() {
|
|
2995
|
+
return this.#toString !== void 0 ? this.#toString : !this.type ? this.#toString = this.#parts.map((p) => String(p)).join("") : this.#toString = this.type + "(" + this.#parts.map((p) => String(p)).join("|") + ")";
|
|
2996
|
+
}
|
|
2997
|
+
#fillNegs() {
|
|
2998
|
+
/* c8 ignore start */
|
|
2999
|
+
if (this !== this.#root) throw new Error("should only call on root");
|
|
3000
|
+
if (this.#filledNegs) return this;
|
|
3001
|
+
/* c8 ignore stop */
|
|
3002
|
+
this.toString();
|
|
3003
|
+
this.#filledNegs = true;
|
|
3004
|
+
let n;
|
|
3005
|
+
while (n = this.#negs.pop()) {
|
|
3006
|
+
if (n.type !== "!") continue;
|
|
3007
|
+
let p = n;
|
|
3008
|
+
let pp = p.#parent;
|
|
3009
|
+
while (pp) {
|
|
3010
|
+
for (let i = p.#parentIndex + 1; !pp.type && i < pp.#parts.length; i++) for (const part of n.#parts) {
|
|
3011
|
+
/* c8 ignore start */
|
|
3012
|
+
if (typeof part === "string") throw new Error("string part in extglob AST??");
|
|
3013
|
+
/* c8 ignore stop */
|
|
3014
|
+
part.copyIn(pp.#parts[i]);
|
|
3015
|
+
}
|
|
3016
|
+
p = pp;
|
|
3017
|
+
pp = p.#parent;
|
|
3018
|
+
}
|
|
3019
|
+
}
|
|
3020
|
+
return this;
|
|
3021
|
+
}
|
|
3022
|
+
push(...parts) {
|
|
3023
|
+
for (const p of parts) {
|
|
3024
|
+
if (p === "") continue;
|
|
3025
|
+
/* c8 ignore start */
|
|
3026
|
+
if (typeof p !== "string" && !(p instanceof _a && p.#parent === this)) throw new Error("invalid part: " + p);
|
|
3027
|
+
/* c8 ignore stop */
|
|
3028
|
+
this.#parts.push(p);
|
|
3029
|
+
}
|
|
3030
|
+
}
|
|
3031
|
+
toJSON() {
|
|
3032
|
+
const ret = this.type === null ? this.#parts.slice().map((p) => typeof p === "string" ? p : p.toJSON()) : [this.type, ...this.#parts.map((p) => p.toJSON())];
|
|
3033
|
+
if (this.isStart() && !this.type) ret.unshift([]);
|
|
3034
|
+
if (this.isEnd() && (this === this.#root || this.#root.#filledNegs && this.#parent?.type === "!")) ret.push({});
|
|
3035
|
+
return ret;
|
|
3036
|
+
}
|
|
3037
|
+
isStart() {
|
|
3038
|
+
if (this.#root === this) return true;
|
|
3039
|
+
if (!this.#parent?.isStart()) return false;
|
|
3040
|
+
if (this.#parentIndex === 0) return true;
|
|
3041
|
+
const p = this.#parent;
|
|
3042
|
+
for (let i = 0; i < this.#parentIndex; i++) {
|
|
3043
|
+
const pp = p.#parts[i];
|
|
3044
|
+
if (!(pp instanceof _a && pp.type === "!")) return false;
|
|
3045
|
+
}
|
|
3046
|
+
return true;
|
|
3047
|
+
}
|
|
3048
|
+
isEnd() {
|
|
3049
|
+
if (this.#root === this) return true;
|
|
3050
|
+
if (this.#parent?.type === "!") return true;
|
|
3051
|
+
if (!this.#parent?.isEnd()) return false;
|
|
3052
|
+
if (!this.type) return this.#parent?.isEnd();
|
|
3053
|
+
/* c8 ignore start */
|
|
3054
|
+
const pl = this.#parent ? this.#parent.#parts.length : 0;
|
|
3055
|
+
/* c8 ignore stop */
|
|
3056
|
+
return this.#parentIndex === pl - 1;
|
|
3057
|
+
}
|
|
3058
|
+
copyIn(part) {
|
|
3059
|
+
if (typeof part === "string") this.push(part);
|
|
3060
|
+
else this.push(part.clone(this));
|
|
3061
|
+
}
|
|
3062
|
+
clone(parent) {
|
|
3063
|
+
const c = new _a(this.type, parent);
|
|
3064
|
+
for (const p of this.#parts) c.copyIn(p);
|
|
3065
|
+
return c;
|
|
3066
|
+
}
|
|
3067
|
+
static #parseAST(str, ast, pos, opt, extDepth) {
|
|
3068
|
+
const maxDepth = opt.maxExtglobRecursion ?? 2;
|
|
3069
|
+
let escaping = false;
|
|
3070
|
+
let inBrace = false;
|
|
3071
|
+
let braceStart = -1;
|
|
3072
|
+
let braceNeg = false;
|
|
3073
|
+
if (ast.type === null) {
|
|
3074
|
+
let i = pos;
|
|
3075
|
+
let acc = "";
|
|
3076
|
+
while (i < str.length) {
|
|
3077
|
+
const c = str.charAt(i++);
|
|
3078
|
+
if (escaping || c === "\\") {
|
|
3079
|
+
escaping = !escaping;
|
|
3080
|
+
acc += c;
|
|
3081
|
+
continue;
|
|
3082
|
+
}
|
|
3083
|
+
if (inBrace) {
|
|
3084
|
+
if (i === braceStart + 1) {
|
|
3085
|
+
if (c === "^" || c === "!") braceNeg = true;
|
|
3086
|
+
} else if (c === "]" && !(i === braceStart + 2 && braceNeg)) inBrace = false;
|
|
3087
|
+
acc += c;
|
|
3088
|
+
continue;
|
|
3089
|
+
} else if (c === "[") {
|
|
3090
|
+
inBrace = true;
|
|
3091
|
+
braceStart = i;
|
|
3092
|
+
braceNeg = false;
|
|
3093
|
+
acc += c;
|
|
3094
|
+
continue;
|
|
3095
|
+
}
|
|
3096
|
+
if (!opt.noext && isExtglobType(c) && str.charAt(i) === "(" && extDepth <= maxDepth) {
|
|
3097
|
+
ast.push(acc);
|
|
3098
|
+
acc = "";
|
|
3099
|
+
const ext = new _a(c, ast);
|
|
3100
|
+
i = _a.#parseAST(str, ext, i, opt, extDepth + 1);
|
|
3101
|
+
ast.push(ext);
|
|
3102
|
+
continue;
|
|
3103
|
+
}
|
|
3104
|
+
acc += c;
|
|
3105
|
+
}
|
|
3106
|
+
ast.push(acc);
|
|
3107
|
+
return i;
|
|
3108
|
+
}
|
|
3109
|
+
let i = pos + 1;
|
|
3110
|
+
let part = new _a(null, ast);
|
|
3111
|
+
const parts = [];
|
|
3112
|
+
let acc = "";
|
|
3113
|
+
while (i < str.length) {
|
|
3114
|
+
const c = str.charAt(i++);
|
|
3115
|
+
if (escaping || c === "\\") {
|
|
3116
|
+
escaping = !escaping;
|
|
3117
|
+
acc += c;
|
|
3118
|
+
continue;
|
|
3119
|
+
}
|
|
3120
|
+
if (inBrace) {
|
|
3121
|
+
if (i === braceStart + 1) {
|
|
3122
|
+
if (c === "^" || c === "!") braceNeg = true;
|
|
3123
|
+
} else if (c === "]" && !(i === braceStart + 2 && braceNeg)) inBrace = false;
|
|
3124
|
+
acc += c;
|
|
3125
|
+
continue;
|
|
3126
|
+
} else if (c === "[") {
|
|
3127
|
+
inBrace = true;
|
|
3128
|
+
braceStart = i;
|
|
3129
|
+
braceNeg = false;
|
|
3130
|
+
acc += c;
|
|
3131
|
+
continue;
|
|
3132
|
+
}
|
|
3133
|
+
/* c8 ignore stop */
|
|
3134
|
+
if (!opt.noext && isExtglobType(c) && str.charAt(i) === "(" && (extDepth <= maxDepth || ast && ast.#canAdoptType(c))) {
|
|
3135
|
+
const depthAdd = ast && ast.#canAdoptType(c) ? 0 : 1;
|
|
3136
|
+
part.push(acc);
|
|
3137
|
+
acc = "";
|
|
3138
|
+
const ext = new _a(c, part);
|
|
3139
|
+
part.push(ext);
|
|
3140
|
+
i = _a.#parseAST(str, ext, i, opt, extDepth + depthAdd);
|
|
3141
|
+
continue;
|
|
3142
|
+
}
|
|
3143
|
+
if (c === "|") {
|
|
3144
|
+
part.push(acc);
|
|
3145
|
+
acc = "";
|
|
3146
|
+
parts.push(part);
|
|
3147
|
+
part = new _a(null, ast);
|
|
3148
|
+
continue;
|
|
3149
|
+
}
|
|
3150
|
+
if (c === ")") {
|
|
3151
|
+
if (acc === "" && ast.#parts.length === 0) ast.#emptyExt = true;
|
|
3152
|
+
part.push(acc);
|
|
3153
|
+
acc = "";
|
|
3154
|
+
ast.push(...parts, part);
|
|
3155
|
+
return i;
|
|
3156
|
+
}
|
|
3157
|
+
acc += c;
|
|
3158
|
+
}
|
|
3159
|
+
ast.type = null;
|
|
3160
|
+
ast.#hasMagic = void 0;
|
|
3161
|
+
ast.#parts = [str.substring(pos - 1)];
|
|
3162
|
+
return i;
|
|
3163
|
+
}
|
|
3164
|
+
#canAdoptWithSpace(child) {
|
|
3165
|
+
return this.#canAdopt(child, adoptionWithSpaceMap);
|
|
3166
|
+
}
|
|
3167
|
+
#canAdopt(child, map = adoptionMap) {
|
|
3168
|
+
if (!child || typeof child !== "object" || child.type !== null || child.#parts.length !== 1 || this.type === null) return false;
|
|
3169
|
+
const gc = child.#parts[0];
|
|
3170
|
+
if (!gc || typeof gc !== "object" || gc.type === null) return false;
|
|
3171
|
+
return this.#canAdoptType(gc.type, map);
|
|
3172
|
+
}
|
|
3173
|
+
#canAdoptType(c, map = adoptionAnyMap) {
|
|
3174
|
+
return !!map.get(this.type)?.includes(c);
|
|
3175
|
+
}
|
|
3176
|
+
#adoptWithSpace(child, index) {
|
|
3177
|
+
const gc = child.#parts[0];
|
|
3178
|
+
const blank = new _a(null, gc, this.options);
|
|
3179
|
+
blank.#parts.push("");
|
|
3180
|
+
gc.push(blank);
|
|
3181
|
+
this.#adopt(child, index);
|
|
3182
|
+
}
|
|
3183
|
+
#adopt(child, index) {
|
|
3184
|
+
const gc = child.#parts[0];
|
|
3185
|
+
this.#parts.splice(index, 1, ...gc.#parts);
|
|
3186
|
+
for (const p of gc.#parts) if (typeof p === "object") p.#parent = this;
|
|
3187
|
+
this.#toString = void 0;
|
|
3188
|
+
}
|
|
3189
|
+
#canUsurpType(c) {
|
|
3190
|
+
return !!usurpMap.get(this.type)?.has(c);
|
|
3191
|
+
}
|
|
3192
|
+
#canUsurp(child) {
|
|
3193
|
+
if (!child || typeof child !== "object" || child.type !== null || child.#parts.length !== 1 || this.type === null || this.#parts.length !== 1) return false;
|
|
3194
|
+
const gc = child.#parts[0];
|
|
3195
|
+
if (!gc || typeof gc !== "object" || gc.type === null) return false;
|
|
3196
|
+
return this.#canUsurpType(gc.type);
|
|
3197
|
+
}
|
|
3198
|
+
#usurp(child) {
|
|
3199
|
+
const m = usurpMap.get(this.type);
|
|
3200
|
+
const gc = child.#parts[0];
|
|
3201
|
+
const nt = m?.get(gc.type);
|
|
3202
|
+
/* c8 ignore start - impossible */
|
|
3203
|
+
if (!nt) return false;
|
|
3204
|
+
/* c8 ignore stop */
|
|
3205
|
+
this.#parts = gc.#parts;
|
|
3206
|
+
for (const p of this.#parts) if (typeof p === "object") p.#parent = this;
|
|
3207
|
+
this.type = nt;
|
|
3208
|
+
this.#toString = void 0;
|
|
3209
|
+
this.#emptyExt = false;
|
|
3210
|
+
}
|
|
3211
|
+
static fromGlob(pattern, options = {}) {
|
|
3212
|
+
const ast = new _a(null, void 0, options);
|
|
3213
|
+
_a.#parseAST(pattern, ast, 0, options, 0);
|
|
3214
|
+
return ast;
|
|
3215
|
+
}
|
|
3216
|
+
toMMPattern() {
|
|
3217
|
+
/* c8 ignore start */
|
|
3218
|
+
if (this !== this.#root) return this.#root.toMMPattern();
|
|
3219
|
+
/* c8 ignore stop */
|
|
3220
|
+
const glob = this.toString();
|
|
3221
|
+
const [re, body, hasMagic, uflag] = this.toRegExpSource();
|
|
3222
|
+
if (!(hasMagic || this.#hasMagic || this.#options.nocase && !this.#options.nocaseMagicOnly && glob.toUpperCase() !== glob.toLowerCase())) return body;
|
|
3223
|
+
const flags = (this.#options.nocase ? "i" : "") + (uflag ? "u" : "");
|
|
3224
|
+
return Object.assign(new RegExp(`^${re}$`, flags), {
|
|
3225
|
+
_src: re,
|
|
3226
|
+
_glob: glob
|
|
3227
|
+
});
|
|
3228
|
+
}
|
|
3229
|
+
get options() {
|
|
3230
|
+
return this.#options;
|
|
3231
|
+
}
|
|
3232
|
+
toRegExpSource(allowDot) {
|
|
3233
|
+
const dot = allowDot ?? !!this.#options.dot;
|
|
3234
|
+
if (this.#root === this) {
|
|
3235
|
+
this.#flatten();
|
|
3236
|
+
this.#fillNegs();
|
|
3237
|
+
}
|
|
3238
|
+
if (!isExtglobAST(this)) {
|
|
3239
|
+
const noEmpty = this.isStart() && this.isEnd() && !this.#parts.some((s) => typeof s !== "string");
|
|
3240
|
+
const src = this.#parts.map((p) => {
|
|
3241
|
+
const [re, _, hasMagic, uflag] = typeof p === "string" ? _a.#parseGlob(p, this.#hasMagic, noEmpty) : p.toRegExpSource(allowDot);
|
|
3242
|
+
this.#hasMagic = this.#hasMagic || hasMagic;
|
|
3243
|
+
this.#uflag = this.#uflag || uflag;
|
|
3244
|
+
return re;
|
|
3245
|
+
}).join("");
|
|
3246
|
+
let start = "";
|
|
3247
|
+
if (this.isStart()) {
|
|
3248
|
+
if (typeof this.#parts[0] === "string") {
|
|
3249
|
+
if (!(this.#parts.length === 1 && justDots.has(this.#parts[0]))) {
|
|
3250
|
+
const aps = addPatternStart;
|
|
3251
|
+
const needNoTrav = dot && aps.has(src.charAt(0)) || src.startsWith("\\.") && aps.has(src.charAt(2)) || src.startsWith("\\.\\.") && aps.has(src.charAt(4));
|
|
3252
|
+
const needNoDot = !dot && !allowDot && aps.has(src.charAt(0));
|
|
3253
|
+
start = needNoTrav ? startNoTraversal : needNoDot ? startNoDot : "";
|
|
3254
|
+
}
|
|
3255
|
+
}
|
|
3256
|
+
}
|
|
3257
|
+
let end = "";
|
|
3258
|
+
if (this.isEnd() && this.#root.#filledNegs && this.#parent?.type === "!") end = "(?:$|\\/)";
|
|
3259
|
+
return [
|
|
3260
|
+
start + src + end,
|
|
3261
|
+
unescape(src),
|
|
3262
|
+
this.#hasMagic = !!this.#hasMagic,
|
|
3263
|
+
this.#uflag
|
|
3264
|
+
];
|
|
3265
|
+
}
|
|
3266
|
+
const repeated = this.type === "*" || this.type === "+";
|
|
3267
|
+
const start = this.type === "!" ? "(?:(?!(?:" : "(?:";
|
|
3268
|
+
let body = this.#partsToRegExp(dot);
|
|
3269
|
+
if (this.isStart() && this.isEnd() && !body && this.type !== "!") {
|
|
3270
|
+
const s = this.toString();
|
|
3271
|
+
const me = this;
|
|
3272
|
+
me.#parts = [s];
|
|
3273
|
+
me.type = null;
|
|
3274
|
+
me.#hasMagic = void 0;
|
|
3275
|
+
return [
|
|
3276
|
+
s,
|
|
3277
|
+
unescape(this.toString()),
|
|
3278
|
+
false,
|
|
3279
|
+
false
|
|
3280
|
+
];
|
|
3281
|
+
}
|
|
3282
|
+
let bodyDotAllowed = !repeated || allowDot || dot || false ? "" : this.#partsToRegExp(true);
|
|
3283
|
+
if (bodyDotAllowed === body) bodyDotAllowed = "";
|
|
3284
|
+
if (bodyDotAllowed) body = `(?:${body})(?:${bodyDotAllowed})*?`;
|
|
3285
|
+
let final = "";
|
|
3286
|
+
if (this.type === "!" && this.#emptyExt) final = (this.isStart() && !dot ? startNoDot : "") + starNoEmpty;
|
|
3287
|
+
else {
|
|
3288
|
+
const close = this.type === "!" ? "))" + (this.isStart() && !dot && !allowDot ? startNoDot : "") + "[^/]*?)" : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && bodyDotAllowed ? ")" : this.type === "*" && bodyDotAllowed ? `)?` : `)${this.type}`;
|
|
3289
|
+
final = start + body + close;
|
|
3290
|
+
}
|
|
3291
|
+
return [
|
|
3292
|
+
final,
|
|
3293
|
+
unescape(body),
|
|
3294
|
+
this.#hasMagic = !!this.#hasMagic,
|
|
3295
|
+
this.#uflag
|
|
3296
|
+
];
|
|
3297
|
+
}
|
|
3298
|
+
#flatten() {
|
|
3299
|
+
if (!isExtglobAST(this)) {
|
|
3300
|
+
for (const p of this.#parts) if (typeof p === "object") p.#flatten();
|
|
3301
|
+
} else {
|
|
3302
|
+
let iterations = 0;
|
|
3303
|
+
let done = false;
|
|
3304
|
+
do {
|
|
3305
|
+
done = true;
|
|
3306
|
+
for (let i = 0; i < this.#parts.length; i++) {
|
|
3307
|
+
const c = this.#parts[i];
|
|
3308
|
+
if (typeof c === "object") {
|
|
3309
|
+
c.#flatten();
|
|
3310
|
+
if (this.#canAdopt(c)) {
|
|
3311
|
+
done = false;
|
|
3312
|
+
this.#adopt(c, i);
|
|
3313
|
+
} else if (this.#canAdoptWithSpace(c)) {
|
|
3314
|
+
done = false;
|
|
3315
|
+
this.#adoptWithSpace(c, i);
|
|
3316
|
+
} else if (this.#canUsurp(c)) {
|
|
3317
|
+
done = false;
|
|
3318
|
+
this.#usurp(c);
|
|
3319
|
+
}
|
|
3320
|
+
}
|
|
3321
|
+
}
|
|
3322
|
+
} while (!done && ++iterations < 10);
|
|
3323
|
+
}
|
|
3324
|
+
this.#toString = void 0;
|
|
3325
|
+
}
|
|
3326
|
+
#partsToRegExp(dot) {
|
|
3327
|
+
return this.#parts.map((p) => {
|
|
3328
|
+
/* c8 ignore start */
|
|
3329
|
+
if (typeof p === "string") throw new Error("string type in extglob ast??");
|
|
3330
|
+
/* c8 ignore stop */
|
|
3331
|
+
const [re, _, _hasMagic, uflag] = p.toRegExpSource(dot);
|
|
3332
|
+
this.#uflag = this.#uflag || uflag;
|
|
3333
|
+
return re;
|
|
3334
|
+
}).filter((p) => !(this.isStart() && this.isEnd()) || !!p).join("|");
|
|
3335
|
+
}
|
|
3336
|
+
static #parseGlob(glob, hasMagic, noEmpty = false) {
|
|
3337
|
+
let escaping = false;
|
|
3338
|
+
let re = "";
|
|
3339
|
+
let uflag = false;
|
|
3340
|
+
let inStar = false;
|
|
3341
|
+
for (let i = 0; i < glob.length; i++) {
|
|
3342
|
+
const c = glob.charAt(i);
|
|
3343
|
+
if (escaping) {
|
|
3344
|
+
escaping = false;
|
|
3345
|
+
re += (reSpecials.has(c) ? "\\" : "") + c;
|
|
3346
|
+
continue;
|
|
3347
|
+
}
|
|
3348
|
+
if (c === "*") {
|
|
3349
|
+
if (inStar) continue;
|
|
3350
|
+
inStar = true;
|
|
3351
|
+
re += noEmpty && /^[*]+$/.test(glob) ? starNoEmpty : star$1;
|
|
3352
|
+
hasMagic = true;
|
|
3353
|
+
continue;
|
|
3354
|
+
} else inStar = false;
|
|
3355
|
+
if (c === "\\") {
|
|
3356
|
+
if (i === glob.length - 1) re += "\\\\";
|
|
3357
|
+
else escaping = true;
|
|
3358
|
+
continue;
|
|
3359
|
+
}
|
|
3360
|
+
if (c === "[") {
|
|
3361
|
+
const [src, needUflag, consumed, magic] = parseClass(glob, i);
|
|
3362
|
+
if (consumed) {
|
|
3363
|
+
re += src;
|
|
3364
|
+
uflag = uflag || needUflag;
|
|
3365
|
+
i += consumed - 1;
|
|
3366
|
+
hasMagic = hasMagic || magic;
|
|
3367
|
+
continue;
|
|
3368
|
+
}
|
|
3369
|
+
}
|
|
3370
|
+
if (c === "?") {
|
|
3371
|
+
re += qmark;
|
|
3372
|
+
hasMagic = true;
|
|
3373
|
+
continue;
|
|
3374
|
+
}
|
|
3375
|
+
re += regExpEscape$1(c);
|
|
3376
|
+
}
|
|
3377
|
+
return [
|
|
3378
|
+
re,
|
|
3379
|
+
unescape(glob),
|
|
3380
|
+
!!hasMagic,
|
|
3381
|
+
uflag
|
|
3382
|
+
];
|
|
3383
|
+
}
|
|
3384
|
+
};
|
|
3385
|
+
_a = AST;
|
|
3386
|
+
//#endregion
|
|
3387
|
+
//#region ../../node_modules/minimatch/dist/esm/escape.js
|
|
3388
|
+
/**
|
|
3389
|
+
* Escape all magic characters in a glob pattern.
|
|
3390
|
+
*
|
|
3391
|
+
* If the {@link MinimatchOptions.windowsPathsNoEscape}
|
|
3392
|
+
* option is used, then characters are escaped by wrapping in `[]`, because
|
|
3393
|
+
* a magic character wrapped in a character class can only be satisfied by
|
|
3394
|
+
* that exact character. In this mode, `\` is _not_ escaped, because it is
|
|
3395
|
+
* not interpreted as a magic character, but instead as a path separator.
|
|
3396
|
+
*
|
|
3397
|
+
* If the {@link MinimatchOptions.magicalBraces} option is used,
|
|
3398
|
+
* then braces (`{` and `}`) will be escaped.
|
|
3399
|
+
*/
|
|
3400
|
+
const escape = (s, { windowsPathsNoEscape = false, magicalBraces = false } = {}) => {
|
|
3401
|
+
if (magicalBraces) return windowsPathsNoEscape ? s.replace(/[?*()[\]{}]/g, "[$&]") : s.replace(/[?*()[\]\\{}]/g, "\\$&");
|
|
3402
|
+
return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
|
|
3403
|
+
};
|
|
3404
|
+
//#endregion
|
|
3405
|
+
//#region ../../node_modules/minimatch/dist/esm/index.js
|
|
3406
|
+
const minimatch = (p, pattern, options = {}) => {
|
|
3407
|
+
assertValidPattern(pattern);
|
|
3408
|
+
if (!options.nocomment && pattern.charAt(0) === "#") return false;
|
|
3409
|
+
return new Minimatch(pattern, options).match(p);
|
|
3410
|
+
};
|
|
3411
|
+
const starDotExtRE = /^\*+([^+@!?*[(]*)$/;
|
|
3412
|
+
const starDotExtTest = (ext) => (f) => !f.startsWith(".") && f.endsWith(ext);
|
|
3413
|
+
const starDotExtTestDot = (ext) => (f) => f.endsWith(ext);
|
|
3414
|
+
const starDotExtTestNocase = (ext) => {
|
|
3415
|
+
ext = ext.toLowerCase();
|
|
3416
|
+
return (f) => !f.startsWith(".") && f.toLowerCase().endsWith(ext);
|
|
3417
|
+
};
|
|
3418
|
+
const starDotExtTestNocaseDot = (ext) => {
|
|
3419
|
+
ext = ext.toLowerCase();
|
|
3420
|
+
return (f) => f.toLowerCase().endsWith(ext);
|
|
3421
|
+
};
|
|
3422
|
+
const starDotStarRE = /^\*+\.\*+$/;
|
|
3423
|
+
const starDotStarTest = (f) => !f.startsWith(".") && f.includes(".");
|
|
3424
|
+
const starDotStarTestDot = (f) => f !== "." && f !== ".." && f.includes(".");
|
|
3425
|
+
const dotStarRE = /^\.\*+$/;
|
|
3426
|
+
const dotStarTest = (f) => f !== "." && f !== ".." && f.startsWith(".");
|
|
3427
|
+
const starRE = /^\*+$/;
|
|
3428
|
+
const starTest = (f) => f.length !== 0 && !f.startsWith(".");
|
|
3429
|
+
const starTestDot = (f) => f.length !== 0 && f !== "." && f !== "..";
|
|
3430
|
+
const qmarksRE = /^\?+([^+@!?*[(]*)?$/;
|
|
3431
|
+
const qmarksTestNocase = ([$0, ext = ""]) => {
|
|
3432
|
+
const noext = qmarksTestNoExt([$0]);
|
|
3433
|
+
if (!ext) return noext;
|
|
3434
|
+
ext = ext.toLowerCase();
|
|
3435
|
+
return (f) => noext(f) && f.toLowerCase().endsWith(ext);
|
|
3436
|
+
};
|
|
3437
|
+
const qmarksTestNocaseDot = ([$0, ext = ""]) => {
|
|
3438
|
+
const noext = qmarksTestNoExtDot([$0]);
|
|
3439
|
+
if (!ext) return noext;
|
|
3440
|
+
ext = ext.toLowerCase();
|
|
3441
|
+
return (f) => noext(f) && f.toLowerCase().endsWith(ext);
|
|
3442
|
+
};
|
|
3443
|
+
const qmarksTestDot = ([$0, ext = ""]) => {
|
|
3444
|
+
const noext = qmarksTestNoExtDot([$0]);
|
|
3445
|
+
return !ext ? noext : (f) => noext(f) && f.endsWith(ext);
|
|
3446
|
+
};
|
|
3447
|
+
const qmarksTest = ([$0, ext = ""]) => {
|
|
3448
|
+
const noext = qmarksTestNoExt([$0]);
|
|
3449
|
+
return !ext ? noext : (f) => noext(f) && f.endsWith(ext);
|
|
3450
|
+
};
|
|
3451
|
+
const qmarksTestNoExt = ([$0]) => {
|
|
3452
|
+
const len = $0.length;
|
|
3453
|
+
return (f) => f.length === len && !f.startsWith(".");
|
|
3454
|
+
};
|
|
3455
|
+
const qmarksTestNoExtDot = ([$0]) => {
|
|
3456
|
+
const len = $0.length;
|
|
3457
|
+
return (f) => f.length === len && f !== "." && f !== "..";
|
|
3458
|
+
};
|
|
3459
|
+
/* c8 ignore start */
|
|
3460
|
+
const defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
|
3461
|
+
const path = {
|
|
3462
|
+
win32: { sep: "\\" },
|
|
3463
|
+
posix: { sep: "/" }
|
|
3464
|
+
};
|
|
3465
|
+
minimatch.sep = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
|
|
3466
|
+
const GLOBSTAR = Symbol("globstar **");
|
|
3467
|
+
minimatch.GLOBSTAR = GLOBSTAR;
|
|
3468
|
+
const star = "[^/]*?";
|
|
3469
|
+
const twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
|
|
3470
|
+
const twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?";
|
|
3471
|
+
const filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options);
|
|
3472
|
+
minimatch.filter = filter;
|
|
3473
|
+
const ext = (a, b = {}) => Object.assign({}, a, b);
|
|
3474
|
+
const defaults = (def) => {
|
|
3475
|
+
if (!def || typeof def !== "object" || !Object.keys(def).length) return minimatch;
|
|
3476
|
+
const orig = minimatch;
|
|
3477
|
+
const m = (p, pattern, options = {}) => orig(p, pattern, ext(def, options));
|
|
3478
|
+
return Object.assign(m, {
|
|
3479
|
+
Minimatch: class Minimatch extends orig.Minimatch {
|
|
3480
|
+
constructor(pattern, options = {}) {
|
|
3481
|
+
super(pattern, ext(def, options));
|
|
3482
|
+
}
|
|
3483
|
+
static defaults(options) {
|
|
3484
|
+
return orig.defaults(ext(def, options)).Minimatch;
|
|
3485
|
+
}
|
|
3486
|
+
},
|
|
3487
|
+
AST: class AST extends orig.AST {
|
|
3488
|
+
/* c8 ignore start */
|
|
3489
|
+
constructor(type, parent, options = {}) {
|
|
3490
|
+
super(type, parent, ext(def, options));
|
|
3491
|
+
}
|
|
3492
|
+
/* c8 ignore stop */
|
|
3493
|
+
static fromGlob(pattern, options = {}) {
|
|
3494
|
+
return orig.AST.fromGlob(pattern, ext(def, options));
|
|
3495
|
+
}
|
|
3496
|
+
},
|
|
3497
|
+
unescape: (s, options = {}) => orig.unescape(s, ext(def, options)),
|
|
3498
|
+
escape: (s, options = {}) => orig.escape(s, ext(def, options)),
|
|
3499
|
+
filter: (pattern, options = {}) => orig.filter(pattern, ext(def, options)),
|
|
3500
|
+
defaults: (options) => orig.defaults(ext(def, options)),
|
|
3501
|
+
makeRe: (pattern, options = {}) => orig.makeRe(pattern, ext(def, options)),
|
|
3502
|
+
braceExpand: (pattern, options = {}) => orig.braceExpand(pattern, ext(def, options)),
|
|
3503
|
+
match: (list, pattern, options = {}) => orig.match(list, pattern, ext(def, options)),
|
|
3504
|
+
sep: orig.sep,
|
|
3505
|
+
GLOBSTAR
|
|
3506
|
+
});
|
|
3507
|
+
};
|
|
3508
|
+
minimatch.defaults = defaults;
|
|
3509
|
+
const braceExpand = (pattern, options = {}) => {
|
|
3510
|
+
assertValidPattern(pattern);
|
|
3511
|
+
if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) return [pattern];
|
|
3512
|
+
return expand(pattern, { max: options.braceExpandMax });
|
|
3513
|
+
};
|
|
3514
|
+
minimatch.braceExpand = braceExpand;
|
|
3515
|
+
const makeRe = (pattern, options = {}) => new Minimatch(pattern, options).makeRe();
|
|
3516
|
+
minimatch.makeRe = makeRe;
|
|
3517
|
+
const match = (list, pattern, options = {}) => {
|
|
3518
|
+
const mm = new Minimatch(pattern, options);
|
|
3519
|
+
list = list.filter((f) => mm.match(f));
|
|
3520
|
+
if (mm.options.nonull && !list.length) list.push(pattern);
|
|
3521
|
+
return list;
|
|
3522
|
+
};
|
|
3523
|
+
minimatch.match = match;
|
|
3524
|
+
const globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
|
|
3525
|
+
const regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
3526
|
+
var Minimatch = class {
|
|
3527
|
+
options;
|
|
3528
|
+
set;
|
|
3529
|
+
pattern;
|
|
3530
|
+
windowsPathsNoEscape;
|
|
3531
|
+
nonegate;
|
|
3532
|
+
negate;
|
|
3533
|
+
comment;
|
|
3534
|
+
empty;
|
|
3535
|
+
preserveMultipleSlashes;
|
|
3536
|
+
partial;
|
|
3537
|
+
globSet;
|
|
3538
|
+
globParts;
|
|
3539
|
+
nocase;
|
|
3540
|
+
isWindows;
|
|
3541
|
+
platform;
|
|
3542
|
+
windowsNoMagicRoot;
|
|
3543
|
+
maxGlobstarRecursion;
|
|
3544
|
+
regexp;
|
|
3545
|
+
constructor(pattern, options = {}) {
|
|
3546
|
+
assertValidPattern(pattern);
|
|
3547
|
+
options = options || {};
|
|
3548
|
+
this.options = options;
|
|
3549
|
+
this.maxGlobstarRecursion = options.maxGlobstarRecursion ?? 200;
|
|
3550
|
+
this.pattern = pattern;
|
|
3551
|
+
this.platform = options.platform || defaultPlatform;
|
|
3552
|
+
this.isWindows = this.platform === "win32";
|
|
3553
|
+
const awe = "allowWindowsEscape";
|
|
3554
|
+
this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options[awe] === false;
|
|
3555
|
+
if (this.windowsPathsNoEscape) this.pattern = this.pattern.replace(/\\/g, "/");
|
|
3556
|
+
this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
|
|
3557
|
+
this.regexp = null;
|
|
3558
|
+
this.negate = false;
|
|
3559
|
+
this.nonegate = !!options.nonegate;
|
|
3560
|
+
this.comment = false;
|
|
3561
|
+
this.empty = false;
|
|
3562
|
+
this.partial = !!options.partial;
|
|
3563
|
+
this.nocase = !!this.options.nocase;
|
|
3564
|
+
this.windowsNoMagicRoot = options.windowsNoMagicRoot !== void 0 ? options.windowsNoMagicRoot : !!(this.isWindows && this.nocase);
|
|
3565
|
+
this.globSet = [];
|
|
3566
|
+
this.globParts = [];
|
|
3567
|
+
this.set = [];
|
|
3568
|
+
this.make();
|
|
3569
|
+
}
|
|
3570
|
+
hasMagic() {
|
|
3571
|
+
if (this.options.magicalBraces && this.set.length > 1) return true;
|
|
3572
|
+
for (const pattern of this.set) for (const part of pattern) if (typeof part !== "string") return true;
|
|
3573
|
+
return false;
|
|
3574
|
+
}
|
|
3575
|
+
debug(..._) {}
|
|
3576
|
+
make() {
|
|
3577
|
+
const pattern = this.pattern;
|
|
3578
|
+
const options = this.options;
|
|
3579
|
+
if (!options.nocomment && pattern.charAt(0) === "#") {
|
|
3580
|
+
this.comment = true;
|
|
3581
|
+
return;
|
|
3582
|
+
}
|
|
3583
|
+
if (!pattern) {
|
|
3584
|
+
this.empty = true;
|
|
3585
|
+
return;
|
|
3586
|
+
}
|
|
3587
|
+
this.parseNegate();
|
|
3588
|
+
this.globSet = [...new Set(this.braceExpand())];
|
|
3589
|
+
if (options.debug) this.debug = (...args) => console.error(...args);
|
|
3590
|
+
this.debug(this.pattern, this.globSet);
|
|
3591
|
+
const rawGlobParts = this.globSet.map((s) => this.slashSplit(s));
|
|
3592
|
+
this.globParts = this.preprocess(rawGlobParts);
|
|
3593
|
+
this.debug(this.pattern, this.globParts);
|
|
3594
|
+
let set = this.globParts.map((s, _, __) => {
|
|
3595
|
+
if (this.isWindows && this.windowsNoMagicRoot) {
|
|
3596
|
+
const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && !globMagic.test(s[3]);
|
|
3597
|
+
const isDrive = /^[a-z]:/i.test(s[0]);
|
|
3598
|
+
if (isUNC) return [...s.slice(0, 4), ...s.slice(4).map((ss) => this.parse(ss))];
|
|
3599
|
+
else if (isDrive) return [s[0], ...s.slice(1).map((ss) => this.parse(ss))];
|
|
3600
|
+
}
|
|
3601
|
+
return s.map((ss) => this.parse(ss));
|
|
3602
|
+
});
|
|
3603
|
+
this.debug(this.pattern, set);
|
|
3604
|
+
this.set = set.filter((s) => s.indexOf(false) === -1);
|
|
3605
|
+
if (this.isWindows) for (let i = 0; i < this.set.length; i++) {
|
|
3606
|
+
const p = this.set[i];
|
|
3607
|
+
if (p[0] === "" && p[1] === "" && this.globParts[i][2] === "?" && typeof p[3] === "string" && /^[a-z]:$/i.test(p[3])) p[2] = "?";
|
|
3608
|
+
}
|
|
3609
|
+
this.debug(this.pattern, this.set);
|
|
3610
|
+
}
|
|
3611
|
+
preprocess(globParts) {
|
|
3612
|
+
if (this.options.noglobstar) {
|
|
3613
|
+
for (const partset of globParts) for (let j = 0; j < partset.length; j++) if (partset[j] === "**") partset[j] = "*";
|
|
3614
|
+
}
|
|
3615
|
+
const { optimizationLevel = 1 } = this.options;
|
|
3616
|
+
if (optimizationLevel >= 2) {
|
|
3617
|
+
globParts = this.firstPhasePreProcess(globParts);
|
|
3618
|
+
globParts = this.secondPhasePreProcess(globParts);
|
|
3619
|
+
} else if (optimizationLevel >= 1) globParts = this.levelOneOptimize(globParts);
|
|
3620
|
+
else globParts = this.adjascentGlobstarOptimize(globParts);
|
|
3621
|
+
return globParts;
|
|
3622
|
+
}
|
|
3623
|
+
adjascentGlobstarOptimize(globParts) {
|
|
3624
|
+
return globParts.map((parts) => {
|
|
3625
|
+
let gs = -1;
|
|
3626
|
+
while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
|
|
3627
|
+
let i = gs;
|
|
3628
|
+
while (parts[i + 1] === "**") i++;
|
|
3629
|
+
if (i !== gs) parts.splice(gs, i - gs);
|
|
3630
|
+
}
|
|
3631
|
+
return parts;
|
|
3632
|
+
});
|
|
3633
|
+
}
|
|
3634
|
+
levelOneOptimize(globParts) {
|
|
3635
|
+
return globParts.map((parts) => {
|
|
3636
|
+
parts = parts.reduce((set, part) => {
|
|
3637
|
+
const prev = set[set.length - 1];
|
|
3638
|
+
if (part === "**" && prev === "**") return set;
|
|
3639
|
+
if (part === "..") {
|
|
3640
|
+
if (prev && prev !== ".." && prev !== "." && prev !== "**") {
|
|
3641
|
+
set.pop();
|
|
3642
|
+
return set;
|
|
3643
|
+
}
|
|
3644
|
+
}
|
|
3645
|
+
set.push(part);
|
|
3646
|
+
return set;
|
|
3647
|
+
}, []);
|
|
3648
|
+
return parts.length === 0 ? [""] : parts;
|
|
3649
|
+
});
|
|
3650
|
+
}
|
|
3651
|
+
levelTwoFileOptimize(parts) {
|
|
3652
|
+
if (!Array.isArray(parts)) parts = this.slashSplit(parts);
|
|
3653
|
+
let didSomething = false;
|
|
3654
|
+
do {
|
|
3655
|
+
didSomething = false;
|
|
3656
|
+
if (!this.preserveMultipleSlashes) {
|
|
3657
|
+
for (let i = 1; i < parts.length - 1; i++) {
|
|
3658
|
+
const p = parts[i];
|
|
3659
|
+
if (i === 1 && p === "" && parts[0] === "") continue;
|
|
3660
|
+
if (p === "." || p === "") {
|
|
3661
|
+
didSomething = true;
|
|
3662
|
+
parts.splice(i, 1);
|
|
3663
|
+
i--;
|
|
3664
|
+
}
|
|
3665
|
+
}
|
|
3666
|
+
if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
|
|
3667
|
+
didSomething = true;
|
|
3668
|
+
parts.pop();
|
|
3669
|
+
}
|
|
3670
|
+
}
|
|
3671
|
+
let dd = 0;
|
|
3672
|
+
while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
|
|
3673
|
+
const p = parts[dd - 1];
|
|
3674
|
+
if (p && p !== "." && p !== ".." && p !== "**" && !(this.isWindows && /^[a-z]:$/i.test(p))) {
|
|
3675
|
+
didSomething = true;
|
|
3676
|
+
parts.splice(dd - 1, 2);
|
|
3677
|
+
dd -= 2;
|
|
3678
|
+
}
|
|
3679
|
+
}
|
|
3680
|
+
} while (didSomething);
|
|
3681
|
+
return parts.length === 0 ? [""] : parts;
|
|
3682
|
+
}
|
|
3683
|
+
firstPhasePreProcess(globParts) {
|
|
3684
|
+
let didSomething = false;
|
|
3685
|
+
do {
|
|
3686
|
+
didSomething = false;
|
|
3687
|
+
for (let parts of globParts) {
|
|
3688
|
+
let gs = -1;
|
|
3689
|
+
while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
|
|
3690
|
+
let gss = gs;
|
|
3691
|
+
while (parts[gss + 1] === "**") gss++;
|
|
3692
|
+
if (gss > gs) parts.splice(gs + 1, gss - gs);
|
|
3693
|
+
let next = parts[gs + 1];
|
|
3694
|
+
const p = parts[gs + 2];
|
|
3695
|
+
const p2 = parts[gs + 3];
|
|
3696
|
+
if (next !== "..") continue;
|
|
3697
|
+
if (!p || p === "." || p === ".." || !p2 || p2 === "." || p2 === "..") continue;
|
|
3698
|
+
didSomething = true;
|
|
3699
|
+
parts.splice(gs, 1);
|
|
3700
|
+
const other = parts.slice(0);
|
|
3701
|
+
other[gs] = "**";
|
|
3702
|
+
globParts.push(other);
|
|
3703
|
+
gs--;
|
|
3704
|
+
}
|
|
3705
|
+
if (!this.preserveMultipleSlashes) {
|
|
3706
|
+
for (let i = 1; i < parts.length - 1; i++) {
|
|
3707
|
+
const p = parts[i];
|
|
3708
|
+
if (i === 1 && p === "" && parts[0] === "") continue;
|
|
3709
|
+
if (p === "." || p === "") {
|
|
3710
|
+
didSomething = true;
|
|
3711
|
+
parts.splice(i, 1);
|
|
3712
|
+
i--;
|
|
3713
|
+
}
|
|
3714
|
+
}
|
|
3715
|
+
if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
|
|
3716
|
+
didSomething = true;
|
|
3717
|
+
parts.pop();
|
|
3718
|
+
}
|
|
3719
|
+
}
|
|
3720
|
+
let dd = 0;
|
|
3721
|
+
while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
|
|
3722
|
+
const p = parts[dd - 1];
|
|
3723
|
+
if (p && p !== "." && p !== ".." && p !== "**") {
|
|
3724
|
+
didSomething = true;
|
|
3725
|
+
const splin = dd === 1 && parts[dd + 1] === "**" ? ["."] : [];
|
|
3726
|
+
parts.splice(dd - 1, 2, ...splin);
|
|
3727
|
+
if (parts.length === 0) parts.push("");
|
|
3728
|
+
dd -= 2;
|
|
3729
|
+
}
|
|
3730
|
+
}
|
|
3731
|
+
}
|
|
3732
|
+
} while (didSomething);
|
|
3733
|
+
return globParts;
|
|
3734
|
+
}
|
|
3735
|
+
secondPhasePreProcess(globParts) {
|
|
3736
|
+
for (let i = 0; i < globParts.length - 1; i++) for (let j = i + 1; j < globParts.length; j++) {
|
|
3737
|
+
const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
|
|
3738
|
+
if (matched) {
|
|
3739
|
+
globParts[i] = [];
|
|
3740
|
+
globParts[j] = matched;
|
|
3741
|
+
break;
|
|
3742
|
+
}
|
|
3743
|
+
}
|
|
3744
|
+
return globParts.filter((gs) => gs.length);
|
|
3745
|
+
}
|
|
3746
|
+
partsMatch(a, b, emptyGSMatch = false) {
|
|
3747
|
+
let ai = 0;
|
|
3748
|
+
let bi = 0;
|
|
3749
|
+
let result = [];
|
|
3750
|
+
let which = "";
|
|
3751
|
+
while (ai < a.length && bi < b.length) if (a[ai] === b[bi]) {
|
|
3752
|
+
result.push(which === "b" ? b[bi] : a[ai]);
|
|
3753
|
+
ai++;
|
|
3754
|
+
bi++;
|
|
3755
|
+
} else if (emptyGSMatch && a[ai] === "**" && b[bi] === a[ai + 1]) {
|
|
3756
|
+
result.push(a[ai]);
|
|
3757
|
+
ai++;
|
|
3758
|
+
} else if (emptyGSMatch && b[bi] === "**" && a[ai] === b[bi + 1]) {
|
|
3759
|
+
result.push(b[bi]);
|
|
3760
|
+
bi++;
|
|
3761
|
+
} else if (a[ai] === "*" && b[bi] && (this.options.dot || !b[bi].startsWith(".")) && b[bi] !== "**") {
|
|
3762
|
+
if (which === "b") return false;
|
|
3763
|
+
which = "a";
|
|
3764
|
+
result.push(a[ai]);
|
|
3765
|
+
ai++;
|
|
3766
|
+
bi++;
|
|
3767
|
+
} else if (b[bi] === "*" && a[ai] && (this.options.dot || !a[ai].startsWith(".")) && a[ai] !== "**") {
|
|
3768
|
+
if (which === "a") return false;
|
|
3769
|
+
which = "b";
|
|
3770
|
+
result.push(b[bi]);
|
|
3771
|
+
ai++;
|
|
3772
|
+
bi++;
|
|
3773
|
+
} else return false;
|
|
3774
|
+
return a.length === b.length && result;
|
|
3775
|
+
}
|
|
3776
|
+
parseNegate() {
|
|
3777
|
+
if (this.nonegate) return;
|
|
3778
|
+
const pattern = this.pattern;
|
|
3779
|
+
let negate = false;
|
|
3780
|
+
let negateOffset = 0;
|
|
3781
|
+
for (let i = 0; i < pattern.length && pattern.charAt(i) === "!"; i++) {
|
|
3782
|
+
negate = !negate;
|
|
3783
|
+
negateOffset++;
|
|
3784
|
+
}
|
|
3785
|
+
if (negateOffset) this.pattern = pattern.slice(negateOffset);
|
|
3786
|
+
this.negate = negate;
|
|
3787
|
+
}
|
|
3788
|
+
matchOne(file, pattern, partial = false) {
|
|
3789
|
+
let fileStartIndex = 0;
|
|
3790
|
+
let patternStartIndex = 0;
|
|
3791
|
+
if (this.isWindows) {
|
|
3792
|
+
const fileDrive = typeof file[0] === "string" && /^[a-z]:$/i.test(file[0]);
|
|
3793
|
+
const fileUNC = !fileDrive && file[0] === "" && file[1] === "" && file[2] === "?" && /^[a-z]:$/i.test(file[3]);
|
|
3794
|
+
const patternDrive = typeof pattern[0] === "string" && /^[a-z]:$/i.test(pattern[0]);
|
|
3795
|
+
const patternUNC = !patternDrive && pattern[0] === "" && pattern[1] === "" && pattern[2] === "?" && typeof pattern[3] === "string" && /^[a-z]:$/i.test(pattern[3]);
|
|
3796
|
+
const fdi = fileUNC ? 3 : fileDrive ? 0 : void 0;
|
|
3797
|
+
const pdi = patternUNC ? 3 : patternDrive ? 0 : void 0;
|
|
3798
|
+
if (typeof fdi === "number" && typeof pdi === "number") {
|
|
3799
|
+
const [fd, pd] = [file[fdi], pattern[pdi]];
|
|
3800
|
+
if (fd.toLowerCase() === pd.toLowerCase()) {
|
|
3801
|
+
pattern[pdi] = fd;
|
|
3802
|
+
patternStartIndex = pdi;
|
|
3803
|
+
fileStartIndex = fdi;
|
|
3804
|
+
}
|
|
3805
|
+
}
|
|
3806
|
+
}
|
|
3807
|
+
const { optimizationLevel = 1 } = this.options;
|
|
3808
|
+
if (optimizationLevel >= 2) file = this.levelTwoFileOptimize(file);
|
|
3809
|
+
if (pattern.includes(GLOBSTAR)) return this.#matchGlobstar(file, pattern, partial, fileStartIndex, patternStartIndex);
|
|
3810
|
+
return this.#matchOne(file, pattern, partial, fileStartIndex, patternStartIndex);
|
|
3811
|
+
}
|
|
3812
|
+
#matchGlobstar(file, pattern, partial, fileIndex, patternIndex) {
|
|
3813
|
+
const firstgs = pattern.indexOf(GLOBSTAR, patternIndex);
|
|
3814
|
+
const lastgs = pattern.lastIndexOf(GLOBSTAR);
|
|
3815
|
+
const [head, body, tail] = partial ? [
|
|
3816
|
+
pattern.slice(patternIndex, firstgs),
|
|
3817
|
+
pattern.slice(firstgs + 1),
|
|
3818
|
+
[]
|
|
3819
|
+
] : [
|
|
3820
|
+
pattern.slice(patternIndex, firstgs),
|
|
3821
|
+
pattern.slice(firstgs + 1, lastgs),
|
|
3822
|
+
pattern.slice(lastgs + 1)
|
|
3823
|
+
];
|
|
3824
|
+
if (head.length) {
|
|
3825
|
+
const fileHead = file.slice(fileIndex, fileIndex + head.length);
|
|
3826
|
+
if (!this.#matchOne(fileHead, head, partial, 0, 0)) return false;
|
|
3827
|
+
fileIndex += head.length;
|
|
3828
|
+
patternIndex += head.length;
|
|
3829
|
+
}
|
|
3830
|
+
let fileTailMatch = 0;
|
|
3831
|
+
if (tail.length) {
|
|
3832
|
+
if (tail.length + fileIndex > file.length) return false;
|
|
3833
|
+
let tailStart = file.length - tail.length;
|
|
3834
|
+
if (this.#matchOne(file, tail, partial, tailStart, 0)) fileTailMatch = tail.length;
|
|
3835
|
+
else {
|
|
3836
|
+
if (file[file.length - 1] !== "" || fileIndex + tail.length === file.length) return false;
|
|
3837
|
+
tailStart--;
|
|
3838
|
+
if (!this.#matchOne(file, tail, partial, tailStart, 0)) return false;
|
|
3839
|
+
fileTailMatch = tail.length + 1;
|
|
3840
|
+
}
|
|
3841
|
+
}
|
|
3842
|
+
if (!body.length) {
|
|
3843
|
+
let sawSome = !!fileTailMatch;
|
|
3844
|
+
for (let i = fileIndex; i < file.length - fileTailMatch; i++) {
|
|
3845
|
+
const f = String(file[i]);
|
|
3846
|
+
sawSome = true;
|
|
3847
|
+
if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) return false;
|
|
3848
|
+
}
|
|
3849
|
+
return partial || sawSome;
|
|
3850
|
+
}
|
|
3851
|
+
const bodySegments = [[[], 0]];
|
|
3852
|
+
let currentBody = bodySegments[0];
|
|
3853
|
+
let nonGsParts = 0;
|
|
3854
|
+
const nonGsPartsSums = [0];
|
|
3855
|
+
for (const b of body) if (b === GLOBSTAR) {
|
|
3856
|
+
nonGsPartsSums.push(nonGsParts);
|
|
3857
|
+
currentBody = [[], 0];
|
|
3858
|
+
bodySegments.push(currentBody);
|
|
3859
|
+
} else {
|
|
3860
|
+
currentBody[0].push(b);
|
|
3861
|
+
nonGsParts++;
|
|
3862
|
+
}
|
|
3863
|
+
let i = bodySegments.length - 1;
|
|
3864
|
+
const fileLength = file.length - fileTailMatch;
|
|
3865
|
+
for (const b of bodySegments) b[1] = fileLength - (nonGsPartsSums[i--] + b[0].length);
|
|
3866
|
+
return !!this.#matchGlobStarBodySections(file, bodySegments, fileIndex, 0, partial, 0, !!fileTailMatch);
|
|
3867
|
+
}
|
|
3868
|
+
#matchGlobStarBodySections(file, bodySegments, fileIndex, bodyIndex, partial, globStarDepth, sawTail) {
|
|
3869
|
+
const bs = bodySegments[bodyIndex];
|
|
3870
|
+
if (!bs) {
|
|
3871
|
+
for (let i = fileIndex; i < file.length; i++) {
|
|
3872
|
+
sawTail = true;
|
|
3873
|
+
const f = file[i];
|
|
3874
|
+
if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) return false;
|
|
3875
|
+
}
|
|
3876
|
+
return sawTail;
|
|
3877
|
+
}
|
|
3878
|
+
const [body, after] = bs;
|
|
3879
|
+
while (fileIndex <= after) {
|
|
3880
|
+
if (this.#matchOne(file.slice(0, fileIndex + body.length), body, partial, fileIndex, 0) && globStarDepth < this.maxGlobstarRecursion) {
|
|
3881
|
+
const sub = this.#matchGlobStarBodySections(file, bodySegments, fileIndex + body.length, bodyIndex + 1, partial, globStarDepth + 1, sawTail);
|
|
3882
|
+
if (sub !== false) return sub;
|
|
3883
|
+
}
|
|
3884
|
+
const f = file[fileIndex];
|
|
3885
|
+
if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) return false;
|
|
3886
|
+
fileIndex++;
|
|
3887
|
+
}
|
|
3888
|
+
return partial || null;
|
|
3889
|
+
}
|
|
3890
|
+
#matchOne(file, pattern, partial, fileIndex, patternIndex) {
|
|
3891
|
+
let fi;
|
|
3892
|
+
let pi;
|
|
3893
|
+
let pl;
|
|
3894
|
+
let fl;
|
|
3895
|
+
for (fi = fileIndex, pi = patternIndex, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
|
|
3896
|
+
this.debug("matchOne loop");
|
|
3897
|
+
let p = pattern[pi];
|
|
3898
|
+
let f = file[fi];
|
|
3899
|
+
this.debug(pattern, p, f);
|
|
3900
|
+
/* c8 ignore start */
|
|
3901
|
+
if (p === false || p === GLOBSTAR) return false;
|
|
3902
|
+
/* c8 ignore stop */
|
|
3903
|
+
let hit;
|
|
3904
|
+
if (typeof p === "string") {
|
|
3905
|
+
hit = f === p;
|
|
3906
|
+
this.debug("string match", p, f, hit);
|
|
3907
|
+
} else {
|
|
3908
|
+
hit = p.test(f);
|
|
3909
|
+
this.debug("pattern match", p, f, hit);
|
|
3910
|
+
}
|
|
3911
|
+
if (!hit) return false;
|
|
3912
|
+
}
|
|
3913
|
+
if (fi === fl && pi === pl) return true;
|
|
3914
|
+
else if (fi === fl) return partial;
|
|
3915
|
+
else if (pi === pl) return fi === fl - 1 && file[fi] === "";
|
|
3916
|
+
else throw new Error("wtf?");
|
|
3917
|
+
/* c8 ignore stop */
|
|
3918
|
+
}
|
|
3919
|
+
braceExpand() {
|
|
3920
|
+
return braceExpand(this.pattern, this.options);
|
|
3921
|
+
}
|
|
3922
|
+
parse(pattern) {
|
|
3923
|
+
assertValidPattern(pattern);
|
|
3924
|
+
const options = this.options;
|
|
3925
|
+
if (pattern === "**") return GLOBSTAR;
|
|
3926
|
+
if (pattern === "") return "";
|
|
3927
|
+
let m;
|
|
3928
|
+
let fastTest = null;
|
|
3929
|
+
if (m = pattern.match(starRE)) fastTest = options.dot ? starTestDot : starTest;
|
|
3930
|
+
else if (m = pattern.match(starDotExtRE)) fastTest = (options.nocase ? options.dot ? starDotExtTestNocaseDot : starDotExtTestNocase : options.dot ? starDotExtTestDot : starDotExtTest)(m[1]);
|
|
3931
|
+
else if (m = pattern.match(qmarksRE)) fastTest = (options.nocase ? options.dot ? qmarksTestNocaseDot : qmarksTestNocase : options.dot ? qmarksTestDot : qmarksTest)(m);
|
|
3932
|
+
else if (m = pattern.match(starDotStarRE)) fastTest = options.dot ? starDotStarTestDot : starDotStarTest;
|
|
3933
|
+
else if (m = pattern.match(dotStarRE)) fastTest = dotStarTest;
|
|
3934
|
+
const re = AST.fromGlob(pattern, this.options).toMMPattern();
|
|
3935
|
+
if (fastTest && typeof re === "object") Reflect.defineProperty(re, "test", { value: fastTest });
|
|
3936
|
+
return re;
|
|
3937
|
+
}
|
|
3938
|
+
makeRe() {
|
|
3939
|
+
if (this.regexp || this.regexp === false) return this.regexp;
|
|
3940
|
+
const set = this.set;
|
|
3941
|
+
if (!set.length) {
|
|
3942
|
+
this.regexp = false;
|
|
3943
|
+
return this.regexp;
|
|
3944
|
+
}
|
|
3945
|
+
const options = this.options;
|
|
3946
|
+
const twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot;
|
|
3947
|
+
const flags = new Set(options.nocase ? ["i"] : []);
|
|
3948
|
+
let re = set.map((pattern) => {
|
|
3949
|
+
const pp = pattern.map((p) => {
|
|
3950
|
+
if (p instanceof RegExp) for (const f of p.flags.split("")) flags.add(f);
|
|
3951
|
+
return typeof p === "string" ? regExpEscape(p) : p === GLOBSTAR ? GLOBSTAR : p._src;
|
|
3952
|
+
});
|
|
3953
|
+
pp.forEach((p, i) => {
|
|
3954
|
+
const next = pp[i + 1];
|
|
3955
|
+
const prev = pp[i - 1];
|
|
3956
|
+
if (p !== GLOBSTAR || prev === GLOBSTAR) return;
|
|
3957
|
+
if (prev === void 0) {
|
|
3958
|
+
if (next !== void 0 && next !== GLOBSTAR) pp[i + 1] = "(?:\\/|" + twoStar + "\\/)?" + next;
|
|
3959
|
+
else pp[i] = twoStar;
|
|
3960
|
+
} else if (next === void 0) pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + ")?";
|
|
3961
|
+
else if (next !== GLOBSTAR) {
|
|
3962
|
+
pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + "\\/)" + next;
|
|
3963
|
+
pp[i + 1] = GLOBSTAR;
|
|
3964
|
+
}
|
|
3965
|
+
});
|
|
3966
|
+
const filtered = pp.filter((p) => p !== GLOBSTAR);
|
|
3967
|
+
if (this.partial && filtered.length >= 1) {
|
|
3968
|
+
const prefixes = [];
|
|
3969
|
+
for (let i = 1; i <= filtered.length; i++) prefixes.push(filtered.slice(0, i).join("/"));
|
|
3970
|
+
return "(?:" + prefixes.join("|") + ")";
|
|
3971
|
+
}
|
|
3972
|
+
return filtered.join("/");
|
|
3973
|
+
}).join("|");
|
|
3974
|
+
const [open, close] = set.length > 1 ? ["(?:", ")"] : ["", ""];
|
|
3975
|
+
re = "^" + open + re + close + "$";
|
|
3976
|
+
if (this.partial) re = "^(?:\\/|" + open + re.slice(1, -1) + close + ")$";
|
|
3977
|
+
if (this.negate) re = "^(?!" + re + ").+$";
|
|
3978
|
+
try {
|
|
3979
|
+
this.regexp = new RegExp(re, [...flags].join(""));
|
|
3980
|
+
} catch {
|
|
3981
|
+
this.regexp = false;
|
|
3982
|
+
}
|
|
3983
|
+
/* c8 ignore stop */
|
|
3984
|
+
return this.regexp;
|
|
3985
|
+
}
|
|
3986
|
+
slashSplit(p) {
|
|
3987
|
+
if (this.preserveMultipleSlashes) return p.split("/");
|
|
3988
|
+
else if (this.isWindows && /^\/\/[^/]+/.test(p)) return ["", ...p.split(/\/+/)];
|
|
3989
|
+
else return p.split(/\/+/);
|
|
3990
|
+
}
|
|
3991
|
+
match(f, partial = this.partial) {
|
|
3992
|
+
this.debug("match", f, this.pattern);
|
|
3993
|
+
if (this.comment) return false;
|
|
3994
|
+
if (this.empty) return f === "";
|
|
3995
|
+
if (f === "/" && partial) return true;
|
|
3996
|
+
const options = this.options;
|
|
3997
|
+
if (this.isWindows) f = f.split("\\").join("/");
|
|
3998
|
+
const ff = this.slashSplit(f);
|
|
3999
|
+
this.debug(this.pattern, "split", ff);
|
|
4000
|
+
const set = this.set;
|
|
4001
|
+
this.debug(this.pattern, "set", set);
|
|
4002
|
+
let filename = ff[ff.length - 1];
|
|
4003
|
+
if (!filename) for (let i = ff.length - 2; !filename && i >= 0; i--) filename = ff[i];
|
|
4004
|
+
for (const pattern of set) {
|
|
4005
|
+
let file = ff;
|
|
4006
|
+
if (options.matchBase && pattern.length === 1) file = [filename];
|
|
4007
|
+
if (this.matchOne(file, pattern, partial)) {
|
|
4008
|
+
if (options.flipNegate) return true;
|
|
4009
|
+
return !this.negate;
|
|
4010
|
+
}
|
|
4011
|
+
}
|
|
4012
|
+
if (options.flipNegate) return false;
|
|
4013
|
+
return this.negate;
|
|
4014
|
+
}
|
|
4015
|
+
static defaults(def) {
|
|
4016
|
+
return minimatch.defaults(def).Minimatch;
|
|
4017
|
+
}
|
|
4018
|
+
};
|
|
4019
|
+
/* c8 ignore stop */
|
|
4020
|
+
minimatch.AST = AST;
|
|
4021
|
+
minimatch.Minimatch = Minimatch;
|
|
4022
|
+
minimatch.escape = escape;
|
|
4023
|
+
minimatch.unescape = unescape;
|
|
4024
|
+
//#endregion
|
|
4025
|
+
//#region ../whiteboard-document/src/file-lenses.ts
|
|
4026
|
+
/** Ends with the Uncategorized lens. `resolve` returns undefined for an anchor
|
|
4027
|
+
* it cannot resolve. */
|
|
4028
|
+
function resolveLenses(lenses, files, fileSources, resolve, options) {
|
|
4029
|
+
const resolved = lenses.map((lens) => {
|
|
4030
|
+
const { id, title } = lens;
|
|
4031
|
+
const unavailableAnchors = [];
|
|
4032
|
+
try {
|
|
4033
|
+
const result = resolveFileLens(lens, files, fileSources, (source, anchor) => {
|
|
4034
|
+
const sources = resolve(source);
|
|
4035
|
+
if (!sources) unavailableAnchors.push(anchor);
|
|
4036
|
+
return sources ?? [];
|
|
4037
|
+
}, options);
|
|
4038
|
+
return {
|
|
4039
|
+
id,
|
|
4040
|
+
title,
|
|
4041
|
+
...result,
|
|
4042
|
+
...unavailableAnchors.length && { unavailableAnchors },
|
|
4043
|
+
...!result.fileCount && { unavailable: "No files match these targets" }
|
|
4044
|
+
};
|
|
4045
|
+
} catch {
|
|
4046
|
+
return {
|
|
4047
|
+
id,
|
|
4048
|
+
title,
|
|
4049
|
+
sources: [],
|
|
4050
|
+
unavailable: "Source links need updating at these pins"
|
|
4051
|
+
};
|
|
4052
|
+
}
|
|
4053
|
+
});
|
|
4054
|
+
const uncategorized = uncategorizedSources(files, resolved.flatMap((lens) => lens.unavailable ? [] : lens.sources));
|
|
4055
|
+
resolved.push({
|
|
4056
|
+
id: UNCATEGORIZED_LENS_ID,
|
|
4057
|
+
title: "Uncategorized changes",
|
|
4058
|
+
sources: uncategorized,
|
|
4059
|
+
wholeFiles: false,
|
|
4060
|
+
fileCount: new Set(uncategorized.map(changedPath(files))).size,
|
|
4061
|
+
...!uncategorized.length && { unavailable: "All changed lines are covered by lenses" }
|
|
4062
|
+
});
|
|
4063
|
+
return resolved;
|
|
4064
|
+
}
|
|
4065
|
+
/** Subtract authored coverage, independently of viewed state. */
|
|
4066
|
+
function uncategorizedSources(files, sources) {
|
|
4067
|
+
const own = sourcesForFile(sources);
|
|
4068
|
+
return files.flatMap((file) => {
|
|
4069
|
+
const covered = scopedCoverage(file, own(file));
|
|
4070
|
+
return coverageSources(file, {
|
|
4071
|
+
base: subtractIntervals(file.changed.base, covered.base),
|
|
4072
|
+
head: subtractIntervals(file.changed.head, covered.head)
|
|
4073
|
+
});
|
|
4074
|
+
});
|
|
4075
|
+
}
|
|
4076
|
+
/** Resolve all targets into one union; a whole-file range subsumes narrower ranges. */
|
|
4077
|
+
function resolveFileLens(lens, files, fileSources, resolve, options) {
|
|
4078
|
+
const targets = lens.targets;
|
|
4079
|
+
const selected = targets.flatMap((target) => {
|
|
4080
|
+
if (target.kind === "ranges") return target.sources.flatMap((source) => resolve(anchorSelection(source), source));
|
|
4081
|
+
const matches = fileLensMatcher(target.patterns, options);
|
|
4082
|
+
return files.filter(matches).flatMap((file) => fileSources.get(file.path) ?? []);
|
|
4083
|
+
});
|
|
4084
|
+
const groups = /* @__PURE__ */ new Map();
|
|
4085
|
+
for (const source of selected) {
|
|
4086
|
+
const key = JSON.stringify([source.side, source.file]);
|
|
4087
|
+
const group = groups.get(key) ?? [];
|
|
4088
|
+
group.push(source);
|
|
4089
|
+
groups.set(key, group);
|
|
4090
|
+
}
|
|
4091
|
+
const sources = [...groups.values()].flatMap((group) => unionIntervals(group.map((source) => [source.fromLine - 1, source.toLine])).map(([start, end]) => ({
|
|
4092
|
+
...group[0],
|
|
4093
|
+
fromLine: start + 1,
|
|
4094
|
+
toLine: end
|
|
4095
|
+
})));
|
|
4096
|
+
return {
|
|
4097
|
+
sources,
|
|
4098
|
+
fileCount: new Set(sources.map(changedPath(files))).size,
|
|
4099
|
+
wholeFiles: targets.every((target) => target.kind === "files")
|
|
4100
|
+
};
|
|
4101
|
+
}
|
|
4102
|
+
/** The changed file a source names on its side, or the source's own file. */
|
|
4103
|
+
function changedPath(files) {
|
|
4104
|
+
const paths = /* @__PURE__ */ new Map();
|
|
4105
|
+
for (const file of files) for (const key of [`base:${file.previousPath ?? file.path}`, `head:${file.path}`]) if (!paths.has(key)) paths.set(key, file.path);
|
|
4106
|
+
return (source) => paths.get(`${source.side}:${source.file}`) ?? source.file;
|
|
4107
|
+
}
|
|
4108
|
+
/** Evaluate authored patterns against the changed-file list, never the filesystem. */
|
|
4109
|
+
function fileLensMatcher(patterns, options) {
|
|
4110
|
+
const matchers = patterns.map((pattern) => {
|
|
4111
|
+
const normalized = pattern.startsWith("./") ? pattern.slice(2) : pattern;
|
|
4112
|
+
const glob = new Minimatch(normalized, {
|
|
4113
|
+
nocase: options?.nocase,
|
|
4114
|
+
windowsPathsNoEscape: true,
|
|
4115
|
+
nonegate: true,
|
|
4116
|
+
nocomment: true,
|
|
4117
|
+
optimizationLevel: 2,
|
|
4118
|
+
platform: "linux",
|
|
4119
|
+
nocaseMagicOnly: true,
|
|
4120
|
+
braceExpandMax: 256
|
|
4121
|
+
});
|
|
4122
|
+
return (path) => path === normalized || glob.match(path);
|
|
4123
|
+
});
|
|
4124
|
+
return (file) => matchers.some((matches) => matches(file.path) || file.previousPath !== void 0 && matches(file.previousPath));
|
|
4125
|
+
}
|
|
4126
|
+
//#endregion
|
|
4127
|
+
//#region ../whiteboard-document/src/lens-report.ts
|
|
4128
|
+
/** The most files an uncategorized report names; the rest are counted. */
|
|
4129
|
+
const REPORT_FILES = 50;
|
|
4130
|
+
/** What a lens author still has to place: the changed lines no lens selects,
|
|
4131
|
+
* grouped by file. */
|
|
4132
|
+
function uncategorizedReport(resolved, files, extra = {}) {
|
|
4133
|
+
const sources = resolved.find((lens) => lens.id === "automatic-uncategorized")?.sources ?? [];
|
|
4134
|
+
const byPath = /* @__PURE__ */ new Map();
|
|
4135
|
+
const pathOf = changedPath(files);
|
|
4136
|
+
for (const source of sources) {
|
|
4137
|
+
const path = pathOf(source);
|
|
4138
|
+
const entry = byPath.get(path) ?? {
|
|
4139
|
+
path,
|
|
4140
|
+
lines: 0,
|
|
4141
|
+
ranges: []
|
|
4142
|
+
};
|
|
4143
|
+
entry.lines += source.toLine - source.fromLine + 1;
|
|
4144
|
+
entry.ranges.push({
|
|
4145
|
+
side: source.side,
|
|
4146
|
+
fromLine: source.fromLine,
|
|
4147
|
+
toLine: source.toLine
|
|
4148
|
+
});
|
|
4149
|
+
byPath.set(path, entry);
|
|
4150
|
+
}
|
|
4151
|
+
const entries = [...byPath.values()];
|
|
4152
|
+
const report = {
|
|
4153
|
+
lines: entries.reduce((total, file) => total + file.lines, 0),
|
|
4154
|
+
files: entries.slice(0, REPORT_FILES)
|
|
4155
|
+
};
|
|
4156
|
+
if (entries.length > REPORT_FILES) report.moreFiles = entries.length - REPORT_FILES;
|
|
4157
|
+
if (extra.unsupported !== void 0) report.unsupported = extra.unsupported;
|
|
4158
|
+
return report;
|
|
4159
|
+
}
|
|
4160
|
+
/** Each lens as authored, with what it resolves to, for a lens author. */
|
|
4161
|
+
function lensReport(lenses, resolved, files, extra = {}) {
|
|
4162
|
+
return {
|
|
4163
|
+
lenses: lenses.map((lens) => {
|
|
4164
|
+
const match = resolved.find((item) => item.id === lens.id);
|
|
4165
|
+
return {
|
|
4166
|
+
...lens,
|
|
4167
|
+
fileCount: match?.fileCount ?? 0,
|
|
4168
|
+
...match?.unavailable && { unavailable: match.unavailable },
|
|
4169
|
+
...match?.unavailableAnchors && { unavailableAnchors: match.unavailableAnchors }
|
|
4170
|
+
};
|
|
4171
|
+
}),
|
|
4172
|
+
uncategorized: uncategorizedReport(resolved, files, extra)
|
|
4173
|
+
};
|
|
4174
|
+
}
|
|
4175
|
+
//#endregion
|
|
4176
|
+
export { fileLineRangeSchema as $, summarizeEdit as A, UNCATEGORIZED_LENS_ID as B, respellCommitLinks as C, reviewTargetSchema as D, respellLinks as E, checkReferences as F, lensTargetsSchema as G, lensEditSchema as H, componentReference as I, updateCoverage as J, emptyCoverage as K, documentAdvice as L, markdownText as M, parseMarkdown as N, selectionReferences as O, blocks as P, checkSourcePath as Q, writableBlockTypes as R, resourceReferences as S, respellEditLinks as T, lensSchema as U, applyLensEdit as V, lensSelections as W, label$1 as X, animationCode as Y, SourceRangeError as Z, pinnedRepositoryIds as _, activityUpdateSchema as _t, anchorPins as a, formatAnchor as at, readsAtBoardPins as b, boardLinks as c, resolveDiffSelection as ct, documentSchema as d, intersectIntervals as dt, requireVisibleSource as et, editSchema as f, subtractIntervals as ft, pinDocumentReferences as g, activityEndSchema as gt, pathTargetSchema as h, activityBeginSchema as ht, adoptFlowUnits as i, comparisonKey as it, markdownNodes as j, sourceReferences as k, boardRepositoryId as l, selectionKey as lt, explicitPins as m, ReviewInputError as mt, uncategorizedReport as n, SELECTION_UNAVAILABLE_REASONS as nt, applyEdit as o, parseAnchor as ot, elements as p, unionIntervals as pt, scopedCoverage as q, resolveLenses as r, SelectionUnavailableError as rt, assignMissingIds as s, patchRows as st, lensReport as t, sliceSourceRange as tt, commitLinkCommits as u, sourceAnchors as ut, pinsSchema as v, focusSchema as vt, respellDocumentLinks as w, resourceReference as x, publishedEdits as y, stepSources as z };
|