@byteluck-fe/model-driven-engine 2.7.0-alpha.31a → 2.7.0-alpha.31b

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 (41) hide show
  1. package/README.md +30 -30
  2. package/dist/esm/common/ActionManager.js +60 -177
  3. package/dist/esm/common/DataManager.js +25 -134
  4. package/dist/esm/common/Engine.js +292 -397
  5. package/dist/esm/common/OkWorker.js +17 -31
  6. package/dist/esm/common/Plugin.js +2 -2
  7. package/dist/esm/common/Runtime.js +41 -56
  8. package/dist/esm/common/Store.js +62 -63
  9. package/dist/esm/common/checkerValue.js +108 -108
  10. package/dist/esm/common/index.js +2 -2
  11. package/dist/esm/common/proxyState.js +76 -76
  12. package/dist/esm/index.js +3 -3
  13. package/dist/esm/plugins/CalcPlugin.js +119 -127
  14. package/dist/esm/plugins/ControlsEventPlugin.js +73 -196
  15. package/dist/esm/plugins/ES6ModulePlugin.js +22 -39
  16. package/dist/esm/plugins/LifecycleEventPlugin.js +79 -198
  17. package/dist/esm/plugins/StylePlugin.js +11 -26
  18. package/dist/esm/plugins/index.js +5 -5
  19. package/dist/esm/utils/index.js +1 -1
  20. package/dist/esm/utils/runtimeUtils.js +7 -5
  21. package/dist/index.umd.js +8 -8
  22. package/dist/types/common/ActionManager.d.ts +14 -14
  23. package/dist/types/common/DataManager.d.ts +10 -10
  24. package/dist/types/common/Engine.d.ts +181 -181
  25. package/dist/types/common/OkWorker.d.ts +13 -13
  26. package/dist/types/common/Plugin.d.ts +6 -6
  27. package/dist/types/common/Runtime.d.ts +26 -26
  28. package/dist/types/common/Store.d.ts +50 -50
  29. package/dist/types/common/checkerValue.d.ts +3 -3
  30. package/dist/types/common/index.d.ts +2 -2
  31. package/dist/types/common/proxyState.d.ts +30 -30
  32. package/dist/types/index.d.ts +3 -3
  33. package/dist/types/plugins/CalcPlugin.d.ts +121 -121
  34. package/dist/types/plugins/ControlsEventPlugin.d.ts +15 -15
  35. package/dist/types/plugins/ES6ModulePlugin.d.ts +27 -27
  36. package/dist/types/plugins/LifecycleEventPlugin.d.ts +14 -14
  37. package/dist/types/plugins/StylePlugin.d.ts +12 -12
  38. package/dist/types/plugins/index.d.ts +5 -5
  39. package/dist/types/utils/index.d.ts +1 -1
  40. package/dist/types/utils/runtimeUtils.d.ts +5 -5
  41. package/package.json +3 -3
