brsh 3.10.1 → 3.10.3

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/wbt.es.js CHANGED
@@ -1440,11 +1440,12 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
1440
1440
  if (!this.captureInput) return;
1441
1441
  let t = a(e);
1442
1442
  for (let e of t) {
1443
- if (e === "^C" && !(this.stdinStream && this.stdinStream.isRaw)) {
1443
+ let t = !!(this.isRaw || this.stdinStream && this.stdinStream.isRaw);
1444
+ if (e === "^C" && !t) {
1444
1445
  this.kill("SIGINT");
1445
1446
  return;
1446
1447
  }
1447
- !this.interactive && !this.stdinStream.isRaw && (e === "Enter" ? this.stdout.write("\r\n") : e === "Backspace" ? this.stdout.write("\b \b") : e.length === 1 && this.stdout.write(e)), this.onInput(e);
1448
+ !this.interactive && !t && (e === "Enter" ? this.stdout.write("\r\n") : e === "Backspace" ? this.stdout.write("\b \b") : e.length === 1 && this.stdout.write(e)), this.onInput(e);
1448
1449
  }
1449
1450
  }, this.stdinStream.on("data", this._onStdinStreamData);
1450
1451
  }
@@ -1502,6 +1503,7 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
1502
1503
  }
1503
1504
  };
