@effect-tui/react 0.12.0 → 0.12.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-tui/react",
3
- "version": "0.12.0",
3
+ "version": "0.12.2",
4
4
  "description": "React bindings for @effect-tui/core",
5
5
  "type": "module",
6
6
  "files": [
@@ -83,7 +83,7 @@
83
83
  "prepublishOnly": "bun run typecheck && bun run build"
84
84
  },
85
85
  "dependencies": {
86
- "@effect-tui/core": "^0.12.0",
86
+ "@effect-tui/core": "^0.12.2",
87
87
  "@effect/platform": "^0.94.0",
88
88
  "@effect/platform-bun": "^0.87.0",
89
89
  "@effect/rpc": "^0.73.0",
@@ -16,6 +16,7 @@ export interface InputProcessorConfig {
16
16
  export class InputProcessor {
17
17
  private pasteActive = false
18
18
  private pasteBuffer = ""
19
+ private pendingInput = ""
19
20
 
20
21
  constructor(private config: InputProcessorConfig) {}
21
22
 
@@ -24,7 +25,8 @@ export class InputProcessor {
24
25
  * Handles bracketed paste detection, key/mouse event decoding, and dispatch.
25
26
  */
26
27
  process(data: Buffer): void {
27
- let chunk = data.toString("utf8")
28
+ let chunk = this.pendingInput + data.toString("utf8")
29
+ this.pendingInput = ""
28
30
 
29
31
  while (chunk.length > 0) {
30
32
  if (this.pasteActive) {
@@ -64,7 +66,12 @@ export class InputProcessor {
64
66
 
65
67
  private emitInput(str: string): void {
66
68
  if (!str) return
67
- const events = decodeInput(Buffer.from(str, "utf8"))
69
+ const { complete, pending } = this.splitIncompleteCsi(str)
70
+ if (pending) {
71
+ this.pendingInput = pending
72
+ }
73
+ if (!complete) return
74
+ const events = decodeInput(Buffer.from(complete, "utf8"))
68
75
 
69
76
  for (const event of events) {
70
77
  if (event.type === "mouse") {
@@ -96,4 +103,17 @@ export class InputProcessor {
96
103
  }
97
104
  }
98
105
  }
106
+
107
+ private splitIncompleteCsi(input: string): { complete: string; pending: string } {
108
+ const lastEsc = input.lastIndexOf("\x1b")
109
+ if (lastEsc < 0) return { complete: input, pending: "" }
110
+
111
+ const tail = input.slice(lastEsc)
112
+ // Only buffer if tail looks like the start of a CSI sequence (ESC[...) without a final byte.
113
+ if (tail.startsWith("\x1b[") && !/[A-Za-z~]$/.test(tail)) {
114
+ return { complete: input.slice(0, lastEsc), pending: tail }
115
+ }
116
+
117
+ return { complete: input, pending: "" }
118
+ }
99
119
  }