brsh 3.10.0 → 3.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/shell.es.js +704 -583
- package/dist/shell.es.js.map +1 -1
- package/dist/shell.min.js +23 -23
- package/dist/shell.min.js.map +1 -1
- package/dist/terminal.cjs.js +3 -3
- package/dist/terminal.cjs.js.map +1 -1
- package/dist/terminal.es.js +55 -33
- package/dist/terminal.es.js.map +1 -1
- package/dist/terminal.min.js +3 -3
- package/dist/terminal.min.js.map +1 -1
- package/dist/wbt.es.js +842 -662
- package/dist/wbt.es.js.map +1 -1
- package/dist/wbt.min.js +14 -14
- package/dist/wbt.min.js.map +1 -1
- package/index.js +36 -9
- package/lib/BaseFileSystem.js +2 -0
- package/lib/BinaryContainer.js +1 -1
- package/lib/Command.js +1 -1
- package/lib/Context.js +3 -2
- package/lib/InteractiveCommand.js +9 -8
- package/lib/ScriptCommand.js +57 -20
- package/lib/Terminal.js +60 -6
- package/lib/TtyStream.js +36 -2
- package/lib/WasmCommand.js +229 -42
- package/lib/wbt/index.js +172 -58
- package/package.json +1 -1
- package/test/devices-signals.test.js +112 -0
- package/test/doom.test.js +7 -4
- package/test/terminal.test.js +148 -0
- package/test/wasm-cli.test.js +76 -0
- package/test/wbt.test.js +111 -1
package/dist/terminal.es.js
CHANGED
|
@@ -1134,7 +1134,7 @@ var D = e?.default ?? e, O = class {
|
|
|
1134
1134
|
this._setupDom(this._el, n), this.renderer = new C(this._cmdList, this.screen, {
|
|
1135
1135
|
cursor: this._cursor,
|
|
1136
1136
|
urlWhitelist: p
|
|
1137
|
-
}), this._listenForEvents(), this.cli && (this.attach(this.cli), typeof this.cli.on == "function" && this.cli.on("exit", (e) => {
|
|
1137
|
+
}), this._measureAndSetSize(), this._listenForEvents(), this.cli && (this.attach(this.cli), typeof this.cli.on == "function" && this.cli.on("exit", (e) => {
|
|
1138
1138
|
delete this.cli, typeof this._exitFn == "function" && this._exitFn(e);
|
|
1139
1139
|
}), u && this.onCommand(u)), g && (this.attach(g), u && this.onCommand(u)), c === "click" && this._mobileInput(), this.renderer.flushRender();
|
|
1140
1140
|
}
|
|
@@ -1303,7 +1303,7 @@ var D = e?.default ?? e, O = class {
|
|
|
1303
1303
|
if (this.screen.isAltScreen) return !0;
|
|
1304
1304
|
if (this.cli && this.cli.runningCommand) {
|
|
1305
1305
|
let e = this.cli.runningCommand;
|
|
1306
|
-
if (e.interactive || e._inAltScreen || e.stdinStream && e.stdinStream.isRaw) return !0;
|
|
1306
|
+
if (e.interactive || e._inAltScreen || e.isRaw || e.stdinStream && e.stdinStream.isRaw) return !0;
|
|
1307
1307
|
}
|
|
1308
1308
|
return !!(this._attachedStream && this._attachedStream.isRaw || /\x1b\[\?(?:1049|1047|47)[hl]/.test(e) || /\x1b\[(?:\d*J|(?:\d+;\d+)?[Hf]|\d*[ABLM]|\d*;\d*r)/.test(e));
|
|
1309
1309
|
}
|
|
@@ -1317,25 +1317,39 @@ var D = e?.default ?? e, O = class {
|
|
|
1317
1317
|
"Alt",
|
|
1318
1318
|
"Shift",
|
|
1319
1319
|
"Meta",
|
|
1320
|
-
"CapsLock"
|
|
1320
|
+
"CapsLock",
|
|
1321
|
+
"NumLock",
|
|
1322
|
+
"ScrollLock",
|
|
1323
|
+
"Dead",
|
|
1324
|
+
"Unidentified"
|
|
1321
1325
|
].includes(e) || a) return null;
|
|
1322
|
-
let o =
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
if (
|
|
1334
|
-
if (
|
|
1335
|
-
if (
|
|
1336
|
-
if (
|
|
1337
|
-
|
|
1338
|
-
if (
|
|
1326
|
+
let o = {
|
|
1327
|
+
Up: "ArrowUp",
|
|
1328
|
+
Down: "ArrowDown",
|
|
1329
|
+
Right: "ArrowRight",
|
|
1330
|
+
Left: "ArrowLeft",
|
|
1331
|
+
Esc: "Escape",
|
|
1332
|
+
Return: "Enter",
|
|
1333
|
+
Del: "Delete",
|
|
1334
|
+
Space: " ",
|
|
1335
|
+
Spacebar: " "
|
|
1336
|
+
}[e] || e, s = this.parser.applicationCursorKeys;
|
|
1337
|
+
if (o === "ArrowUp") return n ? "\x1B[1;3A" : r ? "\x1B[1;5A" : s ? "\x1BOA" : "\x1B[A";
|
|
1338
|
+
if (o === "ArrowDown") return n ? "\x1B[1;3B" : r ? "\x1B[1;5B" : s ? "\x1BOB" : "\x1B[B";
|
|
1339
|
+
if (o === "ArrowRight") return n ? "\x1B[1;3C" : r ? "\x1B[1;5C" : s ? "\x1BOC" : "\x1B[C";
|
|
1340
|
+
if (o === "ArrowLeft") return n ? "\x1B[1;3D" : r ? "\x1B[1;5D" : s ? "\x1BOD" : "\x1B[D";
|
|
1341
|
+
if (o === "Home") return s ? "\x1BOH" : "\x1B[H";
|
|
1342
|
+
if (o === "End") return s ? "\x1BOF" : "\x1B[F";
|
|
1343
|
+
if (o === "Delete") return "\x1B[3~";
|
|
1344
|
+
if (o === "Insert") return "\x1B[2~";
|
|
1345
|
+
if (o === "PageUp") return "\x1B[5~";
|
|
1346
|
+
if (o === "PageDown") return "\x1B[6~";
|
|
1347
|
+
if (o === "Enter") return "\r";
|
|
1348
|
+
if (o === "Backspace") return n ? "\x1B" : "";
|
|
1349
|
+
if (o === "Tab") return i ? "\x1B[Z" : " ";
|
|
1350
|
+
if (o === "Escape") return "\x1B";
|
|
1351
|
+
let c = o.match(/^F(\d{1,2})$/);
|
|
1352
|
+
if (c) return {
|
|
1339
1353
|
1: "\x1BOP",
|
|
1340
1354
|
2: "\x1BOQ",
|
|
1341
1355
|
3: "\x1BOR",
|
|
@@ -1348,15 +1362,15 @@ var D = e?.default ?? e, O = class {
|
|
|
1348
1362
|
10: "\x1B[21~",
|
|
1349
1363
|
11: "\x1B[23~",
|
|
1350
1364
|
12: "\x1B[24~"
|
|
1351
|
-
}[Number(
|
|
1352
|
-
if (r &&
|
|
1353
|
-
let
|
|
1354
|
-
if (
|
|
1355
|
-
let
|
|
1356
|
-
return n ? "\x1B" +
|
|
1365
|
+
}[Number(c[1])] || null;
|
|
1366
|
+
if (r && o.length === 1) {
|
|
1367
|
+
let e = o.toUpperCase().charCodeAt(0);
|
|
1368
|
+
if (e >= 64 && e <= 95) {
|
|
1369
|
+
let t = String.fromCharCode(e - 64);
|
|
1370
|
+
return n ? "\x1B" + t : t;
|
|
1357
1371
|
}
|
|
1358
1372
|
}
|
|
1359
|
-
return
|
|
1373
|
+
return o.length === 1 ? n ? "\x1B" + o : o : null;
|
|
1360
1374
|
}
|
|
1361
1375
|
_enqueueTypeAnimation(e) {
|
|
1362
1376
|
this._typeQueue += e, this._typeTimer === null && (this._typeTimer = setInterval(() => {
|
|
@@ -1393,11 +1407,11 @@ var D = e?.default ?? e, O = class {
|
|
|
1393
1407
|
_setupDom(e, t = "Roboto Mono") {
|
|
1394
1408
|
if (typeof document > "u") return;
|
|
1395
1409
|
let n = document.createElement("link");
|
|
1396
|
-
n.href = `https://fonts.googleapis.com/css?family=${encodeURIComponent(t)}:ital,wght@0,400;0,700;1,400;1,700&display=swap`, n.rel = "stylesheet", document.head && document.head.appendChild && document.head.appendChild(n), this._cmdList = document.createElement("ul"), this._cmdList.style.fontFamily = `'${t}', monospace`, this._cmdList.style.listStyle = "none", this._cmdList.style.padding = "0", this._cmdList.style.margin = "0", this._lineWrap && this._cmdList.classList.add("terminal--wrap"), e.appendChild(this._cmdList), this._charMeasure = document.createElement("span"), this._charMeasure.className = "terminal__char-measure", this._charMeasure.style.fontFamily = `'${t}', monospace`, this._charMeasure.textContent = "X", this._charMeasure.setAttribute("aria-hidden", "true"), e.appendChild(this._charMeasure), setTimeout(() => this._measureAndSetSize(), 0), document.fonts && document.fonts.ready && document.fonts.ready.then(() => this._measureAndSetSize()), typeof ResizeObserver < "u" && new ResizeObserver(() => this._measureAndSetSize()).observe(e);
|
|
1410
|
+
n.href = `https://fonts.googleapis.com/css?family=${encodeURIComponent(t)}:ital,wght@0,400;0,700;1,400;1,700&display=swap`, n.rel = "stylesheet", document.head && document.head.appendChild && document.head.appendChild(n), this._cmdList = document.createElement("ul"), this._cmdList.style.fontFamily = `'${t}', monospace`, this._cmdList.style.listStyle = "none", this._cmdList.style.padding = "0", this._cmdList.style.margin = "0", this._cmdList.style.lineHeight = "1.15em", this._lineWrap && this._cmdList.classList.add("terminal--wrap"), e.appendChild(this._cmdList), this._charMeasure = document.createElement("span"), this._charMeasure.className = "terminal__char-measure", this._charMeasure.style.fontFamily = `'${t}', monospace`, this._charMeasure.style.position = "absolute", this._charMeasure.style.top = "0", this._charMeasure.style.left = "0", this._charMeasure.style.visibility = "hidden", this._charMeasure.style.pointerEvents = "none", this._charMeasure.style.whiteSpace = "pre", this._charMeasure.style.lineHeight = "1.15em", this._charMeasure.textContent = "X", this._charMeasure.setAttribute("aria-hidden", "true"), e.appendChild(this._charMeasure), setTimeout(() => this._measureAndSetSize(), 0), document.fonts && document.fonts.ready && document.fonts.ready.then(() => this._measureAndSetSize()), typeof ResizeObserver < "u" && (this._resizeObserver = new ResizeObserver(() => this._measureAndSetSize()), this._resizeObserver.observe(e));
|
|
1397
1411
|
}
|
|
1398
1412
|
_listenForEvents() {
|
|
1399
|
-
if (!(typeof window > "u") && (this._onKeyDown = (e) => {
|
|
1400
|
-
if (e.metaKey) return;
|
|
1413
|
+
if (!(typeof window > "u") && (this._onWindowResize = () => this._measureAndSetSize(), window.addEventListener("resize", this._onWindowResize), this._onKeyDown = (e) => {
|
|
1414
|
+
if (!e || e.defaultPrevented || e.isComposing || e.keyCode === 229 || e.metaKey) return;
|
|
1401
1415
|
let t = this._encodeKey(e.key, {
|
|
1402
1416
|
alt: !!e.altKey,
|
|
1403
1417
|
ctrl: !!e.ctrlKey,
|
|
@@ -1541,11 +1555,19 @@ var D = e?.default ?? e, O = class {
|
|
|
1541
1555
|
if (!this._charMeasure || !this._el || typeof this._el.getBoundingClientRect != "function") return;
|
|
1542
1556
|
let e = this._charMeasure.getBoundingClientRect(), t = this._el.getBoundingClientRect();
|
|
1543
1557
|
if (!e || !t || !e.width || !e.height || !t.width || e.width >= t.width && e.height >= t.height) return;
|
|
1544
|
-
let n =
|
|
1545
|
-
(
|
|
1558
|
+
let n = typeof this._el.clientWidth == "number" && this._el.clientWidth > 0 ? this._el.clientWidth : t.width, r = typeof this._el.clientHeight == "number" && this._el.clientHeight > 0 ? this._el.clientHeight : t.height || e.height * 24;
|
|
1559
|
+
if (typeof window < "u" && typeof window.getComputedStyle == "function") try {
|
|
1560
|
+
let e = window.getComputedStyle(this._el);
|
|
1561
|
+
if (e) {
|
|
1562
|
+
let t = (parseFloat(e.paddingLeft) || 0) + (parseFloat(e.paddingRight) || 0), i = (parseFloat(e.paddingTop) || 0) + (parseFloat(e.paddingBottom) || 0);
|
|
1563
|
+
n > t && (n -= t), r > i && (r -= i);
|
|
1564
|
+
}
|
|
1565
|
+
} catch {}
|
|
1566
|
+
let i = Math.max(1, Math.floor(n / e.width)), a = Math.max(1, Math.floor(r / e.height));
|
|
1567
|
+
(i !== this._lastCols || a !== this._lastRows) && this.resize(i, a);
|
|
1546
1568
|
}
|
|
1547
1569
|
destroy() {
|
|
1548
|
-
this._typeTimer !== null && (clearInterval(this._typeTimer), this._typeTimer = null), typeof window < "u" && window.removeEventListener && (this._onKeyDown && window.removeEventListener("keydown", this._onKeyDown), this._onPaste && window.removeEventListener("paste", this._onPaste)), this._mobileInputElement &&= (this._onMobileInputClick && this._el && typeof this._el.removeEventListener == "function" && this._el.removeEventListener("click", this._onMobileInputClick), this._mobileInputElement.parentNode ? this._mobileInputElement.parentNode.removeChild(this._mobileInputElement) : typeof this._mobileInputElement.remove == "function" && this._mobileInputElement.remove(), null), this._dataListeners = [], this._resizeListeners = [], this._titleListeners = [];
|
|
1570
|
+
this._typeTimer !== null && (clearInterval(this._typeTimer), this._typeTimer = null), this._resizeObserver && typeof this._resizeObserver.disconnect == "function" && (this._resizeObserver.disconnect(), this._resizeObserver = null), typeof window < "u" && window.removeEventListener && (this._onWindowResize && window.removeEventListener("resize", this._onWindowResize), this._onKeyDown && window.removeEventListener("keydown", this._onKeyDown), this._onPaste && window.removeEventListener("paste", this._onPaste)), this._mobileInputElement &&= (this._onMobileInputClick && this._el && typeof this._el.removeEventListener == "function" && this._el.removeEventListener("click", this._onMobileInputClick), this._mobileInputElement.parentNode ? this._mobileInputElement.parentNode.removeChild(this._mobileInputElement) : typeof this._mobileInputElement.remove == "function" && this._mobileInputElement.remove(), null), this._dataListeners = [], this._resizeListeners = [], this._titleListeners = [];
|
|
1549
1571
|
}
|
|
1550
1572
|
};
|
|
1551
1573
|
k.Terminal = k, k.spawnPty = E, typeof globalThis < "u" && (globalThis.Terminal = k);
|