@opentui/core 0.1.24 → 0.1.26
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/3d.js +1 -1
- package/README.md +5 -1
- package/Renderable.d.ts +18 -8
- package/animation/Timeline.d.ts +2 -1
- package/ansi.d.ts +2 -17
- package/assets/javascript/highlights.scm +205 -0
- package/assets/javascript/tree-sitter-javascript.wasm +0 -0
- package/assets/typescript/highlights.scm +604 -0
- package/assets/typescript/tree-sitter-typescript.wasm +0 -0
- package/{index-0yx9rnxg.js → index-pxa2sv92.js} +1798 -258
- package/index-pxa2sv92.js.map +52 -0
- package/index.js +449 -246
- package/index.js.map +15 -13
- package/lib/KeyHandler.d.ts +51 -9
- package/lib/data-paths.d.ts +26 -0
- package/lib/debounce.d.ts +42 -0
- package/lib/env.d.ts +42 -0
- package/lib/hast-styled-text.d.ts +3 -23
- package/lib/index.d.ts +6 -0
- package/lib/parse.keypress.d.ts +2 -2
- package/lib/queue.d.ts +15 -0
- package/lib/scroll-acceleration.d.ts +43 -0
- package/{singleton.d.ts → lib/singleton.d.ts} +2 -0
- package/lib/styled-text.d.ts +0 -15
- package/lib/syntax-style.d.ts +36 -0
- package/lib/tree-sitter/assets/update.d.ts +11 -0
- package/lib/tree-sitter/client.d.ts +46 -0
- package/lib/tree-sitter/default-parsers.d.ts +2 -0
- package/lib/tree-sitter/download-utils.d.ts +21 -0
- package/lib/tree-sitter/index.d.ts +10 -0
- package/lib/tree-sitter/parser.worker.d.ts +1 -0
- package/lib/tree-sitter/resolve-ft.d.ts +2 -0
- package/lib/tree-sitter/types.d.ts +64 -0
- package/lib/tree-sitter-styled-text.d.ts +7 -0
- package/lib/validate-dir-name.d.ts +1 -0
- package/package.json +21 -8
- package/parser.worker.js +640 -0
- package/parser.worker.js.map +11 -0
- package/renderables/ASCIIFont.d.ts +1 -1
- package/renderables/Code.d.ts +31 -0
- package/renderables/Input.d.ts +4 -4
- package/renderables/ScrollBar.d.ts +2 -2
- package/renderables/ScrollBox.d.ts +7 -3
- package/renderables/Select.d.ts +2 -2
- package/renderables/TabSelect.d.ts +2 -2
- package/renderables/Text.d.ts +11 -65
- package/renderables/TextBufferRenderable.d.ts +81 -0
- package/renderables/TextNode.d.ts +1 -0
- package/renderables/index.d.ts +2 -0
- package/renderer.d.ts +5 -3
- package/testing/mock-keys.d.ts +1 -0
- package/testing/spy.d.ts +7 -0
- package/testing/test-renderer.d.ts +1 -0
- package/testing.d.ts +1 -0
- package/testing.js +31 -6
- package/testing.js.map +6 -5
- package/types.d.ts +2 -1
- package/zig.d.ts +1 -0
- package/index-0yx9rnxg.js.map +0 -38
package/lib/KeyHandler.d.ts
CHANGED
|
@@ -1,15 +1,57 @@
|
|
|
1
1
|
import { EventEmitter } from "events";
|
|
2
|
-
import { type ParsedKey } from "./parse.keypress";
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { type KeyEventType, type ParsedKey } from "./parse.keypress";
|
|
3
|
+
export declare class KeyEvent implements ParsedKey {
|
|
4
|
+
name: string;
|
|
5
|
+
ctrl: boolean;
|
|
6
|
+
meta: boolean;
|
|
7
|
+
shift: boolean;
|
|
8
|
+
option: boolean;
|
|
9
|
+
sequence: string;
|
|
10
|
+
number: boolean;
|
|
11
|
+
raw: string;
|
|
12
|
+
eventType: KeyEventType;
|
|
13
|
+
code?: string;
|
|
14
|
+
super?: boolean;
|
|
15
|
+
hyper?: boolean;
|
|
16
|
+
capsLock?: boolean;
|
|
17
|
+
numLock?: boolean;
|
|
18
|
+
baseCode?: number;
|
|
19
|
+
private _defaultPrevented;
|
|
20
|
+
constructor(key: ParsedKey);
|
|
21
|
+
get defaultPrevented(): boolean;
|
|
22
|
+
preventDefault(): void;
|
|
23
|
+
}
|
|
24
|
+
export declare class PasteEvent {
|
|
25
|
+
text: string;
|
|
26
|
+
private _defaultPrevented;
|
|
27
|
+
constructor(text: string);
|
|
28
|
+
get defaultPrevented(): boolean;
|
|
29
|
+
preventDefault(): void;
|
|
30
|
+
}
|
|
31
|
+
export type KeyHandlerEventMap = {
|
|
32
|
+
keypress: [KeyEvent];
|
|
33
|
+
keyrepeat: [KeyEvent];
|
|
34
|
+
keyrelease: [KeyEvent];
|
|
35
|
+
paste: [PasteEvent];
|
|
8
36
|
};
|
|
9
37
|
export declare class KeyHandler extends EventEmitter<KeyHandlerEventMap> {
|
|
10
|
-
|
|
11
|
-
|
|
38
|
+
protected stdin: NodeJS.ReadStream;
|
|
39
|
+
protected useKittyKeyboard: boolean;
|
|
40
|
+
protected listener: (key: Buffer) => void;
|
|
41
|
+
protected pasteMode: boolean;
|
|
42
|
+
protected pasteBuffer: string[];
|
|
12
43
|
constructor(stdin?: NodeJS.ReadStream, useKittyKeyboard?: boolean);
|
|
13
44
|
destroy(): void;
|
|
14
45
|
}
|
|
15
|
-
|
|
46
|
+
/**
|
|
47
|
+
* This class is used internally by the renderer to ensure global handlers
|
|
48
|
+
* can preventDefault before renderable handlers process events.
|
|
49
|
+
*/
|
|
50
|
+
export declare class InternalKeyHandler extends KeyHandler {
|
|
51
|
+
private renderableHandlers;
|
|
52
|
+
constructor(stdin?: NodeJS.ReadStream, useKittyKeyboard?: boolean);
|
|
53
|
+
emit<K extends keyof KeyHandlerEventMap>(event: K, ...args: KeyHandlerEventMap[K]): boolean;
|
|
54
|
+
private emitWithPriority;
|
|
55
|
+
onInternal<K extends keyof KeyHandlerEventMap>(event: K, handler: (...args: KeyHandlerEventMap[K]) => void): void;
|
|
56
|
+
offInternal<K extends keyof KeyHandlerEventMap>(event: K, handler: (...args: KeyHandlerEventMap[K]) => void): void;
|
|
57
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { EventEmitter } from "events";
|
|
2
|
+
export interface DataPaths {
|
|
3
|
+
globalConfigPath: string;
|
|
4
|
+
globalConfigFile: string;
|
|
5
|
+
localConfigFile: string;
|
|
6
|
+
globalDataPath: string;
|
|
7
|
+
}
|
|
8
|
+
export interface DataPathsEvents {
|
|
9
|
+
"paths:changed": [paths: DataPaths];
|
|
10
|
+
}
|
|
11
|
+
export declare class DataPathsManager extends EventEmitter<DataPathsEvents> {
|
|
12
|
+
private _appName;
|
|
13
|
+
private _globalConfigPath?;
|
|
14
|
+
private _globalConfigFile?;
|
|
15
|
+
private _localConfigFile?;
|
|
16
|
+
private _globalDataPath?;
|
|
17
|
+
constructor();
|
|
18
|
+
get appName(): string;
|
|
19
|
+
set appName(value: string);
|
|
20
|
+
get globalConfigPath(): string;
|
|
21
|
+
get globalConfigFile(): string;
|
|
22
|
+
get localConfigFile(): string;
|
|
23
|
+
get globalDataPath(): string;
|
|
24
|
+
toObject(): DataPaths;
|
|
25
|
+
}
|
|
26
|
+
export declare function getDataPaths(): DataPathsManager;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Debounce controller that manages debounce instances for a specific scope
|
|
3
|
+
*/
|
|
4
|
+
export declare class DebounceController {
|
|
5
|
+
private scopeId;
|
|
6
|
+
constructor(scopeId: string | number);
|
|
7
|
+
/**
|
|
8
|
+
* Debounces the provided function with the given ID
|
|
9
|
+
*
|
|
10
|
+
* @param id Unique identifier within this scope
|
|
11
|
+
* @param ms Milliseconds to wait before executing
|
|
12
|
+
* @param fn Function to execute
|
|
13
|
+
*/
|
|
14
|
+
debounce<R>(id: string | number, ms: number, fn: () => Promise<R>): Promise<R>;
|
|
15
|
+
/**
|
|
16
|
+
* Clear a specific debounce timer in this scope
|
|
17
|
+
*
|
|
18
|
+
* @param id The debounce ID to clear
|
|
19
|
+
*/
|
|
20
|
+
clearDebounce(id: string | number): void;
|
|
21
|
+
/**
|
|
22
|
+
* Clear all debounce timers in this scope
|
|
23
|
+
*/
|
|
24
|
+
clear(): void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Creates a new debounce controller for a specific scope
|
|
28
|
+
*
|
|
29
|
+
* @param scopeId Unique identifier for this debounce scope
|
|
30
|
+
* @returns A DebounceController for the specified scope
|
|
31
|
+
*/
|
|
32
|
+
export declare function createDebounce(scopeId: string | number): DebounceController;
|
|
33
|
+
/**
|
|
34
|
+
* Clears all debounce timers for a specific scope
|
|
35
|
+
*
|
|
36
|
+
* @param scopeId The scope identifier
|
|
37
|
+
*/
|
|
38
|
+
export declare function clearDebounceScope(scopeId: string | number): void;
|
|
39
|
+
/**
|
|
40
|
+
* Clears all active debounce timers across all scopes
|
|
41
|
+
*/
|
|
42
|
+
export declare function clearAllDebounces(): void;
|
package/lib/env.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment variable registry
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { registerEnvVar, env } from "./lib/env.ts";
|
|
7
|
+
*
|
|
8
|
+
* // Register environment variables
|
|
9
|
+
* registerEnvVar({
|
|
10
|
+
* name: "DEBUG",
|
|
11
|
+
* description: "Enable debug logging",
|
|
12
|
+
* type: "boolean",
|
|
13
|
+
* default: false
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* registerEnvVar({
|
|
17
|
+
* name: "PORT",
|
|
18
|
+
* description: "Server port number",
|
|
19
|
+
* type: "number",
|
|
20
|
+
* default: 3000
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* // Access environment variables
|
|
24
|
+
* if (env.DEBUG) {
|
|
25
|
+
* console.log("Debug mode enabled");
|
|
26
|
+
* }
|
|
27
|
+
*
|
|
28
|
+
* const port = env.PORT; // number
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export interface EnvVarConfig {
|
|
32
|
+
name: string;
|
|
33
|
+
description: string;
|
|
34
|
+
default?: string | boolean | number;
|
|
35
|
+
type?: "string" | "boolean" | "number";
|
|
36
|
+
}
|
|
37
|
+
export declare const envRegistry: Record<string, EnvVarConfig>;
|
|
38
|
+
export declare function registerEnvVar(config: EnvVarConfig): void;
|
|
39
|
+
export declare function clearEnvCache(): void;
|
|
40
|
+
export declare function generateEnvMarkdown(): string;
|
|
41
|
+
export declare function generateEnvColored(): string;
|
|
42
|
+
export declare const env: Record<string, any>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RGBA } from "./RGBA";
|
|
2
1
|
import { StyledText } from "./styled-text";
|
|
2
|
+
import { SyntaxStyle } from "./syntax-style";
|
|
3
3
|
export interface HASTText {
|
|
4
4
|
type: "text";
|
|
5
5
|
value: string;
|
|
@@ -13,26 +13,6 @@ export interface HASTElement {
|
|
|
13
13
|
children: HASTNode[];
|
|
14
14
|
}
|
|
15
15
|
export type HASTNode = HASTText | HASTElement;
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
bg?: RGBA;
|
|
19
|
-
bold?: boolean;
|
|
20
|
-
italic?: boolean;
|
|
21
|
-
underline?: boolean;
|
|
22
|
-
dim?: boolean;
|
|
23
|
-
}
|
|
24
|
-
interface MergedStyle {
|
|
25
|
-
fg?: RGBA;
|
|
26
|
-
bg?: RGBA;
|
|
27
|
-
attributes: number;
|
|
28
|
-
}
|
|
29
|
-
export declare class SyntaxStyle {
|
|
30
|
-
private styles;
|
|
31
|
-
private mergedStyleCache;
|
|
32
|
-
constructor(styles: Record<string, StyleDefinition>);
|
|
33
|
-
mergeStyles(...styleNames: string[]): MergedStyle;
|
|
34
|
-
clearCache(): void;
|
|
35
|
-
getCacheSize(): number;
|
|
36
|
-
}
|
|
16
|
+
export { SyntaxStyle } from "./syntax-style";
|
|
17
|
+
export type { StyleDefinition } from "./syntax-style";
|
|
37
18
|
export declare function hastToStyledText(hast: HASTNode, syntaxStyle: SyntaxStyle): StyledText;
|
|
38
|
-
export {};
|
package/lib/index.d.ts
CHANGED
|
@@ -4,7 +4,13 @@ export * from "./ascii.font";
|
|
|
4
4
|
export * from "./hast-styled-text";
|
|
5
5
|
export * from "./RGBA";
|
|
6
6
|
export * from "./parse.keypress";
|
|
7
|
+
export * from "./scroll-acceleration";
|
|
7
8
|
export * from "./styled-text";
|
|
8
9
|
export * from "./yoga.options";
|
|
9
10
|
export * from "./parse.mouse";
|
|
10
11
|
export * from "./selection";
|
|
12
|
+
export * from "./env";
|
|
13
|
+
export * from "./tree-sitter-styled-text";
|
|
14
|
+
export * from "./tree-sitter";
|
|
15
|
+
export * from "./syntax-style";
|
|
16
|
+
export * from "./data-paths";
|
package/lib/parse.keypress.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Buffer } from "node:buffer";
|
|
2
2
|
export declare const nonAlphanumericKeys: string[];
|
|
3
3
|
export type KeyEventType = "press" | "repeat" | "release";
|
|
4
|
-
export
|
|
4
|
+
export interface ParsedKey {
|
|
5
5
|
name: string;
|
|
6
6
|
ctrl: boolean;
|
|
7
7
|
meta: boolean;
|
|
@@ -17,7 +17,7 @@ export type ParsedKey = {
|
|
|
17
17
|
capsLock?: boolean;
|
|
18
18
|
numLock?: boolean;
|
|
19
19
|
baseCode?: number;
|
|
20
|
-
}
|
|
20
|
+
}
|
|
21
21
|
export type ParseKeypressOptions = {
|
|
22
22
|
useKittyKeyboard?: boolean;
|
|
23
23
|
};
|
package/lib/queue.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic processing queue that handles asynchronous job processing
|
|
3
|
+
*/
|
|
4
|
+
export declare class ProcessQueue<T> {
|
|
5
|
+
private processor;
|
|
6
|
+
private queue;
|
|
7
|
+
private processing;
|
|
8
|
+
private autoProcess;
|
|
9
|
+
constructor(processor: (item: T) => Promise<void> | void, autoProcess?: boolean);
|
|
10
|
+
enqueue(item: T): void;
|
|
11
|
+
private processQueue;
|
|
12
|
+
clear(): void;
|
|
13
|
+
isProcessing(): boolean;
|
|
14
|
+
size(): number;
|
|
15
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export interface ScrollAcceleration {
|
|
2
|
+
tick(now?: number): number;
|
|
3
|
+
reset(): void;
|
|
4
|
+
}
|
|
5
|
+
export declare class LinearScrollAccel implements ScrollAcceleration {
|
|
6
|
+
tick(_now?: number): number;
|
|
7
|
+
reset(): void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* macOS-inspired scroll acceleration.
|
|
11
|
+
*
|
|
12
|
+
* The class measures the time between consecutive scroll events and keeps a short
|
|
13
|
+
* moving window of the latest intervals. The average interval determines which
|
|
14
|
+
* multiplier to apply so that quick bursts accelerate and slower gestures stay precise.
|
|
15
|
+
*
|
|
16
|
+
* For intuition, treat the streak as a continuous timeline and compare it with the
|
|
17
|
+
* exponential distance curve from the pointer-acceleration research post:
|
|
18
|
+
* d(t) = v₀ * ( t + A * (exp(t/τ) - 1 - t/τ) ).
|
|
19
|
+
* Small t stays near the base multiplier, medium streaks settle on multiplier1, and
|
|
20
|
+
* sustained bursts reach multiplier2, mirroring how the exponential curve bends up.
|
|
21
|
+
*
|
|
22
|
+
* Options:
|
|
23
|
+
* - threshold1: upper bound (ms) of the "medium" band. Raise to delay the ramp.
|
|
24
|
+
* - threshold2: upper bound (ms) of the "fast" band. Lower to demand tighter bursts.
|
|
25
|
+
* - multiplier1: scale for medium speed streaks.
|
|
26
|
+
* - multiplier2: scale for sustained fast streaks.
|
|
27
|
+
* - baseMultiplier: scale for relaxed scrolling; set to 1 for linear behaviour.
|
|
28
|
+
*/
|
|
29
|
+
export declare class MacOSScrollAccel implements ScrollAcceleration {
|
|
30
|
+
private opts;
|
|
31
|
+
private lastTickTime;
|
|
32
|
+
private velocityHistory;
|
|
33
|
+
private readonly historySize;
|
|
34
|
+
private readonly streakTimeout;
|
|
35
|
+
private readonly minTickInterval;
|
|
36
|
+
constructor(opts?: {
|
|
37
|
+
A?: number;
|
|
38
|
+
tau?: number;
|
|
39
|
+
maxMultiplier?: number;
|
|
40
|
+
});
|
|
41
|
+
tick(now?: number): number;
|
|
42
|
+
reset(): void;
|
|
43
|
+
}
|
package/lib/styled-text.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { TextRenderable } from "../renderables/Text";
|
|
2
1
|
import type { TextChunk } from "../text-buffer";
|
|
3
2
|
import { type ColorInput } from "./RGBA";
|
|
4
3
|
declare const BrandedStyledText: unique symbol;
|
|
@@ -18,21 +17,7 @@ export declare function isStyledText(obj: any): obj is StyledText;
|
|
|
18
17
|
export declare class StyledText {
|
|
19
18
|
[BrandedStyledText]: boolean;
|
|
20
19
|
chunks: TextChunk[];
|
|
21
|
-
textRenderable?: TextRenderable;
|
|
22
20
|
constructor(chunks: TextChunk[]);
|
|
23
|
-
mount(textRenderable: TextRenderable): void;
|
|
24
|
-
/**
|
|
25
|
-
* @deprecated: Use textRenderable.insertChunk instead
|
|
26
|
-
*/
|
|
27
|
-
insert(chunk: TextChunk, index?: number): StyledText;
|
|
28
|
-
/**
|
|
29
|
-
* @deprecated: Use textRenderable.removeChunk instead
|
|
30
|
-
*/
|
|
31
|
-
remove(chunk: TextChunk): StyledText;
|
|
32
|
-
/**
|
|
33
|
-
* @deprecated: Use textRenderable.replaceChunk instead
|
|
34
|
-
*/
|
|
35
|
-
replace(chunk: TextChunk, oldChunk: TextChunk): StyledText;
|
|
36
21
|
}
|
|
37
22
|
export declare function stringToStyledText(content: string): StyledText;
|
|
38
23
|
export type StylableInput = string | number | boolean | TextChunk;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { RGBA, type ColorInput } from "./RGBA";
|
|
2
|
+
export interface StyleDefinition {
|
|
3
|
+
fg?: RGBA;
|
|
4
|
+
bg?: RGBA;
|
|
5
|
+
bold?: boolean;
|
|
6
|
+
italic?: boolean;
|
|
7
|
+
underline?: boolean;
|
|
8
|
+
dim?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface MergedStyle {
|
|
11
|
+
fg?: RGBA;
|
|
12
|
+
bg?: RGBA;
|
|
13
|
+
attributes: number;
|
|
14
|
+
}
|
|
15
|
+
export interface ThemeTokenStyle {
|
|
16
|
+
scope: string[];
|
|
17
|
+
style: {
|
|
18
|
+
foreground?: ColorInput;
|
|
19
|
+
background?: ColorInput;
|
|
20
|
+
bold?: boolean;
|
|
21
|
+
italic?: boolean;
|
|
22
|
+
underline?: boolean;
|
|
23
|
+
dim?: boolean;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export declare function convertThemeToStyles(theme: ThemeTokenStyle[]): Record<string, StyleDefinition>;
|
|
27
|
+
export declare class SyntaxStyle {
|
|
28
|
+
private styles;
|
|
29
|
+
private mergedStyleCache;
|
|
30
|
+
constructor(styles: Record<string, StyleDefinition>);
|
|
31
|
+
static fromTheme(theme: ThemeTokenStyle[]): SyntaxStyle;
|
|
32
|
+
mergeStyles(...styleNames: string[]): MergedStyle;
|
|
33
|
+
getStyle(name: string): StyleDefinition | undefined;
|
|
34
|
+
clearCache(): void;
|
|
35
|
+
getCacheSize(): number;
|
|
36
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
export interface UpdateOptions {
|
|
3
|
+
/** Path to parsers-config.json */
|
|
4
|
+
configPath: string;
|
|
5
|
+
/** Directory where .wasm and .scm files will be downloaded */
|
|
6
|
+
assetsDir: string;
|
|
7
|
+
/** Path where the generated TypeScript file will be written */
|
|
8
|
+
outputPath: string;
|
|
9
|
+
}
|
|
10
|
+
declare function main(options?: Partial<UpdateOptions>): Promise<void>;
|
|
11
|
+
export { main as updateAssets };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { EventEmitter } from "events";
|
|
2
|
+
import type { TreeSitterClientOptions, TreeSitterClientEvents, BufferState, FiletypeParserOptions, Edit, PerformanceStats, SimpleHighlight } from "./types";
|
|
3
|
+
declare global {
|
|
4
|
+
const OTUI_TREE_SITTER_WORKER_PATH: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function addDefaultParsers(parsers: FiletypeParserOptions[]): void;
|
|
7
|
+
export declare class TreeSitterClient extends EventEmitter<TreeSitterClientEvents> {
|
|
8
|
+
private initialized;
|
|
9
|
+
private worker;
|
|
10
|
+
private buffers;
|
|
11
|
+
private initializePromise;
|
|
12
|
+
private initializeResolvers;
|
|
13
|
+
private messageCallbacks;
|
|
14
|
+
private messageIdCounter;
|
|
15
|
+
private editQueues;
|
|
16
|
+
private debouncer;
|
|
17
|
+
private options;
|
|
18
|
+
constructor(options: TreeSitterClientOptions);
|
|
19
|
+
private emitError;
|
|
20
|
+
private emitWarning;
|
|
21
|
+
private startWorker;
|
|
22
|
+
private stopWorker;
|
|
23
|
+
private handleReset;
|
|
24
|
+
initialize(): Promise<void>;
|
|
25
|
+
private registerDefaultParsers;
|
|
26
|
+
private resolvePath;
|
|
27
|
+
addFiletypeParser(filetypeParser: FiletypeParserOptions): void;
|
|
28
|
+
getPerformance(): Promise<PerformanceStats>;
|
|
29
|
+
highlightOnce(content: string, filetype: string): Promise<{
|
|
30
|
+
highlights?: SimpleHighlight[];
|
|
31
|
+
warning?: string;
|
|
32
|
+
error?: string;
|
|
33
|
+
}>;
|
|
34
|
+
private handleWorkerMessage;
|
|
35
|
+
preloadParser(filetype: string): Promise<boolean>;
|
|
36
|
+
createBuffer(id: number, content: string, filetype: string, version?: number, autoInitialize?: boolean): Promise<boolean>;
|
|
37
|
+
updateBuffer(id: number, edits: Edit[], newContent: string, version: number): Promise<void>;
|
|
38
|
+
private processEdit;
|
|
39
|
+
removeBuffer(bufferId: number): Promise<void>;
|
|
40
|
+
destroy(): Promise<void>;
|
|
41
|
+
resetBuffer(bufferId: number, version: number, content: string): Promise<void>;
|
|
42
|
+
getBuffer(bufferId: number): BufferState | undefined;
|
|
43
|
+
getAllBuffers(): BufferState[];
|
|
44
|
+
isInitialized(): boolean;
|
|
45
|
+
setDataPath(dataPath: string): Promise<void>;
|
|
46
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface DownloadResult {
|
|
2
|
+
content?: ArrayBuffer;
|
|
3
|
+
filePath?: string;
|
|
4
|
+
error?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class DownloadUtils {
|
|
7
|
+
private static hashUrl;
|
|
8
|
+
/**
|
|
9
|
+
* Download a file from URL or load from local path, with caching support
|
|
10
|
+
*/
|
|
11
|
+
static downloadOrLoad(source: string, cacheDir: string, cacheSubdir: string, fileExtension: string, useHashForCache?: boolean, filetype?: string): Promise<DownloadResult>;
|
|
12
|
+
/**
|
|
13
|
+
* Download and save a file to a specific target path
|
|
14
|
+
*/
|
|
15
|
+
static downloadToPath(source: string, targetPath: string): Promise<DownloadResult>;
|
|
16
|
+
/**
|
|
17
|
+
* Fetch multiple highlight queries and concatenate them
|
|
18
|
+
*/
|
|
19
|
+
static fetchHighlightQueries(sources: string[], cacheDir: string, filetype: string): Promise<string>;
|
|
20
|
+
private static fetchHighlightQuery;
|
|
21
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TreeSitterClient } from "./client";
|
|
2
|
+
export * from "./client";
|
|
3
|
+
export * from "../tree-sitter-styled-text";
|
|
4
|
+
export * from "../syntax-style";
|
|
5
|
+
export * from "./types";
|
|
6
|
+
export * from "../syntax-style";
|
|
7
|
+
export * from "./resolve-ft";
|
|
8
|
+
export type { UpdateOptions } from "./assets/update";
|
|
9
|
+
export { updateAssets } from "./assets/update";
|
|
10
|
+
export declare function getTreeSitterClient(): TreeSitterClient;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export interface HighlightRange {
|
|
2
|
+
startCol: number;
|
|
3
|
+
endCol: number;
|
|
4
|
+
group: string;
|
|
5
|
+
}
|
|
6
|
+
export interface HighlightResponse {
|
|
7
|
+
line: number;
|
|
8
|
+
highlights: HighlightRange[];
|
|
9
|
+
droppedHighlights: HighlightRange[];
|
|
10
|
+
}
|
|
11
|
+
export type SimpleHighlight = [number, number, string];
|
|
12
|
+
export interface FiletypeParserOptions {
|
|
13
|
+
filetype: string;
|
|
14
|
+
queries: {
|
|
15
|
+
highlights: string[];
|
|
16
|
+
};
|
|
17
|
+
wasm: string;
|
|
18
|
+
}
|
|
19
|
+
export interface BufferState {
|
|
20
|
+
id: number;
|
|
21
|
+
version: number;
|
|
22
|
+
content: string;
|
|
23
|
+
filetype: string;
|
|
24
|
+
hasParser: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface ParsedBuffer extends BufferState {
|
|
27
|
+
hasParser: true;
|
|
28
|
+
}
|
|
29
|
+
export interface TreeSitterClientEvents {
|
|
30
|
+
"highlights:response": [bufferId: number, version: number, highlights: HighlightResponse[]];
|
|
31
|
+
"buffer:initialized": [bufferId: number, hasParser: boolean];
|
|
32
|
+
"buffer:disposed": [bufferId: number];
|
|
33
|
+
"worker:log": [logType: "log" | "error", message: string];
|
|
34
|
+
error: [error: string, bufferId?: number];
|
|
35
|
+
warning: [warning: string, bufferId?: number];
|
|
36
|
+
}
|
|
37
|
+
export interface TreeSitterClientOptions {
|
|
38
|
+
dataPath: string;
|
|
39
|
+
workerPath?: string | URL;
|
|
40
|
+
initTimeout?: number;
|
|
41
|
+
}
|
|
42
|
+
export interface Edit {
|
|
43
|
+
startIndex: number;
|
|
44
|
+
oldEndIndex: number;
|
|
45
|
+
newEndIndex: number;
|
|
46
|
+
startPosition: {
|
|
47
|
+
row: number;
|
|
48
|
+
column: number;
|
|
49
|
+
};
|
|
50
|
+
oldEndPosition: {
|
|
51
|
+
row: number;
|
|
52
|
+
column: number;
|
|
53
|
+
};
|
|
54
|
+
newEndPosition: {
|
|
55
|
+
row: number;
|
|
56
|
+
column: number;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export interface PerformanceStats {
|
|
60
|
+
averageParseTime: number;
|
|
61
|
+
parseTimes: number[];
|
|
62
|
+
averageQueryTime: number;
|
|
63
|
+
queryTimes: number[];
|
|
64
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TextChunk } from "../text-buffer";
|
|
2
|
+
import { StyledText } from "./styled-text";
|
|
3
|
+
import { SyntaxStyle } from "./syntax-style";
|
|
4
|
+
import { TreeSitterClient } from "./tree-sitter/client";
|
|
5
|
+
import type { SimpleHighlight } from "./tree-sitter/types";
|
|
6
|
+
export declare function treeSitterToTextChunks(content: string, highlights: SimpleHighlight[], syntaxStyle: SyntaxStyle): TextChunk[];
|
|
7
|
+
export declare function treeSitterToStyledText(content: string, filetype: string, syntaxStyle: SyntaxStyle, client: TreeSitterClient): Promise<StyledText>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isValidDirectoryName(name: string): boolean;
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"version": "0.1.
|
|
7
|
+
"version": "0.1.26",
|
|
8
8
|
"description": "OpenTUI is a TypeScript library for building terminal user interfaces (TUIs)",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
@@ -27,24 +27,37 @@
|
|
|
27
27
|
"import": "./testing.js",
|
|
28
28
|
"require": "./testing.js",
|
|
29
29
|
"types": "./testing.d.ts"
|
|
30
|
+
},
|
|
31
|
+
"./parser.worker": {
|
|
32
|
+
"import": "./lib/tree-sitter/parser.worker.js",
|
|
33
|
+
"require": "./lib/tree-sitter/parser.worker.js",
|
|
34
|
+
"types": "./lib/tree-sitter/parser.worker.d.ts"
|
|
30
35
|
}
|
|
31
36
|
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"jimp": "1.6.0",
|
|
39
|
+
"yoga-layout": "3.2.1"
|
|
40
|
+
},
|
|
32
41
|
"devDependencies": {
|
|
33
42
|
"@types/bun": "latest",
|
|
34
43
|
"@types/three": "0.177.0",
|
|
35
44
|
"commander": "^13.1.0",
|
|
36
|
-
"typescript": "^5"
|
|
45
|
+
"typescript": "^5",
|
|
46
|
+
"web-tree-sitter": "^0.26.0"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"web-tree-sitter": ">=0.26.0"
|
|
37
50
|
},
|
|
38
51
|
"optionalDependencies": {
|
|
39
52
|
"@dimforge/rapier2d-simd-compat": "^0.17.3",
|
|
40
53
|
"bun-webgpu": "0.1.3",
|
|
41
54
|
"planck": "^1.4.2",
|
|
42
55
|
"three": "0.177.0",
|
|
43
|
-
"@opentui/core-darwin-x64": "0.1.
|
|
44
|
-
"@opentui/core-darwin-arm64": "0.1.
|
|
45
|
-
"@opentui/core-linux-x64": "0.1.
|
|
46
|
-
"@opentui/core-linux-arm64": "0.1.
|
|
47
|
-
"@opentui/core-win32-x64": "0.1.
|
|
48
|
-
"@opentui/core-win32-arm64": "0.1.
|
|
56
|
+
"@opentui/core-darwin-x64": "0.1.26",
|
|
57
|
+
"@opentui/core-darwin-arm64": "0.1.26",
|
|
58
|
+
"@opentui/core-linux-x64": "0.1.26",
|
|
59
|
+
"@opentui/core-linux-arm64": "0.1.26",
|
|
60
|
+
"@opentui/core-win32-x64": "0.1.26",
|
|
61
|
+
"@opentui/core-win32-arm64": "0.1.26"
|
|
49
62
|
}
|
|
50
63
|
}
|