1504
1505
  })), re = /* @__PURE__ */ t(((e, t) => {
1506
+ b();
1505
1507
  var n = ne(), { parseVtKeys: r, hasCustomStdinListener: i } = te();
1506
1508
  function a(e) {
1507
1509
  return /^#!\/(sh\.js|bin\/(sh|brsh))/.test(e);
@@ -1519,7 +1521,11 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
1519
1521
  return !!(this.sandbox && this.sandbox.runningCommand && this.sandbox.runningCommand.interactive);
1520
1522
  }
1521
1523
  get isRaw() {
1522
- return !!(this.stdinStream && this.stdinStream.isRaw || this.sandbox && this.sandbox.runningCommand && (this.sandbox.runningCommand.isRaw || this.sandbox.runningCommand.stdinStream && this.sandbox.runningCommand.stdinStream.isRaw));
1524
+ if (this.sandbox && this.sandbox.runningCommand) {
1525
+ let e = this.sandbox.runningCommand;
1526
+ return !!(e.isRaw || e.stdinStream && e.stdinStream.isRaw);
1527
+ }
1528
+ return !!(this.stdinStream && this.stdinStream.isRaw);
1523
1529
  }
1524
1530
  get _inAltScreen() {
1525
1531
  return !!(this.__inAltScreen || this.sandbox && this.sandbox.runningCommand && this.sandbox.runningCommand._inAltScreen);
@@ -1528,10 +1534,14 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
1528
1534
  this.__inAltScreen = !!e;
1529
1535
  }
1530
1536
  onInput(e) {
1537
+ if ((e === "^C" || e === "") && !this.isRaw) {
1538
+ this.kill("SIGINT");
1539
+ return;
1540
+ }
1531
1541
  this.sandbox && this.sandbox.onInput(e);
1532
1542
  }
1533
1543
  kill(e = "SIGINT") {
1534
- this.sandbox && this.sandbox.runningCommand && typeof this.sandbox.runningCommand.kill == "function" && this.sandbox.runningCommand.kill(e), this.sandbox && typeof this.sandbox.destroy == "function" && this.sandbox.destroy(130), super.kill(e);
1544
+ this._killed = !0, this.sandbox && this.sandbox.runningCommand && typeof this.sandbox.runningCommand.kill == "function" && this.sandbox.runningCommand.kill(e), this.sandbox && typeof this.sandbox.destroy == "function" && this.sandbox.destroy(130), super.kill(e);
1535
1545
  }
1536
1546
  run() {
1537
1547
  this._managesOwnStdinCapture = !0;
@@ -1548,20 +1558,22 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
1548
1558
  typeof this.sandbox.setTerminalSize == "function" && this.sandbox.setTerminalSize(o, s), Array.isArray(this.arguments) && (this.arguments.forEach((e, t) => this.sandbox.context.setVar(String(t + 1), e)), this.sandbox.context.setVar("#", String(this.arguments.length)), this.sandbox.context.setVar("@", this.arguments.join(" ")), this.sandbox.context.setVar("*", this.arguments.join(" "))), this._onStdinStreamData && this.stdinStream && typeof this.stdinStream.off == "function" && this.stdinStream.off("data", this._onStdinStreamData);
1549
1559
  let c = (e) => {
1550
1560
  if (!this.sandbox || !this.sandbox.runningCommand) return;
1551
- let t = this.sandbox.runningCommand, n = i(t);
1552
- if (t.interactive || t._inAltScreen || n) {
1561
+ let t = this.sandbox.runningCommand, n = !!(t.isRaw || t.stdinStream && t.stdinStream.isRaw);
1562
+ if ((typeof e == "string" && e === "" || e instanceof Uint8Array && e.length === 1 && e[0] === 3 || y !== void 0 && y.isBuffer(e) && e.length === 1 && e[0] === 3) && !n) {
1563
+ this.kill("SIGINT");
1564
+ return;
1565
+ }
1566
+ let a = i(t);
1567
+ if (t.interactive || t._inAltScreen || a) {
1553
1568
  t.stdinStream && t.stdinStream.pushData(e);
1554
1569
  return;
1555
1570
  }
1556
- if (t.captureInput && typeof t.onInput == "function") {
1557
- let n = !!(t.isRaw || t.stdinStream && t.stdinStream.isRaw);
1558
- for (let i of r(e)) {
1559
- if (i === "^C" && !n) {
1560
- this.kill("SIGINT");
1561
- return;
1562
- }
1563
- n || (i === "Enter" ? this.stdout.write("\r\n") : i === "Backspace" ? this.stdout.write("\b \b") : i.length === 1 && this.stdout.write(i)), t.onInput(i);
1571
+ if (t.captureInput && typeof t.onInput == "function") for (let i of r(e)) {
1572
+ if (i === "^C" && !n) {
1573
+ this.kill("SIGINT");
1574
+ return;
1564
1575
  }
1576
+ n || (i === "Enter" ? this.stdout.write("\r\n") : i === "Backspace" ? this.stdout.write("\b \b") : i.length === 1 && this.stdout.write(i)), t.onInput(i);
1565
1577
  }
1566
1578
  }, l = () => {
1567
1579
  this.sandbox && typeof this.sandbox.setTerminalSize == "function" && this.stdinStream && this.sandbox.setTerminalSize(this.stdinStream.columns, this.stdinStream.rows);
@@ -1741,25 +1753,41 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
1741
1753
  };
1742
1754
  }
1743
1755
  async _executeNodes(e) {
1744
- for (let t of e) await this._executeNode(t);
1756
+ for (let t of e) {
1757
+ if (this._killed || this.sandbox && this.sandbox.destroyed) break;
1758
+ await this._executeNode(t);
1759
+ }
1745
1760
  }
1746
1761
  _executeNode(e) {
1762
+ if (this._killed || this.sandbox && this.sandbox.destroyed) return Promise.resolve();
1747
1763
  if (e.type === "function") {
1748
1764
  let t = e.name, n = e.bodyLines, r = this, i = ne(), a = class extends i {
1749
1765
  static get name() {
1750
1766
  return t;
1751
1767
  }
1752
1768
  run() {
1753
- let e = this.arguments.map((e, t) => ({
1754
- key: String(t + 1),
1755
- prev: r.sandbox.context.getVar(String(t + 1))
1756
- }));
1757
- this.arguments.forEach((e, t) => r.sandbox.context.setVar(String(t + 1), e));
1758
- let t = () => e.forEach(({ key: e, prev: t }) => t ? r.sandbox.context.setVar(e, t) : r.sandbox.context.unsetVar(e));
1769
+ let e = parseInt(r.sandbox.context.getVar("#") || "0", 10) || 0, t = Math.max(e, this.arguments.length), i = [];
1770
+ for (let e = 1; e <= t; e++) {
1771
+ let t = String(e);
1772
+ i.push({
1773
+ key: t,
1774
+ prev: r.sandbox.context.getVar(t)
1775
+ }), e <= this.arguments.length ? r.sandbox.context.setVar(t, this.arguments[e - 1]) : r.sandbox.context.unsetVar(t);
1776
+ }
1777
+ for (let e of [
1778
+ "#",
1779
+ "@",
1780
+ "*"
1781
+ ]) i.push({
1782
+ key: e,
1783
+ prev: r.sandbox.context.getVar(e)
1784
+ });
1785
+ r.sandbox.context.setVar("#", String(this.arguments.length)), r.sandbox.context.setVar("@", this.arguments.join(" ")), r.sandbox.context.setVar("*", this.arguments.join(" "));
1786
+ let a = () => i.forEach(({ key: e, prev: t }) => t ? r.sandbox.context.setVar(e, t) : r.sandbox.context.unsetVar(e));
1759
1787
  return r._executeFunctionBody(n).then(() => {
1760
- t();
1788
+ a();
1761
1789
  }).catch((e) => {
1762
- if (t(), e && e.__type === "return") {
1790
+ if (a(), e && e.__type === "return") {
1763
1791
  this.exitCode = e.code;
1764
1792
  return;
1765
1793
  }
@@ -1801,11 +1829,14 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
1801
1829
  return e.type === "if" ? this._executeIf(e) : e.type === "while" ? this._executeWhile(e) : e.type === "for" ? this._executeFor(e) : e.type === "case" ? this._executeCase(e) : Promise.resolve();
1802
1830
  }
1803
1831
  async _executeIf(e) {
1804
- for (let t of e.clauses) if (await this.sandbox.onCommand(t.condition, !1), this.sandbox.lastCode === 0) return this._executeNodes(this._parseLines(t.bodyLines));
1805
- if (e.elseLines.length > 0) return this._executeNodes(this._parseLines(e.elseLines));
1832
+ for (let t of e.clauses) {
1833
+ if (this._killed || this.sandbox && this.sandbox.destroyed || (await this.sandbox.onCommand(t.condition, !1), this._killed || this.sandbox && this.sandbox.destroyed)) return;
1834
+ if (this.sandbox.lastCode === 0) return this._executeNodes(this._parseLines(t.bodyLines));
1835
+ }
1836
+ if (e.elseLines.length > 0 && !this._killed && !(this.sandbox && this.sandbox.destroyed)) return this._executeNodes(this._parseLines(e.elseLines));
1806
1837
  }
1807
1838
  async _executeWhile(e) {
1808
- for (; await this.sandbox.onCommand(e.condition, !1), this.sandbox.lastCode === 0;) try {
1839
+ for (; !this._killed && !(this.sandbox && this.sandbox.destroyed) && (await this.sandbox.onCommand(e.condition, !1), !(this._killed || this.sandbox && this.sandbox.destroyed || this.sandbox.lastCode !== 0));) try {
1809
1840
  await this._executeNodes(this._parseLines(e.bodyLines));
1810
1841
  } catch (e) {
1811
1842
  if (e && e.__type === "break") {
@@ -1833,6 +1864,7 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
1833
1864
  for (let n = 1; n <= e; n++) t.push(this.sandbox.context.getVar(String(n)) || "");
1834
1865
  } else t = (await this.sandbox._replaceVariables(e.list)).split(/\s+/).filter(Boolean);
1835
1866
  for (let n of t) {
1867
+ if (this._killed || this.sandbox && this.sandbox.destroyed) break;
1836
1868
  this.sandbox.context.setVar(e.variable, n);
1837
1869
  try {
1838
1870
  await this._executeNodes(this._parseLines(e.bodyLines));
@@ -2974,14 +3006,14 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
2974
3006
  t.exports = null;
2975
3007
  })), X = /* @__PURE__ */ t(((e, t) => {
2976
3008
  b();
2977
- var n = re(), { BinaryFile: r } = J(), i = 0, a = 6, o = 8, s = 20, c = 27, l = 28, u = 31, d = 44, f = 54, p = 70, m = 0, h = 2, g = 3, _ = 4, v = 1, x = 2, S = 4, C = 8, w = 1, T = 4, E = class extends n {
3009
+ var n = re(), { BinaryFile: r } = J(), i = 0, a = 6, o = 8, s = 20, c = 27, l = 28, u = 31, d = 44, f = 54, p = 70, m = 0, h = 2, g = 3, _ = 4, v = 1, x = 2, S = 4, C = 8, w = 1, T = 4, E = 1, D = class extends n {
2978
3010
  constructor(e, t, n) {
2979
3011
  super(e, t, n), this._ensurePkgMeta();
2980
3012
  }
2981
3013
  _ensurePkgMeta() {
2982
3014
  if (this._pkgMeta === void 0 && this.script) {
2983
3015
  let e = this.context && this.context.fs || this.fs;
2984
- e && (this._pkgMeta = I(e, this.script));
3016
+ e && (this._pkgMeta = L(e, this.script));
2985
3017
  }
2986
3018
  return this._pkgMeta || null;
2987
3019
  }
@@ -3001,6 +3033,32 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
3001
3033
  get captureInput() {
3002
3034
  return this.interactive;
3003
3035
  }
3036
+ get isRaw() {
3037
+ if (typeof this._getTermiosLflag == "function") try {
3038
+ let e = (this._getTermiosLflag() >>> 0 & E) == 0;
3039
+ return this._inAltScreen && this.stdinStream && typeof this.stdinStream.setRawMode == "function" && this.stdinStream.isRaw !== e && this.stdinStream.setRawMode(e), e;
3040
+ } catch {}
3041
+ let e = this._ensurePkgMeta();
3042
+ return e && (e.raw !== void 0 || e.wasm?.raw !== void 0) ? !!(e.raw ?? e.wasm?.raw) : !!(this.stdinStream && this.stdinStream.isRaw);
3043
+ }
3044
+ _syncRawMode() {
3045
+ if (!this.stdinStream || typeof this.stdinStream.setRawMode != "function") return;
3046
+ if (!this._inAltScreen && !this._isInteractive) {
3047
+ this.stdinStream.isRaw && this.stdinStream.setRawMode(!1);
3048
+ return;
3049
+ }
3050
+ if (typeof this._getTermiosLflag == "function") try {
3051
+ let e = (this._getTermiosLflag() >>> 0 & E) == 0;
3052
+ this.stdinStream.setRawMode(e);
3053
+ return;
3054
+ } catch {}
3055
+ let e = this._ensurePkgMeta();
3056
+ if (e && (e.raw !== void 0 || e.wasm?.raw !== void 0)) {
3057
+ this.stdinStream.setRawMode(!!(e.raw ?? e.wasm?.raw));
3058
+ return;
3059
+ }
3060
+ this.stdinStream.setRawMode(!1);
3061
+ }
3004
3062
  kill(e = "SIGINT") {
3005
3063
  if (this._killed = !0, this.exitCode = 130, this._exitAltScreen(), this._asyncifyReject) {
3006
3064
  try {
@@ -3018,7 +3076,7 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
3018
3076
  super.kill(e);
3019
3077
  }
3020
3078
  _enterAltScreen() {
3021
- this._inAltScreen || (this._inAltScreen = !0, this.stdinStream && typeof this.stdinStream.setRawMode == "function" && this.stdinStream.setRawMode(!0), this.stdout && typeof this.stdout.write == "function" && this.stdout.write("\x1B[?1049h\x1B[2J\x1B[H"));
3079
+ this._inAltScreen || (this._inAltScreen = !0, this._syncRawMode(), this.stdout && typeof this.stdout.write == "function" && this.stdout.write("\x1B[?1049h\x1B[2J\x1B[H"));
3022
3080
  }
3023
3081
  _exitAltScreen() {
3024
3082
  this._inAltScreen && (this._inAltScreen = !1, this.stdinStream && typeof this.stdinStream.setRawMode == "function" && this.stdinStream.setRawMode(!1), this.stdout && typeof this.stdout.write == "function" && this.stdout.write("\x1B[0m\x1B[?1l\x1B[?1000l\x1B[?1002l\x1B[?1003l\x1B[?1006l\x1B[?1049l\x1B[?25h"));
@@ -3130,7 +3188,7 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
3130
3188
  isWat: this._isWat(e, i)
3131
3189
  });
3132
3190
  }
3133
- return r.then((e) => (!e.isWat && e.bytes && (this._inspectedWasm = M(e.bytes), this._inspectedWasm.isInteractive && (this._isInteractive = !0)), e));
3191
+ return r.then((e) => (!e.isWat && e.bytes && (this._inspectedWasm = N(e.bytes), this._inspectedWasm.isInteractive && (this._isInteractive = !0)), e));
3134
3192
  }
3135
3193
  _isWat(e, t) {
3136
3194
  return e.endsWith(".wat") ? !0 : t.length > 0 && t[0] === 40;
@@ -3171,10 +3229,10 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
3171
3229
  let t = {
3172
3230
  1: "",
3173
3231
  2: ""
3174
- }, n = new TextDecoder(), b = new TextEncoder(), E = null, D = null, O = !1, k = 0, A = null, j = null, P = null, F = !1, I = !1, L = !1, ee = null, R = null, z = null, B = this.stdin === void 0 || this.stdin === null || this.stdin === this.stdinStream || this.stdin && this.stdin.isTTY, V = !!(this.interactive && B);
3232
+ }, n = new TextDecoder(), b = new TextEncoder(), E = null, D = null, O = !1, k = 0, A = null, j = null, M = null, F = !1, I = !1, L = !1, ee = null, R = null, z = null, B = this.stdin === void 0 || this.stdin === null || this.stdin === this.stdinStream || this.stdin && this.stdin.isTTY, V = !!(this.interactive && B);
3175
3233
  V && (this.emit("interactive"), this.context && typeof this.context.emit == "function" && this.context.emit("interactive"));
3176
3234
  let H = () => {
3177
- V || !B || (V = !0, this._isInteractive = !0, this.emit("interactive"), this.context && typeof this.context.emit == "function" && this.context.emit("interactive"), this._enterAltScreen(), t[1] &&= (this.stdout && typeof this.stdout.write == "function" && this.stdout.write(t[1]), ""), t[2] &&= (this.stderr && typeof this.stderr.write == "function" && this.stderr.write(t[2]), ""), this.stdinStream && typeof this.stdinStream.setRawMode == "function" && this.stdinStream.setRawMode(!0));
3235
+ V || !B || (V = !0, this._isInteractive = !0, this.emit("interactive"), this.context && typeof this.context.emit == "function" && this.context.emit("interactive"), this._enterAltScreen(), t[1] &&= (this.stdout && typeof this.stdout.write == "function" && this.stdout.write(t[1]), ""), t[2] &&= (this.stderr && typeof this.stderr.write == "function" && this.stderr.write(t[2]), ""), this._syncRawMode());
3178
3236
  }, U = (e, n) => {
3179
3237
  if (V && (e === 1 || e === 2)) {
3180
3238
  if (e === 1 && this.stdout) {
@@ -3193,12 +3251,18 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
3193
3251
  }, te = () => {
3194
3252
  t[1] &&= (V && this.stdout ? this.stdout.write(t[1]) : this.stdOut = t[1], ""), t[2] &&= (V && this.stderr ? this.stderr.write(t[2]) : this.stdErr = t[2], "");
3195
3253
  }, W = [], ne = (e) => {
3196
- if (!(!e || e.length === 0)) {
3197
- for (let t = 0; t < e.length; t++) W.push(e[t]);
3198
- if (j) {
3199
- let e = j;
3200
- j = null, e();
3254
+ if (!e || e.length === 0) return;
3255
+ let t = this.isRaw;
3256
+ for (let n = 0; n < e.length; n++) {
3257
+ if (e[n] === 3 && !t) {
3258
+ this.kill("SIGINT");
3259
+ return;
3201
3260
  }
3261
+ W.push(e[n]);
3262
+ }
3263
+ if (j) {
3264
+ let e = j;
3265
+ j = null, e();
3202
3266
  }
3203
3267
  };
3204
3268
  z = (e) => {
@@ -3313,7 +3377,7 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
3313
3377
  if (!E) return o;
3314
3378
  let s = new DataView(E.buffer), l = Y.get(e), u = !!(l && l.type === "dev_tty");
3315
3379
  if (e === 0 || V && e === 2 || u) {
3316
- (u || e === 2) && H();
3380
+ (u || e === 2) && H(), this._syncRawMode();
3317
3381
  let o = !!((X.get(e) || 0) & T);
3318
3382
  if (O) {
3319
3383
  if ((typeof D?.exports?.asyncify_get_state == "function" ? D.exports.asyncify_get_state() : 0) === 2) {
@@ -3336,10 +3400,10 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
3336
3400
  }
3337
3401
  return o ? (s.setUint32(r, 0, !0), a) : (L = !1, D.exports.asyncify_start_unwind(k), A = new Promise((e, t) => {
3338
3402
  let n = () => {
3339
- L = !1, j = null, P = null, this._pendingReadResolve = null, this._asyncifyReject = null, e();
3403
+ L = !1, j = null, M = null, this._pendingReadResolve = null, this._asyncifyReject = null, e();
3340
3404
  };
3341
- j = n, this._pendingReadResolve = n, P = () => {
3342
- L = !0, j = null, P = null, this._pendingReadResolve = null, this._asyncifyReject = null, e();
3405
+ j = n, this._pendingReadResolve = n, M = () => {
3406
+ L = !0, j = null, M = null, this._pendingReadResolve = null, this._asyncifyReject = null, e();
3343
3407
  }, this._asyncifyReject = t;
3344
3408
  }), s.setUint32(r, 0, !0), i);
3345
3409
  }
@@ -3647,12 +3711,19 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
3647
3711
  let e = BigInt(Date.now()) * 1000000n;
3648
3712
  c = s > e ? Number((s - e) / 1000000n) : 0;
3649
3713
  } else c = Number(s / 1000000n);
3650
- return O && c > 0 ? (typeof D?.exports?.asyncify_get_state == "function" ? D.exports.asyncify_get_state() : 0) === 2 ? (D.exports.asyncify_stop_rewind(), i) : (D.exports.asyncify_start_unwind(k), A = new Promise((e) => setTimeout(e, Math.max(1, c))), i) : i;
3714
+ return O && c > 0 ? (typeof D?.exports?.asyncify_get_state == "function" ? D.exports.asyncify_get_state() : 0) === 2 ? (D.exports.asyncify_stop_rewind(), i) : (D.exports.asyncify_start_unwind(k), A = new Promise((e, t) => {
3715
+ let n = setTimeout(() => {
3716
+ this._asyncifyReject = null, e();
3717
+ }, Math.max(1, c));
3718
+ this._asyncifyReject = (e) => {
3719
+ clearTimeout(n), this._asyncifyReject = null, t(e);
3720
+ };
3721
+ }), i) : i;
3651
3722
  },
3652
3723
  poll_oneoff: (e, t, n, r) => {
3653
3724
  if (!E) return o;
3654
3725
  let a = new DataView(E.buffer);
3655
- if (O) {
3726
+ if (this._syncRawMode(), O) {
3656
3727
  if ((typeof D?.exports?.asyncify_get_state == "function" ? D.exports.asyncify_get_state() : 0) === 2) {
3657
3728
  if (D.exports.asyncify_stop_rewind(), I && W.length === 0) return I = !1, a.setUint32(r, 0, !0), c;
3658
3729
  I = !1;
@@ -3709,14 +3780,16 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
3709
3780
  }
3710
3781
  return F = !1, I = !1, D.exports.asyncify_start_unwind(k), A = new Promise((e, t) => {
3711
3782
  let n = null;
3712
- this._asyncifyReject = t;
3783
+ this._asyncifyReject = (e) => {
3784
+ n && clearTimeout(n), j = null, M = null, this._pendingReadResolve = null, this._asyncifyReject = null, t(e);
3785
+ };
3713
3786
  let r = () => {
3714
- n && clearTimeout(n), F = !1, I = !1, j = null, P = null, this._pendingReadResolve = null, this._asyncifyReject = null, e();
3787
+ n && clearTimeout(n), F = !1, I = !1, j = null, M = null, this._pendingReadResolve = null, this._asyncifyReject = null, e();
3715
3788
  };
3716
- s && (j = r, this._pendingReadResolve = r, P = () => {
3717
- n && clearTimeout(n), F = !1, I = !0, j = null, P = null, this._pendingReadResolve = null, this._asyncifyReject = null, e();
3789
+ s && (j = r, this._pendingReadResolve = r, M = () => {
3790
+ n && clearTimeout(n), F = !1, I = !0, j = null, M = null, this._pendingReadResolve = null, this._asyncifyReject = null, e();
3718
3791
  }), l !== Infinity && (n = setTimeout(() => {
3719
- F = !0, I = !1, j = null, P = null, this._pendingReadResolve = null, this._asyncifyReject = null, e();
3792
+ F = !0, I = !1, j = null, M = null, this._pendingReadResolve = null, this._asyncifyReject = null, e();
3720
3793
  }, Math.max(1, l)));
3721
3794
  }), a.setUint32(r, 0, !0), i;
3722
3795
  }
@@ -3776,7 +3849,7 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
3776
3849
  });
3777
3850
  E = t, $[e.module] || ($[e.module] = {}), $[e.module][e.name] = t;
3778
3851
  }
3779
- if (D = await WebAssembly.instantiate(t, $), D.exports.memory && (E = D.exports.memory), O = !!(D.exports.asyncify_start_unwind && D.exports.asyncify_stop_unwind), O && E) {
3852
+ if (D = await WebAssembly.instantiate(t, $), D.exports.memory && (E = D.exports.memory), this._getTermiosLflag = typeof D.exports.get_termios_lflag == "function" ? D.exports.get_termios_lflag : null, O = !!(D.exports.asyncify_start_unwind && D.exports.asyncify_stop_unwind), O && E) {
3780
3853
  try {
3781
3854
  k = E.grow(1) * 65536;
3782
3855
  } catch {
@@ -3785,7 +3858,7 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
3785
3858
  let e = k + 8, t = k + 65536 - 8;
3786
3859
  new Int32Array(E.buffer, k, 2).set([e, t]);
3787
3860
  }
3788
- typeof D.exports.set_terminal_size == "function" && H(), V && this._enterAltScreen();
3861
+ typeof D.exports.set_terminal_size == "function" && H(), V && (this._enterAltScreen(), this._syncRawMode());
3789
3862
  let n = this.stdout && this.stdout.columns || this.stdinStream && this.stdinStream.columns || this.context && typeof this.context.getVar == "function" && parseInt(this.context.getVar("COLUMNS"), 10) || 80, r = this.stdout && this.stdout.rows || this.stdinStream && this.stdinStream.rows || this.context && typeof this.context.getVar == "function" && parseInt(this.context.getVar("LINES"), 10) || 24;
3790
3863
  if (typeof D.exports.set_terminal_size == "function") try {
3791
3864
  D.exports.set_terminal_size(n, r);
@@ -3799,9 +3872,9 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
3799
3872
  if (i = e, a = t, typeof D?.exports?.set_terminal_size == "function") try {
3800
3873
  D.exports.set_terminal_size(e, t);
3801
3874
  } catch {}
3802
- if (P) {
3803
- let e = P;
3804
- P = null, e();
3875
+ if (M) {
3876
+ let e = M;
3877
+ M = null, e();
3805
3878
  }
3806
3879
  }
3807
3880
  }
@@ -3846,7 +3919,7 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
3846
3919
  } catch (e) {
3847
3920
  this._killed ? this.exitCode = 130 : (!e || !e._wasmExit) && (this.stdErr = `${this.script}: ${e?.message || String(e)}`, this.exitCode = 1);
3848
3921
  } finally {
3849
- V && this._exitAltScreen(), z && (this.stdinStream && typeof this.stdinStream.off == "function" && this.stdinStream.off("data", z), this.stdin && typeof this.stdin.off == "function" && this.stdin.off("data", z)), re && this._onStdinStreamData && this.stdinStream && typeof this.stdinStream.on == "function" && this.stdinStream.on("data", this._onStdinStreamData), ee && this.stdout && typeof this.stdout.off == "function" && this.stdout.off("resize", ee), R && this.stdinStream && typeof this.stdinStream.off == "function" && this.stdinStream.off("resize", R), this._externalKeyHandler = null;
3922
+ V && this._exitAltScreen(), z && (this.stdinStream && typeof this.stdinStream.off == "function" && this.stdinStream.off("data", z), this.stdin && typeof this.stdin.off == "function" && this.stdin.off("data", z)), re && this._onStdinStreamData && this.stdinStream && typeof this.stdinStream.on == "function" && this.stdinStream.on("data", this._onStdinStreamData), ee && this.stdout && typeof this.stdout.off == "function" && this.stdout.off("resize", ee), R && this.stdinStream && typeof this.stdinStream.off == "function" && this.stdinStream.off("resize", R), this._externalKeyHandler = null, this._getTermiosLflag = null;
3850
3923
  for (let e of Y.values()) se(e);
3851
3924
  }
3852
3925
  te();
@@ -3858,13 +3931,13 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
3858
3931
  description: `WebAssembly WASI binary (${this.script})`
3859
3932
  }, t || {});
3860
3933
  if (pe.includes("--help") || pe.includes("-h")) {
3861
- let t = M(e);
3862
- for (let e of N(n, r, t)) this.stdOut = e;
3934
+ let t = N(e);
3935
+ for (let e of P(n, r, t)) this.stdOut = e;
3863
3936
  } else (pe.includes("--version") || pe.includes("-V") || pe.includes("-v")) && (this.stdOut = `${n} (${r.name} ${r.version} wasm)`);
3864
3937
  }
3865
3938
  }
3866
- }, D = /* @__PURE__ */ new Map();
3867
- function O(e, t) {
3939
+ }, O = /* @__PURE__ */ new Map();
3940
+ function k(e, t) {
3868
3941
  if (!e || !e.exists(t)) return null;
3869
3942
  if (e.isRealFilesystem) try {
3870
3943
  let n = Y();
@@ -3891,7 +3964,7 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
3891
3964
  }
3892
3965
  return null;
3893
3966
  }
3894
- function k(e, t, n, i = "application/octet-stream") {
3967
+ function A(e, t, n, i = "application/octet-stream") {
3895
3968
  let a = n instanceof Uint8Array ? n : new Uint8Array(n);
3896
3969
  if (e && e.isRealFilesystem) {
3897
3970
  e.setFileByPath(t, a, !0);
@@ -3906,7 +3979,7 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
3906
3979
  }
3907
3980
  e.setFileByPath(t, s, !0);
3908
3981
  }
3909
- async function A(e, t, n = null) {
3982
+ async function j(e, t, n = null) {
3910
3983
  if (typeof n == "function") {
3911
3984
  let r = await n(e, t);
3912
3985
  if (r) return r;
@@ -3934,7 +4007,7 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
3934
4007
  }
3935
4008
  throw Error(`Package '${e}' could not be loaded`);
3936
4009
  }
3937
- function j(e, t = !1) {
4010
+ function M(e, t = !1) {
3938
4011
  let n = {
3939
4012
  usage: null,
3940
4013
  options: []
@@ -3951,7 +4024,7 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
3951
4024
  }
3952
4025
  return n;
3953
4026
  }
3954
- function M(e) {
4027
+ function N(e) {
3955
4028
  let t = {
3956
4029
  usage: null,
3957
4030
  options: [],
@@ -3976,12 +4049,12 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
3976
4049
  r.length >= 4 && n.push(r);
3977
4050
  let i = n.join("\n");
3978
4051
  t.isInteractive || (i.includes("/dev/tty") || i.includes("\x1B[?1049h") || i.includes("smcup") || i.includes("xterm")) && (t.isInteractive = !0);
3979
- let a = j(i, !0);
4052
+ let a = M(i, !0);
3980
4053
  t.usage = a.usage, t.options = a.options;
3981
4054
  } catch {}
3982
4055
  return t;
3983
4056
  }
3984
- function N(e, t = {}, n = null) {
4057
+ function P(e, t = {}, n = null) {
3985
4058
  let r = t.name || e, i = t.version || "wasm", a = t.description || "WebAssembly binary", o = t && typeof t.repl == "object" ? t.repl : t.repl ? {} : null, s = n && n.usage || t.usage, c = s ? s.replace(/%s/g, e) : null, l = o ? `${e} [options] ${o.evalFlag ? `[${o.evalFlag} <code>] ` : ""}[file] [args...]` : `${e} [options] [args...]`, u = [`${e} (${r} ${i} wasm) — ${a}`, `Usage: ${c || l}`];
3986
4059
  t.details && u.push("", t.details), u.push("", "Options:");
3987
4060
  let d = n && n.options && n.options.length > 0 ? n.options : Array.isArray(t.options) ? t.options : [];
@@ -3989,7 +4062,7 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
3989
4062
  else o && (o.evalFlag && u.push(` ${o.evalFlag.padEnd(20)}Evaluate inline code and print result`), u.push(` (no arguments) Start interactive ${e} REPL shell`));
3990
4063
  return u.push(" -h, --help Show this help message and exit"), u.push(" -V, --version Show WebAssembly binary version and exit"), n && n.exports && n.exports.length > 0 && u.push("", `WASM Exports: ${n.exports.join(", ")}`), Array.isArray(t.aliases) && t.aliases.length > 0 && u.push("", `Aliases: ${t.aliases.join(", ")}`), (t.homepage || t.cdnUrl || t.wasmUrl) && u.push(`Source: ${t.homepage || t.cdnUrl || t.wasmUrl}`), u;
3991
4064
  }
3992
- function P(e, t = {}, n = null) {
4065
+ function F(e, t = {}, n = null) {
3993
4066
  let r = W(), i = (n || e.bin || e.name).toLowerCase();
3994
4067
  class a extends r {
3995
4068
  static get name() {
@@ -4008,7 +4081,7 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
4008
4081
  return this._subCommand ? !!this._subCommand.captureInput : this.interactive;
4009
4082
  }
4010
4083
  get isRaw() {
4011
- return !!(this.stdinStream && this.stdinStream.isRaw || this._subCommand && (this._subCommand.isRaw || this._subCommand.stdinStream && this._subCommand.stdinStream.isRaw));
4084
+ return this._subCommand ? !!(this._subCommand.isRaw || this._subCommand.stdinStream && this._subCommand.stdinStream.isRaw) : !!(this.stdinStream && this.stdinStream.isRaw);
4012
4085
  }
4013
4086
  get _inAltScreen() {
4014
4087
  return !!(this.__inAltScreen || this._subCommand && this._subCommand._inAltScreen);
@@ -4024,7 +4097,7 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
4024
4097
  }
4025
4098
  async run() {
4026
4099
  let n = [...this.arguments || []], r = n.includes("--help") || n.includes("-h"), a = !r && (n.includes("--version") || n.includes("-V") || n.includes("-v")), o = this.fs || this.context && this.context.fs;
4027
- this._inspectedWasm = null, this._persistedWasmBytes = e.wasmPath ? O(o, e.wasmPath) : null, r && this._persistedWasmBytes && this._persistedWasmBytes.byteLength > 0 && (this._inspectedWasm = M(this._persistedWasmBytes));
4100
+ this._inspectedWasm = null, this._persistedWasmBytes = e.wasmPath ? k(o, e.wasmPath) : null, r && this._persistedWasmBytes && this._persistedWasmBytes.byteLength > 0 && (this._inspectedWasm = N(this._persistedWasmBytes));
4028
4101
  try {
4029
4102
  if ((e.type === "wasm" || e.type === "custom-wasm") && (this._persistedWasmBytes || e.wasmUrl)) {
4030
4103
  let i = this._persistedWasmBytes;
@@ -4033,7 +4106,7 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
4033
4106
  n instanceof Uint8Array || n instanceof ArrayBuffer ? i = n instanceof Uint8Array ? n : new Uint8Array(n) : n && (n.wasmBytes || n.wasm || n.wasmBinary) && (i = n.wasmBytes || n.wasm || n.wasmBinary);
4034
4107
  } catch {}
4035
4108
  if (!i && e.wasmUrl && (i = await this._fetchWasmBytes(e.wasmUrl)), i) {
4036
- r && (this._inspectedWasm = M(i)), await this._runRawWasmBytes(i, n);
4109
+ r && (this._inspectedWasm = N(i)), await this._runRawWasmBytes(i, n);
4037
4110
  return;
4038
4111
  }
4039
4112
  } else {
@@ -4050,19 +4123,19 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
4050
4123
  }
4051
4124
  let c, l;
4052
4125
  try {
4053
- c = await A(e.name, o, t.moduleLoader), l = c && c.default !== void 0 ? c.default : c, l && typeof l.then == "function" && (l = await l);
4126
+ c = await j(e.name, o, t.moduleLoader), l = c && c.default !== void 0 ? c.default : c, l && typeof l.then == "function" && (l = await l);
4054
4127
  } finally {
4055
4128
  s && (globalThis.fetch = s);
4056
4129
  }
4057
4130
  if (l instanceof Uint8Array || l instanceof ArrayBuffer) {
4058
4131
  let e = l instanceof Uint8Array ? l : new Uint8Array(l);
4059
- r && (this._inspectedWasm = M(e)), await this._runRawWasmBytes(e, n);
4132
+ r && (this._inspectedWasm = N(e)), await this._runRawWasmBytes(e, n);
4060
4133
  } else if (l && (l.wasmBytes instanceof Uint8Array || l.wasm instanceof Uint8Array)) {
4061
4134
  let e = l.wasmBytes || l.wasm;
4062
- r && (this._inspectedWasm = M(e)), await this._runRawWasmBytes(e, n);
4135
+ r && (this._inspectedWasm = N(e)), await this._runRawWasmBytes(e, n);
4063
4136
  } else if (typeof l == "function") await this._runFunctionOrEmscripten(l, n, r, a);
4064
4137
  else if (l && typeof l == "object") {
4065
- l.ready && await l.ready, r && (l.HEAPU8 instanceof Uint8Array || l.wasmBinary instanceof Uint8Array) && (this._inspectedWasm = M(l.wasmBinary || l.HEAPU8));
4138
+ l.ready && await l.ready, r && (l.HEAPU8 instanceof Uint8Array || l.wasmBinary instanceof Uint8Array) && (this._inspectedWasm = N(l.wasmBinary || l.HEAPU8));
4066
4139
  let t = l.main || l.run || l.callMain || l.exec;
4067
4140
  if (typeof t == "function") await this._invokeCliFunction(t.bind(l), n);
4068
4141
  else if (l.promised || typeof l.raw == "function" || typeof l.json == "function") {
@@ -4090,29 +4163,29 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
4090
4163
  }
4091
4164
  }
4092
4165
  if (r || a) {
4093
- let t = this.result && this.result.getStdOutput ? this.result.getStdOutput() : [], n = t.map((e) => e.string).join("\n"), o = r ? j(n) : null, s = r && !!(o && (o.usage || o.options.length > 0) || t.some((e) => /\b(usage|options):/i.test(e.string))), c = t.filter((e) => e.type === "out").map((e) => e.string), l = a && c.length > 0 && (this.exitCode === 0 || this.exitCode === void 0);
4166
+ let t = this.result && this.result.getStdOutput ? this.result.getStdOutput() : [], n = t.map((e) => e.string).join("\n"), o = r ? M(n) : null, s = r && !!(o && (o.usage || o.options.length > 0) || t.some((e) => /\b(usage|options):/i.test(e.string))), c = t.filter((e) => e.type === "out").map((e) => e.string), l = a && c.length > 0 && (this.exitCode === 0 || this.exitCode === void 0);
4094
4167
  if (r) if (s) {
4095
4168
  let e = t.map((e) => e.string);
4096
4169
  this.result && Array.isArray(this.result.std) && (this.result.std.length = 0), this.exitCode = 0;
4097
4170
  for (let t of e) this.stdOut = t;
4098
4171
  } else {
4099
4172
  this.result && Array.isArray(this.result.std) && (this.result.std.length = 0), this.exitCode = 0;
4100
- for (let t of N(i, e, this._inspectedWasm)) this.stdOut = t;
4173
+ for (let t of P(i, e, this._inspectedWasm)) this.stdOut = t;
4101
4174
  }
4102
4175
  else a && !l ? (this.result && Array.isArray(this.result.std) && (this.result.std.length = 0), this.exitCode = 0, this.stdOut = `${i} (${e.name} ${e.version || "wasm"} wasm)`) : this.exitCode = 0;
4103
4176
  }
4104
4177
  }
4105
4178
  async _fetchWasmBytes(e) {
4106
- if (D.has(e)) return D.get(e);
4179
+ if (O.has(e)) return O.get(e);
4107
4180
  let n = t.fetch || (typeof fetch == "function" ? fetch : null);
4108
4181
  if (!n) throw Error("fetch is not available in this environment");
4109
4182
  let r = await n(e);
4110
4183
  if (!r || !r.ok) throw Error(`HTTP ${r ? r.status : "error"} fetching ${e}`);
4111
4184
  let i = new Uint8Array(await r.arrayBuffer());
4112
- return D.set(e, i), i;
4185
+ return O.set(e, i), i;
4113
4186
  }
4114
4187
  async _runRawWasmBytes(t, n) {
4115
- let r = new E(i, n, this.context);
4188
+ let r = new D(i, n, this.context);
4116
4189
  r.script = i, r.arguments = n, r.context = this.context, r.fs = this.fs, r._pkgMeta = e, r.stdinStream = this.stdinStream, r.stdout = this.stdout, r.stderr = this.stderr, r.stdin = this.stdin && !this.stdin.isTTY ? this.stdin : this.stdinStream, this._onStdinStreamData && this.stdinStream && typeof this.stdinStream.off == "function" && this.stdinStream.off("data", this._onStdinStreamData);
4117
4190
  let a = () => {
4118
4191
  this.emit("interactive"), this.context && typeof this.context.emit == "function" && this.context.emit("interactive");
@@ -4145,13 +4218,13 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
4145
4218
  let n = t && t !== "." && !e.startsWith("/") ? `${t.replace(/\/+$/, "")}/${e}` : e, r = this.fs.getFileByPath(n) ?? this.fs.getFileByPath(e);
4146
4219
  return r == null ? null : typeof r == "string" ? r : new TextDecoder().decode(r);
4147
4220
  },
4148
- readBytes: (e) => O(this.fs, e),
4221
+ readBytes: (e) => k(this.fs, e),
4149
4222
  writeFile: (e, t, n) => {
4150
4223
  if (!this.fs) return;
4151
4224
  let r = n && n !== "." && !e.startsWith("/") ? `${n.replace(/\/+$/, "")}/${e}` : e;
4152
4225
  if (t instanceof Uint8Array || ArrayBuffer.isView(t)) {
4153
4226
  let e = r.endsWith(".wasm") ? "application/wasm" : "application/octet-stream";
4154
- k(this.fs, r, t, e);
4227
+ A(this.fs, r, t, e);
4155
4228
  } else this.fs.setFileByPath(r, String(t), !0);
4156
4229
  if (r.endsWith(".wasm") || r.endsWith(".wat")) try {
4157
4230
  this.fs.setMode(r, 493);
@@ -4187,7 +4260,7 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
4187
4260
  if (e && typeof e.status == "number") this.exitCode = e.status;
4188
4261
  else throw e;
4189
4262
  }
4190
- if (f && typeof f == "object") if (r && (f.wasmBinary instanceof Uint8Array || f.HEAPU8 instanceof Uint8Array) && (this._inspectedWasm = M(f.wasmBinary || f.HEAPU8)), typeof f.callMain == "function") {
4263
+ if (f && typeof f == "object") if (r && (f.wasmBinary instanceof Uint8Array || f.HEAPU8 instanceof Uint8Array) && (this._inspectedWasm = N(f.wasmBinary || f.HEAPU8)), typeof f.callMain == "function") {
4191
4264
  f.FS && l.size === 0 && (l = this._syncBrshToEmscriptenFs(f.FS, n));
4192
4265
  try {
4193
4266
  let e = await f.callMain(n);
@@ -4250,14 +4323,14 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
4250
4323
  }), !t.loaded && typeof t.load == "function" && await t.load(e.coreUrl ? { coreURL: e.coreUrl } : void 0);
4251
4324
  let a = /* @__PURE__ */ new Set(), o = [];
4252
4325
  for (let e of n) if (!e.startsWith("-") && (o.push(e), this.fs.exists(e))) {
4253
- let n = O(this.fs, e);
4326
+ let n = k(this.fs, e);
4254
4327
  n && (await t.writeFile(e, n), a.add(e));
4255
4328
  }
4256
4329
  let s = await t.exec(n);
4257
4330
  for (let e of o) if (!a.has(e)) try {
4258
4331
  if (typeof t.readFile == "function") {
4259
4332
  let n = await t.readFile(e);
4260
- n && k(this.fs, e, n);
4333
+ n && A(this.fs, e, n);
4261
4334
  }
4262
4335
  } catch {}
4263
4336
  typeof s == "number" && s !== 0 && (this.exitCode = s, i.length === 0 && r.length > 0 && i.push(...r.splice(0, r.length)));
@@ -4274,7 +4347,7 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
4274
4347
  let n = /* @__PURE__ */ new Set();
4275
4348
  if (!this.fs || !e || typeof e.writeFile != "function") return n;
4276
4349
  for (let r of t) if (!r.startsWith("-") && this.fs.exists(r)) {
4277
- let t = O(this.fs, r);
4350
+ let t = k(this.fs, r);
4278
4351
  if (t) try {
4279
4352
  e.writeFile(r, t), n.add(r);
4280
4353
  } catch {}
@@ -4287,7 +4360,7 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
4287
4360
  let t = e.readFile(r);
4288
4361
  if (t) {
4289
4362
  let e = r.endsWith(".wasm") ? "application/wasm" : "application/octet-stream";
4290
- if (k(this.fs, r, t, e), r.endsWith(".wasm") || r.endsWith(".wat")) try {
4363
+ if (A(this.fs, r, t, e), r.endsWith(".wasm") || r.endsWith(".wat")) try {
4291
4364
  this.fs.setMode(r, 493);
4292
4365
  } catch {}
4293
4366
  }
@@ -4297,10 +4370,10 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
4297
4370
  }
4298
4371
  return a;
4299
4372
  }
4300
- function F(e, t) {
4373
+ function I(e, t) {
4301
4374
  return e && (e.endsWith(".wasm") || e.endsWith(".wat")) ? !0 : t instanceof Uint8Array ? t.length >= 4 && t[0] === 0 && t[1] === 97 && t[2] === 115 && t[3] === 109 : typeof t == "string" ? t.charCodeAt(0) === 0 && t.slice(1, 4) === "asm" ? !0 : t.trimStart().startsWith("(module") : !1;
4302
4375
  }
4303
- function I(e, t) {
4376
+ function L(e, t) {
4304
4377
  if (!e || !t || typeof e.exists != "function" || typeof e.getFileByPath != "function") return null;
4305
4378
  try {
4306
4379
  let n = t.split("/").filter(Boolean);
@@ -4313,7 +4386,7 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
4313
4386
  } catch {}
4314
4387
  return null;
4315
4388
  }
4316
- E.isWasmFile = F, E.readSiblingPkgMeta = I, E.readBytesFromFs = O, E.writeBytesToFs = k, E.loadModule = A, E.extractHelpFromText = j, E.inspectWasmBytes = M, E.formatWasmHelp = N, E.createGenericWasmCommand = P, E.createCommand = P, t.exports = E;
4389
+ D.isWasmFile = I, D.readSiblingPkgMeta = L, D.readBytesFromFs = k, D.writeBytesToFs = A, D.loadModule = j, D.extractHelpFromText = M, D.inspectWasmBytes = N, D.formatWasmHelp = P, D.createGenericWasmCommand = F, D.createCommand = F, t.exports = D;
4317
4390
  })), oe = /* @__PURE__ */ t(((e, t) => {
4318
4391
  var n = {
4319
4392
  sqlite3: {
@@ -5582,7 +5655,16 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
5582
5655
  return this._activeSubCommand && this._activeSubCommand.captureInput !== void 0 ? !!this._activeSubCommand.captureInput : this.interactive;
5583
5656
  }
5584
5657
  get isRaw() {
5585
- return !!(this.stdinStream && this.stdinStream.isRaw || this._activeSubCommand && (this._activeSubCommand.isRaw || this._activeSubCommand.stdinStream && this._activeSubCommand.stdinStream.isRaw));
5658
+ return this._activeSubCommand ? !!(this._activeSubCommand.isRaw || this._activeSubCommand.stdinStream && this._activeSubCommand.stdinStream.isRaw) : !!(this.stdinStream && this.stdinStream.isRaw);
5659
+ }
5660
+ get _inAltScreen() {
5661
+ return !!(this.__inAltScreen || this._activeSubCommand && this._activeSubCommand._inAltScreen);
5662
+ }
5663
+ set _inAltScreen(e) {
5664
+ this.__inAltScreen = !!e;
5665
+ }
5666
+ kill(e = "SIGINT") {
5667
+ this._activeSubCommand && typeof this._activeSubCommand.kill == "function" && this._activeSubCommand.kill(e), super.kill(e);
5586
5668
  }
5587
5669
  onInput(e) {
5588
5670
  this._activeSubCommand && typeof this._activeSubCommand.onInput == "function" && this._activeSubCommand.onInput(e);