@orkestrel/terminal 0.0.12 → 0.0.13

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.
@@ -69,15 +69,17 @@ var SEQUENCE_NAMES = Object.freeze({
69
69
  [`${KEY_CSI}8~`]: "end"
70
70
  });
71
71
  /**
72
- * The single control BYTE → key descriptor table {@link import('./helpers.js').parseKey}
73
- * consults for the one-byte keys. Each entry carries the canonical `name` and whether it is a
74
- * `ctrl` combination. The source of truth for the single-byte key decode; frozen.
72
+ * The control BYTE (or CRLF pair) → key descriptor table {@link import('./helpers.js').parseKey}
73
+ * consults for the one-byte keys and the two-byte CRLF Enter chunk. Each entry carries the
74
+ * canonical `name` and whether it is a `ctrl` combination. The source of truth for that decode;
75
+ * frozen.
75
76
  *
76
77
  * @remarks
77
- * `return` / `newline` map to `return` (one canonical Enter name); `delete` / `backspace` both
78
- * map to `backspace` (the two Backspace bytes); the Ctrl combos (`c` / `d` / `u` / `a` / `e`)
79
- * carry `ctrl: true` so a reducer can match `key.ctrl && key.name === 'c'`. `escape` / `tab` /
80
- * `space` are plain named keys.
78
+ * `return` / `newline` / `return + newline` all map to `return` (one canonical Enter name) — a
79
+ * terminal or a paste can deliver Enter as `\r`, `\n`, or the `\r\n` pair in one chunk;
80
+ * `delete` / `backspace` both map to `backspace` (the two Backspace bytes); the Ctrl combos
81
+ * (`c` / `d` / `u` / `a` / `e`) carry `ctrl: true` so a reducer can match
82
+ * `key.ctrl && key.name === 'c'`. `escape` / `tab` / `space` are plain named keys.
81
83
  */
82
84
  var CONTROL_NAMES = Object.freeze({
83
85
  ["\r"]: Object.freeze({
@@ -88,6 +90,11 @@ var CONTROL_NAMES = Object.freeze({
88
90
  name: "return",
89
91
  ctrl: false
90
92
  }),
93
+ [`\r
94
+ `]: Object.freeze({
95
+ name: "return",
96
+ ctrl: false
97
+ }),
91
98
  [" "]: Object.freeze({
92
99
  name: "tab",
93
100
  ctrl: false
@@ -340,15 +347,15 @@ var isTerminalSnapshot = (0, _orkestrel_contract.recordOf)({
340
347
  //#region src/core/helpers.ts
341
348
  /**
342
349
  * Decode one keypress's bytes into a {@link KeyEvent} — total, never throws. A `Uint8Array` is
343
- * read as UTF-8; the resulting string is matched against the known control bytes
344
- * ({@link CONTROL_NAMES}) and escape sequences ({@link SEQUENCE_NAMES}), falling back to a
350
+ * read as UTF-8; the resulting string is matched against the known control bytes and the CRLF
351
+ * pair ({@link CONTROL_NAMES}) and escape sequences ({@link SEQUENCE_NAMES}), falling back to a
345
352
  * single printable character. An unrecognized sequence yields `name: ''` with the raw `sequence`
346
353
  * preserved.
347
354
  *
348
355
  * @remarks
349
356
  * - **Single control byte.** A one-character control input (`return` / `backspace` / `tab` /
350
- * `escape` / `space`, or a Ctrl combo `c` / `d` / `u` / `a` / `e`) is looked up in
351
- * {@link CONTROL_NAMES}, carrying its `ctrl` flag.
357
+ * `escape` / `space`, or a Ctrl combo `c` / `d` / `u` / `a` / `e`), or the two-byte `\r\n`
358
+ * CRLF pair, is looked up in {@link CONTROL_NAMES}, carrying its `ctrl` flag.
352
359
  * - **Escape sequence.** A multi-byte ESC sequence (`up` / `down` / `left` / `right` in BOTH the
353
360
  * `ESC[A` and `ESCOA` forms, plus `home` / `end` / `delete`) is looked up in
354
361
  * {@link SEQUENCE_NAMES} and flagged `meta`.
@@ -364,6 +371,7 @@ var isTerminalSnapshot = (0, _orkestrel_contract.recordOf)({
364
371
  * @example
365
372
  * ```ts
366
373
  * parseKey('\r') // { name: 'return', sequence: '\r', ctrl: false, meta: false, shift: false }
374
+ * parseKey('\r\n') // { name: 'return', sequence: '\r\n', ctrl: false, meta: false, shift: false }
367
375
  * parseKey('\x1b[A') // { name: 'up', sequence: '\x1b[A', ctrl: false, meta: true, shift: false }
368
376
  * parseKey('A') // { name: 'A', sequence: 'A', ctrl: false, meta: false, shift: true }
369
377
  * parseKey('\x03') // { name: 'c', sequence: '\x03', ctrl: true, meta: false, shift: false }