Skip to content

Commit d0fe6ba

Browse files
committed
fix
1 parent 332ba0a commit d0fe6ba

1 file changed

Lines changed: 291 additions & 0 deletions

File tree

src/acode.d.ts

Lines changed: 291 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ declare namespace Acode {
2222
cacheFileUrl: string;
2323
cacheFile: FileSystem;
2424
firstInit: boolean;
25+
ctx: PluginContext | null;
2526
}
2627

2728
type PluginSettingSelectOption =
@@ -55,6 +56,285 @@ declare namespace Acode {
5556
cb: (key: string, value: unknown) => void;
5657
}
5758

59+
interface PluginContext {
60+
created_at: number;
61+
uuid: string;
62+
grantedPermission(permission: string): Promise<boolean>;
63+
listAllPermissions(): Promise<string[]>;
64+
getSecret(key: string, defaultValue?: string): Promise<string>;
65+
setSecret(key: string, value: string): Promise<void>;
66+
}
67+
68+
interface AppConfig {
69+
BASE_URL: string;
70+
SUPPORTED_EDITOR: string;
71+
FILE_NAME_REGEX: RegExp;
72+
FONT_SIZE: RegExp;
73+
DEFAULT_FILE_SESSION: string;
74+
DEFAULT_FILE_NAME: string;
75+
CONSOLE_PORT: number;
76+
SERVER_PORT: number;
77+
PREVIEW_PORT: number;
78+
VIBRATION_TIME: number;
79+
VIBRATION_TIME_LONG: number;
80+
SCROLL_SPEED_FAST_X2: string;
81+
SCROLL_SPEED_NORMAL: string;
82+
SCROLL_SPEED_FAST: string;
83+
SCROLL_SPEED_SLOW: string;
84+
SIDEBAR_SLIDE_START_THRESHOLD_PX: number;
85+
CUSTOM_THEME: string;
86+
FEEDBACK_EMAIL: string;
87+
ERUDA_CDN: string;
88+
PLAY_STORE_URL: string;
89+
API_BASE: string;
90+
SKU_LIST: string[];
91+
LOG_FILE_NAME: string;
92+
DOCS_URL: string;
93+
GITHUB_URL: string;
94+
TELEGRAM_URL: string;
95+
DISCORD_URL: string;
96+
TWITTER_URL: string;
97+
INSTAGRAM_URL: string;
98+
FOXBIZ_URL: string;
99+
HAS_PRO: boolean;
100+
}
101+
102+
interface CodeMirrorNamespace {
103+
autocomplete: unknown;
104+
commands: unknown;
105+
language: typeof import("@codemirror/language");
106+
lezer: typeof import("@lezer/highlight");
107+
lint: unknown;
108+
search: unknown;
109+
state: typeof import("@codemirror/state");
110+
view: typeof import("@codemirror/view");
111+
}
112+
113+
interface LspTransportDescriptor {
114+
kind: "stdio" | "websocket" | "external";
115+
command?: string;
116+
args?: string[];
117+
url?: string;
118+
options?: Record<string, unknown>;
119+
protocols?: string[];
120+
}
121+
122+
interface LspLauncherInstallConfig {
123+
kind?:
124+
| "apk"
125+
| "npm"
126+
| "pip"
127+
| "cargo"
128+
| "github-release"
129+
| "manual"
130+
| "shell";
131+
command?: string;
132+
updateCommand?: string;
133+
uninstallCommand?: string;
134+
label?: string;
135+
source?: string;
136+
executable?: string;
137+
packages?: string[];
138+
pipCommand?: string;
139+
npmCommand?: string;
140+
pythonCommand?: string;
141+
global?: boolean;
142+
breakSystemPackages?: boolean;
143+
repo?: string;
144+
assetNames?: Record<string, string>;
145+
archiveType?: "zip" | "binary";
146+
extractFile?: string;
147+
binaryPath?: string;
148+
}
149+
150+
interface LspLauncherConfig {
151+
command?: string;
152+
args?: string[];
153+
startCommand?: string | string[];
154+
checkCommand?: string;
155+
versionCommand?: string;
156+
updateCommand?: string;
157+
uninstallCommand?: string;
158+
install?: LspLauncherInstallConfig;
159+
bridge?: {
160+
kind?: "axs";
161+
port?: number;
162+
command?: string;
163+
args?: string[];
164+
session?: string;
165+
};
166+
}
167+
168+
interface LspServerManifest {
169+
id?: string;
170+
label?: string;
171+
enabled?: boolean;
172+
languages?: string[];
173+
transport?: LspTransportDescriptor;
174+
initializationOptions?: Record<string, unknown>;
175+
clientConfig?: Record<string, unknown>;
176+
startupTimeout?: number;
177+
capabilityOverrides?: Record<string, unknown>;
178+
rootUri?:
179+
| ((uri: string, context: unknown) => MaybePromise<string | null>)
180+
| null;
181+
documentUri?:
182+
| ((
183+
uri: string,
184+
context: unknown,
185+
) => MaybePromise<string | null | undefined>)
186+
| null;
187+
resolveLanguageId?:
188+
| ((context: {
189+
languageId: string;
190+
languageName?: string;
191+
uri?: string;
192+
file?: unknown;
193+
}) => string | null)
194+
| null;
195+
launcher?: LspLauncherConfig;
196+
useWorkspaceFolders?: boolean;
197+
}
198+
199+
interface LspServerDefinition extends LspServerManifest {
200+
id: string;
201+
label: string;
202+
enabled: boolean;
203+
languages: string[];
204+
transport: LspTransportDescriptor;
205+
}
206+
207+
interface LspServerBundle {
208+
id: string;
209+
label?: string;
210+
getServers: () => LspServerManifest[];
211+
getExecutable?: (
212+
serverId: string,
213+
manifest: LspServerManifest,
214+
) => string | null | undefined;
215+
checkInstallation?: (
216+
serverId: string,
217+
manifest: LspServerManifest,
218+
) => Promise<unknown>;
219+
installServer?: (
220+
serverId: string,
221+
manifest: LspServerManifest,
222+
mode: "install" | "update" | "reinstall",
223+
options?: { promptConfirm?: boolean },
224+
) => Promise<boolean>;
225+
uninstallServer?: (
226+
serverId: string,
227+
manifest: LspServerManifest,
228+
options?: { promptConfirm?: boolean },
229+
) => Promise<boolean>;
230+
}
231+
232+
type LspRegistrationEntry = LspServerManifest | LspServerBundle;
233+
234+
type LspServerUpdater = (
235+
current: LspServerDefinition,
236+
) => Partial<LspServerDefinition> | null;
237+
238+
type LspRegistryEventType = "register" | "unregister" | "update";
239+
240+
type LspRegistryEventListener = (
241+
event: LspRegistryEventType,
242+
server: LspServerDefinition,
243+
) => void;
244+
245+
interface LspApi {
246+
defineServer(options: LspServerManifest): LspServerManifest;
247+
defineBundle(options: {
248+
id: string;
249+
label?: string;
250+
servers: LspServerManifest[];
251+
hooks?: {
252+
getExecutable?: (
253+
serverId: string,
254+
manifest: LspServerManifest,
255+
) => string | null | undefined;
256+
checkInstallation?: (
257+
serverId: string,
258+
manifest: LspServerManifest,
259+
) => Promise<unknown>;
260+
installServer?: (
261+
serverId: string,
262+
manifest: LspServerManifest,
263+
mode: "install" | "update" | "reinstall",
264+
options?: { promptConfirm?: boolean },
265+
) => Promise<boolean>;
266+
uninstallServer?: (
267+
serverId: string,
268+
manifest: LspServerManifest,
269+
options?: { promptConfirm?: boolean },
270+
) => Promise<boolean>;
271+
};
272+
}): LspServerBundle;
273+
register(
274+
entry: LspRegistrationEntry,
275+
options?: { replace?: boolean },
276+
): LspServerDefinition | LspServerBundle;
277+
upsert(entry: LspRegistrationEntry): LspServerDefinition | LspServerBundle;
278+
installers: {
279+
apk(options: {
280+
packages: string[];
281+
executable: string;
282+
label?: string;
283+
source?: string;
284+
}): LspLauncherInstallConfig;
285+
npm(options: {
286+
packages: string[];
287+
executable: string;
288+
label?: string;
289+
source?: string;
290+
global?: boolean;
291+
}): LspLauncherInstallConfig;
292+
pip(options: {
293+
packages: string[];
294+
executable: string;
295+
label?: string;
296+
source?: string;
297+
breakSystemPackages?: boolean;
298+
}): LspLauncherInstallConfig;
299+
cargo(options: {
300+
packages: string[];
301+
executable: string;
302+
label?: string;
303+
source?: string;
304+
}): LspLauncherInstallConfig;
305+
manual(options: {
306+
binaryPath: string;
307+
executable?: string;
308+
label?: string;
309+
source?: string;
310+
}): LspLauncherInstallConfig;
311+
shell(options: {
312+
command: string;
313+
executable: string;
314+
updateCommand?: string;
315+
uninstallCommand?: string;
316+
label?: string;
317+
source?: string;
318+
}): LspLauncherInstallConfig;
319+
};
320+
servers: {
321+
get(id: string): LspServerDefinition | null;
322+
list(): LspServerDefinition[];
323+
listForLanguage(
324+
languageId: string,
325+
options?: { includeDisabled?: boolean },
326+
): LspServerDefinition[];
327+
update(id: string, updater: LspServerUpdater): LspServerDefinition | null;
328+
unregister(id: string): boolean;
329+
onChange(listener: LspRegistryEventListener): () => void;
330+
};
331+
bundles: {
332+
list(): LspServerBundle[];
333+
getForServer(id: string): LspServerBundle | null;
334+
unregister(id: string): boolean;
335+
};
336+
}
337+
58338
type Require = <K extends keyof Modules | (string & {})>(
59339
moduleName: K,
60340
) => Lowercase<K> extends keyof Modules ? Modules[Lowercase<K>] : unknown;
@@ -66,6 +346,14 @@ declare namespace Acode {
66346
}
67347

