@opendesign-plus-test/plugins 0.0.1-rc.24 → 0.0.1-rc.25

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.
@@ -1,1375 +0,0 @@
1
- var Ut = Object.defineProperty;
2
- var yt = (i) => {
3
- throw TypeError(i);
4
- };
5
- var Zt = (i, t, e) => t in i ? Ut(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
6
- var T = (i, t, e) => Zt(i, typeof t != "symbol" ? t + "" : t, e), ct = (i, t, e) => t.has(i) || yt("Cannot " + e);
7
- var o = (i, t, e) => (ct(i, t, "read from private field"), e ? e.call(i) : t.get(i)), R = (i, t, e) => t.has(i) ? yt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(i) : t.set(i, e), S = (i, t, e, s) => (ct(i, t, "write to private field"), s ? s.call(i, e) : t.set(i, e), e), x = (i, t, e) => (ct(i, t, "access private method"), e);
8
- var lt = (i, t, e, s) => ({
9
- set _(n) {
10
- S(i, t, n, e);
11
- },
12
- get _() {
13
- return o(i, t, s);
14
- }
15
- });
16
- import Ht, { resolve as Jt } from "node:path";
17
- import { exec as Vt } from "node:child_process";
18
- import { writeFileSync as Xt } from "node:fs";
19
- import { promisify as Qt } from "node:util";
20
- const Ot = (i, t, e) => {
21
- const s = i instanceof RegExp ? wt(i, e) : i, n = t instanceof RegExp ? wt(t, e) : t, r = s !== null && n != null && Kt(s, n, e);
22
- return r && {
23
- start: r[0],
24
- end: r[1],
25
- pre: e.slice(0, r[0]),
26
- body: e.slice(r[0] + s.length, r[1]),
27
- post: e.slice(r[1] + n.length)
28
- };
29
- }, wt = (i, t) => {
30
- const e = t.match(i);
31
- return e ? e[0] : null;
32
- }, Kt = (i, t, e) => {
33
- let s, n, r, c, a, p = e.indexOf(i), h = e.indexOf(t, p + 1), f = p;
34
- if (p >= 0 && h > 0) {
35
- if (i === t)
36
- return [p, h];
37
- for (s = [], r = e.length; f >= 0 && !a; ) {
38
- if (f === p)
39
- s.push(f), p = e.indexOf(i, f + 1);
40
- else if (s.length === 1) {
41
- const l = s.pop();
42
- l !== void 0 && (a = [l, h]);
43
- } else
44
- n = s.pop(), n !== void 0 && n < r && (r = n, c = h), h = e.indexOf(t, f + 1);
45
- f = p < h && p >= 0 ? p : h;
46
- }
47
- s.length && c !== void 0 && (a = [r, c]);
48
- }
49
- return a;
50
- }, Tt = "\0SLASH" + Math.random() + "\0", vt = "\0OPEN" + Math.random() + "\0", dt = "\0CLOSE" + Math.random() + "\0", Rt = "\0COMMA" + Math.random() + "\0", Pt = "\0PERIOD" + Math.random() + "\0", Yt = new RegExp(Tt, "g"), te = new RegExp(vt, "g"), ee = new RegExp(dt, "g"), se = new RegExp(Rt, "g"), ne = new RegExp(Pt, "g"), ie = /\\\\/g, re = /\\{/g, oe = /\\}/g, ce = /\\,/g, le = /\\\./g, he = 1e5;
51
- function ht(i) {
52
- return isNaN(i) ? i.charCodeAt(0) : parseInt(i, 10);
53
- }
54
- function ae(i) {
55
- return i.replace(ie, Tt).replace(re, vt).replace(oe, dt).replace(ce, Rt).replace(le, Pt);
56
- }
57
- function fe(i) {
58
- return i.replace(Yt, "\\").replace(te, "{").replace(ee, "}").replace(se, ",").replace(ne, ".");
59
- }
60
- function jt(i) {
61
- if (!i)
62
- return [""];
63
- const t = [], e = Ot("{", "}", i);
64
- if (!e)
65
- return i.split(",");
66
- const { pre: s, body: n, post: r } = e, c = s.split(",");
67
- c[c.length - 1] += "{" + n + "}";
68
- const a = jt(r);
69
- return r.length && (c[c.length - 1] += a.shift(), c.push.apply(c, a)), t.push.apply(t, c), t;
70
- }
71
- function ue(i, t = {}) {
72
- if (!i)
73
- return [];
74
- const { max: e = he } = t;
75
- return i.slice(0, 2) === "{}" && (i = "\\{\\}" + i.slice(2)), K(ae(i), e, !0).map(fe);
76
- }
77
- function pe(i) {
78
- return "{" + i + "}";
79
- }
80
- function ge(i) {
81
- return /^-?0\d/.test(i);
82
- }
83
- function de(i, t) {
84
- return i <= t;
85
- }
86
- function me(i, t) {
87
- return i >= t;
88
- }
89
- function K(i, t, e) {
90
- const s = [], n = Ot("{", "}", i);
91
- if (!n)
92
- return [i];
93
- const r = n.pre, c = n.post.length ? K(n.post, t, !1) : [""];
94
- if (/\$$/.test(n.pre))
95
- for (let a = 0; a < c.length && a < t; a++) {
96
- const p = r + "{" + n.body + "}" + c[a];
97
- s.push(p);
98
- }
99
- else {
100
- const a = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body), p = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body), h = a || p, f = n.body.indexOf(",") >= 0;
101
- if (!h && !f)
102
- return n.post.match(/,(?!,).*\}/) ? (i = n.pre + "{" + n.body + dt + n.post, K(i, t, !0)) : [i];
103
- let l;
104
- if (h)
105
- l = n.body.split(/\.\./);
106
- else if (l = jt(n.body), l.length === 1 && l[0] !== void 0 && (l = K(l[0], t, !1).map(pe), l.length === 1))
107
- return c.map((g) => n.pre + l[0] + g);
108
- let u;
109
- if (h && l[0] !== void 0 && l[1] !== void 0) {
110
- const g = ht(l[0]), y = ht(l[1]), E = Math.max(l[0].length, l[1].length);
111
- let w = l.length === 3 && l[2] !== void 0 ? Math.max(Math.abs(ht(l[2])), 1) : 1, b = de;
112
- y < g && (w *= -1, b = me);
113
- const d = l.some(ge);
114
- u = [];
115
- for (let $ = g; b($, y); $ += w) {
116
- let N;
117
- if (p)
118
- N = String.fromCharCode($), N === "\\" && (N = "");
119
- else if (N = String($), d) {
120
- const H = E - N.length;
121
- if (H > 0) {
122
- const X = new Array(H + 1).join("0");
123
- $ < 0 ? N = "-" + X + N.slice(1) : N = X + N;
124
- }
125
- }
126
- u.push(N);
127
- }
128
- } else {
129
- u = [];
130
- for (let g = 0; g < l.length; g++)
131
- u.push.apply(u, K(l[g], t, !1));
132
- }
133
- for (let g = 0; g < u.length; g++)
134
- for (let y = 0; y < c.length && s.length < t; y++) {
135
- const E = r + u[g] + c[y];
136
- (!e || h || E) && s.push(E);
137
- }
138
- }
139
- return s;
140
- }
141
- const ye = 1024 * 64, it = (i) => {
142
- if (typeof i != "string")
143
- throw new TypeError("invalid pattern");
144
- if (i.length > ye)
145
- throw new TypeError("pattern is too long");
146
- }, we = {
147
- "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", !0],
148
- "[:alpha:]": ["\\p{L}\\p{Nl}", !0],
149
- "[:ascii:]": ["\\x00-\\x7f", !1],
150
- "[:blank:]": ["\\p{Zs}\\t", !0],
151
- "[:cntrl:]": ["\\p{Cc}", !0],
152
- "[:digit:]": ["\\p{Nd}", !0],
153
- "[:graph:]": ["\\p{Z}\\p{C}", !0, !0],
154
- "[:lower:]": ["\\p{Ll}", !0],
155
- "[:print:]": ["\\p{C}", !0],
156
- "[:punct:]": ["\\p{P}", !0],
157
- "[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", !0],
158
- "[:upper:]": ["\\p{Lu}", !0],
159
- "[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", !0],
160
- "[:xdigit:]": ["A-Fa-f0-9", !1]
161
- }, Q = (i) => i.replace(/[[\]\\-]/g, "\\$&"), Se = (i) => i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), St = (i) => i.join(""), Ee = (i, t) => {
162
- const e = t;
163
- if (i.charAt(e) !== "[")
164
- throw new Error("not in a brace expression");
165
- const s = [], n = [];
166
- let r = e + 1, c = !1, a = !1, p = !1, h = !1, f = e, l = "";
167
- t: for (; r < i.length; ) {
168
- const E = i.charAt(r);
169
- if ((E === "!" || E === "^") && r === e + 1) {
170
- h = !0, r++;
171
- continue;
172
- }
173
- if (E === "]" && c && !p) {
174
- f = r + 1;
175
- break;
176
- }
177
- if (c = !0, E === "\\" && !p) {
178
- p = !0, r++;
179
- continue;
180
- }
181
- if (E === "[" && !p) {
182
- for (const [w, [b, A, d]] of Object.entries(we))
183
- if (i.startsWith(w, r)) {
184
- if (l)
185
- return ["$.", !1, i.length - e, !0];
186
- r += w.length, d ? n.push(b) : s.push(b), a = a || A;
187
- continue t;
188
- }
189
- }
190
- if (p = !1, l) {
191
- E > l ? s.push(Q(l) + "-" + Q(E)) : E === l && s.push(Q(E)), l = "", r++;
192
- continue;
193
- }
194
- if (i.startsWith("-]", r + 1)) {
195
- s.push(Q(E + "-")), r += 2;
196
- continue;
197
- }
198
- if (i.startsWith("-", r + 1)) {
199
- l = E, r += 2;
200
- continue;
201
- }
202
- s.push(Q(E)), r++;
203
- }
204
- if (f < r)
205
- return ["", !1, 0, !1];
206
- if (!s.length && !n.length)
207
- return ["$.", !1, i.length - e, !0];
208
- if (n.length === 0 && s.length === 1 && /^\\?.$/.test(s[0]) && !h) {
209
- const E = s[0].length === 2 ? s[0].slice(-1) : s[0];
210
- return [Se(E), !1, f - e, !1];
211
- }
212
- const u = "[" + (h ? "^" : "") + St(s) + "]", g = "[" + (h ? "" : "^") + St(n) + "]";
213
- return [s.length && n.length ? "(" + u + "|" + g + ")" : s.length ? u : g, a, f - e, !0];
214
- }, Y = (i, { windowsPathsNoEscape: t = !1, magicalBraces: e = !0 } = {}) => e ? t ? i.replace(/\[([^/\\])\]/g, "$1") : i.replace(/((?!\\).|^)\[([^/\\])\]/g, "$1$2").replace(/\\([^/])/g, "$1") : t ? i.replace(/\[([^/\\{}])\]/g, "$1") : i.replace(/((?!\\).|^)\[([^/\\{}])\]/g, "$1$2").replace(/\\([^/{}])/g, "$1");
215
- var W;
216
- const be = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), at = (i) => be.has(i), Et = (i) => at(i.type), xe = /* @__PURE__ */ new Map([
217
- ["!", ["@"]],
218
- ["?", ["?", "@"]],
219
- ["@", ["@"]],
220
- ["*", ["*", "+", "?", "@"]],
221
- ["+", ["+", "@"]]
222
- ]), Me = /* @__PURE__ */ new Map([
223
- ["!", ["?"]],
224
- ["@", ["?"]],
225
- ["+", ["?", "*"]]
226
- ]), Ne = /* @__PURE__ */ new Map([
227
- ["!", ["?", "@"]],
228
- ["?", ["?", "@"]],
229
- ["@", ["?", "@"]],
230
- ["*", ["*", "+", "?", "@"]],
231
- ["+", ["+", "@", "?", "*"]]
232
- ]), bt = /* @__PURE__ */ new Map([
233
- ["!", /* @__PURE__ */ new Map([["!", "@"]])],
234
- [
235
- "?",
236
- /* @__PURE__ */ new Map([
237
- ["*", "*"],
238
- ["+", "*"]
239
- ])
240
- ],
241
- [
242
- "@",
243
- /* @__PURE__ */ new Map([
244
- ["!", "!"],
245
- ["?", "?"],
246
- ["@", "@"],
247
- ["*", "*"],
248
- ["+", "+"]
249
- ])
250
- ],
251
- [
252
- "+",
253
- /* @__PURE__ */ new Map([
254
- ["?", "*"],
255
- ["*", "*"]
256
- ])
257
- ]
258
- ]), Ae = "(?!(?:^|/)\\.\\.?(?:$|/))", tt = "(?!\\.)", $e = /* @__PURE__ */ new Set(["[", "."]), Oe = /* @__PURE__ */ new Set(["..", "."]), Te = new Set("().*{}+?[]^$\\!"), ve = (i) => i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), mt = "[^/]", xt = mt + "*?", Mt = mt + "+?";
259
- let Re = 0;
260
- var v, P, z, m, O, G, U, F, _, q, V, M, Ct, I, et, Wt, ft, st, Dt, ut, Lt, kt, _t, nt, pt, qt;
261
- class rt {
262
- constructor(t, e, s = {}) {
263
- R(this, M);
264
- T(this, "type");
265
- R(this, v);
266
- R(this, P);
267
- R(this, z, !1);
268
- R(this, m, []);
269
- R(this, O);
270
- R(this, G);
271
- R(this, U);
272
- R(this, F, !1);
273
- R(this, _);
274
- R(this, q);
275
- // set to true if it's an extglob with no children
276
- // (which really means one child of '')
277
- R(this, V, !1);
278
- T(this, "id", ++Re);
279
- this.type = t, t && S(this, P, !0), S(this, O, e), S(this, v, o(this, O) ? o(o(this, O), v) : this), S(this, _, o(this, v) === this ? s : o(o(this, v), _)), S(this, U, o(this, v) === this ? [] : o(o(this, v), U)), t === "!" && !o(o(this, v), F) && o(this, U).push(this), S(this, G, o(this, O) ? o(o(this, O), m).length : 0);
280
- }
281
- get depth() {
282
- var t;
283
- return (((t = o(this, O)) == null ? void 0 : t.depth) ?? -1) + 1;
284
- }
285
- [Symbol.for("nodejs.util.inspect.custom")]() {
286
- var t;
287
- return {
288
- "@@type": "AST",
289
- id: this.id,
290
- type: this.type,
291
- root: o(this, v).id,
292
- parent: (t = o(this, O)) == null ? void 0 : t.id,
293
- depth: this.depth,
294
- partsLength: o(this, m).length,
295
- parts: o(this, m)
296
- };
297
- }
298
- get hasMagic() {
299
- if (o(this, P) !== void 0)
300
- return o(this, P);
301
- for (const t of o(this, m))
302
- if (typeof t != "string" && (t.type || t.hasMagic))
303
- return S(this, P, !0);
304
- return o(this, P);
305
- }
306
- // reconstructs the pattern
307
- toString() {
308
- return o(this, q) !== void 0 ? o(this, q) : this.type ? S(this, q, this.type + "(" + o(this, m).map((t) => String(t)).join("|") + ")") : S(this, q, o(this, m).map((t) => String(t)).join(""));
309
- }
310
- push(...t) {
311
- for (const e of t)
312
- if (e !== "") {
313
- if (typeof e != "string" && !(e instanceof W && o(e, O) === this))
314
- throw new Error("invalid part: " + e);
315
- o(this, m).push(e);
316
- }
317
- }
318
- toJSON() {
319
- var e;
320
- const t = this.type === null ? o(this, m).slice().map((s) => typeof s == "string" ? s : s.toJSON()) : [this.type, ...o(this, m).map((s) => s.toJSON())];
321
- return this.isStart() && !this.type && t.unshift([]), this.isEnd() && (this === o(this, v) || o(o(this, v), F) && ((e = o(this, O)) == null ? void 0 : e.type) === "!") && t.push({}), t;
322
- }
323
- isStart() {
324
- var e;
325
- if (o(this, v) === this)
326
- return !0;
327
- if (!((e = o(this, O)) != null && e.isStart()))
328
- return !1;
329
- if (o(this, G) === 0)
330
- return !0;
331
- const t = o(this, O);
332
- for (let s = 0; s < o(this, G); s++) {
333
- const n = o(t, m)[s];
334
- if (!(n instanceof W && n.type === "!"))
335
- return !1;
336
- }
337
- return !0;
338
- }
339
- isEnd() {
340
- var e, s, n;
341
- if (o(this, v) === this || ((e = o(this, O)) == null ? void 0 : e.type) === "!")
342
- return !0;
343
- if (!((s = o(this, O)) != null && s.isEnd()))
344
- return !1;
345
- if (!this.type)
346
- return (n = o(this, O)) == null ? void 0 : n.isEnd();
347
- const t = o(this, O) ? o(o(this, O), m).length : 0;
348
- return o(this, G) === t - 1;
349
- }
350
- copyIn(t) {
351
- typeof t == "string" ? this.push(t) : this.push(t.clone(this));
352
- }
353
- clone(t) {
354
- const e = new W(this.type, t);
355
- for (const s of o(this, m))
356
- e.copyIn(s);
357
- return e;
358
- }
359
- static fromGlob(t, e = {}) {
360
- var n;
361
- const s = new W(null, void 0, e);
362
- return x(n = W, I, et).call(n, t, s, 0, e, 0), s;
363
- }
364
- // returns the regular expression if there's magic, or the unescaped
365
- // string if not.
366
- toMMPattern() {
367
- if (this !== o(this, v))
368
- return o(this, v).toMMPattern();
369
- const t = this.toString(), [e, s, n, r] = this.toRegExpSource();
370
- if (!(n || o(this, P) || o(this, _).nocase && !o(this, _).nocaseMagicOnly && t.toUpperCase() !== t.toLowerCase()))
371
- return s;
372
- const a = (o(this, _).nocase ? "i" : "") + (r ? "u" : "");
373
- return Object.assign(new RegExp(`^${e}$`, a), {
374
- _src: e,
375
- _glob: t
376
- });
377
- }
378
- get options() {
379
- return o(this, _);
380
- }
381
- // returns the string match, the regexp source, whether there's magic
382
- // in the regexp (so a regular expression is required) and whether or
383
- // not the uflag is needed for the regular expression (for posix classes)
384
- // TODO: instead of injecting the start/end at this point, just return
385
- // the BODY of the regexp, along with the start/end portions suitable
386
- // for binding the start/end in either a joined full-path makeRe context
387
- // (where we bind to (^|/), or a standalone matchPart context (where
388
- // we bind to ^, and not /). Otherwise slashes get duped!
389
- //
390
- // In part-matching mode, the start is:
391
- // - if not isStart: nothing
392
- // - if traversal possible, but not allowed: ^(?!\.\.?$)
393
- // - if dots allowed or not possible: ^
394
- // - if dots possible and not allowed: ^(?!\.)
395
- // end is:
396
- // - if not isEnd(): nothing
397
- // - else: $
398
- //
399
- // In full-path matching mode, we put the slash at the START of the
400
- // pattern, so start is:
401
- // - if first pattern: same as part-matching mode
402
- // - if not isStart(): nothing
403
- // - if traversal possible, but not allowed: /(?!\.\.?(?:$|/))
404
- // - if dots allowed or not possible: /
405
- // - if dots possible and not allowed: /(?!\.)
406
- // end is:
407
- // - if last pattern, same as part-matching mode
408
- // - else nothing
409
- //
410
- // Always put the (?:$|/) on negated tails, though, because that has to be
411
- // there to bind the end of the negated pattern portion, and it's easier to
412
- // just stick it in now rather than try to inject it later in the middle of
413
- // the pattern.
414
- //
415
- // We can just always return the same end, and leave it up to the caller
416
- // to know whether it's going to be used joined or in parts.
417
- // And, if the start is adjusted slightly, can do the same there:
418
- // - if not isStart: nothing
419
- // - if traversal possible, but not allowed: (?:/|^)(?!\.\.?$)
420
- // - if dots allowed or not possible: (?:/|^)
421
- // - if dots possible and not allowed: (?:/|^)(?!\.)
422
- //
423
- // But it's better to have a simpler binding without a conditional, for
424
- // performance, so probably better to return both start options.
425
- //
426
- // Then the caller just ignores the end if it's not the first pattern,
427
- // and the start always gets applied.
428
- //
429
- // But that's always going to be $ if it's the ending pattern, or nothing,
430
- // so the caller can just attach $ at the end of the pattern when building.
431
- //
432
- // So the todo is:
433
- // - better detect what kind of start is needed
434
- // - return both flavors of starting pattern
435
- // - attach $ at the end of the pattern when creating the actual RegExp
436
- //
437
- // Ah, but wait, no, that all only applies to the root when the first pattern
438
- // is not an extglob. If the first pattern IS an extglob, then we need all
439
- // that dot prevention biz to live in the extglob portions, because eg
440
- // +(*|.x*) can match .xy but not .yx.
441
- //
442
- // So, return the two flavors if it's #root and the first child is not an
443
- // AST, otherwise leave it to the child AST to handle it, and there,
444
- // use the (?:^|/) style of start binding.
445
- //
446
- // Even simplified further:
447
- // - Since the start for a join is eg /(?!\.) and the start for a part
448
- // is ^(?!\.), we can just prepend (?!\.) to the pattern (either root
449
- // or start or whatever) and prepend ^ or / at the Regexp construction.
450
- toRegExpSource(t) {
451
- var p;
452
- const e = t ?? !!o(this, _).dot;
453
- if (o(this, v) === this && (x(this, M, nt).call(this), x(this, M, Ct).call(this)), !Et(this)) {
454
- const h = this.isStart() && this.isEnd() && !o(this, m).some((y) => typeof y != "string"), f = o(this, m).map((y) => {
455
- var d;
456
- const [E, w, b, A] = typeof y == "string" ? x(d = W, I, qt).call(d, y, o(this, P), h) : y.toRegExpSource(t);
457
- return S(this, P, o(this, P) || b), S(this, z, o(this, z) || A), E;
458
- }).join("");
459
- let l = "";
460
- if (this.isStart() && typeof o(this, m)[0] == "string" && !(o(this, m).length === 1 && Oe.has(o(this, m)[0]))) {
461
- const E = $e, w = (
462
- // dots are allowed, and the pattern starts with [ or .
463
- e && E.has(f.charAt(0)) || // the pattern starts with \., and then [ or .
464
- f.startsWith("\\.") && E.has(f.charAt(2)) || // the pattern starts with \.\., and then [ or .
465
- f.startsWith("\\.\\.") && E.has(f.charAt(4))
466
- ), b = !e && !t && E.has(f.charAt(0));
467
- l = w ? Ae : b ? tt : "";
468
- }
469
- let u = "";
470
- return this.isEnd() && o(o(this, v), F) && ((p = o(this, O)) == null ? void 0 : p.type) === "!" && (u = "(?:$|\\/)"), [
471
- l + f + u,
472
- Y(f),
473
- S(this, P, !!o(this, P)),
474
- o(this, z)
475
- ];
476
- }
477
- const s = this.type === "*" || this.type === "+", n = this.type === "!" ? "(?:(?!(?:" : "(?:";
478
- let r = x(this, M, pt).call(this, e);
479
- if (this.isStart() && this.isEnd() && !r && this.type !== "!") {
480
- const h = this.toString(), f = this;
481
- return S(f, m, [h]), f.type = null, S(f, P, void 0), [h, Y(this.toString()), !1, !1];
482
- }
483
- let c = !s || t || e || !tt ? "" : x(this, M, pt).call(this, !0);
484
- c === r && (c = ""), c && (r = `(?:${r})(?:${c})*?`);
485
- let a = "";
486
- if (this.type === "!" && o(this, V))
487
- a = (this.isStart() && !e ? tt : "") + Mt;
488
- else {
489
- const h = this.type === "!" ? (
490
- // !() must match something,but !(x) can match ''
491
- "))" + (this.isStart() && !e && !t ? tt : "") + xt + ")"
492
- ) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && c ? ")" : this.type === "*" && c ? ")?" : `)${this.type}`;
493
- a = n + r + h;
494
- }
495
- return [
496
- a,
497
- Y(r),
498
- S(this, P, !!o(this, P)),
499
- o(this, z)
500
- ];
501
- }
502
- }
503
- v = new WeakMap(), P = new WeakMap(), z = new WeakMap(), m = new WeakMap(), O = new WeakMap(), G = new WeakMap(), U = new WeakMap(), F = new WeakMap(), _ = new WeakMap(), q = new WeakMap(), V = new WeakMap(), M = new WeakSet(), Ct = function() {
504
- if (this !== o(this, v))
505
- throw new Error("should only call on root");
506
- if (o(this, F))
507
- return this;
508
- this.toString(), S(this, F, !0);
509
- let t;
510
- for (; t = o(this, U).pop(); ) {
511
- if (t.type !== "!")
512
- continue;
513
- let e = t, s = o(e, O);
514
- for (; s; ) {
515
- for (let n = o(e, G) + 1; !s.type && n < o(s, m).length; n++)
516
- for (const r of o(t, m)) {
517
- if (typeof r == "string")
518
- throw new Error("string part in extglob AST??");
519
- r.copyIn(o(s, m)[n]);
520
- }
521
- e = s, s = o(e, O);
522
- }
523
- }
524
- return this;
525
- }, I = new WeakSet(), et = function(t, e, s, n, r) {
526
- var E, w, b, A;
527
- const c = n.maxExtglobRecursion ?? 2;
528
- let a = !1, p = !1, h = -1, f = !1;
529
- if (e.type === null) {
530
- let d = s, $ = "";
531
- for (; d < t.length; ) {
532
- const N = t.charAt(d++);
533
- if (a || N === "\\") {
534
- a = !a, $ += N;
535
- continue;
536
- }
537
- if (p) {
538
- d === h + 1 ? (N === "^" || N === "!") && (f = !0) : N === "]" && !(d === h + 2 && f) && (p = !1), $ += N;
539
- continue;
540
- } else if (N === "[") {
541
- p = !0, h = d, f = !1, $ += N;
542
- continue;
543
- }
544
- if (!n.noext && at(N) && t.charAt(d) === "(" && r <= c) {
545
- e.push($), $ = "";
546
- const X = new W(N, e);
547
- d = x(E = W, I, et).call(E, t, X, d, n, r + 1), e.push(X);
548
- continue;
549
- }
550
- $ += N;
551
- }
552
- return e.push($), d;
553
- }
554
- let l = s + 1, u = new W(null, e);
555
- const g = [];
556
- let y = "";
557
- for (; l < t.length; ) {
558
- const d = t.charAt(l++);
559
- if (a || d === "\\") {
560
- a = !a, y += d;
561
- continue;
562
- }
563
- if (p) {
564
- l === h + 1 ? (d === "^" || d === "!") && (f = !0) : d === "]" && !(l === h + 2 && f) && (p = !1), y += d;
565
- continue;
566
- } else if (d === "[") {
567
- p = !0, h = l, f = !1, y += d;
568
- continue;
569
- }
570
- if (!n.noext && at(d) && t.charAt(l) === "(" && /* c8 ignore start - the maxDepth is sufficient here */
571
- (r <= c || e && x(w = e, M, st).call(w, d))) {
572
- const N = e && x(b = e, M, st).call(b, d) ? 0 : 1;
573
- u.push(y), y = "";
574
- const H = new W(d, u);
575
- u.push(H), l = x(A = W, I, et).call(A, t, H, l, n, r + N);
576
- continue;
577
- }
578
- if (d === "|") {
579
- u.push(y), y = "", g.push(u), u = new W(null, e);
580
- continue;
581
- }
582
- if (d === ")")
583
- return y === "" && o(e, m).length === 0 && S(e, V, !0), u.push(y), y = "", e.push(...g, u), l;
584
- y += d;
585
- }
586
- return e.type = null, S(e, P, void 0), S(e, m, [t.substring(s - 1)]), l;
587
- }, Wt = function(t) {
588
- return x(this, M, ft).call(this, t, Me);
589
- }, ft = function(t, e = xe) {
590
- if (!t || typeof t != "object" || t.type !== null || o(t, m).length !== 1 || this.type === null)
591
- return !1;
592
- const s = o(t, m)[0];
593
- return !s || typeof s != "object" || s.type === null ? !1 : x(this, M, st).call(this, s.type, e);
594
- }, st = function(t, e = Ne) {
595
- var s;
596
- return !!((s = e.get(this.type)) != null && s.includes(t));
597
- }, Dt = function(t, e) {
598
- const s = o(t, m)[0], n = new W(null, s, this.options);
599
- o(n, m).push(""), s.push(n), x(this, M, ut).call(this, t, e);
600
- }, ut = function(t, e) {
601
- const s = o(t, m)[0];
602
- o(this, m).splice(e, 1, ...o(s, m));
603
- for (const n of o(s, m))
604
- typeof n == "object" && S(n, O, this);
605
- S(this, q, void 0);
606
- }, Lt = function(t) {
607
- const e = bt.get(this.type);
608
- return !!(e != null && e.has(t));
609
- }, kt = function(t) {
610
- if (!t || typeof t != "object" || t.type !== null || o(t, m).length !== 1 || this.type === null || o(this, m).length !== 1)
611
- return !1;
612
- const e = o(t, m)[0];
613
- return !e || typeof e != "object" || e.type === null ? !1 : x(this, M, Lt).call(this, e.type);
614
- }, _t = function(t) {
615
- const e = bt.get(this.type), s = o(t, m)[0], n = e == null ? void 0 : e.get(s.type);
616
- if (!n)
617
- return !1;
618
- S(this, m, o(s, m));
619
- for (const r of o(this, m))
620
- typeof r == "object" && S(r, O, this);
621
- this.type = n, S(this, q, void 0), S(this, V, !1);
622
- }, nt = function() {
623
- var t, e;
624
- if (Et(this)) {
625
- let s = 0, n = !1;
626
- do {
627
- n = !0;
628
- for (let r = 0; r < o(this, m).length; r++) {
629
- const c = o(this, m)[r];
630
- typeof c == "object" && (x(e = c, M, nt).call(e), x(this, M, ft).call(this, c) ? (n = !1, x(this, M, ut).call(this, c, r)) : x(this, M, Wt).call(this, c) ? (n = !1, x(this, M, Dt).call(this, c, r)) : x(this, M, kt).call(this, c) && (n = !1, x(this, M, _t).call(this, c)));
631
- }
632
- } while (!n && ++s < 10);
633
- } else
634
- for (const s of o(this, m))
635
- typeof s == "object" && x(t = s, M, nt).call(t);
636
- S(this, q, void 0);
637
- }, pt = function(t) {
638
- return o(this, m).map((e) => {
639
- if (typeof e == "string")
640
- throw new Error("string type in extglob ast??");
641
- const [s, n, r, c] = e.toRegExpSource(t);
642
- return S(this, z, o(this, z) || c), s;
643
- }).filter((e) => !(this.isStart() && this.isEnd()) || !!e).join("|");
644
- }, qt = function(t, e, s = !1) {
645
- let n = !1, r = "", c = !1, a = !1;
646
- for (let p = 0; p < t.length; p++) {
647
- const h = t.charAt(p);
648
- if (n) {
649
- n = !1, r += (Te.has(h) ? "\\" : "") + h;
650
- continue;
651
- }
652
- if (h === "*") {
653
- if (a)
654
- continue;
655
- a = !0, r += s && /^[*]+$/.test(t) ? Mt : xt, e = !0;
656
- continue;
657
- } else
658
- a = !1;
659
- if (h === "\\") {
660
- p === t.length - 1 ? r += "\\\\" : n = !0;
661
- continue;
662
- }
663
- if (h === "[") {
664
- const [f, l, u, g] = Ee(t, p);
665
- if (u) {
666
- r += f, c = c || l, p += u - 1, e = e || g;
667
- continue;
668
- }
669
- }
670
- if (h === "?") {
671
- r += mt, e = !0;
672
- continue;
673
- }
674
- r += ve(h);
675
- }
676
- return [r, Y(t), !!e, c];
677
- }, R(rt, I);
678
- W = rt;
679
- const Pe = (i, { windowsPathsNoEscape: t = !1, magicalBraces: e = !1 } = {}) => e ? t ? i.replace(/[?*()[\]{}]/g, "[$&]") : i.replace(/[?*()[\]\\{}]/g, "\\$&") : t ? i.replace(/[?*()[\]]/g, "[$&]") : i.replace(/[?*()[\]\\]/g, "\\$&"), j = (i, t, e = {}) => (it(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new ot(t, e).match(i)), je = /^\*+([^+@!?*[(]*)$/, Ce = (i) => (t) => !t.startsWith(".") && t.endsWith(i), We = (i) => (t) => t.endsWith(i), De = (i) => (i = i.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(i)), Le = (i) => (i = i.toLowerCase(), (t) => t.toLowerCase().endsWith(i)), ke = /^\*+\.\*+$/, _e = (i) => !i.startsWith(".") && i.includes("."), qe = (i) => i !== "." && i !== ".." && i.includes("."), ze = /^\.\*+$/, Ge = (i) => i !== "." && i !== ".." && i.startsWith("."), Fe = /^\*+$/, Be = (i) => i.length !== 0 && !i.startsWith("."), Ie = (i) => i.length !== 0 && i !== "." && i !== "..", Ue = /^\?+([^+@!?*[(]*)?$/, Ze = ([i, t = ""]) => {
680
- const e = zt([i]);
681
- return t ? (t = t.toLowerCase(), (s) => e(s) && s.toLowerCase().endsWith(t)) : e;
682
- }, He = ([i, t = ""]) => {
683
- const e = Gt([i]);
684
- return t ? (t = t.toLowerCase(), (s) => e(s) && s.toLowerCase().endsWith(t)) : e;
685
- }, Je = ([i, t = ""]) => {
686
- const e = Gt([i]);
687
- return t ? (s) => e(s) && s.endsWith(t) : e;
688
- }, Ve = ([i, t = ""]) => {
689
- const e = zt([i]);
690
- return t ? (s) => e(s) && s.endsWith(t) : e;
691
- }, zt = ([i]) => {
692
- const t = i.length;
693
- return (e) => e.length === t && !e.startsWith(".");
694
- }, Gt = ([i]) => {
695
- const t = i.length;
696
- return (e) => e.length === t && e !== "." && e !== "..";
697
- }, Ft = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", Nt = {
698
- win32: { sep: "\\" },
699
- posix: { sep: "/" }
700
- }, Xe = Ft === "win32" ? Nt.win32.sep : Nt.posix.sep;
701
- j.sep = Xe;
702
- const C = Symbol("globstar **");
703
- j.GLOBSTAR = C;
704
- const Qe = "[^/]", Ke = Qe + "*?", Ye = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?", ts = "(?:(?!(?:\\/|^)\\.).)*?", es = (i, t = {}) => (e) => j(e, i, t);
705
- j.filter = es;
706
- const k = (i, t = {}) => Object.assign({}, i, t), ss = (i) => {
707
- if (!i || typeof i != "object" || !Object.keys(i).length)
708
- return j;
709
- const t = j;
710
- return Object.assign((s, n, r = {}) => t(s, n, k(i, r)), {
711
- Minimatch: class extends t.Minimatch {
712
- constructor(n, r = {}) {
713
- super(n, k(i, r));
714
- }
715
- static defaults(n) {
716
- return t.defaults(k(i, n)).Minimatch;
717
- }
718
- },
719
- AST: class extends t.AST {
720
- /* c8 ignore start */
721
- constructor(n, r, c = {}) {
722
- super(n, r, k(i, c));
723
- }
724
- /* c8 ignore stop */
725
- static fromGlob(n, r = {}) {
726
- return t.AST.fromGlob(n, k(i, r));
727
- }
728
- },
729
- unescape: (s, n = {}) => t.unescape(s, k(i, n)),
730
- escape: (s, n = {}) => t.escape(s, k(i, n)),
731
- filter: (s, n = {}) => t.filter(s, k(i, n)),
732
- defaults: (s) => t.defaults(k(i, s)),
733
- makeRe: (s, n = {}) => t.makeRe(s, k(i, n)),
734
- braceExpand: (s, n = {}) => t.braceExpand(s, k(i, n)),
735
- match: (s, n, r = {}) => t.match(s, n, k(i, r)),
736
- sep: t.sep,
737
- GLOBSTAR: C
738
- });
739
- };
740
- j.defaults = ss;
741
- const Bt = (i, t = {}) => (it(i), t.nobrace || !/\{(?:(?!\{).)*\}/.test(i) ? [i] : ue(i, { max: t.braceExpandMax }));
742
- j.braceExpand = Bt;
743
- const ns = (i, t = {}) => new ot(i, t).makeRe();
744
- j.makeRe = ns;
745
- const is = (i, t, e = {}) => {
746
- const s = new ot(t, e);
747
- return i = i.filter((n) => s.match(n)), s.options.nonull && !i.length && i.push(t), i;
748
- };
749
- j.match = is;
750
- const At = /[?*]|[+@!]\(.*?\)|\[|\]/, rs = (i) => i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
751
- var L, It, gt, J;
752
- class ot {
753
- constructor(t, e = {}) {
754
- R(this, L);
755
- T(this, "options");
756
- T(this, "set");
757
- T(this, "pattern");
758
- T(this, "windowsPathsNoEscape");
759
- T(this, "nonegate");
760
- T(this, "negate");
761
- T(this, "comment");
762
- T(this, "empty");
763
- T(this, "preserveMultipleSlashes");
764
- T(this, "partial");
765
- T(this, "globSet");
766
- T(this, "globParts");
767
- T(this, "nocase");
768
- T(this, "isWindows");
769
- T(this, "platform");
770
- T(this, "windowsNoMagicRoot");
771
- T(this, "maxGlobstarRecursion");
772
- T(this, "regexp");
773
- it(t), e = e || {}, this.options = e, this.maxGlobstarRecursion = e.maxGlobstarRecursion ?? 200, this.pattern = t, this.platform = e.platform || Ft, this.isWindows = this.platform === "win32";
774
- const s = "allowWindowsEscape";
775
- this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e[s] === !1, this.windowsPathsNoEscape && (this.pattern = this.pattern.replace(/\\/g, "/")), this.preserveMultipleSlashes = !!e.preserveMultipleSlashes, this.regexp = null, this.negate = !1, this.nonegate = !!e.nonegate, this.comment = !1, this.empty = !1, this.partial = !!e.partial, this.nocase = !!this.options.nocase, this.windowsNoMagicRoot = e.windowsNoMagicRoot !== void 0 ? e.windowsNoMagicRoot : !!(this.isWindows && this.nocase), this.globSet = [], this.globParts = [], this.set = [], this.make();
776
- }
777
- hasMagic() {
778
- if (this.options.magicalBraces && this.set.length > 1)
779
- return !0;
780
- for (const t of this.set)
781
- for (const e of t)
782
- if (typeof e != "string")
783
- return !0;
784
- return !1;
785
- }
786
- debug(...t) {
787
- }
788
- make() {
789
- const t = this.pattern, e = this.options;
790
- if (!e.nocomment && t.charAt(0) === "#") {
791
- this.comment = !0;
792
- return;
793
- }
794
- if (!t) {
795
- this.empty = !0;
796
- return;
797
- }
798
- this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], e.debug && (this.debug = (...r) => console.error(...r)), this.debug(this.pattern, this.globSet);
799
- const s = this.globSet.map((r) => this.slashSplit(r));
800
- this.globParts = this.preprocess(s), this.debug(this.pattern, this.globParts);
801
- let n = this.globParts.map((r, c, a) => {
802
- if (this.isWindows && this.windowsNoMagicRoot) {
803
- const p = r[0] === "" && r[1] === "" && (r[2] === "?" || !At.test(r[2])) && !At.test(r[3]), h = /^[a-z]:/i.test(r[0]);
804
- if (p)
805
- return [
806
- ...r.slice(0, 4),
807
- ...r.slice(4).map((f) => this.parse(f))
808
- ];
809
- if (h)
810
- return [r[0], ...r.slice(1).map((f) => this.parse(f))];
811
- }
812
- return r.map((p) => this.parse(p));
813
- });
814
- if (this.debug(this.pattern, n), this.set = n.filter((r) => r.indexOf(!1) === -1), this.isWindows)
815
- for (let r = 0; r < this.set.length; r++) {
816
- const c = this.set[r];
817
- c[0] === "" && c[1] === "" && this.globParts[r][2] === "?" && typeof c[3] == "string" && /^[a-z]:$/i.test(c[3]) && (c[2] = "?");
818
- }
819
- this.debug(this.pattern, this.set);
820
- }
821
- // various transforms to equivalent pattern sets that are
822
- // faster to process in a filesystem walk. The goal is to
823
- // eliminate what we can, and push all ** patterns as far
824
- // to the right as possible, even if it increases the number
825
- // of patterns that we have to process.
826
- preprocess(t) {
827
- if (this.options.noglobstar)
828
- for (const s of t)
829
- for (let n = 0; n < s.length; n++)
830
- s[n] === "**" && (s[n] = "*");
831
- const { optimizationLevel: e = 1 } = this.options;
832
- return e >= 2 ? (t = this.firstPhasePreProcess(t), t = this.secondPhasePreProcess(t)) : e >= 1 ? t = this.levelOneOptimize(t) : t = this.adjascentGlobstarOptimize(t), t;
833
- }
834
- // just get rid of adjascent ** portions
835
- adjascentGlobstarOptimize(t) {
836
- return t.map((e) => {
837
- let s = -1;
838
- for (; (s = e.indexOf("**", s + 1)) !== -1; ) {
839
- let n = s;
840
- for (; e[n + 1] === "**"; )
841
- n++;
842
- n !== s && e.splice(s, n - s);
843
- }
844
- return e;
845
- });
846
- }
847
- // get rid of adjascent ** and resolve .. portions
848
- levelOneOptimize(t) {
849
- return t.map((e) => (e = e.reduce((s, n) => {
850
- const r = s[s.length - 1];
851
- return n === "**" && r === "**" ? s : n === ".." && r && r !== ".." && r !== "." && r !== "**" ? (s.pop(), s) : (s.push(n), s);
852
- }, []), e.length === 0 ? [""] : e));
853
- }
854
- levelTwoFileOptimize(t) {
855
- Array.isArray(t) || (t = this.slashSplit(t));
856
- let e = !1;
857
- do {
858
- if (e = !1, !this.preserveMultipleSlashes) {
859
- for (let n = 1; n < t.length - 1; n++) {
860
- const r = t[n];
861
- n === 1 && r === "" && t[0] === "" || (r === "." || r === "") && (e = !0, t.splice(n, 1), n--);
862
- }
863
- t[0] === "." && t.length === 2 && (t[1] === "." || t[1] === "") && (e = !0, t.pop());
864
- }
865
- let s = 0;
866
- for (; (s = t.indexOf("..", s + 1)) !== -1; ) {
867
- const n = t[s - 1];
868
- n && n !== "." && n !== ".." && n !== "**" && !(this.isWindows && /^[a-z]:$/i.test(n)) && (e = !0, t.splice(s - 1, 2), s -= 2);
869
- }
870
- } while (e);
871
- return t.length === 0 ? [""] : t;
872
- }
873
- // First phase: single-pattern processing
874
- // <pre> is 1 or more portions
875
- // <rest> is 1 or more portions
876
- // <p> is any portion other than ., .., '', or **
877
- // <e> is . or ''
878
- //
879
- // **/.. is *brutal* for filesystem walking performance, because
880
- // it effectively resets the recursive walk each time it occurs,
881
- // and ** cannot be reduced out by a .. pattern part like a regexp
882
- // or most strings (other than .., ., and '') can be.
883
- //
884
- // <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
885
- // <pre>/<e>/<rest> -> <pre>/<rest>
886
- // <pre>/<p>/../<rest> -> <pre>/<rest>
887
- // **/**/<rest> -> **/<rest>
888
- //
889
- // **/*/<rest> -> */**/<rest> <== not valid because ** doesn't follow
890
- // this WOULD be allowed if ** did follow symlinks, or * didn't
891
- firstPhasePreProcess(t) {
892
- let e = !1;
893
- do {
894
- e = !1;
895
- for (let s of t) {
896
- let n = -1;
897
- for (; (n = s.indexOf("**", n + 1)) !== -1; ) {
898
- let c = n;
899
- for (; s[c + 1] === "**"; )
900
- c++;
901
- c > n && s.splice(n + 1, c - n);
902
- let a = s[n + 1];
903
- const p = s[n + 2], h = s[n + 3];
904
- if (a !== ".." || !p || p === "." || p === ".." || !h || h === "." || h === "..")
905
- continue;
906
- e = !0, s.splice(n, 1);
907
- const f = s.slice(0);
908
- f[n] = "**", t.push(f), n--;
909
- }
910
- if (!this.preserveMultipleSlashes) {
911
- for (let c = 1; c < s.length - 1; c++) {
912
- const a = s[c];
913
- c === 1 && a === "" && s[0] === "" || (a === "." || a === "") && (e = !0, s.splice(c, 1), c--);
914
- }
915
- s[0] === "." && s.length === 2 && (s[1] === "." || s[1] === "") && (e = !0, s.pop());
916
- }
917
- let r = 0;
918
- for (; (r = s.indexOf("..", r + 1)) !== -1; ) {
919
- const c = s[r - 1];
920
- if (c && c !== "." && c !== ".." && c !== "**") {
921
- e = !0;
922
- const p = r === 1 && s[r + 1] === "**" ? ["."] : [];
923
- s.splice(r - 1, 2, ...p), s.length === 0 && s.push(""), r -= 2;
924
- }
925
- }
926
- }
927
- } while (e);
928
- return t;
929
- }
930
- // second phase: multi-pattern dedupes
931
- // {<pre>/*/<rest>,<pre>/<p>/<rest>} -> <pre>/*/<rest>
932
- // {<pre>/<rest>,<pre>/<rest>} -> <pre>/<rest>
933
- // {<pre>/**/<rest>,<pre>/<rest>} -> <pre>/**/<rest>
934
- //
935
- // {<pre>/**/<rest>,<pre>/**/<p>/<rest>} -> <pre>/**/<rest>
936
- // ^-- not valid because ** doens't follow symlinks
937
- secondPhasePreProcess(t) {
938
- for (let e = 0; e < t.length - 1; e++)
939
- for (let s = e + 1; s < t.length; s++) {
940
- const n = this.partsMatch(t[e], t[s], !this.preserveMultipleSlashes);
941
- if (n) {
942
- t[e] = [], t[s] = n;
943
- break;
944
- }
945
- }
946
- return t.filter((e) => e.length);
947
- }
948
- partsMatch(t, e, s = !1) {
949
- let n = 0, r = 0, c = [], a = "";
950
- for (; n < t.length && r < e.length; )
951
- if (t[n] === e[r])
952
- c.push(a === "b" ? e[r] : t[n]), n++, r++;
953
- else if (s && t[n] === "**" && e[r] === t[n + 1])
954
- c.push(t[n]), n++;
955
- else if (s && e[r] === "**" && t[n] === e[r + 1])
956
- c.push(e[r]), r++;
957
- else if (t[n] === "*" && e[r] && (this.options.dot || !e[r].startsWith(".")) && e[r] !== "**") {
958
- if (a === "b")
959
- return !1;
960
- a = "a", c.push(t[n]), n++, r++;
961
- } else if (e[r] === "*" && t[n] && (this.options.dot || !t[n].startsWith(".")) && t[n] !== "**") {
962
- if (a === "a")
963
- return !1;
964
- a = "b", c.push(e[r]), n++, r++;
965
- } else
966
- return !1;
967
- return t.length === e.length && c;
968
- }
969
- parseNegate() {
970
- if (this.nonegate)
971
- return;
972
- const t = this.pattern;
973
- let e = !1, s = 0;
974
- for (let n = 0; n < t.length && t.charAt(n) === "!"; n++)
975
- e = !e, s++;
976
- s && (this.pattern = t.slice(s)), this.negate = e;
977
- }
978
- // set partial to true to test if, for example,
979
- // "/a/b" matches the start of "/*/b/*/d"
980
- // Partial means, if you run out of file before you run
981
- // out of pattern, then that's fine, as long as all
982
- // the parts match.
983
- matchOne(t, e, s = !1) {
984
- let n = 0, r = 0;
985
- if (this.isWindows) {
986
- const a = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), p = !a && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), h = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), f = !h && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), l = p ? 3 : a ? 0 : void 0, u = f ? 3 : h ? 0 : void 0;
987
- if (typeof l == "number" && typeof u == "number") {
988
- const [g, y] = [
989
- t[l],
990
- e[u]
991
- ];
992
- g.toLowerCase() === y.toLowerCase() && (e[u] = g, r = u, n = l);
993
- }
994
- }
995
- const { optimizationLevel: c = 1 } = this.options;
996
- return c >= 2 && (t = this.levelTwoFileOptimize(t)), e.includes(C) ? x(this, L, It).call(this, t, e, s, n, r) : x(this, L, J).call(this, t, e, s, n, r);
997
- }
998
- braceExpand() {
999
- return Bt(this.pattern, this.options);
1000
- }
1001
- parse(t) {
1002
- it(t);
1003
- const e = this.options;
1004
- if (t === "**")
1005
- return C;
1006
- if (t === "")
1007
- return "";
1008
- let s, n = null;
1009
- (s = t.match(Fe)) ? n = e.dot ? Ie : Be : (s = t.match(je)) ? n = (e.nocase ? e.dot ? Le : De : e.dot ? We : Ce)(s[1]) : (s = t.match(Ue)) ? n = (e.nocase ? e.dot ? He : Ze : e.dot ? Je : Ve)(s) : (s = t.match(ke)) ? n = e.dot ? qe : _e : (s = t.match(ze)) && (n = Ge);
1010
- const r = rt.fromGlob(t, this.options).toMMPattern();
1011
- return n && typeof r == "object" && Reflect.defineProperty(r, "test", { value: n }), r;
1012
- }
1013
- makeRe() {
1014
- if (this.regexp || this.regexp === !1)
1015
- return this.regexp;
1016
- const t = this.set;
1017
- if (!t.length)
1018
- return this.regexp = !1, this.regexp;
1019
- const e = this.options, s = e.noglobstar ? Ke : e.dot ? Ye : ts, n = new Set(e.nocase ? ["i"] : []);
1020
- let r = t.map((p) => {
1021
- const h = p.map((l) => {
1022
- if (l instanceof RegExp)
1023
- for (const u of l.flags.split(""))
1024
- n.add(u);
1025
- return typeof l == "string" ? rs(l) : l === C ? C : l._src;
1026
- });
1027
- h.forEach((l, u) => {
1028
- const g = h[u + 1], y = h[u - 1];
1029
- l !== C || y === C || (y === void 0 ? g !== void 0 && g !== C ? h[u + 1] = "(?:\\/|" + s + "\\/)?" + g : h[u] = s : g === void 0 ? h[u - 1] = y + "(?:\\/|\\/" + s + ")?" : g !== C && (h[u - 1] = y + "(?:\\/|\\/" + s + "\\/)" + g, h[u + 1] = C));
1030
- });
1031
- const f = h.filter((l) => l !== C);
1032
- if (this.partial && f.length >= 1) {
1033
- const l = [];
1034
- for (let u = 1; u <= f.length; u++)
1035
- l.push(f.slice(0, u).join("/"));
1036
- return "(?:" + l.join("|") + ")";
1037
- }
1038
- return f.join("/");
1039
- }).join("|");
1040
- const [c, a] = t.length > 1 ? ["(?:", ")"] : ["", ""];
1041
- r = "^" + c + r + a + "$", this.partial && (r = "^(?:\\/|" + c + r.slice(1, -1) + a + ")$"), this.negate && (r = "^(?!" + r + ").+$");
1042
- try {
1043
- this.regexp = new RegExp(r, [...n].join(""));
1044
- } catch {
1045
- this.regexp = !1;
1046
- }
1047
- return this.regexp;
1048
- }
1049
- slashSplit(t) {
1050
- return this.preserveMultipleSlashes ? t.split("/") : this.isWindows && /^\/\/[^/]+/.test(t) ? ["", ...t.split(/\/+/)] : t.split(/\/+/);
1051
- }
1052
- match(t, e = this.partial) {
1053
- if (this.debug("match", t, this.pattern), this.comment)
1054
- return !1;
1055
- if (this.empty)
1056
- return t === "";
1057
- if (t === "/" && e)
1058
- return !0;
1059
- const s = this.options;
1060
- this.isWindows && (t = t.split("\\").join("/"));
1061
- const n = this.slashSplit(t);
1062
- this.debug(this.pattern, "split", n);
1063
- const r = this.set;
1064
- this.debug(this.pattern, "set", r);
1065
- let c = n[n.length - 1];
1066
- if (!c)
1067
- for (let a = n.length - 2; !c && a >= 0; a--)
1068
- c = n[a];
1069
- for (const a of r) {
1070
- let p = n;
1071
- if (s.matchBase && a.length === 1 && (p = [c]), this.matchOne(p, a, e))
1072
- return s.flipNegate ? !0 : !this.negate;
1073
- }
1074
- return s.flipNegate ? !1 : this.negate;
1075
- }
1076
- static defaults(t) {
1077
- return j.defaults(t).Minimatch;
1078
- }
1079
- }
1080
- L = new WeakSet(), It = function(t, e, s, n, r) {
1081
- const c = e.indexOf(C, r), a = e.lastIndexOf(C), [p, h, f] = s ? [
1082
- e.slice(r, c),
1083
- e.slice(c + 1),
1084
- []
1085
- ] : [
1086
- e.slice(r, c),
1087
- e.slice(c + 1, a),
1088
- e.slice(a + 1)
1089
- ];
1090
- if (p.length) {
1091
- const A = t.slice(n, n + p.length);
1092
- if (!x(this, L, J).call(this, A, p, s, 0, 0))
1093
- return !1;
1094
- n += p.length, r += p.length;
1095
- }
1096
- let l = 0;
1097
- if (f.length) {
1098
- if (f.length + n > t.length)
1099
- return !1;
1100
- let A = t.length - f.length;
1101
- if (x(this, L, J).call(this, t, f, s, A, 0))
1102
- l = f.length;
1103
- else {
1104
- if (t[t.length - 1] !== "" || n + f.length === t.length || (A--, !x(this, L, J).call(this, t, f, s, A, 0)))
1105
- return !1;
1106
- l = f.length + 1;
1107
- }
1108
- }
1109
- if (!h.length) {
1110
- let A = !!l;
1111
- for (let d = n; d < t.length - l; d++) {
1112
- const $ = String(t[d]);
1113
- if (A = !0, $ === "." || $ === ".." || !this.options.dot && $.startsWith("."))
1114
- return !1;
1115
- }
1116
- return s || A;
1117
- }
1118
- const u = [[[], 0]];
1119
- let g = u[0], y = 0;
1120
- const E = [0];
1121
- for (const A of h)
1122
- A === C ? (E.push(y), g = [[], 0], u.push(g)) : (g[0].push(A), y++);
1123
- let w = u.length - 1;
1124
- const b = t.length - l;
1125
- for (const A of u)
1126
- A[1] = b - (E[w--] + A[0].length);
1127
- return !!x(this, L, gt).call(this, t, u, n, 0, s, 0, !!l);
1128
- }, // return false for "nope, not matching"
1129
- // return null for "not matching, cannot keep trying"
1130
- gt = function(t, e, s, n, r, c, a) {
1131
- const p = e[n];
1132
- if (!p) {
1133
- for (let l = s; l < t.length; l++) {
1134
- a = !0;
1135
- const u = t[l];
1136
- if (u === "." || u === ".." || !this.options.dot && u.startsWith("."))
1137
- return !1;
1138
- }
1139
- return a;
1140
- }
1141
- const [h, f] = p;
1142
- for (; s <= f; ) {
1143
- if (x(this, L, J).call(this, t.slice(0, s + h.length), h, r, s, 0) && c < this.maxGlobstarRecursion) {
1144
- const g = x(this, L, gt).call(this, t, e, s + h.length, n + 1, r, c + 1, a);
1145
- if (g !== !1)
1146
- return g;
1147
- }
1148
- const u = t[s];
1149
- if (u === "." || u === ".." || !this.options.dot && u.startsWith("."))
1150
- return !1;
1151
- s++;
1152
- }
1153
- return r || null;
1154
- }, J = function(t, e, s, n, r) {
1155
- let c, a, p, h;
1156
- for (c = n, a = r, h = t.length, p = e.length; c < h && a < p; c++, a++) {
1157
- this.debug("matchOne loop");
1158
- let f = e[a], l = t[c];
1159
- if (this.debug(e, f, l), f === !1 || f === C)
1160
- return !1;
1161
- let u;
1162
- if (typeof f == "string" ? (u = l === f, this.debug("string match", f, l, u)) : (u = f.test(l), this.debug("pattern match", f, l, u)), !u)
1163
- return !1;
1164
- }
1165
- if (c === h && a === p)
1166
- return !0;
1167
- if (c === h)
1168
- return s;
1169
- if (a === p)
1170
- return c === h - 1 && t[c] === "";
1171
- throw new Error("wtf?");
1172
- };
1173
- j.AST = rt;
1174
- j.Minimatch = ot;
1175
- j.escape = Pe;
1176
- j.unescape = Y;
1177
- class os {
1178
- constructor(t) {
1179
- T(this, "value");
1180
- T(this, "next");
1181
- this.value = t;
1182
- }
1183
- }
1184
- var D, B, Z;
1185
- class cs {
1186
- constructor() {
1187
- R(this, D);
1188
- R(this, B);
1189
- R(this, Z);
1190
- this.clear();
1191
- }
1192
- enqueue(t) {
1193
- const e = new os(t);
1194
- o(this, D) ? (o(this, B).next = e, S(this, B, e)) : (S(this, D, e), S(this, B, e)), lt(this, Z)._++;
1195
- }
1196
- dequeue() {
1197
- const t = o(this, D);
1198
- if (t)
1199
- return S(this, D, o(this, D).next), lt(this, Z)._--, o(this, D) || S(this, B, void 0), t.value;
1200
- }
1201
- peek() {
1202
- if (o(this, D))
1203
- return o(this, D).value;
1204
- }
1205
- clear() {
1206
- S(this, D, void 0), S(this, B, void 0), S(this, Z, 0);
1207
- }
1208
- get size() {
1209
- return o(this, Z);
1210
- }
1211
- *[Symbol.iterator]() {
1212
- let t = o(this, D);
1213
- for (; t; )
1214
- yield t.value, t = t.next;
1215
- }
1216
- *drain() {
1217
- for (; o(this, D); )
1218
- yield this.dequeue();
1219
- }
1220
- }
1221
- D = new WeakMap(), B = new WeakMap(), Z = new WeakMap();
1222
- function ls(i) {
1223
- let t = !1;
1224
- if (typeof i == "object" && ({ concurrency: i, rejectOnClear: t = !1 } = i), $t(i), typeof t != "boolean")
1225
- throw new TypeError("Expected `rejectOnClear` to be a boolean");
1226
- const e = new cs();
1227
- let s = 0;
1228
- const n = () => {
1229
- s < i && e.size > 0 && (s++, e.dequeue().run());
1230
- }, r = () => {
1231
- s--, n();
1232
- }, c = async (h, f, l) => {
1233
- const u = (async () => h(...l))();
1234
- f(u);
1235
- try {
1236
- await u;
1237
- } catch {
1238
- }
1239
- r();
1240
- }, a = (h, f, l, u) => {
1241
- const g = { reject: l };
1242
- new Promise((y) => {
1243
- g.run = y, e.enqueue(g);
1244
- }).then(c.bind(void 0, h, f, u)), s < i && n();
1245
- }, p = (h, ...f) => new Promise((l, u) => {
1246
- a(h, l, u, f);
1247
- });
1248
- return Object.defineProperties(p, {
1249
- activeCount: {
1250
- get: () => s
1251
- },
1252
- pendingCount: {
1253
- get: () => e.size
1254
- },
1255
- clearQueue: {
1256
- value() {
1257
- if (!t) {
1258
- e.clear();
1259
- return;
1260
- }
1261
- const h = AbortSignal.abort().reason;
1262
- for (; e.size > 0; )
1263
- e.dequeue().reject(h);
1264
- }
1265
- },
1266
- concurrency: {
1267
- get: () => i,
1268
- set(h) {
1269
- $t(h), i = h, queueMicrotask(() => {
1270
- for (; s < i && e.size > 0; )
1271
- n();
1272
- });
1273
- }
1274
- },
1275
- map: {
1276
- async value(h, f) {
1277
- const l = Array.from(h, (u, g) => this(f, u, g));
1278
- return Promise.all(l);
1279
- }
1280
- }
1281
- }), p;
1282
- }
1283
- function $t(i) {
1284
- if (!((Number.isInteger(i) || i === Number.POSITIVE_INFINITY) && i > 0))
1285
- throw new TypeError("Expected `concurrency` to be a number from 1 and up");
1286
- }
1287
- const hs = Qt(Vt);
1288
- function as(i) {
1289
- if (i.length < 2) return "never";
1290
- const t = [...i].sort((n, r) => n - r);
1291
- let e = 0;
1292
- for (let n = 1; n < t.length; n++)
1293
- e += t[n] - t[n - 1];
1294
- const s = e / (t.length - 1) / 864e5;
1295
- return s <= 1 ? "daily" : s <= 7 ? "weekly" : s <= 30 ? "monthly" : s <= 365 ? "yearly" : "never";
1296
- }
1297
- function ws(i) {
1298
- const t = i.pageEntryPattern;
1299
- let e = i.rootDir ?? "", s = i.outputFile ?? "";
1300
- const n = i.concurrency ?? 20, r = i.commitCount ?? 10, c = i.ignoreDeps ? Array.isArray(i.ignoreDeps) ? i.ignoreDeps : [i.ignoreDeps] : [], a = {};
1301
- let p;
1302
- return {
1303
- name: "vite-last-modified",
1304
- async configResolved(h) {
1305
- p = h.build.ssr, e || (e = h.root), s || (s = Jt(e, "last-modified.json"));
1306
- },
1307
- async buildEnd() {
1308
- if (p || process.env.NODE_ENV !== "production")
1309
- return;
1310
- const h = /* @__PURE__ */ new Map(), f = ls(n), l = (w) => {
1311
- if (h.has(w))
1312
- return h.get(w);
1313
- const b = f(async () => {
1314
- try {
1315
- const A = w.includes("?") ? w.slice(0, w.indexOf("?")) : w, d = Ht.relative(e, A).replace(/\\/g, "/"), { stdout: $ } = await hs(`git log --follow -n ${r} --format=%at -- "${d}"`, { cwd: e });
1316
- return $.trim() ? $.trim().split(`
1317
- `).map((N) => parseInt(N, 10) * 1e3) : [];
1318
- } catch {
1319
- return [];
1320
- }
1321
- });
1322
- return h.set(w, b), b;
1323
- }, u = (w, b) => {
1324
- if (b.has(w)) return;
1325
- b.add(w);
1326
- const A = this.getModuleInfo(w);
1327
- if (A)
1328
- for (const d of A.importedIds) {
1329
- if (d.includes("node_modules") || !d.startsWith(e))
1330
- continue;
1331
- const $ = d.slice(e.length).replace(/^\/?/, "").split("?")[0];
1332
- c.some((N) => j($, N, { dot: !0 })) || u(d, b);
1333
- }
1334
- }, g = [...this.getModuleIds()].filter((w) => {
1335
- if (!w.startsWith(e))
1336
- return !1;
1337
- const b = w.slice(e.length).replace(/^\//, "");
1338
- return typeof t == "string" ? j(b, t, { dot: !0 }) : t.test(b);
1339
- });
1340
- if (g.length === 0) {
1341
- console.warn("[lastModifiedPlugin] No MD files found in module graph");
1342
- return;
1343
- }
1344
- console.log("[lastModifiedPlugin] start collect entry files deps");
1345
- let y = /* @__PURE__ */ new Map();
1346
- for (const w of g) {
1347
- const b = /* @__PURE__ */ new Set();
1348
- u(w, b), y.set(w, b);
1349
- }
1350
- if (console.log(`[lastModifiedPlugin] Analyzed ${g.length} entry files`), typeof i.modifyDepMap == "function") {
1351
- const w = await i.modifyDepMap(y);
1352
- w && w instanceof Map && (y = w);
1353
- }
1354
- const E = /* @__PURE__ */ new Set();
1355
- for (const w of y.values())
1356
- for (const b of w)
1357
- E.add(b);
1358
- await Promise.all([...E].map(l));
1359
- for (const [w, b] of y) {
1360
- const A = w.slice(e.length).replace(/^\//, ""), d = (await Promise.all([...b].map(l))).flat(), $ = d.length > 0 ? Math.max(...d) : 0, N = as(d);
1361
- a[A] = { lastmod: $, changefreq: N };
1362
- }
1363
- },
1364
- closeBundle() {
1365
- if (p || process.env.NODE_ENV !== "production")
1366
- return;
1367
- const h = Object.fromEntries(Object.entries(a).sort(([f], [l]) => f.localeCompare(l)));
1368
- Xt(s, JSON.stringify(h, null, 2), "utf8"), console.log(`[lastModifiedPlugin] Written ${s}`);
1369
- }
1370
- };
1371
- }
1372
- export {
1373
- ws as g,
1374
- j as m
1375
- };