UNPKG

@antfu/ni

Version:
1,377 lines 254 kB
import { a as __toESM, i as __require, t as __commonJSMin } from "./chunk-CMuxRQOh.mjs"; import { A as require_prompts, T as formatPackageWithUrl, h as getCatalog, i as runCli, l as parseNi, o as getCommand, w as exclude } from "./src-DinnZ_Bc.mjs"; import fs from "node:fs"; import path from "node:path"; import process from "node:process"; import { styleText } from "node:util"; import { Fzf } from "fzf"; //#region node_modules/.pnpm/fast-npm-meta@1.4.2/node_modules/fast-npm-meta/dist/index.mjs var import_prompts = /* @__PURE__ */ __toESM(require_prompts(), 1); const objectToString = Object.prototype.toString; const isError = (value) => objectToString.call(value) === "[object Error]"; const errorMessages = new Set([ "network error", "Failed to fetch", "NetworkError when attempting to fetch resource.", "The Internet connection appears to be offline.", "Network request failed", "fetch failed", "terminated", " A network error occurred.", "Network connection lost" ]); function isNetworkError(error) { if (!(error && isError(error) && error.name === "TypeError" && typeof error.message === "string")) return false; const { message, stack } = error; if (message === "Load failed") return stack === void 0 || "__sentry_captured__" in error; if (message.startsWith("error sending request for url")) return true; return errorMessages.has(message); } function validateRetries(retries) { if (typeof retries === "number") { if (retries < 0) throw new TypeError("Expected `retries` to be a non-negative number."); if (Number.isNaN(retries)) throw new TypeError("Expected `retries` to be a valid number or Infinity, got NaN."); } else if (retries !== void 0) throw new TypeError("Expected `retries` to be a number or Infinity."); } function validateNumberOption(name, value, { min = 0, allowInfinity = false } = {}) { if (value === void 0) return; if (typeof value !== "number" || Number.isNaN(value)) throw new TypeError(`Expected \`${name}\` to be a number${allowInfinity ? " or Infinity" : ""}.`); if (!allowInfinity && !Number.isFinite(value)) throw new TypeError(`Expected \`${name}\` to be a finite number.`); if (value < min) throw new TypeError(`Expected \`${name}\` to be \u2265 ${min}.`); } var AbortError = class extends Error { constructor(message) { super(); if (message instanceof Error) { this.originalError = message; ({message} = message); } else { this.originalError = new Error(message); this.originalError.stack = this.stack; } this.name = "AbortError"; this.message = message; } }; function calculateDelay(retriesConsumed, options) { const attempt = Math.max(1, retriesConsumed + 1); const random = options.randomize ? Math.random() + 1 : 1; let timeout = Math.round(random * options.minTimeout * options.factor ** (attempt - 1)); timeout = Math.min(timeout, options.maxTimeout); return timeout; } function calculateRemainingTime(start, max) { if (!Number.isFinite(max)) return max; return max - (performance.now() - start); } async function onAttemptFailure({ error, attemptNumber, retriesConsumed, startTime, options }) { const normalizedError = error instanceof Error ? error : /* @__PURE__ */ new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`); if (normalizedError instanceof AbortError) throw normalizedError.originalError; const retriesLeft = Number.isFinite(options.retries) ? Math.max(0, options.retries - retriesConsumed) : options.retries; const maxRetryTime = options.maxRetryTime ?? Number.POSITIVE_INFINITY; const context = Object.freeze({ error: normalizedError, attemptNumber, retriesLeft, retriesConsumed }); await options.onFailedAttempt(context); if (calculateRemainingTime(startTime, maxRetryTime) <= 0) throw normalizedError; const consumeRetry = await options.shouldConsumeRetry(context); const remainingTime = calculateRemainingTime(startTime, maxRetryTime); if (remainingTime <= 0 || retriesLeft <= 0) throw normalizedError; if (normalizedError instanceof TypeError && !isNetworkError(normalizedError)) { if (consumeRetry) throw normalizedError; options.signal?.throwIfAborted(); return false; } if (!await options.shouldRetry(context)) throw normalizedError; if (!consumeRetry) { options.signal?.throwIfAborted(); return false; } const delayTime = calculateDelay(retriesConsumed, options); const finalDelay = Math.min(delayTime, remainingTime); options.signal?.throwIfAborted(); if (finalDelay > 0) await new Promise((resolve, reject) => { const onAbort = () => { clearTimeout(timeoutToken); options.signal?.removeEventListener("abort", onAbort); reject(options.signal.reason); }; const timeoutToken = setTimeout(() => { options.signal?.removeEventListener("abort", onAbort); resolve(); }, finalDelay); if (options.unref) timeoutToken.unref?.(); options.signal?.addEventListener("abort", onAbort, { once: true }); }); options.signal?.throwIfAborted(); return true; } async function pRetry(input, options = {}) { options = { ...options }; validateRetries(options.retries); if (Object.hasOwn(options, "forever")) throw new Error("The `forever` option is no longer supported. For many use-cases, you can set `retries: Infinity` instead."); options.retries ??= 10; options.factor ??= 2; options.minTimeout ??= 1e3; options.maxTimeout ??= Number.POSITIVE_INFINITY; options.maxRetryTime ??= Number.POSITIVE_INFINITY; options.randomize ??= false; options.onFailedAttempt ??= () => {}; options.shouldRetry ??= () => true; options.shouldConsumeRetry ??= () => true; validateNumberOption("factor", options.factor, { min: 0, allowInfinity: false }); validateNumberOption("minTimeout", options.minTimeout, { min: 0, allowInfinity: false }); validateNumberOption("maxTimeout", options.maxTimeout, { min: 0, allowInfinity: true }); validateNumberOption("maxRetryTime", options.maxRetryTime, { min: 0, allowInfinity: true }); if (!(options.factor > 0)) options.factor = 1; options.signal?.throwIfAborted(); let attemptNumber = 0; let retriesConsumed = 0; const startTime = performance.now(); while (Number.isFinite(options.retries) ? retriesConsumed <= options.retries : true) { attemptNumber++; try { options.signal?.throwIfAborted(); const result = await input(attemptNumber); options.signal?.throwIfAborted(); return result; } catch (error) { if (await onAttemptFailure({ error, attemptNumber, retriesConsumed, startTime, options })) retriesConsumed++; } } throw new Error("Retry attempts exhausted without throwing an error."); } const defaultRetryOptions = { retries: 5, factor: 2, minTimeout: 1e3, maxTimeout: Infinity, randomize: false }; const defaultOptions = { apiEndpoint: "https://npm.antfu.dev/" }; async function getLatestVersionBatch(packages, options = {}) { const { apiEndpoint = defaultOptions.apiEndpoint, fetch: fetchApi = fetch, throw: throwError = true, retry = defaultRetryOptions } = options; let query = [ options.force ? "force=true" : "", options.metadata ? "metadata=true" : "", throwError ? "" : "throw=false" ].filter(Boolean).join("&"); if (query) query = `?${query}`; const fetchFn = () => fetchApi(new URL(packages.join("+") + query, apiEndpoint)).then((r) => r.json()); const retryOptions = typeof retry === "number" ? { ...defaultRetryOptions, retries: retry } : retry; const list = toArray(await (retryOptions === false ? fetchFn() : pRetry(fetchFn, retryOptions))); return throwError ? throwErrorObject(list) : list; } async function getLatestVersion(name, options = {}) { const [data] = await getLatestVersionBatch([name], options); return data; } function throwErrorObject(data) { for (const item of toArray(data)) if (item && "error" in item) throw new Error(item.message || item.error); return data; } function toArray(data) { if (Array.isArray(data)) return data; return [data]; } //#endregion //#region node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/identity.js var require_identity = /* @__PURE__ */ __commonJSMin(((exports) => { const ALIAS = Symbol.for("yaml.alias"); const DOC = Symbol.for("yaml.document"); const MAP = Symbol.for("yaml.map"); const PAIR = Symbol.for("yaml.pair"); const SCALAR = Symbol.for("yaml.scalar"); const SEQ = Symbol.for("yaml.seq"); const NODE_TYPE = Symbol.for("yaml.node.type"); const isAlias = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === ALIAS; const isDocument = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === DOC; const isMap = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === MAP; const isPair = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === PAIR; const isScalar = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === SCALAR; const isSeq = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === SEQ; function isCollection(node) { if (node && typeof node === "object") switch (node[NODE_TYPE]) { case MAP: case SEQ: return true; } return false; } function isNode(node) { if (node && typeof node === "object") switch (node[NODE_TYPE]) { case ALIAS: case MAP: case SCALAR: case SEQ: return true; } return false; } const hasAnchor = (node) => (isScalar(node) || isCollection(node)) && !!node.anchor; exports.ALIAS = ALIAS; exports.DOC = DOC; exports.MAP = MAP; exports.NODE_TYPE = NODE_TYPE; exports.PAIR = PAIR; exports.SCALAR = SCALAR; exports.SEQ = SEQ; exports.hasAnchor = hasAnchor; exports.isAlias = isAlias; exports.isCollection = isCollection; exports.isDocument = isDocument; exports.isMap = isMap; exports.isNode = isNode; exports.isPair = isPair; exports.isScalar = isScalar; exports.isSeq = isSeq; })); //#endregion //#region node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/visit.js var require_visit = /* @__PURE__ */ __commonJSMin(((exports) => { var identity = require_identity(); const BREAK = Symbol("break visit"); const SKIP = Symbol("skip children"); const REMOVE = Symbol("remove node"); /** * Apply a visitor to an AST node or document. * * Walks through the tree (depth-first) starting from `node`, calling a * `visitor` function with three arguments: * - `key`: For sequence values and map `Pair`, the node's index in the * collection. Within a `Pair`, `'key'` or `'value'`, correspondingly. * `null` for the root node. * - `node`: The current node. * - `path`: The ancestry of the current node. * * The return value of the visitor may be used to control the traversal: * - `undefined` (default): Do nothing and continue * - `visit.SKIP`: Do not visit the children of this node, continue with next * sibling * - `visit.BREAK`: Terminate traversal completely * - `visit.REMOVE`: Remove the current node, then continue with the next one * - `Node`: Replace the current node, then continue by visiting it * - `number`: While iterating the items of a sequence or map, set the index * of the next step. This is useful especially if the index of the current * node has changed. * * If `visitor` is a single function, it will be called with all values * encountered in the tree, including e.g. `null` values. Alternatively, * separate visitor functions may be defined for each `Map`, `Pair`, `Seq`, * `Alias` and `Scalar` node. To define the same visitor function for more than * one node type, use the `Collection` (map and seq), `Value` (map, seq & scalar) * and `Node` (alias, map, seq & scalar) targets. Of all these, only the most * specific defined one will be used for each node. */ function visit(node, visitor) { const visitor_ = initVisitor(visitor); if (identity.isDocument(node)) { if (visit_(null, node.contents, visitor_, Object.freeze([node])) === REMOVE) node.contents = null; } else visit_(null, node, visitor_, Object.freeze([])); } /** Terminate visit traversal completely */ visit.BREAK = BREAK; /** Do not visit the children of the current node */ visit.SKIP = SKIP; /** Remove the current node */ visit.REMOVE = REMOVE; function visit_(key, node, visitor, path) { const ctrl = callVisitor(key, node, visitor, path); if (identity.isNode(ctrl) || identity.isPair(ctrl)) { replaceNode(key, path, ctrl); return visit_(key, ctrl, visitor, path); } if (typeof ctrl !== "symbol") { if (identity.isCollection(node)) { path = Object.freeze(path.concat(node)); for (let i = 0; i < node.items.length; ++i) { const ci = visit_(i, node.items[i], visitor, path); if (typeof ci === "number") i = ci - 1; else if (ci === BREAK) return BREAK; else if (ci === REMOVE) { node.items.splice(i, 1); i -= 1; } } } else if (identity.isPair(node)) { path = Object.freeze(path.concat(node)); const ck = visit_("key", node.key, visitor, path); if (ck === BREAK) return BREAK; else if (ck === REMOVE) node.key = null; const cv = visit_("value", node.value, visitor, path); if (cv === BREAK) return BREAK; else if (cv === REMOVE) node.value = null; } } return ctrl; } /** * Apply an async visitor to an AST node or document. * * Walks through the tree (depth-first) starting from `node`, calling a * `visitor` function with three arguments: * - `key`: For sequence values and map `Pair`, the node's index in the * collection. Within a `Pair`, `'key'` or `'value'`, correspondingly. * `null` for the root node. * - `node`: The current node. * - `path`: The ancestry of the current node. * * The return value of the visitor may be used to control the traversal: * - `Promise`: Must resolve to one of the following values * - `undefined` (default): Do nothing and continue * - `visit.SKIP`: Do not visit the children of this node, continue with next * sibling * - `visit.BREAK`: Terminate traversal completely * - `visit.REMOVE`: Remove the current node, then continue with the next one * - `Node`: Replace the current node, then continue by visiting it * - `number`: While iterating the items of a sequence or map, set the index * of the next step. This is useful especially if the index of the current * node has changed. * * If `visitor` is a single function, it will be called with all values * encountered in the tree, including e.g. `null` values. Alternatively, * separate visitor functions may be defined for each `Map`, `Pair`, `Seq`, * `Alias` and `Scalar` node. To define the same visitor function for more than * one node type, use the `Collection` (map and seq), `Value` (map, seq & scalar) * and `Node` (alias, map, seq & scalar) targets. Of all these, only the most * specific defined one will be used for each node. */ async function visitAsync(node, visitor) { const visitor_ = initVisitor(visitor); if (identity.isDocument(node)) { if (await visitAsync_(null, node.contents, visitor_, Object.freeze([node])) === REMOVE) node.contents = null; } else await visitAsync_(null, node, visitor_, Object.freeze([])); } /** Terminate visit traversal completely */ visitAsync.BREAK = BREAK; /** Do not visit the children of the current node */ visitAsync.SKIP = SKIP; /** Remove the current node */ visitAsync.REMOVE = REMOVE; async function visitAsync_(key, node, visitor, path) { const ctrl = await callVisitor(key, node, visitor, path); if (identity.isNode(ctrl) || identity.isPair(ctrl)) { replaceNode(key, path, ctrl); return visitAsync_(key, ctrl, visitor, path); } if (typeof ctrl !== "symbol") { if (identity.isCollection(node)) { path = Object.freeze(path.concat(node)); for (let i = 0; i < node.items.length; ++i) { const ci = await visitAsync_(i, node.items[i], visitor, path); if (typeof ci === "number") i = ci - 1; else if (ci === BREAK) return BREAK; else if (ci === REMOVE) { node.items.splice(i, 1); i -= 1; } } } else if (identity.isPair(node)) { path = Object.freeze(path.concat(node)); const ck = await visitAsync_("key", node.key, visitor, path); if (ck === BREAK) return BREAK; else if (ck === REMOVE) node.key = null; const cv = await visitAsync_("value", node.value, visitor, path); if (cv === BREAK) return BREAK; else if (cv === REMOVE) node.value = null; } } return ctrl; } function initVisitor(visitor) { if (typeof visitor === "object" && (visitor.Collection || visitor.Node || visitor.Value)) return Object.assign({ Alias: visitor.Node, Map: visitor.Node, Scalar: visitor.Node, Seq: visitor.Node }, visitor.Value && { Map: visitor.Value, Scalar: visitor.Value, Seq: visitor.Value }, visitor.Collection && { Map: visitor.Collection, Seq: visitor.Collection }, visitor); return visitor; } function callVisitor(key, node, visitor, path) { if (typeof visitor === "function") return visitor(key, node, path); if (identity.isMap(node)) return visitor.Map?.(key, node, path); if (identity.isSeq(node)) return visitor.Seq?.(key, node, path); if (identity.isPair(node)) return visitor.Pair?.(key, node, path); if (identity.isScalar(node)) return visitor.Scalar?.(key, node, path); if (identity.isAlias(node)) return visitor.Alias?.(key, node, path); } function replaceNode(key, path, node) { const parent = path[path.length - 1]; if (identity.isCollection(parent)) parent.items[key] = node; else if (identity.isPair(parent)) if (key === "key") parent.key = node; else parent.value = node; else if (identity.isDocument(parent)) parent.contents = node; else { const pt = identity.isAlias(parent) ? "alias" : "scalar"; throw new Error(`Cannot replace node with ${pt} parent`); } } exports.visit = visit; exports.visitAsync = visitAsync; })); //#endregion //#region node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/doc/directives.js var require_directives = /* @__PURE__ */ __commonJSMin(((exports) => { var identity = require_identity(); var visit = require_visit(); const escapeChars = { "!": "%21", ",": "%2C", "[": "%5B", "]": "%5D", "{": "%7B", "}": "%7D" }; const escapeTagName = (tn) => tn.replace(/[!,[\]{}]/g, (ch) => escapeChars[ch]); var Directives = class Directives { constructor(yaml, tags) { /** * The directives-end/doc-start marker `---`. If `null`, a marker may still be * included in the document's stringified representation. */ this.docStart = null; /** The doc-end marker `...`. */ this.docEnd = false; this.yaml = Object.assign({}, Directives.defaultYaml, yaml); this.tags = Object.assign({}, Directives.defaultTags, tags); } clone() { const copy = new Directives(this.yaml, this.tags); copy.docStart = this.docStart; return copy; } /** * During parsing, get a Directives instance for the current document and * update the stream state according to the current version's spec. */ atDocument() { const res = new Directives(this.yaml, this.tags); switch (this.yaml.version) { case "1.1": this.atNextDocument = true; break; case "1.2": this.atNextDocument = false; this.yaml = { explicit: Directives.defaultYaml.explicit, version: "1.2" }; this.tags = Object.assign({}, Directives.defaultTags); break; } return res; } /** * @param onError - May be called even if the action was successful * @returns `true` on success */ add(line, onError) { if (this.atNextDocument) { this.yaml = { explicit: Directives.defaultYaml.explicit, version: "1.1" }; this.tags = Object.assign({}, Directives.defaultTags); this.atNextDocument = false; } const parts = line.trim().split(/[ \t]+/); const name = parts.shift(); switch (name) { case "%TAG": { if (parts.length !== 2) { onError(0, "%TAG directive should contain exactly two parts"); if (parts.length < 2) return false; } const [handle, prefix] = parts; this.tags[handle] = prefix; return true; } case "%YAML": { this.yaml.explicit = true; if (parts.length !== 1) { onError(0, "%YAML directive should contain exactly one part"); return false; } const [version] = parts; if (version === "1.1" || version === "1.2") { this.yaml.version = version; return true; } else { const isValid = /^\d+\.\d+$/.test(version); onError(6, `Unsupported YAML version ${version}`, isValid); return false; } } default: onError(0, `Unknown directive ${name}`, true); return false; } } /** * Resolves a tag, matching handles to those defined in %TAG directives. * * @returns Resolved tag, which may also be the non-specific tag `'!'` or a * `'!local'` tag, or `null` if unresolvable. */ tagName(source, onError) { if (source === "!") return "!"; if (source[0] !== "!") { onError(`Not a valid tag: ${source}`); return null; } if (source[1] === "<") { const verbatim = source.slice(2, -1); if (verbatim === "!" || verbatim === "!!") { onError(`Verbatim tags aren't resolved, so ${source} is invalid.`); return null; } if (source[source.length - 1] !== ">") onError("Verbatim tags must end with a >"); return verbatim; } const [, handle, suffix] = source.match(/^(.*!)([^!]*)$/s); if (!suffix) onError(`The ${source} tag has no suffix`); const prefix = this.tags[handle]; if (prefix) try { return prefix + decodeURIComponent(suffix); } catch (error) { onError(String(error)); return null; } if (handle === "!") return source; onError(`Could not resolve tag: ${source}`); return null; } /** * Given a fully resolved tag, returns its printable string form, * taking into account current tag prefixes and defaults. */ tagString(tag) { for (const [handle, prefix] of Object.entries(this.tags)) if (tag.startsWith(prefix)) return handle + escapeTagName(tag.substring(prefix.length)); return tag[0] === "!" ? tag : `!<${tag}>`; } toString(doc) { const lines = this.yaml.explicit ? [`%YAML ${this.yaml.version || "1.2"}`] : []; const tagEntries = Object.entries(this.tags); let tagNames; if (doc && tagEntries.length > 0 && identity.isNode(doc.contents)) { const tags = {}; visit.visit(doc.contents, (_key, node) => { if (identity.isNode(node) && node.tag) tags[node.tag] = true; }); tagNames = Object.keys(tags); } else tagNames = []; for (const [handle, prefix] of tagEntries) { if (handle === "!!" && prefix === "tag:yaml.org,2002:") continue; if (!doc || tagNames.some((tn) => tn.startsWith(prefix))) lines.push(`%TAG ${handle} ${prefix}`); } return lines.join("\n"); } }; Directives.defaultYaml = { explicit: false, version: "1.2" }; Directives.defaultTags = { "!!": "tag:yaml.org,2002:" }; exports.Directives = Directives; })); //#endregion //#region node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/doc/anchors.js var require_anchors = /* @__PURE__ */ __commonJSMin(((exports) => { var identity = require_identity(); var visit = require_visit(); /** * Verify that the input string is a valid anchor. * * Will throw on errors. */ function anchorIsValid(anchor) { if (/[\x00-\x19\s,[\]{}]/.test(anchor)) { const msg = `Anchor must not contain whitespace or control characters: ${JSON.stringify(anchor)}`; throw new Error(msg); } return true; } function anchorNames(root) { const anchors = /* @__PURE__ */ new Set(); visit.visit(root, { Value(_key, node) { if (node.anchor) anchors.add(node.anchor); } }); return anchors; } /** Find a new anchor name with the given `prefix` and a one-indexed suffix. */ function findNewAnchor(prefix, exclude) { for (let i = 1;; ++i) { const name = `${prefix}${i}`; if (!exclude.has(name)) return name; } } function createNodeAnchors(doc, prefix) { const aliasObjects = []; const sourceObjects = /* @__PURE__ */ new Map(); let prevAnchors = null; return { onAnchor: (source) => { aliasObjects.push(source); prevAnchors ?? (prevAnchors = anchorNames(doc)); const anchor = findNewAnchor(prefix, prevAnchors); prevAnchors.add(anchor); return anchor; }, setAnchors: () => { for (const source of aliasObjects) { const ref = sourceObjects.get(source); if (typeof ref === "object" && ref.anchor && (identity.isScalar(ref.node) || identity.isCollection(ref.node))) ref.node.anchor = ref.anchor; else { const error = /* @__PURE__ */ new Error("Failed to resolve repeated object (this should not happen)"); error.source = source; throw error; } } }, sourceObjects }; } exports.anchorIsValid = anchorIsValid; exports.anchorNames = anchorNames; exports.createNodeAnchors = createNodeAnchors; exports.findNewAnchor = findNewAnchor; })); //#endregion //#region node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/doc/applyReviver.js var require_applyReviver = /* @__PURE__ */ __commonJSMin(((exports) => { /** * Applies the JSON.parse reviver algorithm as defined in the ECMA-262 spec, * in section 24.5.1.1 "Runtime Semantics: InternalizeJSONProperty" of the * 2021 edition: https://tc39.es/ecma262/#sec-json.parse * * Includes extensions for handling Map and Set objects. */ function applyReviver(reviver, obj, key, val) { if (val && typeof val === "object") if (Array.isArray(val)) for (let i = 0, len = val.length; i < len; ++i) { const v0 = val[i]; const v1 = applyReviver(reviver, val, String(i), v0); if (v1 === void 0) delete val[i]; else if (v1 !== v0) val[i] = v1; } else if (val instanceof Map) for (const k of Array.from(val.keys())) { const v0 = val.get(k); const v1 = applyReviver(reviver, val, k, v0); if (v1 === void 0) val.delete(k); else if (v1 !== v0) val.set(k, v1); } else if (val instanceof Set) for (const v0 of Array.from(val)) { const v1 = applyReviver(reviver, val, v0, v0); if (v1 === void 0) val.delete(v0); else if (v1 !== v0) { val.delete(v0); val.add(v1); } } else for (const [k, v0] of Object.entries(val)) { const v1 = applyReviver(reviver, val, k, v0); if (v1 === void 0) delete val[k]; else if (v1 !== v0) val[k] = v1; } return reviver.call(obj, key, val); } exports.applyReviver = applyReviver; })); //#endregion //#region node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/toJS.js var require_toJS = /* @__PURE__ */ __commonJSMin(((exports) => { var identity = require_identity(); /** * Recursively convert any node or its contents to native JavaScript * * @param value - The input value * @param arg - If `value` defines a `toJSON()` method, use this * as its first argument * @param ctx - Conversion context, originally set in Document#toJS(). If * `{ keep: true }` is not set, output should be suitable for JSON * stringification. */ function toJS(value, arg, ctx) { if (Array.isArray(value)) return value.map((v, i) => toJS(v, String(i), ctx)); if (value && typeof value.toJSON === "function") { if (!ctx || !identity.hasAnchor(value)) return value.toJSON(arg, ctx); const data = { aliasCount: 0, count: 1, res: void 0 }; ctx.anchors.set(value, data); ctx.onCreate = (res) => { data.res = res; delete ctx.onCreate; }; const res = value.toJSON(arg, ctx); if (ctx.onCreate) ctx.onCreate(res); return res; } if (typeof value === "bigint" && !ctx?.keep) return Number(value); return value; } exports.toJS = toJS; })); //#endregion //#region node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/Node.js var require_Node = /* @__PURE__ */ __commonJSMin(((exports) => { var applyReviver = require_applyReviver(); var identity = require_identity(); var toJS = require_toJS(); var NodeBase = class { constructor(type) { Object.defineProperty(this, identity.NODE_TYPE, { value: type }); } /** Create a copy of this node. */ clone() { const copy = Object.create(Object.getPrototypeOf(this), Object.getOwnPropertyDescriptors(this)); if (this.range) copy.range = this.range.slice(); return copy; } /** A plain JavaScript representation of this node. */ toJS(doc, { mapAsMap, maxAliasCount, onAnchor, reviver } = {}) { if (!identity.isDocument(doc)) throw new TypeError("A document argument is required"); const ctx = { anchors: /* @__PURE__ */ new Map(), doc, keep: true, mapAsMap: mapAsMap === true, mapKeyWarned: false, maxAliasCount: typeof maxAliasCount === "number" ? maxAliasCount : 100 }; const res = toJS.toJS(this, "", ctx); if (typeof onAnchor === "function") for (const { count, res } of ctx.anchors.values()) onAnchor(res, count); return typeof reviver === "function" ? applyReviver.applyReviver(reviver, { "": res }, "", res) : res; } }; exports.NodeBase = NodeBase; })); //#endregion //#region node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/Alias.js var require_Alias = /* @__PURE__ */ __commonJSMin(((exports) => { var anchors = require_anchors(); var visit = require_visit(); var identity = require_identity(); var Node = require_Node(); var toJS = require_toJS(); var Alias = class extends Node.NodeBase { constructor(source) { super(identity.ALIAS); this.source = source; Object.defineProperty(this, "tag", { set() { throw new Error("Alias nodes cannot have tags"); } }); } /** * Resolve the value of this alias within `doc`, finding the last * instance of the `source` anchor before this node. */ resolve(doc, ctx) { let nodes; if (ctx?.aliasResolveCache) nodes = ctx.aliasResolveCache; else { nodes = []; visit.visit(doc, { Node: (_key, node) => { if (identity.isAlias(node) || identity.hasAnchor(node)) nodes.push(node); } }); if (ctx) ctx.aliasResolveCache = nodes; } let found = void 0; for (const node of nodes) { if (node === this) break; if (node.anchor === this.source) found = node; } return found; } toJSON(_arg, ctx) { if (!ctx) return { source: this.source }; const { anchors, doc, maxAliasCount } = ctx; const source = this.resolve(doc, ctx); if (!source) { const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`; throw new ReferenceError(msg); } let data = anchors.get(source); if (!data) { toJS.toJS(source, null, ctx); data = anchors.get(source); } /* istanbul ignore if */ if (data?.res === void 0) throw new ReferenceError("This should not happen: Alias anchor was not resolved?"); if (maxAliasCount >= 0) { data.count += 1; if (data.aliasCount === 0) data.aliasCount = getAliasCount(doc, source, anchors); if (data.count * data.aliasCount > maxAliasCount) throw new ReferenceError("Excessive alias count indicates a resource exhaustion attack"); } return data.res; } toString(ctx, _onComment, _onChompKeep) { const src = `*${this.source}`; if (ctx) { anchors.anchorIsValid(this.source); if (ctx.options.verifyAliasOrder && !ctx.anchors.has(this.source)) { const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`; throw new Error(msg); } if (ctx.implicitKey) return `${src} `; } return src; } }; function getAliasCount(doc, node, anchors) { if (identity.isAlias(node)) { const source = node.resolve(doc); const anchor = anchors && source && anchors.get(source); return anchor ? anchor.count * anchor.aliasCount : 0; } else if (identity.isCollection(node)) { let count = 0; for (const item of node.items) { const c = getAliasCount(doc, item, anchors); if (c > count) count = c; } return count; } else if (identity.isPair(node)) { const kc = getAliasCount(doc, node.key, anchors); const vc = getAliasCount(doc, node.value, anchors); return Math.max(kc, vc); } return 1; } exports.Alias = Alias; })); //#endregion //#region node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/Scalar.js var require_Scalar = /* @__PURE__ */ __commonJSMin(((exports) => { var identity = require_identity(); var Node = require_Node(); var toJS = require_toJS(); const isScalarValue = (value) => !value || typeof value !== "function" && typeof value !== "object"; var Scalar = class extends Node.NodeBase { constructor(value) { super(identity.SCALAR); this.value = value; } toJSON(arg, ctx) { return ctx?.keep ? this.value : toJS.toJS(this.value, arg, ctx); } toString() { return String(this.value); } }; Scalar.BLOCK_FOLDED = "BLOCK_FOLDED"; Scalar.BLOCK_LITERAL = "BLOCK_LITERAL"; Scalar.PLAIN = "PLAIN"; Scalar.QUOTE_DOUBLE = "QUOTE_DOUBLE"; Scalar.QUOTE_SINGLE = "QUOTE_SINGLE"; exports.Scalar = Scalar; exports.isScalarValue = isScalarValue; })); //#endregion //#region node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/doc/createNode.js var require_createNode = /* @__PURE__ */ __commonJSMin(((exports) => { var Alias = require_Alias(); var identity = require_identity(); var Scalar = require_Scalar(); const defaultTagPrefix = "tag:yaml.org,2002:"; function findTagObject(value, tagName, tags) { if (tagName) { const match = tags.filter((t) => t.tag === tagName); const tagObj = match.find((t) => !t.format) ?? match[0]; if (!tagObj) throw new Error(`Tag ${tagName} not found`); return tagObj; } return tags.find((t) => t.identify?.(value) && !t.format); } function createNode(value, tagName, ctx) { if (identity.isDocument(value)) value = value.contents; if (identity.isNode(value)) return value; if (identity.isPair(value)) { const map = ctx.schema[identity.MAP].createNode?.(ctx.schema, null, ctx); map.items.push(value); return map; } if (value instanceof String || value instanceof Number || value instanceof Boolean || typeof BigInt !== "undefined" && value instanceof BigInt) value = value.valueOf(); const { aliasDuplicateObjects, onAnchor, onTagObj, schema, sourceObjects } = ctx; let ref = void 0; if (aliasDuplicateObjects && value && typeof value === "object") { ref = sourceObjects.get(value); if (ref) { ref.anchor ?? (ref.anchor = onAnchor(value)); return new Alias.Alias(ref.anchor); } else { ref = { anchor: null, node: null }; sourceObjects.set(value, ref); } } if (tagName?.startsWith("!!")) tagName = defaultTagPrefix + tagName.slice(2); let tagObj = findTagObject(value, tagName, schema.tags); if (!tagObj) { if (value && typeof value.toJSON === "function") value = value.toJSON(); if (!value || typeof value !== "object") { const node = new Scalar.Scalar(value); if (ref) ref.node = node; return node; } tagObj = value instanceof Map ? schema[identity.MAP] : Symbol.iterator in Object(value) ? schema[identity.SEQ] : schema[identity.MAP]; } if (onTagObj) { onTagObj(tagObj); delete ctx.onTagObj; } const node = tagObj?.createNode ? tagObj.createNode(ctx.schema, value, ctx) : typeof tagObj?.nodeClass?.from === "function" ? tagObj.nodeClass.from(ctx.schema, value, ctx) : new Scalar.Scalar(value); if (tagName) node.tag = tagName; else if (!tagObj.default) node.tag = tagObj.tag; if (ref) ref.node = node; return node; } exports.createNode = createNode; })); //#endregion //#region node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/nodes/Collection.js var require_Collection = /* @__PURE__ */ __commonJSMin(((exports) => { var createNode = require_createNode(); var identity = require_identity(); var Node = require_Node(); function collectionFromPath(schema, path, value) { let v = value; for (let i = path.length - 1; i >= 0; --i) { const k = path[i]; if (typeof k === "number" && Number.isInteger(k) && k >= 0) { const a = []; a[k] = v; v = a; } else v = new Map([[k, v]]); } return createNode.createNode(v, void 0, { aliasDuplicateObjects: false, keepUndefined: false, onAnchor: () => { throw new Error("This should not happen, please report a bug."); }, schema, sourceObjects: /* @__PURE__ */ new Map() }); } const isEmptyPath = (path) => path == null || typeof path === "object" && !!path[Symbol.iterator]().next().done; var Collection = class extends Node.NodeBase { constructor(type, schema) { super(type); Object.defineProperty(this, "schema", { value: schema, configurable: true, enumerable: false, writable: true }); } /** * Create a copy of this collection. * * @param schema - If defined, overwrites the original's schema */ clone(schema) { const copy = Object.create(Object.getPrototypeOf(this), Object.getOwnPropertyDescriptors(this)); if (schema) copy.schema = schema; copy.items = copy.items.map((it) => identity.isNode(it) || identity.isPair(it) ? it.clone(schema) : it); if (this.range) copy.range = this.range.slice(); return copy; } /** * Adds a value to the collection. For `!!map` and `!!omap` the value must * be a Pair instance or a `{ key, value }` object, which may not have a key * that already exists in the map. */ addIn(path, value) { if (isEmptyPath(path)) this.add(value); else { const [key, ...rest] = path; const node = this.get(key, true); if (identity.isCollection(node)) node.addIn(rest, value); else if (node === void 0 && this.schema) this.set(key, collectionFromPath(this.schema, rest, value)); else throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`); } } /** * Removes a value from the collection. * @returns `true` if the item was found and removed. */ deleteIn(path) { const [key, ...rest] = path; if (rest.length === 0) return this.delete(key); const node = this.get(key, true); if (identity.isCollection(node)) return node.deleteIn(rest); else throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`); } /** * Returns item at `key`, or `undefined` if not found. By default unwraps * scalar values from their surrounding node; to disable set `keepScalar` to * `true` (collections are always returned intact). */ getIn(path, keepScalar) { const [key, ...rest] = path; const node = this.get(key, true); if (rest.length === 0) return !keepScalar && identity.isScalar(node) ? node.value : node; else return identity.isCollection(node) ? node.getIn(rest, keepScalar) : void 0; } hasAllNullValues(allowScalar) { return this.items.every((node) => { if (!identity.isPair(node)) return false; const n = node.value; return n == null || allowScalar && identity.isScalar(n) && n.value == null && !n.commentBefore && !n.comment && !n.tag; }); } /** * Checks if the collection includes a value with the key `key`. */ hasIn(path) { const [key, ...rest] = path; if (rest.length === 0) return this.has(key); const node = this.get(key, true); return identity.isCollection(node) ? node.hasIn(rest) : false; } /** * Sets a value in this collection. For `!!set`, `value` needs to be a * boolean to add/remove the item from the set. */ setIn(path, value) { const [key, ...rest] = path; if (rest.length === 0) this.set(key, value); else { const node = this.get(key, true); if (identity.isCollection(node)) node.setIn(rest, value); else if (node === void 0 && this.schema) this.set(key, collectionFromPath(this.schema, rest, value)); else throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`); } } }; exports.Collection = Collection; exports.collectionFromPath = collectionFromPath; exports.isEmptyPath = isEmptyPath; })); //#endregion //#region node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/stringify/stringifyComment.js var require_stringifyComment = /* @__PURE__ */ __commonJSMin(((exports) => { /** * Stringifies a comment. * * Empty comment lines are left empty, * lines consisting of a single space are replaced by `#`, * and all other lines are prefixed with a `#`. */ const stringifyComment = (str) => str.replace(/^(?!$)(?: $)?/gm, "#"); function indentComment(comment, indent) { if (/^\n+$/.test(comment)) return comment.substring(1); return indent ? comment.replace(/^(?! *$)/gm, indent) : comment; } const lineComment = (str, indent, comment) => str.endsWith("\n") ? indentComment(comment, indent) : comment.includes("\n") ? "\n" + indentComment(comment, indent) : (str.endsWith(" ") ? "" : " ") + comment; exports.indentComment = indentComment; exports.lineComment = lineComment; exports.stringifyComment = stringifyComment; })); //#endregion //#region node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/stringify/foldFlowLines.js var require_foldFlowLines = /* @__PURE__ */ __commonJSMin(((exports) => { const FOLD_FLOW = "flow"; const FOLD_BLOCK = "block"; const FOLD_QUOTED = "quoted"; /** * Tries to keep input at up to `lineWidth` characters, splitting only on spaces * not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are * terminated with `\n` and started with `indent`. */ function foldFlowLines(text, indent, mode = "flow", { indentAtStart, lineWidth = 80, minContentWidth = 20, onFold, onOverflow } = {}) { if (!lineWidth || lineWidth < 0) return text; if (lineWidth < minContentWidth) minContentWidth = 0; const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length); if (text.length <= endStep) return text; const folds = []; const escapedFolds = {}; let end = lineWidth - indent.length; if (typeof indentAtStart === "number") if (indentAtStart > lineWidth - Math.max(2, minContentWidth)) folds.push(0); else end = lineWidth - indentAtStart; let split = void 0; let prev = void 0; let overflow = false; let i = -1; let escStart = -1; let escEnd = -1; if (mode === FOLD_BLOCK) { i = consumeMoreIndentedLines(text, i, indent.length); if (i !== -1) end = i + endStep; } for (let ch; ch = text[i += 1];) { if (mode === FOLD_QUOTED && ch === "\\") { escStart = i; switch (text[i + 1]) { case "x": i += 3; break; case "u": i += 5; break; case "U": i += 9; break; default: i += 1; } escEnd = i; } if (ch === "\n") { if (mode === FOLD_BLOCK) i = consumeMoreIndentedLines(text, i, indent.length); end = i + indent.length + endStep; split = void 0; } else { if (ch === " " && prev && prev !== " " && prev !== "\n" && prev !== " ") { const next = text[i + 1]; if (next && next !== " " && next !== "\n" && next !== " ") split = i; } if (i >= end) if (split) { folds.push(split); end = split + endStep; split = void 0; } else if (mode === FOLD_QUOTED) { while (prev === " " || prev === " ") { prev = ch; ch = text[i += 1]; overflow = true; } const j = i > escEnd + 1 ? i - 2 : escStart - 1; if (escapedFolds[j]) return text; folds.push(j); escapedFolds[j] = true; end = j + endStep; split = void 0; } else overflow = true; } prev = ch; } if (overflow && onOverflow) onOverflow(); if (folds.length === 0) return text; if (onFold) onFold(); let res = text.slice(0, folds[0]); for (let i = 0; i < folds.length; ++i) { const fold = folds[i]; const end = folds[i + 1] || text.length; if (fold === 0) res = `\n${indent}${text.slice(0, end)}`; else { if (mode === FOLD_QUOTED && escapedFolds[fold]) res += `${text[fold]}\\`; res += `\n${indent}${text.slice(fold + 1, end)}`; } } return res; } /** * Presumes `i + 1` is at the start of a line * @returns index of last newline in more-indented block */ function consumeMoreIndentedLines(text, i, indent) { let end = i; let start = i + 1; let ch = text[start]; while (ch === " " || ch === " ") if (i < start + indent) ch = text[++i]; else { do ch = text[++i]; while (ch && ch !== "\n"); end = i; start = i + 1; ch = text[start]; } return end; } exports.FOLD_BLOCK = FOLD_BLOCK; exports.FOLD_FLOW = FOLD_FLOW; exports.FOLD_QUOTED = FOLD_QUOTED; exports.foldFlowLines = foldFlowLines; })); //#endregion //#region node_modules/.pnpm/yaml@2.8.2/node_modules/yaml/dist/stringify/stringifyString.js var require_stringifyString = /* @__PURE__ */ __commonJSMin(((exports) => { var Scalar = require_Scalar(); var foldFlowLines = require_foldFlowLines(); const getFoldOptions = (ctx, isBlock) => ({ indentAtStart: isBlock ? ctx.indent.length : ctx.indentAtStart, lineWidth: ctx.options.lineWidth, minContentWidth: ctx.options.minContentWidth }); const containsDocumentMarker = (str) => /^(%|---|\.\.\.)/m.test(str); function lineLengthOverLimit(str, lineWidth, indentLength) { if (!lineWidth || lineWidth < 0) return false; const limit = lineWidth - indentLength; const strLen = str.length; if (strLen <= limit) return false; for (let i = 0, start = 0; i < strLen; ++i) if (str[i] === "\n") { if (i - start > limit) return true; start = i + 1; if (strLen - start <= limit) return false; } return true; } function doubleQuotedString(value, ctx) { const json = JSON.stringify(value); if (ctx.options.doubleQuotedAsJSON) return json; const { implicitKey } = ctx; const minMultiLineLength = ctx.options.doubleQuotedMinMultiLineLength; const indent = ctx.indent || (containsDocumentMarker(value) ? " " : ""); let str = ""; let start = 0; for (let i = 0, ch = json[i]; ch; ch = json[++i]) { if (ch === " " && json[i + 1] === "\\" && json[i + 2] === "n") { str += json.slice(start, i) + "\\ "; i += 1; start = i; ch = "\\"; } if (ch === "\\") switch (json[i + 1]) { case "u": { str += json.slice(start, i); const code = json.substr(i + 2, 4); switch (code) { case "0000": str += "\\0"; break; case "0007": str += "\\a"; break; case "000b": str += "\\v"; break; case "001b": str += "\\e"; break; case "0085": str += "\\N"; break; case "00a0": str += "\\_"; break; case "2028": str += "\\L"; break; case "2029": str += "\\P"; break; default: if (code.substr(0, 2) === "00") str += "\\x" + code.substr(2); else str += json.substr(i, 6); } i += 5; start = i + 1; } break; case "n": if (implicitKey || json[i + 2] === "\"" || json.length < minMultiLineLength) i += 1; else { str += json.slice(start, i) + "\n\n"; while (json[i + 2] === "\\" && json[i + 3] === "n" && json[i + 4] !== "\"") { str += "\n"; i += 2; } str += indent; if (json[i + 2] === " ") str += "\\"; i += 1; start = i + 1; } break; default: i += 1; } } str = start ? str + json.slice(start) : json; return implicitKey ? str : foldFlowLines.foldFlowLines(str, indent, foldFlowLines.FOLD_QUOTED, getFoldOptions(ctx, false)); } function singleQuotedString(value, ctx) { if (ctx.options.singleQuote === false || ctx.implicitKey && value.includes("\n") || /[ \t]\n|\n[ \t]/.test(value)) return doubleQuotedString(value, ctx); const indent = ctx.indent || (containsDocumentMarker(value) ? " " : ""); const res = "'" + value.replace(/'/g, "''").replace(/\n+/g, `$&\n${indent}`) + "'"; return ctx.implicitKey ? res : foldFlowLines.foldFlowLines(res, indent, foldFlowLines.FOLD_FLOW, getFoldOptions(ctx, false)); } function quotedString(value, ctx) { const { singleQuote } = ctx.options; let qs; if (singleQuote === false) qs = doubleQuotedString; else { const hasDouble = value.includes("\""); const hasSingle = value.includes("'"); if (hasDouble && !hasSingle) qs = singleQuotedString; else if (hasSingle && !hasDouble) qs = doubleQuotedString; else qs = singleQuote ? singleQuotedString : doubleQuotedString; } return qs(value, ctx); } let blockEndNewlines; try { blockEndNewlines = /* @__PURE__ */ new RegExp("(^|(?<!\n))\n+(?!\n|$)", "g"); } catch { blockEndNewlines = /\n+(?!\n|$)/g; } function blockString({ comment, type, value }, ctx, onComment, onChompKeep) { const { blockQuote, commentString, lineWidth } = ctx.options; if (!blockQuote || /\n[\t ]+$/.test(value)) return quotedString(value, ctx); const indent = ctx.indent || (ctx.forceBlockIndent || containsDocumentMarker(value) ? " " : ""); const literal = blockQuote === "literal" ? true : blockQuote === "folded" || type === Scalar.Scalar.BLOCK_FOLDED ? false : type === Scalar.Scalar.BLOCK_LITERAL ? true : !lineLengthOverLimit(value, lineWidth, indent.length); if (!value) return literal ? "|\n" : ">\n"; let chomp; let endStart; for (endStart = value.length; endStart > 0; --endStart) { const ch = value[endStart - 1]; if (ch !== "\n" && ch !== " " && ch !== " ") break; } let end = value.substring(endStart); const endNlPos = end.indexOf("\n"); if (endNlPos === -1) chomp = "-"; else if (value === end || endNlPos !== end.length - 1) { chomp = "+"; if (onChompKeep) onChompKeep(); } else chomp = ""; if (end) { value = value.slice(0, -end.length); if (end[end.length - 1] === "\n") end = end.slice(0, -1); end = end.replace(blockEndNewlines, `$&${indent}`); } let startWithSpace = false; let startEnd; let startNlPos = -1; for (startEnd = 0; startEnd < value.length; ++startEnd) { const ch = value[startEnd]; if (ch === " ") startWithSpace = true; else if (ch === "\n") startNlPos = startEnd; else break; } let start = value.substring(0, startNlPos < startEnd ? startNlPos + 1 : startEnd); if (start) { value = value.substring(start.length); start = start.replace(/\n+/g, `$&${indent}`); } let header = (startWit