@pisell/core 0.0.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/README.md +1 -0
- package/es/app/app.d.ts +101 -0
- package/es/app/app.js +177 -0
- package/es/app/const.d.ts +4 -0
- package/es/app/const.js +6 -0
- package/es/app/index.d.ts +14 -0
- package/es/app/index.js +52 -0
- package/es/applicationManager/application.d.ts +197 -0
- package/es/applicationManager/application.js +469 -0
- package/es/applicationManager/index.d.ts +19 -0
- package/es/applicationManager/index.js +206 -0
- package/es/aws/index.d.ts +16 -0
- package/es/aws/index.js +76 -0
- package/es/cmd/const.d.ts +11 -0
- package/es/cmd/const.js +13 -0
- package/es/cmd/index.d.ts +13 -0
- package/es/cmd/index.js +91 -0
- package/es/cmd/type.d.ts +5 -0
- package/es/cmd/type.js +1 -0
- package/es/communicationManager/index.d.ts +59 -0
- package/es/communicationManager/index.js +174 -0
- package/es/config.d.ts +3 -0
- package/es/config.js +14 -0
- package/es/cookie/index.d.ts +13 -0
- package/es/cookie/index.js +47 -0
- package/es/css/global.less +73 -0
- package/es/css/index.less +31 -0
- package/es/css/variables.css +84 -0
- package/es/data/index.d.ts +8 -0
- package/es/data/index.js +16 -0
- package/es/history/config.d.ts +24 -0
- package/es/history/config.js +43 -0
- package/es/history/index.d.ts +26 -0
- package/es/history/index.js +80 -0
- package/es/history/type.d.ts +2 -0
- package/es/history/type.js +1 -0
- package/es/hooks/index.d.ts +12 -0
- package/es/hooks/index.js +13 -0
- package/es/hooks/useDelayedValue/index.d.ts +2 -0
- package/es/hooks/useDelayedValue/index.js +26 -0
- package/es/hooks/useDispatch/index.d.ts +2 -0
- package/es/hooks/useDispatch/index.js +2 -0
- package/es/hooks/useLowCode/index.d.ts +13 -0
- package/es/hooks/useLowCode/index.js +74 -0
- package/es/hooks/useStore/index.d.ts +6 -0
- package/es/hooks/useStore/index.js +11 -0
- package/es/index.d.ts +8 -0
- package/es/index.js +10 -0
- package/es/indexDB/index.d.ts +296 -0
- package/es/indexDB/index.js +1619 -0
- package/es/locales/en.d.ts +3 -0
- package/es/locales/en.js +5 -0
- package/es/locales/index.d.ts +39 -0
- package/es/locales/index.js +199 -0
- package/es/locales/original.d.ts +3 -0
- package/es/locales/original.js +7 -0
- package/es/locales/type.d.ts +19 -0
- package/es/locales/type.js +1 -0
- package/es/locales/zh-CN.d.ts +3 -0
- package/es/locales/zh-CN.js +5 -0
- package/es/locales/zh-HK.d.ts +3 -0
- package/es/locales/zh-HK.js +5 -0
- package/es/logger/feishu.d.ts +11 -0
- package/es/logger/feishu.js +50 -0
- package/es/logger/index.d.ts +135 -0
- package/es/logger/index.js +870 -0
- package/es/menuManager/hooks.d.ts +17 -0
- package/es/menuManager/hooks.js +136 -0
- package/es/menuManager/index.d.ts +28 -0
- package/es/menuManager/index.js +165 -0
- package/es/models/global.d.ts +32 -0
- package/es/models/global.js +66 -0
- package/es/models/index.d.ts +45 -0
- package/es/models/index.js +65 -0
- package/es/models/type.d.ts +2 -0
- package/es/models/type.js +1 -0
- package/es/plugin/index.d.ts +0 -0
- package/es/plugin/index.js +0 -0
- package/es/pubsub/example.d.ts +5 -0
- package/es/pubsub/example.js +92 -0
- package/es/pubsub/index.d.ts +73 -0
- package/es/pubsub/index.js +166 -0
- package/es/render/index.d.ts +0 -0
- package/es/render/index.js +0 -0
- package/es/request/cache.d.ts +46 -0
- package/es/request/cache.js +372 -0
- package/es/request/cancelToken.d.ts +38 -0
- package/es/request/cancelToken.js +59 -0
- package/es/request/config.d.ts +3 -0
- package/es/request/config.js +63 -0
- package/es/request/constants.d.ts +2 -0
- package/es/request/constants.js +6 -0
- package/es/request/index.d.ts +24 -0
- package/es/request/index.js +267 -0
- package/es/request/pisell2Request.d.ts +6 -0
- package/es/request/pisell2Request.js +62 -0
- package/es/request/type.d.ts +57 -0
- package/es/request/type.js +10 -0
- package/es/request/utils.d.ts +46 -0
- package/es/request/utils.js +147 -0
- package/es/routes/config.d.ts +7 -0
- package/es/routes/config.js +17 -0
- package/es/routes/index.d.ts +28 -0
- package/es/routes/index.js +151 -0
- package/es/socket/components/SocketMonitorPage.d.ts +6 -0
- package/es/socket/components/SocketMonitorPage.js +485 -0
- package/es/socket/components/index.d.ts +2 -0
- package/es/socket/components/index.js +2 -0
- package/es/socket/constants.d.ts +33 -0
- package/es/socket/constants.js +39 -0
- package/es/socket/events.d.ts +31 -0
- package/es/socket/events.js +19 -0
- package/es/socket/heartbeat.d.ts +66 -0
- package/es/socket/heartbeat.js +184 -0
- package/es/socket/index.d.ts +61 -0
- package/es/socket/index.js +246 -0
- package/es/socket/monitor.d.ts +169 -0
- package/es/socket/monitor.js +448 -0
- package/es/socket/reconnect.d.ts +61 -0
- package/es/socket/reconnect.js +199 -0
- package/es/socket/socket.d.ts +130 -0
- package/es/socket/socket.js +613 -0
- package/es/socket/types.d.ts +85 -0
- package/es/socket/types.js +35 -0
- package/es/storage/index.d.ts +17 -0
- package/es/storage/index.js +46 -0
- package/es/tasks/index.d.ts +127 -0
- package/es/tasks/index.js +1119 -0
- package/es/tasks/scheduledTasksExample.d.ts +61 -0
- package/es/tasks/scheduledTasksExample.js +351 -0
- package/es/tasks/type.d.ts +100 -0
- package/es/tasks/type.js +1 -0
- package/es/tasks/useTasks.d.ts +5 -0
- package/es/tasks/useTasks.js +25 -0
- package/es/type.d.ts +2 -0
- package/es/type.js +1 -0
- package/es/utils/adaptiveThrottle/index.d.ts +36 -0
- package/es/utils/adaptiveThrottle/index.js +136 -0
- package/es/variables/VariablesProvider.d.ts +7 -0
- package/es/variables/VariablesProvider.js +12 -0
- package/es/variables/config.d.ts +3 -0
- package/es/variables/config.js +16 -0
- package/es/variables/index.d.ts +6 -0
- package/es/variables/index.js +5 -0
- package/es/variables/type.d.ts +2 -0
- package/es/variables/type.js +1 -0
- package/es/website/index.d.ts +6 -0
- package/es/website/index.js +65 -0
- package/lib/app/app.d.ts +101 -0
- package/lib/app/app.js +171 -0
- package/lib/app/const.d.ts +4 -0
- package/lib/app/const.js +33 -0
- package/lib/app/index.d.ts +14 -0
- package/lib/app/index.js +76 -0
- package/lib/applicationManager/application.d.ts +197 -0
- package/lib/applicationManager/application.js +280 -0
- package/lib/applicationManager/index.d.ts +19 -0
- package/lib/applicationManager/index.js +88 -0
- package/lib/aws/index.d.ts +16 -0
- package/lib/aws/index.js +67 -0
- package/lib/cmd/const.d.ts +11 -0
- package/lib/cmd/const.js +39 -0
- package/lib/cmd/index.d.ts +13 -0
- package/lib/cmd/index.js +96 -0
- package/lib/cmd/type.d.ts +5 -0
- package/lib/cmd/type.js +17 -0
- package/lib/communicationManager/index.d.ts +59 -0
- package/lib/communicationManager/index.js +102 -0
- package/lib/config.d.ts +3 -0
- package/lib/config.js +36 -0
- package/lib/cookie/index.d.ts +13 -0
- package/lib/cookie/index.js +62 -0
- package/lib/css/global.less +73 -0
- package/lib/css/index.less +31 -0
- package/lib/css/variables.css +84 -0
- package/lib/data/index.d.ts +8 -0
- package/lib/data/index.js +38 -0
- package/lib/history/config.d.ts +24 -0
- package/lib/history/config.js +41 -0
- package/lib/history/index.d.ts +26 -0
- package/lib/history/index.js +99 -0
- package/lib/history/type.d.ts +2 -0
- package/lib/history/type.js +17 -0
- package/lib/hooks/index.d.ts +12 -0
- package/lib/hooks/index.js +44 -0
- package/lib/hooks/useDelayedValue/index.d.ts +2 -0
- package/lib/hooks/useDelayedValue/index.js +36 -0
- package/lib/hooks/useDispatch/index.d.ts +2 -0
- package/lib/hooks/useDispatch/index.js +26 -0
- package/lib/hooks/useLowCode/index.d.ts +13 -0
- package/lib/hooks/useLowCode/index.js +75 -0
- package/lib/hooks/useStore/index.d.ts +6 -0
- package/lib/hooks/useStore/index.js +33 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.js +58 -0
- package/lib/indexDB/index.d.ts +296 -0
- package/lib/indexDB/index.js +767 -0
- package/lib/locales/en.d.ts +3 -0
- package/lib/locales/en.js +29 -0
- package/lib/locales/index.d.ts +39 -0
- package/lib/locales/index.js +159 -0
- package/lib/locales/original.d.ts +3 -0
- package/lib/locales/original.js +31 -0
- package/lib/locales/type.d.ts +19 -0
- package/lib/locales/type.js +17 -0
- package/lib/locales/zh-CN.d.ts +3 -0
- package/lib/locales/zh-CN.js +29 -0
- package/lib/locales/zh-HK.d.ts +3 -0
- package/lib/locales/zh-HK.js +29 -0
- package/lib/logger/feishu.d.ts +11 -0
- package/lib/logger/feishu.js +52 -0
- package/lib/logger/index.d.ts +135 -0
- package/lib/logger/index.js +476 -0
- package/lib/menuManager/hooks.d.ts +17 -0
- package/lib/menuManager/hooks.js +135 -0
- package/lib/menuManager/index.d.ts +28 -0
- package/lib/menuManager/index.js +125 -0
- package/lib/models/global.d.ts +32 -0
- package/lib/models/global.js +62 -0
- package/lib/models/index.d.ts +45 -0
- package/lib/models/index.js +69 -0
- package/lib/models/type.d.ts +2 -0
- package/lib/models/type.js +17 -0
- package/lib/plugin/index.d.ts +0 -0
- package/lib/plugin/index.js +0 -0
- package/lib/pubsub/example.d.ts +5 -0
- package/lib/pubsub/example.js +61 -0
- package/lib/pubsub/index.d.ts +73 -0
- package/lib/pubsub/index.js +141 -0
- package/lib/render/index.d.ts +0 -0
- package/lib/render/index.js +0 -0
- package/lib/request/cache.d.ts +46 -0
- package/lib/request/cache.js +195 -0
- package/lib/request/cancelToken.d.ts +38 -0
- package/lib/request/cancelToken.js +59 -0
- package/lib/request/config.d.ts +3 -0
- package/lib/request/config.js +69 -0
- package/lib/request/constants.d.ts +2 -0
- package/lib/request/constants.js +34 -0
- package/lib/request/index.d.ts +24 -0
- package/lib/request/index.js +210 -0
- package/lib/request/pisell2Request.d.ts +6 -0
- package/lib/request/pisell2Request.js +75 -0
- package/lib/request/type.d.ts +57 -0
- package/lib/request/type.js +36 -0
- package/lib/request/utils.d.ts +46 -0
- package/lib/request/utils.js +113 -0
- package/lib/routes/config.d.ts +7 -0
- package/lib/routes/config.js +50 -0
- package/lib/routes/index.d.ts +28 -0
- package/lib/routes/index.js +121 -0
- package/lib/socket/components/SocketMonitorPage.d.ts +6 -0
- package/lib/socket/components/SocketMonitorPage.js +340 -0
- package/lib/socket/components/index.d.ts +2 -0
- package/lib/socket/components/index.js +39 -0
- package/lib/socket/constants.d.ts +33 -0
- package/lib/socket/constants.js +62 -0
- package/lib/socket/events.d.ts +31 -0
- package/lib/socket/events.js +44 -0
- package/lib/socket/heartbeat.d.ts +66 -0
- package/lib/socket/heartbeat.js +157 -0
- package/lib/socket/index.d.ts +61 -0
- package/lib/socket/index.js +198 -0
- package/lib/socket/monitor.d.ts +169 -0
- package/lib/socket/monitor.js +350 -0
- package/lib/socket/reconnect.d.ts +61 -0
- package/lib/socket/reconnect.js +157 -0
- package/lib/socket/socket.d.ts +130 -0
- package/lib/socket/socket.js +426 -0
- package/lib/socket/types.d.ts +85 -0
- package/lib/socket/types.js +36 -0
- package/lib/storage/index.d.ts +17 -0
- package/lib/storage/index.js +64 -0
- package/lib/tasks/index.d.ts +127 -0
- package/lib/tasks/index.js +710 -0
- package/lib/tasks/scheduledTasksExample.d.ts +61 -0
- package/lib/tasks/scheduledTasksExample.js +267 -0
- package/lib/tasks/type.d.ts +100 -0
- package/lib/tasks/type.js +17 -0
- package/lib/tasks/useTasks.d.ts +5 -0
- package/lib/tasks/useTasks.js +37 -0
- package/lib/type.d.ts +2 -0
- package/lib/type.js +17 -0
- package/lib/utils/adaptiveThrottle/index.d.ts +36 -0
- package/lib/utils/adaptiveThrottle/index.js +121 -0
- package/lib/variables/VariablesProvider.d.ts +7 -0
- package/lib/variables/VariablesProvider.js +51 -0
- package/lib/variables/config.d.ts +3 -0
- package/lib/variables/config.js +38 -0
- package/lib/variables/index.d.ts +6 -0
- package/lib/variables/index.js +29 -0
- package/lib/variables/type.d.ts +2 -0
- package/lib/variables/type.js +17 -0
- package/lib/website/index.d.ts +6 -0
- package/lib/website/index.js +75 -0
- package/package.json +49 -0
package/lib/app/index.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/app/index.tsx
|
|
30
|
+
var app_exports = {};
|
|
31
|
+
__export(app_exports, {
|
|
32
|
+
AppProvider: () => AppProvider,
|
|
33
|
+
default: () => app_default,
|
|
34
|
+
getApp: () => getApp,
|
|
35
|
+
useApp: () => useApp
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(app_exports);
|
|
38
|
+
var import_react = __toESM(require("react"));
|
|
39
|
+
var import_app = __toESM(require("./app"));
|
|
40
|
+
var AppContext = (0, import_react.createContext)(void 0);
|
|
41
|
+
var AppProvider = ({ children, options }) => {
|
|
42
|
+
const [globalData, setGlobalData] = (0, import_react.useState)({});
|
|
43
|
+
const app = (0, import_react.useRef)(import_app.default.getInstance(options));
|
|
44
|
+
(0, import_react.useEffect)(() => {
|
|
45
|
+
app.current.install();
|
|
46
|
+
return () => {
|
|
47
|
+
app.current.unInstall();
|
|
48
|
+
};
|
|
49
|
+
}, []);
|
|
50
|
+
const _setGlobalData = (data) => {
|
|
51
|
+
setGlobalData((prev) => ({ ...prev, ...data }));
|
|
52
|
+
app.current.setGlobalData(data);
|
|
53
|
+
};
|
|
54
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
55
|
+
AppContext.Provider,
|
|
56
|
+
{
|
|
57
|
+
value: { globalData, setGlobalData: _setGlobalData, app: app.current }
|
|
58
|
+
},
|
|
59
|
+
children
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
var useApp = () => {
|
|
63
|
+
const context = (0, import_react.useContext)(AppContext);
|
|
64
|
+
if (!context) {
|
|
65
|
+
throw new Error();
|
|
66
|
+
}
|
|
67
|
+
return context;
|
|
68
|
+
};
|
|
69
|
+
var getApp = import_app.default.getInstance;
|
|
70
|
+
var app_default = import_app.default;
|
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
+
0 && (module.exports = {
|
|
73
|
+
AppProvider,
|
|
74
|
+
getApp,
|
|
75
|
+
useApp
|
|
76
|
+
});
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import App from '../app';
|
|
2
|
+
import { LoadLibraryByUrlParams } from '../locales/type';
|
|
3
|
+
import { MenuItem } from '../menuManager/index';
|
|
4
|
+
/**
|
|
5
|
+
* 应用接口类型定义
|
|
6
|
+
* @description 描述应用中单个页面、组件或功能的接口结构
|
|
7
|
+
*/
|
|
8
|
+
export declare type ApplicationInterface = {
|
|
9
|
+
page_type: 'low_code' | 'code';
|
|
10
|
+
page_id: number | string;
|
|
11
|
+
page_code: string;
|
|
12
|
+
page_version?: string;
|
|
13
|
+
page_name: string;
|
|
14
|
+
router: string;
|
|
15
|
+
category: 'page' | 'component' | 'function';
|
|
16
|
+
Component?: any;
|
|
17
|
+
children?: any;
|
|
18
|
+
layout?: string;
|
|
19
|
+
originalUrl?: string;
|
|
20
|
+
routeConfig?: {
|
|
21
|
+
cache?: boolean;
|
|
22
|
+
preload?: boolean;
|
|
23
|
+
prerender?: boolean;
|
|
24
|
+
priority?: 'high' | 'normal' | 'low';
|
|
25
|
+
};
|
|
26
|
+
autoRender?: boolean;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* 应用数据类型定义
|
|
30
|
+
* @description 描述完整应用的数据结构,包含应用的基本信息、接口、功能等
|
|
31
|
+
*/
|
|
32
|
+
export declare type ApplicationData = {
|
|
33
|
+
/** 应用唯一标识 */
|
|
34
|
+
app_id: number;
|
|
35
|
+
/** 应用名称 */
|
|
36
|
+
app_name: string;
|
|
37
|
+
/** 应用类型:系统应用或自定义应用 */
|
|
38
|
+
app_type: 'system' | 'custom';
|
|
39
|
+
/** 应用包含的接口列表 */
|
|
40
|
+
interfaces: ApplicationInterface[];
|
|
41
|
+
/** 应用包含的功能列表,可选 */
|
|
42
|
+
functions?: any[];
|
|
43
|
+
/** 应用的菜单配置 */
|
|
44
|
+
menu?: {
|
|
45
|
+
[key: string]: MenuItem[];
|
|
46
|
+
};
|
|
47
|
+
/** 多语言配置,可选 */
|
|
48
|
+
locales?: LoadLibraryByUrlParams;
|
|
49
|
+
/** 其他扩展属性 */
|
|
50
|
+
[key: string]: any;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* 应用管理类
|
|
54
|
+
* @description 负责管理单个应用的生命周期,包括接口、组件、功能的初始化和管理
|
|
55
|
+
* @class Application
|
|
56
|
+
* @author zhiwei.Wang
|
|
57
|
+
*/
|
|
58
|
+
export declare class Application {
|
|
59
|
+
/** 应用配置数据 */
|
|
60
|
+
options: ApplicationData;
|
|
61
|
+
/** 应用名称 */
|
|
62
|
+
name: ApplicationData['app_name'];
|
|
63
|
+
/** 应用内的页面接口映射表,以页面名称为键 */
|
|
64
|
+
interfaces: Map<ApplicationInterface['page_name'], ApplicationInterface>;
|
|
65
|
+
/** 应用内的组件映射表,以组件编码为键 */
|
|
66
|
+
components: Map<string, any>;
|
|
67
|
+
/** 应用内的功能函数映射表,比如跳转登录页面的方法等 */
|
|
68
|
+
functions: Map<string, any>;
|
|
69
|
+
/** 应用实例引用 */
|
|
70
|
+
app: App;
|
|
71
|
+
/**
|
|
72
|
+
* 构造函数
|
|
73
|
+
* @description 初始化应用实例,设置基本属性并初始化接口和功能
|
|
74
|
+
* @param {ApplicationData} options - 应用配置数据
|
|
75
|
+
* @param {App} app - 应用实例引用
|
|
76
|
+
*/
|
|
77
|
+
constructor(options: ApplicationData, app: App);
|
|
78
|
+
/**
|
|
79
|
+
* 应用添加后的内部处理方法
|
|
80
|
+
* @description 在应用被添加到应用管理器后执行的内部逻辑,包括加载多语言配置和执行用户自定义的afterAdd方法
|
|
81
|
+
* @param {Application} application - 被添加的应用实例
|
|
82
|
+
* @returns {Promise<void>}
|
|
83
|
+
* @private
|
|
84
|
+
*/
|
|
85
|
+
_afterAdd(application: Application): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* 应用加载前的内部处理方法
|
|
88
|
+
* @description 在应用开始加载前执行的内部逻辑,调用用户自定义的beforeLoad方法
|
|
89
|
+
* @returns {Promise<void>}
|
|
90
|
+
* @private
|
|
91
|
+
*/
|
|
92
|
+
_beforeLoad(): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* 应用加载的内部处理方法
|
|
95
|
+
* @description 执行应用的实际加载逻辑,将应用中的所有接口注册为路由
|
|
96
|
+
* @returns {Promise<void>}
|
|
97
|
+
* @private
|
|
98
|
+
*/
|
|
99
|
+
_load(): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* 初始化应用接口
|
|
102
|
+
* @description 遍历应用配置中的接口列表,根据类别将它们分别设置到对应的映射表中
|
|
103
|
+
* @param {ApplicationData['interfaces']} interfaces - 接口配置数组
|
|
104
|
+
* @returns {void}
|
|
105
|
+
*/
|
|
106
|
+
initInterfaces(interfaces: ApplicationData['interfaces']): void;
|
|
107
|
+
/**
|
|
108
|
+
* 初始化应用功能函数
|
|
109
|
+
* @description 遍历应用配置中的功能列表,将它们设置到功能映射表中
|
|
110
|
+
* @param {ApplicationData['functions']} functions - 功能配置数组,可选
|
|
111
|
+
* @returns {void}
|
|
112
|
+
*/
|
|
113
|
+
initFunctions(functions: ApplicationData['functions']): void;
|
|
114
|
+
/**
|
|
115
|
+
* 加载接口组件
|
|
116
|
+
* @description 根据接口类型加载对应的组件,支持低代码和普通代码两种类型
|
|
117
|
+
* @param {ApplicationInterface} interfaceItem - 接口配置项
|
|
118
|
+
* @returns {Promise<ApplicationInterface>} 加载后的接口配置
|
|
119
|
+
*/
|
|
120
|
+
loadInterface(interfaceItem: ApplicationInterface): Promise<ApplicationInterface>;
|
|
121
|
+
/**
|
|
122
|
+
* 设置页面
|
|
123
|
+
* @description 将页面接口添加到接口映射表中
|
|
124
|
+
* @param {string} code - 页面编码
|
|
125
|
+
* @param {ApplicationInterface} interfaceItem - 接口配置项
|
|
126
|
+
* @returns {void}
|
|
127
|
+
*/
|
|
128
|
+
setInterface(code: string, interfaceItem: ApplicationInterface): void;
|
|
129
|
+
/**
|
|
130
|
+
* 设置组件
|
|
131
|
+
* @description 将组件添加到组件映射表中
|
|
132
|
+
* @param {string} code - 组件编码
|
|
133
|
+
* @param {ApplicationInterface} component - 组件配置项
|
|
134
|
+
* @returns {void}
|
|
135
|
+
*/
|
|
136
|
+
setComponent(code: string, component: ApplicationInterface): void;
|
|
137
|
+
/**
|
|
138
|
+
* 设置功能函数
|
|
139
|
+
* @description 将功能函数添加到功能映射表中
|
|
140
|
+
* @param {string} code - 功能编码
|
|
141
|
+
* @param {ApplicationInterface} functionItem - 功能配置项
|
|
142
|
+
* @returns {void}
|
|
143
|
+
*/
|
|
144
|
+
setFunction(code: string, functionItem: ApplicationInterface): void;
|
|
145
|
+
/**
|
|
146
|
+
* 获取页面
|
|
147
|
+
* @description 根据编码从接口映射表中获取页面接口
|
|
148
|
+
* @param {string} code - 页面编码
|
|
149
|
+
* @returns {ApplicationInterface | undefined} 接口配置项或undefined
|
|
150
|
+
*/
|
|
151
|
+
getInterface(code: string): ApplicationInterface | undefined;
|
|
152
|
+
/**
|
|
153
|
+
* 获取组件
|
|
154
|
+
* @description 根据编码从组件映射表中获取组件
|
|
155
|
+
* @param {string} code - 组件编码
|
|
156
|
+
* @returns {any | undefined} 组件或undefined
|
|
157
|
+
*/
|
|
158
|
+
getComponent(code: string): any;
|
|
159
|
+
/**
|
|
160
|
+
* 获取功能函数
|
|
161
|
+
* @description 根据编码从功能映射表中获取功能函数
|
|
162
|
+
* @param {string} code - 功能编码
|
|
163
|
+
* @returns {any | undefined} 功能函数或undefined
|
|
164
|
+
*/
|
|
165
|
+
getFunction(code: string): any;
|
|
166
|
+
/**
|
|
167
|
+
* 执行功能函数
|
|
168
|
+
* @description 根据编码执行对应的功能函数,自动注入应用实例并合并参数
|
|
169
|
+
* @param {string} code - 功能编码
|
|
170
|
+
* @param {any} params - 传递给功能函数的参数对象,可选
|
|
171
|
+
* @param {...any} args - 传递给功能函数的其他参数
|
|
172
|
+
* @returns {any} 功能函数的执行结果
|
|
173
|
+
*/
|
|
174
|
+
runFunction(code: string, params?: any, ...args: any): any;
|
|
175
|
+
/**
|
|
176
|
+
* 应用添加后触发的钩子函数
|
|
177
|
+
* @description 在应用被添加到应用管理器后触发,可被子类覆盖以实现自定义逻辑
|
|
178
|
+
* @param {Application} application - 被添加的应用实例
|
|
179
|
+
* @returns {Promise<void>}
|
|
180
|
+
* @author zhiwei.Wang
|
|
181
|
+
*/
|
|
182
|
+
afterAdd(application: Application): Promise<void>;
|
|
183
|
+
/**
|
|
184
|
+
* 应用加载前触发的钩子函数
|
|
185
|
+
* @description 在应用开始加载前触发,可被子类覆盖以实现自定义预处理逻辑
|
|
186
|
+
* @returns {Promise<void>}
|
|
187
|
+
* @author zhiwei.Wang
|
|
188
|
+
*/
|
|
189
|
+
beforeLoad(application: Application): Promise<void>;
|
|
190
|
+
/**
|
|
191
|
+
* 应用加载完成后触发的钩子函数
|
|
192
|
+
* @description 在应用完成加载后触发,可被子类覆盖以实现自定义后处理逻辑
|
|
193
|
+
* @returns {Promise<void>}
|
|
194
|
+
* @author zhiwei.Wang
|
|
195
|
+
*/
|
|
196
|
+
load(application: Application): Promise<void>;
|
|
197
|
+
}
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/applicationManager/application.tsx
|
|
30
|
+
var application_exports = {};
|
|
31
|
+
__export(application_exports, {
|
|
32
|
+
Application: () => Application
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(application_exports);
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var Application = class {
|
|
37
|
+
/** 应用配置数据 */
|
|
38
|
+
options;
|
|
39
|
+
/** 应用名称 */
|
|
40
|
+
name;
|
|
41
|
+
/** 应用内的页面接口映射表,以页面名称为键 */
|
|
42
|
+
interfaces = /* @__PURE__ */ new Map();
|
|
43
|
+
/** 应用内的组件映射表,以组件编码为键 */
|
|
44
|
+
components = /* @__PURE__ */ new Map();
|
|
45
|
+
/** 应用内的功能函数映射表,比如跳转登录页面的方法等 */
|
|
46
|
+
functions = /* @__PURE__ */ new Map();
|
|
47
|
+
/** 应用实例引用 */
|
|
48
|
+
app;
|
|
49
|
+
/**
|
|
50
|
+
* 构造函数
|
|
51
|
+
* @description 初始化应用实例,设置基本属性并初始化接口和功能
|
|
52
|
+
* @param {ApplicationData} options - 应用配置数据
|
|
53
|
+
* @param {App} app - 应用实例引用
|
|
54
|
+
*/
|
|
55
|
+
constructor(options, app) {
|
|
56
|
+
this.options = options;
|
|
57
|
+
this.name = options.app_name;
|
|
58
|
+
this.app = app;
|
|
59
|
+
this.initInterfaces(options.interfaces);
|
|
60
|
+
this.initFunctions(options.functions);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* 应用添加后的内部处理方法
|
|
64
|
+
* @description 在应用被添加到应用管理器后执行的内部逻辑,包括加载多语言配置和执行用户自定义的afterAdd方法
|
|
65
|
+
* @param {Application} application - 被添加的应用实例
|
|
66
|
+
* @returns {Promise<void>}
|
|
67
|
+
* @private
|
|
68
|
+
*/
|
|
69
|
+
async _afterAdd(application) {
|
|
70
|
+
if (application.options.locales) {
|
|
71
|
+
this.app.locales.loadLibraryByUrl(application.options.locales);
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
await this.afterAdd(this);
|
|
75
|
+
} catch (err) {
|
|
76
|
+
console.log(err);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* 应用加载前的内部处理方法
|
|
81
|
+
* @description 在应用开始加载前执行的内部逻辑,调用用户自定义的beforeLoad方法
|
|
82
|
+
* @returns {Promise<void>}
|
|
83
|
+
* @private
|
|
84
|
+
*/
|
|
85
|
+
async _beforeLoad() {
|
|
86
|
+
try {
|
|
87
|
+
await this.beforeLoad(this);
|
|
88
|
+
} catch (err) {
|
|
89
|
+
console.log(err);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* 应用加载的内部处理方法
|
|
94
|
+
* @description 执行应用的实际加载逻辑,将应用中的所有接口注册为路由
|
|
95
|
+
* @returns {Promise<void>}
|
|
96
|
+
* @private
|
|
97
|
+
*/
|
|
98
|
+
async _load() {
|
|
99
|
+
try {
|
|
100
|
+
this.interfaces.forEach((item, key) => {
|
|
101
|
+
if (((item == null ? void 0 : item.router) || "").indexOf("/native/") === -1) {
|
|
102
|
+
this.app.router.add((item == null ? void 0 : item.router) || "", item);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
await this.load(this);
|
|
106
|
+
} catch (err) {
|
|
107
|
+
console.log(err);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* 初始化应用接口
|
|
112
|
+
* @description 遍历应用配置中的接口列表,根据类别将它们分别设置到对应的映射表中
|
|
113
|
+
* @param {ApplicationData['interfaces']} interfaces - 接口配置数组
|
|
114
|
+
* @returns {void}
|
|
115
|
+
*/
|
|
116
|
+
initInterfaces(interfaces) {
|
|
117
|
+
interfaces.forEach(async (interfaceItem) => {
|
|
118
|
+
let _interface = await this.loadInterface(interfaceItem);
|
|
119
|
+
if (interfaceItem.category === "page") {
|
|
120
|
+
this.setInterface(interfaceItem.page_code, _interface);
|
|
121
|
+
}
|
|
122
|
+
if (interfaceItem.category === "component") {
|
|
123
|
+
this.setComponent(interfaceItem.page_code, _interface);
|
|
124
|
+
}
|
|
125
|
+
if (interfaceItem.category === "function") {
|
|
126
|
+
this.setFunction(interfaceItem.page_code, _interface);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* 初始化应用功能函数
|
|
132
|
+
* @description 遍历应用配置中的功能列表,将它们设置到功能映射表中
|
|
133
|
+
* @param {ApplicationData['functions']} functions - 功能配置数组,可选
|
|
134
|
+
* @returns {void}
|
|
135
|
+
*/
|
|
136
|
+
initFunctions(functions) {
|
|
137
|
+
(functions || []).forEach(async (functionItem) => {
|
|
138
|
+
this.setFunction(functionItem.function_code, functionItem);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* 加载接口组件
|
|
143
|
+
* @description 根据接口类型加载对应的组件,支持低代码和普通代码两种类型
|
|
144
|
+
* @param {ApplicationInterface} interfaceItem - 接口配置项
|
|
145
|
+
* @returns {Promise<ApplicationInterface>} 加载后的接口配置
|
|
146
|
+
*/
|
|
147
|
+
async loadInterface(interfaceItem) {
|
|
148
|
+
if (interfaceItem.Component) {
|
|
149
|
+
return interfaceItem;
|
|
150
|
+
}
|
|
151
|
+
if (interfaceItem.page_type === "low_code") {
|
|
152
|
+
}
|
|
153
|
+
if (interfaceItem.page_type === "code") {
|
|
154
|
+
}
|
|
155
|
+
return interfaceItem;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* 设置页面
|
|
159
|
+
* @description 将页面接口添加到接口映射表中
|
|
160
|
+
* @param {string} code - 页面编码
|
|
161
|
+
* @param {ApplicationInterface} interfaceItem - 接口配置项
|
|
162
|
+
* @returns {void}
|
|
163
|
+
*/
|
|
164
|
+
setInterface(code, interfaceItem) {
|
|
165
|
+
this.interfaces.set(code, interfaceItem);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* 设置组件
|
|
169
|
+
* @description 将组件添加到组件映射表中
|
|
170
|
+
* @param {string} code - 组件编码
|
|
171
|
+
* @param {ApplicationInterface} component - 组件配置项
|
|
172
|
+
* @returns {void}
|
|
173
|
+
*/
|
|
174
|
+
setComponent(code, component) {
|
|
175
|
+
const Component = (props) => {
|
|
176
|
+
const ref = (0, import_react.useRef)();
|
|
177
|
+
const Com = component == null ? void 0 : component.Component;
|
|
178
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
179
|
+
Com,
|
|
180
|
+
{
|
|
181
|
+
...props,
|
|
182
|
+
ref: (_ref) => {
|
|
183
|
+
ref.current = _ref;
|
|
184
|
+
console.log("组件ref执行了");
|
|
185
|
+
this.components.set(code, {
|
|
186
|
+
...this.getComponent(code),
|
|
187
|
+
ref: ref.current
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
);
|
|
192
|
+
};
|
|
193
|
+
this.components.set(code, {
|
|
194
|
+
...component,
|
|
195
|
+
Component: component.autoRender ? Component : component.Component
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* 设置功能函数
|
|
200
|
+
* @description 将功能函数添加到功能映射表中
|
|
201
|
+
* @param {string} code - 功能编码
|
|
202
|
+
* @param {ApplicationInterface} functionItem - 功能配置项
|
|
203
|
+
* @returns {void}
|
|
204
|
+
*/
|
|
205
|
+
setFunction(code, functionItem) {
|
|
206
|
+
this.functions.set(code, functionItem);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* 获取页面
|
|
210
|
+
* @description 根据编码从接口映射表中获取页面接口
|
|
211
|
+
* @param {string} code - 页面编码
|
|
212
|
+
* @returns {ApplicationInterface | undefined} 接口配置项或undefined
|
|
213
|
+
*/
|
|
214
|
+
getInterface(code) {
|
|
215
|
+
return this.interfaces.get(code);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* 获取组件
|
|
219
|
+
* @description 根据编码从组件映射表中获取组件
|
|
220
|
+
* @param {string} code - 组件编码
|
|
221
|
+
* @returns {any | undefined} 组件或undefined
|
|
222
|
+
*/
|
|
223
|
+
getComponent(code) {
|
|
224
|
+
return this.components.get(code);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* 获取功能函数
|
|
228
|
+
* @description 根据编码从功能映射表中获取功能函数
|
|
229
|
+
* @param {string} code - 功能编码
|
|
230
|
+
* @returns {any | undefined} 功能函数或undefined
|
|
231
|
+
*/
|
|
232
|
+
getFunction(code) {
|
|
233
|
+
return this.functions.get(code);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* 执行功能函数
|
|
237
|
+
* @description 根据编码执行对应的功能函数,自动注入应用实例并合并参数
|
|
238
|
+
* @param {string} code - 功能编码
|
|
239
|
+
* @param {any} params - 传递给功能函数的参数对象,可选
|
|
240
|
+
* @param {...any} args - 传递给功能函数的其他参数
|
|
241
|
+
* @returns {any} 功能函数的执行结果
|
|
242
|
+
*/
|
|
243
|
+
runFunction(code, params, ...args) {
|
|
244
|
+
var _a;
|
|
245
|
+
const _params = {
|
|
246
|
+
app: this.app,
|
|
247
|
+
...params
|
|
248
|
+
};
|
|
249
|
+
return (_a = this.getFunction(code)) == null ? void 0 : _a.code(_params, ...args);
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* 应用添加后触发的钩子函数
|
|
253
|
+
* @description 在应用被添加到应用管理器后触发,可被子类覆盖以实现自定义逻辑
|
|
254
|
+
* @param {Application} application - 被添加的应用实例
|
|
255
|
+
* @returns {Promise<void>}
|
|
256
|
+
* @author zhiwei.Wang
|
|
257
|
+
*/
|
|
258
|
+
async afterAdd(application) {
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* 应用加载前触发的钩子函数
|
|
262
|
+
* @description 在应用开始加载前触发,可被子类覆盖以实现自定义预处理逻辑
|
|
263
|
+
* @returns {Promise<void>}
|
|
264
|
+
* @author zhiwei.Wang
|
|
265
|
+
*/
|
|
266
|
+
async beforeLoad(application) {
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* 应用加载完成后触发的钩子函数
|
|
270
|
+
* @description 在应用完成加载后触发,可被子类覆盖以实现自定义后处理逻辑
|
|
271
|
+
* @returns {Promise<void>}
|
|
272
|
+
* @author zhiwei.Wang
|
|
273
|
+
*/
|
|
274
|
+
async load(application) {
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
278
|
+
0 && (module.exports = {
|
|
279
|
+
Application
|
|
280
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import APP from '../app';
|
|
2
|
+
import { Application, ApplicationData } from './application';
|
|
3
|
+
export * from "./application";
|
|
4
|
+
export declare class ApplicationManager {
|
|
5
|
+
applicationList: Application[];
|
|
6
|
+
protected app: APP;
|
|
7
|
+
applications: Map<string, Application>;
|
|
8
|
+
constructor(applicationList: Application[], app: APP);
|
|
9
|
+
init(applicationList: Application[] | ApplicationData[]): Promise<unknown>;
|
|
10
|
+
add(application: Application): Promise<void>;
|
|
11
|
+
get(appName: Application['name']): Application | undefined;
|
|
12
|
+
remove(appName: Application['name']): void;
|
|
13
|
+
load(): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* 循环所有的应用, 找出所有的components进行渲染
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
getAllComponents(): any[];
|
|
19
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/applicationManager/index.tsx
|
|
21
|
+
var applicationManager_exports = {};
|
|
22
|
+
__export(applicationManager_exports, {
|
|
23
|
+
ApplicationManager: () => ApplicationManager
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(applicationManager_exports);
|
|
26
|
+
var import_application = require("./application");
|
|
27
|
+
__reExport(applicationManager_exports, require("./application"), module.exports);
|
|
28
|
+
var ApplicationManager = class {
|
|
29
|
+
constructor(applicationList = [], app) {
|
|
30
|
+
this.applicationList = applicationList;
|
|
31
|
+
this.app = app;
|
|
32
|
+
this.app = app;
|
|
33
|
+
if (applicationList == null ? void 0 : applicationList.length) {
|
|
34
|
+
this.init(applicationList);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
applications = /* @__PURE__ */ new Map();
|
|
38
|
+
async init(applicationList) {
|
|
39
|
+
return new Promise(async (res, req) => {
|
|
40
|
+
applicationList.forEach(
|
|
41
|
+
async (application) => {
|
|
42
|
+
if (typeof application === "object") {
|
|
43
|
+
application = new import_application.Application(
|
|
44
|
+
application,
|
|
45
|
+
this.app
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
await this.add(application);
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
await this.load();
|
|
52
|
+
res(true);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
async add(application) {
|
|
56
|
+
this.applications.set(application.name, application);
|
|
57
|
+
await application._afterAdd(application);
|
|
58
|
+
}
|
|
59
|
+
get(appName) {
|
|
60
|
+
let application = this.applications.get(appName);
|
|
61
|
+
return application;
|
|
62
|
+
}
|
|
63
|
+
remove(appName) {
|
|
64
|
+
this.applications.delete(appName);
|
|
65
|
+
}
|
|
66
|
+
async load() {
|
|
67
|
+
for (const application of this.applications.values()) {
|
|
68
|
+
await application._beforeLoad();
|
|
69
|
+
}
|
|
70
|
+
for (const application of this.applications.values()) {
|
|
71
|
+
await application._load();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 循环所有的应用, 找出所有的components进行渲染
|
|
76
|
+
* @returns
|
|
77
|
+
*/
|
|
78
|
+
getAllComponents() {
|
|
79
|
+
return Array.from(this.applications.values()).flatMap(
|
|
80
|
+
(application) => Array.from(application.components.values())
|
|
81
|
+
).filter((component) => component.autoRender).map((component) => component.Component);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
85
|
+
0 && (module.exports = {
|
|
86
|
+
ApplicationManager,
|
|
87
|
+
...require("./application")
|
|
88
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { S3ClientConfig, PutObjectCommandInput } from '@aws-sdk/client-s3';
|
|
2
|
+
import App from '../app';
|
|
3
|
+
export interface AWSOptions extends S3ClientConfig {
|
|
4
|
+
s3Config: S3ClientConfig;
|
|
5
|
+
bucketName?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface UploadParams extends PutObjectCommandInput {
|
|
8
|
+
}
|
|
9
|
+
declare class AWS {
|
|
10
|
+
private s3Client?;
|
|
11
|
+
private app;
|
|
12
|
+
private config?;
|
|
13
|
+
constructor(app: App, options?: AWSOptions);
|
|
14
|
+
upload(params: UploadParams): Promise<import("@aws-sdk/client-s3").PutObjectCommandOutput | undefined>;
|
|
15
|
+
}
|
|
16
|
+
export default AWS;
|