@effect-tui/react 0.11.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.
Files changed (34) hide show
  1. package/dist/src/components/ListView.js +6 -7
  2. package/dist/src/components/ListView.js.map +1 -1
  3. package/dist/src/hooks/use-scroll.d.ts +3 -0
  4. package/dist/src/hooks/use-scroll.d.ts.map +1 -1
  5. package/dist/src/hooks/use-scroll.js +113 -74
  6. package/dist/src/hooks/use-scroll.js.map +1 -1
  7. package/dist/src/hosts/flex-container.d.ts +3 -1
  8. package/dist/src/hosts/flex-container.d.ts.map +1 -1
  9. package/dist/src/hosts/flex-container.js +22 -4
  10. package/dist/src/hosts/flex-container.js.map +1 -1
  11. package/dist/src/hosts/scroll.d.ts.map +1 -1
  12. package/dist/src/hosts/scroll.js +4 -6
  13. package/dist/src/hosts/scroll.js.map +1 -1
  14. package/dist/src/hosts/text.d.ts +13 -0
  15. package/dist/src/hosts/text.d.ts.map +1 -1
  16. package/dist/src/hosts/text.js +23 -0
  17. package/dist/src/hosts/text.js.map +1 -1
  18. package/dist/src/renderer/input/InputProcessor.d.ts +2 -0
  19. package/dist/src/renderer/input/InputProcessor.d.ts.map +1 -1
  20. package/dist/src/renderer/input/InputProcessor.js +21 -2
  21. package/dist/src/renderer/input/InputProcessor.js.map +1 -1
  22. package/dist/src/utils/styles.d.ts +4 -0
  23. package/dist/src/utils/styles.d.ts.map +1 -1
  24. package/dist/src/utils/styles.js +4 -0
  25. package/dist/src/utils/styles.js.map +1 -1
  26. package/dist/tsconfig.tsbuildinfo +1 -1
  27. package/package.json +2 -2
  28. package/src/components/ListView.tsx +7 -7
  29. package/src/hooks/use-scroll.ts +132 -84
  30. package/src/hosts/flex-container.ts +33 -4
  31. package/src/hosts/scroll.ts +4 -6
  32. package/src/hosts/text.ts +32 -0
  33. package/src/renderer/input/InputProcessor.ts +22 -2
  34. package/src/utils/styles.ts +6 -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
  }
@@ -8,8 +8,10 @@ export interface StyleOptions {
8
8
  fg?: ColorValue
9
9
  bg?: ColorValue
10
10
  bold?: boolean
11
+ dimmed?: boolean
11
12
  italic?: boolean
12
13
  underline?: boolean
14
+ strikethrough?: boolean
13
15
  inverse?: boolean
14
16
  }
15
17
 
@@ -17,8 +19,10 @@ export interface StyleInput {
17
19
  fg?: Color
18
20
  bg?: Color
19
21
  bold?: boolean
22
+ dimmed?: boolean
20
23
  italic?: boolean
21
24
  underline?: boolean
25
+ strikethrough?: boolean
22
26
  inverse?: boolean
23
27
  }
24
28
 
@@ -37,8 +41,10 @@ export function styleSpecFromProps(props: StyleInput): StyleSpec | undefined {
37
41
  if (fg !== undefined) spec.fg = fg
38
42
  if (bg !== undefined) spec.bg = bg
39
43
  if (props.bold) spec.bold = true
44
+ if (props.dimmed) spec.dimmed = true
40
45
  if (props.italic) spec.italic = true
41
46
  if (props.underline) spec.underline = true
47
+ if (props.strikethrough) spec.strikethrough = true
42
48
  if (props.inverse) spec.inverse = true
43
49
 
44
50
  return Object.keys(spec).length > 0 ? spec : undefined