@gratux/sdk 0.0.0-stage → 1.0.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/README.md +193 -2
- package/dist/api-types.d.ts +644 -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 +142 -0
- package/dist/manifest.js +45 -0
- package/dist/runtime.d.ts +29 -0
- package/dist/runtime.js +1136 -0
- package/dist/types.d.ts +147 -0
- package/dist/types.js +206 -0
- package/package.json +55 -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,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manifest contract for Gratux Native extensions.
|
|
3
|
+
*
|
|
4
|
+
* The authoritative validation happens in the Android runtime
|
|
5
|
+
* (`ManifestParser.kt`); these types exist so extension authors get autocomplete
|
|
6
|
+
* and compile-time checks, and so tooling can validate packages.
|
|
7
|
+
*/
|
|
8
|
+
export declare const MANIFEST_SCHEMA_VERSION = 1;
|
|
9
|
+
export type ExtensionType = "typescript" | "javascript" | "declarative";
|
|
10
|
+
export declare const PERMISSIONS: {
|
|
11
|
+
readonly editorRead: "editor.read";
|
|
12
|
+
readonly editorWrite: "editor.write";
|
|
13
|
+
readonly editorDecorations: "editor.decorations";
|
|
14
|
+
readonly terminalExecute: "terminal.execute";
|
|
15
|
+
readonly terminalRead: "terminal.read";
|
|
16
|
+
readonly filesystemRead: "filesystem.read";
|
|
17
|
+
readonly filesystemWrite: "filesystem.write";
|
|
18
|
+
readonly filesystemUnrestricted: "filesystem.unrestricted";
|
|
19
|
+
readonly workspaceRead: "workspace.read";
|
|
20
|
+
readonly workspaceWrite: "workspace.write";
|
|
21
|
+
readonly networkRequest: "network.request";
|
|
22
|
+
readonly networkWebSocket: "network.websocket";
|
|
23
|
+
readonly uiPanel: "ui.panel";
|
|
24
|
+
readonly uiSidebar: "ui.sidebar";
|
|
25
|
+
readonly uiStatusBar: "ui.statusbar";
|
|
26
|
+
readonly uiNotifications: "ui.notifications";
|
|
27
|
+
readonly androidNotifications: "android.notifications";
|
|
28
|
+
readonly androidDocuments: "android.documents";
|
|
29
|
+
readonly androidClipboard: "android.clipboard";
|
|
30
|
+
readonly androidShare: "android.share";
|
|
31
|
+
readonly androidOpenUrl: "android.openUrl";
|
|
32
|
+
readonly aiRequest: "ai.request";
|
|
33
|
+
readonly configWrite: "config.write";
|
|
34
|
+
readonly storageSecret: "storage.secret";
|
|
35
|
+
readonly commandsRegister: "commands.register";
|
|
36
|
+
readonly languagesRegister: "languages.register";
|
|
37
|
+
readonly lspRegister: "lsp.register";
|
|
38
|
+
};
|
|
39
|
+
export type Permission = (typeof PERMISSIONS)[keyof typeof PERMISSIONS];
|
|
40
|
+
export type ActivationEvent = "*" | "onStartupFinished" | `onCommand:${string}` | `onLanguage:${string}` | `onView:${string}` | `onTerminal:${string}` | `onFileSystem:${string}` | `workspaceContains:${string}` | "onDebug" | "onUri";
|
|
41
|
+
export interface CommandContribution {
|
|
42
|
+
id: string;
|
|
43
|
+
title: string;
|
|
44
|
+
category?: string;
|
|
45
|
+
enablement?: string;
|
|
46
|
+
icon?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface KeybindingContribution {
|
|
49
|
+
key: string;
|
|
50
|
+
command: string;
|
|
51
|
+
when?: string;
|
|
52
|
+
}
|
|
53
|
+
export type MenuLocation = "editor/title" | "editor/context" | "explorer/context" | "terminal/title" | "commandPalette";
|
|
54
|
+
export interface MenuContribution {
|
|
55
|
+
command: string;
|
|
56
|
+
location: MenuLocation;
|
|
57
|
+
group?: string;
|
|
58
|
+
when?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface ViewContribution {
|
|
61
|
+
id: string;
|
|
62
|
+
title: string;
|
|
63
|
+
location?: "sidebar" | "panel";
|
|
64
|
+
icon?: string;
|
|
65
|
+
}
|
|
66
|
+
export interface FileOpenerContribution {
|
|
67
|
+
title: string;
|
|
68
|
+
extensions: string[];
|
|
69
|
+
command: string;
|
|
70
|
+
priority?: number;
|
|
71
|
+
}
|
|
72
|
+
export interface LanguageContribution {
|
|
73
|
+
id: string;
|
|
74
|
+
extensions?: string[];
|
|
75
|
+
aliases?: string[];
|
|
76
|
+
}
|
|
77
|
+
export interface LanguageServerContribution {
|
|
78
|
+
id: string;
|
|
79
|
+
label?: string;
|
|
80
|
+
languages: string[];
|
|
81
|
+
languageId: string;
|
|
82
|
+
command: string;
|
|
83
|
+
args?: string[];
|
|
84
|
+
installCommand?: string;
|
|
85
|
+
}
|
|
86
|
+
export interface ConfigurationSchema {
|
|
87
|
+
title?: string;
|
|
88
|
+
properties: Record<string, {
|
|
89
|
+
type: "string" | "number" | "boolean" | "array" | "object";
|
|
90
|
+
default?: unknown;
|
|
91
|
+
description?: string;
|
|
92
|
+
enum?: unknown[];
|
|
93
|
+
}>;
|
|
94
|
+
}
|
|
95
|
+
export interface SnippetContribution {
|
|
96
|
+
language: string;
|
|
97
|
+
prefix: string;
|
|
98
|
+
body: string;
|
|
99
|
+
}
|
|
100
|
+
export interface ThemeContribution {
|
|
101
|
+
name: string;
|
|
102
|
+
colors: Record<string, string>;
|
|
103
|
+
}
|
|
104
|
+
export interface Contributions {
|
|
105
|
+
commands?: CommandContribution[];
|
|
106
|
+
keybindings?: KeybindingContribution[];
|
|
107
|
+
menus?: MenuContribution[];
|
|
108
|
+
views?: ViewContribution[];
|
|
109
|
+
fileOpeners?: FileOpenerContribution[];
|
|
110
|
+
languages?: LanguageContribution[];
|
|
111
|
+
languageServers?: LanguageServerContribution[];
|
|
112
|
+
configuration?: ConfigurationSchema;
|
|
113
|
+
snippets?: SnippetContribution[];
|
|
114
|
+
themes?: ThemeContribution[];
|
|
115
|
+
}
|
|
116
|
+
export interface GratuxManifest {
|
|
117
|
+
schemaVersion?: number;
|
|
118
|
+
id: string;
|
|
119
|
+
name: string;
|
|
120
|
+
description?: string;
|
|
121
|
+
version: string;
|
|
122
|
+
publisher?: string;
|
|
123
|
+
license?: string;
|
|
124
|
+
type?: ExtensionType;
|
|
125
|
+
main?: string;
|
|
126
|
+
engines?: {
|
|
127
|
+
gratux?: string;
|
|
128
|
+
[key: string]: string | undefined;
|
|
129
|
+
};
|
|
130
|
+
permissions?: Permission[];
|
|
131
|
+
activationEvents?: ActivationEvent[];
|
|
132
|
+
dependencies?: string[];
|
|
133
|
+
contributes?: Contributions;
|
|
134
|
+
platform?: {
|
|
135
|
+
os?: string[];
|
|
136
|
+
arch?: string[];
|
|
137
|
+
};
|
|
138
|
+
repository?: string;
|
|
139
|
+
icon?: string;
|
|
140
|
+
}
|
|
141
|
+
/** Authoring helper: keeps the literal type of the manifest. */
|
|
142
|
+
export declare function defineManifest<T extends GratuxManifest>(manifest: T): T;
|
package/dist/manifest.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Manifest contract for Gratux Native extensions.
|
|
4
|
+
*
|
|
5
|
+
* The authoritative validation happens in the Android runtime
|
|
6
|
+
* (`ManifestParser.kt`); these types exist so extension authors get autocomplete
|
|
7
|
+
* and compile-time checks, and so tooling can validate packages.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.PERMISSIONS = exports.MANIFEST_SCHEMA_VERSION = void 0;
|
|
11
|
+
exports.defineManifest = defineManifest;
|
|
12
|
+
exports.MANIFEST_SCHEMA_VERSION = 1;
|
|
13
|
+
exports.PERMISSIONS = {
|
|
14
|
+
editorRead: "editor.read",
|
|
15
|
+
editorWrite: "editor.write",
|
|
16
|
+
editorDecorations: "editor.decorations",
|
|
17
|
+
terminalExecute: "terminal.execute",
|
|
18
|
+
terminalRead: "terminal.read",
|
|
19
|
+
filesystemRead: "filesystem.read",
|
|
20
|
+
filesystemWrite: "filesystem.write",
|
|
21
|
+
filesystemUnrestricted: "filesystem.unrestricted",
|
|
22
|
+
workspaceRead: "workspace.read",
|
|
23
|
+
workspaceWrite: "workspace.write",
|
|
24
|
+
networkRequest: "network.request",
|
|
25
|
+
networkWebSocket: "network.websocket",
|
|
26
|
+
uiPanel: "ui.panel",
|
|
27
|
+
uiSidebar: "ui.sidebar",
|
|
28
|
+
uiStatusBar: "ui.statusbar",
|
|
29
|
+
uiNotifications: "ui.notifications",
|
|
30
|
+
androidNotifications: "android.notifications",
|
|
31
|
+
androidDocuments: "android.documents",
|
|
32
|
+
androidClipboard: "android.clipboard",
|
|
33
|
+
androidShare: "android.share",
|
|
34
|
+
androidOpenUrl: "android.openUrl",
|
|
35
|
+
aiRequest: "ai.request",
|
|
36
|
+
configWrite: "config.write",
|
|
37
|
+
storageSecret: "storage.secret",
|
|
38
|
+
commandsRegister: "commands.register",
|
|
39
|
+
languagesRegister: "languages.register",
|
|
40
|
+
lspRegister: "lsp.register",
|
|
41
|
+
};
|
|
42
|
+
/** Authoring helper: keeps the literal type of the manifest. */
|
|
43
|
+
function defineManifest(manifest) {
|
|
44
|
+
return manifest;
|
|
45
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host-side SDK implementation.
|
|
3
|
+
*
|
|
4
|
+
* The app loads the compiled form of this file in the extension host and builds
|
|
5
|
+
* one `GratuxApi` per extension over that extension's [HostBinding]. Extension
|
|
6
|
+
* code receives this object through `require('gratux')`; it never runs this
|
|
7
|
+
* file directly, which is why the npm entry point only exports types and
|
|
8
|
+
* throwing stubs.
|
|
9
|
+
*/
|
|
10
|
+
import type { CodeAction, CompletionList, DocumentSelector, ExtensionContext, GratuxApi, TextEdit, Uri } from "./api-types";
|
|
11
|
+
import { buildDocument, invokeProvider, normaliseProviderResults, type DocumentSnapshot, type HostBinding } from "./host";
|
|
12
|
+
export declare const SDK_VERSION = "1.0.0";
|
|
13
|
+
/** Creates the API object handed to one extension. */
|
|
14
|
+
export interface ExtensionInternals {
|
|
15
|
+
resolveWebviewView(viewId: string, payload: {
|
|
16
|
+
title?: string;
|
|
17
|
+
visible?: boolean;
|
|
18
|
+
}): void;
|
|
19
|
+
deliverViewMessage(viewId: string, message: unknown): void;
|
|
20
|
+
setViewVisibility(viewId: string, visible: boolean): void;
|
|
21
|
+
disposeView(viewId: string): void;
|
|
22
|
+
}
|
|
23
|
+
export declare function createExtensionApi(binding: HostBinding): {
|
|
24
|
+
api: GratuxApi;
|
|
25
|
+
context: ExtensionContext;
|
|
26
|
+
internal: ExtensionInternals;
|
|
27
|
+
};
|
|
28
|
+
export { invokeProvider, normaliseProviderResults, buildDocument };
|
|
29
|
+
export type { HostBinding, DocumentSnapshot, DocumentSelector, TextEdit, CodeAction, CompletionList, Uri };
|