brsh 2.8.1 → 3.1.0

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.
Files changed (44) hide show
  1. package/.github/workflows/release.yml +3 -1
  2. package/CHANGELOG.md +32 -0
  3. package/POSIX-CHECKLIST.md +3 -3
  4. package/Readme.md +138 -223
  5. package/bin/Readme.md +70 -24
  6. package/bin/brsh-shell.js +16 -131
  7. package/bin/exportFileSystem.js +4 -0
  8. package/bin/zsh-server.js +261 -0
  9. package/dist/brsh.css +1 -1
  10. package/dist/shell.es.js +1020 -648
  11. package/dist/shell.es.js.map +1 -1
  12. package/dist/shell.min.js +34 -19
  13. package/dist/shell.min.js.map +1 -1
  14. package/dist/terminal.cjs.js +77 -100
  15. package/dist/terminal.cjs.js.map +1 -1
  16. package/dist/terminal.es.js +1382 -603
  17. package/dist/terminal.es.js.map +1 -1
  18. package/dist/terminal.min.js +77 -100
  19. package/dist/terminal.min.js.map +1 -1
  20. package/dist/wbt.es.js +410 -238
  21. package/dist/wbt.es.js.map +1 -1
  22. package/dist/wbt.min.js +10 -8
  23. package/dist/wbt.min.js.map +1 -1
  24. package/index.js +472 -0
  25. package/lib/Command.js +30 -0
  26. package/lib/InteractiveCommand.js +28 -0
  27. package/lib/Readme.md +111 -12
  28. package/lib/ReplCommand.js +15 -0
  29. package/lib/Terminal.js +769 -510
  30. package/lib/TtyStream.js +181 -0
  31. package/lib/WasmCommand.js +26 -5
  32. package/lib/builtins/cat.js +2 -2
  33. package/lib/builtins/grep.js +2 -2
  34. package/lib/local/clear.js +3 -0
  35. package/lib/terminal/DomRenderer.js +325 -0
  36. package/lib/terminal/PtyBridge.js +169 -0
  37. package/lib/terminal/ScreenBuffer.js +594 -0
  38. package/lib/terminal/VtParser.js +728 -0
  39. package/lib/wbt/index.js +3 -2
  40. package/lib/wbt/registry.js +15 -1
  41. package/package.json +4 -2
  42. package/styles/terminal.css +33 -4
  43. package/test/terminal.test.js +762 -40
  44. package/test/wbt.test.js +92 -0
package/dist/wbt.es.js CHANGED
@@ -572,14 +572,14 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
572
572
  return e = +e, t >>>= 0, n || U(this, e, t, 4, 4294967295, 0), this[t] = e >>> 24, this[t + 1] = e >>> 16, this[t + 2] = e >>> 8, this[t + 3] = e & 255, t + 4;
573
573
  };
574
574
  function W(e, t, n, r, i) {
575
- Y(t, r, i, e, n, 7);
575
+ re(t, r, i, e, n, 7);
576
576
  let a = Number(t & BigInt(4294967295));
577
577
  e[n++] = a, a >>= 8, e[n++] = a, a >>= 8, e[n++] = a, a >>= 8, e[n++] = a;
578
578
  let o = Number(t >> BigInt(32) & BigInt(4294967295));
579
579
  return e[n++] = o, o >>= 8, e[n++] = o, o >>= 8, e[n++] = o, o >>= 8, e[n++] = o, n;
580
580
  }
