@monaco-neovim-wasm/lib 0.1.6

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.
@@ -0,0 +1,262 @@
1
+ import type { editor as MonacoEditor } from "monaco-editor";
2
+ import { NeovimWasmSession, type NeovimWasmInputMode } from "./neovimWasmSession";
3
+ export type StatusEmitter = (text: string, warn?: boolean) => void;
4
+ export type ClipboardAdapter = {
5
+ readText?: () => Promise<string>;
6
+ writeText?: (text: string) => Promise<void>;
7
+ };
8
+ export type FileSystemAdapter = {
9
+ readFile?: (path: string) => Promise<string | Uint8Array | null | undefined>;
10
+ writeFile?: (path: string, data: string | Uint8Array) => Promise<void>;
11
+ };
12
+ export type HostCommand = {
13
+ action: "edit";
14
+ path?: string;
15
+ bang?: boolean;
16
+ } | {
17
+ action: "write";
18
+ path?: string;
19
+ bang?: boolean;
20
+ } | {
21
+ action: "quit";
22
+ bang?: boolean;
23
+ } | {
24
+ action: "wq";
25
+ bang?: boolean;
26
+ } | {
27
+ action: string;
28
+ [k: string]: unknown;
29
+ };
30
+ export type MonacoNeovimOptions = {
31
+ worker?: Worker | null;
32
+ workerUrl?: URL;
33
+ reuseWorker?: boolean;
34
+ wasmPath?: string;
35
+ runtimePath?: string;
36
+ inputMode?: NeovimWasmInputMode;
37
+ env?: Record<string, string>;
38
+ files?: Array<{
39
+ path: string;
40
+ data: Uint8Array | string;
41
+ }>;
42
+ sharedInputBytes?: number;
43
+ cols?: number;
44
+ rows?: number;
45
+ minCols?: number;
46
+ minRows?: number;
47
+ autoResize?: boolean;
48
+ resizeDebounceMs?: number;
49
+ syncWrap?: boolean;
50
+ wrapStrategy?: "simple" | "advanced";
51
+ syncTabstop?: boolean;
52
+ wrappedLineMotions?: boolean;
53
+ scrollMotions?: boolean;
54
+ scrolloff?: number;
55
+ syncScrolloff?: boolean;
56
+ ctrlKeysForNormalMode?: string[];
57
+ ctrlKeysForInsertMode?: string[];
58
+ altKeysForNormalMode?: string[];
59
+ altKeysForInsertMode?: string[];
60
+ metaKeysForNormalMode?: string[];
61
+ metaKeysForInsertMode?: string[];
62
+ searchHighlights?: boolean;
63
+ hostCommands?: boolean;
64
+ fileSystem?: FileSystemAdapter | null;
65
+ onHostCommand?: (cmd: HostCommand) => void | Promise<void>;
66
+ status?: StatusEmitter;
67
+ seedLines?: string[];
68
+ seedName?: string;
69
+ seedFiletype?: string;
70
+ uiAttach?: boolean;
71
+ uiAttachOptions?: {
72
+ ext_cmdline?: boolean;
73
+ ext_messages?: boolean;
74
+ ext_popupmenu?: boolean;
75
+ rgb?: boolean;
76
+ };
77
+ startupCommands?: string[];
78
+ startupLua?: string;
79
+ visualThemeName?: string;
80
+ rpcTimeoutMs?: number;
81
+ clipboard?: ClipboardAdapter | null;
82
+ onStderr?: (text: string) => void;
83
+ onStartError?: (message?: string) => void;
84
+ onExit?: (code: number, lastStderr?: string) => void;
85
+ onWarning?: (message: string) => void;
86
+ onModeChange?: (mode: string) => void;
87
+ onCmdline?: (text: string | null) => void;
88
+ onMessage?: (text: string | null) => void;
89
+ onPopupmenu?: (items: PopupMenuItem[] | null, selected: number) => void;
90
+ cmdlineContainer?: HTMLElement | null;
91
+ shouldHandleKey?: (ev: KeyboardEvent) => boolean;
92
+ translateKey?: (ev: KeyboardEvent) => string | null;
93
+ };
94
+ export type PopupMenuItem = {
95
+ word: string;
96
+ kind?: string;
97
+ menu?: string;
98
+ info?: string;
99
+ };
100
+ export declare class MonacoNeovimClient {
101
+ private readonly editor;
102
+ private readonly opts;
103
+ private session;
104
+ private bufHandle;
105
+ private uiCols;
106
+ private uiRows;
107
+ private resizeTimer;
108
+ private wrapColumnApplied;
109
+ private wrapStrategyApplied;
110
+ private primeSent;
111
+ private lastCursorPos;
112
+ private suppressCursorSync;
113
+ private lastMode;
114
+ private visualSelectionToken;
115
+ private visualSelectionActive;
116
+ private visualDecorationIds;
117
+ private visualStyleEl;
118
+ private visualBgCss;
119
+ private cursorRefreshTimer;
120
+ private cursorRefreshInFlight;
121
+ private cursorRefreshPending;
122
+ private disposables;
123
+ private notifyChain;
124
+ private nvimChannelId;
125
+ private hostAutocmdInstalled;
126
+ private nvimScrolloff;
127
+ private ctrlKeysNormal;
128
+ private ctrlKeysInsert;
129
+ private altKeysNormal;
130
+ private altKeysInsert;
131
+ private metaKeysNormal;
132
+ private metaKeysInsert;
133
+ private searchDecorationIds;
134
+ private searchStyleEl;
135
+ private searchRefreshTimer;
136
+ private searchRefreshInFlight;
137
+ private searchRefreshPending;
138
+ private execLuaAvailable;
139
+ private visualSelectionRefreshTimer;
140
+ private lastCursorStyle;
141
+ private lastCursorBlink;
142
+ private lastCursorWidth;
143
+ private initialCursorWidth;
144
+ private typicalFullWidth;
145
+ private nextSeedLines;
146
+ private cmdlineEl;
147
+ private cmdlineVisible;
148
+ private messageEl;
149
+ private messageTimer;
150
+ private popupEl;
151
+ private popupItems;
152
+ private popupSelected;
153
+ private preeditEl;
154
+ private preeditVisible;
155
+ private compositionActive;
156
+ private pendingResyncAfterComposition;
157
+ private ignoreNextInputEvent;
158
+ private ignoreTextKeydownUntil;
159
+ private optimisticCursorUntil;
160
+ private optimisticCursorPos;
161
+ private optimisticCursorPrevPos;
162
+ private delegateInsertToMonaco;
163
+ private applyingFromNvim;
164
+ private buffers;
165
+ private buffersByName;
166
+ private cursorSyncTimer;
167
+ private modelContentDisposable;
168
+ private originalOptions;
169
+ private resyncTimer;
170
+ constructor(editor: MonacoEditor.IStandaloneCodeEditor, options?: MonacoNeovimOptions);
171
+ start(seedLines?: string[]): Promise<void>;
172
+ stop(silent?: boolean): void;
173
+ dispose(): void;
174
+ notify(method: string, params?: unknown[]): void;
175
+ call<T = unknown>(method: string, params?: unknown[]): Promise<T>;
176
+ command(cmd: string): void;
177
+ input(keys: string): void;
178
+ paste(text: string): void;
179
+ execLua<T = unknown>(code: string, args?: unknown[]): Promise<T>;
180
+ getSession(): NeovimWasmSession | null;
181
+ resize(cols: number, rows: number): void;
182
+ resizeToEditor(): void;
183
+ private attachEditorListeners;
184
+ private computeGridSize;
185
+ private scheduleResizeToEditor;
186
+ private ensurePreeditUi;
187
+ private setPreedit;
188
+ private applyOptimisticInsert;
189
+ private positionPreedit;
190
+ private disposeEditorListeners;
191
+ private attachActiveModelListener;
192
+ private getActiveState;
193
+ private ensureActiveState;
194
+ private clearBufferStates;
195
+ private primeSession;
196
+ private handleClipboardCopy;
197
+ private handleRequest;
198
+ private handleNotify;
199
+ private applyLinePatch;
200
+ private applyLinePatchToModel;
201
+ private setModelText;
202
+ private initCmdlineUi;
203
+ private setCmdline;
204
+ private setMessage;
205
+ private setPopupmenu;
206
+ private applyMonacoWrap;
207
+ private applyMonacoCursorMove;
208
+ private getScrolloffLines;
209
+ private applyScrolloff;
210
+ private applyMonacoScroll;
211
+ private applyMonacoReveal;
212
+ private applyMonacoMoveCursor;
213
+ private syncTabstopFromMonaco;
214
+ private updatePopupmenuSelection;
215
+ private handleRedraw;
216
+ private initTextInputListeners;
217
+ private scheduleResync;
218
+ private resyncBufferFromNvim;
219
+ private applyBuffer;
220
+ private ensureVisualStyle;
221
+ private setVisualBgCss;
222
+ private clearVisualDecorations;
223
+ private ensureSearchStyle;
224
+ private clearSearchHighlights;
225
+ private scheduleSearchHighlightRefresh;
226
+ private refreshSearchHighlights;
227
+ private applySearchHighlights;
228
+ private applyVisualDecorations;
229
+ private applyNvimMode;
230
+ private handleKey;
231
+ private handleMouse;
232
+ private sendInput;
233
+ private modifiedKeyName;
234
+ private hasExplicitModAllowlist;
235
+ private shouldForwardModifiedKeys;
236
+ private pasteText;
237
+ private handleMonacoModelChange;
238
+ private scheduleCursorSyncToNvim;
239
+ private scheduleFlushPendingMonacoSync;
240
+ private flushPendingMonacoSync;
241
+ private syncCursorToNvimNow;
242
+ private scheduleVisualSelectionRefresh;
243
+ private installHostAutocmds;
244
+ private handleHostCommand;
245
+ private handleBufEnter;
246
+ private handleBufDelete;
247
+ private openText;
248
+ private sendNotify;
249
+ private sendRpcResponse;
250
+ private rpcCall;
251
+ private doClipboardPaste;
252
+ private updateCursor;
253
+ private scheduleCursorRefresh;
254
+ private refreshCursorMode;
255
+ private applyCursorStyle;
256
+ private updateVisualSelection;
257
+ private fetchVisualRanges;
258
+ private syncVisualSelectionColor;
259
+ private fetchVisualBg;
260
+ private seedBuffer;
261
+ }
262
+ export declare function createMonacoNeovim(editor: MonacoEditor.IStandaloneCodeEditor, options?: MonacoNeovimOptions): MonacoNeovimClient;