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
|
@@ -41,10 +41,38 @@ class InteractiveCommand extends Command {
|
|
|
41
41
|
* @returns {{ cols: number, rows: number }}
|
|
42
42
|
*/
|
|
43
43
|
get terminalSize() {
|
|
44
|
+
if (this.stdout && this.stdout.columns && this.stdout.rows) {
|
|
45
|
+
const cols = parseInt(this.context && this.context.getVar && this.context.getVar('COLUMNS'), 10) || this.stdout.columns || 80;
|
|
46
|
+
const rows = parseInt(this.context && this.context.getVar && this.context.getVar('LINES'), 10) || this.stdout.rows || 24;
|
|
47
|
+
return { cols, rows };
|
|
48
|
+
}
|
|
44
49
|
const cols = parseInt(this.context.getVar('COLUMNS'), 10) || 80;
|
|
45
50
|
const rows = parseInt(this.context.getVar('LINES'), 10) || 24;
|
|
46
51
|
return { cols, rows };
|
|
47
52
|
}
|
|
53
|
+
|
|
54
|
+
_enterAltScreen() {
|
|
55
|
+
if (this._inAltScreen) return;
|
|
56
|
+
this._inAltScreen = true;
|
|
57
|
+
if (this.stdinStream) this.stdinStream.setRawMode(true);
|
|
58
|
+
if (this.stdout) this.stdout.write('\x1b[?1049h\x1b[2J\x1b[H');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
_exitAltScreen() {
|
|
62
|
+
if (!this._inAltScreen) return;
|
|
63
|
+
this._inAltScreen = false;
|
|
64
|
+
if (this.stdinStream) this.stdinStream.setRawMode(false);
|
|
65
|
+
if (this.stdout) this.stdout.write('\x1b[?1049l\x1b[?25h');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
runCommand() {
|
|
69
|
+
if (this.interactive) {
|
|
70
|
+
this._enterAltScreen();
|
|
71
|
+
}
|
|
72
|
+
return super.runCommand().finally(() => {
|
|
73
|
+
this._exitAltScreen();
|
|
74
|
+
});
|
|
75
|
+
}
|
|
48
76
|
}
|
|
49
77
|
|
|
50
78
|
module.exports = InteractiveCommand;
|
package/lib/NodeFileSystem.js
CHANGED
|
@@ -140,8 +140,10 @@ class NodeFileSystem extends BaseFileSystem {
|
|
|
140
140
|
if (this._virtualFiles[abs] !== undefined) {
|
|
141
141
|
return;
|
|
142
142
|
}
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
try {
|
|
144
|
+
nodeFs.chmodSync(abs, mode);
|
|
145
|
+
this._triggerChange();
|
|
146
|
+
} catch (e) { /* ignore chmod errors on virtualized paths */ }
|
|
145
147
|
}
|
|
146
148
|
|
|
147
149
|
getSize(path) {
|
package/lib/ReplCommand.js
CHANGED
|
@@ -76,6 +76,9 @@ class ReplCommand extends InteractiveCommand {
|
|
|
76
76
|
this._dynamicReplOpts = opts;
|
|
77
77
|
this._dynamicReplBuffer = '';
|
|
78
78
|
this._dynamicReplMultiline = false;
|
|
79
|
+
if (typeof this._enterAltScreen === 'function') {
|
|
80
|
+
this._enterAltScreen();
|
|
81
|
+
}
|
|
79
82
|
return this._launchInteractiveReplLoop();
|
|
80
83
|
}
|
|
81
84
|
|
|
@@ -244,6 +247,18 @@ class ReplCommand extends InteractiveCommand {
|
|
|
244
247
|
return;
|
|
245
248
|
}
|
|
246
249
|
|
|
250
|
+
if (key === '^W') {
|
|
251
|
+
let pos = this._replCursor;
|
|
252
|
+
while (pos > 0 && this._replInput[pos - 1] === ' ') pos--;
|
|
253
|
+
while (pos > 0 && this._replInput[pos - 1] !== ' ') pos--;
|
|
254
|
+
this._replInput =
|
|
255
|
+
this._replInput.slice(0, pos) +
|
|
256
|
+
this._replInput.slice(this._replCursor);
|
|
257
|
+
this._replCursor = pos;
|
|
258
|
+
this._renderRepl();
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
|
|
247
262
|
if (key === 'Delete') {
|
|
248
263
|
if (this._replCursor < this._replInput.length) {
|
|
249
264
|
this._replInput =
|