@pisell/core 1.0.1 → 1.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 (124) hide show
  1. package/es/app/app.d.ts +15 -54
  2. package/es/app/app.js +33 -48
  3. package/es/app/const.js +3 -3
  4. package/es/app/index.d.ts +1 -1
  5. package/es/app/index.js +9 -11
  6. package/es/applicationManager/application.d.ts +2 -2
  7. package/es/applicationManager/application.js +9 -12
  8. package/es/applicationManager/index.js +4 -4
  9. package/es/config.js +5 -5
  10. package/es/data/index.d.ts +8 -29
  11. package/es/data/index.js +16 -8
  12. package/es/history/config.js +5 -5
  13. package/es/history/index.d.ts +1 -1
  14. package/es/history/index.js +4 -4
  15. package/es/hooks/useDelayedValue/index.js +1 -1
  16. package/es/hooks/useLowCode/index.js +5 -5
  17. package/es/hooks/useStore/index.d.ts +2 -2
  18. package/es/index.d.ts +0 -7
  19. package/es/index.js +8 -7
  20. package/es/indexDB/index.d.ts +3 -1
  21. package/es/indexDB/index.js +28 -22
  22. package/es/locales/index.d.ts +30 -89
  23. package/es/locales/index.js +202 -243
  24. package/es/locales/type.d.ts +3 -3
  25. package/es/logger/feishu.js +2 -2
  26. package/es/logger/index.d.ts +1 -1
  27. package/es/logger/index.js +31 -23
  28. package/es/menuManager/hooks.d.ts +10 -1
  29. package/es/menuManager/hooks.js +4 -6
  30. package/es/menuManager/index.d.ts +1 -1
  31. package/es/menuManager/index.js +3 -3
  32. package/es/models/global.js +8 -7
  33. package/es/models/index.d.ts +6 -6
  34. package/es/models/index.js +1 -2
  35. package/es/pubsub/index.d.ts +1 -1
  36. package/es/pubsub/index.js +3 -3
  37. package/es/request/cache.d.ts +1 -1
  38. package/es/request/cache.js +7 -6
  39. package/es/request/config.js +7 -7
  40. package/es/request/index.js +12 -11
  41. package/es/request/pisell2Request.d.ts +1 -1
  42. package/es/request/pisell2Request.js +5 -5
  43. package/es/request/type.d.ts +1 -0
  44. package/es/request/utils.js +5 -3
  45. package/es/routes/index.d.ts +2 -2
  46. package/es/routes/index.js +11 -17
  47. package/es/socket/components/SocketMonitorPage.js +255 -462
  48. package/es/socket/events.js +3 -3
  49. package/es/socket/heartbeat.js +6 -7
  50. package/es/socket/index.js +7 -7
  51. package/es/socket/monitor.d.ts +1 -1
  52. package/es/socket/monitor.js +24 -15
  53. package/es/socket/reconnect.js +9 -9
  54. package/es/socket/socket.js +11 -13
  55. package/es/socket/types.d.ts +2 -1
  56. package/es/socket/types.js +23 -7
  57. package/es/storage/index.d.ts +17 -42
  58. package/es/storage/index.js +55 -61
  59. package/es/tasks/index.d.ts +1 -1
  60. package/es/tasks/index.js +46 -22
  61. package/es/tasks/type.d.ts +4 -4
  62. package/es/tasks/useTasks.d.ts +2 -1
  63. package/es/tasks/useTasks.js +1 -1
  64. package/es/variables/VariablesProvider.js +3 -5
  65. package/es/variables/config.js +5 -5
  66. package/es/variables/index.d.ts +3 -3
  67. package/lib/app/app.d.ts +15 -54
  68. package/lib/app/app.js +7 -10
  69. package/lib/app/index.d.ts +1 -1
  70. package/lib/applicationManager/application.d.ts +2 -2
  71. package/lib/data/index.d.ts +8 -29
  72. package/lib/data/index.js +8 -22
  73. package/lib/history/index.d.ts +1 -1
  74. package/lib/hooks/useStore/index.d.ts +2 -2
  75. package/lib/index.d.ts +0 -7
  76. package/lib/index.js +0 -37
  77. package/lib/indexDB/index.d.ts +3 -1
  78. package/lib/indexDB/index.js +8 -18
  79. package/lib/locales/index.d.ts +30 -89
  80. package/lib/locales/index.js +111 -124
  81. package/lib/locales/type.d.ts +3 -3
  82. package/lib/logger/index.d.ts +1 -1
  83. package/lib/menuManager/hooks.d.ts +10 -1
  84. package/lib/menuManager/index.d.ts +1 -1
  85. package/lib/models/index.d.ts +6 -6
  86. package/lib/models/index.js +1 -2
  87. package/lib/pubsub/index.d.ts +1 -1
  88. package/lib/request/cache.d.ts +1 -1
  89. package/lib/request/config.js +2 -12
  90. package/lib/request/index.js +5 -1
  91. package/lib/request/pisell2Request.d.ts +1 -1
  92. package/lib/request/type.d.ts +1 -0
  93. package/lib/request/utils.js +2 -0
  94. package/lib/routes/index.d.ts +2 -2
  95. package/lib/socket/monitor.d.ts +1 -1
  96. package/lib/socket/types.d.ts +2 -1
  97. package/lib/storage/index.d.ts +17 -42
  98. package/lib/storage/index.js +35 -38
  99. package/lib/tasks/index.d.ts +1 -1
  100. package/lib/tasks/type.d.ts +4 -4
  101. package/lib/tasks/useTasks.d.ts +2 -1
  102. package/lib/variables/VariablesProvider.js +1 -1
  103. package/lib/variables/index.d.ts +3 -3
  104. package/package.json +11 -4
  105. package/es/locales/config.d.ts +0 -24
  106. package/es/locales/config.js +0 -59
  107. package/es/models/tasks.d.ts +0 -31
  108. package/es/models/tasks.js +0 -331
  109. package/es/models/tasksUtils.d.ts +0 -65
  110. package/es/models/tasksUtils.js +0 -179
  111. package/es/storage/config.d.ts +0 -3
  112. package/es/storage/config.js +0 -16
  113. package/es/storage/type.d.ts +0 -5
  114. package/es/storage/type.js +0 -1
  115. package/lib/locales/config.d.ts +0 -24
  116. package/lib/locales/config.js +0 -66
  117. package/lib/models/tasks.d.ts +0 -31
  118. package/lib/models/tasks.js +0 -199
  119. package/lib/models/tasksUtils.d.ts +0 -65
  120. package/lib/models/tasksUtils.js +0 -160
  121. package/lib/storage/config.d.ts +0 -3
  122. package/lib/storage/config.js +0 -38
  123. package/lib/storage/type.d.ts +0 -5
  124. package/lib/storage/type.js +0 -17
