pncat
Version:
A unified cli tool that enhances package managers catalogs feature.
5,267 lines • 168 kB
JavaScript
import { r as __require, t as __commonJSMin } from "./chunk-6qLfnLNH.mjs";
import { r as require_commonjs$6 } from "./npa-fnjp9MqV.mjs";
//#region node_modules/.pnpm/proc-log@5.0.0/node_modules/proc-log/lib/index.js
var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
const META = Symbol("proc-log.meta");
module.exports = {
META,
output: {
LEVELS: [
"standard",
"error",
"buffer",
"flush"
],
KEYS: {
standard: "standard",
error: "error",
buffer: "buffer",
flush: "flush"
},
standard: function(...args) {
return process.emit("output", "standard", ...args);
},
error: function(...args) {
return process.emit("output", "error", ...args);
},
buffer: function(...args) {
return process.emit("output", "buffer", ...args);
},
flush: function(...args) {
return process.emit("output", "flush", ...args);
}
},
log: {
LEVELS: [
"notice",
"error",
"warn",
"info",
"verbose",
"http",
"silly",
"timing",
"pause",
"resume"
],
KEYS: {
notice: "notice",
error: "error",
warn: "warn",
info: "info",
verbose: "verbose",
http: "http",
silly: "silly",
timing: "timing",
pause: "pause",
resume: "resume"
},
error: function(...args) {
return process.emit("log", "error", ...args);
},
notice: function(...args) {
return process.emit("log", "notice", ...args);
},
warn: function(...args) {
return process.emit("log", "warn", ...args);
},
info: function(...args) {
return process.emit("log", "info", ...args);
},
verbose: function(...args) {
return process.emit("log", "verbose", ...args);
},
http: function(...args) {
return process.emit("log", "http", ...args);
},
silly: function(...args) {
return process.emit("log", "silly", ...args);
},
timing: function(...args) {
return process.emit("log", "timing", ...args);
},
pause: function() {
return process.emit("log", "pause");
},
resume: function() {
return process.emit("log", "resume");
}
},
time: {
LEVELS: ["start", "end"],
KEYS: {
start: "start",
end: "end"
},
start: function(name, fn) {
process.emit("time", "start", name);
function end() {
return process.emit("time", "end", name);
}
if (typeof fn === "function") {
const res = fn();
if (res && res.finally) return res.finally(end);
end();
return res;
}
return end;
},
end: function(name) {
return process.emit("time", "end", name);
}
},
input: {
LEVELS: [
"start",
"end",
"read"
],
KEYS: {
start: "start",
end: "end",
read: "read"
},
start: function(fn) {
process.emit("input", "start");
function end() {
return process.emit("input", "end");
}
if (typeof fn === "function") {
const res = fn();
if (res && res.finally) return res.finally(end);
end();
return res;
}
return end;
},
end: function() {
return process.emit("input", "end");
},
read: function(...args) {
let resolve, reject;
const promise = new Promise((_resolve, _reject) => {
resolve = _resolve;
reject = _reject;
});
process.emit("input", "read", resolve, reject, ...args);
return promise;
}
}
};
}));
//#endregion
//#region node_modules/.pnpm/@isaacs+balanced-match@4.0.1/node_modules/@isaacs/balanced-match/dist/commonjs/index.js
var require_commonjs$5 = /* @__PURE__ */ __commonJSMin(((exports) => {
Object.defineProperty(exports, "__esModule", { value: true });
exports.range = exports.balanced = void 0;
const balanced = (a, b, str) => {
const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
const mb = b instanceof RegExp ? maybeMatch(b, str) : b;
const r = ma !== null && mb != null && (0, exports.range)(ma, mb, str);
return r && {
start: r[0],
end: r[1],
pre: str.slice(0, r[0]),
body: str.slice(r[0] + ma.length, r[1]),
post: str.slice(r[1] + mb.length)
};
};
exports.balanced = balanced;
const maybeMatch = (reg, str) => {
const m = str.match(reg);
return m ? m[0] : null;
};
const range = (a, b, str) => {
let begs, beg, left, right = void 0, result;
let ai = str.indexOf(a);
let bi = str.indexOf(b, ai + 1);
let i = ai;
if (ai >= 0 && bi > 0) {
if (a === b) return [ai, bi];
begs = [];
left = str.length;
while (i >= 0 && !result) {
if (i === ai) {
begs.push(i);
ai = str.indexOf(a, i + 1);
} else if (begs.length === 1) {
const r = begs.pop();
if (r !== void 0) result = [r, bi];
} else {
beg = begs.pop();
if (beg !== void 0 && beg < left) {
left = beg;
right = bi;
}
bi = str.indexOf(b, i + 1);
}
i = ai < bi && ai >= 0 ? ai : bi;
}
if (begs.length && right !== void 0) result = [left, right];
}
return result;
};
exports.range = range;
}));
//#endregion
//#region node_modules/.pnpm/@isaacs+brace-expansion@5.0.0/node_modules/@isaacs/brace-expansion/dist/commonjs/index.js
var require_commonjs$4 = /* @__PURE__ */ __commonJSMin(((exports) => {
Object.defineProperty(exports, "__esModule", { value: true });
exports.expand = expand;
const balanced_match_1 = require_commonjs$5();
const escSlash = "\0SLASH" + Math.random() + "\0";
const escOpen = "\0OPEN" + Math.random() + "\0";
const escClose = "\0CLOSE" + Math.random() + "\0";
const escComma = "\0COMMA" + Math.random() + "\0";
const escPeriod = "\0PERIOD" + Math.random() + "\0";
const escSlashPattern = new RegExp(escSlash, "g");
const escOpenPattern = new RegExp(escOpen, "g");
const escClosePattern = new RegExp(escClose, "g");
const escCommaPattern = new RegExp(escComma, "g");
const escPeriodPattern = new RegExp(escPeriod, "g");
const slashPattern = /\\\\/g;
const openPattern = /\\{/g;
const closePattern = /\\}/g;
const commaPattern = /\\,/g;
const periodPattern = /\\./g;
function numeric(str) {
return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
}
function escapeBraces(str) {
return str.replace(slashPattern, escSlash).replace(openPattern, escOpen).replace(closePattern, escClose).replace(commaPattern, escComma).replace(periodPattern, escPeriod);
}
function unescapeBraces(str) {
return str.replace(escSlashPattern, "\\").replace(escOpenPattern, "{").replace(escClosePattern, "}").replace(escCommaPattern, ",").replace(escPeriodPattern, ".");
}
/**
* Basically just str.split(","), but handling cases
* where we have nested braced sections, which should be
* treated as individual members, like {a,{b,c},d}
*/
function parseCommaParts(str) {
if (!str) return [""];
const parts = [];
const m = (0, balanced_match_1.balanced)("{", "}", str);
if (!m) return str.split(",");
const { pre, body, post } = m;
const p = pre.split(",");
p[p.length - 1] += "{" + body + "}";
const postParts = parseCommaParts(post);
if (post.length) {
p[p.length - 1] += postParts.shift();
p.push.apply(p, postParts);
}
parts.push.apply(parts, p);
return parts;
}
function expand(str) {
if (!str) return [];
if (str.slice(0, 2) === "{}") str = "\\{\\}" + str.slice(2);
return expand_(escapeBraces(str), true).map(unescapeBraces);
}
function embrace(str) {
return "{" + str + "}";
}
function isPadded(el) {
return /^-?0\d/.test(el);
}
function lte(i, y) {
return i <= y;
}
function gte(i, y) {
return i >= y;
}
function expand_(str, isTop) {
/** @type {string[]} */
const expansions = [];
const m = (0, balanced_match_1.balanced)("{", "}", str);
if (!m) return [str];
const pre = m.pre;
const post = m.post.length ? expand_(m.post, false) : [""];
if (/\$$/.test(m.pre)) for (let k = 0; k < post.length; k++) {
const expansion = pre + "{" + m.body + "}" + post[k];
expansions.push(expansion);
}
else {
const isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
const isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
const isSequence = isNumericSequence || isAlphaSequence;
const isOptions = m.body.indexOf(",") >= 0;
if (!isSequence && !isOptions) {
if (m.post.match(/,(?!,).*\}/)) {
str = m.pre + "{" + m.body + escClose + m.post;
return expand_(str);
}
return [str];
}
let n;
if (isSequence) n = m.body.split(/\.\./);
else {
n = parseCommaParts(m.body);
if (n.length === 1 && n[0] !== void 0) {
n = expand_(n[0], false).map(embrace);
/* c8 ignore start */
if (n.length === 1) return post.map((p) => m.pre + n[0] + p);
}
}
let N;
if (isSequence && n[0] !== void 0 && n[1] !== void 0) {
const x = numeric(n[0]);
const y = numeric(n[1]);
const width = Math.max(n[0].length, n[1].length);
let incr = n.length === 3 && n[2] !== void 0 ? Math.abs(numeric(n[2])) : 1;
let test = lte;
if (y < x) {
incr *= -1;
test = gte;
}
const pad = n.some(isPadded);
N = [];
for (let i = x; test(i, y); i += incr) {
let c;
if (isAlphaSequence) {
c = String.fromCharCode(i);
if (c === "\\") c = "";
} else {
c = String(i);
if (pad) {
const need = width - c.length;
if (need > 0) {
const z = new Array(need + 1).join("0");
if (i < 0) c = "-" + z + c.slice(1);
else c = z + c;
}
}
}
N.push(c);
}
} else {
N = [];
for (let j = 0; j < n.length; j++) N.push.apply(N, expand_(n[j], false));
}
for (let j = 0; j < N.length; j++) for (let k = 0; k < post.length; k++) {
const expansion = pre + N[j] + post[k];
if (!isTop || isSequence || expansion) expansions.push(expansion);
}
}
return expansions;
}
}));
//#endregion
//#region node_modules/.pnpm/minimatch@10.0.3/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js
var require_assert_valid_pattern = /* @__PURE__ */ __commonJSMin(((exports) => {
Object.defineProperty(exports, "__esModule", { value: true });
exports.assertValidPattern = void 0;
const MAX_PATTERN_LENGTH = 1024 * 64;
const assertValidPattern = (pattern) => {
if (typeof pattern !== "string") throw new TypeError("invalid pattern");
if (pattern.length > MAX_PATTERN_LENGTH) throw new TypeError("pattern is too long");
};
exports.assertValidPattern = assertValidPattern;
}));
//#endregion
//#region node_modules/.pnpm/minimatch@10.0.3/node_modules/minimatch/dist/commonjs/brace-expressions.js
var require_brace_expressions = /* @__PURE__ */ __commonJSMin(((exports) => {
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseClass = void 0;
const posixClasses = {
"[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true],
"[:alpha:]": ["\\p{L}\\p{Nl}", true],
"[:ascii:]": ["\\x00-\\x7f", 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 braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&");
const regexpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
const rangesToString = (ranges) => ranges.join("");
const parseClass = (glob, position) => {
const pos = position;
/* c8 ignore start */
if (glob.charAt(pos) !== "[") throw new Error("not in a brace expression");
/* c8 ignore stop */
const ranges = [];
const negs = [];
let i = pos + 1;
let sawStart = false;
let uflag = false;
let escaping = false;
let negate = false;
let endPos = pos;
let rangeStart = "";
WHILE: while (i < glob.length) {
const c = glob.charAt(i);
if ((c === "!" || c === "^") && i === pos + 1) {
negate = true;
i++;
continue;
}
if (c === "]" && sawStart && !escaping) {
endPos = i + 1;
break;
}
sawStart = true;
if (c === "\\") {
if (!escaping) {
escaping = true;
i++;
continue;
}
}
if (c === "[" && !escaping) {
for (const [cls, [unip, u, neg]] of Object.entries(posixClasses)) if (glob.startsWith(cls, i)) {
if (rangeStart) return [
"$.",
false,
glob.length - pos,
true
];
i += cls.length;
if (neg) negs.push(unip);
else ranges.push(unip);
uflag = uflag || u;
continue WHILE;
}
}
escaping = false;
if (rangeStart) {
if (c > rangeStart) ranges.push(braceEscape(rangeStart) + "-" + braceEscape(c));
else if (c === rangeStart) ranges.push(braceEscape(c));
rangeStart = "";
i++;
continue;
}
if (glob.startsWith("-]", i + 1)) {
ranges.push(braceEscape(c + "-"));
i += 2;
continue;
}
if (glob.startsWith("-", i + 1)) {
rangeStart = c;
i += 2;
continue;
}
ranges.push(braceEscape(c));
i++;
}
if (endPos < i) return [
"",
false,
0,
false
];
if (!ranges.length && !negs.length) return [
"$.",
false,
glob.length - pos,
true
];
if (negs.length === 0 && ranges.length === 1 && /^\\?.$/.test(ranges[0]) && !negate) return [
regexpEscape(ranges[0].length === 2 ? ranges[0].slice(-1) : ranges[0]),
false,
endPos - pos,
false
];
const sranges = "[" + (negate ? "^" : "") + rangesToString(ranges) + "]";
const snegs = "[" + (negate ? "" : "^") + rangesToString(negs) + "]";
return [
ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs,
uflag,
endPos - pos,
true
];
};
exports.parseClass = parseClass;
}));
//#endregion
//#region node_modules/.pnpm/minimatch@10.0.3/node_modules/minimatch/dist/commonjs/unescape.js
var require_unescape = /* @__PURE__ */ __commonJSMin(((exports) => {
Object.defineProperty(exports, "__esModule", { value: true });
exports.unescape = void 0;
/**
* Un-escape a string that has been escaped with {@link escape}.
*
* If the {@link windowsPathsNoEscape} option is used, then square-brace
* escapes are removed, but not backslash escapes. For example, it will turn
* the string `'[*]'` into `*`, but it will not turn `'\\*'` into `'*'`,
* becuase `\` is a path separator in `windowsPathsNoEscape` mode.
*
* When `windowsPathsNoEscape` is not set, then both brace escapes and
* backslash escapes are removed.
*
* Slashes (and backslashes in `windowsPathsNoEscape` mode) cannot be escaped
* or unescaped.
*/
const unescape = (s, { windowsPathsNoEscape = false } = {}) => {
return windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1");
};
exports.unescape = unescape;
}));
//#endregion
//#region node_modules/.pnpm/minimatch@10.0.3/node_modules/minimatch/dist/commonjs/ast.js
var require_ast = /* @__PURE__ */ __commonJSMin(((exports) => {
Object.defineProperty(exports, "__esModule", { value: true });
exports.AST = void 0;
const brace_expressions_js_1 = require_brace_expressions();
const unescape_js_1$1 = require_unescape();
const types = new Set([
"!",
"?",
"+",
"*",
"@"
]);
const isExtglobType = (c) => types.has(c);
const startNoTraversal = "(?!(?:^|/)\\.\\.?(?:$|/))";
const startNoDot = "(?!\\.)";
const addPatternStart = new Set(["[", "."]);
const justDots = new Set(["..", "."]);
const reSpecials = /* @__PURE__ */ new Set("().*{}+?[]^$\\!");
const regExpEscape$1 = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
const qmark = "[^/]";
const star$1 = qmark + "*?";
const starNoEmpty = qmark + "+?";
var AST = class AST {
type;
#root;
#hasMagic;
#uflag = false;
#parts = [];
#parent;
#parentIndex;
#negs;
#filledNegs = false;
#options;
#toString;
#emptyExt = false;
constructor(type, parent, options = {}) {
this.type = type;
if (type) this.#hasMagic = true;
this.#parent = parent;
this.#root = this.#parent ? this.#parent.#root : this;
this.#options = this.#root === this ? options : this.#root.#options;
this.#negs = this.#root === this ? [] : this.#root.#negs;
if (type === "!" && !this.#root.#filledNegs) this.#negs.push(this);
this.#parentIndex = this.#parent ? this.#parent.#parts.length : 0;
}
get hasMagic() {
/* c8 ignore start */
if (this.#hasMagic !== void 0) return this.#hasMagic;
/* c8 ignore stop */
for (const p of this.#parts) {
if (typeof p === "string") continue;
if (p.type || p.hasMagic) return this.#hasMagic = true;
}
return this.#hasMagic;
}
toString() {
if (this.#toString !== void 0) return this.#toString;
if (!this.type) return this.#toString = this.#parts.map((p) => String(p)).join("");
else return this.#toString = this.type + "(" + this.#parts.map((p) => String(p)).join("|") + ")";
}
#fillNegs() {
/* c8 ignore start */
if (this !== this.#root) throw new Error("should only call on root");
if (this.#filledNegs) return this;
/* c8 ignore stop */
this.toString();
this.#filledNegs = true;
let n;
while (n = this.#negs.pop()) {
if (n.type !== "!") continue;
let p = n;
let pp = p.#parent;
while (pp) {
for (let i = p.#parentIndex + 1; !pp.type && i < pp.#parts.length; i++) for (const part of n.#parts) {
/* c8 ignore start */
if (typeof part === "string") throw new Error("string part in extglob AST??");
/* c8 ignore stop */
part.copyIn(pp.#parts[i]);
}
p = pp;
pp = p.#parent;
}
}
return this;
}
push(...parts) {
for (const p of parts) {
if (p === "") continue;
/* c8 ignore start */
if (typeof p !== "string" && !(p instanceof AST && p.#parent === this)) throw new Error("invalid part: " + p);
/* c8 ignore stop */
this.#parts.push(p);
}
}
toJSON() {
const ret = this.type === null ? this.#parts.slice().map((p) => typeof p === "string" ? p : p.toJSON()) : [this.type, ...this.#parts.map((p) => p.toJSON())];
if (this.isStart() && !this.type) ret.unshift([]);
if (this.isEnd() && (this === this.#root || this.#root.#filledNegs && this.#parent?.type === "!")) ret.push({});
return ret;
}
isStart() {
if (this.#root === this) return true;
if (!this.#parent?.isStart()) return false;
if (this.#parentIndex === 0) return true;
const p = this.#parent;
for (let i = 0; i < this.#parentIndex; i++) {
const pp = p.#parts[i];
if (!(pp instanceof AST && pp.type === "!")) return false;
}
return true;
}
isEnd() {
if (this.#root === this) return true;
if (this.#parent?.type === "!") return true;
if (!this.#parent?.isEnd()) return false;
if (!this.type) return this.#parent?.isEnd();
/* c8 ignore start */
const pl = this.#parent ? this.#parent.#parts.length : 0;
/* c8 ignore stop */
return this.#parentIndex === pl - 1;
}
copyIn(part) {
if (typeof part === "string") this.push(part);
else this.push(part.clone(this));
}
clone(parent) {
const c = new AST(this.type, parent);
for (const p of this.#parts) c.copyIn(p);
return c;
}
static #parseAST(str, ast, pos, opt) {
let escaping = false;
let inBrace = false;
let braceStart = -1;
let braceNeg = false;
if (ast.type === null) {
let i$1 = pos;
let acc$1 = "";
while (i$1 < str.length) {
const c = str.charAt(i$1++);
if (escaping || c === "\\") {
escaping = !escaping;
acc$1 += c;
continue;
}
if (inBrace) {
if (i$1 === braceStart + 1) {
if (c === "^" || c === "!") braceNeg = true;
} else if (c === "]" && !(i$1 === braceStart + 2 && braceNeg)) inBrace = false;
acc$1 += c;
continue;
} else if (c === "[") {
inBrace = true;
braceStart = i$1;
braceNeg = false;
acc$1 += c;
continue;
}
if (!opt.noext && isExtglobType(c) && str.charAt(i$1) === "(") {
ast.push(acc$1);
acc$1 = "";
const ext$1 = new AST(c, ast);
i$1 = AST.#parseAST(str, ext$1, i$1, opt);
ast.push(ext$1);
continue;
}
acc$1 += c;
}
ast.push(acc$1);
return i$1;
}
let i = pos + 1;
let part = new AST(null, ast);
const parts = [];
let acc = "";
while (i < str.length) {
const c = str.charAt(i++);
if (escaping || c === "\\") {
escaping = !escaping;
acc += c;
continue;
}
if (inBrace) {
if (i === braceStart + 1) {
if (c === "^" || c === "!") braceNeg = true;
} else if (c === "]" && !(i === braceStart + 2 && braceNeg)) inBrace = false;
acc += c;
continue;
} else if (c === "[") {
inBrace = true;
braceStart = i;
braceNeg = false;
acc += c;
continue;
}
if (isExtglobType(c) && str.charAt(i) === "(") {
part.push(acc);
acc = "";
const ext$1 = new AST(c, part);
part.push(ext$1);
i = AST.#parseAST(str, ext$1, i, opt);
continue;
}
if (c === "|") {
part.push(acc);
acc = "";
parts.push(part);
part = new AST(null, ast);
continue;
}
if (c === ")") {
if (acc === "" && ast.#parts.length === 0) ast.#emptyExt = true;
part.push(acc);
acc = "";
ast.push(...parts, part);
return i;
}
acc += c;
}
ast.type = null;
ast.#hasMagic = void 0;
ast.#parts = [str.substring(pos - 1)];
return i;
}
static fromGlob(pattern, options = {}) {
const ast = new AST(null, void 0, options);
AST.#parseAST(pattern, ast, 0, options);
return ast;
}
toMMPattern() {
/* c8 ignore start */
if (this !== this.#root) return this.#root.toMMPattern();
/* c8 ignore stop */
const glob = this.toString();
const [re, body, hasMagic$1, uflag] = this.toRegExpSource();
if (!(hasMagic$1 || this.#hasMagic || this.#options.nocase && !this.#options.nocaseMagicOnly && glob.toUpperCase() !== glob.toLowerCase())) return body;
const flags = (this.#options.nocase ? "i" : "") + (uflag ? "u" : "");
return Object.assign(new RegExp(`^${re}$`, flags), {
_src: re,
_glob: glob
});
}
get options() {
return this.#options;
}
toRegExpSource(allowDot) {
const dot = allowDot ?? !!this.#options.dot;
if (this.#root === this) this.#fillNegs();
if (!this.type) {
const noEmpty = this.isStart() && this.isEnd();
const src = this.#parts.map((p) => {
const [re, _, hasMagic$1, uflag] = typeof p === "string" ? AST.#parseGlob(p, this.#hasMagic, noEmpty) : p.toRegExpSource(allowDot);
this.#hasMagic = this.#hasMagic || hasMagic$1;
this.#uflag = this.#uflag || uflag;
return re;
}).join("");
let start$1 = "";
if (this.isStart()) {
if (typeof this.#parts[0] === "string") {
if (!(this.#parts.length === 1 && justDots.has(this.#parts[0]))) {
const aps = addPatternStart;
const needNoTrav = dot && aps.has(src.charAt(0)) || src.startsWith("\\.") && aps.has(src.charAt(2)) || src.startsWith("\\.\\.") && aps.has(src.charAt(4));
const needNoDot = !dot && !allowDot && aps.has(src.charAt(0));
start$1 = needNoTrav ? startNoTraversal : needNoDot ? startNoDot : "";
}
}
}
let end = "";
if (this.isEnd() && this.#root.#filledNegs && this.#parent?.type === "!") end = "(?:$|\\/)";
return [
start$1 + src + end,
(0, unescape_js_1$1.unescape)(src),
this.#hasMagic = !!this.#hasMagic,
this.#uflag
];
}
const repeated = this.type === "*" || this.type === "+";
const start = this.type === "!" ? "(?:(?!(?:" : "(?:";
let body = this.#partsToRegExp(dot);
if (this.isStart() && this.isEnd() && !body && this.type !== "!") {
const s = this.toString();
this.#parts = [s];
this.type = null;
this.#hasMagic = void 0;
return [
s,
(0, unescape_js_1$1.unescape)(this.toString()),
false,
false
];
}
let bodyDotAllowed = !repeated || allowDot || dot || false ? "" : this.#partsToRegExp(true);
if (bodyDotAllowed === body) bodyDotAllowed = "";
if (bodyDotAllowed) body = `(?:${body})(?:${bodyDotAllowed})*?`;
let final = "";
if (this.type === "!" && this.#emptyExt) final = (this.isStart() && !dot ? startNoDot : "") + starNoEmpty;
else {
const close = this.type === "!" ? "))" + (this.isStart() && !dot && !allowDot ? startNoDot : "") + star$1 + ")" : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && bodyDotAllowed ? ")" : this.type === "*" && bodyDotAllowed ? `)?` : `)${this.type}`;
final = start + body + close;
}
return [
final,
(0, unescape_js_1$1.unescape)(body),
this.#hasMagic = !!this.#hasMagic,
this.#uflag
];
}
#partsToRegExp(dot) {
return this.#parts.map((p) => {
/* c8 ignore start */
if (typeof p === "string") throw new Error("string type in extglob ast??");
/* c8 ignore stop */
const [re, _, _hasMagic, uflag] = p.toRegExpSource(dot);
this.#uflag = this.#uflag || uflag;
return re;
}).filter((p) => !(this.isStart() && this.isEnd()) || !!p).join("|");
}
static #parseGlob(glob, hasMagic$1, noEmpty = false) {
let escaping = false;
let re = "";
let uflag = false;
for (let i = 0; i < glob.length; i++) {
const c = glob.charAt(i);
if (escaping) {
escaping = false;
re += (reSpecials.has(c) ? "\\" : "") + c;
continue;
}
if (c === "\\") {
if (i === glob.length - 1) re += "\\\\";
else escaping = true;
continue;
}
if (c === "[") {
const [src, needUflag, consumed, magic] = (0, brace_expressions_js_1.parseClass)(glob, i);
if (consumed) {
re += src;
uflag = uflag || needUflag;
i += consumed - 1;
hasMagic$1 = hasMagic$1 || magic;
continue;
}
}
if (c === "*") {
if (noEmpty && glob === "*") re += starNoEmpty;
else re += star$1;
hasMagic$1 = true;
continue;
}
if (c === "?") {
re += qmark;
hasMagic$1 = true;
continue;
}
re += regExpEscape$1(c);
}
return [
re,
(0, unescape_js_1$1.unescape)(glob),
!!hasMagic$1,
uflag
];
}
};
exports.AST = AST;
}));
//#endregion
//#region node_modules/.pnpm/minimatch@10.0.3/node_modules/minimatch/dist/commonjs/escape.js
var require_escape = /* @__PURE__ */ __commonJSMin(((exports) => {
Object.defineProperty(exports, "__esModule", { value: true });
exports.escape = void 0;
/**
* Escape all magic characters in a glob pattern.
*
* If the {@link windowsPathsNoEscape | GlobOptions.windowsPathsNoEscape}
* option is used, then characters are escaped by wrapping in `[]`, because
* a magic character wrapped in a character class can only be satisfied by
* that exact character. In this mode, `\` is _not_ escaped, because it is
* not interpreted as a magic character, but instead as a path separator.
*/
const escape = (s, { windowsPathsNoEscape = false } = {}) => {
return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
};
exports.escape = escape;
}));
//#endregion
//#region node_modules/.pnpm/minimatch@10.0.3/node_modules/minimatch/dist/commonjs/index.js
var require_commonjs$3 = /* @__PURE__ */ __commonJSMin(((exports) => {
Object.defineProperty(exports, "__esModule", { value: true });
exports.unescape = exports.escape = exports.AST = exports.Minimatch = exports.match = exports.makeRe = exports.braceExpand = exports.defaults = exports.filter = exports.GLOBSTAR = exports.sep = exports.minimatch = void 0;
const brace_expansion_1 = require_commonjs$4();
const assert_valid_pattern_js_1 = require_assert_valid_pattern();
const ast_js_1 = require_ast();
const escape_js_1 = require_escape();
const unescape_js_1 = require_unescape();
const minimatch = (p, pattern, options = {}) => {
(0, assert_valid_pattern_js_1.assertValidPattern)(pattern);
if (!options.nocomment && pattern.charAt(0) === "#") return false;
return new Minimatch(pattern, options).match(p);
};
exports.minimatch = minimatch;
const starDotExtRE = /^\*+([^+@!?\*\[\(]*)$/;
const starDotExtTest = (ext$1) => (f) => !f.startsWith(".") && f.endsWith(ext$1);
const starDotExtTestDot = (ext$1) => (f) => f.endsWith(ext$1);
const starDotExtTestNocase = (ext$1) => {
ext$1 = ext$1.toLowerCase();
return (f) => !f.startsWith(".") && f.toLowerCase().endsWith(ext$1);
};
const starDotExtTestNocaseDot = (ext$1) => {
ext$1 = ext$1.toLowerCase();
return (f) => f.toLowerCase().endsWith(ext$1);
};
const starDotStarRE = /^\*+\.\*+$/;
const starDotStarTest = (f) => !f.startsWith(".") && f.includes(".");
const starDotStarTestDot = (f) => f !== "." && f !== ".." && f.includes(".");
const dotStarRE = /^\.\*+$/;
const dotStarTest = (f) => f !== "." && f !== ".." && f.startsWith(".");
const starRE = /^\*+$/;
const starTest = (f) => f.length !== 0 && !f.startsWith(".");
const starTestDot = (f) => f.length !== 0 && f !== "." && f !== "..";
const qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/;
const qmarksTestNocase = ([$0, ext$1 = ""]) => {
const noext = qmarksTestNoExt([$0]);
if (!ext$1) return noext;
ext$1 = ext$1.toLowerCase();
return (f) => noext(f) && f.toLowerCase().endsWith(ext$1);
};
const qmarksTestNocaseDot = ([$0, ext$1 = ""]) => {
const noext = qmarksTestNoExtDot([$0]);
if (!ext$1) return noext;
ext$1 = ext$1.toLowerCase();
return (f) => noext(f) && f.toLowerCase().endsWith(ext$1);
};
const qmarksTestDot = ([$0, ext$1 = ""]) => {
const noext = qmarksTestNoExtDot([$0]);
return !ext$1 ? noext : (f) => noext(f) && f.endsWith(ext$1);
};
const qmarksTest = ([$0, ext$1 = ""]) => {
const noext = qmarksTestNoExt([$0]);
return !ext$1 ? noext : (f) => noext(f) && f.endsWith(ext$1);
};
const qmarksTestNoExt = ([$0]) => {
const len = $0.length;
return (f) => f.length === len && !f.startsWith(".");
};
const qmarksTestNoExtDot = ([$0]) => {
const len = $0.length;
return (f) => f.length === len && f !== "." && f !== "..";
};
/* c8 ignore start */
const defaultPlatform$2 = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
const path = {
win32: { sep: "\\" },
posix: { sep: "/" }
};
/* c8 ignore stop */
exports.sep = defaultPlatform$2 === "win32" ? path.win32.sep : path.posix.sep;
exports.minimatch.sep = exports.sep;
exports.GLOBSTAR = Symbol("globstar **");
exports.minimatch.GLOBSTAR = exports.GLOBSTAR;
const star = "[^/]*?";
const twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
const twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?";
const filter = (pattern, options = {}) => (p) => (0, exports.minimatch)(p, pattern, options);
exports.filter = filter;
exports.minimatch.filter = exports.filter;
const ext = (a, b = {}) => Object.assign({}, a, b);
const defaults = (def) => {
if (!def || typeof def !== "object" || !Object.keys(def).length) return exports.minimatch;
const orig = exports.minimatch;
const m = (p, pattern, options = {}) => orig(p, pattern, ext(def, options));
return Object.assign(m, {
Minimatch: class Minimatch$1 extends orig.Minimatch {
constructor(pattern, options = {}) {
super(pattern, ext(def, options));
}
static defaults(options) {
return orig.defaults(ext(def, options)).Minimatch;
}
},
AST: class AST$1 extends orig.AST {
/* c8 ignore start */
constructor(type, parent, options = {}) {
super(type, parent, ext(def, options));
}
/* c8 ignore stop */
static fromGlob(pattern, options = {}) {
return orig.AST.fromGlob(pattern, ext(def, options));
}
},
unescape: (s, options = {}) => orig.unescape(s, ext(def, options)),
escape: (s, options = {}) => orig.escape(s, ext(def, options)),
filter: (pattern, options = {}) => orig.filter(pattern, ext(def, options)),
defaults: (options) => orig.defaults(ext(def, options)),
makeRe: (pattern, options = {}) => orig.makeRe(pattern, ext(def, options)),
braceExpand: (pattern, options = {}) => orig.braceExpand(pattern, ext(def, options)),
match: (list, pattern, options = {}) => orig.match(list, pattern, ext(def, options)),
sep: orig.sep,
GLOBSTAR: exports.GLOBSTAR
});
};
exports.defaults = defaults;
exports.minimatch.defaults = exports.defaults;
const braceExpand = (pattern, options = {}) => {
(0, assert_valid_pattern_js_1.assertValidPattern)(pattern);
if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) return [pattern];
return (0, brace_expansion_1.expand)(pattern);
};
exports.braceExpand = braceExpand;
exports.minimatch.braceExpand = exports.braceExpand;
const makeRe = (pattern, options = {}) => new Minimatch(pattern, options).makeRe();
exports.makeRe = makeRe;
exports.minimatch.makeRe = exports.makeRe;
const match = (list, pattern, options = {}) => {
const mm = new Minimatch(pattern, options);
list = list.filter((f) => mm.match(f));
if (mm.options.nonull && !list.length) list.push(pattern);
return list;
};
exports.match = match;
exports.minimatch.match = exports.match;
const globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
const regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
var Minimatch = class {
options;
set;
pattern;
windowsPathsNoEscape;
nonegate;
negate;
comment;
empty;
preserveMultipleSlashes;
partial;
globSet;
globParts;
nocase;
isWindows;
platform;
windowsNoMagicRoot;
regexp;
constructor(pattern, options = {}) {
(0, assert_valid_pattern_js_1.assertValidPattern)(pattern);
options = options || {};
this.options = options;
this.pattern = pattern;
this.platform = options.platform || defaultPlatform$2;
this.isWindows = this.platform === "win32";
this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options.allowWindowsEscape === false;
if (this.windowsPathsNoEscape) this.pattern = this.pattern.replace(/\\/g, "/");
this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
this.regexp = null;
this.negate = false;
this.nonegate = !!options.nonegate;
this.comment = false;
this.empty = false;
this.partial = !!options.partial;
this.nocase = !!this.options.nocase;
this.windowsNoMagicRoot = options.windowsNoMagicRoot !== void 0 ? options.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 pattern of this.set) for (const part of pattern) if (typeof part !== "string") return true;
return false;
}
debug(..._) {}
make() {
const pattern = this.pattern;
const options = this.options;
if (!options.nocomment && pattern.charAt(0) === "#") {
this.comment = true;
return;
}
if (!pattern) {
this.empty = true;
return;
}
this.parseNegate();
this.globSet = [...new Set(this.braceExpand())];
if (options.debug) this.debug = (...args) => console.error(...args);
this.debug(this.pattern, this.globSet);
const rawGlobParts = this.globSet.map((s) => this.slashSplit(s));
this.globParts = this.preprocess(rawGlobParts);
this.debug(this.pattern, this.globParts);
let set = this.globParts.map((s, _, __) => {
if (this.isWindows && this.windowsNoMagicRoot) {
const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && !globMagic.test(s[3]);
const isDrive = /^[a-z]:/i.test(s[0]);
if (isUNC) return [...s.slice(0, 4), ...s.slice(4).map((ss) => this.parse(ss))];
else if (isDrive) return [s[0], ...s.slice(1).map((ss) => this.parse(ss))];
}
return s.map((ss) => this.parse(ss));
});
this.debug(this.pattern, set);
this.set = set.filter((s) => s.indexOf(false) === -1);
if (this.isWindows) for (let i = 0; i < this.set.length; i++) {
const p = this.set[i];
if (p[0] === "" && p[1] === "" && this.globParts[i][2] === "?" && typeof p[3] === "string" && /^[a-z]:$/i.test(p[3])) p[2] = "?";
}
this.debug(this.pattern, this.set);
}
preprocess(globParts) {
if (this.options.noglobstar) {
for (let i = 0; i < globParts.length; i++) for (let j = 0; j < globParts[i].length; j++) if (globParts[i][j] === "**") globParts[i][j] = "*";
}
const { optimizationLevel = 1 } = this.options;
if (optimizationLevel >= 2) {
globParts = this.firstPhasePreProcess(globParts);
globParts = this.secondPhasePreProcess(globParts);
} else if (optimizationLevel >= 1) globParts = this.levelOneOptimize(globParts);
else globParts = this.adjascentGlobstarOptimize(globParts);
return globParts;
}
adjascentGlobstarOptimize(globParts) {
return globParts.map((parts) => {
let gs = -1;
while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
let i = gs;
while (parts[i + 1] === "**") i++;
if (i !== gs) parts.splice(gs, i - gs);
}
return parts;
});
}
levelOneOptimize(globParts) {
return globParts.map((parts) => {
parts = parts.reduce((set, part) => {
const prev = set[set.length - 1];
if (part === "**" && prev === "**") return set;
if (part === "..") {
if (prev && prev !== ".." && prev !== "." && prev !== "**") {
set.pop();
return set;
}
}
set.push(part);
return set;
}, []);
return parts.length === 0 ? [""] : parts;
});
}
levelTwoFileOptimize(parts) {
if (!Array.isArray(parts)) parts = this.slashSplit(parts);
let didSomething = false;
do {
didSomething = false;
if (!this.preserveMultipleSlashes) {
for (let i = 1; i < parts.length - 1; i++) {
const p = parts[i];
if (i === 1 && p === "" && parts[0] === "") continue;
if (p === "." || p === "") {
didSomething = true;
parts.splice(i, 1);
i--;
}
}
if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
didSomething = true;
parts.pop();
}
}
let dd = 0;
while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
const p = parts[dd - 1];
if (p && p !== "." && p !== ".." && p !== "**") {
didSomething = true;
parts.splice(dd - 1, 2);
dd -= 2;
}
}
} while (didSomething);
return parts.length === 0 ? [""] : parts;
}
firstPhasePreProcess(globParts) {
let didSomething = false;
do {
didSomething = false;
for (let parts of globParts) {
let gs = -1;
while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
let gss = gs;
while (parts[gss + 1] === "**") gss++;
if (gss > gs) parts.splice(gs + 1, gss - gs);
let next = parts[gs + 1];
const p = parts[gs + 2];
const p2 = parts[gs + 3];
if (next !== "..") continue;
if (!p || p === "." || p === ".." || !p2 || p2 === "." || p2 === "..") continue;
didSomething = true;
parts.splice(gs, 1);
const other = parts.slice(0);
other[gs] = "**";
globParts.push(other);
gs--;
}
if (!this.preserveMultipleSlashes) {
for (let i = 1; i < parts.length - 1; i++) {
const p = parts[i];
if (i === 1 && p === "" && parts[0] === "") continue;
if (p === "." || p === "") {
didSomething = true;
parts.splice(i, 1);
i--;
}
}
if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
didSomething = true;
parts.pop();
}
}
let dd = 0;
while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
const p = parts[dd - 1];
if (p && p !== "." && p !== ".." && p !== "**") {
didSomething = true;
const splin = dd === 1 && parts[dd + 1] === "**" ? ["."] : [];
parts.splice(dd - 1, 2, ...splin);
if (parts.length === 0) parts.push("");
dd -= 2;
}
}
}
} while (didSomething);
return globParts;
}
secondPhasePreProcess(globParts) {
for (let i = 0; i < globParts.length - 1; i++) for (let j = i + 1; j < globParts.length; j++) {
const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
if (matched) {
globParts[i] = [];
globParts[j] = matched;
break;
}
}
return globParts.filter((gs) => gs.length);
}
partsMatch(a, b, emptyGSMatch = false) {
let ai = 0;
let bi = 0;
let result = [];
let which = "";
while (ai < a.length && bi < b.length) if (a[ai] === b[bi]) {
result.push(which === "b" ? b[bi] : a[ai]);
ai++;
bi++;
} else if (emptyGSMatch && a[ai] === "**" && b[bi] === a[ai + 1]) {
result.push(a[ai]);
ai++;
} else if (emptyGSMatch && b[bi] === "**" && a[ai] === b[bi + 1]) {
result.push(b[bi]);
bi++;
} else if (a[ai] === "*" && b[bi] && (this.options.dot || !b[bi].startsWith(".")) && b[bi] !== "**") {
if (which === "b") return false;
which = "a";
result.push(a[ai]);
ai++;
bi++;
} else if (b[bi] === "*" && a[ai] && (this.options.dot || !a[ai].startsWith(".")) && a[ai] !== "**") {
if (which === "a") return false;
which = "b";
result.push(b[bi]);
ai++;
bi++;
} else return false;
return a.length === b.length && result;
}
parseNegate() {
if (this.nonegate) return;
const pattern = this.pattern;
let negate = false;
let negateOffset = 0;
for (let i = 0; i < pattern.length && pattern.charAt(i) === "!"; i++) {
negate = !negate;
negateOffset++;
}
if (negateOffset) this.pattern = pattern.slice(negateOffset);
this.negate = negate;
}
matchOne(file, pattern, partial = false) {
const options = this.options;
if (this.isWindows) {
const fileDrive = typeof file[0] === "string" && /^[a-z]:$/i.test(file[0]);
const fileUNC = !fileDrive && file[0] === "" && file[1] === "" && file[2] === "?" && /^[a-z]:$/i.test(file[3]);
const patternDrive = typeof pattern[0] === "string" && /^[a-z]:$/i.test(pattern[0]);
const patternUNC = !patternDrive && pattern[0] === "" && pattern[1] === "" && pattern[2] === "?" && typeof pattern[3] === "string" && /^[a-z]:$/i.test(pattern[3]);
const fdi = fileUNC ? 3 : fileDrive ? 0 : void 0;
const pdi = patternUNC ? 3 : patternDrive ? 0 : void 0;
if (typeof fdi === "number" && typeof pdi === "number") {
const [fd, pd] = [file[fdi], pattern[pdi]];
if (fd.toLowerCase() === pd.toLowerCase()) {
pattern[pdi] = fd;
if (pdi > fdi) pattern = pattern.slice(pdi);
else if (fdi > pdi) file = file.slice(fdi);
}
}
}
const { optimizationLevel = 1 } = this.options;
if (optimizationLevel >= 2) file = this.levelTwoFileOptimize(file);
this.debug("matchOne", this, {
file,
pattern
});
this.debug("matchOne", file.length, pattern.length);
for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
this.debug("matchOne loop");
var p = pattern[pi];
var f = file[fi];
this.debug(pattern, p, f);
/* c8 ignore start */
if (p === false) return false;
/* c8 ignore stop */
if (p === exports.GLOBSTAR) {
this.debug("GLOBSTAR", [
pattern,
p,
f
]);
var fr = fi;
var pr = pi + 1;
if (pr === pl) {
this.debug("** at the end");
for (; fi < fl; fi++) if (file[fi] === "." || file[fi] === ".." || !options.dot && file[fi].charAt(0) === ".") return false;
return true;
}
while (fr < fl) {
var swallowee = file[fr];
this.debug("\nglobstar while", file, fr, pattern, pr, swallowee);
if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
this.debug("globstar found match!", fr, fl, swallowee);
return true;
} else {
if (swallowee === "." || swallowee === ".." || !options.dot && swallowee.charAt(0) === ".") {
this.debug("dot detected!", file, fr, pattern, pr);
break;
}
this.debug("globstar swallow a segment, and continue");
fr++;
}
}
/* c8 ignore start */
if (partial) {
this.debug("\n>>> no match, partial?", file, fr, pattern, pr);
if (fr === fl) return true;
}
/* c8 ignore stop */
return false;
}
let hit;
if (typeof p === "string") {
hit = f === p;
this.debug("string match", p, f, hit);
} else {
hit = p.test(f);
this.debug("pattern match", p, f, hit);
}
if (!hit) return false;
}
if (fi === fl && pi === pl) return true;
else if (fi === fl) return partial;
else if (pi === pl) return fi === fl - 1 && file[fi] === "";
else throw new Error("wtf?");
/* c8 ignore stop */
}
braceExpand() {
return (0, exports.braceExpand)(this.pattern, this.options);
}
parse(pattern) {
(0, assert_valid_pattern_js_1.assertValidPattern)(pattern);
const options = this.options;
if (pattern === "**") return exports.GLOBSTAR;
if (pattern === "") return "";
let m;
let fastTest = null;
if (m = pattern.match(starRE)) fastTest = options.dot ? starTestDot : starTest;
else if (m = pattern.match(starDotExtRE)) fastTest = (options.nocase ? options.dot ? starDotExtTestNocaseDot : starDotExtTestNocase : options.dot ? starDotExtTestDot : starDotExtTest)(m[1]);
else if (m = pattern.match(qmarksRE)) fastTest = (options.nocase ? options.dot ? qmarksTestNocaseDot : qmarksTestNocase : options.dot ? qmarksTestDot : qmarksTest)(m);
else if (m = pattern.match(starDotStarRE)) fastTest = options.dot ? starDotStarTestDot : starDotStarTest;
else if (m = pattern.match(dotStarRE)) fastTest = dotStarTest;
const re = ast_js_1.AST.fromGlob(pattern, this.options).toMMPattern();
if (fastTest && typeof re === "object") Reflect.defineProperty(re, "test", { value: fastTest });
return re;
}
makeRe() {
if (this.regexp || this.regexp === false) return this.regexp;
const set = this.set;
if (!set.length) {
this.regexp = false;
return this.regexp;
}
const options = this.options;
const twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot;
const flags = new Set(options.nocase ? ["i"] : []);
let re = set.map((pattern) => {
const pp = pattern.map((p) => {
if (p instanceof RegExp) for (const f of p.flags.split("")) flags.add(f);
return typeof p === "string" ? regExpEscape(p) : p === exports.GLOBSTAR ? exports.GLOBSTAR : p._src;
});
pp.forEach((p, i) => {
const next = pp[i + 1];
const prev = pp[i - 1];
if (p !== exports.GLOBSTAR || prev === exports.GLOBSTAR) return;
if (prev === void 0) if (next !== void 0 && next !== exports.GLOBSTAR) pp[i + 1] = "(?:\\/|" + twoStar + "\\/)?" + next;
else pp[i] = twoStar;
else if (next === void 0) pp[i - 1] = prev + "(?:\\/|" + twoStar + ")?";
else if (next !== exports.GLOBSTAR) {
pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + "\\/)" + next;
pp[i + 1] = exports.GLOBSTAR;
}
});
return pp.filter((p) => p !== exports.GLOBSTAR).join("/");
}).join("|");
const [open, close] = set.length > 1 ? ["(?:", ")"] : ["", ""];
re = "^" + open + re + close + "$";
if (this.negate) re = "^(?!" + re + ").+$";
try {
this.regexp = new RegExp(re, [...flags].join(""));
} catch (ex) {
this.regexp = false;
}
/* c8 ignore stop */
return this.regexp;
}
slashSplit(p) {
if (this.preserveMultipleSlashes) return p.split("/");
else if (this.isWindows && /^\/\/[^\/]+/.test(p)) return ["", ...p.split(/\/+/)];
else return p.split(/\/+/);
}
match(f, partial = this.partial) {
this.debug("match", f, this.pattern);
if (this.comment) return false;
if (this.empty) return f === "";
if (f === "/" && partial) return true;
const options = this.options;
if (this.isWindows) f = f.split("\\").join("/");
const ff = this.slashSplit(f);
this.debug(this.pattern, "split", ff);
const set = this.set;
this.debug(this.pattern, "set", set);
let filename = ff[ff.length - 1];
if (!filename) for (let i = ff.length - 2; !filename && i >= 0; i--) filename = ff[i];
for (let i = 0; i < set.length; i++) {
const pattern = set[i];
let file = ff;
if (options.matchBase && pattern.length === 1) file = [filename];
if (this.matchOne(file, pattern, partial)) {
if (options.flipNegate) return true;
return !this.negate;
}
}
if (options.flipNegate) return false;
return this.negate;
}
static defaults(def) {
return exports.minimatch.defaults(def).Minimatch;
}
};
exports.Minimatch = Minimatch;
/* c8 ignore start */
var ast_js_2 = require_ast();
Object.defineProperty(exports, "AST", {
enumerable: true,
get: function() {
return ast_js_2.AST;
}
});
var escape_js_2 = require_escape();
Object.defineProperty(exports, "escape", {
enumerable: true,
get: function() {
return escape_js_2.escape;
}
});
var unescape_js_2 = require_unescape();
Object.defineProperty(exports, "unescape", {
enumerable: true,
get: function() {
return unescape_js_2.unescape;
}
});
/* c8 ignore stop */
exports.minimatch.AST = ast_js_1.AST;
exports.minimatch.Minimatch = Minimatch;
exports.minimatch.escape = escape_js_1.escape;
exports.minimatch.unescape = unescape_js_1.unescape;
}));
//#endregion
//#region node_modules/.pnpm/minipass@7.1.2/node_modules/minipass/dist/commonjs/index.js
var require_commonjs$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
var __importDefault = exports && exports.__importDefault || function(mod) {
return mod && mod.__esModule ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Minipass = exports.isWritable = exports.isReadable = exports.isStream = void 0;
const proc = typeof process === "object" && process ? process : {
stdout: null,
stderr: null
};
const node_events_1 = __require("node:events");
const node_stream_1 = __importDefault(__require("node:stream"));
const node_string_decoder_1 = __require("node:string_decoder");
/**
* Return true if the argument is a Minipass stream, Node stream, or something
* else that Minipass can interact with.
*/
const isStream = (s) => !!s && typeof s === "object" && (s instanceof Minipass || s instanceof node_stream_1.default || (0, exports.isReadable)(s) || (0, exports.isWritable)(s));
exports.isStream = isStream;
/**
* Return true if the argument is a valid {@link Minipass.Readable}
*/
const isReadable = (s) => !!s && typeof s === "object" && s instanceof node_events_1.EventEmitter && typeof s.pipe === "function" && s.pipe !== node_stream_1.default.Writable.prototype.pipe;
exports.isReadable = isReadable;
/**
* Return true if the argument is a valid {@link Minipass.Writable}
*/
const isWritable = (s) => !!s && typeof s === "object" && s instanceof node_events_1.EventEmitter && typeof s.write === "function" && typeof s.end === "function";
exports.isWritable = isWritable;
const EOF = Symbol("EOF");
const MAYBE_EMIT_END = Symbol("maybeEmitEnd");
const EMITTED_END = Symbol("emittedEnd");
const EMITTING_END = Symbol("emittingEnd");
const EMITTED_ERROR = Symbol("emittedError");
const CLOSED = Symbol("closed");
const READ = Symbol("read");
const FLUSH = Symbol("flush");
const FLUSHCHUNK = Symbol("flushChunk");
const ENCODING = Symbol("encoding");
const DECODER = Symbol("decoder");
const FLOWING = Symbol("flowing");
const PAUSED = Symbol("paused");
const RESUME = Symbol("resume");
const BUFFER = Symbol("buffer");
const PIPES = Symbol("pipes");
const BUFFERLENGTH = Symbol("bufferLength");
const BUFFERPUSH = Symbol("bufferPush");
const BUFFERSHIFT = Symbol("bufferShift");
const OBJECTMODE = Symbol("objectMode");
const DESTROYED = Symbol("destroyed");
const ERROR = Symbol("error");
const EMITDATA = Symbol("emitData");
const EMITEND = Symbol("emitEnd");
const EMITEND2 = Symbol("emitEnd2");
const ASYNC = Symbol("async");
const ABORT = Symbol("abort");
const ABORTED = Symbol("aborted");
const SIGNAL = Symbol("signal");
const DATALISTENERS = Symbol("dataListeners");
const DISCARDED = Symbol("discarded");
const defer = (fn) => Promise.resolve().then(fn);
const nodefer = (fn) => fn();
const isEndish = (ev) => ev === "end" || ev === "finish" || ev === "prefinish";
const isArrayBufferLike = (b) => b instanceof ArrayBuffer || !!b && typeof b === "object" && b.constructor && b.constructor.name === "ArrayBuffer" && b.byteLength >= 0;
const isArrayBufferView = (b) => !Buffer.isBuffer(b) && ArrayBuffer.isView(b);
/**
* Internal class representing a pipe to a destination stream.
*
* @internal
*/
var Pipe = class {
src;
dest;
opts;
ondrain;
constructor(src, dest, opts) {
this.src = src;
this.dest = dest;
this.opts = opts;
this.ondrain = () => src[RESUME]();
this.dest.on("drain", this.ondrain);
}
unpipe() {
this.dest.removeListener("drain", this.ondrain);
}
/* c8 ignore start */
proxyErrors(_er) {}
/* c8 ignore stop */
end() {
this.unpipe();
if (this.opts.end) this.dest.end();
}
};
/**
* Internal class representing a pipe to a destination stream where
* errors are proxied.
*
* @internal
*/
var PipeProxyErrors = class extends Pipe {
unpipe() {
this.src.removeListener("error", this.proxyErrors);
super.unpipe();
}
constructor(src, dest, opts) {
super(src, dest, opts);
this.proxyErrors = (er) => dest.emit("error", er);
src.on("error", this.proxyErrors);
}
};
const isObjectModeOptions = (o) => !!o.objectMode;
const isEncodingOptions = (o) => !o.objectMode && !!o.encoding && o.encoding !== "buffer";
/**
* Main export, the Minipass class
*
* `RType` is the type of data emitted, defaults to Buffer
*
* `WType` is the type of data to be written, if RType is buffer or string,
* then any {@link Minipass.ContiguousData} is allowed.
*
* `Events` is the set of event handler signatures that this object
* will emit, see {@link Minipass.Events}
*/
var Minipass = class extends node_events_1.EventEmitter {
[FLOWING] = false;
[PAUSED] = false;
[PIPES] = [];
[BUFFER] = [];
[OBJECTMODE];
[ENCODING];
[ASYNC];
[DECODER];
[EOF] = false;
[EMITTED_END] = false;
[EMITTING_END] = false;
[CLOSED] = false;
[EMITTED_ERROR] = null;
[BUFFERLENGTH] = 0;
[DESTROYED] = false;
[SIGNAL];
[ABORTED] = false;
[DATALISTENERS] = 0;
[DISCARDED] = false;
/**
* true if the stream can be written
*/
writable = true;
/**
* true if the stream can be read
*/
readable = true;
/**
* If `RType` is Buffer, then options do not need to be provided.
* Otherwise, an options object must be provided to specify either
* {@link Minipass.SharedOptions.objectMode} or
* {@link Minipass.SharedOptions.encoding}, as appropriate.
*/
constructor(...args) {
const options = args[0] || {};
super();
if (options.objectMode && typeof options.encoding === "string") throw new TypeError("Encoding and objectMode may not be used together");
if (isObjectModeOptions(options)) {
this[OBJECTMODE] = true;
this[ENCODING] = null;
} else if (isEncodingOptions(options)) {
this[ENCODING] = options.encoding;
this[OBJECTMODE] = false;
} else {
this[OBJECTMODE] = false;
this[ENCODING] = null;
}
this[ASYNC] = !!options.async;
this[DECODER] = this[ENCODING] ? new node_string_decoder_1.StringDecoder(this[ENCODING]) : null;
if (options && options.debugExposeBuffer === true) Object.defineProperty(this, "buffer", { get: () => this[BUFFER] });
if (options && options.debugExposePipes === true) Object.defineProperty(this, "pipes", { get: () => this[PIPES] });
const { signal } = options;
if (signal) {
this[SIGNAL] = signal;
if (signal.aborted) this[ABORT]();
else signal.addEventListener("abort", () => this[ABORT]());
}
}
/**
* The amount of data stored in the buffer waiting to be read.
*
* For Buffer strings, this will be the total byte length.
* For string encoding streams, this will be the string character length,
* according to JavaScript's `string.length` logic.
* For objectMode streams, this is a count of the items waiting to be
* emitted.
*/
get bufferLength() {
return this[BUFFERLENGTH];
}
/**
* The `BufferEncoding` currently in use, or `null`
*/
get encoding() {
return this[ENCODING];
}
/**
* @deprecated - This is a read only property
*/
set encoding(_enc) {
throw new Error("Encoding must be set at instantiation time");
}
/**
* @deprecated - Encoding may only be set at instantiation time
*/
setEncoding(_enc) {
throw new Error("Encoding must be set at instantiation time");
}
/**
* True if this is an objectMode stream
*/
get objectMode() {
return this[OBJECTMODE];
}
/**
* @deprecated - This is a read-only property
*/
set objectMode(_om) {
throw new Error("objectMode must be set at instantiation time");
}
/**
* true if this is an async stream
*/
get ["async"]() {
return this[ASYNC];
}
/**
* Set to true to make this stream async.
*
* Once set, it cannot be unset, as this would potentially cause incorrect
* behavior. Ie, a sync stream can be made async, but an async stream
* cannot be safely made sync.
*/
set ["async"](a) {
this[ASYNC] = this[ASYNC] || !!a;
}
[ABORT]() {
this[ABORTED] = true;
this.emit("abort", this[SIGNAL]?.reason);
this.destroy(this[SIGNAL]?.reason);
}
/**
* True if the stream has been aborted.
*/
get aborted() {
return this[ABORTED];
}
/**
* No-op setter. Stream aborted status is set via the AbortSignal provided
* in the constructor options.
*/
set aborted(_) {}
write(chunk, encoding, cb) {
if (this[ABORTED]) return false;
if (this[EOF]) throw new Error("write after end");
if (this[DESTROYED]) {
this.emit("error", Object.assign(/* @__PURE__ */ new Error("Cannot call write after a stream was destroyed"), { code: "ERR_STREAM_DESTROYED" }));
return true;
}
if (typeof encoding === "function") {
cb = encoding;
encoding = "utf8";
}
if (!encoding) encoding = "utf8";
const fn = this[ASYNC] ? defer : nodefer;
if (!this[OBJECTMODE] && !Buffer.isBuffer(chunk)) {
if (isArrayBufferView(chunk)) chunk = Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength);
else if (isArrayBufferLike(chunk)) chunk = Buffer.from(chunk);
else if (typeof chunk !== "string") throw new Error("Non-contiguous data written to non-objectMode stream");
}
if (this[OBJECTMODE]) {
/* c8 ignore start */
if (this[FLOWING] && this[BUFFERLENGTH] !== 0) this[FLUSH](true);
/* c8 ignore stop */
if (this[FLOWING]) this.emit("data", chunk);
else this[BUFFERPUSH](chunk);
if (this[BUFFERLENGTH] !== 0) this.emit("readable");
if (cb) fn(cb);
return this[FLOWING];
}
if (!chunk.length) {
if (this[BUFFERLENGTH] !== 0) this.emit("readable");
if (cb) fn(cb);
return this[FLOWING];
}
if (typeof chunk === "string" && !(encoding === this[ENCODING] && !this[DECODER]?.lastNeed)) chunk = Buffer.from(chunk, encoding);
if (Buffer.isBuffer(chunk) && this[ENCODING]) chunk = this[DECODER].write(chunk);
if (this[FLOWING] && this[BUFFERLENGTH] !== 0) this[FLUSH](true);
if (this[FLOWING]) this.emit("data", chunk);
else this[BUFFERPUSH](chunk);
if (this[BUFFERLENGTH] !== 0) this.emit("readable");
if (cb) fn(cb);
return this[FLOWING];
}
/**
* Low-level explicit read method.
*
* In objectMode, the argument is ignored, and one item is returned if
* available.
*
* `n` is the number of bytes (or in the case of encoding streams,
* characters) to consume. If `n` is not provided, then the entire buffer
* is returned, or `null` is returned if no data is available.
*
* If `n` is greater that the amount of data in the internal buffer,
* then `null` is returned.
*/
read(n) {
if (this[DESTROYED]) return null;
this[DISCARDED] = false;
if (this[BUFFERLENGTH] === 0 || n === 0 || n && n > this[BUFFERLENGTH]) {
this[MAYBE_EMIT_END]();
return null;
}
if (this[OBJECTMODE]) n = null;
if (this[BUFFER].length > 1 && !this[OBJECTMODE]) this[BUFFER] = [this[ENCODING] ? this[BUFFER].join("") : Buffer.concat(this[BUFFER], this[BUFFERLENGTH])];
const ret = this[READ](n || null, this[BUFFER][0]);
this[MAYBE_EMIT_END]();
return ret;
}
[READ](n, chunk) {
if (this[OBJECTMODE]) this[BUFFERSHIFT]();
else {
const c = chunk;
if (n === c.length || n === null) this[BUFFERSHIFT]();
else if (typeof c === "string") {
this[BUFFER][0] = c.slice(n);
chunk = c.slice(0, n);
this[BUFFERLENGTH] -= n;
} else {
this[BUFFER][0] = c.subarray(n);
chunk = c.subarray(0, n);
this[BUFFERLENGTH] -= n;
}
}
this.emit("data", chunk);
if (!this[BUFFER].length && !this[EOF]) this.emit("drain");
return chunk;
}
end(chunk, encoding, cb) {
if (typeof chunk === "function") {
cb = chunk;
chunk = void 0;
}
if (typeof encoding === "function") {
cb = encoding;
encoding = "utf8";
}
if (chunk !== void 0) this.write(chunk, encoding);
if (cb) this.once("end", cb);
this[EOF] = true;
this.writable = false;
if (this[FLOWING] || !this[PAUSED]) this[MAYBE_EMIT_END]();
return this;
}
[RESUME]() {
if (this[DESTROYED]) return;
if (!this[DATALISTENERS] && !this[PIPES].length) this[DISCARDED] = true;
this[PAUSED] = false;
this[FLOWING] = true;
this.emit("resume");
if (this[BUFFER].length) this[FLUSH]();
else if (this[EOF]) this[MAYBE_EMIT_END]();
else this.emit("drain");
}
/**
* Resume the stream if it is currently in a paused state
*
* If called when there are no pipe destinations or `data` event listeners,
* this will place the stream in a "discarded" state, where all data will
* be thrown away. The discarded state is removed if a pipe destination or
* data handler is added, if pause() is called, or if any synchronous or
* asynchronous iteration is started.
*/
resume() {
return this[RESUME]();
}
/**
* Pause the stream
*/
pause() {
this[FLOWING] = false;
this[PAUSED] = true;
this[DISCARDED] = false;
}
/**
* true if the stream has been forcibly destroyed
*/
get destroyed() {
return this[DESTROYED];
}
/**
* true if the stream is currently in a flowing state, meaning that
* any writes will be immediately emitted.
*/
get flowing() {
return this[FLOWING];
}
/**
* true if the stream is currently in a paused state
*/
get paused() {
return this[PAUSED];
}
[BUFFERPUSH](chunk) {
if (this[OBJECTMODE]) this[BUFFERLENGTH] += 1;
else this[BUFFERLENGTH] += chunk.length;
this[BUFFER].push(chunk);
}
[BUFFERSHIFT]() {
if (this[OBJECTMODE]) this[BUFFERLENGTH] -= 1;
else this[BUFFERLENGTH] -= this[BUFFER][0].length;
return this[BUFFER].shift();
}
[FLUSH](noDrain = false) {
do ;
while (this[FLUSHCHUNK](this[BUFFERSHIFT]()) && this[BUFFER].length);
if (!noDrain && !this[BUFFER].length && !this[EOF]) this.emit("drain");
}
[FLUSHCHUNK](chunk) {
this.emit("data", chunk);
return this[FLOWING];
}
/**
* Pipe all data emitted by this stream into the destination provided.
*
* Triggers the flow of data.
*/
pipe(dest, opts) {
if (this[DESTROYED]) return dest;
this[DISCARDED] = false;
const ended = this[EMITTED_END];
opts = opts || {};
if (dest === proc.stdout || dest === proc.stderr) opts.end = false;
else opts.end = opts.end !== false;
opts.proxyErrors = !!opts.proxyErrors;
if (ended) {
if (opts.end) dest.end();
} else {
this[PIPES].push(!opts.proxyErrors ? new Pipe(this, dest, opts) : new PipeProxyErrors(this, dest, opts));
if (this[ASYNC]) defer(() => this[RESUME]());
else this[RESUME]();
}
return dest;
}
/**
* Fully unhook a piped destination stream.
*
* If the destination stream was the only consumer of this stream (ie,
* there are no other piped destinations or `'data'` event listeners)
* then the flow of data will stop until there is another consumer or
* {@link Minipass#resume} is explicitly called.
*/
unpipe(dest) {
const p = this[PIPES].find((p$1) => p$1.dest === dest);
if (p) {
if (this[PIPES].length === 1) {
if (this[FLOWING] && this[DATALISTENERS] === 0) this[FLOWING] = false;
this[PIPES] = [];
} else this[PIPES].splice(this[PIPES].indexOf(p), 1);
p.unpipe();
}
}
/**
* Alias for {@link Minipass#on}
*/
addListener(ev, handler) {
return this.on(ev, handler);
}
/**
* Mostly identical to `EventEmitter.on`, with the following
* behavior differences to prevent data loss and unnecessary hangs:
*
* - Adding a 'data' event handler will trigger the flow of data
*
* - Adding a 'readable' event handler when there is data waiting to be read
* will cause 'readable' to be emitted immediately.
*
* - Adding an 'endish' event handler ('end', 'finish', etc.) which has
* already passed will cause the event to be emitted immediately and all
* handlers removed.
*
* - Adding an 'error' event handler after an error has been emitted will
* cause the event to be re-emitted immediately with the error previously
* raised.
*/
on(ev, handler) {
const ret = super.on(ev, handler);
if (ev === "data") {
this[DISCARDED] = false;
this[DATALISTENERS]++;
if (!this[PIPES].length && !this[FLOWING]) this[RESUME]();
} else if (ev === "readable" && this[BUFFERLENGTH] !== 0) super.emit("readable");
else if (isEndish(ev) && this[EMITTED_END]) {
super.emit(ev);
this.removeAllListeners(ev);
} else if (ev === "error" && this[EMITTED_ERROR]) {
const h = handler;
if (this[ASYNC]) defer(() => h.call(this, this[EMITTED_ERROR]));
else h.call(this, this[EMITTED_ERROR]);
}
return ret;
}
/**
* Alias for {@link Minipass#off}
*/
removeListener(ev, handler) {
return this.off(ev, handler);
}
/**
* Mostly identical to `EventEmitter.off`
*
* If a 'data' event handler is removed, and it was the last consumer
* (ie, there are no pipe destinations or other 'data' event listeners),
* then the flow of data will stop until there is another consumer or
* {@link Minipass#resume} is explicitly called.
*/
off(ev, handler) {
const ret = super.off(ev, handler);
if (ev === "data") {
this[DATALISTENERS] = this.listeners("data").length;
if (this[DATALISTENERS] === 0 && !this[DISCARDED] && !this[PIPES].length) this[FLOWING] = false;
}
return ret;
}
/**
* Mostly identical to `EventEmitter.removeAllListeners`
*
* If all 'data' event handlers are removed, and they were the last consumer
* (ie, there are no pipe destinations), then the flow of data will stop
* until there is another consumer or {@link Minipass#resume} is explicitly
* called.
*/
removeAllListeners(ev) {
const ret = super.removeAllListeners(ev);
if (ev === "data" || ev === void 0) {
this[DATALISTENERS] = 0;
if (!this[DISCARDED] && !this[PIPES].length) this[FLOWING] = false;
}
return ret;
}
/**
* true if the 'end' event has been emitted
*/
get emittedEnd() {
return this[EMITTED_END];
}
[MAYBE_EMIT_END]() {
if (!this[EMITTING_END] && !this[EMITTED_END] && !this[DESTROYED] && this[BUFFER].length === 0 && this[EOF]) {
this[EMITTING_END] = true;
this.emit("end");
this.emit("prefinish");
this.emit("finish");
if (this[CLOSED]) this.emit("close");
this[EMITTING_END] = false;
}
}
/**
* Mostly identical to `EventEmitter.emit`, with the following
* behavior differences to prevent data loss and unnecessary hangs:
*
* If the stream has been destroyed, and the event is something other
* than 'close' or 'error', then `false` is returned and no handlers
* are called.
*
* If the event is 'end', and has already been emitted, then the event
* is ignored. If the stream is in a paused or non-flowing state, then
* the event will be deferred until data flow resumes. If the stream is
* async, then handlers will be called on the next tick rather than
* immediately.
*
* If the event is 'close', and 'end' has not yet been emitted, then
* the event will be deferred until after 'end' is emitted.
*
* If the event is 'error', and an AbortSignal was provided for the stream,
* and there are no listeners, then the event is ignored, matching the
* behavior of node core streams in the presense of an AbortSignal.
*
* If the event is 'finish' or 'prefinish', then all listeners will be
* removed after emitting the event, to prevent double-firing.
*/
emit(ev, ...args) {
const data = args[0];
if (ev !== "error" && ev !== "close" && ev !== DESTROYED && this[DESTROYED]) return false;
else if (ev === "data") return !this[OBJECTMODE] && !data ? false : this[ASYNC] ? (defer(() => this[EMITDATA](data)), true) : this[EMITDATA](data);
else if (ev === "end") return this[EMITEND]();
else if (ev === "close") {
this[CLOSED] = true;
if (!this[EMITTED_END] && !this[DESTROYED]) return false;
const ret$1 = super.emit("close");
this.removeAllListeners("close");
return ret$1;
} else if (ev === "error") {
this[EMITTED_ERROR] = data;
super.emit(ERROR, data);
const ret$1 = !this[SIGNAL] || this.listeners("error").length ? super.emit("error", data) : false;
this[MAYBE_EMIT_END]();
return ret$1;
} else if (ev === "resume") {
const ret$1 = super.emit("resume");
this[MAYBE_EMIT_END]();
return ret$1;
} else if (ev === "finish" || ev === "prefinish") {
const ret$1 = super.emit(ev);
this.removeAllListeners(ev);
return ret$1;
}
const ret = super.emit(ev, ...args);
this[MAYBE_EMIT_END]();
return ret;
}
[EMITDATA](data) {
for (const p of this[PIPES]) if (p.dest.write(data) === false) this.pause();
const ret = this[DISCARDED] ? false : super.emit("data", data);
this[MAYBE_EMIT_END]();
return ret;
}
[EMITEND]() {
if (this[EMITTED_END]) return false;
this[EMITTED_END] = true;
this.readable = false;
return this[ASYNC] ? (defer(() => this[EMITEND2]()), true) : this[EMITEND2]();
}
[EMITEND2]() {
if (this[DECODER]) {
const data = this[DECODER].end();
if (data) {
for (const p of this[PIPES]) p.dest.write(data);
if (!this[DISCARDED]) super.emit("data", data);
}
}
for (const p of this[PIPES]) p.end();
const ret = super.emit("end");
this.removeAllListeners("end");
return ret;
}
/**
* Return a Promise that resolves to an array of all emitted data once
* the stream ends.
*/
async collect() {
const buf = Object.assign([], { dataLength: 0 });
if (!this[OBJECTMODE]) buf.dataLength = 0;
const p = this.promise();
this.on("data", (c) => {
buf.push(c);
if (!this[OBJECTMODE]) buf.dataLength += c.length;
});
await p;
return buf;
}
/**
* Return a Promise that resolves to the concatenation of all emitted data
* once the stream ends.
*
* Not allowed on objectMode streams.
*/
async concat() {
if (this[OBJECTMODE]) throw new Error("cannot concat in objectMode");
const buf = await this.collect();
return this[ENCODING] ? buf.join("") : Buffer.concat(buf, buf.dataLength);
}
/**
* Return a void Promise that resolves once the stream ends.
*/
async promise() {
return new Promise((resolve, reject) => {
this.on(DESTROYED, () => reject(/* @__PURE__ */ new Error("stream destroyed")));
this.on("error", (er) => reject(er));
this.on("end", () => resolve());
});
}
/**
* Asynchronous `for await of` iteration.
*
* This will continue emitting all chunks until the stream terminates.
*/
[Symbol.asyncIterator]() {
this[DISCARDED] = false;
let stopped = false;
const stop = async () => {
this.pause();
stopped = true;
return {
value: void 0,
done: true
};
};
const next = () => {
if (stopped) return stop();
const res = this.read();
if (res !== null) return Promise.resolve({
done: false,
value: res
});
if (this[EOF]) return stop();
let resolve;
let reject;
const onerr = (er) => {
this.off("data", ondata);
this.off("end", onend);
this.off(DESTROYED, ondestroy);
stop();
reject(er);
};
const ondata = (value) => {
this.off("error", onerr);
this.off("end", onend);
this.off(DESTROYED, ondestroy);
this.pause();
resolve({
value,
done: !!this[EOF]
});
};
const onend = () => {
this.off("error", onerr);
this.off("data", ondata);
this.off(DESTROYED, ondestroy);
stop();
resolve({
done: true,
value: void 0
});
};
const ondestroy = () => onerr(/* @__PURE__ */ new Error("stream destroyed"));
return new Promise((res$1, rej) => {
reject = rej;
resolve = res$1;
this.once(DESTROYED, ondestroy);
this.once("error", onerr);
this.once("end", onend);
this.once("data", ondata);
});
};
return {
next,
throw: stop,
return: stop,
[Symbol.asyncIterator]() {
return this;
}
};
}
/**
* Synchronous `for of` iteration.
*
* The iteration will terminate when the internal buffer runs out, even
* if the stream has not yet terminated.
*/
[Symbol.iterator]() {
this[DISCARDED] = false;
let stopped = false;
const stop = () => {
this.pause();
this.off(ERROR, stop);
this.off(DESTROYED, stop);
this.off("end", stop);
stopped = true;
return {
done: true,
value: void 0
};
};
const next = () => {
if (stopped) return stop();
const value = this.read();
return value === null ? stop() : {
done: false,
value
};
};
this.once("end", stop);
this.once(ERROR, stop);
this.once(DESTROYED, stop);
return {
next,
throw: stop,
return: stop,
[Symbol.iterator]() {
return this;
}
};
}
/**
* Destroy a stream, preventing it from being used for any further purpose.
*
* If the stream has a `close()` method, then it will be called on
* destruction.
*
* After destruction, any attempt to write data, read data, or emit most
* events will be ignored.
*
* If an error argument is provided, then it will be emitted in an
* 'error' event.
*/
destroy(er) {
if (this[DESTROYED]) {
if (er) this.emit("error", er);
else this.emit(DESTROYED);
return this;
}
this[DESTROYED] = true;
this[DISCARDED] = true;
this[BUFFER].length = 0;
this[BUFFERLENGTH] = 0;
const wc = this;
if (typeof wc.close === "function" && !this[CLOSED]) wc.close();
if (er) this.emit("error", er);
else this.emit(DESTROYED);
return this;
}
/**
* Alias for {@link isStream}
*
* Former export location, maintained for backwards compatibility.
*
* @deprecated
*/
static get isStream() {
return exports.isStream;
}
};
exports.Minipass = Minipass;
}));
//#endregion
//#region node_modules/.pnpm/path-scurry@2.0.0/node_modules/path-scurry/dist/commonjs/index.js
var require_commonjs$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
if (k2 === void 0) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = {
enumerable: true,
get: function() {
return m[k];
}
};
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === void 0) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", {
enumerable: true,
value: v
});
}) : function(o, v) {
o["default"] = v;
});
var __importStar = exports && exports.__importStar || function(mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) {
for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
}
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PathScurry = exports.Path = exports.PathScurryDarwin = exports.PathScurryPosix = exports.PathScurryWin32 = exports.PathScurryBase = exports.PathPosix = exports.PathWin32 = exports.PathBase = exports.ChildrenCache = exports.ResolveCache = void 0;
const lru_cache_1 = require_commonjs$6();
const node_path_1 = __require("node:path");
const node_url_1$1 = __require("node:url");
const fs_1 = __require("fs");
const actualFS = __importStar(__require("node:fs"));
const realpathSync = fs_1.realpathSync.native;
const promises_1 = __require("node:fs/promises");
const minipass_1$1 = require_commonjs$2();
const defaultFS = {
lstatSync: fs_1.lstatSync,
readdir: fs_1.readdir,
readdirSync: fs_1.readdirSync,
readlinkSync: fs_1.readlinkSync,
realpathSync,
promises: {
lstat: promises_1.lstat,
readdir: promises_1.readdir,
readlink: promises_1.readlink,
realpath: promises_1.realpath
}
};
const fsFromOption = (fsOption) => !fsOption || fsOption === defaultFS || fsOption === actualFS ? defaultFS : {
...defaultFS,
...fsOption,
promises: {
...defaultFS.promises,
...fsOption.promises || {}
}
};
const uncDriveRegexp = /^\\\\\?\\([a-z]:)\\?$/i;
const uncToDrive = (rootPath) => rootPath.replace(/\//g, "\\").replace(uncDriveRegexp, "$1\\");
const eitherSep = /[\\\/]/;
const UNKNOWN = 0;
const IFIFO = 1;
const IFCHR = 2;
const IFDIR = 4;
const IFBLK = 6;
const IFREG = 8;
const IFLNK = 10;
const IFSOCK = 12;
const IFMT = 15;
const IFMT_UNKNOWN = ~IFMT;
const READDIR_CALLED = 16;
const LSTAT_CALLED = 32;
const ENOTDIR = 64;
const ENOENT = 128;
const ENOREADLINK = 256;
const ENOREALPATH = 512;
const ENOCHILD = ENOENT | 576;
const TYPEMASK = 1023;
const entToType = (s) => s.isFile() ? IFREG : s.isDirectory() ? IFDIR : s.isSymbolicLink() ? IFLNK : s.isCharacterDevice() ? IFCHR : s.isBlockDevice() ? IFBLK : s.isSocket() ? IFSOCK : s.isFIFO() ? IFIFO : UNKNOWN;
const normalizeCache = /* @__PURE__ */ new Map();
const normalize = (s) => {
const c = normalizeCache.get(s);
if (c) return c;
const n = s.normalize("NFKD");
normalizeCache.set(s, n);
return n;
};
const normalizeNocaseCache = /* @__PURE__ */ new Map();
const normalizeNocase = (s) => {
const c = normalizeNocaseCache.get(s);
if (c) return c;
const n = normalize(s.toLowerCase());
normalizeNocaseCache.set(s, n);
return n;
};
/**
* An LRUCache for storing resolved path strings or Path objects.
* @internal
*/
var ResolveCache = class extends lru_cache_1.LRUCache {
constructor() {
super({ max: 256 });
}
};
exports.ResolveCache = ResolveCache;
/**
* an LRUCache for storing child entries.
* @internal
*/
var ChildrenCache = class extends lru_cache_1.LRUCache {
constructor(maxSize = 16 * 1024) {
super({
maxSize,
sizeCalculation: (a) => a.length + 1
});
}
};
exports.ChildrenCache = ChildrenCache;
const setAsCwd = Symbol("PathScurry setAsCwd");
/**
* Path objects are sort of like a super-powered
* {@link https://nodejs.org/docs/latest/api/fs.html#class-fsdirent fs.Dirent}
*
* Each one represents a single filesystem entry on disk, which may or may not
* exist. It includes methods for reading various types of information via
* lstat, readlink, and readdir, and caches all information to the greatest
* degree possible.
*
* Note that fs operations that would normally throw will instead return an
* "empty" value. This is in order to prevent excessive overhead from error
* stack traces.
*/
var PathBase = class {
/**
* the basename of this path
*
* **Important**: *always* test the path name against any test string
* usingthe {@link isNamed} method, and not by directly comparing this
* string. Otherwise, unicode path strings that the system sees as identical
* will not be properly treated as the same path, leading to incorrect
* behavior and possible security issues.
*/
name;
/**
* the Path entry corresponding to the path root.
*
* @internal
*/
root;
/**
* All roots found within the current PathScurry family
*
* @internal
*/
roots;
/**
* a reference to the parent path, or undefined in the case of root entries
*
* @internal
*/
parent;
/**
* boolean indicating whether paths are compared case-insensitively
* @internal
*/
nocase;
/**
* boolean indicating that this path is the current working directory
* of the PathScurry collection that contains it.
*/
isCWD = false;
#fs;
#dev;
get dev() {
return this.#dev;
}
#mode;
get mode() {
return this.#mode;
}
#nlink;
get nlink() {
return this.#nlink;
}
#uid;
get uid() {
return this.#uid;
}
#gid;
get gid() {
return this.#gid;
}
#rdev;
get rdev() {
return this.#rdev;
}
#blksize;
get blksize() {
return this.#blksize;
}
#ino;
get ino() {
return this.#ino;
}
#size;
get size() {
return this.#size;
}
#blocks;
get blocks() {
return this.#blocks;
}
#atimeMs;
get atimeMs() {
return this.#atimeMs;
}
#mtimeMs;
get mtimeMs() {
return this.#mtimeMs;
}
#ctimeMs;
get ctimeMs() {
return this.#ctimeMs;
}
#birthtimeMs;
get birthtimeMs() {
return this.#birthtimeMs;
}
#atime;
get atime() {
return this.#atime;
}
#mtime;
get mtime() {
return this.#mtime;
}
#ctime;
get ctime() {
return this.#ctime;
}
#birthtime;
get birthtime() {
return this.#birthtime;
}
#matchName;
#depth;
#fullpath;
#fullpathPosix;
#relative;
#relativePosix;
#type;
#children;
#linkTarget;
#realpath;
/**
* This property is for compatibility with the Dirent class as of
* Node v20, where Dirent['parentPath'] refers to the path of the
* directory that was passed to readdir. For root entries, it's the path
* to the entry itself.
*/
get parentPath() {
return (this.parent || this).fullpath();
}
/**
* Deprecated alias for Dirent['parentPath'] Somewhat counterintuitively,
* this property refers to the *parent* path, not the path object itself.
*
* @deprecated
*/
get path() {
return this.parentPath;
}
/**
* Do not create new Path objects directly. They should always be accessed
* via the PathScurry class or other methods on the Path class.
*
* @internal
*/
constructor(name, type = UNKNOWN, root, roots, nocase, children, opts) {
this.name = name;
this.#matchName = nocase ? normalizeNocase(name) : normalize(name);
this.#type = type & TYPEMASK;
this.nocase = nocase;
this.roots = roots;
this.root = root || this;
this.#children = children;
this.#fullpath = opts.fullpath;
this.#relative = opts.relative;
this.#relativePosix = opts.relativePosix;
this.parent = opts.parent;
if (this.parent) this.#fs = this.parent.#fs;
else this.#fs = fsFromOption(opts.fs);
}
/**
* Returns the depth of the Path object from its root.
*
* For example, a path at `/foo/bar` would have a depth of 2.
*/
depth() {
if (this.#depth !== void 0) return this.#depth;
if (!this.parent) return this.#depth = 0;
return this.#depth = this.parent.depth() + 1;
}
/**
* @internal
*/
childrenCache() {
return this.#children;
}
/**
* Get the Path object referenced by the string path, resolved from this Path
*/
resolve(path$1) {
if (!path$1) return this;
const rootPath = this.getRootString(path$1);
const dirParts = path$1.substring(rootPath.length).split(this.splitSep);
return rootPath ? this.getRoot(rootPath).#resolveParts(dirParts) : this.#resolveParts(dirParts);
}
#resolveParts(dirParts) {
let p = this;
for (const part of dirParts) p = p.child(part);
return p;
}
/**
* Returns the cached children Path objects, if still available. If they
* have fallen out of the cache, then returns an empty array, and resets the
* READDIR_CALLED bit, so that future calls to readdir() will require an fs
* lookup.
*
* @internal
*/
children() {
const cached = this.#children.get(this);
if (cached) return cached;
const children = Object.assign([], { provisional: 0 });
this.#children.set(this, children);
this.#type &= ~READDIR_CALLED;
return children;
}
/**
* Resolves a path portion and returns or creates the child Path.
*
* Returns `this` if pathPart is `''` or `'.'`, or `parent` if pathPart is
* `'..'`.
*
* This should not be called directly. If `pathPart` contains any path
* separators, it will lead to unsafe undefined behavior.
*
* Use `Path.resolve()` instead.
*
* @internal
*/
child(pathPart, opts) {
if (pathPart === "" || pathPart === ".") return this;
if (pathPart === "..") return this.parent || this;
const children = this.children();
const name = this.nocase ? normalizeNocase(pathPart) : normalize(pathPart);
for (const p of children) if (p.#matchName === name) return p;
const s = this.parent ? this.sep : "";
const fullpath = this.#fullpath ? this.#fullpath + s + pathPart : void 0;
const pchild = this.newChild(pathPart, UNKNOWN, {
...opts,
parent: this,
fullpath
});
if (!this.canReaddir()) pchild.#type |= ENOENT;
children.push(pchild);
return pchild;
}
/**
* The relative path from the cwd. If it does not share an ancestor with
* the cwd, then this ends up being equivalent to the fullpath()
*/
relative() {
if (this.isCWD) return "";
if (this.#relative !== void 0) return this.#relative;
const name = this.name;
const p = this.parent;
if (!p) return this.#relative = this.name;
const pv = p.relative();
return pv + (!pv || !p.parent ? "" : this.sep) + name;
}
/**
* The relative path from the cwd, using / as the path separator.
* If it does not share an ancestor with
* the cwd, then this ends up being equivalent to the fullpathPosix()
* On posix systems, this is identical to relative().
*/
relativePosix() {
if (this.sep === "/") return this.relative();
if (this.isCWD) return "";
if (this.#relativePosix !== void 0) return this.#relativePosix;
const name = this.name;
const p = this.parent;
if (!p) return this.#relativePosix = this.fullpathPosix();
const pv = p.relativePosix();
return pv + (!pv || !p.parent ? "" : "/") + name;
}
/**
* The fully resolved path string for this Path entry
*/
fullpath() {
if (this.#fullpath !== void 0) return this.#fullpath;
const name = this.name;
const p = this.parent;
if (!p) return this.#fullpath = this.name;
return this.#fullpath = p.fullpath() + (!p.parent ? "" : this.sep) + name;
}
/**
* On platforms other than windows, this is identical to fullpath.
*
* On windows, this is overridden to return the forward-slash form of the
* full UNC path.
*/
fullpathPosix() {
if (this.#fullpathPosix !== void 0) return this.#fullpathPosix;
if (this.sep === "/") return this.#fullpathPosix = this.fullpath();
if (!this.parent) {
const p$1 = this.fullpath().replace(/\\/g, "/");
if (/^[a-z]:\//i.test(p$1)) return this.#fullpathPosix = `//?/${p$1}`;
else return this.#fullpathPosix = p$1;
}
const p = this.parent;
const pfpp = p.fullpathPosix();
return this.#fullpathPosix = pfpp + (!pfpp || !p.parent ? "" : "/") + this.name;
}
/**
* Is the Path of an unknown type?
*
* Note that we might know *something* about it if there has been a previous
* filesystem operation, for example that it does not exist, or is not a
* link, or whether it has child entries.
*/
isUnknown() {
return (this.#type & IFMT) === UNKNOWN;
}
isType(type) {
return this[`is${type}`]();
}
getType() {
return this.isUnknown() ? "Unknown" : this.isDirectory() ? "Directory" : this.isFile() ? "File" : this.isSymbolicLink() ? "SymbolicLink" : this.isFIFO() ? "FIFO" : this.isCharacterDevice() ? "CharacterDevice" : this.isBlockDevice() ? "BlockDevice" : this.isSocket() ? "Socket" : "Unknown";
/* c8 ignore stop */
}
/**
* Is the Path a regular file?
*/
isFile() {
return (this.#type & IFMT) === IFREG;
}
/**
* Is the Path a directory?
*/
isDirectory() {
return (this.#type & IFMT) === IFDIR;
}
/**
* Is the path a character device?
*/
isCharacterDevice() {
return (this.#type & IFMT) === IFCHR;
}
/**
* Is the path a block device?
*/
isBlockDevice() {
return (this.#type & IFMT) === IFBLK;
}
/**
* Is the path a FIFO pipe?
*/
isFIFO() {
return (this.#type & IFMT) === IFIFO;
}
/**
* Is the path a socket?
*/
isSocket() {
return (this.#type & IFMT) === IFSOCK;
}
/**
* Is the path a symbolic link?
*/
isSymbolicLink() {
return (this.#type & IFLNK) === IFLNK;
}
/**
* Return the entry if it has been subject of a successful lstat, or
* undefined otherwise.
*
* Does not read the filesystem, so an undefined result *could* simply
* mean that we haven't called lstat on it.
*/
lstatCached() {
return this.#type & LSTAT_CALLED ? this : void 0;
}
/**
* Return the cached link target if the entry has been the subject of a
* successful readlink, or undefined otherwise.
*
* Does not read the filesystem, so an undefined result *could* just mean we
* don't have any cached data. Only use it if you are very sure that a
* readlink() has been called at some point.
*/
readlinkCached() {
return this.#linkTarget;
}
/**
* Returns the cached realpath target if the entry has been the subject
* of a successful realpath, or undefined otherwise.
*
* Does not read the filesystem, so an undefined result *could* just mean we
* don't have any cached data. Only use it if you are very sure that a
* realpath() has been called at some point.
*/
realpathCached() {
return this.#realpath;
}
/**
* Returns the cached child Path entries array if the entry has been the
* subject of a successful readdir(), or [] otherwise.
*
* Does not read the filesystem, so an empty array *could* just mean we
* don't have any cached data. Only use it if you are very sure that a
* readdir() has been called recently enough to still be valid.
*/
readdirCached() {
const children = this.children();
return children.slice(0, children.provisional);
}
/**
* Return true if it's worth trying to readlink. Ie, we don't (yet) have
* any indication that readlink will definitely fail.
*
* Returns false if the path is known to not be a symlink, if a previous
* readlink failed, or if the entry does not exist.
*/
canReadlink() {
if (this.#linkTarget) return true;
if (!this.parent) return false;
const ifmt = this.#type & IFMT;
return !(ifmt !== UNKNOWN && ifmt !== IFLNK || this.#type & ENOREADLINK || this.#type & ENOENT);
}
/**
* Return true if readdir has previously been successfully called on this
* path, indicating that cachedReaddir() is likely valid.
*/
calledReaddir() {
return !!(this.#type & READDIR_CALLED);
}
/**
* Returns true if the path is known to not exist. That is, a previous lstat
* or readdir failed to verify its existence when that would have been
* expected, or a parent entry was marked either enoent or enotdir.
*/
isENOENT() {
return !!(this.#type & ENOENT);
}
/**
* Return true if the path is a match for the given path name. This handles
* case sensitivity and unicode normalization.
*
* Note: even on case-sensitive systems, it is **not** safe to test the
* equality of the `.name` property to determine whether a given pathname
* matches, due to unicode normalization mismatches.
*
* Always use this method instead of testing the `path.name` property
* directly.
*/
isNamed(n) {
return !this.nocase ? this.#matchName === normalize(n) : this.#matchName === normalizeNocase(n);
}
/**
* Return the Path object corresponding to the target of a symbolic link.
*
* If the Path is not a symbolic link, or if the readlink call fails for any
* reason, `undefined` is returned.
*
* Result is cached, and thus may be outdated if the filesystem is mutated.
*/
async readlink() {
const target = this.#linkTarget;
if (target) return target;
if (!this.canReadlink()) return;
/* c8 ignore start */
if (!this.parent) return;
/* c8 ignore stop */
try {
const read = await this.#fs.promises.readlink(this.fullpath());
const linkTarget = (await this.parent.realpath())?.resolve(read);
if (linkTarget) return this.#linkTarget = linkTarget;
} catch (er) {
this.#readlinkFail(er.code);
return;
}
}
/**
* Synchronous {@link PathBase.readlink}
*/
readlinkSync() {
const target = this.#linkTarget;
if (target) return target;
if (!this.canReadlink()) return;
/* c8 ignore start */
if (!this.parent) return;
/* c8 ignore stop */
try {
const read = this.#fs.readlinkSync(this.fullpath());
const linkTarget = this.parent.realpathSync()?.resolve(read);
if (linkTarget) return this.#linkTarget = linkTarget;
} catch (er) {
this.#readlinkFail(er.code);
return;
}
}
#readdirSuccess(children) {
this.#type |= READDIR_CALLED;
for (let p = children.provisional; p < children.length; p++) {
const c = children[p];
if (c) c.#markENOENT();
}
}
#markENOENT() {
if (this.#type & ENOENT) return;
this.#type = (this.#type | ENOENT) & IFMT_UNKNOWN;
this.#markChildrenENOENT();
}
#markChildrenENOENT() {
const children = this.children();
children.provisional = 0;
for (const p of children) p.#markENOENT();
}
#markENOREALPATH() {
this.#type |= ENOREALPATH;
this.#markENOTDIR();
}
#markENOTDIR() {
/* c8 ignore start */
if (this.#type & ENOTDIR) return;
/* c8 ignore stop */
let t = this.#type;
if ((t & IFMT) === IFDIR) t &= IFMT_UNKNOWN;
this.#type = t | ENOTDIR;
this.#markChildrenENOENT();
}
#readdirFail(code = "") {
if (code === "ENOTDIR" || code === "EPERM") this.#markENOTDIR();
else if (code === "ENOENT") this.#markENOENT();
else this.children().provisional = 0;
}
#lstatFail(code = "") {
/* c8 ignore start */
if (code === "ENOTDIR") this.parent.#markENOTDIR();
else if (code === "ENOENT")
/* c8 ignore stop */
this.#markENOENT();
}
#readlinkFail(code = "") {
let ter = this.#type;
ter |= ENOREADLINK;
if (code === "ENOENT") ter |= ENOENT;
if (code === "EINVAL" || code === "UNKNOWN") ter &= IFMT_UNKNOWN;
this.#type = ter;
/* c8 ignore start */
if (code === "ENOTDIR" && this.parent) this.parent.#markENOTDIR();
/* c8 ignore stop */
}
#readdirAddChild(e, c) {
return this.#readdirMaybePromoteChild(e, c) || this.#readdirAddNewChild(e, c);
}
#readdirAddNewChild(e, c) {
const type = entToType(e);
const child = this.newChild(e.name, type, { parent: this });
const ifmt = child.#type & IFMT;
if (ifmt !== IFDIR && ifmt !== IFLNK && ifmt !== UNKNOWN) child.#type |= ENOTDIR;
c.unshift(child);
c.provisional++;
return child;
}
#readdirMaybePromoteChild(e, c) {
for (let p = c.provisional; p < c.length; p++) {
const pchild = c[p];
if ((this.nocase ? normalizeNocase(e.name) : normalize(e.name)) !== pchild.#matchName) continue;
return this.#readdirPromoteChild(e, pchild, p, c);
}
}
#readdirPromoteChild(e, p, index, c) {
const v = p.name;
p.#type = p.#type & IFMT_UNKNOWN | entToType(e);
if (v !== e.name) p.name = e.name;
if (index !== c.provisional) {
if (index === c.length - 1) c.pop();
else c.splice(index, 1);
c.unshift(p);
}
c.provisional++;
return p;
}
/**
* Call lstat() on this Path, and update all known information that can be
* determined.
*
* Note that unlike `fs.lstat()`, the returned value does not contain some
* information, such as `mode`, `dev`, `nlink`, and `ino`. If that
* information is required, you will need to call `fs.lstat` yourself.
*
* If the Path refers to a nonexistent file, or if the lstat call fails for
* any reason, `undefined` is returned. Otherwise the updated Path object is
* returned.
*
* Results are cached, and thus may be out of date if the filesystem is
* mutated.
*/
async lstat() {
if ((this.#type & ENOENT) === 0) try {
this.#applyStat(await this.#fs.promises.lstat(this.fullpath()));
return this;
} catch (er) {
this.#lstatFail(er.code);
}
}
/**
* synchronous {@link PathBase.lstat}
*/
lstatSync() {
if ((this.#type & ENOENT) === 0) try {
this.#applyStat(this.#fs.lstatSync(this.fullpath()));
return this;
} catch (er) {
this.#lstatFail(er.code);
}
}
#applyStat(st) {
const { atime, atimeMs, birthtime, birthtimeMs, blksize, blocks, ctime, ctimeMs, dev, gid, ino, mode, mtime, mtimeMs, nlink, rdev, size, uid } = st;
this.#atime = atime;
this.#atimeMs = atimeMs;
this.#birthtime = birthtime;
this.#birthtimeMs = birthtimeMs;
this.#blksize = blksize;
this.#blocks = blocks;
this.#ctime = ctime;
this.#ctimeMs = ctimeMs;
this.#dev = dev;
this.#gid = gid;
this.#ino = ino;
this.#mode = mode;
this.#mtime = mtime;
this.#mtimeMs = mtimeMs;
this.#nlink = nlink;
this.#rdev = rdev;
this.#size = size;
this.#uid = uid;
const ifmt = entToType(st);
this.#type = this.#type & IFMT_UNKNOWN | ifmt | LSTAT_CALLED;
if (ifmt !== UNKNOWN && ifmt !== IFDIR && ifmt !== IFLNK) this.#type |= ENOTDIR;
}
#onReaddirCB = [];
#readdirCBInFlight = false;
#callOnReaddirCB(children) {
this.#readdirCBInFlight = false;
const cbs = this.#onReaddirCB.slice();
this.#onReaddirCB.length = 0;
cbs.forEach((cb) => cb(null, children));
}
/**
* Standard node-style callback interface to get list of directory entries.
*
* If the Path cannot or does not contain any children, then an empty array
* is returned.
*
* Results are cached, and thus may be out of date if the filesystem is
* mutated.
*
* @param cb The callback called with (er, entries). Note that the `er`
* param is somewhat extraneous, as all readdir() errors are handled and
* simply result in an empty set of entries being returned.
* @param allowZalgo Boolean indicating that immediately known results should
* *not* be deferred with `queueMicrotask`. Defaults to `false`. Release
* zalgo at your peril, the dark pony lord is devious and unforgiving.
*/
readdirCB(cb, allowZalgo = false) {
if (!this.canReaddir()) {
if (allowZalgo) cb(null, []);
else queueMicrotask(() => cb(null, []));
return;
}
const children = this.children();
if (this.calledReaddir()) {
const c = children.slice(0, children.provisional);
if (allowZalgo) cb(null, c);
else queueMicrotask(() => cb(null, c));
return;
}
this.#onReaddirCB.push(cb);
if (this.#readdirCBInFlight) return;
this.#readdirCBInFlight = true;
const fullpath = this.fullpath();
this.#fs.readdir(fullpath, { withFileTypes: true }, (er, entries) => {
if (er) {
this.#readdirFail(er.code);
children.provisional = 0;
} else {
for (const e of entries) this.#readdirAddChild(e, children);
this.#readdirSuccess(children);
}
this.#callOnReaddirCB(children.slice(0, children.provisional));
});
}
#asyncReaddirInFlight;
/**
* Return an array of known child entries.
*
* If the Path cannot or does not contain any children, then an empty array
* is returned.
*
* Results are cached, and thus may be out of date if the filesystem is
* mutated.
*/
async readdir() {
if (!this.canReaddir()) return [];
const children = this.children();
if (this.calledReaddir()) return children.slice(0, children.provisional);
const fullpath = this.fullpath();
if (this.#asyncReaddirInFlight) await this.#asyncReaddirInFlight;
else {
/* c8 ignore start */
let resolve = () => {};
/* c8 ignore stop */
this.#asyncReaddirInFlight = new Promise((res) => resolve = res);
try {
for (const e of await this.#fs.promises.readdir(fullpath, { withFileTypes: true })) this.#readdirAddChild(e, children);
this.#readdirSuccess(children);
} catch (er) {
this.#readdirFail(er.code);
children.provisional = 0;
}
this.#asyncReaddirInFlight = void 0;
resolve();
}
return children.slice(0, children.provisional);
}
/**
* synchronous {@link PathBase.readdir}
*/
readdirSync() {
if (!this.canReaddir()) return [];
const children = this.children();
if (this.calledReaddir()) return children.slice(0, children.provisional);
const fullpath = this.fullpath();
try {
for (const e of this.#fs.readdirSync(fullpath, { withFileTypes: true })) this.#readdirAddChild(e, children);
this.#readdirSuccess(children);
} catch (er) {
this.#readdirFail(er.code);
children.provisional = 0;
}
return children.slice(0, children.provisional);
}
canReaddir() {
if (this.#type & ENOCHILD) return false;
const ifmt = IFMT & this.#type;
/* c8 ignore start */
if (!(ifmt === UNKNOWN || ifmt === IFDIR || ifmt === IFLNK)) return false;
/* c8 ignore stop */
return true;
}
shouldWalk(dirs, walkFilter) {
return (this.#type & IFDIR) === IFDIR && !(this.#type & ENOCHILD) && !dirs.has(this) && (!walkFilter || walkFilter(this));
}
/**
* Return the Path object corresponding to path as resolved
* by realpath(3).
*
* If the realpath call fails for any reason, `undefined` is returned.
*
* Result is cached, and thus may be outdated if the filesystem is mutated.
* On success, returns a Path object.
*/
async realpath() {
if (this.#realpath) return this.#realpath;
if ((ENOREADLINK | 640) & this.#type) return void 0;
try {
const rp = await this.#fs.promises.realpath(this.fullpath());
return this.#realpath = this.resolve(rp);
} catch (_) {
this.#markENOREALPATH();
}
}
/**
* Synchronous {@link realpath}
*/
realpathSync() {
if (this.#realpath) return this.#realpath;
if ((ENOREADLINK | 640) & this.#type) return void 0;
try {
const rp = this.#fs.realpathSync(this.fullpath());
return this.#realpath = this.resolve(rp);
} catch (_) {
this.#markENOREALPATH();
}
}
/**
* Internal method to mark this Path object as the scurry cwd,
* called by {@link PathScurry#chdir}
*
* @internal
*/
[setAsCwd](oldCwd) {
if (oldCwd === this) return;
oldCwd.isCWD = false;
this.isCWD = true;
const changed = /* @__PURE__ */ new Set([]);
let rp = [];
let p = this;
while (p && p.parent) {
changed.add(p);
p.#relative = rp.join(this.sep);
p.#relativePosix = rp.join("/");
p = p.parent;
rp.push("..");
}
p = oldCwd;
while (p && p.parent && !changed.has(p)) {
p.#relative = void 0;
p.#relativePosix = void 0;
p = p.parent;
}
}
};
exports.PathBase = PathBase;
/**
* Path class used on win32 systems
*
* Uses `'\\'` as the path separator for returned paths, either `'\\'` or `'/'`
* as the path separator for parsing paths.
*/
var PathWin32 = class PathWin32 extends PathBase {
/**
* Separator for generating path strings.
*/
sep = "\\";
/**
* Separator for parsing path strings.
*/
splitSep = eitherSep;
/**
* Do not create new Path objects directly. They should always be accessed
* via the PathScurry class or other methods on the Path class.
*
* @internal
*/
constructor(name, type = UNKNOWN, root, roots, nocase, children, opts) {
super(name, type, root, roots, nocase, children, opts);
}
/**
* @internal
*/
newChild(name, type = UNKNOWN, opts = {}) {
return new PathWin32(name, type, this.root, this.roots, this.nocase, this.childrenCache(), opts);
}
/**
* @internal
*/
getRootString(path$1) {
return node_path_1.win32.parse(path$1).root;
}
/**
* @internal
*/
getRoot(rootPath) {
rootPath = uncToDrive(rootPath.toUpperCase());
if (rootPath === this.root.name) return this.root;
for (const [compare, root] of Object.entries(this.roots)) if (this.sameRoot(rootPath, compare)) return this.roots[rootPath] = root;
return this.roots[rootPath] = new PathScurryWin32(rootPath, this).root;
}
/**
* @internal
*/
sameRoot(rootPath, compare = this.root.name) {
rootPath = rootPath.toUpperCase().replace(/\//g, "\\").replace(uncDriveRegexp, "$1\\");
return rootPath === compare;
}
};
exports.PathWin32 = PathWin32;
/**
* Path class used on all posix systems.
*
* Uses `'/'` as the path separator.
*/
var PathPosix = class PathPosix extends PathBase {
/**
* separator for parsing path strings
*/
splitSep = "/";
/**
* separator for generating path strings
*/
sep = "/";
/**
* Do not create new Path objects directly. They should always be accessed
* via the PathScurry class or other methods on the Path class.
*
* @internal
*/
constructor(name, type = UNKNOWN, root, roots, nocase, children, opts) {
super(name, type, root, roots, nocase, children, opts);
}
/**
* @internal
*/
getRootString(path$1) {
return path$1.startsWith("/") ? "/" : "";
}
/**
* @internal
*/
getRoot(_rootPath) {
return this.root;
}
/**
* @internal
*/
newChild(name, type = UNKNOWN, opts = {}) {
return new PathPosix(name, type, this.root, this.roots, this.nocase, this.childrenCache(), opts);
}
};
exports.PathPosix = PathPosix;
/**
* The base class for all PathScurry classes, providing the interface for path
* resolution and filesystem operations.
*
* Typically, you should *not* instantiate this class directly, but rather one
* of the platform-specific classes, or the exported {@link PathScurry} which
* defaults to the current platform.
*/
var PathScurryBase = class {
/**
* The root Path entry for the current working directory of this Scurry
*/
root;
/**
* The string path for the root of this Scurry's current working directory
*/
rootPath;
/**
* A collection of all roots encountered, referenced by rootPath
*/
roots;
/**
* The Path entry corresponding to this PathScurry's current working directory.
*/
cwd;
#resolveCache;
#resolvePosixCache;
#children;
/**
* Perform path comparisons case-insensitively.
*
* Defaults true on Darwin and Windows systems, false elsewhere.
*/
nocase;
#fs;
/**
* This class should not be instantiated directly.
*
* Use PathScurryWin32, PathScurryDarwin, PathScurryPosix, or PathScurry
*
* @internal
*/
constructor(cwd = process.cwd(), pathImpl, sep, { nocase, childrenCacheSize = 16 * 1024, fs = defaultFS } = {}) {
this.#fs = fsFromOption(fs);
if (cwd instanceof URL || cwd.startsWith("file://")) cwd = (0, node_url_1$1.fileURLToPath)(cwd);
const cwdPath = pathImpl.resolve(cwd);
this.roots = Object.create(null);
this.rootPath = this.parseRootPath(cwdPath);
this.#resolveCache = new ResolveCache();
this.#resolvePosixCache = new ResolveCache();
this.#children = new ChildrenCache(childrenCacheSize);
const split = cwdPath.substring(this.rootPath.length).split(sep);
if (split.length === 1 && !split[0]) split.pop();
/* c8 ignore start */
if (nocase === void 0) throw new TypeError("must provide nocase setting to PathScurryBase ctor");
/* c8 ignore stop */
this.nocase = nocase;
this.root = this.newRoot(this.#fs);
this.roots[this.rootPath] = this.root;
let prev = this.root;
let len = split.length - 1;
const joinSep = pathImpl.sep;
let abs = this.rootPath;
let sawFirst = false;
for (const part of split) {
const l = len--;
prev = prev.child(part, {
relative: new Array(l).fill("..").join(joinSep),
relativePosix: new Array(l).fill("..").join("/"),
fullpath: abs += (sawFirst ? "" : joinSep) + part
});
sawFirst = true;
}
this.cwd = prev;
}
/**
* Get the depth of a provided path, string, or the cwd
*/
depth(path$1 = this.cwd) {
if (typeof path$1 === "string") path$1 = this.cwd.resolve(path$1);
return path$1.depth();
}
/**
* Return the cache of child entries. Exposed so subclasses can create
* child Path objects in a platform-specific way.
*
* @internal
*/
childrenCache() {
return this.#children;
}
/**
* Resolve one or more path strings to a resolved string
*
* Same interface as require('path').resolve.
*
* Much faster than path.resolve() when called multiple times for the same
* path, because the resolved Path objects are cached. Much slower
* otherwise.
*/
resolve(...paths) {
let r = "";
for (let i = paths.length - 1; i >= 0; i--) {
const p = paths[i];
if (!p || p === ".") continue;
r = r ? `${p}/${r}` : p;
if (this.isAbsolute(p)) break;
}
const cached = this.#resolveCache.get(r);
if (cached !== void 0) return cached;
const result = this.cwd.resolve(r).fullpath();
this.#resolveCache.set(r, result);
return result;
}
/**
* Resolve one or more path strings to a resolved string, returning
* the posix path. Identical to .resolve() on posix systems, but on
* windows will return a forward-slash separated UNC path.
*
* Same interface as require('path').resolve.
*
* Much faster than path.resolve() when called multiple times for the same
* path, because the resolved Path objects are cached. Much slower
* otherwise.
*/
resolvePosix(...paths) {
let r = "";
for (let i = paths.length - 1; i >= 0; i--) {
const p = paths[i];
if (!p || p === ".") continue;
r = r ? `${p}/${r}` : p;
if (this.isAbsolute(p)) break;
}
const cached = this.#resolvePosixCache.get(r);
if (cached !== void 0) return cached;
const result = this.cwd.resolve(r).fullpathPosix();
this.#resolvePosixCache.set(r, result);
return result;
}
/**
* find the relative path from the cwd to the supplied path string or entry
*/
relative(entry = this.cwd) {
if (typeof entry === "string") entry = this.cwd.resolve(entry);
return entry.relative();
}
/**
* find the relative path from the cwd to the supplied path string or
* entry, using / as the path delimiter, even on Windows.
*/
relativePosix(entry = this.cwd) {
if (typeof entry === "string") entry = this.cwd.resolve(entry);
return entry.relativePosix();
}
/**
* Return the basename for the provided string or Path object
*/
basename(entry = this.cwd) {
if (typeof entry === "string") entry = this.cwd.resolve(entry);
return entry.name;
}
/**
* Return the dirname for the provided string or Path object
*/
dirname(entry = this.cwd) {
if (typeof entry === "string") entry = this.cwd.resolve(entry);
return (entry.parent || entry).fullpath();
}
async readdir(entry = this.cwd, opts = { withFileTypes: true }) {
if (typeof entry === "string") entry = this.cwd.resolve(entry);
else if (!(entry instanceof PathBase)) {
opts = entry;
entry = this.cwd;
}
const { withFileTypes } = opts;
if (!entry.canReaddir()) return [];
else {
const p = await entry.readdir();
return withFileTypes ? p : p.map((e) => e.name);
}
}
readdirSync(entry = this.cwd, opts = { withFileTypes: true }) {
if (typeof entry === "string") entry = this.cwd.resolve(entry);
else if (!(entry instanceof PathBase)) {
opts = entry;
entry = this.cwd;
}
const { withFileTypes = true } = opts;
if (!entry.canReaddir()) return [];
else if (withFileTypes) return entry.readdirSync();
else return entry.readdirSync().map((e) => e.name);
}
/**
* Call lstat() on the string or Path object, and update all known
* information that can be determined.
*
* Note that unlike `fs.lstat()`, the returned value does not contain some
* information, such as `mode`, `dev`, `nlink`, and `ino`. If that
* information is required, you will need to call `fs.lstat` yourself.
*
* If the Path refers to a nonexistent file, or if the lstat call fails for
* any reason, `undefined` is returned. Otherwise the updated Path object is
* returned.
*
* Results are cached, and thus may be out of date if the filesystem is
* mutated.
*/
async lstat(entry = this.cwd) {
if (typeof entry === "string") entry = this.cwd.resolve(entry);
return entry.lstat();
}
/**
* synchronous {@link PathScurryBase.lstat}
*/
lstatSync(entry = this.cwd) {
if (typeof entry === "string") entry = this.cwd.resolve(entry);
return entry.lstatSync();
}
async readlink(entry = this.cwd, { withFileTypes } = { withFileTypes: false }) {
if (typeof entry === "string") entry = this.cwd.resolve(entry);
else if (!(entry instanceof PathBase)) {
withFileTypes = entry.withFileTypes;
entry = this.cwd;
}
const e = await entry.readlink();
return withFileTypes ? e : e?.fullpath();
}
readlinkSync(entry = this.cwd, { withFileTypes } = { withFileTypes: false }) {
if (typeof entry === "string") entry = this.cwd.resolve(entry);
else if (!(entry instanceof PathBase)) {
withFileTypes = entry.withFileTypes;
entry = this.cwd;
}
const e = entry.readlinkSync();
return withFileTypes ? e : e?.fullpath();
}
async realpath(entry = this.cwd, { withFileTypes } = { withFileTypes: false }) {
if (typeof entry === "string") entry = this.cwd.resolve(entry);
else if (!(entry instanceof PathBase)) {
withFileTypes = entry.withFileTypes;
entry = this.cwd;
}
const e = await entry.realpath();
return withFileTypes ? e : e?.fullpath();
}
realpathSync(entry = this.cwd, { withFileTypes } = { withFileTypes: false }) {
if (typeof entry === "string") entry = this.cwd.resolve(entry);
else if (!(entry instanceof PathBase)) {
withFileTypes = entry.withFileTypes;
entry = this.cwd;
}
const e = entry.realpathSync();
return withFileTypes ? e : e?.fullpath();
}
async walk(entry = this.cwd, opts = {}) {
if (typeof entry === "string") entry = this.cwd.resolve(entry);
else if (!(entry instanceof PathBase)) {
opts = entry;
entry = this.cwd;
}
const { withFileTypes = true, follow = false, filter: filter$1, walkFilter } = opts;
const results = [];
if (!filter$1 || filter$1(entry)) results.push(withFileTypes ? entry : entry.fullpath());
const dirs = /* @__PURE__ */ new Set();
const walk = (dir, cb) => {
dirs.add(dir);
dir.readdirCB((er, entries) => {
/* c8 ignore start */
if (er) return cb(er);
/* c8 ignore stop */
let len = entries.length;
if (!len) return cb();
const next = () => {
if (--len === 0) cb();
};
for (const e of entries) {
if (!filter$1 || filter$1(e)) results.push(withFileTypes ? e : e.fullpath());
if (follow && e.isSymbolicLink()) e.realpath().then((r) => r?.isUnknown() ? r.lstat() : r).then((r) => r?.shouldWalk(dirs, walkFilter) ? walk(r, next) : next());
else if (e.shouldWalk(dirs, walkFilter)) walk(e, next);
else next();
}
}, true);
};
const start = entry;
return new Promise((res, rej) => {
walk(start, (er) => {
/* c8 ignore start */
if (er) return rej(er);
/* c8 ignore stop */
res(results);
});
});
}
walkSync(entry = this.cwd, opts = {}) {
if (typeof entry === "string") entry = this.cwd.resolve(entry);
else if (!(entry instanceof PathBase)) {
opts = entry;
entry = this.cwd;
}
const { withFileTypes = true, follow = false, filter: filter$1, walkFilter } = opts;
const results = [];
if (!filter$1 || filter$1(entry)) results.push(withFileTypes ? entry : entry.fullpath());
const dirs = new Set([entry]);
for (const dir of dirs) {
const entries = dir.readdirSync();
for (const e of entries) {
if (!filter$1 || filter$1(e)) results.push(withFileTypes ? e : e.fullpath());
let r = e;
if (e.isSymbolicLink()) {
if (!(follow && (r = e.realpathSync()))) continue;
if (r.isUnknown()) r.lstatSync();
}
if (r.shouldWalk(dirs, walkFilter)) dirs.add(r);
}
}
return results;
}
/**
* Support for `for await`
*
* Alias for {@link PathScurryBase.iterate}
*
* Note: As of Node 19, this is very slow, compared to other methods of
* walking. Consider using {@link PathScurryBase.stream} if memory overhead
* and backpressure are concerns, or {@link PathScurryBase.walk} if not.
*/
[Symbol.asyncIterator]() {
return this.iterate();
}
iterate(entry = this.cwd, options = {}) {
if (typeof entry === "string") entry = this.cwd.resolve(entry);
else if (!(entry instanceof PathBase)) {
options = entry;
entry = this.cwd;
}
return this.stream(entry, options)[Symbol.asyncIterator]();
}
/**
* Iterating over a PathScurry performs a synchronous walk.
*
* Alias for {@link PathScurryBase.iterateSync}
*/
[Symbol.iterator]() {
return this.iterateSync();
}
*iterateSync(entry = this.cwd, opts = {}) {
if (typeof entry === "string") entry = this.cwd.resolve(entry);
else if (!(entry instanceof PathBase)) {
opts = entry;
entry = this.cwd;
}
const { withFileTypes = true, follow = false, filter: filter$1, walkFilter } = opts;
if (!filter$1 || filter$1(entry)) yield withFileTypes ? entry : entry.fullpath();
const dirs = new Set([entry]);
for (const dir of dirs) {
const entries = dir.readdirSync();
for (const e of entries) {
if (!filter$1 || filter$1(e)) yield withFileTypes ? e : e.fullpath();
let r = e;
if (e.isSymbolicLink()) {
if (!(follow && (r = e.realpathSync()))) continue;
if (r.isUnknown()) r.lstatSync();
}
if (r.shouldWalk(dirs, walkFilter)) dirs.add(r);
}
}
}
stream(entry = this.cwd, opts = {}) {
if (typeof entry === "string") entry = this.cwd.resolve(entry);
else if (!(entry instanceof PathBase)) {
opts = entry;
entry = this.cwd;
}
const { withFileTypes = true, follow = false, filter: filter$1, walkFilter } = opts;
const results = new minipass_1$1.Minipass({ objectMode: true });
if (!filter$1 || filter$1(entry)) results.write(withFileTypes ? entry : entry.fullpath());
const dirs = /* @__PURE__ */ new Set();
const queue = [entry];
let processing = 0;
const process$1 = () => {
let paused = false;
while (!paused) {
const dir = queue.shift();
if (!dir) {
if (processing === 0) results.end();
return;
}
processing++;
dirs.add(dir);
const onReaddir = (er, entries, didRealpaths = false) => {
/* c8 ignore start */
if (er) return results.emit("error", er);
/* c8 ignore stop */
if (follow && !didRealpaths) {
const promises = [];
for (const e of entries) if (e.isSymbolicLink()) promises.push(e.realpath().then((r) => r?.isUnknown() ? r.lstat() : r));
if (promises.length) {
Promise.all(promises).then(() => onReaddir(null, entries, true));
return;
}
}
for (const e of entries) if (e && (!filter$1 || filter$1(e))) {
if (!results.write(withFileTypes ? e : e.fullpath())) paused = true;
}
processing--;
for (const e of entries) {
const r = e.realpathCached() || e;
if (r.shouldWalk(dirs, walkFilter)) queue.push(r);
}
if (paused && !results.flowing) results.once("drain", process$1);
else if (!sync) process$1();
};
let sync = true;
dir.readdirCB(onReaddir, true);
sync = false;
}
};
process$1();
return results;
}
streamSync(entry = this.cwd, opts = {}) {
if (typeof entry === "string") entry = this.cwd.resolve(entry);
else if (!(entry instanceof PathBase)) {
opts = entry;
entry = this.cwd;
}
const { withFileTypes = true, follow = false, filter: filter$1, walkFilter } = opts;
const results = new minipass_1$1.Minipass({ objectMode: true });
const dirs = /* @__PURE__ */ new Set();
if (!filter$1 || filter$1(entry)) results.write(withFileTypes ? entry : entry.fullpath());
const queue = [entry];
let processing = 0;
const process$1 = () => {
let paused = false;
while (!paused) {
const dir = queue.shift();
if (!dir) {
if (processing === 0) results.end();
return;
}
processing++;
dirs.add(dir);
const entries = dir.readdirSync();
for (const e of entries) if (!filter$1 || filter$1(e)) {
if (!results.write(withFileTypes ? e : e.fullpath())) paused = true;
}
processing--;
for (const e of entries) {
let r = e;
if (e.isSymbolicLink()) {
if (!(follow && (r = e.realpathSync()))) continue;
if (r.isUnknown()) r.lstatSync();
}
if (r.shouldWalk(dirs, walkFilter)) queue.push(r);
}
}
if (paused && !results.flowing) results.once("drain", process$1);
};
process$1();
return results;
}
chdir(path$1 = this.cwd) {
const oldCwd = this.cwd;
this.cwd = typeof path$1 === "string" ? this.cwd.resolve(path$1) : path$1;
this.cwd[setAsCwd](oldCwd);
}
};
exports.PathScurryBase = PathScurryBase;
/**
* Windows implementation of {@link PathScurryBase}
*
* Defaults to case insensitve, uses `'\\'` to generate path strings. Uses
* {@link PathWin32} for Path objects.
*/
var PathScurryWin32 = class extends PathScurryBase {
/**
* separator for generating path strings
*/
sep = "\\";
constructor(cwd = process.cwd(), opts = {}) {
const { nocase = true } = opts;
super(cwd, node_path_1.win32, "\\", {
...opts,
nocase
});
this.nocase = nocase;
for (let p = this.cwd; p; p = p.parent) p.nocase = this.nocase;
}
/**
* @internal
*/
parseRootPath(dir) {
return node_path_1.win32.parse(dir).root.toUpperCase();
}
/**
* @internal
*/
newRoot(fs) {
return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs });
}
/**
* Return true if the provided path string is an absolute path
*/
isAbsolute(p) {
return p.startsWith("/") || p.startsWith("\\") || /^[a-z]:(\/|\\)/i.test(p);
}
};
exports.PathScurryWin32 = PathScurryWin32;
/**
* {@link PathScurryBase} implementation for all posix systems other than Darwin.
*
* Defaults to case-sensitive matching, uses `'/'` to generate path strings.
*
* Uses {@link PathPosix} for Path objects.
*/
var PathScurryPosix = class extends PathScurryBase {
/**
* separator for generating path strings
*/
sep = "/";
constructor(cwd = process.cwd(), opts = {}) {
const { nocase = false } = opts;
super(cwd, node_path_1.posix, "/", {
...opts,
nocase
});
this.nocase = nocase;
}
/**
* @internal
*/
parseRootPath(_dir) {
return "/";
}
/**
* @internal
*/
newRoot(fs) {
return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs });
}
/**
* Return true if the provided path string is an absolute path
*/
isAbsolute(p) {
return p.startsWith("/");
}
};
exports.PathScurryPosix = PathScurryPosix;
/**
* {@link PathScurryBase} implementation for Darwin (macOS) systems.
*
* Defaults to case-insensitive matching, uses `'/'` for generating path
* strings.
*
* Uses {@link PathPosix} for Path objects.
*/
var PathScurryDarwin = class extends PathScurryPosix {
constructor(cwd = process.cwd(), opts = {}) {
const { nocase = true } = opts;
super(cwd, {
...opts,
nocase
});
}
};
exports.PathScurryDarwin = PathScurryDarwin;
/**
* Default {@link PathBase} implementation for the current platform.
*
* {@link PathWin32} on Windows systems, {@link PathPosix} on all others.
*/
exports.Path = process.platform === "win32" ? PathWin32 : PathPosix;
/**
* Default {@link PathScurryBase} implementation for the current platform.
*
* {@link PathScurryWin32} on Windows systems, {@link PathScurryDarwin} on
* Darwin (macOS) systems, {@link PathScurryPosix} on all others.
*/
exports.PathScurry = process.platform === "win32" ? PathScurryWin32 : process.platform === "darwin" ? PathScurryDarwin : PathScurryPosix;
}));
//#endregion
//#region node_modules/.pnpm/glob@11.0.3/node_modules/glob/dist/commonjs/pattern.js
var require_pattern = /* @__PURE__ */ __commonJSMin(((exports) => {
Object.defineProperty(exports, "__esModule", { value: true });
exports.Pattern = void 0;
const minimatch_1$5 = require_commonjs$3();
const isPatternList = (pl) => pl.length >= 1;
const isGlobList = (gl) => gl.length >= 1;
/**
* An immutable-ish view on an array of glob parts and their parsed
* results
*/
var Pattern = class Pattern {
#patternList;
#globList;
#index;
length;
#platform;
#rest;
#globString;
#isDrive;
#isUNC;
#isAbsolute;
#followGlobstar = true;
constructor(patternList, globList, index, platform) {
if (!isPatternList(patternList)) throw new TypeError("empty pattern list");
if (!isGlobList(globList)) throw new TypeError("empty glob list");
if (globList.length !== patternList.length) throw new TypeError("mismatched pattern list and glob list lengths");
this.length = patternList.length;
if (index < 0 || index >= this.length) throw new TypeError("index out of range");
this.#patternList = patternList;
this.#globList = globList;
this.#index = index;
this.#platform = platform;
if (this.#index === 0) {
if (this.isUNC()) {
const [p0, p1, p2, p3, ...prest] = this.#patternList;
const [g0, g1, g2, g3, ...grest] = this.#globList;
if (prest[0] === "") {
prest.shift();
grest.shift();
}
const p = [
p0,
p1,
p2,
p3,
""
].join("/");
const g = [
g0,
g1,
g2,
g3,
""
].join("/");
this.#patternList = [p, ...prest];
this.#globList = [g, ...grest];
this.length = this.#patternList.length;
} else if (this.isDrive() || this.isAbsolute()) {
const [p1, ...prest] = this.#patternList;
const [g1, ...grest] = this.#globList;
if (prest[0] === "") {
prest.shift();
grest.shift();
}
const p = p1 + "/";
const g = g1 + "/";
this.#patternList = [p, ...prest];
this.#globList = [g, ...grest];
this.length = this.#patternList.length;
}
}
}
/**
* The first entry in the parsed list of patterns
*/
pattern() {
return this.#patternList[this.#index];
}
/**
* true of if pattern() returns a string
*/
isString() {
return typeof this.#patternList[this.#index] === "string";
}
/**
* true of if pattern() returns GLOBSTAR
*/
isGlobstar() {
return this.#patternList[this.#index] === minimatch_1$5.GLOBSTAR;
}
/**
* true if pattern() returns a regexp
*/
isRegExp() {
return this.#patternList[this.#index] instanceof RegExp;
}
/**
* The /-joined set of glob parts that make up this pattern
*/
globString() {
return this.#globString = this.#globString || (this.#index === 0 ? this.isAbsolute() ? this.#globList[0] + this.#globList.slice(1).join("/") : this.#globList.join("/") : this.#globList.slice(this.#index).join("/"));
}
/**
* true if there are more pattern parts after this one
*/
hasMore() {
return this.length > this.#index + 1;
}
/**
* The rest of the pattern after this part, or null if this is the end
*/
rest() {
if (this.#rest !== void 0) return this.#rest;
if (!this.hasMore()) return this.#rest = null;
this.#rest = new Pattern(this.#patternList, this.#globList, this.#index + 1, this.#platform);
this.#rest.#isAbsolute = this.#isAbsolute;
this.#rest.#isUNC = this.#isUNC;
this.#rest.#isDrive = this.#isDrive;
return this.#rest;
}
/**
* true if the pattern represents a //unc/path/ on windows
*/
isUNC() {
const pl = this.#patternList;
return this.#isUNC !== void 0 ? this.#isUNC : this.#isUNC = this.#platform === "win32" && this.#index === 0 && pl[0] === "" && pl[1] === "" && typeof pl[2] === "string" && !!pl[2] && typeof pl[3] === "string" && !!pl[3];
}
/**
* True if the pattern starts with a drive letter on Windows
*/
isDrive() {
const pl = this.#patternList;
return this.#isDrive !== void 0 ? this.#isDrive : this.#isDrive = this.#platform === "win32" && this.#index === 0 && this.length > 1 && typeof pl[0] === "string" && /^[a-z]:$/i.test(pl[0]);
}
/**
* True if the pattern is rooted on an absolute path
*/
isAbsolute() {
const pl = this.#patternList;
return this.#isAbsolute !== void 0 ? this.#isAbsolute : this.#isAbsolute = pl[0] === "" && pl.length > 1 || this.isDrive() || this.isUNC();
}
/**
* consume the root of the pattern, and return it
*/
root() {
const p = this.#patternList[0];
return typeof p === "string" && this.isAbsolute() && this.#index === 0 ? p : "";
}
/**
* Check to see if the current globstar pattern is allowed to follow
* a symbolic link.
*/
checkFollowGlobstar() {
return !(this.#index === 0 || !this.isGlobstar() || !this.#followGlobstar);
}
/**
* Mark that the current globstar pattern is following a symbolic link
*/
markFollowGlobstar() {
if (this.#index === 0 || !this.isGlobstar() || !this.#followGlobstar) return false;
this.#followGlobstar = false;
return true;
}
};
exports.Pattern = Pattern;
}));
//#endregion
//#region node_modules/.pnpm/glob@11.0.3/node_modules/glob/dist/commonjs/ignore.js
var require_ignore = /* @__PURE__ */ __commonJSMin(((exports) => {
Object.defineProperty(exports, "__esModule", { value: true });
exports.Ignore = void 0;
const minimatch_1$4 = require_commonjs$3();
const pattern_js_1$1 = require_pattern();
const defaultPlatform$1 = typeof process === "object" && process && typeof process.platform === "string" ? process.platform : "linux";
/**
* Class used to process ignored patterns
*/
var Ignore = class {
relative;
relativeChildren;
absolute;
absoluteChildren;
platform;
mmopts;
constructor(ignored, { nobrace, nocase, noext, noglobstar, platform = defaultPlatform$1 }) {
this.relative = [];
this.absolute = [];
this.relativeChildren = [];
this.absoluteChildren = [];
this.platform = platform;
this.mmopts = {
dot: true,
nobrace,
nocase,
noext,
noglobstar,
optimizationLevel: 2,
platform,
nocomment: true,
nonegate: true
};
for (const ign of ignored) this.add(ign);
}
add(ign) {
const mm = new minimatch_1$4.Minimatch(ign, this.mmopts);
for (let i = 0; i < mm.set.length; i++) {
const parsed = mm.set[i];
const globParts = mm.globParts[i];
/* c8 ignore start */
if (!parsed || !globParts) throw new Error("invalid pattern object");
while (parsed[0] === "." && globParts[0] === ".") {
parsed.shift();
globParts.shift();
}
/* c8 ignore stop */
const p = new pattern_js_1$1.Pattern(parsed, globParts, 0, this.platform);
const m = new minimatch_1$4.Minimatch(p.globString(), this.mmopts);
const children = globParts[globParts.length - 1] === "**";
const absolute = p.isAbsolute();
if (absolute) this.absolute.push(m);
else this.relative.push(m);
if (children) if (absolute) this.absoluteChildren.push(m);
else this.relativeChildren.push(m);
}
}
ignored(p) {
const fullpath = p.fullpath();
const fullpaths = `${fullpath}/`;
const relative = p.relative() || ".";
const relatives = `${relative}/`;
for (const m of this.relative) if (m.match(relative) || m.match(relatives)) return true;
for (const m of this.absolute) if (m.match(fullpath) || m.match(fullpaths)) return true;
return false;
}
childrenIgnored(p) {
const fullpath = p.fullpath() + "/";
const relative = (p.relative() || ".") + "/";
for (const m of this.relativeChildren) if (m.match(relative)) return true;
for (const m of this.absoluteChildren) if (m.match(fullpath)) return true;
return false;
}
};
exports.Ignore = Ignore;
}));
//#endregion
//#region node_modules/.pnpm/glob@11.0.3/node_modules/glob/dist/commonjs/processor.js
var require_processor = /* @__PURE__ */ __commonJSMin(((exports) => {
Object.defineProperty(exports, "__esModule", { value: true });
exports.Processor = exports.SubWalks = exports.MatchRecord = exports.HasWalkedCache = void 0;
const minimatch_1$3 = require_commonjs$3();
/**
* A cache of which patterns have been processed for a given Path
*/
var HasWalkedCache = class HasWalkedCache {
store;
constructor(store = /* @__PURE__ */ new Map()) {
this.store = store;
}
copy() {
return new HasWalkedCache(new Map(this.store));
}
hasWalked(target, pattern) {
return this.store.get(target.fullpath())?.has(pattern.globString());
}
storeWalked(target, pattern) {
const fullpath = target.fullpath();
const cached = this.store.get(fullpath);
if (cached) cached.add(pattern.globString());
else this.store.set(fullpath, new Set([pattern.globString()]));
}
};
exports.HasWalkedCache = HasWalkedCache;
/**
* A record of which paths have been matched in a given walk step,
* and whether they only are considered a match if they are a directory,
* and whether their absolute or relative path should be returned.
*/
var MatchRecord = class {
store = /* @__PURE__ */ new Map();
add(target, absolute, ifDir) {
const n = (absolute ? 2 : 0) | (ifDir ? 1 : 0);
const current = this.store.get(target);
this.store.set(target, current === void 0 ? n : n & current);
}
entries() {
return [...this.store.entries()].map(([path$1, n]) => [
path$1,
!!(n & 2),
!!(n & 1)
]);
}
};
exports.MatchRecord = MatchRecord;
/**
* A collection of patterns that must be processed in a subsequent step
* for a given path.
*/
var SubWalks = class {
store = /* @__PURE__ */ new Map();
add(target, pattern) {
if (!target.canReaddir()) return;
const subs = this.store.get(target);
if (subs) {
if (!subs.find((p) => p.globString() === pattern.globString())) subs.push(pattern);
} else this.store.set(target, [pattern]);
}
get(target) {
const subs = this.store.get(target);
/* c8 ignore start */
if (!subs) throw new Error("attempting to walk unknown path");
/* c8 ignore stop */
return subs;
}
entries() {
return this.keys().map((k) => [k, this.store.get(k)]);
}
keys() {
return [...this.store.keys()].filter((t) => t.canReaddir());
}
};
exports.SubWalks = SubWalks;
/**
* The class that processes patterns for a given path.
*
* Handles child entry filtering, and determining whether a path's
* directory contents must be read.
*/
var Processor = class Processor {
hasWalkedCache;
matches = new MatchRecord();
subwalks = new SubWalks();
patterns;
follow;
dot;
opts;
constructor(opts, hasWalkedCache) {
this.opts = opts;
this.follow = !!opts.follow;
this.dot = !!opts.dot;
this.hasWalkedCache = hasWalkedCache ? hasWalkedCache.copy() : new HasWalkedCache();
}
processPatterns(target, patterns) {
this.patterns = patterns;
const processingSet = patterns.map((p) => [target, p]);
for (let [t, pattern] of processingSet) {
this.hasWalkedCache.storeWalked(t, pattern);
const root = pattern.root();
const absolute = pattern.isAbsolute() && this.opts.absolute !== false;
if (root) {
t = t.resolve(root === "/" && this.opts.root !== void 0 ? this.opts.root : root);
const rest$1 = pattern.rest();
if (!rest$1) {
this.matches.add(t, true, false);
continue;
} else pattern = rest$1;
}
if (t.isENOENT()) continue;
let p;
let rest;
let changed = false;
while (typeof (p = pattern.pattern()) === "string" && (rest = pattern.rest())) {
t = t.resolve(p);
pattern = rest;
changed = true;
}
p = pattern.pattern();
rest = pattern.rest();
if (changed) {
if (this.hasWalkedCache.hasWalked(t, pattern)) continue;
this.hasWalkedCache.storeWalked(t, pattern);
}
if (typeof p === "string") {
const ifDir = p === ".." || p === "" || p === ".";
this.matches.add(t.resolve(p), absolute, ifDir);
continue;
} else if (p === minimatch_1$3.GLOBSTAR) {
if (!t.isSymbolicLink() || this.follow || pattern.checkFollowGlobstar()) this.subwalks.add(t, pattern);
const rp = rest?.pattern();
const rrest = rest?.rest();
if (!rest || (rp === "" || rp === ".") && !rrest) this.matches.add(t, absolute, rp === "" || rp === ".");
else if (rp === "..") {
/* c8 ignore start */
const tp = t.parent || t;
/* c8 ignore stop */
if (!rrest) this.matches.add(tp, absolute, true);
else if (!this.hasWalkedCache.hasWalked(tp, rrest)) this.subwalks.add(tp, rrest);
}
} else if (p instanceof RegExp) this.subwalks.add(t, pattern);
}
return this;
}
subwalkTargets() {
return this.subwalks.keys();
}
child() {
return new Processor(this.opts, this.hasWalkedCache);
}
filterEntries(parent, entries) {
const patterns = this.subwalks.get(parent);
const results = this.child();
for (const e of entries) for (const pattern of patterns) {
const absolute = pattern.isAbsolute();
const p = pattern.pattern();
const rest = pattern.rest();
if (p === minimatch_1$3.GLOBSTAR) results.testGlobstar(e, pattern, rest, absolute);
else if (p instanceof RegExp) results.testRegExp(e, p, rest, absolute);
else results.testString(e, p, rest, absolute);
}
return results;
}
testGlobstar(e, pattern, rest, absolute) {
if (this.dot || !e.name.startsWith(".")) {
if (!pattern.hasMore()) this.matches.add(e, absolute, false);
if (e.canReaddir()) {
if (this.follow || !e.isSymbolicLink()) this.subwalks.add(e, pattern);
else if (e.isSymbolicLink()) {
if (rest && pattern.checkFollowGlobstar()) this.subwalks.add(e, rest);
else if (pattern.markFollowGlobstar()) this.subwalks.add(e, pattern);
}
}
}
if (rest) {
const rp = rest.pattern();
if (typeof rp === "string" && rp !== ".." && rp !== "" && rp !== ".") this.testString(e, rp, rest.rest(), absolute);
else if (rp === "..") {
/* c8 ignore start */
const ep = e.parent || e;
/* c8 ignore stop */
this.subwalks.add(ep, rest);
} else if (rp instanceof RegExp) this.testRegExp(e, rp, rest.rest(), absolute);
}
}
testRegExp(e, p, rest, absolute) {
if (!p.test(e.name)) return;
if (!rest) this.matches.add(e, absolute, false);
else this.subwalks.add(e, rest);
}
testString(e, p, rest, absolute) {
if (!e.isNamed(p)) return;
if (!rest) this.matches.add(e, absolute, false);
else this.subwalks.add(e, rest);
}
};
exports.Processor = Processor;
}));
//#endregion
//#region node_modules/.pnpm/glob@11.0.3/node_modules/glob/dist/commonjs/walker.js
var require_walker = /* @__PURE__ */ __commonJSMin(((exports) => {
Object.defineProperty(exports, "__esModule", { value: true });
exports.GlobStream = exports.GlobWalker = exports.GlobUtil = void 0;
/**
* Single-use utility classes to provide functionality to the {@link Glob}
* methods.
*
* @module
*/
const minipass_1 = require_commonjs$2();
const ignore_js_1$1 = require_ignore();
const processor_js_1 = require_processor();
const makeIgnore = (ignore, opts) => typeof ignore === "string" ? new ignore_js_1$1.Ignore([ignore], opts) : Array.isArray(ignore) ? new ignore_js_1$1.Ignore(ignore, opts) : ignore;
/**
* basic walking utilities that all the glob walker types use
*/
var GlobUtil = class {
path;
patterns;
opts;
seen = /* @__PURE__ */ new Set();
paused = false;
aborted = false;
#onResume = [];
#ignore;
#sep;
signal;
maxDepth;
includeChildMatches;
constructor(patterns, path$1, opts) {
this.patterns = patterns;
this.path = path$1;
this.opts = opts;
this.#sep = !opts.posix && opts.platform === "win32" ? "\\" : "/";
this.includeChildMatches = opts.includeChildMatches !== false;
if (opts.ignore || !this.includeChildMatches) {
this.#ignore = makeIgnore(opts.ignore ?? [], opts);
if (!this.includeChildMatches && typeof this.#ignore.add !== "function") throw new Error("cannot ignore child matches, ignore lacks add() method.");
}
/* c8 ignore start */
this.maxDepth = opts.maxDepth || Infinity;
/* c8 ignore stop */
if (opts.signal) {
this.signal = opts.signal;
this.signal.addEventListener("abort", () => {
this.#onResume.length = 0;
});
}
}
#ignored(path$1) {
return this.seen.has(path$1) || !!this.#ignore?.ignored?.(path$1);
}
#childrenIgnored(path$1) {
return !!this.#ignore?.childrenIgnored?.(path$1);
}
pause() {
this.paused = true;
}
resume() {
/* c8 ignore start */
if (this.signal?.aborted) return;
/* c8 ignore stop */
this.paused = false;
let fn = void 0;
while (!this.paused && (fn = this.#onResume.shift())) fn();
}
onResume(fn) {
if (this.signal?.aborted) return;
/* c8 ignore start */
if (!this.paused) fn();
else
/* c8 ignore stop */
this.#onResume.push(fn);
}
async matchCheck(e, ifDir) {
if (ifDir && this.opts.nodir) return void 0;
let rpc;
if (this.opts.realpath) {
rpc = e.realpathCached() || await e.realpath();
if (!rpc) return void 0;
e = rpc;
}
const s = e.isUnknown() || this.opts.stat ? await e.lstat() : e;
if (this.opts.follow && this.opts.nodir && s?.isSymbolicLink()) {
const target = await s.realpath();
/* c8 ignore start */
if (target && (target.isUnknown() || this.opts.stat)) await target.lstat();
}
return this.matchCheckTest(s, ifDir);
}
matchCheckTest(e, ifDir) {
return e && (this.maxDepth === Infinity || e.depth() <= this.maxDepth) && (!ifDir || e.canReaddir()) && (!this.opts.nodir || !e.isDirectory()) && (!this.opts.nodir || !this.opts.follow || !e.isSymbolicLink() || !e.realpathCached()?.isDirectory()) && !this.#ignored(e) ? e : void 0;
}
matchCheckSync(e, ifDir) {
if (ifDir && this.opts.nodir) return void 0;
let rpc;
if (this.opts.realpath) {
rpc = e.realpathCached() || e.realpathSync();
if (!rpc) return void 0;
e = rpc;
}
const s = e.isUnknown() || this.opts.stat ? e.lstatSync() : e;
if (this.opts.follow && this.opts.nodir && s?.isSymbolicLink()) {
const target = s.realpathSync();
if (target && (target?.isUnknown() || this.opts.stat)) target.lstatSync();
}
return this.matchCheckTest(s, ifDir);
}
matchFinish(e, absolute) {
if (this.#ignored(e)) return;
if (!this.includeChildMatches && this.#ignore?.add) {
const ign = `${e.relativePosix()}/**`;
this.#ignore.add(ign);
}
const abs = this.opts.absolute === void 0 ? absolute : this.opts.absolute;
this.seen.add(e);
const mark = this.opts.mark && e.isDirectory() ? this.#sep : "";
if (this.opts.withFileTypes) this.matchEmit(e);
else if (abs) {
const abs$1 = this.opts.posix ? e.fullpathPosix() : e.fullpath();
this.matchEmit(abs$1 + mark);
} else {
const rel = this.opts.posix ? e.relativePosix() : e.relative();
const pre = this.opts.dotRelative && !rel.startsWith(".." + this.#sep) ? "." + this.#sep : "";
this.matchEmit(!rel ? "." + mark : pre + rel + mark);
}
}
async match(e, absolute, ifDir) {
const p = await this.matchCheck(e, ifDir);
if (p) this.matchFinish(p, absolute);
}
matchSync(e, absolute, ifDir) {
const p = this.matchCheckSync(e, ifDir);
if (p) this.matchFinish(p, absolute);
}
walkCB(target, patterns, cb) {
/* c8 ignore start */
if (this.signal?.aborted) cb();
/* c8 ignore stop */
this.walkCB2(target, patterns, new processor_js_1.Processor(this.opts), cb);
}
walkCB2(target, patterns, processor, cb) {
if (this.#childrenIgnored(target)) return cb();
if (this.signal?.aborted) cb();
if (this.paused) {
this.onResume(() => this.walkCB2(target, patterns, processor, cb));
return;
}
processor.processPatterns(target, patterns);
let tasks = 1;
const next = () => {
if (--tasks === 0) cb();
};
for (const [m, absolute, ifDir] of processor.matches.entries()) {
if (this.#ignored(m)) continue;
tasks++;
this.match(m, absolute, ifDir).then(() => next());
}
for (const t of processor.subwalkTargets()) {
if (this.maxDepth !== Infinity && t.depth() >= this.maxDepth) continue;
tasks++;
const childrenCached = t.readdirCached();
if (t.calledReaddir()) this.walkCB3(t, childrenCached, processor, next);
else t.readdirCB((_, entries) => this.walkCB3(t, entries, processor, next), true);
}
next();
}
walkCB3(target, entries, processor, cb) {
processor = processor.filterEntries(target, entries);
let tasks = 1;
const next = () => {
if (--tasks === 0) cb();
};
for (const [m, absolute, ifDir] of processor.matches.entries()) {
if (this.#ignored(m)) continue;
tasks++;
this.match(m, absolute, ifDir).then(() => next());
}
for (const [target$1, patterns] of processor.subwalks.entries()) {
tasks++;
this.walkCB2(target$1, patterns, processor.child(), next);
}
next();
}
walkCBSync(target, patterns, cb) {
/* c8 ignore start */
if (this.signal?.aborted) cb();
/* c8 ignore stop */
this.walkCB2Sync(target, patterns, new processor_js_1.Processor(this.opts), cb);
}
walkCB2Sync(target, patterns, processor, cb) {
if (this.#childrenIgnored(target)) return cb();
if (this.signal?.aborted) cb();
if (this.paused) {
this.onResume(() => this.walkCB2Sync(target, patterns, processor, cb));
return;
}
processor.processPatterns(target, patterns);
let tasks = 1;
const next = () => {
if (--tasks === 0) cb();
};
for (const [m, absolute, ifDir] of processor.matches.entries()) {
if (this.#ignored(m)) continue;
this.matchSync(m, absolute, ifDir);
}
for (const t of processor.subwalkTargets()) {
if (this.maxDepth !== Infinity && t.depth() >= this.maxDepth) continue;
tasks++;
const children = t.readdirSync();
this.walkCB3Sync(t, children, processor, next);
}
next();
}
walkCB3Sync(target, entries, processor, cb) {
processor = processor.filterEntries(target, entries);
let tasks = 1;
const next = () => {
if (--tasks === 0) cb();
};
for (const [m, absolute, ifDir] of processor.matches.entries()) {
if (this.#ignored(m)) continue;
this.matchSync(m, absolute, ifDir);
}
for (const [target$1, patterns] of processor.subwalks.entries()) {
tasks++;
this.walkCB2Sync(target$1, patterns, processor.child(), next);
}
next();
}
};
exports.GlobUtil = GlobUtil;
var GlobWalker = class extends GlobUtil {
matches = /* @__PURE__ */ new Set();
constructor(patterns, path$1, opts) {
super(patterns, path$1, opts);
}
matchEmit(e) {
this.matches.add(e);
}
async walk() {
if (this.signal?.aborted) throw this.signal.reason;
if (this.path.isUnknown()) await this.path.lstat();
await new Promise((res, rej) => {
this.walkCB(this.path, this.patterns, () => {
if (this.signal?.aborted) rej(this.signal.reason);
else res(this.matches);
});
});
return this.matches;
}
walkSync() {
if (this.signal?.aborted) throw this.signal.reason;
if (this.path.isUnknown()) this.path.lstatSync();
this.walkCBSync(this.path, this.patterns, () => {
if (this.signal?.aborted) throw this.signal.reason;
});
return this.matches;
}
};
exports.GlobWalker = GlobWalker;
var GlobStream = class extends GlobUtil {
results;
constructor(patterns, path$1, opts) {
super(patterns, path$1, opts);
this.results = new minipass_1.Minipass({
signal: this.signal,
objectMode: true
});
this.results.on("drain", () => this.resume());
this.results.on("resume", () => this.resume());
}
matchEmit(e) {
this.results.write(e);
if (!this.results.flowing) this.pause();
}
stream() {
const target = this.path;
if (target.isUnknown()) target.lstat().then(() => {
this.walkCB(target, this.patterns, () => this.results.end());
});
else this.walkCB(target, this.patterns, () => this.results.end());
return this.results;
}
streamSync() {
if (this.path.isUnknown()) this.path.lstatSync();
this.walkCBSync(this.path, this.patterns, () => this.results.end());
return this.results;
}
};
exports.GlobStream = GlobStream;
}));
//#endregion
//#region node_modules/.pnpm/glob@11.0.3/node_modules/glob/dist/commonjs/glob.js
var require_glob = /* @__PURE__ */ __commonJSMin(((exports) => {
Object.defineProperty(exports, "__esModule", { value: true });
exports.Glob = void 0;
const minimatch_1$2 = require_commonjs$3();
const node_url_1 = __require("node:url");
const path_scurry_1 = require_commonjs$1();
const pattern_js_1 = require_pattern();
const walker_js_1 = require_walker();
const defaultPlatform = typeof process === "object" && process && typeof process.platform === "string" ? process.platform : "linux";
/**
* An object that can perform glob pattern traversals.
*/
var Glob = class {
absolute;
cwd;
root;
dot;
dotRelative;
follow;
ignore;
magicalBraces;
mark;
matchBase;
maxDepth;
nobrace;
nocase;
nodir;
noext;
noglobstar;
pattern;
platform;
realpath;
scurry;
stat;
signal;
windowsPathsNoEscape;
withFileTypes;
includeChildMatches;
/**
* The options provided to the constructor.
*/
opts;
/**
* An array of parsed immutable {@link Pattern} objects.
*/
patterns;
/**
* All options are stored as properties on the `Glob` object.
*
* See {@link GlobOptions} for full options descriptions.
*
* Note that a previous `Glob` object can be passed as the
* `GlobOptions` to another `Glob` instantiation to re-use settings
* and caches with a new pattern.
*
* Traversal functions can be called multiple times to run the walk
* again.
*/
constructor(pattern, opts) {
/* c8 ignore start */
if (!opts) throw new TypeError("glob options required");
/* c8 ignore stop */
this.withFileTypes = !!opts.withFileTypes;
this.signal = opts.signal;
this.follow = !!opts.follow;
this.dot = !!opts.dot;
this.dotRelative = !!opts.dotRelative;
this.nodir = !!opts.nodir;
this.mark = !!opts.mark;
if (!opts.cwd) this.cwd = "";
else if (opts.cwd instanceof URL || opts.cwd.startsWith("file://")) opts.cwd = (0, node_url_1.fileURLToPath)(opts.cwd);
this.cwd = opts.cwd || "";
this.root = opts.root;
this.magicalBraces = !!opts.magicalBraces;
this.nobrace = !!opts.nobrace;
this.noext = !!opts.noext;
this.realpath = !!opts.realpath;
this.absolute = opts.absolute;
this.includeChildMatches = opts.includeChildMatches !== false;
this.noglobstar = !!opts.noglobstar;
this.matchBase = !!opts.matchBase;
this.maxDepth = typeof opts.maxDepth === "number" ? opts.maxDepth : Infinity;
this.stat = !!opts.stat;
this.ignore = opts.ignore;
if (this.withFileTypes && this.absolute !== void 0) throw new Error("cannot set absolute and withFileTypes:true");
if (typeof pattern === "string") pattern = [pattern];
this.windowsPathsNoEscape = !!opts.windowsPathsNoEscape || opts.allowWindowsEscape === false;
if (this.windowsPathsNoEscape) pattern = pattern.map((p) => p.replace(/\\/g, "/"));
if (this.matchBase) {
if (opts.noglobstar) throw new TypeError("base matching requires globstar");
pattern = pattern.map((p) => p.includes("/") ? p : `./**/${p}`);
}
this.pattern = pattern;
this.platform = opts.platform || defaultPlatform;
this.opts = {
...opts,
platform: this.platform
};
if (opts.scurry) {
this.scurry = opts.scurry;
if (opts.nocase !== void 0 && opts.nocase !== opts.scurry.nocase) throw new Error("nocase option contradicts provided scurry option");
} else this.scurry = new (opts.platform === "win32" ? path_scurry_1.PathScurryWin32 : opts.platform === "darwin" ? path_scurry_1.PathScurryDarwin : opts.platform ? path_scurry_1.PathScurryPosix : path_scurry_1.PathScurry)(this.cwd, {
nocase: opts.nocase,
fs: opts.fs
});
this.nocase = this.scurry.nocase;
const nocaseMagicOnly = this.platform === "darwin" || this.platform === "win32";
const mmo = {
...opts,
dot: this.dot,
matchBase: this.matchBase,
nobrace: this.nobrace,
nocase: this.nocase,
nocaseMagicOnly,
nocomment: true,
noext: this.noext,
nonegate: true,
optimizationLevel: 2,
platform: this.platform,
windowsPathsNoEscape: this.windowsPathsNoEscape,
debug: !!this.opts.debug
};
const [matchSet, globParts] = this.pattern.map((p) => new minimatch_1$2.Minimatch(p, mmo)).reduce((set, m) => {
set[0].push(...m.set);
set[1].push(...m.globParts);
return set;
}, [[], []]);
this.patterns = matchSet.map((set, i) => {
const g = globParts[i];
/* c8 ignore start */
if (!g) throw new Error("invalid pattern object");
/* c8 ignore stop */
return new pattern_js_1.Pattern(set, g, 0, this.platform);
});
}
async walk() {
return [...await new walker_js_1.GlobWalker(this.patterns, this.scurry.cwd, {
...this.opts,
maxDepth: this.maxDepth !== Infinity ? this.maxDepth + this.scurry.cwd.depth() : Infinity,
platform: this.platform,
nocase: this.nocase,
includeChildMatches: this.includeChildMatches
}).walk()];
}
walkSync() {
return [...new walker_js_1.GlobWalker(this.patterns, this.scurry.cwd, {
...this.opts,
maxDepth: this.maxDepth !== Infinity ? this.maxDepth + this.scurry.cwd.depth() : Infinity,
platform: this.platform,
nocase: this.nocase,
includeChildMatches: this.includeChildMatches
}).walkSync()];
}
stream() {
return new walker_js_1.GlobStream(this.patterns, this.scurry.cwd, {
...this.opts,
maxDepth: this.maxDepth !== Infinity ? this.maxDepth + this.scurry.cwd.depth() : Infinity,
platform: this.platform,
nocase: this.nocase,
includeChildMatches: this.includeChildMatches
}).stream();
}
streamSync() {
return new walker_js_1.GlobStream(this.patterns, this.scurry.cwd, {
...this.opts,
maxDepth: this.maxDepth !== Infinity ? this.maxDepth + this.scurry.cwd.depth() : Infinity,
platform: this.platform,
nocase: this.nocase,
includeChildMatches: this.includeChildMatches
}).streamSync();
}
/**
* Default sync iteration function. Returns a Generator that
* iterates over the results.
*/
iterateSync() {
return this.streamSync()[Symbol.iterator]();
}
[Symbol.iterator]() {
return this.iterateSync();
}
/**
* Default async iteration function. Returns an AsyncGenerator that
* iterates over the results.
*/
iterate() {
return this.stream()[Symbol.asyncIterator]();
}
[Symbol.asyncIterator]() {
return this.iterate();
}
};
exports.Glob = Glob;
}));
//#endregion
//#region node_modules/.pnpm/glob@11.0.3/node_modules/glob/dist/commonjs/has-magic.js
var require_has_magic = /* @__PURE__ */ __commonJSMin(((exports) => {
Object.defineProperty(exports, "__esModule", { value: true });
exports.hasMagic = void 0;
const minimatch_1$1 = require_commonjs$3();
/**
* Return true if the patterns provided contain any magic glob characters,
* given the options provided.
*
* Brace expansion is not considered "magic" unless the `magicalBraces` option
* is set, as brace expansion just turns one string into an array of strings.
* So a pattern like `'x{a,b}y'` would return `false`, because `'xay'` and
* `'xby'` both do not contain any magic glob characters, and it's treated the
* same as if you had called it on `['xay', 'xby']`. When `magicalBraces:true`
* is in the options, brace expansion _is_ treated as a pattern having magic.
*/
const hasMagic = (pattern, options = {}) => {
if (!Array.isArray(pattern)) pattern = [pattern];
for (const p of pattern) if (new minimatch_1$1.Minimatch(p, options).hasMagic()) return true;
return false;
};
exports.hasMagic = hasMagic;
}));
//#endregion
//#region node_modules/.pnpm/glob@11.0.3/node_modules/glob/dist/commonjs/index.js
var require_commonjs = /* @__PURE__ */ __commonJSMin(((exports) => {
Object.defineProperty(exports, "__esModule", { value: true });
exports.glob = exports.sync = exports.iterate = exports.iterateSync = exports.stream = exports.streamSync = exports.Ignore = exports.hasMagic = exports.Glob = exports.unescape = exports.escape = void 0;
exports.globStreamSync = globStreamSync;
exports.globStream = globStream;
exports.globSync = globSync;
exports.globIterateSync = globIterateSync;
exports.globIterate = globIterate;
const minimatch_1 = require_commonjs$3();
const glob_js_1 = require_glob();
const has_magic_js_1 = require_has_magic();
var minimatch_2 = require_commonjs$3();
Object.defineProperty(exports, "escape", {
enumerable: true,
get: function() {
return minimatch_2.escape;
}
});
Object.defineProperty(exports, "unescape", {
enumerable: true,
get: function() {
return minimatch_2.unescape;
}
});
var glob_js_2 = require_glob();
Object.defineProperty(exports, "Glob", {
enumerable: true,
get: function() {
return glob_js_2.Glob;
}
});
var has_magic_js_2 = require_has_magic();
Object.defineProperty(exports, "hasMagic", {
enumerable: true,
get: function() {
return has_magic_js_2.hasMagic;
}
});
var ignore_js_1 = require_ignore();
Object.defineProperty(exports, "Ignore", {
enumerable: true,
get: function() {
return ignore_js_1.Ignore;
}
});
function globStreamSync(pattern, options = {}) {
return new glob_js_1.Glob(pattern, options).streamSync();
}
function globStream(pattern, options = {}) {
return new glob_js_1.Glob(pattern, options).stream();
}
function globSync(pattern, options = {}) {
return new glob_js_1.Glob(pattern, options).walkSync();
}
async function glob_(pattern, options = {}) {
return new glob_js_1.Glob(pattern, options).walk();
}
function globIterateSync(pattern, options = {}) {
return new glob_js_1.Glob(pattern, options).iterateSync();
}
function globIterate(pattern, options = {}) {
return new glob_js_1.Glob(pattern, options).iterate();
}
exports.streamSync = globStreamSync;
exports.stream = Object.assign(globStream, { sync: globStreamSync });
exports.iterateSync = globIterateSync;
exports.iterate = Object.assign(globIterate, { sync: globIterateSync });
exports.sync = Object.assign(globSync, {
stream: globStreamSync,
iterate: globIterateSync
});
exports.glob = Object.assign(glob_, {
glob: glob_,
globSync,
sync: exports.sync,
globStream,
stream: exports.stream,
globStreamSync,
streamSync: exports.streamSync,
globIterate,
iterate: exports.iterate,
globIterateSync,
iterateSync: exports.iterateSync,
Glob: glob_js_1.Glob,
hasMagic: has_magic_js_1.hasMagic,
escape: minimatch_1.escape,
unescape: minimatch_1.unescape
});
exports.glob.glob = exports.glob;
}));
//#endregion
//#region node_modules/.pnpm/err-code@2.0.3/node_modules/err-code/index.js
var require_err_code = /* @__PURE__ */ __commonJSMin(((exports, module) => {
function assign(obj, props) {
for (const key in props) Object.defineProperty(obj, key, {
value: props[key],
enumerable: true,
configurable: true
});
return obj;
}
function createError(err, code, props) {
if (!err || typeof err === "string") throw new TypeError("Please pass an Error to err-code");
if (!props) props = {};
if (typeof code === "object") {
props = code;
code = void 0;
}
if (code != null) props.code = code;
try {
return assign(err, props);
} catch (_) {
props.message = err.message;
props.stack = err.stack;
const ErrClass = function() {};
ErrClass.prototype = Object.create(Object.getPrototypeOf(err));
return assign(new ErrClass(), props);
}
}
module.exports = createError;
}));
//#endregion
//#region node_modules/.pnpm/retry@0.12.0/node_modules/retry/lib/retry_operation.js
var require_retry_operation = /* @__PURE__ */ __commonJSMin(((exports, module) => {
function RetryOperation$1(timeouts, options) {
if (typeof options === "boolean") options = { forever: options };
this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
this._timeouts = timeouts;
this._options = options || {};
this._maxRetryTime = options && options.maxRetryTime || Infinity;
this._fn = null;
this._errors = [];
this._attempts = 1;
this._operationTimeout = null;
this._operationTimeoutCb = null;
this._timeout = null;
this._operationStart = null;
if (this._options.forever) this._cachedTimeouts = this._timeouts.slice(0);
}
module.exports = RetryOperation$1;
RetryOperation$1.prototype.reset = function() {
this._attempts = 1;
this._timeouts = this._originalTimeouts;
};
RetryOperation$1.prototype.stop = function() {
if (this._timeout) clearTimeout(this._timeout);
this._timeouts = [];
this._cachedTimeouts = null;
};
RetryOperation$1.prototype.retry = function(err) {
if (this._timeout) clearTimeout(this._timeout);
if (!err) return false;
var currentTime = (/* @__PURE__ */ new Date()).getTime();
if (err && currentTime - this._operationStart >= this._maxRetryTime) {
this._errors.unshift(/* @__PURE__ */ new Error("RetryOperation timeout occurred"));
return false;
}
this._errors.push(err);
var timeout = this._timeouts.shift();
if (timeout === void 0) if (this._cachedTimeouts) {
this._errors.splice(this._errors.length - 1, this._errors.length);
this._timeouts = this._cachedTimeouts.slice(0);
timeout = this._timeouts.shift();
} else return false;
var self = this;
var timer = setTimeout(function() {
self._attempts++;
if (self._operationTimeoutCb) {
self._timeout = setTimeout(function() {
self._operationTimeoutCb(self._attempts);
}, self._operationTimeout);
if (self._options.unref) self._timeout.unref();
}
self._fn(self._attempts);
}, timeout);
if (this._options.unref) timer.unref();
return true;
};
RetryOperation$1.prototype.attempt = function(fn, timeoutOps) {
this._fn = fn;
if (timeoutOps) {
if (timeoutOps.timeout) this._operationTimeout = timeoutOps.timeout;
if (timeoutOps.cb) this._operationTimeoutCb = timeoutOps.cb;
}
var self = this;
if (this._operationTimeoutCb) this._timeout = setTimeout(function() {
self._operationTimeoutCb();
}, self._operationTimeout);
this._operationStart = (/* @__PURE__ */ new Date()).getTime();
this._fn(this._attempts);
};
RetryOperation$1.prototype.try = function(fn) {
console.log("Using RetryOperation.try() is deprecated");
this.attempt(fn);
};
RetryOperation$1.prototype.start = function(fn) {
console.log("Using RetryOperation.start() is deprecated");
this.attempt(fn);
};
RetryOperation$1.prototype.start = RetryOperation$1.prototype.try;
RetryOperation$1.prototype.errors = function() {
return this._errors;
};
RetryOperation$1.prototype.attempts = function() {
return this._attempts;
};
RetryOperation$1.prototype.mainError = function() {
if (this._errors.length === 0) return null;
var counts = {};
var mainError = null;
var mainErrorCount = 0;
for (var i = 0; i < this._errors.length; i++) {
var error = this._errors[i];
var message = error.message;
var count = (counts[message] || 0) + 1;
counts[message] = count;
if (count >= mainErrorCount) {
mainError = error;
mainErrorCount = count;
}
}
return mainError;
};
}));
//#endregion
//#region node_modules/.pnpm/retry@0.12.0/node_modules/retry/lib/retry.js
var require_retry$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
var RetryOperation = require_retry_operation();
exports.operation = function(options) {
return new RetryOperation(exports.timeouts(options), {
forever: options && options.forever,
unref: options && options.unref,
maxRetryTime: options && options.maxRetryTime
});
};
exports.timeouts = function(options) {
if (options instanceof Array) return [].concat(options);
var opts = {
retries: 10,
factor: 2,
minTimeout: 1 * 1e3,
maxTimeout: Infinity,
randomize: false
};
for (var key in options) opts[key] = options[key];
if (opts.minTimeout > opts.maxTimeout) throw new Error("minTimeout is greater than maxTimeout");
var timeouts = [];
for (var i = 0; i < opts.retries; i++) timeouts.push(this.createTimeout(i, opts));
if (options && options.forever && !timeouts.length) timeouts.push(this.createTimeout(i, opts));
timeouts.sort(function(a, b) {
return a - b;
});
return timeouts;
};
exports.createTimeout = function(attempt, opts) {
var random = opts.randomize ? Math.random() + 1 : 1;
var timeout = Math.round(random * opts.minTimeout * Math.pow(opts.factor, attempt));
timeout = Math.min(timeout, opts.maxTimeout);
return timeout;
};
exports.wrap = function(obj, options, methods) {
if (options instanceof Array) {
methods = options;
options = null;
}
if (!methods) {
methods = [];
for (var key in obj) if (typeof obj[key] === "function") methods.push(key);
}
for (var i = 0; i < methods.length; i++) {
var method = methods[i];
var original = obj[method];
obj[method] = function retryWrapper(original$1) {
var op = exports.operation(options);
var args = Array.prototype.slice.call(arguments, 1);
var callback = args.pop();
args.push(function(err) {
if (op.retry(err)) return;
if (err) arguments[0] = op.mainError();
callback.apply(this, arguments);
});
op.attempt(function() {
original$1.apply(obj, args);
});
}.bind(obj, original);
obj[method].options = options;
}
};
}));
//#endregion
//#region node_modules/.pnpm/retry@0.12.0/node_modules/retry/index.js
var require_retry = /* @__PURE__ */ __commonJSMin(((exports, module) => {
module.exports = require_retry$1();
}));
//#endregion
//#region node_modules/.pnpm/promise-retry@2.0.1/node_modules/promise-retry/index.js
var require_promise_retry = /* @__PURE__ */ __commonJSMin(((exports, module) => {
var errcode = require_err_code();
var retry = require_retry();
var hasOwn = Object.prototype.hasOwnProperty;
function isRetryError(err) {
return err && err.code === "EPROMISERETRY" && hasOwn.call(err, "retried");
}
function promiseRetry(fn, options) {
var temp;
var operation;
if (typeof fn === "object" && typeof options === "function") {
temp = options;
options = fn;
fn = temp;
}
operation = retry.operation(options);
return new Promise(function(resolve, reject) {
operation.attempt(function(number) {
Promise.resolve().then(function() {
return fn(function(err) {
if (isRetryError(err)) err = err.retried;
throw errcode(/* @__PURE__ */ new Error("Retrying"), "EPROMISERETRY", { retried: err });
}, number);
}).then(resolve, function(err) {
if (isRetryError(err)) {
err = err.retried;
if (operation.retry(err || /* @__PURE__ */ new Error())) return;
}
reject(err);
});
});
});
}
module.exports = promiseRetry;
}));
//#endregion
export { require_lib as a, require_commonjs$3 as i, require_commonjs as n, require_commonjs$2 as r, require_promise_retry as t };