anycodex 0.0.6 → 0.0.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/dist/bin.js +5462 -42
- package/dist/chunk-3KUWIT4H.js +34011 -0
- package/dist/chunk-5UMV2W7N.js +455 -0
- package/dist/chunk-6SEC53MI.js +18580 -0
- package/dist/chunk-77HVPD4G.js +43 -0
- package/dist/chunk-BTDDMBCN.js +18974 -0
- package/dist/chunk-DU4BGORD.js +50 -0
- package/dist/chunk-FSJHVC5R.js +25144 -0
- package/dist/chunk-H3TAXRCT.js +1564 -0
- package/dist/chunk-LD436475.js +109 -0
- package/dist/chunk-RKQHI4QK.js +2763 -0
- package/dist/chunk-XXVDY7BO.js +53 -0
- package/dist/dist-I2W4X7HT.js +96 -0
- package/dist/glob-RMMK6FVW-WWQVXLWS.js +9 -0
- package/dist/mime-types-5YOYBSSJ.js +9530 -0
- package/dist/registry-VQVHAEPP-NMTKW3ID.js +15 -0
- package/dist/schema-SOLWPA3E-PNTUZRDK.js +14 -0
- package/dist/session-Q7S3ITUV-S7F6XEPQ.js +20 -0
- package/dist/storage-YSEEBFV7-IJTIS3MG.js +29 -0
- package/dist/token-PRJUKXYG.js +65 -0
- package/dist/token-util-NX2T2YVY.js +7 -0
- package/package.json +5 -3
- package/src/bin.ts +11 -20
- package/tsup.config.ts +1 -0
|
@@ -0,0 +1,1564 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// ../../node_modules/.pnpm/@isaacs+balanced-match@4.0.1/node_modules/@isaacs/balanced-match/dist/esm/index.js
|
|
4
|
+
var balanced = (a, b, str) => {
|
|
5
|
+
const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
|
|
6
|
+
const mb = b instanceof RegExp ? maybeMatch(b, str) : b;
|
|
7
|
+
const r = ma !== null && mb != null && range(ma, mb, str);
|
|
8
|
+
return r && {
|
|
9
|
+
start: r[0],
|
|
10
|
+
end: r[1],
|
|
11
|
+
pre: str.slice(0, r[0]),
|
|
12
|
+
body: str.slice(r[0] + ma.length, r[1]),
|
|
13
|
+
post: str.slice(r[1] + mb.length)
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
var maybeMatch = (reg, str) => {
|
|
17
|
+
const m = str.match(reg);
|
|
18
|
+
return m ? m[0] : null;
|
|
19
|
+
};
|
|
20
|
+
var range = (a, b, str) => {
|
|
21
|
+
let begs, beg, left, right = void 0, result;
|
|
22
|
+
let ai = str.indexOf(a);
|
|
23
|
+
let bi = str.indexOf(b, ai + 1);
|
|
24
|
+
let i = ai;
|
|
25
|
+
if (ai >= 0 && bi > 0) {
|
|
26
|
+
if (a === b) {
|
|
27
|
+
return [ai, bi];
|
|
28
|
+
}
|
|
29
|
+
begs = [];
|
|
30
|
+
left = str.length;
|
|
31
|
+
while (i >= 0 && !result) {
|
|
32
|
+
if (i === ai) {
|
|
33
|
+
begs.push(i);
|
|
34
|
+
ai = str.indexOf(a, i + 1);
|
|
35
|
+
} else if (begs.length === 1) {
|
|
36
|
+
const r = begs.pop();
|
|
37
|
+
if (r !== void 0)
|
|
38
|
+
result = [r, bi];
|
|
39
|
+
} else {
|
|
40
|
+
beg = begs.pop();
|
|
41
|
+
if (beg !== void 0 && beg < left) {
|
|
42
|
+
left = beg;
|
|
43
|
+
right = bi;
|
|
44
|
+
}
|
|
45
|
+
bi = str.indexOf(b, i + 1);
|
|
46
|
+
}
|
|
47
|
+
i = ai < bi && ai >= 0 ? ai : bi;
|
|
48
|
+
}
|
|
49
|
+
if (begs.length && right !== void 0) {
|
|
50
|
+
result = [left, right];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// ../../node_modules/.pnpm/@isaacs+brace-expansion@5.0.1/node_modules/@isaacs/brace-expansion/dist/esm/index.js
|
|
57
|
+
var escSlash = "\0SLASH" + Math.random() + "\0";
|
|
58
|
+
var escOpen = "\0OPEN" + Math.random() + "\0";
|
|
59
|
+
var escClose = "\0CLOSE" + Math.random() + "\0";
|
|
60
|
+
var escComma = "\0COMMA" + Math.random() + "\0";
|
|
61
|
+
var escPeriod = "\0PERIOD" + Math.random() + "\0";
|
|
62
|
+
var escSlashPattern = new RegExp(escSlash, "g");
|
|
63
|
+
var escOpenPattern = new RegExp(escOpen, "g");
|
|
64
|
+
var escClosePattern = new RegExp(escClose, "g");
|
|
65
|
+
var escCommaPattern = new RegExp(escComma, "g");
|
|
66
|
+
var escPeriodPattern = new RegExp(escPeriod, "g");
|
|
67
|
+
var slashPattern = /\\\\/g;
|
|
68
|
+
var openPattern = /\\{/g;
|
|
69
|
+
var closePattern = /\\}/g;
|
|
70
|
+
var commaPattern = /\\,/g;
|
|
71
|
+
var periodPattern = /\\./g;
|
|
72
|
+
var EXPANSION_MAX = 1e5;
|
|
73
|
+
function numeric(str) {
|
|
74
|
+
return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
|
|
75
|
+
}
|
|
76
|
+
function escapeBraces(str) {
|
|
77
|
+
return str.replace(slashPattern, escSlash).replace(openPattern, escOpen).replace(closePattern, escClose).replace(commaPattern, escComma).replace(periodPattern, escPeriod);
|
|
78
|
+
}
|
|
79
|
+
function unescapeBraces(str) {
|
|
80
|
+
return str.replace(escSlashPattern, "\\").replace(escOpenPattern, "{").replace(escClosePattern, "}").replace(escCommaPattern, ",").replace(escPeriodPattern, ".");
|
|
81
|
+
}
|
|
82
|
+
function parseCommaParts(str) {
|
|
83
|
+
if (!str) {
|
|
84
|
+
return [""];
|
|
85
|
+
}
|
|
86
|
+
const parts = [];
|
|
87
|
+
const m = balanced("{", "}", str);
|
|
88
|
+
if (!m) {
|
|
89
|
+
return str.split(",");
|
|
90
|
+
}
|
|
91
|
+
const { pre, body, post } = m;
|
|
92
|
+
const p = pre.split(",");
|
|
93
|
+
p[p.length - 1] += "{" + body + "}";
|
|
94
|
+
const postParts = parseCommaParts(post);
|
|
95
|
+
if (post.length) {
|
|
96
|
+
;
|
|
97
|
+
p[p.length - 1] += postParts.shift();
|
|
98
|
+
p.push.apply(p, postParts);
|
|
99
|
+
}
|
|
100
|
+
parts.push.apply(parts, p);
|
|
101
|
+
return parts;
|
|
102
|
+
}
|
|
103
|
+
function expand(str, options = {}) {
|
|
104
|
+
if (!str) {
|
|
105
|
+
return [];
|
|
106
|
+
}
|
|
107
|
+
const { max = EXPANSION_MAX } = options;
|
|
108
|
+
if (str.slice(0, 2) === "{}") {
|
|
109
|
+
str = "\\{\\}" + str.slice(2);
|
|
110
|
+
}
|
|
111
|
+
return expand_(escapeBraces(str), max, true).map(unescapeBraces);
|
|
112
|
+
}
|
|
113
|
+
function embrace(str) {
|
|
114
|
+
return "{" + str + "}";
|
|
115
|
+
}
|
|
116
|
+
function isPadded(el) {
|
|
117
|
+
return /^-?0\d/.test(el);
|
|
118
|
+
}
|
|
119
|
+
function lte(i, y) {
|
|
120
|
+
return i <= y;
|
|
121
|
+
}
|
|
122
|
+
function gte(i, y) {
|
|
123
|
+
return i >= y;
|
|
124
|
+
}
|
|
125
|
+
function expand_(str, max, isTop) {
|
|
126
|
+
const expansions = [];
|
|
127
|
+
const m = balanced("{", "}", str);
|
|
128
|
+
if (!m)
|
|
129
|
+
return [str];
|
|
130
|
+
const pre = m.pre;
|
|
131
|
+
const post = m.post.length ? expand_(m.post, max, false) : [""];
|
|
132
|
+
if (/\$$/.test(m.pre)) {
|
|
133
|
+
for (let k = 0; k < post.length && k < max; k++) {
|
|
134
|
+
const expansion = pre + "{" + m.body + "}" + post[k];
|
|
135
|
+
expansions.push(expansion);
|
|
136
|
+
}
|
|
137
|
+
} else {
|
|
138
|
+
const isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
|
139
|
+
const isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
|
140
|
+
const isSequence = isNumericSequence || isAlphaSequence;
|
|
141
|
+
const isOptions = m.body.indexOf(",") >= 0;
|
|
142
|
+
if (!isSequence && !isOptions) {
|
|
143
|
+
if (m.post.match(/,(?!,).*\}/)) {
|
|
144
|
+
str = m.pre + "{" + m.body + escClose + m.post;
|
|
145
|
+
return expand_(str, max, true);
|
|
146
|
+
}
|
|
147
|
+
return [str];
|
|
148
|
+
}
|
|
149
|
+
let n;
|
|
150
|
+
if (isSequence) {
|
|
151
|
+
n = m.body.split(/\.\./);
|
|
152
|
+
} else {
|
|
153
|
+
n = parseCommaParts(m.body);
|
|
154
|
+
if (n.length === 1 && n[0] !== void 0) {
|
|
155
|
+
n = expand_(n[0], max, false).map(embrace);
|
|
156
|
+
if (n.length === 1) {
|
|
157
|
+
return post.map((p) => m.pre + n[0] + p);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
let N;
|
|
162
|
+
if (isSequence && n[0] !== void 0 && n[1] !== void 0) {
|
|
163
|
+
const x = numeric(n[0]);
|
|
164
|
+
const y = numeric(n[1]);
|
|
165
|
+
const width = Math.max(n[0].length, n[1].length);
|
|
166
|
+
let incr = n.length === 3 && n[2] !== void 0 ? Math.abs(numeric(n[2])) : 1;
|
|
167
|
+
let test = lte;
|
|
168
|
+
const reverse = y < x;
|
|
169
|
+
if (reverse) {
|
|
170
|
+
incr *= -1;
|
|
171
|
+
test = gte;
|
|
172
|
+
}
|
|
173
|
+
const pad = n.some(isPadded);
|
|
174
|
+
N = [];
|
|
175
|
+
for (let i = x; test(i, y); i += incr) {
|
|
176
|
+
let c;
|
|
177
|
+
if (isAlphaSequence) {
|
|
178
|
+
c = String.fromCharCode(i);
|
|
179
|
+
if (c === "\\") {
|
|
180
|
+
c = "";
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
c = String(i);
|
|
184
|
+
if (pad) {
|
|
185
|
+
const need = width - c.length;
|
|
186
|
+
if (need > 0) {
|
|
187
|
+
const z = new Array(need + 1).join("0");
|
|
188
|
+
if (i < 0) {
|
|
189
|
+
c = "-" + z + c.slice(1);
|
|
190
|
+
} else {
|
|
191
|
+
c = z + c;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
N.push(c);
|
|
197
|
+
}
|
|
198
|
+
} else {
|
|
199
|
+
N = [];
|
|
200
|
+
for (let j = 0; j < n.length; j++) {
|
|
201
|
+
N.push.apply(N, expand_(n[j], max, false));
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
for (let j = 0; j < N.length; j++) {
|
|
205
|
+
for (let k = 0; k < post.length && expansions.length < max; k++) {
|
|
206
|
+
const expansion = pre + N[j] + post[k];
|
|
207
|
+
if (!isTop || isSequence || expansion) {
|
|
208
|
+
expansions.push(expansion);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return expansions;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// ../../node_modules/.pnpm/minimatch@10.0.3/node_modules/minimatch/dist/esm/assert-valid-pattern.js
|
|
217
|
+
var MAX_PATTERN_LENGTH = 1024 * 64;
|
|
218
|
+
var assertValidPattern = (pattern) => {
|
|
219
|
+
if (typeof pattern !== "string") {
|
|
220
|
+
throw new TypeError("invalid pattern");
|
|
221
|
+
}
|
|
222
|
+
if (pattern.length > MAX_PATTERN_LENGTH) {
|
|
223
|
+
throw new TypeError("pattern is too long");
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
// ../../node_modules/.pnpm/minimatch@10.0.3/node_modules/minimatch/dist/esm/brace-expressions.js
|
|
228
|
+
var posixClasses = {
|
|
229
|
+
"[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true],
|
|
230
|
+
"[:alpha:]": ["\\p{L}\\p{Nl}", true],
|
|
231
|
+
"[:ascii:]": ["\\x00-\\x7f", false],
|
|
232
|
+
"[:blank:]": ["\\p{Zs}\\t", true],
|
|
233
|
+
"[:cntrl:]": ["\\p{Cc}", true],
|
|
234
|
+
"[:digit:]": ["\\p{Nd}", true],
|
|
235
|
+
"[:graph:]": ["\\p{Z}\\p{C}", true, true],
|
|
236
|
+
"[:lower:]": ["\\p{Ll}", true],
|
|
237
|
+
"[:print:]": ["\\p{C}", true],
|
|
238
|
+
"[:punct:]": ["\\p{P}", true],
|
|
239
|
+
"[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", true],
|
|
240
|
+
"[:upper:]": ["\\p{Lu}", true],
|
|
241
|
+
"[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", true],
|
|
242
|
+
"[:xdigit:]": ["A-Fa-f0-9", false]
|
|
243
|
+
};
|
|
244
|
+
var braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&");
|
|
245
|
+
var regexpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
246
|
+
var rangesToString = (ranges) => ranges.join("");
|
|
247
|
+
var parseClass = (glob, position) => {
|
|
248
|
+
const pos = position;
|
|
249
|
+
if (glob.charAt(pos) !== "[") {
|
|
250
|
+
throw new Error("not in a brace expression");
|
|
251
|
+
}
|
|
252
|
+
const ranges = [];
|
|
253
|
+
const negs = [];
|
|
254
|
+
let i = pos + 1;
|
|
255
|
+
let sawStart = false;
|
|
256
|
+
let uflag = false;
|
|
257
|
+
let escaping = false;
|
|
258
|
+
let negate = false;
|
|
259
|
+
let endPos = pos;
|
|
260
|
+
let rangeStart = "";
|
|
261
|
+
WHILE: while (i < glob.length) {
|
|
262
|
+
const c = glob.charAt(i);
|
|
263
|
+
if ((c === "!" || c === "^") && i === pos + 1) {
|
|
264
|
+
negate = true;
|
|
265
|
+
i++;
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
if (c === "]" && sawStart && !escaping) {
|
|
269
|
+
endPos = i + 1;
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
sawStart = true;
|
|
273
|
+
if (c === "\\") {
|
|
274
|
+
if (!escaping) {
|
|
275
|
+
escaping = true;
|
|
276
|
+
i++;
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
if (c === "[" && !escaping) {
|
|
281
|
+
for (const [cls, [unip, u, neg]] of Object.entries(posixClasses)) {
|
|
282
|
+
if (glob.startsWith(cls, i)) {
|
|
283
|
+
if (rangeStart) {
|
|
284
|
+
return ["$.", false, glob.length - pos, true];
|
|
285
|
+
}
|
|
286
|
+
i += cls.length;
|
|
287
|
+
if (neg)
|
|
288
|
+
negs.push(unip);
|
|
289
|
+
else
|
|
290
|
+
ranges.push(unip);
|
|
291
|
+
uflag = uflag || u;
|
|
292
|
+
continue WHILE;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
escaping = false;
|
|
297
|
+
if (rangeStart) {
|
|
298
|
+
if (c > rangeStart) {
|
|
299
|
+
ranges.push(braceEscape(rangeStart) + "-" + braceEscape(c));
|
|
300
|
+
} else if (c === rangeStart) {
|
|
301
|
+
ranges.push(braceEscape(c));
|
|
302
|
+
}
|
|
303
|
+
rangeStart = "";
|
|
304
|
+
i++;
|
|
305
|
+
continue;
|
|
306
|
+
}
|
|
307
|
+
if (glob.startsWith("-]", i + 1)) {
|
|
308
|
+
ranges.push(braceEscape(c + "-"));
|
|
309
|
+
i += 2;
|
|
310
|
+
continue;
|
|
311
|
+
}
|
|
312
|
+
if (glob.startsWith("-", i + 1)) {
|
|
313
|
+
rangeStart = c;
|
|
314
|
+
i += 2;
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
ranges.push(braceEscape(c));
|
|
318
|
+
i++;
|
|
319
|
+
}
|
|
320
|
+
if (endPos < i) {
|
|
321
|
+
return ["", false, 0, false];
|
|
322
|
+
}
|
|
323
|
+
if (!ranges.length && !negs.length) {
|
|
324
|
+
return ["$.", false, glob.length - pos, true];
|
|
325
|
+
}
|
|
326
|
+
if (negs.length === 0 && ranges.length === 1 && /^\\?.$/.test(ranges[0]) && !negate) {
|
|
327
|
+
const r = ranges[0].length === 2 ? ranges[0].slice(-1) : ranges[0];
|
|
328
|
+
return [regexpEscape(r), false, endPos - pos, false];
|
|
329
|
+
}
|
|
330
|
+
const sranges = "[" + (negate ? "^" : "") + rangesToString(ranges) + "]";
|
|
331
|
+
const snegs = "[" + (negate ? "" : "^") + rangesToString(negs) + "]";
|
|
332
|
+
const comb = ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs;
|
|
333
|
+
return [comb, uflag, endPos - pos, true];
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
// ../../node_modules/.pnpm/minimatch@10.0.3/node_modules/minimatch/dist/esm/unescape.js
|
|
337
|
+
var unescape = (s, { windowsPathsNoEscape = false } = {}) => {
|
|
338
|
+
return windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1");
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
// ../../node_modules/.pnpm/minimatch@10.0.3/node_modules/minimatch/dist/esm/ast.js
|
|
342
|
+
var types = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]);
|
|
343
|
+
var isExtglobType = (c) => types.has(c);
|
|
344
|
+
var startNoTraversal = "(?!(?:^|/)\\.\\.?(?:$|/))";
|
|
345
|
+
var startNoDot = "(?!\\.)";
|
|
346
|
+
var addPatternStart = /* @__PURE__ */ new Set(["[", "."]);
|
|
347
|
+
var justDots = /* @__PURE__ */ new Set(["..", "."]);
|
|
348
|
+
var reSpecials = new Set("().*{}+?[]^$\\!");
|
|
349
|
+
var regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
350
|
+
var qmark = "[^/]";
|
|
351
|
+
var star = qmark + "*?";
|
|
352
|
+
var starNoEmpty = qmark + "+?";
|
|
353
|
+
var AST = class _AST {
|
|
354
|
+
type;
|
|
355
|
+
#root;
|
|
356
|
+
#hasMagic;
|
|
357
|
+
#uflag = false;
|
|
358
|
+
#parts = [];
|
|
359
|
+
#parent;
|
|
360
|
+
#parentIndex;
|
|
361
|
+
#negs;
|
|
362
|
+
#filledNegs = false;
|
|
363
|
+
#options;
|
|
364
|
+
#toString;
|
|
365
|
+
// set to true if it's an extglob with no children
|
|
366
|
+
// (which really means one child of '')
|
|
367
|
+
#emptyExt = false;
|
|
368
|
+
constructor(type, parent, options = {}) {
|
|
369
|
+
this.type = type;
|
|
370
|
+
if (type)
|
|
371
|
+
this.#hasMagic = true;
|
|
372
|
+
this.#parent = parent;
|
|
373
|
+
this.#root = this.#parent ? this.#parent.#root : this;
|
|
374
|
+
this.#options = this.#root === this ? options : this.#root.#options;
|
|
375
|
+
this.#negs = this.#root === this ? [] : this.#root.#negs;
|
|
376
|
+
if (type === "!" && !this.#root.#filledNegs)
|
|
377
|
+
this.#negs.push(this);
|
|
378
|
+
this.#parentIndex = this.#parent ? this.#parent.#parts.length : 0;
|
|
379
|
+
}
|
|
380
|
+
get hasMagic() {
|
|
381
|
+
if (this.#hasMagic !== void 0)
|
|
382
|
+
return this.#hasMagic;
|
|
383
|
+
for (const p of this.#parts) {
|
|
384
|
+
if (typeof p === "string")
|
|
385
|
+
continue;
|
|
386
|
+
if (p.type || p.hasMagic)
|
|
387
|
+
return this.#hasMagic = true;
|
|
388
|
+
}
|
|
389
|
+
return this.#hasMagic;
|
|
390
|
+
}
|
|
391
|
+
// reconstructs the pattern
|
|
392
|
+
toString() {
|
|
393
|
+
if (this.#toString !== void 0)
|
|
394
|
+
return this.#toString;
|
|
395
|
+
if (!this.type) {
|
|
396
|
+
return this.#toString = this.#parts.map((p) => String(p)).join("");
|
|
397
|
+
} else {
|
|
398
|
+
return this.#toString = this.type + "(" + this.#parts.map((p) => String(p)).join("|") + ")";
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
#fillNegs() {
|
|
402
|
+
if (this !== this.#root)
|
|
403
|
+
throw new Error("should only call on root");
|
|
404
|
+
if (this.#filledNegs)
|
|
405
|
+
return this;
|
|
406
|
+
this.toString();
|
|
407
|
+
this.#filledNegs = true;
|
|
408
|
+
let n;
|
|
409
|
+
while (n = this.#negs.pop()) {
|
|
410
|
+
if (n.type !== "!")
|
|
411
|
+
continue;
|
|
412
|
+
let p = n;
|
|
413
|
+
let pp = p.#parent;
|
|
414
|
+
while (pp) {
|
|
415
|
+
for (let i = p.#parentIndex + 1; !pp.type && i < pp.#parts.length; i++) {
|
|
416
|
+
for (const part of n.#parts) {
|
|
417
|
+
if (typeof part === "string") {
|
|
418
|
+
throw new Error("string part in extglob AST??");
|
|
419
|
+
}
|
|
420
|
+
part.copyIn(pp.#parts[i]);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
p = pp;
|
|
424
|
+
pp = p.#parent;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
return this;
|
|
428
|
+
}
|
|
429
|
+
push(...parts) {
|
|
430
|
+
for (const p of parts) {
|
|
431
|
+
if (p === "")
|
|
432
|
+
continue;
|
|
433
|
+
if (typeof p !== "string" && !(p instanceof _AST && p.#parent === this)) {
|
|
434
|
+
throw new Error("invalid part: " + p);
|
|
435
|
+
}
|
|
436
|
+
this.#parts.push(p);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
toJSON() {
|
|
440
|
+
const ret = this.type === null ? this.#parts.slice().map((p) => typeof p === "string" ? p : p.toJSON()) : [this.type, ...this.#parts.map((p) => p.toJSON())];
|
|
441
|
+
if (this.isStart() && !this.type)
|
|
442
|
+
ret.unshift([]);
|
|
443
|
+
if (this.isEnd() && (this === this.#root || this.#root.#filledNegs && this.#parent?.type === "!")) {
|
|
444
|
+
ret.push({});
|
|
445
|
+
}
|
|
446
|
+
return ret;
|
|
447
|
+
}
|
|
448
|
+
isStart() {
|
|
449
|
+
if (this.#root === this)
|
|
450
|
+
return true;
|
|
451
|
+
if (!this.#parent?.isStart())
|
|
452
|
+
return false;
|
|
453
|
+
if (this.#parentIndex === 0)
|
|
454
|
+
return true;
|
|
455
|
+
const p = this.#parent;
|
|
456
|
+
for (let i = 0; i < this.#parentIndex; i++) {
|
|
457
|
+
const pp = p.#parts[i];
|
|
458
|
+
if (!(pp instanceof _AST && pp.type === "!")) {
|
|
459
|
+
return false;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
return true;
|
|
463
|
+
}
|
|
464
|
+
isEnd() {
|
|
465
|
+
if (this.#root === this)
|
|
466
|
+
return true;
|
|
467
|
+
if (this.#parent?.type === "!")
|
|
468
|
+
return true;
|
|
469
|
+
if (!this.#parent?.isEnd())
|
|
470
|
+
return false;
|
|
471
|
+
if (!this.type)
|
|
472
|
+
return this.#parent?.isEnd();
|
|
473
|
+
const pl = this.#parent ? this.#parent.#parts.length : 0;
|
|
474
|
+
return this.#parentIndex === pl - 1;
|
|
475
|
+
}
|
|
476
|
+
copyIn(part) {
|
|
477
|
+
if (typeof part === "string")
|
|
478
|
+
this.push(part);
|
|
479
|
+
else
|
|
480
|
+
this.push(part.clone(this));
|
|
481
|
+
}
|
|
482
|
+
clone(parent) {
|
|
483
|
+
const c = new _AST(this.type, parent);
|
|
484
|
+
for (const p of this.#parts) {
|
|
485
|
+
c.copyIn(p);
|
|
486
|
+
}
|
|
487
|
+
return c;
|
|
488
|
+
}
|
|
489
|
+
static #parseAST(str, ast, pos, opt) {
|
|
490
|
+
let escaping = false;
|
|
491
|
+
let inBrace = false;
|
|
492
|
+
let braceStart = -1;
|
|
493
|
+
let braceNeg = false;
|
|
494
|
+
if (ast.type === null) {
|
|
495
|
+
let i2 = pos;
|
|
496
|
+
let acc2 = "";
|
|
497
|
+
while (i2 < str.length) {
|
|
498
|
+
const c = str.charAt(i2++);
|
|
499
|
+
if (escaping || c === "\\") {
|
|
500
|
+
escaping = !escaping;
|
|
501
|
+
acc2 += c;
|
|
502
|
+
continue;
|
|
503
|
+
}
|
|
504
|
+
if (inBrace) {
|
|
505
|
+
if (i2 === braceStart + 1) {
|
|
506
|
+
if (c === "^" || c === "!") {
|
|
507
|
+
braceNeg = true;
|
|
508
|
+
}
|
|
509
|
+
} else if (c === "]" && !(i2 === braceStart + 2 && braceNeg)) {
|
|
510
|
+
inBrace = false;
|
|
511
|
+
}
|
|
512
|
+
acc2 += c;
|
|
513
|
+
continue;
|
|
514
|
+
} else if (c === "[") {
|
|
515
|
+
inBrace = true;
|
|
516
|
+
braceStart = i2;
|
|
517
|
+
braceNeg = false;
|
|
518
|
+
acc2 += c;
|
|
519
|
+
continue;
|
|
520
|
+
}
|
|
521
|
+
if (!opt.noext && isExtglobType(c) && str.charAt(i2) === "(") {
|
|
522
|
+
ast.push(acc2);
|
|
523
|
+
acc2 = "";
|
|
524
|
+
const ext2 = new _AST(c, ast);
|
|
525
|
+
i2 = _AST.#parseAST(str, ext2, i2, opt);
|
|
526
|
+
ast.push(ext2);
|
|
527
|
+
continue;
|
|
528
|
+
}
|
|
529
|
+
acc2 += c;
|
|
530
|
+
}
|
|
531
|
+
ast.push(acc2);
|
|
532
|
+
return i2;
|
|
533
|
+
}
|
|
534
|
+
let i = pos + 1;
|
|
535
|
+
let part = new _AST(null, ast);
|
|
536
|
+
const parts = [];
|
|
537
|
+
let acc = "";
|
|
538
|
+
while (i < str.length) {
|
|
539
|
+
const c = str.charAt(i++);
|
|
540
|
+
if (escaping || c === "\\") {
|
|
541
|
+
escaping = !escaping;
|
|
542
|
+
acc += c;
|
|
543
|
+
continue;
|
|
544
|
+
}
|
|
545
|
+
if (inBrace) {
|
|
546
|
+
if (i === braceStart + 1) {
|
|
547
|
+
if (c === "^" || c === "!") {
|
|
548
|
+
braceNeg = true;
|
|
549
|
+
}
|
|
550
|
+
} else if (c === "]" && !(i === braceStart + 2 && braceNeg)) {
|
|
551
|
+
inBrace = false;
|
|
552
|
+
}
|
|
553
|
+
acc += c;
|
|
554
|
+
continue;
|
|
555
|
+
} else if (c === "[") {
|
|
556
|
+
inBrace = true;
|
|
557
|
+
braceStart = i;
|
|
558
|
+
braceNeg = false;
|
|
559
|
+
acc += c;
|
|
560
|
+
continue;
|
|
561
|
+
}
|
|
562
|
+
if (isExtglobType(c) && str.charAt(i) === "(") {
|
|
563
|
+
part.push(acc);
|
|
564
|
+
acc = "";
|
|
565
|
+
const ext2 = new _AST(c, part);
|
|
566
|
+
part.push(ext2);
|
|
567
|
+
i = _AST.#parseAST(str, ext2, i, opt);
|
|
568
|
+
continue;
|
|
569
|
+
}
|
|
570
|
+
if (c === "|") {
|
|
571
|
+
part.push(acc);
|
|
572
|
+
acc = "";
|
|
573
|
+
parts.push(part);
|
|
574
|
+
part = new _AST(null, ast);
|
|
575
|
+
continue;
|
|
576
|
+
}
|
|
577
|
+
if (c === ")") {
|
|
578
|
+
if (acc === "" && ast.#parts.length === 0) {
|
|
579
|
+
ast.#emptyExt = true;
|
|
580
|
+
}
|
|
581
|
+
part.push(acc);
|
|
582
|
+
acc = "";
|
|
583
|
+
ast.push(...parts, part);
|
|
584
|
+
return i;
|
|
585
|
+
}
|
|
586
|
+
acc += c;
|
|
587
|
+
}
|
|
588
|
+
ast.type = null;
|
|
589
|
+
ast.#hasMagic = void 0;
|
|
590
|
+
ast.#parts = [str.substring(pos - 1)];
|
|
591
|
+
return i;
|
|
592
|
+
}
|
|
593
|
+
static fromGlob(pattern, options = {}) {
|
|
594
|
+
const ast = new _AST(null, void 0, options);
|
|
595
|
+
_AST.#parseAST(pattern, ast, 0, options);
|
|
596
|
+
return ast;
|
|
597
|
+
}
|
|
598
|
+
// returns the regular expression if there's magic, or the unescaped
|
|
599
|
+
// string if not.
|
|
600
|
+
toMMPattern() {
|
|
601
|
+
if (this !== this.#root)
|
|
602
|
+
return this.#root.toMMPattern();
|
|
603
|
+
const glob = this.toString();
|
|
604
|
+
const [re, body, hasMagic, uflag] = this.toRegExpSource();
|
|
605
|
+
const anyMagic = hasMagic || this.#hasMagic || this.#options.nocase && !this.#options.nocaseMagicOnly && glob.toUpperCase() !== glob.toLowerCase();
|
|
606
|
+
if (!anyMagic) {
|
|
607
|
+
return body;
|
|
608
|
+
}
|
|
609
|
+
const flags = (this.#options.nocase ? "i" : "") + (uflag ? "u" : "");
|
|
610
|
+
return Object.assign(new RegExp(`^${re}$`, flags), {
|
|
611
|
+
_src: re,
|
|
612
|
+
_glob: glob
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
get options() {
|
|
616
|
+
return this.#options;
|
|
617
|
+
}
|
|
618
|
+
// returns the string match, the regexp source, whether there's magic
|
|
619
|
+
// in the regexp (so a regular expression is required) and whether or
|
|
620
|
+
// not the uflag is needed for the regular expression (for posix classes)
|
|
621
|
+
// TODO: instead of injecting the start/end at this point, just return
|
|
622
|
+
// the BODY of the regexp, along with the start/end portions suitable
|
|
623
|
+
// for binding the start/end in either a joined full-path makeRe context
|
|
624
|
+
// (where we bind to (^|/), or a standalone matchPart context (where
|
|
625
|
+
// we bind to ^, and not /). Otherwise slashes get duped!
|
|
626
|
+
//
|
|
627
|
+
// In part-matching mode, the start is:
|
|
628
|
+
// - if not isStart: nothing
|
|
629
|
+
// - if traversal possible, but not allowed: ^(?!\.\.?$)
|
|
630
|
+
// - if dots allowed or not possible: ^
|
|
631
|
+
// - if dots possible and not allowed: ^(?!\.)
|
|
632
|
+
// end is:
|
|
633
|
+
// - if not isEnd(): nothing
|
|
634
|
+
// - else: $
|
|
635
|
+
//
|
|
636
|
+
// In full-path matching mode, we put the slash at the START of the
|
|
637
|
+
// pattern, so start is:
|
|
638
|
+
// - if first pattern: same as part-matching mode
|
|
639
|
+
// - if not isStart(): nothing
|
|
640
|
+
// - if traversal possible, but not allowed: /(?!\.\.?(?:$|/))
|
|
641
|
+
// - if dots allowed or not possible: /
|
|
642
|
+
// - if dots possible and not allowed: /(?!\.)
|
|
643
|
+
// end is:
|
|
644
|
+
// - if last pattern, same as part-matching mode
|
|
645
|
+
// - else nothing
|
|
646
|
+
//
|
|
647
|
+
// Always put the (?:$|/) on negated tails, though, because that has to be
|
|
648
|
+
// there to bind the end of the negated pattern portion, and it's easier to
|
|
649
|
+
// just stick it in now rather than try to inject it later in the middle of
|
|
650
|
+
// the pattern.
|
|
651
|
+
//
|
|
652
|
+
// We can just always return the same end, and leave it up to the caller
|
|
653
|
+
// to know whether it's going to be used joined or in parts.
|
|
654
|
+
// And, if the start is adjusted slightly, can do the same there:
|
|
655
|
+
// - if not isStart: nothing
|
|
656
|
+
// - if traversal possible, but not allowed: (?:/|^)(?!\.\.?$)
|
|
657
|
+
// - if dots allowed or not possible: (?:/|^)
|
|
658
|
+
// - if dots possible and not allowed: (?:/|^)(?!\.)
|
|
659
|
+
//
|
|
660
|
+
// But it's better to have a simpler binding without a conditional, for
|
|
661
|
+
// performance, so probably better to return both start options.
|
|
662
|
+
//
|
|
663
|
+
// Then the caller just ignores the end if it's not the first pattern,
|
|
664
|
+
// and the start always gets applied.
|
|
665
|
+
//
|
|
666
|
+
// But that's always going to be $ if it's the ending pattern, or nothing,
|
|
667
|
+
// so the caller can just attach $ at the end of the pattern when building.
|
|
668
|
+
//
|
|
669
|
+
// So the todo is:
|
|
670
|
+
// - better detect what kind of start is needed
|
|
671
|
+
// - return both flavors of starting pattern
|
|
672
|
+
// - attach $ at the end of the pattern when creating the actual RegExp
|
|
673
|
+
//
|
|
674
|
+
// Ah, but wait, no, that all only applies to the root when the first pattern
|
|
675
|
+
// is not an extglob. If the first pattern IS an extglob, then we need all
|
|
676
|
+
// that dot prevention biz to live in the extglob portions, because eg
|
|
677
|
+
// +(*|.x*) can match .xy but not .yx.
|
|
678
|
+
//
|
|
679
|
+
// So, return the two flavors if it's #root and the first child is not an
|
|
680
|
+
// AST, otherwise leave it to the child AST to handle it, and there,
|
|
681
|
+
// use the (?:^|/) style of start binding.
|
|
682
|
+
//
|
|
683
|
+
// Even simplified further:
|
|
684
|
+
// - Since the start for a join is eg /(?!\.) and the start for a part
|
|
685
|
+
// is ^(?!\.), we can just prepend (?!\.) to the pattern (either root
|
|
686
|
+
// or start or whatever) and prepend ^ or / at the Regexp construction.
|
|
687
|
+
toRegExpSource(allowDot) {
|
|
688
|
+
const dot = allowDot ?? !!this.#options.dot;
|
|
689
|
+
if (this.#root === this)
|
|
690
|
+
this.#fillNegs();
|
|
691
|
+
if (!this.type) {
|
|
692
|
+
const noEmpty = this.isStart() && this.isEnd();
|
|
693
|
+
const src = this.#parts.map((p) => {
|
|
694
|
+
const [re, _, hasMagic, uflag] = typeof p === "string" ? _AST.#parseGlob(p, this.#hasMagic, noEmpty) : p.toRegExpSource(allowDot);
|
|
695
|
+
this.#hasMagic = this.#hasMagic || hasMagic;
|
|
696
|
+
this.#uflag = this.#uflag || uflag;
|
|
697
|
+
return re;
|
|
698
|
+
}).join("");
|
|
699
|
+
let start2 = "";
|
|
700
|
+
if (this.isStart()) {
|
|
701
|
+
if (typeof this.#parts[0] === "string") {
|
|
702
|
+
const dotTravAllowed = this.#parts.length === 1 && justDots.has(this.#parts[0]);
|
|
703
|
+
if (!dotTravAllowed) {
|
|
704
|
+
const aps = addPatternStart;
|
|
705
|
+
const needNoTrav = (
|
|
706
|
+
// dots are allowed, and the pattern starts with [ or .
|
|
707
|
+
dot && aps.has(src.charAt(0)) || // the pattern starts with \., and then [ or .
|
|
708
|
+
src.startsWith("\\.") && aps.has(src.charAt(2)) || // the pattern starts with \.\., and then [ or .
|
|
709
|
+
src.startsWith("\\.\\.") && aps.has(src.charAt(4))
|
|
710
|
+
);
|
|
711
|
+
const needNoDot = !dot && !allowDot && aps.has(src.charAt(0));
|
|
712
|
+
start2 = needNoTrav ? startNoTraversal : needNoDot ? startNoDot : "";
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
let end = "";
|
|
717
|
+
if (this.isEnd() && this.#root.#filledNegs && this.#parent?.type === "!") {
|
|
718
|
+
end = "(?:$|\\/)";
|
|
719
|
+
}
|
|
720
|
+
const final2 = start2 + src + end;
|
|
721
|
+
return [
|
|
722
|
+
final2,
|
|
723
|
+
unescape(src),
|
|
724
|
+
this.#hasMagic = !!this.#hasMagic,
|
|
725
|
+
this.#uflag
|
|
726
|
+
];
|
|
727
|
+
}
|
|
728
|
+
const repeated = this.type === "*" || this.type === "+";
|
|
729
|
+
const start = this.type === "!" ? "(?:(?!(?:" : "(?:";
|
|
730
|
+
let body = this.#partsToRegExp(dot);
|
|
731
|
+
if (this.isStart() && this.isEnd() && !body && this.type !== "!") {
|
|
732
|
+
const s = this.toString();
|
|
733
|
+
this.#parts = [s];
|
|
734
|
+
this.type = null;
|
|
735
|
+
this.#hasMagic = void 0;
|
|
736
|
+
return [s, unescape(this.toString()), false, false];
|
|
737
|
+
}
|
|
738
|
+
let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot ? "" : this.#partsToRegExp(true);
|
|
739
|
+
if (bodyDotAllowed === body) {
|
|
740
|
+
bodyDotAllowed = "";
|
|
741
|
+
}
|
|
742
|
+
if (bodyDotAllowed) {
|
|
743
|
+
body = `(?:${body})(?:${bodyDotAllowed})*?`;
|
|
744
|
+
}
|
|
745
|
+
let final = "";
|
|
746
|
+
if (this.type === "!" && this.#emptyExt) {
|
|
747
|
+
final = (this.isStart() && !dot ? startNoDot : "") + starNoEmpty;
|
|
748
|
+
} else {
|
|
749
|
+
const close = this.type === "!" ? (
|
|
750
|
+
// !() must match something,but !(x) can match ''
|
|
751
|
+
"))" + (this.isStart() && !dot && !allowDot ? startNoDot : "") + star + ")"
|
|
752
|
+
) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && bodyDotAllowed ? ")" : this.type === "*" && bodyDotAllowed ? `)?` : `)${this.type}`;
|
|
753
|
+
final = start + body + close;
|
|
754
|
+
}
|
|
755
|
+
return [
|
|
756
|
+
final,
|
|
757
|
+
unescape(body),
|
|
758
|
+
this.#hasMagic = !!this.#hasMagic,
|
|
759
|
+
this.#uflag
|
|
760
|
+
];
|
|
761
|
+
}
|
|
762
|
+
#partsToRegExp(dot) {
|
|
763
|
+
return this.#parts.map((p) => {
|
|
764
|
+
if (typeof p === "string") {
|
|
765
|
+
throw new Error("string type in extglob ast??");
|
|
766
|
+
}
|
|
767
|
+
const [re, _, _hasMagic, uflag] = p.toRegExpSource(dot);
|
|
768
|
+
this.#uflag = this.#uflag || uflag;
|
|
769
|
+
return re;
|
|
770
|
+
}).filter((p) => !(this.isStart() && this.isEnd()) || !!p).join("|");
|
|
771
|
+
}
|
|
772
|
+
static #parseGlob(glob, hasMagic, noEmpty = false) {
|
|
773
|
+
let escaping = false;
|
|
774
|
+
let re = "";
|
|
775
|
+
let uflag = false;
|
|
776
|
+
for (let i = 0; i < glob.length; i++) {
|
|
777
|
+
const c = glob.charAt(i);
|
|
778
|
+
if (escaping) {
|
|
779
|
+
escaping = false;
|
|
780
|
+
re += (reSpecials.has(c) ? "\\" : "") + c;
|
|
781
|
+
continue;
|
|
782
|
+
}
|
|
783
|
+
if (c === "\\") {
|
|
784
|
+
if (i === glob.length - 1) {
|
|
785
|
+
re += "\\\\";
|
|
786
|
+
} else {
|
|
787
|
+
escaping = true;
|
|
788
|
+
}
|
|
789
|
+
continue;
|
|
790
|
+
}
|
|
791
|
+
if (c === "[") {
|
|
792
|
+
const [src, needUflag, consumed, magic] = parseClass(glob, i);
|
|
793
|
+
if (consumed) {
|
|
794
|
+
re += src;
|
|
795
|
+
uflag = uflag || needUflag;
|
|
796
|
+
i += consumed - 1;
|
|
797
|
+
hasMagic = hasMagic || magic;
|
|
798
|
+
continue;
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
if (c === "*") {
|
|
802
|
+
if (noEmpty && glob === "*")
|
|
803
|
+
re += starNoEmpty;
|
|
804
|
+
else
|
|
805
|
+
re += star;
|
|
806
|
+
hasMagic = true;
|
|
807
|
+
continue;
|
|
808
|
+
}
|
|
809
|
+
if (c === "?") {
|
|
810
|
+
re += qmark;
|
|
811
|
+
hasMagic = true;
|
|
812
|
+
continue;
|
|
813
|
+
}
|
|
814
|
+
re += regExpEscape(c);
|
|
815
|
+
}
|
|
816
|
+
return [re, unescape(glob), !!hasMagic, uflag];
|
|
817
|
+
}
|
|
818
|
+
};
|
|
819
|
+
|
|
820
|
+
// ../../node_modules/.pnpm/minimatch@10.0.3/node_modules/minimatch/dist/esm/escape.js
|
|
821
|
+
var escape = (s, { windowsPathsNoEscape = false } = {}) => {
|
|
822
|
+
return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
|
|
823
|
+
};
|
|
824
|
+
|
|
825
|
+
// ../../node_modules/.pnpm/minimatch@10.0.3/node_modules/minimatch/dist/esm/index.js
|
|
826
|
+
var minimatch = (p, pattern, options = {}) => {
|
|
827
|
+
assertValidPattern(pattern);
|
|
828
|
+
if (!options.nocomment && pattern.charAt(0) === "#") {
|
|
829
|
+
return false;
|
|
830
|
+
}
|
|
831
|
+
return new Minimatch(pattern, options).match(p);
|
|
832
|
+
};
|
|
833
|
+
var starDotExtRE = /^\*+([^+@!?\*\[\(]*)$/;
|
|
834
|
+
var starDotExtTest = (ext2) => (f) => !f.startsWith(".") && f.endsWith(ext2);
|
|
835
|
+
var starDotExtTestDot = (ext2) => (f) => f.endsWith(ext2);
|
|
836
|
+
var starDotExtTestNocase = (ext2) => {
|
|
837
|
+
ext2 = ext2.toLowerCase();
|
|
838
|
+
return (f) => !f.startsWith(".") && f.toLowerCase().endsWith(ext2);
|
|
839
|
+
};
|
|
840
|
+
var starDotExtTestNocaseDot = (ext2) => {
|
|
841
|
+
ext2 = ext2.toLowerCase();
|
|
842
|
+
return (f) => f.toLowerCase().endsWith(ext2);
|
|
843
|
+
};
|
|
844
|
+
var starDotStarRE = /^\*+\.\*+$/;
|
|
845
|
+
var starDotStarTest = (f) => !f.startsWith(".") && f.includes(".");
|
|
846
|
+
var starDotStarTestDot = (f) => f !== "." && f !== ".." && f.includes(".");
|
|
847
|
+
var dotStarRE = /^\.\*+$/;
|
|
848
|
+
var dotStarTest = (f) => f !== "." && f !== ".." && f.startsWith(".");
|
|
849
|
+
var starRE = /^\*+$/;
|
|
850
|
+
var starTest = (f) => f.length !== 0 && !f.startsWith(".");
|
|
851
|
+
var starTestDot = (f) => f.length !== 0 && f !== "." && f !== "..";
|
|
852
|
+
var qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/;
|
|
853
|
+
var qmarksTestNocase = ([$0, ext2 = ""]) => {
|
|
854
|
+
const noext = qmarksTestNoExt([$0]);
|
|
855
|
+
if (!ext2)
|
|
856
|
+
return noext;
|
|
857
|
+
ext2 = ext2.toLowerCase();
|
|
858
|
+
return (f) => noext(f) && f.toLowerCase().endsWith(ext2);
|
|
859
|
+
};
|
|
860
|
+
var qmarksTestNocaseDot = ([$0, ext2 = ""]) => {
|
|
861
|
+
const noext = qmarksTestNoExtDot([$0]);
|
|
862
|
+
if (!ext2)
|
|
863
|
+
return noext;
|
|
864
|
+
ext2 = ext2.toLowerCase();
|
|
865
|
+
return (f) => noext(f) && f.toLowerCase().endsWith(ext2);
|
|
866
|
+
};
|
|
867
|
+
var qmarksTestDot = ([$0, ext2 = ""]) => {
|
|
868
|
+
const noext = qmarksTestNoExtDot([$0]);
|
|
869
|
+
return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2);
|
|
870
|
+
};
|
|
871
|
+
var qmarksTest = ([$0, ext2 = ""]) => {
|
|
872
|
+
const noext = qmarksTestNoExt([$0]);
|
|
873
|
+
return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2);
|
|
874
|
+
};
|
|
875
|
+
var qmarksTestNoExt = ([$0]) => {
|
|
876
|
+
const len = $0.length;
|
|
877
|
+
return (f) => f.length === len && !f.startsWith(".");
|
|
878
|
+
};
|
|
879
|
+
var qmarksTestNoExtDot = ([$0]) => {
|
|
880
|
+
const len = $0.length;
|
|
881
|
+
return (f) => f.length === len && f !== "." && f !== "..";
|
|
882
|
+
};
|
|
883
|
+
var defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
|
884
|
+
var path = {
|
|
885
|
+
win32: { sep: "\\" },
|
|
886
|
+
posix: { sep: "/" }
|
|
887
|
+
};
|
|
888
|
+
var sep = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
|
|
889
|
+
minimatch.sep = sep;
|
|
890
|
+
var GLOBSTAR = /* @__PURE__ */ Symbol("globstar **");
|
|
891
|
+
minimatch.GLOBSTAR = GLOBSTAR;
|
|
892
|
+
var qmark2 = "[^/]";
|
|
893
|
+
var star2 = qmark2 + "*?";
|
|
894
|
+
var twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
|
|
895
|
+
var twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?";
|
|
896
|
+
var filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options);
|
|
897
|
+
minimatch.filter = filter;
|
|
898
|
+
var ext = (a, b = {}) => Object.assign({}, a, b);
|
|
899
|
+
var defaults = (def) => {
|
|
900
|
+
if (!def || typeof def !== "object" || !Object.keys(def).length) {
|
|
901
|
+
return minimatch;
|
|
902
|
+
}
|
|
903
|
+
const orig = minimatch;
|
|
904
|
+
const m = (p, pattern, options = {}) => orig(p, pattern, ext(def, options));
|
|
905
|
+
return Object.assign(m, {
|
|
906
|
+
Minimatch: class Minimatch extends orig.Minimatch {
|
|
907
|
+
constructor(pattern, options = {}) {
|
|
908
|
+
super(pattern, ext(def, options));
|
|
909
|
+
}
|
|
910
|
+
static defaults(options) {
|
|
911
|
+
return orig.defaults(ext(def, options)).Minimatch;
|
|
912
|
+
}
|
|
913
|
+
},
|
|
914
|
+
AST: class AST extends orig.AST {
|
|
915
|
+
/* c8 ignore start */
|
|
916
|
+
constructor(type, parent, options = {}) {
|
|
917
|
+
super(type, parent, ext(def, options));
|
|
918
|
+
}
|
|
919
|
+
/* c8 ignore stop */
|
|
920
|
+
static fromGlob(pattern, options = {}) {
|
|
921
|
+
return orig.AST.fromGlob(pattern, ext(def, options));
|
|
922
|
+
}
|
|
923
|
+
},
|
|
924
|
+
unescape: (s, options = {}) => orig.unescape(s, ext(def, options)),
|
|
925
|
+
escape: (s, options = {}) => orig.escape(s, ext(def, options)),
|
|
926
|
+
filter: (pattern, options = {}) => orig.filter(pattern, ext(def, options)),
|
|
927
|
+
defaults: (options) => orig.defaults(ext(def, options)),
|
|
928
|
+
makeRe: (pattern, options = {}) => orig.makeRe(pattern, ext(def, options)),
|
|
929
|
+
braceExpand: (pattern, options = {}) => orig.braceExpand(pattern, ext(def, options)),
|
|
930
|
+
match: (list, pattern, options = {}) => orig.match(list, pattern, ext(def, options)),
|
|
931
|
+
sep: orig.sep,
|
|
932
|
+
GLOBSTAR
|
|
933
|
+
});
|
|
934
|
+
};
|
|
935
|
+
minimatch.defaults = defaults;
|
|
936
|
+
var braceExpand = (pattern, options = {}) => {
|
|
937
|
+
assertValidPattern(pattern);
|
|
938
|
+
if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
|
|
939
|
+
return [pattern];
|
|
940
|
+
}
|
|
941
|
+
return expand(pattern);
|
|
942
|
+
};
|
|
943
|
+
minimatch.braceExpand = braceExpand;
|
|
944
|
+
var makeRe = (pattern, options = {}) => new Minimatch(pattern, options).makeRe();
|
|
945
|
+
minimatch.makeRe = makeRe;
|
|
946
|
+
var match = (list, pattern, options = {}) => {
|
|
947
|
+
const mm = new Minimatch(pattern, options);
|
|
948
|
+
list = list.filter((f) => mm.match(f));
|
|
949
|
+
if (mm.options.nonull && !list.length) {
|
|
950
|
+
list.push(pattern);
|
|
951
|
+
}
|
|
952
|
+
return list;
|
|
953
|
+
};
|
|
954
|
+
minimatch.match = match;
|
|
955
|
+
var globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
|
|
956
|
+
var regExpEscape2 = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
957
|
+
var Minimatch = class {
|
|
958
|
+
options;
|
|
959
|
+
set;
|
|
960
|
+
pattern;
|
|
961
|
+
windowsPathsNoEscape;
|
|
962
|
+
nonegate;
|
|
963
|
+
negate;
|
|
964
|
+
comment;
|
|
965
|
+
empty;
|
|
966
|
+
preserveMultipleSlashes;
|
|
967
|
+
partial;
|
|
968
|
+
globSet;
|
|
969
|
+
globParts;
|
|
970
|
+
nocase;
|
|
971
|
+
isWindows;
|
|
972
|
+
platform;
|
|
973
|
+
windowsNoMagicRoot;
|
|
974
|
+
regexp;
|
|
975
|
+
constructor(pattern, options = {}) {
|
|
976
|
+
assertValidPattern(pattern);
|
|
977
|
+
options = options || {};
|
|
978
|
+
this.options = options;
|
|
979
|
+
this.pattern = pattern;
|
|
980
|
+
this.platform = options.platform || defaultPlatform;
|
|
981
|
+
this.isWindows = this.platform === "win32";
|
|
982
|
+
this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options.allowWindowsEscape === false;
|
|
983
|
+
if (this.windowsPathsNoEscape) {
|
|
984
|
+
this.pattern = this.pattern.replace(/\\/g, "/");
|
|
985
|
+
}
|
|
986
|
+
this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
|
|
987
|
+
this.regexp = null;
|
|
988
|
+
this.negate = false;
|
|
989
|
+
this.nonegate = !!options.nonegate;
|
|
990
|
+
this.comment = false;
|
|
991
|
+
this.empty = false;
|
|
992
|
+
this.partial = !!options.partial;
|
|
993
|
+
this.nocase = !!this.options.nocase;
|
|
994
|
+
this.windowsNoMagicRoot = options.windowsNoMagicRoot !== void 0 ? options.windowsNoMagicRoot : !!(this.isWindows && this.nocase);
|
|
995
|
+
this.globSet = [];
|
|
996
|
+
this.globParts = [];
|
|
997
|
+
this.set = [];
|
|
998
|
+
this.make();
|
|
999
|
+
}
|
|
1000
|
+
hasMagic() {
|
|
1001
|
+
if (this.options.magicalBraces && this.set.length > 1) {
|
|
1002
|
+
return true;
|
|
1003
|
+
}
|
|
1004
|
+
for (const pattern of this.set) {
|
|
1005
|
+
for (const part of pattern) {
|
|
1006
|
+
if (typeof part !== "string")
|
|
1007
|
+
return true;
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
return false;
|
|
1011
|
+
}
|
|
1012
|
+
debug(..._) {
|
|
1013
|
+
}
|
|
1014
|
+
make() {
|
|
1015
|
+
const pattern = this.pattern;
|
|
1016
|
+
const options = this.options;
|
|
1017
|
+
if (!options.nocomment && pattern.charAt(0) === "#") {
|
|
1018
|
+
this.comment = true;
|
|
1019
|
+
return;
|
|
1020
|
+
}
|
|
1021
|
+
if (!pattern) {
|
|
1022
|
+
this.empty = true;
|
|
1023
|
+
return;
|
|
1024
|
+
}
|
|
1025
|
+
this.parseNegate();
|
|
1026
|
+
this.globSet = [...new Set(this.braceExpand())];
|
|
1027
|
+
if (options.debug) {
|
|
1028
|
+
this.debug = (...args) => console.error(...args);
|
|
1029
|
+
}
|
|
1030
|
+
this.debug(this.pattern, this.globSet);
|
|
1031
|
+
const rawGlobParts = this.globSet.map((s) => this.slashSplit(s));
|
|
1032
|
+
this.globParts = this.preprocess(rawGlobParts);
|
|
1033
|
+
this.debug(this.pattern, this.globParts);
|
|
1034
|
+
let set = this.globParts.map((s, _, __) => {
|
|
1035
|
+
if (this.isWindows && this.windowsNoMagicRoot) {
|
|
1036
|
+
const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && !globMagic.test(s[3]);
|
|
1037
|
+
const isDrive = /^[a-z]:/i.test(s[0]);
|
|
1038
|
+
if (isUNC) {
|
|
1039
|
+
return [...s.slice(0, 4), ...s.slice(4).map((ss) => this.parse(ss))];
|
|
1040
|
+
} else if (isDrive) {
|
|
1041
|
+
return [s[0], ...s.slice(1).map((ss) => this.parse(ss))];
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
return s.map((ss) => this.parse(ss));
|
|
1045
|
+
});
|
|
1046
|
+
this.debug(this.pattern, set);
|
|
1047
|
+
this.set = set.filter((s) => s.indexOf(false) === -1);
|
|
1048
|
+
if (this.isWindows) {
|
|
1049
|
+
for (let i = 0; i < this.set.length; i++) {
|
|
1050
|
+
const p = this.set[i];
|
|
1051
|
+
if (p[0] === "" && p[1] === "" && this.globParts[i][2] === "?" && typeof p[3] === "string" && /^[a-z]:$/i.test(p[3])) {
|
|
1052
|
+
p[2] = "?";
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
this.debug(this.pattern, this.set);
|
|
1057
|
+
}
|
|
1058
|
+
// various transforms to equivalent pattern sets that are
|
|
1059
|
+
// faster to process in a filesystem walk. The goal is to
|
|
1060
|
+
// eliminate what we can, and push all ** patterns as far
|
|
1061
|
+
// to the right as possible, even if it increases the number
|
|
1062
|
+
// of patterns that we have to process.
|
|
1063
|
+
preprocess(globParts) {
|
|
1064
|
+
if (this.options.noglobstar) {
|
|
1065
|
+
for (let i = 0; i < globParts.length; i++) {
|
|
1066
|
+
for (let j = 0; j < globParts[i].length; j++) {
|
|
1067
|
+
if (globParts[i][j] === "**") {
|
|
1068
|
+
globParts[i][j] = "*";
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
const { optimizationLevel = 1 } = this.options;
|
|
1074
|
+
if (optimizationLevel >= 2) {
|
|
1075
|
+
globParts = this.firstPhasePreProcess(globParts);
|
|
1076
|
+
globParts = this.secondPhasePreProcess(globParts);
|
|
1077
|
+
} else if (optimizationLevel >= 1) {
|
|
1078
|
+
globParts = this.levelOneOptimize(globParts);
|
|
1079
|
+
} else {
|
|
1080
|
+
globParts = this.adjascentGlobstarOptimize(globParts);
|
|
1081
|
+
}
|
|
1082
|
+
return globParts;
|
|
1083
|
+
}
|
|
1084
|
+
// just get rid of adjascent ** portions
|
|
1085
|
+
adjascentGlobstarOptimize(globParts) {
|
|
1086
|
+
return globParts.map((parts) => {
|
|
1087
|
+
let gs = -1;
|
|
1088
|
+
while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
|
|
1089
|
+
let i = gs;
|
|
1090
|
+
while (parts[i + 1] === "**") {
|
|
1091
|
+
i++;
|
|
1092
|
+
}
|
|
1093
|
+
if (i !== gs) {
|
|
1094
|
+
parts.splice(gs, i - gs);
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
return parts;
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
// get rid of adjascent ** and resolve .. portions
|
|
1101
|
+
levelOneOptimize(globParts) {
|
|
1102
|
+
return globParts.map((parts) => {
|
|
1103
|
+
parts = parts.reduce((set, part) => {
|
|
1104
|
+
const prev = set[set.length - 1];
|
|
1105
|
+
if (part === "**" && prev === "**") {
|
|
1106
|
+
return set;
|
|
1107
|
+
}
|
|
1108
|
+
if (part === "..") {
|
|
1109
|
+
if (prev && prev !== ".." && prev !== "." && prev !== "**") {
|
|
1110
|
+
set.pop();
|
|
1111
|
+
return set;
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
set.push(part);
|
|
1115
|
+
return set;
|
|
1116
|
+
}, []);
|
|
1117
|
+
return parts.length === 0 ? [""] : parts;
|
|
1118
|
+
});
|
|
1119
|
+
}
|
|
1120
|
+
levelTwoFileOptimize(parts) {
|
|
1121
|
+
if (!Array.isArray(parts)) {
|
|
1122
|
+
parts = this.slashSplit(parts);
|
|
1123
|
+
}
|
|
1124
|
+
let didSomething = false;
|
|
1125
|
+
do {
|
|
1126
|
+
didSomething = false;
|
|
1127
|
+
if (!this.preserveMultipleSlashes) {
|
|
1128
|
+
for (let i = 1; i < parts.length - 1; i++) {
|
|
1129
|
+
const p = parts[i];
|
|
1130
|
+
if (i === 1 && p === "" && parts[0] === "")
|
|
1131
|
+
continue;
|
|
1132
|
+
if (p === "." || p === "") {
|
|
1133
|
+
didSomething = true;
|
|
1134
|
+
parts.splice(i, 1);
|
|
1135
|
+
i--;
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
|
|
1139
|
+
didSomething = true;
|
|
1140
|
+
parts.pop();
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
let dd = 0;
|
|
1144
|
+
while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
|
|
1145
|
+
const p = parts[dd - 1];
|
|
1146
|
+
if (p && p !== "." && p !== ".." && p !== "**") {
|
|
1147
|
+
didSomething = true;
|
|
1148
|
+
parts.splice(dd - 1, 2);
|
|
1149
|
+
dd -= 2;
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
} while (didSomething);
|
|
1153
|
+
return parts.length === 0 ? [""] : parts;
|
|
1154
|
+
}
|
|
1155
|
+
// First phase: single-pattern processing
|
|
1156
|
+
// <pre> is 1 or more portions
|
|
1157
|
+
// <rest> is 1 or more portions
|
|
1158
|
+
// <p> is any portion other than ., .., '', or **
|
|
1159
|
+
// <e> is . or ''
|
|
1160
|
+
//
|
|
1161
|
+
// **/.. is *brutal* for filesystem walking performance, because
|
|
1162
|
+
// it effectively resets the recursive walk each time it occurs,
|
|
1163
|
+
// and ** cannot be reduced out by a .. pattern part like a regexp
|
|
1164
|
+
// or most strings (other than .., ., and '') can be.
|
|
1165
|
+
//
|
|
1166
|
+
// <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
|
|
1167
|
+
// <pre>/<e>/<rest> -> <pre>/<rest>
|
|
1168
|
+
// <pre>/<p>/../<rest> -> <pre>/<rest>
|
|
1169
|
+
// **/**/<rest> -> **/<rest>
|
|
1170
|
+
//
|
|
1171
|
+
// **/*/<rest> -> */**/<rest> <== not valid because ** doesn't follow
|
|
1172
|
+
// this WOULD be allowed if ** did follow symlinks, or * didn't
|
|
1173
|
+
firstPhasePreProcess(globParts) {
|
|
1174
|
+
let didSomething = false;
|
|
1175
|
+
do {
|
|
1176
|
+
didSomething = false;
|
|
1177
|
+
for (let parts of globParts) {
|
|
1178
|
+
let gs = -1;
|
|
1179
|
+
while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
|
|
1180
|
+
let gss = gs;
|
|
1181
|
+
while (parts[gss + 1] === "**") {
|
|
1182
|
+
gss++;
|
|
1183
|
+
}
|
|
1184
|
+
if (gss > gs) {
|
|
1185
|
+
parts.splice(gs + 1, gss - gs);
|
|
1186
|
+
}
|
|
1187
|
+
let next = parts[gs + 1];
|
|
1188
|
+
const p = parts[gs + 2];
|
|
1189
|
+
const p2 = parts[gs + 3];
|
|
1190
|
+
if (next !== "..")
|
|
1191
|
+
continue;
|
|
1192
|
+
if (!p || p === "." || p === ".." || !p2 || p2 === "." || p2 === "..") {
|
|
1193
|
+
continue;
|
|
1194
|
+
}
|
|
1195
|
+
didSomething = true;
|
|
1196
|
+
parts.splice(gs, 1);
|
|
1197
|
+
const other = parts.slice(0);
|
|
1198
|
+
other[gs] = "**";
|
|
1199
|
+
globParts.push(other);
|
|
1200
|
+
gs--;
|
|
1201
|
+
}
|
|
1202
|
+
if (!this.preserveMultipleSlashes) {
|
|
1203
|
+
for (let i = 1; i < parts.length - 1; i++) {
|
|
1204
|
+
const p = parts[i];
|
|
1205
|
+
if (i === 1 && p === "" && parts[0] === "")
|
|
1206
|
+
continue;
|
|
1207
|
+
if (p === "." || p === "") {
|
|
1208
|
+
didSomething = true;
|
|
1209
|
+
parts.splice(i, 1);
|
|
1210
|
+
i--;
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
|
|
1214
|
+
didSomething = true;
|
|
1215
|
+
parts.pop();
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
let dd = 0;
|
|
1219
|
+
while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
|
|
1220
|
+
const p = parts[dd - 1];
|
|
1221
|
+
if (p && p !== "." && p !== ".." && p !== "**") {
|
|
1222
|
+
didSomething = true;
|
|
1223
|
+
const needDot = dd === 1 && parts[dd + 1] === "**";
|
|
1224
|
+
const splin = needDot ? ["."] : [];
|
|
1225
|
+
parts.splice(dd - 1, 2, ...splin);
|
|
1226
|
+
if (parts.length === 0)
|
|
1227
|
+
parts.push("");
|
|
1228
|
+
dd -= 2;
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
} while (didSomething);
|
|
1233
|
+
return globParts;
|
|
1234
|
+
}
|
|
1235
|
+
// second phase: multi-pattern dedupes
|
|
1236
|
+
// {<pre>/*/<rest>,<pre>/<p>/<rest>} -> <pre>/*/<rest>
|
|
1237
|
+
// {<pre>/<rest>,<pre>/<rest>} -> <pre>/<rest>
|
|
1238
|
+
// {<pre>/**/<rest>,<pre>/<rest>} -> <pre>/**/<rest>
|
|
1239
|
+
//
|
|
1240
|
+
// {<pre>/**/<rest>,<pre>/**/<p>/<rest>} -> <pre>/**/<rest>
|
|
1241
|
+
// ^-- not valid because ** doens't follow symlinks
|
|
1242
|
+
secondPhasePreProcess(globParts) {
|
|
1243
|
+
for (let i = 0; i < globParts.length - 1; i++) {
|
|
1244
|
+
for (let j = i + 1; j < globParts.length; j++) {
|
|
1245
|
+
const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
|
|
1246
|
+
if (matched) {
|
|
1247
|
+
globParts[i] = [];
|
|
1248
|
+
globParts[j] = matched;
|
|
1249
|
+
break;
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
return globParts.filter((gs) => gs.length);
|
|
1254
|
+
}
|
|
1255
|
+
partsMatch(a, b, emptyGSMatch = false) {
|
|
1256
|
+
let ai = 0;
|
|
1257
|
+
let bi = 0;
|
|
1258
|
+
let result = [];
|
|
1259
|
+
let which = "";
|
|
1260
|
+
while (ai < a.length && bi < b.length) {
|
|
1261
|
+
if (a[ai] === b[bi]) {
|
|
1262
|
+
result.push(which === "b" ? b[bi] : a[ai]);
|
|
1263
|
+
ai++;
|
|
1264
|
+
bi++;
|
|
1265
|
+
} else if (emptyGSMatch && a[ai] === "**" && b[bi] === a[ai + 1]) {
|
|
1266
|
+
result.push(a[ai]);
|
|
1267
|
+
ai++;
|
|
1268
|
+
} else if (emptyGSMatch && b[bi] === "**" && a[ai] === b[bi + 1]) {
|
|
1269
|
+
result.push(b[bi]);
|
|
1270
|
+
bi++;
|
|
1271
|
+
} else if (a[ai] === "*" && b[bi] && (this.options.dot || !b[bi].startsWith(".")) && b[bi] !== "**") {
|
|
1272
|
+
if (which === "b")
|
|
1273
|
+
return false;
|
|
1274
|
+
which = "a";
|
|
1275
|
+
result.push(a[ai]);
|
|
1276
|
+
ai++;
|
|
1277
|
+
bi++;
|
|
1278
|
+
} else if (b[bi] === "*" && a[ai] && (this.options.dot || !a[ai].startsWith(".")) && a[ai] !== "**") {
|
|
1279
|
+
if (which === "a")
|
|
1280
|
+
return false;
|
|
1281
|
+
which = "b";
|
|
1282
|
+
result.push(b[bi]);
|
|
1283
|
+
ai++;
|
|
1284
|
+
bi++;
|
|
1285
|
+
} else {
|
|
1286
|
+
return false;
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
return a.length === b.length && result;
|
|
1290
|
+
}
|
|
1291
|
+
parseNegate() {
|
|
1292
|
+
if (this.nonegate)
|
|
1293
|
+
return;
|
|
1294
|
+
const pattern = this.pattern;
|
|
1295
|
+
let negate = false;
|
|
1296
|
+
let negateOffset = 0;
|
|
1297
|
+
for (let i = 0; i < pattern.length && pattern.charAt(i) === "!"; i++) {
|
|
1298
|
+
negate = !negate;
|
|
1299
|
+
negateOffset++;
|
|
1300
|
+
}
|
|
1301
|
+
if (negateOffset)
|
|
1302
|
+
this.pattern = pattern.slice(negateOffset);
|
|
1303
|
+
this.negate = negate;
|
|
1304
|
+
}
|
|
1305
|
+
// set partial to true to test if, for example,
|
|
1306
|
+
// "/a/b" matches the start of "/*/b/*/d"
|
|
1307
|
+
// Partial means, if you run out of file before you run
|
|
1308
|
+
// out of pattern, then that's fine, as long as all
|
|
1309
|
+
// the parts match.
|
|
1310
|
+
matchOne(file, pattern, partial = false) {
|
|
1311
|
+
const options = this.options;
|
|
1312
|
+
if (this.isWindows) {
|
|
1313
|
+
const fileDrive = typeof file[0] === "string" && /^[a-z]:$/i.test(file[0]);
|
|
1314
|
+
const fileUNC = !fileDrive && file[0] === "" && file[1] === "" && file[2] === "?" && /^[a-z]:$/i.test(file[3]);
|
|
1315
|
+
const patternDrive = typeof pattern[0] === "string" && /^[a-z]:$/i.test(pattern[0]);
|
|
1316
|
+
const patternUNC = !patternDrive && pattern[0] === "" && pattern[1] === "" && pattern[2] === "?" && typeof pattern[3] === "string" && /^[a-z]:$/i.test(pattern[3]);
|
|
1317
|
+
const fdi = fileUNC ? 3 : fileDrive ? 0 : void 0;
|
|
1318
|
+
const pdi = patternUNC ? 3 : patternDrive ? 0 : void 0;
|
|
1319
|
+
if (typeof fdi === "number" && typeof pdi === "number") {
|
|
1320
|
+
const [fd, pd] = [file[fdi], pattern[pdi]];
|
|
1321
|
+
if (fd.toLowerCase() === pd.toLowerCase()) {
|
|
1322
|
+
pattern[pdi] = fd;
|
|
1323
|
+
if (pdi > fdi) {
|
|
1324
|
+
pattern = pattern.slice(pdi);
|
|
1325
|
+
} else if (fdi > pdi) {
|
|
1326
|
+
file = file.slice(fdi);
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
const { optimizationLevel = 1 } = this.options;
|
|
1332
|
+
if (optimizationLevel >= 2) {
|
|
1333
|
+
file = this.levelTwoFileOptimize(file);
|
|
1334
|
+
}
|
|
1335
|
+
this.debug("matchOne", this, { file, pattern });
|
|
1336
|
+
this.debug("matchOne", file.length, pattern.length);
|
|
1337
|
+
for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
|
|
1338
|
+
this.debug("matchOne loop");
|
|
1339
|
+
var p = pattern[pi];
|
|
1340
|
+
var f = file[fi];
|
|
1341
|
+
this.debug(pattern, p, f);
|
|
1342
|
+
if (p === false) {
|
|
1343
|
+
return false;
|
|
1344
|
+
}
|
|
1345
|
+
if (p === GLOBSTAR) {
|
|
1346
|
+
this.debug("GLOBSTAR", [pattern, p, f]);
|
|
1347
|
+
var fr = fi;
|
|
1348
|
+
var pr = pi + 1;
|
|
1349
|
+
if (pr === pl) {
|
|
1350
|
+
this.debug("** at the end");
|
|
1351
|
+
for (; fi < fl; fi++) {
|
|
1352
|
+
if (file[fi] === "." || file[fi] === ".." || !options.dot && file[fi].charAt(0) === ".")
|
|
1353
|
+
return false;
|
|
1354
|
+
}
|
|
1355
|
+
return true;
|
|
1356
|
+
}
|
|
1357
|
+
while (fr < fl) {
|
|
1358
|
+
var swallowee = file[fr];
|
|
1359
|
+
this.debug("\nglobstar while", file, fr, pattern, pr, swallowee);
|
|
1360
|
+
if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
|
|
1361
|
+
this.debug("globstar found match!", fr, fl, swallowee);
|
|
1362
|
+
return true;
|
|
1363
|
+
} else {
|
|
1364
|
+
if (swallowee === "." || swallowee === ".." || !options.dot && swallowee.charAt(0) === ".") {
|
|
1365
|
+
this.debug("dot detected!", file, fr, pattern, pr);
|
|
1366
|
+
break;
|
|
1367
|
+
}
|
|
1368
|
+
this.debug("globstar swallow a segment, and continue");
|
|
1369
|
+
fr++;
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
if (partial) {
|
|
1373
|
+
this.debug("\n>>> no match, partial?", file, fr, pattern, pr);
|
|
1374
|
+
if (fr === fl) {
|
|
1375
|
+
return true;
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
return false;
|
|
1379
|
+
}
|
|
1380
|
+
let hit;
|
|
1381
|
+
if (typeof p === "string") {
|
|
1382
|
+
hit = f === p;
|
|
1383
|
+
this.debug("string match", p, f, hit);
|
|
1384
|
+
} else {
|
|
1385
|
+
hit = p.test(f);
|
|
1386
|
+
this.debug("pattern match", p, f, hit);
|
|
1387
|
+
}
|
|
1388
|
+
if (!hit)
|
|
1389
|
+
return false;
|
|
1390
|
+
}
|
|
1391
|
+
if (fi === fl && pi === pl) {
|
|
1392
|
+
return true;
|
|
1393
|
+
} else if (fi === fl) {
|
|
1394
|
+
return partial;
|
|
1395
|
+
} else if (pi === pl) {
|
|
1396
|
+
return fi === fl - 1 && file[fi] === "";
|
|
1397
|
+
} else {
|
|
1398
|
+
throw new Error("wtf?");
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
braceExpand() {
|
|
1402
|
+
return braceExpand(this.pattern, this.options);
|
|
1403
|
+
}
|
|
1404
|
+
parse(pattern) {
|
|
1405
|
+
assertValidPattern(pattern);
|
|
1406
|
+
const options = this.options;
|
|
1407
|
+
if (pattern === "**")
|
|
1408
|
+
return GLOBSTAR;
|
|
1409
|
+
if (pattern === "")
|
|
1410
|
+
return "";
|
|
1411
|
+
let m;
|
|
1412
|
+
let fastTest = null;
|
|
1413
|
+
if (m = pattern.match(starRE)) {
|
|
1414
|
+
fastTest = options.dot ? starTestDot : starTest;
|
|
1415
|
+
} else if (m = pattern.match(starDotExtRE)) {
|
|
1416
|
+
fastTest = (options.nocase ? options.dot ? starDotExtTestNocaseDot : starDotExtTestNocase : options.dot ? starDotExtTestDot : starDotExtTest)(m[1]);
|
|
1417
|
+
} else if (m = pattern.match(qmarksRE)) {
|
|
1418
|
+
fastTest = (options.nocase ? options.dot ? qmarksTestNocaseDot : qmarksTestNocase : options.dot ? qmarksTestDot : qmarksTest)(m);
|
|
1419
|
+
} else if (m = pattern.match(starDotStarRE)) {
|
|
1420
|
+
fastTest = options.dot ? starDotStarTestDot : starDotStarTest;
|
|
1421
|
+
} else if (m = pattern.match(dotStarRE)) {
|
|
1422
|
+
fastTest = dotStarTest;
|
|
1423
|
+
}
|
|
1424
|
+
const re = AST.fromGlob(pattern, this.options).toMMPattern();
|
|
1425
|
+
if (fastTest && typeof re === "object") {
|
|
1426
|
+
Reflect.defineProperty(re, "test", { value: fastTest });
|
|
1427
|
+
}
|
|
1428
|
+
return re;
|
|
1429
|
+
}
|
|
1430
|
+
makeRe() {
|
|
1431
|
+
if (this.regexp || this.regexp === false)
|
|
1432
|
+
return this.regexp;
|
|
1433
|
+
const set = this.set;
|
|
1434
|
+
if (!set.length) {
|
|
1435
|
+
this.regexp = false;
|
|
1436
|
+
return this.regexp;
|
|
1437
|
+
}
|
|
1438
|
+
const options = this.options;
|
|
1439
|
+
const twoStar = options.noglobstar ? star2 : options.dot ? twoStarDot : twoStarNoDot;
|
|
1440
|
+
const flags = new Set(options.nocase ? ["i"] : []);
|
|
1441
|
+
let re = set.map((pattern) => {
|
|
1442
|
+
const pp = pattern.map((p) => {
|
|
1443
|
+
if (p instanceof RegExp) {
|
|
1444
|
+
for (const f of p.flags.split(""))
|
|
1445
|
+
flags.add(f);
|
|
1446
|
+
}
|
|
1447
|
+
return typeof p === "string" ? regExpEscape2(p) : p === GLOBSTAR ? GLOBSTAR : p._src;
|
|
1448
|
+
});
|
|
1449
|
+
pp.forEach((p, i) => {
|
|
1450
|
+
const next = pp[i + 1];
|
|
1451
|
+
const prev = pp[i - 1];
|
|
1452
|
+
if (p !== GLOBSTAR || prev === GLOBSTAR) {
|
|
1453
|
+
return;
|
|
1454
|
+
}
|
|
1455
|
+
if (prev === void 0) {
|
|
1456
|
+
if (next !== void 0 && next !== GLOBSTAR) {
|
|
1457
|
+
pp[i + 1] = "(?:\\/|" + twoStar + "\\/)?" + next;
|
|
1458
|
+
} else {
|
|
1459
|
+
pp[i] = twoStar;
|
|
1460
|
+
}
|
|
1461
|
+
} else if (next === void 0) {
|
|
1462
|
+
pp[i - 1] = prev + "(?:\\/|" + twoStar + ")?";
|
|
1463
|
+
} else if (next !== GLOBSTAR) {
|
|
1464
|
+
pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + "\\/)" + next;
|
|
1465
|
+
pp[i + 1] = GLOBSTAR;
|
|
1466
|
+
}
|
|
1467
|
+
});
|
|
1468
|
+
return pp.filter((p) => p !== GLOBSTAR).join("/");
|
|
1469
|
+
}).join("|");
|
|
1470
|
+
const [open, close] = set.length > 1 ? ["(?:", ")"] : ["", ""];
|
|
1471
|
+
re = "^" + open + re + close + "$";
|
|
1472
|
+
if (this.negate)
|
|
1473
|
+
re = "^(?!" + re + ").+$";
|
|
1474
|
+
try {
|
|
1475
|
+
this.regexp = new RegExp(re, [...flags].join(""));
|
|
1476
|
+
} catch (ex) {
|
|
1477
|
+
this.regexp = false;
|
|
1478
|
+
}
|
|
1479
|
+
return this.regexp;
|
|
1480
|
+
}
|
|
1481
|
+
slashSplit(p) {
|
|
1482
|
+
if (this.preserveMultipleSlashes) {
|
|
1483
|
+
return p.split("/");
|
|
1484
|
+
} else if (this.isWindows && /^\/\/[^\/]+/.test(p)) {
|
|
1485
|
+
return ["", ...p.split(/\/+/)];
|
|
1486
|
+
} else {
|
|
1487
|
+
return p.split(/\/+/);
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
match(f, partial = this.partial) {
|
|
1491
|
+
this.debug("match", f, this.pattern);
|
|
1492
|
+
if (this.comment) {
|
|
1493
|
+
return false;
|
|
1494
|
+
}
|
|
1495
|
+
if (this.empty) {
|
|
1496
|
+
return f === "";
|
|
1497
|
+
}
|
|
1498
|
+
if (f === "/" && partial) {
|
|
1499
|
+
return true;
|
|
1500
|
+
}
|
|
1501
|
+
const options = this.options;
|
|
1502
|
+
if (this.isWindows) {
|
|
1503
|
+
f = f.split("\\").join("/");
|
|
1504
|
+
}
|
|
1505
|
+
const ff = this.slashSplit(f);
|
|
1506
|
+
this.debug(this.pattern, "split", ff);
|
|
1507
|
+
const set = this.set;
|
|
1508
|
+
this.debug(this.pattern, "set", set);
|
|
1509
|
+
let filename = ff[ff.length - 1];
|
|
1510
|
+
if (!filename) {
|
|
1511
|
+
for (let i = ff.length - 2; !filename && i >= 0; i--) {
|
|
1512
|
+
filename = ff[i];
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
for (let i = 0; i < set.length; i++) {
|
|
1516
|
+
const pattern = set[i];
|
|
1517
|
+
let file = ff;
|
|
1518
|
+
if (options.matchBase && pattern.length === 1) {
|
|
1519
|
+
file = [filename];
|
|
1520
|
+
}
|
|
1521
|
+
const hit = this.matchOne(file, pattern, partial);
|
|
1522
|
+
if (hit) {
|
|
1523
|
+
if (options.flipNegate) {
|
|
1524
|
+
return true;
|
|
1525
|
+
}
|
|
1526
|
+
return !this.negate;
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
if (options.flipNegate) {
|
|
1530
|
+
return false;
|
|
1531
|
+
}
|
|
1532
|
+
return this.negate;
|
|
1533
|
+
}
|
|
1534
|
+
static defaults(def) {
|
|
1535
|
+
return minimatch.defaults(def).Minimatch;
|
|
1536
|
+
}
|
|
1537
|
+
};
|
|
1538
|
+
minimatch.AST = AST;
|
|
1539
|
+
minimatch.Minimatch = Minimatch;
|
|
1540
|
+
minimatch.escape = escape;
|
|
1541
|
+
minimatch.unescape = unescape;
|
|
1542
|
+
|
|
1543
|
+
// ../agent/dist/chunk-KTNYN62L.js
|
|
1544
|
+
var Glob;
|
|
1545
|
+
((Glob2) => {
|
|
1546
|
+
async function scan(context, pattern, options = {}) {
|
|
1547
|
+
return context.fs.glob(pattern, {
|
|
1548
|
+
cwd: options.cwd,
|
|
1549
|
+
absolute: options.absolute,
|
|
1550
|
+
dot: options.dot,
|
|
1551
|
+
follow: options.symlink ?? false,
|
|
1552
|
+
nodir: options.include !== "all"
|
|
1553
|
+
});
|
|
1554
|
+
}
|
|
1555
|
+
Glob2.scan = scan;
|
|
1556
|
+
function match2(pattern, filepath) {
|
|
1557
|
+
return minimatch(filepath, pattern, { dot: true });
|
|
1558
|
+
}
|
|
1559
|
+
Glob2.match = match2;
|
|
1560
|
+
})(Glob || (Glob = {}));
|
|
1561
|
+
|
|
1562
|
+
export {
|
|
1563
|
+
Glob
|
|
1564
|
+
};
|