@byteluck-fe/model-driven-engine 2.22.2-beta.1 → 2.22.2-beta.3

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 (40) hide show
  1. package/README.md +30 -30
  2. package/dist/esm/common/ActionManager.js +7 -7
  3. package/dist/esm/common/DataManager.js +2 -2
  4. package/dist/esm/common/Engine.js +130 -124
  5. package/dist/esm/common/OkWorker.js +8 -8
  6. package/dist/esm/common/Runtime.js +17 -17
  7. package/dist/esm/common/Store.js +13 -13
  8. package/dist/esm/common/checkerValue.js +22 -22
  9. package/dist/esm/common/index.js +2 -2
  10. package/dist/esm/common/proxyState.js +52 -56
  11. package/dist/esm/index.js +3 -3
  12. package/dist/esm/plugins/CalcPlugin.js +57 -61
  13. package/dist/esm/plugins/ControlsEventPlugin.js +4 -4
  14. package/dist/esm/plugins/ES6ModulePlugin.js +6 -6
  15. package/dist/esm/plugins/LifecycleEventPlugin.js +5 -5
  16. package/dist/esm/plugins/StylePlugin.js +10 -10
  17. package/dist/esm/plugins/index.js +5 -5
  18. package/dist/esm/utils/index.js +1 -1
  19. package/dist/esm/utils/runtimeUtils.js +3 -3
  20. package/dist/index.umd.js +25 -25
  21. package/dist/types/common/ActionManager.d.ts +14 -14
  22. package/dist/types/common/DataManager.d.ts +10 -10
  23. package/dist/types/common/Engine.d.ts +201 -195
  24. package/dist/types/common/OkWorker.d.ts +13 -13
  25. package/dist/types/common/Plugin.d.ts +6 -6
  26. package/dist/types/common/Runtime.d.ts +31 -31
  27. package/dist/types/common/Store.d.ts +54 -54
  28. package/dist/types/common/checkerValue.d.ts +3 -3
  29. package/dist/types/common/index.d.ts +2 -2
  30. package/dist/types/common/proxyState.d.ts +30 -30
  31. package/dist/types/index.d.ts +3 -3
  32. package/dist/types/plugins/CalcPlugin.d.ts +121 -121
  33. package/dist/types/plugins/ControlsEventPlugin.d.ts +17 -17
  34. package/dist/types/plugins/ES6ModulePlugin.d.ts +27 -27
  35. package/dist/types/plugins/LifecycleEventPlugin.d.ts +15 -15
  36. package/dist/types/plugins/StylePlugin.d.ts +13 -13
  37. package/dist/types/plugins/index.d.ts +5 -5
  38. package/dist/types/utils/index.d.ts +1 -1
  39. package/dist/types/utils/runtimeUtils.d.ts +5 -5
  40. package/package.json +2 -2
@@ -30,7 +30,7 @@ function _define_property(obj, key, value) {
30
30
  }
31
31
  return obj;
32
32
  }
