Skip to content

Commit 8f45ba8

Browse files
authored
Added typings for acode
1 parent c1f0d05 commit 8f45ba8

File tree

1 file changed

+86
-16
lines changed

1 file changed

+86
-16
lines changed

typings/acode.d.ts

Lines changed: 86 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,94 @@
1-
declare module 'acode' {
2-
type Module = Object | Function;
3-
4-
interface Acode {
5-
define(name: string, module: Module): void;
6-
require(module: string): Module | undefined;
7-
exec(key: string, val?: any): boolean | undefined;
8-
readonly exitAppMessage: string | undefined;
1+
2+
export default class Acode {
3+
/**
4+
* Define a module
5+
* @param {string} name
6+
* @param {Object|function} module
7+
*/
8+
define(name: string, module: any): void;
9+
10+
require(module: string): any;
11+
12+
exec(key: string, val: any): boolean | undefined;
13+
14+
get exitAppMessage(): string | undefined;
15+
916
setLoadingMessage(message: string): void;
10-
setPluginInit(id: string, initFunction: Function, settings: any): void;
17+
18+
setPluginInit(id: string, initFunction: (baseUrl: string, $page: HTMLElement, options?: any) => Promise<void>, settings: any): void;
19+
1120
getPluginSettings(id: string): any;
12-
setPluginUnmount(id: string, unmountFunction: Function): void;
13-
initPlugin(id: string, baseUrl: Url, $page: HTMLElement, options: any): Promise<void>;
21+
22+
setPluginUnmount(id: string, unmountFunction: () => void): void;
23+
24+
/**
25+
* @param {string} id plugin id
26+
* @param {string} baseUrl local plugin url
27+
* @param {HTMLElement} $page
28+
*/
29+
initPlugin(id: string, baseUrl: string, $page: HTMLElement, options?: any): Promise<void>;
30+
1431
unmountPlugin(id: string): void;
32+
1533
registerFormatter(id: string, extensions: string[], format: () => Promise<void>): void;
34+
1635
unregisterFormatter(id: string): void;
36+
1737
format(selectIfNull?: boolean): Promise<void>;
18-
fsOperation(file: string): FileSystem;
19-
newEditorFile(filename: string, options?: any): EditorFile;
20-
}
2138

22-
const acode: Acode;
23-
export default acode;
39+
fsOperation(file: string): any;
40+
41+
newEditorFile(filename: string, options?: any): void;
42+
43+
// readonly formatters(): { id: string; name: string; exts: string[] }[];
44+
45+
/**
46+
* @param {string[]} extensions
47+
* @returns {Array<[id: string, name: string]>} options
48+
*/
49+
getFormatterFor(extensions: string[]): [id: string, name: string][];
50+
51+
alert(title: string, message: string, onhide: ()=>void): void;
52+
53+
loader(title: string, message: string, cancel: { timeout: number,callback: ()=>void }): void;
54+
55+
joinUrl(...args: string): string;
56+
57+
addIcon(className: string, src: string): void;
58+
59+
async prompt(
60+
message: string,
61+
defaultValue: string,
62+
type: 'textarea' | 'text' | 'number' | 'tel' | 'search' | 'email' | 'url',
63+
options?: {
64+
match: RegExp,
65+
required: boolean,
66+
placeholder: string,
67+
test: (any)=>boolean
68+
}
69+
): Promise<any>;
70+
71+
async confirm(title: string, message: string): Promise<boolean>;
72+
73+
async select(
74+
title: string,
75+
options: string[value: string, text: string, icon: string, disable?: boolean] | string,
76+
opts?: {
77+
onCancel?: () => void;
78+
onHide?: () => void;
79+
hideOnSelect?: boolean;
80+
textTransform?: boolean;
81+
default?: string;
82+
} | rejectOnCancel: boolean
83+
): Promise<any>;
84+
85+
type Input = string;
86+
87+
type Strings = string[];
88+
89+
async multiPrompt(title: string, inputs: Array<Input | Input[]>, help: string): Promise<Strings>;
90+
91+
async fileBrowser(mode: 'file' | 'folder' | 'both', info: string, doesOpenLast: boolean): Promise<import('.').SelectedFile>;
92+
93+
async toInternalUrl(url:string): Promise<url: string>;
2494
}

0 commit comments

Comments
 (0)