UNPKG

corepack

Version:
1,234 lines (1,228 loc) 963 kB
"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 __esm = (fn2, res) => function __init() { return fn2 && (res = (0, fn2[__getOwnPropNames(fn2)[0]])(fn2 = 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 name2 in all) __defProp(target, name2, { get: all[name2], 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 )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // .yarn/cache/typanion-npm-3.14.0-8af344c436-8b03b19844.zip/node_modules/typanion/lib/index.mjs var lib_exports = {}; __export(lib_exports, { KeyRelationship: () => KeyRelationship, TypeAssertionError: () => TypeAssertionError, applyCascade: () => applyCascade, as: () => as, assert: () => assert, assertWithErrors: () => assertWithErrors, cascade: () => cascade, fn: () => fn, hasAtLeastOneKey: () => hasAtLeastOneKey, hasExactLength: () => hasExactLength, hasForbiddenKeys: () => hasForbiddenKeys, hasKeyRelationship: () => hasKeyRelationship, hasMaxLength: () => hasMaxLength, hasMinLength: () => hasMinLength, hasMutuallyExclusiveKeys: () => hasMutuallyExclusiveKeys, hasRequiredKeys: () => hasRequiredKeys, hasUniqueItems: () => hasUniqueItems, isArray: () => isArray, isAtLeast: () => isAtLeast, isAtMost: () => isAtMost, isBase64: () => isBase64, isBoolean: () => isBoolean, isDate: () => isDate, isDict: () => isDict, isEnum: () => isEnum, isHexColor: () => isHexColor, isISO8601: () => isISO8601, isInExclusiveRange: () => isInExclusiveRange, isInInclusiveRange: () => isInInclusiveRange, isInstanceOf: () => isInstanceOf, isInteger: () => isInteger, isJSON: () => isJSON, isLiteral: () => isLiteral, isLowerCase: () => isLowerCase, isMap: () => isMap, isNegative: () => isNegative, isNullable: () => isNullable, isNumber: () => isNumber, isObject: () => isObject, isOneOf: () => isOneOf, isOptional: () => isOptional, isPartial: () => isPartial, isPayload: () => isPayload, isPositive: () => isPositive, isRecord: () => isRecord, isSet: () => isSet, isString: () => isString, isTuple: () => isTuple, isUUID4: () => isUUID4, isUnknown: () => isUnknown, isUpperCase: () => isUpperCase, makeTrait: () => makeTrait, makeValidator: () => makeValidator, matchesRegExp: () => matchesRegExp, softAssert: () => softAssert }); function getPrintable(value) { if (value === null) return `null`; if (value === void 0) return `undefined`; if (value === ``) return `an empty string`; if (typeof value === "symbol") return `<${value.toString()}>`; if (Array.isArray(value)) return `an array`; return JSON.stringify(value); } function getPrintableArray(value, conjunction) { if (value.length === 0) return `nothing`; if (value.length === 1) return getPrintable(value[0]); const rest = value.slice(0, -1); const trailing = value[value.length - 1]; const separator = value.length > 2 ? `, ${conjunction} ` : ` ${conjunction} `; return `${rest.map((value2) => getPrintable(value2)).join(`, `)}${separator}${getPrintable(trailing)}`; } function computeKey(state, key) { var _a, _b, _c; if (typeof key === `number`) { return `${(_a = state === null || state === void 0 ? void 0 : state.p) !== null && _a !== void 0 ? _a : `.`}[${key}]`; } else if (simpleKeyRegExp.test(key)) { return `${(_b = state === null || state === void 0 ? void 0 : state.p) !== null && _b !== void 0 ? _b : ``}.${key}`; } else { return `${(_c = state === null || state === void 0 ? void 0 : state.p) !== null && _c !== void 0 ? _c : `.`}[${JSON.stringify(key)}]`; } } function plural(n, singular, plural2) { return n === 1 ? singular : plural2; } function pushError({ errors, p } = {}, message) { errors === null || errors === void 0 ? void 0 : errors.push(`${p !== null && p !== void 0 ? p : `.`}: ${message}`); return false; } function makeSetter(target, key) { return (v) => { target[key] = v; }; } function makeCoercionFn(target, key) { return (v) => { const previous = target[key]; target[key] = v; return makeCoercionFn(target, key).bind(null, previous); }; } function makeLazyCoercionFn(fn2, orig, generator) { const commit = () => { fn2(generator()); return revert; }; const revert = () => { fn2(orig); return commit; }; return commit; } function isUnknown() { return makeValidator({ test: (value, state) => { return true; } }); } function isLiteral(expected) { return makeValidator({ test: (value, state) => { if (value !== expected) return pushError(state, `Expected ${getPrintable(expected)} (got ${getPrintable(value)})`); return true; } }); } function isString() { return makeValidator({ test: (value, state) => { if (typeof value !== `string`) return pushError(state, `Expected a string (got ${getPrintable(value)})`); return true; } }); } function isEnum(enumSpec) { const valuesArray = Array.isArray(enumSpec) ? enumSpec : Object.values(enumSpec); const isAlphaNum = valuesArray.every((item) => typeof item === "string" || typeof item === "number"); const values = new Set(valuesArray); if (values.size === 1) return isLiteral([...values][0]); return makeValidator({ test: (value, state) => { if (!values.has(value)) { if (isAlphaNum) { return pushError(state, `Expected one of ${getPrintableArray(valuesArray, `or`)} (got ${getPrintable(value)})`); } else { return pushError(state, `Expected a valid enumeration value (got ${getPrintable(value)})`); } } return true; } }); } function isBoolean() { return makeValidator({ test: (value, state) => { var _a; if (typeof value !== `boolean`) { if (typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined`) { if (typeof (state === null || state === void 0 ? void 0 : state.coercion) === `undefined`) return pushError(state, `Unbound coercion result`); const coercion = BOOLEAN_COERCIONS.get(value); if (typeof coercion !== `undefined`) { state.coercions.push([(_a = state.p) !== null && _a !== void 0 ? _a : `.`, state.coercion.bind(null, coercion)]); return true; } } return pushError(state, `Expected a boolean (got ${getPrintable(value)})`); } return true; } }); } function isNumber() { return makeValidator({ test: (value, state) => { var _a; if (typeof value !== `number`) { if (typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined`) { if (typeof (state === null || state === void 0 ? void 0 : state.coercion) === `undefined`) return pushError(state, `Unbound coercion result`); let coercion; if (typeof value === `string`) { let val; try { val = JSON.parse(value); } catch (_b) { } if (typeof val === `number`) { if (JSON.stringify(val) === value) { coercion = val; } else { return pushError(state, `Received a number that can't be safely represented by the runtime (${value})`); } } } if (typeof coercion !== `undefined`) { state.coercions.push([(_a = state.p) !== null && _a !== void 0 ? _a : `.`, state.coercion.bind(null, coercion)]); return true; } } return pushError(state, `Expected a number (got ${getPrintable(value)})`); } return true; } }); } function isPayload(spec) { return makeValidator({ test: (value, state) => { var _a; if (typeof (state === null || state === void 0 ? void 0 : state.coercions) === `undefined`) return pushError(state, `The isPayload predicate can only be used with coercion enabled`); if (typeof state.coercion === `undefined`) return pushError(state, `Unbound coercion result`); if (typeof value !== `string`) return pushError(state, `Expected a string (got ${getPrintable(value)})`); let inner; try { inner = JSON.parse(value); } catch (_b) { return pushError(state, `Expected a JSON string (got ${getPrintable(value)})`); } const wrapper = { value: inner }; if (!spec(inner, Object.assign(Object.assign({}, state), { coercion: makeCoercionFn(wrapper, `value`) }))) return false; state.coercions.push([(_a = state.p) !== null && _a !== void 0 ? _a : `.`, state.coercion.bind(null, wrapper.value)]); return true; } }); } function isDate() { return makeValidator({ test: (value, state) => { var _a; if (!(value instanceof Date)) { if (typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined`) { if (typeof (state === null || state === void 0 ? void 0 : state.coercion) === `undefined`) return pushError(state, `Unbound coercion result`); let coercion; if (typeof value === `string` && iso8601RegExp.test(value)) { coercion = new Date(value); } else { let timestamp; if (typeof value === `string`) { let val; try { val = JSON.parse(value); } catch (_b) { } if (typeof val === `number`) { timestamp = val; } } else if (typeof value === `number`) { timestamp = value; } if (typeof timestamp !== `undefined`) { if (Number.isSafeInteger(timestamp) || !Number.isSafeInteger(timestamp * 1e3)) { coercion = new Date(timestamp * 1e3); } else { return pushError(state, `Received a timestamp that can't be safely represented by the runtime (${value})`); } } } if (typeof coercion !== `undefined`) { state.coercions.push([(_a = state.p) !== null && _a !== void 0 ? _a : `.`, state.coercion.bind(null, coercion)]); return true; } } return pushError(state, `Expected a date (got ${getPrintable(value)})`); } return true; } }); } function isArray(spec, { delimiter } = {}) { return makeValidator({ test: (value, state) => { var _a; const originalValue = value; if (typeof value === `string` && typeof delimiter !== `undefined`) { if (typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined`) { if (typeof (state === null || state === void 0 ? void 0 : state.coercion) === `undefined`) return pushError(state, `Unbound coercion result`); value = value.split(delimiter); } } if (!Array.isArray(value)) return pushError(state, `Expected an array (got ${getPrintable(value)})`); let valid = true; for (let t = 0, T = value.length; t < T; ++t) { valid = spec(value[t], Object.assign(Object.assign({}, state), { p: computeKey(state, t), coercion: makeCoercionFn(value, t) })) && valid; if (!valid && (state === null || state === void 0 ? void 0 : state.errors) == null) { break; } } if (value !== originalValue) state.coercions.push([(_a = state.p) !== null && _a !== void 0 ? _a : `.`, state.coercion.bind(null, value)]); return valid; } }); } function isSet(spec, { delimiter } = {}) { const isArrayValidator = isArray(spec, { delimiter }); return makeValidator({ test: (value, state) => { var _a, _b; if (Object.getPrototypeOf(value).toString() === `[object Set]`) { if (typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined`) { if (typeof (state === null || state === void 0 ? void 0 : state.coercion) === `undefined`) return pushError(state, `Unbound coercion result`); const originalValues = [...value]; const coercedValues = [...value]; if (!isArrayValidator(coercedValues, Object.assign(Object.assign({}, state), { coercion: void 0 }))) return false; const updateValue = () => coercedValues.some((val, t) => val !== originalValues[t]) ? new Set(coercedValues) : value; state.coercions.push([(_a = state.p) !== null && _a !== void 0 ? _a : `.`, makeLazyCoercionFn(state.coercion, value, updateValue)]); return true; } else { let valid = true; for (const subValue of value) { valid = spec(subValue, Object.assign({}, state)) && valid; if (!valid && (state === null || state === void 0 ? void 0 : state.errors) == null) { break; } } return valid; } } if (typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined`) { if (typeof (state === null || state === void 0 ? void 0 : state.coercion) === `undefined`) return pushError(state, `Unbound coercion result`); const store = { value }; if (!isArrayValidator(value, Object.assign(Object.assign({}, state), { coercion: makeCoercionFn(store, `value`) }))) return false; state.coercions.push([(_b = state.p) !== null && _b !== void 0 ? _b : `.`, makeLazyCoercionFn(state.coercion, value, () => new Set(store.value))]); return true; } return pushError(state, `Expected a set (got ${getPrintable(value)})`); } }); } function isMap(keySpec, valueSpec) { const isArrayValidator = isArray(isTuple([keySpec, valueSpec])); const isRecordValidator = isRecord(valueSpec, { keys: keySpec }); return makeValidator({ test: (value, state) => { var _a, _b, _c; if (Object.getPrototypeOf(value).toString() === `[object Map]`) { if (typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined`) { if (typeof (state === null || state === void 0 ? void 0 : state.coercion) === `undefined`) return pushError(state, `Unbound coercion result`); const originalValues = [...value]; const coercedValues = [...value]; if (!isArrayValidator(coercedValues, Object.assign(Object.assign({}, state), { coercion: void 0 }))) return false; const updateValue = () => coercedValues.some((val, t) => val[0] !== originalValues[t][0] || val[1] !== originalValues[t][1]) ? new Map(coercedValues) : value; state.coercions.push([(_a = state.p) !== null && _a !== void 0 ? _a : `.`, makeLazyCoercionFn(state.coercion, value, updateValue)]); return true; } else { let valid = true; for (const [key, subValue] of value) { valid = keySpec(key, Object.assign({}, state)) && valid; if (!valid && (state === null || state === void 0 ? void 0 : state.errors) == null) { break; } valid = valueSpec(subValue, Object.assign(Object.assign({}, state), { p: computeKey(state, key) })) && valid; if (!valid && (state === null || state === void 0 ? void 0 : state.errors) == null) { break; } } return valid; } } if (typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined`) { if (typeof (state === null || state === void 0 ? void 0 : state.coercion) === `undefined`) return pushError(state, `Unbound coercion result`); const store = { value }; if (Array.isArray(value)) { if (!isArrayValidator(value, Object.assign(Object.assign({}, state), { coercion: void 0 }))) return false; state.coercions.push([(_b = state.p) !== null && _b !== void 0 ? _b : `.`, makeLazyCoercionFn(state.coercion, value, () => new Map(store.value))]); return true; } else { if (!isRecordValidator(value, Object.assign(Object.assign({}, state), { coercion: makeCoercionFn(store, `value`) }))) return false; state.coercions.push([(_c = state.p) !== null && _c !== void 0 ? _c : `.`, makeLazyCoercionFn(state.coercion, value, () => new Map(Object.entries(store.value)))]); return true; } } return pushError(state, `Expected a map (got ${getPrintable(value)})`); } }); } function isTuple(spec, { delimiter } = {}) { const lengthValidator = hasExactLength(spec.length); return makeValidator({ test: (value, state) => { var _a; if (typeof value === `string` && typeof delimiter !== `undefined`) { if (typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined`) { if (typeof (state === null || state === void 0 ? void 0 : state.coercion) === `undefined`) return pushError(state, `Unbound coercion result`); value = value.split(delimiter); state.coercions.push([(_a = state.p) !== null && _a !== void 0 ? _a : `.`, state.coercion.bind(null, value)]); } } if (!Array.isArray(value)) return pushError(state, `Expected a tuple (got ${getPrintable(value)})`); let valid = lengthValidator(value, Object.assign({}, state)); for (let t = 0, T = value.length; t < T && t < spec.length; ++t) { valid = spec[t](value[t], Object.assign(Object.assign({}, state), { p: computeKey(state, t), coercion: makeCoercionFn(value, t) })) && valid; if (!valid && (state === null || state === void 0 ? void 0 : state.errors) == null) { break; } } return valid; } }); } function isRecord(spec, { keys: keySpec = null } = {}) { const isArrayValidator = isArray(isTuple([keySpec !== null && keySpec !== void 0 ? keySpec : isString(), spec])); return makeValidator({ test: (value, state) => { var _a; if (Array.isArray(value)) { if (typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined`) { if (typeof (state === null || state === void 0 ? void 0 : state.coercion) === `undefined`) return pushError(state, `Unbound coercion result`); if (!isArrayValidator(value, Object.assign(Object.assign({}, state), { coercion: void 0 }))) return false; value = Object.fromEntries(value); state.coercions.push([(_a = state.p) !== null && _a !== void 0 ? _a : `.`, state.coercion.bind(null, value)]); return true; } } if (typeof value !== `object` || value === null) return pushError(state, `Expected an object (got ${getPrintable(value)})`); const keys = Object.keys(value); let valid = true; for (let t = 0, T = keys.length; t < T && (valid || (state === null || state === void 0 ? void 0 : state.errors) != null); ++t) { const key = keys[t]; const sub = value[key]; if (key === `__proto__` || key === `constructor`) { valid = pushError(Object.assign(Object.assign({}, state), { p: computeKey(state, key) }), `Unsafe property name`); continue; } if (keySpec !== null && !keySpec(key, state)) { valid = false; continue; } if (!spec(sub, Object.assign(Object.assign({}, state), { p: computeKey(state, key), coercion: makeCoercionFn(value, key) }))) { valid = false; continue; } } return valid; } }); } function isDict(spec, opts = {}) { return isRecord(spec, opts); } function isObject(props, { extra: extraSpec = null } = {}) { const specKeys = Object.keys(props); const validator = makeValidator({ test: (value, state) => { if (typeof value !== `object` || value === null) return pushError(state, `Expected an object (got ${getPrintable(value)})`); const keys = /* @__PURE__ */ new Set([...specKeys, ...Object.keys(value)]); const extra = {}; let valid = true; for (const key of keys) { if (key === `constructor` || key === `__proto__`) { valid = pushError(Object.assign(Object.assign({}, state), { p: computeKey(state, key) }), `Unsafe property name`); } else { const spec = Object.prototype.hasOwnProperty.call(props, key) ? props[key] : void 0; const sub = Object.prototype.hasOwnProperty.call(value, key) ? value[key] : void 0; if (typeof spec !== `undefined`) { valid = spec(sub, Object.assign(Object.assign({}, state), { p: computeKey(state, key), coercion: makeCoercionFn(value, key) })) && valid; } else if (extraSpec === null) { valid = pushError(Object.assign(Object.assign({}, state), { p: computeKey(state, key) }), `Extraneous property (got ${getPrintable(sub)})`); } else { Object.defineProperty(extra, key, { enumerable: true, get: () => sub, set: makeSetter(value, key) }); } } if (!valid && (state === null || state === void 0 ? void 0 : state.errors) == null) { break; } } if (extraSpec !== null && (valid || (state === null || state === void 0 ? void 0 : state.errors) != null)) valid = extraSpec(extra, state) && valid; return valid; } }); return Object.assign(validator, { properties: props }); } function isPartial(props) { return isObject(props, { extra: isRecord(isUnknown()) }); } function makeTrait(value) { return () => { return value; }; } function makeValidator({ test }) { return makeTrait(test)(); } function assert(val, validator) { if (!validator(val)) { throw new TypeAssertionError(); } } function assertWithErrors(val, validator) { const errors = []; if (!validator(val, { errors })) { throw new TypeAssertionError({ errors }); } } function softAssert(val, validator) { } function as(value, validator, { coerce = false, errors: storeErrors, throw: throws } = {}) { const errors = storeErrors ? [] : void 0; if (!coerce) { if (validator(value, { errors })) { return throws ? value : { value, errors: void 0 }; } else if (!throws) { return { value: void 0, errors: errors !== null && errors !== void 0 ? errors : true }; } else { throw new TypeAssertionError({ errors }); } } const state = { value }; const coercion = makeCoercionFn(state, `value`); const coercions = []; if (!validator(value, { errors, coercion, coercions })) { if (!throws) { return { value: void 0, errors: errors !== null && errors !== void 0 ? errors : true }; } else { throw new TypeAssertionError({ errors }); } } for (const [, apply] of coercions) apply(); if (throws) { return state.value; } else { return { value: state.value, errors: void 0 }; } } function fn(validators, fn2) { const isValidArgList = isTuple(validators); return (...args) => { const check = isValidArgList(args); if (!check) throw new TypeAssertionError(); return fn2(...args); }; } function hasMinLength(length) { return makeValidator({ test: (value, state) => { if (!(value.length >= length)) return pushError(state, `Expected to have a length of at least ${length} elements (got ${value.length})`); return true; } }); } function hasMaxLength(length) { return makeValidator({ test: (value, state) => { if (!(value.length <= length)) return pushError(state, `Expected to have a length of at most ${length} elements (got ${value.length})`); return true; } }); } function hasExactLength(length) { return makeValidator({ test: (value, state) => { if (!(value.length === length)) return pushError(state, `Expected to have a length of exactly ${length} elements (got ${value.length})`); return true; } }); } function hasUniqueItems({ map } = {}) { return makeValidator({ test: (value, state) => { const set = /* @__PURE__ */ new Set(); const dup = /* @__PURE__ */ new Set(); for (let t = 0, T = value.length; t < T; ++t) { const sub = value[t]; const key = typeof map !== `undefined` ? map(sub) : sub; if (set.has(key)) { if (dup.has(key)) continue; pushError(state, `Expected to contain unique elements; got a duplicate with ${getPrintable(value)}`); dup.add(key); } else { set.add(key); } } return dup.size === 0; } }); } function isNegative() { return makeValidator({ test: (value, state) => { if (!(value <= 0)) return pushError(state, `Expected to be negative (got ${value})`); return true; } }); } function isPositive() { return makeValidator({ test: (value, state) => { if (!(value >= 0)) return pushError(state, `Expected to be positive (got ${value})`); return true; } }); } function isAtLeast(n) { return makeValidator({ test: (value, state) => { if (!(value >= n)) return pushError(state, `Expected to be at least ${n} (got ${value})`); return true; } }); } function isAtMost(n) { return makeValidator({ test: (value, state) => { if (!(value <= n)) return pushError(state, `Expected to be at most ${n} (got ${value})`); return true; } }); } function isInInclusiveRange(a, b) { return makeValidator({ test: (value, state) => { if (!(value >= a && value <= b)) return pushError(state, `Expected to be in the [${a}; ${b}] range (got ${value})`); return true; } }); } function isInExclusiveRange(a, b) { return makeValidator({ test: (value, state) => { if (!(value >= a && value < b)) return pushError(state, `Expected to be in the [${a}; ${b}[ range (got ${value})`); return true; } }); } function isInteger({ unsafe = false } = {}) { return makeValidator({ test: (value, state) => { if (value !== Math.round(value)) return pushError(state, `Expected to be an integer (got ${value})`); if (!unsafe && !Number.isSafeInteger(value)) return pushError(state, `Expected to be a safe integer (got ${value})`); return true; } }); } function matchesRegExp(regExp) { return makeValidator({ test: (value, state) => { if (!regExp.test(value)) return pushError(state, `Expected to match the pattern ${regExp.toString()} (got ${getPrintable(value)})`); return true; } }); } function isLowerCase() { return makeValidator({ test: (value, state) => { if (value !== value.toLowerCase()) return pushError(state, `Expected to be all-lowercase (got ${value})`); return true; } }); } function isUpperCase() { return makeValidator({ test: (value, state) => { if (value !== value.toUpperCase()) return pushError(state, `Expected to be all-uppercase (got ${value})`); return true; } }); } function isUUID4() { return makeValidator({ test: (value, state) => { if (!uuid4RegExp.test(value)) return pushError(state, `Expected to be a valid UUID v4 (got ${getPrintable(value)})`); return true; } }); } function isISO8601() { return makeValidator({ test: (value, state) => { if (!iso8601RegExp.test(value)) return pushError(state, `Expected to be a valid ISO 8601 date string (got ${getPrintable(value)})`); return true; } }); } function isHexColor({ alpha = false }) { return makeValidator({ test: (value, state) => { const res = alpha ? colorStringRegExp.test(value) : colorStringAlphaRegExp.test(value); if (!res) return pushError(state, `Expected to be a valid hexadecimal color string (got ${getPrintable(value)})`); return true; } }); } function isBase64() { return makeValidator({ test: (value, state) => { if (!base64RegExp.test(value)) return pushError(state, `Expected to be a valid base 64 string (got ${getPrintable(value)})`); return true; } }); } function isJSON(spec = isUnknown()) { return makeValidator({ test: (value, state) => { let data; try { data = JSON.parse(value); } catch (_a) { return pushError(state, `Expected to be a valid JSON string (got ${getPrintable(value)})`); } return spec(data, state); } }); } function cascade(spec, ...followups) { const resolvedFollowups = Array.isArray(followups[0]) ? followups[0] : followups; return makeValidator({ test: (value, state) => { var _a, _b; const context = { value }; const subCoercion = typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined` ? makeCoercionFn(context, `value`) : void 0; const subCoercions = typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined` ? [] : void 0; if (!spec(value, Object.assign(Object.assign({}, state), { coercion: subCoercion, coercions: subCoercions }))) return false; const reverts = []; if (typeof subCoercions !== `undefined`) for (const [, coercion] of subCoercions) reverts.push(coercion()); try { if (typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined`) { if (context.value !== value) { if (typeof (state === null || state === void 0 ? void 0 : state.coercion) === `undefined`) return pushError(state, `Unbound coercion result`); state.coercions.push([(_a = state.p) !== null && _a !== void 0 ? _a : `.`, state.coercion.bind(null, context.value)]); } (_b = state === null || state === void 0 ? void 0 : state.coercions) === null || _b === void 0 ? void 0 : _b.push(...subCoercions); } return resolvedFollowups.every((spec2) => { return spec2(context.value, state); }); } finally { for (const revert of reverts) { revert(); } } } }); } function applyCascade(spec, ...followups) { const resolvedFollowups = Array.isArray(followups[0]) ? followups[0] : followups; return cascade(spec, resolvedFollowups); } function isOptional(spec) { return makeValidator({ test: (value, state) => { if (typeof value === `undefined`) return true; return spec(value, state); } }); } function isNullable(spec) { return makeValidator({ test: (value, state) => { if (value === null) return true; return spec(value, state); } }); } function hasRequiredKeys(requiredKeys, options) { var _a; const requiredSet = new Set(requiredKeys); const check = checks[(_a = options === null || options === void 0 ? void 0 : options.missingIf) !== null && _a !== void 0 ? _a : "missing"]; return makeValidator({ test: (value, state) => { const keys = new Set(Object.keys(value)); const problems = []; for (const key of requiredSet) if (!check(keys, key, value)) problems.push(key); if (problems.length > 0) return pushError(state, `Missing required ${plural(problems.length, `property`, `properties`)} ${getPrintableArray(problems, `and`)}`); return true; } }); } function hasAtLeastOneKey(requiredKeys, options) { var _a; const requiredSet = new Set(requiredKeys); const check = checks[(_a = options === null || options === void 0 ? void 0 : options.missingIf) !== null && _a !== void 0 ? _a : "missing"]; return makeValidator({ test: (value, state) => { const keys = Object.keys(value); const valid = keys.some((key) => check(requiredSet, key, value)); if (!valid) return pushError(state, `Missing at least one property from ${getPrintableArray(Array.from(requiredSet), `or`)}`); return true; } }); } function hasForbiddenKeys(forbiddenKeys, options) { var _a; const forbiddenSet = new Set(forbiddenKeys); const check = checks[(_a = options === null || options === void 0 ? void 0 : options.missingIf) !== null && _a !== void 0 ? _a : "missing"]; return makeValidator({ test: (value, state) => { const keys = new Set(Object.keys(value)); const problems = []; for (const key of forbiddenSet) if (check(keys, key, value)) problems.push(key); if (problems.length > 0) return pushError(state, `Forbidden ${plural(problems.length, `property`, `properties`)} ${getPrintableArray(problems, `and`)}`); return true; } }); } function hasMutuallyExclusiveKeys(exclusiveKeys, options) { var _a; const exclusiveSet = new Set(exclusiveKeys); const check = checks[(_a = options === null || options === void 0 ? void 0 : options.missingIf) !== null && _a !== void 0 ? _a : "missing"]; return makeValidator({ test: (value, state) => { const keys = new Set(Object.keys(value)); const used = []; for (const key of exclusiveSet) if (check(keys, key, value)) used.push(key); if (used.length > 1) return pushError(state, `Mutually exclusive properties ${getPrintableArray(used, `and`)}`); return true; } }); } function hasKeyRelationship(subject, relationship, others, options) { var _a, _b; const skipped = new Set((_a = options === null || options === void 0 ? void 0 : options.ignore) !== null && _a !== void 0 ? _a : []); const check = checks[(_b = options === null || options === void 0 ? void 0 : options.missingIf) !== null && _b !== void 0 ? _b : "missing"]; const otherSet = new Set(others); const spec = keyRelationships[relationship]; const conjunction = relationship === KeyRelationship.Forbids ? `or` : `and`; return makeValidator({ test: (value, state) => { const keys = new Set(Object.keys(value)); if (!check(keys, subject, value) || skipped.has(value[subject])) return true; const problems = []; for (const key of otherSet) if ((check(keys, key, value) && !skipped.has(value[key])) !== spec.expect) problems.push(key); if (problems.length >= 1) return pushError(state, `Property "${subject}" ${spec.message} ${plural(problems.length, `property`, `properties`)} ${getPrintableArray(problems, conjunction)}`); return true; } }); } var simpleKeyRegExp, colorStringRegExp, colorStringAlphaRegExp, base64RegExp, uuid4RegExp, iso8601RegExp, BOOLEAN_COERCIONS, isInstanceOf, isOneOf, TypeAssertionError, checks, KeyRelationship, keyRelationships; var init_lib = __esm({ ".yarn/cache/typanion-npm-3.14.0-8af344c436-8b03b19844.zip/node_modules/typanion/lib/index.mjs"() { simpleKeyRegExp = /^[a-zA-Z_][a-zA-Z0-9_]*$/; colorStringRegExp = /^#[0-9a-f]{6}$/i; colorStringAlphaRegExp = /^#[0-9a-f]{6}([0-9a-f]{2})?$/i; base64RegExp = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/; uuid4RegExp = /^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}$/i; iso8601RegExp = /^(?:[1-9]\d{3}(-?)(?:(?:0[1-9]|1[0-2])\1(?:0[1-9]|1\d|2[0-8])|(?:0[13-9]|1[0-2])\1(?:29|30)|(?:0[13578]|1[02])(?:\1)31|00[1-9]|0[1-9]\d|[12]\d{2}|3(?:[0-5]\d|6[0-5]))|(?:[1-9]\d(?:0[48]|[2468][048]|[13579][26])|(?:[2468][048]|[13579][26])00)(?:(-?)02(?:\2)29|-?366))T(?:[01]\d|2[0-3])(:?)[0-5]\d(?:\3[0-5]\d)?(?:Z|[+-][01]\d(?:\3[0-5]\d)?)$/; BOOLEAN_COERCIONS = /* @__PURE__ */ new Map([ [`true`, true], [`True`, true], [`1`, true], [1, true], [`false`, false], [`False`, false], [`0`, false], [0, false] ]); isInstanceOf = (constructor) => makeValidator({ test: (value, state) => { if (!(value instanceof constructor)) return pushError(state, `Expected an instance of ${constructor.name} (got ${getPrintable(value)})`); return true; } }); isOneOf = (specs, { exclusive = false } = {}) => makeValidator({ test: (value, state) => { var _a, _b, _c; const matches = []; const errorBuffer = typeof (state === null || state === void 0 ? void 0 : state.errors) !== `undefined` ? [] : void 0; for (let t = 0, T = specs.length; t < T; ++t) { const subErrors = typeof (state === null || state === void 0 ? void 0 : state.errors) !== `undefined` ? [] : void 0; const subCoercions = typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined` ? [] : void 0; if (specs[t](value, Object.assign(Object.assign({}, state), { errors: subErrors, coercions: subCoercions, p: `${(_a = state === null || state === void 0 ? void 0 : state.p) !== null && _a !== void 0 ? _a : `.`}#${t + 1}` }))) { matches.push([`#${t + 1}`, subCoercions]); if (!exclusive) { break; } } else { errorBuffer === null || errorBuffer === void 0 ? void 0 : errorBuffer.push(subErrors[0]); } } if (matches.length === 1) { const [, subCoercions] = matches[0]; if (typeof subCoercions !== `undefined`) (_b = state === null || state === void 0 ? void 0 : state.coercions) === null || _b === void 0 ? void 0 : _b.push(...subCoercions); return true; } if (matches.length > 1) pushError(state, `Expected to match exactly a single predicate (matched ${matches.join(`, `)})`); else (_c = state === null || state === void 0 ? void 0 : state.errors) === null || _c === void 0 ? void 0 : _c.push(...errorBuffer); return false; } }); TypeAssertionError = class extends Error { constructor({ errors } = {}) { let errorMessage = `Type mismatch`; if (errors && errors.length > 0) { errorMessage += ` `; for (const error of errors) { errorMessage += ` - ${error}`; } } super(errorMessage); } }; checks = { missing: (keys, key) => keys.has(key), undefined: (keys, key, value) => keys.has(key) && typeof value[key] !== `undefined`, nil: (keys, key, value) => keys.has(key) && value[key] != null, falsy: (keys, key, value) => keys.has(key) && !!value[key] }; (function(KeyRelationship2) { KeyRelationship2["Forbids"] = "Forbids"; KeyRelationship2["Requires"] = "Requires"; })(KeyRelationship || (KeyRelationship = {})); keyRelationships = { [KeyRelationship.Forbids]: { expect: false, message: `forbids using` }, [KeyRelationship.Requires]: { expect: true, message: `requires using` } }; } }); // .yarn/__virtual__/clipanion-virtual-dbbb3cfe27/0/cache/clipanion-patch-1b1b878e9f-a833a30963.zip/node_modules/clipanion/lib/platform/node.js var require_node = __commonJS({ ".yarn/__virtual__/clipanion-virtual-dbbb3cfe27/0/cache/clipanion-patch-1b1b878e9f-a833a30963.zip/node_modules/clipanion/lib/platform/node.js"(exports2) { "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); var tty2 = require("tty"); function _interopDefaultLegacy(e) { return e && typeof e === "object" && "default" in e ? e : { "default": e }; } var tty__default = /* @__PURE__ */ _interopDefaultLegacy(tty2); function getDefaultColorDepth2() { if (tty__default["default"] && `getColorDepth` in tty__default["default"].WriteStream.prototype) return tty__default["default"].WriteStream.prototype.getColorDepth(); if (process.env.FORCE_COLOR === `0`) return 1; if (process.env.FORCE_COLOR === `1`) return 8; if (typeof process.stdout !== `undefined` && process.stdout.isTTY) return 8; return 1; } var gContextStorage; function getCaptureActivator2(context) { let contextStorage = gContextStorage; if (typeof contextStorage === `undefined`) { if (context.stdout === process.stdout && context.stderr === process.stderr) return null; const { AsyncLocalStorage: LazyAsyncLocalStorage } = require("async_hooks"); contextStorage = gContextStorage = new LazyAsyncLocalStorage(); const origStdoutWrite = process.stdout._write; process.stdout._write = function(chunk, encoding, cb) { const context2 = contextStorage.getStore(); if (typeof context2 === `undefined`) return origStdoutWrite.call(this, chunk, encoding, cb); return context2.stdout.write(chunk, encoding, cb); }; const origStderrWrite = process.stderr._write; process.stderr._write = function(chunk, encoding, cb) { const context2 = contextStorage.getStore(); if (typeof context2 === `undefined`) return origStderrWrite.call(this, chunk, encoding, cb); return context2.stderr.write(chunk, encoding, cb); }; } return (fn2) => { return contextStorage.run(context, fn2); }; } exports2.getCaptureActivator = getCaptureActivator2; exports2.getDefaultColorDepth = getDefaultColorDepth2; } }); // .yarn/cache/semver-npm-7.7.1-4572475307-fd603a6fb9.zip/node_modules/semver/internal/debug.js var require_debug = __commonJS({ ".yarn/cache/semver-npm-7.7.1-4572475307-fd603a6fb9.zip/node_modules/semver/internal/debug.js"(exports2, module2) { var debug2 = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => { }; module2.exports = debug2; } }); // .yarn/cache/semver-npm-7.7.1-4572475307-fd603a6fb9.zip/node_modules/semver/internal/constants.js var require_constants = __commonJS({ ".yarn/cache/semver-npm-7.7.1-4572475307-fd603a6fb9.zip/node_modules/semver/internal/constants.js"(exports2, module2) { 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 }; } }); // .yarn/cache/semver-npm-7.7.1-4572475307-fd603a6fb9.zip/node_modules/semver/internal/re.js var require_re = __commonJS({ ".yarn/cache/semver-npm-7.7.1-4572475307-fd603a6fb9.zip/node_modules/semver/internal/re.js"(exports2, module2) { var { MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_BUILD_LENGTH, MAX_LENGTH } = require_constants(); var debug2 = 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 = (value) => { for (const [token, max] of safeRegexReplacements) { value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`); } return value; }; var createToken = (name2, value, isGlobal) => { const safe = makeSafeRegex(value); const index = R++; debug2(name2, index, value); t[name2] = 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("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.NUMERICIDENTIFIER]}|${src[t.NONNUMERICIDENTIFIER]})`); createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NUMERICIDENTIFIERLOOSE]}|${src[t.NONNUMERICIDENTIFIER]})`); 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*$"); } }); // .yarn/cache/semver-npm-7.7.1-4572475307-fd603a6fb9.zip/node_modules/semver/internal/parse-options.js var require_parse_options = __commonJS({ ".yarn/cache/semver-npm-7.7.1-4572475307-fd603a6fb9.zip/node_modules/semver/internal/parse-options.js"(exports2, module2) { var looseOption = Object.freeze({ loose: true }); var emptyOpts = Object.freeze({}); var parseOptions = (options) => { if (!options) { return emptyOpts; } if (typeof options !== "object") { return looseOption; } return options; }; modu