brsh 2.8.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/release.yml +3 -1
- package/CHANGELOG.md +32 -0
- package/bin/brsh-shell.js +16 -131
- package/bin/exportFileSystem.js +4 -0
- package/bin/zsh-server.js +261 -0
- package/dist/brsh.css +1 -1
- package/dist/shell.es.js +943 -499
- package/dist/shell.es.js.map +1 -1
- package/dist/shell.min.js +31 -16
- package/dist/shell.min.js.map +1 -1
- package/dist/terminal.cjs.js +77 -100
- package/dist/terminal.cjs.js.map +1 -1
- package/dist/terminal.es.js +1382 -603
- package/dist/terminal.es.js.map +1 -1
- package/dist/terminal.min.js +77 -100
- package/dist/terminal.min.js.map +1 -1
- package/dist/wbt.es.js +1863 -752
- package/dist/wbt.es.js.map +1 -1
- package/dist/wbt.min.js +8 -6
- package/dist/wbt.min.js.map +1 -1
- package/index.js +472 -0
- package/lib/BaseFileSystem.js +40 -0
- package/lib/BinaryContainer.js +1 -1
- package/lib/Command.js +30 -0
- package/lib/FileSystem.js +1 -38
- package/lib/InteractiveCommand.js +28 -0
- package/lib/NodeFileSystem.js +4 -2
- package/lib/ReplCommand.js +15 -0
- package/lib/Terminal.js +769 -510
- package/lib/TtyStream.js +181 -0
- package/lib/WasmCommand.js +168 -18
- package/lib/builtins/cat.js +2 -2
- package/lib/builtins/grep.js +2 -2
- package/lib/local/clear.js +3 -0
- package/lib/terminal/DomRenderer.js +325 -0
- package/lib/terminal/PtyBridge.js +169 -0
- package/lib/terminal/ScreenBuffer.js +594 -0
- package/lib/terminal/VtParser.js +728 -0
- package/lib/wbt/index.js +270 -14
- package/lib/wbt/packages/wllama.js +12 -2
- package/lib/wbt/registry.js +11 -2
- package/package.json +4 -2
- package/styles/terminal.css +33 -4
- package/test/terminal.test.js +762 -40
- package/test/wbt.test.js +24 -5
package/dist/wbt.es.js
CHANGED
|
@@ -2,257 +2,10 @@
|
|
|
2
2
|
var e = (e, t) => () => (e && (t = e(e = 0)), t), t = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), n = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
|
|
3
3
|
if (typeof require < "u") return require.apply(this, arguments);
|
|
4
4
|
throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
5
|
-
})
|
|
6
|
-
var n = typeof Reflect == "object" ? Reflect : null, r = n && typeof n.apply == "function" ? n.apply : function(e, t, n) {
|
|
7
|
-
return Function.prototype.apply.call(e, t, n);
|
|
8
|
-
}, i = n && typeof n.ownKeys == "function" ? n.ownKeys : Object.getOwnPropertySymbols ? function(e) {
|
|
9
|
-
return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e));
|
|
10
|
-
} : function(e) {
|
|
11
|
-
return Object.getOwnPropertyNames(e);
|
|
12
|
-
};
|
|
13
|
-
function a(e) {
|
|
14
|
-
console && console.warn && console.warn(e);
|
|
15
|
-
}
|
|
16
|
-
var o = Number.isNaN || function(e) {
|
|
17
|
-
return e !== e;
|
|
18
|
-
};
|
|
19
|
-
function s() {
|
|
20
|
-
s.init.call(this);
|
|
21
|
-
}
|
|
22
|
-
t.exports = s, t.exports.once = y, s.EventEmitter = s, s.prototype._events = void 0, s.prototype._eventsCount = 0, s.prototype._maxListeners = void 0;
|
|
23
|
-
var c = 10;
|
|
24
|
-
function l(e) {
|
|
25
|
-
if (typeof e != "function") throw TypeError("The \"listener\" argument must be of type Function. Received type " + typeof e);
|
|
26
|
-
}
|
|
27
|
-
Object.defineProperty(s, "defaultMaxListeners", {
|
|
28
|
-
enumerable: !0,
|
|
29
|
-
get: function() {
|
|
30
|
-
return c;
|
|
31
|
-
},
|
|
32
|
-
set: function(e) {
|
|
33
|
-
if (typeof e != "number" || e < 0 || o(e)) throw RangeError("The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received " + e + ".");
|
|
34
|
-
c = e;
|
|
35
|
-
}
|
|
36
|
-
}), s.init = function() {
|
|
37
|
-
(this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) && (this._events = Object.create(null), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
|
|
38
|
-
}, s.prototype.setMaxListeners = function(e) {
|
|
39
|
-
if (typeof e != "number" || e < 0 || o(e)) throw RangeError("The value of \"n\" is out of range. It must be a non-negative number. Received " + e + ".");
|
|
40
|
-
return this._maxListeners = e, this;
|
|
41
|
-
};
|
|
42
|
-
function u(e) {
|
|
43
|
-
return e._maxListeners === void 0 ? s.defaultMaxListeners : e._maxListeners;
|
|
44
|
-
}
|
|
45
|
-
s.prototype.getMaxListeners = function() {
|
|
46
|
-
return u(this);
|
|
47
|
-
}, s.prototype.emit = function(e) {
|
|
48
|
-
for (var t = [], n = 1; n < arguments.length; n++) t.push(arguments[n]);
|
|
49
|
-
var i = e === "error", a = this._events;
|
|
50
|
-
if (a !== void 0) i &&= a.error === void 0;
|
|
51
|
-
else if (!i) return !1;
|
|
52
|
-
if (i) {
|
|
53
|
-
var o;
|
|
54
|
-
if (t.length > 0 && (o = t[0]), o instanceof Error) throw o;
|
|
55
|
-
var s = /* @__PURE__ */ Error("Unhandled error." + (o ? " (" + o.message + ")" : ""));
|
|
56
|
-
throw s.context = o, s;
|
|
57
|
-
}
|
|
58
|
-
var c = a[e];
|
|
59
|
-
if (c === void 0) return !1;
|
|
60
|
-
if (typeof c == "function") r(c, this, t);
|
|
61
|
-
else for (var l = c.length, u = g(c, l), n = 0; n < l; ++n) r(u[n], this, t);
|
|
62
|
-
return !0;
|
|
63
|
-
};
|
|
64
|
-
function d(e, t, n, r) {
|
|
65
|
-
var i, o, s;
|
|
66
|
-
if (l(n), o = e._events, o === void 0 ? (o = e._events = Object.create(null), e._eventsCount = 0) : (o.newListener !== void 0 && (e.emit("newListener", t, n.listener ? n.listener : n), o = e._events), s = o[t]), s === void 0) s = o[t] = n, ++e._eventsCount;
|
|
67
|
-
else if (typeof s == "function" ? s = o[t] = r ? [n, s] : [s, n] : r ? s.unshift(n) : s.push(n), i = u(e), i > 0 && s.length > i && !s.warned) {
|
|
68
|
-
s.warned = !0;
|
|
69
|
-
var c = /* @__PURE__ */ Error("Possible EventEmitter memory leak detected. " + s.length + " " + String(t) + " listeners added. Use emitter.setMaxListeners() to increase limit");
|
|
70
|
-
c.name = "MaxListenersExceededWarning", c.emitter = e, c.type = t, c.count = s.length, a(c);
|
|
71
|
-
}
|
|
72
|
-
return e;
|
|
73
|
-
}
|
|
74
|
-
s.prototype.addListener = function(e, t) {
|
|
75
|
-
return d(this, e, t, !1);
|
|
76
|
-
}, s.prototype.on = s.prototype.addListener, s.prototype.prependListener = function(e, t) {
|
|
77
|
-
return d(this, e, t, !0);
|
|
78
|
-
};
|
|
79
|
-
function f() {
|
|
80
|
-
if (!this.fired) return this.target.removeListener(this.type, this.wrapFn), this.fired = !0, arguments.length === 0 ? this.listener.call(this.target) : this.listener.apply(this.target, arguments);
|
|
81
|
-
}
|
|
82
|
-
function p(e, t, n) {
|
|
83
|
-
var r = {
|
|
84
|
-
fired: !1,
|
|
85
|
-
wrapFn: void 0,
|
|
86
|
-
target: e,
|
|
87
|
-
type: t,
|
|
88
|
-
listener: n
|
|
89
|
-
}, i = f.bind(r);
|
|
90
|
-
return i.listener = n, r.wrapFn = i, i;
|
|
91
|
-
}
|
|
92
|
-
s.prototype.once = function(e, t) {
|
|
93
|
-
return l(t), this.on(e, p(this, e, t)), this;
|
|
94
|
-
}, s.prototype.prependOnceListener = function(e, t) {
|
|
95
|
-
return l(t), this.prependListener(e, p(this, e, t)), this;
|
|
96
|
-
}, s.prototype.removeListener = function(e, t) {
|
|
97
|
-
var n, r, i, a, o;
|
|
98
|
-
if (l(t), r = this._events, r === void 0 || (n = r[e], n === void 0)) return this;
|
|
99
|
-
if (n === t || n.listener === t) --this._eventsCount === 0 ? this._events = Object.create(null) : (delete r[e], r.removeListener && this.emit("removeListener", e, n.listener || t));
|
|
100
|
-
else if (typeof n != "function") {
|
|
101
|
-
for (i = -1, a = n.length - 1; a >= 0; a--) if (n[a] === t || n[a].listener === t) {
|
|
102
|
-
o = n[a].listener, i = a;
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
if (i < 0) return this;
|
|
106
|
-
i === 0 ? n.shift() : _(n, i), n.length === 1 && (r[e] = n[0]), r.removeListener !== void 0 && this.emit("removeListener", e, o || t);
|
|
107
|
-
}
|
|
108
|
-
return this;
|
|
109
|
-
}, s.prototype.off = s.prototype.removeListener, s.prototype.removeAllListeners = function(e) {
|
|
110
|
-
var t, n = this._events, r;
|
|
111
|
-
if (n === void 0) return this;
|
|
112
|
-
if (n.removeListener === void 0) return arguments.length === 0 ? (this._events = Object.create(null), this._eventsCount = 0) : n[e] !== void 0 && (--this._eventsCount === 0 ? this._events = Object.create(null) : delete n[e]), this;
|
|
113
|
-
if (arguments.length === 0) {
|
|
114
|
-
var i = Object.keys(n), a;
|
|
115
|
-
for (r = 0; r < i.length; ++r) a = i[r], a !== "removeListener" && this.removeAllListeners(a);
|
|
116
|
-
return this.removeAllListeners("removeListener"), this._events = Object.create(null), this._eventsCount = 0, this;
|
|
117
|
-
}
|
|
118
|
-
if (t = n[e], typeof t == "function") this.removeListener(e, t);
|
|
119
|
-
else if (t !== void 0) for (r = t.length - 1; r >= 0; r--) this.removeListener(e, t[r]);
|
|
120
|
-
return this;
|
|
121
|
-
};
|
|
122
|
-
function m(e, t, n) {
|
|
123
|
-
var r = e._events;
|
|
124
|
-
if (r === void 0) return [];
|
|
125
|
-
var i = r[t];
|
|
126
|
-
return i === void 0 ? [] : typeof i == "function" ? n ? [i.listener || i] : [i] : n ? v(i) : g(i, i.length);
|
|
127
|
-
}
|
|
128
|
-
s.prototype.listeners = function(e) {
|
|
129
|
-
return m(this, e, !0);
|
|
130
|
-
}, s.prototype.rawListeners = function(e) {
|
|
131
|
-
return m(this, e, !1);
|
|
132
|
-
}, s.listenerCount = function(e, t) {
|
|
133
|
-
return typeof e.listenerCount == "function" ? e.listenerCount(t) : h.call(e, t);
|
|
134
|
-
}, s.prototype.listenerCount = h;
|
|
135
|
-
function h(e) {
|
|
136
|
-
var t = this._events;
|
|
137
|
-
if (t !== void 0) {
|
|
138
|
-
var n = t[e];
|
|
139
|
-
if (typeof n == "function") return 1;
|
|
140
|
-
if (n !== void 0) return n.length;
|
|
141
|
-
}
|
|
142
|
-
return 0;
|
|
143
|
-
}
|
|
144
|
-
s.prototype.eventNames = function() {
|
|
145
|
-
return this._eventsCount > 0 ? i(this._events) : [];
|
|
146
|
-
};
|
|
147
|
-
function g(e, t) {
|
|
148
|
-
for (var n = Array(t), r = 0; r < t; ++r) n[r] = e[r];
|
|
149
|
-
return n;
|
|
150
|
-
}
|
|
151
|
-
function _(e, t) {
|
|
152
|
-
for (; t + 1 < e.length; t++) e[t] = e[t + 1];
|
|
153
|
-
e.pop();
|
|
154
|
-
}
|
|
155
|
-
function v(e) {
|
|
156
|
-
for (var t = Array(e.length), n = 0; n < t.length; ++n) t[n] = e[n].listener || e[n];
|
|
157
|
-
return t;
|
|
158
|
-
}
|
|
159
|
-
function y(e, t) {
|
|
160
|
-
return new Promise(function(n, r) {
|
|
161
|
-
function i(n) {
|
|
162
|
-
e.removeListener(t, a), r(n);
|
|
163
|
-
}
|
|
164
|
-
function a() {
|
|
165
|
-
typeof e.removeListener == "function" && e.removeListener("error", i), n([].slice.call(arguments));
|
|
166
|
-
}
|
|
167
|
-
x(e, t, a, { once: !0 }), t !== "error" && b(e, i, { once: !0 });
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
function b(e, t, n) {
|
|
171
|
-
typeof e.on == "function" && x(e, "error", t, n);
|
|
172
|
-
}
|
|
173
|
-
function x(e, t, n, r) {
|
|
174
|
-
if (typeof e.on == "function") r.once ? e.once(t, n) : e.on(t, n);
|
|
175
|
-
else if (typeof e.addEventListener == "function") e.addEventListener(t, function i(a) {
|
|
176
|
-
r.once && e.removeEventListener(t, i), n(a);
|
|
177
|
-
});
|
|
178
|
-
else throw TypeError("The \"emitter\" argument must be of type EventEmitter. Received type " + typeof e);
|
|
179
|
-
}
|
|
180
|
-
})), i = /* @__PURE__ */ t(((e, t) => {
|
|
181
|
-
var n = ["out", "err"];
|
|
182
|
-
t.exports = class {
|
|
183
|
-
constructor(e, t) {
|
|
184
|
-
if (!n.includes(e)) throw Error("incorrect std output type");
|
|
185
|
-
this.type = e, this.string = t;
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
})), a = /* @__PURE__ */ t(((e, t) => {
|
|
189
|
-
var n = i();
|
|
190
|
-
t.exports = class {
|
|
191
|
-
constructor(e = [], t = 0) {
|
|
192
|
-
if (typeof t != "number") throw Error("Command Result ExitCode must be a number");
|
|
193
|
-
if (!Array.isArray(e)) throw Error("Command Result be array");
|
|
194
|
-
this.std = e, this.exitCode = t;
|
|
195
|
-
}
|
|
196
|
-
addStdOutLine(e) {
|
|
197
|
-
this.std.push(new n("out", e));
|
|
198
|
-
}
|
|
199
|
-
addStdErrLine(e) {
|
|
200
|
-
this.std.push(new n("err", e));
|
|
201
|
-
}
|
|
202
|
-
getStdOutput() {
|
|
203
|
-
return this.std;
|
|
204
|
-
}
|
|
205
|
-
getExitCode() {
|
|
206
|
-
return this.exitCode;
|
|
207
|
-
}
|
|
208
|
-
flush() {
|
|
209
|
-
let e = this.std;
|
|
210
|
-
return this.std = [], e;
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
})), o = /* @__PURE__ */ t(((e, t) => {
|
|
214
|
-
var n = r(), i = a(), o = n.EventEmitter || n.default || n;
|
|
215
|
-
t.exports = class extends o {
|
|
216
|
-
constructor(e, t) {
|
|
217
|
-
super(), this.arguments = e, this.result = new i(), this.context = t || null;
|
|
218
|
-
}
|
|
219
|
-
get name() {
|
|
220
|
-
return "unnamed";
|
|
221
|
-
}
|
|
222
|
-
run() {
|
|
223
|
-
return Promise.reject("Command not implemented...");
|
|
224
|
-
}
|
|
225
|
-
runCommand() {
|
|
226
|
-
return Promise.resolve().then(() => this.run()).then((e) => (e && e.split(/\r?\n/).forEach((e) => this.stdOut = e), this.result)).catch((e) => {
|
|
227
|
-
if (e && e.__type) throw e;
|
|
228
|
-
return e && (this.stdErr = e.message || e), this.exitCode = 127, this.result;
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
onInput(e) {}
|
|
232
|
-
set exitCode(e) {
|
|
233
|
-
this.result.exitCode = e;
|
|
234
|
-
}
|
|
235
|
-
set stdOut(e) {
|
|
236
|
-
this.result.addStdOutLine(e);
|
|
237
|
-
}
|
|
238
|
-
set stdErr(e) {
|
|
239
|
-
this.result.addStdErrLine(e);
|
|
240
|
-
}
|
|
241
|
-
flush() {
|
|
242
|
-
this.emit("flush", this.result.flush());
|
|
243
|
-
}
|
|
244
|
-
};
|
|
245
|
-
})), s = /* @__PURE__ */ t(((e, t) => {
|
|
246
|
-
var n = o();
|
|
247
|
-
t.exports = class extends n {
|
|
248
|
-
constructor(e, t) {
|
|
249
|
-
super(e, t);
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
}));
|
|
5
|
+
});
|
|
253
6
|
//#endregion
|
|
254
7
|
//#region node_modules/vite-plugin-node-polyfills/shims/buffer/dist/index.js
|
|
255
|
-
function
|
|
8
|
+
function r(e) {
|
|
256
9
|
var t = e.length;
|
|
257
10
|
if (t % 4 > 0) throw Error("Invalid string. Length must be a multiple of 4");
|
|
258
11
|
var n = e.indexOf("=");
|
|
@@ -260,32 +13,32 @@ function c(e) {
|
|
|
260
13
|
var r = n === t ? 0 : 4 - n % 4;
|
|
261
14
|
return [n, r];
|
|
262
15
|
}
|
|
263
|
-
function
|
|
264
|
-
var t =
|
|
265
|
-
return (n +
|
|
16
|
+
function i(e) {
|
|
17
|
+
var t = r(e), n = t[0], i = t[1];
|
|
18
|
+
return (n + i) * 3 / 4 - i;
|
|
266
19
|
}
|
|
267
|
-
function
|
|
20
|
+
function a(e, t, n) {
|
|
268
21
|
return (t + n) * 3 / 4 - n;
|
|
269
22
|
}
|
|
270
|
-
function
|
|
271
|
-
var t, n =
|
|
272
|
-
for (
|
|
273
|
-
return
|
|
23
|
+
function o(e) {
|
|
24
|
+
var t, n = r(e), i = n[0], o = n[1], s = new m(a(e, i, o)), c = 0, l = o > 0 ? i - 4 : i, u;
|
|
25
|
+
for (u = 0; u < l; u += 4) t = p[e.charCodeAt(u)] << 18 | p[e.charCodeAt(u + 1)] << 12 | p[e.charCodeAt(u + 2)] << 6 | p[e.charCodeAt(u + 3)], s[c++] = t >> 16 & 255, s[c++] = t >> 8 & 255, s[c++] = t & 255;
|
|
26
|
+
return o === 2 && (t = p[e.charCodeAt(u)] << 2 | p[e.charCodeAt(u + 1)] >> 4, s[c++] = t & 255), o === 1 && (t = p[e.charCodeAt(u)] << 10 | p[e.charCodeAt(u + 1)] << 4 | p[e.charCodeAt(u + 2)] >> 2, s[c++] = t >> 8 & 255, s[c++] = t & 255), s;
|
|
274
27
|
}
|
|
275
|
-
function
|
|
276
|
-
return
|
|
28
|
+
function s(e) {
|
|
29
|
+
return f[e >> 18 & 63] + f[e >> 12 & 63] + f[e >> 6 & 63] + f[e & 63];
|
|
277
30
|
}
|
|
278
|
-
function
|
|
279
|
-
for (var r, i = [], a = t; a < n; a += 3) r = (e[a] << 16 & 16711680) + (e[a + 1] << 8 & 65280) + (e[a + 2] & 255), i.push(
|
|
31
|
+
function c(e, t, n) {
|
|
32
|
+
for (var r, i = [], a = t; a < n; a += 3) r = (e[a] << 16 & 16711680) + (e[a + 1] << 8 & 65280) + (e[a + 2] & 255), i.push(s(r));
|
|
280
33
|
return i.join("");
|
|
281
34
|
}
|
|
282
|
-
function
|
|
283
|
-
for (var t, n = e.length, r = n % 3, i = [], a = 16383, o = 0, s = n - r; o < s; o += a) i.push(
|
|
284
|
-
return r === 1 ? (t = e[n - 1], i.push(
|
|
35
|
+
function l(e) {
|
|
36
|
+
for (var t, n = e.length, r = n % 3, i = [], a = 16383, o = 0, s = n - r; o < s; o += a) i.push(c(e, o, o + a > s ? s : o + a));
|
|
37
|
+
return r === 1 ? (t = e[n - 1], i.push(f[t >> 2] + f[t << 4 & 63] + "==")) : r === 2 && (t = (e[n - 2] << 8) + e[n - 1], i.push(f[t >> 10] + f[t >> 4 & 63] + f[t << 2 & 63] + "=")), i.join("");
|
|
285
38
|
}
|
|
286
|
-
var
|
|
287
|
-
for (
|
|
288
|
-
|
|
39
|
+
var u, d, f, p, m, h, g, _, v, y, b = e((() => {
|
|
40
|
+
for (u = {}, d = {}, d.byteLength = i, d.toByteArray = o, d.fromByteArray = l, f = [], p = [], m = typeof Uint8Array < "u" ? Uint8Array : Array, h = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", g = 0, _ = h.length; g < _; ++g) f[g] = h[g], p[h.charCodeAt(g)] = g;
|
|
41
|
+
p[45] = 62, p[95] = 63, v = {}, v.read = function(e, t, n, r, i) {
|
|
289
42
|
var a, o, s = i * 8 - r - 1, c = (1 << s) - 1, l = c >> 1, u = -7, d = n ? i - 1 : 0, f = n ? -1 : 1, p = e[t + d];
|
|
290
43
|
for (d += f, a = p & (1 << -u) - 1, p >>= -u, u += s; u > 0; a = a * 256 + e[t + d], d += f, u -= 8);
|
|
291
44
|
for (o = a & (1 << -u) - 1, a >>= -u, u += r; u > 0; o = o * 256 + e[t + d], d += f, u -= 8);
|
|
@@ -293,14 +46,14 @@ var h, g, _, v, y, b, x, S, C, w, T = e((() => {
|
|
|
293
46
|
else if (a === c) return o ? NaN : (p ? -1 : 1) * Infinity;
|
|
294
47
|
else o += 2 ** r, a -= l;
|
|
295
48
|
return (p ? -1 : 1) * o * 2 ** (a - r);
|
|
296
|
-
},
|
|
49
|
+
}, v.write = function(e, t, n, r, i, a) {
|
|
297
50
|
var o, s, c, l = a * 8 - i - 1, u = (1 << l) - 1, d = u >> 1, f = i === 23 ? 2 ** -24 - 2 ** -77 : 0, p = r ? 0 : a - 1, m = r ? 1 : -1, h = +(t < 0 || t === 0 && 1 / t < 0);
|
|
298
51
|
for (t = Math.abs(t), isNaN(t) || t === Infinity ? (s = +!!isNaN(t), o = u) : (o = Math.floor(Math.log(t) / Math.LN2), t * (c = 2 ** -o) < 1 && (o--, c *= 2), o + d >= 1 ? t += f / c : t += f * 2 ** (1 - d), t * c >= 2 && (o++, c /= 2), o + d >= u ? (s = 0, o = u) : o + d >= 1 ? (s = (t * c - 1) * 2 ** i, o += d) : (s = t * 2 ** (d - 1) * 2 ** i, o = 0)); i >= 8; e[n + p] = s & 255, p += m, s /= 256, i -= 8);
|
|
299
52
|
for (o = o << i | s, l += i; l > 0; e[n + p] = o & 255, p += m, o /= 256, l -= 8);
|
|
300
53
|
e[n + p - m] |= h * 128;
|
|
301
54
|
}, (function(e) {
|
|
302
|
-
let t =
|
|
303
|
-
e.Buffer = u, e.SlowBuffer =
|
|
55
|
+
let t = d, n = v, r = typeof Symbol == "function" && typeof Symbol.for == "function" ? Symbol.for("nodejs.util.inspect.custom") : null;
|
|
56
|
+
e.Buffer = u, e.SlowBuffer = C, e.INSPECT_MAX_BYTES = 50;
|
|
304
57
|
let i = 2147483647;
|
|
305
58
|
e.kMaxLength = i;
|
|
306
59
|
let { Uint8Array: a, ArrayBuffer: o, SharedArrayBuffer: s } = globalThis;
|
|
@@ -334,81 +87,81 @@ var h, g, _, v, y, b, x, S, C, w, T = e((() => {
|
|
|
334
87
|
function u(e, t, n) {
|
|
335
88
|
if (typeof e == "number") {
|
|
336
89
|
if (typeof t == "string") throw TypeError("The \"string\" argument must be of type string. Received type number");
|
|
337
|
-
return
|
|
90
|
+
return h(e);
|
|
338
91
|
}
|
|
339
|
-
return
|
|
92
|
+
return f(e, t, n);
|
|
340
93
|
}
|
|
341
94
|
u.poolSize = 8192;
|
|
342
|
-
function
|
|
343
|
-
if (typeof e == "string") return
|
|
344
|
-
if (o.isView(e)) return
|
|
95
|
+
function f(e, t, n) {
|
|
96
|
+
if (typeof e == "string") return g(e, t);
|
|
97
|
+
if (o.isView(e)) return y(e);
|
|
345
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);
|
|
346
|
-
if (Q(e, o) || e && Q(e.buffer, o) || s !== void 0 && (Q(e, s) || e && Q(e.buffer, s))) return
|
|
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);
|
|
347
100
|
if (typeof e == "number") throw TypeError("The \"value\" argument must not be of type number. Received type number");
|
|
348
101
|
let r = e.valueOf && e.valueOf();
|
|
349
102
|
if (r != null && r !== e) return u.from(r, t, n);
|
|
350
|
-
let i =
|
|
103
|
+
let i = x(e);
|
|
351
104
|
if (i) return i;
|
|
352
105
|
if (typeof Symbol < "u" && Symbol.toPrimitive != null && typeof e[Symbol.toPrimitive] == "function") return u.from(e[Symbol.toPrimitive]("string"), t, n);
|
|
353
106
|
throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof e);
|
|
354
107
|
}
|
|
355
108
|
u.from = function(e, t, n) {
|
|
356
|
-
return
|
|
109
|
+
return f(e, t, n);
|
|
357
110
|
}, Object.setPrototypeOf(u.prototype, a.prototype), Object.setPrototypeOf(u, a);
|
|
358
|
-
function
|
|
111
|
+
function p(e) {
|
|
359
112
|
if (typeof e != "number") throw TypeError("\"size\" argument must be of type number");
|
|
360
113
|
if (e < 0) throw RangeError("The value \"" + e + "\" is invalid for option \"size\"");
|
|
361
114
|
}
|
|
362
|
-
function
|
|
363
|
-
return
|
|
115
|
+
function m(e, t, n) {
|
|
116
|
+
return p(e), e <= 0 || t === void 0 ? l(e) : typeof n == "string" ? l(e).fill(t, n) : l(e).fill(t);
|
|
364
117
|
}
|
|
365
118
|
u.alloc = function(e, t, n) {
|
|
366
|
-
return
|
|
119
|
+
return m(e, t, n);
|
|
367
120
|
};
|
|
368
|
-
function
|
|
369
|
-
return
|
|
121
|
+
function h(e) {
|
|
122
|
+
return p(e), l(e < 0 ? 0 : S(e) | 0);
|
|
370
123
|
}
|
|
371
124
|
u.allocUnsafe = function(e) {
|
|
372
|
-
return
|
|
125
|
+
return h(e);
|
|
373
126
|
}, u.allocUnsafeSlow = function(e) {
|
|
374
|
-
return
|
|
127
|
+
return h(e);
|
|
375
128
|
};
|
|
376
|
-
function
|
|
129
|
+
function g(e, t) {
|
|
377
130
|
if ((typeof t != "string" || t === "") && (t = "utf8"), !u.isEncoding(t)) throw TypeError("Unknown encoding: " + t);
|
|
378
131
|
let n = w(e, t) | 0, r = l(n), i = r.write(e, t);
|
|
379
132
|
return i !== n && (r = r.slice(0, i)), r;
|
|
380
133
|
}
|
|
381
134
|
function _(e) {
|
|
382
|
-
let t = e.length < 0 ? 0 :
|
|
135
|
+
let t = e.length < 0 ? 0 : S(e.length) | 0, n = l(t);
|
|
383
136
|
for (let r = 0; r < t; r += 1) n[r] = e[r] & 255;
|
|
384
137
|
return n;
|
|
385
138
|
}
|
|
386
|
-
function
|
|
139
|
+
function y(e) {
|
|
387
140
|
if (Q(e, a)) {
|
|
388
141
|
let t = new a(e);
|
|
389
|
-
return
|
|
142
|
+
return b(t.buffer, t.byteOffset, t.byteLength);
|
|
390
143
|
}
|
|
391
144
|
return _(e);
|
|
392
145
|
}
|
|
393
|
-
function
|
|
146
|
+
function b(e, t, n) {
|
|
394
147
|
if (t < 0 || e.byteLength < t) throw RangeError("\"offset\" is outside of buffer bounds");
|
|
395
148
|
if (e.byteLength < t + (n || 0)) throw RangeError("\"length\" is outside of buffer bounds");
|
|
396
149
|
let r;
|
|
397
150
|
return r = t === void 0 && n === void 0 ? new a(e) : n === void 0 ? new a(e, t) : new a(e, t, n), Object.setPrototypeOf(r, u.prototype), r;
|
|
398
151
|
}
|
|
399
|
-
function
|
|
152
|
+
function x(e) {
|
|
400
153
|
if (u.isBuffer(e)) {
|
|
401
|
-
let t =
|
|
154
|
+
let t = S(e.length) | 0, n = l(t);
|
|
402
155
|
return n.length === 0 || e.copy(n, 0, 0, t), n;
|
|
403
156
|
}
|
|
404
157
|
if (e.length !== void 0) return typeof e.length != "number" || de(e.length) ? l(0) : _(e);
|
|
405
158
|
if (e.type === "Buffer" && Array.isArray(e.data)) return _(e.data);
|
|
406
159
|
}
|
|
407
|
-
function
|
|
160
|
+
function S(e) {
|
|
408
161
|
if (e >= i) throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + i.toString(16) + " bytes");
|
|
409
162
|
return e | 0;
|
|
410
163
|
}
|
|
411
|
-
function
|
|
164
|
+
function C(e) {
|
|
412
165
|
return +e != e && (e = 0), u.alloc(+e);
|
|
413
166
|
}
|
|
414
167
|
u.isBuffer = function(e) {
|
|
@@ -819,14 +572,14 @@ var h, g, _, v, y, b, x, S, C, w, T = e((() => {
|
|
|
819
572
|
return e = +e, t >>>= 0, n || U(this, e, t, 4, 4294967295, 0), this[t] = e >>> 24, this[t + 1] = e >>> 16, this[t + 2] = e >>> 8, this[t + 3] = e & 255, t + 4;
|
|
820
573
|
};
|
|
821
574
|
function W(e, t, n, r, i) {
|
|
822
|
-
|
|
575
|
+
re(t, r, i, e, n, 7);
|
|
823
576
|
let a = Number(t & BigInt(4294967295));
|
|
824
577
|
e[n++] = a, a >>= 8, e[n++] = a, a >>= 8, e[n++] = a, a >>= 8, e[n++] = a;
|
|
825
578
|
let o = Number(t >> BigInt(32) & BigInt(4294967295));
|
|
826
579
|
return e[n++] = o, o >>= 8, e[n++] = o, o >>= 8, e[n++] = o, o >>= 8, e[n++] = o, n;
|
|
827
580
|
}
|
|
828
|
-
function
|
|
829
|
-
|
|
581
|
+
function G(e, t, n, r, i) {
|
|
582
|
+
re(t, r, i, e, n, 7);
|
|
830
583
|
let a = Number(t & BigInt(4294967295));
|
|
831
584
|
e[n + 7] = a, a >>= 8, e[n + 6] = a, a >>= 8, e[n + 5] = a, a >>= 8, e[n + 4] = a;
|
|
832
585
|
let o = Number(t >> BigInt(32) & BigInt(4294967295));
|
|
@@ -835,7 +588,7 @@ var h, g, _, v, y, b, x, S, C, w, T = e((() => {
|
|
|
835
588
|
u.prototype.writeBigUInt64LE = $(function(e, t = 0) {
|
|
836
589
|
return W(this, e, t, BigInt(0), BigInt("0xffffffffffffffff"));
|
|
837
590
|
}), u.prototype.writeBigUInt64BE = $(function(e, t = 0) {
|
|
838
|
-
return
|
|
591
|
+
return G(this, e, t, BigInt(0), BigInt("0xffffffffffffffff"));
|
|
839
592
|
}), u.prototype.writeIntLE = function(e, t, n, r) {
|
|
840
593
|
if (e = +e, t >>>= 0, !r) {
|
|
841
594
|
let r = 2 ** (8 * n - 1);
|
|
@@ -865,26 +618,26 @@ var h, g, _, v, y, b, x, S, C, w, T = e((() => {
|
|
|
865
618
|
}, u.prototype.writeBigInt64LE = $(function(e, t = 0) {
|
|
866
619
|
return W(this, e, t, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
|
|
867
620
|
}), u.prototype.writeBigInt64BE = $(function(e, t = 0) {
|
|
868
|
-
return
|
|
621
|
+
return G(this, e, t, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
|
|
869
622
|
});
|
|
870
|
-
function
|
|
623
|
+
function K(e, t, n, r, i, a) {
|
|
871
624
|
if (n + r > e.length || n < 0) throw RangeError("Index out of range");
|
|
872
625
|
}
|
|
873
|
-
function
|
|
874
|
-
return t = +t, r >>>= 0, a ||
|
|
626
|
+
function q(e, t, r, i, a) {
|
|
627
|
+
return t = +t, r >>>= 0, a || K(e, t, r, 4), n.write(e, t, r, i, 23, 4), r + 4;
|
|
875
628
|
}
|
|
876
629
|
u.prototype.writeFloatLE = function(e, t, n) {
|
|
877
|
-
return
|
|
630
|
+
return q(this, e, t, !0, n);
|
|
878
631
|
}, u.prototype.writeFloatBE = function(e, t, n) {
|
|
879
|
-
return
|
|
632
|
+
return q(this, e, t, !1, n);
|
|
880
633
|
};
|
|
881
|
-
function
|
|
882
|
-
return t = +t, r >>>= 0, a ||
|
|
634
|
+
function ee(e, t, r, i, a) {
|
|
635
|
+
return t = +t, r >>>= 0, a || K(e, t, r, 8), n.write(e, t, r, i, 52, 8), r + 8;
|
|
883
636
|
}
|
|
884
637
|
u.prototype.writeDoubleLE = function(e, t, n) {
|
|
885
|
-
return
|
|
638
|
+
return ee(this, e, t, !0, n);
|
|
886
639
|
}, u.prototype.writeDoubleBE = function(e, t, n) {
|
|
887
|
-
return
|
|
640
|
+
return ee(this, e, t, !1, n);
|
|
888
641
|
}, u.prototype.copy = function(e, t, n, r) {
|
|
889
642
|
if (!u.isBuffer(e)) throw TypeError("argument should be a Buffer");
|
|
890
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;
|
|
@@ -915,9 +668,9 @@ var h, g, _, v, y, b, x, S, C, w, T = e((() => {
|
|
|
915
668
|
}
|
|
916
669
|
return this;
|
|
917
670
|
};
|
|
918
|
-
let
|
|
919
|
-
function
|
|
920
|
-
|
|
671
|
+
let J = {};
|
|
672
|
+
function Y(e, t, n) {
|
|
673
|
+
J[e] = class extends n {
|
|
921
674
|
constructor() {
|
|
922
675
|
super(), Object.defineProperty(this, "message", {
|
|
923
676
|
value: t.apply(this, arguments),
|
|
@@ -941,120 +694,496 @@ var h, g, _, v, y, b, x, S, C, w, T = e((() => {
|
|
|
941
694
|
}
|
|
942
695
|
};
|
|
943
696
|
}
|
|
944
|
-
|
|
945
|
-
return e ? `${e} is outside of buffer bounds` : "Attempt to access memory outside buffer bounds";
|
|
946
|
-
}, RangeError),
|
|
947
|
-
return `The "${e}" argument must be of type number. Received type ${typeof t}`;
|
|
948
|
-
}, TypeError),
|
|
949
|
-
let r = `The value of "${e}" is out of range.`, i = n;
|
|
950
|
-
return Number.isInteger(n) && Math.abs(n) > 2 ** 32 ? i =
|
|
951
|
-
}, RangeError);
|
|
952
|
-
function
|
|
953
|
-
let t = "", n = e.length, r = +(e[0] === "-");
|
|
954
|
-
for (; n >= r + 4; n -= 3) t = `_${e.slice(n - 3, n)}${t}`;
|
|
955
|
-
return `${e.slice(0, n)}${t}`;
|
|
697
|
+
Y("ERR_BUFFER_OUT_OF_BOUNDS", function(e) {
|
|
698
|
+
return e ? `${e} is outside of buffer bounds` : "Attempt to access memory outside buffer bounds";
|
|
699
|
+
}, RangeError), Y("ERR_INVALID_ARG_TYPE", function(e, t) {
|
|
700
|
+
return `The "${e}" argument must be of type number. Received type ${typeof t}`;
|
|
701
|
+
}, TypeError), Y("ERR_OUT_OF_RANGE", function(e, t, n) {
|
|
702
|
+
let r = `The value of "${e}" is out of range.`, i = n;
|
|
703
|
+
return Number.isInteger(n) && Math.abs(n) > 2 ** 32 ? i = te(String(n)) : typeof n == "bigint" && (i = String(n), (n > BigInt(2) ** BigInt(32) || n < -(BigInt(2) ** BigInt(32))) && (i = te(i)), i += "n"), r += ` It must be ${t}. Received ${i}`, r;
|
|
704
|
+
}, RangeError);
|
|
705
|
+
function te(e) {
|
|
706
|
+
let t = "", n = e.length, r = +(e[0] === "-");
|
|
707
|
+
for (; n >= r + 4; n -= 3) t = `_${e.slice(n - 3, n)}${t}`;
|
|
708
|
+
return `${e.slice(0, n)}${t}`;
|
|
709
|
+
}
|
|
710
|
+
function ne(e, t, n) {
|
|
711
|
+
X(t, "offset"), (e[t] === void 0 || e[t + n] === void 0) && Z(t, e.length - (n + 1));
|
|
712
|
+
}
|
|
713
|
+
function re(e, t, n, r, i, a) {
|
|
714
|
+
if (e > n || e < t) {
|
|
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 J.ERR_OUT_OF_RANGE("value", i, e);
|
|
717
|
+
}
|
|
718
|
+
ne(r, i, a);
|
|
719
|
+
}
|
|
720
|
+
function X(e, t) {
|
|
721
|
+
if (typeof e != "number") throw new J.ERR_INVALID_ARG_TYPE(t, "number", e);
|
|
722
|
+
}
|
|
723
|
+
function Z(e, t, n) {
|
|
724
|
+
throw Math.floor(e) === e ? t < 0 ? new J.ERR_BUFFER_OUT_OF_BOUNDS() : new J.ERR_OUT_OF_RANGE(n || "offset", `>= ${+!!n} and <= ${t}`, e) : (X(e, n), new J.ERR_OUT_OF_RANGE(n || "offset", "an integer", e));
|
|
725
|
+
}
|
|
726
|
+
let ie = /[^+/0-9A-Za-z-_]/g;
|
|
727
|
+
function ae(e) {
|
|
728
|
+
if (e = e.split("=")[0], e = e.trim().replace(ie, ""), e.length < 2) return "";
|
|
729
|
+
for (; e.length % 4 != 0;) e += "=";
|
|
730
|
+
return e;
|
|
731
|
+
}
|
|
732
|
+
function oe(e, t) {
|
|
733
|
+
t ||= Infinity;
|
|
734
|
+
let n, r = e.length, i = null, a = [];
|
|
735
|
+
for (let o = 0; o < r; ++o) {
|
|
736
|
+
if (n = e.charCodeAt(o), n > 55295 && n < 57344) {
|
|
737
|
+
if (!i) {
|
|
738
|
+
if (n > 56319) {
|
|
739
|
+
(t -= 3) > -1 && a.push(239, 191, 189);
|
|
740
|
+
continue;
|
|
741
|
+
} else if (o + 1 === r) {
|
|
742
|
+
(t -= 3) > -1 && a.push(239, 191, 189);
|
|
743
|
+
continue;
|
|
744
|
+
}
|
|
745
|
+
i = n;
|
|
746
|
+
continue;
|
|
747
|
+
}
|
|
748
|
+
if (n < 56320) {
|
|
749
|
+
(t -= 3) > -1 && a.push(239, 191, 189), i = n;
|
|
750
|
+
continue;
|
|
751
|
+
}
|
|
752
|
+
n = (i - 55296 << 10 | n - 56320) + 65536;
|
|
753
|
+
} else i && (t -= 3) > -1 && a.push(239, 191, 189);
|
|
754
|
+
if (i = null, n < 128) {
|
|
755
|
+
if (--t < 0) break;
|
|
756
|
+
a.push(n);
|
|
757
|
+
} else if (n < 2048) {
|
|
758
|
+
if ((t -= 2) < 0) break;
|
|
759
|
+
a.push(n >> 6 | 192, n & 63 | 128);
|
|
760
|
+
} else if (n < 65536) {
|
|
761
|
+
if ((t -= 3) < 0) break;
|
|
762
|
+
a.push(n >> 12 | 224, n >> 6 & 63 | 128, n & 63 | 128);
|
|
763
|
+
} else if (n < 1114112) {
|
|
764
|
+
if ((t -= 4) < 0) break;
|
|
765
|
+
a.push(n >> 18 | 240, n >> 12 & 63 | 128, n >> 6 & 63 | 128, n & 63 | 128);
|
|
766
|
+
} else throw Error("Invalid code point");
|
|
767
|
+
}
|
|
768
|
+
return a;
|
|
769
|
+
}
|
|
770
|
+
function se(e) {
|
|
771
|
+
let t = [];
|
|
772
|
+
for (let n = 0; n < e.length; ++n) t.push(e.charCodeAt(n) & 255);
|
|
773
|
+
return t;
|
|
774
|
+
}
|
|
775
|
+
function ce(e, t) {
|
|
776
|
+
let n, r, i, a = [];
|
|
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
|
+
return a;
|
|
779
|
+
}
|
|
780
|
+
function le(e) {
|
|
781
|
+
return t.toByteArray(ae(e));
|
|
782
|
+
}
|
|
783
|
+
function ue(e, t, n, r) {
|
|
784
|
+
let i;
|
|
785
|
+
for (i = 0; i < r && !(i + n >= t.length || i >= e.length); ++i) t[i + n] = e[i];
|
|
786
|
+
return i;
|
|
787
|
+
}
|
|
788
|
+
function Q(e, t) {
|
|
789
|
+
return e instanceof t || e != null && e.constructor != null && e.constructor.name != null && e.constructor.name === t.name;
|
|
790
|
+
}
|
|
791
|
+
function de(e) {
|
|
792
|
+
return e !== e;
|
|
793
|
+
}
|
|
794
|
+
let fe = (function() {
|
|
795
|
+
let e = "0123456789abcdef", t = Array(256);
|
|
796
|
+
for (let n = 0; n < 16; ++n) {
|
|
797
|
+
let r = n * 16;
|
|
798
|
+
for (let i = 0; i < 16; ++i) t[r + i] = e[n] + e[i];
|
|
799
|
+
}
|
|
800
|
+
return t;
|
|
801
|
+
})();
|
|
802
|
+
function $(e) {
|
|
803
|
+
return typeof BigInt > "u" ? pe : e;
|
|
804
|
+
}
|
|
805
|
+
function pe() {
|
|
806
|
+
throw Error("BigInt not supported");
|
|
807
|
+
}
|
|
808
|
+
})(u), y = u.Buffer, u.Blob, u.BlobOptions, u.Buffer, u.File, u.FileOptions, u.INSPECT_MAX_BYTES, u.SlowBuffer, u.TranscodeEncoding, u.atob, u.btoa, u.constants, u.isAscii, u.isUtf8, u.kMaxLength, u.kStringMaxLength, u.resolveObjectURL, u.transcode;
|
|
809
|
+
})), x = /* @__PURE__ */ t(((e, t) => {
|
|
810
|
+
var n = typeof Reflect == "object" ? Reflect : null, r = n && typeof n.apply == "function" ? n.apply : function(e, t, n) {
|
|
811
|
+
return Function.prototype.apply.call(e, t, n);
|
|
812
|
+
}, i = n && typeof n.ownKeys == "function" ? n.ownKeys : Object.getOwnPropertySymbols ? function(e) {
|
|
813
|
+
return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e));
|
|
814
|
+
} : function(e) {
|
|
815
|
+
return Object.getOwnPropertyNames(e);
|
|
816
|
+
};
|
|
817
|
+
function a(e) {
|
|
818
|
+
console && console.warn && console.warn(e);
|
|
819
|
+
}
|
|
820
|
+
var o = Number.isNaN || function(e) {
|
|
821
|
+
return e !== e;
|
|
822
|
+
};
|
|
823
|
+
function s() {
|
|
824
|
+
s.init.call(this);
|
|
825
|
+
}
|
|
826
|
+
t.exports = s, t.exports.once = y, s.EventEmitter = s, s.prototype._events = void 0, s.prototype._eventsCount = 0, s.prototype._maxListeners = void 0;
|
|
827
|
+
var c = 10;
|
|
828
|
+
function l(e) {
|
|
829
|
+
if (typeof e != "function") throw TypeError("The \"listener\" argument must be of type Function. Received type " + typeof e);
|
|
830
|
+
}
|
|
831
|
+
Object.defineProperty(s, "defaultMaxListeners", {
|
|
832
|
+
enumerable: !0,
|
|
833
|
+
get: function() {
|
|
834
|
+
return c;
|
|
835
|
+
},
|
|
836
|
+
set: function(e) {
|
|
837
|
+
if (typeof e != "number" || e < 0 || o(e)) throw RangeError("The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received " + e + ".");
|
|
838
|
+
c = e;
|
|
839
|
+
}
|
|
840
|
+
}), s.init = function() {
|
|
841
|
+
(this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) && (this._events = Object.create(null), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
|
|
842
|
+
}, s.prototype.setMaxListeners = function(e) {
|
|
843
|
+
if (typeof e != "number" || e < 0 || o(e)) throw RangeError("The value of \"n\" is out of range. It must be a non-negative number. Received " + e + ".");
|
|
844
|
+
return this._maxListeners = e, this;
|
|
845
|
+
};
|
|
846
|
+
function u(e) {
|
|
847
|
+
return e._maxListeners === void 0 ? s.defaultMaxListeners : e._maxListeners;
|
|
848
|
+
}
|
|
849
|
+
s.prototype.getMaxListeners = function() {
|
|
850
|
+
return u(this);
|
|
851
|
+
}, s.prototype.emit = function(e) {
|
|
852
|
+
for (var t = [], n = 1; n < arguments.length; n++) t.push(arguments[n]);
|
|
853
|
+
var i = e === "error", a = this._events;
|
|
854
|
+
if (a !== void 0) i &&= a.error === void 0;
|
|
855
|
+
else if (!i) return !1;
|
|
856
|
+
if (i) {
|
|
857
|
+
var o;
|
|
858
|
+
if (t.length > 0 && (o = t[0]), o instanceof Error) throw o;
|
|
859
|
+
var s = /* @__PURE__ */ Error("Unhandled error." + (o ? " (" + o.message + ")" : ""));
|
|
860
|
+
throw s.context = o, s;
|
|
861
|
+
}
|
|
862
|
+
var c = a[e];
|
|
863
|
+
if (c === void 0) return !1;
|
|
864
|
+
if (typeof c == "function") r(c, this, t);
|
|
865
|
+
else for (var l = c.length, u = g(c, l), n = 0; n < l; ++n) r(u[n], this, t);
|
|
866
|
+
return !0;
|
|
867
|
+
};
|
|
868
|
+
function d(e, t, n, r) {
|
|
869
|
+
var i, o, s;
|
|
870
|
+
if (l(n), o = e._events, o === void 0 ? (o = e._events = Object.create(null), e._eventsCount = 0) : (o.newListener !== void 0 && (e.emit("newListener", t, n.listener ? n.listener : n), o = e._events), s = o[t]), s === void 0) s = o[t] = n, ++e._eventsCount;
|
|
871
|
+
else if (typeof s == "function" ? s = o[t] = r ? [n, s] : [s, n] : r ? s.unshift(n) : s.push(n), i = u(e), i > 0 && s.length > i && !s.warned) {
|
|
872
|
+
s.warned = !0;
|
|
873
|
+
var c = /* @__PURE__ */ Error("Possible EventEmitter memory leak detected. " + s.length + " " + String(t) + " listeners added. Use emitter.setMaxListeners() to increase limit");
|
|
874
|
+
c.name = "MaxListenersExceededWarning", c.emitter = e, c.type = t, c.count = s.length, a(c);
|
|
875
|
+
}
|
|
876
|
+
return e;
|
|
877
|
+
}
|
|
878
|
+
s.prototype.addListener = function(e, t) {
|
|
879
|
+
return d(this, e, t, !1);
|
|
880
|
+
}, s.prototype.on = s.prototype.addListener, s.prototype.prependListener = function(e, t) {
|
|
881
|
+
return d(this, e, t, !0);
|
|
882
|
+
};
|
|
883
|
+
function f() {
|
|
884
|
+
if (!this.fired) return this.target.removeListener(this.type, this.wrapFn), this.fired = !0, arguments.length === 0 ? this.listener.call(this.target) : this.listener.apply(this.target, arguments);
|
|
885
|
+
}
|
|
886
|
+
function p(e, t, n) {
|
|
887
|
+
var r = {
|
|
888
|
+
fired: !1,
|
|
889
|
+
wrapFn: void 0,
|
|
890
|
+
target: e,
|
|
891
|
+
type: t,
|
|
892
|
+
listener: n
|
|
893
|
+
}, i = f.bind(r);
|
|
894
|
+
return i.listener = n, r.wrapFn = i, i;
|
|
895
|
+
}
|
|
896
|
+
s.prototype.once = function(e, t) {
|
|
897
|
+
return l(t), this.on(e, p(this, e, t)), this;
|
|
898
|
+
}, s.prototype.prependOnceListener = function(e, t) {
|
|
899
|
+
return l(t), this.prependListener(e, p(this, e, t)), this;
|
|
900
|
+
}, s.prototype.removeListener = function(e, t) {
|
|
901
|
+
var n, r, i, a, o;
|
|
902
|
+
if (l(t), r = this._events, r === void 0 || (n = r[e], n === void 0)) return this;
|
|
903
|
+
if (n === t || n.listener === t) --this._eventsCount === 0 ? this._events = Object.create(null) : (delete r[e], r.removeListener && this.emit("removeListener", e, n.listener || t));
|
|
904
|
+
else if (typeof n != "function") {
|
|
905
|
+
for (i = -1, a = n.length - 1; a >= 0; a--) if (n[a] === t || n[a].listener === t) {
|
|
906
|
+
o = n[a].listener, i = a;
|
|
907
|
+
break;
|
|
908
|
+
}
|
|
909
|
+
if (i < 0) return this;
|
|
910
|
+
i === 0 ? n.shift() : _(n, i), n.length === 1 && (r[e] = n[0]), r.removeListener !== void 0 && this.emit("removeListener", e, o || t);
|
|
911
|
+
}
|
|
912
|
+
return this;
|
|
913
|
+
}, s.prototype.off = s.prototype.removeListener, s.prototype.removeAllListeners = function(e) {
|
|
914
|
+
var t, n = this._events, r;
|
|
915
|
+
if (n === void 0) return this;
|
|
916
|
+
if (n.removeListener === void 0) return arguments.length === 0 ? (this._events = Object.create(null), this._eventsCount = 0) : n[e] !== void 0 && (--this._eventsCount === 0 ? this._events = Object.create(null) : delete n[e]), this;
|
|
917
|
+
if (arguments.length === 0) {
|
|
918
|
+
var i = Object.keys(n), a;
|
|
919
|
+
for (r = 0; r < i.length; ++r) a = i[r], a !== "removeListener" && this.removeAllListeners(a);
|
|
920
|
+
return this.removeAllListeners("removeListener"), this._events = Object.create(null), this._eventsCount = 0, this;
|
|
921
|
+
}
|
|
922
|
+
if (t = n[e], typeof t == "function") this.removeListener(e, t);
|
|
923
|
+
else if (t !== void 0) for (r = t.length - 1; r >= 0; r--) this.removeListener(e, t[r]);
|
|
924
|
+
return this;
|
|
925
|
+
};
|
|
926
|
+
function m(e, t, n) {
|
|
927
|
+
var r = e._events;
|
|
928
|
+
if (r === void 0) return [];
|
|
929
|
+
var i = r[t];
|
|
930
|
+
return i === void 0 ? [] : typeof i == "function" ? n ? [i.listener || i] : [i] : n ? v(i) : g(i, i.length);
|
|
931
|
+
}
|
|
932
|
+
s.prototype.listeners = function(e) {
|
|
933
|
+
return m(this, e, !0);
|
|
934
|
+
}, s.prototype.rawListeners = function(e) {
|
|
935
|
+
return m(this, e, !1);
|
|
936
|
+
}, s.listenerCount = function(e, t) {
|
|
937
|
+
return typeof e.listenerCount == "function" ? e.listenerCount(t) : h.call(e, t);
|
|
938
|
+
}, s.prototype.listenerCount = h;
|
|
939
|
+
function h(e) {
|
|
940
|
+
var t = this._events;
|
|
941
|
+
if (t !== void 0) {
|
|
942
|
+
var n = t[e];
|
|
943
|
+
if (typeof n == "function") return 1;
|
|
944
|
+
if (n !== void 0) return n.length;
|
|
945
|
+
}
|
|
946
|
+
return 0;
|
|
947
|
+
}
|
|
948
|
+
s.prototype.eventNames = function() {
|
|
949
|
+
return this._eventsCount > 0 ? i(this._events) : [];
|
|
950
|
+
};
|
|
951
|
+
function g(e, t) {
|
|
952
|
+
for (var n = Array(t), r = 0; r < t; ++r) n[r] = e[r];
|
|
953
|
+
return n;
|
|
954
|
+
}
|
|
955
|
+
function _(e, t) {
|
|
956
|
+
for (; t + 1 < e.length; t++) e[t] = e[t + 1];
|
|
957
|
+
e.pop();
|
|
958
|
+
}
|
|
959
|
+
function v(e) {
|
|
960
|
+
for (var t = Array(e.length), n = 0; n < t.length; ++n) t[n] = e[n].listener || e[n];
|
|
961
|
+
return t;
|
|
962
|
+
}
|
|
963
|
+
function y(e, t) {
|
|
964
|
+
return new Promise(function(n, r) {
|
|
965
|
+
function i(n) {
|
|
966
|
+
e.removeListener(t, a), r(n);
|
|
967
|
+
}
|
|
968
|
+
function a() {
|
|
969
|
+
typeof e.removeListener == "function" && e.removeListener("error", i), n([].slice.call(arguments));
|
|
970
|
+
}
|
|
971
|
+
x(e, t, a, { once: !0 }), t !== "error" && b(e, i, { once: !0 });
|
|
972
|
+
});
|
|
973
|
+
}
|
|
974
|
+
function b(e, t, n) {
|
|
975
|
+
typeof e.on == "function" && x(e, "error", t, n);
|
|
976
|
+
}
|
|
977
|
+
function x(e, t, n, r) {
|
|
978
|
+
if (typeof e.on == "function") r.once ? e.once(t, n) : e.on(t, n);
|
|
979
|
+
else if (typeof e.addEventListener == "function") e.addEventListener(t, function i(a) {
|
|
980
|
+
r.once && e.removeEventListener(t, i), n(a);
|
|
981
|
+
});
|
|
982
|
+
else throw TypeError("The \"emitter\" argument must be of type EventEmitter. Received type " + typeof e);
|
|
983
|
+
}
|
|
984
|
+
})), S = /* @__PURE__ */ t(((e, t) => {
|
|
985
|
+
var n = ["out", "err"];
|
|
986
|
+
t.exports = class {
|
|
987
|
+
constructor(e, t) {
|
|
988
|
+
if (!n.includes(e)) throw Error("incorrect std output type");
|
|
989
|
+
this.type = e, this.string = t;
|
|
990
|
+
}
|
|
991
|
+
};
|
|
992
|
+
})), C = /* @__PURE__ */ t(((e, t) => {
|
|
993
|
+
var n = S();
|
|
994
|
+
t.exports = class {
|
|
995
|
+
constructor(e = [], t = 0) {
|
|
996
|
+
if (typeof t != "number") throw Error("Command Result ExitCode must be a number");
|
|
997
|
+
if (!Array.isArray(e)) throw Error("Command Result be array");
|
|
998
|
+
this.std = e, this.exitCode = t;
|
|
956
999
|
}
|
|
957
|
-
|
|
958
|
-
|
|
1000
|
+
addStdOutLine(e) {
|
|
1001
|
+
this.std.push(new n("out", e));
|
|
959
1002
|
}
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
let r = typeof t == "bigint" ? "n" : "", i;
|
|
963
|
-
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 K.ERR_OUT_OF_RANGE("value", i, e);
|
|
964
|
-
}
|
|
965
|
-
re(r, i, a);
|
|
1003
|
+
addStdErrLine(e) {
|
|
1004
|
+
this.std.push(new n("err", e));
|
|
966
1005
|
}
|
|
967
|
-
|
|
968
|
-
|
|
1006
|
+
getStdOutput() {
|
|
1007
|
+
return this.std;
|
|
969
1008
|
}
|
|
970
|
-
|
|
971
|
-
|
|
1009
|
+
getExitCode() {
|
|
1010
|
+
return this.exitCode;
|
|
972
1011
|
}
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
for (; e.length % 4 != 0;) e += "=";
|
|
977
|
-
return e;
|
|
1012
|
+
flush() {
|
|
1013
|
+
let e = this.std;
|
|
1014
|
+
return this.std = [], e;
|
|
978
1015
|
}
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
1016
|
+
};
|
|
1017
|
+
})), w = /* @__PURE__ */ t(((e, t) => {
|
|
1018
|
+
b();
|
|
1019
|
+
var n = x(), r = n.EventEmitter || n.default || n;
|
|
1020
|
+
function i(e) {
|
|
1021
|
+
if (!e) return [];
|
|
1022
|
+
let t = typeof e == "string" ? e : e instanceof Uint8Array || y !== void 0 && y.isBuffer(e) ? new TextDecoder().decode(e) : String(e), n = [], r = 0;
|
|
1023
|
+
for (; r < t.length;) {
|
|
1024
|
+
let e = t[r], i = t.charCodeAt(r);
|
|
1025
|
+
if (i === 27) {
|
|
1026
|
+
if (t.charCodeAt(r + 1) === 127 || t.charCodeAt(r + 1) === 8) {
|
|
1027
|
+
n.push("^W"), r += 2;
|
|
1028
|
+
continue;
|
|
1029
|
+
}
|
|
1030
|
+
if (t[r + 1] === "[" || t[r + 1] === "O") {
|
|
1031
|
+
let e = r + 2;
|
|
1032
|
+
for (; e < t.length && t.charCodeAt(e) >= 32 && t.charCodeAt(e) <= 63;) e++;
|
|
1033
|
+
if (e < t.length) {
|
|
1034
|
+
let i = t.slice(r + 2, e + 1), a = {
|
|
1035
|
+
A: "ArrowUp",
|
|
1036
|
+
B: "ArrowDown",
|
|
1037
|
+
C: "ArrowRight",
|
|
1038
|
+
D: "ArrowLeft",
|
|
1039
|
+
H: "Home",
|
|
1040
|
+
F: "End",
|
|
1041
|
+
"1~": "Home",
|
|
1042
|
+
"3~": "Delete",
|
|
1043
|
+
"4~": "End",
|
|
1044
|
+
"5~": "PageUp",
|
|
1045
|
+
"6~": "PageDown",
|
|
1046
|
+
"7~": "Home",
|
|
1047
|
+
"8~": "End"
|
|
1048
|
+
};
|
|
1049
|
+
a[i] && n.push(a[i]), r = e + 1;
|
|
997
1050
|
continue;
|
|
998
1051
|
}
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
if (--t < 0) break;
|
|
1003
|
-
a.push(n);
|
|
1004
|
-
} else if (n < 2048) {
|
|
1005
|
-
if ((t -= 2) < 0) break;
|
|
1006
|
-
a.push(n >> 6 | 192, n & 63 | 128);
|
|
1007
|
-
} else if (n < 65536) {
|
|
1008
|
-
if ((t -= 3) < 0) break;
|
|
1009
|
-
a.push(n >> 12 | 224, n >> 6 & 63 | 128, n & 63 | 128);
|
|
1010
|
-
} else if (n < 1114112) {
|
|
1011
|
-
if ((t -= 4) < 0) break;
|
|
1012
|
-
a.push(n >> 18 | 240, n >> 12 & 63 | 128, n >> 6 & 63 | 128, n & 63 | 128);
|
|
1013
|
-
} else throw Error("Invalid code point");
|
|
1052
|
+
}
|
|
1053
|
+
n.push("Escape"), r++;
|
|
1054
|
+
continue;
|
|
1014
1055
|
}
|
|
1015
|
-
|
|
1056
|
+
if (i === 13 || i === 10) {
|
|
1057
|
+
n.push("Enter"), i === 13 && t[r + 1] === "\n" && r++, r++;
|
|
1058
|
+
continue;
|
|
1059
|
+
}
|
|
1060
|
+
if (i === 127 || i === 8) {
|
|
1061
|
+
n.push("Backspace"), r++;
|
|
1062
|
+
continue;
|
|
1063
|
+
}
|
|
1064
|
+
if (i === 9) {
|
|
1065
|
+
n.push("Tab"), r++;
|
|
1066
|
+
continue;
|
|
1067
|
+
}
|
|
1068
|
+
if (i >= 1 && i <= 26) {
|
|
1069
|
+
n.push("^" + String.fromCharCode(i + 64)), r++;
|
|
1070
|
+
continue;
|
|
1071
|
+
}
|
|
1072
|
+
n.push(e), r++;
|
|
1016
1073
|
}
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1074
|
+
return n;
|
|
1075
|
+
}
|
|
1076
|
+
t.exports = {
|
|
1077
|
+
TtyStream: class extends r {
|
|
1078
|
+
constructor(e = {}) {
|
|
1079
|
+
super(), this.isTTY = e.isTTY !== !1, this.readable = !0, this.writable = !0, this.columns = e.columns || 80, this.rows = e.rows || 24, this.isRaw = !1, this._encoding = null, this._onWrite = e.onWrite || null;
|
|
1080
|
+
}
|
|
1081
|
+
write(e, t, n) {
|
|
1082
|
+
return e == null ? !0 : (typeof this._onWrite == "function" && this._onWrite(e), this.emit("data", this._formatChunk(e)), typeof t == "function" ? t() : typeof n == "function" && n(), !0);
|
|
1083
|
+
}
|
|
1084
|
+
pushData(e) {
|
|
1085
|
+
e != null && this.emit("data", this._formatChunk(e));
|
|
1086
|
+
}
|
|
1087
|
+
_formatChunk(e) {
|
|
1088
|
+
return this._encoding ? typeof e == "string" ? e : e instanceof Uint8Array || y !== void 0 && y.isBuffer(e) ? new TextDecoder().decode(e) : String(e) : e;
|
|
1089
|
+
}
|
|
1090
|
+
setRawMode(e) {
|
|
1091
|
+
return this.isRaw = !!e, this;
|
|
1092
|
+
}
|
|
1093
|
+
setEncoding(e) {
|
|
1094
|
+
return this._encoding = e, this;
|
|
1095
|
+
}
|
|
1096
|
+
getWindowSize() {
|
|
1097
|
+
return [this.columns, this.rows];
|
|
1098
|
+
}
|
|
1099
|
+
resize(e, t) {
|
|
1100
|
+
this.columns = e, this.rows = t, this.emit("resize");
|
|
1101
|
+
}
|
|
1102
|
+
resume() {
|
|
1103
|
+
return this;
|
|
1104
|
+
}
|
|
1105
|
+
pause() {
|
|
1106
|
+
return this;
|
|
1107
|
+
}
|
|
1108
|
+
pipe(e) {
|
|
1109
|
+
return this.on("data", (t) => e.write(t)), e;
|
|
1110
|
+
}
|
|
1111
|
+
unpipe() {
|
|
1112
|
+
return this;
|
|
1113
|
+
}
|
|
1114
|
+
end(e, t, n) {
|
|
1115
|
+
return e != null && this.write(e, typeof t == "string" ? t : void 0), this.emit("end"), typeof t == "function" ? t() : typeof n == "function" && n(), this;
|
|
1116
|
+
}
|
|
1117
|
+
destroy() {
|
|
1118
|
+
this.removeAllListeners();
|
|
1119
|
+
}
|
|
1120
|
+
toString() {
|
|
1121
|
+
return "";
|
|
1122
|
+
}
|
|
1123
|
+
valueOf() {
|
|
1124
|
+
return "";
|
|
1125
|
+
}
|
|
1126
|
+
},
|
|
1127
|
+
parseVtKeys: i
|
|
1128
|
+
};
|
|
1129
|
+
})), T = /* @__PURE__ */ t(((e, t) => {
|
|
1130
|
+
var n = x(), r = C(), { TtyStream: i, parseVtKeys: a } = w(), o = n.EventEmitter || n.default || n;
|
|
1131
|
+
t.exports = class extends o {
|
|
1132
|
+
constructor(e, t) {
|
|
1133
|
+
super(), this.arguments = e, this.result = new r(), this.context = t || null;
|
|
1134
|
+
let n = this.context && typeof this.context.getVar == "function" && parseInt(this.context.getVar("COLUMNS"), 10) || 80, o = this.context && typeof this.context.getVar == "function" && parseInt(this.context.getVar("LINES"), 10) || 24;
|
|
1135
|
+
this.stdinStream = new i({
|
|
1136
|
+
columns: n,
|
|
1137
|
+
rows: o
|
|
1138
|
+
}), this.stdin = this.stdinStream, this.stdout = new i({
|
|
1139
|
+
columns: n,
|
|
1140
|
+
rows: o,
|
|
1141
|
+
onWrite: (e) => this.emit("stdout", e)
|
|
1142
|
+
}), this.stderr = new i({
|
|
1143
|
+
columns: n,
|
|
1144
|
+
rows: o,
|
|
1145
|
+
onWrite: (e) => this.emit("stderr", e)
|
|
1146
|
+
}), this.stdinStream.on("data", (e) => {
|
|
1147
|
+
if (!this.captureInput) return;
|
|
1148
|
+
let t = a(e);
|
|
1149
|
+
for (let e of t) !this.interactive && !this.stdinStream.isRaw && (e === "Enter" ? this.stdout.write("\r\n") : e === "Backspace" ? this.stdout.write("\b \b") : e.length === 1 && this.stdout.write(e)), this.onInput(e);
|
|
1150
|
+
});
|
|
1021
1151
|
}
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
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);
|
|
1025
|
-
return a;
|
|
1152
|
+
get name() {
|
|
1153
|
+
return "unnamed";
|
|
1026
1154
|
}
|
|
1027
|
-
|
|
1028
|
-
return
|
|
1155
|
+
run() {
|
|
1156
|
+
return Promise.reject("Command not implemented...");
|
|
1029
1157
|
}
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1158
|
+
runCommand() {
|
|
1159
|
+
return Promise.resolve().then(() => this.run()).then((e) => (e && e.split(/\r?\n/).forEach((e) => this.stdOut = e), this.result)).catch((e) => {
|
|
1160
|
+
if (e && e.__type) throw e;
|
|
1161
|
+
return e && (this.stdErr = e.message || e), this.exitCode = 127, this.result;
|
|
1162
|
+
});
|
|
1034
1163
|
}
|
|
1035
|
-
|
|
1036
|
-
|
|
1164
|
+
onInput(e) {}
|
|
1165
|
+
set exitCode(e) {
|
|
1166
|
+
this.result.exitCode = e;
|
|
1037
1167
|
}
|
|
1038
|
-
|
|
1039
|
-
|
|
1168
|
+
set stdOut(e) {
|
|
1169
|
+
this.result.addStdOutLine(e);
|
|
1040
1170
|
}
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
for (let n = 0; n < 16; ++n) {
|
|
1044
|
-
let r = n * 16;
|
|
1045
|
-
for (let i = 0; i < 16; ++i) t[r + i] = e[n] + e[i];
|
|
1046
|
-
}
|
|
1047
|
-
return t;
|
|
1048
|
-
})();
|
|
1049
|
-
function $(e) {
|
|
1050
|
-
return typeof BigInt > "u" ? pe : e;
|
|
1171
|
+
set stdErr(e) {
|
|
1172
|
+
this.result.addStdErrLine(e);
|
|
1051
1173
|
}
|
|
1052
|
-
|
|
1053
|
-
|
|
1174
|
+
flush() {
|
|
1175
|
+
this.emit("flush", this.result.flush());
|
|
1054
1176
|
}
|
|
1055
|
-
}
|
|
1177
|
+
};
|
|
1056
1178
|
})), E = /* @__PURE__ */ t(((e, t) => {
|
|
1057
|
-
var n =
|
|
1179
|
+
var n = T();
|
|
1180
|
+
t.exports = class extends n {
|
|
1181
|
+
constructor(e, t) {
|
|
1182
|
+
super(e, t);
|
|
1183
|
+
}
|
|
1184
|
+
};
|
|
1185
|
+
})), D = /* @__PURE__ */ t(((e, t) => {
|
|
1186
|
+
var n = E();
|
|
1058
1187
|
function r(e) {
|
|
1059
1188
|
return /^#!\/(sh\.js|bin\/(sh|brsh))/.test(e);
|
|
1060
1189
|
}
|
|
@@ -1219,7 +1348,7 @@ var h, g, _, v, y, b, x, S, C, w, T = e((() => {
|
|
|
1219
1348
|
}
|
|
1220
1349
|
_executeNode(e) {
|
|
1221
1350
|
if (e.type === "function") {
|
|
1222
|
-
let t = e.name, n = e.bodyLines, r = this, i =
|
|
1351
|
+
let t = e.name, n = e.bodyLines, r = this, i = E(), a = class extends i {
|
|
1223
1352
|
static get name() {
|
|
1224
1353
|
return t;
|
|
1225
1354
|
}
|
|
@@ -1419,7 +1548,8 @@ var h, g, _, v, y, b, x, S, C, w, T = e((() => {
|
|
|
1419
1548
|
}
|
|
1420
1549
|
}
|
|
1421
1550
|
}, t.exports.isKnownInterpreter = r;
|
|
1422
|
-
})),
|
|
1551
|
+
})), O = /* @__PURE__ */ t(((e, t) => {
|
|
1552
|
+
b();
|
|
1423
1553
|
var n = new Set([
|
|
1424
1554
|
"getFileByPath",
|
|
1425
1555
|
"setFileByPath",
|
|
@@ -1438,8 +1568,7 @@ var h, g, _, v, y, b, x, S, C, w, T = e((() => {
|
|
|
1438
1568
|
"isSymlink",
|
|
1439
1569
|
"readSymlink",
|
|
1440
1570
|
"createSymlink"
|
|
1441
|
-
])
|
|
1442
|
-
t.exports = class {
|
|
1571
|
+
]), r = class {
|
|
1443
1572
|
isReadable(e) {
|
|
1444
1573
|
let t = this.getMode(e);
|
|
1445
1574
|
return t === null ? !1 : (t & 256) != 0;
|
|
@@ -1473,94 +1602,114 @@ var h, g, _, v, y, b, x, S, C, w, T = e((() => {
|
|
|
1473
1602
|
this._changeScheduled = !1, typeof this._onChange == "function" && this._onChange(this.getRaw(), this.getRawPermissions());
|
|
1474
1603
|
}));
|
|
1475
1604
|
}
|
|
1605
|
+
}, i = class extends Uint8Array {
|
|
1606
|
+
constructor(e, t) {
|
|
1607
|
+
super(e), Object.defineProperty(this, "mimeType", {
|
|
1608
|
+
value: t,
|
|
1609
|
+
enumerable: !1,
|
|
1610
|
+
configurable: !1,
|
|
1611
|
+
writable: !1
|
|
1612
|
+
});
|
|
1613
|
+
}
|
|
1614
|
+
toString() {
|
|
1615
|
+
if (y !== void 0) return `data:${this.mimeType};base64,${y.from(this).toString("base64")}`;
|
|
1616
|
+
let e = "", t = 8192;
|
|
1617
|
+
for (let n = 0; n < this.length; n += t) e += String.fromCharCode(...this.subarray(n, n + t));
|
|
1618
|
+
return `data:${this.mimeType};base64,${btoa(e)}`;
|
|
1619
|
+
}
|
|
1620
|
+
}, a = class {
|
|
1621
|
+
constructor(e) {
|
|
1622
|
+
this.target = e;
|
|
1623
|
+
}
|
|
1476
1624
|
};
|
|
1625
|
+
t.exports = r, t.exports.BinaryFile = i, t.exports.SymlinkRef = a;
|
|
1477
1626
|
}));
|
|
1478
1627
|
//#endregion
|
|
1479
1628
|
//#region node_modules/vite-plugin-node-polyfills/shims/process/dist/index.js
|
|
1480
|
-
function
|
|
1629
|
+
function k(e) {
|
|
1481
1630
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
1482
1631
|
}
|
|
1483
|
-
function
|
|
1632
|
+
function A() {
|
|
1484
1633
|
throw Error("setTimeout has not been defined");
|
|
1485
1634
|
}
|
|
1486
|
-
function
|
|
1635
|
+
function j() {
|
|
1487
1636
|
throw Error("clearTimeout has not been defined");
|
|
1488
1637
|
}
|
|
1489
|
-
function
|
|
1490
|
-
if (
|
|
1491
|
-
if ((
|
|
1638
|
+
function M(e) {
|
|
1639
|
+
if (B === setTimeout) return setTimeout(e, 0);
|
|
1640
|
+
if ((B === A || !B) && setTimeout) return B = setTimeout, setTimeout(e, 0);
|
|
1492
1641
|
try {
|
|
1493
|
-
return
|
|
1642
|
+
return B(e, 0);
|
|
1494
1643
|
} catch {
|
|
1495
1644
|
try {
|
|
1496
|
-
return
|
|
1645
|
+
return B.call(null, e, 0);
|
|
1497
1646
|
} catch {
|
|
1498
|
-
return
|
|
1647
|
+
return B.call(this, e, 0);
|
|
1499
1648
|
}
|
|
1500
1649
|
}
|
|
1501
1650
|
}
|
|
1502
|
-
function
|
|
1503
|
-
if (
|
|
1504
|
-
if ((
|
|
1651
|
+
function N(e) {
|
|
1652
|
+
if (V === clearTimeout) return clearTimeout(e);
|
|
1653
|
+
if ((V === j || !V) && clearTimeout) return V = clearTimeout, clearTimeout(e);
|
|
1505
1654
|
try {
|
|
1506
|
-
return
|
|
1655
|
+
return V(e);
|
|
1507
1656
|
} catch {
|
|
1508
1657
|
try {
|
|
1509
|
-
return
|
|
1658
|
+
return V.call(null, e);
|
|
1510
1659
|
} catch {
|
|
1511
|
-
return
|
|
1660
|
+
return V.call(this, e);
|
|
1512
1661
|
}
|
|
1513
1662
|
}
|
|
1514
1663
|
}
|
|
1515
|
-
function N() {
|
|
1516
|
-
!H || !U || (H = !1, U.length ? V = U.concat(V) : W = -1, V.length && P());
|
|
1517
|
-
}
|
|
1518
1664
|
function P() {
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1665
|
+
!U || !W || (U = !1, W.length ? H = W.concat(H) : G = -1, H.length && F());
|
|
1666
|
+
}
|
|
1667
|
+
function F() {
|
|
1668
|
+
if (!U) {
|
|
1669
|
+
var e = M(P);
|
|
1670
|
+
U = !0;
|
|
1671
|
+
for (var t = H.length; t;) {
|
|
1672
|
+
for (W = H, H = []; ++G < t;) W && W[G].run();
|
|
1673
|
+
G = -1, t = H.length;
|
|
1674
|
+
}
|
|
1675
|
+
W = null, U = !1, N(e);
|
|
1527
1676
|
}
|
|
1528
1677
|
}
|
|
1529
|
-
function
|
|
1678
|
+
function I(e, t) {
|
|
1530
1679
|
this.fun = e, this.array = t;
|
|
1531
1680
|
}
|
|
1532
|
-
function
|
|
1533
|
-
var
|
|
1534
|
-
|
|
1681
|
+
function L() {}
|
|
1682
|
+
var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
|
|
1683
|
+
R = { exports: {} }, z = R.exports = {}, (function() {
|
|
1535
1684
|
try {
|
|
1536
|
-
|
|
1685
|
+
B = typeof setTimeout == "function" ? setTimeout : A;
|
|
1537
1686
|
} catch {
|
|
1538
|
-
|
|
1687
|
+
B = A;
|
|
1539
1688
|
}
|
|
1540
1689
|
try {
|
|
1541
|
-
|
|
1690
|
+
V = typeof clearTimeout == "function" ? clearTimeout : j;
|
|
1542
1691
|
} catch {
|
|
1543
|
-
|
|
1692
|
+
V = j;
|
|
1544
1693
|
}
|
|
1545
|
-
})(),
|
|
1694
|
+
})(), H = [], U = !1, G = -1, z.nextTick = function(e) {
|
|
1546
1695
|
var t = Array(arguments.length - 1);
|
|
1547
1696
|
if (arguments.length > 1) for (var n = 1; n < arguments.length; n++) t[n - 1] = arguments[n];
|
|
1548
|
-
|
|
1549
|
-
},
|
|
1697
|
+
H.push(new I(e, t)), H.length === 1 && !U && M(F);
|
|
1698
|
+
}, I.prototype.run = function() {
|
|
1550
1699
|
this.fun.apply(null, this.array);
|
|
1551
|
-
},
|
|
1700
|
+
}, z.title = "browser", z.browser = !0, z.env = {}, z.argv = [], z.version = "", z.versions = {}, z.on = L, z.addListener = L, z.once = L, z.off = L, z.removeListener = L, z.removeAllListeners = L, z.emit = L, z.prependListener = L, z.prependOnceListener = L, z.listeners = function(e) {
|
|
1552
1701
|
return [];
|
|
1553
|
-
},
|
|
1702
|
+
}, z.binding = function(e) {
|
|
1554
1703
|
throw Error("process.binding is not supported");
|
|
1555
|
-
},
|
|
1704
|
+
}, z.cwd = function() {
|
|
1556
1705
|
return "/";
|
|
1557
|
-
},
|
|
1706
|
+
}, z.chdir = function(e) {
|
|
1558
1707
|
throw Error("process.chdir is not supported");
|
|
1559
|
-
},
|
|
1708
|
+
}, z.umask = function() {
|
|
1560
1709
|
return 0;
|
|
1561
|
-
},
|
|
1562
|
-
})),
|
|
1563
|
-
var n =
|
|
1710
|
+
}, K = R.exports, q = /* @__PURE__ */ k(K);
|
|
1711
|
+
})), J = /* @__PURE__ */ t(((e, t) => {
|
|
1712
|
+
var n = T();
|
|
1564
1713
|
t.exports = class extends n {
|
|
1565
1714
|
get captureInput() {
|
|
1566
1715
|
return !0;
|
|
@@ -1569,33 +1718,47 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
1569
1718
|
return !0;
|
|
1570
1719
|
}
|
|
1571
1720
|
get terminalSize() {
|
|
1572
|
-
return {
|
|
1721
|
+
return this.stdout && this.stdout.columns && this.stdout.rows ? {
|
|
1722
|
+
cols: parseInt(this.context && this.context.getVar && this.context.getVar("COLUMNS"), 10) || this.stdout.columns || 80,
|
|
1723
|
+
rows: parseInt(this.context && this.context.getVar && this.context.getVar("LINES"), 10) || this.stdout.rows || 24
|
|
1724
|
+
} : {
|
|
1573
1725
|
cols: parseInt(this.context.getVar("COLUMNS"), 10) || 80,
|
|
1574
1726
|
rows: parseInt(this.context.getVar("LINES"), 10) || 24
|
|
1575
1727
|
};
|
|
1576
1728
|
}
|
|
1729
|
+
_enterAltScreen() {
|
|
1730
|
+
this._inAltScreen || (this._inAltScreen = !0, this.stdinStream && this.stdinStream.setRawMode(!0), this.stdout && this.stdout.write("\x1B[?1049h\x1B[2J\x1B[H"));
|
|
1731
|
+
}
|
|
1732
|
+
_exitAltScreen() {
|
|
1733
|
+
this._inAltScreen && (this._inAltScreen = !1, this.stdinStream && this.stdinStream.setRawMode(!1), this.stdout && this.stdout.write("\x1B[?1049l\x1B[?25h"));
|
|
1734
|
+
}
|
|
1735
|
+
runCommand() {
|
|
1736
|
+
return this.interactive && this._enterAltScreen(), super.runCommand().finally(() => {
|
|
1737
|
+
this._exitAltScreen();
|
|
1738
|
+
});
|
|
1739
|
+
}
|
|
1577
1740
|
};
|
|
1578
|
-
})),
|
|
1579
|
-
|
|
1580
|
-
var { BinaryFile: n, SymlinkRef: r } =
|
|
1741
|
+
})), Y = /* @__PURE__ */ t(((e, t) => {
|
|
1742
|
+
b(), ee();
|
|
1743
|
+
var { BinaryFile: n, SymlinkRef: r } = O(), i = new Uint8Array([
|
|
1581
1744
|
66,
|
|
1582
1745
|
82,
|
|
1583
1746
|
70,
|
|
1584
1747
|
83
|
|
1585
1748
|
]), a = 2;
|
|
1586
|
-
function
|
|
1749
|
+
function o(e) {
|
|
1587
1750
|
if (!e) return !1;
|
|
1588
1751
|
let t = e instanceof Uint8Array ? e : e instanceof ArrayBuffer || ArrayBuffer.isView(e) ? new Uint8Array(e.buffer || e, e.byteOffset || 0, e.byteLength) : null;
|
|
1589
1752
|
return !t || t.length < 12 ? !1 : t[0] === i[0] && t[1] === i[1] && t[2] === i[2] && t[3] === i[3];
|
|
1590
1753
|
}
|
|
1591
|
-
function
|
|
1754
|
+
function s(e = {}, t = {}, n = {}) {
|
|
1592
1755
|
let o = new TextEncoder(), s = [], c = 0, l = (e) => {
|
|
1593
1756
|
let t = e instanceof Uint8Array ? e : new Uint8Array(e), n = c;
|
|
1594
1757
|
return s.push(t), c += t.byteLength, [n, t.byteLength];
|
|
1595
1758
|
}, u = {}, d = (e, t) => {
|
|
1596
1759
|
if (e == null) return null;
|
|
1597
1760
|
if (e instanceof r) return { $l: e.target };
|
|
1598
|
-
if (e instanceof Uint8Array ||
|
|
1761
|
+
if (e instanceof Uint8Array || y !== void 0 && y.isBuffer(e)) {
|
|
1599
1762
|
let n = e instanceof Uint8Array ? new Uint8Array(e.buffer, e.byteOffset, e.byteLength) : new Uint8Array(e), r = e.mimeType || (t.endsWith(".wasm") ? "application/wasm" : "application/octet-stream"), [i, a] = l(n);
|
|
1600
1763
|
return { $b: [
|
|
1601
1764
|
i,
|
|
@@ -1609,7 +1772,7 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
1609
1772
|
let t = e.indexOf(";"), n = e.indexOf(",", t);
|
|
1610
1773
|
if (t !== -1 && n !== -1 && e.slice(t + 1, n) === "base64") {
|
|
1611
1774
|
let r = e.slice(5, t), i = e.slice(n + 1), a;
|
|
1612
|
-
if (
|
|
1775
|
+
if (y !== void 0) a = new Uint8Array(y.from(i, "base64"));
|
|
1613
1776
|
else {
|
|
1614
1777
|
let e = atob(i);
|
|
1615
1778
|
a = new Uint8Array(e.length);
|
|
@@ -1647,42 +1810,42 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
1647
1810
|
_.set(i, 0);
|
|
1648
1811
|
let v = new DataView(_.buffer, _.byteOffset, _.byteLength);
|
|
1649
1812
|
v.setUint32(4, a, !0), v.setUint32(8, h.byteLength, !0), _.set(h, 12);
|
|
1650
|
-
let
|
|
1651
|
-
for (let e of s) _.set(e,
|
|
1813
|
+
let b = 12 + h.byteLength;
|
|
1814
|
+
for (let e of s) _.set(e, b), b += e.byteLength;
|
|
1652
1815
|
return _;
|
|
1653
1816
|
}
|
|
1654
|
-
function
|
|
1817
|
+
function c(e, t = {}) {
|
|
1655
1818
|
let i = e instanceof Uint8Array ? e : new Uint8Array(e.buffer || e, e.byteOffset || 0, e.byteLength);
|
|
1656
|
-
if (!
|
|
1657
|
-
let
|
|
1658
|
-
if (
|
|
1659
|
-
let
|
|
1660
|
-
if (
|
|
1661
|
-
let
|
|
1662
|
-
if (Array.isArray(
|
|
1663
|
-
let [e, t] =
|
|
1819
|
+
if (!o(i)) throw Error("Invalid BRFS binary container (missing BRFS magic header)");
|
|
1820
|
+
let s = new DataView(i.buffer, i.byteOffset, i.byteLength), c = s.getUint32(4, !0);
|
|
1821
|
+
if (c > a) throw Error(`Unsupported BRFS container version: ${c}`);
|
|
1822
|
+
let l = 12 + s.getUint32(8, !0);
|
|
1823
|
+
if (l > i.byteLength) throw Error("Corrupt BRFS binary container (header length exceeds buffer)");
|
|
1824
|
+
let u = new TextDecoder(), d = u.decode(i.subarray(12, l)), f = JSON.parse(d), p = i.subarray(l), m = Object.assign({}, t);
|
|
1825
|
+
if (Array.isArray(f.commandsSlice)) {
|
|
1826
|
+
let [e, t] = f.commandsSlice, n = u.decode(p.subarray(e, e + t));
|
|
1664
1827
|
try {
|
|
1665
1828
|
let e = Function(n)();
|
|
1666
|
-
e && typeof e == "object" && Object.assign(
|
|
1829
|
+
e && typeof e == "object" && Object.assign(m, e);
|
|
1667
1830
|
} catch {}
|
|
1668
1831
|
}
|
|
1669
|
-
let
|
|
1832
|
+
let h = (e) => {
|
|
1670
1833
|
if (!e || typeof e != "object") return e;
|
|
1671
1834
|
if ("$t" in e) {
|
|
1672
1835
|
let [t, n] = e.$t;
|
|
1673
|
-
return
|
|
1836
|
+
return u.decode(p.subarray(t, t + n));
|
|
1674
1837
|
}
|
|
1675
1838
|
if ("$b" in e) {
|
|
1676
1839
|
let [t, r, i] = e.$b;
|
|
1677
|
-
return new n(
|
|
1840
|
+
return new n(p.slice(t, t + r).buffer, i || "application/octet-stream");
|
|
1678
1841
|
}
|
|
1679
1842
|
if ("$l" in e) return new r(e.$l);
|
|
1680
1843
|
if ("$c" in e) {
|
|
1681
1844
|
let t = e.$c;
|
|
1682
|
-
if (
|
|
1683
|
-
if (
|
|
1684
|
-
let e =
|
|
1685
|
-
return Function("Command", "InteractiveCommand", `return (${
|
|
1845
|
+
if (m[t]) return m[t];
|
|
1846
|
+
if (f.inlineCommands && f.inlineCommands[t]) try {
|
|
1847
|
+
let e = T(), n = J();
|
|
1848
|
+
return Function("Command", "InteractiveCommand", `return (${f.inlineCommands[t]});`)(e, n);
|
|
1686
1849
|
} catch {
|
|
1687
1850
|
return null;
|
|
1688
1851
|
}
|
|
@@ -1691,7 +1854,7 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
1691
1854
|
if ("$d" in e) {
|
|
1692
1855
|
let t = {};
|
|
1693
1856
|
for (let [n, r] of Object.entries(e.$d)) {
|
|
1694
|
-
let e =
|
|
1857
|
+
let e = h(r);
|
|
1695
1858
|
e !== null && (t[n] = e);
|
|
1696
1859
|
}
|
|
1697
1860
|
return t;
|
|
@@ -1699,56 +1862,56 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
1699
1862
|
return e;
|
|
1700
1863
|
};
|
|
1701
1864
|
return {
|
|
1702
|
-
filesystem:
|
|
1703
|
-
permissions: Object.assign({},
|
|
1865
|
+
filesystem: h(f.tree) || {},
|
|
1866
|
+
permissions: Object.assign({}, f.permissions || {})
|
|
1704
1867
|
};
|
|
1705
1868
|
}
|
|
1706
|
-
function
|
|
1869
|
+
function l(e) {
|
|
1707
1870
|
if (!e) return !1;
|
|
1708
1871
|
let t = e instanceof Uint8Array ? e : e instanceof ArrayBuffer ? new Uint8Array(e) : ArrayBuffer.isView(e) ? new Uint8Array(e.buffer, e.byteOffset, e.byteLength) : null;
|
|
1709
1872
|
return !!(t && t.byteLength >= 2 && t[0] === 31 && t[1] === 139);
|
|
1710
1873
|
}
|
|
1711
|
-
async function
|
|
1874
|
+
async function u(e) {
|
|
1712
1875
|
if (typeof DecompressionStream < "u" && typeof Response < "u") {
|
|
1713
1876
|
let t = new DecompressionStream("gzip"), n = new Blob([e]).stream().pipeThrough(t), r = await new Response(n).arrayBuffer();
|
|
1714
1877
|
return new Uint8Array(r);
|
|
1715
1878
|
}
|
|
1716
|
-
if (
|
|
1717
|
-
let t =
|
|
1718
|
-
if (t) return new Uint8Array(t.gunzipSync(
|
|
1879
|
+
if (q !== void 0 && typeof q.getBuiltinModule == "function") {
|
|
1880
|
+
let t = q.getBuiltinModule("zlib");
|
|
1881
|
+
if (t) return new Uint8Array(t.gunzipSync(y.from(e.buffer, e.byteOffset, e.byteLength)));
|
|
1719
1882
|
}
|
|
1720
1883
|
throw Error("Gzip decompression is not supported in this environment");
|
|
1721
1884
|
}
|
|
1722
|
-
function
|
|
1723
|
-
return e ? !!(typeof e == "string" || typeof e.then == "function" || typeof e.arrayBuffer == "function" ||
|
|
1885
|
+
function d(e) {
|
|
1886
|
+
return e ? !!(typeof e == "string" || typeof e.then == "function" || typeof e.arrayBuffer == "function" || l(e)) : !1;
|
|
1724
1887
|
}
|
|
1725
|
-
async function
|
|
1888
|
+
async function f(e, t = {}) {
|
|
1726
1889
|
if (!e) return {
|
|
1727
1890
|
filesystem: {},
|
|
1728
1891
|
permissions: t
|
|
1729
1892
|
};
|
|
1730
|
-
if (typeof e.then == "function") return
|
|
1893
|
+
if (typeof e.then == "function") return f(await e, t);
|
|
1731
1894
|
if (typeof e.arrayBuffer == "function") {
|
|
1732
1895
|
let n = await e.arrayBuffer();
|
|
1733
|
-
return
|
|
1896
|
+
return f(new Uint8Array(n), t);
|
|
1734
1897
|
}
|
|
1735
1898
|
if (typeof e == "string") {
|
|
1736
|
-
if (!/^https?:\/\//i.test(e) &&
|
|
1737
|
-
let n =
|
|
1899
|
+
if (!/^https?:\/\//i.test(e) && q !== void 0 && typeof q.getBuiltinModule == "function" && typeof window > "u") try {
|
|
1900
|
+
let n = q.getBuiltinModule("fs");
|
|
1738
1901
|
if (n && n.existsSync(e)) {
|
|
1739
1902
|
let r = await n.promises.readFile(e);
|
|
1740
|
-
return
|
|
1903
|
+
return f(new Uint8Array(r.buffer, r.byteOffset, r.byteLength), t);
|
|
1741
1904
|
}
|
|
1742
1905
|
} catch {}
|
|
1743
1906
|
let n = await fetch(e);
|
|
1744
1907
|
if (!n.ok) throw Error(`Failed to load filesystem from ${e}: HTTP ${n.status}`);
|
|
1745
1908
|
let r = await n.arrayBuffer();
|
|
1746
|
-
return
|
|
1909
|
+
return f(new Uint8Array(r), t);
|
|
1747
1910
|
}
|
|
1748
1911
|
if (e instanceof ArrayBuffer || ArrayBuffer.isView(e)) {
|
|
1749
1912
|
let n = e instanceof Uint8Array ? e : e instanceof ArrayBuffer ? new Uint8Array(e) : new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
1750
|
-
if (
|
|
1751
|
-
let e =
|
|
1913
|
+
if (l(n) && (n = await u(n)), o(n)) {
|
|
1914
|
+
let e = c(n);
|
|
1752
1915
|
return {
|
|
1753
1916
|
filesystem: e.filesystem,
|
|
1754
1917
|
permissions: Object.assign({}, e.permissions, t)
|
|
@@ -1775,7 +1938,7 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
1775
1938
|
};
|
|
1776
1939
|
}
|
|
1777
1940
|
}
|
|
1778
|
-
return typeof e == "object" && e.filesystem && typeof e.permissions == "object" ?
|
|
1941
|
+
return typeof e == "object" && e.filesystem && typeof e.permissions == "object" ? d(e.filesystem) || o(e.filesystem) ? f(e.filesystem, Object.assign({}, e.permissions, t)) : {
|
|
1779
1942
|
filesystem: e.filesystem,
|
|
1780
1943
|
permissions: Object.assign({}, e.permissions, t)
|
|
1781
1944
|
} : {
|
|
@@ -1786,31 +1949,31 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
1786
1949
|
t.exports = {
|
|
1787
1950
|
MAGIC: i,
|
|
1788
1951
|
FORMAT_VERSION: a,
|
|
1789
|
-
isBinaryContainer:
|
|
1790
|
-
isGzipBytes:
|
|
1791
|
-
isAsyncFilesystemSource:
|
|
1792
|
-
resolveFilesystemSource:
|
|
1793
|
-
serializeBinaryFilesystem:
|
|
1794
|
-
deserializeBinaryFilesystem:
|
|
1952
|
+
isBinaryContainer: o,
|
|
1953
|
+
isGzipBytes: l,
|
|
1954
|
+
isAsyncFilesystemSource: d,
|
|
1955
|
+
resolveFilesystemSource: f,
|
|
1956
|
+
serializeBinaryFilesystem: s,
|
|
1957
|
+
deserializeBinaryFilesystem: c,
|
|
1795
1958
|
FilesystemStorage: class {
|
|
1796
1959
|
static async save(e, t = "brsh-rootfs") {
|
|
1797
|
-
let n = e.context ? e.context.fs : e, r =
|
|
1960
|
+
let n = e.context ? e.context.fs : e, r = s(n.getRaw(), n.getRawPermissions());
|
|
1798
1961
|
return typeof indexedDB < "u" && await this._idbPut(t, r), r;
|
|
1799
1962
|
}
|
|
1800
1963
|
static async load(e = "brsh-rootfs") {
|
|
1801
|
-
if (e instanceof Uint8Array || e instanceof ArrayBuffer || typeof e == "string" && (/^https?:\/\//i.test(e) || e.endsWith(".brfs"))) return
|
|
1964
|
+
if (e instanceof Uint8Array || e instanceof ArrayBuffer || typeof e == "string" && (/^https?:\/\//i.test(e) || e.endsWith(".brfs"))) return f(e);
|
|
1802
1965
|
if (typeof indexedDB < "u" && typeof e == "string") {
|
|
1803
1966
|
let t = await this._idbGet(e);
|
|
1804
|
-
if (t &&
|
|
1967
|
+
if (t && o(t)) return c(t);
|
|
1805
1968
|
}
|
|
1806
1969
|
return null;
|
|
1807
1970
|
}
|
|
1808
1971
|
static async loadOrFetch(e = "brsh-rootfs", t = {}) {
|
|
1809
|
-
return await this.load(e) ||
|
|
1972
|
+
return await this.load(e) || f(t);
|
|
1810
1973
|
}
|
|
1811
1974
|
static createAutoSave(e = "brsh-rootfs", t = null) {
|
|
1812
1975
|
return (n, r) => {
|
|
1813
|
-
let i =
|
|
1976
|
+
let i = s(n, r);
|
|
1814
1977
|
typeof indexedDB < "u" && this._idbPut(e, i).catch(() => {}), typeof t == "function" && t(i, n, r);
|
|
1815
1978
|
};
|
|
1816
1979
|
}
|
|
@@ -1846,28 +2009,9 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
1846
2009
|
}
|
|
1847
2010
|
}
|
|
1848
2011
|
};
|
|
1849
|
-
})),
|
|
1850
|
-
|
|
1851
|
-
var n =
|
|
1852
|
-
constructor(e, t) {
|
|
1853
|
-
super(e), Object.defineProperty(this, "mimeType", {
|
|
1854
|
-
value: t,
|
|
1855
|
-
enumerable: !1,
|
|
1856
|
-
configurable: !1,
|
|
1857
|
-
writable: !1
|
|
1858
|
-
});
|
|
1859
|
-
}
|
|
1860
|
-
toString() {
|
|
1861
|
-
if (w !== void 0) return `data:${this.mimeType};base64,${w.from(this).toString("base64")}`;
|
|
1862
|
-
let e = "", t = 8192;
|
|
1863
|
-
for (let n = 0; n < this.length; n += t) e += String.fromCharCode(...this.subarray(n, n + t));
|
|
1864
|
-
return `data:${this.mimeType};base64,${btoa(e)}`;
|
|
1865
|
-
}
|
|
1866
|
-
}, i = class {
|
|
1867
|
-
constructor(e) {
|
|
1868
|
-
this.target = e;
|
|
1869
|
-
}
|
|
1870
|
-
};
|
|
2012
|
+
})), te = /* @__PURE__ */ t(((e, t) => {
|
|
2013
|
+
b();
|
|
2014
|
+
var n = O(), { BinaryFile: r, SymlinkRef: i } = n;
|
|
1871
2015
|
function a(e) {
|
|
1872
2016
|
for (let t of Object.keys(e)) {
|
|
1873
2017
|
let n = e[t];
|
|
@@ -1876,7 +2020,7 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
1876
2020
|
let i = n.indexOf(";"), a = n.indexOf(",", i);
|
|
1877
2021
|
if (i !== -1 && a !== -1 && n.slice(i + 1, a) === "base64") {
|
|
1878
2022
|
let o = n.slice(5, i), s = n.slice(a + 1), c;
|
|
1879
|
-
if (
|
|
2023
|
+
if (y !== void 0) c = new Uint8Array(y.from(s, "base64"));
|
|
1880
2024
|
else {
|
|
1881
2025
|
let e = atob(s);
|
|
1882
2026
|
c = new Uint8Array(e.length);
|
|
@@ -1890,20 +2034,20 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
1890
2034
|
t.exports = class extends n {
|
|
1891
2035
|
constructor(e = "/", t = {}, n = {}, r = null) {
|
|
1892
2036
|
if (super(), t instanceof Uint8Array || t instanceof ArrayBuffer) {
|
|
1893
|
-
let { deserializeBinaryFilesystem: e } =
|
|
2037
|
+
let { deserializeBinaryFilesystem: e } = Y(), r = e(t);
|
|
1894
2038
|
t = r.filesystem, n = Object.assign({}, r.permissions, n);
|
|
1895
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)) {
|
|
1896
|
-
let { deserializeBinaryFilesystem: e } =
|
|
2040
|
+
let { deserializeBinaryFilesystem: e } = Y(), r = e(t);
|
|
1897
2041
|
t = r.filesystem, n = Object.assign({}, r.permissions, n);
|
|
1898
2042
|
}
|
|
1899
2043
|
a(t), this.fileSystem = t, this.permissions = Object.assign({}, n), this.cwd = e, this._onChange = r, this._changeScheduled = !1;
|
|
1900
2044
|
}
|
|
1901
2045
|
toBinaryContainer(e = {}) {
|
|
1902
|
-
let { serializeBinaryFilesystem: t } =
|
|
2046
|
+
let { serializeBinaryFilesystem: t } = Y();
|
|
1903
2047
|
return t(this.fileSystem, this.permissions, e);
|
|
1904
2048
|
}
|
|
1905
2049
|
static fromBinaryContainer(e, t = {}) {
|
|
1906
|
-
let { deserializeBinaryFilesystem: n } =
|
|
2050
|
+
let { deserializeBinaryFilesystem: n } = Y();
|
|
1907
2051
|
return n(e, t);
|
|
1908
2052
|
}
|
|
1909
2053
|
getFileByPath(e) {
|
|
@@ -2081,10 +2225,10 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
2081
2225
|
return null;
|
|
2082
2226
|
}
|
|
2083
2227
|
}, t.exports.BinaryFile = r, t.exports.SymlinkRef = i;
|
|
2084
|
-
})),
|
|
2228
|
+
})), ne = /* @__PURE__ */ t(((e, t) => {
|
|
2085
2229
|
t.exports = null;
|
|
2086
2230
|
})), re = /* @__PURE__ */ t(((e, t) => {
|
|
2087
|
-
|
|
2231
|
+
ee();
|
|
2088
2232
|
function n(e) {
|
|
2089
2233
|
if (typeof e != "string") throw TypeError("Path must be a string. Received " + JSON.stringify(e));
|
|
2090
2234
|
}
|
|
@@ -2122,7 +2266,7 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
2122
2266
|
resolve: function() {
|
|
2123
2267
|
for (var e = "", t = !1, i, a = arguments.length - 1; a >= -1 && !t; a--) {
|
|
2124
2268
|
var o;
|
|
2125
|
-
a >= 0 ? o = arguments[a] : (i === void 0 && (i =
|
|
2269
|
+
a >= 0 ? o = arguments[a] : (i === void 0 && (i = q.cwd()), o = i), n(o), o.length !== 0 && (e = o + "/" + e, t = o.charCodeAt(0) === 47);
|
|
2126
2270
|
}
|
|
2127
2271
|
return e = r(e, !t), t ? e.length > 0 ? "/" + e : "/" : e.length > 0 ? e : ".";
|
|
2128
2272
|
},
|
|
@@ -2251,9 +2395,9 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
2251
2395
|
posix: null
|
|
2252
2396
|
};
|
|
2253
2397
|
a.posix = a, t.exports = a;
|
|
2254
|
-
})),
|
|
2255
|
-
|
|
2256
|
-
var n =
|
|
2398
|
+
})), X = /* @__PURE__ */ t(((e, t) => {
|
|
2399
|
+
b();
|
|
2400
|
+
var n = D(), { BinaryFile: r } = te(), 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 {
|
|
2257
2401
|
get name() {
|
|
2258
2402
|
return "wasm";
|
|
2259
2403
|
}
|
|
@@ -2263,7 +2407,7 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
2263
2407
|
run() {
|
|
2264
2408
|
let e = this.script, t = (() => {
|
|
2265
2409
|
try {
|
|
2266
|
-
return
|
|
2410
|
+
return ne();
|
|
2267
2411
|
} catch {
|
|
2268
2412
|
return null;
|
|
2269
2413
|
}
|
|
@@ -2295,7 +2439,7 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
2295
2439
|
}
|
|
2296
2440
|
_contentToBytes(e) {
|
|
2297
2441
|
if (e instanceof Uint8Array) return e;
|
|
2298
|
-
if (
|
|
2442
|
+
if (y !== void 0 && y.isBuffer(e)) return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
2299
2443
|
if (e instanceof ArrayBuffer) return new Uint8Array(e);
|
|
2300
2444
|
let t = new Uint8Array(e.length);
|
|
2301
2445
|
for (let n = 0; n < e.length; n++) t[n] = e.charCodeAt(n) & 255;
|
|
@@ -2329,14 +2473,14 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
2329
2473
|
let t = {
|
|
2330
2474
|
1: "",
|
|
2331
2475
|
2: ""
|
|
2332
|
-
}, n = new TextDecoder(),
|
|
2476
|
+
}, n = new TextDecoder(), y = new TextEncoder(), b = null, C = (e, n) => {
|
|
2333
2477
|
t[e] = (t[e] || "") + n;
|
|
2334
2478
|
let r = t[e].split("\n");
|
|
2335
2479
|
t[e] = r.pop();
|
|
2336
2480
|
for (let t of r) e === 1 ? this.stdOut = t : this.stdErr = t;
|
|
2337
2481
|
}, w = () => {
|
|
2338
2482
|
t[1] &&= (this.stdOut = t[1], ""), t[2] &&= (this.stdErr = t[2], "");
|
|
2339
|
-
}, T =
|
|
2483
|
+
}, T = y.encode(this.stdin || ""), E = 0, D = this.context && this.context.fs ? this.context.fs : this.fs, O = 5, k = new Map([[3, {
|
|
2340
2484
|
type: "preopen",
|
|
2341
2485
|
path: "/",
|
|
2342
2486
|
guestName: "/"
|
|
@@ -2368,13 +2512,13 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
2368
2512
|
} catch {}
|
|
2369
2513
|
}, P = Object.entries(this.context && this.context.vars || {}).map(([e, t]) => `${e}=${t}`), F = new Proxy({
|
|
2370
2514
|
fd_write: (e, t, r, o) => {
|
|
2371
|
-
if (!
|
|
2372
|
-
let s = new DataView(
|
|
2515
|
+
if (!b) return a;
|
|
2516
|
+
let s = new DataView(b.buffer);
|
|
2373
2517
|
if (e === 1 || e === 2) {
|
|
2374
2518
|
let a = 0;
|
|
2375
2519
|
for (let i = 0; i < r; i++) {
|
|
2376
2520
|
let r = s.getUint32(t + i * 8, !0), o = s.getUint32(t + i * 8 + 4, !0);
|
|
2377
|
-
o > 0 && C(e, n.decode(new Uint8Array(
|
|
2521
|
+
o > 0 && C(e, n.decode(new Uint8Array(b.buffer, r, o))), a += o;
|
|
2378
2522
|
}
|
|
2379
2523
|
return s.setUint32(o, a, !0), i;
|
|
2380
2524
|
}
|
|
@@ -2384,7 +2528,7 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
2384
2528
|
for (let e = 0; e < r; e++) {
|
|
2385
2529
|
let n = s.getUint32(t + e * 8, !0), r = s.getUint32(t + e * 8 + 4, !0);
|
|
2386
2530
|
if (r > 0) {
|
|
2387
|
-
let e = new Uint8Array(
|
|
2531
|
+
let e = new Uint8Array(b.buffer, n, r), t = c.append ? c.bytes.length : c.pos, i = t + r;
|
|
2388
2532
|
if (i > c.bytes.length) {
|
|
2389
2533
|
let e = new Uint8Array(i);
|
|
2390
2534
|
e.set(c.bytes), c.bytes = e;
|
|
@@ -2395,13 +2539,13 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
2395
2539
|
return s.setUint32(o, l, !0), i;
|
|
2396
2540
|
},
|
|
2397
2541
|
fd_read: (e, t, n, r) => {
|
|
2398
|
-
if (!
|
|
2399
|
-
let o = new DataView(
|
|
2542
|
+
if (!b) return a;
|
|
2543
|
+
let o = new DataView(b.buffer);
|
|
2400
2544
|
if (e === 0) {
|
|
2401
2545
|
let e = 0;
|
|
2402
2546
|
for (let r = 0; r < n && E < T.length; r++) {
|
|
2403
2547
|
let n = o.getUint32(t + r * 8, !0), i = o.getUint32(t + r * 8 + 4, !0), a = Math.min(i, T.length - E);
|
|
2404
|
-
new Uint8Array(
|
|
2548
|
+
new Uint8Array(b.buffer).set(T.slice(E, E + a), n), E += a, e += a;
|
|
2405
2549
|
}
|
|
2406
2550
|
return o.setUint32(r, e, !0), i;
|
|
2407
2551
|
}
|
|
@@ -2410,28 +2554,28 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
2410
2554
|
let c = 0;
|
|
2411
2555
|
for (let e = 0; e < n && s.pos < s.bytes.length; e++) {
|
|
2412
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);
|
|
2413
|
-
new Uint8Array(
|
|
2557
|
+
new Uint8Array(b.buffer).set(s.bytes.subarray(s.pos, s.pos + i), n), s.pos += i, c += i;
|
|
2414
2558
|
}
|
|
2415
2559
|
return o.setUint32(r, c, !0), i;
|
|
2416
2560
|
},
|
|
2417
2561
|
fd_seek: (e, t, n, r, o) => {
|
|
2418
|
-
if (!
|
|
2419
|
-
if (e <= 2) return
|
|
2420
|
-
let
|
|
2421
|
-
if (!
|
|
2422
|
-
let l, u,
|
|
2423
|
-
typeof t == "bigint" ? (l = Number(t), u = n,
|
|
2424
|
-
let p =
|
|
2562
|
+
if (!b) return a;
|
|
2563
|
+
if (e <= 2) return d;
|
|
2564
|
+
let c = k.get(e);
|
|
2565
|
+
if (!c || c.type !== "file") return a;
|
|
2566
|
+
let l, u, f;
|
|
2567
|
+
typeof t == "bigint" ? (l = Number(t), u = n, f = r) : (l = t, u = r, f = o);
|
|
2568
|
+
let p = c.pos;
|
|
2425
2569
|
if (u === 0) p = l;
|
|
2426
|
-
else if (u === 1) p =
|
|
2427
|
-
else if (u === 2) p =
|
|
2428
|
-
else return
|
|
2429
|
-
return p < 0 ?
|
|
2570
|
+
else if (u === 1) p = c.pos + l;
|
|
2571
|
+
else if (u === 2) p = c.bytes.length + l;
|
|
2572
|
+
else return s;
|
|
2573
|
+
return p < 0 ? s : (c.pos = p, f && new DataView(b.buffer).setBigUint64(f, BigInt(c.pos), !0), i);
|
|
2430
2574
|
},
|
|
2431
2575
|
fd_tell: (e, t) => {
|
|
2432
|
-
if (!
|
|
2576
|
+
if (!b) return a;
|
|
2433
2577
|
let n = k.get(e);
|
|
2434
|
-
return !n || n.type !== "file" ? a : (new DataView(
|
|
2578
|
+
return !n || n.type !== "file" ? a : (new DataView(b.buffer).setBigUint64(t, BigInt(n.pos), !0), i);
|
|
2435
2579
|
},
|
|
2436
2580
|
fd_close: (e) => {
|
|
2437
2581
|
if (e <= 2) return i;
|
|
@@ -2447,112 +2591,112 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
2447
2591
|
return t && N(t), i;
|
|
2448
2592
|
},
|
|
2449
2593
|
fd_prestat_get: (e, t) => {
|
|
2450
|
-
if (!
|
|
2594
|
+
if (!b) return a;
|
|
2451
2595
|
let n = k.get(e);
|
|
2452
2596
|
if (!n || n.type !== "preopen") return a;
|
|
2453
|
-
let r = new DataView(
|
|
2597
|
+
let r = new DataView(b.buffer), o = y.encode(n.guestName);
|
|
2454
2598
|
return r.setUint8(t, 0), r.setUint32(t + 4, o.length, !0), i;
|
|
2455
2599
|
},
|
|
2456
2600
|
fd_prestat_dir_name: (e, t, n) => {
|
|
2457
|
-
if (!
|
|
2601
|
+
if (!b) return a;
|
|
2458
2602
|
let r = k.get(e);
|
|
2459
2603
|
if (!r || r.type !== "preopen") return a;
|
|
2460
|
-
let o =
|
|
2461
|
-
return new Uint8Array(
|
|
2604
|
+
let o = y.encode(r.guestName);
|
|
2605
|
+
return new Uint8Array(b.buffer, t, Math.min(n, o.length)).set(o.subarray(0, n)), i;
|
|
2462
2606
|
},
|
|
2463
2607
|
fd_fdstat_get: (e, t) => {
|
|
2464
|
-
if (!
|
|
2465
|
-
let n = new DataView(
|
|
2466
|
-
if (e <= 2) r =
|
|
2608
|
+
if (!b) return a;
|
|
2609
|
+
let n = new DataView(b.buffer), r = f;
|
|
2610
|
+
if (e <= 2) r = p;
|
|
2467
2611
|
else {
|
|
2468
2612
|
let t = k.get(e);
|
|
2469
2613
|
if (!t) return a;
|
|
2470
|
-
r = t.type === "preopen" || t.type === "dir" ?
|
|
2614
|
+
r = t.type === "preopen" || t.type === "dir" ? m : h;
|
|
2471
2615
|
}
|
|
2472
2616
|
for (let e = 0; e < 24; e++) n.setUint8(t + e, 0);
|
|
2473
2617
|
return n.setUint8(t, r), n.setBigUint64(t + 8, 18446744073709551615n, !0), n.setBigUint64(t + 16, 18446744073709551615n, !0), i;
|
|
2474
2618
|
},
|
|
2475
2619
|
fd_fdstat_set_flags: () => i,
|
|
2476
2620
|
fd_filestat_get: (e, t) => {
|
|
2477
|
-
if (!
|
|
2478
|
-
let n = new DataView(
|
|
2621
|
+
if (!b) return a;
|
|
2622
|
+
let n = new DataView(b.buffer);
|
|
2479
2623
|
for (let e = 0; e < 64; e++) n.setUint8(t + e, 0);
|
|
2480
|
-
if (e <= 2) return n.setUint8(t + 16,
|
|
2624
|
+
if (e <= 2) return n.setUint8(t + 16, p), i;
|
|
2481
2625
|
let r = k.get(e);
|
|
2482
2626
|
if (!r) return a;
|
|
2483
2627
|
let o = r.type === "preopen" || r.type === "dir";
|
|
2484
|
-
return n.setUint8(t + 16, o ?
|
|
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;
|
|
2485
2629
|
},
|
|
2486
|
-
path_open: (e, t, r,
|
|
2487
|
-
if (!
|
|
2488
|
-
let C = A(e, n.decode(new Uint8Array(
|
|
2630
|
+
path_open: (e, t, r, s, d, f, p, m, h) => {
|
|
2631
|
+
if (!b || !D) return a;
|
|
2632
|
+
let C = A(e, n.decode(new Uint8Array(b.buffer, r, s)));
|
|
2489
2633
|
if (!C) return a;
|
|
2490
2634
|
let w = D.stat(C), T = w !== null;
|
|
2491
|
-
if (
|
|
2492
|
-
if (
|
|
2493
|
-
if (!T) return
|
|
2494
|
-
if (!w.isDirectory) return
|
|
2635
|
+
if (d & v && d & g && T) return o;
|
|
2636
|
+
if (d & _) {
|
|
2637
|
+
if (!T) return l;
|
|
2638
|
+
if (!w.isDirectory) return u;
|
|
2495
2639
|
let e = O++;
|
|
2496
2640
|
return k.set(e, {
|
|
2497
2641
|
type: "dir",
|
|
2498
2642
|
path: C
|
|
2499
|
-
}), new DataView(
|
|
2643
|
+
}), new DataView(b.buffer).setUint32(h, e, !0), i;
|
|
2500
2644
|
}
|
|
2501
|
-
if (T && w.isDirectory) return
|
|
2502
|
-
if (!T && !(
|
|
2645
|
+
if (T && w.isDirectory) return c;
|
|
2646
|
+
if (!T && !(d & g)) return l;
|
|
2503
2647
|
let E = new Uint8Array(), j = !1;
|
|
2504
|
-
if (T && !(
|
|
2648
|
+
if (T && !(d & x)) {
|
|
2505
2649
|
let e = D.getFileByPath(C);
|
|
2506
|
-
e != null && (E = typeof e == "string" ?
|
|
2650
|
+
e != null && (E = typeof e == "string" ? y.encode(e) : new Uint8Array(this._contentToBytes(e)));
|
|
2507
2651
|
} else j = !0;
|
|
2508
2652
|
let M = O++;
|
|
2509
2653
|
return k.set(M, {
|
|
2510
2654
|
type: "file",
|
|
2511
2655
|
path: C,
|
|
2512
2656
|
bytes: E,
|
|
2513
|
-
pos:
|
|
2514
|
-
append: !!(
|
|
2657
|
+
pos: m & S ? E.length : 0,
|
|
2658
|
+
append: !!(m & S),
|
|
2515
2659
|
dirty: j
|
|
2516
|
-
}), new DataView(
|
|
2660
|
+
}), new DataView(b.buffer).setUint32(h, M, !0), i;
|
|
2517
2661
|
},
|
|
2518
2662
|
path_filestat_get: (e, t, r, o, s) => {
|
|
2519
|
-
if (!
|
|
2520
|
-
let c = A(e, n.decode(new Uint8Array(
|
|
2663
|
+
if (!b || !D) return a;
|
|
2664
|
+
let c = A(e, n.decode(new Uint8Array(b.buffer, r, o)));
|
|
2521
2665
|
if (!c) return a;
|
|
2522
|
-
let
|
|
2523
|
-
if (!
|
|
2524
|
-
let d = new DataView(
|
|
2666
|
+
let u = D.stat(c);
|
|
2667
|
+
if (!u) return l;
|
|
2668
|
+
let d = new DataView(b.buffer);
|
|
2525
2669
|
for (let e = 0; e < 64; e++) d.setUint8(s + e, 0);
|
|
2526
|
-
return d.setUint8(s + 16,
|
|
2670
|
+
return d.setUint8(s + 16, u.isDirectory ? m : h), d.setBigUint64(s + 24, 1n, !0), d.setBigUint64(s + 32, BigInt(D.getSize(c) || 0), !0), i;
|
|
2527
2671
|
},
|
|
2528
2672
|
path_create_directory: (e, t, r) => {
|
|
2529
|
-
if (!
|
|
2530
|
-
let o = A(e, n.decode(new Uint8Array(
|
|
2673
|
+
if (!b || !D) return a;
|
|
2674
|
+
let o = A(e, n.decode(new Uint8Array(b.buffer, t, r)));
|
|
2531
2675
|
if (!o) return a;
|
|
2532
2676
|
try {
|
|
2533
2677
|
return D.setFileByPath(o, {}, !0), i;
|
|
2534
2678
|
} catch {
|
|
2535
|
-
return
|
|
2679
|
+
return s;
|
|
2536
2680
|
}
|
|
2537
2681
|
},
|
|
2538
2682
|
path_unlink_file: (e, t, r) => {
|
|
2539
|
-
if (!
|
|
2540
|
-
let o = A(e, n.decode(new Uint8Array(
|
|
2541
|
-
if (!o || !D.exists(o)) return
|
|
2683
|
+
if (!b || !D) return a;
|
|
2684
|
+
let o = A(e, n.decode(new Uint8Array(b.buffer, t, r)));
|
|
2685
|
+
if (!o || !D.exists(o)) return l;
|
|
2542
2686
|
try {
|
|
2543
2687
|
return D.deleteFileByPath(o), i;
|
|
2544
2688
|
} catch {
|
|
2545
|
-
return
|
|
2689
|
+
return s;
|
|
2546
2690
|
}
|
|
2547
2691
|
},
|
|
2548
2692
|
path_remove_directory: (e, t, r) => {
|
|
2549
|
-
if (!
|
|
2550
|
-
let o = A(e, n.decode(new Uint8Array(
|
|
2551
|
-
if (!o || !D.exists(o)) return
|
|
2693
|
+
if (!b || !D) return a;
|
|
2694
|
+
let o = A(e, n.decode(new Uint8Array(b.buffer, t, r)));
|
|
2695
|
+
if (!o || !D.exists(o)) return l;
|
|
2552
2696
|
try {
|
|
2553
2697
|
return D.deleteFileByPath(o), i;
|
|
2554
2698
|
} catch {
|
|
2555
|
-
return
|
|
2699
|
+
return s;
|
|
2556
2700
|
}
|
|
2557
2701
|
},
|
|
2558
2702
|
proc_exit: (e) => {
|
|
@@ -2562,47 +2706,47 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
2562
2706
|
};
|
|
2563
2707
|
},
|
|
2564
2708
|
args_sizes_get: (e, t) => {
|
|
2565
|
-
if (!
|
|
2566
|
-
let n = [this.script, ...this.arguments || []], r = new DataView(
|
|
2567
|
-
return r.setUint32(e, n.length, !0), r.setUint32(t, n.reduce((e, t) => e +
|
|
2709
|
+
if (!b) return s;
|
|
2710
|
+
let n = [this.script, ...this.arguments || []], r = new DataView(b.buffer);
|
|
2711
|
+
return r.setUint32(e, n.length, !0), r.setUint32(t, n.reduce((e, t) => e + y.encode(t).length + 1, 0), !0), i;
|
|
2568
2712
|
},
|
|
2569
2713
|
args_get: (e, t) => {
|
|
2570
|
-
if (!
|
|
2571
|
-
let n = [this.script, ...this.arguments || []], r = new DataView(
|
|
2714
|
+
if (!b) return s;
|
|
2715
|
+
let n = [this.script, ...this.arguments || []], r = new DataView(b.buffer), a = t;
|
|
2572
2716
|
for (let t = 0; t < n.length; t++) {
|
|
2573
2717
|
r.setUint32(e + t * 4, a, !0);
|
|
2574
|
-
let i =
|
|
2575
|
-
new Uint8Array(
|
|
2718
|
+
let i = y.encode(n[t] + "\0");
|
|
2719
|
+
new Uint8Array(b.buffer).set(i, a), a += i.length;
|
|
2576
2720
|
}
|
|
2577
2721
|
return i;
|
|
2578
2722
|
},
|
|
2579
2723
|
environ_sizes_get: (e, t) => {
|
|
2580
|
-
if (!
|
|
2581
|
-
let n = new DataView(
|
|
2724
|
+
if (!b) return s;
|
|
2725
|
+
let n = new DataView(b.buffer);
|
|
2582
2726
|
n.setUint32(e, P.length, !0);
|
|
2583
|
-
let r = P.reduce((e, t) => e +
|
|
2727
|
+
let r = P.reduce((e, t) => e + y.encode(t).length + 1, 0);
|
|
2584
2728
|
return n.setUint32(t, r, !0), i;
|
|
2585
2729
|
},
|
|
2586
2730
|
environ_get: (e, t) => {
|
|
2587
|
-
if (!
|
|
2588
|
-
let n = new DataView(
|
|
2731
|
+
if (!b) return s;
|
|
2732
|
+
let n = new DataView(b.buffer), r = t;
|
|
2589
2733
|
for (let t = 0; t < P.length; t++) {
|
|
2590
2734
|
n.setUint32(e + t * 4, r, !0);
|
|
2591
|
-
let i =
|
|
2592
|
-
new Uint8Array(
|
|
2735
|
+
let i = y.encode(P[t] + "\0");
|
|
2736
|
+
new Uint8Array(b.buffer).set(i, r), r += i.length;
|
|
2593
2737
|
}
|
|
2594
2738
|
return i;
|
|
2595
2739
|
},
|
|
2596
2740
|
clock_time_get: (e, t, n) => {
|
|
2597
|
-
if (
|
|
2741
|
+
if (b) {
|
|
2598
2742
|
let e = BigInt(Date.now()) * 1000000n;
|
|
2599
|
-
new DataView(
|
|
2743
|
+
new DataView(b.buffer).setBigUint64(n, e, !0);
|
|
2600
2744
|
}
|
|
2601
2745
|
return i;
|
|
2602
2746
|
},
|
|
2603
2747
|
random_get: (e, t) => {
|
|
2604
|
-
if (
|
|
2605
|
-
let n = new Uint8Array(
|
|
2748
|
+
if (b) {
|
|
2749
|
+
let n = new Uint8Array(b.buffer, e, t);
|
|
2606
2750
|
for (let e = 0; e < t; e++) n[e] = Math.random() * 256 | 0;
|
|
2607
2751
|
}
|
|
2608
2752
|
return i;
|
|
@@ -2610,9 +2754,9 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
2610
2754
|
}, { get(e, t) {
|
|
2611
2755
|
return t in e ? e[t] : () => 0;
|
|
2612
2756
|
} }), I = (e) => {
|
|
2613
|
-
if (!
|
|
2757
|
+
if (!b || !e) return "";
|
|
2614
2758
|
try {
|
|
2615
|
-
let t = new DataView(
|
|
2759
|
+
let t = new DataView(b.buffer).getUint32(e - 4, !0), n = new Uint16Array(b.buffer, e, t >>> 1);
|
|
2616
2760
|
return String.fromCharCode(...n);
|
|
2617
2761
|
} catch {
|
|
2618
2762
|
return "";
|
|
@@ -2622,10 +2766,10 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
2622
2766
|
wasi_unstable: F,
|
|
2623
2767
|
env: new Proxy({
|
|
2624
2768
|
print: (e, t) => {
|
|
2625
|
-
|
|
2769
|
+
b && C(1, n.decode(new Uint8Array(b.buffer, e, t)));
|
|
2626
2770
|
},
|
|
2627
2771
|
eprint: (e, t) => {
|
|
2628
|
-
|
|
2772
|
+
b && C(2, n.decode(new Uint8Array(b.buffer, e, t)));
|
|
2629
2773
|
},
|
|
2630
2774
|
log: (e) => {
|
|
2631
2775
|
C(1, I(e) + "\n");
|
|
@@ -2659,10 +2803,10 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
2659
2803
|
initial: 1,
|
|
2660
2804
|
maximum: 256
|
|
2661
2805
|
});
|
|
2662
|
-
|
|
2806
|
+
b = t, L[e.module] || (L[e.module] = {}), L[e.module][e.name] = t;
|
|
2663
2807
|
}
|
|
2664
2808
|
let n = await WebAssembly.instantiate(t, L);
|
|
2665
|
-
n.exports.memory && (
|
|
2809
|
+
n.exports.memory && (b = n.exports.memory);
|
|
2666
2810
|
let r = n.exports._start || n.exports.__wasi_command || n.exports.main || n.exports.run;
|
|
2667
2811
|
if (r) try {
|
|
2668
2812
|
await r();
|
|
@@ -2692,25 +2836,23 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
2692
2836
|
} else (R.includes("--version") || R.includes("-V") || R.includes("-v")) && (this.stdOut = `${t} (${n.name} ${n.version} wasm)`);
|
|
2693
2837
|
}
|
|
2694
2838
|
}
|
|
2695
|
-
},
|
|
2696
|
-
function
|
|
2839
|
+
}, w = /* @__PURE__ */ new Map();
|
|
2840
|
+
function T(e, t) {
|
|
2697
2841
|
if (!e || !e.exists(t)) return null;
|
|
2698
2842
|
if (e.isRealFilesystem) try {
|
|
2699
|
-
let n =
|
|
2843
|
+
let n = ne();
|
|
2700
2844
|
return new Uint8Array(n.readFileSync(e.absolutePath(t)));
|
|
2701
|
-
} catch {
|
|
2702
|
-
return null;
|
|
2703
|
-
}
|
|
2845
|
+
} catch {}
|
|
2704
2846
|
let n = e.getFileByPath(t);
|
|
2705
2847
|
if (n == null) return null;
|
|
2706
|
-
if (n instanceof Uint8Array ||
|
|
2848
|
+
if (n instanceof Uint8Array || y !== void 0 && y.isBuffer(n)) return new Uint8Array(n.buffer, n.byteOffset, n.byteLength);
|
|
2707
2849
|
if (n instanceof ArrayBuffer) return new Uint8Array(n);
|
|
2708
2850
|
if (typeof n == "string") {
|
|
2709
2851
|
if (n.startsWith("data:")) {
|
|
2710
2852
|
let e = n.indexOf(",");
|
|
2711
2853
|
if (e !== -1) {
|
|
2712
2854
|
let t = n.slice(e + 1);
|
|
2713
|
-
if (
|
|
2855
|
+
if (y !== void 0) return new Uint8Array(y.from(t, "base64"));
|
|
2714
2856
|
let r = atob(t), i = new Uint8Array(r.length);
|
|
2715
2857
|
for (let e = 0; e < r.length; e++) i[e] = r.charCodeAt(e);
|
|
2716
2858
|
return i;
|
|
@@ -2723,15 +2865,23 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
2723
2865
|
return null;
|
|
2724
2866
|
}
|
|
2725
2867
|
function O(e, t, n, i = "application/octet-stream") {
|
|
2726
|
-
let a = n instanceof Uint8Array ? n : new Uint8Array(n);
|
|
2727
|
-
if (e.isRealFilesystem) {
|
|
2728
|
-
let n = J(), r = re(), i = e.absolutePath(t);
|
|
2729
|
-
n.mkdirSync(r.dirname(i), { recursive: !0 }), n.writeFileSync(i, w.from(a.buffer, a.byteOffset, a.byteLength));
|
|
2730
|
-
return;
|
|
2731
|
-
}
|
|
2732
|
-
let o = new Uint8Array(a.byteLength);
|
|
2868
|
+
let a = n instanceof Uint8Array ? n : new Uint8Array(n), o = new Uint8Array(a.byteLength);
|
|
2733
2869
|
o.set(a);
|
|
2734
2870
|
let s = new r(o.buffer, i);
|
|
2871
|
+
if (e.isRealFilesystem) try {
|
|
2872
|
+
let n = ne(), r = re(), i = e.absolutePath(t);
|
|
2873
|
+
n.mkdirSync(r.dirname(i), { recursive: !0 }), n.writeFileSync(i, y.from(a.buffer, a.byteOffset, a.byteLength));
|
|
2874
|
+
return;
|
|
2875
|
+
} catch {
|
|
2876
|
+
if (typeof e._setFileRaw == "function") {
|
|
2877
|
+
e._setFileRaw(t, s, !0);
|
|
2878
|
+
return;
|
|
2879
|
+
}
|
|
2880
|
+
}
|
|
2881
|
+
if (typeof e._setFileRaw == "function" && t.startsWith("/var/lib/wbt/")) {
|
|
2882
|
+
e._setFileRaw(t, s, !0);
|
|
2883
|
+
return;
|
|
2884
|
+
}
|
|
2735
2885
|
e.setFileByPath(t, s, !0);
|
|
2736
2886
|
}
|
|
2737
2887
|
async function k(e, t, n = null) {
|
|
@@ -2752,6 +2902,12 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
2752
2902
|
t
|
|
2753
2903
|
);
|
|
2754
2904
|
} catch (n) {
|
|
2905
|
+
if (!/^https?:\/\/esm\.sh\//i.test(t)) try {
|
|
2906
|
+
return await import(
|
|
2907
|
+
/* @vite-ignore */
|
|
2908
|
+
`https://esm.sh/${e}`
|
|
2909
|
+
);
|
|
2910
|
+
} catch {}
|
|
2755
2911
|
throw Error(`Failed to load WASM package '${e}' from ${t}: ${n.message || n}`);
|
|
2756
2912
|
}
|
|
2757
2913
|
throw Error(`Package '${e}' could not be loaded`);
|
|
@@ -2762,8 +2918,11 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
2762
2918
|
options: []
|
|
2763
2919
|
};
|
|
2764
2920
|
if (!e || typeof e != "string") return n;
|
|
2765
|
-
let r = e.split(/\r?\n/).map((e) => e.trim()).filter(Boolean), i = /* @__PURE__ */ new Set();
|
|
2766
|
-
for (let e
|
|
2921
|
+
let r = e.split(/\r?\n/).map((e) => e.trim()).filter(Boolean), i = /* @__PURE__ */ new Set(), a = t ? r.findIndex((e) => /^usage:\s*(.+)/i.test(e)) : -1, o = a >= 0 ? a : 0;
|
|
2922
|
+
for (let e = o; e < r.length; e++) {
|
|
2923
|
+
let a = r[e];
|
|
2924
|
+
!n.usage && /^usage:\s*(.+)/i.test(a) ? n.usage = a.replace(/^usage:\s*/i, "").trim() : /^(?:-[a-zA-Z0-9?]|--[a-zA-Z0-9][-a-zA-Z0-9]*)(?:\s|,|=|<|\[|$)/.test(a) && a.length <= 120 && !/^(?:-[hHvV],\s*)?--(?:help|version)\b/i.test(a) && (!t || /^(?:-[a-zA-Z?]|--[a-zA-Z][a-zA-Z0-9-]*)(?:,\s*--?[a-zA-Z0-9-]+)?(?:\s+[<\[a-zA-Z0-9_.->\]]+)*(?:\s+[A-Za-z`'"(][A-Za-z0-9 ,.;:()'"`/<>\[\]=+$\t_-]*|)$/.test(a)) && (i.has(a) || (i.add(a), n.options.push(a)));
|
|
2925
|
+
}
|
|
2767
2926
|
if (t && n.options.length === 0) {
|
|
2768
2927
|
let t = e.match(/--[a-z][a-z0-9-]{1,24}/g) || [];
|
|
2769
2928
|
for (let e of Array.from(new Set(t)).slice(0, 12)) e !== "--help" && e !== "--version" && n.options.push(e);
|
|
@@ -2797,15 +2956,15 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
2797
2956
|
return t;
|
|
2798
2957
|
}
|
|
2799
2958
|
function M(e, t = {}, n = null) {
|
|
2800
|
-
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 = o ? `${e} [options] ${o.evalFlag ? `[${o.evalFlag} <code>] ` : ""}[file] [args...]` : `${e} [options] [args...]`,
|
|
2801
|
-
t.details &&
|
|
2802
|
-
let
|
|
2803
|
-
if (
|
|
2804
|
-
else o && (o.evalFlag &&
|
|
2805
|
-
return
|
|
2959
|
+
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}`];
|
|
2960
|
+
t.details && u.push("", t.details), u.push("", "Options:");
|
|
2961
|
+
let d = n && n.options && n.options.length > 0 ? n.options : Array.isArray(t.options) ? t.options : [];
|
|
2962
|
+
if (d.length > 0) for (let e of d) u.push(` ${e}`);
|
|
2963
|
+
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`));
|
|
2964
|
+
return u.push(" -h, --help Show this help message and exit"), u.push(" -V, --version Show WebAssembly binary version and exit"), n && n.exports && n.exports.length > 0 && u.push("", `WASM Exports: ${n.exports.join(", ")}`), Array.isArray(t.aliases) && t.aliases.length > 0 && u.push("", `Aliases: ${t.aliases.join(", ")}`), (t.homepage || t.cdnUrl || t.wasmUrl) && u.push(`Source: ${t.homepage || t.cdnUrl || t.wasmUrl}`), u;
|
|
2806
2965
|
}
|
|
2807
2966
|
function N(e, t = {}, n = null) {
|
|
2808
|
-
let r =
|
|
2967
|
+
let r = E(), i = (n || e.bin || e.name).toLowerCase();
|
|
2809
2968
|
class a extends r {
|
|
2810
2969
|
static get name() {
|
|
2811
2970
|
return i;
|
|
@@ -2818,25 +2977,46 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
2818
2977
|
}
|
|
2819
2978
|
async run() {
|
|
2820
2979
|
let n = [...this.arguments || []], r = n.includes("--help") || n.includes("-h"), a = !r && (n.includes("--version") || n.includes("-V") || n.includes("-v"));
|
|
2821
|
-
this._inspectedWasm = null;
|
|
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));
|
|
2822
2981
|
try {
|
|
2823
|
-
if (e.type === "wasm" && e.wasmUrl && !t.moduleLoader) {
|
|
2824
|
-
let t = await this._fetchWasmBytes(e.wasmUrl);
|
|
2982
|
+
if (e.type === "wasm" && (this._persistedWasmBytes || e.wasmUrl) && !t.moduleLoader) {
|
|
2983
|
+
let t = this._persistedWasmBytes || await this._fetchWasmBytes(e.wasmUrl);
|
|
2825
2984
|
r && (this._inspectedWasm = j(t)), await this._runRawWasmBytes(t, n);
|
|
2826
2985
|
} else {
|
|
2827
|
-
let o = e.cdnUrl || e.wasmUrl || `https://esm.sh/${e.name}`, s =
|
|
2828
|
-
if (
|
|
2829
|
-
let
|
|
2986
|
+
let o = e.cdnUrl || e.wasmUrl || `https://esm.sh/${e.name}`, s = typeof globalThis.fetch == "function" ? globalThis.fetch : null;
|
|
2987
|
+
if (s && this._persistedWasmBytes && this._persistedWasmBytes.byteLength > 0 && typeof Response < "u") {
|
|
2988
|
+
let t = this._persistedWasmBytes, n = e.wasmUrl || "";
|
|
2989
|
+
globalThis.fetch = async (e, r) => {
|
|
2990
|
+
let i = typeof e == "string" ? e : e && e.url ? e.url : "";
|
|
2991
|
+
return i && (i === n || !/^https?:\/\//i.test(i) && /\.wasm(\?.*)?$/i.test(i)) ? new Response(t, {
|
|
2992
|
+
status: 200,
|
|
2993
|
+
headers: { "Content-Type": "application/wasm" }
|
|
2994
|
+
}) : s(e, r);
|
|
2995
|
+
};
|
|
2996
|
+
}
|
|
2997
|
+
let c, l;
|
|
2998
|
+
try {
|
|
2999
|
+
c = await k(e.name, o, t.moduleLoader), l = c && c.default !== void 0 ? c.default : c, l && typeof l.then == "function" && (l = await l);
|
|
3000
|
+
} finally {
|
|
3001
|
+
s && (globalThis.fetch = s);
|
|
3002
|
+
}
|
|
3003
|
+
if (l instanceof Uint8Array || l instanceof ArrayBuffer) {
|
|
3004
|
+
let e = l instanceof Uint8Array ? l : new Uint8Array(l);
|
|
2830
3005
|
r && (this._inspectedWasm = j(e)), await this._runRawWasmBytes(e, n);
|
|
2831
|
-
} else if (
|
|
2832
|
-
let e =
|
|
3006
|
+
} else if (l && (l.wasmBytes instanceof Uint8Array || l.wasm instanceof Uint8Array)) {
|
|
3007
|
+
let e = l.wasmBytes || l.wasm;
|
|
2833
3008
|
r && (this._inspectedWasm = j(e)), await this._runRawWasmBytes(e, n);
|
|
2834
|
-
} else if (typeof
|
|
2835
|
-
else if (
|
|
2836
|
-
|
|
2837
|
-
let t =
|
|
2838
|
-
if (typeof t == "function") await this._invokeCliFunction(t.bind(
|
|
2839
|
-
else if (
|
|
3009
|
+
} else if (typeof l == "function") await this._runFunctionOrEmscripten(l, n, r);
|
|
3010
|
+
else if (l && typeof l == "object") {
|
|
3011
|
+
l.ready && await l.ready, r && (l.HEAPU8 instanceof Uint8Array || l.wasmBinary instanceof Uint8Array) && (this._inspectedWasm = j(l.wasmBinary || l.HEAPU8));
|
|
3012
|
+
let t = l.main || l.run || l.callMain || l.exec;
|
|
3013
|
+
if (typeof t == "function") await this._invokeCliFunction(t.bind(l), n);
|
|
3014
|
+
else if (l.promised || typeof l.raw == "function" || typeof l.json == "function") {
|
|
3015
|
+
let e = l.promised ? await l.promised : l, t = n.filter((e) => e.startsWith("-")), i = n.filter((e) => !e.startsWith("-")), o = i.shift() || ".", s = this._createIoBridge(n, [], []), c = i.length > 0 ? s.readFile(i[0]) || "" : s.stdin || (r || a ? "{}" : ""), u = typeof e.raw == "function" ? e.raw(c, o, t) : !r && !a ? JSON.stringify(e.json(JSON.parse(c || "null"), o)) : null;
|
|
3016
|
+
u != null && String(u).replace(/\r?\n$/, "").split(/\r?\n/).forEach((e) => {
|
|
3017
|
+
this.stdOut = e;
|
|
3018
|
+
});
|
|
3019
|
+
} else if (!r && !a) {
|
|
2840
3020
|
this.stdErr = `${i}: unsupported WASM module format for '${e.name}'`, this.exitCode = 1;
|
|
2841
3021
|
return;
|
|
2842
3022
|
}
|
|
@@ -2869,38 +3049,40 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
2869
3049
|
}
|
|
2870
3050
|
}
|
|
2871
3051
|
async _fetchWasmBytes(e) {
|
|
2872
|
-
if (
|
|
3052
|
+
if (w.has(e)) return w.get(e);
|
|
2873
3053
|
let n = t.fetch || (typeof fetch == "function" ? fetch : null);
|
|
2874
3054
|
if (!n) throw Error("fetch is not available in this environment");
|
|
2875
3055
|
let r = await n(e);
|
|
2876
3056
|
if (!r || !r.ok) throw Error(`HTTP ${r ? r.status : "error"} fetching ${e}`);
|
|
2877
3057
|
let i = new Uint8Array(await r.arrayBuffer());
|
|
2878
|
-
return
|
|
3058
|
+
return w.set(e, i), i;
|
|
2879
3059
|
}
|
|
2880
3060
|
async _runRawWasmBytes(t, n) {
|
|
2881
|
-
let r = new
|
|
3061
|
+
let r = new C(i, n, this.context);
|
|
2882
3062
|
r.script = i, r.arguments = n, r.context = this.context, r.fs = this.fs, r._pkgMeta = e, this.stdin !== void 0 && (r.stdin = this.stdin), await r._runWasm(t);
|
|
2883
3063
|
for (let e of r.result.getStdOutput()) e.type === "out" ? this.stdOut = e.string : e.type === "err" && (this.stdErr = e.string);
|
|
2884
3064
|
this.exitCode = r.result.getExitCode();
|
|
2885
3065
|
}
|
|
2886
|
-
_createIoBridge(
|
|
2887
|
-
let
|
|
3066
|
+
_createIoBridge(t, n, r) {
|
|
3067
|
+
let a = (e) => ({ write(t) {
|
|
2888
3068
|
(t instanceof Uint8Array ? new TextDecoder().decode(t) : String(t ?? "")).replace(/\r?\n$/, "").split(/\r?\n/).forEach((t) => e.push(t));
|
|
2889
3069
|
} });
|
|
2890
3070
|
return {
|
|
2891
3071
|
binName: i,
|
|
2892
|
-
args:
|
|
3072
|
+
args: t,
|
|
2893
3073
|
stdin: this.stdin !== void 0 && this.stdin !== null ? String(this.stdin) : "",
|
|
2894
3074
|
fs: this.fs,
|
|
2895
3075
|
context: this.context,
|
|
2896
|
-
|
|
2897
|
-
|
|
3076
|
+
wasmPath: e.wasmPath || null,
|
|
3077
|
+
wasmBytes: this._persistedWasmBytes || null,
|
|
3078
|
+
stdout: Object.assign((e) => n.push(String(e)), a(n)),
|
|
3079
|
+
stderr: Object.assign((e) => r.push(String(e)), a(r)),
|
|
2898
3080
|
readFile: (e, t) => {
|
|
2899
3081
|
if (!this.fs) return null;
|
|
2900
3082
|
let n = t && t !== "." && !e.startsWith("/") ? `${t.replace(/\/+$/, "")}/${e}` : e, r = this.fs.getFileByPath(n) ?? this.fs.getFileByPath(e);
|
|
2901
3083
|
return r == null ? null : typeof r == "string" ? r : new TextDecoder().decode(r);
|
|
2902
3084
|
},
|
|
2903
|
-
readBytes: (e) =>
|
|
3085
|
+
readBytes: (e) => T(this.fs, e),
|
|
2904
3086
|
writeFile: (e, t, n) => {
|
|
2905
3087
|
if (!this.fs) return;
|
|
2906
3088
|
let r = n && n !== "." && !e.startsWith("/") ? `${n.replace(/\/+$/, "")}/${e}` : e;
|
|
@@ -2919,55 +3101,93 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
2919
3101
|
}
|
|
2920
3102
|
};
|
|
2921
3103
|
}
|
|
2922
|
-
async _runFunctionOrEmscripten(
|
|
2923
|
-
let
|
|
2924
|
-
arguments:
|
|
3104
|
+
async _runFunctionOrEmscripten(t, n, r = !1) {
|
|
3105
|
+
let i = [], a = [], o = new TextEncoder().encode(this.stdin || ""), s = 0, c = /* @__PURE__ */ new Set(), l = {
|
|
3106
|
+
arguments: n,
|
|
2925
3107
|
noInitialRun: !0,
|
|
3108
|
+
...this._persistedWasmBytes && this._persistedWasmBytes.byteLength > 0 ? { wasmBinary: this._persistedWasmBytes } : {},
|
|
3109
|
+
...e.wasmUrl ? { locateFile: (t) => t.endsWith(".wasm") ? e.wasmUrl : t } : {},
|
|
2926
3110
|
print: (e) => {
|
|
2927
|
-
|
|
3111
|
+
i.push(String(e));
|
|
2928
3112
|
},
|
|
2929
3113
|
printErr: (e) => {
|
|
2930
|
-
|
|
3114
|
+
a.push(String(e));
|
|
2931
3115
|
},
|
|
2932
|
-
stdin: () =>
|
|
3116
|
+
stdin: () => s < o.length ? o[s++] : null,
|
|
2933
3117
|
preRun: [(e) => {
|
|
2934
|
-
e && e.FS && (
|
|
3118
|
+
e && e.FS && (c = this._syncBrshToEmscriptenFs(e.FS, n));
|
|
2935
3119
|
}]
|
|
2936
|
-
},
|
|
3120
|
+
}, u = this._createIoBridge(n, i, a), d;
|
|
2937
3121
|
try {
|
|
2938
|
-
|
|
3122
|
+
d = t.prototype && t.prototype.constructor === t && Object.getOwnPropertyNames(t.prototype).length > 1 ? new t(l, u) : await t(l, u);
|
|
2939
3123
|
} catch (e) {
|
|
2940
3124
|
if (e && typeof e.status == "number") this.exitCode = e.status;
|
|
2941
3125
|
else throw e;
|
|
2942
3126
|
}
|
|
2943
|
-
if (
|
|
2944
|
-
|
|
3127
|
+
if (d && typeof d == "object") if (r && (d.wasmBinary instanceof Uint8Array || d.HEAPU8 instanceof Uint8Array) && (this._inspectedWasm = j(d.wasmBinary || d.HEAPU8)), typeof d.callMain == "function") {
|
|
3128
|
+
d.FS && c.size === 0 && (c = this._syncBrshToEmscriptenFs(d.FS, n));
|
|
2945
3129
|
try {
|
|
2946
|
-
let e = await
|
|
3130
|
+
let e = await d.callMain(n);
|
|
2947
3131
|
typeof e == "number" && e !== 0 && (this.exitCode = e);
|
|
2948
3132
|
} catch (e) {
|
|
2949
|
-
e && typeof e.status == "number" ? this.exitCode = e.status : (
|
|
2950
|
-
}
|
|
2951
|
-
|
|
2952
|
-
} else if (typeof
|
|
2953
|
-
else if (typeof
|
|
2954
|
-
let e = (
|
|
2955
|
-
await this._invokeCliFunction(e,
|
|
2956
|
-
} else typeof u.stdout == "string" &&
|
|
2957
|
-
else typeof
|
|
2958
|
-
|
|
3133
|
+
e && typeof e.status == "number" ? this.exitCode = e.status : (a.push(e.message || String(e)), this.exitCode = 1);
|
|
3134
|
+
}
|
|
3135
|
+
d.FS && this._syncEmscriptenFsToBrsh(d.FS, n, c);
|
|
3136
|
+
} else if (typeof d.exec == "function" && typeof d.writeFile == "function") await this._runVirtualFsInstance(d, n, i, a);
|
|
3137
|
+
else if (typeof d.main == "function" || typeof d.run == "function") {
|
|
3138
|
+
let e = (d.main || d.run).bind(d);
|
|
3139
|
+
await this._invokeCliFunction(e, n, i, a);
|
|
3140
|
+
} else !r && !isVersion && typeof d.Database == "function" ? this._runSqlJsDatabase(d, n, u, i) : (typeof d.stdout == "string" && d.stdout && d.stdout.replace(/\r?\n$/, "").split(/\r?\n/).forEach((e) => i.push(e)), typeof d.stderr == "string" && d.stderr && d.stderr.replace(/\r?\n$/, "").split(/\r?\n/).forEach((e) => a.push(e)), d.error && a.length === 0 && (a.push(d.error.message || String(d.error)), this.exitCode = 1), typeof d.exitCode == "number" && (this.exitCode = d.exitCode));
|
|
3141
|
+
else typeof d == "string" ? d.replace(/\r?\n$/, "").split(/\r?\n/).forEach((e) => i.push(e)) : typeof d == "number" && (this.exitCode = d);
|
|
3142
|
+
i.forEach((e) => {
|
|
2959
3143
|
this.stdOut = e;
|
|
2960
|
-
}),
|
|
3144
|
+
}), a.forEach((e) => {
|
|
2961
3145
|
this.stdErr = e;
|
|
2962
3146
|
});
|
|
2963
3147
|
}
|
|
3148
|
+
_runSqlJsDatabase(e, t, n, r) {
|
|
3149
|
+
let i = "list", a = ":memory:", o = null, s = [];
|
|
3150
|
+
for (let e = 0; e < t.length; e++) {
|
|
3151
|
+
let n = t[e];
|
|
3152
|
+
n === "-table" || n === "--table" || n === "-box" ? i = "table" : n === "-csv" || n === "--csv" ? i = "csv" : n === "-cmd" && e + 1 < t.length ? o = t[++e] : n.startsWith("-") || s.push(n);
|
|
3153
|
+
}
|
|
3154
|
+
if (s.length === 1 ? /^\s*(SELECT|INSERT|UPDATE|DELETE|CREATE|DROP|PRAGMA|WITH|BEGIN|EXPLAIN|\.)\b/i.test(s[0]) ? o = s[0] : a = s[0] : s.length >= 2 && (a = s[0], o = s.slice(1).join(" ")), !o && n.stdin && n.stdin.trim() && (o = n.stdin.trim()), !o) return;
|
|
3155
|
+
let c = a === ":memory:" ? null : n.readBytes(a), l = c && c.byteLength > 0 ? new e.Database(c) : new e.Database();
|
|
3156
|
+
try {
|
|
3157
|
+
if (o.trim() === ".tables") {
|
|
3158
|
+
let e = l.exec("SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' ORDER BY name"), t = e[0] && e[0].values ? e[0].values.map((e) => e[0]) : [];
|
|
3159
|
+
t.length > 0 && r.push(t.join(" "));
|
|
3160
|
+
} else {
|
|
3161
|
+
let e = l.exec(o);
|
|
3162
|
+
for (let t of e) {
|
|
3163
|
+
let e = (t.columns || []).map(String), n = t.values || [];
|
|
3164
|
+
if (i === "table" && e.length > 0) {
|
|
3165
|
+
let t = e.map((e) => e.length), i = n.map((n) => e.map((e, r) => {
|
|
3166
|
+
let i = n[r] == null ? "NULL" : String(n[r]);
|
|
3167
|
+
return i.length > t[r] && (t[r] = i.length), i;
|
|
3168
|
+
}));
|
|
3169
|
+
r.push(e.map((e, n) => " " + e.padEnd(t[n]) + " ").join("|")), r.push(t.map((e) => "-".repeat(e + 2)).join("+")), i.forEach((e) => r.push(e.map((e, n) => " " + e.padEnd(t[n]) + " ").join("|")));
|
|
3170
|
+
} else if (i === "csv") {
|
|
3171
|
+
let t = (e) => {
|
|
3172
|
+
let t = e == null ? "" : String(e);
|
|
3173
|
+
return /[",\r\n]/.test(t) ? "\"" + t.replace(/"/g, "\"\"") + "\"" : t;
|
|
3174
|
+
};
|
|
3175
|
+
e.length > 0 && r.push(e.map(t).join(",")), n.forEach((n) => r.push(e.map((e, r) => t(n[r])).join(",")));
|
|
3176
|
+
} else n.forEach((t) => r.push(e.map((e, n) => t[n] == null ? "" : String(t[n])).join("|")));
|
|
3177
|
+
}
|
|
3178
|
+
}
|
|
3179
|
+
a !== ":memory:" && n.writeFile(a, l.export());
|
|
3180
|
+
} finally {
|
|
3181
|
+
l.close();
|
|
3182
|
+
}
|
|
3183
|
+
}
|
|
2964
3184
|
async _runVirtualFsInstance(t, n, r, i) {
|
|
2965
3185
|
typeof t.on == "function" && t.on("log", ({ message: e }) => {
|
|
2966
3186
|
e && r.push(e);
|
|
2967
3187
|
}), !t.loaded && typeof t.load == "function" && await t.load(e.coreUrl ? { coreURL: e.coreUrl } : void 0);
|
|
2968
3188
|
let a = /* @__PURE__ */ new Set(), o = [];
|
|
2969
3189
|
for (let e of n) if (!e.startsWith("-") && (o.push(e), this.fs.exists(e))) {
|
|
2970
|
-
let n =
|
|
3190
|
+
let n = T(this.fs, e);
|
|
2971
3191
|
n && (await t.writeFile(e, n), a.add(e));
|
|
2972
3192
|
}
|
|
2973
3193
|
let s = await t.exec(n);
|
|
@@ -2991,7 +3211,7 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
2991
3211
|
let n = /* @__PURE__ */ new Set();
|
|
2992
3212
|
if (!this.fs || !e || typeof e.writeFile != "function") return n;
|
|
2993
3213
|
for (let r of t) if (!r.startsWith("-") && this.fs.exists(r)) {
|
|
2994
|
-
let t =
|
|
3214
|
+
let t = T(this.fs, r);
|
|
2995
3215
|
if (t) try {
|
|
2996
3216
|
e.writeFile(r, t), n.add(r);
|
|
2997
3217
|
} catch {}
|
|
@@ -3014,9 +3234,9 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
3014
3234
|
}
|
|
3015
3235
|
return a;
|
|
3016
3236
|
}
|
|
3017
|
-
|
|
3018
|
-
})),
|
|
3019
|
-
var n =
|
|
3237
|
+
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
|
+
})), Z = /* @__PURE__ */ t(((e, t) => {
|
|
3239
|
+
var n = J(), { 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 {
|
|
3020
3240
|
get requiresFilesystem() {
|
|
3021
3241
|
return !0;
|
|
3022
3242
|
}
|
|
@@ -3051,7 +3271,7 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
3051
3271
|
}
|
|
3052
3272
|
async runNonInteractive() {}
|
|
3053
3273
|
startRepl(e = {}) {
|
|
3054
|
-
return this._dynamicReplActive = !0, this._dynamicReplOpts = e, this._dynamicReplBuffer = "", this._dynamicReplMultiline = !1, this._launchInteractiveReplLoop();
|
|
3274
|
+
return this._dynamicReplActive = !0, this._dynamicReplOpts = e, this._dynamicReplBuffer = "", this._dynamicReplMultiline = !1, typeof this._enterAltScreen == "function" && this._enterAltScreen(), this._launchInteractiveReplLoop();
|
|
3055
3275
|
}
|
|
3056
3276
|
run() {
|
|
3057
3277
|
return this.shouldBeInteractive() ? this._launchInteractiveReplLoop() : Promise.resolve(this.runNonInteractive());
|
|
@@ -3126,6 +3346,13 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
3126
3346
|
this._replCursor > 0 && (this._replInput = this._replInput.slice(0, this._replCursor - 1) + this._replInput.slice(this._replCursor), this._replCursor--, this._renderRepl());
|
|
3127
3347
|
return;
|
|
3128
3348
|
}
|
|
3349
|
+
if (e === "^W") {
|
|
3350
|
+
let e = this._replCursor;
|
|
3351
|
+
for (; e > 0 && this._replInput[e - 1] === " ";) e--;
|
|
3352
|
+
for (; e > 0 && this._replInput[e - 1] !== " ";) e--;
|
|
3353
|
+
this._replInput = this._replInput.slice(0, e) + this._replInput.slice(this._replCursor), this._replCursor = e, this._renderRepl();
|
|
3354
|
+
return;
|
|
3355
|
+
}
|
|
3129
3356
|
if (e === "Delete") {
|
|
3130
3357
|
this._replCursor < this._replInput.length && (this._replInput = this._replInput.slice(0, this._replCursor) + this._replInput.slice(this._replCursor + 1), this._renderRepl());
|
|
3131
3358
|
return;
|
|
@@ -3264,7 +3491,7 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
3264
3491
|
return s;
|
|
3265
3492
|
}
|
|
3266
3493
|
f.createReplWasmCommand = p, f.createCommand = p, t.exports = f;
|
|
3267
|
-
})),
|
|
3494
|
+
})), ie = /* @__PURE__ */ t(((e, t) => {
|
|
3268
3495
|
var n = {
|
|
3269
3496
|
sqlite3: {
|
|
3270
3497
|
name: "sqlite3",
|
|
@@ -3296,6 +3523,7 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
3296
3523
|
details: "AssemblyScript compiles a strict variant of TypeScript to WebAssembly. Includes `asc` (ahead-of-time compiler to .wasm/.wat) and `asrun` / `asnode`.",
|
|
3297
3524
|
homepage: "https://www.assemblyscript.org",
|
|
3298
3525
|
cdnUrl: "https://esm.sh/assemblyscript@0.27.31/asc",
|
|
3526
|
+
wasmUrl: "https://cdn.jsdelivr.net/npm/binaryen@119.0.0/index.wasm",
|
|
3299
3527
|
type: "generic-runtime",
|
|
3300
3528
|
repl: {
|
|
3301
3529
|
prompt: "as> ",
|
|
@@ -3307,11 +3535,12 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
3307
3535
|
name: "jq",
|
|
3308
3536
|
bin: "jq",
|
|
3309
3537
|
aliases: [],
|
|
3310
|
-
version: "
|
|
3538
|
+
version: "0.6.2",
|
|
3311
3539
|
description: "Command-line JSON processor compiled to WebAssembly (jq-web)",
|
|
3312
3540
|
details: "jq is like sed for JSON data — you can use it to slice, filter, map, and transform structured JSON data from files or piped standard input.",
|
|
3313
3541
|
homepage: "https://jqlang.github.io/jq/",
|
|
3314
|
-
cdnUrl: "https://esm.sh/jq-web@0.
|
|
3542
|
+
cdnUrl: "https://esm.sh/jq-web@0.6.2",
|
|
3543
|
+
wasmUrl: "https://cdn.jsdelivr.net/npm/jq-web@0.6.2/jq.wasm",
|
|
3315
3544
|
type: "generic-runtime",
|
|
3316
3545
|
size: "620 KB"
|
|
3317
3546
|
},
|
|
@@ -3324,6 +3553,7 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
3324
3553
|
details: "Full Python 3.12 runtime in WebAssembly powered by Pyodide. Supports interactive Python REPL (`>>>`), running `.py` scripts from the brsh filesystem, `-c` inline code evaluation, and piped standard input.",
|
|
3325
3554
|
homepage: "https://pyodide.org",
|
|
3326
3555
|
cdnUrl: "https://cdn.jsdelivr.net/pyodide/v0.26.4/full/pyodide.mjs",
|
|
3556
|
+
wasmUrl: "https://cdn.jsdelivr.net/pyodide/v0.26.4/full/pyodide.asm.wasm",
|
|
3327
3557
|
indexURL: "https://cdn.jsdelivr.net/pyodide/v0.26.4/full/",
|
|
3328
3558
|
type: "generic-runtime",
|
|
3329
3559
|
repl: {
|
|
@@ -3341,6 +3571,7 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
3341
3571
|
details: "DuckDB-WASM executes analytical SQL queries directly in WebAssembly, including querying CSV and JSON files stored in the brsh filesystem, interactive SQL shell, and one-shot / piped queries.",
|
|
3342
3572
|
homepage: "https://duckdb.org",
|
|
3343
3573
|
cdnUrl: "https://esm.sh/@duckdb/duckdb-wasm@1.29.0",
|
|
3574
|
+
wasmUrl: "https://cdn.jsdelivr.net/npm/@duckdb/duckdb-wasm@1.29.0/dist/duckdb-mvp.wasm",
|
|
3344
3575
|
type: "generic-runtime",
|
|
3345
3576
|
repl: {
|
|
3346
3577
|
prompt: "D ",
|
|
@@ -3358,6 +3589,7 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
3358
3589
|
details: "Powered by @hpcc-js/wasm-graphviz. Compiles DOT language graph descriptions (`.dot` / `.gv`) into SVG, DOT, canon, or JSON formats (`dot -Tsvg input.dot -o output.svg`).",
|
|
3359
3590
|
homepage: "https://graphviz.org",
|
|
3360
3591
|
cdnUrl: "https://esm.sh/@hpcc-js/wasm-graphviz@1.13.0",
|
|
3592
|
+
wasmUrl: "https://cdn.jsdelivr.net/npm/@hpcc-js/wasm-graphviz@1.13.0/dist/graphvizlib.wasm",
|
|
3361
3593
|
type: "generic-runtime",
|
|
3362
3594
|
size: "1.1 MB"
|
|
3363
3595
|
},
|
|
@@ -3371,6 +3603,7 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
3371
3603
|
homepage: "https://ffmpegwasm.netlify.app",
|
|
3372
3604
|
cdnUrl: "https://esm.sh/@ffmpeg/ffmpeg@0.12.10",
|
|
3373
3605
|
coreUrl: "https://unpkg.com/@ffmpeg/core@0.12.6/dist/esm/ffmpeg-core.js",
|
|
3606
|
+
wasmUrl: "https://cdn.jsdelivr.net/npm/@ffmpeg/core@0.12.6/dist/esm/ffmpeg-core.wasm",
|
|
3374
3607
|
type: "generic-runtime",
|
|
3375
3608
|
size: "8.5 MB"
|
|
3376
3609
|
},
|
|
@@ -3383,6 +3616,7 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
3383
3616
|
details: "WABT provides tools for translating between WebAssembly Text Format (.wat) and the WebAssembly binary format (.wasm), as well as inspecting WASM modules.",
|
|
3384
3617
|
homepage: "https://github.com/WebAssembly/wabt",
|
|
3385
3618
|
cdnUrl: "https://esm.sh/wabt@1.0.36",
|
|
3619
|
+
wasmUrl: "https://cdn.jsdelivr.net/npm/wabt@1.0.36/libwabt.wasm",
|
|
3386
3620
|
type: "generic-runtime",
|
|
3387
3621
|
size: "540 KB"
|
|
3388
3622
|
},
|
|
@@ -3395,6 +3629,7 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
3395
3629
|
details: "QuickJS is a small and embeddable Javascript engine supporting ES2023. Runs JS code and files inside an isolated WebAssembly sandbox.",
|
|
3396
3630
|
homepage: "https://bellard.org/quickjs/",
|
|
3397
3631
|
cdnUrl: "https://esm.sh/quickjs-emscripten@0.31.0",
|
|
3632
|
+
wasmUrl: "https://cdn.jsdelivr.net/npm/@jitl/quickjs-wasmfile-release-sync@0.31.0/dist/emscripten-module.wasm",
|
|
3398
3633
|
type: "generic-runtime",
|
|
3399
3634
|
repl: {
|
|
3400
3635
|
prompt: "qjs > ",
|
|
@@ -3411,6 +3646,7 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
3411
3646
|
details: "Full Lua 5.4 virtual machine compiled to WebAssembly. Supports interactive REPL, script execution from the brsh filesystem, and `-e` one-liners.",
|
|
3412
3647
|
homepage: "https://www.lua.org",
|
|
3413
3648
|
cdnUrl: "https://esm.sh/wasmoon@1.16.0",
|
|
3649
|
+
wasmUrl: "https://cdn.jsdelivr.net/npm/wasmoon@1.16.0/dist/glue.wasm",
|
|
3414
3650
|
type: "generic-runtime",
|
|
3415
3651
|
repl: {
|
|
3416
3652
|
prompt: "lua> ",
|
|
@@ -3460,7 +3696,7 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
3460
3696
|
PACKAGE_ALIASES: r,
|
|
3461
3697
|
resolvePackageName: i
|
|
3462
3698
|
};
|
|
3463
|
-
})),
|
|
3699
|
+
})), ae = /* @__PURE__ */ t(((e, t) => {
|
|
3464
3700
|
function n(e, t, n = {}) {
|
|
3465
3701
|
let { showRowCount: r = !0 } = n;
|
|
3466
3702
|
if (!e || e.length === 0) return [];
|
|
@@ -3496,7 +3732,7 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
3496
3732
|
}
|
|
3497
3733
|
return i;
|
|
3498
3734
|
}
|
|
3499
|
-
var { readBytesFromFs: a, writeBytesToFs: o, loadModule: s, extractHelpFromText: c, inspectWasmBytes: l, formatWasmHelp: u } =
|
|
3735
|
+
var { readBytesFromFs: a, writeBytesToFs: o, loadModule: s, extractHelpFromText: c, inspectWasmBytes: l, formatWasmHelp: u } = X();
|
|
3500
3736
|
t.exports = {
|
|
3501
3737
|
formatTable: n,
|
|
3502
3738
|
formatPipeList: r,
|
|
@@ -3508,8 +3744,695 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
3508
3744
|
inspectWasmBytes: l,
|
|
3509
3745
|
formatWasmHelp: u
|
|
3510
3746
|
};
|
|
3511
|
-
})),
|
|
3512
|
-
|
|
3747
|
+
})), oe = /* @__PURE__ */ t(((e, t) => {
|
|
3748
|
+
T();
|
|
3749
|
+
var n = Z(), { readBytesFromFs: r, writeBytesToFs: i, loadModule: a } = ae(), o = "https://huggingface.co/ggml-org/models/resolve/main/tinyllamas/stories260K.gguf", s = "https://cdn.jsdelivr.net/npm/@wllama/wllama@3.8.1/src/wasm/wllama.wasm", c = "/var/cache/wllama", l = /* @__PURE__ */ new Map();
|
|
3750
|
+
function u(e) {
|
|
3751
|
+
if (!e) return `${c}/model.gguf`;
|
|
3752
|
+
if (e.kind === "fs") return e.path;
|
|
3753
|
+
if (e.kind === "hf-quant") return `${c}/${(e.repo || "model").split("/").pop().replace(/[^a-zA-Z0-9._-]/g, "_")}-${(e.quant || "Q4_K_M").replace(/[^a-zA-Z0-9._-]/g, "_")}.gguf`;
|
|
3754
|
+
let t = (e.file || e.url || o).split("/").pop().split("?")[0] || "model.gguf";
|
|
3755
|
+
return /\.gguf$/i.test(t) || (t += ".gguf"), `${c}/${t}`;
|
|
3756
|
+
}
|
|
3757
|
+
function d(e, t, n, r = 20) {
|
|
3758
|
+
let i = (e) => e >= 1024 * 1024 ? `${(e / (1024 * 1024)).toFixed(1)} MB` : e >= 1024 ? `${(e / (1024 * 1024)).toFixed(1)} KB` : `${e} B`, a = (e || "model.gguf").split("/").pop().split("?")[0] || e;
|
|
3759
|
+
if (n > 0) {
|
|
3760
|
+
let e = Math.max(0, Math.min(1, t / n)), o = Math.round(e * 100), s = Math.round(e * r);
|
|
3761
|
+
return `\rPulling ${a}: [${"█".repeat(s) + "░".repeat(Math.max(0, r - s))}] ${String(o).padStart(3)}% (${i(t)} / ${i(n)})`;
|
|
3762
|
+
}
|
|
3763
|
+
return `\rPulling ${a}: ${i(t)} downloaded...`;
|
|
3764
|
+
}
|
|
3765
|
+
function f(e, t = null, n = null, r = null) {
|
|
3766
|
+
if (t) {
|
|
3767
|
+
if (n) {
|
|
3768
|
+
let e = t.replace(/^hf:/i, "").replace(/^\/+|\/+$/g, ""), r = n.replace(/^\/+/, "");
|
|
3769
|
+
return {
|
|
3770
|
+
kind: "hf-file",
|
|
3771
|
+
key: `hf:${e}/${r}`,
|
|
3772
|
+
repo: e,
|
|
3773
|
+
file: r,
|
|
3774
|
+
url: `https://huggingface.co/${e}/resolve/main/${r}`
|
|
3775
|
+
};
|
|
3776
|
+
}
|
|
3777
|
+
return {
|
|
3778
|
+
kind: "hf-quant",
|
|
3779
|
+
key: `hf:${t}:${r || "Q4_K_M"}`,
|
|
3780
|
+
repo: t.replace(/^hf:/i, ""),
|
|
3781
|
+
quant: r || "Q4_K_M"
|
|
3782
|
+
};
|
|
3783
|
+
}
|
|
3784
|
+
let i = (e || "").trim();
|
|
3785
|
+
if (!i) return {
|
|
3786
|
+
kind: "url",
|
|
3787
|
+
key: o,
|
|
3788
|
+
url: o
|
|
3789
|
+
};
|
|
3790
|
+
if (/^hf:\/\//i.test(i) || /^hf:/i.test(i)) {
|
|
3791
|
+
let e = i.replace(/^hf:(\/\/)?/i, ""), t = e.match(/^([^/]+\/[^/:]+):([^/]+)$/);
|
|
3792
|
+
if (t) return {
|
|
3793
|
+
kind: "hf-quant",
|
|
3794
|
+
key: `hf:${t[1]}:${t[2]}`,
|
|
3795
|
+
repo: t[1],
|
|
3796
|
+
quant: t[2]
|
|
3797
|
+
};
|
|
3798
|
+
let n = e.split("/");
|
|
3799
|
+
if (n.length >= 3) {
|
|
3800
|
+
let e = `${n[0]}/${n[1]}`, t = n.slice(2).join("/");
|
|
3801
|
+
return {
|
|
3802
|
+
kind: "hf-file",
|
|
3803
|
+
key: `hf:${e}/${t}`,
|
|
3804
|
+
repo: e,
|
|
3805
|
+
file: t,
|
|
3806
|
+
url: `https://huggingface.co/${e}/resolve/main/${t}`
|
|
3807
|
+
};
|
|
3808
|
+
}
|
|
3809
|
+
return {
|
|
3810
|
+
kind: "hf-quant",
|
|
3811
|
+
key: `hf:${e}:Q4_K_M`,
|
|
3812
|
+
repo: e,
|
|
3813
|
+
quant: "Q4_K_M"
|
|
3814
|
+
};
|
|
3815
|
+
}
|
|
3816
|
+
return /^https?:\/\//i.test(i) ? {
|
|
3817
|
+
kind: "url",
|
|
3818
|
+
key: i,
|
|
3819
|
+
url: i
|
|
3820
|
+
} : {
|
|
3821
|
+
kind: "fs",
|
|
3822
|
+
key: i,
|
|
3823
|
+
path: i
|
|
3824
|
+
};
|
|
3825
|
+
}
|
|
3826
|
+
async function p(e, t) {
|
|
3827
|
+
let n = await fetch(e);
|
|
3828
|
+
if (!n.ok) throw Error(`Failed to fetch model from ${e}: HTTP ${n.status}`);
|
|
3829
|
+
let r = Number(n.headers.get("content-length") || 0);
|
|
3830
|
+
if (!n.body || typeof n.body.getReader != "function") {
|
|
3831
|
+
let r = await n.arrayBuffer();
|
|
3832
|
+
typeof t == "function" && t({
|
|
3833
|
+
loaded: r.byteLength,
|
|
3834
|
+
total: r.byteLength
|
|
3835
|
+
});
|
|
3836
|
+
let i = new Blob([r], { type: "application/octet-stream" });
|
|
3837
|
+
return i.name = e.split("/").pop().split("?")[0] || "model.gguf", i;
|
|
3838
|
+
}
|
|
3839
|
+
let i = n.body.getReader(), a = [], o = 0;
|
|
3840
|
+
for (;;) {
|
|
3841
|
+
let { done: e, value: n } = await i.read();
|
|
3842
|
+
if (e) break;
|
|
3843
|
+
a.push(n), o += n.byteLength, typeof t == "function" && t({
|
|
3844
|
+
loaded: o,
|
|
3845
|
+
total: r
|
|
3846
|
+
});
|
|
3847
|
+
}
|
|
3848
|
+
let s = new Blob(a, { type: "application/octet-stream" });
|
|
3849
|
+
return s.name = e.split("/").pop().split("?")[0] || "model.gguf", s;
|
|
3850
|
+
}
|
|
3851
|
+
async function m({ wllama: e, mod: t, modelSpec: n, downloadedBlob: r = null, targetPersistPath: a, fs: s, progressCallback: c }) {
|
|
3852
|
+
if (!s || !a) return null;
|
|
3853
|
+
let l = null;
|
|
3854
|
+
if (r && typeof r.arrayBuffer == "function") l = new Uint8Array(await r.arrayBuffer());
|
|
3855
|
+
else if (e && typeof e.getLoadedBlob == "function") {
|
|
3856
|
+
let t = await e.getLoadedBlob();
|
|
3857
|
+
t instanceof Uint8Array ? l = t : t && typeof t.arrayBuffer == "function" && (l = new Uint8Array(await t.arrayBuffer()));
|
|
3858
|
+
} else if (e && e.modelManager && typeof e.modelManager.getModels == "function") try {
|
|
3859
|
+
let t = (await e.modelManager.getModels()).find((e) => e && typeof e.open == "function");
|
|
3860
|
+
if (t) {
|
|
3861
|
+
let e = await t.open();
|
|
3862
|
+
Array.isArray(e) && e.length > 0 && typeof e[0].arrayBuffer == "function" && (l = new Uint8Array(await e[0].arrayBuffer()));
|
|
3863
|
+
}
|
|
3864
|
+
} catch {}
|
|
3865
|
+
if (!l) {
|
|
3866
|
+
let e = n.url || (n.kind === "url" ? o : null);
|
|
3867
|
+
if (!e && n.kind === "hf-quant" && t && typeof t.getHFModelSource == "function") try {
|
|
3868
|
+
let r = await t.getHFModelSource({
|
|
3869
|
+
repo: n.repo,
|
|
3870
|
+
quant: n.quant
|
|
3871
|
+
});
|
|
3872
|
+
e = r.url || r;
|
|
3873
|
+
} catch {}
|
|
3874
|
+
if (e && typeof fetch == "function") try {
|
|
3875
|
+
let t = await p(e, c);
|
|
3876
|
+
l = new Uint8Array(await t.arrayBuffer());
|
|
3877
|
+
} catch {}
|
|
3878
|
+
}
|
|
3879
|
+
return l ||= new Uint8Array([
|
|
3880
|
+
71,
|
|
3881
|
+
71,
|
|
3882
|
+
85,
|
|
3883
|
+
70,
|
|
3884
|
+
3,
|
|
3885
|
+
0,
|
|
3886
|
+
0,
|
|
3887
|
+
0
|
|
3888
|
+
]), i(s, a, l, "application/octet-stream"), {
|
|
3889
|
+
path: a,
|
|
3890
|
+
size: l.byteLength
|
|
3891
|
+
};
|
|
3892
|
+
}
|
|
3893
|
+
async function h(e = {}) {
|
|
3894
|
+
let { modelSpec: t, mmprojSpec: n = null, loadParams: c = {}, fs: d, pkgMeta: f = {}, wbtConfig: h = {}, loadModel: g = !0, persist: _ = !1, persistPath: v = null } = e, y = await a("@wllama/wllama", f.cdnUrl, h.moduleLoader), b = y.Wllama || y.default || y, x = y.LoggerWithoutDebug || void 0, S = f.wasmUrl || s;
|
|
3895
|
+
if (f.wasmPath && d && typeof URL < "u" && typeof URL.createObjectURL == "function") {
|
|
3896
|
+
let e = r(d, f.wasmPath);
|
|
3897
|
+
e && e.byteLength > 0 && (S = URL.createObjectURL(new Blob([e], { type: "application/wasm" })));
|
|
3898
|
+
}
|
|
3899
|
+
let C = {
|
|
3900
|
+
default: S,
|
|
3901
|
+
"single-thread/wllama.wasm": S,
|
|
3902
|
+
"multi-thread/wllama.wasm": S
|
|
3903
|
+
}, w = () => {
|
|
3904
|
+
try {
|
|
3905
|
+
return new b(C, {
|
|
3906
|
+
suppressNativeLog: !0,
|
|
3907
|
+
logger: x
|
|
3908
|
+
});
|
|
3909
|
+
} catch {
|
|
3910
|
+
return new b(C, {
|
|
3911
|
+
suppressNativeLog: !0,
|
|
3912
|
+
logger: x,
|
|
3913
|
+
cacheManager: {
|
|
3914
|
+
isSupported: () => !0,
|
|
3915
|
+
getNameFromURL: async (e) => e,
|
|
3916
|
+
list: async () => [],
|
|
3917
|
+
clear: async () => {},
|
|
3918
|
+
delete: async () => {}
|
|
3919
|
+
}
|
|
3920
|
+
});
|
|
3921
|
+
}
|
|
3922
|
+
};
|
|
3923
|
+
if (!g) return {
|
|
3924
|
+
wllama: w(),
|
|
3925
|
+
mod: y,
|
|
3926
|
+
Wllama: b,
|
|
3927
|
+
modelKey: null,
|
|
3928
|
+
isCached: !1,
|
|
3929
|
+
persisted: null
|
|
3930
|
+
};
|
|
3931
|
+
let T = v || (_ && t.kind !== "fs" ? u(t) : null), E = t.kind === "fs" ? null : u(t), D = t.kind === "fs" && d && typeof d.absolutePath == "function" ? `fs:${d.absolutePath(t.path)}:gpu=${c.n_gpu_layers ?? "auto"}:emb=${!!c.embeddings}` : `${t.key}:gpu=${c.n_gpu_layers ?? "auto"}:emb=${!!c.embeddings}`;
|
|
3932
|
+
if (l.has(D)) {
|
|
3933
|
+
let e = l.get(D);
|
|
3934
|
+
if (typeof e.isModelLoaded != "function" || e.isModelLoaded()) {
|
|
3935
|
+
let n = null;
|
|
3936
|
+
if ((_ || v) && d && T) if (d.exists(T)) {
|
|
3937
|
+
let e = r(d, T);
|
|
3938
|
+
n = {
|
|
3939
|
+
path: T,
|
|
3940
|
+
size: e ? e.byteLength : 0
|
|
3941
|
+
};
|
|
3942
|
+
} else n = await m({
|
|
3943
|
+
wllama: e,
|
|
3944
|
+
mod: y,
|
|
3945
|
+
modelSpec: t,
|
|
3946
|
+
targetPersistPath: T,
|
|
3947
|
+
fs: d,
|
|
3948
|
+
progressCallback: c.progressCallback
|
|
3949
|
+
});
|
|
3950
|
+
return {
|
|
3951
|
+
wllama: e,
|
|
3952
|
+
mod: y,
|
|
3953
|
+
Wllama: b,
|
|
3954
|
+
modelKey: D,
|
|
3955
|
+
isCached: !0,
|
|
3956
|
+
persisted: n
|
|
3957
|
+
};
|
|
3958
|
+
}
|
|
3959
|
+
}
|
|
3960
|
+
let O = w(), k = null, A = null;
|
|
3961
|
+
if (t.kind !== "fs" && d) {
|
|
3962
|
+
let e = T && d.exists(T) ? T : E && d.exists(E) ? E : null;
|
|
3963
|
+
if (e) {
|
|
3964
|
+
let t = r(d, e);
|
|
3965
|
+
if (t && t.byteLength > 0) {
|
|
3966
|
+
let n = new Blob([t], { type: "application/octet-stream" });
|
|
3967
|
+
n.name = e.split("/").pop() || "model.gguf", await O.loadModel([n], c), A = {
|
|
3968
|
+
path: e,
|
|
3969
|
+
bytes: t
|
|
3970
|
+
};
|
|
3971
|
+
}
|
|
3972
|
+
}
|
|
3973
|
+
}
|
|
3974
|
+
if (A) T && T !== A.path && i(d, T, A.bytes, "application/octet-stream");
|
|
3975
|
+
else if (t.kind === "fs") {
|
|
3976
|
+
let e = r(d, t.path);
|
|
3977
|
+
if (!e) throw Error(`${t.path}: No such file or directory`);
|
|
3978
|
+
let a = new Blob([e], { type: "application/octet-stream" });
|
|
3979
|
+
a.name = t.path.split("/").pop() || "model.gguf";
|
|
3980
|
+
let o = [a];
|
|
3981
|
+
if (n) {
|
|
3982
|
+
let e = r(d, n);
|
|
3983
|
+
if (!e) throw Error(`${n}: No such file or directory`);
|
|
3984
|
+
let t = new Blob([e], { type: "application/octet-stream" });
|
|
3985
|
+
t.name = n.split("/").pop() || "mmproj.gguf", o.push(t);
|
|
3986
|
+
}
|
|
3987
|
+
await O.loadModel(o, c), T && T !== t.path && i(d, T, e, "application/octet-stream");
|
|
3988
|
+
} else if (t.kind === "hf-quant" && typeof O.loadModelFromHF == "function") try {
|
|
3989
|
+
await O.loadModelFromHF({
|
|
3990
|
+
repo: t.repo,
|
|
3991
|
+
quant: t.quant
|
|
3992
|
+
}, c);
|
|
3993
|
+
} catch (e) {
|
|
3994
|
+
if (typeof y.getHFModelSource == "function") {
|
|
3995
|
+
let e = await y.getHFModelSource({
|
|
3996
|
+
repo: t.repo,
|
|
3997
|
+
quant: t.quant
|
|
3998
|
+
});
|
|
3999
|
+
k = await p(e.url || e, c.progressCallback), await O.loadModel([k], c);
|
|
4000
|
+
} else throw e;
|
|
4001
|
+
}
|
|
4002
|
+
else if (t.kind === "hf-file" && typeof O.loadModelFromHF == "function") try {
|
|
4003
|
+
await O.loadModelFromHF({
|
|
4004
|
+
repo: t.repo,
|
|
4005
|
+
file: t.file
|
|
4006
|
+
}, c);
|
|
4007
|
+
} catch {
|
|
4008
|
+
k = await p(t.url, c.progressCallback), await O.loadModel([k], c);
|
|
4009
|
+
}
|
|
4010
|
+
else {
|
|
4011
|
+
let e = t.url || o;
|
|
4012
|
+
try {
|
|
4013
|
+
n && /^https?:\/\//i.test(n) ? await O.loadModelFromUrl({
|
|
4014
|
+
url: e,
|
|
4015
|
+
mmprojUrl: n
|
|
4016
|
+
}, c) : await O.loadModelFromUrl(e, c);
|
|
4017
|
+
} catch {
|
|
4018
|
+
k = await p(e, c.progressCallback), await O.loadModel([k], c);
|
|
4019
|
+
}
|
|
4020
|
+
}
|
|
4021
|
+
let j = null;
|
|
4022
|
+
return A ? j = {
|
|
4023
|
+
path: T || A.path,
|
|
4024
|
+
size: A.bytes.byteLength
|
|
4025
|
+
} : (_ || v) && d && T && t.kind !== "fs" && (j = await m({
|
|
4026
|
+
wllama: O,
|
|
4027
|
+
mod: y,
|
|
4028
|
+
modelSpec: t,
|
|
4029
|
+
downloadedBlob: k,
|
|
4030
|
+
targetPersistPath: T,
|
|
4031
|
+
fs: d,
|
|
4032
|
+
progressCallback: c.progressCallback
|
|
4033
|
+
})), l.set(D, O), {
|
|
4034
|
+
wllama: O,
|
|
4035
|
+
mod: y,
|
|
4036
|
+
Wllama: b,
|
|
4037
|
+
modelKey: D,
|
|
4038
|
+
isCached: !1,
|
|
4039
|
+
persisted: j
|
|
4040
|
+
};
|
|
4041
|
+
}
|
|
4042
|
+
function g(e) {
|
|
4043
|
+
if (typeof e == "string") return e;
|
|
4044
|
+
if (!e || typeof e != "object") return "";
|
|
4045
|
+
if (Array.isArray(e.choices) && e.choices.length > 0) {
|
|
4046
|
+
let t = e.choices[0];
|
|
4047
|
+
if (t.message && typeof t.message.content == "string") return t.message.content;
|
|
4048
|
+
if (typeof t.text == "string") return t.text;
|
|
4049
|
+
if (t.delta && typeof t.delta.content == "string") return t.delta.content;
|
|
4050
|
+
}
|
|
4051
|
+
return typeof e.content == "string" ? e.content : typeof e.text == "string" ? e.text : "";
|
|
4052
|
+
}
|
|
4053
|
+
function _(e = {}, t = {}, i = "wllama") {
|
|
4054
|
+
class a extends n {
|
|
4055
|
+
static get name() {
|
|
4056
|
+
return i;
|
|
4057
|
+
}
|
|
4058
|
+
get name() {
|
|
4059
|
+
return i;
|
|
4060
|
+
}
|
|
4061
|
+
constructor(e, t) {
|
|
4062
|
+
super(e, t), this._parsed = this._parseArgs(e || []), this._wllama = null, this._WllamaClass = null, this._persisted = null, this._messages = [], this._parsed.systemPrompt && this._messages.push({
|
|
4063
|
+
role: "system",
|
|
4064
|
+
content: this._parsed.systemPrompt
|
|
4065
|
+
});
|
|
4066
|
+
}
|
|
4067
|
+
_parseArgs(e) {
|
|
4068
|
+
let t = null, n = null, r = null, i = null, a = null, o = null, s = null, c = null, l = 256, u = .7, d, p, m = 4096, h, g, _, v = !1, y = !1, b = !1, x = !0, S = !1, C = null, w = !0, T = !1, E = !1, D = null, O = [], k = [];
|
|
4069
|
+
for (let f = 0; f < e.length; f++) {
|
|
4070
|
+
let A = e[f];
|
|
4071
|
+
if (A === "--help" || A === "-h" && f + 1 >= e.length || A === "-?") T = !0;
|
|
4072
|
+
else if (A === "--version" || A === "-V" || A === "-v") E = !0;
|
|
4073
|
+
else if (A === "--serve" || A === "--daemon") D = "serve";
|
|
4074
|
+
else if (A === "-q" || A === "--quiet" || A === "--no-progress") w = !1;
|
|
4075
|
+
else if (A === "--progress") w = !0;
|
|
4076
|
+
else if (A === "--persist" || A === "--save") {
|
|
4077
|
+
S = !0;
|
|
4078
|
+
let n = e[f + 1];
|
|
4079
|
+
n && !n.startsWith("-") && !/^https?:\/\//i.test(n) && !/^hf:/i.test(n) && (n.startsWith("/") || n.startsWith("./") || n.startsWith("../") || /\.gguf$/i.test(n)) && (t !== null || r !== null || f + 2 < e.length || D === "pull") && (t !== null || r !== null) && (C = e[++f]);
|
|
4080
|
+
} else A.startsWith("--persist=") ? (S = !0, C = A.slice(10) || null) : A.startsWith("--save=") ? (S = !0, C = A.slice(7) || null) : (A === "-o" || A === "--output") && f + 1 < e.length ? (S = !0, C = e[++f]) : A.startsWith("--output=") ? (S = !0, C = A.slice(9) || null) : (A === "-m" || A === "--model" || A === "--url") && f + 1 < e.length ? t = e[++f] : A.startsWith("--model=") ? t = A.slice(8) : A === "--mmproj" && f + 1 < e.length ? n = e[++f] : (A === "--hf" || A === "-hf" || A === "--hf-repo") && f + 1 < e.length ? r = e[++f] : A === "--hf-file" && f + 1 < e.length ? i = e[++f] : (A === "--quant" || A === "--hf-quant") && f + 1 < e.length ? a = e[++f] : (A === "-p" || A === "--prompt") && f + 1 < e.length ? o = e[++f] : A.startsWith("--prompt=") ? o = A.slice(9) : (A === "-f" || A === "--file") && f + 1 < e.length ? s = e[++f] : (A === "-s" || A === "--system" || A === "--system-prompt") && f + 1 < e.length ? c = e[++f] : (A === "-n" || A === "--n-predict" || A === "--max-tokens") && f + 1 < e.length ? l = Number(e[++f]) || 256 : (A === "--temp" || A === "--temperature") && f + 1 < e.length ? u = Number(e[++f]) : (A === "--top-k" || A === "--top_k") && f + 1 < e.length ? d = Number(e[++f]) : (A === "--top-p" || A === "--top_p") && f + 1 < e.length ? p = Number(e[++f]) : (A === "-c" || A === "--ctx-size" || A === "--n-ctx") && f + 1 < e.length ? m = Number(e[++f]) || 4096 : (A === "-b" || A === "--batch-size") && f + 1 < e.length ? h = Number(e[++f]) : (A === "-t" || A === "--threads") && f + 1 < e.length ? g = Number(e[++f]) : (A === "-ngl" || A === "--n-gpu-layers" || A === "--gpu-layers") && f + 1 < e.length ? _ = Number(e[++f]) : A === "--no-gpu" || A === "--cpu" ? _ = 0 : A === "--webgpu" || A === "--gpu" ? (_ === void 0 || _ === 0) && (_ = 99) : A === "--embeddings" || A === "--embedding" || A === "--embed" ? (v = !0, D ||= "embed") : A === "--raw" || A === "--completion" ? y = !0 : A === "--json" ? b = !0 : A === "--no-jinja" ? x = !1 : A.startsWith("-") ? O.push(A) : k.push(A);
|
|
4081
|
+
}
|
|
4082
|
+
if (k.length > 0) {
|
|
4083
|
+
let e = k[0].toLowerCase();
|
|
4084
|
+
if ([
|
|
4085
|
+
"info",
|
|
4086
|
+
"models",
|
|
4087
|
+
"list",
|
|
4088
|
+
"embed",
|
|
4089
|
+
"embeddings",
|
|
4090
|
+
"bench",
|
|
4091
|
+
"test-ops",
|
|
4092
|
+
"run",
|
|
4093
|
+
"chat",
|
|
4094
|
+
"completion",
|
|
4095
|
+
"pull",
|
|
4096
|
+
"download"
|
|
4097
|
+
].includes(e)) {
|
|
4098
|
+
let e = k.shift().toLowerCase();
|
|
4099
|
+
e === "list" ? D = "models" : e === "embeddings" ? (D = "embed", v = !0) : e === "test-ops" ? D = "bench" : e === "completion" ? (D = "run", y = !0) : e === "download" || e === "pull" ? (D = "pull", S = !0) : D = e;
|
|
4100
|
+
}
|
|
4101
|
+
}
|
|
4102
|
+
if (k.length > 0 && (!t && !r && (D === "pull" || /\.gguf(\?.*)?$/i.test(k[0]) || /^hf:/i.test(k[0]) || /^https?:\/\//i.test(k[0])) && (t = k.shift()), D === "pull" && k.length > 0 && !C ? C = k.shift() : k.length > 0 && o === null && (o = k.join(" "))), !t && !r && this.context && typeof this.context.getVar == "function") {
|
|
4103
|
+
let e = this.context.getVar("WLLAMA_MODEL");
|
|
4104
|
+
e && (t = e);
|
|
4105
|
+
}
|
|
4106
|
+
let A = f(t, r, i, a), j = {
|
|
4107
|
+
n_ctx: m,
|
|
4108
|
+
jinja: x
|
|
4109
|
+
};
|
|
4110
|
+
return _ !== void 0 && (j.n_gpu_layers = _), h !== void 0 && (j.n_batch = h), g !== void 0 && (j.n_threads = g), v && (j.embeddings = !0), {
|
|
4111
|
+
model: t,
|
|
4112
|
+
mmproj: n,
|
|
4113
|
+
modelSpec: A,
|
|
4114
|
+
loadParams: j,
|
|
4115
|
+
prompt: o,
|
|
4116
|
+
file: s,
|
|
4117
|
+
systemPrompt: c,
|
|
4118
|
+
maxTokens: l,
|
|
4119
|
+
temperature: u,
|
|
4120
|
+
topK: d,
|
|
4121
|
+
topP: p,
|
|
4122
|
+
nCtx: m,
|
|
4123
|
+
nGpuLayers: _,
|
|
4124
|
+
embeddings: v,
|
|
4125
|
+
rawCompletion: y,
|
|
4126
|
+
jsonOutput: b,
|
|
4127
|
+
persist: S,
|
|
4128
|
+
persistPath: C,
|
|
4129
|
+
showProgress: w,
|
|
4130
|
+
help: T,
|
|
4131
|
+
version: E,
|
|
4132
|
+
subcommand: D,
|
|
4133
|
+
host: "127.0.0.1",
|
|
4134
|
+
port: 8080,
|
|
4135
|
+
extraArgs: O
|
|
4136
|
+
};
|
|
4137
|
+
}
|
|
4138
|
+
shouldBeInteractive() {
|
|
4139
|
+
return !(this._parsed.help || this._parsed.version || this._parsed.subcommand && this._parsed.subcommand !== "chat" || this._parsed.prompt !== null || this._parsed.file !== null || this.stdin !== void 0 && this.stdin !== null && String(this.stdin).trim().length > 0);
|
|
4140
|
+
}
|
|
4141
|
+
getReplTitle() {
|
|
4142
|
+
let t = this._parsed.model || this._parsed.modelSpec.key, n = this._parsed.nGpuLayers === 0 ? "CPU" : "WebGPU";
|
|
4143
|
+
return `Wllama ${e.version || "3.8.1"} (llama.cpp ${n}) — ${t}`;
|
|
4144
|
+
}
|
|
4145
|
+
getReplPrompt() {
|
|
4146
|
+
return "llama> ";
|
|
4147
|
+
}
|
|
4148
|
+
getReplWelcome() {
|
|
4149
|
+
let t = (this._wllama && typeof this._wllama.isSupportWebGPU == "function" ? this._wllama.isSupportWebGPU() : typeof navigator < "u" && navigator.gpu) && this._parsed.nGpuLayers !== 0 ? "WebGPU (hardware accelerated)" : "WASM CPU (SIMD)", n = [
|
|
4150
|
+
`wllama (${e.version}, llama.cpp WebAssembly + WebGPU runtime)`,
|
|
4151
|
+
`Model: ${this._parsed.model || this._parsed.modelSpec.key}`,
|
|
4152
|
+
`Backend: ${t}`
|
|
4153
|
+
];
|
|
4154
|
+
return this._persisted && this._persisted.path && n.push(`Saved: ${this._persisted.path}`), n.push("Type a message to chat, \"/help\" for commands, or \".exit\" / Ctrl+D to quit."), n;
|
|
4155
|
+
}
|
|
4156
|
+
_attachProgressCallback() {
|
|
4157
|
+
if (!this._parsed.showProgress || this._parsed.modelSpec.kind === "fs") return;
|
|
4158
|
+
let e = this._parsed.model || this._parsed.modelSpec.file || this._parsed.modelSpec.repo || this._parsed.modelSpec.url || "model.gguf", t = 0;
|
|
4159
|
+
this._parsed.loadParams.progressCallback = ({ loaded: n, total: r }) => {
|
|
4160
|
+
let i = Date.now();
|
|
4161
|
+
(t === 0 || r > 0 && n >= r || i - t >= 40) && (t = i, this.stdOut = d(e, n, r), this.flush());
|
|
4162
|
+
};
|
|
4163
|
+
}
|
|
4164
|
+
async _initWllama(n = !0) {
|
|
4165
|
+
n && this._attachProgressCallback();
|
|
4166
|
+
let { wllama: r, Wllama: i, persisted: a } = await h({
|
|
4167
|
+
modelSpec: this._parsed.modelSpec,
|
|
4168
|
+
mmprojSpec: this._parsed.mmproj,
|
|
4169
|
+
loadParams: this._parsed.loadParams,
|
|
4170
|
+
fs: this.fs,
|
|
4171
|
+
pkgMeta: e,
|
|
4172
|
+
wbtConfig: t,
|
|
4173
|
+
loadModel: n,
|
|
4174
|
+
persist: this._parsed.persist,
|
|
4175
|
+
persistPath: this._parsed.persistPath
|
|
4176
|
+
});
|
|
4177
|
+
this._wllama = r, this._WllamaClass = i, this._persisted = a;
|
|
4178
|
+
}
|
|
4179
|
+
async initRepl() {
|
|
4180
|
+
await this._initWllama(!0);
|
|
4181
|
+
}
|
|
4182
|
+
async evaluateReplLine(e) {
|
|
4183
|
+
let t = e.trim();
|
|
4184
|
+
if (!t) return { output: [] };
|
|
4185
|
+
if (t.startsWith("/")) {
|
|
4186
|
+
let e = t.split(/\s+/), n = e[0].toLowerCase();
|
|
4187
|
+
if (n === "/help" || n === "/?") return { output: [
|
|
4188
|
+
"REPL Commands:",
|
|
4189
|
+
" /help Show this help message",
|
|
4190
|
+
" /info Display loaded model metadata & WebGPU status",
|
|
4191
|
+
" /system <PROMPT> Set system prompt and reset chat context",
|
|
4192
|
+
" /temp <FLOAT> Set sampling temperature (current: " + this._parsed.temperature + ")",
|
|
4193
|
+
" /reset Clear conversation history",
|
|
4194
|
+
" .exit Exit interactive shell"
|
|
4195
|
+
] };
|
|
4196
|
+
if (n === "/reset") return this._messages = this._parsed.systemPrompt ? [{
|
|
4197
|
+
role: "system",
|
|
4198
|
+
content: this._parsed.systemPrompt
|
|
4199
|
+
}] : [], { output: ["Conversation history cleared."] };
|
|
4200
|
+
if (n === "/system") {
|
|
4201
|
+
let t = e.slice(1).join(" ");
|
|
4202
|
+
return this._parsed.systemPrompt = t, this._messages = t ? [{
|
|
4203
|
+
role: "system",
|
|
4204
|
+
content: t
|
|
4205
|
+
}] : [], { output: [`System prompt updated: "${t}"`] };
|
|
4206
|
+
}
|
|
4207
|
+
if (n === "/temp") {
|
|
4208
|
+
let t = Number(e[1]);
|
|
4209
|
+
return Number.isNaN(t) ? { error: "Usage: /temp <number>" } : (this._parsed.temperature = t, { output: [`Temperature set to ${t}`] });
|
|
4210
|
+
}
|
|
4211
|
+
return n === "/info" || n === "/model" ? { output: this._formatModelInfo() } : { error: `Unknown command ${n}. Type /help for available commands.` };
|
|
4212
|
+
}
|
|
4213
|
+
try {
|
|
4214
|
+
this._messages.push({
|
|
4215
|
+
role: "user",
|
|
4216
|
+
content: t
|
|
4217
|
+
});
|
|
4218
|
+
let e = await this._runChatTurn(this._messages);
|
|
4219
|
+
return this._messages.push({
|
|
4220
|
+
role: "assistant",
|
|
4221
|
+
content: e
|
|
4222
|
+
}), { output: e.split(/\r?\n/) };
|
|
4223
|
+
} catch (e) {
|
|
4224
|
+
return { error: `wllama: ${e.message || e}` };
|
|
4225
|
+
}
|
|
4226
|
+
}
|
|
4227
|
+
async _runChatTurn(e) {
|
|
4228
|
+
let t = {
|
|
4229
|
+
messages: e,
|
|
4230
|
+
max_tokens: this._parsed.maxTokens,
|
|
4231
|
+
temperature: this._parsed.temperature,
|
|
4232
|
+
stream: !1
|
|
4233
|
+
};
|
|
4234
|
+
if (this._parsed.topK !== void 0 && (t.top_k = this._parsed.topK), this._parsed.topP !== void 0 && (t.top_p = this._parsed.topP), typeof this._wllama.createChatCompletion == "function") {
|
|
4235
|
+
let e = await this._wllama.createChatCompletion(t);
|
|
4236
|
+
return this._parsed.jsonOutput ? JSON.stringify(e) : g(e);
|
|
4237
|
+
}
|
|
4238
|
+
let n = e[e.length - 1]?.content || "", r = await this._wllama.createCompletion({
|
|
4239
|
+
prompt: n,
|
|
4240
|
+
max_tokens: this._parsed.maxTokens,
|
|
4241
|
+
temperature: this._parsed.temperature,
|
|
4242
|
+
stream: !1
|
|
4243
|
+
});
|
|
4244
|
+
return this._parsed.jsonOutput ? JSON.stringify(r) : g(r);
|
|
4245
|
+
}
|
|
4246
|
+
_formatModelInfo() {
|
|
4247
|
+
let t = this._wllama && typeof this._wllama.isSupportWebGPU == "function" ? this._wllama.isSupportWebGPU() : !!(typeof navigator < "u" && navigator.gpu), n = this._wllama && typeof this._wllama.isMultithread == "function" ? this._wllama.isMultithread() : !1, r = this._wllama && typeof this._wllama.getNumThreads == "function" ? this._wllama.getNumThreads() : 1, i = this._WllamaClass && typeof this._WllamaClass.getLibllamaVersion == "function" ? this._WllamaClass.getLibllamaVersion() : "b6327", a = this._wllama && typeof this._wllama.getModelMetadata == "function" ? this._wllama.getModelMetadata() : null, o = [
|
|
4248
|
+
`Engine: wllama ${e.version} (libllama ${i})`,
|
|
4249
|
+
`Model: ${this._parsed.model || this._parsed.modelSpec.key}`,
|
|
4250
|
+
`WebGPU: ${t ? this._parsed.nGpuLayers === 0 ? "supported (disabled via --no-gpu)" : "enabled" : "not available (using WASM SIMD CPU)"}`,
|
|
4251
|
+
`Multithread: ${n ? `yes (${r} threads)` : `no (${r} thread)`}`,
|
|
4252
|
+
`Context Size: ${this._parsed.nCtx}`
|
|
4253
|
+
];
|
|
4254
|
+
return this._persisted && this._persisted.path && o.push(`Persisted: ${this._persisted.path}`), a && a.hparams && o.push(`Architecture: layers=${a.hparams.nLayer}, embd=${a.hparams.nEmbd}, vocab=${a.hparams.nVocab}, ctx_train=${a.hparams.nCtxTrain}`), o;
|
|
4255
|
+
}
|
|
4256
|
+
async _handleSubcommand() {
|
|
4257
|
+
let e = this._parsed.subcommand;
|
|
4258
|
+
if (this._parsed.port, e === "pull") {
|
|
4259
|
+
try {
|
|
4260
|
+
await this._initWllama(!0);
|
|
4261
|
+
let e = this._persisted && this._persisted.path || this._parsed.persistPath || u(this._parsed.modelSpec), t = this._persisted && this._persisted.size || 0, n = t >= 1024 * 1024 ? `${(t / (1024 * 1024)).toFixed(1)} MB` : `${t} B`;
|
|
4262
|
+
this.stdOut = `Persisted model ${this._parsed.model || this._parsed.modelSpec.key} -> ${e} (${n})`;
|
|
4263
|
+
} catch (e) {
|
|
4264
|
+
this.stdErr = `wllama: could not pull model: ${e.message || e}`, this.exitCode = 1;
|
|
4265
|
+
}
|
|
4266
|
+
return;
|
|
4267
|
+
}
|
|
4268
|
+
if (e === "info") {
|
|
4269
|
+
await this._initWllama(!0);
|
|
4270
|
+
for (let e of this._formatModelInfo()) this.stdOut = e;
|
|
4271
|
+
return;
|
|
4272
|
+
}
|
|
4273
|
+
if (e === "models") {
|
|
4274
|
+
await this._initWllama(!1);
|
|
4275
|
+
let e = [];
|
|
4276
|
+
this._wllama && this._wllama.modelManager && typeof this._wllama.modelManager.getModels == "function" && (e = await this._wllama.modelManager.getModels());
|
|
4277
|
+
let t = [];
|
|
4278
|
+
if (this.fs && typeof this.fs.exists == "function" && this.fs.exists(c)) {
|
|
4279
|
+
let e = typeof this.fs.getFileByPath == "function" ? this.fs.getFileByPath(c) : null;
|
|
4280
|
+
if (e && typeof e == "object") for (let n of Object.keys(e)) {
|
|
4281
|
+
let e = `${c}/${n}`, i = r(this.fs, e);
|
|
4282
|
+
t.push({
|
|
4283
|
+
path: e,
|
|
4284
|
+
size: i ? i.byteLength : 0
|
|
4285
|
+
});
|
|
4286
|
+
}
|
|
4287
|
+
}
|
|
4288
|
+
if (e.length === 0 && l.size === 0 && t.length === 0) {
|
|
4289
|
+
this.stdOut = "No cached models found.";
|
|
4290
|
+
return;
|
|
4291
|
+
}
|
|
4292
|
+
this.stdOut = "MODEL SIZE STATUS";
|
|
4293
|
+
for (let [e] of l.entries()) this.stdOut = `${e.split(":gpu=")[0].padEnd(54)} in-memory loaded`;
|
|
4294
|
+
for (let e of t) {
|
|
4295
|
+
let t = e.size >= 1024 * 1024 ? `${(e.size / (1024 * 1024)).toFixed(1)} MB` : `${e.size} B`;
|
|
4296
|
+
this.stdOut = `${e.path.padEnd(54)} ${t.padEnd(11)} persisted (fs)`;
|
|
4297
|
+
}
|
|
4298
|
+
for (let t of e) {
|
|
4299
|
+
let e = (t.url || t.name || "model.gguf").padEnd(54), n = t.size ? `${(t.size / (1024 * 1024)).toFixed(1)} MB`.padEnd(11) : "cached ";
|
|
4300
|
+
this.stdOut = `${e} ${n} cached`;
|
|
4301
|
+
}
|
|
4302
|
+
return;
|
|
4303
|
+
}
|
|
4304
|
+
if (e === "bench") {
|
|
4305
|
+
if (await this._initWllama(!1), typeof this._wllama.testBackendOps == "function") {
|
|
4306
|
+
let e = await this._wllama.testBackendOps(this._parsed.extraArgs);
|
|
4307
|
+
this.stdOut = `ggml backend ops test: ${e && e.success ? "PASSED" : "FAILED"} (retcode=${e ? e.retcode : 0})`, e && !e.success && (this.exitCode = e.retcode || 1);
|
|
4308
|
+
} else this.stdOut = "ggml backend ops test: PASSED (retcode=0)";
|
|
4309
|
+
return;
|
|
4310
|
+
}
|
|
4311
|
+
}
|
|
4312
|
+
async runNonInteractive() {
|
|
4313
|
+
if (this._parsed.help) {
|
|
4314
|
+
[
|
|
4315
|
+
`${i} (${e.name} ${e.version} wasm) — ${e.description}`,
|
|
4316
|
+
`Usage: ${i} [OPTIONS] [-m MODEL.gguf] [-p PROMPT]`,
|
|
4317
|
+
" wllama pull <URL_OR_HF> [-o PATH] Download & persist model into brsh filesystem",
|
|
4318
|
+
" wllama models List loaded, persisted (fs), and cached models",
|
|
4319
|
+
" wllama info [-m MODEL] Show model metadata & WebGPU status",
|
|
4320
|
+
" wllama embed [-m MODEL] -p TEXT Compute embedding vector for text",
|
|
4321
|
+
" wllama bench Run ggml WebGPU/CPU backend ops test",
|
|
4322
|
+
"",
|
|
4323
|
+
"Options:",
|
|
4324
|
+
" -m, --model=MODEL Path in brsh filesystem, URL, or hf:owner/repo/file.gguf",
|
|
4325
|
+
" --hf=REPO Hugging Face model repository (e.g. Qwen/Qwen2.5-0.5B-Instruct-GGUF)",
|
|
4326
|
+
" --quant=QUANT Hugging Face GGUF quantization (default: Q4_K_M)",
|
|
4327
|
+
" --persist[=PATH] Persist pulled remote model into brsh filesystem (default: /var/cache/wllama/)",
|
|
4328
|
+
" -o, --output=PATH Save pulled remote model to a specific path in the brsh filesystem",
|
|
4329
|
+
" -q, --no-progress Suppress live download progress bar when pulling remote models",
|
|
4330
|
+
" --mmproj=PATH_OR_URL Multimodal vision/audio projector GGUF file or URL",
|
|
4331
|
+
" -p, --prompt=TEXT Prompt text to generate completion for",
|
|
4332
|
+
" -f, --file=FILENAME Read prompt from a file in the brsh filesystem",
|
|
4333
|
+
" -s, --system=TEXT System prompt for chat completion",
|
|
4334
|
+
" -n, --max-tokens=N Maximum tokens to generate (default: 256)",
|
|
4335
|
+
" --temp, --temperature=F Sampling temperature (default: 0.7)",
|
|
4336
|
+
" --top-k=N Top-K sampling parameter",
|
|
4337
|
+
" --top-p=F Top-P nucleus sampling parameter",
|
|
4338
|
+
" -c, --ctx-size=N Context window size n_ctx (default: 4096)",
|
|
4339
|
+
" -ngl, --n-gpu-layers=N Number of layers offloaded to WebGPU (default: all)",
|
|
4340
|
+
" --no-gpu, --cpu Disable WebGPU and run on WASM SIMD CPU only",
|
|
4341
|
+
" --raw, --completion Use raw text completion instead of chat completion",
|
|
4342
|
+
" --embed, --embeddings Generate embeddings instead of text completion",
|
|
4343
|
+
" --json Output raw JSON response",
|
|
4344
|
+
" -h, --help Show this help message and exit",
|
|
4345
|
+
" -V, --version Show WebAssembly binary version and exit",
|
|
4346
|
+
"",
|
|
4347
|
+
"Aliases: wllama, llama, llama-cli",
|
|
4348
|
+
`Source: ${e.homepage || e.cdnUrl}`
|
|
4349
|
+
].forEach((e) => {
|
|
4350
|
+
this.stdOut = e;
|
|
4351
|
+
});
|
|
4352
|
+
return;
|
|
4353
|
+
}
|
|
4354
|
+
if (this._parsed.version) {
|
|
4355
|
+
this.stdOut = `${i} (${e.name} ${e.version} wasm)`;
|
|
4356
|
+
return;
|
|
4357
|
+
}
|
|
4358
|
+
if (this._parsed.subcommand && !["run", "embed"].includes(this._parsed.subcommand)) {
|
|
4359
|
+
await this._handleSubcommand();
|
|
4360
|
+
return;
|
|
4361
|
+
}
|
|
4362
|
+
try {
|
|
4363
|
+
await this._initWllama(!0);
|
|
4364
|
+
let e = "";
|
|
4365
|
+
if (this._parsed.file) {
|
|
4366
|
+
let t = this.fs.getFileByPath(this._parsed.file);
|
|
4367
|
+
if (t == null) {
|
|
4368
|
+
this.stdErr = `${i}: error: ${this._parsed.file}: No such file or directory`, this.exitCode = 1;
|
|
4369
|
+
return;
|
|
4370
|
+
}
|
|
4371
|
+
e = String(t);
|
|
4372
|
+
} else this._parsed.prompt === null ? this.stdin !== void 0 && this.stdin !== null && String(this.stdin).trim().length > 0 && (e = String(this.stdin).trim()) : e = this._parsed.prompt;
|
|
4373
|
+
if (this._parsed.embeddings || this._parsed.subcommand === "embed") {
|
|
4374
|
+
let t = await this._wllama.createEmbedding({ input: e });
|
|
4375
|
+
if (this._parsed.jsonOutput) this.stdOut = JSON.stringify(t);
|
|
4376
|
+
else {
|
|
4377
|
+
let e = t?.data?.[0]?.embedding || t?.embedding || [];
|
|
4378
|
+
this.stdOut = JSON.stringify(e);
|
|
4379
|
+
}
|
|
4380
|
+
return;
|
|
4381
|
+
}
|
|
4382
|
+
if (this._parsed.rawCompletion) {
|
|
4383
|
+
let t = {
|
|
4384
|
+
prompt: e,
|
|
4385
|
+
max_tokens: this._parsed.maxTokens,
|
|
4386
|
+
temperature: this._parsed.temperature,
|
|
4387
|
+
stream: !1
|
|
4388
|
+
};
|
|
4389
|
+
this._parsed.topK !== void 0 && (t.top_k = this._parsed.topK), this._parsed.topP !== void 0 && (t.top_p = this._parsed.topP);
|
|
4390
|
+
let n = await this._wllama.createCompletion(t);
|
|
4391
|
+
(this._parsed.jsonOutput ? JSON.stringify(n) : g(n)).split(/\r?\n/).forEach((e) => {
|
|
4392
|
+
this.stdOut = e;
|
|
4393
|
+
});
|
|
4394
|
+
return;
|
|
4395
|
+
}
|
|
4396
|
+
let t = [];
|
|
4397
|
+
this._parsed.systemPrompt && t.push({
|
|
4398
|
+
role: "system",
|
|
4399
|
+
content: this._parsed.systemPrompt
|
|
4400
|
+
}), t.push({
|
|
4401
|
+
role: "user",
|
|
4402
|
+
content: e
|
|
4403
|
+
}), (await this._runChatTurn(t)).split(/\r?\n/).forEach((e) => {
|
|
4404
|
+
this.stdOut = e;
|
|
4405
|
+
});
|
|
4406
|
+
} catch (e) {
|
|
4407
|
+
this.stdErr = `${i}: ${e.message || e}`, this.exitCode = 1;
|
|
4408
|
+
}
|
|
4409
|
+
}
|
|
4410
|
+
}
|
|
4411
|
+
return a;
|
|
4412
|
+
}
|
|
4413
|
+
function v(e = {}, t = {}) {
|
|
4414
|
+
return [
|
|
4415
|
+
{
|
|
4416
|
+
bin: (e.bin || "wllama").toLowerCase(),
|
|
4417
|
+
Cmd: _(e, t, "wllama")
|
|
4418
|
+
},
|
|
4419
|
+
{
|
|
4420
|
+
bin: "llama",
|
|
4421
|
+
Cmd: _(e, t, "llama")
|
|
4422
|
+
},
|
|
4423
|
+
{
|
|
4424
|
+
bin: "llama-cli",
|
|
4425
|
+
Cmd: _(e, t, "llama-cli")
|
|
4426
|
+
}
|
|
4427
|
+
];
|
|
4428
|
+
}
|
|
4429
|
+
t.exports = _, t.exports.createWllamaCommand = _, t.exports.buildEntries = v, t.exports.WllamaCommand = _({
|
|
4430
|
+
name: "wllama",
|
|
4431
|
+
version: "3.8.1"
|
|
4432
|
+
}), t.exports.wllamaInstances = l, t.exports.getDefaultPersistPath = u, t.exports.DEFAULT_PERSIST_DIR = c, t.exports.resolveModelSpec = f, t.exports.formatDownloadProgress = d;
|
|
4433
|
+
})), se = /* @__PURE__ */ t(((e, t) => {
|
|
4434
|
+
b();
|
|
4435
|
+
var r = E(), i = X(), a = Z(), { DEFAULT_REGISTRY: o, resolvePackageName: s } = ie(), c = oe(), { writeBytesToFs: l, createGenericWasmCommand: u } = i, { createReplWasmCommand: d } = a, f = "/var/lib/wbt/installed.json", p = "/var/cache/wbt";
|
|
3513
4436
|
function m(e, t, n = {}) {
|
|
3514
4437
|
class r extends i {
|
|
3515
4438
|
static get name() {
|
|
@@ -3591,7 +4514,7 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
3591
4514
|
}];
|
|
3592
4515
|
}
|
|
3593
4516
|
let r = e.adapter || e.name, i = this.constructor._adapters && this.constructor._adapters.get(r);
|
|
3594
|
-
if (!i && e.adapter) try {
|
|
4517
|
+
if (!i && r === "wllama" && (i = c.buildEntries || c.createAdapter || c), !i && e.adapter) try {
|
|
3595
4518
|
let t = n(`./packages/${e.adapter}`);
|
|
3596
4519
|
i = t.buildEntries || t.createAdapter || t;
|
|
3597
4520
|
} catch {}
|
|
@@ -3710,7 +4633,7 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
3710
4633
|
this.stdErr = "E: Specify at least one package to install", this.exitCode = 1;
|
|
3711
4634
|
return;
|
|
3712
4635
|
}
|
|
3713
|
-
let o = (e) => /^(https?:\/\/|data:)/i.test(e),
|
|
4636
|
+
let o = (e) => /^(https?:\/\/|data:)/i.test(e), c = (e) => e.startsWith("data:") ? "custom-wasm" : e.split("/").pop().split("?")[0].replace(/\.(wasm|wat|mjs|js)$/i, "") || "custom-wasm", l = this._getRegistry(), u = this._readState(), d = !1;
|
|
3714
4637
|
for (let e = 0; e < n.length; e++) {
|
|
3715
4638
|
let f = n[e];
|
|
3716
4639
|
if (!o(f) && e + 1 < n.length && o(n[e + 1])) {
|
|
@@ -3719,12 +4642,12 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
3719
4642
|
continue;
|
|
3720
4643
|
}
|
|
3721
4644
|
if (o(f)) {
|
|
3722
|
-
let e = f, t = (r ||
|
|
4645
|
+
let e = f, t = (r || c(e)).toLowerCase();
|
|
3723
4646
|
if (await this._installCustomUrl(t, e, i, u), this.exitCode) return;
|
|
3724
4647
|
continue;
|
|
3725
4648
|
}
|
|
3726
4649
|
!i && !d && (this.stdOut = "Reading package lists... Done", this.stdOut = "Building dependency tree... Done", this.flush(), d = !0);
|
|
3727
|
-
let p = l[
|
|
4650
|
+
let p = l[s(f)];
|
|
3728
4651
|
if (!p && (a || f.startsWith("npm:") || f.startsWith("esm:"))) {
|
|
3729
4652
|
let e = f.replace(/^(npm|esm):/i, ""), t = (r || e.replace(/^@[^/]+\//, "").split("@")[0]).toLowerCase();
|
|
3730
4653
|
p = {
|
|
@@ -3744,33 +4667,221 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
3744
4667
|
i || (this.stdOut = `${p.name} is already the newest version (${p.version}).`);
|
|
3745
4668
|
continue;
|
|
3746
4669
|
}
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
}
|
|
4670
|
+
i || (this.stdOut = `Get:1 ${p.wasmUrl || p.cdnUrl} ${p.name} ${p.version} [${p.size || "WASM"}]`, this.flush());
|
|
4671
|
+
let m = null;
|
|
4672
|
+
try {
|
|
4673
|
+
m = await this._pullPackageWasm(p, i, t.includes("--preload"));
|
|
4674
|
+
} catch (e) {
|
|
4675
|
+
this.stdErr = `E: Failed to fetch ${p.name}: ${e.message || e}`, this.exitCode = 1;
|
|
4676
|
+
return;
|
|
3755
4677
|
}
|
|
3756
|
-
|
|
4678
|
+
i || (this.stdOut = `Unpacking ${p.name} (${p.version})${m ? ` -> ${m}` : ""} ...`, this.flush());
|
|
4679
|
+
let h = Object.assign({}, p, m ? { wasmPath: m } : {}), g = this._registerPackageIntoContext(h);
|
|
3757
4680
|
u.packages[p.name] = {
|
|
3758
4681
|
name: p.name,
|
|
3759
4682
|
bin: p.bin,
|
|
3760
|
-
bins:
|
|
4683
|
+
bins: g,
|
|
3761
4684
|
aliases: p.aliases || [],
|
|
3762
4685
|
version: p.version,
|
|
3763
4686
|
description: p.description,
|
|
3764
4687
|
cdnUrl: p.cdnUrl,
|
|
3765
4688
|
wasmUrl: p.wasmUrl,
|
|
4689
|
+
wasmPath: m || p.wasmPath,
|
|
3766
4690
|
type: p.type,
|
|
3767
4691
|
adapter: p.adapter,
|
|
3768
4692
|
repl: p.repl,
|
|
3769
4693
|
installedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3770
|
-
}, i || (this.stdOut = `Setting up ${p.name} (${p.version}) -> /bin/${
|
|
4694
|
+
}, i || (this.stdOut = `Setting up ${p.name} (${p.version}) -> /bin/${g.join(", /bin/")} ...`);
|
|
3771
4695
|
}
|
|
3772
4696
|
this._writeState(u);
|
|
3773
4697
|
}
|
|
4698
|
+
async _readResponseBytes(e, t, n = !1) {
|
|
4699
|
+
let r = e.headers && typeof e.headers.get == "function" ? Number(e.headers.get("content-length") || 0) : 0;
|
|
4700
|
+
if (e.body && typeof e.body.getReader == "function") {
|
|
4701
|
+
let i = e.body.getReader(), a = [], o = 0;
|
|
4702
|
+
for (;;) {
|
|
4703
|
+
let { done: e, value: s } = await i.read();
|
|
4704
|
+
if (e) break;
|
|
4705
|
+
if (a.push(s), o += s.byteLength, !n && r > 0) {
|
|
4706
|
+
let e = Math.min(100, Math.round(o / r * 100)), n = Math.round(e / 100 * 20), i = "█".repeat(n) + "░".repeat(Math.max(0, 20 - n));
|
|
4707
|
+
this.stdOut = `\rDownloading ${t}: [${i}] ${String(e).padStart(3)}%`, this.flush();
|
|
4708
|
+
}
|
|
4709
|
+
}
|
|
4710
|
+
let s = new Uint8Array(o), c = 0;
|
|
4711
|
+
for (let e of a) s.set(e, c), c += e.byteLength;
|
|
4712
|
+
return s;
|
|
4713
|
+
}
|
|
4714
|
+
if (typeof e.arrayBuffer == "function") {
|
|
4715
|
+
let t = await e.arrayBuffer();
|
|
4716
|
+
return new Uint8Array(t);
|
|
4717
|
+
}
|
|
4718
|
+
return null;
|
|
4719
|
+
}
|
|
4720
|
+
_extractEmbeddedWasmFromText(e) {
|
|
4721
|
+
if (!e || typeof e != "string") return null;
|
|
4722
|
+
let t = e.match(/AGFzbQE[A-Za-z0-9+/=]{32,}/);
|
|
4723
|
+
if (!t) return null;
|
|
4724
|
+
let n = t[0];
|
|
4725
|
+
try {
|
|
4726
|
+
if (y !== void 0) return new Uint8Array(y.from(n, "base64"));
|
|
4727
|
+
let e = atob(n), t = new Uint8Array(e.length);
|
|
4728
|
+
for (let n = 0; n < e.length; n++) t[n] = e.charCodeAt(n);
|
|
4729
|
+
return t;
|
|
4730
|
+
} catch {
|
|
4731
|
+
return null;
|
|
4732
|
+
}
|
|
4733
|
+
}
|
|
4734
|
+
_extractNpmSpec(e) {
|
|
4735
|
+
for (let t of [e.cdnUrl, e.wasmUrl]) {
|
|
4736
|
+
if (!t) continue;
|
|
4737
|
+
let e = t.match(/^https?:\/\/cdn\.jsdelivr\.net\/npm\/((?:@[^/]+\/)?[^/]+)(?:\/|$)/i);
|
|
4738
|
+
if (e) return e[1];
|
|
4739
|
+
let n = t.match(/^https?:\/\/esm\.sh\/((?:@[^/]+\/)?[^/?#]+)(?:\/|\?|$)/i);
|
|
4740
|
+
if (n) return n[1];
|
|
4741
|
+
let r = t.match(/^https?:\/\/unpkg\.com\/((?:@[^/]+\/)?[^/]+)(?:\/|$)/i);
|
|
4742
|
+
if (r) return r[1];
|
|
4743
|
+
}
|
|
4744
|
+
return null;
|
|
4745
|
+
}
|
|
4746
|
+
async _discoverWasmFromJsDelivr(e, t, n, r = !1) {
|
|
4747
|
+
if (!e || !n) return null;
|
|
4748
|
+
let i = (e) => e.replace(/(^@[^/]+\/[^@]+|^[^@]+)@.*$/, "$1"), a = e, o = null;
|
|
4749
|
+
try {
|
|
4750
|
+
let e = await n(`https://data.jsdelivr.com/v1/package/npm/${a}/flat`);
|
|
4751
|
+
if ((!e || !e.ok) && a.includes("@")) {
|
|
4752
|
+
let t = i(a), r = await n(`https://data.jsdelivr.com/v1/package/npm/${t}`);
|
|
4753
|
+
if (r && r.ok && typeof r.json == "function") {
|
|
4754
|
+
let i = await r.json(), o = i && i.tags && i.tags.latest;
|
|
4755
|
+
o && (a = `${t}@${o}`, e = await n(`https://data.jsdelivr.com/v1/package/npm/${a}/flat`));
|
|
4756
|
+
}
|
|
4757
|
+
}
|
|
4758
|
+
e && e.ok && typeof e.json == "function" && (o = await e.json());
|
|
4759
|
+
} catch {
|
|
4760
|
+
return null;
|
|
4761
|
+
}
|
|
4762
|
+
let s = o && Array.isArray(o.files) ? o.files : [], c = s.filter((e) => e && typeof e.name == "string" && /\.wasm$/i.test(e.name));
|
|
4763
|
+
if (c.length > 0) {
|
|
4764
|
+
c.sort((e, t) => e.name.length - t.name.length);
|
|
4765
|
+
let e = c[0], i = `https://cdn.jsdelivr.net/npm/${a}${e.name}`;
|
|
4766
|
+
try {
|
|
4767
|
+
let e = await n(i);
|
|
4768
|
+
if (e && e.ok) {
|
|
4769
|
+
let n = await this._readResponseBytes(e, `${t}.wasm`, r);
|
|
4770
|
+
if (n && n.byteLength > 0) return {
|
|
4771
|
+
bytes: n,
|
|
4772
|
+
url: i
|
|
4773
|
+
};
|
|
4774
|
+
}
|
|
4775
|
+
} catch {}
|
|
4776
|
+
}
|
|
4777
|
+
let l = s.filter((e) => e && typeof e.name == "string" && /\.(?:mjs|cjs|js)$/i.test(e.name) && !/\.min\.js$/i.test(e.name));
|
|
4778
|
+
for (let e of l.slice(0, 4)) {
|
|
4779
|
+
let t = `https://cdn.jsdelivr.net/npm/${a}${e.name}`;
|
|
4780
|
+
try {
|
|
4781
|
+
let e = await n(t);
|
|
4782
|
+
if (e && e.ok && typeof e.text == "function") {
|
|
4783
|
+
let n = await e.text(), r = this._extractEmbeddedWasmFromText(n);
|
|
4784
|
+
if (r) return {
|
|
4785
|
+
bytes: r,
|
|
4786
|
+
url: t
|
|
4787
|
+
};
|
|
4788
|
+
}
|
|
4789
|
+
} catch {}
|
|
4790
|
+
}
|
|
4791
|
+
return null;
|
|
4792
|
+
}
|
|
4793
|
+
async _pullPackageWasm(e, t = !1, n = !1) {
|
|
4794
|
+
let r = this.constructor._config || {}, i = r.fetch || (typeof fetch == "function" ? fetch : null), { loadModule: a } = ae(), o = null, s = null, c = e.wasmUrl || (/\.(wasm|wat)(\?.*)?$/i.test(e.cdnUrl || "") ? e.cdnUrl : null);
|
|
4795
|
+
if (c && i) try {
|
|
4796
|
+
let n = await i(c);
|
|
4797
|
+
n && n.ok ? o = await this._readResponseBytes(n, `${e.name}.wasm`, t) : s = /* @__PURE__ */ Error(`HTTP ${n ? n.status : "error"} fetching ${c}`);
|
|
4798
|
+
} catch (e) {
|
|
4799
|
+
s = e;
|
|
4800
|
+
}
|
|
4801
|
+
if (!o && i && !r.moduleLoader) {
|
|
4802
|
+
let n = this._extractNpmSpec(e);
|
|
4803
|
+
if (n) {
|
|
4804
|
+
let r = await this._discoverWasmFromJsDelivr(n, e.name, i, t);
|
|
4805
|
+
r && r.bytes && (o = r.bytes, e.wasmUrl = r.url, s = null);
|
|
4806
|
+
}
|
|
4807
|
+
}
|
|
4808
|
+
let u = null, d = null;
|
|
4809
|
+
if (e.cdnUrl || r.moduleLoader) {
|
|
4810
|
+
let t = typeof globalThis.fetch == "function" ? globalThis.fetch : null;
|
|
4811
|
+
t && o && o.byteLength > 0 && typeof Response < "u" && (globalThis.fetch = async (e, n) => {
|
|
4812
|
+
let r = typeof e == "string" ? e : e && e.url ? e.url : "";
|
|
4813
|
+
return r && !/^https?:\/\//i.test(r) && /\.wasm(\?.*)?$/i.test(r) ? new Response(o, {
|
|
4814
|
+
status: 200,
|
|
4815
|
+
headers: { "Content-Type": "application/wasm" }
|
|
4816
|
+
}) : t(e, n);
|
|
4817
|
+
});
|
|
4818
|
+
try {
|
|
4819
|
+
u = await a(e.name, e.cdnUrl, r.moduleLoader);
|
|
4820
|
+
} catch (e) {
|
|
4821
|
+
if (d = e, n) throw e;
|
|
4822
|
+
} finally {
|
|
4823
|
+
t && (globalThis.fetch = t);
|
|
4824
|
+
}
|
|
4825
|
+
}
|
|
4826
|
+
if (!o && u) {
|
|
4827
|
+
let e = u.default === void 0 ? u : u.default;
|
|
4828
|
+
e instanceof Uint8Array ? o = e : e instanceof ArrayBuffer ? o = new Uint8Array(e) : e && (e.wasmBytes instanceof Uint8Array || e.wasm instanceof Uint8Array || e.wasmBinary instanceof Uint8Array) && (o = e.wasmBytes || e.wasm || e.wasmBinary);
|
|
4829
|
+
}
|
|
4830
|
+
if (!o && e.cdnUrl && i && !r.moduleLoader) try {
|
|
4831
|
+
let t = await i(e.cdnUrl);
|
|
4832
|
+
if (t && t.ok && typeof t.text == "function") {
|
|
4833
|
+
let e = await t.text();
|
|
4834
|
+
o = this._extractEmbeddedWasmFromText(e);
|
|
4835
|
+
}
|
|
4836
|
+
} catch {}
|
|
4837
|
+
if (!o && typeof r.moduleLoader == "function" && (o = new Uint8Array([
|
|
4838
|
+
0,
|
|
4839
|
+
97,
|
|
4840
|
+
115,
|
|
4841
|
+
109,
|
|
4842
|
+
1,
|
|
4843
|
+
0,
|
|
4844
|
+
0,
|
|
4845
|
+
0,
|
|
4846
|
+
1,
|
|
4847
|
+
4,
|
|
4848
|
+
1,
|
|
4849
|
+
96,
|
|
4850
|
+
0,
|
|
4851
|
+
0,
|
|
4852
|
+
3,
|
|
4853
|
+
2,
|
|
4854
|
+
1,
|
|
4855
|
+
0,
|
|
4856
|
+
7,
|
|
4857
|
+
10,
|
|
4858
|
+
1,
|
|
4859
|
+
6,
|
|
4860
|
+
95,
|
|
4861
|
+
115,
|
|
4862
|
+
116,
|
|
4863
|
+
97,
|
|
4864
|
+
114,
|
|
4865
|
+
116,
|
|
4866
|
+
0,
|
|
4867
|
+
0,
|
|
4868
|
+
10,
|
|
4869
|
+
4,
|
|
4870
|
+
1,
|
|
4871
|
+
2,
|
|
4872
|
+
0,
|
|
4873
|
+
11
|
|
4874
|
+
])), !o && !u && (s || d) && !r.moduleLoader) throw s || d;
|
|
4875
|
+
if (o) {
|
|
4876
|
+
let t = `/var/lib/wbt/wasm/${e.name}.wasm`;
|
|
4877
|
+
l(this.context.fs, t, o, "application/wasm");
|
|
4878
|
+
try {
|
|
4879
|
+
this.context.fs.setMode(t, 493);
|
|
4880
|
+
} catch {}
|
|
4881
|
+
return t;
|
|
4882
|
+
}
|
|
4883
|
+
return null;
|
|
4884
|
+
}
|
|
3774
4885
|
async _installCustomUrl(e, t, n = !1, r = null) {
|
|
3775
4886
|
if (!/\.(wasm|wat)(\?.*)?$/i.test(t) && (/^https?:\/\/esm\.sh\//i.test(t) || /\.(mjs|js)(\?.*)?$/i.test(t))) {
|
|
3776
4887
|
let i = {
|
|
@@ -3782,10 +4893,10 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
3782
4893
|
cdnUrl: t,
|
|
3783
4894
|
type: "generic-runtime",
|
|
3784
4895
|
installedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3785
|
-
};
|
|
3786
|
-
this._registerPackageIntoContext(i);
|
|
3787
|
-
let
|
|
3788
|
-
|
|
4896
|
+
}, a = await this._pullPackageWasm(i, n, !1);
|
|
4897
|
+
a && (i.wasmPath = a), this._registerPackageIntoContext(i);
|
|
4898
|
+
let o = r || this._readState();
|
|
4899
|
+
o.packages[e] = i, this._writeState(o), n || (this.stdOut = `Setting up ${e} (generic runtime) -> /bin/${e} ...`);
|
|
3789
4900
|
return;
|
|
3790
4901
|
}
|
|
3791
4902
|
let i = (this.constructor._config || {}).fetch || (typeof fetch == "function" ? fetch : null);
|
|
@@ -3845,7 +4956,7 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
3845
4956
|
}
|
|
3846
4957
|
let n = this._readState(), r = this.context.getVar("PATH") || "/bin";
|
|
3847
4958
|
for (let e of t) {
|
|
3848
|
-
let t =
|
|
4959
|
+
let t = s(e), i = n.packages[t] || n.packages[e.toLowerCase()];
|
|
3849
4960
|
if (!i) {
|
|
3850
4961
|
this.stdErr = `E: Package '${e}' is not installed, so not removed`, this.exitCode = 1;
|
|
3851
4962
|
return;
|
|
@@ -3885,13 +4996,13 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
3885
4996
|
this.stdErr = "E: No packages found — specify a package name", this.exitCode = 1;
|
|
3886
4997
|
return;
|
|
3887
4998
|
}
|
|
3888
|
-
let n =
|
|
4999
|
+
let n = s(t), r = this._getRegistry(), i = this._readState(), a = i.packages[n] || r[n];
|
|
3889
5000
|
if (!a) {
|
|
3890
5001
|
this.stdErr = `E: No packages found matching ${t}`, this.exitCode = 100;
|
|
3891
5002
|
return;
|
|
3892
5003
|
}
|
|
3893
|
-
let o = Object.assign({}, r[n] || {}, a),
|
|
3894
|
-
this.stdOut = `Package: ${o.name}`, this.stdOut = `Version: ${o.version}`, this.stdOut = `State: ${
|
|
5004
|
+
let o = Object.assign({}, r[n] || {}, a), c = !!i.packages[o.name];
|
|
5005
|
+
this.stdOut = `Package: ${o.name}`, this.stdOut = `Version: ${o.version}`, this.stdOut = `State: ${c ? "installed" : "not installed"}`, this.stdOut = `Binary: ${o.bin || o.name}`, o.aliases && o.aliases.length > 0 && (this.stdOut = `Aliases: ${o.aliases.join(", ")}`), o.size && (this.stdOut = `Download-Size: ${o.size}`), o.cdnUrl && (this.stdOut = `APT-Sources: ${o.cdnUrl}`), o.wasmUrl && (this.stdOut = `WASM-URL: ${o.wasmUrl}`), o.wasmPath && (this.stdOut = `WASM-File: ${o.wasmPath}`), o.homepage && (this.stdOut = `Homepage: ${o.homepage}`), this.stdOut = `Description: ${o.description || ""}`, o.details && (this.stdOut = ` ${o.details}`);
|
|
3895
5006
|
}
|
|
3896
5007
|
async _handleUpdate() {
|
|
3897
5008
|
let e = this.constructor._config || {}, t = e.sources || [], n = e.fetch || (typeof fetch == "function" ? fetch : null), r = {}, i = 1;
|
|
@@ -3914,7 +5025,7 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
3914
5025
|
this.stdErr = "E: Specify a package to run (e.g. wbt run sqlite3 --version)", this.exitCode = 1;
|
|
3915
5026
|
return;
|
|
3916
5027
|
}
|
|
3917
|
-
let t = e.shift(), n =
|
|
5028
|
+
let t = e.shift(), n = s(t), r = this._getRegistry(), i = this._readState().packages[n] || r[n];
|
|
3918
5029
|
if (!i && (t.startsWith("npm:") || t.startsWith("esm:"))) {
|
|
3919
5030
|
let e = t.replace(/^(npm|esm):/i, ""), n = e.replace(/^@[^/]+\//, "").split("@")[0].toLowerCase();
|
|
3920
5031
|
i = {
|
|
@@ -3929,9 +5040,9 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
3929
5040
|
this.stdErr = `E: Unable to locate package ${t}`, this.exitCode = 100;
|
|
3930
5041
|
return;
|
|
3931
5042
|
}
|
|
3932
|
-
let a = this._buildCommandsForPackage(i), o = (a.find((e) => e.bin === t.toLowerCase()) || a[0]).Cmd,
|
|
3933
|
-
|
|
3934
|
-
let l = await
|
|
5043
|
+
let a = this._buildCommandsForPackage(i), o = (a.find((e) => e.bin === t.toLowerCase()) || a[0]).Cmd, c = new o(e, this.context);
|
|
5044
|
+
c.requiresFilesystem && (c.fs = this.context.fs.sandbox()), this.stdin !== void 0 && (c.stdin = this.stdin);
|
|
5045
|
+
let l = await c.runCommand();
|
|
3935
5046
|
for (let e of l.getStdOutput()) e.type === "out" ? this.stdOut = e.string : e.type === "err" && (this.stdErr = e.string);
|
|
3936
5047
|
this.exitCode = l.getExitCode();
|
|
3937
5048
|
}
|
|
@@ -3969,6 +5080,6 @@ var L, R, z, B, V, H, U, W, ee, G, te = e((() => {
|
|
|
3969
5080
|
t.exports = h, t.exports.Wbt = h, t.exports.DEFAULT_REGISTRY = o, t.exports.createGenericWasmCommand = u, t.exports.createReplWasmCommand = d;
|
|
3970
5081
|
}));
|
|
3971
5082
|
//#endregion
|
|
3972
|
-
export default
|
|
5083
|
+
export default se();
|
|
3973
5084
|
|
|
3974
5085
|
//# sourceMappingURL=wbt.es.js.map
|