@tuidom/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/dist/backend/iTerminalBackend.d.ts +41 -0
- package/dist/backend/iTerminalBackend.js +1 -0
- package/dist/common/colorUtils.d.ts +19 -0
- package/dist/common/colorUtils.js +30 -0
- package/dist/common/displayLine.d.ts +72 -0
- package/dist/common/displayLine.js +190 -0
- package/dist/common/disposable.d.ts +9 -0
- package/dist/common/disposable.js +18 -0
- package/dist/common/geometryPromitives.d.ts +47 -0
- package/dist/common/geometryPromitives.js +115 -0
- package/dist/common/iTerminalSurface.d.ts +68 -0
- package/dist/common/iTerminalSurface.js +8 -0
- package/dist/common/measureTextWidth.d.ts +21 -0
- package/dist/common/measureTextWidth.js +43 -0
- package/dist/common/styleFlags.d.ts +17 -0
- package/dist/common/styleFlags.js +16 -0
- package/dist/common/textTruncation.d.ts +30 -0
- package/dist/common/textTruncation.js +124 -0
- package/dist/common/typingUtils.d.ts +1 -0
- package/dist/common/typingUtils.js +3 -0
- package/dist/common/unicodeWidth.d.ts +18 -0
- package/dist/common/unicodeWidth.js +339 -0
- package/dist/dom/borderStyle.d.ts +31 -0
- package/dist/dom/borderStyle.js +40 -0
- package/dist/dom/compositeElement.d.ts +20 -0
- package/dist/dom/compositeElement.js +44 -0
- package/dist/dom/events/contextMenuEventSource.d.ts +17 -0
- package/dist/dom/events/contextMenuEventSource.js +44 -0
- package/dist/dom/events/focusManager.d.ts +13 -0
- package/dist/dom/events/focusManager.js +56 -0
- package/dist/dom/events/mouseEventDispatcher.d.ts +24 -0
- package/dist/dom/events/mouseEventDispatcher.js +177 -0
- package/dist/dom/events/tuiEventBase.d.ts +25 -0
- package/dist/dom/events/tuiEventBase.js +39 -0
- package/dist/dom/events/tuiFocusEvent.d.ts +6 -0
- package/dist/dom/events/tuiFocusEvent.js +8 -0
- package/dist/dom/events/tuiKeyboardEvent.d.ts +21 -0
- package/dist/dom/events/tuiKeyboardEvent.js +20 -0
- package/dist/dom/events/tuiMouseEvent.d.ts +40 -0
- package/dist/dom/events/tuiMouseEvent.js +32 -0
- package/dist/dom/events/tuiPasteEvent.d.ts +10 -0
- package/dist/dom/events/tuiPasteEvent.js +13 -0
- package/dist/dom/overlayLayer.d.ts +92 -0
- package/dist/dom/overlayLayer.js +343 -0
- package/dist/dom/styles/index.d.ts +4 -0
- package/dist/dom/styles/index.js +2 -0
- package/dist/dom/styles/styleTokens.d.ts +114 -0
- package/dist/dom/styles/styleTokens.js +122 -0
- package/dist/dom/styles/tuiStyle.d.ts +75 -0
- package/dist/dom/styles/tuiStyle.js +121 -0
- package/dist/dom/tuiApplication.d.ts +57 -0
- package/dist/dom/tuiApplication.js +231 -0
- package/dist/dom/tuiElement.d.ts +528 -0
- package/dist/dom/tuiElement.js +1168 -0
- package/dist/dom/tuiSelector.d.ts +9 -0
- package/dist/dom/tuiSelector.js +82 -0
- package/dist/dom/validateTree.d.ts +42 -0
- package/dist/dom/validateTree.js +125 -0
- package/dist/input/convertToken.d.ts +3 -0
- package/dist/input/convertToken.js +114 -0
- package/dist/input/keyEvent.d.ts +46 -0
- package/dist/input/keyEvent.js +26 -0
- package/dist/input/keyInputParser.d.ts +72 -0
- package/dist/input/keyInputParser.js +249 -0
- package/dist/input/mouseTracking.d.ts +18 -0
- package/dist/input/mouseTracking.js +18 -0
- package/dist/input/parseInput.d.ts +13 -0
- package/dist/input/parseInput.js +17 -0
- package/dist/input/rawTerminalToken.d.ts +142 -0
- package/dist/input/rawTerminalToken.js +2 -0
- package/dist/input/serializeKey.d.ts +14 -0
- package/dist/input/serializeKey.js +179 -0
- package/dist/input/serializeMouse.d.ts +26 -0
- package/dist/input/serializeMouse.js +38 -0
- package/dist/input/tokenize.d.ts +59 -0
- package/dist/input/tokenize.js +681 -0
- package/dist/rendering/cell.d.ts +24 -0
- package/dist/rendering/cell.js +46 -0
- package/dist/rendering/damage.d.ts +35 -0
- package/dist/rendering/damage.js +99 -0
- package/dist/rendering/grid.d.ts +49 -0
- package/dist/rendering/grid.js +216 -0
- package/dist/rendering/gridSnapshot.d.ts +33 -0
- package/dist/rendering/gridSnapshot.js +32 -0
- package/dist/rendering/gridToSvg.d.ts +29 -0
- package/dist/rendering/gridToSvg.js +145 -0
- package/dist/rendering/terminalRenderer.d.ts +28 -0
- package/dist/rendering/terminalRenderer.js +161 -0
- package/dist/rendering/terminalScreen.d.ts +25 -0
- package/dist/rendering/terminalScreen.js +50 -0
- package/package.json +29 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a mouse event description to the raw SGR (1006) terminal sequence.
|
|
3
|
+
* Inverse of the mouse branch of `tokenize` — the counterpart of
|
|
4
|
+
* {@link import("./serializeKey.js").serializeKey} for the pointer:
|
|
5
|
+
* serializeMouse({ action: "press", button: "left", x: 1, y: 1 }) → '\x1b[<0;1;1M'
|
|
6
|
+
* serializeMouse({ action: "release", button: "left", x: 4, y: 2 }) → '\x1b[<0;4;2m'
|
|
7
|
+
* serializeMouse({ action: "scroll-down", x: 4, y: 2 }) → '\x1b[<65;4;2M'
|
|
8
|
+
* serializeMouse({ action: "move", button: "left", x: 4, y: 2 }) → '\x1b[<32;4;2M'
|
|
9
|
+
*
|
|
10
|
+
* Coordinates are 1-based, exactly as they arrive from a terminal and as
|
|
11
|
+
* {@link MouseToken} carries them.
|
|
12
|
+
*/
|
|
13
|
+
import type { MouseAction, MouseButton } from "./rawTerminalToken.js";
|
|
14
|
+
export interface SerializeMouseInit {
|
|
15
|
+
action: MouseAction;
|
|
16
|
+
/** Defaults to `"none"` — the only meaningful button for scroll actions. */
|
|
17
|
+
button?: MouseButton;
|
|
18
|
+
/** 1-based column */
|
|
19
|
+
x: number;
|
|
20
|
+
/** 1-based row */
|
|
21
|
+
y: number;
|
|
22
|
+
shiftKey?: boolean;
|
|
23
|
+
altKey?: boolean;
|
|
24
|
+
ctrlKey?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare function serializeMouse(init: SerializeMouseInit): string;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a mouse event description to the raw SGR (1006) terminal sequence.
|
|
3
|
+
* Inverse of the mouse branch of `tokenize` — the counterpart of
|
|
4
|
+
* {@link import("./serializeKey.ts").serializeKey} for the pointer:
|
|
5
|
+
* serializeMouse({ action: "press", button: "left", x: 1, y: 1 }) → '\x1b[<0;1;1M'
|
|
6
|
+
* serializeMouse({ action: "release", button: "left", x: 4, y: 2 }) → '\x1b[<0;4;2m'
|
|
7
|
+
* serializeMouse({ action: "scroll-down", x: 4, y: 2 }) → '\x1b[<65;4;2M'
|
|
8
|
+
* serializeMouse({ action: "move", button: "left", x: 4, y: 2 }) → '\x1b[<32;4;2M'
|
|
9
|
+
*
|
|
10
|
+
* Coordinates are 1-based, exactly as they arrive from a terminal and as
|
|
11
|
+
* {@link MouseToken} carries them.
|
|
12
|
+
*/
|
|
13
|
+
/** Bits 0-1 of the button byte. `none` maps to 3, the "no button" encoding. */
|
|
14
|
+
const buttonBits = { left: 0, middle: 1, right: 2, none: 3 };
|
|
15
|
+
/** Scroll actions live at 64 + wheel direction (up/down/left/right). */
|
|
16
|
+
const scrollBits = {
|
|
17
|
+
"scroll-up": 64,
|
|
18
|
+
"scroll-down": 65,
|
|
19
|
+
"scroll-left": 66,
|
|
20
|
+
"scroll-right": 67,
|
|
21
|
+
};
|
|
22
|
+
export function serializeMouse(init) {
|
|
23
|
+
const { action, x, y } = init;
|
|
24
|
+
const button = init.button ?? "none";
|
|
25
|
+
let cb = scrollBits[action] ?? buttonBits[button];
|
|
26
|
+
if (action === "move")
|
|
27
|
+
cb |= 32;
|
|
28
|
+
if (init.shiftKey === true)
|
|
29
|
+
cb |= 4;
|
|
30
|
+
if (init.altKey === true)
|
|
31
|
+
cb |= 8;
|
|
32
|
+
if (init.ctrlKey === true)
|
|
33
|
+
cb |= 16;
|
|
34
|
+
// SGR distinguishes release from press by the final byte, not by the button
|
|
35
|
+
// bits — that is exactly why we speak 1006 and not the legacy X10 form.
|
|
36
|
+
const finalByte = action === "release" ? "m" : "M";
|
|
37
|
+
return `\x1b[<${String(cb)};${String(x)};${String(y)}${finalByte}`;
|
|
38
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { CsiLetterToken, CsiTildeToken, CsiUToken, DeviceReportToken, MouseToken, OscToken, RawTerminalToken, UnknownCsiToken } from "./rawTerminalToken.js";
|
|
2
|
+
export declare function tokenize(data: string): RawTerminalToken[];
|
|
3
|
+
/**
|
|
4
|
+
* Map Kitty Keyboard Protocol codepoints (Private Use Area U+E000+) to DOM-style key/code.
|
|
5
|
+
* Also includes standard codepoints used in CSI u for common keys (Enter, Tab, etc.).
|
|
6
|
+
*
|
|
7
|
+
* Reference: https://sw.kovidgoyal.net/kitty/keyboard-protocol/#functional-key-definitions
|
|
8
|
+
*/
|
|
9
|
+
export declare const kittyCodepointMap: Partial<Record<number, {
|
|
10
|
+
key: string;
|
|
11
|
+
code?: string;
|
|
12
|
+
}>>;
|
|
13
|
+
/** CSI final-byte → key name (cursor keys, F1–F4) */
|
|
14
|
+
export declare const csiKeyMap: Partial<Record<string, string>>;
|
|
15
|
+
/** CSI number~ → key name (navigation, F5–F12) */
|
|
16
|
+
export declare const tildeKeyMap: Partial<Record<number, string>>;
|
|
17
|
+
/** SS3 (ESC O) final-byte → key name */
|
|
18
|
+
export declare const ss3KeyMap: Partial<Record<string, string>>;
|
|
19
|
+
/**
|
|
20
|
+
* Decode xterm/kitty modifier parameter into individual boolean flags.
|
|
21
|
+
*
|
|
22
|
+
* Modifier encoding: value = 1 + bitmask
|
|
23
|
+
* Bitmask bits: 0=Shift, 1=Alt, 2=Ctrl, 3=Super(Meta), 4=Hyper, 5=Meta, 6=CapsLock, 7=NumLock
|
|
24
|
+
*/
|
|
25
|
+
export declare function decodeModifiers(mod: number): {
|
|
26
|
+
shiftKey: boolean;
|
|
27
|
+
altKey: boolean;
|
|
28
|
+
ctrlKey: boolean;
|
|
29
|
+
metaKey: boolean;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Infer a DOM-style `code` from a key value.
|
|
33
|
+
* Best-effort for traditional terminal mode (no physical key info available).
|
|
34
|
+
*/
|
|
35
|
+
export declare function inferCode(key: string): string;
|
|
36
|
+
interface CSITokenResult {
|
|
37
|
+
token: CsiUToken | CsiLetterToken | CsiTildeToken | MouseToken | DeviceReportToken | UnknownCsiToken;
|
|
38
|
+
nextIndex: number;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Parse a CSI sequence starting at data[start] = ESC, data[start+1] = '['.
|
|
42
|
+
* Returns the parsed token and next index, or null if the sequence is not recognized.
|
|
43
|
+
*
|
|
44
|
+
* A `null` return also signals an *incomplete* sequence (e.g. the chunk was cut
|
|
45
|
+
* mid-sequence by stdin packetization) — KeyInputParser relies on this to buffer
|
|
46
|
+
* the tail until the rest arrives. See KeyInputParser.incompleteTailStart.
|
|
47
|
+
*/
|
|
48
|
+
export declare function parseCSI(data: string, start: number): CSITokenResult | null;
|
|
49
|
+
interface OSCTokenResult {
|
|
50
|
+
token: OscToken;
|
|
51
|
+
nextIndex: number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Parse an OSC sequence starting at data[start] = ESC, data[start+1] = ']'.
|
|
55
|
+
* OSC is terminated by BEL (\x07) or ST (\x1b\\).
|
|
56
|
+
* Returns null if the sequence is not complete.
|
|
57
|
+
*/
|
|
58
|
+
export declare function parseOSC(data: string, start: number): OSCTokenResult | null;
|
|
59
|
+
export {};
|