@rolldown/browser 1.0.0-beta.34 → 1.0.0-beta.35
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/cli.cjs +215 -210
- package/dist/cli.mjs +203 -203
- package/dist/config.cjs +3 -3
- package/dist/config.d.cts +1 -1
- package/dist/config.d.mts +1 -1
- package/dist/config.mjs +2 -2
- package/dist/experimental-index.browser.mjs +20 -6
- package/dist/experimental-index.cjs +25 -9
- package/dist/experimental-index.d.cts +13 -4
- package/dist/experimental-index.d.mts +13 -4
- package/dist/experimental-index.mjs +20 -6
- package/dist/filter-index.d.cts +1 -1
- package/dist/filter-index.d.mts +1 -1
- package/dist/index.browser.mjs +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/parallel-plugin-worker.cjs +6 -4
- package/dist/parallel-plugin-worker.mjs +2 -2
- package/dist/parallel-plugin.d.cts +1 -1
- package/dist/parallel-plugin.d.mts +1 -1
- package/dist/parse-ast-index.cjs +1 -1
- package/dist/rolldown-binding.wasi-browser.js +4 -0
- package/dist/rolldown-binding.wasi.cjs +4 -0
- package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
- package/dist/shared/{define-config-DzIQxNqU.d.mts → define-config-DJXaSinS.d.mts} +29 -2
- package/dist/shared/{define-config-D5AluabE.d.cts → define-config-DhrkZ_o7.d.cts} +29 -2
- package/dist/shared/{load-config--VYNOtUY.mjs → load-config-BCjD-AGJ.mjs} +1 -1
- package/dist/shared/{load-config-DfHD1OI9.cjs → load-config-BJKhRKZL.cjs} +11 -6
- package/dist/shared/{parse-ast-index-ChWj_C49.cjs → parse-ast-index-J0xVKZRe.cjs} +2 -1
- package/dist/shared/{prompt-QNI93ne7.cjs → prompt-Q05EYrFb.cjs} +8 -4
- package/dist/shared/{src-B4V64IkU.mjs → src-B0RCtUy7.mjs} +75 -31
- package/dist/shared/{src-McCMqGpa.cjs → src-Bd4BGX4v.cjs} +91 -41
- package/dist/{src-Bl12Y5ab.js → src-C8U06Im1.js} +73 -29
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -1,14 +1,220 @@
|
|
|
1
1
|
const require_chunk = require('./shared/chunk-DDkG_k5U.cjs');
|
|
2
|
-
const require_src = require('./shared/src-
|
|
3
|
-
require('./shared/parse-ast-index-
|
|
2
|
+
const require_src = require('./shared/src-Bd4BGX4v.cjs');
|
|
3
|
+
require('./shared/parse-ast-index-J0xVKZRe.cjs');
|
|
4
4
|
const require_dist = require('./shared/dist-CK0hotcm.cjs');
|
|
5
|
-
const require_load_config = require('./shared/load-config-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
const require_load_config = require('./shared/load-config-BJKhRKZL.cjs');
|
|
6
|
+
let node_path = require("node:path");
|
|
7
|
+
node_path = require_chunk.__toESM(node_path);
|
|
8
|
+
let node_process = require("node:process");
|
|
9
|
+
node_process = require_chunk.__toESM(node_process);
|
|
10
|
+
let node_util = require("node:util");
|
|
11
|
+
node_util = require_chunk.__toESM(node_util);
|
|
12
|
+
let node_tty = require("node:tty");
|
|
13
|
+
node_tty = require_chunk.__toESM(node_tty);
|
|
14
|
+
let node_perf_hooks = require("node:perf_hooks");
|
|
15
|
+
node_perf_hooks = require_chunk.__toESM(node_perf_hooks);
|
|
11
16
|
|
|
17
|
+
//#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
|
|
18
|
+
/**
|
|
19
|
+
* This is not the set of all possible signals.
|
|
20
|
+
*
|
|
21
|
+
* It IS, however, the set of all signals that trigger
|
|
22
|
+
* an exit on either Linux or BSD systems. Linux is a
|
|
23
|
+
* superset of the signal names supported on BSD, and
|
|
24
|
+
* the unknown signals just fail to register, so we can
|
|
25
|
+
* catch that easily enough.
|
|
26
|
+
*
|
|
27
|
+
* Windows signals are a different set, since there are
|
|
28
|
+
* signals that terminate Windows processes, but don't
|
|
29
|
+
* terminate (or don't even exist) on Posix systems.
|
|
30
|
+
*
|
|
31
|
+
* Don't bother with SIGKILL. It's uncatchable, which
|
|
32
|
+
* means that we can't fire any callbacks anyway.
|
|
33
|
+
*
|
|
34
|
+
* If a user does happen to register a handler on a non-
|
|
35
|
+
* fatal signal like SIGWINCH or something, and then
|
|
36
|
+
* exit, it'll end up firing `process.emit('exit')`, so
|
|
37
|
+
* the handler will be fired anyway.
|
|
38
|
+
*
|
|
39
|
+
* SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
|
|
40
|
+
* artificially, inherently leave the process in a
|
|
41
|
+
* state from which it is not safe to try and enter JS
|
|
42
|
+
* listeners.
|
|
43
|
+
*/
|
|
44
|
+
const signals = [];
|
|
45
|
+
signals.push("SIGHUP", "SIGINT", "SIGTERM");
|
|
46
|
+
if (process.platform !== "win32") signals.push("SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
|
|
47
|
+
if (process.platform === "linux") signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.js
|
|
51
|
+
const processOk = (process$3) => !!process$3 && typeof process$3 === "object" && typeof process$3.removeListener === "function" && typeof process$3.emit === "function" && typeof process$3.reallyExit === "function" && typeof process$3.listeners === "function" && typeof process$3.kill === "function" && typeof process$3.pid === "number" && typeof process$3.on === "function";
|
|
52
|
+
const kExitEmitter = Symbol.for("signal-exit emitter");
|
|
53
|
+
const global = globalThis;
|
|
54
|
+
const ObjectDefineProperty = Object.defineProperty.bind(Object);
|
|
55
|
+
var Emitter = class {
|
|
56
|
+
emitted = {
|
|
57
|
+
afterExit: false,
|
|
58
|
+
exit: false
|
|
59
|
+
};
|
|
60
|
+
listeners = {
|
|
61
|
+
afterExit: [],
|
|
62
|
+
exit: []
|
|
63
|
+
};
|
|
64
|
+
count = 0;
|
|
65
|
+
id = Math.random();
|
|
66
|
+
constructor() {
|
|
67
|
+
if (global[kExitEmitter]) return global[kExitEmitter];
|
|
68
|
+
ObjectDefineProperty(global, kExitEmitter, {
|
|
69
|
+
value: this,
|
|
70
|
+
writable: false,
|
|
71
|
+
enumerable: false,
|
|
72
|
+
configurable: false
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
on(ev, fn) {
|
|
76
|
+
this.listeners[ev].push(fn);
|
|
77
|
+
}
|
|
78
|
+
removeListener(ev, fn) {
|
|
79
|
+
const list = this.listeners[ev];
|
|
80
|
+
const i$1 = list.indexOf(fn);
|
|
81
|
+
/* c8 ignore start */
|
|
82
|
+
if (i$1 === -1) return;
|
|
83
|
+
/* c8 ignore stop */
|
|
84
|
+
if (i$1 === 0 && list.length === 1) list.length = 0;
|
|
85
|
+
else list.splice(i$1, 1);
|
|
86
|
+
}
|
|
87
|
+
emit(ev, code, signal) {
|
|
88
|
+
if (this.emitted[ev]) return false;
|
|
89
|
+
this.emitted[ev] = true;
|
|
90
|
+
let ret = false;
|
|
91
|
+
for (const fn of this.listeners[ev]) ret = fn(code, signal) === true || ret;
|
|
92
|
+
if (ev === "exit") ret = this.emit("afterExit", code, signal) || ret;
|
|
93
|
+
return ret;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
var SignalExitBase = class {};
|
|
97
|
+
const signalExitWrap = (handler) => {
|
|
98
|
+
return {
|
|
99
|
+
onExit(cb, opts) {
|
|
100
|
+
return handler.onExit(cb, opts);
|
|
101
|
+
},
|
|
102
|
+
load() {
|
|
103
|
+
return handler.load();
|
|
104
|
+
},
|
|
105
|
+
unload() {
|
|
106
|
+
return handler.unload();
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
var SignalExitFallback = class extends SignalExitBase {
|
|
111
|
+
onExit() {
|
|
112
|
+
return () => {};
|
|
113
|
+
}
|
|
114
|
+
load() {}
|
|
115
|
+
unload() {}
|
|
116
|
+
};
|
|
117
|
+
var SignalExit = class extends SignalExitBase {
|
|
118
|
+
/* c8 ignore start */
|
|
119
|
+
#hupSig = process$2.platform === "win32" ? "SIGINT" : "SIGHUP";
|
|
120
|
+
/* c8 ignore stop */
|
|
121
|
+
#emitter = new Emitter();
|
|
122
|
+
#process;
|
|
123
|
+
#originalProcessEmit;
|
|
124
|
+
#originalProcessReallyExit;
|
|
125
|
+
#sigListeners = {};
|
|
126
|
+
#loaded = false;
|
|
127
|
+
constructor(process$3) {
|
|
128
|
+
super();
|
|
129
|
+
this.#process = process$3;
|
|
130
|
+
this.#sigListeners = {};
|
|
131
|
+
for (const sig of signals) this.#sigListeners[sig] = () => {
|
|
132
|
+
const listeners = this.#process.listeners(sig);
|
|
133
|
+
let { count } = this.#emitter;
|
|
134
|
+
/* c8 ignore start */
|
|
135
|
+
const p = process$3;
|
|
136
|
+
if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") count += p.__signal_exit_emitter__.count;
|
|
137
|
+
/* c8 ignore stop */
|
|
138
|
+
if (listeners.length === count) {
|
|
139
|
+
this.unload();
|
|
140
|
+
const ret = this.#emitter.emit("exit", null, sig);
|
|
141
|
+
/* c8 ignore start */
|
|
142
|
+
const s$1 = sig === "SIGHUP" ? this.#hupSig : sig;
|
|
143
|
+
if (!ret) process$3.kill(process$3.pid, s$1);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
this.#originalProcessReallyExit = process$3.reallyExit;
|
|
147
|
+
this.#originalProcessEmit = process$3.emit;
|
|
148
|
+
}
|
|
149
|
+
onExit(cb, opts) {
|
|
150
|
+
/* c8 ignore start */
|
|
151
|
+
if (!processOk(this.#process)) return () => {};
|
|
152
|
+
/* c8 ignore stop */
|
|
153
|
+
if (this.#loaded === false) this.load();
|
|
154
|
+
const ev = opts?.alwaysLast ? "afterExit" : "exit";
|
|
155
|
+
this.#emitter.on(ev, cb);
|
|
156
|
+
return () => {
|
|
157
|
+
this.#emitter.removeListener(ev, cb);
|
|
158
|
+
if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) this.unload();
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
load() {
|
|
162
|
+
if (this.#loaded) return;
|
|
163
|
+
this.#loaded = true;
|
|
164
|
+
this.#emitter.count += 1;
|
|
165
|
+
for (const sig of signals) try {
|
|
166
|
+
const fn = this.#sigListeners[sig];
|
|
167
|
+
if (fn) this.#process.on(sig, fn);
|
|
168
|
+
} catch (_$1) {}
|
|
169
|
+
this.#process.emit = (ev, ...a$1) => {
|
|
170
|
+
return this.#processEmit(ev, ...a$1);
|
|
171
|
+
};
|
|
172
|
+
this.#process.reallyExit = (code) => {
|
|
173
|
+
return this.#processReallyExit(code);
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
unload() {
|
|
177
|
+
if (!this.#loaded) return;
|
|
178
|
+
this.#loaded = false;
|
|
179
|
+
signals.forEach((sig) => {
|
|
180
|
+
const listener = this.#sigListeners[sig];
|
|
181
|
+
/* c8 ignore start */
|
|
182
|
+
if (!listener) throw new Error("Listener not defined for signal: " + sig);
|
|
183
|
+
/* c8 ignore stop */
|
|
184
|
+
try {
|
|
185
|
+
this.#process.removeListener(sig, listener);
|
|
186
|
+
} catch (_$1) {}
|
|
187
|
+
/* c8 ignore stop */
|
|
188
|
+
});
|
|
189
|
+
this.#process.emit = this.#originalProcessEmit;
|
|
190
|
+
this.#process.reallyExit = this.#originalProcessReallyExit;
|
|
191
|
+
this.#emitter.count -= 1;
|
|
192
|
+
}
|
|
193
|
+
#processReallyExit(code) {
|
|
194
|
+
/* c8 ignore start */
|
|
195
|
+
if (!processOk(this.#process)) return 0;
|
|
196
|
+
this.#process.exitCode = code || 0;
|
|
197
|
+
/* c8 ignore stop */
|
|
198
|
+
this.#emitter.emit("exit", this.#process.exitCode, null);
|
|
199
|
+
return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
|
|
200
|
+
}
|
|
201
|
+
#processEmit(ev, ...args) {
|
|
202
|
+
const og = this.#originalProcessEmit;
|
|
203
|
+
if (ev === "exit" && processOk(this.#process)) {
|
|
204
|
+
if (typeof args[0] === "number") this.#process.exitCode = args[0];
|
|
205
|
+
/* c8 ignore start */
|
|
206
|
+
const ret = og.call(this.#process, ev, ...args);
|
|
207
|
+
/* c8 ignore start */
|
|
208
|
+
this.#emitter.emit("exit", this.#process.exitCode, null);
|
|
209
|
+
/* c8 ignore stop */
|
|
210
|
+
return ret;
|
|
211
|
+
} else return og.call(this.#process, ev, ...args);
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
const process$2 = globalThis.process;
|
|
215
|
+
const { onExit, load, unload } = signalExitWrap(processOk(process$2) ? new SignalExit(process$2) : new SignalExitFallback());
|
|
216
|
+
|
|
217
|
+
//#endregion
|
|
12
218
|
//#region ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/core.mjs
|
|
13
219
|
const LogLevels = {
|
|
14
220
|
silent: Number.NEGATIVE_INFINITY,
|
|
@@ -955,7 +1161,7 @@ function createConsola(options$1 = {}) {
|
|
|
955
1161
|
defaults: { level },
|
|
956
1162
|
stdout: process.stdout,
|
|
957
1163
|
stderr: process.stderr,
|
|
958
|
-
prompt: (...args) => Promise.resolve().then(() => require("./shared/prompt-
|
|
1164
|
+
prompt: (...args) => Promise.resolve().then(() => require("./shared/prompt-Q05EYrFb.cjs")).then((m) => m.prompt(...args)),
|
|
959
1165
|
reporters: options$1.reporters || [options$1.fancy ?? !(T || R) ? new FancyReporter() : new BasicReporter()],
|
|
960
1166
|
...options$1
|
|
961
1167
|
});
|
|
@@ -1221,207 +1427,6 @@ function parseCliArguments() {
|
|
|
1221
1427
|
return normalizeCliOptions(values, positionals);
|
|
1222
1428
|
}
|
|
1223
1429
|
|
|
1224
|
-
//#endregion
|
|
1225
|
-
//#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
|
|
1226
|
-
/**
|
|
1227
|
-
* This is not the set of all possible signals.
|
|
1228
|
-
*
|
|
1229
|
-
* It IS, however, the set of all signals that trigger
|
|
1230
|
-
* an exit on either Linux or BSD systems. Linux is a
|
|
1231
|
-
* superset of the signal names supported on BSD, and
|
|
1232
|
-
* the unknown signals just fail to register, so we can
|
|
1233
|
-
* catch that easily enough.
|
|
1234
|
-
*
|
|
1235
|
-
* Windows signals are a different set, since there are
|
|
1236
|
-
* signals that terminate Windows processes, but don't
|
|
1237
|
-
* terminate (or don't even exist) on Posix systems.
|
|
1238
|
-
*
|
|
1239
|
-
* Don't bother with SIGKILL. It's uncatchable, which
|
|
1240
|
-
* means that we can't fire any callbacks anyway.
|
|
1241
|
-
*
|
|
1242
|
-
* If a user does happen to register a handler on a non-
|
|
1243
|
-
* fatal signal like SIGWINCH or something, and then
|
|
1244
|
-
* exit, it'll end up firing `process.emit('exit')`, so
|
|
1245
|
-
* the handler will be fired anyway.
|
|
1246
|
-
*
|
|
1247
|
-
* SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
|
|
1248
|
-
* artificially, inherently leave the process in a
|
|
1249
|
-
* state from which it is not safe to try and enter JS
|
|
1250
|
-
* listeners.
|
|
1251
|
-
*/
|
|
1252
|
-
const signals = [];
|
|
1253
|
-
signals.push("SIGHUP", "SIGINT", "SIGTERM");
|
|
1254
|
-
if (process.platform !== "win32") signals.push("SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
|
|
1255
|
-
if (process.platform === "linux") signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
|
|
1256
|
-
|
|
1257
|
-
//#endregion
|
|
1258
|
-
//#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.js
|
|
1259
|
-
const processOk = (process$3) => !!process$3 && typeof process$3 === "object" && typeof process$3.removeListener === "function" && typeof process$3.emit === "function" && typeof process$3.reallyExit === "function" && typeof process$3.listeners === "function" && typeof process$3.kill === "function" && typeof process$3.pid === "number" && typeof process$3.on === "function";
|
|
1260
|
-
const kExitEmitter = Symbol.for("signal-exit emitter");
|
|
1261
|
-
const global = globalThis;
|
|
1262
|
-
const ObjectDefineProperty = Object.defineProperty.bind(Object);
|
|
1263
|
-
var Emitter = class {
|
|
1264
|
-
emitted = {
|
|
1265
|
-
afterExit: false,
|
|
1266
|
-
exit: false
|
|
1267
|
-
};
|
|
1268
|
-
listeners = {
|
|
1269
|
-
afterExit: [],
|
|
1270
|
-
exit: []
|
|
1271
|
-
};
|
|
1272
|
-
count = 0;
|
|
1273
|
-
id = Math.random();
|
|
1274
|
-
constructor() {
|
|
1275
|
-
if (global[kExitEmitter]) return global[kExitEmitter];
|
|
1276
|
-
ObjectDefineProperty(global, kExitEmitter, {
|
|
1277
|
-
value: this,
|
|
1278
|
-
writable: false,
|
|
1279
|
-
enumerable: false,
|
|
1280
|
-
configurable: false
|
|
1281
|
-
});
|
|
1282
|
-
}
|
|
1283
|
-
on(ev, fn) {
|
|
1284
|
-
this.listeners[ev].push(fn);
|
|
1285
|
-
}
|
|
1286
|
-
removeListener(ev, fn) {
|
|
1287
|
-
const list = this.listeners[ev];
|
|
1288
|
-
const i$1 = list.indexOf(fn);
|
|
1289
|
-
/* c8 ignore start */
|
|
1290
|
-
if (i$1 === -1) return;
|
|
1291
|
-
/* c8 ignore stop */
|
|
1292
|
-
if (i$1 === 0 && list.length === 1) list.length = 0;
|
|
1293
|
-
else list.splice(i$1, 1);
|
|
1294
|
-
}
|
|
1295
|
-
emit(ev, code, signal) {
|
|
1296
|
-
if (this.emitted[ev]) return false;
|
|
1297
|
-
this.emitted[ev] = true;
|
|
1298
|
-
let ret = false;
|
|
1299
|
-
for (const fn of this.listeners[ev]) ret = fn(code, signal) === true || ret;
|
|
1300
|
-
if (ev === "exit") ret = this.emit("afterExit", code, signal) || ret;
|
|
1301
|
-
return ret;
|
|
1302
|
-
}
|
|
1303
|
-
};
|
|
1304
|
-
var SignalExitBase = class {};
|
|
1305
|
-
const signalExitWrap = (handler) => {
|
|
1306
|
-
return {
|
|
1307
|
-
onExit(cb, opts) {
|
|
1308
|
-
return handler.onExit(cb, opts);
|
|
1309
|
-
},
|
|
1310
|
-
load() {
|
|
1311
|
-
return handler.load();
|
|
1312
|
-
},
|
|
1313
|
-
unload() {
|
|
1314
|
-
return handler.unload();
|
|
1315
|
-
}
|
|
1316
|
-
};
|
|
1317
|
-
};
|
|
1318
|
-
var SignalExitFallback = class extends SignalExitBase {
|
|
1319
|
-
onExit() {
|
|
1320
|
-
return () => {};
|
|
1321
|
-
}
|
|
1322
|
-
load() {}
|
|
1323
|
-
unload() {}
|
|
1324
|
-
};
|
|
1325
|
-
var SignalExit = class extends SignalExitBase {
|
|
1326
|
-
/* c8 ignore start */
|
|
1327
|
-
#hupSig = process$2.platform === "win32" ? "SIGINT" : "SIGHUP";
|
|
1328
|
-
/* c8 ignore stop */
|
|
1329
|
-
#emitter = new Emitter();
|
|
1330
|
-
#process;
|
|
1331
|
-
#originalProcessEmit;
|
|
1332
|
-
#originalProcessReallyExit;
|
|
1333
|
-
#sigListeners = {};
|
|
1334
|
-
#loaded = false;
|
|
1335
|
-
constructor(process$3) {
|
|
1336
|
-
super();
|
|
1337
|
-
this.#process = process$3;
|
|
1338
|
-
this.#sigListeners = {};
|
|
1339
|
-
for (const sig of signals) this.#sigListeners[sig] = () => {
|
|
1340
|
-
const listeners = this.#process.listeners(sig);
|
|
1341
|
-
let { count } = this.#emitter;
|
|
1342
|
-
/* c8 ignore start */
|
|
1343
|
-
const p = process$3;
|
|
1344
|
-
if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") count += p.__signal_exit_emitter__.count;
|
|
1345
|
-
/* c8 ignore stop */
|
|
1346
|
-
if (listeners.length === count) {
|
|
1347
|
-
this.unload();
|
|
1348
|
-
const ret = this.#emitter.emit("exit", null, sig);
|
|
1349
|
-
/* c8 ignore start */
|
|
1350
|
-
const s$1 = sig === "SIGHUP" ? this.#hupSig : sig;
|
|
1351
|
-
if (!ret) process$3.kill(process$3.pid, s$1);
|
|
1352
|
-
}
|
|
1353
|
-
};
|
|
1354
|
-
this.#originalProcessReallyExit = process$3.reallyExit;
|
|
1355
|
-
this.#originalProcessEmit = process$3.emit;
|
|
1356
|
-
}
|
|
1357
|
-
onExit(cb, opts) {
|
|
1358
|
-
/* c8 ignore start */
|
|
1359
|
-
if (!processOk(this.#process)) return () => {};
|
|
1360
|
-
/* c8 ignore stop */
|
|
1361
|
-
if (this.#loaded === false) this.load();
|
|
1362
|
-
const ev = opts?.alwaysLast ? "afterExit" : "exit";
|
|
1363
|
-
this.#emitter.on(ev, cb);
|
|
1364
|
-
return () => {
|
|
1365
|
-
this.#emitter.removeListener(ev, cb);
|
|
1366
|
-
if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) this.unload();
|
|
1367
|
-
};
|
|
1368
|
-
}
|
|
1369
|
-
load() {
|
|
1370
|
-
if (this.#loaded) return;
|
|
1371
|
-
this.#loaded = true;
|
|
1372
|
-
this.#emitter.count += 1;
|
|
1373
|
-
for (const sig of signals) try {
|
|
1374
|
-
const fn = this.#sigListeners[sig];
|
|
1375
|
-
if (fn) this.#process.on(sig, fn);
|
|
1376
|
-
} catch (_$1) {}
|
|
1377
|
-
this.#process.emit = (ev, ...a$1) => {
|
|
1378
|
-
return this.#processEmit(ev, ...a$1);
|
|
1379
|
-
};
|
|
1380
|
-
this.#process.reallyExit = (code) => {
|
|
1381
|
-
return this.#processReallyExit(code);
|
|
1382
|
-
};
|
|
1383
|
-
}
|
|
1384
|
-
unload() {
|
|
1385
|
-
if (!this.#loaded) return;
|
|
1386
|
-
this.#loaded = false;
|
|
1387
|
-
signals.forEach((sig) => {
|
|
1388
|
-
const listener = this.#sigListeners[sig];
|
|
1389
|
-
/* c8 ignore start */
|
|
1390
|
-
if (!listener) throw new Error("Listener not defined for signal: " + sig);
|
|
1391
|
-
/* c8 ignore stop */
|
|
1392
|
-
try {
|
|
1393
|
-
this.#process.removeListener(sig, listener);
|
|
1394
|
-
} catch (_$1) {}
|
|
1395
|
-
/* c8 ignore stop */
|
|
1396
|
-
});
|
|
1397
|
-
this.#process.emit = this.#originalProcessEmit;
|
|
1398
|
-
this.#process.reallyExit = this.#originalProcessReallyExit;
|
|
1399
|
-
this.#emitter.count -= 1;
|
|
1400
|
-
}
|
|
1401
|
-
#processReallyExit(code) {
|
|
1402
|
-
/* c8 ignore start */
|
|
1403
|
-
if (!processOk(this.#process)) return 0;
|
|
1404
|
-
this.#process.exitCode = code || 0;
|
|
1405
|
-
/* c8 ignore stop */
|
|
1406
|
-
this.#emitter.emit("exit", this.#process.exitCode, null);
|
|
1407
|
-
return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
|
|
1408
|
-
}
|
|
1409
|
-
#processEmit(ev, ...args) {
|
|
1410
|
-
const og = this.#originalProcessEmit;
|
|
1411
|
-
if (ev === "exit" && processOk(this.#process)) {
|
|
1412
|
-
if (typeof args[0] === "number") this.#process.exitCode = args[0];
|
|
1413
|
-
/* c8 ignore start */
|
|
1414
|
-
const ret = og.call(this.#process, ev, ...args);
|
|
1415
|
-
/* c8 ignore start */
|
|
1416
|
-
this.#emitter.emit("exit", this.#process.exitCode, null);
|
|
1417
|
-
/* c8 ignore stop */
|
|
1418
|
-
return ret;
|
|
1419
|
-
} else return og.call(this.#process, ev, ...args);
|
|
1420
|
-
}
|
|
1421
|
-
};
|
|
1422
|
-
const process$2 = globalThis.process;
|
|
1423
|
-
const { onExit, load, unload } = signalExitWrap(processOk(process$2) ? new SignalExit(process$2) : new SignalExitFallback());
|
|
1424
|
-
|
|
1425
1430
|
//#endregion
|
|
1426
1431
|
//#region src/utils/clear-screen.ts
|
|
1427
1432
|
const CLEAR_SCREEN = "\x1Bc";
|