Files
bare-operating-system/packages/bare-os-seeder/kernel/lib/bare/bundles/bareCov.js
T
2026-04-04 01:20:57 -04:00

11600 lines
408 KiB
JavaScript

var __bare_os_bundle_exports__ = (() => {
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 __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
}) : x)(function(x) {
if (typeof require !== "undefined") return require.apply(this, arguments);
throw Error('Dynamic require of "' + x + '" is not supported');
});
var __commonJS = (cb, mod) => function __require2() {
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/which-runtime/index.js
var require_which_runtime = __commonJS({
"../../node_modules/which-runtime/index.js"(exports) {
var { runtime, platform, arch } = typeof Bare !== "undefined" ? { runtime: "bare", platform: global.Bare.platform, arch: global.Bare.arch } : typeof process !== "undefined" ? { runtime: "node", platform: global.process.platform, arch: global.process.arch } : typeof Window !== "undefined" ? { runtime: "browser", platform: "unknown", arch: "unknown" } : { runtime: "unknown", platform: "unknown", arch: "unknown" };
exports.runtime = runtime;
exports.platform = platform;
exports.arch = arch;
exports.isBare = runtime === "bare";
exports.isBareKit = exports.isBare && typeof BareKit !== "undefined";
exports.isPear = typeof Pear !== "undefined";
exports.isNode = runtime === "node";
exports.isBrowser = runtime === "browser";
exports.isWindows = platform === "win32";
exports.isLinux = platform === "linux";
exports.isMac = platform === "darwin";
exports.isIOS = platform === "ios" || platform === "ios-simulator";
exports.isAndroid = platform === "android";
exports.isElectron = typeof process !== "undefined" && !!global.process.versions?.electron;
exports.isElectronRenderer = exports.isElectron && global.process.type === "renderer";
exports.isElectronWorker = exports.isElectron && global.process.type === "worker";
}
});
// ../../node_modules/bare-abort/binding.js
var require_binding = __commonJS({
"../../node_modules/bare-abort/binding.js"(exports, module) {
module.exports = __require.addon();
}
});
// ../../node_modules/bare-abort/index.js
var require_bare_abort = __commonJS({
"../../node_modules/bare-abort/index.js"(exports, module) {
var binding = require_binding();
module.exports = binding.abort;
}
});
// ../../node_modules/bare-events/lib/errors.js
var require_errors = __commonJS({
"../../node_modules/bare-events/lib/errors.js"(exports, module) {
module.exports = class EventEmitterError extends Error {
constructor(msg, code, fn = EventEmitterError, opts) {
super(`${code}: ${msg}`, opts);
this.code = code;
if (Error.captureStackTrace) {
Error.captureStackTrace(this, fn);
}
}
get name() {
return "EventEmitterError";
}
static OPERATION_ABORTED(cause, msg = "Operation aborted") {
return new EventEmitterError(msg, "OPERATION_ABORTED", EventEmitterError.OPERATION_ABORTED, {
cause
});
}
static UNHANDLED_ERROR(cause, msg = "Unhandled error") {
return new EventEmitterError(msg, "UNHANDLED_ERROR", EventEmitterError.UNHANDLED_ERROR, {
cause
});
}
};
}
});
// ../../node_modules/bare-events/index.js
var require_bare_events = __commonJS({
"../../node_modules/bare-events/index.js"(exports, module) {
var errors = require_errors();
var EventListener = class {
constructor() {
this.list = [];
this.count = 0;
}
append(ctx, name, fn, once) {
this.count++;
ctx.emit("newListener", name, fn);
this.list.push([fn, once]);
}
prepend(ctx, name, fn, once) {
this.count++;
ctx.emit("newListener", name, fn);
this.list.unshift([fn, once]);
}
remove(ctx, name, fn) {
for (let i = 0, n = this.list.length; i < n; i++) {
const l = this.list[i];
if (l[0] === fn) {
this.list.splice(i, 1);
if (this.count === 1) delete ctx._events[name];
ctx.emit("removeListener", name, fn);
this.count--;
return;
}
}
}
removeAll(ctx, name) {
const list = [...this.list];
this.list = [];
if (this.count === list.length) delete ctx._events[name];
for (let i = list.length - 1; i >= 0; i--) {
ctx.emit("removeListener", name, list[i][0]);
}
this.count -= list.length;
}
emit(ctx, name, ...args) {
const list = [...this.list];
for (let i = 0, n = list.length; i < n; i++) {
const l = list[i];
if (l[1] === true) this.remove(ctx, name, l[0]);
Reflect.apply(l[0], ctx, args);
}
return list.length > 0;
}
};
function appendListener(ctx, name, fn, once) {
if (ctx._events === void 0) ctx._events = /* @__PURE__ */ Object.create(null);
const e = ctx._events[name] || (ctx._events[name] = new EventListener());
e.append(ctx, name, fn, once);
return ctx;
}
function prependListener(ctx, name, fn, once) {
if (ctx._events === void 0) ctx._events = /* @__PURE__ */ Object.create(null);
const e = ctx._events[name] || (ctx._events[name] = new EventListener());
e.prepend(ctx, name, fn, once);
return ctx;
}
function removeListener(ctx, name, fn) {
if (ctx._events === void 0) return ctx;
const e = ctx._events[name];
if (e !== void 0) e.remove(ctx, name, fn);
return ctx;
}
function throwUnhandledError(...args) {
let err;
if (args.length > 0) err = args[0];
if (err instanceof Error === false) err = errors.UNHANDLED_ERROR(err);
if (Error.captureStackTrace) {
Error.captureStackTrace(err, exports.prototype.emit);
}
queueMicrotask(() => {
throw err;
});
}
module.exports = exports = class EventEmitter {
constructor() {
this._events = /* @__PURE__ */ Object.create(null);
}
addListener(name, fn) {
return appendListener(this, name, fn, false);
}
addOnceListener(name, fn) {
return appendListener(this, name, fn, true);
}
prependListener(name, fn) {
return prependListener(this, name, fn, false);
}
prependOnceListener(name, fn) {
return prependListener(this, name, fn, true);
}
removeListener(name, fn) {
return removeListener(this, name, fn);
}
on(name, fn) {
return appendListener(this, name, fn, false);
}
once(name, fn) {
return appendListener(this, name, fn, true);
}
off(name, fn) {
return removeListener(this, name, fn);
}
emit(name, ...args) {
if (name === "error" && this._events !== void 0 && this._events.error === void 0) {
throwUnhandledError(...args);
}
if (this._events === void 0) return false;
const e = this._events[name];
return e === void 0 ? false : e.emit(this, name, ...args);
}
listeners(name) {
if (this._events === void 0) return [];
const e = this._events[name];
return e === void 0 ? [] : [...e.list];
}
listenerCount(name) {
if (this._events === void 0) return 0;
const e = this._events[name];
return e === void 0 ? 0 : e.list.length;
}
getMaxListeners() {
return EventEmitter.defaultMaxListeners;
}
setMaxListeners(n) {
}
removeAllListeners(name) {
if (arguments.length === 0) {
for (const key of Reflect.ownKeys(this._events)) {
if (key === "removeListener") continue;
this.removeAllListeners(key);
}
this.removeAllListeners("removeListener");
} else {
const e = this._events[name];
if (e !== void 0) e.removeAll(this, name);
}
return this;
}
};
exports.EventEmitter = exports;
exports.errors = errors;
exports.defaultMaxListeners = 10;
exports.on = function on(emitter, name, opts = {}) {
const { signal } = opts;
if (signal && signal.aborted) {
throw errors.OPERATION_ABORTED(signal.reason);
}
let error = null;
let done = false;
const events = [];
const promises = [];
if (name !== "error") emitter.on("error", onerror);
if (signal) signal.addEventListener("abort", onabort);
emitter.on(name, onevent);
return {
next() {
if (events.length) {
return Promise.resolve({ value: events.shift(), done: false });
}
if (error) {
const err = error;
error = null;
return Promise.reject(err);
}
if (done) return onclose();
return new Promise((resolve, reject) => promises.push({ resolve, reject }));
},
return() {
return onclose();
},
throw(err) {
return onerror(err);
},
[Symbol.asyncIterator]() {
return this;
}
};
function onevent(...args) {
if (promises.length) {
promises.shift().resolve({ value: args, done: false });
} else {
events.push(args);
}
}
function onerror(err) {
emitter.off(name, onevent).off("error", onerror);
if (promises.length) {
promises.shift().reject(err);
} else {
error = err;
}
return Promise.resolve({ done: true });
}
function onabort() {
signal.removeEventListener("abort", onabort);
onerror(errors.OPERATION_ABORTED(signal.reason));
}
function onclose() {
emitter.off(name, onevent);
if (name !== "error") emitter.off("error", onerror);
if (signal) signal.removeEventListener("abort", onabort);
done = true;
if (promises.length) promises.shift().resolve({ done: true });
return Promise.resolve({ done: true });
}
};
exports.once = function once(emitter, name, opts = {}) {
const { signal } = opts;
if (signal && signal.aborted) {
return Promise.reject(errors.OPERATION_ABORTED(signal.reason));
}
return new Promise((resolve, reject) => {
if (name !== "error") emitter.on("error", onerror);
if (signal) signal.addEventListener("abort", onabort);
emitter.once(name, onevent);
function onevent(...args) {
if (name !== "error") emitter.off("error", onerror);
if (signal) signal.removeEventListener("abort", onabort);
resolve(args);
}
function onerror(err) {
emitter.off(name, onevent);
if (name !== "error") emitter.off("error", onerror);
reject(err);
}
function onabort() {
signal.removeEventListener("abort", onabort);
onerror(errors.OPERATION_ABORTED(signal.reason));
}
});
};
exports.forward = function forward(from, to, names, opts = {}) {
if (typeof names === "string") names = [names];
const { emit = to.emit.bind(to) } = opts;
const listeners = names.map(
(name) => function onevent(...args) {
emit(name, ...args);
}
);
to.on("newListener", (name) => {
const i = names.indexOf(name);
if (i !== -1 && to.listenerCount(name) === 0) {
from.on(name, listeners[i]);
}
}).on("removeListener", (name) => {
const i = names.indexOf(name);
if (i !== -1 && to.listenerCount(name) === 0) {
from.off(name, listeners[i]);
}
});
};
exports.listenerCount = function listenerCount(emitter, name) {
return emitter.listenerCount(name);
};
exports.getMaxListeners = function getMaxListeners(emitter) {
if (typeof emitter.getMaxListeners === "function") {
return emitter.getMaxListeners();
}
return exports.defaultMaxListeners;
};
exports.setMaxListeners = function setMaxListeners(n, ...emitters) {
if (emitters.length === 0) exports.defaultMaxListeners = n;
else {
for (const emitter of emitters) {
if (typeof emitter.setMaxListeners === "function") {
emitter.setMaxListeners(n);
}
}
}
};
}
});
// ../../node_modules/bare-os/binding.js
var require_binding2 = __commonJS({
"../../node_modules/bare-os/binding.js"(exports, module) {
module.exports = __require.addon();
}
});
// ../../node_modules/bare-os/lib/errors.js
var require_errors2 = __commonJS({
"../../node_modules/bare-os/lib/errors.js"(exports, module) {
module.exports = class OSError extends Error {
constructor(msg, code, fn = OSError) {
super(`${code}: ${msg}`);
this.code = code;
if (Error.captureStackTrace) {
Error.captureStackTrace(this, fn);
}
}
get name() {
return "OSError";
}
static UNKNOWN_SIGNAL(msg) {
return new OSError(msg, "UNKNOWN_SIGNAL", OSError.UNKNOWN_SIGNAL);
}
static TITLE_OVERFLOW(msg) {
return new OSError(msg, "TITLE_OVERFLOW", OSError.TITLE_OVERFLOW);
}
};
}
});
// ../../node_modules/bare-os/lib/constants.js
var require_constants = __commonJS({
"../../node_modules/bare-os/lib/constants.js"(exports, module) {
var binding = require_binding2();
module.exports = {
signals: binding.signals,
errnos: binding.errnos,
priority: binding.priority
};
}
});
// ../../node_modules/bare-os/index.js
var require_bare_os = __commonJS({
"../../node_modules/bare-os/index.js"(exports) {
var binding = require_binding2();
var errors = require_errors2();
var constants = require_constants();
exports.constants = constants;
exports.EOL = binding.platform === "win32" ? "\r\n" : "\n";
exports.devNull = binding.platform === "win32" ? "\\\\.\\nul" : "/dev/null";
exports.platform = function platform() {
return binding.platform;
};
exports.arch = function arch() {
return binding.arch;
};
exports.type = binding.type;
exports.version = binding.version;
exports.release = binding.release;
exports.machine = binding.machine;
exports.execPath = binding.execPath;
exports.pid = binding.pid;
exports.ppid = binding.ppid;
exports.cwd = binding.cwd;
exports.chdir = binding.chdir;
exports.tmpdir = binding.tmpdir;
exports.homedir = binding.homedir;
exports.hostname = binding.hostname;
exports.userInfo = binding.userInfo;
exports.networkInterfaces = function networkInterfaces() {
const result = {};
for (const entry of binding.networkInterfaces()) {
const { name, ...properties } = entry;
if (result[name]) result[name].push(properties);
else result[name] = [properties];
}
return result;
};
exports.kill = function kill(pid, signal = constants.signals.SIGTERM) {
if (typeof signal === "string") {
if (signal in constants.signals === false) {
throw errors.UNKNOWN_SIGNAL("Unknown signal: " + signal);
}
signal = constants.signals[signal];
}
binding.kill(pid, signal);
};
exports.endianness = function endianness() {
return binding.isLittleEndian ? "LE" : "BE";
};
exports.availableParallelism = binding.availableParallelism;
exports.cpuUsage = function cpuUsage(previous) {
const current = binding.cpuUsage();
if (previous) {
return {
user: current.user - previous.user,
system: current.system - previous.system
};
}
return current;
};
exports.threadCpuUsage = function threadCpuUsage(previous) {
const current = binding.threadCpuUsage();
if (previous) {
return {
user: current.user - previous.user,
system: current.system - previous.system
};
}
return current;
};
exports.resourceUsage = binding.resourceUsage;
exports.memoryUsage = binding.memoryUsage;
exports.freemem = binding.freemem;
exports.totalmem = binding.totalmem;
exports.availableMemory = binding.availableMemory;
exports.constrainedMemory = binding.constrainedMemory;
exports.uptime = binding.uptime;
exports.loadavg = binding.loadavg;
exports.cpus = binding.cpus;
exports.getProcessTitle = binding.getProcessTitle;
exports.setProcessTitle = function setProcessTitle(title) {
if (typeof title !== "string") title = title.toString();
if (title.length >= 256) {
throw errors.TITLE_OVERFLOW("Process title is too long");
}
binding.setProcessTitle(title);
};
exports.getPriority = function getPriority(pid = 0) {
return binding.getPriority(pid);
};
exports.setPriority = function setPriority(pid, priority) {
if (priority === void 0) {
priority = pid;
pid = 0;
}
binding.setPriority(pid, priority);
};
exports.getEnvKeys = binding.getEnvKeys;
exports.getEnv = binding.getEnv;
exports.hasEnv = binding.hasEnv;
exports.setEnv = binding.setEnv;
exports.unsetEnv = binding.unsetEnv;
}
});
// ../../node_modules/bare-signals/binding.js
var require_binding3 = __commonJS({
"../../node_modules/bare-signals/binding.js"(exports, module) {
module.exports = __require.addon();
}
});
// ../../node_modules/bare-signals/lib/errors.js
var require_errors3 = __commonJS({
"../../node_modules/bare-signals/lib/errors.js"(exports, module) {
module.exports = class SignalError extends Error {
constructor(msg, fn = SignalError, code = fn.name) {
super(`${code}: ${msg}`);
this.code = code;
if (Error.captureStackTrace) {
Error.captureStackTrace(this, fn);
}
}
get name() {
return "SignalError";
}
static UNKNOWN_SIGNAL(msg) {
return new SignalError(msg, SignalError.UNKNOWN_SIGNAL);
}
static SIGNAL_CLOSED(msg) {
return new SignalError(msg, SignalError.SIGNAL_CLOSED);
}
};
}
});
// ../../node_modules/bare-signals/lib/emitter.js
var require_emitter = __commonJS({
"../../node_modules/bare-signals/lib/emitter.js"(exports, module) {
var EventEmitter = require_bare_events();
var Signal = require_bare_signals();
module.exports = class SignalEmitter extends EventEmitter {
constructor() {
super();
this._signals = /* @__PURE__ */ new Map();
this._unrefed = false;
this.on("newListener", this._onnewlistener).on(
"removeListener",
this._onremovelistener
);
}
ref() {
this._unrefed = false;
for (const signal of this._signals.values()) signal.ref();
return this;
}
unref() {
this._unrefed = true;
for (const signal of this._signals.values()) signal.unref();
return this;
}
_onnewlistener(name) {
if (name === "newListener" || name === "removeListener") return;
if (this.listenerCount(name) === 0) {
const signal = new Signal(name);
signal.on("signal", this._onsignal.bind(this, name)).start();
if (this._unrefed) signal.unref();
this._signals.set(name, signal);
}
}
_onremovelistener(name) {
if (name === "newListener" || name === "removeListener") return;
if (this.listenerCount(name) === 0) {
const signal = this._signals.get(name);
if (this._unrefed) signal.ref();
signal.close();
this._signals.delete(name);
}
}
_onsignal(name) {
this.emit(name, name, Signal.constants[name]);
}
};
}
});
// ../../node_modules/bare-signals/index.js
var require_bare_signals = __commonJS({
"../../node_modules/bare-signals/index.js"(exports, module) {
var EventEmitter = require_bare_events();
var os = require_bare_os();
var binding = require_binding3();
var errors = require_errors3();
var signals = os.constants.signals;
module.exports = exports = class Signal extends EventEmitter {
constructor(signum) {
super();
if (typeof signum === "string") {
if (signum in signals === false) {
throw errors.UNKNOWN_SIGNAL(`Unknown signal '${signum}'`);
}
signum = signals[signum];
}
this._signum = signum;
this._closing = null;
this._handle = binding.init(this, this._onsignal, this._onclose);
}
start() {
if (this._closing) throw errors.SIGNAL_CLOSED("Signal is closed");
binding.start(this._handle, this._signum);
return this;
}
stop() {
if (this._closing) return this;
binding.stop(this._handle);
return this;
}
ref() {
if (this._closing) return this;
binding.ref(this._handle);
return this;
}
unref() {
if (this._closing) return this;
binding.unref(this._handle);
return this;
}
close() {
if (this._closing) return this._closing;
this._closing = EventEmitter.once(this, "close");
binding.close(this._handle);
return this._closing;
}
_onsignal() {
this.emit("signal", this._signum);
}
_onclose() {
this._handle = null;
this.emit("close");
}
static send(signum, pid = os.pid()) {
os.kill(pid, signum);
}
};
exports.Emitter = require_emitter();
exports.constants = signals;
exports.errors = errors;
}
});
// ../../node_modules/bare-env/index.js
var require_bare_env = __commonJS({
"../../node_modules/bare-env/index.js"(exports, module) {
var os = require_bare_os();
module.exports = new Proxy(/* @__PURE__ */ Object.create(null), {
ownKeys(target) {
return os.getEnvKeys();
},
get(target, property) {
if (typeof property !== "string") return;
return os.getEnv(property);
},
has(target, property) {
if (typeof property !== "string") return false;
return os.hasEnv(property);
},
set(target, property, value2) {
if (typeof property !== "string") return;
const type = typeof value2;
if (type !== "string" && type !== "number" && type !== "boolean") {
throw new Error("Environment variable must be of type string, number, or boolean");
}
value2 = String(value2);
os.setEnv(property, value2);
return true;
},
deleteProperty(target, property) {
if (typeof property !== "string") return;
os.unsetEnv(property);
},
getOwnPropertyDescriptor(target, property) {
return {
value: this.get(target, property),
enumerable: true,
configurable: true,
writable: true
};
}
});
}
});
// ../../node_modules/bare-hrtime/binding.js
var require_binding4 = __commonJS({
"../../node_modules/bare-hrtime/binding.js"(exports, module) {
module.exports = __require.addon();
}
});
// ../../node_modules/bare-hrtime/index.js
var require_bare_hrtime = __commonJS({
"../../node_modules/bare-hrtime/index.js"(exports, module) {
var binding = require_binding4();
module.exports = exports = function hrtime(past) {
let now = binding.hrtime();
if (past) now -= BigInt(past[0]) * 1000000000n + BigInt(past[1]);
return [Number(now / 1000000000n), Number(now % 1000000000n)];
};
exports.bigint = function hrtime() {
return binding.hrtime();
};
}
});
// ../../node_modules/fast-fifo/fixed-size.js
var require_fixed_size = __commonJS({
"../../node_modules/fast-fifo/fixed-size.js"(exports, module) {
module.exports = class FixedFIFO {
constructor(hwm) {
if (!(hwm > 0) || (hwm - 1 & hwm) !== 0) throw new Error("Max size for a FixedFIFO should be a power of two");
this.buffer = new Array(hwm);
this.mask = hwm - 1;
this.top = 0;
this.btm = 0;
this.next = null;
}
clear() {
this.top = this.btm = 0;
this.next = null;
this.buffer.fill(void 0);
}
push(data) {
if (this.buffer[this.top] !== void 0) return false;
this.buffer[this.top] = data;
this.top = this.top + 1 & this.mask;
return true;
}
shift() {
const last = this.buffer[this.btm];
if (last === void 0) return void 0;
this.buffer[this.btm] = void 0;
this.btm = this.btm + 1 & this.mask;
return last;
}
peek() {
return this.buffer[this.btm];
}
isEmpty() {
return this.buffer[this.btm] === void 0;
}
};
}
});
// ../../node_modules/fast-fifo/index.js
var require_fast_fifo = __commonJS({
"../../node_modules/fast-fifo/index.js"(exports, module) {
var FixedFIFO = require_fixed_size();
module.exports = class FastFIFO {
constructor(hwm) {
this.hwm = hwm || 16;
this.head = new FixedFIFO(this.hwm);
this.tail = this.head;
this.length = 0;
}
clear() {
this.head = this.tail;
this.head.clear();
this.length = 0;
}
push(val) {
this.length++;
if (!this.head.push(val)) {
const prev = this.head;
this.head = prev.next = new FixedFIFO(2 * this.head.buffer.length);
this.head.push(val);
}
}
shift() {
if (this.length !== 0) this.length--;
const val = this.tail.shift();
if (val === void 0 && this.tail.next) {
const next = this.tail.next;
this.tail.next = null;
this.tail = next;
return this.tail.shift();
}
return val;
}
peek() {
const val = this.tail.peek();
if (val === void 0 && this.tail.next) return this.tail.next.peek();
return val;
}
isEmpty() {
return this.length === 0;
}
};
}
});
// ../../node_modules/bare-path/lib/constants.js
var require_constants2 = __commonJS({
"../../node_modules/bare-path/lib/constants.js"(exports, module) {
module.exports = {
CHAR_UPPERCASE_A: 65,
CHAR_LOWERCASE_A: 97,
CHAR_UPPERCASE_Z: 90,
CHAR_LOWERCASE_Z: 122,
CHAR_DOT: 46,
CHAR_FORWARD_SLASH: 47,
CHAR_BACKWARD_SLASH: 92,
CHAR_COLON: 58,
CHAR_QUESTION_MARK: 63
};
}
});
// ../../node_modules/bare-path/lib/shared.js
var require_shared = __commonJS({
"../../node_modules/bare-path/lib/shared.js"(exports) {
var {
CHAR_DOT,
CHAR_FORWARD_SLASH
} = require_constants2();
exports.normalizeString = function normalizeString(path, allowAboveRoot, separator, isPathSeparator) {
let res = "";
let lastSegmentLength = 0;
let lastSlash = -1;
let dots = 0;
let code = 0;
for (let i = 0; i <= path.length; ++i) {
if (i < path.length) {
code = path.charCodeAt(i);
} else if (isPathSeparator(code)) {
break;
} else {
code = CHAR_FORWARD_SLASH;
}
if (isPathSeparator(code)) {
if (lastSlash === i - 1 || dots === 1) ;
else if (dots === 2) {
if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== CHAR_DOT || res.charCodeAt(res.length - 2) !== CHAR_DOT) {
if (res.length > 2) {
const lastSlashIndex = res.lastIndexOf(separator);
if (lastSlashIndex === -1) {
res = "";
lastSegmentLength = 0;
} else {
res = res.substring(0, lastSlashIndex);
lastSegmentLength = res.length - 1 - res.lastIndexOf(separator);
}
lastSlash = i;
dots = 0;
continue;
} else if (res.length !== 0) {
res = "";
lastSegmentLength = 0;
lastSlash = i;
dots = 0;
continue;
}
}
if (allowAboveRoot) {
res += res.length > 0 ? `${separator}..` : "..";
lastSegmentLength = 2;
}
} else {
if (res.length > 0) {
res += `${separator}${path.substring(lastSlash + 1, i)}`;
} else {
res = path.substring(lastSlash + 1, i);
}
lastSegmentLength = i - lastSlash - 1;
}
lastSlash = i;
dots = 0;
} else if (code === CHAR_DOT && dots !== -1) {
++dots;
} else {
dots = -1;
}
}
return res;
};
}
});
// ../../node_modules/bare-path/lib/posix.js
var require_posix = __commonJS({
"../../node_modules/bare-path/lib/posix.js"(exports) {
var os = require_bare_os();
var { normalizeString } = require_shared();
var {
CHAR_DOT,
CHAR_FORWARD_SLASH
} = require_constants2();
function isPosixPathSeparator(code) {
return code === CHAR_FORWARD_SLASH;
}
exports.win32 = require_win32();
exports.posix = exports;
exports.sep = "/";
exports.delimiter = ":";
exports.resolve = function resolve(...args) {
let resolvedPath = "";
let resolvedAbsolute = false;
for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
const path = i >= 0 ? args[i] : os.cwd();
if (path.length === 0) {
continue;
}
resolvedPath = `${path}/${resolvedPath}`;
resolvedAbsolute = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
}
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute, "/", isPosixPathSeparator);
if (resolvedAbsolute) {
return `/${resolvedPath}`;
}
return resolvedPath.length > 0 ? resolvedPath : ".";
};
exports.normalize = function normalize(path) {
if (path.length === 0) return ".";
const isAbsolute = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
const trailingSeparator = path.charCodeAt(path.length - 1) === CHAR_FORWARD_SLASH;
path = normalizeString(path, !isAbsolute, "/", isPosixPathSeparator);
if (path.length === 0) {
if (isAbsolute) return "/";
return trailingSeparator ? "./" : ".";
}
if (trailingSeparator) path += "/";
return isAbsolute ? `/${path}` : path;
};
exports.isAbsolute = function isAbsolute(path) {
return path.length > 0 && path.charCodeAt(0) === CHAR_FORWARD_SLASH;
};
exports.join = function join(...args) {
if (args.length === 0) return ".";
let joined;
for (let i = 0; i < args.length; ++i) {
const arg = args[i];
if (arg.length > 0) {
if (joined === void 0) joined = arg;
else joined += `/${arg}`;
}
}
if (joined === void 0) return ".";
return exports.normalize(joined);
};
exports.relative = function relative(from, to) {
if (from === to) return "";
from = exports.resolve(from);
to = exports.resolve(to);
if (from === to) return "";
const fromStart = 1;
const fromEnd = from.length;
const fromLen = fromEnd - fromStart;
const toStart = 1;
const toLen = to.length - toStart;
const length = fromLen < toLen ? fromLen : toLen;
let lastCommonSep = -1;
let i = 0;
for (; i < length; i++) {
const fromCode = from.charCodeAt(fromStart + i);
if (fromCode !== to.charCodeAt(toStart + i)) {
break;
} else if (fromCode === CHAR_FORWARD_SLASH) {
lastCommonSep = i;
}
}
if (i === length) {
if (toLen > length) {
if (to.charCodeAt(toStart + i) === CHAR_FORWARD_SLASH) {
return to.substring(toStart + i + 1);
}
if (i === 0) {
return to.substring(toStart + i);
}
} else if (fromLen > length) {
if (from.charCodeAt(fromStart + i) === CHAR_FORWARD_SLASH) {
lastCommonSep = i;
} else if (i === 0) {
lastCommonSep = 0;
}
}
}
let out = "";
for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
if (i === fromEnd || from.charCodeAt(i) === CHAR_FORWARD_SLASH) {
out += out.length === 0 ? ".." : "/..";
}
}
return `${out}${to.substring(toStart + lastCommonSep)}`;
};
exports.toNamespacedPath = function toNamespacedPath(path) {
return path;
};
exports.dirname = function dirname(path) {
if (path.length === 0) return ".";
const hasRoot = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
let end = -1;
let matchedSlash = true;
for (let i = path.length - 1; i >= 1; --i) {
if (path.charCodeAt(i) === CHAR_FORWARD_SLASH) {
if (!matchedSlash) {
end = i;
break;
}
} else {
matchedSlash = false;
}
}
if (end === -1) return hasRoot ? "/" : ".";
if (hasRoot && end === 1) return "//";
return path.substring(0, end);
};
exports.basename = function basename(path, suffix) {
let start = 0;
let end = -1;
let matchedSlash = true;
if (suffix !== void 0 && suffix.length > 0 && suffix.length <= path.length) {
if (suffix === path) {
return "";
}
let extIdx = suffix.length - 1;
let firstNonSlashEnd = -1;
for (let i = path.length - 1; i >= 0; --i) {
const code = path.charCodeAt(i);
if (code === CHAR_FORWARD_SLASH) {
if (!matchedSlash) {
start = i + 1;
break;
}
} else {
if (firstNonSlashEnd === -1) {
matchedSlash = false;
firstNonSlashEnd = i + 1;
}
if (extIdx >= 0) {
if (code === suffix.charCodeAt(extIdx)) {
if (--extIdx === -1) {
end = i;
}
} else {
extIdx = -1;
end = firstNonSlashEnd;
}
}
}
}
if (start === end) end = firstNonSlashEnd;
else if (end === -1) end = path.length;
return path.substring(start, end);
}
for (let i = path.length - 1; i >= 0; --i) {
if (path.charCodeAt(i) === CHAR_FORWARD_SLASH) {
if (!matchedSlash) {
start = i + 1;
break;
}
} else if (end === -1) {
matchedSlash = false;
end = i + 1;
}
}
if (end === -1) return "";
return path.substring(start, end);
};
exports.extname = function extname(path) {
let startDot = -1;
let startPart = 0;
let end = -1;
let matchedSlash = true;
let preDotState = 0;
for (let i = path.length - 1; i >= 0; --i) {
const code = path.charCodeAt(i);
if (code === CHAR_FORWARD_SLASH) {
if (!matchedSlash) {
startPart = i + 1;
break;
}
continue;
}
if (end === -1) {
matchedSlash = false;
end = i + 1;
}
if (code === CHAR_DOT) {
if (startDot === -1) startDot = i;
else if (preDotState !== 1) preDotState = 1;
} else if (startDot !== -1) {
preDotState = -1;
}
}
if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
return "";
}
return path.substring(startDot, end);
};
}
});
// ../../node_modules/bare-path/lib/win32.js
var require_win32 = __commonJS({
"../../node_modules/bare-path/lib/win32.js"(exports) {
var os = require_bare_os();
var { normalizeString } = require_shared();
var {
CHAR_UPPERCASE_A,
CHAR_LOWERCASE_A,
CHAR_UPPERCASE_Z,
CHAR_LOWERCASE_Z,
CHAR_DOT,
CHAR_FORWARD_SLASH,
CHAR_BACKWARD_SLASH,
CHAR_COLON,
CHAR_QUESTION_MARK
} = require_constants2();
function isWindowsPathSeparator(code) {
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
}
function isWindowsDeviceRoot(code) {
return code >= CHAR_UPPERCASE_A && code <= CHAR_UPPERCASE_Z || code >= CHAR_LOWERCASE_A && code <= CHAR_LOWERCASE_Z;
}
exports.posix = require_posix();
exports.win32 = exports;
exports.sep = "\\";
exports.delimiter = ";";
exports.resolve = function resolve(...args) {
let resolvedDevice = "";
let resolvedTail = "";
let resolvedAbsolute = false;
for (let i = args.length - 1; i >= -1; i--) {
let path;
if (i >= 0) {
path = args[i];
if (path.length === 0) continue;
} else if (resolvedDevice.length === 0) {
path = os.cwd();
} else {
path = os.getEnv(`=${resolvedDevice}`) || os.cwd();
if (path === void 0 || path.substring(0, 2).toLowerCase() !== resolvedDevice.toLowerCase() && path.charCodeAt(2) === CHAR_BACKWARD_SLASH) {
path = `${resolvedDevice}\\`;
}
}
const len = path.length;
let rootEnd = 0;
let device = "";
let isAbsolute = false;
const code = path.charCodeAt(0);
if (len === 1) {
if (isWindowsPathSeparator(code)) {
rootEnd = 1;
isAbsolute = true;
}
} else if (isWindowsPathSeparator(code)) {
isAbsolute = true;
if (isWindowsPathSeparator(path.charCodeAt(1))) {
let j = 2;
let last = j;
while (j < len && !isWindowsPathSeparator(path.charCodeAt(j))) {
j++;
}
if (j < len && j !== last) {
const firstPart = path.substring(last, j);
last = j;
while (j < len && isWindowsPathSeparator(path.charCodeAt(j))) {
j++;
}
if (j < len && j !== last) {
last = j;
while (j < len && !isWindowsPathSeparator(path.charCodeAt(j))) {
j++;
}
if (j === len || j !== last) {
device = `\\\\${firstPart}\\${path.substring(last, j)}`;
rootEnd = j;
}
}
}
} else {
rootEnd = 1;
}
} else if (isWindowsDeviceRoot(code) && path.charCodeAt(1) === CHAR_COLON) {
device = path.substring(0, 2);
rootEnd = 2;
if (len > 2 && isWindowsPathSeparator(path.charCodeAt(2))) {
isAbsolute = true;
rootEnd = 3;
}
}
if (device.length > 0) {
if (resolvedDevice.length > 0) {
if (device.toLowerCase() !== resolvedDevice.toLowerCase()) {
continue;
}
} else {
resolvedDevice = device;
}
}
if (resolvedAbsolute) {
if (resolvedDevice.length > 0) {
break;
}
} else {
resolvedTail = `${path.substring(rootEnd)}\\${resolvedTail}`;
resolvedAbsolute = isAbsolute;
if (isAbsolute && resolvedDevice.length > 0) {
break;
}
}
}
resolvedTail = normalizeString(resolvedTail, !resolvedAbsolute, "\\", isWindowsPathSeparator);
return resolvedAbsolute ? `${resolvedDevice}\\${resolvedTail}` : `${resolvedDevice}${resolvedTail}` || ".";
};
exports.normalize = function normalize(path) {
const len = path.length;
if (len === 0) return ".";
let rootEnd = 0;
let device;
let isAbsolute = false;
const code = path.charCodeAt(0);
if (len === 1) {
return code === CHAR_FORWARD_SLASH ? "\\" : path;
}
if (isWindowsPathSeparator(code)) {
isAbsolute = true;
if (isWindowsPathSeparator(path.charCodeAt(1))) {
let j = 2;
let last = j;
while (j < len && !isWindowsPathSeparator(path.charCodeAt(j))) {
j++;
}
if (j < len && j !== last) {
const firstPart = path.substring(last, j);
last = j;
while (j < len && isWindowsPathSeparator(path.charCodeAt(j))) {
j++;
}
if (j < len && j !== last) {
last = j;
while (j < len && !isWindowsPathSeparator(path.charCodeAt(j))) {
j++;
}
if (j === len) {
return `\\\\${firstPart}\\${path.substring(last)}\\`;
}
if (j !== last) {
device = `\\\\${firstPart}\\${path.substring(last, j)}`;
rootEnd = j;
}
}
}
} else {
rootEnd = 1;
}
} else if (isWindowsDeviceRoot(code) && path.charCodeAt(1) === CHAR_COLON) {
device = path.substring(0, 2);
rootEnd = 2;
if (len > 2 && isWindowsPathSeparator(path.charCodeAt(2))) {
isAbsolute = true;
rootEnd = 3;
}
}
let tail = rootEnd < len ? normalizeString(path.substring(rootEnd), !isAbsolute, "\\", isWindowsPathSeparator) : "";
if (tail.length === 0 && !isAbsolute) {
tail = ".";
}
if (tail.length > 0 && isWindowsPathSeparator(path.charCodeAt(len - 1))) {
tail += "\\";
}
if (device === void 0) {
return isAbsolute ? `\\${tail}` : tail;
}
return isAbsolute ? `${device}\\${tail}` : `${device}${tail}`;
};
exports.isAbsolute = function isAbsolute(path) {
const len = path.length;
if (len === 0) return false;
const code = path.charCodeAt(0);
return isWindowsPathSeparator(code) || len > 2 && isWindowsDeviceRoot(code) && path.charCodeAt(1) === CHAR_COLON && isWindowsPathSeparator(path.charCodeAt(2));
};
exports.join = function join(...args) {
if (args.length === 0) return ".";
let joined;
let firstPart;
for (let i = 0; i < args.length; ++i) {
const arg = args[i];
if (arg.length > 0) {
if (joined === void 0) joined = firstPart = arg;
else joined += `\\${arg}`;
}
}
if (joined === void 0) return ".";
let needsReplace = true;
let slashCount = 0;
if (isWindowsPathSeparator(firstPart.charCodeAt(0))) {
++slashCount;
const firstLen = firstPart.length;
if (firstLen > 1 && isWindowsPathSeparator(firstPart.charCodeAt(1))) {
++slashCount;
if (firstLen > 2) {
if (isWindowsPathSeparator(firstPart.charCodeAt(2))) {
++slashCount;
} else {
needsReplace = false;
}
}
}
}
if (needsReplace) {
while (slashCount < joined.length && isWindowsPathSeparator(joined.charCodeAt(slashCount))) {
slashCount++;
}
if (slashCount >= 2) {
joined = `\\${joined.substring(slashCount)}`;
}
}
return exports.normalize(joined);
};
exports.relative = function relative(from, to) {
if (from === to) return "";
const fromOrig = exports.resolve(from);
const toOrig = exports.resolve(to);
if (fromOrig === toOrig) return "";
from = fromOrig.toLowerCase();
to = toOrig.toLowerCase();
if (from === to) return "";
let fromStart = 0;
while (fromStart < from.length && from.charCodeAt(fromStart) === CHAR_BACKWARD_SLASH) {
fromStart++;
}
let fromEnd = from.length;
while (fromEnd - 1 > fromStart && from.charCodeAt(fromEnd - 1) === CHAR_BACKWARD_SLASH) {
fromEnd--;
}
const fromLen = fromEnd - fromStart;
let toStart = 0;
while (toStart < to.length && to.charCodeAt(toStart) === CHAR_BACKWARD_SLASH) {
toStart++;
}
let toEnd = to.length;
while (toEnd - 1 > toStart && to.charCodeAt(toEnd - 1) === CHAR_BACKWARD_SLASH) {
toEnd--;
}
const toLen = toEnd - toStart;
const length = fromLen < toLen ? fromLen : toLen;
let lastCommonSep = -1;
let i = 0;
for (; i < length; i++) {
const fromCode = from.charCodeAt(fromStart + i);
if (fromCode !== to.charCodeAt(toStart + i)) {
break;
} else if (fromCode === CHAR_BACKWARD_SLASH) {
lastCommonSep = i;
}
}
if (i !== length) {
if (lastCommonSep === -1) return toOrig;
} else {
if (toLen > length) {
if (to.charCodeAt(toStart + i) === CHAR_BACKWARD_SLASH) {
return toOrig.substring(toStart + i + 1);
}
if (i === 2) {
return toOrig.substring(toStart + i);
}
}
if (fromLen > length) {
if (from.charCodeAt(fromStart + i) === CHAR_BACKWARD_SLASH) {
lastCommonSep = i;
} else if (i === 2) {
lastCommonSep = 3;
}
}
if (lastCommonSep === -1) lastCommonSep = 0;
}
let out = "";
for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
if (i === fromEnd || from.charCodeAt(i) === CHAR_BACKWARD_SLASH) {
out += out.length === 0 ? ".." : "\\..";
}
}
toStart += lastCommonSep;
if (out.length > 0) {
return `${out}${toOrig.substring(toStart, toEnd)}`;
}
if (toOrig.charCodeAt(toStart) === CHAR_BACKWARD_SLASH) {
++toStart;
}
return toOrig.substring(toStart, toEnd);
};
exports.toNamespacedPath = function toNamespacedPath(path) {
if (path.length === 0) return path;
const resolvedPath = exports.resolve(path);
if (resolvedPath.length <= 2) return path;
if (resolvedPath.charCodeAt(0) === CHAR_BACKWARD_SLASH) {
if (resolvedPath.charCodeAt(1) === CHAR_BACKWARD_SLASH) {
const code = resolvedPath.charCodeAt(2);
if (code !== CHAR_QUESTION_MARK && code !== CHAR_DOT) {
return `\\\\?\\UNC\\${resolvedPath.substring(2)}`;
}
}
} else if (isWindowsDeviceRoot(resolvedPath.charCodeAt(0)) && resolvedPath.charCodeAt(1) === CHAR_COLON && resolvedPath.charCodeAt(2) === CHAR_BACKWARD_SLASH) {
return `\\\\?\\${resolvedPath}`;
}
return path;
};
exports.dirname = function dirname(path) {
const len = path.length;
if (len === 0) return ".";
let rootEnd = -1;
let offset = 0;
const code = path.charCodeAt(0);
if (len === 1) {
return isWindowsPathSeparator(code) ? path : ".";
}
if (isWindowsPathSeparator(code)) {
rootEnd = offset = 1;
if (isWindowsPathSeparator(path.charCodeAt(1))) {
let j = 2;
let last = j;
while (j < len && !isWindowsPathSeparator(path.charCodeAt(j))) {
j++;
}
if (j < len && j !== last) {
last = j;
while (j < len && isWindowsPathSeparator(path.charCodeAt(j))) {
j++;
}
if (j < len && j !== last) {
last = j;
while (j < len && !isWindowsPathSeparator(path.charCodeAt(j))) {
j++;
}
if (j === len) {
return path;
}
if (j !== last) {
rootEnd = offset = j + 1;
}
}
}
}
} else if (isWindowsDeviceRoot(code) && path.charCodeAt(1) === CHAR_COLON) {
rootEnd = len > 2 && isWindowsPathSeparator(path.charCodeAt(2)) ? 3 : 2;
offset = rootEnd;
}
let end = -1;
let matchedSlash = true;
for (let i = len - 1; i >= offset; --i) {
if (isWindowsPathSeparator(path.charCodeAt(i))) {
if (!matchedSlash) {
end = i;
break;
}
} else {
matchedSlash = false;
}
}
if (end === -1) {
if (rootEnd === -1) return ".";
end = rootEnd;
}
return path.substring(0, end);
};
exports.basename = function basename(path, suffix) {
let start = 0;
let end = -1;
let matchedSlash = true;
if (path.length >= 2 && isWindowsDeviceRoot(path.charCodeAt(0)) && path.charCodeAt(1) === CHAR_COLON) {
start = 2;
}
if (suffix !== void 0 && suffix.length > 0 && suffix.length <= path.length) {
if (suffix === path) return "";
let extIdx = suffix.length - 1;
let firstNonSlashEnd = -1;
for (let i = path.length - 1; i >= start; --i) {
const code = path.charCodeAt(i);
if (isWindowsPathSeparator(code)) {
if (!matchedSlash) {
start = i + 1;
break;
}
} else {
if (firstNonSlashEnd === -1) {
matchedSlash = false;
firstNonSlashEnd = i + 1;
}
if (extIdx >= 0) {
if (code === suffix.charCodeAt(extIdx)) {
if (--extIdx === -1) {
end = i;
}
} else {
extIdx = -1;
end = firstNonSlashEnd;
}
}
}
}
if (start === end) end = firstNonSlashEnd;
else if (end === -1) end = path.length;
return path.substring(start, end);
}
for (let i = path.length - 1; i >= start; --i) {
if (isWindowsPathSeparator(path.charCodeAt(i))) {
if (!matchedSlash) {
start = i + 1;
break;
}
} else if (end === -1) {
matchedSlash = false;
end = i + 1;
}
}
if (end === -1) return "";
return path.substring(start, end);
};
exports.extname = function extname(path) {
let start = 0;
let startDot = -1;
let startPart = 0;
let end = -1;
let matchedSlash = true;
let preDotState = 0;
if (path.length >= 2 && path.charCodeAt(1) === CHAR_COLON && isWindowsDeviceRoot(path.charCodeAt(0))) {
start = startPart = 2;
}
for (let i = path.length - 1; i >= start; --i) {
const code = path.charCodeAt(i);
if (isWindowsPathSeparator(code)) {
if (!matchedSlash) {
startPart = i + 1;
break;
}
continue;
}
if (end === -1) {
matchedSlash = false;
end = i + 1;
}
if (code === CHAR_DOT) {
if (startDot === -1) startDot = i;
else if (preDotState !== 1) preDotState = 1;
} else if (startDot !== -1) {
preDotState = -1;
}
}
if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
return "";
}
return path.substring(startDot, end);
};
}
});
// ../../node_modules/bare-path/index.js
var require_bare_path = __commonJS({
"../../node_modules/bare-path/index.js"(exports, module) {
if (Bare.platform === "win32") {
module.exports = require_win32();
} else {
module.exports = require_posix();
}
}
});
// ../../node_modules/bare-url/binding.js
var require_binding5 = __commonJS({
"../../node_modules/bare-url/binding.js"(exports, module) {
module.exports = __require.addon();
}
});
// ../../node_modules/bare-url/lib/errors.js
var require_errors4 = __commonJS({
"../../node_modules/bare-url/lib/errors.js"(exports, module) {
module.exports = class URLError extends Error {
constructor(msg, fn = URLError, code = fn.name) {
super(`${code}: ${msg}`);
this.code = code;
if (Error.captureStackTrace) Error.captureStackTrace(this, fn);
}
get name() {
return "URLError";
}
static INVALID_URL(msg, input) {
const err = new URLError(msg, URLError.INVALID_URL);
err.input = input;
return err;
}
static INVALID_URL_SCHEME(msg = "Invalid URL") {
return new URLError(msg, URLError.INVALID_URL_SCHEME);
}
static INVALID_FILE_URL_HOST(msg = "Invalid file: URL host") {
return new URLError(msg, URLError.INVALID_FILE_URL_HOST);
}
static INVALID_FILE_URL_PATH(msg = "Invalid file: URL path") {
return new URLError(msg, URLError.INVALID_FILE_URL_PATH);
}
};
}
});
// ../../node_modules/bare-url/lib/url-search-params.js
var require_url_search_params = __commonJS({
"../../node_modules/bare-url/lib/url-search-params.js"(exports, module) {
var kind = Symbol.for("bare.url.search-params.kind");
var URLSearchParams = class _URLSearchParams {
static _urls = /* @__PURE__ */ new WeakMap();
static get [kind]() {
return 0;
}
// https://url.spec.whatwg.org/#dom-urlsearchparams-urlsearchparams
constructor(init, url = null) {
this._params = /* @__PURE__ */ new Map();
if (url) _URLSearchParams._urls.set(this, url);
if (typeof init === "string") {
this._parse(init);
} else if (init) {
for (const [name, value2] of typeof init[Symbol.iterator] === "function" ? init : Object.entries(init)) {
this.append(name, value2);
}
}
}
get [kind]() {
return _URLSearchParams[kind];
}
// https://url.spec.whatwg.org/#dom-urlsearchparams-size
get size() {
return this._params.length;
}
// https://url.spec.whatwg.org/#dom-urlsearchparams-append
append(name, value2 = null) {
if (value2 === null) return;
let list = this._params.get(name);
if (list === void 0) {
list = [];
this._params.set(name, list);
}
list.push(value2);
this._update();
}
// https://url.spec.whatwg.org/#dom-urlsearchparams-delete
delete(name, value2 = null) {
if (value2 === null) this._params.delete(name);
else {
let list = this._params.get(name);
if (list === void 0) return;
list = list.filter((found) => found !== value2);
if (list.length === 0) this._params.delete(name);
else this._params.set(name, list);
}
this._update();
}
// https://url.spec.whatwg.org/#dom-urlsearchparams-get
get(name) {
const list = this._params.get(name);
if (list === void 0) return null;
return list[0];
}
// https://url.spec.whatwg.org/#dom-urlsearchparams-getall
getAll(name) {
const list = this._params.get(name);
if (list === void 0) return [];
return Array.from(list);
}
// https://url.spec.whatwg.org/#dom-urlsearchparams-has
has(name, value2 = null) {
const list = this._params.get(name);
if (list === void 0) return false;
if (value2 === null) return true;
return list.includes(value2);
}
// https://url.spec.whatwg.org/#dom-urlsearchparams-set
set(name, value2 = null) {
if (value2 === null) this._params.delete(name);
else this._params.set(name, [value2]);
this._update();
}
toString() {
return this._serialize();
}
toJSON() {
return [...this];
}
*[Symbol.iterator]() {
for (const [name, values] of this._params) {
for (const value2 of values) yield [name, value2];
}
}
[Symbol.for("bare.inspect")]() {
const object = {
__proto__: { constructor: _URLSearchParams }
};
for (const [name, values] of this._params) {
if (values.length === 1) object[name] = values[0];
else object[name] = values;
}
return object;
}
// https://url.spec.whatwg.org/#concept-urlsearchparams-update
_update() {
const url = _URLSearchParams._urls.get(this);
if (url === void 0) return;
url.search = this._serialize();
}
// https://url.spec.whatwg.org/#concept-urlencoded-parser
_parse(input) {
if (input[0] === "?") input = input.substring(1);
this._params = /* @__PURE__ */ new Map();
for (const sequence of input.split("&")) {
if (sequence.length === 0) continue;
let i = sequence.indexOf("=");
if (i === -1) i = sequence.length;
const name = decodeURIComponent(sequence.substring(0, i));
const value2 = decodeURIComponent(sequence.substring(i + 1, sequence.length));
let list = this._params.get(name);
if (list === void 0) {
list = [];
this._params.set(name, list);
}
list.push(value2);
}
}
// https://url.spec.whatwg.org/#concept-urlencoded-serializer
_serialize() {
let output = "";
for (let [name, values] of this._params) {
name = encodeURIComponent(name);
for (const value2 of values) {
if (output) output += "&";
output += name + "=" + encodeURIComponent(value2);
}
}
return output;
}
};
module.exports = exports = URLSearchParams;
exports.isURLSearchParams = function isURLSearchParams(value2) {
if (value2 instanceof URLSearchParams) return true;
return typeof value2 === "object" && value2 !== null && value2[kind] === URLSearchParams[kind];
};
}
});
// ../../node_modules/bare-url/index.js
var require_bare_url = __commonJS({
"../../node_modules/bare-url/index.js"(exports, module) {
var path = require_bare_path();
var binding = require_binding5();
var errors = require_errors4();
var URLSearchParams = require_url_search_params();
var kind = Symbol.for("bare.url.kind");
var isWindows = Bare.platform === "win32";
var URL = class _URL {
static get [kind]() {
return 0;
}
constructor(input, base, opts = {}) {
if (arguments.length === 0) throw errors.INVALID_URL();
input = String(input);
if (base !== void 0) base = String(base);
this._components = new Uint32Array(8);
this._parse(input, base, opts.throw !== false);
if (this._href) this._params = new URLSearchParams(this.search, this);
}
get [kind]() {
return _URL[kind];
}
// https://url.spec.whatwg.org/#dom-url-href
get href() {
return this._href;
}
set href(value2) {
this._update(value2);
this._params._parse(this.search);
}
// https://url.spec.whatwg.org/#dom-url-protocol
get protocol() {
return this._slice(0, this._components[0]) + ":";
}
set protocol(value2) {
this._update(this._replace(value2.replace(/:+$/, ""), 0, this._components[0]));
}
// https://url.spec.whatwg.org/#dom-url-username
get username() {
return this._slice(this._components[0] + 3, this._components[1]);
}
set username(value2) {
if (cannotHaveCredentialsOrPort(this)) {
return;
}
if (this.username === "") value2 += "@";
this._update(this._replace(value2, this._components[0] + 3, this._components[1]));
}
// https://url.spec.whatwg.org/#dom-url-password
get password() {
return this._href.slice(
this._components[1] + 1,
this._components[2] - 1
/* @ */
);
}
set password(value2) {
if (cannotHaveCredentialsOrPort(this)) {
return;
}
let start = this._components[1] + 1;
let end = this._components[2] - 1;
if (this.password === "") {
value2 = ":" + value2;
start--;
}
if (this.username === "") {
value2 += "@";
end++;
}
this._update(this._replace(value2, start, end));
}
// https://url.spec.whatwg.org/#dom-url-host
get host() {
return this._slice(this._components[2], this._components[5]);
}
set host(value2) {
if (hasOpaquePath(this)) {
return;
}
this._update(
this._replace(value2, this._components[2], this._components[value2.includes(":") ? 5 : 3])
);
}
// https://url.spec.whatwg.org/#dom-url-hostname
get hostname() {
return this._slice(this._components[2], this._components[3]);
}
set hostname(value2) {
if (hasOpaquePath(this)) {
return;
}
this._update(this._replace(value2, this._components[2], this._components[3]));
}
// https://url.spec.whatwg.org/#dom-url-port
get port() {
return this._slice(this._components[3] + 1, this._components[5]);
}
set port(value2) {
if (cannotHaveCredentialsOrPort(this)) {
return;
}
let start = this._components[3] + 1;
if (this.port === "") {
value2 = ":" + value2;
start--;
}
this._update(this._replace(value2, start, this._components[5]));
}
// https://url.spec.whatwg.org/#dom-url-pathname
get pathname() {
return this._slice(
this._components[5],
this._components[6] - 1
/* ? */
);
}
set pathname(value2) {
if (hasOpaquePath(this)) {
return;
}
if (value2[0] !== "/" && value2[0] !== "\\") {
value2 = "/" + value2;
}
this._update(this._replace(
value2,
this._components[5],
this._components[6] - 1
/* ? */
));
}
// https://url.spec.whatwg.org/#dom-url-search
get search() {
return this._slice(
this._components[6] - 1,
this._components[7] - 1
/* # */
);
}
set search(value2) {
if (value2 && value2[0] !== "?") value2 = "?" + value2;
this._update(
this._replace(
value2,
this._components[6] - 1,
this._components[7] - 1
/* # */
)
);
this._params._parse(this.search);
}
// https://url.spec.whatwg.org/#dom-url-searchparams
get searchParams() {
return this._params;
}
// https://url.spec.whatwg.org/#dom-url-hash
get hash() {
return this._slice(
this._components[7] - 1
/* # */
);
}
set hash(value2) {
if (value2 && value2[0] !== "#") value2 = "#" + value2;
this._update(this._replace(
value2,
this._components[7] - 1
/* # */
));
}
toString() {
return this._href;
}
toJSON() {
return this._href;
}
[Symbol.for("bare.inspect")]() {
return {
__proto__: { constructor: _URL },
href: this.href,
protocol: this.protocol,
username: this.username,
password: this.password,
host: this.host,
hostname: this.hostname,
port: this.port,
pathname: this.pathname,
search: this.search,
searchParams: this.searchParams,
hash: this.hash
};
}
_slice(start, end = this._href.length) {
return this._href.slice(start, end);
}
_replace(replacement, start, end = this._href.length) {
return this._slice(0, start) + replacement + this._slice(end);
}
_parse(input, base, shouldThrow) {
try {
this._href = binding.parse(
String(input),
base ? String(base) : null,
this._components,
shouldThrow
);
} catch (err) {
if (err instanceof TypeError) throw err;
throw errors.INVALID_URL(`Invalid URL '${input}'`, input);
}
}
_update(input) {
try {
this._parse(input, null, true);
} catch (err) {
if (err instanceof TypeError) throw err;
}
}
};
module.exports = exports = URL;
function hasOpaquePath(url) {
return url.pathname[0] !== "/";
}
function cannotHaveCredentialsOrPort(url) {
return url.hostname === "" || url.protocol === "file:";
}
exports.URL = URL;
exports.URLSearchParams = URLSearchParams;
exports.errors = errors;
exports.isURL = function isURL(value2) {
if (value2 instanceof URL) return true;
return typeof value2 === "object" && value2 !== null && value2[kind] === URL[kind];
};
exports.isURLSearchParams = URLSearchParams.isURLSearchParams;
exports.parse = function parse(input, base) {
const url = new URL(input, base, { throw: false });
return url._href ? url : null;
};
exports.canParse = function canParse(input, base) {
return binding.canParse(String(input), base ? String(base) : null);
};
exports.fileURLToPath = function fileURLToPath(url) {
if (typeof url === "string") {
url = new URL(url);
}
if (url.protocol !== "file:") {
throw errors.INVALID_URL_SCHEME("The URL must use the file: protocol");
}
if (isWindows) {
if (/%2f|%5c/i.test(url.pathname)) {
throw errors.INVALID_FILE_URL_PATH(
"The file: URL path must not include encoded \\ or / characters"
);
}
} else {
if (url.hostname) {
throw errors.INVALID_FILE_URL_HOST("The file: URL host must be 'localhost' or empty");
}
if (/%2f/i.test(url.pathname)) {
throw errors.INVALID_FILE_URL_PATH("The file: URL path must not include encoded / characters");
}
}
const pathname = path.normalize(decodeURIComponent(url.pathname));
if (isWindows) {
if (url.hostname) return "\\\\" + url.hostname + pathname;
const letter = pathname.charCodeAt(1) | 32;
if (letter < 97 || letter > 122 || pathname.charCodeAt(2) !== 58) {
throw errors.INVALID_FILE_URL_PATH("The file: URL path must be absolute");
}
return pathname.slice(1);
}
return pathname;
};
exports.pathToFileURL = function pathToFileURL(pathname) {
let resolved = path.resolve(pathname);
if (pathname[pathname.length - 1] === "/") {
resolved += "/";
} else if (isWindows && pathname[pathname.length - 1] === "\\") {
resolved += "\\";
}
resolved = resolved.replaceAll("%", "%25").replaceAll("#", "%23").replaceAll("?", "%3f").replaceAll("\n", "%0a").replaceAll("\r", "%0d").replaceAll(" ", "%09");
if (!isWindows) {
resolved = resolved.replaceAll("\\", "%5c");
}
return new URL("file:" + resolved);
};
exports.format = function format(parts) {
const { protocol, auth, host, hostname, port, pathname, search, query, hash, slashes } = parts;
let result = "";
if (typeof protocol === "string") {
result += protocol;
if (protocol[protocol.length - 1] !== ":") {
result += ":";
}
if (slashes === true || /https?|ftp|gopher|file/.test(protocol)) {
result += "//";
}
}
if (typeof auth === "string") {
if (host || hostname) result += auth + "@";
}
if (typeof host === "string") result += host;
else {
result += hostname;
if (port) result += ":" + port;
}
if (typeof pathname === "string" && pathname !== "") {
if (pathname[0] !== "/") result += "/";
result += pathname;
}
if (typeof search === "string") {
if (search[0] !== "?") result += "?";
result += search;
} else if (typeof query === "object" && query !== null) {
result += "?" + new URLSearchParams(query);
}
if (typeof hash === "string") {
if (hash[0] !== "#") result += "#";
result += hash;
}
return result;
};
}
});
// ../../node_modules/events-universal/default.js
var require_default = __commonJS({
"../../node_modules/events-universal/default.js"(exports, module) {
module.exports = __require("events");
}
});
// ../../node_modules/b4a/index.js
var require_b4a = __commonJS({
"../../node_modules/b4a/index.js"(exports, module) {
function isBuffer(value2) {
return Buffer.isBuffer(value2) || value2 instanceof Uint8Array;
}
function isEncoding(encoding) {
return Buffer.isEncoding(encoding);
}
function alloc(size, fill2, encoding) {
return Buffer.alloc(size, fill2, encoding);
}
function allocUnsafe(size) {
return Buffer.allocUnsafe(size);
}
function allocUnsafeSlow(size) {
return Buffer.allocUnsafeSlow(size);
}
function byteLength(string, encoding) {
return Buffer.byteLength(string, encoding);
}
function compare(a, b) {
return Buffer.compare(a, b);
}
function concat(buffers, totalLength) {
return Buffer.concat(buffers, totalLength);
}
function copy(source, target, targetStart, start, end) {
return toBuffer(source).copy(target, targetStart, start, end);
}
function equals(a, b) {
return toBuffer(a).equals(b);
}
function fill(buffer, value2, offset, end, encoding) {
return toBuffer(buffer).fill(value2, offset, end, encoding);
}
function from(value2, encodingOrOffset, length) {
return Buffer.from(value2, encodingOrOffset, length);
}
function includes(buffer, value2, byteOffset, encoding) {
return toBuffer(buffer).includes(value2, byteOffset, encoding);
}
function indexOf(buffer, value2, byfeOffset, encoding) {
return toBuffer(buffer).indexOf(value2, byfeOffset, encoding);
}
function lastIndexOf(buffer, value2, byteOffset, encoding) {
return toBuffer(buffer).lastIndexOf(value2, byteOffset, encoding);
}
function swap16(buffer) {
return toBuffer(buffer).swap16();
}
function swap32(buffer) {
return toBuffer(buffer).swap32();
}
function swap64(buffer) {
return toBuffer(buffer).swap64();
}
function toBuffer(buffer) {
if (Buffer.isBuffer(buffer)) return buffer;
return Buffer.from(buffer.buffer, buffer.byteOffset, buffer.byteLength);
}
function toString(buffer, encoding, start, end) {
return toBuffer(buffer).toString(encoding, start, end);
}
function write(buffer, string, offset, length, encoding) {
return toBuffer(buffer).write(string, offset, length, encoding);
}
function readDoubleBE(buffer, offset) {
return toBuffer(buffer).readDoubleBE(offset);
}
function readDoubleLE(buffer, offset) {
return toBuffer(buffer).readDoubleLE(offset);
}
function readFloatBE(buffer, offset) {
return toBuffer(buffer).readFloatBE(offset);
}
function readFloatLE(buffer, offset) {
return toBuffer(buffer).readFloatLE(offset);
}
function readInt32BE(buffer, offset) {
return toBuffer(buffer).readInt32BE(offset);
}
function readInt32LE(buffer, offset) {
return toBuffer(buffer).readInt32LE(offset);
}
function readUInt32BE(buffer, offset) {
return toBuffer(buffer).readUInt32BE(offset);
}
function readUInt32LE(buffer, offset) {
return toBuffer(buffer).readUInt32LE(offset);
}
function writeDoubleBE(buffer, value2, offset) {
return toBuffer(buffer).writeDoubleBE(value2, offset);
}
function writeDoubleLE(buffer, value2, offset) {
return toBuffer(buffer).writeDoubleLE(value2, offset);
}
function writeFloatBE(buffer, value2, offset) {
return toBuffer(buffer).writeFloatBE(value2, offset);
}
function writeFloatLE(buffer, value2, offset) {
return toBuffer(buffer).writeFloatLE(value2, offset);
}
function writeInt32BE(buffer, value2, offset) {
return toBuffer(buffer).writeInt32BE(value2, offset);
}
function writeInt32LE(buffer, value2, offset) {
return toBuffer(buffer).writeInt32LE(value2, offset);
}
function writeUInt32BE(buffer, value2, offset) {
return toBuffer(buffer).writeUInt32BE(value2, offset);
}
function writeUInt32LE(buffer, value2, offset) {
return toBuffer(buffer).writeUInt32LE(value2, offset);
}
module.exports = {
isBuffer,
isEncoding,
alloc,
allocUnsafe,
allocUnsafeSlow,
byteLength,
compare,
concat,
copy,
equals,
fill,
from,
includes,
indexOf,
lastIndexOf,
swap16,
swap32,
swap64,
toBuffer,
toString,
write,
readDoubleBE,
readDoubleLE,
readFloatBE,
readFloatLE,
readInt32BE,
readInt32LE,
readUInt32BE,
readUInt32LE,
writeDoubleBE,
writeDoubleLE,
writeFloatBE,
writeFloatLE,
writeInt32BE,
writeInt32LE,
writeUInt32BE,
writeUInt32LE
};
}
});
// ../../node_modules/text-decoder/lib/pass-through-decoder.js
var require_pass_through_decoder = __commonJS({
"../../node_modules/text-decoder/lib/pass-through-decoder.js"(exports, module) {
var b4a = require_b4a();
module.exports = class PassThroughDecoder {
constructor(encoding) {
this.encoding = encoding;
}
get remaining() {
return 0;
}
decode(data) {
return b4a.toString(data, this.encoding);
}
flush() {
return "";
}
};
}
});
// ../../node_modules/text-decoder/lib/utf8-decoder.js
var require_utf8_decoder = __commonJS({
"../../node_modules/text-decoder/lib/utf8-decoder.js"(exports, module) {
var b4a = require_b4a();
module.exports = class UTF8Decoder {
constructor() {
this._reset();
}
get remaining() {
return this.bytesSeen;
}
decode(data) {
if (data.byteLength === 0) return "";
if (this.bytesNeeded === 0 && trailingIncomplete(data, 0) === 0) {
this.bytesSeen = trailingBytesSeen(data);
return b4a.toString(data, "utf8");
}
let result = "";
let start = 0;
if (this.bytesNeeded > 0) {
while (start < data.byteLength) {
const byte = data[start];
if (byte < this.lowerBoundary || byte > this.upperBoundary) {
result += "\uFFFD";
this._reset();
break;
}
this.lowerBoundary = 128;
this.upperBoundary = 191;
this.codePoint = this.codePoint << 6 | byte & 63;
this.bytesSeen++;
start++;
if (this.bytesSeen === this.bytesNeeded) {
result += String.fromCodePoint(this.codePoint);
this._reset();
break;
}
}
if (this.bytesNeeded > 0) return result;
}
const trailing = trailingIncomplete(data, start);
const end = data.byteLength - trailing;
if (end > start) result += b4a.toString(data, "utf8", start, end);
for (let i = end; i < data.byteLength; i++) {
const byte = data[i];
if (this.bytesNeeded === 0) {
if (byte <= 127) {
this.bytesSeen = 0;
result += String.fromCharCode(byte);
} else if (byte >= 194 && byte <= 223) {
this.bytesNeeded = 2;
this.bytesSeen = 1;
this.codePoint = byte & 31;
} else if (byte >= 224 && byte <= 239) {
if (byte === 224) this.lowerBoundary = 160;
else if (byte === 237) this.upperBoundary = 159;
this.bytesNeeded = 3;
this.bytesSeen = 1;
this.codePoint = byte & 15;
} else if (byte >= 240 && byte <= 244) {
if (byte === 240) this.lowerBoundary = 144;
else if (byte === 244) this.upperBoundary = 143;
this.bytesNeeded = 4;
this.bytesSeen = 1;
this.codePoint = byte & 7;
} else {
this.bytesSeen = 1;
result += "\uFFFD";
}
continue;
}
if (byte < this.lowerBoundary || byte > this.upperBoundary) {
result += "\uFFFD";
i--;
this._reset();
continue;
}
this.lowerBoundary = 128;
this.upperBoundary = 191;
this.codePoint = this.codePoint << 6 | byte & 63;
this.bytesSeen++;
if (this.bytesSeen === this.bytesNeeded) {
result += String.fromCodePoint(this.codePoint);
this._reset();
}
}
return result;
}
flush() {
const result = this.bytesNeeded > 0 ? "\uFFFD" : "";
this._reset();
return result;
}
_reset() {
this.codePoint = 0;
this.bytesNeeded = 0;
this.bytesSeen = 0;
this.lowerBoundary = 128;
this.upperBoundary = 191;
}
};
function trailingIncomplete(data, start) {
const len = data.byteLength;
if (len <= start) return 0;
const limit = Math.max(start, len - 4);
let i = len - 1;
while (i > limit && (data[i] & 192) === 128) i--;
if (i < start) return 0;
const byte = data[i];
let needed;
if (byte <= 127) return 0;
if (byte >= 194 && byte <= 223) needed = 2;
else if (byte >= 224 && byte <= 239) needed = 3;
else if (byte >= 240 && byte <= 244) needed = 4;
else return 0;
const available = len - i;
return available < needed ? available : 0;
}
function trailingBytesSeen(data) {
const len = data.byteLength;
if (len === 0) return 0;
const last = data[len - 1];
if (last <= 127) return 0;
if ((last & 192) !== 128) return 1;
const limit = Math.max(0, len - 4);
let i = len - 2;
while (i >= limit && (data[i] & 192) === 128) i--;
if (i < 0) return 1;
const first = data[i];
let needed;
if (first >= 194 && first <= 223) needed = 2;
else if (first >= 224 && first <= 239) needed = 3;
else if (first >= 240 && first <= 244) needed = 4;
else return 1;
if (len - i !== needed) return 1;
if (needed >= 3) {
const second = data[i + 1];
if (first === 224 && second < 160) return 1;
if (first === 237 && second > 159) return 1;
if (first === 240 && second < 144) return 1;
if (first === 244 && second > 143) return 1;
}
return 0;
}
}
});
// ../../node_modules/text-decoder/index.js
var require_text_decoder = __commonJS({
"../../node_modules/text-decoder/index.js"(exports, module) {
var PassThroughDecoder = require_pass_through_decoder();
var UTF8Decoder = require_utf8_decoder();
module.exports = class TextDecoder {
constructor(encoding = "utf8") {
this.encoding = normalizeEncoding(encoding);
switch (this.encoding) {
case "utf8":
this.decoder = new UTF8Decoder();
break;
case "utf16le":
case "base64":
throw new Error("Unsupported encoding: " + this.encoding);
default:
this.decoder = new PassThroughDecoder(this.encoding);
}
}
get remaining() {
return this.decoder.remaining;
}
push(data) {
if (typeof data === "string") return data;
return this.decoder.decode(data);
}
// For Node.js compatibility
write(data) {
return this.push(data);
}
end(data) {
let result = "";
if (data) result = this.push(data);
result += this.decoder.flush();
return result;
}
};
function normalizeEncoding(encoding) {
encoding = encoding.toLowerCase();
switch (encoding) {
case "utf8":
case "utf-8":
return "utf8";
case "ucs2":
case "ucs-2":
case "utf16le":
case "utf-16le":
return "utf16le";
case "latin1":
case "binary":
return "latin1";
case "base64":
case "ascii":
case "hex":
return encoding;
default:
throw new Error("Unknown encoding: " + encoding);
}
}
}
});
// ../../node_modules/streamx/index.js
var require_streamx = __commonJS({
"../../node_modules/streamx/index.js"(exports, module) {
var { EventEmitter } = require_default();
var STREAM_DESTROYED = new Error("Stream was destroyed");
var PREMATURE_CLOSE = new Error("Premature close");
var FIFO = require_fast_fifo();
var TextDecoder2 = require_text_decoder();
var qmt = typeof queueMicrotask === "undefined" ? (fn) => global.process.nextTick(fn) : queueMicrotask;
var MAX = (1 << 29) - 1;
var OPENING = 1;
var PREDESTROYING = 2;
var DESTROYING = 4;
var DESTROYED = 8;
var NOT_OPENING = MAX ^ OPENING;
var NOT_PREDESTROYING = MAX ^ PREDESTROYING;
var READ_ACTIVE = 1 << 4;
var READ_UPDATING = 2 << 4;
var READ_PRIMARY = 4 << 4;
var READ_QUEUED = 8 << 4;
var READ_RESUMED = 16 << 4;
var READ_PIPE_DRAINED = 32 << 4;
var READ_ENDING = 64 << 4;
var READ_EMIT_DATA = 128 << 4;
var READ_EMIT_READABLE = 256 << 4;
var READ_EMITTED_READABLE = 512 << 4;
var READ_DONE = 1024 << 4;
var READ_NEXT_TICK = 2048 << 4;
var READ_NEEDS_PUSH = 4096 << 4;
var READ_READ_AHEAD = 8192 << 4;
var READ_FLOWING = READ_RESUMED | READ_PIPE_DRAINED;
var READ_ACTIVE_AND_NEEDS_PUSH = READ_ACTIVE | READ_NEEDS_PUSH;
var READ_PRIMARY_AND_ACTIVE = READ_PRIMARY | READ_ACTIVE;
var READ_EMIT_READABLE_AND_QUEUED = READ_EMIT_READABLE | READ_QUEUED;
var READ_RESUMED_READ_AHEAD = READ_RESUMED | READ_READ_AHEAD;
var READ_NOT_ACTIVE = MAX ^ READ_ACTIVE;
var READ_NON_PRIMARY = MAX ^ READ_PRIMARY;
var READ_NON_PRIMARY_AND_PUSHED = MAX ^ (READ_PRIMARY | READ_NEEDS_PUSH);
var READ_PUSHED = MAX ^ READ_NEEDS_PUSH;
var READ_PAUSED = MAX ^ READ_RESUMED;
var READ_NOT_QUEUED = MAX ^ (READ_QUEUED | READ_EMITTED_READABLE);
var READ_NOT_ENDING = MAX ^ READ_ENDING;
var READ_PIPE_NOT_DRAINED = MAX ^ READ_FLOWING;
var READ_NOT_NEXT_TICK = MAX ^ READ_NEXT_TICK;
var READ_NOT_UPDATING = MAX ^ READ_UPDATING;
var READ_NO_READ_AHEAD = MAX ^ READ_READ_AHEAD;
var READ_PAUSED_NO_READ_AHEAD = MAX ^ READ_RESUMED_READ_AHEAD;
var WRITE_ACTIVE = 1 << 18;
var WRITE_UPDATING = 2 << 18;
var WRITE_PRIMARY = 4 << 18;
var WRITE_QUEUED = 8 << 18;
var WRITE_UNDRAINED = 16 << 18;
var WRITE_DONE = 32 << 18;
var WRITE_EMIT_DRAIN = 64 << 18;
var WRITE_NEXT_TICK = 128 << 18;
var WRITE_WRITING = 256 << 18;
var WRITE_FINISHING = 512 << 18;
var WRITE_CORKED = 1024 << 18;
var WRITE_NOT_ACTIVE = MAX ^ (WRITE_ACTIVE | WRITE_WRITING);
var WRITE_NON_PRIMARY = MAX ^ WRITE_PRIMARY;
var WRITE_NOT_FINISHING = MAX ^ (WRITE_ACTIVE | WRITE_FINISHING);
var WRITE_DRAINED = MAX ^ WRITE_UNDRAINED;
var WRITE_NOT_QUEUED = MAX ^ WRITE_QUEUED;
var WRITE_NOT_NEXT_TICK = MAX ^ WRITE_NEXT_TICK;
var WRITE_NOT_UPDATING = MAX ^ WRITE_UPDATING;
var WRITE_NOT_CORKED = MAX ^ WRITE_CORKED;
var ACTIVE = READ_ACTIVE | WRITE_ACTIVE;
var NOT_ACTIVE = MAX ^ ACTIVE;
var DONE = READ_DONE | WRITE_DONE;
var DESTROY_STATUS = DESTROYING | DESTROYED | PREDESTROYING;
var OPEN_STATUS = DESTROY_STATUS | OPENING;
var AUTO_DESTROY = DESTROY_STATUS | DONE;
var NON_PRIMARY = WRITE_NON_PRIMARY & READ_NON_PRIMARY;
var ACTIVE_OR_TICKING = WRITE_NEXT_TICK | READ_NEXT_TICK;
var TICKING = ACTIVE_OR_TICKING & NOT_ACTIVE;
var IS_OPENING = OPEN_STATUS | TICKING;
var READ_PRIMARY_STATUS = OPEN_STATUS | READ_ENDING | READ_DONE;
var READ_STATUS = OPEN_STATUS | READ_DONE | READ_QUEUED;
var READ_ENDING_STATUS = OPEN_STATUS | READ_ENDING | READ_QUEUED;
var READ_READABLE_STATUS = OPEN_STATUS | READ_EMIT_READABLE | READ_QUEUED | READ_EMITTED_READABLE;
var SHOULD_NOT_READ = OPEN_STATUS | READ_ACTIVE | READ_ENDING | READ_DONE | READ_NEEDS_PUSH | READ_READ_AHEAD;
var READ_BACKPRESSURE_STATUS = DESTROY_STATUS | READ_ENDING | READ_DONE;
var READ_UPDATE_SYNC_STATUS = READ_UPDATING | OPEN_STATUS | READ_NEXT_TICK | READ_PRIMARY;
var READ_NEXT_TICK_OR_OPENING = READ_NEXT_TICK | OPENING;
var WRITE_PRIMARY_STATUS = OPEN_STATUS | WRITE_FINISHING | WRITE_DONE;
var WRITE_QUEUED_AND_UNDRAINED = WRITE_QUEUED | WRITE_UNDRAINED;
var WRITE_QUEUED_AND_ACTIVE = WRITE_QUEUED | WRITE_ACTIVE;
var WRITE_DRAIN_STATUS = WRITE_QUEUED | WRITE_UNDRAINED | OPEN_STATUS | WRITE_ACTIVE;
var WRITE_STATUS = OPEN_STATUS | WRITE_ACTIVE | WRITE_QUEUED | WRITE_CORKED;
var WRITE_PRIMARY_AND_ACTIVE = WRITE_PRIMARY | WRITE_ACTIVE;
var WRITE_ACTIVE_AND_WRITING = WRITE_ACTIVE | WRITE_WRITING;
var WRITE_FINISHING_STATUS = OPEN_STATUS | WRITE_FINISHING | WRITE_QUEUED_AND_ACTIVE | WRITE_DONE;
var WRITE_BACKPRESSURE_STATUS = WRITE_UNDRAINED | DESTROY_STATUS | WRITE_FINISHING | WRITE_DONE;
var WRITE_UPDATE_SYNC_STATUS = WRITE_UPDATING | OPEN_STATUS | WRITE_NEXT_TICK | WRITE_PRIMARY;
var WRITE_DROP_DATA = WRITE_FINISHING | WRITE_DONE | DESTROY_STATUS;
var asyncIterator = Symbol.asyncIterator || Symbol("asyncIterator");
var WritableState = class {
constructor(stream, { highWaterMark = 16384, map = null, mapWritable, byteLength, byteLengthWritable } = {}) {
this.stream = stream;
this.queue = new FIFO();
this.highWaterMark = highWaterMark;
this.buffered = 0;
this.error = null;
this.pipeline = null;
this.drains = null;
this.byteLength = byteLengthWritable || byteLength || defaultByteLength;
this.map = mapWritable || map;
this.afterWrite = afterWrite.bind(this);
this.afterUpdateNextTick = updateWriteNT.bind(this);
}
get ending() {
return (this.stream._duplexState & WRITE_FINISHING) !== 0;
}
get ended() {
return (this.stream._duplexState & WRITE_DONE) !== 0;
}
push(data) {
if ((this.stream._duplexState & WRITE_DROP_DATA) !== 0) return false;
if (this.map !== null) data = this.map(data);
this.buffered += this.byteLength(data);
this.queue.push(data);
if (this.buffered < this.highWaterMark) {
this.stream._duplexState |= WRITE_QUEUED;
return true;
}
this.stream._duplexState |= WRITE_QUEUED_AND_UNDRAINED;
return false;
}
shift() {
const data = this.queue.shift();
this.buffered -= this.byteLength(data);
if (this.buffered === 0) this.stream._duplexState &= WRITE_NOT_QUEUED;
return data;
}
end(data) {
if (typeof data === "function") this.stream.once("finish", data);
else if (data !== void 0 && data !== null) this.push(data);
this.stream._duplexState = (this.stream._duplexState | WRITE_FINISHING) & WRITE_NON_PRIMARY;
}
autoBatch(data, cb) {
const buffer = [];
const stream = this.stream;
buffer.push(data);
while ((stream._duplexState & WRITE_STATUS) === WRITE_QUEUED_AND_ACTIVE) {
buffer.push(stream._writableState.shift());
}
if ((stream._duplexState & OPEN_STATUS) !== 0) return cb(null);
stream._writev(buffer, cb);
}
update() {
const stream = this.stream;
stream._duplexState |= WRITE_UPDATING;
do {
while ((stream._duplexState & WRITE_STATUS) === WRITE_QUEUED) {
const data = this.shift();
stream._duplexState |= WRITE_ACTIVE_AND_WRITING;
stream._write(data, this.afterWrite);
}
if ((stream._duplexState & WRITE_PRIMARY_AND_ACTIVE) === 0) this.updateNonPrimary();
} while (this.continueUpdate() === true);
stream._duplexState &= WRITE_NOT_UPDATING;
}
updateNonPrimary() {
const stream = this.stream;
if ((stream._duplexState & WRITE_FINISHING_STATUS) === WRITE_FINISHING) {
stream._duplexState = stream._duplexState | WRITE_ACTIVE;
stream._final(afterFinal.bind(this));
return;
}
if ((stream._duplexState & DESTROY_STATUS) === DESTROYING) {
if ((stream._duplexState & ACTIVE_OR_TICKING) === 0) {
stream._duplexState |= ACTIVE;
stream._destroy(afterDestroy.bind(this));
}
return;
}
if ((stream._duplexState & IS_OPENING) === OPENING) {
stream._duplexState = (stream._duplexState | ACTIVE) & NOT_OPENING;
stream._open(afterOpen.bind(this));
}
}
continueUpdate() {
if ((this.stream._duplexState & WRITE_NEXT_TICK) === 0) return false;
this.stream._duplexState &= WRITE_NOT_NEXT_TICK;
return true;
}
updateCallback() {
if ((this.stream._duplexState & WRITE_UPDATE_SYNC_STATUS) === WRITE_PRIMARY) this.update();
else this.updateNextTick();
}
updateNextTick() {
if ((this.stream._duplexState & WRITE_NEXT_TICK) !== 0) return;
this.stream._duplexState |= WRITE_NEXT_TICK;
if ((this.stream._duplexState & WRITE_UPDATING) === 0) qmt(this.afterUpdateNextTick);
}
};
var ReadableState = class {
constructor(stream, { highWaterMark = 16384, map = null, mapReadable, byteLength, byteLengthReadable } = {}) {
this.stream = stream;
this.queue = new FIFO();
this.highWaterMark = highWaterMark === 0 ? 1 : highWaterMark;
this.buffered = 0;
this.readAhead = highWaterMark > 0;
this.error = null;
this.pipeline = null;
this.byteLength = byteLengthReadable || byteLength || defaultByteLength;
this.map = mapReadable || map;
this.pipeTo = null;
this.afterRead = afterRead.bind(this);
this.afterUpdateNextTick = updateReadNT.bind(this);
}
get ending() {
return (this.stream._duplexState & READ_ENDING) !== 0;
}
get ended() {
return (this.stream._duplexState & READ_DONE) !== 0;
}
pipe(pipeTo, cb) {
if (this.pipeTo !== null) throw new Error("Can only pipe to one destination");
if (typeof cb !== "function") cb = null;
this.stream._duplexState |= READ_PIPE_DRAINED;
this.pipeTo = pipeTo;
this.pipeline = new Pipeline(this.stream, pipeTo, cb);
if (cb) this.stream.on("error", noop);
if (isStreamx(pipeTo)) {
pipeTo._writableState.pipeline = this.pipeline;
if (cb) pipeTo.on("error", noop);
pipeTo.on("finish", this.pipeline.finished.bind(this.pipeline));
} else {
const onerror = this.pipeline.done.bind(this.pipeline, pipeTo);
const onclose = this.pipeline.done.bind(this.pipeline, pipeTo, null);
pipeTo.on("error", onerror);
pipeTo.on("close", onclose);
pipeTo.on("finish", this.pipeline.finished.bind(this.pipeline));
}
pipeTo.on("drain", afterDrain.bind(this));
this.stream.emit("piping", pipeTo);
pipeTo.emit("pipe", this.stream);
}
push(data) {
const stream = this.stream;
if (data === null) {
this.highWaterMark = 0;
stream._duplexState = (stream._duplexState | READ_ENDING) & READ_NON_PRIMARY_AND_PUSHED;
return false;
}
if (this.map !== null) {
data = this.map(data);
if (data === null) {
stream._duplexState &= READ_PUSHED;
return this.buffered < this.highWaterMark;
}
}
this.buffered += this.byteLength(data);
this.queue.push(data);
stream._duplexState = (stream._duplexState | READ_QUEUED) & READ_PUSHED;
return this.buffered < this.highWaterMark;
}
shift() {
const data = this.queue.shift();
this.buffered -= this.byteLength(data);
if (this.buffered === 0) this.stream._duplexState &= READ_NOT_QUEUED;
return data;
}
unshift(data) {
const pending = [this.map !== null ? this.map(data) : data];
while (this.buffered > 0) pending.push(this.shift());
for (let i = 0; i < pending.length - 1; i++) {
const data2 = pending[i];
this.buffered += this.byteLength(data2);
this.queue.push(data2);
}
this.push(pending[pending.length - 1]);
}
read() {
const stream = this.stream;
if ((stream._duplexState & READ_STATUS) === READ_QUEUED) {
const data = this.shift();
if (this.pipeTo !== null && this.pipeTo.write(data) === false)
stream._duplexState &= READ_PIPE_NOT_DRAINED;
if ((stream._duplexState & READ_EMIT_DATA) !== 0) stream.emit("data", data);
return data;
}
if (this.readAhead === false) {
stream._duplexState |= READ_READ_AHEAD;
this.updateNextTick();
}
return null;
}
drain() {
const stream = this.stream;
while ((stream._duplexState & READ_STATUS) === READ_QUEUED && (stream._duplexState & READ_FLOWING) !== 0) {
const data = this.shift();
if (this.pipeTo !== null && this.pipeTo.write(data) === false)
stream._duplexState &= READ_PIPE_NOT_DRAINED;
if ((stream._duplexState & READ_EMIT_DATA) !== 0) stream.emit("data", data);
}
}
update() {
const stream = this.stream;
stream._duplexState |= READ_UPDATING;
do {
this.drain();
while (this.buffered < this.highWaterMark && (stream._duplexState & SHOULD_NOT_READ) === READ_READ_AHEAD) {
stream._duplexState |= READ_ACTIVE_AND_NEEDS_PUSH;
stream._read(this.afterRead);
this.drain();
}
if ((stream._duplexState & READ_READABLE_STATUS) === READ_EMIT_READABLE_AND_QUEUED) {
stream._duplexState |= READ_EMITTED_READABLE;
stream.emit("readable");
}
if ((stream._duplexState & READ_PRIMARY_AND_ACTIVE) === 0) this.updateNonPrimary();
} while (this.continueUpdate() === true);
stream._duplexState &= READ_NOT_UPDATING;
}
updateNonPrimary() {
const stream = this.stream;
if ((stream._duplexState & READ_ENDING_STATUS) === READ_ENDING) {
stream._duplexState = (stream._duplexState | READ_DONE) & READ_NOT_ENDING;
stream.emit("end");
if ((stream._duplexState & AUTO_DESTROY) === DONE) stream._duplexState |= DESTROYING;
if (this.pipeTo !== null) this.pipeTo.end();
}
if ((stream._duplexState & DESTROY_STATUS) === DESTROYING) {
if ((stream._duplexState & ACTIVE_OR_TICKING) === 0) {
stream._duplexState |= ACTIVE;
stream._destroy(afterDestroy.bind(this));
}
return;
}
if ((stream._duplexState & IS_OPENING) === OPENING) {
stream._duplexState = (stream._duplexState | ACTIVE) & NOT_OPENING;
stream._open(afterOpen.bind(this));
}
}
continueUpdate() {
if ((this.stream._duplexState & READ_NEXT_TICK) === 0) return false;
this.stream._duplexState &= READ_NOT_NEXT_TICK;
return true;
}
updateCallback() {
if ((this.stream._duplexState & READ_UPDATE_SYNC_STATUS) === READ_PRIMARY) this.update();
else this.updateNextTick();
}
updateNextTickIfOpen() {
if ((this.stream._duplexState & READ_NEXT_TICK_OR_OPENING) !== 0) return;
this.stream._duplexState |= READ_NEXT_TICK;
if ((this.stream._duplexState & READ_UPDATING) === 0) qmt(this.afterUpdateNextTick);
}
updateNextTick() {
if ((this.stream._duplexState & READ_NEXT_TICK) !== 0) return;
this.stream._duplexState |= READ_NEXT_TICK;
if ((this.stream._duplexState & READ_UPDATING) === 0) qmt(this.afterUpdateNextTick);
}
};
var TransformState = class {
constructor(stream) {
this.data = null;
this.afterTransform = afterTransform.bind(stream);
this.afterFinal = null;
}
};
var Pipeline = class {
constructor(src, dst, cb) {
this.from = src;
this.to = dst;
this.afterPipe = cb;
this.error = null;
this.pipeToFinished = false;
}
finished() {
this.pipeToFinished = true;
}
done(stream, err) {
if (err) this.error = err;
if (stream === this.to) {
this.to = null;
if (this.from !== null) {
if ((this.from._duplexState & READ_DONE) === 0 || !this.pipeToFinished) {
this.from.destroy(this.error || new Error("Writable stream closed prematurely"));
}
return;
}
}
if (stream === this.from) {
this.from = null;
if (this.to !== null) {
if ((stream._duplexState & READ_DONE) === 0) {
this.to.destroy(this.error || new Error("Readable stream closed before ending"));
}
return;
}
}
if (this.afterPipe !== null) this.afterPipe(this.error);
this.to = this.from = this.afterPipe = null;
}
};
function afterDrain() {
this.stream._duplexState |= READ_PIPE_DRAINED;
this.updateCallback();
}
function afterFinal(err) {
const stream = this.stream;
if (err) stream.destroy(err);
if ((stream._duplexState & DESTROY_STATUS) === 0) {
stream._duplexState |= WRITE_DONE;
stream.emit("finish");
}
if ((stream._duplexState & AUTO_DESTROY) === DONE) {
stream._duplexState |= DESTROYING;
}
stream._duplexState &= WRITE_NOT_FINISHING;
if ((stream._duplexState & WRITE_UPDATING) === 0) this.update();
else this.updateNextTick();
}
function afterDestroy(err) {
const stream = this.stream;
if (!err && this.error !== STREAM_DESTROYED) err = this.error;
if (err) stream.emit("error", err);
stream._duplexState |= DESTROYED;
stream.emit("close");
const rs = stream._readableState;
const ws = stream._writableState;
if (rs !== null && rs.pipeline !== null) rs.pipeline.done(stream, err);
if (ws !== null) {
while (ws.drains !== null && ws.drains.length > 0) ws.drains.shift().resolve(false);
if (ws.pipeline !== null) ws.pipeline.done(stream, err);
}
}
function afterWrite(err) {
const stream = this.stream;
if (err) stream.destroy(err);
stream._duplexState &= WRITE_NOT_ACTIVE;
if (this.drains !== null) tickDrains(this.drains);
if ((stream._duplexState & WRITE_DRAIN_STATUS) === WRITE_UNDRAINED) {
stream._duplexState &= WRITE_DRAINED;
if ((stream._duplexState & WRITE_EMIT_DRAIN) === WRITE_EMIT_DRAIN) {
stream.emit("drain");
}
}
this.updateCallback();
}
function afterRead(err) {
if (err) this.stream.destroy(err);
this.stream._duplexState &= READ_NOT_ACTIVE;
if (this.readAhead === false && (this.stream._duplexState & READ_RESUMED) === 0)
this.stream._duplexState &= READ_NO_READ_AHEAD;
this.updateCallback();
}
function updateReadNT() {
if ((this.stream._duplexState & READ_UPDATING) === 0) {
this.stream._duplexState &= READ_NOT_NEXT_TICK;
this.update();
}
}
function updateWriteNT() {
if ((this.stream._duplexState & WRITE_UPDATING) === 0) {
this.stream._duplexState &= WRITE_NOT_NEXT_TICK;
this.update();
}
}
function tickDrains(drains) {
for (let i = 0; i < drains.length; i++) {
if (--drains[i].writes === 0) {
drains.shift().resolve(true);
i--;
}
}
}
function afterOpen(err) {
const stream = this.stream;
if (err) stream.destroy(err);
if ((stream._duplexState & DESTROYING) === 0) {
if ((stream._duplexState & READ_PRIMARY_STATUS) === 0) stream._duplexState |= READ_PRIMARY;
if ((stream._duplexState & WRITE_PRIMARY_STATUS) === 0) stream._duplexState |= WRITE_PRIMARY;
stream.emit("open");
}
stream._duplexState &= NOT_ACTIVE;
if (stream._writableState !== null) {
stream._writableState.updateCallback();
}
if (stream._readableState !== null) {
stream._readableState.updateCallback();
}
}
function afterTransform(err, data) {
if (data !== void 0 && data !== null) this.push(data);
this._writableState.afterWrite(err);
}
function newListener(name) {
if (this._readableState !== null) {
if (name === "data") {
this._duplexState |= READ_EMIT_DATA | READ_RESUMED_READ_AHEAD;
this._readableState.updateNextTick();
}
if (name === "readable") {
this._duplexState |= READ_EMIT_READABLE;
this._readableState.updateNextTick();
}
}
if (this._writableState !== null) {
if (name === "drain") {
this._duplexState |= WRITE_EMIT_DRAIN;
this._writableState.updateNextTick();
}
}
}
var Stream = class extends EventEmitter {
constructor(opts) {
super();
this._duplexState = 0;
this._readableState = null;
this._writableState = null;
if (opts) {
if (opts.open) this._open = opts.open;
if (opts.destroy) this._destroy = opts.destroy;
if (opts.predestroy) this._predestroy = opts.predestroy;
if (opts.signal) {
opts.signal.addEventListener("abort", abort.bind(this));
}
}
this.on("newListener", newListener);
}
_open(cb) {
cb(null);
}
_destroy(cb) {
cb(null);
}
_predestroy() {
}
get readable() {
return this._readableState !== null ? true : void 0;
}
get writable() {
return this._writableState !== null ? true : void 0;
}
get destroyed() {
return (this._duplexState & DESTROYED) !== 0;
}
get destroying() {
return (this._duplexState & DESTROY_STATUS) !== 0;
}
destroy(err) {
if ((this._duplexState & DESTROY_STATUS) === 0) {
if (!err) err = STREAM_DESTROYED;
this._duplexState = (this._duplexState | DESTROYING) & NON_PRIMARY;
if (this._readableState !== null) {
this._readableState.highWaterMark = 0;
this._readableState.error = err;
}
if (this._writableState !== null) {
this._writableState.highWaterMark = 0;
this._writableState.error = err;
}
this._duplexState |= PREDESTROYING;
this._predestroy();
this._duplexState &= NOT_PREDESTROYING;
if (this._readableState !== null) this._readableState.updateNextTick();
if (this._writableState !== null) this._writableState.updateNextTick();
}
}
};
var Readable = class _Readable extends Stream {
constructor(opts) {
super(opts);
this._duplexState |= OPENING | WRITE_DONE | READ_READ_AHEAD;
this._readableState = new ReadableState(this, opts);
if (opts) {
if (this._readableState.readAhead === false) this._duplexState &= READ_NO_READ_AHEAD;
if (opts.read) this._read = opts.read;
if (opts.eagerOpen) this._readableState.updateNextTick();
if (opts.encoding) this.setEncoding(opts.encoding);
}
}
setEncoding(encoding) {
const dec = new TextDecoder2(encoding);
const map = this._readableState.map || echo;
this._readableState.map = mapOrSkip;
return this;
function mapOrSkip(data) {
const next = dec.push(data);
return next === "" && (data.byteLength !== 0 || dec.remaining > 0) ? null : map(next);
}
}
_read(cb) {
cb(null);
}
pipe(dest, cb) {
this._readableState.updateNextTick();
this._readableState.pipe(dest, cb);
return dest;
}
read() {
this._readableState.updateNextTick();
return this._readableState.read();
}
push(data) {
this._readableState.updateNextTickIfOpen();
return this._readableState.push(data);
}
unshift(data) {
this._readableState.updateNextTickIfOpen();
return this._readableState.unshift(data);
}
resume() {
this._duplexState |= READ_RESUMED_READ_AHEAD;
this._readableState.updateNextTick();
return this;
}
pause() {
this._duplexState &= this._readableState.readAhead === false ? READ_PAUSED_NO_READ_AHEAD : READ_PAUSED;
return this;
}
static _fromAsyncIterator(ite, opts) {
let destroy;
const rs = new _Readable({
...opts,
read(cb) {
ite.next().then(push).then(cb.bind(null, null)).catch(cb);
},
predestroy() {
destroy = ite.return();
},
destroy(cb) {
if (!destroy) return cb(null);
destroy.then(cb.bind(null, null)).catch(cb);
}
});
return rs;
function push(data) {
if (data.done) rs.push(null);
else rs.push(data.value);
}
}
static from(data, opts) {
if (isReadStreamx(data)) return data;
if (data[asyncIterator]) return this._fromAsyncIterator(data[asyncIterator](), opts);
if (!Array.isArray(data)) data = data === void 0 ? [] : [data];
let i = 0;
return new _Readable({
...opts,
read(cb) {
this.push(i === data.length ? null : data[i++]);
cb(null);
}
});
}
static isBackpressured(rs) {
return (rs._duplexState & READ_BACKPRESSURE_STATUS) !== 0 || rs._readableState.buffered >= rs._readableState.highWaterMark;
}
static isPaused(rs) {
return (rs._duplexState & READ_RESUMED) === 0;
}
[asyncIterator]() {
const stream = this;
let error = null;
let promiseResolve = null;
let promiseReject = null;
this.on("error", (err) => {
error = err;
});
this.on("readable", onreadable);
this.on("close", onclose);
return {
[asyncIterator]() {
return this;
},
next() {
return new Promise(function(resolve, reject) {
promiseResolve = resolve;
promiseReject = reject;
const data = stream.read();
if (data !== null) ondata(data);
else if ((stream._duplexState & DESTROYED) !== 0) ondata(null);
});
},
return() {
return destroy(null);
},
throw(err) {
return destroy(err);
}
};
function onreadable() {
if (promiseResolve !== null) ondata(stream.read());
}
function onclose() {
if (promiseResolve !== null) ondata(null);
}
function ondata(data) {
if (promiseReject === null) return;
if (error) promiseReject(error);
else if (data === null && (stream._duplexState & READ_DONE) === 0)
promiseReject(STREAM_DESTROYED);
else promiseResolve({ value: data, done: data === null });
promiseReject = promiseResolve = null;
}
function destroy(err) {
stream.destroy(err);
return new Promise((resolve, reject) => {
if (stream._duplexState & DESTROYED) return resolve({ value: void 0, done: true });
stream.once("close", function() {
if (err) reject(err);
else resolve({ value: void 0, done: true });
});
});
}
}
};
var Writable = class extends Stream {
constructor(opts) {
super(opts);
this._duplexState |= OPENING | READ_DONE;
this._writableState = new WritableState(this, opts);
if (opts) {
if (opts.writev) this._writev = opts.writev;
if (opts.write) this._write = opts.write;
if (opts.final) this._final = opts.final;
if (opts.eagerOpen) this._writableState.updateNextTick();
}
}
cork() {
this._duplexState |= WRITE_CORKED;
}
uncork() {
this._duplexState &= WRITE_NOT_CORKED;
this._writableState.updateNextTick();
}
_writev(batch, cb) {
cb(null);
}
_write(data, cb) {
this._writableState.autoBatch(data, cb);
}
_final(cb) {
cb(null);
}
static isBackpressured(ws) {
return (ws._duplexState & WRITE_BACKPRESSURE_STATUS) !== 0;
}
static drained(ws) {
if (ws.destroyed) return Promise.resolve(false);
const state = ws._writableState;
const pending = isWritev(ws) ? Math.min(1, state.queue.length) : state.queue.length;
const writes = pending + (ws._duplexState & WRITE_WRITING ? 1 : 0);
if (writes === 0) return Promise.resolve(true);
if (state.drains === null) state.drains = [];
return new Promise((resolve) => {
state.drains.push({ writes, resolve });
});
}
write(data) {
this._writableState.updateNextTick();
return this._writableState.push(data);
}
end(data) {
this._writableState.updateNextTick();
this._writableState.end(data);
return this;
}
};
var Duplex = class extends Readable {
// and Writable
constructor(opts) {
super(opts);
this._duplexState = OPENING | this._duplexState & READ_READ_AHEAD;
this._writableState = new WritableState(this, opts);
if (opts) {
if (opts.writev) this._writev = opts.writev;
if (opts.write) this._write = opts.write;
if (opts.final) this._final = opts.final;
}
}
cork() {
this._duplexState |= WRITE_CORKED;
}
uncork() {
this._duplexState &= WRITE_NOT_CORKED;
this._writableState.updateNextTick();
}
_writev(batch, cb) {
cb(null);
}
_write(data, cb) {
this._writableState.autoBatch(data, cb);
}
_final(cb) {
cb(null);
}
write(data) {
this._writableState.updateNextTick();
return this._writableState.push(data);
}
end(data) {
this._writableState.updateNextTick();
this._writableState.end(data);
return this;
}
};
var Transform = class extends Duplex {
constructor(opts) {
super(opts);
this._transformState = new TransformState(this);
if (opts) {
if (opts.transform) this._transform = opts.transform;
if (opts.flush) this._flush = opts.flush;
}
}
_write(data, cb) {
if (this._readableState.buffered >= this._readableState.highWaterMark) {
this._transformState.data = data;
} else {
this._transform(data, this._transformState.afterTransform);
}
}
_read(cb) {
if (this._transformState.data !== null) {
const data = this._transformState.data;
this._transformState.data = null;
cb(null);
this._transform(data, this._transformState.afterTransform);
} else {
cb(null);
}
}
destroy(err) {
super.destroy(err);
if (this._transformState.data !== null) {
this._transformState.data = null;
this._transformState.afterTransform();
}
}
_transform(data, cb) {
cb(null, data);
}
_flush(cb) {
cb(null);
}
_final(cb) {
this._transformState.afterFinal = cb;
this._flush(transformAfterFlush.bind(this));
}
};
var PassThrough = class extends Transform {
};
function transformAfterFlush(err, data) {
const cb = this._transformState.afterFinal;
if (err) return cb(err);
if (data !== null && data !== void 0) this.push(data);
this.push(null);
cb(null);
}
function pipelinePromise(...streams) {
return new Promise((resolve, reject) => {
return pipeline(...streams, (err) => {
if (err) return reject(err);
resolve();
});
});
}
function pipeline(stream, ...streams) {
const all = Array.isArray(stream) ? [...stream, ...streams] : [stream, ...streams];
const done = all.length && typeof all[all.length - 1] === "function" ? all.pop() : null;
if (all.length < 2) throw new Error("Pipeline requires at least 2 streams");
let src = all[0];
let dest = null;
let error = null;
for (let i = 1; i < all.length; i++) {
dest = all[i];
if (isStreamx(src)) {
src.pipe(dest, onerror);
} else {
errorHandle(src, true, i > 1, onerror);
src.pipe(dest);
}
src = dest;
}
if (done) {
let fin = false;
const autoDestroy = isStreamx(dest) || !!(dest._writableState && dest._writableState.autoDestroy);
dest.on("error", (err) => {
if (error === null) error = err;
});
dest.on("finish", () => {
fin = true;
if (!autoDestroy) done(error);
});
if (autoDestroy) {
dest.on("close", () => done(error || (fin ? null : PREMATURE_CLOSE)));
}
}
return dest;
function errorHandle(s, rd, wr, onerror2) {
s.on("error", onerror2);
s.on("close", onclose);
function onclose() {
if (rd && s._readableState && !s._readableState.ended) return onerror2(PREMATURE_CLOSE);
if (wr && s._writableState && !s._writableState.ended) return onerror2(PREMATURE_CLOSE);
}
}
function onerror(err) {
if (!err || error) return;
error = err;
for (const s of all) {
s.destroy(err);
}
}
}
function echo(s) {
return s;
}
function isStream(stream) {
return !!stream._readableState || !!stream._writableState;
}
function isStreamx(stream) {
return typeof stream._duplexState === "number" && isStream(stream);
}
function isEnding(stream) {
return !!stream._readableState && stream._readableState.ending;
}
function isEnded(stream) {
return !!stream._readableState && stream._readableState.ended;
}
function isFinishing(stream) {
return !!stream._writableState && stream._writableState.ending;
}
function isFinished(stream) {
return !!stream._writableState && stream._writableState.ended;
}
function getStreamError(stream, opts = {}) {
const err = stream._readableState && stream._readableState.error || stream._writableState && stream._writableState.error;
return !opts.all && err === STREAM_DESTROYED ? null : err;
}
function isReadStreamx(stream) {
return isStreamx(stream) && stream.readable;
}
function isDisturbed(stream) {
return (stream._duplexState & OPENING) !== OPENING || (stream._duplexState & DESTROYING) === DESTROYING || (stream._duplexState & ACTIVE_OR_TICKING) !== 0;
}
function isTypedArray(data) {
return typeof data === "object" && data !== null && typeof data.byteLength === "number";
}
function defaultByteLength(data) {
return isTypedArray(data) ? data.byteLength : 1024;
}
function noop() {
}
function abort() {
this.destroy(new Error("Stream aborted."));
}
function isWritev(s) {
return s._writev !== Writable.prototype._writev && s._writev !== Duplex.prototype._writev;
}
module.exports = {
pipeline,
pipelinePromise,
isStream,
isStreamx,
isEnding,
isEnded,
isFinishing,
isFinished,
isDisturbed,
getStreamError,
Stream,
Writable,
Readable,
Duplex,
Transform,
// Export PassThrough for compatibility with Node.js core's stream module
PassThrough
};
}
});
// ../../node_modules/teex/index.js
var require_teex = __commonJS({
"../../node_modules/teex/index.js"(exports, module) {
var { Readable } = require_streamx();
module.exports = function(s, forks = 2) {
const streams = new Array(forks);
const status = new Array(forks).fill(true);
let ended = false;
for (let i = 0; i < forks; i++) {
streams[i] = new Readable({
read(cb) {
const check = !status[i];
status[i] = true;
if (check && allReadable()) s.resume();
cb(null);
}
});
}
s.on("end", function() {
ended = true;
for (const stream of streams) stream.push(null);
});
s.on("error", function(err) {
for (const stream of streams) stream.destroy(err);
});
s.on("close", function() {
if (ended) return;
for (const stream of streams) stream.destroy();
});
s.on("data", function(data) {
let needsPause = false;
for (let i = 0; i < streams.length; i++) {
if (!(status[i] = streams[i].push(data))) {
needsPause = true;
}
}
if (needsPause) s.pause();
});
return streams;
function allReadable() {
for (let j = 0; j < status.length; j++) {
if (!status[j]) return false;
}
return true;
}
};
}
});
// ../../node_modules/bare-stream/web.js
var require_web = __commonJS({
"../../node_modules/bare-stream/web.js"(exports) {
var { Readable, Writable, Transform, getStreamError, isStreamx, isDisturbed } = require_streamx();
var tee = require_teex();
var readableKind = Symbol.for("bare.stream.readable.kind");
var writableKind = Symbol.for("bare.stream.writable.kind");
var transformKind = Symbol.for("bare.stream.transform.kind");
exports.ReadableStreamDefaultReader = class ReadableStreamDefaultReader {
constructor(stream) {
this._stream = stream;
this._stream._stream.once("close", onclose).once("error", onerror);
const closed = Promise.withResolvers();
closed.promise.catch(noop);
this._closed = closed;
function onclose() {
closed.resolve();
}
function onerror(err) {
closed.reject(err);
}
}
get closed() {
return this._closed.promise;
}
read() {
const stream = this._stream._stream;
return new Promise((resolve, reject) => {
const err = getStreamError(stream);
if (err) return reject(err);
if (stream.destroyed) {
return resolve({ value: void 0, done: true });
}
const value2 = stream.read();
if (value2 !== null) {
return resolve({ value: value2, done: false });
}
stream.once("readable", onreadable).once("close", onclose).once("error", onerror);
function onreadable() {
const value3 = stream.read();
ondone(null, value3 === null ? { value: void 0, done: true } : { value: value3, done: false });
}
function onclose() {
ondone(null, { value: void 0, done: true });
}
function onerror(err2) {
ondone(err2, null);
}
function ondone(err2, value3) {
stream.off("readable", onreadable).off("close", onclose).off("error", onerror);
if (err2) reject(err2);
else resolve(value3);
}
});
}
releaseLock() {
this._closed.reject(new TypeError("Reader was released"));
this._stream._releaseLock();
this._stream = null;
}
cancel(reason = new TypeError("Stream was cancelled")) {
const stream = this._stream._stream;
if (stream.destroyed) return Promise.resolve();
return new Promise(
(resolve) => stream.once("close", resolve).once("error", noop).destroy(reason)
);
}
};
exports.ReadableStreamDefaultController = class ReadableStreamDefaultController {
constructor(stream) {
this._stream = stream;
}
get desiredSize() {
const stream = this._stream._stream;
return stream._readableState.highWaterMark - stream._readableState.buffered;
}
enqueue(data) {
this._stream._stream.push(data);
}
close() {
this._stream._stream.push(null);
}
error(err) {
this._stream._stream.destroy(err);
}
};
var ReadableStream = class _ReadableStream {
static get [readableKind]() {
return 0;
}
static from(iterable) {
return new _ReadableStream(Readable.from(iterable));
}
constructor(underlyingSource = {}, queuingStrategy) {
if (isStreamx(underlyingSource)) {
this._stream = underlyingSource;
} else {
if (queuingStrategy === void 0) {
queuingStrategy = new exports.CountQueuingStrategy();
}
const { start, pull, cancel } = underlyingSource;
const { highWaterMark = 1, size = defaultSize } = queuingStrategy;
this._stream = new Readable({ highWaterMark, byteLength: size });
const controller = new exports.ReadableStreamDefaultController(this);
if (start) {
this._stream._open = this._open.bind(this, start.call(this, controller));
}
if (pull) {
this._stream._read = this._read.bind(this, pull.bind(this, controller));
}
if (cancel) {
this._stream.once("error", cancel);
}
}
this._reader = null;
}
get [readableKind]() {
return _ReadableStream[readableKind];
}
get locked() {
return this._reader !== null;
}
getReader() {
if (this.locked) throw new TypeError("Stream is locked");
this._reader = new exports.ReadableStreamDefaultReader(this);
return this._reader;
}
cancel(reason = new TypeError("Stream was cancelled")) {
const stream = this._stream;
if (stream.destroyed) return Promise.resolve();
if (this.locked) return Promise.reject(new TypeError("Stream is locked"));
return new Promise(
(resolve) => stream.once("close", resolve).once("error", noop).destroy(reason)
);
}
tee() {
const [a, b] = tee(this._stream);
return [new _ReadableStream(a), new _ReadableStream(b)];
}
pipeTo(destination) {
return new Promise(
(resolve, reject) => this._stream.pipe(destination._stream, (err) => {
err ? reject(err) : resolve();
})
);
}
[Symbol.asyncIterator]() {
return this._stream[Symbol.asyncIterator]();
}
_releaseLock() {
this._reader = null;
}
async _open(starting, cb) {
let err = null;
try {
await starting;
} catch (e) {
err = e;
}
cb(err);
}
async _read(pull, cb) {
let err = null;
try {
await pull();
} catch (e) {
err = e;
}
cb(err);
}
};
function defaultSize() {
return 1;
}
exports.ReadableStream = ReadableStream;
exports.CountQueuingStrategy = class CountQueuingStrategy {
constructor(opts = {}) {
const { highWaterMark = 1 } = opts;
this.highWaterMark = highWaterMark;
}
size(chunk) {
return 1;
}
};
exports.ByteLengthQueuingStrategy = class ByteLengthQueuingStrategy {
constructor(opts = {}) {
const { highWaterMark = 16384 } = opts;
this.highWaterMark = highWaterMark;
}
size(chunk) {
return chunk.byteLength;
}
};
exports.isReadableStream = function isReadableStream(value2) {
if (value2 instanceof ReadableStream) return true;
return typeof value2 === "object" && value2 !== null && value2[readableKind] === ReadableStream[readableKind];
};
exports.isReadableStreamErrored = function isReadableStreamErrored(stream) {
return getStreamError(stream._stream) !== null;
};
exports.isReadableStreamDisturbed = function isReadableStreamDisturbed(stream) {
return isDisturbed(stream._stream);
};
exports.WritableStreamDefaultWriter = class WritableStreamDefaultWriter {
constructor(stream) {
this._stream = stream;
this._stream._stream.once("close", onclose).once("error", onerror);
const closed = Promise.withResolvers();
closed.promise.catch(noop);
this._closed = closed;
function onclose() {
closed.resolve();
}
function onerror(err) {
closed.reject(err);
}
}
get desiredSize() {
const stream = this._stream._stream;
return stream._writableState.highWaterMark - stream._writableState.buffered;
}
get closed() {
return this._closed.promise;
}
get ready() {
const stream = this._stream._stream;
if (getStreamError(stream)) return Promise.reject();
return Writable.drained(stream).then();
}
async write(chunk) {
const stream = this._stream._stream;
let err = getStreamError(stream);
if (err) return Promise.reject(err);
stream.write(chunk);
await Writable.drained(stream);
err = getStreamError(stream);
if (err) return Promise.reject(err);
}
releaseLock() {
this._closed.reject(new TypeError("Writer was released"));
this._stream._releaseLock();
this._stream = null;
}
close() {
const stream = this._stream._stream;
if (stream.destroyed) return Promise.resolve();
return new Promise((resolve) => stream.once("close", resolve).end());
}
abort(reason = new TypeError("Stream was aborted")) {
const stream = this._stream._stream;
if (stream.destroyed) return Promise.resolve();
return new Promise((resolve) => stream.once("close", resolve).destroy(reason));
}
};
exports.WritableStreamDefaultController = class WritableStreamDefaultController {
constructor(stream) {
this._stream = stream;
}
error(err) {
this._stream._stream.destroy(err);
}
};
var WritableStream = class _WritableStream {
static get [writableKind]() {
return 0;
}
constructor(underlyingSink = {}, queuingStrategy = {}) {
if (isStreamx(underlyingSink)) {
this._stream = underlyingSink;
} else {
if (queuingStrategy === void 0) {
queuingStrategy = new exports.CountQueuingStrategy();
}
const { start, write, close, abort } = underlyingSink;
const { highWaterMark = 1, size = defaultSize } = queuingStrategy;
this._stream = new Writable({ highWaterMark, byteLength: size });
this._controller = new exports.WritableStreamDefaultController(this);
if (start) {
this._stream._open = this._open.bind(this, start.call(this, this._controller));
}
if (write) {
this._stream._write = this._write.bind(this, write);
}
if (close) {
this._stream._destroy = this._destroy.bind(this, close.call(this));
}
if (abort) {
this._stream.once("error", abort);
}
}
this._writer = null;
}
get [writableKind]() {
return _WritableStream[writableKind];
}
get locked() {
return this._writer !== null;
}
getWriter() {
if (this.locked) throw new TypeError("Stream is locked");
this._writer = new exports.WritableStreamDefaultWriter(this);
return this._writer;
}
abort(reason = new TypeError("Stream was aborted")) {
if (this._stream.destroyed) return Promise.resolve();
if (this.locked) return Promise.reject(new TypeError("Stream is locked"));
return new Promise((resolve) => this._stream.once("close", resolve).destroy(reason));
}
close() {
if (this._stream.destroyed) return Promise.resolve();
if (this.locked) return Promise.reject(new TypeError("Stream is locked"));
return new Promise((resolve) => this._stream.once("close", resolve).end());
}
_releaseLock() {
this._writer = null;
}
async _open(starting, cb) {
let err = null;
try {
await starting;
} catch (e) {
err = e;
}
cb(err);
}
async _write(write, data, cb) {
let err = null;
try {
await write(data, this._controller);
} catch (e) {
err = e;
}
cb(err);
}
async _destroy(closing, cb) {
let err = null;
try {
await closing;
} catch (e) {
err = e;
}
cb(err);
}
};
exports.WritableStream = WritableStream;
exports.isWritableStream = function isWritableStream(value2) {
if (value2 instanceof WritableStream) return true;
return typeof value2 === "object" && value2 !== null && value2[writableKind] === WritableStream[writableKind];
};
exports.TransformStreamDefaultController = class TransformStreamDefaultController {
constructor(stream) {
this._stream = stream;
}
get desiredSize() {
const stream = this._stream._stream;
return stream._readableState.highWaterMark - stream._readableState.buffered;
}
enqueue(data) {
this._stream._stream.push(data);
}
error(err) {
this._stream._stream.destroy(err);
}
terminate() {
const stream = this._stream._stream;
stream.push(null);
stream.destroy(new TypeError("Stream has been terminated"));
}
};
var TransformStream = class _TransformStream {
static get [transformKind]() {
return 0;
}
constructor(transformer = {}, writableStrategy = {}, readableStrategy = {}) {
const { start, transform, flush } = transformer;
this._stream = new Transform({ ...writableStrategy, ...readableStrategy });
this._writable = new WritableStream(this._stream);
this._readable = new ReadableStream(this._stream);
this._controller = new exports.TransformStreamDefaultController(this);
if (start) {
this._stream._open = this._open.bind(this, start.call(this, this._controller));
}
if (transform) {
this._stream._write = this._transform.bind(this, transform);
}
if (flush) {
this._stream._flush = this._flush.bind(this, flush.call(this, this._controller));
}
}
get [transformKind]() {
return _TransformStream[transformKind];
}
get writable() {
return this._writable;
}
get readable() {
return this._readable;
}
async _open(starting, cb) {
let err = null;
try {
await starting;
} catch (e) {
err = e;
}
cb(err);
}
async _transform(transform, data, cb) {
let err = null;
try {
await transform(data, this._controller);
} catch (e) {
err = e;
}
cb(err);
}
async _flush(flush, cb) {
let err = null;
try {
await flush;
} catch (e) {
err = e;
}
cb(err);
}
};
exports.TransformStream = TransformStream;
exports.isTransformStream = function isTransformStream(value2) {
if (value2 instanceof TransformStream) return true;
return typeof value2 === "object" && value2 !== null && value2[transformKind] === TransformStream[transformKind];
};
function noop() {
}
}
});
// ../../node_modules/bare-stream/index.js
var require_bare_stream = __commonJS({
"../../node_modules/bare-stream/index.js"(exports, module) {
var stream = require_streamx();
var { ReadableStream, WritableStream } = require_web();
var defaultEncoding = "utf8";
module.exports = exports = stream.Stream;
exports.pipeline = stream.pipeline;
exports.isStream = stream.isStream;
exports.isEnding = stream.isEnding;
exports.isEnded = stream.isEnded;
exports.isFinishing = stream.isFinishing;
exports.isFinished = stream.isFinished;
exports.isDisturbed = stream.isDisturbed;
exports.isErrored = function isErrored(stream2) {
return exports.getStreamError(stream2) !== null;
};
exports.isReadable = function isReadable(stream2) {
return stream2.readable && !stream2.destroying && !exports.isEnded(stream2);
};
exports.isWritable = function isWritable(stream2) {
return stream2.writable && !stream2.destroying && !exports.isFinishing(stream2);
};
exports.getStreamError = stream.getStreamError;
exports.addAbortSignal = function addAbortSignal(signal, stream2) {
function onAbort() {
stream2.destroy(signal.reason);
}
if (signal.aborted) onAbort();
else signal.addEventListener("abort", onAbort);
return stream2;
};
exports.Stream = exports;
exports.Readable = class Readable extends stream.Readable {
constructor(opts = {}) {
super({
...opts,
byteLength: null,
byteLengthReadable: null,
map: null,
mapReadable: null
});
if (this._construct) this._open = this._construct;
if (this._read !== stream.Readable.prototype._read) {
this._read = read.bind(this, this._read);
}
if (this._destroy !== stream.Stream.prototype._destroy) {
this._destroy = destroy.bind(this, this._destroy);
}
}
get closed() {
return !exports.isReadable(this);
}
get errored() {
return stream.getStreamError(this);
}
push(chunk, encoding) {
if (typeof chunk === "string") {
chunk = Buffer.from(chunk, encoding || defaultEncoding);
}
return super.push(chunk);
}
unshift(chunk, encoding) {
if (typeof chunk === "string") {
chunk = Buffer.from(chunk, encoding || defaultEncoding);
}
super.unshift(chunk);
}
static fromWeb(readableStream, opts = {}) {
const stream2 = readableStream._stream;
if (opts.encoding) stream2.setEncoding(opts.encoding);
if (opts.signal) exports.addAbortSignal(opts.signal, stream2);
return stream2;
}
static toWeb(readable, opts = {}) {
return new ReadableStream(readable, opts.strategy);
}
async [Symbol.asyncDispose]() {
if (!this.destroyed) this.destroy();
await new Promise((resolve) => exports.finished(this, resolve));
}
};
exports.Writable = class Writable extends stream.Writable {
constructor(opts = {}) {
super({
...opts,
byteLength: null,
byteLengthWritable,
map: null,
mapWritable: null
});
if (this._construct) this._open = this._construct;
if (this._write !== stream.Writable.prototype._write) {
this._write = write.bind(this, this._write);
}
if (this._destroy !== stream.Stream.prototype._destroy) {
this._destroy = destroy.bind(this, this._destroy);
}
}
get closed() {
return !exports.isWritable(this);
}
get errored() {
return stream.getStreamError(this);
}
write(chunk, encoding, cb) {
if (typeof encoding === "function") {
cb = encoding;
encoding = null;
}
if (typeof chunk === "string") {
encoding = encoding || defaultEncoding;
chunk = Buffer.from(chunk, encoding);
} else {
encoding = "buffer";
}
const result = super.write({ chunk, encoding });
if (cb) stream.Writable.drained(this).then(() => cb(null), cb);
return result;
}
end(chunk, encoding, cb) {
if (typeof chunk === "function") {
cb = chunk;
chunk = null;
} else if (typeof encoding === "function") {
cb = encoding;
encoding = null;
}
if (typeof chunk === "string") {
encoding = encoding || defaultEncoding;
chunk = Buffer.from(chunk, encoding || defaultEncoding);
} else {
encoding = "buffer";
}
const result = chunk !== void 0 && chunk !== null ? super.end({ chunk, encoding }) : super.end();
if (cb) this.once("finish", () => cb(null));
return result;
}
static fromWeb(writableStream, opts = {}) {
const stream2 = writableStream._stream;
if (opts.signal) exports.addAbortSignal(opts.signal, stream2);
return stream2;
}
static toWeb(writable) {
return new WritableStream(writable);
}
async [Symbol.asyncDispose]() {
if (!this.destroyed) this.destroy();
await new Promise((resolve) => exports.finished(this, resolve));
}
};
exports.Duplex = class Duplex extends stream.Duplex {
constructor(opts = {}) {
super({
...opts,
byteLength: null,
byteLengthReadable: null,
byteLengthWritable,
map: null,
mapReadable: null,
mapWritable: null
});
if (this._construct) this._open = this._construct;
if (this._read !== stream.Readable.prototype._read) {
this._read = read.bind(this, this._read);
}
if (this._write !== stream.Duplex.prototype._write) {
this._write = write.bind(this, this._write);
}
if (this._destroy !== stream.Stream.prototype._destroy) {
this._destroy = destroy.bind(this, this._destroy);
}
}
push(chunk, encoding) {
if (typeof chunk === "string") {
chunk = Buffer.from(chunk, encoding || defaultEncoding);
}
return super.push(chunk);
}
unshift(chunk, encoding) {
if (typeof chunk === "string") {
chunk = Buffer.from(chunk, encoding || defaultEncoding);
}
super.unshift(chunk);
}
write(chunk, encoding, cb) {
if (typeof encoding === "function") {
cb = encoding;
encoding = null;
}
if (typeof chunk === "string") {
encoding = encoding || defaultEncoding;
chunk = Buffer.from(chunk, encoding);
} else {
encoding = "buffer";
}
const result = super.write({ chunk, encoding });
if (cb) stream.Writable.drained(this).then(() => cb(null), cb);
return result;
}
end(chunk, encoding, cb) {
if (typeof chunk === "function") {
cb = chunk;
chunk = null;
} else if (typeof encoding === "function") {
cb = encoding;
encoding = null;
}
if (typeof chunk === "string") {
encoding = encoding || defaultEncoding;
chunk = Buffer.from(chunk, encoding);
} else {
encoding = "buffer";
}
const result = chunk !== void 0 && chunk !== null ? super.end({ chunk, encoding }) : super.end();
if (cb) this.once("finish", () => cb(null));
return result;
}
static fromWeb({ readable: readableStream, writable: writableStream }, opts) {
const readable = exports.Readable.fromWeb(readableStream, opts);
const writable = exports.Readable.fromWeb(writableStream, opts);
const duplex = new exports.Duplex({
write(data, encoding, cb) {
writable.write(data, encoding, cb);
}
});
readable.on("data", (data) => duplex.push(data)).on("end", () => duplex.push(null)).on("error", (err) => duplex.destroy(err));
writable.on("finish", () => duplex.end()).on("error", (err) => duplex.destroy(err));
return duplex;
}
static toWeb(duplex) {
const readableStream = exports.Readable.toWeb(duplex);
const writableStream = exports.Writable.toWeb(duplex);
return { readable: readableStream, writable: writableStream };
}
};
var DuplexSide = class extends exports.Duplex {
constructor(opts) {
super(opts);
this._otherSide = null;
this._cb = null;
}
_read() {
const cb = this._cb;
if (!cb) return;
this._cb = null;
cb();
}
_write(chunk, encoding, cb) {
this._otherSide.push(chunk, encoding);
this._otherSide._cb = cb;
}
_final(cb) {
this._otherSide.on("end", cb);
this._otherSide.push(null);
}
};
exports.duplexPair = function duplexPair(opts) {
const sideA = new DuplexSide(opts);
const sideB = new DuplexSide(opts);
sideA._otherSide = sideB;
sideB._otherSide = sideA;
return [sideA, sideB];
};
exports.Transform = class Transform extends stream.Transform {
constructor(opts = {}) {
super({
...opts,
byteLength: null,
byteLengthReadable: null,
byteLengthWritable,
map: null,
mapReadable: null,
mapWritable: null
});
if (this._transform !== stream.Transform.prototype._transform) {
this._transform = transform.bind(this, this._transform);
} else {
this._transform = passthrough;
}
}
push(chunk, encoding) {
if (typeof chunk === "string") {
chunk = Buffer.from(chunk, encoding || defaultEncoding);
}
return super.push(chunk);
}
unshift(chunk, encoding) {
if (typeof chunk === "string") {
chunk = Buffer.from(chunk, encoding || defaultEncoding);
}
super.unshift(chunk);
}
write(chunk, encoding, cb) {
if (typeof encoding === "function") {
cb = encoding;
encoding = null;
}
if (typeof chunk === "string") {
encoding = encoding || defaultEncoding;
chunk = Buffer.from(chunk, encoding);
} else {
encoding = "buffer";
}
const result = super.write({ chunk, encoding });
if (cb) stream.Writable.drained(this).then(() => cb(null), cb);
return result;
}
end(chunk, encoding, cb) {
if (typeof chunk === "function") {
cb = chunk;
chunk = null;
} else if (typeof encoding === "function") {
cb = encoding;
encoding = null;
}
if (typeof chunk === "string") {
encoding = encoding || defaultEncoding;
chunk = Buffer.from(chunk, encoding);
} else {
encoding = "buffer";
}
const result = chunk !== void 0 && chunk !== null ? super.end({ chunk, encoding }) : super.end();
if (cb) this.once("finish", () => cb(null));
return result;
}
};
exports.PassThrough = class PassThrough extends exports.Transform {
};
exports.finished = function finished(stream2, opts, cb) {
if (typeof opts === "function") {
cb = opts;
opts = {};
}
if (!opts) opts = {};
const { cleanup = false } = opts;
const done = () => {
cb(exports.getStreamError(stream2, { all: true }));
if (cleanup) detach();
};
const detach = () => {
stream2.off("close", done);
stream2.off("error", noop);
};
if (stream2.destroyed) {
done();
} else {
stream2.on("close", done);
stream2.on("error", noop);
}
return detach;
};
function read(read2, cb) {
read2.call(this, 65536);
cb(null);
}
function write(write2, data, cb) {
write2.call(this, data.chunk, data.encoding, cb);
}
function transform(transform2, data, cb) {
transform2.call(this, data.chunk, data.encoding, cb);
}
function destroy(destroy2, cb) {
destroy2.call(this, exports.getStreamError(this), cb);
}
function passthrough(data, cb) {
cb(null, data.chunk);
}
function byteLengthWritable(data) {
return data.chunk.byteLength;
}
function noop() {
}
}
});
// ../../node_modules/bare-fs/binding.js
var require_binding6 = __commonJS({
"../../node_modules/bare-fs/binding.js"(exports, module) {
module.exports = __require.addon();
}
});
// ../../node_modules/bare-fs/lib/constants.js
var require_constants3 = __commonJS({
"../../node_modules/bare-fs/lib/constants.js"(exports, module) {
var binding = require_binding6();
module.exports = {
O_RDWR: binding.O_RDWR,
O_RDONLY: binding.O_RDONLY,
O_WRONLY: binding.O_WRONLY,
O_CREAT: binding.O_CREAT,
O_TRUNC: binding.O_TRUNC,
O_APPEND: binding.O_APPEND,
F_OK: binding.F_OK || 0,
R_OK: binding.R_OK || 0,
W_OK: binding.W_OK || 0,
X_OK: binding.X_OK || 0,
S_IFMT: binding.S_IFMT,
S_IFREG: binding.S_IFREG,
S_IFDIR: binding.S_IFDIR,
S_IFCHR: binding.S_IFCHR,
S_IFLNK: binding.S_IFLNK,
S_IFBLK: binding.S_IFBLK || 0,
S_IFIFO: binding.S_IFIFO || 0,
S_IFSOCK: binding.S_IFSOCK || 0,
S_IRUSR: binding.S_IRUSR || 0,
S_IWUSR: binding.S_IWUSR || 0,
S_IXUSR: binding.S_IXUSR || 0,
S_IRGRP: binding.S_IRGRP || 0,
S_IWGRP: binding.S_IWGRP || 0,
S_IXGRP: binding.S_IXGRP || 0,
S_IROTH: binding.S_IROTH || 0,
S_IWOTH: binding.S_IWOTH || 0,
S_IXOTH: binding.S_IXOTH || 0,
UV_DIRENT_UNKNOWN: binding.UV_DIRENT_UNKNOWN,
UV_DIRENT_FILE: binding.UV_DIRENT_FILE,
UV_DIRENT_DIR: binding.UV_DIRENT_DIR,
UV_DIRENT_LINK: binding.UV_DIRENT_LINK,
UV_DIRENT_FIFO: binding.UV_DIRENT_FIFO,
UV_DIRENT_SOCKET: binding.UV_DIRENT_SOCKET,
UV_DIRENT_CHAR: binding.UV_DIRENT_CHAR,
UV_DIRENT_BLOCK: binding.UV_DIRENT_BLOCK,
COPYFILE_EXCL: binding.UV_FS_COPYFILE_EXCL,
COPYFILE_FICLONE: binding.UV_FS_COPYFILE_FICLONE,
COPYFILE_FICLONE_FORCE: binding.UV_FS_COPYFILE_FICLONE_FORCE,
UV_FS_SYMLINK_DIR: binding.UV_FS_SYMLINK_DIR,
UV_FS_SYMLINK_JUNCTION: binding.UV_FS_SYMLINK_JUNCTION
};
}
});
// ../../node_modules/bare-fs/lib/errors.js
var require_errors5 = __commonJS({
"../../node_modules/bare-fs/lib/errors.js"(exports, module) {
var os = require_bare_os();
module.exports = class FileError extends Error {
constructor(msg, opts = {}) {
const { code, operation = null, path = null, destination = null, fd = -1 } = opts;
if (operation !== null) msg += describe(operation, opts);
super(`${code}: ${msg}`);
this.code = code;
if (operation !== null) this.operation = operation;
if (path !== null) this.path = path;
if (destination !== null) this.destination = destination;
if (fd !== -1) this.fd = fd;
}
get name() {
return "FileError";
}
// For Node.js compatibility
get errno() {
return os.constants.errnos[this.code];
}
// For Node.js compatibility
get syscall() {
return this.operation;
}
// For Node.js compatibility
get dest() {
return this.destination;
}
};
function describe(operation, opts) {
const { path = null, destination = null, fd = -1 } = opts;
let result = `, ${operation}`;
if (path !== null) {
result += ` ${JSON.stringify(path)}`;
if (destination !== null) {
result += ` -> ${JSON.stringify(destination)}`;
}
} else if (fd !== -1) {
result += ` ${fd}`;
}
return result;
}
}
});
// ../../node_modules/bare-fs/promises.js
var require_promises = __commonJS({
"../../node_modules/bare-fs/promises.js"(exports) {
var EventEmitter = require_bare_events();
var fs = require_bare_fs();
var FileHandle = class extends EventEmitter {
constructor(fd) {
super();
this.fd = fd;
}
async close() {
await fs.close(this.fd);
this.fd = -1;
this.emit("close");
}
async read(buffer, ...args) {
return {
bytesRead: await fs.read(this.fd, buffer, ...args),
buffer
};
}
async readv(buffers, ...args) {
return {
bytesRead: await fs.readv(this.fd, buffers, ...args),
buffers
};
}
async write(buffer, ...args) {
return {
bytesWritten: await fs.write(this.fd, buffer, ...args),
buffer
};
}
async writev(buffers, ...args) {
return {
bytesWritten: await fs.writev(this.fd, buffers, ...args),
buffers
};
}
async stat() {
return fs.fstat(this.fd);
}
async chmod(mode) {
await fs.fchmod(this.fd, mode);
}
createReadStream(opts) {
return fs.createReadStream(null, { ...opts, fd: this.fd });
}
createWriteStream(opts) {
return fs.createWriteStream(null, { ...opts, fd: this.fd });
}
async [Symbol.asyncDispose]() {
await this.close();
}
};
exports.open = async function open(filepath, flags, mode) {
return new FileHandle(await fs.open(filepath, flags, mode));
};
exports.access = fs.access;
exports.appendFile = fs.appendFile;
exports.chmod = fs.chmod;
exports.constants = fs.constants;
exports.copyFile = fs.copyFile;
exports.cp = fs.cp;
exports.lstat = fs.lstat;
exports.mkdir = fs.mkdir;
exports.opendir = fs.opendir;
exports.readFile = fs.readFile;
exports.readdir = fs.readdir;
exports.readlink = fs.readlink;
exports.realpath = fs.realpath;
exports.rename = fs.rename;
exports.rm = fs.rm;
exports.rmdir = fs.rmdir;
exports.stat = fs.stat;
exports.symlink = fs.symlink;
exports.unlink = fs.unlink;
exports.utimes = fs.utimes;
exports.watch = fs.watch;
exports.writeFile = fs.writeFile;
}
});
// ../../node_modules/bare-fs/index.js
var require_bare_fs = __commonJS({
"../../node_modules/bare-fs/index.js"(exports) {
var FIFO = require_fast_fifo();
var EventEmitter = require_bare_events();
var path = require_bare_path();
var { isURL, fileURLToPath } = require_bare_url();
var { Readable, Writable } = require_bare_stream();
var binding = require_binding6();
var constants = require_constants3();
var FileError = require_errors5();
var isWindows = Bare.platform === "win32";
exports.constants = constants;
var FileRequest = class _FileRequest {
static borrow() {
if (this._free.length > 0) return this._free.pop();
return new _FileRequest();
}
static return(req) {
if (this._free.length < 32) this._free.push(req.reset());
else req.destroy();
}
constructor() {
this._reset();
this._handle = binding.requestInit(this, this._onresult);
}
get handle() {
return this._handle;
}
retain(value2) {
this._retain = value2;
}
reset() {
if (this._handle === null) return this;
binding.requestReset(this._handle);
this._reset();
return this;
}
destroy() {
if (this._handle === null) return this;
binding.requestDestroy(this._handle);
this._reset();
this._handle = null;
return this;
}
then(resolve, reject) {
return this._promise.then(resolve, reject);
}
return() {
if (this._handle === null) return this;
_FileRequest.return(this);
return this;
}
_reset() {
this._promise = new Promise((resolve, reject) => {
this._resolve = resolve;
this._reject = reject;
});
this._retain = null;
}
_onresult(err, status) {
if (err) this._reject(err);
else this._resolve(status);
}
};
FileRequest._free = [];
function ok(result, cb) {
if (typeof result === "function") {
cb = result;
result = void 0;
}
if (cb) cb(null, result);
else return result;
}
function fail(err, cb) {
if (cb) cb(err);
else throw err;
}
function done(err, result, cb) {
if (typeof result === "function") {
cb = result;
result = void 0;
}
if (err) fail(err, cb);
else return ok(result, cb);
}
async function open(filepath, flags = "r", mode = 438, cb) {
if (typeof flags === "function") {
cb = flags;
flags = "r";
mode = 438;
} else if (typeof mode === "function") {
cb = mode;
mode = 438;
}
if (typeof flags === "string") flags = toFlags(flags);
if (typeof mode === "string") mode = toMode(mode);
filepath = toNamespacedPath(filepath);
const req = FileRequest.borrow();
let fd;
let err = null;
try {
binding.open(req.handle, filepath, flags, mode);
fd = await req;
} catch (e) {
err = new FileError(e.message, {
operation: "open",
code: e.code,
path: filepath
});
} finally {
req.return();
}
return done(err, fd, cb);
}
function openSync(filepath, flags = "r", mode = 438) {
if (typeof flags === "string") flags = toFlags(flags);
if (typeof mode === "string") mode = toMode(mode);
filepath = toNamespacedPath(filepath);
const req = FileRequest.borrow();
try {
return binding.openSync(req.handle, filepath, flags, mode);
} catch (e) {
throw new FileError(e.message, {
operation: "open",
code: e.code,
path: filepath
});
} finally {
req.return();
}
}
async function close(fd, cb) {
const req = FileRequest.borrow();
let err = null;
try {
binding.close(req.handle, fd);
await req;
} catch (e) {
err = new FileError(e.message, { operation: "close", code: e.code, fd });
} finally {
req.return();
}
return done(err, cb);
}
function closeSync(fd) {
const req = FileRequest.borrow();
try {
binding.closeSync(req.handle, fd);
} catch (e) {
throw new FileError(e.message, { operation: "close", code: e.code, fd });
} finally {
req.return();
}
}
async function access(filepath, mode = constants.F_OK, cb) {
if (typeof mode === "function") {
cb = mode;
mode = constants.F_OK;
}
filepath = toNamespacedPath(filepath);
const req = FileRequest.borrow();
let err = null;
try {
binding.access(req.handle, filepath, mode);
await req;
} catch (e) {
err = new FileError(e.message, {
operation: "access",
code: e.code,
path: filepath
});
} finally {
req.return();
}
return done(err, cb);
}
function accessSync(filepath, mode = constants.F_OK) {
filepath = toNamespacedPath(filepath);
const req = FileRequest.borrow();
try {
binding.accessSync(req.handle, filepath, mode);
} catch (e) {
throw new FileError(e.message, {
operation: "access",
code: e.code,
path: filepath
});
} finally {
req.return();
}
}
async function exists(filepath, cb) {
let ok2 = true;
try {
await access(filepath);
} catch {
ok2 = false;
}
return done(null, ok2, cb);
}
function existsSync(filepath) {
try {
accessSync(filepath);
} catch {
return false;
}
return true;
}
async function read(fd, buffer, offset = 0, len = buffer.byteLength - offset, pos = -1, cb) {
if (typeof offset === "function") {
cb = offset;
offset = 0;
len = buffer.byteLength;
pos = -1;
} else if (typeof len === "function") {
cb = len;
len = buffer.byteLength - offset;
pos = -1;
} else if (typeof pos === "function") {
cb = pos;
pos = -1;
}
if (typeof pos !== "number") pos = -1;
const req = FileRequest.borrow();
let bytes;
let err = null;
try {
binding.read(req.handle, fd, buffer, offset, len, pos);
bytes = await req;
} catch (e) {
err = new FileError(e.message, { operation: "read", code: e.code, fd });
} finally {
req.return();
}
return done(err, bytes, cb);
}
function readSync(fd, buffer, offset = 0, len = buffer.byteLength - offset, pos = -1) {
const req = FileRequest.borrow();
try {
return binding.readSync(req.handle, fd, buffer, offset, len, pos);
} catch (e) {
throw new FileError(e.message, { operation: "read", code: e.code, fd });
} finally {
req.return();
}
}
async function readv(fd, buffers, pos = -1, cb) {
if (typeof pos === "function") {
cb = pos;
pos = -1;
}
if (typeof pos !== "number") pos = -1;
const req = FileRequest.borrow();
let bytes;
let err = null;
try {
binding.readv(req.handle, fd, buffers, pos);
bytes = await req;
} catch (e) {
err = new FileError(e.message, { operation: "readv", code: e.code, fd });
} finally {
req.return();
}
return done(err, bytes, cb);
}
function readvSync(fd, buffers, pos = -1) {
if (typeof pos !== "number") pos = -1;
const req = FileRequest.borrow();
try {
return binding.readvSync(req.handle, fd, buffers, pos);
} catch (e) {
throw new FileError(e.message, { operation: "readv", code: e.code, fd });
} finally {
req.return();
}
}
async function write(fd, data, offset, len, pos = -1, cb) {
if (typeof data === "string") {
let encoding = len;
cb = pos;
pos = offset;
if (typeof pos === "function") {
cb = pos;
pos = -1;
encoding = "utf8";
} else if (typeof encoding === "function") {
cb = encoding;
encoding = "utf8";
}
if (typeof pos === "string") {
encoding = pos;
pos = -1;
}
data = Buffer.from(data, encoding);
offset = 0;
len = data.byteLength;
} else if (typeof offset === "function") {
cb = offset;
offset = 0;
len = data.byteLength;
pos = -1;
} else if (typeof len === "function") {
cb = len;
len = data.byteLength - offset;
pos = -1;
} else if (typeof pos === "function") {
cb = pos;
pos = -1;
}
if (typeof offset !== "number") offset = 0;
if (typeof len !== "number") len = data.byteLength - offset;
if (typeof pos !== "number") pos = -1;
const req = FileRequest.borrow();
let bytes;
let err = null;
try {
binding.write(req.handle, fd, data, offset, len, pos);
bytes = await req;
} catch (e) {
err = new FileError(e.message, { operation: "write", code: e.code, fd });
} finally {
req.return();
}
return done(err, bytes, cb);
}
function writeSync(fd, data, offset, len, pos = -1) {
if (typeof data === "string") {
let encoding = len;
pos = offset;
if (typeof pos === "string") {
encoding = pos;
pos = -1;
}
data = Buffer.from(data, encoding);
offset = 0;
len = data.byteLength;
}
if (typeof offset !== "number") offset = 0;
if (typeof len !== "number") len = data.byteLength - offset;
if (typeof pos !== "number") pos = -1;
const req = FileRequest.borrow();
try {
return binding.writeSync(req.handle, fd, data, offset, len, pos);
} catch (e) {
throw new FileError(e.message, { operation: "write", code: e.code, fd });
} finally {
req.return();
}
}
async function writev(fd, buffers, pos = -1, cb) {
if (typeof pos === "function") {
cb = pos;
pos = -1;
}
if (typeof pos !== "number") pos = -1;
const req = FileRequest.borrow();
let bytes;
let err = null;
try {
binding.writev(req.handle, fd, buffers, pos);
bytes = await req;
} catch (e) {
err = new FileError(e.message, { operation: "writev", code: e.code, fd });
} finally {
req.return();
}
return done(err, bytes, cb);
}
function writevSync(fd, buffers, pos = -1) {
if (typeof pos !== "number") pos = -1;
const req = FileRequest.borrow();
try {
return binding.writevSync(req.handle, fd, buffers, pos);
} catch (e) {
throw new FileError(e.message, { operation: "writev", code: e.code, fd });
} finally {
req.return();
}
}
async function stat(filepath, cb) {
filepath = toNamespacedPath(filepath);
const req = FileRequest.borrow();
let st;
let err = null;
try {
binding.stat(req.handle, filepath);
await req;
st = new Stats(...binding.requestResultStat(req.handle));
} catch (e) {
err = new FileError(e.message, {
operation: "stat",
code: e.code,
path: filepath
});
} finally {
req.return();
}
return done(err, st, cb);
}
function statSync(filepath) {
filepath = toNamespacedPath(filepath);
const req = FileRequest.borrow();
try {
binding.statSync(req.handle, filepath);
return new Stats(...binding.requestResultStat(req.handle));
} catch (e) {
throw new FileError(e.message, {
operation: "stat",
code: e.code,
path: filepath
});
} finally {
req.return();
}
}
async function lstat(filepath, cb) {
filepath = toNamespacedPath(filepath);
const req = FileRequest.borrow();
let st;
let err = null;
try {
binding.lstat(req.handle, filepath);
await req;
st = new Stats(...binding.requestResultStat(req.handle));
} catch (e) {
err = new FileError(e.message, {
operation: "lstat",
code: e.code,
path: filepath
});
} finally {
req.return();
}
return done(err, st, cb);
}
function lstatSync(filepath) {
filepath = toNamespacedPath(filepath);
const req = FileRequest.borrow();
try {
binding.lstatSync(req.handle, filepath);
return new Stats(...binding.requestResultStat(req.handle));
} catch (e) {
throw new FileError(e.message, {
operation: "lstat",
code: e.code,
path: filepath
});
} finally {
req.return();
}
}
async function fstat(fd, cb) {
const req = FileRequest.borrow();
let st;
let err = null;
try {
binding.fstat(req.handle, fd);
await req;
st = new Stats(...binding.requestResultStat(req.handle));
} catch (e) {
err = new FileError(e.message, { operation: "fstat", code: e.code, fd });
} finally {
req.return();
}
return done(err, st, cb);
}
function fstatSync(fd) {
const req = FileRequest.borrow();
try {
binding.fstatSync(req.handle, fd);
return new Stats(...binding.requestResultStat(req.handle));
} catch (e) {
throw new FileError(e.message, { operation: "fstat", code: e.code, fd });
} finally {
req.return();
}
}
async function ftruncate(fd, len = 0, cb) {
if (typeof len === "function") {
cb = len;
len = 0;
}
if (typeof len !== "number") len = 0;
const req = FileRequest.borrow();
let err = null;
try {
binding.ftruncate(req.handle, fd, len);
await req;
} catch (e) {
err = new FileError(e.message, { operation: "ftruncate", code: e.code, fd });
} finally {
req.return();
}
return done(err, cb);
}
function ftruncateSync(fd, len = 0) {
if (typeof len !== "number") len = 0;
const req = FileRequest.borrow();
try {
binding.ftruncateSync(req.handle, fd, len);
} catch (e) {
throw new FileError(e.message, { operation: "ftruncate", code: e.code, fd });
} finally {
req.return();
}
}
async function chmod(filepath, mode, cb) {
if (typeof mode === "string") mode = toMode(mode);
filepath = toNamespacedPath(filepath);
const req = FileRequest.borrow();
let err = null;
try {
binding.chmod(req.handle, filepath, mode);
await req;
} catch (e) {
err = new FileError(e.message, {
operation: "chmod",
code: e.code,
path: filepath
});
} finally {
req.return();
}
return done(err, cb);
}
function chmodSync(filepath, mode) {
if (typeof mode === "string") mode = toMode(mode);
filepath = toNamespacedPath(filepath);
const req = FileRequest.borrow();
try {
binding.chmodSync(req.handle, filepath, mode);
} catch (e) {
throw new FileError(e.message, {
operation: "chmod",
code: e.code,
path: filepath
});
} finally {
req.return();
}
}
async function fchmod(fd, mode, cb) {
if (typeof mode === "string") mode = toMode(mode);
const req = FileRequest.borrow();
let err = null;
try {
binding.fchmod(req.handle, fd, mode);
await req;
} catch (e) {
err = new FileError(e.message, { operation: "fchmod", code: e.code, fd });
} finally {
req.return();
}
return done(err, cb);
}
function fchmodSync(fd, mode) {
if (typeof mode === "string") mode = toMode(mode);
const req = FileRequest.borrow();
try {
binding.fchmodSync(req.handle, fd, mode);
} catch (e) {
throw new FileError(e.message, { operation: "fchmod", code: e.code, fd });
} finally {
req.return();
}
}
async function utimes(filepath, atime, mtime, cb) {
if (typeof atime !== "number") atime = atime.getTime() / 1e3;
if (typeof mtime !== "number") mtime = mtime.getTime() / 1e3;
filepath = toNamespacedPath(filepath);
const req = FileRequest.borrow();
let err = null;
try {
binding.utimes(req.handle, filepath, atime, mtime);
await req;
} catch (e) {
err = new FileError(e.message, {
operation: "utimes",
code: e.code,
path: filepath
});
} finally {
req.return();
}
return done(err, cb);
}
function utimesSync(filepath, atime, mtime) {
if (typeof atime !== "number") atime = atime.getTime() / 1e3;
if (typeof mtime !== "number") mtime = mtime.getTime() / 1e3;
filepath = toNamespacedPath(filepath);
const req = FileRequest.borrow();
try {
binding.utimesSync(req.handle, filepath, atime, mtime);
} catch (e) {
throw new FileError(e.message, {
operation: "utimes",
code: e.code,
path: filepath
});
} finally {
req.return();
}
}
async function mkdir(filepath, opts, cb) {
if (typeof opts === "function") {
cb = opts;
opts = { mode: 511 };
}
if (typeof opts === "number") opts = { mode: opts };
else if (!opts) opts = {};
const mode = typeof opts.mode === "number" ? opts.mode : 511;
filepath = toNamespacedPath(filepath);
if (opts.recursive) {
let err2 = null;
try {
try {
await mkdir(filepath, { mode });
} catch (err3) {
if (err3.code !== "ENOENT") {
if (!(await stat(filepath)).isDirectory()) throw err3;
} else {
while (filepath.endsWith(path.sep)) filepath = filepath.slice(0, -1);
const i = filepath.lastIndexOf(path.sep);
if (i <= 0) throw err3;
await mkdir(filepath.slice(0, i), { mode, recursive: true });
try {
await mkdir(filepath, { mode });
} catch (err4) {
if (!(await stat(filepath)).isDirectory()) throw err4;
}
}
}
} catch (e) {
err2 = e;
}
return done(err2, cb);
}
const req = FileRequest.borrow();
let err = null;
try {
binding.mkdir(req.handle, filepath, mode);
await req;
} catch (e) {
err = new FileError(e.message, {
operation: "mkdir",
code: e.code,
path: filepath
});
} finally {
req.return();
}
return done(err, cb);
}
function mkdirSync(filepath, opts) {
if (typeof opts === "number") opts = { mode: opts };
else if (!opts) opts = {};
const mode = typeof opts.mode === "number" ? opts.mode : 511;
filepath = toNamespacedPath(filepath);
if (opts.recursive) {
try {
mkdirSync(filepath, { mode });
} catch (err) {
if (err.code !== "ENOENT") {
if (!statSync(filepath).isDirectory()) throw err;
} else {
while (filepath.endsWith(path.sep)) filepath = filepath.slice(0, -1);
const i = filepath.lastIndexOf(path.sep);
if (i <= 0) throw err;
mkdirSync(filepath.slice(0, i), { mode, recursive: true });
try {
mkdirSync(filepath, { mode });
} catch (err2) {
if (!statSync(filepath).isDirectory()) throw err2;
}
}
}
return;
}
const req = FileRequest.borrow();
try {
binding.mkdirSync(req.handle, filepath, mode);
} catch (e) {
throw new FileError(e.message, {
operation: "mkdir",
code: e.code,
path: filepath
});
} finally {
req.return();
}
}
async function rmdir(filepath, cb) {
filepath = toNamespacedPath(filepath);
const req = FileRequest.borrow();
let err = null;
try {
binding.rmdir(req.handle, filepath);
await req;
} catch (e) {
err = new FileError(e.message, {
operation: "rmdir",
code: e.code,
path: filepath
});
} finally {
req.return();
}
return done(err, cb);
}
function rmdirSync(filepath) {
filepath = toNamespacedPath(filepath);
const req = FileRequest.borrow();
try {
binding.rmdirSync(req.handle, filepath);
} catch (e) {
throw new FileError(e.message, {
operation: "rmdir",
code: e.code,
path: filepath
});
} finally {
req.return();
}
}
async function rm(filepath, opts, cb) {
if (typeof opts === "function") {
cb = opts;
opts = {};
}
if (!opts) opts = {};
filepath = toNamespacedPath(filepath);
let err = null;
try {
const st = await lstat(filepath);
if (st.isDirectory()) {
if (opts.recursive) {
try {
await rmdir(filepath);
} catch (err2) {
if (err2.code !== "ENOTEMPTY") throw err2;
const files = await readdir(filepath);
for (const file of files) {
await rm(filepath + path.sep + file, opts);
}
await rmdir(filepath);
}
} else {
throw new FileError("is a directory", {
operation: "rm",
code: "EISDIR",
path: filepath
});
}
} else {
await unlink(filepath);
}
} catch (e) {
if (e.code !== "ENOENT" || !opts.force) err = e;
}
return done(err, cb);
}
function rmSync(filepath, opts) {
if (!opts) opts = {};
filepath = toNamespacedPath(filepath);
try {
const st = lstatSync(filepath);
if (st.isDirectory()) {
if (opts.recursive) {
try {
rmdirSync(filepath);
} catch (err) {
if (err.code !== "ENOTEMPTY") throw err;
const files = readdirSync(filepath);
for (const file of files) {
rmSync(filepath + path.sep + file, opts);
}
rmdirSync(filepath);
}
} else {
throw new FileError("is a directory", {
operation: "rm",
code: "EISDIR",
path: filepath
});
}
} else {
unlinkSync(filepath);
}
} catch (err) {
if (err.code !== "ENOENT" || !opts.force) throw err;
}
}
async function unlink(filepath, cb) {
filepath = toNamespacedPath(filepath);
const req = FileRequest.borrow();
let err = null;
try {
binding.unlink(req.handle, filepath);
await req;
} catch (e) {
err = new FileError(e.message, {
operation: "unlink",
code: e.code,
path: filepath
});
} finally {
req.return();
}
return done(err, cb);
}
function unlinkSync(filepath) {
filepath = toNamespacedPath(filepath);
const req = FileRequest.borrow();
try {
binding.unlinkSync(req.handle, filepath);
} catch (e) {
throw new FileError(e.message, {
operation: "unlink",
code: e.code,
path: filepath
});
} finally {
req.return();
}
}
async function rename(src, dst, cb) {
src = toNamespacedPath(src);
dst = toNamespacedPath(dst);
const req = FileRequest.borrow();
let err = null;
try {
binding.rename(req.handle, src, dst);
await req;
} catch (e) {
err = new FileError(e.message, {
operation: "rename",
code: e.code,
path: src,
destination: dst
});
} finally {
req.return();
}
return done(err, cb);
}
function renameSync(src, dst) {
src = toNamespacedPath(src);
dst = toNamespacedPath(dst);
const req = FileRequest.borrow();
try {
binding.renameSync(req.handle, src, dst);
} catch (e) {
throw new FileError(e.message, {
operation: "rename",
code: e.code,
path: src,
destination: dst
});
} finally {
req.return();
}
}
async function copyFile(src, dst, mode = 0, cb) {
if (typeof mode === "function") {
cb = mode;
mode = 0;
}
src = toNamespacedPath(src);
dst = toNamespacedPath(dst);
const req = FileRequest.borrow();
let err = null;
try {
binding.copyfile(req.handle, src, dst, mode);
await req;
} catch (e) {
err = new FileError(e.message, {
operation: "copyfile",
code: e.code,
path: src,
destination: dst
});
} finally {
req.return();
}
return done(err, cb);
}
function copyFileSync(src, dst, mode = 0) {
src = toNamespacedPath(src);
dst = toNamespacedPath(dst);
const req = FileRequest.borrow();
try {
binding.copyfileSync(req.handle, src, dst, mode);
} catch (e) {
throw new FileError(e.message, {
operation: "copyfile",
code: e.code,
path: src,
destination: dst
});
} finally {
req.return();
}
}
async function cp(src, dst, opts, cb) {
if (typeof opts === "function") {
cb = opts;
opts = {};
}
if (!opts) opts = {};
src = toNamespacedPath(src);
dst = toNamespacedPath(dst);
let err = null;
try {
const st = await lstat(src);
if (st.isDirectory()) {
if (opts.recursive !== true) {
throw new FileError("is a directory", { operation: "cp", code: "EISDIR", path: src });
}
try {
await lstat(dst);
} catch (e) {
if (e.code !== "ENOENT") throw e;
await mkdir(dst, { mode: st.mode, recursive: true });
}
const dir = await opendir(src);
for await (const { name } of dir) {
await cp(path.join(src, name), path.join(dst, name), opts);
}
} else if (st.isFile()) {
await copyFile(src, dst);
await chmod(dst, st.mode);
}
} catch (e) {
err = e;
}
return done(err, cb);
}
function cpSync(src, dst, opts = {}) {
src = toNamespacedPath(src);
dst = toNamespacedPath(dst);
const st = lstatSync(src);
if (st.isDirectory()) {
if (opts.recursive !== true) {
throw new FileError("is a directory", { operation: "cp", code: "EISDIR", path: src });
}
try {
lstatSync(dst);
} catch (e) {
if (e.code !== "ENOENT") throw e;
mkdirSync(dst, { mode: st.mode, recursive: true });
}
const dir = opendirSync(src);
for (const { name } of dir) {
cpSync(path.join(src, name), path.join(dst, name), opts);
}
} else if (st.isFile()) {
copyFileSync(src, dst);
chmodSync(dst, st.mode);
}
}
async function realpath(filepath, opts, cb) {
if (typeof opts === "function") {
cb = opts;
opts = {};
}
if (typeof opts === "string") opts = { encoding: opts };
else if (!opts) opts = {};
const { encoding = "utf8" } = opts;
filepath = toNamespacedPath(filepath);
const req = FileRequest.borrow();
let res;
let err = null;
try {
binding.realpath(req.handle, filepath);
await req;
res = Buffer.from(binding.requestResultString(req.handle));
if (encoding !== "buffer") res = res.toString(encoding);
} catch (e) {
err = new FileError(e.message, {
operation: "realpath",
code: e.code,
path: filepath
});
} finally {
req.return();
}
return done(err, res, cb);
}
function realpathSync(filepath, opts) {
if (typeof opts === "string") opts = { encoding: opts };
else if (!opts) opts = {};
const { encoding = "utf8" } = opts;
filepath = toNamespacedPath(filepath);
const req = FileRequest.borrow();
try {
binding.realpathSync(req.handle, filepath);
let res = Buffer.from(binding.requestResultString(req.handle));
if (encoding !== "buffer") res = res.toString(encoding);
return res;
} catch (e) {
throw new FileError(e.message, {
operation: "realpath",
code: e.code,
path: filepath
});
} finally {
req.return();
}
}
async function readlink(filepath, opts, cb) {
if (typeof opts === "function") {
cb = opts;
opts = {};
}
if (typeof opts === "string") opts = { encoding: opts };
else if (!opts) opts = {};
const { encoding = "utf8" } = opts;
filepath = toNamespacedPath(filepath);
const req = FileRequest.borrow();
let res;
let err = null;
try {
binding.readlink(req.handle, filepath);
await req;
res = Buffer.from(binding.requestResultString(req.handle));
if (encoding !== "buffer") res = res.toString(encoding);
} catch (e) {
err = new FileError(e.message, {
operation: "readlink",
code: e.code,
path: filepath
});
} finally {
req.return();
}
return done(err, res, cb);
}
function readlinkSync(filepath, opts) {
if (typeof opts === "string") opts = { encoding: opts };
else if (!opts) opts = {};
const { encoding = "utf8" } = opts;
filepath = toNamespacedPath(filepath);
const req = FileRequest.borrow();
try {
binding.readlinkSync(req.handle, filepath);
let res = Buffer.from(binding.requestResultString(req.handle));
if (encoding !== "buffer") res = res.toString(encoding);
return res;
} catch (e) {
throw new FileError(e.message, {
operation: "readlink",
code: e.code,
path: filepath
});
} finally {
req.return();
}
}
function normalizeSymlinkTarget(target, type, filepath) {
if (isWindows) {
if (type === constants.UV_FS_SYMLINK_JUNCTION) target = path.resolve(filepath, "..", target);
if (path.isAbsolute(target)) return path.toNamespacedPath(target);
return target.replace(/\//g, path.sep);
}
return target;
}
async function symlink(target, filepath, type, cb) {
if (typeof type === "function") {
cb = type;
type = null;
}
filepath = toNamespacedPath(filepath);
if (typeof type === "string") {
switch (type) {
case "dir":
type = constants.UV_FS_SYMLINK_DIR;
break;
case "junction":
type = constants.UV_FS_SYMLINK_JUNCTION;
break;
case "file":
default:
type = 0;
break;
}
} else if (typeof type !== "number") {
if (isWindows) {
target = path.resolve(filepath, "..", target);
try {
type = (await stat(target)).isDirectory() ? constants.UV_FS_SYMLINK_DIR : constants.UV_FS_SYMLINK_JUNCTION;
} catch {
type = 0;
}
} else {
type = 0;
}
}
target = normalizeSymlinkTarget(target, type, filepath);
const req = FileRequest.borrow();
let err = null;
try {
binding.symlink(req.handle, target, filepath, type);
await req;
} catch (e) {
err = new FileError(e.message, {
operation: "symlink",
code: e.code,
path: target,
destination: filepath
});
} finally {
req.return();
}
return done(err, cb);
}
function symlinkSync(target, filepath, type) {
filepath = toNamespacedPath(filepath);
if (typeof type === "string") {
switch (type) {
case "dir":
type = constants.UV_FS_SYMLINK_DIR;
break;
case "junction":
type = constants.UV_FS_SYMLINK_JUNCTION;
break;
case "file":
default:
type = 0;
break;
}
} else if (typeof type !== "number") {
if (isWindows) {
target = path.resolve(filepath, "..", target);
try {
type = statSync(target).isDirectory() ? constants.UV_FS_SYMLINK_DIR : constants.UV_FS_SYMLINK_JUNCTION;
} catch {
type = 0;
}
} else {
type = 0;
}
}
target = normalizeSymlinkTarget(target, type, filepath);
const req = FileRequest.borrow();
try {
binding.symlinkSync(req.handle, target, filepath, type);
} catch (e) {
throw new FileError(e.message, {
operation: "symlink",
code: e.code,
path: target,
destination: filepath
});
} finally {
req.return();
}
}
async function opendir(filepath, opts, cb) {
if (typeof opts === "function") {
cb = opts;
opts = {};
}
if (typeof opts === "string") opts = { encoding: opts };
else if (!opts) opts = {};
filepath = toNamespacedPath(filepath);
const req = FileRequest.borrow();
let dir;
let err = null;
try {
binding.opendir(req.handle, filepath);
await req;
dir = new Dir(filepath, binding.requestResultDir(req.handle), opts);
} catch (e) {
err = new FileError(e.message, {
operation: "opendir",
code: e.code,
path: filepath
});
} finally {
req.return();
}
return done(err, dir, cb);
}
function opendirSync(filepath, opts) {
if (typeof opts === "string") opts = { encoding: opts };
else if (!opts) opts = {};
filepath = toNamespacedPath(filepath);
const req = FileRequest.borrow();
try {
binding.opendirSync(req.handle, filepath);
return new Dir(filepath, binding.requestResultDir(req.handle), opts);
} catch (e) {
throw new FileError(e.message, {
operation: "opendir",
code: e.code,
path: filepath
});
} finally {
req.return();
}
}
async function readdir(filepath, opts, cb) {
if (typeof opts === "function") {
cb = opts;
opts = {};
}
if (typeof opts === "string") opts = { encoding: opts };
else if (!opts) opts = {};
const { withFileTypes = false } = opts;
filepath = toNamespacedPath(filepath);
let result = [];
let err = null;
try {
const dir = await opendir(filepath);
for await (const entry of dir) {
result.push(withFileTypes ? entry : entry.name);
}
} catch (e) {
result = [];
err = e;
}
return done(err, result, cb);
}
function readdirSync(filepath, opts) {
if (typeof opts === "string") opts = { encoding: opts };
else if (!opts) opts = {};
const { withFileTypes = false } = opts;
filepath = toNamespacedPath(filepath);
const dir = opendirSync(filepath, opts);
const result = [];
for (const entry of dir) {
result.push(withFileTypes ? entry : entry.name);
}
return result;
}
async function readFile(filepath, opts, cb) {
if (typeof opts === "function") {
cb = opts;
opts = {};
}
if (typeof opts === "string") opts = { encoding: opts };
else if (!opts) opts = {};
const { encoding = "buffer" } = opts;
let fd = -1;
let buffer = null;
let err = null;
try {
fd = await open(filepath, opts.flag || "r");
const st = await fstat(fd);
let len = 0;
if (st.size === 0) {
const buffers = [];
while (true) {
buffer = Buffer.allocUnsafe(8192);
const r = await read(fd, buffer);
len += r;
if (r === 0) break;
buffers.push(buffer.subarray(0, r));
}
buffer = Buffer.concat(buffers);
} else {
buffer = Buffer.allocUnsafe(st.size);
while (true) {
const r = await read(fd, len ? buffer.subarray(len) : buffer);
len += r;
if (r === 0 || len === buffer.byteLength) break;
}
if (len !== buffer.byteLength) buffer = buffer.subarray(0, len);
}
if (encoding !== "buffer") buffer = buffer.toString(encoding);
} catch (e) {
err = e;
} finally {
if (fd !== -1) await close(fd);
}
return done(err, buffer, cb);
}
function readFileSync(filepath, opts) {
if (typeof opts === "string") opts = { encoding: opts };
else if (!opts) opts = {};
const { encoding = "buffer" } = opts;
let fd = -1;
try {
fd = openSync(filepath, opts.flag || "r");
const st = fstatSync(fd);
let buffer;
let len = 0;
if (st.size === 0) {
const buffers = [];
while (true) {
buffer = Buffer.allocUnsafe(8192);
const r = readSync(fd, buffer);
len += r;
if (r === 0) break;
buffers.push(buffer.subarray(0, r));
}
buffer = Buffer.concat(buffers);
} else {
buffer = Buffer.allocUnsafe(st.size);
while (true) {
const r = readSync(fd, len ? buffer.subarray(len) : buffer);
len += r;
if (r === 0 || len === buffer.byteLength) break;
}
if (len !== buffer.byteLength) buffer = buffer.subarray(0, len);
}
if (encoding !== "buffer") buffer = buffer.toString(encoding);
return buffer;
} finally {
if (fd !== -1) closeSync(fd);
}
}
async function writeFile(filepath, data, opts, cb) {
if (typeof opts === "function") {
cb = opts;
opts = {};
}
if (typeof opts === "string") opts = { encoding: opts };
else if (!opts) opts = {};
if (typeof data === "string") data = Buffer.from(data, opts.encoding);
let fd = -1;
let len = 0;
let err = null;
try {
fd = await open(filepath, opts.flag || "w", opts.mode || 438);
while (true) {
len += await write(fd, len ? data.subarray(len) : data);
if (len === data.byteLength) break;
}
} catch (e) {
err = e;
} finally {
if (fd !== -1) await close(fd);
}
return done(err, len, cb);
}
function writeFileSync(filepath, data, opts) {
if (typeof opts === "string") opts = { encoding: opts };
else if (!opts) opts = {};
if (typeof data === "string") data = Buffer.from(data, opts.encoding);
let fd = -1;
try {
fd = openSync(filepath, opts.flag || "w", opts.mode || 438);
let len = 0;
while (true) {
len += writeSync(fd, len ? data.subarray(len) : data);
if (len === data.byteLength) break;
}
} finally {
if (fd !== -1) closeSync(fd);
}
}
function appendFile(filepath, data, opts, cb) {
if (typeof opts === "function") {
cb = opts;
opts = {};
}
if (typeof opts === "string") opts = { encoding: opts };
else if (!opts) opts = {};
if (!opts.flag) opts = { ...opts, flag: "a" };
return writeFile(filepath, data, opts, cb);
}
function appendFileSync(filepath, data, opts) {
if (typeof opts === "string") opts = { encoding: opts };
else if (!opts) opts = {};
if (!opts.flag) opts = { ...opts, flag: "a" };
return writeFileSync(filepath, data, opts);
}
function watch(filepath, opts, cb) {
if (typeof opts === "function") {
cb = opts;
opts = {};
}
if (typeof opts === "string") opts = { encoding: opts };
else if (!opts) opts = {};
filepath = toNamespacedPath(filepath);
return new Watcher(filepath, opts, cb);
}
var Stats = class {
constructor(dev, mode, nlink, uid, gid, rdev, blksize, ino, size, blocks, atimeMs, mtimeMs, ctimeMs, birthtimeMs) {
this.dev = dev;
this.mode = mode;
this.nlink = nlink;
this.uid = uid;
this.gid = gid;
this.rdev = rdev;
this.blksize = blksize;
this.ino = ino;
this.size = size;
this.blocks = blocks;
this.atimeMs = atimeMs;
this.mtimeMs = mtimeMs;
this.ctimeMs = ctimeMs;
this.birthtimeMs = birthtimeMs;
this.atime = new Date(atimeMs);
this.mtime = new Date(mtimeMs);
this.ctime = new Date(ctimeMs);
this.birthtime = new Date(birthtimeMs);
}
isDirectory() {
return (this.mode & constants.S_IFMT) === constants.S_IFDIR;
}
isFile() {
return (this.mode & constants.S_IFMT) === constants.S_IFREG;
}
isBlockDevice() {
return (this.mode & constants.S_IFMT) === constants.S_IFBLK;
}
isCharacterDevice() {
return (this.mode & constants.S_IFMT) === constants.S_IFCHR;
}
isFIFO() {
return (this.mode & constants.S_IFMT) === constants.S_IFIFO;
}
isSymbolicLink() {
return (this.mode & constants.S_IFMT) === constants.S_IFLNK;
}
isSocket() {
return (this.mode & constants.S_IFMT) === constants.S_IFSOCK;
}
};
var Dir = class {
constructor(path2, handle, opts = {}) {
const { encoding = "utf8", bufferSize = 32 } = opts;
this.path = path2;
this._encoding = encoding;
this._capacity = bufferSize;
this._buffer = new FIFO();
this._ended = false;
this._handle = handle;
}
async read(cb) {
if (this._buffer.length) return ok(this._buffer.shift(), cb);
if (this._ended) return ok(null, cb);
const req = FileRequest.borrow();
let entries;
let err = null;
try {
req.retain(binding.readdir(req.handle, this._handle, this._capacity));
await req;
entries = binding.requestResultDirents(req.handle);
} catch (e) {
err = new FileError(e.message, {
operation: "readdir",
code: e.code,
path: this.path
});
} finally {
req.return();
}
if (err) return fail(err, cb);
if (entries.length === 0) {
this._ended = true;
return ok(null, cb);
}
for (const entry of entries) {
let name = Buffer.from(entry.name);
if (this._encoding !== "buffer") name = name.toString(this._encoding);
this._buffer.push(new Dirent(this.path, name, entry.type));
}
return ok(this._buffer.shift(), cb);
}
readSync() {
if (this._buffer.length) return this._buffer.shift();
if (this._ended) return null;
const req = FileRequest.borrow();
let entries;
try {
req.retain(binding.readdirSync(req.handle, this._handle, this._capacity));
entries = binding.requestResultDirents(req.handle);
} catch (e) {
throw new FileError(e.message, {
operation: "readdir",
code: e.code,
path: this.path
});
} finally {
req.return();
}
if (entries.length === 0) {
this._ended = true;
return null;
}
for (const entry of entries) {
let name = Buffer.from(entry.name);
if (this._encoding !== "buffer") name = name.toString(this._encoding);
this._buffer.push(new Dirent(this.path, name, entry.type));
}
return this._buffer.shift();
}
async close(cb) {
const req = FileRequest.borrow();
let err = null;
try {
binding.closedir(req.handle, this._handle);
await req;
} catch (e) {
err = new FileError(e.message, {
operation: "closedir",
code: e.code,
path: this.path
});
} finally {
req.return();
}
this._handle = null;
return done(err, cb);
}
closeSync() {
const req = FileRequest.borrow();
try {
binding.closedirSync(req.handle, this._handle);
} catch (e) {
throw new FileError(e.message, {
operation: "closedir",
code: e.code,
path: this.path
});
} finally {
req.return();
}
this._handle = null;
}
[Symbol.dispose]() {
this.closeSync();
}
async [Symbol.asyncDispose]() {
await this.close();
}
*[Symbol.iterator]() {
while (true) {
const entry = this.readSync();
if (entry === null) break;
yield entry;
}
this.closeSync();
}
async *[Symbol.asyncIterator]() {
while (true) {
const entry = await this.read();
if (entry === null) break;
yield entry;
}
await this.close();
}
};
var Dirent = class {
constructor(parentPath, name, type) {
this.parentPath = parentPath;
this.name = name;
this.type = type;
}
isFile() {
return this.type === constants.UV_DIRENT_FILE;
}
isDirectory() {
return this.type === constants.UV_DIRENT_DIR;
}
isSymbolicLink() {
return this.type === constants.UV_DIRENT_LINK;
}
isFIFO() {
return this.type === constants.UV_DIRENT_FIFO;
}
isSocket() {
return this.type === constants.UV_DIRENT_SOCKET;
}
isCharacterDevice() {
return this.type === constants.UV_DIRENT_CHAR;
}
isBlockDevice() {
return this.type === constants.UV_DIRENT_BLOCK;
}
};
var FileReadStream = class extends Readable {
constructor(path2, opts = {}) {
const { eagerOpen = true } = opts;
super({ eagerOpen, ...opts });
this.path = path2;
this.fd = typeof opts.fd === "number" ? opts.fd : -1;
this.flags = opts.flags || "r";
this.mode = opts.mode || 438;
this._offset = opts.start || 0;
this._missing = 0;
if (opts.length) {
this._missing = opts.length;
} else if (typeof opts.end === "number") {
this._missing = opts.end - this._offset + 1;
} else {
this._missing = -1;
}
}
async _open(cb) {
let err;
if (this.fd === -1) {
err = null;
try {
this.fd = await open(this.path, this.flags, this.mode);
} catch (e) {
err = e;
}
if (err) return cb(err);
}
let st;
err = null;
try {
st = await fstat(this.fd);
} catch (e) {
err = e;
}
if (err) return cb(err);
if (this._missing === -1) this._missing = st.size;
if (st.size < this._offset) {
this._offset = st.size;
this._missing = 0;
} else if (st.size < this._offset + this._missing) {
this._missing = st.size - this._offset;
}
cb(null);
}
async _read(size) {
if (this._missing <= 0) return this.push(null);
const data = Buffer.allocUnsafe(Math.min(this._missing, size));
let len;
let err = null;
try {
len = await read(this.fd, data, 0, data.byteLength, this._offset);
} catch (e) {
err = e;
}
if (err) return this.destroy(err);
if (len === 0) return this.push(null);
if (this._missing < len) len = this._missing;
this._missing -= len;
this._offset += len;
this.push(data.subarray(0, len));
}
async _destroy(err, cb) {
if (this.fd === -1) return cb(err);
try {
await close(this.fd);
} catch (e) {
err = err || e;
}
cb(err);
}
};
var FileWriteStream = class extends Writable {
constructor(path2, opts = {}) {
const { eagerOpen = true } = opts;
super({ eagerOpen, ...opts });
this.path = path2;
this.fd = typeof opts.fd === "number" ? opts.fd : -1;
this.flags = opts.flags || "w";
this.mode = opts.mode || 438;
}
async _open(cb) {
if (this.fd !== -1) return cb(null);
let err = null;
try {
this.fd = await open(this.path, this.flags, this.mode);
} catch (e) {
err = e;
}
cb(err);
}
async _writev(batch, cb) {
let err = null;
try {
await writev(
this.fd,
batch.map(({ chunk }) => chunk)
);
} catch (e) {
err = e;
}
cb(err);
}
async _destroy(err, cb) {
if (this.fd === -1) return cb(err);
try {
await close(this.fd);
} catch (e) {
err = err || e;
}
cb(err);
}
};
var Watcher = class extends EventEmitter {
constructor(path2, opts, onchange) {
if (typeof opts === "function") {
onchange = opts;
opts = {};
}
if (!opts) opts = {};
const { persistent = true, recursive = false, encoding = "utf8" } = opts;
super();
this._closed = false;
this._encoding = encoding;
this._handle = binding.watcherInit(path2, recursive, this, this._onevent, this._onclose);
if (!persistent) this.unref();
if (onchange) this.on("change", onchange);
}
close() {
if (this._closed) return;
this._closed = true;
binding.watcherClose(this._handle);
}
ref() {
if (this._handle) binding.watcherRef(this._handle);
return this;
}
unref() {
if (this._handle) binding.watcherUnref(this._handle);
return this;
}
[Symbol.asyncIterator]() {
const buffer = [];
let done2 = false;
let error = null;
let next = null;
this.on("change", (eventType, filename) => {
if (next) {
next.resolve({ done: false, value: { eventType, filename } });
next = null;
} else {
buffer.push({ eventType, filename });
}
}).on("error", (err) => {
done2 = true;
error = err;
if (next) {
next.reject(error);
next = null;
}
}).on("close", () => {
done2 = true;
if (next) {
next.resolve({ done: done2 });
next = null;
}
});
return {
next: () => new Promise((resolve, reject) => {
if (error) return reject(error);
if (buffer.length) return resolve({ done: false, value: buffer.shift() });
if (done2) return resolve({ done: done2 });
next = { resolve, reject };
})
};
}
_onevent(err, events, filename) {
if (err) {
this.close();
this.emit("error", err);
} else {
const path2 = this._encoding === "buffer" ? Buffer.from(filename) : Buffer.from(filename).toString(this._encoding);
if (events & binding.UV_RENAME) {
this.emit("change", "rename", path2);
}
if (events & binding.UV_CHANGE) {
this.emit("change", "change", path2);
}
}
}
_onclose() {
this._handle = null;
this.emit("close");
}
};
exports.access = access;
exports.appendFile = appendFile;
exports.chmod = chmod;
exports.close = close;
exports.copyFile = copyFile;
exports.cp = cp;
exports.exists = exists;
exports.fchmod = fchmod;
exports.fstat = fstat;
exports.ftruncate = ftruncate;
exports.lstat = lstat;
exports.mkdir = mkdir;
exports.open = open;
exports.opendir = opendir;
exports.read = read;
exports.readFile = readFile;
exports.readdir = readdir;
exports.readlink = readlink;
exports.readv = readv;
exports.realpath = realpath;
exports.rename = rename;
exports.rm = rm;
exports.rmdir = rmdir;
exports.stat = stat;
exports.symlink = symlink;
exports.unlink = unlink;
exports.utimes = utimes;
exports.watch = watch;
exports.write = write;
exports.writeFile = writeFile;
exports.writev = writev;
exports.accessSync = accessSync;
exports.appendFileSync = appendFileSync;
exports.chmodSync = chmodSync;
exports.closeSync = closeSync;
exports.copyFileSync = copyFileSync;
exports.cpSync = cpSync;
exports.existsSync = existsSync;
exports.fchmodSync = fchmodSync;
exports.fstatSync = fstatSync;
exports.ftruncateSync = ftruncateSync;
exports.lstatSync = lstatSync;
exports.mkdirSync = mkdirSync;
exports.openSync = openSync;
exports.opendirSync = opendirSync;
exports.readFileSync = readFileSync;
exports.readSync = readSync;
exports.readdirSync = readdirSync;
exports.readlinkSync = readlinkSync;
exports.readvSync = readvSync;
exports.realpathSync = realpathSync;
exports.renameSync = renameSync;
exports.rmSync = rmSync;
exports.rmdirSync = rmdirSync;
exports.statSync = statSync;
exports.symlinkSync = symlinkSync;
exports.unlinkSync = unlinkSync;
exports.utimesSync = utimesSync;
exports.writeFileSync = writeFileSync;
exports.writeSync = writeSync;
exports.writevSync = writevSync;
exports.promises = require_promises();
exports.Stats = Stats;
exports.Dir = Dir;
exports.Dirent = Dirent;
exports.Watcher = Watcher;
exports.ReadStream = FileReadStream;
exports.createReadStream = function createReadStream(path2, opts) {
return new FileReadStream(path2, opts);
};
exports.WriteStream = FileWriteStream;
exports.createWriteStream = function createWriteStream(path2, opts) {
return new FileWriteStream(path2, opts);
};
function toNamespacedPath(filepath) {
if (typeof filepath !== "string") {
if (isURL(filepath)) filepath = fileURLToPath(filepath);
else filepath = filepath.toString();
}
return path.toNamespacedPath(filepath);
}
function toFlags(flags) {
switch (flags) {
case "r":
return constants.O_RDONLY;
case "rs":
// Fall through.
case "sr":
return constants.O_RDONLY | constants.O_SYNC;
case "r+":
return constants.O_RDWR;
case "rs+":
// Fall through.
case "sr+":
return constants.O_RDWR | constants.O_SYNC;
case "w":
return constants.O_TRUNC | constants.O_CREAT | constants.O_WRONLY;
case "wx":
// Fall through.
case "xw":
return constants.O_TRUNC | constants.O_CREAT | constants.O_WRONLY | constants.O_EXCL;
case "w+":
return constants.O_TRUNC | constants.O_CREAT | constants.O_RDWR;
case "wx+":
// Fall through.
case "xw+":
return constants.O_TRUNC | constants.O_CREAT | constants.O_RDWR | constants.O_EXCL;
case "a":
return constants.O_APPEND | constants.O_CREAT | constants.O_WRONLY;
case "ax":
// Fall through.
case "xa":
return constants.O_APPEND | constants.O_CREAT | constants.O_WRONLY | constants.O_EXCL;
case "as":
// Fall through.
case "sa":
return constants.O_APPEND | constants.O_CREAT | constants.O_WRONLY | constants.O_SYNC;
case "a+":
return constants.O_APPEND | constants.O_CREAT | constants.O_RDWR;
case "ax+":
// Fall through.
case "xa+":
return constants.O_APPEND | constants.O_CREAT | constants.O_RDWR | constants.O_EXCL;
case "as+":
// Fall through.
case "sa+":
return constants.O_APPEND | constants.O_CREAT | constants.O_RDWR | constants.O_SYNC;
default:
return 0;
}
}
function toMode(mode) {
return parseInt(mode, 8);
}
}
});
// ../../node_modules/bare-tty/binding.js
var require_binding7 = __commonJS({
"../../node_modules/bare-tty/binding.js"(exports, module) {
module.exports = __require.addon();
}
});
// ../../node_modules/bare-tty/lib/constants.js
var require_constants4 = __commonJS({
"../../node_modules/bare-tty/lib/constants.js"(exports, module) {
var binding = require_binding7();
module.exports = exports = {
mode: {
NORMAL: binding.MODE_NORMAL,
RAW: binding.MODE_RAW,
IO: binding.MODE_IO || 0
},
state: {
READING: 1,
CLOSING: 2
}
};
exports.MODE_NORMAL = exports.mode.NORMAL;
exports.MODE_RAW = exports.mode.RAW;
exports.MODE_IO = exports.mode.IO;
}
});
// ../../node_modules/bare-tty/index.js
var require_bare_tty = __commonJS({
"../../node_modules/bare-tty/index.js"(exports) {
var { Readable, Writable } = require_bare_stream();
var Signal = require_bare_signals();
var binding = require_binding7();
var constants = require_constants4();
var defaultReadBufferSize = 65536;
var empty = Buffer.alloc(0);
exports.ReadStream = class TTYReadStream extends Readable {
constructor(fd, opts = {}) {
super();
const { readBufferSize = defaultReadBufferSize, allowHalfOpen = true } = opts;
this._fd = fd;
this._state = 0;
this._allowHalfOpen = allowHalfOpen;
this._buffer = Buffer.alloc(readBufferSize);
this._pendingDestroy = null;
this._handle = binding.init(fd, this._buffer, this, noop, this._onread, this._onclose);
}
get fd() {
return this._fd;
}
get isTTY() {
return true;
}
setMode(mode) {
binding.setMode(this._handle, mode);
return this;
}
setRawMode(enabled) {
return this.setMode(enabled ? constants.mode.RAW : constants.mode.NORMAL);
}
_read() {
if ((this._state & constants.state.READING) === 0) {
this._state |= constants.state.READING;
binding.resume(this._handle);
}
}
_predestroy() {
if (this._state & constants.state.CLOSING) return;
this._state |= constants.state.CLOSING;
binding.close(this._handle);
}
_destroy(err, cb) {
if (this._state & constants.state.CLOSING) return cb(err);
this._state |= constants.state.CLOSING;
this._pendingDestroy = cb;
binding.close(this._handle);
}
_continueDestroy() {
if (this._pendingDestroy === null) return;
const cb = this._pendingDestroy;
this._pendingDestroy = null;
cb(null);
}
_onread(err, read) {
if (err) {
this.destroy(err);
return;
}
if (read === 0) {
this.push(null);
if (this._allowHalfOpen === false) this.end();
return;
}
const copy = Buffer.allocUnsafe(read);
copy.set(this._buffer.subarray(0, read));
if (this.push(copy) === false && this.destroying === false) {
this._state &= ~constants.state.READING;
binding.pause(this._handle);
}
}
_onclose() {
this._handle = null;
this._continueDestroy();
}
};
exports.WriteStream = class TTYWriteStream extends Writable {
constructor(fd, opts = {}) {
super();
this._fd = fd;
this._state = 0;
this._size = null;
this._pendingWrite = null;
this._pendingDestroy = null;
this._handle = binding.init(fd, empty, this, this._onwrite, noop, this._onclose);
this._size = this.getWindowSize();
if (TTYWriteStream._streams.size === 0) TTYWriteStream._resize.start();
TTYWriteStream._streams.add(this);
}
get fd() {
return this._fd;
}
get isTTY() {
return true;
}
get columns() {
return this._size[0];
}
get rows() {
return this._size[1];
}
getWindowSize() {
return binding.getWindowSize(this._handle);
}
_writev(batch, cb) {
this._pendingWrite = [cb, batch];
binding.writev(
this._handle,
batch.map(({ chunk }) => chunk)
);
}
_predestroy() {
if (this._state & constants.state.CLOSING) return;
this._state |= constants.state.CLOSING;
binding.close(this._handle);
TTYWriteStream._streams.delete(this);
if (TTYWriteStream._streams.size === 0) TTYWriteStream._resize.stop();
}
_destroy(err, cb) {
if (this._state & constants.state.CLOSING) return cb(err);
this._state |= constants.state.CLOSING;
this._pendingDestroy = cb;
binding.close(this._handle);
TTYWriteStream._streams.delete(this);
if (TTYWriteStream._streams.size === 0) TTYWriteStream._resize.stop();
}
_continueWrite(err) {
if (this._pendingWrite === null) return;
const cb = this._pendingWrite[0];
this._pendingWrite = null;
cb(err);
}
_continueDestroy() {
if (this._pendingDestroy === null) return;
const cb = this._pendingDestroy;
this._pendingDestroy = null;
cb(null);
}
_onwrite(err) {
this._continueWrite(err);
}
_onclose() {
this._handle = null;
this._continueDestroy();
}
_onresize() {
this._size = this.getWindowSize();
this.emit("resize");
}
static _streams = /* @__PURE__ */ new Set();
static _resize = new Signal("SIGWINCH");
};
exports.constants = constants;
exports.isTTY = binding.isTTY;
exports.isatty = exports.isTTY;
exports.WriteStream._resize.on("signal", () => {
for (const stream of exports.WriteStream._streams) {
stream._onresize();
}
}).unref();
function noop() {
}
}
});
// ../../node_modules/bare-pipe/binding.js
var require_binding8 = __commonJS({
"../../node_modules/bare-pipe/binding.js"(exports, module) {
module.exports = __require.addon();
}
});
// ../../node_modules/bare-pipe/lib/constants.js
var require_constants5 = __commonJS({
"../../node_modules/bare-pipe/lib/constants.js"(exports, module) {
module.exports = {
state: {
CONNECTING: 1,
CONNECTED: 2,
BINDING: 4,
BOUND: 8,
READING: 16,
CLOSING: 32,
READABLE: 64,
WRITABLE: 128,
UNREFED: 256
}
};
}
});
// ../../node_modules/bare-pipe/lib/errors.js
var require_errors6 = __commonJS({
"../../node_modules/bare-pipe/lib/errors.js"(exports, module) {
module.exports = class PipeError extends Error {
constructor(msg, fn = PipeError, code = fn.name) {
super(`${code}: ${msg}`);
this.code = code;
if (Error.captureStackTrace) {
Error.captureStackTrace(this, fn);
}
}
get name() {
return "PipeError";
}
static PIPE_ALREADY_CONNECTED(msg) {
return new PipeError(msg, PipeError.PIPE_ALREADY_CONNECTED);
}
static SERVER_ALREADY_LISTENING(msg) {
return new PipeError(msg, PipeError.SERVER_ALREADY_LISTENING);
}
static SERVER_IS_CLOSED(msg) {
return new PipeError(msg, PipeError.SERVER_IS_CLOSED);
}
};
}
});
// ../../node_modules/bare-pipe/index.js
var require_bare_pipe = __commonJS({
"../../node_modules/bare-pipe/index.js"(exports, module) {
var EventEmitter = require_bare_events();
var { Duplex } = require_bare_stream();
var binding = require_binding8();
var constants = require_constants5();
var errors = require_errors6();
var defaultReadBufferSize = 65536;
var empty = Buffer.alloc(0);
module.exports = exports = class Pipe extends Duplex {
constructor(path, opts = {}) {
if (typeof path === "object" && path !== null) {
opts = path;
path = null;
}
const { readBufferSize = defaultReadBufferSize, allowHalfOpen = true, eagerOpen = true } = opts;
super({ eagerOpen });
this._state = 0;
this._allowHalfOpen = allowHalfOpen;
this._fd = -1;
this._path = null;
this._pendingOpen = null;
this._pendingWrite = null;
this._pendingFinal = null;
this._pendingDestroy = null;
this._buffer = Buffer.alloc(readBufferSize);
this._handle = binding.init(
this._buffer,
this,
noop,
this._onconnect,
this._onwrite,
this._onfinal,
this._onread,
this._onclose
);
if (typeof path === "number") {
this.open(path);
} else if (typeof path === "string") {
this.connect(path);
}
}
get connecting() {
return (this._state & constants.state.CONNECTING) !== 0;
}
get pending() {
return (this._state & constants.state.CONNECTED) === 0;
}
get readyState() {
if (this._state & constants.state.READABLE && this._state & constants.state.WRITABLE) {
return "open";
}
if (this._state & constants.state.READABLE) {
return "readOnly";
}
if (this._state & constants.state.WRITABLE) {
return "writeOnly";
}
return "opening";
}
open(fd, opts = {}, onconnect) {
if (typeof opts === "function") {
onconnect = opts;
opts = {};
}
if (typeof fd === "object" && fd !== null) {
opts = fd || {};
fd = opts.fd;
}
try {
const status = binding.open(this._handle, fd);
this._state |= constants.state.CONNECTED;
this._fd = fd;
if (status & binding.READABLE) {
this._state |= constants.state.READABLE;
} else {
this.push(null);
}
if (status & binding.WRITABLE) {
this._state |= constants.state.WRITABLE;
} else {
this.end();
}
if (onconnect) this.once("connect", onconnect);
queueMicrotask(() => this.emit("connect"));
} catch (err) {
queueMicrotask(() => {
if (this._pendingOpen) this._pendingOpen(err);
else this.destroy(err);
});
}
return this;
}
connect(path, opts = {}, onconnect) {
if (this._state & constants.state.CONNECTING || this._state & constants.state.CONNECTED) {
throw errors.PIPE_ALREADY_CONNECTED("Pipe is already connected");
}
this._state |= constants.state.CONNECTING;
if (typeof opts === "function") {
onconnect = opts;
opts = {};
}
if (typeof path === "object" && path !== null) {
opts = path || {};
path = opts.path;
}
try {
binding.connect(this._handle, path);
this._path = path;
if (onconnect) this.once("connect", onconnect);
} catch (err) {
queueMicrotask(() => {
if (this._pendingOpen) this._pendingOpen(err);
else this.destroy(err);
});
}
return this;
}
ref() {
binding.ref(this._handle);
return this;
}
unref() {
binding.unref(this._handle);
return this;
}
_open(cb) {
if (this._state & constants.state.CONNECTED) return cb(null);
this._pendingOpen = cb;
}
_read() {
if ((this._state & constants.state.READING) === 0) {
this._state |= constants.state.READING;
binding.resume(this._handle);
}
}
_writev(batch, cb) {
this._pendingWrite = [cb, batch];
binding.writev(
this._handle,
batch.map(({ chunk }) => chunk)
);
}
_final(cb) {
if (this._state & constants.state.READABLE && this._state & constants.state.WRITABLE) {
this._pendingFinal = cb;
binding.end(this._handle);
} else {
cb(null);
}
}
_predestroy() {
if (this._state & constants.state.CLOSING) return;
this._state |= constants.state.CLOSING;
binding.close(this._handle);
}
_destroy(err, cb) {
if (this._state & constants.state.CLOSING) return cb(err);
this._state |= constants.state.CLOSING;
this._pendingDestroy = cb;
binding.close(this._handle);
}
_continueOpen(err) {
if (this._pendingOpen === null) return;
const cb = this._pendingOpen;
this._pendingOpen = null;
cb(err);
}
_continueWrite(err) {
if (this._pendingWrite === null) return;
const cb = this._pendingWrite[0];
this._pendingWrite = null;
cb(err);
}
_continueFinal(err) {
if (this._pendingFinal === null) return;
const cb = this._pendingFinal;
this._pendingFinal = null;
cb(err);
}
_continueDestroy() {
if (this._pendingDestroy === null) return;
const cb = this._pendingDestroy;
this._pendingDestroy = null;
cb(null);
}
_onconnect(err) {
if (err) {
if (this._pendingOpen) this._continueOpen(err);
else this.destroy(err);
return;
}
this._state |= constants.state.CONNECTED | constants.state.READABLE | constants.state.WRITABLE;
this._state &= ~constants.state.CONNECTING;
this._continueOpen();
this.emit("connect");
}
_onread(err, read) {
if (err) {
this.destroy(err);
return;
}
if (read === 0) {
this.push(null);
if (this._allowHalfOpen === false) this.end();
return;
}
const copy = Buffer.allocUnsafe(read);
copy.set(this._buffer.subarray(0, read));
if (this.push(copy) === false && this.destroying === false) {
this._state &= ~constants.state.READING;
binding.pause(this._handle);
}
}
_onwrite(err) {
this._continueWrite(err);
}
_onfinal(err) {
this._continueFinal(err === null || err.code === "ENOTCONN" ? null : err);
}
_onclose() {
this._continueDestroy();
}
_onspawn(readable, writable) {
this._state |= constants.state.CONNECTED;
if (readable) {
this._state |= constants.state.READABLE;
} else {
this.push(null);
}
if (writable) {
this._state |= constants.state.WRITABLE;
} else {
this.end();
}
this._continueOpen();
}
};
exports.Pipe = exports;
exports.pipe = function pipe() {
return binding.pipe();
};
exports.Server = class PipeServer extends EventEmitter {
constructor(opts = {}, onconnection) {
if (typeof opts === "function") {
onconnection = opts;
opts = {};
}
super();
const {
readBufferSize = defaultReadBufferSize,
allowHalfOpen = true,
pauseOnConnect = false
} = opts;
this._state = 0;
this._readBufferSize = readBufferSize;
this._allowHalfOpen = allowHalfOpen;
this._pauseOnConnect = pauseOnConnect;
this._path = null;
this._connections = /* @__PURE__ */ new Set();
this._error = null;
this._handle = null;
if (onconnection) this.on("connection", onconnection);
}
get listening() {
return (this._state & constants.state.BOUND) !== 0;
}
address() {
if ((this._state & constants.state.BOUND) === 0) {
return null;
}
return this._path;
}
listen(path, backlog = 511, opts = {}, onlistening) {
if (this._state & constants.state.BINDING || this._state & constants.state.BOUND) {
throw errors.SERVER_ALREADY_LISTENING("Server is already listening");
}
if (this._state & constants.state.CLOSING) {
throw errors.SERVER_IS_CLOSED("Server is closed");
}
this._state |= constants.state.BINDING;
if (typeof backlog === "function") {
onlistening = backlog;
backlog = 511;
} else if (typeof opts === "function") {
onlistening = opts;
opts = {};
}
if (typeof path === "object" && path !== null) {
opts = path || {};
path = opts.path;
backlog = opts.backlog || 511;
}
this._handle = binding.init(
empty,
this,
this._onconnection,
noop,
noop,
noop,
noop,
this._onclose
);
if (this._state & constants.state.UNREFED) binding.unref(this._handle);
try {
binding.bind(this._handle, path, backlog);
this._path = path;
this._state |= constants.state.BOUND;
this._state &= ~constants.state.BINDING;
if (onlistening) this.once("listening", onlistening);
queueMicrotask(() => this.emit("listening"));
} catch (err) {
this._error = err;
binding.close(this._handle);
}
return this;
}
close(onclose) {
if (onclose) this.once("close", onclose);
if (this._state & constants.state.CLOSING) return;
this._state |= constants.state.CLOSING;
this._closeMaybe();
return this;
}
ref() {
this._state &= ~constants.state.UNREFED;
if (this._handle !== null) binding.ref(this._handle);
return this;
}
unref() {
this._state |= constants.state.UNREFED;
if (this._handle !== null) binding.unref(this._handle);
return this;
}
_closeMaybe() {
if (this._state & constants.state.CLOSING && this._connections.size === 0) {
if (this._handle !== null) binding.close(this._handle);
else queueMicrotask(() => this.emit("close"));
}
}
_onconnection(err) {
if (err) {
this.emit("error", err);
return;
}
if (this._state & constants.state.CLOSING) return;
const pipe = new exports.Pipe({
readBufferSize: this._readBufferSize,
allowHalfOpen: this._allowHalfOpen,
eagerOpen: !this._pauseOnConnect
});
try {
binding.accept(this._handle, pipe._handle);
pipe._path = this._path;
pipe._state |= constants.state.CONNECTED | constants.state.READABLE | constants.state.WRITABLE;
this._connections.add(pipe);
pipe.on("close", () => {
this._connections.delete(pipe);
this._closeMaybe();
});
this.emit("connection", pipe);
} catch (err2) {
pipe.destroy();
throw err2;
}
}
_onclose() {
const err = this._error;
this._state &= ~constants.state.BINDING;
this._error = null;
this._handle = null;
if (err) this.emit("error", err);
else this.emit("close");
}
};
exports.constants = constants;
exports.errors = errors;
exports.createConnection = function createConnection(path, opts, onconnect) {
if (typeof opts === "function") {
onconnect = opts;
opts = {};
}
if (typeof path === "object" && path !== null) {
opts = path || {};
path = opts.path;
}
return new exports.Pipe(opts).connect(path, opts, onconnect);
};
exports.createServer = function createServer(opts, onconnection) {
return new exports.Server(opts, onconnection);
};
function noop() {
}
}
});
// ../../node_modules/bare-stdio/binding.js
var require_binding9 = __commonJS({
"../../node_modules/bare-stdio/binding.js"(exports, module) {
module.exports = __require.addon();
}
});
// ../../node_modules/bare-stdio/index.js
var require_bare_stdio = __commonJS({
"../../node_modules/bare-stdio/index.js"(exports, module) {
var fs = require_bare_fs();
var tty = require_bare_tty();
var Pipe = require_bare_pipe();
var binding = require_binding9();
var { TTY, NAMED_PIPE } = binding;
var IO = class {
constructor() {
this._in = null;
this._out = null;
this._err = null;
}
get in() {
if (this._in === null) {
switch (binding.guessType(0)) {
case TTY:
this._in = new tty.ReadStream(0);
break;
case NAMED_PIPE:
this._in = new Pipe(0, { eagerOpen: false });
break;
default:
this._in = fs.createReadStream(null, { fd: 0, eagerOpen: false });
}
}
return this._in;
}
get out() {
if (this._out === null) {
switch (binding.guessType(1)) {
case TTY:
this._out = new tty.WriteStream(1);
break;
case NAMED_PIPE:
this._out = new Pipe(1, { eagerOpen: false });
this._out.unref();
break;
default:
this._out = fs.createWriteStream(null, { fd: 1, eagerOpen: false });
}
}
return this._out;
}
get err() {
if (this._err === null) {
switch (binding.guessType(2)) {
case TTY:
this._err = new tty.WriteStream(2);
break;
case NAMED_PIPE:
this._err = new Pipe(2, { eagerOpen: false });
this._err.unref();
break;
default:
this._err = fs.createWriteStream(null, { fd: 2, eagerOpen: false });
}
}
return this._err;
}
};
module.exports = new IO();
}
});
// ../../node_modules/bare-process/index.js
var require_bare_process = __commonJS({
"../../node_modules/bare-process/index.js"(exports, module) {
var abort = require_bare_abort();
var EventEmitter = require_bare_events();
var Signal = require_bare_signals();
var os = require_bare_os();
var env = require_bare_env();
var hrtime = require_bare_hrtime();
var stdio = require_bare_stdio();
var Process = class _Process extends EventEmitter {
constructor() {
super();
this._startTime = hrtime.bigint();
EventEmitter.forward(Bare, this, [
"uncaughtException",
"unhandledRejection",
"beforeExit",
"exit",
"suspend",
"wakeup",
"idle",
"resume"
]);
const signals = new Signal.Emitter();
signals.unref();
EventEmitter.forward(signals, this, Object.keys(os.constants.signals));
}
get stdin() {
return stdio.in;
}
get stdout() {
return stdio.out;
}
get stderr() {
return stdio.err;
}
get platform() {
return os.platform();
}
get arch() {
return os.arch();
}
get title() {
return os.getProcessTitle();
}
set title(title) {
os.setProcessTitle(title);
}
get pid() {
return os.pid();
}
get ppid() {
return os.ppid();
}
get argv() {
return Bare.argv;
}
get execPath() {
return os.execPath();
}
get exitCode() {
return Bare.exitCode;
}
set exitCode(code) {
Bare.exitCode = code;
}
get version() {
return Bare.version;
}
get versions() {
return Bare.versions;
}
get env() {
return env;
}
get hrtime() {
return hrtime;
}
abort() {
abort();
}
exit(code) {
Bare.exit(code);
}
suspend() {
Bare.suspend();
}
resume() {
Bare.resume();
}
cwd() {
return os.cwd();
}
chdir(directory) {
os.chdir(directory);
}
kill(pid, signal) {
os.kill(pid, signal);
}
uptime() {
return Number(hrtime.bigint() - this._startTime) / 1e9;
}
cpuUsage(previous) {
return os.cpuUsage(previous);
}
threadCpuUsage(previous) {
return os.threadCpuUsage(previous);
}
resourceUsage() {
return os.resourceUsage();
}
availableMemory() {
return os.availableMemory();
}
constrainedMemory() {
return os.constrainedMemory();
}
memoryUsage() {
return os.memoryUsage();
}
nextTick(cb, ...args) {
queueMicrotask(cb.bind(null, ...args));
}
[Symbol.for("bare.inspect")]() {
return {
__proto__: { constructor: _Process },
platform: this.platform,
arch: this.arch,
title: this.title,
pid: this.pid,
ppid: this.ppid,
argv: this.argv,
execPath: this.execPath,
exitCode: this.exitCode,
version: this.version,
versions: this.versions,
env: this.env
};
}
};
module.exports = new Process();
}
});
// ../../node_modules/convert-source-map/index.js
var require_convert_source_map = __commonJS({
"../../node_modules/convert-source-map/index.js"(exports) {
"use strict";
Object.defineProperty(exports, "commentRegex", {
get: function getCommentRegex() {
return /^\s*?\/[\/\*][@#]\s+?sourceMappingURL=data:(((?:application|text)\/json)(?:;charset=([^;,]+?)?)?)?(?:;(base64))?,(.*?)$/mg;
}
});
Object.defineProperty(exports, "mapFileCommentRegex", {
get: function getMapFileCommentRegex() {
return /(?:\/\/[@#][ \t]+?sourceMappingURL=([^\s'"`]+?)[ \t]*?$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^*]+?)[ \t]*?(?:\*\/){1}[ \t]*?$)/mg;
}
});
var decodeBase64;
if (typeof Buffer !== "undefined") {
if (typeof Buffer.from === "function") {
decodeBase64 = decodeBase64WithBufferFrom;
} else {
decodeBase64 = decodeBase64WithNewBuffer;
}
} else {
decodeBase64 = decodeBase64WithAtob;
}
function decodeBase64WithBufferFrom(base64) {
return Buffer.from(base64, "base64").toString();
}
function decodeBase64WithNewBuffer(base64) {
if (typeof value === "number") {
throw new TypeError("The value to decode must not be of type number.");
}
return new Buffer(base64, "base64").toString();
}
function decodeBase64WithAtob(base64) {
return decodeURIComponent(escape(atob(base64)));
}
function stripComment(sm) {
return sm.split(",").pop();
}
function readFromFileMap(sm, read) {
var r = exports.mapFileCommentRegex.exec(sm);
var filename = r[1] || r[2];
try {
var sm = read(filename);
if (sm != null && typeof sm.catch === "function") {
return sm.catch(throwError);
} else {
return sm;
}
} catch (e) {
throwError(e);
}
function throwError(e) {
throw new Error("An error occurred while trying to read the map file at " + filename + "\n" + e.stack);
}
}
function Converter(sm, opts) {
opts = opts || {};
if (opts.hasComment) {
sm = stripComment(sm);
}
if (opts.encoding === "base64") {
sm = decodeBase64(sm);
} else if (opts.encoding === "uri") {
sm = decodeURIComponent(sm);
}
if (opts.isJSON || opts.encoding) {
sm = JSON.parse(sm);
}
this.sourcemap = sm;
}
Converter.prototype.toJSON = function(space) {
return JSON.stringify(this.sourcemap, null, space);
};
if (typeof Buffer !== "undefined") {
if (typeof Buffer.from === "function") {
Converter.prototype.toBase64 = encodeBase64WithBufferFrom;
} else {
Converter.prototype.toBase64 = encodeBase64WithNewBuffer;
}
} else {
Converter.prototype.toBase64 = encodeBase64WithBtoa;
}
function encodeBase64WithBufferFrom() {
var json = this.toJSON();
return Buffer.from(json, "utf8").toString("base64");
}
function encodeBase64WithNewBuffer() {
var json = this.toJSON();
if (typeof json === "number") {
throw new TypeError("The json to encode must not be of type number.");
}
return new Buffer(json, "utf8").toString("base64");
}
function encodeBase64WithBtoa() {
var json = this.toJSON();
return btoa(unescape(encodeURIComponent(json)));
}
Converter.prototype.toURI = function() {
var json = this.toJSON();
return encodeURIComponent(json);
};
Converter.prototype.toComment = function(options) {
var encoding, content, data;
if (options != null && options.encoding === "uri") {
encoding = "";
content = this.toURI();
} else {
encoding = ";base64";
content = this.toBase64();
}
data = "sourceMappingURL=data:application/json;charset=utf-8" + encoding + "," + content;
return options != null && options.multiline ? "/*# " + data + " */" : "//# " + data;
};
Converter.prototype.toObject = function() {
return JSON.parse(this.toJSON());
};
Converter.prototype.addProperty = function(key, value2) {
if (this.sourcemap.hasOwnProperty(key)) throw new Error('property "' + key + '" already exists on the sourcemap, use set property instead');
return this.setProperty(key, value2);
};
Converter.prototype.setProperty = function(key, value2) {
this.sourcemap[key] = value2;
return this;
};
Converter.prototype.getProperty = function(key) {
return this.sourcemap[key];
};
exports.fromObject = function(obj) {
return new Converter(obj);
};
exports.fromJSON = function(json) {
return new Converter(json, { isJSON: true });
};
exports.fromURI = function(uri) {
return new Converter(uri, { encoding: "uri" });
};
exports.fromBase64 = function(base64) {
return new Converter(base64, { encoding: "base64" });
};
exports.fromComment = function(comment) {
var m, encoding;
comment = comment.replace(/^\/\*/g, "//").replace(/\*\/$/g, "");
m = exports.commentRegex.exec(comment);
encoding = m && m[4] || "uri";
return new Converter(comment, { encoding, hasComment: true });
};
function makeConverter(sm) {
return new Converter(sm, { isJSON: true });
}
exports.fromMapFileComment = function(comment, read) {
if (typeof read === "string") {
throw new Error(
"String directory paths are no longer supported with `fromMapFileComment`\nPlease review the Upgrading documentation at https://github.com/thlorenz/convert-source-map#upgrading"
);
}
var sm = readFromFileMap(comment, read);
if (sm != null && typeof sm.then === "function") {
return sm.then(makeConverter);
} else {
return makeConverter(sm);
}
};
exports.fromSource = function(content) {
var m = content.match(exports.commentRegex);
return m ? exports.fromComment(m.pop()) : null;
};
exports.fromMapFileSource = function(content, read) {
if (typeof read === "string") {
throw new Error(
"String directory paths are no longer supported with `fromMapFileSource`\nPlease review the Upgrading documentation at https://github.com/thlorenz/convert-source-map#upgrading"
);
}
var m = content.match(exports.mapFileCommentRegex);
return m ? exports.fromMapFileComment(m.pop(), read) : null;
};
exports.removeComments = function(src) {
return src.replace(exports.commentRegex, "");
};
exports.removeMapFileComments = function(src) {
return src.replace(exports.mapFileCommentRegex, "");
};
exports.generateMapFileComment = function(file, options) {
var data = "sourceMappingURL=" + file;
return options && options.multiline ? "/*# " + data + " */" : "//# " + data;
};
}
});
// ../../node_modules/v8-to-istanbul/lib/branch.js
var require_branch = __commonJS({
"../../node_modules/v8-to-istanbul/lib/branch.js"(exports, module) {
module.exports = class CovBranch {
constructor(startLine, startCol, endLine, endCol, count) {
this.startLine = startLine;
this.startCol = startCol;
this.endLine = endLine;
this.endCol = endCol;
this.count = count;
}
toIstanbul() {
const location = {
start: {
line: this.startLine,
column: this.startCol
},
end: {
line: this.endLine,
column: this.endCol
}
};
return {
type: "branch",
line: this.startLine,
loc: location,
locations: [Object.assign({}, location)]
};
}
};
}
});
// ../../node_modules/v8-to-istanbul/lib/function.js
var require_function = __commonJS({
"../../node_modules/v8-to-istanbul/lib/function.js"(exports, module) {
module.exports = class CovFunction {
constructor(name, startLine, startCol, endLine, endCol, count) {
this.name = name;
this.startLine = startLine;
this.startCol = startCol;
this.endLine = endLine;
this.endCol = endCol;
this.count = count;
}
toIstanbul() {
const loc = {
start: {
line: this.startLine,
column: this.startCol
},
end: {
line: this.endLine,
column: this.endCol
}
};
return {
name: this.name,
decl: loc,
loc,
line: this.startLine
};
}
};
}
});
// ../../node_modules/v8-to-istanbul/lib/line.js
var require_line = __commonJS({
"../../node_modules/v8-to-istanbul/lib/line.js"(exports, module) {
module.exports = class CovLine {
constructor(line, startCol, lineStr) {
this.line = line;
this.startCol = startCol;
const matchedNewLineChar = lineStr.match(/\r?\n$/u);
const newLineLength = matchedNewLineChar ? matchedNewLineChar[0].length : 0;
this.endCol = startCol + lineStr.length - newLineLength;
this.count = 1;
this.ignore = false;
}
toIstanbul() {
return {
start: {
line: this.line,
column: 0
},
end: {
line: this.line,
column: this.endCol - this.startCol
}
};
}
};
}
});
// ../../node_modules/v8-to-istanbul/lib/range.js
var require_range = __commonJS({
"../../node_modules/v8-to-istanbul/lib/range.js"(exports, module) {
module.exports.sliceRange = (lines, startCol, endCol, inclusive = false) => {
let start = 0;
let end = lines.length;
if (inclusive) {
--startCol;
}
while (start < end) {
let mid = start + end >> 1;
if (startCol >= lines[mid].endCol) {
start = mid + 1;
} else if (endCol < lines[mid].startCol) {
end = mid - 1;
} else {
end = mid;
while (mid >= 0 && startCol < lines[mid].endCol && endCol >= lines[mid].startCol) {
--mid;
}
start = mid + 1;
break;
}
}
while (end < lines.length && startCol < lines[end].endCol && endCol >= lines[end].startCol) {
++end;
}
return lines.slice(start, end);
};
}
});
// ../../node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js
var require_resolve_uri_umd = __commonJS({
"../../node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js"(exports, module) {
(function(global2, factory) {
typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, global2.resolveURI = factory());
})(exports, (function() {
"use strict";
const schemeRegex = /^[\w+.-]+:\/\//;
const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/;
const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;
function isAbsoluteUrl(input) {
return schemeRegex.test(input);
}
function isSchemeRelativeUrl(input) {
return input.startsWith("//");
}
function isAbsolutePath(input) {
return input.startsWith("/");
}
function isFileUrl(input) {
return input.startsWith("file:");
}
function isRelative(input) {
return /^[.?#]/.test(input);
}
function parseAbsoluteUrl(input) {
const match = urlRegex.exec(input);
return makeUrl(match[1], match[2] || "", match[3], match[4] || "", match[5] || "/", match[6] || "", match[7] || "");
}
function parseFileUrl(input) {
const match = fileRegex.exec(input);
const path = match[2];
return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path) ? path : "/" + path, match[3] || "", match[4] || "");
}
function makeUrl(scheme, user, host, port, path, query, hash) {
return {
scheme,
user,
host,
port,
path,
query,
hash,
type: 7
};
}
function parseUrl(input) {
if (isSchemeRelativeUrl(input)) {
const url2 = parseAbsoluteUrl("http:" + input);
url2.scheme = "";
url2.type = 6;
return url2;
}
if (isAbsolutePath(input)) {
const url2 = parseAbsoluteUrl("http://foo.com" + input);
url2.scheme = "";
url2.host = "";
url2.type = 5;
return url2;
}
if (isFileUrl(input))
return parseFileUrl(input);
if (isAbsoluteUrl(input))
return parseAbsoluteUrl(input);
const url = parseAbsoluteUrl("http://foo.com/" + input);
url.scheme = "";
url.host = "";
url.type = input ? input.startsWith("?") ? 3 : input.startsWith("#") ? 2 : 4 : 1;
return url;
}
function stripPathFilename(path) {
if (path.endsWith("/.."))
return path;
const index = path.lastIndexOf("/");
return path.slice(0, index + 1);
}
function mergePaths(url, base) {
normalizePath(base, base.type);
if (url.path === "/") {
url.path = base.path;
} else {
url.path = stripPathFilename(base.path) + url.path;
}
}
function normalizePath(url, type) {
const rel = type <= 4;
const pieces = url.path.split("/");
let pointer = 1;
let positive = 0;
let addTrailingSlash = false;
for (let i = 1; i < pieces.length; i++) {
const piece = pieces[i];
if (!piece) {
addTrailingSlash = true;
continue;
}
addTrailingSlash = false;
if (piece === ".")
continue;
if (piece === "..") {
if (positive) {
addTrailingSlash = true;
positive--;
pointer--;
} else if (rel) {
pieces[pointer++] = piece;
}
continue;
}
pieces[pointer++] = piece;
positive++;
}
let path = "";
for (let i = 1; i < pointer; i++) {
path += "/" + pieces[i];
}
if (!path || addTrailingSlash && !path.endsWith("/..")) {
path += "/";
}
url.path = path;
}
function resolve(input, base) {
if (!input && !base)
return "";
const url = parseUrl(input);
let inputType = url.type;
if (base && inputType !== 7) {
const baseUrl = parseUrl(base);
const baseType = baseUrl.type;
switch (inputType) {
case 1:
url.hash = baseUrl.hash;
// fall through
case 2:
url.query = baseUrl.query;
// fall through
case 3:
case 4:
mergePaths(url, baseUrl);
// fall through
case 5:
url.user = baseUrl.user;
url.host = baseUrl.host;
url.port = baseUrl.port;
// fall through
case 6:
url.scheme = baseUrl.scheme;
}
if (baseType > inputType)
inputType = baseType;
}
normalizePath(url, inputType);
const queryHash = url.query + url.hash;
switch (inputType) {
// This is impossible, because of the empty checks at the start of the function.
// case UrlType.Empty:
case 2:
case 3:
return queryHash;
case 4: {
const path = url.path.slice(1);
if (!path)
return queryHash || ".";
if (isRelative(base || input) && !isRelative(path)) {
return "./" + path + queryHash;
}
return path + queryHash;
}
case 5:
return url.path + queryHash;
default:
return url.scheme + "//" + url.user + url.host + url.port + url.path + queryHash;
}
}
return resolve;
}));
}
});
// ../../node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js
var require_sourcemap_codec_umd = __commonJS({
"../../node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js"(exports, module) {
(function(global2, factory) {
if (typeof exports === "object" && typeof module !== "undefined") {
factory(module);
module.exports = def(module);
} else if (typeof define === "function" && define.amd) {
define(["module"], function(mod) {
factory.apply(this, arguments);
mod.exports = def(mod);
});
} else {
const mod = { exports: {} };
factory(mod);
global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self;
global2.sourcemapCodec = def(mod);
}
function def(m) {
return "default" in m.exports ? m.exports.default : m.exports;
}
})(exports, (function(module2) {
"use strict";
var __defProp2 = Object.defineProperty;
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
var __getOwnPropNames2 = Object.getOwnPropertyNames;
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
var __export2 = (target, all) => {
for (var name in all)
__defProp2(target, name, { get: all[name], enumerable: true });
};
var __copyProps2 = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames2(from))
if (!__hasOwnProp2.call(to, key) && key !== except)
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
var sourcemap_codec_exports = {};
__export2(sourcemap_codec_exports, {
decode: () => decode,
decodeGeneratedRanges: () => decodeGeneratedRanges,
decodeOriginalScopes: () => decodeOriginalScopes,
encode: () => encode,
encodeGeneratedRanges: () => encodeGeneratedRanges,
encodeOriginalScopes: () => encodeOriginalScopes
});
module2.exports = __toCommonJS2(sourcemap_codec_exports);
var comma = ",".charCodeAt(0);
var semicolon = ";".charCodeAt(0);
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var intToChar = new Uint8Array(64);
var charToInt = new Uint8Array(128);
for (let i = 0; i < chars.length; i++) {
const c = chars.charCodeAt(i);
intToChar[i] = c;
charToInt[c] = i;
}
function decodeInteger(reader, relative) {
let value2 = 0;
let shift = 0;
let integer = 0;
do {
const c = reader.next();
integer = charToInt[c];
value2 |= (integer & 31) << shift;
shift += 5;
} while (integer & 32);
const shouldNegate = value2 & 1;
value2 >>>= 1;
if (shouldNegate) {
value2 = -2147483648 | -value2;
}
return relative + value2;
}
function encodeInteger(builder, num, relative) {
let delta = num - relative;
delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
do {
let clamped = delta & 31;
delta >>>= 5;
if (delta > 0) clamped |= 32;
builder.write(intToChar[clamped]);
} while (delta > 0);
return num;
}
function hasMoreVlq(reader, max) {
if (reader.pos >= max) return false;
return reader.peek() !== comma;
}
var bufLength = 1024 * 16;
var td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? {
decode(buf) {
const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
return out.toString();
}
} : {
decode(buf) {
let out = "";
for (let i = 0; i < buf.length; i++) {
out += String.fromCharCode(buf[i]);
}
return out;
}
};
var StringWriter = class {
constructor() {
this.pos = 0;
this.out = "";
this.buffer = new Uint8Array(bufLength);
}
write(v) {
const { buffer } = this;
buffer[this.pos++] = v;
if (this.pos === bufLength) {
this.out += td.decode(buffer);
this.pos = 0;
}
}
flush() {
const { buffer, out, pos } = this;
return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
}
};
var StringReader = class {
constructor(buffer) {
this.pos = 0;
this.buffer = buffer;
}
next() {
return this.buffer.charCodeAt(this.pos++);
}
peek() {
return this.buffer.charCodeAt(this.pos);
}
indexOf(char) {
const { buffer, pos } = this;
const idx = buffer.indexOf(char, pos);
return idx === -1 ? buffer.length : idx;
}
};
var EMPTY = [];
function decodeOriginalScopes(input) {
const { length } = input;
const reader = new StringReader(input);
const scopes = [];
const stack = [];
let line = 0;
for (; reader.pos < length; reader.pos++) {
line = decodeInteger(reader, line);
const column = decodeInteger(reader, 0);
if (!hasMoreVlq(reader, length)) {
const last = stack.pop();
last[2] = line;
last[3] = column;
continue;
}
const kind = decodeInteger(reader, 0);
const fields = decodeInteger(reader, 0);
const hasName = fields & 1;
const scope = hasName ? [line, column, 0, 0, kind, decodeInteger(reader, 0)] : [line, column, 0, 0, kind];
let vars = EMPTY;
if (hasMoreVlq(reader, length)) {
vars = [];
do {
const varsIndex = decodeInteger(reader, 0);
vars.push(varsIndex);
} while (hasMoreVlq(reader, length));
}
scope.vars = vars;
scopes.push(scope);
stack.push(scope);
}
return scopes;
}
function encodeOriginalScopes(scopes) {
const writer = new StringWriter();
for (let i = 0; i < scopes.length; ) {
i = _encodeOriginalScopes(scopes, i, writer, [0]);
}
return writer.flush();
}
function _encodeOriginalScopes(scopes, index, writer, state) {
const scope = scopes[index];
const { 0: startLine, 1: startColumn, 2: endLine, 3: endColumn, 4: kind, vars } = scope;
if (index > 0) writer.write(comma);
state[0] = encodeInteger(writer, startLine, state[0]);
encodeInteger(writer, startColumn, 0);
encodeInteger(writer, kind, 0);
const fields = scope.length === 6 ? 1 : 0;
encodeInteger(writer, fields, 0);
if (scope.length === 6) encodeInteger(writer, scope[5], 0);
for (const v of vars) {
encodeInteger(writer, v, 0);
}
for (index++; index < scopes.length; ) {
const next = scopes[index];
const { 0: l, 1: c } = next;
if (l > endLine || l === endLine && c >= endColumn) {
break;
}
index = _encodeOriginalScopes(scopes, index, writer, state);
}
writer.write(comma);
state[0] = encodeInteger(writer, endLine, state[0]);
encodeInteger(writer, endColumn, 0);
return index;
}
function decodeGeneratedRanges(input) {
const { length } = input;
const reader = new StringReader(input);
const ranges = [];
const stack = [];
let genLine = 0;
let definitionSourcesIndex = 0;
let definitionScopeIndex = 0;
let callsiteSourcesIndex = 0;
let callsiteLine = 0;
let callsiteColumn = 0;
let bindingLine = 0;
let bindingColumn = 0;
do {
const semi = reader.indexOf(";");
let genColumn = 0;
for (; reader.pos < semi; reader.pos++) {
genColumn = decodeInteger(reader, genColumn);
if (!hasMoreVlq(reader, semi)) {
const last = stack.pop();
last[2] = genLine;
last[3] = genColumn;
continue;
}
const fields = decodeInteger(reader, 0);
const hasDefinition = fields & 1;
const hasCallsite = fields & 2;
const hasScope = fields & 4;
let callsite = null;
let bindings = EMPTY;
let range;
if (hasDefinition) {
const defSourcesIndex = decodeInteger(reader, definitionSourcesIndex);
definitionScopeIndex = decodeInteger(
reader,
definitionSourcesIndex === defSourcesIndex ? definitionScopeIndex : 0
);
definitionSourcesIndex = defSourcesIndex;
range = [genLine, genColumn, 0, 0, defSourcesIndex, definitionScopeIndex];
} else {
range = [genLine, genColumn, 0, 0];
}
range.isScope = !!hasScope;
if (hasCallsite) {
const prevCsi = callsiteSourcesIndex;
const prevLine = callsiteLine;
callsiteSourcesIndex = decodeInteger(reader, callsiteSourcesIndex);
const sameSource = prevCsi === callsiteSourcesIndex;
callsiteLine = decodeInteger(reader, sameSource ? callsiteLine : 0);
callsiteColumn = decodeInteger(
reader,
sameSource && prevLine === callsiteLine ? callsiteColumn : 0
);
callsite = [callsiteSourcesIndex, callsiteLine, callsiteColumn];
}
range.callsite = callsite;
if (hasMoreVlq(reader, semi)) {
bindings = [];
do {
bindingLine = genLine;
bindingColumn = genColumn;
const expressionsCount = decodeInteger(reader, 0);
let expressionRanges;
if (expressionsCount < -1) {
expressionRanges = [[decodeInteger(reader, 0)]];
for (let i = -1; i > expressionsCount; i--) {
const prevBl = bindingLine;
bindingLine = decodeInteger(reader, bindingLine);
bindingColumn = decodeInteger(reader, bindingLine === prevBl ? bindingColumn : 0);
const expression = decodeInteger(reader, 0);
expressionRanges.push([expression, bindingLine, bindingColumn]);
}
} else {
expressionRanges = [[expressionsCount]];
}
bindings.push(expressionRanges);
} while (hasMoreVlq(reader, semi));
}
range.bindings = bindings;
ranges.push(range);
stack.push(range);
}
genLine++;
reader.pos = semi + 1;
} while (reader.pos < length);
return ranges;
}
function encodeGeneratedRanges(ranges) {
if (ranges.length === 0) return "";
const writer = new StringWriter();
for (let i = 0; i < ranges.length; ) {
i = _encodeGeneratedRanges(ranges, i, writer, [0, 0, 0, 0, 0, 0, 0]);
}
return writer.flush();
}
function _encodeGeneratedRanges(ranges, index, writer, state) {
const range = ranges[index];
const {
0: startLine,
1: startColumn,
2: endLine,
3: endColumn,
isScope,
callsite,
bindings
} = range;
if (state[0] < startLine) {
catchupLine(writer, state[0], startLine);
state[0] = startLine;
state[1] = 0;
} else if (index > 0) {
writer.write(comma);
}
state[1] = encodeInteger(writer, range[1], state[1]);
const fields = (range.length === 6 ? 1 : 0) | (callsite ? 2 : 0) | (isScope ? 4 : 0);
encodeInteger(writer, fields, 0);
if (range.length === 6) {
const { 4: sourcesIndex, 5: scopesIndex } = range;
if (sourcesIndex !== state[2]) {
state[3] = 0;
}
state[2] = encodeInteger(writer, sourcesIndex, state[2]);
state[3] = encodeInteger(writer, scopesIndex, state[3]);
}
if (callsite) {
const { 0: sourcesIndex, 1: callLine, 2: callColumn } = range.callsite;
if (sourcesIndex !== state[4]) {
state[5] = 0;
state[6] = 0;
} else if (callLine !== state[5]) {
state[6] = 0;
}
state[4] = encodeInteger(writer, sourcesIndex, state[4]);
state[5] = encodeInteger(writer, callLine, state[5]);
state[6] = encodeInteger(writer, callColumn, state[6]);
}
if (bindings) {
for (const binding of bindings) {
if (binding.length > 1) encodeInteger(writer, -binding.length, 0);
const expression = binding[0][0];
encodeInteger(writer, expression, 0);
let bindingStartLine = startLine;
let bindingStartColumn = startColumn;
for (let i = 1; i < binding.length; i++) {
const expRange = binding[i];
bindingStartLine = encodeInteger(writer, expRange[1], bindingStartLine);
bindingStartColumn = encodeInteger(writer, expRange[2], bindingStartColumn);
encodeInteger(writer, expRange[0], 0);
}
}
}
for (index++; index < ranges.length; ) {
const next = ranges[index];
const { 0: l, 1: c } = next;
if (l > endLine || l === endLine && c >= endColumn) {
break;
}
index = _encodeGeneratedRanges(ranges, index, writer, state);
}
if (state[0] < endLine) {
catchupLine(writer, state[0], endLine);
state[0] = endLine;
state[1] = 0;
} else {
writer.write(comma);
}
state[1] = encodeInteger(writer, endColumn, state[1]);
return index;
}
function catchupLine(writer, lastLine, line) {
do {
writer.write(semicolon);
} while (++lastLine < line);
}
function decode(mappings) {
const { length } = mappings;
const reader = new StringReader(mappings);
const decoded = [];
let genColumn = 0;
let sourcesIndex = 0;
let sourceLine = 0;
let sourceColumn = 0;
let namesIndex = 0;
do {
const semi = reader.indexOf(";");
const line = [];
let sorted = true;
let lastCol = 0;
genColumn = 0;
while (reader.pos < semi) {
let seg;
genColumn = decodeInteger(reader, genColumn);
if (genColumn < lastCol) sorted = false;
lastCol = genColumn;
if (hasMoreVlq(reader, semi)) {
sourcesIndex = decodeInteger(reader, sourcesIndex);
sourceLine = decodeInteger(reader, sourceLine);
sourceColumn = decodeInteger(reader, sourceColumn);
if (hasMoreVlq(reader, semi)) {
namesIndex = decodeInteger(reader, namesIndex);
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex];
} else {
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn];
}
} else {
seg = [genColumn];
}
line.push(seg);
reader.pos++;
}
if (!sorted) sort(line);
decoded.push(line);
reader.pos = semi + 1;
} while (reader.pos <= length);
return decoded;
}
function sort(line) {
line.sort(sortComparator);
}
function sortComparator(a, b) {
return a[0] - b[0];
}
function encode(decoded) {
const writer = new StringWriter();
let sourcesIndex = 0;
let sourceLine = 0;
let sourceColumn = 0;
let namesIndex = 0;
for (let i = 0; i < decoded.length; i++) {
const line = decoded[i];
if (i > 0) writer.write(semicolon);
if (line.length === 0) continue;
let genColumn = 0;
for (let j = 0; j < line.length; j++) {
const segment = line[j];
if (j > 0) writer.write(comma);
genColumn = encodeInteger(writer, segment[0], genColumn);
if (segment.length === 1) continue;
sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
sourceLine = encodeInteger(writer, segment[2], sourceLine);
sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
if (segment.length === 4) continue;
namesIndex = encodeInteger(writer, segment[4], namesIndex);
}
}
return writer.flush();
}
}));
}
});
// ../../node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js
var require_trace_mapping_umd = __commonJS({
"../../node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js"(exports, module) {
(function(global2, factory) {
if (typeof exports === "object" && typeof module !== "undefined") {
factory(module, require_resolve_uri_umd(), require_sourcemap_codec_umd());
module.exports = def(module);
} else if (typeof define === "function" && define.amd) {
define(["module", "@jridgewell/resolve-uri", "@jridgewell/sourcemap-codec"], function(mod) {
factory.apply(this, arguments);
mod.exports = def(mod);
});
} else {
const mod = { exports: {} };
factory(mod, global2.resolveURI, global2.sourcemapCodec);
global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self;
global2.traceMapping = def(mod);
}
function def(m) {
return "default" in m.exports ? m.exports.default : m.exports;
}
})(exports, (function(module2, require_resolveURI, require_sourcemapCodec) {
"use strict";
var __create2 = Object.create;
var __defProp2 = Object.defineProperty;
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
var __getOwnPropNames2 = Object.getOwnPropertyNames;
var __getProtoOf2 = Object.getPrototypeOf;
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
var __commonJS2 = (cb, mod) => function __require2() {
return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export2 = (target, all) => {
for (var name in all)
__defProp2(target, name, { get: all[name], enumerable: true });
};
var __copyProps2 = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames2(from))
if (!__hasOwnProp2.call(to, key) && key !== except)
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
}
return to;
};
var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(
// 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 ? __defProp2(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
var require_sourcemap_codec = __commonJS2({
"umd:@jridgewell/sourcemap-codec"(exports2, module22) {
module22.exports = require_sourcemapCodec;
}
});
var require_resolve_uri = __commonJS2({
"umd:@jridgewell/resolve-uri"(exports2, module22) {
module22.exports = require_resolveURI;
}
});
var trace_mapping_exports = {};
__export2(trace_mapping_exports, {
AnyMap: () => FlattenMap,
FlattenMap: () => FlattenMap,
GREATEST_LOWER_BOUND: () => GREATEST_LOWER_BOUND,
LEAST_UPPER_BOUND: () => LEAST_UPPER_BOUND,
TraceMap: () => TraceMap,
allGeneratedPositionsFor: () => allGeneratedPositionsFor,
decodedMap: () => decodedMap,
decodedMappings: () => decodedMappings,
eachMapping: () => eachMapping,
encodedMap: () => encodedMap,
encodedMappings: () => encodedMappings,
generatedPositionFor: () => generatedPositionFor,
isIgnored: () => isIgnored,
originalPositionFor: () => originalPositionFor,
presortedDecodedMap: () => presortedDecodedMap,
sourceContentFor: () => sourceContentFor,
traceSegment: () => traceSegment
});
module2.exports = __toCommonJS2(trace_mapping_exports);
var import_sourcemap_codec = __toESM2(require_sourcemap_codec());
var import_resolve_uri = __toESM2(require_resolve_uri());
function stripFilename(path) {
if (!path) return "";
const index = path.lastIndexOf("/");
return path.slice(0, index + 1);
}
function resolver(mapUrl, sourceRoot) {
const from = stripFilename(mapUrl);
const prefix = sourceRoot ? sourceRoot + "/" : "";
return (source) => (0, import_resolve_uri.default)(prefix + (source || ""), from);
}
var COLUMN = 0;
var SOURCES_INDEX = 1;
var SOURCE_LINE = 2;
var SOURCE_COLUMN = 3;
var NAMES_INDEX = 4;
var REV_GENERATED_LINE = 1;
var REV_GENERATED_COLUMN = 2;
function maybeSort(mappings, owned) {
const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);
if (unsortedIndex === mappings.length) return mappings;
if (!owned) mappings = mappings.slice();
for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) {
mappings[i] = sortSegments(mappings[i], owned);
}
return mappings;
}
function nextUnsortedSegmentLine(mappings, start) {
for (let i = start; i < mappings.length; i++) {
if (!isSorted(mappings[i])) return i;
}
return mappings.length;
}
function isSorted(line) {
for (let j = 1; j < line.length; j++) {
if (line[j][COLUMN] < line[j - 1][COLUMN]) {
return false;
}
}
return true;
}
function sortSegments(line, owned) {
if (!owned) line = line.slice();
return line.sort(sortComparator);
}
function sortComparator(a, b) {
return a[COLUMN] - b[COLUMN];
}
function buildBySources(decoded, memos) {
const sources = memos.map(() => []);
for (let i = 0; i < decoded.length; i++) {
const line = decoded[i];
for (let j = 0; j < line.length; j++) {
const seg = line[j];
if (seg.length === 1) continue;
const sourceIndex2 = seg[SOURCES_INDEX];
const sourceLine = seg[SOURCE_LINE];
const sourceColumn = seg[SOURCE_COLUMN];
const source = sources[sourceIndex2];
const segs = source[sourceLine] || (source[sourceLine] = []);
segs.push([sourceColumn, i, seg[COLUMN]]);
}
}
for (let i = 0; i < sources.length; i++) {
const source = sources[i];
for (let j = 0; j < source.length; j++) {
const line = source[j];
if (line) line.sort(sortComparator);
}
}
return sources;
}
var found = false;
function binarySearch(haystack, needle, low, high) {
while (low <= high) {
const mid = low + (high - low >> 1);
const cmp = haystack[mid][COLUMN] - needle;
if (cmp === 0) {
found = true;
return mid;
}
if (cmp < 0) {
low = mid + 1;
} else {
high = mid - 1;
}
}
found = false;
return low - 1;
}
function upperBound(haystack, needle, index) {
for (let i = index + 1; i < haystack.length; index = i++) {
if (haystack[i][COLUMN] !== needle) break;
}
return index;
}
function lowerBound(haystack, needle, index) {
for (let i = index - 1; i >= 0; index = i--) {
if (haystack[i][COLUMN] !== needle) break;
}
return index;
}
function memoizedState() {
return {
lastKey: -1,
lastNeedle: -1,
lastIndex: -1
};
}
function memoizedBinarySearch(haystack, needle, state, key) {
const { lastKey, lastNeedle, lastIndex } = state;
let low = 0;
let high = haystack.length - 1;
if (key === lastKey) {
if (needle === lastNeedle) {
found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle;
return lastIndex;
}
if (needle >= lastNeedle) {
low = lastIndex === -1 ? 0 : lastIndex;
} else {
high = lastIndex;
}
}
state.lastKey = key;
state.lastNeedle = needle;
return state.lastIndex = binarySearch(haystack, needle, low, high);
}
function parse(map) {
return typeof map === "string" ? JSON.parse(map) : map;
}
var FlattenMap = function(map, mapUrl) {
const parsed = parse(map);
if (!("sections" in parsed)) {
return new TraceMap(parsed, mapUrl);
}
const mappings = [];
const sources = [];
const sourcesContent = [];
const names = [];
const ignoreList = [];
recurse(
parsed,
mapUrl,
mappings,
sources,
sourcesContent,
names,
ignoreList,
0,
0,
Infinity,
Infinity
);
const joined = {
version: 3,
file: parsed.file,
names,
sources,
sourcesContent,
mappings,
ignoreList
};
return presortedDecodedMap(joined);
};
function recurse(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) {
const { sections } = input;
for (let i = 0; i < sections.length; i++) {
const { map, offset } = sections[i];
let sl = stopLine;
let sc = stopColumn;
if (i + 1 < sections.length) {
const nextOffset = sections[i + 1].offset;
sl = Math.min(stopLine, lineOffset + nextOffset.line);
if (sl === stopLine) {
sc = Math.min(stopColumn, columnOffset + nextOffset.column);
} else if (sl < stopLine) {
sc = columnOffset + nextOffset.column;
}
}
addSection(
map,
mapUrl,
mappings,
sources,
sourcesContent,
names,
ignoreList,
lineOffset + offset.line,
columnOffset + offset.column,
sl,
sc
);
}
}
function addSection(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) {
const parsed = parse(input);
if ("sections" in parsed) return recurse(...arguments);
const map = new TraceMap(parsed, mapUrl);
const sourcesOffset = sources.length;
const namesOffset = names.length;
const decoded = decodedMappings(map);
const { resolvedSources, sourcesContent: contents, ignoreList: ignores } = map;
append(sources, resolvedSources);
append(names, map.names);
if (contents) append(sourcesContent, contents);
else for (let i = 0; i < resolvedSources.length; i++) sourcesContent.push(null);
if (ignores) for (let i = 0; i < ignores.length; i++) ignoreList.push(ignores[i] + sourcesOffset);
for (let i = 0; i < decoded.length; i++) {
const lineI = lineOffset + i;
if (lineI > stopLine) return;
const out = getLine(mappings, lineI);
const cOffset = i === 0 ? columnOffset : 0;
const line = decoded[i];
for (let j = 0; j < line.length; j++) {
const seg = line[j];
const column = cOffset + seg[COLUMN];
if (lineI === stopLine && column >= stopColumn) return;
if (seg.length === 1) {
out.push([column]);
continue;
}
const sourcesIndex = sourcesOffset + seg[SOURCES_INDEX];
const sourceLine = seg[SOURCE_LINE];
const sourceColumn = seg[SOURCE_COLUMN];
out.push(
seg.length === 4 ? [column, sourcesIndex, sourceLine, sourceColumn] : [column, sourcesIndex, sourceLine, sourceColumn, namesOffset + seg[NAMES_INDEX]]
);
}
}
}
function append(arr, other) {
for (let i = 0; i < other.length; i++) arr.push(other[i]);
}
function getLine(arr, index) {
for (let i = arr.length; i <= index; i++) arr[i] = [];
return arr[index];
}
var LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)";
var COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)";
var LEAST_UPPER_BOUND = -1;
var GREATEST_LOWER_BOUND = 1;
var TraceMap = class {
constructor(map, mapUrl) {
const isString = typeof map === "string";
if (!isString && map._decodedMemo) return map;
const parsed = parse(map);
const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
this.version = version;
this.file = file;
this.names = names || [];
this.sourceRoot = sourceRoot;
this.sources = sources;
this.sourcesContent = sourcesContent;
this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
const resolve = resolver(mapUrl, sourceRoot);
this.resolvedSources = sources.map(resolve);
const { mappings } = parsed;
if (typeof mappings === "string") {
this._encoded = mappings;
this._decoded = void 0;
} else if (Array.isArray(mappings)) {
this._encoded = void 0;
this._decoded = maybeSort(mappings, isString);
} else if (parsed.sections) {
throw new Error(`TraceMap passed sectioned source map, please use FlattenMap export instead`);
} else {
throw new Error(`invalid source map: ${JSON.stringify(parsed)}`);
}
this._decodedMemo = memoizedState();
this._bySources = void 0;
this._bySourceMemos = void 0;
}
};
function cast(map) {
return map;
}
function encodedMappings(map) {
var _a, _b;
return (_b = (_a = cast(map))._encoded) != null ? _b : _a._encoded = (0, import_sourcemap_codec.encode)(cast(map)._decoded);
}
function decodedMappings(map) {
var _a;
return (_a = cast(map))._decoded || (_a._decoded = (0, import_sourcemap_codec.decode)(cast(map)._encoded));
}
function traceSegment(map, line, column) {
const decoded = decodedMappings(map);
if (line >= decoded.length) return null;
const segments = decoded[line];
const index = traceSegmentInternal(
segments,
cast(map)._decodedMemo,
line,
column,
GREATEST_LOWER_BOUND
);
return index === -1 ? null : segments[index];
}
function originalPositionFor(map, needle) {
let { line, column, bias } = needle;
line--;
if (line < 0) throw new Error(LINE_GTR_ZERO);
if (column < 0) throw new Error(COL_GTR_EQ_ZERO);
const decoded = decodedMappings(map);
if (line >= decoded.length) return OMapping(null, null, null, null);
const segments = decoded[line];
const index = traceSegmentInternal(
segments,
cast(map)._decodedMemo,
line,
column,
bias || GREATEST_LOWER_BOUND
);
if (index === -1) return OMapping(null, null, null, null);
const segment = segments[index];
if (segment.length === 1) return OMapping(null, null, null, null);
const { names, resolvedSources } = map;
return OMapping(
resolvedSources[segment[SOURCES_INDEX]],
segment[SOURCE_LINE] + 1,
segment[SOURCE_COLUMN],
segment.length === 5 ? names[segment[NAMES_INDEX]] : null
);
}
function generatedPositionFor(map, needle) {
const { source, line, column, bias } = needle;
return generatedPosition(map, source, line, column, bias || GREATEST_LOWER_BOUND, false);
}
function allGeneratedPositionsFor(map, needle) {
const { source, line, column, bias } = needle;
return generatedPosition(map, source, line, column, bias || LEAST_UPPER_BOUND, true);
}
function eachMapping(map, cb) {
const decoded = decodedMappings(map);
const { names, resolvedSources } = map;
for (let i = 0; i < decoded.length; i++) {
const line = decoded[i];
for (let j = 0; j < line.length; j++) {
const seg = line[j];
const generatedLine = i + 1;
const generatedColumn = seg[0];
let source = null;
let originalLine = null;
let originalColumn = null;
let name = null;
if (seg.length !== 1) {
source = resolvedSources[seg[1]];
originalLine = seg[2] + 1;
originalColumn = seg[3];
}
if (seg.length === 5) name = names[seg[4]];
cb({
generatedLine,
generatedColumn,
source,
originalLine,
originalColumn,
name
});
}
}
}
function sourceIndex(map, source) {
const { sources, resolvedSources } = map;
let index = sources.indexOf(source);
if (index === -1) index = resolvedSources.indexOf(source);
return index;
}
function sourceContentFor(map, source) {
const { sourcesContent } = map;
if (sourcesContent == null) return null;
const index = sourceIndex(map, source);
return index === -1 ? null : sourcesContent[index];
}
function isIgnored(map, source) {
const { ignoreList } = map;
if (ignoreList == null) return false;
const index = sourceIndex(map, source);
return index === -1 ? false : ignoreList.includes(index);
}
function presortedDecodedMap(map, mapUrl) {
const tracer = new TraceMap(clone(map, []), mapUrl);
cast(tracer)._decoded = map.mappings;
return tracer;
}
function decodedMap(map) {
return clone(map, decodedMappings(map));
}
function encodedMap(map) {
return clone(map, encodedMappings(map));
}
function clone(map, mappings) {
return {
version: map.version,
file: map.file,
names: map.names,
sourceRoot: map.sourceRoot,
sources: map.sources,
sourcesContent: map.sourcesContent,
mappings,
ignoreList: map.ignoreList || map.x_google_ignoreList
};
}
function OMapping(source, line, column, name) {
return { source, line, column, name };
}
function GMapping(line, column) {
return { line, column };
}
function traceSegmentInternal(segments, memo, line, column, bias) {
let index = memoizedBinarySearch(segments, column, memo, line);
if (found) {
index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index);
} else if (bias === LEAST_UPPER_BOUND) index++;
if (index === -1 || index === segments.length) return -1;
return index;
}
function sliceGeneratedPositions(segments, memo, line, column, bias) {
let min = traceSegmentInternal(segments, memo, line, column, GREATEST_LOWER_BOUND);
if (!found && bias === LEAST_UPPER_BOUND) min++;
if (min === -1 || min === segments.length) return [];
const matchedColumn = found ? column : segments[min][COLUMN];
if (!found) min = lowerBound(segments, matchedColumn, min);
const max = upperBound(segments, matchedColumn, min);
const result = [];
for (; min <= max; min++) {
const segment = segments[min];
result.push(GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]));
}
return result;
}
function generatedPosition(map, source, line, column, bias, all) {
var _a, _b;
line--;
if (line < 0) throw new Error(LINE_GTR_ZERO);
if (column < 0) throw new Error(COL_GTR_EQ_ZERO);
const { sources, resolvedSources } = map;
let sourceIndex2 = sources.indexOf(source);
if (sourceIndex2 === -1) sourceIndex2 = resolvedSources.indexOf(source);
if (sourceIndex2 === -1) return all ? [] : GMapping(null, null);
const bySourceMemos = (_a = cast(map))._bySourceMemos || (_a._bySourceMemos = sources.map(memoizedState));
const generated = (_b = cast(map))._bySources || (_b._bySources = buildBySources(decodedMappings(map), bySourceMemos));
const segments = generated[sourceIndex2][line];
if (segments == null) return all ? [] : GMapping(null, null);
const memo = bySourceMemos[sourceIndex2];
if (all) return sliceGeneratedPositions(segments, memo, line, column, bias);
const index = traceSegmentInternal(segments, memo, line, column, bias);
if (index === -1) return GMapping(null, null);
const segment = segments[index];
return GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]);
}
}));
}
});
// ../../node_modules/v8-to-istanbul/lib/source.js
var require_source = __commonJS({
"../../node_modules/v8-to-istanbul/lib/source.js"(exports, module) {
var CovLine = require_line();
var { sliceRange } = require_range();
var { originalPositionFor, generatedPositionFor, GREATEST_LOWER_BOUND, LEAST_UPPER_BOUND } = require_trace_mapping_umd();
module.exports = class CovSource {
constructor(sourceRaw, wrapperLength) {
sourceRaw = sourceRaw ? sourceRaw.trimEnd() : "";
this.lines = [];
this.eof = sourceRaw.length;
this.shebangLength = getShebangLength(sourceRaw);
this.wrapperLength = wrapperLength - this.shebangLength;
this._buildLines(sourceRaw);
}
_buildLines(source) {
let position = 0;
let ignoreCount = 0;
let ignoreAll = false;
for (const [i, lineStr] of source.split(/(?<=\r?\n)/u).entries()) {
const line = new CovLine(i + 1, position, lineStr);
if (ignoreCount > 0) {
line.ignore = true;
ignoreCount--;
} else if (ignoreAll) {
line.ignore = true;
}
this.lines.push(line);
position += lineStr.length;
const ignoreToken = this._parseIgnore(lineStr);
if (!ignoreToken) continue;
line.ignore = true;
if (ignoreToken.count !== void 0) {
ignoreCount = ignoreToken.count;
}
if (ignoreToken.start || ignoreToken.stop) {
ignoreAll = ignoreToken.start;
ignoreCount = 0;
}
}
}
/**
* Parses for comments:
* c8 ignore next
* c8 ignore next 3
* c8 ignore start
* c8 ignore stop
* And equivalent ones for v8, e.g. v8 ignore next.
* @param {string} lineStr
* @return {{count?: number, start?: boolean, stop?: boolean}|undefined}
*/
_parseIgnore(lineStr) {
const testIgnoreNextLines = lineStr.match(/^\W*\/\* (?:[cv]8|node:coverage) ignore next (?<count>[0-9]+)/);
if (testIgnoreNextLines) {
return { count: Number(testIgnoreNextLines.groups.count) };
}
if (lineStr.match(/^\W*\/\* (?:[cv]8|node:coverage) ignore next/)) {
return { count: 1 };
}
if (lineStr.match(/\/\* ([cv]8|node:coverage) ignore next/)) {
return { count: 0 };
}
const testIgnoreStartStop = lineStr.match(/\/\* [c|v]8 ignore (?<mode>start|stop)/);
if (testIgnoreStartStop) {
if (testIgnoreStartStop.groups.mode === "start") return { start: true };
if (testIgnoreStartStop.groups.mode === "stop") return { stop: true };
}
const testNodeIgnoreStartStop = lineStr.match(/\/\* node:coverage (?<mode>enable|disable)/);
if (testNodeIgnoreStartStop) {
if (testNodeIgnoreStartStop.groups.mode === "disable") return { start: true };
if (testNodeIgnoreStartStop.groups.mode === "enable") return { stop: true };
}
}
// given a start column and end column in absolute offsets within
// a source file (0 - EOF), returns the relative line column positions.
offsetToOriginalRelative(sourceMap, startCol, endCol) {
const lines = sliceRange(this.lines, startCol, endCol, true);
if (!lines.length) return {};
const start = originalPositionTryBoth(
sourceMap,
lines[0].line,
Math.max(0, startCol - lines[0].startCol)
);
if (!(start && start.source)) {
return {};
}
let end = originalEndPositionFor(
sourceMap,
lines[lines.length - 1].line,
endCol - lines[lines.length - 1].startCol
);
if (!(end && end.source)) {
return {};
}
if (start.source !== end.source) {
return {};
}
if (start.line === end.line && start.column === end.column) {
end = originalPositionFor(sourceMap, {
line: lines[lines.length - 1].line,
column: endCol - lines[lines.length - 1].startCol,
bias: LEAST_UPPER_BOUND
});
end.column -= 1;
}
return {
source: start.source,
startLine: start.line,
relStartCol: start.column,
endLine: end.line,
relEndCol: end.column
};
}
relativeToOffset(line, relCol) {
line = Math.max(line, 1);
if (this.lines[line - 1] === void 0) return this.eof;
return Math.min(this.lines[line - 1].startCol + relCol, this.lines[line - 1].endCol);
}
};
function originalEndPositionFor(sourceMap, line, column) {
const beforeEndMapping = originalPositionTryBoth(
sourceMap,
line,
Math.max(column - 1, 1)
);
if (beforeEndMapping.source === null) {
return null;
}
const afterEndMapping = generatedPositionFor(sourceMap, {
source: beforeEndMapping.source,
line: beforeEndMapping.line,
column: beforeEndMapping.column + 1,
bias: LEAST_UPPER_BOUND
});
if (
// If this is null, it means that we've hit the end of the file,
// so we can use Infinity as the end column.
afterEndMapping.line === null || // If these don't match, it means that the call to
// 'generatedPositionFor' didn't find any other original mappings on
// the line we gave, so consider the binding to extend to infinity.
originalPositionFor(sourceMap, afterEndMapping).line !== beforeEndMapping.line
) {
return {
source: beforeEndMapping.source,
line: beforeEndMapping.line,
column: Infinity
};
}
return originalPositionFor(sourceMap, afterEndMapping);
}
function originalPositionTryBoth(sourceMap, line, column) {
let original = originalPositionFor(sourceMap, {
line,
column,
bias: GREATEST_LOWER_BOUND
});
if (original.line === null) {
original = originalPositionFor(sourceMap, {
line,
column,
bias: LEAST_UPPER_BOUND
});
}
const min = originalPositionFor(sourceMap, {
line,
column: 0,
bias: GREATEST_LOWER_BOUND
});
if (min.line > original.line) {
original = min;
}
return original;
}
var isPreNode12 = /^v1[0-1]\./u.test(process.version);
function getShebangLength(source) {
if (isPreNode12 && source.indexOf("#!") === 0) {
const match = source.match(/(?<shebang>#!.*)/);
if (match) {
return match.groups.shebang.length;
}
} else {
return 0;
}
}
}
});
// ../../node_modules/v8-to-istanbul/package.json
var require_package = __commonJS({
"../../node_modules/v8-to-istanbul/package.json"(exports, module) {
module.exports = {
name: "v8-to-istanbul",
version: "9.3.0",
description: "convert from v8 coverage format to istanbul's format",
main: "index.js",
types: "index.d.ts",
scripts: {
fix: "standard --fix",
snapshot: "TAP_SNAPSHOT=1 tap test/*.js",
test: "c8 --reporter=html --reporter=text tap --no-coverage test/*.js",
posttest: "standard",
coverage: "c8 report --check-coverage"
},
repository: "istanbuljs/v8-to-istanbul",
keywords: [
"istanbul",
"v8",
"coverage"
],
standard: {
ignore: [
"**/test/fixtures"
]
},
author: "Ben Coe <[email protected]>",
license: "ISC",
dependencies: {
"@jridgewell/trace-mapping": "^0.3.12",
"@types/istanbul-lib-coverage": "^2.0.1",
"convert-source-map": "^2.0.0"
},
devDependencies: {
"@types/node": "^20.0.0",
c8: "^7.2.1",
semver: "^7.3.2",
should: "13.2.3",
"source-map": "^0.7.3",
standard: "^17.0.0",
tap: "^16.0.0"
},
engines: {
node: ">=10.12.0"
},
files: [
"lib/*.js",
"index.js",
"index.d.ts"
]
};
}
});
// ../../node_modules/v8-to-istanbul/lib/v8-to-istanbul.js
var require_v8_to_istanbul = __commonJS({
"../../node_modules/v8-to-istanbul/lib/v8-to-istanbul.js"(exports, module) {
var assert = __require("assert");
var convertSourceMap = require_convert_source_map();
var util = __require("util");
var debuglog = util.debuglog("c8");
var { dirname, isAbsolute, join, resolve } = __require("path");
var { fileURLToPath } = __require("url");
var CovBranch = require_branch();
var CovFunction = require_function();
var CovSource = require_source();
var { sliceRange } = require_range();
var compatError = Error(`requires Node.js ${require_package().engines.node}`);
var { readFileSync } = __require("fs");
var readFile = () => {
throw compatError;
};
try {
readFile = __require("fs").promises.readFile;
} catch (_err) {
}
var { TraceMap } = require_trace_mapping_umd();
var isOlderNode10 = /^v10\.(([0-9]\.)|(1[0-5]\.))/u.test(process.version);
var isNode8 = /^v8\./.test(process.version);
var cjsWrapperLength = isOlderNode10 ? __require("module").wrapper[0].length : 0;
module.exports = class V8ToIstanbul {
constructor(scriptPath, wrapperLength, sources, excludePath) {
assert(typeof scriptPath === "string", "scriptPath must be a string");
assert(!isNode8, "This module does not support node 8 or lower, please upgrade to node 10");
this.path = parsePath(scriptPath);
this.wrapperLength = wrapperLength === void 0 ? cjsWrapperLength : wrapperLength;
this.excludePath = excludePath || (() => false);
this.sources = sources || {};
this.generatedLines = [];
this.branches = {};
this.functions = {};
this.covSources = [];
this.rawSourceMap = void 0;
this.sourceMap = void 0;
this.sourceTranspiled = void 0;
this.all = false;
}
async load() {
const rawSource = this.sources.source || await readFile(this.path, "utf8");
this.rawSourceMap = this.sources.sourceMap || // if we find a source-map (either inline, or a .map file) we load
// both the transpiled and original source, both of which are used during
// the backflips we perform to remap absolute to relative positions.
convertSourceMap.fromSource(rawSource) || convertSourceMap.fromMapFileSource(rawSource, this._readFileFromDir.bind(this));
if (this.rawSourceMap) {
if (this.rawSourceMap.sourcemap.sources.length > 1) {
this.sourceMap = new TraceMap(this.rawSourceMap.sourcemap);
if (!this.sourceMap.sourcesContent) {
this.sourceMap.sourcesContent = await this.sourcesContentFromSources();
}
this.covSources = this.sourceMap.sourcesContent.map((rawSource2, i) => ({ source: new CovSource(rawSource2, this.wrapperLength), path: this.sourceMap.sources[i] }));
this.sourceTranspiled = new CovSource(rawSource, this.wrapperLength);
} else {
const candidatePath = this.rawSourceMap.sourcemap.sources.length >= 1 ? this.rawSourceMap.sourcemap.sources[0] : this.rawSourceMap.sourcemap.file;
this.path = this._resolveSource(this.rawSourceMap, candidatePath || this.path);
this.sourceMap = new TraceMap(this.rawSourceMap.sourcemap);
let originalRawSource;
if (this.sources.sourceMap && this.sources.sourceMap.sourcemap && this.sources.sourceMap.sourcemap.sourcesContent && this.sources.sourceMap.sourcemap.sourcesContent.length === 1) {
originalRawSource = this.sources.sourceMap.sourcemap.sourcesContent[0];
} else if (this.sources.originalSource) {
originalRawSource = this.sources.originalSource;
} else if (this.sourceMap.sourcesContent && this.sourceMap.sourcesContent[0]) {
originalRawSource = this.sourceMap.sourcesContent[0];
} else {
originalRawSource = await readFile(this.path, "utf8");
}
this.covSources = [{ source: new CovSource(originalRawSource, this.wrapperLength), path: this.path }];
this.sourceTranspiled = new CovSource(rawSource, this.wrapperLength);
}
} else {
this.covSources = [{ source: new CovSource(rawSource, this.wrapperLength), path: this.path }];
}
}
_readFileFromDir(filename) {
return readFileSync(resolve(dirname(this.path), filename), "utf-8");
}
async sourcesContentFromSources() {
const fileList = this.sourceMap.sources.map((relativePath) => {
const realPath = this._resolveSource(this.rawSourceMap, relativePath);
return readFile(realPath, "utf-8").then((result) => result).catch((err) => {
debuglog(`failed to load ${realPath}: ${err.message}`);
});
});
return await Promise.all(fileList);
}
destroy() {
}
_resolveSource(rawSourceMap, sourcePath) {
if (sourcePath.startsWith("file://")) {
return fileURLToPath(sourcePath);
}
sourcePath = sourcePath.replace(/^webpack:\/\//, "");
const sourceRoot = rawSourceMap.sourcemap.sourceRoot ? rawSourceMap.sourcemap.sourceRoot.replace("file://", "") : "";
const candidatePath = join(sourceRoot, sourcePath);
if (isAbsolute(candidatePath)) {
return candidatePath;
} else {
return resolve(dirname(this.path), candidatePath);
}
}
applyCoverage(blocks) {
blocks.forEach((block) => {
block.ranges.forEach((range, i) => {
const isEmptyCoverage = block.functionName === "(empty-report)";
const { startCol, endCol, path, covSource } = this._maybeRemapStartColEndCol(range, isEmptyCoverage);
if (this.excludePath(path)) {
return;
}
let lines;
if (isEmptyCoverage) {
lines = covSource.lines.filter((line) => {
line.count = 0;
return true;
});
this.all = lines.length > 0;
} else {
lines = sliceRange(covSource.lines, startCol, endCol);
}
if (!lines.length) {
return;
}
const startLineInstance = lines[0];
const endLineInstance = lines[lines.length - 1];
if (block.isBlockCoverage) {
this.branches[path] = this.branches[path] || [];
this.branches[path].push(new CovBranch(
startLineInstance.line,
startCol - startLineInstance.startCol,
endLineInstance.line,
endCol - endLineInstance.startCol,
range.count
));
if (block.functionName && i === 0) {
this.functions[path] = this.functions[path] || [];
this.functions[path].push(new CovFunction(
block.functionName,
startLineInstance.line,
startCol - startLineInstance.startCol,
endLineInstance.line,
endCol - endLineInstance.startCol,
range.count
));
}
} else if (block.functionName) {
this.functions[path] = this.functions[path] || [];
this.functions[path].push(new CovFunction(
block.functionName,
startLineInstance.line,
startCol - startLineInstance.startCol,
endLineInstance.line,
endCol - endLineInstance.startCol,
range.count
));
}
lines.forEach((line) => {
if (startCol <= line.startCol && endCol >= line.endCol && !line.ignore) {
line.count = range.count;
}
});
});
});
}
_maybeRemapStartColEndCol(range, isEmptyCoverage) {
let covSource = this.covSources[0].source;
const covSourceWrapperLength = isEmptyCoverage ? 0 : covSource.wrapperLength;
let startCol = Math.max(0, range.startOffset - covSourceWrapperLength);
let endCol = Math.min(covSource.eof, range.endOffset - covSourceWrapperLength);
let path = this.path;
if (this.sourceMap) {
const sourceTranspiledWrapperLength = isEmptyCoverage ? 0 : this.sourceTranspiled.wrapperLength;
startCol = Math.max(0, range.startOffset - sourceTranspiledWrapperLength);
endCol = Math.min(this.sourceTranspiled.eof, range.endOffset - sourceTranspiledWrapperLength);
const { startLine, relStartCol, endLine, relEndCol, source } = this.sourceTranspiled.offsetToOriginalRelative(
this.sourceMap,
startCol,
endCol
);
const matchingSource = this.covSources.find((covSource2) => covSource2.path === source);
covSource = matchingSource ? matchingSource.source : this.covSources[0].source;
path = matchingSource ? matchingSource.path : this.covSources[0].path;
startCol = covSource.relativeToOffset(startLine, relStartCol);
endCol = covSource.relativeToOffset(endLine, relEndCol);
}
return {
path,
covSource,
startCol,
endCol
};
}
getInnerIstanbul(source, path) {
let resolvedPath = path;
if (this.rawSourceMap && this.rawSourceMap.sourcemap.sources.length > 1) {
resolvedPath = this._resolveSource(this.rawSourceMap, path);
}
if (this.excludePath(resolvedPath)) {
return;
}
return {
[resolvedPath]: {
path: resolvedPath,
all: this.all,
...this._statementsToIstanbul(source, path),
...this._branchesToIstanbul(source, path),
...this._functionsToIstanbul(source, path)
}
};
}
toIstanbul() {
return this.covSources.reduce((istanbulOuter, { source, path }) => Object.assign(istanbulOuter, this.getInnerIstanbul(source, path)), {});
}
_statementsToIstanbul(source, path) {
const statements = {
statementMap: {},
s: {}
};
source.lines.forEach((line, index) => {
statements.statementMap[`${index}`] = line.toIstanbul();
statements.s[`${index}`] = line.ignore ? 1 : line.count;
});
return statements;
}
_branchesToIstanbul(source, path) {
const branches = {
branchMap: {},
b: {}
};
this.branches[path] = this.branches[path] || [];
this.branches[path].forEach((branch, index) => {
const srcLine = source.lines[branch.startLine - 1];
const ignore = srcLine === void 0 ? true : srcLine.ignore;
branches.branchMap[`${index}`] = branch.toIstanbul();
branches.b[`${index}`] = [ignore ? 1 : branch.count];
});
return branches;
}
_functionsToIstanbul(source, path) {
const functions = {
fnMap: {},
f: {}
};
this.functions[path] = this.functions[path] || [];
this.functions[path].forEach((fn, index) => {
const srcLine = source.lines[fn.startLine - 1];
const ignore = srcLine === void 0 ? true : srcLine.ignore;
functions.fnMap[`${index}`] = fn.toIstanbul();
functions.f[`${index}`] = ignore ? 1 : fn.count;
});
return functions;
}
};
function parsePath(scriptPath) {
return scriptPath.startsWith("file://") ? fileURLToPath(scriptPath) : scriptPath;
}
}
});
// ../../node_modules/v8-to-istanbul/index.js
var require_v8_to_istanbul2 = __commonJS({
"../../node_modules/v8-to-istanbul/index.js"(exports, module) {
var V8ToIstanbul = require_v8_to_istanbul();
module.exports = function(path, wrapperLength, sources, excludePath) {
return new V8ToIstanbul(path, wrapperLength, sources, excludePath);
};
}
});
// ../../node_modules/bare-v8-to-istanbul/index.js
var require_bare_v8_to_istanbul = __commonJS({
"../../node_modules/bare-v8-to-istanbul/index.js"(exports, module) {
var { isBare } = require_which_runtime();
if (isBare) {
const originalProcess = global.process;
global.process = require_bare_process();
try {
module.exports = __require("v8-to-istanbul", { with: { imports: "./package.json" } });
} finally {
global.process = originalProcess;
}
} else {
module.exports = require_v8_to_istanbul2();
}
}
});
// ../../node_modules/picomatch/lib/constants.js
var require_constants6 = __commonJS({
"../../node_modules/picomatch/lib/constants.js"(exports, module) {
"use strict";
var WIN_SLASH = "\\\\/";
var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
var DEFAULT_MAX_EXTGLOB_RECURSION = 0;
var DOT_LITERAL = "\\.";
var PLUS_LITERAL = "\\+";
var QMARK_LITERAL = "\\?";
var SLASH_LITERAL = "\\/";
var ONE_CHAR = "(?=.)";
var QMARK = "[^/]";
var END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
var START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
var DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
var NO_DOT = `(?!${DOT_LITERAL})`;
var NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
var NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
var NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
var QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
var STAR = `${QMARK}*?`;
var SEP = "/";
var POSIX_CHARS = {
DOT_LITERAL,
PLUS_LITERAL,
QMARK_LITERAL,
SLASH_LITERAL,
ONE_CHAR,
QMARK,
END_ANCHOR,
DOTS_SLASH,
NO_DOT,
NO_DOTS,
NO_DOT_SLASH,
NO_DOTS_SLASH,
QMARK_NO_DOT,
STAR,
START_ANCHOR,
SEP
};
var WINDOWS_CHARS = {
...POSIX_CHARS,
SLASH_LITERAL: `[${WIN_SLASH}]`,
QMARK: WIN_NO_SLASH,
STAR: `${WIN_NO_SLASH}*?`,
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
NO_DOT: `(?!${DOT_LITERAL})`,
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
SEP: "\\"
};
var POSIX_REGEX_SOURCE = {
__proto__: null,
alnum: "a-zA-Z0-9",
alpha: "a-zA-Z",
ascii: "\\x00-\\x7F",
blank: " \\t",
cntrl: "\\x00-\\x1F\\x7F",
digit: "0-9",
graph: "\\x21-\\x7E",
lower: "a-z",
print: "\\x20-\\x7E ",
punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
space: " \\t\\r\\n\\v\\f",
upper: "A-Z",
word: "A-Za-z0-9_",
xdigit: "A-Fa-f0-9"
};
module.exports = {
DEFAULT_MAX_EXTGLOB_RECURSION,
MAX_LENGTH: 1024 * 64,
POSIX_REGEX_SOURCE,
// regular expressions
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
// Replace globs with equivalent patterns to reduce parsing time.
REPLACEMENTS: {
__proto__: null,
"***": "*",
"**/**": "**",
"**/**/**": "**"
},
// Digits
CHAR_0: 48,
/* 0 */
CHAR_9: 57,
/* 9 */
// Alphabet chars.
CHAR_UPPERCASE_A: 65,
/* A */
CHAR_LOWERCASE_A: 97,
/* a */
CHAR_UPPERCASE_Z: 90,
/* Z */
CHAR_LOWERCASE_Z: 122,
/* z */
CHAR_LEFT_PARENTHESES: 40,
/* ( */
CHAR_RIGHT_PARENTHESES: 41,
/* ) */
CHAR_ASTERISK: 42,
/* * */
// Non-alphabetic chars.
CHAR_AMPERSAND: 38,
/* & */
CHAR_AT: 64,
/* @ */
CHAR_BACKWARD_SLASH: 92,
/* \ */
CHAR_CARRIAGE_RETURN: 13,
/* \r */
CHAR_CIRCUMFLEX_ACCENT: 94,
/* ^ */
CHAR_COLON: 58,
/* : */
CHAR_COMMA: 44,
/* , */
CHAR_DOT: 46,
/* . */
CHAR_DOUBLE_QUOTE: 34,
/* " */
CHAR_EQUAL: 61,
/* = */
CHAR_EXCLAMATION_MARK: 33,
/* ! */
CHAR_FORM_FEED: 12,
/* \f */
CHAR_FORWARD_SLASH: 47,
/* / */
CHAR_GRAVE_ACCENT: 96,
/* ` */
CHAR_HASH: 35,
/* # */
CHAR_HYPHEN_MINUS: 45,
/* - */
CHAR_LEFT_ANGLE_BRACKET: 60,
/* < */
CHAR_LEFT_CURLY_BRACE: 123,
/* { */
CHAR_LEFT_SQUARE_BRACKET: 91,
/* [ */
CHAR_LINE_FEED: 10,
/* \n */
CHAR_NO_BREAK_SPACE: 160,
/* \u00A0 */
CHAR_PERCENT: 37,
/* % */
CHAR_PLUS: 43,
/* + */
CHAR_QUESTION_MARK: 63,
/* ? */
CHAR_RIGHT_ANGLE_BRACKET: 62,
/* > */
CHAR_RIGHT_CURLY_BRACE: 125,
/* } */
CHAR_RIGHT_SQUARE_BRACKET: 93,
/* ] */
CHAR_SEMICOLON: 59,
/* ; */
CHAR_SINGLE_QUOTE: 39,
/* ' */
CHAR_SPACE: 32,
/* */
CHAR_TAB: 9,
/* \t */
CHAR_UNDERSCORE: 95,
/* _ */
CHAR_VERTICAL_LINE: 124,
/* | */
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
/* \uFEFF */
/**
* Create EXTGLOB_CHARS
*/
extglobChars(chars) {
return {
"!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` },
"?": { type: "qmark", open: "(?:", close: ")?" },
"+": { type: "plus", open: "(?:", close: ")+" },
"*": { type: "star", open: "(?:", close: ")*" },
"@": { type: "at", open: "(?:", close: ")" }
};
},
/**
* Create GLOB_CHARS
*/
globChars(win32) {
return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
}
};
}
});
// ../../node_modules/picomatch/lib/utils.js
var require_utils = __commonJS({
"../../node_modules/picomatch/lib/utils.js"(exports) {
"use strict";
var {
REGEX_BACKSLASH,
REGEX_REMOVE_BACKSLASH,
REGEX_SPECIAL_CHARS,
REGEX_SPECIAL_CHARS_GLOBAL
} = require_constants6();
exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
exports.isRegexChar = (str) => str.length === 1 && exports.hasRegexChars(str);
exports.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
exports.isWindows = () => {
if (typeof navigator !== "undefined" && navigator.platform) {
const platform = navigator.platform.toLowerCase();
return platform === "win32" || platform === "windows";
}
if (typeof process !== "undefined" && process.platform) {
return process.platform === "win32";
}
return false;
};
exports.removeBackslashes = (str) => {
return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
return match === "\\" ? "" : match;
});
};
exports.escapeLast = (input, char, lastIdx) => {
const idx = input.lastIndexOf(char, lastIdx);
if (idx === -1) return input;
if (input[idx - 1] === "\\") return exports.escapeLast(input, char, idx - 1);
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
};
exports.removePrefix = (input, state = {}) => {
let output = input;
if (output.startsWith("./")) {
output = output.slice(2);
state.prefix = "./";
}
return output;
};
exports.wrapOutput = (input, state = {}, options = {}) => {
const prepend = options.contains ? "" : "^";
const append = options.contains ? "" : "$";
let output = `${prepend}(?:${input})${append}`;
if (state.negated === true) {
output = `(?:^(?!${output}).*$)`;
}
return output;
};
exports.basename = (path, { windows } = {}) => {
const segs = path.split(windows ? /[\\/]/ : "/");
const last = segs[segs.length - 1];
if (last === "") {
return segs[segs.length - 2];
}
return last;
};
}
});
// ../../node_modules/picomatch/lib/scan.js
var require_scan = __commonJS({
"../../node_modules/picomatch/lib/scan.js"(exports, module) {
"use strict";
var utils = require_utils();
var {
CHAR_ASTERISK,
/* * */
CHAR_AT,
/* @ */
CHAR_BACKWARD_SLASH,
/* \ */
CHAR_COMMA,
/* , */
CHAR_DOT,
/* . */
CHAR_EXCLAMATION_MARK,
/* ! */
CHAR_FORWARD_SLASH,
/* / */
CHAR_LEFT_CURLY_BRACE,
/* { */
CHAR_LEFT_PARENTHESES,
/* ( */
CHAR_LEFT_SQUARE_BRACKET,
/* [ */
CHAR_PLUS,
/* + */
CHAR_QUESTION_MARK,
/* ? */
CHAR_RIGHT_CURLY_BRACE,
/* } */
CHAR_RIGHT_PARENTHESES,
/* ) */
CHAR_RIGHT_SQUARE_BRACKET
/* ] */
} = require_constants6();
var isPathSeparator = (code) => {
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
};
var depth = (token) => {
if (token.isPrefix !== true) {
token.depth = token.isGlobstar ? Infinity : 1;
}
};
var scan = (input, options) => {
const opts = options || {};
const length = input.length - 1;
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
const slashes = [];
const tokens = [];
const parts = [];
let str = input;
let index = -1;
let start = 0;
let lastIndex = 0;
let isBrace = false;
let isBracket = false;
let isGlob = false;
let isExtglob = false;
let isGlobstar = false;
let braceEscaped = false;
let backslashes = false;
let negated = false;
let negatedExtglob = false;
let finished = false;
let braces = 0;
let prev;
let code;
let token = { value: "", depth: 0, isGlob: false };
const eos = () => index >= length;
const peek = () => str.charCodeAt(index + 1);
const advance = () => {
prev = code;
return str.charCodeAt(++index);
};
while (index < length) {
code = advance();
let next;
if (code === CHAR_BACKWARD_SLASH) {
backslashes = token.backslashes = true;
code = advance();
if (code === CHAR_LEFT_CURLY_BRACE) {
braceEscaped = true;
}
continue;
}
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
braces++;
while (eos() !== true && (code = advance())) {
if (code === CHAR_BACKWARD_SLASH) {
backslashes = token.backslashes = true;
advance();
continue;
}
if (code === CHAR_LEFT_CURLY_BRACE) {
braces++;
continue;
}
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
isBrace = token.isBrace = true;
isGlob = token.isGlob = true;
finished = true;
if (scanToEnd === true) {
continue;
}
break;
}
if (braceEscaped !== true && code === CHAR_COMMA) {
isBrace = token.isBrace = true;
isGlob = token.isGlob = true;
finished = true;
if (scanToEnd === true) {
continue;
}
break;
}
if (code === CHAR_RIGHT_CURLY_BRACE) {
braces--;
if (braces === 0) {
braceEscaped = false;
isBrace = token.isBrace = true;
finished = true;
break;
}
}
}
if (scanToEnd === true) {
continue;
}
break;
}
if (code === CHAR_FORWARD_SLASH) {
slashes.push(index);
tokens.push(token);
token = { value: "", depth: 0, isGlob: false };
if (finished === true) continue;
if (prev === CHAR_DOT && index === start + 1) {
start += 2;
continue;
}
lastIndex = index + 1;
continue;
}
if (opts.noext !== true) {
const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
isGlob = token.isGlob = true;
isExtglob = token.isExtglob = true;
finished = true;
if (code === CHAR_EXCLAMATION_MARK && index === start) {
negatedExtglob = true;
}
if (scanToEnd === true) {
while (eos() !== true && (code = advance())) {
if (code === CHAR_BACKWARD_SLASH) {
backslashes = token.backslashes = true;
code = advance();
continue;
}
if (code === CHAR_RIGHT_PARENTHESES) {
isGlob = token.isGlob = true;
finished = true;
break;
}
}
continue;
}
break;
}
}
if (code === CHAR_ASTERISK) {
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
isGlob = token.isGlob = true;
finished = true;
if (scanToEnd === true) {
continue;
}
break;
}
if (code === CHAR_QUESTION_MARK) {
isGlob = token.isGlob = true;
finished = true;
if (scanToEnd === true) {
continue;
}
break;
}
if (code === CHAR_LEFT_SQUARE_BRACKET) {
while (eos() !== true && (next = advance())) {
if (next === CHAR_BACKWARD_SLASH) {
backslashes = token.backslashes = true;
advance();
continue;
}
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
isBracket = token.isBracket = true;
isGlob = token.isGlob = true;
finished = true;
break;
}
}
if (scanToEnd === true) {
continue;
}
break;
}
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
negated = token.negated = true;
start++;
continue;
}
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
isGlob = token.isGlob = true;
if (scanToEnd === true) {
while (eos() !== true && (code = advance())) {
if (code === CHAR_LEFT_PARENTHESES) {
backslashes = token.backslashes = true;
code = advance();
continue;
}
if (code === CHAR_RIGHT_PARENTHESES) {
finished = true;
break;
}
}
continue;
}
break;
}
if (isGlob === true) {
finished = true;
if (scanToEnd === true) {
continue;
}
break;
}
}
if (opts.noext === true) {
isExtglob = false;
isGlob = false;
}
let base = str;
let prefix = "";
let glob = "";
if (start > 0) {
prefix = str.slice(0, start);
str = str.slice(start);
lastIndex -= start;
}
if (base && isGlob === true && lastIndex > 0) {
base = str.slice(0, lastIndex);
glob = str.slice(lastIndex);
} else if (isGlob === true) {
base = "";
glob = str;
} else {
base = str;
}
if (base && base !== "" && base !== "/" && base !== str) {
if (isPathSeparator(base.charCodeAt(base.length - 1))) {
base = base.slice(0, -1);
}
}
if (opts.unescape === true) {
if (glob) glob = utils.removeBackslashes(glob);
if (base && backslashes === true) {
base = utils.removeBackslashes(base);
}
}
const state = {
prefix,
input,
start,
base,
glob,
isBrace,
isBracket,
isGlob,
isExtglob,
isGlobstar,
negated,
negatedExtglob
};
if (opts.tokens === true) {
state.maxDepth = 0;
if (!isPathSeparator(code)) {
tokens.push(token);
}
state.tokens = tokens;
}
if (opts.parts === true || opts.tokens === true) {
let prevIndex;
for (let idx = 0; idx < slashes.length; idx++) {
const n = prevIndex ? prevIndex + 1 : start;
const i = slashes[idx];
const value2 = input.slice(n, i);
if (opts.tokens) {
if (idx === 0 && start !== 0) {
tokens[idx].isPrefix = true;
tokens[idx].value = prefix;
} else {
tokens[idx].value = value2;
}
depth(tokens[idx]);
state.maxDepth += tokens[idx].depth;
}
if (idx !== 0 || value2 !== "") {
parts.push(value2);
}
prevIndex = i;
}
if (prevIndex && prevIndex + 1 < input.length) {
const value2 = input.slice(prevIndex + 1);
parts.push(value2);
if (opts.tokens) {
tokens[tokens.length - 1].value = value2;
depth(tokens[tokens.length - 1]);
state.maxDepth += tokens[tokens.length - 1].depth;
}
}
state.slashes = slashes;
state.parts = parts;
}
return state;
};
module.exports = scan;
}
});
// ../../node_modules/picomatch/lib/parse.js
var require_parse = __commonJS({
"../../node_modules/picomatch/lib/parse.js"(exports, module) {
"use strict";
var constants = require_constants6();
var utils = require_utils();
var {
MAX_LENGTH,
POSIX_REGEX_SOURCE,
REGEX_NON_SPECIAL_CHARS,
REGEX_SPECIAL_CHARS_BACKREF,
REPLACEMENTS
} = constants;
var expandRange = (args, options) => {
if (typeof options.expandRange === "function") {
return options.expandRange(...args, options);
}
args.sort();
const value2 = `[${args.join("-")}]`;
try {
new RegExp(value2);
} catch (ex) {
return args.map((v) => utils.escapeRegex(v)).join("..");
}
return value2;
};
var syntaxError = (type, char) => {
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
};
var splitTopLevel = (input) => {
const parts = [];
let bracket = 0;
let paren = 0;
let quote = 0;
let value2 = "";
let escaped = false;
for (const ch of input) {
if (escaped === true) {
value2 += ch;
escaped = false;
continue;
}
if (ch === "\\") {
value2 += ch;
escaped = true;
continue;
}
if (ch === '"') {
quote = quote === 1 ? 0 : 1;
value2 += ch;
continue;
}
if (quote === 0) {
if (ch === "[") {
bracket++;
} else if (ch === "]" && bracket > 0) {
bracket--;
} else if (bracket === 0) {
if (ch === "(") {
paren++;
} else if (ch === ")" && paren > 0) {
paren--;
} else if (ch === "|" && paren === 0) {
parts.push(value2);
value2 = "";
continue;
}
}
}
value2 += ch;
}
parts.push(value2);
return parts;
};
var isPlainBranch = (branch) => {
let escaped = false;
for (const ch of branch) {
if (escaped === true) {
escaped = false;
continue;
}
if (ch === "\\") {
escaped = true;
continue;
}
if (/[?*+@!()[\]{}]/.test(ch)) {
return false;
}
}
return true;
};
var normalizeSimpleBranch = (branch) => {
let value2 = branch.trim();
let changed = true;
while (changed === true) {
changed = false;
if (/^@\([^\\()[\]{}|]+\)$/.test(value2)) {
value2 = value2.slice(2, -1);
changed = true;
}
}
if (!isPlainBranch(value2)) {
return;
}
return value2.replace(/\\(.)/g, "$1");
};
var hasRepeatedCharPrefixOverlap = (branches) => {
const values = branches.map(normalizeSimpleBranch).filter(Boolean);
for (let i = 0; i < values.length; i++) {
for (let j = i + 1; j < values.length; j++) {
const a = values[i];
const b = values[j];
const char = a[0];
if (!char || a !== char.repeat(a.length) || b !== char.repeat(b.length)) {
continue;
}
if (a === b || a.startsWith(b) || b.startsWith(a)) {
return true;
}
}
}
return false;
};
var parseRepeatedExtglob = (pattern, requireEnd = true) => {
if (pattern[0] !== "+" && pattern[0] !== "*" || pattern[1] !== "(") {
return;
}
let bracket = 0;
let paren = 0;
let quote = 0;
let escaped = false;
for (let i = 1; i < pattern.length; i++) {
const ch = pattern[i];
if (escaped === true) {
escaped = false;
continue;
}
if (ch === "\\") {
escaped = true;
continue;
}
if (ch === '"') {
quote = quote === 1 ? 0 : 1;
continue;
}
if (quote === 1) {
continue;
}
if (ch === "[") {
bracket++;
continue;
}
if (ch === "]" && bracket > 0) {
bracket--;
continue;
}
if (bracket > 0) {
continue;
}
if (ch === "(") {
paren++;
continue;
}
if (ch === ")") {
paren--;
if (paren === 0) {
if (requireEnd === true && i !== pattern.length - 1) {
return;
}
return {
type: pattern[0],
body: pattern.slice(2, i),
end: i
};
}
}
}
};
var getStarExtglobSequenceOutput = (pattern) => {
let index = 0;
const chars = [];
while (index < pattern.length) {
const match = parseRepeatedExtglob(pattern.slice(index), false);
if (!match || match.type !== "*") {
return;
}
const branches = splitTopLevel(match.body).map((branch2) => branch2.trim());
if (branches.length !== 1) {
return;
}
const branch = normalizeSimpleBranch(branches[0]);
if (!branch || branch.length !== 1) {
return;
}
chars.push(branch);
index += match.end + 1;
}
if (chars.length < 1) {
return;
}
const source = chars.length === 1 ? utils.escapeRegex(chars[0]) : `[${chars.map((ch) => utils.escapeRegex(ch)).join("")}]`;
return `${source}*`;
};
var repeatedExtglobRecursion = (pattern) => {
let depth = 0;
let value2 = pattern.trim();
let match = parseRepeatedExtglob(value2);
while (match) {
depth++;
value2 = match.body.trim();
match = parseRepeatedExtglob(value2);
}
return depth;
};
var analyzeRepeatedExtglob = (body, options) => {
if (options.maxExtglobRecursion === false) {
return { risky: false };
}
const max = typeof options.maxExtglobRecursion === "number" ? options.maxExtglobRecursion : constants.DEFAULT_MAX_EXTGLOB_RECURSION;
const branches = splitTopLevel(body).map((branch) => branch.trim());
if (branches.length > 1) {
if (branches.some((branch) => branch === "") || branches.some((branch) => /^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) {
return { risky: true };
}
}
for (const branch of branches) {
const safeOutput = getStarExtglobSequenceOutput(branch);
if (safeOutput) {
return { risky: true, safeOutput };
}
if (repeatedExtglobRecursion(branch) > max) {
return { risky: true };
}
}
return { risky: false };
};
var parse = (input, options) => {
if (typeof input !== "string") {
throw new TypeError("Expected a string");
}
input = REPLACEMENTS[input] || input;
const opts = { ...options };
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
let len = input.length;
if (len > max) {
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
}
const bos = { type: "bos", value: "", output: opts.prepend || "" };
const tokens = [bos];
const capture = opts.capture ? "" : "?:";
const PLATFORM_CHARS = constants.globChars(opts.windows);
const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
const {
DOT_LITERAL,
PLUS_LITERAL,
SLASH_LITERAL,
ONE_CHAR,
DOTS_SLASH,
NO_DOT,
NO_DOT_SLASH,
NO_DOTS_SLASH,
QMARK,
QMARK_NO_DOT,
STAR,
START_ANCHOR
} = PLATFORM_CHARS;
const globstar = (opts2) => {
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
};
const nodot = opts.dot ? "" : NO_DOT;
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
let star = opts.bash === true ? globstar(opts) : STAR;
if (opts.capture) {
star = `(${star})`;
}
if (typeof opts.noext === "boolean") {
opts.noextglob = opts.noext;
}
const state = {
input,
index: -1,
start: 0,
dot: opts.dot === true,
consumed: "",
output: "",
prefix: "",
backtrack: false,
negated: false,
brackets: 0,
braces: 0,
parens: 0,
quotes: 0,
globstar: false,
tokens
};
input = utils.removePrefix(input, state);
len = input.length;
const extglobs = [];
const braces = [];
const stack = [];
let prev = bos;
let value2;
const eos = () => state.index === len - 1;
const peek = state.peek = (n = 1) => input[state.index + n];
const advance = state.advance = () => input[++state.index] || "";
const remaining = () => input.slice(state.index + 1);
const consume = (value3 = "", num = 0) => {
state.consumed += value3;
state.index += num;
};
const append = (token) => {
state.output += token.output != null ? token.output : token.value;
consume(token.value);
};
const negate = () => {
let count = 1;
while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
advance();
state.start++;
count++;
}
if (count % 2 === 0) {
return false;
}
state.negated = true;
state.start++;
return true;
};
const increment = (type) => {
state[type]++;
stack.push(type);
};
const decrement = (type) => {
state[type]--;
stack.pop();
};
const push = (tok) => {
if (prev.type === "globstar") {
const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
state.output = state.output.slice(0, -prev.output.length);
prev.type = "star";
prev.value = "*";
prev.output = star;
state.output += prev.output;
}
}
if (extglobs.length && tok.type !== "paren") {
extglobs[extglobs.length - 1].inner += tok.value;
}
if (tok.value || tok.output) append(tok);
if (prev && prev.type === "text" && tok.type === "text") {
prev.output = (prev.output || prev.value) + tok.value;
prev.value += tok.value;
return;
}
tok.prev = prev;
tokens.push(tok);
prev = tok;
};
const extglobOpen = (type, value3) => {
const token = { ...EXTGLOB_CHARS[value3], conditions: 1, inner: "" };
token.prev = prev;
token.parens = state.parens;
token.output = state.output;
token.startIndex = state.index;
token.tokensIndex = tokens.length;
const output = (opts.capture ? "(" : "") + token.open;
increment("parens");
push({ type, value: value3, output: state.output ? "" : ONE_CHAR });
push({ type: "paren", extglob: true, value: advance(), output });
extglobs.push(token);
};
const extglobClose = (token) => {
const literal = input.slice(token.startIndex, state.index + 1);
const body = input.slice(token.startIndex + 2, state.index);
const analysis = analyzeRepeatedExtglob(body, opts);
if ((token.type === "plus" || token.type === "star") && analysis.risky) {
const safeOutput = analysis.safeOutput ? (token.output ? "" : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : void 0;
const open = tokens[token.tokensIndex];
open.type = "text";
open.value = literal;
open.output = safeOutput || utils.escapeRegex(literal);
for (let i = token.tokensIndex + 1; i < tokens.length; i++) {
tokens[i].value = "";
tokens[i].output = "";
delete tokens[i].suffix;
}
state.output = token.output + open.output;
state.backtrack = true;
push({ type: "paren", extglob: true, value: value2, output: "" });
decrement("parens");
return;
}
let output = token.close + (opts.capture ? ")" : "");
let rest;
if (token.type === "negate") {
let extglobStar = star;
if (token.inner && token.inner.length > 1 && token.inner.includes("/")) {
extglobStar = globstar(opts);
}
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
output = token.close = `)$))${extglobStar}`;
}
if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
const expression = parse(rest, { ...options, fastpaths: false }).output;
output = token.close = `)${expression})${extglobStar})`;
}
if (token.prev.type === "bos") {
state.negatedExtglob = true;
}
}
push({ type: "paren", extglob: true, value: value2, output });
decrement("parens");
};
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
let backslashes = false;
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
if (first === "\\") {
backslashes = true;
return m;
}
if (first === "?") {
if (esc) {
return esc + first + (rest ? QMARK.repeat(rest.length) : "");
}
if (index === 0) {
return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : "");
}
return QMARK.repeat(chars.length);
}
if (first === ".") {
return DOT_LITERAL.repeat(chars.length);
}
if (first === "*") {
if (esc) {
return esc + first + (rest ? star : "");
}
return star;
}
return esc ? m : `\\${m}`;
});
if (backslashes === true) {
if (opts.unescape === true) {
output = output.replace(/\\/g, "");
} else {
output = output.replace(/\\+/g, (m) => {
return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
});
}
}
if (output === input && opts.contains === true) {
state.output = input;
return state;
}
state.output = utils.wrapOutput(output, state, options);
return state;
}
while (!eos()) {
value2 = advance();
if (value2 === "\0") {
continue;
}
if (value2 === "\\") {
const next = peek();
if (next === "/" && opts.bash !== true) {
continue;
}
if (next === "." || next === ";") {
continue;
}
if (!next) {
value2 += "\\";
push({ type: "text", value: value2 });
continue;
}
const match = /^\\+/.exec(remaining());
let slashes = 0;
if (match && match[0].length > 2) {
slashes = match[0].length;
state.index += slashes;
if (slashes % 2 !== 0) {
value2 += "\\";
}
}
if (opts.unescape === true) {
value2 = advance();
} else {
value2 += advance();
}
if (state.brackets === 0) {
push({ type: "text", value: value2 });
continue;
}
}
if (state.brackets > 0 && (value2 !== "]" || prev.value === "[" || prev.value === "[^")) {
if (opts.posix !== false && value2 === ":") {
const inner = prev.value.slice(1);
if (inner.includes("[")) {
prev.posix = true;
if (inner.includes(":")) {
const idx = prev.value.lastIndexOf("[");
const pre = prev.value.slice(0, idx);
const rest2 = prev.value.slice(idx + 2);
const posix = POSIX_REGEX_SOURCE[rest2];
if (posix) {
prev.value = pre + posix;
state.backtrack = true;
advance();
if (!bos.output && tokens.indexOf(prev) === 1) {
bos.output = ONE_CHAR;
}
continue;
}
}
}
}
if (value2 === "[" && peek() !== ":" || value2 === "-" && peek() === "]") {
value2 = `\\${value2}`;
}
if (value2 === "]" && (prev.value === "[" || prev.value === "[^")) {
value2 = `\\${value2}`;
}
if (opts.posix === true && value2 === "!" && prev.value === "[") {
value2 = "^";
}
prev.value += value2;
append({ value: value2 });
continue;
}
if (state.quotes === 1 && value2 !== '"') {
value2 = utils.escapeRegex(value2);
prev.value += value2;
append({ value: value2 });
continue;
}
if (value2 === '"') {
state.quotes = state.quotes === 1 ? 0 : 1;
if (opts.keepQuotes === true) {
push({ type: "text", value: value2 });
}
continue;
}
if (value2 === "(") {
increment("parens");
push({ type: "paren", value: value2 });
continue;
}
if (value2 === ")") {
if (state.parens === 0 && opts.strictBrackets === true) {
throw new SyntaxError(syntaxError("opening", "("));
}
const extglob = extglobs[extglobs.length - 1];
if (extglob && state.parens === extglob.parens + 1) {
extglobClose(extglobs.pop());
continue;
}
push({ type: "paren", value: value2, output: state.parens ? ")" : "\\)" });
decrement("parens");
continue;
}
if (value2 === "[") {
if (opts.nobracket === true || !remaining().includes("]")) {
if (opts.nobracket !== true && opts.strictBrackets === true) {
throw new SyntaxError(syntaxError("closing", "]"));
}
value2 = `\\${value2}`;
} else {
increment("brackets");
}
push({ type: "bracket", value: value2 });
continue;
}
if (value2 === "]") {
if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
push({ type: "text", value: value2, output: `\\${value2}` });
continue;
}
if (state.brackets === 0) {
if (opts.strictBrackets === true) {
throw new SyntaxError(syntaxError("opening", "["));
}
push({ type: "text", value: value2, output: `\\${value2}` });
continue;
}
decrement("brackets");
const prevValue = prev.value.slice(1);
if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) {
value2 = `/${value2}`;
}
prev.value += value2;
append({ value: value2 });
if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
continue;
}
const escaped = utils.escapeRegex(prev.value);
state.output = state.output.slice(0, -prev.value.length);
if (opts.literalBrackets === true) {
state.output += escaped;
prev.value = escaped;
continue;
}
prev.value = `(${capture}${escaped}|${prev.value})`;
state.output += prev.value;
continue;
}
if (value2 === "{" && opts.nobrace !== true) {
increment("braces");
const open = {
type: "brace",
value: value2,
output: "(",
outputIndex: state.output.length,
tokensIndex: state.tokens.length
};
braces.push(open);
push(open);
continue;
}
if (value2 === "}") {
const brace = braces[braces.length - 1];
if (opts.nobrace === true || !brace) {
push({ type: "text", value: value2, output: value2 });
continue;
}
let output = ")";
if (brace.dots === true) {
const arr = tokens.slice();
const range = [];
for (let i = arr.length - 1; i >= 0; i--) {
tokens.pop();
if (arr[i].type === "brace") {
break;
}
if (arr[i].type !== "dots") {
range.unshift(arr[i].value);
}
}
output = expandRange(range, opts);
state.backtrack = true;
}
if (brace.comma !== true && brace.dots !== true) {
const out = state.output.slice(0, brace.outputIndex);
const toks = state.tokens.slice(brace.tokensIndex);
brace.value = brace.output = "\\{";
value2 = output = "\\}";
state.output = out;
for (const t of toks) {
state.output += t.output || t.value;
}
}
push({ type: "brace", value: value2, output });
decrement("braces");
braces.pop();
continue;
}
if (value2 === "|") {
if (extglobs.length > 0) {
extglobs[extglobs.length - 1].conditions++;
}
push({ type: "text", value: value2 });
continue;
}
if (value2 === ",") {
let output = value2;
const brace = braces[braces.length - 1];
if (brace && stack[stack.length - 1] === "braces") {
brace.comma = true;
output = "|";
}
push({ type: "comma", value: value2, output });
continue;
}
if (value2 === "/") {
if (prev.type === "dot" && state.index === state.start + 1) {
state.start = state.index + 1;
state.consumed = "";
state.output = "";
tokens.pop();
prev = bos;
continue;
}
push({ type: "slash", value: value2, output: SLASH_LITERAL });
continue;
}
if (value2 === ".") {
if (state.braces > 0 && prev.type === "dot") {
if (prev.value === ".") prev.output = DOT_LITERAL;
const brace = braces[braces.length - 1];
prev.type = "dots";
prev.output += value2;
prev.value += value2;
brace.dots = true;
continue;
}
if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
push({ type: "text", value: value2, output: DOT_LITERAL });
continue;
}
push({ type: "dot", value: value2, output: DOT_LITERAL });
continue;
}
if (value2 === "?") {
const isGroup = prev && prev.value === "(";
if (!isGroup && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
extglobOpen("qmark", value2);
continue;
}
if (prev && prev.type === "paren") {
const next = peek();
let output = value2;
if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) {
output = `\\${value2}`;
}
push({ type: "text", value: value2, output });
continue;
}
if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
push({ type: "qmark", value: value2, output: QMARK_NO_DOT });
continue;
}
push({ type: "qmark", value: value2, output: QMARK });
continue;
}
if (value2 === "!") {
if (opts.noextglob !== true && peek() === "(") {
if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
extglobOpen("negate", value2);
continue;
}
}
if (opts.nonegate !== true && state.index === 0) {
negate();
continue;
}
}
if (value2 === "+") {
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
extglobOpen("plus", value2);
continue;
}
if (prev && prev.value === "(" || opts.regex === false) {
push({ type: "plus", value: value2, output: PLUS_LITERAL });
continue;
}
if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
push({ type: "plus", value: value2 });
continue;
}
push({ type: "plus", value: PLUS_LITERAL });
continue;
}
if (value2 === "@") {
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
push({ type: "at", extglob: true, value: value2, output: "" });
continue;
}
push({ type: "text", value: value2 });
continue;
}
if (value2 !== "*") {
if (value2 === "$" || value2 === "^") {
value2 = `\\${value2}`;
}
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
if (match) {
value2 += match[0];
state.index += match[0].length;
}
push({ type: "text", value: value2 });
continue;
}
if (prev && (prev.type === "globstar" || prev.star === true)) {
prev.type = "star";
prev.star = true;
prev.value += value2;
prev.output = star;
state.backtrack = true;
state.globstar = true;
consume(value2);
continue;
}
let rest = remaining();
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
extglobOpen("star", value2);
continue;
}
if (prev.type === "star") {
if (opts.noglobstar === true) {
consume(value2);
continue;
}
const prior = prev.prev;
const before = prior.prev;
const isStart = prior.type === "slash" || prior.type === "bos";
const afterStar = before && (before.type === "star" || before.type === "globstar");
if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
push({ type: "star", value: value2, output: "" });
continue;
}
const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
push({ type: "star", value: value2, output: "" });
continue;
}
while (rest.slice(0, 3) === "/**") {
const after = input[state.index + 4];
if (after && after !== "/") {
break;
}
rest = rest.slice(3);
consume("/**", 3);
}
if (prior.type === "bos" && eos()) {
prev.type = "globstar";
prev.value += value2;
prev.output = globstar(opts);
state.output = prev.output;
state.globstar = true;
consume(value2);
continue;
}
if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
state.output = state.output.slice(0, -(prior.output + prev.output).length);
prior.output = `(?:${prior.output}`;
prev.type = "globstar";
prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
prev.value += value2;
state.globstar = true;
state.output += prior.output + prev.output;
consume(value2);
continue;
}
if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
const end = rest[1] !== void 0 ? "|$" : "";
state.output = state.output.slice(0, -(prior.output + prev.output).length);
prior.output = `(?:${prior.output}`;
prev.type = "globstar";
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
prev.value += value2;
state.output += prior.output + prev.output;
state.globstar = true;
consume(value2 + advance());
push({ type: "slash", value: "/", output: "" });
continue;
}
if (prior.type === "bos" && rest[0] === "/") {
prev.type = "globstar";
prev.value += value2;
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
state.output = prev.output;
state.globstar = true;
consume(value2 + advance());
push({ type: "slash", value: "/", output: "" });
continue;
}
state.output = state.output.slice(0, -prev.output.length);
prev.type = "globstar";
prev.output = globstar(opts);
prev.value += value2;
state.output += prev.output;
state.globstar = true;
consume(value2);
continue;
}
const token = { type: "star", value: value2, output: star };
if (opts.bash === true) {
token.output = ".*?";
if (prev.type === "bos" || prev.type === "slash") {
token.output = nodot + token.output;
}
push(token);
continue;
}
if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
token.output = value2;
push(token);
continue;
}
if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
if (prev.type === "dot") {
state.output += NO_DOT_SLASH;
prev.output += NO_DOT_SLASH;
} else if (opts.dot === true) {
state.output += NO_DOTS_SLASH;
prev.output += NO_DOTS_SLASH;
} else {
state.output += nodot;
prev.output += nodot;
}
if (peek() !== "*") {
state.output += ONE_CHAR;
prev.output += ONE_CHAR;
}
}
push(token);
}
while (state.brackets > 0) {
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
state.output = utils.escapeLast(state.output, "[");
decrement("brackets");
}
while (state.parens > 0) {
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
state.output = utils.escapeLast(state.output, "(");
decrement("parens");
}
while (state.braces > 0) {
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
state.output = utils.escapeLast(state.output, "{");
decrement("braces");
}
if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) {
push({ type: "maybe_slash", value: "", output: `${SLASH_LITERAL}?` });
}
if (state.backtrack === true) {
state.output = "";
for (const token of state.tokens) {
state.output += token.output != null ? token.output : token.value;
if (token.suffix) {
state.output += token.suffix;
}
}
}
return state;
};
parse.fastpaths = (input, options) => {
const opts = { ...options };
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
const len = input.length;
if (len > max) {
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
}
input = REPLACEMENTS[input] || input;
const {
DOT_LITERAL,
SLASH_LITERAL,
ONE_CHAR,
DOTS_SLASH,
NO_DOT,
NO_DOTS,
NO_DOTS_SLASH,
STAR,
START_ANCHOR
} = constants.globChars(opts.windows);
const nodot = opts.dot ? NO_DOTS : NO_DOT;
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
const capture = opts.capture ? "" : "?:";
const state = { negated: false, prefix: "" };
let star = opts.bash === true ? ".*?" : STAR;
if (opts.capture) {
star = `(${star})`;
}
const globstar = (opts2) => {
if (opts2.noglobstar === true) return star;
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
};
const create = (str) => {
switch (str) {
case "*":
return `${nodot}${ONE_CHAR}${star}`;
case ".*":
return `${DOT_LITERAL}${ONE_CHAR}${star}`;
case "*.*":
return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
case "*/*":
return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
case "**":
return nodot + globstar(opts);
case "**/*":
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
case "**/*.*":
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
case "**/.*":
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
default: {
const match = /^(.*?)\.(\w+)$/.exec(str);
if (!match) return;
const source2 = create(match[1]);
if (!source2) return;
return source2 + DOT_LITERAL + match[2];
}
}
};
const output = utils.removePrefix(input, state);
let source = create(output);
if (source && opts.strictSlashes !== true) {
source += `${SLASH_LITERAL}?`;
}
return source;
};
module.exports = parse;
}
});
// ../../node_modules/picomatch/lib/picomatch.js
var require_picomatch = __commonJS({
"../../node_modules/picomatch/lib/picomatch.js"(exports, module) {
"use strict";
var scan = require_scan();
var parse = require_parse();
var utils = require_utils();
var constants = require_constants6();
var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
var picomatch = (glob, options, returnState = false) => {
if (Array.isArray(glob)) {
const fns = glob.map((input) => picomatch(input, options, returnState));
const arrayMatcher = (str) => {
for (const isMatch of fns) {
const state2 = isMatch(str);
if (state2) return state2;
}
return false;
};
return arrayMatcher;
}
const isState = isObject(glob) && glob.tokens && glob.input;
if (glob === "" || typeof glob !== "string" && !isState) {
throw new TypeError("Expected pattern to be a non-empty string");
}
const opts = options || {};
const posix = opts.windows;
const regex = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true);
const state = regex.state;
delete regex.state;
let isIgnored = () => false;
if (opts.ignore) {
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
}
const matcher = (input, returnObject = false) => {
const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix });
const result = { glob, state, regex, posix, input, output, match, isMatch };
if (typeof opts.onResult === "function") {
opts.onResult(result);
}
if (isMatch === false) {
result.isMatch = false;
return returnObject ? result : false;
}
if (isIgnored(input)) {
if (typeof opts.onIgnore === "function") {
opts.onIgnore(result);
}
result.isMatch = false;
return returnObject ? result : false;
}
if (typeof opts.onMatch === "function") {
opts.onMatch(result);
}
return returnObject ? result : true;
};
if (returnState) {
matcher.state = state;
}
return matcher;
};
picomatch.test = (input, regex, options, { glob, posix } = {}) => {
if (typeof input !== "string") {
throw new TypeError("Expected input to be a string");
}
if (input === "") {
return { isMatch: false, output: "" };
}
const opts = options || {};
const format = opts.format || (posix ? utils.toPosixSlashes : null);
let match = input === glob;
let output = match && format ? format(input) : input;
if (match === false) {
output = format ? format(input) : input;
match = output === glob;
}
if (match === false || opts.capture === true) {
if (opts.matchBase === true || opts.basename === true) {
match = picomatch.matchBase(input, regex, options, posix);
} else {
match = regex.exec(output);
}
}
return { isMatch: Boolean(match), match, output };
};
picomatch.matchBase = (input, glob, options) => {
const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
return regex.test(utils.basename(input));
};
picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
picomatch.parse = (pattern, options) => {
if (Array.isArray(pattern)) return pattern.map((p) => picomatch.parse(p, options));
return parse(pattern, { ...options, fastpaths: false });
};
picomatch.scan = (input, options) => scan(input, options);
picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
if (returnOutput === true) {
return state.output;
}
const opts = options || {};
const prepend = opts.contains ? "" : "^";
const append = opts.contains ? "" : "$";
let source = `${prepend}(?:${state.output})${append}`;
if (state && state.negated === true) {
source = `^(?!${source}).*$`;
}
const regex = picomatch.toRegex(source, options);
if (returnState === true) {
regex.state = state;
}
return regex;
};
picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
if (!input || typeof input !== "string") {
throw new TypeError("Expected a non-empty string");
}
let parsed = { negated: false, fastpaths: true };
if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) {
parsed.output = parse.fastpaths(input, options);
}
if (!parsed.output) {
parsed = parse(input, options);
}
return picomatch.compileRe(parsed, options, returnOutput, returnState);
};
picomatch.toRegex = (source, options) => {
try {
const opts = options || {};
return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
} catch (err) {
if (options && options.debug === true) throw err;
return /$^/;
}
};
picomatch.constants = constants;
module.exports = picomatch;
}
});
// ../../node_modules/picomatch/index.js
var require_picomatch2 = __commonJS({
"../../node_modules/picomatch/index.js"(exports, module) {
"use strict";
var pico = require_picomatch();
var utils = require_utils();
function picomatch(glob, options, returnState = false) {
if (options && (options.windows === null || options.windows === void 0)) {
options = { ...options, windows: utils.isWindows() };
}
return pico(glob, options, returnState);
}
Object.assign(picomatch, pico);
module.exports = picomatch;
}
});
// ../../node_modules/bare-cov/lib/test-exclude.js
var require_test_exclude = __commonJS({
"../../node_modules/bare-cov/lib/test-exclude.js"(exports, module) {
var { isWindows } = require_which_runtime();
var path = __require("path");
var process2 = __require("process");
var picomatch = require_picomatch2();
var DEFAULT_EXCLUDES = [
"coverage/**",
"packages/*/test{,s}/**",
"**/*.d.ts",
"test{,s}/**",
"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}",
"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}",
"**/__tests__/**",
"**/{ava,babel,nyc}.config.{js,cjs,mjs}",
"**/jest.config.{js,cjs,mjs,ts}",
"**/{karma,rollup,webpack}.config.js",
"**/.{eslint,mocha}rc.{js,cjs}"
];
var DEFAULT_EXTENSIONS = [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx"];
function isOutsideDir(dir, filename) {
return isWindows ? !path.resolve(dir, filename).startsWith(path.resolve(dir) + path.sep) : /^\.\./.test(path.relative(dir, filename));
}
var TestExclude = class {
constructor(opts = {}) {
this.cwd = opts.cwd ?? process2.cwd();
this.include = opts.include ?? [];
this.exclude = opts.exclude ?? DEFAULT_EXCLUDES;
this.extension = opts.extension ?? DEFAULT_EXTENSIONS;
this.excludeNodeModules = opts.excludeNodeModules || true;
this.relativePath = opts.relativePath || true;
if (typeof this.include === "string") this.include = [this.include];
if (typeof this.exclude === "string") this.exclude = [this.exclude];
if (typeof this.extension === "string") this.extension = [this.extension];
else if (this.extension.length === 0) this.extension = false;
if (this.include && this.include.length > 0)
this.include = prepGlobPatterns([].concat(this.include));
else this.include = false;
if (this.excludeNodeModules && !this.exclude.includes("**/node_modules/**"))
this.exclude = this.exclude.concat("**/node_modules/**");
this.exclude = prepGlobPatterns([].concat(this.exclude));
this.handleNegation();
}
/* handle the special case of negative globs
* (!**foo/bar); we create a new this.excludeNegated set
* of rules, which is applied after excludes and we
* move excluded include rules into this.excludes.
*/
handleNegation() {
const noNeg = (e) => e.charAt(0) !== "!";
const onlyNeg = (e) => e.charAt(0) === "!";
const stripNeg = (e) => e.slice(1);
if (Array.isArray(this.include)) {
const includeNegated = this.include.filter(onlyNeg).map(stripNeg);
this.exclude.push(...prepGlobPatterns(includeNegated));
this.include = this.include.filter(noNeg);
}
this.excludeNegated = this.exclude.filter(onlyNeg).map(stripNeg);
this.exclude = this.exclude.filter(noNeg);
this.excludeNegated = prepGlobPatterns(this.excludeNegated);
}
shouldInstrument(filename, relFile) {
if (this.extension && !this.extension.some((ext) => filename.endsWith(ext))) return false;
let pathToCheck = filename;
if (this.relativePath) {
relFile = relFile || path.relative(this.cwd, filename);
if (isOutsideDir(this.cwd, filename)) return false;
pathToCheck = relFile.replace(/^\.[\\/]/, "");
}
const dot = { dot: true, windows: isWindows };
const matches = (pattern) => picomatch.isMatch(pathToCheck, pattern, dot);
return (!this.include || this.include.some(matches)) && (!this.exclude.some(matches) || this.excludeNegated.some(matches));
}
};
function prepGlobPatterns(patterns) {
return patterns.reduce((result, pattern) => {
if (!/\/\*\*$/.test(pattern)) result = result.concat(pattern.replace(/\/$/, "") + "/**");
if (/^\*\*\//.test(pattern)) result = result.concat(pattern.replace(/^\*\*\//, ""));
return result.concat(pattern);
}, []);
}
module.exports = TestExclude;
}
});
// ../../node_modules/bare-cov/lib/summarize.js
var require_summarize = __commonJS({
"../../node_modules/bare-cov/lib/summarize.js"(exports, module) {
function summarizeFileCoverage(file) {
const summary = {
total: { statements: 0, branches: 0, functions: 0, lines: 0 },
covered: { statements: 0, branches: 0, functions: 0, lines: 0 },
uncovered: { lines: [] }
};
if (file.s) {
const statements = Object.values(file.s);
summary.total.statements = statements.length;
summary.covered.statements = statements.filter((hitCount) => hitCount > 0).length;
}
if (file.b) {
for (const branch of Object.values(file.b)) {
summary.total.branches += branch.length;
summary.covered.branches += branch.filter((hitCount) => hitCount > 0).length;
}
}
if (file.f) {
const functions = Object.values(file.f);
summary.total.functions = functions.length;
summary.covered.functions = functions.filter((hitCount) => hitCount > 0).length;
}
let lineCoverage = file.l;
if (!lineCoverage && file.s && file.statementMap) {
lineCoverage = {};
for (const [statementId, hitCount] of Object.entries(file.s)) {
const statementInfo = file.statementMap[statementId];
if (!statementInfo) continue;
const { line } = statementInfo.start;
const lastCount = lineCoverage[line];
if (lastCount === void 0 || lastCount < hitCount) lineCoverage[line] = hitCount;
}
}
const lines = Object.entries(lineCoverage);
summary.total.lines = lines.length;
for (const [line, hitCount] of lines) {
if (hitCount > 0) summary.covered.lines++;
else summary.uncovered.lines.push(line);
}
return summary;
}
module.exports = function summarizeCoverage(coverageData) {
const summary = {
total: { statements: 0, branches: 0, functions: 0, lines: 0 },
covered: { statements: 0, branches: 0, functions: 0, lines: 0 }
};
const fileSummaries = {};
for (const [filename, file] of Object.entries(coverageData)) {
const fileSummary = fileSummaries[filename] = summarizeFileCoverage(file);
summary.total.statements += fileSummary.total.statements;
summary.covered.statements += fileSummary.covered.statements;
summary.total.branches += fileSummary.total.branches;
summary.covered.branches += fileSummary.covered.branches;
summary.total.functions += fileSummary.total.functions;
summary.covered.functions += fileSummary.covered.functions;
summary.total.lines += fileSummary.total.lines;
summary.covered.lines += fileSummary.covered.lines;
}
return {
summary,
fileSummaries
};
};
}
});
// ../../node_modules/bare-cov/lib/report.js
var require_report = __commonJS({
"../../node_modules/bare-cov/lib/report.js"(exports, module) {
var path = __require("path");
var process2 = __require("process");
var PERCENT_WIDTH = 9;
var DIR_INDENT = 1;
var FILE_INDENT = 2;
var TERMINAL_WIDTH = process2?.stdout?.columns ?? 80;
var STATIC_WIDTH = PERCENT_WIDTH * 4 + 6;
var MIN_NAME_WIDTH = 5;
var MIN_UNCOVERED_WIDTH = 17;
function findCommonPath(paths) {
const getCommon = (a, b) => {
let i = 0;
while (i < a.length && i < b.length && a[i] === b[i]) i++;
return a.slice(0, i);
};
if (!paths || paths.length === 0) return [];
const splitPaths = paths.map((p) => p.split(path.sep));
return splitPaths.slice(1).reduce((acc, path2) => {
return getCommon(acc, path2);
}, splitPaths[0]);
}
function truncate(str, width, right = false, delimiter = null) {
if (str.length <= width) return str;
let truncateAt = right ? str.length - width + 1 : width - 1;
if (delimiter) {
const nextSeparatorIndex = right ? str.indexOf(delimiter, truncateAt) : str.lastIndexOf(delimiter, truncateAt - 1);
if (nextSeparatorIndex === -1) return "\u2026";
truncateAt = right ? nextSeparatorIndex : nextSeparatorIndex + 1;
}
return right ? "\u2026" + str.slice(truncateAt) : str.slice(0, truncateAt) + "\u2026";
}
function toPercent(covered, total) {
if (total === 0 || covered === total) return "100";
if (covered === 0) return "0";
return (covered / total * 100).toFixed(2);
}
function ntimes(n, str) {
return Array(n).fill(str).join("");
}
function pad(str, width, right) {
if (str.length >= width) return str;
const fill = ntimes(width - str.length, " ");
return right ? str + fill : fill + str;
}
function rowSeparator(nameWidth, uncoveredWidth) {
const name = ntimes(nameWidth, "-");
const uncovered = ntimes(uncoveredWidth, "-");
const percent = ntimes(PERCENT_WIDTH, "-");
const branch = ntimes(PERCENT_WIDTH + 1, "-");
return [name, percent, branch, percent, percent, uncovered].join("|");
}
function printHeader(nameWidth, uncoveredWidth) {
const name = pad("File", nameWidth, true);
const unc = pad(truncate("Uncovered Line #s", uncoveredWidth - 1), uncoveredWidth - 1, true);
console.log(`${name}| % Stmts | % Branch | % Funcs | % Lines | ${unc}`);
}
function printRow(fileSummary, fileName, nameWidth, uncoveredWidth) {
const statements = toPercent(fileSummary.covered.statements, fileSummary.total.statements);
const branches = toPercent(fileSummary.covered.branches, fileSummary.total.branches);
const functions = toPercent(fileSummary.covered.functions, fileSummary.total.functions);
const lines = toPercent(fileSummary.covered.lines, fileSummary.total.lines);
const uncoveredLines = fileSummary?.uncovered?.normalizedLines ? fileSummary.uncovered.normalizedLines : " ";
console.log(
[
pad(` ${truncate(fileName, nameWidth - 2)} `, nameWidth, true),
pad(` ${statements} `, PERCENT_WIDTH),
pad(` ${branches} `, PERCENT_WIDTH + 1),
pad(` ${functions} `, PERCENT_WIDTH),
pad(` ${lines} `, PERCENT_WIDTH),
pad(` ${truncate(uncoveredLines, uncoveredWidth - 2, true, ",")} `, uncoveredWidth, true)
].join("|")
);
}
function deriveWidths(groupedSummaries) {
let nameWidth = MIN_NAME_WIDTH;
let uncoveredWidth = MIN_UNCOVERED_WIDTH;
for (const [dirName, dirSummary] of Object.entries(groupedSummaries)) {
if (dirName.length + DIR_INDENT > nameWidth) nameWidth = dirName.length + DIR_INDENT;
for (const [fileName, fileSummary] of Object.entries(dirSummary.files)) {
const normalizedLines = fileSummary.uncovered?.normalizedLines;
if (fileName.length + FILE_INDENT > nameWidth) nameWidth = fileName.length + FILE_INDENT;
if (normalizedLines && normalizedLines.length > uncoveredWidth)
uncoveredWidth = normalizedLines.length;
}
}
nameWidth += 2;
uncoveredWidth += 2;
if (nameWidth + uncoveredWidth + STATIC_WIDTH > TERMINAL_WIDTH) {
const availableWidth = TERMINAL_WIDTH - STATIC_WIDTH;
nameWidth = Math.floor(availableWidth / 2);
uncoveredWidth = availableWidth - nameWidth;
}
return { nameWidth, uncoveredWidth };
}
function normalizeUncoveredLines(uncoveredLines) {
if (!uncoveredLines || uncoveredLines.length === 0) return "";
const lines = uncoveredLines.map((line) => Number(line)).sort((a, b) => a - b);
const ranges = [];
let start = lines[0];
let end = start;
for (let i = 1; i < lines.length; i++) {
if (lines[i] === end + 1) {
end = lines[i];
continue;
}
ranges.push(start === end ? `${start}` : `${start}-${end}`);
start = lines[i];
end = start;
}
ranges.push(start === end ? `${start}` : `${start}-${end}`);
return ranges.join(",");
}
function addCoverages(a, b) {
a.covered.statements += b.covered.statements;
a.covered.branches += b.covered.branches;
a.covered.functions += b.covered.functions;
a.covered.lines += b.covered.lines;
a.total.statements += b.total.statements;
a.total.branches += b.total.branches;
a.total.functions += b.total.functions;
a.total.lines += b.total.lines;
}
function groupByDirectory(fileSummaries) {
const commonPath = findCommonPath(Object.keys(fileSummaries)).join(path.sep);
const commonDir = path.basename(commonPath);
const directories = {};
for (const [filePath, summary] of Object.entries(fileSummaries)) {
const relativePath = path.relative(commonPath, filePath).replace(/^\.\//g, "");
const pathName = path.join(commonDir, relativePath);
const directory = path.dirname(pathName);
const file = path.basename(pathName);
if (!directories[directory]) {
directories[directory] = {
files: {},
coverage: {
total: { statements: 0, branches: 0, functions: 0, lines: 0 },
covered: { statements: 0, branches: 0, functions: 0, lines: 0 }
}
};
}
directories[directory].files[file] = summary;
addCoverages(directories[directory].coverage, summary);
}
return directories;
}
function printBody(grouped, nameWidth, uncoveredWidth) {
for (const [dirName, dirSummary] of Object.entries(grouped)) {
printRow(dirSummary.coverage, `${ntimes(DIR_INDENT, " ")}${dirName}`, nameWidth, uncoveredWidth);
for (const [fileName, fileSummary] of Object.entries(dirSummary.files)) {
printRow(fileSummary, `${ntimes(FILE_INDENT, " ")}${fileName}`, nameWidth, uncoveredWidth);
}
}
}
module.exports = function reportCoverage({ summary, fileSummaries }) {
Object.values(fileSummaries).forEach((fileSummary) => {
fileSummary.uncovered.normalizedLines = normalizeUncoveredLines(fileSummary.uncovered.lines);
});
const grouped = groupByDirectory(fileSummaries);
const { nameWidth, uncoveredWidth } = deriveWidths(grouped);
const separator = rowSeparator(nameWidth, uncoveredWidth);
const printSeparator = () => console.log(separator);
printSeparator();
printHeader(nameWidth, uncoveredWidth);
printSeparator();
printRow(summary, "All files", nameWidth, uncoveredWidth);
printBody(grouped, nameWidth, uncoveredWidth);
printSeparator();
};
}
});
// ../../node_modules/bare-cov/lib/merge.js
var require_merge = __commonJS({
"../../node_modules/bare-cov/lib/merge.js"(exports, module) {
var isLineColumn = (o) => typeof o?.line === "number" && typeof o?.column === "number";
var isLoc = (o) => isLineColumn(o?.start) && isLineColumn(o.end);
var getLoc = (o) => isLoc(o) ? o : isLoc(o.loc) ? o.loc : null;
function findNearestContainer(coverageRecord, targetRecordMap) {
const loc = getLoc(coverageRecord);
if (!loc) return null;
let container = { nearest: null, distance: null, key: null };
for (const [key, [, targetCoverageRecord]] of Object.entries(targetRecordMap)) {
const tLoc = getLoc(targetCoverageRecord);
if (!tLoc) continue;
const distance = [
loc.start.line - tLoc.start.line,
loc.start.column - tLoc.start.column,
tLoc.end.line - loc.end.line,
tLoc.end.column - loc.end.column
];
if (distance[0] < 0 || distance[2] < 0 || distance[0] === 0 && distance[1] < 0 || distance[2] === 0 && distance[3] < 0)
continue;
if (container.nearest === null) {
container = { nearest: targetCoverageRecord, distance, key };
continue;
}
const closerBefore = distance[0] < container.distance[0] || distance[0] === 0 && distance[1] < container.distance[1];
const closerAfter = distance[2] < container.distance[2] || distance[2] === 0 && distance[3] < container.distance[3];
if (closerBefore || closerAfter) container = { nearest: targetCoverageRecord, distance, key };
}
return container.key;
}
function addContainedHits(hits, coverageRecord, sourceRecord) {
const container = findNearestContainer(coverageRecord, sourceRecord);
return container ? addHits(hits, sourceRecord[container][0]) : hits;
}
function addHits(a, b) {
if (typeof a === "number" && typeof b === "number") return a + b;
if (Array.isArray(a) && Array.isArray(b)) {
if (a.length >= b.length) return a.map((hits, i) => hits + (b[i] || 0));
return b.map((hits, i) => hits + (a[i] || 0));
}
return null;
}
function toHitMap(hits, map, toKey) {
return Object.entries(hits).reduce((acc, [id, value2]) => {
const coverageRecord = map[id];
if (coverageRecord) acc[toKey(coverageRecord)] = [value2, coverageRecord];
return acc;
}, {});
}
function mergeHitMaps(a, b) {
const mergedRecords = {};
for (const [key, [hits, record]] of Object.entries(a)) {
const matchingValue = b[key];
const newHits = matchingValue ? addHits(hits, matchingValue[0]) : addContainedHits(hits, record, b);
mergedRecords[key] = [newHits, record];
}
for (const [key, [hits, record]] of Object.entries(b)) {
if (mergedRecords[key]) continue;
const newHits = addContainedHits(hits, record, a);
mergedRecords[key] = [newHits, record];
}
return Object.values(mergedRecords).reduce(
(acc, [hits, record], index) => {
acc.hits[index] = hits;
acc.map[index] = record;
return acc;
},
{ hits: {}, map: {} }
);
}
function mergeCoverages(a, b) {
const merged = { ...a };
const toKey = ({ start, end }) => `${start.line}|${start.column}|${end.line}|${end.column}`;
({ hits: merged.s, map: merged.statementMap } = mergeHitMaps(
toHitMap(a.s, a.statementMap, toKey),
toHitMap(b.s, b.statementMap, toKey)
));
const toKeyFn = ({ loc }) => toKey(loc);
({ hits: merged.f, map: merged.fnMap } = mergeHitMaps(
toHitMap(a.f, a.fnMap, toKeyFn),
toHitMap(b.f, b.fnMap, toKeyFn)
));
const toKeyBranch = ({ locations }) => toKey(locations[0]);
({ hits: merged.b, map: merged.branchMap } = mergeHitMaps(
toHitMap(a.b, a.branchMap, toKeyBranch),
toHitMap(b.b, b.branchMap, toKeyBranch)
));
return merged;
}
module.exports = mergeCoverages;
}
});
// ../../node_modules/bare-cov/lib/transformer.js
var require_transformer = __commonJS({
"../../node_modules/bare-cov/lib/transformer.js"(exports, module) {
"use strict";
var { isAbsolute } = __require("path");
var { fileURLToPath } = __require("url");
var v8ToIstanbul = require_bare_v8_to_istanbul();
var TestExclude = require_test_exclude();
var summarize = require_summarize();
var report = require_report();
var merge = require_merge();
var Transformer = class {
constructor(opts = {}) {
this.includeRelative = opts.includeRelative ?? false;
this.exclude = new TestExclude({ cwd: opts.cwd });
this.includedUrlCache = /* @__PURE__ */ new Map();
}
normalizeUrl(v8ReportResult) {
if (/^node:/.test(v8ReportResult.url)) {
v8ReportResult.url = `${v8ReportResult.url.replace(/^node:/, "")}.js`;
}
if (/^file:\/\//.test(v8ReportResult.url)) {
v8ReportResult.url = fileURLToPath(v8ReportResult.url);
}
return v8ReportResult;
}
isResultUrlIncluded(url) {
const cacheResult = this.includedUrlCache.get(url);
if (cacheResult !== void 0) return cacheResult;
const result = (this.includeRelative || isAbsolute(url)) && this.exclude.shouldInstrument(url);
this.includedUrlCache.set(url, result);
return result;
}
async transformToCoverageMap(rawV8Report) {
const v8Report = {
result: rawV8Report.result.map((v8ReportResult) => this.normalizeUrl(v8ReportResult)).filter((v8ReportResult) => this.isResultUrlIncluded(v8ReportResult.url))
};
const coverages = {};
for (const v8ReportResult of v8Report.result) {
const converter = v8ToIstanbul(v8ReportResult.url);
await converter.load();
converter.applyCoverage(v8ReportResult.functions);
const converted = converter.toIstanbul();
for (const [path, coverage] of Object.entries(converted)) {
coverages[path] = coverages[path] ? merge(coverages[path], coverage) : coverage;
}
}
return coverages;
}
report(coverage) {
report(summarize(coverage));
}
};
module.exports = Transformer;
}
});
// ../../node_modules/bare-cov/index.js
var require_bare_cov = __commonJS({
"../../node_modules/bare-cov/index.js"(exports, module) {
"use strict";
var { isBare } = require_which_runtime();
var { Session } = __require("inspector");
var fs = __require("fs");
var path = __require("path");
var Transformer = require_transformer();
var process2 = __require("process");
module.exports = async function setupCoverage(opts = {}) {
const cwd = process2.cwd();
const dir = path.resolve(opts.dir ?? "coverage");
const session = new Session();
session.connect();
const sessionPost = (...args) => new Promise(
(resolve, reject) => session.post(...args, (err, result) => err ? reject(err) : resolve(result))
);
await sessionPost("Profiler.enable");
await sessionPost("Profiler.startPreciseCoverage", {
callCount: true,
detailed: true
});
process2.once("beforeExit", async () => {
const v8Report = await sessionPost("Profiler.takePreciseCoverage");
isBare ? session.destroy() : session.disconnect();
if (opts.skipRawDump !== true) {
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
fs.writeFileSync(path.join(dir, "v8-coverage.json"), JSON.stringify(v8Report));
}
const reporters = Array.isArray(opts.reporters) ? opts.reporters : ["text", "json"];
const transformer = new Transformer({ ...opts, cwd });
const coverageMap = await transformer.transformToCoverageMap(v8Report);
if (reporters.includes("json")) {
fs.writeFileSync(path.join(dir, "coverage-final.json"), JSON.stringify(coverageMap));
}
if (reporters.includes("text")) transformer.report(coverageMap);
});
};
}
});
// ../../bare-lib-entry-bareCov.js
var bare_lib_entry_bareCov_exports = {};
__export(bare_lib_entry_bareCov_exports, {
default: () => bare_lib_entry_bareCov_default
});
var import_bare_cov = __toESM(require_bare_cov());
var bare_lib_entry_bareCov_default = import_bare_cov.default;
return __toCommonJS(bare_lib_entry_bareCov_exports);
})();
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};var e=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;var v=e!=null&&typeof e==="object"&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e;g[s]["bareCov"]=v;})();