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
|
@@ -2,15 +2,22 @@ import KoaRouter from 'koa-router';
|
|
|
2
2
|
import fs__default, { existsSync } from 'fs';
|
|
3
3
|
import path__default, { join, dirname } from 'path';
|
|
4
4
|
import mime from 'mime-types';
|
|
5
|
-
import
|
|
5
|
+
import { renderHelloHtml } 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, getChildrenApp, getRuntimeAppKoaRouters } from '../../store.js';
|
|
20
|
+
import { dispatchHttpError } from '../../lifecycle-callbacks.js';
|
|
14
21
|
|
|
15
22
|
const initRequire = () => { };
|
|
16
23
|
initRequire.resolve = () => '';
|
|
@@ -31,14 +38,61 @@ const resolvePackageRoot = (startDir) => {
|
|
|
31
38
|
const readWebRootConfig = (packageRoot) => {
|
|
32
39
|
const packageJsonPath = path__default.join(packageRoot, 'package.json');
|
|
33
40
|
if (!existsSync(packageJsonPath)) {
|
|
41
|
+
if (existsSync(path__default.join(packageRoot, 'dist', 'index.html'))) {
|
|
42
|
+
return 'dist';
|
|
43
|
+
}
|
|
34
44
|
return '';
|
|
35
45
|
}
|
|
36
46
|
const pkg = require$1(packageJsonPath) ?? {};
|
|
37
|
-
|
|
47
|
+
const configuredRoot = pkg?.alemonjs?.web?.root ?? '';
|
|
48
|
+
if (typeof configuredRoot === 'string' && configuredRoot.trim()) {
|
|
49
|
+
return configuredRoot;
|
|
50
|
+
}
|
|
51
|
+
if (existsSync(path__default.join(packageRoot, 'dist', 'index.html'))) {
|
|
52
|
+
return 'dist';
|
|
53
|
+
}
|
|
54
|
+
return '';
|
|
55
|
+
};
|
|
56
|
+
const matchBasePath = (requestPath, basePath) => {
|
|
57
|
+
if (!basePath) {
|
|
58
|
+
return requestPath;
|
|
59
|
+
}
|
|
60
|
+
if (requestPath === basePath) {
|
|
61
|
+
return '/';
|
|
62
|
+
}
|
|
63
|
+
if (requestPath.startsWith(`${basePath}/`)) {
|
|
64
|
+
return requestPath.slice(basePath.length) || '/';
|
|
65
|
+
}
|
|
66
|
+
return '';
|
|
67
|
+
};
|
|
68
|
+
const matchApiBasePath = (requestPath, basePath) => {
|
|
69
|
+
return requestPath === basePath || requestPath.startsWith(`${basePath}/`);
|
|
70
|
+
};
|
|
71
|
+
const needsTrailingSlashRedirect = (requestUrl, basePath) => {
|
|
72
|
+
return requestUrl === basePath || requestUrl.startsWith(`${basePath}?`);
|
|
73
|
+
};
|
|
74
|
+
const getOriginalPathname = (ctx) => {
|
|
75
|
+
const rawUrl = typeof ctx.originalUrl === 'string' && ctx.originalUrl ? ctx.originalUrl : ctx.url;
|
|
76
|
+
const [pathname] = String(rawUrl).split('?');
|
|
77
|
+
return pathname || '/';
|
|
78
|
+
};
|
|
79
|
+
const rewriteCtxPath = async (ctx, nextPath, handler) => {
|
|
80
|
+
const search = ctx.querystring ? `?${ctx.querystring}` : '';
|
|
81
|
+
const originalUrl = ctx.url;
|
|
82
|
+
const originalReqUrl = ctx.req.url;
|
|
83
|
+
ctx.url = `${nextPath}${search}`;
|
|
84
|
+
ctx.req.url = `${nextPath}${search}`;
|
|
85
|
+
try {
|
|
86
|
+
await handler();
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
ctx.url = originalUrl;
|
|
90
|
+
ctx.req.url = originalReqUrl;
|
|
91
|
+
}
|
|
38
92
|
};
|
|
39
93
|
const denyRuntimeAppAccess = (ctx, appName, capability) => {
|
|
40
94
|
const runtimeApp = getRuntimeApp(appName);
|
|
41
|
-
if (!runtimeApp
|
|
95
|
+
if (!runtimeApp?.enabled) {
|
|
42
96
|
ctx.status = 404;
|
|
43
97
|
ctx.body = {
|
|
44
98
|
code: 404,
|
|
@@ -96,30 +150,59 @@ const denyRuntimeAppAccess = (ctx, appName, capability) => {
|
|
|
96
150
|
}
|
|
97
151
|
return runtimeApp;
|
|
98
152
|
};
|
|
99
|
-
const
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
153
|
+
const getRuntimeAppRouters = (appName) => {
|
|
154
|
+
const registerRouters = getChildrenApp(appName)?.register?.koaRouter;
|
|
155
|
+
const storedRouters = getRuntimeAppKoaRouters(appName);
|
|
156
|
+
return (storedRouters.length ? storedRouters : Array.isArray(registerRouters) ? registerRouters : registerRouters ? [registerRouters] : []).filter(Boolean);
|
|
157
|
+
};
|
|
158
|
+
const dispatchAppKoaRouters = async (ctx, appName) => {
|
|
159
|
+
const runtimeApp = getRuntimeApp(appName);
|
|
160
|
+
if (!runtimeApp || !runtimeApp.enabled || runtimeApp.status !== 'ready' || !hasRuntimeAppCapability(appName, 'httpApi')) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
const routers = getRuntimeAppRouters(appName);
|
|
164
|
+
const aliasBases = appName === 'main' ? ['/app'] : [`/apps/${appName}`];
|
|
165
|
+
for (const koaRouter of routers) {
|
|
166
|
+
for (const basePath of aliasBases) {
|
|
167
|
+
const rewrittenPath = matchBasePath(ctx.path, basePath);
|
|
168
|
+
if (!rewrittenPath) {
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
108
171
|
try {
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
|
|
172
|
+
const matchedContext = ctx;
|
|
173
|
+
const beforeMatched = Array.isArray(matchedContext.matched) ? matchedContext.matched.length : 0;
|
|
174
|
+
const beforeStatus = ctx.status;
|
|
175
|
+
const beforeBody = ctx.body;
|
|
176
|
+
const beforeMatchedRoute = ctx._matchedRoute;
|
|
177
|
+
const beforeRouterPath = ctx.routerPath;
|
|
178
|
+
let fallthrough = false;
|
|
179
|
+
await rewriteCtxPath(ctx, rewrittenPath, async () => {
|
|
180
|
+
await koaRouter.routes()(ctx, async () => {
|
|
181
|
+
fallthrough = true;
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
const afterMatched = Array.isArray(matchedContext.matched) ? matchedContext.matched.length : 0;
|
|
185
|
+
const afterMatchedRoute = ctx._matchedRoute;
|
|
186
|
+
const afterRouterPath = ctx.routerPath;
|
|
187
|
+
const handled = afterMatched > beforeMatched
|
|
188
|
+
|| afterMatchedRoute !== beforeMatchedRoute
|
|
189
|
+
|| afterRouterPath !== beforeRouterPath
|
|
190
|
+
|| ctx.status !== beforeStatus
|
|
191
|
+
|| ctx.body !== beforeBody
|
|
192
|
+
|| !fallthrough;
|
|
193
|
+
if (!handled) {
|
|
113
194
|
continue;
|
|
114
195
|
}
|
|
115
|
-
await
|
|
196
|
+
await rewriteCtxPath(ctx, rewrittenPath, async () => {
|
|
197
|
+
await koaRouter.allowedMethods()(ctx, async () => { });
|
|
198
|
+
});
|
|
116
199
|
return true;
|
|
117
200
|
}
|
|
118
201
|
catch (error) {
|
|
119
202
|
const handled = await dispatchHttpError({
|
|
120
203
|
ctx,
|
|
121
204
|
error,
|
|
122
|
-
appName
|
|
205
|
+
appName,
|
|
123
206
|
path: ctx.path,
|
|
124
207
|
method: ctx.method,
|
|
125
208
|
kind: 'koa-router'
|
|
@@ -144,10 +227,112 @@ const dispatchRegisteredKoaRouters = async (ctx) => {
|
|
|
144
227
|
}
|
|
145
228
|
return false;
|
|
146
229
|
};
|
|
230
|
+
const isNamespacedHtmlRequest = (ctx) => {
|
|
231
|
+
if (ctx.method !== 'GET') {
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
if (ctx.path === '/app' || ctx.path.startsWith('/app/')) {
|
|
235
|
+
return !matchApiBasePath(ctx.path, '/app/api');
|
|
236
|
+
}
|
|
237
|
+
if (!ctx.path.startsWith('/apps/')) {
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
const [, , appName, segment = ''] = ctx.path.split('/');
|
|
241
|
+
if (!appName) {
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
return !matchApiBasePath(ctx.path, `/apps/${appName}/api`);
|
|
245
|
+
};
|
|
246
|
+
const dispatchRegisteredKoaRouters = async (ctx) => {
|
|
247
|
+
const registeredRouters = listRuntimeAppKoaRouters();
|
|
248
|
+
const candidates = new Set(registeredRouters.map(item => item.name));
|
|
249
|
+
const runtimeApps = listRuntimeApps();
|
|
250
|
+
runtimeApps.forEach(item => {
|
|
251
|
+
if (item.capabilities?.httpApi) {
|
|
252
|
+
candidates.add(item.name);
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
for (const appName of candidates) {
|
|
256
|
+
const handled = await dispatchAppKoaRouters(ctx, appName);
|
|
257
|
+
if (handled) {
|
|
258
|
+
return true;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return false;
|
|
262
|
+
};
|
|
263
|
+
const serveStaticResource = async (ctx, appName, rootDir, resourcePath) => {
|
|
264
|
+
const packageRoot = resolvePackageRoot(rootDir);
|
|
265
|
+
let root = '';
|
|
266
|
+
try {
|
|
267
|
+
root = readWebRootConfig(packageRoot);
|
|
268
|
+
}
|
|
269
|
+
catch (err) {
|
|
270
|
+
const handled = await dispatchHttpError({
|
|
271
|
+
ctx,
|
|
272
|
+
error: err,
|
|
273
|
+
appName,
|
|
274
|
+
path: ctx.path,
|
|
275
|
+
method: ctx.method,
|
|
276
|
+
kind: 'web'
|
|
277
|
+
});
|
|
278
|
+
if (handled) {
|
|
279
|
+
return 'handled';
|
|
280
|
+
}
|
|
281
|
+
ctx.status = 500;
|
|
282
|
+
ctx.body = {
|
|
283
|
+
code: 500,
|
|
284
|
+
message: '加载 package.json 时发生错误。',
|
|
285
|
+
error: err instanceof Error ? err.message : String(err)
|
|
286
|
+
};
|
|
287
|
+
return 'handled';
|
|
288
|
+
}
|
|
289
|
+
const webRoot = root ? path__default.join(packageRoot, root) : packageRoot;
|
|
290
|
+
const fullPath = safePath(webRoot, resourcePath);
|
|
291
|
+
if (!fullPath) {
|
|
292
|
+
ctx.status = 403;
|
|
293
|
+
ctx.body = {
|
|
294
|
+
code: 403,
|
|
295
|
+
message: '非法路径',
|
|
296
|
+
data: null
|
|
297
|
+
};
|
|
298
|
+
return 'handled';
|
|
299
|
+
}
|
|
300
|
+
if (!existsSync(fullPath)) {
|
|
301
|
+
return 'miss';
|
|
302
|
+
}
|
|
303
|
+
try {
|
|
304
|
+
const file = await fs__default.promises.readFile(fullPath);
|
|
305
|
+
const mimeType = mime.lookup(fullPath) || 'application/octet-stream';
|
|
306
|
+
ctx.set('Content-Type', mimeType);
|
|
307
|
+
ctx.body = file;
|
|
308
|
+
ctx.status = 200;
|
|
309
|
+
return 'handled';
|
|
310
|
+
}
|
|
311
|
+
catch (err) {
|
|
312
|
+
const handled = await dispatchHttpError({
|
|
313
|
+
ctx,
|
|
314
|
+
error: err,
|
|
315
|
+
appName,
|
|
316
|
+
path: ctx.path,
|
|
317
|
+
method: ctx.method,
|
|
318
|
+
kind: 'web'
|
|
319
|
+
});
|
|
320
|
+
if (handled) {
|
|
321
|
+
return 'handled';
|
|
322
|
+
}
|
|
323
|
+
ctx.status = 500;
|
|
324
|
+
ctx.body = {
|
|
325
|
+
code: 500,
|
|
326
|
+
message: appName === 'main' ? '加载资源时发生服务器错误。' : `加载子应用 '${appName}' 资源时发生服务器错误。`,
|
|
327
|
+
error: err instanceof Error ? err.message : String(err)
|
|
328
|
+
};
|
|
329
|
+
return 'handled';
|
|
330
|
+
}
|
|
331
|
+
};
|
|
147
332
|
router.get('/', ctx => {
|
|
148
333
|
ctx.status = 200;
|
|
149
334
|
ctx.set('Content-Type', 'text/html; charset=utf-8');
|
|
150
|
-
ctx.body =
|
|
335
|
+
ctx.body = renderHelloHtml(listRuntimeApps());
|
|
151
336
|
});
|
|
152
337
|
router.get('api/online', ctx => {
|
|
153
338
|
ctx.status = 200;
|
|
@@ -192,13 +377,21 @@ router.get('api/runtime/apps/:app', ctx => {
|
|
|
192
377
|
};
|
|
193
378
|
});
|
|
194
379
|
router.use(async (ctx, next) => {
|
|
380
|
+
if (isNamespacedHtmlRequest(ctx)) {
|
|
381
|
+
await next();
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
195
384
|
const handled = await dispatchRegisteredKoaRouters(ctx);
|
|
196
385
|
if (handled) {
|
|
197
386
|
return;
|
|
198
387
|
}
|
|
199
388
|
await next();
|
|
200
389
|
});
|
|
201
|
-
|
|
390
|
+
const handleMainAppRequest = async (ctx) => {
|
|
391
|
+
if (needsTrailingSlashRedirect(getOriginalPathname(ctx), '/app')) {
|
|
392
|
+
ctx.redirect('/app/');
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
202
395
|
if (!process.env.input) {
|
|
203
396
|
ctx.status = 400;
|
|
204
397
|
ctx.body = {
|
|
@@ -210,7 +403,7 @@ router.all('app/{*path}', async (ctx) => {
|
|
|
210
403
|
}
|
|
211
404
|
const rootPath = process.cwd();
|
|
212
405
|
const apiPath = '/app/api';
|
|
213
|
-
if (ctx.path
|
|
406
|
+
if (matchApiBasePath(ctx.path, apiPath)) {
|
|
214
407
|
const runtimeApp = denyRuntimeAppAccess(ctx, 'main', 'httpApi');
|
|
215
408
|
if (!runtimeApp) {
|
|
216
409
|
return;
|
|
@@ -291,88 +484,36 @@ router.all('app/{*path}', async (ctx) => {
|
|
|
291
484
|
ctx.status = 405;
|
|
292
485
|
return;
|
|
293
486
|
}
|
|
294
|
-
|
|
487
|
+
const runtimeApp = getRuntimeApp('main');
|
|
295
488
|
const resourcePath = formatPath(ctx.params?.path);
|
|
296
|
-
|
|
297
|
-
|
|
489
|
+
if (!runtimeApp?.enabled || runtimeApp.status !== 'ready') {
|
|
490
|
+
denyRuntimeAppAccess(ctx, 'main', 'web');
|
|
298
491
|
return;
|
|
299
492
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}
|
|
304
|
-
catch (err) {
|
|
305
|
-
const handled = await dispatchHttpError({
|
|
306
|
-
ctx,
|
|
307
|
-
error: err,
|
|
308
|
-
appName: 'main',
|
|
309
|
-
path: ctx.path,
|
|
310
|
-
method: ctx.method,
|
|
311
|
-
kind: 'web'
|
|
312
|
-
});
|
|
313
|
-
if (handled) {
|
|
493
|
+
if (hasRuntimeAppCapability('main', 'web')) {
|
|
494
|
+
const staticResult = await serveStaticResource(ctx, 'main', runtimeApp.rootDir, resourcePath);
|
|
495
|
+
if (staticResult === 'handled') {
|
|
314
496
|
return;
|
|
315
497
|
}
|
|
316
|
-
ctx.status = 500;
|
|
317
|
-
ctx.body = {
|
|
318
|
-
code: 500,
|
|
319
|
-
message: '加载 package.json 时发生错误。',
|
|
320
|
-
error: err instanceof Error ? err.message : String(err)
|
|
321
|
-
};
|
|
322
|
-
return;
|
|
323
498
|
}
|
|
324
|
-
|
|
325
|
-
const fullPath = safePath(webRoot, resourcePath);
|
|
326
|
-
if (!fullPath) {
|
|
327
|
-
ctx.status = 403;
|
|
328
|
-
ctx.body = {
|
|
329
|
-
code: 403,
|
|
330
|
-
message: '非法路径',
|
|
331
|
-
data: null
|
|
332
|
-
};
|
|
499
|
+
if (await dispatchAppKoaRouters(ctx, 'main')) {
|
|
333
500
|
return;
|
|
334
501
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
ctx.set('Content-Type', mimeType);
|
|
339
|
-
ctx.body = file;
|
|
340
|
-
ctx.status = 200;
|
|
341
|
-
}
|
|
342
|
-
catch (err) {
|
|
343
|
-
const handled = await dispatchHttpError({
|
|
344
|
-
ctx,
|
|
345
|
-
error: err,
|
|
346
|
-
appName: 'main',
|
|
347
|
-
path: ctx.path,
|
|
348
|
-
method: ctx.method,
|
|
349
|
-
kind: 'web'
|
|
350
|
-
});
|
|
351
|
-
if (handled) {
|
|
352
|
-
return;
|
|
353
|
-
}
|
|
354
|
-
if (err?.status === 404) {
|
|
355
|
-
ctx.status = 404;
|
|
356
|
-
ctx.body = {
|
|
357
|
-
code: 404,
|
|
358
|
-
message: '资源中未找到。',
|
|
359
|
-
data: null
|
|
360
|
-
};
|
|
361
|
-
}
|
|
362
|
-
else {
|
|
363
|
-
ctx.status = 500;
|
|
364
|
-
ctx.body = {
|
|
365
|
-
code: 500,
|
|
366
|
-
message: '加载资源时发生服务器错误。',
|
|
367
|
-
error: err instanceof Error ? err.message : String(err)
|
|
368
|
-
};
|
|
369
|
-
}
|
|
502
|
+
if (!hasRuntimeAppCapability('main', 'web')) {
|
|
503
|
+
denyRuntimeAppAccess(ctx, 'main', 'web');
|
|
504
|
+
return;
|
|
370
505
|
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
506
|
+
ctx.status = 404;
|
|
507
|
+
ctx.body = {
|
|
508
|
+
code: 404,
|
|
509
|
+
message: '资源中未找到。',
|
|
510
|
+
data: null
|
|
511
|
+
};
|
|
512
|
+
};
|
|
513
|
+
router.all('app', handleMainAppRequest);
|
|
514
|
+
router.all('app/', handleMainAppRequest);
|
|
515
|
+
router.all('app/{*path}', handleMainAppRequest);
|
|
516
|
+
const handlePluginAppRequest = async (ctx) => {
|
|
376
517
|
const appName = ctx.params.app;
|
|
377
518
|
if (!isValidPackageName(appName)) {
|
|
378
519
|
ctx.status = 400;
|
|
@@ -383,8 +524,12 @@ router.all('apps/:app/{*path}', async (ctx) => {
|
|
|
383
524
|
};
|
|
384
525
|
return;
|
|
385
526
|
}
|
|
527
|
+
if (needsTrailingSlashRedirect(getOriginalPathname(ctx), `/apps/${appName}`)) {
|
|
528
|
+
ctx.redirect(`/apps/${appName}/`);
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
386
531
|
const apiPath = `/apps/${appName}/api`;
|
|
387
|
-
if (ctx.path
|
|
532
|
+
if (matchApiBasePath(ctx.path, apiPath)) {
|
|
388
533
|
const runtimeApp = denyRuntimeAppAccess(ctx, appName, 'httpApi');
|
|
389
534
|
if (!runtimeApp) {
|
|
390
535
|
return;
|
|
@@ -459,93 +604,34 @@ router.all('apps/:app/{*path}', async (ctx) => {
|
|
|
459
604
|
ctx.status = 405;
|
|
460
605
|
return;
|
|
461
606
|
}
|
|
462
|
-
const runtimeApp =
|
|
463
|
-
if (!runtimeApp) {
|
|
464
|
-
return;
|
|
465
|
-
}
|
|
466
|
-
const packageRoot = resolvePackageRoot(runtimeApp.rootDir);
|
|
607
|
+
const runtimeApp = getRuntimeApp(appName);
|
|
467
608
|
const resourcePath = formatPath(ctx.params?.path);
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
609
|
+
if (!runtimeApp?.enabled || runtimeApp.status !== 'ready') {
|
|
610
|
+
denyRuntimeAppAccess(ctx, appName, 'web');
|
|
611
|
+
return;
|
|
471
612
|
}
|
|
472
|
-
|
|
473
|
-
const
|
|
474
|
-
|
|
475
|
-
error: err,
|
|
476
|
-
appName,
|
|
477
|
-
path: ctx.path,
|
|
478
|
-
method: ctx.method,
|
|
479
|
-
kind: 'web'
|
|
480
|
-
});
|
|
481
|
-
if (handled) {
|
|
613
|
+
if (hasRuntimeAppCapability(appName, 'web')) {
|
|
614
|
+
const staticResult = await serveStaticResource(ctx, appName, runtimeApp.rootDir, resourcePath);
|
|
615
|
+
if (staticResult === 'handled') {
|
|
482
616
|
return;
|
|
483
617
|
}
|
|
484
|
-
ctx.status = 500;
|
|
485
|
-
ctx.body = {
|
|
486
|
-
code: 500,
|
|
487
|
-
message: '加载 package.json 时发生错误。',
|
|
488
|
-
error: err instanceof Error ? err.message : String(err)
|
|
489
|
-
};
|
|
490
|
-
return;
|
|
491
618
|
}
|
|
492
|
-
|
|
493
|
-
const fullPath = safePath(webRoot, resourcePath);
|
|
494
|
-
if (!fullPath) {
|
|
495
|
-
ctx.status = 403;
|
|
496
|
-
ctx.body = {
|
|
497
|
-
code: 403,
|
|
498
|
-
message: '非法路径',
|
|
499
|
-
data: null
|
|
500
|
-
};
|
|
619
|
+
if (await dispatchAppKoaRouters(ctx, appName)) {
|
|
501
620
|
return;
|
|
502
621
|
}
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
ctx.set('Content-Type', mimeType);
|
|
507
|
-
ctx.body = file;
|
|
508
|
-
ctx.status = 200;
|
|
509
|
-
}
|
|
510
|
-
catch (err) {
|
|
511
|
-
const handled = await dispatchHttpError({
|
|
512
|
-
ctx,
|
|
513
|
-
error: err,
|
|
514
|
-
appName,
|
|
515
|
-
path: ctx.path,
|
|
516
|
-
method: ctx.method,
|
|
517
|
-
kind: 'web'
|
|
518
|
-
});
|
|
519
|
-
if (handled) {
|
|
520
|
-
return;
|
|
521
|
-
}
|
|
522
|
-
if (err?.status === 404) {
|
|
523
|
-
ctx.status = 404;
|
|
524
|
-
ctx.body = {
|
|
525
|
-
code: 404,
|
|
526
|
-
message: `资源 '${resourcePath}' 在子应用 '${appName}' 中未找到。`,
|
|
527
|
-
data: null
|
|
528
|
-
};
|
|
529
|
-
}
|
|
530
|
-
else {
|
|
531
|
-
logger.warn({
|
|
532
|
-
code: ResultCode.Fail,
|
|
533
|
-
message: `Error request ${ctx.path}:`,
|
|
534
|
-
data: err instanceof Error ? err.message : String(err)
|
|
535
|
-
});
|
|
536
|
-
ctx.status = 500;
|
|
537
|
-
ctx.body = {
|
|
538
|
-
code: 500,
|
|
539
|
-
message: `加载子应用 '${appName}' 资源时发生服务器错误。`,
|
|
540
|
-
error: err instanceof Error ? err.message : String(err)
|
|
541
|
-
};
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
});
|
|
545
|
-
router.all('apps/:name', ctx => {
|
|
546
|
-
if (ctx.path === `/apps/${ctx.params.name}`) {
|
|
547
|
-
ctx.redirect(`/apps/${ctx.params.name}/`);
|
|
622
|
+
if (!hasRuntimeAppCapability(appName, 'web')) {
|
|
623
|
+
denyRuntimeAppAccess(ctx, appName, 'web');
|
|
624
|
+
return;
|
|
548
625
|
}
|
|
549
|
-
|
|
626
|
+
ctx.status = 404;
|
|
627
|
+
ctx.body = {
|
|
628
|
+
code: 404,
|
|
629
|
+
message: `资源 '${resourcePath}' 在子应用 '${appName}' 中未找到。`,
|
|
630
|
+
data: null
|
|
631
|
+
};
|
|
632
|
+
};
|
|
633
|
+
router.all('apps/:app', handlePluginAppRequest);
|
|
634
|
+
router.all('apps/:app/', handlePluginAppRequest);
|
|
635
|
+
router.all('apps/:app/{*path}', handlePluginAppRequest);
|
|
550
636
|
|
|
551
637
|
export { router as default };
|
|
@@ -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,31 @@ const getModuelFile = (dir) => {
|
|
|
34
34
|
}
|
|
35
35
|
return '';
|
|
36
36
|
};
|
|
37
|
-
const formatPath = (
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
const formatPath = (pathValue) => {
|
|
38
|
+
const normalizedPath = String(pathValue || '')
|
|
39
|
+
.replace(/\\/g, '/')
|
|
40
|
+
.replace(/^\/+/, '')
|
|
41
|
+
.replace(/\/{2,}/g, '/')
|
|
42
|
+
.trim();
|
|
43
|
+
if (!normalizedPath) {
|
|
44
|
+
return 'index.html';
|
|
45
|
+
}
|
|
46
|
+
if (normalizedPath === 'index' || normalizedPath === 'index.html') {
|
|
47
|
+
return 'index.html';
|
|
48
|
+
}
|
|
49
|
+
if (normalizedPath.endsWith('/')) {
|
|
50
|
+
return `${normalizedPath}index.html`;
|
|
51
|
+
}
|
|
52
|
+
const parts = normalizedPath.split('/');
|
|
53
|
+
const lastPath = parts[parts.length - 1];
|
|
54
|
+
if (lastPath === 'index' || lastPath === 'index.html') {
|
|
55
|
+
parts[parts.length - 1] = 'index.html';
|
|
56
|
+
return parts.join('/');
|
|
40
57
|
}
|
|
41
|
-
const pates = path.split('/');
|
|
42
|
-
const lastPath = pates[pates.length - 1];
|
|
43
58
|
if (lastPath.includes('.')) {
|
|
44
|
-
return
|
|
59
|
+
return normalizedPath;
|
|
45
60
|
}
|
|
46
|
-
|
|
47
|
-
return path;
|
|
61
|
+
return `${normalizedPath}.html`;
|
|
48
62
|
};
|
|
49
63
|
|
|
50
64
|
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 = () => {
|