brsh 3.10.0 → 3.10.2
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/CHANGELOG.md +14 -0
- package/dist/shell.es.js +750 -596
- package/dist/shell.es.js.map +1 -1
- package/dist/shell.min.js +23 -23
- package/dist/shell.min.js.map +1 -1
- package/dist/terminal.cjs.js +3 -3
- package/dist/terminal.cjs.js.map +1 -1
- package/dist/terminal.es.js +55 -33
- package/dist/terminal.es.js.map +1 -1
- package/dist/terminal.min.js +3 -3
- package/dist/terminal.min.js.map +1 -1
- package/dist/wbt.es.js +862 -670
- package/dist/wbt.es.js.map +1 -1
- package/dist/wbt.min.js +14 -14
- package/dist/wbt.min.js.map +1 -1
- package/index.js +79 -18
- package/lib/BaseFileSystem.js +2 -0
- package/lib/BinaryContainer.js +1 -1
- package/lib/Command.js +1 -1
- package/lib/Context.js +3 -2
- package/lib/InteractiveCommand.js +9 -8
- package/lib/ScriptCommand.js +76 -27
- package/lib/Terminal.js +60 -6
- package/lib/TtyStream.js +36 -2
- package/lib/WasmCommand.js +229 -42
- package/lib/wbt/index.js +172 -58
- package/package.json +1 -1
- package/test/devices-signals.test.js +112 -0
- package/test/doom.test.js +7 -4
- package/test/scripts.test.js +48 -0
- package/test/shell.test.js +60 -0
- package/test/terminal.test.js +148 -0
- package/test/wasm-cli.test.js +76 -0
- package/test/wbt.test.js +111 -1
package/dist/wbt.es.js
CHANGED
|
@@ -96,7 +96,7 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
|
|
|
96
96
|
if (typeof e == "string") return g(e, t);
|
|
97
97
|
if (o.isView(e)) return y(e);
|
|
98
98
|
if (e == null) throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof e);
|
|
99
|
-
if (
|
|
99
|
+
if (Q(e, o) || e && Q(e.buffer, o) || s !== void 0 && (Q(e, s) || e && Q(e.buffer, s))) return b(e, t, n);
|
|
100
100
|
if (typeof e == "number") throw TypeError("The \"value\" argument must not be of type number. Received type number");
|
|
101
101
|
let r = e.valueOf && e.valueOf();
|
|
102
102
|
if (r != null && r !== e) return u.from(r, t, n);
|
|
@@ -137,7 +137,7 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
|
|
|
137
137
|
return n;
|
|
138
138
|
}
|
|
139
139
|
function y(e) {
|
|
140
|
-
if (
|
|
140
|
+
if (Q(e, a)) {
|
|
141
141
|
let t = new a(e);
|
|
142
142
|
return b(t.buffer, t.byteOffset, t.byteLength);
|
|
143
143
|
}
|
|
@@ -154,7 +154,7 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
|
|
|
154
154
|
let t = S(e.length) | 0, n = l(t);
|
|
155
155
|
return n.length === 0 || e.copy(n, 0, 0, t), n;
|
|
156
156
|
}
|
|
157
|
-
if (e.length !== void 0) return typeof e.length != "number" ||
|
|
157
|
+
if (e.length !== void 0) return typeof e.length != "number" || de(e.length) ? l(0) : _(e);
|
|
158
158
|
if (e.type === "Buffer" && Array.isArray(e.data)) return _(e.data);
|
|
159
159
|
}
|
|
160
160
|
function S(e) {
|
|
@@ -167,7 +167,7 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
|
|
|
167
167
|
u.isBuffer = function(e) {
|
|
168
168
|
return e != null && e._isBuffer === !0 && e !== u.prototype;
|
|
169
169
|
}, u.compare = function(e, t) {
|
|
170
|
-
if (
|
|
170
|
+
if (Q(e, a) && (e = u.from(e, e.offset, e.byteLength)), Q(t, a) && (t = u.from(t, t.offset, t.byteLength)), !u.isBuffer(e) || !u.isBuffer(t)) throw TypeError("The \"buf1\", \"buf2\" arguments must be one of type Buffer or Uint8Array");
|
|
171
171
|
if (e === t) return 0;
|
|
172
172
|
let n = e.length, r = t.length;
|
|
173
173
|
for (let i = 0, a = Math.min(n, r); i < a; ++i) if (e[i] !== t[i]) {
|
|
@@ -198,7 +198,7 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
|
|
|
198
198
|
let r = u.allocUnsafe(t), i = 0;
|
|
199
199
|
for (n = 0; n < e.length; ++n) {
|
|
200
200
|
let t = e[n];
|
|
201
|
-
if (
|
|
201
|
+
if (Q(t, a)) i + t.length > r.length ? (u.isBuffer(t) || (t = u.from(t)), t.copy(r, i)) : a.prototype.set.call(r, t, i);
|
|
202
202
|
else if (u.isBuffer(t)) t.copy(r, i);
|
|
203
203
|
else throw TypeError("\"list\" argument must be an Array of Buffers");
|
|
204
204
|
i += t.length;
|
|
@@ -207,7 +207,7 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
|
|
|
207
207
|
};
|
|
208
208
|
function w(e, t) {
|
|
209
209
|
if (u.isBuffer(e)) return e.length;
|
|
210
|
-
if (o.isView(e) ||
|
|
210
|
+
if (o.isView(e) || Q(e, o)) return e.byteLength;
|
|
211
211
|
if (typeof e != "string") throw TypeError("The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. Received type " + typeof e);
|
|
212
212
|
let n = e.length, r = arguments.length > 2 && arguments[2] === !0;
|
|
213
213
|
if (!r && n === 0) return 0;
|
|
@@ -217,15 +217,15 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
|
|
|
217
217
|
case "latin1":
|
|
218
218
|
case "binary": return n;
|
|
219
219
|
case "utf8":
|
|
220
|
-
case "utf-8": return
|
|
220
|
+
case "utf-8": return Z(e).length;
|
|
221
221
|
case "ucs2":
|
|
222
222
|
case "ucs-2":
|
|
223
223
|
case "utf16le":
|
|
224
224
|
case "utf-16le": return n * 2;
|
|
225
225
|
case "hex": return n >>> 1;
|
|
226
|
-
case "base64": return
|
|
226
|
+
case "base64": return le(e).length;
|
|
227
227
|
default:
|
|
228
|
-
if (i) return r ? -1 :
|
|
228
|
+
if (i) return r ? -1 : Z(e).length;
|
|
229
229
|
t = ("" + t).toLowerCase(), i = !0;
|
|
230
230
|
}
|
|
231
231
|
}
|
|
@@ -234,17 +234,17 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
|
|
|
234
234
|
let r = !1;
|
|
235
235
|
if ((t === void 0 || t < 0) && (t = 0), t > this.length || ((n === void 0 || n > this.length) && (n = this.length), n <= 0) || (n >>>= 0, t >>>= 0, n <= t)) return "";
|
|
236
236
|
for (e ||= "utf8";;) switch (e) {
|
|
237
|
-
case "hex": return
|
|
237
|
+
case "hex": return z(this, t, n);
|
|
238
238
|
case "utf8":
|
|
239
239
|
case "utf-8": return F(this, t, n);
|
|
240
|
-
case "ascii": return
|
|
240
|
+
case "ascii": return ee(this, t, n);
|
|
241
241
|
case "latin1":
|
|
242
|
-
case "binary": return
|
|
242
|
+
case "binary": return R(this, t, n);
|
|
243
243
|
case "base64": return P(this, t, n);
|
|
244
244
|
case "ucs2":
|
|
245
245
|
case "ucs-2":
|
|
246
246
|
case "utf16le":
|
|
247
|
-
case "utf-16le": return
|
|
247
|
+
case "utf-16le": return B(this, t, n);
|
|
248
248
|
default:
|
|
249
249
|
if (r) throw TypeError("Unknown encoding: " + e);
|
|
250
250
|
e = (e + "").toLowerCase(), r = !0;
|
|
@@ -280,7 +280,7 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
|
|
|
280
280
|
let t = "", n = e.INSPECT_MAX_BYTES;
|
|
281
281
|
return t = this.toString("hex", 0, n).replace(/(.{2})/g, "$1 ").trim(), this.length > n && (t += " ... "), "<Buffer " + t + ">";
|
|
282
282
|
}, r && (u.prototype[r] = u.prototype.inspect), u.prototype.compare = function(e, t, n, r, i) {
|
|
283
|
-
if (
|
|
283
|
+
if (Q(e, a) && (e = u.from(e, e.offset, e.byteLength)), !u.isBuffer(e)) throw TypeError("The \"target\" argument must be one of type Buffer or Uint8Array. Received type " + typeof e);
|
|
284
284
|
if (t === void 0 && (t = 0), n === void 0 && (n = e ? e.length : 0), r === void 0 && (r = 0), i === void 0 && (i = this.length), t < 0 || n > e.length || r < 0 || i > this.length) throw RangeError("out of range index");
|
|
285
285
|
if (r >= i && t >= n) return 0;
|
|
286
286
|
if (r >= i) return -1;
|
|
@@ -295,7 +295,7 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
|
|
|
295
295
|
};
|
|
296
296
|
function D(e, t, n, r, i) {
|
|
297
297
|
if (e.length === 0) return -1;
|
|
298
|
-
if (typeof n == "string" ? (r = n, n = 0) : n > 2147483647 ? n = 2147483647 : n < -2147483648 && (n = -2147483648), n = +n,
|
|
298
|
+
if (typeof n == "string" ? (r = n, n = 0) : n > 2147483647 ? n = 2147483647 : n < -2147483648 && (n = -2147483648), n = +n, de(n) && (n = i ? 0 : e.length - 1), n < 0 && (n = e.length + n), n >= e.length) {
|
|
299
299
|
if (i) return -1;
|
|
300
300
|
n = e.length - 1;
|
|
301
301
|
} else if (n < 0) if (i) n = 0;
|
|
@@ -345,22 +345,22 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
|
|
|
345
345
|
let o;
|
|
346
346
|
for (o = 0; o < r; ++o) {
|
|
347
347
|
let r = parseInt(t.substr(o * 2, 2), 16);
|
|
348
|
-
if (
|
|
348
|
+
if (de(r)) return o;
|
|
349
349
|
e[n + o] = r;
|
|
350
350
|
}
|
|
351
351
|
return o;
|
|
352
352
|
}
|
|
353
353
|
function A(e, t, n, r) {
|
|
354
|
-
return
|
|
354
|
+
return ue(Z(t, e.length - n), e, n, r);
|
|
355
355
|
}
|
|
356
356
|
function j(e, t, n, r) {
|
|
357
|
-
return
|
|
357
|
+
return ue(se(t), e, n, r);
|
|
358
358
|
}
|
|
359
359
|
function M(e, t, n, r) {
|
|
360
|
-
return le(
|
|
360
|
+
return ue(le(t), e, n, r);
|
|
361
361
|
}
|
|
362
362
|
function N(e, t, n, r) {
|
|
363
|
-
return
|
|
363
|
+
return ue(ce(t, e.length - n), e, n, r);
|
|
364
364
|
}
|
|
365
365
|
u.prototype.write = function(e, t, n, r) {
|
|
366
366
|
if (t === void 0) r = "utf8", n = this.length, t = 0;
|
|
@@ -428,26 +428,26 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
|
|
|
428
428
|
for (; r < t;) n += String.fromCharCode.apply(String, e.slice(r, r += I));
|
|
429
429
|
return n;
|
|
430
430
|
}
|
|
431
|
-
function
|
|
431
|
+
function ee(e, t, n) {
|
|
432
432
|
let r = "";
|
|
433
433
|
n = Math.min(e.length, n);
|
|
434
434
|
for (let i = t; i < n; ++i) r += String.fromCharCode(e[i] & 127);
|
|
435
435
|
return r;
|
|
436
436
|
}
|
|
437
|
-
function
|
|
437
|
+
function R(e, t, n) {
|
|
438
438
|
let r = "";
|
|
439
439
|
n = Math.min(e.length, n);
|
|
440
440
|
for (let i = t; i < n; ++i) r += String.fromCharCode(e[i]);
|
|
441
441
|
return r;
|
|
442
442
|
}
|
|
443
|
-
function
|
|
443
|
+
function z(e, t, n) {
|
|
444
444
|
let r = e.length;
|
|
445
445
|
(!t || t < 0) && (t = 0), (!n || n < 0 || n > r) && (n = r);
|
|
446
446
|
let i = "";
|
|
447
|
-
for (let r = t; r < n; ++r) i +=
|
|
447
|
+
for (let r = t; r < n; ++r) i += fe[e[r]];
|
|
448
448
|
return i;
|
|
449
449
|
}
|
|
450
|
-
function
|
|
450
|
+
function B(e, t, n) {
|
|
451
451
|
let r = e.slice(t, n), i = "";
|
|
452
452
|
for (let e = 0; e < r.length - 1; e += 2) i += String.fromCharCode(r[e] + r[e + 1] * 256);
|
|
453
453
|
return i;
|
|
@@ -482,16 +482,16 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
|
|
|
482
482
|
return e >>>= 0, t || V(e, 4, this.length), (this[e] | this[e + 1] << 8 | this[e + 2] << 16) + this[e + 3] * 16777216;
|
|
483
483
|
}, u.prototype.readUint32BE = u.prototype.readUInt32BE = function(e, t) {
|
|
484
484
|
return e >>>= 0, t || V(e, 4, this.length), this[e] * 16777216 + (this[e + 1] << 16 | this[e + 2] << 8 | this[e + 3]);
|
|
485
|
-
}, u.prototype.readBigUInt64LE =
|
|
486
|
-
e >>>= 0,
|
|
485
|
+
}, u.prototype.readBigUInt64LE = $(function(e) {
|
|
486
|
+
e >>>= 0, J(e, "offset");
|
|
487
487
|
let t = this[e], n = this[e + 7];
|
|
488
|
-
(t === void 0 || n === void 0) &&
|
|
488
|
+
(t === void 0 || n === void 0) && Y(e, this.length - 8);
|
|
489
489
|
let r = t + this[++e] * 2 ** 8 + this[++e] * 2 ** 16 + this[++e] * 2 ** 24, i = this[++e] + this[++e] * 2 ** 8 + this[++e] * 2 ** 16 + n * 2 ** 24;
|
|
490
490
|
return BigInt(r) + (BigInt(i) << BigInt(32));
|
|
491
|
-
}), u.prototype.readBigUInt64BE =
|
|
492
|
-
e >>>= 0,
|
|
491
|
+
}), u.prototype.readBigUInt64BE = $(function(e) {
|
|
492
|
+
e >>>= 0, J(e, "offset");
|
|
493
493
|
let t = this[e], n = this[e + 7];
|
|
494
|
-
(t === void 0 || n === void 0) &&
|
|
494
|
+
(t === void 0 || n === void 0) && Y(e, this.length - 8);
|
|
495
495
|
let r = t * 2 ** 24 + this[++e] * 2 ** 16 + this[++e] * 2 ** 8 + this[++e], i = this[++e] * 2 ** 24 + this[++e] * 2 ** 16 + this[++e] * 2 ** 8 + n;
|
|
496
496
|
return (BigInt(r) << BigInt(32)) + BigInt(i);
|
|
497
497
|
}), u.prototype.readIntLE = function(e, t, n) {
|
|
@@ -518,16 +518,16 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
|
|
|
518
518
|
return e >>>= 0, t || V(e, 4, this.length), this[e] | this[e + 1] << 8 | this[e + 2] << 16 | this[e + 3] << 24;
|
|
519
519
|
}, u.prototype.readInt32BE = function(e, t) {
|
|
520
520
|
return e >>>= 0, t || V(e, 4, this.length), this[e] << 24 | this[e + 1] << 16 | this[e + 2] << 8 | this[e + 3];
|
|
521
|
-
}, u.prototype.readBigInt64LE =
|
|
522
|
-
e >>>= 0,
|
|
521
|
+
}, u.prototype.readBigInt64LE = $(function(e) {
|
|
522
|
+
e >>>= 0, J(e, "offset");
|
|
523
523
|
let t = this[e], n = this[e + 7];
|
|
524
|
-
(t === void 0 || n === void 0) &&
|
|
524
|
+
(t === void 0 || n === void 0) && Y(e, this.length - 8);
|
|
525
525
|
let r = this[e + 4] + this[e + 5] * 2 ** 8 + this[e + 6] * 2 ** 16 + (n << 24);
|
|
526
526
|
return (BigInt(r) << BigInt(32)) + BigInt(t + this[++e] * 2 ** 8 + this[++e] * 2 ** 16 + this[++e] * 2 ** 24);
|
|
527
|
-
}), u.prototype.readBigInt64BE =
|
|
528
|
-
e >>>= 0,
|
|
527
|
+
}), u.prototype.readBigInt64BE = $(function(e) {
|
|
528
|
+
e >>>= 0, J(e, "offset");
|
|
529
529
|
let t = this[e], n = this[e + 7];
|
|
530
|
-
(t === void 0 || n === void 0) &&
|
|
530
|
+
(t === void 0 || n === void 0) && Y(e, this.length - 8);
|
|
531
531
|
let r = (t << 24) + this[++e] * 2 ** 16 + this[++e] * 2 ** 8 + this[++e];
|
|
532
532
|
return (BigInt(r) << BigInt(32)) + BigInt(this[++e] * 2 ** 24 + this[++e] * 2 ** 16 + this[++e] * 2 ** 8 + n);
|
|
533
533
|
}), u.prototype.readFloatLE = function(e, t) {
|
|
@@ -572,23 +572,23 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
|
|
|
572
572
|
return e = +e, t >>>= 0, n || H(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 U(e, t, n, r, i) {
|
|
575
|
-
|
|
575
|
+
ae(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
|
-
function
|
|
582
|
-
|
|
581
|
+
function te(e, t, n, r, i) {
|
|
582
|
+
ae(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));
|
|
586
586
|
return e[n + 3] = o, o >>= 8, e[n + 2] = o, o >>= 8, e[n + 1] = o, o >>= 8, e[n] = o, n + 8;
|
|
587
587
|
}
|
|
588
|
-
u.prototype.writeBigUInt64LE =
|
|
588
|
+
u.prototype.writeBigUInt64LE = $(function(e, t = 0) {
|
|
589
589
|
return U(this, e, t, BigInt(0), BigInt("0xffffffffffffffff"));
|
|
590
|
-
}), u.prototype.writeBigUInt64BE =
|
|
591
|
-
return
|
|
590
|
+
}), u.prototype.writeBigUInt64BE = $(function(e, t = 0) {
|
|
591
|
+
return te(this, e, t, BigInt(0), BigInt("0xffffffffffffffff"));
|
|
592
592
|
}), u.prototype.writeIntLE = function(e, t, n, r) {
|
|
593
593
|
if (e = +e, t >>>= 0, !r) {
|
|
594
594
|
let r = 2 ** (8 * n - 1);
|
|
@@ -615,29 +615,29 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
|
|
|
615
615
|
return e = +e, t >>>= 0, n || H(this, e, t, 4, 2147483647, -2147483648), this[t] = e & 255, this[t + 1] = e >>> 8, this[t + 2] = e >>> 16, this[t + 3] = e >>> 24, t + 4;
|
|
616
616
|
}, u.prototype.writeInt32BE = function(e, t, n) {
|
|
617
617
|
return e = +e, t >>>= 0, n || H(this, e, t, 4, 2147483647, -2147483648), e < 0 && (e = 4294967295 + e + 1), this[t] = e >>> 24, this[t + 1] = e >>> 16, this[t + 2] = e >>> 8, this[t + 3] = e & 255, t + 4;
|
|
618
|
-
}, u.prototype.writeBigInt64LE =
|
|
618
|
+
}, u.prototype.writeBigInt64LE = $(function(e, t = 0) {
|
|
619
619
|
return U(this, e, t, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
|
|
620
|
-
}), u.prototype.writeBigInt64BE =
|
|
621
|
-
return
|
|
620
|
+
}), u.prototype.writeBigInt64BE = $(function(e, t = 0) {
|
|
621
|
+
return te(this, e, t, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
|
|
622
622
|
});
|
|
623
|
-
function
|
|
623
|
+
function W(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
|
|
627
|
-
return t = +t, r >>>= 0, a ||
|
|
626
|
+
function ne(e, t, r, i, a) {
|
|
627
|
+
return t = +t, r >>>= 0, a || W(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
|
|
630
|
+
return ne(this, e, t, !0, n);
|
|
631
631
|
}, u.prototype.writeFloatBE = function(e, t, n) {
|
|
632
|
-
return
|
|
632
|
+
return ne(this, e, t, !1, n);
|
|
633
633
|
};
|
|
634
|
-
function
|
|
635
|
-
return t = +t, r >>>= 0, a ||
|
|
634
|
+
function re(e, t, r, i, a) {
|
|
635
|
+
return t = +t, r >>>= 0, a || W(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
|
-
return
|
|
638
|
+
return re(this, e, t, !0, n);
|
|
639
639
|
}, u.prototype.writeDoubleBE = function(e, t, n) {
|
|
640
|
-
return
|
|
640
|
+
return re(this, e, t, !1, n);
|
|
641
641
|
}, u.prototype.copy = function(e, t, n, r) {
|
|
642
642
|
if (!u.isBuffer(e)) throw TypeError("argument should be a Buffer");
|
|
643
643
|
if (n ||= 0, !r && r !== 0 && (r = this.length), t >= e.length && (t = e.length), t ||= 0, r > 0 && r < n && (r = n), r === n || e.length === 0 || this.length === 0) return 0;
|
|
@@ -668,9 +668,9 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
|
|
|
668
668
|
}
|
|
669
669
|
return this;
|
|
670
670
|
};
|
|
671
|
-
let
|
|
672
|
-
function
|
|
673
|
-
|
|
671
|
+
let G = {};
|
|
672
|
+
function K(e, t, n) {
|
|
673
|
+
G[e] = class extends n {
|
|
674
674
|
constructor() {
|
|
675
675
|
super(), Object.defineProperty(this, "message", {
|
|
676
676
|
value: t.apply(this, arguments),
|
|
@@ -694,42 +694,42 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
|
|
|
694
694
|
}
|
|
695
695
|
};
|
|
696
696
|
}
|
|
697
|
-
|
|
697
|
+
K("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),
|
|
699
|
+
}, RangeError), K("ERR_INVALID_ARG_TYPE", function(e, t) {
|
|
700
700
|
return `The "${e}" argument must be of type number. Received type ${typeof t}`;
|
|
701
|
-
}, TypeError),
|
|
701
|
+
}, TypeError), K("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 =
|
|
703
|
+
return Number.isInteger(n) && Math.abs(n) > 2 ** 32 ? i = q(String(n)) : typeof n == "bigint" && (i = String(n), (n > BigInt(2) ** BigInt(32) || n < -(BigInt(2) ** BigInt(32))) && (i = q(i)), i += "n"), r += ` It must be ${t}. Received ${i}`, r;
|
|
704
704
|
}, RangeError);
|
|
705
|
-
function
|
|
705
|
+
function q(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
|
|
711
|
-
|
|
710
|
+
function ie(e, t, n) {
|
|
711
|
+
J(t, "offset"), (e[t] === void 0 || e[t + n] === void 0) && Y(t, e.length - (n + 1));
|
|
712
712
|
}
|
|
713
|
-
function
|
|
713
|
+
function ae(e, t, n, r, i, a) {
|
|
714
714
|
if (e > n || e < t) {
|
|
715
715
|
let r = typeof t == "bigint" ? "n" : "", i;
|
|
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
|
|
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 G.ERR_OUT_OF_RANGE("value", i, e);
|
|
717
717
|
}
|
|
718
|
-
|
|
718
|
+
ie(r, i, a);
|
|
719
719
|
}
|
|
720
|
-
function
|
|
721
|
-
if (typeof e != "number") throw new
|
|
720
|
+
function J(e, t) {
|
|
721
|
+
if (typeof e != "number") throw new G.ERR_INVALID_ARG_TYPE(t, "number", e);
|
|
722
722
|
}
|
|
723
|
-
function
|
|
724
|
-
throw Math.floor(e) === e ? t < 0 ? new
|
|
723
|
+
function Y(e, t, n) {
|
|
724
|
+
throw Math.floor(e) === e ? t < 0 ? new G.ERR_BUFFER_OUT_OF_BOUNDS() : new G.ERR_OUT_OF_RANGE(n || "offset", `>= ${+!!n} and <= ${t}`, e) : (J(e, n), new G.ERR_OUT_OF_RANGE(n || "offset", "an integer", e));
|
|
725
725
|
}
|
|
726
|
-
let
|
|
727
|
-
function
|
|
728
|
-
if (e = e.split("=")[0], e = e.trim().replace(
|
|
726
|
+
let X = /[^+/0-9A-Za-z-_]/g;
|
|
727
|
+
function oe(e) {
|
|
728
|
+
if (e = e.split("=")[0], e = e.trim().replace(X, ""), e.length < 2) return "";
|
|
729
729
|
for (; e.length % 4 != 0;) e += "=";
|
|
730
730
|
return e;
|
|
731
731
|
}
|
|
732
|
-
function
|
|
732
|
+
function Z(e, t) {
|
|
733
733
|
t ||= Infinity;
|
|
734
734
|
let n, r = e.length, i = null, a = [];
|
|
735
735
|
for (let o = 0; o < r; ++o) {
|
|
@@ -767,31 +767,31 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
|
|
|
767
767
|
}
|
|
768
768
|
return a;
|
|
769
769
|
}
|
|
770
|
-
function
|
|
770
|
+
function se(e) {
|
|
771
771
|
let t = [];
|
|
772
772
|
for (let n = 0; n < e.length; ++n) t.push(e.charCodeAt(n) & 255);
|
|
773
773
|
return t;
|
|
774
774
|
}
|
|
775
|
-
function
|
|
775
|
+
function ce(e, t) {
|
|
776
776
|
let n, r, i, a = [];
|
|
777
777
|
for (let o = 0; o < e.length && !((t -= 2) < 0); ++o) n = e.charCodeAt(o), r = n >> 8, i = n % 256, a.push(i), a.push(r);
|
|
778
778
|
return a;
|
|
779
779
|
}
|
|
780
|
-
function
|
|
781
|
-
return t.toByteArray(
|
|
780
|
+
function le(e) {
|
|
781
|
+
return t.toByteArray(oe(e));
|
|
782
782
|
}
|
|
783
|
-
function
|
|
783
|
+
function ue(e, t, n, r) {
|
|
784
784
|
let i;
|
|
785
785
|
for (i = 0; i < r && !(i + n >= t.length || i >= e.length); ++i) t[i + n] = e[i];
|
|
786
786
|
return i;
|
|
787
787
|
}
|
|
788
|
-
function
|
|
788
|
+
function Q(e, t) {
|
|
789
789
|
return e instanceof t || e != null && e.constructor != null && e.constructor.name != null && e.constructor.name === t.name;
|
|
790
790
|
}
|
|
791
|
-
function
|
|
791
|
+
function de(e) {
|
|
792
792
|
return e !== e;
|
|
793
793
|
}
|
|
794
|
-
let
|
|
794
|
+
let fe = (function() {
|
|
795
795
|
let e = "0123456789abcdef", t = Array(256);
|
|
796
796
|
for (let n = 0; n < 16; ++n) {
|
|
797
797
|
let r = n * 16;
|
|
@@ -799,7 +799,7 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
|
|
|
799
799
|
}
|
|
800
800
|
return t;
|
|
801
801
|
})();
|
|
802
|
-
function
|
|
802
|
+
function $(e) {
|
|
803
803
|
return typeof BigInt > "u" ? pe : e;
|
|
804
804
|
}
|
|
805
805
|
function pe() {
|
|
@@ -862,7 +862,7 @@ function O(e, t) {
|
|
|
862
862
|
this.fun = e, this.array = t;
|
|
863
863
|
}
|
|
864
864
|
function k() {}
|
|
865
|
-
var A, j, M, N, P, F, I, L, R, z
|
|
865
|
+
var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
|
|
866
866
|
A = { exports: {} }, j = A.exports = {}, (function() {
|
|
867
867
|
try {
|
|
868
868
|
M = typeof setTimeout == "function" ? setTimeout : S;
|
|
@@ -890,9 +890,9 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
890
890
|
throw Error("process.chdir is not supported");
|
|
891
891
|
}, j.umask = function() {
|
|
892
892
|
return 0;
|
|
893
|
-
},
|
|
894
|
-
})),
|
|
895
|
-
|
|
893
|
+
}, ee = A.exports, R = /* @__PURE__ */ x(ee);
|
|
894
|
+
})), B = /* @__PURE__ */ t(((e, t) => {
|
|
895
|
+
z();
|
|
896
896
|
function n(e) {
|
|
897
897
|
if (typeof e != "string") throw TypeError("Path must be a string. Received " + JSON.stringify(e));
|
|
898
898
|
}
|
|
@@ -930,7 +930,7 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
930
930
|
resolve: function() {
|
|
931
931
|
for (var e = "", t = !1, i, a = arguments.length - 1; a >= -1 && !t; a--) {
|
|
932
932
|
var o;
|
|
933
|
-
a >= 0 ? o = arguments[a] : (i === void 0 && (i =
|
|
933
|
+
a >= 0 ? o = arguments[a] : (i === void 0 && (i = R.cwd()), o = i), n(o), o.length !== 0 && (e = o + "/" + e, t = o.charCodeAt(0) === 47);
|
|
934
934
|
}
|
|
935
935
|
return e = r(e, !t), t ? e.length > 0 ? "/" + e : "/" : e.length > 0 ? e : ".";
|
|
936
936
|
},
|
|
@@ -1267,7 +1267,7 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
1267
1267
|
return this.std = [], e;
|
|
1268
1268
|
}
|
|
1269
1269
|
};
|
|
1270
|
-
})),
|
|
1270
|
+
})), te = /* @__PURE__ */ t(((e, t) => {
|
|
1271
1271
|
b();
|
|
1272
1272
|
var n = V(), r = n.EventEmitter || n.default || n;
|
|
1273
1273
|
function i(e) {
|
|
@@ -1291,15 +1291,34 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
1291
1291
|
D: "ArrowLeft",
|
|
1292
1292
|
H: "Home",
|
|
1293
1293
|
F: "End",
|
|
1294
|
+
Z: "BackTab",
|
|
1295
|
+
P: "F1",
|
|
1296
|
+
Q: "F2",
|
|
1297
|
+
R: "F3",
|
|
1298
|
+
S: "F4",
|
|
1294
1299
|
"1~": "Home",
|
|
1300
|
+
"2~": "Insert",
|
|
1295
1301
|
"3~": "Delete",
|
|
1296
1302
|
"4~": "End",
|
|
1297
1303
|
"5~": "PageUp",
|
|
1298
1304
|
"6~": "PageDown",
|
|
1299
1305
|
"7~": "Home",
|
|
1300
|
-
"8~": "End"
|
|
1306
|
+
"8~": "End",
|
|
1307
|
+
"15~": "F5",
|
|
1308
|
+
"17~": "F6",
|
|
1309
|
+
"18~": "F7",
|
|
1310
|
+
"19~": "F8",
|
|
1311
|
+
"20~": "F9",
|
|
1312
|
+
"21~": "F10",
|
|
1313
|
+
"23~": "F11",
|
|
1314
|
+
"24~": "F12"
|
|
1301
1315
|
};
|
|
1302
|
-
a[i]
|
|
1316
|
+
if (a[i]) n.push(a[i]);
|
|
1317
|
+
else {
|
|
1318
|
+
let e = i.match(/^1;\d+([ABCDHF])$/);
|
|
1319
|
+
e && a[e[1]] && n.push(a[e[1]]);
|
|
1320
|
+
}
|
|
1321
|
+
r = e + 1;
|
|
1303
1322
|
continue;
|
|
1304
1323
|
}
|
|
1305
1324
|
}
|
|
@@ -1326,75 +1345,82 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
1326
1345
|
}
|
|
1327
1346
|
return n;
|
|
1328
1347
|
}
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1348
|
+
var a = class extends r {
|
|
1349
|
+
constructor(e = {}) {
|
|
1350
|
+
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;
|
|
1351
|
+
}
|
|
1352
|
+
write(e, t, n) {
|
|
1353
|
+
if (e == null) return !0;
|
|
1354
|
+
typeof this._onWrite == "function" && this._onWrite(e), this._isPushing = !0;
|
|
1355
|
+
try {
|
|
1356
|
+
this.emit("data", this._formatChunk(e));
|
|
1357
|
+
} finally {
|
|
1358
|
+
this._isPushing = !1;
|
|
1333
1359
|
}
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1360
|
+
return typeof t == "function" ? t() : typeof n == "function" && n(), !0;
|
|
1361
|
+
}
|
|
1362
|
+
pushData(e) {
|
|
1363
|
+
if (e != null) {
|
|
1364
|
+
this._isPushing = !0;
|
|
1337
1365
|
try {
|
|
1338
1366
|
this.emit("data", this._formatChunk(e));
|
|
1339
1367
|
} finally {
|
|
1340
1368
|
this._isPushing = !1;
|
|
1341
1369
|
}
|
|
1342
|
-
return typeof t == "function" ? t() : typeof n == "function" && n(), !0;
|
|
1343
|
-
}
|
|
1344
|
-
pushData(e) {
|
|
1345
|
-
if (e != null) {
|
|
1346
|
-
this._isPushing = !0;
|
|
1347
|
-
try {
|
|
1348
|
-
this.emit("data", this._formatChunk(e));
|
|
1349
|
-
} finally {
|
|
1350
|
-
this._isPushing = !1;
|
|
1351
|
-
}
|
|
1352
|
-
}
|
|
1353
|
-
}
|
|
1354
|
-
_formatChunk(e) {
|
|
1355
|
-
return this._encoding ? typeof e == "string" ? e : e instanceof Uint8Array || y !== void 0 && y.isBuffer(e) ? new TextDecoder().decode(e) : String(e) : e;
|
|
1356
|
-
}
|
|
1357
|
-
setRawMode(e) {
|
|
1358
|
-
return this.isRaw = !!e, this;
|
|
1359
|
-
}
|
|
1360
|
-
setEncoding(e) {
|
|
1361
|
-
return this._encoding = e, this;
|
|
1362
|
-
}
|
|
1363
|
-
getWindowSize() {
|
|
1364
|
-
return [this.columns, this.rows];
|
|
1365
|
-
}
|
|
1366
|
-
resize(e, t) {
|
|
1367
|
-
this.columns = e, this.rows = t, this.emit("resize");
|
|
1368
|
-
}
|
|
1369
|
-
resume() {
|
|
1370
|
-
return this;
|
|
1371
|
-
}
|
|
1372
|
-
pause() {
|
|
1373
|
-
return this;
|
|
1374
|
-
}
|
|
1375
|
-
pipe(e) {
|
|
1376
|
-
return this.on("data", (t) => e.write(t)), e;
|
|
1377
|
-
}
|
|
1378
|
-
unpipe() {
|
|
1379
|
-
return this;
|
|
1380
|
-
}
|
|
1381
|
-
end(e, t, n) {
|
|
1382
|
-
return e != null && this.write(e, typeof t == "string" ? t : void 0), this.emit("end"), typeof t == "function" ? t() : typeof n == "function" && n(), this;
|
|
1383
|
-
}
|
|
1384
|
-
destroy() {
|
|
1385
|
-
this.removeAllListeners();
|
|
1386
|
-
}
|
|
1387
|
-
toString() {
|
|
1388
|
-
return "";
|
|
1389
|
-
}
|
|
1390
|
-
valueOf() {
|
|
1391
|
-
return "";
|
|
1392
1370
|
}
|
|
1393
|
-
}
|
|
1394
|
-
|
|
1371
|
+
}
|
|
1372
|
+
_formatChunk(e) {
|
|
1373
|
+
return this._encoding ? typeof e == "string" ? e : e instanceof Uint8Array || y !== void 0 && y.isBuffer(e) ? new TextDecoder().decode(e) : String(e) : e;
|
|
1374
|
+
}
|
|
1375
|
+
setRawMode(e) {
|
|
1376
|
+
return this.isRaw = !!e, this;
|
|
1377
|
+
}
|
|
1378
|
+
setEncoding(e) {
|
|
1379
|
+
return this._encoding = e, this;
|
|
1380
|
+
}
|
|
1381
|
+
getWindowSize() {
|
|
1382
|
+
return [this.columns, this.rows];
|
|
1383
|
+
}
|
|
1384
|
+
resize(e, t) {
|
|
1385
|
+
this.columns = e, this.rows = t, this.emit("resize");
|
|
1386
|
+
}
|
|
1387
|
+
resume() {
|
|
1388
|
+
return this;
|
|
1389
|
+
}
|
|
1390
|
+
pause() {
|
|
1391
|
+
return this;
|
|
1392
|
+
}
|
|
1393
|
+
pipe(e) {
|
|
1394
|
+
return this.on("data", (t) => e.write(t)), e;
|
|
1395
|
+
}
|
|
1396
|
+
unpipe() {
|
|
1397
|
+
return this;
|
|
1398
|
+
}
|
|
1399
|
+
end(e, t, n) {
|
|
1400
|
+
return e != null && this.write(e, typeof t == "string" ? t : void 0), this.emit("end"), typeof t == "function" ? t() : typeof n == "function" && n(), this;
|
|
1401
|
+
}
|
|
1402
|
+
destroy() {
|
|
1403
|
+
this.removeAllListeners();
|
|
1404
|
+
}
|
|
1405
|
+
toString() {
|
|
1406
|
+
return "";
|
|
1407
|
+
}
|
|
1408
|
+
valueOf() {
|
|
1409
|
+
return "";
|
|
1410
|
+
}
|
|
1395
1411
|
};
|
|
1396
|
-
|
|
1397
|
-
|
|
1412
|
+
function o(e) {
|
|
1413
|
+
if (!e || e._managesOwnStdinCapture || !e.stdinStream || typeof e.stdinStream.listenerCount != "function") return !1;
|
|
1414
|
+
let t = e.stdinStream.listenerCount("data");
|
|
1415
|
+
return t === 0 ? !1 : e._onStdinStreamData && typeof e.stdinStream.listeners == "function" ? t > +!!e.stdinStream.listeners("data").includes(e._onStdinStreamData) : t > 0;
|
|
1416
|
+
}
|
|
1417
|
+
t.exports = {
|
|
1418
|
+
TtyStream: a,
|
|
1419
|
+
parseVtKeys: i,
|
|
1420
|
+
hasCustomStdinListener: o
|
|
1421
|
+
};
|
|
1422
|
+
})), W = /* @__PURE__ */ t(((e, t) => {
|
|
1423
|
+
var n = V(), r = U(), { TtyStream: i, parseVtKeys: a } = te(), o = n.EventEmitter || n.default || n;
|
|
1398
1424
|
t.exports = class extends o {
|
|
1399
1425
|
constructor(e, t) {
|
|
1400
1426
|
super(), this.arguments = e, this.result = new r(), this.context = t || null;
|
|
@@ -1414,7 +1440,7 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
1414
1440
|
if (!this.captureInput) return;
|
|
1415
1441
|
let t = a(e);
|
|
1416
1442
|
for (let e of t) {
|
|
1417
|
-
if (e === "^C") {
|
|
1443
|
+
if (e === "^C" && !(this.stdinStream && this.stdinStream.isRaw)) {
|
|
1418
1444
|
this.kill("SIGINT");
|
|
1419
1445
|
return;
|
|
1420
1446
|
}
|
|
@@ -1468,16 +1494,16 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
1468
1494
|
this.emit("flush", this.result.flush());
|
|
1469
1495
|
}
|
|
1470
1496
|
};
|
|
1471
|
-
})),
|
|
1472
|
-
var n =
|
|
1497
|
+
})), ne = /* @__PURE__ */ t(((e, t) => {
|
|
1498
|
+
var n = W();
|
|
1473
1499
|
t.exports = class extends n {
|
|
1474
1500
|
constructor(e, t) {
|
|
1475
1501
|
super(e, t);
|
|
1476
1502
|
}
|
|
1477
1503
|
};
|
|
1478
|
-
})),
|
|
1479
|
-
var n =
|
|
1480
|
-
function
|
|
1504
|
+
})), re = /* @__PURE__ */ t(((e, t) => {
|
|
1505
|
+
var n = ne(), { parseVtKeys: r, hasCustomStdinListener: i } = te();
|
|
1506
|
+
function a(e) {
|
|
1481
1507
|
return /^#!\/(sh\.js|bin\/(sh|brsh))/.test(e);
|
|
1482
1508
|
}
|
|
1483
1509
|
t.exports = class extends n {
|
|
@@ -1485,11 +1511,16 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
1485
1511
|
super(t, n), this.script = e, this.source = r;
|
|
1486
1512
|
}
|
|
1487
1513
|
get captureInput() {
|
|
1488
|
-
|
|
1514
|
+
if (!this.sandbox || !this.sandbox.runningCommand) return !1;
|
|
1515
|
+
let e = this.sandbox.runningCommand;
|
|
1516
|
+
return !!(e.captureInput || e.interactive || e._inAltScreen || i(e));
|
|
1489
1517
|
}
|
|
1490
1518
|
get interactive() {
|
|
1491
1519
|
return !!(this.sandbox && this.sandbox.runningCommand && this.sandbox.runningCommand.interactive);
|
|
1492
1520
|
}
|
|
1521
|
+
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));
|
|
1523
|
+
}
|
|
1493
1524
|
get _inAltScreen() {
|
|
1494
1525
|
return !!(this.__inAltScreen || this.sandbox && this.sandbox.runningCommand && this.sandbox.runningCommand._inAltScreen);
|
|
1495
1526
|
}
|
|
@@ -1503,38 +1534,43 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
1503
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);
|
|
1504
1535
|
}
|
|
1505
1536
|
run() {
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1537
|
+
this._managesOwnStdinCapture = !0;
|
|
1538
|
+
let e = this.context && this.context.fs || this.fs, t = e && e[Symbol.for("brsh.fs.target")] || e, n = t && t.isRealFilesystem ? { useRealFilesystem: !0 } : {
|
|
1539
|
+
filesystem: t && t.getRaw() || {},
|
|
1540
|
+
permissions: t && t.getRawPermissions() || {}
|
|
1509
1541
|
};
|
|
1510
1542
|
this.sandbox = new globalThis.shell({
|
|
1511
|
-
cwd:
|
|
1512
|
-
...
|
|
1543
|
+
cwd: t && t.cwd || "/",
|
|
1544
|
+
...n,
|
|
1513
1545
|
subshell: !0
|
|
1514
1546
|
}), this.sandbox.context.source(this.context);
|
|
1515
|
-
let
|
|
1516
|
-
typeof this.sandbox.setTerminalSize == "function" && this.sandbox.setTerminalSize(
|
|
1517
|
-
let
|
|
1547
|
+
let o = this.stdout && this.stdout.columns || this.stdinStream && this.stdinStream.columns || this.context && typeof this.context.getVar == "function" && parseInt(this.context.getVar("COLUMNS"), 10) || 80, s = this.stdout && this.stdout.rows || this.stdinStream && this.stdinStream.rows || this.context && typeof this.context.getVar == "function" && parseInt(this.context.getVar("LINES"), 10) || 24;
|
|
1548
|
+
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
|
+
let c = (e) => {
|
|
1518
1550
|
if (!this.sandbox || !this.sandbox.runningCommand) return;
|
|
1519
|
-
let t = this.sandbox.runningCommand, n = t
|
|
1551
|
+
let t = this.sandbox.runningCommand, n = i(t);
|
|
1520
1552
|
if (t.interactive || t._inAltScreen || n) {
|
|
1521
1553
|
t.stdinStream && t.stdinStream.pushData(e);
|
|
1522
1554
|
return;
|
|
1523
1555
|
}
|
|
1524
1556
|
if (t.captureInput && typeof t.onInput == "function") {
|
|
1525
|
-
let
|
|
1526
|
-
for (let
|
|
1527
|
-
if (
|
|
1557
|
+
let n = !!(t.isRaw || t.stdinStream && t.stdinStream.isRaw);
|
|
1558
|
+
for (let i of r(e)) {
|
|
1559
|
+
if (i === "^C" && !n) {
|
|
1528
1560
|
this.kill("SIGINT");
|
|
1529
1561
|
return;
|
|
1530
1562
|
}
|
|
1531
|
-
|
|
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);
|
|
1532
1564
|
}
|
|
1533
1565
|
}
|
|
1534
|
-
},
|
|
1566
|
+
}, l = () => {
|
|
1535
1567
|
this.sandbox && typeof this.sandbox.setTerminalSize == "function" && this.stdinStream && this.sandbox.setTerminalSize(this.stdinStream.columns, this.stdinStream.rows);
|
|
1568
|
+
}, u = () => {
|
|
1569
|
+
this.sandbox && typeof this.sandbox.setTerminalSize == "function" && this.stdout && this.sandbox.setTerminalSize(this.stdout.columns, this.stdout.rows);
|
|
1570
|
+
}, d = () => {
|
|
1571
|
+
this.stdinStream && typeof this.stdinStream.off == "function" && (this.stdinStream.off("data", c), this.stdinStream.off("resize", l)), this.stdout && typeof this.stdout.off == "function" && this.stdout.off("resize", u);
|
|
1536
1572
|
};
|
|
1537
|
-
this.stdinStream && typeof this.stdinStream.on == "function" && (this.stdinStream.on("data",
|
|
1573
|
+
this.stdinStream && typeof this.stdinStream.on == "function" && (this.stdinStream.on("data", c), this.stdinStream.on("resize", l)), this.stdout && this.stdout !== this.stdinStream && typeof this.stdout.on == "function" && this.stdout.on("resize", u), this.sandbox.on("stdOut", (e) => {
|
|
1538
1574
|
this.stdOut = e, this.flush();
|
|
1539
1575
|
}), this.sandbox.on("stdErr", (e) => {
|
|
1540
1576
|
this.stdErr = e, this.flush();
|
|
@@ -1543,19 +1579,19 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
1543
1579
|
}), this.sandbox.stderr && typeof this.sandbox.stderr.on == "function" && this.sandbox.stderr.on("data", (e) => {
|
|
1544
1580
|
this.stderr && typeof this.stderr.write == "function" && this.stderr.write(e);
|
|
1545
1581
|
}), this._scriptFunctions = {};
|
|
1546
|
-
let
|
|
1547
|
-
if (!
|
|
1548
|
-
let e =
|
|
1549
|
-
return
|
|
1582
|
+
let f = this.script.split(/\r?\n/);
|
|
1583
|
+
if (!a(f[0])) {
|
|
1584
|
+
let e = f[0].startsWith("#!") ? f[0].slice(2).split(/\s/)[0] : f[0];
|
|
1585
|
+
return d(), Promise.reject(`${e}: bad interpreter: No such file or directory`);
|
|
1550
1586
|
}
|
|
1551
|
-
let
|
|
1552
|
-
return this._executeNodes(
|
|
1587
|
+
let p = this._parseLines(f.slice(1));
|
|
1588
|
+
return this._executeNodes(p).catch((e) => {
|
|
1553
1589
|
if (e && e.__type === "return") this.sandbox.lastCode = e.code;
|
|
1554
1590
|
else if (e && e.__type === "errexit") this.sandbox.lastCode = e.code;
|
|
1555
1591
|
else if (e && (e.__type === "break" || e.__type === "continue")) this.stdErr = `${e.__type}: only meaningful in a for or while loop`, this.sandbox.lastCode = 1;
|
|
1556
1592
|
else return Promise.reject(e);
|
|
1557
1593
|
}).finally(() => {
|
|
1558
|
-
|
|
1594
|
+
d();
|
|
1559
1595
|
}).then(() => {
|
|
1560
1596
|
this.exitCode = this.sandbox.lastCode, this.source && this.context.source(this.sandbox.context);
|
|
1561
1597
|
});
|
|
@@ -1709,21 +1745,33 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
1709
1745
|
}
|
|
1710
1746
|
_executeNode(e) {
|
|
1711
1747
|
if (e.type === "function") {
|
|
1712
|
-
let t = e.name, n = e.bodyLines, r = this, i =
|
|
1748
|
+
let t = e.name, n = e.bodyLines, r = this, i = ne(), a = class extends i {
|
|
1713
1749
|
static get name() {
|
|
1714
1750
|
return t;
|
|
1715
1751
|
}
|
|
1716
1752
|
run() {
|
|
1717
|
-
let e =
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1753
|
+
let e = parseInt(r.sandbox.context.getVar("#") || "0", 10) || 0, t = Math.max(e, this.arguments.length), i = [];
|
|
1754
|
+
for (let e = 1; e <= t; e++) {
|
|
1755
|
+
let t = String(e);
|
|
1756
|
+
i.push({
|
|
1757
|
+
key: t,
|
|
1758
|
+
prev: r.sandbox.context.getVar(t)
|
|
1759
|
+
}), e <= this.arguments.length ? r.sandbox.context.setVar(t, this.arguments[e - 1]) : r.sandbox.context.unsetVar(t);
|
|
1760
|
+
}
|
|
1761
|
+
for (let e of [
|
|
1762
|
+
"#",
|
|
1763
|
+
"@",
|
|
1764
|
+
"*"
|
|
1765
|
+
]) i.push({
|
|
1766
|
+
key: e,
|
|
1767
|
+
prev: r.sandbox.context.getVar(e)
|
|
1768
|
+
});
|
|
1769
|
+
r.sandbox.context.setVar("#", String(this.arguments.length)), r.sandbox.context.setVar("@", this.arguments.join(" ")), r.sandbox.context.setVar("*", this.arguments.join(" "));
|
|
1770
|
+
let a = () => i.forEach(({ key: e, prev: t }) => t ? r.sandbox.context.setVar(e, t) : r.sandbox.context.unsetVar(e));
|
|
1723
1771
|
return r._executeFunctionBody(n).then(() => {
|
|
1724
|
-
|
|
1772
|
+
a();
|
|
1725
1773
|
}).catch((e) => {
|
|
1726
|
-
if (
|
|
1774
|
+
if (a(), e && e.__type === "return") {
|
|
1727
1775
|
this.exitCode = e.code;
|
|
1728
1776
|
return;
|
|
1729
1777
|
}
|
|
@@ -1913,9 +1961,9 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
1913
1961
|
return !1;
|
|
1914
1962
|
}
|
|
1915
1963
|
}
|
|
1916
|
-
}, t.exports.isKnownInterpreter =
|
|
1917
|
-
})),
|
|
1918
|
-
var n =
|
|
1964
|
+
}, t.exports.isKnownInterpreter = a;
|
|
1965
|
+
})), G = /* @__PURE__ */ t(((e, t) => {
|
|
1966
|
+
var n = W();
|
|
1919
1967
|
t.exports = class extends n {
|
|
1920
1968
|
get captureInput() {
|
|
1921
1969
|
return !0;
|
|
@@ -1924,19 +1972,16 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
1924
1972
|
return !0;
|
|
1925
1973
|
}
|
|
1926
1974
|
get terminalSize() {
|
|
1927
|
-
return
|
|
1928
|
-
cols:
|
|
1929
|
-
rows:
|
|
1930
|
-
} : {
|
|
1931
|
-
cols: parseInt(this.context.getVar("COLUMNS"), 10) || 80,
|
|
1932
|
-
rows: parseInt(this.context.getVar("LINES"), 10) || 24
|
|
1975
|
+
return {
|
|
1976
|
+
cols: this.stdout && this.stdout.columns || this.stdinStream && this.stdinStream.columns || this.context && typeof this.context.getVar == "function" && parseInt(this.context.getVar("COLUMNS"), 10) || 80,
|
|
1977
|
+
rows: this.stdout && this.stdout.rows || this.stdinStream && this.stdinStream.rows || this.context && typeof this.context.getVar == "function" && parseInt(this.context.getVar("LINES"), 10) || 24
|
|
1933
1978
|
};
|
|
1934
1979
|
}
|
|
1935
1980
|
_enterAltScreen() {
|
|
1936
1981
|
this._inAltScreen || (this._inAltScreen = !0, this.stdinStream && this.stdinStream.setRawMode(!0), this.stdout && this.stdout.write("\x1B[?1049h\x1B[2J\x1B[H"));
|
|
1937
1982
|
}
|
|
1938
1983
|
_exitAltScreen() {
|
|
1939
|
-
this._inAltScreen && (this._inAltScreen = !1, this.stdinStream && this.stdinStream.setRawMode(!1), this.stdout && this.stdout.write("\x1B[?1049l\x1B[?25h"));
|
|
1984
|
+
this._inAltScreen && (this._inAltScreen = !1, this.stdinStream && this.stdinStream.setRawMode(!1), this.stdout && this.stdout.write("\x1B[0m\x1B[?1l\x1B[?1000l\x1B[?1002l\x1B[?1003l\x1B[?1006l\x1B[?1049l\x1B[?25h"));
|
|
1940
1985
|
}
|
|
1941
1986
|
kill(e = "SIGINT") {
|
|
1942
1987
|
this._exitAltScreen(), super.kill(e);
|
|
@@ -1947,8 +1992,8 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
1947
1992
|
});
|
|
1948
1993
|
}
|
|
1949
1994
|
};
|
|
1950
|
-
})),
|
|
1951
|
-
var n =
|
|
1995
|
+
})), K = /* @__PURE__ */ t(((e, t) => {
|
|
1996
|
+
var n = G(), { 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 {
|
|
1952
1997
|
get requiresFilesystem() {
|
|
1953
1998
|
return !0;
|
|
1954
1999
|
}
|
|
@@ -2217,7 +2262,7 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
2217
2262
|
return s;
|
|
2218
2263
|
}
|
|
2219
2264
|
f.createReplWasmCommand = p, f.createCommand = p, t.exports = f;
|
|
2220
|
-
})),
|
|
2265
|
+
})), q = /* @__PURE__ */ t(((e, t) => {
|
|
2221
2266
|
b();
|
|
2222
2267
|
function n(e) {
|
|
2223
2268
|
if (!e || e.length === 0) return !0;
|
|
@@ -2235,7 +2280,7 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
2235
2280
|
}
|
|
2236
2281
|
}
|
|
2237
2282
|
t.exports = n, t.exports.isUtf8Text = n;
|
|
2238
|
-
})),
|
|
2283
|
+
})), ie = /* @__PURE__ */ t(((e, t) => {
|
|
2239
2284
|
b();
|
|
2240
2285
|
var r = new Set([
|
|
2241
2286
|
"cwd",
|
|
@@ -2266,7 +2311,7 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
2266
2311
|
if (typeof t == "function") return t;
|
|
2267
2312
|
let r = typeof t == "string" ? t : new TextDecoder().decode(t);
|
|
2268
2313
|
/^\s*export\s+default\s+/m.test(r) && (r = r.replace(/^\s*export\s+default\s+/m, "module.exports = "));
|
|
2269
|
-
let i = { exports: {} }, a =
|
|
2314
|
+
let i = { exports: {} }, a = W(), o = ne(), s = X(), c = G(), l = K();
|
|
2270
2315
|
return Function("module", "exports", "require", "Command", "LocalCommand", "WasmCommand", "InteractiveCommand", "ReplCommand", r)(i, i.exports, n, a, o, s, c, l), i.exports.default === void 0 ? i.exports : i.exports.default;
|
|
2271
2316
|
}
|
|
2272
2317
|
isReadable(e) {
|
|
@@ -2291,12 +2336,13 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
2291
2336
|
return n;
|
|
2292
2337
|
}
|
|
2293
2338
|
sandbox() {
|
|
2294
|
-
let e = this;
|
|
2339
|
+
let e = this, t = Symbol.for("brsh.fs.target");
|
|
2295
2340
|
return new Proxy(Object.create(null), {
|
|
2296
|
-
get(
|
|
2297
|
-
if (
|
|
2298
|
-
|
|
2299
|
-
|
|
2341
|
+
get(n, i) {
|
|
2342
|
+
if (i === t) return e;
|
|
2343
|
+
if (!r.has(i)) return;
|
|
2344
|
+
let a = e[i];
|
|
2345
|
+
return typeof a == "function" ? a.bind(e) : a;
|
|
2300
2346
|
},
|
|
2301
2347
|
set() {
|
|
2302
2348
|
return !1;
|
|
@@ -2341,11 +2387,11 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
2341
2387
|
let e = this.read();
|
|
2342
2388
|
return e == null ? "" : typeof e == "string" ? e : e.toString();
|
|
2343
2389
|
}
|
|
2344
|
-
}, c =
|
|
2390
|
+
}, c = q();
|
|
2345
2391
|
t.exports = i, t.exports.BinaryFile = a, t.exports.SymlinkRef = o, t.exports.DeviceFile = s, t.exports.isUtf8Text = c;
|
|
2346
|
-
})),
|
|
2347
|
-
b(),
|
|
2348
|
-
var { BinaryFile: n, SymlinkRef: r, DeviceFile: i } =
|
|
2392
|
+
})), ae = /* @__PURE__ */ t(((e, t) => {
|
|
2393
|
+
b(), z();
|
|
2394
|
+
var { BinaryFile: n, SymlinkRef: r, DeviceFile: i } = ie(), a = new Uint8Array([
|
|
2349
2395
|
66,
|
|
2350
2396
|
82,
|
|
2351
2397
|
70,
|
|
@@ -2372,7 +2418,7 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
2372
2418
|
r
|
|
2373
2419
|
] };
|
|
2374
2420
|
}
|
|
2375
|
-
if (typeof e == "function") return n.commandsBundle || (d[t] = e.toString()), { $c: t };
|
|
2421
|
+
if (typeof e == "function") return n.commandsBundle || (d[t] = e.__source || e.toString()), { $c: t };
|
|
2376
2422
|
if (typeof e == "string") {
|
|
2377
2423
|
if (e.startsWith("data:")) {
|
|
2378
2424
|
let t = e.indexOf(";"), n = e.indexOf(",", t);
|
|
@@ -2451,7 +2497,7 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
2451
2497
|
let t = e.$c;
|
|
2452
2498
|
if (h[t]) return h[t];
|
|
2453
2499
|
if (p.inlineCommands && p.inlineCommands[t]) try {
|
|
2454
|
-
let e =
|
|
2500
|
+
let e = W(), n = G();
|
|
2455
2501
|
return Function("Command", "InteractiveCommand", `return (${p.inlineCommands[t]});`)(e, n);
|
|
2456
2502
|
} catch {
|
|
2457
2503
|
return null;
|
|
@@ -2483,8 +2529,8 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
2483
2529
|
let t = new DecompressionStream("gzip"), n = new Blob([e]).stream().pipeThrough(t), r = await new Response(n).arrayBuffer();
|
|
2484
2530
|
return new Uint8Array(r);
|
|
2485
2531
|
}
|
|
2486
|
-
if (
|
|
2487
|
-
let t =
|
|
2532
|
+
if (R !== void 0 && typeof R.getBuiltinModule == "function") {
|
|
2533
|
+
let t = R.getBuiltinModule("zlib");
|
|
2488
2534
|
if (t) return new Uint8Array(t.gunzipSync(y.from(e.buffer, e.byteOffset, e.byteLength)));
|
|
2489
2535
|
}
|
|
2490
2536
|
throw Error("Gzip decompression is not supported in this environment");
|
|
@@ -2503,8 +2549,8 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
2503
2549
|
return p(new Uint8Array(n), t);
|
|
2504
2550
|
}
|
|
2505
2551
|
if (typeof e == "string") {
|
|
2506
|
-
if (!/^https?:\/\//i.test(e) &&
|
|
2507
|
-
let n =
|
|
2552
|
+
if (!/^https?:\/\//i.test(e) && R !== void 0 && typeof R.getBuiltinModule == "function" && typeof window > "u") try {
|
|
2553
|
+
let n = R.getBuiltinModule("fs");
|
|
2508
2554
|
if (n && n.existsSync(e)) {
|
|
2509
2555
|
let r = await n.promises.readFile(e);
|
|
2510
2556
|
return p(new Uint8Array(r.buffer, r.byteOffset, r.byteLength), t);
|
|
@@ -2616,9 +2662,9 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
2616
2662
|
}
|
|
2617
2663
|
}
|
|
2618
2664
|
};
|
|
2619
|
-
})),
|
|
2665
|
+
})), J = /* @__PURE__ */ t(((e, t) => {
|
|
2620
2666
|
b();
|
|
2621
|
-
var n =
|
|
2667
|
+
var n = ie(), { BinaryFile: r, SymlinkRef: i, DeviceFile: a } = n;
|
|
2622
2668
|
function o(e) {
|
|
2623
2669
|
for (let t of Object.keys(e)) {
|
|
2624
2670
|
let n = e[t];
|
|
@@ -2642,10 +2688,10 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
2642
2688
|
t.exports = class extends n {
|
|
2643
2689
|
constructor(e = "/", t = {}, n = {}, r = null) {
|
|
2644
2690
|
if (super(), t instanceof Uint8Array || t instanceof ArrayBuffer) {
|
|
2645
|
-
let { deserializeBinaryFilesystem: e } =
|
|
2691
|
+
let { deserializeBinaryFilesystem: e } = ae(), r = e(t);
|
|
2646
2692
|
t = r.filesystem, n = Object.assign({}, r.permissions, n);
|
|
2647
2693
|
} 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)) {
|
|
2648
|
-
let { deserializeBinaryFilesystem: e } =
|
|
2694
|
+
let { deserializeBinaryFilesystem: e } = ae(), r = e(t);
|
|
2649
2695
|
t = r.filesystem, n = Object.assign({}, r.permissions, n);
|
|
2650
2696
|
}
|
|
2651
2697
|
o(t), this.fileSystem = t, this.permissions = Object.assign({}, n), this.cwd = e.endsWith("/") ? e : e + "/", this._onChange = r, this._changeScheduled = !1, this._initDevices();
|
|
@@ -2687,11 +2733,11 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
2687
2733
|
}), this._devices.stdin = new i("/dev/tty"), this._devices.stdout = new i("/dev/tty"), this._devices.stderr = new i("/dev/tty");
|
|
2688
2734
|
}
|
|
2689
2735
|
toBinaryContainer(e = {}) {
|
|
2690
|
-
let { serializeBinaryFilesystem: t } =
|
|
2736
|
+
let { serializeBinaryFilesystem: t } = ae();
|
|
2691
2737
|
return t(this.fileSystem, this.permissions, e);
|
|
2692
2738
|
}
|
|
2693
2739
|
static fromBinaryContainer(e, t = {}) {
|
|
2694
|
-
let { deserializeBinaryFilesystem: n } =
|
|
2740
|
+
let { deserializeBinaryFilesystem: n } = ae();
|
|
2695
2741
|
return n(e, t);
|
|
2696
2742
|
}
|
|
2697
2743
|
getFileByPath(e) {
|
|
@@ -2936,18 +2982,18 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
2936
2982
|
return null;
|
|
2937
2983
|
}
|
|
2938
2984
|
}, t.exports.BinaryFile = r, t.exports.SymlinkRef = i;
|
|
2939
|
-
})),
|
|
2985
|
+
})), Y = /* @__PURE__ */ t(((e, t) => {
|
|
2940
2986
|
t.exports = null;
|
|
2941
|
-
})),
|
|
2987
|
+
})), X = /* @__PURE__ */ t(((e, t) => {
|
|
2942
2988
|
b();
|
|
2943
|
-
var n =
|
|
2989
|
+
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 {
|
|
2944
2990
|
constructor(e, t, n) {
|
|
2945
2991
|
super(e, t, n), this._ensurePkgMeta();
|
|
2946
2992
|
}
|
|
2947
2993
|
_ensurePkgMeta() {
|
|
2948
2994
|
if (this._pkgMeta === void 0 && this.script) {
|
|
2949
2995
|
let e = this.context && this.context.fs || this.fs;
|
|
2950
|
-
e && (this._pkgMeta =
|
|
2996
|
+
e && (this._pkgMeta = I(e, this.script));
|
|
2951
2997
|
}
|
|
2952
2998
|
return this._pkgMeta || null;
|
|
2953
2999
|
}
|
|
@@ -2987,11 +3033,22 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
2987
3033
|
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"));
|
|
2988
3034
|
}
|
|
2989
3035
|
_exitAltScreen() {
|
|
2990
|
-
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[?1049l\x1B[?25h"));
|
|
3036
|
+
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"));
|
|
2991
3037
|
}
|
|
2992
3038
|
_keyToBytes(e) {
|
|
2993
3039
|
if (!e) return null;
|
|
2994
3040
|
if (typeof e != "string") return e instanceof Uint8Array ? e : new Uint8Array([Number(e) & 255]);
|
|
3041
|
+
if ([
|
|
3042
|
+
"Control",
|
|
3043
|
+
"Alt",
|
|
3044
|
+
"Shift",
|
|
3045
|
+
"Meta",
|
|
3046
|
+
"CapsLock",
|
|
3047
|
+
"NumLock",
|
|
3048
|
+
"ScrollLock",
|
|
3049
|
+
"Dead",
|
|
3050
|
+
"Unidentified"
|
|
3051
|
+
].includes(e)) return null;
|
|
2995
3052
|
let t = e.match(/^\^([A-Za-z@\[\\\]^_?])$/);
|
|
2996
3053
|
if (t) {
|
|
2997
3054
|
let e = t[1].toUpperCase();
|
|
@@ -3000,19 +3057,40 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
3000
3057
|
let n = {
|
|
3001
3058
|
Enter: "\r",
|
|
3002
3059
|
Return: "\r",
|
|
3060
|
+
Space: " ",
|
|
3061
|
+
Spacebar: " ",
|
|
3003
3062
|
Backspace: "",
|
|
3004
3063
|
Tab: " ",
|
|
3064
|
+
BackTab: "\x1B[Z",
|
|
3005
3065
|
Escape: "\x1B",
|
|
3066
|
+
Esc: "\x1B",
|
|
3006
3067
|
ArrowUp: "\x1B[A",
|
|
3068
|
+
Up: "\x1B[A",
|
|
3007
3069
|
ArrowDown: "\x1B[B",
|
|
3070
|
+
Down: "\x1B[B",
|
|
3008
3071
|
ArrowRight: "\x1B[C",
|
|
3072
|
+
Right: "\x1B[C",
|
|
3009
3073
|
ArrowLeft: "\x1B[D",
|
|
3074
|
+
Left: "\x1B[D",
|
|
3010
3075
|
Home: "\x1B[H",
|
|
3011
3076
|
End: "\x1B[F",
|
|
3012
3077
|
PageUp: "\x1B[5~",
|
|
3013
3078
|
PageDown: "\x1B[6~",
|
|
3014
3079
|
Delete: "\x1B[3~",
|
|
3015
|
-
|
|
3080
|
+
Del: "\x1B[3~",
|
|
3081
|
+
Insert: "\x1B[2~",
|
|
3082
|
+
F1: "\x1BOP",
|
|
3083
|
+
F2: "\x1BOQ",
|
|
3084
|
+
F3: "\x1BOR",
|
|
3085
|
+
F4: "\x1BOS",
|
|
3086
|
+
F5: "\x1B[15~",
|
|
3087
|
+
F6: "\x1B[17~",
|
|
3088
|
+
F7: "\x1B[18~",
|
|
3089
|
+
F8: "\x1B[19~",
|
|
3090
|
+
F9: "\x1B[20~",
|
|
3091
|
+
F10: "\x1B[21~",
|
|
3092
|
+
F11: "\x1B[23~",
|
|
3093
|
+
F12: "\x1B[24~"
|
|
3016
3094
|
};
|
|
3017
3095
|
return n[e] ? new TextEncoder().encode(n[e]) : new TextEncoder().encode(e);
|
|
3018
3096
|
}
|
|
@@ -3033,7 +3111,7 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
3033
3111
|
run() {
|
|
3034
3112
|
let e = this.script, t = (() => {
|
|
3035
3113
|
try {
|
|
3036
|
-
return
|
|
3114
|
+
return Y();
|
|
3037
3115
|
} catch {
|
|
3038
3116
|
return null;
|
|
3039
3117
|
}
|
|
@@ -3064,7 +3142,7 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
3064
3142
|
isWat: this._isWat(e, i)
|
|
3065
3143
|
});
|
|
3066
3144
|
}
|
|
3067
|
-
return r.then((e) => (!e.isWat && e.bytes && (this._inspectedWasm =
|
|
3145
|
+
return r.then((e) => (!e.isWat && e.bytes && (this._inspectedWasm = M(e.bytes), this._inspectedWasm.isInteractive && (this._isInteractive = !0)), e));
|
|
3068
3146
|
}
|
|
3069
3147
|
_isWat(e, t) {
|
|
3070
3148
|
return e.endsWith(".wat") ? !0 : t.length > 0 && t[0] === 40;
|
|
@@ -3105,12 +3183,12 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
3105
3183
|
let t = {
|
|
3106
3184
|
1: "",
|
|
3107
3185
|
2: ""
|
|
3108
|
-
}, n = new TextDecoder(), b = new TextEncoder(),
|
|
3109
|
-
|
|
3110
|
-
let
|
|
3111
|
-
|
|
3112
|
-
},
|
|
3113
|
-
if (
|
|
3186
|
+
}, 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);
|
|
3187
|
+
V && (this.emit("interactive"), this.context && typeof this.context.emit == "function" && this.context.emit("interactive"));
|
|
3188
|
+
let H = () => {
|
|
3189
|
+
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));
|
|
3190
|
+
}, U = (e, n) => {
|
|
3191
|
+
if (V && (e === 1 || e === 2)) {
|
|
3114
3192
|
if (e === 1 && this.stdout) {
|
|
3115
3193
|
this.stdout.write(n);
|
|
3116
3194
|
return;
|
|
@@ -3124,61 +3202,63 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
3124
3202
|
let r = t[e].split("\n");
|
|
3125
3203
|
t[e] = r.pop();
|
|
3126
3204
|
for (let t of r) e === 1 ? this.stdOut = t : this.stdErr = t;
|
|
3127
|
-
},
|
|
3128
|
-
t[1] &&= (
|
|
3129
|
-
},
|
|
3205
|
+
}, te = () => {
|
|
3206
|
+
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], "");
|
|
3207
|
+
}, W = [], ne = (e) => {
|
|
3130
3208
|
if (!(!e || e.length === 0)) {
|
|
3131
|
-
for (let t = 0; t < e.length; t++)
|
|
3132
|
-
if (
|
|
3133
|
-
let e =
|
|
3134
|
-
|
|
3209
|
+
for (let t = 0; t < e.length; t++) W.push(e[t]);
|
|
3210
|
+
if (j) {
|
|
3211
|
+
let e = j;
|
|
3212
|
+
j = null, e();
|
|
3135
3213
|
}
|
|
3136
3214
|
}
|
|
3137
3215
|
};
|
|
3138
|
-
|
|
3216
|
+
z = (e) => {
|
|
3139
3217
|
this._handlingStreamData = !0;
|
|
3140
3218
|
try {
|
|
3141
|
-
|
|
3219
|
+
ne(typeof e == "string" ? b.encode(e) : e instanceof Uint8Array ? e : y !== void 0 && y.isBuffer(e) ? new Uint8Array(e) : b.encode(String(e ?? "")));
|
|
3142
3220
|
} finally {
|
|
3143
3221
|
this._handlingStreamData = !1;
|
|
3144
3222
|
}
|
|
3145
3223
|
}, this._externalKeyHandler = (e) => {
|
|
3146
3224
|
if (this._handlingStreamData) return;
|
|
3147
3225
|
let t = this._keyToBytes(e);
|
|
3148
|
-
t &&
|
|
3149
|
-
}
|
|
3150
|
-
let
|
|
3226
|
+
t && ne(t);
|
|
3227
|
+
};
|
|
3228
|
+
let re = !!(this._onStdinStreamData && this.stdinStream && typeof this.stdinStream.listeners == "function" && this.stdinStream.listeners("data").includes(this._onStdinStreamData));
|
|
3229
|
+
re && typeof this.stdinStream.off == "function" && this.stdinStream.off("data", this._onStdinStreamData), B && this.stdinStream && typeof this.stdinStream.on == "function" && this.stdinStream.on("data", z), B && this.stdin && this.stdin !== this.stdinStream && typeof this.stdin.on == "function" && this.stdin.on("data", z);
|
|
3230
|
+
let G = !B && typeof this.stdin == "string" ? b.encode(this.stdin) : !B && this.stdin instanceof Uint8Array ? this.stdin : !B && y !== void 0 && y.isBuffer(this.stdin) ? new Uint8Array(this.stdin) : new Uint8Array(), K = 0, q = this.context && this.context.fs ? this.context.fs : this.fs, ie = this.context && this.context.fs && this.context.fs.cwd || this.fs && this.fs.cwd || this.context && typeof this.context.getVar == "function" && this.context.getVar("PWD") || q && q.cwd || "/", ae = ie.length > 1 && ie.endsWith("/") ? ie.slice(0, -1) : ie, J = 5, Y = new Map([[3, {
|
|
3151
3231
|
type: "preopen",
|
|
3152
3232
|
path: "/",
|
|
3153
3233
|
guestName: "/"
|
|
3154
3234
|
}], [4, {
|
|
3155
3235
|
type: "preopen",
|
|
3156
|
-
path:
|
|
3236
|
+
path: ae,
|
|
3157
3237
|
guestName: "."
|
|
3158
|
-
}]]),
|
|
3238
|
+
}]]), X = new Map([
|
|
3159
3239
|
[0, 0],
|
|
3160
3240
|
[1, 0],
|
|
3161
3241
|
[2, 0]
|
|
3162
|
-
]),
|
|
3242
|
+
]), oe = (e) => {
|
|
3163
3243
|
let t = e.split("/").filter(Boolean);
|
|
3164
3244
|
return t.pop(), "/" + t.join("/");
|
|
3165
|
-
},
|
|
3166
|
-
let n =
|
|
3245
|
+
}, Z = (e, t) => {
|
|
3246
|
+
let n = Y.get(e);
|
|
3167
3247
|
if (!n || n.type !== "preopen" && n.type !== "dir") return null;
|
|
3168
|
-
if (t.startsWith("/")) return
|
|
3169
|
-
if (!t || t === ".") return
|
|
3170
|
-
let r = n.path.endsWith("/") ? n.path : n.path + "/", i =
|
|
3248
|
+
if (t.startsWith("/")) return q.absolutePath(t);
|
|
3249
|
+
if (!t || t === ".") return q.absolutePath(n.path);
|
|
3250
|
+
let r = n.path.endsWith("/") ? n.path : n.path + "/", i = q.absolutePath(r + t), a = q.absolutePath("/" + t);
|
|
3171
3251
|
if (n.path !== "/") {
|
|
3172
|
-
if (
|
|
3173
|
-
if (
|
|
3174
|
-
let e =
|
|
3175
|
-
return
|
|
3252
|
+
if (q.exists(i)) return i;
|
|
3253
|
+
if (q.exists(a)) return a;
|
|
3254
|
+
let e = q.exists(oe(i));
|
|
3255
|
+
return q.exists(oe(a)) && !e ? a : i;
|
|
3176
3256
|
}
|
|
3177
|
-
if (
|
|
3178
|
-
let o =
|
|
3179
|
-
return
|
|
3180
|
-
},
|
|
3181
|
-
if (!(!e || e.type !== "file" || !e.dirty || !
|
|
3257
|
+
if (q.exists(i)) return i;
|
|
3258
|
+
let o = q.absolutePath(t);
|
|
3259
|
+
return q.exists(o) ? o : i;
|
|
3260
|
+
}, se = (e) => {
|
|
3261
|
+
if (!(!e || e.type !== "file" || !e.dirty || !q)) try {
|
|
3182
3262
|
let t = !0;
|
|
3183
3263
|
for (let n = 0; n < e.bytes.length; n++) if (e.bytes[n] === 0) {
|
|
3184
3264
|
t = !1;
|
|
@@ -3186,32 +3266,32 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
3186
3266
|
}
|
|
3187
3267
|
if (t) {
|
|
3188
3268
|
let t = n.decode(e.bytes);
|
|
3189
|
-
|
|
3269
|
+
q.setFileByPath(e.path, t, !0);
|
|
3190
3270
|
} else {
|
|
3191
3271
|
let t = new Uint8Array(e.bytes.length);
|
|
3192
|
-
t.set(e.bytes),
|
|
3272
|
+
t.set(e.bytes), q.setFileByPath(e.path, new r(t.buffer, "application/octet-stream"), !0);
|
|
3193
3273
|
}
|
|
3194
3274
|
e.dirty = !1;
|
|
3195
3275
|
} catch {}
|
|
3196
|
-
},
|
|
3276
|
+
}, ce = this.stdout && this.stdout.columns || this.stdinStream && this.stdinStream.columns || this.context && typeof this.context.getVar == "function" && parseInt(this.context.getVar("COLUMNS"), 10) || 80, le = this.stdout && this.stdout.rows || this.stdinStream && this.stdinStream.rows || this.context && typeof this.context.getVar == "function" && parseInt(this.context.getVar("LINES"), 10) || 24, ue = {
|
|
3197
3277
|
TERM: "xterm-256color",
|
|
3198
3278
|
COLORTERM: "truecolor",
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
},
|
|
3279
|
+
...this.context && this.context.vars || {},
|
|
3280
|
+
COLUMNS: String(ce),
|
|
3281
|
+
LINES: String(le)
|
|
3282
|
+
}, Q = Object.entries(ue).map(([e, t]) => `${e}=${t}`), de = new Proxy({
|
|
3203
3283
|
fd_write: (e, t, r, a) => {
|
|
3204
|
-
if (!
|
|
3205
|
-
let s = new DataView(
|
|
3284
|
+
if (!E) return o;
|
|
3285
|
+
let s = new DataView(E.buffer);
|
|
3206
3286
|
if (e === 1 || e === 2) {
|
|
3207
3287
|
let o = 0;
|
|
3208
3288
|
for (let i = 0; i < r; i++) {
|
|
3209
3289
|
let r = s.getUint32(t + i * 8, !0), a = s.getUint32(t + i * 8 + 4, !0);
|
|
3210
|
-
a > 0 &&
|
|
3290
|
+
a > 0 && U(e, n.decode(new Uint8Array(E.buffer, r, a))), o += a;
|
|
3211
3291
|
}
|
|
3212
3292
|
return s.setUint32(a, o, !0), i;
|
|
3213
3293
|
}
|
|
3214
|
-
let c =
|
|
3294
|
+
let c = Y.get(e);
|
|
3215
3295
|
if (!c) return o;
|
|
3216
3296
|
if (c.type === "dev_null" || c.type === "dev_zero") {
|
|
3217
3297
|
let e = 0;
|
|
@@ -3222,7 +3302,7 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
3222
3302
|
let e = 0;
|
|
3223
3303
|
for (let i = 0; i < r; i++) {
|
|
3224
3304
|
let r = s.getUint32(t + i * 8, !0), a = s.getUint32(t + i * 8 + 4, !0);
|
|
3225
|
-
a > 0 &&
|
|
3305
|
+
a > 0 && U(1, n.decode(new Uint8Array(E.buffer, r, a))), e += a;
|
|
3226
3306
|
}
|
|
3227
3307
|
return s.setUint32(a, e, !0), i;
|
|
3228
3308
|
}
|
|
@@ -3231,7 +3311,7 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
3231
3311
|
for (let e = 0; e < r; e++) {
|
|
3232
3312
|
let n = s.getUint32(t + e * 8, !0), r = s.getUint32(t + e * 8 + 4, !0);
|
|
3233
3313
|
if (r > 0) {
|
|
3234
|
-
let e = new Uint8Array(
|
|
3314
|
+
let e = new Uint8Array(E.buffer, n, r), t = c.append ? c.bytes.length : c.pos, i = t + r;
|
|
3235
3315
|
if (i > c.bytes.length) {
|
|
3236
3316
|
let e = new Uint8Array(i);
|
|
3237
3317
|
e.set(c.bytes), c.bytes = e;
|
|
@@ -3242,276 +3322,282 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
3242
3322
|
return s.setUint32(a, l, !0), i;
|
|
3243
3323
|
},
|
|
3244
3324
|
fd_read: (e, t, n, r) => {
|
|
3245
|
-
if (!
|
|
3246
|
-
let s = new DataView(
|
|
3247
|
-
if (e === 0 ||
|
|
3248
|
-
(
|
|
3249
|
-
let o = !!((
|
|
3250
|
-
if (
|
|
3251
|
-
if ((typeof
|
|
3252
|
-
|
|
3325
|
+
if (!E) return o;
|
|
3326
|
+
let s = new DataView(E.buffer), l = Y.get(e), u = !!(l && l.type === "dev_tty");
|
|
3327
|
+
if (e === 0 || V && e === 2 || u) {
|
|
3328
|
+
(u || e === 2) && H();
|
|
3329
|
+
let o = !!((X.get(e) || 0) & T);
|
|
3330
|
+
if (O) {
|
|
3331
|
+
if ((typeof D?.exports?.asyncify_get_state == "function" ? D.exports.asyncify_get_state() : 0) === 2) {
|
|
3332
|
+
if (D.exports.asyncify_stop_rewind(), L && W.length === 0) return L = !1, s.setUint32(r, 0, !0), c;
|
|
3333
|
+
L = !1;
|
|
3253
3334
|
let e = 0;
|
|
3254
|
-
for (let r = 0; r < n &&
|
|
3255
|
-
let n = s.getUint32(t + r * 8, !0), i = s.getUint32(t + r * 8 + 4, !0), a = Math.min(i,
|
|
3256
|
-
new Uint8Array(
|
|
3335
|
+
for (let r = 0; r < n && W.length > 0; r++) {
|
|
3336
|
+
let n = s.getUint32(t + r * 8, !0), i = s.getUint32(t + r * 8 + 4, !0), a = Math.min(i, W.length), o = W.splice(0, a);
|
|
3337
|
+
new Uint8Array(E.buffer).set(o, n), e += a;
|
|
3257
3338
|
}
|
|
3258
3339
|
return s.setUint32(r, e, !0), i;
|
|
3259
3340
|
}
|
|
3260
|
-
if (
|
|
3341
|
+
if (W.length > 0) {
|
|
3261
3342
|
let e = 0;
|
|
3262
|
-
for (let r = 0; r < n &&
|
|
3263
|
-
let n = s.getUint32(t + r * 8, !0), i = s.getUint32(t + r * 8 + 4, !0), a = Math.min(i,
|
|
3264
|
-
new Uint8Array(
|
|
3343
|
+
for (let r = 0; r < n && W.length > 0; r++) {
|
|
3344
|
+
let n = s.getUint32(t + r * 8, !0), i = s.getUint32(t + r * 8 + 4, !0), a = Math.min(i, W.length), o = W.splice(0, a);
|
|
3345
|
+
new Uint8Array(E.buffer).set(o, n), e += a;
|
|
3265
3346
|
}
|
|
3266
3347
|
return s.setUint32(r, e, !0), i;
|
|
3267
3348
|
}
|
|
3268
|
-
return o ? (s.setUint32(r, 0, !0), a) : (
|
|
3269
|
-
|
|
3349
|
+
return o ? (s.setUint32(r, 0, !0), a) : (L = !1, D.exports.asyncify_start_unwind(k), A = new Promise((e, t) => {
|
|
3350
|
+
let n = () => {
|
|
3351
|
+
L = !1, j = null, P = null, this._pendingReadResolve = null, this._asyncifyReject = null, e();
|
|
3352
|
+
};
|
|
3353
|
+
j = n, this._pendingReadResolve = n, P = () => {
|
|
3354
|
+
L = !0, j = null, P = null, this._pendingReadResolve = null, this._asyncifyReject = null, e();
|
|
3355
|
+
}, this._asyncifyReject = t;
|
|
3270
3356
|
}), s.setUint32(r, 0, !0), i);
|
|
3271
3357
|
}
|
|
3272
|
-
if (
|
|
3358
|
+
if (W.length > 0) {
|
|
3273
3359
|
let e = 0;
|
|
3274
|
-
for (let r = 0; r < n &&
|
|
3275
|
-
let n = s.getUint32(t + r * 8, !0), i = s.getUint32(t + r * 8 + 4, !0), a = Math.min(i,
|
|
3276
|
-
new Uint8Array(
|
|
3360
|
+
for (let r = 0; r < n && W.length > 0; r++) {
|
|
3361
|
+
let n = s.getUint32(t + r * 8, !0), i = s.getUint32(t + r * 8 + 4, !0), a = Math.min(i, W.length), o = W.splice(0, a);
|
|
3362
|
+
new Uint8Array(E.buffer).set(o, n), e += a;
|
|
3277
3363
|
}
|
|
3278
3364
|
return s.setUint32(r, e, !0), i;
|
|
3279
3365
|
}
|
|
3280
|
-
let
|
|
3281
|
-
for (let e = 0; e < n &&
|
|
3282
|
-
let n = s.getUint32(t + e * 8, !0), r = s.getUint32(t + e * 8 + 4, !0), i = Math.min(r,
|
|
3283
|
-
new Uint8Array(
|
|
3366
|
+
let l = 0;
|
|
3367
|
+
for (let e = 0; e < n && K < G.length; e++) {
|
|
3368
|
+
let n = s.getUint32(t + e * 8, !0), r = s.getUint32(t + e * 8 + 4, !0), i = Math.min(r, G.length - K);
|
|
3369
|
+
new Uint8Array(E.buffer).set(G.slice(K, K + i), n), K += i, l += i;
|
|
3284
3370
|
}
|
|
3285
|
-
return
|
|
3371
|
+
return l === 0 && o && K >= G.length ? (s.setUint32(r, 0, !0), a) : (s.setUint32(r, l, !0), i);
|
|
3286
3372
|
}
|
|
3287
|
-
if (!
|
|
3288
|
-
if (
|
|
3289
|
-
if (
|
|
3373
|
+
if (!l) return o;
|
|
3374
|
+
if (l.type === "dev_null") return s.setUint32(r, 0, !0), i;
|
|
3375
|
+
if (l.type === "dev_zero") {
|
|
3290
3376
|
let e = 0;
|
|
3291
3377
|
for (let r = 0; r < n; r++) {
|
|
3292
3378
|
let n = s.getUint32(t + r * 8, !0), i = s.getUint32(t + r * 8 + 4, !0);
|
|
3293
|
-
new Uint8Array(
|
|
3379
|
+
new Uint8Array(E.buffer, n, i).fill(0), e += i;
|
|
3294
3380
|
}
|
|
3295
3381
|
return s.setUint32(r, e, !0), i;
|
|
3296
3382
|
}
|
|
3297
|
-
if (
|
|
3383
|
+
if (l.type === "dev_urandom") {
|
|
3298
3384
|
let e = 0;
|
|
3299
3385
|
for (let r = 0; r < n; r++) {
|
|
3300
|
-
let n = s.getUint32(t + r * 8, !0), i = s.getUint32(t + r * 8 + 4, !0), a = new Uint8Array(
|
|
3386
|
+
let n = s.getUint32(t + r * 8, !0), i = s.getUint32(t + r * 8 + 4, !0), a = new Uint8Array(E.buffer, n, i);
|
|
3301
3387
|
if (typeof crypto < "u" && crypto.getRandomValues) crypto.getRandomValues(a);
|
|
3302
3388
|
else for (let e = 0; e < i; e++) a[e] = Math.floor(Math.random() * 256);
|
|
3303
3389
|
e += i;
|
|
3304
3390
|
}
|
|
3305
3391
|
return s.setUint32(r, e, !0), i;
|
|
3306
3392
|
}
|
|
3307
|
-
if (
|
|
3308
|
-
let
|
|
3309
|
-
for (let e = 0; e < n &&
|
|
3310
|
-
let n = s.getUint32(t + e * 8, !0), r = s.getUint32(t + e * 8 + 4, !0), i = Math.min(r,
|
|
3311
|
-
new Uint8Array(
|
|
3393
|
+
if (l.type !== "file") return o;
|
|
3394
|
+
let d = 0;
|
|
3395
|
+
for (let e = 0; e < n && l.pos < l.bytes.length; e++) {
|
|
3396
|
+
let n = s.getUint32(t + e * 8, !0), r = s.getUint32(t + e * 8 + 4, !0), i = Math.min(r, l.bytes.length - l.pos);
|
|
3397
|
+
new Uint8Array(E.buffer).set(l.bytes.subarray(l.pos, l.pos + i), n), l.pos += i, d += i;
|
|
3312
3398
|
}
|
|
3313
|
-
return s.setUint32(r,
|
|
3399
|
+
return s.setUint32(r, d, !0), i;
|
|
3314
3400
|
},
|
|
3315
3401
|
fd_seek: (e, t, n, r, a) => {
|
|
3316
|
-
if (!
|
|
3317
|
-
if (e <= 2) return
|
|
3318
|
-
let s =
|
|
3402
|
+
if (!E) return o;
|
|
3403
|
+
if (e <= 2) return p;
|
|
3404
|
+
let s = Y.get(e);
|
|
3319
3405
|
if (!s) return o;
|
|
3320
|
-
if (s.type === "dev_tty" || s.type === "dev_null" || s.type === "dev_zero" || s.type === "dev_urandom") return
|
|
3406
|
+
if (s.type === "dev_tty" || s.type === "dev_null" || s.type === "dev_zero" || s.type === "dev_urandom") return p;
|
|
3321
3407
|
if (s.type !== "file") return o;
|
|
3322
|
-
let
|
|
3323
|
-
typeof t == "bigint" ? (
|
|
3324
|
-
let
|
|
3325
|
-
if (u === 0)
|
|
3326
|
-
else if (u === 1)
|
|
3327
|
-
else if (u === 2)
|
|
3328
|
-
else return
|
|
3329
|
-
return
|
|
3408
|
+
let c, u, d;
|
|
3409
|
+
typeof t == "bigint" ? (c = Number(t), u = n, d = r) : (c = t, u = r, d = a);
|
|
3410
|
+
let f = s.pos;
|
|
3411
|
+
if (u === 0) f = c;
|
|
3412
|
+
else if (u === 1) f = s.pos + c;
|
|
3413
|
+
else if (u === 2) f = s.bytes.length + c;
|
|
3414
|
+
else return l;
|
|
3415
|
+
return f < 0 ? l : (s.pos = f, d && new DataView(E.buffer).setBigUint64(d, BigInt(s.pos), !0), i);
|
|
3330
3416
|
},
|
|
3331
3417
|
fd_tell: (e, t) => {
|
|
3332
|
-
if (!
|
|
3333
|
-
let n =
|
|
3334
|
-
return !n || n.type !== "file" ? o : (new DataView(
|
|
3418
|
+
if (!E) return o;
|
|
3419
|
+
let n = Y.get(e);
|
|
3420
|
+
return !n || n.type !== "file" ? o : (new DataView(E.buffer).setBigUint64(t, BigInt(n.pos), !0), i);
|
|
3335
3421
|
},
|
|
3336
3422
|
fd_close: (e) => {
|
|
3337
3423
|
if (e <= 2) return i;
|
|
3338
|
-
let t =
|
|
3339
|
-
return t ? (t.type === "file" &&
|
|
3424
|
+
let t = Y.get(e);
|
|
3425
|
+
return t ? (t.type === "file" && se(t), Y.delete(e), X.delete(e), i) : o;
|
|
3340
3426
|
},
|
|
3341
3427
|
fd_sync: (e) => {
|
|
3342
|
-
let t =
|
|
3343
|
-
return t &&
|
|
3428
|
+
let t = Y.get(e);
|
|
3429
|
+
return t && se(t), i;
|
|
3344
3430
|
},
|
|
3345
3431
|
fd_datasync: (e) => {
|
|
3346
|
-
let t =
|
|
3347
|
-
return t &&
|
|
3432
|
+
let t = Y.get(e);
|
|
3433
|
+
return t && se(t), i;
|
|
3348
3434
|
},
|
|
3349
3435
|
fd_prestat_get: (e, t) => {
|
|
3350
|
-
if (!
|
|
3351
|
-
let n =
|
|
3436
|
+
if (!E) return o;
|
|
3437
|
+
let n = Y.get(e);
|
|
3352
3438
|
if (!n || n.type !== "preopen") return o;
|
|
3353
|
-
let r = new DataView(
|
|
3439
|
+
let r = new DataView(E.buffer), a = b.encode(n.guestName);
|
|
3354
3440
|
return r.setUint8(t, 0), r.setUint32(t + 4, a.length, !0), i;
|
|
3355
3441
|
},
|
|
3356
3442
|
fd_prestat_dir_name: (e, t, n) => {
|
|
3357
|
-
if (!
|
|
3358
|
-
let r =
|
|
3443
|
+
if (!E) return o;
|
|
3444
|
+
let r = Y.get(e);
|
|
3359
3445
|
if (!r || r.type !== "preopen") return o;
|
|
3360
3446
|
let a = b.encode(r.guestName);
|
|
3361
|
-
return new Uint8Array(
|
|
3447
|
+
return new Uint8Array(E.buffer, t, Math.min(n, a.length)).set(a.subarray(0, n)), i;
|
|
3362
3448
|
},
|
|
3363
3449
|
fd_fdstat_get: (e, t) => {
|
|
3364
|
-
if (!
|
|
3365
|
-
let n = new DataView(
|
|
3366
|
-
if (e <= 2) r =
|
|
3450
|
+
if (!E) return o;
|
|
3451
|
+
let n = new DataView(E.buffer), r = m;
|
|
3452
|
+
if (e <= 2) r = h;
|
|
3367
3453
|
else {
|
|
3368
|
-
let t =
|
|
3454
|
+
let t = Y.get(e);
|
|
3369
3455
|
if (!t) return o;
|
|
3370
|
-
r = t.type === "dev_null" || t.type === "dev_zero" || t.type === "dev_urandom" || t.type === "dev_tty" ?
|
|
3456
|
+
r = t.type === "dev_null" || t.type === "dev_zero" || t.type === "dev_urandom" || t.type === "dev_tty" ? h : t.type === "preopen" || t.type === "dir" ? g : _;
|
|
3371
3457
|
}
|
|
3372
3458
|
for (let e = 0; e < 24; e++) n.setUint8(t + e, 0);
|
|
3373
3459
|
n.setUint8(t, r);
|
|
3374
|
-
let a =
|
|
3460
|
+
let a = X.get(e) || (Y.get(e)?.append ? w : 0);
|
|
3375
3461
|
return n.setUint16(t + 2, a, !0), n.setBigUint64(t + 8, 18446744073709551615n, !0), n.setBigUint64(t + 16, 18446744073709551615n, !0), i;
|
|
3376
3462
|
},
|
|
3377
3463
|
fd_fdstat_set_flags: (e, t) => {
|
|
3378
|
-
if (!
|
|
3379
|
-
|
|
3380
|
-
let n =
|
|
3381
|
-
return n && (n.append = !!(t &
|
|
3464
|
+
if (!E || e > 2 && !Y.has(e)) return o;
|
|
3465
|
+
X.set(e, t);
|
|
3466
|
+
let n = Y.get(e);
|
|
3467
|
+
return n && (n.append = !!(t & w)), (e === 0 || e === 2 || n && n.type === "dev_tty") && t & T && H(), i;
|
|
3382
3468
|
},
|
|
3383
3469
|
fd_filestat_get: (e, t) => {
|
|
3384
|
-
if (!
|
|
3385
|
-
let n = new DataView(
|
|
3470
|
+
if (!E) return o;
|
|
3471
|
+
let n = new DataView(E.buffer);
|
|
3386
3472
|
for (let e = 0; e < 64; e++) n.setUint8(t + e, 0);
|
|
3387
|
-
if (e <= 2) return n.setUint8(t + 16,
|
|
3388
|
-
let r =
|
|
3473
|
+
if (e <= 2) return n.setUint8(t + 16, h), i;
|
|
3474
|
+
let r = Y.get(e);
|
|
3389
3475
|
if (!r) return o;
|
|
3390
|
-
if (r.type === "dev_null" || r.type === "dev_zero" || r.type === "dev_urandom" || r.type === "dev_tty") return n.setUint8(t + 16,
|
|
3476
|
+
if (r.type === "dev_null" || r.type === "dev_zero" || r.type === "dev_urandom" || r.type === "dev_tty") return n.setUint8(t + 16, h), n.setBigUint64(t + 24, 1n, !0), i;
|
|
3391
3477
|
let a = r.type === "preopen" || r.type === "dir";
|
|
3392
|
-
return n.setUint8(t + 16, a ?
|
|
3478
|
+
return n.setUint8(t + 16, a ? g : _), n.setBigUint64(t + 24, 1n, !0), n.setBigUint64(t + 32, BigInt(r.bytes ? r.bytes.length : 0), !0), i;
|
|
3393
3479
|
},
|
|
3394
|
-
path_open: (e, t, r, a, c,
|
|
3395
|
-
if (!
|
|
3396
|
-
let g =
|
|
3480
|
+
path_open: (e, t, r, a, c, l, p, m, h) => {
|
|
3481
|
+
if (!E || !q) return o;
|
|
3482
|
+
let g = Z(e, n.decode(new Uint8Array(E.buffer, r, a)));
|
|
3397
3483
|
if (!g) return o;
|
|
3398
|
-
let
|
|
3399
|
-
if (
|
|
3400
|
-
let e =
|
|
3401
|
-
return
|
|
3484
|
+
let _ = g.replace(/\/+/g, "/").replace(/\/$/, "") || "/";
|
|
3485
|
+
if (_ === "/dev/null") {
|
|
3486
|
+
let e = J++;
|
|
3487
|
+
return Y.set(e, {
|
|
3402
3488
|
type: "dev_null",
|
|
3403
3489
|
path: "/dev/null"
|
|
3404
|
-
}), new DataView(
|
|
3490
|
+
}), new DataView(E.buffer).setUint32(h, e, !0), i;
|
|
3405
3491
|
}
|
|
3406
|
-
if (
|
|
3407
|
-
let e =
|
|
3408
|
-
return
|
|
3492
|
+
if (_ === "/dev/zero") {
|
|
3493
|
+
let e = J++;
|
|
3494
|
+
return Y.set(e, {
|
|
3409
3495
|
type: "dev_zero",
|
|
3410
3496
|
path: "/dev/zero"
|
|
3411
|
-
}), new DataView(
|
|
3497
|
+
}), new DataView(E.buffer).setUint32(h, e, !0), i;
|
|
3412
3498
|
}
|
|
3413
|
-
if (
|
|
3414
|
-
let e =
|
|
3415
|
-
return
|
|
3499
|
+
if (_ === "/dev/urandom" || _ === "/dev/random") {
|
|
3500
|
+
let e = J++;
|
|
3501
|
+
return Y.set(e, {
|
|
3416
3502
|
type: "dev_urandom",
|
|
3417
|
-
path:
|
|
3418
|
-
}), new DataView(
|
|
3503
|
+
path: _
|
|
3504
|
+
}), new DataView(E.buffer).setUint32(h, e, !0), i;
|
|
3419
3505
|
}
|
|
3420
|
-
if (
|
|
3421
|
-
|
|
3422
|
-
let e =
|
|
3423
|
-
return
|
|
3506
|
+
if (_ === "/dev/tty" || _ === "/dev/stdin") {
|
|
3507
|
+
H();
|
|
3508
|
+
let e = J++;
|
|
3509
|
+
return Y.set(e, {
|
|
3424
3510
|
type: "dev_tty",
|
|
3425
|
-
path:
|
|
3426
|
-
}), new DataView(
|
|
3511
|
+
path: _
|
|
3512
|
+
}), new DataView(E.buffer).setUint32(h, e, !0), i;
|
|
3427
3513
|
}
|
|
3428
|
-
if (
|
|
3429
|
-
if (
|
|
3430
|
-
let
|
|
3431
|
-
if (c &
|
|
3432
|
-
if (c &
|
|
3433
|
-
if (!
|
|
3434
|
-
if (!
|
|
3435
|
-
let e =
|
|
3436
|
-
return
|
|
3514
|
+
if (_ === "/dev/stdout") return new DataView(E.buffer).setUint32(h, 1, !0), i;
|
|
3515
|
+
if (_ === "/dev/stderr") return new DataView(E.buffer).setUint32(h, 2, !0), i;
|
|
3516
|
+
let y = q.stat(g), T = y !== null;
|
|
3517
|
+
if (c & S && c & v && T) return s;
|
|
3518
|
+
if (c & x) {
|
|
3519
|
+
if (!T) return d;
|
|
3520
|
+
if (!y.isDirectory) return f;
|
|
3521
|
+
let e = J++;
|
|
3522
|
+
return Y.set(e, {
|
|
3437
3523
|
type: "dir",
|
|
3438
3524
|
path: g
|
|
3439
|
-
}), new DataView(
|
|
3525
|
+
}), new DataView(E.buffer).setUint32(h, e, !0), i;
|
|
3440
3526
|
}
|
|
3441
|
-
if (
|
|
3442
|
-
if (!
|
|
3527
|
+
if (T && y.isDirectory) return u;
|
|
3528
|
+
if (!T && !(c & v)) return d;
|
|
3443
3529
|
let D = new Uint8Array(), O = !1;
|
|
3444
|
-
if (
|
|
3445
|
-
let e =
|
|
3530
|
+
if (T && !(c & C)) {
|
|
3531
|
+
let e = q.getFileByPath(g);
|
|
3446
3532
|
e != null && (D = typeof e == "string" ? b.encode(e) : new Uint8Array(this._contentToBytes(e)));
|
|
3447
3533
|
} else O = !0;
|
|
3448
|
-
let k =
|
|
3449
|
-
return
|
|
3534
|
+
let k = J++;
|
|
3535
|
+
return Y.set(k, {
|
|
3450
3536
|
type: "file",
|
|
3451
3537
|
path: g,
|
|
3452
3538
|
bytes: D,
|
|
3453
|
-
pos: m &
|
|
3454
|
-
append: !!(m &
|
|
3539
|
+
pos: m & w ? D.length : 0,
|
|
3540
|
+
append: !!(m & w),
|
|
3455
3541
|
dirty: O
|
|
3456
|
-
}), new DataView(
|
|
3542
|
+
}), new DataView(E.buffer).setUint32(h, k, !0), i;
|
|
3457
3543
|
},
|
|
3458
3544
|
path_filestat_get: (e, t, r, a, s) => {
|
|
3459
|
-
if (!
|
|
3460
|
-
let c =
|
|
3545
|
+
if (!E || !q) return o;
|
|
3546
|
+
let c = Z(e, n.decode(new Uint8Array(E.buffer, r, a)));
|
|
3461
3547
|
if (!c) return o;
|
|
3462
|
-
let l = c.replace(/\/+/g, "/").replace(/\/$/, "") || "/",
|
|
3463
|
-
if (l === "/dev/null" || l === "/dev/zero" || l === "/dev/urandom" || l === "/dev/random" || l === "/dev/tty" || l === "/dev/stdin" || l === "/dev/stdout" || l === "/dev/stderr" ||
|
|
3464
|
-
let e = new DataView(
|
|
3548
|
+
let l = c.replace(/\/+/g, "/").replace(/\/$/, "") || "/", u = q.stat(c);
|
|
3549
|
+
if (l === "/dev/null" || l === "/dev/zero" || l === "/dev/urandom" || l === "/dev/random" || l === "/dev/tty" || l === "/dev/stdin" || l === "/dev/stdout" || l === "/dev/stderr" || u && (u.isDevice || u.isCharacterDevice)) {
|
|
3550
|
+
let e = new DataView(E.buffer);
|
|
3465
3551
|
for (let t = 0; t < 64; t++) e.setUint8(s + t, 0);
|
|
3466
|
-
return e.setUint8(s + 16,
|
|
3552
|
+
return e.setUint8(s + 16, h), e.setBigUint64(s + 24, 1n, !0), i;
|
|
3467
3553
|
}
|
|
3468
|
-
if (!
|
|
3469
|
-
let f = new DataView(
|
|
3554
|
+
if (!u) return d;
|
|
3555
|
+
let f = new DataView(E.buffer);
|
|
3470
3556
|
for (let e = 0; e < 64; e++) f.setUint8(s + e, 0);
|
|
3471
|
-
return f.setUint8(s + 16,
|
|
3557
|
+
return f.setUint8(s + 16, u.isDirectory ? g : _), f.setBigUint64(s + 24, 1n, !0), f.setBigUint64(s + 32, BigInt(q.getSize(c) || 0), !0), i;
|
|
3472
3558
|
},
|
|
3473
3559
|
path_create_directory: (e, t, r) => {
|
|
3474
|
-
if (!
|
|
3475
|
-
let a =
|
|
3560
|
+
if (!E || !q) return o;
|
|
3561
|
+
let a = Z(e, n.decode(new Uint8Array(E.buffer, t, r)));
|
|
3476
3562
|
if (!a) return o;
|
|
3477
|
-
if (
|
|
3563
|
+
if (q.exists(a)) return s;
|
|
3478
3564
|
try {
|
|
3479
|
-
return
|
|
3565
|
+
return q.setFileByPath(a, {}, !0), i;
|
|
3480
3566
|
} catch {
|
|
3481
|
-
return
|
|
3567
|
+
return l;
|
|
3482
3568
|
}
|
|
3483
3569
|
},
|
|
3484
3570
|
path_unlink_file: (e, t, r) => {
|
|
3485
|
-
if (!
|
|
3486
|
-
let a =
|
|
3487
|
-
if (!a || !
|
|
3571
|
+
if (!E || !q) return o;
|
|
3572
|
+
let a = Z(e, n.decode(new Uint8Array(E.buffer, t, r)));
|
|
3573
|
+
if (!a || !q.exists(a)) return d;
|
|
3488
3574
|
try {
|
|
3489
|
-
return
|
|
3575
|
+
return q.deleteFileByPath(a), i;
|
|
3490
3576
|
} catch {
|
|
3491
|
-
return
|
|
3577
|
+
return l;
|
|
3492
3578
|
}
|
|
3493
3579
|
},
|
|
3494
3580
|
path_remove_directory: (e, t, r) => {
|
|
3495
|
-
if (!
|
|
3496
|
-
let a =
|
|
3497
|
-
if (!a || !
|
|
3581
|
+
if (!E || !q) return o;
|
|
3582
|
+
let a = Z(e, n.decode(new Uint8Array(E.buffer, t, r)));
|
|
3583
|
+
if (!a || !q.exists(a)) return d;
|
|
3498
3584
|
try {
|
|
3499
|
-
return
|
|
3585
|
+
return q.deleteFileByPath(a), i;
|
|
3500
3586
|
} catch {
|
|
3501
|
-
return
|
|
3587
|
+
return l;
|
|
3502
3588
|
}
|
|
3503
3589
|
},
|
|
3504
|
-
path_rename: (e, t, r, a, s,
|
|
3505
|
-
if (!
|
|
3506
|
-
let
|
|
3590
|
+
path_rename: (e, t, r, a, s, c) => {
|
|
3591
|
+
if (!E || !q) return o;
|
|
3592
|
+
let u = n.decode(new Uint8Array(E.buffer, t, r)), f = n.decode(new Uint8Array(E.buffer, s, c)), p = Z(e, u), m = Z(a, f);
|
|
3507
3593
|
if (!p || !m) return o;
|
|
3508
|
-
if (!
|
|
3509
|
-
for (let e of
|
|
3594
|
+
if (!q.exists(p)) return d;
|
|
3595
|
+
for (let e of Y.values()) e.path === p && (se(e), e.path = m);
|
|
3510
3596
|
try {
|
|
3511
|
-
let e =
|
|
3512
|
-
return
|
|
3597
|
+
let e = q.getFileByPath(p);
|
|
3598
|
+
return q.setFileByPath(m, e, !0), q.deleteFileByPath(p), i;
|
|
3513
3599
|
} catch {
|
|
3514
|
-
return
|
|
3600
|
+
return l;
|
|
3515
3601
|
}
|
|
3516
3602
|
},
|
|
3517
3603
|
proc_exit: (e) => {
|
|
@@ -3521,76 +3607,85 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
3521
3607
|
};
|
|
3522
3608
|
},
|
|
3523
3609
|
args_sizes_get: (e, t) => {
|
|
3524
|
-
if (!
|
|
3525
|
-
let n = [this.script, ...this.arguments || []], r = new DataView(
|
|
3610
|
+
if (!E) return l;
|
|
3611
|
+
let n = [this.script, ...this.arguments || []], r = new DataView(E.buffer);
|
|
3526
3612
|
return r.setUint32(e, n.length, !0), r.setUint32(t, n.reduce((e, t) => e + b.encode(t).length + 1, 0), !0), i;
|
|
3527
3613
|
},
|
|
3528
3614
|
args_get: (e, t) => {
|
|
3529
|
-
if (!
|
|
3530
|
-
let n = [this.script, ...this.arguments || []], r = new DataView(
|
|
3615
|
+
if (!E) return l;
|
|
3616
|
+
let n = [this.script, ...this.arguments || []], r = new DataView(E.buffer), a = t;
|
|
3531
3617
|
for (let t = 0; t < n.length; t++) {
|
|
3532
3618
|
r.setUint32(e + t * 4, a, !0);
|
|
3533
3619
|
let i = b.encode(n[t] + "\0");
|
|
3534
|
-
new Uint8Array(
|
|
3620
|
+
new Uint8Array(E.buffer).set(i, a), a += i.length;
|
|
3535
3621
|
}
|
|
3536
3622
|
return i;
|
|
3537
3623
|
},
|
|
3538
3624
|
environ_sizes_get: (e, t) => {
|
|
3539
|
-
if (!
|
|
3540
|
-
let n = new DataView(
|
|
3541
|
-
n.setUint32(e,
|
|
3542
|
-
let r =
|
|
3625
|
+
if (!E) return l;
|
|
3626
|
+
let n = new DataView(E.buffer);
|
|
3627
|
+
n.setUint32(e, Q.length, !0);
|
|
3628
|
+
let r = Q.reduce((e, t) => e + b.encode(t).length + 1, 0);
|
|
3543
3629
|
return n.setUint32(t, r, !0), i;
|
|
3544
3630
|
},
|
|
3545
3631
|
environ_get: (e, t) => {
|
|
3546
|
-
if (!
|
|
3547
|
-
let n = new DataView(
|
|
3548
|
-
for (let t = 0; t <
|
|
3632
|
+
if (!E) return l;
|
|
3633
|
+
let n = new DataView(E.buffer), r = t;
|
|
3634
|
+
for (let t = 0; t < Q.length; t++) {
|
|
3549
3635
|
n.setUint32(e + t * 4, r, !0);
|
|
3550
|
-
let i = b.encode(
|
|
3551
|
-
new Uint8Array(
|
|
3636
|
+
let i = b.encode(Q[t] + "\0");
|
|
3637
|
+
new Uint8Array(E.buffer).set(i, r), r += i.length;
|
|
3552
3638
|
}
|
|
3553
3639
|
return i;
|
|
3554
3640
|
},
|
|
3555
3641
|
clock_time_get: (e, t, n) => {
|
|
3556
|
-
if (
|
|
3557
|
-
let
|
|
3558
|
-
new DataView(
|
|
3642
|
+
if (E) {
|
|
3643
|
+
let t = e === 1 && typeof performance < "u" && typeof performance.now == "function" ? BigInt(Math.round(performance.now() * 1e6)) : BigInt(Date.now()) * 1000000n;
|
|
3644
|
+
new DataView(E.buffer).setBigUint64(n, t, !0);
|
|
3559
3645
|
}
|
|
3560
3646
|
return i;
|
|
3561
3647
|
},
|
|
3562
3648
|
random_get: (e, t) => {
|
|
3563
|
-
if (
|
|
3564
|
-
let n = new Uint8Array(
|
|
3649
|
+
if (E) {
|
|
3650
|
+
let n = new Uint8Array(E.buffer, e, t);
|
|
3565
3651
|
for (let e = 0; e < t; e++) n[e] = Math.random() * 256 | 0;
|
|
3566
3652
|
}
|
|
3567
3653
|
return i;
|
|
3568
3654
|
},
|
|
3569
3655
|
clock_nanosleep: (e, t, n, r, a) => {
|
|
3570
|
-
if (!
|
|
3571
|
-
let s = new DataView(
|
|
3656
|
+
if (!E) return o;
|
|
3657
|
+
let s = new DataView(E.buffer).getBigUint64(n, !0), c = 0;
|
|
3572
3658
|
if (t & 1) {
|
|
3573
3659
|
let e = BigInt(Date.now()) * 1000000n;
|
|
3574
3660
|
c = s > e ? Number((s - e) / 1000000n) : 0;
|
|
3575
3661
|
} else c = Number(s / 1000000n);
|
|
3576
|
-
return
|
|
3662
|
+
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;
|
|
3577
3663
|
},
|
|
3578
3664
|
poll_oneoff: (e, t, n, r) => {
|
|
3579
|
-
if (!
|
|
3580
|
-
let a = new DataView(
|
|
3581
|
-
if (
|
|
3582
|
-
if ((typeof
|
|
3583
|
-
|
|
3665
|
+
if (!E) return o;
|
|
3666
|
+
let a = new DataView(E.buffer);
|
|
3667
|
+
if (O) {
|
|
3668
|
+
if ((typeof D?.exports?.asyncify_get_state == "function" ? D.exports.asyncify_get_state() : 0) === 2) {
|
|
3669
|
+
if (D.exports.asyncify_stop_rewind(), I && W.length === 0) return I = !1, a.setUint32(r, 0, !0), c;
|
|
3670
|
+
I = !1;
|
|
3584
3671
|
let o = 0;
|
|
3585
3672
|
for (let r = 0; r < n; r++) {
|
|
3586
|
-
let n = e + r * 48, s = a.getBigUint64(n, !0), c = a.getUint8(n + 8), l =
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3673
|
+
let n = e + r * 48, s = a.getBigUint64(n, !0), c = a.getUint8(n + 8), l = !1;
|
|
3674
|
+
if (c === 0) l = F;
|
|
3675
|
+
else if (c === 1) {
|
|
3676
|
+
let e = a.getUint32(n + 16, !0), t = Y.get(e), r = !!(t && t.type === "dev_tty");
|
|
3677
|
+
(e === 0 || V && e === 2 || r) && W.length > 0 && (l = !0);
|
|
3678
|
+
} else c === 2 && (l = !0);
|
|
3679
|
+
if (l) {
|
|
3680
|
+
let e = t + o * 32;
|
|
3681
|
+
a.setBigUint64(e, s, !0), a.setUint16(e + 8, i, !0), a.setUint8(e + 10, c);
|
|
3682
|
+
for (let t = 11; t < 32; t++) a.setUint8(e + t, 0);
|
|
3683
|
+
c === 1 && a.setBigUint64(e + 16, BigInt(W.length), !0), o++;
|
|
3684
|
+
}
|
|
3590
3685
|
}
|
|
3591
3686
|
return a.setUint32(r, o, !0), i;
|
|
3592
3687
|
}
|
|
3593
|
-
let o = 0, s = Infinity;
|
|
3688
|
+
let o = 0, s = !1, l = Infinity;
|
|
3594
3689
|
for (let t = 0; t < n; t++) {
|
|
3595
3690
|
let n = e + t * 48, r = a.getUint8(n + 8);
|
|
3596
3691
|
if (r === 0) {
|
|
@@ -3599,80 +3694,83 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
3599
3694
|
let t = BigInt(Date.now()) * 1000000n;
|
|
3600
3695
|
r = e > t ? Number((e - t) / 1000000n) : 0;
|
|
3601
3696
|
} else r = Number(e / 1000000n);
|
|
3602
|
-
r <
|
|
3697
|
+
r < l && (l = r);
|
|
3603
3698
|
} else if (r === 1) {
|
|
3604
|
-
|
|
3605
|
-
|
|
3699
|
+
s = !0;
|
|
3700
|
+
let e = a.getUint32(n + 16, !0), t = Y.get(e), r = !!(t && t.type === "dev_tty");
|
|
3701
|
+
(e === 0 || e === 2 || r) && H(), (e === 0 || V && e === 2 || r) && W.length > 0 && o++;
|
|
3606
3702
|
} else r === 2 && o++;
|
|
3607
3703
|
}
|
|
3608
|
-
if (o > 0 ||
|
|
3704
|
+
if (o > 0 || l === 0) {
|
|
3609
3705
|
let o = 0;
|
|
3610
3706
|
for (let r = 0; r < n; r++) {
|
|
3611
|
-
let n = e + r * 48,
|
|
3612
|
-
if (
|
|
3613
|
-
else if (
|
|
3614
|
-
let e = a.getUint32(n + 16, !0), t =
|
|
3615
|
-
(e === 0 ||
|
|
3616
|
-
} else
|
|
3707
|
+
let n = e + r * 48, s = a.getBigUint64(n, !0), c = a.getUint8(n + 8), u = !1;
|
|
3708
|
+
if (c === 0 && l === 0) u = !0;
|
|
3709
|
+
else if (c === 1) {
|
|
3710
|
+
let e = a.getUint32(n + 16, !0), t = Y.get(e), r = !!(t && t.type === "dev_tty");
|
|
3711
|
+
(e === 0 || V && e === 2 || r) && W.length > 0 && (u = !0);
|
|
3712
|
+
} else c === 2 && (u = !0);
|
|
3617
3713
|
if (u) {
|
|
3618
3714
|
let e = t + o * 32;
|
|
3619
|
-
a.setBigUint64(e,
|
|
3715
|
+
a.setBigUint64(e, s, !0), a.setUint16(e + 8, i, !0), a.setUint8(e + 10, c);
|
|
3620
3716
|
for (let t = 11; t < 32; t++) a.setUint8(e + t, 0);
|
|
3621
|
-
|
|
3717
|
+
c === 1 && a.setBigUint64(e + 16, BigInt(W.length), !0), o++;
|
|
3622
3718
|
}
|
|
3623
3719
|
}
|
|
3624
3720
|
return a.setUint32(r, o, !0), i;
|
|
3625
3721
|
}
|
|
3626
|
-
return
|
|
3722
|
+
return F = !1, I = !1, D.exports.asyncify_start_unwind(k), A = new Promise((e, t) => {
|
|
3627
3723
|
let n = null;
|
|
3628
3724
|
this._asyncifyReject = t;
|
|
3629
3725
|
let r = () => {
|
|
3630
|
-
n && clearTimeout(n),
|
|
3726
|
+
n && clearTimeout(n), F = !1, I = !1, j = null, P = null, this._pendingReadResolve = null, this._asyncifyReject = null, e();
|
|
3631
3727
|
};
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
},
|
|
3728
|
+
s && (j = r, this._pendingReadResolve = r, P = () => {
|
|
3729
|
+
n && clearTimeout(n), F = !1, I = !0, j = null, P = null, this._pendingReadResolve = null, this._asyncifyReject = null, e();
|
|
3730
|
+
}), l !== Infinity && (n = setTimeout(() => {
|
|
3731
|
+
F = !0, I = !1, j = null, P = null, this._pendingReadResolve = null, this._asyncifyReject = null, e();
|
|
3732
|
+
}, Math.max(1, l)));
|
|
3635
3733
|
}), a.setUint32(r, 0, !0), i;
|
|
3636
3734
|
}
|
|
3637
3735
|
return a.setUint32(r, 0, !0), i;
|
|
3638
3736
|
}
|
|
3639
3737
|
}, { get(e, t) {
|
|
3640
3738
|
return t in e ? e[t] : () => 0;
|
|
3641
|
-
} }),
|
|
3642
|
-
if (!
|
|
3739
|
+
} }), fe = (e) => {
|
|
3740
|
+
if (!E || !e) return "";
|
|
3643
3741
|
try {
|
|
3644
|
-
let t = new DataView(
|
|
3742
|
+
let t = new DataView(E.buffer).getUint32(e - 4, !0), n = new Uint16Array(E.buffer, e, t >>> 1);
|
|
3645
3743
|
return String.fromCharCode(...n);
|
|
3646
3744
|
} catch {
|
|
3647
3745
|
return "";
|
|
3648
3746
|
}
|
|
3649
|
-
},
|
|
3650
|
-
wasi_snapshot_preview1:
|
|
3651
|
-
wasi_unstable:
|
|
3747
|
+
}, $ = {
|
|
3748
|
+
wasi_snapshot_preview1: de,
|
|
3749
|
+
wasi_unstable: de,
|
|
3652
3750
|
env: new Proxy({
|
|
3653
3751
|
print: (e, t) => {
|
|
3654
|
-
|
|
3752
|
+
E && U(1, n.decode(new Uint8Array(E.buffer, e, t)));
|
|
3655
3753
|
},
|
|
3656
3754
|
eprint: (e, t) => {
|
|
3657
|
-
|
|
3755
|
+
E && U(2, n.decode(new Uint8Array(E.buffer, e, t)));
|
|
3658
3756
|
},
|
|
3659
3757
|
log: (e) => {
|
|
3660
|
-
|
|
3758
|
+
U(1, fe(e) + "\n");
|
|
3661
3759
|
},
|
|
3662
3760
|
logi: (e) => {
|
|
3663
|
-
|
|
3761
|
+
U(1, String(e) + "\n");
|
|
3664
3762
|
},
|
|
3665
3763
|
logf: (e) => {
|
|
3666
|
-
|
|
3764
|
+
U(1, String(e) + "\n");
|
|
3667
3765
|
},
|
|
3668
3766
|
trace: (e, t, ...n) => {
|
|
3669
3767
|
let r = t > 0 ? " " + n.slice(0, t).join(", ") : "";
|
|
3670
|
-
|
|
3768
|
+
U(1, `trace: ${fe(e)}${r}\n`);
|
|
3671
3769
|
},
|
|
3672
3770
|
seed: () => Date.now() * Math.random(),
|
|
3673
3771
|
abort: (e, t, n, r) => {
|
|
3674
|
-
let i =
|
|
3675
|
-
throw (i || a) &&
|
|
3772
|
+
let i = fe(e), a = fe(t);
|
|
3773
|
+
throw (i || a) && U(2, `abort: ${i || "aborted"} at ${a || this.script}:${n || 0}:${r || 0}\n`), this.exitCode = 134, {
|
|
3676
3774
|
_wasmExit: !0,
|
|
3677
3775
|
code: 134
|
|
3678
3776
|
};
|
|
@@ -3688,85 +3786,100 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
3688
3786
|
initial: 1,
|
|
3689
3787
|
maximum: 256
|
|
3690
3788
|
});
|
|
3691
|
-
|
|
3789
|
+
E = t, $[e.module] || ($[e.module] = {}), $[e.module][e.name] = t;
|
|
3692
3790
|
}
|
|
3693
|
-
if (
|
|
3791
|
+
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) {
|
|
3694
3792
|
try {
|
|
3695
|
-
|
|
3793
|
+
k = E.grow(1) * 65536;
|
|
3696
3794
|
} catch {
|
|
3697
|
-
|
|
3795
|
+
k = 16;
|
|
3698
3796
|
}
|
|
3699
|
-
let e =
|
|
3700
|
-
new Int32Array(
|
|
3797
|
+
let e = k + 8, t = k + 65536 - 8;
|
|
3798
|
+
new Int32Array(E.buffer, k, 2).set([e, t]);
|
|
3701
3799
|
}
|
|
3702
|
-
typeof
|
|
3703
|
-
let n = this.stdout && this.stdout.columns || this.context && typeof this.context.getVar == "function" && parseInt(this.context.getVar("COLUMNS"), 10) || 80, r = this.stdout && this.stdout.rows || this.context && typeof this.context.getVar == "function" && parseInt(this.context.getVar("LINES"), 10) || 24;
|
|
3704
|
-
if (typeof
|
|
3705
|
-
|
|
3800
|
+
typeof D.exports.set_terminal_size == "function" && H(), V && this._enterAltScreen();
|
|
3801
|
+
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;
|
|
3802
|
+
if (typeof D.exports.set_terminal_size == "function") try {
|
|
3803
|
+
D.exports.set_terminal_size(n, r);
|
|
3706
3804
|
} catch {}
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3805
|
+
let i = n, a = r, o = (e, t) => {
|
|
3806
|
+
if (!(!e || !t)) {
|
|
3807
|
+
if (this.stdout && (this.stdout.columns !== e || this.stdout.rows !== t) && (this.stdout.columns = e, this.stdout.rows = t), this.stdinStream && (this.stdinStream.columns !== e || this.stdinStream.rows !== t) && (this.stdinStream.columns = e, this.stdinStream.rows = t), this.context && typeof this.context.setVar == "function") try {
|
|
3808
|
+
this.context.setVar("COLUMNS", String(e)), this.context.setVar("LINES", String(t));
|
|
3809
|
+
} catch {}
|
|
3810
|
+
if (!(e === i && t === a)) {
|
|
3811
|
+
if (i = e, a = t, typeof D?.exports?.set_terminal_size == "function") try {
|
|
3812
|
+
D.exports.set_terminal_size(e, t);
|
|
3813
|
+
} catch {}
|
|
3814
|
+
if (P) {
|
|
3815
|
+
let e = P;
|
|
3816
|
+
P = null, e();
|
|
3817
|
+
}
|
|
3818
|
+
}
|
|
3819
|
+
}
|
|
3820
|
+
};
|
|
3821
|
+
ee = () => {
|
|
3822
|
+
o(this.stdout && this.stdout.columns || this.context && typeof this.context.getVar == "function" && parseInt(this.context.getVar("COLUMNS"), 10) || 80, this.stdout && this.stdout.rows || this.context && typeof this.context.getVar == "function" && parseInt(this.context.getVar("LINES"), 10) || 24);
|
|
3823
|
+
}, R = () => {
|
|
3824
|
+
o(this.stdinStream && this.stdinStream.columns || this.stdout && this.stdout.columns || this.context && typeof this.context.getVar == "function" && parseInt(this.context.getVar("COLUMNS"), 10) || 80, this.stdinStream && this.stdinStream.rows || this.stdout && this.stdout.rows || this.context && typeof this.context.getVar == "function" && parseInt(this.context.getVar("LINES"), 10) || 24);
|
|
3825
|
+
}, this.stdout && typeof this.stdout.on == "function" && this.stdout.on("resize", ee), this.stdinStream && this.stdinStream !== this.stdout && typeof this.stdinStream.on == "function" && this.stdinStream.on("resize", R);
|
|
3826
|
+
let s = D.exports._start || D.exports.__wasi_command || D.exports.main || D.exports.run;
|
|
3827
|
+
if (s) try {
|
|
3828
|
+
let e = s();
|
|
3829
|
+
for (e && typeof e.then == "function" && (e = await e); O && typeof D.exports.asyncify_get_state == "function" && D.exports.asyncify_get_state() === 1;) {
|
|
3717
3830
|
if (this._killed) {
|
|
3718
3831
|
this.exitCode = 130;
|
|
3719
3832
|
break;
|
|
3720
3833
|
}
|
|
3721
|
-
if (
|
|
3834
|
+
if (D.exports.asyncify_stop_unwind(), A) {
|
|
3722
3835
|
try {
|
|
3723
|
-
await
|
|
3836
|
+
await A;
|
|
3724
3837
|
} catch {
|
|
3725
3838
|
if (this._killed) {
|
|
3726
3839
|
this.exitCode = 130;
|
|
3727
3840
|
break;
|
|
3728
3841
|
}
|
|
3729
3842
|
}
|
|
3730
|
-
|
|
3843
|
+
A = null;
|
|
3731
3844
|
}
|
|
3732
3845
|
if (this._killed) {
|
|
3733
3846
|
this.exitCode = 130;
|
|
3734
3847
|
break;
|
|
3735
3848
|
}
|
|
3736
|
-
|
|
3849
|
+
D.exports.asyncify_start_rewind(k), e = s(), e && typeof e.then == "function" && (e = await e);
|
|
3737
3850
|
}
|
|
3738
3851
|
} catch (e) {
|
|
3739
3852
|
this._killed ? this.exitCode = 130 : (!e || !e._wasmExit) && (this.stdErr = `${this.script}: runtime error: ${e?.message || String(e)}`, this.exitCode = 1);
|
|
3740
3853
|
}
|
|
3741
3854
|
else {
|
|
3742
|
-
let e = Object.entries(
|
|
3855
|
+
let e = Object.entries(D.exports).filter(([, e]) => typeof e == "function").map(([e]) => e), t = e.length > 0 ? ` (module is a library exporting: ${e.join(", ")})` : "";
|
|
3743
3856
|
this.stdErr = `${this.script}: no CLI entry point found (expected _start, main, or run)${t}`, this.exitCode = 1;
|
|
3744
3857
|
}
|
|
3745
3858
|
} catch (e) {
|
|
3746
3859
|
this._killed ? this.exitCode = 130 : (!e || !e._wasmExit) && (this.stdErr = `${this.script}: ${e?.message || String(e)}`, this.exitCode = 1);
|
|
3747
3860
|
} finally {
|
|
3748
|
-
|
|
3749
|
-
for (let e of
|
|
3861
|
+
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;
|
|
3862
|
+
for (let e of Y.values()) se(e);
|
|
3750
3863
|
}
|
|
3751
|
-
|
|
3752
|
-
let
|
|
3864
|
+
te();
|
|
3865
|
+
let pe = this.arguments || [];
|
|
3753
3866
|
if (!(this.result && this.result.getStdOutput && this.result.getStdOutput().length > 0) && (this.exitCode === 0 || this.exitCode === void 0)) {
|
|
3754
3867
|
let t = this._ensurePkgMeta(), n = t && t.bin || (this.script || "wasm").split("/").pop(), r = Object.assign({
|
|
3755
3868
|
name: t && t.name || n,
|
|
3756
3869
|
version: t && t.version || "wasi",
|
|
3757
3870
|
description: `WebAssembly WASI binary (${this.script})`
|
|
3758
3871
|
}, t || {});
|
|
3759
|
-
if (
|
|
3760
|
-
let t =
|
|
3761
|
-
for (let e of
|
|
3762
|
-
} else (
|
|
3872
|
+
if (pe.includes("--help") || pe.includes("-h")) {
|
|
3873
|
+
let t = M(e);
|
|
3874
|
+
for (let e of N(n, r, t)) this.stdOut = e;
|
|
3875
|
+
} else (pe.includes("--version") || pe.includes("-V") || pe.includes("-v")) && (this.stdOut = `${n} (${r.name} ${r.version} wasm)`);
|
|
3763
3876
|
}
|
|
3764
3877
|
}
|
|
3765
|
-
},
|
|
3766
|
-
function
|
|
3878
|
+
}, D = /* @__PURE__ */ new Map();
|
|
3879
|
+
function O(e, t) {
|
|
3767
3880
|
if (!e || !e.exists(t)) return null;
|
|
3768
3881
|
if (e.isRealFilesystem) try {
|
|
3769
|
-
let n =
|
|
3882
|
+
let n = Y();
|
|
3770
3883
|
return new Uint8Array(n.readFileSync(e.absolutePath(t)));
|
|
3771
3884
|
} catch {}
|
|
3772
3885
|
let n = e.getFileByPath(t);
|
|
@@ -3790,7 +3903,7 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
3790
3903
|
}
|
|
3791
3904
|
return null;
|
|
3792
3905
|
}
|
|
3793
|
-
function
|
|
3906
|
+
function k(e, t, n, i = "application/octet-stream") {
|
|
3794
3907
|
let a = n instanceof Uint8Array ? n : new Uint8Array(n);
|
|
3795
3908
|
if (e && e.isRealFilesystem) {
|
|
3796
3909
|
e.setFileByPath(t, a, !0);
|
|
@@ -3805,7 +3918,7 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
3805
3918
|
}
|
|
3806
3919
|
e.setFileByPath(t, s, !0);
|
|
3807
3920
|
}
|
|
3808
|
-
async function
|
|
3921
|
+
async function A(e, t, n = null) {
|
|
3809
3922
|
if (typeof n == "function") {
|
|
3810
3923
|
let r = await n(e, t);
|
|
3811
3924
|
if (r) return r;
|
|
@@ -3833,7 +3946,7 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
3833
3946
|
}
|
|
3834
3947
|
throw Error(`Package '${e}' could not be loaded`);
|
|
3835
3948
|
}
|
|
3836
|
-
function
|
|
3949
|
+
function j(e, t = !1) {
|
|
3837
3950
|
let n = {
|
|
3838
3951
|
usage: null,
|
|
3839
3952
|
options: []
|
|
@@ -3850,7 +3963,7 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
3850
3963
|
}
|
|
3851
3964
|
return n;
|
|
3852
3965
|
}
|
|
3853
|
-
function
|
|
3966
|
+
function M(e) {
|
|
3854
3967
|
let t = {
|
|
3855
3968
|
usage: null,
|
|
3856
3969
|
options: [],
|
|
@@ -3875,12 +3988,12 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
3875
3988
|
r.length >= 4 && n.push(r);
|
|
3876
3989
|
let i = n.join("\n");
|
|
3877
3990
|
t.isInteractive || (i.includes("/dev/tty") || i.includes("\x1B[?1049h") || i.includes("smcup") || i.includes("xterm")) && (t.isInteractive = !0);
|
|
3878
|
-
let a =
|
|
3991
|
+
let a = j(i, !0);
|
|
3879
3992
|
t.usage = a.usage, t.options = a.options;
|
|
3880
3993
|
} catch {}
|
|
3881
3994
|
return t;
|
|
3882
3995
|
}
|
|
3883
|
-
function
|
|
3996
|
+
function N(e, t = {}, n = null) {
|
|
3884
3997
|
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}`];
|
|
3885
3998
|
t.details && u.push("", t.details), u.push("", "Options:");
|
|
3886
3999
|
let d = n && n.options && n.options.length > 0 ? n.options : Array.isArray(t.options) ? t.options : [];
|
|
@@ -3888,8 +4001,8 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
3888
4001
|
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`));
|
|
3889
4002
|
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;
|
|
3890
4003
|
}
|
|
3891
|
-
function
|
|
3892
|
-
let r =
|
|
4004
|
+
function P(e, t = {}, n = null) {
|
|
4005
|
+
let r = W(), i = (n || e.bin || e.name).toLowerCase();
|
|
3893
4006
|
class a extends r {
|
|
3894
4007
|
static get name() {
|
|
3895
4008
|
return i;
|
|
@@ -3904,7 +4017,16 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
3904
4017
|
return this._subCommand ? this._subCommand.interactive : this._isInteractive === void 0 ? !!(e && (e.interactive || e.wasm?.interactive) || this._inspectedWasm && this._inspectedWasm.isInteractive) : !!this._isInteractive;
|
|
3905
4018
|
}
|
|
3906
4019
|
get captureInput() {
|
|
3907
|
-
return this.interactive;
|
|
4020
|
+
return this._subCommand ? !!this._subCommand.captureInput : this.interactive;
|
|
4021
|
+
}
|
|
4022
|
+
get isRaw() {
|
|
4023
|
+
return !!(this.stdinStream && this.stdinStream.isRaw || this._subCommand && (this._subCommand.isRaw || this._subCommand.stdinStream && this._subCommand.stdinStream.isRaw));
|
|
4024
|
+
}
|
|
4025
|
+
get _inAltScreen() {
|
|
4026
|
+
return !!(this.__inAltScreen || this._subCommand && this._subCommand._inAltScreen);
|
|
4027
|
+
}
|
|
4028
|
+
set _inAltScreen(e) {
|
|
4029
|
+
this.__inAltScreen = !!e;
|
|
3908
4030
|
}
|
|
3909
4031
|
kill(e = "SIGINT") {
|
|
3910
4032
|
this._subCommand && typeof this._subCommand.kill == "function" && this._subCommand.kill(e), super.kill(e);
|
|
@@ -3913,8 +4035,8 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
3913
4035
|
this._subCommand && typeof this._subCommand.onInput == "function" && this._subCommand.onInput(e);
|
|
3914
4036
|
}
|
|
3915
4037
|
async run() {
|
|
3916
|
-
let n = [...this.arguments || []], r = n.includes("--help") || n.includes("-h"), a = !r && (n.includes("--version") || n.includes("-V") || n.includes("-v"));
|
|
3917
|
-
this._inspectedWasm = null, this._persistedWasmBytes = e.wasmPath ?
|
|
4038
|
+
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;
|
|
4039
|
+
this._inspectedWasm = null, this._persistedWasmBytes = e.wasmPath ? O(o, e.wasmPath) : null, r && this._persistedWasmBytes && this._persistedWasmBytes.byteLength > 0 && (this._inspectedWasm = M(this._persistedWasmBytes));
|
|
3918
4040
|
try {
|
|
3919
4041
|
if ((e.type === "wasm" || e.type === "custom-wasm") && (this._persistedWasmBytes || e.wasmUrl)) {
|
|
3920
4042
|
let i = this._persistedWasmBytes;
|
|
@@ -3923,7 +4045,7 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
3923
4045
|
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);
|
|
3924
4046
|
} catch {}
|
|
3925
4047
|
if (!i && e.wasmUrl && (i = await this._fetchWasmBytes(e.wasmUrl)), i) {
|
|
3926
|
-
r && (this._inspectedWasm =
|
|
4048
|
+
r && (this._inspectedWasm = M(i)), await this._runRawWasmBytes(i, n);
|
|
3927
4049
|
return;
|
|
3928
4050
|
}
|
|
3929
4051
|
} else {
|
|
@@ -3940,19 +4062,19 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
3940
4062
|
}
|
|
3941
4063
|
let c, l;
|
|
3942
4064
|
try {
|
|
3943
|
-
c = await
|
|
4065
|
+
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);
|
|
3944
4066
|
} finally {
|
|
3945
4067
|
s && (globalThis.fetch = s);
|
|
3946
4068
|
}
|
|
3947
4069
|
if (l instanceof Uint8Array || l instanceof ArrayBuffer) {
|
|
3948
4070
|
let e = l instanceof Uint8Array ? l : new Uint8Array(l);
|
|
3949
|
-
r && (this._inspectedWasm =
|
|
4071
|
+
r && (this._inspectedWasm = M(e)), await this._runRawWasmBytes(e, n);
|
|
3950
4072
|
} else if (l && (l.wasmBytes instanceof Uint8Array || l.wasm instanceof Uint8Array)) {
|
|
3951
4073
|
let e = l.wasmBytes || l.wasm;
|
|
3952
|
-
r && (this._inspectedWasm =
|
|
4074
|
+
r && (this._inspectedWasm = M(e)), await this._runRawWasmBytes(e, n);
|
|
3953
4075
|
} else if (typeof l == "function") await this._runFunctionOrEmscripten(l, n, r, a);
|
|
3954
4076
|
else if (l && typeof l == "object") {
|
|
3955
|
-
l.ready && await l.ready, r && (l.HEAPU8 instanceof Uint8Array || l.wasmBinary instanceof Uint8Array) && (this._inspectedWasm =
|
|
4077
|
+
l.ready && await l.ready, r && (l.HEAPU8 instanceof Uint8Array || l.wasmBinary instanceof Uint8Array) && (this._inspectedWasm = M(l.wasmBinary || l.HEAPU8));
|
|
3956
4078
|
let t = l.main || l.run || l.callMain || l.exec;
|
|
3957
4079
|
if (typeof t == "function") await this._invokeCliFunction(t.bind(l), n);
|
|
3958
4080
|
else if (l.promised || typeof l.raw == "function" || typeof l.json == "function") {
|
|
@@ -3980,34 +4102,38 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
3980
4102
|
}
|
|
3981
4103
|
}
|
|
3982
4104
|
if (r || a) {
|
|
3983
|
-
let t = this.result && this.result.getStdOutput ? this.result.getStdOutput() : [], n = t.map((e) => e.string).join("\n"), o = r ?
|
|
4105
|
+
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);
|
|
3984
4106
|
if (r) if (s) {
|
|
3985
4107
|
let e = t.map((e) => e.string);
|
|
3986
4108
|
this.result && Array.isArray(this.result.std) && (this.result.std.length = 0), this.exitCode = 0;
|
|
3987
4109
|
for (let t of e) this.stdOut = t;
|
|
3988
4110
|
} else {
|
|
3989
4111
|
this.result && Array.isArray(this.result.std) && (this.result.std.length = 0), this.exitCode = 0;
|
|
3990
|
-
for (let t of
|
|
4112
|
+
for (let t of N(i, e, this._inspectedWasm)) this.stdOut = t;
|
|
3991
4113
|
}
|
|
3992
4114
|
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;
|
|
3993
4115
|
}
|
|
3994
4116
|
}
|
|
3995
4117
|
async _fetchWasmBytes(e) {
|
|
3996
|
-
if (
|
|
4118
|
+
if (D.has(e)) return D.get(e);
|
|
3997
4119
|
let n = t.fetch || (typeof fetch == "function" ? fetch : null);
|
|
3998
4120
|
if (!n) throw Error("fetch is not available in this environment");
|
|
3999
4121
|
let r = await n(e);
|
|
4000
4122
|
if (!r || !r.ok) throw Error(`HTTP ${r ? r.status : "error"} fetching ${e}`);
|
|
4001
4123
|
let i = new Uint8Array(await r.arrayBuffer());
|
|
4002
|
-
return
|
|
4124
|
+
return D.set(e, i), i;
|
|
4003
4125
|
}
|
|
4004
4126
|
async _runRawWasmBytes(t, n) {
|
|
4005
|
-
let r = new
|
|
4006
|
-
r.script = i, r.arguments = n, r.context = this.context, r.fs = this.fs, r._pkgMeta = e, this.
|
|
4127
|
+
let r = new E(i, n, this.context);
|
|
4128
|
+
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);
|
|
4129
|
+
let a = () => {
|
|
4130
|
+
this.emit("interactive"), this.context && typeof this.context.emit == "function" && this.context.emit("interactive");
|
|
4131
|
+
};
|
|
4132
|
+
r.on("interactive", a), this._subCommand = r;
|
|
4007
4133
|
try {
|
|
4008
4134
|
await r._runWasm(t);
|
|
4009
4135
|
} finally {
|
|
4010
|
-
this._subCommand = null;
|
|
4136
|
+
r.removeListener("interactive", a), r._inAltScreen && r._exitAltScreen(), this._subCommand = null, this._onStdinStreamData && this.stdinStream && typeof this.stdinStream.on == "function" && this.stdinStream.on("data", this._onStdinStreamData);
|
|
4011
4137
|
}
|
|
4012
4138
|
for (let e of r.result.getStdOutput()) e.type === "out" ? this.stdOut = e.string : e.type === "err" && (this.stdErr = e.string);
|
|
4013
4139
|
this.exitCode = r.result.getExitCode();
|
|
@@ -4031,16 +4157,16 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
4031
4157
|
let n = t && t !== "." && !e.startsWith("/") ? `${t.replace(/\/+$/, "")}/${e}` : e, r = this.fs.getFileByPath(n) ?? this.fs.getFileByPath(e);
|
|
4032
4158
|
return r == null ? null : typeof r == "string" ? r : new TextDecoder().decode(r);
|
|
4033
4159
|
},
|
|
4034
|
-
readBytes: (e) =>
|
|
4160
|
+
readBytes: (e) => O(this.fs, e),
|
|
4035
4161
|
writeFile: (e, t, n) => {
|
|
4036
4162
|
if (!this.fs) return;
|
|
4037
4163
|
let r = n && n !== "." && !e.startsWith("/") ? `${n.replace(/\/+$/, "")}/${e}` : e;
|
|
4038
4164
|
if (t instanceof Uint8Array || ArrayBuffer.isView(t)) {
|
|
4039
4165
|
let e = r.endsWith(".wasm") ? "application/wasm" : "application/octet-stream";
|
|
4040
|
-
|
|
4166
|
+
k(this.fs, r, t, e);
|
|
4041
4167
|
} else this.fs.setFileByPath(r, String(t), !0);
|
|
4042
4168
|
if (r.endsWith(".wasm") || r.endsWith(".wat")) try {
|
|
4043
|
-
this.
|
|
4169
|
+
this.fs.setMode(r, 493);
|
|
4044
4170
|
} catch {}
|
|
4045
4171
|
},
|
|
4046
4172
|
listFiles: (e, t) => {
|
|
@@ -4073,7 +4199,7 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
4073
4199
|
if (e && typeof e.status == "number") this.exitCode = e.status;
|
|
4074
4200
|
else throw e;
|
|
4075
4201
|
}
|
|
4076
|
-
if (f && typeof f == "object") if (r && (f.wasmBinary instanceof Uint8Array || f.HEAPU8 instanceof Uint8Array) && (this._inspectedWasm =
|
|
4202
|
+
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") {
|
|
4077
4203
|
f.FS && l.size === 0 && (l = this._syncBrshToEmscriptenFs(f.FS, n));
|
|
4078
4204
|
try {
|
|
4079
4205
|
let e = await f.callMain(n);
|
|
@@ -4136,14 +4262,14 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
4136
4262
|
}), !t.loaded && typeof t.load == "function" && await t.load(e.coreUrl ? { coreURL: e.coreUrl } : void 0);
|
|
4137
4263
|
let a = /* @__PURE__ */ new Set(), o = [];
|
|
4138
4264
|
for (let e of n) if (!e.startsWith("-") && (o.push(e), this.fs.exists(e))) {
|
|
4139
|
-
let n =
|
|
4265
|
+
let n = O(this.fs, e);
|
|
4140
4266
|
n && (await t.writeFile(e, n), a.add(e));
|
|
4141
4267
|
}
|
|
4142
4268
|
let s = await t.exec(n);
|
|
4143
4269
|
for (let e of o) if (!a.has(e)) try {
|
|
4144
4270
|
if (typeof t.readFile == "function") {
|
|
4145
4271
|
let n = await t.readFile(e);
|
|
4146
|
-
n &&
|
|
4272
|
+
n && k(this.fs, e, n);
|
|
4147
4273
|
}
|
|
4148
4274
|
} catch {}
|
|
4149
4275
|
typeof s == "number" && s !== 0 && (this.exitCode = s, i.length === 0 && r.length > 0 && i.push(...r.splice(0, r.length)));
|
|
@@ -4160,7 +4286,7 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
4160
4286
|
let n = /* @__PURE__ */ new Set();
|
|
4161
4287
|
if (!this.fs || !e || typeof e.writeFile != "function") return n;
|
|
4162
4288
|
for (let r of t) if (!r.startsWith("-") && this.fs.exists(r)) {
|
|
4163
|
-
let t =
|
|
4289
|
+
let t = O(this.fs, r);
|
|
4164
4290
|
if (t) try {
|
|
4165
4291
|
e.writeFile(r, t), n.add(r);
|
|
4166
4292
|
} catch {}
|
|
@@ -4173,8 +4299,8 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
4173
4299
|
let t = e.readFile(r);
|
|
4174
4300
|
if (t) {
|
|
4175
4301
|
let e = r.endsWith(".wasm") ? "application/wasm" : "application/octet-stream";
|
|
4176
|
-
if (
|
|
4177
|
-
this.
|
|
4302
|
+
if (k(this.fs, r, t, e), r.endsWith(".wasm") || r.endsWith(".wat")) try {
|
|
4303
|
+
this.fs.setMode(r, 493);
|
|
4178
4304
|
} catch {}
|
|
4179
4305
|
}
|
|
4180
4306
|
} catch {}
|
|
@@ -4183,10 +4309,10 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
4183
4309
|
}
|
|
4184
4310
|
return a;
|
|
4185
4311
|
}
|
|
4186
|
-
function
|
|
4312
|
+
function F(e, t) {
|
|
4187
4313
|
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;
|
|
4188
4314
|
}
|
|
4189
|
-
function
|
|
4315
|
+
function I(e, t) {
|
|
4190
4316
|
if (!e || !t || typeof e.exists != "function" || typeof e.getFileByPath != "function") return null;
|
|
4191
4317
|
try {
|
|
4192
4318
|
let n = t.split("/").filter(Boolean);
|
|
@@ -4199,8 +4325,8 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
4199
4325
|
} catch {}
|
|
4200
4326
|
return null;
|
|
4201
4327
|
}
|
|
4202
|
-
|
|
4203
|
-
})),
|
|
4328
|
+
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;
|
|
4329
|
+
})), oe = /* @__PURE__ */ t(((e, t) => {
|
|
4204
4330
|
var n = {
|
|
4205
4331
|
sqlite3: {
|
|
4206
4332
|
name: "sqlite3",
|
|
@@ -4438,7 +4564,7 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
4438
4564
|
PACKAGE_ALIASES: r,
|
|
4439
4565
|
resolvePackageName: i
|
|
4440
4566
|
};
|
|
4441
|
-
})),
|
|
4567
|
+
})), Z = /* @__PURE__ */ t(((e, t) => {
|
|
4442
4568
|
function n(e, t, n = {}) {
|
|
4443
4569
|
let { showRowCount: r = !0 } = n;
|
|
4444
4570
|
if (!e || e.length === 0) return [];
|
|
@@ -4474,7 +4600,7 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
4474
4600
|
}
|
|
4475
4601
|
return i;
|
|
4476
4602
|
}
|
|
4477
|
-
var { readBytesFromFs: a, writeBytesToFs: o, loadModule: s, extractHelpFromText: c, inspectWasmBytes: l, formatWasmHelp: u } =
|
|
4603
|
+
var { readBytesFromFs: a, writeBytesToFs: o, loadModule: s, extractHelpFromText: c, inspectWasmBytes: l, formatWasmHelp: u } = X();
|
|
4478
4604
|
t.exports = {
|
|
4479
4605
|
formatTable: n,
|
|
4480
4606
|
formatPipeList: r,
|
|
@@ -4486,9 +4612,9 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
4486
4612
|
inspectWasmBytes: l,
|
|
4487
4613
|
formatWasmHelp: u
|
|
4488
4614
|
};
|
|
4489
|
-
})),
|
|
4490
|
-
|
|
4491
|
-
var n =
|
|
4615
|
+
})), se = /* @__PURE__ */ t(((e, t) => {
|
|
4616
|
+
W();
|
|
4617
|
+
var n = K(), { readBytesFromFs: r, writeBytesToFs: i, loadModule: a } = Z(), o = {
|
|
4492
4618
|
smol: "https://huggingface.co/bartowski/SmolLM2-135M-Instruct-GGUF/resolve/main/SmolLM2-135M-Instruct-Q4_K_M.gguf",
|
|
4493
4619
|
smollm: "https://huggingface.co/bartowski/SmolLM2-135M-Instruct-GGUF/resolve/main/SmolLM2-135M-Instruct-Q4_K_M.gguf",
|
|
4494
4620
|
smollm2: "https://huggingface.co/bartowski/SmolLM2-135M-Instruct-GGUF/resolve/main/SmolLM2-135M-Instruct-Q4_K_M.gguf",
|
|
@@ -5381,9 +5507,9 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
5381
5507
|
name: "wllama",
|
|
5382
5508
|
version: "3.8.1"
|
|
5383
5509
|
}), t.exports.wllamaInstances = u, t.exports.getDefaultPersistPath = d, t.exports.DEFAULT_PERSIST_DIR = l, t.exports.resolveModelSpec = h, t.exports.formatDownloadProgress = p, t.exports.DEFAULT_MODEL_URL = s, t.exports.MODEL_ALIASES = o;
|
|
5384
|
-
})),
|
|
5510
|
+
})), ce = /* @__PURE__ */ t(((e, t) => {
|
|
5385
5511
|
b();
|
|
5386
|
-
var r =
|
|
5512
|
+
var r = B(), i = W(), a = X(), o = K(), { DEFAULT_REGISTRY: s, resolvePackageName: c } = oe(), l = se(), { writeBytesToFs: u, createGenericWasmCommand: d } = a, { createReplWasmCommand: f } = o, p = "/var/cache/wbt";
|
|
5387
5513
|
function m(e, t, n = {}) {
|
|
5388
5514
|
class r extends a {
|
|
5389
5515
|
static get name() {
|
|
@@ -5417,6 +5543,45 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
5417
5543
|
get requiresFilesystem() {
|
|
5418
5544
|
return !0;
|
|
5419
5545
|
}
|
|
5546
|
+
get _fs() {
|
|
5547
|
+
return this.fs || this.context && this.context.fs || null;
|
|
5548
|
+
}
|
|
5549
|
+
get _pathDir() {
|
|
5550
|
+
return this.context && typeof this.context.getVar == "function" && this.context.getVar("PATH") || "/bin";
|
|
5551
|
+
}
|
|
5552
|
+
_withWritableParent(e, t) {
|
|
5553
|
+
let n = this._fs;
|
|
5554
|
+
if (!n) return;
|
|
5555
|
+
let r = (typeof n.absolutePath == "function" ? n.absolutePath(e) : e).split("/");
|
|
5556
|
+
r.pop();
|
|
5557
|
+
let i = r.join("/") || "/", a = typeof n.getMode == "function" ? n.getMode(i) : null, o = a !== null && (a & 128) == 0;
|
|
5558
|
+
if (o) try {
|
|
5559
|
+
n.setMode(i, a | 128);
|
|
5560
|
+
} catch {}
|
|
5561
|
+
try {
|
|
5562
|
+
return t(n);
|
|
5563
|
+
} finally {
|
|
5564
|
+
if (o) try {
|
|
5565
|
+
n.setMode(i, a);
|
|
5566
|
+
} catch {}
|
|
5567
|
+
}
|
|
5568
|
+
}
|
|
5569
|
+
_writeFileSafe(e, t) {
|
|
5570
|
+
this._withWritableParent(e, (n) => {
|
|
5571
|
+
if (n.exists(e)) try {
|
|
5572
|
+
n.setMode(e, 493);
|
|
5573
|
+
} catch {}
|
|
5574
|
+
n.setFileByPath(e, t, !0);
|
|
5575
|
+
});
|
|
5576
|
+
}
|
|
5577
|
+
_writeBytesSafe(e, t, n = "application/wasm") {
|
|
5578
|
+
this._withWritableParent(e, (r) => {
|
|
5579
|
+
if (r.exists(e)) try {
|
|
5580
|
+
r.setMode(e, 493);
|
|
5581
|
+
} catch {}
|
|
5582
|
+
u(r, e, t, n);
|
|
5583
|
+
});
|
|
5584
|
+
}
|
|
5420
5585
|
get interactive() {
|
|
5421
5586
|
if (this._activeSubCommand && this._activeSubCommand.interactive !== void 0) return !!this._activeSubCommand.interactive;
|
|
5422
5587
|
if (this.arguments && this.arguments[0] === "run" && this.arguments[1]) {
|
|
@@ -5428,6 +5593,9 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
5428
5593
|
get captureInput() {
|
|
5429
5594
|
return this._activeSubCommand && this._activeSubCommand.captureInput !== void 0 ? !!this._activeSubCommand.captureInput : this.interactive;
|
|
5430
5595
|
}
|
|
5596
|
+
get isRaw() {
|
|
5597
|
+
return !!(this.stdinStream && this.stdinStream.isRaw || this._activeSubCommand && (this._activeSubCommand.isRaw || this._activeSubCommand.stdinStream && this._activeSubCommand.stdinStream.isRaw));
|
|
5598
|
+
}
|
|
5431
5599
|
onInput(e) {
|
|
5432
5600
|
this._activeSubCommand && typeof this._activeSubCommand.onInput == "function" && this._activeSubCommand.onInput(e);
|
|
5433
5601
|
}
|
|
@@ -5452,30 +5620,32 @@ var A, j, M, N, P, F, I, L, R, z, B = e((() => {
|
|
|
5452
5620
|
_getRegistry() {
|
|
5453
5621
|
let e = this.constructor._config || {}, t = Object.assign({}, s, e.registry || {});
|
|
5454
5622
|
try {
|
|
5455
|
-
let e = this.
|
|
5456
|
-
if (typeof
|
|
5457
|
-
let
|
|
5458
|
-
Object.assign(t,
|
|
5623
|
+
let e = this._fs, n = e ? e.getFileByPath(`${p}/remote-registry.json`) : null;
|
|
5624
|
+
if (typeof n == "string" && n.trim()) {
|
|
5625
|
+
let e = JSON.parse(n);
|
|
5626
|
+
Object.assign(t, e);
|
|
5459
5627
|
}
|
|
5460
5628
|
} catch {}
|
|
5461
5629
|
return t;
|
|
5462
5630
|
}
|
|
5463
5631
|
_getInstalledPackages() {
|
|
5464
|
-
let e = {}, t = this.
|
|
5465
|
-
if (!t
|
|
5466
|
-
let n =
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5632
|
+
let e = {}, t = this._fs;
|
|
5633
|
+
if (!t) return e;
|
|
5634
|
+
let n = t.getFileByPath("/usr/lib");
|
|
5635
|
+
if (!n || typeof n != "object") return e;
|
|
5636
|
+
let r = this._getRegistry();
|
|
5637
|
+
for (let i of Object.keys(n)) {
|
|
5638
|
+
if (i.startsWith(".")) continue;
|
|
5639
|
+
let n = i.toLowerCase(), a = r[n] || Object.values(r).find((e) => e.name === n || e.bin === n), o = t.getFileByPath(`/usr/lib/${i}`) || {}, s = (typeof o == "object" ? Object.keys(o) : []).find((e) => e.endsWith(".wasm") || e.endsWith(".wat")), c = s ? `/usr/lib/${i}/${s}` : t.exists(`/usr/lib/${i}/${n}.wasm`) ? `/usr/lib/${i}/${n}.wasm` : null, l = a && a.bin || n, u = [l];
|
|
5640
|
+
a && a.aliases && u.push(...a.aliases), a && a.scripts && u.push(...Object.keys(a.scripts)), e[n] = Object.assign({
|
|
5641
|
+
name: n,
|
|
5642
|
+
bin: l,
|
|
5643
|
+
bins: u,
|
|
5644
|
+
version: a && a.version || "custom",
|
|
5645
|
+
description: a && a.description || `Installed package ${n}`,
|
|
5646
|
+
type: a && a.type || (c ? "custom-wasm" : "generic-runtime"),
|
|
5647
|
+
wasmPath: c
|
|
5648
|
+
}, a || {}), c && (e[n].wasmPath = c);
|
|
5479
5649
|
}
|
|
5480
5650
|
return e;
|
|
5481
5651
|
}
|
|
@@ -5488,7 +5658,7 @@ try {
|
|
|
5488
5658
|
wllamaModule = require(${JSON.stringify(n)});\n} catch (_) {\n try {\n wllamaModule = require('brsh/wbt/packages/wllama');\n } catch (e) {\n wllamaModule = require('./wllama');\n }\n}\nmodule.exports = wllamaModule.createWllamaCommand(${JSON.stringify(e)}, {}, ${JSON.stringify(t)});\n`;
|
|
5489
5659
|
}
|
|
5490
5660
|
let n = JSON.stringify(e, null, 2);
|
|
5491
|
-
return e.repl ? `'use strict';\nconst pkgMeta = ${n};\nconst
|
|
5661
|
+
return e.repl ? `'use strict';\nconst pkgMeta = ${n};\nconst _Repl = typeof ReplCommand !== 'undefined' ? ReplCommand : (typeof require !== 'undefined' ? require('brsh/ReplCommand') : globalThis.ReplCommand);\nmodule.exports = _Repl.createReplWasmCommand(pkgMeta, {}, ${JSON.stringify(t)});\n` : `'use strict';\nconst pkgMeta = ${n};\nconst _Wasm = typeof WasmCommand !== 'undefined' ? WasmCommand : (typeof require !== 'undefined' ? require('brsh/WasmCommand') : globalThis.WasmCommand);\nmodule.exports = _Wasm.createGenericWasmCommand(pkgMeta, {}, ${JSON.stringify(t)});\n`;
|
|
5492
5662
|
}
|
|
5493
5663
|
_buildCommandsForPackage(e) {
|
|
5494
5664
|
let t = this.constructor._config || {};
|
|
@@ -5526,63 +5696,65 @@ try {
|
|
|
5526
5696
|
return s;
|
|
5527
5697
|
}
|
|
5528
5698
|
_registerPackageIntoContext(e) {
|
|
5529
|
-
let t = this.
|
|
5699
|
+
let t = this._fs, n = this.constructor._config || {}, r = this._pathDir, i = (e.name || "").split("/").pop().toLowerCase(), a = (e.bin || i).toLowerCase(), o = `/usr/lib/${i}`, s = this._buildCommandsForPackage(e), c = [], l = e.adapter || e.name, u = !!(n.moduleLoader || n.fetch || l === "wllama" || this.constructor._adapters && this.constructor._adapters.has(l)), d = e.wasmPath || (t.exists(`${o}/${a}.wasm`) ? `${o}/${a}.wasm` : null), f = `${o}/package.json`, p = {
|
|
5530
5700
|
name: e.name,
|
|
5531
5701
|
version: e.version || "1.0.0",
|
|
5532
|
-
bin:
|
|
5702
|
+
bin: a,
|
|
5533
5703
|
aliases: e.aliases || [],
|
|
5534
|
-
description: e.description || ""
|
|
5704
|
+
description: e.description || "",
|
|
5705
|
+
...e.interactive ? { interactive: !0 } : {}
|
|
5535
5706
|
};
|
|
5536
|
-
this.
|
|
5537
|
-
for (let { bin: n, Cmd:
|
|
5538
|
-
let a = n.toLowerCase(),
|
|
5539
|
-
if (
|
|
5707
|
+
this._writeFileSafe(f, JSON.stringify(p, null, 2));
|
|
5708
|
+
for (let { bin: n, Cmd: i } of s) {
|
|
5709
|
+
let a = n.toLowerCase(), s;
|
|
5710
|
+
if (d && (!e.type || e.type === "custom-wasm" || e.type === "wasm")) s = d;
|
|
5540
5711
|
else {
|
|
5541
|
-
|
|
5542
|
-
let
|
|
5543
|
-
|
|
5712
|
+
s = `${o}/${a}.js`;
|
|
5713
|
+
let n = this._generateJsCommandSource(e, a);
|
|
5714
|
+
typeof i == "function" && (i.__source = n), !t.isRealFilesystem && typeof i == "function" && u ? this._writeFileSafe(s, i) : this._writeFileSafe(s, n);
|
|
5544
5715
|
try {
|
|
5545
|
-
|
|
5716
|
+
t.setMode(s, 493);
|
|
5546
5717
|
} catch {}
|
|
5547
5718
|
}
|
|
5548
|
-
this._createBinSymlink(
|
|
5719
|
+
this._createBinSymlink(r, a, s), c.push(a);
|
|
5549
5720
|
}
|
|
5550
|
-
for (let
|
|
5551
|
-
let
|
|
5552
|
-
if (!
|
|
5553
|
-
let
|
|
5554
|
-
this._createBinSymlink(
|
|
5721
|
+
for (let t of e.aliases || []) {
|
|
5722
|
+
let n = t.toLowerCase();
|
|
5723
|
+
if (!c.includes(n) && s.length > 0) {
|
|
5724
|
+
let t = d && (!e.type || e.type === "custom-wasm" || e.type === "wasm") ? d : `${o}/${a}.js`;
|
|
5725
|
+
this._createBinSymlink(r, n, t), c.push(n);
|
|
5555
5726
|
}
|
|
5556
5727
|
}
|
|
5557
|
-
let
|
|
5558
|
-
for (let [e, n] of Object.entries(
|
|
5559
|
-
let
|
|
5560
|
-
!
|
|
5728
|
+
let m = e.scriptPaths || {};
|
|
5729
|
+
for (let [e, n] of Object.entries(m)) {
|
|
5730
|
+
let i = e.toLowerCase();
|
|
5731
|
+
!c.includes(i) && t.exists(n) && (this._createBinSymlink(r, i, n), c.push(i));
|
|
5561
5732
|
}
|
|
5562
5733
|
if (e.scripts && typeof e.scripts == "object") for (let n of Object.keys(e.scripts)) {
|
|
5563
|
-
let e = n.toLowerCase(),
|
|
5564
|
-
!
|
|
5734
|
+
let e = n.toLowerCase(), i = `${o}/${e}`;
|
|
5735
|
+
!c.includes(e) && t.exists(i) && (this._createBinSymlink(r, e, i), c.push(e));
|
|
5565
5736
|
}
|
|
5566
|
-
return
|
|
5737
|
+
return c;
|
|
5567
5738
|
}
|
|
5568
5739
|
_createBinSymlink(e, t, n) {
|
|
5569
|
-
let r = `${e}/${t.toLowerCase()}`;
|
|
5740
|
+
let r = this._fs, i = `${e}/${t.toLowerCase()}`;
|
|
5570
5741
|
this._removeBin(e, t);
|
|
5571
5742
|
try {
|
|
5572
|
-
|
|
5743
|
+
r.createSymlink(n, i), r.setMode(i, 493);
|
|
5573
5744
|
} catch {
|
|
5574
|
-
this.
|
|
5745
|
+
this._writeFileSafe(i, r.getFileByPath(n));
|
|
5575
5746
|
try {
|
|
5576
|
-
|
|
5747
|
+
r.setMode(i, 493);
|
|
5577
5748
|
} catch {}
|
|
5578
5749
|
}
|
|
5579
5750
|
}
|
|
5580
5751
|
_removeBin(e, t) {
|
|
5581
5752
|
let n = `${e}/${t.toLowerCase()}`;
|
|
5582
|
-
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
|
|
5753
|
+
this._withWritableParent(n, (e) => {
|
|
5754
|
+
try {
|
|
5755
|
+
e.deleteFileByPath(n);
|
|
5756
|
+
} catch {}
|
|
5757
|
+
});
|
|
5586
5758
|
}
|
|
5587
5759
|
async run() {
|
|
5588
5760
|
let e = [...this.arguments || []], t = e.length >= 2 && e[0].toLowerCase() === "run";
|
|
@@ -5694,9 +5866,9 @@ try {
|
|
|
5694
5866
|
let s;
|
|
5695
5867
|
s = typeof i.text == "function" ? await i.text() : typeof i.arrayBuffer == "function" ? new TextDecoder().decode(new Uint8Array(await i.arrayBuffer())) : "";
|
|
5696
5868
|
let c = `${a}/${e}`;
|
|
5697
|
-
this.
|
|
5869
|
+
this._writeFileSafe(c, s);
|
|
5698
5870
|
try {
|
|
5699
|
-
this.
|
|
5871
|
+
this._fs.setMode(c, 493);
|
|
5700
5872
|
} catch {}
|
|
5701
5873
|
o[e] = c;
|
|
5702
5874
|
}
|
|
@@ -5798,7 +5970,7 @@ try {
|
|
|
5798
5970
|
return null;
|
|
5799
5971
|
}
|
|
5800
5972
|
async _pullPackageWasm(e, t = !1, n = !1, r = null) {
|
|
5801
|
-
let i = this.constructor._config || {}, a = i.fetch || (typeof fetch == "function" ? fetch : null), { loadModule: o } =
|
|
5973
|
+
let i = this.constructor._config || {}, a = i.fetch || (typeof fetch == "function" ? fetch : null), { loadModule: o } = Z(), s = null, c = null, l = e.wasmUrl || (/\.(wasm|wat)(\?.*)?$/i.test(e.cdnUrl || "") ? e.cdnUrl : null);
|
|
5802
5974
|
if (l && a) try {
|
|
5803
5975
|
let n = await a(l);
|
|
5804
5976
|
n && n.ok ? s = await this._readResponseBytes(n, `${e.name}.wasm`, t) : c = /* @__PURE__ */ Error(`HTTP ${n ? n.status : "error"} fetching ${l}`);
|
|
@@ -5812,7 +5984,7 @@ try {
|
|
|
5812
5984
|
r && r.bytes && (s = r.bytes, e.wasmUrl = r.url, c = null);
|
|
5813
5985
|
}
|
|
5814
5986
|
}
|
|
5815
|
-
let
|
|
5987
|
+
let u = null, d = null;
|
|
5816
5988
|
if (e.cdnUrl || i.moduleLoader) {
|
|
5817
5989
|
let t = typeof globalThis.fetch == "function" ? globalThis.fetch : null;
|
|
5818
5990
|
t && s && s.byteLength > 0 && typeof Response < "u" && (globalThis.fetch = async (e, n) => {
|
|
@@ -5823,15 +5995,15 @@ try {
|
|
|
5823
5995
|
}) : t(e, n);
|
|
5824
5996
|
});
|
|
5825
5997
|
try {
|
|
5826
|
-
|
|
5998
|
+
u = await o(e.name, e.cdnUrl, i.moduleLoader);
|
|
5827
5999
|
} catch (e) {
|
|
5828
|
-
if (
|
|
6000
|
+
if (d = e, n) throw e;
|
|
5829
6001
|
} finally {
|
|
5830
6002
|
t && (globalThis.fetch = t);
|
|
5831
6003
|
}
|
|
5832
6004
|
}
|
|
5833
|
-
if (!s &&
|
|
5834
|
-
let e =
|
|
6005
|
+
if (!s && u) {
|
|
6006
|
+
let e = u.default === void 0 ? u : u.default;
|
|
5835
6007
|
e instanceof Uint8Array ? s = e : e instanceof ArrayBuffer ? s = new Uint8Array(e) : e && (e.wasmBytes instanceof Uint8Array || e.wasm instanceof Uint8Array || e.wasmBinary instanceof Uint8Array) && (s = e.wasmBytes || e.wasm || e.wasmBinary);
|
|
5836
6008
|
}
|
|
5837
6009
|
if (!s && e.cdnUrl && a && !i.moduleLoader) try {
|
|
@@ -5878,12 +6050,12 @@ try {
|
|
|
5878
6050
|
2,
|
|
5879
6051
|
0,
|
|
5880
6052
|
11
|
|
5881
|
-
])), !s && !
|
|
6053
|
+
])), !s && !u && (c || d) && !i.moduleLoader) throw c || d;
|
|
5882
6054
|
if (s) {
|
|
5883
6055
|
let t = (e.name || "").split("/").pop().toLowerCase(), n = (e.bin || t).toLowerCase(), i = `${r || `/usr/lib/${t}`}/${n}.wasm`;
|
|
5884
|
-
|
|
6056
|
+
this._writeBytesSafe(i, s, "application/wasm");
|
|
5885
6057
|
try {
|
|
5886
|
-
this.
|
|
6058
|
+
this._fs.setMode(i, 493);
|
|
5887
6059
|
} catch {}
|
|
5888
6060
|
return i;
|
|
5889
6061
|
}
|
|
@@ -5932,12 +6104,14 @@ try {
|
|
|
5932
6104
|
let o = t.endsWith(".wat"), s = o ? ".wat" : ".wasm", c = `${`/usr/lib/${e}`}/${e}${s}`;
|
|
5933
6105
|
if (o) {
|
|
5934
6106
|
let e = await a.text();
|
|
5935
|
-
this.
|
|
6107
|
+
this._writeFileSafe(c, e);
|
|
5936
6108
|
} else {
|
|
5937
6109
|
let e = await a.arrayBuffer();
|
|
5938
|
-
|
|
6110
|
+
this._writeBytesSafe(c, new Uint8Array(e), "application/wasm");
|
|
5939
6111
|
}
|
|
5940
|
-
|
|
6112
|
+
try {
|
|
6113
|
+
this._fs.setMode(c, 493);
|
|
6114
|
+
} catch {}
|
|
5941
6115
|
let l = {
|
|
5942
6116
|
name: e,
|
|
5943
6117
|
bin: e,
|
|
@@ -5957,7 +6131,7 @@ try {
|
|
|
5957
6131
|
this.stdErr = "E: Specify at least one package to remove", this.exitCode = 1;
|
|
5958
6132
|
return;
|
|
5959
6133
|
}
|
|
5960
|
-
let n = this._getInstalledPackages(), r = this._getRegistry(), i = this.
|
|
6134
|
+
let n = this._getInstalledPackages(), r = this._getRegistry(), i = this._pathDir;
|
|
5961
6135
|
for (let e of t) {
|
|
5962
6136
|
let t = c(e), a = n[t] || n[e.toLowerCase()];
|
|
5963
6137
|
if (!a) {
|
|
@@ -5975,7 +6149,7 @@ try {
|
|
|
5975
6149
|
for (let e of s) this._removeBin(i, e);
|
|
5976
6150
|
let l = `/usr/lib/${t}`;
|
|
5977
6151
|
try {
|
|
5978
|
-
this.
|
|
6152
|
+
this._fs.deleteFileByPath(l);
|
|
5979
6153
|
} catch {}
|
|
5980
6154
|
this.stdOut = `Removing ${a.name} (${a.version}) ...`;
|
|
5981
6155
|
}
|
|
@@ -6026,7 +6200,7 @@ try {
|
|
|
6026
6200
|
} catch (t) {
|
|
6027
6201
|
this.stdErr = `W: Failed to fetch ${e}: ${t.message || t}`;
|
|
6028
6202
|
}
|
|
6029
|
-
Object.keys(r).length > 0 && this.
|
|
6203
|
+
Object.keys(r).length > 0 && this._writeFileSafe(`${p}/remote-registry.json`, JSON.stringify(r, null, 2));
|
|
6030
6204
|
let a = this._getRegistry();
|
|
6031
6205
|
this.stdOut = `Reading package lists... Done (${Object.keys(a).length} packages available)`;
|
|
6032
6206
|
}
|
|
@@ -6050,10 +6224,10 @@ try {
|
|
|
6050
6224
|
this.stdErr = `E: Unable to locate package ${t}`, this.exitCode = 100;
|
|
6051
6225
|
return;
|
|
6052
6226
|
}
|
|
6053
|
-
let s =
|
|
6227
|
+
let s = this._fs, l = null, u = this._pathDir;
|
|
6054
6228
|
try {
|
|
6055
|
-
if (a || (
|
|
6056
|
-
let e = await this._pullPackageWasm(o, !0, !1,
|
|
6229
|
+
if (a || (l = `/tmp/.wbt-run-${n}-${Date.now()}`), (o.type === "custom-wasm" || o.type === "wasm") && !o.wasmPath) try {
|
|
6230
|
+
let e = await this._pullPackageWasm(o, !0, !1, l);
|
|
6057
6231
|
e && (o = Object.assign({}, o, { wasmPath: e }));
|
|
6058
6232
|
} catch (e) {
|
|
6059
6233
|
this.stdErr = `E: Failed to fetch ${o.name}: ${e.message || e}`, this.exitCode = 1;
|
|
@@ -6062,40 +6236,58 @@ try {
|
|
|
6062
6236
|
let r = t.toLowerCase(), i;
|
|
6063
6237
|
if (o.scripts && o.scripts[r]) {
|
|
6064
6238
|
let t = o.scriptPaths && o.scriptPaths[r] || `/usr/lib/${n}/${r}`;
|
|
6065
|
-
if (!
|
|
6066
|
-
let e = await this._pullPackageScripts(o, !0,
|
|
6239
|
+
if (!s.exists(t)) try {
|
|
6240
|
+
let e = await this._pullPackageScripts(o, !0, l);
|
|
6067
6241
|
e && e[r] && (t = e[r]);
|
|
6068
6242
|
} catch (e) {
|
|
6069
6243
|
this.stdErr = `E: Failed to fetch script ${r}: ${e.message || e}`, this.exitCode = 1;
|
|
6070
6244
|
return;
|
|
6071
6245
|
}
|
|
6072
|
-
|
|
6246
|
+
let a = (e) => this.context && typeof this.context.getVar == "function" ? this.context.getVar(e) : "", c = l ? `${l}:${u}` : u, d = this.context && this.context.vars ? Object.assign({}, this.context.vars) : {
|
|
6247
|
+
HOME: a("HOME") || "/root",
|
|
6248
|
+
HOST: a("HOST") || "browser",
|
|
6249
|
+
COLUMNS: String(this.stdout && this.stdout.columns || a("COLUMNS") || 80),
|
|
6250
|
+
LINES: String(this.stdout && this.stdout.rows || a("LINES") || 24)
|
|
6251
|
+
};
|
|
6252
|
+
d.PATH = c;
|
|
6253
|
+
let f = {
|
|
6254
|
+
vars: d,
|
|
6255
|
+
aliases: this.context && this.context.aliases || {},
|
|
6256
|
+
getVar: (e) => e === "PATH" ? c : d[e] || a(e),
|
|
6257
|
+
getAlias: (e) => this.context && typeof this.context.getAlias == "function" ? this.context.getAlias(e) : null,
|
|
6258
|
+
getCommand: (e) => this.context && typeof this.context.getCommand == "function" ? this.context.getCommand(e) : null
|
|
6259
|
+
};
|
|
6260
|
+
i = new (re())(s.getFileByPath(t), e, f), i.fs = s;
|
|
6073
6261
|
} else {
|
|
6074
6262
|
let t = this._buildCommandsForPackage(o), n = (t.find((e) => e.bin === r) || t[0]).Cmd;
|
|
6075
|
-
i = new n(e, this.context);
|
|
6263
|
+
i = new n(e, this.context), i.requiresFilesystem && (i.fs = typeof s.sandbox == "function" ? s.sandbox() : s);
|
|
6076
6264
|
}
|
|
6077
|
-
i.
|
|
6078
|
-
let c = (
|
|
6265
|
+
this._activeSubCommand = i, this._onStdinStreamData && this.stdinStream && typeof this.stdinStream.off == "function" && this.stdinStream.off("data", this._onStdinStreamData), i.stdinStream = this.stdinStream, i.stdin = this.stdin && !this.stdin.isTTY ? this.stdin : this.stdinStream, i._onStdinStreamData && this.stdinStream && typeof this.stdinStream.on == "function" && this.stdinStream.on("data", i._onStdinStreamData), this.stdout && i.stdout && (this.stdout.columns && (i.stdout.columns = this.stdout.columns), this.stdout.rows && (i.stdout.rows = this.stdout.rows)), this.stderr && i.stderr && (this.stderr.columns && (i.stderr.columns = this.stderr.columns), this.stderr.rows && (i.stderr.rows = this.stderr.rows));
|
|
6266
|
+
let c = () => {
|
|
6267
|
+
!this.stdout || !i.stdout || (typeof i.stdout.resize == "function" ? i.stdout.resize(this.stdout.columns, this.stdout.rows) : (i.stdout.columns = this.stdout.columns, i.stdout.rows = this.stdout.rows));
|
|
6268
|
+
};
|
|
6269
|
+
this.stdout && typeof this.stdout.on == "function" && this.stdout.on("resize", c);
|
|
6270
|
+
let d = (e) => {
|
|
6079
6271
|
this.stdout && typeof this.stdout.write == "function" && this.stdout.write(e);
|
|
6080
|
-
}, d = (e) => {
|
|
6081
|
-
this.stderr && typeof this.stderr.write == "function" && this.stderr.write(e);
|
|
6082
6272
|
}, f = (e) => {
|
|
6273
|
+
this.stderr && typeof this.stderr.write == "function" && this.stderr.write(e);
|
|
6274
|
+
}, p = (e) => {
|
|
6083
6275
|
let t = Array.isArray(e) ? e : e && typeof e.getStdOutput == "function" ? e.getStdOutput() : [];
|
|
6084
6276
|
for (let e of t) e.type === "out" ? this.stdOut = e.string : e.type === "err" && (this.stdErr = e.string);
|
|
6085
6277
|
this.flush();
|
|
6086
6278
|
};
|
|
6087
|
-
i.stdout && typeof i.stdout.on == "function" && i.stdout.on("data",
|
|
6088
|
-
let
|
|
6279
|
+
i.stdout && typeof i.stdout.on == "function" && i.stdout.on("data", d), i.stderr && typeof i.stderr.on == "function" && i.stderr.on("data", f), typeof i.on == "function" && i.on("flush", p);
|
|
6280
|
+
let m;
|
|
6089
6281
|
try {
|
|
6090
|
-
|
|
6282
|
+
m = await i.runCommand();
|
|
6091
6283
|
} finally {
|
|
6092
|
-
this._activeSubCommand = null, i.stdout && typeof i.stdout.off == "function" && i.stdout.off("data",
|
|
6284
|
+
this._activeSubCommand = null, this.stdout && typeof this.stdout.off == "function" && this.stdout.off("resize", c), i._onStdinStreamData && this.stdinStream && typeof this.stdinStream.off == "function" && this.stdinStream.off("data", i._onStdinStreamData), this._onStdinStreamData && this.stdinStream && typeof this.stdinStream.on == "function" && this.stdinStream.on("data", this._onStdinStreamData), i.stdout && typeof i.stdout.off == "function" && i.stdout.off("data", d), i.stderr && typeof i.stderr.off == "function" && i.stderr.off("data", f), typeof i.removeListener == "function" && i.removeListener("flush", p);
|
|
6093
6285
|
}
|
|
6094
|
-
if (!i.interactive &&
|
|
6095
|
-
this.exitCode =
|
|
6286
|
+
if (!i.interactive && m) for (let e of m.getStdOutput()) e.type === "out" ? this.stdOut = e.string : e.type === "err" && (this.stdErr = e.string);
|
|
6287
|
+
this.exitCode = m ? m.getExitCode() : 0;
|
|
6096
6288
|
} finally {
|
|
6097
|
-
if (
|
|
6098
|
-
|
|
6289
|
+
if (l && s) try {
|
|
6290
|
+
s.deleteFileByPath(l);
|
|
6099
6291
|
} catch {}
|
|
6100
6292
|
}
|
|
6101
6293
|
}
|
|
@@ -6135,6 +6327,6 @@ try {
|
|
|
6135
6327
|
t.exports = h, t.exports.Wbt = h, t.exports.DEFAULT_REGISTRY = s, t.exports.createGenericWasmCommand = d, t.exports.createReplWasmCommand = f;
|
|
6136
6328
|
}));
|
|
6137
6329
|
//#endregion
|
|
6138
|
-
export default
|
|
6330
|
+
export default ce();
|
|
6139
6331
|
|
|
6140
6332
|
//# sourceMappingURL=wbt.es.js.map
|