UNPKG

pnpm

Version:

Fast, disk space efficient package manager

1,419 lines (1,405 loc) • 8.88 MB
"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 = (fn, res) => function __init() { return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; }; var __commonJS = (cb, mod) => function __require() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // ../node_modules/.pnpm/fast-safe-stringify@2.1.1/node_modules/fast-safe-stringify/index.js var require_fast_safe_stringify = __commonJS({ "../node_modules/.pnpm/fast-safe-stringify@2.1.1/node_modules/fast-safe-stringify/index.js"(exports2, module2) { module2.exports = stringify2; stringify2.default = stringify2; stringify2.stable = deterministicStringify; stringify2.stableStringify = deterministicStringify; var LIMIT_REPLACE_NODE = "[...]"; var CIRCULAR_REPLACE_NODE = "[Circular]"; var arr = []; var replacerStack = []; function defaultOptions() { return { depthLimit: Number.MAX_SAFE_INTEGER, edgesLimit: Number.MAX_SAFE_INTEGER }; } function stringify2(obj, replacer, spacer, options) { if (typeof options === "undefined") { options = defaultOptions(); } decirc(obj, "", 0, [], void 0, 0, options); var res; try { if (replacerStack.length === 0) { res = JSON.stringify(obj, replacer, spacer); } else { res = JSON.stringify(obj, replaceGetterValues(replacer), spacer); } } catch (_) { return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]"); } finally { while (arr.length !== 0) { var part = arr.pop(); if (part.length === 4) { Object.defineProperty(part[0], part[1], part[3]); } else { part[0][part[1]] = part[2]; } } } return res; } function setReplace(replace, val, k, parent) { var propertyDescriptor = Object.getOwnPropertyDescriptor(parent, k); if (propertyDescriptor.get !== void 0) { if (propertyDescriptor.configurable) { Object.defineProperty(parent, k, { value: replace }); arr.push([parent, k, val, propertyDescriptor]); } else { replacerStack.push([val, k, replace]); } } else { parent[k] = replace; arr.push([parent, k, val]); } } function decirc(val, k, edgeIndex, stack, parent, depth, options) { depth += 1; var i; if (typeof val === "object" && val !== null) { for (i = 0; i < stack.length; i++) { if (stack[i] === val) { setReplace(CIRCULAR_REPLACE_NODE, val, k, parent); return; } } if (typeof options.depthLimit !== "undefined" && depth > options.depthLimit) { setReplace(LIMIT_REPLACE_NODE, val, k, parent); return; } if (typeof options.edgesLimit !== "undefined" && edgeIndex + 1 > options.edgesLimit) { setReplace(LIMIT_REPLACE_NODE, val, k, parent); return; } stack.push(val); if (Array.isArray(val)) { for (i = 0; i < val.length; i++) { decirc(val[i], i, i, stack, val, depth, options); } } else { var keys = Object.keys(val); for (i = 0; i < keys.length; i++) { var key = keys[i]; decirc(val[key], key, i, stack, val, depth, options); } } stack.pop(); } } function compareFunction(a, b) { if (a < b) { return -1; } if (a > b) { return 1; } return 0; } function deterministicStringify(obj, replacer, spacer, options) { if (typeof options === "undefined") { options = defaultOptions(); } var tmp = deterministicDecirc(obj, "", 0, [], void 0, 0, options) || obj; var res; try { if (replacerStack.length === 0) { res = JSON.stringify(tmp, replacer, spacer); } else { res = JSON.stringify(tmp, replaceGetterValues(replacer), spacer); } } catch (_) { return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]"); } finally { while (arr.length !== 0) { var part = arr.pop(); if (part.length === 4) { Object.defineProperty(part[0], part[1], part[3]); } else { part[0][part[1]] = part[2]; } } } return res; } function deterministicDecirc(val, k, edgeIndex, stack, parent, depth, options) { depth += 1; var i; if (typeof val === "object" && val !== null) { for (i = 0; i < stack.length; i++) { if (stack[i] === val) { setReplace(CIRCULAR_REPLACE_NODE, val, k, parent); return; } } try { if (typeof val.toJSON === "function") { return; } } catch (_) { return; } if (typeof options.depthLimit !== "undefined" && depth > options.depthLimit) { setReplace(LIMIT_REPLACE_NODE, val, k, parent); return; } if (typeof options.edgesLimit !== "undefined" && edgeIndex + 1 > options.edgesLimit) { setReplace(LIMIT_REPLACE_NODE, val, k, parent); return; } stack.push(val); if (Array.isArray(val)) { for (i = 0; i < val.length; i++) { deterministicDecirc(val[i], i, i, stack, val, depth, options); } } else { var tmp = {}; var keys = Object.keys(val).sort(compareFunction); for (i = 0; i < keys.length; i++) { var key = keys[i]; deterministicDecirc(val[key], key, i, stack, val, depth, options); tmp[key] = val[key]; } if (typeof parent !== "undefined") { arr.push([parent, k, val]); parent[k] = tmp; } else { return tmp; } } stack.pop(); } } function replaceGetterValues(replacer) { replacer = typeof replacer !== "undefined" ? replacer : function(k, v) { return v; }; return function(key, val) { if (replacerStack.length > 0) { for (var i = 0; i < replacerStack.length; i++) { var part = replacerStack[i]; if (part[1] === key && part[0] === val) { val = part[2]; replacerStack.splice(i, 1); break; } } } return replacer.call(this, key, val); }; } } }); // ../node_modules/.pnpm/individual@3.0.0/node_modules/individual/index.js var require_individual = __commonJS({ "../node_modules/.pnpm/individual@3.0.0/node_modules/individual/index.js"(exports2, module2) { "use strict"; var root = typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {}; module2.exports = Individual; function Individual(key, value) { if (key in root) { return root[key]; } root[key] = value; return value; } } }); // ../node_modules/.pnpm/bole@5.0.17/node_modules/bole/format.js var require_format = __commonJS({ "../node_modules/.pnpm/bole@5.0.17/node_modules/bole/format.js"(exports2, module2) { var utilformat = require("util").format; function format(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16) { if (a16 !== void 0) { return utilformat(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16); } if (a15 !== void 0) { return utilformat(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15); } if (a14 !== void 0) { return utilformat(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14); } if (a13 !== void 0) { return utilformat(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13); } if (a12 !== void 0) { return utilformat(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); } if (a11 !== void 0) { return utilformat(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11); } if (a10 !== void 0) { return utilformat(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); } if (a9 !== void 0) { return utilformat(a1, a2, a3, a4, a5, a6, a7, a8, a9); } if (a8 !== void 0) { return utilformat(a1, a2, a3, a4, a5, a6, a7, a8); } if (a7 !== void 0) { return utilformat(a1, a2, a3, a4, a5, a6, a7); } if (a6 !== void 0) { return utilformat(a1, a2, a3, a4, a5, a6); } if (a5 !== void 0) { return utilformat(a1, a2, a3, a4, a5); } if (a4 !== void 0) { return utilformat(a1, a2, a3, a4); } if (a3 !== void 0) { return utilformat(a1, a2, a3); } if (a2 !== void 0) { return utilformat(a1, a2); } return a1; } module2.exports = format; } }); // ../node_modules/.pnpm/bole@5.0.17/node_modules/bole/bole.js var require_bole = __commonJS({ "../node_modules/.pnpm/bole@5.0.17/node_modules/bole/bole.js"(exports2, module2) { "use strict"; var _stringify = require_fast_safe_stringify(); var individual = require_individual()("$$bole", { fastTime: false }); var format = require_format(); var levels = "debug info warn error".split(" "); var os = require("os"); var pid = process.pid; var hasObjMode = false; var scache = []; var hostname; try { hostname = os.hostname(); } catch (e) { hostname = os.version().indexOf("Windows 7 ") === 0 ? "windows7" : "hostname-unknown"; } var hostnameSt = _stringify(hostname); for (const level of levels) { scache[level] = ',"hostname":' + hostnameSt + ',"pid":' + pid + ',"level":"' + level; Number(scache[level]); if (!Array.isArray(individual[level])) { individual[level] = []; } } function stackToString(e) { let s = e.stack; let ce; if (typeof e.cause === "function" && (ce = e.cause())) { s += "\nCaused by: " + stackToString(ce); } return s; } function errorToOut(err, out) { out.err = { name: err.name, message: err.message, code: err.code, // perhaps stack: stackToString(err) }; } function requestToOut(req, out) { out.req = { method: req.method, url: req.url, headers: req.headers, remoteAddress: req.connection.remoteAddress, remotePort: req.connection.remotePort }; } function objectToOut(obj, out) { for (const k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k) && obj[k] !== void 0) { out[k] = obj[k]; } } } function objectMode(stream) { return stream._writableState && stream._writableState.objectMode === true; } function stringify2(level, name, message, obj) { let s = '{"time":' + (individual.fastTime ? Date.now() : '"' + (/* @__PURE__ */ new Date()).toISOString() + '"') + scache[level] + '","name":' + name + (message !== void 0 ? ',"message":' + _stringify(message) : ""); for (const k in obj) { s += "," + _stringify(k) + ":" + _stringify(obj[k]); } s += "}"; Number(s); return s; } function extend(level, name, message, obj) { const newObj = { time: individual.fastTime ? Date.now() : (/* @__PURE__ */ new Date()).toISOString(), hostname, pid, level, name }; if (message !== void 0) { obj.message = message; } for (const k in obj) { newObj[k] = obj[k]; } return newObj; } function levelLogger(level, name) { const outputs = individual[level]; const nameSt = _stringify(name); return function namedLevelLogger(inp, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16) { if (outputs.length === 0) { return; } const out = {}; let objectOut; let i = 0; const l = outputs.length; let stringified; let message; if (typeof inp === "string" || inp == null) { if (!(message = format(inp, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16))) { message = void 0; } } else { if (inp instanceof Error) { if (typeof a2 === "object") { objectToOut(a2, out); errorToOut(inp, out); if (!(message = format(a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16))) { message = void 0; } } else { errorToOut(inp, out); if (!(message = format(a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16))) { message = void 0; } } } else { if (!(message = format(a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16))) { message = void 0; } } if (typeof inp === "boolean") { message = String(inp); } else if (typeof inp === "object" && !(inp instanceof Error)) { if (inp.method && inp.url && inp.headers && inp.socket) { requestToOut(inp, out); } else { objectToOut(inp, out); } } } if (l === 1 && !hasObjMode) { outputs[0].write(Buffer.from(stringify2(level, nameSt, message, out) + "\n")); return; } for (; i < l; i++) { if (objectMode(outputs[i])) { if (objectOut === void 0) { objectOut = extend(level, name, message, out); } outputs[i].write(objectOut); } else { if (stringified === void 0) { stringified = Buffer.from(stringify2(level, nameSt, message, out) + "\n"); } outputs[i].write(stringified); } } }; } function bole(name) { function boleLogger(subname) { return bole(name + ":" + subname); } function makeLogger(p, level) { p[level] = levelLogger(level, name); return p; } return levels.reduce(makeLogger, boleLogger); } bole.output = function output(opt) { let b = false; if (Array.isArray(opt)) { opt.forEach(bole.output); return bole; } if (typeof opt.level !== "string") { throw new TypeError('Must provide a "level" option'); } for (const level of levels) { if (!b && level === opt.level) { b = true; } if (b) { if (opt.stream && objectMode(opt.stream)) { hasObjMode = true; } individual[level].push(opt.stream); } } return bole; }; bole.reset = function reset() { for (const level of levels) { individual[level].splice(0, individual[level].length); } individual.fastTime = false; return bole; }; bole.setFastTime = function setFastTime(b) { if (!arguments.length) { individual.fastTime = true; } else { individual.fastTime = b; } return bole; }; module2.exports = bole; } }); // ../packages/logger/lib/logger.js var require_logger = __commonJS({ "../packages/logger/lib/logger.js"(exports2) { "use strict"; var __importDefault2 = exports2 && exports2.__importDefault || function(mod) { return mod && mod.__esModule ? mod : { "default": mod }; }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.logger = void 0; exports2.globalWarn = globalWarn; exports2.globalInfo = globalInfo; var bole_1 = __importDefault2(require_bole()); bole_1.default.setFastTime(); exports2.logger = (0, bole_1.default)("pnpm"); var globalLogger = (0, bole_1.default)("pnpm:global"); function globalWarn(message) { globalLogger.warn(message); } function globalInfo(message) { globalLogger.info(message); } } }); // ../node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/stream.js var require_stream = __commonJS({ "../node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/stream.js"(exports2, module2) { module2.exports = require("stream"); } }); // ../node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/buffer_list.js var require_buffer_list = __commonJS({ "../node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/buffer_list.js"(exports2, module2) { "use strict"; function ownKeys2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function(sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys2(Object(source), true).forEach(function(key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys2(Object(source)).forEach(function(key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== void 0) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } var _require = require("buffer"); var Buffer2 = _require.Buffer; var _require2 = require("util"); var inspect = _require2.inspect; var custom = inspect && inspect.custom || "inspect"; function copyBuffer(src, target, offset) { Buffer2.prototype.copy.call(src, target, offset); } module2.exports = /* @__PURE__ */ function() { function BufferList() { _classCallCheck(this, BufferList); this.head = null; this.tail = null; this.length = 0; } _createClass(BufferList, [{ key: "push", value: function push(v) { var entry = { data: v, next: null }; if (this.length > 0) this.tail.next = entry; else this.head = entry; this.tail = entry; ++this.length; } }, { key: "unshift", value: function unshift(v) { var entry = { data: v, next: this.head }; if (this.length === 0) this.tail = entry; this.head = entry; ++this.length; } }, { key: "shift", value: function shift() { if (this.length === 0) return; var ret2 = this.head.data; if (this.length === 1) this.head = this.tail = null; else this.head = this.head.next; --this.length; return ret2; } }, { key: "clear", value: function clear() { this.head = this.tail = null; this.length = 0; } }, { key: "join", value: function join(s) { if (this.length === 0) return ""; var p = this.head; var ret2 = "" + p.data; while (p = p.next) ret2 += s + p.data; return ret2; } }, { key: "concat", value: function concat(n) { if (this.length === 0) return Buffer2.alloc(0); var ret2 = Buffer2.allocUnsafe(n >>> 0); var p = this.head; var i = 0; while (p) { copyBuffer(p.data, ret2, i); i += p.data.length; p = p.next; } return ret2; } // Consumes a specified amount of bytes or characters from the buffered data. }, { key: "consume", value: function consume(n, hasStrings) { var ret2; if (n < this.head.data.length) { ret2 = this.head.data.slice(0, n); this.head.data = this.head.data.slice(n); } else if (n === this.head.data.length) { ret2 = this.shift(); } else { ret2 = hasStrings ? this._getString(n) : this._getBuffer(n); } return ret2; } }, { key: "first", value: function first() { return this.head.data; } // Consumes a specified amount of characters from the buffered data. }, { key: "_getString", value: function _getString(n) { var p = this.head; var c = 1; var ret2 = p.data; n -= ret2.length; while (p = p.next) { var str = p.data; var nb = n > str.length ? str.length : n; if (nb === str.length) ret2 += str; else ret2 += str.slice(0, n); n -= nb; if (n === 0) { if (nb === str.length) { ++c; if (p.next) this.head = p.next; else this.head = this.tail = null; } else { this.head = p; p.data = str.slice(nb); } break; } ++c; } this.length -= c; return ret2; } // Consumes a specified amount of bytes from the buffered data. }, { key: "_getBuffer", value: function _getBuffer(n) { var ret2 = Buffer2.allocUnsafe(n); var p = this.head; var c = 1; p.data.copy(ret2); n -= p.data.length; while (p = p.next) { var buf = p.data; var nb = n > buf.length ? buf.length : n; buf.copy(ret2, ret2.length - n, 0, nb); n -= nb; if (n === 0) { if (nb === buf.length) { ++c; if (p.next) this.head = p.next; else this.head = this.tail = null; } else { this.head = p; p.data = buf.slice(nb); } break; } ++c; } this.length -= c; return ret2; } // Make sure the linked list only shows the minimal necessary information. }, { key: custom, value: function value(_, options) { return inspect(this, _objectSpread(_objectSpread({}, options), {}, { // Only inspect one level. depth: 0, // It should not recurse. customInspect: false })); } }]); return BufferList; }(); } }); // ../node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/destroy.js var require_destroy = __commonJS({ "../node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/destroy.js"(exports2, module2) { "use strict"; function destroy(err, cb) { var _this = this; var readableDestroyed = this._readableState && this._readableState.destroyed; var writableDestroyed = this._writableState && this._writableState.destroyed; if (readableDestroyed || writableDestroyed) { if (cb) { cb(err); } else if (err) { if (!this._writableState) { process.nextTick(emitErrorNT, this, err); } else if (!this._writableState.errorEmitted) { this._writableState.errorEmitted = true; process.nextTick(emitErrorNT, this, err); } } return this; } if (this._readableState) { this._readableState.destroyed = true; } if (this._writableState) { this._writableState.destroyed = true; } this._destroy(err || null, function(err2) { if (!cb && err2) { if (!_this._writableState) { process.nextTick(emitErrorAndCloseNT, _this, err2); } else if (!_this._writableState.errorEmitted) { _this._writableState.errorEmitted = true; process.nextTick(emitErrorAndCloseNT, _this, err2); } else { process.nextTick(emitCloseNT, _this); } } else if (cb) { process.nextTick(emitCloseNT, _this); cb(err2); } else { process.nextTick(emitCloseNT, _this); } }); return this; } function emitErrorAndCloseNT(self2, err) { emitErrorNT(self2, err); emitCloseNT(self2); } function emitCloseNT(self2) { if (self2._writableState && !self2._writableState.emitClose) return; if (self2._readableState && !self2._readableState.emitClose) return; self2.emit("close"); } function undestroy() { if (this._readableState) { this._readableState.destroyed = false; this._readableState.reading = false; this._readableState.ended = false; this._readableState.endEmitted = false; } if (this._writableState) { this._writableState.destroyed = false; this._writableState.ended = false; this._writableState.ending = false; this._writableState.finalCalled = false; this._writableState.prefinished = false; this._writableState.finished = false; this._writableState.errorEmitted = false; } } function emitErrorNT(self2, err) { self2.emit("error", err); } function errorOrDestroy(stream, err) { var rState = stream._readableState; var wState = stream._writableState; if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err); else stream.emit("error", err); } module2.exports = { destroy, undestroy, errorOrDestroy }; } }); // ../node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/errors.js var require_errors = __commonJS({ "../node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/errors.js"(exports2, module2) { "use strict"; var codes = {}; function createErrorType(code, message, Base) { if (!Base) { Base = Error; } function getMessage(arg1, arg2, arg3) { if (typeof message === "string") { return message; } else { return message(arg1, arg2, arg3); } } class NodeError extends Base { constructor(arg1, arg2, arg3) { super(getMessage(arg1, arg2, arg3)); } } NodeError.prototype.name = Base.name; NodeError.prototype.code = code; codes[code] = NodeError; } function oneOf(expected, thing) { if (Array.isArray(expected)) { const len = expected.length; expected = expected.map((i) => String(i)); if (len > 2) { return `one of ${thing} ${expected.slice(0, len - 1).join(", ")}, or ` + expected[len - 1]; } else if (len === 2) { return `one of ${thing} ${expected[0]} or ${expected[1]}`; } else { return `of ${thing} ${expected[0]}`; } } else { return `of ${thing} ${String(expected)}`; } } function startsWith(str, search, pos) { return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search; } function endsWith(str, search, this_len) { if (this_len === void 0 || this_len > str.length) { this_len = str.length; } return str.substring(this_len - search.length, this_len) === search; } function includes(str, search, start) { if (typeof start !== "number") { start = 0; } if (start + search.length > str.length) { return false; } else { return str.indexOf(search, start) !== -1; } } createErrorType("ERR_INVALID_OPT_VALUE", function(name, value) { return 'The value "' + value + '" is invalid for option "' + name + '"'; }, TypeError); createErrorType("ERR_INVALID_ARG_TYPE", function(name, expected, actual) { let determiner; if (typeof expected === "string" && startsWith(expected, "not ")) { determiner = "must not be"; expected = expected.replace(/^not /, ""); } else { determiner = "must be"; } let msg; if (endsWith(name, " argument")) { msg = `The ${name} ${determiner} ${oneOf(expected, "type")}`; } else { const type = includes(name, ".") ? "property" : "argument"; msg = `The "${name}" ${type} ${determiner} ${oneOf(expected, "type")}`; } msg += `. Received type ${typeof actual}`; return msg; }, TypeError); createErrorType("ERR_STREAM_PUSH_AFTER_EOF", "stream.push() after EOF"); createErrorType("ERR_METHOD_NOT_IMPLEMENTED", function(name) { return "The " + name + " method is not implemented"; }); createErrorType("ERR_STREAM_PREMATURE_CLOSE", "Premature close"); createErrorType("ERR_STREAM_DESTROYED", function(name) { return "Cannot call " + name + " after a stream was destroyed"; }); createErrorType("ERR_MULTIPLE_CALLBACK", "Callback called multiple times"); createErrorType("ERR_STREAM_CANNOT_PIPE", "Cannot pipe, not readable"); createErrorType("ERR_STREAM_WRITE_AFTER_END", "write after end"); createErrorType("ERR_STREAM_NULL_VALUES", "May not write null values to stream", TypeError); createErrorType("ERR_UNKNOWN_ENCODING", function(arg) { return "Unknown encoding: " + arg; }, TypeError); createErrorType("ERR_STREAM_UNSHIFT_AFTER_END_EVENT", "stream.unshift() after end event"); module2.exports.codes = codes; } }); // ../node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/state.js var require_state = __commonJS({ "../node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/state.js"(exports2, module2) { "use strict"; var ERR_INVALID_OPT_VALUE = require_errors().codes.ERR_INVALID_OPT_VALUE; function highWaterMarkFrom(options, isDuplex, duplexKey) { return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null; } function getHighWaterMark(state, options, duplexKey, isDuplex) { var hwm = highWaterMarkFrom(options, isDuplex, duplexKey); if (hwm != null) { if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) { var name = isDuplex ? duplexKey : "highWaterMark"; throw new ERR_INVALID_OPT_VALUE(name, hwm); } return Math.floor(hwm); } return state.objectMode ? 16 : 16 * 1024; } module2.exports = { getHighWaterMark }; } }); // ../node_modules/.pnpm/inherits@2.0.4/node_modules/inherits/inherits_browser.js var require_inherits_browser = __commonJS({ "../node_modules/.pnpm/inherits@2.0.4/node_modules/inherits/inherits_browser.js"(exports2, module2) { if (typeof Object.create === "function") { module2.exports = function inherits(ctor, superCtor) { if (superCtor) { ctor.super_ = superCtor; ctor.prototype = Object.create(superCtor.prototype, { constructor: { value: ctor, enumerable: false, writable: true, configurable: true } }); } }; } else { module2.exports = function inherits(ctor, superCtor) { if (superCtor) { ctor.super_ = superCtor; var TempCtor = function() { }; TempCtor.prototype = superCtor.prototype; ctor.prototype = new TempCtor(); ctor.prototype.constructor = ctor; } }; } } }); // ../node_modules/.pnpm/inherits@2.0.4/node_modules/inherits/inherits.js var require_inherits = __commonJS({ "../node_modules/.pnpm/inherits@2.0.4/node_modules/inherits/inherits.js"(exports2, module2) { try { util = require("util"); if (typeof util.inherits !== "function") throw ""; module2.exports = util.inherits; } catch (e) { module2.exports = require_inherits_browser(); } var util; } }); // ../node_modules/.pnpm/util-deprecate@1.0.2/node_modules/util-deprecate/node.js var require_node = __commonJS({ "../node_modules/.pnpm/util-deprecate@1.0.2/node_modules/util-deprecate/node.js"(exports2, module2) { module2.exports = require("util").deprecate; } }); // ../node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/_stream_writable.js var require_stream_writable = __commonJS({ "../node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/_stream_writable.js"(exports2, module2) { "use strict"; module2.exports = Writable; function CorkedRequest(state) { var _this = this; this.next = null; this.entry = null; this.finish = function() { onCorkedFinish(_this, state); }; } var Duplex; Writable.WritableState = WritableState; var internalUtil = { deprecate: require_node() }; var Stream = require_stream(); var Buffer2 = require("buffer").Buffer; var OurUint8Array = (typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : {}).Uint8Array || function() { }; function _uint8ArrayToBuffer(chunk) { return Buffer2.from(chunk); } function _isUint8Array(obj) { return Buffer2.isBuffer(obj) || obj instanceof OurUint8Array; } var destroyImpl = require_destroy(); var _require = require_state(); var getHighWaterMark = _require.getHighWaterMark; var _require$codes = require_errors().codes; var ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE; var ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED; var ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK; var ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE; var ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED; var ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES; var ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END; var ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING; var errorOrDestroy = destroyImpl.errorOrDestroy; require_inherits()(Writable, Stream); function nop() { } function WritableState(options, stream, isDuplex) { Duplex = Duplex || require_stream_duplex(); options = options || {}; if (typeof isDuplex !== "boolean") isDuplex = stream instanceof Duplex; this.objectMode = !!options.objectMode; if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; this.highWaterMark = getHighWaterMark(this, options, "writableHighWaterMark", isDuplex); this.finalCalled = false; this.needDrain = false; this.ending = false; this.ended = false; this.finished = false; this.destroyed = false; var noDecode = options.decodeStrings === false; this.decodeStrings = !noDecode; this.defaultEncoding = options.defaultEncoding || "utf8"; this.length = 0; this.writing = false; this.corked = 0; this.sync = true; this.bufferProcessing = false; this.onwrite = function(er) { onwrite(stream, er); }; this.writecb = null; this.writelen = 0; this.bufferedRequest = null; this.lastBufferedRequest = null; this.pendingcb = 0; this.prefinished = false; this.errorEmitted = false; this.emitClose = options.emitClose !== false; this.autoDestroy = !!options.autoDestroy; this.bufferedRequestCount = 0; this.corkedRequestsFree = new CorkedRequest(this); } WritableState.prototype.getBuffer = function getBuffer() { var current = this.bufferedRequest; var out = []; while (current) { out.push(current); current = current.next; } return out; }; (function() { try { Object.defineProperty(WritableState.prototype, "buffer", { get: internalUtil.deprecate(function writableStateBufferGetter() { return this.getBuffer(); }, "_writableState.buffer is deprecated. Use _writableState.getBuffer instead.", "DEP0003") }); } catch (_) { } })(); var realHasInstance; if (typeof Symbol === "function" && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === "function") { realHasInstance = Function.prototype[Symbol.hasInstance]; Object.defineProperty(Writable, Symbol.hasInstance, { value: function value(object) { if (realHasInstance.call(this, object)) return true; if (this !== Writable) return false; return object && object._writableState instanceof WritableState; } }); } else { realHasInstance = function realHasInstance2(object) { return object instanceof this; }; } function Writable(options) { Duplex = Duplex || require_stream_duplex(); var isDuplex = this instanceof Duplex; if (!isDuplex && !realHasInstance.call(Writable, this)) return new Writable(options); this._writableState = new WritableState(options, this, isDuplex); this.writable = true; if (options) { if (typeof options.write === "function") this._write = options.write; if (typeof options.writev === "function") this._writev = options.writev; if (typeof options.destroy === "function") this._destroy = options.destroy; if (typeof options.final === "function") this._final = options.final; } Stream.call(this); } Writable.prototype.pipe = function() { errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE()); }; function writeAfterEnd(stream, cb) { var er = new ERR_STREAM_WRITE_AFTER_END(); errorOrDestroy(stream, er); process.nextTick(cb, er); } function validChunk(stream, state, chunk, cb) { var er; if (chunk === null) { er = new ERR_STREAM_NULL_VALUES(); } else if (typeof chunk !== "string" && !state.objectMode) { er = new ERR_INVALID_ARG_TYPE("chunk", ["string", "Buffer"], chunk); } if (er) { errorOrDestroy(stream, er); process.nextTick(cb, er); return false; } return true; } Writable.prototype.write = function(chunk, encoding, cb) { var state = this._writableState; var ret2 = false; var isBuf = !state.objectMode && _isUint8Array(chunk); if (isBuf && !Buffer2.isBuffer(chunk)) { chunk = _uint8ArrayToBuffer(chunk); } if (typeof encoding === "function") { cb = encoding; encoding = null; } if (isBuf) encoding = "buffer"; else if (!encoding) encoding = state.defaultEncoding; if (typeof cb !== "function") cb = nop; if (state.ending) writeAfterEnd(this, cb); else if (isBuf || validChunk(this, state, chunk, cb)) { state.pendingcb++; ret2 = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); } return ret2; }; Writable.prototype.cork = function() { this._writableState.corked++; }; Writable.prototype.uncork = function() { var state = this._writableState; if (state.corked) { state.corked--; if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); } }; Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { if (typeof encoding === "string") encoding = encoding.toLowerCase(); if (!(["hex", "utf8", "utf-8", "ascii", "binary", "base64", "ucs2", "ucs-2", "utf16le", "utf-16le", "raw"].indexOf((encoding + "").toLowerCase()) > -1)) throw new ERR_UNKNOWN_ENCODING(encoding); this._writableState.defaultEncoding = encoding; return this; }; Object.defineProperty(Writable.prototype, "writableBuffer", { // making it explicit this property is not enumerable // because otherwise some prototype manipulation in // userland will fail enumerable: false, get: function get() { return this._writableState && this._writableState.getBuffer(); } }); function decodeChunk(state, chunk, encoding) { if (!state.objectMode && state.decodeStrings !== false && typeof chunk === "string") { chunk = Buffer2.from(chunk, encoding); } return chunk; } Object.defineProperty(Writable.prototype, "writableHighWaterMark", { // making it explicit this property is not enumerable // because otherwise some prototype manipulation in // userland will fail enumerable: false, get: function get() { return this._writableState.highWaterMark; } }); function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { if (!isBuf) { var newChunk = decodeChunk(state, chunk, encoding); if (chunk !== newChunk) { isBuf = true; encoding = "buffer"; chunk = newChunk; } } var len = state.objectMode ? 1 : chunk.length; state.length += len; var ret2 = state.length < state.highWaterMark; if (!ret2) state.needDrain = true; if (state.writing || state.corked) { var last = state.lastBufferedRequest; state.lastBufferedRequest = { chunk, encoding, isBuf, callback: cb, next: null }; if (last) { last.next = state.lastBufferedRequest; } else { state.bufferedRequest = state.lastBufferedRequest; } state.bufferedRequestCount += 1; } else { doWrite(stream, state, false, len, chunk, encoding, cb); } return ret2; } function doWrite(stream, state, writev, len, chunk, encoding, cb) { state.writelen = len; state.writecb = cb; state.writing = true; state.sync = true; if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED("write")); else if (writev) stream._writev(chunk, state.onwrite); else stream._write(chunk, encoding, state.onwrite); state.sync = false; } function onwriteError(stream, state, sync, er, cb) { --state.pendingcb; if (sync) { process.nextTick(cb, er); process.nextTick(finishMaybe, stream, state); stream._writableState.errorEmitted = true; errorOrDestroy(stream, er); } else { cb(er); stream._writableState.errorEmitted = true; errorOrDestroy(stream, er); finishMaybe(stream, state); } } function onwriteStateUpdate(state) { state.writing = false; state.writecb = null; state.length -= state.writelen; state.writelen = 0; } function onwrite(stream, er) { var state = stream._writableState; var sync = state.sync; var cb = state.writecb; if (typeof cb !== "function") throw new ERR_MULTIPLE_CALLBACK(); onwriteStateUpdate(state); if (er) onwriteError(stream, state, sync, er, cb); else { var finished = needFinish(state) || stream.destroyed; if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { clearBuffer(stream, state); } if (sync) { process.nextTick(afterWrite, stream, state, finished, cb); } else { afterWrite(stream, state, finished, cb); } } } function afterWrite(stream, state, finished, cb) { if (!finished) onwriteDrain(stream, state); state.pendingcb--; cb(); finishMaybe(stream, state); } function onwriteDrain(stream, state) { if (state.length === 0 && state.needDrain) { state.needDrain = false; stream.emit("drain"); } } function clearBuffer(stream, state) { state.bufferProcessing = true; var entry = state.bufferedRequest; if (stream._writev && entry && entry.next) { var l = state.bufferedRequestCount; var buffer = new Array(l); var holder = state.corkedRequestsFree; holder.entry = entry; var count = 0; var allBuffers = true; while (entry) { buffer[count] = entry; if (!entry.isBuf) allBuffers = false; entry = entry.next; count += 1; } buffer.allBuffers = allBuffers; doWrite(stream, state, true, state.length, buffer, "", holder.finish); state.pendingcb++; state.lastBufferedRequest = null; if (holder.next) { state.corkedRequestsFree = holder.next; holder.next = null; } else { state.corkedRequestsFree = new CorkedRequest(state); } state.bufferedRequestCount = 0; } else { while (entry) { var chunk = entry.chunk; var encoding = entry.encoding; var cb = entry.callback; var len = state.objectMode ? 1 : chunk.length; doWrite(stream, state, false, len, chunk, encoding, cb); entry = entry.next; state.bufferedRequestCount--; if (state.writing) { break; } } if (entry === null) state.lastBufferedRequest = null; } state.bufferedRequest = entry; state.bufferProcessing = false; } Writable.prototype._write = function(chunk, encoding, cb) { cb(new ERR_METHOD_NOT_IMPLEMENTED("_write()")); }; Writable.prototype._writev = null; Writable.prototype.end = function(chunk, encoding, cb) { var state = this._writableState; if (typeof chunk === "function") { cb = chunk; chunk = null; encoding = null; } else if (typeof encoding === "function") { cb = encoding; encoding = null; } if (chunk !== null && chunk !== void 0) this.write(chunk, encoding); if (state.corked) { state.corked = 1; this.uncork(); } if (!state.ending) endWritable(this, state, cb); return this; }; Object.defineProperty(Writable.prototype, "writableLength", { // making it explicit this property is not enumerable // because