lakutata
Version:
An IoC-based universal application framework.
1,726 lines (1,602 loc) • 158 kB
JavaScript
/* Build Date: Mon Jan 05 2026 23:52:23 GMT+0800 (China Standard Time) */
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, {
value: "Module"
});
const t = require("node:url");
const e = require("node:path");
const s = require("fs");
const i = require("node:fs");
const n = require("node:fs/promises");
const r = require("node:events");
const o = require("node:stream");
const h = require("node:string_decoder");
const a = t => t && t.__esModule ? t : {
default: t
};
function l(t) {
if (t && t.__esModule) return t;
const e = Object.create(null, {
[Symbol.toStringTag]: {
value: "Module"
}
});
if (t) {
for (const s in t) {
if (s !== "default") {
const i = Object.getOwnPropertyDescriptor(t, s);
Object.defineProperty(e, s, i.get ? i : {
enumerable: true,
get: () => t[s]
});
}
}
}
e.default = t;
return Object.freeze(e);
}
const c = l(i);
const f = a(o);
const u = (t, e, s) => {
const i = t instanceof RegExp ? d(t, s) : t;
const n = e instanceof RegExp ? d(e, s) : e;
const r = i !== null && n != null && p(i, n, s);
return r && {
start: r[0],
end: r[1],
pre: s.slice(0, r[0]),
body: s.slice(r[0] + i.length, r[1]),
post: s.slice(r[1] + n.length)
};
};
const d = (t, e) => {
const s = e.match(t);
return s ? s[0] : null;
};
const p = (t, e, s) => {
let i, n, r, o = undefined, h;
let a = s.indexOf(t);
let l = s.indexOf(e, a + 1);
let c = a;
if (a >= 0 && l > 0) {
if (t === e) {
return [ a, l ];
}
i = [];
r = s.length;
while (c >= 0 && !h) {
if (c === a) {
i.push(c);
a = s.indexOf(t, c + 1);
} else if (i.length === 1) {
const t = i.pop();
if (t !== undefined) h = [ t, l ];
} else {
n = i.pop();
if (n !== undefined && n < r) {
r = n;
o = l;
}
l = s.indexOf(e, c + 1);
}
c = a < l && a >= 0 ? a : l;
}
if (i.length && o !== undefined) {
h = [ r, o ];
}
}
return h;
};
const g = "\0SLASH" + Math.random() + "\0";
const m = "\0OPEN" + Math.random() + "\0";
const w = "\0CLOSE" + Math.random() + "\0";
const y = "\0COMMA" + Math.random() + "\0";
const b = "\0PERIOD" + Math.random() + "\0";
const S = new RegExp(g, "g");
const k = new RegExp(m, "g");
const v = new RegExp(w, "g");
const x = new RegExp(y, "g");
const E = new RegExp(b, "g");
const C = /\\\\/g;
const T = /\\{/g;
const L = /\\}/g;
const A = /\\,/g;
const M = /\\./g;
function P(t) {
return !isNaN(t) ? parseInt(t, 10) : t.charCodeAt(0);
}
function F(t) {
return t.replace(C, g).replace(T, m).replace(L, w).replace(A, y).replace(M, b);
}
function R(t) {
return t.replace(S, "\\").replace(k, "{").replace(v, "}").replace(x, ",").replace(E, ".");
}
function O(t) {
if (!t) {
return [ "" ];
}
const e = [];
const s = u("{", "}", t);
if (!s) {
return t.split(",");
}
const {pre: i, body: n, post: r} = s;
const o = i.split(",");
o[o.length - 1] += "{" + n + "}";
const h = O(r);
if (r.length) {
o[o.length - 1] += h.shift();
o.push.apply(o, h);
}
e.push.apply(e, o);
return e;
}
function z(t) {
if (!t) {
return [];
}
if (t.slice(0, 2) === "{}") {
t = "\\{\\}" + t.slice(2);
}
return I(F(t), true).map(R);
}
function D(t) {
return "{" + t + "}";
}
function N(t) {
return /^-?0\d/.test(t);
}
function B(t, e) {
return t <= e;
}
function W(t, e) {
return t >= e;
}
function I(t, e) {
const s = [];
const i = u("{", "}", t);
if (!i) return [ t ];
const n = i.pre;
const r = i.post.length ? I(i.post, false) : [ "" ];
if (/\$$/.test(i.pre)) {
for (let t = 0; t < r.length; t++) {
const e = n + "{" + i.body + "}" + r[t];
s.push(e);
}
} else {
const o = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body);
const h = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body);
const a = o || h;
const l = i.body.indexOf(",") >= 0;
if (!a && !l) {
if (i.post.match(/,(?!,).*\}/)) {
t = i.pre + "{" + i.body + w + i.post;
return I(t);
}
return [ t ];
}
let c;
if (a) {
c = i.body.split(/\.\./);
} else {
c = O(i.body);
if (c.length === 1 && c[0] !== undefined) {
c = I(c[0], false).map(D);
if (c.length === 1) {
return r.map(t => i.pre + c[0] + t);
}
}
}
let f;
if (a && c[0] !== undefined && c[1] !== undefined) {
const t = P(c[0]);
const e = P(c[1]);
const s = Math.max(c[0].length, c[1].length);
let i = c.length === 3 && c[2] !== undefined ? Math.abs(P(c[2])) : 1;
let n = B;
const r = e < t;
if (r) {
i *= -1;
n = W;
}
const o = c.some(N);
f = [];
for (let r = t; n(r, e); r += i) {
let t;
if (h) {
t = String.fromCharCode(r);
if (t === "\\") {
t = "";
}
} else {
t = String(r);
if (o) {
const e = s - t.length;
if (e > 0) {
const s = new Array(e + 1).join("0");
if (r < 0) {
t = "-" + s + t.slice(1);
} else {
t = s + t;
}
}
}
}
f.push(t);
}
} else {
f = [];
for (let t = 0; t < c.length; t++) {
f.push.apply(f, I(c[t], false));
}
}
for (let t = 0; t < f.length; t++) {
for (let i = 0; i < r.length; i++) {
const o = n + f[t] + r[i];
if (!e || a || o) {
s.push(o);
}
}
}
}
return s;
}
const _ = 1024 * 64;
const j = t => {
if (typeof t !== "string") {
throw new TypeError("invalid pattern");
}
if (t.length > _) {
throw new TypeError("pattern is too long");
}
};
const U = {
"[:alnum:]": [ "\\p{L}\\p{Nl}\\p{Nd}", true ],
"[:alpha:]": [ "\\p{L}\\p{Nl}", true ],
"[:ascii:]": [ "\\x" + "00-\\x" + "7f", false ],
"[:blank:]": [ "\\p{Zs}\\t", true ],
"[:cntrl:]": [ "\\p{Cc}", true ],
"[:digit:]": [ "\\p{Nd}", true ],
"[:graph:]": [ "\\p{Z}\\p{C}", true, true ],
"[:lower:]": [ "\\p{Ll}", true ],
"[:print:]": [ "\\p{C}", true ],
"[:punct:]": [ "\\p{P}", true ],
"[:space:]": [ "\\p{Z}\\t\\r\\n\\v\\f", true ],
"[:upper:]": [ "\\p{Lu}", true ],
"[:word:]": [ "\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", true ],
"[:xdigit:]": [ "A-Fa-f0-9", false ]
};
const $ = t => t.replace(/[[\]\\-]/g, "\\$&");
const G = t => t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
const q = t => t.join("");
const H = (t, e) => {
const s = e;
if (t.charAt(s) !== "[") {
throw new Error("not in a brace expression");
}
const i = [];
const n = [];
let r = s + 1;
let o = false;
let h = false;
let a = false;
let l = false;
let c = s;
let f = "";
t: while (r < t.length) {
const e = t.charAt(r);
if ((e === "!" || e === "^") && r === s + 1) {
l = true;
r++;
continue;
}
if (e === "]" && o && !a) {
c = r + 1;
break;
}
o = true;
if (e === "\\") {
if (!a) {
a = true;
r++;
continue;
}
}
if (e === "[" && !a) {
for (const [e, [o, a, l]] of Object.entries(U)) {
if (t.startsWith(e, r)) {
if (f) {
return [ "$.", false, t.length - s, true ];
}
r += e.length;
if (l) n.push(o); else i.push(o);
h = h || a;
continue t;
}
}
}
a = false;
if (f) {
if (e > f) {
i.push($(f) + "-" + $(e));
} else if (e === f) {
i.push($(e));
}
f = "";
r++;
continue;
}
if (t.startsWith("-]", r + 1)) {
i.push($(e + "-"));
r += 2;
continue;
}
if (t.startsWith("-", r + 1)) {
f = e;
r += 2;
continue;
}
i.push($(e));
r++;
}
if (c < r) {
return [ "", false, 0, false ];
}
if (!i.length && !n.length) {
return [ "$.", false, t.length - s, true ];
}
if (n.length === 0 && i.length === 1 && /^\\?.$/.test(i[0]) && !l) {
const t = i[0].length === 2 ? i[0].slice(-1) : i[0];
return [ G(t), false, c - s, false ];
}
const u = "[" + (l ? "^" : "") + q(i) + "]";
const d = "[" + (l ? "" : "^") + q(n) + "]";
const p = i.length && n.length ? "(" + u + "|" + d + ")" : i.length ? u : d;
return [ p, h, c - s, true ];
};
const Z = (t, {windowsPathsNoEscape: e = false, magicalBraces: s = true} = {}) => {
if (s) {
return e ? t.replace(/\[([^\/\\])\]/g, "$1") : t.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1");
}
return e ? t.replace(/\[([^\/\\{}])\]/g, "$1") : t.replace(/((?!\\).|^)\[([^\/\\{}])\]/g, "$1$2").replace(/\\([^\/{}])/g, "$1");
};
const V = new Set([ "!", "?", "+", "*", "@" ]);
const J = t => V.has(t);
const K = "(?!(?:^|/)\\.\\.?(?:$|/))";
const Y = "(?!\\.)";
const X = new Set([ "[", "." ]);
const Q = new Set([ "..", "." ]);
const tt = new Set("().*{}+?[]^$\\!");
const et = t => t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
const st = "[^/]";
const it = st + "*?";
const nt = st + "+?";
class AST {
type;
#t;
#e;
#s=false;
#i=[];
#n;
#r;
#o;
#h=false;
#a;
#l;
#c=false;
constructor(t, e, s = {}) {
this.type = t;
if (t) this.#e = true;
this.#n = e;
this.#t = this.#n ? this.#n.#t : this;
this.#a = this.#t === this ? s : this.#t.#a;
this.#o = this.#t === this ? [] : this.#t.#o;
if (t === "!" && !this.#t.#h) this.#o.push(this);
this.#r = this.#n ? this.#n.#i.length : 0;
}
get hasMagic() {
if (this.#e !== undefined) return this.#e;
for (const t of this.#i) {
if (typeof t === "string") continue;
if (t.type || t.hasMagic) return this.#e = true;
}
return this.#e;
}
toString() {
if (this.#l !== undefined) return this.#l;
if (!this.type) {
return this.#l = this.#i.map(t => String(t)).join("");
} else {
return this.#l = this.type + "(" + this.#i.map(t => String(t)).join("|") + ")";
}
}
#f() {
if (this !== this.#t) throw new Error("should only call on root");
if (this.#h) return this;
this.toString();
this.#h = true;
let t;
while (t = this.#o.pop()) {
if (t.type !== "!") continue;
let e = t;
let s = e.#n;
while (s) {
for (let i = e.#r + 1; !s.type && i < s.#i.length; i++) {
for (const e of t.#i) {
if (typeof e === "string") {
throw new Error("string part in extglob AST??");
}
e.copyIn(s.#i[i]);
}
}
e = s;
s = e.#n;
}
}
return this;
}
push(...t) {
for (const e of t) {
if (e === "") continue;
if (typeof e !== "string" && !(e instanceof AST && e.#n === this)) {
throw new Error("invalid part: " + e);
}
this.#i.push(e);
}
}
toJSON() {
const t = this.type === null ? this.#i.slice().map(t => typeof t === "string" ? t : t.toJSON()) : [ this.type, ...this.#i.map(t => t.toJSON()) ];
if (this.isStart() && !this.type) t.unshift([]);
if (this.isEnd() && (this === this.#t || this.#t.#h && this.#n?.type === "!")) {
t.push({});
}
return t;
}
isStart() {
if (this.#t === this) return true;
if (!this.#n?.isStart()) return false;
if (this.#r === 0) return true;
const t = this.#n;
for (let e = 0; e < this.#r; e++) {
const s = t.#i[e];
if (!(s instanceof AST && s.type === "!")) {
return false;
}
}
return true;
}
isEnd() {
if (this.#t === this) return true;
if (this.#n?.type === "!") return true;
if (!this.#n?.isEnd()) return false;
if (!this.type) return this.#n?.isEnd();
const t = this.#n ? this.#n.#i.length : 0;
return this.#r === t - 1;
}
copyIn(t) {
if (typeof t === "string") this.push(t); else this.push(t.clone(this));
}
clone(t) {
const e = new AST(this.type, t);
for (const t of this.#i) {
e.copyIn(t);
}
return e;
}
static #u(t, e, s, i) {
let n = false;
let r = false;
let o = -1;
let h = false;
if (e.type === null) {
let a = s;
let l = "";
while (a < t.length) {
const s = t.charAt(a++);
if (n || s === "\\") {
n = !n;
l += s;
continue;
}
if (r) {
if (a === o + 1) {
if (s === "^" || s === "!") {
h = true;
}
} else if (s === "]" && !(a === o + 2 && h)) {
r = false;
}
l += s;
continue;
} else if (s === "[") {
r = true;
o = a;
h = false;
l += s;
continue;
}
if (!i.noext && J(s) && t.charAt(a) === "(") {
e.push(l);
l = "";
const n = new AST(s, e);
a = AST.#u(t, n, a, i);
e.push(n);
continue;
}
l += s;
}
e.push(l);
return a;
}
let a = s + 1;
let l = new AST(null, e);
const c = [];
let f = "";
while (a < t.length) {
const s = t.charAt(a++);
if (n || s === "\\") {
n = !n;
f += s;
continue;
}
if (r) {
if (a === o + 1) {
if (s === "^" || s === "!") {
h = true;
}
} else if (s === "]" && !(a === o + 2 && h)) {
r = false;
}
f += s;
continue;
} else if (s === "[") {
r = true;
o = a;
h = false;
f += s;
continue;
}
if (J(s) && t.charAt(a) === "(") {
l.push(f);
f = "";
const e = new AST(s, l);
l.push(e);
a = AST.#u(t, e, a, i);
continue;
}
if (s === "|") {
l.push(f);
f = "";
c.push(l);
l = new AST(null, e);
continue;
}
if (s === ")") {
if (f === "" && e.#i.length === 0) {
e.#c = true;
}
l.push(f);
f = "";
e.push(...c, l);
return a;
}
f += s;
}
e.type = null;
e.#e = undefined;
e.#i = [ t.substring(s - 1) ];
return a;
}
static fromGlob(t, e = {}) {
const s = new AST(null, undefined, e);
AST.#u(t, s, 0, e);
return s;
}
toMMPattern() {
if (this !== this.#t) return this.#t.toMMPattern();
const t = this.toString();
const [e, s, i, n] = this.toRegExpSource();
const r = i || this.#e || this.#a.nocase && !this.#a.nocaseMagicOnly && t.toUpperCase() !== t.toLowerCase();
if (!r) {
return s;
}
const o = (this.#a.nocase ? "i" : "") + (n ? "u" : "");
return Object.assign(new RegExp(`^${e}$`, o), {
_src: e,
_glob: t
});
}
get options() {
return this.#a;
}
toRegExpSource(t) {
const e = t ?? !!this.#a.dot;
if (this.#t === this) this.#f();
if (!this.type) {
const s = this.isStart() && this.isEnd() && !this.#i.some(t => typeof t !== "string");
const i = this.#i.map(e => {
const [i, n, r, o] = typeof e === "string" ? AST.#d(e, this.#e, s) : e.toRegExpSource(t);
this.#e = this.#e || r;
this.#s = this.#s || o;
return i;
}).join("");
let n = "";
if (this.isStart()) {
if (typeof this.#i[0] === "string") {
const s = this.#i.length === 1 && Q.has(this.#i[0]);
if (!s) {
const s = X;
const r = e && s.has(i.charAt(0)) || i.startsWith("\\.") && s.has(i.charAt(2)) || i.startsWith("\\.\\.") && s.has(i.charAt(4));
const o = !e && !t && s.has(i.charAt(0));
n = r ? K : o ? Y : "";
}
}
}
let r = "";
if (this.isEnd() && this.#t.#h && this.#n?.type === "!") {
r = "(?:$|\\/)";
}
const o = n + i + r;
return [ o, Z(i), this.#e = !!this.#e, this.#s ];
}
const s = this.type === "*" || this.type === "+";
const i = this.type === "!" ? "(?:(?!(?:" : "(?:";
let n = this.#p(e);
if (this.isStart() && this.isEnd() && !n && this.type !== "!") {
const t = this.toString();
this.#i = [ t ];
this.type = null;
this.#e = undefined;
return [ t, Z(this.toString()), false, false ];
}
let r = !s || t || e || !Y ? "" : this.#p(true);
if (r === n) {
r = "";
}
if (r) {
n = `(?:${n})(?:${r})*?`;
}
let o = "";
if (this.type === "!" && this.#c) {
o = (this.isStart() && !e ? Y : "") + nt;
} else {
const s = this.type === "!" ? "))" + (this.isStart() && !e && !t ? Y : "") + it + ")" : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && r ? ")" : this.type === "*" && r ? `)?` : `)${this.type}`;
o = i + n + s;
}
return [ o, Z(n), this.#e = !!this.#e, this.#s ];
}
#p(t) {
return this.#i.map(e => {
if (typeof e === "string") {
throw new Error("string type in extglob ast??");
}
const [s, i, n, r] = e.toRegExpSource(t);
this.#s = this.#s || r;
return s;
}).filter(t => !(this.isStart() && this.isEnd()) || !!t).join("|");
}
static #d(t, e, s = false) {
let i = false;
let n = "";
let r = false;
for (let o = 0; o < t.length; o++) {
const h = t.charAt(o);
if (i) {
i = false;
n += (tt.has(h) ? "\\" : "") + h;
continue;
}
if (h === "\\") {
if (o === t.length - 1) {
n += "\\\\";
} else {
i = true;
}
continue;
}
if (h === "[") {
const [s, i, h, a] = H(t, o);
if (h) {
n += s;
r = r || i;
o += h - 1;
e = e || a;
continue;
}
}
if (h === "*") {
n += s && t === "*" ? nt : it;
e = true;
continue;
}
if (h === "?") {
n += st;
e = true;
continue;
}
n += et(h);
}
return [ n, Z(t), !!e, r ];
}
}
const rt = (t, {windowsPathsNoEscape: e = false, magicalBraces: s = false} = {}) => {
if (s) {
return e ? t.replace(/[?*()[\]{}]/g, "[$&]") : t.replace(/[?*()[\]\\{}]/g, "\\$&");
}
return e ? t.replace(/[?*()[\]]/g, "[$&]") : t.replace(/[?*()[\]\\]/g, "\\$&");
};
const ot = (t, e, s = {}) => {
j(e);
if (!s.nocomment && e.charAt(0) === "#") {
return false;
}
return new Minimatch(e, s).match(t);
};
const ht = /^\*+([^+@!?\*\[\(]*)$/;
const at = t => e => !e.startsWith(".") && e.endsWith(t);
const lt = t => e => e.endsWith(t);
const ct = t => {
t = t.toLowerCase();
return e => !e.startsWith(".") && e.toLowerCase().endsWith(t);
};
const ft = t => {
t = t.toLowerCase();
return e => e.toLowerCase().endsWith(t);
};
const ut = /^\*+\.\*+$/;
const dt = t => !t.startsWith(".") && t.includes(".");
const pt = t => t !== "." && t !== ".." && t.includes(".");
const gt = /^\.\*+$/;
const mt = t => t !== "." && t !== ".." && t.startsWith(".");
const wt = /^\*+$/;
const yt = t => t.length !== 0 && !t.startsWith(".");
const bt = t => t.length !== 0 && t !== "." && t !== "..";
const St = /^\?+([^+@!?\*\[\(]*)?$/;
const kt = ([t, e = ""]) => {
const s = Ct([ t ]);
if (!e) return s;
e = e.toLowerCase();
return t => s(t) && t.toLowerCase().endsWith(e);
};
const vt = ([t, e = ""]) => {
const s = Tt([ t ]);
if (!e) return s;
e = e.toLowerCase();
return t => s(t) && t.toLowerCase().endsWith(e);
};
const xt = ([t, e = ""]) => {
const s = Tt([ t ]);
return !e ? s : t => s(t) && t.endsWith(e);
};
const Et = ([t, e = ""]) => {
const s = Ct([ t ]);
return !e ? s : t => s(t) && t.endsWith(e);
};
const Ct = ([t]) => {
const e = t.length;
return t => t.length === e && !t.startsWith(".");
};
const Tt = ([t]) => {
const e = t.length;
return t => t.length === e && t !== "." && t !== "..";
};
const Lt = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
const At = {
win32: {
sep: "\\"
},
posix: {
sep: "/"
}
};
const Mt = Lt === "win32" ? At.win32.sep : At.posix.sep;
ot.sep = Mt;
const Pt = Symbol("globstar **");
ot.GLOBSTAR = Pt;
const Ft = "[^/]";
const Rt = Ft + "*?";
const Ot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
const zt = "(?:(?!(?:\\/|^)\\.).)*?";
const Dt = (t, e = {}) => s => ot(s, t, e);
ot.filter = Dt;
const Nt = (t, e = {}) => Object.assign({}, t, e);
const Bt = t => {
if (!t || typeof t !== "object" || !Object.keys(t).length) {
return ot;
}
const e = ot;
const s = (s, i, n = {}) => e(s, i, Nt(t, n));
return Object.assign(s, {
Minimatch: class Minimatch extends e.Minimatch {
constructor(e, s = {}) {
super(e, Nt(t, s));
}
static defaults(s) {
return e.defaults(Nt(t, s)).Minimatch;
}
},
AST: class AST extends e.AST {
constructor(e, s, i = {}) {
super(e, s, Nt(t, i));
}
static fromGlob(s, i = {}) {
return e.AST.fromGlob(s, Nt(t, i));
}
},
unescape: (s, i = {}) => e.unescape(s, Nt(t, i)),
escape: (s, i = {}) => e.escape(s, Nt(t, i)),
filter: (s, i = {}) => e.filter(s, Nt(t, i)),
defaults: s => e.defaults(Nt(t, s)),
makeRe: (s, i = {}) => e.makeRe(s, Nt(t, i)),
braceExpand: (s, i = {}) => e.braceExpand(s, Nt(t, i)),
match: (s, i, n = {}) => e.match(s, i, Nt(t, n)),
sep: e.sep,
GLOBSTAR: Pt
});
};
ot.defaults = Bt;
const Wt = (t, e = {}) => {
j(t);
if (e.nobrace || !/\{(?:(?!\{).)*\}/.test(t)) {
return [ t ];
}
return z(t);
};
ot.braceExpand = Wt;
const It = (t, e = {}) => new Minimatch(t, e).makeRe();
ot.makeRe = It;
const _t = (t, e, s = {}) => {
const i = new Minimatch(e, s);
t = t.filter(t => i.match(t));
if (i.options.nonull && !t.length) {
t.push(e);
}
return t;
};
ot.match = _t;
const jt = /[?*]|[+@!]\(.*?\)|\[|\]/;
const Ut = t => t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
class Minimatch {
options;
set;
pattern;
windowsPathsNoEscape;
nonegate;
negate;
comment;
empty;
preserveMultipleSlashes;
partial;
globSet;
globParts;
nocase;
isWindows;
platform;
windowsNoMagicRoot;
regexp;
constructor(t, e = {}) {
j(t);
e = e || {};
this.options = e;
this.pattern = t;
this.platform = e.platform || Lt;
this.isWindows = this.platform === "win32";
this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e.allowWindowsEscape === false;
if (this.windowsPathsNoEscape) {
this.pattern = this.pattern.replace(/\\/g, "/");
}
this.preserveMultipleSlashes = !!e.preserveMultipleSlashes;
this.regexp = null;
this.negate = false;
this.nonegate = !!e.nonegate;
this.comment = false;
this.empty = false;
this.partial = !!e.partial;
this.nocase = !!this.options.nocase;
this.windowsNoMagicRoot = e.windowsNoMagicRoot !== undefined ? e.windowsNoMagicRoot : !!(this.isWindows && this.nocase);
this.globSet = [];
this.globParts = [];
this.set = [];
this.make();
}
hasMagic() {
if (this.options.magicalBraces && this.set.length > 1) {
return true;
}
for (const t of this.set) {
for (const e of t) {
if (typeof e !== "string") return true;
}
}
return false;
}
debug(...t) {}
make() {
const t = this.pattern;
const e = this.options;
if (!e.nocomment && t.charAt(0) === "#") {
this.comment = true;
return;
}
if (!t) {
this.empty = true;
return;
}
this.parseNegate();
this.globSet = [ ...new Set(this.braceExpand()) ];
if (e.debug) {
this.debug = (...t) => console.error(...t);
}
this.debug(this.pattern, this.globSet);
const s = this.globSet.map(t => this.slashSplit(t));
this.globParts = this.preprocess(s);
this.debug(this.pattern, this.globParts);
let i = this.globParts.map((t, e, s) => {
if (this.isWindows && this.windowsNoMagicRoot) {
const e = t[0] === "" && t[1] === "" && (t[2] === "?" || !jt.test(t[2])) && !jt.test(t[3]);
const s = /^[a-z]:/i.test(t[0]);
if (e) {
return [ ...t.slice(0, 4), ...t.slice(4).map(t => this.parse(t)) ];
} else if (s) {
return [ t[0], ...t.slice(1).map(t => this.parse(t)) ];
}
}
return t.map(t => this.parse(t));
});
this.debug(this.pattern, i);
this.set = i.filter(t => t.indexOf(false) === -1);
if (this.isWindows) {
for (let t = 0; t < this.set.length; t++) {
const e = this.set[t];
if (e[0] === "" && e[1] === "" && this.globParts[t][2] === "?" && typeof e[3] === "string" && /^[a-z]:$/i.test(e[3])) {
e[2] = "?";
}
}
}
this.debug(this.pattern, this.set);
}
preprocess(t) {
if (this.options.noglobstar) {
for (let e = 0; e < t.length; e++) {
for (let s = 0; s < t[e].length; s++) {
if (t[e][s] === "**") {
t[e][s] = "*";
}
}
}
}
const {optimizationLevel: e = 1} = this.options;
if (e >= 2) {
t = this.firstPhasePreProcess(t);
t = this.secondPhasePreProcess(t);
} else if (e >= 1) {
t = this.levelOneOptimize(t);
} else {
t = this.adjascentGlobstarOptimize(t);
}
return t;
}
adjascentGlobstarOptimize(t) {
return t.map(t => {
let e = -1;
while (-1 !== (e = t.indexOf("**", e + 1))) {
let s = e;
while (t[s + 1] === "**") {
s++;
}
if (s !== e) {
t.splice(e, s - e);
}
}
return t;
});
}
levelOneOptimize(t) {
return t.map(t => {
t = t.reduce((t, e) => {
const s = t[t.length - 1];
if (e === "**" && s === "**") {
return t;
}
if (e === "..") {
if (s && s !== ".." && s !== "." && s !== "**") {
t.pop();
return t;
}
}
t.push(e);
return t;
}, []);
return t.length === 0 ? [ "" ] : t;
});
}
levelTwoFileOptimize(t) {
if (!Array.isArray(t)) {
t = this.slashSplit(t);
}
let e = false;
do {
e = false;
if (!this.preserveMultipleSlashes) {
for (let s = 1; s < t.length - 1; s++) {
const i = t[s];
if (s === 1 && i === "" && t[0] === "") continue;
if (i === "." || i === "") {
e = true;
t.splice(s, 1);
s--;
}
}
if (t[0] === "." && t.length === 2 && (t[1] === "." || t[1] === "")) {
e = true;
t.pop();
}
}
let s = 0;
while (-1 !== (s = t.indexOf("..", s + 1))) {
const i = t[s - 1];
if (i && i !== "." && i !== ".." && i !== "**") {
e = true;
t.splice(s - 1, 2);
s -= 2;
}
}
} while (e);
return t.length === 0 ? [ "" ] : t;
}
firstPhasePreProcess(t) {
let e = false;
do {
e = false;
for (let s of t) {
let i = -1;
while (-1 !== (i = s.indexOf("**", i + 1))) {
let n = i;
while (s[n + 1] === "**") {
n++;
}
if (n > i) {
s.splice(i + 1, n - i);
}
let r = s[i + 1];
const o = s[i + 2];
const h = s[i + 3];
if (r !== "..") continue;
if (!o || o === "." || o === ".." || !h || h === "." || h === "..") {
continue;
}
e = true;
s.splice(i, 1);
const a = s.slice(0);
a[i] = "**";
t.push(a);
i--;
}
if (!this.preserveMultipleSlashes) {
for (let t = 1; t < s.length - 1; t++) {
const i = s[t];
if (t === 1 && i === "" && s[0] === "") continue;
if (i === "." || i === "") {
e = true;
s.splice(t, 1);
t--;
}
}
if (s[0] === "." && s.length === 2 && (s[1] === "." || s[1] === "")) {
e = true;
s.pop();
}
}
let n = 0;
while (-1 !== (n = s.indexOf("..", n + 1))) {
const t = s[n - 1];
if (t && t !== "." && t !== ".." && t !== "**") {
e = true;
const t = n === 1 && s[n + 1] === "**";
const i = t ? [ "." ] : [];
s.splice(n - 1, 2, ...i);
if (s.length === 0) s.push("");
n -= 2;
}
}
}
} while (e);
return t;
}
secondPhasePreProcess(t) {
for (let e = 0; e < t.length - 1; e++) {
for (let s = e + 1; s < t.length; s++) {
const i = this.partsMatch(t[e], t[s], !this.preserveMultipleSlashes);
if (i) {
t[e] = [];
t[s] = i;
break;
}
}
}
return t.filter(t => t.length);
}
partsMatch(t, e, s = false) {
let i = 0;
let n = 0;
let r = [];
let o = "";
while (i < t.length && n < e.length) {
if (t[i] === e[n]) {
r.push(o === "b" ? e[n] : t[i]);
i++;
n++;
} else if (s && t[i] === "**" && e[n] === t[i + 1]) {
r.push(t[i]);
i++;
} else if (s && e[n] === "**" && t[i] === e[n + 1]) {
r.push(e[n]);
n++;
} else if (t[i] === "*" && e[n] && (this.options.dot || !e[n].startsWith(".")) && e[n] !== "**") {
if (o === "b") return false;
o = "a";
r.push(t[i]);
i++;
n++;
} else if (e[n] === "*" && t[i] && (this.options.dot || !t[i].startsWith(".")) && t[i] !== "**") {
if (o === "a") return false;
o = "b";
r.push(e[n]);
i++;
n++;
} else {
return false;
}
}
return t.length === e.length && r;
}
parseNegate() {
if (this.nonegate) return;
const t = this.pattern;
let e = false;
let s = 0;
for (let i = 0; i < t.length && t.charAt(i) === "!"; i++) {
e = !e;
s++;
}
if (s) this.pattern = t.slice(s);
this.negate = e;
}
matchOne(t, e, s = false) {
const i = this.options;
if (this.isWindows) {
const s = typeof t[0] === "string" && /^[a-z]:$/i.test(t[0]);
const i = !s && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]);
const n = typeof e[0] === "string" && /^[a-z]:$/i.test(e[0]);
const r = !n && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] === "string" && /^[a-z]:$/i.test(e[3]);
const o = i ? 3 : s ? 0 : undefined;
const h = r ? 3 : n ? 0 : undefined;
if (typeof o === "number" && typeof h === "number") {
const [s, i] = [ t[o], e[h] ];
if (s.toLowerCase() === i.toLowerCase()) {
e[h] = s;
if (h > o) {
e = e.slice(h);
} else if (o > h) {
t = t.slice(o);
}
}
}
}
const {optimizationLevel: n = 1} = this.options;
if (n >= 2) {
t = this.levelTwoFileOptimize(t);
}
this.debug("matchOne", this, {
file: t,
pattern: e
});
this.debug("matchOne", t.length, e.length);
for (var r = 0, o = 0, h = t.length, a = e.length; r < h && o < a; r++, o++) {
this.debug("matchOne loop");
var l = e[o];
var c = t[r];
this.debug(e, l, c);
if (l === false) {
return false;
}
if (l === Pt) {
this.debug("GLOBSTAR", [ e, l, c ]);
var f = r;
var u = o + 1;
if (u === a) {
this.debug("** at the end");
for (;r < h; r++) {
if (t[r] === "." || t[r] === ".." || !i.dot && t[r].charAt(0) === ".") return false;
}
return true;
}
while (f < h) {
var d = t[f];
this.debug("\nglobstar while", t, f, e, u, d);
if (this.matchOne(t.slice(f), e.slice(u), s)) {
this.debug("globstar found match!", f, h, d);
return true;
} else {
if (d === "." || d === ".." || !i.dot && d.charAt(0) === ".") {
this.debug("dot detected!", t, f, e, u);
break;
}
this.debug("globstar swallow a segment, and continue");
f++;
}
}
if (s) {
this.debug("\n>>> no match, partial?", t, f, e, u);
if (f === h) {
return true;
}
}
return false;
}
let n;
if (typeof l === "string") {
n = c === l;
this.debug("string match", l, c, n);
} else {
n = l.test(c);
this.debug("pattern match", l, c, n);
}
if (!n) return false;
}
if (r === h && o === a) {
return true;
} else if (r === h) {
return s;
} else if (o === a) {
return r === h - 1 && t[r] === "";
} else {
throw new Error("wtf?");
}
}
braceExpand() {
return Wt(this.pattern, this.options);
}
parse(t) {
j(t);
const e = this.options;
if (t === "**") return Pt;
if (t === "") return "";
let s;
let i = null;
if (s = t.match(wt)) {
i = e.dot ? bt : yt;
} else if (s = t.match(ht)) {
i = (e.nocase ? e.dot ? ft : ct : e.dot ? lt : at)(s[1]);
} else if (s = t.match(St)) {
i = (e.nocase ? e.dot ? vt : kt : e.dot ? xt : Et)(s);
} else if (s = t.match(ut)) {
i = e.dot ? pt : dt;
} else if (s = t.match(gt)) {
i = mt;
}
const n = AST.fromGlob(t, this.options).toMMPattern();
if (i && typeof n === "object") {
Reflect.defineProperty(n, "test", {
value: i
});
}
return n;
}
makeRe() {
if (this.regexp || this.regexp === false) return this.regexp;
const t = this.set;
if (!t.length) {
this.regexp = false;
return this.regexp;
}
const e = this.options;
const s = e.noglobstar ? Rt : e.dot ? Ot : zt;
const i = new Set(e.nocase ? [ "i" ] : []);
let n = t.map(t => {
const e = t.map(t => {
if (t instanceof RegExp) {
for (const e of t.flags.split("")) i.add(e);
}
return typeof t === "string" ? Ut(t) : t === Pt ? Pt : t._src;
});
e.forEach((t, i) => {
const n = e[i + 1];
const r = e[i - 1];
if (t !== Pt || r === Pt) {
return;
}
if (r === undefined) {
if (n !== undefined && n !== Pt) {
e[i + 1] = "(?:\\/|" + s + "\\/)?" + n;
} else {
e[i] = s;
}
} else if (n === undefined) {
e[i - 1] = r + "(?:\\/|\\/" + s + ")?";
} else if (n !== Pt) {
e[i - 1] = r + "(?:\\/|\\/" + s + "\\/)" + n;
e[i + 1] = Pt;
}
});
const n = e.filter(t => t !== Pt);
if (this.partial && n.length >= 1) {
const t = [];
for (let e = 1; e <= n.length; e++) {
t.push(n.slice(0, e).join("/"));
}
return "(?:" + t.join("|") + ")";
}
return n.join("/");
}).join("|");
const [r, o] = t.length > 1 ? [ "(?:", ")" ] : [ "", "" ];
n = "^" + r + n + o + "$";
if (this.partial) {
n = "^(?:\\/|" + r + n.slice(1, -1) + o + ")$";
}
if (this.negate) n = "^(?!" + n + ").+$";
try {
this.regexp = new RegExp(n, [ ...i ].join(""));
} catch (t) {
this.regexp = false;
}
return this.regexp;
}
slashSplit(t) {
if (this.preserveMultipleSlashes) {
return t.split("/");
} else if (this.isWindows && /^\/\/[^\/]+/.test(t)) {
return [ "", ...t.split(/\/+/) ];
} else {
return t.split(/\/+/);
}
}
match(t, e = this.partial) {
this.debug("match", t, this.pattern);
if (this.comment) {
return false;
}
if (this.empty) {
return t === "";
}
if (t === "/" && e) {
return true;
}
const s = this.options;
if (this.isWindows) {
t = t.split("\\").join("/");
}
const i = this.slashSplit(t);
this.debug(this.pattern, "split", i);
const n = this.set;
this.debug(this.pattern, "set", n);
let r = i[i.length - 1];
if (!r) {
for (let t = i.length - 2; !r && t >= 0; t--) {
r = i[t];
}
}
for (let t = 0; t < n.length; t++) {
const o = n[t];
let h = i;
if (s.matchBase && o.length === 1) {
h = [ r ];
}
const a = this.matchOne(h, o, e);
if (a) {
if (s.flipNegate) {
return true;
}
return !this.negate;
}
}
if (s.flipNegate) {
return false;
}
return this.negate;
}
static defaults(t) {
return ot.defaults(t).Minimatch;
}
}
ot.AST = AST;
ot.Minimatch = Minimatch;
ot.escape = rt;
ot.unescape = Z;
const $t = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date;
const Gt = new Set;
const qt = typeof process === "object" && !!process ? process : {};
const Ht = (t, e, s, i) => {
typeof qt.emitWarning === "function" ? qt.emitWarning(t, e, s, i) : console.error(`[${s}] ${e}: ${t}`);
};
let Zt = globalThis.AbortController;
let Vt = globalThis.AbortSignal;
if (typeof Zt === "undefined") {
Vt = class AbortSignal {
onabort;
_onabort=[];
reason;
aborted=false;
addEventListener(t, e) {
this._onabort.push(e);
}
};
Zt = class AbortController {
constructor() {
e();
}
signal=new Vt;
abort(t) {
if (this.signal.aborted) return;
this.signal.reason = t;
this.signal.aborted = true;
for (const e of this.signal._onabort) {
e(t);
}
this.signal.onabort?.(t);
}
};
let t = qt.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1";
const e = () => {
if (!t) return;
t = false;
Ht("AbortController is not defined. If using lru-cache in " + "node 14, load an AbortController polyfill from the " + "`node-abort-controller` package. A minimal polyfill is " + "provided for use by LRUCache.fetch(), but it should not be " + "relied upon in other contexts (eg, passing it to other APIs that " + "use AbortController/AbortSignal might have undesirable effects). " + "You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", "NO_ABORT_CONTROLLER", "ENOTSUP", e);
};
}
const Jt = t => !Gt.has(t);
const Kt = t => t && t === Math.floor(t) && t > 0 && isFinite(t);
const Yt = t => !Kt(t) ? null : t <= Math.pow(2, 8) ? Uint8Array : t <= Math.pow(2, 16) ? Uint16Array : t <= Math.pow(2, 32) ? Uint32Array : t <= Number.MAX_SAFE_INTEGER ? ZeroArray : null;
class ZeroArray extends Array {
constructor(t) {
super(t);
this.fill(0);
}
}
class Stack {
heap;
length;
static #g=false;
static create(t) {
const e = Yt(t);
if (!e) return [];
Stack.#g = true;
const s = new Stack(t, e);
Stack.#g = false;
return s;
}
constructor(t, e) {
if (!Stack.#g) {
throw new TypeError("instantiate Stack using Stack.create(n)");
}
this.heap = new e(t);
this.length = 0;
}
push(t) {
this.heap[this.length++] = t;
}
pop() {
return this.heap[--this.length];
}
}
class LRUCache {
#m;
#w;
#y;
#b;
#S;
#k;
#v;
#x;
get perf() {
return this.#x;
}
ttl;
ttlResolution;
ttlAutopurge;
updateAgeOnGet;
updateAgeOnHas;
allowStale;
noDisposeOnSet;
noUpdateTTL;
maxEntrySize;
sizeCalculation;
noDeleteOnFetchRejection;
noDeleteOnStaleGet;
allowStaleOnFetchAbort;
allowStaleOnFetchRejection;
ignoreFetchAbort;
#E;
#C;
#T;
#L;
#A;
#M;
#P;
#F;
#R;
#O;
#z;
#D;
#N;
#B;
#W;
#I;
#_;
#j;
static unsafeExposeInternals(t) {
return {
starts: t.#N,
ttls: t.#B,
sizes: t.#D,
keyMap: t.#T,
keyList: t.#L,
valList: t.#A,
next: t.#M,
prev: t.#P,
get head() {
return t.#F;
},
get tail() {
return t.#R;
},
free: t.#O,
isBackgroundFetch: e => t.#U(e),
backgroundFetch: (e, s, i, n) => t.#$(e, s, i, n),
moveToTail: e => t.#G(e),
indexes: e => t.#q(e),
rindexes: e => t.#H(e),
isStale: e => t.#Z(e)
};
}
get max() {
return this.#m;
}
get maxSize() {
return this.#w;
}
get calculatedSize() {
return this.#C;
}
get size() {
return this.#E;
}
get fetchMethod() {
return this.#k;
}
get memoMethod() {
return this.#v;
}
get dispose() {
return this.#y;
}
get onInsert() {
return this.#b;
}
get disposeAfter() {
return this.#S;
}
constructor(t) {
const {max: e = 0, ttl: s, ttlResolution: i = 1, ttlAutopurge: n, updateAgeOnGet: r, updateAgeOnHas: o, allowStale: h, dispose: a, onInsert: l, disposeAfter: c, noDisposeOnSet: f, noUpdateTTL: u, maxSize: d = 0, maxEntrySize: p = 0, sizeCalculation: g, fetchMethod: m, memoMethod: w, noDeleteOnFetchRejection: y, noDeleteOnStaleGet: b, allowStaleOnFetchRejection: S, allowStaleOnFetchAbort: k, ignoreFetchAbort: v, perf: x} = t;
if (x !== undefined) {
if (typeof x?.now !== "function") {
throw new TypeError("perf option must have a now() method if specified");
}
}
this.#x = x ?? $t;
if (e !== 0 && !Kt(e)) {
throw new TypeError("max option must be a nonnegative integer");
}
const E = e ? Yt(e) : Array;
if (!E) {
throw new Error("invalid max value: " + e);
}
this.#m = e;
this.#w = d;
this.maxEntrySize = p || this.#w;
this.sizeCalculation = g;
if (this.sizeCalculation) {
if (!this.#w && !this.maxEntrySize) {
throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
}
if (typeof this.sizeCalculation !== "function") {
throw new TypeError("s