581
581
  function G(e, t, n, r, i) {
582
- Y(t, r, i, e, n, 7);
582
+ re(t, r, i, e, n, 7);
583
583
  let a = Number(t & BigInt(4294967295));
584
584
  e[n + 7] = a, a >>= 8, e[n + 6] = a, a >>= 8, e[n + 5] = a, a >>= 8, e[n + 4] = a;
585
585
  let o = Number(t >> BigInt(32) & BigInt(4294967295));
@@ -620,19 +620,19 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
620
620
  }), u.prototype.writeBigInt64BE = $(function(e, t = 0) {
621
621
  return G(this, e, t, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
622
622
  });
623
- function K(e, t, n, r, i, a) {
623
+ function ee(e, t, n, r, i, a) {
624
624
  if (n + r > e.length || n < 0) throw RangeError("Index out of range");
625
625
  }
626
- function ee(e, t, r, i, a) {
627
- return t = +t, r >>>= 0, a || K(e, t, r, 4), n.write(e, t, r, i, 23, 4), r + 4;
626
+ function K(e, t, r, i, a) {
627
+ return t = +t, r >>>= 0, a || ee(e, t, r, 4), n.write(e, t, r, i, 23, 4), r + 4;
628
628
  }
629
629
  u.prototype.writeFloatLE = function(e, t, n) {
630
- return ee(this, e, t, !0, n);
630
+ return K(this, e, t, !0, n);
631
631
  }, u.prototype.writeFloatBE = function(e, t, n) {
632
- return ee(this, e, t, !1, n);
632
+ return K(this, e, t, !1, n);
633
633
  };
634
634
  function te(e, t, r, i, a) {
635
- return t = +t, r >>>= 0, a || K(e, t, r, 8), n.write(e, t, r, i, 52, 8), r + 8;
635
+ return t = +t, r >>>= 0, a || ee(e, t, r, 8), n.write(e, t, r, i, 52, 8), r + 8;
636
636
  }
637
637
  u.prototype.writeDoubleLE = function(e, t, n) {
638
638
  return te(this, e, t, !0, n);
@@ -669,7 +669,7 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
669
669
  return this;
670
670
  };
671
671
  let q = {};
672
- function ne(e, t, n) {
672
+ function J(e, t, n) {
673
673
  q[e] = class extends n {
674
674
  constructor() {
675
675
  super(), Object.defineProperty(this, "message", {
@@ -694,28 +694,28 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
694
694
  }
695
695
  };
696
696
  }
697
- ne("ERR_BUFFER_OUT_OF_BOUNDS", function(e) {
697
+ J("ERR_BUFFER_OUT_OF_BOUNDS", function(e) {
698
698
  return e ? `${e} is outside of buffer bounds` : "Attempt to access memory outside buffer bounds";
699
- }, RangeError), ne("ERR_INVALID_ARG_TYPE", function(e, t) {
699
+ }, RangeError), J("ERR_INVALID_ARG_TYPE", function(e, t) {
700
700
  return `The "${e}" argument must be of type number. Received type ${typeof t}`;
701
- }, TypeError), ne("ERR_OUT_OF_RANGE", function(e, t, n) {
701
+ }, TypeError), J("ERR_OUT_OF_RANGE", function(e, t, n) {
702
702
  let r = `The value of "${e}" is out of range.`, i = n;
703
- return Number.isInteger(n) && Math.abs(n) > 2 ** 32 ? i = J(String(n)) : typeof n == "bigint" && (i = String(n), (n > BigInt(2) ** BigInt(32) || n < -(BigInt(2) ** BigInt(32))) && (i = J(i)), i += "n"), r += ` It must be ${t}. Received ${i}`, r;
703
+ return Number.isInteger(n) && Math.abs(n) > 2 ** 32 ? i = ne(String(n)) : typeof n == "bigint" && (i = String(n), (n > BigInt(2) ** BigInt(32) || n < -(BigInt(2) ** BigInt(32))) && (i = ne(i)), i += "n"), r += ` It must be ${t}. Received ${i}`, r;
704
704
  }, RangeError);
705
- function J(e) {
705
+ function ne(e) {
706
706
  let t = "", n = e.length, r = +(e[0] === "-");
707
707
  for (; n >= r + 4; n -= 3) t = `_${e.slice(n - 3, n)}${t}`;
708
708
  return `${e.slice(0, n)}${t}`;
709
709
  }
710
- function re(e, t, n) {
710
+ function Y(e, t, n) {
711
711
  X(t, "offset"), (e[t] === void 0 || e[t + n] === void 0) && Z(t, e.length - (n + 1));
712
712
  }
713
- function Y(e, t, n, r, i, a) {
713
+ function re(e, t, n, r, i, a) {
714
714
  if (e > n || e < t) {
715
715
  let r = typeof t == "bigint" ? "n" : "", i;
716
716
  throw i = a > 3 ? t === 0 || t === BigInt(0) ? `>= 0${r} and < 2${r} ** ${(a + 1) * 8}${r}` : `>= -(2${r} ** ${(a + 1) * 8 - 1}${r}) and < 2 ** ${(a + 1) * 8 - 1}${r}` : `>= ${t}${r} and <= ${n}${r}`, new q.ERR_OUT_OF_RANGE("value", i, e);
717
717
  }
718
- re(r, i, a);
718
+ Y(r, i, a);
719
719
  }
720
720
  function X(e, t) {
721
721
  if (typeof e != "number") throw new q.ERR_INVALID_ARG_TYPE(t, "number", e);
@@ -1015,10 +1015,139 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
1015
1015
  }
1016
1016
  };
1017
1017
  })), w = /* @__PURE__ */ t(((e, t) => {
1018
- var n = x(), r = C(), i = n.EventEmitter || n.default || n;
1019
- t.exports = class extends i {
1018
+ b();
1019
+ var n = x(), r = n.EventEmitter || n.default || n;
1020
+ function i(e) {
1021
+ if (!e) return [];
1022
+ let t = typeof e == "string" ? e : e instanceof Uint8Array || y !== void 0 && y.isBuffer(e) ? new TextDecoder().decode(e) : String(e), n = [], r = 0;
1023
+ for (; r < t.length;) {
1024
+ let e = t[r], i = t.charCodeAt(r);
1025
+ if (i === 27) {
1026
+ if (t.charCodeAt(r + 1) === 127 || t.charCodeAt(r + 1) === 8) {
1027
+ n.push("^W"), r += 2;
1028
+ continue;
1029
+ }
1030
+ if (t[r + 1] === "[" || t[r + 1] === "O") {
1031
+ let e = r + 2;
1032
+ for (; e < t.length && t.charCodeAt(e) >= 32 && t.charCodeAt(e) <= 63;) e++;
1033
+ if (e < t.length) {
1034
+ let i = t.slice(r + 2, e + 1), a = {
1035
+ A: "ArrowUp",
1036
+ B: "ArrowDown",
1037
+ C: "ArrowRight",
1038
+ D: "ArrowLeft",
1039
+ H: "Home",
1040
+ F: "End",
1041
+ "1~": "Home",
1042
+ "3~": "Delete",
1043
+ "4~": "End",
1044
+ "5~": "PageUp",
1045
+ "6~": "PageDown",
1046
+ "7~": "Home",
1047
+ "8~": "End"
1048
+ };
1049
+ a[i] && n.push(a[i]), r = e + 1;
1050
+ continue;
1051
+ }
1052
+ }
1053
+ n.push("Escape"), r++;
1054
+ continue;
1055
+ }
1056
+ if (i === 13 || i === 10) {
1057
+ n.push("Enter"), i === 13 && t[r + 1] === "\n" && r++, r++;
1058
+ continue;
1059
+ }
1060
+ if (i === 127 || i === 8) {
1061
+ n.push("Backspace"), r++;
1062
+ continue;
1063
+ }
1064
+ if (i === 9) {
1065
+ n.push("Tab"), r++;
1066
+ continue;
1067
+ }
1068
+ if (i >= 1 && i <= 26) {
1069
+ n.push("^" + String.fromCharCode(i + 64)), r++;
1070
+ continue;
1071
+ }
1072
+ n.push(e), r++;
1073
+ }
1074
+ return n;
1075
+ }
1076
+ t.exports = {
1077
+ TtyStream: class extends r {
1078
+ constructor(e = {}) {
1079
+ super(), this.isTTY = e.isTTY !== !1, this.readable = !0, this.writable = !0, this.columns = e.columns || 80, this.rows = e.rows || 24, this.isRaw = !1, this._encoding = null, this._onWrite = e.onWrite || null;
1080
+ }
1081
+ write(e, t, n) {
1082
+ return e == null ? !0 : (typeof this._onWrite == "function" && this._onWrite(e), this.emit("data", this._formatChunk(e)), typeof t == "function" ? t() : typeof n == "function" && n(), !0);
1083
+ }
1084
+ pushData(e) {
1085
+ e != null && this.emit("data", this._formatChunk(e));
1086
+ }
1087
+ _formatChunk(e) {
1088
+ return this._encoding ? typeof e == "string" ? e : e instanceof Uint8Array || y !== void 0 && y.isBuffer(e) ? new TextDecoder().decode(e) : String(e) : e;
1089
+ }
1090
+ setRawMode(e) {
1091
+ return this.isRaw = !!e, this;
1092
+ }
1093
+ setEncoding(e) {
1094
+ return this._encoding = e, this;
1095
+ }
1096
+ getWindowSize() {
1097
+ return [this.columns, this.rows];
1098
+ }
1099
+ resize(e, t) {
1100
+ this.columns = e, this.rows = t, this.emit("resize");
1101
+ }
1102
+ resume() {
1103
+ return this;
1104
+ }
1105
+ pause() {
1106
+ return this;
1107
+ }
1108
+ pipe(e) {
1109
+ return this.on("data", (t) => e.write(t)), e;
1110
+ }
1111
+ unpipe() {
1112
+ return this;
1113
+ }
1114
+ end(e, t, n) {
1115
+ return e != null && this.write(e, typeof t == "string" ? t : void 0), this.emit("end"), typeof t == "function" ? t() : typeof n == "function" && n(), this;
1116
+ }
1117
+ destroy() {
1118
+ this.removeAllListeners();
1119
+ }
1120
+ toString() {
1121
+ return "";
1122
+ }
1123
+ valueOf() {
1124
+ return "";
1125
+ }
1126
+ },
1127
+ parseVtKeys: i
1128
+ };
1129
+ })), T = /* @__PURE__ */ t(((e, t) => {
1130
+ var n = x(), r = C(), { TtyStream: i, parseVtKeys: a } = w(), o = n.EventEmitter || n.default || n;
1131
+ t.exports = class extends o {
1020
1132
  constructor(e, t) {
1021
1133
  super(), this.arguments = e, this.result = new r(), this.context = t || null;
1134
+ let n = this.context && typeof this.context.getVar == "function" && parseInt(this.context.getVar("COLUMNS"), 10) || 80, o = this.context && typeof this.context.getVar == "function" && parseInt(this.context.getVar("LINES"), 10) || 24;
1135
+ this.stdinStream = new i({
1136
+ columns: n,
1137
+ rows: o
1138
+ }), this.stdin = this.stdinStream, this.stdout = new i({
1139
+ columns: n,
1140
+ rows: o,
1141
+ onWrite: (e) => this.emit("stdout", e)
1142
+ }), this.stderr = new i({
1143
+ columns: n,
1144
+ rows: o,
1145
+ onWrite: (e) => this.emit("stderr", e)
1146
+ }), this.stdinStream.on("data", (e) => {
1147
+ if (!this.captureInput) return;
1148
+ let t = a(e);
1149
+ for (let e of t) !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);
1150
+ });
1022
1151
  }
1023
1152
  get name() {
1024
1153
  return "unnamed";
@@ -1046,15 +1175,15 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
1046
1175
  this.emit("flush", this.result.flush());
1047
1176
  }
1048
1177
  };
1049
- })), T = /* @__PURE__ */ t(((e, t) => {
1050
- var n = w();
1178
+ })), E = /* @__PURE__ */ t(((e, t) => {
1179
+ var n = T();
1051
1180
  t.exports = class extends n {
1052
1181
  constructor(e, t) {
1053
1182
  super(e, t);
1054
1183
  }
1055
1184
  };
1056
- })), E = /* @__PURE__ */ t(((e, t) => {
1057
- var n = T();
1185
+ })), D = /* @__PURE__ */ t(((e, t) => {
1186
+ var n = E();
1058
1187
  function r(e) {
1059
1188
  return /^#!\/(sh\.js|bin\/(sh|brsh))/.test(e);
1060
1189
  }
@@ -1219,7 +1348,7 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
1219
1348
  }
1220
1349
  _executeNode(e) {
1221
1350
  if (e.type === "function") {
1222
- let t = e.name, n = e.bodyLines, r = this, i = T(), a = class extends i {
1351
+ let t = e.name, n = e.bodyLines, r = this, i = E(), a = class extends i {
1223
1352
  static get name() {
1224
1353
  return t;
1225
1354
  }
@@ -1419,7 +1548,7 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
1419
1548
  }
1420
1549
  }
1421
1550
  }, t.exports.isKnownInterpreter = r;
1422
- })), D = /* @__PURE__ */ t(((e, t) => {
1551
+ })), O = /* @__PURE__ */ t(((e, t) => {
1423
1552
  b();
1424
1553
  var n = new Set([
1425
1554
  "getFileByPath",
@@ -1497,90 +1626,90 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
1497
1626
  }));
1498
1627
  //#endregion
1499
1628
  //#region node_modules/vite-plugin-node-polyfills/shims/process/dist/index.js
1500
- function O(e) {
1629
+ function k(e) {
1501
1630
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
1502
1631
  }
1503
- function k() {
1632
+ function A() {
1504
1633
  throw Error("setTimeout has not been defined");
1505
1634
  }
1506
- function A() {
1635
+ function j() {
1507
1636
  throw Error("clearTimeout has not been defined");
1508
1637
  }
1509
- function j(e) {
1510
- if (z === setTimeout) return setTimeout(e, 0);
1511
- if ((z === k || !z) && setTimeout) return z = setTimeout, setTimeout(e, 0);
1638
+ function M(e) {
1639
+ if (B === setTimeout) return setTimeout(e, 0);
1640
+ if ((B === A || !B) && setTimeout) return B = setTimeout, setTimeout(e, 0);
1512
1641
  try {
1513
- return z(e, 0);
1642
+ return B(e, 0);
1514
1643
  } catch {
1515
1644
  try {
1516
- return z.call(null, e, 0);
1645
+ return B.call(null, e, 0);
1517
1646
  } catch {
1518
- return z.call(this, e, 0);
1647
+ return B.call(this, e, 0);
1519
1648
  }
1520
1649
  }
1521
1650
  }
1522
- function M(e) {
1523
- if (B === clearTimeout) return clearTimeout(e);
1524
- if ((B === A || !B) && clearTimeout) return B = clearTimeout, clearTimeout(e);
1651
+ function N(e) {
1652
+ if (V === clearTimeout) return clearTimeout(e);
1653
+ if ((V === j || !V) && clearTimeout) return V = clearTimeout, clearTimeout(e);
1525
1654
  try {
1526
- return B(e);
1655
+ return V(e);
1527
1656
  } catch {
1528
1657
  try {
1529
- return B.call(null, e);
1658
+ return V.call(null, e);
1530
1659
  } catch {
1531
- return B.call(this, e);
1660
+ return V.call(this, e);
1532
1661
  }
1533
1662
  }
1534
1663
  }
1535
- function N() {
1536
- !H || !U || (H = !1, U.length ? V = U.concat(V) : W = -1, V.length && P());
1537
- }
1538
1664
  function P() {
1539
- if (!H) {
1540
- var e = j(N);
1541
- H = !0;
1542
- for (var t = V.length; t;) {
1543
- for (U = V, V = []; ++W < t;) U && U[W].run();
1544
- W = -1, t = V.length;
1545
- }
1546
- U = null, H = !1, M(e);
1665
+ !U || !W || (U = !1, W.length ? H = W.concat(H) : G = -1, H.length && F());
1666
+ }
1667
+ function F() {
1668
+ if (!U) {
1669
+ var e = M(P);
1670
+ U = !0;
1671
+ for (var t = H.length; t;) {
1672
+ for (W = H, H = []; ++G < t;) W && W[G].run();
1673
+ G = -1, t = H.length;
1674
+ }
1675
+ W = null, U = !1, N(e);
1547
1676
  }
1548
1677
  }
1549
- function F(e, t) {
1678
+ function I(e, t) {
1550
1679
  this.fun = e, this.array = t;
1551
1680
  }
1552
- function I() {}
1553
- var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
1554
- L = { exports: {} }, R = L.exports = {}, (function() {
1681
+ function L() {}
1682
+ var R, z, B, V, H, U, W, G, ee, K, te = e((() => {
1683
+ R = { exports: {} }, z = R.exports = {}, (function() {
1555
1684
  try {
1556
- z = typeof setTimeout == "function" ? setTimeout : k;
1685
+ B = typeof setTimeout == "function" ? setTimeout : A;
1557
1686
  } catch {
1558
- z = k;
1687
+ B = A;
1559
1688
  }
1560
1689
  try {
1561
- B = typeof clearTimeout == "function" ? clearTimeout : A;
1690
+ V = typeof clearTimeout == "function" ? clearTimeout : j;
1562
1691
  } catch {
1563
- B = A;
1692
+ V = j;
1564
1693
  }
1565
- })(), V = [], H = !1, W = -1, R.nextTick = function(e) {
1694
+ })(), H = [], U = !1, G = -1, z.nextTick = function(e) {
1566
1695
  var t = Array(arguments.length - 1);
1567
1696
  if (arguments.length > 1) for (var n = 1; n < arguments.length; n++) t[n - 1] = arguments[n];
1568
- V.push(new F(e, t)), V.length === 1 && !H && j(P);
1569
- }, F.prototype.run = function() {
1697
+ H.push(new I(e, t)), H.length === 1 && !U && M(F);
1698
+ }, I.prototype.run = function() {
1570
1699
  this.fun.apply(null, this.array);
1571
- }, R.title = "browser", R.browser = !0, R.env = {}, R.argv = [], R.version = "", R.versions = {}, R.on = I, R.addListener = I, R.once = I, R.off = I, R.removeListener = I, R.removeAllListeners = I, R.emit = I, R.prependListener = I, R.prependOnceListener = I, R.listeners = function(e) {
1700
+ }, z.title = "browser", z.browser = !0, z.env = {}, z.argv = [], z.version = "", z.versions = {}, z.on = L, z.addListener = L, z.once = L, z.off = L, z.removeListener = L, z.removeAllListeners = L, z.emit = L, z.prependListener = L, z.prependOnceListener = L, z.listeners = function(e) {
1572
1701
  return [];
1573
- }, R.binding = function(e) {
1702
+ }, z.binding = function(e) {
1574
1703
  throw Error("process.binding is not supported");
1575
- }, R.cwd = function() {
1704
+ }, z.cwd = function() {
1576
1705
  return "/";
1577
- }, R.chdir = function(e) {
1706
+ }, z.chdir = function(e) {
1578
1707
  throw Error("process.chdir is not supported");
1579
- }, R.umask = function() {
1708
+ }, z.umask = function() {
1580
1709
  return 0;
1581
- }, G = L.exports, K = /* @__PURE__ */ O(G);
1582
- })), te = /* @__PURE__ */ t(((e, t) => {
1583
- var n = w();
1710
+ }, ee = R.exports, K = /* @__PURE__ */ k(ee);
1711
+ })), q = /* @__PURE__ */ t(((e, t) => {
1712
+ var n = T();
1584
1713
  t.exports = class extends n {
1585
1714
  get captureInput() {
1586
1715
  return !0;
@@ -1589,15 +1718,29 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
1589
1718
  return !0;
1590
1719
  }
1591
1720
  get terminalSize() {
1592
- return {
1721
+ return this.stdout && this.stdout.columns && this.stdout.rows ? {
1722
+ cols: parseInt(this.context && this.context.getVar && this.context.getVar("COLUMNS"), 10) || this.stdout.columns || 80,
1723
+ rows: parseInt(this.context && this.context.getVar && this.context.getVar("LINES"), 10) || this.stdout.rows || 24
1724
+ } : {
1593
1725
  cols: parseInt(this.context.getVar("COLUMNS"), 10) || 80,
1594
1726
  rows: parseInt(this.context.getVar("LINES"), 10) || 24
1595
1727
  };
1596
1728
  }
1729
+ _enterAltScreen() {
1730
+ this._inAltScreen || (this._inAltScreen = !0, this.stdinStream && this.stdinStream.setRawMode(!0), this.stdout && this.stdout.write("\x1B[?1049h\x1B[2J\x1B[H"));
1731
+ }
1732
+ _exitAltScreen() {
1733
+ this._inAltScreen && (this._inAltScreen = !1, this.stdinStream && this.stdinStream.setRawMode(!1), this.stdout && this.stdout.write("\x1B[?1049l\x1B[?25h"));
1734
+ }
1735
+ runCommand() {
1736
+ return this.interactive && this._enterAltScreen(), super.runCommand().finally(() => {
1737
+ this._exitAltScreen();
1738
+ });
1739
+ }
1597
1740
  };
1598
- })), q = /* @__PURE__ */ t(((e, t) => {
1599
- b(), ee();
1600
- var { BinaryFile: n, SymlinkRef: r } = D(), i = new Uint8Array([
1741
+ })), J = /* @__PURE__ */ t(((e, t) => {
1742
+ b(), te();
1743
+ var { BinaryFile: n, SymlinkRef: r } = O(), i = new Uint8Array([
1601
1744
  66,
1602
1745
  82,
1603
1746
  70,
@@ -1701,7 +1844,7 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
1701
1844
  let t = e.$c;
1702
1845
  if (m[t]) return m[t];
1703
1846
  if (f.inlineCommands && f.inlineCommands[t]) try {
1704
- let e = w(), n = te();
1847
+ let e = T(), n = q();
1705
1848
  return Function("Command", "InteractiveCommand", `return (${f.inlineCommands[t]});`)(e, n);
1706
1849
  } catch {
1707
1850
  return null;
@@ -1868,7 +2011,7 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
1868
2011
  };
1869
2012
  })), ne = /* @__PURE__ */ t(((e, t) => {
1870
2013
  b();
1871
- var n = D(), { BinaryFile: r, SymlinkRef: i } = n;
2014
+ var n = O(), { BinaryFile: r, SymlinkRef: i } = n;
1872
2015
  function a(e) {
1873
2016
  for (let t of Object.keys(e)) {
1874
2017
  let n = e[t];
@@ -1891,20 +2034,20 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
1891
2034
  t.exports = class extends n {
1892
2035
  constructor(e = "/", t = {}, n = {}, r = null) {
1893
2036
  if (super(), t instanceof Uint8Array || t instanceof ArrayBuffer) {
1894
- let { deserializeBinaryFilesystem: e } = q(), r = e(t);
2037
+ let { deserializeBinaryFilesystem: e } = J(), r = e(t);
1895
2038
  t = r.filesystem, n = Object.assign({}, r.permissions, n);
1896
2039
  } else if (t && typeof t == "object" && t.filesystem && (t.filesystem instanceof Uint8Array || typeof t.filesystem == "object") && (n = Object.assign({}, t.permissions || {}, n), t = t.filesystem, t instanceof Uint8Array || t instanceof ArrayBuffer)) {
1897
- let { deserializeBinaryFilesystem: e } = q(), r = e(t);
2040
+ let { deserializeBinaryFilesystem: e } = J(), r = e(t);
1898
2041
  t = r.filesystem, n = Object.assign({}, r.permissions, n);
1899
2042
  }
1900
2043
  a(t), this.fileSystem = t, this.permissions = Object.assign({}, n), this.cwd = e, this._onChange = r, this._changeScheduled = !1;
1901
2044
  }
1902
2045
  toBinaryContainer(e = {}) {
1903
- let { serializeBinaryFilesystem: t } = q();
2046
+ let { serializeBinaryFilesystem: t } = J();
1904
2047
  return t(this.fileSystem, this.permissions, e);
1905
2048
  }
1906
2049
  static fromBinaryContainer(e, t = {}) {
1907
- let { deserializeBinaryFilesystem: n } = q();
2050
+ let { deserializeBinaryFilesystem: n } = J();
1908
2051
  return n(e, t);
1909
2052
  }
1910
2053
  getFileByPath(e) {
@@ -2082,10 +2225,10 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
2082
2225
  return null;
2083
2226
  }
2084
2227
  }, t.exports.BinaryFile = r, t.exports.SymlinkRef = i;
2085
- })), J = /* @__PURE__ */ t(((e, t) => {
2228
+ })), Y = /* @__PURE__ */ t(((e, t) => {
2086
2229
  t.exports = null;
2087
2230
  })), re = /* @__PURE__ */ t(((e, t) => {
2088
- ee();
2231
+ te();
2089
2232
  function n(e) {
2090
2233
  if (typeof e != "string") throw TypeError("Path must be a string. Received " + JSON.stringify(e));
2091
2234
  }
@@ -2252,9 +2395,9 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
2252
2395
  posix: null
2253
2396
  };
2254
2397
  a.posix = a, t.exports = a;
2255
- })), Y = /* @__PURE__ */ t(((e, t) => {
2398
+ })), X = /* @__PURE__ */ t(((e, t) => {
2256
2399
  b();
2257
- var n = E(), { BinaryFile: r } = ne(), i = 0, a = 8, o = 20, s = 28, c = 31, l = 44, u = 54, d = 70, f = 0, p = 2, m = 3, h = 4, g = 1, _ = 2, v = 4, x = 8, S = 1, C = class extends n {
2400
+ var n = D(), { BinaryFile: r } = ne(), i = 0, a = 8, o = 20, s = 28, c = 31, l = 44, u = 54, d = 70, f = 0, p = 2, m = 3, h = 4, g = 1, _ = 2, v = 4, x = 8, S = 1, C = class extends n {
2258
2401
  get name() {
2259
2402
  return "wasm";
2260
2403
  }
@@ -2264,7 +2407,7 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
2264
2407
  run() {
2265
2408
  let e = this.script, t = (() => {
2266
2409
  try {
2267
- return J();
2410
+ return Y();
2268
2411
  } catch {
2269
2412
  return null;
2270
2413
  }
@@ -2330,29 +2473,29 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
2330
2473
  let t = {
2331
2474
  1: "",
2332
2475
  2: ""
2333
- }, n = new TextDecoder(), y = new TextEncoder(), b = null, C = (e, n) => {
2476
+ }, n = new TextDecoder(), b = new TextEncoder(), C = null, w = (e, n) => {
2334
2477
  t[e] = (t[e] || "") + n;
2335
2478
  let r = t[e].split("\n");
2336
2479
  t[e] = r.pop();
2337
2480
  for (let t of r) e === 1 ? this.stdOut = t : this.stdErr = t;
2338
- }, w = () => {
2481
+ }, T = () => {
2339
2482
  t[1] &&= (this.stdOut = t[1], ""), t[2] &&= (this.stdErr = t[2], "");
2340
- }, T = y.encode(this.stdin || ""), E = 0, D = this.context && this.context.fs ? this.context.fs : this.fs, O = 5, k = new Map([[3, {
2483
+ }, E = typeof this.stdin == "string" ? b.encode(this.stdin) : this.stdin instanceof Uint8Array ? this.stdin : y !== void 0 && y.isBuffer(this.stdin) ? new Uint8Array(this.stdin) : new Uint8Array(), D = 0, O = this.context && this.context.fs ? this.context.fs : this.fs, k = 5, A = new Map([[3, {
2341
2484
  type: "preopen",
2342
2485
  path: "/",
2343
2486
  guestName: "/"
2344
2487
  }], [4, {
2345
2488
  type: "preopen",
2346
- path: D && D.cwd || "/",
2489
+ path: O && O.cwd || "/",
2347
2490
  guestName: "."
2348
- }]]), A = (e, t) => {
2349
- let n = k.get(e);
2491
+ }]]), N = (e, t) => {
2492
+ let n = A.get(e);
2350
2493
  if (!n || n.type !== "preopen" && n.type !== "dir") return null;
2351
- if (t.startsWith("/")) return D.absolutePath(t);
2494
+ if (t.startsWith("/")) return O.absolutePath(t);
2352
2495
  let r = n.path.endsWith("/") ? n.path : n.path + "/";
2353
- return D.absolutePath(r + t);
2354
- }, N = (e) => {
2355
- if (!(!e || e.type !== "file" || !e.dirty || !D)) try {
2496
+ return O.absolutePath(r + t);
2497
+ }, P = (e) => {
2498
+ if (!(!e || e.type !== "file" || !e.dirty || !O)) try {
2356
2499
  let t = !0;
2357
2500
  for (let n = 0; n < e.bytes.length; n++) if (e.bytes[n] === 0) {
2358
2501
  t = !1;
@@ -2360,32 +2503,32 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
2360
2503
  }
2361
2504
  if (t) {
2362
2505
  let t = n.decode(e.bytes);
2363
- D.setFileByPath(e.path, t, !0);
2506
+ O.setFileByPath(e.path, t, !0);
2364
2507
  } else {
2365
2508
  let t = new Uint8Array(e.bytes.length);
2366
- t.set(e.bytes), D.setFileByPath(e.path, new r(t.buffer, "application/octet-stream"), !0);
2509
+ t.set(e.bytes), O.setFileByPath(e.path, new r(t.buffer, "application/octet-stream"), !0);
2367
2510
  }
2368
2511
  e.dirty = !1;
2369
2512
  } catch {}
2370
- }, P = Object.entries(this.context && this.context.vars || {}).map(([e, t]) => `${e}=${t}`), F = new Proxy({
2513
+ }, F = Object.entries(this.context && this.context.vars || {}).map(([e, t]) => `${e}=${t}`), I = new Proxy({
2371
2514
  fd_write: (e, t, r, o) => {
2372
- if (!b) return a;
2373
- let s = new DataView(b.buffer);
2515
+ if (!C) return a;
2516
+ let s = new DataView(C.buffer);
2374
2517
  if (e === 1 || e === 2) {
2375
2518
  let a = 0;
2376
2519
  for (let i = 0; i < r; i++) {
2377
2520
  let r = s.getUint32(t + i * 8, !0), o = s.getUint32(t + i * 8 + 4, !0);
2378
- o > 0 && C(e, n.decode(new Uint8Array(b.buffer, r, o))), a += o;
2521
+ o > 0 && w(e, n.decode(new Uint8Array(C.buffer, r, o))), a += o;
2379
2522
  }
2380
2523
  return s.setUint32(o, a, !0), i;
2381
2524
  }
2382
- let c = k.get(e);
2525
+ let c = A.get(e);
2383
2526
  if (!c || c.type !== "file") return a;
2384
2527
  let l = 0;
2385
2528
  for (let e = 0; e < r; e++) {
2386
2529
  let n = s.getUint32(t + e * 8, !0), r = s.getUint32(t + e * 8 + 4, !0);
2387
2530
  if (r > 0) {
2388
- let e = new Uint8Array(b.buffer, n, r), t = c.append ? c.bytes.length : c.pos, i = t + r;
2531
+ let e = new Uint8Array(C.buffer, n, r), t = c.append ? c.bytes.length : c.pos, i = t + r;
2389
2532
  if (i > c.bytes.length) {
2390
2533
  let e = new Uint8Array(i);
2391
2534
  e.set(c.bytes), c.bytes = e;
@@ -2396,29 +2539,29 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
2396
2539
  return s.setUint32(o, l, !0), i;
2397
2540
  },
2398
2541
  fd_read: (e, t, n, r) => {
2399
- if (!b) return a;
2400
- let o = new DataView(b.buffer);
2542
+ if (!C) return a;
2543
+ let o = new DataView(C.buffer);
2401
2544
  if (e === 0) {
2402
2545
  let e = 0;
2403
- for (let r = 0; r < n && E < T.length; r++) {
2404
- let n = o.getUint32(t + r * 8, !0), i = o.getUint32(t + r * 8 + 4, !0), a = Math.min(i, T.length - E);
2405
- new Uint8Array(b.buffer).set(T.slice(E, E + a), n), E += a, e += a;
2546
+ for (let r = 0; r < n && D < E.length; r++) {
2547
+ let n = o.getUint32(t + r * 8, !0), i = o.getUint32(t + r * 8 + 4, !0), a = Math.min(i, E.length - D);
2548
+ new Uint8Array(C.buffer).set(E.slice(D, D + a), n), D += a, e += a;
2406
2549
  }
2407
2550
  return o.setUint32(r, e, !0), i;
2408
2551
  }
2409
- let s = k.get(e);
2552
+ let s = A.get(e);
2410
2553
  if (!s || s.type !== "file") return a;
2411
2554
  let c = 0;
2412
2555
  for (let e = 0; e < n && s.pos < s.bytes.length; e++) {
2413
2556
  let n = o.getUint32(t + e * 8, !0), r = o.getUint32(t + e * 8 + 4, !0), i = Math.min(r, s.bytes.length - s.pos);
2414
- new Uint8Array(b.buffer).set(s.bytes.subarray(s.pos, s.pos + i), n), s.pos += i, c += i;
2557
+ new Uint8Array(C.buffer).set(s.bytes.subarray(s.pos, s.pos + i), n), s.pos += i, c += i;
2415
2558
  }
2416
2559
  return o.setUint32(r, c, !0), i;
2417
2560
  },
2418
2561
  fd_seek: (e, t, n, r, o) => {
2419
- if (!b) return a;
2562
+ if (!C) return a;
2420
2563
  if (e <= 2) return d;
2421
- let c = k.get(e);
2564
+ let c = A.get(e);
2422
2565
  if (!c || c.type !== "file") return a;
2423
2566
  let l, u, f;
2424
2567
  typeof t == "bigint" ? (l = Number(t), u = n, f = r) : (l = t, u = r, f = o);
@@ -2427,46 +2570,46 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
2427
2570
  else if (u === 1) p = c.pos + l;
2428
2571
  else if (u === 2) p = c.bytes.length + l;
2429
2572
  else return s;
2430
- return p < 0 ? s : (c.pos = p, f && new DataView(b.buffer).setBigUint64(f, BigInt(c.pos), !0), i);
2573
+ return p < 0 ? s : (c.pos = p, f && new DataView(C.buffer).setBigUint64(f, BigInt(c.pos), !0), i);
2431
2574
  },
2432
2575
  fd_tell: (e, t) => {
2433
- if (!b) return a;
2434
- let n = k.get(e);
2435
- return !n || n.type !== "file" ? a : (new DataView(b.buffer).setBigUint64(t, BigInt(n.pos), !0), i);
2576
+ if (!C) return a;
2577
+ let n = A.get(e);
2578
+ return !n || n.type !== "file" ? a : (new DataView(C.buffer).setBigUint64(t, BigInt(n.pos), !0), i);
2436
2579
  },
2437
2580
  fd_close: (e) => {
2438
2581
  if (e <= 2) return i;
2439
- let t = k.get(e);
2440
- return t ? (N(t), k.delete(e), i) : a;
2582
+ let t = A.get(e);
2583
+ return t ? (P(t), A.delete(e), i) : a;
2441
2584
  },
2442
2585
  fd_sync: (e) => {
2443
- let t = k.get(e);
2444
- return t && N(t), i;
2586
+ let t = A.get(e);
2587
+ return t && P(t), i;
2445
2588
  },
2446
2589
  fd_datasync: (e) => {
2447
- let t = k.get(e);
2448
- return t && N(t), i;
2590
+ let t = A.get(e);
2591
+ return t && P(t), i;
2449
2592
  },
2450
2593
  fd_prestat_get: (e, t) => {
2451
- if (!b) return a;
2452
- let n = k.get(e);
2594
+ if (!C) return a;
2595
+ let n = A.get(e);
2453
2596
  if (!n || n.type !== "preopen") return a;
2454
- let r = new DataView(b.buffer), o = y.encode(n.guestName);
2597
+ let r = new DataView(C.buffer), o = b.encode(n.guestName);
2455
2598
  return r.setUint8(t, 0), r.setUint32(t + 4, o.length, !0), i;
2456
2599
  },
2457
2600
  fd_prestat_dir_name: (e, t, n) => {
2458
- if (!b) return a;
2459
- let r = k.get(e);
2601
+ if (!C) return a;
2602
+ let r = A.get(e);
2460
2603
  if (!r || r.type !== "preopen") return a;
2461
- let o = y.encode(r.guestName);
2462
- return new Uint8Array(b.buffer, t, Math.min(n, o.length)).set(o.subarray(0, n)), i;
2604
+ let o = b.encode(r.guestName);
2605
+ return new Uint8Array(C.buffer, t, Math.min(n, o.length)).set(o.subarray(0, n)), i;
2463
2606
  },
2464
2607
  fd_fdstat_get: (e, t) => {
2465
- if (!b) return a;
2466
- let n = new DataView(b.buffer), r = f;
2608
+ if (!C) return a;
2609
+ let n = new DataView(C.buffer), r = f;
2467
2610
  if (e <= 2) r = p;
2468
2611
  else {
2469
- let t = k.get(e);
2612
+ let t = A.get(e);
2470
2613
  if (!t) return a;
2471
2614
  r = t.type === "preopen" || t.type === "dir" ? m : h;
2472
2615
  }
@@ -2475,83 +2618,83 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
2475
2618
  },
2476
2619
  fd_fdstat_set_flags: () => i,
2477
2620
  fd_filestat_get: (e, t) => {
2478
- if (!b) return a;
2479
- let n = new DataView(b.buffer);
2621
+ if (!C) return a;
2622
+ let n = new DataView(C.buffer);
2480
2623
  for (let e = 0; e < 64; e++) n.setUint8(t + e, 0);
2481
2624
  if (e <= 2) return n.setUint8(t + 16, p), i;
2482
- let r = k.get(e);
2625
+ let r = A.get(e);
2483
2626
  if (!r) return a;
2484
2627
  let o = r.type === "preopen" || r.type === "dir";
2485
2628
  return n.setUint8(t + 16, o ? m : h), n.setBigUint64(t + 24, 1n, !0), n.setBigUint64(t + 32, BigInt(r.bytes ? r.bytes.length : 0), !0), i;
2486
2629
  },
2487
2630
  path_open: (e, t, r, s, d, f, p, m, h) => {
2488
- if (!b || !D) return a;
2489
- let C = A(e, n.decode(new Uint8Array(b.buffer, r, s)));
2490
- if (!C) return a;
2491
- let w = D.stat(C), T = w !== null;
2631
+ if (!C || !O) return a;
2632
+ let y = N(e, n.decode(new Uint8Array(C.buffer, r, s)));
2633
+ if (!y) return a;
2634
+ let w = O.stat(y), T = w !== null;
2492
2635
  if (d & v && d & g && T) return o;
2493
2636
  if (d & _) {
2494
2637
  if (!T) return l;
2495
2638
  if (!w.isDirectory) return u;
2496
- let e = O++;
2497
- return k.set(e, {
2639
+ let e = k++;
2640
+ return A.set(e, {
2498
2641
  type: "dir",
2499
- path: C
2500
- }), new DataView(b.buffer).setUint32(h, e, !0), i;
2642
+ path: y
2643
+ }), new DataView(C.buffer).setUint32(h, e, !0), i;
2501
2644
  }
2502
2645
  if (T && w.isDirectory) return c;
2503
2646
  if (!T && !(d & g)) return l;
2504
- let E = new Uint8Array(), j = !1;
2647
+ let E = new Uint8Array(), D = !1;
2505
2648
  if (T && !(d & x)) {
2506
- let e = D.getFileByPath(C);
2507
- e != null && (E = typeof e == "string" ? y.encode(e) : new Uint8Array(this._contentToBytes(e)));
2508
- } else j = !0;
2509
- let M = O++;
2510
- return k.set(M, {
2649
+ let e = O.getFileByPath(y);
2650
+ e != null && (E = typeof e == "string" ? b.encode(e) : new Uint8Array(this._contentToBytes(e)));
2651
+ } else D = !0;
2652
+ let j = k++;
2653
+ return A.set(j, {
2511
2654
  type: "file",
2512
- path: C,
2655
+ path: y,
2513
2656
  bytes: E,
2514
2657
  pos: m & S ? E.length : 0,
2515
2658
  append: !!(m & S),
2516
- dirty: j
2517
- }), new DataView(b.buffer).setUint32(h, M, !0), i;
2659
+ dirty: D
2660
+ }), new DataView(C.buffer).setUint32(h, j, !0), i;
2518
2661
  },
2519
2662
  path_filestat_get: (e, t, r, o, s) => {
2520
- if (!b || !D) return a;
2521
- let c = A(e, n.decode(new Uint8Array(b.buffer, r, o)));
2663
+ if (!C || !O) return a;
2664
+ let c = N(e, n.decode(new Uint8Array(C.buffer, r, o)));
2522
2665
  if (!c) return a;
2523
- let u = D.stat(c);
2666
+ let u = O.stat(c);
2524
2667
  if (!u) return l;
2525
- let d = new DataView(b.buffer);
2668
+ let d = new DataView(C.buffer);
2526
2669
  for (let e = 0; e < 64; e++) d.setUint8(s + e, 0);
2527
- return d.setUint8(s + 16, u.isDirectory ? m : h), d.setBigUint64(s + 24, 1n, !0), d.setBigUint64(s + 32, BigInt(D.getSize(c) || 0), !0), i;
2670
+ return d.setUint8(s + 16, u.isDirectory ? m : h), d.setBigUint64(s + 24, 1n, !0), d.setBigUint64(s + 32, BigInt(O.getSize(c) || 0), !0), i;
2528
2671
  },
2529
2672
  path_create_directory: (e, t, r) => {
2530
- if (!b || !D) return a;
2531
- let o = A(e, n.decode(new Uint8Array(b.buffer, t, r)));
2673
+ if (!C || !O) return a;
2674
+ let o = N(e, n.decode(new Uint8Array(C.buffer, t, r)));
2532
2675
  if (!o) return a;
2533
2676
  try {
2534
- return D.setFileByPath(o, {}, !0), i;
2677
+ return O.setFileByPath(o, {}, !0), i;
2535
2678
  } catch {
2536
2679
  return s;
2537
2680
  }
2538
2681
  },
2539
2682
  path_unlink_file: (e, t, r) => {
2540
- if (!b || !D) return a;
2541
- let o = A(e, n.decode(new Uint8Array(b.buffer, t, r)));
2542
- if (!o || !D.exists(o)) return l;
2683
+ if (!C || !O) return a;
2684
+ let o = N(e, n.decode(new Uint8Array(C.buffer, t, r)));
2685
+ if (!o || !O.exists(o)) return l;
2543
2686
  try {
2544
- return D.deleteFileByPath(o), i;
2687
+ return O.deleteFileByPath(o), i;
2545
2688
  } catch {
2546
2689
  return s;
2547
2690
  }
2548
2691
  },
2549
2692
  path_remove_directory: (e, t, r) => {
2550
- if (!b || !D) return a;
2551
- let o = A(e, n.decode(new Uint8Array(b.buffer, t, r)));
2552
- if (!o || !D.exists(o)) return l;
2693
+ if (!C || !O) return a;
2694
+ let o = N(e, n.decode(new Uint8Array(C.buffer, t, r)));
2695
+ if (!o || !O.exists(o)) return l;
2553
2696
  try {
2554
- return D.deleteFileByPath(o), i;
2697
+ return O.deleteFileByPath(o), i;
2555
2698
  } catch {
2556
2699
  return s;
2557
2700
  }
@@ -2563,88 +2706,88 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
2563
2706
  };
2564
2707
  },
2565
2708
  args_sizes_get: (e, t) => {
2566
- if (!b) return s;
2567
- let n = [this.script, ...this.arguments || []], r = new DataView(b.buffer);
2568
- return r.setUint32(e, n.length, !0), r.setUint32(t, n.reduce((e, t) => e + y.encode(t).length + 1, 0), !0), i;
2709
+ if (!C) return s;
2710
+ let n = [this.script, ...this.arguments || []], r = new DataView(C.buffer);
2711
+ return r.setUint32(e, n.length, !0), r.setUint32(t, n.reduce((e, t) => e + b.encode(t).length + 1, 0), !0), i;
2569
2712
  },
2570
2713
  args_get: (e, t) => {
2571
- if (!b) return s;
2572
- let n = [this.script, ...this.arguments || []], r = new DataView(b.buffer), a = t;
2714
+ if (!C) return s;
2715
+ let n = [this.script, ...this.arguments || []], r = new DataView(C.buffer), a = t;
2573
2716
  for (let t = 0; t < n.length; t++) {
2574
2717
  r.setUint32(e + t * 4, a, !0);
2575
- let i = y.encode(n[t] + "\0");
2576
- new Uint8Array(b.buffer).set(i, a), a += i.length;
2718
+ let i = b.encode(n[t] + "\0");
2719
+ new Uint8Array(C.buffer).set(i, a), a += i.length;
2577
2720
  }
2578
2721
  return i;
2579
2722
  },
2580
2723
  environ_sizes_get: (e, t) => {
2581
- if (!b) return s;
2582
- let n = new DataView(b.buffer);
2583
- n.setUint32(e, P.length, !0);
2584
- let r = P.reduce((e, t) => e + y.encode(t).length + 1, 0);
2724
+ if (!C) return s;
2725
+ let n = new DataView(C.buffer);
2726
+ n.setUint32(e, F.length, !0);
2727
+ let r = F.reduce((e, t) => e + b.encode(t).length + 1, 0);
2585
2728
  return n.setUint32(t, r, !0), i;
2586
2729
  },
2587
2730
  environ_get: (e, t) => {
2588
- if (!b) return s;
2589
- let n = new DataView(b.buffer), r = t;
2590
- for (let t = 0; t < P.length; t++) {
2731
+ if (!C) return s;
2732
+ let n = new DataView(C.buffer), r = t;
2733
+ for (let t = 0; t < F.length; t++) {
2591
2734
  n.setUint32(e + t * 4, r, !0);
2592
- let i = y.encode(P[t] + "\0");
2593
- new Uint8Array(b.buffer).set(i, r), r += i.length;
2735
+ let i = b.encode(F[t] + "\0");
2736
+ new Uint8Array(C.buffer).set(i, r), r += i.length;
2594
2737
  }
2595
2738
  return i;
2596
2739
  },
2597
2740
  clock_time_get: (e, t, n) => {
2598
- if (b) {
2741
+ if (C) {
2599
2742
  let e = BigInt(Date.now()) * 1000000n;
2600
- new DataView(b.buffer).setBigUint64(n, e, !0);
2743
+ new DataView(C.buffer).setBigUint64(n, e, !0);
2601
2744
  }
2602
2745
  return i;
2603
2746
  },
2604
2747
  random_get: (e, t) => {
2605
- if (b) {
2606
- let n = new Uint8Array(b.buffer, e, t);
2748
+ if (C) {
2749
+ let n = new Uint8Array(C.buffer, e, t);
2607
2750
  for (let e = 0; e < t; e++) n[e] = Math.random() * 256 | 0;
2608
2751
  }
2609
2752
  return i;
2610
2753
  }
2611
2754
  }, { get(e, t) {
2612
2755
  return t in e ? e[t] : () => 0;
2613
- } }), I = (e) => {
2614
- if (!b || !e) return "";
2756
+ } }), L = (e) => {
2757
+ if (!C || !e) return "";
2615
2758
  try {
2616
- let t = new DataView(b.buffer).getUint32(e - 4, !0), n = new Uint16Array(b.buffer, e, t >>> 1);
2759
+ let t = new DataView(C.buffer).getUint32(e - 4, !0), n = new Uint16Array(C.buffer, e, t >>> 1);
2617
2760
  return String.fromCharCode(...n);
2618
2761
  } catch {
2619
2762
  return "";
2620
2763
  }
2621
- }, L = {
2622
- wasi_snapshot_preview1: F,
2623
- wasi_unstable: F,
2764
+ }, R = {
2765
+ wasi_snapshot_preview1: I,
2766
+ wasi_unstable: I,
2624
2767
  env: new Proxy({
2625
2768
  print: (e, t) => {
2626
- b && C(1, n.decode(new Uint8Array(b.buffer, e, t)));
2769
+ C && w(1, n.decode(new Uint8Array(C.buffer, e, t)));
2627
2770
  },
2628
2771
  eprint: (e, t) => {
2629
- b && C(2, n.decode(new Uint8Array(b.buffer, e, t)));
2772
+ C && w(2, n.decode(new Uint8Array(C.buffer, e, t)));
2630
2773
  },
2631
2774
  log: (e) => {
2632
- C(1, I(e) + "\n");
2775
+ w(1, L(e) + "\n");
2633
2776
  },
2634
2777
  logi: (e) => {
2635
- C(1, String(e) + "\n");
2778
+ w(1, String(e) + "\n");
2636
2779
  },
2637
2780
  logf: (e) => {
2638
- C(1, String(e) + "\n");
2781
+ w(1, String(e) + "\n");
2639
2782
  },
2640
2783
  trace: (e, t, ...n) => {
2641
2784
  let r = t > 0 ? " " + n.slice(0, t).join(", ") : "";
2642
- C(1, `trace: ${I(e)}${r}\n`);
2785
+ w(1, `trace: ${L(e)}${r}\n`);
2643
2786
  },
2644
2787
  seed: () => Date.now() * Math.random(),
2645
2788
  abort: (e, t, n, r) => {
2646
- let i = I(e), a = I(t);
2647
- throw (i || a) && C(2, `abort: ${i || "aborted"} at ${a || this.script}:${n || 0}:${r || 0}\n`), this.exitCode = 134, {
2789
+ let i = L(e), a = L(t);
2790
+ throw (i || a) && w(2, `abort: ${i || "aborted"} at ${a || this.script}:${n || 0}:${r || 0}\n`), this.exitCode = 134, {
2648
2791
  _wasmExit: !0,
2649
2792
  code: 134
2650
2793
  };
@@ -2660,10 +2803,10 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
2660
2803
  initial: 1,
2661
2804
  maximum: 256
2662
2805
  });
2663
- b = t, L[e.module] || (L[e.module] = {}), L[e.module][e.name] = t;
2806
+ C = t, R[e.module] || (R[e.module] = {}), R[e.module][e.name] = t;
2664
2807
  }
2665
- let n = await WebAssembly.instantiate(t, L);
2666
- n.exports.memory && (b = n.exports.memory);
2808
+ let n = await WebAssembly.instantiate(t, R);
2809
+ n.exports.memory && (C = n.exports.memory);
2667
2810
  let r = n.exports._start || n.exports.__wasi_command || n.exports.main || n.exports.run;
2668
2811
  if (r) try {
2669
2812
  await r();
@@ -2677,27 +2820,27 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
2677
2820
  } catch (e) {
2678
2821
  (!e || !e._wasmExit) && (this.stdErr = `${this.script}: ${e?.message || String(e)}`, this.exitCode = 1);
2679
2822
  } finally {
2680
- for (let e of k.values()) N(e);
2823
+ for (let e of A.values()) P(e);
2681
2824
  }
2682
- w();
2683
- let R = this.arguments || [];
2825
+ T();
2826
+ let z = this.arguments || [];
2684
2827
  if (!(this.result && this.result.getStdOutput && this.result.getStdOutput().length > 0) && (this.exitCode === 0 || this.exitCode === void 0)) {
2685
2828
  let t = (this.script || "wasm").split("/").pop(), n = Object.assign({
2686
2829
  name: t,
2687
2830
  version: "wasi",
2688
2831
  description: `WebAssembly WASI binary (${this.script})`
2689
2832
  }, this._pkgMeta || {});
2690
- if (R.includes("--help") || R.includes("-h")) {
2833
+ if (z.includes("--help") || z.includes("-h")) {
2691
2834
  let r = j(e);
2692
2835
  for (let e of M(t, n, r)) this.stdOut = e;
2693
- } else (R.includes("--version") || R.includes("-V") || R.includes("-v")) && (this.stdOut = `${t} (${n.name} ${n.version} wasm)`);
2836
+ } else (z.includes("--version") || z.includes("-V") || z.includes("-v")) && (this.stdOut = `${t} (${n.name} ${n.version} wasm)`);
2694
2837
  }
2695
2838
  }
2696
2839
  }, w = /* @__PURE__ */ new Map();
2697
- function D(e, t) {
2840
+ function T(e, t) {
2698
2841
  if (!e || !e.exists(t)) return null;
2699
2842
  if (e.isRealFilesystem) try {
2700
- let n = J();
2843
+ let n = Y();
2701
2844
  return new Uint8Array(n.readFileSync(e.absolutePath(t)));
2702
2845
  } catch {}
2703
2846
  let n = e.getFileByPath(t);
@@ -2726,7 +2869,7 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
2726
2869
  o.set(a);
2727
2870
  let s = new r(o.buffer, i);
2728
2871
  if (e.isRealFilesystem) try {
2729
- let n = J(), r = re(), i = e.absolutePath(t);
2872
+ let n = Y(), r = re(), i = e.absolutePath(t);
2730
2873
  n.mkdirSync(r.dirname(i), { recursive: !0 }), n.writeFileSync(i, y.from(a.buffer, a.byteOffset, a.byteLength));
2731
2874
  return;
2732
2875
  } catch {
@@ -2821,7 +2964,7 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
2821
2964
  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;
2822
2965
  }
2823
2966
  function N(e, t = {}, n = null) {
2824
- let r = T(), i = (n || e.bin || e.name).toLowerCase();
2967
+ let r = E(), i = (n || e.bin || e.name).toLowerCase();
2825
2968
  class a extends r {
2826
2969
  static get name() {
2827
2970
  return i;
@@ -2834,11 +2977,18 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
2834
2977
  }
2835
2978
  async run() {
2836
2979
  let n = [...this.arguments || []], r = n.includes("--help") || n.includes("-h"), a = !r && (n.includes("--version") || n.includes("-V") || n.includes("-v"));
2837
- this._inspectedWasm = null, this._persistedWasmBytes = e.wasmPath ? D(this.context && this.context.fs || this.fs, e.wasmPath) : null, r && this._persistedWasmBytes && this._persistedWasmBytes.byteLength > 0 && (this._inspectedWasm = j(this._persistedWasmBytes));
2980
+ this._inspectedWasm = null, this._persistedWasmBytes = e.wasmPath ? T(this.context && this.context.fs || this.fs, e.wasmPath) : null, r && this._persistedWasmBytes && this._persistedWasmBytes.byteLength > 0 && (this._inspectedWasm = j(this._persistedWasmBytes));
2838
2981
  try {
2839
- if (e.type === "wasm" && (this._persistedWasmBytes || e.wasmUrl) && !t.moduleLoader) {
2840
- let t = this._persistedWasmBytes || await this._fetchWasmBytes(e.wasmUrl);
2841
- r && (this._inspectedWasm = j(t)), await this._runRawWasmBytes(t, n);
2982
+ if ((e.type === "wasm" || e.type === "custom-wasm") && (this._persistedWasmBytes || e.wasmUrl)) {
2983
+ let i = this._persistedWasmBytes;
2984
+ if (!i && t.moduleLoader) try {
2985
+ let n = await t.moduleLoader(e.name, e.cdnUrl);
2986
+ 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);
2987
+ } catch {}
2988
+ if (!i && e.wasmUrl && (i = await this._fetchWasmBytes(e.wasmUrl)), i) {
2989
+ r && (this._inspectedWasm = j(i)), await this._runRawWasmBytes(i, n);
2990
+ return;
2991
+ }
2842
2992
  } else {
2843
2993
  let o = e.cdnUrl || e.wasmUrl || `https://esm.sh/${e.name}`, s = typeof globalThis.fetch == "function" ? globalThis.fetch : null;
2844
2994
  if (s && this._persistedWasmBytes && this._persistedWasmBytes.byteLength > 0 && typeof Response < "u") {
@@ -2939,7 +3089,7 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
2939
3089
  let n = t && t !== "." && !e.startsWith("/") ? `${t.replace(/\/+$/, "")}/${e}` : e, r = this.fs.getFileByPath(n) ?? this.fs.getFileByPath(e);
2940
3090
  return r == null ? null : typeof r == "string" ? r : new TextDecoder().decode(r);
2941
3091
  },
2942
- readBytes: (e) => D(this.fs, e),
3092
+ readBytes: (e) => T(this.fs, e),
2943
3093
  writeFile: (e, t, n) => {
2944
3094
  if (!this.fs) return;
2945
3095
  let r = n && n !== "." && !e.startsWith("/") ? `${n.replace(/\/+$/, "")}/${e}` : e;
@@ -3044,7 +3194,7 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
3044
3194
  }), !t.loaded && typeof t.load == "function" && await t.load(e.coreUrl ? { coreURL: e.coreUrl } : void 0);
3045
3195
  let a = /* @__PURE__ */ new Set(), o = [];
3046
3196
  for (let e of n) if (!e.startsWith("-") && (o.push(e), this.fs.exists(e))) {
3047
- let n = D(this.fs, e);
3197
+ let n = T(this.fs, e);
3048
3198
  n && (await t.writeFile(e, n), a.add(e));
3049
3199
  }
3050
3200
  let s = await t.exec(n);
@@ -3068,7 +3218,7 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
3068
3218
  let n = /* @__PURE__ */ new Set();
3069
3219
  if (!this.fs || !e || typeof e.writeFile != "function") return n;
3070
3220
  for (let r of t) if (!r.startsWith("-") && this.fs.exists(r)) {
3071
- let t = D(this.fs, r);
3221
+ let t = T(this.fs, r);
3072
3222
  if (t) try {
3073
3223
  e.writeFile(r, t), n.add(r);
3074
3224
  } catch {}
@@ -3091,9 +3241,9 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
3091
3241
  }
3092
3242
  return a;
3093
3243
  }
3094
- C.readBytesFromFs = D, C.writeBytesToFs = O, C.loadModule = k, C.extractHelpFromText = A, C.inspectWasmBytes = j, C.formatWasmHelp = M, C.createGenericWasmCommand = N, C.createCommand = N, t.exports = C;
3095
- })), X = /* @__PURE__ */ t(((e, t) => {
3096
- var n = te(), { createGenericWasmCommand: r } = Y(), i = "\x1B[2J\x1B[H", a = "\x1B[0m", o = "\x1B[7m", s = "\x1B[1m", c = "\x1B[2m", l = "\x1B[36m", u = "\x1B[31m", d = "\x1B[32m", f = class extends n {
3244
+ C.readBytesFromFs = T, C.writeBytesToFs = O, C.loadModule = k, C.extractHelpFromText = A, C.inspectWasmBytes = j, C.formatWasmHelp = M, C.createGenericWasmCommand = N, C.createCommand = N, t.exports = C;
3245
+ })), Z = /* @__PURE__ */ t(((e, t) => {
3246
+ var n = q(), { createGenericWasmCommand: r } = X(), i = "\x1B[2J\x1B[H", a = "\x1B[0m", o = "\x1B[7m", s = "\x1B[1m", c = "\x1B[2m", l = "\x1B[36m", u = "\x1B[31m", d = "\x1B[32m", f = class extends n {
3097
3247
  get requiresFilesystem() {
3098
3248
  return !0;
3099
3249
  }
@@ -3128,7 +3278,7 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
3128
3278
  }
3129
3279
  async runNonInteractive() {}
3130
3280
  startRepl(e = {}) {
3131
- return this._dynamicReplActive = !0, this._dynamicReplOpts = e, this._dynamicReplBuffer = "", this._dynamicReplMultiline = !1, this._launchInteractiveReplLoop();
3281
+ return this._dynamicReplActive = !0, this._dynamicReplOpts = e, this._dynamicReplBuffer = "", this._dynamicReplMultiline = !1, typeof this._enterAltScreen == "function" && this._enterAltScreen(), this._launchInteractiveReplLoop();
3132
3282
  }
3133
3283
  run() {
3134
3284
  return this.shouldBeInteractive() ? this._launchInteractiveReplLoop() : Promise.resolve(this.runNonInteractive());
@@ -3203,6 +3353,13 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
3203
3353
  this._replCursor > 0 && (this._replInput = this._replInput.slice(0, this._replCursor - 1) + this._replInput.slice(this._replCursor), this._replCursor--, this._renderRepl());
3204
3354
  return;
3205
3355
  }
3356
+ if (e === "^W") {
3357
+ let e = this._replCursor;
3358
+ for (; e > 0 && this._replInput[e - 1] === " ";) e--;
3359
+ for (; e > 0 && this._replInput[e - 1] !== " ";) e--;
3360
+ this._replInput = this._replInput.slice(0, e) + this._replInput.slice(this._replCursor), this._replCursor = e, this._renderRepl();
3361
+ return;
3362
+ }
3206
3363
  if (e === "Delete") {
3207
3364
  this._replCursor < this._replInput.length && (this._replInput = this._replInput.slice(0, this._replCursor) + this._replInput.slice(this._replCursor + 1), this._renderRepl());
3208
3365
  return;
@@ -3341,7 +3498,7 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
3341
3498
  return s;
3342
3499
  }
3343
3500
  f.createReplWasmCommand = p, f.createCommand = p, t.exports = f;
3344
- })), Z = /* @__PURE__ */ t(((e, t) => {
3501
+ })), ie = /* @__PURE__ */ t(((e, t) => {
3345
3502
  var n = {
3346
3503
  sqlite3: {
3347
3504
  name: "sqlite3",
@@ -3517,6 +3674,19 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
3517
3674
  type: "builtin-adapter",
3518
3675
  adapter: "wllama",
3519
3676
  size: "8.8 MB"
3677
+ },
3678
+ nano: {
3679
+ name: "nano",
3680
+ bin: "nano",
3681
+ aliases: ["nano-wasm"],
3682
+ version: "8.0.0",
3683
+ description: "GNU nano 8.0 text editor compiled to WebAssembly (wasm32-wasip1) with ncurses",
3684
+ details: "GNU nano is a small, user-friendly command-line text editor compiled to WebAssembly with wide-character ncurses 6.5, built-in terminfo fallbacks (xterm-256color, vt100, etc.), dynamic terminal dimensions (TIOCGWINSZ / LINES & COLUMNS), and zero custom imports (standard wasi_snapshot_preview1).",
3685
+ homepage: "https://github.com/eliotstocker/nano-wasm",
3686
+ cdnUrl: "https://cdn.jsdelivr.net/gh/eliotstocker/nano-wasm@main/dist/nano.wasm",
3687
+ wasmUrl: "https://cdn.jsdelivr.net/gh/eliotstocker/nano-wasm@main/dist/nano.wasm",
3688
+ type: "custom-wasm",
3689
+ size: "574 KB"
3520
3690
  }
3521
3691
  }, r = {
3522
3692
  sqlite: "sqlite3",
@@ -3534,7 +3704,8 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
3534
3704
  llama: "wllama",
3535
3705
  "llama-cli": "wllama",
3536
3706
  "llama.cpp": "wllama",
3537
- "@wllama/wllama": "wllama"
3707
+ "@wllama/wllama": "wllama",
3708
+ "nano-wasm": "nano"
3538
3709
  };
3539
3710
  function i(e) {
3540
3711
  if (!e) return null;
@@ -3546,7 +3717,7 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
3546
3717
  PACKAGE_ALIASES: r,
3547
3718
  resolvePackageName: i
3548
3719
  };
3549
- })), ie = /* @__PURE__ */ t(((e, t) => {
3720
+ })), ae = /* @__PURE__ */ t(((e, t) => {
3550
3721
  function n(e, t, n = {}) {
3551
3722
  let { showRowCount: r = !0 } = n;
3552
3723
  if (!e || e.length === 0) return [];
@@ -3582,7 +3753,7 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
3582
3753
  }
3583
3754
  return i;
3584
3755
  }
3585
- var { readBytesFromFs: a, writeBytesToFs: o, loadModule: s, extractHelpFromText: c, inspectWasmBytes: l, formatWasmHelp: u } = Y();
3756
+ var { readBytesFromFs: a, writeBytesToFs: o, loadModule: s, extractHelpFromText: c, inspectWasmBytes: l, formatWasmHelp: u } = X();
3586
3757
  t.exports = {
3587
3758
  formatTable: n,
3588
3759
  formatPipeList: r,
@@ -3594,9 +3765,9 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
3594
3765
  inspectWasmBytes: l,
3595
3766
  formatWasmHelp: u
3596
3767
  };
3597
- })), ae = /* @__PURE__ */ t(((e, t) => {
3598
- w();
3599
- var n = X(), { readBytesFromFs: r, writeBytesToFs: i, loadModule: a } = ie(), o = "https://huggingface.co/ggml-org/models/resolve/main/tinyllamas/stories260K.gguf", s = "https://cdn.jsdelivr.net/npm/@wllama/wllama@3.8.1/src/wasm/wllama.wasm", c = "/var/cache/wllama", l = /* @__PURE__ */ new Map();
3768
+ })), oe = /* @__PURE__ */ t(((e, t) => {
3769
+ T();
3770
+ var n = Z(), { readBytesFromFs: r, writeBytesToFs: i, loadModule: a } = ae(), o = "https://huggingface.co/ggml-org/models/resolve/main/tinyllamas/stories260K.gguf", s = "https://cdn.jsdelivr.net/npm/@wllama/wllama@3.8.1/src/wasm/wllama.wasm", c = "/var/cache/wllama", l = /* @__PURE__ */ new Map();
3600
3771
  function u(e) {
3601
3772
  if (!e) return `${c}/model.gguf`;
3602
3773
  if (e.kind === "fs") return e.path;
@@ -4280,9 +4451,9 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
4280
4451
  name: "wllama",
4281
4452
  version: "3.8.1"
4282
4453
  }), t.exports.wllamaInstances = l, t.exports.getDefaultPersistPath = u, t.exports.DEFAULT_PERSIST_DIR = c, t.exports.resolveModelSpec = f, t.exports.formatDownloadProgress = d;
4283
- })), oe = /* @__PURE__ */ t(((e, t) => {
4454
+ })), se = /* @__PURE__ */ t(((e, t) => {
4284
4455
  b();
4285
- var r = T(), i = Y(), a = X(), { DEFAULT_REGISTRY: o, resolvePackageName: s } = Z(), c = ae(), { writeBytesToFs: l, createGenericWasmCommand: u } = i, { createReplWasmCommand: d } = a, f = "/var/lib/wbt/installed.json", p = "/var/cache/wbt";
4456
+ var r = E(), i = X(), a = Z(), { DEFAULT_REGISTRY: o, resolvePackageName: s } = ie(), c = oe(), { writeBytesToFs: l, createGenericWasmCommand: u } = i, { createReplWasmCommand: d } = a, f = "/var/lib/wbt/installed.json", p = "/var/cache/wbt";
4286
4457
  function m(e, t, n = {}) {
4287
4458
  class r extends i {
4288
4459
  static get name() {
@@ -4356,7 +4527,7 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
4356
4527
  }
4357
4528
  _buildCommandsForPackage(e) {
4358
4529
  let t = this.constructor._config || {};
4359
- if (e.type === "custom-wasm" && e.wasmPath) {
4530
+ if ((e.type === "custom-wasm" || e.type === "wasm") && e.wasmPath) {
4360
4531
  let t = (e.bin || e.name).toLowerCase();
4361
4532
  return [{
4362
4533
  bin: t,
@@ -4641,7 +4812,7 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
4641
4812
  return null;
4642
4813
  }
4643
4814
  async _pullPackageWasm(e, t = !1, n = !1) {
4644
- let r = this.constructor._config || {}, i = r.fetch || (typeof fetch == "function" ? fetch : null), { loadModule: a } = ie(), o = null, s = null, c = e.wasmUrl || (/\.(wasm|wat)(\?.*)?$/i.test(e.cdnUrl || "") ? e.cdnUrl : null);
4815
+ let r = this.constructor._config || {}, i = r.fetch || (typeof fetch == "function" ? fetch : null), { loadModule: a } = ae(), o = null, s = null, c = e.wasmUrl || (/\.(wasm|wat)(\?.*)?$/i.test(e.cdnUrl || "") ? e.cdnUrl : null);
4645
4816
  if (c && i) try {
4646
4817
  let n = await i(c);
4647
4818
  n && n.ok ? o = await this._readResponseBytes(n, `${e.name}.wasm`, t) : s = /* @__PURE__ */ Error(`HTTP ${n ? n.status : "error"} fetching ${c}`);
@@ -4921,7 +5092,8 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
4921
5092
  " wabt WebAssembly Binary Toolkit (wat2wasm, wasm2wat)",
4922
5093
  " quickjs Sandboxed QuickJS JavaScript engine (qjs)",
4923
5094
  " lua Lua 5.4 WebAssembly interpreter (lua)",
4924
- " wllama WASM & WebGPU LLM inference engine (wllama, llama, llama-cli)"
5095
+ " wllama WASM & WebGPU LLM inference engine (wllama, llama, llama-cli)",
5096
+ " nano GNU nano 8.0 text editor with ncurses (nano, nano-wasm)"
4925
5097
  ].forEach((e) => {
4926
5098
  this.stdOut = e;
4927
5099
  });
@@ -4930,6 +5102,6 @@ var L, R, z, B, V, H, U, W, G, K, ee = e((() => {
4930
5102
  t.exports = h, t.exports.Wbt = h, t.exports.DEFAULT_REGISTRY = o, t.exports.createGenericWasmCommand = u, t.exports.createReplWasmCommand = d;
4931
5103
  }));
4932
5104
  //#endregion
4933
- export default oe();
5105
+ export default se();
4934
5106
 
4935
5107
  //# sourceMappingURL=wbt.es.js.map