brsh 3.0.0 → 3.1.1
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/POSIX-CHECKLIST.md +3 -3
- package/Readme.md +138 -223
- package/bin/Readme.md +70 -24
- package/dist/shell.es.js +353 -334
- package/dist/shell.es.js.map +1 -1
- package/dist/shell.min.js +7 -7
- package/dist/shell.min.js.map +1 -1
- package/dist/wbt.es.js +198 -176
- package/dist/wbt.es.js.map +1 -1
- package/dist/wbt.min.js +7 -7
- package/dist/wbt.min.js.map +1 -1
- package/index.js +20 -0
- package/lib/Readme.md +111 -12
- package/lib/WasmCommand.js +26 -5
- package/lib/wbt/index.js +3 -2
- package/lib/wbt/registry.js +15 -1
- package/package.json +1 -1
- package/test/shell.test.js +49 -0
- package/test/wbt.test.js +92 -0
package/dist/wbt.es.js
CHANGED
|
@@ -620,24 +620,24 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
|
|
|
620
620
|
}), u.prototype.writeBigInt64BE = $(function(e, t = 0) {
|
|
621
621
|
return G(this, e, t, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
|
|
622
622
|
});
|
|
623
|
-
function
|
|
623
|
+
function ee(e, t, n, r, i, a) {
|
|
624
624
|
if (n + r > e.length || n < 0) throw RangeError("Index out of range");
|
|
625
625
|
}
|
|
626
|
-
function
|
|
627
|
-
return t = +t, r >>>= 0, a ||
|
|
626
|
+
function K(e, t, r, i, a) {
|
|
627
|
+
return t = +t, r >>>= 0, a || ee(e, t, r, 4), n.write(e, t, r, i, 23, 4), r + 4;
|
|
628
628
|
}
|
|
629
629
|
u.prototype.writeFloatLE = function(e, t, n) {
|
|
630
|
-
return
|
|
630
|
+
return K(this, e, t, !0, n);
|
|
631
631
|
}, u.prototype.writeFloatBE = function(e, t, n) {
|
|
632
|
-
return
|
|
632
|
+
return K(this, e, t, !1, n);
|
|
633
633
|
};
|
|
634
|
-
function
|
|
635
|
-
return t = +t, r >>>= 0, a ||
|
|
634
|
+
function te(e, t, r, i, a) {
|
|
635
|
+
return t = +t, r >>>= 0, a || ee(e, t, r, 8), n.write(e, t, r, i, 52, 8), r + 8;
|
|
636
636
|
}
|
|
637
637
|
u.prototype.writeDoubleLE = function(e, t, n) {
|
|
638
|
-
return
|
|
638
|
+
return te(this, e, t, !0, n);
|
|
639
639
|
}, u.prototype.writeDoubleBE = function(e, t, n) {
|
|
640
|
-
return
|
|
640
|
+
return te(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 q = {};
|
|
672
|
+
function J(e, t, n) {
|
|
673
|
+
q[e] = class extends n {
|
|
674
674
|
constructor() {
|
|
675
675
|
super(), Object.defineProperty(this, "message", {
|
|
676
676
|
value: t.apply(this, arguments),
|
|
@@ -694,34 +694,34 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
|
|
|
694
694
|
}
|
|
695
695
|
};
|
|
696
696
|
}
|
|
697
|
-
|
|
697
|
+
J("ERR_BUFFER_OUT_OF_BOUNDS", function(e) {
|
|
698
698
|
return e ? `${e} is outside of buffer bounds` : "Attempt to access memory outside buffer bounds";
|
|
699
|
-
}, RangeError),
|
|
699
|
+
}, RangeError), J("ERR_INVALID_ARG_TYPE", function(e, t) {
|
|
700
700
|
return `The "${e}" argument must be of type number. Received type ${typeof t}`;
|
|
701
|
-
}, TypeError),
|
|
701
|
+
}, TypeError), J("ERR_OUT_OF_RANGE", function(e, t, n) {
|
|
702
702
|
let r = `The value of "${e}" is out of range.`, i = n;
|
|
703
|
-
return Number.isInteger(n) && Math.abs(n) > 2 ** 32 ? i =
|
|
703
|
+
return Number.isInteger(n) && Math.abs(n) > 2 ** 32 ? i = ne(String(n)) : typeof n == "bigint" && (i = String(n), (n > BigInt(2) ** BigInt(32) || n < -(BigInt(2) ** BigInt(32))) && (i = ne(i)), i += "n"), r += ` It must be ${t}. Received ${i}`, r;
|
|
704
704
|
}, RangeError);
|
|
705
|
-
function
|
|
705
|
+
function ne(e) {
|
|
706
706
|
let t = "", n = e.length, r = +(e[0] === "-");
|
|
707
707
|
for (; n >= r + 4; n -= 3) t = `_${e.slice(n - 3, n)}${t}`;
|
|
708
708
|
return `${e.slice(0, n)}${t}`;
|
|
709
709
|
}
|
|
710
|
-
function
|
|
710
|
+
function Y(e, t, n) {
|
|
711
711
|
X(t, "offset"), (e[t] === void 0 || e[t + n] === void 0) && Z(t, e.length - (n + 1));
|
|
712
712
|
}
|
|
713
713
|
function re(e, t, n, r, i, a) {
|
|
714
714
|
if (e > n || e < t) {
|
|
715
715
|
let r = typeof t == "bigint" ? "n" : "", i;
|
|
716
|
-
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 q.ERR_OUT_OF_RANGE("value", i, e);
|
|
717
717
|
}
|
|
718
|
-
|
|
718
|
+
Y(r, i, a);
|
|
719
719
|
}
|
|
720
720
|
function X(e, t) {
|
|
721
|
-
if (typeof e != "number") throw new
|
|
721
|
+
if (typeof e != "number") throw new q.ERR_INVALID_ARG_TYPE(t, "number", e);
|
|
722
722
|
}
|
|
723
723
|
function Z(e, t, n) {
|
|
724
|
-
throw Math.floor(e) === e ? t < 0 ? new
|
|
724
|
+
throw Math.floor(e) === e ? t < 0 ? new q.ERR_BUFFER_OUT_OF_BOUNDS() : new q.ERR_OUT_OF_RANGE(n || "offset", `>= ${+!!n} and <= ${t}`, e) : (X(e, n), new q.ERR_OUT_OF_RANGE(n || "offset", "an integer", e));
|
|
725
725
|
}
|
|
726
726
|
let ie = /[^+/0-9A-Za-z-_]/g;
|
|
727
727
|
function ae(e) {
|
|
@@ -1679,7 +1679,7 @@ function I(e, t) {
|
|
|
1679
1679
|
this.fun = e, this.array = t;
|
|
1680
1680
|
}
|
|
1681
1681
|
function L() {}
|
|
1682
|
-
var R, z, B, V, H, U, W, G,
|
|
1682
|
+
var R, z, B, V, H, U, W, G, ee, K, te = e((() => {
|
|
1683
1683
|
R = { exports: {} }, z = R.exports = {}, (function() {
|
|
1684
1684
|
try {
|
|
1685
1685
|
B = typeof setTimeout == "function" ? setTimeout : A;
|
|
@@ -1707,8 +1707,8 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
|
|
|
1707
1707
|
throw Error("process.chdir is not supported");
|
|
1708
1708
|
}, z.umask = function() {
|
|
1709
1709
|
return 0;
|
|
1710
|
-
},
|
|
1711
|
-
})),
|
|
1710
|
+
}, ee = R.exports, K = /* @__PURE__ */ k(ee);
|
|
1711
|
+
})), q = /* @__PURE__ */ t(((e, t) => {
|
|
1712
1712
|
var n = T();
|
|
1713
1713
|
t.exports = class extends n {
|
|
1714
1714
|
get captureInput() {
|
|
@@ -1738,8 +1738,8 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
|
|
|
1738
1738
|
});
|
|
1739
1739
|
}
|
|
1740
1740
|
};
|
|
1741
|
-
})),
|
|
1742
|
-
b(),
|
|
1741
|
+
})), J = /* @__PURE__ */ t(((e, t) => {
|
|
1742
|
+
b(), te();
|
|
1743
1743
|
var { BinaryFile: n, SymlinkRef: r } = O(), i = new Uint8Array([
|
|
1744
1744
|
66,
|
|
1745
1745
|
82,
|
|
@@ -1844,7 +1844,7 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
|
|
|
1844
1844
|
let t = e.$c;
|
|
1845
1845
|
if (m[t]) return m[t];
|
|
1846
1846
|
if (f.inlineCommands && f.inlineCommands[t]) try {
|
|
1847
|
-
let e = T(), n =
|
|
1847
|
+
let e = T(), n = q();
|
|
1848
1848
|
return Function("Command", "InteractiveCommand", `return (${f.inlineCommands[t]});`)(e, n);
|
|
1849
1849
|
} catch {
|
|
1850
1850
|
return null;
|
|
@@ -1876,8 +1876,8 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
|
|
|
1876
1876
|
let t = new DecompressionStream("gzip"), n = new Blob([e]).stream().pipeThrough(t), r = await new Response(n).arrayBuffer();
|
|
1877
1877
|
return new Uint8Array(r);
|
|
1878
1878
|
}
|
|
1879
|
-
if (
|
|
1880
|
-
let t =
|
|
1879
|
+
if (K !== void 0 && typeof K.getBuiltinModule == "function") {
|
|
1880
|
+
let t = K.getBuiltinModule("zlib");
|
|
1881
1881
|
if (t) return new Uint8Array(t.gunzipSync(y.from(e.buffer, e.byteOffset, e.byteLength)));
|
|
1882
1882
|
}
|
|
1883
1883
|
throw Error("Gzip decompression is not supported in this environment");
|
|
@@ -1896,8 +1896,8 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
|
|
|
1896
1896
|
return f(new Uint8Array(n), t);
|
|
1897
1897
|
}
|
|
1898
1898
|
if (typeof e == "string") {
|
|
1899
|
-
if (!/^https?:\/\//i.test(e) &&
|
|
1900
|
-
let n =
|
|
1899
|
+
if (!/^https?:\/\//i.test(e) && K !== void 0 && typeof K.getBuiltinModule == "function" && typeof window > "u") try {
|
|
1900
|
+
let n = K.getBuiltinModule("fs");
|
|
1901
1901
|
if (n && n.existsSync(e)) {
|
|
1902
1902
|
let r = await n.promises.readFile(e);
|
|
1903
1903
|
return f(new Uint8Array(r.buffer, r.byteOffset, r.byteLength), t);
|
|
@@ -2009,7 +2009,7 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
|
|
|
2009
2009
|
}
|
|
2010
2010
|
}
|
|
2011
2011
|
};
|
|
2012
|
-
})),
|
|
2012
|
+
})), ne = /* @__PURE__ */ t(((e, t) => {
|
|
2013
2013
|
b();
|
|
2014
2014
|
var n = O(), { BinaryFile: r, SymlinkRef: i } = n;
|
|
2015
2015
|
function a(e) {
|
|
@@ -2034,20 +2034,20 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
|
|
|
2034
2034
|
t.exports = class extends n {
|
|
2035
2035
|
constructor(e = "/", t = {}, n = {}, r = null) {
|
|
2036
2036
|
if (super(), t instanceof Uint8Array || t instanceof ArrayBuffer) {
|
|
2037
|
-
let { deserializeBinaryFilesystem: e } =
|
|
2037
|
+
let { deserializeBinaryFilesystem: e } = J(), r = e(t);
|
|
2038
2038
|
t = r.filesystem, n = Object.assign({}, r.permissions, n);
|
|
2039
2039
|
} else if (t && typeof t == "object" && t.filesystem && (t.filesystem instanceof Uint8Array || typeof t.filesystem == "object") && (n = Object.assign({}, t.permissions || {}, n), t = t.filesystem, t instanceof Uint8Array || t instanceof ArrayBuffer)) {
|
|
2040
|
-
let { deserializeBinaryFilesystem: e } =
|
|
2040
|
+
let { deserializeBinaryFilesystem: e } = J(), r = e(t);
|
|
2041
2041
|
t = r.filesystem, n = Object.assign({}, r.permissions, n);
|
|
2042
2042
|
}
|
|
2043
2043
|
a(t), this.fileSystem = t, this.permissions = Object.assign({}, n), this.cwd = e, this._onChange = r, this._changeScheduled = !1;
|
|
2044
2044
|
}
|
|
2045
2045
|
toBinaryContainer(e = {}) {
|
|
2046
|
-
let { serializeBinaryFilesystem: t } =
|
|
2046
|
+
let { serializeBinaryFilesystem: t } = J();
|
|
2047
2047
|
return t(this.fileSystem, this.permissions, e);
|
|
2048
2048
|
}
|
|
2049
2049
|
static fromBinaryContainer(e, t = {}) {
|
|
2050
|
-
let { deserializeBinaryFilesystem: n } =
|
|
2050
|
+
let { deserializeBinaryFilesystem: n } = J();
|
|
2051
2051
|
return n(e, t);
|
|
2052
2052
|
}
|
|
2053
2053
|
getFileByPath(e) {
|
|
@@ -2225,10 +2225,10 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
|
|
|
2225
2225
|
return null;
|
|
2226
2226
|
}
|
|
2227
2227
|
}, t.exports.BinaryFile = r, t.exports.SymlinkRef = i;
|
|
2228
|
-
})),
|
|
2228
|
+
})), Y = /* @__PURE__ */ t(((e, t) => {
|
|
2229
2229
|
t.exports = null;
|
|
2230
2230
|
})), re = /* @__PURE__ */ t(((e, t) => {
|
|
2231
|
-
|
|
2231
|
+
te();
|
|
2232
2232
|
function n(e) {
|
|
2233
2233
|
if (typeof e != "string") throw TypeError("Path must be a string. Received " + JSON.stringify(e));
|
|
2234
2234
|
}
|
|
@@ -2266,7 +2266,7 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
|
|
|
2266
2266
|
resolve: function() {
|
|
2267
2267
|
for (var e = "", t = !1, i, a = arguments.length - 1; a >= -1 && !t; a--) {
|
|
2268
2268
|
var o;
|
|
2269
|
-
a >= 0 ? o = arguments[a] : (i === void 0 && (i =
|
|
2269
|
+
a >= 0 ? o = arguments[a] : (i === void 0 && (i = K.cwd()), o = i), n(o), o.length !== 0 && (e = o + "/" + e, t = o.charCodeAt(0) === 47);
|
|
2270
2270
|
}
|
|
2271
2271
|
return e = r(e, !t), t ? e.length > 0 ? "/" + e : "/" : e.length > 0 ? e : ".";
|
|
2272
2272
|
},
|
|
@@ -2397,7 +2397,7 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
|
|
|
2397
2397
|
a.posix = a, t.exports = a;
|
|
2398
2398
|
})), X = /* @__PURE__ */ t(((e, t) => {
|
|
2399
2399
|
b();
|
|
2400
|
-
var n = D(), { BinaryFile: r } =
|
|
2400
|
+
var n = D(), { BinaryFile: r } = ne(), i = 0, a = 8, o = 20, s = 28, c = 31, l = 44, u = 54, d = 70, f = 0, p = 2, m = 3, h = 4, g = 1, _ = 2, v = 4, x = 8, S = 1, C = class extends n {
|
|
2401
2401
|
get name() {
|
|
2402
2402
|
return "wasm";
|
|
2403
2403
|
}
|
|
@@ -2407,7 +2407,7 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
|
|
|
2407
2407
|
run() {
|
|
2408
2408
|
let e = this.script, t = (() => {
|
|
2409
2409
|
try {
|
|
2410
|
-
return
|
|
2410
|
+
return Y();
|
|
2411
2411
|
} catch {
|
|
2412
2412
|
return null;
|
|
2413
2413
|
}
|
|
@@ -2473,29 +2473,29 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
|
|
|
2473
2473
|
let t = {
|
|
2474
2474
|
1: "",
|
|
2475
2475
|
2: ""
|
|
2476
|
-
}, n = new TextDecoder(),
|
|
2476
|
+
}, n = new TextDecoder(), b = new TextEncoder(), C = null, w = (e, n) => {
|
|
2477
2477
|
t[e] = (t[e] || "") + n;
|
|
2478
2478
|
let r = t[e].split("\n");
|
|
2479
2479
|
t[e] = r.pop();
|
|
2480
2480
|
for (let t of r) e === 1 ? this.stdOut = t : this.stdErr = t;
|
|
2481
|
-
},
|
|
2481
|
+
}, T = () => {
|
|
2482
2482
|
t[1] &&= (this.stdOut = t[1], ""), t[2] &&= (this.stdErr = t[2], "");
|
|
2483
|
-
},
|
|
2483
|
+
}, E = typeof this.stdin == "string" ? b.encode(this.stdin) : this.stdin instanceof Uint8Array ? this.stdin : y !== void 0 && y.isBuffer(this.stdin) ? new Uint8Array(this.stdin) : new Uint8Array(), D = 0, O = this.context && this.context.fs ? this.context.fs : this.fs, k = 5, A = new Map([[3, {
|
|
2484
2484
|
type: "preopen",
|
|
2485
2485
|
path: "/",
|
|
2486
2486
|
guestName: "/"
|
|
2487
2487
|
}], [4, {
|
|
2488
2488
|
type: "preopen",
|
|
2489
|
-
path:
|
|
2489
|
+
path: O && O.cwd || "/",
|
|
2490
2490
|
guestName: "."
|
|
2491
|
-
}]]),
|
|
2492
|
-
let n =
|
|
2491
|
+
}]]), N = (e, t) => {
|
|
2492
|
+
let n = A.get(e);
|
|
2493
2493
|
if (!n || n.type !== "preopen" && n.type !== "dir") return null;
|
|
2494
|
-
if (t.startsWith("/")) return
|
|
2494
|
+
if (t.startsWith("/")) return O.absolutePath(t);
|
|
2495
2495
|
let r = n.path.endsWith("/") ? n.path : n.path + "/";
|
|
2496
|
-
return
|
|
2497
|
-
},
|
|
2498
|
-
if (!(!e || e.type !== "file" || !e.dirty || !
|
|
2496
|
+
return O.absolutePath(r + t);
|
|
2497
|
+
}, P = (e) => {
|
|
2498
|
+
if (!(!e || e.type !== "file" || !e.dirty || !O)) try {
|
|
2499
2499
|
let t = !0;
|
|
2500
2500
|
for (let n = 0; n < e.bytes.length; n++) if (e.bytes[n] === 0) {
|
|
2501
2501
|
t = !1;
|
|
@@ -2503,32 +2503,32 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
|
|
|
2503
2503
|
}
|
|
2504
2504
|
if (t) {
|
|
2505
2505
|
let t = n.decode(e.bytes);
|
|
2506
|
-
|
|
2506
|
+
O.setFileByPath(e.path, t, !0);
|
|
2507
2507
|
} else {
|
|
2508
2508
|
let t = new Uint8Array(e.bytes.length);
|
|
2509
|
-
t.set(e.bytes),
|
|
2509
|
+
t.set(e.bytes), O.setFileByPath(e.path, new r(t.buffer, "application/octet-stream"), !0);
|
|
2510
2510
|
}
|
|
2511
2511
|
e.dirty = !1;
|
|
2512
2512
|
} catch {}
|
|
2513
|
-
},
|
|
2513
|
+
}, F = Object.entries(this.context && this.context.vars || {}).map(([e, t]) => `${e}=${t}`), I = new Proxy({
|
|
2514
2514
|
fd_write: (e, t, r, o) => {
|
|
2515
|
-
if (!
|
|
2516
|
-
let s = new DataView(
|
|
2515
|
+
if (!C) return a;
|
|
2516
|
+
let s = new DataView(C.buffer);
|
|
2517
2517
|
if (e === 1 || e === 2) {
|
|
2518
2518
|
let a = 0;
|
|
2519
2519
|
for (let i = 0; i < r; i++) {
|
|
2520
2520
|
let r = s.getUint32(t + i * 8, !0), o = s.getUint32(t + i * 8 + 4, !0);
|
|
2521
|
-
o > 0 &&
|
|
2521
|
+
o > 0 && w(e, n.decode(new Uint8Array(C.buffer, r, o))), a += o;
|
|
2522
2522
|
}
|
|
2523
2523
|
return s.setUint32(o, a, !0), i;
|
|
2524
2524
|
}
|
|
2525
|
-
let c =
|
|
2525
|
+
let c = A.get(e);
|
|
2526
2526
|
if (!c || c.type !== "file") return a;
|
|
2527
2527
|
let l = 0;
|
|
2528
2528
|
for (let e = 0; e < r; e++) {
|
|
2529
2529
|
let n = s.getUint32(t + e * 8, !0), r = s.getUint32(t + e * 8 + 4, !0);
|
|
2530
2530
|
if (r > 0) {
|
|
2531
|
-
let e = new Uint8Array(
|
|
2531
|
+
let e = new Uint8Array(C.buffer, n, r), t = c.append ? c.bytes.length : c.pos, i = t + r;
|
|
2532
2532
|
if (i > c.bytes.length) {
|
|
2533
2533
|
let e = new Uint8Array(i);
|
|
2534
2534
|
e.set(c.bytes), c.bytes = e;
|
|
@@ -2539,29 +2539,29 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
|
|
|
2539
2539
|
return s.setUint32(o, l, !0), i;
|
|
2540
2540
|
},
|
|
2541
2541
|
fd_read: (e, t, n, r) => {
|
|
2542
|
-
if (!
|
|
2543
|
-
let o = new DataView(
|
|
2542
|
+
if (!C) return a;
|
|
2543
|
+
let o = new DataView(C.buffer);
|
|
2544
2544
|
if (e === 0) {
|
|
2545
2545
|
let e = 0;
|
|
2546
|
-
for (let r = 0; r < n &&
|
|
2547
|
-
let n = o.getUint32(t + r * 8, !0), i = o.getUint32(t + r * 8 + 4, !0), a = Math.min(i,
|
|
2548
|
-
new Uint8Array(
|
|
2546
|
+
for (let r = 0; r < n && D < E.length; r++) {
|
|
2547
|
+
let n = o.getUint32(t + r * 8, !0), i = o.getUint32(t + r * 8 + 4, !0), a = Math.min(i, E.length - D);
|
|
2548
|
+
new Uint8Array(C.buffer).set(E.slice(D, D + a), n), D += a, e += a;
|
|
2549
2549
|
}
|
|
2550
2550
|
return o.setUint32(r, e, !0), i;
|
|
2551
2551
|
}
|
|
2552
|
-
let s =
|
|
2552
|
+
let s = A.get(e);
|
|
2553
2553
|
if (!s || s.type !== "file") return a;
|
|
2554
2554
|
let c = 0;
|
|
2555
2555
|
for (let e = 0; e < n && s.pos < s.bytes.length; e++) {
|
|
2556
2556
|
let n = o.getUint32(t + e * 8, !0), r = o.getUint32(t + e * 8 + 4, !0), i = Math.min(r, s.bytes.length - s.pos);
|
|
2557
|
-
new Uint8Array(
|
|
2557
|
+
new Uint8Array(C.buffer).set(s.bytes.subarray(s.pos, s.pos + i), n), s.pos += i, c += i;
|
|
2558
2558
|
}
|
|
2559
2559
|
return o.setUint32(r, c, !0), i;
|
|
2560
2560
|
},
|
|
2561
2561
|
fd_seek: (e, t, n, r, o) => {
|
|
2562
|
-
if (!
|
|
2562
|
+
if (!C) return a;
|
|
2563
2563
|
if (e <= 2) return d;
|
|
2564
|
-
let c =
|
|
2564
|
+
let c = A.get(e);
|
|
2565
2565
|
if (!c || c.type !== "file") return a;
|
|
2566
2566
|
let l, u, f;
|
|
2567
2567
|
typeof t == "bigint" ? (l = Number(t), u = n, f = r) : (l = t, u = r, f = o);
|
|
@@ -2570,46 +2570,46 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
|
|
|
2570
2570
|
else if (u === 1) p = c.pos + l;
|
|
2571
2571
|
else if (u === 2) p = c.bytes.length + l;
|
|
2572
2572
|
else return s;
|
|
2573
|
-
return p < 0 ? s : (c.pos = p, f && new DataView(
|
|
2573
|
+
return p < 0 ? s : (c.pos = p, f && new DataView(C.buffer).setBigUint64(f, BigInt(c.pos), !0), i);
|
|
2574
2574
|
},
|
|
2575
2575
|
fd_tell: (e, t) => {
|
|
2576
|
-
if (!
|
|
2577
|
-
let n =
|
|
2578
|
-
return !n || n.type !== "file" ? a : (new DataView(
|
|
2576
|
+
if (!C) return a;
|
|
2577
|
+
let n = A.get(e);
|
|
2578
|
+
return !n || n.type !== "file" ? a : (new DataView(C.buffer).setBigUint64(t, BigInt(n.pos), !0), i);
|
|
2579
2579
|
},
|
|
2580
2580
|
fd_close: (e) => {
|
|
2581
2581
|
if (e <= 2) return i;
|
|
2582
|
-
let t =
|
|
2583
|
-
return t ? (
|
|
2582
|
+
let t = A.get(e);
|
|
2583
|
+
return t ? (P(t), A.delete(e), i) : a;
|
|
2584
2584
|
},
|
|
2585
2585
|
fd_sync: (e) => {
|
|
2586
|
-
let t =
|
|
2587
|
-
return t &&
|
|
2586
|
+
let t = A.get(e);
|
|
2587
|
+
return t && P(t), i;
|
|
2588
2588
|
},
|
|
2589
2589
|
fd_datasync: (e) => {
|
|
2590
|
-
let t =
|
|
2591
|
-
return t &&
|
|
2590
|
+
let t = A.get(e);
|
|
2591
|
+
return t && P(t), i;
|
|
2592
2592
|
},
|
|
2593
2593
|
fd_prestat_get: (e, t) => {
|
|
2594
|
-
if (!
|
|
2595
|
-
let n =
|
|
2594
|
+
if (!C) return a;
|
|
2595
|
+
let n = A.get(e);
|
|
2596
2596
|
if (!n || n.type !== "preopen") return a;
|
|
2597
|
-
let r = new DataView(
|
|
2597
|
+
let r = new DataView(C.buffer), o = b.encode(n.guestName);
|
|
2598
2598
|
return r.setUint8(t, 0), r.setUint32(t + 4, o.length, !0), i;
|
|
2599
2599
|
},
|
|
2600
2600
|
fd_prestat_dir_name: (e, t, n) => {
|
|
2601
|
-
if (!
|
|
2602
|
-
let r =
|
|
2601
|
+
if (!C) return a;
|
|
2602
|
+
let r = A.get(e);
|
|
2603
2603
|
if (!r || r.type !== "preopen") return a;
|
|
2604
|
-
let o =
|
|
2605
|
-
return new Uint8Array(
|
|
2604
|
+
let o = b.encode(r.guestName);
|
|
2605
|
+
return new Uint8Array(C.buffer, t, Math.min(n, o.length)).set(o.subarray(0, n)), i;
|
|
2606
2606
|
},
|
|
2607
2607
|
fd_fdstat_get: (e, t) => {
|
|
2608
|
-
if (!
|
|
2609
|
-
let n = new DataView(
|
|
2608
|
+
if (!C) return a;
|
|
2609
|
+
let n = new DataView(C.buffer), r = f;
|
|
2610
2610
|
if (e <= 2) r = p;
|
|
2611
2611
|
else {
|
|
2612
|
-
let t =
|
|
2612
|
+
let t = A.get(e);
|
|
2613
2613
|
if (!t) return a;
|
|
2614
2614
|
r = t.type === "preopen" || t.type === "dir" ? m : h;
|
|
2615
2615
|
}
|
|
@@ -2618,83 +2618,83 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
|
|
|
2618
2618
|
},
|
|
2619
2619
|
fd_fdstat_set_flags: () => i,
|
|
2620
2620
|
fd_filestat_get: (e, t) => {
|
|
2621
|
-
if (!
|
|
2622
|
-
let n = new DataView(
|
|
2621
|
+
if (!C) return a;
|
|
2622
|
+
let n = new DataView(C.buffer);
|
|
2623
2623
|
for (let e = 0; e < 64; e++) n.setUint8(t + e, 0);
|
|
2624
2624
|
if (e <= 2) return n.setUint8(t + 16, p), i;
|
|
2625
|
-
let r =
|
|
2625
|
+
let r = A.get(e);
|
|
2626
2626
|
if (!r) return a;
|
|
2627
2627
|
let o = r.type === "preopen" || r.type === "dir";
|
|
2628
2628
|
return n.setUint8(t + 16, o ? m : h), n.setBigUint64(t + 24, 1n, !0), n.setBigUint64(t + 32, BigInt(r.bytes ? r.bytes.length : 0), !0), i;
|
|
2629
2629
|
},
|
|
2630
2630
|
path_open: (e, t, r, s, d, f, p, m, h) => {
|
|
2631
|
-
if (!
|
|
2632
|
-
let
|
|
2633
|
-
if (!
|
|
2634
|
-
let w =
|
|
2631
|
+
if (!C || !O) return a;
|
|
2632
|
+
let y = N(e, n.decode(new Uint8Array(C.buffer, r, s)));
|
|
2633
|
+
if (!y) return a;
|
|
2634
|
+
let w = O.stat(y), T = w !== null;
|
|
2635
2635
|
if (d & v && d & g && T) return o;
|
|
2636
2636
|
if (d & _) {
|
|
2637
2637
|
if (!T) return l;
|
|
2638
2638
|
if (!w.isDirectory) return u;
|
|
2639
|
-
let e =
|
|
2640
|
-
return
|
|
2639
|
+
let e = k++;
|
|
2640
|
+
return A.set(e, {
|
|
2641
2641
|
type: "dir",
|
|
2642
|
-
path:
|
|
2643
|
-
}), new DataView(
|
|
2642
|
+
path: y
|
|
2643
|
+
}), new DataView(C.buffer).setUint32(h, e, !0), i;
|
|
2644
2644
|
}
|
|
2645
2645
|
if (T && w.isDirectory) return c;
|
|
2646
2646
|
if (!T && !(d & g)) return l;
|
|
2647
|
-
let E = new Uint8Array(),
|
|
2647
|
+
let E = new Uint8Array(), D = !1;
|
|
2648
2648
|
if (T && !(d & x)) {
|
|
2649
|
-
let e =
|
|
2650
|
-
e != null && (E = typeof e == "string" ?
|
|
2651
|
-
} else
|
|
2652
|
-
let
|
|
2653
|
-
return
|
|
2649
|
+
let e = O.getFileByPath(y);
|
|
2650
|
+
e != null && (E = typeof e == "string" ? b.encode(e) : new Uint8Array(this._contentToBytes(e)));
|
|
2651
|
+
} else D = !0;
|
|
2652
|
+
let j = k++;
|
|
2653
|
+
return A.set(j, {
|
|
2654
2654
|
type: "file",
|
|
2655
|
-
path:
|
|
2655
|
+
path: y,
|
|
2656
2656
|
bytes: E,
|
|
2657
2657
|
pos: m & S ? E.length : 0,
|
|
2658
2658
|
append: !!(m & S),
|
|
2659
|
-
dirty:
|
|
2660
|
-
}), new DataView(
|
|
2659
|
+
dirty: D
|
|
2660
|
+
}), new DataView(C.buffer).setUint32(h, j, !0), i;
|
|
2661
2661
|
},
|
|
2662
2662
|
path_filestat_get: (e, t, r, o, s) => {
|
|
2663
|
-
if (!
|
|
2664
|
-
let c =
|
|
2663
|
+
if (!C || !O) return a;
|
|
2664
|
+
let c = N(e, n.decode(new Uint8Array(C.buffer, r, o)));
|
|
2665
2665
|
if (!c) return a;
|
|
2666
|
-
let u =
|
|
2666
|
+
let u = O.stat(c);
|
|
2667
2667
|
if (!u) return l;
|
|
2668
|
-
let d = new DataView(
|
|
2668
|
+
let d = new DataView(C.buffer);
|
|
2669
2669
|
for (let e = 0; e < 64; e++) d.setUint8(s + e, 0);
|
|
2670
|
-
return d.setUint8(s + 16, u.isDirectory ? m : h), d.setBigUint64(s + 24, 1n, !0), d.setBigUint64(s + 32, BigInt(
|
|
2670
|
+
return d.setUint8(s + 16, u.isDirectory ? m : h), d.setBigUint64(s + 24, 1n, !0), d.setBigUint64(s + 32, BigInt(O.getSize(c) || 0), !0), i;
|
|
2671
2671
|
},
|
|
2672
2672
|
path_create_directory: (e, t, r) => {
|
|
2673
|
-
if (!
|
|
2674
|
-
let o =
|
|
2673
|
+
if (!C || !O) return a;
|
|
2674
|
+
let o = N(e, n.decode(new Uint8Array(C.buffer, t, r)));
|
|
2675
2675
|
if (!o) return a;
|
|
2676
2676
|
try {
|
|
2677
|
-
return
|
|
2677
|
+
return O.setFileByPath(o, {}, !0), i;
|
|
2678
2678
|
} catch {
|
|
2679
2679
|
return s;
|
|
2680
2680
|
}
|
|
2681
2681
|
},
|
|
2682
2682
|
path_unlink_file: (e, t, r) => {
|
|
2683
|
-
if (!
|
|
2684
|
-
let o =
|
|
2685
|
-
if (!o || !
|
|
2683
|
+
if (!C || !O) return a;
|
|
2684
|
+
let o = N(e, n.decode(new Uint8Array(C.buffer, t, r)));
|
|
2685
|
+
if (!o || !O.exists(o)) return l;
|
|
2686
2686
|
try {
|
|
2687
|
-
return
|
|
2687
|
+
return O.deleteFileByPath(o), i;
|
|
2688
2688
|
} catch {
|
|
2689
2689
|
return s;
|
|
2690
2690
|
}
|
|
2691
2691
|
},
|
|
2692
2692
|
path_remove_directory: (e, t, r) => {
|
|
2693
|
-
if (!
|
|
2694
|
-
let o =
|
|
2695
|
-
if (!o || !
|
|
2693
|
+
if (!C || !O) return a;
|
|
2694
|
+
let o = N(e, n.decode(new Uint8Array(C.buffer, t, r)));
|
|
2695
|
+
if (!o || !O.exists(o)) return l;
|
|
2696
2696
|
try {
|
|
2697
|
-
return
|
|
2697
|
+
return O.deleteFileByPath(o), i;
|
|
2698
2698
|
} catch {
|
|
2699
2699
|
return s;
|
|
2700
2700
|
}
|
|
@@ -2706,88 +2706,88 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
|
|
|
2706
2706
|
};
|
|
2707
2707
|
},
|
|
2708
2708
|
args_sizes_get: (e, t) => {
|
|
2709
|
-
if (!
|
|
2710
|
-
let n = [this.script, ...this.arguments || []], r = new DataView(
|
|
2711
|
-
return r.setUint32(e, n.length, !0), r.setUint32(t, n.reduce((e, t) => e +
|
|
2709
|
+
if (!C) return s;
|
|
2710
|
+
let n = [this.script, ...this.arguments || []], r = new DataView(C.buffer);
|
|
2711
|
+
return r.setUint32(e, n.length, !0), r.setUint32(t, n.reduce((e, t) => e + b.encode(t).length + 1, 0), !0), i;
|
|
2712
2712
|
},
|
|
2713
2713
|
args_get: (e, t) => {
|
|
2714
|
-
if (!
|
|
2715
|
-
let n = [this.script, ...this.arguments || []], r = new DataView(
|
|
2714
|
+
if (!C) return s;
|
|
2715
|
+
let n = [this.script, ...this.arguments || []], r = new DataView(C.buffer), a = t;
|
|
2716
2716
|
for (let t = 0; t < n.length; t++) {
|
|
2717
2717
|
r.setUint32(e + t * 4, a, !0);
|
|
2718
|
-
let i =
|
|
2719
|
-
new Uint8Array(
|
|
2718
|
+
let i = b.encode(n[t] + "\0");
|
|
2719
|
+
new Uint8Array(C.buffer).set(i, a), a += i.length;
|
|
2720
2720
|
}
|
|
2721
2721
|
return i;
|
|
2722
2722
|
},
|
|
2723
2723
|
environ_sizes_get: (e, t) => {
|
|
2724
|
-
if (!
|
|
2725
|
-
let n = new DataView(
|
|
2726
|
-
n.setUint32(e,
|
|
2727
|
-
let r =
|
|
2724
|
+
if (!C) return s;
|
|
2725
|
+
let n = new DataView(C.buffer);
|
|
2726
|
+
n.setUint32(e, F.length, !0);
|
|
2727
|
+
let r = F.reduce((e, t) => e + b.encode(t).length + 1, 0);
|
|
2728
2728
|
return n.setUint32(t, r, !0), i;
|
|
2729
2729
|
},
|
|
2730
2730
|
environ_get: (e, t) => {
|
|
2731
|
-
if (!
|
|
2732
|
-
let n = new DataView(
|
|
2733
|
-
for (let t = 0; t <
|
|
2731
|
+
if (!C) return s;
|
|
2732
|
+
let n = new DataView(C.buffer), r = t;
|
|
2733
|
+
for (let t = 0; t < F.length; t++) {
|
|
2734
2734
|
n.setUint32(e + t * 4, r, !0);
|
|
2735
|
-
let i =
|
|
2736
|
-
new Uint8Array(
|
|
2735
|
+
let i = b.encode(F[t] + "\0");
|
|
2736
|
+
new Uint8Array(C.buffer).set(i, r), r += i.length;
|
|
2737
2737
|
}
|
|
2738
2738
|
return i;
|
|
2739
2739
|
},
|
|
2740
2740
|
clock_time_get: (e, t, n) => {
|
|
2741
|
-
if (
|
|
2741
|
+
if (C) {
|
|
2742
2742
|
let e = BigInt(Date.now()) * 1000000n;
|
|
2743
|
-
new DataView(
|
|
2743
|
+
new DataView(C.buffer).setBigUint64(n, e, !0);
|
|
2744
2744
|
}
|
|
2745
2745
|
return i;
|
|
2746
2746
|
},
|
|
2747
2747
|
random_get: (e, t) => {
|
|
2748
|
-
if (
|
|
2749
|
-
let n = new Uint8Array(
|
|
2748
|
+
if (C) {
|
|
2749
|
+
let n = new Uint8Array(C.buffer, e, t);
|
|
2750
2750
|
for (let e = 0; e < t; e++) n[e] = Math.random() * 256 | 0;
|
|
2751
2751
|
}
|
|
2752
2752
|
return i;
|
|
2753
2753
|
}
|
|
2754
2754
|
}, { get(e, t) {
|
|
2755
2755
|
return t in e ? e[t] : () => 0;
|
|
2756
|
-
} }),
|
|
2757
|
-
if (!
|
|
2756
|
+
} }), L = (e) => {
|
|
2757
|
+
if (!C || !e) return "";
|
|
2758
2758
|
try {
|
|
2759
|
-
let t = new DataView(
|
|
2759
|
+
let t = new DataView(C.buffer).getUint32(e - 4, !0), n = new Uint16Array(C.buffer, e, t >>> 1);
|
|
2760
2760
|
return String.fromCharCode(...n);
|
|
2761
2761
|
} catch {
|
|
2762
2762
|
return "";
|
|
2763
2763
|
}
|
|
2764
|
-
},
|
|
2765
|
-
wasi_snapshot_preview1:
|
|
2766
|
-
wasi_unstable:
|
|
2764
|
+
}, R = {
|
|
2765
|
+
wasi_snapshot_preview1: I,
|
|
2766
|
+
wasi_unstable: I,
|
|
2767
2767
|
env: new Proxy({
|
|
2768
2768
|
print: (e, t) => {
|
|
2769
|
-
|
|
2769
|
+
C && w(1, n.decode(new Uint8Array(C.buffer, e, t)));
|
|
2770
2770
|
},
|
|
2771
2771
|
eprint: (e, t) => {
|
|
2772
|
-
|
|
2772
|
+
C && w(2, n.decode(new Uint8Array(C.buffer, e, t)));
|
|
2773
2773
|
},
|
|
2774
2774
|
log: (e) => {
|
|
2775
|
-
|
|
2775
|
+
w(1, L(e) + "\n");
|
|
2776
2776
|
},
|
|
2777
2777
|
logi: (e) => {
|
|
2778
|
-
|
|
2778
|
+
w(1, String(e) + "\n");
|
|
2779
2779
|
},
|
|
2780
2780
|
logf: (e) => {
|
|
2781
|
-
|
|
2781
|
+
w(1, String(e) + "\n");
|
|
2782
2782
|
},
|
|
2783
2783
|
trace: (e, t, ...n) => {
|
|
2784
2784
|
let r = t > 0 ? " " + n.slice(0, t).join(", ") : "";
|
|
2785
|
-
|
|
2785
|
+
w(1, `trace: ${L(e)}${r}\n`);
|
|
2786
2786
|
},
|
|
2787
2787
|
seed: () => Date.now() * Math.random(),
|
|
2788
2788
|
abort: (e, t, n, r) => {
|
|
2789
|
-
let i =
|
|
2790
|
-
throw (i || a) &&
|
|
2789
|
+
let i = L(e), a = L(t);
|
|
2790
|
+
throw (i || a) && w(2, `abort: ${i || "aborted"} at ${a || this.script}:${n || 0}:${r || 0}\n`), this.exitCode = 134, {
|
|
2791
2791
|
_wasmExit: !0,
|
|
2792
2792
|
code: 134
|
|
2793
2793
|
};
|
|
@@ -2803,10 +2803,10 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
|
|
|
2803
2803
|
initial: 1,
|
|
2804
2804
|
maximum: 256
|
|
2805
2805
|
});
|
|
2806
|
-
|
|
2806
|
+
C = t, R[e.module] || (R[e.module] = {}), R[e.module][e.name] = t;
|
|
2807
2807
|
}
|
|
2808
|
-
let n = await WebAssembly.instantiate(t,
|
|
2809
|
-
n.exports.memory && (
|
|
2808
|
+
let n = await WebAssembly.instantiate(t, R);
|
|
2809
|
+
n.exports.memory && (C = n.exports.memory);
|
|
2810
2810
|
let r = n.exports._start || n.exports.__wasi_command || n.exports.main || n.exports.run;
|
|
2811
2811
|
if (r) try {
|
|
2812
2812
|
await r();
|
|
@@ -2820,27 +2820,27 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
|
|
|
2820
2820
|
} catch (e) {
|
|
2821
2821
|
(!e || !e._wasmExit) && (this.stdErr = `${this.script}: ${e?.message || String(e)}`, this.exitCode = 1);
|
|
2822
2822
|
} finally {
|
|
2823
|
-
for (let e of
|
|
2823
|
+
for (let e of A.values()) P(e);
|
|
2824
2824
|
}
|
|
2825
|
-
|
|
2826
|
-
let
|
|
2825
|
+
T();
|
|
2826
|
+
let z = this.arguments || [];
|
|
2827
2827
|
if (!(this.result && this.result.getStdOutput && this.result.getStdOutput().length > 0) && (this.exitCode === 0 || this.exitCode === void 0)) {
|
|
2828
2828
|
let t = (this.script || "wasm").split("/").pop(), n = Object.assign({
|
|
2829
2829
|
name: t,
|
|
2830
2830
|
version: "wasi",
|
|
2831
2831
|
description: `WebAssembly WASI binary (${this.script})`
|
|
2832
2832
|
}, this._pkgMeta || {});
|
|
2833
|
-
if (
|
|
2833
|
+
if (z.includes("--help") || z.includes("-h")) {
|
|
2834
2834
|
let r = j(e);
|
|
2835
2835
|
for (let e of M(t, n, r)) this.stdOut = e;
|
|
2836
|
-
} else (
|
|
2836
|
+
} else (z.includes("--version") || z.includes("-V") || z.includes("-v")) && (this.stdOut = `${t} (${n.name} ${n.version} wasm)`);
|
|
2837
2837
|
}
|
|
2838
2838
|
}
|
|
2839
2839
|
}, w = /* @__PURE__ */ new Map();
|
|
2840
2840
|
function T(e, t) {
|
|
2841
2841
|
if (!e || !e.exists(t)) return null;
|
|
2842
2842
|
if (e.isRealFilesystem) try {
|
|
2843
|
-
let n =
|
|
2843
|
+
let n = Y();
|
|
2844
2844
|
return new Uint8Array(n.readFileSync(e.absolutePath(t)));
|
|
2845
2845
|
} catch {}
|
|
2846
2846
|
let n = e.getFileByPath(t);
|
|
@@ -2869,7 +2869,7 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
|
|
|
2869
2869
|
o.set(a);
|
|
2870
2870
|
let s = new r(o.buffer, i);
|
|
2871
2871
|
if (e.isRealFilesystem) try {
|
|
2872
|
-
let n =
|
|
2872
|
+
let n = Y(), r = re(), i = e.absolutePath(t);
|
|
2873
2873
|
n.mkdirSync(r.dirname(i), { recursive: !0 }), n.writeFileSync(i, y.from(a.buffer, a.byteOffset, a.byteLength));
|
|
2874
2874
|
return;
|
|
2875
2875
|
} catch {
|
|
@@ -2979,9 +2979,16 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
|
|
|
2979
2979
|
let n = [...this.arguments || []], r = n.includes("--help") || n.includes("-h"), a = !r && (n.includes("--version") || n.includes("-V") || n.includes("-v"));
|
|
2980
2980
|
this._inspectedWasm = null, this._persistedWasmBytes = e.wasmPath ? T(this.context && this.context.fs || this.fs, e.wasmPath) : null, r && this._persistedWasmBytes && this._persistedWasmBytes.byteLength > 0 && (this._inspectedWasm = j(this._persistedWasmBytes));
|
|
2981
2981
|
try {
|
|
2982
|
-
if (e.type === "wasm" && (this._persistedWasmBytes || e.wasmUrl)
|
|
2983
|
-
let
|
|
2984
|
-
|
|
2982
|
+
if ((e.type === "wasm" || e.type === "custom-wasm") && (this._persistedWasmBytes || e.wasmUrl)) {
|
|
2983
|
+
let i = this._persistedWasmBytes;
|
|
2984
|
+
if (!i && t.moduleLoader) try {
|
|
2985
|
+
let n = await t.moduleLoader(e.name, e.cdnUrl);
|
|
2986
|
+
n instanceof Uint8Array || n instanceof ArrayBuffer ? i = n instanceof Uint8Array ? n : new Uint8Array(n) : n && (n.wasmBytes || n.wasm || n.wasmBinary) && (i = n.wasmBytes || n.wasm || n.wasmBinary);
|
|
2987
|
+
} catch {}
|
|
2988
|
+
if (!i && e.wasmUrl && (i = await this._fetchWasmBytes(e.wasmUrl)), i) {
|
|
2989
|
+
r && (this._inspectedWasm = j(i)), await this._runRawWasmBytes(i, n);
|
|
2990
|
+
return;
|
|
2991
|
+
}
|
|
2985
2992
|
} else {
|
|
2986
2993
|
let o = e.cdnUrl || e.wasmUrl || `https://esm.sh/${e.name}`, s = typeof globalThis.fetch == "function" ? globalThis.fetch : null;
|
|
2987
2994
|
if (s && this._persistedWasmBytes && this._persistedWasmBytes.byteLength > 0 && typeof Response < "u") {
|
|
@@ -3236,7 +3243,7 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
|
|
|
3236
3243
|
}
|
|
3237
3244
|
C.readBytesFromFs = T, C.writeBytesToFs = O, C.loadModule = k, C.extractHelpFromText = A, C.inspectWasmBytes = j, C.formatWasmHelp = M, C.createGenericWasmCommand = N, C.createCommand = N, t.exports = C;
|
|
3238
3245
|
})), Z = /* @__PURE__ */ t(((e, t) => {
|
|
3239
|
-
var n =
|
|
3246
|
+
var n = q(), { createGenericWasmCommand: r } = X(), i = "\x1B[2J\x1B[H", a = "\x1B[0m", o = "\x1B[7m", s = "\x1B[1m", c = "\x1B[2m", l = "\x1B[36m", u = "\x1B[31m", d = "\x1B[32m", f = class extends n {
|
|
3240
3247
|
get requiresFilesystem() {
|
|
3241
3248
|
return !0;
|
|
3242
3249
|
}
|
|
@@ -3667,6 +3674,19 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
|
|
|
3667
3674
|
type: "builtin-adapter",
|
|
3668
3675
|
adapter: "wllama",
|
|
3669
3676
|
size: "8.8 MB"
|
|
3677
|
+
},
|
|
3678
|
+
nano: {
|
|
3679
|
+
name: "nano",
|
|
3680
|
+
bin: "nano",
|
|
3681
|
+
aliases: ["nano-wasm"],
|
|
3682
|
+
version: "8.0.0",
|
|
3683
|
+
description: "GNU nano 8.0 text editor compiled to WebAssembly (wasm32-wasip1) with ncurses",
|
|
3684
|
+
details: "GNU nano is a small, user-friendly command-line text editor compiled to WebAssembly with wide-character ncurses 6.5, built-in terminfo fallbacks (xterm-256color, vt100, etc.), dynamic terminal dimensions (TIOCGWINSZ / LINES & COLUMNS), and zero custom imports (standard wasi_snapshot_preview1).",
|
|
3685
|
+
homepage: "https://github.com/eliotstocker/nano-wasm",
|
|
3686
|
+
cdnUrl: "https://cdn.jsdelivr.net/gh/eliotstocker/nano-wasm@main/dist/nano.wasm",
|
|
3687
|
+
wasmUrl: "https://cdn.jsdelivr.net/gh/eliotstocker/nano-wasm@main/dist/nano.wasm",
|
|
3688
|
+
type: "custom-wasm",
|
|
3689
|
+
size: "574 KB"
|
|
3670
3690
|
}
|
|
3671
3691
|
}, r = {
|
|
3672
3692
|
sqlite: "sqlite3",
|
|
@@ -3684,7 +3704,8 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
|
|
|
3684
3704
|
llama: "wllama",
|
|
3685
3705
|
"llama-cli": "wllama",
|
|
3686
3706
|
"llama.cpp": "wllama",
|
|
3687
|
-
"@wllama/wllama": "wllama"
|
|
3707
|
+
"@wllama/wllama": "wllama",
|
|
3708
|
+
"nano-wasm": "nano"
|
|
3688
3709
|
};
|
|
3689
3710
|
function i(e) {
|
|
3690
3711
|
if (!e) return null;
|
|
@@ -4506,7 +4527,7 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
|
|
|
4506
4527
|
}
|
|
4507
4528
|
_buildCommandsForPackage(e) {
|
|
4508
4529
|
let t = this.constructor._config || {};
|
|
4509
|
-
if (e.type === "custom-wasm" && e.wasmPath) {
|
|
4530
|
+
if ((e.type === "custom-wasm" || e.type === "wasm") && e.wasmPath) {
|
|
4510
4531
|
let t = (e.bin || e.name).toLowerCase();
|
|
4511
4532
|
return [{
|
|
4512
4533
|
bin: t,
|
|
@@ -5071,7 +5092,8 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
|
|
|
5071
5092
|
" wabt WebAssembly Binary Toolkit (wat2wasm, wasm2wat)",
|
|
5072
5093
|
" quickjs Sandboxed QuickJS JavaScript engine (qjs)",
|
|
5073
5094
|
" lua Lua 5.4 WebAssembly interpreter (lua)",
|
|
5074
|
-
" wllama WASM & WebGPU LLM inference engine (wllama, llama, llama-cli)"
|
|
5095
|
+
" wllama WASM & WebGPU LLM inference engine (wllama, llama, llama-cli)",
|
|
5096
|
+
" nano GNU nano 8.0 text editor with ncurses (nano, nano-wasm)"
|
|
5075
5097
|
].forEach((e) => {
|
|
5076
5098
|
this.stdOut = e;
|
|
5077
5099
|
});
|