alemonjs 2.1.54 → 2.1.56
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/event-format.js +1 -1
- package/lib/app/event-processor-cycleRoute.js +1 -0
- package/lib/app/event-processor-subscribe.js +2 -1
- package/package.json +1 -1
- package/lib/app/define/define-children.d.ts +0 -8
- package/lib/app/define/define-children.js +0 -25
- package/lib/app/define/define-middleware.d.ts +0 -2
- package/lib/app/define/define-middleware.js +0 -8
- package/lib/app/define/define-platform.d.ts +0 -13
- package/lib/app/define/define-platform.js +0 -40
- package/lib/app/define/define-response.d.ts +0 -2
- package/lib/app/define/define-response.js +0 -8
- package/lib/app/define/define-router.d.ts +0 -17
- package/lib/app/define/define-router.js +0 -34
- package/lib/app/event/event-group.d.ts +0 -9
- package/lib/app/event/event-group.js +0 -29
- package/lib/app/event/event-middleware.d.ts +0 -23
- package/lib/app/event/event-middleware.js +0 -44
- package/lib/app/event/event-response.d.ts +0 -16
- package/lib/app/event/event-response.js +0 -23
- package/lib/app/event/event-selects.d.ts +0 -13
- package/lib/app/event/event-selects.js +0 -15
- package/lib/app/event-processor/event-processor-callHandler.d.ts +0 -1
- package/lib/app/event-processor/event-processor-callHandler.js +0 -43
- package/lib/app/event-processor/event-processor-cycle.d.ts +0 -14
- package/lib/app/event-processor/event-processor-cycle.js +0 -97
- package/lib/app/event-processor/event-processor-cycleFiles.d.ts +0 -11
- package/lib/app/event-processor/event-processor-cycleFiles.js +0 -147
- package/lib/app/event-processor/event-processor-cycleRoute.d.ts +0 -10
- package/lib/app/event-processor/event-processor-cycleRoute.js +0 -133
- package/lib/app/event-processor/event-processor-event.d.ts +0 -24
- package/lib/app/event-processor/event-processor-event.js +0 -41
- package/lib/app/event-processor/event-processor-middleware.d.ts +0 -14
- package/lib/app/event-processor/event-processor-middleware.js +0 -31
- package/lib/app/event-processor/event-processor-subscribe.d.ts +0 -35
- package/lib/app/event-processor/event-processor-subscribe.js +0 -115
- package/lib/app/event-processor/event-processor.d.ts +0 -17
- package/lib/app/event-processor/event-processor.js +0 -207
- package/lib/app/hook-use/hook-use-api.d.ts +0 -6
- package/lib/app/hook-use/hook-use-api.js +0 -22
- package/lib/app/hook-use/hook-use-channel.d.ts +0 -8
- package/lib/app/hook-use/hook-use-channel.js +0 -33
- package/lib/app/hook-use/hook-use-client.d.ts +0 -7
- package/lib/app/hook-use/hook-use-client.js +0 -27
- package/lib/app/hook-use/hook-use-me.d.ts +0 -8
- package/lib/app/hook-use/hook-use-me.js +0 -45
- package/lib/app/hook-use/hook-use-menber.d.ts +0 -8
- package/lib/app/hook-use/hook-use-menber.js +0 -59
- package/lib/app/hook-use/hook-use-mention.d.ts +0 -23
- package/lib/app/hook-use/hook-use-mention.js +0 -105
- package/lib/app/hook-use/hook-use-message.d.ts +0 -29
- package/lib/app/hook-use/hook-use-message.js +0 -88
- package/lib/app/hook-use/hook-use-state.d.ts +0 -30
- package/lib/app/hook-use/hook-use-state.js +0 -101
- package/lib/app/hook-use/hook-use-subscribe.d.ts +0 -46
- package/lib/app/hook-use/hook-use-subscribe.js +0 -143
- package/lib/app/hook-use-api.d.ts +0 -268
- package/lib/app/hook-use-api.js +0 -1213
- package/lib/app/hook-use-state.d.ts +0 -3
- package/lib/app/hook-use-state.js +0 -68
- package/lib/app/hook-use-subscribe.d.ts +0 -73
- package/lib/app/hook-use-subscribe.js +0 -112
- package/lib/app/message/message-api.d.ts +0 -69
- package/lib/app/message/message-api.js +0 -105
- package/lib/app/message/message-format-old.d.ts +0 -143
- package/lib/app/message/message-format-old.js +0 -359
- package/lib/app/message/message-format.d.ts +0 -215
- package/lib/app/message/message-format.js +0 -382
- package/lib/app/message-controller.d.ts +0 -25
- package/lib/app/message-controller.js +0 -66
- package/lib/app/message-format.old.d.ts +0 -50
- package/lib/app/message-format.old.js +0 -217
- package/lib/cbp/processor/handle.d.ts +0 -3
- package/lib/cbp/processor/handle.js +0 -32
- package/lib/jsx/index.d.ts +0 -105
- package/lib/jsx/index.js +0 -211
- package/lib/jsx/jsx-dev-runtime.d.ts +0 -2
- package/lib/jsx/jsx-dev-runtime.js +0 -1
- package/lib/jsx/jsx-runtime.d.ts +0 -18
- package/lib/jsx/jsx-runtime.js +0 -24
- package/lib/process/client.js +0 -109
- package/lib/store/SinglyLinkedList.d.ts +0 -22
- package/lib/store/SinglyLinkedList.js +0 -97
- package/lib/store/store.d.ts +0 -127
- package/lib/store/store.js +0 -443
package/lib/app/event-format.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getSubscribeList } from './store.js';
|
|
2
2
|
import { SubscribeStatus } from './config.js';
|
|
3
|
+
import { withEventContext } from './hook-event-context.js';
|
|
3
4
|
|
|
4
5
|
const expendSubscribe = (valueEvent, select, next, choose) => {
|
|
5
6
|
const subListValue = getSubscribeList(choose, select);
|
|
@@ -56,7 +57,7 @@ const expendSubscribe = (valueEvent, select, next, choose) => {
|
|
|
56
57
|
nextObserver(...cns);
|
|
57
58
|
}
|
|
58
59
|
};
|
|
59
|
-
item.data.current(valueEvent, Continue);
|
|
60
|
+
withEventContext(valueEvent, Continue, () => item.data.current(valueEvent, Continue));
|
|
60
61
|
};
|
|
61
62
|
nextObserver();
|
|
62
63
|
};
|
package/package.json
CHANGED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { ResultCode } from '../../core/variable.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 定义子事件
|
|
5
|
-
* @param callback
|
|
6
|
-
* @throws {Error} - 如果 callback 无效,抛出错误。
|
|
7
|
-
* @returns
|
|
8
|
-
*/
|
|
9
|
-
const defineChildren = callback => {
|
|
10
|
-
if (typeof callback === 'function' || typeof callback === 'object') {
|
|
11
|
-
return {
|
|
12
|
-
_name: 'app',
|
|
13
|
-
callback
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
logger.error({
|
|
17
|
-
code: ResultCode.FailParams,
|
|
18
|
-
message: 'Invalid callback: callback must be a object or function',
|
|
19
|
-
data: null
|
|
20
|
-
});
|
|
21
|
-
throw new Error('Invalid callback: callback must be a object or function');
|
|
22
|
-
};
|
|
23
|
-
global.defineChildren = defineChildren;
|
|
24
|
-
|
|
25
|
-
export { defineChildren };
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
const definePlatform = (options) => {
|
|
2
|
-
const platformName = options.name || process.env.platform || 'unknown';
|
|
3
|
-
// 开始注册子进程交互
|
|
4
|
-
const mainProcess = () => {
|
|
5
|
-
['SIGINT', 'SIGTERM', 'SIGQUIT', 'disconnect'].forEach(sig => {
|
|
6
|
-
process?.on?.(sig, () => {
|
|
7
|
-
logger.info?.(`[${platformName}][${sig}] 收到信号,正在关闭...`);
|
|
8
|
-
setImmediate(() => process.exit(0));
|
|
9
|
-
});
|
|
10
|
-
});
|
|
11
|
-
process?.on?.('exit', code => {
|
|
12
|
-
logger.info?.(`[${platformName}][exit] 进程退出,code=${code}`);
|
|
13
|
-
});
|
|
14
|
-
// 监听主进程消息
|
|
15
|
-
process.on('message', msg => {
|
|
16
|
-
try {
|
|
17
|
-
const data = typeof msg === 'string' ? JSON.parse(msg) : msg;
|
|
18
|
-
if (data?.type === 'start') {
|
|
19
|
-
options.main();
|
|
20
|
-
}
|
|
21
|
-
else if (data?.type === 'stop') {
|
|
22
|
-
process.exit(0);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
catch { }
|
|
26
|
-
});
|
|
27
|
-
// 主动发送 ready 消息
|
|
28
|
-
if (process.send) {
|
|
29
|
-
process.send(JSON.stringify({ type: 'ready' }));
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
// 仅当作为平台进程入口加载时才执行 mainProcess,
|
|
33
|
-
if (!global.__client_loaded) {
|
|
34
|
-
mainProcess();
|
|
35
|
-
}
|
|
36
|
-
// 这里是旧兼容性返回
|
|
37
|
-
return options.main;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export { definePlatform };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { DefineRouterFunc } from '../../types';
|
|
2
|
-
/**
|
|
3
|
-
* Lazy load a response handler
|
|
4
|
-
* @param fnc
|
|
5
|
-
* @returns
|
|
6
|
-
*/
|
|
7
|
-
export declare const lazy: <T extends {
|
|
8
|
-
default: any;
|
|
9
|
-
}>(fnc: () => Promise<T>) => (() => Promise<T["default"]>);
|
|
10
|
-
/**
|
|
11
|
-
* 定义路由
|
|
12
|
-
* 与 defineResponse 类似,但路由处理器是纯异步函数组件,
|
|
13
|
-
* 内部自动根据 selects 来分类。
|
|
14
|
-
* @param routes 路由配置数组
|
|
15
|
-
* @returns
|
|
16
|
-
*/
|
|
17
|
-
export declare const defineRouter: DefineRouterFunc;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lazy load a response handler
|
|
3
|
-
* @param fnc
|
|
4
|
-
* @returns
|
|
5
|
-
*/
|
|
6
|
-
const lazy = (fnc) => {
|
|
7
|
-
let c = null;
|
|
8
|
-
// fnc 是一个 ()=> imoprt(); 函数。
|
|
9
|
-
const back = async () => {
|
|
10
|
-
if (c) {
|
|
11
|
-
return c;
|
|
12
|
-
}
|
|
13
|
-
const mod = await fnc();
|
|
14
|
-
if (!mod || !mod.default) ;
|
|
15
|
-
c = mod.default;
|
|
16
|
-
// 当back被调用时。
|
|
17
|
-
return c;
|
|
18
|
-
};
|
|
19
|
-
return back;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* 定义路由
|
|
23
|
-
* 与 defineResponse 类似,但路由处理器是纯异步函数组件,
|
|
24
|
-
* 内部自动根据 selects 来分类。
|
|
25
|
-
* @param routes 路由配置数组
|
|
26
|
-
* @returns
|
|
27
|
-
*/
|
|
28
|
-
const defineRouter = routes => {
|
|
29
|
-
return {
|
|
30
|
-
current: routes
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export { defineRouter, lazy };
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 定义一组标准执行导出
|
|
3
|
-
* @param calls
|
|
4
|
-
* @deprecated 废弃
|
|
5
|
-
* @returns
|
|
6
|
-
*/
|
|
7
|
-
const onGroup = (...calls) => {
|
|
8
|
-
if (calls.length === 0) {
|
|
9
|
-
throw new Error('onGroup: 至少需要一个响应或中间件');
|
|
10
|
-
}
|
|
11
|
-
const firstItem = calls[0];
|
|
12
|
-
const baseSelects = firstItem.select;
|
|
13
|
-
// 把如果item是数组的,豆扁平起来。
|
|
14
|
-
const currents = calls.reduce((acc, item) => {
|
|
15
|
-
if (Array.isArray(item.current)) {
|
|
16
|
-
return acc.concat(item.current);
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
return acc.concat(item.current);
|
|
20
|
-
}
|
|
21
|
-
}, []);
|
|
22
|
-
return {
|
|
23
|
-
select: baseSelects,
|
|
24
|
-
current: currents
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
global.onGroup = onGroup;
|
|
28
|
-
|
|
29
|
-
export { onGroup };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview 中间件
|
|
3
|
-
* @module middleware
|
|
4
|
-
* @author ningmengchongshui
|
|
5
|
-
*/
|
|
6
|
-
import { OnMiddlewareReversalFunc, OnMiddlewareReversalFuncBack } from '../../types';
|
|
7
|
-
/**
|
|
8
|
-
* 中间件
|
|
9
|
-
* @param select 事件选择
|
|
10
|
-
* @param callback 回调函数,处理事件和 API
|
|
11
|
-
* @throws {Error} - 如果 select 无效,抛出错误。
|
|
12
|
-
* @throws {Error} - 如果 callback 无效,抛出错误。
|
|
13
|
-
* @returns
|
|
14
|
-
*/
|
|
15
|
-
export declare const onMiddleware: OnMiddlewareReversalFunc;
|
|
16
|
-
/**
|
|
17
|
-
* 废弃,请使用 onMiddleware
|
|
18
|
-
* @deprecated
|
|
19
|
-
* @param select
|
|
20
|
-
* @param callback
|
|
21
|
-
* @returns
|
|
22
|
-
*/
|
|
23
|
-
export declare const OnMiddleware: OnMiddlewareReversalFuncBack;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { ResultCode } from '../../core/variable.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 中间件
|
|
5
|
-
* @param select 事件选择
|
|
6
|
-
* @param callback 回调函数,处理事件和 API
|
|
7
|
-
* @throws {Error} - 如果 select 无效,抛出错误。
|
|
8
|
-
* @throws {Error} - 如果 callback 无效,抛出错误。
|
|
9
|
-
* @returns
|
|
10
|
-
*/
|
|
11
|
-
const onMiddleware = (select, callback) => {
|
|
12
|
-
// 参数检查
|
|
13
|
-
if (typeof callback !== 'function') {
|
|
14
|
-
logger.error({
|
|
15
|
-
code: ResultCode.FailParams,
|
|
16
|
-
message: 'Invalid callback: callback must be a function',
|
|
17
|
-
data: null
|
|
18
|
-
});
|
|
19
|
-
throw new Error('Invalid callback: callback must be a function');
|
|
20
|
-
}
|
|
21
|
-
if (typeof select === 'string' || typeof select === 'object') {
|
|
22
|
-
return { current: callback, select };
|
|
23
|
-
}
|
|
24
|
-
logger.error({
|
|
25
|
-
code: ResultCode.FailParams,
|
|
26
|
-
message: 'Invalid select: select must be a string or object',
|
|
27
|
-
data: null
|
|
28
|
-
});
|
|
29
|
-
throw new Error('Invalid select: select must be a string or object');
|
|
30
|
-
};
|
|
31
|
-
global.onMiddleware = onMiddleware;
|
|
32
|
-
/**
|
|
33
|
-
* 废弃,请使用 onMiddleware
|
|
34
|
-
* @deprecated
|
|
35
|
-
* @param select
|
|
36
|
-
* @param callback
|
|
37
|
-
* @returns
|
|
38
|
-
*/
|
|
39
|
-
const OnMiddleware = (callback, select) => {
|
|
40
|
-
return onMiddleware(select, callback);
|
|
41
|
-
};
|
|
42
|
-
global.OnMiddleware = OnMiddleware;
|
|
43
|
-
|
|
44
|
-
export { OnMiddleware, onMiddleware };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { OnResponseReversalFunc, OnResponseReversalFuncBack } from '../../types';
|
|
2
|
-
/**
|
|
3
|
-
* 处理响应事件
|
|
4
|
-
* @param select 事件选择
|
|
5
|
-
* @param callback 回调函数,处理事件和 API
|
|
6
|
-
* @returns 回调函数的执行结果
|
|
7
|
-
*/
|
|
8
|
-
export declare const onResponse: OnResponseReversalFunc;
|
|
9
|
-
/**
|
|
10
|
-
* 废弃,请使用 onResponse
|
|
11
|
-
* @deprecated
|
|
12
|
-
* @param callback
|
|
13
|
-
* @param select
|
|
14
|
-
* @returns
|
|
15
|
-
*/
|
|
16
|
-
export declare const OnResponse: OnResponseReversalFuncBack;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 处理响应事件
|
|
3
|
-
* @param select 事件选择
|
|
4
|
-
* @param callback 回调函数,处理事件和 API
|
|
5
|
-
* @returns 回调函数的执行结果
|
|
6
|
-
*/
|
|
7
|
-
const onResponse = (select, callback) => {
|
|
8
|
-
return { current: callback, select };
|
|
9
|
-
};
|
|
10
|
-
global.onResponse = onResponse;
|
|
11
|
-
/**
|
|
12
|
-
* 废弃,请使用 onResponse
|
|
13
|
-
* @deprecated
|
|
14
|
-
* @param callback
|
|
15
|
-
* @param select
|
|
16
|
-
* @returns
|
|
17
|
-
*/
|
|
18
|
-
const OnResponse = (callback, select) => {
|
|
19
|
-
return onResponse(select, callback);
|
|
20
|
-
};
|
|
21
|
-
global.OnResponse = OnResponse;
|
|
22
|
-
|
|
23
|
-
export { OnResponse, onResponse };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { EventKeys } from '../../types';
|
|
2
|
-
/**
|
|
3
|
-
* 创建选择器
|
|
4
|
-
* @param values
|
|
5
|
-
* @returns
|
|
6
|
-
*/
|
|
7
|
-
export declare const onSelects: <T extends EventKeys[] | EventKeys>(values: T) => T;
|
|
8
|
-
/**
|
|
9
|
-
* @deprecated 废弃,请使用onSelects
|
|
10
|
-
* @param values
|
|
11
|
-
* @returns
|
|
12
|
-
*/
|
|
13
|
-
export declare const createSelects: <T extends EventKeys[] | EventKeys>(values: T) => T;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 创建选择器
|
|
3
|
-
* @param values
|
|
4
|
-
* @returns
|
|
5
|
-
*/
|
|
6
|
-
const onSelects = (values) => values;
|
|
7
|
-
global.onSelects = onSelects;
|
|
8
|
-
/**
|
|
9
|
-
* @deprecated 废弃,请使用onSelects
|
|
10
|
-
* @param values
|
|
11
|
-
* @returns
|
|
12
|
-
*/
|
|
13
|
-
const createSelects = onSelects;
|
|
14
|
-
|
|
15
|
-
export { createSelects, onSelects };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const createCallHandler: (valueEvent: any) => (currents: any, nextEvent: any) => void;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { showErrorModule } from '../../core/utils.js';
|
|
2
|
-
|
|
3
|
-
const createCallHandler = valueEvent => {
|
|
4
|
-
// 开始处理 handler
|
|
5
|
-
const callHandler = (currents, nextEvent) => {
|
|
6
|
-
let index = 0;
|
|
7
|
-
let isClose = false;
|
|
8
|
-
let isNext = false;
|
|
9
|
-
const start = async () => {
|
|
10
|
-
if (index >= currents.length) {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
if (isNext) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
if (isClose) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
try {
|
|
20
|
-
// 统一使用 await,无需区分同步/异步函数
|
|
21
|
-
const res = await currents[index](valueEvent, (...cns) => {
|
|
22
|
-
isNext = true;
|
|
23
|
-
nextEvent(...cns);
|
|
24
|
-
});
|
|
25
|
-
// return true → 局部中间件放行,继续执行 children handler
|
|
26
|
-
// return void/false → 处理完毕或拦截,停止当前链
|
|
27
|
-
if (res !== true) {
|
|
28
|
-
isClose = true;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
catch (err) {
|
|
32
|
-
showErrorModule(err);
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
++index;
|
|
36
|
-
void start();
|
|
37
|
-
};
|
|
38
|
-
void start();
|
|
39
|
-
};
|
|
40
|
-
return callHandler;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export { createCallHandler };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview 消息处理快
|
|
3
|
-
* 登录模块向核心模块发送数据
|
|
4
|
-
* 核心模块调用模块索引
|
|
5
|
-
* @module processor
|
|
6
|
-
* @author ningmengchongshui
|
|
7
|
-
*/
|
|
8
|
-
import { Events, EventKeys } from '../../types';
|
|
9
|
-
/**
|
|
10
|
-
* 消息体处理机制
|
|
11
|
-
* @param event
|
|
12
|
-
* @param key
|
|
13
|
-
*/
|
|
14
|
-
export declare const expendCycle: <T extends EventKeys>(valueEvent: Events[T], select: T, config?: any) => void;
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { ResultCode } from '../../core/variable.js';
|
|
2
|
-
import { expendEvent } from './event-processor-event.js';
|
|
3
|
-
import { expendMiddleware } from './event-processor-middleware.js';
|
|
4
|
-
import { expendSubscribeCreate, expendSubscribeMount, expendSubscribeUnmount } from './event-processor-subscribe.js';
|
|
5
|
-
import { getConfigValue } from '../../core/config.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 打印日志
|
|
9
|
-
* @param event
|
|
10
|
-
* @param select
|
|
11
|
-
*/
|
|
12
|
-
const showLog = (event, select) => {
|
|
13
|
-
if (process.env.NODE_ENV === 'development') {
|
|
14
|
-
const log = {
|
|
15
|
-
Name: select
|
|
16
|
-
};
|
|
17
|
-
for (const key in event) {
|
|
18
|
-
if (Object.prototype.hasOwnProperty.call(event, key)) {
|
|
19
|
-
const value = event[key];
|
|
20
|
-
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
21
|
-
log[key] = value;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
logger.debug({
|
|
26
|
-
code: ResultCode.Ok,
|
|
27
|
-
message: 'new event',
|
|
28
|
-
data: log
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
// 批量收集非空字段后一次 join — 避免多次 typeof 检查 + 字符串 += 拼接
|
|
33
|
-
const parts = [`[Name:${select}]`];
|
|
34
|
-
const fields = ['GuildId', 'ChannelId', 'UserKey', 'UserId', 'MessageId', 'MessageText'];
|
|
35
|
-
for (const f of fields) {
|
|
36
|
-
const v = event[f];
|
|
37
|
-
if (typeof v === 'string' && v !== '') {
|
|
38
|
-
parts.push(`[${f}:${v}]`);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
logger.info(parts.join(''));
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* 消息体处理机制
|
|
46
|
-
* @param event
|
|
47
|
-
* @param key
|
|
48
|
-
*/
|
|
49
|
-
const expendCycle = (valueEvent, select, config) => {
|
|
50
|
-
const nextEnd = () => { };
|
|
51
|
-
// unmount
|
|
52
|
-
const nextUnMount = (cn, ...cns) => {
|
|
53
|
-
if (cn) {
|
|
54
|
-
nextEnd(...cns);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
void expendSubscribeUnmount(valueEvent, select, nextEnd);
|
|
58
|
-
};
|
|
59
|
-
// event
|
|
60
|
-
const nextEvent = (cn, ...cns) => {
|
|
61
|
-
if (cn) {
|
|
62
|
-
nextUnMount(...cns);
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
void expendEvent(valueEvent, select, nextUnMount);
|
|
66
|
-
};
|
|
67
|
-
// mount
|
|
68
|
-
const nextMount = (cn, ...cns) => {
|
|
69
|
-
if (cn) {
|
|
70
|
-
nextEvent(...cns);
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
void expendSubscribeMount(valueEvent, select, nextEvent);
|
|
74
|
-
};
|
|
75
|
-
// middleware
|
|
76
|
-
const nextCreate = (cn, ...cns) => {
|
|
77
|
-
if (cn) {
|
|
78
|
-
nextMount(...cns);
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
void expendMiddleware(valueEvent, select, nextMount);
|
|
82
|
-
};
|
|
83
|
-
const value = config ?? getConfigValue() ?? {};
|
|
84
|
-
if (Array.isArray(value?.logs?.channel_id)) {
|
|
85
|
-
const channelIds = value?.logs?.channel_id;
|
|
86
|
-
if (channelIds && channelIds.length > 0 && channelIds.includes(valueEvent['ChannelId'])) {
|
|
87
|
-
showLog(valueEvent, select);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
showLog(valueEvent, select);
|
|
92
|
-
}
|
|
93
|
-
// create
|
|
94
|
-
void expendSubscribeCreate(valueEvent, select, nextCreate);
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
export { expendCycle };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Next, Events, EventKeys, StoreResponseItem } from '../../types';
|
|
2
|
-
/**
|
|
3
|
-
* 清除模块缓存(用于热更新等场景)
|
|
4
|
-
*/
|
|
5
|
-
export declare const clearModuleCache: (path?: string) => void;
|
|
6
|
-
/**
|
|
7
|
-
* 创建 next 处理函数
|
|
8
|
-
* @param event
|
|
9
|
-
* @param select
|
|
10
|
-
*/
|
|
11
|
-
export declare const createNextStep: <T extends EventKeys>(valueEvent: Events[T], select: T, next: Next, files: StoreResponseItem[], callHandler: (currents: any, nextEvent: any) => void) => Next;
|