@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.
Files changed (296) hide show
  1. package/README.md +1 -0
  2. package/es/app/app.d.ts +101 -0
  3. package/es/app/app.js +177 -0
  4. package/es/app/const.d.ts +4 -0
  5. package/es/app/const.js +6 -0
  6. package/es/app/index.d.ts +14 -0
  7. package/es/app/index.js +52 -0
  8. package/es/applicationManager/application.d.ts +197 -0
  9. package/es/applicationManager/application.js +469 -0
  10. package/es/applicationManager/index.d.ts +19 -0
  11. package/es/applicationManager/index.js +206 -0
  12. package/es/aws/index.d.ts +16 -0
  13. package/es/aws/index.js +76 -0
  14. package/es/cmd/const.d.ts +11 -0
  15. package/es/cmd/const.js +13 -0
  16. package/es/cmd/index.d.ts +13 -0
  17. package/es/cmd/index.js +91 -0
  18. package/es/cmd/type.d.ts +5 -0
  19. package/es/cmd/type.js +1 -0
  20. package/es/communicationManager/index.d.ts +59 -0
  21. package/es/communicationManager/index.js +174 -0
  22. package/es/config.d.ts +3 -0
  23. package/es/config.js +14 -0
  24. package/es/cookie/index.d.ts +13 -0
  25. package/es/cookie/index.js +47 -0
  26. package/es/css/global.less +73 -0
  27. package/es/css/index.less +31 -0
  28. package/es/css/variables.css +84 -0
  29. package/es/data/index.d.ts +8 -0
  30. package/es/data/index.js +16 -0
  31. package/es/history/config.d.ts +24 -0
  32. package/es/history/config.js +43 -0
  33. package/es/history/index.d.ts +26 -0
  34. package/es/history/index.js +80 -0
  35. package/es/history/type.d.ts +2 -0
  36. package/es/history/type.js +1 -0
  37. package/es/hooks/index.d.ts +12 -0
  38. package/es/hooks/index.js +13 -0
  39. package/es/hooks/useDelayedValue/index.d.ts +2 -0
  40. package/es/hooks/useDelayedValue/index.js +26 -0
  41. package/es/hooks/useDispatch/index.d.ts +2 -0
  42. package/es/hooks/useDispatch/index.js +2 -0
  43. package/es/hooks/useLowCode/index.d.ts +13 -0
  44. package/es/hooks/useLowCode/index.js +74 -0
  45. package/es/hooks/useStore/index.d.ts +6 -0
  46. package/es/hooks/useStore/index.js +11 -0
  47. package/es/index.d.ts +8 -0
  48. package/es/index.js +10 -0
  49. package/es/indexDB/index.d.ts +296 -0
  50. package/es/indexDB/index.js +1619 -0
  51. package/es/locales/en.d.ts +3 -0
  52. package/es/locales/en.js +5 -0
  53. package/es/locales/index.d.ts +39 -0
  54. package/es/locales/index.js +199 -0
  55. package/es/locales/original.d.ts +3 -0
  56. package/es/locales/original.js +7 -0
  57. package/es/locales/type.d.ts +19 -0
  58. package/es/locales/type.js +1 -0
  59. package/es/locales/zh-CN.d.ts +3 -0
  60. package/es/locales/zh-CN.js +5 -0
  61. package/es/locales/zh-HK.d.ts +3 -0
  62. package/es/locales/zh-HK.js +5 -0
  63. package/es/logger/feishu.d.ts +11 -0
  64. package/es/logger/feishu.js +50 -0
  65. package/es/logger/index.d.ts +135 -0
  66. package/es/logger/index.js +870 -0
  67. package/es/menuManager/hooks.d.ts +17 -0
  68. package/es/menuManager/hooks.js +136 -0
  69. package/es/menuManager/index.d.ts +28 -0
  70. package/es/menuManager/index.js +165 -0
  71. package/es/models/global.d.ts +32 -0
  72. package/es/models/global.js +66 -0
  73. package/es/models/index.d.ts +45 -0
  74. package/es/models/index.js +65 -0
  75. package/es/models/type.d.ts +2 -0
  76. package/es/models/type.js +1 -0
  77. package/es/plugin/index.d.ts +0 -0
  78. package/es/plugin/index.js +0 -0
  79. package/es/pubsub/example.d.ts +5 -0
  80. package/es/pubsub/example.js +92 -0
  81. package/es/pubsub/index.d.ts +73 -0
  82. package/es/pubsub/index.js +166 -0
  83. package/es/render/index.d.ts +0 -0
  84. package/es/render/index.js +0 -0
  85. package/es/request/cache.d.ts +46 -0
  86. package/es/request/cache.js +372 -0
  87. package/es/request/cancelToken.d.ts +38 -0
  88. package/es/request/cancelToken.js +59 -0
  89. package/es/request/config.d.ts +3 -0
  90. package/es/request/config.js +63 -0
  91. package/es/request/constants.d.ts +2 -0
  92. package/es/request/constants.js +6 -0
  93. package/es/request/index.d.ts +24 -0
  94. package/es/request/index.js +267 -0
  95. package/es/request/pisell2Request.d.ts +6 -0
  96. package/es/request/pisell2Request.js +62 -0
  97. package/es/request/type.d.ts +57 -0
  98. package/es/request/type.js +10 -0
  99. package/es/request/utils.d.ts +46 -0
  100. package/es/request/utils.js +147 -0
  101. package/es/routes/config.d.ts +7 -0
  102. package/es/routes/config.js +17 -0
  103. package/es/routes/index.d.ts +28 -0
  104. package/es/routes/index.js +151 -0
  105. package/es/socket/components/SocketMonitorPage.d.ts +6 -0
  106. package/es/socket/components/SocketMonitorPage.js +485 -0
  107. package/es/socket/components/index.d.ts +2 -0
  108. package/es/socket/components/index.js +2 -0
  109. package/es/socket/constants.d.ts +33 -0
  110. package/es/socket/constants.js +39 -0
  111. package/es/socket/events.d.ts +31 -0
  112. package/es/socket/events.js +19 -0
  113. package/es/socket/heartbeat.d.ts +66 -0
  114. package/es/socket/heartbeat.js +184 -0
  115. package/es/socket/index.d.ts +61 -0
  116. package/es/socket/index.js +246 -0
  117. package/es/socket/monitor.d.ts +169 -0
  118. package/es/socket/monitor.js +448 -0
  119. package/es/socket/reconnect.d.ts +61 -0
  120. package/es/socket/reconnect.js +199 -0
  121. package/es/socket/socket.d.ts +130 -0
  122. package/es/socket/socket.js +613 -0
  123. package/es/socket/types.d.ts +85 -0
  124. package/es/socket/types.js +35 -0
  125. package/es/storage/index.d.ts +17 -0
  126. package/es/storage/index.js +46 -0
  127. package/es/tasks/index.d.ts +127 -0
  128. package/es/tasks/index.js +1119 -0
  129. package/es/tasks/scheduledTasksExample.d.ts +61 -0
  130. package/es/tasks/scheduledTasksExample.js +351 -0
  131. package/es/tasks/type.d.ts +100 -0
  132. package/es/tasks/type.js +1 -0
  133. package/es/tasks/useTasks.d.ts +5 -0
  134. package/es/tasks/useTasks.js +25 -0
  135. package/es/type.d.ts +2 -0
  136. package/es/type.js +1 -0
  137. package/es/utils/adaptiveThrottle/index.d.ts +36 -0
  138. package/es/utils/adaptiveThrottle/index.js +136 -0
  139. package/es/variables/VariablesProvider.d.ts +7 -0
  140. package/es/variables/VariablesProvider.js +12 -0
  141. package/es/variables/config.d.ts +3 -0
  142. package/es/variables/config.js +16 -0
  143. package/es/variables/index.d.ts +6 -0
  144. package/es/variables/index.js +5 -0
  145. package/es/variables/type.d.ts +2 -0
  146. package/es/variables/type.js +1 -0
  147. package/es/website/index.d.ts +6 -0
  148. package/es/website/index.js +65 -0
  149. package/lib/app/app.d.ts +101 -0
  150. package/lib/app/app.js +171 -0
  151. package/lib/app/const.d.ts +4 -0
  152. package/lib/app/const.js +33 -0
  153. package/lib/app/index.d.ts +14 -0
  154. package/lib/app/index.js +76 -0
  155. package/lib/applicationManager/application.d.ts +197 -0
  156. package/lib/applicationManager/application.js +280 -0
  157. package/lib/applicationManager/index.d.ts +19 -0
  158. package/lib/applicationManager/index.js +88 -0
  159. package/lib/aws/index.d.ts +16 -0
  160. package/lib/aws/index.js +67 -0
  161. package/lib/cmd/const.d.ts +11 -0
  162. package/lib/cmd/const.js +39 -0
  163. package/lib/cmd/index.d.ts +13 -0
  164. package/lib/cmd/index.js +96 -0
  165. package/lib/cmd/type.d.ts +5 -0
  166. package/lib/cmd/type.js +17 -0
  167. package/lib/communicationManager/index.d.ts +59 -0
  168. package/lib/communicationManager/index.js +102 -0
  169. package/lib/config.d.ts +3 -0
  170. package/lib/config.js +36 -0
  171. package/lib/cookie/index.d.ts +13 -0
  172. package/lib/cookie/index.js +62 -0
  173. package/lib/css/global.less +73 -0
  174. package/lib/css/index.less +31 -0
  175. package/lib/css/variables.css +84 -0
  176. package/lib/data/index.d.ts +8 -0
  177. package/lib/data/index.js +38 -0
  178. package/lib/history/config.d.ts +24 -0
  179. package/lib/history/config.js +41 -0
  180. package/lib/history/index.d.ts +26 -0
  181. package/lib/history/index.js +99 -0
  182. package/lib/history/type.d.ts +2 -0
  183. package/lib/history/type.js +17 -0
  184. package/lib/hooks/index.d.ts +12 -0
  185. package/lib/hooks/index.js +44 -0
  186. package/lib/hooks/useDelayedValue/index.d.ts +2 -0
  187. package/lib/hooks/useDelayedValue/index.js +36 -0
  188. package/lib/hooks/useDispatch/index.d.ts +2 -0
  189. package/lib/hooks/useDispatch/index.js +26 -0
  190. package/lib/hooks/useLowCode/index.d.ts +13 -0
  191. package/lib/hooks/useLowCode/index.js +75 -0
  192. package/lib/hooks/useStore/index.d.ts +6 -0
  193. package/lib/hooks/useStore/index.js +33 -0
  194. package/lib/index.d.ts +8 -0
  195. package/lib/index.js +58 -0
  196. package/lib/indexDB/index.d.ts +296 -0
  197. package/lib/indexDB/index.js +767 -0
  198. package/lib/locales/en.d.ts +3 -0
  199. package/lib/locales/en.js +29 -0
  200. package/lib/locales/index.d.ts +39 -0
  201. package/lib/locales/index.js +159 -0
  202. package/lib/locales/original.d.ts +3 -0
  203. package/lib/locales/original.js +31 -0
  204. package/lib/locales/type.d.ts +19 -0
  205. package/lib/locales/type.js +17 -0
  206. package/lib/locales/zh-CN.d.ts +3 -0
  207. package/lib/locales/zh-CN.js +29 -0
  208. package/lib/locales/zh-HK.d.ts +3 -0
  209. package/lib/locales/zh-HK.js +29 -0
  210. package/lib/logger/feishu.d.ts +11 -0
  211. package/lib/logger/feishu.js +52 -0
  212. package/lib/logger/index.d.ts +135 -0
  213. package/lib/logger/index.js +476 -0
  214. package/lib/menuManager/hooks.d.ts +17 -0
  215. package/lib/menuManager/hooks.js +135 -0
  216. package/lib/menuManager/index.d.ts +28 -0
  217. package/lib/menuManager/index.js +125 -0
  218. package/lib/models/global.d.ts +32 -0
  219. package/lib/models/global.js +62 -0
  220. package/lib/models/index.d.ts +45 -0
  221. package/lib/models/index.js +69 -0
  222. package/lib/models/type.d.ts +2 -0
  223. package/lib/models/type.js +17 -0
  224. package/lib/plugin/index.d.ts +0 -0
  225. package/lib/plugin/index.js +0 -0
  226. package/lib/pubsub/example.d.ts +5 -0
  227. package/lib/pubsub/example.js +61 -0
  228. package/lib/pubsub/index.d.ts +73 -0
  229. package/lib/pubsub/index.js +141 -0
  230. package/lib/render/index.d.ts +0 -0
  231. package/lib/render/index.js +0 -0
  232. package/lib/request/cache.d.ts +46 -0
  233. package/lib/request/cache.js +195 -0
  234. package/lib/request/cancelToken.d.ts +38 -0
  235. package/lib/request/cancelToken.js +59 -0
  236. package/lib/request/config.d.ts +3 -0
  237. package/lib/request/config.js +69 -0
  238. package/lib/request/constants.d.ts +2 -0
  239. package/lib/request/constants.js +34 -0
  240. package/lib/request/index.d.ts +24 -0
  241. package/lib/request/index.js +210 -0
  242. package/lib/request/pisell2Request.d.ts +6 -0
  243. package/lib/request/pisell2Request.js +75 -0
  244. package/lib/request/type.d.ts +57 -0
  245. package/lib/request/type.js +36 -0
  246. package/lib/request/utils.d.ts +46 -0
  247. package/lib/request/utils.js +113 -0
  248. package/lib/routes/config.d.ts +7 -0
  249. package/lib/routes/config.js +50 -0
  250. package/lib/routes/index.d.ts +28 -0
  251. package/lib/routes/index.js +121 -0
  252. package/lib/socket/components/SocketMonitorPage.d.ts +6 -0
  253. package/lib/socket/components/SocketMonitorPage.js +340 -0
  254. package/lib/socket/components/index.d.ts +2 -0
  255. package/lib/socket/components/index.js +39 -0
  256. package/lib/socket/constants.d.ts +33 -0
  257. package/lib/socket/constants.js +62 -0
  258. package/lib/socket/events.d.ts +31 -0
  259. package/lib/socket/events.js +44 -0
  260. package/lib/socket/heartbeat.d.ts +66 -0
  261. package/lib/socket/heartbeat.js +157 -0
  262. package/lib/socket/index.d.ts +61 -0
  263. package/lib/socket/index.js +198 -0
  264. package/lib/socket/monitor.d.ts +169 -0
  265. package/lib/socket/monitor.js +350 -0
  266. package/lib/socket/reconnect.d.ts +61 -0
  267. package/lib/socket/reconnect.js +157 -0
  268. package/lib/socket/socket.d.ts +130 -0
  269. package/lib/socket/socket.js +426 -0
  270. package/lib/socket/types.d.ts +85 -0
  271. package/lib/socket/types.js +36 -0
  272. package/lib/storage/index.d.ts +17 -0
  273. package/lib/storage/index.js +64 -0
  274. package/lib/tasks/index.d.ts +127 -0
  275. package/lib/tasks/index.js +710 -0
  276. package/lib/tasks/scheduledTasksExample.d.ts +61 -0
  277. package/lib/tasks/scheduledTasksExample.js +267 -0
  278. package/lib/tasks/type.d.ts +100 -0
  279. package/lib/tasks/type.js +17 -0
  280. package/lib/tasks/useTasks.d.ts +5 -0
  281. package/lib/tasks/useTasks.js +37 -0
  282. package/lib/type.d.ts +2 -0
  283. package/lib/type.js +17 -0
  284. package/lib/utils/adaptiveThrottle/index.d.ts +36 -0
  285. package/lib/utils/adaptiveThrottle/index.js +121 -0
  286. package/lib/variables/VariablesProvider.d.ts +7 -0
  287. package/lib/variables/VariablesProvider.js +51 -0
  288. package/lib/variables/config.d.ts +3 -0
  289. package/lib/variables/config.js +38 -0
  290. package/lib/variables/index.d.ts +6 -0
  291. package/lib/variables/index.js +29 -0
  292. package/lib/variables/type.d.ts +2 -0
  293. package/lib/variables/type.js +17 -0
  294. package/lib/website/index.d.ts +6 -0
  295. package/lib/website/index.js +75 -0
  296. package/package.json +49 -0
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # @pisell/core
@@ -0,0 +1,101 @@
1
+ import { RouterManager } from '../routes';
2
+ import { ApplicationManager } from '../applicationManager';
3
+ import { History, HistoryOptions } from '../history';
4
+ import { Data } from '../data';
5
+ import { Locales, LocalesOptions } from '../locales';
6
+ import { Storage, StorageOptions } from '../storage';
7
+ import { MenuManager } from '../menuManager';
8
+ import LoggerManager, { LoggerOptions } from '../logger';
9
+ import { TasksManager } from '../tasks';
10
+ import IndexDBManager, { DBOptions } from '../indexDB';
11
+ import CMD, { CMDOptions } from "../cmd";
12
+ import AWS, { AWSOptions } from "../aws";
13
+ import CommunicationManager from '../communicationManager';
14
+ declare global {
15
+ interface Window {
16
+ app: App;
17
+ }
18
+ }
19
+ export interface Bootstrap {
20
+ hooks: {
21
+ [key: string]: () => Promise<void>;
22
+ };
23
+ }
24
+ export interface AppOptions {
25
+ logger?: LoggerOptions;
26
+ db?: DBOptions;
27
+ constants?: any;
28
+ history?: HistoryOptions;
29
+ storage?: StorageOptions;
30
+ locales?: LocalesOptions;
31
+ cmd?: CMDOptions;
32
+ aws?: AWSOptions;
33
+ getPisellos?: () => any;
34
+ }
35
+ declare class App {
36
+ private static instance;
37
+ private plugins;
38
+ globalData: any;
39
+ router: RouterManager;
40
+ applicationManager: ApplicationManager;
41
+ history: History;
42
+ data: Data;
43
+ hooks: import("../hooks").HooksExport;
44
+ locales: Locales;
45
+ models: {
46
+ getStore: () => import("../models").Store;
47
+ StoreProvider: typeof import("react-redux").Provider;
48
+ setConfig: (models: any[]) => void;
49
+ };
50
+ request: {
51
+ get: (url: string, data: any, config: import("../request").RequestSetting | undefined) => Promise<any>;
52
+ post: (url: string, data: any, config: import("../request").RequestSetting | undefined) => Promise<any>;
53
+ put: (url: string, data: any, config: import("../request").RequestSetting | undefined) => Promise<any>;
54
+ remove: (url: string, data: any, config: import("../request").RequestSetting | undefined) => Promise<any>;
55
+ custom: (url: string, config: import("../request").RequestSetting | undefined) => any;
56
+ setConfig: (newConfig: Partial<import("../request").RequestConfig>) => void;
57
+ getConfig: () => import("../request").RequestConfig;
58
+ };
59
+ storage: Storage;
60
+ menuManager: MenuManager;
61
+ cookie: {
62
+ setCookie: (name: string, value: string, domain?: string | undefined) => void;
63
+ getCookie: (name: string) => string | null;
64
+ deleteCookie: (name: string, domain?: string | undefined) => void;
65
+ checkCookie: (name: string) => boolean;
66
+ updateCookie: (name: string, value: string, domain?: string | undefined) => void;
67
+ };
68
+ website: {
69
+ setTitle: (title: string) => void;
70
+ setIcon: (paramsIcon: string) => void;
71
+ setAppleWebAppTitle: (title: string) => void;
72
+ };
73
+ logger: LoggerManager;
74
+ pubsub: import("../pubsub").PubSub;
75
+ cmd: CMD;
76
+ aws: AWS;
77
+ tasksManager: TasksManager;
78
+ getPisellos: any;
79
+ bootstrap?: Bootstrap;
80
+ dbManager: IndexDBManager | null;
81
+ constants: {
82
+ channel: string;
83
+ [key: string]: string;
84
+ };
85
+ comm: CommunicationManager;
86
+ private constructor();
87
+ static getInstance(options?: AppOptions): App;
88
+ setGlobalData(globalData: any): void;
89
+ usePlugin(name: string, plugin: any): void;
90
+ usePlugins(plugins: {
91
+ name: string;
92
+ plugin: any;
93
+ }[]): void;
94
+ getPlugin(name: string): any;
95
+ getGlobalData(): any;
96
+ install(): void;
97
+ unInstall(): void;
98
+ setBootstrap(bootstrap: Bootstrap): void;
99
+ getBootstrap(): Bootstrap | undefined;
100
+ }
101
+ export default App;
package/es/app/app.js ADDED
@@ -0,0 +1,177 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
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(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
9
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
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
+ import CMD from "../cmd";
28
+ import AWS from "../aws";
29
+ import CommunicationManager from "../communicationManager";
30
+ var App = /*#__PURE__*/function () {
31
+ function App(options) {
32
+ _classCallCheck(this, App);
33
+ // 插件管理
34
+ _defineProperty(this, "plugins", void 0);
35
+ // 全局数据
36
+ _defineProperty(this, "globalData", void 0);
37
+ // 路由管理
38
+ _defineProperty(this, "router", void 0);
39
+ // 应用管理
40
+ _defineProperty(this, "applicationManager", void 0);
41
+ // History
42
+ _defineProperty(this, "history", void 0);
43
+ // 数据存储
44
+ _defineProperty(this, "data", void 0);
45
+ // hooks
46
+ _defineProperty(this, "hooks", hooks);
47
+ // 多语言
48
+ _defineProperty(this, "locales", void 0);
49
+ // dva
50
+ _defineProperty(this, "models", models);
51
+ // 请求
52
+ _defineProperty(this, "request", request);
53
+ // 存储
54
+ _defineProperty(this, "storage", void 0);
55
+ // 菜单管理
56
+ _defineProperty(this, "menuManager", void 0);
57
+ // cookie
58
+ _defineProperty(this, "cookie", cookie);
59
+ // 网站信息
60
+ _defineProperty(this, "website", website);
61
+ // 日志
62
+ _defineProperty(this, "logger", void 0);
63
+ // 发布订阅
64
+ _defineProperty(this, "pubsub", pubsub);
65
+ // cmd
66
+ _defineProperty(this, "cmd", void 0);
67
+ // aws
68
+ _defineProperty(this, "aws", void 0);
69
+ // 任务管理
70
+ _defineProperty(this, "tasksManager", void 0);
71
+ // getPisellos
72
+ _defineProperty(this, "getPisellos", void 0);
73
+ _defineProperty(this, "bootstrap", void 0);
74
+ _defineProperty(this, "dbManager", null);
75
+ _defineProperty(this, "constants", {
76
+ channel: ""
77
+ });
78
+ // 通信管理
79
+ _defineProperty(this, "comm", void 0);
80
+ this.plugins = new Map();
81
+ this.globalData = {};
82
+ this.router = new RouterManager({}, this);
83
+ this.menuManager = new MenuManager([], this);
84
+ this.applicationManager = new ApplicationManager([], this);
85
+ this.history = new History(this, options === null || options === void 0 ? void 0 : options.history);
86
+ this.storage = new Storage(this, options === null || options === void 0 ? void 0 : options.storage);
87
+ this.data = new Data(this);
88
+ this.locales = new Locales(this, options === null || options === void 0 ? void 0 : options.locales);
89
+ if (options !== null && options !== void 0 && options.db) {
90
+ this.dbManager = new IndexDBManager(this, options === null || options === void 0 ? void 0 : options.db);
91
+ }
92
+ this.logger = new LoggerManager(this, options === null || options === void 0 ? void 0 : options.logger);
93
+ this.tasksManager = new TasksManager(this);
94
+ this.cmd = new CMD(this, options === null || options === void 0 ? void 0 : options.cmd);
95
+ this.aws = new AWS(this, options === null || options === void 0 ? void 0 : options.aws);
96
+ this.getPisellos = options === null || options === void 0 ? void 0 : options.getPisellos;
97
+ if (options !== null && options !== void 0 && options.constants) {
98
+ this.constants = options.constants || {};
99
+ }
100
+ this.comm = new CommunicationManager(this);
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: "setBootstrap",
155
+ value: function setBootstrap(bootstrap) {
156
+ this.bootstrap = bootstrap;
157
+ }
158
+ }, {
159
+ key: "getBootstrap",
160
+ value: function getBootstrap() {
161
+ return this.bootstrap;
162
+ }
163
+ }], [{
164
+ key: "getInstance",
165
+ value: function getInstance(options) {
166
+ if (!App.instance) {
167
+ App.instance = new App(options);
168
+ window.app = App.instance;
169
+ }
170
+ return App.instance;
171
+ }
172
+ }]);
173
+ return App;
174
+ }();
175
+ // 实例
176
+ _defineProperty(App, "instance", void 0);
177
+ export default App;
@@ -0,0 +1,4 @@
1
+ export declare enum APPEvent {
2
+ APP_INSTALL = "app.install",
3
+ APP_UNINSTALL = "app.uninstall"
4
+ }
@@ -0,0 +1,6 @@
1
+ // 定义枚举
2
+ export var APPEvent = /*#__PURE__*/function (APPEvent) {
3
+ APPEvent["APP_INSTALL"] = "app.install";
4
+ APPEvent["APP_UNINSTALL"] = "app.uninstall";
5
+ return APPEvent;
6
+ }({});
@@ -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;
@@ -0,0 +1,52 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
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(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
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(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
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
+ var AppContext = /*#__PURE__*/createContext(undefined);
16
+ export var AppProvider = function AppProvider(_ref) {
17
+ var children = _ref.children,
18
+ options = _ref.options;
19
+ var _useState = useState({}),
20
+ _useState2 = _slicedToArray(_useState, 2),
21
+ globalData = _useState2[0],
22
+ setGlobalData = _useState2[1];
23
+ var app = useRef(App.getInstance(options));
24
+ useEffect(function () {
25
+ app.current.install();
26
+ return function () {
27
+ app.current.unInstall();
28
+ };
29
+ }, []);
30
+ var _setGlobalData = function _setGlobalData(data) {
31
+ setGlobalData(function (prev) {
32
+ return _objectSpread(_objectSpread({}, prev), data);
33
+ });
34
+ app.current.setGlobalData(data);
35
+ };
36
+ return /*#__PURE__*/React.createElement(AppContext.Provider, {
37
+ value: {
38
+ globalData: globalData,
39
+ setGlobalData: _setGlobalData,
40
+ app: app.current
41
+ }
42
+ }, children);
43
+ };
44
+ export var useApp = function useApp() {
45
+ var context = useContext(AppContext);
46
+ if (!context) {
47
+ throw new Error();
48
+ }
49
+ return context;
50
+ };
51
+ export var getApp = App.getInstance;
52
+ export default App;
@@ -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
+ }