const process$2 = require('node:process'); const require$$0 = require('assert'); const require$$2 = require('events'); function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; } const process__default = /*#__PURE__*/_interopDefault(process$2); const require$$0__default = /*#__PURE__*/_interopDefault(require$$0); const require$$2__default = /*#__PURE__*/_interopDefault(require$$2); var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; var once$1 = {exports: {}}; // Returns a wrapper function that returns a wrapped callback // The wrapper function should do some stuff, and return a // presumably different callback function. // This makes sure that own properties are retained, so that // decorations and such are not lost along the way. var wrappy_1 = wrappy$1; function wrappy$1 (fn, cb) { if (fn && cb) return wrappy$1(fn)(cb) if (typeof fn !== 'function') throw new TypeError('need wrapper function') Object.keys(fn).forEach(function (k) { wrapper[k] = fn[k]; }); return wrapper function wrapper() { var args = new Array(arguments.length); for (var i = 0; i < args.length; i++) { args[i] = arguments[i]; } var ret = fn.apply(this, args); var cb = args[args.length-1]; if (typeof ret === 'function' && ret !== cb) { Object.keys(cb).forEach(function (k) { ret[k] = cb[k]; }); } return ret } } var wrappy = wrappy_1; once$1.exports = wrappy(once); once$1.exports.strict = wrappy(onceStrict); once.proto = once(function () { Object.defineProperty(Function.prototype, 'once', { value: function () { return once(this) }, configurable: true }); Object.defineProperty(Function.prototype, 'onceStrict', { value: function () { return onceStrict(this) }, configurable: true }); }); function once (fn) { var f = function () { if (f.called) return f.value f.called = true; return f.value = fn.apply(this, arguments) }; f.called = false; return f } function onceStrict (fn) { var f = function () { if (f.called) throw new Error(f.onceError) f.called = true; return f.value = fn.apply(this, arguments) }; var name = fn.name || 'Function wrapped with `once`'; f.onceError = name + " shouldn't be called more than once"; f.called = false; return f } var signalExit = {exports: {}}; var signals$1 = {exports: {}}; var hasRequiredSignals; function requireSignals () { if (hasRequiredSignals) return signals$1.exports; hasRequiredSignals = 1; (function (module) { // This is not the set of all possible signals. // // It IS, however, the set of all signals that trigger // an exit on either Linux or BSD systems. Linux is a // superset of the signal names supported on BSD, and // the unknown signals just fail to register, so we can // catch that easily enough. // // Don't bother with SIGKILL. It's uncatchable, which // means that we can't fire any callbacks anyway. // // If a user does happen to register a handler on a non- // fatal signal like SIGWINCH or something, and then // exit, it'll end up firing `process.emit('exit')`, so // the handler will be fired anyway. // // SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised // artificially, inherently leave the process in a // state from which it is not safe to try and enter JS // listeners. module.exports = [ 'SIGABRT', 'SIGALRM', 'SIGHUP', 'SIGINT', 'SIGTERM' ]; if (process.platform !== 'win32') { module.exports.push( 'SIGVTALRM', 'SIGXCPU', 'SIGXFSZ', 'SIGUSR2', 'SIGTRAP', 'SIGSYS', 'SIGQUIT', 'SIGIOT' // should detect profiler and enable/disable accordingly. // see #21 // 'SIGPROF' ); } if (process.platform === 'linux') { module.exports.push( 'SIGIO', 'SIGPOLL', 'SIGPWR', 'SIGSTKFLT', 'SIGUNUSED' ); } } (signals$1)); return signals$1.exports; } // Note: since nyc uses this module to output coverage, any lines // that are in the direct sync flow of nyc's outputCoverage are // ignored, since we can never get coverage for them. // grab a reference to node's real process object right away var process$1 = commonjsGlobal.process; const processOk = function (process) { return process && typeof process === 'object' && typeof process.removeListener === 'function' && typeof process.emit === 'function' && typeof process.reallyExit === 'function' && typeof process.listeners === 'function' && typeof process.kill === 'function' && typeof process.pid === 'number' && typeof process.on === 'function' }; // some kind of non-node environment, just no-op /* istanbul ignore if */ if (!processOk(process$1)) { signalExit.exports = function () { return function () {} }; } else { var assert = require$$0__default["default"]; var signals = requireSignals(); var isWin = /^win/i.test(process$1.platform); var EE = require$$2__default["default"]; /* istanbul ignore if */ if (typeof EE !== 'function') { EE = EE.EventEmitter; } var emitter; if (process$1.__signal_exit_emitter__) { emitter = process$1.__signal_exit_emitter__; } else { emitter = process$1.__signal_exit_emitter__ = new EE(); emitter.count = 0; emitter.emitted = {}; } // Because this emitter is a global, we have to check to see if a // previous version of this library failed to enable infinite listeners. // I know what you're about to say. But literally everything about // signal-exit is a compromise with evil. Get used to it. if (!emitter.infinite) { emitter.setMaxListeners(Infinity); emitter.infinite = true; } signalExit.exports = function (cb, opts) { /* istanbul ignore if */ if (!processOk(commonjsGlobal.process)) { return function () {} } assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler'); if (loaded === false) { load(); } var ev = 'exit'; if (opts && opts.alwaysLast) { ev = 'afterexit'; } var remove = function () { emitter.removeListener(ev, cb); if (emitter.listeners('exit').length === 0 && emitter.listeners('afterexit').length === 0) { unload(); } }; emitter.on(ev, cb); return remove }; var unload = function unload () { if (!loaded || !processOk(commonjsGlobal.process)) { return } loaded = false; signals.forEach(function (sig) { try { process$1.removeListener(sig, sigListeners[sig]); } catch (er) {} }); process$1.emit = originalProcessEmit; process$1.reallyExit = originalProcessReallyExit; emitter.count -= 1; }; signalExit.exports.unload = unload; var emit = function emit (event, code, signal) { /* istanbul ignore if */ if (emitter.emitted[event]) { return } emitter.emitted[event] = true; emitter.emit(event, code, signal); }; // { : , ... } var sigListeners = {}; signals.forEach(function (sig) { sigListeners[sig] = function listener () { /* istanbul ignore if */ if (!processOk(commonjsGlobal.process)) { return } // If there are no other listeners, an exit is coming! // Simplest way: remove us and then re-send the signal. // We know that this will kill the process, so we can // safely emit now. var listeners = process$1.listeners(sig); if (listeners.length === emitter.count) { unload(); emit('exit', null, sig); /* istanbul ignore next */ emit('afterexit', null, sig); /* istanbul ignore next */ if (isWin && sig === 'SIGHUP') { // "SIGHUP" throws an `ENOSYS` error on Windows, // so use a supported signal instead sig = 'SIGINT'; } /* istanbul ignore next */ process$1.kill(process$1.pid, sig); } }; }); signalExit.exports.signals = function () { return signals }; var loaded = false; var load = function load () { if (loaded || !processOk(commonjsGlobal.process)) { return } loaded = true; // This is the number of onSignalExit's that are in play. // It's important so that we can count the correct number of // listeners on signals, and don't wait for the other one to // handle it instead of us. emitter.count += 1; signals = signals.filter(function (sig) { try { process$1.on(sig, sigListeners[sig]); return true } catch (er) { return false } }); process$1.emit = processEmit; process$1.reallyExit = processReallyExit; }; signalExit.exports.load = load; var originalProcessReallyExit = process$1.reallyExit; var processReallyExit = function processReallyExit (code) { /* istanbul ignore if */ if (!processOk(commonjsGlobal.process)) { return } process$1.exitCode = code || /* istanbul ignore next */ 0; emit('exit', process$1.exitCode, null); /* istanbul ignore next */ emit('afterexit', process$1.exitCode, null); /* istanbul ignore next */ originalProcessReallyExit.call(process$1, process$1.exitCode); }; var originalProcessEmit = process$1.emit; var processEmit = function processEmit (ev, arg) { if (ev === 'exit' && processOk(commonjsGlobal.process)) { /* istanbul ignore else */ if (arg !== undefined) { process$1.exitCode = arg; } var ret = originalProcessEmit.apply(this, arguments); /* istanbul ignore next */ emit('exit', process$1.exitCode, null); /* istanbul ignore next */ emit('afterexit', process$1.exitCode, null); /* istanbul ignore next */ return ret } else { return originalProcessEmit.apply(this, arguments) } }; } const restoreCursor = once$1.exports(() => { signalExit.exports(() => { process__default["default"].stderr.write('\u001B[?25h'); }, {alwaysLast: true}); }); let isHidden = false; const cliCursor = {}; cliCursor.show = (writableStream = process__default["default"].stderr) => { if (!writableStream.isTTY) { return; } isHidden = false; writableStream.write('\u001B[?25h'); }; cliCursor.hide = (writableStream = process__default["default"].stderr) => { if (!writableStream.isTTY) { return; } restoreCursor(); isHidden = true; writableStream.write('\u001B[?25l'); }; cliCursor.toggle = (force, writableStream) => { if (force !== undefined) { isHidden = force; } if (isHidden) { cliCursor.show(writableStream); } else { cliCursor.hide(writableStream); } }; module.exports = cliCursor;