alemonjs 2.1.83-alpha.1 → 2.1.83-alpha.2
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 +12 -0
- package/lib/application/index.js +32 -0
- package/lib/{app → application}/router/dsl.d.ts +1 -1
- package/lib/{app → application}/router/dsl.js +11 -7
- package/lib/{cbp → application/runtime/cbp}/connects/client.d.ts +1 -1
- package/lib/{cbp → application/runtime/cbp}/connects/client.js +11 -20
- 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/{cbp → application/runtime/cbp}/processor/actions.js +12 -4
- package/lib/application/runtime/cbp/processor/api.d.ts +3 -0
- package/lib/{cbp → application/runtime/cbp}/processor/api.js +12 -4
- 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/{server → application/runtime/http}/routers/hello.html.js +1 -1
- package/lib/{server → application/runtime/http}/routers/middleware.js +1 -2
- package/lib/{server → application/runtime/http}/routers/router.js +11 -4
- package/lib/{server → application/runtime/http}/routers/utils.d.ts +1 -1
- package/lib/{server → application/runtime/http}/routers/utils.js +6 -6
- 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 +3 -3
- 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/{cbp → common/cbp}/normalize.d.ts +2 -2
- package/lib/{cbp → common/cbp}/normalize.js +1 -5
- package/lib/common/cbp/runtime.d.ts +2 -0
- package/lib/common/cbp/runtime.js +10 -0
- package/lib/{cbp → common/cbp}/typings.d.ts +2 -2
- 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/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 +10 -4
- 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 +6 -1
- 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 +5 -4
- package/lib/index.js +9 -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} +8 -8
- 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/client/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/api.d.ts +0 -3
- package/lib/cbp/processor/config.d.ts +0 -33
- package/lib/cbp/processor/config.js +0 -56
- package/lib/process/index.d.ts +0 -4
- /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/{cbp → application/runtime/http}/routers/hello.html.d.ts +0 -0
- /package/lib/{server → application/runtime/http}/routers/middleware.d.ts +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}/react.js +0 -0
- /package/lib/{core → common}/variable.d.ts +0 -0
- /package/lib/{server → 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,19 @@
|
|
|
1
|
+
import { logger } from './logger.js';
|
|
2
|
+
import { ResultCode } from './variable.js';
|
|
3
|
+
|
|
4
|
+
const createResult = (code, message, data) => {
|
|
5
|
+
if (code !== ResultCode.Ok) {
|
|
6
|
+
logger.error({
|
|
7
|
+
code,
|
|
8
|
+
message,
|
|
9
|
+
data
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
code,
|
|
14
|
+
message,
|
|
15
|
+
data
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { createResult };
|
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
import { Dirent } from 'fs';
|
|
2
|
-
|
|
2
|
+
export { createUserHashKey, fastHash, isMaster, matchIn, useUserHashKey } from './identity.js';
|
|
3
|
+
export type { Result } from './result.js';
|
|
4
|
+
export { createResult } from './result.js';
|
|
3
5
|
export declare const createHash: (str: string, options?: {
|
|
4
6
|
length?: number;
|
|
5
7
|
algorithm?: string;
|
|
6
8
|
}) => string;
|
|
7
|
-
export declare const fastHash: (str: string) => string;
|
|
8
9
|
export declare const getCachedRegExp: (pattern: string | RegExp) => RegExp;
|
|
9
|
-
export declare const createUserHashKey: (event: {
|
|
10
|
-
UserId: string;
|
|
11
|
-
Platform: string;
|
|
12
|
-
}) => string;
|
|
13
|
-
export declare const useUserHashKey: (event: {
|
|
14
|
-
UserId: string;
|
|
15
|
-
Platform: string;
|
|
16
|
-
}) => string;
|
|
17
|
-
export declare const matchIn: (source: any, key: string) => boolean;
|
|
18
|
-
export declare const isMaster: (UserId: string, platform: string) => boolean;
|
|
19
10
|
export declare const createEventName: (url: string, appKey: string) => string;
|
|
20
11
|
export declare const stringToNumber: (str: string, size?: number) => number;
|
|
21
12
|
export declare const getRecursiveDirFiles: (dir: string, condition?: (func: Dirent) => boolean) => {
|
|
@@ -25,9 +16,3 @@ export declare const getRecursiveDirFiles: (dir: string, condition?: (func: Dire
|
|
|
25
16
|
export declare const showErrorModule: (e: Error) => void;
|
|
26
17
|
export declare const sanitizeForSerialization: (data: any) => any;
|
|
27
18
|
export declare const getInputExportPath: (input?: string) => any;
|
|
28
|
-
export type Result<T = any> = {
|
|
29
|
-
code: ResultCode;
|
|
30
|
-
message: string | object;
|
|
31
|
-
data: T;
|
|
32
|
-
};
|
|
33
|
-
export declare const createResult: <T>(code: ResultCode, message: string | object, data?: T) => Result<T>;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { createHash as createHash$1 } from 'node:crypto';
|
|
2
2
|
import fs__default, { existsSync, readdirSync } from 'fs';
|
|
3
3
|
import path__default, { join } from 'path';
|
|
4
|
-
import { ResultCode, fileSuffixResponse } from './variable.js';
|
|
5
4
|
import module$1 from 'module';
|
|
6
|
-
import {
|
|
5
|
+
import { ResultCode, fileSuffixResponse } from './variable.js';
|
|
6
|
+
import { logger } from './logger.js';
|
|
7
|
+
export { createUserHashKey, fastHash, isMaster, matchIn, useUserHashKey } from './identity.js';
|
|
8
|
+
export { createResult } from './result.js';
|
|
7
9
|
|
|
8
10
|
const initRequire = () => { };
|
|
9
11
|
initRequire.resolve = () => '';
|
|
@@ -13,14 +15,6 @@ const createHash = (str, options = {}) => {
|
|
|
13
15
|
const hash = createHash$1(algorithm).update(str).digest('hex');
|
|
14
16
|
return hash.slice(0, length);
|
|
15
17
|
};
|
|
16
|
-
const fastHash = (str) => {
|
|
17
|
-
let hash = 0x811c9dc5;
|
|
18
|
-
for (let i = 0; i < str.length; i++) {
|
|
19
|
-
hash ^= str.charCodeAt(i);
|
|
20
|
-
hash = Math.imul(hash, 0x01000193);
|
|
21
|
-
}
|
|
22
|
-
return (hash >>> 0).toString(36);
|
|
23
|
-
};
|
|
24
18
|
const _regexpCache = new Map();
|
|
25
19
|
const getCachedRegExp = (pattern) => {
|
|
26
20
|
if (pattern instanceof RegExp) {
|
|
@@ -33,28 +27,6 @@ const getCachedRegExp = (pattern) => {
|
|
|
33
27
|
}
|
|
34
28
|
return cached;
|
|
35
29
|
};
|
|
36
|
-
const createUserHashKey = (event) => {
|
|
37
|
-
return fastHash(`${event.Platform}:${event.UserId}`);
|
|
38
|
-
};
|
|
39
|
-
const useUserHashKey = createUserHashKey;
|
|
40
|
-
const matchIn = (source, key) => {
|
|
41
|
-
if (Array.isArray(source)) {
|
|
42
|
-
return source.includes(key);
|
|
43
|
-
}
|
|
44
|
-
if (source && typeof source === 'object') {
|
|
45
|
-
return Object.prototype.hasOwnProperty.call(source, key) && !!source[key];
|
|
46
|
-
}
|
|
47
|
-
return false;
|
|
48
|
-
};
|
|
49
|
-
const isMaster = (UserId, platform) => {
|
|
50
|
-
const values = getConfigValue() || {};
|
|
51
|
-
const value = values[platform] && typeof values[platform] === 'object' ? values[platform] : {};
|
|
52
|
-
const UserKey = createUserHashKey({
|
|
53
|
-
Platform: platform,
|
|
54
|
-
UserId: UserId
|
|
55
|
-
});
|
|
56
|
-
return matchIn(values.master_key, UserKey) || matchIn(values.master_id, UserId) || matchIn(value.master_key, UserKey) || matchIn(value.master_id, UserId);
|
|
57
|
-
};
|
|
58
30
|
const createEventName = (url, appKey) => {
|
|
59
31
|
let uri = url;
|
|
60
32
|
if (process.platform === 'win32') {
|
|
@@ -62,8 +34,7 @@ const createEventName = (url, appKey) => {
|
|
|
62
34
|
}
|
|
63
35
|
const names = uri.split('/').filter(item => item !== '');
|
|
64
36
|
names.pop();
|
|
65
|
-
|
|
66
|
-
return name;
|
|
37
|
+
return `${appKey}:${names.join(':')}`;
|
|
67
38
|
};
|
|
68
39
|
const stringToNumber = (str, size = 33) => {
|
|
69
40
|
let hash = 5381;
|
|
@@ -140,19 +111,5 @@ const getInputExportPath = (input) => {
|
|
|
140
111
|
}
|
|
141
112
|
}
|
|
142
113
|
};
|
|
143
|
-
const createResult = (code, message, data) => {
|
|
144
|
-
if (code !== ResultCode.Ok) {
|
|
145
|
-
logger.error({
|
|
146
|
-
code,
|
|
147
|
-
message,
|
|
148
|
-
data: data
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
return {
|
|
152
|
-
code,
|
|
153
|
-
message,
|
|
154
|
-
data: data
|
|
155
|
-
};
|
|
156
|
-
};
|
|
157
114
|
|
|
158
|
-
export { createEventName, createHash,
|
|
115
|
+
export { createEventName, createHash, getCachedRegExp, getInputExportPath, getRecursiveDirFiles, sanitizeForSerialization, showErrorModule, stringToNumber };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { cbpServer } from './server/main.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { cbpServer } from './server/main.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { WebSocket } from 'ws';
|
|
2
|
+
export declare const childrenClient: Map<string, WebSocket>;
|
|
3
|
+
export declare const platformClient: Map<string, WebSocket>;
|
|
4
|
+
export declare const fullClient: Map<string, WebSocket>;
|
|
5
|
+
export declare const childrenBind: Map<string, string>;
|
|
6
|
+
export declare const clientBindCount: Map<string, number>;
|
|
7
|
+
export declare const bindChannelToClient: (channelId: string, clientId: string) => void;
|
|
8
|
+
export declare const unbindClient: (clientId: string) => void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const childrenClient = new Map();
|
|
2
|
+
const platformClient = new Map();
|
|
3
|
+
const fullClient = new Map();
|
|
4
|
+
const childrenBind = new Map();
|
|
5
|
+
const clientBindCount = new Map();
|
|
6
|
+
const bindChannelToClient = (channelId, clientId) => {
|
|
7
|
+
const oldClientId = childrenBind.get(channelId);
|
|
8
|
+
if (oldClientId && oldClientId !== clientId) {
|
|
9
|
+
const oldCount = clientBindCount.get(oldClientId) ?? 0;
|
|
10
|
+
if (oldCount > 1) {
|
|
11
|
+
clientBindCount.set(oldClientId, oldCount - 1);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
clientBindCount.delete(oldClientId);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
childrenBind.set(channelId, clientId);
|
|
18
|
+
clientBindCount.set(clientId, (clientBindCount.get(clientId) ?? 0) + 1);
|
|
19
|
+
};
|
|
20
|
+
const unbindClient = (clientId) => {
|
|
21
|
+
for (const [channelId, boundClientId] of childrenBind.entries()) {
|
|
22
|
+
if (boundClientId === clientId) {
|
|
23
|
+
childrenBind.delete(channelId);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
clientBindCount.delete(clientId);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { bindChannelToClient, childrenBind, childrenClient, clientBindCount, fullClient, platformClient, unbindClient };
|
|
@@ -3,15 +3,21 @@ import { WebSocketServer, WebSocket } from 'ws';
|
|
|
3
3
|
import * as flattedJSON from 'flatted';
|
|
4
4
|
import koaCors from '@koa/cors';
|
|
5
5
|
import router from '../routers/router.js';
|
|
6
|
-
import { ResultCode } from '../../core/variable.js';
|
|
7
6
|
import 'fs';
|
|
8
7
|
import 'path';
|
|
9
8
|
import 'yaml';
|
|
10
|
-
import '
|
|
11
|
-
import {
|
|
9
|
+
import '../../../common/logger.js';
|
|
10
|
+
import { ResultCode } from '../../../common/variable.js';
|
|
11
|
+
import '../../../common/utils.js';
|
|
12
|
+
import 'net';
|
|
13
|
+
import 'v8';
|
|
14
|
+
import 'os';
|
|
15
|
+
import { USER_AGENT_HEADER, USER_AGENT_HEADER_VALUE_MAP, DEVICE_ID_HEADER, FULL_RECEIVE_HEADER } from '../../../common/cbp/constants.js';
|
|
16
|
+
import '../../../common/cbp/runtime.js';
|
|
17
|
+
import { normalizeInboundMessage, getNormalizedDeviceId, getNormalizedEventRouteId } from '../../../common/cbp/normalize.js';
|
|
18
|
+
import { platformClient, childrenClient, fullClient, childrenBind, clientBindCount, unbindClient, bindChannelToClient } from '../processor/config.js';
|
|
12
19
|
import { createTestOneController } from './testone.js';
|
|
13
20
|
import { getClientChild } from '../../process/ipc-bridge.js';
|
|
14
|
-
import { normalizeInboundMessage, getNormalizedDeviceId, getNormalizedEventRouteId } from '../normalize.js';
|
|
15
21
|
|
|
16
22
|
const routeNormalizedMessage = (message, input) => {
|
|
17
23
|
const normalized = normalizeInboundMessage(input);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IncomingMessage } from 'http';
|
|
2
2
|
import { WebSocket } from 'ws';
|
|
3
|
-
import type { ParsedMessage } from '
|
|
3
|
+
import type { ParsedMessage } from '../../../common/cbp/typings.js';
|
|
4
4
|
export declare const createTestOneController: (ws: WebSocket, _request: IncomingMessage) => {
|
|
5
5
|
onMessage: (parsedMessage: ParsedMessage) => void;
|
|
6
6
|
close: () => void;
|
|
@@ -3,9 +3,15 @@ import { join, dirname } from 'path';
|
|
|
3
3
|
import { existsSync, mkdirSync, watch, readFileSync, writeFile } from 'fs';
|
|
4
4
|
import _ from 'lodash';
|
|
5
5
|
import { readFile } from 'fs/promises';
|
|
6
|
-
import { ResultCode } from '../../core/variable.js';
|
|
7
6
|
import 'yaml';
|
|
8
|
-
import '
|
|
7
|
+
import '../../../common/logger.js';
|
|
8
|
+
import { ResultCode } from '../../../common/variable.js';
|
|
9
|
+
import '../../../common/utils.js';
|
|
10
|
+
import 'net';
|
|
11
|
+
import 'v8';
|
|
12
|
+
import 'os';
|
|
13
|
+
import '../../../common/cbp/runtime.js';
|
|
14
|
+
import 'ws';
|
|
9
15
|
|
|
10
16
|
const createTestOneController = (ws, _request) => {
|
|
11
17
|
const testonePath = join(process.cwd(), 'testone');
|
package/lib/core/index.d.ts
CHANGED
package/lib/core/index.js
CHANGED
|
@@ -1,3 +1 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { getConfig, getConfigValue, onWatchConfigValue } from './config.js';
|
|
3
|
-
export { createEventName, createHash, createResult, createUserHashKey, fastHash, getCachedRegExp, getInputExportPath, getRecursiveDirFiles, isMaster, matchIn, sanitizeForSerialization, showErrorModule, stringToNumber, useUserHashKey } from './utils.js';
|
|
1
|
+
export { start } from './start.js';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { startModuleAdapter } from './module.js';
|
|
2
2
|
export { startPlatformAdapterWithFallback } from './platform.js';
|
|
3
3
|
export { forwardFromClient, forwardFromPlatform, getClientChild, getPlatformChild, setClientChild, setPlatformChild } from './ipc-bridge.js';
|
|
4
|
-
export { createDirectClient, createDirectServer, generateSocketPath } from './direct-channel.js';
|
|
@@ -4,7 +4,12 @@ import * as flattedJSON from 'flatted';
|
|
|
4
4
|
import 'fs';
|
|
5
5
|
import 'path';
|
|
6
6
|
import 'yaml';
|
|
7
|
-
import
|
|
7
|
+
import '../../common/logger.js';
|
|
8
|
+
import { sanitizeForSerialization } from '../../common/utils.js';
|
|
9
|
+
import 'net';
|
|
10
|
+
import 'v8';
|
|
11
|
+
import 'os';
|
|
12
|
+
import '../../common/cbp/runtime.js';
|
|
8
13
|
|
|
9
14
|
let platformChild = null;
|
|
10
15
|
let clientChild = null;
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import childProcess from 'child_process';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import '
|
|
2
|
+
import { getConfigValue } from '../../common/config.js';
|
|
3
|
+
import { ResultCode } from '../../common/variable.js';
|
|
4
|
+
import '../../common/logger.js';
|
|
5
|
+
import '../../common/utils.js';
|
|
6
|
+
import 'net';
|
|
7
|
+
import 'v8';
|
|
8
|
+
import 'os';
|
|
9
|
+
import 'path';
|
|
10
|
+
import 'fs';
|
|
11
|
+
import 'flatted';
|
|
12
|
+
import '../../common/cbp/runtime.js';
|
|
13
|
+
import 'ws';
|
|
5
14
|
import module$1 from 'module';
|
|
6
15
|
import { setClientChild, forwardFromClient } from './ipc-bridge.js';
|
|
7
16
|
|
|
@@ -17,7 +26,7 @@ function startModuleAdapter() {
|
|
|
17
26
|
FORK_TIMEOUT: pro?.fork_timeout ?? 6000
|
|
18
27
|
};
|
|
19
28
|
try {
|
|
20
|
-
modulePath = require$1.resolve('
|
|
29
|
+
modulePath = require$1.resolve('../../client.js');
|
|
21
30
|
}
|
|
22
31
|
catch (error) {
|
|
23
32
|
logger?.warn?.({
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import childProcess from 'child_process';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import '
|
|
2
|
+
import { getConfigValue } from '../../common/config.js';
|
|
3
|
+
import { ResultCode } from '../../common/variable.js';
|
|
4
|
+
import '../../common/logger.js';
|
|
5
|
+
import '../../common/utils.js';
|
|
6
|
+
import 'net';
|
|
7
|
+
import 'v8';
|
|
8
|
+
import 'os';
|
|
9
|
+
import 'path';
|
|
10
|
+
import 'fs';
|
|
11
|
+
import 'flatted';
|
|
12
|
+
import '../../common/cbp/runtime.js';
|
|
13
|
+
import 'ws';
|
|
5
14
|
import module$1 from 'module';
|
|
6
15
|
import { setPlatformChild, forwardFromPlatform } from './ipc-bridge.js';
|
|
7
16
|
|
|
@@ -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,7 @@
|
|
|
1
1
|
export * from './types/index.js';
|
|
2
2
|
export * from './global.js';
|
|
3
|
-
export
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
3
|
+
export { start } from './main.js';
|
|
4
|
+
export * as common from './common/index.js';
|
|
5
|
+
export * as core from './core/index.js';
|
|
6
|
+
export * as platform from './platform/index.js';
|
|
7
|
+
export * as application from './application/index.js';
|
package/lib/index.js
CHANGED
|
@@ -1,55 +1,10 @@
|
|
|
1
1
|
export { ActionsEventEnum } from './types/event/actions.js';
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
export {
|
|
5
|
-
|
|
6
|
-
export {
|
|
7
|
-
|
|
8
|
-
export {
|
|
9
|
-
|
|
10
|
-
export {
|
|
11
|
-
export { loadChildren, loadChildrenFile } from './app/load_modules/loadChild.js';
|
|
12
|
-
export { defineChildren } from './app/define-children.js';
|
|
13
|
-
export { definePlatform } from './app/define-platform.js';
|
|
14
|
-
export { defineResponse } from './app/define-response.js';
|
|
15
|
-
export { defineMiddleware } from './app/define-middleware.js';
|
|
16
|
-
export { defineRouter, lazy, runHandler } from './app/define-router.js';
|
|
17
|
-
export { FormatEvent, wrapEvent } from './app/event-format.js';
|
|
18
|
-
export { onGroup } from './app/event-group.js';
|
|
19
|
-
export { OnMiddleware, onMiddleware } from './app/event-middleware.js';
|
|
20
|
-
export { OnProcessor, onProcessor } from './app/event-processor.js';
|
|
21
|
-
export { OnResponse, onResponse } from './app/event-response.js';
|
|
22
|
-
export { expendCycle } from './app/event-processor-cycle.js';
|
|
23
|
-
export { expendEvent } from './app/event-processor-event.js';
|
|
24
|
-
export { expendMiddleware } from './app/event-processor-middleware.js';
|
|
25
|
-
export { expendSubscribe, expendSubscribeCreate, expendSubscribeMount, expendSubscribeUnmount } from './app/event-processor-subscribe.js';
|
|
26
|
-
export { useAnnounce } from './app/hook-use/announce.js';
|
|
27
|
-
export { useChannel } from './app/hook-use/channel.js';
|
|
28
|
-
export { useClient } from './app/hook-use/client.js';
|
|
29
|
-
export { useGuild } from './app/hook-use/guild.js';
|
|
30
|
-
export { useHistory } from './app/hook-use/history.js';
|
|
31
|
-
export { useMedia } from './app/hook-use/media.js';
|
|
32
|
-
export { useMe } from './app/hook-use/me.js';
|
|
33
|
-
export { useMember } from './app/hook-use/member.js';
|
|
34
|
-
export { useMention } from './app/hook-use/mention.js';
|
|
35
|
-
export { useMessage, useSend, useSends } from './app/hook-use/message.js';
|
|
36
|
-
export { usePermission } from './app/hook-use/permission.js';
|
|
37
|
-
export { useReaction } from './app/hook-use/reaction.js';
|
|
38
|
-
export { useRequest } from './app/hook-use/request.js';
|
|
39
|
-
export { useRole } from './app/hook-use/role.js';
|
|
40
|
-
export { useRoute } from './app/hook-use/route.js';
|
|
41
|
-
export { useUser } from './app/hook-use/user.js';
|
|
42
|
-
export { useObserver, useSubscribe } from './app/hook-use/subscribe.js';
|
|
43
|
-
export { createEvent, useEvent } from './app/hook-use/event.js';
|
|
44
|
-
export { clearInterval, clearTimeout, listSchedule, pauseSchedule, resumeSchedule, setCron, setInterval, setTimeout } from './app/api/schedule.js';
|
|
45
|
-
export { finishCurrentTrace, getCurrentAppName, getCurrentEvent, getCurrentNext, getCurrentPhase, markEventSendAttempt, markEventSendFailure, markEventSendSuccess, recordEventSendResults, withEventContext, withProcessorTrace } from './app/hook-event-context.js';
|
|
46
|
-
export { registerAppDir, scheduleCancel, scheduleCancelAll, scheduleCancelByApp, scheduleCron, scheduleInterval, scheduleList, schedulePause, scheduleResume, scheduleTimeout, unregisterAppDir } from './app/schedule-store.js';
|
|
47
|
-
export { createEventValue, createSelects, onSelects, onState, unChildren, unState, useState } from './app/event-utils.js';
|
|
48
|
-
export { MessageDirect, createDataFormat, format, getMessageIntent, sendToChannel, sendToUser } from './app/message-api.js';
|
|
49
|
-
export { Format, FormatButtonGroup, FormatMarkDown, FormatSelect } from './app/message-format.js';
|
|
50
|
-
export { Router } from './app/router/dsl.js';
|
|
51
|
-
export { checkFallbackHint } from './app/router/fallback.js';
|
|
52
|
-
export { normalizeRoutePath, parseMessageText } from './app/router/parser.js';
|
|
53
|
-
export { validateRouteArgs } from './app/router/validator.js';
|
|
54
|
-
export { start } from './main.js';
|
|
55
|
-
export { Attachment, Audio, BT, Button, Image, ImageFile, ImageURL, Link, MD, Markdown, MarkdownOriginal, Mention, Text, Video } from './app/message-format-old.js';
|
|
2
|
+
export { start } from './core/start.js';
|
|
3
|
+
import * as index$1 from './common/index.js';
|
|
4
|
+
export { index$1 as common };
|
|
5
|
+
import * as index$2 from './core/index.js';
|
|
6
|
+
export { index$2 as core };
|
|
7
|
+
import * as index$3 from './platform/index.js';
|
|
8
|
+
export { index$3 as platform };
|
|
9
|
+
import * as index from './application/index.js';
|
|
10
|
+
export { index as application };
|
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
|
}) => {
|