alemonjs 2.0.3-alpha.1 → 2.0.5-alpha.1
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/app/define-chidren.js +1 -1
- package/lib/app/event-processor-event.js +3 -3
- package/lib/app/event-processor-middleware.js +4 -4
- package/lib/app/hook-use-api.d.ts +4 -6
- package/lib/app/hook-use-api.js +11 -22
- package/lib/app/load.d.ts +4 -4
- package/lib/app/load.js +63 -58
- package/lib/app/message-format.d.ts +8 -2
- package/lib/app/message-format.js +44 -2
- package/lib/app/store.d.ts +42 -5
- package/lib/app/store.js +99 -53
- package/lib/app/utils.d.ts +2 -2
- package/lib/app/utils.js +12 -11
- package/lib/global.d.ts +9 -13
- package/lib/index.d.ts +4 -4
- package/lib/index.js +2 -2
- package/lib/jsx.d.ts +23 -2
- package/lib/jsx.js +39 -1
- package/lib/main.js +1 -1
- package/lib/typing/event/index.d.ts +1 -1
- package/lib/typing/message/index.d.ts +32 -19
- package/lib/typing/store/res.d.ts +17 -7
- package/package.json +1 -1
|
@@ -19,7 +19,7 @@ import { useSend } from './hook-use-api.js';
|
|
|
19
19
|
const expendEvent = async (valueEvent, select, next) => {
|
|
20
20
|
const res = new Response();
|
|
21
21
|
const Send = useSend(valueEvent);
|
|
22
|
-
// 得到所有
|
|
22
|
+
// 得到所有 res
|
|
23
23
|
const StoreResponse = res.value;
|
|
24
24
|
let valueI = 0;
|
|
25
25
|
/**
|
|
@@ -71,8 +71,8 @@ const expendEvent = async (valueEvent, select, next) => {
|
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
73
|
// 检查状态
|
|
74
|
-
if (file?.
|
|
75
|
-
const [state] = useState(file?.
|
|
74
|
+
if (file?.stateKey) {
|
|
75
|
+
const [state] = useState(file?.stateKey);
|
|
76
76
|
if (state == false) {
|
|
77
77
|
// 继续
|
|
78
78
|
nextEvent();
|
|
@@ -19,7 +19,7 @@ import { useSend } from './hook-use-api.js';
|
|
|
19
19
|
const expendMiddleware = async (valueEvent, select, next) => {
|
|
20
20
|
const mw = new Middleware();
|
|
21
21
|
const Send = useSend(valueEvent);
|
|
22
|
-
// 得到所有
|
|
22
|
+
// 得到所有 mws
|
|
23
23
|
const mwFiles = mw.value;
|
|
24
24
|
let valueI = 0;
|
|
25
25
|
// let valueJ = 0
|
|
@@ -37,7 +37,7 @@ const expendMiddleware = async (valueEvent, select, next) => {
|
|
|
37
37
|
next();
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
|
-
// 检查所有
|
|
40
|
+
// 检查所有
|
|
41
41
|
calli();
|
|
42
42
|
};
|
|
43
43
|
/**
|
|
@@ -71,8 +71,8 @@ const expendMiddleware = async (valueEvent, select, next) => {
|
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
73
|
// 检查状态
|
|
74
|
-
if (file?.
|
|
75
|
-
const [state] = useState(file?.
|
|
74
|
+
if (file?.stateKey) {
|
|
75
|
+
const [state] = useState(file?.stateKey);
|
|
76
76
|
if (state == false) {
|
|
77
77
|
// 继续
|
|
78
78
|
nextMiddleware();
|
|
@@ -16,17 +16,15 @@ declare const useMention: <T extends EventKeys>(event: Events[T]) => Promise<Use
|
|
|
16
16
|
*/
|
|
17
17
|
declare const useSend: <T extends EventKeys>(event: Events[T]) => (...val: DataEnums[]) => Promise<any[]>;
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* @param {string} mainDir - 模块的主目录路径。
|
|
22
|
-
* @throws {Error} - 如果 mainDir 无效,抛出错误。
|
|
19
|
+
* 卸载模块
|
|
20
|
+
* @param name
|
|
23
21
|
*/
|
|
24
|
-
declare const unChildren: (
|
|
22
|
+
declare const unChildren: (name?: string) => void;
|
|
25
23
|
/**
|
|
26
24
|
* 废弃,请使用unChildren
|
|
27
25
|
* @deprecated
|
|
28
26
|
*/
|
|
29
|
-
declare const unMount: (
|
|
27
|
+
declare const unMount: () => void;
|
|
30
28
|
/**
|
|
31
29
|
*
|
|
32
30
|
* @param values
|
package/lib/app/hook-use-api.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ChildrenApp } from './store.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* 使用提及。
|
|
3
5
|
* @param {Object} event - 事件对象,包含触发提及的相关信息。
|
|
@@ -41,34 +43,21 @@ const useSend = (event) => {
|
|
|
41
43
|
};
|
|
42
44
|
};
|
|
43
45
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* @param {string} mainDir - 模块的主目录路径。
|
|
47
|
-
* @throws {Error} - 如果 mainDir 无效,抛出错误。
|
|
46
|
+
* 卸载模块
|
|
47
|
+
* @param name
|
|
48
48
|
*/
|
|
49
|
-
const unChildren = (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
// 从 storeMains 中移除
|
|
54
|
-
// const storeMainsIndex = alemonjsCore.storeMains.indexOf(mainDir)
|
|
55
|
-
// if (storeMainsIndex !== -1) {
|
|
56
|
-
// alemonjsCore.storeMains.splice(storeMainsIndex, 1)
|
|
57
|
-
// }
|
|
58
|
-
// 从 storeResponse 中移除
|
|
59
|
-
if (alemonjsCore.storeResponse.find(item => item.source == mainDir)) {
|
|
60
|
-
alemonjsCore.storeResponse = alemonjsCore.storeResponse.filter(item => item.source !== mainDir);
|
|
61
|
-
}
|
|
62
|
-
// 从 storeMiddleware 中移除
|
|
63
|
-
if (alemonjsCore.storeMiddleware.find(item => item.source == mainDir)) {
|
|
64
|
-
alemonjsCore.storeMiddleware = alemonjsCore.storeMiddleware.filter(item => item.source !== mainDir);
|
|
65
|
-
}
|
|
49
|
+
const unChildren = (name = 'main') => {
|
|
50
|
+
const app = new ChildrenApp(name);
|
|
51
|
+
app.un();
|
|
66
52
|
};
|
|
67
53
|
/**
|
|
68
54
|
* 废弃,请使用unChildren
|
|
69
55
|
* @deprecated
|
|
70
56
|
*/
|
|
71
|
-
const unMount =
|
|
57
|
+
const unMount = () => {
|
|
58
|
+
// 警告,已废弃。
|
|
59
|
+
console.warn('unMount 已废弃,请使用 unChildren');
|
|
60
|
+
};
|
|
72
61
|
/**
|
|
73
62
|
*
|
|
74
63
|
* @param values
|
package/lib/app/load.d.ts
CHANGED
|
@@ -2,21 +2,21 @@
|
|
|
2
2
|
* 加载模块
|
|
3
3
|
* @param mainPath
|
|
4
4
|
*/
|
|
5
|
-
declare const loadChildren: (mainPath: string,
|
|
5
|
+
declare const loadChildren: (mainPath: string, appName: string) => Promise<void>;
|
|
6
6
|
/**
|
|
7
7
|
* 废弃,请使用 loadChildren
|
|
8
8
|
* @deprecated
|
|
9
9
|
*/
|
|
10
|
-
declare const loadModule: (mainPath: string,
|
|
10
|
+
declare const loadModule: (mainPath: string, appName: string) => Promise<void>;
|
|
11
11
|
/**
|
|
12
12
|
* 模块文件
|
|
13
13
|
* @param app
|
|
14
14
|
*/
|
|
15
|
-
declare const loadChildrenFile: (
|
|
15
|
+
declare const loadChildrenFile: (appName: string) => Promise<void>;
|
|
16
16
|
/**
|
|
17
17
|
* 废弃,请使用 loadChildrenFile
|
|
18
18
|
* @deprecated
|
|
19
19
|
*/
|
|
20
|
-
declare const moduleChildrenFiles: (
|
|
20
|
+
declare const moduleChildrenFiles: (appName: string) => Promise<void>;
|
|
21
21
|
|
|
22
22
|
export { loadChildren, loadChildrenFile, loadModule, moduleChildrenFiles };
|
package/lib/app/load.js
CHANGED
|
@@ -1,67 +1,26 @@
|
|
|
1
1
|
import { dirname, join } from 'path';
|
|
2
2
|
import { existsSync } from 'fs';
|
|
3
|
-
import { unChildren } from './hook-use-api.js';
|
|
4
3
|
import { showErrorModule, getRecursiveDirFiles, createEventName } from './utils.js';
|
|
5
4
|
import { createRequire } from 'module';
|
|
5
|
+
import { ChildrenApp } from './store.js';
|
|
6
6
|
|
|
7
7
|
const require = createRequire(import.meta.url);
|
|
8
8
|
const mwReg = /^mw(\.|\..*\.)(js|ts|jsx|tsx)$/;
|
|
9
|
-
/**
|
|
10
|
-
* 加载文件
|
|
11
|
-
* @param app
|
|
12
|
-
*/
|
|
13
|
-
const loadChildrenFiles = async (mainDir, node) => {
|
|
14
|
-
const appsDir = join(mainDir, 'apps');
|
|
15
|
-
const appsFiles = getRecursiveDirFiles(appsDir);
|
|
16
|
-
const data = [];
|
|
17
|
-
for (const file of appsFiles) {
|
|
18
|
-
const state = createEventName(file.path, node);
|
|
19
|
-
const reesponse = {
|
|
20
|
-
source: mainDir,
|
|
21
|
-
dir: dirname(file.path),
|
|
22
|
-
path: file.path,
|
|
23
|
-
name: file.name,
|
|
24
|
-
state,
|
|
25
|
-
node
|
|
26
|
-
};
|
|
27
|
-
data.push(reesponse);
|
|
28
|
-
alemonjsCore.storeResponse.push(reesponse);
|
|
29
|
-
}
|
|
30
|
-
const mwDir = join(mainDir, 'middleware');
|
|
31
|
-
const mwFiles = getRecursiveDirFiles(mwDir, item => mwReg.test(item.name));
|
|
32
|
-
const mwData = [];
|
|
33
|
-
for (const file of mwFiles) {
|
|
34
|
-
const state = createEventName(file.path, node, 'mw');
|
|
35
|
-
const middleware = {
|
|
36
|
-
source: mainDir,
|
|
37
|
-
dir: dirname(file.path),
|
|
38
|
-
path: file.path,
|
|
39
|
-
name: file.name,
|
|
40
|
-
state,
|
|
41
|
-
node
|
|
42
|
-
};
|
|
43
|
-
mwData.push(middleware);
|
|
44
|
-
alemonjsCore.storeMiddleware.push(middleware);
|
|
45
|
-
}
|
|
46
|
-
return {
|
|
47
|
-
response: data,
|
|
48
|
-
middleware: mwData
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
9
|
/**
|
|
52
10
|
* 加载模块
|
|
53
11
|
* @param mainPath
|
|
54
12
|
*/
|
|
55
|
-
const loadChildren = async (mainPath,
|
|
13
|
+
const loadChildren = async (mainPath, appName) => {
|
|
56
14
|
if (!mainPath || typeof mainPath !== 'string') {
|
|
57
15
|
logger.error('The module path is not correct');
|
|
58
16
|
return;
|
|
59
17
|
}
|
|
60
18
|
const mainDir = dirname(mainPath);
|
|
19
|
+
const App = new ChildrenApp(appName);
|
|
61
20
|
const show = (e) => {
|
|
62
21
|
showErrorModule(e);
|
|
63
|
-
//
|
|
64
|
-
|
|
22
|
+
// 卸载
|
|
23
|
+
App.un();
|
|
65
24
|
};
|
|
66
25
|
try {
|
|
67
26
|
const moduleApp = await import(`file://${mainPath}`);
|
|
@@ -71,7 +30,7 @@ const loadChildren = async (mainPath, node) => {
|
|
|
71
30
|
if (!moduleApp?.default?._name) {
|
|
72
31
|
throw new Error('The Children name is not correct');
|
|
73
32
|
}
|
|
74
|
-
if (moduleApp.default._name !== '
|
|
33
|
+
if (moduleApp.default._name !== 'app') {
|
|
75
34
|
throw new Error('The Children name is not correct');
|
|
76
35
|
}
|
|
77
36
|
if (!moduleApp?.default?.callback) {
|
|
@@ -84,13 +43,15 @@ const loadChildren = async (mainPath, node) => {
|
|
|
84
43
|
else {
|
|
85
44
|
app = await moduleApp.default.callback();
|
|
86
45
|
}
|
|
46
|
+
App.pushSycle(app);
|
|
87
47
|
const unMounted = async (e) => {
|
|
88
48
|
show(e);
|
|
89
49
|
try {
|
|
90
50
|
await app?.unMounted(e);
|
|
91
51
|
}
|
|
92
52
|
catch (e) {
|
|
93
|
-
|
|
53
|
+
// 卸载周期出意外,不需要进行卸载
|
|
54
|
+
showErrorModule(e);
|
|
94
55
|
}
|
|
95
56
|
};
|
|
96
57
|
// onCreated 创建
|
|
@@ -106,20 +67,65 @@ const loadChildren = async (mainPath, node) => {
|
|
|
106
67
|
}
|
|
107
68
|
// onMounted 加载
|
|
108
69
|
try {
|
|
109
|
-
|
|
110
|
-
|
|
70
|
+
/**
|
|
71
|
+
* load response files
|
|
72
|
+
*/
|
|
73
|
+
const appsDir = join(mainDir, 'apps');
|
|
74
|
+
const appsFiles = getRecursiveDirFiles(appsDir);
|
|
75
|
+
// 使用 新 目录 response
|
|
76
|
+
const responseDir = join(mainDir, 'response');
|
|
77
|
+
const responseFiles = getRecursiveDirFiles(responseDir);
|
|
78
|
+
const files = [...appsFiles, ...responseFiles];
|
|
79
|
+
const resData = [];
|
|
80
|
+
for (const file of files) {
|
|
81
|
+
// 切掉 mainDir
|
|
82
|
+
const url = file.path.replace(mainDir, '');
|
|
83
|
+
const stateKey = createEventName(url, appName);
|
|
84
|
+
const reesponse = {
|
|
85
|
+
input: mainDir,
|
|
86
|
+
dir: dirname(file.path),
|
|
87
|
+
path: file.path,
|
|
88
|
+
name: file.name,
|
|
89
|
+
stateKey,
|
|
90
|
+
appName: appName
|
|
91
|
+
};
|
|
92
|
+
resData.push(reesponse);
|
|
93
|
+
}
|
|
94
|
+
App.pushResponse(resData);
|
|
95
|
+
/**
|
|
96
|
+
* load middleware files
|
|
97
|
+
*/
|
|
98
|
+
const mwDir = join(mainDir, 'middleware');
|
|
99
|
+
const mwFiles = getRecursiveDirFiles(mwDir, item => mwReg.test(item.name));
|
|
100
|
+
const mwData = [];
|
|
101
|
+
for (const file of mwFiles) {
|
|
102
|
+
// 切掉 mainDir
|
|
103
|
+
const url = file.path.replace(mainDir, '');
|
|
104
|
+
const stateKey = createEventName(url, appName);
|
|
105
|
+
const middleware = {
|
|
106
|
+
input: mainDir,
|
|
107
|
+
dir: dirname(file.path),
|
|
108
|
+
path: file.path,
|
|
109
|
+
name: file.name,
|
|
110
|
+
stateKey,
|
|
111
|
+
appName: appName
|
|
112
|
+
};
|
|
113
|
+
mwData.push(middleware);
|
|
114
|
+
}
|
|
115
|
+
App.pushMiddleware(mwData);
|
|
111
116
|
// onMounted 完成索引识别
|
|
112
117
|
if (typeof app?.onMounted == 'function') {
|
|
113
118
|
try {
|
|
114
|
-
await app?.onMounted(
|
|
119
|
+
await app?.onMounted({ response: resData, middleware: mwData });
|
|
120
|
+
// 校验完周期后,再进行挂载。
|
|
121
|
+
// 防止校验过程中,出现初始化完周期,就执行匹配
|
|
122
|
+
App.on();
|
|
115
123
|
}
|
|
116
124
|
catch (e) {
|
|
117
125
|
unMounted(e);
|
|
118
126
|
return;
|
|
119
127
|
}
|
|
120
128
|
}
|
|
121
|
-
// 记录 main
|
|
122
|
-
// alemonjsCore.storeMains.push(mainDir)
|
|
123
129
|
}
|
|
124
130
|
catch (e) {
|
|
125
131
|
unMounted(e);
|
|
@@ -139,20 +145,19 @@ const loadModule = loadChildren;
|
|
|
139
145
|
* 模块文件
|
|
140
146
|
* @param app
|
|
141
147
|
*/
|
|
142
|
-
const loadChildrenFile = async (
|
|
143
|
-
if (typeof
|
|
148
|
+
const loadChildrenFile = async (appName) => {
|
|
149
|
+
if (typeof appName !== 'string') {
|
|
144
150
|
logger.error('The module name is not correct');
|
|
145
151
|
return;
|
|
146
152
|
}
|
|
147
153
|
try {
|
|
148
|
-
const mainPath = require.resolve(
|
|
154
|
+
const mainPath = require.resolve(appName);
|
|
149
155
|
// 不存在 main
|
|
150
156
|
if (!existsSync(mainPath)) {
|
|
151
157
|
logger.error('The main file does not exist', mainPath);
|
|
152
158
|
return;
|
|
153
159
|
}
|
|
154
|
-
|
|
155
|
-
loadChildren(mainPath, node);
|
|
160
|
+
loadChildren(mainPath, appName);
|
|
156
161
|
}
|
|
157
162
|
catch (e) {
|
|
158
163
|
showErrorModule(e);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataText, DataImage, DataImageURL, DataImageFile, DataMention } from '../typing/message/index.js';
|
|
1
|
+
import { DataText, DataImage, DataImageURL, DataImageFile, DataMention, DataButton, ButtonRow, DataButtonGroup } from '../typing/message/index.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* 文本消息
|
|
@@ -32,5 +32,11 @@ declare const ImageFile: (val: DataImageFile["value"]) => DataImageFile;
|
|
|
32
32
|
* @returns
|
|
33
33
|
*/
|
|
34
34
|
declare const Mention: (UserId?: DataMention["value"], options?: DataMention["options"]) => DataMention;
|
|
35
|
+
declare const BT: {
|
|
36
|
+
(title: string, data: DataButton["options"]["data"], options?: Omit<DataButton["options"], "data">): DataButton;
|
|
37
|
+
group(...rows: ButtonRow[]): DataButtonGroup;
|
|
38
|
+
template(value: DataButtonGroup["options"]["template_id"]): DataButtonGroup;
|
|
39
|
+
row(...buttons: DataButton[]): ButtonRow;
|
|
40
|
+
};
|
|
35
41
|
|
|
36
|
-
export { Image, ImageFile, ImageURL, Mention, Text };
|
|
42
|
+
export { BT, Image, ImageFile, ImageURL, Mention, Text };
|
|
@@ -54,11 +54,53 @@ const Mention = (UserId, options) => {
|
|
|
54
54
|
return {
|
|
55
55
|
type: 'Mention',
|
|
56
56
|
value: UserId,
|
|
57
|
-
//
|
|
58
57
|
options: options ?? {
|
|
59
58
|
belong: 'user'
|
|
60
59
|
}
|
|
61
60
|
};
|
|
62
61
|
};
|
|
62
|
+
const BT = (title, data, options) => {
|
|
63
|
+
return {
|
|
64
|
+
type: 'Button',
|
|
65
|
+
value: title,
|
|
66
|
+
options: {
|
|
67
|
+
data,
|
|
68
|
+
...options
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
BT.group = function Group(...rows) {
|
|
73
|
+
return {
|
|
74
|
+
type: 'BT.group',
|
|
75
|
+
value: rows
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
BT.template = function Template(value) {
|
|
79
|
+
return {
|
|
80
|
+
type: 'BT.group',
|
|
81
|
+
value: [],
|
|
82
|
+
options: {
|
|
83
|
+
template_id: value
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
BT.row = function Row(...buttons) {
|
|
88
|
+
return {
|
|
89
|
+
type: 'BT.row',
|
|
90
|
+
value: buttons
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
// const Send = (...x: DataButtonGroup[]) => {
|
|
94
|
+
// return x;
|
|
95
|
+
// };
|
|
96
|
+
// Send(
|
|
97
|
+
// BT.template('123'),
|
|
98
|
+
// BT.group(
|
|
99
|
+
// BT.row(BT("开始", "/开始游戏")),
|
|
100
|
+
// BT.row(BT("百度一下", "https://baidu.com", { isLink: true })),
|
|
101
|
+
// BT.row(BT("是否同意", { click: "/同意", confirm: "/同意", cancel: "/不同意" })),
|
|
102
|
+
// BT.row(BT("哈哈", "/哈哈", { autoEnter: false, showList: true, toolTip: '不支持' }))
|
|
103
|
+
// )
|
|
104
|
+
// )
|
|
63
105
|
|
|
64
|
-
export { Image, ImageFile, ImageURL, Mention, Text };
|
|
106
|
+
export { BT, Image, ImageFile, ImageURL, Mention, Text };
|
package/lib/app/store.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { EventCycleEnum } from '../typing/cycle/index.js';
|
|
1
|
+
import { EventCycleEnum, ChildrenCycle } from '../typing/cycle/index.js';
|
|
2
2
|
import { EventKeys } from '../typing/event/map.js';
|
|
3
|
-
import {
|
|
3
|
+
import { StoreChildrenApp, StoreResponseItem, StoreMiddlewareItem } from '../typing/store/res.js';
|
|
4
4
|
import { StateSubscribeMap, SubscribeKeysMap, SubscribeValue } from '../typing/subscribe/index.js';
|
|
5
5
|
import '../global.js';
|
|
6
6
|
import { ResponseState } from '../typing/state/index.js';
|
|
@@ -21,8 +21,9 @@ declare class Core {
|
|
|
21
21
|
storeState: ResponseState;
|
|
22
22
|
storeStateSubscribe: StateSubscribeMap;
|
|
23
23
|
storeSubscribeList: SubscribeKeysMap;
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
storeChildrenApp: {
|
|
25
|
+
[key: string]: StoreChildrenApp;
|
|
26
|
+
};
|
|
26
27
|
};
|
|
27
28
|
}
|
|
28
29
|
declare class Response {
|
|
@@ -45,9 +46,45 @@ declare class StateSubscribe {
|
|
|
45
46
|
}
|
|
46
47
|
declare class State {
|
|
47
48
|
#private;
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* @param name
|
|
52
|
+
* @param defaultValue 默认,允许匹配
|
|
53
|
+
*/
|
|
48
54
|
constructor(name: string, defaultValue?: boolean);
|
|
49
55
|
get value(): boolean;
|
|
50
56
|
set value(value: boolean);
|
|
51
57
|
}
|
|
58
|
+
declare class ChildrenApp {
|
|
59
|
+
#private;
|
|
60
|
+
constructor(name?: string);
|
|
61
|
+
/**
|
|
62
|
+
* 推送响应体
|
|
63
|
+
* @param data
|
|
64
|
+
*/
|
|
65
|
+
pushResponse(data: StoreResponseItem[]): void;
|
|
66
|
+
/**
|
|
67
|
+
* 推送中间件
|
|
68
|
+
* @param data
|
|
69
|
+
*/
|
|
70
|
+
pushMiddleware(data: StoreMiddlewareItem[]): void;
|
|
71
|
+
/**
|
|
72
|
+
* 推送周期
|
|
73
|
+
* @param data
|
|
74
|
+
*/
|
|
75
|
+
pushSycle(data: ChildrenCycle): void;
|
|
76
|
+
/**
|
|
77
|
+
* 挂载
|
|
78
|
+
*/
|
|
79
|
+
on(): void;
|
|
80
|
+
/**
|
|
81
|
+
* 卸载
|
|
82
|
+
*/
|
|
83
|
+
un(): void;
|
|
84
|
+
/**
|
|
85
|
+
* 获取
|
|
86
|
+
*/
|
|
87
|
+
get value(): StoreChildrenApp;
|
|
88
|
+
}
|
|
52
89
|
|
|
53
|
-
export { Core, Logger, Middleware, Response, State, StateSubscribe, SubscribeList };
|
|
90
|
+
export { ChildrenApp, Core, Logger, Middleware, Response, State, StateSubscribe, SubscribeList };
|
package/lib/app/store.js
CHANGED
|
@@ -103,8 +103,7 @@ class Core {
|
|
|
103
103
|
mount: {},
|
|
104
104
|
unmount: {}
|
|
105
105
|
},
|
|
106
|
-
|
|
107
|
-
storeResponse: [],
|
|
106
|
+
storeChildrenApp: {}
|
|
108
107
|
};
|
|
109
108
|
}
|
|
110
109
|
}
|
|
@@ -114,12 +113,20 @@ class Core {
|
|
|
114
113
|
}
|
|
115
114
|
class Response {
|
|
116
115
|
get value() {
|
|
117
|
-
|
|
116
|
+
// 得到所有 app,得到所有 res
|
|
117
|
+
const data = Object.keys(alemonjsCore.storeChildrenApp).map(key => {
|
|
118
|
+
return alemonjsCore.storeChildrenApp[key].response;
|
|
119
|
+
});
|
|
120
|
+
return data.flat();
|
|
118
121
|
}
|
|
119
122
|
}
|
|
120
123
|
class Middleware {
|
|
121
124
|
get value() {
|
|
122
|
-
|
|
125
|
+
// 得到所有 app,得到所有 res
|
|
126
|
+
const data = Object.keys(alemonjsCore.storeChildrenApp).map(key => {
|
|
127
|
+
return alemonjsCore.storeChildrenApp[key].middleware;
|
|
128
|
+
});
|
|
129
|
+
return data.flat();
|
|
123
130
|
}
|
|
124
131
|
}
|
|
125
132
|
class SubscribeList {
|
|
@@ -154,28 +161,38 @@ class StateSubscribe {
|
|
|
154
161
|
return alemonjsCore.storeStateSubscribe[this.#name];
|
|
155
162
|
}
|
|
156
163
|
}
|
|
164
|
+
class StateProxy {
|
|
165
|
+
create(value = {}) {
|
|
166
|
+
return new Proxy(value, {
|
|
167
|
+
get(target, prop) {
|
|
168
|
+
return prop in target ? target[prop] : false;
|
|
169
|
+
},
|
|
170
|
+
set(target, prop, value) {
|
|
171
|
+
target[prop] = value;
|
|
172
|
+
// 通知所有订阅者
|
|
173
|
+
if (alemonjsCore.storeStateSubscribe[prop]) {
|
|
174
|
+
for (const callback of alemonjsCore.storeStateSubscribe[prop]) {
|
|
175
|
+
callback(value);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return true; // 表示设置成功
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
157
183
|
class State {
|
|
158
184
|
#name = null;
|
|
185
|
+
/**
|
|
186
|
+
*
|
|
187
|
+
* @param name
|
|
188
|
+
* @param defaultValue 默认,允许匹配
|
|
189
|
+
*/
|
|
159
190
|
constructor(name, defaultValue = true) {
|
|
160
191
|
this.#name = name;
|
|
161
192
|
// 不存在,需要初始化
|
|
162
193
|
if (!alemonjsCore.storeState) {
|
|
163
194
|
// 初始化全局状态
|
|
164
|
-
alemonjsCore.storeState = new
|
|
165
|
-
get(target, prop) {
|
|
166
|
-
return prop in target ? target[prop] : false;
|
|
167
|
-
},
|
|
168
|
-
set(target, prop, value) {
|
|
169
|
-
target[prop] = value;
|
|
170
|
-
// 通知所有订阅者
|
|
171
|
-
if (alemonjsCore.storeStateSubscribe[prop]) {
|
|
172
|
-
for (const callback of alemonjsCore.storeStateSubscribe[prop]) {
|
|
173
|
-
callback(value);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
return true; // 表示设置成功
|
|
177
|
-
}
|
|
178
|
-
});
|
|
195
|
+
alemonjsCore.storeState = new StateProxy().create();
|
|
179
196
|
}
|
|
180
197
|
// 如果不存在则设置默认值
|
|
181
198
|
if (!(name in alemonjsCore.storeState)) {
|
|
@@ -189,38 +206,67 @@ class State {
|
|
|
189
206
|
alemonjsCore.storeState[this.#name] = value;
|
|
190
207
|
}
|
|
191
208
|
}
|
|
192
|
-
|
|
193
|
-
//
|
|
194
|
-
|
|
195
|
-
//
|
|
196
|
-
|
|
197
|
-
//
|
|
198
|
-
|
|
199
|
-
//
|
|
200
|
-
|
|
201
|
-
//
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
209
|
+
class ChildrenApp {
|
|
210
|
+
// 名字
|
|
211
|
+
#name = null;
|
|
212
|
+
// 中间件
|
|
213
|
+
#middleware = [];
|
|
214
|
+
// 响应体
|
|
215
|
+
#response = [];
|
|
216
|
+
// 周期
|
|
217
|
+
#cycle = null;
|
|
218
|
+
// create
|
|
219
|
+
constructor(name = 'main') {
|
|
220
|
+
this.#name = name;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* 推送响应体
|
|
224
|
+
* @param data
|
|
225
|
+
*/
|
|
226
|
+
pushResponse(data) {
|
|
227
|
+
this.#response = this.#response.concat(data);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* 推送中间件
|
|
231
|
+
* @param data
|
|
232
|
+
*/
|
|
233
|
+
pushMiddleware(data) {
|
|
234
|
+
this.#middleware = this.#middleware.concat(data);
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* 推送周期
|
|
238
|
+
* @param data
|
|
239
|
+
*/
|
|
240
|
+
pushSycle(data) {
|
|
241
|
+
this.#cycle = data;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* 挂载
|
|
245
|
+
*/
|
|
246
|
+
on() {
|
|
247
|
+
alemonjsCore.storeChildrenApp[this.#name] = {
|
|
248
|
+
name: this.#name,
|
|
249
|
+
middleware: this.#middleware,
|
|
250
|
+
response: this.#response,
|
|
251
|
+
cycle: this.#cycle
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* 卸载
|
|
256
|
+
*/
|
|
257
|
+
un() {
|
|
258
|
+
// 清理
|
|
259
|
+
delete alemonjsCore.storeChildrenApp[this.#name];
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* 获取
|
|
263
|
+
*/
|
|
264
|
+
get value() {
|
|
265
|
+
if (!alemonjsCore.storeChildrenApp[this.#name]) {
|
|
266
|
+
this.on();
|
|
267
|
+
}
|
|
268
|
+
return alemonjsCore.storeChildrenApp[this.#name];
|
|
269
|
+
}
|
|
270
|
+
}
|
|
225
271
|
|
|
226
|
-
export { Core, Logger, Middleware, Response, State, StateSubscribe, SubscribeList };
|
|
272
|
+
export { ChildrenApp, Core, Logger, Middleware, Response, State, StateSubscribe, SubscribeList };
|
package/lib/app/utils.d.ts
CHANGED
|
@@ -23,10 +23,10 @@ declare const useUserHashKey: (event: {
|
|
|
23
23
|
* 创建app名称
|
|
24
24
|
* @param url
|
|
25
25
|
* @param app 模块名
|
|
26
|
-
* @param select 选择事件类型,默认
|
|
26
|
+
* @param select 选择事件类型,默认 res
|
|
27
27
|
* @returns
|
|
28
28
|
*/
|
|
29
|
-
declare const createEventName: (url: string,
|
|
29
|
+
declare const createEventName: (url: string, appKey: string) => string;
|
|
30
30
|
/**
|
|
31
31
|
* 将字符串转为数字
|
|
32
32
|
* @param str
|
package/lib/app/utils.js
CHANGED
|
@@ -29,18 +29,19 @@ const useUserHashKey = (event) => {
|
|
|
29
29
|
* 创建app名称
|
|
30
30
|
* @param url
|
|
31
31
|
* @param app 模块名
|
|
32
|
-
* @param select 选择事件类型,默认
|
|
32
|
+
* @param select 选择事件类型,默认 res
|
|
33
33
|
* @returns
|
|
34
34
|
*/
|
|
35
|
-
const createEventName = (url,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (/.(ts.js)/.test(cur[cur.length])) {
|
|
40
|
-
const name = `${app}:${cur.slice(0, -1).join(':')}`;
|
|
41
|
-
return name;
|
|
35
|
+
const createEventName = (url, appKey) => {
|
|
36
|
+
let uri = url;
|
|
37
|
+
if (process.platform === 'win32') {
|
|
38
|
+
uri = uri.replace(/\\/g, '/');
|
|
42
39
|
}
|
|
43
|
-
|
|
40
|
+
// 去掉空字符串
|
|
41
|
+
const names = uri.split('/').filter(item => item !== '');
|
|
42
|
+
// 去掉最后一个文件名
|
|
43
|
+
names.pop();
|
|
44
|
+
const name = `${appKey}:${names.join(':')}`;
|
|
44
45
|
return name;
|
|
45
46
|
};
|
|
46
47
|
/**
|
|
@@ -59,14 +60,14 @@ const stringToNumber = (str, size = 33) => {
|
|
|
59
60
|
*通过执行无符号位移,将带符号的int转换为无符号*/
|
|
60
61
|
return hash >>> 0;
|
|
61
62
|
};
|
|
62
|
-
const
|
|
63
|
+
const resReg = /^res(\.|\..*\.)(js|ts|jsx|tsx)$/;
|
|
63
64
|
/**
|
|
64
65
|
* 递归获取所有文件
|
|
65
66
|
* @param dir
|
|
66
67
|
* @param condition
|
|
67
68
|
* @returns
|
|
68
69
|
*/
|
|
69
|
-
const getRecursiveDirFiles = (dir, condition = item =>
|
|
70
|
+
const getRecursiveDirFiles = (dir, condition = item => resReg.test(item.name)) => {
|
|
70
71
|
//
|
|
71
72
|
let results = [];
|
|
72
73
|
if (!existsSync(dir))
|
package/lib/global.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OnResponseFunc, OnResponseReversalFunc, OnMiddlewareFunc, OnMiddlewareReversalFunc, DefineChildrenFunc, DefinePlatformFunc } from './typing/event/index.js';
|
|
2
2
|
import { ClientAPI } from './typing/client/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { StoreChildrenApp } from './typing/store/res.js';
|
|
4
4
|
import { StateSubscribeMap, SubscribeKeysMap } from './typing/subscribe/index.js';
|
|
5
5
|
import { LoggerUtils } from './typing/logger/index.js';
|
|
6
6
|
import { ResponseState } from './typing/state/index.js';
|
|
@@ -27,13 +27,11 @@ declare global {
|
|
|
27
27
|
*/
|
|
28
28
|
storeSubscribeList: SubscribeKeysMap;
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* 子模块
|
|
31
31
|
*/
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
*/
|
|
36
|
-
storeResponse: StoreResponseItem[];
|
|
32
|
+
storeChildrenApp: {
|
|
33
|
+
[key: string]: StoreChildrenApp;
|
|
34
|
+
};
|
|
37
35
|
};
|
|
38
36
|
/**
|
|
39
37
|
* 客户端
|
|
@@ -86,13 +84,11 @@ declare const core: {
|
|
|
86
84
|
*/
|
|
87
85
|
storeSubscribeList: SubscribeKeysMap;
|
|
88
86
|
/**
|
|
89
|
-
*
|
|
87
|
+
* 子模块
|
|
90
88
|
*/
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
*/
|
|
95
|
-
storeResponse: StoreResponseItem[];
|
|
89
|
+
storeChildrenApp: {
|
|
90
|
+
[key: string]: StoreChildrenApp;
|
|
91
|
+
};
|
|
96
92
|
};
|
|
97
93
|
|
|
98
94
|
export { core, logger };
|
package/lib/index.d.ts
CHANGED
|
@@ -14,8 +14,8 @@ export { Current, CurrentResult, DefineBot, DefineBotCallback, DefineBotValue, D
|
|
|
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
16
|
export { ClientAPI } from './typing/client/index.js';
|
|
17
|
-
export { DataEnums, DataImage, DataImageFile, DataImageURL, DataMap, DataMention, DataText, MessageDataFormat
|
|
18
|
-
export { StoreMiddleware, StoreMiddlewareItem, StoreResponse, StoreResponseItem } from './typing/store/res.js';
|
|
17
|
+
export { ButtonRow, DataButton, DataButtonGroup, DataEnums, DataImage, DataImageFile, DataImageURL, DataMap, DataMention, DataText, MessageDataFormat } from './typing/message/index.js';
|
|
18
|
+
export { StoreChildrenApp, StoreMiddleware, StoreMiddlewareItem, StoreResponse, StoreResponseItem } from './typing/store/res.js';
|
|
19
19
|
export { StateSubscribeMap, SubscribeKeysMap, SubscribeMap, SubscribeValue } from './typing/subscribe/index.js';
|
|
20
20
|
export { core, logger } from './global.js';
|
|
21
21
|
export { ConfigCore, getConfig, getConfigValue } from './config.js';
|
|
@@ -29,7 +29,7 @@ export { eventState, onState, unEventState, unState, useState } from './app/hook
|
|
|
29
29
|
export { useObserver, useSubscribe } from './app/hook-use-subscribe.js';
|
|
30
30
|
export { loadChildren, loadChildrenFile, loadModule, moduleChildrenFiles } from './app/load.js';
|
|
31
31
|
export { createSendDataFormat, sendToChannel, sendToUser } from './app/message-api.js';
|
|
32
|
-
export { Image, ImageFile, ImageURL, Mention, Text } from './app/message-format.js';
|
|
33
|
-
export { Core, Logger, Middleware, Response, State, StateSubscribe, SubscribeList } from './app/store.js';
|
|
32
|
+
export { BT, Image, ImageFile, ImageURL, Mention, Text } from './app/message-format.js';
|
|
33
|
+
export { ChildrenApp, Core, Logger, Middleware, Response, State, StateSubscribe, SubscribeList } from './app/store.js';
|
|
34
34
|
export { ErrorModule, createEventName, createHash, getInputExportPath, getRecursiveDirFiles, showErrorModule, stringToNumber, useUserHashKey } from './app/utils.js';
|
|
35
35
|
export { run, start } from './main.js';
|
package/lib/index.js
CHANGED
|
@@ -12,7 +12,7 @@ export { eventState, onState, unEventState, unState, useState } from './app/hook
|
|
|
12
12
|
export { useObserver, useSubscribe } from './app/hook-use-subscribe.js';
|
|
13
13
|
export { loadChildren, loadChildrenFile, loadModule, moduleChildrenFiles } from './app/load.js';
|
|
14
14
|
export { createSendDataFormat, sendToChannel, sendToUser } from './app/message-api.js';
|
|
15
|
-
export { Image, ImageFile, ImageURL, Mention, Text } from './app/message-format.js';
|
|
16
|
-
export { Core, Logger, Middleware, Response, State, StateSubscribe, SubscribeList } from './app/store.js';
|
|
15
|
+
export { BT, Image, ImageFile, ImageURL, Mention, Text } from './app/message-format.js';
|
|
16
|
+
export { ChildrenApp, Core, Logger, Middleware, Response, State, StateSubscribe, SubscribeList } from './app/store.js';
|
|
17
17
|
export { ErrorModule, createEventName, createHash, getInputExportPath, getRecursiveDirFiles, showErrorModule, stringToNumber, useUserHashKey } from './app/utils.js';
|
|
18
18
|
export { run, start } from './main.js';
|
package/lib/jsx.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { EventKeys, Events } from './typing/event/map.js';
|
|
3
|
-
import { DataText, DataImageURL, DataImageFile, DataImage, DataMention, DataEnums } from './typing/message/index.js';
|
|
3
|
+
import { DataText, DataImageURL, DataImageFile, DataImage, DataMention, DataEnums, DataButton } from './typing/message/index.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
*
|
|
@@ -54,6 +54,27 @@ declare function Mention(_props: {
|
|
|
54
54
|
}): React.ReactElement<{
|
|
55
55
|
dataType: string;
|
|
56
56
|
}, string | React.JSXElementConstructor<any>>;
|
|
57
|
+
interface BTProps {
|
|
58
|
+
text: DataButton['value'];
|
|
59
|
+
data: DataButton['options']['data'];
|
|
60
|
+
autoEnter?: DataButton['options']['autoEnter'];
|
|
61
|
+
toolTip?: DataButton['options']['toolTip'];
|
|
62
|
+
showList?: DataButton['options']['showList'];
|
|
63
|
+
isLink?: DataButton['options']['isLink'];
|
|
64
|
+
children?: DataButton['value'];
|
|
65
|
+
}
|
|
66
|
+
declare const BT: React.FC<BTProps> & {
|
|
67
|
+
group: React.FC<{
|
|
68
|
+
children?: React.ReactNode;
|
|
69
|
+
}>;
|
|
70
|
+
row: React.FC<{
|
|
71
|
+
children?: React.ReactNode;
|
|
72
|
+
}>;
|
|
73
|
+
template: React.FC<{
|
|
74
|
+
id: string;
|
|
75
|
+
}>;
|
|
76
|
+
};
|
|
77
|
+
|
|
57
78
|
/**
|
|
58
79
|
* 转换数据
|
|
59
80
|
* ***
|
|
@@ -88,4 +109,4 @@ declare const sendToChannel: (channel_id: string, data: React.JSX.Element[]) =>
|
|
|
88
109
|
*/
|
|
89
110
|
declare const sendToUser: (user_id: string, data: React.JSX.Element[]) => Promise<any[]>;
|
|
90
111
|
|
|
91
|
-
export { Image, ImageFile, ImageURL, JSX, Mention, Text, sendToChannel, sendToUser, useSend };
|
|
112
|
+
export { BT, Image, ImageFile, ImageURL, JSX, Mention, Text, sendToChannel, sendToUser, useSend };
|
package/lib/jsx.js
CHANGED
|
@@ -63,6 +63,28 @@ function Mention(_props) {
|
|
|
63
63
|
dataType: 'Mention'
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
|
+
const BT = (_props) => {
|
|
67
|
+
return React.createElement('div', {
|
|
68
|
+
dataType: 'Button',
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
// BT.group 子组件
|
|
72
|
+
BT.group = (_props) => {
|
|
73
|
+
return React.createElement('div', {
|
|
74
|
+
dataType: 'BT.group',
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
BT.template = (_props) => {
|
|
78
|
+
return React.createElement('div', {
|
|
79
|
+
dataType: 'BT.group',
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
// BT.row 子组件
|
|
83
|
+
BT.row = (_props) => {
|
|
84
|
+
return React.createElement('div', {
|
|
85
|
+
dataType: 'BT.row',
|
|
86
|
+
});
|
|
87
|
+
};
|
|
66
88
|
/**
|
|
67
89
|
* 转换数据
|
|
68
90
|
* ***
|
|
@@ -104,6 +126,9 @@ function JSX(...arg) {
|
|
|
104
126
|
}
|
|
105
127
|
: null));
|
|
106
128
|
}
|
|
129
|
+
else if (dataType === 'BT.group') {
|
|
130
|
+
console.log('Button', props, item.type());
|
|
131
|
+
}
|
|
107
132
|
}
|
|
108
133
|
if (data.length === 0) {
|
|
109
134
|
logger.error('Invalid data: data must be a non-empty array');
|
|
@@ -138,5 +163,18 @@ const sendToChannel = async (channel_id, data) => {
|
|
|
138
163
|
const sendToUser = async (user_id, data) => {
|
|
139
164
|
return sendToUser$1(user_id, JSX(...data));
|
|
140
165
|
};
|
|
166
|
+
// const Send = (..._x: any[]) => {
|
|
167
|
+
// //
|
|
168
|
+
// }
|
|
169
|
+
// Send(
|
|
170
|
+
// <BT.template id="12121" />,
|
|
171
|
+
// <BT.group>
|
|
172
|
+
// <BT.row><BT text="登录" data="/登录游戏" /><BT text="退出" data="/退出游戏" /></BT.row>
|
|
173
|
+
// <BT.row><BT text="是否同意" data={{ "click": "/点击", "confirm": "/同意", "cancel": "/不同意" }} /></BT.row>
|
|
174
|
+
// <BT.row><BT text="百度一下" data="htts://baidu.com" isLink /></BT.row>
|
|
175
|
+
// <BT.row><BT text="自动" data="/自动发出" autoEnter /></BT.row>
|
|
176
|
+
// <BT.row><BT text="禁用的" data="/点不了" toolTip="不支持点击" /></BT.row>
|
|
177
|
+
// </BT.group>
|
|
178
|
+
// )
|
|
141
179
|
|
|
142
|
-
export { Image, ImageFile, ImageURL, JSX, Mention, Text, sendToChannel, sendToUser, useSend };
|
|
180
|
+
export { BT, Image, ImageFile, ImageURL, JSX, Mention, Text, sendToChannel, sendToUser, useSend };
|
package/lib/main.js
CHANGED
|
@@ -43,31 +43,44 @@ type DataMention = {
|
|
|
43
43
|
payload?: User | Guild | Channel | 'everyone';
|
|
44
44
|
};
|
|
45
45
|
};
|
|
46
|
+
type DataButton = {
|
|
47
|
+
type: 'Button';
|
|
48
|
+
value: string | {
|
|
49
|
+
title: string;
|
|
50
|
+
label: string;
|
|
51
|
+
};
|
|
52
|
+
options?: {
|
|
53
|
+
toolTip?: string;
|
|
54
|
+
autoEnter?: boolean;
|
|
55
|
+
showList?: boolean;
|
|
56
|
+
data?: string | {
|
|
57
|
+
"click": string;
|
|
58
|
+
"confirm": string;
|
|
59
|
+
"cancel": string;
|
|
60
|
+
};
|
|
61
|
+
isLink?: boolean;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
type ButtonRow = {
|
|
65
|
+
type: 'BT.row';
|
|
66
|
+
value: DataButton[];
|
|
67
|
+
};
|
|
68
|
+
type DataButtonGroup = {
|
|
69
|
+
type: 'BT.group';
|
|
70
|
+
value: ButtonRow[];
|
|
71
|
+
options?: {
|
|
72
|
+
template_id?: string;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
46
75
|
type DataMap = {
|
|
47
76
|
Text: DataText;
|
|
48
77
|
Image: DataImage;
|
|
49
78
|
ImageURL: DataImageURL;
|
|
50
79
|
ImageFile: DataImageFile;
|
|
51
80
|
Mention: DataMention;
|
|
81
|
+
ButtonGroup: DataButtonGroup;
|
|
52
82
|
};
|
|
53
|
-
type
|
|
54
|
-
Text: string | undefined;
|
|
55
|
-
Image: Buffer[] | undefined;
|
|
56
|
-
Link: any;
|
|
57
|
-
Mention: {
|
|
58
|
-
value: string;
|
|
59
|
-
typing: string;
|
|
60
|
-
name: string;
|
|
61
|
-
avatar: string;
|
|
62
|
-
bot: boolean;
|
|
63
|
-
}[] | undefined;
|
|
64
|
-
Button: any;
|
|
65
|
-
File: any;
|
|
66
|
-
Voice: any;
|
|
67
|
-
Video: any;
|
|
68
|
-
ButtonBox: any;
|
|
69
|
-
};
|
|
70
|
-
type DataEnums = DataText | DataImage | DataImageURL | DataImageFile | DataMention;
|
|
83
|
+
type DataEnums = DataText | DataImage | DataImageURL | DataImageFile | DataMention | DataButtonGroup;
|
|
71
84
|
type MessageDataFormat = DataEnums[];
|
|
72
85
|
|
|
73
|
-
export type { DataEnums, DataImage, DataImageFile, DataImageURL, DataMap, DataMention, DataText, MessageDataFormat
|
|
86
|
+
export type { ButtonRow, DataButton, DataButtonGroup, DataEnums, DataImage, DataImageFile, DataImageURL, DataMap, DataMention, DataText, MessageDataFormat };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { ChildrenCycle } from '../cycle/index.js';
|
|
1
2
|
import { EventKeys } from '../event/map.js';
|
|
2
3
|
|
|
3
4
|
type StoreResponseItem = {
|
|
4
5
|
/**
|
|
5
6
|
* 来源
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
+
input: string;
|
|
8
9
|
/**
|
|
9
10
|
* 目录
|
|
10
11
|
*/
|
|
@@ -20,11 +21,11 @@ type StoreResponseItem = {
|
|
|
20
21
|
/**
|
|
21
22
|
* 节点
|
|
22
23
|
*/
|
|
23
|
-
|
|
24
|
+
appName: string;
|
|
24
25
|
/**
|
|
25
26
|
*
|
|
26
27
|
*/
|
|
27
|
-
|
|
28
|
+
stateKey?: string;
|
|
28
29
|
/**
|
|
29
30
|
*
|
|
30
31
|
*/
|
|
@@ -39,12 +40,12 @@ type StoreMiddlewareItem = {
|
|
|
39
40
|
/**
|
|
40
41
|
* 来源
|
|
41
42
|
*/
|
|
42
|
-
|
|
43
|
+
input: string;
|
|
43
44
|
dir: string;
|
|
44
45
|
path: string;
|
|
45
46
|
name: string;
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
appName: string;
|
|
48
|
+
stateKey?: string;
|
|
48
49
|
value?: {
|
|
49
50
|
select: string;
|
|
50
51
|
} | null;
|
|
@@ -61,5 +62,14 @@ type StoreMiddleware = {
|
|
|
61
62
|
type StoreResponse = {
|
|
62
63
|
[key in EventKeys]: StoreMiddlewareItem[];
|
|
63
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
*
|
|
67
|
+
*/
|
|
68
|
+
type StoreChildrenApp = {
|
|
69
|
+
name: string;
|
|
70
|
+
middleware: StoreMiddlewareItem[];
|
|
71
|
+
response: StoreResponseItem[];
|
|
72
|
+
cycle: ChildrenCycle;
|
|
73
|
+
};
|
|
64
74
|
|
|
65
|
-
export type { StoreMiddleware, StoreMiddlewareItem, StoreResponse, StoreResponseItem };
|
|
75
|
+
export type { StoreChildrenApp, StoreMiddleware, StoreMiddlewareItem, StoreResponse, StoreResponseItem };
|