UNPKG

@socketsecurity/lib

Version:

Core utilities and infrastructure for Socket.dev security tools

1,368 lines (1,353 loc) 2.5 MB
"use strict"; /** * Bundled from libnpmpack * This is a zero-dependency bundle created by esbuild. */ "use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); var __esm = (fn, res) => function __init() { return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; }; var __commonJS = (cb, mod) => function __require() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); // node_modules/.pnpm/json-parse-even-better-errors@4.0.0/node_modules/json-parse-even-better-errors/lib/index.js var require_lib = __commonJS({ "node_modules/.pnpm/json-parse-even-better-errors@4.0.0/node_modules/json-parse-even-better-errors/lib/index.js"(exports2, module2) { "use strict"; var INDENT = Symbol.for("indent"); var NEWLINE = Symbol.for("newline"); var DEFAULT_NEWLINE = "\n"; var DEFAULT_INDENT = " "; var BOM = /^\uFEFF/; var FORMAT = /^\s*[{[]((?:\r?\n)+)([\s\t]*)/; var EMPTY = /^(?:\{\}|\[\])((?:\r?\n)+)?$/; var UNEXPECTED_TOKEN = /^Unexpected token '?(.)'?(,)? /i; var hexify = /* @__PURE__ */ __name((char) => { const h = char.charCodeAt(0).toString(16).toUpperCase(); return `0x${h.length % 2 ? "0" : ""}${h}`; }, "hexify"); var stripBOM = /* @__PURE__ */ __name((txt) => String(txt).replace(BOM, ""), "stripBOM"); var makeParsedError = /* @__PURE__ */ __name((msg, parsing, position = 0) => ({ message: `${msg} while parsing ${parsing}`, position }), "makeParsedError"); var parseError = /* @__PURE__ */ __name((e, txt, context = 20) => { let msg = e.message; if (!txt) { return makeParsedError(msg, "empty string"); } const badTokenMatch = msg.match(UNEXPECTED_TOKEN); const badIndexMatch = msg.match(/ position\s+(\d+)/i); if (badTokenMatch) { msg = msg.replace( UNEXPECTED_TOKEN, `Unexpected token ${JSON.stringify(badTokenMatch[1])} (${hexify(badTokenMatch[1])})$2 ` ); } let errIdx; if (badIndexMatch) { errIdx = +badIndexMatch[1]; } else if (msg.match(/^Unexpected end of JSON.*/i)) { errIdx = txt.length - 1; } if (errIdx == null) { return makeParsedError(msg, `'${txt.slice(0, context * 2)}'`); } const start = errIdx <= context ? 0 : errIdx - context; const end = errIdx + context >= txt.length ? txt.length : errIdx + context; const slice = `${start ? "..." : ""}${txt.slice(start, end)}${end === txt.length ? "" : "..."}`; return makeParsedError( msg, `${txt === slice ? "" : "near "}${JSON.stringify(slice)}`, errIdx ); }, "parseError"); var JSONParseError = class extends SyntaxError { static { __name(this, "JSONParseError"); } constructor(er, txt, context, caller) { const metadata = parseError(er, txt, context); super(metadata.message); Object.assign(this, metadata); this.code = "EJSONPARSE"; this.systemError = er; Error.captureStackTrace(this, caller || this.constructor); } get name() { return this.constructor.name; } set name(n) { } get [Symbol.toStringTag]() { return this.constructor.name; } }; var parseJson = /* @__PURE__ */ __name((txt, reviver) => { const result = JSON.parse(txt, reviver); if (result && typeof result === "object") { const match = txt.match(EMPTY) || txt.match(FORMAT) || [null, "", ""]; result[NEWLINE] = match[1] ?? DEFAULT_NEWLINE; result[INDENT] = match[2] ?? DEFAULT_INDENT; } return result; }, "parseJson"); var parseJsonError = /* @__PURE__ */ __name((raw, reviver, context) => { const txt = stripBOM(raw); try { return parseJson(txt, reviver); } catch (e) { if (typeof raw !== "string" && !Buffer.isBuffer(raw)) { const msg = Array.isArray(raw) && raw.length === 0 ? "an empty array" : String(raw); throw Object.assign( new TypeError(`Cannot parse ${msg}`), { code: "EJSONPARSE", systemError: e } ); } throw new JSONParseError(e, txt, context, parseJsonError); } }, "parseJsonError"); module2.exports = parseJsonError; parseJsonError.JSONParseError = JSONParseError; parseJsonError.noExceptions = (raw, reviver) => { try { return parseJson(stripBOM(raw), reviver); } catch { } }; } }); // node_modules/.pnpm/@npmcli+package-json@7.0.0/node_modules/@npmcli/package-json/lib/update-dependencies.js var require_update_dependencies = __commonJS({ "node_modules/.pnpm/@npmcli+package-json@7.0.0/node_modules/@npmcli/package-json/lib/update-dependencies.js"(exports2, module2) { var depTypes = /* @__PURE__ */ new Set([ "dependencies", "optionalDependencies", "devDependencies", "peerDependencies" ]); var orderDeps = /* @__PURE__ */ __name((content) => { for (const type of depTypes) { if (content && content[type]) { content[type] = Object.keys(content[type]).sort((a, b) => a.localeCompare(b, "en")).reduce((res, key) => { res[key] = content[type][key]; return res; }, {}); } } return content; }, "orderDeps"); var updateDependencies = /* @__PURE__ */ __name(({ content, originalContent }) => { const pkg = orderDeps({ ...content }); if (pkg.dependencies) { if (pkg.optionalDependencies) { for (const name of Object.keys(pkg.optionalDependencies)) { delete pkg.dependencies[name]; } } } const result = { ...originalContent }; for (const type of depTypes) { if (pkg[type]) { result[type] = pkg[type]; } const emptyDepType = pkg[type] && typeof pkg === "object" && Object.keys(pkg[type]).length === 0; if (emptyDepType) { delete result[type]; } } const { dependencies: origProd, peerDependencies: origPeer } = originalContent || {}; const { peerDependencies: newPeer } = result; if (origProd && origPeer && newPeer) { for (const name of Object.keys(origPeer)) { if (origProd[name] !== void 0 && newPeer[name] !== void 0) { result.dependencies = result.dependencies || {}; result.dependencies[name] = newPeer[name]; } } } return result; }, "updateDependencies"); updateDependencies.knownKeys = depTypes; module2.exports = updateDependencies; } }); // node_modules/.pnpm/@npmcli+package-json@7.0.0/node_modules/@npmcli/package-json/lib/update-scripts.js var require_update_scripts = __commonJS({ "node_modules/.pnpm/@npmcli+package-json@7.0.0/node_modules/@npmcli/package-json/lib/update-scripts.js"(exports2, module2) { var updateScripts = /* @__PURE__ */ __name(({ content, originalContent = {} }) => { const newScripts = content.scripts; if (!newScripts) { return originalContent; } const hasInvalidScripts = /* @__PURE__ */ __name(() => Object.entries(newScripts).some(([key, value]) => typeof key !== "string" || typeof value !== "string"), "hasInvalidScripts"); if (hasInvalidScripts()) { throw Object.assign( new TypeError( "package.json scripts should be a key-value pair of strings." ), { code: "ESCRIPTSINVALID" } ); } return { ...originalContent, scripts: { ...newScripts } }; }, "updateScripts"); module2.exports = updateScripts; } }); // node_modules/.pnpm/@npmcli+package-json@7.0.0/node_modules/@npmcli/package-json/lib/update-workspaces.js var require_update_workspaces = __commonJS({ "node_modules/.pnpm/@npmcli+package-json@7.0.0/node_modules/@npmcli/package-json/lib/update-workspaces.js"(exports2, module2) { var updateWorkspaces = /* @__PURE__ */ __name(({ content, originalContent = {} }) => { const newWorkspaces = content.workspaces; if (!newWorkspaces) { return originalContent; } const hasInvalidWorkspaces = /* @__PURE__ */ __name(() => newWorkspaces.some((w) => !(typeof w === "string")), "hasInvalidWorkspaces"); if (!newWorkspaces.length || hasInvalidWorkspaces()) { throw Object.assign( new TypeError("workspaces should be an array of strings."), { code: "EWORKSPACESINVALID" } ); } return { ...originalContent, workspaces: [ ...newWorkspaces ] }; }, "updateWorkspaces"); module2.exports = updateWorkspaces; } }); // node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/debug.js var require_debug = __commonJS({ "node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/debug.js"(exports2, module2) { "use strict"; var debug = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => void 0 : () => { }; module2.exports = debug; } }); // node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/constants.js var require_constants = __commonJS({ "node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/constants.js"(exports2, module2) { "use strict"; var SEMVER_SPEC_VERSION = "2.0.0"; var MAX_LENGTH = 256; var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */ 9007199254740991; var MAX_SAFE_COMPONENT_LENGTH = 16; var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6; var RELEASE_TYPES = [ "major", "premajor", "minor", "preminor", "patch", "prepatch", "prerelease" ]; module2.exports = { MAX_LENGTH, MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_BUILD_LENGTH, MAX_SAFE_INTEGER, RELEASE_TYPES, SEMVER_SPEC_VERSION, FLAG_INCLUDE_PRERELEASE: 1, FLAG_LOOSE: 2 }; } }); // node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/re.js var require_re = __commonJS({ "node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/re.js"(exports2, module2) { "use strict"; var { MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_BUILD_LENGTH, MAX_LENGTH } = require_constants(); var debug = require_debug(); exports2 = module2.exports = {}; var re = exports2.re = []; var safeRe = exports2.safeRe = []; var src = exports2.src = []; var safeSrc = exports2.safeSrc = []; var t = exports2.t = {}; var R = 0; var LETTERDASHNUMBER = "[a-zA-Z0-9-]"; var safeRegexReplacements = [ ["\\s", 1], ["\\d", MAX_LENGTH], [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH] ]; var makeSafeRegex = /* @__PURE__ */ __name((value) => { for (const [token, max] of safeRegexReplacements) { value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`); } return value; }, "makeSafeRegex"); var createToken = /* @__PURE__ */ __name((name, value, isGlobal) => { const safe = makeSafeRegex(value); const index = R++; debug(name, index, value); t[name] = index; src[index] = value; safeSrc[index] = safe; re[index] = new RegExp(value, isGlobal ? "g" : void 0); safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0); }, "createToken"); createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*"); createToken("NUMERICIDENTIFIERLOOSE", "\\d+"); createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`); createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`); createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`); createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`); createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`); createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`); createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`); createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`); createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`); createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`); createToken("FULL", `^${src[t.FULLPLAIN]}$`); createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`); createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`); createToken("GTLT", "((?:<|>)?=?)"); createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`); createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`); createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`); createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`); createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`); createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`); createToken("COERCEPLAIN", `${"(^|[^\\d])(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`); createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`); createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`); createToken("COERCERTL", src[t.COERCE], true); createToken("COERCERTLFULL", src[t.COERCEFULL], true); createToken("LONETILDE", "(?:~>?)"); createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true); exports2.tildeTrimReplace = "$1~"; createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`); createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`); createToken("LONECARET", "(?:\\^)"); createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true); exports2.caretTrimReplace = "$1^"; createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`); createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`); createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`); createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`); createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true); exports2.comparatorTrimReplace = "$1$2$3"; createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`); createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`); createToken("STAR", "(<|>)?=?\\s*\\*"); createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$"); createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$"); } }); // node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/parse-options.js var require_parse_options = __commonJS({ "node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/parse-options.js"(exports2, module2) { "use strict"; var looseOption = Object.freeze({ loose: true }); var emptyOpts = Object.freeze({}); var parseOptions = /* @__PURE__ */ __name((options) => { if (!options) { return emptyOpts; } if (typeof options !== "object") { return looseOption; } return options; }, "parseOptions"); module2.exports = parseOptions; } }); // node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/identifiers.js var require_identifiers = __commonJS({ "node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/identifiers.js"(exports2, module2) { "use strict"; var numeric = /^[0-9]+$/; var compareIdentifiers = /* @__PURE__ */ __name((a, b) => { const anum = numeric.test(a); const bnum = numeric.test(b); if (anum && bnum) { a = +a; b = +b; } return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1; }, "compareIdentifiers"); var rcompareIdentifiers = /* @__PURE__ */ __name((a, b) => compareIdentifiers(b, a), "rcompareIdentifiers"); module2.exports = { compareIdentifiers, rcompareIdentifiers }; } }); // node_modules/.pnpm/semver@7.7.2/node_modules/semver/classes/semver.js var require_semver = __commonJS({ "node_modules/.pnpm/semver@7.7.2/node_modules/semver/classes/semver.js"(exports2, module2) { "use strict"; var debug = require_debug(); var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants(); var { safeRe: re, t } = require_re(); var parseOptions = require_parse_options(); var { compareIdentifiers } = require_identifiers(); var SemVer = class _SemVer { static { __name(this, "SemVer"); } constructor(version, options) { options = parseOptions(options); if (version instanceof _SemVer) { if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) { return version; } else { version = version.version; } } else if (typeof version !== "string") { throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`); } if (version.length > MAX_LENGTH) { throw new TypeError( `version is longer than ${MAX_LENGTH} characters` ); } debug("SemVer", version, options); this.options = options; this.loose = !!options.loose; this.includePrerelease = !!options.includePrerelease; const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]); if (!m) { throw new TypeError(`Invalid Version: ${version}`); } this.raw = version; this.major = +m[1]; this.minor = +m[2]; this.patch = +m[3]; if (this.major > MAX_SAFE_INTEGER || this.major < 0) { throw new TypeError("Invalid major version"); } if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { throw new TypeError("Invalid minor version"); } if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { throw new TypeError("Invalid patch version"); } if (!m[4]) { this.prerelease = []; } else { this.prerelease = m[4].split(".").map((id) => { if (/^[0-9]+$/.test(id)) { const num = +id; if (num >= 0 && num < MAX_SAFE_INTEGER) { return num; } } return id; }); } this.build = m[5] ? m[5].split(".") : []; this.format(); } format() { this.version = `${this.major}.${this.minor}.${this.patch}`; if (this.prerelease.length) { this.version += `-${this.prerelease.join(".")}`; } return this.version; } toString() { return this.version; } compare(other) { debug("SemVer.compare", this.version, this.options, other); if (!(other instanceof _SemVer)) { if (typeof other === "string" && other === this.version) { return 0; } other = new _SemVer(other, this.options); } if (other.version === this.version) { return 0; } return this.compareMain(other) || this.comparePre(other); } compareMain(other) { if (!(other instanceof _SemVer)) { other = new _SemVer(other, this.options); } return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch); } comparePre(other) { if (!(other instanceof _SemVer)) { other = new _SemVer(other, this.options); } if (this.prerelease.length && !other.prerelease.length) { return -1; } else if (!this.prerelease.length && other.prerelease.length) { return 1; } else if (!this.prerelease.length && !other.prerelease.length) { return 0; } let i = 0; do { const a = this.prerelease[i]; const b = other.prerelease[i]; debug("prerelease compare", i, a, b); if (a === void 0 && b === void 0) { return 0; } else if (b === void 0) { return 1; } else if (a === void 0) { return -1; } else if (a === b) { continue; } else { return compareIdentifiers(a, b); } } while (++i); } compareBuild(other) { if (!(other instanceof _SemVer)) { other = new _SemVer(other, this.options); } let i = 0; do { const a = this.build[i]; const b = other.build[i]; debug("build compare", i, a, b); if (a === void 0 && b === void 0) { return 0; } else if (b === void 0) { return 1; } else if (a === void 0) { return -1; } else if (a === b) { continue; } else { return compareIdentifiers(a, b); } } while (++i); } // preminor will bump the version up to the next minor release, and immediately // down to pre-release. premajor and prepatch work the same way. inc(release, identifier, identifierBase) { if (release.startsWith("pre")) { if (!identifier && identifierBase === false) { throw new Error("invalid increment argument: identifier is empty"); } if (identifier) { const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]); if (!match || match[1] !== identifier) { throw new Error(`invalid identifier: ${identifier}`); } } } switch (release) { case "premajor": this.prerelease.length = 0; this.patch = 0; this.minor = 0; this.major++; this.inc("pre", identifier, identifierBase); break; case "preminor": this.prerelease.length = 0; this.patch = 0; this.minor++; this.inc("pre", identifier, identifierBase); break; case "prepatch": this.prerelease.length = 0; this.inc("patch", identifier, identifierBase); this.inc("pre", identifier, identifierBase); break; // If the input is a non-prerelease version, this acts the same as // prepatch. case "prerelease": if (this.prerelease.length === 0) { this.inc("patch", identifier, identifierBase); } this.inc("pre", identifier, identifierBase); break; case "release": if (this.prerelease.length === 0) { throw new Error(`version ${this.raw} is not a prerelease`); } this.prerelease.length = 0; break; case "major": if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) { this.major++; } this.minor = 0; this.patch = 0; this.prerelease = []; break; case "minor": if (this.patch !== 0 || this.prerelease.length === 0) { this.minor++; } this.patch = 0; this.prerelease = []; break; case "patch": if (this.prerelease.length === 0) { this.patch++; } this.prerelease = []; break; // This probably shouldn't be used publicly. // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction. case "pre": { const base = Number(identifierBase) ? 1 : 0; if (this.prerelease.length === 0) { this.prerelease = [base]; } else { let i = this.prerelease.length; while (--i >= 0) { if (typeof this.prerelease[i] === "number") { this.prerelease[i]++; i = -2; } } if (i === -1) { if (identifier === this.prerelease.join(".") && identifierBase === false) { throw new Error("invalid increment argument: identifier already exists"); } this.prerelease.push(base); } } if (identifier) { let prerelease = [identifier, base]; if (identifierBase === false) { prerelease = [identifier]; } if (compareIdentifiers(this.prerelease[0], identifier) === 0) { if (isNaN(this.prerelease[1])) { this.prerelease = prerelease; } } else { this.prerelease = prerelease; } } break; } default: throw new Error(`invalid increment argument: ${release}`); } this.raw = this.format(); if (this.build.length) { this.raw += `+${this.build.join(".")}`; } return this; } }; module2.exports = SemVer; } }); // node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/parse.js var require_parse = __commonJS({ "node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/parse.js"(exports2, module2) { "use strict"; var SemVer = require_semver(); var parse = /* @__PURE__ */ __name((version, options, throwErrors = false) => { if (version instanceof SemVer) { return version; } try { return new SemVer(version, options); } catch (er) { if (!throwErrors) { return null; } throw er; } }, "parse"); module2.exports = parse; } }); // node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/valid.js var require_valid = __commonJS({ "node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/valid.js"(exports2, module2) { "use strict"; var parse = require_parse(); var valid = /* @__PURE__ */ __name((version, options) => { const v = parse(version, options); return v ? v.version : null; }, "valid"); module2.exports = valid; } }); // node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/clean.js var require_clean = __commonJS({ "node_modules/.pnpm/semver@7.7.2/node_modules/semver/functions/clean.js"(exports2, module2) { "use strict"; var parse = require_parse(); var clean = /* @__PURE__ */ __name((version, options) => { const s = parse(version.trim().replace(/^[=v]+/, ""), options); return s ? s.version : null; }, "clean"); module2.exports = clean; } }); // node_modules/.pnpm/proc-log@5.0.0/node_modules/proc-log/lib/index.js var require_lib2 = __commonJS({ "node_modules/.pnpm/proc-log@5.0.0/node_modules/proc-log/lib/index.js"(exports2, module2) { var META = Symbol("proc-log.meta"); module2.exports = { META, output: { LEVELS: [ "standard", "error", "buffer", "flush" ], KEYS: { standard: "standard", error: "error", buffer: "buffer", flush: "flush" }, standard: /* @__PURE__ */ __name(function(...args) { return process.emit("output", "standard", ...args); }, "standard"), error: /* @__PURE__ */ __name(function(...args) { return process.emit("output", "error", ...args); }, "error"), buffer: /* @__PURE__ */ __name(function(...args) { return process.emit("output", "buffer", ...args); }, "buffer"), flush: /* @__PURE__ */ __name(function(...args) { return process.emit("output", "flush", ...args); }, "flush") }, 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: /* @__PURE__ */ __name(function(...args) { return process.emit("log", "error", ...args); }, "error"), notice: /* @__PURE__ */ __name(function(...args) { return process.emit("log", "notice", ...args); }, "notice"), warn: /* @__PURE__ */ __name(function(...args) { return process.emit("log", "warn", ...args); }, "warn"), info: /* @__PURE__ */ __name(function(...args) { return process.emit("log", "info", ...args); }, "info"), verbose: /* @__PURE__ */ __name(function(...args) { return process.emit("log", "verbose", ...args); }, "verbose"), http: /* @__PURE__ */ __name(function(...args) { return process.emit("log", "http", ...args); }, "http"), silly: /* @__PURE__ */ __name(function(...args) { return process.emit("log", "silly", ...args); }, "silly"), timing: /* @__PURE__ */ __name(function(...args) { return process.emit("log", "timing", ...args); }, "timing"), pause: /* @__PURE__ */ __name(function() { return process.emit("log", "pause"); }, "pause"), resume: /* @__PURE__ */ __name(function() { return process.emit("log", "resume"); }, "resume") }, time: { LEVELS: [ "start", "end" ], KEYS: { start: "start", end: "end" }, start: /* @__PURE__ */ __name(function(name, fn) { process.emit("time", "start", name); function end() { return process.emit("time", "end", name); } __name(end, "end"); if (typeof fn === "function") { const res = fn(); if (res && res.finally) { return res.finally(end); } end(); return res; } return end; }, "start"), end: /* @__PURE__ */ __name(function(name) { return process.emit("time", "end", name); }, "end") }, input: { LEVELS: [ "start", "end", "read" ], KEYS: { start: "start", end: "end", read: "read" }, start: /* @__PURE__ */ __name(function(fn) { process.emit("input", "start"); function end() { return process.emit("input", "end"); } __name(end, "end"); if (typeof fn === "function") { const res = fn(); if (res && res.finally) { return res.finally(end); } end(); return res; } return end; }, "start"), end: /* @__PURE__ */ __name(function() { return process.emit("input", "end"); }, "end"), read: /* @__PURE__ */ __name(function(...args) { let resolve, reject; const promise = new Promise((_resolve, _reject) => { resolve = _resolve; reject = _reject; }); process.emit("input", "read", resolve, reject, ...args); return promise; }, "read") } }; } }); // node_modules/.pnpm/lru-cache@11.2.2/node_modules/lru-cache/dist/commonjs/index.js var require_commonjs = __commonJS({ "node_modules/.pnpm/lru-cache@11.2.2/node_modules/lru-cache/dist/commonjs/index.js"(exports2) { "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.LRUCache = void 0; var defaultPerf = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date; var warned = /* @__PURE__ */ new Set(); var PROCESS = typeof process === "object" && !!process ? process : {}; var emitWarning = /* @__PURE__ */ __name((msg, type, code, fn) => { typeof PROCESS.emitWarning === "function" ? PROCESS.emitWarning(msg, type, code, fn) : void 0; }, "emitWarning"); var AC = globalThis.AbortController; var AS = globalThis.AbortSignal; if (typeof AC === "undefined") { AS = class AbortSignal { static { __name(this, "AbortSignal"); } onabort; _onabort = []; reason; aborted = false; addEventListener(_, fn) { this._onabort.push(fn); } }; AC = class AbortController { static { __name(this, "AbortController"); } constructor() { warnACPolyfill(); } signal = new AS(); abort(reason) { if (this.signal.aborted) return; this.signal.reason = reason; this.signal.aborted = true; for (const fn of this.signal._onabort) { fn(reason); } this.signal.onabort?.(reason); } }; let printACPolyfillWarning = PROCESS.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1"; const warnACPolyfill = /* @__PURE__ */ __name(() => { if (!printACPolyfillWarning) return; printACPolyfillWarning = false; emitWarning("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", "NO_ABORT_CONTROLLER", "ENOTSUP", warnACPolyfill); }, "warnACPolyfill"); } var shouldWarn = /* @__PURE__ */ __name((code) => !warned.has(code), "shouldWarn"); var TYPE = Symbol("type"); var isPosInt = /* @__PURE__ */ __name((n) => n && n === Math.floor(n) && n > 0 && isFinite(n), "isPosInt"); var getUintArray = /* @__PURE__ */ __name((max) => !isPosInt(max) ? null : max <= Math.pow(2, 8) ? Uint8Array : max <= Math.pow(2, 16) ? Uint16Array : max <= Math.pow(2, 32) ? Uint32Array : max <= Number.MAX_SAFE_INTEGER ? ZeroArray : null, "getUintArray"); var ZeroArray = class extends Array { static { __name(this, "ZeroArray"); } constructor(size) { super(size); this.fill(0); } }; var Stack = class _Stack { static { __name(this, "Stack"); } heap; length; // private constructor static #constructing = false; static create(max) { const HeapCls = getUintArray(max); if (!HeapCls) return []; _Stack.#constructing = true; const s = new _Stack(max, HeapCls); _Stack.#constructing = false; return s; } constructor(max, HeapCls) { if (!_Stack.#constructing) { throw new TypeError("instantiate Stack using Stack.create(n)"); } this.heap = new HeapCls(max); this.length = 0; } push(n) { this.heap[this.length++] = n; } pop() { return this.heap[--this.length]; } }; var LRUCache = class _LRUCache { static { __name(this, "LRUCache"); } // options that cannot be changed without disaster #max; #maxSize; #dispose; #onInsert; #disposeAfter; #fetchMethod; #memoMethod; #perf; /** * {@link LRUCache.OptionsBase.perf} */ get perf() { return this.#perf; } /** * {@link LRUCache.OptionsBase.ttl} */ ttl; /** * {@link LRUCache.OptionsBase.ttlResolution} */ ttlResolution; /** * {@link LRUCache.OptionsBase.ttlAutopurge} */ ttlAutopurge; /** * {@link LRUCache.OptionsBase.updateAgeOnGet} */ updateAgeOnGet; /** * {@link LRUCache.OptionsBase.updateAgeOnHas} */ updateAgeOnHas; /** * {@link LRUCache.OptionsBase.allowStale} */ allowStale; /** * {@link LRUCache.OptionsBase.noDisposeOnSet} */ noDisposeOnSet; /** * {@link LRUCache.OptionsBase.noUpdateTTL} */ noUpdateTTL; /** * {@link LRUCache.OptionsBase.maxEntrySize} */ maxEntrySize; /** * {@link LRUCache.OptionsBase.sizeCalculation} */ sizeCalculation; /** * {@link LRUCache.OptionsBase.noDeleteOnFetchRejection} */ noDeleteOnFetchRejection; /** * {@link LRUCache.OptionsBase.noDeleteOnStaleGet} */ noDeleteOnStaleGet; /** * {@link LRUCache.OptionsBase.allowStaleOnFetchAbort} */ allowStaleOnFetchAbort; /** * {@link LRUCache.OptionsBase.allowStaleOnFetchRejection} */ allowStaleOnFetchRejection; /** * {@link LRUCache.OptionsBase.ignoreFetchAbort} */ ignoreFetchAbort; // computed properties #size; #calculatedSize; #keyMap; #keyList; #valList; #next; #prev; #head; #tail; #free; #disposed; #sizes; #starts; #ttls; #hasDispose; #hasFetchMethod; #hasDisposeAfter; #hasOnInsert; /** * Do not call this method unless you need to inspect the * inner workings of the cache. If anything returned by this * object is modified in any way, strange breakage may occur. * * These fields are private for a reason! * * @internal */ static unsafeExposeInternals(c) { return { // properties starts: c.#starts, ttls: c.#ttls, sizes: c.#sizes, keyMap: c.#keyMap, keyList: c.#keyList, valList: c.#valList, next: c.#next, prev: c.#prev, get head() { return c.#head; }, get tail() { return c.#tail; }, free: c.#free, // methods isBackgroundFetch: /* @__PURE__ */ __name((p) => c.#isBackgroundFetch(p), "isBackgroundFetch"), backgroundFetch: /* @__PURE__ */ __name((k, index, options, context) => c.#backgroundFetch(k, index, options, context), "backgroundFetch"), moveToTail: /* @__PURE__ */ __name((index) => c.#moveToTail(index), "moveToTail"), indexes: /* @__PURE__ */ __name((options) => c.#indexes(options), "indexes"), rindexes: /* @__PURE__ */ __name((options) => c.#rindexes(options), "rindexes"), isStale: /* @__PURE__ */ __name((index) => c.#isStale(index), "isStale") }; } // Protected read-only members /** * {@link LRUCache.OptionsBase.max} (read-only) */ get max() { return this.#max; } /** * {@link LRUCache.OptionsBase.maxSize} (read-only) */ get maxSize() { return this.#maxSize; } /** * The total computed size of items in the cache (read-only) */ get calculatedSize() { return this.#calculatedSize; } /** * The number of items stored in the cache (read-only) */ get size() { return this.#size; } /** * {@link LRUCache.OptionsBase.fetchMethod} (read-only) */ get fetchMethod() { return this.#fetchMethod; } get memoMethod() { return this.#memoMethod; } /** * {@link LRUCache.OptionsBase.dispose} (read-only) */ get dispose() { return this.#dispose; } /** * {@link LRUCache.OptionsBase.onInsert} (read-only) */ get onInsert() { return this.#onInsert; } /** * {@link LRUCache.OptionsBase.disposeAfter} (read-only) */ get disposeAfter() { return this.#disposeAfter; } constructor(options) { const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, onInsert, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, memoMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort, perf } = options; if (perf !== void 0) { if (typeof perf?.now !== "function") { throw new TypeError("perf option must have a now() method if specified"); } } this.#perf = perf ?? defaultPerf; if (max !== 0 && !isPosInt(max)) { throw new TypeError("max option must be a nonnegative integer"); } const UintArray = max ? getUintArray(max) : Array; if (!UintArray) { throw new Error("invalid max value: " + max); } this.#max = max; this.#maxSize = maxSize; this.maxEntrySize = maxEntrySize || this.#maxSize; this.sizeCalculation = sizeCalculation; if (this.sizeCalculation) { if (!this.#maxSize && !this.maxEntrySize) { throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize"); } if (typeof this.sizeCalculation !== "function") { throw new TypeError("sizeCalculation set to non-function"); } } if (memoMethod !== void 0 && typeof memoMethod !== "function") { throw new TypeError("memoMethod must be a function if defined"); } this.#memoMethod = memoMethod; if (fetchMethod !== void 0 && typeof fetchMethod !== "function") { throw new TypeError("fetchMethod must be a function if specified"); } this.#fetchMethod = fetchMethod; this.#hasFetchMethod = !!fetchMethod; this.#keyMap = /* @__PURE__ */ new Map(); this.#keyList = new Array(max).fill(void 0); this.#valList = new Array(max).fill(void 0); this.#next = new UintArray(max); this.#prev = new UintArray(max); this.#head = 0; this.#tail = 0; this.#free = Stack.create(max); this.#size = 0; this.#calculatedSize = 0; if (typeof dispose === "function") { this.#dispose = dispose; } if (typeof onInsert === "function") { this.#onInsert = onInsert; } if (typeof disposeAfter === "function") { this.#disposeAfter = disposeAfter; this.#disposed = []; } else { this.#disposeAfter = void 0; this.#disposed = void 0; } this.#hasDispose = !!this.#dispose; this.#hasOnInsert = !!this.#onInsert; this.#hasDisposeAfter = !!this.#disposeAfter; this.noDisposeOnSet = !!noDisposeOnSet; this.noUpdateTTL = !!noUpdateTTL; this.noDeleteOnFetchRejection = !!noDeleteOnFetchRejection; this.allowStaleOnFetchRejection = !!allowStaleOnFetchRejection; this.allowStaleOnFetchAbort = !!allowStaleOnFetchAbort; this.ignoreFetchAbort = !!ignoreFetchAbort; if (this.maxEntrySize !== 0) { if (this.#maxSize !== 0) { if (!isPosInt(this.#maxSize)) { throw new TypeError("maxSize must be a positive integer if specified"); } } if (!isPosInt(this.maxEntrySize)) { throw new TypeError("maxEntrySize must be a positive integer if specified"); } this.#initializeSizeTracking(); } this.allowStale = !!allowStale; this.noDeleteOnStaleGet = !!noDeleteOnStaleGet; this.updateAgeOnGet = !!updateAgeOnGet; this.updateAgeOnHas = !!updateAgeOnHas; this.ttlResolution = isPosInt(ttlResolution) || ttlResolution === 0 ? ttlResolution : 1; this.ttlAutopurge = !!ttlAutopurge; this.ttl = ttl || 0; if (this.ttl) { if (!isPosInt(this.ttl)) { throw new TypeError("ttl must be a positive integer if specified"); } this.#initializeTTLTracking(); } if (this.#max === 0 && this.ttl === 0 && this.#maxSize === 0) { throw new TypeError("At least one of max, maxSize, or ttl is required"); } if (!this.ttlAutopurge && !this.#max && !this.#maxSize) { const code = "LRU_CACHE_UNBOUNDED"; if (shouldWarn(code)) { warned.add(code); const msg = "TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption."; emitWarning(msg, "UnboundedCacheWarning", code, _LRUCache); } } } /** * Return the number of ms left in the item's TTL. If item is not in cache, * returns `0`. Returns `Infinity` if item is in cache without a defined TTL. */ getRemainingTTL(key) { return this.#keyMap.has(key) ? Infinity : 0; } #initializeTTLTracking() { const ttls = new ZeroArray(this.#max); const starts = new ZeroArray(this.#max); this.#ttls = ttls; this.#starts = starts; this.#setItemTTL = (index, ttl, start = this.#perf.now()) => { starts[index] = ttl !== 0 ? start : 0; ttls[index] = ttl; if (ttl !== 0 && this.ttlAutopurge) { const t = setTimeout(() => { if (this.#isStale(index)) { this.#delete(this.#keyList[index], "expire"); } }, ttl + 1); if (t.unref) { t.unref(); } } }; this.#updateItemAge = (index) => { starts[index] = ttls[index] !== 0 ? this.#perf.now() : 0; }; this.#statusTTL = (status, index) => { if (ttls[index]) { const ttl = ttls[index]; const start = starts[index]; if (!ttl || !start) return; status.ttl = ttl; status.start = start; status.now = cachedNow || getNow(); const age = status.now - start; status.remainingTTL = ttl - age; } }; let cachedNow = 0; const getNow = /* @__PURE__ */ __name(() => { const n = this.#perf.now(); if (this.ttlResolution > 0) { cachedNow = n; const t = setTimeout(() => cachedNow = 0, this.ttlResolution); if (t.unref) { t.unref(); } } return n; }, "getNow"); this.getRemainingTTL = (key) => { const index = this.#keyMap.get(key); if (index === void 0) { return 0; } const ttl = ttls[index]; const start = starts[index]; if (!ttl || !start) { return Infinity; } const age = (cachedNow || getNow()) - start; return ttl - age; }; this.#isStale = (index) => { const s = starts[index]; const t = ttls[index]; return !!t && !!s && (cachedNow || getNow()) - s > t; }; } // conditionally set private methods related to TTL #updateItemAge = /* @__PURE__ */ __name(() => { }, "#updateItemAge"