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
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
import { ResultCode } from '../../core/variable.js';
|
|
2
1
|
import 'fs';
|
|
3
2
|
import 'path';
|
|
4
3
|
import 'yaml';
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
4
|
+
import '../../../../common/logger.js';
|
|
5
|
+
import { ResultCode } from '../../../../common/variable.js';
|
|
6
|
+
import { createResult } from '../../../../common/result.js';
|
|
7
|
+
import { sanitizeForSerialization } from '../../../../common/utils.js';
|
|
8
|
+
import 'net';
|
|
9
|
+
import 'v8';
|
|
10
|
+
import 'os';
|
|
7
11
|
import * as flattedJSON from 'flatted';
|
|
12
|
+
import { timeoutTime } from '../../../../common/cbp/constants.js';
|
|
13
|
+
import { generateUniqueId, deviceId } from '../../../../common/cbp/runtime.js';
|
|
14
|
+
import 'ws';
|
|
15
|
+
import { createApiRequestEnvelope } from '../../../../common/cbp/normalize.js';
|
|
16
|
+
import { apiRequestResolves, apiRequestTimeouts } from './request-registry.js';
|
|
8
17
|
import { getDirectSend } from './transport.js';
|
|
9
|
-
import { createApiRequestEnvelope } from '../normalize.js';
|
|
10
18
|
|
|
11
19
|
const setupApiResolve = (requestId, resolve) => {
|
|
12
20
|
apiRequestResolves.set(requestId, resolve);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Result } from '../../../../common/index.js';
|
|
2
|
+
type RequestReplyValue = Result[] | PromiseLike<Result[]>;
|
|
3
|
+
type RequestReplyResolve = (value: RequestReplyValue) => void;
|
|
4
|
+
export declare const actionRequestResolves: Map<string, RequestReplyResolve>;
|
|
5
|
+
export declare const apiRequestResolves: Map<string, RequestReplyResolve>;
|
|
6
|
+
export declare const actionRequestTimeouts: Map<string, NodeJS.Timeout>;
|
|
7
|
+
export declare const apiRequestTimeouts: Map<string, NodeJS.Timeout>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { cbpClient } from './cbp/connects/client.js';
|
|
2
|
+
import 'flatted';
|
|
3
|
+
import 'fs';
|
|
4
|
+
import 'path';
|
|
5
|
+
import 'yaml';
|
|
6
|
+
import '../../common/logger.js';
|
|
7
|
+
import { defaultPort } from '../../common/variable.js';
|
|
8
|
+
import '../../common/utils.js';
|
|
9
|
+
import 'net';
|
|
10
|
+
import 'v8';
|
|
11
|
+
import 'os';
|
|
12
|
+
import '../../common/cbp/runtime.js';
|
|
13
|
+
import 'ws';
|
|
14
|
+
import { loadModels } from './load-modules/load.js';
|
|
15
|
+
import { createServer } from './http-server.js';
|
|
16
|
+
import { disposeAllRuntimeApps } from './store.js';
|
|
17
|
+
import { scheduleCancelByApp, unregisterAppDir } from './schedule-store.js';
|
|
18
|
+
import { dispatchDisposeAllApps } from './lifecycle-callbacks.js';
|
|
19
|
+
|
|
20
|
+
global.__client_loaded = true;
|
|
21
|
+
let runtimeDisposed = false;
|
|
22
|
+
const disposeRuntime = async () => {
|
|
23
|
+
if (runtimeDisposed) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
runtimeDisposed = true;
|
|
27
|
+
await dispatchDisposeAllApps();
|
|
28
|
+
const apps = disposeAllRuntimeApps();
|
|
29
|
+
apps.forEach(app => {
|
|
30
|
+
scheduleCancelByApp(app.name);
|
|
31
|
+
unregisterAppDir(app.name);
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
const shutdown = async (reason) => {
|
|
35
|
+
logger.info?.(`[alemonjs][${reason}] 收到信号,正在关闭...`);
|
|
36
|
+
await disposeRuntime();
|
|
37
|
+
process.exit(0);
|
|
38
|
+
};
|
|
39
|
+
const mainServer = () => {
|
|
40
|
+
const port = process.env.serverPort;
|
|
41
|
+
if (!port) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
createServer(port, () => {
|
|
45
|
+
const httpURL = `http://127.0.0.1:${port}`;
|
|
46
|
+
logger.info(`应用服务器: ${httpURL}`);
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
const main = () => {
|
|
50
|
+
const login = process.env.login ?? '';
|
|
51
|
+
const platform = process.env.platform ?? '';
|
|
52
|
+
const url = process.env.url ?? '';
|
|
53
|
+
const port = process.env.port ?? defaultPort;
|
|
54
|
+
const isFullReceive = process.env.is_full_receive === 'true' || process.env.is_full_receive === '1';
|
|
55
|
+
if (!login && !platform && url) {
|
|
56
|
+
logger.info(`[Connecting to CBP server at ${url}]`);
|
|
57
|
+
cbpClient(url);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
cbpClient(`http://127.0.0.1:${port}`, { isFullReceive });
|
|
61
|
+
}
|
|
62
|
+
loadModels();
|
|
63
|
+
};
|
|
64
|
+
const mainProcess = () => {
|
|
65
|
+
process.on('unhandledRejection', (reason) => {
|
|
66
|
+
logger.error('[alemonjs][unhandledRejection] 未捕获的 Promise 拒绝:', reason);
|
|
67
|
+
});
|
|
68
|
+
process.on('uncaughtException', (error) => {
|
|
69
|
+
logger.error('[alemonjs][uncaughtException] 未捕获的异常:', error);
|
|
70
|
+
});
|
|
71
|
+
['SIGINT', 'SIGTERM', 'SIGQUIT', 'disconnect'].forEach(sig => {
|
|
72
|
+
process?.on?.(sig, () => void shutdown(sig));
|
|
73
|
+
});
|
|
74
|
+
process?.on?.('exit', code => {
|
|
75
|
+
void disposeRuntime();
|
|
76
|
+
logger.info?.(`[alemonjs][exit] 进程退出,code=${code}`);
|
|
77
|
+
});
|
|
78
|
+
process.on('message', msg => {
|
|
79
|
+
try {
|
|
80
|
+
const data = typeof msg === 'string' ? JSON.parse(msg) : msg;
|
|
81
|
+
if (data?.type === 'start') {
|
|
82
|
+
main();
|
|
83
|
+
mainServer();
|
|
84
|
+
}
|
|
85
|
+
else if (data?.type === 'stop') {
|
|
86
|
+
void shutdown('stop');
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch { }
|
|
90
|
+
});
|
|
91
|
+
if (process.send) {
|
|
92
|
+
process.send({ type: 'ready' });
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
mainProcess();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { EventErrorContext } from '
|
|
1
|
+
import type { EventErrorContext } from '../../types/index.js';
|
|
2
2
|
export declare const dispatchEventError: (context: EventErrorContext) => Promise<boolean>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { OnMiddlewareReversalFunc, OnMiddlewareReversalFuncBack } from '
|
|
1
|
+
import { OnMiddlewareReversalFunc, OnMiddlewareReversalFuncBack } from '../../types/index.js';
|
|
2
2
|
export declare const onMiddleware: OnMiddlewareReversalFunc;
|
|
3
3
|
export declare const OnMiddleware: OnMiddlewareReversalFuncBack;
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import 'fs';
|
|
2
2
|
import 'path';
|
|
3
3
|
import 'yaml';
|
|
4
|
-
import
|
|
4
|
+
import '../../common/logger.js';
|
|
5
|
+
import { showErrorModule } from '../../common/utils.js';
|
|
6
|
+
import 'net';
|
|
7
|
+
import 'v8';
|
|
8
|
+
import 'os';
|
|
9
|
+
import 'flatted';
|
|
10
|
+
import '../../common/cbp/runtime.js';
|
|
11
|
+
import 'ws';
|
|
5
12
|
import { withEventContext, finishCurrentTrace } from './hook-event-context.js';
|
|
6
13
|
import { dispatchEventError } from './event-error.js';
|
|
7
14
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Events, EventKeys } from '
|
|
1
|
+
import { Events, EventKeys } from '../../types/index.js';
|
|
2
2
|
export declare const expendCycle: <T extends EventKeys>(valueEvent: Events[T], select: T, _config?: any) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Next, Events, EventKeys, FileTreeNode, StoreResponseItem } from '
|
|
1
|
+
import { Next, Events, EventKeys, FileTreeNode, StoreResponseItem } from '../../types/index.js';
|
|
2
2
|
export declare const clearModuleCache: (path?: string) => void;
|
|
3
3
|
export declare const createNextStep: <T extends EventKeys>(valueEvent: Events[T], select: T, next: Next, files: StoreResponseItem[], callHandler: (currents: any, nextEvent: any) => void) => Next;
|
|
4
4
|
export declare const createFileTreeStep: <T extends EventKeys>(valueEvent: Events[T], select: T, next: Next, root: FileTreeNode, callHandler: (currents: any, nextEvent: any, meta?: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getCachedRegExp, showErrorModule } from '
|
|
2
|
-
import { EventMessageText } from '
|
|
1
|
+
import { getCachedRegExp, showErrorModule } from '../../common/utils.js';
|
|
2
|
+
import { EventMessageText } from '../../common/variable.js';
|
|
3
3
|
import { dispatchEventError } from './event-error.js';
|
|
4
4
|
|
|
5
5
|
const moduleCache = new Map();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Next, Events, EventKeys, ResponseRoute } from '
|
|
1
|
+
import { Next, Events, EventKeys, ResponseRoute } from '../../types/index.js';
|
|
2
2
|
export declare const createRouteProcessChildren: <T extends EventKeys>(valueEvent: Events[T], select: T, nextCycle: Next, callHandler: (currents: any, nextEvent: any, meta?: {
|
|
3
3
|
appName?: string;
|
|
4
4
|
phase?: "route";
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import { EventMessageText } from '
|
|
1
|
+
import { EventMessageText } from '../../common/variable.js';
|
|
2
2
|
import 'fs';
|
|
3
3
|
import 'path';
|
|
4
4
|
import 'yaml';
|
|
5
|
-
import
|
|
5
|
+
import '../../common/logger.js';
|
|
6
|
+
import { getCachedRegExp, showErrorModule } from '../../common/utils.js';
|
|
7
|
+
import 'net';
|
|
8
|
+
import 'v8';
|
|
9
|
+
import 'os';
|
|
10
|
+
import 'flatted';
|
|
11
|
+
import '../../common/cbp/runtime.js';
|
|
12
|
+
import 'ws';
|
|
6
13
|
import { dispatchEventError } from './event-error.js';
|
|
7
14
|
|
|
8
15
|
const AsyncFunction = (async () => { }).constructor;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Next, Events, EventKeys } from '
|
|
1
|
+
import { Next, Events, EventKeys } from '../../types/index.js';
|
|
2
2
|
export declare const expendEvent: <T extends EventKeys>(valueEvent: Events[T], select: T, next: Next) => void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Next, Events, EventKeys } from '
|
|
1
|
+
import { Next, Events, EventKeys } from '../../types/index.js';
|
|
2
2
|
export declare const expendMiddleware: <T extends EventKeys>(valueEvent: Events[T], select: T, next: Next) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Next, Events, EventCycleEnum, EventKeys } from '
|
|
1
|
+
import { Next, Events, EventCycleEnum, EventKeys } from '../../types/index.js';
|
|
2
2
|
export declare const expendSubscribe: <T extends EventKeys>(valueEvent: Events[T], select: T, next: Next, choose: EventCycleEnum) => void;
|
|
3
3
|
export declare const expendSubscribeCreate: <T extends EventKeys>(valueEvent: Events[T], select: T, next: Next) => void;
|
|
4
4
|
export declare const expendSubscribeMount: <T extends EventKeys>(valueEvent: Events[T], select: T, next: Next) => void;
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import 'fs';
|
|
2
2
|
import 'path';
|
|
3
3
|
import 'yaml';
|
|
4
|
-
import
|
|
4
|
+
import '../../common/logger.js';
|
|
5
|
+
import { showErrorModule } from '../../common/utils.js';
|
|
6
|
+
import 'net';
|
|
7
|
+
import 'v8';
|
|
8
|
+
import 'os';
|
|
9
|
+
import 'flatted';
|
|
10
|
+
import '../../common/cbp/runtime.js';
|
|
11
|
+
import 'ws';
|
|
5
12
|
import { getSubscribeList } from './store.js';
|
|
6
|
-
import { SubscribeStatus } from './
|
|
13
|
+
import { SubscribeStatus } from './subscribe-status.js';
|
|
7
14
|
import { withEventContext, finishCurrentTrace } from './hook-event-context.js';
|
|
8
15
|
import { dispatchEventError } from './event-error.js';
|
|
9
16
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { EventKeys, Events } from '
|
|
1
|
+
import { EventKeys, Events } from '../../types/index.js';
|
|
2
2
|
export declare const onProcessor: <T extends EventKeys>(name: T, event: Events[T], data?: any) => void;
|
|
3
3
|
export declare const OnProcessor: <T extends EventKeys>(event: Events[T], name: T) => void;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { getConfigValue } from '
|
|
2
|
-
import { processorRepeatedClearTimeMin, processorRepeatedClearTimeMax, processorRepeatedEventTime, processorRepeatedUserTime, processorRepeatedClearSize, processorMaxMapSize } from '
|
|
1
|
+
import { getConfigValue } from '../../common/config.js';
|
|
2
|
+
import { processorRepeatedClearTimeMin, processorRepeatedClearTimeMax, processorRepeatedEventTime, processorRepeatedUserTime, processorRepeatedClearSize, processorMaxMapSize } from '../../common/variable.js';
|
|
3
3
|
import { expendCycle } from './event-processor-cycle.js';
|
|
4
4
|
import { withProcessorTrace, finishCurrentTrace } from './hook-event-context.js';
|
|
5
5
|
import { ProcessorEventAutoClearMap, ProcessorEventUserAutoClearMap } from './store.js';
|
|
6
|
-
import { getCachedRegExp
|
|
6
|
+
import { getCachedRegExp } from '../../common/utils.js';
|
|
7
7
|
import { dispatchEventStart } from './lifecycle-callbacks.js';
|
|
8
|
+
import { matchIn, fastHash } from '../../common/identity.js';
|
|
8
9
|
|
|
9
10
|
const filter = ({ Now, store, INTERVAL }, MessageId) => {
|
|
10
11
|
if (store.has(MessageId)) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { OnResponseReversalFunc, OnResponseReversalFuncBack } from '
|
|
1
|
+
import { OnResponseReversalFunc, OnResponseReversalFuncBack } from '../../types/index.js';
|
|
2
2
|
export declare const onResponse: OnResponseReversalFunc;
|
|
3
3
|
export declare const OnResponse: OnResponseReversalFuncBack;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getConfig } from '
|
|
1
|
+
import { getConfig } from '../../common/config.js';
|
|
2
2
|
import { StateSubscribe, ChildrenApp, State } from './store.js';
|
|
3
|
-
import { ResultCode } from '
|
|
3
|
+
import { ResultCode } from '../../common/variable.js';
|
|
4
4
|
|
|
5
5
|
const unChildren = (name = 'main') => {
|
|
6
6
|
if (!name || typeof name !== 'string') {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Result } from '
|
|
2
|
-
import { EventErrorPhase, EventKeys, Events, EventTraceReason } from '
|
|
1
|
+
import { Result } from '../../common/index.js';
|
|
2
|
+
import { EventErrorPhase, EventKeys, Events, EventTraceReason } from '../../types/index.js';
|
|
3
3
|
export declare const withEventContext: <T extends EventKeys, R>(event: Events[T], next: (...args: boolean[]) => void, runner: () => R, options?: {
|
|
4
4
|
appName?: string;
|
|
5
5
|
phase?: EventErrorPhase;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
2
|
import { performance } from 'node:perf_hooks';
|
|
3
|
-
import { getConfigValue } from '
|
|
4
|
-
import { ResultCode } from '
|
|
3
|
+
import { getConfigValue } from '../../common/config.js';
|
|
4
|
+
import { ResultCode } from '../../common/variable.js';
|
|
5
5
|
import { dispatchEventFinished } from './lifecycle-callbacks.js';
|
|
6
6
|
|
|
7
7
|
const eventStore = new AsyncLocalStorage();
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createServer } from '../http-server.js';
|
|
2
|
+
export { default as MessageRouter } from './routers/router.js';
|
|
3
|
+
export { collectMiddlewares, runMiddlewares } from './routers/middleware.js';
|
|
4
|
+
export { formatPath, getModuelFile, isValidPackageName, safePath } from './routers/utils.js';
|
|
@@ -6,11 +6,18 @@ import hello from './hello.html.js';
|
|
|
6
6
|
import { safePath, getModuelFile, formatPath, isValidPackageName } from './utils.js';
|
|
7
7
|
import { collectMiddlewares, runMiddlewares } from './middleware.js';
|
|
8
8
|
import module$1 from 'module';
|
|
9
|
-
import { ResultCode } from '../../core/variable.js';
|
|
10
9
|
import 'yaml';
|
|
11
|
-
import '
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
10
|
+
import '../../../../common/logger.js';
|
|
11
|
+
import { ResultCode } from '../../../../common/variable.js';
|
|
12
|
+
import '../../../../common/utils.js';
|
|
13
|
+
import 'net';
|
|
14
|
+
import 'v8';
|
|
15
|
+
import 'os';
|
|
16
|
+
import 'flatted';
|
|
17
|
+
import '../../../../common/cbp/runtime.js';
|
|
18
|
+
import 'ws';
|
|
19
|
+
import { listRuntimeApps, getRuntimeApp, toRuntimeAppSnapshot, listRuntimeAppKoaRouters, hasRuntimeAppCapability, getRuntimeAppKoaRouters } from '../../store.js';
|
|
20
|
+
import { dispatchHttpError } from '../../lifecycle-callbacks.js';
|
|
14
21
|
|
|
15
22
|
const initRequire = () => { };
|
|
16
23
|
initRequire.resolve = () => '';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const safePath: (root: string, untrusted: string) => string | null;
|
|
2
2
|
export declare const isValidPackageName: (name: string) => boolean;
|
|
3
3
|
export declare const getModuelFile: (dir: string) => string;
|
|
4
|
-
export declare const formatPath: (
|
|
4
|
+
export declare const formatPath: (pathValue: string) => string;
|
|
@@ -34,17 +34,17 @@ const getModuelFile = (dir) => {
|
|
|
34
34
|
}
|
|
35
35
|
return '';
|
|
36
36
|
};
|
|
37
|
-
const formatPath = (
|
|
38
|
-
if (!
|
|
37
|
+
const formatPath = (pathValue) => {
|
|
38
|
+
if (!pathValue || pathValue === '/') {
|
|
39
39
|
return '/index.html';
|
|
40
40
|
}
|
|
41
|
-
const pates =
|
|
41
|
+
const pates = pathValue.split('/');
|
|
42
42
|
const lastPath = pates[pates.length - 1];
|
|
43
43
|
if (lastPath.includes('.')) {
|
|
44
|
-
return
|
|
44
|
+
return pathValue;
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
return
|
|
46
|
+
pathValue += '.html';
|
|
47
|
+
return pathValue;
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
export { formatPath, getModuelFile, isValidPackageName, safePath };
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import Koa from 'koa';
|
|
2
2
|
import koaCors from '@koa/cors';
|
|
3
|
-
import router from './routers/router.js';
|
|
4
|
-
import { ResultCode } from '
|
|
5
|
-
import 'fs';
|
|
6
|
-
import 'path';
|
|
7
|
-
import 'yaml';
|
|
8
|
-
import '../core/utils.js';
|
|
3
|
+
import router from './http/routers/router.js';
|
|
4
|
+
import { ResultCode } from '../../common/variable.js';
|
|
9
5
|
|
|
10
6
|
const createServer = (port, listeningListener) => {
|
|
11
7
|
try {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EventFinishedContext, EventStartContext, HttpErrorContext, RuntimeStatusChangeContext } from '
|
|
1
|
+
import type { EventFinishedContext, EventStartContext, HttpErrorContext, RuntimeStatusChangeContext } from '../../types/index.js';
|
|
2
2
|
export declare const dispatchEventStart: (context: EventStartContext) => Promise<void>;
|
|
3
3
|
export declare const dispatchEventFinished: (context: EventFinishedContext) => Promise<void>;
|
|
4
4
|
export declare const dispatchHttpError: (context: HttpErrorContext) => Promise<boolean>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { showErrorModule } from '
|
|
1
|
+
import { showErrorModule } from '../../common/utils.js';
|
|
2
2
|
|
|
3
3
|
const swallowLifecycleError = (error) => {
|
|
4
4
|
showErrorModule(error instanceof Error ? error : new Error(typeof error === 'string' ? error : 'Unknown lifecycle error'));
|
|
@@ -65,12 +65,7 @@ const dispatchAppReady = async (appName, store) => {
|
|
|
65
65
|
if (!handler) {
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
|
-
|
|
69
|
-
await handler(store);
|
|
70
|
-
}
|
|
71
|
-
catch (error) {
|
|
72
|
-
throw error;
|
|
73
|
-
}
|
|
68
|
+
await handler(store);
|
|
74
69
|
};
|
|
75
70
|
const dispatchAppDispose = async (appName, error) => {
|
|
76
71
|
const app = getChildrenApp(appName);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { getConfig } from '
|
|
1
|
+
import { getConfig } from '../../../common/config.js';
|
|
2
2
|
import { loadChildren, loadChildrenFile } from './loadChild.js';
|
|
3
3
|
import { join, dirname } from 'path';
|
|
4
4
|
import { existsSync } from 'fs';
|
|
5
|
-
import { ResultCode } from '
|
|
5
|
+
import { ResultCode } from '../../../common/variable.js';
|
|
6
6
|
import { registerRuntimeApp } from '../store.js';
|
|
7
7
|
|
|
8
8
|
const loadApps = () => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { dirname, join } from 'path';
|
|
2
2
|
import { existsSync } from 'fs';
|
|
3
|
-
import { showErrorModule, getRecursiveDirFiles, createEventName } from '
|
|
3
|
+
import { showErrorModule, getRecursiveDirFiles, createEventName } from '../../../common/utils.js';
|
|
4
4
|
import { registerRuntimeApp, updateRuntimeAppStatus, ChildrenApp, clearRuntimeAppKoaRouters, setRuntimeAppKoaRouters, updateRuntimeAppCapabilities } from '../store.js';
|
|
5
|
-
import { registerExpose } from '
|
|
6
|
-
import { ResultCode, fileSuffixMiddleware } from '
|
|
5
|
+
import { registerExpose } from '../../expose.js';
|
|
6
|
+
import { ResultCode, fileSuffixMiddleware } from '../../../common/variable.js';
|
|
7
7
|
import { registerAppDir, scheduleCancelByApp, unregisterAppDir } from '../schedule-store.js';
|
|
8
8
|
import module$1 from 'module';
|
|
9
9
|
import { dispatchRuntimeStatusChange, dispatchAppDispose, dispatchAppReady } from '../lifecycle-callbacks.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ScheduleId, ScheduleItem, ScheduleStatus, ScheduleCallback, CronExpression } from '
|
|
1
|
+
import { ScheduleId, ScheduleItem, ScheduleStatus, ScheduleCallback, CronExpression } from '../../types/schedule';
|
|
2
2
|
export declare const registerAppDir: (appName: string, mainDir: string) => void;
|
|
3
3
|
export declare const unregisterAppDir: (appName: string) => void;
|
|
4
4
|
export declare const scheduleInterval: (callback: ScheduleCallback, ms: number, appName?: string) => ScheduleId;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { SinglyLinkedList } from '
|
|
2
|
-
import { childrenCallbackRes, ChildrenCycle, EventCycleEnum, EventKeys, FileTreeNode, StoreMiddlewareItem, StoreResponseItem, SubscribeValue } from '
|
|
1
|
+
import { SinglyLinkedList } from '../../common/SinglyLinkedList.js';
|
|
2
|
+
import { childrenCallbackRes, ChildrenCycle, EventCycleEnum, EventKeys, FileTreeNode, StoreMiddlewareItem, StoreResponseItem, SubscribeValue } from '../../types';
|
|
3
3
|
import type KoaRouter from 'koa-router';
|
|
4
|
+
export { Logger, logger } from '../../common/logger.js';
|
|
4
5
|
export type RuntimeAppStatus = 'discovered' | 'loading' | 'ready' | 'failed' | 'disposed';
|
|
5
6
|
export type RuntimeAppCapability = {
|
|
6
7
|
event: boolean;
|
|
@@ -26,19 +27,14 @@ export type RuntimeAppRecord = {
|
|
|
26
27
|
createdAt: number;
|
|
27
28
|
updatedAt: number;
|
|
28
29
|
};
|
|
29
|
-
export declare class Logger {
|
|
30
|
-
#private;
|
|
31
|
-
constructor();
|
|
32
|
-
get value(): any;
|
|
33
|
-
}
|
|
34
30
|
export declare class Core {
|
|
35
31
|
constructor();
|
|
36
32
|
get value(): {
|
|
37
|
-
storeState: import("../
|
|
38
|
-
storeStateSubscribe: import("../
|
|
39
|
-
storeSubscribeList: import("../
|
|
33
|
+
storeState: import("../index.js").ResponseState;
|
|
34
|
+
storeStateSubscribe: import("../index.js").StateSubscribeMap;
|
|
35
|
+
storeSubscribeList: import("../index.js").SubscribeKeysMap;
|
|
40
36
|
storeChildrenApp: {
|
|
41
|
-
[key: string]: import("../
|
|
37
|
+
[key: string]: import("../index.js").StoreChildrenApp;
|
|
42
38
|
};
|
|
43
39
|
runtimeApps?: {
|
|
44
40
|
[key: string]: RuntimeAppRecord;
|
|
@@ -185,19 +181,18 @@ export declare class ChildrenApp {
|
|
|
185
181
|
pushCycle(data: ChildrenCycle): void;
|
|
186
182
|
on(): void;
|
|
187
183
|
un(): void;
|
|
188
|
-
get value(): import("../
|
|
184
|
+
get value(): import("../index.js").StoreChildrenApp;
|
|
189
185
|
}
|
|
190
|
-
export declare const getChildrenApp: (name: string) => import("../
|
|
191
|
-
export declare const listChildrenApps: () => import("../
|
|
186
|
+
export declare const getChildrenApp: (name: string) => import("../index.js").StoreChildrenApp;
|
|
187
|
+
export declare const listChildrenApps: () => import("../index.js").StoreChildrenApp[];
|
|
192
188
|
export declare const ProcessorEventAutoClearMap: Map<any, any>;
|
|
193
189
|
export declare const ProcessorEventUserAutoClearMap: Map<any, any>;
|
|
194
|
-
export declare const logger: any;
|
|
195
190
|
export declare const core: {
|
|
196
|
-
storeState: import("../
|
|
197
|
-
storeStateSubscribe: import("../
|
|
198
|
-
storeSubscribeList: import("../
|
|
191
|
+
storeState: import("../index.js").ResponseState;
|
|
192
|
+
storeStateSubscribe: import("../index.js").StateSubscribeMap;
|
|
193
|
+
storeSubscribeList: import("../index.js").SubscribeKeysMap;
|
|
199
194
|
storeChildrenApp: {
|
|
200
|
-
[key: string]: import("../
|
|
195
|
+
[key: string]: import("../index.js").StoreChildrenApp;
|
|
201
196
|
};
|
|
202
197
|
runtimeApps?: {
|
|
203
198
|
[key: string]: RuntimeAppRecord;
|