@opentui/core 0.1.25 → 0.1.27

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 (55) hide show
  1. package/3d.js +140 -140
  2. package/3d.js.map +2 -2
  3. package/README.md +5 -1
  4. package/Renderable.d.ts +8 -7
  5. package/animation/Timeline.d.ts +2 -1
  6. package/assets/javascript/highlights.scm +205 -0
  7. package/assets/javascript/tree-sitter-javascript.wasm +0 -0
  8. package/assets/typescript/highlights.scm +604 -0
  9. package/assets/typescript/tree-sitter-typescript.wasm +0 -0
  10. package/{index-6kvgbzah.js → index-zx1dwm33.js} +1498 -133
  11. package/index-zx1dwm33.js.map +52 -0
  12. package/index.js +2371 -2179
  13. package/index.js.map +16 -14
  14. package/lib/KeyHandler.d.ts +54 -12
  15. package/lib/data-paths.d.ts +26 -0
  16. package/lib/debounce.d.ts +42 -0
  17. package/lib/env.d.ts +2 -1
  18. package/lib/hast-styled-text.d.ts +3 -23
  19. package/lib/index.d.ts +5 -0
  20. package/lib/parse.keypress.d.ts +2 -2
  21. package/lib/queue.d.ts +15 -0
  22. package/lib/scroll-acceleration.d.ts +43 -0
  23. package/lib/singleton.d.ts +2 -0
  24. package/lib/styled-text.d.ts +0 -15
  25. package/lib/syntax-style.d.ts +36 -0
  26. package/lib/tree-sitter/assets/update.d.ts +11 -0
  27. package/lib/tree-sitter/client.d.ts +46 -0
  28. package/lib/tree-sitter/default-parsers.d.ts +2 -0
  29. package/lib/tree-sitter/download-utils.d.ts +21 -0
  30. package/lib/tree-sitter/index.d.ts +10 -0
  31. package/lib/tree-sitter/parser.worker.d.ts +1 -0
  32. package/lib/tree-sitter/resolve-ft.d.ts +2 -0
  33. package/lib/tree-sitter/types.d.ts +64 -0
  34. package/lib/tree-sitter-styled-text.d.ts +7 -0
  35. package/lib/validate-dir-name.d.ts +1 -0
  36. package/package.json +22 -8
  37. package/parser.worker.js +640 -0
  38. package/parser.worker.js.map +11 -0
  39. package/renderables/Code.d.ts +31 -0
  40. package/renderables/Input.d.ts +2 -2
  41. package/renderables/ScrollBar.d.ts +2 -2
  42. package/renderables/ScrollBox.d.ts +9 -3
  43. package/renderables/Select.d.ts +2 -2
  44. package/renderables/TabSelect.d.ts +2 -2
  45. package/renderables/Text.d.ts +10 -67
  46. package/renderables/TextBufferRenderable.d.ts +81 -0
  47. package/renderables/TextNode.d.ts +3 -1
  48. package/renderables/index.d.ts +11 -8
  49. package/renderer.d.ts +18 -3
  50. package/testing/spy.d.ts +7 -0
  51. package/testing.d.ts +1 -0
  52. package/testing.js +17 -2
  53. package/testing.js.map +5 -4
  54. package/types.d.ts +2 -1
  55. package/index-6kvgbzah.js.map +0 -39
package/README.md CHANGED
@@ -3,7 +3,11 @@
3
3
  OpenTUI Core is a TypeScript library for building terminal user interfaces (TUIs). It is currently in
4
4
  development and is not ready for production use.
5
5
 
6
- [Getting Started](docs/getting-started.md)
6
+ ## Documentation
7
+
8
+ - [Getting Started](docs/getting-started.md)
9
+ - [Tree-Sitter](docs/tree-sitter.md)
10
+ - [Environment Variables](docs/env-vars.md)
7
11
 
8
12
  ## Install
9
13
 
package/Renderable.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { EventEmitter } from "events";
2
2
  import { type Node as YogaNode } from "yoga-layout";
3
3
  import { OptimizedBuffer } from "./buffer";
4
- import type { ParsedKey } from "./lib/parse.keypress";
4
+ import type { KeyEvent, PasteEvent } from "./lib/KeyHandler";
5
5
  import type { Selection } from "./lib/selection";
6
6
  import { type AlignString, type FlexDirectionString, type JustifyString, type OverflowString, type PositionTypeString, type WrapString } from "./lib/yoga.options";
