@cascadetui/core 0.1.1
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/SpriteResourceManager.d.ts +74 -0
- package/3d/SpriteUtils.d.ts +13 -0
- package/3d/TextureUtils.d.ts +24 -0
- package/3d/ThreeRenderable.d.ts +40 -0
- package/3d/WGPURenderer.d.ts +61 -0
- package/3d/animation/ExplodingSpriteEffect.d.ts +71 -0
- package/3d/animation/PhysicsExplodingSpriteEffect.d.ts +76 -0
- package/3d/animation/SpriteAnimator.d.ts +124 -0
- package/3d/animation/SpriteParticleGenerator.d.ts +62 -0
- package/3d/canvas.d.ts +44 -0
- package/3d/index.d.ts +12 -0
- package/3d/physics/PlanckPhysicsAdapter.d.ts +19 -0
- package/3d/physics/RapierPhysicsAdapter.d.ts +19 -0
- package/3d/physics/physics-interface.d.ts +27 -0
- package/3d.d.ts +2 -0
- package/3d.js +34041 -0
- package/3d.js.map +155 -0
- package/LICENSE +21 -0
- package/NativeSpanFeed.d.ts +41 -0
- package/README.md +62 -0
- package/Renderable.d.ts +334 -0
- package/animation/Timeline.d.ts +126 -0
- package/ansi.d.ts +13 -0
- package/assets/javascript/highlights.scm +205 -0
- package/assets/javascript/tree-sitter-javascript.wasm +0 -0
- package/assets/markdown/highlights.scm +150 -0
- package/assets/markdown/injections.scm +27 -0
- package/assets/markdown/tree-sitter-markdown.wasm +0 -0
- package/assets/markdown_inline/highlights.scm +115 -0
- package/assets/markdown_inline/tree-sitter-markdown_inline.wasm +0 -0
- package/assets/typescript/highlights.scm +604 -0
- package/assets/typescript/tree-sitter-typescript.wasm +0 -0
- package/assets/zig/highlights.scm +284 -0
- package/assets/zig/tree-sitter-zig.wasm +0 -0
- package/buffer.d.ts +107 -0
- package/console.d.ts +140 -0
- package/edit-buffer.d.ts +98 -0
- package/editor-view.d.ts +73 -0
- package/index-jx194wn1.js +17723 -0
- package/index-jx194wn1.js.map +61 -0
- package/index.d.ts +18 -0
- package/index.js +12210 -0
- package/index.js.map +49 -0
- package/lib/KeyHandler.d.ts +61 -0
- package/lib/RGBA.d.ts +25 -0
- package/lib/ascii.font.d.ts +508 -0
- package/lib/border.d.ts +49 -0
- package/lib/bunfs.d.ts +7 -0
- package/lib/clipboard.d.ts +29 -0
- package/lib/data-paths.d.ts +26 -0
- package/lib/debounce.d.ts +42 -0
- package/lib/env.d.ts +42 -0
- package/lib/extmarks-history.d.ts +17 -0
- package/lib/extmarks.d.ts +89 -0
- package/lib/hast-styled-text.d.ts +17 -0
- package/lib/index.d.ts +18 -0
- package/lib/keymapping.d.ts +25 -0
- package/lib/objects-in-viewport.d.ts +24 -0
- package/lib/output.capture.d.ts +24 -0
- package/lib/parse.keypress-kitty.d.ts +2 -0
- package/lib/parse.keypress.d.ts +26 -0
- package/lib/parse.mouse.d.ts +30 -0
- package/lib/queue.d.ts +15 -0
- package/lib/renderable.validations.d.ts +12 -0
- package/lib/scroll-acceleration.d.ts +43 -0
- package/lib/selection.d.ts +63 -0
- package/lib/singleton.d.ts +7 -0
- package/lib/stdin-buffer.d.ts +44 -0
- package/lib/styled-text.d.ts +63 -0
- package/lib/terminal-capability-detection.d.ts +30 -0
- package/lib/terminal-palette.d.ts +43 -0
- package/lib/tree-sitter/assets/update.d.ts +11 -0
- package/lib/tree-sitter/client.d.ts +47 -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 +8 -0
- package/lib/tree-sitter/parser.worker.d.ts +1 -0
- package/lib/tree-sitter/parsers-config.d.ts +38 -0
- package/lib/tree-sitter/resolve-ft.d.ts +2 -0
- package/lib/tree-sitter/types.d.ts +81 -0
- package/lib/tree-sitter-styled-text.d.ts +14 -0
- package/lib/validate-dir-name.d.ts +1 -0
- package/lib/yoga.options.d.ts +32 -0
- package/package.json +67 -0
- package/parser.worker.js +878 -0
- package/parser.worker.js.map +12 -0
- package/post/filters.d.ts +105 -0
- package/renderables/ASCIIFont.d.ts +52 -0
- package/renderables/Box.d.ts +72 -0
- package/renderables/Code.d.ts +66 -0
- package/renderables/Diff.d.ts +135 -0
- package/renderables/EditBufferRenderable.d.ts +162 -0
- package/renderables/FrameBuffer.d.ts +16 -0
- package/renderables/Input.d.ts +67 -0
- package/renderables/LineNumberRenderable.d.ts +74 -0
- package/renderables/Markdown.d.ts +150 -0
- package/renderables/ScrollBar.d.ts +77 -0
- package/renderables/ScrollBox.d.ts +116 -0
- package/renderables/Select.d.ts +115 -0
- package/renderables/Slider.d.ts +44 -0
- package/renderables/TabSelect.d.ts +96 -0
- package/renderables/Text.d.ts +36 -0
- package/renderables/TextBufferRenderable.d.ts +105 -0
- package/renderables/TextNode.d.ts +91 -0
- package/renderables/TextTable.d.ts +130 -0
- package/renderables/Textarea.d.ts +114 -0
- package/renderables/__tests__/renderable-test-utils.d.ts +7 -0
- package/renderables/composition/VRenderable.d.ts +16 -0
- package/renderables/composition/constructs.d.ts +35 -0
- package/renderables/composition/vnode.d.ts +46 -0
- package/renderables/index.d.ts +21 -0
- package/renderables/markdown-parser.d.ts +10 -0
- package/renderer.d.ts +382 -0
- package/syntax-style.d.ts +54 -0
- package/testing/mock-keys.d.ts +80 -0
- package/testing/mock-mouse.d.ts +38 -0
- package/testing/mock-tree-sitter-client.d.ts +23 -0
- package/testing/spy.d.ts +7 -0
- package/testing/test-recorder.d.ts +61 -0
- package/testing/test-renderer.d.ts +23 -0
- package/testing.d.ts +6 -0
- package/testing.js +670 -0
- package/testing.js.map +15 -0
- package/text-buffer-view.d.ts +42 -0
- package/text-buffer.d.ts +67 -0
- package/types.d.ts +126 -0
- package/utils.d.ts +14 -0
- package/zig-structs.d.ts +155 -0
- package/zig.d.ts +351 -0
|
@@ -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>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Extmark } from "./extmarks";
|
|
2
|
+
export interface ExtmarksSnapshot {
|
|
3
|
+
extmarks: Map<number, Extmark>;
|
|
4
|
+
nextId: number;
|
|
5
|
+
}
|
|
6
|
+
export declare class ExtmarksHistory {
|
|
7
|
+
private undoStack;
|
|
8
|
+
private redoStack;
|
|
9
|
+
saveSnapshot(extmarks: Map<number, Extmark>, nextId: number): void;
|
|
10
|
+
undo(): ExtmarksSnapshot | null;
|
|
11
|
+
redo(): ExtmarksSnapshot | null;
|
|
12
|
+
pushRedo(snapshot: ExtmarksSnapshot): void;
|
|
13
|
+
pushUndo(snapshot: ExtmarksSnapshot): void;
|
|
14
|
+
clear(): void;
|
|
15
|
+
canUndo(): boolean;
|
|
16
|
+
canRedo(): boolean;
|
|
17
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { EditBuffer } from "../edit-buffer";
|
|
2
|
+
import type { EditorView } from "../editor-view";
|
|
3
|
+
export interface Extmark {
|
|
4
|
+
id: number;
|
|
5
|
+
start: number;
|
|
6
|
+
end: number;
|
|
7
|
+
virtual: boolean;
|
|
8
|
+
styleId?: number;
|
|
9
|
+
priority?: number;
|
|
10
|
+
data?: any;
|
|
11
|
+
typeId: number;
|
|
12
|
+
}
|
|
13
|
+
export interface ExtmarkOptions {
|
|
14
|
+
start: number;
|
|
15
|
+
end: number;
|
|
16
|
+
virtual?: boolean;
|
|
17
|
+
styleId?: number;
|
|
18
|
+
priority?: number;
|
|
19
|
+
data?: any;
|
|
20
|
+
typeId?: number;
|
|
21
|
+
metadata?: any;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* WARNING: This is simulating extmarks in the edit buffer
|
|
25
|
+
* and will move to a real native implementation in the future.
|
|
26
|
+
* Use with caution.
|
|
27
|
+
*/
|
|
28
|
+
export declare class ExtmarksController {
|
|
29
|
+
private editBuffer;
|
|
30
|
+
private editorView;
|
|
31
|
+
private extmarks;
|
|
32
|
+
private extmarksByTypeId;
|
|
33
|
+
private metadata;
|
|
34
|
+
private nextId;
|
|
35
|
+
private destroyed;
|
|
36
|
+
private history;
|
|
37
|
+
private typeNameToId;
|
|
38
|
+
private typeIdToName;
|
|
39
|
+
private nextTypeId;
|
|
40
|
+
private originalMoveCursorLeft;
|
|
41
|
+
private originalMoveCursorRight;
|
|
42
|
+
private originalSetCursorByOffset;
|
|
43
|
+
private originalMoveUpVisual;
|
|
44
|
+
private originalMoveDownVisual;
|
|
45
|
+
private originalDeleteCharBackward;
|
|
46
|
+
private originalDeleteChar;
|
|
47
|
+
private originalInsertText;
|
|
48
|
+
private originalInsertChar;
|
|
49
|
+
private originalDeleteRange;
|
|
50
|
+
private originalSetText;
|
|
51
|
+
private originalReplaceText;
|
|
52
|
+
private originalClear;
|
|
53
|
+
private originalNewLine;
|
|
54
|
+
private originalDeleteLine;
|
|
55
|
+
private originalEditorViewDeleteSelectedText;
|
|
56
|
+
private originalUndo;
|
|
57
|
+
private originalRedo;
|
|
58
|
+
constructor(editBuffer: EditBuffer, editorView: EditorView);
|
|
59
|
+
private wrapCursorMovement;
|
|
60
|
+
private wrapDeletion;
|
|
61
|
+
private wrapInsertion;
|
|
62
|
+
private wrapEditorViewDeleteSelectedText;
|
|
63
|
+
private setupContentChangeListener;
|
|
64
|
+
private deleteExtmarkById;
|
|
65
|
+
private findVirtualExtmarkContaining;
|
|
66
|
+
private adjustExtmarksAfterInsertion;
|
|
67
|
+
adjustExtmarksAfterDeletion(deleteOffset: number, length: number): void;
|
|
68
|
+
private offsetToPosition;
|
|
69
|
+
private positionToOffset;
|
|
70
|
+
private updateHighlights;
|
|
71
|
+
private offsetExcludingNewlines;
|
|
72
|
+
create(options: ExtmarkOptions): number;
|
|
73
|
+
delete(id: number): boolean;
|
|
74
|
+
get(id: number): Extmark | null;
|
|
75
|
+
getAll(): Extmark[];
|
|
76
|
+
getVirtual(): Extmark[];
|
|
77
|
+
getAtOffset(offset: number): Extmark[];
|
|
78
|
+
getAllForTypeId(typeId: number): Extmark[];
|
|
79
|
+
clear(): void;
|
|
80
|
+
private saveSnapshot;
|
|
81
|
+
private restoreSnapshot;
|
|
82
|
+
private wrapUndoRedo;
|
|
83
|
+
registerType(typeName: string): number;
|
|
84
|
+
getTypeId(typeName: string): number | null;
|
|
85
|
+
getTypeName(typeId: number): string | null;
|
|
86
|
+
getMetadataFor(extmarkId: number): any;
|
|
87
|
+
destroy(): void;
|
|
88
|
+
}
|
|
89
|
+
export declare function createExtmarksController(editBuffer: EditBuffer, editorView: EditorView): ExtmarksController;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { StyledText } from "./styled-text";
|
|
2
|
+
import { SyntaxStyle } from "../syntax-style";
|
|
3
|
+
export interface HASTText {
|
|
4
|
+
type: "text";
|
|
5
|
+
value: string;
|
|
6
|
+
}
|
|
7
|
+
export interface HASTElement {
|
|
8
|
+
type: "element";
|
|
9
|
+
tagName: string;
|
|
10
|
+
properties?: {
|
|
11
|
+
className?: string;
|
|
12
|
+
};
|
|
13
|
+
children: HASTNode[];
|
|
14
|
+
}
|
|
15
|
+
export type HASTNode = HASTText | HASTElement;
|
|
16
|
+
export type { StyleDefinition } from "../syntax-style";
|
|
17
|
+
export declare function hastToStyledText(hast: HASTNode, syntaxStyle: SyntaxStyle): StyledText;
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export * from "./border";
|
|
2
|
+
export * from "./KeyHandler";
|
|
3
|
+
export * from "./ascii.font";
|
|
4
|
+
export * from "./hast-styled-text";
|
|
5
|
+
export * from "./RGBA";
|
|
6
|
+
export * from "./parse.keypress";
|
|
7
|
+
export * from "./scroll-acceleration";
|
|
8
|
+
export * from "./stdin-buffer";
|
|
9
|
+
export * from "./styled-text";
|
|
10
|
+
export * from "./yoga.options";
|
|
11
|
+
export * from "./parse.mouse";
|
|
12
|
+
export * from "./selection";
|
|
13
|
+
export * from "./env";
|
|
14
|
+
export * from "./tree-sitter-styled-text";
|
|
15
|
+
export * from "./tree-sitter";
|
|
16
|
+
export * from "./data-paths";
|
|
17
|
+
export * from "./extmarks";
|
|
18
|
+
export * from "./terminal-palette";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface KeyBinding<Action extends string = string> {
|
|
2
|
+
name: string;
|
|
3
|
+
ctrl?: boolean;
|
|
4
|
+
shift?: boolean;
|
|
5
|
+
meta?: boolean;
|
|
6
|
+
super?: boolean;
|
|
7
|
+
action: Action;
|
|
8
|
+
}
|
|
9
|
+
export type KeyAliasMap = Record<string, string>;
|
|
10
|
+
export declare const defaultKeyAliases: KeyAliasMap;
|
|
11
|
+
export declare function mergeKeyAliases(defaults: KeyAliasMap, custom: KeyAliasMap): KeyAliasMap;
|
|
12
|
+
export declare function mergeKeyBindings<Action extends string>(defaults: KeyBinding<Action>[], custom: KeyBinding<Action>[]): KeyBinding<Action>[];
|
|
13
|
+
export declare function getKeyBindingKey<Action extends string>(binding: KeyBinding<Action>): string;
|
|
14
|
+
export declare function buildKeyBindingsMap<Action extends string>(bindings: KeyBinding<Action>[], aliasMap?: KeyAliasMap): Map<string, Action>;
|
|
15
|
+
/**
|
|
16
|
+
* Converts a key binding to a human-readable string representation
|
|
17
|
+
* @param binding The key binding to stringify
|
|
18
|
+
* @returns A string like "ctrl+shift+y" or just "escape"
|
|
19
|
+
* @example
|
|
20
|
+
* keyBindingToString({ name: "y", ctrl: true, shift: true }) // "ctrl+shift+y"
|
|
21
|
+
* keyBindingToString({ name: "escape" }) // "escape"
|
|
22
|
+
* keyBindingToString({ name: "c", ctrl: true }) // "ctrl+c"
|
|
23
|
+
* keyBindingToString({ name: "s", super: true }) // "super+s"
|
|
24
|
+
*/
|
|
25
|
+
export declare function keyBindingToString<Action extends string>(binding: KeyBinding<Action>): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ViewportBounds } from "../types";
|
|
2
|
+
interface ViewportObject {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
zIndex: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Returns objects that overlap with the viewport bounds.
|
|
11
|
+
*
|
|
12
|
+
* @param viewport - The viewport bounds to check against
|
|
13
|
+
* @param objects - Array of objects MUST be sorted by position (y for column, x for row direction)
|
|
14
|
+
* @param direction - Primary scroll direction: "column" (vertical) or "row" (horizontal)
|
|
15
|
+
* @param padding - Extra padding around viewport to include nearby objects
|
|
16
|
+
* @param minTriggerSize - Minimum array size to use binary search optimization
|
|
17
|
+
* @returns Array of visible objects sorted by zIndex
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* Objects must be pre-sorted by their start position (y for column direction, x for row direction).
|
|
21
|
+
* Unsorted input will produce incorrect results.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getObjectsInViewport<T extends ViewportObject>(viewport: ViewportBounds, objects: T[], direction?: "row" | "column", padding?: number, minTriggerSize?: number): T[];
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Writable } from "stream";
|
|
2
|
+
import { EventEmitter } from "events";
|
|
3
|
+
export type CapturedOutput = {
|
|
4
|
+
stream: "stdout" | "stderr";
|
|
5
|
+
output: string;
|
|
6
|
+
};
|
|
7
|
+
export declare class Capture extends EventEmitter {
|
|
8
|
+
private output;
|
|
9
|
+
constructor();
|
|
10
|
+
get size(): number;
|
|
11
|
+
write(stream: "stdout" | "stderr", data: string): void;
|
|
12
|
+
claimOutput(): string;
|
|
13
|
+
private clear;
|
|
14
|
+
}
|
|
15
|
+
export declare class CapturedWritableStream extends Writable {
|
|
16
|
+
private stream;
|
|
17
|
+
private capture;
|
|
18
|
+
isTTY: boolean;
|
|
19
|
+
columns: number;
|
|
20
|
+
rows: number;
|
|
21
|
+
constructor(stream: "stdout" | "stderr", capture: Capture);
|
|
22
|
+
_write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
|
|
23
|
+
getColorDepth(): number;
|
|
24
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
export declare const nonAlphanumericKeys: string[];
|
|
3
|
+
export type KeyEventType = "press" | "repeat" | "release";
|
|
4
|
+
export interface ParsedKey {
|
|
5
|
+
name: string;
|
|
6
|
+
ctrl: boolean;
|
|
7
|
+
meta: boolean;
|
|
8
|
+
shift: boolean;
|
|
9
|
+
option: boolean;
|
|
10
|
+
sequence: string;
|
|
11
|
+
number: boolean;
|
|
12
|
+
raw: string;
|
|
13
|
+
eventType: KeyEventType;
|
|
14
|
+
source: "raw" | "kitty";
|
|
15
|
+
code?: string;
|
|
16
|
+
super?: boolean;
|
|
17
|
+
hyper?: boolean;
|
|
18
|
+
capsLock?: boolean;
|
|
19
|
+
numLock?: boolean;
|
|
20
|
+
baseCode?: number;
|
|
21
|
+
repeated?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export type ParseKeypressOptions = {
|
|
24
|
+
useKittyKeyboard?: boolean;
|
|
25
|
+
};
|
|
26
|
+
export declare const parseKeypress: (s?: Buffer | string, options?: ParseKeypressOptions) => ParsedKey | null;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type MouseEventType = "down" | "up" | "move" | "drag" | "drag-end" | "drop" | "over" | "out" | "scroll";
|
|
2
|
+
export interface ScrollInfo {
|
|
3
|
+
direction: "up" | "down" | "left" | "right";
|
|
4
|
+
delta: number;
|
|
5
|
+
}
|
|
6
|
+
export type RawMouseEvent = {
|
|
7
|
+
type: MouseEventType;
|
|
8
|
+
button: number;
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
modifiers: {
|
|
12
|
+
shift: boolean;
|
|
13
|
+
alt: boolean;
|
|
14
|
+
ctrl: boolean;
|
|
15
|
+
};
|
|
16
|
+
scroll?: ScrollInfo;
|
|
17
|
+
};
|
|
18
|
+
export declare class MouseParser {
|
|
19
|
+
private mouseButtonsPressed;
|
|
20
|
+
private static readonly SCROLL_DIRECTIONS;
|
|
21
|
+
reset(): void;
|
|
22
|
+
private decodeInput;
|
|
23
|
+
parseMouseEvent(data: Buffer): RawMouseEvent | null;
|
|
24
|
+
parseAllMouseEvents(data: Buffer): RawMouseEvent[];
|
|
25
|
+
private parseMouseSequenceAt;
|
|
26
|
+
private parseSgrSequence;
|
|
27
|
+
private parseBasicSequence;
|
|
28
|
+
private decodeSgrEvent;
|
|
29
|
+
private decodeBasicEvent;
|
|
30
|
+
}
|
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,12 @@
|
|
|
1
|
+
import type { RenderableOptions, Renderable } from "../Renderable";
|
|
2
|
+
import type { PositionTypeString, OverflowString } from "./yoga.options";
|
|
3
|
+
export declare function validateOptions(id: string, options: RenderableOptions<Renderable>): void;
|
|
4
|
+
export declare function isValidPercentage(value: any): value is `${number}%`;
|
|
5
|
+
export declare function isMarginType(value: any): value is number | "auto" | `${number}%`;
|
|
6
|
+
export declare function isPaddingType(value: any): value is number | `${number}%`;
|
|
7
|
+
export declare function isPositionType(value: any): value is number | "auto" | `${number}%`;
|
|
8
|
+
export declare function isPositionTypeType(value: any): value is PositionTypeString;
|
|
9
|
+
export declare function isOverflowType(value: any): value is OverflowString;
|
|
10
|
+
export declare function isDimensionType(value: any): value is number | "auto" | `${number}%`;
|
|
11
|
+
export declare function isFlexBasisType(value: any): value is number | "auto" | undefined;
|
|
12
|
+
export declare function isSizeType(value: any): value is number | `${number}%` | undefined;
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Renderable, type ViewportBounds } from "..";
|
|
2
|
+
import { fonts } from "./ascii.font";
|
|
3
|
+
export declare class Selection {
|
|
4
|
+
private _anchor;
|
|
5
|
+
private _focus;
|
|
6
|
+
private _selectedRenderables;
|
|
7
|
+
private _touchedRenderables;
|
|
8
|
+
private _isActive;
|
|
9
|
+
private _isDragging;
|
|
10
|
+
private _isStart;
|
|
11
|
+
constructor(anchorRenderable: Renderable, anchor: {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
}, focus: {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
});
|
|
18
|
+
get isStart(): boolean;
|
|
19
|
+
set isStart(value: boolean);
|
|
20
|
+
get anchor(): {
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
};
|
|
24
|
+
get focus(): {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
};
|
|
28
|
+
set focus(value: {
|
|
29
|
+
x: number;
|
|
30
|
+
y: number;
|
|
31
|
+
});
|
|
32
|
+
get isActive(): boolean;
|
|
33
|
+
set isActive(value: boolean);
|
|
34
|
+
get isDragging(): boolean;
|
|
35
|
+
set isDragging(value: boolean);
|
|
36
|
+
get bounds(): ViewportBounds;
|
|
37
|
+
updateSelectedRenderables(selectedRenderables: Renderable[]): void;
|
|
38
|
+
get selectedRenderables(): Renderable[];
|
|
39
|
+
updateTouchedRenderables(touchedRenderables: Renderable[]): void;
|
|
40
|
+
get touchedRenderables(): Renderable[];
|
|
41
|
+
getSelectedText(): string;
|
|
42
|
+
}
|
|
43
|
+
export interface LocalSelectionBounds {
|
|
44
|
+
anchorX: number;
|
|
45
|
+
anchorY: number;
|
|
46
|
+
focusX: number;
|
|
47
|
+
focusY: number;
|
|
48
|
+
isActive: boolean;
|
|
49
|
+
}
|
|
50
|
+
export declare function convertGlobalToLocalSelection(globalSelection: Selection | null, localX: number, localY: number): LocalSelectionBounds | null;
|
|
51
|
+
export declare class ASCIIFontSelectionHelper {
|
|
52
|
+
private getText;
|
|
53
|
+
private getFont;
|
|
54
|
+
private localSelection;
|
|
55
|
+
constructor(getText: () => string, getFont: () => keyof typeof fonts);
|
|
56
|
+
hasSelection(): boolean;
|
|
57
|
+
getSelection(): {
|
|
58
|
+
start: number;
|
|
59
|
+
end: number;
|
|
60
|
+
} | null;
|
|
61
|
+
shouldStartSelection(localX: number, localY: number, width: number, height: number): boolean;
|
|
62
|
+
onLocalSelectionChanged(localSelection: LocalSelectionBounds | null, width: number, height: number): boolean;
|
|
63
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ensures a value is initialized once per process,
|
|
3
|
+
* persists across Bun hot reloads, and is type-safe.
|
|
4
|
+
*/
|
|
5
|
+
export declare function singleton<T>(key: string, factory: () => T): T;
|
|
6
|
+
export declare function destroySingleton(key: string): void;
|
|
7
|
+
export declare function hasSingleton(key: string): boolean;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StdinBuffer buffers input and emits complete sequences.
|
|
3
|
+
*
|
|
4
|
+
* This is necessary because stdin data events can arrive in partial chunks,
|
|
5
|
+
* especially for escape sequences like mouse events. Without buffering,
|
|
6
|
+
* partial sequences can be misinterpreted as regular keypresses.
|
|
7
|
+
*
|
|
8
|
+
* For example, the mouse SGR sequence `\x1b[<35;20;5m` might arrive as:
|
|
9
|
+
* - Event 1: `\x1b`
|
|
10
|
+
* - Event 2: `[<35`
|
|
11
|
+
* - Event 3: `;20;5m`
|
|
12
|
+
*
|
|
13
|
+
* The buffer accumulates these until a complete sequence is detected.
|
|
14
|
+
* Call the `process()` method to feed input data.
|
|
15
|
+
*/
|
|
16
|
+
import { EventEmitter } from "events";
|
|
17
|
+
export type StdinBufferOptions = {
|
|
18
|
+
/**
|
|
19
|
+
* Maximum time to wait for sequence completion (default: 10ms)
|
|
20
|
+
* After this time, the buffer is flushed even if incomplete
|
|
21
|
+
*/
|
|
22
|
+
timeout?: number;
|
|
23
|
+
};
|
|
24
|
+
export type StdinBufferEventMap = {
|
|
25
|
+
data: [string];
|
|
26
|
+
paste: [string];
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Buffers stdin input and emits complete sequences via the 'data' event.
|
|
30
|
+
* Handles partial escape sequences that arrive across multiple chunks.
|
|
31
|
+
*/
|
|
32
|
+
export declare class StdinBuffer extends EventEmitter<StdinBufferEventMap> {
|
|
33
|
+
private buffer;
|
|
34
|
+
private timeout;
|
|
35
|
+
private readonly timeoutMs;
|
|
36
|
+
private pasteMode;
|
|
37
|
+
private pasteBuffer;
|
|
38
|
+
constructor(options?: StdinBufferOptions);
|
|
39
|
+
process(data: string | Buffer): void;
|
|
40
|
+
flush(): string[];
|
|
41
|
+
clear(): void;
|
|
42
|
+
getBuffer(): string;
|
|
43
|
+
destroy(): void;
|
|
44
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { TextChunk } from "../text-buffer";
|
|
2
|
+
import { type ColorInput } from "./RGBA";
|
|
3
|
+
declare const BrandedStyledText: unique symbol;
|
|
4
|
+
export type Color = ColorInput;
|
|
5
|
+
export interface StyleAttrs {
|
|
6
|
+
fg?: Color;
|
|
7
|
+
bg?: Color;
|
|
8
|
+
bold?: boolean;
|
|
9
|
+
italic?: boolean;
|
|
10
|
+
underline?: boolean;
|
|
11
|
+
strikethrough?: boolean;
|
|
12
|
+
dim?: boolean;
|
|
13
|
+
reverse?: boolean;
|
|
14
|
+
blink?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function isStyledText(obj: any): obj is StyledText;
|
|
17
|
+
export declare class StyledText {
|
|
18
|
+
[BrandedStyledText]: boolean;
|
|
19
|
+
chunks: TextChunk[];
|
|
20
|
+
constructor(chunks: TextChunk[]);
|
|
21
|
+
}
|
|
22
|
+
export declare function stringToStyledText(content: string): StyledText;
|
|
23
|
+
export type StylableInput = string | number | boolean | TextChunk;
|
|
24
|
+
export declare const black: (input: StylableInput) => TextChunk;
|
|
25
|
+
export declare const red: (input: StylableInput) => TextChunk;
|
|
26
|
+
export declare const green: (input: StylableInput) => TextChunk;
|
|
27
|
+
export declare const yellow: (input: StylableInput) => TextChunk;
|
|
28
|
+
export declare const blue: (input: StylableInput) => TextChunk;
|
|
29
|
+
export declare const magenta: (input: StylableInput) => TextChunk;
|
|
30
|
+
export declare const cyan: (input: StylableInput) => TextChunk;
|
|
31
|
+
export declare const white: (input: StylableInput) => TextChunk;
|
|
32
|
+
export declare const brightBlack: (input: StylableInput) => TextChunk;
|
|
33
|
+
export declare const brightRed: (input: StylableInput) => TextChunk;
|
|
34
|
+
export declare const brightGreen: (input: StylableInput) => TextChunk;
|
|
35
|
+
export declare const brightYellow: (input: StylableInput) => TextChunk;
|
|
36
|
+
export declare const brightBlue: (input: StylableInput) => TextChunk;
|
|
37
|
+
export declare const brightMagenta: (input: StylableInput) => TextChunk;
|
|
38
|
+
export declare const brightCyan: (input: StylableInput) => TextChunk;
|
|
39
|
+
export declare const brightWhite: (input: StylableInput) => TextChunk;
|
|
40
|
+
export declare const bgBlack: (input: StylableInput) => TextChunk;
|
|
41
|
+
export declare const bgRed: (input: StylableInput) => TextChunk;
|
|
42
|
+
export declare const bgGreen: (input: StylableInput) => TextChunk;
|
|
43
|
+
export declare const bgYellow: (input: StylableInput) => TextChunk;
|
|
44
|
+
export declare const bgBlue: (input: StylableInput) => TextChunk;
|
|
45
|
+
export declare const bgMagenta: (input: StylableInput) => TextChunk;
|
|
46
|
+
export declare const bgCyan: (input: StylableInput) => TextChunk;
|
|
47
|
+
export declare const bgWhite: (input: StylableInput) => TextChunk;
|
|
48
|
+
export declare const bold: (input: StylableInput) => TextChunk;
|
|
49
|
+
export declare const italic: (input: StylableInput) => TextChunk;
|
|
50
|
+
export declare const underline: (input: StylableInput) => TextChunk;
|
|
51
|
+
export declare const strikethrough: (input: StylableInput) => TextChunk;
|
|
52
|
+
export declare const dim: (input: StylableInput) => TextChunk;
|
|
53
|
+
export declare const reverse: (input: StylableInput) => TextChunk;
|
|
54
|
+
export declare const blink: (input: StylableInput) => TextChunk;
|
|
55
|
+
export declare const fg: (color: Color) => (input: StylableInput) => TextChunk;
|
|
56
|
+
export declare const bg: (color: Color) => (input: StylableInput) => TextChunk;
|
|
57
|
+
export declare const link: (url: string) => (input: StylableInput) => TextChunk;
|
|
58
|
+
/**
|
|
59
|
+
* Template literal handler for styled text (non-cached version).
|
|
60
|
+
* Returns a StyledText object containing chunks of text with optional styles.
|
|
61
|
+
*/
|
|
62
|
+
export declare function t(strings: TemplateStringsArray, ...values: StylableInput[]): StyledText;
|
|
63
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terminal capability response detection utilities.
|
|
3
|
+
*
|
|
4
|
+
* Detects various terminal capability response sequences:
|
|
5
|
+
* - DECRPM (DEC Request Mode): ESC[?...;N$y where N is 0,1,2,3,4
|
|
6
|
+
* - CPR (Cursor Position Report): ESC[row;colR (used for width detection)
|
|
7
|
+
* - XTVersion: ESC P >| ... ESC \
|
|
8
|
+
* - Kitty Graphics: ESC _ G ... ESC \
|
|
9
|
+
* - Kitty Keyboard Query: ESC[?Nu where N is 0,1,2,etc
|
|
10
|
+
* - DA1 (Device Attributes): ESC[?...c
|
|
11
|
+
* - Pixel Resolution: ESC[4;height;widtht
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Check if a sequence is a terminal capability response.
|
|
15
|
+
* Returns true if the sequence matches any known capability response pattern.
|
|
16
|
+
*/
|
|
17
|
+
export declare function isCapabilityResponse(sequence: string): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Check if a sequence is a pixel resolution response.
|
|
20
|
+
* Format: ESC[4;height;widtht
|
|
21
|
+
*/
|
|
22
|
+
export declare function isPixelResolutionResponse(sequence: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Parse pixel resolution from response sequence.
|
|
25
|
+
* Returns { width, height } or null if not a valid resolution response.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parsePixelResolution(sequence: string): {
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
} | null;
|