Skip to content

Commit b48e10e

Browse files
authored
Merge pull request #28 from bajrangCoder/main
Fixed typings issue
2 parents 98dc114 + 6442c0f commit b48e10e

File tree

5 files changed

+47
-16
lines changed

5 files changed

+47
-16
lines changed

plugin.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
"readme": "readme.md",
77
"icon": "icon.png",
88
"files": [],
9+
"minVersionCode" : 290,
10+
"price": 0,
911
"author": {
1012
"name": "",
1113
"email": "",
1214
"github": ""
1315
}
14-
}
16+
}

readme.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# Acode plugin
22

3-
Read acode plugin [documentation](https://acode.foxdebug.com/plugin-docs) to develop plugin for acode editor.
3+
> For typescript version of plugin template switch this repo to main-ts
4+
5+
Read acode plugin [documentation](https://acode.foxdebug.com/plugin-docs) to develop plugin for acode editor.

src/main.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ class AcodePlugin {
1313

1414
if (window.acode) {
1515
const acodePlugin = new AcodePlugin();
16-
acode.setPluginInit(plugin.id, (baseUrl, $page, { cacheFileUrl, cacheFile }) => {
16+
acode.setPluginInit(plugin.id, async (baseUrl, $page, { cacheFileUrl, cacheFile }) => {
1717
if (!baseUrl.endsWith('/')) {
1818
baseUrl += '/';
1919
}
2020
acodePlugin.baseUrl = baseUrl;
21-
acodePlugin.init($page, cacheFile, cacheFileUrl);
21+
await acodePlugin.init($page, cacheFile, cacheFileUrl);
2222
});
2323
acode.setPluginUnmount(plugin.id, () => {
2424
acodePlugin.destroy();
2525
});
26-
}
26+
}

typings/acode.d.ts

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
type Input = string;
2+
type Strings = string[];
13

2-
export default class acode {
4+
declare var acode: Acode;
5+
6+
interface Acode {
37
/**
48
* Define a module
59
* @param {string} name
@@ -15,7 +19,11 @@ export default class acode {
1519

1620
setLoadingMessage(message: string): void;
1721

18-
setPluginInit(id: string, initFunction: (baseUrl: string, $page: HTMLElement, options?: any) => Promise<void>, settings: any): void;
22+
setPluginInit(
23+
id: string,
24+
initFunction: (baseUrl: string, $page: HTMLElement, options?: any) => Promise<void>,
25+
settings?: any
26+
): void;
1927

2028
getPluginSettings(id: string): any;
2129

@@ -52,7 +60,7 @@ export default class acode {
5260

5361
loader(title: string, message: string, cancel: { timeout: number,callback: ()=>void }): void;
5462

55-
joinUrl(...args: string): string;
63+
joinUrl(...args: string[]): string;
5664

5765
addIcon(className: string, src: string): void;
5866

@@ -72,23 +80,41 @@ export default class acode {
7280

7381
select(
7482
title: string,
75-
options: string[string, string, string, boolean] | string,
83+
options: [string, string, string, boolean][] | string,
7684
opts?: {
7785
onCancel?: () => void;
7886
onHide?: () => void;
7987
hideOnSelect?: boolean;
8088
textTransform?: boolean;
8189
default?: string;
82-
} | rejectOnCancel: boolean
90+
} | boolean
8391
): Promise<any>;
8492

85-
type Input = string;
86-
87-
type Strings = string[];
88-
8993
multiPrompt(title: string, inputs: Array<Input | Input[]>, help: string): Promise<Strings>;
9094

91-
fileBrowser(mode: 'file' | 'folder' | 'both', info: string, doesOpenLast: boolean): Promise<import('.').SelectedFile>;
95+
fileBrowser(mode: 'file' | 'folder' | 'both', info: string, doesOpenLast: boolean): Promise<
96+
| {
97+
name: string;
98+
type: 'file';
99+
url: string;
100+
}
101+
| {
102+
list: {
103+
icon: string;
104+
isDirectory: boolean;
105+
isFile: boolean;
106+
mime: string;
107+
name: string;
108+
type: 'file' | 'folder';
109+
uri: string;
110+
url: string;
111+
}[];
112+
scroll: number;
113+
name: string;
114+
type: 'folder';
115+
url: string;
116+
}
117+
>;
92118

93-
toInternalUrl(url:string): Promise<url: string>;
119+
toInternalUrl(url: string): Promise<string>;
94120
}

typings/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference path="acode.d.ts" />

0 commit comments

Comments
 (0)