|
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 | + |
9 | 16 | 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 | + |
11 | 20 | 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 | + |
14 | 31 | unmountPlugin(id: string): void; |
| 32 | + |
15 | 33 | registerFormatter(id: string, extensions: string[], format: () => Promise<void>): void; |
| 34 | + |
16 | 35 | unregisterFormatter(id: string): void; |
| 36 | + |
17 | 37 | format(selectIfNull?: boolean): Promise<void>; |
18 | | - fsOperation(file: string): FileSystem; |
19 | | - newEditorFile(filename: string, options?: any): EditorFile; |
20 | | - } |
21 | 38 |
|
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>; |
24 | 94 | } |
0 commit comments