UNPKG

prettier

Version:

Prettier is an opinionated code formatter

1,446 lines (1,407 loc) 445 kB
import { createRequire as __prettierCreateRequire } from "module"; import { fileURLToPath as __prettierFileUrlToPath } from "url"; import { dirname as __prettierDirname } from "path"; const require = __prettierCreateRequire(import.meta.url); const __filename = __prettierFileUrlToPath(import.meta.url); const __dirname = __prettierDirname(__filename); var __defProp = Object.defineProperty; var __getOwnPropNames = Object.getOwnPropertyNames; var __esm = (fn, res) => function __init() { return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; }; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; // scripts/build/shims/shared.js var OPTIONAL_OBJECT, createMethodShim; var init_shared = __esm({ "scripts/build/shims/shared.js"() { OPTIONAL_OBJECT = 1; createMethodShim = (methodName, getImplementation) => (flags, object, ...arguments_) => { if (flags | OPTIONAL_OBJECT && (object === void 0 || object === null)) { return; } const implementation = getImplementation.call(object) ?? object[methodName]; return implementation.apply(object, arguments_); }; } }); // scripts/build/shims/method-replace-all.js var stringReplaceAll, replaceAll, method_replace_all_default; var init_method_replace_all = __esm({ "scripts/build/shims/method-replace-all.js"() { init_shared(); stringReplaceAll = String.prototype.replaceAll ?? function(pattern, replacement) { if (pattern.global) { return this.replace(pattern, replacement); } return this.split(pattern).join(replacement); }; replaceAll = createMethodShim("replaceAll", function() { if (typeof this === "string") { return stringReplaceAll; } }); method_replace_all_default = replaceAll; } }); // node_modules/find-up-path/dist/index.js import fs from "fs"; import path from "path"; import process2 from "process"; var findUpPath, dist_default; var init_dist = __esm({ "node_modules/find-up-path/dist/index.js"() { findUpPath = (fileName, folderPath = process2.cwd(), maxDepth = 25) => { let filePath = path.normalize(path.join(folderPath, fileName)); let depth = 1; while (true) { if (depth > maxDepth) return; if (fs.existsSync(filePath)) return filePath; folderPath = path.resolve(folderPath, ".."); const filePathNext = path.normalize(path.join(folderPath, fileName)); if (filePathNext === filePath) return; filePath = filePathNext; depth += 1; } }; dist_default = findUpPath; } }); // node_modules/find-up-json/dist/utils.js var attempt; var init_utils = __esm({ "node_modules/find-up-json/dist/utils.js"() { attempt = (fn, fallback) => { try { return fn(); } catch { return fallback; } }; } }); // node_modules/find-up-json/dist/index.js import { Buffer as Buffer2 } from "buffer"; import fs2 from "fs"; import process3 from "process"; var findUp, dist_default2; var init_dist2 = __esm({ "node_modules/find-up-json/dist/index.js"() { init_dist(); init_utils(); findUp = (fileName, folderPath = process3.cwd(), maxDepth = 25) => { const path18 = dist_default(fileName, folderPath, maxDepth); if (!path18) return; const buffer2 = attempt(() => fs2.readFileSync(path18), Buffer2.alloc(0)); const content = attempt(() => JSON.parse(buffer2.toString()), {}); return { path: path18, buffer: buffer2, content }; }; dist_default2 = findUp; } }); // node_modules/get-current-package/dist/index.js import fs3 from "fs"; import path2 from "path"; import process4 from "process"; var getCurrentPackage, dist_default3; var init_dist3 = __esm({ "node_modules/get-current-package/dist/index.js"() { init_dist2(); getCurrentPackage = () => { try { const filePath = fs3.realpathSync(process4.argv[1]); const folderPath = path2.dirname(filePath); const pkg = dist_default2("package.json", folderPath); return pkg?.content; } catch { return; } }; dist_default3 = getCurrentPackage; } }); // node_modules/tiny-colors/dist/constants.js var ENV, ARGV, ENABLED; var init_constants = __esm({ "node_modules/tiny-colors/dist/constants.js"() { ENV = globalThis.process?.env || {}; ARGV = globalThis.process?.argv || []; ENABLED = !("NO_COLOR" in ENV) && ENV.COLOR !== "0" && ENV.TERM !== "dumb" && !ARGV.includes("--no-color") && !ARGV.includes("--no-colors") && (ENV.COLOR === "1" || !globalThis.process?.stdout || globalThis.process?.stdout?.isTTY === true); } }); // node_modules/tiny-colors/dist/index.js var chain, wrap, colors, dist_default4; var init_dist4 = __esm({ "node_modules/tiny-colors/dist/index.js"() { init_constants(); chain = (modifier) => { return new Proxy(modifier, { get(target, prop) { if (prop in colors) { return chain((string2) => modifier(colors[prop](string2))); } else { return target[prop]; } } }); }; wrap = (start, end) => { return chain((string2) => { if (!ENABLED) return string2; return `\x1B[${start}m${string2}\x1B[${end}m`; }); }; colors = { /* MODIFIERS */ reset: wrap(0, 0), bold: wrap(1, 22), dim: wrap(2, 22), italic: wrap(3, 23), underline: wrap(4, 24), overline: wrap(53, 55), inverse: wrap(7, 27), hidden: wrap(8, 28), strikethrough: wrap(9, 29), /* FOREGOUND */ black: wrap(30, 39), red: wrap(31, 39), green: wrap(32, 39), yellow: wrap(33, 39), blue: wrap(34, 39), magenta: wrap(35, 39), cyan: wrap(36, 39), white: wrap(37, 39), gray: wrap(90, 39), /* BACKGROUND */ bgBlack: wrap(40, 49), bgRed: wrap(41, 49), bgGreen: wrap(42, 49), bgYellow: wrap(43, 49), bgBlue: wrap(44, 49), bgMagenta: wrap(45, 49), bgCyan: wrap(46, 49), bgWhite: wrap(47, 49), bgGray: wrap(100, 49) }; dist_default4 = colors; } }); // node_modules/tiny-parse-argv/dist/utils.js var castArray, isBoolean, isNil, isNull, isOverridable, isUndefined, setNormal, setVariadic, uniq, uniqBy, without, zip; var init_utils2 = __esm({ "node_modules/tiny-parse-argv/dist/utils.js"() { castArray = (value) => { return Array.isArray(value) ? value : [value]; }; isBoolean = (value) => { return value === true || value === false; }; isNil = (value) => { return value === null || value === void 0; }; isNull = (value) => { return value === null; }; isOverridable = (value) => { return isNil(value) || isBoolean(value) || value === ""; }; isUndefined = (value) => { return value === void 0; }; setNormal = (target, key2, value, override) => { if (override) { target[key2] = value; } else if (Array.isArray(target[key2])) { target[key2].push(value); } else if (isOverridable(target[key2])) { target[key2] = value; } else { target[key2] = [target[key2], value]; } }; setVariadic = (target, key2, value, override) => { const values = castArray(value); if (override) { target[key2] = values; } else if (Array.isArray(target[key2])) { target[key2].push(...values); } else if (isOverridable(target[key2])) { target[key2] = values; } else { target[key2] = [target[key2], ...values]; } }; uniq = (values) => { return Array.from(new Set(values)); }; uniqBy = (values, iterator) => { const ids = /* @__PURE__ */ new Set(); return values.filter((value, index, arr) => { const id = iterator(value, index, arr); if (ids.has(id)) return false; ids.add(id); return true; }); }; without = (values, value) => { return values.filter((other) => other !== value); }; zip = (keys, value) => { return Object.fromEntries(Array.from(keys).map((key2) => [key2, value])); }; } }); // node_modules/tiny-parse-argv/dist/index.js var getAliasesMap, getAliasedMap, getAliasedSet, getAliasedDefaults, getAliasedIncompatibles, setAliased, parseDoubleHyphen, parseWithRegExp, parseCharSeparator, parseEqualsSeparator, parseImplicitSeparator, parseProto, parseOption, parseOptionNegation, parseValue, unquote, parseArgv, dist_default5; var init_dist5 = __esm({ "node_modules/tiny-parse-argv/dist/index.js"() { init_utils2(); getAliasesMap = (aliases = {}) => { const map2 = {}; for (const key2 in aliases) { const values = uniq([key2, ...aliases[key2] || []]); for (const value of values) { if (value in map2) continue; map2[value] = without(values, value); } } return map2; }; getAliasedMap = (aliases, object) => { const map2 = /* @__PURE__ */ new Map(); for (const key2 in object) { const value = object[key2]; if (isUndefined(value)) continue; map2.set(key2, value); const keyAliases = aliases[key2]; if (!keyAliases) continue; for (const key3 of keyAliases) { map2.set(key3, value); } } return map2; }; getAliasedSet = (aliases, values = []) => { const valuesAliases = values.flatMap((value) => aliases[value] || []); const valuesAliased = /* @__PURE__ */ new Set([...values, ...valuesAliases]); return valuesAliased; }; getAliasedDefaults = (aliases, defaults = {}) => { const defaultsAliased = {}; for (const key2 in defaults) { const value = defaults[key2]; const keys = uniq([key2, ...aliases[key2] || []]); for (const key3 of keys) { if (key3 in defaultsAliased) continue; defaultsAliased[key3] = value; } } return defaultsAliased; }; getAliasedIncompatibles = (aliases, incompatibles = {}) => { const incompatiblesAliased = {}; for (const source2 in incompatibles) { const sources = getAliasedSet(aliases, [source2]); const targets = getAliasedSet(aliases, incompatibles[source2]); for (const source3 of sources) { for (const target of targets) { const sourceSet = incompatiblesAliased[source3] || (incompatiblesAliased[source3] = /* @__PURE__ */ new Set()); const targetSet = incompatiblesAliased[target] || (incompatiblesAliased[target] = /* @__PURE__ */ new Set()); sourceSet.add(target); targetSet.add(source3); } } } return incompatiblesAliased; }; setAliased = (target, key2, value, unary, variadic, aliases) => { const set3 = variadic ? setVariadic : setNormal; set3(target, key2, value, unary); aliases[key2]?.forEach((alias) => { set3(target, alias, value, unary); }); }; parseDoubleHyphen = (argv) => { const index = argv.indexOf("--"); if (index < 0) return [argv, []]; const parse8 = argv.slice(0, index); const preserve = argv.slice(index + 1); return [parse8, preserve]; }; parseWithRegExp = (argv, re, callback) => { return argv.flatMap((arg) => { const match2 = re.exec(arg); if (!match2) return arg; return callback(...match2); }); }; parseCharSeparator = (argv) => { const re = /^-([a-zA-Z0-9\.]{2,})([^]*)$/; return parseWithRegExp(argv, re, (_, chars2) => chars2.split("").map((char) => `-${char}`)); }; parseEqualsSeparator = (argv) => { const re = /^(--?[^=][^=]*?)=([^]*)$/; const shieldValue = (value) => value.startsWith("-") ? `"${value}"` : value; return parseWithRegExp(argv, re, (_, key2, value) => [key2, shieldValue(value)]); }; parseImplicitSeparator = (argv) => { const re = /^(--?(?:no-)?\S*?[a-zA-Z]\S*?)((?:[0-9\/]|-(?=$))[^]*)$/; return parseWithRegExp(argv, re, (_, key2, value) => [key2, value]); }; parseProto = (argv) => { const re = /^--?(no-)?(__proto__|prototype|constructor)$/; return argv.filter((arg, index) => !re.test(arg) && !re.test(argv[index - 1])); }; parseOption = (arg) => { const optionRe = /^(--?)([^]+)$/; const match2 = optionRe.exec(arg); if (!match2) return; return match2[2]; }; parseOptionNegation = (arg) => { const negationRe = /^no-([^]+)$/; const match2 = negationRe.exec(arg); if (!match2) return [arg, true]; return [match2[1], false]; }; parseValue = (key2, valueRaw, booleans, integers, numbers, strings, validators) => { const value = unquote(String(valueRaw)); if (validators.get(key2)?.(value) === false) { return null; } if (booleans.has(key2)) { if (value === "true") return true; if (value === "false") return false; } if (integers.has(key2)) { const integer = Number(value); if (Number.isInteger(integer)) return integer; return null; } if (numbers.has(key2)) { const number = Number(value); if (!Number.isNaN(number)) return number; return null; } if (strings.has(key2) || value !== valueRaw) { return value; } const numberRe = /^0[xX][0-9a-fA-F]+$|^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][-+]?\d+)?$/; if (numberRe.test(value)) { return Number(value); } else { return value; } }; unquote = (value) => { return value.replace(/^(['"])(\1*)(.*)(\1\2)$/, "$3"); }; parseArgv = (argv, options = {}) => { const aliases = getAliasesMap(options.alias); const booleans = getAliasedSet(aliases, options.boolean); const integers = getAliasedSet(aliases, options.integer); const numbers = getAliasedSet(aliases, options.number); const strings = getAliasedSet(aliases, options.string); const eagers = getAliasedSet(aliases, options.eager); const unarys = getAliasedSet(aliases, options.unary); const variadics = getAliasedSet(aliases, options.variadic); const defaults = getAliasedDefaults(aliases, options.default); const incompatibles = getAliasedIncompatibles(aliases, options.incompatible); const validators = getAliasedMap(aliases, options.validators); const required = options.required || []; const known = /* @__PURE__ */ new Set([...booleans, ...integers, ...numbers, ...strings, ...Object.keys(defaults)]); const found = []; const onIncompatible = options.onIncompatible; const onInvalid = options.onInvalid; const onMissing = options.onMissing; const onUnknown = options.onUnknown; const [parse8, preserve] = parseDoubleHyphen(argv); const parsed = { _: [], "--": preserve }; const args = parseCharSeparator(parseImplicitSeparator(parseEqualsSeparator(parseProto(parse8)))); let optionPrev = ""; let optionEagerPrev = ""; for (let i = 0, l = args.length; i < l; i++) { const arg = args[i]; const option = parseOption(arg); if (option) { const [key2, positive] = parseOptionNegation(option); if (isOverridable(parsed[key2])) { if (!integers.has(key2) && !numbers.has(key2) && !strings.has(key2)) { const unary = unarys.has(key2); const variadic = variadics.has(key2); const value = variadic ? [positive] : positive; setAliased(parsed, key2, value, unary, variadic, aliases); } } found.push(key2); optionPrev = option; optionEagerPrev = eagers.has(key2) ? option : ""; } else { const value = parseValue(optionPrev, arg, booleans, integers, numbers, strings, validators); if (optionPrev && (!booleans.has(optionPrev) || isBoolean(value))) { if (!isNull(value)) { const unary = unarys.has(optionPrev); const variadic = variadics.has(optionPrev); setAliased(parsed, optionPrev, value, unary, variadic, aliases); } } else if (optionEagerPrev && !booleans.has(optionEagerPrev)) { if (!isNull(value)) { const unary = unarys.has(optionEagerPrev); const variadic = variadics.has(optionEagerPrev); setAliased(parsed, optionEagerPrev, value, unary, variadic, aliases); } } else { parsed._.push(String(value ?? arg)); optionEagerPrev = ""; } optionPrev = ""; } } const parsedWithDefaults = { ...defaults, ...parsed }; const parsedWithDefaultsAndBooleans = { ...zip(booleans, false), ...parsedWithDefaults }; if (onUnknown) { const unknowns = Object.keys(parsedWithDefaults).filter((key2) => key2 !== "_" && key2 !== "--" && !known.has(key2)); if (unknowns.length) { onUnknown(unknowns); } } if (onMissing) { const missings = required.filter((key2) => !(key2 in parsedWithDefaults)); if (missings.length) { onMissing(missings); } } if (onInvalid) { const invalids = found.filter((key2) => parsedWithDefaults[key2] === void 0); if (invalids.length) { onInvalid(invalids); } } if (onIncompatible) { const options2 = uniq(found); const pairs2 = []; for (let si = 0, sl = options2.length; si < sl; si++) { const source2 = options2[si]; const sourceIncompatibles = incompatibles[source2]; if (!sourceIncompatibles) continue; for (let ti = si + 1, tl = sl; ti < tl; ti++) { const target = options2[ti]; if (!sourceIncompatibles.has(target)) continue; pairs2.push([source2, target]); } } if (pairs2.length) { const pairsUnique = uniqBy(pairs2, (pair) => [...pair].sort().join()); onIncompatible(pairsUnique); } } return parsedWithDefaultsAndBooleans; }; dist_default5 = parseArgv; } }); // node_modules/ionstore/dist/utils.js var attempt2; var init_utils3 = __esm({ "node_modules/ionstore/dist/utils.js"() { attempt2 = (fn, fallback) => { try { return fn(); } catch { return fallback; } }; } }); // node_modules/ionstore/dist/abstract.js var __classPrivateFieldSet, __classPrivateFieldGet, _AbstractStore_save, AbstractStore, abstract_default; var init_abstract = __esm({ "node_modules/ionstore/dist/abstract.js"() { init_utils3(); __classPrivateFieldSet = function(receiver, state, value, kind, f) { if (kind === "m") throw new TypeError("Private method is not writable"); if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value; }; __classPrivateFieldGet = function(receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); }; AbstractStore = class extends Map { /* CONSTRUCTOR */ constructor(options) { super(); _AbstractStore_save.set(this, void 0); const { id, backend } = options; if (!/^[a-zA-Z0-9_-]+$/.test(id)) throw new Error(`Invalid store id: "${id}"`); const read3 = () => attempt2(() => backend.read(id), []); const write = () => attempt2(() => backend.write(id, this.entries()), null); for (const [key2, value] of read3()) { super.set(key2, value); } __classPrivateFieldSet(this, _AbstractStore_save, write, "f"); return this; } /* API */ clear() { if (!this.size) return; super.clear(); __classPrivateFieldGet(this, _AbstractStore_save, "f").call(this); } delete(key2) { const deleted = super.delete(key2); if (!deleted) return false; __classPrivateFieldGet(this, _AbstractStore_save, "f").call(this); return true; } set(key2, value) { const valuePrev = this.get(key2); if (value === valuePrev) return this; super.set(key2, value); __classPrivateFieldGet(this, _AbstractStore_save, "f").call(this); return this; } }; _AbstractStore_save = /* @__PURE__ */ new WeakMap(); abstract_default = AbstractStore; } }); // node_modules/ionstore/dist/node.js import fs4 from "fs"; import os from "os"; import path3 from "path"; var NodeStore, node_default; var init_node = __esm({ "node_modules/ionstore/dist/node.js"() { init_abstract(); NodeStore = class extends abstract_default { /* CONSTRUCTOR */ constructor(id) { super({ id, backend: { read: (id2) => { const filePath = path3.join(os.tmpdir(), `ionstore_${id2}.json`); const content = fs4.readFileSync(filePath, "utf8"); return JSON.parse(content); }, write: (id2, data) => { const filePath = path3.join(os.tmpdir(), `ionstore_${id2}.json`); const content = JSON.stringify(Array.from(data)); return fs4.writeFileSync(filePath, content); } } }); } }; node_default = NodeStore; } }); // node_modules/when-exit/dist/node/constants.js import process5 from "process"; var IS_LINUX, IS_WINDOWS; var init_constants2 = __esm({ "node_modules/when-exit/dist/node/constants.js"() { IS_LINUX = process5.platform === "linux"; IS_WINDOWS = process5.platform === "win32"; } }); // node_modules/when-exit/dist/node/signals.js var Signals, signals_default; var init_signals = __esm({ "node_modules/when-exit/dist/node/signals.js"() { init_constants2(); Signals = ["SIGHUP", "SIGINT", "SIGTERM"]; if (!IS_WINDOWS) { Signals.push("SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT"); } if (IS_LINUX) { Signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT"); } signals_default = Signals; } }); // node_modules/when-exit/dist/node/interceptor.js import process6 from "process"; var Interceptor, interceptor_default; var init_interceptor = __esm({ "node_modules/when-exit/dist/node/interceptor.js"() { init_constants2(); init_signals(); Interceptor = class { /* CONSTRUCTOR */ constructor() { this.callbacks = /* @__PURE__ */ new Set(); this.exited = false; this.exit = (signal) => { if (this.exited) return; this.exited = true; for (const callback of this.callbacks) { callback(); } if (signal) { if (IS_WINDOWS && (signal !== "SIGINT" && signal !== "SIGTERM" && signal !== "SIGKILL")) { process6.kill(process6.pid, "SIGTERM"); } else { process6.kill(process6.pid, signal); } } }; this.hook = () => { process6.once("exit", () => this.exit()); for (const signal of signals_default) { try { process6.once(signal, () => this.exit(signal)); } catch { } } }; this.register = (callback) => { this.callbacks.add(callback); return () => { this.callbacks.delete(callback); }; }; this.hook(); } }; interceptor_default = new Interceptor(); } }); // node_modules/when-exit/dist/node/index.js var whenExit, node_default2; var init_node2 = __esm({ "node_modules/when-exit/dist/node/index.js"() { init_interceptor(); whenExit = interceptor_default.register; node_default2 = whenExit; } }); // node_modules/tiny-updater/dist/compare.js var compare, compare_default; var init_compare = __esm({ "node_modules/tiny-updater/dist/compare.js"() { compare = (a, b) => { const pa = a.split("."); const pb = b.split("."); for (let i = 0; i < 3; i++) { let na = Number(pa[i]); let nb = Number(pb[i]); if (na > nb) return 1; if (nb > na) return -1; if (!isNaN(na) && isNaN(nb)) return 1; if (isNaN(na) && !isNaN(nb)) return -1; } return 0; }; compare_default = compare; } }); // node_modules/tiny-updater/dist/utils.js var Utils, utils_default; var init_utils4 = __esm({ "node_modules/tiny-updater/dist/utils.js"() { init_dist4(); init_node2(); init_compare(); Utils = { /* API */ fetch: async (url3) => { const signal = Utils.getExitSignal(); const request = await fetch(url3, { signal }); const json2 = await request.json(); return json2; }, getExitSignal: () => { const aborter = new AbortController(); node_default2(() => aborter.abort()); return aborter.signal; }, getLatestVersion: async (name) => { const latestUrl = `https://registry.npmjs.org/${name}/latest`; const latest = await Utils.fetch(latestUrl); return latest.version; }, isNumber: (value) => { return typeof value === "number"; }, isString: (value) => { return typeof value === "string"; }, isUpdateAvailable: (current, latest) => { return compare_default(current, latest) === -1; }, noop: () => { return; }, notify: (name, version, latest) => { if (!globalThis.process?.stdout?.isTTY) return; const log = () => console.log(` \u{1F4E6} Update available for ${dist_default4.cyan(name)}: ${dist_default4.gray(version)} \u2192 ${dist_default4.green(latest)}`); node_default2(log); } }; utils_default = Utils; } }); // node_modules/tiny-updater/dist/store.js var Store, store_default; var init_store = __esm({ "node_modules/tiny-updater/dist/store.js"() { init_node(); init_utils4(); Store = class { constructor() { this.store = new node_default("tiny-updater"); this.get = (name) => { try { const recordRaw = this.store.get(name); if (!recordRaw) return; const record = JSON.parse(recordRaw); if (!utils_default.isNumber(record.timestampFetch)) return; if (!utils_default.isNumber(record.timestampNotification)) return; if (!utils_default.isString(record.version)) return; return record; } catch { return; } }; this.set = (name, record) => { this.store.set(name, JSON.stringify(record)); }; } }; store_default = new Store(); } }); // node_modules/tiny-updater/dist/index.js var updater, dist_default6; var init_dist6 = __esm({ "node_modules/tiny-updater/dist/index.js"() { init_store(); init_utils4(); updater = async ({ name, version, ttl = 0 }) => { const record = store_default.get(name); const timestamp2 = Date.now(); const isFresh = !record || timestamp2 - record.timestampFetch >= ttl; const latest = isFresh ? await utils_default.getLatestVersion(name).catch(utils_default.noop) : record?.version; if (!latest) return false; if (isFresh) { const record2 = { timestampFetch: timestamp2, timestampNotification: timestamp2, version: latest }; store_default.set(name, record2); } if (!utils_default.isUpdateAvailable(version, latest)) { return false; } if (isFresh) { utils_default.notify(name, version, latest); } return true; }; dist_default6 = updater; } }); // node_modules/fast-string-truncated-width/dist/utils.js var getCodePointsLength, isFullWidth, isWideNotCJKTNotEmoji; var init_utils5 = __esm({ "node_modules/fast-string-truncated-width/dist/utils.js"() { getCodePointsLength = /* @__PURE__ */ (() => { const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g; return (input) => { let surrogatePairsNr = 0; SURROGATE_PAIR_RE.lastIndex = 0; while (SURROGATE_PAIR_RE.test(input)) { surrogatePairsNr += 1; } return input.length - surrogatePairsNr; }; })(); isFullWidth = (x) => { return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510; }; isWideNotCJKTNotEmoji = (x) => { return x === 8987 || x === 9001 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141; }; } }); // node_modules/fast-string-truncated-width/dist/index.js var ANSI_RE, CONTROL_RE, CJKT_WIDE_RE, TAB_RE, EMOJI_RE, LATIN_RE, MODIFIER_RE, NO_TRUNCATION, getStringTruncatedWidth, dist_default7; var init_dist7 = __esm({ "node_modules/fast-string-truncated-width/dist/index.js"() { init_method_replace_all(); init_utils5(); ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y; CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y; CJKT_WIDE_RE = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu; TAB_RE = /\t{1,1000}/y; EMOJI_RE = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu; LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y; MODIFIER_RE = /\p{M}+/gu; NO_TRUNCATION = { limit: Infinity, ellipsis: "" }; getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => { const LIMIT = truncationOptions.limit ?? Infinity; const ELLIPSIS2 = truncationOptions.ellipsis ?? ""; const ELLIPSIS_WIDTH2 = truncationOptions?.ellipsisWidth ?? (ELLIPSIS2 ? getStringTruncatedWidth(ELLIPSIS2, NO_TRUNCATION, widthOptions).width : 0); const ANSI_WIDTH = 0; const CONTROL_WIDTH = widthOptions.controlWidth ?? 0; const TAB_WIDTH = widthOptions.tabWidth ?? 8; const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2; const FULL_WIDTH_WIDTH = 2; const REGULAR_WIDTH = widthOptions.regularWidth ?? 1; const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH; const PARSE_BLOCKS = [[LATIN_RE, REGULAR_WIDTH], [ANSI_RE, ANSI_WIDTH], [CONTROL_RE, CONTROL_WIDTH], [TAB_RE, TAB_WIDTH], [EMOJI_RE, EMOJI_WIDTH], [CJKT_WIDE_RE, WIDE_WIDTH]]; let indexPrev = 0; let index = 0; let length = input.length; let lengthExtra = 0; let truncationEnabled = false; let truncationIndex = length; let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH2); let unmatchedStart = 0; let unmatchedEnd = 0; let width = 0; let widthExtra = 0; outer: while (true) { if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) { const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index); lengthExtra = 0; for (const char of method_replace_all_default( /* OPTIONAL_OBJECT: false */ 0, unmatched, MODIFIER_RE, "" )) { const codePoint = char.codePointAt(0) || 0; if (isFullWidth(codePoint)) { widthExtra = FULL_WIDTH_WIDTH; } else if (isWideNotCJKTNotEmoji(codePoint)) { widthExtra = WIDE_WIDTH; } else { widthExtra = REGULAR_WIDTH; } if (width + widthExtra > truncationLimit) { truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra); } if (width + widthExtra > LIMIT) { truncationEnabled = true; break outer; } lengthExtra += char.length; width += widthExtra; } unmatchedStart = unmatchedEnd = 0; } if (index >= length) { break outer; } for (let i = 0, l = PARSE_BLOCKS.length; i < l; i++) { const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i]; BLOCK_RE.lastIndex = index; if (BLOCK_RE.test(input)) { lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index; widthExtra = lengthExtra * BLOCK_WIDTH; if (width + widthExtra > truncationLimit) { truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH)); } if (width + widthExtra > LIMIT) { truncationEnabled = true; break outer; } width += widthExtra; unmatchedStart = indexPrev; unmatchedEnd = index; index = indexPrev = BLOCK_RE.lastIndex; continue outer; } } index += 1; } return { width: truncationEnabled ? truncationLimit : width, index: truncationEnabled ? truncationIndex : length, truncated: truncationEnabled, ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH2 }; }; dist_default7 = getStringTruncatedWidth; } }); // node_modules/fast-string-width/dist/index.js var NO_TRUNCATION2, fastStringWidth, dist_default8; var init_dist8 = __esm({ "node_modules/fast-string-width/dist/index.js"() { init_dist7(); NO_TRUNCATION2 = { limit: Infinity, ellipsis: "", ellipsisWidth: 0 }; fastStringWidth = (input, options = {}) => { return dist_default7(input, NO_TRUNCATION2, options).width; }; dist_default8 = fastStringWidth; } }); // node_modules/tiny-bin/dist/objects/addon.js var Addon, addon_default; var init_addon = __esm({ "node_modules/tiny-bin/dist/objects/addon.js"() { Addon = class { /* CONSTRUCTOR */ constructor(bin2) { this.bin = bin2; this.stdout = bin2.stdout; this.stderr = bin2.stderr; } }; addon_default = Addon; } }); // node_modules/ansi-purge/dist/constants.js var ANSI_RE2; var init_constants3 = __esm({ "node_modules/ansi-purge/dist/constants.js"() { ANSI_RE2 = /([\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c))/g; } }); // node_modules/ansi-purge/dist/index.js var purge, dist_default9; var init_dist9 = __esm({ "node_modules/ansi-purge/dist/index.js"() { init_constants3(); purge = (str2) => { return str2.replace(ANSI_RE2, ""); }; dist_default9 = purge; } }); // node_modules/tiny-levenshtein/dist/matrix.js var Matrix, matrix_default; var init_matrix = __esm({ "node_modules/tiny-levenshtein/dist/matrix.js"() { Matrix = class { /* CONSTRUCTOR */ constructor(rows, columns, Buffer3 = Uint32Array) { this.rows = rows; this.columns = columns; this.buffer = new Buffer3(this.rows * this.columns); } /* API */ get(row, column2) { const index = row * this.columns + column2; return this.buffer[index]; } set(row, column2, value) { const index = row * this.columns + column2; return this.buffer[index] = value; } }; matrix_default = Matrix; } }); // node_modules/tiny-levenshtein/dist/index.js var levenshtein, dist_default10; var init_dist10 = __esm({ "node_modules/tiny-levenshtein/dist/index.js"() { init_matrix(); levenshtein = (a, b) => { if (a === b) return 0; let start = 0; let aEnd = a.length - 1; let bEnd = b.length - 1; while (start <= aEnd && start <= bEnd) { if (a[start] !== b[start]) break; start += 1; } while (aEnd >= start && bEnd >= start) { if (a[aEnd] !== b[bEnd]) break; aEnd -= 1; bEnd -= 1; } const aLength = aEnd - start + 1; const bLength = bEnd - start + 1; if (!aLength) return bLength; if (!bLength) return aLength; const maxDistance = Math.max(aLength, bLength); const Buffer3 = maxDistance < 255 ? Uint8Array : maxDistance < 65535 ? Uint16Array : Uint32Array; const matrix = new matrix_default(aLength + 1, bLength + 1, Buffer3); for (let i = 1, l = aLength; i <= l; i++) { matrix.set(i, 0, i); } for (let i = 1, l = bLength; i <= l; i++) { matrix.set(0, i, i); } for (let i = 1; i <= aLength; i++) { for (let j = 1; j <= bLength; j++) { const cost = a[start + i - 1] === b[start + j - 1] ? 0 : 1; const deletion = matrix.get(i - 1, j) + 1; const insertion = matrix.get(i, j - 1) + 1; const substitution = matrix.get(i - 1, j - 1) + cost; const value = Math.min(deletion, insertion, substitution); matrix.set(i, j, value); } } const distance = matrix.get(aLength, bLength); return distance; }; dist_default10 = levenshtein; } }); // node_modules/tiny-bin/dist/utils.js var camelCase, castArray2, defer, getClosest, groupBy, identity, isArray, isUndefined2, pushBack, sum; var init_utils6 = __esm({ "node_modules/tiny-bin/dist/utils.js"() { init_dist9(); init_dist10(); camelCase = /* @__PURE__ */ (() => { const dividerRe = /[_.\s-]+/g; const prefixRe = /^[_.\s-]+/g; const upperDigitRe = /\d+[\p{Alpha}\p{N}_]/gu; const upperDividerRe = /[_.\s-]+[\p{Alpha}\p{N}_]/gu; const toUpperCase = (str2) => str2.toUpperCase(); return (str2) => { return str2.trim().toLowerCase().replace(prefixRe, "").replace(upperDigitRe, toUpperCase).replace(upperDividerRe, toUpperCase).replace(dividerRe, ""); }; })(); castArray2 = (value) => { return Array.isArray(value) ? value : [value]; }; defer = (fn) => { setTimeout(fn, 0); }; getClosest = (values, value, maxDistance = 3, caseInsensitive = false) => { if (!values.length) return; const target = caseInsensitive ? value.toLowerCase() : value; const targets = caseInsensitive ? values.map((value2) => value2.toLowerCase()) : values; const distances = targets.map((other) => dist_default10(target, other)); const minDistance = Math.min(...distances); if (minDistance > maxDistance) return; const minDistanceIndex = distances.indexOf(minDistance); const closest = values[minDistanceIndex]; return closest; }; groupBy = (values, iterator) => { const groups = /* @__PURE__ */ new Map(); for (let i = 0, l = values.length; i < l; i++) { const value = values[i]; const key2 = iterator(value, i, values); const group = groups.get(key2) || []; group.push(value); groups.set(key2, group); } return groups; }; identity = (value) => { return value; }; isArray = (value) => { return Array.isArray(value); }; isUndefined2 = (value) => { return value === void 0; }; pushBack = (map2, key2) => { const value = map2.get(key2); if (isUndefined2(value)) return map2; map2.delete(key2); map2.set(key2, value); return map2; }; sum = (numbers) => { return numbers.reduce((acc, value) => acc + value, 0); }; } }); // node_modules/tiny-bin/dist/objects/logger.js var Logger, logger_default; var init_logger = __esm({ "node_modules/tiny-bin/dist/objects/logger.js"() { init_dist8(); init_dist4(); init_addon(); init_utils6(); Logger = class extends addon_default { /* CONSTRUCTOR */ constructor(bin2, handler) { super(bin2); this.indentationLevel = 0; this.indentation = " "; this.handler = handler; } /* API */ indent() { this.indentationLevel += 1; } dedent() { this.indentationLevel -= 1; } group(name, fn) { this.print(dist_default4.bold(name.toUpperCase())); this.indent(); this.print(); fn(); this.print(); this.dedent(); } print(message = "") { const colorize = this.bin.metadata.colors ? identity : dist_default9; this.handler(colorize(`${this.indentation.repeat(this.indentationLevel)}${message}`)); } table(rows, mode = "line") { const rowsLengths = rows.map((row) => row.map((cell) => dist_default8(cell))); const maxLengths = rowsLengths[0].map((_, j) => Math.max(...rowsLengths.map((_2, i) => rowsLengths[i][j]))); if (mode === "lines" && maxLengths.length === 2) { const COLUMN = 30; const PADDING = 4; rows.forEach(([left, right], i) => { const leftNedded = dist_default8(left) + PADDING; const leftAvailable = COLUMN - leftNedded; const leftShortEnough = leftAvailable >= 2; const rightLines = right.trim().split(/\r?\n|\r/g); const line2 = [left, rightLines.map((line3, i2) => leftShortEnough && !i2 ? `${" ".repeat(leftAvailable)}${line3}` : `${i2 ? "" : "\n"}${" ".repeat(COLUMN)}${line3}`).join("\n")].join(""); this.print(line2); }); } else if (mode === "line") { rows.forEach((row, i) => { const line2 = row.map((value, j) => { const paddingLength = j === row.length - 1 ? 0 : Math.max(0, 1 + maxLengths[j] - rowsLengths[i][j]); const padding = " ".repeat(paddingLength); return `${value}${padding}`; }).join(" "); this.print(line2); }); } else { throw new Error("Unsupported printing mode"); } } }; logger_default = Logger; } }); // node_modules/tiny-bin/dist/objects/metadata.js var Metadata, metadata_default; var init_metadata = __esm({ "node_modules/tiny-bin/dist/objects/metadata.js"() { init_dist4(); init_addon(); Metadata = class extends addon_default { constructor() { super(...arguments); this.name = "bin"; this.description = ""; this.package = ""; this.version = "0.0.0"; this.colors = true; this.exiter = true; this.updater = true; } /* API */ print() { this.stdout.print(`${dist_default4.cyan(this.name)} ${dist_default4.dim(this.version)}`); this.stdout.print(); } }; metadata_default = Metadata; } }); // node_modules/tiny-bin/dist/objects/collection.js var Collection, collection_default; var init_collection = __esm({ "node_modules/tiny-bin/dist/objects/collection.js"() { init_addon(); init_utils6(); Collection = class extends addon_default { constructor() { super(...arguments); this.list = []; this.map = /* @__PURE__ */ new Map(); } /* API */ getAll() { return this.list; } getById(id) { return this.getByIds([id])?.value; } getByIdOrFail(id) { const value = this.getById(id); if (value) return value; const ids = Array.from(this.map.keys()); const closest = getClosest(ids, id, 3, true); this.bin.fail(`Not found "${id}"${closest ? `. Did you mean "${closest}"?` : ""}`); } getByIds(ids) { for (const id of ids) { const value = this.map.get(id); if (value) return { id, value }; } } register(value, override = false) { const existing = this.getByIds(value.ids); if (existing && override) { const index = this.list.indexOf(existing.value); existing.value.ids.forEach((id) => this.map.delete(id)); value.ids.forEach((id) => this.map.set(id, value)); this.list.splice(index, 1, value); } else { value.ids.forEach((id) => this.map.set(id, value)); this.list.push(value); } } }; collection_default = Collection; } }); // node_modules/tiny-bin/dist/objects/commands.js var Commands, commands_default; var init_commands = __esm({ "node_modules/tiny-bin/dist/objects/commands.js"() { init_dist4(); init_collection(); init_utils6(); Commands = class extends collection_default { /* API */ print(mode) { const commands = this.getAll(); if (!commands.length) return; const commandsVisible = commands.filter((command) => !command.hidden); if (!commandsVisible.length) return; const withoutOther = (section) => section.toLowerCase() !== "other" ? section : ""; const commandsBySection = pushBack(groupBy(commandsVisible, (command) => withoutOther(command.section.toLowerCase())), ""); commandsBySection.forEach((commands2, section) => { if (!commands2.length) return; const title = section ? `${section.toUpperCase()} COMMANDS` : commandsBySection.size > 1 ? "OTHER COMMANDS" : "COMMANDS"; const table = commands2.map((command) => { const withDeprecated = command.deprecated ? dist_default4.dim : identity; return [ [ dist_default4.magenta(command.name), ...command.arguments.getAll().map((arg) => dist_default4.yellow(arg.name)) ].join(" "), command.description ].map(withDeprecated); }); this.stdout.group(title, () => { this.stdout.table(table, mode); }); }); } run(name, options, argv) { const command = this.getByIdOrFail(name); return command.run(options, argv); } }; commands_default = Commands; } }); // node_modules/tiny-bin/dist/objects/arguments.js var Arguments, arguments_default; var init_arguments = __esm({ "node_modules/tiny-bin/dist/objects/arguments.js"() { init_dist4(); init_collection(); Arguments = class extends collection_default { /* API */ print(mode) { const args = this.getAll(); if (!args.length) return; const table = args.map((arg) => [ dist_default4.yellow(arg.name), arg.description ]); this.stdout.group("ARGUMENTS", () => { this.stdout.table(table, mode); }); } }; arguments_default = Arguments; } }); // node_modules/tiny-bin/dist/objects/options.js var Options, options_default; var init_options = __esm({ "node_modules/tiny-bin/dist/objects/options.js"() { init_dist4(); init_collection(); init_utils6(); Options = class extends collection_default { /* API */ print(mode) { const options = this.getAll(); if (!options.length) return; const optionsVisible = options.filter((option) => !option.hidden); if (!optionsVisible.length) return; const withoutOther = (section) => section.toLowerCase() !== "other" ? section : ""; const optionsBySection = pushBack(groupBy(optionsVisible, (option) => withoutOther(option.section.toLowerCase())), ""); optionsBySection.forEach((options2, section) => { if (!options2.length) return; const title = section ? `${section.toUpperCase()} OPTIONS` : optionsBySection.size > 1 ? "OTHER OPTIONS" : "OPTIONS"; const table = options2.map((option) => { const withDeprecated = option.deprecated ? dist_default4.dim : identity; return [ [ [ ...option.data.longs.sort().map((long) => dist_default4.green(`--${long}`)), ...option.data.shorts.sort().map((short) => dist_default4.green(`-${short}`)) ].join(", "), [