68348
interface Modules {
349+
"@codemirror/autocomplete": unknown;
350+
"@codemirror/commands": unknown;
351+
"@codemirror/language": typeof import("@codemirror/language");
352+
"@codemirror/lint": unknown;
353+
"@codemirror/search": unknown;
354+
"@codemirror/state": typeof import("@codemirror/state");
355+
"@codemirror/view": typeof import("@codemirror/view");
356+
"@lezer/highlight": typeof import("@lezer/highlight");
69357
acemodes: AceModes;
70358
actionstack: ActionStack;
71359
addedfolder: AddedFolder;
@@ -81,6 +369,8 @@ declare namespace Acode {
81369
editorlanguages: EditorLanguages;
82370
editorthemes: EditorThemes;
83371
encodings: Encodings;
372+
codemirror: CodeMirrorNamespace;
373+
config: AppConfig;
84374
filebrowser: FileBrowser;
85375
filelist: FileList;
86376
fonts: Fonts;
@@ -92,6 +382,7 @@ declare namespace Acode {
92382
keyboard: Keyboard;
93383
loader: Loader;
94384
multiprompt: MultiPrompt;
385+
lsp: LspApi;
95386
openfolder: OpenFolder;
96387
page: Page;
97388
palette: Palette;

0 commit comments

Comments
 (0)