@alemonjs/kook 2.1.0-alpha.3 → 2.1.0-alpha.4
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/lib/config.d.ts +4 -5
- package/lib/config.js +1 -1
- package/lib/core/config.d.ts +8 -0
- package/lib/core/config.js +0 -23
- package/lib/desktop.d.ts +1 -3
- package/lib/desktop.js +0 -9
- package/lib/hook.d.ts +7 -19
- package/lib/hook.js +0 -10
- package/lib/index.d.ts +5 -6
- package/lib/index.js +113 -225
- package/lib/sdk/api.d.ts +3 -117
- package/lib/sdk/api.js +0 -112
- package/lib/sdk/config.d.ts +4 -0
- package/lib/sdk/conversation.d.ts +35 -0
- package/lib/sdk/conversation.js +0 -45
- package/lib/sdk/index.d.ts +2 -0
- package/lib/sdk/index.js +2 -0
- package/lib/sdk/instance.d.ts +3 -0
- package/lib/sdk/instance.js +12 -28
- package/lib/sdk/message/INTERACTION.d.ts +2 -0
- package/lib/sdk/message/INTERACTION.js +1 -0
- package/lib/sdk/message/MEMBER_ADD.d.ts +2 -0
- package/lib/sdk/message/MEMBER_ADD.js +1 -0
- package/lib/sdk/message/MEMBER_REMOVE.d.ts +2 -0
- package/lib/sdk/message/MEMBER_REMOVE.js +1 -0
- package/lib/sdk/message/MESSAGES_DIRECT.d.ts +2 -0
- package/lib/sdk/message/MESSAGES_DIRECT.js +1 -0
- package/lib/sdk/message/MESSAGES_PUBLIC.d.ts +2 -0
- package/lib/sdk/message/MESSAGES_PUBLIC.js +1 -0
- package/lib/sdk/message/REACTIONS.d.ts +2 -0
- package/lib/sdk/message/REACTIONS.js +1 -0
- package/lib/sdk/message.d.ts +24 -0
- package/lib/sdk/message.js +3 -7
- package/lib/sdk/typings.d.ts +192 -43
- package/lib/sdk/typings.js +14 -89
- package/lib/sdk/wss.d.ts +9 -0
- package/lib/sdk/wss.js +10 -39
- package/lib/sdk/wss.types.d.ts +3 -0
- package/lib/sdk/wss.types.js +1 -0
- package/package.json +3 -3
package/lib/config.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
declare const platform = "
|
|
2
|
-
type Options = {
|
|
1
|
+
export declare const platform = "kook";
|
|
2
|
+
export type Options = {
|
|
3
3
|
token: string;
|
|
4
4
|
master_key?: string[];
|
|
5
5
|
master_id?: string[];
|
|
6
6
|
};
|
|
7
|
-
|
|
8
|
-
export
|
|
9
|
-
export type { Options };
|
|
7
|
+
export declare const getKOOKConfig: () => Options;
|
|
8
|
+
export declare const getMaster: (UserId: string) => readonly [boolean, string];
|
package/lib/config.js
CHANGED
package/lib/core/config.js
CHANGED
|
@@ -1,44 +1,21 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 基础配置结构
|
|
3
|
-
*/
|
|
4
1
|
class BaseConfig {
|
|
5
2
|
#data = null;
|
|
6
3
|
constructor(val) {
|
|
7
4
|
this.#data = val;
|
|
8
5
|
}
|
|
9
|
-
/**
|
|
10
|
-
* 设置配置
|
|
11
|
-
* @param key
|
|
12
|
-
* @param val
|
|
13
|
-
*/
|
|
14
6
|
set(key, val) {
|
|
15
7
|
if (val !== undefined) {
|
|
16
8
|
this.#data[key] = val;
|
|
17
9
|
}
|
|
18
10
|
return this;
|
|
19
11
|
}
|
|
20
|
-
/**
|
|
21
|
-
*
|
|
22
|
-
* @param key
|
|
23
|
-
* @returns
|
|
24
|
-
*/
|
|
25
12
|
has(key) {
|
|
26
13
|
if (Object.prototype.hasOwnProperty.call(this.#data, key)) ;
|
|
27
14
|
return false;
|
|
28
15
|
}
|
|
29
|
-
/**
|
|
30
|
-
* 读取配置
|
|
31
|
-
* @param key
|
|
32
|
-
* @returns
|
|
33
|
-
*/
|
|
34
16
|
all() {
|
|
35
17
|
return this.#data;
|
|
36
18
|
}
|
|
37
|
-
/**
|
|
38
|
-
* 读取配置
|
|
39
|
-
* @param key
|
|
40
|
-
* @returns
|
|
41
|
-
*/
|
|
42
19
|
get(key) {
|
|
43
20
|
return this.#data[key];
|
|
44
21
|
}
|
package/lib/desktop.d.ts
CHANGED
package/lib/desktop.js
CHANGED
|
@@ -3,30 +3,22 @@ import { dirname, join } from 'path';
|
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import { getConfig, getConfigValue } from 'alemonjs';
|
|
5
5
|
|
|
6
|
-
// 当前目录
|
|
7
6
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
|
-
// 被激活的时候。
|
|
9
7
|
const activate = context => {
|
|
10
|
-
// 创建一个 webview。
|
|
11
8
|
const webView = context.createSidebarWebView(context);
|
|
12
|
-
// 当命令被触发的时候。
|
|
13
9
|
context.onCommand('open.kook', () => {
|
|
14
10
|
const dir = join(__dirname, '../', 'dist', 'index.html');
|
|
15
11
|
const scriptReg = /<script.*?src="(.+?)".*?>/;
|
|
16
12
|
const styleReg = /<link.*?rel="stylesheet".*?href="(.+?)".*?>/;
|
|
17
13
|
const iconReg = /<link.*?rel="icon".*?href="(.+?)".*?>/g;
|
|
18
|
-
// 创建 webview 路径
|
|
19
14
|
const styleUri = context.createExtensionDir(join(__dirname, '../', 'dist', 'assets', 'index.css'));
|
|
20
15
|
const scriptUri = context.createExtensionDir(join(__dirname, '../', 'dist', 'assets', 'index.js'));
|
|
21
|
-
// 确保路径存在
|
|
22
16
|
const html = readFileSync(dir, 'utf-8')
|
|
23
17
|
.replace(iconReg, '')
|
|
24
18
|
.replace(scriptReg, `<script type="module" crossorigin src="${scriptUri}"></script>`)
|
|
25
19
|
.replace(styleReg, `<link rel="stylesheet" crossorigin href="${styleUri}">`);
|
|
26
|
-
// 立即渲染 webview
|
|
27
20
|
webView.loadWebView(html);
|
|
28
21
|
});
|
|
29
|
-
// 监听 webview 的消息。
|
|
30
22
|
webView.onMessage(data => {
|
|
31
23
|
try {
|
|
32
24
|
if (data.type === 'kook.form.save') {
|
|
@@ -45,7 +37,6 @@ const activate = context => {
|
|
|
45
37
|
if (!config) {
|
|
46
38
|
config = {};
|
|
47
39
|
}
|
|
48
|
-
// 发送消息
|
|
49
40
|
webView.postMessage({
|
|
50
41
|
type: 'kook.init',
|
|
51
42
|
data: config.kook ?? {}
|
package/lib/hook.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { EventKeys, Events } from 'alemonjs';
|
|
2
|
-
import { EventData } from './sdk/typings
|
|
3
|
-
import { KOOKAPI } from './sdk/api.js';
|
|
4
|
-
|
|
2
|
+
import { EventData } from './sdk/typings';
|
|
3
|
+
import { KOOKAPI as API } from './sdk/api.js';
|
|
5
4
|
type MAP = {
|
|
6
5
|
'message.create': EventData;
|
|
7
6
|
'private.message.create': EventData;
|
|
@@ -11,8 +10,8 @@ type MAP = {
|
|
|
11
10
|
'message.delete': undefined;
|
|
12
11
|
'message.reaction.add': undefined;
|
|
13
12
|
'message.reaction.remove': undefined;
|
|
14
|
-
'
|
|
15
|
-
'
|
|
13
|
+
'channel.create': undefined;
|
|
14
|
+
'channel.delete': undefined;
|
|
16
15
|
'guild.join': undefined;
|
|
17
16
|
'guild.exit': undefined;
|
|
18
17
|
'member.add': undefined;
|
|
@@ -22,17 +21,6 @@ type MAP = {
|
|
|
22
21
|
'private.friend.add': undefined;
|
|
23
22
|
'private.guild.add': undefined;
|
|
24
23
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
* @returns
|
|
29
|
-
*/
|
|
30
|
-
declare const useValue: <T extends EventKeys>(event: Events[T]) => readonly [MAP[T]];
|
|
31
|
-
/**
|
|
32
|
-
*
|
|
33
|
-
* @param event
|
|
34
|
-
* @returns
|
|
35
|
-
*/
|
|
36
|
-
declare const useClient: <T extends EventKeys>(event: Events[T]) => readonly [KOOKAPI, MAP[T]];
|
|
37
|
-
|
|
38
|
-
export { useClient, useValue };
|
|
24
|
+
export declare const useValue: <T extends EventKeys>(event: Events[T]) => readonly [MAP[T]];
|
|
25
|
+
export declare const useClient: <T extends EventKeys>(event: Events[T]) => readonly [API, MAP[T]];
|
|
26
|
+
export {};
|
package/lib/hook.js
CHANGED
|
@@ -1,20 +1,10 @@
|
|
|
1
1
|
import { createEventValue, useClient as useClient$1 } from 'alemonjs';
|
|
2
2
|
import { KOOKAPI } from './sdk/api.js';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
* @param event
|
|
7
|
-
* @returns
|
|
8
|
-
*/
|
|
9
4
|
const useValue = (event) => {
|
|
10
5
|
const value = createEventValue(event);
|
|
11
6
|
return [value];
|
|
12
7
|
};
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
15
|
-
* @param event
|
|
16
|
-
* @returns
|
|
17
|
-
*/
|
|
18
8
|
const useClient = (event) => {
|
|
19
9
|
const [client] = useClient$1(event, KOOKAPI);
|
|
20
10
|
const value = createEventValue(event);
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export
|
|
2
|
-
export {
|
|
1
|
+
export * from './hook.js';
|
|
2
|
+
export { platform } from './config.js';
|
|
3
3
|
export { KOOKAPI as API } from './sdk/api.js';
|
|
4
|
-
|
|
5
|
-
declare const
|
|
6
|
-
|
|
7
|
-
export { main as default };
|
|
4
|
+
export { type Options } from './config.js';
|
|
5
|
+
declare const _default: () => any;
|
|
6
|
+
export default _default;
|