@byteluck-fe/model-driven-engine 2.8.1-beta2 → 2.8.2-beta.12
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.
- package/dist/esm/common/ActionManager.js +6 -5
- package/dist/esm/common/DataManager.js +2 -2
- package/dist/esm/common/Engine.js +85 -94
- package/dist/esm/common/OkWorker.js +8 -8
- package/dist/esm/common/Runtime.js +27 -43
- package/dist/esm/common/Store.js +28 -8
- package/dist/esm/common/checkerValue.js +39 -59
- package/dist/esm/common/index.js +2 -2
- package/dist/esm/common/proxyState.js +38 -34
- package/dist/esm/index.js +3 -3
- package/dist/esm/plugins/CalcPlugin.js +21 -17
- package/dist/esm/plugins/ControlsEventPlugin.js +4 -4
- package/dist/esm/plugins/ES6ModulePlugin.js +6 -6
- package/dist/esm/plugins/LifecycleEventPlugin.js +7 -6
- package/dist/esm/plugins/StylePlugin.js +10 -9
- package/dist/esm/plugins/index.js +5 -5
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/runtimeUtils.js +4 -4
- package/dist/index.umd.js +6 -11
- package/dist/types/common/Engine.d.ts +2 -1
- package/dist/types/plugins/LifecycleEventPlugin.d.ts +1 -0
- package/package.json +4 -4
|
@@ -179,7 +179,7 @@ function _ts_generator(thisArg, body) {
|
|
|
179
179
|
};
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
|
-
import { error, logerror } from
|
|
182
|
+
import { error, logerror } from '@byteluck-fe/model-driven-shared';
|
|
183
183
|
export var ActionManager = /*#__PURE__*/ function() {
|
|
184
184
|
"use strict";
|
|
185
185
|
function ActionManager() {
|
|
@@ -237,9 +237,10 @@ export var ActionManager = /*#__PURE__*/ function() {
|
|
|
237
237
|
e = _state.sent();
|
|
238
238
|
// 执行的时候不使用throw error,而是使用console.error,避免阻塞内置代码的执行
|
|
239
239
|
logerror("".concat(action.id, " Exception during calling action: ").concat(e));
|
|
240
|
+
//尤其是在表单提交前事件异常,不能默认允许它通过。
|
|
240
241
|
return [
|
|
241
|
-
|
|
242
|
-
|
|
242
|
+
2,
|
|
243
|
+
false
|
|
243
244
|
];
|
|
244
245
|
case 4:
|
|
245
246
|
return [
|
|
@@ -254,7 +255,7 @@ export var ActionManager = /*#__PURE__*/ function() {
|
|
|
254
255
|
key: "addAction",
|
|
255
256
|
value: function addAction(name, func) {
|
|
256
257
|
if (this.actionMap.has(name)) {
|
|
257
|
-
error(
|
|
258
|
+
error('duplicated action key');
|
|
258
259
|
}
|
|
259
260
|
var action = new Action(name, func);
|
|
260
261
|
this.actionMap.set(name, action);
|
|
@@ -267,7 +268,7 @@ var Action = function Action(id, func) {
|
|
|
267
268
|
"use strict";
|
|
268
269
|
_class_call_check(this, Action);
|
|
269
270
|
_define_property(this, "func", void 0);
|
|
270
|
-
_define_property(this, "id",
|
|
271
|
+
_define_property(this, "id", '');
|
|
271
272
|
this.id = id;
|
|
272
273
|
this.func = func;
|
|
273
274
|
};
|
|
@@ -154,7 +154,7 @@ function _ts_generator(thisArg, body) {
|
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
import { JSONCopy, logerror } from
|
|
157
|
+
import { JSONCopy, logerror } from '@byteluck-fe/model-driven-shared';
|
|
158
158
|
export var DataManager = /*#__PURE__*/ function() {
|
|
159
159
|
"use strict";
|
|
160
160
|
function DataManager(callbackExecuter) {
|
|
@@ -190,7 +190,7 @@ export var DataManager = /*#__PURE__*/ function() {
|
|
|
190
190
|
return _async_to_generator(function() {
|
|
191
191
|
return _ts_generator(this, function(_state) {
|
|
192
192
|
if (_this.executer === undefined) {
|
|
193
|
-
logerror(
|
|
193
|
+
logerror('未初始化executer');
|
|
194
194
|
return [
|
|
195
195
|
2,
|
|
196
196
|
[]
|
|
@@ -44,6 +44,10 @@ function _async_to_generator(fn) {
|
|
|
44
44
|
});
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
+
function _call_super(_this, derived, args) {
|
|
48
|
+
derived = _get_prototype_of(derived);
|
|
49
|
+
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
50
|
+
}
|
|
47
51
|
function _class_call_check(instance, Constructor) {
|
|
48
52
|
if (!(instance instanceof Constructor)) {
|
|
49
53
|
throw new TypeError("Cannot call a class as a function");
|
|
@@ -222,28 +226,12 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
222
226
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
223
227
|
}
|
|
224
228
|
function _is_native_reflect_construct() {
|
|
225
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
226
|
-
if (Reflect.construct.sham) return false;
|
|
227
|
-
if (typeof Proxy === "function") return true;
|
|
228
229
|
try {
|
|
229
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
return
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
function _create_super(Derived) {
|
|
236
|
-
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
237
|
-
return function _createSuperInternal() {
|
|
238
|
-
var Super = _get_prototype_of(Derived), result;
|
|
239
|
-
if (hasNativeReflectConstruct) {
|
|
240
|
-
var NewTarget = _get_prototype_of(this).constructor;
|
|
241
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
242
|
-
} else {
|
|
243
|
-
result = Super.apply(this, arguments);
|
|
244
|
-
}
|
|
245
|
-
return _possible_constructor_return(this, result);
|
|
246
|
-
};
|
|
230
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
231
|
+
} catch (_) {}
|
|
232
|
+
return (_is_native_reflect_construct = function() {
|
|
233
|
+
return !!result;
|
|
234
|
+
})();
|
|
247
235
|
}
|
|
248
236
|
function _ts_generator(thisArg, body) {
|
|
249
237
|
var f, y, t, g, _ = {
|
|
@@ -340,49 +328,35 @@ function _ts_generator(thisArg, body) {
|
|
|
340
328
|
};
|
|
341
329
|
}
|
|
342
330
|
}
|
|
343
|
-
import { isDataBind } from
|
|
344
|
-
import { CONTROL_BASE_TYPE, CONTROL_TYPE, DEFAULT_LOCALE, error, genNonDuplicateId, isString, JSONCopy, log, RulesMessage, updateValueFromKeys, warn, Watcher, isBuiltInControls } from
|
|
345
|
-
import { Runtime } from
|
|
346
|
-
import { Store } from
|
|
347
|
-
import { findItem, proxyState } from
|
|
348
|
-
import { ActionManager } from
|
|
349
|
-
import { DataManager } from
|
|
350
|
-
import { checkerSubtableValue, checkerValue } from
|
|
351
|
-
|
|
331
|
+
import { isDataBind } from '@byteluck-fe/model-driven-core';
|
|
332
|
+
import { CONTROL_BASE_TYPE, CONTROL_TYPE, DEFAULT_LOCALE, error, genNonDuplicateId, isString, JSONCopy, log, RulesMessage, updateValueFromKeys, warn, Watcher, isBuiltInControls } from '@byteluck-fe/model-driven-shared';
|
|
333
|
+
import { Runtime } from './Runtime';
|
|
334
|
+
import { Store } from './Store';
|
|
335
|
+
import { findItem, proxyState } from './proxyState';
|
|
336
|
+
import { ActionManager } from './ActionManager';
|
|
337
|
+
import { DataManager } from './DataManager';
|
|
338
|
+
import { checkerSubtableValue, checkerValue } from './checkerValue';
|
|
339
|
+
import { buildUUID } from '../utils/runtimeUtils';
|
|
340
|
+
if (typeof window !== 'undefined') {
|
|
352
341
|
// @ts-ignore
|
|
353
342
|
window.engines = {};
|
|
354
343
|
}
|
|
355
344
|
// setState的时候,存储options中转变量
|
|
356
345
|
var eventOptionsTemp = null;
|
|
357
346
|
// 当前正在注册的插件名称
|
|
358
|
-
var applyingPluginName =
|
|
347
|
+
var applyingPluginName = '';
|
|
359
348
|
// 整体渲染引擎 并且 提供发布订阅能力
|
|
360
349
|
var Engine = /*#__PURE__*/ function(Watcher) {
|
|
361
350
|
"use strict";
|
|
362
351
|
_inherits(Engine, Watcher);
|
|
363
|
-
var _super = _create_super(Engine);
|
|
364
352
|
function Engine(props) {
|
|
365
353
|
_class_call_check(this, Engine);
|
|
366
354
|
var _this;
|
|
367
|
-
_this =
|
|
368
|
-
_define_property(
|
|
369
|
-
_define_property(_assert_this_initialized(_this), "rawStore", {});
|
|
370
|
-
_define_property(_assert_this_initialized(_this), "parent", void 0);
|
|
371
|
-
// 提供注册运行态控件以及实例化控件的能力
|
|
372
|
-
_define_property(_assert_this_initialized(_this), "runtime", void 0);
|
|
373
|
-
// 提供子线程处理脚本以及修改数据的能力
|
|
355
|
+
_this = _call_super(this, Engine), _define_property(_this, "store", void 0), _define_property(_this, "rawStore", {}), _define_property(_this, "parent", void 0), // 提供注册运行态控件以及实例化控件的能力
|
|
356
|
+
_define_property(_this, "runtime", void 0), // 提供子线程处理脚本以及修改数据的能力
|
|
374
357
|
// public worker: OkWorker
|
|
375
|
-
_define_property(
|
|
376
|
-
_define_property(
|
|
377
|
-
_define_property(_assert_this_initialized(_this), "externalParams", void 0);
|
|
378
|
-
// 提供外部注册插件,在不同的hooks触发时执行固定函数的能力
|
|
379
|
-
_define_property(_assert_this_initialized(_this), "__plugins", void 0);
|
|
380
|
-
_define_property(_assert_this_initialized(_this), "__pluginsApplied", false);
|
|
381
|
-
_define_property(_assert_this_initialized(_this), "$options", void 0);
|
|
382
|
-
_define_property(_assert_this_initialized(_this), "actionManager", new ActionManager());
|
|
383
|
-
_define_property(_assert_this_initialized(_this), "dataManager", void 0);
|
|
384
|
-
_define_property(_assert_this_initialized(_this), "_jobTasks", []);
|
|
385
|
-
_define_property(_assert_this_initialized(_this), "createControlInstance", _this.createInstance);
|
|
358
|
+
_define_property(_this, "isMounted", false), _define_property(_this, "id", genNonDuplicateId(8)), _define_property(_this, "externalParams", void 0), // 提供外部注册插件,在不同的hooks触发时执行固定函数的能力
|
|
359
|
+
_define_property(_this, "__plugins", void 0), _define_property(_this, "__pluginsApplied", false), _define_property(_this, "$options", void 0), _define_property(_this, "actionManager", new ActionManager()), _define_property(_this, "dataManager", void 0), _define_property(_this, "_jobTasks", []), _define_property(_this, "createControlInstance", _this.createInstance);
|
|
386
360
|
_this.$options = Object.freeze(props);
|
|
387
361
|
var _this_$options = _this.$options, _this_$options_autoMount = _this_$options.autoMount, autoMount = _this_$options_autoMount === void 0 ? true : _this_$options_autoMount, schema = _this_$options.schema, beforeCreateInstance = _this_$options.beforeCreateInstance, externalParams = _this_$options.externalParams, _this_$options_language = _this_$options.// fieldModel,
|
|
388
362
|
language, language = _this_$options_language === void 0 ? DEFAULT_LOCALE : _this_$options_language, _this_$options_debug = _this_$options.debug, debug = _this_$options_debug === void 0 ? false : _this_$options_debug;
|
|
@@ -396,7 +370,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
396
370
|
_this.store = new Store({
|
|
397
371
|
instance: _this.runtime.instance
|
|
398
372
|
});
|
|
399
|
-
_this.debugLog(
|
|
373
|
+
_this.debugLog('engine is Instantiation complete');
|
|
400
374
|
// 自动执行挂载完成,也可以手动调用mount方法
|
|
401
375
|
autoMount && _this.mount();
|
|
402
376
|
return _this;
|
|
@@ -443,7 +417,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
443
417
|
// 触发所有控件的默认值的change事件
|
|
444
418
|
this.setStates(this.getState());
|
|
445
419
|
this.debugLog("engine的mount方法调用结束");
|
|
446
|
-
if (this.debug && typeof window !==
|
|
420
|
+
if (this.debug && typeof window !== 'undefined') {
|
|
447
421
|
// @ts-ignore
|
|
448
422
|
window.engines[this.id] = this;
|
|
449
423
|
}
|
|
@@ -452,7 +426,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
452
426
|
{
|
|
453
427
|
key: "destroy",
|
|
454
428
|
value: function destroy() {
|
|
455
|
-
if (this.debug && typeof window !==
|
|
429
|
+
if (this.debug && typeof window !== 'undefined') {
|
|
456
430
|
// @ts-ignore
|
|
457
431
|
delete window.engines[this.id];
|
|
458
432
|
}
|
|
@@ -493,7 +467,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
493
467
|
checkerSubtableValue(fieldTypeMap, row, emptyState));
|
|
494
468
|
});
|
|
495
469
|
}
|
|
496
|
-
var keys = key.split(
|
|
470
|
+
var keys = key.split('.');
|
|
497
471
|
var lastKey = keys[keys.length - 1];
|
|
498
472
|
try {
|
|
499
473
|
return checkerValue(instance.fieldType, lastKey, newValue, oldValue);
|
|
@@ -526,7 +500,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
526
500
|
var newRows = [];
|
|
527
501
|
for(var i = 0; i < len; i++){
|
|
528
502
|
// @ts-ignore
|
|
529
|
-
var row = _this.listControlCreateRow(subtable,
|
|
503
|
+
var row = _this.listControlCreateRow(subtable, 'subtable-row');
|
|
530
504
|
row && newRows.push(row);
|
|
531
505
|
}
|
|
532
506
|
// @ts-ignore
|
|
@@ -541,8 +515,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
541
515
|
if (type && args) {
|
|
542
516
|
// const subtableOldLength = subtable.children.length
|
|
543
517
|
switch(type){
|
|
544
|
-
case
|
|
545
|
-
case
|
|
518
|
+
case 'push':
|
|
519
|
+
case 'unshift':
|
|
546
520
|
var _subtable_children;
|
|
547
521
|
var newRowLengths = args.length;
|
|
548
522
|
createdNewRows = createRows(newRowLengths);
|
|
@@ -550,7 +524,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
550
524
|
(_subtable_children = subtable.children)[type].apply(_subtable_children, _to_consumable_array(createdNewRows));
|
|
551
525
|
this.runtime.getFlatInstances();
|
|
552
526
|
break;
|
|
553
|
-
case
|
|
527
|
+
case 'splice':
|
|
554
528
|
if (args.length > 2) {
|
|
555
529
|
var // @ts-ignore
|
|
556
530
|
_subtable_children1;
|
|
@@ -592,24 +566,26 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
592
566
|
this.runtime.getFlatInstances();
|
|
593
567
|
break;
|
|
594
568
|
}
|
|
595
|
-
if (type ===
|
|
569
|
+
if (type === 'splice') {
|
|
596
570
|
deleted = result;
|
|
597
571
|
} else if ([
|
|
598
|
-
|
|
599
|
-
|
|
572
|
+
'pop',
|
|
573
|
+
'shift'
|
|
600
574
|
].includes(type)) {
|
|
601
575
|
deleted = [
|
|
602
576
|
result
|
|
603
577
|
];
|
|
604
578
|
}
|
|
605
|
-
this.
|
|
579
|
+
var subtableData = this.getState(subtable.id);
|
|
580
|
+
this._handlerSubtableUpdateUid(subtableData);
|
|
581
|
+
this.emit('list-change', {
|
|
606
582
|
instance: subtable,
|
|
607
|
-
value:
|
|
583
|
+
value: subtableData,
|
|
608
584
|
options: Object.assign({}, options, {
|
|
609
585
|
changed: createdNewRows,
|
|
610
586
|
data: createdNewRowsData,
|
|
611
587
|
deleted: deleted !== null && deleted !== void 0 ? deleted : [],
|
|
612
|
-
jsonValue: JSON.stringify(
|
|
588
|
+
jsonValue: JSON.stringify(subtableData),
|
|
613
589
|
isDeleteLastOne: isDeleteLastOne,
|
|
614
590
|
type: type,
|
|
615
591
|
args: args
|
|
@@ -620,6 +596,19 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
620
596
|
}
|
|
621
597
|
}
|
|
622
598
|
},
|
|
599
|
+
{
|
|
600
|
+
key: "_handlerSubtableUpdateUid",
|
|
601
|
+
value: function _handlerSubtableUpdateUid(subtableData) {
|
|
602
|
+
;
|
|
603
|
+
subtableData.forEach(function(item) {
|
|
604
|
+
if (!item.uid) {
|
|
605
|
+
Object.assign(item, {
|
|
606
|
+
uid: 'new:' + buildUUID('uid')
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
},
|
|
623
612
|
{
|
|
624
613
|
key: "_handlerObjectUpdate",
|
|
625
614
|
value: function _handlerObjectUpdate(state, key, value, oldValue) {
|
|
@@ -639,7 +628,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
639
628
|
var newRows = [];
|
|
640
629
|
for(var i = 0; i < newValue.length; i++){
|
|
641
630
|
// @ts-ignore
|
|
642
|
-
var row = this.listControlCreateRow(instance,
|
|
631
|
+
var row = this.listControlCreateRow(instance, 'subtable-row');
|
|
643
632
|
row && newRows.push(row);
|
|
644
633
|
}
|
|
645
634
|
(_instance_children = instance.children).push.apply(_instance_children, _to_consumable_array(newRows));
|
|
@@ -652,7 +641,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
652
641
|
if ((options === null || options === void 0 ? void 0 : options.setData) === true) {
|
|
653
642
|
deleted = [];
|
|
654
643
|
}
|
|
655
|
-
this.
|
|
644
|
+
this._handlerSubtableUpdateUid(newValue);
|
|
645
|
+
this.emit('list-change', {
|
|
656
646
|
instance: instance,
|
|
657
647
|
value: value,
|
|
658
648
|
options: _object_spread_props(_object_spread({}, options), {
|
|
@@ -661,11 +651,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
661
651
|
data: newValue,
|
|
662
652
|
deleted: deleted,
|
|
663
653
|
// deleted: oldValue ?? [],
|
|
664
|
-
type:
|
|
654
|
+
type: 'push',
|
|
655
|
+
jsonValue: JSON.stringify(newValue)
|
|
665
656
|
})
|
|
666
657
|
});
|
|
667
658
|
} else {
|
|
668
|
-
this.emit(
|
|
659
|
+
this.emit('change', {
|
|
669
660
|
instance: instance,
|
|
670
661
|
value: this.getState(instance.id, index),
|
|
671
662
|
rowIndex: index,
|
|
@@ -689,7 +680,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
689
680
|
} catch (e) {
|
|
690
681
|
error("".concat(applyingPluginName, " Plugin apply Error \n ").concat(e));
|
|
691
682
|
} finally{
|
|
692
|
-
applyingPluginName =
|
|
683
|
+
applyingPluginName = '';
|
|
693
684
|
}
|
|
694
685
|
});
|
|
695
686
|
this.__pluginsApplied = true;
|
|
@@ -699,20 +690,20 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
699
690
|
key: "listControlCreateRow",
|
|
700
691
|
value: function listControlCreateRow(instance, rowType) {
|
|
701
692
|
var row;
|
|
702
|
-
if (rowType ===
|
|
693
|
+
if (rowType === 'subtable-row') {
|
|
703
694
|
row = {
|
|
704
695
|
children: [],
|
|
705
696
|
controlType: CONTROL_BASE_TYPE.LAYOUT,
|
|
706
697
|
id: genNonDuplicateId(),
|
|
707
|
-
type:
|
|
698
|
+
type: 'subtable-row',
|
|
708
699
|
props: {
|
|
709
|
-
caption:
|
|
700
|
+
caption: '',
|
|
710
701
|
isHide: false,
|
|
711
702
|
style: {
|
|
712
|
-
height:
|
|
713
|
-
heightConfig:
|
|
714
|
-
width:
|
|
715
|
-
widthConfig:
|
|
703
|
+
height: '',
|
|
704
|
+
heightConfig: 'fill',
|
|
705
|
+
width: '',
|
|
706
|
+
widthConfig: 'fill'
|
|
716
707
|
}
|
|
717
708
|
},
|
|
718
709
|
fieldType: undefined,
|
|
@@ -766,7 +757,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
766
757
|
key: "listControlAddRow",
|
|
767
758
|
value: function listControlAddRow(instance) {
|
|
768
759
|
var // @ts-ignore
|
|
769
|
-
rowType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] :
|
|
760
|
+
rowType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 'subtable-row';
|
|
770
761
|
var row = this.listControlCreateRow(instance, rowType);
|
|
771
762
|
if (!row) return;
|
|
772
763
|
instance.children.push(row);
|
|
@@ -785,12 +776,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
785
776
|
return _ts_generator(this, function(_state) {
|
|
786
777
|
switch(_state.label){
|
|
787
778
|
case 0:
|
|
788
|
-
if (!(eventKey ===
|
|
779
|
+
if (!(eventKey === 'engine-mounted')) return [
|
|
789
780
|
3,
|
|
790
781
|
3
|
|
791
782
|
];
|
|
792
783
|
if (_this1.isMounted) {
|
|
793
|
-
warn(
|
|
784
|
+
warn('The engine-mounted life cycle can only be triggered once');
|
|
794
785
|
return [
|
|
795
786
|
2,
|
|
796
787
|
Promise.resolve([])
|
|
@@ -800,7 +791,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
800
791
|
3,
|
|
801
792
|
2
|
|
802
793
|
];
|
|
803
|
-
console.time(
|
|
794
|
+
console.time('engine-mounted need wait');
|
|
804
795
|
needWait = _to_consumable_array(_this1._jobTasks);
|
|
805
796
|
return [
|
|
806
797
|
4,
|
|
@@ -808,7 +799,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
808
799
|
];
|
|
809
800
|
case 1:
|
|
810
801
|
_state.sent();
|
|
811
|
-
console.timeEnd(
|
|
802
|
+
console.timeEnd('engine-mounted need wait');
|
|
812
803
|
_state.label = 2;
|
|
813
804
|
case 2:
|
|
814
805
|
_this1.isMounted = true;
|
|
@@ -973,9 +964,9 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
973
964
|
key: "setState",
|
|
974
965
|
value: function setState(controlId, value, rowIndex, options) {
|
|
975
966
|
eventOptionsTemp = options;
|
|
976
|
-
this.debugLog(
|
|
967
|
+
this.debugLog('[%o]: 触发setState, 修改的值为%o, rowIndex=%o, options=%o', controlId, value, rowIndex, options);
|
|
977
968
|
this.store.setState(controlId, value, rowIndex);
|
|
978
|
-
this.debugLog(
|
|
969
|
+
this.debugLog('[%o]: setState完成, 修改的值为%o, rowIndex=%o', controlId, value, rowIndex);
|
|
979
970
|
eventOptionsTemp = null;
|
|
980
971
|
}
|
|
981
972
|
},
|
|
@@ -1062,7 +1053,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1062
1053
|
var _controlIdMapping_controlId_children_key_dataBind, _controlIdMapping_controlId_children_key, _controlIdMapping_controlId;
|
|
1063
1054
|
var fieldCode = (_controlIdMapping_controlId = controlIdMapping[controlId]) === null || _controlIdMapping_controlId === void 0 ? void 0 : (_controlIdMapping_controlId_children_key = _controlIdMapping_controlId.children[key]) === null || _controlIdMapping_controlId_children_key === void 0 ? void 0 : (_controlIdMapping_controlId_children_key_dataBind = _controlIdMapping_controlId_children_key.dataBind) === null || _controlIdMapping_controlId_children_key_dataBind === void 0 ? void 0 : _controlIdMapping_controlId_children_key_dataBind.fieldCode;
|
|
1064
1055
|
//未绑定字段的控件,直接抛弃
|
|
1065
|
-
if (fieldCode !==
|
|
1056
|
+
if (fieldCode !== '') {
|
|
1066
1057
|
var _controlIdMapping_controlId1;
|
|
1067
1058
|
if (fieldCode) {
|
|
1068
1059
|
obj[fieldCode] = item[key];
|
|
@@ -1093,7 +1084,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1093
1084
|
var _controlIdMapping_key_children_keyChi;
|
|
1094
1085
|
var fieldCode = (_controlIdMapping_key_children_keyChi = controlIdMapping[key].children[keyChi]) === null || _controlIdMapping_key_children_keyChi === void 0 ? void 0 : _controlIdMapping_key_children_keyChi.dataBind.fieldCode;
|
|
1095
1086
|
//未绑定字段的控件,直接抛弃
|
|
1096
|
-
if (fieldCode !==
|
|
1087
|
+
if (fieldCode !== '') {
|
|
1097
1088
|
if (fieldCode) {
|
|
1098
1089
|
objChi[fieldCode] = item[keyChi];
|
|
1099
1090
|
} else {
|
|
@@ -1314,9 +1305,9 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1314
1305
|
});
|
|
1315
1306
|
newRow[fieldMapping.controlId] = objValue;
|
|
1316
1307
|
}
|
|
1317
|
-
} else if (fieldCode ===
|
|
1308
|
+
} else if (fieldCode === 'uid' && row.uid !== undefined) {
|
|
1318
1309
|
newRow.uid = row.uid;
|
|
1319
|
-
} else if (fieldCode ===
|
|
1310
|
+
} else if (fieldCode === 'virtualStore' && row.virtualStore !== undefined) {
|
|
1320
1311
|
newRow.virtualStore = Object.freeze(row.virtualStore);
|
|
1321
1312
|
}
|
|
1322
1313
|
});
|
|
@@ -1368,7 +1359,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1368
1359
|
var _newState_newMapping_controlId;
|
|
1369
1360
|
var mainStateKeys = Object.keys((_newState_newMapping_controlId = newState === null || newState === void 0 ? void 0 : newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) !== null && _newState_newMapping_controlId !== void 0 ? _newState_newMapping_controlId : {});
|
|
1370
1361
|
mappingKeys === null || mappingKeys === void 0 ? void 0 : mappingKeys.forEach(function(key) {
|
|
1371
|
-
if (!mainStateKeys.includes(key) && key !==
|
|
1362
|
+
if (!mainStateKeys.includes(key) && key !== 'uid' && newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) {
|
|
1372
1363
|
if (Object.keys(newState).length) {
|
|
1373
1364
|
Object.assign(newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId], _define_property({}, key, mappingValue[key]));
|
|
1374
1365
|
} else {
|
|
@@ -1505,14 +1496,14 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1505
1496
|
value: function setInstance(instance, props, value, rowIndex) {
|
|
1506
1497
|
var _this = this;
|
|
1507
1498
|
try {
|
|
1508
|
-
if (typeof instance ===
|
|
1499
|
+
if (typeof instance === 'string' && rowIndex === -1) {
|
|
1509
1500
|
//修改明细表整列属性的逻辑
|
|
1510
1501
|
var instances = this.getInstances(instance, rowIndex === -1);
|
|
1511
1502
|
instances.map(function(_instance) {
|
|
1512
1503
|
if (_instance) {
|
|
1513
1504
|
_this.debugLog("[%o]: 修改instance: %o的%o属性,修改的值为%o。", _instance.id, _instance, props, value);
|
|
1514
1505
|
updateValueFromKeys(_instance.props, props, value);
|
|
1515
|
-
_this.schemaEvent(
|
|
1506
|
+
_this.schemaEvent('schema-change', {
|
|
1516
1507
|
instance: _instance,
|
|
1517
1508
|
props: props,
|
|
1518
1509
|
value: value,
|
|
@@ -1522,7 +1513,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1522
1513
|
});
|
|
1523
1514
|
} else {
|
|
1524
1515
|
var _instance;
|
|
1525
|
-
if (typeof instance ===
|
|
1516
|
+
if (typeof instance === 'string') {
|
|
1526
1517
|
_instance = this.getInstance(instance, rowIndex);
|
|
1527
1518
|
} else {
|
|
1528
1519
|
_instance = instance;
|
|
@@ -1532,7 +1523,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1532
1523
|
}
|
|
1533
1524
|
this.debugLog("[%o]: 修改instance: %o的%o属性,修改的值为%o。", _instance.id, _instance, props, value);
|
|
1534
1525
|
updateValueFromKeys(_instance.props, props, value);
|
|
1535
|
-
this.schemaEvent(
|
|
1526
|
+
this.schemaEvent('schema-change', {
|
|
1536
1527
|
instance: _instance,
|
|
1537
1528
|
props: props,
|
|
1538
1529
|
value: value,
|
|
@@ -1659,7 +1650,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1659
1650
|
CONTROL_TYPE.SUBTABLE_COLUMN);
|
|
1660
1651
|
if (isColumnChild) {
|
|
1661
1652
|
var instanceList = this.runtime.instanceMap[instance.id];
|
|
1662
|
-
if (Object.prototype.toString.call(instanceList) ===
|
|
1653
|
+
if (Object.prototype.toString.call(instanceList) === '[object Array]') {
|
|
1663
1654
|
var index = instanceList.findIndex(function(item) {
|
|
1664
1655
|
return item === instance;
|
|
1665
1656
|
});
|
|
@@ -1765,7 +1756,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1765
1756
|
key: "register",
|
|
1766
1757
|
value: // 注册外部控件
|
|
1767
1758
|
function register(control) {
|
|
1768
|
-
return Runtime.register(control,
|
|
1759
|
+
return Runtime.register(control, 'Runtime');
|
|
1769
1760
|
}
|
|
1770
1761
|
},
|
|
1771
1762
|
{
|
|
@@ -30,7 +30,7 @@ function _define_property(obj, key, value) {
|
|
|
30
30
|
}
|
|
31
31
|
return obj;
|
|
32
32
|
}
|
|
33
|
-
import { log } from
|
|
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:
|
|
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(
|
|
80
|
+
log('🚀 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:
|
|
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(
|
|
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:
|
|
121
|
+
action: 'delete',
|
|
122
122
|
payload: {
|
|
123
|
-
key:
|
|
124
|
-
value:
|
|
123
|
+
key: 'key3[0].key1',
|
|
124
|
+
value: 'index'
|
|
125
125
|
}
|
|
126
126
|
});
|
|
127
127
|
});
|