lakutata
Version:
An IoC-based universal application framework.
1,680 lines (1,580 loc) • 152 kB
JavaScript
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, {
value: "Module"
});
const t = require("../../../vendor/Package.63.cjs");
const e = require("node:url");
const s = require("node:path");
const i = require("fs");
const n = require("node:fs");
const r = require("node:fs/promises");
const o = require("node:events");
const h = require("node:stream");
const a = require("node:string_decoder");
require("../../../vendor/Package.5.cjs");
const l = t => t && t.__esModule ? t : {
default: t
};
function c(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 f = c(n);
const u = l(h);
const d = 1024 * 64;
const p = t => {
if (typeof t !== "string") {
throw new TypeError("invalid pattern");
}
if (t.length > d) {
throw new TypeError("pattern is too long");
}
};
const g = {
"[: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 m = t => t.replace(/[[\]\\-]/g, "\\$&");
const w = t => t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
const y = t => t.join("");
const b = (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(g)) {
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(m(f) + "-" + m(e));
} else if (e === f) {
i.push(m(e));
}
f = "";
r++;
continue;
}
if (t.startsWith("-]", r + 1)) {
i.push(m(e + "-"));
r += 2;
continue;
}
if (t.startsWith("-", r + 1)) {
f = e;
r += 2;
continue;
}
i.push(m(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 [ w(t), false, c - s, false ];
}
const u = "[" + (l ? "^" : "") + y(i) + "]";
const d = "[" + (l ? "" : "^") + y(n) + "]";
const p = i.length && n.length ? "(" + u + "|" + d + ")" : i.length ? u : d;
return [ p, h, c - s, true ];
};
const S = (t, {windowsPathsNoEscape: e = false} = {}) => e ? t.replace(/\[([^\/\\])\]/g, "$1") : t.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1");
const k = new Set([ "!", "?", "+", "*", "@" ]);
const v = t => k.has(t);
const x = "(?!(?:^|/)\\.\\.?(?:$|/))";
const E = "(?!\\.)";
const T = new Set([ "[", "." ]);
const C = new Set([ "..", "." ]);
const L = new Set("().*{}+?[]^$\\!");
const A = t => t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
const M = "[^/]";
const P = M + "*?";
const F = M + "+?";
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 && v(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 (v(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();
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 && C.has(this.#i[0]);
if (!s) {
const s = T;
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 ? x : o ? E : "";
}
}
}
let r = "";
if (this.isEnd() && this.#t.#h && this.#n?.type === "!") {
r = "(?:$|\\/)";
}
const o = n + i + r;
return [ o, S(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, S(this.toString()), false, false ];
}
let r = !s || t || e || !E ? "" : this.#p(true);
if (r === n) {
r = "";
}
if (r) {
n = `(?:${n})(?:${r})*?`;
}
let o = "";
if (this.type === "!" && this.#c) {
o = (this.isStart() && !e ? E : "") + F;
} else {
const s = this.type === "!" ? "))" + (this.isStart() && !e && !t ? E : "") + P + ")" : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && r ? ")" : this.type === "*" && r ? `)?` : `)${this.type}`;
o = i + n + s;
}
return [ o, S(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 += (L.has(h) ? "\\" : "") + h;
continue;
}
if (h === "\\") {
if (o === t.length - 1) {
n += "\\\\";
} else {
i = true;
}
continue;
}
if (h === "[") {
const [s, i, h, a] = b(t, o);
if (h) {
n += s;
r = r || i;
o += h - 1;
e = e || a;
continue;
}
}
if (h === "*") {
if (s && t === "*") n += F; else n += P;
e = true;
continue;
}
if (h === "?") {
n += M;
e = true;
continue;
}
n += A(h);
}
return [ n, S(t), !!e, r ];
}
}
const R = (t, {windowsPathsNoEscape: e = false} = {}) => e ? t.replace(/[?*()[\]]/g, "[$&]") : t.replace(/[?*()[\]\\]/g, "\\$&");
const O = (t, e, s = {}) => {
p(e);
if (!s.nocomment && e.charAt(0) === "#") {
return false;
}
return new Minimatch(e, s).match(t);
};
const z = /^\*+([^+@!?\*\[\(]*)$/;
const D = t => e => !e.startsWith(".") && e.endsWith(t);
const N = t => e => e.endsWith(t);
const B = t => {
t = t.toLowerCase();
return e => !e.startsWith(".") && e.toLowerCase().endsWith(t);
};
const W = t => {
t = t.toLowerCase();
return e => e.toLowerCase().endsWith(t);
};
const _ = /^\*+\.\*+$/;
const I = t => !t.startsWith(".") && t.includes(".");
const j = t => t !== "." && t !== ".." && t.includes(".");
const U = /^\.\*+$/;
const G = t => t !== "." && t !== ".." && t.startsWith(".");
const $ = /^\*+$/;
const q = t => t.length !== 0 && !t.startsWith(".");
const H = t => t.length !== 0 && t !== "." && t !== "..";
const Z = /^\?+([^+@!?\*\[\(]*)?$/;
const V = ([t, e = ""]) => {
const s = X([ t ]);
if (!e) return s;
e = e.toLowerCase();
return t => s(t) && t.toLowerCase().endsWith(e);
};
const J = ([t, e = ""]) => {
const s = Q([ t ]);
if (!e) return s;
e = e.toLowerCase();
return t => s(t) && t.toLowerCase().endsWith(e);
};
const K = ([t, e = ""]) => {
const s = Q([ t ]);
return !e ? s : t => s(t) && t.endsWith(e);
};
const Y = ([t, e = ""]) => {
const s = X([ t ]);
return !e ? s : t => s(t) && t.endsWith(e);
};
const X = ([t]) => {
const e = t.length;
return t => t.length === e && !t.startsWith(".");
};
const Q = ([t]) => {
const e = t.length;
return t => t.length === e && t !== "." && t !== "..";
};
const tt = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
const et = {
win32: {
sep: "\\"
},
posix: {
sep: "/"
}
};
const st = tt === "win32" ? et.win32.sep : et.posix.sep;
O.sep = st;
const it = Symbol("globstar **");
O.GLOBSTAR = it;
const nt = "[^/]";
const rt = nt + "*?";
const ot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
const ht = "(?:(?!(?:\\/|^)\\.).)*?";
const at = (t, e = {}) => s => O(s, t, e);
O.filter = at;
const lt = (t, e = {}) => Object.assign({}, t, e);
const ct = t => {
if (!t || typeof t !== "object" || !Object.keys(t).length) {
return O;
}
const e = O;
const s = (s, i, n = {}) => e(s, i, lt(t, n));
return Object.assign(s, {
Minimatch: class Minimatch extends e.Minimatch {
constructor(e, s = {}) {
super(e, lt(t, s));
}
static defaults(s) {
return e.defaults(lt(t, s)).Minimatch;
}
},
AST: class AST extends e.AST {
constructor(e, s, i = {}) {
super(e, s, lt(t, i));
}
static fromGlob(s, i = {}) {
return e.AST.fromGlob(s, lt(t, i));
}
},
unescape: (s, i = {}) => e.unescape(s, lt(t, i)),
escape: (s, i = {}) => e.escape(s, lt(t, i)),
filter: (s, i = {}) => e.filter(s, lt(t, i)),
defaults: s => e.defaults(lt(t, s)),
makeRe: (s, i = {}) => e.makeRe(s, lt(t, i)),
braceExpand: (s, i = {}) => e.braceExpand(s, lt(t, i)),
match: (s, i, n = {}) => e.match(s, i, lt(t, n)),
sep: e.sep,
GLOBSTAR: it
});
};
O.defaults = ct;
const ft = (e, s = {}) => {
p(e);
if (s.nobrace || !/\{(?:(?!\{).)*\}/.test(e)) {
return [ e ];
}
return t.expand(e);
};
O.braceExpand = ft;
const ut = (t, e = {}) => new Minimatch(t, e).makeRe();
O.makeRe = ut;
const dt = (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;
};
O.match = dt;
const pt = /[?*]|[+@!]\(.*?\)|\[|\]/;
const gt = 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 = {}) {
p(t);
e = e || {};
this.options = e;
this.pattern = t;
this.platform = e.platform || tt;
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] === "?" || !pt.test(t[2])) && !pt.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 === it) {
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 ft(this.pattern, this.options);
}
parse(t) {
p(t);
const e = this.options;
if (t === "**") return it;
if (t === "") return "";
let s;
let i = null;
if (s = t.match($)) {
i = e.dot ? H : q;
} else if (s = t.match(z)) {
i = (e.nocase ? e.dot ? W : B : e.dot ? N : D)(s[1]);
} else if (s = t.match(Z)) {
i = (e.nocase ? e.dot ? J : V : e.dot ? K : Y)(s);
} else if (s = t.match(_)) {
i = e.dot ? j : I;
} else if (s = t.match(U)) {
i = G;
}
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 : ht;
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" ? gt(t) : t === it ? it : t._src;
}));
e.forEach(((t, i) => {
const n = e[i + 1];
const r = e[i - 1];
if (t !== it || r === it) {
return;
}
if (r === undefined) {
if (n !== undefined && n !== it) {
e[i + 1] = "(?:\\/|" + s + "\\/)?" + n;
} else {
e[i] = s;
}
} else if (n === undefined) {
e[i - 1] = r + "(?:\\/|" + s + ")?";
} else if (n !== it) {
e[i - 1] = r + "(?:\\/|\\/" + s + "\\/)" + n;
e[i + 1] = it;
}
}));
return e.filter((t => t !== it)).join("/");
})).join("|");
const [r, o] = t.length > 1 ? [ "(?:", ")" ] : [ "", "" ];
n = "^" + r + n + 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 O.defaults(t).Minimatch;
}
}
O.AST = AST;
O.Minimatch = Minimatch;
O.escape = R;
O.unescape = S;
const mt = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date;
const wt = new Set;
const yt = typeof process === "object" && !!process ? process : {};
const bt = (t, e, s, i) => {
typeof yt.emitWarning === "function" ? yt.emitWarning(t, e, s, i) : console.error(`[${s}] ${e}: ${t}`);
};
let St = globalThis.AbortController;
let kt = globalThis.AbortSignal;
if (typeof St === "undefined") {
kt = class AbortSignal {
onabort;
_onabort=[];
reason;
aborted=false;
addEventListener(t, e) {
this._onabort.push(e);
}
};
St = class AbortController {
constructor() {
e();
}
signal=new kt;
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 = yt.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1";
const e = () => {
if (!t) return;
t = false;
bt("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 vt = t => !wt.has(t);
const xt = Symbol("type");
const Et = t => t && t === Math.floor(t) && t > 0 && isFinite(t);
const Tt = t => !Et(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 = Tt(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;
ttl;
ttlResolution;
ttlAutopurge;
updateAgeOnGet;
updateAgeOnHas;
allowStale;
noDisposeOnSet;
noUpdateTTL;
maxEntrySize;
sizeCalculation;
noDeleteOnFetchRejection;
noDeleteOnStaleGet;
allowStaleOnFetchAbort;
allowStaleOnFetchRejection;
ignoreFetchAbort;
#x;
#E;
#T;
#C;
#L;
#A;
#M;
#P;
#F;
#R;
#O;
#z;
#D;
#N;
#B;
#W;
#_;
#I;
static unsafeExposeInternals(t) {
return {
starts: t.#D,
ttls: t.#N,
sizes: t.#z,
keyMap: t.#T,
keyList: t.#C,
valList: t.#L,
next: t.#A,
prev: t.#M,
get head() {
return t.#P;
},
get tail() {
return t.#F;
},
free: t.#R,
isBackgroundFetch: e => t.#j(e),
backgroundFetch: (e, s, i, n) => t.#U(e, s, i, n),
moveToTail: e => t.#G(e),
indexes: e => t.#$(e),
rindexes: e => t.#q(e),
isStale: e => t.#H(e)
};
}
get max() {
return this.#m;
}
get maxSize() {
return this.#w;
}
get calculatedSize() {
return this.#E;
}
get size() {
return this.#x;
}
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} = t;
if (e !== 0 && !Et(e)) {
throw new TypeError("max option must be a nonnegative integer");
}
const x = e ? Tt(e) : Array;
if (!x) {
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("sizeCalculation set to non-function");
}
}
if (w !== undefined && typeof w !== "function") {
throw new TypeError("memoMethod must be a function if defined");
}
this.#v = w;
if (m !== undefined && typeof m !== "function") {
throw new TypeError("fetchMethod must be a function if specified");
}
this.#k = m;
this.#W = !!m;
this.#T = new Map;
this.#C = new Array(e).fill(undefined);
this.#L = new Array(e).fill(undefined);
this.#A = new x(e);
this.#M = new x(e);
this.#P = 0;
this.#F = 0;
this.#R = Stack.create(e);
this.#x = 0;
this.#E = 0;
if (typeof a === "function") {
this.#y = a;
}
if (typeof l === "function") {
this.#b = l;
}
if (typeof c === "function") {
this.#S = c;
this.#O = [];
} else {
this.#S = undefined;
this.#O = undefined;
}
this.#B = !!this.#y;
this.#I = !!this.#b;
this.#_ = !!this.#S;
this.noDisposeOnSet = !!f;
this.noUpdateTTL = !!u;
this.noDeleteOnFetchRejection = !!y;
this.allowStaleOnFetchRejection = !!S;
this.allowStaleOnFetchAbort = !!k;
this.ignoreFetchAbort = !!v;
if (this.maxEntrySize !== 0) {
if (this.#w !== 0) {
if (!Et(this.#w)) {
throw new TypeError("maxSize must be a positive integer if specified");
}
}
if (!Et(this.maxEntrySize)) {
throw new TypeError("maxEntrySize must be a positive integer if specified");
}
this.#Z();
}
this.allowStale = !!h;
this.noDeleteOnStaleGet = !!b;
this.updateAgeOnGet = !!r;
this.updateAgeOnHas = !!o;
this.ttlResolution = Et(i) || i === 0 ? i : 1;
this.ttlAutopurge = !!n;
this.ttl = s || 0;
if (this.ttl) {
if (!Et(this.ttl)) {
throw new TypeError("ttl must be a positive integer if specified");
}
this.#V();
}
if (this.#m === 0 && this.ttl === 0 && this.#w === 0) {
throw new TypeError("At least one of max, maxSize, or ttl is required");
}
if (!this.ttlAutopurge && !this.#m && !this.#w) {
const t = "LRU_CACHE_UNBOUNDED";
if (vt(t)) {
wt.add(t);
const e = "TTL caching without ttlAutopurge, max, or maxSize can " + "result in unbounded memory consumption.";
bt(e, "UnboundedCacheWarning", t, LRUCache);
}
}
}
getRemainingTTL(t) {
return this.#T.has(t) ? Infinity : 0;
}
#V() {
const t = new ZeroArray(this.#m);
const e = new ZeroArray(this.#m);
this.#N = t;
this.#D = e;
this.#J = (s, i, n = mt.now()) => {
e[s] = i !== 0 ? n : 0;
t[s] = i;
if (i !== 0 && this.ttlAutopurge) {
const t = setTimeout((() => {
if (this.#H(s)) {
this.#K(this.#C[s], "expire");
}
}), i + 1);
if (t.unref) {
t.unref();
}
}
};
this.#Y = s => {
e[s] = t[s] !== 0 ? mt.now() : 0;
};
this.#X = (n, r) => {
if (t[r]) {
const o = t[r];
const h = e[r];
if (!o || !h) return;
n.ttl = o;
n.start = h;
n.now = s || i();
const a = n.now - h;
n.remainingTTL = o - a;
}
};
let s = 0;
const i = () => {
const t = mt.now();
if (this.ttlResolution > 0) {
s = t;
const e = setTimeout((() => s = 0), this.ttlResolution);
if (e.unref) {
e.unref();
}
}
return t;
};
this.getRemainingTTL = n => {
const r = this.#T.get(n);
if (r === undefined) {
return 0;
}
const o = t[r];
const h = e[r];
if (!o || !h) {
return Infinity;
}
const a = (s || i()) - h;
return o - a;
};
this.#H = n => {
const r = e[n];
const o = t[n];
return !!o && !!r && (s || i()) - r > o;
};
}
#Y=() => {};
#X=() => {};
#J=() => {};
#H=() => false;
#Z() {
const t = new ZeroArray(this.#m);
this.#E = 0;
this.#z = t;
this.#Q = e => {
this.#E -= t[e];
t[e] = 0;
};
this.#tt = (t, e, s, i) => {
if (this.#j(e)) {
return 0;
}
if (!Et(s)) {
if (i) {
if (typeof i !== "function") {
throw new TypeError("sizeCalculation must be a function");
}
s = i(e, t);
if (!Et(s)) {
throw new TypeError("sizeCalculation return invalid (expect positive integer)");
}
} else {
throw new TypeError("invalid size value (must be positive integer). " + "When maxSize or maxEntrySize is used, sizeCalculation " + "or size must be set.");
}
}
return s;
};
this.#et = (e, s, i) => {
t[e] = s;
if (this.#w) {
const s = this.#w - t[e];
while (this.#E > s) {
this.#st(true);
}
}
this.#E += t[e];
if (i) {
i.entrySize = s;
i.totalCalculatedSize = this.#E;
}
};
}
#Q=t => {};
#et=(t, e, s) => {};
#tt=(t, e, s, i) => {
if (s || i) {
throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
}
return 0;
};
* #$({allowStale: t = this.allowStale} = {}) {
if (this.#x) {
for (let e = this.#F; true; ) {
if (!this.#it(e)) {
break;
}
if (t || !this.#H(e)) {
yield e;
}
if (e === this.#P) {