33
- import { log } from '@byteluck-fe/model-driven-shared';
33
+ import { log } from "@byteluck-fe/model-driven-shared";
34
34
  var OkWorker = /*#__PURE__*/ function() {
35
35
  "use strict";
36
36
  function OkWorker() {
@@ -43,7 +43,7 @@ var OkWorker = /*#__PURE__*/ function() {
43
43
  value: function run(initState) {
44
44
  this.worker = OkWorker.createWorker();
45
45
  this.postMessage({
46
- action: 'init',
46
+ action: "init",
47
47
  payload: initState
48
48
  });
49
49
  }
@@ -77,7 +77,7 @@ var OkWorker = /*#__PURE__*/ function() {
77
77
  key: "createWorkerFunction",
78
78
  value: function createWorkerFunction() {
79
79
  return function() {
80
- log('‍🚀 worker running');
80
+ log("‍\uD83D\uDE80 worker running");
81
81
  var _self = self;
82
82
  function createHandler(parentKey) {
83
83
  return {
@@ -87,7 +87,7 @@ var OkWorker = /*#__PURE__*/ function() {
87
87
  set: function set(target, key, value) {
88
88
  if (parentKey) {
89
89
  _self.postMessage({
90
- action: 'update',
90
+ action: "update",
91
91
  key: "".concat(parentKey, ".").concat(key)
92
92
  });
93
93
  }
@@ -106,7 +106,7 @@ var OkWorker = /*#__PURE__*/ function() {
106
106
  // }
107
107
  // return new Proxy(obj, createHandler(parentKey))
108
108
  // }
109
- _self.addEventListener('message', function(event) {
109
+ _self.addEventListener("message", function(event) {
110
110
  var _event_data = event.data, action = _event_data.action, payload = _event_data.payload, fn = _event_data.fn;
111
111
  log(action, payload);
112
112
  // 通过proxy进行代理,每次修改的时候,自动向外抛出postMessage
@@ -118,10 +118,10 @@ var OkWorker = /*#__PURE__*/ function() {
118
118
  //
119
119
  // const result = fn(data, schema)
120
120
  _self.postMessage({
121
- action: 'delete',
121
+ action: "delete",
122
122
  payload: {
123
- key: 'key3[0].key1',
124
- value: 'index'
123
+ key: "key3[0].key1",
124
+ value: "index"
125
125
  }
126
126
  });
127
127
  });
@@ -96,9 +96,9 @@ function _create_super(Derived) {
96
96
  return _possible_constructor_return(this, result);
97
97
  };
98
98
  }
99
- import { RegisterControls, isDataBind } from '@byteluck-fe/model-driven-core';
100
- import { CONTROL_BASE_TYPE, CONTROL_TYPE, JSONCopy, loopFormSchema, isArray } from '@byteluck-fe/model-driven-shared';
101
- import { hasChildrenControl, loopDataViewControl, loopFormControl } from '../utils/runtimeUtils';
99
+ import { RegisterControls, isDataBind } from "@byteluck-fe/model-driven-core";
100
+ import { CONTROL_BASE_TYPE, CONTROL_TYPE, JSONCopy, loopFormSchema, isArray } from "@byteluck-fe/model-driven-shared";
101
+ import { hasChildrenControl, loopDataViewControl, loopFormControl } from "../utils/runtimeUtils";
102
102
  export var Runtime = /*#__PURE__*/ function(RegisterControls) {
103
103
  "use strict";
104
104
  _inherits(Runtime, RegisterControls);
@@ -106,7 +106,7 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
106
106
  function Runtime(props) {
107
107
  _class_call_check(this, Runtime);
108
108
  var _this;
109
- _this = _super.call(this, 'Runtime');
109
+ _this = _super.call(this, "Runtime");
110
110
  _define_property(_assert_this_initialized(_this), "_schema", void 0);
111
111
  _define_property(_assert_this_initialized(_this), "_instance", void 0);
112
112
  _define_property(_assert_this_initialized(_this), "_flatInstances", []);
@@ -125,7 +125,7 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
125
125
  var instances = [];
126
126
  var instanceMap = {};
127
127
  var controlParentIdMap = {};
128
- loop(this._instance, '', function(item, parentId) {
128
+ loop(this._instance, "", function(item, parentId) {
129
129
  var _item_parent;
130
130
  // 3.4.1 避免将subtable-row 放到 _flatInstances 中
131
131
  //4.3.0-lh2 将自处注释掉,为使instance.parent能取到父级
@@ -140,7 +140,7 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
140
140
  instanceMap[item.id] = [];
141
141
  }
142
142
  //不知为何subtable-column会多存一次
143
- if (item.type === 'subtable-column') {
143
+ if (item.type === "subtable-column") {
144
144
  if (instanceMap[item.id].length > 0) {
145
145
  return;
146
146
  }
@@ -294,7 +294,7 @@ function loop(control, parentId, callback) {
294
294
  // @ts-ignore
295
295
  loop(ctl.children, ctl.id, callback);
296
296
  }
297
- if (hasHeaderOrFooterControl(item, 'headers')) {
297
+ if (hasHeaderOrFooterControl(item, "headers")) {
298
298
  loop(item.props.headers, item.id, callback);
299
299
  }
300
300
  // if (hasHeaderOrFooterControl(item, 'footers')) {
@@ -305,8 +305,8 @@ function loop(control, parentId, callback) {
305
305
  function hasHeaderOrFooterControl(control, checkType) {
306
306
  return checkType in control.props && isArray(control.props[checkType]);
307
307
  }
308
- /**
309
- * 控件是否在视图中隐藏,遍历查找所有parent
308
+ /**
309
+ * 控件是否在视图中隐藏,遍历查找所有parent
310
310
  * */ function getControlIsHide(control) {
311
311
  if (control.props.isHide) {
312
312
  return true;
@@ -331,7 +331,7 @@ item) {
331
331
  // data[item.id] = item.rules
332
332
  data[item.id] = result;
333
333
  var itemRules = {
334
- type: 'array',
334
+ type: "array",
335
335
  fields: {}
336
336
  };
337
337
  (isSubtableDefaultRules === true ? [
@@ -343,7 +343,7 @@ item) {
343
343
  if (itemRules.fields) {
344
344
  if (!itemRules.fields[index]) {
345
345
  itemRules.fields[index] = {
346
- type: 'object',
346
+ type: "object",
347
347
  required: true,
348
348
  fields: {}
349
349
  };
@@ -372,7 +372,7 @@ item) {
372
372
  if (item.controlType === CONTROL_BASE_TYPE.FORM) {
373
373
  if (isDataBind(item.props.dataBind)) {
374
374
  var _item_props_dataBind;
375
- if (((_item_props_dataBind = item.props.dataBind) === null || _item_props_dataBind === void 0 ? void 0 : _item_props_dataBind.fieldCode) != '') {
375
+ if (((_item_props_dataBind = item.props.dataBind) === null || _item_props_dataBind === void 0 ? void 0 : _item_props_dataBind.fieldCode) != "") {
376
376
  var _item_props_dataBind1;
377
377
  data[(_item_props_dataBind1 = item.props.dataBind) === null || _item_props_dataBind1 === void 0 ? void 0 : _item_props_dataBind1.fieldCode] = result;
378
378
  }
@@ -380,7 +380,7 @@ item) {
380
380
  for(var dataBindKey in item.props.dataBind){
381
381
  var _item_props_dataBind_dataBindKey;
382
382
  // @ts-ignore
383
- if (((_item_props_dataBind_dataBindKey = item.props.dataBind[dataBindKey]) === null || _item_props_dataBind_dataBindKey === void 0 ? void 0 : _item_props_dataBind_dataBindKey.fieldCode) != '') {
383
+ if (((_item_props_dataBind_dataBindKey = item.props.dataBind[dataBindKey]) === null || _item_props_dataBind_dataBindKey === void 0 ? void 0 : _item_props_dataBind_dataBindKey.fieldCode) != "") {
384
384
  var // @ts-ignore
385
385
  _item_props_dataBind_dataBindKey1, _findFields;
386
386
  // @ts-ignore
@@ -392,7 +392,7 @@ item) {
392
392
  var _item_props_datasourceBind, _item_props_datasourceBind1;
393
393
  data[(_item_props_datasourceBind = item.props.datasourceBind) === null || _item_props_datasourceBind === void 0 ? void 0 : _item_props_datasourceBind.dataCode] = result;
394
394
  var itemRules = {
395
- type: 'array',
395
+ type: "array",
396
396
  fields: {}
397
397
  };
398
398
  (isSubtableDefaultRules === true ? [
@@ -404,7 +404,7 @@ item) {
404
404
  if (itemRules.fields) {
405
405
  if (!itemRules.fields[index]) {
406
406
  itemRules.fields[index] = {
407
- type: 'object',
407
+ type: "object",
408
408
  required: true,
409
409
  fields: {}
410
410
  };
@@ -414,7 +414,7 @@ item) {
414
414
  for(var dataBindKey in formControl.props.dataBind){
415
415
  var _formControl_props_dataBind_dataBindKey;
416
416
  // @ts-ignore
417
- if (((_formControl_props_dataBind_dataBindKey = formControl.props.dataBind[dataBindKey]) === null || _formControl_props_dataBind_dataBindKey === void 0 ? void 0 : _formControl_props_dataBind_dataBindKey.fieldCode) != '') {
417
+ if (((_formControl_props_dataBind_dataBindKey = formControl.props.dataBind[dataBindKey]) === null || _formControl_props_dataBind_dataBindKey === void 0 ? void 0 : _formControl_props_dataBind_dataBindKey.fieldCode) != "") {
418
418
  var _findFields;
419
419
  // @ts-ignore
420
420
  itemRules.fields[index].fields[// @ts-ignore
@@ -423,7 +423,7 @@ item) {
423
423
  }
424
424
  } else {
425
425
  var _formControl_props_dataBind;
426
- if (((_formControl_props_dataBind = formControl.props.dataBind) === null || _formControl_props_dataBind === void 0 ? void 0 : _formControl_props_dataBind.fieldCode) != '') {
426
+ if (((_formControl_props_dataBind = formControl.props.dataBind) === null || _formControl_props_dataBind === void 0 ? void 0 : _formControl_props_dataBind.fieldCode) != "") {
427
427
  var _formControl_props_dataBind1;
428
428
  // @ts-ignore
429
429
  itemRules.fields[index].fields[(_formControl_props_dataBind1 = formControl.props.dataBind) === null || _formControl_props_dataBind1 === void 0 ? void 0 : _formControl_props_dataBind1.fieldCode] = childResult;
@@ -45,9 +45,9 @@ function _object_spread(target) {
45
45
  }
46
46
  return target;
47
47
  }
48
- import { DataBind, isDataBind } from '@byteluck-fe/model-driven-core';
49
- import { loopFormSchema, JSONCopy, warn, CONTROL_TYPE, CONTROL_BASE_TYPE } from '@byteluck-fe/model-driven-shared';
50
- import { loopDataViewControl, loopFormControl, buildUUID } from '../utils/runtimeUtils';
48
+ import { DataBind, isDataBind } from "@byteluck-fe/model-driven-core";
49
+ import { loopFormSchema, JSONCopy, warn, CONTROL_TYPE, CONTROL_BASE_TYPE } from "@byteluck-fe/model-driven-shared";
50
+ import { loopDataViewControl, loopFormControl, buildUUID } from "../utils/runtimeUtils";
51
51
  var Store = /*#__PURE__*/ function() {
52
52
  "use strict";
53
53
  function Store(props) {
@@ -69,10 +69,10 @@ var Store = /*#__PURE__*/ function() {
69
69
  }
70
70
  _create_class(Store, [
71
71
  {
72
- /**
73
- * 使用该方法仅改变数据,不会表单触发事件。明细表可全量赋值也可根据rowIndex进行单独设置
74
- * @param controlId 组件ID
75
- * @param value
72
+ /**
73
+ * 使用该方法仅改变数据,不会表单触发事件。明细表可全量赋值也可根据rowIndex进行单独设置
74
+ * @param controlId 组件ID
75
+ * @param value
76
76
  */ key: "setState",
77
77
  value: function setState(controlId, value, rowIndex) {
78
78
  var _this = this;
@@ -84,7 +84,7 @@ var Store = /*#__PURE__*/ function() {
84
84
  value.forEach(function(item) {
85
85
  if (!item.uid) {
86
86
  Object.assign(item, {
87
- uid: 'new:' + buildUUID('uid')
87
+ uid: "new:" + buildUUID("uid")
88
88
  });
89
89
  }
90
90
  });
@@ -192,9 +192,9 @@ var Store = /*#__PURE__*/ function() {
192
192
  if (controlInfo !== undefined) {
193
193
  var state = this.emptyState[controlInfo.dataView][controlId];
194
194
  //判断找到的是否是明细表的控件
195
- if ('children' in controlInfo) {
195
+ if ("children" in controlInfo) {
196
196
  Object.assign(state, {
197
- uid: 'new:' + buildUUID('uid')
197
+ uid: "new:" + buildUUID("uid")
198
198
  });
199
199
  }
200
200
  return state;
@@ -292,7 +292,7 @@ item) {
292
292
  var _item_props_defaultRows, _fill_map;
293
293
  dataViewState[item.id] = (_fill_map = new Array((_item_props_defaultRows = item.props.defaultRows) !== null && _item_props_defaultRows !== void 0 ? _item_props_defaultRows : 1).fill(0).map(function() {
294
294
  return _object_spread({
295
- uid: 'new:' + buildUUID('uid')
295
+ uid: "new:" + buildUUID("uid")
296
296
  }, JSONCopy(emptyTemplate));
297
297
  })) !== null && _fill_map !== void 0 ? _fill_map : [];
298
298
  emptyDataViewState[item.id] = emptyTemplate;
@@ -347,7 +347,7 @@ item) {
347
347
  });
348
348
  }
349
349
  } else {
350
- if (item.props.datasourceBind.dataCode === '') {
350
+ if (item.props.datasourceBind.dataCode === "") {
351
351
  //敏捷依赖后端生成dataCode,预览的时候没有
352
352
  warn("datasourceBind.dataCode is empty! maybe in preview mode, control:".concat(item.id, " type:").concat(item.type));
353
353
  return;
@@ -408,7 +408,7 @@ item) {
408
408
  data[item.id] = {
409
409
  dataBind: new DataBind({
410
410
  dataCode: item.props.datasourceBind.dataCode,
411
- fieldCode: ''
411
+ fieldCode: ""
412
412
  }),
413
413
  dataView: dataViewId,
414
414
  children: {},
@@ -157,9 +157,9 @@ function _create_super(Derived) {
157
157
  return _possible_constructor_return(this, result);
158
158
  };
159
159
  }
160
- import { isArray, isFunction, isString, isJSONArray, isJSONObject, isNumber, isNumberAndEmptyStringArray, isPlainObject, isStringArray, FieldTypes, isObject } from '@byteluck-fe/model-driven-shared';
161
- import { AddressValue, AmountValue, CalcValue, RangeDateValue } from '@byteluck-fe/model-driven-core';
162
- import { camelizeKeys } from 'humps';
160
+ import { isArray, isFunction, isString, isJSONArray, isJSONObject, isNumber, isNumberAndEmptyStringArray, isPlainObject, isStringArray, FieldTypes, isObject } from "@byteluck-fe/model-driven-shared";
161
+ import { AddressValue, AmountValue, CalcValue, RangeDateValue } from "@byteluck-fe/model-driven-core";
162
+ import { camelizeKeys } from "humps";
163
163
  var ValueChecker = function ValueChecker() {
164
164
  "use strict";
165
165
  _class_call_check(this, ValueChecker);
@@ -183,7 +183,7 @@ var StringValueChecker = /*#__PURE__*/ function(ValueChecker) {
183
183
  key: "transform",
184
184
  value: function transform(value) {
185
185
  if (value === null || value === undefined) {
186
- return '';
186
+ return "";
187
187
  }
188
188
  if (!isPlainObject(value) && !isFunction(value)) {
189
189
  return String(value);
@@ -210,14 +210,14 @@ var NumberValueChecker = /*#__PURE__*/ function(ValueChecker) {
210
210
  // 数字类型允许是空字符串,用于置空数据
211
211
  key: "validate",
212
212
  value: function validate(value) {
213
- return isNumber(value) || value === '';
213
+ return isNumber(value) || value === "";
214
214
  }
215
215
  },
216
216
  {
217
217
  key: "transform",
218
218
  value: function transform(value) {
219
219
  if (value === null || value === undefined) {
220
- return '';
220
+ return "";
221
221
  }
222
222
  var newValue = !isPlainObject(value) && !isFunction(value) ? Number(value) : undefined;
223
223
  if (!Number.isNaN(newValue) && newValue !== undefined) {
@@ -252,7 +252,7 @@ var StringArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
252
252
  }
253
253
  function getStringValueArray(value) {
254
254
  return value.map(function(item) {
255
- return !item ? '' : String(item);
255
+ return !item ? "" : String(item);
256
256
  });
257
257
  }
258
258
  if (isArray(value)) {
@@ -297,9 +297,9 @@ var NumberArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
297
297
  }
298
298
  function getNumberValueArray(value) {
299
299
  return value.map(function(item) {
300
- return !item && item !== 0 ? '' : Number(item);
300
+ return !item && item !== 0 ? "" : Number(item);
301
301
  }).filter(function(item) {
302
- return item === '' || !Number.isNaN(item);
302
+ return item === "" || !Number.isNaN(item);
303
303
  });
304
304
  }
305
305
  if (isArray(value)) {
@@ -338,13 +338,13 @@ var MoneyValueChecker = /*#__PURE__*/ function(ValueChecker) {
338
338
  key: "validate",
339
339
  value: function validate(value) {
340
340
  return(// value instanceof AmountValue ||
341
- isPlainObject(value) && 'amount' in value && isNumber(value.amount) && 'currency' in value && isString(value.currency));
341
+ isPlainObject(value) && "amount" in value && isNumber(value.amount) && "currency" in value && isString(value.currency));
342
342
  }
343
343
  },
344
344
  {
345
345
  key: "transform",
346
346
  value: function transform(value, oldValue) {
347
- if (value === undefined || value === null || value === '') {
347
+ if (value === undefined || value === null || value === "") {
348
348
  return new AmountValue({
349
349
  currency: oldValue === null || oldValue === void 0 ? void 0 : oldValue.currency
350
350
  });
@@ -389,13 +389,13 @@ var TimeScopeValueChecker = /*#__PURE__*/ function(ValueChecker) {
389
389
  key: "validate",
390
390
  value: function validate(value) {
391
391
  return(// value instanceof RangeDateValue ||
392
- isPlainObject(value) && 'min' in value && isString(value.min) && 'max' in value && isString(value.max));
392
+ isPlainObject(value) && "min" in value && isString(value.min) && "max" in value && isString(value.max));
393
393
  }
394
394
  },
395
395
  {
396
396
  key: "transform",
397
397
  value: function transform(value, oldValue) {
398
- if (value === undefined || value === null || value === '') {
398
+ if (value === undefined || value === null || value === "") {
399
399
  return new RangeDateValue();
400
400
  }
401
401
  var result;
@@ -437,13 +437,13 @@ var CalcValueChecker = /*#__PURE__*/ function(ValueChecker) {
437
437
  key: "validate",
438
438
  value: function validate(value) {
439
439
  return(// value instanceof CalcValue ||
440
- isPlainObject(value) && 'result' in value && isNumber(value.result) && 'unit' in value && isString(value.unit));
440
+ isPlainObject(value) && "result" in value && isNumber(value.result) && "unit" in value && isString(value.unit));
441
441
  }
442
442
  },
443
443
  {
444
444
  key: "transform",
445
445
  value: function transform(value, oldValue) {
446
- if (value === undefined || value === null || value === '') {
446
+ if (value === undefined || value === null || value === "") {
447
447
  return new CalcValue({
448
448
  unit: oldValue === null || oldValue === void 0 ? void 0 : oldValue.unit
449
449
  });
@@ -504,7 +504,7 @@ var AddressValueChecker = /*#__PURE__*/ function(ValueChecker) {
504
504
  {
505
505
  key: "transform",
506
506
  value: function transform(value, oldValue) {
507
- if (value === undefined || value === null || value === '') {
507
+ if (value === undefined || value === null || value === "") {
508
508
  return new AddressValue();
509
509
  }
510
510
  var result;
@@ -588,15 +588,15 @@ var ValueCheckerFactory = /*#__PURE__*/ function() {
588
588
  }();
589
589
  function getFieldTypeFromKey(key) {
590
590
  if ([
591
- 'min',
592
- 'max',
593
- 'currency',
594
- 'unit'
591
+ "min",
592
+ "max",
593
+ "currency",
594
+ "unit"
595
595
  ].includes(key)) {
596
596
  return FieldTypes.VARCHAR;
597
597
  } else if ([
598
- 'result',
599
- 'amount'
598
+ "result",
599
+ "amount"
600
600
  ].includes(key)) {
601
601
  return FieldTypes.DECIMAL;
602
602
  }
@@ -1,2 +1,2 @@
1
- export * from './Engine';
2
- export * from './Plugin';
1
+ export * from "./Engine";
2
+ export * from "./Plugin";
@@ -15,10 +15,6 @@ function _non_iterable_spread() {
15
15
  function _to_consumable_array(arr) {
16
16
  return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
17
17
  }
18
- function _type_of(obj) {
19
- "@swc/helpers - typeof";
20
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
21
- }
22
18
  function _unsupported_iterable_to_array(o, minLen) {
23
19
  if (!o) return;
24
20
  if (typeof o === "string") return _array_like_to_array(o, minLen);
@@ -28,21 +24,21 @@ function _unsupported_iterable_to_array(o, minLen) {
28
24
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
29
25
  }
30
26
  var cc = console;
31
- import { CONTROL_BASE_TYPE, error, logerror, JSONCopy } from '@byteluck-fe/model-driven-shared';
27
+ import { CONTROL_BASE_TYPE, error, logerror, JSONCopy } from "@byteluck-fe/model-driven-shared";
32
28
  var proxyArrayApi = [
33
- 'splice',
34
- 'push',
35
- 'shift',
36
- 'pop',
37
- 'unshift',
38
- 'reverse'
29
+ "splice",
30
+ "push",
31
+ "shift",
32
+ "pop",
33
+ "unshift",
34
+ "reverse"
39
35
  ];
40
- export var engineProxyFlag = Symbol('__engineProxy__');
41
- export var engineTargetKey = Symbol('__engineTarget__');
42
- export var engineArrayBeforeSetCallbackFlag = Symbol('__engineArrayBeforeSetCallbackFlag__');
43
- 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__");
44
40
  var currentHandlerState = {
45
- type: '',
41
+ type: "",
46
42
  args: [],
47
43
  callback: emptyFn
48
44
  };
@@ -59,16 +55,16 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
59
55
  // 操作下标
60
56
  // Number(propertyKey) > target.length 说明当前操作的下标已经超过了安全范围(数组的运行长度,比如[1,2,3],它的长度为3,可操作的下标为0,1,2,3,如果操作4将会产生一个empty index)
61
57
  if (index > target.length) {
62
- 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"));
63
59
  return;
64
60
  }
65
61
  // 不是操作下标,而是直接操作length或者自定义属性等
66
62
  var isNotHandlerIndex = Number.isNaN(index);
67
- if (isNotHandlerIndex && propertyKey !== 'length') {
63
+ if (isNotHandlerIndex && propertyKey !== "length") {
68
64
  return;
69
65
  }
70
66
  // 直接操作length
71
- if (propertyKey === 'length') {
67
+ if (propertyKey === "length") {
72
68
  var newLength = value;
73
69
  var oldLength = target.length;
74
70
  if (newLength > target.length) {
@@ -80,7 +76,7 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
80
76
  }
81
77
  // 通过操作length删除旧的行
82
78
  return function() {
83
- return callback.call(null, target, thisKey, 'splice', [
79
+ return callback.call(null, target, thisKey, "splice", [
84
80
  newLength,
85
81
  oldLength - newLength
86
82
  ]);
@@ -90,13 +86,13 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
90
86
  // 正常操作
91
87
  if (index === target.length) {
92
88
  return function() {
93
- return callback.call(null, target, thisKey, 'push', [
89
+ return callback.call(null, target, thisKey, "push", [
94
90
  value
95
91
  ]);
96
92
  };
97
93
  } else {
98
94
  return function() {
99
- return callback.call(null, target, thisKey, 'splice', [
95
+ return callback.call(null, target, thisKey, "splice", [
100
96
  index,
101
97
  1,
102
98
  value
@@ -105,11 +101,11 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
105
101
  }
106
102
  }
107
103
  }
108
- /**
109
- * 返回proxy操作对象
110
- * @param thisKey 当前对象在上级中的key
111
- * @param callback 需要在修改的时候,触发的回调函数
112
- * @param beforeSetCallback 需要在修改之前触发的回调函数,可以进行校验和对值的修改等等,最终的返回值不为undefined就会使用
104
+ /**
105
+ * 返回proxy操作对象
106
+ * @param thisKey 当前对象在上级中的key
107
+ * @param callback 需要在修改的时候,触发的回调函数
108
+ * @param beforeSetCallback 需要在修改之前触发的回调函数,可以进行校验和对值的修改等等,最终的返回值不为undefined就会使用
113
109
  * */ function handler(thisKey, callback, beforeSetCallback) {
114
110
  return {
115
111
  __engineProxy__: true,
@@ -132,9 +128,9 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
132
128
  var newValue = JSONCopy(value);
133
129
  // @ts-ignore
134
130
  var oldValue = target[propertyKey];
135
- var concatKey = thisKey === '' ? propertyKey : thisKey + '.' + propertyKey;
131
+ var concatKey = thisKey === "" ? propertyKey : thisKey + "." + propertyKey;
136
132
  function reProxyState(value) {
137
- if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === 'object' && value !== null) {
133
+ if (typeof value === "object" && value !== null) {
138
134
  // @ts-ignore
139
135
  if (value[engineProxyFlag] !== true) {
140
136
  return proxyState(value, callback, beforeSetCallback, concatKey);
@@ -183,22 +179,22 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
183
179
  }
184
180
  };
185
181
  }
186
- /**
187
- * 代理state数据
188
- * @param state 数据对象
189
- * @param callback 触发set时候的回调函数
190
- * @param beforeSetCallback
191
- * @param prevKey 递归对象的key
182
+ /**
183
+ * 代理state数据
184
+ * @param state 数据对象
185
+ * @param callback 触发set时候的回调函数
186
+ * @param beforeSetCallback
187
+ * @param prevKey 递归对象的key
192
188
  * */ export function proxyState(state, callback, beforeSetCallback) {
193
- var prevKey = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : '';
189
+ var prevKey = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "";
194
190
  // 冻结的对象不需要再执行proxy,否则会报错
195
191
  if (Object.isFrozen(state)) {
196
192
  return state;
197
193
  }
198
194
  for(var key in state){
199
- var concatKey = prevKey === '' ? key : prevKey + '.' + key;
195
+ var concatKey = prevKey === "" ? key : prevKey + "." + key;
200
196
  var obj = state[key];
201
- if ((typeof obj === "undefined" ? "undefined" : _type_of(obj)) === 'object' && obj !== null) {
197
+ if (typeof obj === "object" && obj !== null) {
202
198
  // @ts-ignore
203
199
  state[key] = proxyState(obj, callback, beforeSetCallback, concatKey);
204
200
  }
@@ -209,20 +205,20 @@ function flatInstanceForChildren(controls) {
209
205
  var result = [];
210
206
  controls.forEach(function(item) {
211
207
  result.push(item);
212
- if (item.controlType === 'layout' || item.controlType === 'wrap') {
208
+ if (item.controlType === "layout" || item.controlType === "wrap") {
213
209
  var _result;
214
210
  (_result = result).push.apply(_result, _to_consumable_array(flatInstanceForChildren(item.children)));
215
211
  }
216
212
  });
217
213
  return result;
218
214
  }
219
- /**
220
- * 在flatInstance中通过key查找出对应的instance
221
- * @param flatInstance 拍平的instance数组
222
- * @param key 操作的数据在state的key - 可以是深层次的 subtable.0.input等
215
+ /**
216
+ * 在flatInstance中通过key查找出对应的instance
217
+ * @param flatInstance 拍平的instance数组
218
+ * @param key 操作的数据在state的key - 可以是深层次的 subtable.0.input等
223
219
  * */ export function findItem(flatInstance, key, instanceMap) {
224
- if (key === '') return undefined;
225
- var keys = key.split('.');
220
+ if (key === "") return undefined;
221
+ var keys = key.split(".");
226
222
  if (keys.length === 0) return undefined;
227
223
  var oneKey = keys[0];
228
224
  var otherKeys = keys.slice(1);
@@ -257,28 +253,28 @@ function flatInstanceForChildren(controls) {
257
253
  }
258
254
  function getArrayNewValue(type, args) {
259
255
  if ([
260
- 'push',
261
- 'unshift'
256
+ "push",
257
+ "unshift"
262
258
  ].includes(type)) {
263
259
  return args;
264
- } else if (type === 'splice') {
260
+ } else if (type === "splice") {
265
261
  return args.slice(2);
266
262
  }
267
263
  return [];
268
264
  }
269
265
  function getArrayNewArgs(type, args, value) {
270
266
  if ([
271
- 'push',
272
- 'unshift'
267
+ "push",
268
+ "unshift"
273
269
  ].includes(type)) {
274
270
  return value;
275
- } else if (type === 'splice') {
271
+ } else if (type === "splice") {
276
272
  return args.slice(0, 2).concat(value);
277
273
  }
278
274
  }
279
- /**
280
- * TODO 数组劫持操作需要模仿vue3进行重构,不再直接劫持原生property
281
- * 劫持数组api,达到操作数组api的时候,可以同步操作instance
275
+ /**
276
+ * TODO 数组劫持操作需要模仿vue3进行重构,不再直接劫持原生property
277
+ * 劫持数组api,达到操作数组api的时候,可以同步操作instance
282
278
  * */ function hijackArrayProperty() {
283
279
  proxyArrayApi.forEach(function(key) {
284
280
  var oldApiHandler = Array.prototype[key];
@@ -307,8 +303,8 @@ function getArrayNewArgs(type, args, value) {
307
303
  // @ts-ignore
308
304
  result = oldApiHandler.apply(this, args);
309
305
  }
310
- typeof currentHandlerState.callback === 'function' && currentHandlerState.callback(key, args, result);
311
- currentHandlerState.type = '';
306
+ typeof currentHandlerState.callback === "function" && currentHandlerState.callback(key, args, result);
307
+ currentHandlerState.type = "";
312
308
  currentHandlerState.args = [];
313
309
  currentHandlerState.callback = emptyFn;
314
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";