7
7
  import { type VNode } from "./renderables/composition/vnode";
@@ -78,7 +78,7 @@ export interface RenderableOptions<T extends BaseRenderable = BaseRenderable> ex
78
78
  onMouseOut?: (this: T, event: MouseEvent) => void;
79
79
  onMouseScroll?: (this: T, event: MouseEvent) => void;
80
80
  onPaste?: (this: T, text: string) => void;
81
- onKeyDown?: (key: ParsedKey) => void;
81
+ onKeyDown?: (key: KeyEvent) => void;
82
82
  onSizeChange?: (this: T) => void;
83
83
  }
84
84
  export declare function isRenderable(obj: any): obj is Renderable;
@@ -98,6 +98,7 @@ export declare abstract class BaseRenderable extends EventEmitter {
98
98
  abstract getChildrenCount(): number;
99
99
  abstract getRenderable(id: string): BaseRenderable | undefined;
100
100
  abstract requestRender(): void;
101
+ abstract findDescendantById(id: string): BaseRenderable | undefined;
101
102
  get id(): string;
102
103
  set id(value: string);
103
104
  get isDirty(): boolean;
@@ -126,8 +127,8 @@ export declare abstract class Renderable extends BaseRenderable {
126
127
  protected frameBuffer: OptimizedBuffer | null;
127
128
  protected _focusable: boolean;
128
129
  protected _focused: boolean;
129
- protected keypressHandler: ((key: ParsedKey) => void) | null;
130
- protected pasteHandler: ((text: string) => void) | null;
130
+ protected keypressHandler: ((key: KeyEvent) => void) | null;
131
+ protected pasteHandler: ((event: PasteEvent) => void) | null;
131
132
  private _live;
132
133
  protected _liveCount: number;
133
134
  private _sizeChangeListener;
@@ -169,7 +170,7 @@ export declare abstract class Renderable extends BaseRenderable {
169
170
  get liveCount(): number;
170
171
  set live(value: boolean);
171
172
  protected propagateLiveCount(delta: number): void;
172
- handleKeyPress?(key: ParsedKey | string): boolean;
173
+ handleKeyPress?(key: KeyEvent | string): boolean;
173
174
  handlePaste?(text: string): void;
174
175
  findDescendantById(id: string): Renderable | undefined;
175
176
  requestRender(): void;
@@ -276,8 +277,8 @@ export declare abstract class Renderable extends BaseRenderable {
276
277
  set onMouseScroll(handler: ((event: MouseEvent) => void) | undefined);
277
278
  set onPaste(handler: ((text: string) => void) | undefined);
278
279
  get onPaste(): ((text: string) => void) | undefined;
279
- set onKeyDown(handler: ((key: ParsedKey) => void) | undefined);
280
- get onKeyDown(): ((key: ParsedKey) => void) | undefined;
280
+ set onKeyDown(handler: ((key: KeyEvent) => void) | undefined);
281
+ get onKeyDown(): ((key: KeyEvent) => void) | undefined;
281
282
  set onSizeChange(handler: (() => void) | undefined);
282
283
  get onSizeChange(): (() => void) | undefined;
283
284
  private applyEventOptions;
@@ -1,3 +1,4 @@
1
+ import type { CliRenderer } from "../renderer";
1
2
  export interface TimelineOptions {
2
3
  duration?: number;
3
4
  loop?: boolean;
@@ -111,7 +112,7 @@ declare class TimelineEngine {
111
112
  defaults: {
112
113
  frameRate: number;
113
114
  };
114
- attach(renderer: any): void;
115
+ attach(renderer: CliRenderer): void;
115
116
  detach(): void;
116
117
  private updateLiveState;
117
118
  private onTimelineStateChange;
@@ -0,0 +1,205 @@
1
+ ; Query from: https://raw.githubusercontent.com/tree-sitter/tree-sitter-javascript/refs/heads/master/queries/highlights.scm
2
+ ; Variables
3
+ ;----------
4
+
5
+ (identifier) @variable
6
+
7
+ ; Properties
8
+ ;-----------
9
+
10
+ (property_identifier) @property
11
+
12
+ ; Function and method definitions
13
+ ;--------------------------------
14
+
15
+ (function_expression
16
+ name: (identifier) @function)
17
+ (function_declaration
18
+ name: (identifier) @function)
19
+ (method_definition
20
+ name: (property_identifier) @function.method)
21
+
22
+ (pair
23
+ key: (property_identifier) @function.method
24
+ value: [(function_expression) (arrow_function)])
25
+
26
+ (assignment_expression
27
+ left: (member_expression
28
+ property: (property_identifier) @function.method)
29
+ right: [(function_expression) (arrow_function)])
30
+
31
+ (variable_declarator
32
+ name: (identifier) @function
33
+ value: [(function_expression) (arrow_function)])
34
+
35
+ (assignment_expression
36
+ left: (identifier) @function
37
+ right: [(function_expression) (arrow_function)])
38
+
39
+ ; Function and method calls
40
+ ;--------------------------
41
+
42
+ (call_expression
43
+ function: (identifier) @function)
44
+
45
+ (call_expression
46
+ function: (member_expression
47
+ property: (property_identifier) @function.method))
48
+
49
+ ; Special identifiers
50
+ ;--------------------
51
+
52
+ ((identifier) @constructor
53
+ (#match? @constructor "^[A-Z]"))
54
+
55
+ ([
56
+ (identifier)
57
+ (shorthand_property_identifier)
58
+ (shorthand_property_identifier_pattern)
59
+ ] @constant
60
+ (#match? @constant "^[A-Z_][A-Z\\d_]+$"))
61
+
62
+ ((identifier) @variable.builtin
63
+ (#match? @variable.builtin "^(arguments|module|console|window|document)$")
64
+ (#is-not? local))
65
+
66
+ ((identifier) @function.builtin
67
+ (#eq? @function.builtin "require")
68
+ (#is-not? local))
69
+
70
+ ; Literals
71
+ ;---------
72
+
73
+ (this) @variable.builtin
74
+ (super) @variable.builtin
75
+
76
+ [
77
+ (true)
78
+ (false)
79
+ (null)
80
+ (undefined)
81
+ ] @constant.builtin
82
+
83
+ (comment) @comment
84
+
85
+ [
86
+ (string)
87
+ (template_string)
88
+ ] @string
89
+
90
+ (regex) @string.special
91
+ (number) @number
92
+
93
+ ; Tokens
94
+ ;-------
95
+
96
+ [
97
+ ";"
98
+ (optional_chain)
99
+ "."
100
+ ","
101
+ ] @punctuation.delimiter
102
+
103
+ [
104
+ "-"
105
+ "--"
106
+ "-="
107
+ "+"
108
+ "++"
109
+ "+="
110
+ "*"
111
+ "*="
112
+ "**"
113
+ "**="
114
+ "/"
115
+ "/="
116
+ "%"
117
+ "%="
118
+ "<"
119
+ "<="
120
+ "<<"
121
+ "<<="
122
+ "="
123
+ "=="
124
+ "==="
125
+ "!"
126
+ "!="
127
+ "!=="
128
+ "=>"
129
+ ">"
130
+ ">="
131
+ ">>"
132
+ ">>="
133
+ ">>>"
134
+ ">>>="
135
+ "~"
136
+ "^"
137
+ "&"
138
+ "|"
139
+ "^="
140
+ "&="
141
+ "|="
142
+ "&&"
143
+ "||"
144
+ "??"
145
+ "&&="
146
+ "||="
147
+ "??="
148
+ ] @operator
149
+
150
+ [
151
+ "("
152
+ ")"
153
+ "["
154
+ "]"
155
+ "{"
156
+ "}"
157
+ ] @punctuation.bracket
158
+
159
+ (template_substitution
160
+ "${" @punctuation.special
161
+ "}" @punctuation.special) @embedded
162
+
163
+ [
164
+ "as"
165
+ "async"
166
+ "await"
167
+ "break"
168
+ "case"
169
+ "catch"
170
+ "class"
171
+ "const"
172
+ "continue"
173
+ "debugger"
174
+ "default"
175
+ "delete"
176
+ "do"
177
+ "else"
178
+ "export"
179
+ "extends"
180
+ "finally"
181
+ "for"
182
+ "from"
183
+ "function"
184
+ "get"
185
+ "if"
186
+ "import"
187
+ "in"
188
+ "instanceof"
189
+ "let"
190
+ "new"
191
+ "of"
192
+ "return"
193
+ "set"
194
+ "static"
195
+ "switch"
196
+ "target"
197
+ "throw"
198
+ "try"
199
+ "typeof"
200
+ "var"
201
+ "void"
202
+ "while"
203
+ "with"
204
+ "yield"
205
+ ] @keyword