@pisell/core 1.0.0 → 1.0.1
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/es/app/app.d.ts +122 -0
- package/es/app/app.js +166 -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 +54 -0
- package/es/applicationManager/application.d.ts +50 -0
- package/es/applicationManager/application.js +226 -0
- package/es/applicationManager/index.d.ts +13 -0
- package/es/applicationManager/index.js +190 -0
- package/es/config.d.ts +3 -3
- 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 +29 -0
- package/es/data/index.js +8 -0
- package/es/history/config.d.ts +24 -0
- package/es/history/config.js +43 -0
- package/es/history/index.d.ts +20 -0
- package/es/history/index.js +41 -0
- package/es/history/type.d.ts +2 -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 +7 -1
- package/es/index.js +8 -2
- package/es/indexDB/index.d.ts +176 -0
- package/es/indexDB/index.js +536 -0
- package/es/locales/config.js +10 -8
- package/es/locales/en.d.ts +2 -1
- package/es/locales/en.js +5 -1
- package/es/locales/index.d.ts +44 -1
- package/es/locales/index.js +192 -8
- package/es/locales/original.d.ts +3 -0
- package/es/locales/original.js +7 -0
- package/es/locales/type.d.ts +15 -5
- package/es/locales/zh-CN.d.ts +2 -1
- package/es/locales/zh-CN.js +5 -1
- package/es/locales/zh-HK.d.ts +2 -1
- package/es/locales/zh-HK.js +5 -1
- package/es/logger/feishu.d.ts +11 -0
- package/es/logger/feishu.js +50 -0
- package/es/logger/index.d.ts +122 -0
- package/es/logger/index.js +531 -0
- package/es/menuManager/hooks.d.ts +8 -0
- package/es/menuManager/hooks.js +138 -0
- package/es/menuManager/index.d.ts +28 -0
- package/es/menuManager/index.js +142 -0
- package/es/models/global.d.ts +32 -0
- package/es/models/global.js +65 -0
- package/es/models/index.d.ts +45 -0
- package/es/models/index.js +66 -0
- package/es/models/tasks.d.ts +31 -0
- package/es/models/tasks.js +331 -0
- package/es/models/tasksUtils.d.ts +65 -0
- package/es/models/tasksUtils.js +179 -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 +63 -0
- package/es/pubsub/index.js +144 -0
- package/es/request/cache.d.ts +46 -0
- package/es/request/cache.js +310 -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 +58 -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 +175 -0
- package/es/request/pisell2Request.d.ts +6 -0
- package/es/request/pisell2Request.js +62 -0
- package/es/request/type.d.ts +40 -0
- package/es/request/type.js +1 -0
- package/es/request/utils.d.ts +46 -0
- package/es/request/utils.js +145 -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 +154 -0
- package/es/socket/components/SocketMonitorPage.d.ts +6 -0
- package/es/socket/components/SocketMonitorPage.js +692 -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 +185 -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 +438 -0
- package/es/socket/reconnect.d.ts +61 -0
- package/es/socket/reconnect.js +199 -0
- package/es/socket/socket.d.ts +129 -0
- package/es/socket/socket.js +597 -0
- package/es/socket/types.d.ts +84 -0
- package/es/socket/types.js +19 -0
- package/es/storage/config.d.ts +3 -0
- package/es/{date → storage}/config.js +1 -6
- package/es/storage/index.d.ts +42 -0
- package/es/storage/index.js +62 -0
- package/es/storage/type.d.ts +5 -0
- package/es/storage/type.js +1 -0
- package/es/tasks/index.d.ts +77 -0
- package/es/tasks/index.js +719 -0
- package/es/tasks/type.d.ts +62 -0
- package/es/tasks/type.js +1 -0
- package/es/tasks/useTasks.d.ts +4 -0
- package/es/tasks/useTasks.js +25 -0
- package/es/type.d.ts +1 -1
- package/es/variables/VariablesProvider.d.ts +7 -0
- package/es/variables/VariablesProvider.js +14 -0
- package/es/variables/config.d.ts +3 -0
- package/es/{date/index.js → variables/config.js} +8 -14
- 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 +122 -0
- package/lib/app/app.js +128 -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 +50 -0
- package/lib/applicationManager/application.js +110 -0
- package/lib/applicationManager/index.d.ts +13 -0
- package/lib/applicationManager/index.js +76 -0
- package/lib/config.d.ts +3 -3
- package/lib/cookie/index.d.ts +13 -0
- package/lib/cookie/index.js +64 -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 +29 -0
- package/lib/{date → data}/index.js +19 -20
- package/lib/history/config.d.ts +24 -0
- package/lib/history/config.js +41 -0
- package/lib/history/index.d.ts +20 -0
- package/lib/history/index.js +58 -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 +7 -1
- package/lib/index.js +23 -5
- package/lib/indexDB/index.d.ts +176 -0
- package/lib/indexDB/index.js +287 -0
- package/lib/locales/config.js +10 -7
- package/lib/locales/en.d.ts +2 -1
- package/lib/locales/en.js +5 -1
- package/lib/locales/index.d.ts +44 -1
- package/lib/locales/index.js +106 -4
- package/lib/locales/original.d.ts +3 -0
- package/lib/locales/original.js +31 -0
- package/lib/locales/type.d.ts +15 -5
- package/lib/locales/zh-CN.d.ts +2 -1
- package/lib/locales/zh-CN.js +5 -1
- package/lib/locales/zh-HK.d.ts +2 -1
- package/lib/locales/zh-HK.js +5 -1
- package/lib/logger/feishu.d.ts +11 -0
- package/lib/logger/feishu.js +52 -0
- package/lib/logger/index.d.ts +122 -0
- package/lib/logger/index.js +288 -0
- package/lib/menuManager/hooks.d.ts +8 -0
- package/lib/menuManager/hooks.js +135 -0
- package/lib/menuManager/index.d.ts +28 -0
- package/lib/menuManager/index.js +110 -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 +70 -0
- package/lib/models/tasks.d.ts +31 -0
- package/lib/models/tasks.js +199 -0
- package/lib/models/tasksUtils.d.ts +65 -0
- package/lib/models/tasksUtils.js +160 -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 +63 -0
- package/lib/pubsub/index.js +129 -0
- package/lib/request/cache.d.ts +46 -0
- package/lib/request/cache.js +159 -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 +74 -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 +143 -0
- package/lib/request/pisell2Request.d.ts +6 -0
- package/lib/request/pisell2Request.js +75 -0
- package/lib/request/type.d.ts +40 -0
- package/lib/request/type.js +17 -0
- package/lib/request/utils.d.ts +46 -0
- package/lib/request/utils.js +111 -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 +118 -0
- package/lib/socket/components/SocketMonitorPage.d.ts +6 -0
- package/lib/socket/components/SocketMonitorPage.js +346 -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 +152 -0
- package/lib/socket/index.d.ts +61 -0
- package/lib/socket/index.js +200 -0
- package/lib/socket/monitor.d.ts +169 -0
- package/lib/socket/monitor.js +346 -0
- package/lib/socket/reconnect.d.ts +61 -0
- package/lib/socket/reconnect.js +153 -0
- package/lib/socket/socket.d.ts +129 -0
- package/lib/socket/socket.js +410 -0
- package/lib/socket/types.d.ts +84 -0
- package/lib/socket/types.js +36 -0
- package/lib/storage/config.d.ts +3 -0
- package/lib/{date → storage}/config.js +2 -7
- package/lib/storage/index.d.ts +42 -0
- package/lib/storage/index.js +66 -0
- package/lib/storage/type.d.ts +5 -0
- package/lib/storage/type.js +17 -0
- package/lib/tasks/index.d.ts +77 -0
- package/lib/tasks/index.js +438 -0
- package/lib/tasks/type.d.ts +62 -0
- package/lib/{date → tasks}/type.js +1 -1
- package/lib/tasks/useTasks.d.ts +4 -0
- package/lib/tasks/useTasks.js +37 -0
- package/lib/type.d.ts +1 -1
- 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 +13 -3
- package/es/date/config.d.ts +0 -3
- package/es/date/index.d.ts +0 -7
- package/es/date/type.d.ts +0 -7
- package/lib/date/config.d.ts +0 -3
- package/lib/date/index.d.ts +0 -7
- package/lib/date/type.d.ts +0 -7
- /package/es/{date → history}/type.js +0 -0
package/es/app/app.d.ts
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { RouterManager } from '../routes';
|
|
2
|
+
import { ApplicationManager } from '../applicationManager';
|
|
3
|
+
import { History, HistoryOptions } from '../history';
|
|
4
|
+
import { MenuManager } from '../menuManager';
|
|
5
|
+
import LoggerManager, { LoggerOptions } from '../logger';
|
|
6
|
+
import { TasksManager } from '../tasks';
|
|
7
|
+
import IndexDBManager, { DBOptions } from '../indexDB';
|
|
8
|
+
declare global {
|
|
9
|
+
interface Window {
|
|
10
|
+
app: App;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export interface AppOptions {
|
|
14
|
+
logger?: LoggerOptions;
|
|
15
|
+
db?: DBOptions;
|
|
16
|
+
constants?: any;
|
|
17
|
+
history?: HistoryOptions;
|
|
18
|
+
}
|
|
19
|
+
declare class App {
|
|
20
|
+
private static instance;
|
|
21
|
+
private plugins;
|
|
22
|
+
globalData: any;
|
|
23
|
+
router: RouterManager;
|
|
24
|
+
applicationManager: ApplicationManager;
|
|
25
|
+
history: History;
|
|
26
|
+
data: {
|
|
27
|
+
store: {
|
|
28
|
+
getStore: () => import("../models").Store;
|
|
29
|
+
StoreProvider: typeof import("react-redux").Provider;
|
|
30
|
+
setConfig: (models: any[]) => void;
|
|
31
|
+
};
|
|
32
|
+
storage: {
|
|
33
|
+
setStorage: (key: string, value: string) => void;
|
|
34
|
+
getStorage: (key: string) => string | null;
|
|
35
|
+
removeStorage: (key: string) => void;
|
|
36
|
+
createKey: (key: string) => string;
|
|
37
|
+
setConfig: (newConfig: Partial<import("../storage/type").StorageConfig>) => void;
|
|
38
|
+
getConfig: () => import("../storage/type").StorageConfig;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
hooks: import("../hooks").HooksExport;
|
|
42
|
+
locales: {
|
|
43
|
+
getLocale: () => string;
|
|
44
|
+
getCurrentTexts: (locale?: string | undefined) => {
|
|
45
|
+
[key: string]: string;
|
|
46
|
+
};
|
|
47
|
+
setLocale: (locale: string, reload?: boolean) => void;
|
|
48
|
+
getText: (id: string, locale?: string | undefined) => string;
|
|
49
|
+
isCN: () => boolean;
|
|
50
|
+
getConfig: () => import("../locales/type").LocaleConfig;
|
|
51
|
+
setConfig: (newConfig: Partial<import("../locales/type").LocaleConfig>) => import("../locales/type").LocaleConfig;
|
|
52
|
+
loadLibraryByUrl: (urls: import("../locales/type").LoadLibraryByUrlParams) => Promise<{
|
|
53
|
+
[x: string]: import("../locales/type").LibraryItem;
|
|
54
|
+
}>;
|
|
55
|
+
translation: (text: string | {
|
|
56
|
+
[key: string]: string;
|
|
57
|
+
}, locale?: string | undefined) => string | number;
|
|
58
|
+
loadLibraryByItems: (libraryList: import("../locales/type").LibraryItem[]) => void;
|
|
59
|
+
getLibraryByData: (data: import("../locales/type").LibraryItem[]) => {};
|
|
60
|
+
createTextsByLibrary: (id: string, library?: {
|
|
61
|
+
[x: string]: import("../locales/type").LibraryItem;
|
|
62
|
+
} | undefined) => {
|
|
63
|
+
[x: string]: string;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
models: {
|
|
67
|
+
getStore: () => import("../models").Store;
|
|
68
|
+
StoreProvider: typeof import("react-redux").Provider;
|
|
69
|
+
setConfig: (models: any[]) => void;
|
|
70
|
+
};
|
|
71
|
+
request: {
|
|
72
|
+
get: (url: string, data: any, config: import("../request").RequestSetting | undefined) => Promise<any>;
|
|
73
|
+
post: (url: string, data: any, config: import("../request").RequestSetting | undefined) => Promise<any>;
|
|
74
|
+
put: (url: string, data: any, config: import("../request").RequestSetting | undefined) => Promise<any>;
|
|
75
|
+
remove: (url: string, data: any, config: import("../request").RequestSetting | undefined) => Promise<any>;
|
|
76
|
+
custom: (url: string, config: import("../request").RequestSetting | undefined) => Promise<any>;
|
|
77
|
+
setConfig: (newConfig: Partial<import("../request").RequestConfig>) => void;
|
|
78
|
+
getConfig: () => import("../request").RequestConfig;
|
|
79
|
+
};
|
|
80
|
+
storage: {
|
|
81
|
+
setStorage: (key: string, value: string) => void;
|
|
82
|
+
getStorage: (key: string) => string | null;
|
|
83
|
+
removeStorage: (key: string) => void;
|
|
84
|
+
createKey: (key: string) => string;
|
|
85
|
+
setConfig: (newConfig: Partial<import("../storage/type").StorageConfig>) => void;
|
|
86
|
+
getConfig: () => import("../storage/type").StorageConfig;
|
|
87
|
+
};
|
|
88
|
+
menuManager: MenuManager;
|
|
89
|
+
cookie: {
|
|
90
|
+
setCookie: (name: string, value: string, domain?: string | undefined) => void;
|
|
91
|
+
getCookie: (name: string) => string | null;
|
|
92
|
+
deleteCookie: (name: string, domain?: string | undefined) => void;
|
|
93
|
+
checkCookie: (name: string) => boolean;
|
|
94
|
+
updateCookie: (name: string, value: string, domain?: string | undefined) => void;
|
|
95
|
+
};
|
|
96
|
+
website: {
|
|
97
|
+
setTitle: (title: string) => void;
|
|
98
|
+
setIcon: (paramsIcon: string) => void;
|
|
99
|
+
setAppleWebAppTitle: (title: string) => void;
|
|
100
|
+
};
|
|
101
|
+
logger: LoggerManager;
|
|
102
|
+
pubsub: import("../pubsub").PubSub;
|
|
103
|
+
tasksManager: TasksManager;
|
|
104
|
+
dbManager: IndexDBManager | null;
|
|
105
|
+
constants: {
|
|
106
|
+
channel: string;
|
|
107
|
+
[key: string]: string;
|
|
108
|
+
};
|
|
109
|
+
private constructor();
|
|
110
|
+
static getInstance(options?: AppOptions): App;
|
|
111
|
+
setGlobalData(globalData: any): void;
|
|
112
|
+
usePlugin(name: string, plugin: any): void;
|
|
113
|
+
usePlugins(plugins: {
|
|
114
|
+
name: string;
|
|
115
|
+
plugin: any;
|
|
116
|
+
}[]): void;
|
|
117
|
+
getPlugin(name: string): any;
|
|
118
|
+
getGlobalData(): any;
|
|
119
|
+
install(): void;
|
|
120
|
+
unInstall(): void;
|
|
121
|
+
}
|
|
122
|
+
export default App;
|
package/es/app/app.js
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
5
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
6
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
7
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
9
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
10
|
+
import { RouterManager } from "../routes";
|
|
11
|
+
import { ApplicationManager } from "../applicationManager";
|
|
12
|
+
import { History } from "../history";
|
|
13
|
+
import data from "../data";
|
|
14
|
+
import hooks from "../hooks";
|
|
15
|
+
import locales from "../locales";
|
|
16
|
+
import models from "../models";
|
|
17
|
+
import request from "../request";
|
|
18
|
+
import storage from "../storage";
|
|
19
|
+
import { MenuManager } from "../menuManager";
|
|
20
|
+
import cookie from "../cookie";
|
|
21
|
+
import website from "../website";
|
|
22
|
+
import LoggerManager from "../logger";
|
|
23
|
+
import { TasksManager } from "../tasks";
|
|
24
|
+
import IndexDBManager from "../indexDB";
|
|
25
|
+
import pubsub from "../pubsub";
|
|
26
|
+
import { APPEvent } from "./const";
|
|
27
|
+
var App = /*#__PURE__*/function () {
|
|
28
|
+
// 实例
|
|
29
|
+
|
|
30
|
+
// 插件管理
|
|
31
|
+
|
|
32
|
+
// 全局数据
|
|
33
|
+
|
|
34
|
+
// 路由管理
|
|
35
|
+
|
|
36
|
+
// 应用管理
|
|
37
|
+
|
|
38
|
+
// History
|
|
39
|
+
|
|
40
|
+
// 数据存储
|
|
41
|
+
|
|
42
|
+
// hooks
|
|
43
|
+
|
|
44
|
+
// 多语言
|
|
45
|
+
|
|
46
|
+
// dva
|
|
47
|
+
|
|
48
|
+
// 请求
|
|
49
|
+
|
|
50
|
+
// 存储
|
|
51
|
+
|
|
52
|
+
// 菜单管理
|
|
53
|
+
|
|
54
|
+
// cookie
|
|
55
|
+
|
|
56
|
+
// 网站信息
|
|
57
|
+
|
|
58
|
+
// 日志
|
|
59
|
+
|
|
60
|
+
// 发布订阅
|
|
61
|
+
|
|
62
|
+
// 任务管理
|
|
63
|
+
|
|
64
|
+
function App(options) {
|
|
65
|
+
_classCallCheck(this, App);
|
|
66
|
+
_defineProperty(this, "plugins", void 0);
|
|
67
|
+
_defineProperty(this, "globalData", void 0);
|
|
68
|
+
_defineProperty(this, "router", void 0);
|
|
69
|
+
_defineProperty(this, "applicationManager", void 0);
|
|
70
|
+
_defineProperty(this, "history", void 0);
|
|
71
|
+
_defineProperty(this, "data", data);
|
|
72
|
+
_defineProperty(this, "hooks", hooks);
|
|
73
|
+
_defineProperty(this, "locales", locales);
|
|
74
|
+
_defineProperty(this, "models", models);
|
|
75
|
+
_defineProperty(this, "request", request);
|
|
76
|
+
_defineProperty(this, "storage", storage);
|
|
77
|
+
_defineProperty(this, "menuManager", void 0);
|
|
78
|
+
_defineProperty(this, "cookie", cookie);
|
|
79
|
+
_defineProperty(this, "website", website);
|
|
80
|
+
_defineProperty(this, "logger", void 0);
|
|
81
|
+
_defineProperty(this, "pubsub", pubsub);
|
|
82
|
+
_defineProperty(this, "tasksManager", void 0);
|
|
83
|
+
_defineProperty(this, "dbManager", null);
|
|
84
|
+
_defineProperty(this, "constants", {
|
|
85
|
+
channel: ""
|
|
86
|
+
});
|
|
87
|
+
this.plugins = new Map();
|
|
88
|
+
this.globalData = {};
|
|
89
|
+
this.router = new RouterManager({}, this);
|
|
90
|
+
this.menuManager = new MenuManager([], this);
|
|
91
|
+
this.applicationManager = new ApplicationManager([], this);
|
|
92
|
+
this.history = new History(this, options === null || options === void 0 ? void 0 : options.history);
|
|
93
|
+
if (options !== null && options !== void 0 && options.db) {
|
|
94
|
+
this.dbManager = new IndexDBManager(options === null || options === void 0 ? void 0 : options.db);
|
|
95
|
+
}
|
|
96
|
+
this.logger = new LoggerManager(this, options === null || options === void 0 ? void 0 : options.logger);
|
|
97
|
+
this.tasksManager = new TasksManager(this);
|
|
98
|
+
if (options !== null && options !== void 0 && options.constants) {
|
|
99
|
+
this.constants = options.constants || {};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// 单例模式
|
|
104
|
+
_createClass(App, [{
|
|
105
|
+
key: "setGlobalData",
|
|
106
|
+
value:
|
|
107
|
+
// 初始化配置
|
|
108
|
+
function setGlobalData(globalData) {
|
|
109
|
+
this.globalData = _objectSpread(_objectSpread({}, this.globalData), globalData);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// 注册插件
|
|
113
|
+
}, {
|
|
114
|
+
key: "usePlugin",
|
|
115
|
+
value: function usePlugin(name, plugin) {
|
|
116
|
+
this.plugins.set(name, plugin);
|
|
117
|
+
}
|
|
118
|
+
// 注册插件列表
|
|
119
|
+
}, {
|
|
120
|
+
key: "usePlugins",
|
|
121
|
+
value: function usePlugins(plugins) {
|
|
122
|
+
var _this = this;
|
|
123
|
+
plugins.forEach(function (_ref) {
|
|
124
|
+
var name = _ref.name,
|
|
125
|
+
plugin = _ref.plugin;
|
|
126
|
+
_this.plugins.set(name, plugin);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// 获取应用
|
|
131
|
+
}, {
|
|
132
|
+
key: "getPlugin",
|
|
133
|
+
value: function getPlugin(name) {
|
|
134
|
+
return this.plugins.get(name);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// 获取配置
|
|
138
|
+
}, {
|
|
139
|
+
key: "getGlobalData",
|
|
140
|
+
value: function getGlobalData() {
|
|
141
|
+
return this.globalData;
|
|
142
|
+
}
|
|
143
|
+
}, {
|
|
144
|
+
key: "install",
|
|
145
|
+
value: function install() {
|
|
146
|
+
this.pubsub.publish(APPEvent.APP_INSTALL, this);
|
|
147
|
+
}
|
|
148
|
+
}, {
|
|
149
|
+
key: "unInstall",
|
|
150
|
+
value: function unInstall() {
|
|
151
|
+
this.pubsub.publish(APPEvent.APP_UNINSTALL, this);
|
|
152
|
+
}
|
|
153
|
+
}], [{
|
|
154
|
+
key: "getInstance",
|
|
155
|
+
value: function getInstance(options) {
|
|
156
|
+
if (!App.instance) {
|
|
157
|
+
App.instance = new App(options);
|
|
158
|
+
window.app = App.instance;
|
|
159
|
+
}
|
|
160
|
+
return App.instance;
|
|
161
|
+
}
|
|
162
|
+
}]);
|
|
163
|
+
return App;
|
|
164
|
+
}();
|
|
165
|
+
_defineProperty(App, "instance", void 0);
|
|
166
|
+
export default App;
|
package/es/app/const.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import App, { AppOptions } from "./app";
|
|
3
|
+
declare type AppContextType = {
|
|
4
|
+
globalData: any;
|
|
5
|
+
setGlobalData: React.Dispatch<React.SetStateAction<any>>;
|
|
6
|
+
app: App;
|
|
7
|
+
};
|
|
8
|
+
export declare const AppProvider: React.FC<{
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
options: AppOptions;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const useApp: () => AppContextType;
|
|
13
|
+
export declare const getApp: typeof App.getInstance;
|
|
14
|
+
export default App;
|
package/es/app/index.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
import React, { createContext, useContext, useEffect, useRef, useState } from "react";
|
|
14
|
+
import App from "./app";
|
|
15
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
+
var AppContext = /*#__PURE__*/createContext(undefined);
|
|
17
|
+
export var AppProvider = function AppProvider(_ref) {
|
|
18
|
+
var children = _ref.children,
|
|
19
|
+
options = _ref.options;
|
|
20
|
+
var _useState = useState({}),
|
|
21
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
22
|
+
globalData = _useState2[0],
|
|
23
|
+
setGlobalData = _useState2[1];
|
|
24
|
+
var app = useRef(App.getInstance(options));
|
|
25
|
+
useEffect(function () {
|
|
26
|
+
app.current.install();
|
|
27
|
+
return function () {
|
|
28
|
+
app.current.unInstall();
|
|
29
|
+
};
|
|
30
|
+
}, []);
|
|
31
|
+
var _setGlobalData = function _setGlobalData(data) {
|
|
32
|
+
setGlobalData(function (prev) {
|
|
33
|
+
return _objectSpread(_objectSpread({}, prev), data);
|
|
34
|
+
});
|
|
35
|
+
app.current.setGlobalData(data);
|
|
36
|
+
};
|
|
37
|
+
return /*#__PURE__*/_jsx(AppContext.Provider, {
|
|
38
|
+
value: {
|
|
39
|
+
globalData: globalData,
|
|
40
|
+
setGlobalData: _setGlobalData,
|
|
41
|
+
app: app.current
|
|
42
|
+
},
|
|
43
|
+
children: children
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
export var useApp = function useApp() {
|
|
47
|
+
var context = useContext(AppContext);
|
|
48
|
+
if (!context) {
|
|
49
|
+
throw new Error();
|
|
50
|
+
}
|
|
51
|
+
return context;
|
|
52
|
+
};
|
|
53
|
+
export var getApp = App.getInstance;
|
|
54
|
+
export default App;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import App from "../app";
|
|
2
|
+
import { LoadLibraryByUrlParams } from "../locales/type";
|
|
3
|
+
import { MenuItem } from "../menuManager/index";
|
|
4
|
+
export declare type ApplicationInterface = {
|
|
5
|
+
page_type: "low_code" | "code";
|
|
6
|
+
page_id: number | string;
|
|
7
|
+
page_code: string;
|
|
8
|
+
page_version?: string;
|
|
9
|
+
page_name: string;
|
|
10
|
+
router: string;
|
|
11
|
+
category: "page" | "component" | "function";
|
|
12
|
+
Component?: any;
|
|
13
|
+
children?: any;
|
|
14
|
+
layout?: string;
|
|
15
|
+
originalUrl?: string;
|
|
16
|
+
};
|
|
17
|
+
export declare type ApplicationData = {
|
|
18
|
+
app_id: number;
|
|
19
|
+
app_name: string;
|
|
20
|
+
app_type: "system" | "custom";
|
|
21
|
+
interfaces: ApplicationInterface[];
|
|
22
|
+
functions?: any[];
|
|
23
|
+
menu?: {
|
|
24
|
+
[key: string]: MenuItem[];
|
|
25
|
+
};
|
|
26
|
+
locales?: LoadLibraryByUrlParams;
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
};
|
|
29
|
+
export declare class Application {
|
|
30
|
+
options: ApplicationData;
|
|
31
|
+
name: ApplicationData["app_name"];
|
|
32
|
+
interfaces: Map<ApplicationInterface["page_name"], ApplicationInterface>;
|
|
33
|
+
components: Map<string, any>;
|
|
34
|
+
functions: Map<string, any>;
|
|
35
|
+
app: App;
|
|
36
|
+
constructor(options: ApplicationData, app: App);
|
|
37
|
+
afterAdd(application: Application): Promise<void>;
|
|
38
|
+
beforeLoad(): Promise<void>;
|
|
39
|
+
load(): Promise<void>;
|
|
40
|
+
initInterfaces(interfaces: ApplicationData["interfaces"]): void;
|
|
41
|
+
initFunctions(functions: ApplicationData["functions"]): void;
|
|
42
|
+
loadInterface(interfaceItem: ApplicationInterface): Promise<ApplicationInterface>;
|
|
43
|
+
setInterface(code: string, interfaceItem: ApplicationInterface): void;
|
|
44
|
+
setComponent(code: string, component: ApplicationInterface): void;
|
|
45
|
+
setFunction(code: string, functionItem: ApplicationInterface): void;
|
|
46
|
+
getInterface(code: string): ApplicationInterface | undefined;
|
|
47
|
+
getComponent(code: string): any;
|
|
48
|
+
getFunction(code: string): any;
|
|
49
|
+
runFunction(code: string, params?: any, ...args: any): any;
|
|
50
|
+
}
|