@volter/supercode-terminal 0.2.43 → 0.2.44

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/substrate/tmux.js +20 -17
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/supercode-terminal",
3
- "version": "0.2.43",
3
+ "version": "0.2.44",
4
4
  "type": "module",
5
5
  "description": "Optional leak-safe terminal and tmux host adapter for Volter Harness frontends",
6
6
  "exports": {
package/substrate/tmux.js CHANGED
@@ -849,29 +849,32 @@ function terminalInputRunOptions(deadlineMs) {
849
849
  throw new Error("Terminal input expired before delivery.");
850
850
  return { timeoutMs };
851
851
  }
852
+ // The escape sequences a keystream carries for named keys, as tmux names them.
853
+ const ESCAPE_SEQUENCE_KEYS = [
854
+ ["\u001b[A", "Up"],
855
+ ["\u001b[B", "Down"],
856
+ ["\u001b[C", "Right"],
857
+ ["\u001b[D", "Left"],
858
+ ["\u001b[H", "Home"],
859
+ ["\u001b[F", "End"],
860
+ ["\u001b[Z", "BTab"],
861
+ ["\u001b[3~", "DC"],
862
+ ["\u001b[5~", "PPage"],
863
+ ["\u001b[6~", "NPage"],
864
+ ];
852
865
  function tokenizeTerminalInput(data) {
853
866
  const tokens = [];
854
867
  for (let i = 0; i < data.length; i += 1) {
855
868
  const char = data[i];
856
- const next3 = data.slice(i, i + 3);
857
- if (next3 === "\u001b[A") {
858
- tokens.push({ key: "Up" });
859
- i += 2;
860
- continue;
861
- }
862
- if (next3 === "\u001b[B") {
863
- tokens.push({ key: "Down" });
864
- i += 2;
865
- continue;
866
- }
867
- if (next3 === "\u001b[C") {
868
- tokens.push({ key: "Right" });
869
- i += 2;
869
+ const sequence = ESCAPE_SEQUENCE_KEYS.find(([bytes]) => data.startsWith(bytes, i));
870
+ if (sequence) {
871
+ tokens.push({ key: sequence[1] });
872
+ i += sequence[0].length - 1;
870
873
  continue;
871
874
  }
872
- if (next3 === "\u001b[D") {
873
- tokens.push({ key: "Left" });
874
- i += 2;
875
+ // A lone ESC (no sequence after it) is the Escape key.
876
+ if (char === "\u001b") {
877
+ tokens.push({ key: "Escape" });
875
878
  continue;
876
879
  }
877
880
  if (char === "\r" || char === "\n") {