@visulima/ansi 1.0.13 → 1.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/scroll.cjs CHANGED
@@ -1 +1,13 @@
1
- "use strict";var c=Object.defineProperty;var r=(e,o)=>c(e,"name",{value:o,configurable:!0});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./packem_shared/constants-DNNXUmVx.cjs");var n=Object.defineProperty,t=r((e,o)=>n(e,"name",{value:o,configurable:!0}),"o");const s=t((e=1)=>`${l.C}T`.repeat(e),"scrollDown"),a=t((e=1)=>`${l.C}S`.repeat(e),"scrollUp");exports.scrollDown=s;exports.scrollUp=a;
1
+ 'use strict';
2
+
3
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
+
5
+ const constants = require('./packem_shared/constants-D8u2npjW.cjs');
6
+
7
+ var __defProp = Object.defineProperty;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ const scrollDown = /* @__PURE__ */ __name((count = 1) => `${constants.CSI}T`.repeat(count), "scrollDown");
10
+ const scrollUp = /* @__PURE__ */ __name((count = 1) => `${constants.CSI}S`.repeat(count), "scrollUp");
11
+
12
+ exports.scrollDown = scrollDown;
13
+ exports.scrollUp = scrollUp;
package/dist/scroll.mjs CHANGED
@@ -1 +1,8 @@
1
- var p=Object.defineProperty;var e=(r,o)=>p(r,"name",{value:o,configurable:!0});import{C as l}from"./packem_shared/constants-DeW8ueso.mjs";var c=Object.defineProperty,a=e((r,o)=>c(r,"name",{value:o,configurable:!0}),"o");const s=a((r=1)=>`${l}T`.repeat(r),"scrollDown"),f=a((r=1)=>`${l}S`.repeat(r),"scrollUp");export{s as scrollDown,f as scrollUp};
1
+ import { C as CSI } from './packem_shared/constants-CqXMfQy0.mjs';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+ const scrollDown = /* @__PURE__ */ __name((count = 1) => `${CSI}T`.repeat(count), "scrollDown");
6
+ const scrollUp = /* @__PURE__ */ __name((count = 1) => `${CSI}S`.repeat(count), "scrollUp");
7
+
8
+ export { scrollDown, scrollUp };
package/dist/strip.cjs CHANGED
@@ -1 +1,20 @@
1
- "use strict";var u=Object.defineProperty;var a=(e,r)=>u(e,"name",{value:r,configurable:!0});var t=Object.defineProperty,o=a((e,r)=>t(e,"name",{value:r,configurable:!0}),"u");function n({onlyFirst:e=!1}={}){const r=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(r,e?void 0:"g")}a(n,"a");o(n,"ansiRegex");var c=Object.defineProperty,i=a((e,r)=>c(e,"name",{value:r,configurable:!0}),"r");const d=n(),s=i(e=>e.replace(/\u001B\]0;.*\u0007/,"").replace(d,""),"strip");module.exports=s;
1
+ 'use strict';
2
+
3
+ var __defProp$1 = Object.defineProperty;
4
+ var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
5
+ function ansiRegex({ onlyFirst = false } = {}) {
6
+ const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
7
+ const pattern = [
8
+ `[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ST})`,
9
+ "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"
10
+ ].join("|");
11
+ return new RegExp(pattern, onlyFirst ? undefined : "g");
12
+ }
13
+ __name$1(ansiRegex, "ansiRegex");
14
+
15
+ var __defProp = Object.defineProperty;
16
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
17
+ const regex = ansiRegex();
18
+ const strip = /* @__PURE__ */ __name((input) => input.replace(/\u001B\]0;.*\u0007/, "").replace(regex, ""), "strip");
19
+
20
+ module.exports = strip;
package/dist/strip.mjs CHANGED
@@ -1 +1,18 @@
1
- var u=Object.defineProperty;var r=(e,a)=>u(e,"name",{value:a,configurable:!0});var t=Object.defineProperty,o=r((e,a)=>t(e,"name",{value:a,configurable:!0}),"u");function n({onlyFirst:e=!1}={}){const a=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(a,e?void 0:"g")}r(n,"a");o(n,"ansiRegex");var d=Object.defineProperty,c=r((e,a)=>d(e,"name",{value:a,configurable:!0}),"r");const i=n(),f=c(e=>e.replace(/\u001B\]0;.*\u0007/,"").replace(i,""),"strip");export{f as default};
1
+ var __defProp$1 = Object.defineProperty;
2
+ var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
3
+ function ansiRegex({ onlyFirst = false } = {}) {
4
+ const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
5
+ const pattern = [
6
+ `[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ST})`,
7
+ "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"
8
+ ].join("|");
9
+ return new RegExp(pattern, onlyFirst ? undefined : "g");
10
+ }
11
+ __name$1(ansiRegex, "ansiRegex");
12
+
13
+ var __defProp = Object.defineProperty;
14
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
15
+ const regex = ansiRegex();
16
+ const strip = /* @__PURE__ */ __name((input) => input.replace(/\u001B\]0;.*\u0007/, "").replace(regex, ""), "strip");
17
+
18
+ export { strip as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/ansi",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "ANSI escape codes for some terminal swag.",
5
5
  "keywords": [
6
6
  "alternative-screen",
@@ -200,37 +200,37 @@
200
200
  "devDependencies": {
201
201
  "@anolilab/eslint-config": "^15.0.3",
202
202
  "@anolilab/prettier-config": "^5.0.14",
203
- "@anolilab/semantic-release-pnpm": "1.1.3",
203
+ "@anolilab/semantic-release-pnpm": "1.1.6",
204
204
  "@anolilab/semantic-release-preset": "^9.0.3",
205
205
  "@arethetypeswrong/cli": "^0.17.2",
206
206
  "@babel/core": "^7.26.0",
207
207
  "@rushstack/eslint-plugin-security": "^0.8.3",
208
208
  "@secretlint/secretlint-rule-preset-recommend": "^9.0.0",
209
209
  "@total-typescript/ts-reset": "^0.6.1",
210
- "@types/node": "20.14.6",
211
- "@visulima/colorize": "1.4.16",
212
- "@visulima/packem": "1.9.2",
213
- "@visulima/path": "1.3.1",
210
+ "@types/node": "22.10.5",
211
+ "@visulima/colorize": "1.4.17",
212
+ "@visulima/packem": "1.10.7",
213
+ "@visulima/path": "1.3.2",
214
214
  "@vitest/coverage-v8": "^2.1.8",
215
215
  "@vitest/ui": "^2.1.8",
216
216
  "ansi-regex": "^6.1.0",
217
217
  "conventional-changelog-conventionalcommits": "8.0.0",
218
218
  "cross-env": "^7.0.3",
219
- "esbuild": "0.24.0",
220
- "eslint": "8.57.0",
219
+ "esbuild": "0.24.2",
220
+ "eslint": "9.18.0",
221
221
  "eslint-plugin-deprecation": "^3.0.0",
222
222
  "eslint-plugin-etc": "^2.0.3",
223
223
  "eslint-plugin-import": "npm:eslint-plugin-i@^2.29.1",
224
224
  "eslint-plugin-mdx": "^3.1.5",
225
- "eslint-plugin-vitest": "^0.4.1",
225
+ "eslint-plugin-vitest": "^0.5.4",
226
226
  "eslint-plugin-vitest-globals": "^1.5.0",
227
227
  "prettier": "^3.4.2",
228
228
  "restore-cursor": "^5.1.0",
229
- "rimraf": "5.0.9",
230
- "secretlint": "8.2.4",
231
- "semantic-release": "^24.2.0",
232
- "type-fest": "^4.31.0",
233
- "typescript": "5.4.5",
229
+ "rimraf": "6.0.1",
230
+ "secretlint": "9.0.0",
231
+ "semantic-release": "^24.2.1",
232
+ "type-fest": "^4.32.0",
233
+ "typescript": "5.7.3",
234
234
  "vitest": "^2.1.8"
235
235
  },
236
236
  "engines": {
@@ -1 +0,0 @@
1
- "use strict";const S="\x1B",B=`${S}[`,C="\x1B]",E="\x07",s=";";exports.B=E;exports.C=B;exports.E=S;exports.O=C;exports.S=s;
@@ -1 +0,0 @@
1
- const s="\x1B",a=`${s}[`,S="\x1B]",x="\x07",B=";";export{x as B,a as C,s as E,S as O,B as S};
@@ -1 +0,0 @@
1
- "use strict";var a=Object.defineProperty;var u=(r,e)=>a(r,"name",{value:e,configurable:!0});const o=require("./constants-DNNXUmVx.cjs");require("./restoreCursor-7AxUIcBE.cjs");const n=globalThis?.window?.document!==void 0,i=!n&&process.env.TERM_PROGRAM==="Apple_Terminal",C=!n&&process.platform==="win32";var t=Object.defineProperty,s=u((r,e)=>t(r,"name",{value:e,configurable:!0}),"e");const p=s((r=1)=>o.C+r+"D","cursorBackward"),d=s((r=1)=>o.C+r+"B","cursorDown"),l=s((r=1)=>o.C+r+"C","cursorForward"),w=o.C+"?25l",v=o.C+"G",m=s((r,e)=>{let c="";return r<0?c+=o.C+-r+"D":r>0&&(c+=o.C+r+"C"),e<0?c+=o.C+-e+"A":e>0&&(c+=o.C+e+"B"),c},"cursorMove"),E=s((r=1)=>(o.C+"E").repeat(r),"cursorNextLine"),T=s((r=1)=>(o.C+"F").repeat(r),"cursorPreviousLine"),f=i?o.E+"8":o.E+"u",A=i?o.E+"7":o.E+"s",L=o.C+"?25h",b=s((r,e)=>!e&&e!==0?o.C+(r+1)+"G":o.C+(e+1)+o.S+(r+1)+"H","cursorTo"),h=s((r=1)=>o.C+r+"A","cursorUp");exports.a=d;exports.b=l;exports.c=p;exports.d=w;exports.e=v;exports.f=m;exports.g=E;exports.h=T;exports.i=f;exports.j=A;exports.k=L;exports.l=b;exports.m=h;exports.n=C;
@@ -1 +0,0 @@
1
- var p=Object.defineProperty;var u=(r,o)=>p(r,"name",{value:o,configurable:!0});import{C as s,E as c,S as t}from"./constants-DeW8ueso.mjs";import"./restoreCursor-uO8SZYVx.mjs";const i=globalThis?.window?.document!==void 0,n=!i&&process.env.TERM_PROGRAM==="Apple_Terminal",m=!i&&process.platform==="win32";var d=Object.defineProperty,e=u((r,o)=>d(r,"name",{value:o,configurable:!0}),"e");const f=e((r=1)=>s+r+"D","cursorBackward"),S=e((r=1)=>s+r+"B","cursorDown"),T=e((r=1)=>s+r+"C","cursorForward"),A=s+"?25l",C=s+"G",E=e((r,o)=>{let a="";return r<0?a+=s+-r+"D":r>0&&(a+=s+r+"C"),o<0?a+=s+-o+"A":o>0&&(a+=s+o+"B"),a},"cursorMove"),L=e((r=1)=>(s+"E").repeat(r),"cursorNextLine"),P=e((r=1)=>(s+"F").repeat(r),"cursorPreviousLine"),b=n?c+"8":c+"u",h=n?c+"7":c+"s",B=s+"?25h",D=e((r,o)=>!o&&o!==0?s+(r+1)+"G":s+(o+1)+t+(r+1)+"H","cursorTo"),M=e((r=1)=>s+r+"A","cursorUp");export{S as a,T as b,f as c,A as d,C as e,E as f,L as g,P as h,b as i,h as j,B as k,D as l,M as m,m as n};
@@ -1,2 +0,0 @@
1
- "use strict";var E=Object.defineProperty;var s=(t,e)=>E(t,"name",{value:e,configurable:!0});const I=require("node:process"),P=s(t=>t&&typeof t=="object"&&"default"in t?t.default:t,"_interopDefaultCompat"),h=P(I);var _=Object.defineProperty,l=s((t,e)=>_(t,"name",{value:e,configurable:!0}),"r$2");const v=l((t,e,i,n)=>{if(i==="length"||i==="prototype"||i==="arguments"||i==="caller")return;const o=Object.getOwnPropertyDescriptor(t,i),r=Object.getOwnPropertyDescriptor(e,i);!G(o,r)&&n||Object.defineProperty(t,i,r)},"copyProperty"),G=l(function(t,e){return t===void 0||t.configurable||t.writable===e.writable&&t.enumerable===e.enumerable&&t.configurable===e.configurable&&(t.writable||t.value===e.value)},"canCopyProperty"),T=l((t,e)=>{const i=Object.getPrototypeOf(e);i!==Object.getPrototypeOf(t)&&Object.setPrototypeOf(t,i)},"changePrototype"),j=l((t,e)=>`/* Wrapped ${t}*/
2
- ${e}`,"wrappedToString"),$=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),L=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),C=l((t,e,i)=>{const n=i===""?"":`with ${i.trim()}() `,o=j.bind(null,n,e.toString());Object.defineProperty(o,"name",L);const{writable:r,enumerable:u,configurable:d}=$;Object.defineProperty(t,"toString",{value:o,writable:r,enumerable:u,configurable:d})},"changeToString");function S(t,e,{ignoreNonConfigurable:i=!1}={}){const{name:n}=t;for(const o of Reflect.ownKeys(e))v(t,e,o,i);return T(t,e),C(t,e,n),t}s(S,"P");l(S,"mimicFunction");var R=Object.defineProperty,g=s((t,e)=>R(t,"name",{value:e,configurable:!0}),"a$1");const p=new WeakMap,w=g((t,e={})=>{if(typeof t!="function")throw new TypeError("Expected a function");let i,n=0;const o=t.displayName||t.name||"<anonymous>",r=g(function(...u){if(p.set(r,++n),n===1)i=t.apply(this,u),t=void 0;else if(e.throw===!0)throw new Error(`Function \`${o}\` can only be called once`);return i},"onetime");return S(r,t),p.set(r,n),r},"onetime");w.callCount=t=>{if(!p.has(t))throw new Error(`The given function \`${t.name}\` is not wrapped by the \`onetime\` package`);return p.get(t)};const a=[];a.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&a.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&a.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var F=Object.defineProperty,c=s((t,e)=>F(t,"name",{value:e,configurable:!0}),"r$1");const f=c(t=>!!t&&!0&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function","processOk"),m=Symbol.for("signal-exit emitter"),y=globalThis,k=Object.defineProperty.bind(Object);class U{static{s(this,"y")}static{c(this,"Emitter")}emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(y[m])return y[m];k(y,m,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,i){this.listeners[e].push(i)}removeListener(e,i){const n=this.listeners[e],o=n.indexOf(i);o!==-1&&(o===0&&n.length===1?n.length=0:n.splice(o,1))}emit(e,i,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let o=!1;for(const r of this.listeners[e])o=r(i,n)===!0||o;return e==="exit"&&(o=this.emit("afterExit",i,n)||o),o}}class O{static{s(this,"c")}static{c(this,"SignalExitBase")}}const D=c(t=>({onExit(e,i){return t.onExit(e,i)},load(){return t.load()},unload(){return t.unload()}}),"signalExitWrap");class M extends O{static{s(this,"_")}static{c(this,"SignalExitFallback")}onExit(){return()=>{}}load(){}unload(){}}class A extends O{static{s(this,"p")}static{c(this,"SignalExit")}#s=b.platform==="win32"?"SIGINT":"SIGHUP";#e=new U;#t;#o;#r;#n={};#i=!1;constructor(e){super(),this.#t=e,this.#n={};for(const i of a)this.#n[i]=()=>{const n=this.#t.listeners(i);let{count:o}=this.#e;const r=e;if(typeof r.__signal_exit_emitter__=="object"&&typeof r.__signal_exit_emitter__.count=="number"&&(o+=r.__signal_exit_emitter__.count),n.length===o){this.unload();const u=this.#e.emit("exit",null,i),d=i==="SIGHUP"?this.#s:i;u||e.kill(e.pid,d)}};this.#r=e.reallyExit,this.#o=e.emit}onExit(e,i){if(!f(this.#t))return()=>{};this.#i===!1&&this.load();const n=i?.alwaysLast?"afterExit":"exit";return this.#e.on(n,e),()=>{this.#e.removeListener(n,e),this.#e.listeners.exit.length===0&&this.#e.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#i){this.#i=!0,this.#e.count+=1;for(const e of a)try{const i=this.#n[e];i&&this.#t.on(e,i)}catch{}this.#t.emit=(e,...i)=>this.#l(e,...i),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#i&&(this.#i=!1,a.forEach(e=>{const i=this.#n[e];if(!i)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,i)}catch{}}),this.#t.emit=this.#o,this.#t.reallyExit=this.#r,this.#e.count-=1)}#a(e){return f(this.#t)?(this.#t.exitCode=e||0,this.#e.emit("exit",this.#t.exitCode,null),this.#r.call(this.#t,this.#t.exitCode)):0}#l(e,...i){const n=this.#o;if(e==="exit"&&f(this.#t)){typeof i[0]=="number"&&(this.#t.exitCode=i[0]);const o=n.call(this.#t,e,...i);return this.#e.emit("exit",this.#t.exitCode,null),o}else return n.call(this.#t,e,...i)}}const b=globalThis.process,{onExit:N,load:H,unload:Y}=D(f(b)?new A(b):new M),x=h.stderr.isTTY?h.stderr:h.stdout.isTTY?h.stdout:void 0,W=x?w(()=>{N(()=>{x.write("\x1B[?25h")},{alwaysLast:!0})}):()=>{};module.exports=W;
@@ -1,2 +0,0 @@
1
- var E=Object.defineProperty;var s=(e,t)=>E(e,"name",{value:t,configurable:!0});import u from"node:process";var I=Object.defineProperty,l=s((e,t)=>I(e,"name",{value:t,configurable:!0}),"r$2");const P=l((e,t,i,n)=>{if(i==="length"||i==="prototype"||i==="arguments"||i==="caller")return;const r=Object.getOwnPropertyDescriptor(e,i),o=Object.getOwnPropertyDescriptor(t,i);!v(r,o)&&n||Object.defineProperty(e,i,o)},"copyProperty"),v=l(function(e,t){return e===void 0||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},"canCopyProperty"),G=l((e,t)=>{const i=Object.getPrototypeOf(t);i!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,i)},"changePrototype"),T=l((e,t)=>`/* Wrapped ${e}*/
2
- ${t}`,"wrappedToString"),_=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),j=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),$=l((e,t,i)=>{const n=i===""?"":`with ${i.trim()}() `,r=T.bind(null,n,t.toString());Object.defineProperty(r,"name",j);const{writable:o,enumerable:h,configurable:m}=_;Object.defineProperty(e,"toString",{value:r,writable:o,enumerable:h,configurable:m})},"changeToString");function S(e,t,{ignoreNonConfigurable:i=!1}={}){const{name:n}=e;for(const r of Reflect.ownKeys(t))P(e,t,r,i);return G(e,t),$(e,t,n),e}s(S,"P");l(S,"mimicFunction");var L=Object.defineProperty,g=s((e,t)=>L(e,"name",{value:t,configurable:!0}),"a$1");const p=new WeakMap,w=g((e,t={})=>{if(typeof e!="function")throw new TypeError("Expected a function");let i,n=0;const r=e.displayName||e.name||"<anonymous>",o=g(function(...h){if(p.set(o,++n),n===1)i=e.apply(this,h),e=void 0;else if(t.throw===!0)throw new Error(`Function \`${r}\` can only be called once`);return i},"onetime");return S(o,e),p.set(o,n),o},"onetime");w.callCount=e=>{if(!p.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return p.get(e)};const a=[];a.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&a.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&a.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var C=Object.defineProperty,c=s((e,t)=>C(e,"name",{value:t,configurable:!0}),"r$1");const f=c(e=>!!e&&!0&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function","processOk"),d=Symbol.for("signal-exit emitter"),y=globalThis,R=Object.defineProperty.bind(Object);class F{static{s(this,"y")}static{c(this,"Emitter")}emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(y[d])return y[d];R(y,d,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(t,i){this.listeners[t].push(i)}removeListener(t,i){const n=this.listeners[t],r=n.indexOf(i);r!==-1&&(r===0&&n.length===1?n.length=0:n.splice(r,1))}emit(t,i,n){if(this.emitted[t])return!1;this.emitted[t]=!0;let r=!1;for(const o of this.listeners[t])r=o(i,n)===!0||r;return t==="exit"&&(r=this.emit("afterExit",i,n)||r),r}}class O{static{s(this,"c")}static{c(this,"SignalExitBase")}}const k=c(e=>({onExit(t,i){return e.onExit(t,i)},load(){return e.load()},unload(){return e.unload()}}),"signalExitWrap");class U extends O{static{s(this,"_")}static{c(this,"SignalExitFallback")}onExit(){return()=>{}}load(){}unload(){}}class M extends O{static{s(this,"p")}static{c(this,"SignalExit")}#s=b.platform==="win32"?"SIGINT":"SIGHUP";#e=new F;#t;#r;#o;#n={};#i=!1;constructor(t){super(),this.#t=t,this.#n={};for(const i of a)this.#n[i]=()=>{const n=this.#t.listeners(i);let{count:r}=this.#e;const o=t;if(typeof o.__signal_exit_emitter__=="object"&&typeof o.__signal_exit_emitter__.count=="number"&&(r+=o.__signal_exit_emitter__.count),n.length===r){this.unload();const h=this.#e.emit("exit",null,i),m=i==="SIGHUP"?this.#s:i;h||t.kill(t.pid,m)}};this.#o=t.reallyExit,this.#r=t.emit}onExit(t,i){if(!f(this.#t))return()=>{};this.#i===!1&&this.load();const n=i?.alwaysLast?"afterExit":"exit";return this.#e.on(n,t),()=>{this.#e.removeListener(n,t),this.#e.listeners.exit.length===0&&this.#e.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#i){this.#i=!0,this.#e.count+=1;for(const t of a)try{const i=this.#n[t];i&&this.#t.on(t,i)}catch{}this.#t.emit=(t,...i)=>this.#l(t,...i),this.#t.reallyExit=t=>this.#a(t)}}unload(){this.#i&&(this.#i=!1,a.forEach(t=>{const i=this.#n[t];if(!i)throw new Error("Listener not defined for signal: "+t);try{this.#t.removeListener(t,i)}catch{}}),this.#t.emit=this.#r,this.#t.reallyExit=this.#o,this.#e.count-=1)}#a(t){return f(this.#t)?(this.#t.exitCode=t||0,this.#e.emit("exit",this.#t.exitCode,null),this.#o.call(this.#t,this.#t.exitCode)):0}#l(t,...i){const n=this.#r;if(t==="exit"&&f(this.#t)){typeof i[0]=="number"&&(this.#t.exitCode=i[0]);const r=n.call(this.#t,t,...i);return this.#e.emit("exit",this.#t.exitCode,null),r}else return n.call(this.#t,t,...i)}}const b=globalThis.process,{onExit:A,load:W,unload:B}=k(f(b)?new M(b):new U),x=u.stderr.isTTY?u.stderr:u.stdout.isTTY?u.stdout:void 0,H=x?w(()=>{A(()=>{x.write("\x1B[?25h")},{alwaysLast:!0})}):()=>{};export{H as default};