@aurigax-ai/ghostty-web 0.0.0-stage → 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/GHOSTTY_COMMIT +1 -0
- package/LICENSE +22 -0
- package/README.md +90 -2
- package/ghostty-vt.wasm +0 -0
- package/lib/abi.ts +227 -0
- package/lib/addons/fit.ts +242 -0
- package/lib/buffer.ts +402 -0
- package/lib/event-emitter.ts +27 -0
- package/lib/ghostty.ts +1135 -0
- package/lib/index.ts +110 -0
- package/lib/input-handler.ts +1104 -0
- package/lib/interfaces.ts +218 -0
- package/lib/link-detector.ts +215 -0
- package/lib/marker.ts +55 -0
- package/lib/providers/osc8-link-provider.ts +144 -0
- package/lib/providers/url-regex-provider.ts +150 -0
- package/lib/renderer.ts +958 -0
- package/lib/selection-manager.ts +1052 -0
- package/lib/terminal.ts +2026 -0
- package/lib/types.ts +648 -0
- package/package.json +70 -4
package/lib/index.ts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public API for @cmux/ghostty-terminal
|
|
3
|
+
*
|
|
4
|
+
* Main entry point following xterm.js conventions
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Ghostty } from './ghostty';
|
|
8
|
+
|
|
9
|
+
// Module-level Ghostty instance (initialized by init())
|
|
10
|
+
let ghosttyInstance: Ghostty | null = null;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Initialize the ghostty-web library by loading the WASM module.
|
|
14
|
+
* Must be called before creating any Terminal instances.
|
|
15
|
+
*
|
|
16
|
+
* This creates a shared WASM instance that all Terminal instances will use.
|
|
17
|
+
* For test isolation, pass a Ghostty instance directly to Terminal constructor.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { init, Terminal } from 'ghostty-web';
|
|
22
|
+
*
|
|
23
|
+
* await init();
|
|
24
|
+
* const term = new Terminal();
|
|
25
|
+
* term.open(document.getElementById('terminal'));
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export async function init(): Promise<void> {
|
|
29
|
+
if (ghosttyInstance) {
|
|
30
|
+
return; // Already initialized
|
|
31
|
+
}
|
|
32
|
+
ghosttyInstance = await Ghostty.load();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Get the initialized Ghostty instance.
|
|
37
|
+
* Throws if init() hasn't been called.
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
40
|
+
export function getGhostty(): Ghostty {
|
|
41
|
+
if (!ghosttyInstance) {
|
|
42
|
+
throw new Error(
|
|
43
|
+
'ghostty-web not initialized. Call init() before creating Terminal instances.\n' +
|
|
44
|
+
'Example:\n' +
|
|
45
|
+
' import { init, Terminal } from "@aurigax-ai/ghostty-web";\n' +
|
|
46
|
+
' await init();\n' +
|
|
47
|
+
' const term = new Terminal();\n\n' +
|
|
48
|
+
'For tests, pass a Ghostty instance directly:\n' +
|
|
49
|
+
' import { Ghostty, Terminal } from "@aurigax-ai/ghostty-web";\n' +
|
|
50
|
+
' const ghostty = await Ghostty.load();\n' +
|
|
51
|
+
' const term = new Terminal({ ghostty });'
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
return ghosttyInstance;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Main Terminal class
|
|
58
|
+
export { Terminal } from './terminal';
|
|
59
|
+
|
|
60
|
+
// xterm.js-compatible interfaces
|
|
61
|
+
export type {
|
|
62
|
+
ITerminalOptions,
|
|
63
|
+
ITheme,
|
|
64
|
+
ITerminalAddon,
|
|
65
|
+
ITerminalCore,
|
|
66
|
+
IDisposable,
|
|
67
|
+
IEvent,
|
|
68
|
+
IBufferRange,
|
|
69
|
+
IKeyEvent,
|
|
70
|
+
IUnicodeVersionProvider,
|
|
71
|
+
} from './interfaces';
|
|
72
|
+
|
|
73
|
+
// Ghostty WASM components (for advanced usage)
|
|
74
|
+
export {
|
|
75
|
+
Ghostty,
|
|
76
|
+
GhosttyTerminal,
|
|
77
|
+
KeyEncoder,
|
|
78
|
+
CellFlags,
|
|
79
|
+
DirtyState,
|
|
80
|
+
KeyEncoderOption,
|
|
81
|
+
} from './ghostty';
|
|
82
|
+
export type {
|
|
83
|
+
DesktopNotificationEvent,
|
|
84
|
+
MouseTrackingMode,
|
|
85
|
+
SemanticPromptEvent,
|
|
86
|
+
SemanticPromptKind,
|
|
87
|
+
TrackedRow,
|
|
88
|
+
} from './ghostty';
|
|
89
|
+
export type { IMarker } from './marker';
|
|
90
|
+
export { Abi, GhosttyCallError } from './abi';
|
|
91
|
+
export { Key, KeyAction, Mods } from './types';
|
|
92
|
+
export type { KeyEvent, GhosttyCell, RGB, Cursor, TerminalHandle } from './types';
|
|
93
|
+
|
|
94
|
+
// Low-level components (for custom integrations)
|
|
95
|
+
export { CanvasRenderer } from './renderer';
|
|
96
|
+
export type { RendererOptions, FontMetrics, IRenderable } from './renderer';
|
|
97
|
+
export { InputHandler } from './input-handler';
|
|
98
|
+
export { EventEmitter } from './event-emitter';
|
|
99
|
+
export { SelectionManager } from './selection-manager';
|
|
100
|
+
export type { SelectionCoordinates } from './selection-manager';
|
|
101
|
+
|
|
102
|
+
// Addons
|
|
103
|
+
export { FitAddon } from './addons/fit';
|
|
104
|
+
export type { ITerminalDimensions } from './addons/fit';
|
|
105
|
+
|
|
106
|
+
// Link providers
|
|
107
|
+
export { OSC8LinkProvider } from './providers/osc8-link-provider';
|
|
108
|
+
export { UrlRegexProvider } from './providers/url-regex-provider';
|
|
109
|
+
export { LinkDetector } from './link-detector';
|
|
110
|
+
export type { ILink, ILinkProvider, IBufferCellPosition } from './types';
|