@@ -1,160 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/models/tasksUtils.ts
30
- var tasksUtils_exports = {};
31
- __export(tasksUtils_exports, {
32
- TasksManager: () => TasksManager
33
- });
34
- module.exports = __toCommonJS(tasksUtils_exports);
35
- var import_storage = __toESM(require("../storage"));
36
- var import_dayjs = __toESM(require("dayjs"));
37
- var import_utils = require("@pisell/utils");
38
- var { getStorage, setStorage } = import_storage.default;
39
- var TasksManager = class {
40
- constructor() {
41
- // 将任务队列状态同步到 localStorage
42
- this.saveTaskQueueToLocalStorage = (state) => {
43
- setStorage("tasks", JSON.stringify(state));
44
- };
45
- // 从 localStorage 加载任务队列状态
46
- this.loadTaskQueueFromLocalStorage = () => {
47
- const tasks = getStorage("tasks");
48
- return tasks ? JSON.parse(tasks) : null;
49
- };
50
- /**
51
- * @title: 执行任务
52
- * @description:
53
- * @param {Task} task
54
- * @return {*}
55
- * @Author: zhiwei.Wang
56
- * @Date: 2024-09-26 13:53
57
- */
58
- this.runTask = async (task) => {
59
- const beforeAction = this.getTask(task.beforeAction);
60
- const afterAction = this.getTask(task.afterAction);
61
- const action = this.getTask(task.action);
62
- let res = { status: "success" };
63
- try {
64
- if (beforeAction) {
65
- await beforeAction(task.beforePayload);
66
- }
67
- if (action) {
68
- res = await action(task.payload);
69
- }
70
- if (afterAction) {
71
- await afterAction(task.afterPayload);
72
- }
73
- } catch (error) {
74
- res = { status: "failure" };
75
- }
76
- return res;
77
- };
78
- /**
79
- * @title: 创建任务数据
80
- * @description:
81
- * @param {Partial} payload
82
- * @return {*}
83
- * @Author: zhiwei.Wang
84
- * @Date: 2024-09-26 13:54
85
- */
86
- this.createTaskData = (payload) => {
87
- return {
88
- id: (0, import_utils.getUniqueId)("task_"),
89
- create_at: (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss"),
90
- type: "local",
91
- retries: 0,
92
- maxRetries: 3,
93
- status: "pending",
94
- // 执行函数
95
- action: "",
96
- // 执行参数
97
- payload: {},
98
- // 执行前的钩子
99
- beforeAction: "",
100
- // 执行前的参数
101
- beforePayload: {},
102
- // 执行后的钩子
103
- afterAction: "",
104
- // 执行后的参数
105
- afterPayload: {},
106
- ...payload
107
- };
108
- };
109
- // 创建任务
110
- this.createTask = (payload) => {
111
- dispatch({
112
- type: "tasks/addTasks",
113
- payload: {
114
- queueId: "order_1",
115
- module: "orders",
116
- tasks: [
117
- {
118
- action: "createOrder",
119
- payload: { order: 1 }
120
- },
121
- {
122
- action: "syncCloudOrder",
123
- payload: { order: 1 }
124
- },
125
- {
126
- action: "goPayment",
127
- payload: { order: 1 }
128
- }
129
- ]
130
- }
131
- });
132
- };
133
- this.tasks = /* @__PURE__ */ new Map();
134
- }
135
- // 单例模式
136
- static getInstance() {
137
- if (!TasksManager.instance) {
138
- TasksManager.instance = new TasksManager();
139
- }
140
- return TasksManager.instance;
141
- }
142
- // 注册任务
143
- useTask(name, plugin) {
144
- this.tasks.set(name, plugin);
145
- }
146
- // 注册任务列表
147
- useTasks(tasks) {
148
- tasks.forEach(({ name, plugin }) => {
149
- this.tasks.set(name, plugin);
150
- });
151
- }
152
- // 获取任务
153
- getTask(name) {
154
- return this.tasks.get(name);
155
- }
156
- };
157
- // Annotate the CommonJS export names for ESM import in node:
158
- 0 && (module.exports = {
159
- TasksManager
160
- });
@@ -1,3 +0,0 @@
1
- import { StorageConfig } from './type';
2
- export declare const setConfig: (newConfig: Partial<StorageConfig>) => void;
3
- export declare const getConfig: () => StorageConfig;
@@ -1,38 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/storage/config.ts
20
- var config_exports = {};
21
- __export(config_exports, {
22
- getConfig: () => getConfig,
23
- setConfig: () => setConfig
24
- });
25
- module.exports = __toCommonJS(config_exports);
26
- var defaultConfig = {
27
- STORAGE_KEY: "CapacitorStorage.native_"
28
- };
29
- var config = { ...defaultConfig };
30
- var setConfig = (newConfig) => {
31
- config = { ...config, ...newConfig };
32
- };
33
- var getConfig = () => config;
34
- // Annotate the CommonJS export names for ESM import in node:
35
- 0 && (module.exports = {
36
- getConfig,
37
- setConfig
38
- });
@@ -1,5 +0,0 @@
1
- export interface StorageConfig {
2
- STORAGE_KEY: string;
3
- setStorageAfter?: (key: string, value: string) => void;
4
- removeStorageAfter?: (key: string) => string;
5
- }
@@ -1,17 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from))
8
- if (!__hasOwnProp.call(to, key) && key !== except)
9
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
- }
11
- return to;
12
- };
13
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
-
15
- // src/storage/type.ts
16
- var type_exports = {};
17
- module.exports = __toCommonJS(type_exports);