@@ -1,44 +1,44 @@
1
- function _array_like_to_array(arr, len) {
1
+ function _arrayLikeToArray(arr, len) {
2
2
  if (len == null || len > arr.length) len = arr.length;
3
3
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
4
  return arr2;
5
5
  }
6
- function _array_without_holes(arr) {
7
- if (Array.isArray(arr)) return _array_like_to_array(arr);
6
+ function _arrayWithoutHoles(arr) {
7
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
8
8
  }
9
- function _iterable_to_array(iter) {
9
+ function _iterableToArray(iter) {
10
10
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
11
11
  }
12
- function _non_iterable_spread() {
12
+ function _nonIterableSpread() {
13
13
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
14
14
  }
15
- function _to_consumable_array(arr) {
16
- return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
15
+ function _toConsumableArray(arr) {
16
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
17
17
  }
18
- function _unsupported_iterable_to_array(o, minLen) {
18
+ function _unsupportedIterableToArray(o, minLen) {
19
19
  if (!o) return;
20
- if (typeof o === "string") return _array_like_to_array(o, minLen);
20
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
21
21
  var n = Object.prototype.toString.call(o).slice(8, -1);
22
22
  if (n === "Object" && o.constructor) n = o.constructor.name;
23
23
  if (n === "Map" || n === "Set") return Array.from(n);
24
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
24
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
25
25
  }
26
+ import { CONTROL_BASE_TYPE, error, logerror } from '@byteluck-fe/model-driven-shared';
26
27
  var cc = console;
27
- import { CONTROL_BASE_TYPE, error, logerror } from "@byteluck-fe/model-driven-shared";
28
28
  var proxyArrayApi = [
29
- "splice",
30
- "push",
31
- "shift",
32
- "pop",
33
- "unshift",
34
- "reverse"
29
+ 'splice',
30
+ 'push',
31
+ 'shift',
32
+ 'pop',
33
+ 'unshift',
34
+ 'reverse',
35
35
  ];
36
- export var engineProxyFlag = Symbol("__engineProxy__");
37
- export var engineTargetKey = Symbol("__engineTarget__");
38
- export var engineArrayBeforeSetCallbackFlag = Symbol("__engineArrayBeforeSetCallbackFlag__");
39
- export var engineProxyThisKey = Symbol("__engineProxyThisKey__");
36
+ export var engineProxyFlag = Symbol('__engineProxy__');
37
+ export var engineTargetKey = Symbol('__engineTarget__');
38
+ export var engineArrayBeforeSetCallbackFlag = Symbol('__engineArrayBeforeSetCallbackFlag__');
39
+ export var engineProxyThisKey = Symbol('__engineProxyThisKey__');
40
40
  var currentHandlerState = {
41
- type: "",
41
+ type: '',
42
42
  args: [],
43
43
  callback: emptyFn
44
44
  };
@@ -55,16 +55,16 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
55
55
  // 操作下标
56
56
  // Number(propertyKey) > target.length 说明当前操作的下标已经超过了安全范围(数组的运行长度,比如[1,2,3],它的长度为3,可操作的下标为0,1,2,3,如果操作4将会产生一个empty index)
57
57
  if (index > target.length) {
58
- error("Wrong array operations may cause unknown errors. It is recommended to use APIs such as ".concat(proxyArrayApi.join(","), " for array operations"));
58
+ error("Wrong array operations may cause unknown errors. It is recommended to use APIs such as ".concat(proxyArrayApi.join(','), " for array operations"));
59
59
  return;
60
60
  }
61
61
  // 不是操作下标,而是直接操作length或者自定义属性等
62
62
  var isNotHandlerIndex = Number.isNaN(index);
63
- if (isNotHandlerIndex && propertyKey !== "length") {
63
+ if (isNotHandlerIndex && propertyKey !== 'length') {
64
64
  return;
65
65
  }
66
66
  // 直接操作length
67
- if (propertyKey === "length") {
67
+ if (propertyKey === 'length') {
68
68
  var newLength = value;
69
69
  var oldLength = target.length;
70
70
  if (newLength > target.length) {
@@ -76,9 +76,9 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
76
76
  }
77
77
  // 通过操作length删除旧的行
78
78
  return function() {
79
- return callback.call(null, target, thisKey, "splice", [
79
+ return callback.call(null, target, thisKey, 'splice', [
80
80
  newLength,
81
- oldLength - newLength
81
+ oldLength - newLength,
82
82
  ]);
83
83
  };
84
84
  // 直接操作下标
@@ -86,13 +86,13 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
86
86
  // 正常操作
87
87
  if (index === target.length) {
88
88
  return function() {
89
- return callback.call(null, target, thisKey, "push", [
89
+ return callback.call(null, target, thisKey, 'push', [
90
90
  value
91
91
  ]);
92
92
  };
93
93
  } else {
94
94
  return function() {
95
- return callback.call(null, target, thisKey, "splice", [
95
+ return callback.call(null, target, thisKey, 'splice', [
96
96
  index,
97
97
  1,
98
98
  value
@@ -101,11 +101,11 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
101
101
  }
102
102
  }
103
103
  }
104
- /**
105
- * 返回proxy操作对象
106
- * @param thisKey 当前对象在上级中的key
107
- * @param callback 需要在修改的时候,触发的回调函数
108
- * @param beforeSetCallback 需要在修改之前触发的回调函数,可以进行校验和对值的修改等等,最终的返回值不为undefined就会使用
104
+ /**
105
+ * 返回proxy操作对象
106
+ * @param thisKey 当前对象在上级中的key
107
+ * @param callback 需要在修改的时候,触发的回调函数
108
+ * @param beforeSetCallback 需要在修改之前触发的回调函数,可以进行校验和对值的修改等等,最终的返回值不为undefined就会使用
109
109
  * */ function handler(thisKey, callback, beforeSetCallback) {
110
110
  return {
111
111
  __engineProxy__: true,
@@ -124,9 +124,9 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
124
124
  }
125
125
  return Reflect.get(target, propertyKey, receiver);
126
126
  },
127
- set: function set(target, propertyKey, value, receiver) {
127
+ set: function set(target, propertyKey, value1, receiver) {
128
128
  var reProxyState = function reProxyState(value) {
129
- if (typeof value === "object" && value !== null) {
129
+ if (typeof value === 'object' && value !== null) {
130
130
  // @ts-ignore
131
131
  if (value[engineProxyFlag] !== true) {
132
132
  return proxyState(value, callback, beforeSetCallback, concatKey);
@@ -137,19 +137,19 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
137
137
  }
138
138
  }
139
139
  };
140
- var newValue = value;
140
+ var newValue = value1;
141
141
  // @ts-ignore
142
142
  var oldValue = target[propertyKey];
143
- var concatKey = thisKey === "" ? propertyKey : thisKey + "." + propertyKey;
144
- var _reProxyState;
145
- newValue = (_reProxyState = reProxyState(value)) !== null && _reProxyState !== void 0 ? _reProxyState : newValue;
143
+ var concatKey = thisKey === '' ? propertyKey : thisKey + '.' + propertyKey;
144
+ var ref;
145
+ newValue = (ref = reProxyState(value1)) !== null && ref !== void 0 ? ref : newValue;
146
146
  // 先设置值,然后再进行触发回调,确保回调内拿到的是最新的值
147
147
  var setResult;
148
148
  // TODO 数组拦截操作需要重构,优化现有逻辑
149
149
  // TODO 直接操作下标改动明细表时,没有对行数据进行checker
150
150
  if (Array.isArray(target)) {
151
151
  // 操作数组的时候,不需要使用拼接的thisKey,先判断执行的是否是违规操作,违规操作的话会报错,不允许继续执行,正常操作的话,返回一个回调函数,用于在值修改完之后触发
152
- var nextHandler = ArrayHandler(target, propertyKey, value, thisKey, callback);
152
+ var nextHandler = ArrayHandler(target, propertyKey, value1, thisKey, callback);
153
153
  setResult = Reflect.set(target, propertyKey, newValue, receiver);
154
154
  if (nextHandler) {
155
155
  nextHandler();
@@ -171,7 +171,7 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
171
171
  return true;
172
172
  }
173
173
  setResult = Reflect.set(target, propertyKey, newValue, receiver);
174
- callback.call(null, target, concatKey, value, oldValue);
174
+ callback.call(null, target, concatKey, value1, oldValue);
175
175
  }
176
176
  // 不返回falsy 值(即 false、0、null、undefined、空字符串等)
177
177
  //fix: TypeError: Proxy object's 'set' trap returned falsy value for property 'length'
@@ -179,22 +179,22 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
179
179
  }
180
180
  };
181
181
  }
182
- /**
183
- * 代理state数据
184
- * @param state 数据对象
185
- * @param callback 触发set时候的回调函数
186
- * @param beforeSetCallback
187
- * @param prevKey 递归对象的key
182
+ /**
183
+ * 代理state数据
184
+ * @param state 数据对象
185
+ * @param callback 触发set时候的回调函数
186
+ * @param beforeSetCallback
187
+ * @param prevKey 递归对象的key
188
188
  * */ export function proxyState(state, callback, beforeSetCallback) {
189
- var prevKey = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "";
189
+ var prevKey = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : '';
190
190
  // 冻结的对象不需要再执行proxy,否则会报错
191
191
  if (Object.isFrozen(state)) {
192
192
  return state;
193
193
  }
194
194
  for(var key in state){
195
- var concatKey = prevKey === "" ? key : prevKey + "." + key;
195
+ var concatKey = prevKey === '' ? key : prevKey + '.' + key;
196
196
  var obj = state[key];
197
- if (typeof obj === "object" && obj !== null) {
197
+ if (typeof obj === 'object' && obj !== null) {
198
198
  // @ts-ignore
199
199
  state[key] = proxyState(obj, callback, beforeSetCallback, concatKey);
200
200
  }
@@ -205,20 +205,20 @@ function flatInstanceForChildren(controls) {
205
205
  var result = [];
206
206
  controls.forEach(function(item) {
207
207
  result.push(item);
208
- if (item.controlType === "layout" || item.controlType === "wrap") {
208
+ if (item.controlType === 'layout' || item.controlType === 'wrap') {
209
209
  var _result;
210
- (_result = result).push.apply(_result, _to_consumable_array(flatInstanceForChildren(item.children)));
210
+ (_result = result).push.apply(_result, _toConsumableArray(flatInstanceForChildren(item.children)));
211
211
  }
212
212
  });
213
213
  return result;
214
214
  }
215
- /**
216
- * 在flatInstance中通过key查找出对应的instance
217
- * @param flatInstance 拍平的instance数组
218
- * @param key 操作的数据在state的key - 可以是深层次的 subtable.0.input等
219
- * */ export function findItem(flatInstance, key, instanceMap) {
220
- if (key === "") return undefined;
221
- var keys = key.split(".");
215
+ /**
216
+ * 在flatInstance中通过key查找出对应的instance
217
+ * @param flatInstance 拍平的instance数组
218
+ * @param key 操作的数据在state的key - 可以是深层次的 subtable.0.input等
219
+ * */ export function findItem(flatInstance, key1, instanceMap) {
220
+ if (key1 === '') return undefined;
221
+ var keys = key1.split('.');
222
222
  if (keys.length === 0) return undefined;
223
223
  var oneKey = keys[0];
224
224
  var otherKeys = keys.slice(1);
@@ -244,37 +244,37 @@ function flatInstanceForChildren(controls) {
244
244
  // 最后一个key可能是值对象上边的key,比如金额的amount和currency,计算公式的result和unit,所以需要判断前一个控件是不是一个表单控件,是的话就返回最后一个表单控件
245
245
  return findEndItem ? findEndItem : prevItem.controlType === CONTROL_BASE_TYPE.FORM ? prevItem : undefined;
246
246
  } else {
247
- var _prevItem_children;
248
- var _prevItem_children_index;
247
+ var ref;
248
+ var ref1;
249
249
  // 如果有children,则取children中对应的下标,没有的话一直返回prevItem
250
- return (_prevItem_children_index = prevItem === null || prevItem === void 0 ? void 0 : (_prevItem_children = prevItem.children) === null || _prevItem_children === void 0 ? void 0 : _prevItem_children[index]) !== null && _prevItem_children_index !== void 0 ? _prevItem_children_index : prevItem;
250
+ return (ref1 = prevItem === null || prevItem === void 0 ? void 0 : (ref = prevItem.children) === null || ref === void 0 ? void 0 : ref[index]) !== null && ref1 !== void 0 ? ref1 : prevItem;
251
251
  }
252
252
  }, initInstance);
253
253
  }
254
254
  function getArrayNewValue(type, args) {
255
255
  if ([
256
- "push",
257
- "unshift"
256
+ 'push',
257
+ 'unshift'
258
258
  ].includes(type)) {
259
259
  return args;
260
- } else if (type === "splice") {
260
+ } else if (type === 'splice') {
261
261
  return args.slice(2);
262
262
  }
263
263
  return [];
264
264
  }
265
265
  function getArrayNewArgs(type, args, value) {
266
266
  if ([
267
- "push",
268
- "unshift"
267
+ 'push',
268
+ 'unshift'
269
269
  ].includes(type)) {
270
270
  return value;
271
- } else if (type === "splice") {
271
+ } else if (type === 'splice') {
272
272
  return args.slice(0, 2).concat(value);
273
273
  }
274
274
  }
275
- /**
276
- * TODO 数组劫持操作需要模仿vue3进行重构,不再直接劫持原生property
277
- * 劫持数组api,达到操作数组api的时候,可以同步操作instance
275
+ /**
276
+ * TODO 数组劫持操作需要模仿vue3进行重构,不再直接劫持原生property
277
+ * 劫持数组api,达到操作数组api的时候,可以同步操作instance
278
278
  * */ function hijackArrayProperty() {
279
279
  proxyArrayApi.forEach(function(key) {
280
280
  var oldApiHandler = Array.prototype[key];
@@ -287,9 +287,9 @@ function getArrayNewArgs(type, args, value) {
287
287
  var result;
288
288
  var addValue = getArrayNewValue(key, args);
289
289
  if (addValue.length) {
290
- var _this_engineArrayBeforeSetCallbackFlag, _this;
290
+ var _obj, ref;
291
291
  // @ts-ignore
292
- var newValue = (_this_engineArrayBeforeSetCallbackFlag = (_this = this)[engineArrayBeforeSetCallbackFlag]) === null || _this_engineArrayBeforeSetCallbackFlag === void 0 ? void 0 : _this_engineArrayBeforeSetCallbackFlag.call(_this, // @ts-ignore
292
+ var newValue = (ref = (_obj = this)[engineArrayBeforeSetCallbackFlag]) === null || ref === void 0 ? void 0 : ref.call(_obj, // @ts-ignore
293
293
  this[engineTargetKey], // @ts-ignore
294
294
  this[engineProxyThisKey], addValue);
295
295
  var newArgs = getArrayNewArgs(key, args, newValue);
@@ -303,8 +303,8 @@ function getArrayNewArgs(type, args, value) {
303
303
  // @ts-ignore
304
304
  result = oldApiHandler.apply(this, args);
305
305
  }
306
- typeof currentHandlerState.callback === "function" && currentHandlerState.callback(key, args, result);
307
- currentHandlerState.type = "";
306
+ typeof currentHandlerState.callback === 'function' && currentHandlerState.callback(key, args, result);
307
+ currentHandlerState.type = '';
308
308
  currentHandlerState.args = [];
309
309
  currentHandlerState.callback = emptyFn;
310
310
  return result;
package/dist/esm/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export * from "./common";
2
- export * from "./plugins";
3
- export * from "./utils";
1
+ export * from './common';
2
+ export * from './plugins';
3
+ export * from './utils';