@gratux/sdk 0.0.0-stage → 1.0.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/README.md +159 -2
- package/dist/api-types.d.ts +639 -0
- package/dist/api-types.js +2 -0
- package/dist/host-entry.d.ts +16 -0
- package/dist/host-entry.js +43 -0
- package/dist/host.d.ts +108 -0
- package/dist/host.js +172 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +81 -0
- package/dist/language-types.d.ts +135 -0
- package/dist/language-types.js +38 -0
- package/dist/manifest.d.ts +135 -0
- package/dist/manifest.js +45 -0
- package/dist/runtime.d.ts +29 -0
- package/dist/runtime.js +1103 -0
- package/dist/types.d.ts +147 -0
- package/dist/types.js +206 -0
- package/package.json +51 -4
- package/templates/basic/README.md +17 -0
- package/templates/basic/gratux.json +19 -0
- package/templates/basic/src/extension.ts +7 -0
- package/templates/basic/tsconfig.json +15 -0
- package/templates/webview/README.md +17 -0
- package/templates/webview/gratux.json +19 -0
- package/templates/webview/src/extension.ts +43 -0
- package/templates/webview/tsconfig.json +15 -0
|
@@ -0,0 +1,639 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The public Gratux Native SDK contract (v1.0).
|
|
3
|
+
*
|
|
4
|
+
* These interfaces are what extension authors see. The implementations live in
|
|
5
|
+
* the extension host (`runtime.ts`), which is injected by the app: an extension
|
|
6
|
+
* never contains an SDK runtime copy. Build extensions as CommonJS and keep
|
|
7
|
+
* `@gratux/sdk` external (the host provides it via `require`).
|
|
8
|
+
*/
|
|
9
|
+
import type { CancellationToken, Disposable, Event, LogOutputChannel, Memento, OutputChannel, Progress, ProgressOptions, RangeLike, Selection, StatusBarAlignment, StatusBarItem, TextEdit, Uri } from "./types";
|
|
10
|
+
import type { CompletionContext, CompletionItem, CompletionList, Diagnostic, DocumentSymbol, Hover, Location, ProviderResult, TextDocument, TextDocumentChangeEvent, TextEditorState } from "./language-types";
|
|
11
|
+
export type { CancellationToken, Disposable, Event, LogOutputChannel, Memento, OutputChannel, Progress, ProgressOptions, Range, RangeLike, Selection, StatusBarAlignment, StatusBarItem, TextEdit, Uri, } from "./types";
|
|
12
|
+
export type { CodeLens, CompletionContext, CompletionItem, CompletionList, Diagnostic, DiagnosticSeverity, DocumentSymbol, Hover, Location, ProviderResult, TextDocument, TextDocumentChangeEvent, TextEditorState, TextLine, } from "./language-types";
|
|
13
|
+
export interface GratuxApi {
|
|
14
|
+
readonly version: string;
|
|
15
|
+
readonly commands: CommandsApi;
|
|
16
|
+
readonly window: WindowApi;
|
|
17
|
+
readonly workspace: WorkspaceApi;
|
|
18
|
+
readonly fs: FileSystemApi;
|
|
19
|
+
readonly editor: EditorApi;
|
|
20
|
+
readonly languages: LanguagesApi;
|
|
21
|
+
readonly lsp: LspApi;
|
|
22
|
+
readonly terminal: TerminalApi;
|
|
23
|
+
readonly network: NetworkApi;
|
|
24
|
+
readonly storage: StorageApi;
|
|
25
|
+
readonly config: ConfigApi;
|
|
26
|
+
readonly android: AndroidApi;
|
|
27
|
+
readonly ai: AiApi;
|
|
28
|
+
readonly env: EnvApi;
|
|
29
|
+
readonly permissions: PermissionsApi;
|
|
30
|
+
}
|
|
31
|
+
export interface CommandsApi {
|
|
32
|
+
/**
|
|
33
|
+
* Registers a command handler. The command also has to be listed in
|
|
34
|
+
* `contributes.commands` to appear in the command palette before activation.
|
|
35
|
+
*/
|
|
36
|
+
registerCommand(id: string, callback: (...args: unknown[]) => unknown, thisArg?: unknown): Disposable;
|
|
37
|
+
executeCommand<T = unknown>(id: string, ...args: unknown[]): Promise<T>;
|
|
38
|
+
getCommands(filterInternal?: boolean): Promise<string[]>;
|
|
39
|
+
readonly onDidExecuteCommand: Event<{
|
|
40
|
+
id: string;
|
|
41
|
+
args: unknown[];
|
|
42
|
+
}>;
|
|
43
|
+
}
|
|
44
|
+
export type MessageSeverity = "info" | "warning" | "error";
|
|
45
|
+
export interface MessageOptions {
|
|
46
|
+
modal?: boolean;
|
|
47
|
+
detail?: string;
|
|
48
|
+
}
|
|
49
|
+
export interface StatusBarItemOptions {
|
|
50
|
+
alignment?: StatusBarAlignment;
|
|
51
|
+
priority?: number;
|
|
52
|
+
}
|
|
53
|
+
export interface QuickPickItem {
|
|
54
|
+
label: string;
|
|
55
|
+
description?: string;
|
|
56
|
+
detail?: string;
|
|
57
|
+
/** Value returned instead of the label. */
|
|
58
|
+
value?: unknown;
|
|
59
|
+
picked?: boolean;
|
|
60
|
+
}
|
|
61
|
+
export interface QuickPickOptions {
|
|
62
|
+
title?: string;
|
|
63
|
+
placeHolder?: string;
|
|
64
|
+
canPickMany?: boolean;
|
|
65
|
+
ignoreFocusOut?: boolean;
|
|
66
|
+
}
|
|
67
|
+
export interface InputBoxOptions {
|
|
68
|
+
title?: string;
|
|
69
|
+
prompt?: string;
|
|
70
|
+
placeHolder?: string;
|
|
71
|
+
value?: string;
|
|
72
|
+
password?: boolean;
|
|
73
|
+
ignoreFocusOut?: boolean;
|
|
74
|
+
validateInput?: (value: string) => string | undefined | null | Promise<string | undefined | null>;
|
|
75
|
+
}
|
|
76
|
+
export interface WebviewOptions {
|
|
77
|
+
enableScripts?: boolean;
|
|
78
|
+
retainContextWhenHidden?: boolean;
|
|
79
|
+
}
|
|
80
|
+
export interface Webview {
|
|
81
|
+
/** HTML rendered in the native WebView; a bridge script is injected automatically. */
|
|
82
|
+
html: string;
|
|
83
|
+
readonly options: WebviewOptions;
|
|
84
|
+
postMessage(message: unknown): Promise<boolean>;
|
|
85
|
+
readonly onDidReceiveMessage: Event<unknown>;
|
|
86
|
+
asWebviewUri(path: string): Uri;
|
|
87
|
+
}
|
|
88
|
+
export interface WebviewView {
|
|
89
|
+
readonly viewId: string;
|
|
90
|
+
readonly title: string;
|
|
91
|
+
readonly visible: boolean;
|
|
92
|
+
readonly webview: Webview;
|
|
93
|
+
show(preserveFocus?: boolean): void;
|
|
94
|
+
readonly onDidChangeVisibility: Event<boolean>;
|
|
95
|
+
readonly onDidDispose: Event<void>;
|
|
96
|
+
}
|
|
97
|
+
export interface WebviewViewProvider {
|
|
98
|
+
resolveWebviewView(view: WebviewView, context: {
|
|
99
|
+
subscriptions: Disposable[];
|
|
100
|
+
}, token: CancellationToken): void | Promise<void>;
|
|
101
|
+
}
|
|
102
|
+
export interface WindowApi {
|
|
103
|
+
showInformationMessage(message: string, ...items: string[]): Promise<string | undefined>;
|
|
104
|
+
showInformationMessage(message: string, options: MessageOptions, ...items: string[]): Promise<string | undefined>;
|
|
105
|
+
showWarningMessage(message: string, ...items: string[]): Promise<string | undefined>;
|
|
106
|
+
showWarningMessage(message: string, options: MessageOptions, ...items: string[]): Promise<string | undefined>;
|
|
107
|
+
showErrorMessage(message: string, ...items: string[]): Promise<string | undefined>;
|
|
108
|
+
showErrorMessage(message: string, options: MessageOptions, ...items: string[]): Promise<string | undefined>;
|
|
109
|
+
showQuickPick(items: readonly QuickPickItem[], options?: QuickPickOptions): Promise<QuickPickItem | undefined>;
|
|
110
|
+
showQuickPick(items: readonly string[], options?: QuickPickOptions): Promise<string | undefined>;
|
|
111
|
+
showInputBox(options?: InputBoxOptions): Promise<string | undefined>;
|
|
112
|
+
showCustomDialog(options: {
|
|
113
|
+
title: string;
|
|
114
|
+
message?: string;
|
|
115
|
+
buttons?: string[];
|
|
116
|
+
}): Promise<number>;
|
|
117
|
+
createStatusBarItem(options?: StatusBarItemOptions): StatusBarItem;
|
|
118
|
+
createOutputChannel(name: string): OutputChannel;
|
|
119
|
+
createLogOutputChannel(name: string): LogOutputChannel;
|
|
120
|
+
withProgress<T>(options: ProgressOptions, task: (progress: Progress<{
|
|
121
|
+
message?: string;
|
|
122
|
+
increment?: number;
|
|
123
|
+
}>, token: CancellationToken) => Promise<T>): Promise<T>;
|
|
124
|
+
registerWebviewViewProvider(viewId: string, provider: WebviewViewProvider): Disposable;
|
|
125
|
+
/** Opens a contributed view (sidebar or panel) in the IDE. */
|
|
126
|
+
showView(viewId: string): Promise<void>;
|
|
127
|
+
readonly onDidChangeActiveWebviewView: Event<{
|
|
128
|
+
viewId: string;
|
|
129
|
+
} | undefined>;
|
|
130
|
+
}
|
|
131
|
+
export interface WorkspaceFolder {
|
|
132
|
+
readonly uri: Uri;
|
|
133
|
+
readonly name: string;
|
|
134
|
+
readonly path: string;
|
|
135
|
+
}
|
|
136
|
+
export interface WorkspaceInfo {
|
|
137
|
+
readonly root: string;
|
|
138
|
+
readonly name: string;
|
|
139
|
+
readonly folders: WorkspaceFolder[];
|
|
140
|
+
}
|
|
141
|
+
export interface WorkspaceConfiguration {
|
|
142
|
+
get<T>(section: string, defaultValue?: T): T | undefined;
|
|
143
|
+
has(section: string): boolean;
|
|
144
|
+
update(section: string, value: unknown, target?: "global" | "workspace"): Promise<void>;
|
|
145
|
+
}
|
|
146
|
+
export interface FileSystemWatcher extends Disposable {
|
|
147
|
+
readonly pattern: string;
|
|
148
|
+
readonly onDidCreate: Event<{
|
|
149
|
+
path: string;
|
|
150
|
+
}>;
|
|
151
|
+
readonly onDidChange: Event<{
|
|
152
|
+
path: string;
|
|
153
|
+
}>;
|
|
154
|
+
readonly onDidDelete: Event<{
|
|
155
|
+
path: string;
|
|
156
|
+
}>;
|
|
157
|
+
}
|
|
158
|
+
export interface WorkspaceApi {
|
|
159
|
+
readonly rootPath: string;
|
|
160
|
+
readonly name: string;
|
|
161
|
+
readonly rootUri: Uri;
|
|
162
|
+
readonly folders: readonly WorkspaceFolder[];
|
|
163
|
+
getInfo(): WorkspaceInfo;
|
|
164
|
+
relativePath(path: string): string;
|
|
165
|
+
findFiles(include: string, exclude?: string, maxResults?: number): Promise<{
|
|
166
|
+
path: string;
|
|
167
|
+
size: number;
|
|
168
|
+
modified: number;
|
|
169
|
+
isDirectory: boolean;
|
|
170
|
+
}[]>;
|
|
171
|
+
openFile(path: string, options?: {
|
|
172
|
+
line?: number;
|
|
173
|
+
column?: number;
|
|
174
|
+
preview?: boolean;
|
|
175
|
+
}): Promise<void>;
|
|
176
|
+
saveAll(): Promise<boolean>;
|
|
177
|
+
watch(pattern?: string, options?: {
|
|
178
|
+
recursive?: boolean;
|
|
179
|
+
}): FileSystemWatcher;
|
|
180
|
+
getConfiguration(section?: string): WorkspaceConfiguration;
|
|
181
|
+
readonly onDidChangeWorkspaceFolders: Event<{
|
|
182
|
+
root: string;
|
|
183
|
+
name: string;
|
|
184
|
+
}>;
|
|
185
|
+
readonly onDidCreateFiles: Event<{
|
|
186
|
+
path: string;
|
|
187
|
+
}>;
|
|
188
|
+
readonly onDidChangeFiles: Event<{
|
|
189
|
+
path: string;
|
|
190
|
+
}>;
|
|
191
|
+
readonly onDidDeleteFiles: Event<{
|
|
192
|
+
path: string;
|
|
193
|
+
}>;
|
|
194
|
+
}
|
|
195
|
+
export interface FileStat {
|
|
196
|
+
type: "file" | "directory" | "unknown";
|
|
197
|
+
size: number;
|
|
198
|
+
modified: number;
|
|
199
|
+
path: string;
|
|
200
|
+
}
|
|
201
|
+
export interface FileSystemApi {
|
|
202
|
+
readFile(path: string): Promise<string>;
|
|
203
|
+
readFileSync(path: string): string;
|
|
204
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
205
|
+
writeFileSync(path: string, content: string): void;
|
|
206
|
+
exists(path: string): boolean;
|
|
207
|
+
stat(path: string): Promise<FileStat>;
|
|
208
|
+
statSync(path: string): FileStat;
|
|
209
|
+
readDirectory(path: string): Promise<{
|
|
210
|
+
name: string;
|
|
211
|
+
path: string;
|
|
212
|
+
type: "file" | "directory";
|
|
213
|
+
}[]>;
|
|
214
|
+
createDirectory(path: string): Promise<void>;
|
|
215
|
+
delete(path: string, options?: {
|
|
216
|
+
recursive?: boolean;
|
|
217
|
+
}): Promise<void>;
|
|
218
|
+
rename(from: string, to: string): Promise<void>;
|
|
219
|
+
copy(from: string, to: string): Promise<void>;
|
|
220
|
+
/** Absolute path of a workspace-relative path, or undefined when it escapes the workspace. */
|
|
221
|
+
resolveWorkspacePath(relative: string): string | undefined;
|
|
222
|
+
readonly onDidChange: Event<{
|
|
223
|
+
path: string;
|
|
224
|
+
type: "created" | "changed" | "deleted";
|
|
225
|
+
}>;
|
|
226
|
+
}
|
|
227
|
+
export interface EditorSelection {
|
|
228
|
+
anchor: PositionLike;
|
|
229
|
+
active: PositionLike;
|
|
230
|
+
start: PositionLike;
|
|
231
|
+
end: PositionLike;
|
|
232
|
+
}
|
|
233
|
+
export interface PositionLike {
|
|
234
|
+
line: number;
|
|
235
|
+
character: number;
|
|
236
|
+
}
|
|
237
|
+
export interface EditorApi {
|
|
238
|
+
getActiveDocument(): TextDocument | undefined;
|
|
239
|
+
getActiveEditorState(): TextEditorState | undefined;
|
|
240
|
+
getText(): string;
|
|
241
|
+
getSelection(): Selection | undefined;
|
|
242
|
+
getSelections(): Selection[];
|
|
243
|
+
insertText(text: string): Promise<boolean>;
|
|
244
|
+
replaceSelection(text: string): Promise<boolean>;
|
|
245
|
+
replaceRange(start: {
|
|
246
|
+
line: number;
|
|
247
|
+
character: number;
|
|
248
|
+
}, end: {
|
|
249
|
+
line: number;
|
|
250
|
+
character: number;
|
|
251
|
+
}, text: string): Promise<boolean>;
|
|
252
|
+
applyEdits(edits: TextEdit[]): Promise<boolean>;
|
|
253
|
+
setSelection(start: {
|
|
254
|
+
line: number;
|
|
255
|
+
character: number;
|
|
256
|
+
}, end?: {
|
|
257
|
+
line: number;
|
|
258
|
+
character: number;
|
|
259
|
+
}): Promise<boolean>;
|
|
260
|
+
revealLine(line: number, column?: number): Promise<boolean>;
|
|
261
|
+
save(): Promise<boolean>;
|
|
262
|
+
openFile(path: string, options?: {
|
|
263
|
+
line?: number;
|
|
264
|
+
column?: number;
|
|
265
|
+
}): Promise<boolean>;
|
|
266
|
+
find(query: string, options?: {
|
|
267
|
+
caseSensitive?: boolean;
|
|
268
|
+
limit?: number;
|
|
269
|
+
}): Promise<{
|
|
270
|
+
start: number;
|
|
271
|
+
end: number;
|
|
272
|
+
line: number;
|
|
273
|
+
column: number;
|
|
274
|
+
}[]>;
|
|
275
|
+
replaceAll(query: string, replacement: string, options?: {
|
|
276
|
+
caseSensitive?: boolean;
|
|
277
|
+
}): Promise<number>;
|
|
278
|
+
setDecorations(owner: string, decorations: {
|
|
279
|
+
line: number;
|
|
280
|
+
style?: "error" | "warning" | "info" | "highlight";
|
|
281
|
+
message?: string;
|
|
282
|
+
}[]): Promise<boolean>;
|
|
283
|
+
clearDecorations(owner?: string): Promise<boolean>;
|
|
284
|
+
readonly onDidChangeActiveDocument: Event<TextDocument | undefined>;
|
|
285
|
+
readonly onDidChangeDocument: Event<TextDocumentChangeEvent>;
|
|
286
|
+
readonly onDidChangeSelection: Event<{
|
|
287
|
+
selections: EditorSelection[];
|
|
288
|
+
}>;
|
|
289
|
+
readonly onDidSaveDocument: Event<{
|
|
290
|
+
path: string;
|
|
291
|
+
}>;
|
|
292
|
+
}
|
|
293
|
+
export type DocumentSelector = string | {
|
|
294
|
+
language?: string;
|
|
295
|
+
scheme?: string;
|
|
296
|
+
pattern?: string;
|
|
297
|
+
} | readonly (string | {
|
|
298
|
+
language?: string;
|
|
299
|
+
scheme?: string;
|
|
300
|
+
pattern?: string;
|
|
301
|
+
})[];
|
|
302
|
+
export interface CompletionItemProvider {
|
|
303
|
+
provideCompletionItems(document: TextDocument, position: {
|
|
304
|
+
line: number;
|
|
305
|
+
character: number;
|
|
306
|
+
}, token: CancellationToken, context: CompletionContext): ProviderResult<CompletionItem[] | CompletionList>;
|
|
307
|
+
}
|
|
308
|
+
export interface HoverProvider {
|
|
309
|
+
provideHover(document: TextDocument, position: {
|
|
310
|
+
line: number;
|
|
311
|
+
character: number;
|
|
312
|
+
}, token: CancellationToken): ProviderResult<Hover>;
|
|
313
|
+
}
|
|
314
|
+
export interface DefinitionProvider {
|
|
315
|
+
provideDefinition(document: TextDocument, position: {
|
|
316
|
+
line: number;
|
|
317
|
+
character: number;
|
|
318
|
+
}, token: CancellationToken): ProviderResult<Location | Location[]>;
|
|
319
|
+
}
|
|
320
|
+
export interface ReferenceProvider {
|
|
321
|
+
provideReferences(document: TextDocument, position: {
|
|
322
|
+
line: number;
|
|
323
|
+
character: number;
|
|
324
|
+
}, token: CancellationToken): ProviderResult<Location[]>;
|
|
325
|
+
}
|
|
326
|
+
export interface DocumentFormattingEditProvider {
|
|
327
|
+
provideDocumentFormattingEdits(document: TextDocument, options: {
|
|
328
|
+
tabSize: number;
|
|
329
|
+
insertSpaces: boolean;
|
|
330
|
+
}, token: CancellationToken): ProviderResult<TextEdit[]>;
|
|
331
|
+
}
|
|
332
|
+
export interface CodeActionProvider {
|
|
333
|
+
provideCodeActions(document: TextDocument, range: RangeLike, context: {
|
|
334
|
+
diagnostics: Diagnostic[];
|
|
335
|
+
}, token: CancellationToken): ProviderResult<CodeAction[]>;
|
|
336
|
+
}
|
|
337
|
+
export interface DocumentSymbolProvider {
|
|
338
|
+
provideDocumentSymbols(document: TextDocument, token: CancellationToken): ProviderResult<DocumentSymbol[]>;
|
|
339
|
+
}
|
|
340
|
+
export interface CodeAction {
|
|
341
|
+
title: string;
|
|
342
|
+
kind?: string;
|
|
343
|
+
edit?: {
|
|
344
|
+
edits: TextEdit[];
|
|
345
|
+
};
|
|
346
|
+
command?: {
|
|
347
|
+
id: string;
|
|
348
|
+
title?: string;
|
|
349
|
+
arguments?: unknown[];
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
export interface DiagnosticCollection extends Disposable {
|
|
353
|
+
readonly name: string;
|
|
354
|
+
set(uri: string, diagnostics: Diagnostic[]): void;
|
|
355
|
+
get(uri: string): readonly Diagnostic[];
|
|
356
|
+
delete(uri: string): void;
|
|
357
|
+
clear(): void;
|
|
358
|
+
}
|
|
359
|
+
export interface LanguagesApi {
|
|
360
|
+
register(language: {
|
|
361
|
+
id: string;
|
|
362
|
+
extensions?: string[];
|
|
363
|
+
aliases?: string[];
|
|
364
|
+
}): Disposable;
|
|
365
|
+
getLanguages(): Promise<{
|
|
366
|
+
id: string;
|
|
367
|
+
extensions: string[];
|
|
368
|
+
aliases: string[];
|
|
369
|
+
}[]>;
|
|
370
|
+
registerCompletionItemProvider(selector: DocumentSelector, provider: CompletionItemProvider, triggerCharacters?: string[]): Disposable;
|
|
371
|
+
registerHoverProvider(selector: DocumentSelector, provider: HoverProvider): Disposable;
|
|
372
|
+
registerDefinitionProvider(selector: DocumentSelector, provider: DefinitionProvider): Disposable;
|
|
373
|
+
registerReferenceProvider(selector: DocumentSelector, provider: ReferenceProvider): Disposable;
|
|
374
|
+
registerDocumentFormattingEditProvider(selector: DocumentSelector, provider: DocumentFormattingEditProvider): Disposable;
|
|
375
|
+
registerCodeActionProvider(selector: DocumentSelector, provider: CodeActionProvider): Disposable;
|
|
376
|
+
registerDocumentSymbolProvider(selector: DocumentSelector, provider: DocumentSymbolProvider): Disposable;
|
|
377
|
+
createDiagnosticCollection(name?: string): DiagnosticCollection;
|
|
378
|
+
setDiagnostics(uri: string, diagnostics: Diagnostic[]): void;
|
|
379
|
+
getDiagnostics(uri?: string): Promise<{
|
|
380
|
+
uri: string;
|
|
381
|
+
diagnostics: Diagnostic[];
|
|
382
|
+
}[]>;
|
|
383
|
+
readonly onDidChangeDiagnostics: Event<{
|
|
384
|
+
uri: string;
|
|
385
|
+
diagnostics: Diagnostic[];
|
|
386
|
+
}[]>;
|
|
387
|
+
}
|
|
388
|
+
export interface LanguageServerSpec {
|
|
389
|
+
id: string;
|
|
390
|
+
label?: string;
|
|
391
|
+
languages: string[];
|
|
392
|
+
languageId?: string;
|
|
393
|
+
/** Executable inside the Gratux prefix (e.g. "typescript-language-server"). */
|
|
394
|
+
command: string;
|
|
395
|
+
args?: string[];
|
|
396
|
+
installCommand?: string;
|
|
397
|
+
}
|
|
398
|
+
export interface LanguageServerStatus {
|
|
399
|
+
id: string;
|
|
400
|
+
label: string;
|
|
401
|
+
installed: boolean;
|
|
402
|
+
running: boolean;
|
|
403
|
+
}
|
|
404
|
+
export interface LspApi {
|
|
405
|
+
registerServer(spec: LanguageServerSpec): Disposable;
|
|
406
|
+
start(id: string): Promise<boolean>;
|
|
407
|
+
stop(id: string): Promise<boolean>;
|
|
408
|
+
status(): Promise<LanguageServerStatus[]>;
|
|
409
|
+
readonly onDidChangeStatus: Event<LanguageServerStatus[]>;
|
|
410
|
+
}
|
|
411
|
+
export interface TerminalOptions {
|
|
412
|
+
name?: string;
|
|
413
|
+
cwd?: string;
|
|
414
|
+
env?: Record<string, string>;
|
|
415
|
+
/** Do not add the terminal to the visible tab strip (default true adds it). */
|
|
416
|
+
showInPanel?: boolean;
|
|
417
|
+
}
|
|
418
|
+
export interface Terminal {
|
|
419
|
+
readonly id: string;
|
|
420
|
+
readonly name: string;
|
|
421
|
+
readonly cwd: string;
|
|
422
|
+
readonly shellPath: string;
|
|
423
|
+
readonly pid: number;
|
|
424
|
+
sendText(text: string, addNewline?: boolean): Promise<boolean>;
|
|
425
|
+
execute(command: string): Promise<boolean>;
|
|
426
|
+
read(): Promise<string>;
|
|
427
|
+
resize(cols: number, rows: number): Promise<boolean>;
|
|
428
|
+
show(preserveFocus?: boolean): Promise<void>;
|
|
429
|
+
close(): void;
|
|
430
|
+
readonly onDidWriteData: Event<string>;
|
|
431
|
+
readonly onDidClose: Event<{
|
|
432
|
+
exitCode: number | undefined;
|
|
433
|
+
}>;
|
|
434
|
+
}
|
|
435
|
+
export interface TerminalProfile {
|
|
436
|
+
shellPath: string;
|
|
437
|
+
name: string;
|
|
438
|
+
environment: Record<string, string>;
|
|
439
|
+
cwd: string;
|
|
440
|
+
}
|
|
441
|
+
export interface TerminalApi {
|
|
442
|
+
createTerminal(options?: TerminalOptions | string): Terminal;
|
|
443
|
+
getTerminal(id: string): Terminal | undefined;
|
|
444
|
+
get terminals(): readonly Terminal[];
|
|
445
|
+
list(): Promise<{
|
|
446
|
+
id: string;
|
|
447
|
+
name: string;
|
|
448
|
+
cwd: string;
|
|
449
|
+
pid: number;
|
|
450
|
+
}[]>;
|
|
451
|
+
getProfiles(): Promise<TerminalProfile[]>;
|
|
452
|
+
show(id?: string): Promise<void>;
|
|
453
|
+
readonly onDidOpenTerminal: Event<{
|
|
454
|
+
id: string;
|
|
455
|
+
name: string;
|
|
456
|
+
}>;
|
|
457
|
+
readonly onDidCloseTerminal: Event<{
|
|
458
|
+
id: string;
|
|
459
|
+
}>;
|
|
460
|
+
readonly onDidWriteTerminalData: Event<{
|
|
461
|
+
id: string;
|
|
462
|
+
data: string;
|
|
463
|
+
}>;
|
|
464
|
+
readonly activeTerminal: Terminal | undefined;
|
|
465
|
+
}
|
|
466
|
+
export interface NetworkRequest {
|
|
467
|
+
url: string;
|
|
468
|
+
method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD";
|
|
469
|
+
headers?: Record<string, string>;
|
|
470
|
+
body?: string;
|
|
471
|
+
timeoutMs?: number;
|
|
472
|
+
}
|
|
473
|
+
export interface NetworkResponse {
|
|
474
|
+
url: string;
|
|
475
|
+
status: number;
|
|
476
|
+
statusText: string;
|
|
477
|
+
headers: Record<string, string>;
|
|
478
|
+
text: string;
|
|
479
|
+
ok: boolean;
|
|
480
|
+
}
|
|
481
|
+
export interface WebSocketLike extends Disposable {
|
|
482
|
+
readonly url: string;
|
|
483
|
+
send(data: string): void;
|
|
484
|
+
close(code?: number, reason?: string): void;
|
|
485
|
+
readonly onOpen: Event<void>;
|
|
486
|
+
readonly onMessage: Event<string>;
|
|
487
|
+
readonly onError: Event<{
|
|
488
|
+
message: string;
|
|
489
|
+
}>;
|
|
490
|
+
readonly onClose: Event<{
|
|
491
|
+
code: number;
|
|
492
|
+
reason: string;
|
|
493
|
+
}>;
|
|
494
|
+
}
|
|
495
|
+
export interface NetworkApi {
|
|
496
|
+
fetch(request: string | NetworkRequest, token?: CancellationToken): Promise<NetworkResponse>;
|
|
497
|
+
cancelAll(): Promise<void>;
|
|
498
|
+
createWebSocket(url: string, protocols?: string[]): Promise<WebSocketLike>;
|
|
499
|
+
readonly onDidCompleteRequest: Event<{
|
|
500
|
+
url: string;
|
|
501
|
+
status: number;
|
|
502
|
+
}>;
|
|
503
|
+
}
|
|
504
|
+
export interface StorageApi {
|
|
505
|
+
get<T>(key: string, defaultValue?: T): T | undefined;
|
|
506
|
+
set(key: string, value: unknown): Promise<void>;
|
|
507
|
+
delete(key: string): Promise<void>;
|
|
508
|
+
keys(): string[];
|
|
509
|
+
clear(): Promise<void>;
|
|
510
|
+
readonly secrets: {
|
|
511
|
+
get(key: string): Promise<string | undefined>;
|
|
512
|
+
set(key: string, value: string): Promise<void>;
|
|
513
|
+
delete(key: string): Promise<void>;
|
|
514
|
+
};
|
|
515
|
+
readonly onDidChange: Event<{
|
|
516
|
+
key: string;
|
|
517
|
+
value: unknown;
|
|
518
|
+
}>;
|
|
519
|
+
}
|
|
520
|
+
export interface ConfigApi {
|
|
521
|
+
get<T>(key: string, defaultValue?: T): T | undefined;
|
|
522
|
+
has(key: string): boolean;
|
|
523
|
+
update(key: string, value: unknown, target?: "global" | "workspace"): Promise<void>;
|
|
524
|
+
readonly onDidChange: Event<{
|
|
525
|
+
key: string;
|
|
526
|
+
value: unknown;
|
|
527
|
+
scope: "global" | "workspace";
|
|
528
|
+
}>;
|
|
529
|
+
getConfiguration(section?: string): WorkspaceConfiguration;
|
|
530
|
+
}
|
|
531
|
+
export interface DeviceInfo {
|
|
532
|
+
manufacturer: string;
|
|
533
|
+
model: string;
|
|
534
|
+
androidVersion: string;
|
|
535
|
+
sdk: number;
|
|
536
|
+
abi: string;
|
|
537
|
+
appVersion: string;
|
|
538
|
+
packageName: string;
|
|
539
|
+
}
|
|
540
|
+
export interface PickedDocument {
|
|
541
|
+
uri: string;
|
|
542
|
+
name: string;
|
|
543
|
+
size: number;
|
|
544
|
+
mimeType: string;
|
|
545
|
+
}
|
|
546
|
+
export interface AndroidApi {
|
|
547
|
+
showNotification(options: {
|
|
548
|
+
title: string;
|
|
549
|
+
body?: string;
|
|
550
|
+
id?: number;
|
|
551
|
+
}): Promise<boolean>;
|
|
552
|
+
copyToClipboard(text: string): Promise<boolean>;
|
|
553
|
+
readClipboard(): Promise<string>;
|
|
554
|
+
share(options: {
|
|
555
|
+
text?: string;
|
|
556
|
+
subject?: string;
|
|
557
|
+
url?: string;
|
|
558
|
+
}): Promise<boolean>;
|
|
559
|
+
openUrl(url: string): Promise<boolean>;
|
|
560
|
+
getDeviceInfo(): DeviceInfo;
|
|
561
|
+
pickDocument(options?: {
|
|
562
|
+
mimeType?: string;
|
|
563
|
+
multiple?: boolean;
|
|
564
|
+
}): Promise<PickedDocument[]>;
|
|
565
|
+
readDocument(uri: string): Promise<string>;
|
|
566
|
+
writeDocument(uri: string, content: string): Promise<boolean>;
|
|
567
|
+
readonly onDidChangeLifecycle: Event<{
|
|
568
|
+
state: "foreground" | "background";
|
|
569
|
+
}>;
|
|
570
|
+
}
|
|
571
|
+
export interface AiProviderInfo {
|
|
572
|
+
id: string;
|
|
573
|
+
label: string;
|
|
574
|
+
configured: boolean;
|
|
575
|
+
protocol: string;
|
|
576
|
+
}
|
|
577
|
+
export interface AiRequest {
|
|
578
|
+
provider?: string;
|
|
579
|
+
model?: string;
|
|
580
|
+
system?: string;
|
|
581
|
+
messages: {
|
|
582
|
+
role: "user" | "assistant" | "system";
|
|
583
|
+
content: string;
|
|
584
|
+
}[];
|
|
585
|
+
maxTokens?: number;
|
|
586
|
+
temperature?: number;
|
|
587
|
+
requestId?: string;
|
|
588
|
+
}
|
|
589
|
+
export interface AiStreamHandle extends Disposable {
|
|
590
|
+
readonly requestId: string;
|
|
591
|
+
readonly text: Promise<string>;
|
|
592
|
+
}
|
|
593
|
+
export interface AiApi {
|
|
594
|
+
getProviders(): Promise<AiProviderInfo[]>;
|
|
595
|
+
request(options: AiRequest): Promise<string>;
|
|
596
|
+
stream(options: AiRequest & {
|
|
597
|
+
onChunk: (chunk: string) => void;
|
|
598
|
+
onDone?: (text: string) => void;
|
|
599
|
+
onError?: (error: string) => void;
|
|
600
|
+
}): AiStreamHandle;
|
|
601
|
+
cancel(requestId: string): Promise<boolean>;
|
|
602
|
+
getModels(provider?: string): Promise<string[]>;
|
|
603
|
+
readonly onDidRegisterProvider: Event<AiProviderInfo>;
|
|
604
|
+
}
|
|
605
|
+
export interface EnvApi {
|
|
606
|
+
readonly appVersion: string;
|
|
607
|
+
readonly sdkVersion: string;
|
|
608
|
+
readonly platform: string;
|
|
609
|
+
readonly arch: string;
|
|
610
|
+
readonly prefix: string;
|
|
611
|
+
readonly home: string;
|
|
612
|
+
readonly workspace: string;
|
|
613
|
+
readonly isTermuxInstalled: boolean;
|
|
614
|
+
}
|
|
615
|
+
export interface PermissionsApi {
|
|
616
|
+
check(permission: string): boolean;
|
|
617
|
+
getGranted(): string[];
|
|
618
|
+
getDeclared(): string[];
|
|
619
|
+
readonly onDidChange: Event<{
|
|
620
|
+
permission: string;
|
|
621
|
+
granted: boolean;
|
|
622
|
+
}>;
|
|
623
|
+
}
|
|
624
|
+
/** The object passed to `activate(context)`. */
|
|
625
|
+
export interface ExtensionContext {
|
|
626
|
+
readonly extensionId: string;
|
|
627
|
+
readonly extensionPath: string;
|
|
628
|
+
readonly extension: {
|
|
629
|
+
readonly id: string;
|
|
630
|
+
readonly packageJSON: Record<string, unknown>;
|
|
631
|
+
readonly extensionUri: Uri;
|
|
632
|
+
};
|
|
633
|
+
readonly subscriptions: Disposable[];
|
|
634
|
+
readonly globalState: Memento;
|
|
635
|
+
readonly workspaceState: Memento;
|
|
636
|
+
readonly storage: Memento;
|
|
637
|
+
readonly log: LogOutputChannel;
|
|
638
|
+
asAbsolutePath(relativePath: string): string;
|
|
639
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host entry point.
|
|
3
|
+
*
|
|
4
|
+
* `extension-sdk.js` in the APK is built from this file. It contains the real
|
|
5
|
+
* API implementation and helper functions the extension host shim needs; it is
|
|
6
|
+
* not imported by extensions (they get a per-extension API object through
|
|
7
|
+
* `require('gratux')`).
|
|
8
|
+
*/
|
|
9
|
+
export { createExtensionApi, SDK_VERSION } from "./runtime";
|
|
10
|
+
export type { ExtensionInternals } from "./runtime";
|
|
11
|
+
export { createState, invokeProvider, normaliseProviderResults, disposeAll, buildDocument } from "./host";
|
|
12
|
+
export type { HostBinding, NativeTransport, ExtensionState, ProviderRegistration } from "./host";
|
|
13
|
+
export { EventEmitter, CancellationTokenSource, Position, Range, Selection, Uri, StatusBarAlignment } from "./types";
|
|
14
|
+
export type * from "./api-types";
|
|
15
|
+
export type * from "./language-types";
|
|
16
|
+
export * from "./manifest";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.StatusBarAlignment = exports.Uri = exports.Selection = exports.Range = exports.Position = exports.CancellationTokenSource = exports.EventEmitter = exports.buildDocument = exports.disposeAll = exports.normaliseProviderResults = exports.invokeProvider = exports.createState = exports.SDK_VERSION = exports.createExtensionApi = void 0;
|
|
18
|
+
/**
|
|
19
|
+
* Host entry point.
|
|
20
|
+
*
|
|
21
|
+
* `extension-sdk.js` in the APK is built from this file. It contains the real
|
|
22
|
+
* API implementation and helper functions the extension host shim needs; it is
|
|
23
|
+
* not imported by extensions (they get a per-extension API object through
|
|
24
|
+
* `require('gratux')`).
|
|
25
|
+
*/
|
|
26
|
+
var runtime_1 = require("./runtime");
|
|
27
|
+
Object.defineProperty(exports, "createExtensionApi", { enumerable: true, get: function () { return runtime_1.createExtensionApi; } });
|
|
28
|
+
Object.defineProperty(exports, "SDK_VERSION", { enumerable: true, get: function () { return runtime_1.SDK_VERSION; } });
|
|
29
|
+
var host_1 = require("./host");
|
|
30
|
+
Object.defineProperty(exports, "createState", { enumerable: true, get: function () { return host_1.createState; } });
|
|
31
|
+
Object.defineProperty(exports, "invokeProvider", { enumerable: true, get: function () { return host_1.invokeProvider; } });
|
|
32
|
+
Object.defineProperty(exports, "normaliseProviderResults", { enumerable: true, get: function () { return host_1.normaliseProviderResults; } });
|
|
33
|
+
Object.defineProperty(exports, "disposeAll", { enumerable: true, get: function () { return host_1.disposeAll; } });
|
|
34
|
+
Object.defineProperty(exports, "buildDocument", { enumerable: true, get: function () { return host_1.buildDocument; } });
|
|
35
|
+
var types_1 = require("./types");
|
|
36
|
+
Object.defineProperty(exports, "EventEmitter", { enumerable: true, get: function () { return types_1.EventEmitter; } });
|
|
37
|
+
Object.defineProperty(exports, "CancellationTokenSource", { enumerable: true, get: function () { return types_1.CancellationTokenSource; } });
|
|
38
|
+
Object.defineProperty(exports, "Position", { enumerable: true, get: function () { return types_1.Position; } });
|
|
39
|
+
Object.defineProperty(exports, "Range", { enumerable: true, get: function () { return types_1.Range; } });
|
|
40
|
+
Object.defineProperty(exports, "Selection", { enumerable: true, get: function () { return types_1.Selection; } });
|
|
41
|
+
Object.defineProperty(exports, "Uri", { enumerable: true, get: function () { return types_1.Uri; } });
|
|
42
|
+
Object.defineProperty(exports, "StatusBarAlignment", { enumerable: true, get: function () { return types_1.StatusBarAlignment; } });
|
|
43
|
+
__exportStar(require("./manifest"), exports);
|