@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
@@ -0,0 +1,80 @@
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 _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); } }
3
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5
+ 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; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ 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); }
8
+ import { createBrowserHistory } from "history";
9
+ import { useHistory, useLocation, useParams } from "react-router-dom";
10
+ export var History = /*#__PURE__*/_createClass(function History(app, options) {
11
+ var _this = this;
12
+ _classCallCheck(this, History);
13
+ _defineProperty(this, "instance", void 0);
14
+ _defineProperty(this, "useHistory", useHistory);
15
+ _defineProperty(this, "useLocation", useLocation);
16
+ _defineProperty(this, "useParams", useParams);
17
+ _defineProperty(this, "app", void 0);
18
+ _defineProperty(this, "interceptor", void 0);
19
+ _defineProperty(this, "push", function (path, state) {
20
+ if (_this.interceptor) {
21
+ return _this.interceptor(path, state, function () {
22
+ _this.instance.push(path, state);
23
+ });
24
+ }
25
+ _this.instance.push(path, state);
26
+ });
27
+ _defineProperty(this, "replace", function (path, state) {
28
+ if (_this.interceptor) {
29
+ return _this.interceptor(path, state, function () {
30
+ _this.instance.replace(path, state);
31
+ });
32
+ }
33
+ _this.instance.replace(path, state);
34
+ });
35
+ _defineProperty(this, "reload", function () {
36
+ window.location.reload();
37
+ });
38
+ _defineProperty(this, "reloadTo", function (path) {
39
+ if (_this.interceptor) {
40
+ return _this.interceptor(path, {}, function () {
41
+ window.location.href = path;
42
+ });
43
+ }
44
+ window.location.href = path;
45
+ });
46
+ _defineProperty(this, "externalPage", function (path) {
47
+ if (_this.interceptor) {
48
+ return _this.interceptor(path, {}, function () {
49
+ window.open(path);
50
+ });
51
+ }
52
+ window.open(path);
53
+ });
54
+ _defineProperty(this, "goLogin", function () {
55
+ var _this$app$application, _this$app$application2;
56
+ return (_this$app$application = _this.app.applicationManager.get("login")) === null || _this$app$application === void 0 || (_this$app$application2 = _this$app$application.runFunction) === null || _this$app$application2 === void 0 ? void 0 : _this$app$application2.call(_this$app$application, "goLogin");
57
+ });
58
+ _defineProperty(this, "getQuery", function () {
59
+ try {
60
+ var search = _this.instance.location.search;
61
+ var params = new URLSearchParams(search);
62
+ var obj = Object.fromEntries(params.entries());
63
+ return obj;
64
+ } catch (err) {
65
+ _this.app.logger.addLog({
66
+ type: "error",
67
+ title: "获取query参数失败",
68
+ metadata: {
69
+ data: err
70
+ }
71
+ });
72
+ }
73
+ return {};
74
+ });
75
+ this.app = app;
76
+ this.instance = createBrowserHistory({
77
+ basename: (options === null || options === void 0 ? void 0 : options.basename) || "/"
78
+ });
79
+ this.interceptor = options === null || options === void 0 ? void 0 : options.interceptor;
80
+ });
@@ -0,0 +1,2 @@
1
+ export interface HistoryConfig {
2
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ import useLowCode from './useLowCode';
2
+ import useDelayedValue from './useDelayedValue';
3
+ import useStore from './useStore';
4
+ import useDispatch from './useDispatch';
5
+ export interface HooksExport {
6
+ useLowCode: typeof useLowCode;
7
+ useDelayedValue: typeof useDelayedValue;
8
+ useStore: typeof useStore;
9
+ useDispatch: typeof useDispatch;
10
+ }
11
+ declare const _default: HooksExport;
12
+ export default _default;
@@ -0,0 +1,13 @@
1
+ import useLowCode from "./useLowCode";
2
+ import useDelayedValue from "./useDelayedValue";
3
+ import useStore from "./useStore";
4
+ import useDispatch from "./useDispatch";
5
+ // 定义一个接口来描述导出对象的类型
6
+
7
+ // 添加类型注释
8
+ export default {
9
+ useLowCode: useLowCode,
10
+ useDelayedValue: useDelayedValue,
11
+ useStore: useStore,
12
+ useDispatch: useDispatch
13
+ };
@@ -0,0 +1,2 @@
1
+ declare function useDelayedValue<T>(value: T, timeout?: number): T;
2
+ export default useDelayedValue;
@@ -0,0 +1,26 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ 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."); }
3
+ 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); }
4
+ 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; }
5
+ 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; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import { useState, useEffect } from 'react';
8
+ function useDelayedValue(value) {
9
+ var timeout = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200;
10
+ var _useState = useState(value),
11
+ _useState2 = _slicedToArray(_useState, 2),
12
+ delayedValue = _useState2[0],
13
+ setDelayedValue = _useState2[1];
14
+ useEffect(function () {
15
+ var timer = setTimeout(function () {
16
+ setDelayedValue(value);
17
+ }, timeout);
18
+
19
+ // 清除定时器,避免内存泄漏
20
+ return function () {
21
+ return clearTimeout(timer);
22
+ };
23
+ }, [value, timeout]);
24
+ return delayedValue;
25
+ }
26
+ export default useDelayedValue;
@@ -0,0 +1,2 @@
1
+ import { useDispatch } from "react-redux";
2
+ export default useDispatch;
@@ -0,0 +1,2 @@
1
+ import { useDispatch } from "react-redux";
2
+ export default useDispatch;
@@ -0,0 +1,13 @@
1
+ export interface useLowCodeProps {
2
+ onChange: (e: any) => void;
3
+ onReady: (e: any) => void;
4
+ }
5
+ export interface useLowCodeResult {
6
+ lowcodeRef: {
7
+ onReady: (e: any) => void;
8
+ onChange: (e: any) => void;
9
+ };
10
+ setState: (values: any, callback?: any) => any;
11
+ }
12
+ declare const useLowCode: (props: Partial<useLowCodeProps>) => useLowCodeResult;
13
+ export default useLowCode;
@@ -0,0 +1,74 @@
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
+ import { useRef } from "react";
8
+ var useLowCode = function useLowCode(props) {
9
+ var onChange = props.onChange,
10
+ onReady = props.onReady;
11
+ var lowcodeRef = useRef(null);
12
+ var cacheState = useRef(null);
13
+
14
+ /**
15
+ * @title: lowcode 页面初始化
16
+ * @description:
17
+ * @param {any} e
18
+ * @return {*}
19
+ * @Author: zhiwei.Wang
20
+ * @Date: 2023-12-06 09:40
21
+ */
22
+ var _onReady = function _onReady(e) {
23
+ try {
24
+ // 储存this
25
+ lowcodeRef.current = e;
26
+
27
+ // 返回外部
28
+ var val = onReady && onReady(e);
29
+
30
+ // 如果在初始化前调用了setState, 则在ready之后进行赋值
31
+ if (cacheState.current) {
32
+ _setState(cacheState.current.values, cacheState.current.callback);
33
+ cacheState.current = null;
34
+ }
35
+ return val;
36
+ } catch (err) {
37
+ console.error(err);
38
+ }
39
+ };
40
+ var _onChange = function _onChange(e) {
41
+ onChange && onChange(e);
42
+ };
43
+ var _setState = function _setState(values, callback) {
44
+ try {
45
+ if (lowcodeRef.current) {
46
+ lowcodeRef.current.setState(values, callback);
47
+ return;
48
+ }
49
+
50
+ // 当没有初始化完成时, 需要临时储存state
51
+ if (cacheState.current) {
52
+ cacheState.current = {
53
+ values: _objectSpread(_objectSpread({}, cacheState.current.values), values),
54
+ callback: callback
55
+ };
56
+ } else {
57
+ cacheState.current = {
58
+ values: values,
59
+ callback: callback
60
+ };
61
+ }
62
+ } catch (err) {
63
+ console.error(err);
64
+ }
65
+ };
66
+ return {
67
+ lowcodeRef: {
68
+ onReady: _onReady,
69
+ onChange: _onChange
70
+ },
71
+ setState: _setState
72
+ };
73
+ };
74
+ export default useLowCode;
@@ -0,0 +1,6 @@
1
+ import { ModelsState } from "../../models";
2
+ declare const useStore: <T extends "global", D extends keyof ModelsState[T]>(props: {
3
+ models: T;
4
+ key?: D | undefined;
5
+ }) => D extends undefined ? ModelsState[T] : ModelsState[T][D];
6
+ export default useStore;
@@ -0,0 +1,11 @@
1
+ import { useSelector } from "react-redux";
2
+ var useStore = function useStore(props) {
3
+ var models = useSelector(function (state) {
4
+ return state[props.models];
5
+ });
6
+ if (props.key !== undefined) {
7
+ return models === null || models === void 0 ? void 0 : models[props.key];
8
+ }
9
+ return models;
10
+ };
11
+ export default useStore;
package/es/index.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ export { default as request } from './request';
2
+ export { default as hooks } from './hooks';
3
+ export { default as models } from './models';
4
+ export { default as pubsub } from './pubsub';
5
+ export { default as socket } from './socket';
6
+ export * from './applicationManager';
7
+ export * from './app';
8
+ export * from './communicationManager';
package/es/index.js ADDED
@@ -0,0 +1,10 @@
1
+ // export { default as storage } from './storage';
2
+ export { default as request } from "./request";
3
+ export { default as hooks } from "./hooks";
4
+ // export { default as locales } from './locales';
5
+ export { default as models } from "./models";
6
+ export { default as pubsub } from "./pubsub";
7
+ export { default as socket } from "./socket";
8
+ export * from "./applicationManager";
9
+ export * from "./app";
10
+ export * from "./communicationManager";
@@ -0,0 +1,296 @@
1
+ import App from "../app";
2
+ export declare const mockPromise: (data: any, timeout?: number) => Promise<unknown>;
3
+ /**
4
+ * IndexDB 管理器模块
5
+ *
6
+ * 这个模块使用 Dexie.js 提供了对浏览器 IndexedDB 的简单封装,并在不支持 IndexedDB 的环境中
7
+ * 自动降级使用内存存储作为备选存储方案。
8
+ */
9
+ /**
10
+ * 数据库配置选项接口
11
+ * @interface DBOptions
12
+ * @property {string} dbName - 数据库名称
13
+ * @property {number} version - 数据库版本号
14
+ * @property {Array} stores - 存储对象配置数组
15
+ * @property {string} stores[].name - 存储对象名称
16
+ * @property {string} stores[].keyPath - 主键路径
17
+ * @property {Array} [stores[].indexes] - 索引配置数组(可选)
18
+ * @property {string} stores[].indexes[].name - 索引名称
19
+ * @property {string} stores[].indexes[].keyPath - 索引键路径
20
+ * @property {IDBIndexParameters} [stores[].indexes[].options] - 索引选项(可选)
21
+ */
22
+ export interface DBOptions {
23
+ dbName: string;
24
+ version: number;
25
+ stores: {
26
+ name: string;
27
+ keyPath: string;
28
+ indexes?: {
29
+ name: string;
30
+ keyPath: string;
31
+ options?: IDBIndexParameters;
32
+ }[];
33
+ }[];
34
+ timeout?: number;
35
+ }
36
+ /**
37
+ * IndexDB 管理器类
38
+ * 使用 Dexie.js 提供对 IndexedDB 的封装,支持自动降级到内存存储
39
+ * @class IndexDBManager
40
+ */
41
+ declare class IndexDBManager {
42
+ /**
43
+ * 检查环境是否支持 IndexedDB
44
+ * @returns {boolean} 是否支持 IndexedDB
45
+ * @private
46
+ */
47
+ private static isSupported;
48
+ private db;
49
+ private dbName;
50
+ private version;
51
+ private stores;
52
+ private useIndexDB;
53
+ private app;
54
+ private memoryStorage;
55
+ private timeout;
56
+ private debouncedBuffers;
57
+ private debouncedTimers;
58
+ private debouncedFlushing;
59
+ private debouncedDelay;
60
+ private debouncedBatchSize;
61
+ private debouncedUpdateBuffers;
62
+ private debouncedUpdateTimers;
63
+ private debouncedUpdateFlushing;
64
+ private debouncedUpdateDelay;
65
+ private debouncedUpdateBatchSize;
66
+ /**
67
+ * 创建 IndexDBManager 实例
68
+ * @param {DBOptions} options - 数据库配置选项
69
+ */
70
+ constructor(app: App, options: DBOptions);
71
+ /**
72
+ * 超时包装器 - 为 Promise 添加超时控制
73
+ * @param {Promise<T>} promise - 需要包装的 Promise
74
+ * @param {string} operation - 操作名称(用于错误提示)
75
+ * @returns {Promise<T>} 带超时控制的 Promise
76
+ * @private
77
+ */
78
+ private withTimeout;
79
+ /**
80
+ * 初始化数据库连接
81
+ * 如果环境不支持 IndexedDB,将自动使用内存存储
82
+ * @returns {Promise<boolean>} 连接是否成功
83
+ */
84
+ connect(): Promise<boolean>;
85
+ /**
86
+ * 获取内存存储中指定 store 的 Map
87
+ * @param {string} storeName - 存储对象名称
88
+ * @returns {Map<string | number, any>} 存储 Map
89
+ * @private
90
+ */
91
+ private getMemoryStore;
92
+ /**
93
+ * 防抖合并 add(用于高频写入场景)
94
+ * @param storeName 存储对象名称
95
+ * @param data 数据
96
+ */
97
+ debouncedAdd<T>(storeName: string, data: T): void;
98
+ /**
99
+ * 立即 flush 指定 store 的防抖 add
100
+ */
101
+ flushDebouncedAdd(storeName: string): Promise<void>;
102
+ /**
103
+ * 防抖合并 update(同 key 自动合并)
104
+ */
105
+ debouncedUpdate<T extends Record<string, any>>(storeName: string, data: T): void;
106
+ /**
107
+ * flush 防抖 update
108
+ */
109
+ flushDebouncedUpdate(storeName: string): Promise<void>;
110
+ /**
111
+ * 添加数据到指定的存储对象
112
+ * @param {string} storeName - 存储对象名称
113
+ * @param {T} data - 要添加的数据
114
+ * * @param {boolean} [log=true] - 是否记录日志
115
+ * @returns {Promise<T>} 添加的数据
116
+ * @template T
117
+ */
118
+ add<T>(storeName: string, data: T, log?: boolean): Promise<T>;
119
+ /**
120
+ * 快速检查指定存储对象中的数据是否存在
121
+ * @param {string} storeName - 存储对象名称
122
+ * @param {string|number} key - 数据主键
123
+ * @returns {Promise<boolean>} 数据是否存在
124
+ */
125
+ exists(storeName: string, key: string | number): Promise<boolean>;
126
+ /**
127
+ * 获取指定存储对象中的数据
128
+ * @param {string} storeName - 存储对象名称
129
+ * @param {string|number} key - 数据主键
130
+ * * @param {boolean} [log=true] - 是否记录日志
131
+ * @returns {Promise<T|null>} 获取的数据,不存在则返回 null
132
+ * @template T
133
+ */
134
+ get<T>(storeName: string, key: string | number, log?: boolean): Promise<T | null>;
135
+ /**
136
+ * 更新指定存储对象中的数据
137
+ * @param {string} storeName - 存储对象名称
138
+ * @param {T} data - 要更新的数据
139
+ * * @param {boolean} [log=true] - 是否记录日志
140
+ * @returns {Promise<T>} 更新后的数据
141
+ * @template T
142
+ */
143
+ update<T>(storeName: string, data: T, log?: boolean): Promise<T>;
144
+ /**
145
+ * 删除指定存储对象中的数据
146
+ * @param {string} storeName - 存储对象名称
147
+ * @param {string|number} key - 数据主键
148
+ * @returns {Promise<boolean>} 删除是否成功
149
+ */
150
+ delete(storeName: string, key: string | number): Promise<boolean>;
151
+ /**
152
+ * 通过索引获取数据
153
+ * @param {string} storeName - 存储对象名称
154
+ * @param {string} indexName - 索引名称
155
+ * @param {string|number} indexValue - 索引值
156
+ * @returns {Promise<T|null>} 获取的数据,不存在则返回 null
157
+ * @template T
158
+ */
159
+ getByIndex<T>(storeName: string, indexName: string, indexValue: string | number): Promise<T | null>;
160
+ /**
161
+ * 通过索引检查数据是否存在
162
+ * @param {string} storeName - 存储对象名称
163
+ * @param {string} indexName - 索引名称
164
+ * @param {string|number} indexValue - 索引值
165
+ * @returns {Promise<boolean>} 数据是否存在
166
+ */
167
+ existsByIndex(storeName: string, indexName: string, indexValue: string | number): Promise<boolean>;
168
+ /**
169
+ * 通过索引获取多条数据
170
+ * @param {string} storeName - 存储对象名称
171
+ * @param {string} indexName - 索引名称
172
+ * @param {string|number} indexValue - 索引值
173
+ * @returns {Promise<T[]>} 数据数组
174
+ * @template T
175
+ */
176
+ getAllByIndex<T>(storeName: string, indexName: string, indexValue: string | number): Promise<T[]>;
177
+ /**
178
+ * 统计指定存储对象中的数据数量
179
+ * @param {string} storeName - 存储对象名称
180
+ * @returns {Promise<number>} 数据数量
181
+ */
182
+ count(storeName: string): Promise<number>;
183
+ /**
184
+ * 通过索引统计数据数量
185
+ * @param {string} storeName - 存储对象名称
186
+ * @param {string} indexName - 索引名称
187
+ * @param {string|number} indexValue - 索引值
188
+ * @returns {Promise<number>} 数据数量
189
+ */
190
+ countByIndex(storeName: string, indexName: string, indexValue: string | number): Promise<number>;
191
+ /**
192
+ * 获取指定存储对象中的所有数据
193
+ * @param {string} storeName - 存储对象名称
194
+ * @returns {Promise<T[]>} 数据数组
195
+ * @template T
196
+ */
197
+ getAll<T>(storeName: string): Promise<T[]>;
198
+ /**
199
+ * 清空指定存储对象中的所有数据
200
+ * @param {string} storeName - 存储对象名称
201
+ * @returns {Promise<boolean>} 清空是否成功
202
+ */
203
+ clear(storeName: string): Promise<boolean>;
204
+ /**
205
+ * 关闭数据库连接
206
+ * 在不再需要使用数据库时调用,释放资源
207
+ */
208
+ close(): void;
209
+ /**
210
+ * 获取当前使用的存储方式
211
+ * @returns {'indexDB'|'memory'} 当前使用的存储方式
212
+ */
213
+ getCurrentStorage(): 'indexDB' | 'memory';
214
+ }
215
+ /**
216
+ * 使用示例:
217
+ *
218
+ * // 1. 创建数据库配置
219
+ * const dbOptions: DBOptions = {
220
+ * dbName: 'myApp',
221
+ * version: 1,
222
+ * stores: [
223
+ * {
224
+ * name: 'users',
225
+ * keyPath: 'id',
226
+ * indexes: [
227
+ * { name: 'email', keyPath: 'email', options: { unique: true } },
228
+ * { name: 'department', keyPath: 'department', options: { unique: false } }
229
+ * ]
230
+ * },
231
+ * {
232
+ * name: 'products',
233
+ * keyPath: 'id'
234
+ * }
235
+ * ]
236
+ * };
237
+ *
238
+ * // 2. 创建并连接数据库
239
+ * const db = new IndexDBManager(app, dbOptions);
240
+ * await db.connect();
241
+ *
242
+ * // 3. 添加数据
243
+ * const user = { id: '1', name: '张三', email: 'zhangsan@example.com', department: 'IT' };
244
+ * await db.add('users', user);
245
+ *
246
+ * // 4. 获取数据
247
+ * const retrievedUser = await db.get('users', '1');
248
+ *
249
+ * // 5. 快速检查数据是否存在(推荐用法)
250
+ * const userExists = await db.exists('users', '1'); // 返回 true/false,比 get 更高效
251
+ *
252
+ * // 6. 通过索引获取数据
253
+ * const userByEmail = await db.getByIndex('users', 'email', 'zhangsan@example.com');
254
+ *
255
+ * // 7. 通过索引检查数据是否存在
256
+ * const emailExists = await db.existsByIndex('users', 'email', 'zhangsan@example.com');
257
+ *
258
+ * // 8. 通过索引获取多条数据
259
+ * const itUsers = await db.getAllByIndex('users', 'department', 'IT');
260
+ *
261
+ * // 9. 统计数据数量
262
+ * const totalUsers = await db.count('users');
263
+ * const itUserCount = await db.countByIndex('users', 'department', 'IT');
264
+ *
265
+ * // 10. 更新数据
266
+ * user.name = '张三 (已更新)';
267
+ * await db.update('users', user);
268
+ *
269
+ * // 11. 获取所有数据
270
+ * const allUsers = await db.getAll('users');
271
+ *
272
+ * // 12. 删除数据
273
+ * await db.delete('users', '1');
274
+ *
275
+ * // 13. 清空存储对象
276
+ * await db.clear('users');
277
+ *
278
+ * // 14. 关闭数据库连接
279
+ * db.close();
280
+ *
281
+ * // 15. 检查当前使用的存储方式
282
+ * const storageType = db.getCurrentStorage(); // 'indexDB' 或 'memory'
283
+ *
284
+ * // 性能优化建议:
285
+ * // - 使用 exists() 而不是 get() 来检查数据是否存在
286
+ * // - 为常用查询字段创建索引
287
+ * // - 使用索引查询方法来提高查询效率
288
+ * // - 批量操作时使用事务(可以考虑后续扩展)
289
+ *
290
+ * // 降级方案说明:
291
+ * // - 当浏览器不支持 IndexedDB 时,会自动使用内存存储 (Map) 作为降级方案
292
+ * // - 内存存储的数据在页面刷新后会丢失,仅适合临时数据存储
293
+ * // - 内存存储支持所有 IndexedDB API,包括索引查询
294
+ * // - 对于需要持久化的数据,请确保浏览器支持 IndexedDB
295
+ */
296
+ export default IndexDBManager;