@bettertui/core 0.1.0

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/index.d.ts ADDED
@@ -0,0 +1,461 @@
1
+ /* auto-generated by NAPI-RS */
2
+ /* eslint-disable */
3
+ export declare class NativeEngine {
4
+ constructor(width: number, height: number)
5
+ processCommands(commandsJson: string): string
6
+ beginFrame(): void
7
+ commitFrame(): void
8
+ render(): string
9
+ renderFull(): string
10
+ setScreenMode(mode: string, footerHeight?: number | undefined | null): void
11
+ resize(width: number, height: number): void
12
+ nodeCount(): number
13
+ frameCount(): number
14
+ printTree(): string
15
+ validate(): boolean
16
+ shutdown(): void
17
+ setBackgroundColor(color: string): void
18
+ setStyle(id: number, styleJson: string): void
19
+ setLayout(id: number, layoutJson: string): void
20
+ getNode(id: number): string
21
+ treeSummary(): string
22
+ root(): number
23
+ createNode(kind: string): number
24
+ appendChild(parent: number, child: number): boolean
25
+ /**
26
+ * Inserts `child` immediately before `before` in the tree.
27
+ * The parent is inferred from `before`'s current parent — this is the fast
28
+ * path used by the React reconciler to avoid the JSON command round-trip.
29
+ */
30
+ insertBefore(before: number, child: number): boolean
31
+ removeNode(id: number): void
32
+ setText(id: number, text: string): void
33
+ /**
34
+ * Set the scroll offset on a node.
35
+ *
36
+ * The offset is applied during render-tree building: all children of the
37
+ * node are shifted by `(-scroll_x, -scroll_y)` in screen coordinates.
38
+ * Combine with `overflow: "hidden"` on the same node to achieve clipping.
39
+ */
40
+ setScrollOffset(id: number, scrollX: number, scrollY: number): void
41
+ hitGridCheck(x: number, y: number): number
42
+ hitGridIsDirty(): boolean
43
+ hitGridClearCurrent(): void
44
+ hitGridPushScissor(x: number, y: number, width: number, height: number): void
45
+ hitGridPopScissor(): void
46
+ hitGridAddCurrentClipped(x: number, y: number, width: number, height: number, id: number): void
47
+ hitGridDump(): string
48
+ }
49
+
50
+ export declare class NativeEventBus {
51
+ constructor()
52
+ pushKey(key: string, ctrl: boolean, shift: boolean, alt: boolean): void
53
+ pushMouse(button: string, x: number, y: number): void
54
+ pushMouseMotion(x: number, y: number): void
55
+ pushPaste(text: string): void
56
+ pushResize(width: number, height: number, prevWidth: number, prevHeight: number): void
57
+ drain(): string
58
+ len(): number
59
+ isEmpty(): boolean
60
+ clear(): void
61
+ }
62
+
63
+ export declare class NativeEventPipeline {
64
+ constructor(config?: NativeEventPipelineConfig | undefined | null)
65
+ feed(data: Buffer): void
66
+ pushKey(key: string, ctrl: boolean, shift: boolean, alt: boolean): void
67
+ pushMouse(button: string, x: number, y: number): void
68
+ pushPaste(text: string): void
69
+ pushResize(width: number, height: number, prevWidth: number, prevHeight: number): void
70
+ drain(): string
71
+ len(): number
72
+ isEmpty(): boolean
73
+ clear(): void
74
+ resize(width: number, height: number): void
75
+ reset(): void
76
+ }
77
+
78
+ export declare class NativeFocusManager {
79
+ constructor()
80
+ focus(id: number): boolean
81
+ blur(id: number): boolean
82
+ blurCurrent(): boolean
83
+ focused(): number
84
+ isFocused(id: number): boolean
85
+ traverse(direction: string): string
86
+ focusOrder(): Array<number>
87
+ clear(): void
88
+ }
89
+
90
+ export declare class NativeHitGrid {
91
+ constructor(width: number, height: number)
92
+ resize(width: number, height: number): void
93
+ add(x: number, y: number, width: number, height: number, id: number): void
94
+ check(x: number, y: number): number
95
+ clearNext(): void
96
+ clearCurrent(): void
97
+ swap(): boolean
98
+ isDirty(): boolean
99
+ dimensions(): string
100
+ pushScissor(x: number, y: number, width: number, height: number): void
101
+ popScissor(): void
102
+ clearScissors(): void
103
+ }
104
+
105
+ export declare class NativeKeymap {
106
+ constructor()
107
+ addBinding(layer: string, id: string, keys: string, command: string, description: string | undefined | null, priority: number): boolean
108
+ handleKey(key: string): string
109
+ hasPending(): boolean
110
+ clearPending(): void
111
+ setMode(mode: string): void
112
+ currentMode(): string
113
+ clearMode(): void
114
+ removeLayer(name: string): boolean
115
+ setChordTimeout(ms: number): void
116
+ chordTimeout(): number
117
+ pendingKeys(): Array<string>
118
+ activeBindings(): string
119
+ allBindings(): string
120
+ commandHistory(): Array<string>
121
+ clearHistory(): void
122
+ parseKey(keyStr: string): string
123
+ parseSequence(keyStr: string): Array<string>
124
+ }
125
+
126
+ /**
127
+ * napi wrapper exposing the plugin [`PluginHost`] and named string-valued
128
+ * [`SlotRegistry`]s to TypeScript. Slot values are strings (typically a node id or
129
+ * a serialized descriptor); the TS side owns their meaning.
130
+ */
131
+ export declare class NativePluginHost {
132
+ constructor()
133
+ /**
134
+ * Registers a plugin. `capabilities` is a list of capability names. Returns
135
+ * an error string on duplicate registration, else `None`.
136
+ */
137
+ register(name: string, version: string, author: string, capabilities: Array<string>): string | null
138
+ /** Unregisters a plugin and removes any slot contributions it made. */
139
+ unregister(name: string): string | null
140
+ /** Lifecycle hook: `Registered`/`Stopped` → `Initialized`. */
141
+ initialize(name: string): string | null
142
+ /** Lifecycle hook: `Initialized`/`Stopped` → `Running`. */
143
+ start(name: string): string | null
144
+ /** Lifecycle hook: `Running` → `Stopped`. */
145
+ stop(name: string): string | null
146
+ /** Lifecycle hook: mark a plugin as errored. */
147
+ markError(name: string): string | null
148
+ /** Current lifecycle state of a plugin, or `None` if unregistered. */
149
+ state(name: string): string | null
150
+ /** Names of all registered plugins. */
151
+ pluginNames(): Array<string>
152
+ /**
153
+ * Ensures a named slot exists with the given resolution mode. No-op if the
154
+ * slot already exists (mode is not changed).
155
+ */
156
+ ensureSlot(slot: string, mode: string): void
157
+ /** Registers a contribution to `slot` and returns its token (0 on failure). */
158
+ slotRegister(slot: string, pluginId: string, priority: number, value: string): number
159
+ /** Removes a slot contribution by token. Returns `true` if one was removed. */
160
+ slotRemove(slot: string, token: number): boolean
161
+ /** Resolves a slot to its effective contributions per its mode. */
162
+ slotResolve(slot: string): Array<string>
163
+ /** Returns and clears a slot's dirty flag (for coalesced recomputation). */
164
+ slotTakeDirty(slot: string): boolean
165
+ }
166
+
167
+ export declare class NativeScheduler {
168
+ constructor(fps?: number | undefined | null)
169
+ requestFrame(): void
170
+ beginFrame(): boolean
171
+ endFrame(): void
172
+ isIdle(): boolean
173
+ frameCount(): number
174
+ fps(): number
175
+ shouldRender(): boolean
176
+ requestRenderCoalesced(): void
177
+ requestRenderImmediate(): void
178
+ hasScheduledFrame(): boolean
179
+ isRendering(): boolean
180
+ beginRender(): void
181
+ endRender(): boolean
182
+ }
183
+
184
+ export declare class NativeSpanFeed {
185
+ constructor(options?: NativeSpanFeedOptions | undefined | null)
186
+ write(data: Buffer): number
187
+ drainSpans(out: Buffer): number
188
+ close(): void
189
+ reset(): void
190
+ pendingSpans(): number
191
+ pendingBytes(): number
192
+ isClosed(): boolean
193
+ isBackpressured(): boolean
194
+ stats(): NativeSpanFeedStats
195
+ markConsumed(chunkIndex: number): void
196
+ }
197
+
198
+ export declare class NativeTextEngine {
199
+ constructor(text?: string | undefined | null)
200
+ insertChar(ch: string): void
201
+ insertStr(text: string): void
202
+ deleteChar(): void
203
+ getText(): string
204
+ clear(): void
205
+ canUndo(): boolean
206
+ canRedo(): boolean
207
+ undo(): boolean
208
+ redo(): boolean
209
+ cursorLeft(): void
210
+ cursorRight(): void
211
+ cursorPosition(): number
212
+ setCursorPosition(pos: number): void
213
+ length(): number
214
+ lineCount(): number
215
+ isEmpty(): boolean
216
+ wordCount(): number
217
+ }
218
+
219
+ /**
220
+ * napi wrapper exposing the Rust animation [`Timeline`] to TypeScript.
221
+ * Schedule scalar tweens at offsets, drive the timeline each frame with `update(dt)`, and read each
222
+ * tween's interpolated value with `animationValue(index)`.
223
+ */
224
+ export declare class NativeTimeline {
225
+ constructor(duration?: number | undefined | null, looping?: boolean | undefined | null)
226
+ /**
227
+ * Schedule a scalar tween (`from`→`to` over `duration` seconds, with the
228
+ * named easing) to begin at `start_time`. Returns the animation index used
229
+ * by [`animation_value`](Self::animation_value).
230
+ */
231
+ addTween(from: number, to: number, duration: number, startTime: number, easing?: string | undefined | null): number
232
+ play(): void
233
+ pause(): void
234
+ restart(): void
235
+ /** Advance the timeline by `dt` seconds (typically the frame delta). */
236
+ update(dt: number): void
237
+ /** Current interpolated value of the tween scheduled at `index`. */
238
+ animationValue(index: number): number | null
239
+ currentTime(): number
240
+ isComplete(): boolean
241
+ isPlaying(): boolean
242
+ setSpeed(speed: number): void
243
+ /** Progress 0.0–1.0 if the timeline has a duration, else `None`. */
244
+ progress(): number | null
245
+ }
246
+
247
+ /**
248
+ * Decodes a base64 OSC 52 clipboard payload into UTF-8 text. Returns `null`
249
+ * for the `?` query marker or invalid base64/UTF-8.
250
+ */
251
+ export declare function clipboardDecode(payload: string): string | null
252
+
253
+ /**
254
+ * Builds the OSC 52 *query* sequence asking the terminal to report the current
255
+ * clipboard contents. The response returns as an inbound OSC 52 that
256
+ * [`clipboard_decode`] can decode.
257
+ */
258
+ export declare function clipboardQuerySequence(selection: string): Array<number>
259
+
260
+ /**
261
+ * Builds the OSC 52 escape sequence that sets the terminal clipboard to `text`.
262
+ *
263
+ * `selection` is one of `clipboard`/`primary`/`secondary`/`tertiary`. The
264
+ * caller writes the returned bytes to the terminal (stdout).
265
+ */
266
+ export declare function clipboardSetSequence(selection: string, text: string): Array<number>
267
+
268
+ export declare function createDarkTheme(): NapiTheme
269
+
270
+ export declare function createLightTheme(): NapiTheme
271
+
272
+ export declare function detectCapabilities(): TerminalCapabilities
273
+
274
+ export declare function getVersion(): string
275
+
276
+ /** Builds an iTerm2 inline-image sequence for `file_bytes` (e.g. PNG file data). */
277
+ export declare function graphicsItermWrite(fileBytes: Buffer, name?: string | undefined | null, width?: number | undefined | null, height?: number | undefined | null): Buffer
278
+
279
+ /** Builds the Kitty sequence deleting image `id`. */
280
+ export declare function graphicsKittyDelete(id: number): Buffer
281
+
282
+ /** Builds the Kitty sequence deleting all transmitted images. */
283
+ export declare function graphicsKittyDeleteAll(): Buffer
284
+
285
+ /**
286
+ * Builds a Kitty graphics-protocol sequence transmitting+displaying `data`
287
+ * (raw `rgb`/`rgba` pixels or `png` bytes) with the given numeric `id`.
288
+ */
289
+ export declare function graphicsKittyWrite(format: string, width: number, height: number, data: Buffer, id: number): Buffer
290
+
291
+ /**
292
+ * Builds the probe sequence(s) detecting which graphics protocols the terminal
293
+ * supports (Kitty query + DA1 for Sixel).
294
+ */
295
+ export declare function graphicsQuery(): Buffer
296
+
297
+ /** Builds a Sixel sequence for a raw `rgb`/`rgba` image (empty for `png`). */
298
+ export declare function graphicsSixelWrite(format: string, width: number, height: number, data: Buffer): Buffer
299
+
300
+ /**
301
+ * Highlight `code` written in `language` using the built-in tree-sitter engine.
302
+ *
303
+ * Returns one `HighlightedLine` per source line (empty array if the language
304
+ * is unknown or the input is empty).
305
+ */
306
+ export declare function highlightCode(code: string, language: string): Array<HighlightedLine>
307
+
308
+ /** A single highlighted line, composed of [`HighlightSegment`]s. */
309
+ export interface HighlightedLine {
310
+ segments: Array<HighlightSegment>
311
+ }
312
+
313
+ /** A single styled segment returned by [`highlight_code`]. */
314
+ export interface HighlightSegment {
315
+ text: string
316
+ fg?: string
317
+ bg?: string
318
+ bold?: boolean
319
+ italic?: boolean
320
+ underline?: boolean
321
+ dim?: boolean
322
+ strikethrough?: boolean
323
+ }
324
+
325
+ /** Flush the logger */
326
+ export declare function loggerFlush(): void
327
+
328
+ /** Get a snapshot of diagnostic counters */
329
+ export declare function loggerGetDiagnostics(): NapiDiagnosticSnapshot
330
+
331
+ /** Get the current log level */
332
+ export declare function loggerGetLevel(): string
333
+
334
+ /** Initialize the logger with the given configuration */
335
+ export declare function loggerInit(config: NapiLoggerConfig): void
336
+
337
+ /** Set the global log level */
338
+ export declare function loggerSetLevel(level: string): void
339
+
340
+ /** Set the module filter */
341
+ export declare function loggerSetModuleFilter(include?: Array<string> | undefined | null, exclude?: Array<string> | undefined | null): void
342
+
343
+ /** Diagnostic snapshot for TypeScript */
344
+ export interface NapiDiagnosticSnapshot {
345
+ renderCalls: number
346
+ renderBytes: number
347
+ eventDispatches: number
348
+ layoutComputations: number
349
+ cacheHits: number
350
+ cacheMisses: number
351
+ allocations: number
352
+ averageFrameTime: number
353
+ fps: number
354
+ }
355
+
356
+ /** Logger configuration for TypeScript */
357
+ export interface NapiLoggerConfig {
358
+ level?: string
359
+ color?: boolean
360
+ timestamp?: boolean
361
+ module?: boolean
362
+ thread?: boolean
363
+ file?: string
364
+ maxFileSize?: number
365
+ maxFiles?: number
366
+ dev?: boolean
367
+ }
368
+
369
+ export interface NapiTheme {
370
+ name: string
371
+ colors: NapiThemeColors
372
+ spacing: NapiThemeSpacing
373
+ borders: NapiThemeBorders
374
+ }
375
+
376
+ export interface NapiThemeBorders {
377
+ style: string
378
+ fg: string
379
+ }
380
+
381
+ export interface NapiThemeColors {
382
+ background: string
383
+ surface: string
384
+ surfaceHigh: string
385
+ surfaceLow: string
386
+ primary: string
387
+ primaryForeground: string
388
+ secondary: string
389
+ secondaryForeground: string
390
+ text: string
391
+ textMuted: string
392
+ textDim: string
393
+ border: string
394
+ borderFocused: string
395
+ accent: string
396
+ accentForeground: string
397
+ error: string
398
+ warning: string
399
+ success: string
400
+ info: string
401
+ scrollbar: string
402
+ scrollbarThumb: string
403
+ }
404
+
405
+ export interface NapiThemeSpacing {
406
+ none: number
407
+ xxs: number
408
+ xs: number
409
+ sm: number
410
+ md: number
411
+ lg: number
412
+ xl: number
413
+ xxl: number
414
+ }
415
+
416
+ export interface NativeEventPipelineConfig {
417
+ kittyKeyboard?: boolean
418
+ bracketedPaste?: boolean
419
+ focusEvents?: boolean
420
+ mouseTracking?: boolean
421
+ width?: number
422
+ height?: number
423
+ }
424
+
425
+ export interface NativeSpanFeedOptions {
426
+ chunkSize: number
427
+ initialChunks: number
428
+ maxBytes: number
429
+ growthPolicy: number
430
+ autoCommitOnFull: number
431
+ spanQueueCapacity: number
432
+ }
433
+
434
+ export interface NativeSpanFeedStats {
435
+ bytesWritten: number
436
+ spansCommitted: number
437
+ chunks: number
438
+ pendingSpans: number
439
+ }
440
+
441
+ export interface TerminalCapabilities {
442
+ brand: string
443
+ trueColor: boolean
444
+ kittyKeyboard: boolean
445
+ csiU: boolean
446
+ bracketedPaste: boolean
447
+ focusEvents: boolean
448
+ mouse: boolean
449
+ osc52: boolean
450
+ osc8: boolean
451
+ sync: boolean
452
+ sgrPixel: boolean
453
+ underlineColor: boolean
454
+ strikethrough: boolean
455
+ cursorStyle: boolean
456
+ alternateScroll: boolean
457
+ inlineImages: boolean
458
+ sixel: boolean
459
+ columns: number
460
+ rows: number
461
+ }