alemonjs 2.0.7 → 2.0.9
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/README.md +16 -16
- package/lib/app/code.d.ts +9 -9
- package/lib/app/code.js +14 -14
- package/lib/app/event-middleware.js +1 -1
- package/lib/app/event-processor-cycle.js +1 -1
- package/lib/app/hook-use-api.d.ts +4 -3
- package/lib/app/message-api.d.ts +4 -14
- package/lib/code.d.ts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/jsx.d.ts +4 -13
- package/lib/typing/client/index.d.ts +10 -14
- package/package.json +1 -1
- package/tsconfig.json +0 -7
package/README.md
CHANGED
|
@@ -8,26 +8,26 @@ yarn add alemonjs @alemonjs/gui -W
|
|
|
8
8
|
|
|
9
9
|
- 启动
|
|
10
10
|
|
|
11
|
-
> src/index.
|
|
11
|
+
> src/index.js
|
|
12
12
|
|
|
13
|
-
```
|
|
13
|
+
```js
|
|
14
14
|
import { start } from 'alemonjs'
|
|
15
|
-
start('src/index.
|
|
15
|
+
start('src/index.js')
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
- 响应
|
|
19
19
|
|
|
20
|
-
> src/
|
|
21
|
-
|
|
22
|
-
```
|
|
23
|
-
import { Text, useSend } from 'alemonjs'
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
> src/response/res.js
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
import { createSelects, onResponse, Text, useSend } from 'alemonjs'
|
|
24
|
+
// 创建事件类型
|
|
25
|
+
export const selects = createSelects(['message.create'])
|
|
26
|
+
// 导出响应
|
|
27
|
+
export default onResponse(selects, event => {
|
|
28
|
+
// 使用发送函数
|
|
29
|
+
const send = useSend(event)
|
|
30
|
+
// 发送文本
|
|
31
|
+
send(Text('Hello Word!'))
|
|
32
|
+
})
|
|
31
33
|
```
|
|
32
|
-
|
|
33
|
-
[配置编辑器](./bin/README.md)
|
package/lib/app/code.d.ts
CHANGED
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
* - 4002: 权限不足
|
|
11
11
|
*/
|
|
12
12
|
declare const ResultCode: {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
type ResultCode = typeof ResultCode[keyof typeof ResultCode]
|
|
13
|
+
readonly Ok: 2000
|
|
14
|
+
readonly Fail: 4000
|
|
15
|
+
readonly FailParams: 4001
|
|
16
|
+
readonly Warn: 2100
|
|
17
|
+
readonly FailAuth: 4002
|
|
18
|
+
readonly FailInternal: 5000
|
|
19
|
+
}
|
|
20
|
+
type ResultCode = (typeof ResultCode)[keyof typeof ResultCode]
|
|
21
21
|
|
|
22
|
-
export { ResultCode }
|
|
22
|
+
export { ResultCode }
|
package/lib/app/code.js
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
* 结果反馈码
|
|
3
3
|
*/
|
|
4
4
|
// 成功码
|
|
5
|
-
const Ok = 2000
|
|
5
|
+
const Ok = 2000 // 成功
|
|
6
6
|
// 警惕码
|
|
7
|
-
const Warn = 2100
|
|
7
|
+
const Warn = 2100 // 任意警告
|
|
8
8
|
// 失败码
|
|
9
|
-
const Fail = 4000
|
|
10
|
-
const FailParams = 4001
|
|
9
|
+
const Fail = 4000 // 未知错误
|
|
10
|
+
const FailParams = 4001 // 参数错误
|
|
11
11
|
// 权限错误
|
|
12
|
-
const FailAuth = 4002
|
|
12
|
+
const FailAuth = 4002 // 权限不足
|
|
13
13
|
// 内部错误
|
|
14
|
-
const FailInternal = 5000
|
|
14
|
+
const FailInternal = 5000 // 内部错误
|
|
15
15
|
/**
|
|
16
16
|
* 结果反馈码
|
|
17
17
|
* @description
|
|
@@ -21,12 +21,12 @@ const FailInternal = 5000; // 内部错误
|
|
|
21
21
|
* - 4002: 权限不足
|
|
22
22
|
*/
|
|
23
23
|
const ResultCode = {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
24
|
+
Ok,
|
|
25
|
+
Fail,
|
|
26
|
+
FailParams,
|
|
27
|
+
Warn,
|
|
28
|
+
FailAuth,
|
|
29
|
+
FailInternal
|
|
30
|
+
}
|
|
31
31
|
|
|
32
|
-
export { ResultCode }
|
|
32
|
+
export { ResultCode }
|
|
@@ -39,7 +39,7 @@ const OnMiddleware = (callback, select) => {
|
|
|
39
39
|
message: 'OnMiddleware is deprecated, please use onMiddleware',
|
|
40
40
|
data: null
|
|
41
41
|
});
|
|
42
|
-
return
|
|
42
|
+
return { select, current: callback };
|
|
43
43
|
};
|
|
44
44
|
global.OnMiddleware = OnMiddleware;
|
|
45
45
|
|
|
@@ -10,7 +10,7 @@ import { expendSubscribeCreate, expendSubscribeMount, expendSubscribeUnmount } f
|
|
|
10
10
|
*/
|
|
11
11
|
const showLog = (event, select) => {
|
|
12
12
|
const log = {
|
|
13
|
-
|
|
13
|
+
Name: select
|
|
14
14
|
};
|
|
15
15
|
if (typeof event['ChannelId'] == 'string' && event['ChannelId'] != '') {
|
|
16
16
|
log['ChannelId'] = event['ChannelId'];
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Result } from './utils.js';
|
|
2
1
|
import { EventKeys, Events } from '../typing/event/map.js';
|
|
3
|
-
import '../
|
|
2
|
+
import { ClientAPIMessageResult } from '../typing/client/index.js';
|
|
4
3
|
import { DataEnums } from '../typing/message/index.js';
|
|
4
|
+
import '../global.js';
|
|
5
|
+
import { Result } from './utils.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* 使用提及。
|
|
@@ -29,7 +30,7 @@ declare const useMention: <T extends EventKeys>(event: Events[T]) => {
|
|
|
29
30
|
* @param {Object} event - 事件对象,包含触发发送的相关信息。
|
|
30
31
|
* @throws {Error} - 如果 event 无效,抛出错误。
|
|
31
32
|
*/
|
|
32
|
-
declare const useSend: <T extends EventKeys>(event: Events[T]) => (...val: DataEnums[]) => Promise<Result>;
|
|
33
|
+
declare const useSend: <T extends EventKeys>(event: Events[T]) => (...val: DataEnums[]) => Promise<Result | ClientAPIMessageResult[]>;
|
|
33
34
|
/**
|
|
34
35
|
* 卸载模块
|
|
35
36
|
* @param name
|
package/lib/app/message-api.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import '../global.js';
|
|
1
|
+
import { ClientAPIMessageResult } from '../typing/client/index.js';
|
|
3
2
|
import { DataEnums } from '../typing/message/index.js';
|
|
3
|
+
import '../global.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* 创建数据格式。
|
|
@@ -15,23 +15,13 @@ declare const createSendDataFormat: (...data: DataEnums[]) => DataEnums[];
|
|
|
15
15
|
* @param {DataEnums[]} data - 要发送的数据。
|
|
16
16
|
* @throws {Error} - 如果 channel_id 无效或发送失败,抛出错误。
|
|
17
17
|
*/
|
|
18
|
-
declare const sendToChannel: (channel_id: string, data: DataEnums[]) => Promise<
|
|
19
|
-
data: {
|
|
20
|
-
[key: string]: any;
|
|
21
|
-
id: string;
|
|
22
|
-
};
|
|
23
|
-
})[]>;
|
|
18
|
+
declare const sendToChannel: (channel_id: string, data: DataEnums[]) => Promise<ClientAPIMessageResult[]>;
|
|
24
19
|
/**
|
|
25
20
|
* 向指定用户发送消息。
|
|
26
21
|
* @param {string} user_id - 目标用户的 ID。
|
|
27
22
|
* @param {DataEnums[]} data - 要发送的数据。
|
|
28
23
|
* @throws {Error} - 如果 user_id 无效或发送失败,抛出错误。
|
|
29
24
|
*/
|
|
30
|
-
declare const sendToUser: (user_id: string, data: DataEnums[]) => Promise<
|
|
31
|
-
data: {
|
|
32
|
-
[key: string]: any;
|
|
33
|
-
id: string;
|
|
34
|
-
};
|
|
35
|
-
}>;
|
|
25
|
+
declare const sendToUser: (user_id: string, data: DataEnums[]) => Promise<ClientAPIMessageResult[]>;
|
|
36
26
|
|
|
37
27
|
export { createSendDataFormat, sendToChannel, sendToUser };
|
package/lib/code.d.ts
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export { ActionsEventEnum } from './typing/event/actions.js';
|
|
|
13
13
|
export { Current, CurrentResult, DefineBot, DefineBotCallback, DefineBotValue, DefineChildrenCallback, DefineChildrenFunc, DefineChildrenValue, DefinePlatformCallback, DefinePlatformFunc, DefinePlatformValue, OnMiddlewareFunc, OnMiddlewareReversalFunc, OnMiddlewareValue, OnResponseFunc, OnResponseReversalFunc, OnResponseValue } from './typing/event/index.js';
|
|
14
14
|
export { EventKeys, Events, EventsEnum, EventsKeyEnum, EventsMessageCreate, EventsMessageCreateEnum, EventsMessageCreateKeys } from './typing/event/map.js';
|
|
15
15
|
export { LoggerUtils } from './typing/logger/index.js';
|
|
16
|
-
export { ClientAPI } from './typing/client/index.js';
|
|
16
|
+
export { ClientAPI, ClientAPIMessageResult } from './typing/client/index.js';
|
|
17
17
|
export { DataEnums, MessageDataFormat } from './typing/message/index.js';
|
|
18
18
|
export { StoreChildrenApp, StoreMiddleware, StoreMiddlewareItem, StoreResponse, StoreResponseItem } from './typing/store/res.js';
|
|
19
19
|
export { StateSubscribeMap, SubscribeKeysMap, SubscribeMap, SubscribeValue } from './typing/subscribe/index.js';
|
package/lib/jsx.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EventKeys, Events } from './typing/event/map.js';
|
|
2
|
+
import { ClientAPIMessageResult } from './typing/client/index.js';
|
|
2
3
|
import { DataEnums } from './typing/message/index.js';
|
|
3
4
|
import { Result } from './app/utils.js';
|
|
4
5
|
import React from 'react';
|
|
@@ -102,30 +103,20 @@ declare function JSX(...arg: React.JSX.Element[]): DataEnums[];
|
|
|
102
103
|
* @param e
|
|
103
104
|
* @returns
|
|
104
105
|
*/
|
|
105
|
-
declare const useSend: <T extends EventKeys>(e: Events[T]) => (...arg: React.JSX.Element[]) => Promise<Result>;
|
|
106
|
+
declare const useSend: <T extends EventKeys>(e: Events[T]) => (...arg: React.JSX.Element[]) => Promise<Result | ClientAPIMessageResult[]>;
|
|
106
107
|
/**
|
|
107
108
|
*
|
|
108
109
|
* @param channel_id
|
|
109
110
|
* @param data
|
|
110
111
|
* @returns
|
|
111
112
|
*/
|
|
112
|
-
declare const sendToChannel: (channel_id: string, data: React.JSX.Element[]) => Promise<
|
|
113
|
-
data: {
|
|
114
|
-
[key: string]: any;
|
|
115
|
-
id: string;
|
|
116
|
-
};
|
|
117
|
-
})[]>;
|
|
113
|
+
declare const sendToChannel: (channel_id: string, data: React.JSX.Element[]) => Promise<ClientAPIMessageResult[]>;
|
|
118
114
|
/**
|
|
119
115
|
*
|
|
120
116
|
* @param user_id
|
|
121
117
|
* @param data
|
|
122
118
|
* @returns
|
|
123
119
|
*/
|
|
124
|
-
declare const sendToUser: (user_id: string, data: React.JSX.Element[]) => Promise<
|
|
125
|
-
data: {
|
|
126
|
-
[key: string]: any;
|
|
127
|
-
id: string;
|
|
128
|
-
};
|
|
129
|
-
}>;
|
|
120
|
+
declare const sendToUser: (user_id: string, data: React.JSX.Element[]) => Promise<ClientAPIMessageResult[]>;
|
|
130
121
|
|
|
131
122
|
export { BT, Image, ImageFile, ImageURL, JSX, Mention, Text, sendToChannel, sendToUser, useSend };
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { EventKeys, Events } from '../event/map.js';
|
|
2
2
|
import { User } from '../event/base/user.js';
|
|
3
3
|
import { DataEnums } from '../message/index.js';
|
|
4
|
-
import { Result } from '../../app/utils.js';
|
|
5
4
|
import '../../global.js';
|
|
5
|
+
import { Result } from '../../app/utils.js';
|
|
6
6
|
|
|
7
|
-
type
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
type ClientAPIMessageResult = Result & {
|
|
8
|
+
data: {
|
|
9
|
+
id: string;
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
};
|
|
10
12
|
};
|
|
11
13
|
type ClientAPI = {
|
|
12
14
|
/**
|
|
@@ -23,9 +25,7 @@ type ClientAPI = {
|
|
|
23
25
|
* @param val
|
|
24
26
|
* @returns
|
|
25
27
|
*/
|
|
26
|
-
send: <T extends EventKeys>(event: Events[T], val: DataEnums[]) => Promise<
|
|
27
|
-
data: SendMessageRes;
|
|
28
|
-
})>;
|
|
28
|
+
send: <T extends EventKeys>(event: Events[T], val: DataEnums[]) => Promise<ClientAPIMessageResult[]>;
|
|
29
29
|
/**
|
|
30
30
|
* 获取提及信息
|
|
31
31
|
* @param event
|
|
@@ -47,18 +47,14 @@ type ClientAPI = {
|
|
|
47
47
|
* @param data
|
|
48
48
|
* @returns
|
|
49
49
|
*/
|
|
50
|
-
channel: (channel_id: string, data: DataEnums[]) => Promise<
|
|
51
|
-
data: SendMessageRes;
|
|
52
|
-
})[]>;
|
|
50
|
+
channel: (channel_id: string, data: DataEnums[]) => Promise<ClientAPIMessageResult[]>;
|
|
53
51
|
/**
|
|
54
52
|
* 向指定用户发送消息
|
|
55
53
|
* @param user_id
|
|
56
54
|
* @param data
|
|
57
55
|
* @returns
|
|
58
56
|
*/
|
|
59
|
-
user: (user_id: string, data: DataEnums[]) => Promise<
|
|
60
|
-
data: SendMessageRes;
|
|
61
|
-
})>;
|
|
57
|
+
user: (user_id: string, data: DataEnums[]) => Promise<ClientAPIMessageResult[]>;
|
|
62
58
|
};
|
|
63
59
|
};
|
|
64
60
|
};
|
|
@@ -68,4 +64,4 @@ type ClientAPI = {
|
|
|
68
64
|
platform: string;
|
|
69
65
|
};
|
|
70
66
|
|
|
71
|
-
export type { ClientAPI };
|
|
67
|
+
export type { ClientAPI, ClientAPIMessageResult };
|
package/package.json
CHANGED