alemonjs 2.1.83 → 2.1.85
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 → application}/define-children.js +2 -1
- package/lib/{app → application/format}/message-api.d.ts +2 -2
- package/lib/{app → application/format}/message-api.js +12 -4
- package/lib/{app → application/format}/message-format-old.d.ts +1 -1
- package/lib/{app → application/format}/message-format.d.ts +1 -2
- package/lib/{app → application/format}/message-format.js +0 -2
- package/lib/{app/hook-use → application/hooks}/announce.js +4 -3
- package/lib/{app/hook-use → application/hooks}/channel.js +4 -3
- package/lib/{app/hook-use → application/hooks}/client.d.ts +1 -1
- package/lib/{app/hook-use → application/hooks}/client.js +4 -11
- package/lib/{app/hook-use → application/hooks}/common.d.ts +7 -7
- package/lib/{app/hook-use → application/hooks}/common.js +9 -8
- package/lib/{app/hook-use → application/hooks}/event.js +1 -1
- package/lib/{app/hook-use → application/hooks}/guild.js +4 -3
- package/lib/{app/hook-use → application/hooks}/history.js +4 -3
- package/lib/{app/hook-use → application/hooks}/me.js +12 -7
- package/lib/{app/hook-use → application/hooks}/media.d.ts +3 -3
- package/lib/{app/hook-use → application/hooks}/media.js +4 -3
- package/lib/{app/hook-use → application/hooks}/member.js +4 -3
- package/lib/{app/hook-use → application/hooks}/mention.js +4 -3
- package/lib/{app/hook-use → application/hooks}/message.js +6 -5
- package/lib/{app/hook-use → application/hooks}/permission.js +4 -3
- package/lib/{app/hook-use → application/hooks}/reaction.js +4 -3
- package/lib/{app/hook-use → application/hooks}/request.js +12 -7
- package/lib/{app/hook-use → application/hooks}/role.js +4 -3
- package/lib/{app/hook-use → application/hooks}/subscribe.js +4 -4
- package/lib/{app/hook-use → application/hooks}/user.js +12 -7
- package/lib/application/index.d.ts +29 -0
- package/lib/application/index.js +58 -0
- package/lib/{app → application}/router/dsl.d.ts +1 -1
- package/lib/{app → application}/router/dsl.js +14 -10
- package/lib/{cbp → application/runtime/cbp}/connects/client.d.ts +1 -1
- package/lib/{cbp → application/runtime/cbp}/connects/client.js +43 -50
- package/lib/application/runtime/cbp/index.d.ts +3 -0
- package/lib/application/runtime/cbp/index.js +3 -0
- package/lib/application/runtime/cbp/processor/actions.d.ts +3 -0
- package/lib/application/runtime/cbp/processor/actions.js +58 -0
- package/lib/application/runtime/cbp/processor/api.d.ts +3 -0
- package/lib/application/runtime/cbp/processor/api.js +58 -0
- package/lib/application/runtime/cbp/processor/request-registry.d.ts +8 -0
- package/lib/application/runtime/cbp/processor/request-registry.js +6 -0
- package/lib/application/runtime/client-runtime.d.ts +1 -0
- package/lib/application/runtime/client-runtime.js +95 -0
- package/lib/{app → application/runtime}/event-error.d.ts +1 -1
- package/lib/{app → application/runtime}/event-error.js +1 -1
- package/lib/{app → application/runtime}/event-group.d.ts +1 -1
- package/lib/{app → application/runtime}/event-middleware.d.ts +1 -1
- package/lib/{app → application/runtime}/event-middleware.js +1 -1
- package/lib/{app → application/runtime}/event-processor-callHandler.d.ts +1 -1
- package/lib/{app → application/runtime}/event-processor-callHandler.js +8 -1
- package/lib/{app → application/runtime}/event-processor-cycle.d.ts +1 -1
- package/lib/{app → application/runtime}/event-processor-cycleFiles.d.ts +1 -1
- package/lib/{app → application/runtime}/event-processor-cycleFiles.js +2 -2
- package/lib/{app → application/runtime}/event-processor-cycleRoute.d.ts +1 -1
- package/lib/{app → application/runtime}/event-processor-cycleRoute.js +9 -2
- package/lib/{app → application/runtime}/event-processor-event.d.ts +1 -1
- package/lib/{app → application/runtime}/event-processor-middleware.d.ts +1 -1
- package/lib/{app → application/runtime}/event-processor-subscribe.d.ts +1 -1
- package/lib/{app → application/runtime}/event-processor-subscribe.js +9 -2
- package/lib/{app → application/runtime}/event-processor.d.ts +1 -1
- package/lib/{app → application/runtime}/event-processor.js +4 -3
- package/lib/{app → application/runtime}/event-response.d.ts +1 -1
- package/lib/{app → application/runtime}/event-utils.d.ts +1 -1
- package/lib/{app → application/runtime}/event-utils.js +2 -2
- package/lib/{app → application/runtime}/hook-event-context.d.ts +2 -2
- package/lib/{app → application/runtime}/hook-event-context.js +2 -2
- package/lib/application/runtime/http/index.d.ts +4 -0
- package/lib/application/runtime/http/index.js +4 -0
- package/lib/application/runtime/http/routers/hello.html.d.ts +4 -0
- package/lib/application/runtime/http/routers/hello.html.js +363 -0
- package/lib/{server → application/runtime/http}/routers/router.js +265 -179
- package/lib/{server → application/runtime/http}/routers/utils.d.ts +1 -1
- package/lib/{server → application/runtime/http}/routers/utils.js +22 -8
- package/lib/{server/main.js → application/runtime/http-server.js} +2 -6
- package/lib/{app → application/runtime}/lifecycle-callbacks.d.ts +1 -1
- package/lib/{app → application/runtime}/lifecycle-callbacks.js +2 -7
- package/lib/{app/load_modules → application/runtime/load-modules}/load.js +2 -2
- package/lib/{app/load_modules → application/runtime/load-modules}/loadChild.js +14 -5
- package/lib/{app → application/runtime}/schedule-store.d.ts +1 -1
- package/lib/{app → application/runtime}/schedule-store.js +1 -1
- package/lib/{app → application/runtime}/store.d.ts +14 -19
- package/lib/{app → application/runtime}/store.js +8 -103
- package/lib/application/schedule.d.ts +17 -0
- package/lib/{app/api → application}/schedule.js +1 -1
- package/lib/client.d.ts +1 -1
- package/lib/client.js +1 -117
- package/lib/common/cbp/constants.d.ts +11 -0
- package/lib/common/cbp/constants.js +13 -0
- package/lib/{cbp/connects/connect.js → common/cbp/heartbeat.js} +3 -6
- package/lib/common/cbp/normalize.d.ts +16 -0
- package/lib/common/cbp/normalize.js +324 -0
- package/lib/common/cbp/runtime.d.ts +2 -0
- package/lib/common/cbp/runtime.js +10 -0
- package/lib/common/cbp/typings.d.ts +159 -0
- package/lib/{cbp/connects/base.js → common/cbp/ws-connector.js} +7 -9
- package/lib/{core → common}/config.d.ts +2 -2
- package/lib/{core → common}/config.js +5 -4
- package/lib/common/identity.d.ts +11 -0
- package/lib/common/identity.js +34 -0
- package/lib/common/index.d.ts +15 -0
- package/lib/common/index.js +14 -0
- package/lib/common/logger.d.ts +6 -0
- package/lib/common/logger.js +99 -0
- package/lib/{core → common}/react.js +22 -3
- package/lib/common/result.d.ts +7 -0
- package/lib/common/result.js +19 -0
- package/lib/{core → common}/utils.d.ts +3 -18
- package/lib/{core → common}/utils.js +6 -49
- package/lib/{core → common}/variable.js +1 -1
- package/lib/core/cbp/index.d.ts +1 -0
- package/lib/core/cbp/index.js +1 -0
- package/lib/core/cbp/processor/config.d.ts +8 -0
- package/lib/core/cbp/processor/config.js +29 -0
- package/lib/{cbp → core/cbp}/routers/hello.html.js +1 -1
- package/lib/{cbp → core/cbp}/server/main.js +57 -35
- package/lib/{cbp → core/cbp}/server/testone.d.ts +1 -1
- package/lib/{cbp → core/cbp}/server/testone.js +8 -2
- package/lib/core/index.d.ts +1 -3
- package/lib/core/index.js +1 -3
- package/lib/core/process/index.d.ts +3 -0
- package/lib/{process → core/process}/index.js +0 -1
- package/lib/{process → core/process}/ipc-bridge.js +16 -2
- package/lib/{process → core/process}/module.js +13 -4
- package/lib/{process → core/process}/platform.js +12 -3
- package/lib/core/start.d.ts +2 -0
- package/lib/core/start.js +76 -0
- package/lib/global.d.ts +4 -3
- package/lib/index.d.ts +10 -2
- package/lib/index.js +74 -54
- package/lib/main.d.ts +1 -2
- package/lib/main.js +1 -76
- package/lib/{cbp/connects/platform.d.ts → platform/cbp-platform.d.ts} +2 -2
- package/lib/{cbp/connects/platform.js → platform/cbp-platform.js} +52 -75
- package/lib/{app → platform}/define-platform.js +2 -0
- package/lib/platform/event-value.d.ts +7 -0
- package/lib/platform/event-value.js +5 -0
- package/lib/platform/index.d.ts +5 -0
- package/lib/platform/index.js +5 -0
- package/lib/types/actions.d.ts +20 -1
- package/lib/types/apis.d.ts +2 -1
- package/lib/types/client/index.d.ts +1 -1
- package/lib/types/cycle/index.d.ts +1 -1
- package/lib/types/event/index.d.ts +1 -1
- package/lib/types/subscribe/index.d.ts +1 -1
- package/package.json +22 -1
- package/lib/app/api/schedule.d.ts +0 -17
- package/lib/app/index.d.ts +0 -25
- package/lib/app/index.js +0 -47
- package/lib/cbp/index.d.ts +0 -3
- package/lib/cbp/index.js +0 -3
- package/lib/cbp/processor/actions.d.ts +0 -3
- package/lib/cbp/processor/actions.js +0 -48
- package/lib/cbp/processor/api.d.ts +0 -3
- package/lib/cbp/processor/api.js +0 -48
- package/lib/cbp/processor/config.d.ts +0 -29
- package/lib/cbp/processor/config.js +0 -52
- package/lib/cbp/typings.d.ts +0 -20
- package/lib/process/index.d.ts +0 -4
- package/lib/server/routers/hello.html.d.ts +0 -2
- package/lib/server/routers/hello.html.js +0 -31
- /package/lib/{app → application}/define-children.d.ts +0 -0
- /package/lib/{app → application}/define-middleware.d.ts +0 -0
- /package/lib/{app → application}/define-middleware.js +0 -0
- /package/lib/{app → application}/define-response.d.ts +0 -0
- /package/lib/{app → application}/define-response.js +0 -0
- /package/lib/{app → application}/define-router.d.ts +0 -0
- /package/lib/{app → application}/define-router.js +0 -0
- /package/lib/{app → application}/expose.d.ts +0 -0
- /package/lib/{app → application}/expose.js +0 -0
- /package/lib/{app → application/format}/message-format-old.js +0 -0
- /package/lib/{app/hook-use → application/hooks}/announce.d.ts +0 -0
- /package/lib/{app/hook-use → application/hooks}/channel.d.ts +0 -0
- /package/lib/{app/hook-use → application/hooks}/event.d.ts +0 -0
- /package/lib/{app/hook-use → application/hooks}/guild.d.ts +0 -0
- /package/lib/{app/hook-use → application/hooks}/history.d.ts +0 -0
- /package/lib/{app/hook-use → application/hooks}/index.d.ts +0 -0
- /package/lib/{app/hook-use → application/hooks}/index.js +0 -0
- /package/lib/{app/hook-use → application/hooks}/me.d.ts +0 -0
- /package/lib/{app/hook-use → application/hooks}/member.d.ts +0 -0
- /package/lib/{app/hook-use → application/hooks}/mention.d.ts +0 -0
- /package/lib/{app/hook-use → application/hooks}/message.d.ts +0 -0
- /package/lib/{app/hook-use → application/hooks}/permission.d.ts +0 -0
- /package/lib/{app/hook-use → application/hooks}/reaction.d.ts +0 -0
- /package/lib/{app/hook-use → application/hooks}/request.d.ts +0 -0
- /package/lib/{app/hook-use → application/hooks}/role.d.ts +0 -0
- /package/lib/{app/hook-use → application/hooks}/route.d.ts +0 -0
- /package/lib/{app/hook-use → application/hooks}/route.js +0 -0
- /package/lib/{app/hook-use → application/hooks}/subscribe.d.ts +0 -0
- /package/lib/{app/hook-use → application/hooks}/user.d.ts +0 -0
- /package/lib/{app → application}/router/fallback.d.ts +0 -0
- /package/lib/{app → application}/router/fallback.js +0 -0
- /package/lib/{app → application}/router/main.d.ts +0 -0
- /package/lib/{app → application}/router/main.js +0 -0
- /package/lib/{app → application}/router/parser.d.ts +0 -0
- /package/lib/{app → application}/router/parser.js +0 -0
- /package/lib/{app → application}/router/types.d.ts +0 -0
- /package/lib/{app → application}/router/types.js +0 -0
- /package/lib/{app → application}/router/validator.d.ts +0 -0
- /package/lib/{app → application}/router/validator.js +0 -0
- /package/lib/{cbp → application/runtime/cbp}/processor/transport.d.ts +0 -0
- /package/lib/{cbp → application/runtime/cbp}/processor/transport.js +0 -0
- /package/lib/{app → application/runtime}/event-group.js +0 -0
- /package/lib/{app → application/runtime}/event-processor-cycle.js +0 -0
- /package/lib/{app → application/runtime}/event-processor-event.js +0 -0
- /package/lib/{app → application/runtime}/event-processor-middleware.js +0 -0
- /package/lib/{app → application/runtime}/event-response.js +0 -0
- /package/lib/{server → application/runtime/http}/routers/middleware.d.ts +0 -0
- /package/lib/{server → application/runtime/http}/routers/middleware.js +0 -0
- /package/lib/{cbp → application/runtime/http}/routers/router.d.ts +0 -0
- /package/lib/{server/main.d.ts → application/runtime/http-server.d.ts} +0 -0
- /package/lib/{app/load_modules → application/runtime/load-modules}/index.d.ts +0 -0
- /package/lib/{app/load_modules → application/runtime/load-modules}/index.js +0 -0
- /package/lib/{app/load_modules → application/runtime/load-modules}/load.d.ts +0 -0
- /package/lib/{app/load_modules → application/runtime/load-modules}/loadChild.d.ts +0 -0
- /package/lib/{app/config.d.ts → application/runtime/subscribe-status.d.ts} +0 -0
- /package/lib/{app/config.js → application/runtime/subscribe-status.js} +0 -0
- /package/lib/{app → common}/SinglyLinkedList.d.ts +0 -0
- /package/lib/{app → common}/SinglyLinkedList.js +0 -0
- /package/lib/{cbp/connects/connect.d.ts → common/cbp/heartbeat.d.ts} +0 -0
- /package/lib/{cbp → common/cbp}/typings.js +0 -0
- /package/lib/{cbp/connects/base.d.ts → common/cbp/ws-connector.d.ts} +0 -0
- /package/lib/{process → common}/direct-channel.d.ts +0 -0
- /package/lib/{process → common}/direct-channel.js +0 -0
- /package/lib/{core → common}/react.d.ts +0 -0
- /package/lib/{core → common}/variable.d.ts +0 -0
- /package/lib/{cbp → core/cbp}/routers/hello.html.d.ts +0 -0
- /package/lib/{server → core/cbp}/routers/router.d.ts +0 -0
- /package/lib/{cbp → core/cbp}/routers/router.js +0 -0
- /package/lib/{cbp → core/cbp}/server/main.d.ts +0 -0
- /package/lib/{process → core/process}/ipc-bridge.d.ts +0 -0
- /package/lib/{process → core/process}/module.d.ts +0 -0
- /package/lib/{process → core/process}/platform.d.ts +0 -0
- /package/lib/{app → platform}/define-platform.d.ts +0 -0
- /package/lib/{app → platform}/event-format.d.ts +0 -0
- /package/lib/{app → platform}/event-format.js +0 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { getConfig } from '../common/config.js';
|
|
2
|
+
import { cbpServer } from './cbp/server/main.js';
|
|
3
|
+
import { filePrefixCommon, defaultPlatformCommonPrefix } from '../common/variable.js';
|
|
4
|
+
import { startPlatformAdapterWithFallback } from './process/platform.js';
|
|
5
|
+
import { startModuleAdapter } from './process/module.js';
|
|
6
|
+
import { generateSocketPath } from '../common/direct-channel.js';
|
|
7
|
+
|
|
8
|
+
const createOptionsByKey = (options, key, defaultValue) => {
|
|
9
|
+
const cfg = getConfig();
|
|
10
|
+
const curValue = options?.[key] ?? cfg.argv?.[key];
|
|
11
|
+
const value = curValue ?? cfg.value?.[key] ?? defaultValue;
|
|
12
|
+
return value;
|
|
13
|
+
};
|
|
14
|
+
const startPlatform = (options) => {
|
|
15
|
+
const platform = createOptionsByKey(options, 'platform', '');
|
|
16
|
+
const login = createOptionsByKey(options, 'login', '');
|
|
17
|
+
if (!platform && !login) {
|
|
18
|
+
global.__sandbox = true;
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
void startPlatformAdapterWithFallback();
|
|
22
|
+
};
|
|
23
|
+
const startClient = (options) => {
|
|
24
|
+
process.env.input = createOptionsByKey(options, 'input', '');
|
|
25
|
+
process.env.output = createOptionsByKey(options, 'output', '');
|
|
26
|
+
process.env.is_full_receive = String(createOptionsByKey(options, 'is_full_receive', true));
|
|
27
|
+
process.env.port = String(createOptionsByKey(options, 'port', '') || '');
|
|
28
|
+
process.env.url = createOptionsByKey(options, 'url', '');
|
|
29
|
+
startModuleAdapter();
|
|
30
|
+
};
|
|
31
|
+
const start = (options = {}) => {
|
|
32
|
+
if (typeof options === 'string') {
|
|
33
|
+
options = { input: options };
|
|
34
|
+
}
|
|
35
|
+
global.__options = options;
|
|
36
|
+
const port = createOptionsByKey(options, 'port', '');
|
|
37
|
+
const serverPort = createOptionsByKey(options, 'serverPort', '');
|
|
38
|
+
const platform = createOptionsByKey(options, 'platform', '');
|
|
39
|
+
const login = createOptionsByKey(options, 'login', '');
|
|
40
|
+
if (platform) {
|
|
41
|
+
const reg = filePrefixCommon;
|
|
42
|
+
if (reg.test(platform)) {
|
|
43
|
+
process.env.platform = platform;
|
|
44
|
+
process.env.login = platform.replace(reg, '');
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
process.env.platform = platform;
|
|
48
|
+
process.env.login = platform;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else if (login) {
|
|
52
|
+
process.env.platform = `${defaultPlatformCommonPrefix}${login}`;
|
|
53
|
+
process.env.login = login;
|
|
54
|
+
}
|
|
55
|
+
process.env.port = port ? String(port) : '';
|
|
56
|
+
process.env.serverPort = serverPort;
|
|
57
|
+
if (port) {
|
|
58
|
+
cbpServer(port, () => {
|
|
59
|
+
const httpURL = `http://127.0.0.1:${port}`;
|
|
60
|
+
const wsURL = `ws://127.0.0.1:${port}`;
|
|
61
|
+
logger.info(`[CBP-Server] ${httpURL}`);
|
|
62
|
+
logger.info(`[CBP-Server] ${wsURL}]`);
|
|
63
|
+
startClient(options);
|
|
64
|
+
startPlatform(options);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
const sockPath = generateSocketPath();
|
|
69
|
+
process.env.__ALEMON_DIRECT_SOCK = sockPath;
|
|
70
|
+
logger.info('[Direct-IPC] 平台↔客户端直连');
|
|
71
|
+
startClient(options);
|
|
72
|
+
startPlatform(options);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export { start };
|
package/lib/global.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { DefineChildrenFunc, OnResponseReversalFunc, OnMiddlewareReversalFunc, OnSelectsFunc, OnDataFormatFunc, OnResponseReversalFuncBack, OnGroupFunc, OnMiddlewareReversalFuncBack, DefineResponseFunc, defineMiddlewareFunc, StoreChildrenApp, StateSubscribeMap, SubscribeKeysMap, LoggerUtils, ResponseState, StartOptions } from './types';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import { type Server } from 'ws';
|
|
3
|
+
import type WebSocket from 'ws';
|
|
4
|
+
import type { IncomingMessage } from 'http';
|
|
4
5
|
import type KoaRouter from 'koa-router';
|
|
5
|
-
import type { RuntimeAppRecord } from './
|
|
6
|
+
import type { RuntimeAppRecord } from './application/runtime/store.js';
|
|
6
7
|
declare global {
|
|
7
8
|
var __config: any;
|
|
8
9
|
var __options: StartOptions;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
export * from './types/index.js';
|
|
2
2
|
export * from './global.js';
|
|
3
|
+
export * from './common/index.js';
|
|
3
4
|
export * from './core/index.js';
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
5
|
+
export * from './platform/index.js';
|
|
6
|
+
export * from './application/index.js';
|
|
7
|
+
export { cbpServer } from './core/cbp/index.js';
|
|
8
|
+
export { Result } from './common/variable.js';
|
|
9
|
+
export { start } from './main.js';
|
|
6
10
|
export * from './main.js';
|
|
11
|
+
export * as common from './common/index.js';
|
|
12
|
+
export * as core from './core/index.js';
|
|
13
|
+
export * as platform from './platform/index.js';
|
|
14
|
+
export * as application from './application/index.js';
|
package/lib/index.js
CHANGED
|
@@ -1,55 +1,75 @@
|
|
|
1
1
|
export { ActionsEventEnum } from './types/event/actions.js';
|
|
2
|
-
|
|
3
|
-
export {
|
|
4
|
-
|
|
5
|
-
export {
|
|
6
|
-
|
|
7
|
-
export {
|
|
8
|
-
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
21
|
-
export {
|
|
22
|
-
export {
|
|
23
|
-
export {
|
|
24
|
-
export {
|
|
25
|
-
export {
|
|
26
|
-
export {
|
|
27
|
-
export {
|
|
28
|
-
export {
|
|
29
|
-
export {
|
|
30
|
-
export {
|
|
31
|
-
export {
|
|
32
|
-
export {
|
|
33
|
-
export {
|
|
34
|
-
export {
|
|
35
|
-
export {
|
|
36
|
-
export {
|
|
37
|
-
export {
|
|
38
|
-
export {
|
|
39
|
-
export {
|
|
40
|
-
export {
|
|
41
|
-
export {
|
|
42
|
-
export {
|
|
43
|
-
export {
|
|
44
|
-
export {
|
|
45
|
-
export {
|
|
46
|
-
export {
|
|
47
|
-
export {
|
|
48
|
-
export {
|
|
49
|
-
export {
|
|
50
|
-
export {
|
|
51
|
-
export {
|
|
52
|
-
export {
|
|
53
|
-
export {
|
|
54
|
-
export {
|
|
55
|
-
export {
|
|
2
|
+
import * as index$1 from './common/index.js';
|
|
3
|
+
export { index$1 as common };
|
|
4
|
+
import * as index$2 from './core/index.js';
|
|
5
|
+
export { index$2 as core };
|
|
6
|
+
import * as index$3 from './platform/index.js';
|
|
7
|
+
export { index$3 as platform };
|
|
8
|
+
import * as index from './application/index.js';
|
|
9
|
+
export { index as application };
|
|
10
|
+
export { cbpServer } from './core/cbp/server/main.js';
|
|
11
|
+
export { EventMessageText, Fail, FailAuth, FailInternal, FailParams, Ok, Result, ResultCode, Warn, defaultLogin, defaultPlatformCommonPrefix, defaultPlatformPrefix, defaultPort, filePrefixCommon, fileSuffixMiddleware, fileSuffixResponse, processorMaxMapSize, processorRepeatedClearSize, processorRepeatedClearTimeMax, processorRepeatedClearTimeMin, processorRepeatedEventTime, processorRepeatedUserTime } from './common/variable.js';
|
|
12
|
+
export { start } from './core/start.js';
|
|
13
|
+
export { A, Body, Component, DOCTYPE, Div, H1, Head, Html, P, Style, Title, createElement, renderToString } from './common/react.js';
|
|
14
|
+
export { Attachment, Audio, BT, Button, Image, ImageFile, ImageURL, Link, MD, Markdown, MarkdownOriginal, Mention, Text, Video } from './application/format/message-format-old.js';
|
|
15
|
+
export { ChildrenApp, Core, Middleware, MiddlewareRouter, MiddlewareTree, ProcessorEventAutoClearMap, ProcessorEventUserAutoClearMap, Response, ResponseMiddleware, ResponseRouter, ResponseTree, State, StateSubscribe, SubscribeList, bumpStoreVersion, clearRuntimeAppKoaRouters, disposeAllRuntimeApps, disposeRuntimeApp, getChildrenApp, getRuntimeApp, getRuntimeAppKoaRouters, getSubscribeList, hasRuntimeAppCapability, listChildrenApps, listRuntimeAppKoaRouters, listRuntimeApps, registerRuntimeApp, setRuntimeAppKoaRouters, toRuntimeAppSnapshot, updateRuntimeAppCapabilities, updateRuntimeAppStatus } from './application/runtime/store.js';
|
|
16
|
+
export { DEVICE_ID_HEADER, FULL_RECEIVE_HEADER, HEARTBEAT_INTERVAL, USER_AGENT_HEADER, USER_AGENT_HEADER_VALUE_MAP, reconnectInterval, timeoutTime } from './common/cbp/constants.js';
|
|
17
|
+
export { Expose, clearAllExpose, disposeExpose, registerExpose } from './application/expose.js';
|
|
18
|
+
export { Format, FormatButtonGroup, FormatMarkDown, FormatSelect } from './application/format/message-format.js';
|
|
19
|
+
export { FormatEvent, wrapEvent } from './platform/event-format.js';
|
|
20
|
+
export { Logger, logger } from './common/logger.js';
|
|
21
|
+
export { MessageDirect, createDataFormat, format, getMessageIntent, sendToChannel, sendToUser } from './application/format/message-api.js';
|
|
22
|
+
export { OnMiddleware, onMiddleware } from './application/runtime/event-middleware.js';
|
|
23
|
+
export { OnProcessor, onProcessor } from './application/runtime/event-processor.js';
|
|
24
|
+
export { OnResponse, onResponse } from './application/runtime/event-response.js';
|
|
25
|
+
export { Router } from './application/router/dsl.js';
|
|
26
|
+
export { SinglyLinkedList } from './common/SinglyLinkedList.js';
|
|
27
|
+
export { cbpClient } from './application/runtime/cbp/connects/client.js';
|
|
28
|
+
export { cbpPlatform } from './platform/cbp-platform.js';
|
|
29
|
+
export { checkFallbackHint } from './application/router/fallback.js';
|
|
30
|
+
export { clearInterval, clearTimeout, listSchedule, pauseSchedule, resumeSchedule, setCron, setInterval, setTimeout } from './application/schedule.js';
|
|
31
|
+
export { createActionRequestEnvelope, createActionResponseEnvelope, createApiRequestEnvelope, createApiResponseEnvelope, createEventEnvelope, getNormalizedDeviceId, getNormalizedEventRouteId, isCBPEnvelope, isNormalizedActionRequest, isNormalizedApiRequest, normalizeInboundMessage, toLegacyActionData, toLegacyApiData } from './common/cbp/normalize.js';
|
|
32
|
+
export { createDirectClient, createDirectServer, generateSocketPath } from './common/direct-channel.js';
|
|
33
|
+
export { createEvent, useEvent } from './application/hooks/event.js';
|
|
34
|
+
export { createEventName, createHash, getCachedRegExp, getInputExportPath, getRecursiveDirFiles, sanitizeForSerialization, showErrorModule, stringToNumber } from './common/utils.js';
|
|
35
|
+
export { createEventValue } from './platform/event-value.js';
|
|
36
|
+
export { createResult } from './common/result.js';
|
|
37
|
+
export { createSelects, onSelects, onState, unChildren, unState, useState } from './application/runtime/event-utils.js';
|
|
38
|
+
export { createUserHashKey, fastHash, isMaster, matchIn, useUserHashKey } from './common/identity.js';
|
|
39
|
+
export { createWSConnector } from './common/cbp/ws-connector.js';
|
|
40
|
+
export { defineChildren } from './application/define-children.js';
|
|
41
|
+
export { defineMiddleware } from './application/define-middleware.js';
|
|
42
|
+
export { definePlatform } from './platform/define-platform.js';
|
|
43
|
+
export { defineResponse } from './application/define-response.js';
|
|
44
|
+
export { defineRouter, lazy, runHandler } from './application/define-router.js';
|
|
45
|
+
export { deviceId, generateUniqueId } from './common/cbp/runtime.js';
|
|
46
|
+
export { expendCycle } from './application/runtime/event-processor-cycle.js';
|
|
47
|
+
export { expendEvent } from './application/runtime/event-processor-event.js';
|
|
48
|
+
export { expendMiddleware } from './application/runtime/event-processor-middleware.js';
|
|
49
|
+
export { expendSubscribe, expendSubscribeCreate, expendSubscribeMount, expendSubscribeUnmount } from './application/runtime/event-processor-subscribe.js';
|
|
50
|
+
export { finishCurrentTrace, getCurrentAppName, getCurrentEvent, getCurrentNext, getCurrentPhase, markEventSendAttempt, markEventSendFailure, markEventSendSuccess, recordEventSendResults, withEventContext, withProcessorTrace } from './application/runtime/hook-event-context.js';
|
|
51
|
+
export { getConfig, getConfigValue, onWatchConfigValue } from './common/config.js';
|
|
52
|
+
export { loadChildren, loadChildrenFile } from './application/runtime/load-modules/loadChild.js';
|
|
53
|
+
export { loadModels, run } from './application/runtime/load-modules/load.js';
|
|
54
|
+
export { normalizeRoutePath, parseMessageText } from './application/router/parser.js';
|
|
55
|
+
export { onGroup } from './application/runtime/event-group.js';
|
|
56
|
+
export { registerAppDir, scheduleCancel, scheduleCancelAll, scheduleCancelByApp, scheduleCron, scheduleInterval, scheduleList, schedulePause, scheduleResume, scheduleTimeout, unregisterAppDir } from './application/runtime/schedule-store.js';
|
|
57
|
+
export { useAnnounce } from './application/hooks/announce.js';
|
|
58
|
+
export { useChannel } from './application/hooks/channel.js';
|
|
59
|
+
export { useClient } from './application/hooks/client.js';
|
|
60
|
+
export { useGuild } from './application/hooks/guild.js';
|
|
61
|
+
export { useHeartbeat } from './common/cbp/heartbeat.js';
|
|
62
|
+
export { useHistory } from './application/hooks/history.js';
|
|
63
|
+
export { useMe } from './application/hooks/me.js';
|
|
64
|
+
export { useMedia } from './application/hooks/media.js';
|
|
65
|
+
export { useMember } from './application/hooks/member.js';
|
|
66
|
+
export { useMention } from './application/hooks/mention.js';
|
|
67
|
+
export { useMessage, useSend, useSends } from './application/hooks/message.js';
|
|
68
|
+
export { useObserver, useSubscribe } from './application/hooks/subscribe.js';
|
|
69
|
+
export { usePermission } from './application/hooks/permission.js';
|
|
70
|
+
export { useReaction } from './application/hooks/reaction.js';
|
|
71
|
+
export { useRequest } from './application/hooks/request.js';
|
|
72
|
+
export { useRole } from './application/hooks/role.js';
|
|
73
|
+
export { useRoute } from './application/hooks/route.js';
|
|
74
|
+
export { useUser } from './application/hooks/user.js';
|
|
75
|
+
export { validateRouteArgs, validateRouteArgsForCommand } from './application/router/validator.js';
|
package/lib/main.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const start: (options?: StartOptions | string) => void;
|
|
1
|
+
export { start } from './core/start.js';
|
package/lib/main.js
CHANGED
|
@@ -1,76 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { cbpServer } from './cbp/server/main.js';
|
|
3
|
-
import { filePrefixCommon, defaultPlatformCommonPrefix } from './core/variable.js';
|
|
4
|
-
import { startPlatformAdapterWithFallback } from './process/platform.js';
|
|
5
|
-
import { startModuleAdapter } from './process/module.js';
|
|
6
|
-
import { generateSocketPath } from './process/direct-channel.js';
|
|
7
|
-
|
|
8
|
-
const createOptionsByKey = (options, key, defaultValue) => {
|
|
9
|
-
const cfg = getConfig();
|
|
10
|
-
const curValue = options?.[key] ?? cfg.argv?.[key];
|
|
11
|
-
const value = curValue ?? cfg.value?.[key] ?? defaultValue;
|
|
12
|
-
return value;
|
|
13
|
-
};
|
|
14
|
-
const startPlatform = (options) => {
|
|
15
|
-
const platform = createOptionsByKey(options, 'platform', '');
|
|
16
|
-
const login = createOptionsByKey(options, 'login', '');
|
|
17
|
-
if (!platform && !login) {
|
|
18
|
-
global.__sandbox = true;
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
void startPlatformAdapterWithFallback();
|
|
22
|
-
};
|
|
23
|
-
const startClient = (options) => {
|
|
24
|
-
process.env.input = createOptionsByKey(options, 'input', '');
|
|
25
|
-
process.env.output = createOptionsByKey(options, 'output', '');
|
|
26
|
-
process.env.is_full_receive = String(createOptionsByKey(options, 'is_full_receive', true));
|
|
27
|
-
process.env.port = String(createOptionsByKey(options, 'port', '') || '');
|
|
28
|
-
process.env.url = createOptionsByKey(options, 'url', '');
|
|
29
|
-
startModuleAdapter();
|
|
30
|
-
};
|
|
31
|
-
const start = (options = {}) => {
|
|
32
|
-
if (typeof options === 'string') {
|
|
33
|
-
options = { input: options };
|
|
34
|
-
}
|
|
35
|
-
global.__options = options;
|
|
36
|
-
const port = createOptionsByKey(options, 'port', '');
|
|
37
|
-
const serverPort = createOptionsByKey(options, 'serverPort', '');
|
|
38
|
-
const platform = createOptionsByKey(options, 'platform', '');
|
|
39
|
-
const login = createOptionsByKey(options, 'login', '');
|
|
40
|
-
if (platform) {
|
|
41
|
-
const reg = filePrefixCommon;
|
|
42
|
-
if (reg.test(platform)) {
|
|
43
|
-
process.env.platform = platform;
|
|
44
|
-
process.env.login = platform.replace(reg, '');
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
process.env.platform = platform;
|
|
48
|
-
process.env.login = platform;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
else if (login) {
|
|
52
|
-
process.env.platform = `${defaultPlatformCommonPrefix}${login}`;
|
|
53
|
-
process.env.login = login;
|
|
54
|
-
}
|
|
55
|
-
process.env.port = port ? String(port) : '';
|
|
56
|
-
process.env.serverPort = serverPort;
|
|
57
|
-
if (port) {
|
|
58
|
-
cbpServer(port, () => {
|
|
59
|
-
const httpURL = `http://127.0.0.1:${port}`;
|
|
60
|
-
const wsURL = `ws://127.0.0.1:${port}`;
|
|
61
|
-
logger.info(`[CBP-Server] ${httpURL}`);
|
|
62
|
-
logger.info(`[CBP-Server] ${wsURL}]`);
|
|
63
|
-
startClient(options);
|
|
64
|
-
startPlatform(options);
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
const sockPath = generateSocketPath();
|
|
69
|
-
process.env.__ALEMON_DIRECT_SOCK = sockPath;
|
|
70
|
-
logger.info('[Direct-IPC] 平台↔客户端直连');
|
|
71
|
-
startClient(options);
|
|
72
|
-
startPlatform(options);
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export { start };
|
|
1
|
+
export { start } from './core/start.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { ActionReplyFunc, ApiReplyFunc } from '../common/cbp/typings.js';
|
|
2
|
+
import type { EventsEnum } from '../types/index.js';
|
|
3
3
|
export declare const cbpPlatform: (url?: string, options?: {
|
|
4
4
|
open: () => void;
|
|
5
5
|
}) => {
|
|
@@ -1,14 +1,38 @@
|
|
|
1
1
|
import * as flattedJSON from 'flatted';
|
|
2
2
|
import { WebSocket } from 'ws';
|
|
3
|
-
import { deviceId } from '../processor/config.js';
|
|
4
|
-
import { ResultCode } from '../../core/variable.js';
|
|
5
3
|
import 'fs';
|
|
6
4
|
import 'path';
|
|
7
5
|
import 'yaml';
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
6
|
+
import '../common/logger.js';
|
|
7
|
+
import { ResultCode } from '../common/variable.js';
|
|
8
|
+
import { sanitizeForSerialization } from '../common/utils.js';
|
|
9
|
+
import { createDirectClient } from '../common/direct-channel.js';
|
|
10
|
+
import { deviceId } from '../common/cbp/runtime.js';
|
|
11
|
+
import { createWSConnector } from '../common/cbp/ws-connector.js';
|
|
12
|
+
import { createEventEnvelope, normalizeInboundMessage, isNormalizedApiRequest, toLegacyApiData, isNormalizedActionRequest, toLegacyActionData, createApiResponseEnvelope, createActionResponseEnvelope } from '../common/cbp/normalize.js';
|
|
11
13
|
|
|
14
|
+
const dispatchLegacyActionHandlers = (actionReplys, replyAction, input) => {
|
|
15
|
+
const normalized = normalizeInboundMessage(input);
|
|
16
|
+
if (!isNormalizedActionRequest(normalized)) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
const legacy = toLegacyActionData(normalized);
|
|
20
|
+
for (const cb of actionReplys) {
|
|
21
|
+
void cb(legacy, val => replyAction(legacy, val));
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
};
|
|
25
|
+
const dispatchLegacyApiHandlers = (apiReplys, replyApi, input) => {
|
|
26
|
+
const normalized = normalizeInboundMessage(input);
|
|
27
|
+
if (!isNormalizedApiRequest(normalized)) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
const legacy = toLegacyApiData(normalized);
|
|
31
|
+
for (const cb of apiReplys) {
|
|
32
|
+
void cb(legacy, val => replyApi(legacy, val));
|
|
33
|
+
}
|
|
34
|
+
return true;
|
|
35
|
+
};
|
|
12
36
|
const cbpPlatformDirect = (sockPath, open) => {
|
|
13
37
|
const actionReplys = [];
|
|
14
38
|
const apiReplys = [];
|
|
@@ -17,28 +41,19 @@ const cbpPlatformDirect = (sockPath, open) => {
|
|
|
17
41
|
const send = (data) => {
|
|
18
42
|
data.DeviceId = deviceId;
|
|
19
43
|
data.CreateAt = Date.now();
|
|
44
|
+
const envelope = createEventEnvelope(data);
|
|
20
45
|
if (channel) {
|
|
21
|
-
channel.send(
|
|
46
|
+
channel.send(envelope);
|
|
22
47
|
}
|
|
23
48
|
else {
|
|
24
|
-
pendingQueue.push(
|
|
49
|
+
pendingQueue.push(envelope);
|
|
25
50
|
}
|
|
26
51
|
};
|
|
27
52
|
const replyAction = (data, payload) => {
|
|
28
|
-
channel?.send(
|
|
29
|
-
action: data.action,
|
|
30
|
-
payload: payload,
|
|
31
|
-
actionId: data.actionId,
|
|
32
|
-
DeviceId: data.DeviceId
|
|
33
|
-
});
|
|
53
|
+
channel?.send(createActionResponseEnvelope(data, payload));
|
|
34
54
|
};
|
|
35
55
|
const replyApi = (data, payload) => {
|
|
36
|
-
channel?.send(
|
|
37
|
-
action: data.action,
|
|
38
|
-
apiId: data.apiId,
|
|
39
|
-
DeviceId: data.DeviceId,
|
|
40
|
-
payload: payload
|
|
41
|
-
});
|
|
56
|
+
channel?.send(createApiResponseEnvelope(data, payload));
|
|
42
57
|
};
|
|
43
58
|
const onactions = (reply) => {
|
|
44
59
|
actionReplys.push(reply);
|
|
@@ -47,16 +62,10 @@ const cbpPlatformDirect = (sockPath, open) => {
|
|
|
47
62
|
apiReplys.push(reply);
|
|
48
63
|
};
|
|
49
64
|
createDirectClient(sockPath, (data) => {
|
|
50
|
-
if (data
|
|
51
|
-
|
|
52
|
-
void cb(data, val => replyApi(data, val));
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
else if (data?.actionId) {
|
|
56
|
-
for (const cb of actionReplys) {
|
|
57
|
-
void cb(data, val => replyAction(data, val));
|
|
58
|
-
}
|
|
65
|
+
if (dispatchLegacyApiHandlers(apiReplys, replyApi, data)) {
|
|
66
|
+
return;
|
|
59
67
|
}
|
|
68
|
+
dispatchLegacyActionHandlers(actionReplys, replyAction, data);
|
|
60
69
|
})
|
|
61
70
|
.then(ch => {
|
|
62
71
|
channel = ch;
|
|
@@ -88,19 +97,15 @@ const cbpPlatformIPC = (open, existingActionReplys, existingApiReplys) => {
|
|
|
88
97
|
if (typeof process.send === 'function') {
|
|
89
98
|
data.DeviceId = deviceId;
|
|
90
99
|
data.CreateAt = Date.now();
|
|
91
|
-
|
|
100
|
+
const envelope = createEventEnvelope(data);
|
|
101
|
+
process.send({ type: 'ipc:data', data: sanitizeForSerialization(envelope) });
|
|
92
102
|
}
|
|
93
103
|
};
|
|
94
104
|
const replyAction = (data, payload) => {
|
|
95
105
|
if (typeof process.send === 'function') {
|
|
96
106
|
process.send({
|
|
97
107
|
type: 'ipc:data',
|
|
98
|
-
data:
|
|
99
|
-
action: data.action,
|
|
100
|
-
payload: payload,
|
|
101
|
-
actionId: data.actionId,
|
|
102
|
-
DeviceId: data.DeviceId
|
|
103
|
-
}
|
|
108
|
+
data: sanitizeForSerialization(createActionResponseEnvelope(data, payload))
|
|
104
109
|
});
|
|
105
110
|
}
|
|
106
111
|
};
|
|
@@ -108,12 +113,7 @@ const cbpPlatformIPC = (open, existingActionReplys, existingApiReplys) => {
|
|
|
108
113
|
if (typeof process.send === 'function') {
|
|
109
114
|
process.send({
|
|
110
115
|
type: 'ipc:data',
|
|
111
|
-
data:
|
|
112
|
-
action: data.action,
|
|
113
|
-
apiId: data.apiId,
|
|
114
|
-
DeviceId: data.DeviceId,
|
|
115
|
-
payload: payload
|
|
116
|
-
}
|
|
116
|
+
data: sanitizeForSerialization(createApiResponseEnvelope(data, payload))
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
};
|
|
@@ -127,17 +127,10 @@ const cbpPlatformIPC = (open, existingActionReplys, existingApiReplys) => {
|
|
|
127
127
|
try {
|
|
128
128
|
const msg = typeof message === 'string' ? JSON.parse(message) : message;
|
|
129
129
|
if (msg?.type === 'ipc:data') {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
for (const cb of apiReplys) {
|
|
133
|
-
void cb(data, val => replyApi(data, val));
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
else if (data?.actionId) {
|
|
137
|
-
for (const cb of actionReplys) {
|
|
138
|
-
void cb(data, val => replyAction(data, val));
|
|
139
|
-
}
|
|
130
|
+
if (dispatchLegacyApiHandlers(apiReplys, replyApi, msg.data)) {
|
|
131
|
+
return;
|
|
140
132
|
}
|
|
133
|
+
dispatchLegacyActionHandlers(actionReplys, replyAction, msg.data);
|
|
141
134
|
}
|
|
142
135
|
}
|
|
143
136
|
catch (error) {
|
|
@@ -188,29 +181,20 @@ const cbpPlatform = (url, options = {
|
|
|
188
181
|
if (global.chatbotPlatform?.readyState === WebSocket.OPEN) {
|
|
189
182
|
data.DeviceId = deviceId;
|
|
190
183
|
data.CreateAt = Date.now();
|
|
191
|
-
|
|
184
|
+
const envelope = createEventEnvelope(data);
|
|
185
|
+
global.chatbotPlatform.send(flattedJSON.stringify(sanitizeForSerialization(envelope)));
|
|
192
186
|
}
|
|
193
187
|
};
|
|
194
188
|
const actionReplys = [];
|
|
195
189
|
const apiReplys = [];
|
|
196
190
|
const replyAction = (data, payload) => {
|
|
197
191
|
if (global.chatbotPlatform?.readyState === WebSocket.OPEN) {
|
|
198
|
-
global.chatbotPlatform.send(flattedJSON.stringify(
|
|
199
|
-
action: data.action,
|
|
200
|
-
payload: payload,
|
|
201
|
-
actionId: data.actionId,
|
|
202
|
-
DeviceId: data.DeviceId
|
|
203
|
-
}));
|
|
192
|
+
global.chatbotPlatform.send(flattedJSON.stringify(createActionResponseEnvelope(data, payload)));
|
|
204
193
|
}
|
|
205
194
|
};
|
|
206
195
|
const replyApi = (data, payload) => {
|
|
207
196
|
if (global.chatbotPlatform?.readyState === WebSocket.OPEN) {
|
|
208
|
-
global.chatbotPlatform.send(flattedJSON.stringify(
|
|
209
|
-
action: data.action,
|
|
210
|
-
apiId: data.apiId,
|
|
211
|
-
DeviceId: data.DeviceId,
|
|
212
|
-
payload: payload
|
|
213
|
-
}));
|
|
197
|
+
global.chatbotPlatform.send(flattedJSON.stringify(createApiResponseEnvelope(data, payload)));
|
|
214
198
|
}
|
|
215
199
|
};
|
|
216
200
|
const onactions = (reply) => {
|
|
@@ -227,16 +211,10 @@ const cbpPlatform = (url, options = {
|
|
|
227
211
|
onMessage: (messageStr) => {
|
|
228
212
|
try {
|
|
229
213
|
const data = flattedJSON.parse(messageStr);
|
|
230
|
-
if (data
|
|
231
|
-
|
|
232
|
-
void cb(data, val => replyApi(data, val));
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
else if (data.actionId) {
|
|
236
|
-
for (const cb of actionReplys) {
|
|
237
|
-
void cb(data, val => replyAction(data, val));
|
|
238
|
-
}
|
|
214
|
+
if (dispatchLegacyApiHandlers(apiReplys, replyApi, data)) {
|
|
215
|
+
return;
|
|
239
216
|
}
|
|
217
|
+
dispatchLegacyActionHandlers(actionReplys, replyAction, data);
|
|
240
218
|
}
|
|
241
219
|
catch (error) {
|
|
242
220
|
logger.error({
|
|
@@ -247,12 +225,11 @@ const cbpPlatform = (url, options = {
|
|
|
247
225
|
}
|
|
248
226
|
}
|
|
249
227
|
});
|
|
250
|
-
|
|
228
|
+
return {
|
|
251
229
|
send,
|
|
252
230
|
onactions,
|
|
253
231
|
onapis
|
|
254
232
|
};
|
|
255
|
-
return client;
|
|
256
233
|
};
|
|
257
234
|
|
|
258
235
|
export { cbpPlatform };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { ActionsEventEnum } from '../types/event/actions.js';
|
|
2
|
+
export { definePlatform } from './define-platform.js';
|
|
3
|
+
export { cbpPlatform } from './cbp-platform.js';
|
|
4
|
+
export { FormatEvent, wrapEvent } from './event-format.js';
|
|
5
|
+
export { createEventValue } from './event-value.js';
|