UNPKG

@gemini-dock/server

Version:

An extensible Gemini server written in TypeScript

1,531 lines (1,515 loc) 117 kB
#!/usr/bin/env node "use strict"; var __getOwnPropNames = Object.getOwnPropertyNames; var __commonJS = (cb, mod) => function __require() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; // ../../../node_modules/.pnpm/colorette@2.0.20/node_modules/colorette/index.cjs var require_colorette = __commonJS({ "../../../node_modules/.pnpm/colorette@2.0.20/node_modules/colorette/index.cjs"(exports2) { "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); var tty = require("tty"); function _interopNamespace(e) { if (e && e.__esModule) return e; var n = /* @__PURE__ */ Object.create(null); if (e) { Object.keys(e).forEach(function(k) { if (k !== "default") { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, get: function() { return e[k]; } }); } }); } n["default"] = e; return Object.freeze(n); } var tty__namespace = /* @__PURE__ */ _interopNamespace(tty); var { env = {}, argv = [], platform = "" } = typeof process === "undefined" ? {} : process; var isDisabled = "NO_COLOR" in env || argv.includes("--no-color"); var isForced = "FORCE_COLOR" in env || argv.includes("--color"); var isWindows = platform === "win32"; var isDumbTerminal = env.TERM === "dumb"; var isCompatibleTerminal = tty__namespace && tty__namespace.isatty && tty__namespace.isatty(1) && env.TERM && !isDumbTerminal; var isCI = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env); var isColorSupported2 = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI); var replaceClose = (index, string, close, replace, head = string.substring(0, index) + replace, tail = string.substring(index + close.length), next = tail.indexOf(close)) => head + (next < 0 ? tail : replaceClose(next, tail, close, replace)); var clearBleed = (index, string, open, close, replace) => index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close; var filterEmpty = (open, close, replace = open, at = open.length + 1) => (string) => string || !(string === "" || string === void 0) ? clearBleed( ("" + string).indexOf(close, at), string, open, close, replace ) : ""; var init = (open, close, replace) => filterEmpty(`\x1B[${open}m`, `\x1B[${close}m`, replace); var colors2 = { reset: init(0, 0), bold: init(1, 22, "\x1B[22m\x1B[1m"), dim: init(2, 22, "\x1B[22m\x1B[2m"), italic: init(3, 23), underline: init(4, 24), inverse: init(7, 27), hidden: init(8, 28), strikethrough: init(9, 29), black: init(30, 39), red: init(31, 39), green: init(32, 39), yellow: init(33, 39), blue: init(34, 39), magenta: init(35, 39), cyan: init(36, 39), white: init(37, 39), gray: init(90, 39), bgBlack: init(40, 49), bgRed: init(41, 49), bgGreen: init(42, 49), bgYellow: init(43, 49), bgBlue: init(44, 49), bgMagenta: init(45, 49), bgCyan: init(46, 49), bgWhite: init(47, 49), blackBright: init(90, 39), redBright: init(91, 39), greenBright: init(92, 39), yellowBright: init(93, 39), blueBright: init(94, 39), magentaBright: init(95, 39), cyanBright: init(96, 39), whiteBright: init(97, 39), bgBlackBright: init(100, 49), bgRedBright: init(101, 49), bgGreenBright: init(102, 49), bgYellowBright: init(103, 49), bgBlueBright: init(104, 49), bgMagentaBright: init(105, 49), bgCyanBright: init(106, 49), bgWhiteBright: init(107, 49) }; var createColors = ({ useColor = isColorSupported2 } = {}) => useColor ? colors2 : Object.keys(colors2).reduce( (colors3, key) => ({ ...colors3, [key]: String }), {} ); var { reset, bold, dim, italic, underline, inverse, hidden, strikethrough, black, red, green, yellow, blue, magenta, cyan, white, gray, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, blackBright, redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright, whiteBright, bgBlackBright, bgRedBright, bgGreenBright, bgYellowBright, bgBlueBright, bgMagentaBright, bgCyanBright, bgWhiteBright } = createColors(); exports2.bgBlack = bgBlack; exports2.bgBlackBright = bgBlackBright; exports2.bgBlue = bgBlue; exports2.bgBlueBright = bgBlueBright; exports2.bgCyan = bgCyan; exports2.bgCyanBright = bgCyanBright; exports2.bgGreen = bgGreen; exports2.bgGreenBright = bgGreenBright; exports2.bgMagenta = bgMagenta; exports2.bgMagentaBright = bgMagentaBright; exports2.bgRed = bgRed; exports2.bgRedBright = bgRedBright; exports2.bgWhite = bgWhite; exports2.bgWhiteBright = bgWhiteBright; exports2.bgYellow = bgYellow; exports2.bgYellowBright = bgYellowBright; exports2.black = black; exports2.blackBright = blackBright; exports2.blue = blue; exports2.blueBright = blueBright; exports2.bold = bold; exports2.createColors = createColors; exports2.cyan = cyan; exports2.cyanBright = cyanBright; exports2.dim = dim; exports2.gray = gray; exports2.green = green; exports2.greenBright = greenBright; exports2.hidden = hidden; exports2.inverse = inverse; exports2.isColorSupported = isColorSupported2; exports2.italic = italic; exports2.magenta = magenta; exports2.magentaBright = magentaBright; exports2.red = red; exports2.redBright = redBright; exports2.reset = reset; exports2.strikethrough = strikethrough; exports2.underline = underline; exports2.white = white; exports2.whiteBright = whiteBright; exports2.yellow = yellow; exports2.yellowBright = yellowBright; } }); // ../../../node_modules/.pnpm/wrappy@1.0.2/node_modules/wrappy/wrappy.js var require_wrappy = __commonJS({ "../../../node_modules/.pnpm/wrappy@1.0.2/node_modules/wrappy/wrappy.js"(exports2, module2) { module2.exports = wrappy; function wrappy(fn, cb) { if (fn && cb) return wrappy(fn)(cb); if (typeof fn !== "function") throw new TypeError("need wrapper function"); Object.keys(fn).forEach(function(k) { wrapper[k] = fn[k]; }); return wrapper; function wrapper() { var args = new Array(arguments.length); for (var i = 0; i < args.length; i++) { args[i] = arguments[i]; } var ret = fn.apply(this, args); var cb2 = args[args.length - 1]; if (typeof ret === "function" && ret !== cb2) { Object.keys(cb2).forEach(function(k) { ret[k] = cb2[k]; }); } return ret; } } } }); // ../../../node_modules/.pnpm/once@1.4.0/node_modules/once/once.js var require_once = __commonJS({ "../../../node_modules/.pnpm/once@1.4.0/node_modules/once/once.js"(exports2, module2) { var wrappy = require_wrappy(); module2.exports = wrappy(once); module2.exports.strict = wrappy(onceStrict); once.proto = once(function() { Object.defineProperty(Function.prototype, "once", { value: function() { return once(this); }, configurable: true }); Object.defineProperty(Function.prototype, "onceStrict", { value: function() { return onceStrict(this); }, configurable: true }); }); function once(fn) { var f = function() { if (f.called) return f.value; f.called = true; return f.value = fn.apply(this, arguments); }; f.called = false; return f; } function onceStrict(fn) { var f = function() { if (f.called) throw new Error(f.onceError); f.called = true; return f.value = fn.apply(this, arguments); }; var name = fn.name || "Function wrapped with `once`"; f.onceError = name + " shouldn't be called more than once"; f.called = false; return f; } } }); // ../../../node_modules/.pnpm/end-of-stream@1.4.4/node_modules/end-of-stream/index.js var require_end_of_stream = __commonJS({ "../../../node_modules/.pnpm/end-of-stream@1.4.4/node_modules/end-of-stream/index.js"(exports2, module2) { var once = require_once(); var noop = function() { }; var isRequest = function(stream) { return stream.setHeader && typeof stream.abort === "function"; }; var isChildProcess = function(stream) { return stream.stdio && Array.isArray(stream.stdio) && stream.stdio.length === 3; }; var eos = function(stream, opts, callback) { if (typeof opts === "function") return eos(stream, null, opts); if (!opts) opts = {}; callback = once(callback || noop); var ws = stream._writableState; var rs = stream._readableState; var readable = opts.readable || opts.readable !== false && stream.readable; var writable = opts.writable || opts.writable !== false && stream.writable; var cancelled = false; var onlegacyfinish = function() { if (!stream.writable) onfinish(); }; var onfinish = function() { writable = false; if (!readable) callback.call(stream); }; var onend = function() { readable = false; if (!writable) callback.call(stream); }; var onexit = function(exitCode) { callback.call(stream, exitCode ? new Error("exited with error code: " + exitCode) : null); }; var onerror = function(err) { callback.call(stream, err); }; var onclose = function() { process.nextTick(onclosenexttick); }; var onclosenexttick = function() { if (cancelled) return; if (readable && !(rs && (rs.ended && !rs.destroyed))) return callback.call(stream, new Error("premature close")); if (writable && !(ws && (ws.ended && !ws.destroyed))) return callback.call(stream, new Error("premature close")); }; var onrequest = function() { stream.req.on("finish", onfinish); }; if (isRequest(stream)) { stream.on("complete", onfinish); stream.on("abort", onclose); if (stream.req) onrequest(); else stream.on("request", onrequest); } else if (writable && !ws) { stream.on("end", onlegacyfinish); stream.on("close", onlegacyfinish); } if (isChildProcess(stream)) stream.on("exit", onexit); stream.on("end", onend); stream.on("finish", onfinish); if (opts.error !== false) stream.on("error", onerror); stream.on("close", onclose); return function() { cancelled = true; stream.removeListener("complete", onfinish); stream.removeListener("abort", onclose); stream.removeListener("request", onrequest); if (stream.req) stream.req.removeListener("finish", onfinish); stream.removeListener("end", onlegacyfinish); stream.removeListener("close", onlegacyfinish); stream.removeListener("finish", onfinish); stream.removeListener("exit", onexit); stream.removeListener("end", onend); stream.removeListener("error", onerror); stream.removeListener("close", onclose); }; }; module2.exports = eos; } }); // ../../../node_modules/.pnpm/pump@3.0.2/node_modules/pump/index.js var require_pump = __commonJS({ "../../../node_modules/.pnpm/pump@3.0.2/node_modules/pump/index.js"(exports2, module2) { var once = require_once(); var eos = require_end_of_stream(); var fs; try { fs = require("fs"); } catch (e) { } var noop = function() { }; var ancient = /^v?\.0/.test(process.version); var isFn = function(fn) { return typeof fn === "function"; }; var isFS = function(stream) { if (!ancient) return false; if (!fs) return false; return (stream instanceof (fs.ReadStream || noop) || stream instanceof (fs.WriteStream || noop)) && isFn(stream.close); }; var isRequest = function(stream) { return stream.setHeader && isFn(stream.abort); }; var destroyer = function(stream, reading, writing, callback) { callback = once(callback); var closed = false; stream.on("close", function() { closed = true; }); eos(stream, { readable: reading, writable: writing }, function(err) { if (err) return callback(err); closed = true; callback(); }); var destroyed = false; return function(err) { if (closed) return; if (destroyed) return; destroyed = true; if (isFS(stream)) return stream.close(noop); if (isRequest(stream)) return stream.abort(); if (isFn(stream.destroy)) return stream.destroy(); callback(err || new Error("stream was destroyed")); }; }; var call = function(fn) { fn(); }; var pipe = function(from, to) { return from.pipe(to); }; var pump2 = function() { var streams = Array.prototype.slice.call(arguments); var callback = isFn(streams[streams.length - 1] || noop) && streams.pop() || noop; if (Array.isArray(streams[0])) streams = streams[0]; if (streams.length < 2) throw new Error("pump requires two streams per minimum"); var error; var destroys = streams.map(function(stream, i) { var reading = i < streams.length - 1; var writing = i > 0; return destroyer(stream, reading, writing, function(err) { if (!error) error = err; if (err) destroys.forEach(call); if (reading) return; destroys.forEach(call); callback(error); }); }); return streams.reduce(pipe); }; module2.exports = pump2; } }); // ../../../node_modules/.pnpm/split2@4.2.0/node_modules/split2/index.js var require_split2 = __commonJS({ "../../../node_modules/.pnpm/split2@4.2.0/node_modules/split2/index.js"(exports2, module2) { "use strict"; var { Transform: Transform2 } = require("stream"); var { StringDecoder } = require("string_decoder"); var kLast = Symbol("last"); var kDecoder = Symbol("decoder"); function transform(chunk, enc, cb) { let list; if (this.overflow) { const buf = this[kDecoder].write(chunk); list = buf.split(this.matcher); if (list.length === 1) return cb(); list.shift(); this.overflow = false; } else { this[kLast] += this[kDecoder].write(chunk); list = this[kLast].split(this.matcher); } this[kLast] = list.pop(); for (let i = 0; i < list.length; i++) { try { push(this, this.mapper(list[i])); } catch (error) { return cb(error); } } this.overflow = this[kLast].length > this.maxLength; if (this.overflow && !this.skipOverflow) { cb(new Error("maximum buffer reached")); return; } cb(); } function flush(cb) { this[kLast] += this[kDecoder].end(); if (this[kLast]) { try { push(this, this.mapper(this[kLast])); } catch (error) { return cb(error); } } cb(); } function push(self, val) { if (val !== void 0) { self.push(val); } } function noop(incoming) { return incoming; } function split(matcher, mapper, options) { matcher = matcher || /\r?\n/; mapper = mapper || noop; options = options || {}; switch (arguments.length) { case 1: if (typeof matcher === "function") { mapper = matcher; matcher = /\r?\n/; } else if (typeof matcher === "object" && !(matcher instanceof RegExp) && !matcher[Symbol.split]) { options = matcher; matcher = /\r?\n/; } break; case 2: if (typeof matcher === "function") { options = mapper; mapper = matcher; matcher = /\r?\n/; } else if (typeof mapper === "object") { options = mapper; mapper = noop; } } options = Object.assign({}, options); options.autoDestroy = true; options.transform = transform; options.flush = flush; options.readableObjectMode = true; const stream = new Transform2(options); stream[kLast] = ""; stream[kDecoder] = new StringDecoder("utf8"); stream.matcher = matcher; stream.mapper = mapper; stream.maxLength = options.maxLength; stream.skipOverflow = options.skipOverflow || false; stream.overflow = false; stream._destroy = function(err, cb) { this._writableState.errorEmitted = false; cb(err); }; return stream; } module2.exports = split; } }); // ../../../node_modules/.pnpm/pino-abstract-transport@2.0.0/node_modules/pino-abstract-transport/index.js var require_pino_abstract_transport = __commonJS({ "../../../node_modules/.pnpm/pino-abstract-transport@2.0.0/node_modules/pino-abstract-transport/index.js"(exports2, module2) { "use strict"; var metadata = Symbol.for("pino.metadata"); var split = require_split2(); var { Duplex } = require("stream"); var { parentPort, workerData } = require("worker_threads"); function createDeferred() { let resolve; let reject; const promise = new Promise((_resolve, _reject) => { resolve = _resolve; reject = _reject; }); promise.resolve = resolve; promise.reject = reject; return promise; } module2.exports = function build2(fn, opts = {}) { const waitForConfig = opts.expectPinoConfig === true && workerData?.workerData?.pinoWillSendConfig === true; const parseLines = opts.parse === "lines"; const parseLine = typeof opts.parseLine === "function" ? opts.parseLine : JSON.parse; const close = opts.close || defaultClose; const stream = split(function(line) { let value; try { value = parseLine(line); } catch (error) { this.emit("unknown", line, error); return; } if (value === null) { this.emit("unknown", line, "Null value ignored"); return; } if (typeof value !== "object") { value = { data: value, time: Date.now() }; } if (stream[metadata]) { stream.lastTime = value.time; stream.lastLevel = value.level; stream.lastObj = value; } if (parseLines) { return line; } return value; }, { autoDestroy: true }); stream._destroy = function(err, cb) { const promise = close(err, cb); if (promise && typeof promise.then === "function") { promise.then(cb, cb); } }; if (opts.expectPinoConfig === true && workerData?.workerData?.pinoWillSendConfig !== true) { setImmediate(() => { stream.emit("error", new Error("This transport is not compatible with the current version of pino. Please upgrade pino to the latest version.")); }); } if (opts.metadata !== false) { stream[metadata] = true; stream.lastTime = 0; stream.lastLevel = 0; stream.lastObj = null; } if (waitForConfig) { let pinoConfig = {}; const configReceived = createDeferred(); parentPort.on("message", function handleMessage(message) { if (message.code === "PINO_CONFIG") { pinoConfig = message.config; configReceived.resolve(); parentPort.off("message", handleMessage); } }); Object.defineProperties(stream, { levels: { get() { return pinoConfig.levels; } }, messageKey: { get() { return pinoConfig.messageKey; } }, errorKey: { get() { return pinoConfig.errorKey; } } }); return configReceived.then(finish); } return finish(); function finish() { let res = fn(stream); if (res && typeof res.catch === "function") { res.catch((err) => { stream.destroy(err); }); res = null; } else if (opts.enablePipelining && res) { return Duplex.from({ writable: stream, readable: res }); } return stream; } }; function defaultClose(err, cb) { process.nextTick(cb, err); } } }); // ../../../node_modules/.pnpm/pino-pretty@13.0.0/node_modules/pino-pretty/lib/constants.js var require_constants = __commonJS({ "../../../node_modules/.pnpm/pino-pretty@13.0.0/node_modules/pino-pretty/lib/constants.js"(exports2, module2) { "use strict"; module2.exports = { DATE_FORMAT: "yyyy-mm-dd HH:MM:ss.l o", DATE_FORMAT_SIMPLE: "HH:MM:ss.l", /** * @type {K_ERROR_LIKE_KEYS} */ ERROR_LIKE_KEYS: ["err", "error"], MESSAGE_KEY: "msg", LEVEL_KEY: "level", LEVEL_LABEL: "levelLabel", TIMESTAMP_KEY: "time", LEVELS: { default: "USERLVL", 60: "FATAL", 50: "ERROR", 40: "WARN", 30: "INFO", 20: "DEBUG", 10: "TRACE" }, LEVEL_NAMES: { fatal: 60, error: 50, warn: 40, info: 30, debug: 20, trace: 10 }, // Object keys that probably came from a logger like Pino or Bunyan. LOGGER_KEYS: [ "pid", "hostname", "name", "level", "time", "timestamp", "caller" ] }; } }); // ../../../node_modules/.pnpm/pino-pretty@13.0.0/node_modules/pino-pretty/lib/utils/get-level-label-data.js var require_get_level_label_data = __commonJS({ "../../../node_modules/.pnpm/pino-pretty@13.0.0/node_modules/pino-pretty/lib/utils/get-level-label-data.js"(exports2, module2) { "use strict"; module2.exports = getLevelLabelData; var { LEVELS, LEVEL_NAMES } = require_constants(); function getLevelLabelData(useOnlyCustomProps, customLevels, customLevelNames) { const levels = useOnlyCustomProps ? customLevels || LEVELS : Object.assign({}, LEVELS, customLevels); const levelNames = useOnlyCustomProps ? customLevelNames || LEVEL_NAMES : Object.assign({}, LEVEL_NAMES, customLevelNames); return function(level) { let levelNum = "default"; if (Number.isInteger(+level)) { levelNum = Object.prototype.hasOwnProperty.call(levels, level) ? level : levelNum; } else { levelNum = Object.prototype.hasOwnProperty.call(levelNames, level.toLowerCase()) ? levelNames[level.toLowerCase()] : levelNum; } return [levels[levelNum], levelNum]; }; } } }); // ../../../node_modules/.pnpm/pino-pretty@13.0.0/node_modules/pino-pretty/lib/colors.js var require_colors = __commonJS({ "../../../node_modules/.pnpm/pino-pretty@13.0.0/node_modules/pino-pretty/lib/colors.js"(exports2, module2) { "use strict"; var nocolor = (input) => input; var plain = { default: nocolor, 60: nocolor, 50: nocolor, 40: nocolor, 30: nocolor, 20: nocolor, 10: nocolor, message: nocolor, greyMessage: nocolor }; var { createColors } = require_colorette(); var getLevelLabelData = require_get_level_label_data(); var availableColors = createColors({ useColor: true }); var { white, bgRed, red, yellow, green, blue, gray, cyan } = availableColors; var colored = { default: white, 60: bgRed, 50: red, 40: yellow, 30: green, 20: blue, 10: gray, message: cyan, greyMessage: gray }; function resolveCustomColoredColorizer(customColors) { return customColors.reduce( function(agg, [level, color]) { agg[level] = typeof availableColors[color] === "function" ? availableColors[color] : white; return agg; }, { default: white, message: cyan, greyMessage: gray } ); } function colorizeLevel(useOnlyCustomProps) { return function(level, colorizer, { customLevels, customLevelNames } = {}) { const [levelStr, levelNum] = getLevelLabelData(useOnlyCustomProps, customLevels, customLevelNames)(level); return Object.prototype.hasOwnProperty.call(colorizer, levelNum) ? colorizer[levelNum](levelStr) : colorizer.default(levelStr); }; } function plainColorizer(useOnlyCustomProps) { const newPlainColorizer = colorizeLevel(useOnlyCustomProps); const customColoredColorizer = function(level, opts) { return newPlainColorizer(level, plain, opts); }; customColoredColorizer.message = plain.message; customColoredColorizer.greyMessage = plain.greyMessage; customColoredColorizer.colors = createColors({ useColor: false }); return customColoredColorizer; } function coloredColorizer(useOnlyCustomProps) { const newColoredColorizer = colorizeLevel(useOnlyCustomProps); const customColoredColorizer = function(level, opts) { return newColoredColorizer(level, colored, opts); }; customColoredColorizer.message = colored.message; customColoredColorizer.greyMessage = colored.greyMessage; customColoredColorizer.colors = availableColors; return customColoredColorizer; } function customColoredColorizerFactory(customColors, useOnlyCustomProps) { const onlyCustomColored = resolveCustomColoredColorizer(customColors); const customColored = useOnlyCustomProps ? onlyCustomColored : Object.assign({}, colored, onlyCustomColored); const colorizeLevelCustom = colorizeLevel(useOnlyCustomProps); const customColoredColorizer = function(level, opts) { return colorizeLevelCustom(level, customColored, opts); }; customColoredColorizer.colors = availableColors; customColoredColorizer.message = customColoredColorizer.message || customColored.message; customColoredColorizer.greyMessage = customColoredColorizer.greyMessage || customColored.greyMessage; return customColoredColorizer; } module2.exports = function getColorizer(useColors = false, customColors, useOnlyCustomProps) { if (useColors && customColors !== void 0) { return customColoredColorizerFactory(customColors, useOnlyCustomProps); } else if (useColors) { return coloredColorizer(useOnlyCustomProps); } return plainColorizer(useOnlyCustomProps); }; } }); // ../../../node_modules/.pnpm/atomic-sleep@1.0.0/node_modules/atomic-sleep/index.js var require_atomic_sleep = __commonJS({ "../../../node_modules/.pnpm/atomic-sleep@1.0.0/node_modules/atomic-sleep/index.js"(exports2, module2) { "use strict"; if (typeof SharedArrayBuffer !== "undefined" && typeof Atomics !== "undefined") { let sleep = function(ms) { const valid = ms > 0 && ms < Infinity; if (valid === false) { if (typeof ms !== "number" && typeof ms !== "bigint") { throw TypeError("sleep: ms must be a number"); } throw RangeError("sleep: ms must be a number that is greater than 0 but less than Infinity"); } Atomics.wait(nil, 0, 0, Number(ms)); }; const nil = new Int32Array(new SharedArrayBuffer(4)); module2.exports = sleep; } else { let sleep = function(ms) { const valid = ms > 0 && ms < Infinity; if (valid === false) { if (typeof ms !== "number" && typeof ms !== "bigint") { throw TypeError("sleep: ms must be a number"); } throw RangeError("sleep: ms must be a number that is greater than 0 but less than Infinity"); } const target = Date.now() + Number(ms); while (target > Date.now()) { } }; module2.exports = sleep; } } }); // ../../../node_modules/.pnpm/sonic-boom@4.2.0/node_modules/sonic-boom/index.js var require_sonic_boom = __commonJS({ "../../../node_modules/.pnpm/sonic-boom@4.2.0/node_modules/sonic-boom/index.js"(exports2, module2) { "use strict"; var fs = require("fs"); var EventEmitter = require("events"); var inherits = require("util").inherits; var path = require("path"); var sleep = require_atomic_sleep(); var assert = require("assert"); var BUSY_WRITE_TIMEOUT = 100; var kEmptyBuffer = Buffer.allocUnsafe(0); var MAX_WRITE = 16 * 1024; var kContentModeBuffer = "buffer"; var kContentModeUtf8 = "utf8"; var [major, minor] = (process.versions.node || "0.0").split(".").map(Number); var kCopyBuffer = major >= 22 && minor >= 7; function openFile(file, sonic) { sonic._opening = true; sonic._writing = true; sonic._asyncDrainScheduled = false; function fileOpened(err, fd) { if (err) { sonic._reopening = false; sonic._writing = false; sonic._opening = false; if (sonic.sync) { process.nextTick(() => { if (sonic.listenerCount("error") > 0) { sonic.emit("error", err); } }); } else { sonic.emit("error", err); } return; } const reopening = sonic._reopening; sonic.fd = fd; sonic.file = file; sonic._reopening = false; sonic._opening = false; sonic._writing = false; if (sonic.sync) { process.nextTick(() => sonic.emit("ready")); } else { sonic.emit("ready"); } if (sonic.destroyed) { return; } if (!sonic._writing && sonic._len > sonic.minLength || sonic._flushPending) { sonic._actualWrite(); } else if (reopening) { process.nextTick(() => sonic.emit("drain")); } } const flags = sonic.append ? "a" : "w"; const mode = sonic.mode; if (sonic.sync) { try { if (sonic.mkdir) fs.mkdirSync(path.dirname(file), { recursive: true }); const fd = fs.openSync(file, flags, mode); fileOpened(null, fd); } catch (err) { fileOpened(err); throw err; } } else if (sonic.mkdir) { fs.mkdir(path.dirname(file), { recursive: true }, (err) => { if (err) return fileOpened(err); fs.open(file, flags, mode, fileOpened); }); } else { fs.open(file, flags, mode, fileOpened); } } function SonicBoom(opts) { if (!(this instanceof SonicBoom)) { return new SonicBoom(opts); } let { fd, dest, minLength, maxLength, maxWrite, periodicFlush, sync, append = true, mkdir, retryEAGAIN, fsync, contentMode, mode } = opts || {}; fd = fd || dest; this._len = 0; this.fd = -1; this._bufs = []; this._lens = []; this._writing = false; this._ending = false; this._reopening = false; this._asyncDrainScheduled = false; this._flushPending = false; this._hwm = Math.max(minLength || 0, 16387); this.file = null; this.destroyed = false; this.minLength = minLength || 0; this.maxLength = maxLength || 0; this.maxWrite = maxWrite || MAX_WRITE; this._periodicFlush = periodicFlush || 0; this._periodicFlushTimer = void 0; this.sync = sync || false; this.writable = true; this._fsync = fsync || false; this.append = append || false; this.mode = mode; this.retryEAGAIN = retryEAGAIN || (() => true); this.mkdir = mkdir || false; let fsWriteSync; let fsWrite; if (contentMode === kContentModeBuffer) { this._writingBuf = kEmptyBuffer; this.write = writeBuffer; this.flush = flushBuffer; this.flushSync = flushBufferSync; this._actualWrite = actualWriteBuffer; fsWriteSync = () => fs.writeSync(this.fd, this._writingBuf); fsWrite = () => fs.write(this.fd, this._writingBuf, this.release); } else if (contentMode === void 0 || contentMode === kContentModeUtf8) { this._writingBuf = ""; this.write = write; this.flush = flush; this.flushSync = flushSync; this._actualWrite = actualWrite; fsWriteSync = () => fs.writeSync(this.fd, this._writingBuf, "utf8"); fsWrite = () => fs.write(this.fd, this._writingBuf, "utf8", this.release); } else { throw new Error(`SonicBoom supports "${kContentModeUtf8}" and "${kContentModeBuffer}", but passed ${contentMode}`); } if (typeof fd === "number") { this.fd = fd; process.nextTick(() => this.emit("ready")); } else if (typeof fd === "string") { openFile(fd, this); } else { throw new Error("SonicBoom supports only file descriptors and files"); } if (this.minLength >= this.maxWrite) { throw new Error(`minLength should be smaller than maxWrite (${this.maxWrite})`); } this.release = (err, n) => { if (err) { if ((err.code === "EAGAIN" || err.code === "EBUSY") && this.retryEAGAIN(err, this._writingBuf.length, this._len - this._writingBuf.length)) { if (this.sync) { try { sleep(BUSY_WRITE_TIMEOUT); this.release(void 0, 0); } catch (err2) { this.release(err2); } } else { setTimeout(fsWrite, BUSY_WRITE_TIMEOUT); } } else { this._writing = false; this.emit("error", err); } return; } this.emit("write", n); const releasedBufObj = releaseWritingBuf(this._writingBuf, this._len, n); this._len = releasedBufObj.len; this._writingBuf = releasedBufObj.writingBuf; if (this._writingBuf.length) { if (!this.sync) { fsWrite(); return; } try { do { const n2 = fsWriteSync(); const releasedBufObj2 = releaseWritingBuf(this._writingBuf, this._len, n2); this._len = releasedBufObj2.len; this._writingBuf = releasedBufObj2.writingBuf; } while (this._writingBuf.length); } catch (err2) { this.release(err2); return; } } if (this._fsync) { fs.fsyncSync(this.fd); } const len = this._len; if (this._reopening) { this._writing = false; this._reopening = false; this.reopen(); } else if (len > this.minLength) { this._actualWrite(); } else if (this._ending) { if (len > 0) { this._actualWrite(); } else { this._writing = false; actualClose(this); } } else { this._writing = false; if (this.sync) { if (!this._asyncDrainScheduled) { this._asyncDrainScheduled = true; process.nextTick(emitDrain, this); } } else { this.emit("drain"); } } }; this.on("newListener", function(name) { if (name === "drain") { this._asyncDrainScheduled = false; } }); if (this._periodicFlush !== 0) { this._periodicFlushTimer = setInterval(() => this.flush(null), this._periodicFlush); this._periodicFlushTimer.unref(); } } function releaseWritingBuf(writingBuf, len, n) { if (typeof writingBuf === "string" && Buffer.byteLength(writingBuf) !== n) { n = Buffer.from(writingBuf).subarray(0, n).toString().length; } len = Math.max(len - n, 0); writingBuf = writingBuf.slice(n); return { writingBuf, len }; } function emitDrain(sonic) { const hasListeners = sonic.listenerCount("drain") > 0; if (!hasListeners) return; sonic._asyncDrainScheduled = false; sonic.emit("drain"); } inherits(SonicBoom, EventEmitter); function mergeBuf(bufs, len) { if (bufs.length === 0) { return kEmptyBuffer; } if (bufs.length === 1) { return bufs[0]; } return Buffer.concat(bufs, len); } function write(data) { if (this.destroyed) { throw new Error("SonicBoom destroyed"); } const len = this._len + data.length; const bufs = this._bufs; if (this.maxLength && len > this.maxLength) { this.emit("drop", data); return this._len < this._hwm; } if (bufs.length === 0 || bufs[bufs.length - 1].length + data.length > this.maxWrite) { bufs.push("" + data); } else { bufs[bufs.length - 1] += data; } this._len = len; if (!this._writing && this._len >= this.minLength) { this._actualWrite(); } return this._len < this._hwm; } function writeBuffer(data) { if (this.destroyed) { throw new Error("SonicBoom destroyed"); } const len = this._len + data.length; const bufs = this._bufs; const lens = this._lens; if (this.maxLength && len > this.maxLength) { this.emit("drop", data); return this._len < this._hwm; } if (bufs.length === 0 || lens[lens.length - 1] + data.length > this.maxWrite) { bufs.push([data]); lens.push(data.length); } else { bufs[bufs.length - 1].push(data); lens[lens.length - 1] += data.length; } this._len = len; if (!this._writing && this._len >= this.minLength) { this._actualWrite(); } return this._len < this._hwm; } function callFlushCallbackOnDrain(cb) { this._flushPending = true; const onDrain = () => { if (!this._fsync) { try { fs.fsync(this.fd, (err) => { this._flushPending = false; cb(err); }); } catch (err) { cb(err); } } else { this._flushPending = false; cb(); } this.off("error", onError); }; const onError = (err) => { this._flushPending = false; cb(err); this.off("drain", onDrain); }; this.once("drain", onDrain); this.once("error", onError); } function flush(cb) { if (cb != null && typeof cb !== "function") { throw new Error("flush cb must be a function"); } if (this.destroyed) { const error = new Error("SonicBoom destroyed"); if (cb) { cb(error); return; } throw error; } if (this.minLength <= 0) { cb?.(); return; } if (cb) { callFlushCallbackOnDrain.call(this, cb); } if (this._writing) { return; } if (this._bufs.length === 0) { this._bufs.push(""); } this._actualWrite(); } function flushBuffer(cb) { if (cb != null && typeof cb !== "function") { throw new Error("flush cb must be a function"); } if (this.destroyed) { const error = new Error("SonicBoom destroyed"); if (cb) { cb(error); return; } throw error; } if (this.minLength <= 0) { cb?.(); return; } if (cb) { callFlushCallbackOnDrain.call(this, cb); } if (this._writing) { return; } if (this._bufs.length === 0) { this._bufs.push([]); this._lens.push(0); } this._actualWrite(); } SonicBoom.prototype.reopen = function(file) { if (this.destroyed) { throw new Error("SonicBoom destroyed"); } if (this._opening) { this.once("ready", () => { this.reopen(file); }); return; } if (this._ending) { return; } if (!this.file) { throw new Error("Unable to reopen a file descriptor, you must pass a file to SonicBoom"); } if (file) { this.file = file; } this._reopening = true; if (this._writing) { return; } const fd = this.fd; this.once("ready", () => { if (fd !== this.fd) { fs.close(fd, (err) => { if (err) { return this.emit("error", err); } }); } }); openFile(this.file, this); }; SonicBoom.prototype.end = function() { if (this.destroyed) { throw new Error("SonicBoom destroyed"); } if (this._opening) { this.once("ready", () => { this.end(); }); return; } if (this._ending) { return; } this._ending = true; if (this._writing) { return; } if (this._len > 0 && this.fd >= 0) { this._actualWrite(); } else { actualClose(this); } }; function flushSync() { if (this.destroyed) { throw new Error("SonicBoom destroyed"); } if (this.fd < 0) { throw new Error("sonic boom is not ready yet"); } if (!this._writing && this._writingBuf.length > 0) { this._bufs.unshift(this._writingBuf); this._writingBuf = ""; } let buf = ""; while (this._bufs.length || buf) { if (buf.length <= 0) { buf = this._bufs[0]; } try { const n = fs.writeSync(this.fd, buf, "utf8"); const releasedBufObj = releaseWritingBuf(buf, this._len, n); buf = releasedBufObj.writingBuf; this._len = releasedBufObj.len; if (buf.length <= 0) { this._bufs.shift(); } } catch (err) { const shouldRetry = err.code === "EAGAIN" || err.code === "EBUSY"; if (shouldRetry && !this.retryEAGAIN(err, buf.length, this._len - buf.length)) { throw err; } sleep(BUSY_WRITE_TIMEOUT); } } try { fs.fsyncSync(this.fd); } catch { } } function flushBufferSync() { if (this.destroyed) { throw new Error("SonicBoom destroyed"); } if (this.fd < 0) { throw new Error("sonic boom is not ready yet"); } if (!this._writing && this._writingBuf.length > 0) { this._bufs.unshift([this._writingBuf]); this._writingBuf = kEmptyBuffer; } let buf = kEmptyBuffer; while (this._bufs.length || buf.length) { if (buf.length <= 0) { buf = mergeBuf(this._bufs[0], this._lens[0]); } try { const n = fs.writeSync(this.fd, buf); buf = buf.subarray(n); this._len = Math.max(this._len - n, 0); if (buf.length <= 0) { this._bufs.shift(); this._lens.shift(); } } catch (err) { const shouldRetry = err.code === "EAGAIN" || err.code === "EBUSY"; if (shouldRetry && !this.retryEAGAIN(err, buf.length, this._len - buf.length)) { throw err; } sleep(BUSY_WRITE_TIMEOUT); } } } SonicBoom.prototype.destroy = function() { if (this.destroyed) { return; } actualClose(this); }; function actualWrite() { const release = this.release; this._writing = true; this._writingBuf = this._writingBuf || this._bufs.shift() || ""; if (this.sync) { try { const written = fs.writeSync(this.fd, this._writingBuf, "utf8"); release(null, written); } catch (err) { release(err); } } else { fs.write(this.fd, this._writingBuf, "utf8", release); } } function actualWriteBuffer() { const release = this.release; this._writing = true; this._writingBuf = this._writingBuf.length ? this._writingBuf : mergeBuf(this._bufs.shift(), this._lens.shift()); if (this.sync) { try { const written = fs.writeSync(this.fd, this._writingBuf); release(null, written); } catch (err) { release(err); } } else { if (kCopyBuffer) { this._writingBuf = Buffer.from(this._writingBuf); } fs.write(this.fd, this._writingBuf, release); } } function actualClose(sonic) { if (sonic.fd === -1) { sonic.once("ready", actualClose.bind(null, sonic)); return; } if (sonic._periodicFlushTimer !== void 0) { clearInterval(sonic._periodicFlushTimer); } sonic.destroyed = true; sonic._bufs = []; sonic._lens = []; assert(typeof sonic.fd === "number", `sonic.fd must be a number, got ${typeof sonic.fd}`); try { fs.fsync(sonic.fd, closeWrapped); } catch { } function closeWrapped() { if (sonic.fd !== 1 && sonic.fd !== 2) { fs.close(sonic.fd, done); } else { done(); } } function done(err) { if (err) { sonic.emit("error", err); return; } if (sonic._ending && !sonic._writing) { sonic.emit("finish"); } sonic.emit("close"); } } SonicBoom.SonicBoom = SonicBoom; SonicBoom.default = SonicBoom; module2.exports = SonicBoom; } }); // ../../../node_modules/.pnpm/pino-pretty@13.0.0/node_modules/pino-pretty/lib/utils/noop.js var require_noop = __commonJS({ "../../../node_modules/.pnpm/pino-pretty@13.0.0/node_modules/pino-pretty/lib/utils/noop.js"(exports2, module2) { "use strict"; module2.exports = function noop() { }; } }); // ../../../node_modules/.pnpm/on-exit-leak-free@2.1.2/node_modules/on-exit-leak-free/index.js var require_on_exit_leak_free = __commonJS({ "../../../node_modules/.pnpm/on-exit-leak-free@2.1.2/node_modules/on-exit-leak-free/index.js"(exports2, module2) { "use strict"; var refs = { exit: [], beforeExit: [] }; var functions = { exit: onExit, beforeExit: onBeforeExit }; var registry; function ensureRegistry() { if (registry === void 0) { registry = new FinalizationRegistry(clear); } } function install(event) { if (refs[event].length > 0) { return; } process.on(event, functions[event]); } function uninstall(event) { if (refs[event].length > 0) { return; } process.removeListener(event, functions[event]); if (refs.exit.length === 0 && refs.beforeExit.length === 0) { registry = void 0; } } function onExit() { callRefs("exit"); } function onBeforeExit() { callRefs("beforeExit"); } function callRefs(event) { for (const ref of refs[event]) { const obj = ref.deref(); const fn = ref.fn; if (obj !== void 0) { fn(obj, event); } } refs[event] = []; } function clear(ref) { for (const event of ["exit", "beforeExit"]) { const index = refs[event].indexOf(ref); refs[event].splice(index, index + 1); uninstall(event); } } function _register(event, obj, fn) { if (obj === void 0) { throw new Error("the object can't be undefined"); } install(event); const ref = new WeakRef(obj); ref.fn = fn; ensureRegistry(); registry.register(obj, ref); refs[event].push(ref); } function register(obj, fn) { _register("exit", obj, fn); } function registerBeforeExit(obj, fn) { _register("beforeExit", obj, fn); } function unregister(obj) { if (registry === void 0) { return; } registry.unregister(obj); for (const event of ["exit", "beforeExit"]) { refs[event] = refs[event].filter((ref) => { const _obj = ref.deref(); return _obj && _obj !== obj; }); uninstall(event); } } module2.exports = { register, registerBeforeExit, unregister }; } }); // ../../../node_modules/.pnpm/pino-pretty@13.0.0/node_modules/pino-pretty/lib/utils/build-safe-sonic-boom.js var require_build_safe_sonic_boom = __commonJS({ "../../../node_modules/.pnpm/pino-pretty@13.0.0/node_modules/pino-pretty/lib/utils/build-safe-sonic-boom.js"(exports2, module2) { "use strict"; module2.exports = buildSafeSonicBoom2; var { isMainThread } = require("worker_threads"); var SonicBoom = require_sonic_boom(); var noop = require_noop(); function buildSafeSonicBoom2(opts) { const stream = new SonicBoom(opts); stream.on("error", filterBrokenPipe); if (!process.env.NODE_V8_COVERAGE && !opts.sync && isMainThread) { setupOnExit(stream); } return stream; function filterBrokenPipe(err) { if (err.code === "EPIPE") { stream.write = noop; st